]>
Commit | Line | Data |
---|---|---|
a9e2aefa | 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 | ||
88cb7938 | 16 | /* $Id$ */ |
a9e2aefa | 17 | |
a9e2aefa | 18 | |
30178c30 | 19 | #include "AliMUONResponseV0.h" |
885d501b | 20 | |
f29ba3e1 | 21 | #include "AliLog.h" |
885d501b | 22 | #include "AliMUON.h" |
23 | #include "AliMUONConstants.h" | |
24 | #include "AliMUONDigit.h" | |
25 | #include "AliMUONGeometrySegmentation.h" | |
26 | #include "AliMUONGeometryTransformer.h" | |
27 | #include "AliMUONHit.h" | |
28 | #include "AliMUONSegmentation.h" | |
29 | #include "AliMpArea.h" | |
30 | #include "AliMpDEManager.h" | |
885d501b | 31 | #include "AliMpVPadIterator.h" |
32 | #include "AliMpVSegmentation.h" | |
33 | #include "AliRun.h" | |
34 | #include "Riostream.h" | |
35 | #include "TVector2.h" | |
36 | #include <TMath.h> | |
37 | #include <TRandom.h> | |
8c343c7c | 38 | |
d5bfadcc | 39 | ClassImp(AliMUONResponseV0) |
40 | ||
885d501b | 41 | AliMUON* muon() |
42 | { | |
43 | return static_cast<AliMUON*>(gAlice->GetModule("MUON")); | |
44 | } | |
45 | ||
46 | void Global2Local(Int_t detElemId, Double_t xg, Double_t yg, Double_t zg, | |
47 | Double_t& xl, Double_t& yl, Double_t& zl) | |
48 | { | |
49 | // ideally should be : | |
50 | // Double_t x,y,z; | |
51 | // AliMUONGeometry::Global2Local(detElemId,xg,yg,zg,x,y,z); | |
52 | // but while waiting for this geometry singleton, let's go through | |
53 | // AliMUON still. | |
54 | ||
55 | const AliMUONGeometryTransformer* transformer = muon()->GetGeometryTransformer(); | |
56 | transformer->Global2Local(detElemId,xg,yg,zg,xl,yl,zl); | |
57 | } | |
58 | ||
59 | AliMUONSegmentation* Segmentation() | |
60 | { | |
61 | static AliMUONSegmentation* segmentation = muon()->GetSegmentation(); | |
62 | return segmentation; | |
63 | } | |
64 | ||
30178c30 | 65 | //__________________________________________________________________________ |
66 | AliMUONResponseV0::AliMUONResponseV0() | |
885d501b | 67 | : AliMUONResponse(), |
68 | fChargeSlope(0.0), | |
69 | fChargeSpreadX(0.0), | |
70 | fChargeSpreadY(0.0), | |
71 | fSigmaIntegration(0.0), | |
72 | fMaxAdc(0), | |
73 | fZeroSuppression(0), | |
74 | fChargeCorrel(0.0), | |
75 | fMathieson(new AliMUONMathieson), | |
76 | fChargeThreshold(1e-4) | |
30178c30 | 77 | { |
885d501b | 78 | // Normal constructor |
79 | AliDebug(1,Form("Default ctor")); | |
30178c30 | 80 | } |
f29ba3e1 | 81 | |
82 | //_________________________________________________________________________ | |
83 | AliMUONResponseV0::AliMUONResponseV0(const AliMUONResponseV0& rhs) | |
84 | : AliMUONResponse(rhs) | |
85 | { | |
86 | // Protected copy constructor | |
87 | ||
88 | AliFatal("Not implemented."); | |
89 | } | |
90 | ||
a713db22 | 91 | //__________________________________________________________________________ |
92 | AliMUONResponseV0::~AliMUONResponseV0() | |
93 | { | |
885d501b | 94 | AliDebug(1,""); |
a713db22 | 95 | delete fMathieson; |
96 | } | |
f29ba3e1 | 97 | |
98 | //________________________________________________________________________ | |
99 | AliMUONResponseV0& AliMUONResponseV0::operator = (const AliMUONResponseV0& rhs) | |
100 | { | |
101 | // Protected assignement operator | |
102 | ||
103 | if (this == &rhs) return *this; | |
104 | ||
105 | AliFatal("Not implemented."); | |
106 | ||
107 | return *this; | |
885d501b | 108 | } |
109 | ||
110 | //______________________________________________________________________________ | |
111 | void | |
112 | AliMUONResponseV0::Print(Option_t*) const | |
113 | { | |
114 | cout << " ChargeSlope=" << fChargeSlope | |
115 | << " ChargeSpreadX,Y=" << fChargeSpreadX | |
116 | << fChargeSpreadY | |
117 | << " ChargeCorrelation=" << fChargeCorrel | |
118 | << endl; | |
119 | ||
120 | //Float_t fChargeSlope; // Slope of the charge distribution | |
121 | //Float_t fChargeSpreadX; // Width of the charge distribution in x | |
122 | //Float_t fChargeSpreadY; // Width of the charge distribution in y | |
123 | //Float_t fSigmaIntegration; // Number of sigma's used for charge distribution | |
124 | //Int_t fMaxAdc; // Maximum ADC channel | |
125 | //Int_t fSaturation; // Pad saturation in ADC channel | |
126 | //Int_t fZeroSuppression; // Zero suppression threshold | |
127 | //Float_t fChargeCorrel; // amplitude of charge correlation on 2 cathods | |
128 | // // is RMS of ln(q1/q2) | |
129 | //AliMUONMathieson* fMathieson; // pointer to mathieson fct | |
130 | //Float_t fChargeThreshold; // Charges below this threshold are = 0 | |
131 | // | |
132 | ||
f29ba3e1 | 133 | } |
134 | ||
d5bfadcc | 135 | //__________________________________________________________________________ |
136 | void AliMUONResponseV0::SetSqrtKx3AndDeriveKx2Kx4(Float_t SqrtKx3) | |
137 | { | |
138 | // Set to "SqrtKx3" the Mathieson parameter K3 ("fSqrtKx3") | |
139 | // in the X direction, perpendicular to the wires, | |
140 | // and derive the Mathieson parameters K2 ("fKx2") and K4 ("fKx4") | |
141 | // in the same direction | |
a713db22 | 142 | fMathieson->SetSqrtKx3AndDeriveKx2Kx4(SqrtKx3); |
d5bfadcc | 143 | } |
144 | ||
145 | //__________________________________________________________________________ | |
146 | void AliMUONResponseV0::SetSqrtKy3AndDeriveKy2Ky4(Float_t SqrtKy3) | |
147 | { | |
148 | // Set to "SqrtKy3" the Mathieson parameter K3 ("fSqrtKy3") | |
149 | // in the Y direction, along the wires, | |
150 | // and derive the Mathieson parameters K2 ("fKy2") and K4 ("fKy4") | |
151 | // in the same direction | |
a713db22 | 152 | fMathieson->SetSqrtKy3AndDeriveKy2Ky4(SqrtKy3); |
d5bfadcc | 153 | } |
a713db22 | 154 | //__________________________________________________________________________ |
a9e2aefa | 155 | Float_t AliMUONResponseV0::IntPH(Float_t eloss) |
156 | { | |
157 | // Calculate charge from given ionization energy loss | |
158 | Int_t nel; | |
4ac9d21e | 159 | nel= Int_t(eloss*1.e9/27.4); |
a9e2aefa | 160 | Float_t charge=0; |
161 | if (nel == 0) nel=1; | |
162 | for (Int_t i=1;i<=nel;i++) { | |
01997fa2 | 163 | Float_t arg=0.; |
164 | while(!arg) arg = gRandom->Rndm(); | |
165 | charge -= fChargeSlope*TMath::Log(arg); | |
a9e2aefa | 166 | } |
167 | return charge; | |
168 | } | |
a713db22 | 169 | |
a713db22 | 170 | //------------------------------------------- |
171 | Float_t AliMUONResponseV0::IntXY(Int_t idDE, AliMUONGeometrySegmentation* segmentation) | |
172 | { | |
173 | // Calculate charge on current pad according to Mathieson distribution | |
a9e2aefa | 174 | |
a713db22 | 175 | return fMathieson->IntXY(idDE, segmentation); |
176 | } | |
885d501b | 177 | |
178 | ||
a713db22 | 179 | //------------------------------------------- |
f7b62f08 | 180 | Int_t AliMUONResponseV0::DigitResponse(Int_t digit, AliMUONTransientDigit* /*where*/) |
a9e2aefa | 181 | { |
32c9ead9 | 182 | // \deprecated method |
183 | // Now part of the digitizer (where it belongs really), e.g. DigitizerV3 | |
184 | // | |
185 | // add white noise and do zero-suppression and signal truncation | |
186 | ||
187 | // Float_t meanNoise = gRandom->Gaus(1, 0.2); | |
b64652f5 | 188 | // correct noise for slat chambers; |
189 | // one more field to add to AliMUONResponseV0 to allow different noises ???? | |
885d501b | 190 | // Float_t meanNoise = gRandom->Gaus(1., 0.2); |
191 | // Float_t noise = gRandom->Gaus(0., meanNoise); | |
192 | Float_t noise = gRandom->Gaus(0., 1.0); | |
104b5ac2 | 193 | digit += TMath::Nint(noise); |
ddc10e24 | 194 | if ( digit <= ZeroSuppression()) digit = 0; |
4ac9d21e | 195 | // if ( digit > MaxAdc()) digit=MaxAdc(); |
885d501b | 196 | if ( digit > Saturation()) |
197 | { | |
198 | digit=Saturation(); | |
199 | } | |
4ac9d21e | 200 | |
a9e2aefa | 201 | return digit; |
202 | } | |
203 | ||
885d501b | 204 | //_____________________________________________________________________________ |
205 | Float_t | |
206 | AliMUONResponseV0::GetAnod(Float_t x) const | |
207 | { | |
208 | // | |
209 | // Return wire coordinate closest to x. | |
210 | // | |
211 | Int_t n = Int_t(x/Pitch()); | |
212 | Float_t wire = (x>0) ? n+0.5 : n-0.5; | |
213 | return Pitch()*wire; | |
214 | } | |
a9e2aefa | 215 | |
885d501b | 216 | //______________________________________________________________________________ |
217 | void | |
218 | AliMUONResponseV0::DisIntegrate(const AliMUONHit& hit, TList& digits) | |
219 | { | |
220 | // | |
32c9ead9 | 221 | // Go from 1 hit to a list of digits. |
222 | // The energy deposition of that hit is first converted into charge | |
223 | // (in IntPH() method), and then this charge is dispatched on several | |
224 | // pads, according to the Mathieson distribution. | |
885d501b | 225 | // |
226 | ||
227 | digits.Clear(); | |
228 | ||
229 | Int_t detElemId = hit.DetElemId(); | |
230 | ||
885d501b | 231 | // Width of the integration area |
885d501b | 232 | Double_t dx = SigmaIntegration()*ChargeSpreadX(); |
233 | Double_t dy = SigmaIntegration()*ChargeSpreadY(); | |
234 | ||
235 | // Use that (dx,dy) to specify the area upon which | |
236 | // we will iterate to spread charge into. | |
237 | Double_t x,y,z; | |
238 | Global2Local(detElemId,hit.X(),hit.Y(),hit.Z(),x,y,z); | |
239 | x = GetAnod(x); | |
240 | TVector2 hitPosition(x,y); | |
241 | AliMpArea area(hitPosition,TVector2(dx,dy)); | |
242 | ||
32c9ead9 | 243 | // Get pulse height from energy loss. |
885d501b | 244 | Float_t qtot = IntPH(hit.Eloss()); |
245 | ||
32c9ead9 | 246 | // Get the charge correlation between cathodes. |
885d501b | 247 | Float_t currentCorrel = TMath::Exp(gRandom->Gaus(0.0,ChargeCorrel()/2.0)); |
a9e2aefa | 248 | |
885d501b | 249 | for ( Int_t cath = 0; cath < 2; ++cath ) |
250 | { | |
251 | Float_t qcath = qtot * ( cath == 0 ? currentCorrel : 1.0/currentCorrel); | |
252 | ||
885d501b | 253 | // Get an iterator to loop over pads, within the given area. |
32c9ead9 | 254 | const AliMpVSegmentation* seg = |
885d501b | 255 | Segmentation()->GetMpSegmentation(detElemId,cath); |
885d501b | 256 | |
32c9ead9 | 257 | AliMpVPadIterator* it = seg->CreateIterator(area); |
258 | ||
259 | if (!it) | |
260 | { | |
261 | AliError(Form("Could not get iterator for detElemId %d",detElemId)); | |
262 | return; | |
263 | } | |
264 | ||
265 | // Start loop over pads. | |
266 | it->First(); | |
267 | ||
268 | if ( it->IsDone() ) | |
269 | { | |
270 | // Exceptional case : iterator is built, but is invalid from the start. | |
271 | AliMpPad pad = seg->PadByPosition(area.Position(),kFALSE); | |
272 | if ( pad.IsValid() ) | |
885d501b | 273 | { |
32c9ead9 | 274 | AliWarning(Form("Got an invalid iterator bug (area.Position() is within " |
275 | " DE but the iterator is void) for detElemId %d cath %d", | |
276 | detElemId,cath)); | |
885d501b | 277 | } |
32c9ead9 | 278 | else |
885d501b | 279 | { |
32c9ead9 | 280 | AliError(Form("Got an invalid iterator bug for detElemId %d cath %d." |
281 | "Might be a bad hit ? area.Position()=(%e,%e) " | |
282 | "Dimensions()=(%e,%e)", | |
283 | detElemId,cath,area.Position().X(),area.Position().Y(), | |
284 | area.Dimensions().X(),area.Dimensions().Y())); | |
885d501b | 285 | } |
286 | delete it; | |
32c9ead9 | 287 | return; |
288 | } | |
289 | ||
290 | while ( !it->IsDone() ) | |
291 | { | |
292 | // For each pad given by the iterator, compute the charge of that | |
293 | // pad, according to the Mathieson distribution. | |
294 | AliMpPad pad = it->CurrentItem(); | |
295 | TVector2 lowerLeft(hitPosition-pad.Position()-pad.Dimensions()); | |
296 | TVector2 upperRight(lowerLeft + pad.Dimensions()*2.0); | |
297 | Float_t qp = TMath::Abs(fMathieson->IntXY(lowerLeft.X(),lowerLeft.Y(), | |
298 | upperRight.X(),upperRight.Y())); | |
299 | ||
300 | Int_t icharge = Int_t(qp*qcath); | |
301 | ||
302 | if ( qp > fChargeThreshold ) | |
303 | { | |
304 | // If we're above threshold, then we create a digit, | |
305 | // and fill it with relevant information, including electronics. | |
306 | AliMUONDigit* d = new AliMUONDigit; | |
307 | d->SetDetElemId(detElemId); | |
308 | d->SetPadX(pad.GetIndices().GetFirst()); | |
309 | d->SetPadY(pad.GetIndices().GetSecond()); | |
310 | d->SetSignal(icharge); | |
311 | d->AddPhysicsSignal(d->Signal()); | |
312 | d->SetCathode(cath); | |
313 | d->SetElectronics(pad.GetLocation().GetFirst(), | |
314 | pad.GetLocation().GetSecond()); | |
315 | digits.Add(d); | |
316 | } | |
317 | it->Next(); | |
318 | } | |
319 | delete it; | |
885d501b | 320 | } |
321 | } | |
a9e2aefa | 322 | |
323 | ||
324 |