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 // --------------------------
24 #include "AliMUONResponseV0.h"
26 #include "AliMUONConstants.h"
27 #include "AliMUONDigit.h"
28 #include "AliMUONGeometryTransformer.h"
29 #include "AliMUONHit.h"
31 #include "AliMpArea.h"
32 #include "AliMpDEManager.h"
33 #include "AliMpVPadIterator.h"
34 #include "AliMpSegmentation.h"
35 #include "AliMpVSegmentation.h"
36 #include "AliMpCathodType.h"
41 #include "Riostream.h"
47 ClassImp(AliMUONResponseV0)
52 return static_cast<AliMUON*>(gAlice->GetModule("MUON"));
55 void Global2Local(Int_t detElemId, Double_t xg, Double_t yg, Double_t zg,
56 Double_t& xl, Double_t& yl, Double_t& zl)
58 /// ideally should be :
60 /// AliMUONGeometry::Global2Local(detElemId,xg,yg,zg,x,y,z);
61 /// but while waiting for this geometry singleton, let's go through
64 const AliMUONGeometryTransformer* transformer = muon()->GetGeometryTransformer();
65 transformer->Global2Local(detElemId,xg,yg,zg,xl,yl,zl);
68 //__________________________________________________________________________
69 AliMUONResponseV0::AliMUONResponseV0()
74 fSigmaIntegration(0.0),
79 fMathieson(new AliMUONMathieson),
80 fChargeThreshold(1e-4)
82 /// Normal constructor
83 AliDebug(1,Form("Default ctor"));
86 //__________________________________________________________________________
87 AliMUONResponseV0::AliMUONResponseV0(const AliMUONResponseV0& other)
92 fSigmaIntegration(0.0),
98 fChargeThreshold(1e-4)
104 //__________________________________________________________________________
106 AliMUONResponseV0::operator=(const AliMUONResponseV0& other)
108 /// Assignment operator
113 //__________________________________________________________________________
114 AliMUONResponseV0::~AliMUONResponseV0()
122 //______________________________________________________________________________
124 AliMUONResponseV0::CopyTo(AliMUONResponseV0& other) const
126 /// Copy *this to other
127 other.fChargeSlope=fChargeSlope;
128 other.fChargeSpreadX=fChargeSpreadX;
129 other.fChargeSpreadY=fChargeSpreadY;
130 other.fSigmaIntegration=fSigmaIntegration;
131 other.fMaxAdc=fMaxAdc;
132 other.fSaturation=fSaturation;
133 other.fZeroSuppression=fZeroSuppression;
134 other.fChargeCorrel=fChargeCorrel;
135 delete other.fMathieson;
136 other.fMathieson = new AliMUONMathieson(*fMathieson);
137 other.fChargeThreshold=fChargeThreshold;
140 //______________________________________________________________________________
142 AliMUONResponseV0::Print(Option_t*) const
146 cout << " ChargeSlope=" << fChargeSlope
147 << " ChargeSpreadX,Y=" << fChargeSpreadX
149 << " ChargeCorrelation=" << fChargeCorrel
153 //__________________________________________________________________________
154 void AliMUONResponseV0::SetSqrtKx3AndDeriveKx2Kx4(Float_t SqrtKx3)
156 /// Set to "SqrtKx3" the Mathieson parameter K3 ("fSqrtKx3")
157 /// in the X direction, perpendicular to the wires,
158 /// and derive the Mathieson parameters K2 ("fKx2") and K4 ("fKx4")
159 /// in the same direction
160 fMathieson->SetSqrtKx3AndDeriveKx2Kx4(SqrtKx3);
163 //__________________________________________________________________________
164 void AliMUONResponseV0::SetSqrtKy3AndDeriveKy2Ky4(Float_t SqrtKy3)
166 /// Set to "SqrtKy3" the Mathieson parameter K3 ("fSqrtKy3")
167 /// in the Y direction, along the wires,
168 /// and derive the Mathieson parameters K2 ("fKy2") and K4 ("fKy4")
169 /// in the same direction
170 fMathieson->SetSqrtKy3AndDeriveKy2Ky4(SqrtKy3);
172 //__________________________________________________________________________
173 Float_t AliMUONResponseV0::IntPH(Float_t eloss) const
175 /// Calculate charge from given ionization energy loss
177 nel= Int_t(eloss*1.e9/27.4);
180 for (Int_t i=1;i<=nel;i++) {
182 while(!arg) arg = gRandom->Rndm();
183 charge -= fChargeSlope*TMath::Log(arg);
188 //_____________________________________________________________________________
190 AliMUONResponseV0::GetAnod(Float_t x) const
192 /// Return wire coordinate closest to x.
194 Int_t n = Int_t(x/Pitch());
195 Float_t wire = (x>0) ? n+0.5 : n-0.5;
199 //______________________________________________________________________________
201 AliMUONResponseV0::DisIntegrate(const AliMUONHit& hit, TList& digits)
203 /// Go from 1 hit to a list of digits.
204 /// The energy deposition of that hit is first converted into charge
205 /// (in IntPH() method), and then this charge is dispatched on several
206 /// pads, according to the Mathieson distribution.
210 Int_t detElemId = hit.DetElemId();
212 // Width of the integration area
213 Double_t dx = SigmaIntegration()*ChargeSpreadX();
214 Double_t dy = SigmaIntegration()*ChargeSpreadY();
216 // Use that (dx,dy) to specify the area upon which
217 // we will iterate to spread charge into.
219 Global2Local(detElemId,hit.X(),hit.Y(),hit.Z(),x,y,z);
221 TVector2 hitPosition(x,y);
222 AliMpArea area(hitPosition,TVector2(dx,dy));
224 // Get pulse height from energy loss.
225 Float_t qtot = IntPH(hit.Eloss());
227 // Get the charge correlation between cathodes.
228 Float_t currentCorrel = TMath::Exp(gRandom->Gaus(0.0,ChargeCorrel()/2.0));
230 for ( Int_t cath = AliMp::kCath0; cath <= AliMp::kCath1; ++cath )
232 Float_t qcath = qtot * ( cath == 0 ? currentCorrel : 1.0/currentCorrel);
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));
239 AliMpVPadIterator* it = seg->CreateIterator(area);
243 AliError(Form("Could not get iterator for detElemId %d",detElemId));
247 // Start loop over pads.
252 // Exceptional case : iterator is built, but is invalid from the start.
253 AliMpPad pad = seg->PadByPosition(area.Position(),kFALSE);
256 AliWarning(Form("Got an invalid iterator bug (area.Position() is within "
257 " DE but the iterator is void) for detElemId %d cath %d",
262 AliError(Form("Got an invalid iterator bug for detElemId %d cath %d."
263 "Might be a bad hit ? area.Position()=(%e,%e) "
264 "Dimensions()=(%e,%e)",
265 detElemId,cath,area.Position().X(),area.Position().Y(),
266 area.Dimensions().X(),area.Dimensions().Y()));
272 while ( !it->IsDone() )
274 // For each pad given by the iterator, compute the charge of that
275 // pad, according to the Mathieson distribution.
276 AliMpPad pad = it->CurrentItem();
277 TVector2 lowerLeft(hitPosition-pad.Position()-pad.Dimensions());
278 TVector2 upperRight(lowerLeft + pad.Dimensions()*2.0);
279 Float_t qp = TMath::Abs(fMathieson->IntXY(lowerLeft.X(),lowerLeft.Y(),
280 upperRight.X(),upperRight.Y()));
282 Int_t icharge = Int_t(qp*qcath);
284 if ( qp > fChargeThreshold )
286 // If we're above threshold, then we create a digit,
287 // and fill it with relevant information, including electronics.
288 AliMUONDigit* d = new AliMUONDigit(detElemId,pad.GetLocation().GetFirst(),
289 pad.GetLocation().GetSecond(),cath);
290 d->SetPadXY(pad.GetIndices().GetFirst(),pad.GetIndices().GetSecond());
291 d->SetCharge(icharge);