]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSv5.cxx
38df7059cd0646f6335ba69c803077b8e0c1efb6
[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.15  2000/02/23 16:25:21  fca
19 AliVMC and AliGeant3 classes introduced
20 ReadEuclid moved from AliRun to AliModule
21
22 Revision 1.14.4.3  2000/03/04 23:46:38  nilsen
23 Fixed up the comments/documentation.
24
25 Revision 1.14.4.2  2000/03/02 21:53:02  nilsen
26 To make it compatable with the changes in AliRun/AliModule.
27
28 Revision 1.14.4.1  2000/01/12 19:03:33  nilsen
29 This is the version of the files after the merging done in December 1999.
30 See the ReadMe110100.txt file for details
31
32 Revision 1.14  1999/10/22 08:16:49  fca
33 Correct destructors, thanks to I.Hrivnacova
34
35 Revision 1.13  1999/10/06 10:15:19  fca
36 Correct bug in allocation of layer name and add destructor
37
38 Revision 1.12  1999/10/05 08:05:09  fca
39 Minor corrections for uninitialised variables.
40
41 Revision 1.11  1999/09/29 09:24:20  fca
42 Introduction of the Copyright and cvs Log
43
44 */
45
46 ///////////////////////////////////////////////////////////////////////////////
47 //
48 //  Inner Traking System version 5
49 //  This class contains the base procedures for the Inner Tracking System
50 //
51 // Authors: R. Barbera, B. S. Nilsen.
52 // version 5.
53 // Created September 17 1999.
54 //
55 ///////////////////////////////////////////////////////////////////////////////
56
57 // See AliITSv5::StepManager().
58 #define ALIITSPRINTGEOM 0 // default. don't print out gemetry information
59 //#define ALIITSPRINTGEOM 1 // print out geometry information
60
61 #include <stdio.h>
62 #include <stdlib.h>
63 #include <TMath.h>
64
65 #include "AliRun.h"
66 #include "TSystem.h"
67 #if ALIITSPRINTGEOM==1
68 #include "../TGeant3/TGeant3.h"
69 #endif
70 #include "AliITShit.h"
71 #include "AliITS.h"
72 #include "AliITSv5.h"
73 #include "AliITSgeom.h"
74
75 ClassImp(AliITSv5)
76  
77 //_____________________________________________________________________________
78 AliITSv5::AliITSv5() {
79 ////////////////////////////////////////////////////////////////////////
80 //    Standard default constructor for the ITS version 5.
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 //_____________________________________________________________________________
92 AliITSv5::~AliITSv5() {
93 ////////////////////////////////////////////////////////////////////////
94 //    Standard destructor for the ITS version 5.
95 ////////////////////////////////////////////////////////////////////////
96   delete [] fId5Name;
97 }
98 //_____________________________________________________________________________
99 AliITSv5::AliITSv5(const char *name, const char *title) : AliITS(name, title){
100 ////////////////////////////////////////////////////////////////////////
101 //    Standard constructor for the ITS version 5.
102 ////////////////////////////////////////////////////////////////////////
103     fId5N = 6;
104     fId5Name = new char*[fId5N];
105     fId5Name[0] = "ITS1";
106     fId5Name[1] = "ITS2";
107     fId5Name[2] = "ITS3";
108     fId5Name[3] = "ITS4";
109     fId5Name[4] = "ITS5";
110     fId5Name[5] = "ITS6";
111
112     fEuclidMaterial = "$ALICE_ROOT/Euclid/ITSgeometry_5.tme";
113     fEuclidGeometry = "$ALICE_ROOT/Euclid/ITSgeometry_5.euc";
114
115 //_____________________________________________________________________________
116 void AliITSv5::CreateMaterials(){
117 ////////////////////////////////////////////////////////////////////////
118 //     Read a file containing the materials for the ITS version 5.
119 ////////////////////////////////////////////////////////////////////////
120     char *filtmp;
121
122   filtmp = gSystem->ExpandPathName(fEuclidMaterial.Data());
123
124   FILE *file = fopen(filtmp,"r");
125   if(file) {
126     fclose(file);
127     ReadEuclidMedia(filtmp);
128   } else {
129     Error("CreateMaterials"," THE MEDIA FILE %s DOES NOT EXIST !",filtmp);
130     exit(1);
131   } // end if(file)
132 }
133 //_____________________________________________________________________________
134 void AliITSv5::CreateGeometry(){
135 //////////////////////////////////////////////////////////////////////
136 //    This is the geometry used for the ITS Pre-TDR and comes from an 
137 // Euclid to Geant conversion. The only difference
138 // is in the details of the ITS supports. The detectors elements, 
139 // detector numbering, and local and global reference frames are shown in
140 //  the following figures.
141 //Begin_Html
142 /*
143 <img src="picts/ITS/its1+2_convention_front_5.gif">
144 </pre>
145 <br clear=left>
146 <font size=+2 color=red>
147 <p>This shows the front view of the SPDs.
148 </font>
149 <pre>
150 <img src="picts/ITS/its1+2_convention_side_5.gif">
151 </pre>
152 <br clear=left>
153 <font size=+2 color=red>
154 <p>This shows the perspective view of the SPDs.
155 </font>
156 <img src="picts/ITS/its1+2_tree.gif">
157 </pre>
158 <br clear=left>
159 <font size=+2 color=red>
160 <p>This shows the geometry Tree for the SPDs.
161 </font>
162 <pre>
163
164 <pre>
165 <img src="picts/ITS/its3+4_convention_front_5.gif">
166 </pre>
167 <br clear=left>
168 <font size=+2 color=red>
169 <p>This shows the front view of the SDDs.
170 </font>
171 <pre>
172 <img src="picts/ITS/its3+4_convention_side_5.gif">
173 </pre>
174 <br clear=left>
175 <font size=+2 color=red>
176 <p>This shows the perspective view of the SDDs.
177 </font>
178 <img src="picts/ITS/its3+4_tree.gif">
179 </pre>
180 <br clear=left>
181 <font size=+2 color=red>
182 <p>This shows the geometry Tree for the SDDs.
183 </font>
184 <pre>
185
186 <pre>
187 <img src="picts/ITS/its5+6_convention_front_5.gif">
188 </pre>
189 <br clear=left>
190 <font size=+2 color=red>
191 <p>This shows the front view of the SSDs.
192 </font>
193 <pre>
194 <img src="picts/ITS/its5+6_convention_side_5.gif">
195 </pre>
196 <br clear=left>
197 <font size=+2 color=red>
198 <p>This shows the perspective view of the SSDs.
199 </font>
200 <pre>
201 <img src="picts/ITS/its5+6_tree.gif">
202 </pre>
203 <br clear=left>
204 <font size=+2 color=red>
205 <p>This shows the geometry Tree for the SSDs.
206 </font>
207 <pre>
208
209
210 <img src="picts/ITS/its_layer1-6_2.gif">
211 </pre>
212 <br clear=left>
213 <font size=+2 color=red>
214 <p>This shows the front view of the whole ITS..
215 </font>
216 <pre>
217
218 <img src="picts/ITS/its_layer1-6_1.gif">
219 </pre>
220 <br clear=left>
221 <font size=+2 color=red>
222 <p>This shows the perspective view of the whole ITS..
223 </font>
224 <pre>
225
226 <img src="picts/ITS/its1-6_tree.gif">
227 </pre>
228 <br clear=left>
229 <font size=+2 color=red>
230 <p>This shows the geometry Tree for the whole ITS.
231 </font>
232 <pre>
233 */
234 //End_Html
235 //
236 //
237 //      Here are shown the details of the ITS support cones and services.
238 // First is a GEANT tree showing the organization of all of the volumes
239 // that make up the ITS supports and services.
240 //Begin_Html
241 /*
242 <img src="picts/ITS/supports_tree.gif">
243  */
244 //End_Html
245 //     What follows are a number of figures showing what these support
246 // structures look like.
247 //Begin_Html
248 /*
249
250 <img src="picts/ITS/supports_3.gif">
251 </pre>
252 <br clear=left>
253 <font size=+2 color=red>
254 <p>This shows the geometry of the supports for the Drift and Strip layers only.
255 </font>
256 <pre>
257
258 <img src="picts/ITS/supports_2.gif">
259 </pre>
260 <br clear=left>
261 <font size=+2 color=red>
262 <p>This shows the geometry of the supports for the Drift and Strip layers in front cut out.
263 </font>
264 <pre>
265
266 <img src="picts/ITS/supports_1.gif">
267 </pre>
268 <br clear=left>
269 <font size=+2 color=red>
270 <p>This shows the geometry of the supports for the Drift and Strip layers in a back cut out..
271 </font>
272 <pre>
273
274 <img src="picts/ITS/suppssd.gif">
275 </pre>
276 <br clear=left>
277 <font size=+2 color=red>
278 <p>This shows the geometry for the Strip layers supports.
279 </font>
280 <pre>
281
282 <img src="picts/ITS/suppsdd.gif">
283 </pre>
284 <br clear=left>
285 <font size=+2 color=red>
286 <p>This shows the geometry for the Drift layers supports.
287 </font>
288 <pre>
289  */
290 //End_Html
291 //
292 //    Read a file containing the geometry for the ITS version 5.
293 ////////////////////////////////////////////////////////////////////////
294
295     Int_t size;
296     char topvol[5];
297     char *filtmp;
298
299   filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
300   FILE *file = fopen(filtmp,"r");
301   delete [] filtmp;
302   if(file) {
303     fclose(file);
304     printf("Ready to read Euclid geometry file\n");
305     ReadEuclid(fEuclidGeometry.Data(),topvol);
306     printf("Read in euclid geometries\n");
307   } else {
308     Error("CreateGeometry"," THE GEOM FILE %s DOES NOT EXIST !",
309           fEuclidGeometry.Data());
310     exit(1);
311   } // end if(file)
312   //
313   // Place the ITS ghost volume ITSV in its mother volume (ALIC) and make it
314   // invisible
315   //
316   gMC->Gspos("ITSV",1,"ALIC",0,0,0,0,"ONLY");
317   //
318   // Outputs the geometry tree in the EUCLID/CAD format if requested to do so
319   
320     if (fEuclidOut) {
321       gMC->WriteEuclid("ITSgeometry", "ITSV", 1, 5);
322     } // end if (fEuclidOut)
323
324     // read in the file containing the transformations for the active
325     // volumes for the ITS version 5. This is expected to be in a file
326     // ending in .det. This geometry is kept in the AliITSgeom class.
327     filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
328     size = strlen(filtmp);
329     if(size>4){
330         filtmp[size-3] = 'd'; // change from .euc to .det
331         filtmp[size-2] = 'e';
332         filtmp[size-1] = 't';
333         file = fopen(filtmp,"r");
334         if(file){ // if file exists use it to fill AliITSgeom structure.
335             fclose(file);
336             printf("ready to read .det file %s\n",filtmp);
337             fITSgeom = new AliITSgeom(filtmp);
338         }else{
339             fITSgeom = 0;
340             // fill AliITSgeom structure from geant structure just filled above
341         }// end if(file)
342         delete [] filtmp;
343     }// end if(size>4)
344     printf("finished with euclid geometrys\n");
345 }
346 //_____________________________________________________________________________
347 void AliITSv5::Init(){
348 ////////////////////////////////////////////////////////////////////////
349 //     Initialise the ITS after it has been created.
350 ////////////////////////////////////////////////////////////////////////
351     Int_t i,j,l;
352
353     fIdN    = fId5N;
354     fIdName = new char*[fId5N];
355     fIdSens = new Int_t[fId5N];
356     for(i=0;i<fId5N;i++) {
357         l = strlen(fId5Name[i]);
358         fIdName[i] = new char[l+1];
359         for(j=0;j<l;j++) fIdName[i][j] = fId5Name[i][j];
360         fIdName[i][l] = '\0'; // Null terminate this string.
361     } // end for i
362
363     AliITS::Init();
364
365 //_____________________________________________________________________________
366 void AliITSv5::StepManager(){
367 ////////////////////////////////////////////////////////////////////////
368 //    Called for every step in the ITS, then calles the AliITShit class
369 // creator with the information to be recoreded about that hit.
370 //     The value of the macro ALIITSPRINTGEOM if set to 1 will allow the
371 // printing of information to a file which can be used to create a .det
372 // file read in by the routine CreateGeometry(). If set to 0 or any other
373 // value except 1, the default behavior, then no such file is created nor
374 // it the extra variables and the like used in the printing allocated.
375 ////////////////////////////////////////////////////////////////////////
376   Int_t          copy, id;
377   Int_t          copy1,copy2;
378   Float_t        hits[8];
379   Int_t          vol[4];
380   TLorentzVector position, momentum;
381   TClonesArray   &lhits = *fHits;
382 #if ALIITSPRINTGEOM==1
383   FILE          *fp;
384   Int_t         i;
385   Float_t       xl[3],xt[3],angl[6];
386 //  Float_t       par[20],att[20];
387   Float_t      mat[9];
388   static Bool_t first=kTRUE,printit[6][50][50];
389   if(first){ for(copy1=0;copy1<6;copy1++)for(copy2=0;copy2<50;copy2++)
390       for(id=0;id<50;id++) printit[copy1][copy2][id] = kTRUE;
391   first = kFALSE;
392   }
393   // end if first
394 #endif
395   //
396   // Track status
397   vol[3] = 0;
398   if(gMC->IsTrackInside())      vol[3] +=  1;
399   if(gMC->IsTrackEntering())    vol[3] +=  2;
400   if(gMC->IsTrackExiting())     vol[3] +=  4;
401   if(gMC->IsTrackOut())         vol[3] +=  8;
402   if(gMC->IsTrackDisappeared()) vol[3] += 16;
403   if(gMC->IsTrackStop())        vol[3] += 32;
404   if(gMC->IsTrackAlive())       vol[3] += 64;
405   //
406   // Fill hit structure.
407   if(!(gMC->TrackCharge())) return;
408   //
409   // Only entering charged tracks
410   if((id = gMC->CurrentVolID(copy)) == fIdSens[0]) {
411       vol[0] = 1;
412       id = gMC->CurrentVolOffID(0,copy);
413       //detector copy in the ladder = 1<->4  (ITS1)
414       vol[1] = copy;
415       gMC->CurrentVolOffID(1,copy1);
416       //ladder copy in the module   = 1<->2  (I186)
417       gMC->CurrentVolOffID(2,copy2);
418       //module copy in the layer    = 1<->10 (I132)
419       vol[2] = copy1+(copy2-1)*2;//# of ladders in one module  = 2
420   } else if(id == fIdSens[1]){
421       vol[0] = 2;
422       id = gMC->CurrentVolOffID(0,copy);
423       //detector copy in the ladder = 1<->4  (ITS2)
424       vol[1] = copy;
425       gMC->CurrentVolOffID(1,copy1);
426       //ladder copy in the module   = 1<->4  (I131)
427       gMC->CurrentVolOffID(2,copy2);
428       //module copy in the layer    = 1<->10 (I132)
429       vol[2] = copy1+(copy2-1)*4;//# of ladders in one module  = 4
430   } else if(id == fIdSens[2]){
431       vol[0] = 3;
432       id = gMC->CurrentVolOffID(1,copy);
433       //detector copy in the ladder = 1<->5  (ITS3 is inside I314)
434       vol[1] = copy;
435       id = gMC->CurrentVolOffID(2,copy);
436       //ladder copy in the layer    = 1<->12 (I316)
437       vol[2] = copy;
438   } else if(id == fIdSens[3]){
439       vol[0] = 4;
440       id = gMC->CurrentVolOffID(1,copy);
441       //detector copy in the ladder = 1<->8  (ITS4 is inside I414)
442       vol[1] = copy;
443       id = gMC->CurrentVolOffID(2,copy);
444       //ladder copy in the layer    = 1<->22 (I417)
445       vol[2] = copy;
446   }else if(id == fIdSens[4]){
447       vol[0] = 5;
448       id = gMC->CurrentVolOffID(1,copy);
449       //detector copy in the ladder = 1<->23  (ITS5 is inside I562)
450       vol[1] = copy;
451       id = gMC->CurrentVolOffID(2,copy);
452      //ladder copy in the layer    = 1<->34 (I565)
453       vol[2] = copy;
454   }else if(id == fIdSens[5]){
455       vol[0] = 6;
456       id = gMC->CurrentVolOffID(1,copy);
457       //detector copy in the ladder = 1<->26  (ITS6 is inside I566)
458       vol[1] = copy;
459       id = gMC->CurrentVolOffID(2,copy);
460       //ladder copy in the layer = 1<->38 (I569)
461       vol[2] = copy;
462   } else {
463       return; // not an ITS volume?
464   } // end if/else if (gMC->CurentVolID(copy) == fIdSens[i])
465 //
466   gMC->TrackPosition(position);
467   gMC->TrackMomentum(momentum);
468   hits[0]=position[0];
469   hits[1]=position[1];
470   hits[2]=position[2];
471   hits[3]=momentum[0];
472   hits[4]=momentum[1];
473   hits[5]=momentum[2];
474   hits[6]=gMC->Edep();
475   hits[7]=gMC->TrackTime();
476   // Fill hit structure with this new hit.
477   new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->CurrentTrack(),vol,hits);
478 #if ALIITSPRINTGEOM==1
479   if(printit[vol[0]][vol[2]][vol[1]]){
480       printit[vol[0]][vol[2]][vol[1]] = kFALSE;
481       xl[0] = xl[1] = xl[2] = 0.0;
482       gMC->Gdtom(xl,xt,1);
483       for(i=0;i<9;i++) mat[i] = 0.0;
484       mat[0] = mat[4] = mat[8] = 1.0;  // default with identity matrix
485       xl[0] = 1.0;
486       xl[1] = xl[2] =0.0;
487       gMC->Gdtom(xl,&(mat[0]),2);
488       xl[1] = 1.0;
489       xl[0] = xl[2] =0.0;
490       gMC->Gdtom(xl,&(mat[3]),2);
491       xl[2] = 1.0;
492       xl[1] = xl[0] =0.0;
493       gMC->Gdtom(xl,&(mat[6]),2);
494
495       angl[0] = TMath::ACos(mat[2]);
496       if(mat[2]==1.0) angl[0] = 0.0;
497       angl[1] = TMath::ATan2(mat[1],mat[0]);
498       if(angl[1]<0.0) angl[1] += 2.0*TMath::Pi();
499
500       angl[2] = TMath::ACos(mat[5]);
501       if(mat[5]==1.0) angl[2] = 0.0;
502       angl[3] = TMath::ATan2(mat[4],mat[3]);
503       if(angl[3]<0.0) angl[3] += 2.0*TMath::Pi();
504
505       angl[4] = TMath::ACos(mat[8]);
506       if(mat[8]==1.0) angl[4] = 0.0;
507       angl[5] = TMath::ATan2(mat[7],mat[6]);
508       if(angl[5]<0.0) angl[5] += 2.0*TMath::Pi();
509
510       for(i=0;i<6;i++) angl[i] *= 180.0/TMath::Pi(); // degrees
511       fp = fopen("ITSgeometry_v5.det","a");
512       fprintf(fp,"%2d %2d %2d %9e %9e %9e %9e %9e %9e %9e %9e %9e ",
513               vol[0],vol[2],vol[1], // layer ladder detector
514               xt[0],xt[1],xt[2],    // Translation vector
515               angl[0],angl[1],angl[2],angl[3],angl[4],angl[5] // Geant rotaion
516                                                            // angles (degrees)
517               );
518       fprintf(fp,"%9e %9e %9e %9e %9e %9e %9e %9e %9e",
519              mat[0],mat[1],mat[2],mat[3],mat[4],mat[5],mat[6],mat[7],mat[8]
520           );  // Adding the rotation matrix.
521       fprintf(fp,"\n");
522       fclose(fp);
523   } // end if printit[layer][ladder][detector]
524 #endif
525   return;
526 }
527 //____________________________________________________________________________
528 void AliITSv5::Streamer(TBuffer &R__b){
529 ////////////////////////////////////////////////////////////////////////
530 //    A dummy Streamer function for this class AliITSv5. By default it
531 // only streams the AliITS class as it is required. Since this class
532 // dosen't contain any "real" data to be saved, it doesn't.
533 ////////////////////////////////////////////////////////////////////////
534    if (R__b.IsReading()) {
535       Version_t R__v = R__b.ReadVersion(); 
536       if (R__v==1) {
537           AliITS::Streamer(R__b);
538           // This information does not need to be read. It is "hard wired"
539           // into this class via its creators.
540           //R__b >> fId5N;
541           //R__b.ReadArray(fId5Name);
542       }else{
543       } // end if R__v==1
544    } else {
545       R__b.WriteVersion(AliITSv5::IsA());
546       AliITS::Streamer(R__b);
547       // This information does not need to be saved. It is "hard wired"
548       // into this class via its creators.
549       //R__b << fId5N;
550       //R__b.WriteArray(fId5Name, __COUNTER__);
551    } // end if R__b.IsReading()
552 }
553