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 "AliPHOSRawStream.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 //____________________________________________________________________________
82 AliPHOSGetter::AliPHOSGetter(const char* headerFile, const char* version, Option_t * openingOption)
84 // ctor only called by Instance()
86 AliRunLoader* rl = AliRunLoader::GetRunLoader(version) ;
88 rl = AliRunLoader::Open(headerFile, version, openingOption);
90 Fatal("AliPHOSGetter", "Could not find the Run Loader for %s - %s",headerFile, version) ;
93 if (rl->GetAliRun() == 0x0) {
95 gAlice = rl->GetAliRun(); // should be removed
99 fgPhosLoader = dynamic_cast<AliPHOSLoader*>(rl->GetLoader("PHOSLoader"));
101 Error("AliPHOSGetter", "Could not find PHOSLoader") ;
103 fgPhosLoader->SetTitle(version);
105 // initialize data members
109 fLoadingStatus = "" ;
111 fESDFileName = rl->GetFileName() ; // this should be the galice.root file
112 fESDFileName.ReplaceAll("galice.root", "AliESDs.root") ;
116 fRawDigits = kFALSE ;
120 //____________________________________________________________________________
121 AliPHOSGetter::~AliPHOSGetter()
125 delete fgPhosLoader ;
133 fPrimaries->Delete() ;
144 //____________________________________________________________________________
145 void AliPHOSGetter::Reset()
147 // resets things in case the getter is called consecutively with different files
148 // the PHOS Loader is already deleted by the Run Loader
151 fPrimaries->Delete() ;
158 //____________________________________________________________________________
159 AliPHOSClusterizer * AliPHOSGetter::Clusterizer()
161 // Returns pointer to the Clusterizer task
162 AliPHOSClusterizer * rv ;
163 rv = dynamic_cast<AliPHOSClusterizer *>(PhosLoader()->Reconstructioner()) ;
166 rv = dynamic_cast<AliPHOSClusterizer*>(PhosLoader()->Reconstructioner()) ;
171 //____________________________________________________________________________
172 TObjArray * AliPHOSGetter::CpvRecPoints() const
174 // asks the Loader to return the CPV RecPoints container
178 rv = PhosLoader()->CpvRecPoints() ;
180 PhosLoader()->MakeRecPointsArray() ;
181 rv = PhosLoader()->CpvRecPoints() ;
186 //____________________________________________________________________________
187 TClonesArray * AliPHOSGetter::Digits() const
189 // asks the Loader to return the Digits container
191 TClonesArray * rv = 0 ;
192 rv = PhosLoader()->Digits() ;
195 PhosLoader()->MakeDigitsArray() ;
196 rv = PhosLoader()->Digits() ;
201 //____________________________________________________________________________
202 AliPHOSDigitizer * AliPHOSGetter::Digitizer()
204 // Returns pointer to the Digitizer task
205 AliPHOSDigitizer * rv ;
206 rv = dynamic_cast<AliPHOSDigitizer *>(PhosLoader()->Digitizer()) ;
209 rv = dynamic_cast<AliPHOSDigitizer *>(PhosLoader()->Digitizer()) ;
215 //____________________________________________________________________________
216 TObjArray * AliPHOSGetter::EmcRecPoints() const
218 // asks the Loader to return the EMC RecPoints container
222 rv = PhosLoader()->EmcRecPoints() ;
224 PhosLoader()->MakeRecPointsArray() ;
225 rv = PhosLoader()->EmcRecPoints() ;
230 //____________________________________________________________________________
231 TClonesArray * AliPHOSGetter::TrackSegments() const
233 // asks the Loader to return the TrackSegments container
235 TClonesArray * rv = 0 ;
237 rv = PhosLoader()->TrackSegments() ;
239 PhosLoader()->MakeTrackSegmentsArray() ;
240 rv = PhosLoader()->TrackSegments() ;
245 //____________________________________________________________________________
246 AliPHOSTrackSegmentMaker * AliPHOSGetter::TrackSegmentMaker()
248 // Returns pointer to the TrackSegmentMaker task
249 AliPHOSTrackSegmentMaker * rv ;
250 rv = dynamic_cast<AliPHOSTrackSegmentMaker *>(PhosLoader()->TrackSegmentMaker()) ;
253 rv = dynamic_cast<AliPHOSTrackSegmentMaker *>(PhosLoader()->TrackSegmentMaker()) ;
258 //____________________________________________________________________________
259 TClonesArray * AliPHOSGetter::RecParticles() const
261 // asks the Loader to return the TrackSegments container
263 TClonesArray * rv = 0 ;
265 rv = PhosLoader()->RecParticles() ;
267 PhosLoader()->MakeRecParticlesArray() ;
268 rv = PhosLoader()->RecParticles() ;
272 //____________________________________________________________________________
273 void AliPHOSGetter::Event(Int_t event, const char* opt)
275 // Reads the content of all Tree's S, D and R
277 // if ( event >= MaxEvent() ) {
278 // Error("Event", "%d not found in TreeE !", event) ;
282 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
284 // // checks if we are dealing with test-beam data
285 // TBranch * btb = rl->TreeE()->GetBranch("AliPHOSBeamTestEvent") ;
288 // fBTE = new AliPHOSBeamTestEvent() ;
289 // btb->SetAddress(&fBTE) ;
290 // btb->GetEntry(event) ;
299 // Loads the type of object(s) requested
301 rl->GetEvent(event) ;
303 if(strstr(opt,"X") || (strcmp(opt,"")==0)){
307 if(strstr(opt,"H") ){
311 if(strstr(opt,"S") ){
315 if(strstr(opt,"D") ){
319 if(strstr(opt,"R") ){
323 if( strstr(opt,"T") ){
327 if( strstr(opt,"P") ){
331 if( strstr(opt,"E") ){
338 //____________________________________________________________________________
339 void AliPHOSGetter::Event(AliRawReader *rawReader, const char* opt)
341 // Reads the raw event from rawReader
343 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
345 if( strstr(opt,"W") ){
346 rawReader->NextEvent();
347 Int_t iEvent = rl->GetEventNumber();
348 rl->GetEvent(iEvent);
355 //____________________________________________________________________________
356 Int_t AliPHOSGetter::EventNumber() const
358 // return the current event number
359 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
360 return static_cast<Int_t>(rl->GetEventNumber()) ;
363 //____________________________________________________________________________
364 TClonesArray * AliPHOSGetter::Hits() const
366 // asks the loader to return the Hits container
368 TClonesArray * rv = 0 ;
370 rv = PhosLoader()->Hits() ;
372 PhosLoader()->LoadHits("read");
373 rv = PhosLoader()->Hits() ;
378 //____________________________________________________________________________
379 AliPHOSGetter * AliPHOSGetter::Instance(const char* alirunFileName, const char* version, Option_t * openingOption)
381 // Creates and returns the pointer of the unique instance
382 // Must be called only when the environment has changed
384 if(!fgObjGetter){ // first time the getter is called
385 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
387 else { // the getter has been called previously
388 AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle());
389 if ( rl->GetFileName() == alirunFileName ) {// the alirunFile has the same name
390 // check if the file is already open
391 TFile * galiceFile = dynamic_cast<TFile *>(gROOT->FindObject(rl->GetFileName()) ) ;
394 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
396 else { // the file is already open check the version name
397 TString currentVersionName = rl->GetEventFolder()->GetName() ;
398 TString newVersionName(version) ;
399 if (currentVersionName == newVersionName)
401 ::Warning( "Instance", "Files with version %s already open", currentVersionName.Data() ) ;
403 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
408 AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle()) ;
409 if ( strstr(version, AliConfig::GetDefaultEventFolderName()) ) // false in case of merging
411 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
415 ::Error("AliPHOSGetter::Instance", "Failed to create the PHOS Getter object") ;
423 //____________________________________________________________________________
424 AliPHOSGetter * AliPHOSGetter::Instance()
426 // Returns the pointer of the unique instance already defined
428 if(!fgObjGetter && fgDebug)
429 ::Warning("AliPHOSGetter::Instance", "Getter not initialized") ;
435 //____________________________________________________________________________
436 Int_t AliPHOSGetter::MaxEvent() const
438 // returns the number of events in the run (from TE)
440 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
441 return static_cast<Int_t>(rl->GetNumberOfEvents()) ;
444 //____________________________________________________________________________
445 TParticle * AliPHOSGetter::Primary(Int_t index) const
447 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
448 return rl->Stack()->Particle(index) ;
451 //____________________________________________________________________________
452 AliPHOS * AliPHOSGetter:: PHOS() const
454 // returns the PHOS object
455 AliPHOSLoader * loader = 0;
456 static AliPHOSLoader * oldloader = 0;
457 static AliPHOS * phos = 0;
459 loader = PhosLoader();
461 if ( loader != oldloader) {
462 phos = dynamic_cast<AliPHOS*>(loader->GetModulesFolder()->FindObject("PHOS")) ;
467 Warning("PHOS", "PHOS module not found in module folders: %s", PhosLoader()->GetModulesFolder()->GetName() ) ;
473 //____________________________________________________________________________
474 AliPHOSPID * AliPHOSGetter::PID()
476 // Returns pointer to the PID task
478 rv = dynamic_cast<AliPHOSPID *>(PhosLoader()->PIDTask()) ;
481 rv = dynamic_cast<AliPHOSPID *>(PhosLoader()->PIDTask()) ;
486 //____________________________________________________________________________
487 AliPHOSGeometry * AliPHOSGetter::PHOSGeometry() const
489 // Returns PHOS geometry
491 AliPHOSGeometry * rv = 0 ;
493 rv = PHOS()->GetGeometry() ;
497 //____________________________________________________________________________
498 TClonesArray * AliPHOSGetter::Primaries()
500 // creates the Primaries container if needed
503 Info("Primaries", "Creating a new TClonesArray for primaries") ;
504 fPrimaries = new TClonesArray("TParticle", 1000) ;
509 //____________________________________________________________________________
510 void AliPHOSGetter::Print()
512 // Print usefull information about the getter
514 AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle());
515 ::Info( "Print", "gAlice file is %s -- version name is %s", (rl->GetFileName()).Data(), rl->GetEventFolder()->GetName() ) ;
518 //____________________________________________________________________________
519 void AliPHOSGetter::ReadPrimaries()
521 // Read Primaries from Kinematics.root
523 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
525 // gets kine tree from the root file (Kinematics.root)
526 if ( ! rl->TreeK() ) { // load treeK the first time
527 rl->LoadKinematics() ;
530 fNPrimaries = (rl->GetHeader())->GetNtrack();
532 Info( "ReadTreeK", "Found %d particles in event # %d", fNPrimaries, EventNumber() ) ;
535 // first time creates the container
537 fPrimaries->Clear() ;
540 for (index = 0 ; index < fNPrimaries; index++) {
541 new ((*fPrimaries)[index]) TParticle(*(Primary(index)));
545 //____________________________________________________________________________
546 Bool_t AliPHOSGetter::OpenESDFile()
551 fESDFile = TFile::Open(fESDFileName) ;
555 else if (fESDFile->IsOpen()) {
557 fESDFile = TFile::Open(fESDFileName) ;
559 if (!fESDFile->IsOpen())
564 //____________________________________________________________________________
565 void AliPHOSGetter::FitRaw(Bool_t lowGainFlag, TGraph * gLowGain, TGraph * gHighGain, TF1* signalF, Double_t & energy, Double_t & time) const
567 // Fits the raw signal time distribution
569 const Int_t kNoiseThreshold = 0 ;
570 Double_t timezero1 = 0., timezero2 = 0., timemax = 0. ;
571 Double_t signal = 0., signalmax = 0. ;
576 timezero1 = timezero2 = signalmax = timemax = 0. ;
577 signalF->FixParameter(0, PHOS()->GetRawFormatLowCharge()) ;
578 signalF->FixParameter(1, PHOS()->GetRawFormatLowGain()) ;
580 for (index = 0; index < PHOS()->GetRawFormatTimeBins(); index++) {
581 gLowGain->GetPoint(index, time, signal) ;
582 if (signal > kNoiseThreshold && timezero1 == 0.)
584 if (signal <= kNoiseThreshold && timezero1 > 0. && timezero2 == 0.)
586 if (signal > signalmax) {
591 signalmax /= PHOS()->RawResponseFunctionMax(PHOS()->GetRawFormatLowCharge(),
592 PHOS()->GetRawFormatLowGain()) ;
593 if ( timezero1 + PHOS()->GetRawFormatTimePeak() < PHOS()->GetRawFormatTimeMax() * 0.4 ) { // else its noise
594 signalF->SetParameter(2, signalmax) ;
595 signalF->SetParameter(3, timezero1) ;
596 gLowGain->Fit(signalF, "QRO", "", 0., timezero2); //, "QRON") ;
597 energy = signalF->GetParameter(2) ;
598 time = signalF->GetMaximumX() - PHOS()->GetRawFormatTimePeak() - PHOS()->GetRawFormatTimeTrigger() ;
601 timezero1 = timezero2 = signalmax = timemax = 0. ;
602 signalF->FixParameter(0, PHOS()->GetRawFormatHighCharge()) ;
603 signalF->FixParameter(1, PHOS()->GetRawFormatHighGain()) ;
605 for (index = 0; index < PHOS()->GetRawFormatTimeBins(); index++) {
606 gHighGain->GetPoint(index, time, signal) ;
607 if (signal > kNoiseThreshold && timezero1 == 0.)
609 if (signal <= kNoiseThreshold && timezero1 > 0. && timezero2 == 0.)
611 if (signal > signalmax) {
616 signalmax /= PHOS()->RawResponseFunctionMax(PHOS()->GetRawFormatHighCharge(),
617 PHOS()->GetRawFormatHighGain()) ;;
618 if ( timezero1 + PHOS()->GetRawFormatTimePeak() < PHOS()->GetRawFormatTimeMax() * 0.4 ) { // else its noise
619 signalF->SetParameter(2, signalmax) ;
620 signalF->SetParameter(3, timezero1) ;
621 gHighGain->Fit(signalF, "QRO", "", 0., timezero2) ;
622 energy = signalF->GetParameter(2) ;
623 time = signalF->GetMaximumX() - PHOS()->GetRawFormatTimePeak() - PHOS()->GetRawFormatTimeTrigger() ;
626 if (time == 0) energy = 0 ;
629 //____________________________________________________________________________
630 Int_t AliPHOSGetter::CalibrateRaw(Double_t energy, Int_t *relId)
632 // Convert energy into digitized amplitude for a cell relId
633 // It is a user responsilibity to open CDB and set
634 // AliPHOSCalibData object by the following operators:
636 // AliCDBLocal *loc = new AliCDBLocal("deCalibDB");
637 // AliPHOSCalibData* clb = (AliPHOSCalibData*)AliCDBStorage::Instance()
638 // ->Get(path_to_calibdata,run_number);
639 // AliPHOSGetter* gime = AliPHOSGetter::Instance("galice.root");
640 // gime->SetCalibData(clb);
642 if (CalibData() == 0)
643 Warning("CalibrateRaw","Calibration DB is not initiated!");
645 Int_t module = relId[0];
646 Int_t column = relId[3];
647 Int_t row = relId[2];
649 Float_t gainFactor = 0.0015; // width of one Emc ADC channel in GeV
650 Float_t pedestal = 0.005; // Emc pedestals
653 gainFactor = CalibData()->GetADCchannelEmc (module,column,row);
654 pedestal = CalibData()->GetADCpedestalEmc(module,column,row);
657 Int_t amp = static_cast<Int_t>( (energy - pedestal) / gainFactor + 0.5 ) ;
660 //____________________________________________________________________________
661 Int_t AliPHOSGetter::ReadRaw(AliRawReader *rawReader)
663 // reads the raw format data, converts it into digits format and store digits in Digits()
666 AliPHOSRawStream in(rawReader);
668 Bool_t first = kTRUE ;
670 TF1 * signalF = new TF1("signal", AliPHOS::RawResponseFunction, 0, PHOS()->GetRawFormatTimeMax(), 4);
671 signalF->SetParNames("Charge", "Gain", "Amplitude", "TimeZero") ;
673 Int_t relId[4], id =0;
674 Bool_t lowGainFlag = kFALSE ;
676 TClonesArray * digits = Digits() ;
680 Double_t energy = 0. ;
683 TGraph * gLowGain = new TGraph(PHOS()->GetRawFormatTimeBins()) ;
684 TGraph * gHighGain= new TGraph(PHOS()->GetRawFormatTimeBins()) ;
685 gLowGain ->SetTitle("Low gain channel");
686 gHighGain->SetTitle("High gain channel");
688 while ( in.Next() ) { // PHOS entries loop
689 if ( (in.IsNewRow() || in.IsNewColumn() || in.IsNewModule()) ) {
691 FitRaw(lowGainFlag, gLowGain, gHighGain, signalF, energy, time) ;
694 new((*digits)[idigit]) AliPHOSDigit( -1, id, (Float_t)energy, time) ;
698 for (index = 0; index < PHOS()->GetRawFormatTimeBins(); index++) {
699 gLowGain ->SetPoint(index,
700 index * PHOS()->GetRawFormatTimeMax() /
701 PHOS()->GetRawFormatTimeBins(), 0) ;
702 gHighGain->SetPoint(index,
703 index * PHOS()->GetRawFormatTimeMax() /
704 PHOS()->GetRawFormatTimeBins(), 0) ;
708 relId[0] = in.GetModule() ;
709 if ( relId[0] >= PHOS()->GetRawFormatLowGainOffset() ) {
710 relId[0] -= PHOS()->GetRawFormatLowGainOffset() ;
711 lowGainFlag = kTRUE ;
713 lowGainFlag = kFALSE ;
715 relId[2] = in.GetRow() ;
716 relId[3] = in.GetColumn() ;
717 PHOSGeometry()->RelToAbsNumbering(relId, id) ;
720 gLowGain->SetPoint(in.GetTime(),
721 in.GetTime()* PHOS()->GetRawFormatTimeMax() /
722 PHOS()->GetRawFormatTimeBins(),
725 gHighGain->SetPoint(in.GetTime(),
726 in.GetTime() * PHOS()->GetRawFormatTimeMax() /
727 PHOS()->GetRawFormatTimeBins(),
730 } // PHOS entries loop
732 FitRaw(lowGainFlag, gLowGain, gHighGain, signalF, energy, time) ;
735 new((*digits)[idigit]) AliPHOSDigit( -1, id, (Float_t)energy, time) ;
744 return digits->GetEntriesFast() ;
747 //____________________________________________________________________________
748 Int_t AliPHOSGetter::ReadTreeD() const
752 PhosLoader()->CleanDigits() ;
753 PhosLoader()->LoadDigits("UPDATE") ;
754 PhosLoader()->LoadDigitizer("UPDATE") ;
755 return Digits()->GetEntries() ;
758 //____________________________________________________________________________
759 Int_t AliPHOSGetter::ReadTreeH() const
762 PhosLoader()->CleanHits() ;
763 // gets TreeH from the root file (PHOS.Hit.root)
764 //if ( !IsLoaded("H") ) {
765 PhosLoader()->LoadHits("UPDATE") ;
768 return Hits()->GetEntries() ;
771 //____________________________________________________________________________
772 Int_t AliPHOSGetter::ReadTreeR() const
774 // Read the RecPoints
776 PhosLoader()->CleanRecPoints() ;
777 // gets TreeR from the root file (PHOS.RecPoints.root)
778 //if ( !IsLoaded("R") ) {
779 PhosLoader()->LoadRecPoints("UPDATE") ;
780 PhosLoader()->LoadClusterizer("UPDATE") ;
784 return EmcRecPoints()->GetEntries() ;
787 //____________________________________________________________________________
788 Int_t AliPHOSGetter::ReadTreeT() const
790 // Read the TrackSegments
792 PhosLoader()->CleanTracks() ;
793 // gets TreeT from the root file (PHOS.TrackSegments.root)
794 //if ( !IsLoaded("T") ) {
795 PhosLoader()->LoadTracks("UPDATE") ;
796 PhosLoader()->LoadTrackSegmentMaker("UPDATE") ;
800 return TrackSegments()->GetEntries() ;
802 //____________________________________________________________________________
803 Int_t AliPHOSGetter::ReadTreeP() const
805 // Read the RecParticles
807 PhosLoader()->CleanRecParticles() ;
809 // gets TreeT from the root file (PHOS.TrackSegments.root)
810 // if ( !IsLoaded("P") ) {
811 PhosLoader()->LoadRecParticles("UPDATE") ;
812 PhosLoader()->LoadPID("UPDATE") ;
816 return RecParticles()->GetEntries() ;
818 //____________________________________________________________________________
819 Int_t AliPHOSGetter::ReadTreeS() const
823 PhosLoader()->CleanSDigits() ;
824 // gets TreeS from the root file (PHOS.SDigits.root)
825 //if ( !IsLoaded("S") ) {
826 PhosLoader()->LoadSDigits("READ") ;
827 PhosLoader()->LoadSDigitizer("READ") ;
831 return SDigits()->GetEntries() ;
834 //____________________________________________________________________________
835 Int_t AliPHOSGetter::ReadTreeE(Int_t event)
839 // gets esdTree from the root file (AliESDs.root)
841 if ( !OpenESDFile() )
844 fESDTree = static_cast<TTree*>(fESDFile->Get("esdTree")) ;
848 Error("ReadTreeE", "no ESD tree found");
851 fESDTree->SetBranchAddress("ESD", &fESD);
852 fESDTree->GetEvent(event);
857 //____________________________________________________________________________
858 TClonesArray * AliPHOSGetter::SDigits() const
860 // asks the Loader to return the Digits container
862 TClonesArray * rv = 0 ;
864 rv = PhosLoader()->SDigits() ;
866 PhosLoader()->MakeSDigitsArray() ;
867 rv = PhosLoader()->SDigits() ;
872 //____________________________________________________________________________
873 AliPHOSSDigitizer * AliPHOSGetter::SDigitizer()
875 // Returns pointer to the SDigitizer task
876 AliPHOSSDigitizer * rv ;
877 rv = dynamic_cast<AliPHOSSDigitizer *>(PhosLoader()->SDigitizer()) ;
880 rv = dynamic_cast<AliPHOSSDigitizer *>(PhosLoader()->SDigitizer()) ;
885 //____________________________________________________________________________
886 TParticle * AliPHOSGetter::Secondary(const TParticle* p, Int_t index) const
888 // Return first (index=1) or second (index=2) secondary particle of primary particle p
896 Int_t daughterIndex = p->GetDaughter(index-1) ;
897 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
898 return rl->GetAliRun()->GetMCApp()->Particle(daughterIndex) ;
904 //____________________________________________________________________________
905 void AliPHOSGetter::Track(Int_t itrack)
907 // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
909 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
911 if( !TreeH() ) // load treeH the first time
914 // first time create the container
915 TClonesArray * hits = Hits() ;
919 TBranch * phosbranch = dynamic_cast<TBranch*>(TreeH()->GetBranch("PHOS")) ;
920 phosbranch->SetAddress(&hits) ;
921 phosbranch->GetEntry(itrack) ;
924 //____________________________________________________________________________
925 TTree * AliPHOSGetter::TreeD() const
927 // Returns pointer to the Digits Tree
929 rv = PhosLoader()->TreeD() ;
931 PhosLoader()->MakeTree("D");
932 rv = PhosLoader()->TreeD() ;
938 //____________________________________________________________________________
939 TTree * AliPHOSGetter::TreeH() const
941 // Returns pointer to the Hits Tree
943 rv = PhosLoader()->TreeH() ;
945 PhosLoader()->MakeTree("H");
946 rv = PhosLoader()->TreeH() ;
952 //____________________________________________________________________________
953 TTree * AliPHOSGetter::TreeR() const
955 // Returns pointer to the RecPoints Tree
957 rv = PhosLoader()->TreeR() ;
959 PhosLoader()->MakeTree("R");
960 rv = PhosLoader()->TreeR() ;
966 //____________________________________________________________________________
967 TTree * AliPHOSGetter::TreeT() const
969 // Returns pointer to the TrackSegments Tree
971 rv = PhosLoader()->TreeT() ;
973 PhosLoader()->MakeTree("T");
974 rv = PhosLoader()->TreeT() ;
979 //____________________________________________________________________________
980 TTree * AliPHOSGetter::TreeP() const
982 // Returns pointer to the RecParticles Tree
984 rv = PhosLoader()->TreeP() ;
986 PhosLoader()->MakeTree("P");
987 rv = PhosLoader()->TreeP() ;
993 //____________________________________________________________________________
994 TTree * AliPHOSGetter::TreeS() const
996 // Returns pointer to the SDigits Tree
998 rv = PhosLoader()->TreeS() ;
1000 PhosLoader()->MakeTree("S");
1001 rv = PhosLoader()->TreeS() ;
1007 //____________________________________________________________________________
1008 Bool_t AliPHOSGetter::VersionExists(TString & opt) const
1010 // checks if the version with the present name already exists in the same directory
1012 Bool_t rv = kFALSE ;
1014 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
1015 TString version( rl->GetEventFolder()->GetName() ) ;
1019 if ( opt == "sdigits") {
1020 // add the version name to the root file name
1021 TString fileName( PhosLoader()->GetSDigitsFileName() ) ;
1022 if (version != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
1023 fileName = fileName.ReplaceAll(".root", "") + "_" + version + ".root" ;
1024 if ( !(gSystem->AccessPathName(fileName)) ) {
1025 Warning("VersionExists", "The file %s already exists", fileName.Data()) ;
1028 PhosLoader()->SetSDigitsFileName(fileName) ;
1031 if ( opt == "digits") {
1032 // add the version name to the root file name
1033 TString fileName( PhosLoader()->GetDigitsFileName() ) ;
1034 if (version != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
1035 fileName = fileName.ReplaceAll(".root", "") + "_" + version + ".root" ;
1036 if ( !(gSystem->AccessPathName(fileName)) ) {
1037 Warning("VersionExists", "The file %s already exists", fileName.Data()) ;
1046 //____________________________________________________________________________
1047 UShort_t AliPHOSGetter::EventPattern(void) const
1049 // Return the pattern (trigger bit register) of the beam-test event
1051 return fBTE->GetPattern() ;
1055 //____________________________________________________________________________
1056 Float_t AliPHOSGetter::BeamEnergy(void) const
1058 // Return the beam energy of the beam-test event
1060 return fBTE->GetBeamEnergy() ;
1064 //____________________________________________________________________________
1066 AliPHOSCalibData* AliPHOSGetter::CalibData()
1068 // Check if the instance of AliPHOSCalibData exists, and return it