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 // --------------------------
21 // Implementation of Mathieson response
24 #include "AliMUONResponseV0.h"
28 #include "AliMUONConstants.h"
29 #include "AliMUONDigit.h"
30 #include "AliMUONGeometrySegmentation.h"
31 #include "AliMUONGeometryTransformer.h"
32 #include "AliMUONHit.h"
33 #include "AliMUONSegmentation.h"
34 #include "AliMpArea.h"
35 #include "AliMpDEManager.h"
36 #include "AliMpVPadIterator.h"
37 #include "AliMpVSegmentation.h"
39 #include "Riostream.h"
44 ClassImp(AliMUONResponseV0)
48 return static_cast<AliMUON*>(gAlice->GetModule("MUON"));
51 void Global2Local(Int_t detElemId, Double_t xg, Double_t yg, Double_t zg,
52 Double_t& xl, Double_t& yl, Double_t& zl)
54 // ideally should be :
56 // AliMUONGeometry::Global2Local(detElemId,xg,yg,zg,x,y,z);
57 // but while waiting for this geometry singleton, let's go through
60 const AliMUONGeometryTransformer* transformer = muon()->GetGeometryTransformer();
61 transformer->Global2Local(detElemId,xg,yg,zg,xl,yl,zl);
64 AliMUONSegmentation* Segmentation()
66 static AliMUONSegmentation* segmentation = muon()->GetSegmentation();
70 //__________________________________________________________________________
71 AliMUONResponseV0::AliMUONResponseV0()
76 fSigmaIntegration(0.0),
80 fMathieson(new AliMUONMathieson),
81 fChargeThreshold(1e-4)
84 AliDebug(1,Form("Default ctor"));
87 //_________________________________________________________________________
88 AliMUONResponseV0::AliMUONResponseV0(const AliMUONResponseV0& rhs)
89 : AliMUONResponse(rhs)
91 // Protected copy constructor
93 AliFatal("Not implemented.");
96 //__________________________________________________________________________
97 AliMUONResponseV0::~AliMUONResponseV0()
103 //________________________________________________________________________
104 AliMUONResponseV0& AliMUONResponseV0::operator = (const AliMUONResponseV0& rhs)
106 // Protected assignement operator
108 if (this == &rhs) return *this;
110 AliFatal("Not implemented.");
115 //______________________________________________________________________________
117 AliMUONResponseV0::Print(Option_t*) const
121 cout << " ChargeSlope=" << fChargeSlope
122 << " ChargeSpreadX,Y=" << fChargeSpreadX
124 << " ChargeCorrelation=" << fChargeCorrel
127 //Float_t fChargeSlope; // Slope of the charge distribution
128 //Float_t fChargeSpreadX; // Width of the charge distribution in x
129 //Float_t fChargeSpreadY; // Width of the charge distribution in y
130 //Float_t fSigmaIntegration; // Number of sigma's used for charge distribution
131 //Int_t fMaxAdc; // Maximum ADC channel
132 //Int_t fSaturation; // Pad saturation in ADC channel
133 //Int_t fZeroSuppression; // Zero suppression threshold
134 //Float_t fChargeCorrel; // amplitude of charge correlation on 2 cathods
135 // // is RMS of ln(q1/q2)
136 //AliMUONMathieson* fMathieson; // pointer to mathieson fct
137 //Float_t fChargeThreshold; // Charges below this threshold are = 0
142 //__________________________________________________________________________
143 void AliMUONResponseV0::SetSqrtKx3AndDeriveKx2Kx4(Float_t SqrtKx3)
145 // Set to "SqrtKx3" the Mathieson parameter K3 ("fSqrtKx3")
146 // in the X direction, perpendicular to the wires,
147 // and derive the Mathieson parameters K2 ("fKx2") and K4 ("fKx4")
148 // in the same direction
149 fMathieson->SetSqrtKx3AndDeriveKx2Kx4(SqrtKx3);
152 //__________________________________________________________________________
153 void AliMUONResponseV0::SetSqrtKy3AndDeriveKy2Ky4(Float_t SqrtKy3)
155 // Set to "SqrtKy3" the Mathieson parameter K3 ("fSqrtKy3")
156 // in the Y direction, along the wires,
157 // and derive the Mathieson parameters K2 ("fKy2") and K4 ("fKy4")
158 // in the same direction
159 fMathieson->SetSqrtKy3AndDeriveKy2Ky4(SqrtKy3);
161 //__________________________________________________________________________
162 Float_t AliMUONResponseV0::IntPH(Float_t eloss) const
164 // Calculate charge from given ionization energy loss
166 nel= Int_t(eloss*1.e9/27.4);
169 for (Int_t i=1;i<=nel;i++) {
171 while(!arg) arg = gRandom->Rndm();
172 charge -= fChargeSlope*TMath::Log(arg);
177 //-------------------------------------------
178 Float_t AliMUONResponseV0::IntXY(Int_t idDE,
179 AliMUONGeometrySegmentation* segmentation)
182 // Calculate charge on current pad according to Mathieson distribution
184 return fMathieson->IntXY(idDE, segmentation);
188 //-------------------------------------------
189 Int_t AliMUONResponseV0::DigitResponse(Int_t digit,
190 AliMUONTransientDigit* /*where*/)
193 // \deprecated method
194 // Now part of the digitizer (where it belongs really), e.g. DigitizerV3
196 // add white noise and do zero-suppression and signal truncation
198 // Float_t meanNoise = gRandom->Gaus(1, 0.2);
199 // correct noise for slat chambers;
200 // one more field to add to AliMUONResponseV0 to allow different noises ????
201 // Float_t meanNoise = gRandom->Gaus(1., 0.2);
202 // Float_t noise = gRandom->Gaus(0., meanNoise);
203 Float_t noise = gRandom->Gaus(0., 1.0);
204 digit += TMath::Nint(noise);
205 if ( digit <= ZeroSuppression()) digit = 0;
206 // if ( digit > MaxAdc()) digit=MaxAdc();
207 if ( digit > Saturation())
215 //_____________________________________________________________________________
217 AliMUONResponseV0::GetAnod(Float_t x) const
220 // Return wire coordinate closest to x.
222 Int_t n = Int_t(x/Pitch());
223 Float_t wire = (x>0) ? n+0.5 : n-0.5;
227 //______________________________________________________________________________
229 AliMUONResponseV0::DisIntegrate(const AliMUONHit& hit, TList& digits)
232 // Go from 1 hit to a list of digits.
233 // The energy deposition of that hit is first converted into charge
234 // (in IntPH() method), and then this charge is dispatched on several
235 // pads, according to the Mathieson distribution.
240 Int_t detElemId = hit.DetElemId();
242 // Width of the integration area
243 Double_t dx = SigmaIntegration()*ChargeSpreadX();
244 Double_t dy = SigmaIntegration()*ChargeSpreadY();
246 // Use that (dx,dy) to specify the area upon which
247 // we will iterate to spread charge into.
249 Global2Local(detElemId,hit.X(),hit.Y(),hit.Z(),x,y,z);
251 TVector2 hitPosition(x,y);
252 AliMpArea area(hitPosition,TVector2(dx,dy));
254 // Get pulse height from energy loss.
255 Float_t qtot = IntPH(hit.Eloss());
257 // Get the charge correlation between cathodes.
258 Float_t currentCorrel = TMath::Exp(gRandom->Gaus(0.0,ChargeCorrel()/2.0));
260 for ( Int_t cath = 0; cath < 2; ++cath )
262 Float_t qcath = qtot * ( cath == 0 ? currentCorrel : 1.0/currentCorrel);
264 // Get an iterator to loop over pads, within the given area.
265 const AliMpVSegmentation* seg =
266 Segmentation()->GetMpSegmentation(detElemId,cath);
268 AliMpVPadIterator* it = seg->CreateIterator(area);
272 AliError(Form("Could not get iterator for detElemId %d",detElemId));
276 // Start loop over pads.
281 // Exceptional case : iterator is built, but is invalid from the start.
282 AliMpPad pad = seg->PadByPosition(area.Position(),kFALSE);
285 AliWarning(Form("Got an invalid iterator bug (area.Position() is within "
286 " DE but the iterator is void) for detElemId %d cath %d",
291 AliError(Form("Got an invalid iterator bug for detElemId %d cath %d."
292 "Might be a bad hit ? area.Position()=(%e,%e) "
293 "Dimensions()=(%e,%e)",
294 detElemId,cath,area.Position().X(),area.Position().Y(),
295 area.Dimensions().X(),area.Dimensions().Y()));
301 while ( !it->IsDone() )
303 // For each pad given by the iterator, compute the charge of that
304 // pad, according to the Mathieson distribution.
305 AliMpPad pad = it->CurrentItem();
306 TVector2 lowerLeft(hitPosition-pad.Position()-pad.Dimensions());
307 TVector2 upperRight(lowerLeft + pad.Dimensions()*2.0);
308 Float_t qp = TMath::Abs(fMathieson->IntXY(lowerLeft.X(),lowerLeft.Y(),
309 upperRight.X(),upperRight.Y()));
311 Int_t icharge = Int_t(qp*qcath);
313 if ( qp > fChargeThreshold )
315 // If we're above threshold, then we create a digit,
316 // and fill it with relevant information, including electronics.
317 AliMUONDigit* d = new AliMUONDigit;
318 d->SetDetElemId(detElemId);
319 d->SetPadX(pad.GetIndices().GetFirst());
320 d->SetPadY(pad.GetIndices().GetSecond());
321 d->SetSignal(icharge);
322 d->AddPhysicsSignal(d->Signal());
324 d->SetElectronics(pad.GetLocation().GetFirst(),
325 pad.GetLocation().GetSecond());