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"
69 #include "AliCDBManager.h"
71 ClassImp(AliPHOSGetter)
73 AliPHOSGetter * AliPHOSGetter::fgObjGetter = 0 ;
74 AliPHOSLoader * AliPHOSGetter::fgPhosLoader = 0;
75 Int_t AliPHOSGetter::fgDebug = 0;
76 AliPHOSCalibData* AliPHOSGetter::fCalibData = 0;
78 // TFile * AliPHOSGetter::fgFile = 0 ;
80 //____________________________________________________________________________
81 AliPHOSGetter::AliPHOSGetter(const char* headerFile, const char* version, Option_t * openingOption)
83 // ctor only called by Instance()
85 AliRunLoader* rl = AliRunLoader::GetRunLoader(version) ;
87 rl = AliRunLoader::Open(headerFile, version, openingOption);
89 Fatal("AliPHOSGetter", "Could not find the Run Loader for %s - %s",headerFile, version) ;
92 if (rl->GetAliRun() == 0x0) {
94 gAlice = rl->GetAliRun(); // should be removed
98 fgPhosLoader = dynamic_cast<AliPHOSLoader*>(rl->GetLoader("PHOSLoader"));
100 Error("AliPHOSGetter", "Could not find PHOSLoader") ;
102 fgPhosLoader->SetTitle(version);
104 // initialize data members
108 fLoadingStatus = "" ;
110 fESDFileName = rl->GetFileName() ; // this should be the galice.root file
111 fESDFileName.ReplaceAll("galice.root", "AliESDs.root") ;
115 fRawDigits = kFALSE ;
119 //____________________________________________________________________________
120 AliPHOSGetter::~AliPHOSGetter()
124 delete fgPhosLoader ;
132 fPrimaries->Delete() ;
143 //____________________________________________________________________________
144 void AliPHOSGetter::Reset()
146 // resets things in case the getter is called consecutively with different files
147 // the PHOS Loader is already deleted by the Run Loader
150 fPrimaries->Delete() ;
157 //____________________________________________________________________________
158 AliPHOSClusterizer * AliPHOSGetter::Clusterizer()
160 // Returns pointer to the Clusterizer task
161 AliPHOSClusterizer * rv ;
162 rv = dynamic_cast<AliPHOSClusterizer *>(PhosLoader()->Reconstructioner()) ;
165 rv = dynamic_cast<AliPHOSClusterizer*>(PhosLoader()->Reconstructioner()) ;
170 //____________________________________________________________________________
171 TObjArray * AliPHOSGetter::CpvRecPoints()
173 // asks the Loader to return the CPV RecPoints container
177 rv = PhosLoader()->CpvRecPoints() ;
179 PhosLoader()->MakeRecPointsArray() ;
180 rv = PhosLoader()->CpvRecPoints() ;
185 //____________________________________________________________________________
186 TClonesArray * AliPHOSGetter::Digits()
188 // asks the Loader to return the Digits container
190 TClonesArray * rv = 0 ;
191 rv = PhosLoader()->Digits() ;
194 PhosLoader()->MakeDigitsArray() ;
195 rv = PhosLoader()->Digits() ;
200 //____________________________________________________________________________
201 AliPHOSDigitizer * AliPHOSGetter::Digitizer()
203 // Returns pointer to the Digitizer task
204 AliPHOSDigitizer * rv ;
205 rv = dynamic_cast<AliPHOSDigitizer *>(PhosLoader()->Digitizer()) ;
208 rv = dynamic_cast<AliPHOSDigitizer *>(PhosLoader()->Digitizer()) ;
214 //____________________________________________________________________________
215 TObjArray * AliPHOSGetter::EmcRecPoints()
217 // asks the Loader to return the EMC RecPoints container
221 rv = PhosLoader()->EmcRecPoints() ;
223 PhosLoader()->MakeRecPointsArray() ;
224 rv = PhosLoader()->EmcRecPoints() ;
229 //____________________________________________________________________________
230 TClonesArray * AliPHOSGetter::TrackSegments()
232 // asks the Loader to return the TrackSegments container
234 TClonesArray * rv = 0 ;
236 rv = PhosLoader()->TrackSegments() ;
238 PhosLoader()->MakeTrackSegmentsArray() ;
239 rv = PhosLoader()->TrackSegments() ;
244 //____________________________________________________________________________
245 AliPHOSTrackSegmentMaker * AliPHOSGetter::TrackSegmentMaker()
247 // Returns pointer to the TrackSegmentMaker task
248 AliPHOSTrackSegmentMaker * rv ;
249 rv = dynamic_cast<AliPHOSTrackSegmentMaker *>(PhosLoader()->TrackSegmentMaker()) ;
252 rv = dynamic_cast<AliPHOSTrackSegmentMaker *>(PhosLoader()->TrackSegmentMaker()) ;
257 //____________________________________________________________________________
258 TClonesArray * AliPHOSGetter::RecParticles()
260 // asks the Loader to return the TrackSegments container
262 TClonesArray * rv = 0 ;
264 rv = PhosLoader()->RecParticles() ;
266 PhosLoader()->MakeRecParticlesArray() ;
267 rv = PhosLoader()->RecParticles() ;
271 //____________________________________________________________________________
272 void AliPHOSGetter::Event(Int_t event, const char* opt)
274 // Reads the content of all Tree's S, D and R
276 // if ( event >= MaxEvent() ) {
277 // Error("Event", "%d not found in TreeE !", event) ;
281 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
283 // // checks if we are dealing with test-beam data
284 // TBranch * btb = rl->TreeE()->GetBranch("AliPHOSBeamTestEvent") ;
287 // fBTE = new AliPHOSBeamTestEvent() ;
288 // btb->SetAddress(&fBTE) ;
289 // btb->GetEntry(event) ;
298 // Loads the type of object(s) requested
300 rl->GetEvent(event) ;
302 if(strstr(opt,"X") || (strcmp(opt,"")==0)){
306 if(strstr(opt,"H") ){
310 if(strstr(opt,"S") ){
314 if(strstr(opt,"D") ){
318 if(strstr(opt,"R") ){
322 if( strstr(opt,"T") ){
326 if( strstr(opt,"P") ){
330 if( strstr(opt,"E") ){
337 //____________________________________________________________________________
338 void AliPHOSGetter::Event(AliRawReader *rawReader, const char* opt)
340 // Reads the raw event from rawReader
342 if( strstr(opt,"W") ){
349 //____________________________________________________________________________
350 Int_t AliPHOSGetter::EventNumber() const
352 // return the current event number
353 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
354 return static_cast<Int_t>(rl->GetEventNumber()) ;
357 //____________________________________________________________________________
358 TClonesArray * AliPHOSGetter::Hits()
360 // asks the loader to return the Hits container
362 TClonesArray * rv = 0 ;
364 rv = PhosLoader()->Hits() ;
366 PhosLoader()->LoadHits("read");
367 rv = PhosLoader()->Hits() ;
372 //____________________________________________________________________________
373 AliPHOSGetter * AliPHOSGetter::Instance(const char* alirunFileName, const char* version, Option_t * openingOption)
375 // Creates and returns the pointer of the unique instance
376 // Must be called only when the environment has changed
378 if(!fgObjGetter){ // first time the getter is called
379 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
381 else { // the getter has been called previously
382 AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle());
383 if ( rl->GetFileName() == alirunFileName ) {// the alirunFile has the same name
384 // check if the file is already open
385 TFile * galiceFile = dynamic_cast<TFile *>(gROOT->FindObject(rl->GetFileName()) ) ;
388 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
390 else { // the file is already open check the version name
391 TString currentVersionName = rl->GetEventFolder()->GetName() ;
392 TString newVersionName(version) ;
393 if (currentVersionName == newVersionName)
395 ::Warning( "Instance", "Files with version %s already open", currentVersionName.Data() ) ;
397 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
402 AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle()) ;
403 if ( strstr(version, AliConfig::GetDefaultEventFolderName()) ) // false in case of merging
405 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
409 ::Error("AliPHOSGetter::Instance", "Failed to create the PHOS Getter object") ;
417 //____________________________________________________________________________
418 AliPHOSGetter * AliPHOSGetter::Instance()
420 // Returns the pointer of the unique instance already defined
422 if(!fgObjGetter && fgDebug)
423 ::Warning("AliPHOSGetter::Instance", "Getter not initialized") ;
429 //____________________________________________________________________________
430 Int_t AliPHOSGetter::MaxEvent() const
432 // returns the number of events in the run (from TE)
434 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
435 return static_cast<Int_t>(rl->GetNumberOfEvents()) ;
438 //____________________________________________________________________________
439 TParticle * AliPHOSGetter::Primary(Int_t index) const
441 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
442 return rl->Stack()->Particle(index) ;
445 //____________________________________________________________________________
446 AliPHOS * AliPHOSGetter:: PHOS() const
448 // returns the PHOS object
449 AliPHOSLoader * loader = 0;
450 static AliPHOSLoader * oldloader = 0;
451 static AliPHOS * phos = 0;
453 loader = PhosLoader();
455 if ( loader != oldloader) {
456 phos = dynamic_cast<AliPHOS*>(loader->GetModulesFolder()->FindObject("PHOS")) ;
461 Warning("PHOS", "PHOS module not found in module folders: %s", PhosLoader()->GetModulesFolder()->GetName() ) ;
467 //____________________________________________________________________________
468 AliPHOSPID * AliPHOSGetter::PID()
470 // Returns pointer to the PID task
472 rv = dynamic_cast<AliPHOSPID *>(PhosLoader()->PIDTask()) ;
475 rv = dynamic_cast<AliPHOSPID *>(PhosLoader()->PIDTask()) ;
480 //____________________________________________________________________________
481 AliPHOSGeometry * AliPHOSGetter::PHOSGeometry() const
483 // Returns PHOS geometry
485 AliPHOSGeometry * rv = 0 ;
487 rv = PHOS()->GetGeometry() ;
491 //____________________________________________________________________________
492 TClonesArray * AliPHOSGetter::Primaries()
494 // creates the Primaries container if needed
497 Info("Primaries", "Creating a new TClonesArray for primaries") ;
498 fPrimaries = new TClonesArray("TParticle", 1000) ;
503 //____________________________________________________________________________
504 void AliPHOSGetter::Print()
506 // Print usefull information about the getter
508 AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle());
509 ::Info( "Print", "gAlice file is %s -- version name is %s", (rl->GetFileName()).Data(), rl->GetEventFolder()->GetName() ) ;
512 //____________________________________________________________________________
513 void AliPHOSGetter::ReadPrimaries()
515 // Read Primaries from Kinematics.root
517 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
519 // gets kine tree from the root file (Kinematics.root)
520 if ( ! rl->TreeK() ) { // load treeK the first time
521 rl->LoadKinematics() ;
524 fNPrimaries = (rl->GetHeader())->GetNtrack();
526 Info( "ReadTreeK", "Found %d particles in event # %d", fNPrimaries, EventNumber() ) ;
529 // first time creates the container
531 fPrimaries->Clear() ;
534 for (index = 0 ; index < fNPrimaries; index++) {
535 new ((*fPrimaries)[index]) TParticle(*(Primary(index)));
539 //____________________________________________________________________________
540 Bool_t AliPHOSGetter::OpenESDFile()
545 fESDFile = TFile::Open(fESDFileName) ;
549 else if (fESDFile->IsOpen()) {
551 fESDFile = TFile::Open(fESDFileName) ;
553 if (!fESDFile->IsOpen())
558 //____________________________________________________________________________
559 void AliPHOSGetter::FitRaw(Bool_t lowGainFlag, TGraph * gLowGain, TGraph * gHighGain, TF1* signalF, Double_t & energy, Double_t & time)
561 // Fits the raw signal time distribution
563 const Int_t kNoiseThreshold = 0 ;
564 Double_t timezero1 = 0., timezero2 = 0., timemax = 0. ;
565 Double_t signal = 0., signalmax = 0. ;
570 timezero1 = timezero2 = signalmax = timemax = 0. ;
571 signalF->FixParameter(0, PHOS()->GetRawFormatLowCharge()) ;
572 signalF->FixParameter(1, PHOS()->GetRawFormatLowGain()) ;
574 for (index = 0; index < PHOS()->GetRawFormatTimeBins(); index++) {
575 gLowGain->GetPoint(index, time, signal) ;
576 if (signal > kNoiseThreshold && timezero1 == 0.)
578 if (signal <= kNoiseThreshold && timezero1 > 0. && timezero2 == 0.)
580 if (signal > signalmax) {
585 signalmax /= PHOS()->RawResponseFunctionMax(PHOS()->GetRawFormatLowCharge(),
586 PHOS()->GetRawFormatLowGain()) ;
587 if ( timezero1 + PHOS()->GetRawFormatTimePeak() < PHOS()->GetRawFormatTimeMax() * 0.4 ) { // else its noise
588 signalF->SetParameter(2, signalmax) ;
589 signalF->SetParameter(3, timezero1) ;
590 gLowGain->Fit(signalF, "QRON", "", 0., timezero2); //, "QRON") ;
591 energy = signalF->GetParameter(2) ;
592 time = signalF->GetMaximumX() - PHOS()->GetRawFormatTimePeak() - PHOS()->GetRawFormatTimeTrigger() ;
595 timezero1 = timezero2 = signalmax = timemax = 0. ;
596 signalF->FixParameter(0, PHOS()->GetRawFormatHighCharge()) ;
597 signalF->FixParameter(1, PHOS()->GetRawFormatHighGain()) ;
599 for (index = 0; index < PHOS()->GetRawFormatTimeBins(); index++) {
600 gHighGain->GetPoint(index, time, signal) ;
601 if (signal > kNoiseThreshold && timezero1 == 0.)
603 if (signal <= kNoiseThreshold && timezero1 > 0. && timezero2 == 0.)
605 if (signal > signalmax) {
610 signalmax /= PHOS()->RawResponseFunctionMax(PHOS()->GetRawFormatHighCharge(),
611 PHOS()->GetRawFormatHighGain()) ;;
612 if ( timezero1 + PHOS()->GetRawFormatTimePeak() < PHOS()->GetRawFormatTimeMax() * 0.4 ) { // else its noise
613 signalF->SetParameter(2, signalmax) ;
614 signalF->SetParameter(3, timezero1) ;
615 gHighGain->Fit(signalF, "QRON", "", 0., timezero2) ;
616 energy = signalF->GetParameter(2) ;
617 time = signalF->GetMaximumX() - PHOS()->GetRawFormatTimePeak() - PHOS()->GetRawFormatTimeTrigger() ;
620 if (time == 0) energy = 0 ;
623 //____________________________________________________________________________
624 Int_t AliPHOSGetter::CalibrateRaw(Double_t energy, Int_t *relId)
626 // Convert energy into digitized amplitude for a cell relId
627 // It is a user responsilibity to open CDB and set
628 // AliPHOSCalibData object by the following operators:
630 // AliCDBLocal *loc = new AliCDBLocal("deCalibDB");
631 // AliPHOSCalibData* clb = (AliPHOSCalibData*)AliCDBStorage::Instance()
632 // ->Get(path_to_calibdata,run_number);
633 // AliPHOSGetter* gime = AliPHOSGetter::Instance("galice.root");
634 // gime->SetCalibData(clb);
636 if (CalibData() == 0)
637 Fatal("CalibrateRaw","Failure to calibrate raw data");
639 Int_t module = relId[0];
640 Int_t column = relId[2];
641 Int_t row = relId[3];
642 Float_t gainFactor = CalibData()->GetADCchannelEmc (module,column,row);
643 Float_t pedestal = CalibData()->GetADCpedestalEmc(module,column,row);
644 Int_t amp = static_cast<Int_t>( (energy - pedestal) / gainFactor + 0.5 ) ;
647 //____________________________________________________________________________
648 Int_t AliPHOSGetter::ReadRaw(AliRawReader *rawReader)
650 // reads the raw format data, converts it into digits format and store digits in Digits()
653 AliPHOSRawStream in(rawReader);
655 Bool_t first = kTRUE ;
657 TF1 * signalF = new TF1("signal", AliPHOS::RawResponseFunction, 0, PHOS()->GetRawFormatTimeMax(), 4);
658 signalF->SetParNames("Charge", "Gain", "Amplitude", "TimeZero") ;
660 Int_t relId[4], id =0;
661 Bool_t lowGainFlag = kFALSE ;
663 TClonesArray * digits = Digits() ;
667 Double_t energy = 0. ;
670 TGraph * gLowGain = new TGraph(PHOS()->GetRawFormatTimeBins()) ;
671 TGraph * gHighGain= new TGraph(PHOS()->GetRawFormatTimeBins()) ;
673 while ( in.Next() ) { // PHOS entries loop
674 if ( (in.IsNewRow() || in.IsNewColumn() || in.IsNewModule()) ) {
675 relId[0] = in.GetModule() ;
676 if ( relId[0] >= PHOS()->GetRawFormatLowGainOffset() ) {
677 relId[0] -= PHOS()->GetRawFormatLowGainOffset() ;
678 lowGainFlag = kTRUE ;
680 lowGainFlag = kFALSE ;
682 relId[2] = in.GetRow() ;
683 relId[3] = in.GetColumn() ;
684 PHOSGeometry()->RelToAbsNumbering(relId, id) ;
687 FitRaw(lowGainFlag, gLowGain, gHighGain, signalF, energy, time) ;
688 amp = CalibrateRaw(energy,relId);
690 new((*digits)[idigit]) AliPHOSDigit( -1, id, amp, time) ;
694 for (index = 0; index < PHOS()->GetRawFormatTimeBins(); index++) {
695 gLowGain->SetPoint(index, index * PHOS()->GetRawFormatTimeMax() / PHOS()->GetRawFormatTimeBins(), 0) ;
696 gHighGain->SetPoint(index, index * PHOS()->GetRawFormatTimeMax() / PHOS()->GetRawFormatTimeBins(), 0) ;
702 gLowGain->SetPoint(in.GetTime(),
703 in.GetTime()* PHOS()->GetRawFormatTimeMax() / PHOS()->GetRawFormatTimeBins(),
706 gHighGain->SetPoint(in.GetTime(),
707 in.GetTime() * PHOS()->GetRawFormatTimeMax() / PHOS()->GetRawFormatTimeBins(),
710 } // PHOS entries loop
712 FitRaw(lowGainFlag, gLowGain, gHighGain, signalF, energy, time) ;
713 amp = CalibrateRaw(energy,relId);
715 new((*digits)[idigit]) AliPHOSDigit( -1, id, amp, time) ;
724 return digits->GetEntriesFast() ;
727 // TClonesArray * digits = Digits() ;
729 // Int_t idigit = 0 ;
731 // while ( in.Next() ) { // PHOS entries loop
733 // Int_t amp = in.GetSignal() ;
734 // Double_t time = in.GetTime() ;
735 // Int_t relId[4], id ;
737 // relId[0] = in.GetModule() ;
738 // if ( relId[0] >= PHOS()->GetRawFormatLowGainOffset() ) {
739 // relId[0] -= PHOS()->GetRawFormatLowGainOffset() ;
742 // relId[2] = in.GetRow() ;
743 // relId[3] = in.GetColumn() ;
744 // PHOSGeometry()->RelToAbsNumbering(relId, id) ;
746 // if (amp > 0 && id >=0 ) {
747 // new((*digits)[idigit]) AliPHOSDigit( -1, id, amp, time) ;
751 // } // PHOS entries loop
755 // return digits->GetEntriesFast() ;
757 //____________________________________________________________________________
758 Int_t AliPHOSGetter::ReadTreeD()
762 PhosLoader()->CleanDigits() ;
763 PhosLoader()->LoadDigits("UPDATE") ;
764 PhosLoader()->LoadDigitizer("UPDATE") ;
765 return Digits()->GetEntries() ;
768 //____________________________________________________________________________
769 Int_t AliPHOSGetter::ReadTreeH()
772 PhosLoader()->CleanHits() ;
773 // gets TreeH from the root file (PHOS.Hit.root)
774 //if ( !IsLoaded("H") ) {
775 PhosLoader()->LoadHits("UPDATE") ;
778 return Hits()->GetEntries() ;
781 //____________________________________________________________________________
782 Int_t AliPHOSGetter::ReadTreeR()
784 // Read the RecPoints
786 PhosLoader()->CleanRecPoints() ;
787 // gets TreeR from the root file (PHOS.RecPoints.root)
788 //if ( !IsLoaded("R") ) {
789 PhosLoader()->LoadRecPoints("UPDATE") ;
790 PhosLoader()->LoadClusterizer("UPDATE") ;
794 return EmcRecPoints()->GetEntries() ;
797 //____________________________________________________________________________
798 Int_t AliPHOSGetter::ReadTreeT()
800 // Read the TrackSegments
802 PhosLoader()->CleanTracks() ;
803 // gets TreeT from the root file (PHOS.TrackSegments.root)
804 //if ( !IsLoaded("T") ) {
805 PhosLoader()->LoadTracks("UPDATE") ;
806 PhosLoader()->LoadTrackSegmentMaker("UPDATE") ;
810 return TrackSegments()->GetEntries() ;
812 //____________________________________________________________________________
813 Int_t AliPHOSGetter::ReadTreeP()
815 // Read the RecParticles
817 PhosLoader()->CleanRecParticles() ;
819 // gets TreeT from the root file (PHOS.TrackSegments.root)
820 // if ( !IsLoaded("P") ) {
821 PhosLoader()->LoadRecParticles("UPDATE") ;
822 PhosLoader()->LoadPID("UPDATE") ;
826 return RecParticles()->GetEntries() ;
828 //____________________________________________________________________________
829 Int_t AliPHOSGetter::ReadTreeS()
833 PhosLoader()->CleanSDigits() ;
834 // gets TreeS from the root file (PHOS.SDigits.root)
835 //if ( !IsLoaded("S") ) {
836 PhosLoader()->LoadSDigits("READ") ;
837 PhosLoader()->LoadSDigitizer("READ") ;
841 return SDigits()->GetEntries() ;
844 //____________________________________________________________________________
845 Int_t AliPHOSGetter::ReadTreeE(Int_t event)
849 // gets esdTree from the root file (AliESDs.root)
851 if ( !OpenESDFile() )
854 fESDTree = static_cast<TTree*>(fESDFile->Get("esdTree")) ;
858 Error("ReadTreeE", "no ESD tree found");
861 fESDTree->SetBranchAddress("ESD", &fESD);
862 fESDTree->GetEvent(event);
867 //____________________________________________________________________________
868 TClonesArray * AliPHOSGetter::SDigits()
870 // asks the Loader to return the Digits container
872 TClonesArray * rv = 0 ;
874 rv = PhosLoader()->SDigits() ;
876 PhosLoader()->MakeSDigitsArray() ;
877 rv = PhosLoader()->SDigits() ;
882 //____________________________________________________________________________
883 AliPHOSSDigitizer * AliPHOSGetter::SDigitizer()
885 // Returns pointer to the SDigitizer task
886 AliPHOSSDigitizer * rv ;
887 rv = dynamic_cast<AliPHOSSDigitizer *>(PhosLoader()->SDigitizer()) ;
890 rv = dynamic_cast<AliPHOSSDigitizer *>(PhosLoader()->SDigitizer()) ;
895 //____________________________________________________________________________
896 TParticle * AliPHOSGetter::Secondary(const TParticle* p, Int_t index) const
898 // Return first (index=1) or second (index=2) secondary particle of primary particle p
906 Int_t daughterIndex = p->GetDaughter(index-1) ;
907 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
908 return rl->GetAliRun()->GetMCApp()->Particle(daughterIndex) ;
914 //____________________________________________________________________________
915 void AliPHOSGetter::Track(Int_t itrack)
917 // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
919 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
921 if( !TreeH() ) // load treeH the first time
924 // first time create the container
925 TClonesArray * hits = Hits() ;
929 TBranch * phosbranch = dynamic_cast<TBranch*>(TreeH()->GetBranch("PHOS")) ;
930 phosbranch->SetAddress(&hits) ;
931 phosbranch->GetEntry(itrack) ;
934 //____________________________________________________________________________
935 TTree * AliPHOSGetter::TreeD() const
937 // Returns pointer to the Digits Tree
939 rv = PhosLoader()->TreeD() ;
941 PhosLoader()->MakeTree("D");
942 rv = PhosLoader()->TreeD() ;
948 //____________________________________________________________________________
949 TTree * AliPHOSGetter::TreeH() const
951 // Returns pointer to the Hits Tree
953 rv = PhosLoader()->TreeH() ;
955 PhosLoader()->MakeTree("H");
956 rv = PhosLoader()->TreeH() ;
962 //____________________________________________________________________________
963 TTree * AliPHOSGetter::TreeR() const
965 // Returns pointer to the RecPoints Tree
967 rv = PhosLoader()->TreeR() ;
969 PhosLoader()->MakeTree("R");
970 rv = PhosLoader()->TreeR() ;
976 //____________________________________________________________________________
977 TTree * AliPHOSGetter::TreeT() const
979 // Returns pointer to the TrackSegments Tree
981 rv = PhosLoader()->TreeT() ;
983 PhosLoader()->MakeTree("T");
984 rv = PhosLoader()->TreeT() ;
989 //____________________________________________________________________________
990 TTree * AliPHOSGetter::TreeP() const
992 // Returns pointer to the RecParticles Tree
994 rv = PhosLoader()->TreeP() ;
996 PhosLoader()->MakeTree("P");
997 rv = PhosLoader()->TreeP() ;
1003 //____________________________________________________________________________
1004 TTree * AliPHOSGetter::TreeS() const
1006 // Returns pointer to the SDigits Tree
1008 rv = PhosLoader()->TreeS() ;
1010 PhosLoader()->MakeTree("S");
1011 rv = PhosLoader()->TreeS() ;
1017 //____________________________________________________________________________
1018 Bool_t AliPHOSGetter::VersionExists(TString & opt) const
1020 // checks if the version with the present name already exists in the same directory
1022 Bool_t rv = kFALSE ;
1024 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
1025 TString version( rl->GetEventFolder()->GetName() ) ;
1029 if ( opt == "sdigits") {
1030 // add the version name to the root file name
1031 TString fileName( PhosLoader()->GetSDigitsFileName() ) ;
1032 if (version != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
1033 fileName = fileName.ReplaceAll(".root", "") + "_" + version + ".root" ;
1034 if ( !(gSystem->AccessPathName(fileName)) ) {
1035 Warning("VersionExists", "The file %s already exists", fileName.Data()) ;
1038 PhosLoader()->SetSDigitsFileName(fileName) ;
1041 if ( opt == "digits") {
1042 // add the version name to the root file name
1043 TString fileName( PhosLoader()->GetDigitsFileName() ) ;
1044 if (version != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
1045 fileName = fileName.ReplaceAll(".root", "") + "_" + version + ".root" ;
1046 if ( !(gSystem->AccessPathName(fileName)) ) {
1047 Warning("VersionExists", "The file %s already exists", fileName.Data()) ;
1056 //____________________________________________________________________________
1057 UShort_t AliPHOSGetter::EventPattern(void) const
1059 // Return the pattern (trigger bit register) of the beam-test event
1061 return fBTE->GetPattern() ;
1065 //____________________________________________________________________________
1066 Float_t AliPHOSGetter::BeamEnergy(void) const
1068 // Return the beam energy of the beam-test event
1070 return fBTE->GetBeamEnergy() ;
1074 //____________________________________________________________________________
1076 AliPHOSCalibData* AliPHOSGetter::CalibData()
1079 if( !(AliCDBManager::Instance()->IsDefaultStorageSet()) ) {
1081 Warning("CalibData","Calibration DB is not initiated!");