68{
69
72 throw std::runtime_error("Unable to retrieve TileTBID");
73
74
76
77
78 StoredPhysVol* storedLArECA = 0;
79 StoredPhysVol* storedLArECC = 0;
80
82 if(
status.isFailure() || storedLArECA == 0)
83 throw std::runtime_error("Failed to locate LAr Endcap A");
84
86 if(
status.isFailure() || storedLArECC == 0)
87 throw std::runtime_error("Failed to locate LAr Endcap C");
88
89
90
91 GeoFullPhysVol* pvLArECA = storedLArECA->
getPhysVol();
92 GeoFullPhysVol* pvLArECC = storedLArECC->
getPhysVol();
93
94 GeoTrf::Transform3D xfLArECA = pvLArECA->getAbsoluteTransform();
95 GeoTrf::Transform3D xfLArECC = pvLArECC->getAbsoluteTransform();
96
97
98 GeoTrf::Transform3D xfMbtsMother;
99 PVConstLink pvMbtsMother;
100 bool mbtsExists = false;
101
102 GeoVolumeCursor cursor1(pvLArECA);
103 while(!cursor1.atEnd())
104 {
105 PVConstLink child = cursor1.getVolume();
106 if(child->getLogVol()->getName() == "MBTS_mother")
107 {
108 pvMbtsMother = child;
109 xfMbtsMother = cursor1.getTransform();
110 mbtsExists = true;
111 break;
112 }
113 cursor1.next();
114 }
115
116 if(!mbtsExists)
117 throw std::runtime_error("Unable to find MBTS volume");
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134 GeoVolumeCursor cursor2(pvMbtsMother);
135
136 PVConstLink pvScin1;
137 PVConstLink pvScin2;
138
139 bool scin1Exists = false;
140 bool scin2Exists = false;
141
142 while(!cursor2.atEnd())
143 {
144 PVConstLink child = cursor2.getVolume();
145 std::string childName = child->getLogVol()->getName();
146 if(childName.find("MBTSAirEnv")!=std::string::npos) {
148 break;
149 }
150 if(childName == "MBTS1")
151 {
152 scin1Exists = true;
153 pvScin1 = child;
154 int copyNo= cursor2.getId().value();
155
156 aTransforms1[copyNo] = xfLArECA * xfMbtsMother * cursor2.getTransform();
157 cTransforms1[copyNo] = xfLArECC * xfMbtsMother * cursor2.getTransform();
158 }
159 else if(childName == "MBTS2")
160 {
161 scin2Exists = true;
162 pvScin2 = child;
163 int copyNo= cursor2.getId().value();
164
165 aTransforms2[copyNo] = xfLArECA * xfMbtsMother * cursor2.getTransform();
166 cTransforms2[copyNo] = xfLArECC * xfMbtsMother * cursor2.getTransform();
167 }
168 cursor2.next();
169 }
170
172 GeoVolumeCursor cursor2a(pvMbtsMother);
173 while(!cursor2a.atEnd()) {
174 PVConstLink pvAirEnv = cursor2a.getVolume();
175 if(pvAirEnv->getLogVol()->getName().find("MBTSAirEnv")!=std::string::npos) {
176 int copyNo = cursor2a.getId().value();
177
178
179 GeoVolumeCursor cursor3(pvAirEnv);
180 bool aluEnvExists(false);
181 while(!cursor3.atEnd()) {
182 if(cursor3.getVolume()->getLogVol()->getName().find("MBTSAluEnv")!=std::string::npos) {
183 aluEnvExists = true;
184 break;
185 }
186 cursor3.next();
187 }
188 if(!aluEnvExists)
189 throw std::runtime_error("Problems with MBTS geometry: Cannot find MBTSAluEnv!");
190
191 PVConstLink pvAluEnv = cursor3.getVolume();
192
193
194 GeoVolumeCursor cursor4(pvAluEnv);
195 bool airInAluExists(false);
196 while(!cursor4.atEnd()) {
197 if(cursor4.getVolume()->getLogVol()->getName().find("MBTSAirInAlu")!=std::string::npos) {
198 airInAluExists = true;
199 break;
200 }
201 cursor4.next();
202 }
203 if(!airInAluExists)
204 throw std::runtime_error("Problems with MBTS geometry: Cannot find MBTSAirInAlu!");
205
206 PVConstLink pvAirInAluEnv = cursor4.getVolume();
207
208
209 GeoVolumeCursor cursor5(pvAirInAluEnv);
210 while(!cursor5.atEnd()) {
211 PVConstLink child = cursor5.getVolume();
212 if(child->getLogVol()->getName()=="MBTS1") {
213 scin1Exists = true;
214 pvScin1 = child;
215 aTransforms1[copyNo] = xfLArECA * xfMbtsMother * cursor2a.getTransform() * cursor3.getTransform() * cursor4.getTransform() * cursor5.getTransform();
216 cTransforms1[copyNo] = xfLArECC * xfMbtsMother * cursor2a.getTransform() * cursor3.getTransform() * cursor4.getTransform() * cursor5.getTransform();
217 }
218 if(child->getLogVol()->getName()=="MBTS2") {
219 scin2Exists = true;
220 pvScin2 = child;
221 aTransforms2[copyNo] = xfLArECA * xfMbtsMother * cursor2a.getTransform() * cursor3.getTransform() * cursor4.getTransform() * cursor5.getTransform();
222 cTransforms2[copyNo] = xfLArECC * xfMbtsMother * cursor2a.getTransform() * cursor3.getTransform() * cursor4.getTransform() * cursor5.getTransform();
223 }
224 cursor5.next();
225 }
226 }
227 cursor2a.next();
228 }
229 }
230
231 if(!scin1Exists)
232 throw std::runtime_error("No MBTS1 in the geometry");
233
234 if(!scin2Exists)
235 throw std::runtime_error("No MBTS2 in the geometry");
236
237 const GeoShape* shape1 = pvScin1->getLogVol()->getShape();
238 const GeoShape* shape2 = pvScin2->getLogVol()->getShape();
239
240 const GeoTrd* trd1 = dynamic_cast<const GeoTrd*>(shape1);
241 const GeoTrd* trd2 = dynamic_cast<const GeoTrd*>(shape2);
242
243 if(trd1==0)
244 throw std::runtime_error("The shape of MBTS1 is not TRD");
245
246 if(trd2==0)
247 throw std::runtime_error("The shape of MBTS2 is not TRD");
248
249
250 VP1CC_MbtsScinInfo* scinInfo1 = new VP1CC_MbtsScinInfo();
251 VP1CC_MbtsScinInfo* scinInfo2 = new VP1CC_MbtsScinInfo();
252
253 scinInfo1->
dx1 = trd1->getXHalfLength1();
254 scinInfo1->
dx2 = trd1->getXHalfLength2();
255 scinInfo1->
dy1 = trd1->getYHalfLength1();
256 scinInfo1->
dy2 = trd1->getYHalfLength2();
257 scinInfo1->
dz = trd1->getZHalfLength();
260
261 scinInfo2->
dx1 = trd2->getXHalfLength1();
262 scinInfo2->
dx2 = trd2->getXHalfLength2();
263 scinInfo2->
dy1 = trd2->getYHalfLength1();
264 scinInfo2->
dy2 = trd2->getYHalfLength2();
265 scinInfo2->
dz = trd2->getZHalfLength();
268
269
272}
std::map< int, GeoTrf::Transform3D, std::less< int > > VP1CC_MbtsXfMap
GeoFullPhysVol * getPhysVol()
Destructor.
VP1CC_MbtsXfMap cTransforms
VP1CC_MbtsXfMap aTransforms