86 if(
m_svcLocator->service (
"GeoModelSvc",geoModel) == StatusCode::FAILURE)
87 throw std::runtime_error(
"Error in FCALConstruction, cannot access GeoModelSvc");
88 if(
m_svcLocator->service (
"RDBAccessSvc",rdbAccess) == StatusCode::FAILURE)
89 throw std::runtime_error(
"Error in FCALConstruction, cannot access RDBAccessSvc");
92 m_fcalMod = rdbAccess->getRecordsetPtr(
"FCalMod", larVersionKey.tag(),larVersionKey.node());
94 m_fcalMod=rdbAccess->getRecordsetPtr(
"FCalMod",
"FCalMod-00");
96 throw std::runtime_error(
"Error getting FCAL Module parameters from database");
100 m_LArPosition = rdbAccess->getRecordsetPtr(
"LArPosition", larVersionKey.tag(), larVersionKey.node());
102 m_LArPosition = rdbAccess->getRecordsetPtr(
"LArPosition",
"LArPosition-00");
104 throw std::runtime_error(
"Error, no lar position table in database!");
111 const bool F1=
true,F2=
true,F3=
true;
115 throw std::runtime_error(
"Error in FCALConstruction, cannot access DetectorStore");
119 if (StatusCode::SUCCESS !=
detStore->retrieve(materialManager, std::string(
"MATERIALS")))
return nullptr;
121 const GeoMaterial *Copper = materialManager->
getMaterial(
"std::Copper");
122 if (!Copper)
throw std::runtime_error(
"Error in FCALConstruction, std::Copper is not found.");
124 const GeoMaterial *Iron = materialManager->
getMaterial(
"std::Iron");
125 if (!Iron)
throw std::runtime_error(
"Error in FCALConstruction, std::Iron is not found.");
127 const GeoMaterial *Lead = materialManager->
getMaterial(
"std::Lead");
128 if (!Lead)
throw std::runtime_error(
"Error in FCALConstruction, std::Lead is not found.");
130 const GeoMaterial *
LAr = materialManager->
getMaterial(
"std::LiquidArgon");
131 if (!
LAr)
throw std::runtime_error(
"Error in FCALConstruction, std::LiquidArgon is not found.");
133 const GeoMaterial *Air = materialManager->
getMaterial(
"std::Air");
134 if (!Air)
throw std::runtime_error(
"Error in FCALConstruction, std::Air is not found.");
136 const GeoMaterial *Kapton = materialManager->
getMaterial(
"std::Kapton");
137 if (!Kapton)
throw std::runtime_error(
"Error in FCALConstruction, std::Kapton is not found.");
139 const GeoMaterial *Glue = materialManager->
getMaterial(
"LAr::Glue");
140 if (!Glue)
throw std::runtime_error(
"Error in FCALConstruction, LAr::Glue is not found.");
142 const GeoMaterial *G10 = materialManager->
getMaterial(
"LAr::G10");
143 if (!G10)
throw std::runtime_error(
"Error in FCALConstruction, LAr::G10 is not found.");
146 const GeoMaterial *FCal1Absorber = materialManager->
getMaterial(
"LAr::FCal1Absorber");
147 if (!FCal1Absorber)
throw std::runtime_error(
"Error in FCALConstruction, LAr::FCal1Absorber is not found.");
149 const GeoMaterial *FCal23Absorber = materialManager->
getMaterial(
"LAr::FCal23Absorber");
150 if (!FCal23Absorber)
throw std::runtime_error(
"Error in FCALConstruction, LAr::FCal23Absorber is not found.");
152 const GeoMaterial *FCalCableHarness = materialManager->
getMaterial(
"LAr::FCalCableHarness");
153 if (!FCalCableHarness)
throw std::runtime_error(
"Error in FCALConstruction, LAr::FCalCableHarness is not found.");
155 const GeoMaterial *FCal23Slugs = materialManager->
getMaterial(
"LAr::FCal23Slugs");
156 if (!FCal23Slugs)
throw std::runtime_error(
"Error in FCALConstruction, LAr::FCal23Slugs is not found.");
159 auto cmap = std::make_unique<FCAL_ChannelMap>(0);
161 GeoIntrusivePtr<GeoFullPhysVol> fcalPhysical{
nullptr};
163 std::string baseName =
"LAr::FCAL::";
165 double startZFCal1 = (*m_fcalMod)[0]->getDouble(
"STARTPOSITION");
167 double startZFCal3 = (*m_fcalMod)[2]->getDouble(
"STARTPOSITION");
169 double outerModuleRadius1=(*m_fcalMod)[0]->getDouble(
"OUTERMODULERADIUS");
170 double outerModuleRadius2=(*m_fcalMod)[1]->getDouble(
"OUTERMODULERADIUS");
171 double outerModuleRadius3=(*m_fcalMod)[2]->getDouble(
"OUTERMODULERADIUS");
172 double innerModuleRadius1=(*m_fcalMod)[0]->getDouble(
"INNERMODULERADIUS");
173 double innerModuleRadius2=(*m_fcalMod)[1]->getDouble(
"INNERMODULERADIUS");
174 double innerModuleRadius3=(*m_fcalMod)[2]->getDouble(
"INNERMODULERADIUS");
175 double fullModuleDepth1=(*m_fcalMod)[0]->getDouble(
"FULLMODULEDEPTH");
176 double fullModuleDepth2=(*m_fcalMod)[1]->getDouble(
"FULLMODULEDEPTH");
177 double fullModuleDepth3=(*m_fcalMod)[2]->getDouble(
"FULLMODULEDEPTH");
178 double fullGapDepth1=(*m_fcalMod)[0]->getDouble(
"FULLGAPDEPTH");
179 double fullGapDepth2=(*m_fcalMod)[1]->getDouble(
"FULLGAPDEPTH");
180 double fullGapDepth3=(*m_fcalMod)[2]->getDouble(
"FULLGAPDEPTH");
181 double outerGapRadius1=(*m_fcalMod)[0]->getDouble(
"OUTERGAPRADIUS");
182 double outerGapRadius2=(*m_fcalMod)[1]->getDouble(
"OUTERGAPRADIUS");
183 double outerGapRadius3=(*m_fcalMod)[2]->getDouble(
"OUTERGAPRADIUS");
184 double innerGapRadius1=(*m_fcalMod)[0]->getDouble(
"INNERGAPRADIUS");
185 double innerGapRadius2=(*m_fcalMod)[1]->getDouble(
"INNERGAPRADIUS");
186 double innerGapRadius3=(*m_fcalMod)[2]->getDouble(
"INNERGAPRADIUS");
192 double outerRadius =
std::max(outerModuleRadius1,
std::max(outerModuleRadius2,outerModuleRadius3));
193 double innerRadius =
std::min(innerModuleRadius1,
std::min(innerModuleRadius2,innerModuleRadius3));
194 double depthZFCal3 = fullModuleDepth3;
195 double stopZFCal3 = startZFCal3 + depthZFCal3;
197 double totalDepth = stopZFCal3 - startZFCal1;
198 double halfDepth = totalDepth/2.;
200 std::string
name = baseName +
"LiquidArgonC";
201 GeoTubs *tubs =
new GeoTubs(innerRadius,outerRadius,halfDepth,0,360*
Gaudi::Units::deg);
202 GeoLogVol *logVol=
new GeoLogVol(
name, tubs,
LAr);
203 fcalPhysical =
new GeoFullPhysVol(logVol);
212 GeoIntrusivePtr<GeoFullPhysVol> modPhysical{
nullptr};
214 double halfDepth = fullModuleDepth1/2;
215 double innerRadius = innerModuleRadius1;
216 double outerRadius = outerModuleRadius1;
217 GeoIntrusivePtr<GeoFullPhysVol>physVol;
223 GeoTubs *tubs =
new GeoTubs( innerRadius, outerRadius, halfDepth, 0, 2*
M_PI);
224 GeoLogVol *logVol =
new GeoLogVol(baseName +
"Module1::Absorber", tubs, FCal1Absorber);
225 physVol =
new GeoFullPhysVol(logVol);
231 if (!posRec)
throw std::runtime_error(
"Error, no lar position record in the database") ;
233 GeoAlignableTransform *xfAbs1 =
new GeoAlignableTransform(xfPos);
235 fcalPhysical->add(xfAbs1);
236 if (!bPos) fcalPhysical->add(
new GeoTransform(GeoTrf::RotateY3D(180*
Gaudi::Units::deg)));
237 fcalPhysical->add(physVol);
238 modPhysical = physVol;
240 std::string
tag = bPos? std::string(
"FCAL1_POS") : std::string(
"FCAL1_NEG");
245 if(!
status.isSuccess())
throw std::runtime_error ((std::string(
"Cannot store")+
tag).c_str());
249 if(!
status.isSuccess())
throw std::runtime_error ((std::string(
"Cannot store")+
tag).c_str());
255 double outerRadius = outerModuleRadius1;
256 double innerRadius = outerRadius - troughDepth;
257 double halfLength = fullModuleDepth1/ 2.0;
260 GeoTubs * tubs =
new GeoTubs(innerRadius,outerRadius,halfLength,startPhi,
deltaPhi );
261 GeoLogVol *logVol =
new GeoLogVol(baseName+
"Module1::CableTrough",tubs,FCalCableHarness);
262 GeoIntrusivePtr<GeoPhysVol>physVol =
new GeoPhysVol(logVol);
263 GeoGenfun::Variable
i;
265 GeoXF::TRANSFUNCTION xf = GeoXF::Pow(GeoTrf::RotateZ3D(1.0),rotationAngle);
266 GeoSerialTransformer *st =
new GeoSerialTransformer(physVol,&xf,16);
267 modPhysical->add(st);
271 double halfDepth = fullGapDepth1/2.0;
272 double innerRadius = innerGapRadius1;
273 double outerRadius = outerGapRadius1;
274 GeoIntrusivePtr<GeoPhysVol>physVol{
nullptr};
276 GeoTubs *tubs =
new GeoTubs(innerRadius,outerRadius,halfDepth,0.0, 2.0*
M_PI);
277 GeoLogVol *logVol =
new GeoLogVol(baseName +
"Module1::Gap",tubs,
LAr);
278 physVol =
new GeoPhysVol(logVol);
279 modPhysical->add(
new GeoSerialIdentifier(0));
287 unsigned fieldModNumber(2);
288 unsigned fieldTileName(1);
294 unsigned fieldHvFt(8);
296 std::unique_ptr<IRDBQuery>
query;
298 query = rdbAccess->getQuery(
"LArFCalElectrodes", larVersionKey.tag(),larVersionKey.node());
300 query = rdbAccess->getQuery(
"LArFCalElectrodes",
"LArFCalElectrodes-00");
302 throw std::runtime_error(
"Error getting Session and Query pointers");
306 throw std::runtime_error(
"Error, unable to fetch fcal electrodes from the database!");
309 while(
query->next()) {
311 if(myGroup!=
query->data<
int>(fieldModNumber))
continue;
314 int thisTubeI=
query->data<
int>(fieldI);
315 int thisTubeJ=
query->data<
int>(fieldJ);
316 int thisTubeID =
query->data<
int>(fieldId);
317 int thisTubeMod = myGroup;
318 double thisTubeX=
query->data<
double>(fieldX);
319 double thisTubeY=
query->data<
double>(fieldY);
322 cmap->add_tube(
query->data<std::string>(fieldTileName),
323 thisTubeMod, thisTubeID, thisTubeI,thisTubeJ, thisTubeX, thisTubeY,
324 query->data<std::string>(fieldHvFt));
329 modPhysical->add(xf);
330 modPhysical->add(physVol);
341 GeoIntrusivePtr<GeoFullPhysVol> modPhysical{
nullptr};
343 double halfDepth = fullModuleDepth2/2;
344 double innerRadius = innerModuleRadius2;
345 double outerRadius = outerModuleRadius2;
346 GeoIntrusivePtr<GeoFullPhysVol>physVol;
352 GeoTubs *tubs =
new GeoTubs( innerRadius, outerRadius, halfDepth, 0, 2*
M_PI);
353 GeoLogVol *logVol =
new GeoLogVol(baseName +
"Module2::Absorber", tubs, FCal23Absorber);
354 physVol =
new GeoFullPhysVol(logVol);
360 if (!posRec)
throw std::runtime_error(
"Error, no lar position record in the database") ;
362 GeoAlignableTransform *xfAbs2 =
new GeoAlignableTransform(xfPos);
364 fcalPhysical->add(xfAbs2);
365 if (!bPos) fcalPhysical->add(
new GeoTransform(GeoTrf::RotateY3D(180*
Gaudi::Units::deg)));
366 fcalPhysical->add(physVol);
367 modPhysical = physVol;
369 std::string
tag = bPos? std::string(
"FCAL2_POS") : std::string(
"FCAL2_NEG");
374 if(!
status.isSuccess())
throw std::runtime_error ((std::string(
"Cannot store")+
tag).c_str());
378 if(!
status.isSuccess())
throw std::runtime_error ((std::string(
"Cannot store")+
tag).c_str());
384 double outerRadius = outerModuleRadius2;
385 double innerRadius = outerRadius - troughDepth;
386 double halfLength = fullModuleDepth2/ 2.0;
389 GeoTubs * tubs =
new GeoTubs(innerRadius,outerRadius,halfLength,startPhi,
deltaPhi );
390 GeoLogVol *logVol =
new GeoLogVol(baseName+
"Module2::CableTrough",tubs,FCalCableHarness);
391 GeoIntrusivePtr<GeoPhysVol>physVol =
new GeoPhysVol(logVol);
392 GeoGenfun::Variable
i;
394 GeoXF::TRANSFUNCTION xf = GeoXF::Pow(GeoTrf::RotateZ3D(1.0),rotationAngle);
395 GeoSerialTransformer *st =
new GeoSerialTransformer(physVol,&xf,16);
396 modPhysical->add(st);
401 double halfDepth = fullGapDepth2/2.0;
402 double innerRadius = innerGapRadius2;
403 double outerRadius = outerGapRadius2;
405 GeoIntrusivePtr<GeoPhysVol> gapPhys{
nullptr};
406 GeoIntrusivePtr<GeoPhysVol> rodPhys{
nullptr};
408 GeoTubs *gapTubs =
new GeoTubs(0,outerRadius,halfDepth,0.0, 2.0*
M_PI);
409 GeoLogVol *gapLog =
new GeoLogVol(baseName +
"Module2::Gap",gapTubs,
LAr);
410 gapPhys =
new GeoPhysVol(gapLog);
412 GeoTubs *rodTubs =
new GeoTubs(0,innerRadius,halfDepth,0.0, 2.0*
M_PI);
413 GeoLogVol *rodLog =
new GeoLogVol(baseName +
"Module2::Rod",rodTubs, FCal23Slugs);
414 rodPhys =
new GeoPhysVol(rodLog);
415 gapPhys->add(rodPhys);
416 modPhysical->add(
new GeoSerialIdentifier(0));
424 unsigned fieldModNumber(2);
425 unsigned fieldTileName(1);
431 unsigned fieldHvFt(8);
433 std::unique_ptr<IRDBQuery>
query;
435 query = rdbAccess->getQuery(
"LArFCalElectrodes", larVersionKey.tag(),larVersionKey.node());
437 query = rdbAccess->getQuery(
"LArFCalElectrodes",
"LArFCalElectrodes-00");
439 throw std::runtime_error(
"Error getting Session and Query pointers");
443 throw std::runtime_error(
"Error, unable to fetch fcal electrodes from the database!");
445 while(
query->next()) {
447 if(myGroup!=
query->data<
int>(fieldModNumber))
continue;
451 int thisTubeI=
query->data<
int>(fieldI);
452 int thisTubeJ=
query->data<
int>(fieldJ);
453 int thisTubeID =
query->data<
int>(fieldId);
454 int thisTubeMod = myGroup;
455 double thisTubeX=
query->data<
double>(fieldX);
456 double thisTubeY=
query->data<
double>(fieldY);
459 cmap->add_tube(
query->data<std::string>(fieldTileName),
460 thisTubeMod, thisTubeID, thisTubeI,thisTubeJ, thisTubeX, thisTubeY,
461 query->data<std::string>(fieldHvFt));
466 modPhysical->add(xf);
467 modPhysical->add(gapPhys);
479 GeoIntrusivePtr<GeoFullPhysVol> modPhysical{
nullptr};
481 double halfDepth = fullModuleDepth3/2;
482 double innerRadius = innerModuleRadius3;
483 double outerRadius = outerModuleRadius3;
484 GeoIntrusivePtr<GeoFullPhysVol>physVol;
490 GeoTubs *tubs =
new GeoTubs( innerRadius, outerRadius, halfDepth, 0, 2*
M_PI);
491 GeoLogVol *logVol =
new GeoLogVol(baseName +
"Module3::Absorber", tubs, FCal23Absorber);
492 physVol =
new GeoFullPhysVol(logVol);
497 if (!posRec)
throw std::runtime_error(
"Error, no lar position record in the database") ;
499 GeoAlignableTransform *xfAbs3 =
new GeoAlignableTransform(xfPos);
501 fcalPhysical->add(xfAbs3);
502 if (!bPos) fcalPhysical->add(
new GeoTransform(GeoTrf::RotateY3D(180*
Gaudi::Units::deg)));
503 fcalPhysical->add(physVol);
504 modPhysical = physVol;
506 std::string
tag = bPos? std::string(
"FCAL3_POS") : std::string(
"FCAL3_NEG");
511 if(!
status.isSuccess())
throw std::runtime_error ((std::string(
"Cannot store")+
tag).c_str());
515 if(!
status.isSuccess())
throw std::runtime_error ((std::string(
"Cannot store")+
tag).c_str());
521 static const double rotAngles[] =
549 double outerRadius = outerModuleRadius3;
550 double innerRadius = outerRadius - troughDepth;
551 double halfLength = fullModuleDepth3/ 2.0;
554 GeoTubs * tubs =
new GeoTubs(innerRadius,outerRadius,halfLength,startPhi,
deltaPhi );
555 GeoLogVol *logVol =
new GeoLogVol(baseName+
"Module3::CableTrough",tubs,FCalCableHarness);
556 GeoIntrusivePtr<GeoPhysVol>physVol =
new GeoPhysVol(logVol);
557 GeoXF::TRANSFUNCTION xf = GeoXF::Pow(GeoTrf::RotateZ3D(1.0),rotationAngle);
558 GeoSerialTransformer *st =
new GeoSerialTransformer(physVol,&xf,24);
559 modPhysical->add(st);
564 double halfDepth = fullGapDepth3/2.0;
565 double innerRadius = innerGapRadius3;
566 double outerRadius = outerGapRadius3;
568 GeoIntrusivePtr<GeoPhysVol> gapPhys{
nullptr};
569 GeoIntrusivePtr<GeoPhysVol> rodPhys{
nullptr};
571 GeoTubs *gapTubs =
new GeoTubs(0,outerRadius,halfDepth,0.0, 2.0*
M_PI);
572 GeoLogVol *gapLog =
new GeoLogVol(baseName +
"Module3::Gap",gapTubs,
LAr);
573 gapPhys =
new GeoPhysVol(gapLog);
575 GeoTubs *rodTubs =
new GeoTubs(0,innerRadius,halfDepth,0.0, 2.0*
M_PI);
576 GeoLogVol *rodLog =
new GeoLogVol(baseName +
"Module3::Rod",rodTubs, FCal23Slugs);
577 rodPhys =
new GeoPhysVol(rodLog);
578 gapPhys->add(rodPhys);
579 modPhysical->add(
new GeoSerialIdentifier(0));
587 unsigned fieldModNumber(2);
588 unsigned fieldTileName(1);
594 unsigned fieldHvFt(8);
596 std::unique_ptr<IRDBQuery>
query;
598 query = rdbAccess->getQuery(
"LArFCalElectrodes", larVersionKey.tag(),larVersionKey.node());
600 query = rdbAccess->getQuery(
"LArFCalElectrodes",
"LArFCalElectrodes-00");
602 throw std::runtime_error(
"Error getting Session and Query pointers");
606 throw std::runtime_error(
"Error, unable to fetch fcal electrodes from the database!");
608 while(
query->next()) {
610 if(myGroup!=
query->data<
int>(fieldModNumber))
continue;
613 int thisTubeI=
query->data<
int>(fieldI);
614 int thisTubeJ=
query->data<
int>(fieldJ);
615 int thisTubeID =
query->data<
int>(fieldId);
616 int thisTubeMod = myGroup;
617 double thisTubeX=
query->data<
double>(fieldX);
618 double thisTubeY=
query->data<
double>(fieldY);
621 cmap->add_tube(
query->data<std::string>(fieldTileName),
622 thisTubeMod, thisTubeID, thisTubeI,thisTubeJ, thisTubeX, thisTubeY,
623 query->data<std::string>(fieldHvFt));
628 modPhysical->add(xf);
629 modPhysical->add(gapPhys);
644 if(!
status.isSuccess())
throw std::runtime_error (
"Cannot store FCAL_ChannelMap");