10 #include "GaudiKernel/ISvcLocator.h"
11 #include "GaudiKernel/MsgStream.h"
12 #include "GaudiKernel/IMessageSvc.h"
13 #include "GaudiKernel/SystemOfUnits.h"
16 #include "GeoModelKernel/GeoMaterial.h"
17 #include "GeoModelKernel/GeoFullPhysVol.h"
18 #include "GeoModelKernel/GeoPhysVol.h"
19 #include "GeoModelKernel/GeoLogVol.h"
20 #include "GeoModelKernel/GeoTransform.h"
21 #include "GeoModelKernel/GeoSerialTransformer.h"
22 #include "GeoModelKernel/GeoTube.h"
23 #include "GeoModelKernel/GeoBox.h"
24 #include "GeoModelKernel/GeoPcon.h"
25 #include "GeoModelKernel/GeoTrd.h"
26 #include "GeoModelKernel/GeoShape.h"
27 #include "GeoModelKernel/GeoShapeUnion.h"
28 #include "GeoModelKernel/GeoShapeShift.h"
29 #include "GeoModelKernel/GeoShapeSubtraction.h"
30 #include "GeoModelKernel/GeoDefinitions.h"
39 #include "GeoGenericFunctions/Variable.h"
51 ISvcLocator* svcLocator = Gaudi::svcLocator();
53 log << MSG::INFO <<
"Start building EC electronics geometry" <<
endmsg;
55 SmartIF<StoreGateSvc>
detStore{svcLocator->service(
"DetectorStore")};
57 throw std::runtime_error(
"Error in EndcapDMConstruction, cannot access DetectorStore");
59 SmartIF<IGeoModelSvc> geoModel{svcLocator->service(
"GeoModelSvc")};
60 if(!geoModel.isValid())
61 throw std::runtime_error(
"Error in EndcapDMConstruction, cannot access GeoModelSvc");
63 SmartIF<IRDBAccessSvc> rdbAccess{svcLocator->service(
"RDBAccessSvc")};
64 if(!rdbAccess.isValid())
65 throw std::runtime_error(
"Error in EndcapDMConstruction, cannot access RDBAccessSvc");
69 if(StatusCode::SUCCESS !=
detStore->retrieve(materialManager, std::string(
"MATERIALS")))
70 throw std::runtime_error(
"Error in EndcapDMConstruction, stored MaterialManager is not found");
73 if(LArEndcapCrate->size()==0) {
74 log << MSG::INFO <<
"Skip building EC electronics. Database flag not set" <<
endmsg;
77 IRDBRecordset_ptr LArEndcapCratePhiPos = rdbAccess->getRecordsetPtr(
"LArEndcapCratePhiPos",keyLAr.
tag(),keyLAr.
node());
83 std::map<std::string, unsigned int> boxMap;
84 for(
unsigned int j=0; j<BarrelDMBoxes->size(); j++) {
85 const std::string&
key = (*BarrelDMBoxes)[j]->getString(
"BOXNAME");
88 std::map<std::string, unsigned int> tubeMap;
89 for(
unsigned int i=0;
i<BarrelDMTubes->size();
i++) {
90 const std::string&
key = (*BarrelDMTubes)[
i]->getString(
"TUBENAME");
93 std::map<std::string, unsigned int> ecCrateMap;
94 for(
unsigned int i=0;
i<LArEndcapCrate->size();
i++) {
95 const std::string&
key = (*LArEndcapCrate)[
i]->getString(
"BOXNAME");
99 unsigned int recordIndex;
102 const GeoMaterial *alu = materialManager->
getMaterial(
"std::Aluminium");
103 const GeoMaterial* matBoardsEnvelope = materialManager->
getMaterial(
"LAr::BoardsEnvelope");
106 recordIndex = tubeMap[
"Ped2"];
107 double ped2zhlen = (*BarrelDMTubes)[recordIndex]->getDouble(
"ZHLEN");
108 double ped2minr = (*BarrelDMTubes)[recordIndex]->getDouble(
"MINR");
109 double ped2maxr = (*BarrelDMTubes)[recordIndex]->getDouble(
"MAXR");
110 double ped2ytr = (*BarrelDMTubes)[recordIndex]->getDouble(
"YTR");
111 recordIndex = tubeMap[
"Ped3"];
112 double ped3zhlen = (*BarrelDMTubes)[recordIndex]->getDouble(
"ZHLEN");
113 double ped3minr = (*BarrelDMTubes)[recordIndex]->getDouble(
"MINR");
114 double ped3maxr = (*BarrelDMTubes)[recordIndex]->getDouble(
"MAXR");
115 double ped3xtr = (*BarrelDMTubes)[recordIndex]->getDouble(
"XTR");
117 recordIndex = boxMap[
"Pedest"];
118 double pedesthlen = (*BarrelDMBoxes)[recordIndex]->getDouble(
"HLEN");
119 double pedesthwdt = (*BarrelDMBoxes)[recordIndex]->getDouble(
"HWDT");
120 double pedesthhgt = (*BarrelDMBoxes)[recordIndex]->getDouble(
"HHGT");
121 double pedestxtr = (*BarrelDMBoxes)[recordIndex]->getDouble(
"XTR");
122 double pedestztr = (*BarrelDMBoxes)[recordIndex]->getDouble(
"ZTR");
123 recordIndex = boxMap[
"Ped1"];
124 double ped1hlen = (*BarrelDMBoxes)[recordIndex]->getDouble(
"HLEN");
125 double ped1hwdt = (*BarrelDMBoxes)[recordIndex]->getDouble(
"HWDT");
126 double ped1hhgt = (*BarrelDMBoxes)[recordIndex]->getDouble(
"HHGT");
127 recordIndex = boxMap[
"Crate1"];
128 double crate1hlen = (*BarrelDMBoxes)[recordIndex]->getDouble(
"HLEN");
129 double crate1hwdt = (*BarrelDMBoxes)[recordIndex]->getDouble(
"HWDT");
130 double crate1hhgt = (*BarrelDMBoxes)[recordIndex]->getDouble(
"HHGT");
131 double crate1xtr = (*BarrelDMBoxes)[recordIndex]->getDouble(
"XTR");
132 double crate1ztr = (*BarrelDMBoxes)[recordIndex]->getDouble(
"ZTR");
133 recordIndex = boxMap[
"Crate2"];
134 double crate2hlen = (*BarrelDMBoxes)[recordIndex]->getDouble(
"HLEN");
135 double crate2hwdt = (*BarrelDMBoxes)[recordIndex]->getDouble(
"HWDT");
136 double crate2hhgt = (*BarrelDMBoxes)[recordIndex]->getDouble(
"HHGT");
137 recordIndex = boxMap[
"Crate3"];
138 double crate3hlen = (*BarrelDMBoxes)[recordIndex]->getDouble(
"HLEN");
139 double crate3hwdt = (*BarrelDMBoxes)[recordIndex]->getDouble(
"HWDT");
140 double crate3hhgt = (*BarrelDMBoxes)[recordIndex]->getDouble(
"HHGT");
141 double crate3xtr = (*BarrelDMBoxes)[recordIndex]->getDouble(
"XTR");
142 recordIndex = boxMap[
"BoardE"];
143 double BoardEhlen = (*BarrelDMBoxes)[recordIndex]->getDouble(
"HLEN");
144 double BoardEhwdt = (*BarrelDMBoxes)[recordIndex]->getDouble(
"HWDT");
145 double BoardEhhgt = (*BarrelDMBoxes)[recordIndex]->getDouble(
"HHGT");
146 double BoardExtr = (*BarrelDMBoxes)[recordIndex]->getDouble(
"XTR");
147 double BoardEytr = (*BarrelDMBoxes)[recordIndex]->getDouble(
"YTR");
148 double BoardEztr = (*BarrelDMBoxes)[recordIndex]->getDouble(
"ZTR");
151 std::map<std::string, unsigned int>::const_iterator
it = ecCrateMap.find(
"Crate1");
152 if(
it != ecCrateMap.end()) {
153 recordIndex = ecCrateMap[
"Crate1"];
154 double ztrEC = (*LArEndcapCrate)[recordIndex]->getDouble(
"ZTR");
156 if(m_activateFT && ztrEC == -249.05){
159 <<
" to fit mother volume" <<
endmsg;
168 double xtrEC = (*LArEndcapCrate)[recordIndex]->getDouble(
"XTR");
173 it = ecCrateMap.find(
"Pedest");
174 if(
it!=ecCrateMap.end()) {
175 recordIndex = ecCrateMap[
"Pedest"];
176 pedestxtr = (*LArEndcapCrate)[recordIndex]->getDouble(
"XTR");
178 it = ecCrateMap.find(
"BoardE");
179 if(
it!=ecCrateMap.end()) {
180 recordIndex = ecCrateMap[
"BoardE"];
181 BoardExtr = (*LArEndcapCrate)[recordIndex]->getDouble(
"XTR");
185 const double epsilon = m_activateFT? 0.: 6.;
188 GeoBox *Pedestal =
new GeoBox(pedesthlen, pedesthwdt, pedesthhgt - epsilon);
189 GeoBox *Ped1 =
new GeoBox(ped1hlen, ped1hwdt, ped1hhgt - epsilon);
190 GeoTube *Ped2 =
new GeoTube(ped2minr, ped2maxr, ped2zhlen);
191 GeoTube *Ped3 =
new GeoTube(ped3minr,ped3maxr , ped3zhlen);
192 const GeoShape & CratePed=((*Pedestal).subtract(*Ped1).
193 subtract((*Ped2) <<GeoTrf::TranslateY3D(-ped2ytr)*GeoTrf::RotateY3D(90*
Gaudi::Units::deg)).
194 subtract((*Ped3) <<GeoTrf::TranslateX3D(-ped3xtr)).
195 subtract((*Ped2) <<GeoTrf::TranslateY3D(ped2ytr)*GeoTrf::RotateY3D(90*
Gaudi::Units::deg)));
197 GeoLogVol *lvped =
new GeoLogVol(
"LAr::DM::Ped",&CratePed,alu);
198 GeoIntrusivePtr<GeoPhysVol>pedestal =
new GeoPhysVol(lvped);
201 GeoBox *Crate1 =
new GeoBox(crate1hlen, crate1hwdt, crate1hhgt - epsilon);
202 GeoBox *Crate2 =
new GeoBox(crate2hlen, crate2hwdt, crate2hhgt - epsilon);
203 GeoBox *Crate3 =
new GeoBox(crate3hlen, crate3hwdt, crate3hhgt - epsilon);
204 const GeoShape & FEBCrate=(*Crate1).subtract(*Crate2).add((*Crate3) <<GeoTrf::TranslateX3D(-crate3xtr));
206 GeoLogVol *lvcrate =
new GeoLogVol(
"LAr::DM::Crate",&FEBCrate,alu);
207 GeoIntrusivePtr<GeoPhysVol>crate =
new GeoPhysVol(lvcrate);
210 GeoBox *BoardEnvelope =
new GeoBox(BoardEhlen, BoardEhwdt, BoardEhhgt - epsilon);
211 GeoLogVol *lvbenv =
new GeoLogVol(
"LAr::DM::FEBoard",BoardEnvelope,matBoardsEnvelope);
212 GeoIntrusivePtr<GeoPhysVol>boardenvelope =
new GeoPhysVol(lvbenv);
215 GeoTransform* xfCrateBase(
new GeoTransform(GeoTrf::TranslateX3D(crate1xtr)*GeoTrf::TranslateZ3D(crate1ztr)));
216 GeoTransform* xfPedestBase(
new GeoTransform(GeoTrf::TranslateX3D(pedestxtr)*GeoTrf::TranslateZ3D(pedestztr)));
217 GeoTransform* xfBoardEBase1(
new GeoTransform(GeoTrf::TranslateY3D(BoardEytr)*GeoTrf::TranslateX3D(BoardExtr)*GeoTrf::TranslateZ3D(BoardEztr)));
218 GeoTransform* xfBoardEBase2(
new GeoTransform(GeoTrf::TranslateY3D(-BoardEytr)*GeoTrf::TranslateX3D(BoardExtr)*GeoTrf::TranslateZ3D(BoardEztr)));
220 for(
unsigned i(0);
i<LArEndcapCratePhiPos->size(); ++
i) {
222 GeoTransform* xfPhiPos(
new GeoTransform(GeoTrf::RotateZ3D(phiPos)));
224 envelope->add(xfPhiPos);
225 envelope->add(xfCrateBase);
226 envelope->add(crate);
228 envelope->add(xfPhiPos);
229 envelope->add(xfPedestBase);
230 envelope->add(pedestal);
232 envelope->add(xfPhiPos);
233 envelope->add(xfBoardEBase1);
234 envelope->add(boardenvelope);
236 envelope->add(xfPhiPos);
237 envelope->add(xfBoardEBase2);
238 envelope->add(boardenvelope);
242 std::string
name =
"LAr::Endcap::SignalFT::";
245 const GeoMaterial* iron = materialManager->
getMaterial(
"std::Iron");
249 const GeoMaterial* wflange_mat = materialManager->
getMaterial(
"LAr::FT::WarmFlange");
251 GeoShape* wflange =
new GeoTube(0., wflange_R, wflange_height/2);
252 GeoLogVol* wflangeLV =
new GeoLogVol(
name +
"WarmFlange", wflange, wflange_mat);
253 GeoIntrusivePtr<GeoPhysVol> wflangePV =
new GeoPhysVol(wflangeLV);
258 const GeoMaterial* bellow_mat = materialManager->
getMaterial(
"LAr::FT::Bellow");
260 const double bellow_Rinner = bellow_Router - bellow_wall;
261 GeoShape* bellow =
new GeoTube(bellow_Rinner, bellow_Router, bellow_height/2);
262 GeoLogVol* bellowLV =
new GeoLogVol(
name +
"Bellow", bellow, bellow_mat);
263 GeoIntrusivePtr<GeoPhysVol> bellowPV =
new GeoPhysVol(bellowLV);
265 const GeoMaterial* vcables_mat = materialManager->
getMaterial(
"LAr::FT::VacuumCables");
267 GeoShape* vcables =
new GeoTube(0., bellow_Rinner, bellow_height/2);
268 GeoLogVol* vcablesLV =
new GeoLogVol(
name +
"VacuumCables", vcables, vcables_mat);
269 GeoIntrusivePtr<GeoPhysVol> vcablesPV =
new GeoPhysVol(vcablesLV);
273 const GeoMaterial* cflange_mat = materialManager->
getMaterial(
"LAr::FT::ColdFlange");
274 GeoShape* cflange =
new GeoTube(0., cflange_Router, cflange_height/2);
275 GeoLogVol* cflangeLV =
new GeoLogVol(
name +
"ColdFlange", cflange, cflange_mat);
276 GeoIntrusivePtr<GeoPhysVol> cflangePV =
new GeoPhysVol(cflangeLV);
278 const double coldbox1_Router = cflange_Router;
286 const GeoMaterial* coldbox_mat = iron;
287 GeoShape* coldbox1 =
new GeoTube(coldbox1_Router - coldbox1_wall, coldbox1_Router, coldbox1_height/2);
288 GeoShape* coldbox11 =
new GeoTube(0., coldbox1_Router, coldbox1_height/2);
289 GeoLogVol* coldbox1LV =
new GeoLogVol(
name +
"ColdBox1", coldbox1, coldbox_mat);
290 GeoIntrusivePtr<GeoPhysVol> coldbox1PV =
new GeoPhysVol(coldbox1LV);
291 GeoShape* coldbox21 =
new GeoTube(0., coldbox1_Router, coldbox2_height/2);
292 GeoShape* coldbox22 =
new GeoTube(0., hole_r, coldbox2_height);
293 const GeoShape& coldbox2 = coldbox21->subtract((*coldbox22) << GeoTrf::TranslateY3D(hole_shift));
294 GeoLogVol* coldbox2LV =
new GeoLogVol(
name +
"ColdBox2", &coldbox2, coldbox_mat);
295 GeoIntrusivePtr<GeoPhysVol> coldbox2PV =
new GeoPhysVol(coldbox2LV);
296 GeoShape* coldbox3 =
new GeoTube(hole_r, coldbox3_Router, coldbox3_height/2);
297 GeoShape* coldbox31 =
new GeoTube(0., coldbox3_Router, coldbox3_height/2);
298 GeoLogVol* coldbox3LV =
new GeoLogVol(
name +
"ColdBox3", coldbox3, coldbox_mat);
299 GeoIntrusivePtr<GeoPhysVol> coldbox3PV =
new GeoPhysVol(coldbox3LV);
301 GeoTrf::TranslateZ3D bellow_pos(-wflange_height/2 - bellow_height/2);
302 GeoTrf::TranslateZ3D cflange_pos(-wflange_height/2 - bellow_height - cflange_height/2);
303 GeoTrf::TranslateZ3D coldbox1_pos(-wflange_height/2 - bellow_height - cflange_height - coldbox1_height/2);
304 GeoTrf::TranslateZ3D coldbox2_pos(-wflange_height/2 - bellow_height - cflange_height - coldbox1_height - coldbox2_height/2);
305 GeoTrf::Translate3D coldbox2hole_pos(
307 -wflange_height/2 - bellow_height - cflange_height - coldbox1_height - coldbox2_height/2
309 GeoTrf::Translate3D coldbox3_pos(
311 -wflange_height/2 - bellow_height - cflange_height - coldbox1_height - coldbox2_height - coldbox3_height/2
314 const GeoShape& FTenvelope = wflange->add(
315 (*bellow) << bellow_pos
317 (*cflange) << cflange_pos
319 (*coldbox11) << coldbox1_pos
321 (*coldbox21) << coldbox2_pos
323 (*coldbox31) << coldbox3_pos
326 GeoLogVol* FTLV =
new GeoLogVol(
name +
"Envelope",
330 GeoIntrusivePtr<GeoPhysVol> FTPV =
new GeoPhysVol(FTLV);
332 FTPV->add(wflangePV);
333 GeoTransform *bellow_trf =
new GeoTransform(bellow_pos);
334 FTPV->add(bellow_trf);
336 FTPV->add(bellow_trf);
337 FTPV->add(vcablesPV);
338 GeoTransform *cflange_trf =
new GeoTransform(cflange_pos);
339 FTPV->add(cflange_trf);
340 FTPV->add(cflangePV);
341 GeoTransform *coldbox1_trf =
new GeoTransform(coldbox1_pos);
342 FTPV->add(coldbox1_trf);
343 FTPV->add(coldbox1PV);
344 GeoTransform *coldbox2_trf =
new GeoTransform(coldbox2_pos);
345 FTPV->add(coldbox2_trf);
346 FTPV->add(coldbox2PV);
347 GeoTransform *coldbox3_trf =
new GeoTransform(coldbox3_pos);
348 FTPV->add(coldbox3_trf);
349 FTPV->add(coldbox3PV);
351 const GeoMaterial* lar_mat = materialManager->
getMaterial(
"std::LiquidArgon");
352 GeoShape* lar1 =
new GeoTube(0., coldbox1_Router - coldbox1_wall, coldbox1_height/2);
353 GeoShape* lar2 =
new GeoTube(0., hole_r, coldbox1_height);
354 const GeoShape& lar = lar1->subtract((*lar2) << GeoTrf::TranslateY3D(hole_shift));
355 GeoLogVol* larLV =
new GeoLogVol(
name +
"LAr", &lar, lar_mat);
356 GeoIntrusivePtr<GeoPhysVol> larPV =
new GeoPhysVol(larLV);
357 FTPV->add(coldbox1_trf);
360 const GeoMaterial *pigtail_mat = materialManager->
getMaterial(
"LAr::FT::Pigtail");
362 const double pth = (coldbox1_height + coldbox2_height + coldbox3_height) / 2;
363 GeoTransform *pigtail_trf =
new GeoTransform(
364 GeoTrf::Translate3D(0, hole_shift,
365 -wflange_height/2 - bellow_height - cflange_height - pth
367 GeoShape* pigtail =
new GeoTube(0., hole_r, pth);
368 GeoLogVol* pigtailLV =
new GeoLogVol(
name +
"Pigtails", pigtail, pigtail_mat);
369 GeoIntrusivePtr<GeoPhysVol> pigtailPV =
new GeoPhysVol(pigtailLV);
370 FTPV->add(pigtail_trf);
371 FTPV->add(pigtailPV);
376 const GeoMaterial* ocable_mat = materialManager->
getMaterial(
"LAr::FT::Cable");
377 GeoShape* ocable =
new GeoTube(0., ocable_R, ocable_len / 2);
378 GeoLogVol* ocableLV =
new GeoLogVol(
"LAr::Endcap::FTCables", ocable, ocable_mat);
379 GeoIntrusivePtr<GeoPhysVol> ocablePV =
new GeoPhysVol(ocableLV);
384 const GeoMaterial* chimney_mat = iron;
385 GeoShape* chimney1 =
new GeoTube(chimney_Router - chimney_wall, chimney_Router, chimney_height/2);
388 GeoShape* chimney2 =
new GeoTube(chimney_Router, chimney_Router + ch_lowring_r, ch_lowring_h/2);
391 GeoShape* chimney3 =
new GeoTube(bellow_Router, chimney_Router + ch_upring_r, ch_upring_h/2);
392 const GeoShape& chimney = chimney1->add(
393 (*chimney2) << GeoTrf::TranslateZ3D(-chimney_height/2 + ch_lowring_h/2)
395 (*chimney3) << GeoTrf::TranslateZ3D(chimney_height/2 - ch_upring_h/2)
397 GeoLogVol* chimneyLV =
new GeoLogVol(
"LAr::Endcap::FTChimney", &chimney, chimney_mat);
398 GeoIntrusivePtr<GeoPhysVol> chimneyPV =
new GeoPhysVol(chimneyLV);
403 const double r0 = cryo_Router + chimney_height + wflange_height/2;
404 const double r1 = cryo_Router + chimney_height/2;
405 const double r2 = cryo_Router + chimney_height + wflange_height + ocable_len/2;
406 auto put1 = [&envelope, z_pos](GeoIntrusivePtr<GeoPhysVol>
object,
double r,
double phi)
408 envelope->add(
new GeoTransform(
409 GeoTrf::Translate3D(
r*
cos(phi),
r*
sin(phi), z_pos) *
413 envelope->add(
object);
416 auto put = [&put1, &FTPV, &chimneyPV, &ocablePV, r0, r1, r2](
double phi)
419 put1(chimneyPV, r1, phi);
420 put1(ocablePV, r2, phi);
424 for(
unsigned int i{0};
i < LArEndcapCratePhiPos->size(); ++
i){
425 const int num = (*LArEndcapCratePhiPos)[
i]->getInt(
"CRATENUM");
441 if(EndcapDMTubes->size()) {
442 const GeoMaterial* matECServices = materialManager->
getMaterial(
"LAr::LArECServices");
443 for(
unsigned i(0);
i<EndcapDMTubes->size(); ++
i) {
444 GeoTube* endcapTube =
new GeoTube((*EndcapDMTubes)[
i]->getDouble(
"RMIN"),(*EndcapDMTubes)[
i]->getDouble(
"RMAX"),(*EndcapDMTubes)[
i]->getDouble(
"DZ"));
445 GeoLogVol* endcapTubeLv =
new GeoLogVol((*EndcapDMTubes)[
i]->getString(
"TUBENAME"),endcapTube,matECServices);
446 GeoIntrusivePtr<GeoPhysVol> endcapTubePv =
new GeoPhysVol(endcapTubeLv);
447 envelope->add(
new GeoTransform(GeoTrf::TranslateZ3D((*EndcapDMTubes)[
i]->getDouble(
"ZPOS"))));
448 envelope->add(endcapTubePv);