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 "AliRunLoader.h"
65 #include "AliCaloRawStream.h"
66 #include "AliRawReaderFile.h"
68 #include "AliCDBLocal.h"
69 #include "AliCDBStorage.h"
70 #include "AliCDBManager.h"
72 ClassImp(AliPHOSGetter)
74 AliPHOSGetter * AliPHOSGetter::fgObjGetter = 0 ;
75 AliPHOSLoader * AliPHOSGetter::fgPhosLoader = 0;
76 AliPHOSCalibData* AliPHOSGetter::fgCalibData = 0;
77 Int_t AliPHOSGetter::fgDebug = 0;
79 // TFile * AliPHOSGetter::fgFile = 0 ;
81 AliPHOSGetter::AliPHOSGetter() :
93 // ctor: this is a singleton, the ctor should never be called but cint needs it as public
94 Fatal("ctor", "AliPHOSGetter is a singleton default ctor not callable") ;
98 //____________________________________________________________________________
99 AliPHOSGetter::AliPHOSGetter(const char* headerFile, const char* version, Option_t * openingOption) :
111 // ctor only called by Instance()
113 AliRunLoader* rl = AliRunLoader::GetRunLoader(version) ;
115 rl = AliRunLoader::Open(headerFile, version, openingOption);
117 Fatal("AliPHOSGetter", "Could not find the Run Loader for %s - %s",headerFile, version) ;
120 if (rl->GetAliRun() == 0x0) {
122 gAlice = rl->GetAliRun(); // should be removed
126 fgPhosLoader = dynamic_cast<AliPHOSLoader*>(rl->GetLoader("PHOSLoader"));
128 Error("AliPHOSGetter", "Could not find PHOSLoader") ;
130 fgPhosLoader->SetTitle(version);
132 // initialize data members
136 fLoadingStatus = "" ;
138 fESDFileName = rl->GetFileName() ; // this should be the galice.root file
139 fESDFileName.ReplaceAll("galice.root", "AliESDs.root") ;
143 fRawDigits = kFALSE ;
147 AliPHOSGetter::AliPHOSGetter(const AliPHOSGetter & obj) :
160 // cpy ctor requested by Coding Convention
161 Fatal("cpy ctor", "not implemented") ;
164 //____________________________________________________________________________
165 AliPHOSGetter::AliPHOSGetter(Int_t /*i*/) :
177 // special constructor for onflight
181 //____________________________________________________________________________
182 AliPHOSGetter::~AliPHOSGetter()
186 delete fgPhosLoader ;
194 fPrimaries->Delete() ;
205 //____________________________________________________________________________
206 void AliPHOSGetter::Reset()
208 // resets things in case the getter is called consecutively with different files
209 // the PHOS Loader is already deleted by the Run Loader
212 fPrimaries->Delete() ;
219 //____________________________________________________________________________
220 AliPHOSClusterizer * AliPHOSGetter::Clusterizer()
222 // Returns pointer to the Clusterizer task
223 AliPHOSClusterizer * rv ;
224 rv = dynamic_cast<AliPHOSClusterizer *>(PhosLoader()->Reconstructioner()) ;
227 rv = dynamic_cast<AliPHOSClusterizer*>(PhosLoader()->Reconstructioner()) ;
232 //____________________________________________________________________________
233 TObjArray * AliPHOSGetter::CpvRecPoints() const
235 // asks the Loader to return the CPV RecPoints container
239 rv = PhosLoader()->CpvRecPoints() ;
241 PhosLoader()->MakeRecPointsArray() ;
242 rv = PhosLoader()->CpvRecPoints() ;
247 //____________________________________________________________________________
248 TClonesArray * AliPHOSGetter::Digits() const
250 // asks the Loader to return the Digits container
252 TClonesArray * rv = 0 ;
253 rv = PhosLoader()->Digits() ;
256 PhosLoader()->MakeDigitsArray() ;
257 rv = PhosLoader()->Digits() ;
262 //____________________________________________________________________________
263 AliPHOSDigitizer * AliPHOSGetter::Digitizer()
265 // Returns pointer to the Digitizer task
266 AliPHOSDigitizer * rv ;
267 rv = dynamic_cast<AliPHOSDigitizer *>(PhosLoader()->Digitizer()) ;
270 rv = dynamic_cast<AliPHOSDigitizer *>(PhosLoader()->Digitizer()) ;
276 //____________________________________________________________________________
277 TObjArray * AliPHOSGetter::EmcRecPoints() const
279 // asks the Loader to return the EMC RecPoints container
283 rv = PhosLoader()->EmcRecPoints() ;
285 PhosLoader()->MakeRecPointsArray() ;
286 rv = PhosLoader()->EmcRecPoints() ;
291 //____________________________________________________________________________
292 TClonesArray * AliPHOSGetter::TrackSegments() const
294 // asks the Loader to return the TrackSegments container
296 TClonesArray * rv = 0 ;
298 rv = PhosLoader()->TrackSegments() ;
300 PhosLoader()->MakeTrackSegmentsArray() ;
301 rv = PhosLoader()->TrackSegments() ;
306 //____________________________________________________________________________
307 AliPHOSTrackSegmentMaker * AliPHOSGetter::TrackSegmentMaker()
309 // Returns pointer to the TrackSegmentMaker task
310 AliPHOSTrackSegmentMaker * rv ;
311 rv = dynamic_cast<AliPHOSTrackSegmentMaker *>(PhosLoader()->TrackSegmentMaker()) ;
314 rv = dynamic_cast<AliPHOSTrackSegmentMaker *>(PhosLoader()->TrackSegmentMaker()) ;
319 //____________________________________________________________________________
320 TClonesArray * AliPHOSGetter::RecParticles() const
322 // asks the Loader to return the TrackSegments container
324 TClonesArray * rv = 0 ;
326 rv = PhosLoader()->RecParticles() ;
328 PhosLoader()->MakeRecParticlesArray() ;
329 rv = PhosLoader()->RecParticles() ;
333 //____________________________________________________________________________
334 void AliPHOSGetter::Event(Int_t event, const char* opt)
336 // Reads the content of all Tree's S, D and R
338 // if ( event >= MaxEvent() ) {
339 // Error("Event", "%d not found in TreeE !", event) ;
343 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
345 // // checks if we are dealing with test-beam data
346 // TBranch * btb = rl->TreeE()->GetBranch("AliPHOSBeamTestEvent") ;
349 // fBTE = new AliPHOSBeamTestEvent() ;
350 // btb->SetAddress(&fBTE) ;
351 // btb->GetEntry(event) ;
360 // Loads the type of object(s) requested
362 rl->GetEvent(event) ;
364 if(strstr(opt,"X") || (strcmp(opt,"")==0)){
368 if(strstr(opt,"H") ){
372 if(strstr(opt,"S") ){
376 if(strstr(opt,"D") ){
380 if(strstr(opt,"R") ){
384 if( strstr(opt,"T") ){
388 if( strstr(opt,"P") ){
392 if( strstr(opt,"E") ){
399 //____________________________________________________________________________
400 void AliPHOSGetter::Event(AliRawReader *rawReader, const char* opt, Bool_t isOldRCUFormat)
402 // Reads the raw event from rawReader
403 // isOldRCUFormat defines whenever to assume
404 // the old RCU format or not
406 if( strstr(opt,"W") ){
407 rawReader->NextEvent();
408 ReadRaw(rawReader,isOldRCUFormat) ;
414 //____________________________________________________________________________
415 Int_t AliPHOSGetter::EventNumber() const
417 // return the current event number
418 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
419 return static_cast<Int_t>(rl->GetEventNumber()) ;
422 //____________________________________________________________________________
423 TClonesArray * AliPHOSGetter::Hits() const
425 // asks the loader to return the Hits container
427 TClonesArray * rv = 0 ;
429 rv = PhosLoader()->Hits() ;
431 PhosLoader()->LoadHits("read");
432 rv = PhosLoader()->Hits() ;
437 //____________________________________________________________________________
438 AliPHOSGetter * AliPHOSGetter::Instance(const char* alirunFileName, const char* version, Option_t * openingOption)
440 // Creates and returns the pointer of the unique instance
441 // Must be called only when the environment has changed
443 if(!fgObjGetter){ // first time the getter is called
444 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
446 else { // the getter has been called previously
447 AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle());
448 if ( rl->GetFileName() == alirunFileName ) {// the alirunFile has the same name
449 // check if the file is already open
450 TFile * galiceFile = dynamic_cast<TFile *>(gROOT->FindObject(rl->GetFileName()) ) ;
453 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
455 else { // the file is already open check the version name
456 TString currentVersionName = rl->GetEventFolder()->GetName() ;
457 TString newVersionName(version) ;
458 if (currentVersionName == newVersionName)
460 ::Warning( "Instance", "Files with version %s already open", currentVersionName.Data() ) ;
462 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
467 AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle()) ;
468 if ( strstr(version, AliConfig::GetDefaultEventFolderName()) ) // false in case of merging
470 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
474 ::Error("AliPHOSGetter::Instance", "Failed to create the PHOS Getter object") ;
482 //____________________________________________________________________________
483 AliPHOSGetter * AliPHOSGetter::Instance()
485 // Returns the pointer of the unique instance already defined
487 if(!fgObjGetter && fgDebug)
488 ::Warning("AliPHOSGetter::Instance", "Getter not initialized") ;
494 //____________________________________________________________________________
495 Int_t AliPHOSGetter::MaxEvent() const
497 // returns the number of events in the run (from TE)
499 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
500 return static_cast<Int_t>(rl->GetNumberOfEvents()) ;
503 //____________________________________________________________________________
504 TParticle * AliPHOSGetter::Primary(Int_t index) const
506 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
507 return rl->Stack()->Particle(index) ;
510 //____________________________________________________________________________
511 AliPHOS * AliPHOSGetter:: PHOS() const
513 // returns the PHOS object
514 AliPHOSLoader * loader = 0;
515 static AliPHOSLoader * oldloader = 0;
516 static AliPHOS * phos = 0;
518 loader = PhosLoader();
520 if ( loader != oldloader) {
521 phos = dynamic_cast<AliPHOS*>(loader->GetModulesFolder()->FindObject("PHOS")) ;
526 Warning("PHOS", "PHOS module not found in module folders: %s", PhosLoader()->GetModulesFolder()->GetName() ) ;
532 //____________________________________________________________________________
533 AliPHOSPID * AliPHOSGetter::PID()
535 // Returns pointer to the PID task
537 rv = dynamic_cast<AliPHOSPID *>(PhosLoader()->PIDTask()) ;
540 rv = dynamic_cast<AliPHOSPID *>(PhosLoader()->PIDTask()) ;
545 //____________________________________________________________________________
546 AliPHOSGeometry * AliPHOSGetter::PHOSGeometry() const
548 // Returns PHOS geometry
550 AliPHOSGeometry * rv = 0 ;
552 rv = PHOS()->GetGeometry() ;
554 rv = AliPHOSGeometry::GetInstance();
556 AliError("Could not find PHOS geometry! Loading the default one !");
557 rv = AliPHOSGeometry::GetInstance("IHEP","");
563 //____________________________________________________________________________
564 TClonesArray * AliPHOSGetter::Primaries()
566 // creates the Primaries container if needed
569 Info("Primaries", "Creating a new TClonesArray for primaries") ;
570 fPrimaries = new TClonesArray("TParticle", 1000) ;
575 //____________________________________________________________________________
576 void AliPHOSGetter::Print()
578 // Print usefull information about the getter
580 AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle());
581 ::Info( "Print", "gAlice file is %s -- version name is %s", (rl->GetFileName()).Data(), rl->GetEventFolder()->GetName() ) ;
584 //____________________________________________________________________________
585 void AliPHOSGetter::ReadPrimaries()
587 // Read Primaries from Kinematics.root
589 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
591 // gets kine tree from the root file (Kinematics.root)
592 if ( ! rl->TreeK() ) { // load treeK the first time
593 rl->LoadKinematics() ;
596 fNPrimaries = (rl->GetHeader())->GetNtrack();
598 Info( "ReadTreeK", "Found %d particles in event # %d", fNPrimaries, EventNumber() ) ;
601 // first time creates the container
603 fPrimaries->Clear() ;
606 for (index = 0 ; index < fNPrimaries; index++) {
607 new ((*fPrimaries)[index]) TParticle(*(Primary(index)));
611 //____________________________________________________________________________
612 Bool_t AliPHOSGetter::OpenESDFile()
617 fESDFile = TFile::Open(fESDFileName) ;
621 else if (fESDFile->IsOpen()) {
623 fESDFile = TFile::Open(fESDFileName) ;
625 if (!fESDFile->IsOpen())
630 //____________________________________________________________________________
631 void AliPHOSGetter::FitRaw(Bool_t lowGainFlag, TGraph * gLowGain, TGraph * gHighGain, TF1* signalF, Double_t & energy, Double_t & time) const
633 // Fits the raw signal time distribution
635 const Int_t kNoiseThreshold = 0 ;
636 Double_t timezero1 = 0., timezero2 = 0., timemax = 0. ;
637 Double_t signal = 0., signalmax = 0. ;
642 timezero1 = timezero2 = signalmax = timemax = 0. ;
643 signalF->FixParameter(0, PHOS()->GetRawFormatLowCharge()) ;
644 signalF->FixParameter(1, PHOS()->GetRawFormatLowGain()) ;
646 for (index = 0; index < PHOS()->GetRawFormatTimeBins(); index++) {
647 gLowGain->GetPoint(index, time, signal) ;
648 if (signal > kNoiseThreshold && timezero1 == 0.)
650 if (signal <= kNoiseThreshold && timezero1 > 0. && timezero2 == 0.)
652 if (signal > signalmax) {
657 signalmax /= PHOS()->RawResponseFunctionMax(PHOS()->GetRawFormatLowCharge(),
658 PHOS()->GetRawFormatLowGain()) ;
659 if ( timezero1 + PHOS()->GetRawFormatTimePeak() < PHOS()->GetRawFormatTimeMax() * 0.4 ) { // else its noise
660 signalF->SetParameter(2, signalmax) ;
661 signalF->SetParameter(3, timezero1) ;
662 gLowGain->Fit(signalF, "QRO", "", 0., timezero2); //, "QRON") ;
663 energy = signalF->GetParameter(2) ;
664 time = signalF->GetMaximumX() - PHOS()->GetRawFormatTimePeak() - PHOS()->GetRawFormatTimeTrigger() ;
667 timezero1 = timezero2 = signalmax = timemax = 0. ;
668 signalF->FixParameter(0, PHOS()->GetRawFormatHighCharge()) ;
669 signalF->FixParameter(1, PHOS()->GetRawFormatHighGain()) ;
671 for (index = 0; index < PHOS()->GetRawFormatTimeBins(); index++) {
672 gHighGain->GetPoint(index, time, signal) ;
673 if (signal > kNoiseThreshold && timezero1 == 0.)
675 if (signal <= kNoiseThreshold && timezero1 > 0. && timezero2 == 0.)
677 if (signal > signalmax) {
682 signalmax /= PHOS()->RawResponseFunctionMax(PHOS()->GetRawFormatHighCharge(),
683 PHOS()->GetRawFormatHighGain()) ;;
684 if ( timezero1 + PHOS()->GetRawFormatTimePeak() < PHOS()->GetRawFormatTimeMax() * 0.4 ) { // else its noise
685 signalF->SetParameter(2, signalmax) ;
686 signalF->SetParameter(3, timezero1) ;
687 gHighGain->Fit(signalF, "QRO", "", 0., timezero2) ;
688 energy = signalF->GetParameter(2) ;
689 time = signalF->GetMaximumX() - PHOS()->GetRawFormatTimePeak() - PHOS()->GetRawFormatTimeTrigger() ;
692 if (time == 0) energy = 0 ;
695 //____________________________________________________________________________
696 Int_t AliPHOSGetter::CalibrateRaw(Double_t energy, Int_t *relId)
698 // Convert energy into digitized amplitude for a cell relId
699 // It is a user responsilibity to open CDB and set
700 // AliPHOSCalibData object by the following operators:
702 // AliCDBLocal *loc = new AliCDBLocal("deCalibDB");
703 // AliPHOSCalibData* clb = (AliPHOSCalibData*)AliCDBStorage::Instance()
704 // ->Get(path_to_calibdata,run_number);
705 // AliPHOSGetter* gime = AliPHOSGetter::Instance("galice.root");
706 // gime->SetCalibData(clb);
708 if (CalibData() == 0)
709 Warning("CalibrateRaw","Calibration DB is not initiated!");
711 Int_t module = relId[0];
712 Int_t column = relId[3];
713 Int_t row = relId[2];
715 Float_t gainFactor = 0.0015; // width of one Emc ADC channel in GeV
716 Float_t pedestal = 0.005; // Emc pedestals
719 gainFactor = CalibData()->GetADCchannelEmc (module,column,row);
720 pedestal = CalibData()->GetADCpedestalEmc(module,column,row);
723 Int_t amp = static_cast<Int_t>( (energy - pedestal) / gainFactor + 0.5 ) ;
726 //____________________________________________________________________________
727 Int_t AliPHOSGetter::ReadRaw(AliRawReader *rawReader,Bool_t isOldRCUFormat)
729 // reads the raw format data, converts it into digits format and store digits in Digits()
731 // isOldRCUFormat = kTRUE in case of the old RCU
732 // format used in the raw data readout.
733 // Reimplemented by Boris Polichtchouk (Jul 2006)
734 // to make it working with the Jul-Aug 2006 beam test data.
736 AliCaloRawStream in(rawReader,"PHOS");
737 in.SetOldRCUFormat(isOldRCUFormat);
739 TF1 * signalF = new TF1("signal", AliPHOS::RawResponseFunction, 0, PHOS()->GetRawFormatTimeMax(), 4);
740 signalF->SetParNames("Charge", "Gain", "Amplitude", "TimeZero") ;
742 Int_t relId[4], id =0;
743 Bool_t lowGainFlag = kFALSE ;
745 TClonesArray * digits = Digits() ;
750 Double_t energyHG = 0. ;
751 Double_t energyLG = 0. ;
760 while ( in.Next() ) { // PHOS entries loop
762 if(!gHighGain) gHighGain = new TH1F("gHighGain","High gain",in.GetTimeLength(),0,in.GetTimeLength());
764 if(gHighGain->GetNbinsX() != in.GetTimeLength()) {
766 gHighGain = new TH1F("gHighGain","High gain",in.GetTimeLength(),0,in.GetTimeLength());
769 if(!gLowGain) gLowGain = new TH1F("gLowGain","Low gain",in.GetTimeLength(),0,in.GetTimeLength());
771 if(gLowGain->GetNbinsX() != in.GetTimeLength()) {
773 gLowGain = new TH1F("gLowGain","Low gain",in.GetTimeLength(),0,in.GetTimeLength());
776 lowGainFlag = in.IsLowGain();
779 gLowGain->SetBinContent(in.GetTimeLength()-iBin-1,in.GetSignal());
781 gHighGain->SetBinContent(in.GetTimeLength()-iBin-1,in.GetSignal());
786 if(iBin==in.GetTimeLength()) {
789 if(lowGainFlag) iDigLow++;
792 // Temporarily we do not fit the sample graph, but
793 // take the energy from the graph maximum, and the pedestal from the 0th point
796 //FitRaw(lowGainFlag, gLowGain, gHighGain, signalF, energy, time);
798 energyHG = gHighGain->GetMaximum();
799 energyHG -= gHighGain->GetBinContent(0); // "pedestal subtraction"
801 energyLG = gLowGain->GetMaximum();
802 energyLG -= gLowGain->GetBinContent(0); // "pedestal subtraction"
803 energyLG *= AliPHOS::GetRawFormatHighLowGainFactor(); // *16
805 if(AliLog::GetGlobalDebugLevel()>3) {
806 AliDebug(4,Form("----Printing gHighGain: ----\n")); gHighGain->Print("all");
807 AliDebug(4,Form("----Printing gLowGain: ----\n")); gLowGain->Print("all");
810 AliDebug(2,Form("AliPHOSGetter::ReadRaw: mod %d energyHG %f, energyLG %f lowGainFlag %d\n",
811 in.GetModule(),energyHG,energyLG,(Int_t)lowGainFlag));
814 relId[0] = in.GetModule()+1;
816 relId[2] = in.GetRow();
817 relId[3] = in.GetColumn();
818 if(!PHOSGeometry()) Fatal("ReadRaw","Couldn't find PHOSGeometry!");
819 PHOSGeometry()->RelToAbsNumbering(relId, id);
822 new((*digits)[idigit]) AliPHOSDigit(-1,id,(Float_t)energyHG,time);
826 new((*digits)[idigit]) AliPHOSDigit(-1,id,(Float_t)energyLG,time);
844 for(Int_t iDigit=0; iDigit<digits->GetEntries(); iDigit++) {
845 AliPHOSDigit* digit = (AliPHOSDigit*)digits->At(iDigit);
846 if(digit->GetEnergy()>eMax) {
847 PHOSGeometry()->AbsToRelNumbering(digit->GetId(),relId);
848 eMax=digit->GetEnergy();
854 // printf("\t\t\t------ %d Digits: %d LowGain + %d HighGain.\n",
855 // digits->GetEntriesFast(),iDigLow,iDigHigh);
857 AliDebug(1,Form("Digit with max. energy: modMax %d colMax %d rowMax %d eMax %f\n",
858 modMax,colMax,rowMax,eMax));
864 return digits->GetEntriesFast() ;
867 //____________________________________________________________________________
868 Int_t AliPHOSGetter::ReadTreeD() const
872 PhosLoader()->CleanDigits() ;
873 PhosLoader()->LoadDigits("UPDATE") ;
874 PhosLoader()->LoadDigitizer("UPDATE") ;
875 return Digits()->GetEntries() ;
878 //____________________________________________________________________________
879 Int_t AliPHOSGetter::ReadTreeH() const
882 PhosLoader()->CleanHits() ;
883 // gets TreeH from the root file (PHOS.Hit.root)
884 //if ( !IsLoaded("H") ) {
885 PhosLoader()->LoadHits("UPDATE") ;
888 return Hits()->GetEntries() ;
891 //____________________________________________________________________________
892 Int_t AliPHOSGetter::ReadTreeR() const
894 // Read the RecPoints
896 PhosLoader()->CleanRecPoints() ;
897 // gets TreeR from the root file (PHOS.RecPoints.root)
898 //if ( !IsLoaded("R") ) {
899 PhosLoader()->LoadRecPoints("UPDATE") ;
900 PhosLoader()->LoadClusterizer("UPDATE") ;
904 return EmcRecPoints()->GetEntries() ;
907 //____________________________________________________________________________
908 Int_t AliPHOSGetter::ReadTreeT() const
910 // Read the TrackSegments
912 PhosLoader()->CleanTracks() ;
913 // gets TreeT from the root file (PHOS.TrackSegments.root)
914 //if ( !IsLoaded("T") ) {
915 PhosLoader()->LoadTracks("UPDATE") ;
916 PhosLoader()->LoadTrackSegmentMaker("UPDATE") ;
920 return TrackSegments()->GetEntries() ;
922 //____________________________________________________________________________
923 Int_t AliPHOSGetter::ReadTreeP() const
925 // Read the RecParticles
927 PhosLoader()->CleanRecParticles() ;
929 // gets TreeT from the root file (PHOS.TrackSegments.root)
930 // if ( !IsLoaded("P") ) {
931 PhosLoader()->LoadRecParticles("UPDATE") ;
932 PhosLoader()->LoadPID("UPDATE") ;
936 return RecParticles()->GetEntries() ;
938 //____________________________________________________________________________
939 Int_t AliPHOSGetter::ReadTreeS() const
943 PhosLoader()->CleanSDigits() ;
944 // gets TreeS from the root file (PHOS.SDigits.root)
945 //if ( !IsLoaded("S") ) {
946 PhosLoader()->LoadSDigits("READ") ;
947 PhosLoader()->LoadSDigitizer("READ") ;
951 return SDigits()->GetEntries() ;
954 //____________________________________________________________________________
955 Int_t AliPHOSGetter::ReadTreeE(Int_t event)
959 // gets esdTree from the root file (AliESDs.root)
961 if ( !OpenESDFile() )
964 fESDTree = static_cast<TTree*>(fESDFile->Get("esdTree")) ;
968 Error("ReadTreeE", "no ESD tree found");
971 fESDTree->SetBranchAddress("ESD", &fESD);
972 fESDTree->GetEvent(event);
977 //____________________________________________________________________________
978 TClonesArray * AliPHOSGetter::SDigits() const
980 // asks the Loader to return the Digits container
982 TClonesArray * rv = 0 ;
984 rv = PhosLoader()->SDigits() ;
986 PhosLoader()->MakeSDigitsArray() ;
987 rv = PhosLoader()->SDigits() ;
992 //____________________________________________________________________________
993 AliPHOSSDigitizer * AliPHOSGetter::SDigitizer()
995 // Returns pointer to the SDigitizer task
996 AliPHOSSDigitizer * rv ;
997 rv = dynamic_cast<AliPHOSSDigitizer *>(PhosLoader()->SDigitizer()) ;
1000 rv = dynamic_cast<AliPHOSSDigitizer *>(PhosLoader()->SDigitizer()) ;
1005 //____________________________________________________________________________
1006 TParticle * AliPHOSGetter::Secondary(const TParticle* p, Int_t index) const
1008 // Return first (index=1) or second (index=2) secondary particle of primary particle p
1016 Int_t daughterIndex = p->GetDaughter(index-1) ;
1017 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
1018 return rl->GetAliRun()->GetMCApp()->Particle(daughterIndex) ;
1024 //____________________________________________________________________________
1025 void AliPHOSGetter::Track(Int_t itrack)
1027 // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
1029 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
1031 if( !TreeH() ) // load treeH the first time
1034 // first time create the container
1035 TClonesArray * hits = Hits() ;
1039 TBranch * phosbranch = dynamic_cast<TBranch*>(TreeH()->GetBranch("PHOS")) ;
1040 phosbranch->SetAddress(&hits) ;
1041 phosbranch->GetEntry(itrack) ;
1044 //____________________________________________________________________________
1045 TTree * AliPHOSGetter::TreeD() const
1047 // Returns pointer to the Digits Tree
1049 rv = PhosLoader()->TreeD() ;
1051 PhosLoader()->MakeTree("D");
1052 rv = PhosLoader()->TreeD() ;
1058 //____________________________________________________________________________
1059 TTree * AliPHOSGetter::TreeH() const
1061 // Returns pointer to the Hits Tree
1063 rv = PhosLoader()->TreeH() ;
1065 PhosLoader()->MakeTree("H");
1066 rv = PhosLoader()->TreeH() ;
1072 //____________________________________________________________________________
1073 TTree * AliPHOSGetter::TreeR() const
1075 // Returns pointer to the RecPoints Tree
1077 rv = PhosLoader()->TreeR() ;
1079 PhosLoader()->MakeTree("R");
1080 rv = PhosLoader()->TreeR() ;
1086 //____________________________________________________________________________
1087 TTree * AliPHOSGetter::TreeT() const
1089 // Returns pointer to the TrackSegments Tree
1091 rv = PhosLoader()->TreeT() ;
1093 PhosLoader()->MakeTree("T");
1094 rv = PhosLoader()->TreeT() ;
1099 //____________________________________________________________________________
1100 TTree * AliPHOSGetter::TreeP() const
1102 // Returns pointer to the RecParticles Tree
1104 rv = PhosLoader()->TreeP() ;
1106 PhosLoader()->MakeTree("P");
1107 rv = PhosLoader()->TreeP() ;
1113 //____________________________________________________________________________
1114 TTree * AliPHOSGetter::TreeS() const
1116 // Returns pointer to the SDigits Tree
1118 rv = PhosLoader()->TreeS() ;
1120 PhosLoader()->MakeTree("S");
1121 rv = PhosLoader()->TreeS() ;
1127 //____________________________________________________________________________
1128 Bool_t AliPHOSGetter::VersionExists(TString & opt) const
1130 // checks if the version with the present name already exists in the same directory
1132 Bool_t rv = kFALSE ;
1134 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
1135 TString version( rl->GetEventFolder()->GetName() ) ;
1139 if ( opt == "sdigits") {
1140 // add the version name to the root file name
1141 TString fileName( PhosLoader()->GetSDigitsFileName() ) ;
1142 if (version != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
1143 fileName = fileName.ReplaceAll(".root", "") + "_" + version + ".root" ;
1144 if ( !(gSystem->AccessPathName(fileName)) ) {
1145 Warning("VersionExists", "The file %s already exists", fileName.Data()) ;
1148 PhosLoader()->SetSDigitsFileName(fileName) ;
1151 if ( opt == "digits") {
1152 // add the version name to the root file name
1153 TString fileName( PhosLoader()->GetDigitsFileName() ) ;
1154 if (version != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
1155 fileName = fileName.ReplaceAll(".root", "") + "_" + version + ".root" ;
1156 if ( !(gSystem->AccessPathName(fileName)) ) {
1157 Warning("VersionExists", "The file %s already exists", fileName.Data()) ;
1166 //____________________________________________________________________________
1167 UShort_t AliPHOSGetter::EventPattern(void) const
1169 // Return the pattern (trigger bit register) of the beam-test event
1171 return fBTE->GetPattern() ;
1175 //____________________________________________________________________________
1176 Float_t AliPHOSGetter::BeamEnergy(void) const
1178 // Return the beam energy of the beam-test event
1180 return fBTE->GetBeamEnergy() ;
1184 //____________________________________________________________________________
1186 AliPHOSCalibData* AliPHOSGetter::CalibData()
1188 // Check if the instance of AliPHOSCalibData exists, and return it