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"
32 #include "AliMpArea.h"
33 #include "AliMpDEManager.h"
34 #include "AliMpVPadIterator.h"
35 #include "AliMpSegmentation.h"
36 #include "AliMpVSegmentation.h"
37 #include "AliMpCathodType.h"
42 #include "Riostream.h"
48 ClassImp(AliMUONResponseV0)
53 return static_cast<AliMUON*>(gAlice->GetModule("MUON"));
56 void Global2Local(Int_t detElemId, Double_t xg, Double_t yg, Double_t zg,
57 Double_t& xl, Double_t& yl, Double_t& zl)
59 /// ideally should be :
61 /// AliMUONGeometry::Global2Local(detElemId,xg,yg,zg,x,y,z);
62 /// but while waiting for this geometry singleton, let's go through
65 const AliMUONGeometryTransformer* transformer = muon()->GetGeometryTransformer();
66 transformer->Global2Local(detElemId,xg,yg,zg,xl,yl,zl);
69 //__________________________________________________________________________
70 AliMUONResponseV0::AliMUONResponseV0()
75 fSigmaIntegration(0.0),
80 fMathieson(new AliMUONMathieson),
81 fChargeThreshold(1e-4),
84 /// Normal constructor
85 AliDebug(1,Form("Default ctor"));
88 //__________________________________________________________________________
89 AliMUONResponseV0::AliMUONResponseV0(const AliMUONResponseV0& other)
94 fSigmaIntegration(0.0),
100 fChargeThreshold(1e-4),
101 fIsTailEffect(kFALSE)
107 //__________________________________________________________________________
109 AliMUONResponseV0::operator=(const AliMUONResponseV0& other)
111 /// Assignment operator
116 //__________________________________________________________________________
117 AliMUONResponseV0::~AliMUONResponseV0()
125 //______________________________________________________________________________
127 AliMUONResponseV0::CopyTo(AliMUONResponseV0& other) const
129 /// Copy *this to other
130 other.fChargeSlope=fChargeSlope;
131 other.fChargeSpreadX=fChargeSpreadX;
132 other.fChargeSpreadY=fChargeSpreadY;
133 other.fSigmaIntegration=fSigmaIntegration;
134 other.fMaxAdc=fMaxAdc;
135 other.fSaturation=fSaturation;
136 other.fZeroSuppression=fZeroSuppression;
137 other.fChargeCorrel=fChargeCorrel;
138 delete other.fMathieson;
139 other.fMathieson = new AliMUONMathieson(*fMathieson);
140 other.fChargeThreshold=fChargeThreshold;
143 //______________________________________________________________________________
145 AliMUONResponseV0::Print(Option_t*) const
149 cout << " ChargeSlope=" << fChargeSlope
150 << " ChargeSpreadX,Y=" << fChargeSpreadX
152 << " ChargeCorrelation=" << fChargeCorrel
156 //__________________________________________________________________________
157 void AliMUONResponseV0::SetSqrtKx3AndDeriveKx2Kx4(Float_t SqrtKx3)
159 /// Set to "SqrtKx3" the Mathieson parameter K3 ("fSqrtKx3")
160 /// in the X direction, perpendicular to the wires,
161 /// and derive the Mathieson parameters K2 ("fKx2") and K4 ("fKx4")
162 /// in the same direction
163 fMathieson->SetSqrtKx3AndDeriveKx2Kx4(SqrtKx3);
166 //__________________________________________________________________________
167 void AliMUONResponseV0::SetSqrtKy3AndDeriveKy2Ky4(Float_t SqrtKy3)
169 /// Set to "SqrtKy3" the Mathieson parameter K3 ("fSqrtKy3")
170 /// in the Y direction, along the wires,
171 /// and derive the Mathieson parameters K2 ("fKy2") and K4 ("fKy4")
172 /// in the same direction
173 fMathieson->SetSqrtKy3AndDeriveKy2Ky4(SqrtKy3);
175 //__________________________________________________________________________
176 Float_t AliMUONResponseV0::IntPH(Float_t eloss) const
178 /// Calculate charge from given ionization energy loss
180 nel= Int_t(eloss*1.e9/27.4);
183 for (Int_t i=1;i<=nel;i++) {
185 while(!arg) arg = gRandom->Rndm();
186 charge -= fChargeSlope*TMath::Log(arg);
191 //_____________________________________________________________________________
193 AliMUONResponseV0::GetAnod(Float_t x) const
195 /// Return wire coordinate closest to x.
197 Int_t n = Int_t(x/Pitch());
198 Float_t wire = (x>0) ? n+0.5 : n-0.5;
202 //______________________________________________________________________________
204 AliMUONResponseV0::DisIntegrate(const AliMUONHit& hit, TList& digits)
206 /// Go from 1 hit to a list of digits.
207 /// The energy deposition of that hit is first converted into charge
208 /// (in IntPH() method), and then this charge is dispatched on several
209 /// pads, according to the Mathieson distribution.
213 Int_t detElemId = hit.DetElemId();
214 Double_t hitX = hit.X() ;
215 Double_t hitY = hit.Y() ;
216 Double_t hitZ = hit.Z() ;
218 // Width of the integration area
219 Double_t dx = SigmaIntegration()*ChargeSpreadX();
220 Double_t dy = SigmaIntegration()*ChargeSpreadY();
222 //Modify to take the tailing effect.
224 Double_t locX,locY,locZ,globXCenter,globYCenter,globZ;
225 Int_t para = 5; // This parameter is a natural number(excluding zero), higher the value less is the tailing effect
226 Double_t termA = 1.0;
227 Double_t termB = 1.0;
229 for ( Int_t cath = AliMp::kCath0; cath <= AliMp::kCath1; ++cath )
231 // Get an iterator to loop over pads, within the given area.
232 const AliMpVSegmentation* seg =
233 AliMpSegmentation::Instance()
234 ->GetMpSegmentation(detElemId,AliMp::GetCathodType(cath));
235 AliMp::PlaneType plane = seg->PlaneType();
237 if(plane == AliMp::kBendingPlane) {
238 Global2Local(detElemId,hitX,hitY,hitZ,locX,locY,locZ);
239 AliMpPad pad = seg->PadByPosition(locX,locY,kFALSE);
241 Double_t locYCenter = pad.GetPositionY();
242 Double_t locXCenter = pad.GetPositionX();
243 const AliMUONGeometryTransformer* transformer = muon()->GetGeometryTransformer();
244 transformer->Local2Global(detElemId,locXCenter,locYCenter,locZ,globXCenter,globYCenter,globZ);
245 for(Int_t itime = 0; itime<para; itime++)
248 for(Int_t itime = 0; itime<Int_t((2*para) + 1); itime++)
249 termB *= (hitY - globYCenter) ;
251 hitY = hitY + termA*termB;
252 }// if the pad is a valid one
255 }// if para > 0 condn
258 // Use that (dx,dy) to specify the area upon which
259 // we will iterate to spread charge into.
261 Global2Local(detElemId,hitX,hitY,hitZ,x,y,z);
263 AliMpArea area(x,y,dx,dy);
265 // Get pulse height from energy loss.
266 Float_t qtot = IntPH(hit.Eloss());
268 // Get the charge correlation between cathodes.
269 Float_t currentCorrel = TMath::Exp(gRandom->Gaus(0.0,ChargeCorrel()/2.0));
271 for ( Int_t cath = AliMp::kCath0; cath <= AliMp::kCath1; ++cath )
273 Float_t qcath = qtot * ( cath == 0 ? currentCorrel : 1.0/currentCorrel);
275 // Get an iterator to loop over pads, within the given area.
276 const AliMpVSegmentation* seg =
277 AliMpSegmentation::Instance()
278 ->GetMpSegmentation(detElemId,AliMp::GetCathodType(cath));
280 AliMpVPadIterator* it = seg->CreateIterator(area);
284 AliError(Form("Could not get iterator for detElemId %d",detElemId));
288 // Start loop over pads.
293 // Exceptional case : iterator is built, but is invalid from the start.
294 AliMpPad pad = seg->PadByPosition(area.GetPositionX(),area.GetPositionY(),
298 AliWarning(Form("Got an invalid iterator bug (area.Position() is within "
299 " DE but the iterator is void) for detElemId %d cath %d",
304 AliError(Form("Got an invalid iterator bug for detElemId %d cath %d."
305 "Might be a bad hit ? area.Position()=(%e,%e) "
306 "Dimensions()=(%e,%e)",
307 detElemId,cath,area.GetPositionX(),area.GetPositionY(),
308 area.GetDimensionX(),area.GetDimensionY()));
314 while ( !it->IsDone() )
316 // For each pad given by the iterator, compute the charge of that
317 // pad, according to the Mathieson distribution.
318 AliMpPad pad = it->CurrentItem();
319 TVector2 lowerLeft(TVector2(x,y)-TVector2(pad.GetPositionX(),pad.GetPositionY())-
320 TVector2(pad.GetDimensionX(),pad.GetDimensionY()));
321 TVector2 upperRight(lowerLeft + TVector2(pad.GetDimensionX(),pad.GetDimensionY())*2.0);
322 Float_t qp = TMath::Abs(fMathieson->IntXY(lowerLeft.X(),lowerLeft.Y(),
323 upperRight.X(),upperRight.Y()));
325 Int_t icharge = Int_t(qp*qcath);
327 if ( qp > fChargeThreshold )
329 // If we're above threshold, then we create a digit,
330 // and fill it with relevant information, including electronics.
331 AliMUONDigit* d = new AliMUONDigit(detElemId,pad.GetManuId(),
332 pad.GetManuChannel(),cath);
333 d->SetPadXY(pad.GetIx(),pad.GetIy());
334 d->SetCharge(icharge);