15 #include "GeoModelKernel/GeoPhysVol.h"
16 #include "GeoModelKernel/GeoTransform.h"
17 #include "GeoModelKernel/GeoAlignableTransform.h"
18 #include "GeoModelKernel/GeoNameTag.h"
19 #include "GeoModelKernel/GeoShapeUnion.h"
20 #include "GeoModelKernel/GeoDefinitions.h"
21 #include "GaudiKernel/SystemOfUnits.h"
28 #include "GaudiKernel/Bootstrap.h"
40 #include "GeoModelKernel/CellBinning.h"
47 , m_detectorManager(nullptr)
49 , m_hvManager(hvManager)
50 , m_barrelSagging(false)
51 , m_barrelVisLimit(-1)
55 , m_testbeam(testbeam)
70 GeoIntrusivePtr<GeoFullPhysVol> barrelEnvelope{
nullptr}, endcapEnvelopePos{
nullptr}, endcapEnvelopeNeg{
nullptr};
72 double projectivityDisplacement(0.);
74 if(m_testbeam==0 || m_testbeam==1) {
75 m_parameters = std::make_unique<LArGeo::RAL>();
79 if (StatusCode::SUCCESS != m_detStore->retrieve(materialManager, std::string(
"MATERIALS"))) {
80 throw std::runtime_error(
"Error in LArDetectorFactory, cannot access Material Manager");
83 SmartIF<IRDBAccessSvc> rdbAccess{Gaudi::svcLocator()->service(
"RDBAccessSvc")};
85 if(!rdbAccess.isValid())
86 throw std::runtime_error(
"Error in BarrelCryostatConstruction, cannot access RDBAccessSvc");
89 ATH_MSG_DEBUG(
"Getting primary numbers for " << larVersionKey.
node() <<
", " << larVersionKey.
tag());
93 if(larPosition->size()==0) {
94 larPosition = rdbAccess->getRecordsetPtr(
"LArPosition",
"LArPosition-00");
95 if (larPosition->size()==0)
96 throw std::runtime_error(
"Error, no lar position table in database!");
99 IRDBRecordset_ptr emecGeometry = rdbAccess->getRecordsetPtr(
"EmecGeometry",larVersionKey.
tag(),larVersionKey.
node());
100 projectivityDisplacement = (*emecGeometry)[0]->getDouble(
"ZSHIFT");
118 EndcapCryostatConstruction endcapCryostatConstruction(m_fullGeo, m_EMECVariantInner, m_EMECVariantOuter, m_activateFT, m_enableMBTS);
122 barrelEnvelope = barrelCryostatConstruction.
GetEnvelope(m_parameters.get());
126 endcapEnvelopePos = endcapCryostatConstruction.
createEnvelope(
true);
127 endcapEnvelopeNeg = endcapCryostatConstruction.
createEnvelope(
false);
131 a_container->add(
new GeoNameTag(
"LAr"));
133 if(m_buildBarrel && m_buildEndcap) {
142 if(!barrelRec)
throw std::runtime_error(
"Error, no lar position record in the database");
144 GeoAlignableTransform* barrelAlXf =
new GeoAlignableTransform(xfBarrel);
149 if(!
status.isSuccess())
throw std::runtime_error(
"Cannot store LARCRYO_B PhysVol");
152 status=m_detStore->record(sAlignX,
"LARCRYO_B");
153 if(!
status.isSuccess())
throw std::runtime_error(
"Cannot store LARCRYO_B Alignable XF");
156 a_container->add(
new GeoNameTag(
"LArBarrel"));
157 a_container->add(barrelAlXf);
158 a_container->add(barrelEnvelope);
162 if (!posRec)
throw std::runtime_error(
"Error, no lar position record in the database") ;
164 GeoAlignableTransform *xfEndcapPos =
new GeoAlignableTransform(xfPos);
169 if(!
status.isSuccess())
throw std::runtime_error(
"Cannot store LARCRYO_EC_POS PhysVol");
172 status=m_detStore->record(sAlignX,
"LARCRYO_EC_POS");
173 if(!
status.isSuccess())
throw std::runtime_error (
"Cannot store LARCRYO_EC_POS");
178 if (!negRec)
throw std::runtime_error(
"Error, no lar position record in the database") ;
180 GeoAlignableTransform *xfEndcapNeg =
new GeoAlignableTransform(xfNeg);
185 if(!
status.isSuccess())
throw std::runtime_error(
"Cannot store LARCRYO_EC_NEG PhysVol");
188 status=m_detStore->record(sAlignX,
"LARCRYO_EC_NEG");
189 if(!
status.isSuccess())
throw std::runtime_error (
"Cannot store LARCRYO_EC_NEG");
192 a_container->add(
new GeoNameTag(
"LArEndcapPos"));
193 a_container->add(xfEndcapPos);
194 a_container->add(endcapEnvelopePos);
195 a_container->add(
new GeoNameTag(
"LArEndcapNeg"));
196 a_container->add(xfEndcapNeg);
198 a_container->add(endcapEnvelopeNeg);
200 else if(!m_buildEndcap) {
203 if(!barrelRec)
throw std::runtime_error(
"Error, no lar position record in the database");
205 GeoAlignableTransform* barrelAlXf =
new GeoAlignableTransform(xfBarrel);
210 if(!
status.isSuccess())
throw std::runtime_error(
"Cannot store LARCRYO_B PhysVol");
213 status=m_detStore->record(sAlignX,
"LARCRYO_B");
214 if(!
status.isSuccess())
throw std::runtime_error(
"Cannot store LARCRYO_B Alignable XF");
217 a_container->add(
new GeoNameTag(
"LArBarrel"));
218 a_container->add(barrelAlXf);
219 a_container->add(barrelEnvelope);
222 else if(!m_buildBarrel) {
225 if (!posRec)
throw std::runtime_error(
"Error, no lar position record in the database") ;
227 GeoAlignableTransform *xfEndcapPos =
new GeoAlignableTransform(xfPos);
232 if(!
status.isSuccess())
throw std::runtime_error(
"Cannot store LARCRYO_EC_POS PhysVol");
235 status=m_detStore->record(sAlignX,
"LARCRYO_EC_POS");
236 if(!
status.isSuccess())
throw std::runtime_error (
"Cannot store LARCRYO_EC_POS");
241 if (!negRec)
throw std::runtime_error(
"Error, no lar position record in the database") ;
243 GeoAlignableTransform *xfEndcapNeg =
new GeoAlignableTransform(xfNeg);
248 if(!
status.isSuccess())
throw std::runtime_error(
"Cannot store LARCRYO_EC_NEG PhysVol");
251 status=m_detStore->record(sAlignX,
"LARCRYO_EC_NEG");
252 if(!
status.isSuccess())
throw std::runtime_error (
"Cannot store LARCRYO_EC_NEG");
255 a_container->add(
new GeoNameTag(
"LArEndcapPos"));
256 a_container->add(xfEndcapPos);
257 a_container->add(endcapEnvelopePos);
258 a_container->add(
new GeoNameTag(
"LArEndcapNeg"));
259 a_container->add(xfEndcapNeg);
261 a_container->add(endcapEnvelopeNeg);
270 barrelEnvelope = tbbarrelCryostatConstruction.
GetEnvelope(m_parameters.get());
272 a_container->add(
new GeoNameTag(
"LAr"));
273 a_container->add(barrelEnvelope);
282 , projectivityDisplacement);
289 if(!embDetectorManager
290 || !emecDetectorManager
291 || !hecDetectorManager
292 || !fcalDetectorManager) {
293 std::string errorMessage=
"Failed to build LAr Readout Geometry description";
294 throw std::runtime_error(errorMessage);
297 m_detectorManager =
new LArDetectorManager(embDetectorManager,emecDetectorManager,hecDetectorManager,fcalDetectorManager);
298 m_detectorManager->isTestBeam(
false);
299 if (barrelEnvelope) m_detectorManager->addTreeTop(barrelEnvelope);
300 if (endcapEnvelopePos) m_detectorManager->addTreeTop(endcapEnvelopePos);
301 if (endcapEnvelopeNeg) m_detectorManager->addTreeTop(endcapEnvelopeNeg);
308 return m_detectorManager;
313 return std::move (m_parameters);