ATLAS Offline Software
CrackDMConstruction.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include "GeoModelKernel/GeoElement.h"
8 #include "GeoModelKernel/GeoMaterial.h"
9 #include "GeoModelKernel/GeoFullPhysVol.h"
10 #include "GeoModelKernel/GeoPhysVol.h"
11 #include "GeoModelKernel/GeoVPhysVol.h"
12 #include "GeoModelKernel/GeoLogVol.h"
13 #include "GeoModelKernel/GeoTransform.h"
14 #include "GeoModelKernel/GeoAlignableTransform.h"
15 #include "GeoModelKernel/GeoIdentifierTag.h"
16 #include "GeoModelKernel/GeoNameTag.h"
17 #include "GeoModelKernel/GeoSerialTransformer.h"
18 #include "GeoModelKernel/GeoXF.h"
19 #include "GeoModelKernel/GeoTube.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/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/Units.h"
31 
32 #include "StoreGate/StoreGateSvc.h"
39 
40 // For units:
41 #include "GaudiKernel/PhysicalConstants.h"
42 #include "GaudiKernel/MsgStream.h"
43 #include "GaudiKernel/Bootstrap.h"
44 
45 // For functions:
46 #include "GeoGenericFunctions/Variable.h"
47 
48 using namespace GeoGenfun;
49 using namespace GeoXF;
50 
51 static const unsigned int NCrates=16;
52 static const double Alfa=360*Gaudi::Units::deg/NCrates;
53 static const double Enda=1155;
54 static const double Endb=1695.2;
55 static const double Endc=2771.6;
56 static const double DYa=1155*tan(Alfa/2);
57 static const double DYb=1695.2*tan(Alfa/2);
58 static const double DYc=2771.6*tan(Alfa/2);
59 
60 
61 void
62 createSectorEnvelopes2FromDB (GeoFullPhysVol* envelope,
63  StoredMaterialManager* materialManager,
64  std::map<std::string, unsigned int>& trdMap,
65  IRDBRecordset& BarrelDMTrds,
66  std::map<std::string, unsigned int>& trapMap,
67  IRDBRecordset& BarrelDMTraps,
68  std::map<std::string, unsigned int>& boxMap,
69  IRDBRecordset& BarrelDMBoxes,
70  GENFUNCTION& f,
71  GeoBox* Box)
72 {
73  unsigned int recordIndex = trdMap["SecE2"];
74  double SecE2xhlen1 = BarrelDMTrds[recordIndex]->getDouble("XHLEN1");
75  double SecE2xhlen2 = BarrelDMTrds[recordIndex]->getDouble("XHLEN2");
76  double SecE2ztr = BarrelDMTrds[recordIndex]->getDouble("ZTR");
77 
78  recordIndex = trdMap["Spb0"];
79  double Spb0xhlen1 = BarrelDMTrds[recordIndex]->getDouble("XHLEN1");
80  double Spb0xhlen2 = BarrelDMTrds[recordIndex]->getDouble("XHLEN2");
81  double Spb0yhlen1 = BarrelDMTrds[recordIndex]->getDouble("YHLEN1");
82  double Spb0yhlen2 = BarrelDMTrds[recordIndex]->getDouble("YHLEN2");
83  double Spb0zhlen = BarrelDMTrds[recordIndex]->getDouble("ZHLEN");
84  double Spb0ytr = BarrelDMTrds[recordIndex]->getDouble("YTR");
85  double Spb0xrot = BarrelDMTrds[recordIndex]->getDouble("XROT");
86 
87  recordIndex = boxMap["Box"];
88  //double Boxhlen = BarrelDMBoxes[recordIndex]->getDouble("HLEN");
89  //double Boxhwdt = BarrelDMBoxes[recordIndex]->getDouble("HWDT");
90  //double Boxhhgt = BarrelDMBoxes[recordIndex]->getDouble("HHGT");
91  double Boxxtr = BarrelDMBoxes[recordIndex]->getDouble("XTR");
92  double Boxytr = BarrelDMBoxes[recordIndex]->getDouble("YTR");
93  double Boxztr = BarrelDMBoxes[recordIndex]->getDouble("ZTR");
94  //double Boxxrot = BarrelDMBoxes[recordIndex]->getDouble("XROT");
95 
96  recordIndex = boxMap["SplBox"];
97  double SplBoxhlen = BarrelDMBoxes[recordIndex]->getDouble("HLEN");
98  double SplBoxhwdt = BarrelDMBoxes[recordIndex]->getDouble("HWDT");
99  double SplBoxhhgt = BarrelDMBoxes[recordIndex]->getDouble("HHGT");
100  double SplBoxytr = BarrelDMBoxes[recordIndex]->getDouble("YTR");
101  double SplBoxztr = BarrelDMBoxes[recordIndex]->getDouble("ZTR");
102  double SplBoxxrot = BarrelDMBoxes[recordIndex]->getDouble("XROT");
103 
104  recordIndex = trapMap["Spb1"];
105  double Spb1zhlen = BarrelDMTraps[recordIndex]->getDouble("ZHLEN");
106  double Spb1theta = BarrelDMTraps[recordIndex]->getDouble("THETA");
107  double Spb1phi = BarrelDMTraps[recordIndex]->getDouble("PHI");
108  double Spb1yzn = BarrelDMTraps[recordIndex]->getDouble("YZN");
109  double Spb1xynzn = BarrelDMTraps[recordIndex]->getDouble("XYNZN");
110  double Spb1xypzn = BarrelDMTraps[recordIndex]->getDouble("XYPZN");
111  double Spb1angn = BarrelDMTraps[recordIndex]->getDouble("ANGN");
112  double Spb1yzp = BarrelDMTraps[recordIndex]->getDouble("YZP");
113  double Spb1xynzp = BarrelDMTraps[recordIndex]->getDouble("XYNZP");
114  double Spb1xypzp = BarrelDMTraps[recordIndex]->getDouble("XYPZP");
115  double Spb1angp = BarrelDMTraps[recordIndex]->getDouble("ANGP");
116  double Spb1xtr = BarrelDMTraps[recordIndex]->getDouble("XTR");
117  double Spb1ytr = BarrelDMTraps[recordIndex]->getDouble("YTR");
118  double Spb1ztr = BarrelDMTraps[recordIndex]->getDouble("ZTR");
119  double Spb1xrot = BarrelDMTraps[recordIndex]->getDouble("XROT");
120 
121  recordIndex = trapMap["Spb3"];
122  double Spb3zhlen = BarrelDMTraps[recordIndex]->getDouble("ZHLEN");
123  double Spb3theta = BarrelDMTraps[recordIndex]->getDouble("THETA");
124  double Spb3phi = BarrelDMTraps[recordIndex]->getDouble("PHI");
125  double Spb3yzn = BarrelDMTraps[recordIndex]->getDouble("YZN");
126  double Spb3xynzn = BarrelDMTraps[recordIndex]->getDouble("XYNZN");
127  double Spb3xypzn = BarrelDMTraps[recordIndex]->getDouble("XYPZN");
128  double Spb3angn = BarrelDMTraps[recordIndex]->getDouble("ANGN");
129  double Spb3yzp = BarrelDMTraps[recordIndex]->getDouble("YZP");
130  double Spb3xynzp = BarrelDMTraps[recordIndex]->getDouble("XYNZP");
131  double Spb3xypzp = BarrelDMTraps[recordIndex]->getDouble("XYPZP");
132  double Spb3angp = BarrelDMTraps[recordIndex]->getDouble("ANGP");
133  double Spb3ztr = BarrelDMTraps[recordIndex]->getDouble("ZTR");
134 
135  recordIndex = trapMap["Spb2"];
136  double Spb2zhlen = BarrelDMTraps[recordIndex]->getDouble("ZHLEN");
137  double Spb2theta = BarrelDMTraps[recordIndex]->getDouble("THETA");
138  double Spb2phi = BarrelDMTraps[recordIndex]->getDouble("PHI");
139  double Spb2yzn = BarrelDMTraps[recordIndex]->getDouble("YZN");
140  double Spb2xynzn = BarrelDMTraps[recordIndex]->getDouble("XYNZN");
141  double Spb2xypzn = BarrelDMTraps[recordIndex]->getDouble("XYPZN");
142  double Spb2angn = BarrelDMTraps[recordIndex]->getDouble("ANGN");
143  double Spb2yzp = BarrelDMTraps[recordIndex]->getDouble("YZP");
144  double Spb2xynzp = BarrelDMTraps[recordIndex]->getDouble("XYNZP");
145  double Spb2xypzp = BarrelDMTraps[recordIndex]->getDouble("XYPZP");
146  double Spb2angp = BarrelDMTraps[recordIndex]->getDouble("ANGP");
147  double Spb2ytr = BarrelDMTraps[recordIndex]->getDouble("YTR");
148  double Spb2ztr = BarrelDMTraps[recordIndex]->getDouble("ZTR");
149 
150  const GeoMaterial* matLArServices17 = materialManager->getMaterial("LAr::LArServices17");// 0.035*gram/cm3
151  const GeoMaterial* matLArServices18 = materialManager->getMaterial("LAr::LArServices18");// 0.240*gram/cm3
152  const GeoMaterial* matLArServices19 = materialManager->getMaterial("LAr::LArServices19");// 0.469*gram/cm3
153  const GeoMaterial* matLArServices20 = materialManager->getMaterial("LAr::LArServices20");// 0.353*gram/cm3
154  const GeoMaterial *alu = materialManager->getMaterial("std::Aluminium"); //2.7 g/cm3
155  const GeoMaterial *air = materialManager->getMaterial("std::Air"); //0.001214 g/cm3
156 
157  GeoTrf::Transform3D Cut3Boxe = GeoTrf::Translate3D(Boxxtr, Boxytr, Boxztr)*GeoTrf::RotateX3D(-20*Gaudi::Units::deg)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
158  GeoTrf::Transform3D Cut4Boxe = GeoTrf::Translate3D(Boxxtr, -Boxytr,Boxztr)*GeoTrf::RotateX3D(20*Gaudi::Units::deg)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
159 
160  // build 5 instances of SectorEnvelopes1 with 3 different materials!
161  GeoTrd *Trdair2 = new GeoTrd(SecE2xhlen1, SecE2xhlen2, DYb, DYc, (Endc-Endb)/2);
162  const GeoShape & SectorEnvelope= ((*Trdair2).
163  subtract((*Box) <<GeoTrf::Transform3D(Cut3Boxe)).
164  subtract((*Box) <<GeoTrf::Transform3D(Cut4Boxe)));
165 
166  const GeoShape & SectorEnvelopes= ((SectorEnvelope).
167  add(SectorEnvelope << GeoTrf::TranslateY3D(-(DYb+DYc)*cos(Alfa/2)*cos(Alfa/2))*GeoTrf::TranslateZ3D(-(DYb+DYc)*0.5*sin(Alfa))*GeoTrf::RotateX3D(Alfa)));
168 
169  GeoLogVol *lvse2r = new GeoLogVol("LAr::DM::SectorEnvelopes2r",&SectorEnvelopes,matLArServices20);
170  GeoPhysVol *sectorenvelopes2r = new GeoPhysVol(lvse2r); // for right-handed splice boxes
171 
172  GeoLogVol *lvse2l = new GeoLogVol("LAr::DM::SectorEnvelopes2l",&SectorEnvelopes,matLArServices20);
173  GeoPhysVol *sectorenvelopes2l = new GeoPhysVol(lvse2l); // for left-handed splice boxes
174 
175  GeoLogVol *lvse2h = new GeoLogVol("LAr::DM::SectorEnvelopes2h",&SectorEnvelopes,matLArServices19);
176  GeoPhysVol *sectorenvelopes2h = new GeoPhysVol(lvse2h); // no splice boxes horizontal at 0 & 180 Gaudi::Units::deg.
177 
178  GeoLogVol *lvse2vup = new GeoLogVol("LAr::DM::SectorEnvelopes2vup",&SectorEnvelopes,matLArServices17);
179  GeoPhysVol *sectorenvelopes2vup = new GeoPhysVol(lvse2vup); // no splice boxes vertical up at 90 Gaudi::Units::deg
180 
181  GeoLogVol *lvse2vd = new GeoLogVol("LAr::DM::SectorEnvelopes2Vd",&SectorEnvelopes,matLArServices18);
182  GeoPhysVol *sectorenvelopes2vd = new GeoPhysVol(lvse2vd); // no splice boxes vertical down at 270 Gaudi::Units::deg
183 
184  //---------- Build Splice boxes for InDet optical fibers--------
185 
186  GeoTrap *GeoTrap1 = new GeoTrap(Spb1zhlen, Spb1theta, Spb1phi, Spb1yzn, Spb1xynzn, Spb1xypzn, Spb1angn, Spb1yzp, Spb1xynzp, Spb1xypzp, Spb1angp);
187  GeoBox *Box1 = new GeoBox(SplBoxhlen, SplBoxhwdt, SplBoxhhgt);
188  const GeoShape & SpliceBox = ((*GeoTrap1).
189  subtract(*Box1 << GeoTrf::TranslateZ3D(SplBoxztr)*GeoTrf::TranslateY3D(-SplBoxytr)*GeoTrf::RotateX3D(SplBoxxrot*Gaudi::Units::deg)));
190 
191  GeoTransform *xtr = new GeoTransform (GeoTrf::TranslateZ3D(Spb1ztr)*GeoTrf::TranslateY3D(-Spb1ytr)*GeoTrf::TranslateX3D(Spb1xtr)*GeoTrf::RotateX3D(Spb1xrot*Gaudi::Units::deg));
192  sectorenvelopes2r->add(xtr);
193  GeoLogVol *lvspbr = new GeoLogVol("LAr::DM::SPliceBoxr",&SpliceBox,alu);
194  GeoPhysVol *spliceboxr = new GeoPhysVol(lvspbr);
195  sectorenvelopes2r->add(spliceboxr);
196 
197  GeoTransform *xtl = new GeoTransform (GeoTrf::TranslateZ3D(Spb1ztr)*GeoTrf::TranslateY3D(-Spb1ytr)*GeoTrf::TranslateX3D(Spb1xtr)*GeoTrf::RotateY3D(-180*Gaudi::Units::deg)*GeoTrf::RotateX3D(-(Alfa/2)));
198  sectorenvelopes2l->add(xtl);
199  GeoLogVol *lvspbl = new GeoLogVol("LAr::DM::SpliceBoxl",&SpliceBox,alu);
200  GeoPhysVol *spliceboxl = new GeoPhysVol(lvspbl);
201  sectorenvelopes2l->add(spliceboxl);
202 
204  GeoTrd *Trd1 = new GeoTrd(Spb0xhlen1, Spb0xhlen2, Spb0yhlen1, Spb0yhlen2, Spb0zhlen);
205  GeoTrap *GeoTrap2 = new GeoTrap(Spb2zhlen, Spb2theta, Spb2phi, Spb2yzn, Spb2xynzn, Spb2xypzn, Spb2angn, Spb2yzp, Spb2xynzp, Spb2xypzp, Spb2angp);
206  GeoTrap *GeoTrap3 = new GeoTrap(Spb3zhlen, Spb3theta, Spb3phi, Spb3yzn, Spb3xynzn, Spb3xypzn, Spb3angn, Spb3yzp, Spb3xynzp, Spb3xypzp, Spb3angp);
207 
208  GeoTransform *xt1 = new GeoTransform (GeoTrf::TranslateY3D(-Spb0ytr)*GeoTrf::RotateX3D(Spb0xrot*Gaudi::Units::deg));
209  spliceboxr->add(xt1);
210  spliceboxl->add(xt1);
211  GeoLogVol *lt1 = new GeoLogVol("LAr::DM::TBox1",Trd1,air);
212  GeoPhysVol *tbox1 = new GeoPhysVol(lt1);
213  spliceboxr->add(tbox1);
214  spliceboxl->add(tbox1);
215 
216  GeoTransform *xt2 = new GeoTransform (GeoTrf::TranslateZ3D(Spb2ztr)*GeoTrf::TranslateY3D(Spb2ytr));
217  spliceboxr->add(xt2);
218  spliceboxl->add(xt2);
219  GeoLogVol *lt2 = new GeoLogVol("LAr::DM::TBox2",GeoTrap2,air);
220  GeoPhysVol *tbox2 = new GeoPhysVol(lt2);
221  spliceboxr->add(tbox2);
222  spliceboxl->add(tbox2);
223 
224  GeoTransform *xt3 = new GeoTransform (GeoTrf::TranslateZ3D(-Spb3ztr));
225  spliceboxr->add(xt3);
226  spliceboxl->add(xt3);
227  GeoLogVol *lt3 = new GeoLogVol("LAr::DM::TBox3",GeoTrap3,air);
228  GeoPhysVol *tbox3 = new GeoPhysVol(lt3);
229  spliceboxr->add(tbox3);
230  spliceboxl->add(tbox3);
231 
232  //-------------- Place volumes in LAr Envelope -------------------
233 
234  TRANSFUNCTION seA2r = Pow(GeoTrf::RotateZ3D(1.0),8*f-(3*Alfa/2))*GeoTrf::TranslateX3D((Endb+Endc)/2)*GeoTrf::TranslateZ3D(SecE2ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
235  TRANSFUNCTION seA2l = Pow(GeoTrf::RotateZ3D(1.0),8*f+(5*Alfa/2))*GeoTrf::TranslateX3D((Endb+Endc)/2)*GeoTrf::TranslateZ3D(SecE2ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
236  TRANSFUNCTION seC2r = Pow(GeoTrf::RotateZ3D(1.0),8*f-(3*Alfa/2))*GeoTrf::TranslateX3D((Endb+Endc)/2)*GeoTrf::TranslateZ3D(-SecE2ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
237  TRANSFUNCTION seC2l = Pow(GeoTrf::RotateZ3D(1.0),8*f+(5*Alfa/2))*GeoTrf::TranslateX3D((Endb+Endc)/2)*GeoTrf::TranslateZ3D(-SecE2ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
238  TRANSFUNCTION seA2Vup = Pow(GeoTrf::RotateZ3D(1.0),f+(9*Alfa/2))*GeoTrf::TranslateX3D((Endb+Endc)/2)*GeoTrf::TranslateZ3D(SecE2ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
239  TRANSFUNCTION seA2Vd = Pow(GeoTrf::RotateZ3D(1.0),f-(7*Alfa/2))*GeoTrf::TranslateX3D((Endb+Endc)/2)*GeoTrf::TranslateZ3D(SecE2ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
240  TRANSFUNCTION seA2H = Pow(GeoTrf::RotateZ3D(1.0),8*f+(Alfa/2))*GeoTrf::TranslateX3D((Endb+Endc)/2)*GeoTrf::TranslateZ3D(SecE2ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
241  TRANSFUNCTION seC2Vup = Pow(GeoTrf::RotateZ3D(1.0),f+(9*Alfa/2))*GeoTrf::TranslateX3D((Endb+Endc)/2)*GeoTrf::TranslateZ3D(-SecE2ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
242  TRANSFUNCTION seC2Vd = Pow(GeoTrf::RotateZ3D(1.0),f-(7*Alfa/2))*GeoTrf::TranslateX3D((Endb+Endc)/2)*GeoTrf::TranslateZ3D(-SecE2ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
243  TRANSFUNCTION seC2H = Pow(GeoTrf::RotateZ3D(1.0),8*f+(Alfa/2))*GeoTrf::TranslateX3D((Endb+Endc)/2)*GeoTrf::TranslateZ3D(-SecE2ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
244 
245  GeoSerialTransformer *setA2r = new GeoSerialTransformer(sectorenvelopes2r,&seA2r, 2);
246  GeoSerialTransformer *setA2l = new GeoSerialTransformer(sectorenvelopes2l,&seA2l, 2);
247  GeoSerialTransformer *setC2r = new GeoSerialTransformer(sectorenvelopes2r,&seC2r, 2);
248  GeoSerialTransformer *setC2l = new GeoSerialTransformer(sectorenvelopes2l,&seC2l, 2);
249  GeoSerialTransformer *setA2Vup = new GeoSerialTransformer(sectorenvelopes2vup,&seA2Vup, 1);
250  GeoSerialTransformer *setA2Vd = new GeoSerialTransformer(sectorenvelopes2vd,&seA2Vd, 1);
251  GeoSerialTransformer *setA2H = new GeoSerialTransformer(sectorenvelopes2h,&seA2H, 2);
252  GeoSerialTransformer *setC2Vup = new GeoSerialTransformer(sectorenvelopes2vup,&seC2Vup, 1);
253  GeoSerialTransformer *setC2Vd = new GeoSerialTransformer(sectorenvelopes2vd,&seC2Vd, 1);
254  GeoSerialTransformer *setC2H = new GeoSerialTransformer(sectorenvelopes2h,&seC2H, 2);
255 
256  envelope->add(setA2r);
257  envelope->add(setA2l);
258  envelope->add(setC2r);
259  envelope->add(setC2l);
260  envelope->add(setA2Vup);
261  envelope->add(setA2Vd);
262  envelope->add(setA2H);
263  envelope->add(setC2Vup);
264  envelope->add(setC2Vd);
265  envelope->add(setC2H);
266 }
267 
268 
269 void
270 createBridgeEnvelopesFromDB (GeoFullPhysVol* envelope,
271  std::map<std::string, unsigned int>& trapMap,
272  IRDBRecordset& BarrelDMTraps,
273  const GeoMaterial* matLArServices8,
274  GENFUNCTION& f)
275 {
276  unsigned int recordIndex = trapMap["BridgeE"];
277  const IRDBRecord* r = BarrelDMTraps[recordIndex];
278  double BridgeEzhlen = r->getDouble("ZHLEN");
279  double BridgeEtheta = r->getDouble("THETA");
280  double BridgeEphi = r->getDouble("PHI");
281  double BridgeEyzn = r->getDouble("YZN");
282  double BridgeExynzn = r->getDouble("XYNZN");
283  double BridgeExypzn = r->getDouble("XYPZN");
284  double BridgeEangn = r->getDouble("ANGN");
285  double BridgeEyzp = r->getDouble("YZP");
286  double BridgeExynzp = r->getDouble("XYNZP");
287  double BridgeExypzp = r->getDouble("XYPZP");
288  double BridgeEangp = r->getDouble("ANGP");
289  double BridgeExtr = r->getDouble("XTR");
290  double BridgeEztr = r->getDouble("ZTR");
291 
292  GeoTrap *Trapair = new GeoTrap(BridgeEzhlen, BridgeEtheta*Gaudi::Units::deg, BridgeEphi, BridgeEyzn, BridgeExynzn, BridgeExypzn, BridgeEangn, BridgeEyzp, BridgeExynzp, BridgeExypzp, BridgeEangp);
293  GeoLogVol *lvbre = new GeoLogVol("LAr::DM::BridgeEnvelopes",Trapair,matLArServices8);//In the end Density at least >= than SE1 because of Cryo Pipes
294  GeoPhysVol *bridgeenvelopes = new GeoPhysVol(lvbre);
295 
296  TRANSFUNCTION breA = Pow(GeoTrf::RotateZ3D(1.0),f-(Alfa/2))*GeoTrf::TranslateX3D(BridgeExtr)*GeoTrf::TranslateZ3D(BridgeEztr)*GeoTrf::RotateZ3D(90*Gaudi::Units::deg)*GeoTrf::RotateY3D(90*Gaudi::Units::deg)*GeoTrf::RotateX3D(90*Gaudi::Units::deg);
297  TRANSFUNCTION breC = Pow(GeoTrf::RotateZ3D(1.0),f-(Alfa/2))*GeoTrf::TranslateX3D(BridgeExtr)*GeoTrf::TranslateZ3D(-BridgeEztr)*GeoTrf::RotateZ3D(-90*Gaudi::Units::deg)*GeoTrf::RotateY3D(-90*Gaudi::Units::deg)*GeoTrf::RotateX3D(-90*Gaudi::Units::deg);
298  GeoSerialTransformer *bretA = new GeoSerialTransformer(bridgeenvelopes,&breA, NCrates);
299  GeoSerialTransformer *bretC = new GeoSerialTransformer(bridgeenvelopes,&breC, NCrates);
300  envelope->add(bretA);
301  envelope->add(bretC);
302 }
303 
304 
305 void
306 createBaseEnvelopesFromDB (GeoFullPhysVol* envelope,
307  std::map<std::string, unsigned int>& trdMap,
308  IRDBRecordset& BarrelDMTrds,
309  const GeoMaterial* matLArServices8,
310  GENFUNCTION& f)
311 {
312  unsigned int recordIndex = trdMap["BaseE"];
313  const IRDBRecord* r = BarrelDMTrds[recordIndex];
314  double BaseExhlen1 = r->getDouble("XHLEN1");
315  double BaseExhlen2 = r->getDouble("XHLEN2");
316  double BaseEyhlen1 = r->getDouble("YHLEN1");
317  double BaseEyhlen2 = r->getDouble("YHLEN2");
318  double BaseEzhlen = r->getDouble("ZHLEN");//
319  double BaseExtr = r->getDouble("XTR");
320  double BaseEztr = r->getDouble("ZTR");
321 
322  GeoTrd *Trd1air = new GeoTrd(BaseExhlen1, BaseExhlen2, BaseEyhlen1, BaseEyhlen2, BaseEzhlen);
323  GeoLogVol *lvbe = new GeoLogVol("LAr::DM::BaseEnvelopes",Trd1air,matLArServices8); //In the end Density at least >= than SE1 because of Cryo Pipes
324  GeoPhysVol *baseenvelopes = new GeoPhysVol(lvbe);
325 
326  TRANSFUNCTION beA = Pow(GeoTrf::RotateZ3D(1.0),f-(Alfa/2))*GeoTrf::TranslateX3D(BaseExtr)*GeoTrf::TranslateZ3D(BaseEztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
327  TRANSFUNCTION beC = Pow(GeoTrf::RotateZ3D(1.0),f+(Alfa/2))*GeoTrf::TranslateX3D(BaseExtr)*GeoTrf::TranslateZ3D(-BaseEztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
328  GeoSerialTransformer *betA = new GeoSerialTransformer(baseenvelopes,&beA, NCrates);
329  GeoSerialTransformer *betC = new GeoSerialTransformer(baseenvelopes,&beC, NCrates);
330  envelope->add(betA);
331  envelope->add(betC);
332 }
333 
334 void createFromDB (GeoFullPhysVol* envelope,
335  IRDBAccessSvc* rdbAccess,
336  IGeoModelSvc* geoModel,
337  StoredMaterialManager* materialManager)
338 {
339  // Use Geometry Database
340  DecodeVersionKey keyLAr(geoModel,"LAr");
341  IRDBRecordset_ptr BarrelDMTraps = rdbAccess->getRecordsetPtr("BarrelDMTraps",keyLAr.tag(),keyLAr.node());
342  IRDBRecordset_ptr BarrelDMTrds = rdbAccess->getRecordsetPtr("BarrelDMTrds",keyLAr.tag(),keyLAr.node());
343  IRDBRecordset_ptr BarrelDMTubes = rdbAccess->getRecordsetPtr("BarrelDMTubes",keyLAr.tag(),keyLAr.node());
344  IRDBRecordset_ptr BarrelDMBoxes = rdbAccess->getRecordsetPtr("BarrelDMBoxes",keyLAr.tag(),keyLAr.node());
345 
346  std::map<std::string, unsigned int> tubeMap;
347  for (unsigned int i=0; i<BarrelDMTubes->size(); i++)
348  {
349  const std::string& key = (*BarrelDMTubes)[i]->getString("TUBENAME");
350  tubeMap[key] = i;
351  }
352  std::map<std::string, unsigned int> boxMap;
353  for (unsigned int j=0; j<BarrelDMBoxes->size(); j++)
354  {
355  const std::string& key = (*BarrelDMBoxes)[j]->getString("BOXNAME");
356  boxMap[key] = j;
357  }
358  std::map<std::string, unsigned int> trdMap;
359  for (unsigned int k=0; k<BarrelDMTrds->size(); k++)
360  {
361  const std::string& key = (*BarrelDMTrds)[k]->getString("TRDNAME");
362  trdMap[key] = k;
363  }
364  std::map<std::string, unsigned int> trapMap;
365  for (unsigned int l=0; l<BarrelDMTraps->size(); l++)
366  {
367  const std::string& key = (*BarrelDMTraps)[l]->getString("TRAPNAME");
368  trapMap[key] = l;
369  }
370 
371  unsigned int recordIndex;
372 
373  // Get materials
374  const GeoMaterial *alu = materialManager->getMaterial("std::Aluminium"); //2.7 g/cm3
375  const GeoMaterial* matBoardsEnvelope = materialManager->getMaterial("LAr::BoardsEnvelope");// 0.932*gram/cm3);
376  const GeoMaterial* matLArServices1 = materialManager->getMaterial("LAr::LArServices1");// 1.020*gram/cm3
377  const GeoMaterial* matLArServices2 = materialManager->getMaterial("LAr::LArServices2");// 0.955*gram/cm3
378  const GeoMaterial* matLArServices3 = materialManager->getMaterial("LAr::LArServices3");// 1.005*gram/cm3
379  const GeoMaterial* matLArServices4 = materialManager->getMaterial("LAr::LArServices4");// 0.460*gram/cm3
380  const GeoMaterial* matLArServices5 = materialManager->getMaterial("LAr::LArServices5");// 0.480*gram/cm3
381  const GeoMaterial* matLArServices6 = materialManager->getMaterial("LAr::LArServices6");// 1.000*gram/cm3
382  const GeoMaterial* matLArServices7 = materialManager->getMaterial("LAr::LArServices7");// 0.935*gram/cm3
383  const GeoMaterial* matLArServices8 = materialManager->getMaterial("LAr::LArServices8");// 1.070*gram/cm3
384  const GeoMaterial* matLArServices9 = materialManager->getMaterial("LAr::LArServices9");// 1.020*gram/cm3
385  const GeoMaterial* matLArServices10 = materialManager->getMaterial("LAr::LArServices10");// 0.995*gram/cm3
386  const GeoMaterial* matLArServices11 = materialManager->getMaterial("LAr::LArServices11");// 0.835*gram/cm3
387  const GeoMaterial* matLArServices12 = materialManager->getMaterial("LAr::LArServices12");// 0.640*gram/cm3
388  const GeoMaterial* matLArServices13 = materialManager->getMaterial("LAr::LArServices13");// 0.690*gram/cm3
389  const GeoMaterial* matLArServices14 = materialManager->getMaterial("LAr::LArServices14");// 0.825*gram/cm3
390  const GeoMaterial* matLArServices15 = materialManager->getMaterial("LAr::LArServices15");// 0.875*gram/cm3
391  const GeoMaterial* matLArServices16 = materialManager->getMaterial("LAr::LArServices16");// 1.035*gram/cm3
392 
393  const double inv_Endab = 1. / (Endb - Enda);
394  Variable i;
395  GENFUNCTION f = Alfa*i;
396 
398 
399  recordIndex = tubeMap["Ped2"];
400  double ped2zhlen = (*BarrelDMTubes)[recordIndex]->getDouble("ZHLEN");
401  double ped2minr = (*BarrelDMTubes)[recordIndex]->getDouble("MINR");
402  double ped2maxr = (*BarrelDMTubes)[recordIndex]->getDouble("MAXR");
403  double ped2ytr = (*BarrelDMTubes)[recordIndex]->getDouble("YTR");
404  recordIndex = tubeMap["Ped3"];
405  double ped3zhlen = (*BarrelDMTubes)[recordIndex]->getDouble("ZHLEN");
406  double ped3minr = (*BarrelDMTubes)[recordIndex]->getDouble("MINR");
407  double ped3maxr = (*BarrelDMTubes)[recordIndex]->getDouble("MAXR");
408  double ped3xtr = (*BarrelDMTubes)[recordIndex]->getDouble("XTR");
409 
410  recordIndex = boxMap["Pedest"];
411  double pedesthlen = (*BarrelDMBoxes)[recordIndex]->getDouble("HLEN");
412  double pedesthwdt = (*BarrelDMBoxes)[recordIndex]->getDouble("HWDT");
413  double pedesthhgt = (*BarrelDMBoxes)[recordIndex]->getDouble("HHGT");
414  double pedestxtr = (*BarrelDMBoxes)[recordIndex]->getDouble("XTR");
415  double pedestztr = (*BarrelDMBoxes)[recordIndex]->getDouble("ZTR");
416  recordIndex = boxMap["Ped1"];
417  double ped1hlen = (*BarrelDMBoxes)[recordIndex]->getDouble("HLEN");
418  double ped1hwdt = (*BarrelDMBoxes)[recordIndex]->getDouble("HWDT");
419  double ped1hhgt = (*BarrelDMBoxes)[recordIndex]->getDouble("HHGT");
420  recordIndex = boxMap["Crate1"];
421  double crate1hlen = (*BarrelDMBoxes)[recordIndex]->getDouble("HLEN");
422  double crate1hwdt = (*BarrelDMBoxes)[recordIndex]->getDouble("HWDT");
423  double crate1hhgt = (*BarrelDMBoxes)[recordIndex]->getDouble("HHGT");
424  double crate1xtr = (*BarrelDMBoxes)[recordIndex]->getDouble("XTR");
425  double crate1ztr = (*BarrelDMBoxes)[recordIndex]->getDouble("ZTR");
426  recordIndex = boxMap["Crate2"];
427  double crate2hlen = (*BarrelDMBoxes)[recordIndex]->getDouble("HLEN");
428  double crate2hwdt = (*BarrelDMBoxes)[recordIndex]->getDouble("HWDT");
429  double crate2hhgt = (*BarrelDMBoxes)[recordIndex]->getDouble("HHGT");
430  recordIndex = boxMap["Crate3"];
431  double crate3hlen = (*BarrelDMBoxes)[recordIndex]->getDouble("HLEN");
432  double crate3hwdt = (*BarrelDMBoxes)[recordIndex]->getDouble("HWDT");
433  double crate3hhgt = (*BarrelDMBoxes)[recordIndex]->getDouble("HHGT");
434  double crate3xtr = (*BarrelDMBoxes)[recordIndex]->getDouble("XTR");
435  recordIndex = boxMap["BoardE"];
436  double BoardEhlen = (*BarrelDMBoxes)[recordIndex]->getDouble("HLEN");
437  double BoardEhwdt = (*BarrelDMBoxes)[recordIndex]->getDouble("HWDT");
438  double BoardEhhgt = (*BarrelDMBoxes)[recordIndex]->getDouble("HHGT");
439  double BoardExtr = (*BarrelDMBoxes)[recordIndex]->getDouble("XTR");
440  double BoardEytr = (*BarrelDMBoxes)[recordIndex]->getDouble("YTR");
441  double BoardEztr = (*BarrelDMBoxes)[recordIndex]->getDouble("ZTR");
442  recordIndex = boxMap["Box"];
443  double Boxhlen = (*BarrelDMBoxes)[recordIndex]->getDouble("HLEN");
444  double Boxhwdt = (*BarrelDMBoxes)[recordIndex]->getDouble("HWDT");
445  double Boxhhgt = (*BarrelDMBoxes)[recordIndex]->getDouble("HHGT");
446  double Boxxtr = (*BarrelDMBoxes)[recordIndex]->getDouble("XTR");
447  double Boxytr = (*BarrelDMBoxes)[recordIndex]->getDouble("YTR");
448  double Boxxrot = (*BarrelDMBoxes)[recordIndex]->getDouble("XROT");
449 
450  // ----- build pedestal -----
451  GeoBox *Pedestal = new GeoBox(pedesthlen, pedesthwdt, pedesthhgt);
452  GeoBox *Ped1 = new GeoBox(ped1hlen, ped1hwdt, ped1hhgt);
453  GeoTube *Ped2 = new GeoTube(ped2minr, ped2maxr, ped2zhlen);
454  GeoTube *Ped3 = new GeoTube(ped3minr,ped3maxr , ped3zhlen);
455  const GeoShape & CratePed=((*Pedestal).subtract(*Ped1).
456  subtract((*Ped2) <<GeoTrf::TranslateY3D(-ped2ytr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg)).
457  subtract((*Ped3) <<GeoTrf::TranslateX3D(-ped3xtr)).
458  subtract((*Ped2) <<GeoTrf::TranslateY3D(ped2ytr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg)));
459 
460  GeoLogVol *lvped = new GeoLogVol("LAr::DM::Ped",&CratePed,alu);
461  GeoPhysVol *pedestal = new GeoPhysVol(lvped);
462 
463  // ----- build crates -----
464  GeoBox *Crate1 = new GeoBox(crate1hlen, crate1hwdt, crate1hhgt);
465  GeoBox *Crate2 = new GeoBox(crate2hlen, crate2hwdt, crate2hhgt);
466  GeoBox *Crate3 = new GeoBox(crate3hlen, crate3hwdt, crate3hhgt);
467  const GeoShape & FEBCrate=(*Crate1).subtract(*Crate2).add((*Crate3) <<GeoTrf::TranslateX3D(-crate3xtr));
468 
469  GeoLogVol *lvcrate = new GeoLogVol("LAr::DM::Crate",&FEBCrate,alu);
470  GeoPhysVol *crate = new GeoPhysVol(lvcrate);
471 
472  // ----- build boardenvelopes -----
473  GeoBox *BoardEnvelope = new GeoBox(BoardEhlen, BoardEhwdt, BoardEhhgt);
474  GeoLogVol *lvbenv = new GeoLogVol("LAr::DM::FEBoard",BoardEnvelope,matBoardsEnvelope);
475  GeoPhysVol *boardenvelope = new GeoPhysVol(lvbenv);
476 
477  //-------------- Place volumes in envelope ----------------------------
478 
479  //Crates
480  TRANSFUNCTION crA = Pow(GeoTrf::RotateZ3D(1.0),f)*GeoTrf::TranslateX3D(crate1xtr)*GeoTrf::TranslateZ3D(crate1ztr);
481  TRANSFUNCTION crC = Pow(GeoTrf::RotateZ3D(1.0),f)*GeoTrf::TranslateX3D(crate1xtr)*GeoTrf::TranslateZ3D(-crate1ztr);
482  GeoSerialTransformer *crtA = new GeoSerialTransformer(crate,&crA, NCrates);
483  GeoSerialTransformer *crtC = new GeoSerialTransformer(crate,&crC, NCrates);
484  envelope->add(crtA);
485  envelope->add(crtC);
486 
487  //Pedestals
488  TRANSFUNCTION pedA = Pow(GeoTrf::RotateZ3D(1.0),f)*GeoTrf::TranslateX3D(pedestxtr)*GeoTrf::TranslateZ3D(pedestztr);
489  TRANSFUNCTION pedC = Pow(GeoTrf::RotateZ3D(1.0),f)*GeoTrf::TranslateX3D(pedestxtr)*GeoTrf::TranslateZ3D(-pedestztr);
490  GeoSerialTransformer *pedtA = new GeoSerialTransformer(pedestal,&pedA, NCrates);
491  GeoSerialTransformer *pedtC = new GeoSerialTransformer(pedestal,&pedC, NCrates);
492  envelope->add(pedtA);
493  envelope->add(pedtC);
494 
495  //FEBoards
496  TRANSFUNCTION feb1A = Pow(GeoTrf::RotateZ3D(1.0),f)*GeoTrf::TranslateY3D(BoardEytr)*GeoTrf::TranslateX3D(BoardExtr)*GeoTrf::TranslateZ3D(BoardEztr);
497  TRANSFUNCTION feb2A = Pow(GeoTrf::RotateZ3D(1.0),f)*GeoTrf::TranslateY3D(-BoardEytr)*GeoTrf::TranslateX3D(BoardExtr)*GeoTrf::TranslateZ3D(BoardEztr);
498  TRANSFUNCTION feb1C = Pow(GeoTrf::RotateZ3D(1.0),f)*GeoTrf::TranslateY3D(BoardEytr)*GeoTrf::TranslateX3D(BoardExtr)*GeoTrf::TranslateZ3D(-BoardEztr);
499  TRANSFUNCTION feb2C = Pow(GeoTrf::RotateZ3D(1.0),f)*GeoTrf::TranslateY3D(-BoardEytr)*GeoTrf::TranslateX3D(BoardExtr)*GeoTrf::TranslateZ3D(-BoardEztr);
500  GeoSerialTransformer *febt1A = new GeoSerialTransformer(boardenvelope,&feb1A, NCrates);
501  GeoSerialTransformer *febt1C = new GeoSerialTransformer(boardenvelope,&feb1C, NCrates);
502  GeoSerialTransformer *febt2A = new GeoSerialTransformer(boardenvelope,&feb2A, NCrates);
503  GeoSerialTransformer *febt2C = new GeoSerialTransformer(boardenvelope,&feb2C, NCrates);
504  envelope->add(febt1A);
505  envelope->add(febt1C);
506  envelope->add(febt2A);
507  envelope->add(febt2C);
508 
510  recordIndex = trdMap["SecP"];
511  double SecPxhlen1 = (*BarrelDMTrds)[recordIndex]->getDouble("XHLEN1");
512  double SecPxhlen2 = (*BarrelDMTrds)[recordIndex]->getDouble("XHLEN2");
513  double SecPyhlen1 = (*BarrelDMTrds)[recordIndex]->getDouble("YHLEN1");//
514  double SecPyhlen2 = (*BarrelDMTrds)[recordIndex]->getDouble("YHLEN2");//
515  double SecPzhlen = (*BarrelDMTrds)[recordIndex]->getDouble("ZHLEN");//
516  double SecPxtr = (*BarrelDMTrds)[recordIndex]->getDouble("XTR");
517  double SecPztr = (*BarrelDMTrds)[recordIndex]->getDouble("ZTR");
518  recordIndex = trdMap["BaseP"];
519  double BasePxhlen1 = (*BarrelDMTrds)[recordIndex]->getDouble("XHLEN1");
520  double BasePxhlen2 = (*BarrelDMTrds)[recordIndex]->getDouble("XHLEN2");
521  double BasePyhlen1 = (*BarrelDMTrds)[recordIndex]->getDouble("YHLEN1");
522  double BasePyhlen2 = (*BarrelDMTrds)[recordIndex]->getDouble("YHLEN2");
523  double BasePzhlen = (*BarrelDMTrds)[recordIndex]->getDouble("ZHLEN");
524  double BasePxtr = (*BarrelDMTrds)[recordIndex]->getDouble("XTR");
525  double BasePztr = (*BarrelDMTrds)[recordIndex]->getDouble("ZTR");
526  recordIndex = trdMap["SecE1"];
527  double SecE1xhlen1 = (*BarrelDMTrds)[recordIndex]->getDouble("XHLEN1");
528  double SecE1xhlen2 = (*BarrelDMTrds)[recordIndex]->getDouble("XHLEN2");
529  double SecE1ztr = (*BarrelDMTrds)[recordIndex]->getDouble("ZTR");
530  recordIndex = trapMap["BridgeP"];
531  double BridgePzhlen = (*BarrelDMTraps)[recordIndex]->getDouble("ZHLEN");
532  double BridgePtheta = (*BarrelDMTraps)[recordIndex]->getDouble("THETA");
533  double BridgePphi = (*BarrelDMTraps)[recordIndex]->getDouble("PHI");
534  double BridgePyzn = (*BarrelDMTraps)[recordIndex]->getDouble("YZN");
535  double BridgePxynzn = (*BarrelDMTraps)[recordIndex]->getDouble("XYNZN");
536  double BridgePxypzn = (*BarrelDMTraps)[recordIndex]->getDouble("XYPZN");
537  double BridgePangn = (*BarrelDMTraps)[recordIndex]->getDouble("ANGN");
538  double BridgePyzp = (*BarrelDMTraps)[recordIndex]->getDouble("YZP");
539  double BridgePxynzp = (*BarrelDMTraps)[recordIndex]->getDouble("XYNZP");
540  double BridgePxypzp = (*BarrelDMTraps)[recordIndex]->getDouble("XYPZP");
541  double BridgePangp = (*BarrelDMTraps)[recordIndex]->getDouble("ANGP");
542  double BridgePxtr = (*BarrelDMTraps)[recordIndex]->getDouble("XTR");
543  double BridgePztr = (*BarrelDMTraps)[recordIndex]->getDouble("ZTR");
544 
545  // transforms
546  GeoBox *Box = new GeoBox(Boxhlen, Boxhwdt, Boxhhgt);
547 
548  GeoTrf::Transform3D Cut3Boxp = GeoTrf::Translate3D(Boxxtr, Boxytr, Boxxrot)*GeoTrf::RotateX3D(-20*Gaudi::Units::deg)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
549  GeoTrf::Transform3D Cut4Boxp = GeoTrf::Translate3D(Boxxtr, -Boxytr,Boxxrot)*GeoTrf::RotateX3D(20*Gaudi::Units::deg)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
550 
551  // ----- build sector envelopes -----
552  // build 16 instances of SectorEnvelopes1 each with its own material!
553  GeoTrd *Trdair1 = new GeoTrd(SecE1xhlen1, SecE1xhlen2, DYa, DYb, (Endb-Enda)/2);
554 
555  GeoLogVol *lvse1g1 = new GeoLogVol("LAr::DM::SectorEnvelopes1g1",Trdair1,matLArServices1);
556  GeoPhysVol *sectorenvelopes1g1 = new GeoPhysVol(lvse1g1);
557 
558  GeoLogVol *lvse1g2 = new GeoLogVol("LAr::DM::SectorEnvelopes1g3",Trdair1,matLArServices2);
559  GeoPhysVol *sectorenvelopes1g2 = new GeoPhysVol(lvse1g2);
560 
561  GeoLogVol *lvse1g3 = new GeoLogVol("LAr::DM::SectorEnvelopes1g3",Trdair1,matLArServices3);
562  GeoPhysVol *sectorenvelopes1g3 = new GeoPhysVol(lvse1g3);
563 
564  GeoLogVol *lvse1g4 = new GeoLogVol("LAr::DM::SectorEnvelopes1g4",Trdair1,matLArServices4);
565  GeoPhysVol *sectorenvelopes1g4 = new GeoPhysVol(lvse1g4);
566 
567  GeoLogVol *lvse1g5 = new GeoLogVol("LAr::DM::SectorEnvelopes1g5",Trdair1,matLArServices5);
568  GeoPhysVol *sectorenvelopes1g5 = new GeoPhysVol(lvse1g5);
569 
570  GeoLogVol *lvse1g6 = new GeoLogVol("LAr::DM::SectorEnvelopes1g6",Trdair1,matLArServices6);
571  GeoPhysVol *sectorenvelopes1g6 = new GeoPhysVol(lvse1g6);
572 
573  GeoLogVol *lvse1g7 = new GeoLogVol("LAr::DM::SectorEnvelopes1g7",Trdair1,matLArServices7);
574  GeoPhysVol *sectorenvelopes1g7 = new GeoPhysVol(lvse1g7);
575 
576  GeoLogVol *lvse1g8 = new GeoLogVol("LAr::DM::SectorEnvelopes1g8",Trdair1,matLArServices8);
577  GeoPhysVol *sectorenvelopes1g8 = new GeoPhysVol(lvse1g8);
578 
579  GeoLogVol *lvse1g9 = new GeoLogVol("LAr::DM::SectorEnvelopes1g9",Trdair1,matLArServices9);
580  GeoPhysVol *sectorenvelopes1g9 = new GeoPhysVol(lvse1g9);
581 
582  GeoLogVol *lvse1g10 = new GeoLogVol("LAr::DM::SectorEnvelopes1g10",Trdair1,matLArServices10);
583  GeoPhysVol *sectorenvelopes1g10 = new GeoPhysVol(lvse1g10);
584 
585  GeoLogVol *lvse1g11 = new GeoLogVol("LAr::DM::SectorEnvelopes1g11",Trdair1,matLArServices11);
586  GeoPhysVol *sectorenvelopes1g11 = new GeoPhysVol(lvse1g11);
587 
588  GeoLogVol *lvse1g12 = new GeoLogVol("LAr::DM::SectorEnvelopes1g12",Trdair1,matLArServices12);
589  GeoPhysVol *sectorenvelopes1g12 = new GeoPhysVol(lvse1g12);
590 
591  GeoLogVol *lvse1g13 = new GeoLogVol("LAr::DM::SectorEnvelopes1g13",Trdair1,matLArServices13);
592  GeoPhysVol *sectorenvelopes1g13 = new GeoPhysVol(lvse1g13);
593 
594  GeoLogVol *lvse1g14 = new GeoLogVol("LAr::DM::SectorEnvelopes1g14",Trdair1,matLArServices14);
595  GeoPhysVol *sectorenvelopes1g14 = new GeoPhysVol(lvse1g14);
596 
597  GeoLogVol *lvse1g15 = new GeoLogVol("LAr::DM::SectorEnvelopes1g15",Trdair1,matLArServices15);
598  GeoPhysVol *sectorenvelopes1g15 = new GeoPhysVol(lvse1g15);
599 
600  GeoLogVol *lvse1g16 = new GeoLogVol("LAr::DM::SectorEnvelopes1g16",Trdair1,matLArServices16);
601  GeoPhysVol *sectorenvelopes1g16 = new GeoPhysVol(lvse1g16);
602 
603 
604  std::vector<GeoPhysVol*> se1List;
605  se1List.push_back(sectorenvelopes1g1);
606  se1List.push_back(sectorenvelopes1g2);
607  se1List.push_back(sectorenvelopes1g3);
608  se1List.push_back(sectorenvelopes1g4);
609  se1List.push_back(sectorenvelopes1g5);
610  se1List.push_back(sectorenvelopes1g6);
611  se1List.push_back(sectorenvelopes1g7);
612  se1List.push_back(sectorenvelopes1g8);
613  se1List.push_back(sectorenvelopes1g9);
614  se1List.push_back(sectorenvelopes1g10);
615  se1List.push_back(sectorenvelopes1g11);
616  se1List.push_back(sectorenvelopes1g12);
617  se1List.push_back(sectorenvelopes1g13);
618  se1List.push_back(sectorenvelopes1g14);
619  se1List.push_back(sectorenvelopes1g15);
620  se1List.push_back(sectorenvelopes1g16);
621 
622  // dedicated volumes to add in SectorEnvelopes1
623  // (a) volume in Trd shape to add slice of extra material in a given eta bin
624  IRDBRecordset_ptr BarrelDMRing = rdbAccess->getRecordsetPtr("LArDMEnv1Ring",keyLAr.tag(),keyLAr.node());
625  for (unsigned int i=0;i<BarrelDMRing->size();i++) {
626  double etaMin=(*BarrelDMRing)[i]->getDouble("ETAMIN");
627  double etaMax=(*BarrelDMRing)[i]->getDouble("ETAMAX");
628  double thicknessExtra=(*BarrelDMRing)[i]->getDouble("THICKNESS");
629  std::string ringName = "LAr::DM::SectorEnvelopes1::"+(*BarrelDMRing)[i]->getString("RINGNAME");
630 
631  double radiusMin=SecE1ztr/sinh(etaMax);
632  double radiusMax=SecE1ztr/sinh(etaMin);
633  double dy1 = DYa + (DYb-DYa)*(radiusMin-Enda)*inv_Endab;
634  double dy2 = DYa + (DYb-DYa)*(radiusMax-Enda)*inv_Endab;
635  double zpos=0.5*(radiusMax+radiusMin - (Endb+Enda));
636  const GeoMaterial *matExtraTdr = materialManager->getMaterial((*BarrelDMRing)[i]->getString("MATERIAL"));
637 
638  GeoTrd *extraMatTdr = new GeoTrd(thicknessExtra/2., thicknessExtra/2., dy1, dy2, (radiusMax-radiusMin)/2);
639  GeoLogVol *extraMatLog = new GeoLogVol(ringName,extraMatTdr,matExtraTdr);
640  GeoPhysVol *extraMatPhys = new GeoPhysVol(extraMatLog);
641  for (unsigned int isect=0;isect<se1List.size();isect++) {
642  se1List[isect]->add(new GeoTransform(GeoTrf::TranslateZ3D(zpos)));
643  se1List[isect]->add(extraMatPhys);
644  }
645  }
646 
647  // (b) extra material at fixed phi locations in the PPF1 area
648  IRDBRecordset_ptr BarrelDMPhiBox = rdbAccess->getRecordsetPtr("LArDMEnv1PhiBox",keyLAr.tag(),keyLAr.node());
649  for (unsigned int i=0;i<BarrelDMPhiBox->size();i++) {
650  double eta=(*BarrelDMPhiBox)[i]->getDouble("ETA");
651  double phi0=(*BarrelDMPhiBox)[i]->getDouble("PHI0");
652  double deltaR=(*BarrelDMPhiBox)[i]->getDouble("DELTAR");
653  double deltaRphi=(*BarrelDMPhiBox)[i]->getDouble("DELTARPHI");
654  double thickness=(*BarrelDMPhiBox)[i]->getDouble("THICKNESS");
655  int nphi=(*BarrelDMPhiBox)[i]->getInt("NPHI");
656  int noHorizontal = (*BarrelDMPhiBox)[i]->getInt("NOHORIZ");
657 
658  const GeoMaterial* matExtraPPF1 = materialManager->getMaterial((*BarrelDMPhiBox)[i]->getString("MATERIAL"));
659  std::string boxName = "LAr::DM::SectorEnvelopes1::"+(*BarrelDMPhiBox)[i]->getString("BOXNAME");
660 
661  GeoBox *ppf1Box = new GeoBox(thickness/2.,deltaRphi/2.,deltaR/2.);
662  GeoLogVol *ppf1Log = new GeoLogVol(boxName,ppf1Box,matExtraPPF1);
663  GeoPhysVol *ppf1Phys = new GeoPhysVol(ppf1Log);
664 
665  int nPerEnv1 = nphi/NCrates;
666  double dphi=2.*M_PI/((float)(nphi));
667  double radius=SecE1ztr/sinh(eta);
668  for (int iphi=0;iphi<nPerEnv1;iphi++) {
669  double xpos=0.;
670  double ypos=radius*sin(phi0+((float)(iphi))*dphi);
671  double zpos=radius*cos(phi0+((float)(iphi))*dphi) - (Endb+Enda)/2.;
672  for (unsigned int isect=0;isect<se1List.size();isect++) {
673  // no PPF1 box around phi=0 and phi=pi
674  if (noHorizontal>0 && ((isect==7 && iphi==1) || (isect==8 && iphi==0) || (isect==15 && iphi==1) || (isect==0 && iphi==0) ) ) continue;
675  se1List[isect]->add(new GeoTransform(GeoTrf::Translate3D(xpos,ypos,zpos)));
676  se1List[isect]->add(ppf1Phys);
677  }
678  }
679  }
680 
681  // ----- build base plates -----
682  GeoTrd *Trd1alu = new GeoTrd(BasePxhlen1, BasePxhlen2, BasePyhlen1, BasePyhlen2, BasePzhlen);
683  GeoLogVol *lvbp = new GeoLogVol("LAr::DM::BasePlates",Trd1alu,alu);
684  GeoPhysVol *baseplates = new GeoPhysVol(lvbp);
685 
686  // ----- build bridge plates -----
687  GeoTrap *Trapalu = new GeoTrap(BridgePzhlen, BridgePtheta*Gaudi::Units::deg, BridgePphi, BridgePyzn, BridgePxynzn, BridgePxypzn, BridgePangn, BridgePyzp, BridgePxynzp, BridgePxypzp, BridgePangp);
688  GeoLogVol *lvbrp = new GeoLogVol("LAr::DM::BridgePlates",Trapalu,alu);
689  GeoPhysVol *bridgeplates = new GeoPhysVol(lvbrp);
690 
691 
692  // ----- build sector plates -----
693  GeoTrd *Trd2alu = new GeoTrd(SecPxhlen1, SecPxhlen2, SecPyhlen1, SecPyhlen2, SecPzhlen );
694  const GeoShape & SectorPlates= ((*Trd2alu).
695  subtract((*Box) <<GeoTrf::Transform3D(Cut3Boxp)).
696  subtract((*Box) <<GeoTrf::Transform3D(Cut4Boxp)));
697  GeoLogVol *lvsp = new GeoLogVol("LAr::DM::SectorPlates",&SectorPlates,alu);
698  GeoPhysVol *sectorplates = new GeoPhysVol(lvsp);
699 
700 
701  //-------------- Place volumes in LAr Envelope -------------------
702 
703  //sectorPlates
704  TRANSFUNCTION spA = Pow(GeoTrf::RotateZ3D(1.0),f-(Alfa/2))*GeoTrf::TranslateX3D(SecPxtr)*GeoTrf::TranslateZ3D(SecPztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
705  TRANSFUNCTION spC = Pow(GeoTrf::RotateZ3D(1.0),f+(Alfa/2))*GeoTrf::TranslateX3D(SecPxtr)*GeoTrf::TranslateZ3D(-SecPztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
706  GeoSerialTransformer *sptA = new GeoSerialTransformer(sectorplates,&spA, NCrates);
707  GeoSerialTransformer *sptC = new GeoSerialTransformer(sectorplates,&spC, NCrates);
708  envelope->add(sptA);
709  envelope->add(sptC);
710 
711  //bridgePlates
712  TRANSFUNCTION brpA1 = Pow(GeoTrf::RotateZ3D(1.0),f-(5*Alfa/2))*GeoTrf::TranslateX3D(BridgePxtr)*GeoTrf::TranslateZ3D(BridgePztr)*GeoTrf::RotateZ3D(90*Gaudi::Units::deg)*GeoTrf::RotateY3D(90*Gaudi::Units::deg)*GeoTrf::RotateX3D(90*Gaudi::Units::deg);
713  TRANSFUNCTION brpA2 = Pow(GeoTrf::RotateZ3D(1.0),f+(13*Alfa/2))*GeoTrf::TranslateX3D(BridgePxtr)*GeoTrf::TranslateZ3D(BridgePztr)*GeoTrf::RotateZ3D(90*Gaudi::Units::deg)*GeoTrf::RotateY3D(90*Gaudi::Units::deg)*GeoTrf::RotateX3D(90*Gaudi::Units::deg);
714  TRANSFUNCTION brpC1 = Pow(GeoTrf::RotateZ3D(1.0),f-(5*Alfa/2))*GeoTrf::TranslateX3D(BridgePxtr)*GeoTrf::TranslateZ3D(-BridgePztr)*GeoTrf::RotateZ3D(-90*Gaudi::Units::deg)*GeoTrf::RotateY3D(-90*Gaudi::Units::deg)*GeoTrf::RotateX3D(-90*Gaudi::Units::deg);
715  TRANSFUNCTION brpC2 = Pow(GeoTrf::RotateZ3D(1.0),f+(13*Alfa/2))*GeoTrf::TranslateX3D(BridgePxtr)*GeoTrf::TranslateZ3D(-BridgePztr)*GeoTrf::RotateZ3D(-90*Gaudi::Units::deg)*GeoTrf::RotateY3D(-90*Gaudi::Units::deg)*GeoTrf::RotateX3D(-90*Gaudi::Units::deg); GeoSerialTransformer *brptA1 = new GeoSerialTransformer(bridgeplates,&brpA1, 5);
716  GeoSerialTransformer *brptA2 = new GeoSerialTransformer(bridgeplates,&brpA2, 5);
717  GeoSerialTransformer *brptC1 = new GeoSerialTransformer(bridgeplates,&brpC1, 5);
718  GeoSerialTransformer *brptC2 = new GeoSerialTransformer(bridgeplates,&brpC2, 5);
719  envelope->add(brptA1);
720  envelope->add(brptA2);
721  envelope->add(brptC1);
722  envelope->add(brptC2);
723 
724  //basePlates
725  TRANSFUNCTION bpA = Pow(GeoTrf::RotateZ3D(1.0),f-(Alfa/2))*GeoTrf::TranslateX3D(BasePxtr)*GeoTrf::TranslateZ3D(BasePztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
726  TRANSFUNCTION bpC = Pow(GeoTrf::RotateZ3D(1.0),f+(Alfa/2))*GeoTrf::TranslateX3D(BasePxtr)*GeoTrf::TranslateZ3D(-BasePztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
727  GeoSerialTransformer *bptA = new GeoSerialTransformer(baseplates,&bpA, NCrates);
728  GeoSerialTransformer *bptC = new GeoSerialTransformer(baseplates,&bpC, NCrates);
729  envelope->add(bptA);
730  envelope->add(bptC);
731 
732  //sectorEnvelopes1
733  //counter-clockwise from top if taking sideA for reference (clockwise for sideC)
734  TRANSFUNCTION seA1G5 = Pow(GeoTrf::RotateZ3D(1.0),f+(9*Alfa/2))*GeoTrf::TranslateX3D((Endb+Enda)/2)*GeoTrf::TranslateZ3D(SecE1ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
735  TRANSFUNCTION seC1G5 = Pow(GeoTrf::RotateZ3D(1.0),f+(9*Alfa/2))*GeoTrf::TranslateX3D((Endb+Enda)/2)*GeoTrf::TranslateZ3D(-SecE1ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
736  TRANSFUNCTION seA1G6 = Pow(GeoTrf::RotateZ3D(1.0),f+(11*Alfa/2))*GeoTrf::TranslateX3D((Endb+Enda)/2)*GeoTrf::TranslateZ3D(SecE1ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
737  TRANSFUNCTION seC1G6 = Pow(GeoTrf::RotateZ3D(1.0),f+(11*Alfa/2))*GeoTrf::TranslateX3D((Endb+Enda)/2)*GeoTrf::TranslateZ3D(-SecE1ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
738  TRANSFUNCTION seA1G7 = Pow(GeoTrf::RotateZ3D(1.0),f+(13*Alfa/2))*GeoTrf::TranslateX3D((Endb+Enda)/2)*GeoTrf::TranslateZ3D(SecE1ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
739  TRANSFUNCTION seC1G7 = Pow(GeoTrf::RotateZ3D(1.0),f+(13*Alfa/2))*GeoTrf::TranslateX3D((Endb+Enda)/2)*GeoTrf::TranslateZ3D(-SecE1ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
740  TRANSFUNCTION seA1G8 = Pow(GeoTrf::RotateZ3D(1.0),f+(15*Alfa/2))*GeoTrf::TranslateX3D((Endb+Enda)/2)*GeoTrf::TranslateZ3D(SecE1ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
741  TRANSFUNCTION seC1G8 = Pow(GeoTrf::RotateZ3D(1.0),f+(15*Alfa/2))*GeoTrf::TranslateX3D((Endb+Enda)/2)*GeoTrf::TranslateZ3D(-SecE1ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
742  TRANSFUNCTION seA1G9 = Pow(GeoTrf::RotateZ3D(1.0),f+(17*Alfa/2))*GeoTrf::TranslateX3D((Endb+Enda)/2)*GeoTrf::TranslateZ3D(SecE1ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
743  TRANSFUNCTION seC1G9 = Pow(GeoTrf::RotateZ3D(1.0),f+(17*Alfa/2))*GeoTrf::TranslateX3D((Endb+Enda)/2)*GeoTrf::TranslateZ3D(-SecE1ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
744  TRANSFUNCTION seA1G10 = Pow(GeoTrf::RotateZ3D(1.0),f+(19*Alfa/2))*GeoTrf::TranslateX3D((Endb+Enda)/2)*GeoTrf::TranslateZ3D(SecE1ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
745  TRANSFUNCTION seC1G10 = Pow(GeoTrf::RotateZ3D(1.0),f+(19*Alfa/2))*GeoTrf::TranslateX3D((Endb+Enda)/2)*GeoTrf::TranslateZ3D(-SecE1ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
746  TRANSFUNCTION seA1G11 = Pow(GeoTrf::RotateZ3D(1.0),f+(21*Alfa/2))*GeoTrf::TranslateX3D((Endb+Enda)/2)*GeoTrf::TranslateZ3D(SecE1ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
747  TRANSFUNCTION seC1G11 = Pow(GeoTrf::RotateZ3D(1.0),f+(21*Alfa/2))*GeoTrf::TranslateX3D((Endb+Enda)/2)*GeoTrf::TranslateZ3D(-SecE1ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
748  TRANSFUNCTION seA1G12 = Pow(GeoTrf::RotateZ3D(1.0),f+(23*Alfa/2))*GeoTrf::TranslateX3D((Endb+Enda)/2)*GeoTrf::TranslateZ3D(SecE1ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
749  TRANSFUNCTION seC1G12 = Pow(GeoTrf::RotateZ3D(1.0),f+(23*Alfa/2))*GeoTrf::TranslateX3D((Endb+Enda)/2)*GeoTrf::TranslateZ3D(-SecE1ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
750  //clockwise from top if taking sideA for reference (counter-clockwise for sideC)
751  TRANSFUNCTION seA1G4 = Pow(GeoTrf::RotateZ3D(1.0),f+(7*Alfa/2))*GeoTrf::TranslateX3D((Endb+Enda)/2)*GeoTrf::TranslateZ3D(SecE1ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
752  TRANSFUNCTION seC1G4 = Pow(GeoTrf::RotateZ3D(1.0),f+(7*Alfa/2))*GeoTrf::TranslateX3D((Endb+Enda)/2)*GeoTrf::TranslateZ3D(-SecE1ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
753  TRANSFUNCTION seA1G3 = Pow(GeoTrf::RotateZ3D(1.0),f+(5*Alfa/2))*GeoTrf::TranslateX3D((Endb+Enda)/2)*GeoTrf::TranslateZ3D(SecE1ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
754  TRANSFUNCTION seC1G3 = Pow(GeoTrf::RotateZ3D(1.0),f+(5*Alfa/2))*GeoTrf::TranslateX3D((Endb+Enda)/2)*GeoTrf::TranslateZ3D(-SecE1ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
755  TRANSFUNCTION seA1G2 = Pow(GeoTrf::RotateZ3D(1.0),f+(3*Alfa/2))*GeoTrf::TranslateX3D((Endb+Enda)/2)*GeoTrf::TranslateZ3D(SecE1ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
756  TRANSFUNCTION seC1G2 = Pow(GeoTrf::RotateZ3D(1.0),f+(3*Alfa/2))*GeoTrf::TranslateX3D((Endb+Enda)/2)*GeoTrf::TranslateZ3D(-SecE1ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
757  TRANSFUNCTION seA1G1 = Pow(GeoTrf::RotateZ3D(1.0),f+(1*Alfa/2))*GeoTrf::TranslateX3D((Endb+Enda)/2)*GeoTrf::TranslateZ3D(SecE1ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
758  TRANSFUNCTION seC1G1 = Pow(GeoTrf::RotateZ3D(1.0),f+(1*Alfa/2))*GeoTrf::TranslateX3D((Endb+Enda)/2)*GeoTrf::TranslateZ3D(-SecE1ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
759  TRANSFUNCTION seA1G16 = Pow(GeoTrf::RotateZ3D(1.0),f-(1*Alfa/2))*GeoTrf::TranslateX3D((Endb+Enda)/2)*GeoTrf::TranslateZ3D(SecE1ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
760  TRANSFUNCTION seC1G16 = Pow(GeoTrf::RotateZ3D(1.0),f-(1*Alfa/2))*GeoTrf::TranslateX3D((Endb+Enda)/2)*GeoTrf::TranslateZ3D(-SecE1ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
761  TRANSFUNCTION seA1G15 = Pow(GeoTrf::RotateZ3D(1.0),f-(3*Alfa/2))*GeoTrf::TranslateX3D((Endb+Enda)/2)*GeoTrf::TranslateZ3D(SecE1ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
762  TRANSFUNCTION seC1G15 = Pow(GeoTrf::RotateZ3D(1.0),f-(3*Alfa/2))*GeoTrf::TranslateX3D((Endb+Enda)/2)*GeoTrf::TranslateZ3D(-SecE1ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
763  TRANSFUNCTION seA1G14 = Pow(GeoTrf::RotateZ3D(1.0),f-(5*Alfa/2))*GeoTrf::TranslateX3D((Endb+Enda)/2)*GeoTrf::TranslateZ3D(SecE1ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
764  TRANSFUNCTION seC1G14 = Pow(GeoTrf::RotateZ3D(1.0),f-(5*Alfa/2))*GeoTrf::TranslateX3D((Endb+Enda)/2)*GeoTrf::TranslateZ3D(-SecE1ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
765  TRANSFUNCTION seA1G13 = Pow(GeoTrf::RotateZ3D(1.0),f-(7*Alfa/2))*GeoTrf::TranslateX3D((Endb+Enda)/2)*GeoTrf::TranslateZ3D(SecE1ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
766  TRANSFUNCTION seC1G13 = Pow(GeoTrf::RotateZ3D(1.0),f-(7*Alfa/2))*GeoTrf::TranslateX3D((Endb+Enda)/2)*GeoTrf::TranslateZ3D(-SecE1ztr)*GeoTrf::RotateY3D(90*Gaudi::Units::deg);
767 
768  GeoSerialTransformer *setA1G5 = new GeoSerialTransformer(sectorenvelopes1g5,&seA1G5, 1);
769  GeoSerialTransformer *setC1G5 = new GeoSerialTransformer(sectorenvelopes1g5,&seC1G5, 1);
770  GeoSerialTransformer *setA1G6 = new GeoSerialTransformer(sectorenvelopes1g6,&seA1G6, 1);
771  GeoSerialTransformer *setC1G6 = new GeoSerialTransformer(sectorenvelopes1g6,&seC1G6, 1);
772  GeoSerialTransformer *setA1G7 = new GeoSerialTransformer(sectorenvelopes1g7,&seA1G7, 1);
773  GeoSerialTransformer *setC1G7 = new GeoSerialTransformer(sectorenvelopes1g7,&seC1G7, 1);
774  GeoSerialTransformer *setA1G8 = new GeoSerialTransformer(sectorenvelopes1g8,&seA1G8, 1);
775  GeoSerialTransformer *setC1G8 = new GeoSerialTransformer(sectorenvelopes1g8,&seC1G8, 1);
776  GeoSerialTransformer *setA1G9 = new GeoSerialTransformer(sectorenvelopes1g9,&seA1G9, 1);
777  GeoSerialTransformer *setC1G9 = new GeoSerialTransformer(sectorenvelopes1g9,&seC1G9, 1);
778  GeoSerialTransformer *setA1G10 = new GeoSerialTransformer(sectorenvelopes1g10,&seA1G10, 1);
779  GeoSerialTransformer *setC1G10 = new GeoSerialTransformer(sectorenvelopes1g10,&seC1G10, 1);
780  GeoSerialTransformer *setA1G11 = new GeoSerialTransformer(sectorenvelopes1g11,&seA1G11, 1);
781  GeoSerialTransformer *setC1G11 = new GeoSerialTransformer(sectorenvelopes1g11,&seC1G11, 1);
782  GeoSerialTransformer *setA1G12 = new GeoSerialTransformer(sectorenvelopes1g12,&seA1G12, 1);
783  GeoSerialTransformer *setC1G12 = new GeoSerialTransformer(sectorenvelopes1g12,&seC1G12, 1);
784 
785  GeoSerialTransformer *setA1G4 = new GeoSerialTransformer(sectorenvelopes1g4,&seA1G4, 1);
786  GeoSerialTransformer *setC1G4 = new GeoSerialTransformer(sectorenvelopes1g4,&seC1G4, 1);
787  GeoSerialTransformer *setA1G3 = new GeoSerialTransformer(sectorenvelopes1g3,&seA1G3, 1);
788  GeoSerialTransformer *setC1G3 = new GeoSerialTransformer(sectorenvelopes1g3,&seC1G3, 1);
789  GeoSerialTransformer *setA1G2 = new GeoSerialTransformer(sectorenvelopes1g2,&seA1G2, 1);
790  GeoSerialTransformer *setC1G2 = new GeoSerialTransformer(sectorenvelopes1g2,&seC1G2, 1);
791  GeoSerialTransformer *setA1G1 = new GeoSerialTransformer(sectorenvelopes1g1,&seA1G1, 1);
792  GeoSerialTransformer *setC1G1 = new GeoSerialTransformer(sectorenvelopes1g1,&seC1G1, 1);
793  GeoSerialTransformer *setA1G16 = new GeoSerialTransformer(sectorenvelopes1g16,&seA1G16, 1);
794  GeoSerialTransformer *setC1G16 = new GeoSerialTransformer(sectorenvelopes1g16,&seC1G16, 1);
795  GeoSerialTransformer *setA1G15 = new GeoSerialTransformer(sectorenvelopes1g15,&seA1G15, 1);
796  GeoSerialTransformer *setC1G15 = new GeoSerialTransformer(sectorenvelopes1g15,&seC1G15, 1);
797  GeoSerialTransformer *setA1G14 = new GeoSerialTransformer(sectorenvelopes1g14,&seA1G14, 1);
798  GeoSerialTransformer *setC1G14 = new GeoSerialTransformer(sectorenvelopes1g14,&seC1G14, 1);
799  GeoSerialTransformer *setA1G13 = new GeoSerialTransformer(sectorenvelopes1g13,&seA1G13, 1);
800  GeoSerialTransformer *setC1G13 = new GeoSerialTransformer(sectorenvelopes1g13,&seC1G13, 1);
801 
802  envelope->add(setA1G5);
803  envelope->add(setC1G5);
804  envelope->add(setA1G6);
805  envelope->add(setC1G6);
806  envelope->add(setA1G7);
807  envelope->add(setC1G7);
808  envelope->add(setA1G8);
809  envelope->add(setC1G8);
810  envelope->add(setA1G9);
811  envelope->add(setC1G9);
812  envelope->add(setA1G10);
813  envelope->add(setC1G10);
814  envelope->add(setA1G11);
815  envelope->add(setC1G11);
816  envelope->add(setA1G12);
817  envelope->add(setC1G12);
818 
819  envelope->add(setA1G4);
820  envelope->add(setC1G4);
821  envelope->add(setA1G3);
822  envelope->add(setC1G3);
823  envelope->add(setA1G2);
824  envelope->add(setC1G2);
825  envelope->add(setA1G1);
826  envelope->add(setC1G1);
827  envelope->add(setA1G16);
828  envelope->add(setC1G16);
829  envelope->add(setA1G15);
830  envelope->add(setC1G15);
831  envelope->add(setA1G14);
832  envelope->add(setC1G14);
833  envelope->add(setA1G13);
834  envelope->add(setC1G13);
835 
836  createSectorEnvelopes2FromDB (envelope, materialManager,
837  trdMap, *BarrelDMTrds,
838  trapMap, *BarrelDMTraps,
839  boxMap, *BarrelDMBoxes,
840  f, Box);
841  createBridgeEnvelopesFromDB (envelope, trapMap, *BarrelDMTraps,
842  matLArServices8, f);
843  createBaseEnvelopesFromDB (envelope, trdMap, *BarrelDMTrds,
844  matLArServices8, f);
845 }
846 
847 
849  , IGeoModelSvc* geoModel
850  , StoredMaterialManager* materialManager
851  , bool activateFT)
852  : AthMessaging("CrackDMConstruction")
853  , m_rdbAccess(rdbAccess)
854  , m_geoModel(geoModel)
855  , m_materialManager(materialManager)
856  , m_activateFT(activateFT)
857 {
858 }
859 
860 void CrackDMConstruction::create(GeoFullPhysVol* envelope)
861 {
862  createFromDB(envelope
863  , m_rdbAccess
864  , m_geoModel
866 
867  if(m_activateFT){
868  std::string name = "LAr::Barrel::SignalFT::";
869  ATH_MSG_DEBUG("creating " << name << " volumes");
870 
871  const GeoMaterial* iron = m_materialManager->getMaterial("std::Iron");
872 
873  const double wflange_height = 37.*Gaudi::Units::mm;
874  const double wflange_R = 0.5*360.*Gaudi::Units::mm;
875  const GeoMaterial* wflange_mat = m_materialManager->getMaterial("LAr::FT::WarmFlange");
876 
877  GeoShape* wflange = new GeoTube(0., wflange_R, wflange_height/2);
878  GeoLogVol* wflangeLV = new GeoLogVol(name + "WarmFlange", wflange, wflange_mat);
879  GeoPhysVol* wflangePV = new GeoPhysVol(wflangeLV);
880 
881  const double bellow_height = 225.*Gaudi::Units::mm;
882  const double bellow_Router = 0.5*299.*Gaudi::Units::mm; // this also to be cut in warm wall
883  const double bellow_wall = 15.*Gaudi::Units::mm;
884  const GeoMaterial* bellow_mat = m_materialManager->getMaterial("LAr::FT::Bellow");
885 
886  const double bellow_Rinner = bellow_Router - bellow_wall;
887  GeoShape* bellow = new GeoTube(bellow_Rinner, bellow_Router, bellow_height/2);
888  GeoLogVol* bellowLV = new GeoLogVol(name + "Bellow", bellow, bellow_mat);
889  GeoPhysVol* bellowPV = new GeoPhysVol(bellowLV);
890 
891  const GeoMaterial* vcables_mat = m_materialManager->getMaterial("LAr::FT::VacuumCables");
892 
893  GeoShape* vcables = new GeoTube(0., bellow_Rinner, bellow_height/2);
894  GeoLogVol* vcablesLV = new GeoLogVol(name + "VacuumCables", vcables, vcables_mat);
895  GeoPhysVol* vcablesPV = new GeoPhysVol(vcablesLV);
896 
897  const double cflange_height = 35.*Gaudi::Units::mm;
898  const double cflange_Router = 0.5*283.*Gaudi::Units::mm;
899  const GeoMaterial* cflange_mat = m_materialManager->getMaterial("LAr::FT::ColdFlange");
900  GeoShape* cflange = new GeoTube(0., cflange_Router, cflange_height/2);
901  GeoLogVol* cflangeLV = new GeoLogVol(name + "ColdFlange", cflange, cflange_mat);
902  GeoPhysVol* cflangePV = new GeoPhysVol(cflangeLV);
903 
904  const double coldbox1_Router = cflange_Router;
905  const double coldbox1_wall = 0.134*2.54*Gaudi::Units::cm;
906  const double coldbox1_height = 90.*Gaudi::Units::mm;
907  const double coldbox2_height = 16.*Gaudi::Units::mm;
908  const double hole_r = 0.5*133.*Gaudi::Units::mm;
909  const double hole_shift = -31.*Gaudi::Units::mm;
910  const double coldbox3_Router = 0.5*140.*Gaudi::Units::mm; // this also to be cut in cold wall
911  const double barrel_dist_from_outer_warm_wall_to_inner_cold_wall =
912  500.*Gaudi::Units::mm;
913  const double coldbox3_height = // adjust to match dist between cryo walls
914  barrel_dist_from_outer_warm_wall_to_inner_cold_wall
915  - bellow_height - coldbox1_height - coldbox2_height;
916  ATH_MSG_DEBUG("funnel tube len = " << coldbox3_height / Gaudi::Units::mm << " mm ");
917  const GeoMaterial* coldbox_mat = iron;
918  GeoShape* coldbox1 = new GeoTube(coldbox1_Router - coldbox1_wall, coldbox1_Router, coldbox1_height/2); // wide part
919  GeoShape* coldbox11 = new GeoTube(0., coldbox1_Router, coldbox1_height/2); // wide part for FTenvelope
920  GeoLogVol* coldbox1LV = new GeoLogVol(name + "ColdBox1", coldbox1, coldbox_mat);
921  GeoPhysVol* coldbox1PV = new GeoPhysVol(coldbox1LV);
922  GeoShape* coldbox21 = new GeoTube(0., coldbox1_Router, coldbox2_height/2); // plate
923  GeoShape* coldbox22 = new GeoTube(0., hole_r, coldbox2_height); // hole in the plate
924  const GeoShape& coldbox2 = coldbox21->subtract((*coldbox22) << GeoTrf::TranslateY3D(hole_shift));
925  GeoLogVol* coldbox2LV = new GeoLogVol(name + "ColdBox2", &coldbox2, coldbox_mat);
926  GeoPhysVol* coldbox2PV = new GeoPhysVol(coldbox2LV);
927  GeoShape* coldbox3 = new GeoTube(hole_r, coldbox3_Router, coldbox3_height/2); // narrow part
928  GeoShape* coldbox31 = new GeoTube(0., coldbox3_Router, coldbox3_height/2); // narrow part for FTenvelope
929  GeoLogVol* coldbox3LV = new GeoLogVol(name + "ColdBox3", coldbox3, coldbox_mat);
930  GeoPhysVol* coldbox3PV = new GeoPhysVol(coldbox3LV);
931 
932  GeoTrf::TranslateZ3D bellow_pos(-wflange_height/2 - bellow_height/2);
933  GeoTrf::TranslateZ3D cflange_pos(-wflange_height/2 - bellow_height - cflange_height/2);
934  GeoTrf::TranslateZ3D coldbox1_pos(-wflange_height/2 - bellow_height - cflange_height - coldbox1_height/2);
935  GeoTrf::TranslateZ3D coldbox2_pos(-wflange_height/2 - bellow_height - cflange_height - coldbox1_height - coldbox2_height/2);
936  GeoTrf::Translate3D coldbox2hole_pos(
937  0., hole_shift,
938  -wflange_height/2 - bellow_height - cflange_height - coldbox1_height - coldbox2_height/2
939  );
940  GeoTrf::Translate3D coldbox3_pos(
941  0., hole_shift,
942  -wflange_height/2 - bellow_height - cflange_height - coldbox1_height - coldbox2_height - coldbox3_height/2
943  );
944 
945  const GeoShape& FTenvelope = wflange->add(
946  (*bellow) << bellow_pos
947  ).add(
948  (*cflange) << cflange_pos
949  ).add(
950  (*coldbox11) << coldbox1_pos
951  ).add(
952  (*coldbox21) << coldbox2_pos
953  ).add(
954  (*coldbox31) << coldbox3_pos
955  );
956 
957  GeoLogVol* FTLV = new GeoLogVol(name + "Envelope",
958  &FTenvelope,
959  m_materialManager->getMaterial("std::Air")
960  );
961  GeoPhysVol* FTPV = new GeoPhysVol(FTLV);
962 
963  FTPV->add(wflangePV);
964  GeoTransform *bellow_trf = new GeoTransform(bellow_pos);
965  FTPV->add(bellow_trf);
966  FTPV->add(bellowPV);
967  FTPV->add(bellow_trf);
968  FTPV->add(vcablesPV);
969  GeoTransform *cflange_trf = new GeoTransform(cflange_pos);
970  FTPV->add(cflange_trf);
971  FTPV->add(cflangePV);
972  GeoTransform *coldbox1_trf = new GeoTransform(coldbox1_pos);
973  FTPV->add(coldbox1_trf);
974  FTPV->add(coldbox1PV);
975  GeoTransform *coldbox2_trf = new GeoTransform(coldbox2_pos);
976  FTPV->add(coldbox2_trf);
977  FTPV->add(coldbox2PV);
978  GeoTransform *coldbox3_trf = new GeoTransform(coldbox3_pos);
979  FTPV->add(coldbox3_trf);
980  FTPV->add(coldbox3PV);
981 
982  const GeoMaterial* lar_mat = m_materialManager->getMaterial("std::LiquidArgon");
983  GeoShape* lar1 = new GeoTube(0., coldbox1_Router - coldbox1_wall, coldbox1_height/2);
984  GeoShape* lar2 = new GeoTube(0., hole_r, coldbox1_height);
985  const GeoShape& lar = lar1->subtract((*lar2) << GeoTrf::TranslateY3D(hole_shift));
986  GeoLogVol* larLV = new GeoLogVol(name + "LAr", &lar, lar_mat);
987  GeoPhysVol* larPV = new GeoPhysVol(larLV);
988  FTPV->add(coldbox1_trf);
989  FTPV->add(larPV);
990 
991  const GeoMaterial *pigtail_mat = m_materialManager->getMaterial("LAr::FT::Pigtail");
992 
993  const double pth = (coldbox1_height + coldbox2_height + coldbox3_height) / 2;
994  GeoTransform *pigtail_trf = new GeoTransform(
995  GeoTrf::Translate3D(0, hole_shift,
996  -wflange_height/2 - bellow_height - cflange_height - pth
997  ));
998  GeoShape* pigtail = new GeoTube(0., hole_r, pth);
999  GeoLogVol* pigtailLV = new GeoLogVol(name + "Pigtail", pigtail, pigtail_mat);
1000  GeoPhysVol* pigtailPV = new GeoPhysVol(pigtailLV);
1001  FTPV->add(pigtail_trf);
1002  FTPV->add(pigtailPV);
1003 
1004  // total lenght should be 28.5 cm
1005  const double ocable_len = 10.*Gaudi::Units::cm;
1006  const double ocable_R = (1.1/2)*sqrt(1920*2.85)*Gaudi::Units::mm;
1007  const GeoMaterial* ocable_mat = m_materialManager->getMaterial("LAr::FT::Cable");
1008  GeoShape* ocable = new GeoTube(0., ocable_R, ocable_len / 2);
1009  GeoLogVol* ocableLV = new GeoLogVol("LAr::Barrel::FTCables", ocable, ocable_mat);
1010  GeoPhysVol* ocablePV = new GeoPhysVol(ocableLV);
1011 
1012  // todo: take cryostat parameters from DB
1013  const double r0 = 277.5*Gaudi::Units::cm // cryo warm wall outer radius
1014  + wflange_height/2; // warm flange is abobe the wall
1015  const double r2 = r0 + wflange_height/2 + ocable_len/2;
1016  const double z_pos = 3170.*Gaudi::Units::mm;
1017  const int NCrates = 16;
1018  const double dphi = 4.*Gaudi::Units::deg;
1019 
1020  auto put1 = [&envelope](GeoPhysVol *object, double r, double phi, double z)
1021  {
1022  envelope->add(new GeoTransform(
1023  GeoTrf::Translate3D(r*cos(phi), r*sin(phi), z) *
1024  GeoTrf::RotateX3D(90.*Gaudi::Units::deg) *
1025  GeoTrf::RotateY3D(phi + 90.*Gaudi::Units::deg)
1026  ));
1027  if(z < 0){
1028  envelope->add(new GeoTransform(GeoTrf::RotateZ3D(180.*Gaudi::Units::deg)));
1029  }
1030  envelope->add(object);
1031  };
1032 
1033  auto put = [&put1, &FTPV, &ocablePV, r0, r2](double phi, double z)
1034  {
1035  put1(FTPV, r0, phi, z);
1036  put1(ocablePV, r2, phi, z);
1037  };
1038 
1039  for(int i = 0; i < 16; ++ i){
1040  const double phi = 360.*Gaudi::Units::deg / NCrates * i;
1041  put(phi - dphi, z_pos);
1042  put(phi + dphi, z_pos);
1043  put(phi - dphi, -z_pos);
1044  put(phi + dphi, -z_pos);
1045  }
1046  }
1047 
1048 }
1049 
beamspotman.r
def r
Definition: beamspotman.py:676
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
IRDBAccessSvc::getRecordsetPtr
virtual IRDBRecordset_ptr getRecordsetPtr(const std::string &node, const std::string &tag, const std::string &tag2node="", const std::string &connName="ATLASDD")=0
Provides access to the Recordset object containing HVS-tagged data.
IGeoModelSvc
Definition: IGeoModelSvc.h:17
InDetAccessor::phi0
@ phi0
Definition: InDetAccessor.h:33
M_PI
#define M_PI
Definition: ActiveFraction.h:11
xAOD::etaMax
etaMax
Definition: HIEventShape_v2.cxx:46
deg
#define deg
Definition: SbPolyhedron.cxx:17
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
DecodeVersionKey::node
const std::string & node() const
Return the version node.
Definition: DecodeVersionKey.cxx:97
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
IRDBRecordset
IRDBRecordset is an abstract interface to the RDB Recordsets, which represent a snapshot of HVS-tagge...
Definition: IRDBRecordset.h:35
CrackDMConstruction::m_activateFT
bool m_activateFT
Definition: CrackDMConstruction.h:30
CrackDMConstruction::m_materialManager
StoredMaterialManager * m_materialManager
Definition: CrackDMConstruction.h:29
cm
const double cm
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/FCAL_ChannelMap.cxx:25
IRDBAccessSvc.h
Definition of the abstract IRDBAccessSvc interface.
lumiFormat.i
int i
Definition: lumiFormat.py:85
z
#define z
CrackDMConstruction::create
void create(GeoFullPhysVol *envelope)
Definition: CrackDMConstruction.cxx:860
IRDBAccessSvc
IRDBAccessSvc is an abstract interface to the athena service that provides the following functionalit...
Definition: IRDBAccessSvc.h:42
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
DecodeVersionKey
This is a helper class to query the version tags from GeoModelSvc and determine the appropriate tag a...
Definition: DecodeVersionKey.h:18
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
TRT_PAI_physicsConstants::r0
const double r0
electron radius{cm}
Definition: TRT_PAI_physicsConstants.h:20
DecodeVersionKey::tag
const std::string & tag() const
Return version tag.
Definition: DecodeVersionKey.cxx:91
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
add
bool add(const std::string &hname, TKey *tobj)
Definition: fastadd.cxx:55
hist_file_dump.f
f
Definition: hist_file_dump.py:135
CrackDMConstruction::m_rdbAccess
IRDBAccessSvc * m_rdbAccess
Definition: CrackDMConstruction.h:27
drawFromPickle.tan
tan
Definition: drawFromPickle.py:36
Box
Acts::Volume::BoundingBox Box
Definition: ActsCaloTrackingVolumeBuilder.cxx:29
IRDBRecordset_ptr
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition: IRDBAccessSvc.h:25
CrackDMConstruction.h
createSectorEnvelopes2FromDB
void createSectorEnvelopes2FromDB(GeoFullPhysVol *envelope, StoredMaterialManager *materialManager, std::map< std::string, unsigned int > &trdMap, IRDBRecordset &BarrelDMTrds, std::map< std::string, unsigned int > &trapMap, IRDBRecordset &BarrelDMTraps, std::map< std::string, unsigned int > &boxMap, IRDBRecordset &BarrelDMBoxes, GENFUNCTION &f, GeoBox *Box)
Definition: CrackDMConstruction.cxx:62
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
StoredMaterialManager.h
CrackDMConstruction::CrackDMConstruction
CrackDMConstruction()=delete
DecodeVersionKey.h
Variable
Wrapper around a histogram which allows for some additional filling patterns and data manipulation.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/Variable.h:39
ParticleGun_SamplingFraction.radius
radius
Definition: ParticleGun_SamplingFraction.py:96
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
createFromDB
void createFromDB(GeoFullPhysVol *envelope, IRDBAccessSvc *rdbAccess, IGeoModelSvc *geoModel, StoredMaterialManager *materialManager)
Definition: CrackDMConstruction.cxx:334
LArCellBinning.etaMin
etaMin
Definition: LArCellBinning.py:84
IRDBRecord.h
Definition of the abstract IRDBRecord interface.
GeoGenfun
Definition: ArrayFunction.cxx:7
IRDBRecord
IRDBRecord is one record in the IRDBRecordset object.
Definition: IRDBRecord.h:27
StoredMaterialManager::getMaterial
virtual const GeoMaterial * getMaterial(const std::string &name)=0
StoredMaterialManager
This class holds one or more material managers and makes them storeable, under StoreGate.
Definition: StoredMaterialManager.h:28
pickleTool.object
object
Definition: pickleTool.py:30
CrackDMConstruction::m_geoModel
IGeoModelSvc * m_geoModel
Definition: CrackDMConstruction.h:28
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
IRDBRecordset.h
Definition of the abstract IRDBRecordset interface.
IGeoModelSvc.h
makeComparison.deltaR
float deltaR
Definition: makeComparison.py:36
StoreGateSvc.h
readCCLHist.float
float
Definition: readCCLHist.py:83
createBridgeEnvelopesFromDB
void createBridgeEnvelopesFromDB(GeoFullPhysVol *envelope, std::map< std::string, unsigned int > &trapMap, IRDBRecordset &BarrelDMTraps, const GeoMaterial *matLArServices8, GENFUNCTION &f)
Definition: CrackDMConstruction.cxx:270
fitman.k
k
Definition: fitman.py:528
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
createBaseEnvelopesFromDB
void createBaseEnvelopesFromDB(GeoFullPhysVol *envelope, std::map< std::string, unsigned int > &trdMap, IRDBRecordset &BarrelDMTrds, const GeoMaterial *matLArServices8, GENFUNCTION &f)
Definition: CrackDMConstruction.cxx:306