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