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, Double_t & energy, 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. ;
569 timezero1 = timezero2 = signalmax = timemax = 0. ;
570 signalF->FixParameter(0, PHOS()->GetRawFormatLowCharge()) ;
571 signalF->FixParameter(1, PHOS()->GetRawFormatLowGain()) ;
573 for (index = 0; index < PHOS()->GetRawFormatTimeBins(); index++) {
574 gLowGain->GetPoint(index, time, signal) ;
575 if (signal > kNoiseThreshold && timezero1 == 0.)
577 if (signal <= kNoiseThreshold && timezero1 > 0. && timezero2 == 0.)
579 if (signal > signalmax) {
584 signalmax /= PHOS()->RawResponseFunctionMax(PHOS()->GetRawFormatLowCharge(),
585 PHOS()->GetRawFormatLowGain()) ;
586 if ( timezero1 + PHOS()->GetRawFormatTimePeak() < PHOS()->GetRawFormatTimeMax() * 0.4 ) { // else its noise
587 signalF->SetParameter(2, signalmax) ;
588 signalF->SetParameter(3, timezero1) ;
589 gLowGain->Fit(signalF, "QRON", "", 0., timezero2); //, "QRON") ;
590 energy = signalF->GetParameter(2) ;
591 time = signalF->GetMaximumX() - PHOS()->GetRawFormatTimePeak() - PHOS()->GetRawFormatTimeTrigger() ;
594 timezero1 = timezero2 = signalmax = timemax = 0. ;
595 signalF->FixParameter(0, PHOS()->GetRawFormatHighCharge()) ;
596 signalF->FixParameter(1, PHOS()->GetRawFormatHighGain()) ;
598 for (index = 0; index < PHOS()->GetRawFormatTimeBins(); index++) {
599 gHighGain->GetPoint(index, time, signal) ;
600 if (signal > kNoiseThreshold && timezero1 == 0.)
602 if (signal <= kNoiseThreshold && timezero1 > 0. && timezero2 == 0.)
604 if (signal > signalmax) {
609 signalmax /= PHOS()->RawResponseFunctionMax(PHOS()->GetRawFormatHighCharge(),
610 PHOS()->GetRawFormatHighGain()) ;;
611 if ( timezero1 + PHOS()->GetRawFormatTimePeak() < PHOS()->GetRawFormatTimeMax() * 0.4 ) { // else its noise
612 signalF->SetParameter(2, signalmax) ;
613 signalF->SetParameter(3, timezero1) ;
614 gHighGain->Fit(signalF, "QRON", "", 0., timezero2) ;
615 energy = signalF->GetParameter(2) ;
616 time = signalF->GetMaximumX() - PHOS()->GetRawFormatTimePeak() - PHOS()->GetRawFormatTimeTrigger() ;
619 if (time == 0) energy = 0 ;
622 //____________________________________________________________________________
623 Int_t AliPHOSGetter::CalibrateRaw(Double_t energy, Int_t *relId)
625 // Convert energy into digitized amplitude for a cell relId
626 // It is a user responsilibity to open CDB and set
627 // AliPHOSCalibData object by the following operators:
629 // AliCDBLocal *loc = new AliCDBLocal("deCalibDB");
630 // AliPHOSCalibData* clb = (AliPHOSCalibData*)AliCDBStorage::Instance()
631 // ->Get(path_to_calibdata,run_number);
632 // AliPHOSGetter* gime = AliPHOSGetter::Instance("galice.root");
633 // gime->SetCalibData(clb);
635 if (CalibData() == 0)
636 Fatal("CalibrateRaw","Failure to calibrate raw data");
638 Int_t module = relId[0];
639 Int_t column = relId[2];
640 Int_t row = relId[3];
641 Float_t gainFactor = CalibData()->GetADCchannelEmc (module,column,row);
642 Float_t pedestal = CalibData()->GetADCpedestalEmc(module,column,row);
643 Int_t amp = static_cast<Int_t>( (energy - pedestal) / gainFactor + 0.5 ) ;
646 //____________________________________________________________________________
647 Int_t AliPHOSGetter::ReadRaw(AliRawReader *rawReader)
649 // reads the raw format data, converts it into digits format and store digits in Digits()
652 AliPHOSRawStream in(rawReader);
654 Bool_t first = kTRUE ;
656 TF1 * signalF = new TF1("signal", AliPHOS::RawResponseFunction, 0, PHOS()->GetRawFormatTimeMax(), 4);
657 signalF->SetParNames("Charge", "Gain", "Amplitude", "TimeZero") ;
659 Int_t relId[4], id =0;
660 Bool_t lowGainFlag = kFALSE ;
662 TClonesArray * digits = Digits() ;
666 Double_t energy = 0. ;
669 TGraph * gLowGain = new TGraph(PHOS()->GetRawFormatTimeBins()) ;
670 TGraph * gHighGain= new TGraph(PHOS()->GetRawFormatTimeBins()) ;
672 while ( in.Next() ) { // PHOS entries loop
673 if ( (in.IsNewRow() || in.IsNewColumn() || in.IsNewModule()) ) {
674 relId[0] = in.GetModule() ;
675 if ( relId[0] >= PHOS()->GetRawFormatLowGainOffset() ) {
676 relId[0] -= PHOS()->GetRawFormatLowGainOffset() ;
677 lowGainFlag = kTRUE ;
679 lowGainFlag = kFALSE ;
681 relId[2] = in.GetRow() ;
682 relId[3] = in.GetColumn() ;
683 PHOSGeometry()->RelToAbsNumbering(relId, id) ;
686 FitRaw(lowGainFlag, gLowGain, gHighGain, signalF, energy, time) ;
687 amp = CalibrateRaw(energy,relId);
689 new((*digits)[idigit]) AliPHOSDigit( -1, id, amp, time) ;
693 for (index = 0; index < PHOS()->GetRawFormatTimeBins(); index++) {
694 gLowGain->SetPoint(index, index * PHOS()->GetRawFormatTimeMax() / PHOS()->GetRawFormatTimeBins(), 0) ;
695 gHighGain->SetPoint(index, index * PHOS()->GetRawFormatTimeMax() / PHOS()->GetRawFormatTimeBins(), 0) ;
701 gLowGain->SetPoint(in.GetTime(),
702 in.GetTime()* PHOS()->GetRawFormatTimeMax() / PHOS()->GetRawFormatTimeBins(),
705 gHighGain->SetPoint(in.GetTime(),
706 in.GetTime() * PHOS()->GetRawFormatTimeMax() / PHOS()->GetRawFormatTimeBins(),
709 } // PHOS entries loop
711 FitRaw(lowGainFlag, gLowGain, gHighGain, signalF, energy, time) ;
712 amp = CalibrateRaw(energy,relId);
714 new((*digits)[idigit]) AliPHOSDigit( -1, id, amp, time) ;
723 return digits->GetEntriesFast() ;
726 // TClonesArray * digits = Digits() ;
728 // Int_t idigit = 0 ;
730 // while ( in.Next() ) { // PHOS entries loop
732 // Int_t amp = in.GetSignal() ;
733 // Double_t time = in.GetTime() ;
734 // Int_t relId[4], id ;
736 // relId[0] = in.GetModule() ;
737 // if ( relId[0] >= PHOS()->GetRawFormatLowGainOffset() ) {
738 // relId[0] -= PHOS()->GetRawFormatLowGainOffset() ;
741 // relId[2] = in.GetRow() ;
742 // relId[3] = in.GetColumn() ;
743 // PHOSGeometry()->RelToAbsNumbering(relId, id) ;
745 // if (amp > 0 && id >=0 ) {
746 // new((*digits)[idigit]) AliPHOSDigit( -1, id, amp, time) ;
750 // } // PHOS entries loop
754 // return digits->GetEntriesFast() ;
756 //____________________________________________________________________________
757 Int_t AliPHOSGetter::ReadTreeD()
761 PhosLoader()->CleanDigits() ;
762 PhosLoader()->LoadDigits("UPDATE") ;
763 PhosLoader()->LoadDigitizer("UPDATE") ;
764 return Digits()->GetEntries() ;
767 //____________________________________________________________________________
768 Int_t AliPHOSGetter::ReadTreeH()
771 PhosLoader()->CleanHits() ;
772 // gets TreeH from the root file (PHOS.Hit.root)
773 //if ( !IsLoaded("H") ) {
774 PhosLoader()->LoadHits("UPDATE") ;
777 return Hits()->GetEntries() ;
780 //____________________________________________________________________________
781 Int_t AliPHOSGetter::ReadTreeR()
783 // Read the RecPoints
785 PhosLoader()->CleanRecPoints() ;
786 // gets TreeR from the root file (PHOS.RecPoints.root)
787 //if ( !IsLoaded("R") ) {
788 PhosLoader()->LoadRecPoints("UPDATE") ;
789 PhosLoader()->LoadClusterizer("UPDATE") ;
793 return EmcRecPoints()->GetEntries() ;
796 //____________________________________________________________________________
797 Int_t AliPHOSGetter::ReadTreeT()
799 // Read the TrackSegments
801 PhosLoader()->CleanTracks() ;
802 // gets TreeT from the root file (PHOS.TrackSegments.root)
803 //if ( !IsLoaded("T") ) {
804 PhosLoader()->LoadTracks("UPDATE") ;
805 PhosLoader()->LoadTrackSegmentMaker("UPDATE") ;
809 return TrackSegments()->GetEntries() ;
811 //____________________________________________________________________________
812 Int_t AliPHOSGetter::ReadTreeP()
814 // Read the RecParticles
816 PhosLoader()->CleanRecParticles() ;
818 // gets TreeT from the root file (PHOS.TrackSegments.root)
819 // if ( !IsLoaded("P") ) {
820 PhosLoader()->LoadRecParticles("UPDATE") ;
821 PhosLoader()->LoadPID("UPDATE") ;
825 return RecParticles()->GetEntries() ;
827 //____________________________________________________________________________
828 Int_t AliPHOSGetter::ReadTreeS()
832 PhosLoader()->CleanSDigits() ;
833 // gets TreeS from the root file (PHOS.SDigits.root)
834 //if ( !IsLoaded("S") ) {
835 PhosLoader()->LoadSDigits("READ") ;
836 PhosLoader()->LoadSDigitizer("READ") ;
840 return SDigits()->GetEntries() ;
843 //____________________________________________________________________________
844 Int_t AliPHOSGetter::ReadTreeE(Int_t event)
848 // gets esdTree from the root file (AliESDs.root)
850 if ( !OpenESDFile() )
853 fESDTree = static_cast<TTree*>(fESDFile->Get("esdTree")) ;
857 Error("ReadTreeE", "no ESD tree found");
860 fESDTree->SetBranchAddress("ESD", &fESD);
861 fESDTree->GetEvent(event);
866 //____________________________________________________________________________
867 TClonesArray * AliPHOSGetter::SDigits()
869 // asks the Loader to return the Digits container
871 TClonesArray * rv = 0 ;
873 rv = PhosLoader()->SDigits() ;
875 PhosLoader()->MakeSDigitsArray() ;
876 rv = PhosLoader()->SDigits() ;
881 //____________________________________________________________________________
882 AliPHOSSDigitizer * AliPHOSGetter::SDigitizer()
884 // Returns pointer to the SDigitizer task
885 AliPHOSSDigitizer * rv ;
886 rv = dynamic_cast<AliPHOSSDigitizer *>(PhosLoader()->SDigitizer()) ;
889 rv = dynamic_cast<AliPHOSSDigitizer *>(PhosLoader()->SDigitizer()) ;
894 //____________________________________________________________________________
895 TParticle * AliPHOSGetter::Secondary(const TParticle* p, Int_t index) const
897 // Return first (index=1) or second (index=2) secondary particle of primary particle p
905 Int_t daughterIndex = p->GetDaughter(index-1) ;
906 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
907 return rl->GetAliRun()->GetMCApp()->Particle(daughterIndex) ;
913 //____________________________________________________________________________
914 void AliPHOSGetter::Track(Int_t itrack)
916 // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
918 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
920 if( !TreeH() ) // load treeH the first time
923 // first time create the container
924 TClonesArray * hits = Hits() ;
928 TBranch * phosbranch = dynamic_cast<TBranch*>(TreeH()->GetBranch("PHOS")) ;
929 phosbranch->SetAddress(&hits) ;
930 phosbranch->GetEntry(itrack) ;
933 //____________________________________________________________________________
934 TTree * AliPHOSGetter::TreeD() const
936 // Returns pointer to the Digits Tree
938 rv = PhosLoader()->TreeD() ;
940 PhosLoader()->MakeTree("D");
941 rv = PhosLoader()->TreeD() ;
947 //____________________________________________________________________________
948 TTree * AliPHOSGetter::TreeH() const
950 // Returns pointer to the Hits Tree
952 rv = PhosLoader()->TreeH() ;
954 PhosLoader()->MakeTree("H");
955 rv = PhosLoader()->TreeH() ;
961 //____________________________________________________________________________
962 TTree * AliPHOSGetter::TreeR() const
964 // Returns pointer to the RecPoints Tree
966 rv = PhosLoader()->TreeR() ;
968 PhosLoader()->MakeTree("R");
969 rv = PhosLoader()->TreeR() ;
975 //____________________________________________________________________________
976 TTree * AliPHOSGetter::TreeT() const
978 // Returns pointer to the TrackSegments Tree
980 rv = PhosLoader()->TreeT() ;
982 PhosLoader()->MakeTree("T");
983 rv = PhosLoader()->TreeT() ;
988 //____________________________________________________________________________
989 TTree * AliPHOSGetter::TreeP() const
991 // Returns pointer to the RecParticles Tree
993 rv = PhosLoader()->TreeP() ;
995 PhosLoader()->MakeTree("P");
996 rv = PhosLoader()->TreeP() ;
1002 //____________________________________________________________________________
1003 TTree * AliPHOSGetter::TreeS() const
1005 // Returns pointer to the SDigits Tree
1007 rv = PhosLoader()->TreeS() ;
1009 PhosLoader()->MakeTree("S");
1010 rv = PhosLoader()->TreeS() ;
1016 //____________________________________________________________________________
1017 Bool_t AliPHOSGetter::VersionExists(TString & opt) const
1019 // checks if the version with the present name already exists in the same directory
1021 Bool_t rv = kFALSE ;
1023 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
1024 TString version( rl->GetEventFolder()->GetName() ) ;
1028 if ( opt == "sdigits") {
1029 // add the version name to the root file name
1030 TString fileName( PhosLoader()->GetSDigitsFileName() ) ;
1031 if (version != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
1032 fileName = fileName.ReplaceAll(".root", "") + "_" + version + ".root" ;
1033 if ( !(gSystem->AccessPathName(fileName)) ) {
1034 Warning("VersionExists", "The file %s already exists", fileName.Data()) ;
1037 PhosLoader()->SetSDigitsFileName(fileName) ;
1040 if ( opt == "digits") {
1041 // add the version name to the root file name
1042 TString fileName( PhosLoader()->GetDigitsFileName() ) ;
1043 if (version != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
1044 fileName = fileName.ReplaceAll(".root", "") + "_" + version + ".root" ;
1045 if ( !(gSystem->AccessPathName(fileName)) ) {
1046 Warning("VersionExists", "The file %s already exists", fileName.Data()) ;
1055 //____________________________________________________________________________
1056 UShort_t AliPHOSGetter::EventPattern(void) const
1058 // Return the pattern (trigger bit register) of the beam-test event
1060 return fBTE->GetPattern() ;
1064 //____________________________________________________________________________
1065 Float_t AliPHOSGetter::BeamEnergy(void) const
1067 // Return the beam energy of the beam-test event
1069 return fBTE->GetBeamEnergy() ;
1073 //____________________________________________________________________________
1075 AliPHOSCalibData* AliPHOSGetter::CalibData()
1078 if(!AliCDBStorage::Instance()) {
1080 Warning("CalibData","Calibration DB is not initiated!");