]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONResponseV0.cxx
In AliMUONCheck:
[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"
2a5f75ae 31#include "AliMUONConstants.h"
9265505b 32
885d501b 33#include "AliMpArea.h"
34#include "AliMpDEManager.h"
885d501b 35#include "AliMpVPadIterator.h"
9265505b 36#include "AliMpSegmentation.h"
885d501b 37#include "AliMpVSegmentation.h"
866c3232 38#include "AliMpCathodType.h"
9265505b 39
885d501b 40#include "AliRun.h"
9265505b 41#include "AliLog.h"
42
885d501b 43#include "Riostream.h"
44#include "TVector2.h"
45#include <TMath.h>
46#include <TRandom.h>
8c343c7c 47
9265505b 48/// \cond CLASSIMP
d5bfadcc 49ClassImp(AliMUONResponseV0)
9265505b 50/// \endcond
d5bfadcc 51
885d501b 52AliMUON* muon()
53{
54 return static_cast<AliMUON*>(gAlice->GetModule("MUON"));
55}
56
57void Global2Local(Int_t detElemId, Double_t xg, Double_t yg, Double_t zg,
58 Double_t& xl, Double_t& yl, Double_t& zl)
59{
9265505b 60 /// ideally should be :
61 /// Double_t x,y,z;
62 /// AliMUONGeometry::Global2Local(detElemId,xg,yg,zg,x,y,z);
63 /// but while waiting for this geometry singleton, let's go through
64 /// AliMUON still.
885d501b 65
66 const AliMUONGeometryTransformer* transformer = muon()->GetGeometryTransformer();
67 transformer->Global2Local(detElemId,xg,yg,zg,xl,yl,zl);
68}
69
30178c30 70//__________________________________________________________________________
71AliMUONResponseV0::AliMUONResponseV0()
885d501b 72 : AliMUONResponse(),
73 fChargeSlope(0.0),
74 fChargeSpreadX(0.0),
75 fChargeSpreadY(0.0),
76 fSigmaIntegration(0.0),
77 fMaxAdc(0),
ccea41d4 78 fSaturation(0),
885d501b 79 fZeroSuppression(0),
80 fChargeCorrel(0.0),
81 fMathieson(new AliMUONMathieson),
d1bb9a6f 82 fChargeThreshold(1e-4),
83 fIsTailEffect(kFALSE)
30178c30 84{
9265505b 85 /// Normal constructor
885d501b 86 AliDebug(1,Form("Default ctor"));
30178c30 87}
f29ba3e1 88
2a7d64a9 89//__________________________________________________________________________
90AliMUONResponseV0::AliMUONResponseV0(const AliMUONResponseV0& other)
91: AliMUONResponse(),
92fChargeSlope(0.0),
93fChargeSpreadX(0.0),
94fChargeSpreadY(0.0),
95fSigmaIntegration(0.0),
96fMaxAdc(0),
97fSaturation(0),
98fZeroSuppression(0),
99fChargeCorrel(0.0),
100fMathieson(0),
d1bb9a6f 101fChargeThreshold(1e-4),
102fIsTailEffect(kFALSE)
2a7d64a9 103{
104 /// copy ctor
105 other.CopyTo(*this);
106}
107
108//__________________________________________________________________________
109AliMUONResponseV0&
110AliMUONResponseV0::operator=(const AliMUONResponseV0& other)
111{
112 /// Assignment operator
113 other.CopyTo(*this);
114 return *this;
115}
116
ccea41d4 117//__________________________________________________________________________
a713db22 118AliMUONResponseV0::~AliMUONResponseV0()
119{
9265505b 120/// Destructor
121
885d501b 122 AliDebug(1,"");
a713db22 123 delete fMathieson;
124}
f29ba3e1 125
2a7d64a9 126//______________________________________________________________________________
127void
128AliMUONResponseV0::CopyTo(AliMUONResponseV0& other) const
129{
130 /// Copy *this to other
131 other.fChargeSlope=fChargeSlope;
132 other.fChargeSpreadX=fChargeSpreadX;
133 other.fChargeSpreadY=fChargeSpreadY;
134 other.fSigmaIntegration=fSigmaIntegration;
135 other.fMaxAdc=fMaxAdc;
136 other.fSaturation=fSaturation;
137 other.fZeroSuppression=fZeroSuppression;
138 other.fChargeCorrel=fChargeCorrel;
139 delete other.fMathieson;
140 other.fMathieson = new AliMUONMathieson(*fMathieson);
141 other.fChargeThreshold=fChargeThreshold;
142}
143
885d501b 144//______________________________________________________________________________
145void
146AliMUONResponseV0::Print(Option_t*) const
147{
9265505b 148/// Printing
d19b6003 149
885d501b 150 cout << " ChargeSlope=" << fChargeSlope
151 << " ChargeSpreadX,Y=" << fChargeSpreadX
152 << fChargeSpreadY
153 << " ChargeCorrelation=" << fChargeCorrel
154 << endl;
f29ba3e1 155}
156
d5bfadcc 157 //__________________________________________________________________________
158void AliMUONResponseV0::SetSqrtKx3AndDeriveKx2Kx4(Float_t SqrtKx3)
159{
9265505b 160 /// Set to "SqrtKx3" the Mathieson parameter K3 ("fSqrtKx3")
161 /// in the X direction, perpendicular to the wires,
162 /// and derive the Mathieson parameters K2 ("fKx2") and K4 ("fKx4")
163 /// in the same direction
a713db22 164 fMathieson->SetSqrtKx3AndDeriveKx2Kx4(SqrtKx3);
d5bfadcc 165}
166
167 //__________________________________________________________________________
168void AliMUONResponseV0::SetSqrtKy3AndDeriveKy2Ky4(Float_t SqrtKy3)
169{
9265505b 170 /// Set to "SqrtKy3" the Mathieson parameter K3 ("fSqrtKy3")
171 /// in the Y direction, along the wires,
172 /// and derive the Mathieson parameters K2 ("fKy2") and K4 ("fKy4")
173 /// in the same direction
a713db22 174 fMathieson->SetSqrtKy3AndDeriveKy2Ky4(SqrtKy3);
d5bfadcc 175}
a713db22 176 //__________________________________________________________________________
85fec35d 177Float_t AliMUONResponseV0::IntPH(Float_t eloss) const
a9e2aefa 178{
9265505b 179 /// Calculate charge from given ionization energy loss
a9e2aefa 180 Int_t nel;
4ac9d21e 181 nel= Int_t(eloss*1.e9/27.4);
a9e2aefa 182 Float_t charge=0;
183 if (nel == 0) nel=1;
184 for (Int_t i=1;i<=nel;i++) {
01997fa2 185 Float_t arg=0.;
186 while(!arg) arg = gRandom->Rndm();
187 charge -= fChargeSlope*TMath::Log(arg);
a9e2aefa 188 }
189 return charge;
190}
a713db22 191
885d501b 192//_____________________________________________________________________________
193Float_t
194AliMUONResponseV0::GetAnod(Float_t x) const
195{
9265505b 196 /// Return wire coordinate closest to x.
197
885d501b 198 Int_t n = Int_t(x/Pitch());
199 Float_t wire = (x>0) ? n+0.5 : n-0.5;
200 return Pitch()*wire;
201}
a9e2aefa 202
885d501b 203//______________________________________________________________________________
204void
2a5f75ae 205AliMUONResponseV0::DisIntegrate(const AliMUONHit& hit, TList& digits, Float_t timeDif)
885d501b 206{
9265505b 207 /// Go from 1 hit to a list of digits.
208 /// The energy deposition of that hit is first converted into charge
209 /// (in IntPH() method), and then this charge is dispatched on several
210 /// pads, according to the Mathieson distribution.
885d501b 211
212 digits.Clear();
213
214 Int_t detElemId = hit.DetElemId();
d1bb9a6f 215 Double_t hitX = hit.X() ;
216 Double_t hitY = hit.Y() ;
217 Double_t hitZ = hit.Z() ;
218
885d501b 219 // Width of the integration area
885d501b 220 Double_t dx = SigmaIntegration()*ChargeSpreadX();
221 Double_t dy = SigmaIntegration()*ChargeSpreadY();
222
d1bb9a6f 223 //Modify to take the tailing effect.
224 if(fIsTailEffect){
225 Double_t locX,locY,locZ,globXCenter,globYCenter,globZ;
5fe36481 226 Int_t para = 5; // This parameter is a natural number(excluding zero), higher the value less is the tailing effect
d1bb9a6f 227 Double_t termA = 1.0;
228 Double_t termB = 1.0;
229 if(para>0){
230 for ( Int_t cath = AliMp::kCath0; cath <= AliMp::kCath1; ++cath )
231 {
232 // Get an iterator to loop over pads, within the given area.
233 const AliMpVSegmentation* seg =
234 AliMpSegmentation::Instance()
235 ->GetMpSegmentation(detElemId,AliMp::GetCathodType(cath));
236 AliMp::PlaneType plane = seg->PlaneType();
237
238 if(plane == AliMp::kBendingPlane) {
239 Global2Local(detElemId,hitX,hitY,hitZ,locX,locY,locZ);
6e97fbb8 240 AliMpPad pad = seg->PadByPosition(locX,locY,kFALSE);
5fe36481 241 if(pad.IsValid()){
6e97fbb8 242 Double_t locYCenter = pad.GetPositionY();
243 Double_t locXCenter = pad.GetPositionX();
5fe36481 244 const AliMUONGeometryTransformer* transformer = muon()->GetGeometryTransformer();
245 transformer->Local2Global(detElemId,locXCenter,locYCenter,locZ,globXCenter,globYCenter,globZ);
246 for(Int_t itime = 0; itime<para; itime++)
247 termA *= 10.0;
248
249 for(Int_t itime = 0; itime<Int_t((2*para) + 1); itime++)
250 termB *= (hitY - globYCenter) ;
251
252 hitY = hitY + termA*termB;
253 }// if the pad is a valid one
d1bb9a6f 254 }// if bending plane
255 }// cathode loop
256 }// if para > 0 condn
257 }// if tail effect
258
885d501b 259 // Use that (dx,dy) to specify the area upon which
260 // we will iterate to spread charge into.
261 Double_t x,y,z;
d1bb9a6f 262 Global2Local(detElemId,hitX,hitY,hitZ,x,y,z);
885d501b 263 x = GetAnod(x);
6e97fbb8 264 AliMpArea area(x,y,dx,dy);
885d501b 265
32c9ead9 266 // Get pulse height from energy loss.
885d501b 267 Float_t qtot = IntPH(hit.Eloss());
268
2a5f75ae 269 // If from a pileup event we apply a reduction factor to the charge
270 if (timeDif!=0){
271 qtot = AliMUONConstants::ReducedQTot(qtot,timeDif);
272 }
273
05315e71 274 // Scale the charge to it'll (roughly) be in fC
275 qtot *= AliMUONConstants::DefaultADC2MV()*AliMUONConstants::DefaultA0()*AliMUONConstants::DefaultCapa();
276
32c9ead9 277 // Get the charge correlation between cathodes.
885d501b 278 Float_t currentCorrel = TMath::Exp(gRandom->Gaus(0.0,ChargeCorrel()/2.0));
a9e2aefa 279
866c3232 280 for ( Int_t cath = AliMp::kCath0; cath <= AliMp::kCath1; ++cath )
885d501b 281 {
282 Float_t qcath = qtot * ( cath == 0 ? currentCorrel : 1.0/currentCorrel);
283
885d501b 284 // Get an iterator to loop over pads, within the given area.
32c9ead9 285 const AliMpVSegmentation* seg =
866c3232 286 AliMpSegmentation::Instance()
287 ->GetMpSegmentation(detElemId,AliMp::GetCathodType(cath));
885d501b 288
32c9ead9 289 AliMpVPadIterator* it = seg->CreateIterator(area);
290
291 if (!it)
292 {
293 AliError(Form("Could not get iterator for detElemId %d",detElemId));
294 return;
295 }
296
297 // Start loop over pads.
298 it->First();
299
300 if ( it->IsDone() )
301 {
302 // Exceptional case : iterator is built, but is invalid from the start.
6e97fbb8 303 AliMpPad pad = seg->PadByPosition(area.GetPositionX(),area.GetPositionY(),
304 kFALSE);
32c9ead9 305 if ( pad.IsValid() )
885d501b 306 {
ae7445c5 307 AliDebug(1, Form("Got an invalid iterator bug (area.Position() is within "
32c9ead9 308 " DE but the iterator is void) for detElemId %d cath %d",
309 detElemId,cath));
885d501b 310 }
32c9ead9 311 else
885d501b 312 {
ae7445c5 313 AliDebug(1, Form("Got an invalid iterator bug for detElemId %d cath %d."
32c9ead9 314 "Might be a bad hit ? area.Position()=(%e,%e) "
315 "Dimensions()=(%e,%e)",
6e97fbb8 316 detElemId,cath,area.GetPositionX(),area.GetPositionY(),
317 area.GetDimensionX(),area.GetDimensionY()));
885d501b 318 }
319 delete it;
32c9ead9 320 return;
321 }
322
323 while ( !it->IsDone() )
324 {
325 // For each pad given by the iterator, compute the charge of that
326 // pad, according to the Mathieson distribution.
327 AliMpPad pad = it->CurrentItem();
6e97fbb8 328 TVector2 lowerLeft(TVector2(x,y)-TVector2(pad.GetPositionX(),pad.GetPositionY())-
329 TVector2(pad.GetDimensionX(),pad.GetDimensionY()));
330 TVector2 upperRight(lowerLeft + TVector2(pad.GetDimensionX(),pad.GetDimensionY())*2.0);
32c9ead9 331 Float_t qp = TMath::Abs(fMathieson->IntXY(lowerLeft.X(),lowerLeft.Y(),
332 upperRight.X(),upperRight.Y()));
333
05315e71 334 if ( qp > fChargeThreshold &&
335 qp*qcath > AliMUONConstants::DefaultADC2MV()*AliMUONConstants::DefaultA0()*AliMUONConstants::DefaultCapa() )
32c9ead9 336 {
337 // If we're above threshold, then we create a digit,
338 // and fill it with relevant information, including electronics.
05315e71 339
340 // note that the second condition above is to be backward compatible (when
341 // the sdigitizer was making a cut on Int_t(qp*qcath) > 0 and qcath was in ADC, not in fC)
342
168e9c4d 343 AliMUONDigit* d = new AliMUONDigit(detElemId,pad.GetManuId(),
344 pad.GetManuChannel(),cath);
345 d->SetPadXY(pad.GetIx(),pad.GetIy());
05315e71 346 d->SetCharge(qp*qcath);
32c9ead9 347 digits.Add(d);
348 }
349 it->Next();
350 }
351 delete it;
885d501b 352 }
353}
a9e2aefa 354
355
356