1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //-----------------------------------------------------------------------------
19 // Class AliMUONResponseV0
20 // --------------------------
23 //-----------------------------------------------------------------------------
25 #include "AliMUONResponseV0.h"
27 #include "AliMUONConstants.h"
28 #include "AliMUONDigit.h"
29 #include "AliMUONGeometryTransformer.h"
30 #include "AliMUONHit.h"
31 #include "AliMUONConstants.h"
33 #include "AliMpArea.h"
34 #include "AliMpDEManager.h"
35 #include "AliMpVPadIterator.h"
36 #include "AliMpSegmentation.h"
37 #include "AliMpVSegmentation.h"
38 #include "AliMpCathodType.h"
43 #include "Riostream.h"
51 ClassImp(AliMUONResponseV0)
56 return static_cast<AliMUON*>(gAlice->GetModule("MUON"));
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)
62 /// ideally should be :
64 /// AliMUONGeometry::Global2Local(detElemId,xg,yg,zg,x,y,z);
65 /// but while waiting for this geometry singleton, let's go through
68 const AliMUONGeometryTransformer* transformer = muon()->GetGeometryTransformer();
69 transformer->Global2Local(detElemId,xg,yg,zg,xl,yl,zl);
72 //__________________________________________________________________________
73 AliMUONResponseV0::AliMUONResponseV0()
78 fSigmaIntegration(0.0),
83 fMathieson(new AliMUONMathieson),
84 fChargeThreshold(1e-4),
87 /// Normal constructor
88 AliDebug(1,Form("Default ctor"));
91 //__________________________________________________________________________
92 AliMUONResponseV0::AliMUONResponseV0(const AliMUONResponseV0& other)
97 fSigmaIntegration(0.0),
103 fChargeThreshold(1e-4),
104 fIsTailEffect(kFALSE)
110 //__________________________________________________________________________
112 AliMUONResponseV0::operator=(const AliMUONResponseV0& other)
114 /// Assignment operator
119 //__________________________________________________________________________
120 AliMUONResponseV0::~AliMUONResponseV0()
128 //______________________________________________________________________________
130 AliMUONResponseV0::CopyTo(AliMUONResponseV0& other) const
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;
146 //______________________________________________________________________________
148 AliMUONResponseV0::Print(Option_t*) const
152 cout << " ChargeSlope=" << fChargeSlope
153 << " ChargeSpreadX,Y=" << fChargeSpreadX
155 << " ChargeCorrelation=" << fChargeCorrel
159 //__________________________________________________________________________
160 void AliMUONResponseV0::SetSqrtKx3AndDeriveKx2Kx4(Float_t SqrtKx3)
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);
169 //__________________________________________________________________________
170 void AliMUONResponseV0::SetSqrtKy3AndDeriveKy2Ky4(Float_t SqrtKy3)
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);
178 //__________________________________________________________________________
179 Float_t AliMUONResponseV0::IntPH(Float_t eloss) const
181 /// Calculate charge from given ionization energy loss
183 nel= Int_t(eloss*1.e9/27.4);
186 for (Int_t i=1;i<=nel;i++) {
188 while(!arg) arg = gRandom->Rndm();
189 charge -= fChargeSlope*TMath::Log(arg);
194 //_____________________________________________________________________________
196 AliMUONResponseV0::GetAnod(Float_t x) const
198 /// Return wire coordinate closest to x.
200 Int_t n = Int_t(x/Pitch());
201 Float_t wire = (x>0) ? n+0.5 : n-0.5;
205 //______________________________________________________________________________
207 AliMUONResponseV0::DisIntegrate(const AliMUONHit& hit, TList& digits, Float_t timeDif)
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.
216 Int_t detElemId = hit.DetElemId();
217 Double_t hitX = hit.X() ;
218 Double_t hitY = hit.Y() ;
219 Double_t hitZ = hit.Z() ;
221 // Width of the integration area
222 Double_t dx = SigmaIntegration()*ChargeSpreadX();
223 Double_t dy = SigmaIntegration()*ChargeSpreadY();
225 //Modify to take the tailing effect.
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;
232 for ( Int_t cath = AliMp::kCath0; cath <= AliMp::kCath1; ++cath )
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();
240 if(plane == AliMp::kBendingPlane) {
241 Global2Local(detElemId,hitX,hitY,hitZ,locX,locY,locZ);
242 AliMpPad pad = seg->PadByPosition(locX,locY,kFALSE);
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++)
251 for(Int_t itime = 0; itime<Int_t((2*para) + 1); itime++)
252 termB *= (hitY - globYCenter) ;
254 hitY = hitY + termA*termB;
255 }// if the pad is a valid one
258 }// if para > 0 condn
261 // Use that (dx,dy) to specify the area upon which
262 // we will iterate to spread charge into.
264 Global2Local(detElemId,hitX,hitY,hitZ,x,y,z);
266 AliMpArea area(x,y,dx,dy);
268 // Get pulse height from energy loss.
269 Float_t qtot = IntPH(hit.Eloss());
271 // If from a pileup event we apply a reduction factor to the charge
273 qtot = AliMUONConstants::ReducedQTot(qtot,timeDif);
276 // Scale the charge to it'll (roughly) be in fC
277 qtot *= AliMUONConstants::DefaultADC2MV()*AliMUONConstants::DefaultA0()*AliMUONConstants::DefaultCapa();
279 // Get the charge correlation between cathodes.
280 Float_t currentCorrel = TMath::Exp(gRandom->Gaus(0.0,ChargeCorrel()/2.0));
282 for ( Int_t cath = AliMp::kCath0; cath <= AliMp::kCath1; ++cath )
284 Float_t qcath = qtot * ( cath == 0 ? currentCorrel : 1.0/currentCorrel);
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));
291 AliMpVPadIterator* it = seg->CreateIterator(area);
295 AliError(Form("Could not get iterator for detElemId %d",detElemId));
299 // Start loop over pads.
304 // Exceptional case : iterator is built, but is invalid from the start.
305 AliMpPad pad = seg->PadByPosition(area.GetPositionX(),area.GetPositionY(),
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",
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()));
325 while ( !it->IsDone() )
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()));
336 if ( qp > fChargeThreshold &&
337 qp*qcath > AliMUONConstants::DefaultADC2MV()*AliMUONConstants::DefaultA0()*AliMUONConstants::DefaultCapa() )
339 // If we're above threshold, then we create a digit,
340 // and fill it with relevant information, including electronics.
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)
345 AliMUONDigit* d = new AliMUONDigit(detElemId,pad.GetManuId(),
346 pad.GetManuChannel(),cath);
347 d->SetPadXY(pad.GetIx(),pad.GetIy());
348 d->SetCharge(qp*qcath);