]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONChamber.cxx
stdlib.h included (for Alpha)
[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 $Log$
17 Revision 1.9  2001/01/26 21:35:54  morsch
18 All pointers set to 0 in default constructor.
19
20 Revision 1.8  2001/01/17 20:53:40  hristov
21 Destructors corrected to avoid memory leaks
22
23 Revision 1.7  2000/12/20 13:00:22  egangler
24
25 Added charge correlation between cathods.
26 In Config_slat.C, use
27  MUON->Chamber(chamber-1).SetChargeCorrel(0.11); to set the RMS of
28  q1/q2 to 11 % (number from Alberto)
29  This is stored in AliMUONChamber fChargeCorrel member.
30  At generation time, when a tracks enters the volume,
31  AliMUONv1::StepManager calls
32  AliMUONChamber::ChargeCorrelationInit() to set the current value of
33  fCurrentCorrel which is then used at Disintegration level to scale
34  appropriately the PadHit charges.
35
36 Revision 1.6  2000/10/09 14:01:12  morsch
37 Double inclusion of AliResponse removed.
38
39 Revision 1.5  2000/07/03 11:54:57  morsch
40 AliMUONSegmentation and AliMUONHitMap have been replaced by AliSegmentation and AliHitMap in STEER
41 The methods GetPadIxy and GetPadXxy of AliMUONSegmentation have changed name to GetPadI and GetPadC.
42
43 Revision 1.4  2000/06/29 12:34:09  morsch
44 AliMUONSegmentation class has been made independent of AliMUONChamber. This makes
45 it usable with any other geometry class. The link to the object to which it belongs is
46 established via an index. This assumes that there exists a global geometry manager
47 from which the pointer to the parent object can be obtained (in our case gAlice).
48
49 Revision 1.3  2000/06/28 15:16:35  morsch
50 (1) Client code adapted to new method signatures in AliMUONSegmentation (see comments there)
51 to allow development of slat-muon chamber simulation and reconstruction code in the MUON
52 framework. The changes should have no side effects (mostly dummy arguments).
53 (2) Hit disintegration uses 3-dim hit coordinates to allow simulation
54 of chambers with overlapping modules (MakePadHits, Disintegration).
55
56 Revision 1.2  2000/06/15 07:58:48  morsch
57 Code from MUON-dev joined
58
59 Revision 1.1.2.5  2000/06/09 21:27:01  morsch
60 Most coding rule violations corrected.
61
62 Revision 1.1.2.4  2000/05/05 11:34:12  morsch
63 Log inside comments.
64
65 Revision 1.1.2.3  2000/05/05 10:09:52  morsch
66 Log messages included
67 */
68
69 // --- MUON includes ---
70 #include "AliMUONChamber.h"
71
72 // --- ROOT includes ---
73
74 #include "TRandom.h"
75 #include "TMath.h"
76
77 ClassImp(AliMUONChamber)        
78
79     AliMUONChamber::AliMUONChamber()
80 {
81 // Default constructor
82     fSegmentation = 0;
83     fResponse=0;
84     fnsec=1;
85     fReconstruction=0;
86     fId=0;
87     // to avoid mistakes if ChargeCorrelInit is not called
88     fCurrentCorrel =1;
89 }
90
91     AliMUONChamber::AliMUONChamber(Int_t id) 
92 {
93 // Construtor with chamber id 
94     fSegmentation = new TObjArray(2);
95     (*fSegmentation)[0] = 0;
96     (*fSegmentation)[1] = 0;    
97     fResponse=0;
98     fnsec=1;
99     fReconstruction=0;
100     fId=id;
101     // to avoid mistakes if ChargeCorrelInit is not called
102     fCurrentCorrel =1;
103 }
104
105 AliMUONChamber::~AliMUONChamber() 
106 {
107 // Destructor
108   if (fSegmentation) {
109     fSegmentation->Delete();
110     delete fSegmentation;
111   }
112 }
113
114 AliMUONChamber::AliMUONChamber(const AliMUONChamber& rChamber)
115 {
116 // Dummy copy constructor
117     ;
118 }
119
120
121 void AliMUONChamber::Init()
122 {
123 // Initalisation ..
124 //
125 // ... for chamber segmentation
126     if ((*fSegmentation)[0]) 
127     ((AliSegmentation *) (*fSegmentation)[0])->Init(fId);
128
129     if (fnsec==2) {
130         if ((*fSegmentation)[1])
131         ((AliSegmentation *) (*fSegmentation)[1])->Init(fId);
132     }
133 }
134
135 Int_t   AliMUONChamber::SigGenCond(Float_t x, Float_t y, Float_t z)
136 {
137 // Ask segmentation if signal should be generated 
138     if (fnsec==1) {
139         return ((AliSegmentation*) (*fSegmentation)[0])
140             ->SigGenCond(x, y, z) ;
141     } else {
142         return (((AliSegmentation*) (*fSegmentation)[0])
143                 ->SigGenCond(x, y, z)) ||
144             (((AliSegmentation*) (*fSegmentation)[1])
145              ->SigGenCond(x, y, z)) ;
146     }
147 }
148
149
150 void    AliMUONChamber::SigGenInit(Float_t x, Float_t y, Float_t z)
151 {
152 //
153 // Initialisation of segmentation for hit
154 //  
155     if (fnsec==1) {
156         ((AliSegmentation*) (*fSegmentation)[0])->SigGenInit(x, y, z) ;
157     } else {
158         ((AliSegmentation*) (*fSegmentation)[0])->SigGenInit(x, y, z) ;
159         ((AliSegmentation*) (*fSegmentation)[1])->SigGenInit(x, y, z) ;
160     }
161 }
162
163 void AliMUONChamber::ChargeCorrelationInit() {
164 // Initialisation of charge correlation for current hit
165 // the value is stored, and then used by Disintegration
166 if (fnsec==1) 
167     fCurrentCorrel =1;
168 else 
169     // exponential is here to avoid eventual problems in 0 
170     // factor 2 because chargecorrel is q1/q2 and not q1/qtrue
171     fCurrentCorrel = TMath::Exp(gRandom->Gaus(0,fResponse->ChargeCorrel()/2));
172 }
173
174 void AliMUONChamber::DisIntegration(Float_t eloss, Float_t tof, 
175                                     Float_t xhit, Float_t yhit, Float_t zhit,
176                                     Int_t& nnew,Float_t newclust[6][500]) 
177 {
178 //    
179 //  Generates pad hits (simulated cluster) 
180 //  using the segmentation and the response model 
181     Float_t dx, dy;
182     //
183     // Width of the integration area
184     //
185     dx=fResponse->SigmaIntegration()*fResponse->ChargeSpreadX();
186     dy=fResponse->SigmaIntegration()*fResponse->ChargeSpreadY();
187     //
188     // Get pulse height from energy loss
189     Float_t qtot = fResponse->IntPH(eloss);
190     //
191     // Loop Over Pads
192     
193     Float_t qcheck=0, qp;
194     nnew=0;
195     
196     // Cathode plane loop
197     for (Int_t i=1; i<=fnsec; i++) {
198         qcheck=0;
199         Float_t qcath = qtot * (i==1? fCurrentCorrel : 1/fCurrentCorrel);
200         AliSegmentation * segmentation=
201             (AliSegmentation *) (*fSegmentation)[i-1];
202         for (segmentation->FirstPad(xhit, yhit, zhit, dx, dy); 
203              segmentation->MorePads(); 
204              segmentation->NextPad()) 
205         {
206             qp=fResponse->IntXY(segmentation);
207             qp=TMath::Abs(qp);
208 //
209 //
210             if (qp > 1.e-4) {
211                 qcheck+=qp*qcath;
212             //
213             // --- store signal information
214                 newclust[0][nnew]=qcath;                     // total charge
215                 newclust[1][nnew]=segmentation->Ix();       // ix-position of pad
216                 newclust[2][nnew]=segmentation->Iy();       // iy-position of pad
217                 newclust[3][nnew]=qp * qcath;                // charge on pad
218                 newclust[4][nnew]=segmentation->ISector();  // sector id
219                 newclust[5][nnew]=(Float_t) i;              // counter
220                 nnew++;
221 //              if (i==2) printf("\n i, nnew, q %d %d %f", i, nnew, qp*qcath);
222                 
223             }
224         } // Pad loop
225         
226     } // Cathode plane loop
227 }
228
229
230
231 void AliMUONChamber::InitGeo(Float_t zpos)
232 {
233 //    sensitive gas gap
234       fdGas= 0.5;
235 //    3% radiation length of aluminum (X0=8.9 cm)      
236       fdAlu= 3.0/100*8.9;
237 }
238
239
240 AliMUONChamber & AliMUONChamber::operator =(const AliMUONChamber& rhs)
241 {
242 // Dummy assignment operator
243     return *this;
244 }