]>
Commit | Line | Data |
---|---|---|
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 | //----------------------------------------------------------------------------- | |
19 | // Class AliMUONResponseV0 | |
20 | // -------------------------- | |
21 | // Implementation of | |
22 | // Mathieson response | |
23 | //----------------------------------------------------------------------------- | |
24 | ||
25 | #include "AliMUONResponseV0.h" | |
26 | #include "AliMUON.h" | |
27 | #include "AliMUONConstants.h" | |
28 | #include "AliMUONDigit.h" | |
29 | #include "AliMUONGeometryTransformer.h" | |
30 | #include "AliMUONHit.h" | |
31 | #include "AliMUONConstants.h" | |
32 | ||
33 | #include "AliMpArea.h" | |
34 | #include "AliMpDEManager.h" | |
35 | #include "AliMpVPadIterator.h" | |
36 | #include "AliMpSegmentation.h" | |
37 | #include "AliMpVSegmentation.h" | |
38 | #include "AliMpCathodType.h" | |
39 | ||
40 | #include "AliRun.h" | |
41 | #include "AliLog.h" | |
42 | ||
43 | #include "Riostream.h" | |
44 | #include "TVector2.h" | |
45 | #include <TMath.h> | |
46 | #include <TRandom.h> | |
47 | ||
48 | using std::endl; | |
49 | using std::cout; | |
50 | /// \cond CLASSIMP | |
51 | ClassImp(AliMUONResponseV0) | |
52 | /// \endcond | |
53 | ||
54 | AliMUON* muon() | |
55 | { | |
56 | return static_cast<AliMUON*>(gAlice->GetModule("MUON")); | |
57 | } | |
58 | ||
59 | void Global2Local(Int_t detElemId, Double_t xg, Double_t yg, Double_t zg, | |
60 | Double_t& xl, Double_t& yl, Double_t& zl) | |
61 | { | |
62 | /// ideally should be : | |
63 | /// Double_t x,y,z; | |
64 | /// AliMUONGeometry::Global2Local(detElemId,xg,yg,zg,x,y,z); | |
65 | /// but while waiting for this geometry singleton, let's go through | |
66 | /// AliMUON still. | |
67 | ||
68 | const AliMUONGeometryTransformer* transformer = muon()->GetGeometryTransformer(); | |
69 | transformer->Global2Local(detElemId,xg,yg,zg,xl,yl,zl); | |
70 | } | |
71 | ||
72 | //__________________________________________________________________________ | |
73 | AliMUONResponseV0::AliMUONResponseV0() | |
74 | : AliMUONResponse(), | |
75 | fChargeSlope(0.0), | |
76 | fChargeSpreadX(0.0), | |
77 | fChargeSpreadY(0.0), | |
78 | fSigmaIntegration(0.0), | |
79 | fMaxAdc(0), | |
80 | fSaturation(0), | |
81 | fZeroSuppression(0), | |
82 | fChargeCorrel(0.0), | |
83 | fMathieson(new AliMUONMathieson), | |
84 | fChargeThreshold(1e-4), | |
85 | fIsTailEffect(kFALSE) | |
86 | { | |
87 | /// Normal constructor | |
88 | AliDebug(1,Form("Default ctor")); | |
89 | } | |
90 | ||
91 | //__________________________________________________________________________ | |
92 | AliMUONResponseV0::AliMUONResponseV0(const AliMUONResponseV0& other) | |
93 | : AliMUONResponse(), | |
94 | fChargeSlope(0.0), | |
95 | fChargeSpreadX(0.0), | |
96 | fChargeSpreadY(0.0), | |
97 | fSigmaIntegration(0.0), | |
98 | fMaxAdc(0), | |
99 | fSaturation(0), | |
100 | fZeroSuppression(0), | |
101 | fChargeCorrel(0.0), | |
102 | fMathieson(0), | |
103 | fChargeThreshold(1e-4), | |
104 | fIsTailEffect(kFALSE) | |
105 | { | |
106 | /// copy ctor | |
107 | other.CopyTo(*this); | |
108 | } | |
109 | ||
110 | //__________________________________________________________________________ | |
111 | AliMUONResponseV0& | |
112 | AliMUONResponseV0::operator=(const AliMUONResponseV0& other) | |
113 | { | |
114 | /// Assignment operator | |
115 | other.CopyTo(*this); | |
116 | return *this; | |
117 | } | |
118 | ||
119 | //__________________________________________________________________________ | |
120 | AliMUONResponseV0::~AliMUONResponseV0() | |
121 | { | |
122 | /// Destructor | |
123 | ||
124 | AliDebug(1,""); | |
125 | delete fMathieson; | |
126 | } | |
127 | ||
128 | //______________________________________________________________________________ | |
129 | void | |
130 | AliMUONResponseV0::CopyTo(AliMUONResponseV0& other) const | |
131 | { | |
132 | /// Copy *this to other | |
133 | other.fChargeSlope=fChargeSlope; | |
134 | other.fChargeSpreadX=fChargeSpreadX; | |
135 | other.fChargeSpreadY=fChargeSpreadY; | |
136 | other.fSigmaIntegration=fSigmaIntegration; | |
137 | other.fMaxAdc=fMaxAdc; | |
138 | other.fSaturation=fSaturation; | |
139 | other.fZeroSuppression=fZeroSuppression; | |
140 | other.fChargeCorrel=fChargeCorrel; | |
141 | delete other.fMathieson; | |
142 | other.fMathieson = new AliMUONMathieson(*fMathieson); | |
143 | other.fChargeThreshold=fChargeThreshold; | |
144 | } | |
145 | ||
146 | //______________________________________________________________________________ | |
147 | void | |
148 | AliMUONResponseV0::Print(Option_t*) const | |
149 | { | |
150 | /// Printing | |
151 | ||
152 | cout << " ChargeSlope=" << fChargeSlope | |
153 | << " ChargeSpreadX,Y=" << fChargeSpreadX | |
154 | << fChargeSpreadY | |
155 | << " ChargeCorrelation=" << fChargeCorrel | |
156 | << endl; | |
157 | } | |
158 | ||
159 | //__________________________________________________________________________ | |
160 | void AliMUONResponseV0::SetSqrtKx3AndDeriveKx2Kx4(Float_t SqrtKx3) | |
161 | { | |
162 | /// Set to "SqrtKx3" the Mathieson parameter K3 ("fSqrtKx3") | |
163 | /// in the X direction, perpendicular to the wires, | |
164 | /// and derive the Mathieson parameters K2 ("fKx2") and K4 ("fKx4") | |
165 | /// in the same direction | |
166 | fMathieson->SetSqrtKx3AndDeriveKx2Kx4(SqrtKx3); | |
167 | } | |
168 | ||
169 | //__________________________________________________________________________ | |
170 | void AliMUONResponseV0::SetSqrtKy3AndDeriveKy2Ky4(Float_t SqrtKy3) | |
171 | { | |
172 | /// Set to "SqrtKy3" the Mathieson parameter K3 ("fSqrtKy3") | |
173 | /// in the Y direction, along the wires, | |
174 | /// and derive the Mathieson parameters K2 ("fKy2") and K4 ("fKy4") | |
175 | /// in the same direction | |
176 | fMathieson->SetSqrtKy3AndDeriveKy2Ky4(SqrtKy3); | |
177 | } | |
178 | //__________________________________________________________________________ | |
179 | Float_t AliMUONResponseV0::IntPH(Float_t eloss) const | |
180 | { | |
181 | /// Calculate charge from given ionization energy loss | |
182 | Int_t nel; | |
183 | nel= Int_t(eloss*1.e9/27.4); | |
184 | Float_t charge=0; | |
185 | if (nel == 0) nel=1; | |
186 | for (Int_t i=1;i<=nel;i++) { | |
187 | Float_t arg=0.; | |
188 | while(!arg) arg = gRandom->Rndm(); | |
189 | charge -= fChargeSlope*TMath::Log(arg); | |
190 | } | |
191 | return charge; | |
192 | } | |
193 | ||
194 | //_____________________________________________________________________________ | |
195 | Float_t | |
196 | AliMUONResponseV0::GetAnod(Float_t x) const | |
197 | { | |
198 | /// Return wire coordinate closest to x. | |
199 | ||
200 | Int_t n = Int_t(x/Pitch()); | |
201 | Float_t wire = (x>0) ? n+0.5 : n-0.5; | |
202 | return Pitch()*wire; | |
203 | } | |
204 | ||
205 | //______________________________________________________________________________ | |
206 | void | |
207 | AliMUONResponseV0::DisIntegrate(const AliMUONHit& hit, TList& digits, Float_t timeDif) | |
208 | { | |
209 | /// Go from 1 hit to a list of digits. | |
210 | /// The energy deposition of that hit is first converted into charge | |
211 | /// (in IntPH() method), and then this charge is dispatched on several | |
212 | /// pads, according to the Mathieson distribution. | |
213 | ||
214 | digits.Clear(); | |
215 | ||
216 | Int_t detElemId = hit.DetElemId(); | |
217 | Double_t hitX = hit.X() ; | |
218 | Double_t hitY = hit.Y() ; | |
219 | Double_t hitZ = hit.Z() ; | |
220 | ||
221 | // Width of the integration area | |
222 | Double_t dx = SigmaIntegration()*ChargeSpreadX(); | |
223 | Double_t dy = SigmaIntegration()*ChargeSpreadY(); | |
224 | ||
225 | //Modify to take the tailing effect. | |
226 | if(fIsTailEffect){ | |
227 | Double_t locX,locY,locZ,globXCenter,globYCenter,globZ; | |
228 | Int_t para = 5; // This parameter is a natural number(excluding zero), higher the value less is the tailing effect | |
229 | Double_t termA = 1.0; | |
230 | Double_t termB = 1.0; | |
231 | if(para>0){ | |
232 | for ( Int_t cath = AliMp::kCath0; cath <= AliMp::kCath1; ++cath ) | |
233 | { | |
234 | // Get an iterator to loop over pads, within the given area. | |
235 | const AliMpVSegmentation* seg = | |
236 | AliMpSegmentation::Instance() | |
237 | ->GetMpSegmentation(detElemId,AliMp::GetCathodType(cath)); | |
238 | AliMp::PlaneType plane = seg->PlaneType(); | |
239 | ||
240 | if(plane == AliMp::kBendingPlane) { | |
241 | Global2Local(detElemId,hitX,hitY,hitZ,locX,locY,locZ); | |
242 | AliMpPad pad = seg->PadByPosition(locX,locY,kFALSE); | |
243 | if(pad.IsValid()){ | |
244 | Double_t locYCenter = pad.GetPositionY(); | |
245 | Double_t locXCenter = pad.GetPositionX(); | |
246 | const AliMUONGeometryTransformer* transformer = muon()->GetGeometryTransformer(); | |
247 | transformer->Local2Global(detElemId,locXCenter,locYCenter,locZ,globXCenter,globYCenter,globZ); | |
248 | for(Int_t itime = 0; itime<para; itime++) | |
249 | termA *= 10.0; | |
250 | ||
251 | for(Int_t itime = 0; itime<Int_t((2*para) + 1); itime++) | |
252 | termB *= (hitY - globYCenter) ; | |
253 | ||
254 | hitY = hitY + termA*termB; | |
255 | }// if the pad is a valid one | |
256 | }// if bending plane | |
257 | }// cathode loop | |
258 | }// if para > 0 condn | |
259 | }// if tail effect | |
260 | ||
261 | // Use that (dx,dy) to specify the area upon which | |
262 | // we will iterate to spread charge into. | |
263 | Double_t x,y,z; | |
264 | Global2Local(detElemId,hitX,hitY,hitZ,x,y,z); | |
265 | x = GetAnod(x); | |
266 | AliMpArea area(x,y,dx,dy); | |
267 | ||
268 | // Get pulse height from energy loss. | |
269 | Float_t qtot = IntPH(hit.Eloss()); | |
270 | ||
271 | // If from a pileup event we apply a reduction factor to the charge | |
272 | if (timeDif!=0){ | |
273 | qtot = AliMUONConstants::ReducedQTot(qtot,timeDif); | |
274 | } | |
275 | ||
276 | // Scale the charge to it'll (roughly) be in fC | |
277 | qtot *= AliMUONConstants::DefaultADC2MV()*AliMUONConstants::DefaultA0()*AliMUONConstants::DefaultCapa(); | |
278 | ||
279 | // Get the charge correlation between cathodes. | |
280 | Float_t currentCorrel = TMath::Exp(gRandom->Gaus(0.0,ChargeCorrel()/2.0)); | |
281 | ||
282 | for ( Int_t cath = AliMp::kCath0; cath <= AliMp::kCath1; ++cath ) | |
283 | { | |
284 | Float_t qcath = qtot * ( cath == 0 ? currentCorrel : 1.0/currentCorrel); | |
285 | ||
286 | // Get an iterator to loop over pads, within the given area. | |
287 | const AliMpVSegmentation* seg = | |
288 | AliMpSegmentation::Instance() | |
289 | ->GetMpSegmentation(detElemId,AliMp::GetCathodType(cath)); | |
290 | ||
291 | AliMpVPadIterator* it = seg->CreateIterator(area); | |
292 | ||
293 | if (!it) | |
294 | { | |
295 | AliError(Form("Could not get iterator for detElemId %d",detElemId)); | |
296 | return; | |
297 | } | |
298 | ||
299 | // Start loop over pads. | |
300 | it->First(); | |
301 | ||
302 | if ( it->IsDone() ) | |
303 | { | |
304 | // Exceptional case : iterator is built, but is invalid from the start. | |
305 | AliMpPad pad = seg->PadByPosition(area.GetPositionX(),area.GetPositionY(), | |
306 | kFALSE); | |
307 | if ( pad.IsValid() ) | |
308 | { | |
309 | AliDebug(1, Form("Got an invalid iterator bug (area.Position() is within " | |
310 | " DE but the iterator is void) for detElemId %d cath %d", | |
311 | detElemId,cath)); | |
312 | } | |
313 | else | |
314 | { | |
315 | AliDebug(1, Form("Got an invalid iterator bug for detElemId %d cath %d." | |
316 | "Might be a bad hit ? area.Position()=(%e,%e) " | |
317 | "Dimensions()=(%e,%e)", | |
318 | detElemId,cath,area.GetPositionX(),area.GetPositionY(), | |
319 | area.GetDimensionX(),area.GetDimensionY())); | |
320 | } | |
321 | delete it; | |
322 | return; | |
323 | } | |
324 | ||
325 | while ( !it->IsDone() ) | |
326 | { | |
327 | // For each pad given by the iterator, compute the charge of that | |
328 | // pad, according to the Mathieson distribution. | |
329 | AliMpPad pad = it->CurrentItem(); | |
330 | TVector2 lowerLeft(TVector2(x,y)-TVector2(pad.GetPositionX(),pad.GetPositionY())- | |
331 | TVector2(pad.GetDimensionX(),pad.GetDimensionY())); | |
332 | TVector2 upperRight(lowerLeft + TVector2(pad.GetDimensionX(),pad.GetDimensionY())*2.0); | |
333 | Float_t qp = TMath::Abs(fMathieson->IntXY(lowerLeft.X(),lowerLeft.Y(), | |
334 | upperRight.X(),upperRight.Y())); | |
335 | ||
336 | if ( qp > fChargeThreshold && | |
337 | qp*qcath > AliMUONConstants::DefaultADC2MV()*AliMUONConstants::DefaultA0()*AliMUONConstants::DefaultCapa() ) | |
338 | { | |
339 | // If we're above threshold, then we create a digit, | |
340 | // and fill it with relevant information, including electronics. | |
341 | ||
342 | // note that the second condition above is to be backward compatible (when | |
343 | // the sdigitizer was making a cut on Int_t(qp*qcath) > 0 and qcath was in ADC, not in fC) | |
344 | ||
345 | AliMUONDigit* d = new AliMUONDigit(detElemId,pad.GetManuId(), | |
346 | pad.GetManuChannel(),cath); | |
347 | d->SetPadXY(pad.GetIx(),pad.GetIy()); | |
348 | d->SetCharge(qp*qcath); | |
349 | digits.Add(d); | |
350 | } | |
351 | it->Next(); | |
352 | } | |
353 | delete it; | |
354 | } | |
355 | } | |
356 | ||
357 | ||
358 |