ATLAS Offline Software
LArDetectorFactoryLite.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
9 #include "LArHV/LArHVManager.h"
12 #include "LArGeoRAL/RAL.h"
13 
18 
19 #include "GeoModelRead/ReadGeoModel.h"
20 #include "GeoModelKernel/GeoVolumeCursor.h"
23 
25 #include "StoreGate/StoreGateSvc.h"
26 
30 
31 #define SYSTEM_OF_UNITS Gaudi::Units
32 
34  , IRDBAccessSvc* paramSvc
35  , GeoModelIO::ReadGeoModel* sqliteReader
36  , const LArHVManager* hvManager)
37  : AthMessaging("LArDetectorFactoryLite")
38  , m_detectorManager(nullptr)
39  , m_detStore(detStore)
40  , m_paramSvc(paramSvc)
41  , m_sqliteReader(sqliteReader)
42  , m_hvManager(hvManager)
43  , m_barrelSagging(false)
44  , m_testBeam(0)
45 {
46 }
47 
48 
50 {
51  ATH_MSG_INFO("LArDetectorFactoryLite::create()");
52 
53  std::string errorMessage{""};
54 
55  if(LArGeo::buildFcalChannelMap(m_detStore,m_paramSvc,Athena::getMessageSvc()).isFailure()) {
56  errorMessage="Failed to build FCAL Channel Map";
57  ATH_MSG_FATAL(errorMessage);
58  throw std::runtime_error(errorMessage);
59  }
60 
61  // Build Electrode straight sections in the barrel
63  , m_paramSvc
65  , m_barrelSagging) != StatusCode::SUCCESS) {
66  errorMessage="Failed to build LAr Barrel electrode sections";
67  ATH_MSG_FATAL(errorMessage);
68  throw std::runtime_error(errorMessage);
69  }
70 
71  // Get the list of alignable transforms from SQLite, and record them into DetStore
72  std::map<std::string, GeoAlignableTransform*> mapAXF = m_sqliteReader->getPublishedNodes<std::string, GeoAlignableTransform*>("LAr");
73  for( auto& [key,xf] : mapAXF) {
74  StoredAlignX *sAlignX = new StoredAlignX(xf);
75  if(m_detStore->record(sAlignX,key)!=StatusCode::SUCCESS) {
76  errorMessage="Failed to record StoredAlignX for the key: "+key;
77  ATH_MSG_FATAL(errorMessage);
78  throw std::runtime_error(errorMessage);
79  }
80  }
81  // Get the list of full phys volumes from SQLite, and record them into DetStore
82  std::map<std::string, GeoFullPhysVol*> mapFPV = m_sqliteReader->getPublishedNodes<std::string, GeoFullPhysVol*>("LAr");
83  for( auto& [key,pv] : mapFPV) {
84  StoredPhysVol *sPhysVol = new StoredPhysVol(pv);
85  if(m_detStore->record(sPhysVol,key)!=StatusCode::SUCCESS) {
86  errorMessage="Failed to record StoredPhysVol for the key: " + key;
87  ATH_MSG_FATAL(errorMessage);
88  throw std::runtime_error(errorMessage);
89  }
90  }
91 
92  // Build LAr readout geometry
93  double projectivityDisplacement{0.};
94  IRDBRecordset_ptr emecGeometry = m_paramSvc->getRecordsetPtr("EmecGeometry","");
95  projectivityDisplacement = (*emecGeometry)[0]->getDouble("ZSHIFT");
96 
97  auto subDetManagers = buildLArReadoutGeometry(m_detStore
98  , m_hvManager
100  , m_testBeam
101  , projectivityDisplacement);
102 
103  EMBDetectorManager* embDetectorManager{std::get<0>(subDetManagers)};
104  EMECDetectorManager* emecDetectorManager{std::get<1>(subDetManagers)};
105  HECDetectorManager* hecDetectorManager{std::get<2>(subDetManagers)};
106  FCALDetectorManager* fcalDetectorManager{std::get<3>(subDetManagers)};
107 
108  if(!embDetectorManager
109  || !emecDetectorManager
110  || !hecDetectorManager
111  || !fcalDetectorManager) {
112  errorMessage="Failed to build LAr Readout Geometry description";
113  ATH_MSG_FATAL(errorMessage);
114  throw std::runtime_error(errorMessage);
115  }
116 
117  m_detectorManager = new LArDetectorManager(embDetectorManager,emecDetectorManager,hecDetectorManager,fcalDetectorManager);
118  m_detectorManager->isTestBeam(false);
119 
120  // Build MBTS readout geometry
121  IRDBRecordset_ptr mbtsTrds = m_paramSvc->getRecordsetPtr("MBTSTrds","");
122  IRDBRecordset_ptr mbtsTubs = m_paramSvc->getRecordsetPtr("MBTSTubs","");
123  IRDBRecordset_ptr mbtsPcons = m_paramSvc->getRecordsetPtr("MBTSPcons","");
124  IRDBRecordset_ptr cryoPcons = m_paramSvc->getRecordsetPtr("CryoPcons","");
125 
126 
128  double zposMM = 0.;
129 
130  if(mbtsPcons->size()==0) {
131  first = mbtsTubs->begin();
132  last = mbtsTubs->end();
133  for(; first!=last; ++first) {
134  if((*first)->getString("TUBE") == "MBTS_mother") {
135  zposMM = (*first)->getDouble("ZPOS")*SYSTEM_OF_UNITS::mm;
136  break;
137  }
138  }
139  }
140  else {
141  double zStartCryoMother = 0.;
142  first = cryoPcons->begin();
143  last = cryoPcons->end();
144  for(; first!=last; ++first) {
145  if((*first)->getString("PCON")=="Endcap::CryoMother"
146  && (*first)->getInt("PLANE_ID")==0) {
147  zStartCryoMother = (*first)->getDouble("ZPLANE");
148  break;
149  }
150  }
151 
152  double zStartMM = 0.;
153  first = mbtsPcons->begin();
154  last = mbtsPcons->end();
155  for(; first!=last; ++first) {
156  if((*first)->getString("PCON")=="MBTS::Mother"
157  && (*first)->getInt("PLANE_ID")==0) {
158  zStartMM = (*first)->getDouble("ZPLANE");
159  break;
160  }
161  }
162 
163  zposMM = zStartCryoMother - zStartMM;
164  }
165 
166 
167  std::map<std::string,unsigned> trdMap;
168  for(unsigned indTrd(0);indTrd<mbtsTrds->size();++indTrd) {
169  const std::string& keyTrd = (*mbtsTrds)[indTrd]->getString("TRD");
170  trdMap[keyTrd]=indTrd;
171  }
172 
173  if(LArGeo::buildMbtsReadout(m_detStore
174  , m_paramSvc
176  , zposMM
177  , trdMap
178  , std::string()
179  , std::string()).isFailure()) {
180  errorMessage="Failed to build MBTS Readout Geometry description";
181  ATH_MSG_FATAL(errorMessage);
182  throw std::runtime_error(errorMessage);
183  }
184 
185  // Set Tree Tops
186  GeoVolumeCursor cursor(world);
187  while(!cursor.atEnd()) {
188  std::string volName = cursor.getName();
189  if(volName.compare(0,3,"LAr")==0) {
190  m_detectorManager->addTreeTop(cursor.getVolume());
191  }
192  cursor.next();
193  }
194 
195 }
196 
LArHVManager.h
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
FCALDetectorManager
A manager class providing access to readout geometry information for the forward calorimeter.
Definition: FCALDetectorManager.h:29
LArGeo::buildMbtsReadout
StatusCode buildMbtsReadout(StoreGateSvc *detStore, IRDBAccessSvc *paramSvc, IMessageSvc *msgSvc, double zposMM, const std::map< std::string, unsigned > &trdMap, const std::string &detKey, const std::string &detNode)
Definition: MbtsReadoutBuilder.cxx:22
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
EMECDetectorManager
A manager class providing access to readout geometry information for the electromagnetic endcap calor...
Definition: EMECDetectorManager.h:31
LArDetectorFactoryLite.h
EMECDetectorManager.h
FCALDetectorManager.h
StoredAlignX
Definition: StoredAlignX.h:23
StoredAlignX.h
LArGeo::buildElStraightSections
StatusCode buildElStraightSections(StoreGateSvc *detStore, IRDBAccessSvc *paramSvc, IMessageSvc *msgSvc, bool sagging)
Definition: ElStraightSectionBuilder.cxx:27
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
FCALChannelMapBuilder.h
Helper function for building FCAL Channel Map.
LArReadoutGeometryBuilder.h
Helper function for building readout geometries of all LAr subsystems.
RAL.h
StoredPhysVol
Definition: StoredPhysVol.h:27
EMBDetectorManager
A manager class providing access to readout geometry information for the electromagnetic barrel calor...
Definition: EMBDetectorManager.h:32
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:125
IRDBAccessSvc.h
Definition of the abstract IRDBAccessSvc interface.
IRDBAccessSvc
IRDBAccessSvc is an abstract interface to the athena service that provides the following functionalit...
Definition: IRDBAccessSvc.h:42
ElStraightSectionBuilder.h
Helper function for constructing the instances of GeoStraightAccSection when LAr GeoModel description...
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
LArDetectorManager
Stored in storegate. Provides access to EMB, EMEC, HEC and FCAL Detector Managers....
Definition: LArDetectorManager.h:26
LArGeo::buildFcalChannelMap
StatusCode buildFcalChannelMap(StoreGateSvc *detStore, IRDBAccessSvc *paramSvc, IMessageSvc *msgSvc)
Definition: FCALChannelMapBuilder.cxx:14
IRDBRecordset_ptr
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition: IRDBAccessSvc.h:25
HECDetectorManager
A manager class providing access to readout geometry information for the hadronic endcap calorimeter.
Definition: HECDetectorManager.h:28
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
VDetectorParameters.h
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
query_example.cursor
cursor
Definition: query_example.py:21
LArHVManager
This class provides access to the High Voltage throughout the LAr. High voltage conditions can also b...
Definition: LArHVManager.h:24
IRDBRecord.h
Definition of the abstract IRDBRecord interface.
buildLArReadoutGeometry
std::tuple< EMBDetectorManager *,EMECDetectorManager *,HECDetectorManager *,FCALDetectorManager * > buildLArReadoutGeometry(StoreGateSvc *detStore, const LArHVManager *hvManager, IMessageSvc *msgSvc, int testbeam, double projectivityDisplacement)
Definition: LArReadoutGeometryBuilder.cxx:37
DeMoScan.first
bool first
Definition: DeMoScan.py:536
python.changerun.pv
pv
Definition: changerun.py:81
IRDBRecordset.h
Definition of the abstract IRDBRecordset interface.
StoreGateSvc.h
EMBDetectorManager.h
MbtsReadoutBuilder.h
Helper function for building readout geometry of the MBTS.
HECDetectorManager.h
IRDBRecordset::const_iterator
RecordsVector::const_iterator const_iterator
Definition: IRDBRecordset.h:52
LArGeo::LArDetectorFactoryLite::LArDetectorFactoryLite
LArDetectorFactoryLite()=delete
StoredPhysVol.h
LArGeo::LArDetectorFactoryLite::create
virtual void create(GeoPhysVol *world) override
Definition: LArDetectorFactoryLite.cxx:49
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37