]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONv0.cxx
Fixed bug in parent assignment and implemented Birk's law in the Step Manager
[u/mrichter/AliRoot.git] / MUON / AliMUONv0.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 /* $Id$ */
17
18 /////////////////////////////////////////////////////////
19 //  Manager and hits classes for set:MUON version 0    //
20 /////////////////////////////////////////////////////////
21
22 #include <TLorentzVector.h> 
23 #include <TVirtualMC.h>
24
25 #include "AliConst.h" 
26 #include "AliMUONChamber.h"
27 #include "AliMUONChamberGeometry.h"
28 #include "AliMUONConstants.h"
29 #include "AliMUONFactory.h"
30 #include "AliMUONHit.h"
31 #include "AliMUONv0.h"
32 #include "AliMagF.h"
33 #include "AliRun.h"
34 #include "AliMC.h"
35
36 ClassImp(AliMUONv0)
37  
38 //___________________________________________
39 AliMUONv0::AliMUONv0() 
40   : AliMUON()
41 {
42 // Constructor
43     fChambers = 0;
44 }
45  
46 //___________________________________________
47 AliMUONv0::AliMUONv0(const char *name, const char *title)
48   : AliMUON(name,title)
49 {
50 // Constructor
51     AliMUONFactory factory;
52     factory.Build(this, title);
53 }
54
55 //___________________________________________
56 void AliMUONv0::CreateGeometry()
57 {
58 // Creates coarse geometry for hit density simulations
59     Int_t *idtmed = fIdtmed->GetArray()-1099;
60 //
61      Float_t zpos, dAlu, tpar[3];
62      Int_t idAir=idtmed[1100];
63      Int_t idAlu=idtmed[1103];     
64
65      AliMUONChamber *iChamber;
66      // Loop over all chambers (tracking and trigger)
67      for (Int_t ch = 0; ch < AliMUONConstants::NCh(); ch++) {
68          char alu[8];
69          char gas[8];
70      
71          iChamber=(AliMUONChamber*) (*fChambers)[ch];
72          // Z of the chamber
73          zpos=iChamber->Z(); 
74          dAlu=iChamber->DAlu();
75          if (ch < AliMUONConstants::NTrackingCh()) {
76            // tracking chambers
77              sprintf(alu,"SA0%1d",ch);
78              sprintf(gas,"SG0%1d",ch);   
79          } else {
80            // trigger chambers
81              sprintf(alu,"SA%2d",ch);
82              sprintf(gas,"SG%2d",ch);    
83          }
84 //
85          tpar[0] = iChamber->RInner(); 
86          tpar[1] = iChamber->ROuter();
87          tpar[2] = (dAlu+0.2)/2.;
88          if (ch !=4 && ch !=5) {
89              gMC->Gsvolu(alu, "TUBE", idAlu, tpar, 3);
90              tpar[2] = 0.1;
91              gMC->Gsvolu(gas, "TUBE", idAir, tpar, 3);
92          } else {
93              gMC->Gsvolu(alu, "TUBE", idAlu, tpar, 3);
94              tpar[2] = 0.1;
95              gMC->Gsvolu(gas, "TUBE", idAir, tpar, 3);
96          }
97          gMC->Gspos(gas, 1, alu,  0., 0., 0., 0, "ONLY");
98          if (ch == 4 || ch ==5) {
99              if (gMC->VolId("DDIP")) {
100                  gMC->Gspos(alu, 1, "DDIP", 0., 0., zpos, 0, "ONLY");
101              } else {
102                  gMC->Gspos(alu, 1, "ALIC", 0., 0., zpos, 0, "ONLY");
103              }
104          } else {
105              gMC->Gspos(alu, 1, "ALIC", 0., 0., zpos, 0, "ONLY");
106          }
107      }
108 }
109
110 //___________________________________________
111 void AliMUONv0::CreateMaterials()
112 {
113 // Creates materials for coarse geometry
114     AliMaterial(15, "AIR$      ", 14.61,  7.3, .001205, 30423.24, 67500);
115     AliMaterial( 9, "ALUMINIUM$", 26.98, 13. , 2.7, 8.9, 37.2);
116
117     Float_t epsil  = .001; // Tracking precision, 
118     Float_t stemax = -1.;  // Maximum displacement for multiple scat 
119     Float_t tmaxfd = -20.; // Maximum angle due to field deflection 
120     Float_t deemax = -.3;  // Maximum fractional energy loss, DLS 
121     Float_t stmin  = -.8;
122     Int_t isxfld   = gAlice->Field()->Integ();
123     Float_t sxmgmx = gAlice->Field()->Max();
124
125     //
126     //    Air 
127     AliMedium(1, "AIR_CH_US         ", 15, 1, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
128     AliMedium(4, "ALU_CH_US         ",  9, 0, isxfld, sxmgmx, tmaxfd, fMaxStepAlu, 
129             fMaxDestepAlu, epsil, stmin);
130
131 }
132
133 void AliMUONv0::Init()
134 {
135    // 
136    // Initialize Tracking Chambers
137    //
138     char vName[8];
139     printf("\n\n\n Start Init for version 0 - CPC chamber type\n\n\n");
140     for (Int_t i=0; i<AliMUONConstants::NCh(); i++) {
141 // Initialise chamber
142         ((AliMUONChamber*) (*fChambers)[i])->Init();
143 // Set sensitive volume Id
144         if (i < AliMUONConstants::NTrackingCh()) {
145             // tracking chambers
146             sprintf(vName,"SG0%1d",i);   
147         } else {
148             // trigger chambers
149             sprintf(vName,"SG%2d",i);    
150         }
151         //((AliMUONChamber*) (*fChambers)[i])->SetGid(gMC->VolId(vName));
152         ((AliMUONChamber*) (*fChambers)[i])
153            ->GetGeometry()->SetSensitiveVolume(gMC->VolId(vName));
154     }
155 }
156
157 void AliMUONv0::StepManager()
158 {
159 //
160 // Step manager for hit density simulations
161   Int_t          copy, id;
162   static Int_t   idvol;
163   static Int_t   vol[2];
164   Int_t          ipart;
165   TLorentzVector pos;
166   TLorentzVector mom;
167   Float_t        theta,phi;
168   
169   //  modifs perso
170   static Float_t hits[15];
171
172   TClonesArray &lhits = *fHits;
173   //
174   // Only gas gap inside chamber
175   // Tag chambers and record hits when track enters 
176   idvol=-1;
177   id=gMC->CurrentVolID(copy);
178   
179     for (Int_t i=1; i<=AliMUONConstants::NCh(); i++) {
180       //if(id==((AliMUONChamber*)(*fChambers)[i-1])->GetGid()){ 
181       if ( ((AliMUONChamber*)(*fChambers)[i-1])->IsSensId(id) ) {
182           vol[0]=i; 
183           idvol=i-1;
184       }
185     }
186     if (idvol == -1) return;
187   //
188   // Get current particle id (ipart), track position (pos)  and momentum (mom) 
189   gMC->TrackPosition(pos);
190   gMC->TrackMomentum(mom);
191
192   ipart  = gMC->TrackPid();
193   //
194   // record hits when track enters ...
195   if( !(gMC->TrackCharge()) ) return; 
196   if( gMC->IsTrackEntering()) {
197 //      printf("\n Particle entering %f %f %f", pos[0], pos[1], pos[2] );
198       
199       Double_t tc = mom[0]*mom[0]+mom[1]*mom[1];
200       Double_t rt = TMath::Sqrt(tc);
201       theta   = Float_t(TMath::ATan2(rt,Double_t(mom[2])))*kRaddeg;
202       phi     = Float_t(TMath::ATan2(Double_t(mom[1]),Double_t(mom[0])))*kRaddeg;
203       hits[0] = Float_t(ipart);             // Geant3 particle type
204       hits[1] = pos[0];                     // X-position for hit
205       hits[2] = pos[1];                     // Y-position for hit
206       hits[3] = pos[2];                     // Z-position for hit
207       hits[4] = theta;                      // theta angle of incidence
208       hits[5] = phi;                        // phi angle of incidence 
209       hits[8] = -1;                         // first padhit
210       hits[9] = -1;                         // last pad hit
211       hits[10] = mom[3];                    // hit Energy
212       hits[11] = mom[0];                    // Px
213       hits[12] = mom[1];                    // Py
214       hits[13] = mom[2];                    // Pz
215       hits[14] = gMC->TrackTime();          // time of flight
216       new(lhits[fNhits++]) 
217           AliMUONHit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,hits);
218
219   }
220 //  if( gMC->IsTrackExiting()) gMC->StopTrack(); 
221 }
222
223
224
225
226
227
228
229
230