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"
49 ClassImp(AliMUONResponseV0)
54 return static_cast<AliMUON*>(gAlice->GetModule("MUON"));
57 void Global2Local(Int_t detElemId, Double_t xg, Double_t yg, Double_t zg,
58 Double_t& xl, Double_t& yl, Double_t& zl)
60 /// ideally should be :
62 /// AliMUONGeometry::Global2Local(detElemId,xg,yg,zg,x,y,z);
63 /// but while waiting for this geometry singleton, let's go through
66 const AliMUONGeometryTransformer* transformer = muon()->GetGeometryTransformer();
67 transformer->Global2Local(detElemId,xg,yg,zg,xl,yl,zl);
70 //__________________________________________________________________________
71 AliMUONResponseV0::AliMUONResponseV0()
76 fSigmaIntegration(0.0),
81 fMathieson(new AliMUONMathieson),
82 fChargeThreshold(1e-4),
85 /// Normal constructor
86 AliDebug(1,Form("Default ctor"));
89 //__________________________________________________________________________
90 AliMUONResponseV0::AliMUONResponseV0(const AliMUONResponseV0& other)
95 fSigmaIntegration(0.0),
101 fChargeThreshold(1e-4),
102 fIsTailEffect(kFALSE)
108 //__________________________________________________________________________
110 AliMUONResponseV0::operator=(const AliMUONResponseV0& other)
112 /// Assignment operator
117 //__________________________________________________________________________
118 AliMUONResponseV0::~AliMUONResponseV0()
126 //______________________________________________________________________________
128 AliMUONResponseV0::CopyTo(AliMUONResponseV0& other) const
130 /// Copy *this to other
131 other.fChargeSlope=fChargeSlope;
132 other.fChargeSpreadX=fChargeSpreadX;
133 other.fChargeSpreadY=fChargeSpreadY;
134 other.fSigmaIntegration=fSigmaIntegration;
135 other.fMaxAdc=fMaxAdc;
136 other.fSaturation=fSaturation;
137 other.fZeroSuppression=fZeroSuppression;
138 other.fChargeCorrel=fChargeCorrel;
139 delete other.fMathieson;
140 other.fMathieson = new AliMUONMathieson(*fMathieson);
141 other.fChargeThreshold=fChargeThreshold;
144 //______________________________________________________________________________
146 AliMUONResponseV0::Print(Option_t*) const
150 cout << " ChargeSlope=" << fChargeSlope
151 << " ChargeSpreadX,Y=" << fChargeSpreadX
153 << " ChargeCorrelation=" << fChargeCorrel
157 //__________________________________________________________________________
158 void AliMUONResponseV0::SetSqrtKx3AndDeriveKx2Kx4(Float_t SqrtKx3)
160 /// Set to "SqrtKx3" the Mathieson parameter K3 ("fSqrtKx3")
161 /// in the X direction, perpendicular to the wires,
162 /// and derive the Mathieson parameters K2 ("fKx2") and K4 ("fKx4")
163 /// in the same direction
164 fMathieson->SetSqrtKx3AndDeriveKx2Kx4(SqrtKx3);
167 //__________________________________________________________________________
168 void AliMUONResponseV0::SetSqrtKy3AndDeriveKy2Ky4(Float_t SqrtKy3)
170 /// Set to "SqrtKy3" the Mathieson parameter K3 ("fSqrtKy3")
171 /// in the Y direction, along the wires,
172 /// and derive the Mathieson parameters K2 ("fKy2") and K4 ("fKy4")
173 /// in the same direction
174 fMathieson->SetSqrtKy3AndDeriveKy2Ky4(SqrtKy3);
176 //__________________________________________________________________________
177 Float_t AliMUONResponseV0::IntPH(Float_t eloss) const
179 /// Calculate charge from given ionization energy loss
181 nel= Int_t(eloss*1.e9/27.4);
184 for (Int_t i=1;i<=nel;i++) {
186 while(!arg) arg = gRandom->Rndm();
187 charge -= fChargeSlope*TMath::Log(arg);
192 //_____________________________________________________________________________
194 AliMUONResponseV0::GetAnod(Float_t x) const
196 /// Return wire coordinate closest to x.
198 Int_t n = Int_t(x/Pitch());
199 Float_t wire = (x>0) ? n+0.5 : n-0.5;
203 //______________________________________________________________________________
205 AliMUONResponseV0::DisIntegrate(const AliMUONHit& hit, TList& digits, Float_t timeDif)
207 /// Go from 1 hit to a list of digits.
208 /// The energy deposition of that hit is first converted into charge
209 /// (in IntPH() method), and then this charge is dispatched on several
210 /// pads, according to the Mathieson distribution.
214 Int_t detElemId = hit.DetElemId();
215 Double_t hitX = hit.X() ;
216 Double_t hitY = hit.Y() ;
217 Double_t hitZ = hit.Z() ;
219 // Width of the integration area
220 Double_t dx = SigmaIntegration()*ChargeSpreadX();
221 Double_t dy = SigmaIntegration()*ChargeSpreadY();
223 //Modify to take the tailing effect.
225 Double_t locX,locY,locZ,globXCenter,globYCenter,globZ;
226 Int_t para = 5; // This parameter is a natural number(excluding zero), higher the value less is the tailing effect
227 Double_t termA = 1.0;
228 Double_t termB = 1.0;
230 for ( Int_t cath = AliMp::kCath0; cath <= AliMp::kCath1; ++cath )
232 // Get an iterator to loop over pads, within the given area.
233 const AliMpVSegmentation* seg =
234 AliMpSegmentation::Instance()
235 ->GetMpSegmentation(detElemId,AliMp::GetCathodType(cath));
236 AliMp::PlaneType plane = seg->PlaneType();
238 if(plane == AliMp::kBendingPlane) {
239 Global2Local(detElemId,hitX,hitY,hitZ,locX,locY,locZ);
240 AliMpPad pad = seg->PadByPosition(locX,locY,kFALSE);
242 Double_t locYCenter = pad.GetPositionY();
243 Double_t locXCenter = pad.GetPositionX();
244 const AliMUONGeometryTransformer* transformer = muon()->GetGeometryTransformer();
245 transformer->Local2Global(detElemId,locXCenter,locYCenter,locZ,globXCenter,globYCenter,globZ);
246 for(Int_t itime = 0; itime<para; itime++)
249 for(Int_t itime = 0; itime<Int_t((2*para) + 1); itime++)
250 termB *= (hitY - globYCenter) ;
252 hitY = hitY + termA*termB;
253 }// if the pad is a valid one
256 }// if para > 0 condn
259 // Use that (dx,dy) to specify the area upon which
260 // we will iterate to spread charge into.
262 Global2Local(detElemId,hitX,hitY,hitZ,x,y,z);
264 AliMpArea area(x,y,dx,dy);
266 // Get pulse height from energy loss.
267 Float_t qtot = IntPH(hit.Eloss());
269 // If from a pileup event we apply a reduction factor to the charge
271 qtot = AliMUONConstants::ReducedQTot(qtot,timeDif);
274 // Get the charge correlation between cathodes.
275 Float_t currentCorrel = TMath::Exp(gRandom->Gaus(0.0,ChargeCorrel()/2.0));
277 for ( Int_t cath = AliMp::kCath0; cath <= AliMp::kCath1; ++cath )
279 Float_t qcath = qtot * ( cath == 0 ? currentCorrel : 1.0/currentCorrel);
281 // Get an iterator to loop over pads, within the given area.
282 const AliMpVSegmentation* seg =
283 AliMpSegmentation::Instance()
284 ->GetMpSegmentation(detElemId,AliMp::GetCathodType(cath));
286 AliMpVPadIterator* it = seg->CreateIterator(area);
290 AliError(Form("Could not get iterator for detElemId %d",detElemId));
294 // Start loop over pads.
299 // Exceptional case : iterator is built, but is invalid from the start.
300 AliMpPad pad = seg->PadByPosition(area.GetPositionX(),area.GetPositionY(),
304 AliWarning(Form("Got an invalid iterator bug (area.Position() is within "
305 " DE but the iterator is void) for detElemId %d cath %d",
310 AliError(Form("Got an invalid iterator bug for detElemId %d cath %d."
311 "Might be a bad hit ? area.Position()=(%e,%e) "
312 "Dimensions()=(%e,%e)",
313 detElemId,cath,area.GetPositionX(),area.GetPositionY(),
314 area.GetDimensionX(),area.GetDimensionY()));
320 while ( !it->IsDone() )
322 // For each pad given by the iterator, compute the charge of that
323 // pad, according to the Mathieson distribution.
324 AliMpPad pad = it->CurrentItem();
325 TVector2 lowerLeft(TVector2(x,y)-TVector2(pad.GetPositionX(),pad.GetPositionY())-
326 TVector2(pad.GetDimensionX(),pad.GetDimensionY()));
327 TVector2 upperRight(lowerLeft + TVector2(pad.GetDimensionX(),pad.GetDimensionY())*2.0);
328 Float_t qp = TMath::Abs(fMathieson->IntXY(lowerLeft.X(),lowerLeft.Y(),
329 upperRight.X(),upperRight.Y()));
331 Int_t icharge = Int_t(qp*qcath);
333 if ( qp > fChargeThreshold )
335 // If we're above threshold, then we create a digit,
336 // and fill it with relevant information, including electronics.
337 AliMUONDigit* d = new AliMUONDigit(detElemId,pad.GetManuId(),
338 pad.GetManuChannel(),cath);
339 d->SetPadXY(pad.GetIx(),pad.GetIy());
340 d->SetCharge(icharge);