]>
Commit | Line | Data |
---|---|---|
29998a6e | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* | |
451f5018 | 17 | $Id: AliITSUInitGeometry.cxx $ |
29998a6e | 18 | */ |
19 | //////////////////////////////////////////////////////////////// | |
20 | // This class initializes the class AliITSgeom | |
21 | // The initialization is done starting from | |
22 | // a geometry coded by means of the ROOT geometrical modeler | |
23 | // This initialization can be used both for simulation and reconstruction | |
24 | /////////////////////////////////////////////////////////////// | |
25 | ||
26 | #include <TArrayD.h> | |
27 | #include <TArrayF.h> | |
28 | #include <TStopwatch.h> | |
29 | #include <TGeoManager.h> | |
30 | #include <TGeoMatrix.h> | |
31 | #include <TGeoVolume.h> | |
32 | #include <TGeoShape.h> | |
33 | #include <TGeoBBox.h> | |
34 | #include <TGeoTrd1.h> | |
35 | #include <TGeoTrd2.h> | |
36 | #include <TGeoArb8.h> | |
37 | #include <TGeoTube.h> | |
38 | #include <TGeoCone.h> | |
39 | #include <TGeoSphere.h> | |
40 | #include <TGeoPara.h> | |
41 | #include <TGeoPgon.h> | |
42 | #include <TGeoPcon.h> | |
43 | #include <TGeoEltu.h> | |
44 | #include <TGeoHype.h> | |
45 | #include <TMath.h> | |
46 | ||
47 | #include "AliLog.h" | |
451f5018 | 48 | #include "AliITSUGeomTGeo.h" |
49 | #include "AliITSUInitGeometry.h" | |
29998a6e | 50 | #include <TDatime.h> |
51 | ||
451f5018 | 52 | ClassImp(AliITSUInitGeometry) |
29998a6e | 53 | |
54 | //______________________________________________________________________ | |
451f5018 | 55 | AliITSUInitGeometry::AliITSUInitGeometry() |
56 | : TObject() | |
57 | ,fName(0) | |
58 | ,fTiming(kFALSE) | |
59 | ,fDebug(0) | |
60 | { | |
29998a6e | 61 | } |
29998a6e | 62 | |
29998a6e | 63 | //______________________________________________________________________ |
451f5018 | 64 | AliITSgeom* AliITSUInitGeometry::CreateAliITSgeom() |
65 | { | |
66 | // Creates and Initilizes the geometry transformation class AliITSgeom | |
67 | // to values appropreate to this specific geometry. Now that | |
68 | // the segmentation is part of AliITSgeom, the detector | |
69 | // segmentations are also defined here. | |
70 | // | |
29998a6e | 71 | |
72 | AliITSVersion_t version = kvDefault; | |
73 | Int_t minor = 0; | |
74 | TDatime datetime; | |
451f5018 | 75 | TGeoVolume *itsV = gGeoManager->GetVolume(AliITSUGeomTGeo::GetITSVolPattern()); |
29998a6e | 76 | if(!itsV){ |
77 | Error("CreateAliITSgeom","Can't find ITS volume ITSV, aborting"); | |
78 | return 0; | |
79 | }// end if | |
451f5018 | 80 | |
29998a6e | 81 | SetTiming(kFALSE); |
82 | SetSegGeom(kFALSE); | |
83 | SetDecoding(kFALSE); | |
84 | AliITSgeom *geom = CreateAliITSgeom(version,minor); | |
85 | AliDebug(1,"AliITSgeom object has been initialized from TGeo\n"); | |
86 | return geom; | |
87 | } | |
451f5018 | 88 | |
29998a6e | 89 | //______________________________________________________________________ |
451f5018 | 90 | AliITSgeom* AliITSUInitGeometry::CreateAliITSgeom(Int_t major,Int_t minor){ |
29998a6e | 91 | // Creates and Initilizes the geometry transformation class AliITSgeom |
92 | // to values appropreate to this specific geometry. Now that | |
93 | // the segmentation is part of AliITSgeom, the detector | |
94 | // segmentations are also defined here. | |
95 | // Inputs: | |
96 | // Int_t major major version, see AliITSVersion_t | |
97 | // Int_t minor minor version | |
98 | // Outputs: | |
99 | // none. | |
100 | // Return: | |
101 | // A pointer to a new properly inilized AliITSgeom class. If | |
102 | // pointer = 0 then failed to init. | |
103 | ||
104 | switch(major){ | |
105 | case kv11: | |
106 | SetGeometryName("AliITSv11"); | |
107 | SetVersion(kv11,minor); | |
108 | break; | |
109 | case kvUpgrade: | |
451f5018 | 110 | SetGeometryName("AliITSUv11"); |
29998a6e | 111 | SetVersion(kvUpgrade,minor); |
112 | break; | |
113 | case kvDefault: | |
114 | default: | |
115 | SetGeometryName("Undefined"); | |
116 | SetVersion(kvDefault,minor); | |
117 | break; | |
118 | } // end switch | |
119 | AliITSgeom *geom = new AliITSgeom(); | |
120 | if(!InitAliITSgeom(geom)){ // Error initilization failed | |
121 | delete geom; | |
122 | geom = 0; | |
123 | } // end if | |
124 | return geom; | |
125 | } | |
126 | //______________________________________________________________________ | |
451f5018 | 127 | Bool_t AliITSUInitGeometry::InitAliITSgeom(AliITSgeom *geom){ |
29998a6e | 128 | // Initilizes the geometry transformation class AliITSgeom |
129 | // to values appropreate to this specific geometry. Now that | |
130 | // the segmentation is part of AliITSgeom, the detector | |
131 | // segmentations are also defined here. | |
132 | // Inputs: | |
133 | // AliITSgeom *geom A pointer to the AliITSgeom class | |
134 | // Outputs: | |
135 | // AliITSgeom *geom This pointer recreated and properly inilized. | |
136 | // Return: | |
137 | // none. | |
138 | ||
139 | if(!gGeoManager){ | |
140 | AliFatal("The geometry manager has not been initialized (e.g. " | |
141 | "TGeoManager::Import(\"geometry.root\")should be " | |
142 | "called in advance) - exit forced"); | |
143 | return kFALSE; | |
144 | } // end if | |
145 | switch(fMajorVersion) { | |
146 | case kv11: { | |
147 | return InitAliITSgeomV11(geom); | |
148 | } break; // end case | |
149 | case kvUpgrade: { | |
150 | return InitAliITSgeomVUpgrade(geom); | |
151 | } break; // end case | |
152 | case kvDefault: default: { | |
153 | AliFatal("Undefined geometry"); | |
154 | return kFALSE; | |
155 | } break; // end case | |
156 | } // end switch | |
157 | return kFALSE; | |
158 | } | |
159 | //______________________________________________________________________ | |
451f5018 | 160 | void AliITSUInitGeometry::TransposeTGeoHMatrix(TGeoHMatrix *m)const{ |
29998a6e | 161 | // Transpose the rotation matrix part of a TGeoHMatrix. This |
162 | // is needed because TGeo stores the transpose of the rotation | |
163 | // matrix as compared to what AliITSgeomMatrix uses (and Geant3). | |
164 | // Inputs: | |
165 | // TGeoHMatrix *m The matrix to be transposed | |
166 | // Outputs: | |
167 | // TGEoHMatrix *m The transposed matrix | |
168 | // Return: | |
169 | // none. | |
170 | Int_t i; | |
171 | Double_t r[9]; | |
172 | ||
173 | if(m==0) return; // no matrix to transpose. | |
174 | for(i=0;i<9;i += 4) r[i] = m->GetRotationMatrix()[i]; // diagonals | |
175 | r[1] = m->GetRotationMatrix()[3]; | |
176 | r[2] = m->GetRotationMatrix()[6]; | |
177 | r[3] = m->GetRotationMatrix()[1]; | |
178 | r[5] = m->GetRotationMatrix()[7]; | |
179 | r[6] = m->GetRotationMatrix()[2]; | |
180 | r[7] = m->GetRotationMatrix()[5]; | |
181 | m->SetRotation(r); | |
182 | return; | |
183 | } | |
184 | ||
185 | ||
186 | //______________________________________________________________________ | |
451f5018 | 187 | Bool_t AliITSUInitGeometry::InitAliITSgeomV11(AliITSgeom *geom){ |
29998a6e | 188 | // Initilizes the geometry transformation class AliITSgeom |
189 | // Now that the segmentation is part of AliITSgeom, the detector | |
190 | // segmentations are also defined here. | |
191 | // | |
192 | // Inputs: | |
193 | // AliITSgeom *geom A pointer to the AliITSgeom class | |
194 | // Outputs: | |
195 | // AliITSgeom *geom This pointer recreated and properly inilized. | |
196 | // LG | |
197 | ||
198 | const Int_t kItype = 0; // Type of transformation defined 0=> Geant | |
199 | const Int_t klayers = 6; // number of layers in the ITS | |
200 | const Int_t kladders[klayers] = {20,40,14,22,34,38}; // Number of ladders | |
201 | const Int_t kdetectors[klayers] = {4,4,6,8,22,25};// number of detector/lad | |
202 | const AliITSDetector kIdet[6] = {kSPD,kSPD,kSDD,kSDD,kSSD,kSSD}; | |
203 | const TString kPathbase = "/ALIC_1/ITSV_1/"; | |
204 | ||
205 | const char *pathSPDsens1, *pathSPDsens2; | |
206 | pathSPDsens1="%sITSSPD_1/ITSSPDCarbonFiberSectorV_%d/ITSSPDSensitiveVirtualvolumeM0_1/ITSSPDlay1-Stave_%d/ITSSPDhalf-Stave%d_1/ITSSPDlay1-Ladder_%d/ITSSPDlay1-sensor_1"; | |
207 | pathSPDsens2="%sITSSPD_1/ITSSPDCarbonFiberSectorV_%d/ITSSPDSensitiveVirtualvolumeM0_1/ITSSPDlay2-Stave_%d/ITSSPDhalf-Stave%d_1/ITSSPDlay2-Ladder_%d/ITSSPDlay2-sensor_1"; | |
208 | ||
209 | const char *pathSDDsens1, *pathSDDsens2; | |
210 | pathSDDsens1 = "%sITSsddLayer3_1/ITSsddLadd_%d/ITSsddSensor3_%d/ITSsddWafer3_%d/ITSsddSensitivL3_1"; | |
211 | pathSDDsens2 = "%sITSsddLayer4_1/ITSsddLadd_%d/ITSsddSensor4_%d/ITSsddWafer4_%d/ITSsddSensitivL4_1"; | |
212 | ||
213 | const char *pathSSDsens1, *pathSSDsens2; | |
214 | pathSSDsens1 = "%sITSssdLayer5_1/ITSssdLay5Ladd_%d/ITSssdSensor5_%d/ITSssdSensitivL5_1"; | |
215 | pathSSDsens2 = "%sITSssdLayer6_1/ITSssdLay6Ladd_%d/ITSssdSensor6_%d/ITSssdSensitivL6_1"; | |
216 | ||
217 | const TString kNames[klayers] = { | |
218 | pathSPDsens1, // lay=1 | |
219 | pathSPDsens2, // lay=2 | |
220 | pathSDDsens1, // lay=3 | |
221 | pathSDDsens2, // lay=4 | |
222 | pathSSDsens1, // lay=5 | |
223 | pathSSDsens2};// Lay=6 | |
224 | ||
225 | Int_t mod,nmods=0, lay, lad, det, cpn0, cpn1, cpn2, cpnHS=1; | |
226 | Double_t tran[3]={0.,0.,0.}, rot[10]={9*0.0,1.0}; | |
227 | TArrayD shapePar; | |
228 | TString path, shapeName; | |
229 | TGeoHMatrix matrix; | |
230 | Bool_t initSeg[3]={kFALSE, kFALSE, kFALSE}; | |
231 | TStopwatch *time = 0x0; | |
232 | if(fTiming) time = new TStopwatch(); | |
233 | ||
234 | if(fTiming) time->Start(); | |
235 | for(mod=0;mod<klayers;mod++) nmods += kladders[mod]*kdetectors[mod]; | |
236 | geom->Init(kItype,klayers,kladders,kdetectors,nmods); | |
237 | ||
238 | for(mod=0; mod<nmods; mod++) { | |
239 | ||
240 | DecodeDetectorLayers(mod,lay,lad,det); | |
241 | geom->CreateMatrix(mod,lay,lad,det,kIdet[lay-1],tran,rot); | |
242 | RecodeDetector(mod,cpn0,cpn1,cpn2); | |
243 | ||
244 | if (kIdet[lay-1]==kSPD) { // we need 1 more copy number because of the half-stave | |
245 | if (det<3) cpnHS = 0; else cpnHS = 1; | |
246 | path.Form(kNames[lay-1].Data(),kPathbase.Data(),cpn0,cpn1,cpnHS,cpn2); | |
247 | } else { | |
248 | path.Form(kNames[lay-1].Data(),kPathbase.Data(),cpn0,cpn1,cpn2); | |
249 | }; | |
250 | ||
251 | geom->GetGeomMatrix(mod)->SetPath(path); | |
252 | GetTransformation(path.Data(),matrix); | |
253 | geom->SetTrans(mod,matrix.GetTranslation()); | |
254 | TransposeTGeoHMatrix(&matrix); //Transpose TGeo's rotation matrixes | |
255 | geom->SetRotMatrix(mod,matrix.GetRotationMatrix()); | |
256 | if(initSeg[kIdet[lay-1]]) continue; | |
257 | GetShape(path,shapeName,shapePar); | |
258 | if(shapeName.CompareTo("BOX")){ | |
259 | Error("InitITSgeom","Geometry changed without proper code update" | |
260 | "or error in reading geometry. Shape is not BOX."); | |
261 | return kFALSE; | |
262 | } // end if | |
263 | } // end for module | |
264 | ||
265 | if(fTiming){ | |
266 | time->Stop(); | |
267 | time->Print(); | |
268 | delete time; | |
269 | } // end if | |
270 | return kTRUE; | |
271 | } | |
272 | //______________________________________________________________________ | |
451f5018 | 273 | Bool_t AliITSUInitGeometry::InitAliITSgeomVUpgrade(AliITSgeom *geom){ |
29998a6e | 274 | // Initilizes the geometry transformation class AliITSgeom |
275 | // Now that the segmentation is part of AliITSgeom, the detector | |
276 | // segmentations are also defined here. | |
277 | // | |
278 | // Inputs: | |
279 | // AliITSgeom *geom A pointer to the AliITSgeom class | |
280 | // Outputs: | |
281 | // AliITSgeom *geom This pointer recreated and properly inilized. | |
282 | // LG | |
283 | ||
284 | const Int_t kItype = 0; // Type of transformation defined 0=> Geant | |
285 | const Int_t klayers = GetNumberOfLayers(); // Number of layers in the ITS | |
4cddfe15 | 286 | const AliITSDetector kIdet = AliITSDetector(0); //kUPG; RS temporary |
29998a6e | 287 | if (klayers <= 0) { |
288 | AliError("No layers found in ITSV"); | |
289 | return kFALSE; | |
290 | } | |
291 | ||
292 | Int_t *kladders = new Int_t[klayers]; // Number of ladders | |
293 | Int_t *kdetectors = new Int_t[klayers]; // Number of detectors/ladder | |
294 | ||
295 | for (Int_t j=0; j<klayers; j++) { | |
296 | kladders[j] = GetNumberOfLadders(j); | |
297 | kdetectors[j] = GetNumberOfModules(j); | |
298 | } | |
451f5018 | 299 | const TString kPathBase = Form("/ALIC_1/%s_1/",AliITSUGeomTGeo::GetITSVolPattern()); |
535d15f5 | 300 | const TString kNames = Form("%%s%s%%d_1/%s%%d_%%d/%s%%d_%%d/%s%%d_%%d" |
451f5018 | 301 | ,AliITSUGeomTGeo::GetITSLayerPattern() |
302 | ,AliITSUGeomTGeo::GetITSLadderPattern() | |
303 | ,AliITSUGeomTGeo::GetITSModulePattern() | |
304 | ,AliITSUGeomTGeo::GetITSSensorPattern() | |
535d15f5 | 305 | ); |
29998a6e | 306 | Int_t mod,nmods=0, lay, lad, det, cpn0, cpn1, cpn2; |
307 | Double_t tran[3]={0.,0.,0.}, rot[10]={9*0.0,1.0}; | |
308 | TArrayD shapePar; | |
309 | TString path, shapeName; | |
310 | TGeoHMatrix matrix; | |
e409171b | 311 | // Bool_t initSeg[3]={kFALSE, kFALSE, kFALSE}; |
29998a6e | 312 | TStopwatch *time = 0x0; |
313 | if(fTiming) time = new TStopwatch(); | |
314 | ||
315 | if(fTiming) time->Start(); | |
316 | for(mod=0;mod<klayers;mod++) nmods += kladders[mod]*kdetectors[mod]; | |
317 | geom->Init(kItype,klayers,kladders,kdetectors,nmods); | |
318 | ||
319 | for(mod=0; mod<nmods; mod++) { | |
320 | ||
321 | DecodeDetectorLayers(mod,lay,lad,det); | |
322 | geom->CreateMatrix(mod,lay,lad,det,kIdet,tran,rot); | |
323 | RecodeDetector(mod,cpn0,cpn1,cpn2); | |
324 | ||
535d15f5 | 325 | path.Form(kNames.Data(),kPathBase.Data(),lay,lay,cpn0,lay,cpn1,lay,cpn2); |
29998a6e | 326 | |
327 | geom->GetGeomMatrix(mod)->SetPath(path); | |
328 | GetTransformation(path.Data(),matrix); | |
329 | geom->SetTrans(mod,matrix.GetTranslation()); | |
330 | TransposeTGeoHMatrix(&matrix); //Transpose TGeo's rotation matrixes | |
331 | geom->SetRotMatrix(mod,matrix.GetRotationMatrix()); | |
332 | // if(initSeg[kIdet[lay-1]]) continue; | |
29998a6e | 333 | GetShape(path,shapeName,shapePar); |
334 | if(shapeName.CompareTo("BOX")){ | |
335 | Error("InitITSgeom","Geometry changed without proper code update" | |
336 | "or error in reading geometry. Shape is not BOX."); | |
337 | return kFALSE; | |
338 | } // end if | |
339 | } // end for module | |
340 | ||
341 | if(fTiming){ | |
342 | time->Stop(); | |
343 | time->Print(); | |
344 | delete time; | |
345 | } // end if | |
346 | return kTRUE; | |
347 | } | |
348 | ||
349 | //_______________________________________________________________________ | |
451f5018 | 350 | Bool_t AliITSUInitGeometry::GetTransformation(const TString &volumePath, |
29998a6e | 351 | TGeoHMatrix &mat){ |
352 | // Returns the Transformation matrix between the volume specified | |
353 | // by the path volumePath and the Top or mater volume. The format | |
354 | // of the path volumePath is as follows (assuming ALIC is the Top volume) | |
355 | // "/ALIC_1/DDIP_1/S05I_2/S05H_1/S05G_3". Here ALIC is the top most | |
356 | // or master volume which has only 1 instance of. Of all of the daughter | |
357 | // volumes of ALICE, DDIP volume copy #1 is indicated. Similarly for | |
358 | // the daughter volume of DDIP is S05I copy #2 and so on. | |
359 | // Inputs: | |
360 | // TString& volumePath The volume path to the specific volume | |
361 | // for which you want the matrix. Volume name | |
362 | // hierarchy is separated by "/" while the | |
363 | // copy number is appended using a "_". | |
364 | // Outputs: | |
365 | // TGeoHMatrix &mat A matrix with its values set to those | |
366 | // appropriate to the Local to Master transformation | |
367 | // Return: | |
368 | // A logical value if kFALSE then an error occurred and no change to | |
369 | // mat was made. | |
370 | ||
371 | // We have to preserve the modeler state | |
372 | ||
373 | // Preserve the modeler state. | |
374 | gGeoManager->PushPath(); | |
375 | if (!gGeoManager->cd(volumePath.Data())) { | |
376 | gGeoManager->PopPath(); | |
377 | Error("GetTransformation","Error in cd-ing to %s",volumePath.Data()); | |
378 | return kFALSE; | |
379 | } // end if !gGeoManager | |
380 | mat = *gGeoManager->GetCurrentMatrix(); | |
381 | // Retstore the modeler state. | |
382 | gGeoManager->PopPath(); | |
383 | return kTRUE; | |
384 | } | |
385 | //______________________________________________________________________ | |
451f5018 | 386 | Bool_t AliITSUInitGeometry::GetShape(const TString &volumePath, |
29998a6e | 387 | TString &shapeType,TArrayD &par){ |
388 | // Returns the shape and its parameters for the volume specified | |
389 | // by volumeName. | |
390 | // Inputs: | |
391 | // TString& volumeName The volume name | |
392 | // Outputs: | |
393 | // TString &shapeType Shape type | |
394 | // TArrayD &par A TArrayD of parameters with all of the | |
395 | // parameters of the specified shape. | |
396 | // Return: | |
397 | // A logical indicating whether there was an error in getting this | |
398 | // information | |
399 | Int_t npar; | |
400 | gGeoManager->PushPath(); | |
401 | if (!gGeoManager->cd(volumePath.Data())) { | |
402 | gGeoManager->PopPath(); | |
403 | return kFALSE; | |
404 | } | |
405 | TGeoVolume * vol = gGeoManager->GetCurrentVolume(); | |
406 | gGeoManager->PopPath(); | |
407 | if (!vol) return kFALSE; | |
408 | TGeoShape *shape = vol->GetShape(); | |
409 | TClass *classType = shape->IsA(); | |
410 | if (classType==TGeoBBox::Class()) { | |
411 | shapeType = "BOX"; | |
412 | npar = 3; | |
413 | par.Set(npar); | |
414 | TGeoBBox *box = (TGeoBBox*)shape; | |
415 | par.AddAt(box->GetDX(),0); | |
416 | par.AddAt(box->GetDY(),1); | |
417 | par.AddAt(box->GetDZ(),2); | |
418 | return kTRUE; | |
419 | } // end if | |
420 | if (classType==TGeoTrd1::Class()) { | |
421 | shapeType = "TRD1"; | |
422 | npar = 4; | |
423 | par.Set(npar); | |
424 | TGeoTrd1 *trd1 = (TGeoTrd1*)shape; | |
425 | par.AddAt(trd1->GetDx1(),0); | |
426 | par.AddAt(trd1->GetDx2(),1); | |
427 | par.AddAt(trd1->GetDy(), 2); | |
428 | par.AddAt(trd1->GetDz(), 3); | |
429 | return kTRUE; | |
430 | } // end if | |
431 | if (classType==TGeoTrd2::Class()) { | |
432 | shapeType = "TRD2"; | |
433 | npar = 5; | |
434 | par.Set(npar); | |
435 | TGeoTrd2 *trd2 = (TGeoTrd2*)shape; | |
436 | par.AddAt(trd2->GetDx1(),0); | |
437 | par.AddAt(trd2->GetDx2(),1); | |
438 | par.AddAt(trd2->GetDy1(),2); | |
439 | par.AddAt(trd2->GetDy2(),3); | |
440 | par.AddAt(trd2->GetDz(), 4); | |
441 | return kTRUE; | |
442 | } // end if | |
443 | if (classType==TGeoTrap::Class()) { | |
444 | shapeType = "TRAP"; | |
445 | npar = 11; | |
446 | par.Set(npar); | |
447 | TGeoTrap *trap = (TGeoTrap*)shape; | |
448 | Double_t tth = TMath::Tan(trap->GetTheta()*TMath::DegToRad()); | |
449 | par.AddAt(trap->GetDz(),0); | |
450 | par.AddAt(tth*TMath::Cos(trap->GetPhi()*TMath::DegToRad()),1); | |
451 | par.AddAt(tth*TMath::Sin(trap->GetPhi()*TMath::DegToRad()),2); | |
452 | par.AddAt(trap->GetH1(),3); | |
453 | par.AddAt(trap->GetBl1(),4); | |
454 | par.AddAt(trap->GetTl1(),5); | |
455 | par.AddAt(TMath::Tan(trap->GetAlpha1()*TMath::DegToRad()),6); | |
456 | par.AddAt(trap->GetH2(),7); | |
457 | par.AddAt(trap->GetBl2(),8); | |
458 | par.AddAt(trap->GetTl2(),9); | |
459 | par.AddAt(TMath::Tan(trap->GetAlpha2()*TMath::DegToRad()),10); | |
460 | return kTRUE; | |
461 | } // end if | |
462 | if (classType==TGeoTube::Class()) { | |
463 | shapeType = "TUBE"; | |
464 | npar = 3; | |
465 | par.Set(npar); | |
466 | TGeoTube *tube = (TGeoTube*)shape; | |
467 | par.AddAt(tube->GetRmin(),0); | |
468 | par.AddAt(tube->GetRmax(),1); | |
469 | par.AddAt(tube->GetDz(),2); | |
470 | return kTRUE; | |
471 | } // end if | |
472 | if (classType==TGeoTubeSeg::Class()) { | |
473 | shapeType = "TUBS"; | |
474 | npar = 5; | |
475 | par.Set(npar); | |
476 | TGeoTubeSeg *tubs = (TGeoTubeSeg*)shape; | |
477 | par.AddAt(tubs->GetRmin(),0); | |
478 | par.AddAt(tubs->GetRmax(),1); | |
479 | par.AddAt(tubs->GetDz(),2); | |
480 | par.AddAt(tubs->GetPhi1(),3); | |
481 | par.AddAt(tubs->GetPhi2(),4); | |
482 | return kTRUE; | |
483 | } // end if | |
484 | if (classType==TGeoCone::Class()) { | |
485 | shapeType = "CONE"; | |
486 | npar = 5; | |
487 | par.Set(npar); | |
488 | TGeoCone *cone = (TGeoCone*)shape; | |
489 | par.AddAt(cone->GetDz(),0); | |
490 | par.AddAt(cone->GetRmin1(),1); | |
491 | par.AddAt(cone->GetRmax1(),2); | |
492 | par.AddAt(cone->GetRmin2(),3); | |
493 | par.AddAt(cone->GetRmax2(),4); | |
494 | return kTRUE; | |
495 | } // end if | |
496 | if (classType==TGeoConeSeg::Class()) { | |
497 | shapeType = "CONS"; | |
498 | npar = 7; | |
499 | par.Set(npar); | |
500 | TGeoConeSeg *cons = (TGeoConeSeg*)shape; | |
501 | par.AddAt(cons->GetDz(),0); | |
502 | par.AddAt(cons->GetRmin1(),1); | |
503 | par.AddAt(cons->GetRmax1(),2); | |
504 | par.AddAt(cons->GetRmin2(),3); | |
505 | par.AddAt(cons->GetRmax2(),4); | |
506 | par.AddAt(cons->GetPhi1(),5); | |
507 | par.AddAt(cons->GetPhi2(),6); | |
508 | return kTRUE; | |
509 | } // end if | |
510 | if (classType==TGeoSphere::Class()) { | |
511 | shapeType = "SPHE"; | |
512 | npar = 6; | |
513 | par.Set(npar); | |
514 | ||
515 | TGeoSphere *sphe = (TGeoSphere*)shape; | |
516 | par.AddAt(sphe->GetRmin(),0); | |
517 | par.AddAt(sphe->GetRmax(),1); | |
518 | par.AddAt(sphe->GetTheta1(),2); | |
519 | par.AddAt(sphe->GetTheta2(),3); | |
520 | par.AddAt(sphe->GetPhi1(),4); | |
521 | par.AddAt(sphe->GetPhi2(),5); | |
522 | return kTRUE; | |
523 | } // end if | |
524 | if (classType==TGeoPara::Class()) { | |
525 | shapeType = "PARA"; | |
526 | npar = 6; | |
527 | par.Set(npar); | |
528 | TGeoPara *para = (TGeoPara*)shape; | |
529 | par.AddAt(para->GetX(),0); | |
530 | par.AddAt(para->GetY(),1); | |
531 | par.AddAt(para->GetZ(),2); | |
532 | par.AddAt(para->GetTxy(),3); | |
533 | par.AddAt(para->GetTxz(),4); | |
534 | par.AddAt(para->GetTyz(),5); | |
535 | return kTRUE; | |
536 | } // end if | |
537 | if (classType==TGeoPgon::Class()) { | |
538 | shapeType = "PGON"; | |
539 | TGeoPgon *pgon = (TGeoPgon*)shape; | |
540 | Int_t nz = pgon->GetNz(); | |
541 | const Double_t *rmin = pgon->GetRmin(); | |
542 | const Double_t *rmax = pgon->GetRmax(); | |
543 | const Double_t *z = pgon->GetZ(); | |
544 | npar = 4 + 3*nz; | |
545 | par.Set(npar); | |
546 | par.AddAt(pgon->GetPhi1(),0); | |
547 | par.AddAt(pgon->GetDphi(),1); | |
548 | par.AddAt(pgon->GetNedges(),2); | |
549 | par.AddAt(pgon->GetNz(),3); | |
550 | for (Int_t i=0; i<nz; i++) { | |
551 | par.AddAt(z[i], 4+3*i); | |
552 | par.AddAt(rmin[i], 4+3*i+1); | |
553 | par.AddAt(rmax[i], 4+3*i+2); | |
554 | } | |
555 | return kTRUE; | |
556 | } // end if | |
557 | if (classType==TGeoPcon::Class()) { | |
558 | shapeType = "PCON"; | |
559 | TGeoPcon *pcon = (TGeoPcon*)shape; | |
560 | Int_t nz = pcon->GetNz(); | |
561 | const Double_t *rmin = pcon->GetRmin(); | |
562 | const Double_t *rmax = pcon->GetRmax(); | |
563 | const Double_t *z = pcon->GetZ(); | |
564 | npar = 3 + 3*nz; | |
565 | par.Set(npar); | |
566 | par.AddAt(pcon->GetPhi1(),0); | |
567 | par.AddAt(pcon->GetDphi(),1); | |
568 | par.AddAt(pcon->GetNz(),2); | |
569 | for (Int_t i=0; i<nz; i++) { | |
570 | par.AddAt(z[i], 3+3*i); | |
571 | ||
572 | par.AddAt(rmin[i], 3+3*i+1); | |
573 | par.AddAt(rmax[i], 3+3*i+2); | |
574 | } | |
575 | return kTRUE; | |
576 | } // end if | |
577 | if (classType==TGeoEltu::Class()) { | |
578 | shapeType = "ELTU"; | |
579 | npar = 3; | |
580 | par.Set(npar); | |
581 | TGeoEltu *eltu = (TGeoEltu*)shape; | |
582 | par.AddAt(eltu->GetA(),0); | |
583 | par.AddAt(eltu->GetB(),1); | |
584 | par.AddAt(eltu->GetDz(),2); | |
585 | return kTRUE; | |
586 | } // end if | |
587 | if (classType==TGeoHype::Class()) { | |
588 | shapeType = "HYPE"; | |
589 | npar = 5; | |
590 | par.Set(npar); | |
591 | TGeoHype *hype = (TGeoHype*)shape; | |
592 | par.AddAt(TMath::Sqrt(hype->RadiusHypeSq(0.,kTRUE)),0); | |
593 | par.AddAt(TMath::Sqrt(hype->RadiusHypeSq(0.,kFALSE)),1); | |
594 | par.AddAt(hype->GetDZ(),2); | |
595 | par.AddAt(hype->GetStIn(),3); | |
596 | par.AddAt(hype->GetStOut(),4); | |
597 | return kTRUE; | |
598 | } // end if | |
599 | if (classType==TGeoGtra::Class()) { | |
600 | shapeType = "GTRA"; | |
601 | npar = 12; | |
602 | par.Set(npar); | |
603 | TGeoGtra *trap = (TGeoGtra*)shape; | |
604 | Double_t tth = TMath::Tan(trap->GetTheta()*TMath::DegToRad()); | |
605 | par.AddAt(trap->GetDz(),0); | |
606 | par.AddAt(tth*TMath::Cos(trap->GetPhi()*TMath::DegToRad()),1); | |
607 | par.AddAt(tth*TMath::Sin(trap->GetPhi()*TMath::DegToRad()),2); | |
608 | par.AddAt(trap->GetH1(),3); | |
609 | par.AddAt(trap->GetBl1(),4); | |
610 | par.AddAt(trap->GetTl1(),5); | |
611 | par.AddAt(TMath::Tan(trap->GetAlpha1()*TMath::DegToRad()),6); | |
612 | par.AddAt(trap->GetH2(),7); | |
613 | par.AddAt(trap->GetBl2(),8); | |
614 | par.AddAt(trap->GetTl2(),9); | |
615 | par.AddAt(TMath::Tan(trap->GetAlpha2()*TMath::DegToRad()),10); | |
616 | par.AddAt(trap->GetTwistAngle(),11); | |
617 | return kTRUE; | |
618 | } // end if | |
619 | if (classType==TGeoCtub::Class()) { | |
620 | shapeType = "CTUB"; | |
621 | npar = 11; | |
622 | par.Set(npar); | |
623 | TGeoCtub *ctub = (TGeoCtub*)shape; | |
624 | const Double_t *lx = ctub->GetNlow(); | |
625 | const Double_t *tx = ctub->GetNhigh(); | |
626 | par.AddAt(ctub->GetRmin(),0); | |
627 | par.AddAt(ctub->GetRmax(),1); | |
628 | par.AddAt(ctub->GetDz(),2); | |
629 | par.AddAt(ctub->GetPhi1(),3); | |
630 | par.AddAt(ctub->GetPhi2(),4); | |
631 | par.AddAt(lx[0],5); | |
632 | par.AddAt(lx[1],6); | |
633 | par.AddAt(lx[2],7); | |
634 | par.AddAt(tx[0],8); | |
635 | par.AddAt(tx[1],9); | |
636 | par.AddAt(tx[2],10); | |
637 | return kTRUE; | |
638 | } // end if | |
639 | Error("GetShape","Getting shape parameters for shape %s not implemented", | |
640 | shape->ClassName()); | |
641 | shapeType = "Unknown"; | |
642 | return kFALSE; | |
643 | } | |
644 | //______________________________________________________________________ | |
451f5018 | 645 | void AliITSUInitGeometry::DecodeDetector( |
29998a6e | 646 | Int_t &mod,Int_t layer,Int_t cpn0,Int_t cpn1,Int_t cpn2) const { |
647 | // decode geometry into detector module number. There are two decoding | |
648 | // Scheams. Old which does not follow the ALICE coordinate system | |
649 | // requirements, and New which dose. | |
650 | // Inputs: | |
651 | // Int_t layer The ITS layer | |
652 | // Int_t cpn0 The lowest copy number | |
653 | // Int_t cpn1 The middle copy number | |
654 | // Int_t cpn2 the highest copy number | |
655 | // Output: | |
656 | // Int_t &mod The module number assoicated with this set | |
657 | // of copy numbers. | |
658 | // Return: | |
659 | // none. | |
660 | ||
661 | // This is a FIXED switch yard function. I (Bjorn Nilsen) Don't | |
662 | // like them but I see not better way for the moment. | |
663 | switch (fMajorVersion){ | |
664 | case kvDefault:{ | |
665 | Error("DecodeDetector","Major version = kvDefault, not supported"); | |
666 | }break; | |
667 | case kv11:{ | |
668 | return DecodeDetectorv11(mod,layer,cpn0,cpn1,cpn2); | |
669 | }break; | |
670 | case kvUpgrade:{ | |
671 | return DecodeDetectorvUpgrade(mod,layer,cpn0,cpn1,cpn2); | |
672 | }break; | |
673 | default:{ | |
674 | Error("DecodeDetector","Major version = %d, not supported", | |
675 | (Int_t)fMajorVersion); | |
676 | return; | |
677 | }break; | |
678 | } // end switch | |
679 | return; | |
680 | } | |
681 | //______________________________________________________________________ | |
451f5018 | 682 | void AliITSUInitGeometry::RecodeDetector(Int_t mod,Int_t &cpn0, |
29998a6e | 683 | Int_t &cpn1,Int_t &cpn2){ |
684 | // decode geometry into detector module number. There are two decoding | |
685 | // Scheams. Old which does not follow the ALICE coordinate system | |
686 | // requirements, and New which dose. | |
687 | // Inputs: | |
688 | // Int_t mod The module number assoicated with this set | |
689 | // of copy numbers. | |
690 | // Output: | |
691 | // Int_t cpn0 The lowest copy number | |
692 | // Int_t cpn1 The middle copy number | |
693 | // Int_t cpn2 the highest copy number | |
694 | // Return: | |
695 | // none. | |
696 | ||
697 | // This is a FIXED switch yard function. I (Bjorn Nilsen) Don't | |
698 | // like them but I see not better way for the moment. | |
699 | switch (fMajorVersion){ | |
700 | case kvDefault:{ | |
701 | Error("RecodeDetector","Major version = kvDefault, not supported"); | |
702 | return; | |
703 | } | |
704 | case kv11:{ | |
705 | return RecodeDetectorv11(mod,cpn0,cpn1,cpn2); | |
706 | }break; | |
707 | case kvUpgrade:{ | |
708 | return RecodeDetectorvUpgrade(mod,cpn0,cpn1,cpn2); | |
709 | }break; | |
710 | default:{ | |
711 | Error("RecodeDetector","Major version = %d, not supported", | |
712 | (Int_t)fMajorVersion); | |
713 | return; | |
714 | }break; | |
715 | } // end switch | |
716 | return; | |
717 | } | |
718 | //______________________________________________________________________ | |
451f5018 | 719 | void AliITSUInitGeometry::DecodeDetectorLayers(Int_t mod,Int_t &layer, |
29998a6e | 720 | Int_t &lad,Int_t &det){ |
721 | // decode geometry into detector module number. There are two decoding | |
722 | // Scheams. Old which does not follow the ALICE coordinate system | |
723 | // requirements, and New which dose. Note, this use of layer ladder | |
724 | // and detector numbers are strictly for internal use of this | |
725 | // specific code. They do not represent the "standard" layer ladder | |
726 | // or detector numbering except in a very old and obsoleate sence. | |
727 | // Inputs: | |
728 | // Int_t mod The module number assoicated with this set | |
729 | // of copy numbers. | |
730 | // Output: | |
731 | // Int_t lay The layer number | |
732 | // Int_t lad The ladder number | |
733 | // Int_t det the dettector number | |
734 | // Return: | |
735 | // none. | |
736 | ||
737 | // This is a FIXED switch yard function. I (Bjorn Nilsen) Don't | |
738 | // like them but I see not better way for the moment. | |
739 | switch (fMajorVersion) { | |
740 | case kvDefault:{ | |
741 | Error("DecodeDetectorLayers", | |
742 | "Major version = kvDefault, not supported"); | |
743 | return; | |
744 | }break; | |
745 | case kv11:{ | |
746 | return DecodeDetectorLayersv11(mod,layer,lad,det); | |
747 | }break; | |
748 | case kvUpgrade:{ | |
749 | return DecodeDetectorLayersvUpgrade(mod,layer,lad,det); | |
750 | }break; | |
751 | default:{ | |
752 | Error("DecodeDetectorLayers","Major version = %d, not supported", | |
753 | (Int_t)fMajorVersion); | |
754 | return; | |
755 | }break; | |
756 | } // end switch | |
757 | return; | |
758 | } | |
759 | ||
760 | //______________________________________________________________________ | |
451f5018 | 761 | void AliITSUInitGeometry::DecodeDetectorv11(Int_t &mod,Int_t layer, |
29998a6e | 762 | Int_t cpn0,Int_t cpn1,Int_t cpn2) const { |
763 | // decode geometry into detector module number | |
764 | // Inputs: | |
765 | // Int_t layer The ITS layer | |
766 | // Int_t cpn0 The lowest copy number | |
767 | // Int_t cpn1 The middle copy number | |
768 | // Int_t cpn2 the highest copy number | |
769 | // Output: | |
770 | // Int_t &mod The module number assoicated with this set | |
771 | // of copy numbers. | |
772 | // Return: | |
773 | // none. | |
774 | const Int_t kDetPerLadderSPD[2]={2,4}; | |
775 | const Int_t kDetPerLadder[6]={4,4,6,8,22,25}; | |
776 | const Int_t kLadPerLayer[6]={20,40,14,22,34,38}; | |
777 | Int_t lad=-1,det=-1; | |
778 | ||
779 | switch(layer) { | |
780 | case 1: case 2:{ | |
781 | lad = cpn1+kDetPerLadderSPD[layer-1]*(cpn0-1); | |
782 | det = cpn2; | |
783 | } break; | |
784 | case 3: case 4:{ | |
785 | lad = cpn0+1; | |
786 | det = cpn1+1; | |
787 | } break; | |
788 | case 5: case 6:{ | |
789 | lad = cpn0+1; | |
790 | det = cpn1+1; | |
791 | } break; | |
792 | default:{ | |
793 | } break; | |
794 | } // end switch | |
795 | mod = 0; | |
796 | for(Int_t i=0;i<layer-1;i++) mod += kLadPerLayer[i]*kDetPerLadder[i]; | |
797 | mod += kDetPerLadder[layer-1]*(lad-1)+det-1;// module start at zero. | |
798 | return; | |
799 | } | |
800 | ||
801 | //______________________________________________________________________ | |
451f5018 | 802 | void AliITSUInitGeometry::DecodeDetectorvUpgrade(Int_t &mod,Int_t layer, |
e409171b | 803 | Int_t cpn0,Int_t cpn1,Int_t /*cpn2*/) const { |
29998a6e | 804 | // decode geometry into detector module number |
805 | // Inputs: | |
806 | // Int_t layer The ITS layer | |
807 | // Int_t cpn0 The lowest copy number | |
808 | // Int_t cpn1 The middle copy number | |
809 | // Int_t cpn2 the highest copy number | |
810 | // Output: | |
811 | // Int_t &mod The module number assoicated with this set | |
812 | // of copy numbers. | |
813 | // Return: | |
814 | // none. | |
815 | // MS 23jun11 | |
816 | Int_t lad=-1,det=-1; | |
840da413 | 817 | layer--; // starts from 1! |
29998a6e | 818 | lad = cpn0; |
819 | det = cpn1; | |
820 | mod = 0; | |
821 | for(Int_t i=0;i<layer;i++) mod += GetNumberOfLadders(i)*GetNumberOfModules(i); | |
822 | mod += GetNumberOfModules(layer)*(lad-1)+det-1;// module start at zero. | |
823 | return; | |
824 | } | |
825 | ||
826 | //______________________________________________________________________ | |
451f5018 | 827 | void AliITSUInitGeometry::RecodeDetectorv11(Int_t mod,Int_t &cpn0, |
29998a6e | 828 | Int_t &cpn1,Int_t &cpn2) { |
829 | // decode geometry into detector module number using the new decoding | |
830 | // Scheme. | |
831 | // Inputs: | |
832 | // Int_t mod The module number assoicated with this set | |
833 | // of copy numbers. | |
834 | // Output: | |
835 | // Int_t cpn0 The lowest copy number (SPD sector or SDD/SSD ladder) | |
836 | // Int_t cpn1 The middle copy number (SPD stave or SDD/SSD module) | |
837 | // Int_t cpn2 the highest copy number (SPD ladder or 1 for SDD/SSD) | |
838 | // Return: | |
839 | // none. | |
840 | const Int_t kDetPerLadderSPD[2]={2,4}; | |
841 | Int_t lay,lad,det; | |
842 | ||
843 | DecodeDetectorLayersv11(mod,lay,lad,det); | |
844 | if (lay<3) { // SPD | |
845 | cpn2 = det; // Detector 1-4 | |
846 | cpn0 = (lad+kDetPerLadderSPD[lay-1]-1)/kDetPerLadderSPD[lay-1]; | |
847 | cpn1 = (lad+kDetPerLadderSPD[lay-1]-1)%kDetPerLadderSPD[lay-1] + 1; | |
848 | } else { // SDD and SSD | |
849 | cpn2 = 1; | |
850 | cpn1 = det; | |
851 | cpn0 = lad; | |
852 | if (lay<5) { // SDD | |
853 | cpn1--; | |
854 | cpn0--; | |
855 | } else { //SSD | |
856 | cpn1--; | |
857 | cpn0--; | |
858 | } // end if Lay<5/else | |
859 | } // end if lay<3/else | |
451f5018 | 860 | /*printf("AliITSUInitGeometry::RecodeDetectorv11:" |
29998a6e | 861 | "mod=%d lay=%d lad=%d det=%d cpn0=%d cpn1=%d cpn2=%d\n", |
862 | mod,lay,lad,det,cpn0,cpn1,cpn2);*/ | |
863 | } | |
864 | ||
865 | //______________________________________________________________________ | |
451f5018 | 866 | void AliITSUInitGeometry::RecodeDetectorvUpgrade(Int_t mod,Int_t &cpn0, |
29998a6e | 867 | Int_t &cpn1,Int_t &cpn2) { |
868 | // decode geometry into detector module number using the new decoding | |
869 | // Scheme. | |
870 | // Inputs: | |
871 | // Int_t mod The module number assoicated with this set | |
872 | // of copy numbers. | |
873 | // Output: | |
874 | // Int_t cpn0 The lowest copy number (ladder) | |
875 | // Int_t cpn1 The middle copy number (module) | |
876 | // Int_t cpn2 the highest copy number (sensor - always 1 for now) | |
877 | // Return: | |
878 | // none. | |
879 | // MS - 23jun11 - cross your fingers and hope for the best | |
880 | Int_t lay,lad,det; | |
881 | ||
882 | DecodeDetectorLayersvUpgrade(mod,lay,lad,det); | |
883 | cpn2 = 1; | |
884 | cpn1 = det; | |
885 | cpn0 = lad; | |
886 | // cpn1--; | |
887 | // cpn0--; | |
451f5018 | 888 | /*printf("AliITSUInitGeometry::RecodeDetectorv11:" |
29998a6e | 889 | "mod=%d lay=%d lad=%d det=%d cpn0=%d cpn1=%d cpn2=%d\n", |
890 | mod,lay,lad,det,cpn0,cpn1,cpn2);*/ | |
891 | } | |
892 | ||
893 | //______________________________________________________________________ | |
451f5018 | 894 | void AliITSUInitGeometry::DecodeDetectorLayersv11(Int_t mod,Int_t &lay, |
29998a6e | 895 | Int_t &lad,Int_t &det) { |
896 | ||
897 | // decode module number into detector indices for v11 | |
898 | // mod starts from 0 | |
899 | // lay, lad, det start from 1 | |
900 | ||
901 | // Inputs: | |
902 | // Int_t mod The module number associated with this set | |
903 | // of copy numbers. | |
904 | // Output: | |
905 | // Int_t lay The layer number | |
906 | // Int_t lad The ladder number | |
907 | // Int_t det the dettector number | |
908 | ||
909 | const Int_t kDetPerLadder[6] = {4,4,6,8,22,25}; | |
910 | const Int_t kLadPerLayer[6] = {20,40,14,22,34,38}; | |
911 | ||
912 | Int_t mod2 = 0; | |
913 | lay = 0; | |
914 | ||
915 | do { | |
916 | mod2 += kLadPerLayer[lay]*kDetPerLadder[lay]; | |
917 | lay++; | |
918 | } while(mod2<=mod); // end while | |
919 | if(lay>6) Error("DecodeDetectorLayers","lay=%d>6",lay); | |
920 | ||
921 | mod2 = kLadPerLayer[lay-1]*kDetPerLadder[lay-1] - mod2+mod; | |
922 | lad = mod2/kDetPerLadder[lay-1]; | |
923 | ||
924 | if(lad>=kLadPerLayer[lay-1]||lad<0) Error("DecodeDetectorLayers", | |
925 | "lad=%d not in the correct range",lad); | |
926 | det = (mod2 - lad*kDetPerLadder[lay-1])+1; | |
927 | if(det>kDetPerLadder[lay-1]||det<1) Error("DecodeDetectorLayers", | |
928 | "det=%d not in the correct range",det); | |
929 | lad++; | |
930 | } | |
931 | ||
932 | //______________________________________________________________________ | |
451f5018 | 933 | void AliITSUInitGeometry::DecodeDetectorLayersvUpgrade(Int_t mod,Int_t &lay, |
29998a6e | 934 | Int_t &lad,Int_t &det){ |
935 | ||
936 | // decode module number into detector indices for vUpgrade | |
937 | // mod starts from 0 | |
938 | // lay, lad, det start from 1 | |
939 | ||
940 | // Inputs: | |
941 | // Int_t mod The module number associated with this set | |
942 | // of copy numbers. | |
943 | // Output: | |
944 | // Int_t lay The layer number | |
945 | // Int_t lad The ladder number | |
946 | // Int_t det the dettector number | |
947 | // MS - 22jun11 | |
948 | ||
949 | const Int_t kLayers = GetNumberOfLayers(); | |
950 | ||
951 | Int_t mod2 = 0; | |
952 | lay = 0; | |
953 | ||
954 | do { | |
955 | mod2 += GetNumberOfLadders(lay)*GetNumberOfModules(lay); | |
956 | lay++; | |
957 | } while(mod2<=mod); // end while | |
958 | if(lay>kLayers) Error("DecodeDetectorLayers","lay=%d>%d",lay,kLayers); | |
959 | ||
960 | mod2 = GetNumberOfLadders(lay-1)*GetNumberOfModules(lay-1) - mod2+mod; | |
961 | lad = mod2/GetNumberOfModules(lay-1); | |
962 | ||
963 | if(lad>=GetNumberOfLadders(lay-1)||lad<0) Error("DecodeDetectorLayers", | |
964 | "lad=%d not in the correct range",lad); | |
965 | det = (mod2 - lad*GetNumberOfModules(lay-1))+1; | |
966 | if(det>GetNumberOfModules(lay-1)||det<1) Error("DecodeDetectorLayers", | |
967 | ||
968 | "det=%d not in the correct range",det); | |
91fc36e5 | 969 | // lay--; |
29998a6e | 970 | lad++; |
971 | } | |
972 | ||
973 | //______________________________________________________________________ | |
451f5018 | 974 | Bool_t AliITSUInitGeometry::WriteVersionString(Char_t *str,Int_t length, |
29998a6e | 975 | AliITSVersion_t maj,Int_t min, |
976 | const Char_t *cvsDate,const Char_t *cvsRevision)const{ | |
977 | // fills the string str with the major and minor version number | |
978 | // Inputs: | |
979 | // Char_t *str The character string to hold the major | |
980 | // and minor version numbers in | |
981 | // Int_t length The maximum number of characters which | |
982 | // can be accomidated by this string. | |
983 | // str[length-1] must exist and will be set to zero | |
984 | // AliITSVersion_t maj The major number | |
985 | // Int_t min The minor number | |
986 | // Char_t *cvsDate The date string from cvs | |
987 | // Char_t *cvsRevision The Revision string from cvs | |
988 | // Outputs: | |
989 | // Char_t *str The character string holding the major and minor | |
990 | // version numbers. str[length-1] must exist | |
991 | // and will be set to zero | |
992 | // Return: | |
993 | // kTRUE if no errors | |
994 | Char_t cvslikedate[30]; | |
995 | Int_t i,n,cvsDateLength,cvsRevisionLength; | |
996 | ||
997 | cvsDateLength = (Int_t)strlen(cvsDate); | |
998 | if(cvsDateLength>30){ // svn string, make a cvs like string | |
999 | i=0;n=0; | |
1000 | do{ | |
1001 | cvslikedate[i] = cvsDate[i]; | |
1002 | if(cvsDate[i]=='+' || cvsDate[i++]=='-'){ | |
1003 | n++; // count number of - | |
1004 | cvslikedate[i-1] = '/'; // replace -'s by /'s. | |
1005 | } // end if | |
1006 | } while(n<3&&i<30); // once additonal - of time zone reach exit | |
1007 | cvslikedate[i-1] = '$'; // put $ at end then zero. | |
1008 | for(;i<30;i++) cvslikedate[i]=0;// i starts wher do loop left off. | |
1009 | }else{ | |
1010 | for(i=0;i<cvsDateLength&&i<30;i++) cvslikedate[i]=cvsDate[i]; | |
1011 | }// end if | |
1012 | cvsDateLength = (Int_t)strlen(cvslikedate); | |
1013 | cvsRevisionLength = (Int_t)strlen(cvsRevision); | |
1014 | i = (Int_t)maj; | |
1015 | n = 50+(Int_t)(TMath::Log10(TMath::Abs((Double_t)i)))+1+ | |
1016 | (Int_t)(TMath::Log10(TMath::Abs((Double_t)min)))+1 | |
1017 | +cvsDateLength-6+cvsRevisionLength-10; | |
451f5018 | 1018 | if(GetDebug()>1) printf("AliITSUInitGeometry::WriteVersionString:" |
29998a6e | 1019 | "length=%d major=%d minor=%d cvsDate=%s[%d] " |
1020 | "cvsRevision=%s[%d] n=%d\n",length,i,min,cvslikedate, | |
1021 | cvsDateLength,cvsRevision,cvsRevisionLength,n); | |
1022 | if(i<0) n++; | |
1023 | if(min<0) n++; | |
1024 | if(length<n){// not enough space to write in output string. | |
1025 | Warning("WriteVersionString","Output string not long enough " | |
1026 | "lenght=%d must be at least %d long\n",length,n); | |
1027 | return kFALSE; | |
1028 | } // end if length<n | |
1029 | char *cvsrevision = new char[cvsRevisionLength-10]; | |
1030 | char *cvsdate = new char[cvsDateLength-6]; | |
1031 | for(i=0;i<cvsRevisionLength-10;i++) | |
1032 | if(10+i<cvsRevisionLength-1) | |
1033 | cvsrevision[i] = cvsRevision[10+i]; else cvsrevision[i] = 0; | |
1034 | for(i=0;i<cvsDateLength-6;i++) if(6+i<cvsDateLength-1) | |
1035 | cvsdate[i] = cvslikedate[6+i]; else cvsdate[i] = 0; | |
1036 | for(i=0;i<length;i++) str[i] = 0; // zero it out for now. | |
1037 | i = (Int_t)maj; | |
1038 | snprintf(str,length-1,"Major Version= %d Minor Version= %d Revision: %s Date: %s",i,min,cvsrevision,cvsdate); | |
1039 | /* this gives compilation warnings on some compilers: descriptor zu | |
451f5018 | 1040 | if(GetDebug()>1)printf("AliITSUInitGeometry::WriteVersionString: " |
29998a6e | 1041 | "n=%d str=%s revision[%zu] date[%zu]\n", |
1042 | n,str,strlen(cvsrevision),strlen(cvsdate)); | |
1043 | */ | |
1044 | delete[] cvsrevision; | |
1045 | delete[] cvsdate; | |
1046 | return kTRUE; | |
1047 | } | |
1048 | //______________________________________________________________________ | |
451f5018 | 1049 | Bool_t AliITSUInitGeometry::ReadVersionString(const Char_t *str,Int_t length, |
29998a6e | 1050 | AliITSVersion_t &maj,Int_t &min, |
1051 | TDatime &dt)const{ | |
1052 | // fills the string str with the major and minor version number | |
1053 | // Inputs: | |
1054 | // Char_t *str The character string to holding the major and minor | |
1055 | // version numbers in | |
1056 | // Int_t length The maximum number of characters which can be | |
1057 | // accomidated by this string. str[length-1] must exist | |
1058 | // Outputs: | |
1059 | // Char_t *str The character string holding the major and minor | |
1060 | // version numbers unchanged. str[length-1] must exist. | |
1061 | // AliITSVersion_t maj The major number | |
1062 | // Int_t min The minor number | |
1063 | // TDatime dt The date and time of the cvs commit | |
1064 | // Return: | |
1065 | // kTRUE if no errors | |
1066 | Bool_t ok; | |
1067 | Char_t cvsRevision[10],cvsDate[11],cvsTime[9]; | |
1068 | Int_t i,m,n=strlen(str),year,month,day,hours,minuits,seconds; | |
1069 | memset(cvsRevision,0,10*sizeof(Char_t)); | |
1070 | memset(cvsDate,0,11*sizeof(Char_t)); | |
1071 | memset(cvsTime,0,9*sizeof(Char_t)); | |
1072 | ||
451f5018 | 1073 | if(GetDebug()>1)printf("AliITSUInitGeometry::ReadVersionString:" |
29998a6e | 1074 | "str=%s length=%d\n", |
1075 | str,length); | |
1076 | if(n<35) return kFALSE; // not enough space for numbers | |
1077 | m = sscanf(str,"Major Version= %d Minor Version= %d Revision: %9s " | |
1078 | "Date: %10s %8s",&i,&min,cvsRevision,cvsDate,cvsTime); | |
1079 | ok = m==5; | |
1080 | if(!ok) return !ok; | |
1081 | m = sscanf(cvsDate,"%d/%d/%d",&year,&month,&day); | |
1082 | ok = m==3; | |
1083 | if(!ok) return !ok; | |
1084 | m = sscanf(cvsTime,"%d:%d:%d",&hours,&minuits,&seconds); | |
1085 | ok = m==3; | |
1086 | if(!ok) return !ok; | |
1087 | dt.Set(year,month,day,hours,minuits,seconds); | |
451f5018 | 1088 | if(GetDebug()>1)printf("AliITSUInitGeometry::ReadVersionString: i=%d " |
29998a6e | 1089 | "min=%d cvsRevision=%s cvsDate=%s cvsTime=%s m=%d\n", |
1090 | i,min,cvsRevision,cvsDate,cvsTime,m); | |
451f5018 | 1091 | if(GetDebug()>1)printf("AliITSUInitGeometry::ReadVersionString: year=%d" |
29998a6e | 1092 | " month=%d day=%d hours=%d minuits=%d seconds=%d\n", |
1093 | year,month,day,hours,minuits,seconds); | |
1094 | switch (i){ | |
1095 | case kv11:{ | |
1096 | maj = kv11; | |
1097 | } break; | |
1098 | case kvUpgrade:{ | |
1099 | maj = kvUpgrade; | |
1100 | } break; | |
1101 | default:{ | |
1102 | maj = kvDefault; | |
1103 | } break; | |
1104 | } // end switch | |
1105 | return ok; | |
1106 | } | |
1107 | //______________________________________________________________________ | |
451f5018 | 1108 | Int_t AliITSUInitGeometry::GetNumberOfLayers(){ |
29998a6e | 1109 | // Determines the number of layers in the Upgrade Geometry |
1110 | // | |
1111 | // Inputs: | |
1112 | // none | |
1113 | // Outputs: | |
1114 | // none | |
1115 | // Return: | |
1116 | // the number of layers in the current geometry | |
1117 | // -1 if not Upgrade Geometry | |
1118 | // MS | |
1119 | ||
1120 | Int_t numberOfLayers = 0; | |
1121 | ||
1122 | if (fMajorVersion != kvUpgrade) { | |
1123 | AliError("Not Upgrade Geometry!"); | |
1124 | return -1; | |
1125 | } | |
1126 | ||
1127 | // This checks should be redundant, but let's do things neatly | |
1128 | if (!gGeoManager) { | |
1129 | AliError("gGeoManager is null"); | |
1130 | return 0; | |
1131 | } | |
1132 | ||
451f5018 | 1133 | if (!gGeoManager->GetVolume(AliITSUGeomTGeo::GetITSVolPattern())) { |
1134 | AliError(Form("can't find %s volume",AliITSUGeomTGeo::GetITSVolPattern())); | |
29998a6e | 1135 | return 0; |
1136 | } | |
1137 | ||
1138 | // Loop on all ITSV nodes, count Layer volumes by checking names | |
451f5018 | 1139 | Int_t nNodes = gGeoManager->GetVolume(AliITSUGeomTGeo::GetITSVolPattern())->GetNodes()->GetEntries(); |
29998a6e | 1140 | |
1141 | if (nNodes == 0) | |
1142 | return 0; | |
1143 | ||
1144 | for (Int_t j=0; j<nNodes; j++) | |
451f5018 | 1145 | if (strstr(gGeoManager->GetVolume(AliITSUGeomTGeo::GetITSVolPattern())->GetNodes()->At(j)->GetName(), |
1146 | AliITSUGeomTGeo::GetITSLayerPattern())) | |
29998a6e | 1147 | numberOfLayers++; |
1148 | ||
1149 | ||
1150 | return numberOfLayers; | |
1151 | } | |
535d15f5 | 1152 | |
29998a6e | 1153 | //______________________________________________________________________ |
451f5018 | 1154 | Int_t AliITSUInitGeometry::GetNumberOfLadders(const Int_t lay) const { |
29998a6e | 1155 | // Determines the number of layers in the Upgrade Geometry |
1156 | // | |
1157 | // Inputs: | |
1158 | // lay: layer number | |
1159 | // Outputs: | |
1160 | // none | |
1161 | // Return: | |
1162 | // the number of ladders in layer lay | |
1163 | // -1 if not Upgrade Geometry | |
1164 | // MS | |
1165 | ||
1166 | Int_t numberOfLadders = 0; | |
1167 | ||
1168 | if (fMajorVersion != kvUpgrade) { | |
1169 | AliError("Not Upgrade Geometry!"); | |
1170 | return -1; | |
1171 | } | |
1172 | ||
1173 | // This checks should be redundant, but let's do things neatly | |
1174 | if (!gGeoManager) { | |
1175 | AliError("gGeoManager is null"); | |
1176 | return 0; | |
1177 | } | |
1178 | ||
1179 | char laynam[15]; | |
451f5018 | 1180 | snprintf(laynam, 15, "%s%d", AliITSUGeomTGeo::GetITSLayerPattern(),lay+1); |
29998a6e | 1181 | if (!gGeoManager->GetVolume(laynam)) { |
1182 | AliError(Form("can't find %s volume",laynam)); | |
1183 | return 0; | |
1184 | } | |
1185 | ||
1186 | // Loop on all layer nodes, count Ladder volumes by checking names | |
1187 | Int_t nNodes = gGeoManager->GetVolume(laynam)->GetNodes()->GetEntries(); | |
1188 | ||
1189 | if (nNodes == 0) | |
1190 | return 0; | |
1191 | ||
1192 | for (Int_t j=0; j<nNodes; j++) | |
1193 | if (strstr(gGeoManager->GetVolume(laynam)->GetNodes()->At(j)->GetName(), | |
451f5018 | 1194 | AliITSUGeomTGeo::GetITSLadderPattern())) |
29998a6e | 1195 | numberOfLadders++; |
1196 | ||
1197 | ||
1198 | return numberOfLadders; | |
1199 | } | |
535d15f5 | 1200 | |
1201 | //______________________________________________________________________ | |
451f5018 | 1202 | Int_t AliITSUInitGeometry::GetLayerDetTypeID(const Int_t lay) const |
535d15f5 | 1203 | { |
1204 | // Determines the layers det. type in the Upgrade Geometry | |
1205 | // | |
1206 | // Inputs: | |
1207 | // lay: layer number | |
1208 | // Outputs: | |
1209 | // none | |
1210 | // Return: | |
1211 | // det id | |
1212 | // -1 if not Upgrade Geometry | |
1213 | // MS | |
1214 | ||
1215 | if (fMajorVersion != kvUpgrade) { | |
1216 | AliError("Not Upgrade Geometry!"); | |
1217 | return -1; | |
1218 | } | |
1219 | ||
1220 | // This checks should be redundant, but let's do things neatly | |
1221 | if (!gGeoManager) { | |
1222 | AliError("gGeoManager is null"); | |
1223 | return 0; | |
1224 | } | |
1225 | ||
1226 | char laynam[15]; | |
451f5018 | 1227 | snprintf(laynam, 15, "%s%d", AliITSUGeomTGeo::GetITSLayerPattern(),lay+1); |
535d15f5 | 1228 | TGeoVolume* volLr = gGeoManager->GetVolume(laynam); |
1229 | if (!volLr) { | |
1230 | AliError(Form("can't find %s volume",laynam)); | |
1231 | return -1; | |
1232 | } | |
1233 | // | |
1234 | return volLr->GetUniqueID(); | |
1235 | // | |
1236 | } | |
1237 | ||
29998a6e | 1238 | //______________________________________________________________________ |
451f5018 | 1239 | Int_t AliITSUInitGeometry::GetNumberOfModules(const Int_t lay) const { |
29998a6e | 1240 | // Determines the number of layers in the Upgrade Geometry |
1241 | // | |
1242 | // Inputs: | |
1243 | // lay: layer number | |
1244 | // Outputs: | |
1245 | // none | |
1246 | // Return: | |
1247 | // the number of modules per ladder in layer lay | |
1248 | // -1 if not Upgrade Geometry | |
1249 | // MS | |
1250 | ||
1251 | Int_t numberOfModules = 0; | |
1252 | ||
1253 | if (fMajorVersion != kvUpgrade) { | |
1254 | AliError("Not Upgrade Geometry!"); | |
1255 | return -1; | |
1256 | } | |
1257 | ||
1258 | // This checks should be redundant, but let's do things neatly | |
1259 | if (!gGeoManager) { | |
1260 | AliError("gGeoManager is null"); | |
1261 | return 0; | |
1262 | } | |
1263 | ||
1264 | char laddnam[15]; | |
451f5018 | 1265 | snprintf(laddnam, 15, "%s%d", AliITSUGeomTGeo::GetITSLadderPattern(),lay+1); |
29998a6e | 1266 | if (!gGeoManager->GetVolume(laddnam)) { |
1267 | AliError(Form("can't find %s volume",laddnam)); | |
1268 | return 0; | |
1269 | } | |
1270 | ||
1271 | // Loop on all ladder nodes, count Module volumes by checking names | |
1272 | Int_t nNodes = gGeoManager->GetVolume(laddnam)->GetNodes()->GetEntries(); | |
1273 | ||
1274 | if (nNodes == 0) | |
1275 | return 0; | |
1276 | ||
1277 | for (Int_t j=0; j<nNodes; j++) | |
1278 | if (strstr(gGeoManager->GetVolume(laddnam)->GetNodes()->At(j)->GetName(), | |
451f5018 | 1279 | AliITSUGeomTGeo::GetITSModulePattern())) |
29998a6e | 1280 | numberOfModules++; |
1281 | ||
1282 | ||
1283 | return numberOfModules; | |
1284 | } |