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 **************************************************************************/
19 #include "AliMUONResponseV0.h"
23 #include "AliMUONConstants.h"
24 #include "AliMUONDigit.h"
25 #include "AliMUONGeometrySegmentation.h"
26 #include "AliMUONGeometryTransformer.h"
27 #include "AliMUONHit.h"
28 #include "AliMUONSegmentation.h"
29 #include "AliMpArea.h"
30 #include "AliMpDEManager.h"
31 #include "AliMpVPadIterator.h"
32 #include "AliMpVSegmentation.h"
34 #include "Riostream.h"
39 ClassImp(AliMUONResponseV0)
43 return static_cast<AliMUON*>(gAlice->GetModule("MUON"));
46 void Global2Local(Int_t detElemId, Double_t xg, Double_t yg, Double_t zg,
47 Double_t& xl, Double_t& yl, Double_t& zl)
49 // ideally should be :
51 // AliMUONGeometry::Global2Local(detElemId,xg,yg,zg,x,y,z);
52 // but while waiting for this geometry singleton, let's go through
55 const AliMUONGeometryTransformer* transformer = muon()->GetGeometryTransformer();
56 transformer->Global2Local(detElemId,xg,yg,zg,xl,yl,zl);
59 AliMUONSegmentation* Segmentation()
61 static AliMUONSegmentation* segmentation = muon()->GetSegmentation();
65 //__________________________________________________________________________
66 AliMUONResponseV0::AliMUONResponseV0()
71 fSigmaIntegration(0.0),
75 fMathieson(new AliMUONMathieson),
76 fChargeThreshold(1e-4)
79 AliDebug(1,Form("Default ctor"));
82 //_________________________________________________________________________
83 AliMUONResponseV0::AliMUONResponseV0(const AliMUONResponseV0& rhs)
84 : AliMUONResponse(rhs)
86 // Protected copy constructor
88 AliFatal("Not implemented.");
91 //__________________________________________________________________________
92 AliMUONResponseV0::~AliMUONResponseV0()
98 //________________________________________________________________________
99 AliMUONResponseV0& AliMUONResponseV0::operator = (const AliMUONResponseV0& rhs)
101 // Protected assignement operator
103 if (this == &rhs) return *this;
105 AliFatal("Not implemented.");
110 //______________________________________________________________________________
112 AliMUONResponseV0::Print(Option_t*) const
114 cout << " ChargeSlope=" << fChargeSlope
115 << " ChargeSpreadX,Y=" << fChargeSpreadX
117 << " ChargeCorrelation=" << fChargeCorrel
120 //Float_t fChargeSlope; // Slope of the charge distribution
121 //Float_t fChargeSpreadX; // Width of the charge distribution in x
122 //Float_t fChargeSpreadY; // Width of the charge distribution in y
123 //Float_t fSigmaIntegration; // Number of sigma's used for charge distribution
124 //Int_t fMaxAdc; // Maximum ADC channel
125 //Int_t fSaturation; // Pad saturation in ADC channel
126 //Int_t fZeroSuppression; // Zero suppression threshold
127 //Float_t fChargeCorrel; // amplitude of charge correlation on 2 cathods
128 // // is RMS of ln(q1/q2)
129 //AliMUONMathieson* fMathieson; // pointer to mathieson fct
130 //Float_t fChargeThreshold; // Charges below this threshold are = 0
135 //__________________________________________________________________________
136 void AliMUONResponseV0::SetSqrtKx3AndDeriveKx2Kx4(Float_t SqrtKx3)
138 // Set to "SqrtKx3" the Mathieson parameter K3 ("fSqrtKx3")
139 // in the X direction, perpendicular to the wires,
140 // and derive the Mathieson parameters K2 ("fKx2") and K4 ("fKx4")
141 // in the same direction
142 fMathieson->SetSqrtKx3AndDeriveKx2Kx4(SqrtKx3);
145 //__________________________________________________________________________
146 void AliMUONResponseV0::SetSqrtKy3AndDeriveKy2Ky4(Float_t SqrtKy3)
148 // Set to "SqrtKy3" the Mathieson parameter K3 ("fSqrtKy3")
149 // in the Y direction, along the wires,
150 // and derive the Mathieson parameters K2 ("fKy2") and K4 ("fKy4")
151 // in the same direction
152 fMathieson->SetSqrtKy3AndDeriveKy2Ky4(SqrtKy3);
154 //__________________________________________________________________________
155 Float_t AliMUONResponseV0::IntPH(Float_t eloss)
157 // Calculate charge from given ionization energy loss
159 nel= Int_t(eloss*1.e9/27.4);
162 for (Int_t i=1;i<=nel;i++) {
164 while(!arg) arg = gRandom->Rndm();
165 charge -= fChargeSlope*TMath::Log(arg);
170 //-------------------------------------------
171 Float_t AliMUONResponseV0::IntXY(Int_t idDE, AliMUONGeometrySegmentation* segmentation)
173 // Calculate charge on current pad according to Mathieson distribution
175 return fMathieson->IntXY(idDE, segmentation);
179 //-------------------------------------------
180 Int_t AliMUONResponseV0::DigitResponse(Int_t digit, AliMUONTransientDigit* /*where*/)
182 // \deprecated method
183 // Now part of the digitizer (where it belongs really), e.g. DigitizerV3
185 // add white noise and do zero-suppression and signal truncation
187 // Float_t meanNoise = gRandom->Gaus(1, 0.2);
188 // correct noise for slat chambers;
189 // one more field to add to AliMUONResponseV0 to allow different noises ????
190 // Float_t meanNoise = gRandom->Gaus(1., 0.2);
191 // Float_t noise = gRandom->Gaus(0., meanNoise);
192 Float_t noise = gRandom->Gaus(0., 1.0);
193 digit += TMath::Nint(noise);
194 if ( digit <= ZeroSuppression()) digit = 0;
195 // if ( digit > MaxAdc()) digit=MaxAdc();
196 if ( digit > Saturation())
204 //_____________________________________________________________________________
206 AliMUONResponseV0::GetAnod(Float_t x) const
209 // Return wire coordinate closest to x.
211 Int_t n = Int_t(x/Pitch());
212 Float_t wire = (x>0) ? n+0.5 : n-0.5;
216 //______________________________________________________________________________
218 AliMUONResponseV0::DisIntegrate(const AliMUONHit& hit, TList& digits)
221 // Go from 1 hit to a list of digits.
222 // The energy deposition of that hit is first converted into charge
223 // (in IntPH() method), and then this charge is dispatched on several
224 // pads, according to the Mathieson distribution.
229 Int_t detElemId = hit.DetElemId();
231 // Width of the integration area
232 Double_t dx = SigmaIntegration()*ChargeSpreadX();
233 Double_t dy = SigmaIntegration()*ChargeSpreadY();
235 // Use that (dx,dy) to specify the area upon which
236 // we will iterate to spread charge into.
238 Global2Local(detElemId,hit.X(),hit.Y(),hit.Z(),x,y,z);
240 TVector2 hitPosition(x,y);
241 AliMpArea area(hitPosition,TVector2(dx,dy));
243 // Get pulse height from energy loss.
244 Float_t qtot = IntPH(hit.Eloss());
246 // Get the charge correlation between cathodes.
247 Float_t currentCorrel = TMath::Exp(gRandom->Gaus(0.0,ChargeCorrel()/2.0));
249 for ( Int_t cath = 0; cath < 2; ++cath )
251 Float_t qcath = qtot * ( cath == 0 ? currentCorrel : 1.0/currentCorrel);
253 // Get an iterator to loop over pads, within the given area.
254 const AliMpVSegmentation* seg =
255 Segmentation()->GetMpSegmentation(detElemId,cath);
257 AliMpVPadIterator* it = seg->CreateIterator(area);
261 AliError(Form("Could not get iterator for detElemId %d",detElemId));
265 // Start loop over pads.
270 // Exceptional case : iterator is built, but is invalid from the start.
271 AliMpPad pad = seg->PadByPosition(area.Position(),kFALSE);
274 AliWarning(Form("Got an invalid iterator bug (area.Position() is within "
275 " DE but the iterator is void) for detElemId %d cath %d",
280 AliError(Form("Got an invalid iterator bug for detElemId %d cath %d."
281 "Might be a bad hit ? area.Position()=(%e,%e) "
282 "Dimensions()=(%e,%e)",
283 detElemId,cath,area.Position().X(),area.Position().Y(),
284 area.Dimensions().X(),area.Dimensions().Y()));
290 while ( !it->IsDone() )
292 // For each pad given by the iterator, compute the charge of that
293 // pad, according to the Mathieson distribution.
294 AliMpPad pad = it->CurrentItem();
295 TVector2 lowerLeft(hitPosition-pad.Position()-pad.Dimensions());
296 TVector2 upperRight(lowerLeft + pad.Dimensions()*2.0);
297 Float_t qp = TMath::Abs(fMathieson->IntXY(lowerLeft.X(),lowerLeft.Y(),
298 upperRight.X(),upperRight.Y()));
300 Int_t icharge = Int_t(qp*qcath);
302 if ( qp > fChargeThreshold )
304 // If we're above threshold, then we create a digit,
305 // and fill it with relevant information, including electronics.
306 AliMUONDigit* d = new AliMUONDigit;
307 d->SetDetElemId(detElemId);
308 d->SetPadX(pad.GetIndices().GetFirst());
309 d->SetPadY(pad.GetIndices().GetSecond());
310 d->SetSignal(icharge);
311 d->AddPhysicsSignal(d->Signal());
313 d->SetElectronics(pad.GetLocation().GetFirst(),
314 pad.GetLocation().GetSecond());