]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONResponseV0.cxx
- Added class for Global Crate object
[u/mrichter/AliRoot.git] / MUON / AliMUONResponseV0.cxx
CommitLineData
a9e2aefa 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
88cb7938 16/* $Id$ */
a9e2aefa 17
3d1463c8 18//-----------------------------------------------------------------------------
d19b6003 19// Class AliMUONResponseV0
20// --------------------------
9265505b 21// Implementation of
22// Mathieson response
3d1463c8 23//-----------------------------------------------------------------------------
a9e2aefa 24
30178c30 25#include "AliMUONResponseV0.h"
885d501b 26#include "AliMUON.h"
27#include "AliMUONConstants.h"
28#include "AliMUONDigit.h"
885d501b 29#include "AliMUONGeometryTransformer.h"
30#include "AliMUONHit.h"
9265505b 31
885d501b 32#include "AliMpArea.h"
33#include "AliMpDEManager.h"
885d501b 34#include "AliMpVPadIterator.h"
9265505b 35#include "AliMpSegmentation.h"
885d501b 36#include "AliMpVSegmentation.h"
866c3232 37#include "AliMpCathodType.h"
9265505b 38
885d501b 39#include "AliRun.h"
9265505b 40#include "AliLog.h"
41
885d501b 42#include "Riostream.h"
43#include "TVector2.h"
44#include <TMath.h>
45#include <TRandom.h>
8c343c7c 46
9265505b 47/// \cond CLASSIMP
d5bfadcc 48ClassImp(AliMUONResponseV0)
9265505b 49/// \endcond
d5bfadcc 50
885d501b 51AliMUON* muon()
52{
53 return static_cast<AliMUON*>(gAlice->GetModule("MUON"));
54}
55
56void Global2Local(Int_t detElemId, Double_t xg, Double_t yg, Double_t zg,
57 Double_t& xl, Double_t& yl, Double_t& zl)
58{
9265505b 59 /// ideally should be :
60 /// Double_t x,y,z;
61 /// AliMUONGeometry::Global2Local(detElemId,xg,yg,zg,x,y,z);
62 /// but while waiting for this geometry singleton, let's go through
63 /// AliMUON still.
885d501b 64
65 const AliMUONGeometryTransformer* transformer = muon()->GetGeometryTransformer();
66 transformer->Global2Local(detElemId,xg,yg,zg,xl,yl,zl);
67}
68
30178c30 69//__________________________________________________________________________
70AliMUONResponseV0::AliMUONResponseV0()
885d501b 71 : AliMUONResponse(),
72 fChargeSlope(0.0),
73 fChargeSpreadX(0.0),
74 fChargeSpreadY(0.0),
75 fSigmaIntegration(0.0),
76 fMaxAdc(0),
ccea41d4 77 fSaturation(0),
885d501b 78 fZeroSuppression(0),
79 fChargeCorrel(0.0),
80 fMathieson(new AliMUONMathieson),
81 fChargeThreshold(1e-4)
30178c30 82{
9265505b 83 /// Normal constructor
885d501b 84 AliDebug(1,Form("Default ctor"));
30178c30 85}
f29ba3e1 86
2a7d64a9 87//__________________________________________________________________________
88AliMUONResponseV0::AliMUONResponseV0(const AliMUONResponseV0& other)
89: AliMUONResponse(),
90fChargeSlope(0.0),
91fChargeSpreadX(0.0),
92fChargeSpreadY(0.0),
93fSigmaIntegration(0.0),
94fMaxAdc(0),
95fSaturation(0),
96fZeroSuppression(0),
97fChargeCorrel(0.0),
98fMathieson(0),
99fChargeThreshold(1e-4)
100{
101 /// copy ctor
102 other.CopyTo(*this);
103}
104
105//__________________________________________________________________________
106AliMUONResponseV0&
107AliMUONResponseV0::operator=(const AliMUONResponseV0& other)
108{
109 /// Assignment operator
110 other.CopyTo(*this);
111 return *this;
112}
113
ccea41d4 114//__________________________________________________________________________
a713db22 115AliMUONResponseV0::~AliMUONResponseV0()
116{
9265505b 117/// Destructor
118
885d501b 119 AliDebug(1,"");
a713db22 120 delete fMathieson;
121}
f29ba3e1 122
2a7d64a9 123//______________________________________________________________________________
124void
125AliMUONResponseV0::CopyTo(AliMUONResponseV0& other) const
126{
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;
139}
140
885d501b 141//______________________________________________________________________________
142void
143AliMUONResponseV0::Print(Option_t*) const
144{
9265505b 145/// Printing
d19b6003 146
885d501b 147 cout << " ChargeSlope=" << fChargeSlope
148 << " ChargeSpreadX,Y=" << fChargeSpreadX
149 << fChargeSpreadY
150 << " ChargeCorrelation=" << fChargeCorrel
151 << endl;
f29ba3e1 152}
153
d5bfadcc 154 //__________________________________________________________________________
155void AliMUONResponseV0::SetSqrtKx3AndDeriveKx2Kx4(Float_t SqrtKx3)
156{
9265505b 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
a713db22 161 fMathieson->SetSqrtKx3AndDeriveKx2Kx4(SqrtKx3);
d5bfadcc 162}
163
164 //__________________________________________________________________________
165void AliMUONResponseV0::SetSqrtKy3AndDeriveKy2Ky4(Float_t SqrtKy3)
166{
9265505b 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
a713db22 171 fMathieson->SetSqrtKy3AndDeriveKy2Ky4(SqrtKy3);
d5bfadcc 172}
a713db22 173 //__________________________________________________________________________
85fec35d 174Float_t AliMUONResponseV0::IntPH(Float_t eloss) const
a9e2aefa 175{
9265505b 176 /// Calculate charge from given ionization energy loss
a9e2aefa 177 Int_t nel;
4ac9d21e 178 nel= Int_t(eloss*1.e9/27.4);
a9e2aefa 179 Float_t charge=0;
180 if (nel == 0) nel=1;
181 for (Int_t i=1;i<=nel;i++) {
01997fa2 182 Float_t arg=0.;
183 while(!arg) arg = gRandom->Rndm();
184 charge -= fChargeSlope*TMath::Log(arg);
a9e2aefa 185 }
186 return charge;
187}
a713db22 188
885d501b 189//_____________________________________________________________________________
190Float_t
191AliMUONResponseV0::GetAnod(Float_t x) const
192{
9265505b 193 /// Return wire coordinate closest to x.
194
885d501b 195 Int_t n = Int_t(x/Pitch());
196 Float_t wire = (x>0) ? n+0.5 : n-0.5;
197 return Pitch()*wire;
198}
a9e2aefa 199
885d501b 200//______________________________________________________________________________
201void
202AliMUONResponseV0::DisIntegrate(const AliMUONHit& hit, TList& digits)
203{
9265505b 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.
885d501b 208
209 digits.Clear();
210
211 Int_t detElemId = hit.DetElemId();
212
885d501b 213 // Width of the integration area
885d501b 214 Double_t dx = SigmaIntegration()*ChargeSpreadX();
215 Double_t dy = SigmaIntegration()*ChargeSpreadY();
216
217 // Use that (dx,dy) to specify the area upon which
218 // we will iterate to spread charge into.
219 Double_t x,y,z;
220 Global2Local(detElemId,hit.X(),hit.Y(),hit.Z(),x,y,z);
221 x = GetAnod(x);
222 TVector2 hitPosition(x,y);
223 AliMpArea area(hitPosition,TVector2(dx,dy));
224
32c9ead9 225 // Get pulse height from energy loss.
885d501b 226 Float_t qtot = IntPH(hit.Eloss());
227
32c9ead9 228 // Get the charge correlation between cathodes.
885d501b 229 Float_t currentCorrel = TMath::Exp(gRandom->Gaus(0.0,ChargeCorrel()/2.0));
a9e2aefa 230
866c3232 231 for ( Int_t cath = AliMp::kCath0; cath <= AliMp::kCath1; ++cath )
885d501b 232 {
233 Float_t qcath = qtot * ( cath == 0 ? currentCorrel : 1.0/currentCorrel);
234
885d501b 235 // Get an iterator to loop over pads, within the given area.
32c9ead9 236 const AliMpVSegmentation* seg =
866c3232 237 AliMpSegmentation::Instance()
238 ->GetMpSegmentation(detElemId,AliMp::GetCathodType(cath));
885d501b 239
32c9ead9 240 AliMpVPadIterator* it = seg->CreateIterator(area);
241
242 if (!it)
243 {
244 AliError(Form("Could not get iterator for detElemId %d",detElemId));
245 return;
246 }
247
248 // Start loop over pads.
249 it->First();
250
251 if ( it->IsDone() )
252 {
253 // Exceptional case : iterator is built, but is invalid from the start.
254 AliMpPad pad = seg->PadByPosition(area.Position(),kFALSE);
255 if ( pad.IsValid() )
885d501b 256 {
32c9ead9 257 AliWarning(Form("Got an invalid iterator bug (area.Position() is within "
258 " DE but the iterator is void) for detElemId %d cath %d",
259 detElemId,cath));
885d501b 260 }
32c9ead9 261 else
885d501b 262 {
32c9ead9 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()));
885d501b 268 }
269 delete it;
32c9ead9 270 return;
271 }
272
273 while ( !it->IsDone() )
274 {
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()));
282
283 Int_t icharge = Int_t(qp*qcath);
284
285 if ( qp > fChargeThreshold )
286 {
287 // If we're above threshold, then we create a digit,
288 // and fill it with relevant information, including electronics.
2a7d64a9 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);
32c9ead9 293 digits.Add(d);
294 }
295 it->Next();
296 }
297 delete it;
885d501b 298 }
299}
a9e2aefa 300
301
302