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 //_________________________________________________________________________
19 // A singleton. This class should be used in the analysis stage to get
20 // reconstructed objects: Digits, RecPoints, TrackSegments and RecParticles,
21 // instead of directly reading them from galice.root file. This container
22 // ensures, that one reads Digits, made of these particular digits, RecPoints,
23 // made of these particular RecPoints, TrackSegments and RecParticles.
24 // This becomes non trivial if there are several identical branches, produced with
25 // different set of parameters.
27 // An example of how to use (see also class AliPHOSAnalyser):
28 // AliPHOSGetter * gime = AliPHOSGetter::GetInstance("galice.root","test") ;
29 // for(Int_t irecp = 0; irecp < gime->NRecParticles() ; irecp++)
30 // AliPHOSRecParticle * part = gime->RecParticle(1) ;
32 // gime->Event(event) ; // reads new event from galice.root
34 //*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
35 //*-- Completely redesigned by Dmitri Peressounko March 2001
37 //*-- YS June 2001 : renamed the original AliPHOSIndexToObject and make
38 //*-- systematic usage of TFolders without changing the interface
39 //////////////////////////////////////////////////////////////////////////////
41 // --- ROOT system ---
46 #include <TParticle.h>
53 // --- Standard library ---
55 // --- AliRoot header files ---
57 #include "AliHeader.h"
60 #include "AliPHOSBeamTestEvent.h"
61 #include "AliPHOSGetter.h"
62 #include "AliPHOSLoader.h"
63 #include "AliPHOSPulseGenerator.h"
64 #include "AliRunLoader.h"
66 #include "AliCaloRawStream.h"
67 #include "AliRawReaderFile.h"
69 #include "AliCDBLocal.h"
70 #include "AliCDBStorage.h"
71 #include "AliCDBManager.h"
73 ClassImp(AliPHOSGetter)
75 AliPHOSGetter * AliPHOSGetter::fgObjGetter = 0 ;
76 AliPHOSLoader * AliPHOSGetter::fgPhosLoader = 0;
77 AliPHOSCalibData* AliPHOSGetter::fgCalibData = 0;
78 Int_t AliPHOSGetter::fgDebug = 0;
80 // TFile * AliPHOSGetter::fgFile = 0 ;
82 AliPHOSGetter::AliPHOSGetter() :
94 // ctor: this is a singleton, the ctor should never be called but cint needs it as public
95 Fatal("ctor", "AliPHOSGetter is a singleton default ctor not callable") ;
99 //____________________________________________________________________________
100 AliPHOSGetter::AliPHOSGetter(const char* headerFile, const char* version, Option_t * openingOption) :
112 // ctor only called by Instance()
114 AliRunLoader* rl = AliRunLoader::GetRunLoader(version) ;
116 rl = AliRunLoader::Open(headerFile, version, openingOption);
118 Fatal("AliPHOSGetter", "Could not find the Run Loader for %s - %s",headerFile, version) ;
121 if (rl->GetAliRun() == 0x0) {
123 gAlice = rl->GetAliRun(); // should be removed
127 fgPhosLoader = dynamic_cast<AliPHOSLoader*>(rl->GetLoader("PHOSLoader"));
129 Error("AliPHOSGetter", "Could not find PHOSLoader") ;
131 fgPhosLoader->SetTitle(version);
133 // initialize data members
137 fLoadingStatus = "" ;
139 fESDFileName = rl->GetFileName() ; // this should be the galice.root file
140 fESDFileName.ReplaceAll("galice.root", "AliESDs.root") ;
144 fRawDigits = kFALSE ;
148 AliPHOSGetter::AliPHOSGetter(const AliPHOSGetter & obj) :
161 // cpy ctor requested by Coding Convention
162 Fatal("cpy ctor", "not implemented") ;
165 //____________________________________________________________________________
166 AliPHOSGetter::AliPHOSGetter(Int_t /*i*/) :
178 // special constructor for onflight
182 //____________________________________________________________________________
183 AliPHOSGetter::~AliPHOSGetter()
187 delete fgPhosLoader ;
195 fPrimaries->Delete() ;
206 //____________________________________________________________________________
207 void AliPHOSGetter::Reset()
209 // resets things in case the getter is called consecutively with different files
210 // the PHOS Loader is already deleted by the Run Loader
213 fPrimaries->Delete() ;
220 //____________________________________________________________________________
221 AliPHOSClusterizer * AliPHOSGetter::Clusterizer()
223 // Returns pointer to the Clusterizer task
224 AliPHOSClusterizer * rv ;
225 rv = dynamic_cast<AliPHOSClusterizer *>(PhosLoader()->Reconstructioner()) ;
228 rv = dynamic_cast<AliPHOSClusterizer*>(PhosLoader()->Reconstructioner()) ;
233 //____________________________________________________________________________
234 TObjArray * AliPHOSGetter::CpvRecPoints() const
236 // asks the Loader to return the CPV RecPoints container
240 rv = PhosLoader()->CpvRecPoints() ;
242 PhosLoader()->MakeRecPointsArray() ;
243 rv = PhosLoader()->CpvRecPoints() ;
248 //____________________________________________________________________________
249 TClonesArray * AliPHOSGetter::Digits() const
251 // asks the Loader to return the Digits container
253 TClonesArray * rv = 0 ;
254 rv = PhosLoader()->Digits() ;
257 PhosLoader()->MakeDigitsArray() ;
258 rv = PhosLoader()->Digits() ;
263 //____________________________________________________________________________
264 AliPHOSDigitizer * AliPHOSGetter::Digitizer()
266 // Returns pointer to the Digitizer task
267 AliPHOSDigitizer * rv ;
268 rv = dynamic_cast<AliPHOSDigitizer *>(PhosLoader()->Digitizer()) ;
271 rv = dynamic_cast<AliPHOSDigitizer *>(PhosLoader()->Digitizer()) ;
277 //____________________________________________________________________________
278 TObjArray * AliPHOSGetter::EmcRecPoints() const
280 // asks the Loader to return the EMC RecPoints container
284 rv = PhosLoader()->EmcRecPoints() ;
286 PhosLoader()->MakeRecPointsArray() ;
287 rv = PhosLoader()->EmcRecPoints() ;
292 //____________________________________________________________________________
293 TClonesArray * AliPHOSGetter::TrackSegments() const
295 // asks the Loader to return the TrackSegments container
297 TClonesArray * rv = 0 ;
299 rv = PhosLoader()->TrackSegments() ;
301 PhosLoader()->MakeTrackSegmentsArray() ;
302 rv = PhosLoader()->TrackSegments() ;
307 //____________________________________________________________________________
308 AliPHOSTrackSegmentMaker * AliPHOSGetter::TrackSegmentMaker()
310 // Returns pointer to the TrackSegmentMaker task
311 AliPHOSTrackSegmentMaker * rv ;
312 rv = dynamic_cast<AliPHOSTrackSegmentMaker *>(PhosLoader()->TrackSegmentMaker()) ;
315 rv = dynamic_cast<AliPHOSTrackSegmentMaker *>(PhosLoader()->TrackSegmentMaker()) ;
320 //____________________________________________________________________________
321 TClonesArray * AliPHOSGetter::RecParticles() const
323 // asks the Loader to return the TrackSegments container
325 TClonesArray * rv = 0 ;
327 rv = PhosLoader()->RecParticles() ;
329 PhosLoader()->MakeRecParticlesArray() ;
330 rv = PhosLoader()->RecParticles() ;
334 //____________________________________________________________________________
335 void AliPHOSGetter::Event(Int_t event, const char* opt)
337 // Reads the content of all Tree's S, D and R
339 // if ( event >= MaxEvent() ) {
340 // Error("Event", "%d not found in TreeE !", event) ;
344 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
346 // // checks if we are dealing with test-beam data
347 // TBranch * btb = rl->TreeE()->GetBranch("AliPHOSBeamTestEvent") ;
350 // fBTE = new AliPHOSBeamTestEvent() ;
351 // btb->SetAddress(&fBTE) ;
352 // btb->GetEntry(event) ;
361 // Loads the type of object(s) requested
363 rl->GetEvent(event) ;
365 if(strstr(opt,"X") || (strcmp(opt,"")==0)){
369 if(strstr(opt,"H") ){
373 if(strstr(opt,"S") ){
377 if(strstr(opt,"D") ){
381 if(strstr(opt,"R") ){
385 if( strstr(opt,"T") ){
389 if( strstr(opt,"P") ){
393 if( strstr(opt,"E") ){
400 //____________________________________________________________________________
401 void AliPHOSGetter::Event(AliRawReader *rawReader, const char* opt, Bool_t isOldRCUFormat)
403 // Reads the raw event from rawReader
404 // isOldRCUFormat defines whenever to assume
405 // the old RCU format or not
407 if( strstr(opt,"W") ){
408 rawReader->NextEvent();
409 ReadRaw(rawReader,isOldRCUFormat) ;
415 //____________________________________________________________________________
416 Int_t AliPHOSGetter::EventNumber() const
418 // return the current event number
419 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
420 return static_cast<Int_t>(rl->GetEventNumber()) ;
423 //____________________________________________________________________________
424 TClonesArray * AliPHOSGetter::Hits() const
426 // asks the loader to return the Hits container
428 TClonesArray * rv = 0 ;
430 rv = PhosLoader()->Hits() ;
432 PhosLoader()->LoadHits("read");
433 rv = PhosLoader()->Hits() ;
438 //____________________________________________________________________________
439 AliPHOSGetter * AliPHOSGetter::Instance(const char* alirunFileName, const char* version, Option_t * openingOption)
441 // Creates and returns the pointer of the unique instance
442 // Must be called only when the environment has changed
444 if(!fgObjGetter){ // first time the getter is called
445 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
447 else { // the getter has been called previously
448 AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle());
449 if ( rl->GetFileName() == alirunFileName ) {// the alirunFile has the same name
450 // check if the file is already open
451 TFile * galiceFile = dynamic_cast<TFile *>(gROOT->FindObject(rl->GetFileName()) ) ;
454 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
456 else { // the file is already open check the version name
457 TString currentVersionName = rl->GetEventFolder()->GetName() ;
458 TString newVersionName(version) ;
459 if (currentVersionName == newVersionName)
461 ::Warning( "Instance", "Files with version %s already open", currentVersionName.Data() ) ;
463 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
468 AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle()) ;
469 if ( strstr(version, AliConfig::GetDefaultEventFolderName()) ) // false in case of merging
471 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
475 ::Error("AliPHOSGetter::Instance", "Failed to create the PHOS Getter object") ;
483 //____________________________________________________________________________
484 AliPHOSGetter * AliPHOSGetter::Instance()
486 // Returns the pointer of the unique instance already defined
488 if(!fgObjGetter && fgDebug)
489 ::Warning("AliPHOSGetter::Instance", "Getter not initialized") ;
495 //____________________________________________________________________________
496 Int_t AliPHOSGetter::MaxEvent() const
498 // returns the number of events in the run (from TE)
500 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
501 return static_cast<Int_t>(rl->GetNumberOfEvents()) ;
504 //____________________________________________________________________________
505 TParticle * AliPHOSGetter::Primary(Int_t index) const
507 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
508 return rl->Stack()->Particle(index) ;
511 //____________________________________________________________________________
512 AliPHOS * AliPHOSGetter:: PHOS() const
514 // returns the PHOS object
515 AliPHOSLoader * loader = 0;
516 static AliPHOSLoader * oldloader = 0;
517 static AliPHOS * phos = 0;
519 loader = PhosLoader();
521 if ( loader != oldloader) {
522 phos = dynamic_cast<AliPHOS*>(loader->GetModulesFolder()->FindObject("PHOS")) ;
527 Warning("PHOS", "PHOS module not found in module folders: %s", PhosLoader()->GetModulesFolder()->GetName() ) ;
533 //____________________________________________________________________________
534 AliPHOSPID * AliPHOSGetter::PID()
536 // Returns pointer to the PID task
538 rv = dynamic_cast<AliPHOSPID *>(PhosLoader()->PIDTask()) ;
541 rv = dynamic_cast<AliPHOSPID *>(PhosLoader()->PIDTask()) ;
546 //____________________________________________________________________________
547 AliPHOSGeometry * AliPHOSGetter::PHOSGeometry() const
549 // Returns PHOS geometry
551 AliPHOSGeometry * rv = 0 ;
553 rv = PHOS()->GetGeometry() ;
555 rv = AliPHOSGeometry::GetInstance();
557 AliError("Could not find PHOS geometry! Loading the default one !");
558 rv = AliPHOSGeometry::GetInstance("IHEP","");
564 //____________________________________________________________________________
565 TClonesArray * AliPHOSGetter::Primaries()
567 // creates the Primaries container if needed
570 Info("Primaries", "Creating a new TClonesArray for primaries") ;
571 fPrimaries = new TClonesArray("TParticle", 1000) ;
576 //____________________________________________________________________________
577 void AliPHOSGetter::Print()
579 // Print usefull information about the getter
581 AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle());
582 ::Info( "Print", "gAlice file is %s -- version name is %s", (rl->GetFileName()).Data(), rl->GetEventFolder()->GetName() ) ;
585 //____________________________________________________________________________
586 void AliPHOSGetter::ReadPrimaries()
588 // Read Primaries from Kinematics.root
590 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
592 // gets kine tree from the root file (Kinematics.root)
593 if ( ! rl->TreeK() ) { // load treeK the first time
594 rl->LoadKinematics() ;
597 fNPrimaries = (rl->GetHeader())->GetNtrack();
599 Info( "ReadTreeK", "Found %d particles in event # %d", fNPrimaries, EventNumber() ) ;
602 // first time creates the container
604 fPrimaries->Clear() ;
607 for (index = 0 ; index < fNPrimaries; index++) {
608 new ((*fPrimaries)[index]) TParticle(*(Primary(index)));
612 //____________________________________________________________________________
613 Bool_t AliPHOSGetter::OpenESDFile()
618 fESDFile = TFile::Open(fESDFileName) ;
622 else if (fESDFile->IsOpen()) {
624 fESDFile = TFile::Open(fESDFileName) ;
626 if (!fESDFile->IsOpen())
631 //____________________________________________________________________________
632 void AliPHOSGetter::FitRaw(Bool_t lowGainFlag, TGraph * gLowGain, TGraph * gHighGain, TF1* signalF, Double_t & energy, Double_t & time) const
634 // Fits the raw signal time distribution
636 const Int_t kNoiseThreshold = 0 ;
637 Double_t timezero1 = 0., timezero2 = 0., timemax = 0. ;
638 Double_t signal = 0., signalmax = 0. ;
642 // Create a shaper pulse object which contains all the shaper parameters
643 AliPHOSPulseGenerator pulse;
646 timezero1 = timezero2 = signalmax = timemax = 0. ;
647 signalF->FixParameter(0, pulse.GetRawFormatLowCharge()) ;
648 signalF->FixParameter(1, pulse.GetRawFormatLowGain()) ;
650 for (index = 0; index < pulse.GetRawFormatTimeBins(); index++) {
651 gLowGain->GetPoint(index, time, signal) ;
652 if (signal > kNoiseThreshold && timezero1 == 0.)
654 if (signal <= kNoiseThreshold && timezero1 > 0. && timezero2 == 0.)
656 if (signal > signalmax) {
662 pulse.RawResponseFunctionMax(pulse.GetRawFormatLowCharge(),
663 pulse.GetRawFormatLowGain()) ;
664 if ( timezero1 + pulse.GetRawFormatTimePeak() < pulse.GetRawFormatTimeMax() * 0.4 ) { // else its noise
665 signalF->SetParameter(2, signalmax) ;
666 signalF->SetParameter(3, timezero1) ;
667 gLowGain->Fit(signalF, "QRO", "", 0., timezero2); //, "QRON") ;
668 energy = signalF->GetParameter(2) ;
669 time = signalF->GetMaximumX() - pulse.GetRawFormatTimePeak() - pulse.GetRawFormatTimeTrigger() ;
672 timezero1 = timezero2 = signalmax = timemax = 0. ;
673 signalF->FixParameter(0, pulse.GetRawFormatHighCharge()) ;
674 signalF->FixParameter(1, pulse.GetRawFormatHighGain()) ;
676 for (index = 0; index < pulse.GetRawFormatTimeBins(); index++) {
677 gHighGain->GetPoint(index, time, signal) ;
678 if (signal > kNoiseThreshold && timezero1 == 0.)
680 if (signal <= kNoiseThreshold && timezero1 > 0. && timezero2 == 0.)
682 if (signal > signalmax) {
687 signalmax /= pulse.RawResponseFunctionMax(pulse.GetRawFormatHighCharge(),
688 pulse.GetRawFormatHighGain()) ;;
689 if ( timezero1 + pulse.GetRawFormatTimePeak() < pulse.GetRawFormatTimeMax() * 0.4 ) { // else its noise
690 signalF->SetParameter(2, signalmax) ;
691 signalF->SetParameter(3, timezero1) ;
692 gHighGain->Fit(signalF, "QRO", "", 0., timezero2) ;
693 energy = signalF->GetParameter(2) ;
694 time = signalF->GetMaximumX() - pulse.GetRawFormatTimePeak() - pulse.GetRawFormatTimeTrigger() ;
697 if (time == 0) energy = 0 ;
700 //____________________________________________________________________________
701 Int_t AliPHOSGetter::CalibrateRaw(Double_t energy, Int_t *relId)
703 // Convert energy into digitized amplitude for a cell relId
704 // It is a user responsilibity to open CDB and set
705 // AliPHOSCalibData object by the following operators:
707 // AliCDBLocal *loc = new AliCDBLocal("deCalibDB");
708 // AliPHOSCalibData* clb = (AliPHOSCalibData*)AliCDBStorage::Instance()
709 // ->Get(path_to_calibdata,run_number);
710 // AliPHOSGetter* gime = AliPHOSGetter::Instance("galice.root");
711 // gime->SetCalibData(clb);
713 if (CalibData() == 0)
714 Warning("CalibrateRaw","Calibration DB is not initiated!");
716 Int_t module = relId[0];
717 Int_t column = relId[3];
718 Int_t row = relId[2];
720 Float_t gainFactor = 0.0015; // width of one Emc ADC channel in GeV
721 Float_t pedestal = 0.005; // Emc pedestals
724 gainFactor = CalibData()->GetADCchannelEmc (module,column,row);
725 pedestal = CalibData()->GetADCpedestalEmc(module,column,row);
728 Int_t amp = static_cast<Int_t>( (energy - pedestal) / gainFactor + 0.5 ) ;
731 //____________________________________________________________________________
732 Int_t AliPHOSGetter::ReadRaw(AliRawReader *rawReader,Bool_t isOldRCUFormat)
734 // reads the raw format data, converts it into digits format and store digits in Digits()
736 // isOldRCUFormat = kTRUE in case of the old RCU
737 // format used in the raw data readout.
738 // Reimplemented by Boris Polichtchouk (Jul 2006)
739 // to make it working with the Jul-Aug 2006 beam test data.
741 AliCaloRawStream in(rawReader,"PHOS");
742 in.SetOldRCUFormat(isOldRCUFormat);
744 // Create a shaper pulse object
745 AliPHOSPulseGenerator pulse;
746 TF1 * signalF = new TF1("signal", AliPHOSPulseGenerator::RawResponseFunction, 0, pulse.GetRawFormatTimeMax(), 4);
747 signalF->SetParNames("Charge", "Gain", "Amplitude", "TimeZero") ;
749 Int_t relId[4], absId =0;
750 Bool_t lowGainFlag = kFALSE ;
752 TClonesArray * digits = Digits() ;
757 Double_t energyHG = 0. ;
758 Double_t energyLG = 0. ;
765 while ( in.Next() ) { // PHOS entries loop
767 lowGainFlag = in.IsLowGain();
769 // (Re)create histograms to store samples
773 hLowGain = new TH1F("hLowGain","Low gain",in.GetTimeLength(),0,in.GetTimeLength());
775 if(hLowGain->GetNbinsX() != in.GetTimeLength()) {
777 hLowGain = new TH1F("hLowGain","Low gain",in.GetTimeLength(),0,in.GetTimeLength());
781 hHighGain = new TH1F("hHighGain","High gain",in.GetTimeLength(),0,in.GetTimeLength());
783 if(hHighGain->GetNbinsX() != in.GetTimeLength()) {
785 hHighGain = new TH1F("hHighGain","High gain",in.GetTimeLength(),0,in.GetTimeLength());
789 // Fill histograms with samples
791 hLowGain ->SetBinContent(in.GetTimeLength()-iBin-1,in.GetSignal());
793 hHighGain->SetBinContent(in.GetTimeLength()-iBin-1,in.GetSignal());
798 // Fit the full sample
799 if(iBin==in.GetTimeLength()) {
802 // Temporarily we do not fit the sample graph, but
803 // take the energy from the graph maximum, and the pedestal from the 0th point
806 //FitRaw(lowGainFlag, hLowGain, hHighGain, signalF, energy, time);
809 energyLG = hLowGain ->GetMaximum(); // "digit amplitude"
810 // energyLG -= hLowGain ->GetBinContent(0); // "pedestal subtraction"
811 energyLG *= pulse.GetRawFormatHighLowGainFactor(); // *16
812 if(AliLog::GetGlobalDebugLevel()>3) {
813 AliDebug(4,Form("----Printing hLowGain: ----\n")) ;
814 hLowGain ->Print("all");
816 if(AliLog::GetGlobalDebugLevel()>2)
817 AliDebug(2,Form("(mod,col,row)=(%d,%d,%d), low gain energy=%f\n\n",
818 in.GetModule(),in.GetColumn(),in.GetRow(),energyLG));
822 energyHG = hHighGain->GetMaximum(); // "digit amplitude"
823 // energyHG -= hHighGain->GetBinContent(0); // "pedestal subtraction"
824 if(AliLog::GetGlobalDebugLevel()>3) {
825 AliDebug(4,Form("----Printing hHighGain: ----\n"));
826 hHighGain->Print("all");
828 if(AliLog::GetGlobalDebugLevel()>2)
829 AliDebug(2,Form("(mod,col,row)=(%d,%d,%d), high gain energy=%f\n\n",
830 in.GetModule(),in.GetColumn(),in.GetRow(),energyHG));
833 // Time is not evaluated for the moment (12.01.2007). To be implemented later.
836 relId[0] = in.GetModule()+1;
838 relId[2] = in.GetRow() +1;
839 relId[3] = in.GetColumn()+1;
840 if(!PHOSGeometry()) AliFatal("Couldn't find PHOSGeometry!");
841 PHOSGeometry()->RelToAbsNumbering(relId, absId);
843 AliDebug(2,Form("relId=(mod,row,col)=(%d,%d,%d), absId=%d\n\n",
844 relId[0],relId[2],relId[3],absId));
846 // Add low gain digit only if the high gain digit does not exist in the digits array
849 for (iOldDigit=iDigit-1; iOldDigit==0; iOldDigit--) {
850 if ((dynamic_cast<AliPHOSDigit*>(digits->At(iOldDigit)))->GetId() == absId) {
856 new((*digits)[iDigit]) AliPHOSDigit(-1,absId,(Float_t)energyLG,time);
859 // Add high gain digit only if it is not saturated;
860 // replace low gain digit by a high gain one
862 if (energyHG >= 1023) continue;
863 for (iOldDigit=iDigit-1; iOldDigit==0; iOldDigit--) {
864 if ((dynamic_cast<AliPHOSDigit*>(digits->At(iOldDigit)))->GetId() == absId) {
865 digits->RemoveAt(iOldDigit);
866 new((*digits)[iDigit]) AliPHOSDigit(-1,absId,(Float_t)energyHG,time);
872 new((*digits)[iDigit]) AliPHOSDigit(-1,absId,(Float_t)energyHG,time);
875 AliPHOSDigit *dig = dynamic_cast<AliPHOSDigit*>(digits->At(iDigit));
893 for(iDigit=0; iDigit<digits->GetEntries(); iDigit++) {
894 AliPHOSDigit* digit = (AliPHOSDigit*)digits->At(iDigit);
895 if(digit->GetEnergy()>eMax) {
896 PHOSGeometry()->AbsToRelNumbering(digit->GetId(),relId);
897 eMax=digit->GetEnergy();
904 AliDebug(1,Form("Digit with max. energy: modMax %d colMax %d rowMax %d eMax %f\n\n",
905 modMax,colMax,rowMax,eMax));
911 return digits->GetEntriesFast() ;
914 //____________________________________________________________________________
915 Int_t AliPHOSGetter::ReadTreeD() const
919 PhosLoader()->CleanDigits() ;
920 PhosLoader()->LoadDigits("UPDATE") ;
921 PhosLoader()->LoadDigitizer("UPDATE") ;
922 return Digits()->GetEntries() ;
925 //____________________________________________________________________________
926 Int_t AliPHOSGetter::ReadTreeH() const
929 PhosLoader()->CleanHits() ;
930 // gets TreeH from the root file (PHOS.Hit.root)
931 //if ( !IsLoaded("H") ) {
932 PhosLoader()->LoadHits("UPDATE") ;
935 return Hits()->GetEntries() ;
938 //____________________________________________________________________________
939 Int_t AliPHOSGetter::ReadTreeR() const
941 // Read the RecPoints
943 PhosLoader()->CleanRecPoints() ;
944 // gets TreeR from the root file (PHOS.RecPoints.root)
945 //if ( !IsLoaded("R") ) {
946 PhosLoader()->LoadRecPoints("UPDATE") ;
947 PhosLoader()->LoadClusterizer("UPDATE") ;
951 return EmcRecPoints()->GetEntries() ;
954 //____________________________________________________________________________
955 Int_t AliPHOSGetter::ReadTreeT() const
957 // Read the TrackSegments
959 PhosLoader()->CleanTracks() ;
960 // gets TreeT from the root file (PHOS.TrackSegments.root)
961 //if ( !IsLoaded("T") ) {
962 PhosLoader()->LoadTracks("UPDATE") ;
963 PhosLoader()->LoadTrackSegmentMaker("UPDATE") ;
967 return TrackSegments()->GetEntries() ;
969 //____________________________________________________________________________
970 Int_t AliPHOSGetter::ReadTreeP() const
972 // Read the RecParticles
974 PhosLoader()->CleanRecParticles() ;
976 // gets TreeT from the root file (PHOS.TrackSegments.root)
977 // if ( !IsLoaded("P") ) {
978 PhosLoader()->LoadRecParticles("UPDATE") ;
979 PhosLoader()->LoadPID("UPDATE") ;
983 return RecParticles()->GetEntries() ;
985 //____________________________________________________________________________
986 Int_t AliPHOSGetter::ReadTreeS() const
990 PhosLoader()->CleanSDigits() ;
991 // gets TreeS from the root file (PHOS.SDigits.root)
992 //if ( !IsLoaded("S") ) {
993 PhosLoader()->LoadSDigits("READ") ;
994 PhosLoader()->LoadSDigitizer("READ") ;
998 return SDigits()->GetEntries() ;
1001 //____________________________________________________________________________
1002 Int_t AliPHOSGetter::ReadTreeE(Int_t event)
1006 // gets esdTree from the root file (AliESDs.root)
1008 if ( !OpenESDFile() )
1011 fESDTree = static_cast<TTree*>(fESDFile->Get("esdTree")) ;
1015 Error("ReadTreeE", "no ESD tree found");
1018 fESDTree->SetBranchAddress("ESD", &fESD);
1019 fESDTree->GetEvent(event);
1024 //____________________________________________________________________________
1025 TClonesArray * AliPHOSGetter::SDigits() const
1027 // asks the Loader to return the Digits container
1029 TClonesArray * rv = 0 ;
1031 rv = PhosLoader()->SDigits() ;
1033 PhosLoader()->MakeSDigitsArray() ;
1034 rv = PhosLoader()->SDigits() ;
1039 //____________________________________________________________________________
1040 AliPHOSSDigitizer * AliPHOSGetter::SDigitizer()
1042 // Returns pointer to the SDigitizer task
1043 AliPHOSSDigitizer * rv ;
1044 rv = dynamic_cast<AliPHOSSDigitizer *>(PhosLoader()->SDigitizer()) ;
1047 rv = dynamic_cast<AliPHOSSDigitizer *>(PhosLoader()->SDigitizer()) ;
1052 //____________________________________________________________________________
1053 TParticle * AliPHOSGetter::Secondary(const TParticle* p, Int_t index) const
1055 // Return first (index=1) or second (index=2) secondary particle of primary particle p
1063 Int_t daughterIndex = p->GetDaughter(index-1) ;
1064 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
1065 return rl->GetAliRun()->GetMCApp()->Particle(daughterIndex) ;
1071 //____________________________________________________________________________
1072 void AliPHOSGetter::Track(Int_t itrack)
1074 // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
1076 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
1078 if( !TreeH() ) // load treeH the first time
1081 // first time create the container
1082 TClonesArray * hits = Hits() ;
1086 TBranch * phosbranch = dynamic_cast<TBranch*>(TreeH()->GetBranch("PHOS")) ;
1087 phosbranch->SetAddress(&hits) ;
1088 phosbranch->GetEntry(itrack) ;
1091 //____________________________________________________________________________
1092 TTree * AliPHOSGetter::TreeD() const
1094 // Returns pointer to the Digits Tree
1096 rv = PhosLoader()->TreeD() ;
1098 PhosLoader()->MakeTree("D");
1099 rv = PhosLoader()->TreeD() ;
1105 //____________________________________________________________________________
1106 TTree * AliPHOSGetter::TreeH() const
1108 // Returns pointer to the Hits Tree
1110 rv = PhosLoader()->TreeH() ;
1112 PhosLoader()->MakeTree("H");
1113 rv = PhosLoader()->TreeH() ;
1119 //____________________________________________________________________________
1120 TTree * AliPHOSGetter::TreeR() const
1122 // Returns pointer to the RecPoints Tree
1124 rv = PhosLoader()->TreeR() ;
1126 PhosLoader()->MakeTree("R");
1127 rv = PhosLoader()->TreeR() ;
1133 //____________________________________________________________________________
1134 TTree * AliPHOSGetter::TreeT() const
1136 // Returns pointer to the TrackSegments Tree
1138 rv = PhosLoader()->TreeT() ;
1140 PhosLoader()->MakeTree("T");
1141 rv = PhosLoader()->TreeT() ;
1146 //____________________________________________________________________________
1147 TTree * AliPHOSGetter::TreeP() const
1149 // Returns pointer to the RecParticles Tree
1151 rv = PhosLoader()->TreeP() ;
1153 PhosLoader()->MakeTree("P");
1154 rv = PhosLoader()->TreeP() ;
1160 //____________________________________________________________________________
1161 TTree * AliPHOSGetter::TreeS() const
1163 // Returns pointer to the SDigits Tree
1165 rv = PhosLoader()->TreeS() ;
1167 PhosLoader()->MakeTree("S");
1168 rv = PhosLoader()->TreeS() ;
1174 //____________________________________________________________________________
1175 Bool_t AliPHOSGetter::VersionExists(TString & opt) const
1177 // checks if the version with the present name already exists in the same directory
1179 Bool_t rv = kFALSE ;
1181 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
1182 TString version( rl->GetEventFolder()->GetName() ) ;
1186 if ( opt == "sdigits") {
1187 // add the version name to the root file name
1188 TString fileName( PhosLoader()->GetSDigitsFileName() ) ;
1189 if (version != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
1190 fileName = fileName.ReplaceAll(".root", "") + "_" + version + ".root" ;
1191 if ( !(gSystem->AccessPathName(fileName)) ) {
1192 Warning("VersionExists", "The file %s already exists", fileName.Data()) ;
1195 PhosLoader()->SetSDigitsFileName(fileName) ;
1198 if ( opt == "digits") {
1199 // add the version name to the root file name
1200 TString fileName( PhosLoader()->GetDigitsFileName() ) ;
1201 if (version != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
1202 fileName = fileName.ReplaceAll(".root", "") + "_" + version + ".root" ;
1203 if ( !(gSystem->AccessPathName(fileName)) ) {
1204 Warning("VersionExists", "The file %s already exists", fileName.Data()) ;
1213 //____________________________________________________________________________
1214 UShort_t AliPHOSGetter::EventPattern(void) const
1216 // Return the pattern (trigger bit register) of the beam-test event
1218 return fBTE->GetPattern() ;
1222 //____________________________________________________________________________
1223 Float_t AliPHOSGetter::BeamEnergy(void) const
1225 // Return the beam energy of the beam-test event
1227 return fBTE->GetBeamEnergy() ;
1231 //____________________________________________________________________________
1233 AliPHOSCalibData* AliPHOSGetter::CalibData()
1235 // Check if the instance of AliPHOSCalibData exists, and return it