]>
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 | |
56b1929b | 205 | #include <AliRunDigitizer.h> // ALIRUNDIGITIZER_H |
206 | #include <AliRun.h> // ALIRUN_H | |
207 | #include <AliLoader.h> // ALILOADER_H | |
208 | #include <AliRunLoader.h> // ALIRUNLOADER_H | |
4347b38f | 209 | |
4347b38f | 210 | //==================================================================== |
925e6570 | 211 | ClassImp(AliFMDBaseDigitizer) |
1a1fdef7 | 212 | #if 0 |
213 | ; // This is here to keep Emacs for indenting the next line | |
214 | #endif | |
4347b38f | 215 | |
216 | //____________________________________________________________________ | |
217 | AliFMDBaseDigitizer::AliFMDBaseDigitizer() | |
218 | : fRunLoader(0) | |
66d2ede1 | 219 | { |
4347b38f | 220 | // Default ctor - don't use it |
66d2ede1 | 221 | } |
222 | ||
4347b38f | 223 | //____________________________________________________________________ |
224 | AliFMDBaseDigitizer::AliFMDBaseDigitizer(AliRunDigitizer* manager) | |
225 | : AliDigitizer(manager, "AliFMDBaseDigitizer", "FMD Digitizer base class"), | |
226 | fRunLoader(0), | |
e802be3e | 227 | fEdep(AliFMDMap::kMaxDetectors, |
228 | AliFMDMap::kMaxRings, | |
229 | AliFMDMap::kMaxSectors, | |
230 | AliFMDMap::kMaxStrips) | |
66d2ede1 | 231 | { |
4347b38f | 232 | // Normal CTOR |
102e9e9c | 233 | AliDebug(1," processed"); |
4347b38f | 234 | SetVA1MipRange(); |
235 | SetAltroChannelSize(); | |
236 | SetSampleRate(); | |
237 | SetShapingTime(); | |
66d2ede1 | 238 | } |
239 | ||
4347b38f | 240 | //____________________________________________________________________ |
241 | AliFMDBaseDigitizer::AliFMDBaseDigitizer(const Char_t* name, | |
242 | const Char_t* title) | |
243 | : AliDigitizer(name, title), | |
244 | fRunLoader(0), | |
e802be3e | 245 | fEdep(AliFMDMap::kMaxDetectors, |
246 | AliFMDMap::kMaxRings, | |
247 | AliFMDMap::kMaxSectors, | |
248 | AliFMDMap::kMaxStrips) | |
66d2ede1 | 249 | { |
4347b38f | 250 | // Normal CTOR |
251 | AliDebug(1," processed"); | |
252 | SetVA1MipRange(); | |
253 | SetAltroChannelSize(); | |
254 | SetSampleRate(); | |
255 | SetShapingTime(); | |
256 | } | |
3d44ce66 | 257 | |
4347b38f | 258 | //____________________________________________________________________ |
259 | AliFMDBaseDigitizer::~AliFMDBaseDigitizer() | |
260 | { | |
261 | // Destructor | |
66d2ede1 | 262 | } |
263 | ||
4347b38f | 264 | //____________________________________________________________________ |
265 | Bool_t | |
266 | AliFMDBaseDigitizer::Init() | |
66d2ede1 | 267 | { |
4347b38f | 268 | // Initialization |
269 | return kTRUE; | |
66d2ede1 | 270 | } |
271 | ||
88cb7938 | 272 | |
4347b38f | 273 | //____________________________________________________________________ |
274 | void | |
275 | AliFMDBaseDigitizer::SumContributions(AliFMD* fmd) | |
276 | { | |
277 | // Sum energy deposited contributions from each hit in a cache | |
278 | // (fEdep). | |
279 | if (!fRunLoader) | |
280 | Fatal("SumContributions", "no run loader"); | |
281 | ||
282 | // Clear array of deposited energies | |
69b696b9 | 283 | fEdep.Reset(); |
4347b38f | 284 | |
285 | // Get the FMD loader | |
286 | AliLoader* inFMD = fRunLoader->GetLoader("FMDLoader"); | |
287 | // And load the hits | |
288 | inFMD->LoadHits("READ"); | |
289 | ||
290 | // Get the tree of hits | |
291 | TTree* hitsTree = inFMD->TreeH(); | |
292 | if (!hitsTree) { | |
293 | // Try again | |
294 | inFMD->LoadHits("READ"); | |
295 | hitsTree = inFMD->TreeH(); | |
296 | } | |
297 | ||
298 | // Get the FMD branch | |
299 | TBranch* hitsBranch = hitsTree->GetBranch("FMD"); | |
300 | if (hitsBranch) fmd->SetHitsAddressBranch(hitsBranch); | |
301 | else AliFatal("Branch FMD hit not found"); | |
302 | ||
303 | // Get a list of hits from the FMD manager | |
304 | TClonesArray *fmdHits = fmd->Hits(); | |
305 | ||
306 | // Get number of entries in the tree | |
307 | Int_t ntracks = Int_t(hitsTree->GetEntries()); | |
308 | ||
a1f80595 | 309 | Int_t read = 0; |
4347b38f | 310 | // Loop over the tracks in the |
311 | for (Int_t track = 0; track < ntracks; track++) { | |
312 | // Read in entry number `track' | |
a1f80595 | 313 | read += hitsBranch->GetEntry(track); |
4347b38f | 314 | |
315 | // Get the number of hits | |
316 | Int_t nhits = fmdHits->GetEntries (); | |
317 | for (Int_t hit = 0; hit < nhits; hit++) { | |
318 | // Get the hit number `hit' | |
319 | AliFMDHit* fmdHit = | |
320 | static_cast<AliFMDHit*>(fmdHits->UncheckedAt(hit)); | |
321 | ||
322 | // Extract parameters | |
323 | UShort_t detector = fmdHit->Detector(); | |
324 | Char_t ring = fmdHit->Ring(); | |
325 | UShort_t sector = fmdHit->Sector(); | |
326 | UShort_t strip = fmdHit->Strip(); | |
327 | Float_t edep = fmdHit->Edep(); | |
e802be3e | 328 | if (fEdep(detector, ring, sector, strip).fEdep != 0) |
a1f80595 | 329 | AliDebug(5, Form("Double hit in %d%c(%d,%d)", |
4347b38f | 330 | detector, ring, sector, strip)); |
331 | ||
e802be3e | 332 | fEdep(detector, ring, sector, strip).fEdep += edep; |
333 | fEdep(detector, ring, sector, strip).fN += 1; | |
4347b38f | 334 | // Add this to the energy deposited for this strip |
335 | } // hit loop | |
336 | } // track loop | |
a1f80595 | 337 | AliDebug(1, Form("Size of cache: %d bytes, read %d bytes", |
338 | sizeof(fEdep), read)); | |
4347b38f | 339 | } |
66d2ede1 | 340 | |
4347b38f | 341 | //____________________________________________________________________ |
342 | void | |
343 | AliFMDBaseDigitizer::DigitizeHits(AliFMD* fmd) const | |
66d2ede1 | 344 | { |
4347b38f | 345 | // For the stored energy contributions in the cache (fEdep), convert |
346 | // the energy signal to ADC counts, and store the created digit in | |
347 | // the digits array (AliFMD::fDigits) | |
348 | // | |
1a1fdef7 | 349 | AliFMDGeometry* geometry = AliFMDGeometry::Instance(); |
350 | ||
4347b38f | 351 | TArrayI counts(3); |
352 | for (UShort_t detector=1; detector <= 3; detector++) { | |
353 | // Get pointer to subdetector | |
1a1fdef7 | 354 | AliFMDDetector* det = geometry->GetDetector(detector); |
4347b38f | 355 | if (!det) continue; |
356 | for (UShort_t ringi = 0; ringi <= 1; ringi++) { | |
357 | // Get pointer to Ring | |
1a1fdef7 | 358 | AliFMDRing* r = det->GetRing((ringi == 0 ? 'I' : 'O')); |
4347b38f | 359 | if (!r) continue; |
360 | ||
361 | // Get number of sectors | |
362 | UShort_t nSectors = UShort_t(360. / r->GetTheta()); | |
363 | // Loop over the number of sectors | |
364 | for (UShort_t sector = 0; sector < nSectors; sector++) { | |
365 | // Get number of strips | |
366 | UShort_t nStrips = r->GetNStrips(); | |
367 | // Loop over the stips | |
e802be3e | 368 | Float_t last = 0; |
4347b38f | 369 | for (UShort_t strip = 0; strip < nStrips; strip++) { |
e802be3e | 370 | // Reset the counter array to the invalid value -1 |
4347b38f | 371 | counts.Reset(-1); |
e802be3e | 372 | // Reset the last `ADC' value when we've get to the end of a |
373 | // VA1_ALICE channel. | |
374 | if (strip % 128 == 0) last = 0; | |
375 | ||
376 | Float_t edep = fEdep(detector, r->GetId(), sector, strip).fEdep; | |
56b1929b | 377 | ConvertToCount(edep, last, r->GetSiThickness(), |
1a1fdef7 | 378 | geometry->GetSiDensity(), counts); |
e802be3e | 379 | last = edep; |
4347b38f | 380 | AddDigit(fmd, detector, r->GetId(), sector, strip, |
381 | edep, UShort_t(counts[0]), | |
382 | Short_t(counts[1]), Short_t(counts[2])); | |
383 | #if 0 | |
384 | // This checks if the digit created will give the `right' | |
385 | // number of particles when reconstructed, using a naiive | |
386 | // approach. It's here only as a quality check - nothing | |
387 | // else. | |
e802be3e | 388 | CheckDigit(fEdep(detector, r->GetId(), sector, strip).fEdep, |
389 | fEdep(detector, r->GetId(), sector, strip).fN, | |
4347b38f | 390 | counts); |
391 | #endif | |
392 | } // Strip | |
393 | } // Sector | |
394 | } // Ring | |
395 | } // Detector | |
396 | } | |
88cb7938 | 397 | |
4347b38f | 398 | //____________________________________________________________________ |
399 | void | |
400 | AliFMDBaseDigitizer::ConvertToCount(Float_t edep, | |
e802be3e | 401 | Float_t last, |
4347b38f | 402 | Float_t siThickness, |
403 | Float_t siDensity, | |
404 | TArrayI& counts) const | |
405 | { | |
e802be3e | 406 | // Convert the total energy deposited to a (set of) ADC count(s). |
4347b38f | 407 | // |
e802be3e | 408 | // This is done by |
409 | // | |
410 | // Energy_Deposited ALTRO_Channel_Size | |
411 | // ADC = -------------------------- ------------------- + pedestal | |
412 | // Energy_Deposition_Of_1_MIP VA1_ALICE_MIP_Range | |
4347b38f | 413 | // |
e802be3e | 414 | // Energy_Deposited fAltroChannelSize |
415 | // = --------------------------------- ----------------- + pedestal | |
416 | // 1.664 * Si_Thickness * Si_Density fVA1MipRange | |
417 | // | |
4347b38f | 418 | // |
e802be3e | 419 | // = Energy_Deposited * ConversionFactor + pedestal |
420 | // | |
421 | // However, this is modified by the response function of the | |
422 | // VA1_ALICE pre-amp. chip in case we are doing oversampling of the | |
423 | // VA1_ALICE output. | |
424 | // | |
425 | // In that case, we get N=fSampleRate values of the ADC, and the | |
426 | // `EnergyDeposited' is a function of which sample where are | |
427 | // calculating the ADC for | |
428 | // | |
429 | // ADC_i = f(EnergyDeposited, i/N, Last) * ConversionFactor + pedestal | |
430 | // | |
431 | // where Last is the Energy deposited in the previous strip. | |
432 | // | |
433 | // Here, f is the shaping function of the VA1_ALICE. This is given | |
434 | // by | |
435 | // | |
436 | // | (E - l) * (1 - exp(-B * t) + l if E > l | |
437 | // f(E, t, l) = < | |
438 | // | (l - E) * exp(-B * t) + E otherwise | |
439 | // | |
440 | // | |
441 | // = E + (l - E) * ext(-B * t) | |
442 | // | |
443 | const Float_t mipEnergy = 1.664 * siThickness * siDensity; | |
444 | const Float_t convf = (1 / mipEnergy * Float_t(fAltroChannelSize) | |
445 | / fVA1MipRange); | |
446 | UShort_t ped = MakePedestal(); | |
447 | ||
448 | // In case we don't oversample, just return the end value. | |
449 | if (fSampleRate == 1) { | |
450 | counts[0] = UShort_t(TMath::Min(edep * convf + ped, | |
451 | Float_t(fAltroChannelSize))); | |
452 | return; | |
453 | } | |
454 | ||
4347b38f | 455 | // Create a pedestal |
e802be3e | 456 | Int_t n = fSampleRate; |
457 | Float_t B = fShapingTime; | |
4347b38f | 458 | for (Ssiz_t i = 0; i < n; i++) { |
e802be3e | 459 | Float_t t = Float_t(i) / n; |
460 | Float_t s = edep + (last - edep) * TMath::Exp(-B * t); | |
461 | counts[i] = UShort_t(TMath::Min(s * convf + ped, | |
4347b38f | 462 | Float_t(fAltroChannelSize))); |
463 | } | |
464 | } | |
88cb7938 | 465 | |
3d44ce66 | 466 | |
4347b38f | 467 | //==================================================================== |
925e6570 | 468 | ClassImp(AliFMDDigitizer) |
66d2ede1 | 469 | |
4347b38f | 470 | //____________________________________________________________________ |
471 | AliFMDDigitizer::AliFMDDigitizer() | |
472 | : AliFMDBaseDigitizer() | |
473 | { | |
474 | // Default ctor - don't use it | |
475 | } | |
66d2ede1 | 476 | |
4347b38f | 477 | //____________________________________________________________________ |
478 | AliFMDDigitizer::AliFMDDigitizer(AliRunDigitizer* manager) | |
479 | : AliFMDBaseDigitizer(manager) | |
480 | { | |
481 | // Normal CTOR | |
482 | AliDebug(1," processed"); | |
483 | SetPedestal(); | |
484 | } | |
66d2ede1 | 485 | |
4347b38f | 486 | //____________________________________________________________________ |
487 | void | |
488 | AliFMDDigitizer::Exec(Option_t*) | |
489 | { | |
490 | // Get the output manager | |
491 | TString outFolder(fManager->GetOutputFolderName()); | |
492 | AliRunLoader* out = | |
493 | AliRunLoader::GetRunLoader(outFolder.Data()); | |
494 | // Get the FMD output manager | |
495 | AliLoader* outFMD = out->GetLoader("FMDLoader"); | |
496 | ||
497 | // Get the input loader | |
498 | TString inFolder(fManager->GetInputFolderName(0)); | |
499 | fRunLoader = | |
a3537838 | 500 | AliRunLoader::GetRunLoader(inFolder.Data()); |
4347b38f | 501 | if (!fRunLoader) { |
502 | AliError("Can not find Run Loader for input stream 0"); | |
503 | return; | |
504 | } | |
505 | // Get the AliRun object | |
506 | if (!fRunLoader->GetAliRun()) fRunLoader->LoadgAlice(); | |
507 | ||
508 | // Get the AliFMD object | |
509 | AliFMD* fmd = static_cast<AliFMD*>(fRunLoader->GetAliRun()->GetDetector("FMD")); | |
510 | if (!fmd) { | |
511 | AliError("Can not get FMD from gAlice"); | |
512 | return; | |
513 | } | |
514 | ||
515 | Int_t nFiles= fManager->GetNinputs(); | |
516 | for (Int_t inputFile = 0; inputFile < nFiles; inputFile++) { | |
517 | AliDebug(1,Form(" Digitizing event number %d", | |
518 | fManager->GetOutputEventNr())); | |
519 | // Get the current loader | |
520 | fRunLoader = | |
521 | AliRunLoader::GetRunLoader(fManager->GetInputFolderName(inputFile)); | |
522 | if (!fRunLoader) Fatal("Exec", "no run loader"); | |
523 | // Cache contriutions | |
524 | SumContributions(fmd); | |
525 | } | |
526 | // Digitize the event | |
527 | DigitizeHits(fmd); | |
528 | ||
529 | // Load digits from the tree | |
530 | outFMD->LoadDigits("update"); | |
531 | // Get the tree of digits | |
532 | TTree* digitTree = outFMD->TreeD(); | |
533 | if (!digitTree) { | |
534 | outFMD->MakeTree("D"); | |
535 | digitTree = outFMD->TreeD(); | |
536 | } | |
537 | digitTree->Reset(); | |
538 | // Make a branch in the tree | |
539 | TClonesArray* digits = fmd->Digits(); | |
540 | fmd->MakeBranchInTree(digitTree, fmd->GetName(), &(digits), 4000, 0); | |
541 | // TBranch* digitBranch = digitTree->GetBranch(fmd->GetName()); | |
542 | // Fill the tree | |
a1f80595 | 543 | Int_t write = 0; |
544 | write = digitTree->Fill(); | |
545 | AliDebug(1, Form("Wrote %d bytes to digit tree", write)); | |
66d2ede1 | 546 | |
4347b38f | 547 | // Write the digits to disk |
548 | outFMD->WriteDigits("OVERWRITE"); | |
549 | outFMD->UnloadHits(); | |
550 | outFMD->UnloadDigits(); | |
4110645f | 551 | |
4347b38f | 552 | // Reset the digits in the AliFMD object |
553 | fmd->ResetDigits(); | |
554 | } | |
3d44ce66 | 555 | |
88cb7938 | 556 | |
4347b38f | 557 | //____________________________________________________________________ |
558 | UShort_t | |
559 | AliFMDDigitizer::MakePedestal() const | |
560 | { | |
561 | return UShort_t(TMath::Max(gRandom->Gaus(fPedestal, fPedestalWidth), 0.)); | |
562 | } | |
88cb7938 | 563 | |
4347b38f | 564 | //____________________________________________________________________ |
565 | void | |
566 | AliFMDDigitizer::AddDigit(AliFMD* fmd, | |
567 | UShort_t detector, | |
568 | Char_t ring, | |
569 | UShort_t sector, | |
570 | UShort_t strip, | |
571 | Float_t /* edep */, | |
572 | UShort_t count1, | |
573 | Short_t count2, | |
574 | Short_t count3) const | |
575 | { | |
69b696b9 | 576 | fmd->AddDigitByFields(detector, ring, sector, strip, count1, count2, count3); |
4347b38f | 577 | } |
3d44ce66 | 578 | |
4347b38f | 579 | //____________________________________________________________________ |
580 | void | |
581 | AliFMDDigitizer::CheckDigit(Float_t /* edep */, | |
582 | UShort_t nhits, | |
583 | const TArrayI& counts) | |
584 | { | |
585 | Int_t integral = counts[0]; | |
586 | if (counts[1] >= 0) integral += counts[1]; | |
587 | if (counts[2] >= 0) integral += counts[2]; | |
588 | integral -= Int_t(fPedestal + 2 * fPedestalWidth); | |
589 | if (integral < 0) integral = 0; | |
590 | ||
591 | Float_t convf = Float_t(fVA1MipRange) / fAltroChannelSize; | |
592 | Float_t mips = integral * convf; | |
593 | if (mips > Float_t(nhits) + .5 || mips < Float_t(nhits) - .5) | |
594 | Warning("CheckDigit", "Digit -> %4.2f MIPS != %d +/- .5 hits", | |
595 | mips, nhits); | |
596 | } | |
66d2ede1 | 597 | |
4347b38f | 598 | //==================================================================== |
925e6570 | 599 | ClassImp(AliFMDSDigitizer) |
3d44ce66 | 600 | |
4347b38f | 601 | //____________________________________________________________________ |
602 | AliFMDSDigitizer::AliFMDSDigitizer() | |
603 | { | |
604 | // Default ctor - don't use it | |
605 | } | |
88cb7938 | 606 | |
4347b38f | 607 | //____________________________________________________________________ |
608 | AliFMDSDigitizer::AliFMDSDigitizer(const Char_t* headerFile, | |
609 | const Char_t* /* sdigfile */) | |
610 | : AliFMDBaseDigitizer("FMDSDigitizer", "FMD SDigitizer") | |
611 | { | |
612 | // Normal CTOR | |
613 | AliDebug(1," processed"); | |
3d44ce66 | 614 | |
4347b38f | 615 | fRunLoader = AliRunLoader::GetRunLoader(); // Open(headerFile); |
616 | if (!fRunLoader) | |
617 | Fatal("AliFMDSDigitizer", "cannot open session, header file '%s'", | |
618 | headerFile); | |
619 | AliLoader* loader = fRunLoader->GetLoader("FMDLoader"); | |
620 | if (!loader) | |
621 | Fatal("AliFMDSDigitizer", "cannot find FMD loader in specified event"); | |
3d44ce66 | 622 | |
4347b38f | 623 | // Add task to tasks folder |
624 | loader->PostSDigitizer(this); | |
afddaa11 | 625 | |
4347b38f | 626 | } |
88cb7938 | 627 | |
4347b38f | 628 | //____________________________________________________________________ |
629 | AliFMDSDigitizer::~AliFMDSDigitizer() | |
630 | { | |
631 | AliLoader* loader = fRunLoader->GetLoader("FMDLoader"); | |
632 | loader->CleanSDigitizer(); | |
633 | } | |
3d44ce66 | 634 | |
4347b38f | 635 | //____________________________________________________________________ |
636 | void | |
637 | AliFMDSDigitizer::Exec(Option_t*) | |
638 | { | |
639 | // Get the output manager | |
640 | if (!fRunLoader) { | |
641 | Error("Exec", "Run loader is not set"); | |
642 | return; | |
643 | } | |
644 | if (!fRunLoader->GetAliRun()) fRunLoader->LoadgAlice(); | |
645 | if (!fRunLoader->TreeE()) fRunLoader->LoadHeader(); | |
646 | ||
647 | AliLoader* fmdLoader = fRunLoader->GetLoader("FMDLoader"); | |
648 | if (!fmdLoader) Fatal("Exec", "no FMD loader"); | |
649 | ||
650 | // Get the AliFMD object | |
651 | AliFMD* fmd = | |
652 | static_cast<AliFMD*>(fRunLoader->GetAliRun()->GetDetector("FMD")); | |
653 | if (!fmd) { | |
654 | AliError("Can not get FMD from gAlice"); | |
655 | return; | |
656 | } | |
657 | ||
658 | Int_t nEvents = Int_t(fRunLoader->TreeE()->GetEntries()); | |
659 | for (Int_t event = 0; event < nEvents; event++) { | |
660 | AliDebug(1,Form(" Digitizing event number %d", event)); | |
661 | // Get the current loader | |
662 | fRunLoader->GetEvent(event); | |
663 | ||
664 | if (!fmdLoader->TreeS()) fmdLoader->MakeTree("S"); | |
665 | // Make a branch | |
666 | fmd->MakeBranch("S"); | |
667 | ||
668 | // Cache contriutions | |
669 | SumContributions(fmd); | |
670 | ||
671 | // Digitize the event | |
672 | DigitizeHits(fmd); | |
673 | ||
674 | fmdLoader->TreeS()->Reset(); | |
675 | fmdLoader->TreeS()->Fill(); | |
676 | fmdLoader->WriteSDigits("OVERWRITE"); | |
677 | } | |
678 | } | |
66d2ede1 | 679 | |
4347b38f | 680 | //____________________________________________________________________ |
681 | void | |
682 | AliFMDSDigitizer::AddDigit(AliFMD* fmd, | |
683 | UShort_t detector, | |
684 | Char_t ring, | |
685 | UShort_t sector, | |
686 | UShort_t strip, | |
687 | Float_t edep, | |
688 | UShort_t count1, | |
689 | Short_t count2, | |
690 | Short_t count3) const | |
691 | { | |
69b696b9 | 692 | fmd->AddSDigitByFields(detector, ring, sector, strip, edep, |
693 | count1, count2, count3); | |
66d2ede1 | 694 | } |
4347b38f | 695 | |
696 | ||
697 | ||
698 | //____________________________________________________________________ | |
699 | // | |
700 | // EOF | |
701 | // | |
88cb7938 | 702 | |
703 | ||
704 | ||
66d2ede1 | 705 |