]> git.uio.no Git - u/mrichter/AliRoot.git/blame - FMD/AliFMDDigitizer.cxx
08-mar-2006 NvE Time offset correction in IceF2k extended to allow also a user define...
[u/mrichter/AliRoot.git] / FMD / AliFMDDigitizer.cxx
CommitLineData
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 211ClassImp(AliFMDBaseDigitizer)
1a1fdef7 212#if 0
213 ; // This is here to keep Emacs for indenting the next line
214#endif
4347b38f 215
216//____________________________________________________________________
217AliFMDBaseDigitizer::AliFMDBaseDigitizer()
218 : fRunLoader(0)
66d2ede1 219{
4347b38f 220 // Default ctor - don't use it
66d2ede1 221}
222
4347b38f 223//____________________________________________________________________
224AliFMDBaseDigitizer::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//____________________________________________________________________
241AliFMDBaseDigitizer::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//____________________________________________________________________
259AliFMDBaseDigitizer::~AliFMDBaseDigitizer()
260{
261 // Destructor
66d2ede1 262}
263
4347b38f 264//____________________________________________________________________
265Bool_t
266AliFMDBaseDigitizer::Init()
66d2ede1 267{
4347b38f 268 // Initialization
269 return kTRUE;
66d2ede1 270}
271
88cb7938 272
4347b38f 273//____________________________________________________________________
274void
275AliFMDBaseDigitizer::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//____________________________________________________________________
342void
343AliFMDBaseDigitizer::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//____________________________________________________________________
399void
400AliFMDBaseDigitizer::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 //
088f8e79 443 Float_t mipEnergy = 1.664 * siThickness * siDensity;
444 Float_t convF = (1/mipEnergy*Float_t(fAltroChannelSize)/fVA1MipRange);
445 UShort_t ped = MakePedestal();
e802be3e 446
447 // In case we don't oversample, just return the end value.
448 if (fSampleRate == 1) {
088f8e79 449 counts[0] = UShort_t(TMath::Min(edep * convF + ped,
e802be3e 450 Float_t(fAltroChannelSize)));
451 return;
452 }
088f8e79 453
4347b38f 454 // Create a pedestal
e802be3e 455 Int_t n = fSampleRate;
088f8e79 456 Float_t b = fShapingTime;
4347b38f 457 for (Ssiz_t i = 0; i < n; i++) {
e802be3e 458 Float_t t = Float_t(i) / n;
088f8e79 459 Float_t s = edep + (last - edep) * TMath::Exp(-b * t);
460 counts[i] = UShort_t(TMath::Min(s * convF + ped,
4347b38f 461 Float_t(fAltroChannelSize)));
462 }
463}
88cb7938 464
3d44ce66 465
4347b38f 466//====================================================================
925e6570 467ClassImp(AliFMDDigitizer)
66d2ede1 468
4347b38f 469//____________________________________________________________________
470AliFMDDigitizer::AliFMDDigitizer()
471 : AliFMDBaseDigitizer()
472{
473 // Default ctor - don't use it
474}
66d2ede1 475
4347b38f 476//____________________________________________________________________
477AliFMDDigitizer::AliFMDDigitizer(AliRunDigitizer* manager)
478 : AliFMDBaseDigitizer(manager)
479{
480 // Normal CTOR
481 AliDebug(1," processed");
482 SetPedestal();
483}
66d2ede1 484
4347b38f 485//____________________________________________________________________
486void
487AliFMDDigitizer::Exec(Option_t*)
488{
489 // Get the output manager
490 TString outFolder(fManager->GetOutputFolderName());
491 AliRunLoader* out =
492 AliRunLoader::GetRunLoader(outFolder.Data());
493 // Get the FMD output manager
494 AliLoader* outFMD = out->GetLoader("FMDLoader");
495
496 // Get the input loader
497 TString inFolder(fManager->GetInputFolderName(0));
498 fRunLoader =
a3537838 499 AliRunLoader::GetRunLoader(inFolder.Data());
4347b38f 500 if (!fRunLoader) {
501 AliError("Can not find Run Loader for input stream 0");
502 return;
503 }
504 // Get the AliRun object
505 if (!fRunLoader->GetAliRun()) fRunLoader->LoadgAlice();
506
507 // Get the AliFMD object
508 AliFMD* fmd = static_cast<AliFMD*>(fRunLoader->GetAliRun()->GetDetector("FMD"));
509 if (!fmd) {
510 AliError("Can not get FMD from gAlice");
511 return;
512 }
513
514 Int_t nFiles= fManager->GetNinputs();
515 for (Int_t inputFile = 0; inputFile < nFiles; inputFile++) {
516 AliDebug(1,Form(" Digitizing event number %d",
517 fManager->GetOutputEventNr()));
518 // Get the current loader
519 fRunLoader =
520 AliRunLoader::GetRunLoader(fManager->GetInputFolderName(inputFile));
521 if (!fRunLoader) Fatal("Exec", "no run loader");
522 // Cache contriutions
523 SumContributions(fmd);
524 }
525 // Digitize the event
526 DigitizeHits(fmd);
527
528 // Load digits from the tree
529 outFMD->LoadDigits("update");
530 // Get the tree of digits
531 TTree* digitTree = outFMD->TreeD();
532 if (!digitTree) {
533 outFMD->MakeTree("D");
534 digitTree = outFMD->TreeD();
535 }
536 digitTree->Reset();
537 // Make a branch in the tree
538 TClonesArray* digits = fmd->Digits();
539 fmd->MakeBranchInTree(digitTree, fmd->GetName(), &(digits), 4000, 0);
540 // TBranch* digitBranch = digitTree->GetBranch(fmd->GetName());
541 // Fill the tree
a1f80595 542 Int_t write = 0;
543 write = digitTree->Fill();
544 AliDebug(1, Form("Wrote %d bytes to digit tree", write));
66d2ede1 545
4347b38f 546 // Write the digits to disk
547 outFMD->WriteDigits("OVERWRITE");
548 outFMD->UnloadHits();
549 outFMD->UnloadDigits();
4110645f 550
4347b38f 551 // Reset the digits in the AliFMD object
552 fmd->ResetDigits();
553}
3d44ce66 554
88cb7938 555
4347b38f 556//____________________________________________________________________
557UShort_t
558AliFMDDigitizer::MakePedestal() const
559{
088f8e79 560 // Make a pedestal
4347b38f 561 return UShort_t(TMath::Max(gRandom->Gaus(fPedestal, fPedestalWidth), 0.));
562}
88cb7938 563
4347b38f 564//____________________________________________________________________
565void
566AliFMDDigitizer::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{
088f8e79 576 // Add a digit
69b696b9 577 fmd->AddDigitByFields(detector, ring, sector, strip, count1, count2, count3);
4347b38f 578}
3d44ce66 579
4347b38f 580//____________________________________________________________________
581void
582AliFMDDigitizer::CheckDigit(Float_t /* edep */,
583 UShort_t nhits,
584 const TArrayI& counts)
585{
088f8e79 586 // Check that digit is consistent
4347b38f 587 Int_t integral = counts[0];
588 if (counts[1] >= 0) integral += counts[1];
589 if (counts[2] >= 0) integral += counts[2];
590 integral -= Int_t(fPedestal + 2 * fPedestalWidth);
591 if (integral < 0) integral = 0;
592
088f8e79 593 Float_t convF = Float_t(fVA1MipRange) / fAltroChannelSize;
594 Float_t mips = integral * convF;
4347b38f 595 if (mips > Float_t(nhits) + .5 || mips < Float_t(nhits) - .5)
596 Warning("CheckDigit", "Digit -> %4.2f MIPS != %d +/- .5 hits",
597 mips, nhits);
598}
66d2ede1 599
4347b38f 600//====================================================================
925e6570 601ClassImp(AliFMDSDigitizer)
3d44ce66 602
4347b38f 603//____________________________________________________________________
604AliFMDSDigitizer::AliFMDSDigitizer()
605{
606 // Default ctor - don't use it
607}
88cb7938 608
4347b38f 609//____________________________________________________________________
610AliFMDSDigitizer::AliFMDSDigitizer(const Char_t* headerFile,
611 const Char_t* /* sdigfile */)
612 : AliFMDBaseDigitizer("FMDSDigitizer", "FMD SDigitizer")
613{
614 // Normal CTOR
615 AliDebug(1," processed");
3d44ce66 616
4347b38f 617 fRunLoader = AliRunLoader::GetRunLoader(); // Open(headerFile);
618 if (!fRunLoader)
619 Fatal("AliFMDSDigitizer", "cannot open session, header file '%s'",
620 headerFile);
621 AliLoader* loader = fRunLoader->GetLoader("FMDLoader");
622 if (!loader)
623 Fatal("AliFMDSDigitizer", "cannot find FMD loader in specified event");
3d44ce66 624
4347b38f 625 // Add task to tasks folder
626 loader->PostSDigitizer(this);
afddaa11 627
4347b38f 628}
88cb7938 629
4347b38f 630//____________________________________________________________________
631AliFMDSDigitizer::~AliFMDSDigitizer()
632{
088f8e79 633 // Destructor
4347b38f 634 AliLoader* loader = fRunLoader->GetLoader("FMDLoader");
635 loader->CleanSDigitizer();
636}
3d44ce66 637
4347b38f 638//____________________________________________________________________
639void
640AliFMDSDigitizer::Exec(Option_t*)
641{
642 // Get the output manager
643 if (!fRunLoader) {
644 Error("Exec", "Run loader is not set");
645 return;
646 }
647 if (!fRunLoader->GetAliRun()) fRunLoader->LoadgAlice();
648 if (!fRunLoader->TreeE()) fRunLoader->LoadHeader();
649
650 AliLoader* fmdLoader = fRunLoader->GetLoader("FMDLoader");
651 if (!fmdLoader) Fatal("Exec", "no FMD loader");
652
653 // Get the AliFMD object
654 AliFMD* fmd =
655 static_cast<AliFMD*>(fRunLoader->GetAliRun()->GetDetector("FMD"));
656 if (!fmd) {
657 AliError("Can not get FMD from gAlice");
658 return;
659 }
660
661 Int_t nEvents = Int_t(fRunLoader->TreeE()->GetEntries());
662 for (Int_t event = 0; event < nEvents; event++) {
663 AliDebug(1,Form(" Digitizing event number %d", event));
664 // Get the current loader
665 fRunLoader->GetEvent(event);
666
667 if (!fmdLoader->TreeS()) fmdLoader->MakeTree("S");
668 // Make a branch
669 fmd->MakeBranch("S");
670
671 // Cache contriutions
672 SumContributions(fmd);
673
674 // Digitize the event
675 DigitizeHits(fmd);
676
677 fmdLoader->TreeS()->Reset();
678 fmdLoader->TreeS()->Fill();
679 fmdLoader->WriteSDigits("OVERWRITE");
680 }
681}
66d2ede1 682
4347b38f 683//____________________________________________________________________
684void
685AliFMDSDigitizer::AddDigit(AliFMD* fmd,
686 UShort_t detector,
687 Char_t ring,
688 UShort_t sector,
689 UShort_t strip,
690 Float_t edep,
691 UShort_t count1,
692 Short_t count2,
693 Short_t count3) const
694{
088f8e79 695 // Add a summable digit
69b696b9 696 fmd->AddSDigitByFields(detector, ring, sector, strip, edep,
697 count1, count2, count3);
66d2ede1 698}
4347b38f 699
700
701
702//____________________________________________________________________
703//
704// EOF
705//
88cb7938 706
707
708
66d2ede1 709