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