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