ATLAS Offline Software
Loading...
Searching...
No Matches
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
12#include "LArGeoRAL/RAL.h"
13
18
19#include "GeoModelRead/ReadGeoModel.h"
20#include "GeoModelKernel/GeoVolumeCursor.h"
23
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
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
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
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
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
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
Helper function for constructing the instances of GeoStraightAccSection when LAr GeoModel description...
Helper function for building FCAL Channel Map.
Definition of the abstract IRDBAccessSvc interface.
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition of the abstract IRDBRecord interface.
Definition of the abstract IRDBRecordset interface.
std::tuple< EMBDetectorManager *, EMECDetectorManager *, HECDetectorManager *, FCALDetectorManager * > buildLArReadoutGeometry(StoreGateSvc *detStore, const LArHVManager *hvManager, IMessageSvc *msgSvc, int testbeam, double projectivityDisplacement)
Helper function for building readout geometries of all LAr subsystems.
Helper function for building readout geometry of the MBTS.
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
A manager class providing access to readout geometry information for the electromagnetic barrel calor...
A manager class providing access to readout geometry information for the electromagnetic endcap calor...
A manager class providing access to readout geometry information for the forward calorimeter.
A manager class providing access to readout geometry information for the hadronic endcap calorimeter.
IRDBAccessSvc is an abstract interface to the athena service that provides the following functionalit...
RecordsVector::const_iterator const_iterator
virtual const_iterator begin() const =0
virtual const_iterator end() const =0
virtual unsigned int size() const =0
Stored in storegate.
virtual void create(GeoPhysVol *world) override
GeoModelIO::ReadGeoModel * m_sqliteReader
This class provides access to the High Voltage throughout the LAr.
The Athena Transient Store API.
singleton-like access to IMessageSvc via open function and helper
IMessageSvc * getMessageSvc(bool quiet=false)
StatusCode buildElStraightSections(StoreGateSvc *detStore, IRDBAccessSvc *paramSvc, IMessageSvc *msgSvc, bool sagging)
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)
StatusCode buildFcalChannelMap(StoreGateSvc *detStore, IRDBAccessSvc *paramSvc, IMessageSvc *msgSvc)