]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONChamber.cxx
New definition of the geometry based on builders and usign Ivana's envelop method...
[u/mrichter/AliRoot.git] / MUON / AliMUONChamber.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 // --- MUON includes ---
19 #include "AliMUONChamber.h"
20 #include "AliMUONChamberGeometry.h"
21
22 // --- ROOT includes ---
23
24 #include "TRandom.h"
25 #include "TMath.h"
26
27 ClassImp(AliMUONChamber)        
28
29     AliMUONChamber::AliMUONChamber()
30 {
31 // Default constructor
32     fSegmentation = 0;
33     fResponse=0;
34     fnsec=1;
35     fReconstruction=0;
36     fGeometry = 0;
37     
38     fId=0;
39     // to avoid mistakes if ChargeCorrelInit is not called
40     fCurrentCorrel =1;
41 }
42
43     AliMUONChamber::AliMUONChamber(Int_t id) 
44 {
45 // Construtor with chamber id 
46     fSegmentation = new TObjArray(2);
47     fSegmentation->AddAt(0,0);
48     fSegmentation->AddAt(0,1);
49     fResponse=0;
50     fGeometry = new AliMUONChamberGeometry(fId);
51     fnsec=1;
52     fReconstruction=0;
53     fId=id;
54     // to avoid mistakes if ChargeCorrelInit is not called
55     fCurrentCorrel =1;
56 }
57
58 AliMUONChamber::~AliMUONChamber() 
59 {
60 // Destructor
61   if (fSegmentation) {
62     fSegmentation->Delete();
63     delete fSegmentation;
64   }
65 }
66
67 AliMUONChamber::AliMUONChamber(const AliMUONChamber& rChamber):TObject(rChamber)
68 {
69  // Dummy copy constructor
70      ;
71 }
72
73
74 Bool_t  AliMUONChamber::IsSensId(Int_t volId) const 
75 {
76 // Returns true if the volume specified by volId is in the list
77 // of sesitive volumes for this chamber
78
79   return fGeometry->IsSensitiveVolume(volId);
80 }  
81
82 void AliMUONChamber::Init()
83 {
84 // Initalisation ..
85 //
86 // ... for chamber segmentation
87   //PH    if ((*fSegmentation)[0]) 
88   //PH    ((AliSegmentation *) (*fSegmentation)[0])->Init(fId);
89     if (fSegmentation->At(0)) 
90     ((AliSegmentation *) fSegmentation->At(0))->Init(fId);
91
92     if (fnsec==2) {
93       //PH      if ((*fSegmentation)[1])
94       //PH      ((AliSegmentation *) (*fSegmentation)[1])->Init(fId);
95         if (fSegmentation->At(1))
96         ((AliSegmentation *) fSegmentation->At(1))->Init(fId);
97     }
98 }
99
100 Int_t   AliMUONChamber::SigGenCond(Float_t x, Float_t y, Float_t z)
101 {
102 // Ask segmentation if signal should be generated 
103     if (fnsec==1) {
104       //PH      return ((AliSegmentation*) (*fSegmentation)[0])
105         return ((AliSegmentation*) fSegmentation->At(0))
106             ->SigGenCond(x, y, z) ;
107     } else {
108       //PH      return (((AliSegmentation*) (*fSegmentation)[0])
109         return (((AliSegmentation*) fSegmentation->At(0))
110                 ->SigGenCond(x, y, z)) ||
111       //PH          (((AliSegmentation*) (*fSegmentation)[1])
112             (((AliSegmentation*) fSegmentation->At(1))
113              ->SigGenCond(x, y, z)) ;
114     }
115 }
116
117
118 void    AliMUONChamber::SigGenInit(Float_t x, Float_t y, Float_t z)
119 {
120 //
121 // Initialisation of segmentation for hit
122 //  
123     if (fnsec==1) {
124       //PH      ((AliSegmentation*) (*fSegmentation)[0])->SigGenInit(x, y, z) ;
125         ((AliSegmentation*) fSegmentation->At(0))->SigGenInit(x, y, z) ;
126     } else {
127       //PH      ((AliSegmentation*) (*fSegmentation)[0])->SigGenInit(x, y, z) ;
128       //PH      ((AliSegmentation*) (*fSegmentation)[1])->SigGenInit(x, y, z) ;
129         ((AliSegmentation*) fSegmentation->At(0))->SigGenInit(x, y, z) ;
130         ((AliSegmentation*) fSegmentation->At(1))->SigGenInit(x, y, z) ;
131     }
132 }
133
134 void AliMUONChamber::ChargeCorrelationInit() {
135 // Initialisation of charge correlation for current hit
136 // the value is stored, and then used by Disintegration
137 if (fnsec==1) 
138     fCurrentCorrel =1;
139 else 
140     // exponential is here to avoid eventual problems in 0 
141     // factor 2 because chargecorrel is q1/q2 and not q1/qtrue
142     fCurrentCorrel = TMath::Exp(gRandom->Gaus(0,fResponse->ChargeCorrel()/2));
143 }
144
145 void AliMUONChamber::DisIntegration(Float_t eloss, Float_t /*tof*/, 
146                                     Float_t xhit, Float_t yhit, Float_t zhit,
147                                     Int_t& nnew,Float_t newclust[6][500]) 
148 {
149 //    
150 //  Generates pad hits (simulated cluster) 
151 //  using the segmentation and the response model 
152     Float_t dx, dy;
153     //
154     // Width of the integration area
155     //
156     dx=fResponse->SigmaIntegration()*fResponse->ChargeSpreadX();
157     dy=fResponse->SigmaIntegration()*fResponse->ChargeSpreadY();
158     //
159     // Get pulse height from energy loss
160     Float_t qtot = fResponse->IntPH(eloss);
161     //
162     // Loop Over Pads
163     
164     Float_t qcheck=0, qp;
165     nnew=0;
166     
167     // Cathode plane loop
168     for (Int_t i=1; i<=fnsec; i++) {
169         qcheck=0;
170         Float_t qcath = qtot * (i==1? fCurrentCorrel : 1/fCurrentCorrel);
171         AliSegmentation * segmentation=
172       //PH          (AliSegmentation *) (*fSegmentation)[i-1];
173             (AliSegmentation *) fSegmentation->At(i-1);
174         for (segmentation->FirstPad(xhit, yhit, zhit, dx, dy); 
175              segmentation->MorePads(); 
176              segmentation->NextPad()) 
177         {
178             qp=fResponse->IntXY(segmentation);
179             qp=TMath::Abs(qp);
180 //
181 //
182             if (qp > 1.e-4) {
183                 qcheck+=qp*qcath;
184             //
185             // --- store signal information
186                 newclust[0][nnew]=qcath;                     // total charge
187                 newclust[1][nnew]=segmentation->Ix();       // ix-position of pad
188                 newclust[2][nnew]=segmentation->Iy();       // iy-position of pad
189                 newclust[3][nnew]=qp * qcath;                // charge on pad
190                 newclust[4][nnew]=segmentation->ISector();  // sector id
191                 newclust[5][nnew]=(Float_t) i;              // counter
192                 nnew++;
193 //              if (i==2) printf("\n i, nnew, q %d %d %f", i, nnew, qp*qcath);
194                 
195             }
196         } // Pad loop
197         
198     } // Cathode plane loop
199 }
200
201
202
203 void AliMUONChamber::InitGeo(Float_t /*zpos*/)
204 {
205 //    sensitive gas gap
206       fdGas= 0.5;
207 //    3% radiation length of aluminum (X0=8.9 cm)      
208       fdAlu= 3.0/100*8.9;
209 }
210
211
212 AliMUONChamber & AliMUONChamber::operator =(const AliMUONChamber& /*rhs*/)
213 {
214 // Dummy assignment operator
215     return *this;
216 }