]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONv0.cxx
AliRICHDetectV1 added.
[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 /*
17 $Log$
18 Revision 1.22  2002/10/14 14:57:29  hristov
19 Merging the VirtualMC branch to the main development branch (HEAD)
20
21 Revision 1.20.6.2  2002/07/24 10:07:21  alibrary
22 Updating VirtualMC
23
24 Revision 1.21  2002/07/23 10:02:46  morsch
25 All volume names start with "S".
26
27 Revision 1.20  2001/10/30 12:18:45  morsch
28 Place station 3 into DDIP only if DDIP is present.
29
30 Revision 1.19  2001/07/17 09:51:38  morsch
31 Place station 3 inside Dipole.
32
33 Revision 1.18  2001/04/06 11:24:43  morsch
34 Dependency on implementations of AliSegmentation and AliMUONResponse moved to AliMUONFactory class.
35 Static method Build() builds the MUON system out of chambers, segmentation and response.
36
37 Revision 1.17  2001/03/17 10:07:20  morsch
38 Correct inconsistent variable name / method name / comments.
39
40 Revision 1.16  2001/01/27 08:50:50  morsch
41 Call non default constructors of segmentation classes.
42
43 Revision 1.15  2001/01/17 20:57:45  hristov
44 Unused variable removed
45
46 Revision 1.14  2000/12/21 22:42:55  morsch
47 Constructor contains default set-up for segmentation.
48 Record charged particles only.
49
50 Revision 1.13  2000/10/06 10:03:38  morsch
51 Call to gMC->VolId() moved to Init()
52
53 Revision 1.12  2000/10/02 21:28:09  fca
54 Removal of useless dependecies via forward declarations
55
56 Revision 1.11  2000/06/27 07:31:07  morsch
57 fChambers = 0; deleted from constructor.
58
59 Revision 1.10  2000/06/26 14:02:38  morsch
60 Add class AliMUONConstants with MUON specific constants using static memeber data and access methods.
61
62 Revision 1.9  2000/06/15 07:58:49  morsch
63 Code from MUON-dev joined
64
65 Revision 1.8.4.9  2000/06/12 19:20:49  morsch
66 Constructor sets default geometry, segmentation and response parameters.
67
68 Revision 1.8.4.8  2000/06/09 21:55:28  morsch
69 Most coding rule violations corrected.
70
71 Revision 1.8.4.7  2000/05/02 13:15:18  morsch
72 Coding rule violations RS3, RN13 corected
73
74 Revision 1.8.4.6  2000/05/02 10:24:26  morsch
75 Public access to fdGas and fdAlu of AliMUONChamber replaced by getters.
76
77 Revision 1.8.4.5  2000/04/26 19:58:47  morsch
78 Obsolete reference to trig_ removed.
79
80 Revision 1.8.4.4  2000/04/19 19:42:47  morsch
81 change NCH to kNCH
82
83 Revision 1.8.4.3  2000/02/17 08:17:43  morsch
84 Gammas and neutrons are also scored in the stepmanager
85 */
86
87 /////////////////////////////////////////////////////////
88 //  Manager and hits classes for set:MUON version 0    //
89 /////////////////////////////////////////////////////////
90
91 #include <TTUBE.h>
92 #include <TNode.h> 
93 #include <TRandom.h> 
94 #include <TLorentzVector.h> 
95 #include <Riostream.h>
96
97 #include "AliMUONv0.h"
98 #include "AliMUONChamber.h"
99 #include "AliRun.h"
100 #include "AliMC.h"
101 #include "AliMagF.h"
102 #include "AliMUONHit.h"
103 #include "AliMUONPadHit.h"
104 #include "AliCallf77.h"
105 #include "AliConst.h" 
106 #include "AliMUONConstants.h"
107 #include "AliMUONFactory.h"
108 ClassImp(AliMUONv0)
109  
110 //___________________________________________
111 AliMUONv0::AliMUONv0() : AliMUON()
112 {
113 // Constructor
114     fChambers = 0;
115 }
116  
117 //___________________________________________
118 AliMUONv0::AliMUONv0(const char *name, const char *title)
119        : AliMUON(name,title)
120 {
121 // Constructor
122     AliMUONFactory::Build(this, "default");
123 }
124
125 void AliMUONv0::CreateGeometry()
126 {
127 // Creates coarse geometry for hit density simulations
128     Int_t *idtmed = fIdtmed->GetArray()-1099;
129 //
130      Float_t zpos, dAlu, tpar[3];
131      Int_t idAir=idtmed[1100];
132      Int_t idAlu=idtmed[1103];     
133
134      AliMUONChamber *iChamber;
135      // Loop over all chambers (tracking and trigger)
136      for (Int_t ch = 0; ch < AliMUONConstants::NCh(); ch++) {
137          char alu[8];
138          char gas[8];
139      
140          iChamber=(AliMUONChamber*) (*fChambers)[ch];
141          // Z of the chamber
142          zpos=iChamber->Z(); 
143          dAlu=iChamber->DAlu();
144          if (ch < AliMUONConstants::NTrackingCh()) {
145            // tracking chambers
146              sprintf(alu,"SA0%1d",ch);
147              sprintf(gas,"SG0%1d",ch);   
148          } else {
149            // trigger chambers
150              sprintf(alu,"SA%2d",ch);
151              sprintf(gas,"SG%2d",ch);    
152          }
153 //
154          tpar[0] = iChamber->RInner(); 
155          tpar[1] = iChamber->ROuter();
156          tpar[2] = (dAlu+0.2)/2.;
157          if (ch !=4 && ch !=5) {
158              gMC->Gsvolu(alu, "TUBE", idAlu, tpar, 3);
159              tpar[2] = 0.1;
160              gMC->Gsvolu(gas, "TUBE", idAir, tpar, 3);
161          } else {
162              gMC->Gsvolu(alu, "TUBE", idAlu, tpar, 3);
163              tpar[2] = 0.1;
164              gMC->Gsvolu(gas, "TUBE", idAir, tpar, 3);
165          }
166          gMC->Gspos(gas, 1, alu,  0., 0., 0., 0, "ONLY");
167          if (ch == 4 || ch ==5) {
168              if (gMC->VolId("DDIP")) {
169                  gMC->Gspos(alu, 1, "DDIP", 0., 0., zpos, 0, "ONLY");
170              } else {
171                  gMC->Gspos(alu, 1, "ALIC", 0., 0., zpos, 0, "ONLY");
172              }
173          } else {
174              gMC->Gspos(alu, 1, "ALIC", 0., 0., zpos, 0, "ONLY");
175          }
176      }
177 }
178
179 //___________________________________________
180 void AliMUONv0::CreateMaterials()
181 {
182 // Creates materials for coarse geometry
183     AliMaterial(15, "AIR$      ", 14.61,  7.3, .001205, 30423.24, 67500);
184     AliMaterial( 9, "ALUMINIUM$", 26.98, 13. , 2.7, 8.9, 37.2);
185
186     Float_t epsil  = .001; // Tracking precision, 
187     Float_t stemax = -1.;  // Maximum displacement for multiple scat 
188     Float_t tmaxfd = -20.; // Maximum angle due to field deflection 
189     Float_t deemax = -.3;  // Maximum fractional energy loss, DLS 
190     Float_t stmin  = -.8;
191     Int_t isxfld   = gAlice->Field()->Integ();
192     Float_t sxmgmx = gAlice->Field()->Max();
193
194     //
195     //    Air 
196     AliMedium(1, "AIR_CH_US         ", 15, 1, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
197     AliMedium(4, "ALU_CH_US         ",  9, 0, isxfld, sxmgmx, tmaxfd, fMaxStepAlu, 
198             fMaxDestepAlu, epsil, stmin);
199
200 }
201
202 void AliMUONv0::Init()
203 {
204    // 
205    // Initialize Tracking Chambers
206    //
207     char vName[8];
208     printf("\n\n\n Start Init for version 0 - CPC chamber type\n\n\n");
209     for (Int_t i=0; i<AliMUONConstants::NCh(); i++) {
210 // Initialise chamber
211         ((AliMUONChamber*) (*fChambers)[i])->Init();
212 // Set sensitive volume Id
213         if (i < AliMUONConstants::NTrackingCh()) {
214             // tracking chambers
215             sprintf(vName,"SG0%1d",i);   
216         } else {
217             // trigger chambers
218             sprintf(vName,"SG%2d",i);    
219         }
220         ((AliMUONChamber*) (*fChambers)[i])->SetGid(gMC->VolId(vName));
221     }
222 }
223
224 void AliMUONv0::StepManager()
225 {
226 //
227 // Step manager for hit density simulations
228   Int_t          copy, id;
229   static Int_t   idvol;
230   static Int_t   vol[2];
231   Int_t          ipart;
232   TLorentzVector pos;
233   TLorentzVector mom;
234   Float_t        theta,phi;
235   
236   //  modifs perso
237   static Float_t hits[15];
238
239   TClonesArray &lhits = *fHits;
240   //
241   // Only gas gap inside chamber
242   // Tag chambers and record hits when track enters 
243   idvol=-1;
244   id=gMC->CurrentVolID(copy);
245   
246     for (Int_t i=1; i<=AliMUONConstants::NCh(); i++) {
247       if(id==((AliMUONChamber*)(*fChambers)[i-1])->GetGid()){ 
248           vol[0]=i; 
249           idvol=i-1;
250       }
251     }
252     if (idvol == -1) return;
253   //
254   // Get current particle id (ipart), track position (pos)  and momentum (mom) 
255   gMC->TrackPosition(pos);
256   gMC->TrackMomentum(mom);
257
258   ipart  = gMC->TrackPid();
259   //
260   // record hits when track enters ...
261   if( !(gMC->TrackCharge()) ) return; 
262   if( gMC->IsTrackEntering()) {
263 //      printf("\n Particle entering %f %f %f", pos[0], pos[1], pos[2] );
264       
265       Double_t tc = mom[0]*mom[0]+mom[1]*mom[1];
266       Double_t rt = TMath::Sqrt(tc);
267       theta   = Float_t(TMath::ATan2(rt,Double_t(mom[2])))*kRaddeg;
268       phi     = Float_t(TMath::ATan2(Double_t(mom[1]),Double_t(mom[0])))*kRaddeg;
269       hits[0] = Float_t(ipart);             // Geant3 particle type
270       hits[1] = pos[0];                     // X-position for hit
271       hits[2] = pos[1];                     // Y-position for hit
272       hits[3] = pos[2];                     // Z-position for hit
273       hits[4] = theta;                      // theta angle of incidence
274       hits[5] = phi;                        // phi angle of incidence 
275       hits[8] = -1;                         // first padhit
276       hits[9] = -1;                         // last pad hit
277       hits[10] = mom[3];                    // hit Energy
278       hits[11] = mom[0];                    // Px
279       hits[12] = mom[1];                    // Py
280       hits[13] = mom[2];                    // Pz
281       hits[14] = gMC->TrackTime();          // time of flight
282       new(lhits[fNhits++]) 
283           AliMUONHit(fIshunt,gAlice->CurrentTrack(),vol,hits);
284
285   }
286 //  if( gMC->IsTrackExiting()) gMC->StopTrack(); 
287 }
288
289
290
291
292
293
294
295
296