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 
49 = default;
50 
51 
53 {
54  ATH_MSG_INFO("LArDetectorFactoryLite::create()");
55 
56  std::string errorMessage{""};
57 
58  if(LArGeo::buildFcalChannelMap(m_detStore,m_paramSvc,Athena::getMessageSvc()).isFailure()) {
59  errorMessage="Failed to build FCAL Channel Map";
60  ATH_MSG_FATAL(errorMessage);
61  throw std::runtime_error(errorMessage);
62  }
63 
64  // Build Electrode straight sections in the barrel
66  , m_paramSvc
68  , m_barrelSagging) != StatusCode::SUCCESS) {
69  errorMessage="Failed to build LAr Barrel electrode sections";
70  ATH_MSG_FATAL(errorMessage);
71  throw std::runtime_error(errorMessage);
72  }
73 
74  // Get the list of alignable transforms from SQLite, and record them into DetStore
75  std::map<std::string, GeoAlignableTransform*> mapAXF = m_sqliteReader->getPublishedNodes<std::string, GeoAlignableTransform*>("LAr");
76  for( auto& [key,xf] : mapAXF) {
77  StoredAlignX *sAlignX = new StoredAlignX(xf);
78  if(m_detStore->record(sAlignX,key)!=StatusCode::SUCCESS) {
79  errorMessage="Failed to record StoredAlignX for the key: "+key;
80  ATH_MSG_FATAL(errorMessage);
81  throw std::runtime_error(errorMessage);
82  }
83  }
84  // Get the list of full phys volumes from SQLite, and record them into DetStore
85  std::map<std::string, GeoFullPhysVol*> mapFPV = m_sqliteReader->getPublishedNodes<std::string, GeoFullPhysVol*>("LAr");
86  for( auto& [key,pv] : mapFPV) {
87  StoredPhysVol *sPhysVol = new StoredPhysVol(pv);
88  if(m_detStore->record(sPhysVol,key)!=StatusCode::SUCCESS) {
89  errorMessage="Failed to record StoredPhysVol for the key: " + key;
90  ATH_MSG_FATAL(errorMessage);
91  throw std::runtime_error(errorMessage);
92  }
93  }
94 
95  // Build LAr readout geometry
96  double projectivityDisplacement{0.};
97  IRDBRecordset_ptr emecGeometry = m_paramSvc->getRecordsetPtr("EmecGeometry","");
98  projectivityDisplacement = (*emecGeometry)[0]->getDouble("ZSHIFT");
99 
100  auto subDetManagers = buildLArReadoutGeometry(m_detStore
101  , m_hvManager
103  , m_testBeam
104  , projectivityDisplacement);
105 
106  EMBDetectorManager* embDetectorManager{std::get<0>(subDetManagers)};
107  EMECDetectorManager* emecDetectorManager{std::get<1>(subDetManagers)};
108  HECDetectorManager* hecDetectorManager{std::get<2>(subDetManagers)};
109  FCALDetectorManager* fcalDetectorManager{std::get<3>(subDetManagers)};
110 
111  if(!embDetectorManager
112  || !emecDetectorManager
113  || !hecDetectorManager
114  || !fcalDetectorManager) {
115  errorMessage="Failed to build LAr Readout Geometry description";
116  ATH_MSG_FATAL(errorMessage);
117  throw std::runtime_error(errorMessage);
118  }
119 
120  m_detectorManager = new LArDetectorManager(embDetectorManager,emecDetectorManager,hecDetectorManager,fcalDetectorManager);
121  m_detectorManager->isTestBeam(false);
122 
123  // Build MBTS readout geometry
124  IRDBRecordset_ptr mbtsTrds = m_paramSvc->getRecordsetPtr("MBTSTrds","");
125  IRDBRecordset_ptr mbtsTubs = m_paramSvc->getRecordsetPtr("MBTSTubs","");
126  IRDBRecordset_ptr mbtsPcons = m_paramSvc->getRecordsetPtr("MBTSPcons","");
127  IRDBRecordset_ptr cryoPcons = m_paramSvc->getRecordsetPtr("CryoPcons","");
128 
129 
131  double zposMM = 0.;
132 
133  if(mbtsPcons->size()==0) {
134  first = mbtsTubs->begin();
135  last = mbtsTubs->end();
136  for(; first!=last; ++first) {
137  if((*first)->getString("TUBE") == "MBTS_mother") {
138  zposMM = (*first)->getDouble("ZPOS")*SYSTEM_OF_UNITS::mm;
139  break;
140  }
141  }
142  }
143  else {
144  double zStartCryoMother = 0.;
145  first = cryoPcons->begin();
146  last = cryoPcons->end();
147  for(; first!=last; ++first) {
148  if((*first)->getString("PCON")=="Endcap::CryoMother"
149  && (*first)->getInt("PLANE_ID")==0) {
150  zStartCryoMother = (*first)->getDouble("ZPLANE");
151  break;
152  }
153  }
154 
155  double zStartMM = 0.;
156  first = mbtsPcons->begin();
157  last = mbtsPcons->end();
158  for(; first!=last; ++first) {
159  if((*first)->getString("PCON")=="MBTS::Mother"
160  && (*first)->getInt("PLANE_ID")==0) {
161  zStartMM = (*first)->getDouble("ZPLANE");
162  break;
163  }
164  }
165 
166  zposMM = zStartCryoMother - zStartMM;
167  }
168 
169 
170  std::map<std::string,unsigned> trdMap;
171  for(unsigned indTrd(0);indTrd<mbtsTrds->size();++indTrd) {
172  const std::string& keyTrd = (*mbtsTrds)[indTrd]->getString("TRD");
173  trdMap[keyTrd]=indTrd;
174  }
175 
176  if(LArGeo::buildMbtsReadout(m_detStore
177  , m_paramSvc
179  , zposMM
180  , trdMap
181  , std::string()
182  , std::string()).isFailure()) {
183  errorMessage="Failed to build MBTS Readout Geometry description";
184  ATH_MSG_FATAL(errorMessage);
185  throw std::runtime_error(errorMessage);
186  }
187 
188  // Set Tree Tops
189  GeoVolumeCursor cursor(world);
190  while(!cursor.atEnd()) {
191  std::string volName = cursor.getName();
192  if(volName.compare(0,3,"LAr")==0) {
193  m_detectorManager->addTreeTop(cursor.getVolume());
194  }
195  cursor.next();
196  }
197 
198 }
199 
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:128
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:45
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:534
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.
LArGeo::LArDetectorFactoryLite::~LArDetectorFactoryLite
virtual ~LArDetectorFactoryLite()
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:52
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37