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