]>
Commit | Line | Data |
---|---|---|
4347b38f | 1 | /************************************************************************** |
2 | * Copyright(c) 2004, ALICE Experiment at CERN, All rights reserved. * | |
66d2ede1 | 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 | ||
4347b38f | 16 | /* $Id$ */ |
17 | ||
18 | ////////////////////////////////////////////////////////////////////////////// | |
19 | // | |
20 | // This class contains the procedures simulation ADC signal for the | |
21 | // Forward Multiplicity detector : Hits->Digits and Hits->SDigits | |
22 | // | |
23 | // Digits consists of | |
24 | // - Detector # | |
25 | // - Ring ID | |
26 | // - Sector # | |
27 | // - Strip # | |
28 | // - ADC count in this channel | |
29 | // | |
30 | // Digits consists of | |
31 | // - Detector # | |
32 | // - Ring ID | |
33 | // - Sector # | |
34 | // - Strip # | |
35 | // - Total energy deposited in the strip | |
36 | // - ADC count in this channel | |
37 | // | |
38 | // As the Digits and SDigits have so much in common, the classes | |
39 | // AliFMDDigitizer and AliFMDSDigitizer are implemented via a base | |
40 | // class AliFMDBaseDigitizer. | |
41 | // | |
42 | // +---------------------+ | |
43 | // | AliFMDBaseDigitizer | | |
44 | // +---------------------+ | |
45 | // ^ | |
46 | // | | |
47 | // +----------+---------+ | |
48 | // | | | |
49 | // +-----------------+ +------------------+ | |
50 | // | AliFMDDigitizer | | AliFMDSDigitizer | | |
51 | // +-----------------+ +------------------+ | |
52 | // | |
53 | // These classes has several paramters: | |
54 | // | |
55 | // fPedestal | |
56 | // fPedestalWidth | |
57 | // (Only AliFMDDigitizer) | |
58 | // Mean and width of the pedestal. The pedestal is simulated | |
59 | // by a Guassian, but derived classes my override MakePedestal | |
60 | // to simulate it differently (or pick it up from a database). | |
61 | // | |
62 | // fVA1MipRange | |
63 | // The dymamic MIP range of the VA1_ALICE pre-amplifier chip | |
64 | // | |
65 | // fAltroChannelSize | |
66 | // The largest number plus one that can be stored in one | |
67 | // channel in one time step in the ALTRO ADC chip. | |
68 | // | |
69 | // fSampleRate | |
70 | // How many times the ALTRO ADC chip samples the VA1_ALICE | |
71 | // pre-amplifier signal. The VA1_ALICE chip is read-out at | |
72 | // 10MHz, while it's possible to drive the ALTRO chip at | |
73 | // 25MHz. That means, that the ALTRO chip can have time to | |
74 | // sample each VA1_ALICE signal up to 2 times. Although it's | |
75 | // not certain this feature will be used in the production, | |
76 | // we'd like have the option, and so it should be reflected in | |
77 | // the code. | |
78 | // | |
4347b38f | 79 | // |
e802be3e | 80 | // The shaping function of the VA1_ALICE is generally given by |
4347b38f | 81 | // |
e802be3e | 82 | // f(x) = A(1 - exp(-Bx)) |
4347b38f | 83 | // |
e802be3e | 84 | // where A is the total charge collected in the pre-amp., and B is a |
85 | // paramter that depends on the shaping time of the VA1_ALICE circut. | |
86 | // | |
87 | // When simulating the shaping function of the VA1_ALICe | |
88 | // pre-amp. chip, we have to take into account, that the shaping | |
89 | // function depends on the previous value of read from the pre-amp. | |
90 | // | |
91 | // That results in the following algorithm: | |
92 | // | |
93 | // last = 0; | |
94 | // FOR charge IN pre-amp. charge train DO | |
95 | // IF last < charge THEN | |
96 | // f(t) = (charge - last) * (1 - exp(-B * t)) + last | |
97 | // ELSE | |
98 | // f(t) = (last - charge) * exp(-B * t) + charge) | |
99 | // ENDIF | |
100 | // FOR i IN # samples DO | |
101 | // adc_i = f(i / (# samples)) | |
102 | // DONE | |
103 | // last = charge | |
104 | // DONE | |
105 | // | |
106 | // Here, | |
107 | // | |
108 | // pre-amp. charge train | |
109 | // is a series of 128 charges read from the VA1_ALICE chip | |
110 | // | |
111 | // # samples | |
112 | // is the number of times the ALTRO ADC samples each of the 128 | |
113 | // charges from the pre-amp. | |
4347b38f | 114 | // |
115 | // Where Q is the total charge collected by the VA1_ALICE | |
116 | // pre-amplifier. Q is then given by | |
117 | // | |
118 | // E S | |
119 | // Q = - - | |
120 | // e R | |
121 | // | |
122 | // where E is the total energy deposited in a silicon strip, R is the | |
123 | // dynamic range of the VA1_ALICE pre-amp (fVA1MipRange), e is the | |
124 | // energy deposited by a single MIP, and S ALTRO channel size in each | |
125 | // time step (fAltroChannelSize). | |
126 | // | |
127 | // The energy deposited per MIP is given by | |
128 | // | |
129 | // e = M * rho * w | |
130 | // | |
131 | // where M is the universal number 1.664, rho is the density of | |
132 | // silicon, and w is the depth of the silicon sensor. | |
133 | // | |
134 | // The final ADC count is given by | |
135 | // | |
136 | // C' = C + P | |
137 | // | |
138 | // where P is the (randomized) pedestal (see MakePedestal) | |
139 | // | |
140 | // This class uses the class template AliFMDMap<Type> to make an | |
141 | // internal cache of the energy deposted of the hits. The class | |
142 | // template is instantasized as | |
143 | // | |
144 | // typedef AliFMDMap<std::pair<Float_t, UShort_t> > AliFMDEdepMap; | |
145 | // | |
146 | // The first member of the values is the summed energy deposition in a | |
147 | // given strip, while the second member of the values is the number of | |
148 | // hits in a given strip. Using the second member, it's possible to | |
149 | // do some checks on just how many times a strip got hit, and what | |
150 | // kind of error we get in our reconstructed hits. Note, that this | |
151 | // information is currently not written to the digits tree. I think a | |
152 | // QA (Quality Assurance) digit tree is better suited for that task. | |
153 | // However, the information is there to be used in the future. | |
154 | // | |
155 | // | |
156 | // Latest changes by Christian Holm Christensen | |
157 | // | |
158 | ////////////////////////////////////////////////////////////////////////////// | |
159 | ||
e802be3e | 160 | // /1 |
161 | // | A(-1 + B + exp(-B)) | |
162 | // | f(x) dx = ------------------- = 1 | |
163 | // | B | |
164 | // / 0 | |
165 | // | |
166 | // and B is the a parameter defined by the shaping time (fShapingTime). | |
167 | // | |
168 | // Solving the above equation, for A gives | |
169 | // | |
170 | // B | |
171 | // A = ---------------- | |
172 | // -1 + B + exp(-B) | |
173 | // | |
174 | // So, if we define the function g: [0,1] -> [0:1] by | |
175 | // | |
176 | // / v | |
177 | // | Bu + exp(-Bu) - Bv - exp(-Bv) | |
178 | // g(u,v) = | f(x) dx = -A ----------------------------- | |
179 | // | B | |
180 | // / u | |
181 | // | |
182 | // we can evaluate the ALTRO sample of the VA1_ALICE pre-amp between | |
183 | // any two times (u, v), by | |
184 | // | |
185 | // | |
186 | // B Bu + exp(-Bu) - Bv - exp(-Bv) | |
187 | // C = Q g(u,v) = - Q ---------------- ----------------------------- | |
188 | // -1 + B + exp(-B) B | |
189 | // | |
190 | // Bu + exp(-Bu) - Bv - exp(-Bv) | |
191 | // = - Q ----------------------------- | |
192 | // -1 + B + exp(-B) | |
193 | // | |
194 | ||
56b1929b | 195 | #include <TTree.h> // ROOT_TTree |
196 | #include <TRandom.h> // ROOT_TRandom | |
197 | #include <AliLog.h> // ALILOG_H | |
e802be3e | 198 | #include "AliFMDDigitizer.h" // ALIFMDDIGITIZER_H |
199 | #include "AliFMD.h" // ALIFMD_H | |
1a1fdef7 | 200 | #include "AliFMDGeometry.h" // ALIFMDGEOMETRY_H |
201 | #include "AliFMDDetector.h" // ALIFMDDETECTOR_H | |
202 | #include "AliFMDRing.h" // ALIFMDRING_H | |
e802be3e | 203 | #include "AliFMDHit.h" // ALIFMDHIT_H |
204 | #include "AliFMDDigit.h" // ALIFMDDIGIT_H | |
8f6ee336 | 205 | #include "AliFMDParameters.h" // ALIFMDPARAMETERS_H |
56b1929b | 206 | #include <AliRunDigitizer.h> // ALIRUNDIGITIZER_H |
207 | #include <AliRun.h> // ALIRUN_H | |
208 | #include <AliLoader.h> // ALILOADER_H | |
209 | #include <AliRunLoader.h> // ALIRUNLOADER_H | |
4347b38f | 210 | |
4347b38f | 211 | //==================================================================== |
925e6570 | 212 | ClassImp(AliFMDBaseDigitizer) |
1a1fdef7 | 213 | #if 0 |
214 | ; // This is here to keep Emacs for indenting the next line | |
215 | #endif | |
4347b38f | 216 | |
217 | //____________________________________________________________________ | |
218 | AliFMDBaseDigitizer::AliFMDBaseDigitizer() | |
219 | : fRunLoader(0) | |
66d2ede1 | 220 | { |
4347b38f | 221 | // Default ctor - don't use it |
66d2ede1 | 222 | } |
223 | ||
4347b38f | 224 | //____________________________________________________________________ |
225 | AliFMDBaseDigitizer::AliFMDBaseDigitizer(AliRunDigitizer* manager) | |
226 | : AliDigitizer(manager, "AliFMDBaseDigitizer", "FMD Digitizer base class"), | |
227 | fRunLoader(0), | |
e802be3e | 228 | fEdep(AliFMDMap::kMaxDetectors, |
229 | AliFMDMap::kMaxRings, | |
230 | AliFMDMap::kMaxSectors, | |
231 | AliFMDMap::kMaxStrips) | |
66d2ede1 | 232 | { |
4347b38f | 233 | // Normal CTOR |
102e9e9c | 234 | AliDebug(1," processed"); |
4347b38f | 235 | SetShapingTime(); |
66d2ede1 | 236 | } |
237 | ||
4347b38f | 238 | //____________________________________________________________________ |
239 | AliFMDBaseDigitizer::AliFMDBaseDigitizer(const Char_t* name, | |
240 | const Char_t* title) | |
241 | : AliDigitizer(name, title), | |
242 | fRunLoader(0), | |
e802be3e | 243 | fEdep(AliFMDMap::kMaxDetectors, |
244 | AliFMDMap::kMaxRings, | |
245 | AliFMDMap::kMaxSectors, | |
246 | AliFMDMap::kMaxStrips) | |
66d2ede1 | 247 | { |
4347b38f | 248 | // Normal CTOR |
249 | AliDebug(1," processed"); | |
4347b38f | 250 | SetShapingTime(); |
251 | } | |
3d44ce66 | 252 | |
4347b38f | 253 | //____________________________________________________________________ |
254 | AliFMDBaseDigitizer::~AliFMDBaseDigitizer() | |
255 | { | |
256 | // Destructor | |
66d2ede1 | 257 | } |
258 | ||
4347b38f | 259 | //____________________________________________________________________ |
260 | Bool_t | |
261 | AliFMDBaseDigitizer::Init() | |
66d2ede1 | 262 | { |
4347b38f | 263 | // Initialization |
1e8f773e | 264 | AliFMDParameters::Instance()->Init(); |
4347b38f | 265 | return kTRUE; |
66d2ede1 | 266 | } |
267 | ||
88cb7938 | 268 | |
8f6ee336 | 269 | //____________________________________________________________________ |
270 | UShort_t | |
271 | AliFMDBaseDigitizer::MakePedestal(UShort_t, | |
272 | Char_t, | |
273 | UShort_t, | |
274 | UShort_t) const | |
275 | { | |
276 | return 0; | |
277 | } | |
278 | ||
4347b38f | 279 | //____________________________________________________________________ |
280 | void | |
281 | AliFMDBaseDigitizer::SumContributions(AliFMD* fmd) | |
282 | { | |
283 | // Sum energy deposited contributions from each hit in a cache | |
284 | // (fEdep). | |
285 | if (!fRunLoader) | |
286 | Fatal("SumContributions", "no run loader"); | |
287 | ||
288 | // Clear array of deposited energies | |
69b696b9 | 289 | fEdep.Reset(); |
4347b38f | 290 | |
291 | // Get the FMD loader | |
292 | AliLoader* inFMD = fRunLoader->GetLoader("FMDLoader"); | |
293 | // And load the hits | |
294 | inFMD->LoadHits("READ"); | |
295 | ||
296 | // Get the tree of hits | |
297 | TTree* hitsTree = inFMD->TreeH(); | |
298 | if (!hitsTree) { | |
299 | // Try again | |
300 | inFMD->LoadHits("READ"); | |
301 | hitsTree = inFMD->TreeH(); | |
302 | } | |
303 | ||
304 | // Get the FMD branch | |
305 | TBranch* hitsBranch = hitsTree->GetBranch("FMD"); | |
306 | if (hitsBranch) fmd->SetHitsAddressBranch(hitsBranch); | |
307 | else AliFatal("Branch FMD hit not found"); | |
308 | ||
309 | // Get a list of hits from the FMD manager | |
310 | TClonesArray *fmdHits = fmd->Hits(); | |
311 | ||
312 | // Get number of entries in the tree | |
313 | Int_t ntracks = Int_t(hitsTree->GetEntries()); | |
314 | ||
8f6ee336 | 315 | AliFMDParameters* param = AliFMDParameters::Instance(); |
a1f80595 | 316 | Int_t read = 0; |
4347b38f | 317 | // Loop over the tracks in the |
318 | for (Int_t track = 0; track < ntracks; track++) { | |
319 | // Read in entry number `track' | |
a1f80595 | 320 | read += hitsBranch->GetEntry(track); |
4347b38f | 321 | |
322 | // Get the number of hits | |
323 | Int_t nhits = fmdHits->GetEntries (); | |
324 | for (Int_t hit = 0; hit < nhits; hit++) { | |
325 | // Get the hit number `hit' | |
326 | AliFMDHit* fmdHit = | |
327 | static_cast<AliFMDHit*>(fmdHits->UncheckedAt(hit)); | |
328 | ||
329 | // Extract parameters | |
330 | UShort_t detector = fmdHit->Detector(); | |
331 | Char_t ring = fmdHit->Ring(); | |
332 | UShort_t sector = fmdHit->Sector(); | |
333 | UShort_t strip = fmdHit->Strip(); | |
334 | Float_t edep = fmdHit->Edep(); | |
8f6ee336 | 335 | |
336 | // Check if strip is `dead' | |
337 | if (param->IsDead(detector, ring, sector, strip)) continue; | |
338 | ||
339 | // Give warning in case of double hit | |
e802be3e | 340 | if (fEdep(detector, ring, sector, strip).fEdep != 0) |
a1f80595 | 341 | AliDebug(5, Form("Double hit in %d%c(%d,%d)", |
4347b38f | 342 | detector, ring, sector, strip)); |
343 | ||
8f6ee336 | 344 | // Sum energy deposition |
e802be3e | 345 | fEdep(detector, ring, sector, strip).fEdep += edep; |
346 | fEdep(detector, ring, sector, strip).fN += 1; | |
4347b38f | 347 | // Add this to the energy deposited for this strip |
348 | } // hit loop | |
349 | } // track loop | |
a1f80595 | 350 | AliDebug(1, Form("Size of cache: %d bytes, read %d bytes", |
351 | sizeof(fEdep), read)); | |
4347b38f | 352 | } |
66d2ede1 | 353 | |
4347b38f | 354 | //____________________________________________________________________ |
355 | void | |
356 | AliFMDBaseDigitizer::DigitizeHits(AliFMD* fmd) const | |
66d2ede1 | 357 | { |
4347b38f | 358 | // For the stored energy contributions in the cache (fEdep), convert |
359 | // the energy signal to ADC counts, and store the created digit in | |
360 | // the digits array (AliFMD::fDigits) | |
361 | // | |
1a1fdef7 | 362 | AliFMDGeometry* geometry = AliFMDGeometry::Instance(); |
363 | ||
4347b38f | 364 | TArrayI counts(3); |
365 | for (UShort_t detector=1; detector <= 3; detector++) { | |
366 | // Get pointer to subdetector | |
1a1fdef7 | 367 | AliFMDDetector* det = geometry->GetDetector(detector); |
4347b38f | 368 | if (!det) continue; |
369 | for (UShort_t ringi = 0; ringi <= 1; ringi++) { | |
8f6ee336 | 370 | Char_t ring = ringi == 0 ? 'I' : 'O'; |
4347b38f | 371 | // Get pointer to Ring |
8f6ee336 | 372 | AliFMDRing* r = det->GetRing(ring); |
4347b38f | 373 | if (!r) continue; |
374 | ||
375 | // Get number of sectors | |
376 | UShort_t nSectors = UShort_t(360. / r->GetTheta()); | |
377 | // Loop over the number of sectors | |
378 | for (UShort_t sector = 0; sector < nSectors; sector++) { | |
379 | // Get number of strips | |
380 | UShort_t nStrips = r->GetNStrips(); | |
381 | // Loop over the stips | |
e802be3e | 382 | Float_t last = 0; |
4347b38f | 383 | for (UShort_t strip = 0; strip < nStrips; strip++) { |
e802be3e | 384 | // Reset the counter array to the invalid value -1 |
4347b38f | 385 | counts.Reset(-1); |
e802be3e | 386 | // Reset the last `ADC' value when we've get to the end of a |
387 | // VA1_ALICE channel. | |
388 | if (strip % 128 == 0) last = 0; | |
389 | ||
8f6ee336 | 390 | Float_t edep = fEdep(detector, ring, sector, strip).fEdep; |
391 | ConvertToCount(edep, last, detector, ring, sector, strip, counts); | |
e802be3e | 392 | last = edep; |
8f6ee336 | 393 | AddDigit(fmd, detector, ring, sector, strip, edep, |
394 | UShort_t(counts[0]), Short_t(counts[1]), | |
395 | Short_t(counts[2])); | |
4347b38f | 396 | #if 0 |
397 | // This checks if the digit created will give the `right' | |
398 | // number of particles when reconstructed, using a naiive | |
399 | // approach. It's here only as a quality check - nothing | |
400 | // else. | |
8f6ee336 | 401 | CheckDigit(digit, fEdep(detector, ring, sector, strip).fN, |
4347b38f | 402 | counts); |
403 | #endif | |
404 | } // Strip | |
405 | } // Sector | |
406 | } // Ring | |
407 | } // Detector | |
408 | } | |
88cb7938 | 409 | |
4347b38f | 410 | //____________________________________________________________________ |
411 | void | |
412 | AliFMDBaseDigitizer::ConvertToCount(Float_t edep, | |
e802be3e | 413 | Float_t last, |
8f6ee336 | 414 | UShort_t detector, |
415 | Char_t ring, | |
416 | UShort_t sector, | |
417 | UShort_t strip, | |
4347b38f | 418 | TArrayI& counts) const |
419 | { | |
e802be3e | 420 | // Convert the total energy deposited to a (set of) ADC count(s). |
4347b38f | 421 | // |
e802be3e | 422 | // This is done by |
423 | // | |
424 | // Energy_Deposited ALTRO_Channel_Size | |
425 | // ADC = -------------------------- ------------------- + pedestal | |
426 | // Energy_Deposition_Of_1_MIP VA1_ALICE_MIP_Range | |
4347b38f | 427 | // |
e802be3e | 428 | // Energy_Deposited fAltroChannelSize |
429 | // = --------------------------------- ----------------- + pedestal | |
430 | // 1.664 * Si_Thickness * Si_Density fVA1MipRange | |
431 | // | |
4347b38f | 432 | // |
e802be3e | 433 | // = Energy_Deposited * ConversionFactor + pedestal |
434 | // | |
435 | // However, this is modified by the response function of the | |
436 | // VA1_ALICE pre-amp. chip in case we are doing oversampling of the | |
437 | // VA1_ALICE output. | |
438 | // | |
439 | // In that case, we get N=fSampleRate values of the ADC, and the | |
440 | // `EnergyDeposited' is a function of which sample where are | |
441 | // calculating the ADC for | |
442 | // | |
443 | // ADC_i = f(EnergyDeposited, i/N, Last) * ConversionFactor + pedestal | |
444 | // | |
445 | // where Last is the Energy deposited in the previous strip. | |
446 | // | |
447 | // Here, f is the shaping function of the VA1_ALICE. This is given | |
448 | // by | |
449 | // | |
450 | // | (E - l) * (1 - exp(-B * t) + l if E > l | |
451 | // f(E, t, l) = < | |
452 | // | (l - E) * exp(-B * t) + E otherwise | |
453 | // | |
454 | // | |
455 | // = E + (l - E) * ext(-B * t) | |
456 | // | |
8f6ee336 | 457 | AliFMDParameters* param = AliFMDParameters::Instance(); |
458 | Float_t convF = 1/param->GetPulseGain(detector,ring,sector,strip); | |
459 | UShort_t ped = MakePedestal(detector,ring,sector,strip); | |
460 | UInt_t maxAdc = param->GetAltroChannelSize(); | |
461 | UShort_t rate = param->GetSampleRate(AliFMDParameters::kBaseDDL); | |
462 | UShort_t size = param->GetAltroChannelSize(); | |
463 | ||
e802be3e | 464 | // In case we don't oversample, just return the end value. |
8f6ee336 | 465 | if (rate == 1) { |
466 | counts[0] = UShort_t(TMath::Min(edep * convF + ped, Float_t(size))); | |
e802be3e | 467 | return; |
468 | } | |
088f8e79 | 469 | |
4347b38f | 470 | // Create a pedestal |
088f8e79 | 471 | Float_t b = fShapingTime; |
8f6ee336 | 472 | for (Ssiz_t i = 0; i < rate; i++) { |
473 | Float_t t = Float_t(i) / rate; | |
088f8e79 | 474 | Float_t s = edep + (last - edep) * TMath::Exp(-b * t); |
8f6ee336 | 475 | counts[i] = UShort_t(TMath::Min(s * convF + ped, Float_t(maxAdc))); |
4347b38f | 476 | } |
477 | } | |
88cb7938 | 478 | |
3d44ce66 | 479 | |
4347b38f | 480 | //==================================================================== |
925e6570 | 481 | ClassImp(AliFMDDigitizer) |
66d2ede1 | 482 | |
4347b38f | 483 | //____________________________________________________________________ |
484 | AliFMDDigitizer::AliFMDDigitizer() | |
485 | : AliFMDBaseDigitizer() | |
486 | { | |
487 | // Default ctor - don't use it | |
488 | } | |
66d2ede1 | 489 | |
4347b38f | 490 | //____________________________________________________________________ |
491 | AliFMDDigitizer::AliFMDDigitizer(AliRunDigitizer* manager) | |
492 | : AliFMDBaseDigitizer(manager) | |
493 | { | |
494 | // Normal CTOR | |
495 | AliDebug(1," processed"); | |
4347b38f | 496 | } |
66d2ede1 | 497 | |
4347b38f | 498 | //____________________________________________________________________ |
499 | void | |
500 | AliFMDDigitizer::Exec(Option_t*) | |
501 | { | |
502 | // Get the output manager | |
503 | TString outFolder(fManager->GetOutputFolderName()); | |
504 | AliRunLoader* out = | |
505 | AliRunLoader::GetRunLoader(outFolder.Data()); | |
506 | // Get the FMD output manager | |
507 | AliLoader* outFMD = out->GetLoader("FMDLoader"); | |
508 | ||
509 | // Get the input loader | |
510 | TString inFolder(fManager->GetInputFolderName(0)); | |
511 | fRunLoader = | |
a3537838 | 512 | AliRunLoader::GetRunLoader(inFolder.Data()); |
4347b38f | 513 | if (!fRunLoader) { |
514 | AliError("Can not find Run Loader for input stream 0"); | |
515 | return; | |
516 | } | |
517 | // Get the AliRun object | |
518 | if (!fRunLoader->GetAliRun()) fRunLoader->LoadgAlice(); | |
519 | ||
520 | // Get the AliFMD object | |
8f6ee336 | 521 | AliFMD* fmd = |
522 | static_cast<AliFMD*>(fRunLoader->GetAliRun()->GetDetector("FMD")); | |
4347b38f | 523 | if (!fmd) { |
524 | AliError("Can not get FMD from gAlice"); | |
525 | return; | |
526 | } | |
527 | ||
528 | Int_t nFiles= fManager->GetNinputs(); | |
529 | for (Int_t inputFile = 0; inputFile < nFiles; inputFile++) { | |
530 | AliDebug(1,Form(" Digitizing event number %d", | |
531 | fManager->GetOutputEventNr())); | |
532 | // Get the current loader | |
533 | fRunLoader = | |
534 | AliRunLoader::GetRunLoader(fManager->GetInputFolderName(inputFile)); | |
535 | if (!fRunLoader) Fatal("Exec", "no run loader"); | |
536 | // Cache contriutions | |
537 | SumContributions(fmd); | |
538 | } | |
539 | // Digitize the event | |
540 | DigitizeHits(fmd); | |
541 | ||
542 | // Load digits from the tree | |
543 | outFMD->LoadDigits("update"); | |
544 | // Get the tree of digits | |
545 | TTree* digitTree = outFMD->TreeD(); | |
546 | if (!digitTree) { | |
547 | outFMD->MakeTree("D"); | |
548 | digitTree = outFMD->TreeD(); | |
549 | } | |
550 | digitTree->Reset(); | |
551 | // Make a branch in the tree | |
552 | TClonesArray* digits = fmd->Digits(); | |
553 | fmd->MakeBranchInTree(digitTree, fmd->GetName(), &(digits), 4000, 0); | |
554 | // TBranch* digitBranch = digitTree->GetBranch(fmd->GetName()); | |
555 | // Fill the tree | |
a1f80595 | 556 | Int_t write = 0; |
557 | write = digitTree->Fill(); | |
558 | AliDebug(1, Form("Wrote %d bytes to digit tree", write)); | |
66d2ede1 | 559 | |
4347b38f | 560 | // Write the digits to disk |
561 | outFMD->WriteDigits("OVERWRITE"); | |
562 | outFMD->UnloadHits(); | |
563 | outFMD->UnloadDigits(); | |
4110645f | 564 | |
4347b38f | 565 | // Reset the digits in the AliFMD object |
566 | fmd->ResetDigits(); | |
567 | } | |
3d44ce66 | 568 | |
88cb7938 | 569 | |
4347b38f | 570 | //____________________________________________________________________ |
571 | UShort_t | |
8f6ee336 | 572 | AliFMDDigitizer::MakePedestal(UShort_t detector, |
573 | Char_t ring, | |
574 | UShort_t sector, | |
575 | UShort_t strip) const | |
4347b38f | 576 | { |
088f8e79 | 577 | // Make a pedestal |
8f6ee336 | 578 | AliFMDParameters* param =AliFMDParameters::Instance(); |
579 | Float_t mean =param->GetPedestal(detector,ring,sector,strip); | |
580 | Float_t width =param->GetPedestalWidth(detector,ring,sector,strip); | |
581 | return UShort_t(TMath::Max(gRandom->Gaus(mean, width), 0.)); | |
4347b38f | 582 | } |
88cb7938 | 583 | |
4347b38f | 584 | //____________________________________________________________________ |
585 | void | |
586 | AliFMDDigitizer::AddDigit(AliFMD* fmd, | |
587 | UShort_t detector, | |
588 | Char_t ring, | |
589 | UShort_t sector, | |
590 | UShort_t strip, | |
591 | Float_t /* edep */, | |
592 | UShort_t count1, | |
593 | Short_t count2, | |
594 | Short_t count3) const | |
595 | { | |
088f8e79 | 596 | // Add a digit |
69b696b9 | 597 | fmd->AddDigitByFields(detector, ring, sector, strip, count1, count2, count3); |
4347b38f | 598 | } |
3d44ce66 | 599 | |
4347b38f | 600 | //____________________________________________________________________ |
601 | void | |
8f6ee336 | 602 | AliFMDDigitizer::CheckDigit(AliFMDDigit* digit, |
4347b38f | 603 | UShort_t nhits, |
604 | const TArrayI& counts) | |
605 | { | |
088f8e79 | 606 | // Check that digit is consistent |
8f6ee336 | 607 | AliFMDParameters* param = AliFMDParameters::Instance(); |
608 | UShort_t det = digit->Detector(); | |
609 | Char_t ring = digit->Ring(); | |
610 | UShort_t sec = digit->Sector(); | |
611 | UShort_t str = digit->Strip(); | |
612 | Float_t mean = param->GetPedestal(det,ring,sec,str); | |
613 | Float_t width = param->GetPedestalWidth(det,ring,sec,str); | |
614 | UShort_t range = param->GetVA1MipRange(); | |
615 | UShort_t size = param->GetAltroChannelSize(); | |
616 | Int_t integral = counts[0]; | |
4347b38f | 617 | if (counts[1] >= 0) integral += counts[1]; |
618 | if (counts[2] >= 0) integral += counts[2]; | |
8f6ee336 | 619 | integral -= Int_t(mean + 2 * width); |
4347b38f | 620 | if (integral < 0) integral = 0; |
621 | ||
8f6ee336 | 622 | Float_t convF = Float_t(range) / size; |
088f8e79 | 623 | Float_t mips = integral * convF; |
4347b38f | 624 | if (mips > Float_t(nhits) + .5 || mips < Float_t(nhits) - .5) |
625 | Warning("CheckDigit", "Digit -> %4.2f MIPS != %d +/- .5 hits", | |
626 | mips, nhits); | |
627 | } | |
66d2ede1 | 628 | |
4347b38f | 629 | //==================================================================== |
925e6570 | 630 | ClassImp(AliFMDSDigitizer) |
3d44ce66 | 631 | |
4347b38f | 632 | //____________________________________________________________________ |
633 | AliFMDSDigitizer::AliFMDSDigitizer() | |
634 | { | |
635 | // Default ctor - don't use it | |
636 | } | |
88cb7938 | 637 | |
4347b38f | 638 | //____________________________________________________________________ |
639 | AliFMDSDigitizer::AliFMDSDigitizer(const Char_t* headerFile, | |
640 | const Char_t* /* sdigfile */) | |
641 | : AliFMDBaseDigitizer("FMDSDigitizer", "FMD SDigitizer") | |
642 | { | |
643 | // Normal CTOR | |
644 | AliDebug(1," processed"); | |
3d44ce66 | 645 | |
4347b38f | 646 | fRunLoader = AliRunLoader::GetRunLoader(); // Open(headerFile); |
647 | if (!fRunLoader) | |
648 | Fatal("AliFMDSDigitizer", "cannot open session, header file '%s'", | |
649 | headerFile); | |
650 | AliLoader* loader = fRunLoader->GetLoader("FMDLoader"); | |
651 | if (!loader) | |
652 | Fatal("AliFMDSDigitizer", "cannot find FMD loader in specified event"); | |
3d44ce66 | 653 | |
4347b38f | 654 | // Add task to tasks folder |
655 | loader->PostSDigitizer(this); | |
afddaa11 | 656 | |
4347b38f | 657 | } |
88cb7938 | 658 | |
4347b38f | 659 | //____________________________________________________________________ |
660 | AliFMDSDigitizer::~AliFMDSDigitizer() | |
661 | { | |
088f8e79 | 662 | // Destructor |
4347b38f | 663 | AliLoader* loader = fRunLoader->GetLoader("FMDLoader"); |
664 | loader->CleanSDigitizer(); | |
665 | } | |
3d44ce66 | 666 | |
4347b38f | 667 | //____________________________________________________________________ |
668 | void | |
669 | AliFMDSDigitizer::Exec(Option_t*) | |
670 | { | |
671 | // Get the output manager | |
672 | if (!fRunLoader) { | |
673 | Error("Exec", "Run loader is not set"); | |
674 | return; | |
675 | } | |
676 | if (!fRunLoader->GetAliRun()) fRunLoader->LoadgAlice(); | |
677 | if (!fRunLoader->TreeE()) fRunLoader->LoadHeader(); | |
678 | ||
679 | AliLoader* fmdLoader = fRunLoader->GetLoader("FMDLoader"); | |
680 | if (!fmdLoader) Fatal("Exec", "no FMD loader"); | |
681 | ||
682 | // Get the AliFMD object | |
683 | AliFMD* fmd = | |
684 | static_cast<AliFMD*>(fRunLoader->GetAliRun()->GetDetector("FMD")); | |
685 | if (!fmd) { | |
686 | AliError("Can not get FMD from gAlice"); | |
687 | return; | |
688 | } | |
689 | ||
690 | Int_t nEvents = Int_t(fRunLoader->TreeE()->GetEntries()); | |
691 | for (Int_t event = 0; event < nEvents; event++) { | |
692 | AliDebug(1,Form(" Digitizing event number %d", event)); | |
693 | // Get the current loader | |
694 | fRunLoader->GetEvent(event); | |
695 | ||
696 | if (!fmdLoader->TreeS()) fmdLoader->MakeTree("S"); | |
697 | // Make a branch | |
698 | fmd->MakeBranch("S"); | |
699 | ||
700 | // Cache contriutions | |
701 | SumContributions(fmd); | |
702 | ||
703 | // Digitize the event | |
704 | DigitizeHits(fmd); | |
705 | ||
706 | fmdLoader->TreeS()->Reset(); | |
707 | fmdLoader->TreeS()->Fill(); | |
708 | fmdLoader->WriteSDigits("OVERWRITE"); | |
709 | } | |
710 | } | |
66d2ede1 | 711 | |
4347b38f | 712 | //____________________________________________________________________ |
713 | void | |
714 | AliFMDSDigitizer::AddDigit(AliFMD* fmd, | |
715 | UShort_t detector, | |
716 | Char_t ring, | |
717 | UShort_t sector, | |
718 | UShort_t strip, | |
719 | Float_t edep, | |
720 | UShort_t count1, | |
721 | Short_t count2, | |
722 | Short_t count3) const | |
723 | { | |
088f8e79 | 724 | // Add a summable digit |
69b696b9 | 725 | fmd->AddSDigitByFields(detector, ring, sector, strip, edep, |
726 | count1, count2, count3); | |
66d2ede1 | 727 | } |
4347b38f | 728 | |
729 | ||
730 | ||
731 | //____________________________________________________________________ | |
732 | // | |
733 | // EOF | |
734 | // | |
88cb7938 | 735 | |
736 | ||
737 | ||
66d2ede1 | 738 |