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>
49 //#include <TCanvas.h>
52 // --- Standard library ---
54 // --- AliRoot header files ---
56 #include "AliHeader.h"
59 #include "AliPHOSBeamTestEvent.h"
60 #include "AliPHOSGetter.h"
61 #include "AliPHOSLoader.h"
62 #include "AliRunLoader.h"
64 #include "AliPHOSRawStream.h"
65 #include "AliRawReaderFile.h"
67 #include "AliCDBLocal.h"
68 #include "AliCDBStorage.h"
70 ClassImp(AliPHOSGetter)
72 AliPHOSGetter * AliPHOSGetter::fgObjGetter = 0 ;
73 AliPHOSLoader * AliPHOSGetter::fgPhosLoader = 0;
74 Int_t AliPHOSGetter::fgDebug = 0;
75 AliPHOSCalibData* AliPHOSGetter::fCalibData = 0;
77 // TFile * AliPHOSGetter::fgFile = 0 ;
79 //____________________________________________________________________________
80 AliPHOSGetter::AliPHOSGetter(const char* headerFile, const char* version, Option_t * openingOption)
82 // ctor only called by Instance()
84 AliRunLoader* rl = AliRunLoader::GetRunLoader(version) ;
86 rl = AliRunLoader::Open(headerFile, version, openingOption);
88 Fatal("AliPHOSGetter", "Could not find the Run Loader for %s - %s",headerFile, version) ;
91 if (rl->GetAliRun() == 0x0) {
93 gAlice = rl->GetAliRun(); // should be removed
97 fgPhosLoader = dynamic_cast<AliPHOSLoader*>(rl->GetLoader("PHOSLoader"));
99 Error("AliPHOSGetter", "Could not find PHOSLoader") ;
101 fgPhosLoader->SetTitle(version);
103 // initialize data members
107 fLoadingStatus = "" ;
109 fESDFileName = rl->GetFileName() ; // this should be the galice.root file
110 fESDFileName.ReplaceAll("galice.root", "AliESDs.root") ;
114 fRawDigits = kFALSE ;
118 //____________________________________________________________________________
119 AliPHOSGetter::~AliPHOSGetter()
123 delete fgPhosLoader ;
131 fPrimaries->Delete() ;
142 //____________________________________________________________________________
143 void AliPHOSGetter::Reset()
145 // resets things in case the getter is called consecutively with different files
146 // the PHOS Loader is already deleted by the Run Loader
149 fPrimaries->Delete() ;
156 //____________________________________________________________________________
157 AliPHOSClusterizer * AliPHOSGetter::Clusterizer()
159 // Returns pointer to the Clusterizer task
160 AliPHOSClusterizer * rv ;
161 rv = dynamic_cast<AliPHOSClusterizer *>(PhosLoader()->Reconstructioner()) ;
164 rv = dynamic_cast<AliPHOSClusterizer*>(PhosLoader()->Reconstructioner()) ;
169 //____________________________________________________________________________
170 TObjArray * AliPHOSGetter::CpvRecPoints()
172 // asks the Loader to return the CPV RecPoints container
176 rv = PhosLoader()->CpvRecPoints() ;
178 PhosLoader()->MakeRecPointsArray() ;
179 rv = PhosLoader()->CpvRecPoints() ;
184 //____________________________________________________________________________
185 TClonesArray * AliPHOSGetter::Digits()
187 // asks the Loader to return the Digits container
189 TClonesArray * rv = 0 ;
190 rv = PhosLoader()->Digits() ;
193 PhosLoader()->MakeDigitsArray() ;
194 rv = PhosLoader()->Digits() ;
199 //____________________________________________________________________________
200 AliPHOSDigitizer * AliPHOSGetter::Digitizer()
202 // Returns pointer to the Digitizer task
203 AliPHOSDigitizer * rv ;
204 rv = dynamic_cast<AliPHOSDigitizer *>(PhosLoader()->Digitizer()) ;
207 rv = dynamic_cast<AliPHOSDigitizer *>(PhosLoader()->Digitizer()) ;
213 //____________________________________________________________________________
214 TObjArray * AliPHOSGetter::EmcRecPoints()
216 // asks the Loader to return the EMC RecPoints container
220 rv = PhosLoader()->EmcRecPoints() ;
222 PhosLoader()->MakeRecPointsArray() ;
223 rv = PhosLoader()->EmcRecPoints() ;
228 //____________________________________________________________________________
229 TClonesArray * AliPHOSGetter::TrackSegments()
231 // asks the Loader to return the TrackSegments container
233 TClonesArray * rv = 0 ;
235 rv = PhosLoader()->TrackSegments() ;
237 PhosLoader()->MakeTrackSegmentsArray() ;
238 rv = PhosLoader()->TrackSegments() ;
243 //____________________________________________________________________________
244 AliPHOSTrackSegmentMaker * AliPHOSGetter::TrackSegmentMaker()
246 // Returns pointer to the TrackSegmentMaker task
247 AliPHOSTrackSegmentMaker * rv ;
248 rv = dynamic_cast<AliPHOSTrackSegmentMaker *>(PhosLoader()->TrackSegmentMaker()) ;
251 rv = dynamic_cast<AliPHOSTrackSegmentMaker *>(PhosLoader()->TrackSegmentMaker()) ;
256 //____________________________________________________________________________
257 TClonesArray * AliPHOSGetter::RecParticles()
259 // asks the Loader to return the TrackSegments container
261 TClonesArray * rv = 0 ;
263 rv = PhosLoader()->RecParticles() ;
265 PhosLoader()->MakeRecParticlesArray() ;
266 rv = PhosLoader()->RecParticles() ;
270 //____________________________________________________________________________
271 void AliPHOSGetter::Event(Int_t event, const char* opt)
273 // Reads the content of all Tree's S, D and R
275 // if ( event >= MaxEvent() ) {
276 // Error("Event", "%d not found in TreeE !", event) ;
280 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
282 // // checks if we are dealing with test-beam data
283 // TBranch * btb = rl->TreeE()->GetBranch("AliPHOSBeamTestEvent") ;
286 // fBTE = new AliPHOSBeamTestEvent() ;
287 // btb->SetAddress(&fBTE) ;
288 // btb->GetEntry(event) ;
297 // Loads the type of object(s) requested
299 rl->GetEvent(event) ;
301 if(strstr(opt,"X") || (strcmp(opt,"")==0)){
305 if(strstr(opt,"H") ){
309 if(strstr(opt,"S") ){
313 if(strstr(opt,"D") ){
317 if(strstr(opt,"R") ){
321 if( strstr(opt,"T") ){
325 if( strstr(opt,"P") ){
329 if( strstr(opt,"E") ){
336 //____________________________________________________________________________
337 void AliPHOSGetter::Event(AliRawReader *rawReader, const char* opt)
339 // Reads the raw event from rawReader
341 if( strstr(opt,"W") ){
348 //____________________________________________________________________________
349 Int_t AliPHOSGetter::EventNumber() const
351 // return the current event number
352 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
353 return static_cast<Int_t>(rl->GetEventNumber()) ;
356 //____________________________________________________________________________
357 TClonesArray * AliPHOSGetter::Hits()
359 // asks the loader to return the Hits container
361 TClonesArray * rv = 0 ;
363 rv = PhosLoader()->Hits() ;
365 PhosLoader()->LoadHits("read");
366 rv = PhosLoader()->Hits() ;
371 //____________________________________________________________________________
372 AliPHOSGetter * AliPHOSGetter::Instance(const char* alirunFileName, const char* version, Option_t * openingOption)
374 // Creates and returns the pointer of the unique instance
375 // Must be called only when the environment has changed
377 if(!fgObjGetter){ // first time the getter is called
378 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
380 else { // the getter has been called previously
381 AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle());
382 if ( rl->GetFileName() == alirunFileName ) {// the alirunFile has the same name
383 // check if the file is already open
384 TFile * galiceFile = dynamic_cast<TFile *>(gROOT->FindObject(rl->GetFileName()) ) ;
387 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
389 else { // the file is already open check the version name
390 TString currentVersionName = rl->GetEventFolder()->GetName() ;
391 TString newVersionName(version) ;
392 if (currentVersionName == newVersionName)
394 ::Warning( "Instance", "Files with version %s already open", currentVersionName.Data() ) ;
396 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
401 AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle()) ;
402 if ( strstr(version, AliConfig::GetDefaultEventFolderName()) ) // false in case of merging
404 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
408 ::Error("AliPHOSGetter::Instance", "Failed to create the PHOS Getter object") ;
416 //____________________________________________________________________________
417 AliPHOSGetter * AliPHOSGetter::Instance()
419 // Returns the pointer of the unique instance already defined
421 if(!fgObjGetter && fgDebug)
422 ::Warning("AliPHOSGetter::Instance", "Getter not initialized") ;
428 //____________________________________________________________________________
429 Int_t AliPHOSGetter::MaxEvent() const
431 // returns the number of events in the run (from TE)
433 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
434 return static_cast<Int_t>(rl->GetNumberOfEvents()) ;
437 //____________________________________________________________________________
438 TParticle * AliPHOSGetter::Primary(Int_t index) const
440 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
441 return rl->Stack()->Particle(index) ;
444 //____________________________________________________________________________
445 AliPHOS * AliPHOSGetter:: PHOS() const
447 // returns the PHOS object
448 AliPHOSLoader * loader = 0;
449 static AliPHOSLoader * oldloader = 0;
450 static AliPHOS * phos = 0;
452 loader = PhosLoader();
454 if ( loader != oldloader) {
455 phos = dynamic_cast<AliPHOS*>(loader->GetModulesFolder()->FindObject("PHOS")) ;
460 Warning("PHOS", "PHOS module not found in module folders: %s", PhosLoader()->GetModulesFolder()->GetName() ) ;
466 //____________________________________________________________________________
467 AliPHOSPID * AliPHOSGetter::PID()
469 // Returns pointer to the PID task
471 rv = dynamic_cast<AliPHOSPID *>(PhosLoader()->PIDTask()) ;
474 rv = dynamic_cast<AliPHOSPID *>(PhosLoader()->PIDTask()) ;
479 //____________________________________________________________________________
480 AliPHOSGeometry * AliPHOSGetter::PHOSGeometry() const
482 // Returns PHOS geometry
484 AliPHOSGeometry * rv = 0 ;
486 rv = PHOS()->GetGeometry() ;
490 //____________________________________________________________________________
491 TClonesArray * AliPHOSGetter::Primaries()
493 // creates the Primaries container if needed
496 Info("Primaries", "Creating a new TClonesArray for primaries") ;
497 fPrimaries = new TClonesArray("TParticle", 1000) ;
502 //____________________________________________________________________________
503 void AliPHOSGetter::Print()
505 // Print usefull information about the getter
507 AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle());
508 ::Info( "Print", "gAlice file is %s -- version name is %s", (rl->GetFileName()).Data(), rl->GetEventFolder()->GetName() ) ;
511 //____________________________________________________________________________
512 void AliPHOSGetter::ReadPrimaries()
514 // Read Primaries from Kinematics.root
516 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
518 // gets kine tree from the root file (Kinematics.root)
519 if ( ! rl->TreeK() ) { // load treeK the first time
520 rl->LoadKinematics() ;
523 fNPrimaries = (rl->GetHeader())->GetNtrack();
525 Info( "ReadTreeK", "Found %d particles in event # %d", fNPrimaries, EventNumber() ) ;
528 // first time creates the container
530 fPrimaries->Clear() ;
533 for (index = 0 ; index < fNPrimaries; index++) {
534 new ((*fPrimaries)[index]) TParticle(*(Primary(index)));
538 //____________________________________________________________________________
539 Bool_t AliPHOSGetter::OpenESDFile()
544 fESDFile = TFile::Open(fESDFileName) ;
548 else if (fESDFile->IsOpen()) {
550 fESDFile = TFile::Open(fESDFileName) ;
552 if (!fESDFile->IsOpen())
557 //____________________________________________________________________________
558 void AliPHOSGetter::FitRaw(Bool_t lowGainFlag, TGraph * gLowGain, TGraph * gHighGain, TF1* signalF, Int_t & amp, Double_t & time)
560 // Fits the raw signal time distribution
562 const Int_t kNoiseThreshold = 0 ;
563 Double_t timezero1 = 0., timezero2 = 0., timemax = 0. ;
564 Double_t signal = 0., signalmax = 0. ;
565 Double_t energy = time = 0. ;
568 timezero1 = timezero2 = signalmax = timemax = 0. ;
569 signalF->FixParameter(0, PHOS()->GetRawFormatLowCharge()) ;
570 signalF->FixParameter(1, PHOS()->GetRawFormatLowGain()) ;
572 for (index = 0; index < PHOS()->GetRawFormatTimeBins(); index++) {
573 gLowGain->GetPoint(index, time, signal) ;
574 if (signal > kNoiseThreshold && timezero1 == 0.)
576 if (signal <= kNoiseThreshold && timezero1 > 0. && timezero2 == 0.)
578 if (signal > signalmax) {
583 signalmax /= PHOS()->RawResponseFunctionMax(PHOS()->GetRawFormatLowCharge(),
584 PHOS()->GetRawFormatLowGain()) ;
585 if ( timezero1 + PHOS()->GetRawFormatTimePeak() < PHOS()->GetRawFormatTimeMax() * 0.4 ) { // else its noise
586 signalF->SetParameter(2, signalmax) ;
587 signalF->SetParameter(3, timezero1) ;
588 gLowGain->Fit(signalF, "QRON", "", 0., timezero2); //, "QRON") ;
589 energy = signalF->GetParameter(2) ;
590 time = signalF->GetMaximumX() - PHOS()->GetRawFormatTimePeak() - PHOS()->GetRawFormatTimeTrigger() ;
593 timezero1 = timezero2 = signalmax = timemax = 0. ;
594 signalF->FixParameter(0, PHOS()->GetRawFormatHighCharge()) ;
595 signalF->FixParameter(1, PHOS()->GetRawFormatHighGain()) ;
597 for (index = 0; index < PHOS()->GetRawFormatTimeBins(); index++) {
598 gHighGain->GetPoint(index, time, signal) ;
599 if (signal > kNoiseThreshold && timezero1 == 0.)
601 if (signal <= kNoiseThreshold && timezero1 > 0. && timezero2 == 0.)
603 if (signal > signalmax) {
608 signalmax /= PHOS()->RawResponseFunctionMax(PHOS()->GetRawFormatHighCharge(),
609 PHOS()->GetRawFormatHighGain()) ;;
610 if ( timezero1 + PHOS()->GetRawFormatTimePeak() < PHOS()->GetRawFormatTimeMax() * 0.4 ) { // else its noise
611 signalF->SetParameter(2, signalmax) ;
612 signalF->SetParameter(3, timezero1) ;
613 gHighGain->Fit(signalF, "QRON", "", 0., timezero2) ;
614 energy = signalF->GetParameter(2) ;
615 time = signalF->GetMaximumX() - PHOS()->GetRawFormatTimePeak() - PHOS()->GetRawFormatTimeTrigger() ;
619 if (time == 0. && energy == 0.)
622 AliPHOSDigitizer * digitizer = Digitizer() ;
623 amp = static_cast<Int_t>( (energy - digitizer->GetEMCpedestal()) / digitizer->GetEMCchannel() + 0.5 ) ;
627 //____________________________________________________________________________
628 Int_t AliPHOSGetter::ReadRaw(AliRawReader *rawReader)
630 // reads the raw format data, converts it into digits format and store digits in Digits()
633 AliPHOSRawStream in(rawReader);
635 Bool_t first = kTRUE ;
637 TF1 * signalF = new TF1("signal", AliPHOS::RawResponseFunction, 0, PHOS()->GetRawFormatTimeMax(), 4);
638 signalF->SetParNames("Charge", "Gain", "Amplitude", "TimeZero") ;
641 Bool_t lowGainFlag = kFALSE ;
643 TClonesArray * digits = Digits() ;
649 TGraph * gLowGain = new TGraph(PHOS()->GetRawFormatTimeBins()) ;
650 TGraph * gHighGain= new TGraph(PHOS()->GetRawFormatTimeBins()) ;
652 while ( in.Next() ) { // PHOS entries loop
653 if ( (in.IsNewRow() || in.IsNewColumn() || in.IsNewModule()) ) {
655 FitRaw(lowGainFlag, gLowGain, gHighGain, signalF, amp, time) ;
657 new((*digits)[idigit]) AliPHOSDigit( -1, id, amp, time) ;
661 for (index = 0; index < PHOS()->GetRawFormatTimeBins(); index++) {
662 gLowGain->SetPoint(index, index * PHOS()->GetRawFormatTimeMax() / PHOS()->GetRawFormatTimeBins(), 0) ;
663 gHighGain->SetPoint(index, index * PHOS()->GetRawFormatTimeMax() / PHOS()->GetRawFormatTimeBins(), 0) ;
667 relId[0] = in.GetModule() ;
668 if ( relId[0] >= PHOS()->GetRawFormatLowGainOffset() ) {
669 relId[0] -= PHOS()->GetRawFormatLowGainOffset() ;
670 lowGainFlag = kTRUE ;
672 lowGainFlag = kFALSE ;
674 relId[2] = in.GetRow() ;
675 relId[3] = in.GetColumn() ;
676 PHOSGeometry()->RelToAbsNumbering(relId, id) ;
679 gLowGain->SetPoint(in.GetTime(),
680 in.GetTime()* PHOS()->GetRawFormatTimeMax() / PHOS()->GetRawFormatTimeBins(),
683 gHighGain->SetPoint(in.GetTime(),
684 in.GetTime() * PHOS()->GetRawFormatTimeMax() / PHOS()->GetRawFormatTimeBins(),
687 } // PHOS entries loop
689 FitRaw(lowGainFlag, gLowGain, gHighGain, signalF, amp, time) ;
691 new((*digits)[idigit]) AliPHOSDigit( -1, id, amp, time) ;
697 delete gLowGain, gHighGain ;
699 return digits->GetEntriesFast() ;
702 // TClonesArray * digits = Digits() ;
704 // Int_t idigit = 0 ;
706 // while ( in.Next() ) { // PHOS entries loop
708 // Int_t amp = in.GetSignal() ;
709 // Double_t time = in.GetTime() ;
710 // Int_t relId[4], id ;
712 // relId[0] = in.GetModule() ;
713 // if ( relId[0] >= PHOS()->GetRawFormatLowGainOffset() ) {
714 // relId[0] -= PHOS()->GetRawFormatLowGainOffset() ;
717 // relId[2] = in.GetRow() ;
718 // relId[3] = in.GetColumn() ;
719 // PHOSGeometry()->RelToAbsNumbering(relId, id) ;
721 // if (amp > 0 && id >=0 ) {
722 // new((*digits)[idigit]) AliPHOSDigit( -1, id, amp, time) ;
726 // } // PHOS entries loop
730 // return digits->GetEntriesFast() ;
732 //____________________________________________________________________________
733 Int_t AliPHOSGetter::ReadTreeD()
737 PhosLoader()->CleanDigits() ;
738 PhosLoader()->LoadDigits("UPDATE") ;
739 PhosLoader()->LoadDigitizer("UPDATE") ;
740 return Digits()->GetEntries() ;
743 //____________________________________________________________________________
744 Int_t AliPHOSGetter::ReadTreeH()
747 PhosLoader()->CleanHits() ;
748 // gets TreeH from the root file (PHOS.Hit.root)
749 //if ( !IsLoaded("H") ) {
750 PhosLoader()->LoadHits("UPDATE") ;
753 return Hits()->GetEntries() ;
756 //____________________________________________________________________________
757 Int_t AliPHOSGetter::ReadTreeR()
759 // Read the RecPoints
761 PhosLoader()->CleanRecPoints() ;
762 // gets TreeR from the root file (PHOS.RecPoints.root)
763 //if ( !IsLoaded("R") ) {
764 PhosLoader()->LoadRecPoints("UPDATE") ;
765 PhosLoader()->LoadClusterizer("UPDATE") ;
769 return EmcRecPoints()->GetEntries() ;
772 //____________________________________________________________________________
773 Int_t AliPHOSGetter::ReadTreeT()
775 // Read the TrackSegments
777 PhosLoader()->CleanTracks() ;
778 // gets TreeT from the root file (PHOS.TrackSegments.root)
779 //if ( !IsLoaded("T") ) {
780 PhosLoader()->LoadTracks("UPDATE") ;
781 PhosLoader()->LoadTrackSegmentMaker("UPDATE") ;
785 return TrackSegments()->GetEntries() ;
787 //____________________________________________________________________________
788 Int_t AliPHOSGetter::ReadTreeP()
790 // Read the RecParticles
792 PhosLoader()->CleanRecParticles() ;
794 // gets TreeT from the root file (PHOS.TrackSegments.root)
795 // if ( !IsLoaded("P") ) {
796 PhosLoader()->LoadRecParticles("UPDATE") ;
797 PhosLoader()->LoadPID("UPDATE") ;
801 return RecParticles()->GetEntries() ;
803 //____________________________________________________________________________
804 Int_t AliPHOSGetter::ReadTreeS()
808 PhosLoader()->CleanSDigits() ;
809 // gets TreeS from the root file (PHOS.SDigits.root)
810 //if ( !IsLoaded("S") ) {
811 PhosLoader()->LoadSDigits("READ") ;
812 PhosLoader()->LoadSDigitizer("READ") ;
816 return SDigits()->GetEntries() ;
819 //____________________________________________________________________________
820 Int_t AliPHOSGetter::ReadTreeE(Int_t event)
824 // gets esdTree from the root file (AliESDs.root)
826 if ( !OpenESDFile() )
829 fESDTree = static_cast<TTree*>(fESDFile->Get("esdTree")) ;
833 Error("ReadTreeE", "no ESD tree found");
836 fESDTree->SetBranchAddress("ESD", &fESD);
837 fESDTree->GetEvent(event);
842 //____________________________________________________________________________
843 TClonesArray * AliPHOSGetter::SDigits()
845 // asks the Loader to return the Digits container
847 TClonesArray * rv = 0 ;
849 rv = PhosLoader()->SDigits() ;
851 PhosLoader()->MakeSDigitsArray() ;
852 rv = PhosLoader()->SDigits() ;
857 //____________________________________________________________________________
858 AliPHOSSDigitizer * AliPHOSGetter::SDigitizer()
860 // Returns pointer to the SDigitizer task
861 AliPHOSSDigitizer * rv ;
862 rv = dynamic_cast<AliPHOSSDigitizer *>(PhosLoader()->SDigitizer()) ;
865 rv = dynamic_cast<AliPHOSSDigitizer *>(PhosLoader()->SDigitizer()) ;
870 //____________________________________________________________________________
871 TParticle * AliPHOSGetter::Secondary(const TParticle* p, Int_t index) const
873 // Return first (index=1) or second (index=2) secondary particle of primary particle p
881 Int_t daughterIndex = p->GetDaughter(index-1) ;
882 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
883 return rl->GetAliRun()->GetMCApp()->Particle(daughterIndex) ;
889 //____________________________________________________________________________
890 void AliPHOSGetter::Track(Int_t itrack)
892 // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
894 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
896 if( !TreeH() ) // load treeH the first time
899 // first time create the container
900 TClonesArray * hits = Hits() ;
904 TBranch * phosbranch = dynamic_cast<TBranch*>(TreeH()->GetBranch("PHOS")) ;
905 phosbranch->SetAddress(&hits) ;
906 phosbranch->GetEntry(itrack) ;
909 //____________________________________________________________________________
910 TTree * AliPHOSGetter::TreeD() const
912 // Returns pointer to the Digits Tree
914 rv = PhosLoader()->TreeD() ;
916 PhosLoader()->MakeTree("D");
917 rv = PhosLoader()->TreeD() ;
923 //____________________________________________________________________________
924 TTree * AliPHOSGetter::TreeH() const
926 // Returns pointer to the Hits Tree
928 rv = PhosLoader()->TreeH() ;
930 PhosLoader()->MakeTree("H");
931 rv = PhosLoader()->TreeH() ;
937 //____________________________________________________________________________
938 TTree * AliPHOSGetter::TreeR() const
940 // Returns pointer to the RecPoints Tree
942 rv = PhosLoader()->TreeR() ;
944 PhosLoader()->MakeTree("R");
945 rv = PhosLoader()->TreeR() ;
951 //____________________________________________________________________________
952 TTree * AliPHOSGetter::TreeT() const
954 // Returns pointer to the TrackSegments Tree
956 rv = PhosLoader()->TreeT() ;
958 PhosLoader()->MakeTree("T");
959 rv = PhosLoader()->TreeT() ;
964 //____________________________________________________________________________
965 TTree * AliPHOSGetter::TreeP() const
967 // Returns pointer to the RecParticles Tree
969 rv = PhosLoader()->TreeP() ;
971 PhosLoader()->MakeTree("P");
972 rv = PhosLoader()->TreeP() ;
978 //____________________________________________________________________________
979 TTree * AliPHOSGetter::TreeS() const
981 // Returns pointer to the SDigits Tree
983 rv = PhosLoader()->TreeS() ;
985 PhosLoader()->MakeTree("S");
986 rv = PhosLoader()->TreeS() ;
992 //____________________________________________________________________________
993 Bool_t AliPHOSGetter::VersionExists(TString & opt) const
995 // checks if the version with the present name already exists in the same directory
999 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
1000 TString version( rl->GetEventFolder()->GetName() ) ;
1004 if ( opt == "sdigits") {
1005 // add the version name to the root file name
1006 TString fileName( PhosLoader()->GetSDigitsFileName() ) ;
1007 if (version != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
1008 fileName = fileName.ReplaceAll(".root", "") + "_" + version + ".root" ;
1009 if ( !(gSystem->AccessPathName(fileName)) ) {
1010 Warning("VersionExists", "The file %s already exists", fileName.Data()) ;
1013 PhosLoader()->SetSDigitsFileName(fileName) ;
1016 if ( opt == "digits") {
1017 // add the version name to the root file name
1018 TString fileName( PhosLoader()->GetDigitsFileName() ) ;
1019 if (version != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
1020 fileName = fileName.ReplaceAll(".root", "") + "_" + version + ".root" ;
1021 if ( !(gSystem->AccessPathName(fileName)) ) {
1022 Warning("VersionExists", "The file %s already exists", fileName.Data()) ;
1031 //____________________________________________________________________________
1032 UShort_t AliPHOSGetter::EventPattern(void) const
1034 // Return the pattern (trigger bit register) of the beam-test event
1036 return fBTE->GetPattern() ;
1040 //____________________________________________________________________________
1041 Float_t AliPHOSGetter::BeamEnergy(void) const
1043 // Return the beam energy of the beam-test event
1045 return fBTE->GetBeamEnergy() ;
1049 //____________________________________________________________________________
1051 AliPHOSCalibData* AliPHOSGetter::CalibData()
1054 if(!AliCDBStorage::Instance()) {
1056 Warning("CalibData","Calibration DB is not initiated!");