1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //_________________________________________________________________________
20 //////////////////////////////////////////////////////////////////////////////
21 // Class performs digitization of Summable digits
23 // In addition it performs mixing of summable digits from different events.
25 // For each event two branches are created in TreeD:
26 // "EMCAL" - list of digits
27 // "AliEMCALDigitizer" - AliEMCALDigitizer with all parameters used in digitization
29 // Note, that one cset title for new digits branch, and repeat digitization with
30 // another set of parameters.
33 // root[0] AliEMCALDigitizer * d = new AliEMCALDigitizer() ;
34 // root[1] d->ExecuteTask()
35 // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
36 // //Digitizes SDigitis in all events found in file galice.root
38 // root[2] AliEMCALDigitizer * d1 = new AliEMCALDigitizer("galice1.root") ;
39 // // Will read sdigits from galice1.root
40 // root[3] d1->MixWith("galice2.root")
41 // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
42 // // Reads another portion of sdigits from galice2.root
43 // root[3] d1->MixWith("galice3.root")
44 // // Reads another portion of sdigits from galice3.root
45 // root[4] d->ExecuteTask("deb timing")
46 // // Reads SDigits from files galice1.root, galice2.root ....
47 // // mixes them and stores produced Digits in file galice1.root
48 // // deb - prints number of produced digits
49 // // deb all - prints list of produced digits
50 // // timing - prints time used for digitization
51 ////////////////////////////////////////////////////////////////////////////////////
53 //*-- Author: Sahal Yacoob (LBL)
54 // based on : AliEMCALDigitizer
56 // August 2002 Yves Schutz: clone PHOS as closely as possible and intoduction
57 // of new IO (à la PHOS)
58 // November 2003 Aleksei Pavlinov : adopted for Shish-Kebab geometry
59 //_________________________________________________________________________________
61 // --- ROOT system ---
65 #include <TBenchmark.h>
69 #include <TObjectTable.h>
73 // --- AliRoot header files ---
76 #include "AliRunDigitizer.h"
77 #include "AliRunLoader.h"
78 #include "AliCDBManager.h"
79 #include "AliCDBEntry.h"
80 #include "AliEMCALDigit.h"
82 #include "AliEMCALLoader.h"
83 #include "AliEMCALDigitizer.h"
84 #include "AliEMCALSDigitizer.h"
85 #include "AliEMCALGeometry.h"
86 #include "AliEMCALTick.h"
87 #include "AliEMCALHistoUtilities.h"
89 ClassImp(AliEMCALDigitizer)
92 //____________________________________________________________________________
93 AliEMCALDigitizer::AliEMCALDigitizer()
94 : AliDigitizer("",""),
102 fMeanPhotonElectron(0),
108 fTimeSignalLength(0),
112 fEventFolderName(""),
116 fHists(0),fCalibData(0x0)
120 fManager = 0 ; // We work in the standalong mode
123 //____________________________________________________________________________
124 AliEMCALDigitizer::AliEMCALDigitizer(TString alirunFileName, TString eventFolderName)
125 : AliDigitizer("EMCAL"+AliConfig::Instance()->GetDigitizerTaskName(), alirunFileName),
126 fDefaultInit(kFALSE),
133 fMeanPhotonElectron(0),
139 fTimeSignalLength(0),
143 fEventFolderName(eventFolderName),
147 fHists(0),fCalibData(0x0)
152 fManager = 0 ; // We work in the standalong mode
155 //____________________________________________________________________________
156 AliEMCALDigitizer::AliEMCALDigitizer(const AliEMCALDigitizer & d)
157 : AliDigitizer(d.GetName(),d.GetTitle()),
158 fDefaultInit(d.fDefaultInit),
159 fDigitsInRun(d.fDigitsInRun),
162 fInputFileNames(d.fInputFileNames),
163 fEventNames(d.fEventNames),
164 fDigitThreshold(d.fDigitThreshold),
165 fMeanPhotonElectron(d.fMeanPhotonElectron),
166 fPedestal(d.fPedestal),
168 fPinNoise(d.fPinNoise),
169 fTimeResolution(d.fTimeResolution),
170 fTimeThreshold(d.fTimeThreshold),
171 fTimeSignalLength(d.fTimeSignalLength),
172 fADCchannelEC(d.fADCchannelEC),
173 fADCpedestalEC(d.fADCpedestalEC),
175 fEventFolderName(d.fEventFolderName),
176 fFirstEvent(d.fFirstEvent),
177 fLastEvent(d.fLastEvent),
178 fControlHists(d.fControlHists),
179 fHists(d.fHists),fCalibData(d.fCalibData)
184 //____________________________________________________________________________
185 AliEMCALDigitizer::AliEMCALDigitizer(AliRunDigitizer * rd)
186 : AliDigitizer(rd,"EMCAL"+AliConfig::Instance()->GetDigitizerTaskName()),
187 fDefaultInit(kFALSE),
194 fMeanPhotonElectron(0),
200 fTimeSignalLength(0),
208 fHists(0),fCalibData(0x0)
210 // ctor Init() is called by RunDigitizer
212 fEventFolderName = fManager->GetInputFolderName(0) ;
213 SetTitle(dynamic_cast<AliStream*>(fManager->GetInputStream(0))->GetFileName(0));
217 //____________________________________________________________________________
218 AliEMCALDigitizer::~AliEMCALDigitizer()
221 if (AliRunLoader::GetRunLoader()) {
222 AliLoader *emcalLoader=0;
223 if ((emcalLoader = AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL")))
224 emcalLoader->CleanDigitizer();
227 AliDebug(1," no runloader present");
228 delete [] fInputFileNames ;
229 delete [] fEventNames ;
231 if(fHists) delete fHists;
234 //____________________________________________________________________________
235 void AliEMCALDigitizer::Digitize(Int_t event)
238 // Makes the digitization of the collected summable digits
239 // for this it first creates the array of all EMCAL modules
240 // filled with noise (different for EMC, CPV and PPSD) and
241 // after that adds contributions from SDigits. This design
242 // helps to avoid scanning over the list of digits to add
243 // contribution of any new SDigit.
244 static int nEMC=0; //max number of digits possible
246 AliRunLoader *rl = AliRunLoader::GetRunLoader();
247 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(rl->GetDetectorLoader("EMCAL"));
248 Int_t readEvent = event ;
249 // fManager is data member from AliDigitizer
251 readEvent = dynamic_cast<AliStream*>(fManager->GetInputStream(0))->GetCurrentEventNumber() ;
252 AliDebug(1,Form("Adding event %d from input stream 0 %s %s",
253 readEvent, GetTitle(), fEventFolderName.Data())) ;
254 rl->GetEvent(readEvent);
256 TClonesArray * digits = emcalLoader->Digits() ;
260 AliEMCALGeometry *geom = 0;
261 if (rl->GetAliRun()) {
262 AliEMCAL * emcal = (AliEMCAL*)rl->GetAliRun()->GetDetector("EMCAL");
263 geom = emcal->GetGeometry();
266 AliFatal("Could not get AliRun from runLoader");
268 nEMC = geom->GetNCells();
269 AliDebug(1,Form("nEMC %i (number cells in EMCAL) | %s \n", nEMC, geom->GetName()));
273 digits->Expand(nEMC) ;
275 // get first the sdigitizer from the tasks list (must have same name as the digitizer)
276 if ( !emcalLoader->SDigitizer() )
277 emcalLoader->LoadSDigitizer();
278 AliEMCALSDigitizer * sDigitizer = dynamic_cast<AliEMCALSDigitizer*>(emcalLoader->SDigitizer());
281 Fatal("Digitize", "SDigitizer with name %s %s not found", fEventFolderName.Data(), GetTitle() ) ;
283 //take all the inputs to add together and load the SDigits
284 TObjArray * sdigArray = new TObjArray(fInput) ;
285 sdigArray->AddAt(emcalLoader->SDigits(), 0) ;
288 for(i = 1 ; i < fInput ; i++){
289 TString tempo(fEventNames[i]) ;
292 AliRunLoader * rl2 = AliRunLoader::GetRunLoader(tempo) ;
295 rl2 = AliRunLoader::Open(fInputFileNames[i], tempo) ;
298 readEvent = dynamic_cast<AliStream*>(fManager->GetInputStream(i))->GetCurrentEventNumber() ;
299 Info("Digitize", "Adding event %d from input stream %d %s %s", readEvent, i, fInputFileNames[i].Data(), tempo.Data()) ;
301 rl2->GetEvent(readEvent);
302 AliEMCALLoader *emcalLoader2 = dynamic_cast<AliEMCALLoader*>(rl2->GetDetectorLoader("EMCAL"));
303 sdigArray->AddAt(emcalLoader2->SDigits(), i) ;
306 //Find the first tower with signal
307 Int_t nextSig = nEMC + 1 ;
308 TClonesArray * sdigits ;
309 for(i = 0 ; i < fInput ; i++){
310 sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
311 if ( !sdigits->GetEntriesFast() )
313 Int_t curNext = dynamic_cast<AliEMCALDigit *>(sdigits->At(0))->GetId() ;
314 if(curNext < nextSig)
316 AliDebug(1,Form("input %i : #sdigits %i \n",
317 i, sdigits->GetEntriesFast()));
319 AliDebug(1,Form("FIRST tower with signal %i \n", nextSig));
321 TArrayI index(fInput) ;
322 index.Reset() ; //Set all indexes to zero
324 AliEMCALDigit * digit ;
325 AliEMCALDigit * curSDigit ;
327 TClonesArray * ticks = new TClonesArray("AliEMCALTick",1000) ;
329 //Put Noise contribution
330 for(absID = 0; absID < nEMC; absID++){ // Nov 30, 2006 by PAI; was from 1 to nEMC
332 // amplitude set to zero, noise will be added later
333 new((*digits)[absID]) AliEMCALDigit( -1, -1, absID, 0, TimeOfNoise() ); // absID-1->absID
334 //look if we have to add signal?
335 digit = dynamic_cast<AliEMCALDigit *>(digits->At(absID)); // absID-1->absID
338 //Add SDigits from all inputs
341 Float_t a = digit->GetAmp() ;
342 Float_t b = TMath::Abs( a /fTimeSignalLength) ;
343 //Mark the beginning of the signal
344 new((*ticks)[contrib++]) AliEMCALTick(digit->GetTime(),0, b);
345 //Mark the end of the signal
346 new((*ticks)[contrib++]) AliEMCALTick(digit->GetTime()+fTimeSignalLength, -a, -b);
349 for(i = 0; i< fInput ; i++){ //loop over (possible) merge sources
350 if(dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
351 curSDigit = dynamic_cast<AliEMCALDigit*>(dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;
354 //May be several digits will contribute from the same input
355 while(curSDigit && (curSDigit->GetId() == absID)){
356 //Shift primary to separate primaries belonging different inputs
357 Int_t primaryoffset ;
359 primaryoffset = fManager->GetMask(i) ;
362 curSDigit->ShiftPrimary(primaryoffset) ;
364 a = curSDigit->GetAmp() ;
365 b = a /fTimeSignalLength ;
366 new((*ticks)[contrib++]) AliEMCALTick(curSDigit->GetTime(),0, b);
367 new((*ticks)[contrib++]) AliEMCALTick(curSDigit->GetTime()+fTimeSignalLength, -a, -b);
369 *digit = *digit + *curSDigit ; //add energies
372 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
373 curSDigit = dynamic_cast<AliEMCALDigit*>(dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;
378 // add fluctuations for photo-electron creation
379 amp = sDigitizer->Calibrate(digit->GetAmp()) ; // GeV
380 amp *= static_cast<Float_t>(gRandom->Poisson(fMeanPhotonElectron)) / static_cast<Float_t>(fMeanPhotonElectron) ;
382 //calculate and set time
383 Float_t time = FrontEdgeTime(ticks) ;
384 digit->SetTime(time) ;
386 //Find next signal module
388 for(i = 0 ; i < fInput ; i++){
389 sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
390 Int_t curNext = nextSig ;
391 if(sdigits->GetEntriesFast() > index[i] ){
392 curNext = dynamic_cast<AliEMCALDigit *>(sdigits->At(index[i]))->GetId() ;
394 if(curNext < nextSig) nextSig = curNext ;
398 amp += TMath::Abs(gRandom->Gaus(0., fPinNoise)) ;
399 digit->SetAmp(sDigitizer->Digitize(amp)) ;
400 AliDebug(10,Form(" absID %5i amp %f nextSig %5i\n",
401 absID, amp, nextSig));
402 } // for(absID = 1; absID <= nEMC; absID++)
407 delete sdigArray ; //We should not delete its contents
409 //remove digits below thresholds
410 for(i = 0 ; i < nEMC ; i++){
411 digit = dynamic_cast<AliEMCALDigit*>( digits->At(i) ) ;
412 Float_t threshold = fDigitThreshold ;
413 if(sDigitizer->Calibrate( digit->GetAmp() ) < threshold)
414 digits->RemoveAt(i) ;
416 digit->SetTime(gRandom->Gaus(digit->GetTime(),fTimeResolution) ) ;
421 Int_t ndigits = digits->GetEntriesFast() ;
423 //Set indexes in list of digits and fill hists.
424 AliEMCALHistoUtilities::FillH1(fHists, 0, Double_t(ndigits));
425 Float_t energy=0., esum=0.;
426 for (i = 0 ; i < ndigits ; i++) {
427 digit = dynamic_cast<AliEMCALDigit *>( digits->At(i) ) ;
428 digit->SetIndexInList(i) ;
429 energy = sDigitizer->Calibrate(digit->GetAmp()) ;
431 digit->SetAmp(DigitizeEnergy(energy, digit->GetId()) ) ; // for what ??
432 AliEMCALHistoUtilities::FillH1(fHists, 2, double(digit->GetAmp()));
433 AliEMCALHistoUtilities::FillH1(fHists, 3, double(energy));
434 AliEMCALHistoUtilities::FillH1(fHists, 4, double(digit->GetId()));
435 // if(digit->GetId() == nEMC) {
436 // printf(" i %i \n", i );
441 AliEMCALHistoUtilities::FillH1(fHists, 1, esum);
444 // //_____________________________________________________________________
445 Int_t AliEMCALDigitizer::DigitizeEnergy(Float_t energy, Int_t AbsId)
447 // Returns digitized value of the energy in a cell absId
450 const AliEMCALGeometry * geom = AliEMCALGeometry::GetInstance();
453 AliFatal("Did not get geometry from EMCALLoader");
461 Int_t channel = -999;
463 Bool_t bCell = geom->GetCellIndex(AbsId, iSupMod, nModule, nIphi, nIeta) ;
465 Error("DigitizeEnergy","Wrong cell id number : AbsId %i ", AbsId) ;
466 geom->GetCellPhiEtaIndexInSModule(iSupMod,nModule,nIphi, nIeta,iphi,ieta);
469 fADCpedestalEC = fCalibData->GetADCpedestal(iSupMod,ieta,iphi);
470 fADCchannelEC = fCalibData->GetADCchannel(iSupMod,ieta,iphi);
473 channel = static_cast<Int_t> (TMath::Ceil( (energy + fADCpedestalEC)/fADCchannelEC )) ;
475 if(channel > fNADCEC )
481 //____________________________________________________________________________
482 void AliEMCALDigitizer::Exec(Option_t *option)
484 // Steering method to process digitization for events
485 // in the range from fFirstEvent to fLastEvent.
486 // This range is optionally set by SetEventRange().
487 // if fLastEvent=-1, then process events until the end.
488 // by default fLastEvent = fFirstEvent (process only one event)
490 if (!fInit) { // to prevent overwrite existing file
491 Error( "Exec", "Give a version name different from %s", fEventFolderName.Data() ) ;
495 if (strstr(option,"print")) {
501 if(strstr(option,"tim"))
502 gBenchmark->Start("EMCALDigitizer");
504 AliRunLoader *rl = AliRunLoader::GetRunLoader();
505 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(rl->GetDetectorLoader("EMCAL"));
507 // Post Digitizer to the white board
508 emcalLoader->PostDigitizer(this) ;
510 if (fLastEvent == -1) {
511 fLastEvent = rl->GetNumberOfEvents() - 1 ;
514 fLastEvent = fFirstEvent ; // what is this ??
516 Int_t nEvents = fLastEvent - fFirstEvent + 1;
519 rl->LoadSDigits("EMCAL");
520 for (ievent = fFirstEvent; ievent <= fLastEvent; ievent++) {
522 rl->GetEvent(ievent);
524 Digitize(ievent) ; //Add prepared SDigits to digits and add the noise
528 if(strstr(option,"deb"))
530 if(strstr(option,"table")) gObjectTable->Print();
532 //increment the total number of Digits per run
533 fDigitsInRun += emcalLoader->Digits()->GetEntriesFast() ;
536 emcalLoader->CleanDigitizer() ;
538 if(strstr(option,"tim")){
539 gBenchmark->Stop("EMCALDigitizer");
540 AliInfo(Form("Exec: took %f seconds for Digitizing %f seconds per event",
541 gBenchmark->GetCpuTime("EMCALDigitizer"), gBenchmark->GetCpuTime("EMCALDigitizer")/nEvents )) ;
545 //____________________________________________________________________________
546 Float_t AliEMCALDigitizer::FrontEdgeTime(TClonesArray * ticks)
548 // Returns the shortest time among all time ticks
550 ticks->Sort() ; //Sort in accordance with times of ticks
552 AliEMCALTick * ctick = (AliEMCALTick *) it.Next() ;
553 Float_t time = ctick->CrossingTime(fTimeThreshold) ;
556 while((t=(AliEMCALTick*) it.Next())){
557 if(t->GetTime() < time) //This tick starts before crossing
562 time = ctick->CrossingTime(fTimeThreshold) ;
567 //____________________________________________________________________________
568 Bool_t AliEMCALDigitizer::Init()
570 // Makes all memory allocations
572 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL"));
574 if ( emcalLoader == 0 ) {
575 Fatal("Init", "Could not obtain the AliEMCALLoader");
580 fLastEvent = fFirstEvent ;
583 fInput = fManager->GetNinputs() ;
587 fInputFileNames = new TString[fInput] ;
588 fEventNames = new TString[fInput] ;
589 fInputFileNames[0] = GetTitle() ;
590 fEventNames[0] = fEventFolderName.Data() ;
592 for (index = 1 ; index < fInput ; index++) {
593 fInputFileNames[index] = dynamic_cast<AliStream*>(fManager->GetInputStream(index))->GetFileName(0);
594 TString tempo = fManager->GetInputFolderName(index) ;
595 fEventNames[index] = tempo.Remove(tempo.Length()-1) ; // strip of the stream number added bt fManager
598 //to prevent cleaning of this object while GetEvent is called
599 emcalLoader->GetDigitsDataLoader()->GetBaseTaskLoader()->SetDoNotReload(kTRUE);
602 //Calibration instance
603 fCalibData = emcalLoader->CalibData();
607 //____________________________________________________________________________
608 void AliEMCALDigitizer::InitParameters()
610 // Parameter initialization for digitizer
611 // Tune parameters - 24-nov-04; Apr 29, 2007
612 // New parameters JLK 14-Apr-2008
614 fMeanPhotonElectron = 4400; // electrons per GeV
615 fPinNoise = 0.037; // pin noise in GEV from analysis test beam data
616 if (fPinNoise == 0. )
617 Warning("InitParameters", "No noise added\n") ;
618 fDigitThreshold = fPinNoise * 3; // 3 * sigma
619 fTimeResolution = 0.3e-9 ; // 300 psc
620 fTimeSignalLength = 1.0e-9 ;
622 // These defaults are normally not used.
623 // Values are read from calibration database instead
624 fADCchannelEC = 0.0153; // Update 24 Apr 2007: 250./16/1024 - width of one ADC channel in GeV
625 fADCpedestalEC = 0.0 ; // GeV
626 fNADCEC = (Int_t) TMath::Power(2,16) ; // number of channels in Tower ADC - 65536
628 fTimeThreshold = 0.001*10000000 ; // Means 1 MeV in terms of SDigits amplitude ??
629 // hists. for control; no hists on default
634 //__________________________________________________________________
635 void AliEMCALDigitizer::MixWith(TString alirunFileName, TString eventFolderName)
637 // Allows to produce digits by superimposing background and signal event.
638 // It is assumed, that headers file with SIGNAL events is opened in
640 // Sets the BACKGROUND event, with which the SIGNAL event is to be mixed
641 // Thus we avoid writing (changing) huge and expensive
642 // backgound files: all output will be writen into SIGNAL, i.e.
643 // opened in constructor file.
645 // One can open as many files to mix with as one needs.
646 // However only Sdigits with the same name (i.e. constructed with the same SDigitizer)
649 if( strcmp(GetName(), "") == 0 )
653 Error("MixWith", "Cannot use this method under AliRunDigitizer") ;
656 // looking for file which contains AliRun
657 if (gSystem->AccessPathName(alirunFileName)) {// file does not exist
658 Error("MixWith", "File %s does not exist!", alirunFileName.Data()) ;
661 // looking for the file which contains SDigits
662 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL"));
663 TString fileName( emcalLoader->GetSDigitsFileName() ) ;
664 if ( eventFolderName != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
665 fileName = fileName.ReplaceAll(".root", "") + "_" + eventFolderName + ".root" ;
666 if ( (gSystem->AccessPathName(fileName)) ) {
667 Error("MixWith", "The file %s does not exist!", fileName.Data()) ;
670 // need to increase the arrays
671 // MvL: This code only works when fInput == 1, I think.
672 TString tempo = fInputFileNames[fInput-1] ;
673 delete [] fInputFileNames ;
674 fInputFileNames = new TString[fInput+1] ;
675 fInputFileNames[fInput-1] = tempo ;
677 tempo = fEventNames[fInput-1] ;
678 delete [] fEventNames ;
679 fEventNames = new TString[fInput+1] ;
680 fEventNames[fInput-1] = tempo ;
682 fInputFileNames[fInput] = alirunFileName ;
683 fEventNames[fInput] = eventFolderName ;
687 //__________________________________________________________________
688 void AliEMCALDigitizer::Print1(Option_t * option)
689 { // 19-nov-04 - just for convinience
694 //__________________________________________________________________
695 void AliEMCALDigitizer::Print(Option_t*)const
697 // Print Digitizer's parameters
698 printf("Print: \n------------------- %s -------------", GetName() ) ;
699 if( strcmp(fEventFolderName.Data(), "") != 0 ){
700 printf(" Writing Digits to branch with title %s\n", fEventFolderName.Data()) ;
704 nStreams = GetNInputStreams() ;
712 for (index = 0 ; index < nStreams ; index++) {
713 TString tempo(fEventNames[index]) ;
715 if ((rl = AliRunLoader::GetRunLoader(tempo)) == 0)
716 rl = AliRunLoader::Open(fInputFileNames[index], tempo) ;
717 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(rl->GetDetectorLoader("EMCAL"));
718 TString fileName( emcalLoader->GetSDigitsFileName() ) ;
719 if ( fEventNames[index] != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
720 fileName = fileName.ReplaceAll(".root", "") + "_" + fEventNames[index] + ".root" ;
721 printf ("Adding SDigits from %s %s\n", fInputFileNames[index].Data(), fileName.Data()) ;
724 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL"));
726 printf("\nWriting digits to %s", emcalLoader->GetDigitsFileName().Data()) ;
728 printf("\nWith following parameters:\n") ;
730 printf(" Electronics noise in EMC (fPinNoise) = %f\n", fPinNoise) ;
731 printf(" Threshold in EMC (fDigitThreshold) = %f\n", fDigitThreshold) ;
732 printf("---------------------------------------------------\n") ;
735 printf("Print: AliEMCALDigitizer not initialized") ;
738 //__________________________________________________________________
739 void AliEMCALDigitizer::PrintDigits(Option_t * option)
741 //utility method for printing digit information
743 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL"));
744 TClonesArray * digits = emcalLoader->Digits() ;
745 TClonesArray * sdigits = emcalLoader->SDigits() ;
747 printf("\n #Digits: %d : sdigits %d ", digits->GetEntriesFast(), sdigits->GetEntriesFast()) ;
748 printf("\n event %d", emcalLoader->GetRunLoader()->GetEventNumber());
750 if(strstr(option,"all")){
752 AliEMCALDigit * digit;
753 printf("\nEMC digits (with primaries):\n") ;
754 printf("\n Id Amplitude Time Index Nprim: Primaries list \n") ;
756 for (index = 0 ; index < digits->GetEntries() ; index++) {
757 digit = dynamic_cast<AliEMCALDigit *>(digits->At(index)) ;
758 printf("\n%6d %8d %6.5e %4d %2d : ",
759 digit->GetId(), digit->GetAmp(), digit->GetTime(), digit->GetIndexInList(), digit->GetNprimary()) ;
761 for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) {
762 printf("%d ",digit->GetPrimary(iprimary+1) ) ;
769 //__________________________________________________________________
770 Float_t AliEMCALDigitizer::TimeOfNoise(void)
772 // Calculates the time signal generated by noise
773 //PH Info("TimeOfNoise", "Change me") ;
774 return gRandom->Rndm() * 1.28E-5;
777 //__________________________________________________________________
778 void AliEMCALDigitizer::Unload()
780 // Unloads the SDigits and Digits
784 for(i = 1 ; i < fInput ; i++){
785 TString tempo(fEventNames[i]) ;
787 if ((rl = AliRunLoader::GetRunLoader(tempo)))
788 rl->GetDetectorLoader("EMCAL")->UnloadSDigits() ;
790 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL"));
791 emcalLoader->UnloadDigits() ;
794 //_________________________________________________________________________________________
795 void AliEMCALDigitizer::WriteDigits()
798 // Makes TreeD in the output file.
799 // Check if branch already exists:
800 // if yes, exit without writing: ROOT TTree does not support overwriting/updating of
801 // already existing branches.
802 // else creates branch with Digits, named "EMCAL", title "...",
803 // and branch "AliEMCALDigitizer", with the same title to keep all the parameters
804 // and names of files, from which digits are made.
806 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL"));
808 const TClonesArray * digits = emcalLoader->Digits() ;
809 TTree * treeD = emcalLoader->TreeD();
811 emcalLoader->MakeDigitsContainer();
812 treeD = emcalLoader->TreeD();
815 // -- create Digits branch
816 Int_t bufferSize = 32000 ;
817 TBranch * digitsBranch = 0;
818 if ((digitsBranch = treeD->GetBranch("EMCAL"))) {
819 digitsBranch->SetAddress(&digits);
820 AliWarning("Digits Branch already exists. Not all digits will be visible");
823 treeD->Branch("EMCAL","TClonesArray",&digits,bufferSize);
824 //digitsBranch->SetTitle(fEventFolderName);
827 emcalLoader->WriteDigits("OVERWRITE");
828 emcalLoader->WriteDigitizer("OVERWRITE");
834 //__________________________________________________________________
835 void AliEMCALDigitizer::Browse(TBrowser* b)
837 if(fHists) b->Add(fHists);
841 //__________________________________________________________________
842 TList *AliEMCALDigitizer::BookControlHists(int var)
845 // histograms for monitoring digitizer performance
847 Info("BookControlHists"," started ");
849 const AliEMCALGeometry *geom = AliEMCALGeometry::GetInstance();
851 new TH1F("hDigiN", "#EMCAL digits with fAmp > fDigitThreshold",
852 fNADCEC+1, -0.5, Double_t(fNADCEC));
853 new TH1F("HDigiSumEnergy","Sum.EMCAL energy from digi", 1000, 0.0, 200.);
854 new TH1F("hDigiAmp", "EMCAL digital amplitude", fNADCEC+1, -0.5, Double_t(fNADCEC));
855 new TH1F("hDigiEnergy","EMCAL cell energy", 2000, 0.0, 200.);
856 new TH1F("hDigiAbsId","EMCAL absId cells with fAmp > fDigitThreshold ",
857 geom->GetNCells(), 0.5, Double_t(geom->GetNCells())+0.5);
860 fHists = AliEMCALHistoUtilities::MoveHistsToList("EmcalDigiControlHists", kFALSE);
861 fHists = 0; //huh? JLK 03-Mar-2006
865 //__________________________________________________________________
866 void AliEMCALDigitizer::SaveHists(const char* name, Bool_t kSingleKey, const char* opt)
868 AliEMCALHistoUtilities::SaveListOfHists(fHists, name, kSingleKey, opt);