]>
Commit | Line | Data |
---|---|---|
02a27b50 | 1 | /************************************************************************** |
2 | * Copyright(c) 2004, 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 | /* $Id$ */ | |
16 | /** @file AliFMDBaseDigitizer.cxx | |
17 | @author Christian Holm Christensen <cholm@nbi.dk> | |
18 | @date Mon Mar 27 12:38:26 2006 | |
19 | @brief FMD Digitizers implementation | |
20 | @ingroup FMD_sim | |
21 | */ | |
22 | ////////////////////////////////////////////////////////////////////////////// | |
23 | // | |
24 | // This class contains the procedures simulation ADC signal for the | |
25 | // Forward Multiplicity detector : Hits->Digits and Hits->SDigits | |
26 | // | |
27 | // Digits consists of | |
28 | // - Detector # | |
29 | // - Ring ID | |
30 | // - Sector # | |
31 | // - Strip # | |
32 | // - ADC count in this channel | |
33 | // | |
34 | // Digits consists of | |
35 | // - Detector # | |
36 | // - Ring ID | |
37 | // - Sector # | |
38 | // - Strip # | |
39 | // - Total energy deposited in the strip | |
40 | // - ADC count in this channel | |
41 | // | |
42 | // As the Digits and SDigits have so much in common, the classes | |
43 | // AliFMDDigitizer and AliFMDSDigitizer are implemented via a base | |
44 | // class AliFMDBaseDigitizer. | |
45 | // | |
46 | // +---------------------+ | |
47 | // | AliFMDBaseDigitizer | | |
48 | // +---------------------+ | |
49 | // ^ | |
50 | // | | |
51 | // +----------+---------+ | |
52 | // | | | |
53 | // +-----------------+ +------------------+ | |
54 | // | AliFMDDigitizer | | AliFMDSDigitizer | | |
55 | // +-----------------+ +------------------+ | |
56 | // | |
57 | // These classes has several paramters: | |
58 | // | |
59 | // fPedestal | |
60 | // fPedestalWidth | |
61 | // (Only AliFMDDigitizer) | |
62 | // Mean and width of the pedestal. The pedestal is simulated | |
63 | // by a Guassian, but derived classes my override MakePedestal | |
64 | // to simulate it differently (or pick it up from a database). | |
65 | // | |
66 | // fVA1MipRange | |
67 | // The dymamic MIP range of the VA1_ALICE pre-amplifier chip | |
68 | // | |
69 | // fAltroChannelSize | |
70 | // The largest number plus one that can be stored in one | |
71 | // channel in one time step in the ALTRO ADC chip. | |
72 | // | |
73 | // fSampleRate | |
74 | // How many times the ALTRO ADC chip samples the VA1_ALICE | |
75 | // pre-amplifier signal. The VA1_ALICE chip is read-out at | |
76 | // 10MHz, while it's possible to drive the ALTRO chip at | |
77 | // 25MHz. That means, that the ALTRO chip can have time to | |
78 | // sample each VA1_ALICE signal up to 2 times. Although it's | |
79 | // not certain this feature will be used in the production, | |
80 | // we'd like have the option, and so it should be reflected in | |
81 | // the code. | |
82 | // | |
83 | // | |
84 | // The shaping function of the VA1_ALICE is generally given by | |
85 | // | |
86 | // f(x) = A(1 - exp(-Bx)) | |
87 | // | |
88 | // where A is the total charge collected in the pre-amp., and B is a | |
89 | // paramter that depends on the shaping time of the VA1_ALICE circut. | |
90 | // | |
91 | // When simulating the shaping function of the VA1_ALICe | |
92 | // pre-amp. chip, we have to take into account, that the shaping | |
93 | // function depends on the previous value of read from the pre-amp. | |
94 | // | |
95 | // That results in the following algorithm: | |
96 | // | |
97 | // last = 0; | |
98 | // FOR charge IN pre-amp. charge train DO | |
99 | // IF last < charge THEN | |
100 | // f(t) = (charge - last) * (1 - exp(-B * t)) + last | |
101 | // ELSE | |
102 | // f(t) = (last - charge) * exp(-B * t) + charge) | |
103 | // ENDIF | |
104 | // FOR i IN # samples DO | |
105 | // adc_i = f(i / (# samples)) | |
106 | // DONE | |
107 | // last = charge | |
108 | // DONE | |
109 | // | |
110 | // Here, | |
111 | // | |
112 | // pre-amp. charge train | |
113 | // is a series of 128 charges read from the VA1_ALICE chip | |
114 | // | |
115 | // # samples | |
116 | // is the number of times the ALTRO ADC samples each of the 128 | |
117 | // charges from the pre-amp. | |
118 | // | |
119 | // Where Q is the total charge collected by the VA1_ALICE | |
120 | // pre-amplifier. Q is then given by | |
121 | // | |
122 | // E S | |
123 | // Q = - - | |
124 | // e R | |
125 | // | |
126 | // where E is the total energy deposited in a silicon strip, R is the | |
127 | // dynamic range of the VA1_ALICE pre-amp (fVA1MipRange), e is the | |
128 | // energy deposited by a single MIP, and S ALTRO channel size in each | |
129 | // time step (fAltroChannelSize). | |
130 | // | |
131 | // The energy deposited per MIP is given by | |
132 | // | |
133 | // e = M * rho * w | |
134 | // | |
135 | // where M is the universal number 1.664, rho is the density of | |
136 | // silicon, and w is the depth of the silicon sensor. | |
137 | // | |
138 | // The final ADC count is given by | |
139 | // | |
140 | // C' = C + P | |
141 | // | |
142 | // where P is the (randomized) pedestal (see MakePedestal) | |
143 | // | |
144 | // This class uses the class template AliFMDMap<Type> to make an | |
145 | // internal cache of the energy deposted of the hits. The class | |
146 | // template is instantasized as | |
147 | // | |
148 | // typedef AliFMDMap<std::pair<Float_t, UShort_t> > AliFMDEdepMap; | |
149 | // | |
150 | // The first member of the values is the summed energy deposition in a | |
151 | // given strip, while the second member of the values is the number of | |
152 | // hits in a given strip. Using the second member, it's possible to | |
153 | // do some checks on just how many times a strip got hit, and what | |
154 | // kind of error we get in our reconstructed hits. Note, that this | |
155 | // information is currently not written to the digits tree. I think a | |
156 | // QA (Quality Assurance) digit tree is better suited for that task. | |
157 | // However, the information is there to be used in the future. | |
158 | // | |
159 | // | |
160 | // Latest changes by Christian Holm Christensen | |
161 | // | |
162 | ////////////////////////////////////////////////////////////////////////////// | |
163 | ||
164 | // /1 | |
165 | // | A(-1 + B + exp(-B)) | |
166 | // | f(x) dx = ------------------- = 1 | |
167 | // | B | |
168 | // / 0 | |
169 | // | |
170 | // and B is the a parameter defined by the shaping time (fShapingTime). | |
171 | // | |
172 | // Solving the above equation, for A gives | |
173 | // | |
174 | // B | |
175 | // A = ---------------- | |
176 | // -1 + B + exp(-B) | |
177 | // | |
178 | // So, if we define the function g: [0,1] -> [0:1] by | |
179 | // | |
180 | // / v | |
181 | // | Bu + exp(-Bu) - Bv - exp(-Bv) | |
182 | // g(u,v) = | f(x) dx = -A ----------------------------- | |
183 | // | B | |
184 | // / u | |
185 | // | |
186 | // we can evaluate the ALTRO sample of the VA1_ALICE pre-amp between | |
187 | // any two times (u, v), by | |
188 | // | |
189 | // | |
190 | // B Bu + exp(-Bu) - Bv - exp(-Bv) | |
191 | // C = Q g(u,v) = - Q ---------------- ----------------------------- | |
192 | // -1 + B + exp(-B) B | |
193 | // | |
194 | // Bu + exp(-Bu) - Bv - exp(-Bv) | |
195 | // = - Q ----------------------------- | |
196 | // -1 + B + exp(-B) | |
197 | // | |
198 | ||
090026bf | 199 | #include <TMath.h> |
02a27b50 | 200 | #include <TTree.h> // ROOT_TTree |
201 | //#include <TRandom.h> // ROOT_TRandom | |
f95a63c4 | 202 | // #include <AliLog.h> // ALILOG_H |
203 | #include "AliFMDDebug.h" // Better debug macros | |
02a27b50 | 204 | #include "AliFMDBaseDigitizer.h" // ALIFMDDIGITIZER_H |
205 | #include "AliFMD.h" // ALIFMD_H | |
206 | #include "AliFMDGeometry.h" // ALIFMDGEOMETRY_H | |
207 | #include "AliFMDDetector.h" // ALIFMDDETECTOR_H | |
208 | #include "AliFMDRing.h" // ALIFMDRING_H | |
209 | #include "AliFMDHit.h" // ALIFMDHIT_H | |
6169f936 | 210 | // #include "AliFMDDigit.h" // ALIFMDDIGIT_H |
02a27b50 | 211 | #include "AliFMDParameters.h" // ALIFMDPARAMETERS_H |
6169f936 | 212 | // #include <AliRunDigitizer.h> // ALIRUNDIGITIZER_H |
02a27b50 | 213 | //#include <AliRun.h> // ALIRUN_H |
214 | #include <AliLoader.h> // ALILOADER_H | |
42f1b2f5 | 215 | #include <AliRun.h> // ALILOADER_H |
02a27b50 | 216 | #include <AliRunLoader.h> // ALIRUNLOADER_H |
ef8e8623 | 217 | #include <TRandom.h> |
02a27b50 | 218 | |
219 | //==================================================================== | |
220 | ClassImp(AliFMDBaseDigitizer) | |
221 | #if 0 | |
222 | ; // This is here to keep Emacs for indenting the next line | |
223 | #endif | |
224 | ||
225 | //____________________________________________________________________ | |
226 | AliFMDBaseDigitizer::AliFMDBaseDigitizer() | |
ef8e8623 | 227 | : fFMD(0), |
228 | fRunLoader(0), | |
b5ee4425 | 229 | fEdep(AliFMDMap::kMaxDetectors, |
230 | AliFMDMap::kMaxRings, | |
231 | AliFMDMap::kMaxSectors, | |
232 | AliFMDMap::kMaxStrips), | |
b2e6f0b0 | 233 | fShapingTime(6), |
2180cab3 | 234 | fStoreTrackRefs(kTRUE), |
235 | fIgnoredLabels(0) | |
02a27b50 | 236 | { |
42f1b2f5 | 237 | AliFMDDebug(1, ("Constructed")); |
02a27b50 | 238 | // Default ctor - don't use it |
239 | } | |
240 | ||
241 | //____________________________________________________________________ | |
242 | AliFMDBaseDigitizer::AliFMDBaseDigitizer(AliRunDigitizer* manager) | |
243 | : AliDigitizer(manager, "AliFMDBaseDigitizer", "FMD Digitizer base class"), | |
ef8e8623 | 244 | fFMD(0), |
02a27b50 | 245 | fRunLoader(0), |
021f1396 | 246 | fEdep(0), // nDet==0 means 51200 slots |
b2e6f0b0 | 247 | fShapingTime(6), |
2180cab3 | 248 | fStoreTrackRefs(kTRUE), |
249 | fIgnoredLabels(0) | |
02a27b50 | 250 | { |
251 | // Normal CTOR | |
42f1b2f5 | 252 | AliFMDDebug(1, ("Constructed")); |
02a27b50 | 253 | SetShapingTime(); |
254 | } | |
255 | ||
256 | //____________________________________________________________________ | |
257 | AliFMDBaseDigitizer::AliFMDBaseDigitizer(const Char_t* name, | |
258 | const Char_t* title) | |
259 | : AliDigitizer(name, title), | |
ef8e8623 | 260 | fFMD(0), |
02a27b50 | 261 | fRunLoader(0), |
021f1396 | 262 | fEdep(0), // nDet==0 means 51200 slots |
b2e6f0b0 | 263 | fShapingTime(6), |
2180cab3 | 264 | fStoreTrackRefs(kTRUE), |
265 | fIgnoredLabels(0) | |
02a27b50 | 266 | { |
267 | // Normal CTOR | |
42f1b2f5 | 268 | AliFMDDebug(1, (" Constructed")); |
02a27b50 | 269 | SetShapingTime(); |
270 | } | |
271 | ||
272 | //____________________________________________________________________ | |
273 | AliFMDBaseDigitizer::~AliFMDBaseDigitizer() | |
274 | { | |
275 | // Destructor | |
276 | } | |
277 | ||
278 | //____________________________________________________________________ | |
279 | Bool_t | |
280 | AliFMDBaseDigitizer::Init() | |
281 | { | |
ef8e8623 | 282 | // Initialization. Get a pointer to the parameter manager, and |
283 | // initialize it. | |
02a27b50 | 284 | AliFMDParameters::Instance()->Init(); |
ef8e8623 | 285 | if (AliLog::GetDebugLevel("FMD","") >= 15) |
286 | AliFMDParameters::Instance()->Print(""); | |
42f1b2f5 | 287 | return kTRUE; |
288 | } | |
289 | ||
02a27b50 | 290 | //____________________________________________________________________ |
291 | UShort_t | |
ef8e8623 | 292 | AliFMDBaseDigitizer::MakePedestal(UShort_t detector, |
293 | Char_t ring, | |
294 | UShort_t sector, | |
295 | UShort_t strip) const | |
02a27b50 | 296 | { |
ef8e8623 | 297 | // Make a pedestal. The pedestal value is drawn from a Gaussian |
298 | // distribution. The mean of the distribution is the measured | |
299 | // pedestal, and the width is the measured noise. | |
300 | AliFMDParameters* param =AliFMDParameters::Instance(); | |
301 | Float_t mean =param->GetPedestal(detector,ring,sector,strip); | |
302 | Float_t width =param->GetPedestalWidth(detector,ring,sector,strip); | |
303 | return UShort_t(TMath::Max(gRandom->Gaus(mean, width), 0.)); | |
02a27b50 | 304 | } |
305 | ||
306 | //____________________________________________________________________ | |
307 | void | |
ef8e8623 | 308 | AliFMDBaseDigitizer::AddContribution(UShort_t detector, |
309 | Char_t ring, | |
310 | UShort_t sector, | |
311 | UShort_t strip, | |
83ad576a | 312 | Float_t edep, |
b2e6f0b0 | 313 | Bool_t isPrimary, |
faf80567 | 314 | Int_t nTrack, |
315 | Int_t* tracknos) | |
02a27b50 | 316 | { |
ef8e8623 | 317 | // Add edep contribution from (detector,ring,sector,strip) to cache |
318 | AliFMDParameters* param = AliFMDParameters::Instance(); | |
8d00dfa3 | 319 | AliFMDDebug(10, ("Adding contribution %7.5f for FMD%d%c[%2d,%3d] " |
320 | " from %d tracks (%s)", | |
321 | edep, | |
322 | detector, | |
323 | ring, | |
324 | sector, | |
325 | strip, | |
326 | nTrack, | |
327 | (isPrimary ? "primary" : "secondary"))); | |
ef8e8623 | 328 | // Check if strip is `dead' |
329 | if (param->IsDead(detector, ring, sector, strip)) { | |
330 | AliFMDDebug(5, ("FMD%d%c[%2d,%3d] is marked as dead", | |
331 | detector, ring, sector, strip)); | |
332 | return; | |
02a27b50 | 333 | } |
ef8e8623 | 334 | // Check if strip is out-side read-out range |
335 | // if (strip < minstrip || strip > maxstrip) { | |
336 | // AliFMDDebug(5, ("FMD%d%c[%2d,%3d] is outside range [%3d,%3d]", | |
337 | // detector,ring,sector,strip,minstrip,maxstrip)); | |
338 | // continue; | |
339 | // } | |
02a27b50 | 340 | |
b2e6f0b0 | 341 | AliFMDEdepHitPair& entry = fEdep(detector, ring, sector, strip); |
342 | ||
ef8e8623 | 343 | // Give warning in case of double sdigit |
b2e6f0b0 | 344 | if (entry.fEdep != 0) |
345 | AliFMDDebug(5, ("Double digit in FMD%d%c[%2d,%3d]", | |
ef8e8623 | 346 | detector, ring, sector, strip)); |
02a27b50 | 347 | |
ef8e8623 | 348 | // Sum energy deposition |
8d00dfa3 | 349 | Int_t oldN = entry.fN; |
b2e6f0b0 | 350 | entry.fEdep += edep; |
faf80567 | 351 | entry.fN += nTrack; |
352 | if (isPrimary) entry.fNPrim += nTrack; | |
b2e6f0b0 | 353 | if (fStoreTrackRefs) { |
8d00dfa3 | 354 | if (entry.fLabels.fN < entry.fN) { |
355 | AliFMDDebug(15, ("== New label array size %d, was %d, added %d", | |
356 | entry.fN, entry.fLabels.fN, nTrack)); | |
357 | entry.fLabels.Set(entry.fN); | |
358 | } | |
359 | for (Int_t i = 0; i < nTrack; i++) { | |
360 | AliFMDDebug(15, ("=> Setting track label # %d", oldN+i)); | |
faf80567 | 361 | entry.fLabels[oldN + i] = tracknos[i]; |
8d00dfa3 | 362 | AliFMDDebug(15, ("<= Setting track label # %d", oldN+i)); |
363 | } | |
b2e6f0b0 | 364 | } |
8d00dfa3 | 365 | AliFMDDebug(15,("Adding contribution %f to FMD%d%c[%2d,%3d] (%f) track %d", |
366 | edep, detector, ring, sector, strip, | |
367 | entry.fEdep, (nTrack > 0 ? tracknos[0] : -1))); | |
83ad576a | 368 | |
02a27b50 | 369 | } |
370 | ||
371 | //____________________________________________________________________ | |
372 | void | |
ef8e8623 | 373 | AliFMDBaseDigitizer::DigitizeHits() const |
02a27b50 | 374 | { |
375 | // For the stored energy contributions in the cache (fEdep), convert | |
376 | // the energy signal to ADC counts, and store the created digit in | |
377 | // the digits array (AliFMD::fDigits) | |
378 | // | |
42f1b2f5 | 379 | AliFMDDebug(5, ("Will now digitize all the summed signals")); |
2180cab3 | 380 | fIgnoredLabels = 0; |
02a27b50 | 381 | AliFMDGeometry* geometry = AliFMDGeometry::Instance(); |
382 | ||
2aeec17d | 383 | TArrayI counts(4); |
02a27b50 | 384 | for (UShort_t detector=1; detector <= 3; detector++) { |
ef8e8623 | 385 | AliFMDDebug(10, ("Processing hits in FMD%d", detector)); |
02a27b50 | 386 | // Get pointer to subdetector |
387 | AliFMDDetector* det = geometry->GetDetector(detector); | |
388 | if (!det) continue; | |
389 | for (UShort_t ringi = 0; ringi <= 1; ringi++) { | |
390 | Char_t ring = ringi == 0 ? 'I' : 'O'; | |
ef8e8623 | 391 | AliFMDDebug(10, (" Processing hits in FMD%d%c", detector,ring)); |
02a27b50 | 392 | // Get pointer to Ring |
393 | AliFMDRing* r = det->GetRing(ring); | |
394 | if (!r) continue; | |
395 | ||
396 | // Get number of sectors | |
397 | UShort_t nSectors = UShort_t(360. / r->GetTheta()); | |
398 | // Loop over the number of sectors | |
399 | for (UShort_t sector = 0; sector < nSectors; sector++) { | |
ef8e8623 | 400 | AliFMDDebug(10, (" Processing hits in FMD%d%c[%2d]", |
f95a63c4 | 401 | detector,ring,sector)); |
02a27b50 | 402 | // Get number of strips |
403 | UShort_t nStrips = r->GetNStrips(); | |
404 | // Loop over the stips | |
405 | Float_t last = 0; | |
406 | for (UShort_t strip = 0; strip < nStrips; strip++) { | |
407 | // Reset the counter array to the invalid value -1 | |
408 | counts.Reset(-1); | |
409 | // Reset the last `ADC' value when we've get to the end of a | |
410 | // VA1_ALICE channel. | |
411 | if (strip % 128 == 0) last = 0; | |
412 | ||
b2e6f0b0 | 413 | const AliFMDEdepHitPair& entry = fEdep(detector,ring,sector,strip); |
414 | Float_t edep = entry.fEdep; | |
415 | UShort_t ntot = entry.fN; | |
416 | UShort_t nprim = entry.fNPrim; | |
417 | const TArrayI& labels = entry.fLabels; | |
83ad576a | 418 | if (edep > 0) |
419 | AliFMDDebug(15, ("Edep = %f for FMD%d%c[%2d,%3d]", | |
420 | edep, detector, ring, sector, strip)); | |
02a27b50 | 421 | ConvertToCount(edep, last, detector, ring, sector, strip, counts); |
422 | last = edep; | |
8b26caab | 423 | |
83ad576a | 424 | |
8b26caab | 425 | // The following line was introduced - wrongly - by Peter |
426 | // Hristov. It _will_ break the digitisation and the | |
427 | // following reconstruction. The behviour of the | |
428 | // digitisation models exactly the front-end as it should | |
429 | // (no matter what memory concuption it may entail). The | |
430 | // check should be on zero suppression, since that's what | |
431 | // models the front-end - if zero suppression is turned on | |
432 | // in the front-end, then we can suppress empty digits - | |
433 | // otherwise we shoud never do that. Note, that the line | |
434 | // affects _both_ normal digitisation and digitisation for | |
435 | // summable digits, since the condition is on the energy | |
436 | // deposition and not on the actual number of counts. If | |
437 | // this line should go anywhere, it should be in the | |
438 | // possible overloaded AliFMDSDigitizer::AddDigit - not | |
439 | // here. | |
440 | // | |
441 | // if (edep<=0) continue; | |
ef8e8623 | 442 | AddDigit(detector, ring, sector, strip, edep, |
02a27b50 | 443 | UShort_t(counts[0]), Short_t(counts[1]), |
83ad576a | 444 | Short_t(counts[2]), Short_t(counts[3]), |
b2e6f0b0 | 445 | ntot, nprim, labels); |
ef8e8623 | 446 | AliFMDDebug(15, (" Adding digit in FMD%d%c[%2d,%3d]=%d", |
faf80567 | 447 | detector,ring,sector,strip,counts[0])); |
02a27b50 | 448 | #if 0 |
449 | // This checks if the digit created will give the `right' | |
450 | // number of particles when reconstructed, using a naiive | |
451 | // approach. It's here only as a quality check - nothing | |
452 | // else. | |
453 | CheckDigit(digit, fEdep(detector, ring, sector, strip).fN, | |
454 | counts); | |
455 | #endif | |
456 | } // Strip | |
457 | } // Sector | |
458 | } // Ring | |
459 | } // Detector | |
2180cab3 | 460 | if (fIgnoredLabels > 0) |
461 | AliWarning(Form("%d track labels could not be associated with digits " | |
462 | "due to limited storage facilities in AliDigit", | |
463 | fIgnoredLabels)); | |
02a27b50 | 464 | } |
465 | ||
466 | //____________________________________________________________________ | |
467 | void | |
468 | AliFMDBaseDigitizer::ConvertToCount(Float_t edep, | |
469 | Float_t last, | |
470 | UShort_t detector, | |
471 | Char_t ring, | |
472 | UShort_t sector, | |
473 | UShort_t strip, | |
474 | TArrayI& counts) const | |
475 | { | |
476 | // Convert the total energy deposited to a (set of) ADC count(s). | |
477 | // | |
478 | // This is done by | |
479 | // | |
480 | // Energy_Deposited ALTRO_Channel_Size | |
481 | // ADC = -------------------------- ------------------- + pedestal | |
482 | // Energy_Deposition_Of_1_MIP VA1_ALICE_MIP_Range | |
483 | // | |
484 | // Energy_Deposited fAltroChannelSize | |
485 | // = --------------------------------- ----------------- + pedestal | |
486 | // 1.664 * Si_Thickness * Si_Density fVA1MipRange | |
487 | // | |
488 | // | |
489 | // = Energy_Deposited * ConversionFactor + pedestal | |
490 | // | |
491 | // However, this is modified by the response function of the | |
492 | // VA1_ALICE pre-amp. chip in case we are doing oversampling of the | |
493 | // VA1_ALICE output. | |
494 | // | |
495 | // In that case, we get N=fSampleRate values of the ADC, and the | |
496 | // `EnergyDeposited' is a function of which sample where are | |
497 | // calculating the ADC for | |
498 | // | |
499 | // ADC_i = f(EnergyDeposited, i/N, Last) * ConversionFactor + pedestal | |
500 | // | |
501 | // where Last is the Energy deposited in the previous strip. | |
502 | // | |
503 | // Here, f is the shaping function of the VA1_ALICE. This is given | |
504 | // by | |
505 | // | |
506 | // | (E - l) * (1 - exp(-B * t) + l if E > l | |
507 | // f(E, t, l) = < | |
508 | // | (l - E) * exp(-B * t) + E otherwise | |
509 | // | |
510 | // | |
511 | // = E + (l - E) * ext(-B * t) | |
512 | // | |
513 | AliFMDParameters* param = AliFMDParameters::Instance(); | |
83ad576a | 514 | Float_t convF = (param->GetDACPerMIP() / param->GetEdepMip() * |
515 | param->GetPulseGain(detector,ring,sector,strip)); | |
a9579262 | 516 | Int_t ped = MakePedestal(detector,ring,sector,strip); |
517 | Int_t maxAdc = param->GetAltroChannelSize()-1; | |
518 | if (maxAdc < 0) { | |
519 | AliWarning(Form("Maximum ADC is %d < 0, forcing it to 1023", maxAdc)); | |
520 | maxAdc = 1023; | |
521 | } | |
02a27b50 | 522 | UShort_t rate = param->GetSampleRate(detector,ring,sector,strip); |
ef8e8623 | 523 | AliFMDDebug(15, ("Sample rate for FMD%d%c[%2d,%3d] = %d", |
83ad576a | 524 | detector, ring, sector, strip, rate)); |
ef8e8623 | 525 | if (rate < 1 || rate > 4) { |
526 | AliWarning(Form("Invalid sample rate for for FMD%d%c[%2d,%3d] = %d", | |
527 | detector, ring, sector, strip, rate)); | |
528 | rate = 1; | |
529 | } | |
530 | ||
02a27b50 | 531 | // In case we don't oversample, just return the end value. |
532 | if (rate == 1) { | |
a9579262 | 533 | Float_t a = edep * convF + ped; |
534 | if (a < 0) a = 0; | |
535 | counts[0] = UShort_t(TMath::Min(a, Float_t(maxAdc))); | |
ef8e8623 | 536 | AliFMDDebug(15, ("FMD%d%c[%2d,%3d]: converting ELoss %f to " |
a9579262 | 537 | "ADC %4d (%f,%d)", |
538 | detector,ring,sector,strip,edep,counts[0],convF,ped)); | |
02a27b50 | 539 | return; |
540 | } | |
83ad576a | 541 | |
02a27b50 | 542 | |
543 | // Create a pedestal | |
544 | Float_t b = fShapingTime; | |
545 | for (Ssiz_t i = 0; i < rate; i++) { | |
2aeec17d | 546 | Float_t t = Float_t(i) / rate + 1./rate; |
a9579262 | 547 | Float_t s = edep + (last - edep) * TMath::Exp(-b * t); |
548 | Float_t a = Int_t(s * convF + ped); | |
549 | if (a < 0) a = 0; | |
550 | counts[i] = UShort_t(TMath::Min(a, Float_t(maxAdc))); | |
02a27b50 | 551 | } |
83ad576a | 552 | AliFMDDebug(15, ("Converted edep = %f to ADC (%x,%x,%x,%x) " |
553 | "[gain: %f=(%f/%f*%f), pedestal: %d, rate: %d]", | |
554 | edep, counts[0], counts[1], counts[2], counts[3], | |
555 | convF, param->GetDACPerMIP(),param->GetEdepMip(), | |
556 | param->GetPulseGain(detector,ring,sector,strip), | |
557 | ped, rate)); | |
02a27b50 | 558 | } |
559 | ||
ef8e8623 | 560 | //____________________________________________________________________ |
561 | void | |
b2e6f0b0 | 562 | AliFMDBaseDigitizer::AddDigit(UShort_t detector, |
563 | Char_t ring, | |
564 | UShort_t sector, | |
565 | UShort_t strip, | |
566 | Float_t /* edep */, | |
567 | UShort_t count1, | |
568 | Short_t count2, | |
569 | Short_t count3, | |
570 | Short_t count4, | |
8d00dfa3 | 571 | UShort_t ntot, |
b2e6f0b0 | 572 | UShort_t /* nprim */, |
faf80567 | 573 | const TArrayI& refs) const |
ef8e8623 | 574 | { |
575 | // Add a digit or summable digit | |
ef8e8623 | 576 | fFMD->AddDigitByFields(detector, ring, sector, strip, |
8d00dfa3 | 577 | count1, count2, count3, count4, |
578 | ntot, fStoreTrackRefs ? refs.fArray : 0); | |
2180cab3 | 579 | if (fStoreTrackRefs && ntot > 3) fIgnoredLabels += ntot - 3; |
ef8e8623 | 580 | } |
02a27b50 | 581 | |
ef8e8623 | 582 | //____________________________________________________________________ |
583 | TTree* | |
584 | AliFMDBaseDigitizer::MakeOutputTree(AliLoader* loader) | |
585 | { | |
586 | // Create output tree using loader. If the passed loader differs | |
587 | // from the currently set loader in the FMD object, reset the FMD | |
588 | // loader to be the passed loader. This is for the cases wher the | |
589 | // output is different from the output. | |
590 | AliFMDDebug(5, ("Making digits tree")); | |
591 | loader->LoadDigits("UPDATE"); // "RECREATE"); | |
592 | TTree* out = loader->TreeD(); | |
593 | if (!out) loader->MakeTree("D"); | |
594 | out = loader->TreeD(); | |
595 | if (out) { | |
596 | out->Reset(); | |
597 | if (loader != fFMD->GetLoader()) | |
598 | fFMD->SetLoader(loader); | |
599 | fFMD->MakeBranch("D"); | |
600 | } | |
601 | return out; | |
602 | } | |
603 | ||
604 | //____________________________________________________________________ | |
605 | void | |
606 | AliFMDBaseDigitizer::StoreDigits(AliLoader* loader) | |
607 | { | |
608 | // Write the digits to disk | |
609 | AliFMDDebug(5, ("Storing %d digits", fFMD->Digits()->GetEntries())); | |
610 | loader->WriteDigits("OVERWRITE"); | |
611 | loader->UnloadDigits(); | |
612 | // Reset the digits in the AliFMD object | |
613 | fFMD->ResetDigits(); | |
614 | } | |
02a27b50 | 615 | |
616 | //____________________________________________________________________ | |
617 | // | |
618 | // EOF | |
619 | // | |
620 | ||
621 | ||
622 | ||
623 |