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 "AliMpPlaneType.h"
32 #include "AliMpStationType.h"
33 #include "AliMpVPadIterator.h"
34 #include "AliMpVSegmentation.h"
36 #include "Riostream.h"
41 ClassImp(AliMUONResponseV0)
45 return static_cast<AliMUON*>(gAlice->GetModule("MUON"));
48 void Global2Local(Int_t detElemId, Double_t xg, Double_t yg, Double_t zg,
49 Double_t& xl, Double_t& yl, Double_t& zl)
51 // ideally should be :
53 // AliMUONGeometry::Global2Local(detElemId,xg,yg,zg,x,y,z);
54 // but while waiting for this geometry singleton, let's go through
57 const AliMUONGeometryTransformer* transformer = muon()->GetGeometryTransformer();
58 transformer->Global2Local(detElemId,xg,yg,zg,xl,yl,zl);
61 AliMUONSegmentation* Segmentation()
63 static AliMUONSegmentation* segmentation = muon()->GetSegmentation();
67 //__________________________________________________________________________
68 AliMUONResponseV0::AliMUONResponseV0()
73 fSigmaIntegration(0.0),
77 fMathieson(new AliMUONMathieson),
78 fChargeThreshold(1e-4)
81 AliDebug(1,Form("Default ctor"));
84 //_________________________________________________________________________
85 AliMUONResponseV0::AliMUONResponseV0(const AliMUONResponseV0& rhs)
86 : AliMUONResponse(rhs)
88 // Protected copy constructor
90 AliFatal("Not implemented.");
93 //__________________________________________________________________________
94 AliMUONResponseV0::~AliMUONResponseV0()
100 //________________________________________________________________________
101 AliMUONResponseV0& AliMUONResponseV0::operator = (const AliMUONResponseV0& rhs)
103 // Protected assignement operator
105 if (this == &rhs) return *this;
107 AliFatal("Not implemented.");
112 //______________________________________________________________________________
114 AliMUONResponseV0::Print(Option_t*) const
116 cout << " ChargeSlope=" << fChargeSlope
117 << " ChargeSpreadX,Y=" << fChargeSpreadX
119 << " ChargeCorrelation=" << fChargeCorrel
122 //Float_t fChargeSlope; // Slope of the charge distribution
123 //Float_t fChargeSpreadX; // Width of the charge distribution in x
124 //Float_t fChargeSpreadY; // Width of the charge distribution in y
125 //Float_t fSigmaIntegration; // Number of sigma's used for charge distribution
126 //Int_t fMaxAdc; // Maximum ADC channel
127 //Int_t fSaturation; // Pad saturation in ADC channel
128 //Int_t fZeroSuppression; // Zero suppression threshold
129 //Float_t fChargeCorrel; // amplitude of charge correlation on 2 cathods
130 // // is RMS of ln(q1/q2)
131 //AliMUONMathieson* fMathieson; // pointer to mathieson fct
132 //Float_t fChargeThreshold; // Charges below this threshold are = 0
137 //__________________________________________________________________________
138 void AliMUONResponseV0::SetSqrtKx3AndDeriveKx2Kx4(Float_t SqrtKx3)
140 // Set to "SqrtKx3" the Mathieson parameter K3 ("fSqrtKx3")
141 // in the X direction, perpendicular to the wires,
142 // and derive the Mathieson parameters K2 ("fKx2") and K4 ("fKx4")
143 // in the same direction
144 fMathieson->SetSqrtKx3AndDeriveKx2Kx4(SqrtKx3);
147 //__________________________________________________________________________
148 void AliMUONResponseV0::SetSqrtKy3AndDeriveKy2Ky4(Float_t SqrtKy3)
150 // Set to "SqrtKy3" the Mathieson parameter K3 ("fSqrtKy3")
151 // in the Y direction, along the wires,
152 // and derive the Mathieson parameters K2 ("fKy2") and K4 ("fKy4")
153 // in the same direction
154 fMathieson->SetSqrtKy3AndDeriveKy2Ky4(SqrtKy3);
156 //__________________________________________________________________________
157 Float_t AliMUONResponseV0::IntPH(Float_t eloss)
159 // Calculate charge from given ionization energy loss
161 nel= Int_t(eloss*1.e9/27.4);
164 for (Int_t i=1;i<=nel;i++) {
166 while(!arg) arg = gRandom->Rndm();
167 charge -= fChargeSlope*TMath::Log(arg);
172 //-------------------------------------------
173 Float_t AliMUONResponseV0::IntXY(Int_t idDE, AliMUONGeometrySegmentation* segmentation)
175 // Calculate charge on current pad according to Mathieson distribution
177 return fMathieson->IntXY(idDE, segmentation);
181 //-------------------------------------------
182 Int_t AliMUONResponseV0::DigitResponse(Int_t digit, AliMUONTransientDigit* /*where*/)
184 // FIXME : AliFatal("put the pedestal adding here!");
185 // add white noise and do zero-suppression and signal truncation
186 // Float_t meanNoise = gRandom->Gaus(1, 0.2);
187 // correct noise for slat chambers;
188 // one more field to add to AliMUONResponseV0 to allow different noises ????
189 // Float_t meanNoise = gRandom->Gaus(1., 0.2);
190 // Float_t noise = gRandom->Gaus(0., meanNoise);
191 Float_t noise = gRandom->Gaus(0., 1.0);
192 digit += TMath::Nint(noise);
193 if ( digit <= ZeroSuppression()) digit = 0;
194 // if ( digit > MaxAdc()) digit=MaxAdc();
195 if ( digit > Saturation())
203 //_____________________________________________________________________________
205 AliMUONResponseV0::GetAnod(Float_t x) const
208 // Return wire coordinate closest to x.
210 Int_t n = Int_t(x/Pitch());
211 Float_t wire = (x>0) ? n+0.5 : n-0.5;
215 //______________________________________________________________________________
217 AliMUONResponseV0::DisIntegrate(const AliMUONHit& hit, TList& digits)
225 Int_t detElemId = hit.DetElemId();
228 // Width of the integration area
230 Double_t dx = SigmaIntegration()*ChargeSpreadX();
231 Double_t dy = SigmaIntegration()*ChargeSpreadY();
233 // Use that (dx,dy) to specify the area upon which
234 // we will iterate to spread charge into.
236 Global2Local(detElemId,hit.X(),hit.Y(),hit.Z(),x,y,z);
238 TVector2 hitPosition(x,y);
239 AliMpArea area(hitPosition,TVector2(dx,dy));
242 // Get pulse height from energy loss
243 Float_t qtot = IntPH(hit.Eloss());
245 Float_t currentCorrel = TMath::Exp(gRandom->Gaus(0.0,ChargeCorrel()/2.0));
247 AliDebug(4,Form("DE=%d eloss=%e x,y,z=%e,%e,%e fCurrentCorrel=%e dx,dy=%e,%e",
248 detElemId,hit.Eloss(),hit.X(),hit.Y(),hit.Z(),
249 currentCorrel,dx,dy));
251 AliMpStationType station = AliMpDEManager::GetStationType(detElemId);
254 if ( station == kStation1 || station == kStation2 )
259 for ( Int_t cath = 0; cath < 2; ++cath )
261 Float_t qcath = qtot * ( cath == 0 ? currentCorrel : 1.0/currentCorrel);
263 AliDebug(4,Form("i=%d qtot=%e qcath=%e",cath+1,qtot,qcath));
264 // Get an iterator to loop over pads, within the given area.
265 const AliMpVSegmentation* seg =
266 Segmentation()->GetMpSegmentation(detElemId,cath);
267 AliMpVPadIterator* it = seg->CreateIterator(area);
271 AliError(Form("Could not get iterator for detElemId %d",detElemId));
275 // Start loop over pads.
277 while ( !it->IsDone() )
279 AliMpPad pad = it->CurrentItem();
280 TVector2 lowerLeft(hitPosition-pad.Position()-pad.Dimensions());
281 TVector2 upperRight(lowerLeft + pad.Dimensions()*2.0);
282 Float_t qp = TMath::Abs(fMathieson->IntXY(lowerLeft.X(),lowerLeft.Y(),
283 upperRight.X(),upperRight.Y()));
286 Int_t icharge = Int_t(qp*qcath);
288 if ( qp > fChargeThreshold )
290 AliDebug(4,Form("ix,iy=%d,%d qp=%e",
291 pad.GetIndices().GetFirst()+intOffset,
292 pad.GetIndices().GetSecond()+intOffset,
294 AliMUONDigit* d = new AliMUONDigit;
295 d->SetDetElemId(detElemId);
296 d->SetPadX(pad.GetIndices().GetFirst()+intOffset);
297 d->SetPadY(pad.GetIndices().GetSecond()+intOffset);
298 d->SetSignal(icharge);
299 d->AddPhysicsSignal(d->Signal());
301 Int_t manuId = pad.GetLocation().GetFirst();
302 Int_t manuChannel = pad.GetLocation().GetSecond();
303 AliMpPlaneType planeType = AliMpDEManager::GetPlaneType(detElemId,cath);
304 if ( planeType == kNonBendingPlane )
306 // FIXME: this should not be there, but integrated in the mapping files directly.
309 d->SetElectronics(manuId,manuChannel);