]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSvtest.cxx
Updated comment for compliance with the parsing algorithm
[u/mrichter/AliRoot.git] / ITS / AliITSvtest.cxx
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 /* $Id$ */
17
18 ///////////////////////////////////////////////////////////////////////////////
19 //                                                                           //
20 //  Inner Traking System version Test                                        //
21 //  This class contains the base procedures for the Inner Tracking System    //
22 //                                                                           //
23 // Authors: R. Barbera, B. S. Nilsen.                                        //
24 // version  Test                                                             //
25 // Created October 16 1999.                                                  //
26 //                                                                           //
27 ///////////////////////////////////////////////////////////////////////////////
28
29 #include <Riostream.h>
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <TLorentzVector.h>
33 #include <TMath.h>
34 #include <TSystem.h>
35 #include <TGeometry.h>
36 #include <TVirtualMC.h>
37 #include <TGeoMatrix.h>
38 #include <TGeoManager.h>
39 #include <TGeoMaterial.h>
40 #include <TGeoMedium.h>
41 #include <TGeoBBox.h>
42 #include <TGeoVolume.h>
43
44 #include "AliRun.h"
45 #include "AliMC.h"
46 #include "AliMagF.h"
47 #include "AliITSgeom.h"
48 #include "AliITSgeomSDD.h"
49 #include "AliITSgeomSPD.h"
50 #include "AliITSgeomSSD.h"
51 #include "AliITShit.h"
52 #include "AliITSvtest.h"
53
54 ClassImp(AliITSvtest)
55
56 const Double_t AliITSvtest::fgkmicron = 1.0E-4;
57 const Double_t AliITSvtest::fgkmm = 0.10;
58 const Double_t AliITSvtest::fgkcm = 1.00;
59 const Double_t AliITSvtest::fgkDegree = 1.0;
60 const Double_t AliITSvtest::fgkRadian = 180./3.14159265358979323846;
61 const Double_t AliITSvtest::fgkgcm3 = 1.0; // assume default is g/cm^3
62 const Double_t AliITSvtest::fgkCelsius = 1.0; // Assume default is C
63 const Double_t AliITSvtest::fgkPascal  = 1.0E-3; // Assume kPascal
64 const Double_t AliITSvtest::fgkKPascal = 1.0;    // Asume kPascal
65 const Double_t AliITSvtest::fgkeV      = 1.0E-9; // GeV default
66 const Double_t AliITSvtest::fgkKeV     = 1.0e-6; // GeV default
67 const Double_t AliITSvtest::fgkMeV     = 1.0e-3; // GeV default
68 const Double_t AliITSvtest::fgkGeV     = 1.0;    // GeV default
69
70  
71 //_____________________________________________________________________________
72 AliITSvtest::AliITSvtest() :
73 AliITS(),                   // Base Class
74 fGeomDetOut(kFALSE),       // Flag to write .det file out
75 fGeomDetIn(kFALSE),         // Flag to read .det file or directly from Geat.
76 fMajorVersion(IsVersion()), // Major version number == IsVersion
77 fMinorVersion(-1),          // Minor version number
78 fEuclidGeomDet(),           // file where detector transormation are define.
79 fRead(),                    //! file name to read .det file
80 fWrite(),                   //! file name to write .det file
81 fIgm()                      //! Geometry initilization object
82 {
83     // Default constructor for the ITS
84     // Inputs:
85     //   none.
86     // Outputs:
87     //   none.
88     // Return:
89     //   none.
90
91 //_____________________________________________________________________________
92 AliITSvtest::AliITSvtest(const Char_t *title,Int_t version) :
93 AliITS("ITS",title),        // Base Class
94 fGeomDetOut(kFALSE),       // Flag to write .det file out
95 fGeomDetIn(kFALSE),         // Flag to read .det file or directly from Geat.
96 fMajorVersion(IsVersion()), // Major version number == IsVersion
97 fMinorVersion(version),     // Minor version number
98 fEuclidGeomDet("$ALICE_ROOT/ITS/ITSgeometry_test.det"),// file where detector transormation are define.
99 fRead("$ALICE_ROOT/ITS/ITSgeometry_test.det"),//! file name to read .det file
100 fWrite("$ALICE_ROOT/ITS/ITSgeometry_test.det"),//! file name to write .det file
101 fIgm()                      //! Geometry initilization object
102 {
103     // Default constructor for the ITS. version=1 reads Euclide file for
104     // geometry. version=2 use's internal geometry
105     // Inputs:
106     //   Char_t *title   Geomety title
107     //   Int_t   version Minor version number to use.
108     //                       =-1 Not defined
109     //                       = 1 read Euclid geometry
110     //                       = 2 use internal geometry minor verion 2.
111     // Outputs:
112     //   none.
113     // Return:
114     //   none.
115     Int_t i;
116
117     fIdN    = 6;
118     fIdName    = new TString[fIdN];
119     fIdName[0] = "ITS1";
120     fIdName[1] = "ITS2";
121     fIdName[2] = "ITS3";
122     fIdName[3] = "ITS4";
123     fIdName[4] = "ITS5";
124     fIdName[5] = "ITS6";
125     fIdSens    = new Int_t[fIdN];
126     for(i=0;i<fIdN;i++) fIdSens[i] = 0;
127 }
128 //_____________________________________________________________________________
129 AliITSvtest::~AliITSvtest() {
130     // Standard destructor for the ITS
131     // Inputs:
132     //   none.
133     // Outputs:
134     //   none.
135     // Return:
136     //   none.
137 }
138 //_____________________________________________________________________________
139 AliITSvtest::AliITSvtest(const char *fileeuc,const char *filetme,
140                          const char *name, const char *title) :
141 AliITS(name, title),        // Base Class
142 fGeomDetOut(kFALSE),       // Flag to write .det file out
143 fGeomDetIn(kFALSE),         // Flag to read .det file or directly from Geat.
144 fMajorVersion(IsVersion()), // Major version number == IsVersion
145 fMinorVersion(1),           // Minor version number
146 fEuclidGeomDet("$ALICE_ROOT/ITS/ITSgeometry_test.det"),// file where detector transormation are define.
147 fRead("$ALICE_ROOT/ITS/ITSgeometry_test.det"),//! file name to read .det file
148 fWrite("$ALICE_ROOT/ITS/ITSgeometry_test.det"),//! file name to write .det file
149 fIgm()                      //! Geometry initilization object
150 {
151     // Standard constructor for the ITS
152     // Inputs:
153     //   none.
154     // Outputs:
155     //   none.
156     // Return:
157     //   none.
158     Int_t i;
159
160     fIdN    = 6;
161     fIdName    = new TString[fIdN];
162     fIdName[0] = "ITS1";
163     fIdName[1] = "ITS2";
164     fIdName[2] = "ITS3";
165     fIdName[3] = "ITS4";
166     fIdName[4] = "ITS5";
167     fIdName[5] = "ITS6";
168     fIdSens    = new Int_t[fIdN];
169     for(i=0;i<fIdN;i++) fIdSens[i] = 0;
170
171     fEuclidMaterial = filetme;
172     fEuclidGeometry = fileeuc;
173     //  The .det file for the geometry must have the same name as 
174     // fileeuc with .euc replaced by .det.
175 }
176 //_____________________________________________________________________________
177 void AliITSvtest::CreateMaterials(){
178     // Read materials for the ITS
179     // Inputs:
180     //   none.
181     // Outputs:
182     //   none.
183     // Return:
184     //   none.
185
186     switch(GetMinorVersion()){
187     case 1:
188         CreateMaterialsEuclid();
189         break;
190     case 2:
191         CreateMaterials2();
192         break;
193     default:
194         Warning("CreateMaterials","No CreateMaterials for minor version=%d",
195                  GetMinorVersion());
196         break;
197     } // end switch
198     return;
199 }
200 //_____________________________________________________________________________
201 void AliITSvtest::CreateMaterialsEuclid(){
202     // Read materials for the ITS
203     // Inputs:
204     //   none.
205     // Outputs:
206     //   none.
207     // Return:
208     //   none.
209     char *filtmp;
210
211     filtmp = gSystem->ExpandPathName(fEuclidMaterial.Data());
212     //  FILE *file = fopen(fEuclidMaterial.Data(),"r");
213     FILE *file = fopen(filtmp,"r");
214     if(file) {
215         fclose(file);
216         //    ReadEuclidMedia(fEuclidMaterial.Data(),this);
217         ReadEuclidMedia(filtmp);
218     } else {
219         Error("CreateMaterials"," THE MEDIA FILE %s DOES NOT EXIST !",
220               //          fEuclidMaterial.Data());
221               filtmp);
222         exit(1);
223     } // end if(file)
224 }
225 //_____________________________________________________________________________
226 void AliITSvtest::CreateMaterials2(){
227     // Read materials for the ITS
228     // Inputs:
229     //   none.
230     // Outputs:
231     //   none.
232     // Return:
233     //   none.
234     //TGeoManager *mgr = gGeoManager;
235     TGeoMaterial *si,*n2;
236     TGeoMedium *sims,*simn,*simN2;
237     Double_t params[8];
238     Int_t   ifield = gAlice->Field()->Integ();
239     Double_t fieldm = gAlice->Field()->Max(); // [kilogauss]
240
241     params[0] = 1.0; // sensitive volume flag
242     params[1] = (Double_t)ifield; // magnetic field type
243     params[2] = fieldm; // magnetic field stregth
244     params[3] = 0.1*fgkDegree; // tmaxfd  Theta max deviation over step
245     params[4] = 0.0075*fgkcm; // maximum step size
246     params[5] = 0.1; // Maximum fractional energy loss over a step
247     params[6] = 1.0E-4*fgkcm; // tracking precision
248     params[7] = 0.0*fgkcm; // Minimum step (=0 compute automatically)
249                            // must always be =0!
250
251     si = new TGeoMaterial("SI",28.86,14.0,2.33*fgkgcm3,
252                           TGeoMaterial::kMatStateSolid,25.0*fgkCelsius,
253                           0.0*fgkPascal);
254     sims = new TGeoMedium("ITSsensitiveSi",4,si,params);
255     params[0] = 0.0; // non sesitive.
256     simn = new TGeoMedium("ITSnonsensitiveSi",5,si,params);
257     //
258     n2 = new TGeoMaterial("Nitrogen Gas",14.00674,7.0,1.250E-3*fgkgcm3,
259                           TGeoMaterial::kMatStateGas,25.0*fgkCelsius,
260                           101325.0*fgkPascal);
261     simN2 = new TGeoMedium("ITSN2",6,n2,params);
262     //
263     if(sims==0 || simn==0 || simN2==0)
264         Error("CreateMaterial","Error getting medium ITSsensitiveSi=%p"
265               " ITSnonsensitiveSi=%p ITSN2=%p",sims,simn,simN2);
266 }
267 //_____________________________________________________________________________
268 void AliITSvtest::CreateGeometry(){
269     // Read geometry for the ITS
270     // Inputs:
271     //   none.
272     // Outputs:
273     //   none.
274     // Return:
275     //   none.
276
277     switch(GetMinorVersion()){
278     case 1:
279         CreateGeometryEuclid();
280         break;
281     case 2:
282         CreateGeometry2();
283         break;
284     default:
285         Warning("CreateGeometry","No CreateMaterials for minor version=%d",
286                  GetMinorVersion());
287         break;
288     } // end switch
289     return;
290 }
291 //_____________________________________________________________________________
292 void AliITSvtest::CreateGeometryEuclid(){
293     // Read geometry for the ITS
294     // Inputs:
295     //   none.
296     // Outputs:
297     //   none.
298     // Return:
299     //   none.
300     char topvol[5];
301     char *filtmp;
302
303     filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
304     FILE *file = fopen(filtmp,"r");
305     delete [] filtmp;
306     if(file) {
307         fclose(file);
308         printf("Ready to read Euclid geometry file\n");
309         ReadEuclid(fEuclidGeometry.Data(),topvol);
310         printf("Read in euclid geometries\n");
311     } else {
312         Error("CreateGeometry"," THE GEOM FILE %s DOES NOT EXIST !",
313               fEuclidGeometry.Data());
314         exit(1);
315     } // end if(file)
316     //
317     //---Place the ITS logical volume ITSV in its mother volume (ALIC) 
318     //   and make it invisible
319     //
320     gMC->Gspos("ITSV",1,"ALIC",0,0,0,0,"ONLY");
321     //
322     //---Outputs the geometry tree in the EUCLID/CAD format
323     
324     if (fEuclidOut) {
325         gMC->WriteEuclid("ITSgeometry", "ITSV", 1, 5);
326     } // end if (fEuclidOut)
327     cout <<"finished with euclid geometrys"<< endl;
328 }
329 //_____________________________________________________________________________
330 void AliITSvtest::CreateGeometry2(){
331     // Test geometry verion 2.
332     //  /ALIC_1/ITSV_1/ITSspd1_1/ITS1_1/   lay=1
333     //  /ALIC_1/ITSV_1/ITSspd2_1/ITS2_1/   lay=2
334     //  /ALIC_1/ITSV_1/ITSsdd1_1/ITS3_1/   lay=3
335     //  /ALIC_1/ITSV_1/ITSsdd2_1/ITS4_1/   lay=4
336     //  /ALIC_1/ITSV_1/ITSssd1_1/ITS5_1/   lay=5
337     //  /ALIC_1/ITSV_1/ITSssd2_1/ITS6_1/   Lay=6
338     // Inputs:
339     //   none.
340     // Outputs:
341     //   none.
342     // Return:
343     //   none.
344     // These constant character strings are set by cvs during commit
345     // do not change them unless you know what you are doing!
346     const Char_t *cvsDate="$Date$";
347     const Char_t *cvsRevision="$Revision$";
348     const Double_t ksensitiveSPD[3]={0.6*fgkcm,0.01*fgkcm,3.5*fgkcm};
349     const Double_t ksensitiveSDD[3]={3.5085*fgkcm,0.01499*fgkcm,3.7485*fgkcm};
350     const Double_t ksensitiveSSD[3]={3.75*fgkcm,0.0150*fgkcm,2.1*fgkcm};
351     const Double_t kwaferSPD[3]={0.7*fgkcm,0.01*fgkcm,3.6*fgkcm};
352     const Double_t kwaferSDD[3]={3.61*fgkcm,0.0150*fgkcm,4.38*fgkcm};
353     const Double_t kwaferSSD[3]={3.85*fgkcm,0.0150*fgkcm,2.2*fgkcm};
354     TGeoManager *mgr = gGeoManager;
355     TGeoVolume *vALIC=0;
356     TGeoMedium *sensitiveSi=0,*bulckSi=0,*n2=0;
357     TGeoBBox *sITS,*sSPD,*sSDD,*sSSD;
358     TGeoBBox *sITS1,*sITS2,*sITS3,*sITS4,*sITS5,*sITS6;
359     TGeoVolume *vITS,*vSPD1,*vSPD2,*vSDD1,*vSDD2,*vSSD1,*vSSD2;
360     TGeoVolume *vITS1,*vITS2,*vITS3,*vITS4,*vITS5,*vITS6;
361
362     vALIC = mgr->GetTopVolume();
363     if(vALIC==0) {
364         vALIC = mgr->GetVolume("ALIC");
365         if(vALIC==0) {
366             Error("CreateGeometry2","vALIC=0");
367             return;
368         }// end if
369     } // end if
370     //sensitiveSi = mgr->GetMedium("ITSsensitiveSi");
371     sensitiveSi = mgr->GetMedium(4);
372     //bulckSi     = mgr->GetMedium("ITSnonesensitiveSi");
373     bulckSi     = mgr->GetMedium(5);
374     //n2          = mgr->GetMedium("ITSN2");
375     n2          = mgr->GetMedium(6);
376     if(sensitiveSi==0 || bulckSi==0 || n2==0){
377         Error("CreateGeometry2","Error getting medium sensitiveSi=%p"
378               " bulckSi=%p n2=%p",sensitiveSi,bulckSi,n2);
379         TList *lmed = mgr->GetListOfMedia();
380         TIter next(lmed);
381         while(TGeoMedium *med = (TGeoMedium*) next())
382             med->Inspect();
383     } //
384     sITS1 = new TGeoBBox((Double_t*)ksensitiveSPD);
385     vITS1 = new TGeoVolume("ITS1",sITS1,sensitiveSi);
386     sITS2 = new TGeoBBox((Double_t*)ksensitiveSPD);
387     vITS2 = new TGeoVolume("ITS2",sITS2,sensitiveSi);
388     sSPD  = new TGeoBBox((Double_t*)kwaferSPD);
389     vSPD1 = new TGeoVolume("ITSspd1",sSPD,bulckSi);
390     vSPD2 = new TGeoVolume("ITSspd2",sSPD,bulckSi);
391     vSPD1->AddNode(vITS1,1,0); // one copy no translation/rotation
392     vSPD2->AddNode(vITS2,1,0); // one copy no translation/rotation
393     //
394     sITS3 = new TGeoBBox((Double_t*)ksensitiveSDD);
395     vITS3 = new TGeoVolume("ITS3",sITS3,sensitiveSi);
396     sITS4 = new TGeoBBox((Double_t*)ksensitiveSDD);
397     vITS4 = new TGeoVolume("ITS4",sITS4,sensitiveSi);
398     sSDD  = new TGeoBBox((Double_t*)kwaferSDD);
399     vSDD1 = new TGeoVolume("ITSsdd1",sSDD,bulckSi);
400     vSDD2 = new TGeoVolume("ITSsdd2",sSDD,bulckSi);
401     vSDD1->AddNode(vITS3,1,0); // one copy no translation/rotation
402     vSDD2->AddNode(vITS4,1,0); // one copy no translation/rotation
403     //
404     sITS5 = new TGeoBBox((Double_t*)ksensitiveSSD);
405     vITS5 = new TGeoVolume("ITS5",sITS5,sensitiveSi);
406     sITS6 = new TGeoBBox((Double_t*)ksensitiveSSD);
407     vITS6 = new TGeoVolume("ITS6",sITS6,sensitiveSi);
408     sSSD  = new TGeoBBox((Double_t*)kwaferSSD);
409     vSSD1 = new TGeoVolume("ITSssd1",sSSD,bulckSi);
410     vSSD2 = new TGeoVolume("ITSssd2",sSSD,bulckSi);
411     vSSD1->AddNode(vITS5,1,0); // one copy no translation/rotation
412     vSSD2->AddNode(vITS6,1,0); // one copy no translation/rotation
413     //
414     sITS = new TGeoBBox(100.0,100.,100.0);
415     vITS = new TGeoVolume("ITSV",sITS,n2); // one copy of vacume ITSV
416     const Int_t length=100;
417     Char_t vstrng[length];
418     if(fIgm.WriteVersionString(vstrng,length,(AliITSVersion_t)IsVersion(),
419                                fMinorVersion,cvsDate,cvsRevision))
420         vITS->SetTitle(vstrng);
421     else Error("CreateGeometry2","Error writing/setting version string");
422
423     vALIC->AddNode(vITS,1,0);// one copy no translation/rotation
424     //
425     TGeoTranslation *t1,*t2,*t3,*t4,*t5,*t6;
426     TGeoRotation    *r1,*r2,*r3,*r4,*r5,*r6;
427     TGeoCombiTrans  *tr1,*tr2,*tr3,*tr4,*tr5,*tr6;
428     t1 = new TGeoTranslation( +4.0,+0.0,+0.0); // "perfect" location
429     r1 = new TGeoRotation("",90.0,0.0,0.0);    // "perfect" location
430     tr1= new TGeoCombiTrans(*t1,*r1);// "perfect" location
431     t2 = new TGeoTranslation( +7.0,+0.2,-0.5);
432     r2 = new TGeoRotation("",-91.0,10.0,-5.0);
433     tr2= new TGeoCombiTrans(*t2,*r2);
434     t3 = new TGeoTranslation(+14.9,-0.6,+0.1);
435     r3 = new TGeoRotation("",93.0,-7.0,5.0);
436     tr3= new TGeoCombiTrans(*t3,*r3);
437     t4 = new TGeoTranslation(+23.8,+0.3,-0.2);
438     r4 = new TGeoRotation("",91.0,10.0,-5.0);
439     tr4= new TGeoCombiTrans(*t4,*r4);
440     t5 = new TGeoTranslation(+39.1,+0.1,+0.4);
441     r5 = new TGeoRotation("",88.0,1.0,5.0);
442     tr5= new TGeoCombiTrans(*t5,*r5);
443     t6 = new TGeoTranslation(+43.6,-0.5,+0.2);
444     r6 = new TGeoRotation("",92.0,0.0,-5.0);
445     tr6= new TGeoCombiTrans(*t6,*r6);
446     //
447     vITS->AddNode(vSPD1,1,tr1);
448     vITS->AddNode(vSPD2,1,tr2);
449     vITS->AddNode(vSDD1,1,tr3);
450     vITS->AddNode(vSDD2,1,tr4);
451     vITS->AddNode(vSSD1,1,tr5);
452     vITS->AddNode(vSSD2,1,tr6);
453     //
454     return;
455 }
456 //_____________________________________________________________________________
457 void AliITSvtest::Init(){
458     // Initialise the ITS after it has been created.
459     // Inputs:
460     //   none.
461     // Outputs:
462     //   none.
463     // Return:
464     //   none.
465     Int_t i;
466
467     cout << endl;
468     for(i=0;i<29;i++) cout << "*";cout << " ITSvtest_Init ";
469     for(i=0;i<28;i++) cout << "*";cout << endl;
470
471     switch(GetMinorVersion()){
472     case 1:
473         InitEuclid();
474         break;
475     case 2:
476         Init2();
477         break;
478     default:
479         break;
480     } // end switch
481     UpdateInternalGeometry();
482     AliITS::Init();
483     if(fGeomDetOut) GetITSgeom()->WriteNewFile(fWrite.Data());
484
485     for(i=0;i<72;i++) cout << "*";
486     cout << endl;
487 }
488 //_____________________________________________________________________________
489 void AliITSvtest::InitEuclid(){
490     // Initialise the ITS after it has been created. Euclid version
491     // Inputs:
492     //   none.
493     // Outputs:
494     //   none.
495     // Return:
496     //   none.
497 }
498 //_____________________________________________________________________________
499 void AliITSvtest::Init2(){
500     // Initialise the ITS after it has been created. Geometry 2 verion
501     // Inputs:
502     //   none.
503     // Outputs:
504     //   none.
505     // Return:
506     //   none.
507     Int_t i,n=3,imed[3];
508     TGeoManager *mgr = gGeoManager;
509     if(mgr==0) Error("Init2","mgr=0");
510     TGeoMedium *sensitiveSi = mgr->GetMedium("ITSsensitiveSi");
511     TGeoMedium *bulckSi = mgr->GetMedium("ITSnonsensitiveSi");
512     TGeoMedium *n2 = mgr->GetMedium("ITSN2");
513
514     if(sensitiveSi==0) Error("Init2","sensitiveSi=0");
515     if(bulckSi==0) Error("Init2","bulckSi=0");
516     if(n2==0) Error("Init2","n2=0");
517     imed[0] = sensitiveSi->GetId();
518     imed[1] = bulckSi->GetId();
519     imed[2] = n2->GetId();
520     for(i=0;i<n;i++){
521         if(imed[i]<=0){
522             Error("Init2","GetId failed for imed[i=%d]=%d",i,imed[i]);
523             return;
524         } // end if
525         gMC->Gstpar(imed[i],"CUTGAM",30.0*fgkKeV);
526         gMC->Gstpar(imed[i],"CUTELE",30.0*fgkKeV);
527         gMC->Gstpar(imed[i],"CUTNEU",30.0*fgkKeV);
528         gMC->Gstpar(imed[i],"CUTHAD",30.0*fgkKeV);
529         gMC->Gstpar(imed[i],"CUTMUO",30.0*fgkKeV);
530         gMC->Gstpar(imed[i],"BCUTE",30.0*fgkKeV);
531         gMC->Gstpar(imed[i],"BCUTM",30.0*fgkKeV);
532         gMC->Gstpar(imed[i],"DCUTE",30.0*fgkKeV);
533         gMC->Gstpar(imed[i],"DCUTM",30.0*fgkKeV);
534         //gMC->Gstpar(imed[i],"PPCUTM",);
535         //gMC->Gstpar(imed[i],"PAIR",);
536         //gMC->Gstpar(imed[i],"COMPT",);
537         //gMC->Gstpar(imed[i],"PHOT",);
538         //gMC->Gstpar(imed[i],"PFIS",);
539         gMC->Gstpar(imed[i],"DRAY",1);
540         //gMC->Gstpar(imed[i],"ANNI",);
541         //gMC->Gstpar(imed[i],"BREM",);
542         //gMC->Gstpar(imed[i],"HADR",);
543         //gMC->Gstpar(imed[i],"MUNU",);
544         //gMC->Gstpar(imed[i],"DCAY",);
545         gMC->Gstpar(imed[i],"LOSS",1);
546         //gMC->Gstpar(imed[i],"MULS",);
547         //gMC->Gstpar(imed[i],"GHCOR1",);
548         //gMC->Gstpar(imed[i],"BIRK1",);
549         //gMC->Gstpar(imed[i],"BRIK2",);
550         //gMC->Gstpar(imed[i],"BRIK3",);
551         //gMC->Gstpar(imed[i],"LABS",);
552         //gMC->Gstpar(imed[i],"SYNC",);
553         //gMC->Gstpar(imed[i],"STRA",);
554     } // end for i
555     return;
556 }
557 //_____________________________________________________________________________
558 void AliITSvtest::StepManager(){
559     // Called for every step in the ITS
560     // Inputs:
561     //   none.
562     // Outputs:
563     //   none.
564     // Return:
565     //   none.
566     //
567     // Fill hit structure.
568     static TLorentzVector position, momentum; // Saves on calls to construtors
569     static AliITShit hit;                     // Saves on calls to construtors
570     Int_t cpn0,cpn1,cpn2,status,lay,mod,id;
571
572     if(!(gMC->TrackCharge())) return;
573     if(!(this->IsActive())) return;
574     TClonesArray &lhits = *(Hits());
575     // Track status
576     status = 0;
577     if(gMC->IsTrackInside())      status +=  1;
578     if(gMC->IsTrackEntering())    status +=  2;
579     if(gMC->IsTrackExiting())     status +=  4;
580     if(gMC->IsTrackOut())         status +=  8;
581     if(gMC->IsTrackDisappeared()) status += 16;
582     if(gMC->IsTrackStop())        status += 32;
583     if(gMC->IsTrackAlive())       status += 64;
584     // Only entering charged tracks
585     id = gMC->CurrentVolID(cpn0);
586     for(lay=0;lay<6;lay++) if(id == fIdSens[lay]) break;
587     lay++;
588     if(lay>6) return; // not in detector
589     cpn0=cpn1=cpn2=1;
590     fIgm.DecodeDetector(mod,lay,cpn0,cpn1,cpn2);
591     // Fill hit structure.
592     hit.SetModule(mod);
593     hit.SetTrack(gAlice->GetMCApp()->GetCurrentTrackNumber());
594     gMC->TrackPosition(position);
595     gMC->TrackMomentum(momentum);
596     hit.SetPosition(position);
597     hit.SetTime(gMC->TrackTime());
598     hit.SetMomentum(momentum);
599     hit.SetStatus(status);
600     hit.SetEdep(gMC->Edep());
601     hit.SetShunt(GetIshunt());
602     if(gMC->IsTrackEntering()){
603         hit.SetStartPosition(position);
604         hit.SetStartTime(gMC->TrackTime());
605         hit.SetStartStatus(status);
606         return; // don't save entering hit.
607     } // end if IsEntering
608     // Fill hit structure with this new hit.
609     new(lhits[fNhits++]) AliITShit(hit); // Use Copy Construtor.
610     // Save old position... for next hit.
611     hit.SetStartPosition(position);
612     hit.SetStartTime(gMC->TrackTime());
613     hit.SetStartStatus(status);
614     //
615     Double_t g0[4],l0[4],g1[4];
616     position.GetXYZT(g0);
617     gMC->Gmtod(g0,l0,1); // flag=1 convert coordiantes
618     gMC->Gdtom(l0,g1,1); // flag=1 convert coordinates
619     printf("    gMC: mod=%d g=%g %g %g %g -> l= %g %g %g %g ->g=%g %g %g %g\n",
620            mod,g0[0],g0[1],g0[2],g0[3],l0[0],l0[1],l0[2],l0[3],g1[0],g1[2],g1[2],g1[3]);
621     GetITSgeom()->GtoL(mod,g0,l0);
622     GetITSgeom()->LtoG(mod,l0,g1);
623     printf("ITSgeom: mod=%d g=%g %g %g %g -> l= %g %g %g %g ->g=%g %g %g %g\n",
624            mod,g0[0],g0[1],g0[2],g0[3],l0[0],l0[1],l0[2],l0[3],g1[0],g1[2],g1[2],g1[3]);
625     TGeoNode *cur = gGeoManager->GetCurrentNode();
626     cur->MasterToLocal(g0,l0);
627     cur->LocalToMaster(l0,g1);
628     printf("   TGeo: mod=%d g=%g %g %g %g -> l= %g %g %g %g ->g=%g %g %g %g\n",
629            mod,g0[0],g0[1],g0[2],g0[3],l0[0],l0[1],l0[2],l0[3],g1[0],g1[2],g1[2],g1[3]);
630     printf("=====================\n");
631     //
632
633   return;
634 }
635 //______________________________________________________________________
636 void AliITSvtest::PrintAscii(ostream *os)const{
637     // Print out class data values in Ascii Form to output stream
638     // Inputs:
639     //   ostream *os   Output stream where Ascii data is to be writen
640     // Outputs:
641     //   none.
642     // Return:
643     //   none.
644 #if defined __GNUC__
645 #if __GNUC__ > 2
646     ios::fmtflags fmt;
647 #else
648     Int_t fmt;
649 #endif
650 #else
651 #if defined __ICC || defined __ECC || defined __xlC__
652     ios::fmtflags fmt;
653 #else
654     Int_t fmt;
655 #endif
656 #endif
657
658     *os << fGeomDetOut << " " << fGeomDetIn  << " ";
659     *os << fMajorVersion << " " << fMinorVersion << " ";
660     *os << "\"" << fEuclidGeomDet.Data() << "\"" << " ";
661     *os << "\"" << fRead.Data() << "\"" << " ";
662     *os << "\"" << fWrite.Data() << "\"" << " ";
663     fmt = os->setf(ios::scientific); // set scientific floating point output
664     os->flags(fmt); // reset back to old Formating.
665     return;
666 }
667 //______________________________________________________________________
668 void AliITSvtest::ReadAscii(istream *is){
669     // Read in class data values in Ascii Form to output stream
670     // Inputs:
671     //   istream *is   Input stream where Ascii data is to be read in from
672     // Outputs:
673     //   none.
674     // Return:
675     //   none.
676     Char_t name[120];
677
678     *is >> fGeomDetOut >> fGeomDetIn ;
679     *is >> fMajorVersion >> fMinorVersion;
680     *is >> name;
681     fEuclidGeomDet = name;
682     *is >> name;
683     fRead = name;
684     *is >> name;
685     fWrite = name;
686     fIgm.SetVersion((AliITSVersion_t)fMajorVersion,fMinorVersion);
687     fIgm.SetGeometryName("ITS test geometry");
688 }
689 //______________________________________________________________________
690 ostream &operator<<(ostream &os,const AliITSvtest &s){
691     // Standard output streaming function
692     // Inputs:
693     //   ostream            &os  output steam
694     //   AliITSvtest &s class to be streamed.
695     // Output:
696     //   none.
697     // Return:
698     //   ostream &os  The stream pointer
699
700     s.PrintAscii(&os);
701     return os;
702 }
703 //______________________________________________________________________
704 istream &operator>>(istream &is,AliITSvtest &s){
705     // Standard inputput streaming function
706     // Inputs:
707     //   istream            &is  input steam
708     //   AliITSvtest &s class to be streamed.
709     // Output:
710     //   none.
711     // Return:
712     //   ostream &os  The stream pointer
713
714     s.ReadAscii(&is);
715     return is;
716 }