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