]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSv5.cxx
bae64219ab34920fa05b83f74edba76ed862db61
[u/mrichter/AliRoot.git] / ITS / AliITSv5.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.13  1999/10/06 10:15:19  fca
19 Correct bug in allocation of layer name and add destructor
20
21 Revision 1.12  1999/10/05 08:05:09  fca
22 Minor corrections for uninitialised variables.
23
24 Revision 1.11  1999/09/29 09:24:20  fca
25 Introduction of the Copyright and cvs Log
26
27 */
28
29 ///////////////////////////////////////////////////////////////////////////////
30 //                                                                           //
31 //  Inner Traking System version 5                                           //
32 //  This class contains the base procedures for the Inner Tracking System    //
33 //                                                                           //
34 // Authors: R. Barbera, B. S. Nilsen.
35 // version 5.
36 // Created September 17 1999.
37 //                                                                           //
38 ///////////////////////////////////////////////////////////////////////////////
39
40 #include <stdio.h>
41 #include <stdlib.h>
42 #include <TMath.h>
43
44 #include "AliRun.h"
45 #include "TSystem.h"
46 #include "AliITShit.h"
47 #include "AliITS.h"
48 #include "AliITSv5.h"
49 #include "AliITSgeom.h"
50
51 ClassImp(AliITSv5)
52  
53 //_____________________________________________________________________________
54 AliITSv5::AliITSv5() {
55     //
56     // Standard constructor for the ITS
57     //
58     fId5N = 6;
59     fId5Name = new char*[fId5N];
60     fId5Name[0] = "ITS1";
61     fId5Name[1] = "ITS2";
62     fId5Name[2] = "ITS3";
63     fId5Name[3] = "ITS4";
64     fId5Name[4] = "ITS5";
65     fId5Name[5] = "ITS6";
66 }
67 //_____________________________________________________________________________
68 AliITSv5::~AliITSv5() {
69     //
70     // Standard destructor for the ITS
71     //
72   delete [] fId5Name;
73 }
74 //_____________________________________________________________________________
75 AliITSv5::AliITSv5(const char *name, const char *title) : AliITS(name, title){
76     //
77     // Standard constructor for the ITS
78     //
79     fId5N = 6;
80     fId5Name = new char*[fId5N];
81     fId5Name[0] = "ITS1";
82     fId5Name[1] = "ITS2";
83     fId5Name[2] = "ITS3";
84     fId5Name[3] = "ITS4";
85     fId5Name[4] = "ITS5";
86     fId5Name[5] = "ITS6";
87
88     fEuclidMaterial = "$ALICE_ROOT/Euclid/ITSgeometry_5.tme";
89     fEuclidGeometry = "$ALICE_ROOT/Euclid/ITSgeometry_5.euc";
90 }
91
92  
93 //_____________________________________________________________________________
94 void AliITSv5::CreateMaterials(){
95   //
96   // Read materials for the ITS
97   //
98     char *filtmp;
99 //
100   filtmp = gSystem->ExpandPathName(fEuclidMaterial.Data());
101 //  FILE *file = fopen(fEuclidMaterial.Data(),"r");
102   FILE *file = fopen(filtmp,"r");
103   if(file) {
104     fclose(file);
105 //    gAlice->ReadEuclidMedia(fEuclidMaterial.Data(),this);
106     gAlice->ReadEuclidMedia(filtmp,this);
107   } else {
108     Error("CreateMaterials"," THE MEDIA FILE %s DOES NOT EXIST !",
109 //        fEuclidMaterial.Data());
110           filtmp);
111     exit(1);
112   } // end if(file)
113 }
114
115 //_____________________________________________________________________________
116 void AliITSv5::CreateGeometry(){
117 //////////////////////////////////////////////////////////////////////
118 //    This is the geometry used for the ITS Pre-TDR and comes from an 
119 // Euclid to Geant conversion. The only difference
120 // is in the details of the ITS supports. The detectors elements, 
121 // detector numbering, and local and global reference frames are shown in
122 //  the following figures.
123 //Begin_Html
124 /*
125 <img src="picts/ITS/its1+2_convention_front_5.gif">
126 </pre>
127 <br clear=left>
128 <font size=+2 color=red>
129 <p>This shows the front view of the SPDs.
130 </font>
131 <pre>
132 <img src="picts/ITS/its1+2_convention_side_5.gif">
133 </pre>
134 <br clear=left>
135 <font size=+2 color=red>
136 <p>This shows the perspective view of the SPDs.
137 </font>
138 <img src="picts/ITS/its1+2_tree.gif">
139 </pre>
140 <br clear=left>
141 <font size=+2 color=red>
142 <p>This shows the geometry Tree for the SPDs.
143 </font>
144 <pre>
145
146 <pre>
147 <img src="picts/ITS/its3+4_convention_front_5.gif">
148 </pre>
149 <br clear=left>
150 <font size=+2 color=red>
151 <p>This shows the front view of the SDDs.
152 </font>
153 <pre>
154 <img src="picts/ITS/its3+4_convention_side_5.gif">
155 </pre>
156 <br clear=left>
157 <font size=+2 color=red>
158 <p>This shows the perspective view of the SDDs.
159 </font>
160 <img src="picts/ITS/its3+4_tree.gif">
161 </pre>
162 <br clear=left>
163 <font size=+2 color=red>
164 <p>This shows the geometry Tree for the SDDs.
165 </font>
166 <pre>
167
168 <pre>
169 <img src="picts/ITS/its5+6_convention_front_5.gif">
170 </pre>
171 <br clear=left>
172 <font size=+2 color=red>
173 <p>This shows the front view of the SSDs.
174 </font>
175 <pre>
176 <img src="picts/ITS/its5+6_convention_side_5.gif">
177 </pre>
178 <br clear=left>
179 <font size=+2 color=red>
180 <p>This shows the perspective view of the SSDs.
181 </font>
182 <pre>
183 <img src="picts/ITS/its5+6_tree.gif">
184 </pre>
185 <br clear=left>
186 <font size=+2 color=red>
187 <p>This shows the geometry Tree for the SSDs.
188 </font>
189 <pre>
190
191
192 <img src="picts/ITS/its_layer1-6_2.gif">
193 </pre>
194 <br clear=left>
195 <font size=+2 color=red>
196 <p>This shows the front view of the whole ITS..
197 </font>
198 <pre>
199
200 <img src="picts/ITS/its_layer1-6_1.gif">
201 </pre>
202 <br clear=left>
203 <font size=+2 color=red>
204 <p>This shows the perspective view of the whole ITS..
205 </font>
206 <pre>
207
208 <img src="picts/ITS/its1-6_tree.gif">
209 </pre>
210 <br clear=left>
211 <font size=+2 color=red>
212 <p>This shows the geometry Tree for the whole ITS.
213 </font>
214 <pre>
215 */
216 //End_Html
217 //
218 //
219 //      Here are shown the details of the ITS support cones and services.
220 // First is a GEANT tree showing the organization of all of the volumes
221 // that make up the ITS supports and services.
222 //Begin_Html
223 /*
224 <img src="picts/ITS/supports_tree.gif">
225  */
226 //End_Html
227 //     What follows are a number of figures showing what these support
228 // structures look like.
229 //Begin_Html
230 /*
231
232 <img src="picts/ITS/supports_3.gif">
233 </pre>
234 <br clear=left>
235 <font size=+2 color=red>
236 <p>This shows the geometry of the supports for the Drift and Strip layers only.
237 </font>
238 <pre>
239
240 <img src="picts/ITS/supports_2.gif">
241 </pre>
242 <br clear=left>
243 <font size=+2 color=red>
244 <p>This shows the geometry of the supports for the Drift and Strip layers in front cut out.
245 </font>
246 <pre>
247
248 <img src="picts/ITS/supports_1.gif">
249 </pre>
250 <br clear=left>
251 <font size=+2 color=red>
252 <p>This shows the geometry of the supports for the Drift and Strip layers in a back cut out..
253 </font>
254 <pre>
255
256 <img src="picts/ITS/suppssd.gif">
257 </pre>
258 <br clear=left>
259 <font size=+2 color=red>
260 <p>This shows the geometry for the Strip layers supports.
261 </font>
262 <pre>
263
264 <img src="picts/ITS/suppsdd.gif">
265 </pre>
266 <br clear=left>
267 <font size=+2 color=red>
268 <p>This shows the geometry for the Drift layers supports.
269 </font>
270 <pre>
271  */
272 //End_Html
273 ////////////////////////////////////////////////////////////////////////
274 // Read geometry for the ITS
275 //
276
277     Int_t size;
278     char topvol[5];
279     char *filtmp;
280 //
281   filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
282   FILE *file = fopen(filtmp,"r");
283   delete [] filtmp;
284   if(file) {
285     fclose(file);
286     printf("Ready to read Euclid geometry file\n");
287     gAlice->ReadEuclid(fEuclidGeometry.Data(),this,topvol);
288     printf("Read in euclid geometries\n");
289   } else {
290     Error("CreateGeometry"," THE GEOM FILE %s DOES NOT EXIST !",
291           fEuclidGeometry.Data());
292     exit(1);
293   } // end if(file)
294   //
295   //---Place the ITS ghost volume ITSV in its mother volume (ALIC) and make it
296   //     invisible
297   //
298   gMC->Gspos("ITSV",1,"ALIC",0,0,0,0,"ONLY");
299   //
300   //---Outputs the geometry tree in the EUCLID/CAD format
301   
302     if (fEuclidOut) {
303       gMC->WriteEuclid("ITSgeometry", "ITSV", 1, 5);
304     } // end if (fEuclidOut)
305
306     filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
307     size = strlen(filtmp);
308     if(size>4){
309         filtmp[size-3] = 'd'; // change from .euc to .det
310         filtmp[size-2] = 'e';
311         filtmp[size-1] = 't';
312         file = fopen(filtmp,"r");
313         if(file){ // if file exists use it to fill AliITSgeom structure.
314             fclose(file);
315             printf("ready to read .det file %s\n",filtmp);
316             fITSgeom = new AliITSgeom(filtmp);
317         }else{
318             fITSgeom = 0;
319             // fill AliITSgeom structure from geant structure just filled above
320         }// end if(file)
321         delete [] filtmp;
322     }// end if(size>4)
323     printf("finished with euclid geometrys\n");
324 }
325
326 //_____________________________________________________________________________
327 void AliITSv5::Init(){
328     //
329     // Initialise the ITS after it has been created
330     //
331     Int_t i,j,l;
332
333     fIdN    = fId5N;
334     fIdName = new char*[fId5N];
335     fIdSens = new Int_t[fId5N];
336     for(i=0;i<fId5N;i++) {
337         l = strlen(fId5Name[i]);
338         fIdName[i] = new char[l+1];
339         for(j=0;j<l;j++) fIdName[i][j] = fId5Name[i][j];
340         fIdName[i][l] = '\0'; // Null terminate this string.
341     } // end for i
342
343     AliITS::Init();
344
345  
346 //_____________________________________________________________________________
347 void AliITSv5::StepManager(){
348   //
349   // Called for every step in the ITS
350   //
351   Int_t          copy, id;
352   Int_t          copy1,copy2;
353   Float_t        hits[8];
354   Int_t          vol[4];
355   TLorentzVector position, momentum;
356   TClonesArray   &lhits = *fHits;
357   //
358   // Track status
359   vol[3] = 0;
360   if(gMC->IsTrackInside())      vol[3] +=  1;
361   if(gMC->IsTrackEntering())    vol[3] +=  2;
362   if(gMC->IsTrackExiting())     vol[3] +=  4;
363   if(gMC->IsTrackOut())         vol[3] +=  8;
364   if(gMC->IsTrackDisappeared()) vol[3] += 16;
365   if(gMC->IsTrackStop())        vol[3] += 32;
366   if(gMC->IsTrackAlive())       vol[3] += 64;
367   //
368   // Fill hit structure.
369   if(!(gMC->TrackCharge())) return;
370   //
371   // Only entering charged tracks
372   if((id = gMC->CurrentVolID(copy)) == fIdSens[0]) {
373       vol[0] = 1;
374       id = gMC->CurrentVolOffID(0,copy);
375       //detector copy in the ladder = 1<->4  (ITS1)
376       vol[1] = copy;
377       gMC->CurrentVolOffID(1,copy1);
378       //ladder copy in the module   = 1<->2  (I186)
379       gMC->CurrentVolOffID(2,copy2);
380       //module copy in the layer    = 1<->10 (I132)
381       vol[2] = copy1+(copy2-1)*2;//# of ladders in one module  = 2
382   } else if(id == fIdSens[1]){
383       vol[0] = 2;
384       id = gMC->CurrentVolOffID(0,copy);
385       //detector copy in the ladder = 1<->4  (ITS2)
386       vol[1] = copy;
387       gMC->CurrentVolOffID(1,copy1);
388       //ladder copy in the module   = 1<->4  (I131)
389       gMC->CurrentVolOffID(2,copy2);
390       //module copy in the layer    = 1<->10 (I132)
391       vol[2] = copy1+(copy2-1)*4;//# of ladders in one module  = 4
392   } else if(id == fIdSens[2]){
393       vol[0] = 3;
394       id = gMC->CurrentVolOffID(1,copy);
395       //detector copy in the ladder = 1<->5  (ITS3 is inside I314)
396       vol[1] = copy;
397       id = gMC->CurrentVolOffID(2,copy);
398       //ladder copy in the layer    = 1<->12 (I316)
399       vol[2] = copy;
400   } else if(id == fIdSens[3]){
401       vol[0] = 4;
402       id = gMC->CurrentVolOffID(1,copy);
403       //detector copy in the ladder = 1<->8  (ITS4 is inside I414)
404       vol[1] = copy;
405       id = gMC->CurrentVolOffID(2,copy);
406       //ladder copy in the layer    = 1<->22 (I417)
407       vol[2] = copy;
408   }else if(id == fIdSens[4]){
409       vol[0] = 5;
410       id = gMC->CurrentVolOffID(1,copy);
411       //detector copy in the ladder = 1<->23  (ITS5 is inside I562)
412       vol[1] = copy;
413       id = gMC->CurrentVolOffID(2,copy);
414      //ladder copy in the layer    = 1<->34 (I565)
415       vol[2] = copy;
416   }else if(id == fIdSens[5]){
417       vol[0] = 6;
418       id = gMC->CurrentVolOffID(1,copy);
419       //detector copy in the ladder = 1<->26  (ITS6 is inside I566)
420       vol[1] = copy;
421       id = gMC->CurrentVolOffID(2,copy);
422       //ladder copy in the layer = 1<->38 (I569)
423       vol[2] = copy;
424   } else {
425       return; // not an ITS volume?
426   } // end if/else if (gMC->CurentVolID(copy) == fIdSens[i])
427 //
428   gMC->TrackPosition(position);
429   gMC->TrackMomentum(momentum);
430   hits[0]=position[0];
431   hits[1]=position[1];
432   hits[2]=position[2];
433   hits[3]=momentum[0];
434   hits[4]=momentum[1];
435   hits[5]=momentum[2];
436   hits[6]=gMC->Edep();
437   hits[7]=gMC->TrackTime();
438   // Fill hit structure with this new hit.
439   new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->CurrentTrack(),vol,hits);
440   return;
441 }
442 //____________________________________________________________________________
443 void AliITSv5::Streamer(TBuffer &R__b)
444 {
445    // Stream an object of class AliITSv5.
446
447    if (R__b.IsReading()) {
448       Version_t R__v = R__b.ReadVersion(); if (R__v) { }
449       AliITS::Streamer(R__b);
450       // This information does not need to be read. It is "hard wired"
451       // into this class via its creators.
452       //R__b >> fId5N;
453       //R__b.ReadArray(fId5Name);
454    } else {
455       R__b.WriteVersion(AliITSv5::IsA());
456       AliITS::Streamer(R__b);
457       // This information does not need to be saved. It is "hard wired"
458       // into this class via its creators.
459       //R__b << fId5N;
460       //R__b.WriteArray(fId5Name, __COUNTER__);
461    }
462 }
463