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