Line data Source code
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 16 : ClassImp(AliMUONResponseV0)
52 : /// \endcond
53 :
54 : AliMUON* muon()
55 : {
56 498 : 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 332 : const AliMUONGeometryTransformer* transformer = muon()->GetGeometryTransformer();
69 166 : transformer->Global2Local(detElemId,xg,yg,zg,xl,yl,zl);
70 166 : }
71 :
72 : //__________________________________________________________________________
73 : AliMUONResponseV0::AliMUONResponseV0()
74 132 : : AliMUONResponse(),
75 132 : fChargeSlope(0.0),
76 132 : fChargeSpreadX(0.0),
77 132 : fChargeSpreadY(0.0),
78 132 : fSigmaIntegration(0.0),
79 132 : fMaxAdc(0),
80 132 : fSaturation(0),
81 132 : fZeroSuppression(0),
82 132 : fChargeCorrel(0.0),
83 396 : fMathieson(new AliMUONMathieson),
84 132 : fChargeThreshold(1e-4),
85 132 : fIsTailEffect(kFALSE)
86 660 : {
87 : /// Normal constructor
88 660 : AliDebug(1,Form("Default ctor"));
89 264 : }
90 :
91 : //__________________________________________________________________________
92 : AliMUONResponseV0::AliMUONResponseV0(const AliMUONResponseV0& other)
93 0 : : AliMUONResponse(),
94 0 : fChargeSlope(0.0),
95 0 : fChargeSpreadX(0.0),
96 0 : fChargeSpreadY(0.0),
97 0 : fSigmaIntegration(0.0),
98 0 : fMaxAdc(0),
99 0 : fSaturation(0),
100 0 : fZeroSuppression(0),
101 0 : fChargeCorrel(0.0),
102 0 : fMathieson(0),
103 0 : fChargeThreshold(1e-4),
104 0 : fIsTailEffect(kFALSE)
105 0 : {
106 : /// copy ctor
107 0 : other.CopyTo(*this);
108 0 : }
109 :
110 : //__________________________________________________________________________
111 : AliMUONResponseV0&
112 : AliMUONResponseV0::operator=(const AliMUONResponseV0& other)
113 : {
114 : /// Assignment operator
115 0 : other.CopyTo(*this);
116 0 : return *this;
117 : }
118 :
119 : //__________________________________________________________________________
120 : AliMUONResponseV0::~AliMUONResponseV0()
121 790 : {
122 : /// Destructor
123 :
124 660 : AliDebug(1,"");
125 264 : delete fMathieson;
126 395 : }
127 :
128 : //______________________________________________________________________________
129 : void
130 : AliMUONResponseV0::CopyTo(AliMUONResponseV0& other) const
131 : {
132 : /// Copy *this to other
133 0 : other.fChargeSlope=fChargeSlope;
134 0 : other.fChargeSpreadX=fChargeSpreadX;
135 0 : other.fChargeSpreadY=fChargeSpreadY;
136 0 : other.fSigmaIntegration=fSigmaIntegration;
137 0 : other.fMaxAdc=fMaxAdc;
138 0 : other.fSaturation=fSaturation;
139 0 : other.fZeroSuppression=fZeroSuppression;
140 0 : other.fChargeCorrel=fChargeCorrel;
141 0 : delete other.fMathieson;
142 0 : other.fMathieson = new AliMUONMathieson(*fMathieson);
143 0 : other.fChargeThreshold=fChargeThreshold;
144 0 : }
145 :
146 : //______________________________________________________________________________
147 : void
148 : AliMUONResponseV0::Print(Option_t*) const
149 : {
150 : /// Printing
151 :
152 0 : cout << " ChargeSlope=" << fChargeSlope
153 0 : << " ChargeSpreadX,Y=" << fChargeSpreadX
154 0 : << fChargeSpreadY
155 0 : << " ChargeCorrelation=" << fChargeCorrel
156 0 : << endl;
157 0 : }
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 4 : fMathieson->SetSqrtKx3AndDeriveKx2Kx4(SqrtKx3);
167 2 : }
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 4 : fMathieson->SetSqrtKy3AndDeriveKy2Ky4(SqrtKy3);
177 2 : }
178 : //__________________________________________________________________________
179 : Float_t AliMUONResponseV0::IntPH(Float_t eloss) const
180 : {
181 : /// Calculate charge from given ionization energy loss
182 : Int_t nel;
183 166 : nel= Int_t(eloss*1.e9/27.4);
184 : Float_t charge=0;
185 83 : if (nel == 0) nel=1;
186 7062 : for (Int_t i=1;i<=nel;i++) {
187 : Float_t arg=0.;
188 13792 : while(!arg) arg = gRandom->Rndm();
189 3448 : charge -= fChargeSlope*TMath::Log(arg);
190 : }
191 83 : 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 166 : Int_t n = Int_t(x/Pitch());
201 83 : Float_t wire = (x>0) ? n+0.5 : n-0.5;
202 83 : 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 166 : digits.Clear();
215 :
216 83 : Int_t detElemId = hit.DetElemId();
217 83 : Double_t hitX = hit.X() ;
218 83 : Double_t hitY = hit.Y() ;
219 83 : Double_t hitZ = hit.Z() ;
220 :
221 : // Width of the integration area
222 83 : Double_t dx = SigmaIntegration()*ChargeSpreadX();
223 83 : Double_t dy = SigmaIntegration()*ChargeSpreadY();
224 :
225 : //Modify to take the tailing effect.
226 83 : if(fIsTailEffect){
227 83 : 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 83 : if(para>0){
232 498 : 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 332 : AliMpSegmentation::Instance()
237 166 : ->GetMpSegmentation(detElemId,AliMp::GetCathodType(cath));
238 166 : AliMp::PlaneType plane = seg->PlaneType();
239 :
240 166 : if(plane == AliMp::kBendingPlane) {
241 83 : Global2Local(detElemId,hitX,hitY,hitZ,locX,locY,locZ);
242 83 : AliMpPad pad = seg->PadByPosition(locX,locY,kFALSE);
243 83 : if(pad.IsValid()){
244 83 : Double_t locYCenter = pad.GetPositionY();
245 83 : Double_t locXCenter = pad.GetPositionX();
246 166 : const AliMUONGeometryTransformer* transformer = muon()->GetGeometryTransformer();
247 83 : transformer->Local2Global(detElemId,locXCenter,locYCenter,locZ,globXCenter,globYCenter,globZ);
248 996 : for(Int_t itime = 0; itime<para; itime++)
249 415 : termA *= 10.0;
250 :
251 1992 : for(Int_t itime = 0; itime<Int_t((2*para) + 1); itime++)
252 913 : termB *= (hitY - globYCenter) ;
253 :
254 83 : hitY = hitY + termA*termB;
255 83 : }// if the pad is a valid one
256 83 : }// if bending plane
257 : }// cathode loop
258 83 : }// if para > 0 condn
259 83 : }// if tail effect
260 :
261 : // Use that (dx,dy) to specify the area upon which
262 : // we will iterate to spread charge into.
263 83 : Double_t x,y,z;
264 83 : Global2Local(detElemId,hitX,hitY,hitZ,x,y,z);
265 83 : x = GetAnod(x);
266 83 : AliMpArea area(x,y,dx,dy);
267 :
268 : // Get pulse height from energy loss.
269 83 : Float_t qtot = IntPH(hit.Eloss());
270 :
271 : // If from a pileup event we apply a reduction factor to the charge
272 83 : if (timeDif!=0){
273 0 : qtot = AliMUONConstants::ReducedQTot(qtot,timeDif);
274 0 : }
275 :
276 : // Scale the charge to it'll (roughly) be in fC
277 83 : qtot *= AliMUONConstants::DefaultADC2MV()*AliMUONConstants::DefaultA0()*AliMUONConstants::DefaultCapa();
278 :
279 : // Get the charge correlation between cathodes.
280 249 : Float_t currentCorrel = TMath::Exp(gRandom->Gaus(0.0,ChargeCorrel()/2.0));
281 :
282 581 : for ( Int_t cath = AliMp::kCath0; cath <= AliMp::kCath1; ++cath )
283 : {
284 415 : 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 332 : AliMpSegmentation::Instance()
289 166 : ->GetMpSegmentation(detElemId,AliMp::GetCathodType(cath));
290 :
291 166 : AliMpVPadIterator* it = seg->CreateIterator(area);
292 :
293 166 : if (!it)
294 : {
295 0 : AliError(Form("Could not get iterator for detElemId %d",detElemId));
296 0 : return;
297 : }
298 :
299 : // Start loop over pads.
300 166 : it->First();
301 :
302 332 : if ( it->IsDone() )
303 : {
304 : // Exceptional case : iterator is built, but is invalid from the start.
305 0 : AliMpPad pad = seg->PadByPosition(area.GetPositionX(),area.GetPositionY(),
306 : kFALSE);
307 0 : if ( pad.IsValid() )
308 : {
309 0 : 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 0 : 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 0 : delete it;
322 : return;
323 0 : }
324 :
325 10742 : 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 3470 : AliMpPad pad = it->CurrentItem();
330 17350 : TVector2 lowerLeft(TVector2(x,y)-TVector2(pad.GetPositionX(),pad.GetPositionY())-
331 3470 : TVector2(pad.GetDimensionX(),pad.GetDimensionY()));
332 13880 : TVector2 upperRight(lowerLeft + TVector2(pad.GetDimensionX(),pad.GetDimensionY())*2.0);
333 10410 : Float_t qp = TMath::Abs(fMathieson->IntXY(lowerLeft.X(),lowerLeft.Y(),
334 3470 : upperRight.X(),upperRight.Y()));
335 :
336 4842 : if ( qp > fChargeThreshold &&
337 1372 : 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 2586 : AliMUONDigit* d = new AliMUONDigit(detElemId,pad.GetManuId(),
346 862 : pad.GetManuChannel(),cath);
347 2586 : d->SetPadXY(pad.GetIx(),pad.GetIy());
348 862 : d->SetCharge(qp*qcath);
349 862 : digits.Add(d);
350 862 : }
351 3470 : it->Next();
352 3470 : }
353 332 : delete it;
354 166 : }
355 166 : }
356 :
357 :
358 :
|