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 "AliPHOSRawDecoder.h"
67 #include "AliRawReaderFile.h"
69 #include "AliCDBLocal.h"
70 #include "AliCDBStorage.h"
71 #include "AliCDBManager.h"
72 #include "AliPHOSRawDigiProducer.h"
73 #include "AliPHOSReconstructor.h"
74 #include "AliPHOSRecoParam.h"
76 ClassImp(AliPHOSGetter)
78 AliPHOSGetter * AliPHOSGetter::fgObjGetter = 0 ;
79 AliPHOSLoader * AliPHOSGetter::fgPhosLoader = 0;
80 AliPHOSCalibData* AliPHOSGetter::fgCalibData = 0;
81 Int_t AliPHOSGetter::fgDebug = 0;
83 // TFile * AliPHOSGetter::fgFile = 0 ;
85 AliPHOSGetter::AliPHOSGetter() :
97 // ctor: this is a singleton, the ctor should never be called but cint needs it as public
98 Fatal("ctor", "AliPHOSGetter is a singleton default ctor not callable") ;
102 //____________________________________________________________________________
103 AliPHOSGetter::AliPHOSGetter(const char* headerFile, const char* version, Option_t * openingOption) :
115 // ctor only called by Instance()
117 AliRunLoader* rl = AliRunLoader::GetRunLoader(version) ;
119 rl = AliRunLoader::Open(headerFile, version, openingOption);
121 Fatal("AliPHOSGetter", "Could not find the Run Loader for %s - %s",headerFile, version) ;
124 if (rl->GetAliRun() == 0x0) {
126 gAlice = rl->GetAliRun(); // should be removed
130 fgPhosLoader = dynamic_cast<AliPHOSLoader*>(rl->GetLoader("PHOSLoader"));
132 Error("AliPHOSGetter", "Could not find PHOSLoader") ;
134 fgPhosLoader->SetTitle(version);
136 // initialize data members
140 fLoadingStatus = "" ;
142 fESDFileName = rl->GetFileName() ; // this should be the galice.root file
143 fESDFileName.ReplaceAll("galice.root", "AliESDs.root") ;
147 fRawDigits = kFALSE ;
151 AliPHOSGetter::AliPHOSGetter(const AliPHOSGetter & obj) :
164 // cpy ctor requested by Coding Convention
165 Fatal("cpy ctor", "not implemented") ;
168 //____________________________________________________________________________
169 AliPHOSGetter::AliPHOSGetter(Int_t /*i*/) :
181 // special constructor for onflight
185 //____________________________________________________________________________
186 AliPHOSGetter::~AliPHOSGetter()
190 delete fgPhosLoader ;
198 fPrimaries->Delete() ;
209 //____________________________________________________________________________
210 void AliPHOSGetter::Reset()
212 // resets things in case the getter is called consecutively with different files
213 // the PHOS Loader is already deleted by the Run Loader
216 fPrimaries->Delete() ;
223 //____________________________________________________________________________
224 AliPHOSClusterizer * AliPHOSGetter::Clusterizer()
226 // Returns pointer to the Clusterizer task
227 AliPHOSClusterizer * rv ;
228 rv = dynamic_cast<AliPHOSClusterizer *>(PhosLoader()->Reconstructioner()) ;
231 rv = dynamic_cast<AliPHOSClusterizer*>(PhosLoader()->Reconstructioner()) ;
236 //____________________________________________________________________________
237 TObjArray * AliPHOSGetter::CpvRecPoints() const
239 // asks the Loader to return the CPV RecPoints container
243 rv = PhosLoader()->CpvRecPoints() ;
245 PhosLoader()->MakeRecPointsArray() ;
246 rv = PhosLoader()->CpvRecPoints() ;
251 //____________________________________________________________________________
252 TClonesArray * AliPHOSGetter::Digits() const
254 // asks the Loader to return the Digits container
256 TClonesArray * rv = 0 ;
257 rv = PhosLoader()->Digits() ;
260 PhosLoader()->MakeDigitsArray() ;
261 rv = PhosLoader()->Digits() ;
266 //____________________________________________________________________________
267 AliPHOSDigitizer * AliPHOSGetter::Digitizer()
269 // Returns pointer to the Digitizer task
270 AliPHOSDigitizer * rv ;
271 rv = dynamic_cast<AliPHOSDigitizer *>(PhosLoader()->Digitizer()) ;
274 rv = dynamic_cast<AliPHOSDigitizer *>(PhosLoader()->Digitizer()) ;
280 //____________________________________________________________________________
281 TObjArray * AliPHOSGetter::EmcRecPoints() const
283 // asks the Loader to return the EMC RecPoints container
287 rv = PhosLoader()->EmcRecPoints() ;
289 PhosLoader()->MakeRecPointsArray() ;
290 rv = PhosLoader()->EmcRecPoints() ;
295 //____________________________________________________________________________
296 TClonesArray * AliPHOSGetter::TrackSegments() const
298 // asks the Loader to return the TrackSegments container
300 TClonesArray * rv = 0 ;
302 rv = PhosLoader()->TrackSegments() ;
304 PhosLoader()->MakeTrackSegmentsArray() ;
305 rv = PhosLoader()->TrackSegments() ;
310 //____________________________________________________________________________
311 AliPHOSTrackSegmentMaker * AliPHOSGetter::TrackSegmentMaker()
313 // Returns pointer to the TrackSegmentMaker task
314 AliPHOSTrackSegmentMaker * rv ;
315 rv = dynamic_cast<AliPHOSTrackSegmentMaker *>(PhosLoader()->TrackSegmentMaker()) ;
318 rv = dynamic_cast<AliPHOSTrackSegmentMaker *>(PhosLoader()->TrackSegmentMaker()) ;
323 //____________________________________________________________________________
324 TClonesArray * AliPHOSGetter::RecParticles() const
326 // asks the Loader to return the TrackSegments container
328 TClonesArray * rv = 0 ;
330 rv = PhosLoader()->RecParticles() ;
332 PhosLoader()->MakeRecParticlesArray() ;
333 rv = PhosLoader()->RecParticles() ;
337 //____________________________________________________________________________
338 void AliPHOSGetter::Event(Int_t event, const char* opt)
340 // Reads the content of all Tree's S, D and R
342 // if ( event >= MaxEvent() ) {
343 // Error("Event", "%d not found in TreeE !", event) ;
347 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
349 // // checks if we are dealing with test-beam data
350 // TBranch * btb = rl->TreeE()->GetBranch("AliPHOSBeamTestEvent") ;
353 // fBTE = new AliPHOSBeamTestEvent() ;
354 // btb->SetAddress(&fBTE) ;
355 // btb->GetEntry(event) ;
364 // Loads the type of object(s) requested
366 rl->GetEvent(event) ;
368 if(strstr(opt,"X") || (strcmp(opt,"")==0)){
372 if(strstr(opt,"H") ){
376 if(strstr(opt,"S") ){
380 if(strstr(opt,"D") ){
384 if(strstr(opt,"R") ){
388 if( strstr(opt,"T") ){
392 if( strstr(opt,"P") ){
396 if( strstr(opt,"E") ){
403 //____________________________________________________________________________
404 void AliPHOSGetter::Event(AliRawReader *rawReader, const char* opt, Bool_t isOldRCUFormat)
406 // Reads the raw event from rawReader
407 // isOldRCUFormat defines whenever to assume
408 // the old RCU format or not
410 if( strstr(opt,"W") ){
411 rawReader->NextEvent();
412 ReadRaw(rawReader,isOldRCUFormat) ;
418 //____________________________________________________________________________
419 Int_t AliPHOSGetter::EventNumber() const
421 // return the current event number
422 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
423 return static_cast<Int_t>(rl->GetEventNumber()) ;
426 //____________________________________________________________________________
427 TClonesArray * AliPHOSGetter::Hits() const
429 // asks the loader to return the Hits container
431 TClonesArray * rv = 0 ;
433 rv = PhosLoader()->Hits() ;
435 PhosLoader()->LoadHits("read");
436 rv = PhosLoader()->Hits() ;
441 //____________________________________________________________________________
442 AliPHOSGetter * AliPHOSGetter::Instance(const char* alirunFileName, const char* version, Option_t * openingOption)
444 // Creates and returns the pointer of the unique instance
445 // Must be called only when the environment has changed
447 if(!fgObjGetter){ // first time the getter is called
448 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
450 else { // the getter has been called previously
451 AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle());
452 if ( rl->GetFileName() == alirunFileName ) {// the alirunFile has the same name
453 // check if the file is already open
454 TFile * galiceFile = dynamic_cast<TFile *>(gROOT->FindObject(rl->GetFileName()) ) ;
457 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
459 else { // the file is already open check the version name
460 TString currentVersionName = rl->GetEventFolder()->GetName() ;
461 TString newVersionName(version) ;
462 if (currentVersionName == newVersionName)
464 ::Warning( "Instance", "Files with version %s already open", currentVersionName.Data() ) ;
466 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
471 rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle()) ;
472 if ( strstr(version, AliConfig::GetDefaultEventFolderName()) ) // false in case of merging
474 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
478 ::Error("AliPHOSGetter::Instance", "Failed to create the PHOS Getter object") ;
486 //____________________________________________________________________________
487 AliPHOSGetter * AliPHOSGetter::Instance()
489 // Returns the pointer of the unique instance already defined
491 if(!fgObjGetter && fgDebug)
492 ::Warning("AliPHOSGetter::Instance", "Getter not initialized") ;
498 //____________________________________________________________________________
499 Int_t AliPHOSGetter::MaxEvent() const
501 // returns the number of events in the run (from TE)
503 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
504 return static_cast<Int_t>(rl->GetNumberOfEvents()) ;
507 //____________________________________________________________________________
508 TParticle * AliPHOSGetter::Primary(Int_t index) const
510 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
511 return rl->Stack()->Particle(index) ;
514 //____________________________________________________________________________
515 AliPHOS * AliPHOSGetter:: PHOS() const
517 // returns the PHOS object
518 AliPHOSLoader * loader = 0;
519 static AliPHOSLoader * oldloader = 0;
520 static AliPHOS * phos = 0;
522 loader = PhosLoader();
524 if ( loader != oldloader) {
525 phos = dynamic_cast<AliPHOS*>(loader->GetModulesFolder()->FindObject("PHOS")) ;
530 Warning("PHOS", "PHOS module not found in module folders: %s", PhosLoader()->GetModulesFolder()->GetName() ) ;
536 //____________________________________________________________________________
537 AliPHOSPID * AliPHOSGetter::PID()
539 // Returns pointer to the PID task
541 rv = dynamic_cast<AliPHOSPID *>(PhosLoader()->PIDTask()) ;
544 rv = dynamic_cast<AliPHOSPID *>(PhosLoader()->PIDTask()) ;
549 //____________________________________________________________________________
550 AliPHOSGeometry * AliPHOSGetter::PHOSGeometry() const
552 // Returns PHOS geometry
554 AliPHOSGeometry * rv = 0 ;
556 rv = PHOS()->GetGeometry() ;
558 rv = AliPHOSGeometry::GetInstance();
560 AliError("Could not find PHOS geometry! Loading the default one !");
561 rv = AliPHOSGeometry::GetInstance("IHEP","");
567 //____________________________________________________________________________
568 TClonesArray * AliPHOSGetter::Primaries()
570 // creates the Primaries container if needed
573 Info("Primaries", "Creating a new TClonesArray for primaries") ;
574 fPrimaries = new TClonesArray("TParticle", 1000) ;
579 //____________________________________________________________________________
580 void AliPHOSGetter::Print()
582 // Print usefull information about the getter
584 AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle());
585 ::Info( "Print", "gAlice file is %s -- version name is %s", (rl->GetFileName()).Data(), rl->GetEventFolder()->GetName() ) ;
588 //____________________________________________________________________________
589 void AliPHOSGetter::ReadPrimaries()
591 // Read Primaries from Kinematics.root
593 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
595 // gets kine tree from the root file (Kinematics.root)
596 if ( ! rl->TreeK() ) { // load treeK the first time
597 rl->LoadKinematics() ;
600 fNPrimaries = (rl->GetHeader())->GetNtrack();
602 Info( "ReadTreeK", "Found %d particles in event # %d", fNPrimaries, EventNumber() ) ;
605 // first time creates the container
607 fPrimaries->Clear() ;
610 for (index = 0 ; index < fNPrimaries; index++) {
611 new ((*fPrimaries)[index]) TParticle(*(Primary(index)));
615 //____________________________________________________________________________
616 Bool_t AliPHOSGetter::OpenESDFile()
621 fESDFile = TFile::Open(fESDFileName) ;
625 else if (fESDFile->IsOpen()) {
627 fESDFile = TFile::Open(fESDFileName) ;
629 if (!fESDFile->IsOpen())
634 //____________________________________________________________________________
635 void AliPHOSGetter::FitRaw(Bool_t lowGainFlag, TGraph * gLowGain, TGraph * gHighGain, TF1* signalF, Double_t & energy, Double_t & time) const
637 // Fits the raw signal time distribution
639 const Int_t kNoiseThreshold = 0 ;
640 Double_t timezero1 = 0., timezero2 = 0., timemax = 0. ;
641 Double_t signal = 0., signalmax = 0. ;
645 // Create a shaper pulse object which contains all the shaper parameters
646 AliPHOSPulseGenerator pulse;
649 timezero1 = timezero2 = signalmax = timemax = 0. ;
650 signalF->FixParameter(0, pulse.GetRawFormatLowCharge()) ;
651 signalF->FixParameter(1, pulse.GetRawFormatLowGain()) ;
653 for (index = 0; index < pulse.GetRawFormatTimeBins(); index++) {
654 gLowGain->GetPoint(index, time, signal) ;
655 if (signal > kNoiseThreshold && timezero1 == 0.)
657 if (signal <= kNoiseThreshold && timezero1 > 0. && timezero2 == 0.)
659 if (signal > signalmax) {
665 pulse.RawResponseFunctionMax(pulse.GetRawFormatLowCharge(),
666 pulse.GetRawFormatLowGain()) ;
667 if ( timezero1 + pulse.GetRawFormatTimePeak() < pulse.GetRawFormatTimeMax() * 0.4 ) { // else its noise
668 signalF->SetParameter(2, signalmax) ;
669 signalF->SetParameter(3, timezero1) ;
670 gLowGain->Fit(signalF, "QRO", "", 0., timezero2); //, "QRON") ;
671 energy = signalF->GetParameter(2) ;
672 time = signalF->GetMaximumX() - pulse.GetRawFormatTimePeak() - pulse.GetRawFormatTimeTrigger() ;
675 timezero1 = timezero2 = signalmax = timemax = 0. ;
676 signalF->FixParameter(0, pulse.GetRawFormatHighCharge()) ;
677 signalF->FixParameter(1, pulse.GetRawFormatHighGain()) ;
679 for (index = 0; index < pulse.GetRawFormatTimeBins(); index++) {
680 gHighGain->GetPoint(index, time, signal) ;
681 if (signal > kNoiseThreshold && timezero1 == 0.)
683 if (signal <= kNoiseThreshold && timezero1 > 0. && timezero2 == 0.)
685 if (signal > signalmax) {
690 signalmax /= pulse.RawResponseFunctionMax(pulse.GetRawFormatHighCharge(),
691 pulse.GetRawFormatHighGain()) ;;
692 if ( timezero1 + pulse.GetRawFormatTimePeak() < pulse.GetRawFormatTimeMax() * 0.4 ) { // else its noise
693 signalF->SetParameter(2, signalmax) ;
694 signalF->SetParameter(3, timezero1) ;
695 gHighGain->Fit(signalF, "QRO", "", 0., timezero2) ;
696 energy = signalF->GetParameter(2) ;
697 time = signalF->GetMaximumX() - pulse.GetRawFormatTimePeak() - pulse.GetRawFormatTimeTrigger() ;
700 if (time == 0) energy = 0 ;
703 //____________________________________________________________________________
704 Int_t AliPHOSGetter::CalibrateRaw(Double_t energy, Int_t *relId)
706 // Convert energy into digitized amplitude for a cell relId
707 // It is a user responsilibity to open CDB and set
708 // AliPHOSCalibData object by the following operators:
710 // AliCDBLocal *loc = new AliCDBLocal("deCalibDB");
711 // AliPHOSCalibData* clb = (AliPHOSCalibData*)AliCDBStorage::Instance()
712 // ->Get(path_to_calibdata,run_number);
713 // AliPHOSGetter* gime = AliPHOSGetter::Instance("galice.root");
714 // gime->SetCalibData(clb);
716 if (CalibData() == 0)
717 Warning("CalibrateRaw","Calibration DB is not initiated!");
719 Int_t module = relId[0];
720 Int_t column = relId[3];
721 Int_t row = relId[2];
723 Float_t gainFactor = 0.0015; // width of one Emc ADC channel in GeV
724 Float_t pedestal = 0.005; // Emc pedestals
727 gainFactor = CalibData()->GetADCchannelEmc (module,column,row);
728 pedestal = CalibData()->GetADCpedestalEmc(module,column,row);
731 Int_t amp = static_cast<Int_t>( (energy - pedestal) / gainFactor + 0.5 ) ;
734 //____________________________________________________________________________
735 Int_t AliPHOSGetter::ReadRaw(AliRawReader *rawReader,Bool_t isOldRCUFormat)
737 // reads the raw format data, converts it into digits format and store digits in Digits()
739 // isOldRCUFormat = kTRUE in case of the old RCU
740 // format used in the raw data readout.
741 // Reimplemented by Boris Polichtchouk (Jul 2006)
742 // to make it working with the Jul-Aug 2006 beam test data.
744 //Create raw decoder.
746 AliPHOSRawDecoder dc(rawReader);
747 dc.SetOldRCUFormat(isOldRCUFormat);
748 dc.SubtractPedestals(AliPHOSReconstructor::GetRecoParamEmc()->SubtractPedestals());
750 TClonesArray * digits = Digits() ;
751 AliPHOSRawDigiProducer pr;
752 pr.MakeDigits(digits,&dc);
755 for(Int_t i=0; i<digits->GetEntries(); i++) {
756 AliPHOSDigit* digit = (AliPHOSDigit*)digits->At(i);
757 digit->SetEnergy(digit->GetEnergy()/AliPHOSPulseGenerator::GeV2ADC());
768 for(Int_t iDigit=0; iDigit<digits->GetEntries(); iDigit++) {
769 AliPHOSDigit* digit = (AliPHOSDigit*)digits->At(iDigit);
770 if(digit->GetEnergy()>eMax) {
771 PHOSGeometry()->AbsToRelNumbering(digit->GetId(),relId);
772 eMax=digit->GetEnergy();
779 AliDebug(1,Form("Digit with max. energy: modMax %d colMax %d rowMax %d eMax %f\n\n",
780 modMax,colMax,rowMax,eMax));
782 return digits->GetEntriesFast() ;
785 //____________________________________________________________________________
786 Int_t AliPHOSGetter::ReadTreeD() const
790 PhosLoader()->CleanDigits() ;
791 PhosLoader()->LoadDigits("UPDATE") ;
792 PhosLoader()->LoadDigitizer("UPDATE") ;
793 return Digits()->GetEntries() ;
796 //____________________________________________________________________________
797 Int_t AliPHOSGetter::ReadTreeH() const
800 PhosLoader()->CleanHits() ;
801 // gets TreeH from the root file (PHOS.Hit.root)
802 //if ( !IsLoaded("H") ) {
803 PhosLoader()->LoadHits("UPDATE") ;
806 return Hits()->GetEntries() ;
809 //____________________________________________________________________________
810 Int_t AliPHOSGetter::ReadTreeR() const
812 // Read the RecPoints
814 PhosLoader()->CleanRecPoints() ;
815 // gets TreeR from the root file (PHOS.RecPoints.root)
816 //if ( !IsLoaded("R") ) {
817 PhosLoader()->LoadRecPoints("UPDATE") ;
821 return EmcRecPoints()->GetEntries() ;
824 //____________________________________________________________________________
825 Int_t AliPHOSGetter::ReadTreeT() const
827 // Read the TrackSegments
829 PhosLoader()->CleanTracks() ;
830 // gets TreeT from the root file (PHOS.TrackSegments.root)
831 //if ( !IsLoaded("T") ) {
832 PhosLoader()->LoadTracks("UPDATE") ;
833 PhosLoader()->LoadTrackSegmentMaker("UPDATE") ;
837 return TrackSegments()->GetEntries() ;
839 //____________________________________________________________________________
840 Int_t AliPHOSGetter::ReadTreeP() const
842 // Read the RecParticles
844 PhosLoader()->CleanRecParticles() ;
846 // gets TreeT from the root file (PHOS.TrackSegments.root)
847 // if ( !IsLoaded("P") ) {
848 PhosLoader()->LoadRecParticles("UPDATE") ;
849 PhosLoader()->LoadPID("UPDATE") ;
853 return RecParticles()->GetEntries() ;
855 //____________________________________________________________________________
856 Int_t AliPHOSGetter::ReadTreeS() const
860 PhosLoader()->CleanSDigits() ;
861 // gets TreeS from the root file (PHOS.SDigits.root)
862 //if ( !IsLoaded("S") ) {
863 PhosLoader()->LoadSDigits("READ") ;
864 PhosLoader()->LoadSDigitizer("READ") ;
868 return SDigits()->GetEntries() ;
871 //____________________________________________________________________________
872 Int_t AliPHOSGetter::ReadTreeE(Int_t event)
876 // gets esdTree from the root file (AliESDs.root)
878 if ( !OpenESDFile() )
881 fESDTree = static_cast<TTree*>(fESDFile->Get("esdTree")) ;
885 Error("ReadTreeE", "no ESD tree found");
888 fESDTree->SetBranchAddress("ESD", &fESD);
889 fESDTree->GetEvent(event);
894 //____________________________________________________________________________
895 TClonesArray * AliPHOSGetter::SDigits() const
897 // asks the Loader to return the Digits container
899 TClonesArray * rv = 0 ;
901 rv = PhosLoader()->SDigits() ;
903 PhosLoader()->MakeSDigitsArray() ;
904 rv = PhosLoader()->SDigits() ;
909 //____________________________________________________________________________
910 AliPHOSSDigitizer * AliPHOSGetter::SDigitizer()
912 // Returns pointer to the SDigitizer task
913 AliPHOSSDigitizer * rv ;
914 rv = dynamic_cast<AliPHOSSDigitizer *>(PhosLoader()->SDigitizer()) ;
917 rv = dynamic_cast<AliPHOSSDigitizer *>(PhosLoader()->SDigitizer()) ;
922 //____________________________________________________________________________
923 TParticle * AliPHOSGetter::Secondary(const TParticle* p, Int_t index) const
925 // Return first (index=1) or second (index=2) secondary particle of primary particle p
933 Int_t daughterIndex = p->GetDaughter(index-1) ;
934 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
935 return rl->GetAliRun()->GetMCApp()->Particle(daughterIndex) ;
941 //____________________________________________________________________________
942 void AliPHOSGetter::Track(Int_t itrack)
944 // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
946 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
948 if( !TreeH() ) // load treeH the first time
951 // first time create the container
952 TClonesArray * hits = Hits() ;
956 TBranch * phosbranch = dynamic_cast<TBranch*>(TreeH()->GetBranch("PHOS")) ;
957 phosbranch->SetAddress(&hits) ;
958 phosbranch->GetEntry(itrack) ;
961 //____________________________________________________________________________
962 TTree * AliPHOSGetter::TreeD() const
964 // Returns pointer to the Digits Tree
966 rv = PhosLoader()->TreeD() ;
968 PhosLoader()->MakeTree("D");
969 rv = PhosLoader()->TreeD() ;
975 //____________________________________________________________________________
976 TTree * AliPHOSGetter::TreeH() const
978 // Returns pointer to the Hits Tree
980 rv = PhosLoader()->TreeH() ;
982 PhosLoader()->MakeTree("H");
983 rv = PhosLoader()->TreeH() ;
989 //____________________________________________________________________________
990 TTree * AliPHOSGetter::TreeR() const
992 // Returns pointer to the RecPoints Tree
994 rv = PhosLoader()->TreeR() ;
996 PhosLoader()->MakeTree("R");
997 rv = PhosLoader()->TreeR() ;
1003 //____________________________________________________________________________
1004 TTree * AliPHOSGetter::TreeT() const
1006 // Returns pointer to the TrackSegments Tree
1008 rv = PhosLoader()->TreeT() ;
1010 PhosLoader()->MakeTree("T");
1011 rv = PhosLoader()->TreeT() ;
1016 //____________________________________________________________________________
1017 TTree * AliPHOSGetter::TreeP() const
1019 // Returns pointer to the RecParticles Tree
1021 rv = PhosLoader()->TreeP() ;
1023 PhosLoader()->MakeTree("P");
1024 rv = PhosLoader()->TreeP() ;
1030 //____________________________________________________________________________
1031 TTree * AliPHOSGetter::TreeS() const
1033 // Returns pointer to the SDigits Tree
1035 rv = PhosLoader()->TreeS() ;
1037 PhosLoader()->MakeTree("S");
1038 rv = PhosLoader()->TreeS() ;
1044 //____________________________________________________________________________
1045 Bool_t AliPHOSGetter::VersionExists(TString & opt) const
1047 // checks if the version with the present name already exists in the same directory
1049 Bool_t rv = kFALSE ;
1051 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
1052 TString version( rl->GetEventFolder()->GetName() ) ;
1056 if ( opt == "sdigits") {
1057 // add the version name to the root file name
1058 TString fileName( PhosLoader()->GetSDigitsFileName() ) ;
1059 if (version != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
1060 fileName = fileName.ReplaceAll(".root", "") + "_" + version + ".root" ;
1061 if ( !(gSystem->AccessPathName(fileName)) ) {
1062 Warning("VersionExists", "The file %s already exists", fileName.Data()) ;
1065 PhosLoader()->SetSDigitsFileName(fileName) ;
1068 if ( opt == "digits") {
1069 // add the version name to the root file name
1070 TString fileName( PhosLoader()->GetDigitsFileName() ) ;
1071 if (version != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
1072 fileName = fileName.ReplaceAll(".root", "") + "_" + version + ".root" ;
1073 if ( !(gSystem->AccessPathName(fileName)) ) {
1074 Warning("VersionExists", "The file %s already exists", fileName.Data()) ;
1083 //____________________________________________________________________________
1084 UShort_t AliPHOSGetter::EventPattern(void) const
1086 // Return the pattern (trigger bit register) of the beam-test event
1088 return fBTE->GetPattern() ;
1092 //____________________________________________________________________________
1093 Float_t AliPHOSGetter::BeamEnergy(void) const
1095 // Return the beam energy of the beam-test event
1097 return fBTE->GetBeamEnergy() ;
1101 //____________________________________________________________________________
1103 AliPHOSCalibData* AliPHOSGetter::CalibData()
1105 // Check if the instance of AliPHOSCalibData exists, and return it