AliRoot Core  a565103 (a565103)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMUONResponseV0.cxx
Go to the documentation of this file.
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 
16 /* $Id$ */
17 
18 //-----------------------------------------------------------------------------
19 // Class AliMUONResponseV0
20 // --------------------------
21 // Implementation of
22 // Mathieson response
23 //-----------------------------------------------------------------------------
24 
25 #include "AliMUONResponseV0.h"
26 #include "AliMUON.h"
27 #include "AliMUONConstants.h"
28 #include "AliMUONDigit.h"
30 #include "AliMUONHit.h"
31 #include "AliMUONConstants.h"
32 
33 #include "AliMpArea.h"
34 #include "AliMpDEManager.h"
35 #include "AliMpVPadIterator.h"
36 #include "AliMpSegmentation.h"
37 #include "AliMpVSegmentation.h"
38 #include "AliMpCathodType.h"
39 
40 #include "AliRun.h"
41 #include "AliLog.h"
42 
43 #include "Riostream.h"
44 #include "TVector2.h"
45 #include <TMath.h>
46 #include <TRandom.h>
47 
48 using std::endl;
49 using std::cout;
53 
55 {
56  return static_cast<AliMUON*>(gAlice->GetModule("MUON"));
57 }
58 
59 void Global2Local(Int_t detElemId, Double_t xg, Double_t yg, Double_t zg,
60  Double_t& xl, Double_t& yl, Double_t& zl)
61 {
67 
68  const AliMUONGeometryTransformer* transformer = muon()->GetGeometryTransformer();
69  transformer->Global2Local(detElemId,xg,yg,zg,xl,yl,zl);
70 }
71 
72 //__________________________________________________________________________
74  : AliMUONResponse(),
75  fChargeSlope(0.0),
76  fChargeSpreadX(0.0),
77  fChargeSpreadY(0.0),
78  fSigmaIntegration(0.0),
79  fMaxAdc(0),
80  fSaturation(0),
81  fZeroSuppression(0),
82  fChargeCorrel(0.0),
83  fMathieson(new AliMUONMathieson),
84  fChargeThreshold(1e-4),
85  fIsTailEffect(kFALSE)
86 {
88  AliDebug(1,Form("Default ctor"));
89 }
90 
91 //__________________________________________________________________________
93 : AliMUONResponse(),
94 fChargeSlope(0.0),
95 fChargeSpreadX(0.0),
96 fChargeSpreadY(0.0),
97 fSigmaIntegration(0.0),
98 fMaxAdc(0),
99 fSaturation(0),
100 fZeroSuppression(0),
101 fChargeCorrel(0.0),
102 fMathieson(0),
103 fChargeThreshold(1e-4),
104 fIsTailEffect(kFALSE)
105 {
107  other.CopyTo(*this);
108 }
109 
110 //__________________________________________________________________________
113 {
115  other.CopyTo(*this);
116  return *this;
117 }
118 
119 //__________________________________________________________________________
121 {
123 
124  AliDebug(1,"");
125  delete fMathieson;
126 }
127 
128 //______________________________________________________________________________
129 void
131 {
137  other.fMaxAdc=fMaxAdc;
138  other.fSaturation=fSaturation;
141  delete other.fMathieson;
142  other.fMathieson = new AliMUONMathieson(*fMathieson);
144 }
145 
146 //______________________________________________________________________________
147 void
148 AliMUONResponseV0::Print(Option_t*) const
149 {
151 
152  cout << " ChargeSlope=" << fChargeSlope
153  << " ChargeSpreadX,Y=" << fChargeSpreadX
154  << fChargeSpreadY
155  << " ChargeCorrelation=" << fChargeCorrel
156  << endl;
157 }
158 
159  //__________________________________________________________________________
161 {
167 }
168 
169  //__________________________________________________________________________
171 {
177 }
178  //__________________________________________________________________________
179 Float_t AliMUONResponseV0::IntPH(Float_t eloss) const
180 {
182  Int_t nel;
183  nel= Int_t(eloss*1.e9/27.4);
184  Float_t charge=0;
185  if (nel == 0) nel=1;
186  for (Int_t i=1;i<=nel;i++) {
187  Float_t arg=0.;
188  while(!arg) arg = gRandom->Rndm();
189  charge -= fChargeSlope*TMath::Log(arg);
190  }
191  return charge;
192 }
193 
194 //_____________________________________________________________________________
195 Float_t
197 {
199 
200  Int_t n = Int_t(x/Pitch());
201  Float_t wire = (x>0) ? n+0.5 : n-0.5;
202  return Pitch()*wire;
203 }
204 
205 //______________________________________________________________________________
206 void
207 AliMUONResponseV0::DisIntegrate(const AliMUONHit& hit, TList& digits, Float_t timeDif)
208 {
213 
214  digits.Clear();
215 
216  Int_t detElemId = hit.DetElemId();
217  Double_t hitX = hit.X() ;
218  Double_t hitY = hit.Y() ;
219  Double_t hitZ = hit.Z() ;
220 
221  // Width of the integration area
222  Double_t dx = SigmaIntegration()*ChargeSpreadX();
223  Double_t dy = SigmaIntegration()*ChargeSpreadY();
224 
225  //Modify to take the tailing effect.
226  if(fIsTailEffect){
227  Double_t locX,locY,locZ,globXCenter,globYCenter,globZ;
228  Int_t para = 5; // This parameter is a natural number(excluding zero), higher the value less is the tailing effect
229  Double_t termA = 1.0;
230  Double_t termB = 1.0;
231  if(para>0){
232  for ( Int_t cath = AliMp::kCath0; cath <= AliMp::kCath1; ++cath )
233  {
234  // Get an iterator to loop over pads, within the given area.
235  const AliMpVSegmentation* seg =
237  ->GetMpSegmentation(detElemId,AliMp::GetCathodType(cath));
238  AliMp::PlaneType plane = seg->PlaneType();
239 
240  if(plane == AliMp::kBendingPlane) {
241  Global2Local(detElemId,hitX,hitY,hitZ,locX,locY,locZ);
242  AliMpPad pad = seg->PadByPosition(locX,locY,kFALSE);
243  if(pad.IsValid()){
244  Double_t locYCenter = pad.GetPositionY();
245  Double_t locXCenter = pad.GetPositionX();
246  const AliMUONGeometryTransformer* transformer = muon()->GetGeometryTransformer();
247  transformer->Local2Global(detElemId,locXCenter,locYCenter,locZ,globXCenter,globYCenter,globZ);
248  for(Int_t itime = 0; itime<para; itime++)
249  termA *= 10.0;
250 
251  for(Int_t itime = 0; itime<Int_t((2*para) + 1); itime++)
252  termB *= (hitY - globYCenter) ;
253 
254  hitY = hitY + termA*termB;
255  }// if the pad is a valid one
256  }// if bending plane
257  }// cathode loop
258  }// if para > 0 condn
259  }// if tail effect
260 
261  // Use that (dx,dy) to specify the area upon which
262  // we will iterate to spread charge into.
263  Double_t x,y,z;
264  Global2Local(detElemId,hitX,hitY,hitZ,x,y,z);
265  x = GetAnod(x);
266  AliMpArea area(x,y,dx,dy);
267 
268  // Get pulse height from energy loss.
269  Float_t qtot = IntPH(hit.Eloss());
270 
271  // If from a pileup event we apply a reduction factor to the charge
272  if (timeDif!=0){
273  qtot = AliMUONConstants::ReducedQTot(qtot,timeDif);
274  }
275 
276  // Scale the charge to it'll (roughly) be in fC
278 
279  // Get the charge correlation between cathodes.
280  Float_t currentCorrel = TMath::Exp(gRandom->Gaus(0.0,ChargeCorrel()/2.0));
281 
282  for ( Int_t cath = AliMp::kCath0; cath <= AliMp::kCath1; ++cath )
283  {
284  Float_t qcath = qtot * ( cath == 0 ? currentCorrel : 1.0/currentCorrel);
285 
286  // Get an iterator to loop over pads, within the given area.
287  const AliMpVSegmentation* seg =
289  ->GetMpSegmentation(detElemId,AliMp::GetCathodType(cath));
290 
291  AliMpVPadIterator* it = seg->CreateIterator(area);
292 
293  if (!it)
294  {
295  AliError(Form("Could not get iterator for detElemId %d",detElemId));
296  return;
297  }
298 
299  // Start loop over pads.
300  it->First();
301 
302  if ( it->IsDone() )
303  {
304  // Exceptional case : iterator is built, but is invalid from the start.
305  AliMpPad pad = seg->PadByPosition(area.GetPositionX(),area.GetPositionY(),
306  kFALSE);
307  if ( pad.IsValid() )
308  {
309  AliDebug(1, Form("Got an invalid iterator bug (area.Position() is within "
310  " DE but the iterator is void) for detElemId %d cath %d",
311  detElemId,cath));
312  }
313  else
314  {
315  AliDebug(1, Form("Got an invalid iterator bug for detElemId %d cath %d."
316  "Might be a bad hit ? area.Position()=(%e,%e) "
317  "Dimensions()=(%e,%e)",
318  detElemId,cath,area.GetPositionX(),area.GetPositionY(),
319  area.GetDimensionX(),area.GetDimensionY()));
320  }
321  delete it;
322  return;
323  }
324 
325  while ( !it->IsDone() )
326  {
327  // For each pad given by the iterator, compute the charge of that
328  // pad, according to the Mathieson distribution.
329  AliMpPad pad = it->CurrentItem();
330  TVector2 lowerLeft(TVector2(x,y)-TVector2(pad.GetPositionX(),pad.GetPositionY())-
331  TVector2(pad.GetDimensionX(),pad.GetDimensionY()));
332  TVector2 upperRight(lowerLeft + TVector2(pad.GetDimensionX(),pad.GetDimensionY())*2.0);
333  Float_t qp = TMath::Abs(fMathieson->IntXY(lowerLeft.X(),lowerLeft.Y(),
334  upperRight.X(),upperRight.Y()));
335 
336  if ( qp > fChargeThreshold &&
338  {
339  // If we're above threshold, then we create a digit,
340  // and fill it with relevant information, including electronics.
341 
342  // note that the second condition above is to be backward compatible (when
343  // the sdigitizer was making a cut on Int_t(qp*qcath) > 0 and qcath was in ADC, not in fC)
344 
345  AliMUONDigit* d = new AliMUONDigit(detElemId,pad.GetManuId(),
346  pad.GetManuChannel(),cath);
347  d->SetPadXY(pad.GetIx(),pad.GetIy());
348  d->SetCharge(qp*qcath);
349  digits.Add(d);
350  }
351  it->Next();
352  }
353  delete it;
354  }
355 }
356 
357 
358 
virtual Float_t ChargeSpreadX() const
Get sigma_X of the charge spread function.
virtual Float_t Pitch() const
Set anode cathode Pitch.
const AliMpVSegmentation * GetMpSegmentation(Int_t detElemId, AliMp::CathodType cath, Bool_t warn=true) const
void SetSqrtKx3AndDeriveKx2Kx4(Float_t SqrtKx3)
Mathieson sqrt{Kx3} and derived Kx2 and Kx4.
Double_t GetDimensionY() const
Return y dimensions.
Definition: AliMpArea.h:81
Float_t IntXY(Float_t xi1, Float_t yi1, Float_t xi2, Float_t yi2) const
Charge integration on region (x1,y1,x2,y2).
Double_t GetPositionY() const
Return y position.
Definition: AliMpArea.h:77
virtual AliMp::PlaneType PlaneType() const =0
Return the plane type.
static AliMpSegmentation * Instance(Bool_t warn=true)
Float_t Eloss() const
Return Ionisation energy loss in gas.
Definition: AliMUONHit.h:52
Int_t GetIy() const
Definition: AliMpPad.cxx:280
Int_t fZeroSuppression
Zero suppression threshold.
Top container class for geometry transformations.
Int_t GetManuId() const
Definition: AliMpPad.cxx:256
Float_t fChargeSpreadY
Width of the charge distribution in y.
virtual Float_t ChargeSpreadY() const
Get sigma_Y of the charge spread function.
Implementation of Mathieson response.
void Global2Local(Int_t detElemId, Double_t xg, Double_t yg, Double_t zg, Double_t &xl, Double_t &yl, Double_t &zl)
Float_t fChargeThreshold
Charges below this threshold are = 0.
A rectangle area positioned in plane..
Definition: AliMpArea.h:20
AliDetector class for MUON subsystem providing simulation data management.
Definition: AliMUON.h:37
virtual void SetSqrtKy3AndDeriveKy2Ky4(Float_t SqrtKy3)
Mathieson sqrt{Ky3} and derived Ky2 and Ky4.
virtual Bool_t IsDone() const =0
Is iterator done.
static Float_t DefaultA0()
static Float_t ReducedQTot(Float_t qtot, Float_t timeDif)
Return a reduced total charge.
Float_t fChargeSpreadX
Width of the charge distribution in x.
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
Int_t fSaturation
Pad saturation in ADC channel.
Int_t GetManuChannel() const
Definition: AliMpPad.cxx:264
void Local2Global(Int_t detElemId, Float_t xl, Float_t yl, Float_t zl, Float_t &xg, Float_t &yg, Float_t &zg) const
virtual Float_t ChargeCorrel() const
Get the charge correlation.
Float_t fChargeCorrel
amplitude of charge correlation on 2 cathods is RMS of ln(q1/q2)
Float_t fSigmaIntegration
Number of sigma's used for charge distribution.
virtual void Print(Option_t *opt="") const
virtual void SetPadXY(Int_t padx, Int_t pady)
Set pad number along x.
Definition: AliMUONDigit.h:66
virtual Float_t GetAnod(Float_t x) const
AliMUONMathieson * fMathieson
pointer to mathieson fct
void CopyTo(AliMUONResponseV0 &other) const
Double_t GetDimensionX() const
Return x dimensions.
Definition: AliMpArea.h:79
MUON digit.
Definition: AliMUONDigit.h:17
virtual void Next()=0
Set iterator to the next pad.
Float_t fChargeSlope
Slope of the charge distribution.
An interface for an iterator over pads.
Double_t GetPositionY() const
Return the pad x position (in cm)
Definition: AliMpPad.h:81
Bool_t fIsTailEffect
switch to turn on/off the tail effect
static Float_t DefaultCapa()
Int_t fMaxAdc
Maximum ADC channel.
const AliMUONGeometryTransformer * GetGeometryTransformer() const
Definition: AliMUON.cxx:243
static Float_t DefaultADC2MV()
virtual void SetCharge(Float_t q)
Set charge.
Definition: AliMUONDigit.h:67
AliMp::CathodType GetCathodType(Int_t cathodNumber)
Convert integer number in enum;.
AliRun * gAlice
Implementation of Mathieson response.
Double_t GetPositionX() const
Return x position.
Definition: AliMpArea.h:75
virtual AliMpPad CurrentItem() const =0
Return current pad.
Int_t DetElemId() const
Return detection element ID.
Definition: AliMUONHit.h:43
virtual void SetSqrtKx3AndDeriveKx2Kx4(Float_t SqrtKx3)
Bool_t IsValid() const
Return validity.
Definition: AliMpPad.h:89
bending plane
virtual AliMpPad PadByPosition(Double_t x, Double_t y, Bool_t warning=true) const =0
Find pad by position.
void Global2Local(Int_t detElemId, Float_t xg, Float_t yg, Float_t zg, Float_t &xl, Float_t &yl, Float_t &zl) const
Int_t GetIx() const
Definition: AliMpPad.cxx:272
Chamber response base class.
AliMUON * muon()
The abstract base class for the segmentation.
virtual Float_t IntPH(Float_t eloss) const
Pulse height from scored quantity (eloss) (dummy)
MonteCarlo hit.
Definition: AliMUONHit.h:24
Double_t GetDimensionY() const
Return the y pad dimension - half length (in cm)
Definition: AliMpPad.h:86
virtual void DisIntegrate(const AliMUONHit &hit, TList &digits, Float_t timeDif)
virtual void First()=0
Set iterator to the first pad.
Class which encapsuate all information about a pad.
Definition: AliMpPad.h:22
Double_t GetPositionX() const
Return the pad x position (in cm)
Definition: AliMpPad.h:79
Double_t GetDimensionX() const
Return the x pad dimension - half length (in cm)
Definition: AliMpPad.h:84
void SetSqrtKy3AndDeriveKy2Ky4(Float_t SqrtKy3)
Mathieson sqrt{Ky3} and derived Ky2 and Ky4.
virtual Float_t SigmaIntegration() const
Get number of sigmas over which cluster didintegration is performed.
AliMUONResponseV0 & operator=(const AliMUONResponseV0 &rhs)