Skip to content
Snippets Groups Projects
Commit 03dcdaf6 authored by Adam Edward Barton's avatar Adam Edward Barton :speech_balloon:
Browse files

Merge branch 'muAmdcART' into 'master'

Add OutputFileName property to AGDDTools

See merge request atlas/athena!33857
parents 2101bb30 c22c80a1
No related branches found
No related tags found
No related merge requests found
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
#ifndef MuonAGDDTool_H
......@@ -20,8 +20,7 @@ class IToolSvc;
class MuonAGDDTool: public AGDDToolBase
{
public:
MuonAGDDTool(const std::string& type, const std::string& name,
const IInterface* parent);
MuonAGDDTool(const std::string& type, const std::string& name, const IInterface* parent);
virtual StatusCode construct();
virtual StatusCode initialize();
......@@ -32,6 +31,8 @@ private:
std::vector<std::string> m_structuresFromFlags;
std::string m_outFileType;
std::string m_outPREsqlName;
std::string m_DBFileName;
std::string m_agdd2GeoSvcName;
bool m_readAGDD;
bool m_dumpAGDD;
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
#ifndef NSWAGDDTool_H
......@@ -17,8 +17,7 @@ namespace MuonGM
class NSWAGDDTool: public AGDDToolBase
{
public:
NSWAGDDTool(const std::string& type, const std::string& name,
const IInterface* parent);
NSWAGDDTool(const std::string& type, const std::string& name, const IInterface* parent);
virtual StatusCode construct();
virtual StatusCode initialize();
......@@ -36,6 +35,8 @@ private:
std::string m_outFileType;
std::string m_outPREsqlName;
std::string m_DBFileName;
std::string m_agdd2GeoSvcName;
bool m_readAGDD;
bool m_dumpAGDD;
......
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
#include "MuonAGDD/MuonAGDDTool.h"
......@@ -16,19 +16,23 @@
using namespace MuonGM;
MuonAGDDTool::MuonAGDDTool(const std::string& type, const std::string& name,
const IInterface* parent):AGDDToolBase(type,name,parent),
m_overrideConfiguration(false),m_buildNSW(true)
MuonAGDDTool::MuonAGDDTool(const std::string& type, const std::string& name, const IInterface* parent) :
AGDDToolBase(type,name,parent),
m_outPREsqlName(""),
m_overrideConfiguration(false),
m_buildNSW(true)
#ifndef SIMULATIONBASE
, p_AmdcsimrecAthenaSvc ( "AmdcsimrecAthenaSvc",name )
#endif
{
declareProperty( "Structures" , m_structuresToBuild);
declareProperty( "ReadAGDD", m_readAGDD = true);
declareProperty( "DumpAGDD", m_dumpAGDD = false);
declareProperty( "DumpAGDD", m_dumpAGDD = false, "write blob from DB into text file");
declareProperty( "OverrideConfiguration",m_overrideConfiguration = false);
declareProperty( "BuildNSW", m_buildNSW = true);
declareProperty( "OutputFileType", m_outFileType = "AGDD", "Name for database table");
declareProperty( "OutputFileName", m_DBFileName = "", "specify name for DB text file");
declareProperty( "AGDDtoGeoSvcName", m_agdd2GeoSvcName = "AGDDtoGeoSvc", "specify name of AGDDtoGeoSvc");
}
StatusCode MuonAGDDTool::initialize()
......@@ -39,6 +43,10 @@ StatusCode MuonAGDDTool::initialize()
ATH_CHECK(AGDDToolBase::initialize());
if (m_DBFileName.empty()) {
m_DBFileName = "Generated_" + m_outFileType + "_pool.txt";
}
// please see more details on regarding the dependency on AMDB on ATLASSIM-3636
// and the CMakeLists.txt . the NSWAGDDTool avoids the dependency already
#ifndef SIMULATIONBASE
......@@ -48,6 +56,7 @@ StatusCode MuonAGDDTool::initialize()
if (m_buildNSW)
{
MuonAGDDToolHelper theHelper;
theHelper.setAGDDtoGeoSvcName(m_agdd2GeoSvcName);
theHelper.SetNSWComponents();
}
......@@ -58,7 +67,8 @@ StatusCode MuonAGDDTool::initialize()
StatusCode MuonAGDDTool::construct()
{
MuonAGDDToolHelper theHelper;
theHelper.setAGDDtoGeoSvcName(m_agdd2GeoSvcName);
m_controller->UseGeoModelDetector("Muon");
if (!m_locked)
......@@ -81,8 +91,8 @@ StatusCode MuonAGDDTool::construct()
}
ATH_MSG_INFO(" now reading AGDD blob ");
std::string AGDDfile=theHelper.GetAGDD(m_dumpAGDD, m_outFileType);
std::string AGDDfile=theHelper.GetAGDD(m_dumpAGDD, m_outFileType, m_DBFileName);
#ifndef SIMULATIONBASE
if(m_writeDBfile) AGDDfile = p_AmdcsimrecAthenaSvc->GetAgddString();
#endif
......
......@@ -38,12 +38,15 @@
#include "MuonAGDDBase/mmSpacer_TechHandler.h"
#include "MuonAGDDBase/mm_readoutHandler.h"
#include <TString.h> // for Form
#include <fstream>
using namespace MuonGM;
MuonAGDDToolHelper::MuonAGDDToolHelper()
{
MuonAGDDToolHelper::MuonAGDDToolHelper() :
p_RDBAccessSvc(nullptr),
p_GeoModelSvc(nullptr),
m_svcName("AGDDtoGeoSvc") {
StatusCode result;
result=Gaudi::svcLocator()->service("GeoModelSvc",p_GeoModelSvc);
......@@ -64,10 +67,8 @@ std::vector<std::string>& MuonAGDDToolHelper::ReadAGDDFlags()
structuresFromFlags.clear();
std::string agdd2geoVersion = p_RDBAccessSvc->getChildTag("AGDD2GeoSwitches",p_GeoModelSvc->muonVersion(),"MuonSpectrometer");
// m_AGDD2GeoSwitches.clear();
if(!agdd2geoVersion.empty())
{
// m_AGDD2GeoSwitchesStamp = m_AGDD2GeoSwitchesStamp + 1;
std::string TheKEYNAME;
int TheKEYVALUE;
IRDBRecordset_ptr pIRDBRecordset = p_RDBAccessSvc->getRecordsetPtr("AGDD2GeoSwitches",p_GeoModelSvc->muonVersion(),"MuonSpectrometer");
......@@ -78,8 +79,6 @@ std::vector<std::string>& MuonAGDDToolHelper::ReadAGDDFlags()
TheKEYVALUE = record->getInt("KEYVALUE");
if ( TheKEYVALUE == 1 )
{
// std::cout<<" Add to m_AGDD2GeoSwitches " << TheKEYNAME <<std::endl;
// if (aliases->IsAliased(TheKEYNAME))
structuresFromFlags.push_back(TheKEYNAME);
}
}
......@@ -92,7 +91,7 @@ std::vector<std::string>& MuonAGDDToolHelper::ReadAGDDFlags()
}
std::string MuonAGDDToolHelper::GetAGDD(bool dumpIt, std::string tableName)
std::string MuonAGDDToolHelper::GetAGDD(const bool dumpIt, const std::string& tableName, const std::string& outFileName)
{
const IGeoModelSvc * geoModel=p_GeoModelSvc;
......@@ -125,11 +124,7 @@ std::string MuonAGDDToolHelper::GetAGDD(bool dumpIt, std::string tableName)
if (dumpIt)
{
std::ofstream GeneratedFile;
std::string fileName;
fileName.append("Generated_");
fileName.append(tableName);
fileName.append("_pool.txt");
GeneratedFile.open(fileName);
GeneratedFile.open(outFileName);
GeneratedFile<<AgddString<<std::endl;
GeneratedFile.close();
}
......@@ -140,45 +135,20 @@ std::string MuonAGDDToolHelper::GetAGDD(bool dumpIt, std::string tableName)
bool MuonAGDDToolHelper::BuildMScomponents() const
{
// ATH_MSG_INFO("BuildMScomponents - start");
StoreGateSvc* pDetStore=0;
StoreGateSvc* pDetStore=nullptr;
ISvcLocator* svcLocator = Gaudi::svcLocator();
StatusCode sc=svcLocator->service("DetectorStore",pDetStore);
if (sc.isFailure())
{
// ATH_MSG_ERROR("AGDDController could not get at the detector store!");
}
MuonGM::MuonDetectorManager* muonMgr;
sc = pDetStore->retrieve( muonMgr );
if ( sc.isFailure() ) {
// ATH_MSG_ERROR(" Cannot retrieve MuonDetectorManager " );
return false;
}
if (svcLocator->service("DetectorStore",pDetStore).isFailure()) return false;
MuonGM::MuonDetectorManager* muonMgr=nullptr;
if (pDetStore->retrieve(muonMgr).isFailure()) return false;
bool readoutGeoDone = BuildReadoutGeometry(muonMgr/*, GetMSdetectors*/);
if (!readoutGeoDone) {
// ATH_MSG_INFO(" Problems met while building the ReadoutGeometry " );
return false;
}
// else ATH_MSG_INFO( "ReadoutGeometry created" );
// ATH_MSG_INFO("In BuildMScomponents - done");
if (!readoutGeoDone) return false;
return true;
}
bool MuonAGDDToolHelper::BuildReadoutGeometry(MuonGM::MuonDetectorManager* mgr/*, std::map<GeoFullPhysVol*, std::string>* vec*/) const
{
bool geoBuilt = true;
// ATH_MSG_INFO("In BuildReadoutGeometry - start");
//std::map<std::string, GeoFullPhysVol*>* myMap = NULL;
//myMap = GetMSdetectors();
//log<<MSG::INFO<<"In AGDD2GeoSvc::BuildReadoutGeometry - size of the detector map = "<<myMap->size()<<endmsg;
//std::map<std::string, GeoFullPhysVol*>::const_iterator it;
detectorList& dList=AGDDDetectorStore::GetDetectorStore()->GetDetectorList();
detectorList::const_iterator it;
for (it=dList.begin(); it!=dList.end(); ++it)
......@@ -188,7 +158,6 @@ bool MuonAGDDToolHelper::BuildReadoutGeometry(MuonGM::MuonDetectorManager* mgr/*
{
std::string chTag = dPos[i]->ID.detectorAddress;
GeoFullPhysVol* vol = dPos[i]->theVolume;
// ATH_MSG_INFO("Building RE for component named <"<<chTag<<">");
std::string stName = chTag.substr(0,4);
......@@ -205,20 +174,10 @@ bool MuonAGDDToolHelper::BuildReadoutGeometry(MuonGM::MuonDetectorManager* mgr/*
phiIndex = atoi((chTag.substr(12,1)).c_str());
mLayer = atoi((chTag.substr(7,1)).c_str());
//MuonReadoutElement* re = NULL;
if (chTag.substr(0,3)=="sMD")
{
MMReadoutElement* re = new MMReadoutElement((GeoVFullPhysVol*)vol, stName, etaIndex, phiIndex, mLayer, false, mgr);
std::string myVolName = (chTag.substr(0,8)).c_str();
/* AGDDParameterBagMM* MMparaBag = dynamic_cast<AGDDParameterBagMM*> (AGDDParameterStore::GetParameterStore()->GetParameterBag(myVolName));
if(!MMparaBag) {
std::cout << " not possible to retrieve parameters for <" << myVolName << ": quitting! >" << std::endl;
return false;
}
double pitch;
if(iLS==1) pitch = MMparaBag->TechParameters->pitchSS; //small
else pitch = MMparaBag->TechParameters->pitchLS; //large
re->initDesign(MMparaBag->largeX, MMparaBag->smallX, MMparaBag->lengthY, pitch, MMparaBag->TechParameters->thickness); */
re->initDesign(-999., -999., -999., -999., -999.);
re->fillCache();
mgr->addMMReadoutElement_withIdFields(re, iLS, etaIndex, phiIndex, mLayer);
......@@ -228,43 +187,23 @@ bool MuonAGDDToolHelper::BuildReadoutGeometry(MuonGM::MuonDetectorManager* mgr/*
{
sTgcReadoutElement* re = new sTgcReadoutElement((GeoVFullPhysVol*)vol, stName, etaIndex, phiIndex, mLayer, false, mgr);
std::string myVolName = (chTag.substr(0,8)).c_str();
/*
AGDDParameterBagsTGC* sTGCparaBag = dynamic_cast<AGDDParameterBagsTGC*> (AGDDParameterStore::GetParameterStore()->GetParameterBag(myVolName));
if(!sTGCparaBag) {
std::cout << " not possible to retrieve parameters for <" << myVolName << ": quitting! >" << std::endl;
return false;
}
re->initDesign(sTGCparaBag->largeX, sTGCparaBag->smallX, sTGCparaBag->lengthY, sTGCparaBag->TechParameters->stripPitch,
sTGCparaBag->TechParameters->wirePitch, sTGCparaBag->TechParameters->stripWidth, sTGCparaBag->TechParameters->wireWidth,
sTGCparaBag->TechParameters->thickness);
since the concept of Parameter Bag is dismissed things get hardcoded
initDesign for sTGCReadoutElement only uses stripPitch, strip Width and thickness - all other dimensions (here -999.) are (hard)coded there again
*/
re->initDesign(-999., -999., -999., 3.2, -999., 2.7, -999., 2.6);
re->fillCache();
mgr->addsTgcReadoutElement_withIdFields(re, iLS, etaIndex, phiIndex, mLayer);
re->setDelta(mgr);
}
}
//aggdContainer->push_back(*it);
}
//std::cout<<"Size of the NSWdetectors = <"<<vec->size()<<"> "<<aggdContainer->size()<<std::cout;
//sc=pDetStore->record( aggdContainer ,"NSWdetectors");
return geoBuilt;
}
void MuonAGDDToolHelper::SetNSWComponents()
{
IAGDDtoGeoSvc* agddsvc;
StatusCode result;
result=Gaudi::svcLocator()->service("AGDDtoGeoSvc",agddsvc);
if (result.isFailure())
{
std::cout<<"could not initialize AGDDtoGeoSvc!!! "<<std::endl;
}
IAGDDtoGeoSvc* agddsvc = nullptr;
if (Gaudi::svcLocator()->service(m_svcName,agddsvc).isFailure()) {
throw std::runtime_error(Form("File: %s, Line: %d\nMuonAGDDToolHelper::SetNSWComponents() - Could not retrieve %s from ServiceLocator", __FILE__, __LINE__, m_svcName.c_str()));
}
agddsvc->addHandler(new micromegasHandler("micromegas"));
agddsvc->addHandler(new mm_TechHandler("mm_Tech"));
......@@ -275,3 +214,7 @@ void MuonAGDDToolHelper::SetNSWComponents()
agddsvc->addHandler(new mmSpacer_TechHandler("mmSpacer_Tech"));
agddsvc->addHandler(new mm_readoutHandler("mm_readout"));
}
void MuonAGDDToolHelper::setAGDDtoGeoSvcName(const std::string& name) {
m_svcName = name;
}
\ No newline at end of file
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
#ifndef MUONAGDD_MUONAGDDTOOLHELPER_H
......@@ -25,15 +25,18 @@ public:
void SetNSWComponents();
std::string GetAGDD(bool dumpIt, std::string tableName);
std::string GetAGDD(const bool dumpIt, const std::string& tableName, const std::string& outFileName);
bool BuildMScomponents() const;
bool BuildReadoutGeometry(MuonGM::MuonDetectorManager* mgr) const;
void setAGDDtoGeoSvcName(const std::string& name);
private:
IRDBAccessSvc* p_RDBAccessSvc;
IGeoModelSvc* p_GeoModelSvc;
std::string m_svcName;
};
......
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
#include "MuonAGDD/NSWAGDDTool.h"
#include "MuonAGDDToolHelper.h"
#include "AGDDControl/AGDDController.h"
#include "AGDDControl/AGDD2GeoModelBuilder.h"
#include "AGDD2GeoSvc/IAGDD2GeoSvc.h"
#include "AGDDModel/AGDDParameterStore.h"
#include "AGDDKernel/AGDDDetector.h"
#include "AGDDKernel/AGDDDetectorStore.h"
#include <fstream>
using namespace MuonGM;
NSWAGDDTool::NSWAGDDTool(const std::string& type, const std::string& name,
const IInterface* parent):AGDDToolBase(type,name,parent)
NSWAGDDTool::NSWAGDDTool(const std::string& type, const std::string& name, const IInterface* parent) :
AGDDToolBase(type,name,parent),
m_outPREsqlName("")
{
declareProperty( "ReadAGDD", m_readAGDD = true, "read description from DB");
declareProperty( "DumpAGDD", m_dumpAGDD = false, "write out parsed XML");
......@@ -28,6 +30,8 @@ NSWAGDDTool::NSWAGDDTool(const std::string& type, const std::string& name,
declareProperty( "OutputFilePASVNAME", m_outFilePasN = "", "passive structure version string");
declareProperty( "OutputFileFORMAT", m_outFileForm = "AGDDXML", "format of output file");
declareProperty( "OutputFileType", m_outFileType = "NSWD", "name for database table");
declareProperty( "OutputFileName", m_DBFileName = "", "specify name for DB text file");
declareProperty( "AGDDtoGeoSvcName", m_agdd2GeoSvcName = "AGDDtoGeoSvc", "specify name of AGDDtoGeoSvc");
}
StatusCode NSWAGDDTool::initialize()
......@@ -44,7 +48,11 @@ StatusCode NSWAGDDTool::initialize()
m_outFileName = "Out.AmdcOracle.AM." + m_outFileType + "temp.data";
m_outPREsqlName = "Out.AmdcOracle.AM." + m_outFileType + ".PREsql";
ATH_CHECK(AGDDToolBase::initialize());
ATH_CHECK(AGDDToolBase::initialize());
if (m_DBFileName.empty()) {
m_DBFileName = "Generated_" + m_outFileType + "_pool.txt";
}
static int iEntries=0;
......@@ -52,6 +60,7 @@ StatusCode NSWAGDDTool::initialize()
{
iEntries=1;
MuonAGDDToolHelper theHelper;
theHelper.setAGDDtoGeoSvcName(m_agdd2GeoSvcName);
theHelper.SetNSWComponents();
}
......@@ -65,6 +74,7 @@ StatusCode NSWAGDDTool::construct()
ATH_MSG_INFO(" Name = "<<name());
MuonAGDDToolHelper theHelper;
theHelper.setAGDDtoGeoSvcName(m_agdd2GeoSvcName);
if (!m_readAGDD)
{
ATH_MSG_INFO(" trying to parse files ");
......@@ -73,7 +83,7 @@ StatusCode NSWAGDDTool::construct()
else
{
ATH_MSG_INFO(" trying to parse data base content ");
std::string AGDDfile = theHelper.GetAGDD(m_dumpAGDD, m_outFileType);
std::string AGDDfile = theHelper.GetAGDD(m_dumpAGDD, m_outFileType, m_DBFileName);
m_controller->ParseString(AGDDfile);
}
......@@ -100,7 +110,6 @@ StatusCode NSWAGDDTool::construct()
if(m_writeDBfile)
{
// build model before writing blob - if Athena crashes the XML is not good and should not become a blob
//((AGDD2GeoModelBuilder*)m_controller->GetBuilder())->BuildAllVolumes();
ATH_MSG_INFO("\t-- attempting to write output to "<< m_outFileName );
if( !m_outFileName.empty() )
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment