ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
MuonGM::MuonDetectorFactoryLite Class Reference

#include <MuonDetectorFactoryLite.h>

Inheritance diagram for MuonGM::MuonDetectorFactoryLite:
Collaboration diagram for MuonGM::MuonDetectorFactoryLite:

Public Member Functions

 MuonDetectorFactoryLite (StoreGateSvc *pDetStore, GeoModelIO::ReadGeoModel *sqliteReader)
 
 ~MuonDetectorFactoryLite ()
 
virtual void create (GeoPhysVol *world) override
 
virtual const MuonDetectorManagergetDetectorManager () const override
 
MuonDetectorManagergetDetectorManager ()
 
void setRDBAccess (IRDBAccessSvc *access)
 

Private Attributes

MuonDetectorManagerm_manager {nullptr}
 
StoreGateSvcm_pDetStore {nullptr}
 
IRDBAccessSvcm_pRDBAccess {nullptr}
 
GeoModelIO::ReadGeoModel * m_sqliteReader
 

Detailed Description

Definition at line 19 of file MuonDetectorFactoryLite.h.

Constructor & Destructor Documentation

◆ MuonDetectorFactoryLite()

MuonGM::MuonDetectorFactoryLite::MuonDetectorFactoryLite ( StoreGateSvc pDetStore,
GeoModelIO::ReadGeoModel *  sqliteReader 
)

Definition at line 41 of file MuonDetectorFactoryLite.cxx.

41  :
42  m_pDetStore{pDetStore},
43  m_sqliteReader(sqliteReader) {
44  }

◆ ~MuonDetectorFactoryLite()

MuonGM::MuonDetectorFactoryLite::~MuonDetectorFactoryLite ( )
default

Member Function Documentation

◆ create()

void MuonGM::MuonDetectorFactoryLite::create ( GeoPhysVol *  world)
overridevirtual

Definition at line 51 of file MuonDetectorFactoryLite.cxx.

51  {
52 
53  std::map<std::string, GeoAlignableTransform*> mapAXF = m_sqliteReader->getPublishedNodes<std::string, GeoAlignableTransform*>("MuonSys");
54  std::map<std::string, GeoFullPhysVol*> mapFPV = m_sqliteReader->getPublishedNodes<std::string, GeoFullPhysVol*>("MuonSys");
55 
56  MsgStream log(Athena::getMessageSvc(), "MuGM:MuonFactory");
57 
58  if (!m_manager) m_manager = new MuonDetectorManager();
59 
60 
61 
62 
63 
64  // Iterate using iterator in for loop
65  for (const auto& [key, pV] : mapFPV) {
66  int /*index1=key[3]-'0',*/ eta=key[5]-'0', ml=key[7]-'0', phi=key[12]-'0';
67 
68  char AC=key[13];
69  int ec = AC=='C' ? -1 : 1;
70  std::string vName = pV->getLogVol()->getName();
71  if (key.substr(0,3)=="sMD") {
72  std::string sName = vName.substr(4,4);
73  std::unique_ptr<MuonGM::MMReadoutElement> re = std::make_unique<MuonGM::MMReadoutElement>(pV, sName, ec*eta,phi,ml,m_manager,nullptr);
74  re->initDesign();
75  re->fillCache();
76  m_manager->addMMReadoutElement(std::move(re));
77  }
78  else if (key.substr(0,3)=="sTG") {
79  std::string sName = vName.substr(7,4);
80  std::unique_ptr<sTgcReadoutElement> re = std::make_unique<sTgcReadoutElement>(pV, sName, ec*eta, phi, ml, m_manager);
81  re->initDesign(2.6);
82  re->fillCache();
83  m_manager->addsTgcReadoutElement(std::move(re));
84  }
85  }
86 
87 
88 
89  // here create the MYSQL singleton
91  mysql->set_amdb_from_RDB(true);
92 
93  std::unique_ptr<RDBReaderAtlas> dbr;
94  {
95  // We never alter these in the "Lite" workflow
96  std::string oracleTag="";
97  std::string oracleNode="";
98  std::map<std::string, std::string> ascii{};
99  dbr = std::make_unique<RDBReaderAtlas>(m_pDetStore, m_pRDBAccess, oracleTag, oracleNode, ascii);
100 
101 
102  }
103 
104 
105 
106  // set here the flag deciding whether to include cutouts:
107  // m_includeCutouts = 1 => include cutouts
108  // m_includeCutouts = 0 => no cutouts
109  m_manager->setCutoutsFlag(true);
111 
112 
113  StatusCode sc = StatusCode::SUCCESS;
114 
115  dbr->setManager(getDetectorManager());
116  sc = dbr->ProcessDB(*mysql);
117  if (sc != StatusCode::SUCCESS) {
118  log << MSG::ERROR << " FAILURE in DB access; Muon node will not be built" << endmsg;
119  return;
120  }
121 
122  GeoFullPhysVol *p4 = mapFPV["MuonTreeTop"];
123  m_manager->addTreeTop(p4); // This is the top!
124  log << MSG::INFO << " TreeTop added to the Manager" << endmsg;
125 
126  // Look through the map explicitly for Stations
127  std::set<std::string> mappedStations;
128  for (const auto& i: mapFPV) {
129  size_t pos=i.first.find("_Station");
130  if (pos!=std::string::npos) mappedStations.insert(i.first.substr(0,pos));
131  }
132 
133  // Boudreau Jan 2024 Keep track of instantiated readout geometries. This is
134  // needed because the muon geometry is rebuild multiple times in current
135  // implementation.
136  std::set<std::string> keyset;
137 
138  for (const auto& i: mappedStations) {
139  auto it= mysql->stationMap().find(i);
140  if (it==mysql->stationMap().end()) {
141  throw std::runtime_error("Raw/readout geometry mismatch");
142  }
143 
144  Station *station = (*it).second.get();
145  std::string stname(station->GetName(), 0, 3);
146 
147  bool isAssembly = false;
148  if (station->GetNrOfCutouts() > 0 && stname.substr(0, 1) != "T")
149  isAssembly = true;
150 
151  // BIR have multilayers of diff. length and overall station volume clashes with toroids
152  if (stname == "BIR")
153  isAssembly = true;
154 
155  MuonChamberLite l(*mysql, station,&mapFPV,&mapAXF); // here is where we start to create a MuonChamber with all readoutelements
156  l.setKeyset(&keyset);
157 
158  PositionIterator pit;
159  AlignPos ap;
160  for ( auto const& [key, position] : *station) {
161  int zi = position.zindex;
162  int fi = position.phiindex;
163 
164  // here build the physical volume (tree) associated to the chamber
165  if (stname == "CSL") isAssembly = true;
166 
167  // CSL because coffin shape of the station mother volume
168  l.addReadoutLayers(*mysql, getDetectorManager(), zi, fi, position.isMirrored, isAssembly);
169 
170  // here define the GeoAlignableTransform associated to the chamber
171  // nominal transform first
172  GeoAlignableTransform *xf = mapAXF[station->GetName()+"_Station_"+std::to_string(zi)+"_"+std::to_string(fi)];
173  // alignment issues and readout geometry for station
174  MuonStation *mst = m_manager->getMuonStation(station->GetName(), zi, fi + 1);
175  if (!mst) {
176  log << MSG::WARNING << "For Station with nameTag=<" << station->GetName() << "> at zi/fi = " << zi << "/" << fi
177  << " no MuonStation found => no possibility to align" << endmsg;
178  continue;
179  }
180 
181  mst->setTransform(xf);
182  GeoTrf::Transform3D tsz_to_szt = GeoTrf::RotateZ3D(-90 * Gaudi::Units::degree) * GeoTrf::RotateY3D(-90 * Gaudi::Units::degree);
183  mst->setNativeToAmdbLRS(tsz_to_szt * station->native_to_tsz_frame(*mysql, position));
184  mst->setNominalAmdbLRSToGlobal(station->tsz_to_global_frame(*mysql, position) * tsz_to_szt.inverse());
185 
186  int nAlines = station->CountAlignPos(zi, fi);
187  if (nAlines == 0) {
188  ap.tras = ap.traz = ap.trat = ap.rots = ap.rotz = ap.rott = 0.;
189  ap.jobindex = 0;
190  mst->setDelta_fromAline(ap.tras, ap.traz, ap.trat, ap.rots, ap.rotz, ap.rott);
191  } else if (nAlines > 0) {
192  AlignPosIterator alast;
193  AlignPosIterator afirst = station->getFirstAlignPosInRange(zi, fi, alast);
194 
195  for (AlignPosIterator acurrent = afirst; acurrent != alast; ++acurrent) {
196  ap = acurrent->second;
197  if (ap.phiindex != fi || ap.zindex != zi) {
198  log << MSG::ERROR << "Inconsistent AlignedPosition found in the static Geometry DB: aligPos.fi, zi = " << ap.phiindex << ", " << ap.zindex
199  << " for station " << station->GetName() << " at fi/zi = " << fi << "/" << zi << " AlignPos indices fi/zi " << fi << "/" << zi << endmsg;
200  }
201  if (ap.jobindex == 0) {
202  mst->setDelta_fromAline(ap.tras, ap.traz, ap.trat, ap.rots, ap.rotz, ap.rott);
203  } else {
204  mst->setDelta_fromAline_forComp(ap.jobindex, ap.tras, ap.traz, ap.trat, ap.rots, ap.rotz, ap.rott);
205  }
206  }
207  }
208  } // end loop on positions
209  } // for ( it = sel.begin(); it != sel.end(); it++ ) {
210  delete mysql.get();
211  } // MuonDetectorFactoryLite::create

◆ getDetectorManager() [1/2]

MuonDetectorManager * MuonGM::MuonDetectorFactoryLite::getDetectorManager ( )

Definition at line 49 of file MuonDetectorFactoryLite.cxx.

49 { return m_manager; }

◆ getDetectorManager() [2/2]

const MuonDetectorManager * MuonGM::MuonDetectorFactoryLite::getDetectorManager ( ) const
overridevirtual

Definition at line 48 of file MuonDetectorFactoryLite.cxx.

48 { return m_manager; }

◆ setRDBAccess()

void MuonGM::MuonDetectorFactoryLite::setRDBAccess ( IRDBAccessSvc access)
inline

Definition at line 48 of file MuonDetectorFactoryLite.h.

48 { m_pRDBAccess = access; }

Member Data Documentation

◆ m_manager

MuonDetectorManager* MuonGM::MuonDetectorFactoryLite::m_manager {nullptr}
private

Definition at line 41 of file MuonDetectorFactoryLite.h.

◆ m_pDetStore

StoreGateSvc* MuonGM::MuonDetectorFactoryLite::m_pDetStore {nullptr}
private

Definition at line 42 of file MuonDetectorFactoryLite.h.

◆ m_pRDBAccess

IRDBAccessSvc* MuonGM::MuonDetectorFactoryLite::m_pRDBAccess {nullptr}
private

Definition at line 43 of file MuonDetectorFactoryLite.h.

◆ m_sqliteReader

GeoModelIO::ReadGeoModel* MuonGM::MuonDetectorFactoryLite::m_sqliteReader
private

Definition at line 44 of file MuonDetectorFactoryLite.h.


The documentation for this class was generated from the following files:
beamspotnt.ascii
ascii
Definition: bin/beamspotnt.py:1476
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
MuonGM::MYSQL::LockedMYSQL
CxxUtils::LockedPointer< MYSQL > LockedMYSQL
Definition: MYSQL.h:47
MuonGM::MuonDetectorManager::addTreeTop
void addTreeTop(PVLink)
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonDetectorManager.cxx:117
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
skel.it
it
Definition: skel.GENtoEVGEN.py:423
MuonGM::MuonDetectorFactoryLite::getDetectorManager
virtual const MuonDetectorManager * getDetectorManager() const override
Definition: MuonDetectorFactoryLite.cxx:48
TRT_PAI_gasdata::AC
const float AC
Definition: TRT_PAI_gasdata.h:27
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
MuonGM::MuonDetectorFactoryLite::m_pDetStore
StoreGateSvc * m_pDetStore
Definition: MuonDetectorFactoryLite.h:42
python.compareNtuple.vName
vName
Definition: compareNtuple.py:23
python.AtlRunQueryParser.ap
ap
Definition: AtlRunQueryParser.py:826
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
lumiFormat.i
int i
Definition: lumiFormat.py:92
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
MuonGM::PositionIterator
std::map< int, Position, std::less< int > >::const_iterator PositionIterator
Definition: Station.h:37
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
MuonGM::AlignPosIterator
std::multimap< int, AlignPos, std::less< int > >::const_iterator AlignPosIterator
Definition: Station.h:38
MuonGM::MuonDetectorManager::setCutoutsFlag
void setCutoutsFlag(int flag)
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonDetectorManager.cxx:684
MuonGM::MuonDetectorManager::setCutoutsBogFlag
void setCutoutsBogFlag(int flag)
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonDetectorManager.cxx:685
python.dummyaccess.access
def access(filename, mode)
Definition: dummyaccess.py:18
MuonGM::MuonDetectorFactoryLite::m_pRDBAccess
IRDBAccessSvc * m_pRDBAccess
Definition: MuonDetectorFactoryLite.h:43
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
MuonGM::MuonDetectorFactoryLite::m_manager
MuonDetectorManager * m_manager
Definition: MuonDetectorFactoryLite.h:41
MuonGM::MYSQL::GetPointer
static LockedMYSQL GetPointer()
Definition: MYSQL.cxx:42
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
MuonGM::MuonDetectorManager::getMuonStation
const MuonStation * getMuonStation(const std::string &stName, int eta, int phi) const
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonDetectorManager.cxx:137
re
const boost::regex re(r_e)
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
checkFileSG.fi
fi
Definition: checkFileSG.py:65
WriteBchToCool.dbr
dbr
Definition: WriteBchToCool.py:164
MuonGM::MuonDetectorManager::addMMReadoutElement
void addMMReadoutElement(std::unique_ptr< MMReadoutElement > &&reEle)
store the MMReadoutElement using as "key" the identifier
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonDetectorManager.cxx:173
MuonGM::MuonDetectorManager::addsTgcReadoutElement
void addsTgcReadoutElement(std::unique_ptr< sTgcReadoutElement > &&reEle)
store the sTGCReadoutElement using as "key" the identifier
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonDetectorManager.cxx:183
MuonGM::MuonDetectorFactoryLite::m_sqliteReader
GeoModelIO::ReadGeoModel * m_sqliteReader
Definition: MuonDetectorFactoryLite.h:44
python.SystemOfUnits.degree
tuple degree
Definition: SystemOfUnits.py:106
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37