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