1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 //_________________________________________________________________________
19 // A singleton. This class should be used in the analysis stage to get
20 // reconstructed objects: Digits, RecPoints, TrackSegments and RecParticles,
21 // instead of directly reading them from galice.root file. This container
22 // ensures, that one reads Digits, made of these particular digits, RecPoints,
23 // made of these particular RecPoints, TrackSegments and RecParticles.
24 // This becomes non trivial if there are several identical branches, produced with
25 // different set of parameters.
27 // An example of how to use (see also class AliPHOSAnalyser):
28 // AliPHOSGetter * gime = AliPHOSGetter::GetInstance("galice.root","test") ;
29 // for(Int_t irecp = 0; irecp < gime->NRecParticles() ; irecp++)
30 // AliPHOSRecParticle * part = gime->RecParticle(1) ;
32 // gime->Event(event) ; // reads new event from galice.root
34 //*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
35 //*-- Completely redesigned by Dmitri Peressounko March 2001
37 //*-- YS June 2001 : renamed the original AliPHOSIndexToObject and make
38 //*-- systematic usage of TFolders without changing the interface
39 //////////////////////////////////////////////////////////////////////////////
41 // --- ROOT system ---
46 #include <TParticle.h>
53 // --- Standard library ---
55 // --- AliRoot header files ---
57 #include "AliHeader.h"
60 #include "AliPHOSBeamTestEvent.h"
61 #include "AliPHOSGetter.h"
62 #include "AliPHOSLoader.h"
63 #include "AliPHOSPulseGenerator.h"
64 #include "AliRunLoader.h"
66 #include "AliPHOSRawDecoder.h"
67 #include "AliRawReaderFile.h"
69 #include "AliCDBLocal.h"
70 #include "AliCDBStorage.h"
71 #include "AliCDBManager.h"
72 #include "AliPHOSRawDigiProducer.h"
73 #include "AliPHOSReconstructor.h"
74 #include "AliPHOSRecoParam.h"
76 ClassImp(AliPHOSGetter)
78 AliPHOSGetter * AliPHOSGetter::fgObjGetter = 0 ;
79 AliPHOSLoader * AliPHOSGetter::fgPhosLoader = 0;
80 AliPHOSCalibData* AliPHOSGetter::fgCalibData = 0;
81 Int_t AliPHOSGetter::fgDebug = 0;
83 // TFile * AliPHOSGetter::fgFile = 0 ;
85 AliPHOSGetter::AliPHOSGetter() :
97 // ctor: this is a singleton, the ctor should never be called but cint needs it as public
98 Fatal("ctor", "AliPHOSGetter is a singleton default ctor not callable") ;
102 //____________________________________________________________________________
103 AliPHOSGetter::AliPHOSGetter(const char* headerFile, const char* version, Option_t * openingOption) :
115 // ctor only called by Instance()
117 AliRunLoader* rl = AliRunLoader::GetRunLoader(version) ;
119 rl = AliRunLoader::Open(headerFile, version, openingOption);
121 Fatal("AliPHOSGetter", "Could not find the Run Loader for %s - %s",headerFile, version) ;
124 if (rl->GetAliRun() == 0x0) {
126 gAlice = rl->GetAliRun(); // should be removed
130 fgPhosLoader = dynamic_cast<AliPHOSLoader*>(rl->GetLoader("PHOSLoader"));
132 Error("AliPHOSGetter", "Could not find PHOSLoader") ;
134 fgPhosLoader->SetTitle(version);
136 // initialize data members
140 fLoadingStatus = "" ;
142 fESDFileName = rl->GetFileName() ; // this should be the galice.root file
143 fESDFileName.ReplaceAll("galice.root", "AliESDs.root") ;
147 fRawDigits = kFALSE ;
151 AliPHOSGetter::AliPHOSGetter(const AliPHOSGetter & obj) :
164 // cpy ctor requested by Coding Convention
165 Fatal("cpy ctor", "not implemented") ;
168 //____________________________________________________________________________
169 AliPHOSGetter::AliPHOSGetter(Int_t /*i*/) :
181 // special constructor for onflight
185 //____________________________________________________________________________
186 AliPHOSGetter::~AliPHOSGetter()
190 delete fgPhosLoader ;
198 fPrimaries->Delete() ;
209 //____________________________________________________________________________
210 void AliPHOSGetter::Reset()
212 // resets things in case the getter is called consecutively with different files
213 // the PHOS Loader is already deleted by the Run Loader
216 fPrimaries->Delete() ;
223 //____________________________________________________________________________
224 AliPHOSClusterizer * AliPHOSGetter::Clusterizer()
226 // Returns pointer to the Clusterizer task
227 AliPHOSClusterizer * rv ;
228 rv = dynamic_cast<AliPHOSClusterizer *>(PhosLoader()->Reconstructioner()) ;
231 rv = dynamic_cast<AliPHOSClusterizer*>(PhosLoader()->Reconstructioner()) ;
236 //____________________________________________________________________________
237 TObjArray * AliPHOSGetter::CpvRecPoints() const
239 // asks the Loader to return the CPV RecPoints container
243 rv = PhosLoader()->CpvRecPoints() ;
245 PhosLoader()->MakeRecPointsArray() ;
246 rv = PhosLoader()->CpvRecPoints() ;
251 //____________________________________________________________________________
252 TClonesArray * AliPHOSGetter::Digits() const
254 // asks the Loader to return the Digits container
256 TClonesArray * rv = 0 ;
257 rv = PhosLoader()->Digits() ;
260 PhosLoader()->MakeDigitsArray() ;
261 rv = PhosLoader()->Digits() ;
266 //____________________________________________________________________________
267 AliPHOSDigitizer * AliPHOSGetter::Digitizer()
269 // Returns pointer to the Digitizer task
270 AliPHOSDigitizer * rv ;
271 rv = dynamic_cast<AliPHOSDigitizer *>(PhosLoader()->Digitizer()) ;
274 rv = dynamic_cast<AliPHOSDigitizer *>(PhosLoader()->Digitizer()) ;
280 //____________________________________________________________________________
281 TObjArray * AliPHOSGetter::EmcRecPoints() const
283 // asks the Loader to return the EMC RecPoints container
287 rv = PhosLoader()->EmcRecPoints() ;
289 PhosLoader()->MakeRecPointsArray() ;
290 rv = PhosLoader()->EmcRecPoints() ;
295 //____________________________________________________________________________
296 TClonesArray * AliPHOSGetter::TrackSegments() const
298 // asks the Loader to return the TrackSegments container
300 TClonesArray * rv = 0 ;
302 rv = PhosLoader()->TrackSegments() ;
304 PhosLoader()->MakeTrackSegmentsArray() ;
305 rv = PhosLoader()->TrackSegments() ;
310 //____________________________________________________________________________
311 AliPHOSTrackSegmentMaker * AliPHOSGetter::TrackSegmentMaker()
313 // Returns pointer to the TrackSegmentMaker task
314 AliPHOSTrackSegmentMaker * rv ;
315 rv = dynamic_cast<AliPHOSTrackSegmentMaker *>(PhosLoader()->TrackSegmentMaker()) ;
318 rv = dynamic_cast<AliPHOSTrackSegmentMaker *>(PhosLoader()->TrackSegmentMaker()) ;
323 //____________________________________________________________________________
324 TClonesArray * AliPHOSGetter::RecParticles() const
326 // asks the Loader to return the TrackSegments container
328 TClonesArray * rv = 0 ;
330 rv = PhosLoader()->RecParticles() ;
332 PhosLoader()->MakeRecParticlesArray() ;
333 rv = PhosLoader()->RecParticles() ;
337 //____________________________________________________________________________
338 void AliPHOSGetter::Event(Int_t event, const char* opt)
340 // Reads the content of all Tree's S, D and R
342 // if ( event >= MaxEvent() ) {
343 // Error("Event", "%d not found in TreeE !", event) ;
347 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
349 // // checks if we are dealing with test-beam data
350 // TBranch * btb = rl->TreeE()->GetBranch("AliPHOSBeamTestEvent") ;
353 // fBTE = new AliPHOSBeamTestEvent() ;
354 // btb->SetAddress(&fBTE) ;
355 // btb->GetEntry(event) ;
364 // Loads the type of object(s) requested
366 rl->GetEvent(event) ;
368 if(strstr(opt,"X") || (strcmp(opt,"")==0)){
372 if(strstr(opt,"H") ){
376 if(strstr(opt,"S") ){
380 if(strstr(opt,"D") ){
384 if(strstr(opt,"R") ){
388 if( strstr(opt,"T") ){
392 if( strstr(opt,"P") ){
396 if( strstr(opt,"E") ){
403 //____________________________________________________________________________
404 void AliPHOSGetter::Event(AliRawReader *rawReader, const char* opt, Bool_t isOldRCUFormat)
406 // Reads the raw event from rawReader
407 // isOldRCUFormat defines whenever to assume
408 // the old RCU format or not
410 if( strstr(opt,"W") ){
411 rawReader->NextEvent();
412 ReadRaw(rawReader,isOldRCUFormat) ;
418 //____________________________________________________________________________
419 Int_t AliPHOSGetter::EventNumber() const
421 // return the current event number
422 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
423 return static_cast<Int_t>(rl->GetEventNumber()) ;
426 //____________________________________________________________________________
427 TClonesArray * AliPHOSGetter::Hits() const
429 // asks the loader to return the Hits container
431 TClonesArray * rv = 0 ;
433 rv = PhosLoader()->Hits() ;
435 PhosLoader()->LoadHits("read");
436 rv = PhosLoader()->Hits() ;
441 //____________________________________________________________________________
442 AliPHOSGetter * AliPHOSGetter::Instance(const char* alirunFileName, const char* version, Option_t * openingOption)
444 // Creates and returns the pointer of the unique instance
445 // Must be called only when the environment has changed
447 if(!fgObjGetter){ // first time the getter is called
448 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
450 else { // the getter has been called previously
451 AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle());
452 if ( rl->GetFileName() == alirunFileName ) {// the alirunFile has the same name
453 // check if the file is already open
454 TFile * galiceFile = dynamic_cast<TFile *>(gROOT->FindObject(rl->GetFileName()) ) ;
457 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
459 else { // the file is already open check the version name
460 TString currentVersionName = rl->GetEventFolder()->GetName() ;
461 TString newVersionName(version) ;
462 if (currentVersionName == newVersionName)
464 ::Warning( "Instance", "Files with version %s already open", currentVersionName.Data() ) ;
466 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
471 rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle()) ;
472 if ( strstr(version, AliConfig::GetDefaultEventFolderName()) ) // false in case of merging
474 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
478 ::Error("AliPHOSGetter::Instance", "Failed to create the PHOS Getter object") ;
486 //____________________________________________________________________________
487 AliPHOSGetter * AliPHOSGetter::Instance()
489 // Returns the pointer of the unique instance already defined
491 if(!fgObjGetter && fgDebug)
492 ::Warning("AliPHOSGetter::Instance", "Getter not initialized") ;
498 //____________________________________________________________________________
499 Int_t AliPHOSGetter::MaxEvent() const
501 // returns the number of events in the run (from TE)
503 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
504 return static_cast<Int_t>(rl->GetNumberOfEvents()) ;
507 //____________________________________________________________________________
508 TParticle * AliPHOSGetter::Primary(Int_t index) const
510 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
511 return rl->Stack()->Particle(index) ;
514 //____________________________________________________________________________
515 AliPHOS * AliPHOSGetter:: PHOS() const
517 // returns the PHOS object
518 AliPHOSLoader * loader = 0;
519 static AliPHOSLoader * oldloader = 0;
520 static AliPHOS * phos = 0;
522 loader = PhosLoader();
524 if ( loader != oldloader) {
525 phos = dynamic_cast<AliPHOS*>(loader->GetModulesFolder()->FindObject("PHOS")) ;
530 Warning("PHOS", "PHOS module not found in module folders: %s", PhosLoader()->GetModulesFolder()->GetName() ) ;
536 //____________________________________________________________________________
537 AliPHOSPID * AliPHOSGetter::PID()
539 // Returns pointer to the PID task
541 rv = dynamic_cast<AliPHOSPID *>(PhosLoader()->PIDTask()) ;
544 rv = dynamic_cast<AliPHOSPID *>(PhosLoader()->PIDTask()) ;
549 //____________________________________________________________________________
550 TClonesArray * AliPHOSGetter::Primaries()
552 // creates the Primaries container if needed
555 Info("Primaries", "Creating a new TClonesArray for primaries") ;
556 fPrimaries = new TClonesArray("TParticle", 1000) ;
561 //____________________________________________________________________________
562 void AliPHOSGetter::Print()
564 // Print usefull information about the getter
566 AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle());
567 ::Info( "Print", "gAlice file is %s -- version name is %s", (rl->GetFileName()).Data(), rl->GetEventFolder()->GetName() ) ;
570 //____________________________________________________________________________
571 void AliPHOSGetter::ReadPrimaries()
573 // Read Primaries from Kinematics.root
575 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
577 // gets kine tree from the root file (Kinematics.root)
578 if ( ! rl->TreeK() ) { // load treeK the first time
579 rl->LoadKinematics() ;
582 fNPrimaries = (rl->GetHeader())->GetNtrack();
584 Info( "ReadTreeK", "Found %d particles in event # %d", fNPrimaries, EventNumber() ) ;
587 // first time creates the container
589 fPrimaries->Clear() ;
592 for (index = 0 ; index < fNPrimaries; index++) {
593 new ((*fPrimaries)[index]) TParticle(*(Primary(index)));
597 //____________________________________________________________________________
598 Bool_t AliPHOSGetter::OpenESDFile()
603 fESDFile = TFile::Open(fESDFileName) ;
607 else if (fESDFile->IsOpen()) {
609 fESDFile = TFile::Open(fESDFileName) ;
611 if (!fESDFile->IsOpen())
616 //____________________________________________________________________________
617 void AliPHOSGetter::FitRaw(Bool_t lowGainFlag, TGraph * gLowGain, TGraph * gHighGain, TF1* signalF, Double_t & energy, Double_t & time) const
619 // Fits the raw signal time distribution
621 const Int_t kNoiseThreshold = 0 ;
622 Double_t timezero1 = 0., timezero2 = 0., timemax = 0. ;
623 Double_t signal = 0., signalmax = 0. ;
627 // Create a shaper pulse object which contains all the shaper parameters
628 AliPHOSPulseGenerator pulse;
631 timezero1 = timezero2 = signalmax = timemax = 0. ;
632 signalF->FixParameter(0, pulse.GetRawFormatLowCharge()) ;
633 signalF->FixParameter(1, pulse.GetRawFormatLowGain()) ;
635 for (index = 0; index < pulse.GetRawFormatTimeBins(); index++) {
636 gLowGain->GetPoint(index, time, signal) ;
637 if (signal > kNoiseThreshold && timezero1 == 0.)
639 if (signal <= kNoiseThreshold && timezero1 > 0. && timezero2 == 0.)
641 if (signal > signalmax) {
647 pulse.RawResponseFunctionMax(pulse.GetRawFormatLowCharge(),
648 pulse.GetRawFormatLowGain()) ;
649 if ( timezero1 + pulse.GetRawFormatTimePeak() < pulse.GetRawFormatTimeMax() * 0.4 ) { // else its noise
650 signalF->SetParameter(2, signalmax) ;
651 signalF->SetParameter(3, timezero1) ;
652 gLowGain->Fit(signalF, "QRO", "", 0., timezero2); //, "QRON") ;
653 energy = signalF->GetParameter(2) ;
654 time = signalF->GetMaximumX() - pulse.GetRawFormatTimePeak() - pulse.GetRawFormatTimeTrigger() ;
657 timezero1 = timezero2 = signalmax = timemax = 0. ;
658 signalF->FixParameter(0, pulse.GetRawFormatHighCharge()) ;
659 signalF->FixParameter(1, pulse.GetRawFormatHighGain()) ;
661 for (index = 0; index < pulse.GetRawFormatTimeBins(); index++) {
662 gHighGain->GetPoint(index, time, signal) ;
663 if (signal > kNoiseThreshold && timezero1 == 0.)
665 if (signal <= kNoiseThreshold && timezero1 > 0. && timezero2 == 0.)
667 if (signal > signalmax) {
672 signalmax /= pulse.RawResponseFunctionMax(pulse.GetRawFormatHighCharge(),
673 pulse.GetRawFormatHighGain()) ;;
674 if ( timezero1 + pulse.GetRawFormatTimePeak() < pulse.GetRawFormatTimeMax() * 0.4 ) { // else its noise
675 signalF->SetParameter(2, signalmax) ;
676 signalF->SetParameter(3, timezero1) ;
677 gHighGain->Fit(signalF, "QRO", "", 0., timezero2) ;
678 energy = signalF->GetParameter(2) ;
679 time = signalF->GetMaximumX() - pulse.GetRawFormatTimePeak() - pulse.GetRawFormatTimeTrigger() ;
682 if (time == 0) energy = 0 ;
685 //____________________________________________________________________________
686 Int_t AliPHOSGetter::CalibrateRaw(Double_t energy, Int_t *relId)
688 // Convert energy into digitized amplitude for a cell relId
689 // It is a user responsilibity to open CDB and set
690 // AliPHOSCalibData object by the following operators:
692 // AliCDBLocal *loc = new AliCDBLocal("deCalibDB");
693 // AliPHOSCalibData* clb = (AliPHOSCalibData*)AliCDBStorage::Instance()
694 // ->Get(path_to_calibdata,run_number);
695 // AliPHOSGetter* gime = AliPHOSGetter::Instance("galice.root");
696 // gime->SetCalibData(clb);
698 if (CalibData() == 0)
699 Warning("CalibrateRaw","Calibration DB is not initiated!");
701 Int_t module = relId[0];
702 Int_t column = relId[3];
703 Int_t row = relId[2];
705 Float_t gainFactor = 0.0015; // width of one Emc ADC channel in GeV
706 Float_t pedestal = 0.005; // Emc pedestals
709 gainFactor = CalibData()->GetADCchannelEmc (module,column,row);
710 pedestal = CalibData()->GetADCpedestalEmc(module,column,row);
713 Int_t amp = static_cast<Int_t>( (energy - pedestal) / gainFactor + 0.5 ) ;
716 //____________________________________________________________________________
717 Int_t AliPHOSGetter::ReadRaw(AliRawReader *rawReader,Bool_t isOldRCUFormat)
719 // reads the raw format data, converts it into digits format and store digits in Digits()
721 // isOldRCUFormat = kTRUE in case of the old RCU
722 // format used in the raw data readout.
723 // Reimplemented by Boris Polichtchouk (Jul 2006)
724 // to make it working with the Jul-Aug 2006 beam test data.
726 //Create raw decoder.
728 AliPHOSRawDecoder dc(rawReader);
729 dc.SetOldRCUFormat(isOldRCUFormat);
730 dc.SubtractPedestals(AliPHOSReconstructor::GetRecoParamEmc()->SubtractPedestals());
732 TClonesArray * digits = Digits() ;
733 AliPHOSRawDigiProducer pr;
734 pr.MakeDigits(digits,&dc);
737 for(Int_t i=0; i<digits->GetEntries(); i++) {
738 AliPHOSDigit* digit = (AliPHOSDigit*)digits->At(i);
739 digit->SetEnergy(digit->GetEnergy()/AliPHOSPulseGenerator::GeV2ADC());
749 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
751 for(Int_t iDigit=0; iDigit<digits->GetEntries(); iDigit++) {
752 AliPHOSDigit* digit = (AliPHOSDigit*)digits->At(iDigit);
753 if(digit->GetEnergy()>eMax) {
754 phosgeom->AbsToRelNumbering(digit->GetId(),relId);
755 eMax=digit->GetEnergy();
762 AliDebug(1,Form("Digit with max. energy: modMax %d colMax %d rowMax %d eMax %f\n\n",
763 modMax,colMax,rowMax,eMax));
765 return digits->GetEntriesFast() ;
768 //____________________________________________________________________________
769 Int_t AliPHOSGetter::ReadTreeD() const
773 PhosLoader()->CleanDigits() ;
774 PhosLoader()->LoadDigits("UPDATE") ;
775 PhosLoader()->LoadDigitizer("UPDATE") ;
776 return Digits()->GetEntries() ;
779 //____________________________________________________________________________
780 Int_t AliPHOSGetter::ReadTreeH() const
783 PhosLoader()->CleanHits() ;
784 // gets TreeH from the root file (PHOS.Hit.root)
785 //if ( !IsLoaded("H") ) {
786 PhosLoader()->LoadHits("UPDATE") ;
789 return Hits()->GetEntries() ;
792 //____________________________________________________________________________
793 Int_t AliPHOSGetter::ReadTreeR() const
795 // Read the RecPoints
797 PhosLoader()->CleanRecPoints() ;
798 // gets TreeR from the root file (PHOS.RecPoints.root)
799 //if ( !IsLoaded("R") ) {
800 PhosLoader()->LoadRecPoints("UPDATE") ;
804 return EmcRecPoints()->GetEntries() ;
807 //____________________________________________________________________________
808 Int_t AliPHOSGetter::ReadTreeT() const
810 // Read the TrackSegments
812 PhosLoader()->CleanTracks() ;
813 // gets TreeT from the root file (PHOS.TrackSegments.root)
814 //if ( !IsLoaded("T") ) {
815 PhosLoader()->LoadTracks("UPDATE") ;
816 PhosLoader()->LoadTrackSegmentMaker("UPDATE") ;
820 return TrackSegments()->GetEntries() ;
822 //____________________________________________________________________________
823 Int_t AliPHOSGetter::ReadTreeP() const
825 // Read the RecParticles
827 PhosLoader()->CleanRecParticles() ;
829 // gets TreeT from the root file (PHOS.TrackSegments.root)
830 // if ( !IsLoaded("P") ) {
831 PhosLoader()->LoadRecParticles("UPDATE") ;
832 PhosLoader()->LoadPID("UPDATE") ;
836 return RecParticles()->GetEntries() ;
838 //____________________________________________________________________________
839 Int_t AliPHOSGetter::ReadTreeS() const
843 PhosLoader()->CleanSDigits() ;
844 // gets TreeS from the root file (PHOS.SDigits.root)
845 //if ( !IsLoaded("S") ) {
846 PhosLoader()->LoadSDigits("READ") ;
847 PhosLoader()->LoadSDigitizer("READ") ;
851 return SDigits()->GetEntries() ;
854 //____________________________________________________________________________
855 Int_t AliPHOSGetter::ReadTreeE(Int_t event)
859 // gets esdTree from the root file (AliESDs.root)
861 if ( !OpenESDFile() )
864 fESDTree = static_cast<TTree*>(fESDFile->Get("esdTree")) ;
868 Error("ReadTreeE", "no ESD tree found");
871 fESDTree->SetBranchAddress("ESD", &fESD);
872 fESDTree->GetEvent(event);
877 //____________________________________________________________________________
878 TClonesArray * AliPHOSGetter::SDigits() const
880 // asks the Loader to return the Digits container
882 TClonesArray * rv = 0 ;
884 rv = PhosLoader()->SDigits() ;
886 PhosLoader()->MakeSDigitsArray() ;
887 rv = PhosLoader()->SDigits() ;
892 //____________________________________________________________________________
893 AliPHOSSDigitizer * AliPHOSGetter::SDigitizer()
895 // Returns pointer to the SDigitizer task
896 AliPHOSSDigitizer * rv ;
897 rv = dynamic_cast<AliPHOSSDigitizer *>(PhosLoader()->SDigitizer()) ;
900 rv = dynamic_cast<AliPHOSSDigitizer *>(PhosLoader()->SDigitizer()) ;
905 //____________________________________________________________________________
906 TParticle * AliPHOSGetter::Secondary(const TParticle* p, Int_t index) const
908 // Return first (index=1) or second (index=2) secondary particle of primary particle p
916 Int_t daughterIndex = p->GetDaughter(index-1) ;
917 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
918 return rl->GetAliRun()->GetMCApp()->Particle(daughterIndex) ;
924 //____________________________________________________________________________
925 void AliPHOSGetter::Track(Int_t itrack)
927 // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
929 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
931 if( !TreeH() ) // load treeH the first time
934 // first time create the container
935 TClonesArray * hits = Hits() ;
939 TBranch * phosbranch = dynamic_cast<TBranch*>(TreeH()->GetBranch("PHOS")) ;
940 phosbranch->SetAddress(&hits) ;
941 phosbranch->GetEntry(itrack) ;
944 //____________________________________________________________________________
945 TTree * AliPHOSGetter::TreeD() const
947 // Returns pointer to the Digits Tree
949 rv = PhosLoader()->TreeD() ;
951 PhosLoader()->MakeTree("D");
952 rv = PhosLoader()->TreeD() ;
958 //____________________________________________________________________________
959 TTree * AliPHOSGetter::TreeH() const
961 // Returns pointer to the Hits Tree
963 rv = PhosLoader()->TreeH() ;
965 PhosLoader()->MakeTree("H");
966 rv = PhosLoader()->TreeH() ;
972 //____________________________________________________________________________
973 TTree * AliPHOSGetter::TreeR() const
975 // Returns pointer to the RecPoints Tree
977 rv = PhosLoader()->TreeR() ;
979 PhosLoader()->MakeTree("R");
980 rv = PhosLoader()->TreeR() ;
986 //____________________________________________________________________________
987 TTree * AliPHOSGetter::TreeT() const
989 // Returns pointer to the TrackSegments Tree
991 rv = PhosLoader()->TreeT() ;
993 PhosLoader()->MakeTree("T");
994 rv = PhosLoader()->TreeT() ;
999 //____________________________________________________________________________
1000 TTree * AliPHOSGetter::TreeP() const
1002 // Returns pointer to the RecParticles Tree
1004 rv = PhosLoader()->TreeP() ;
1006 PhosLoader()->MakeTree("P");
1007 rv = PhosLoader()->TreeP() ;
1013 //____________________________________________________________________________
1014 TTree * AliPHOSGetter::TreeS() const
1016 // Returns pointer to the SDigits Tree
1018 rv = PhosLoader()->TreeS() ;
1020 PhosLoader()->MakeTree("S");
1021 rv = PhosLoader()->TreeS() ;
1027 //____________________________________________________________________________
1028 Bool_t AliPHOSGetter::VersionExists(TString & opt) const
1030 // checks if the version with the present name already exists in the same directory
1032 Bool_t rv = kFALSE ;
1034 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
1035 TString version( rl->GetEventFolder()->GetName() ) ;
1039 if ( opt == "sdigits") {
1040 // add the version name to the root file name
1041 TString fileName( PhosLoader()->GetSDigitsFileName() ) ;
1042 if (version != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
1043 fileName = fileName.ReplaceAll(".root", "") + "_" + version + ".root" ;
1044 if ( !(gSystem->AccessPathName(fileName)) ) {
1045 Warning("VersionExists", "The file %s already exists", fileName.Data()) ;
1048 PhosLoader()->SetSDigitsFileName(fileName) ;
1051 if ( opt == "digits") {
1052 // add the version name to the root file name
1053 TString fileName( PhosLoader()->GetDigitsFileName() ) ;
1054 if (version != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
1055 fileName = fileName.ReplaceAll(".root", "") + "_" + version + ".root" ;
1056 if ( !(gSystem->AccessPathName(fileName)) ) {
1057 Warning("VersionExists", "The file %s already exists", fileName.Data()) ;
1066 //____________________________________________________________________________
1067 UShort_t AliPHOSGetter::EventPattern(void) const
1069 // Return the pattern (trigger bit register) of the beam-test event
1071 return fBTE->GetPattern() ;
1075 //____________________________________________________________________________
1076 Float_t AliPHOSGetter::BeamEnergy(void) const
1078 // Return the beam energy of the beam-test event
1080 return fBTE->GetBeamEnergy() ;
1084 //____________________________________________________________________________
1086 AliPHOSCalibData* AliPHOSGetter::CalibData()
1088 // Check if the instance of AliPHOSCalibData exists, and return it