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