]>
Commit | Line | Data |
---|---|---|
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 | // -------------------------- | |
9265505b | 21 | // Implementation of |
22 | // Mathieson response | |
a9e2aefa | 23 | |
30178c30 | 24 | #include "AliMUONResponseV0.h" |
885d501b | 25 | #include "AliMUON.h" |
26 | #include "AliMUONConstants.h" | |
27 | #include "AliMUONDigit.h" | |
28 | #include "AliMUONGeometrySegmentation.h" | |
29 | #include "AliMUONGeometryTransformer.h" | |
30 | #include "AliMUONHit.h" | |
31 | #include "AliMUONSegmentation.h" | |
9265505b | 32 | |
885d501b | 33 | #include "AliMpArea.h" |
34 | #include "AliMpDEManager.h" | |
885d501b | 35 | #include "AliMpVPadIterator.h" |
9265505b | 36 | #include "AliMpSegmentation.h" |
885d501b | 37 | #include "AliMpVSegmentation.h" |
9265505b | 38 | |
885d501b | 39 | #include "AliRun.h" |
9265505b | 40 | #include "AliLog.h" |
41 | ||
885d501b | 42 | #include "Riostream.h" |
43 | #include "TVector2.h" | |
44 | #include <TMath.h> | |
45 | #include <TRandom.h> | |
8c343c7c | 46 | |
9265505b | 47 | /// \cond CLASSIMP |
d5bfadcc | 48 | ClassImp(AliMUONResponseV0) |
9265505b | 49 | /// \endcond |
d5bfadcc | 50 | |
885d501b | 51 | AliMUON* muon() |
52 | { | |
53 | return static_cast<AliMUON*>(gAlice->GetModule("MUON")); | |
54 | } | |
55 | ||
56 | void Global2Local(Int_t detElemId, Double_t xg, Double_t yg, Double_t zg, | |
57 | Double_t& xl, Double_t& yl, Double_t& zl) | |
58 | { | |
9265505b | 59 | /// ideally should be : |
60 | /// Double_t x,y,z; | |
61 | /// AliMUONGeometry::Global2Local(detElemId,xg,yg,zg,x,y,z); | |
62 | /// but while waiting for this geometry singleton, let's go through | |
63 | /// AliMUON still. | |
885d501b | 64 | |
65 | const AliMUONGeometryTransformer* transformer = muon()->GetGeometryTransformer(); | |
66 | transformer->Global2Local(detElemId,xg,yg,zg,xl,yl,zl); | |
67 | } | |
68 | ||
69 | AliMUONSegmentation* Segmentation() | |
70 | { | |
71 | static AliMUONSegmentation* segmentation = muon()->GetSegmentation(); | |
72 | return segmentation; | |
73 | } | |
74 | ||
30178c30 | 75 | //__________________________________________________________________________ |
76 | AliMUONResponseV0::AliMUONResponseV0() | |
885d501b | 77 | : AliMUONResponse(), |
78 | fChargeSlope(0.0), | |
79 | fChargeSpreadX(0.0), | |
80 | fChargeSpreadY(0.0), | |
81 | fSigmaIntegration(0.0), | |
82 | fMaxAdc(0), | |
ccea41d4 | 83 | fSaturation(0), |
885d501b | 84 | fZeroSuppression(0), |
85 | fChargeCorrel(0.0), | |
86 | fMathieson(new AliMUONMathieson), | |
87 | fChargeThreshold(1e-4) | |
30178c30 | 88 | { |
9265505b | 89 | /// Normal constructor |
885d501b | 90 | AliDebug(1,Form("Default ctor")); |
30178c30 | 91 | } |
f29ba3e1 | 92 | |
ccea41d4 | 93 | //__________________________________________________________________________ |
a713db22 | 94 | AliMUONResponseV0::~AliMUONResponseV0() |
95 | { | |
9265505b | 96 | /// Destructor |
97 | ||
885d501b | 98 | AliDebug(1,""); |
a713db22 | 99 | delete fMathieson; |
100 | } | |
f29ba3e1 | 101 | |
885d501b | 102 | //______________________________________________________________________________ |
103 | void | |
104 | AliMUONResponseV0::Print(Option_t*) const | |
105 | { | |
9265505b | 106 | /// Printing |
d19b6003 | 107 | |
885d501b | 108 | cout << " ChargeSlope=" << fChargeSlope |
109 | << " ChargeSpreadX,Y=" << fChargeSpreadX | |
110 | << fChargeSpreadY | |
111 | << " ChargeCorrelation=" << fChargeCorrel | |
112 | << endl; | |
f29ba3e1 | 113 | } |
114 | ||
d5bfadcc | 115 | //__________________________________________________________________________ |
116 | void AliMUONResponseV0::SetSqrtKx3AndDeriveKx2Kx4(Float_t SqrtKx3) | |
117 | { | |
9265505b | 118 | /// Set to "SqrtKx3" the Mathieson parameter K3 ("fSqrtKx3") |
119 | /// in the X direction, perpendicular to the wires, | |
120 | /// and derive the Mathieson parameters K2 ("fKx2") and K4 ("fKx4") | |
121 | /// in the same direction | |
a713db22 | 122 | fMathieson->SetSqrtKx3AndDeriveKx2Kx4(SqrtKx3); |
d5bfadcc | 123 | } |
124 | ||
125 | //__________________________________________________________________________ | |
126 | void AliMUONResponseV0::SetSqrtKy3AndDeriveKy2Ky4(Float_t SqrtKy3) | |
127 | { | |
9265505b | 128 | /// Set to "SqrtKy3" the Mathieson parameter K3 ("fSqrtKy3") |
129 | /// in the Y direction, along the wires, | |
130 | /// and derive the Mathieson parameters K2 ("fKy2") and K4 ("fKy4") | |
131 | /// in the same direction | |
a713db22 | 132 | fMathieson->SetSqrtKy3AndDeriveKy2Ky4(SqrtKy3); |
d5bfadcc | 133 | } |
a713db22 | 134 | //__________________________________________________________________________ |
85fec35d | 135 | Float_t AliMUONResponseV0::IntPH(Float_t eloss) const |
a9e2aefa | 136 | { |
9265505b | 137 | /// Calculate charge from given ionization energy loss |
a9e2aefa | 138 | Int_t nel; |
4ac9d21e | 139 | nel= Int_t(eloss*1.e9/27.4); |
a9e2aefa | 140 | Float_t charge=0; |
141 | if (nel == 0) nel=1; | |
142 | for (Int_t i=1;i<=nel;i++) { | |
01997fa2 | 143 | Float_t arg=0.; |
144 | while(!arg) arg = gRandom->Rndm(); | |
145 | charge -= fChargeSlope*TMath::Log(arg); | |
a9e2aefa | 146 | } |
147 | return charge; | |
148 | } | |
a713db22 | 149 | |
a713db22 | 150 | //------------------------------------------- |
85fec35d | 151 | Float_t AliMUONResponseV0::IntXY(Int_t idDE, |
152 | AliMUONGeometrySegmentation* segmentation) | |
153 | const | |
a713db22 | 154 | { |
9265505b | 155 | /// Calculate charge on current pad according to Mathieson distribution |
a9e2aefa | 156 | |
a713db22 | 157 | return fMathieson->IntXY(idDE, segmentation); |
158 | } | |
885d501b | 159 | |
160 | ||
885d501b | 161 | //_____________________________________________________________________________ |
162 | Float_t | |
163 | AliMUONResponseV0::GetAnod(Float_t x) const | |
164 | { | |
9265505b | 165 | /// Return wire coordinate closest to x. |
166 | ||
885d501b | 167 | Int_t n = Int_t(x/Pitch()); |
168 | Float_t wire = (x>0) ? n+0.5 : n-0.5; | |
169 | return Pitch()*wire; | |
170 | } | |
a9e2aefa | 171 | |
885d501b | 172 | //______________________________________________________________________________ |
173 | void | |
174 | AliMUONResponseV0::DisIntegrate(const AliMUONHit& hit, TList& digits) | |
175 | { | |
9265505b | 176 | /// Go from 1 hit to a list of digits. |
177 | /// The energy deposition of that hit is first converted into charge | |
178 | /// (in IntPH() method), and then this charge is dispatched on several | |
179 | /// pads, according to the Mathieson distribution. | |
885d501b | 180 | |
181 | digits.Clear(); | |
182 | ||
183 | Int_t detElemId = hit.DetElemId(); | |
184 | ||
885d501b | 185 | // Width of the integration area |
885d501b | 186 | Double_t dx = SigmaIntegration()*ChargeSpreadX(); |
187 | Double_t dy = SigmaIntegration()*ChargeSpreadY(); | |
188 | ||
189 | // Use that (dx,dy) to specify the area upon which | |
190 | // we will iterate to spread charge into. | |
191 | Double_t x,y,z; | |
192 | Global2Local(detElemId,hit.X(),hit.Y(),hit.Z(),x,y,z); | |
193 | x = GetAnod(x); | |
194 | TVector2 hitPosition(x,y); | |
195 | AliMpArea area(hitPosition,TVector2(dx,dy)); | |
196 | ||
32c9ead9 | 197 | // Get pulse height from energy loss. |
885d501b | 198 | Float_t qtot = IntPH(hit.Eloss()); |
199 | ||
32c9ead9 | 200 | // Get the charge correlation between cathodes. |
885d501b | 201 | Float_t currentCorrel = TMath::Exp(gRandom->Gaus(0.0,ChargeCorrel()/2.0)); |
a9e2aefa | 202 | |
885d501b | 203 | for ( Int_t cath = 0; cath < 2; ++cath ) |
204 | { | |
205 | Float_t qcath = qtot * ( cath == 0 ? currentCorrel : 1.0/currentCorrel); | |
206 | ||
885d501b | 207 | // Get an iterator to loop over pads, within the given area. |
32c9ead9 | 208 | const AliMpVSegmentation* seg = |
9265505b | 209 | AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,cath); |
885d501b | 210 | |
32c9ead9 | 211 | AliMpVPadIterator* it = seg->CreateIterator(area); |
212 | ||
213 | if (!it) | |
214 | { | |
215 | AliError(Form("Could not get iterator for detElemId %d",detElemId)); | |
216 | return; | |
217 | } | |
218 | ||
219 | // Start loop over pads. | |
220 | it->First(); | |
221 | ||
222 | if ( it->IsDone() ) | |
223 | { | |
224 | // Exceptional case : iterator is built, but is invalid from the start. | |
225 | AliMpPad pad = seg->PadByPosition(area.Position(),kFALSE); | |
226 | if ( pad.IsValid() ) | |
885d501b | 227 | { |
32c9ead9 | 228 | AliWarning(Form("Got an invalid iterator bug (area.Position() is within " |
229 | " DE but the iterator is void) for detElemId %d cath %d", | |
230 | detElemId,cath)); | |
885d501b | 231 | } |
32c9ead9 | 232 | else |
885d501b | 233 | { |
32c9ead9 | 234 | AliError(Form("Got an invalid iterator bug for detElemId %d cath %d." |
235 | "Might be a bad hit ? area.Position()=(%e,%e) " | |
236 | "Dimensions()=(%e,%e)", | |
237 | detElemId,cath,area.Position().X(),area.Position().Y(), | |
238 | area.Dimensions().X(),area.Dimensions().Y())); | |
885d501b | 239 | } |
240 | delete it; | |
32c9ead9 | 241 | return; |
242 | } | |
243 | ||
244 | while ( !it->IsDone() ) | |
245 | { | |
246 | // For each pad given by the iterator, compute the charge of that | |
247 | // pad, according to the Mathieson distribution. | |
248 | AliMpPad pad = it->CurrentItem(); | |
249 | TVector2 lowerLeft(hitPosition-pad.Position()-pad.Dimensions()); | |
250 | TVector2 upperRight(lowerLeft + pad.Dimensions()*2.0); | |
251 | Float_t qp = TMath::Abs(fMathieson->IntXY(lowerLeft.X(),lowerLeft.Y(), | |
252 | upperRight.X(),upperRight.Y())); | |
253 | ||
254 | Int_t icharge = Int_t(qp*qcath); | |
255 | ||
256 | if ( qp > fChargeThreshold ) | |
257 | { | |
258 | // If we're above threshold, then we create a digit, | |
259 | // and fill it with relevant information, including electronics. | |
260 | AliMUONDigit* d = new AliMUONDigit; | |
261 | d->SetDetElemId(detElemId); | |
262 | d->SetPadX(pad.GetIndices().GetFirst()); | |
263 | d->SetPadY(pad.GetIndices().GetSecond()); | |
264 | d->SetSignal(icharge); | |
265 | d->AddPhysicsSignal(d->Signal()); | |
266 | d->SetCathode(cath); | |
267 | d->SetElectronics(pad.GetLocation().GetFirst(), | |
268 | pad.GetLocation().GetSecond()); | |
269 | digits.Add(d); | |
270 | } | |
271 | it->Next(); | |
272 | } | |
273 | delete it; | |
885d501b | 274 | } |
275 | } | |
a9e2aefa | 276 | |
277 | ||
278 |