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)
83 /// Normal constructor
84 AliDebug(1,Form("Default ctor"));
87 //__________________________________________________________________________
88 AliMUONResponseV0::AliMUONResponseV0(const AliMUONResponseV0& other)
93 fSigmaIntegration(0.0),
99 fChargeThreshold(1e-4)
105 //__________________________________________________________________________
107 AliMUONResponseV0::operator=(const AliMUONResponseV0& other)
109 /// Assignment operator
114 //__________________________________________________________________________
115 AliMUONResponseV0::~AliMUONResponseV0()
123 //______________________________________________________________________________
125 AliMUONResponseV0::CopyTo(AliMUONResponseV0& other) const
127 /// Copy *this to other
128 other.fChargeSlope=fChargeSlope;
129 other.fChargeSpreadX=fChargeSpreadX;
130 other.fChargeSpreadY=fChargeSpreadY;
131 other.fSigmaIntegration=fSigmaIntegration;
132 other.fMaxAdc=fMaxAdc;
133 other.fSaturation=fSaturation;
134 other.fZeroSuppression=fZeroSuppression;
135 other.fChargeCorrel=fChargeCorrel;
136 delete other.fMathieson;
137 other.fMathieson = new AliMUONMathieson(*fMathieson);
138 other.fChargeThreshold=fChargeThreshold;
141 //______________________________________________________________________________
143 AliMUONResponseV0::Print(Option_t*) const
147 cout << " ChargeSlope=" << fChargeSlope
148 << " ChargeSpreadX,Y=" << fChargeSpreadX
150 << " ChargeCorrelation=" << fChargeCorrel
154 //__________________________________________________________________________
155 void AliMUONResponseV0::SetSqrtKx3AndDeriveKx2Kx4(Float_t SqrtKx3)
157 /// Set to "SqrtKx3" the Mathieson parameter K3 ("fSqrtKx3")
158 /// in the X direction, perpendicular to the wires,
159 /// and derive the Mathieson parameters K2 ("fKx2") and K4 ("fKx4")
160 /// in the same direction
161 fMathieson->SetSqrtKx3AndDeriveKx2Kx4(SqrtKx3);
164 //__________________________________________________________________________
165 void AliMUONResponseV0::SetSqrtKy3AndDeriveKy2Ky4(Float_t SqrtKy3)
167 /// Set to "SqrtKy3" the Mathieson parameter K3 ("fSqrtKy3")
168 /// in the Y direction, along the wires,
169 /// and derive the Mathieson parameters K2 ("fKy2") and K4 ("fKy4")
170 /// in the same direction
171 fMathieson->SetSqrtKy3AndDeriveKy2Ky4(SqrtKy3);
173 //__________________________________________________________________________
174 Float_t AliMUONResponseV0::IntPH(Float_t eloss) const
176 /// Calculate charge from given ionization energy loss
178 nel= Int_t(eloss*1.e9/27.4);
181 for (Int_t i=1;i<=nel;i++) {
183 while(!arg) arg = gRandom->Rndm();
184 charge -= fChargeSlope*TMath::Log(arg);
189 //_____________________________________________________________________________
191 AliMUONResponseV0::GetAnod(Float_t x) const
193 /// Return wire coordinate closest to x.
195 Int_t n = Int_t(x/Pitch());
196 Float_t wire = (x>0) ? n+0.5 : n-0.5;
200 //______________________________________________________________________________
202 AliMUONResponseV0::DisIntegrate(const AliMUONHit& hit, TList& digits)
204 /// Go from 1 hit to a list of digits.
205 /// The energy deposition of that hit is first converted into charge
206 /// (in IntPH() method), and then this charge is dispatched on several
207 /// pads, according to the Mathieson distribution.
211 Int_t detElemId = hit.DetElemId();
213 // Width of the integration area
214 Double_t dx = SigmaIntegration()*ChargeSpreadX();
215 Double_t dy = SigmaIntegration()*ChargeSpreadY();
217 // Use that (dx,dy) to specify the area upon which
218 // we will iterate to spread charge into.
220 Global2Local(detElemId,hit.X(),hit.Y(),hit.Z(),x,y,z);
222 TVector2 hitPosition(x,y);
223 AliMpArea area(hitPosition,TVector2(dx,dy));
225 // Get pulse height from energy loss.
226 Float_t qtot = IntPH(hit.Eloss());
228 // Get the charge correlation between cathodes.
229 Float_t currentCorrel = TMath::Exp(gRandom->Gaus(0.0,ChargeCorrel()/2.0));
231 for ( Int_t cath = AliMp::kCath0; cath <= AliMp::kCath1; ++cath )
233 Float_t qcath = qtot * ( cath == 0 ? currentCorrel : 1.0/currentCorrel);
235 // Get an iterator to loop over pads, within the given area.
236 const AliMpVSegmentation* seg =
237 AliMpSegmentation::Instance()
238 ->GetMpSegmentation(detElemId,AliMp::GetCathodType(cath));
240 AliMpVPadIterator* it = seg->CreateIterator(area);
244 AliError(Form("Could not get iterator for detElemId %d",detElemId));
248 // Start loop over pads.
253 // Exceptional case : iterator is built, but is invalid from the start.
254 AliMpPad pad = seg->PadByPosition(area.Position(),kFALSE);
257 AliWarning(Form("Got an invalid iterator bug (area.Position() is within "
258 " DE but the iterator is void) for detElemId %d cath %d",
263 AliError(Form("Got an invalid iterator bug for detElemId %d cath %d."
264 "Might be a bad hit ? area.Position()=(%e,%e) "
265 "Dimensions()=(%e,%e)",
266 detElemId,cath,area.Position().X(),area.Position().Y(),
267 area.Dimensions().X(),area.Dimensions().Y()));
273 while ( !it->IsDone() )
275 // For each pad given by the iterator, compute the charge of that
276 // pad, according to the Mathieson distribution.
277 AliMpPad pad = it->CurrentItem();
278 TVector2 lowerLeft(hitPosition-pad.Position()-pad.Dimensions());
279 TVector2 upperRight(lowerLeft + pad.Dimensions()*2.0);
280 Float_t qp = TMath::Abs(fMathieson->IntXY(lowerLeft.X(),lowerLeft.Y(),
281 upperRight.X(),upperRight.Y()));
283 Int_t icharge = Int_t(qp*qcath);
285 if ( qp > fChargeThreshold )
287 // If we're above threshold, then we create a digit,
288 // and fill it with relevant information, including electronics.
289 AliMUONDigit* d = new AliMUONDigit(detElemId,pad.GetLocation().GetFirst(),
290 pad.GetLocation().GetSecond(),cath);
291 d->SetPadXY(pad.GetIndices().GetFirst(),pad.GetIndices().GetSecond());
292 d->SetCharge(icharge);