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"
68 ClassImp(AliPHOSGetter)
70 AliPHOSGetter * AliPHOSGetter::fgObjGetter = 0 ;
71 AliPHOSLoader * AliPHOSGetter::fgPhosLoader = 0;
72 Int_t AliPHOSGetter::fgDebug = 0;
74 // TFile * AliPHOSGetter::fgFile = 0 ;
76 //____________________________________________________________________________
77 AliPHOSGetter::AliPHOSGetter(const char* headerFile, const char* version, Option_t * openingOption)
79 // ctor only called by Instance()
81 AliRunLoader* rl = AliRunLoader::GetRunLoader(version) ;
83 rl = AliRunLoader::Open(headerFile, version, openingOption);
85 Fatal("AliPHOSGetter", "Could not find the Run Loader for %s - %s",headerFile, version) ;
88 if (rl->GetAliRun() == 0x0) {
90 gAlice = rl->GetAliRun(); // should be removed
94 fgPhosLoader = dynamic_cast<AliPHOSLoader*>(rl->GetLoader("PHOSLoader"));
96 Error("AliPHOSGetter", "Could not find PHOSLoader") ;
98 fgPhosLoader->SetTitle(version);
100 // initialize data members
104 fLoadingStatus = "" ;
106 fESDFileName = rl->GetFileName() ; // this should be the galice.root file
107 fESDFileName.ReplaceAll("galice.root", "AliESDs.root") ;
111 fRawDigits = kFALSE ;
114 //____________________________________________________________________________
115 AliPHOSGetter::~AliPHOSGetter()
119 delete fgPhosLoader ;
127 fPrimaries->Delete() ;
138 //____________________________________________________________________________
139 void AliPHOSGetter::Reset()
141 // resets things in case the getter is called consecutively with different files
142 // the PHOS Loader is already deleted by the Run Loader
145 fPrimaries->Delete() ;
152 //____________________________________________________________________________
153 AliPHOSClusterizer * AliPHOSGetter::Clusterizer()
155 // Returns pointer to the Clusterizer task
156 AliPHOSClusterizer * rv ;
157 rv = dynamic_cast<AliPHOSClusterizer *>(PhosLoader()->Reconstructioner()) ;
160 rv = dynamic_cast<AliPHOSClusterizer*>(PhosLoader()->Reconstructioner()) ;
165 //____________________________________________________________________________
166 TObjArray * AliPHOSGetter::CpvRecPoints()
168 // asks the Loader to return the CPV RecPoints container
172 rv = PhosLoader()->CpvRecPoints() ;
174 PhosLoader()->MakeRecPointsArray() ;
175 rv = PhosLoader()->CpvRecPoints() ;
180 //____________________________________________________________________________
181 TClonesArray * AliPHOSGetter::Digits()
183 // asks the Loader to return the Digits container
185 TClonesArray * rv = 0 ;
186 rv = PhosLoader()->Digits() ;
189 PhosLoader()->MakeDigitsArray() ;
190 rv = PhosLoader()->Digits() ;
195 //____________________________________________________________________________
196 AliPHOSDigitizer * AliPHOSGetter::Digitizer()
198 // Returns pointer to the Digitizer task
199 AliPHOSDigitizer * rv ;
200 rv = dynamic_cast<AliPHOSDigitizer *>(PhosLoader()->Digitizer()) ;
203 rv = dynamic_cast<AliPHOSDigitizer *>(PhosLoader()->Digitizer()) ;
209 //____________________________________________________________________________
210 TObjArray * AliPHOSGetter::EmcRecPoints()
212 // asks the Loader to return the EMC RecPoints container
216 rv = PhosLoader()->EmcRecPoints() ;
218 PhosLoader()->MakeRecPointsArray() ;
219 rv = PhosLoader()->EmcRecPoints() ;
224 //____________________________________________________________________________
225 TClonesArray * AliPHOSGetter::TrackSegments()
227 // asks the Loader to return the TrackSegments container
229 TClonesArray * rv = 0 ;
231 rv = PhosLoader()->TrackSegments() ;
233 PhosLoader()->MakeTrackSegmentsArray() ;
234 rv = PhosLoader()->TrackSegments() ;
239 //____________________________________________________________________________
240 AliPHOSTrackSegmentMaker * AliPHOSGetter::TrackSegmentMaker()
242 // Returns pointer to the TrackSegmentMaker task
243 AliPHOSTrackSegmentMaker * rv ;
244 rv = dynamic_cast<AliPHOSTrackSegmentMaker *>(PhosLoader()->TrackSegmentMaker()) ;
247 rv = dynamic_cast<AliPHOSTrackSegmentMaker *>(PhosLoader()->TrackSegmentMaker()) ;
252 //____________________________________________________________________________
253 TClonesArray * AliPHOSGetter::RecParticles()
255 // asks the Loader to return the TrackSegments container
257 TClonesArray * rv = 0 ;
259 rv = PhosLoader()->RecParticles() ;
261 PhosLoader()->MakeRecParticlesArray() ;
262 rv = PhosLoader()->RecParticles() ;
266 //____________________________________________________________________________
267 void AliPHOSGetter::Event(Int_t event, const char* opt)
269 // Reads the content of all Tree's S, D and R
271 // if ( event >= MaxEvent() ) {
272 // Error("Event", "%d not found in TreeE !", event) ;
276 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
278 // // checks if we are dealing with test-beam data
279 // TBranch * btb = rl->TreeE()->GetBranch("AliPHOSBeamTestEvent") ;
282 // fBTE = new AliPHOSBeamTestEvent() ;
283 // btb->SetAddress(&fBTE) ;
284 // btb->GetEntry(event) ;
293 // Loads the type of object(s) requested
295 rl->GetEvent(event) ;
297 if(strstr(opt,"X") || (strcmp(opt,"")==0)){
301 if(strstr(opt,"H") ){
305 if(strstr(opt,"S") ){
309 if(strstr(opt,"D") ){
313 if(strstr(opt,"R") ){
317 if( strstr(opt,"T") ){
321 if( strstr(opt,"P") ){
325 if( strstr(opt,"E") ){
332 //____________________________________________________________________________
333 void AliPHOSGetter::Event(AliRawReader *rawReader, const char* opt)
335 // Reads the raw event from rawReader
337 if( strstr(opt,"W") ){
344 //____________________________________________________________________________
345 Int_t AliPHOSGetter::EventNumber() const
347 // return the current event number
348 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
349 return static_cast<Int_t>(rl->GetEventNumber()) ;
352 //____________________________________________________________________________
353 TClonesArray * AliPHOSGetter::Hits()
355 // asks the loader to return the Hits container
357 TClonesArray * rv = 0 ;
359 rv = PhosLoader()->Hits() ;
361 PhosLoader()->LoadHits("read");
362 rv = PhosLoader()->Hits() ;
367 //____________________________________________________________________________
368 AliPHOSGetter * AliPHOSGetter::Instance(const char* alirunFileName, const char* version, Option_t * openingOption)
370 // Creates and returns the pointer of the unique instance
371 // Must be called only when the environment has changed
373 if(!fgObjGetter){ // first time the getter is called
374 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
376 else { // the getter has been called previously
377 AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle());
378 if ( rl->GetFileName() == alirunFileName ) {// the alirunFile has the same name
379 // check if the file is already open
380 TFile * galiceFile = dynamic_cast<TFile *>(gROOT->FindObject(rl->GetFileName()) ) ;
383 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
385 else { // the file is already open check the version name
386 TString currentVersionName = rl->GetEventFolder()->GetName() ;
387 TString newVersionName(version) ;
388 if (currentVersionName == newVersionName)
390 ::Warning( "Instance", "Files with version %s already open", currentVersionName.Data() ) ;
392 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
397 AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle()) ;
398 if ( strstr(version, AliConfig::GetDefaultEventFolderName()) ) // false in case of merging
400 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
404 ::Error("AliPHOSGetter::Instance", "Failed to create the PHOS Getter object") ;
412 //____________________________________________________________________________
413 AliPHOSGetter * AliPHOSGetter::Instance()
415 // Returns the pointer of the unique instance already defined
417 if(!fgObjGetter && fgDebug)
418 ::Warning("AliPHOSGetter::Instance", "Getter not initialized") ;
424 //____________________________________________________________________________
425 Int_t AliPHOSGetter::MaxEvent() const
427 // returns the number of events in the run (from TE)
429 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
430 return static_cast<Int_t>(rl->GetNumberOfEvents()) ;
433 //____________________________________________________________________________
434 TParticle * AliPHOSGetter::Primary(Int_t index) const
436 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
437 return rl->Stack()->Particle(index) ;
440 //____________________________________________________________________________
441 AliPHOS * AliPHOSGetter:: PHOS() const
443 // returns the PHOS object
444 AliPHOSLoader * loader = 0;
445 static AliPHOSLoader * oldloader = 0;
446 static AliPHOS * phos = 0;
448 loader = PhosLoader();
450 if ( loader != oldloader) {
451 phos = dynamic_cast<AliPHOS*>(loader->GetModulesFolder()->FindObject("PHOS")) ;
456 Warning("PHOS", "PHOS module not found in module folders: %s", PhosLoader()->GetModulesFolder()->GetName() ) ;
462 //____________________________________________________________________________
463 AliPHOSPID * AliPHOSGetter::PID()
465 // Returns pointer to the PID task
467 rv = dynamic_cast<AliPHOSPID *>(PhosLoader()->PIDTask()) ;
470 rv = dynamic_cast<AliPHOSPID *>(PhosLoader()->PIDTask()) ;
475 //____________________________________________________________________________
476 AliPHOSGeometry * AliPHOSGetter::PHOSGeometry() const
478 // Returns PHOS geometry
480 AliPHOSGeometry * rv = 0 ;
482 rv = PHOS()->GetGeometry() ;
486 //____________________________________________________________________________
487 TClonesArray * AliPHOSGetter::Primaries()
489 // creates the Primaries container if needed
492 Info("Primaries", "Creating a new TClonesArray for primaries") ;
493 fPrimaries = new TClonesArray("TParticle", 1000) ;
498 //____________________________________________________________________________
499 void AliPHOSGetter::Print()
501 // Print usefull information about the getter
503 AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle());
504 ::Info( "Print", "gAlice file is %s -- version name is %s", (rl->GetFileName()).Data(), rl->GetEventFolder()->GetName() ) ;
507 //____________________________________________________________________________
508 void AliPHOSGetter::ReadPrimaries()
510 // Read Primaries from Kinematics.root
512 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
514 // gets kine tree from the root file (Kinematics.root)
515 if ( ! rl->TreeK() ) { // load treeK the first time
516 rl->LoadKinematics() ;
519 fNPrimaries = (rl->GetHeader())->GetNtrack();
521 Info( "ReadTreeK", "Found %d particles in event # %d", fNPrimaries, EventNumber() ) ;
524 // first time creates the container
526 fPrimaries->Clear() ;
529 for (index = 0 ; index < fNPrimaries; index++) {
530 new ((*fPrimaries)[index]) TParticle(*(Primary(index)));
534 //____________________________________________________________________________
535 Bool_t AliPHOSGetter::OpenESDFile()
540 fESDFile = TFile::Open(fESDFileName) ;
544 else if (fESDFile->IsOpen()) {
546 fESDFile = TFile::Open(fESDFileName) ;
548 if (!fESDFile->IsOpen())
553 //____________________________________________________________________________
554 void AliPHOSGetter::FitRaw(Bool_t lowGainFlag, TGraph * gLowGain, TGraph * gHighGain, TF1* signalF, Int_t & amp, Double_t & time)
556 // Fits the raw signal time distribution
558 const Int_t kNoiseThreshold = 0 ;
559 Double_t timezero1 = 0., timezero2 = 0., timemax = 0. ;
560 Double_t signal = 0., signalmax = 0. ;
561 Double_t energy = time = 0. ;
564 timezero1 = timezero2 = signalmax = timemax = 0. ;
565 signalF->FixParameter(0, PHOS()->GetRawFormatLowCharge()) ;
566 signalF->FixParameter(1, PHOS()->GetRawFormatLowGain()) ;
568 for (index = 0; index < PHOS()->GetRawFormatTimeBins(); index++) {
569 gLowGain->GetPoint(index, time, signal) ;
570 if (signal > kNoiseThreshold && timezero1 == 0.)
572 if (signal <= kNoiseThreshold && timezero1 > 0. && timezero2 == 0.)
574 if (signal > signalmax) {
579 signalmax /= PHOS()->RawResponseFunctionMax(PHOS()->GetRawFormatLowCharge(),
580 PHOS()->GetRawFormatLowGain()) ;
581 if ( timezero1 + PHOS()->GetRawFormatTimePeak() < PHOS()->GetRawFormatTimeMax() * 0.4 ) { // else its noise
582 signalF->SetParameter(2, signalmax) ;
583 signalF->SetParameter(3, timezero1) ;
584 gLowGain->Fit(signalF, "QRON", "", 0., timezero2); //, "QRON") ;
585 energy = signalF->GetParameter(2) ;
586 time = signalF->GetMaximumX() - PHOS()->GetRawFormatTimePeak() - PHOS()->GetRawFormatTimeTrigger() ;
589 timezero1 = timezero2 = signalmax = timemax = 0. ;
590 signalF->FixParameter(0, PHOS()->GetRawFormatHighCharge()) ;
591 signalF->FixParameter(1, PHOS()->GetRawFormatHighGain()) ;
593 for (index = 0; index < PHOS()->GetRawFormatTimeBins(); index++) {
594 gHighGain->GetPoint(index, time, signal) ;
595 if (signal > kNoiseThreshold && timezero1 == 0.)
597 if (signal <= kNoiseThreshold && timezero1 > 0. && timezero2 == 0.)
599 if (signal > signalmax) {
604 signalmax /= PHOS()->RawResponseFunctionMax(PHOS()->GetRawFormatHighCharge(),
605 PHOS()->GetRawFormatHighGain()) ;;
606 if ( timezero1 + PHOS()->GetRawFormatTimePeak() < PHOS()->GetRawFormatTimeMax() * 0.4 ) { // else its noise
607 signalF->SetParameter(2, signalmax) ;
608 signalF->SetParameter(3, timezero1) ;
609 gHighGain->Fit(signalF, "QRON", "", 0., timezero2) ;
610 energy = signalF->GetParameter(2) ;
611 time = signalF->GetMaximumX() - PHOS()->GetRawFormatTimePeak() - PHOS()->GetRawFormatTimeTrigger() ;
615 if (time == 0. && energy == 0.)
618 AliPHOSDigitizer * digitizer = Digitizer() ;
619 amp = static_cast<Int_t>( (energy - digitizer->GetEMCpedestal()) / digitizer->GetEMCchannel() + 0.5 ) ;
623 //____________________________________________________________________________
624 Int_t AliPHOSGetter::ReadRaw(AliRawReader *rawReader)
626 // reads the raw format data, converts it into digits format and store digits in Digits()
629 AliPHOSRawStream in(rawReader);
631 Bool_t first = kTRUE ;
633 TF1 * signalF = new TF1("signal", AliPHOS::RawResponseFunction, 0, PHOS()->GetRawFormatTimeMax(), 4);
634 signalF->SetParNames("Charge", "Gain", "Amplitude", "TimeZero") ;
637 Bool_t lowGainFlag = kFALSE ;
639 TClonesArray * digits = Digits() ;
645 TGraph * gLowGain = new TGraph(PHOS()->GetRawFormatTimeBins()) ;
646 TGraph * gHighGain= new TGraph(PHOS()->GetRawFormatTimeBins()) ;
648 while ( in.Next() ) { // PHOS entries loop
649 if ( (in.IsNewRow() || in.IsNewColumn() || in.IsNewModule()) ) {
651 FitRaw(lowGainFlag, gLowGain, gHighGain, signalF, amp, time) ;
653 new((*digits)[idigit]) AliPHOSDigit( -1, id, amp, time) ;
657 for (index = 0; index < PHOS()->GetRawFormatTimeBins(); index++) {
658 gLowGain->SetPoint(index, index * PHOS()->GetRawFormatTimeMax() / PHOS()->GetRawFormatTimeBins(), 0) ;
659 gHighGain->SetPoint(index, index * PHOS()->GetRawFormatTimeMax() / PHOS()->GetRawFormatTimeBins(), 0) ;
663 relId[0] = in.GetModule() ;
664 if ( relId[0] >= PHOS()->GetRawFormatLowGainOffset() ) {
665 relId[0] -= PHOS()->GetRawFormatLowGainOffset() ;
666 lowGainFlag = kTRUE ;
668 lowGainFlag = kFALSE ;
670 relId[2] = in.GetRow() ;
671 relId[3] = in.GetColumn() ;
672 PHOSGeometry()->RelToAbsNumbering(relId, id) ;
675 gLowGain->SetPoint(in.GetTime(),
676 in.GetTime()* PHOS()->GetRawFormatTimeMax() / PHOS()->GetRawFormatTimeBins(),
679 gHighGain->SetPoint(in.GetTime(),
680 in.GetTime() * PHOS()->GetRawFormatTimeMax() / PHOS()->GetRawFormatTimeBins(),
683 } // PHOS entries loop
685 FitRaw(lowGainFlag, gLowGain, gHighGain, signalF, amp, time) ;
687 new((*digits)[idigit]) AliPHOSDigit( -1, id, amp, time) ;
693 delete gLowGain, gHighGain ;
695 return digits->GetEntriesFast() ;
698 // TClonesArray * digits = Digits() ;
700 // Int_t idigit = 0 ;
702 // while ( in.Next() ) { // PHOS entries loop
704 // Int_t amp = in.GetSignal() ;
705 // Double_t time = in.GetTime() ;
706 // Int_t relId[4], id ;
708 // relId[0] = in.GetModule() ;
709 // if ( relId[0] >= PHOS()->GetRawFormatLowGainOffset() ) {
710 // relId[0] -= PHOS()->GetRawFormatLowGainOffset() ;
713 // relId[2] = in.GetRow() ;
714 // relId[3] = in.GetColumn() ;
715 // PHOSGeometry()->RelToAbsNumbering(relId, id) ;
717 // if (amp > 0 && id >=0 ) {
718 // new((*digits)[idigit]) AliPHOSDigit( -1, id, amp, time) ;
722 // } // PHOS entries loop
726 // return digits->GetEntriesFast() ;
728 //____________________________________________________________________________
729 Int_t AliPHOSGetter::ReadTreeD()
733 PhosLoader()->CleanDigits() ;
734 PhosLoader()->LoadDigits("UPDATE") ;
735 PhosLoader()->LoadDigitizer("UPDATE") ;
736 return Digits()->GetEntries() ;
739 //____________________________________________________________________________
740 Int_t AliPHOSGetter::ReadTreeH()
743 PhosLoader()->CleanHits() ;
744 // gets TreeH from the root file (PHOS.Hit.root)
745 //if ( !IsLoaded("H") ) {
746 PhosLoader()->LoadHits("UPDATE") ;
749 return Hits()->GetEntries() ;
752 //____________________________________________________________________________
753 Int_t AliPHOSGetter::ReadTreeR()
755 // Read the RecPoints
757 PhosLoader()->CleanRecPoints() ;
758 // gets TreeR from the root file (PHOS.RecPoints.root)
759 //if ( !IsLoaded("R") ) {
760 PhosLoader()->LoadRecPoints("UPDATE") ;
761 PhosLoader()->LoadClusterizer("UPDATE") ;
765 return EmcRecPoints()->GetEntries() ;
768 //____________________________________________________________________________
769 Int_t AliPHOSGetter::ReadTreeT()
771 // Read the TrackSegments
773 PhosLoader()->CleanTracks() ;
774 // gets TreeT from the root file (PHOS.TrackSegments.root)
775 //if ( !IsLoaded("T") ) {
776 PhosLoader()->LoadTracks("UPDATE") ;
777 PhosLoader()->LoadTrackSegmentMaker("UPDATE") ;
781 return TrackSegments()->GetEntries() ;
783 //____________________________________________________________________________
784 Int_t AliPHOSGetter::ReadTreeP()
786 // Read the RecParticles
788 PhosLoader()->CleanRecParticles() ;
790 // gets TreeT from the root file (PHOS.TrackSegments.root)
791 // if ( !IsLoaded("P") ) {
792 PhosLoader()->LoadRecParticles("UPDATE") ;
793 PhosLoader()->LoadPID("UPDATE") ;
797 return RecParticles()->GetEntries() ;
799 //____________________________________________________________________________
800 Int_t AliPHOSGetter::ReadTreeS()
804 PhosLoader()->CleanSDigits() ;
805 // gets TreeS from the root file (PHOS.SDigits.root)
806 //if ( !IsLoaded("S") ) {
807 PhosLoader()->LoadSDigits("READ") ;
808 PhosLoader()->LoadSDigitizer("READ") ;
812 return SDigits()->GetEntries() ;
815 //____________________________________________________________________________
816 Int_t AliPHOSGetter::ReadTreeE(Int_t event)
820 // gets esdTree from the root file (AliESDs.root)
822 if ( !OpenESDFile() )
825 fESDTree = static_cast<TTree*>(fESDFile->Get("esdTree")) ;
829 Error("ReadTreeE", "no ESD tree found");
832 fESDTree->SetBranchAddress("ESD", &fESD);
833 fESDTree->GetEvent(event);
838 //____________________________________________________________________________
839 TClonesArray * AliPHOSGetter::SDigits()
841 // asks the Loader to return the Digits container
843 TClonesArray * rv = 0 ;
845 rv = PhosLoader()->SDigits() ;
847 PhosLoader()->MakeSDigitsArray() ;
848 rv = PhosLoader()->SDigits() ;
853 //____________________________________________________________________________
854 AliPHOSSDigitizer * AliPHOSGetter::SDigitizer()
856 // Returns pointer to the SDigitizer task
857 AliPHOSSDigitizer * rv ;
858 rv = dynamic_cast<AliPHOSSDigitizer *>(PhosLoader()->SDigitizer()) ;
861 rv = dynamic_cast<AliPHOSSDigitizer *>(PhosLoader()->SDigitizer()) ;
866 //____________________________________________________________________________
867 TParticle * AliPHOSGetter::Secondary(const TParticle* p, Int_t index) const
869 // Return first (index=1) or second (index=2) secondary particle of primary particle p
877 Int_t daughterIndex = p->GetDaughter(index-1) ;
878 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
879 return rl->GetAliRun()->GetMCApp()->Particle(daughterIndex) ;
885 //____________________________________________________________________________
886 void AliPHOSGetter::Track(Int_t itrack)
888 // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
890 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
892 if( !TreeH() ) // load treeH the first time
895 // first time create the container
896 TClonesArray * hits = Hits() ;
900 TBranch * phosbranch = dynamic_cast<TBranch*>(TreeH()->GetBranch("PHOS")) ;
901 phosbranch->SetAddress(&hits) ;
902 phosbranch->GetEntry(itrack) ;
905 //____________________________________________________________________________
906 TTree * AliPHOSGetter::TreeD() const
908 // Returns pointer to the Digits Tree
910 rv = PhosLoader()->TreeD() ;
912 PhosLoader()->MakeTree("D");
913 rv = PhosLoader()->TreeD() ;
919 //____________________________________________________________________________
920 TTree * AliPHOSGetter::TreeH() const
922 // Returns pointer to the Hits Tree
924 rv = PhosLoader()->TreeH() ;
926 PhosLoader()->MakeTree("H");
927 rv = PhosLoader()->TreeH() ;
933 //____________________________________________________________________________
934 TTree * AliPHOSGetter::TreeR() const
936 // Returns pointer to the RecPoints Tree
938 rv = PhosLoader()->TreeR() ;
940 PhosLoader()->MakeTree("R");
941 rv = PhosLoader()->TreeR() ;
947 //____________________________________________________________________________
948 TTree * AliPHOSGetter::TreeT() const
950 // Returns pointer to the TrackSegments Tree
952 rv = PhosLoader()->TreeT() ;
954 PhosLoader()->MakeTree("T");
955 rv = PhosLoader()->TreeT() ;
960 //____________________________________________________________________________
961 TTree * AliPHOSGetter::TreeP() const
963 // Returns pointer to the RecParticles Tree
965 rv = PhosLoader()->TreeP() ;
967 PhosLoader()->MakeTree("P");
968 rv = PhosLoader()->TreeP() ;
974 //____________________________________________________________________________
975 TTree * AliPHOSGetter::TreeS() const
977 // Returns pointer to the SDigits Tree
979 rv = PhosLoader()->TreeS() ;
981 PhosLoader()->MakeTree("S");
982 rv = PhosLoader()->TreeS() ;
988 //____________________________________________________________________________
989 Bool_t AliPHOSGetter::VersionExists(TString & opt) const
991 // checks if the version with the present name already exists in the same directory
995 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
996 TString version( rl->GetEventFolder()->GetName() ) ;
1000 if ( opt == "sdigits") {
1001 // add the version name to the root file name
1002 TString fileName( PhosLoader()->GetSDigitsFileName() ) ;
1003 if (version != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
1004 fileName = fileName.ReplaceAll(".root", "") + "_" + version + ".root" ;
1005 if ( !(gSystem->AccessPathName(fileName)) ) {
1006 Warning("VersionExists", "The file %s already exists", fileName.Data()) ;
1009 PhosLoader()->SetSDigitsFileName(fileName) ;
1012 if ( opt == "digits") {
1013 // add the version name to the root file name
1014 TString fileName( PhosLoader()->GetDigitsFileName() ) ;
1015 if (version != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
1016 fileName = fileName.ReplaceAll(".root", "") + "_" + version + ".root" ;
1017 if ( !(gSystem->AccessPathName(fileName)) ) {
1018 Warning("VersionExists", "The file %s already exists", fileName.Data()) ;
1027 //____________________________________________________________________________
1028 UShort_t AliPHOSGetter::EventPattern(void) const
1030 // Return the pattern (trigger bit register) of the beam-test event
1032 return fBTE->GetPattern() ;
1036 //____________________________________________________________________________
1037 Float_t AliPHOSGetter::BeamEnergy(void) const
1039 // Return the beam energy of the beam-test event
1041 return fBTE->GetBeamEnergy() ;