]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONResponseV0.cxx
Short test script with use of calibration data
[u/mrichter/AliRoot.git] / MUON / AliMUONResponseV0.cxx
CommitLineData
a9e2aefa 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
88cb7938 16/* $Id$ */
a9e2aefa 17
a9e2aefa 18
30178c30 19#include "AliMUONResponseV0.h"
885d501b 20
f29ba3e1 21#include "AliLog.h"
885d501b 22#include "AliMUON.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"
35#include "AliRun.h"
36#include "Riostream.h"
37#include "TVector2.h"
38#include <TMath.h>
39#include <TRandom.h>
8c343c7c 40
d5bfadcc 41ClassImp(AliMUONResponseV0)
42
885d501b 43AliMUON* muon()
44{
45 return static_cast<AliMUON*>(gAlice->GetModule("MUON"));
46}
47
48void Global2Local(Int_t detElemId, Double_t xg, Double_t yg, Double_t zg,
49 Double_t& xl, Double_t& yl, Double_t& zl)
50{
51 // ideally should be :
52 // Double_t x,y,z;
53 // AliMUONGeometry::Global2Local(detElemId,xg,yg,zg,x,y,z);
54 // but while waiting for this geometry singleton, let's go through
55 // AliMUON still.
56
57 const AliMUONGeometryTransformer* transformer = muon()->GetGeometryTransformer();
58 transformer->Global2Local(detElemId,xg,yg,zg,xl,yl,zl);
59}
60
61AliMUONSegmentation* Segmentation()
62{
63 static AliMUONSegmentation* segmentation = muon()->GetSegmentation();
64 return segmentation;
65}
66
30178c30 67//__________________________________________________________________________
68AliMUONResponseV0::AliMUONResponseV0()
885d501b 69 : AliMUONResponse(),
70 fChargeSlope(0.0),
71 fChargeSpreadX(0.0),
72 fChargeSpreadY(0.0),
73 fSigmaIntegration(0.0),
74 fMaxAdc(0),
75 fZeroSuppression(0),
76 fChargeCorrel(0.0),
77 fMathieson(new AliMUONMathieson),
78 fChargeThreshold(1e-4)
30178c30 79{
885d501b 80 // Normal constructor
81 AliDebug(1,Form("Default ctor"));
30178c30 82}
f29ba3e1 83
84 //_________________________________________________________________________
85AliMUONResponseV0::AliMUONResponseV0(const AliMUONResponseV0& rhs)
86 : AliMUONResponse(rhs)
87{
88// Protected copy constructor
89
90 AliFatal("Not implemented.");
91}
92
a713db22 93 //__________________________________________________________________________
94AliMUONResponseV0::~AliMUONResponseV0()
95{
885d501b 96 AliDebug(1,"");
a713db22 97 delete fMathieson;
98}
f29ba3e1 99
100 //________________________________________________________________________
101AliMUONResponseV0& AliMUONResponseV0::operator = (const AliMUONResponseV0& rhs)
102{
103// Protected assignement operator
104
105 if (this == &rhs) return *this;
106
107 AliFatal("Not implemented.");
108
109 return *this;
885d501b 110}
111
112//______________________________________________________________________________
113void
114AliMUONResponseV0::Print(Option_t*) const
115{
116 cout << " ChargeSlope=" << fChargeSlope
117 << " ChargeSpreadX,Y=" << fChargeSpreadX
118 << fChargeSpreadY
119 << " ChargeCorrelation=" << fChargeCorrel
120 << endl;
121
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
133//
134
f29ba3e1 135}
136
d5bfadcc 137 //__________________________________________________________________________
138void AliMUONResponseV0::SetSqrtKx3AndDeriveKx2Kx4(Float_t SqrtKx3)
139{
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
a713db22 144 fMathieson->SetSqrtKx3AndDeriveKx2Kx4(SqrtKx3);
d5bfadcc 145}
146
147 //__________________________________________________________________________
148void AliMUONResponseV0::SetSqrtKy3AndDeriveKy2Ky4(Float_t SqrtKy3)
149{
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
a713db22 154 fMathieson->SetSqrtKy3AndDeriveKy2Ky4(SqrtKy3);
d5bfadcc 155}
a713db22 156 //__________________________________________________________________________
a9e2aefa 157Float_t AliMUONResponseV0::IntPH(Float_t eloss)
158{
159 // Calculate charge from given ionization energy loss
160 Int_t nel;
4ac9d21e 161 nel= Int_t(eloss*1.e9/27.4);
a9e2aefa 162 Float_t charge=0;
163 if (nel == 0) nel=1;
164 for (Int_t i=1;i<=nel;i++) {
01997fa2 165 Float_t arg=0.;
166 while(!arg) arg = gRandom->Rndm();
167 charge -= fChargeSlope*TMath::Log(arg);
a9e2aefa 168 }
169 return charge;
170}
a713db22 171
a713db22 172 //-------------------------------------------
173Float_t AliMUONResponseV0::IntXY(Int_t idDE, AliMUONGeometrySegmentation* segmentation)
174{
175 // Calculate charge on current pad according to Mathieson distribution
a9e2aefa 176
a713db22 177 return fMathieson->IntXY(idDE, segmentation);
178}
885d501b 179
180
a713db22 181 //-------------------------------------------
f7b62f08 182Int_t AliMUONResponseV0::DigitResponse(Int_t digit, AliMUONTransientDigit* /*where*/)
a9e2aefa 183{
885d501b 184// FIXME : AliFatal("put the pedestal adding here!");
a9e2aefa 185 // add white noise and do zero-suppression and signal truncation
b64652f5 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 ????
885d501b 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);
104b5ac2 192 digit += TMath::Nint(noise);
ddc10e24 193 if ( digit <= ZeroSuppression()) digit = 0;
4ac9d21e 194 // if ( digit > MaxAdc()) digit=MaxAdc();
885d501b 195 if ( digit > Saturation())
196 {
197 digit=Saturation();
198 }
4ac9d21e 199
a9e2aefa 200 return digit;
201}
202
885d501b 203//_____________________________________________________________________________
204Float_t
205AliMUONResponseV0::GetAnod(Float_t x) const
206{
207 //
208 // Return wire coordinate closest to x.
209 //
210 Int_t n = Int_t(x/Pitch());
211 Float_t wire = (x>0) ? n+0.5 : n-0.5;
212 return Pitch()*wire;
213}
a9e2aefa 214
885d501b 215//______________________________________________________________________________
216void
217AliMUONResponseV0::DisIntegrate(const AliMUONHit& hit, TList& digits)
218{
219 //
220 //
221 //
222
223 digits.Clear();
224
225 Int_t detElemId = hit.DetElemId();
226
227 //
228 // Width of the integration area
229 //
230 Double_t dx = SigmaIntegration()*ChargeSpreadX();
231 Double_t dy = SigmaIntegration()*ChargeSpreadY();
232
233 // Use that (dx,dy) to specify the area upon which
234 // we will iterate to spread charge into.
235 Double_t x,y,z;
236 Global2Local(detElemId,hit.X(),hit.Y(),hit.Z(),x,y,z);
237 x = GetAnod(x);
238 TVector2 hitPosition(x,y);
239 AliMpArea area(hitPosition,TVector2(dx,dy));
240
241 //
242 // Get pulse height from energy loss
243 Float_t qtot = IntPH(hit.Eloss());
244
245 Float_t currentCorrel = TMath::Exp(gRandom->Gaus(0.0,ChargeCorrel()/2.0));
a9e2aefa 246
885d501b 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));
250
251 AliMpStationType station = AliMpDEManager::GetStationType(detElemId);
252
253 Int_t intOffset = 1;
254 if ( station == kStation1 || station == kStation2 )
255 {
256 intOffset = 0;
257 }
258
259 for ( Int_t cath = 0; cath < 2; ++cath )
260 {
261 Float_t qcath = qtot * ( cath == 0 ? currentCorrel : 1.0/currentCorrel);
262
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);
268
269 if (!it)
270 {
271 AliError(Form("Could not get iterator for detElemId %d",detElemId));
272 return;
273 }
274
275 // Start loop over pads.
276 it->First();
277 while ( !it->IsDone() )
278 {
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()));
a9e2aefa 284
285
885d501b 286 Int_t icharge = Int_t(qp*qcath);
287
288 if ( qp > fChargeThreshold )
289 {
290 AliDebug(4,Form("ix,iy=%d,%d qp=%e",
291 pad.GetIndices().GetFirst()+intOffset,
292 pad.GetIndices().GetSecond()+intOffset,
293 qp));
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());
300 d->SetCathode(cath);
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 )
305 {
306 // FIXME: this should not be there, but integrated in the mapping files directly.
307 manuId |= (1<<11);
308 }
309 d->SetElectronics(manuId,manuChannel);
310 digits.Add(d);
311 }
312 it->Next();
313 }
314 delete it;
315 }
316}
a9e2aefa 317
318
319