]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONv0.cxx
Call to gMC->VolId() moved to Init()
[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.12  2000/10/02 21:28:09  fca
19 Removal of useless dependecies via forward declarations
20
21 Revision 1.11  2000/06/27 07:31:07  morsch
22 fChambers = 0; deleted from constructor.
23
24 Revision 1.10  2000/06/26 14:02:38  morsch
25 Add class AliMUONConstants with MUON specific constants using static memeber data and access methods.
26
27 Revision 1.9  2000/06/15 07:58:49  morsch
28 Code from MUON-dev joined
29
30 Revision 1.8.4.9  2000/06/12 19:20:49  morsch
31 Constructor sets default geometry, segmentation and response parameters.
32
33 Revision 1.8.4.8  2000/06/09 21:55:28  morsch
34 Most coding rule violations corrected.
35
36 Revision 1.8.4.7  2000/05/02 13:15:18  morsch
37 Coding rule violations RS3, RN13 corected
38
39 Revision 1.8.4.6  2000/05/02 10:24:26  morsch
40 Public access to fdGas and fdAlu of AliMUONChamber replaced by getters.
41
42 Revision 1.8.4.5  2000/04/26 19:58:47  morsch
43 Obsolete reference to trig_ removed.
44
45 Revision 1.8.4.4  2000/04/19 19:42:47  morsch
46 change NCH to kNCH
47
48 Revision 1.8.4.3  2000/02/17 08:17:43  morsch
49 Gammas and neutrons are also scored in the stepmanager
50 */
51
52 /////////////////////////////////////////////////////////
53 //  Manager and hits classes for set:MUON version 0    //
54 /////////////////////////////////////////////////////////
55
56 #include <TTUBE.h>
57 #include <TNode.h> 
58 #include <TRandom.h> 
59 #include <TLorentzVector.h> 
60 #include <iostream.h>
61
62 #include "AliMUONv0.h"
63 #include "AliMUONChamber.h"
64 #include "AliRun.h"
65 #include "AliMC.h"
66 #include "AliMagF.h"
67 #include "AliMUONHit.h"
68 #include "AliMUONPadHit.h"
69 #include "AliCallf77.h"
70 #include "AliConst.h" 
71 #include "AliMUONResponseV0.h"
72 #include "AliMUONResponseTrigger.h"
73 #include "AliMUONSegmentationV0.h"
74 #include "AliMUONSegmentationV01.h"
75 #include "AliMUONSegmentationV02.h"
76 #include "AliMUONSegmentationV04.h"
77 #include "AliMUONSegmentationV05.h"
78 #include "AliMUONSegmentationTrigger.h"
79 #include "AliMUONSegmentationTriggerX.h"
80 #include "AliMUONSegmentationTriggerY.h"
81 #include "AliMUONConstants.h"
82
83 ClassImp(AliMUONv0)
84  
85 //___________________________________________
86 AliMUONv0::AliMUONv0() : AliMUON()
87 {
88 // Constructor
89     fChambers = 0;
90 }
91  
92 //___________________________________________
93 AliMUONv0::AliMUONv0(const char *name, const char *title)
94        : AliMUON(name,title)
95 {
96 // Constructor
97     SetIshunt(0);
98     SetMaxStepGas(0.1);
99     SetMaxStepAlu(0.1);
100 //
101 // Version 0
102 //
103 // First define the number of planes that are segmented (1 or 2) by a call
104 // to SetNsec. 
105 // Then chose for each chamber (chamber plane) the segmentation 
106 // and response model.
107 // They should be equal for the two chambers of each station. In a future
108 // version this will be enforced.
109 //
110 //  
111     Int_t chamber;
112     Int_t station;
113 // Default response
114     AliMUONResponseV0* response0 = new AliMUONResponseV0;
115     response0->SetSqrtKx3(0.7131);
116     response0->SetKx2(1.0107);
117     response0->SetKx4(0.4036);
118     response0->SetSqrtKy3(0.7642);
119     response0->SetKy2(0.9706);
120     response0->SetKy4(0.3831);
121     response0->SetPitch(0.25);
122     response0->SetSigmaIntegration(10.);
123     response0->SetChargeSlope(50);
124     response0->SetChargeSpread(0.18, 0.18);
125     response0->SetMaxAdc(4096);
126     response0->SetZeroSuppression(6);
127 //--------------------------------------------------------
128 // Configuration for Chamber TC1/2  (Station 1) ----------           
129 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
130     Float_t rseg1[4]={17.5, 55.2, 71.3, 95.5};
131     Int_t   nseg1[4]={4, 4, 2, 1};
132 //
133     chamber=1;
134 //^^^^^^^^^
135     SetNsec(chamber-1,2);
136 //
137     AliMUONSegmentationV01 *seg11=new AliMUONSegmentationV01;
138     
139     seg11->SetSegRadii(rseg1);
140     seg11->SetPadSize(3, 0.5);
141     seg11->SetDAnod(3.0/3./4);
142     seg11->SetPadDivision(nseg1);
143     
144     SetSegmentationModel(chamber-1, 1, seg11);
145 //
146     AliMUONSegmentationV02 *seg12=new AliMUONSegmentationV02;
147     seg12->SetSegRadii(rseg1); 
148     seg12->SetPadSize(0.75, 2.0);
149     seg12->SetDAnod(3.0/3./4);
150     seg12->SetPadDivision(nseg1);
151     
152     SetSegmentationModel(chamber-1, 2, seg12);
153     
154     SetResponseModel(chamber-1, response0);         
155     
156     chamber=2;
157 //^^^^^^^^^
158 //
159     SetNsec(chamber-1,2);
160 //
161     AliMUONSegmentationV01 *seg21=new AliMUONSegmentationV01;
162     seg21->SetSegRadii(rseg1);
163     seg21->SetPadSize(3, 0.5);
164     seg21->SetDAnod(3.0/3./4);
165     seg21->SetPadDivision(nseg1);
166     SetSegmentationModel(chamber-1, 1, seg21);
167 //
168     AliMUONSegmentationV02 *seg22=new AliMUONSegmentationV02;
169     seg22->SetSegRadii(rseg1); 
170     seg22->SetPadSize(0.75, 2.);
171     seg22->SetDAnod(3.0/3./4);
172     seg22->SetPadDivision(nseg1);
173     SetSegmentationModel(chamber-1, 2, seg22);
174     
175     SetResponseModel(chamber-1, response0);         
176 //
177 //--------------------------------------------------------
178 // Configuration for Chamber TC3/4 -----------------------
179 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
180     Float_t rseg2[4]={23.5, 47.1, 87.7, 122.5};
181     Int_t   nseg2[4]={4, 4, 2, 1};
182 //
183     chamber=3;
184 //^^^^^^^^^
185     SetNsec(chamber-1,2);
186 //
187     AliMUONSegmentationV01 *seg31=new AliMUONSegmentationV01;
188     seg31->SetSegRadii(rseg2);
189     seg31->SetPadSize(6, 0.5);
190     seg31->SetDAnod(3.0/3./4);
191     seg31->SetPadDivision(nseg2);
192     SetSegmentationModel(chamber-1, 1, seg31);
193 //
194     AliMUONSegmentationV02 *seg32=new AliMUONSegmentationV02;
195     seg32->SetSegRadii(rseg2); 
196     seg32->SetPadSize(0.75, 4.);
197     seg32->SetPadDivision(nseg2);
198     seg32->SetDAnod(3.0/3./4);
199     
200     SetSegmentationModel(chamber-1, 2, seg32);
201     
202     SetResponseModel(chamber-1, response0);         
203     
204     chamber=4;
205 //^^^^^^^^^
206 //
207     SetNsec(chamber-1,2);
208 //
209     AliMUONSegmentationV01 *seg41=new AliMUONSegmentationV01;
210     seg41->SetSegRadii(rseg2);
211     seg41->SetPadSize(6, 0.5);
212     seg41->SetDAnod(3.0/3./4);
213     seg41->SetPadDivision(nseg2);
214     SetSegmentationModel(chamber-1, 1, seg41);
215 //
216     AliMUONSegmentationV02 *seg42=new AliMUONSegmentationV02;
217     seg42->SetSegRadii(rseg2); 
218     seg42->SetPadSize(0.75, 4.);
219     seg42->SetPadDivision(nseg2);
220     seg42->SetDAnod(3.0/3./4);
221     
222     SetSegmentationModel(chamber-1, 2, seg42);
223     
224     SetResponseModel(chamber-1, response0);         
225
226
227 //--------------------------------------------------------
228 // Configuration for Chamber TC5/6 -----------------------
229 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
230     chamber=5;
231 //^^^^^^^^^
232     SetNsec(chamber-1,2);
233 //
234     AliMUONSegmentationV01 *seg51=new AliMUONSegmentationV01;
235     seg51->SetSegRadii(rseg2);
236     seg51->SetPadSize(6, 0.5);
237     seg51->SetDAnod(3.0/3./4);
238     seg51->SetPadDivision(nseg2);
239     SetSegmentationModel(chamber-1, 1, seg51);
240 //
241     AliMUONSegmentationV02 *seg52=new AliMUONSegmentationV02;
242     seg52->SetSegRadii(rseg2); 
243     seg52->SetPadSize(0.75, 4.);
244     seg52->SetPadDivision(nseg2);
245     seg52->SetDAnod(3.0/3./4);
246     
247     SetSegmentationModel(chamber-1, 2, seg52);
248     SetResponseModel(chamber-1, response0);         
249     
250     chamber=6;
251 //^^^^^^^^^
252 //
253     SetNsec(chamber-1,2);
254 //
255     AliMUONSegmentationV01 *seg61=new AliMUONSegmentationV01;
256     seg61->SetSegRadii(rseg2);
257     seg61->SetPadSize(6, 0.5);
258     seg61->SetDAnod(3.0/3./4);
259     seg61->SetPadDivision(nseg2);
260     SetSegmentationModel(chamber-1, 1, seg61);
261 //
262     AliMUONSegmentationV02 *seg62=new AliMUONSegmentationV02;
263     seg62->SetSegRadii(rseg2); 
264     seg62->SetPadSize(0.75, 4.);
265     seg62->SetPadDivision(nseg2);
266     seg62->SetDAnod(3.0/3./4);
267     
268     SetSegmentationModel(chamber-1, 2, seg62);
269     
270     SetResponseModel(chamber-1, response0);         
271
272
273 //
274 // Station 3
275     station=3;
276     SetPadSize(station, 1, 0.975, 0.55);
277
278 //--------------------------------------------------------
279 // Configuration for Chamber TC7/8  (Station 4) ----------           
280 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
281
282     Int_t   nseg4[4]={4, 4, 2, 1};
283
284     chamber=7;
285 //^^^^^^^^^
286     SetNsec(chamber-1,2);
287 //
288     AliMUONSegmentationV04 *seg71=new AliMUONSegmentationV04;
289     seg71->SetPadSize(10.,0.5);
290     seg71->SetDAnod(0.25);
291     seg71->SetPadDivision(nseg4);
292     SetSegmentationModel(chamber-1, 1, seg71);
293     AliMUONSegmentationV05 *seg72=new AliMUONSegmentationV05;
294     seg72->SetPadSize(1,10);
295     seg72->SetDAnod(0.25);
296     seg72->SetPadDivision(nseg4);
297     SetSegmentationModel(chamber-1, 2, seg72);
298     
299     SetResponseModel(chamber-1, response0);         
300
301     chamber=8;
302 //^^^^^^^^^
303     SetNsec(chamber-1,2);
304     AliMUONSegmentationV04 *seg81=new AliMUONSegmentationV04;
305     seg81->SetPadSize(10., 0.5);
306     seg81->SetPadDivision(nseg4);
307     seg81->SetDAnod(0.25);
308     SetSegmentationModel(chamber-1, 1, seg81);
309     
310     AliMUONSegmentationV05 *seg82=new AliMUONSegmentationV05;
311     seg82->SetPadSize(1, 10);
312     seg82->SetPadDivision(nseg4);
313     seg82->SetDAnod(0.25);
314     SetSegmentationModel(chamber-1, 2, seg82);
315     
316     SetResponseModel(chamber-1, response0);         
317 //--------------------------------------------------------
318 // Configuration for Chamber TC9/10  (Station 5) ---------           
319 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
320     chamber=9;
321 //^^^^^^^^^
322     SetNsec(chamber-1,2);
323 //
324     AliMUONSegmentationV04 *seg91=new AliMUONSegmentationV04;
325     seg91->SetPadSize(10.,0.5);
326     seg91->SetDAnod(0.25);
327     seg91->SetPadDivision(nseg4);
328     SetSegmentationModel(chamber-1, 1, seg91);
329     
330     AliMUONSegmentationV05 *seg92=new AliMUONSegmentationV05;
331     seg92->SetPadSize(1,10);
332     seg92->SetDAnod(0.25);
333     seg92->SetPadDivision(nseg4);
334     
335     SetSegmentationModel(chamber-1, 2, seg92);
336     
337     SetResponseModel(chamber-1, response0);         
338     
339     chamber=10;
340 //^^^^^^^^^
341     SetNsec(chamber-1,2);
342     AliMUONSegmentationV04 *seg101=new AliMUONSegmentationV04;
343     seg101->SetPadSize(10., 0.5);
344     seg101->SetPadDivision(nseg4);
345     seg101->SetDAnod(0.25);
346     SetSegmentationModel(chamber-1, 1, seg101);
347     
348     AliMUONSegmentationV05 *seg102=new AliMUONSegmentationV05;
349     seg102->SetPadSize(1,10);
350     seg102->SetPadDivision(nseg4);
351     seg102->SetDAnod(0.25);
352     SetSegmentationModel(chamber-1, 2, seg102);
353     
354     SetResponseModel(chamber-1, response0);         
355
356 //--------------------------------------------------------
357 // Configuration for Trigger staions --------------------- 
358 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
359     AliMUONResponseTrigger* responseTrigger0 =  new AliMUONResponseTrigger;
360     
361     chamber=11;
362     SetNsec(chamber-1,2);
363     AliMUONSegmentationTriggerX *seg111=new AliMUONSegmentationTriggerX;
364     SetSegmentationModel(chamber-1, 1, seg111);
365     AliMUONSegmentationTriggerY *seg112=new AliMUONSegmentationTriggerY;
366     SetSegmentationModel(chamber-1, 2, seg112);
367     
368     SetResponseModel(chamber-1, responseTrigger0);      
369     
370     chamber=12;
371     SetNsec(chamber-1,2);
372     AliMUONSegmentationTriggerX *seg121=new AliMUONSegmentationTriggerX;
373     SetSegmentationModel(chamber-1, 1, seg121);
374     AliMUONSegmentationTriggerY *seg122=new AliMUONSegmentationTriggerY;
375     SetSegmentationModel(chamber-1, 2, seg122);
376     
377     SetResponseModel(chamber-1, responseTrigger0);      
378     
379     chamber=13;
380     SetNsec(chamber-1,2);
381     AliMUONSegmentationTriggerX *seg131=new AliMUONSegmentationTriggerX;
382     SetSegmentationModel(chamber-1, 1, seg131);
383     AliMUONSegmentationTriggerY *seg132=new AliMUONSegmentationTriggerY;
384     SetSegmentationModel(chamber-1, 2, seg132);
385     SetResponseModel(chamber-1, responseTrigger0);      
386     
387     chamber=14;
388     SetNsec(chamber-1,2);
389     AliMUONSegmentationTriggerX *seg141=new AliMUONSegmentationTriggerX;
390     SetSegmentationModel(chamber-1, 1, seg141);
391     AliMUONSegmentationTriggerY *seg142=new AliMUONSegmentationTriggerY;
392     SetSegmentationModel(chamber-1, 2, seg142);
393     
394     SetResponseModel(chamber-1, responseTrigger0); 
395 }
396
397 void AliMUONv0::CreateGeometry()
398 {
399 // Creates coarse geometry for hit density simulations
400     Int_t *idtmed = fIdtmed->GetArray()-1099;
401 //
402      Float_t zpos, dAlu, tpar[3];
403      Int_t idAir=idtmed[1100];
404      Int_t idAlu=idtmed[1103];     
405
406      AliMUONChamber *iChamber;
407      // Loop over all chambers (tracking and trigger)
408      for (Int_t ch = 0; ch < AliMUONConstants::NCh(); ch++) {
409          char alu[8];
410          char gas[8];
411      
412          iChamber=(AliMUONChamber*) (*fChambers)[ch];
413          // Z of the chamber
414          zpos=iChamber->Z(); 
415          dAlu=iChamber->DAlu();
416          if (ch < AliMUONConstants::NTrackingCh()) {
417            // tracking chambers
418              sprintf(alu,"CA0%1d",ch);
419              sprintf(gas,"CG0%1d",ch);   
420          } else {
421            // trigger chambers
422              sprintf(alu,"CA%2d",ch);
423              sprintf(gas,"CG%2d",ch);    
424          }
425 //
426          tpar[0] = iChamber->RInner(); 
427          tpar[1] = iChamber->ROuter();
428          tpar[2] = (dAlu+0.2)/2.;
429          if (ch !=4 && ch !=5) {
430              gMC->Gsvolu(alu, "TUBE", idAlu, tpar, 3);
431              tpar[2] = 0.1;
432              gMC->Gsvolu(gas, "TUBE", idAir, tpar, 3);
433          } else {
434              gMC->Gsvolu(alu, "TUBE", idAlu, tpar, 3);
435              tpar[2] = 0.1;
436              gMC->Gsvolu(gas, "TUBE", idAir, tpar, 3);
437          }
438          gMC->Gspos(gas, 1, alu,  0., 0., 0., 0, "ONLY");
439          gMC->Gspos(alu, 1, "ALIC", 0., 0., zpos, 0, "ONLY");
440      }
441 }
442
443 //___________________________________________
444 void AliMUONv0::CreateMaterials()
445 {
446 // Creates materials for coarse geometry
447     AliMaterial(15, "AIR$      ", 14.61, 7.3, .001205, 30423.24, 67500);
448     AliMaterial(9, "ALUMINIUM$", 26.98, 13., 2.7, 8.9, 37.2);
449
450     Float_t epsil  = .001; // Tracking precision, 
451     Float_t stemax = -1.;  // Maximum displacement for multiple scat 
452     Float_t tmaxfd = -20.; // Maximum angle due to field deflection 
453     Float_t deemax = -.3;  // Maximum fractional energy loss, DLS 
454     Float_t stmin  = -.8;
455     Int_t isxfld   = gAlice->Field()->Integ();
456     Float_t sxmgmx = gAlice->Field()->Max();
457
458     //
459     //    Air 
460     AliMedium(1, "AIR_CH_US         ", 15, 1, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
461     AliMedium(4, "ALU_CH_US          ", 9, 0, isxfld, sxmgmx, tmaxfd, fMaxStepAlu, 
462             fMaxDestepAlu, epsil, stmin);
463
464 }
465
466 void AliMUONv0::Init()
467 {
468    // 
469    // Initialize Tracking Chambers
470    //
471     char vName[8];
472     printf("\n\n\n Start Init for version 0 - CPC chamber type\n\n\n");
473     for (Int_t i=0; i<AliMUONConstants::NCh(); i++) {
474 // Initialise chamber
475         ((AliMUONChamber*) (*fChambers)[i])->Init();
476 // Set sensitive volume Id
477         if (i < AliMUONConstants::NTrackingCh()) {
478             // tracking chambers
479             sprintf(vName,"CG0%1d",i);   
480         } else {
481             // trigger chambers
482             sprintf(vName,"CG%2d",i);    
483         }
484         ((AliMUONChamber*) (*fChambers)[i])->SetGid(gMC->VolId(vName));
485     }
486 }
487
488 void AliMUONv0::StepManager()
489 {
490 //
491 // Step manager for hit density simulations
492   Int_t          copy, id;
493   static Int_t   idvol;
494   static Int_t   vol[2];
495   Int_t          ipart;
496   TLorentzVector pos;
497   TLorentzVector mom;
498   Float_t        theta,phi;
499   
500   //  modifs perso
501   static Float_t hits[15];
502
503   TClonesArray &lhits = *fHits;
504   //
505   // Only gas gap inside chamber
506   // Tag chambers and record hits when track enters 
507   idvol=-1;
508   id=gMC->CurrentVolID(copy);
509   
510     for (Int_t i=1; i<=AliMUONConstants::NCh(); i++) {
511       if(id==((AliMUONChamber*)(*fChambers)[i-1])->GetGid()){ 
512           vol[0]=i; 
513           idvol=i-1;
514       }
515     }
516     if (idvol == -1) return;
517   //
518   // Get current particle id (ipart), track position (pos)  and momentum (mom) 
519   gMC->TrackPosition(pos);
520   gMC->TrackMomentum(mom);
521
522   ipart  = gMC->TrackPid();
523   //
524   // record hits when track enters ...
525 //  if( !(gMC->TrackCharge()) ) return; 
526   if( gMC->IsTrackEntering()) {
527       Double_t tc = mom[0]*mom[0]+mom[1]*mom[1];
528       Double_t rt = TMath::Sqrt(tc);
529       theta   = Float_t(TMath::ATan2(rt,Double_t(mom[2])))*kRaddeg;
530       phi     = Float_t(TMath::ATan2(Double_t(mom[1]),Double_t(mom[0])))*kRaddeg;
531       hits[0] = Float_t(ipart);             // Geant3 particle type
532       hits[1] = pos[0];                     // X-position for hit
533       hits[2] = pos[1];                     // Y-position for hit
534       hits[3] = pos[2];                     // Z-position for hit
535       hits[4] = theta;                      // theta angle of incidence
536       hits[5] = phi;                        // phi angle of incidence 
537       hits[8] = -1;                         // first padhit
538       hits[9] = -1;                         // last pad hit
539
540       // modifs personel
541       hits[10] = mom[3]; // hit Energy
542       hits[11] = mom[0]; // Px
543       hits[12] = mom[1]; // Py
544       hits[13] = mom[2]; // Pz
545       hits[14] = gMC->TrackTime();
546       
547       // fin modifs perso
548       new(lhits[fNhits++]) 
549           AliMUONHit(fIshunt,gAlice->CurrentTrack(),vol,hits);
550
551   }
552 }
553
554
555
556
557
558
559
560
561