]> git.uio.no Git - u/mrichter/AliRoot.git/blob - AliITSvtest.cxx
472d5b091be37c119d60b8ec6d0edf66b663eb7e
[u/mrichter/AliRoot.git] / 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 /*
17 $Log$
18 Revision 1.1.2.8  2000/10/05 20:28:18  nilsen
19 Now using root generated streamer function.
20
21 Revision 1.1.2.7  2000/07/31 13:51:22  barbera
22 Updated from the release
23
24 Revision 1.2  2000/07/10 16:07:19  fca
25 Release version of ITS code
26
27 Revision 1.1.2.2  2000/03/02 21:53:36  nilsen
28 to make it compatable with the changes in AliRun/AliModule.
29
30 Revision 1.1.2.1  2000/01/12 20:19:03  nilsen
31         The changes made with this latest inclusion of code is very large.
32 Many of the new files were added just in December when P. Cerello added his
33 SDD simulations to the distrobutions. Also added are some file of P. Skowronski
34 for SSD cluster finding and ghost RecPoints. None of this "new" code has been
35 proporly tested. Other code new to this cvs repository is explained in the
36 ITS Off-line web page. In general the changes are too large to give a resonable
37 discription of them but probably should be taken as the starting point for
38 the developement branch (ITS-working).
39     B. S. Nilsen
40
41 Revision 1.13  1999/10/16 19:49:00  BSN
42 $Name$
43 $Author$
44 $Id$
45 */
46
47 ///////////////////////////////////////////////////////////////////////////////
48 //                                                                           //
49 //  Inner Traking System version Test                                        //
50 //  This class contains the base procedures for the Inner Tracking System    //
51 //                                                                           //
52 // Authors: R. Barbera, B. S. Nilsen.                                        //
53 // version  Test                                                             //
54 // Created October 16 1999.                                                  //
55 //                                                                           //
56 ///////////////////////////////////////////////////////////////////////////////
57 #include <stdio.h>
58 #include <stdlib.h>
59 #include <TMath.h>
60 #include <TGeometry.h>
61 #include <TNode.h>
62 #include <TTUBE.h>
63 #include <TFile.h>    // only required for Tracking function?
64 #include <TCanvas.h>
65 #include <TObjArray.h>
66 #include <TObjString.h>
67 #include <TClonesArray.h>
68 #include <TLorentzVector.h>
69 #include <TBRIK.h>
70 #include <TSystem.h>
71
72 #include "AliMC.h"
73 #include "AliRun.h"
74 #include "AliITShit.h"
75 #include "AliITS.h"
76 #include "AliITSvtest.h"
77 #include "AliITSgeom.h"
78
79 ClassImp(AliITSvtest)
80  
81 //_____________________________________________________________________________
82 AliITSvtest::AliITSvtest() {
83     //
84     // Standard constructor for the ITS
85     //
86     fIdN    = 0;
87     fIdName = 0;
88     fIdSens = 0;
89     fMajorVersion = -1;
90     fMinorVersion = -1;
91 }
92 //____________________________________________________________________________
93 AliITSvtest::AliITSvtest(const AliITSvtest &source){
94 ////////////////////////////////////////////////////////////////////////
95 //     Copy Constructor for ITS test version.
96 ////////////////////////////////////////////////////////////////////////
97     if(&source == this) return;
98     printf("Not allowed to copy AliITSvtest\n");
99     return;
100 }
101 //_____________________________________________________________________________
102 AliITSvtest& AliITSvtest::operator=(const AliITSvtest &source){
103 ////////////////////////////////////////////////////////////////////////
104 //    Assignment operator for the ITS version 1.
105 ////////////////////////////////////////////////////////////////////////
106         if(&source == this) return *this;
107         printf("Not allowed to copy AliITSvtest\n");
108         return *this;
109 }
110 //_____________________________________________________________________________
111 AliITSvtest::~AliITSvtest() {
112     //
113     // Standard destructor for the ITS
114     //
115 }
116 //_____________________________________________________________________________
117 AliITSvtest::AliITSvtest(const char *fileeuc,const char *filetme,
118                          const char *name, const char *title) 
119     : AliITS(name, title){
120     //
121     // Standard constructor for the ITS
122     //
123     fIdN    = 6;
124 /*
125 //  TObjArray of TObjStrings
126     fIdName = new TObjArray(fIdN);
127     fIdName->AddAt(new TObjString("ITS1"),0);
128     fIdName->AddAt(new TObjString("ITS2"),1);
129     fIdName->AddAt(new TObjString("ITS3"),2);
130     fIdName->AddAt(new TObjString("ITS4"),3);
131     fIdName->AddAt(new TObjString("ITS5"),4);
132     fIdName->AddAt(new TObjString("ITS6"),5);
133 */
134 //  Array of TStrings.
135     fIdName    = new TString[fIdN];
136     fIdName[0] = "ITS1";
137     fIdName[1] = "ITS2";
138     fIdName[2] = "ITS3";
139     fIdName[3] = "ITS4";
140     fIdName[4] = "ITS5";
141     fIdName[5] = "ITS6";
142     fIdSens    = new Int_t[fIdN];
143     for (Int_t i=0;i<fIdN;i++) fIdSens[i] = 0;
144     fMajorVersion = -1;
145     fMinorVersion = 1;
146
147     fEuclidMaterial = filetme;
148     fEuclidGeometry = fileeuc;
149 //  The .det file for the geometry must have the same name as fileeuc with
150 //  .euc replaced by .det.
151 }
152
153  
154 //_____________________________________________________________________________
155 void AliITSvtest::CreateMaterials(){
156   //
157   // Read materials for the ITS
158   //
159     char *filtmp;
160 //
161   filtmp = gSystem->ExpandPathName(fEuclidMaterial.Data());
162 //  FILE *file = fopen(fEuclidMaterial.Data(),"r");
163   FILE *file = fopen(filtmp,"r");
164   if(file) {
165     fclose(file);
166 //    ReadEuclidMedia(fEuclidMaterial.Data(),this);
167     ReadEuclidMedia(filtmp);
168   } else {
169     Error("CreateMaterials"," THE MEDIA FILE %s DOES NOT EXIST !",
170 //        fEuclidMaterial.Data());
171           filtmp);
172     exit(1);
173   } // end if(file)
174 }
175
176 //_____________________________________________________________________________
177 void AliITSvtest::CreateGeometry(){
178 //////////////////////////////////////////////////////////////////////
179 ////////////////////////////////////////////////////////////////////////
180 // Read geometry for the ITS
181 //
182
183     Int_t size;
184     char topvol[5];
185     char *filtmp;
186 //
187   filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
188   FILE *file = fopen(filtmp,"r");
189   delete [] filtmp;
190   if(file) {
191     fclose(file);
192     printf("Ready to read Euclid geometry file\n");
193     ReadEuclid(fEuclidGeometry.Data(),topvol);
194     printf("Read in euclid geometries\n");
195   } else {
196     Error("CreateGeometry"," THE GEOM FILE %s DOES NOT EXIST !",
197           fEuclidGeometry.Data());
198     exit(1);
199   } // end if(file)
200   //
201   //---Place the ITS ghost volume ITSV in its mother volume (ALIC) and make it
202   //     invisible
203   //
204   gMC->Gspos("ITSV",1,"ALIC",0,0,0,0,"ONLY");
205   //
206   //---Outputs the geometry tree in the EUCLID/CAD format
207   
208     if (fEuclidOut) {
209       gMC->WriteEuclid("ITSgeometry", "ITSV", 1, 5);
210     } // end if (fEuclidOut)
211
212     filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
213     size = strlen(filtmp);
214     if(size>4){
215         filtmp[size-3] = 'd'; // change from .euc to .det
216         filtmp[size-2] = 'e';
217         filtmp[size-1] = 't';
218         file = fopen(filtmp,"r");
219         if(file){ // if file exists use it to fill AliITSgeom structure.
220             fclose(file);
221             printf("ready to read .det file %s\n",filtmp);
222             fITSgeom = new AliITSgeom(filtmp);
223         }else{
224             fITSgeom = 0;
225             // fill AliITSgeom structure from geant structure just filled above
226         }// end if(file)
227         delete [] filtmp;
228     }// end if(size>4)
229     printf("finished with euclid geometrys\n");
230 }
231
232 //_____________________________________________________________________________
233 void AliITSvtest::Init(){
234     //
235     // Initialise the ITS after it has been created
236     //
237     AliITS::Init();
238     fMajorVersion = -1;
239     fMinorVersion = 0;
240
241  
242 //_____________________________________________________________________________
243 void AliITSvtest::StepManager(){
244   //
245   // Called for every step in the ITS
246   //
247   Int_t          copy, id;
248   Int_t          copy1,copy2;
249   Float_t        hits[8];
250   Int_t          vol[4];
251   TLorentzVector position, momentum;
252   TClonesArray   &lhits = *fHits;
253   //
254   // Track status
255   vol[3] = 0;
256   if(gMC->IsTrackInside())      vol[3] +=  1;
257   if(gMC->IsTrackEntering())    vol[3] +=  2;
258   if(gMC->IsTrackExiting())     vol[3] +=  4;
259   if(gMC->IsTrackOut())         vol[3] +=  8;
260   if(gMC->IsTrackDisappeared()) vol[3] += 16;
261   if(gMC->IsTrackStop())        vol[3] += 32;
262   if(gMC->IsTrackAlive())       vol[3] += 64;
263   //
264   // Fill hit structure.
265   if(!(gMC->TrackCharge())) return;
266   //
267   // Only entering charged tracks
268   if((id = gMC->CurrentVolID(copy)) == fIdSens[0]) {
269       vol[0] = 1;
270       id = gMC->CurrentVolOffID(0,copy);
271       //detector copy in the ladder = 1<->4  (ITS1)
272       vol[1] = copy;
273       gMC->CurrentVolOffID(1,copy1);
274       //ladder copy in the module   = 1<->2  (I186)
275       gMC->CurrentVolOffID(2,copy2);
276       //module copy in the layer    = 1<->10 (I132)
277       vol[2] = copy1+(copy2-1)*2;//# of ladders in one module  = 2
278   } else if(id == fIdSens[1]){
279       vol[0] = 2;
280       id = gMC->CurrentVolOffID(0,copy);
281       //detector copy in the ladder = 1<->4  (ITS2)
282       vol[1] = copy;
283       gMC->CurrentVolOffID(1,copy1);
284       //ladder copy in the module   = 1<->4  (I131)
285       gMC->CurrentVolOffID(2,copy2);
286       //module copy in the layer    = 1<->10 (I132)
287       vol[2] = copy1+(copy2-1)*4;//# of ladders in one module  = 4
288   } else if(id == fIdSens[2]){
289       vol[0] = 3;
290       id = gMC->CurrentVolOffID(1,copy);
291       //detector copy in the ladder = 1<->5  (ITS3 is inside I314)
292       vol[1] = copy;
293       id = gMC->CurrentVolOffID(2,copy);
294       //ladder copy in the layer    = 1<->12 (I316)
295       vol[2] = copy;
296   } else if(id == fIdSens[3]){
297       vol[0] = 4;
298       id = gMC->CurrentVolOffID(1,copy);
299       //detector copy in the ladder = 1<->8  (ITS4 is inside I414)
300       vol[1] = copy;
301       id = gMC->CurrentVolOffID(2,copy);
302       //ladder copy in the layer    = 1<->22 (I417)
303       vol[2] = copy;
304   }else if(id == fIdSens[4]){
305       vol[0] = 5;
306       id = gMC->CurrentVolOffID(1,copy);
307       //detector copy in the ladder = 1<->23  (ITS5 is inside I562)
308       vol[1] = copy;
309       id = gMC->CurrentVolOffID(2,copy);
310      //ladder copy in the layer    = 1<->34 (I565)
311       vol[2] = copy;
312   }else if(id == fIdSens[5]){
313       vol[0] = 6;
314       id = gMC->CurrentVolOffID(1,copy);
315       //detector copy in the ladder = 1<->26  (ITS6 is inside I566)
316       vol[1] = copy;
317       id = gMC->CurrentVolOffID(2,copy);
318       //ladder copy in the layer = 1<->38 (I569)
319       vol[2] = copy;
320   } else {
321       return; // not an ITS volume?
322   } // end if/else if (gMC->CurentVolID(copy) == fIdSens[i])
323 //
324   gMC->TrackPosition(position);
325   gMC->TrackMomentum(momentum);
326   hits[0]=position[0];
327   hits[1]=position[1];
328   hits[2]=position[2];
329   hits[3]=momentum[0];
330   hits[4]=momentum[1];
331   hits[5]=momentum[2];
332   hits[6]=gMC->Edep();
333   hits[7]=gMC->TrackTime();
334   // Fill hit structure with this new hit.
335   new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->CurrentTrack(),vol,hits);
336   return;
337 }
338 /*
339 //____________________________________________________________________________
340 void AliITSvtest::Streamer(TBuffer &R__b)
341 {
342    // Stream an object of class AliITSvtest.
343
344    if (R__b.IsReading()) {
345       Version_t R__v = R__b.ReadVersion(); if (R__v) { }
346       AliITS::Streamer(R__b);
347    } else {
348       R__b.WriteVersion(AliITSvtest::IsA());
349       AliITS::Streamer(R__b);
350    }
351 }
352 */