]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONResponseV0.cxx
switch to activate ResponseTriggerV1 from Config
[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
d19b6003 18// --------------------------
19// Class AliMUONResponseV0
20// --------------------------
21// Implementation of Mathieson response
22// ...
a9e2aefa 23
30178c30 24#include "AliMUONResponseV0.h"
885d501b 25
f29ba3e1 26#include "AliLog.h"
885d501b 27#include "AliMUON.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"
885d501b 36#include "AliMpVPadIterator.h"
37#include "AliMpVSegmentation.h"
38#include "AliRun.h"
39#include "Riostream.h"
40#include "TVector2.h"
41#include <TMath.h>
42#include <TRandom.h>
8c343c7c 43
d5bfadcc 44ClassImp(AliMUONResponseV0)
45
885d501b 46AliMUON* muon()
47{
48 return static_cast<AliMUON*>(gAlice->GetModule("MUON"));
49}
50
51void Global2Local(Int_t detElemId, Double_t xg, Double_t yg, Double_t zg,
52 Double_t& xl, Double_t& yl, Double_t& zl)
53{
54 // ideally should be :
55 // Double_t x,y,z;
56 // AliMUONGeometry::Global2Local(detElemId,xg,yg,zg,x,y,z);
57 // but while waiting for this geometry singleton, let's go through
58 // AliMUON still.
59
60 const AliMUONGeometryTransformer* transformer = muon()->GetGeometryTransformer();
61 transformer->Global2Local(detElemId,xg,yg,zg,xl,yl,zl);
62}
63
64AliMUONSegmentation* Segmentation()
65{
66 static AliMUONSegmentation* segmentation = muon()->GetSegmentation();
67 return segmentation;
68}
69
30178c30 70//__________________________________________________________________________
71AliMUONResponseV0::AliMUONResponseV0()
885d501b 72 : AliMUONResponse(),
73 fChargeSlope(0.0),
74 fChargeSpreadX(0.0),
75 fChargeSpreadY(0.0),
76 fSigmaIntegration(0.0),
77 fMaxAdc(0),
78 fZeroSuppression(0),
79 fChargeCorrel(0.0),
80 fMathieson(new AliMUONMathieson),
81 fChargeThreshold(1e-4)
30178c30 82{
885d501b 83 // Normal constructor
84 AliDebug(1,Form("Default ctor"));
30178c30 85}
f29ba3e1 86
87 //_________________________________________________________________________
88AliMUONResponseV0::AliMUONResponseV0(const AliMUONResponseV0& rhs)
89 : AliMUONResponse(rhs)
90{
91// Protected copy constructor
92
93 AliFatal("Not implemented.");
94}
95
a713db22 96 //__________________________________________________________________________
97AliMUONResponseV0::~AliMUONResponseV0()
98{
885d501b 99 AliDebug(1,"");
a713db22 100 delete fMathieson;
101}
f29ba3e1 102
103 //________________________________________________________________________
104AliMUONResponseV0& AliMUONResponseV0::operator = (const AliMUONResponseV0& rhs)
105{
106// Protected assignement operator
107
108 if (this == &rhs) return *this;
109
110 AliFatal("Not implemented.");
111
112 return *this;
885d501b 113}
114
115//______________________________________________________________________________
116void
117AliMUONResponseV0::Print(Option_t*) const
118{
d19b6003 119// Printing
120
885d501b 121 cout << " ChargeSlope=" << fChargeSlope
122 << " ChargeSpreadX,Y=" << fChargeSpreadX
123 << fChargeSpreadY
124 << " ChargeCorrelation=" << fChargeCorrel
125 << endl;
126
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
138//
139
f29ba3e1 140}
141
d5bfadcc 142 //__________________________________________________________________________
143void AliMUONResponseV0::SetSqrtKx3AndDeriveKx2Kx4(Float_t SqrtKx3)
144{
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
a713db22 149 fMathieson->SetSqrtKx3AndDeriveKx2Kx4(SqrtKx3);
d5bfadcc 150}
151
152 //__________________________________________________________________________
153void AliMUONResponseV0::SetSqrtKy3AndDeriveKy2Ky4(Float_t SqrtKy3)
154{
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
a713db22 159 fMathieson->SetSqrtKy3AndDeriveKy2Ky4(SqrtKy3);
d5bfadcc 160}
a713db22 161 //__________________________________________________________________________
85fec35d 162Float_t AliMUONResponseV0::IntPH(Float_t eloss) const
a9e2aefa 163{
164 // Calculate charge from given ionization energy loss
165 Int_t nel;
4ac9d21e 166 nel= Int_t(eloss*1.e9/27.4);
a9e2aefa 167 Float_t charge=0;
168 if (nel == 0) nel=1;
169 for (Int_t i=1;i<=nel;i++) {
01997fa2 170 Float_t arg=0.;
171 while(!arg) arg = gRandom->Rndm();
172 charge -= fChargeSlope*TMath::Log(arg);
a9e2aefa 173 }
174 return charge;
175}
a713db22 176
a713db22 177 //-------------------------------------------
85fec35d 178Float_t AliMUONResponseV0::IntXY(Int_t idDE,
179 AliMUONGeometrySegmentation* segmentation)
180const
a713db22 181{
182 // Calculate charge on current pad according to Mathieson distribution
a9e2aefa 183
a713db22 184 return fMathieson->IntXY(idDE, segmentation);
185}
885d501b 186
187
a713db22 188 //-------------------------------------------
85fec35d 189Int_t AliMUONResponseV0::DigitResponse(Int_t digit,
190 AliMUONTransientDigit* /*where*/)
191const
a9e2aefa 192{
32c9ead9 193 // \deprecated method
194 // Now part of the digitizer (where it belongs really), e.g. DigitizerV3
195 //
196 // add white noise and do zero-suppression and signal truncation
197
198 // Float_t meanNoise = gRandom->Gaus(1, 0.2);
b64652f5 199 // correct noise for slat chambers;
200 // one more field to add to AliMUONResponseV0 to allow different noises ????
885d501b 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);
104b5ac2 204 digit += TMath::Nint(noise);
ddc10e24 205 if ( digit <= ZeroSuppression()) digit = 0;
4ac9d21e 206 // if ( digit > MaxAdc()) digit=MaxAdc();
885d501b 207 if ( digit > Saturation())
208 {
209 digit=Saturation();
210 }
4ac9d21e 211
a9e2aefa 212 return digit;
213}
214
885d501b 215//_____________________________________________________________________________
216Float_t
217AliMUONResponseV0::GetAnod(Float_t x) const
218{
219 //
220 // Return wire coordinate closest to x.
221 //
222 Int_t n = Int_t(x/Pitch());
223 Float_t wire = (x>0) ? n+0.5 : n-0.5;
224 return Pitch()*wire;
225}
a9e2aefa 226
885d501b 227//______________________________________________________________________________
228void
229AliMUONResponseV0::DisIntegrate(const AliMUONHit& hit, TList& digits)
230{
231 //
32c9ead9 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.
885d501b 236 //
237
238 digits.Clear();
239
240 Int_t detElemId = hit.DetElemId();
241
885d501b 242 // Width of the integration area
885d501b 243 Double_t dx = SigmaIntegration()*ChargeSpreadX();
244 Double_t dy = SigmaIntegration()*ChargeSpreadY();
245
246 // Use that (dx,dy) to specify the area upon which
247 // we will iterate to spread charge into.
248 Double_t x,y,z;
249 Global2Local(detElemId,hit.X(),hit.Y(),hit.Z(),x,y,z);
250 x = GetAnod(x);
251 TVector2 hitPosition(x,y);
252 AliMpArea area(hitPosition,TVector2(dx,dy));
253
32c9ead9 254 // Get pulse height from energy loss.
885d501b 255 Float_t qtot = IntPH(hit.Eloss());
256
32c9ead9 257 // Get the charge correlation between cathodes.
885d501b 258 Float_t currentCorrel = TMath::Exp(gRandom->Gaus(0.0,ChargeCorrel()/2.0));
a9e2aefa 259
885d501b 260 for ( Int_t cath = 0; cath < 2; ++cath )
261 {
262 Float_t qcath = qtot * ( cath == 0 ? currentCorrel : 1.0/currentCorrel);
263
885d501b 264 // Get an iterator to loop over pads, within the given area.
32c9ead9 265 const AliMpVSegmentation* seg =
885d501b 266 Segmentation()->GetMpSegmentation(detElemId,cath);
885d501b 267
32c9ead9 268 AliMpVPadIterator* it = seg->CreateIterator(area);
269
270 if (!it)
271 {
272 AliError(Form("Could not get iterator for detElemId %d",detElemId));
273 return;
274 }
275
276 // Start loop over pads.
277 it->First();
278
279 if ( it->IsDone() )
280 {
281 // Exceptional case : iterator is built, but is invalid from the start.
282 AliMpPad pad = seg->PadByPosition(area.Position(),kFALSE);
283 if ( pad.IsValid() )
885d501b 284 {
32c9ead9 285 AliWarning(Form("Got an invalid iterator bug (area.Position() is within "
286 " DE but the iterator is void) for detElemId %d cath %d",
287 detElemId,cath));
885d501b 288 }
32c9ead9 289 else
885d501b 290 {
32c9ead9 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()));
885d501b 296 }
297 delete it;
32c9ead9 298 return;
299 }
300
301 while ( !it->IsDone() )
302 {
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()));
310
311 Int_t icharge = Int_t(qp*qcath);
312
313 if ( qp > fChargeThreshold )
314 {
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());
323 d->SetCathode(cath);
324 d->SetElectronics(pad.GetLocation().GetFirst(),
325 pad.GetLocation().GetSecond());
326 digits.Add(d);
327 }
328 it->Next();
329 }
330 delete it;
885d501b 331 }
332}
a9e2aefa 333
334
335