5 #include "LArReadoutGeometry/FCAL_ChannelMap.h"
8 #include "GeoModelKernel/GeoMaterial.h"
9 #include "GeoModelKernel/GeoFullPhysVol.h"
10 #include "GeoModelKernel/GeoPhysVol.h"
11 #include "GeoModelKernel/GeoLogVol.h"
12 #include "GeoModelKernel/GeoTransform.h"
13 #include "GeoModelKernel/GeoAlignableTransform.h"
14 #include "GeoModelKernel/GeoIdentifierTag.h"
15 #include "GeoModelKernel/GeoSerialIdentifier.h"
16 #include "GeoModelKernel/GeoSerialTransformer.h"
17 #include "GeoModelKernel/GeoXF.h"
20 #include "GeoModelKernel/GeoPcon.h"
21 #include "GeoModelKernel/GeoTubs.h"
22 #include "GeoModelKernel/GeoCons.h"
23 #include "GeoModelKernel/GeoBox.h"
24 #include "GeoModelKernel/GeoTrap.h"
25 #include "GeoModelKernel/GeoDefinitions.h"
35 #include "GeoGenericFunctions/Variable.h"
36 #include "GeoGenericFunctions/ArrayFunction.h"
43 #include "GaudiKernel/ISvcLocator.h"
44 #include "GaudiKernel/MsgStream.h"
45 #include "GaudiKernel/Bootstrap.h"
46 #include "GaudiKernel/SystemOfUnits.h"
64 SmartIF<IGeoModelSvc> gModel{
m_svcLocator->service(
"GeoModelSvc")};
65 if(!gModel.isValid()) {
66 throw std::runtime_error(
"Error in FCALConstruction, cannot access GeoModelSvc");
68 geoModel = gModel.get();
69 SmartIF<IRDBAccessSvc> rAccess{
m_svcLocator->service(
"RDBAccessSvc")};
70 if(!rAccess.isValid()) {
71 throw std::runtime_error(
"Error in FCALConstruction, cannot access RDBAccessSvc");
73 rdbAccess = rAccess.get();
76 m_fcalMod = rdbAccess->getRecordsetPtr(
"FCalMod", larVersionKey.
tag(),larVersionKey.
node());
78 m_fcalMod=rdbAccess->getRecordsetPtr(
"FCalMod",
"FCalMod-00");
80 throw std::runtime_error(
"Error getting FCAL Module parameters from database");
84 m_LArPosition = rdbAccess->getRecordsetPtr(
"LArPosition", larVersionKey.
tag(), larVersionKey.
node());
86 m_LArPosition = rdbAccess->getRecordsetPtr(
"LArPosition",
"LArPosition-00");
88 throw std::runtime_error(
"Error, no lar position table in database!");
95 const bool F1=
true,F2=
true,F3=
true;
99 throw std::runtime_error(
"Error in FCALConstruction, cannot access DetectorStore");
103 if (StatusCode::SUCCESS !=
detStore->retrieve(materialManager, std::string(
"MATERIALS")))
return nullptr;
105 const GeoMaterial *Copper = materialManager->
getMaterial(
"std::Copper");
106 if (!Copper)
throw std::runtime_error(
"Error in FCALConstruction, std::Copper is not found.");
108 const GeoMaterial *Iron = materialManager->
getMaterial(
"std::Iron");
109 if (!Iron)
throw std::runtime_error(
"Error in FCALConstruction, std::Iron is not found.");
111 const GeoMaterial *Lead = materialManager->
getMaterial(
"std::Lead");
112 if (!Lead)
throw std::runtime_error(
"Error in FCALConstruction, std::Lead is not found.");
114 const GeoMaterial *
LAr = materialManager->
getMaterial(
"std::LiquidArgon");
115 if (!
LAr)
throw std::runtime_error(
"Error in FCALConstruction, std::LiquidArgon is not found.");
117 const GeoMaterial *Air = materialManager->
getMaterial(
"std::Air");
118 if (!Air)
throw std::runtime_error(
"Error in FCALConstruction, std::Air is not found.");
120 const GeoMaterial *Kapton = materialManager->
getMaterial(
"std::Kapton");
121 if (!Kapton)
throw std::runtime_error(
"Error in FCALConstruction, std::Kapton is not found.");
123 const GeoMaterial *Glue = materialManager->
getMaterial(
"LAr::Glue");
124 if (!Glue)
throw std::runtime_error(
"Error in FCALConstruction, LAr::Glue is not found.");
126 const GeoMaterial *G10 = materialManager->
getMaterial(
"LAr::G10");
127 if (!G10)
throw std::runtime_error(
"Error in FCALConstruction, LAr::G10 is not found.");
130 const GeoMaterial *FCal1Absorber = materialManager->
getMaterial(
"LAr::FCal1Absorber");
131 if (!FCal1Absorber)
throw std::runtime_error(
"Error in FCALConstruction, LAr::FCal1Absorber is not found.");
133 const GeoMaterial *FCal23Absorber = materialManager->
getMaterial(
"LAr::FCal23Absorber");
134 if (!FCal23Absorber)
throw std::runtime_error(
"Error in FCALConstruction, LAr::FCal23Absorber is not found.");
136 const GeoMaterial *FCalCableHarness = materialManager->
getMaterial(
"LAr::FCalCableHarness");
137 if (!FCalCableHarness)
throw std::runtime_error(
"Error in FCALConstruction, LAr::FCalCableHarness is not found.");
139 const GeoMaterial *FCal23Slugs = materialManager->
getMaterial(
"LAr::FCal23Slugs");
140 if (!FCal23Slugs)
throw std::runtime_error(
"Error in FCALConstruction, LAr::FCal23Slugs is not found.");
143 auto cmap = std::make_unique<FCAL_ChannelMap>(0);
145 GeoIntrusivePtr<GeoFullPhysVol> fcalPhysical{
nullptr};
147 std::string baseName =
"LAr::FCAL::";
149 double startZFCal1 = (*m_fcalMod)[0]->getDouble(
"STARTPOSITION");
151 double startZFCal3 = (*m_fcalMod)[2]->getDouble(
"STARTPOSITION");
153 double outerModuleRadius1=(*m_fcalMod)[0]->getDouble(
"OUTERMODULERADIUS");
154 double outerModuleRadius2=(*m_fcalMod)[1]->getDouble(
"OUTERMODULERADIUS");
155 double outerModuleRadius3=(*m_fcalMod)[2]->getDouble(
"OUTERMODULERADIUS");
156 double innerModuleRadius1=(*m_fcalMod)[0]->getDouble(
"INNERMODULERADIUS");
157 double innerModuleRadius2=(*m_fcalMod)[1]->getDouble(
"INNERMODULERADIUS");
158 double innerModuleRadius3=(*m_fcalMod)[2]->getDouble(
"INNERMODULERADIUS");
159 double fullModuleDepth1=(*m_fcalMod)[0]->getDouble(
"FULLMODULEDEPTH");
160 double fullModuleDepth2=(*m_fcalMod)[1]->getDouble(
"FULLMODULEDEPTH");
161 double fullModuleDepth3=(*m_fcalMod)[2]->getDouble(
"FULLMODULEDEPTH");
162 double fullGapDepth1=(*m_fcalMod)[0]->getDouble(
"FULLGAPDEPTH");
163 double fullGapDepth2=(*m_fcalMod)[1]->getDouble(
"FULLGAPDEPTH");
164 double fullGapDepth3=(*m_fcalMod)[2]->getDouble(
"FULLGAPDEPTH");
165 double outerGapRadius1=(*m_fcalMod)[0]->getDouble(
"OUTERGAPRADIUS");
166 double outerGapRadius2=(*m_fcalMod)[1]->getDouble(
"OUTERGAPRADIUS");
167 double outerGapRadius3=(*m_fcalMod)[2]->getDouble(
"OUTERGAPRADIUS");
168 double innerGapRadius1=(*m_fcalMod)[0]->getDouble(
"INNERGAPRADIUS");
169 double innerGapRadius2=(*m_fcalMod)[1]->getDouble(
"INNERGAPRADIUS");
170 double innerGapRadius3=(*m_fcalMod)[2]->getDouble(
"INNERGAPRADIUS");
176 double outerRadius =
std::max(outerModuleRadius1,
std::max(outerModuleRadius2,outerModuleRadius3));
177 double innerRadius =
std::min(innerModuleRadius1,
std::min(innerModuleRadius2,innerModuleRadius3));
178 double depthZFCal3 = fullModuleDepth3;
179 double stopZFCal3 = startZFCal3 + depthZFCal3;
181 double totalDepth = stopZFCal3 - startZFCal1;
182 double halfDepth = totalDepth/2.;
184 std::string
name = baseName +
"LiquidArgonC";
185 GeoTubs *tubs =
new GeoTubs(innerRadius,outerRadius,halfDepth,0,360*
Gaudi::Units::deg);
186 GeoLogVol *logVol=
new GeoLogVol(
name, tubs,
LAr);
187 fcalPhysical =
new GeoFullPhysVol(logVol);
196 GeoIntrusivePtr<GeoFullPhysVol> modPhysical{
nullptr};
198 double halfDepth = fullModuleDepth1/2;
199 double innerRadius = innerModuleRadius1;
200 double outerRadius = outerModuleRadius1;
201 GeoIntrusivePtr<GeoFullPhysVol>physVol;
207 GeoTubs *tubs =
new GeoTubs( innerRadius, outerRadius, halfDepth, 0, 2*
M_PI);
208 GeoLogVol *logVol =
new GeoLogVol(baseName +
"Module1::Absorber", tubs, FCal1Absorber);
209 physVol =
new GeoFullPhysVol(logVol);
215 if (!posRec)
throw std::runtime_error(
"Error, no lar position record in the database") ;
217 GeoAlignableTransform *xfAbs1 =
new GeoAlignableTransform(xfPos);
219 fcalPhysical->add(xfAbs1);
220 if (!bPos) fcalPhysical->add(
new GeoTransform(GeoTrf::RotateY3D(180*
Gaudi::Units::deg)));
221 fcalPhysical->add(physVol);
222 modPhysical = physVol;
224 std::string
tag = bPos? std::string(
"FCAL1_POS") : std::string(
"FCAL1_NEG");
229 if(!
status.isSuccess())
throw std::runtime_error ((std::string(
"Cannot store")+
tag).c_str());
233 if(!
status.isSuccess())
throw std::runtime_error ((std::string(
"Cannot store")+
tag).c_str());
239 double outerRadius = outerModuleRadius1;
240 double innerRadius = outerRadius - troughDepth;
241 double halfLength = fullModuleDepth1/ 2.0;
244 GeoTubs * tubs =
new GeoTubs(innerRadius,outerRadius,halfLength,startPhi,
deltaPhi );
245 GeoLogVol *logVol =
new GeoLogVol(baseName+
"Module1::CableTrough",tubs,FCalCableHarness);
246 GeoIntrusivePtr<GeoPhysVol>physVol =
new GeoPhysVol(logVol);
247 GeoGenfun::Variable
i;
249 GeoXF::TRANSFUNCTION xf = GeoXF::Pow(GeoTrf::RotateZ3D(1.0),rotationAngle);
250 GeoSerialTransformer *st =
new GeoSerialTransformer(physVol,&xf,16);
251 modPhysical->add(st);
255 double halfDepth = fullGapDepth1/2.0;
256 double innerRadius = innerGapRadius1;
257 double outerRadius = outerGapRadius1;
258 GeoIntrusivePtr<GeoPhysVol>physVol{
nullptr};
260 GeoTubs *tubs =
new GeoTubs(innerRadius,outerRadius,halfDepth,0.0, 2.0*
M_PI);
261 GeoLogVol *logVol =
new GeoLogVol(baseName +
"Module1::Gap",tubs,
LAr);
262 physVol =
new GeoPhysVol(logVol);
263 modPhysical->add(
new GeoSerialIdentifier(0));
271 unsigned fieldModNumber(2);
272 unsigned fieldTileName(1);
278 unsigned fieldHvFt(8);
280 std::unique_ptr<IRDBQuery>
query;
282 query = rdbAccess->getQuery(
"LArFCalElectrodes", larVersionKey.
tag(),larVersionKey.
node());
284 query = rdbAccess->getQuery(
"LArFCalElectrodes",
"LArFCalElectrodes-00");
286 throw std::runtime_error(
"Error getting Session and Query pointers");
290 throw std::runtime_error(
"Error, unable to fetch fcal electrodes from the database!");
293 while(
query->next()) {
295 if(myGroup!=
query->data<
int>(fieldModNumber))
continue;
298 int thisTubeI=
query->data<
int>(fieldI);
299 int thisTubeJ=
query->data<
int>(fieldJ);
300 int thisTubeID =
query->data<
int>(fieldId);
301 int thisTubeMod = myGroup;
302 double thisTubeX=
query->data<
double>(fieldX);
303 double thisTubeY=
query->data<
double>(fieldY);
306 cmap->add_tube(
query->data<std::string>(fieldTileName),
307 thisTubeMod, thisTubeID, thisTubeI,thisTubeJ, thisTubeX, thisTubeY,
308 query->data<std::string>(fieldHvFt));
313 modPhysical->add(xf);
314 modPhysical->add(physVol);
325 GeoIntrusivePtr<GeoFullPhysVol> modPhysical{
nullptr};
327 double halfDepth = fullModuleDepth2/2;
328 double innerRadius = innerModuleRadius2;
329 double outerRadius = outerModuleRadius2;
330 GeoIntrusivePtr<GeoFullPhysVol>physVol;
336 GeoTubs *tubs =
new GeoTubs( innerRadius, outerRadius, halfDepth, 0, 2*
M_PI);
337 GeoLogVol *logVol =
new GeoLogVol(baseName +
"Module2::Absorber", tubs, FCal23Absorber);
338 physVol =
new GeoFullPhysVol(logVol);
344 if (!posRec)
throw std::runtime_error(
"Error, no lar position record in the database") ;
346 GeoAlignableTransform *xfAbs2 =
new GeoAlignableTransform(xfPos);
348 fcalPhysical->add(xfAbs2);
349 if (!bPos) fcalPhysical->add(
new GeoTransform(GeoTrf::RotateY3D(180*
Gaudi::Units::deg)));
350 fcalPhysical->add(physVol);
351 modPhysical = physVol;
353 std::string
tag = bPos? std::string(
"FCAL2_POS") : std::string(
"FCAL2_NEG");
358 if(!
status.isSuccess())
throw std::runtime_error ((std::string(
"Cannot store")+
tag).c_str());
362 if(!
status.isSuccess())
throw std::runtime_error ((std::string(
"Cannot store")+
tag).c_str());
368 double outerRadius = outerModuleRadius2;
369 double innerRadius = outerRadius - troughDepth;
370 double halfLength = fullModuleDepth2/ 2.0;
373 GeoTubs * tubs =
new GeoTubs(innerRadius,outerRadius,halfLength,startPhi,
deltaPhi );
374 GeoLogVol *logVol =
new GeoLogVol(baseName+
"Module2::CableTrough",tubs,FCalCableHarness);
375 GeoIntrusivePtr<GeoPhysVol>physVol =
new GeoPhysVol(logVol);
376 GeoGenfun::Variable
i;
378 GeoXF::TRANSFUNCTION xf = GeoXF::Pow(GeoTrf::RotateZ3D(1.0),rotationAngle);
379 GeoSerialTransformer *st =
new GeoSerialTransformer(physVol,&xf,16);
380 modPhysical->add(st);
385 double halfDepth = fullGapDepth2/2.0;
386 double innerRadius = innerGapRadius2;
387 double outerRadius = outerGapRadius2;
389 GeoIntrusivePtr<GeoPhysVol> gapPhys{
nullptr};
390 GeoIntrusivePtr<GeoPhysVol> rodPhys{
nullptr};
392 GeoTubs *gapTubs =
new GeoTubs(0,outerRadius,halfDepth,0.0, 2.0*
M_PI);
393 GeoLogVol *gapLog =
new GeoLogVol(baseName +
"Module2::Gap",gapTubs,
LAr);
394 gapPhys =
new GeoPhysVol(gapLog);
396 GeoTubs *rodTubs =
new GeoTubs(0,innerRadius,halfDepth,0.0, 2.0*
M_PI);
397 GeoLogVol *rodLog =
new GeoLogVol(baseName +
"Module2::Rod",rodTubs, FCal23Slugs);
398 rodPhys =
new GeoPhysVol(rodLog);
399 gapPhys->add(rodPhys);
400 modPhysical->add(
new GeoSerialIdentifier(0));
408 unsigned fieldModNumber(2);
409 unsigned fieldTileName(1);
415 unsigned fieldHvFt(8);
417 std::unique_ptr<IRDBQuery>
query;
419 query = rdbAccess->getQuery(
"LArFCalElectrodes", larVersionKey.
tag(),larVersionKey.
node());
421 query = rdbAccess->getQuery(
"LArFCalElectrodes",
"LArFCalElectrodes-00");
423 throw std::runtime_error(
"Error getting Session and Query pointers");
427 throw std::runtime_error(
"Error, unable to fetch fcal electrodes from the database!");
429 while(
query->next()) {
431 if(myGroup!=
query->data<
int>(fieldModNumber))
continue;
435 int thisTubeI=
query->data<
int>(fieldI);
436 int thisTubeJ=
query->data<
int>(fieldJ);
437 int thisTubeID =
query->data<
int>(fieldId);
438 int thisTubeMod = myGroup;
439 double thisTubeX=
query->data<
double>(fieldX);
440 double thisTubeY=
query->data<
double>(fieldY);
443 cmap->add_tube(
query->data<std::string>(fieldTileName),
444 thisTubeMod, thisTubeID, thisTubeI,thisTubeJ, thisTubeX, thisTubeY,
445 query->data<std::string>(fieldHvFt));
450 modPhysical->add(xf);
451 modPhysical->add(gapPhys);
463 GeoIntrusivePtr<GeoFullPhysVol> modPhysical{
nullptr};
465 double halfDepth = fullModuleDepth3/2;
466 double innerRadius = innerModuleRadius3;
467 double outerRadius = outerModuleRadius3;
468 GeoIntrusivePtr<GeoFullPhysVol>physVol;
474 GeoTubs *tubs =
new GeoTubs( innerRadius, outerRadius, halfDepth, 0, 2*
M_PI);
475 GeoLogVol *logVol =
new GeoLogVol(baseName +
"Module3::Absorber", tubs, FCal23Absorber);
476 physVol =
new GeoFullPhysVol(logVol);
481 if (!posRec)
throw std::runtime_error(
"Error, no lar position record in the database") ;
483 GeoAlignableTransform *xfAbs3 =
new GeoAlignableTransform(xfPos);
485 fcalPhysical->add(xfAbs3);
486 if (!bPos) fcalPhysical->add(
new GeoTransform(GeoTrf::RotateY3D(180*
Gaudi::Units::deg)));
487 fcalPhysical->add(physVol);
488 modPhysical = physVol;
490 std::string
tag = bPos? std::string(
"FCAL3_POS") : std::string(
"FCAL3_NEG");
495 if(!
status.isSuccess())
throw std::runtime_error ((std::string(
"Cannot store")+
tag).c_str());
499 if(!
status.isSuccess())
throw std::runtime_error ((std::string(
"Cannot store")+
tag).c_str());
505 static const double rotAngles[] =
533 double outerRadius = outerModuleRadius3;
534 double innerRadius = outerRadius - troughDepth;
535 double halfLength = fullModuleDepth3/ 2.0;
538 GeoTubs * tubs =
new GeoTubs(innerRadius,outerRadius,halfLength,startPhi,
deltaPhi );
539 GeoLogVol *logVol =
new GeoLogVol(baseName+
"Module3::CableTrough",tubs,FCalCableHarness);
540 GeoIntrusivePtr<GeoPhysVol>physVol =
new GeoPhysVol(logVol);
541 GeoXF::TRANSFUNCTION xf = GeoXF::Pow(GeoTrf::RotateZ3D(1.0),rotationAngle);
542 GeoSerialTransformer *st =
new GeoSerialTransformer(physVol,&xf,24);
543 modPhysical->add(st);
548 double halfDepth = fullGapDepth3/2.0;
549 double innerRadius = innerGapRadius3;
550 double outerRadius = outerGapRadius3;
552 GeoIntrusivePtr<GeoPhysVol> gapPhys{
nullptr};
553 GeoIntrusivePtr<GeoPhysVol> rodPhys{
nullptr};
555 GeoTubs *gapTubs =
new GeoTubs(0,outerRadius,halfDepth,0.0, 2.0*
M_PI);
556 GeoLogVol *gapLog =
new GeoLogVol(baseName +
"Module3::Gap",gapTubs,
LAr);
557 gapPhys =
new GeoPhysVol(gapLog);
559 GeoTubs *rodTubs =
new GeoTubs(0,innerRadius,halfDepth,0.0, 2.0*
M_PI);
560 GeoLogVol *rodLog =
new GeoLogVol(baseName +
"Module3::Rod",rodTubs, FCal23Slugs);
561 rodPhys =
new GeoPhysVol(rodLog);
562 gapPhys->add(rodPhys);
563 modPhysical->add(
new GeoSerialIdentifier(0));
571 unsigned fieldModNumber(2);
572 unsigned fieldTileName(1);
578 unsigned fieldHvFt(8);
580 std::unique_ptr<IRDBQuery>
query;
582 query = rdbAccess->getQuery(
"LArFCalElectrodes", larVersionKey.
tag(),larVersionKey.
node());
584 query = rdbAccess->getQuery(
"LArFCalElectrodes",
"LArFCalElectrodes-00");
586 throw std::runtime_error(
"Error getting Session and Query pointers");
590 throw std::runtime_error(
"Error, unable to fetch fcal electrodes from the database!");
592 while(
query->next()) {
594 if(myGroup!=
query->data<
int>(fieldModNumber))
continue;
597 int thisTubeI=
query->data<
int>(fieldI);
598 int thisTubeJ=
query->data<
int>(fieldJ);
599 int thisTubeID =
query->data<
int>(fieldId);
600 int thisTubeMod = myGroup;
601 double thisTubeX=
query->data<
double>(fieldX);
602 double thisTubeY=
query->data<
double>(fieldY);
605 cmap->add_tube(
query->data<std::string>(fieldTileName),
606 thisTubeMod, thisTubeID, thisTubeI,thisTubeJ, thisTubeX, thisTubeY,
607 query->data<std::string>(fieldHvFt));
612 modPhysical->add(xf);
613 modPhysical->add(gapPhys);
628 if(!
status.isSuccess())
throw std::runtime_error (
"Cannot store FCAL_ChannelMap");