]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSv11.cxx
cea5780687ff22abaab81652b89d72d3eda6b531
[u/mrichter/AliRoot.git] / ITS / AliITSv11.cxx
1 /**************************************************************************
2  * Copyright(c) 2007-2008, 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 //************************************************************************
18 //
19 //                 Inner Traking System geometry v11
20 //
21 //  Based on ROOT geometrical modeler
22 //
23 // B. Nilsen, L. Gaudichet
24 //************************************************************************
25
26 #include <TClonesArray.h>
27 #include <TGeoManager.h>
28 #include <TGeoPcon.h>
29 #include <TGeoVolume.h>
30 #include <TLorentzVector.h>
31 #include <TVirtualMC.h>
32
33 #include "AliITS.h"
34 #include "AliITSCalibrationSDD.h"
35 #include "AliITSDetTypeSim.h"
36 #include "AliITShit.h"
37 #include "AliITSsegmentationSDD.h"
38 #include "AliITSsegmentationSPD.h"
39 #include "AliITSsegmentationSSD.h"
40 #include "AliITSv11.h"
41 #include "AliITSv11GeometrySDD.h"
42 #include "AliITSv11GeometrySPD.h"
43 #include "AliITSv11GeometrySSD.h"
44 #include "AliITSv11GeometrySupport.h"
45 #include "AliMC.h"
46 #include "AliMagF.h"
47 #include "AliRun.h"
48 #include "AliTrackReference.h"
49
50 ClassImp(AliITSv11)
51  
52 //______________________________________________________________________
53 AliITSv11::AliITSv11() : 
54 fByThick(kTRUE),
55 fMajorVersion(IsVersion()),
56 fMinorVersion(0),
57 fSPDgeom(),
58 fSDDgeom(0),
59 fSSDgeom(),
60 fSupgeom(),
61 fIgm(kv11)
62 {
63   //    Standard default constructor for the ITS version 11.
64
65     fIdN          = 0;
66     fIdName       = 0;
67     fIdSens       = 0;
68 }
69
70
71 //______________________________________________________________________
72 AliITSv11::AliITSv11(const char *name, const char *title): 
73 AliITS("ITS", title),
74 fByThick(kTRUE),
75 fMajorVersion(IsVersion()),
76 fMinorVersion(0),
77 fSPDgeom(),
78 fSDDgeom(0),
79 fSSDgeom(),
80 fSupgeom(),
81 fIgm(kv11)
82 {
83   //    Standard constructor for the ITS version 11.
84
85   fSDDgeom = new AliITSv11GeometrySDD(0);
86
87   Int_t i;
88   fIdN = 6;
89   fIdName = new TString[fIdN];
90   fIdName[0] = name; // removes warning message
91   fIdName[0] = "ITS1";
92   fIdName[1] = "ITS2";
93   fIdName[2] = fSDDgeom->GetSenstiveVolumeName3();
94   fIdName[3] = fSDDgeom->GetSenstiveVolumeName4();
95   fIdName[4] = "ITS5";
96   fIdName[5] = "ITS6";
97   fIdSens    = new Int_t[fIdN];
98   for(i=0;i<fIdN;i++) fIdSens[i] = 0;
99   // not needed, fByThick set to kTRUE in in the member initialization lis
100   
101 }
102 //______________________________________________________________________
103 AliITSv11::AliITSv11(Int_t /* debugITS */,Int_t debugSPD,Int_t debugSDD,
104                    Int_t debugSSD,Int_t debugSUP) :
105 AliITS("ITS","ITS geometry v11"),
106 fByThick(kTRUE),
107 fMajorVersion(IsVersion()),
108 fMinorVersion(0),
109 fSPDgeom(),
110 fSDDgeom(0),
111 fSSDgeom(),
112 fSupgeom(),
113 fIgm(kv11)
114 {
115   // Standard default constructor for the ITS version 11.
116
117
118   fSPDgeom = new AliITSv11GeometrySPD(debugSPD);
119   fSDDgeom = new AliITSv11GeometrySDD(debugSDD);
120   fSDDgeom->SetDebug(debugSDD);
121   fSSDgeom = new AliITSv11GeometrySSD();
122   fSSDgeom->SetDebug(debugSSD);
123   fSupgeom = new AliITSv11GeometrySupport(debugSUP);
124
125   Int_t i;
126   fIdN = 6;
127   fIdName = new TString[fIdN];
128   fIdName[0] = fSPDgeom->GetSenstiveVolumeName1();
129   fIdName[1] = fSPDgeom->GetSenstiveVolumeName2();
130   fIdName[2] = fSDDgeom->GetSenstiveVolumeName3();
131   fIdName[3] = fSDDgeom->GetSenstiveVolumeName4();
132   fIdName[4] = fSSDgeom->GetSenstiveVolumeName5();
133   fIdName[5] = fSSDgeom->GetSenstiveVolumeName6();
134   fIdSens    = new Int_t[fIdN];
135   for(i=0;i<fIdN;i++) fIdSens[i] = 0;
136   //  debugITS = (debugSPD && debugSSD && debugSUP && debugSDD); //remove temp. warnings
137 }
138 //______________________________________________________________________
139 AliITSv11::~AliITSv11() {
140   delete fSDDgeom;
141 }
142 //______________________________________________________________________
143 void AliITSv11::CreateGeometry(){
144     //
145     // Create ROOT geometry
146     //
147     // These constant character strings are set by cvs during commit
148     // do not change them unless you know what you are doing!
149     const Char_t *cvsDate="$Date$";
150     const Char_t *cvsRevision="$Revision$";
151
152     TGeoManager *geoManager = gGeoManager;
153     TGeoVolume *vALIC = geoManager->GetTopVolume();
154
155     TGeoPcon *sITS = new TGeoPcon("ITS Top Volume",0.0,360.0,2);
156
157     // DefineSection(section number, Z, Rmin, Rmax).
158     const Double_t kcm = 1.0;
159     sITS->DefineSection(0,-300.0*kcm,0.01*kcm,50.0*kcm);
160     sITS->DefineSection(1,+300.0*kcm,0.01*kcm,50.0*kcm);
161
162     TGeoMedium *air = gGeoManager->GetMedium("ITS_AIR$");
163     TGeoVolume *vITS = new TGeoVolume("ITSV",sITS,air);
164     vITS->SetVisibility(kFALSE);
165     const Int_t length=100;
166     Char_t vstrng[length];
167     if(fIgm.WriteVersionString(vstrng,length,(AliITSVersion_t)IsVersion(),
168                                fMinorVersion,cvsDate,cvsRevision))
169         vITS->SetTitle(vstrng);
170     //printf("Title set to %s\n",vstrng);
171     vALIC->AddNode(vITS,1,0);
172
173 //   fSPDgeom->CenteralSPD(vITS);
174
175   fSDDgeom->Layer3(vITS);
176   fSDDgeom->Layer4(vITS);
177
178 //     fSupgeom->SPDCone(vITS);
179 //     fSupgeom->SPDThermalSheald(vITS);
180 //     fSupgeom->SDDCone(vITS);
181 //     fSupgeom->SSDCone(vITS);
182 //     fSupgeom->ServicesCableSupport(vITS);
183
184 }
185 //______________________________________________________________________
186 void AliITSv11::CreateMaterials(){
187     // Create Standard ITS Materials
188     // Inputs:
189     //  none.
190     // Outputs:
191     //  none.
192     // Return:
193     // none.
194
195     
196     //
197     fSPDgeom->AliITSv11Geometry::CreateDefaultMaterials();
198     // Detector specific material definistions
199     fSPDgeom->CreateMaterials();
200     fSDDgeom->CreateMaterials();
201     fSSDgeom->CreateMaterials();
202     fSupgeom->CreateMaterials();
203 }
204
205 //______________________________________________________________________
206 void AliITSv11::Init(){
207   //
208   //     Initialise the ITS after it has been created.
209   //
210
211   //AliInfo(Form("Minor version %d",fMinorVersion));
212     //
213     UpdateInternalGeometry();
214     AliITS::Init();
215
216 }
217
218 //______________________________________________________________________
219 void AliITSv11::SetDefaults(){
220   //
221   // Set response and segmentation models for SPD, SDD and SSD
222   //
223
224 //     if(!fDetTypeSim) fDetTypeSim = new AliITSDetTypeSim();
225 //     fDetTypeSim->SetITSgeom(GetITSgeom());
226     if(!fDetTypeSim) {
227       Warning("SetDefaults","Error fDetTypeSim not defined");
228       return;
229     }
230   
231     fDetTypeSim->ResetCalibrationArray();
232     fDetTypeSim->ResetSegmentation();
233     fDetTypeSim->SetDefaults();
234     
235     if(fgkNTYPES>3){
236         Warning("SetDefaults",
237                 "Only the four basic detector types are initialised!");
238     }// end if
239
240     
241     return;
242 }
243
244 // //______________________________________________________________________
245 // void AliITSv11::StepManager(){
246 //   //
247 //   //    Called for every step in the ITS, then calles the AliITShit class
248 //   // creator with the information to be recoreded about that hit.
249 //   //
250 //     Int_t         copy, id;
251 //     TLorentzVector position, momentum;
252 //     static TLorentzVector position0;
253 //     static Int_t stat0=0;
254
255 //     if(!(this->IsActive())){
256 //      return;
257 //     } // end if !Active volume.
258
259 //     if(!(gMC->TrackCharge())) return;
260
261 //     id=gMC->CurrentVolID(copy);
262
263 //     Bool_t sensvol = kFALSE;
264 //     for(Int_t kk=0;kk<6;kk++)if(id == fIdSens[kk])sensvol=kTRUE;
265 //     if(sensvol && (gMC->IsTrackExiting())){
266 //      copy = fTrackReferences->GetEntriesFast();
267 //      TClonesArray &lTR = *fTrackReferences;
268 //      // Fill TrackReference structure with this new TrackReference.
269 //      new(lTR[copy]) AliTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
270 //     } // if Outer ITS mother Volume
271
272
273 //     Int_t   copy1,copy2;  
274 //     Int_t   vol[5];
275 //     TClonesArray &lhits = *fHits;
276 //     //
277 //     // Track status
278 //     vol[3] = 0;
279 //     vol[4] = 0;
280 //     if(gMC->IsTrackInside())      vol[3] +=  1;
281 //     if(gMC->IsTrackEntering())    vol[3] +=  2;
282 //     if(gMC->IsTrackExiting())     vol[3] +=  4;
283 //     if(gMC->IsTrackOut())         vol[3] +=  8;
284 //     if(gMC->IsTrackDisappeared()) vol[3] += 16;
285 //     if(gMC->IsTrackStop())        vol[3] += 32;
286 //     if(gMC->IsTrackAlive())       vol[3] += 64;
287 //     //
288 //     // Fill hit structure.
289 //     if(!(gMC->TrackCharge())) return;
290 //     //
291 //     // Only entering charged tracks
292 //     if((id = gMC->CurrentVolID(copy)) == fIdSens[0]) {
293 //      vol[0] = 1;
294 //      id = gMC->CurrentVolOffID(2,copy);
295 //      //detector copy in the ladder = 1<->4  (ITS1 < I101 < I103 < I10A)
296 //      vol[1] = copy;
297 //      gMC->CurrentVolOffID(3,copy1);
298 //      //ladder copy in the module   = 1<->2  (I10A < I12A)
299 //      gMC->CurrentVolOffID(4,copy2);
300 //      //module copy in the layer    = 1<->10 (I12A < IT12)
301 //      vol[2] = copy1+(copy2-1)*2;//# of ladders in one module  = 2
302 //     } else if(id == fIdSens[1]){
303 //      vol[0] = 2;
304 //      id = gMC->CurrentVolOffID(2,copy);
305 //      //detector copy in the ladder = 1<->4  (ITS2 < I1D1 < I1D3 < I20A)
306 //      vol[1] = copy;
307 //      gMC->CurrentVolOffID(3,copy1);
308 //      //ladder copy in the module   = 1<->4  (I20A < I12A)
309 //      gMC->CurrentVolOffID(4,copy2);
310 //      //module copy in the layer    = 1<->10 (I12A < IT12)
311 //      vol[2] = copy1+(copy2-1)*4;//# of ladders in one module  = 4
312 //     } else if(id == fIdSens[2]){
313 //      vol[0] = 3;
314 //      id = gMC->CurrentVolOffID(1,copy);
315 //      //detector copy in the ladder = 1<->6  (ITS3 < I302 < I004)
316 //      vol[1] = copy;
317 //      id = gMC->CurrentVolOffID(2,copy);
318 //      //ladder copy in the layer    = 1<->14 (I004 < IT34)
319 //      vol[2] = copy;
320 //     } else if(id == fIdSens[3]){
321 //      vol[0] = 4;
322 //      id = gMC->CurrentVolOffID(1,copy);
323 //      //detector copy in the ladder = 1<->8  (ITS4 < I402 < I005)
324 //      vol[1] = copy;
325 //      id = gMC->CurrentVolOffID(2,copy);
326 //      //ladder copy in the layer    = 1<->22 (I005 < IT34))
327 //      vol[2] = copy;
328 //     }else if(id == fIdSens[4]){
329 //      vol[0] = 5;
330 //      id = gMC->CurrentVolOffID(1,copy);
331 //      //detector copy in the ladder = 1<->22  (ITS5 < I562 < I565)
332 //      vol[1] = copy;
333 //      id = gMC->CurrentVolOffID(2,copy);
334 //      //ladder copy in the layer    = 1<->34 (I565 < IT56)
335 //      vol[2] = copy;
336 //     }else if(id == fIdSens[5]){
337 //      vol[0] = 6;
338 //      id = gMC->CurrentVolOffID(1,copy);
339 //      //detector copy in the ladder = 1<->25  (ITS6 < I566 < I569)
340 //      vol[1] = copy;
341 //      id = gMC->CurrentVolOffID(2,copy);
342 //      //ladder copy in the layer = 1<->38 (I569 < IT56)
343 //      vol[2] = copy;
344 //     } else {
345 //      return; // not an ITS volume?
346 //     } // end if/else if (gMC->CurentVolID(copy) == fIdSens[i])
347 //     //
348 //     gMC->TrackPosition(position);
349 //     gMC->TrackMomentum(momentum);
350 //     vol[4] = stat0;
351 //     if(gMC->IsTrackEntering()){
352 //      position0 = position;
353 //      stat0 = vol[3];
354 //      return;
355 //     } // end if IsEntering
356 //     // Fill hit structure with this new hit.
357     
358 //     new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,
359 //                                 gMC->Edep(),gMC->TrackTime(),position,
360 //                                 position0,momentum);
361
362 //     position0 = position;
363 //     stat0 = vol[3];
364
365 //     return;
366 // }
367
368
369 //______________________________________________________________________
370 void AliITSv11::StepManager(){
371   //
372   //    Called for every step in the ITS, then calles the AliITShit class
373   // creator with the information to be recoreded about that hit.
374   //
375     Int_t         copy, id;
376     TLorentzVector position, momentum;
377     static TLorentzVector position0;
378     static Int_t stat0=0;
379
380     if(!(this->IsActive())){
381         return;
382     } // end if !Active volume.
383
384     if(!(gMC->TrackCharge())) return;
385
386     id=gMC->CurrentVolID(copy);
387
388     Bool_t sensvol = kFALSE;
389     for(Int_t kk=0;kk<6;kk++)if(id == fIdSens[kk])sensvol=kTRUE;
390     if(sensvol && (gMC->IsTrackExiting())){
391         AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber(), AliTrackReference::kITS);
392     } // if Outer ITS mother Volume
393
394
395     Int_t   copy1,copy2;  
396     Int_t   vol[5];
397     TClonesArray &lhits = *fHits;
398     //
399     // Track status
400     vol[3] = 0;
401     vol[4] = 0;
402     if(gMC->IsTrackInside())      vol[3] +=  1;
403     if(gMC->IsTrackEntering())    vol[3] +=  2;
404     if(gMC->IsTrackExiting())     vol[3] +=  4;
405     if(gMC->IsTrackOut())         vol[3] +=  8;
406     if(gMC->IsTrackDisappeared()) vol[3] += 16;
407     if(gMC->IsTrackStop())        vol[3] += 32;
408     if(gMC->IsTrackAlive())       vol[3] += 64;
409     //
410     // Fill hit structure.
411     if(!(gMC->TrackCharge())) return;
412
413     // Only entering charged tracks
414     if((id = gMC->CurrentVolID(copy)) == fIdSens[0]) {
415         vol[0] = 1;
416         id = gMC->CurrentVolOffID(2,copy);
417         //detector copy in the ladder = 1<->4  (ITS1 < I101 < I103 < I10A)
418         vol[1] = copy;
419         gMC->CurrentVolOffID(3,copy1);
420         //ladder copy in the module   = 1<->2  (I10A < I12A)
421         gMC->CurrentVolOffID(4,copy2);
422         //module copy in the layer    = 1<->10 (I12A < IT12)
423         vol[2] = copy1+(copy2-1)*2;//# of ladders in one module  = 2
424
425     } else if(id == fIdSens[1]){
426         vol[0] = 2;
427         id = gMC->CurrentVolOffID(2,copy);
428         //detector copy in the ladder = 1<->4  (ITS2 < I1D1 < I1D3 < I20A)
429         vol[1] = copy;
430         gMC->CurrentVolOffID(3,copy1);
431         //ladder copy in the module   = 1<->4  (I20A < I12A)
432         gMC->CurrentVolOffID(4,copy2);
433         //module copy in the layer    = 1<->10 (I12A < IT12)
434         vol[2] = copy1+(copy2-1)*4;//# of ladders in one module  = 4
435
436     } else if(id == fIdSens[2]){
437         vol[0] = 3;
438         id = gMC->CurrentVolOffID(1,copy);
439         //detector copy in the ladder = 1<->6  (ITS3 < I302 < I004)
440         vol[1] = copy;
441         id = gMC->CurrentVolOffID(2,copy);
442         //ladder copy in the layer    = 1<->14 (I004 < IT34)
443         vol[2] = copy;
444
445     } else if(id == fIdSens[3]){
446         vol[0] = 4;
447         id = gMC->CurrentVolOffID(1,copy);
448         //detector copy in the ladder = 1<->8  (ITS4 < I402 < I005)
449         vol[1] = copy;
450         id = gMC->CurrentVolOffID(2,copy);
451         //ladder copy in the layer    = 1<->22 (I005 < IT34))
452         vol[2] = copy;
453
454     }else if(id == fIdSens[4]){
455         vol[0] = 5;
456         id = gMC->CurrentVolOffID(1,copy);
457         //detector copy in the ladder = 1<->22  (ITS5 < I562 < I565)
458         vol[1] = copy;
459         id = gMC->CurrentVolOffID(2,copy);
460         //ladder copy in the layer    = 1<->34 (I565 < IT56)
461         vol[2] = copy;
462
463     }else if(id == fIdSens[5]){
464         vol[0] = 6;
465         id = gMC->CurrentVolOffID(1,copy);
466         //detector copy in the ladder = 1<->25  (ITS6 < I566 < I569)
467         vol[1] = copy;
468         id = gMC->CurrentVolOffID(2,copy);
469         //ladder copy in the layer = 1<->38 (I569 < IT56)
470         vol[2] = copy;
471     } else {
472         return; // not an ITS volume?
473     } // end if/else if (gMC->CurentVolID(copy) == fIdSens[i])
474     //
475     gMC->TrackPosition(position);
476     gMC->TrackMomentum(momentum);
477     vol[4] = stat0;
478     if(gMC->IsTrackEntering()){
479         position0 = position;
480         stat0 = vol[3];
481         return;
482     } // end if IsEntering
483     // Fill hit structure with this new hit.
484     
485     new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,
486                                    gMC->Edep(),gMC->TrackTime(),position,
487                                    position0,momentum);
488
489     position0 = position;
490     stat0 = vol[3];
491
492     return;
493 }
494