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),
81 fMathieson(new AliMUONMathieson),
82 fChargeThreshold(1e-4)
85 AliDebug(1,Form("Default ctor"));
88 //__________________________________________________________________________
89 AliMUONResponseV0::~AliMUONResponseV0()
95 //______________________________________________________________________________
97 AliMUONResponseV0::Print(Option_t*) const
101 cout << " ChargeSlope=" << fChargeSlope
102 << " ChargeSpreadX,Y=" << fChargeSpreadX
104 << " ChargeCorrelation=" << fChargeCorrel
108 //__________________________________________________________________________
109 void AliMUONResponseV0::SetSqrtKx3AndDeriveKx2Kx4(Float_t SqrtKx3)
111 // Set to "SqrtKx3" the Mathieson parameter K3 ("fSqrtKx3")
112 // in the X direction, perpendicular to the wires,
113 // and derive the Mathieson parameters K2 ("fKx2") and K4 ("fKx4")
114 // in the same direction
115 fMathieson->SetSqrtKx3AndDeriveKx2Kx4(SqrtKx3);
118 //__________________________________________________________________________
119 void AliMUONResponseV0::SetSqrtKy3AndDeriveKy2Ky4(Float_t SqrtKy3)
121 // Set to "SqrtKy3" the Mathieson parameter K3 ("fSqrtKy3")
122 // in the Y direction, along the wires,
123 // and derive the Mathieson parameters K2 ("fKy2") and K4 ("fKy4")
124 // in the same direction
125 fMathieson->SetSqrtKy3AndDeriveKy2Ky4(SqrtKy3);
127 //__________________________________________________________________________
128 Float_t AliMUONResponseV0::IntPH(Float_t eloss) const
130 // Calculate charge from given ionization energy loss
132 nel= Int_t(eloss*1.e9/27.4);
135 for (Int_t i=1;i<=nel;i++) {
137 while(!arg) arg = gRandom->Rndm();
138 charge -= fChargeSlope*TMath::Log(arg);
143 //-------------------------------------------
144 Float_t AliMUONResponseV0::IntXY(Int_t idDE,
145 AliMUONGeometrySegmentation* segmentation)
148 // Calculate charge on current pad according to Mathieson distribution
150 return fMathieson->IntXY(idDE, segmentation);
154 //-------------------------------------------
155 Int_t AliMUONResponseV0::DigitResponse(Int_t digit,
156 AliMUONTransientDigit* /*where*/)
159 // \deprecated method
160 // Now part of the digitizer (where it belongs really), e.g. DigitizerV3
162 // add white noise and do zero-suppression and signal truncation
164 // Float_t meanNoise = gRandom->Gaus(1, 0.2);
165 // correct noise for slat chambers;
166 // one more field to add to AliMUONResponseV0 to allow different noises ????
167 // Float_t meanNoise = gRandom->Gaus(1., 0.2);
168 // Float_t noise = gRandom->Gaus(0., meanNoise);
169 Float_t noise = gRandom->Gaus(0., 1.0);
170 digit += TMath::Nint(noise);
171 if ( digit <= ZeroSuppression()) digit = 0;
172 // if ( digit > MaxAdc()) digit=MaxAdc();
173 if ( digit > Saturation())
181 //_____________________________________________________________________________
183 AliMUONResponseV0::GetAnod(Float_t x) const
186 // Return wire coordinate closest to x.
188 Int_t n = Int_t(x/Pitch());
189 Float_t wire = (x>0) ? n+0.5 : n-0.5;
193 //______________________________________________________________________________
195 AliMUONResponseV0::DisIntegrate(const AliMUONHit& hit, TList& digits)
198 // Go from 1 hit to a list of digits.
199 // The energy deposition of that hit is first converted into charge
200 // (in IntPH() method), and then this charge is dispatched on several
201 // pads, according to the Mathieson distribution.
206 Int_t detElemId = hit.DetElemId();
208 // Width of the integration area
209 Double_t dx = SigmaIntegration()*ChargeSpreadX();
210 Double_t dy = SigmaIntegration()*ChargeSpreadY();
212 // Use that (dx,dy) to specify the area upon which
213 // we will iterate to spread charge into.
215 Global2Local(detElemId,hit.X(),hit.Y(),hit.Z(),x,y,z);
217 TVector2 hitPosition(x,y);
218 AliMpArea area(hitPosition,TVector2(dx,dy));
220 // Get pulse height from energy loss.
221 Float_t qtot = IntPH(hit.Eloss());
223 // Get the charge correlation between cathodes.
224 Float_t currentCorrel = TMath::Exp(gRandom->Gaus(0.0,ChargeCorrel()/2.0));
226 for ( Int_t cath = 0; cath < 2; ++cath )
228 Float_t qcath = qtot * ( cath == 0 ? currentCorrel : 1.0/currentCorrel);
230 // Get an iterator to loop over pads, within the given area.
231 const AliMpVSegmentation* seg =
232 Segmentation()->GetMpSegmentation(detElemId,cath);
234 AliMpVPadIterator* it = seg->CreateIterator(area);
238 AliError(Form("Could not get iterator for detElemId %d",detElemId));
242 // Start loop over pads.
247 // Exceptional case : iterator is built, but is invalid from the start.
248 AliMpPad pad = seg->PadByPosition(area.Position(),kFALSE);
251 AliWarning(Form("Got an invalid iterator bug (area.Position() is within "
252 " DE but the iterator is void) for detElemId %d cath %d",
257 AliError(Form("Got an invalid iterator bug for detElemId %d cath %d."
258 "Might be a bad hit ? area.Position()=(%e,%e) "
259 "Dimensions()=(%e,%e)",
260 detElemId,cath,area.Position().X(),area.Position().Y(),
261 area.Dimensions().X(),area.Dimensions().Y()));
267 while ( !it->IsDone() )
269 // For each pad given by the iterator, compute the charge of that
270 // pad, according to the Mathieson distribution.
271 AliMpPad pad = it->CurrentItem();
272 TVector2 lowerLeft(hitPosition-pad.Position()-pad.Dimensions());
273 TVector2 upperRight(lowerLeft + pad.Dimensions()*2.0);
274 Float_t qp = TMath::Abs(fMathieson->IntXY(lowerLeft.X(),lowerLeft.Y(),
275 upperRight.X(),upperRight.Y()));
277 Int_t icharge = Int_t(qp*qcath);
279 if ( qp > fChargeThreshold )
281 // If we're above threshold, then we create a digit,
282 // and fill it with relevant information, including electronics.
283 AliMUONDigit* d = new AliMUONDigit;
284 d->SetDetElemId(detElemId);
285 d->SetPadX(pad.GetIndices().GetFirst());
286 d->SetPadY(pad.GetIndices().GetSecond());
287 d->SetSignal(icharge);
288 d->AddPhysicsSignal(d->Signal());
290 d->SetElectronics(pad.GetLocation().GetFirst(),
291 pad.GetLocation().GetSecond());