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"
74 ClassImp(AliPHOSGetter)
76 AliPHOSGetter * AliPHOSGetter::fgObjGetter = 0 ;
77 AliPHOSLoader * AliPHOSGetter::fgPhosLoader = 0;
78 AliPHOSCalibData* AliPHOSGetter::fgCalibData = 0;
79 Int_t AliPHOSGetter::fgDebug = 0;
81 // TFile * AliPHOSGetter::fgFile = 0 ;
83 AliPHOSGetter::AliPHOSGetter() :
95 // ctor: this is a singleton, the ctor should never be called but cint needs it as public
96 Fatal("ctor", "AliPHOSGetter is a singleton default ctor not callable") ;
100 //____________________________________________________________________________
101 AliPHOSGetter::AliPHOSGetter(const char* headerFile, const char* version, Option_t * openingOption) :
113 // ctor only called by Instance()
115 AliRunLoader* rl = AliRunLoader::GetRunLoader(version) ;
117 rl = AliRunLoader::Open(headerFile, version, openingOption);
119 Fatal("AliPHOSGetter", "Could not find the Run Loader for %s - %s",headerFile, version) ;
122 if (rl->GetAliRun() == 0x0) {
124 gAlice = rl->GetAliRun(); // should be removed
128 fgPhosLoader = dynamic_cast<AliPHOSLoader*>(rl->GetLoader("PHOSLoader"));
130 Error("AliPHOSGetter", "Could not find PHOSLoader") ;
132 fgPhosLoader->SetTitle(version);
134 // initialize data members
138 fLoadingStatus = "" ;
140 fESDFileName = rl->GetFileName() ; // this should be the galice.root file
141 fESDFileName.ReplaceAll("galice.root", "AliESDs.root") ;
145 fRawDigits = kFALSE ;
149 AliPHOSGetter::AliPHOSGetter(const AliPHOSGetter & obj) :
162 // cpy ctor requested by Coding Convention
163 Fatal("cpy ctor", "not implemented") ;
166 //____________________________________________________________________________
167 AliPHOSGetter::AliPHOSGetter(Int_t /*i*/) :
179 // special constructor for onflight
183 //____________________________________________________________________________
184 AliPHOSGetter::~AliPHOSGetter()
188 delete fgPhosLoader ;
196 fPrimaries->Delete() ;
207 //____________________________________________________________________________
208 void AliPHOSGetter::Reset()
210 // resets things in case the getter is called consecutively with different files
211 // the PHOS Loader is already deleted by the Run Loader
214 fPrimaries->Delete() ;
221 //____________________________________________________________________________
222 AliPHOSClusterizer * AliPHOSGetter::Clusterizer()
224 // Returns pointer to the Clusterizer task
225 AliPHOSClusterizer * rv ;
226 rv = dynamic_cast<AliPHOSClusterizer *>(PhosLoader()->Reconstructioner()) ;
229 rv = dynamic_cast<AliPHOSClusterizer*>(PhosLoader()->Reconstructioner()) ;
234 //____________________________________________________________________________
235 TObjArray * AliPHOSGetter::CpvRecPoints() const
237 // asks the Loader to return the CPV RecPoints container
241 rv = PhosLoader()->CpvRecPoints() ;
243 PhosLoader()->MakeRecPointsArray() ;
244 rv = PhosLoader()->CpvRecPoints() ;
249 //____________________________________________________________________________
250 TClonesArray * AliPHOSGetter::Digits() const
252 // asks the Loader to return the Digits container
254 TClonesArray * rv = 0 ;
255 rv = PhosLoader()->Digits() ;
258 PhosLoader()->MakeDigitsArray() ;
259 rv = PhosLoader()->Digits() ;
264 //____________________________________________________________________________
265 AliPHOSDigitizer * AliPHOSGetter::Digitizer()
267 // Returns pointer to the Digitizer task
268 AliPHOSDigitizer * rv ;
269 rv = dynamic_cast<AliPHOSDigitizer *>(PhosLoader()->Digitizer()) ;
272 rv = dynamic_cast<AliPHOSDigitizer *>(PhosLoader()->Digitizer()) ;
278 //____________________________________________________________________________
279 TObjArray * AliPHOSGetter::EmcRecPoints() const
281 // asks the Loader to return the EMC RecPoints container
285 rv = PhosLoader()->EmcRecPoints() ;
287 PhosLoader()->MakeRecPointsArray() ;
288 rv = PhosLoader()->EmcRecPoints() ;
293 //____________________________________________________________________________
294 TClonesArray * AliPHOSGetter::TrackSegments() const
296 // asks the Loader to return the TrackSegments container
298 TClonesArray * rv = 0 ;
300 rv = PhosLoader()->TrackSegments() ;
302 PhosLoader()->MakeTrackSegmentsArray() ;
303 rv = PhosLoader()->TrackSegments() ;
308 //____________________________________________________________________________
309 AliPHOSTrackSegmentMaker * AliPHOSGetter::TrackSegmentMaker()
311 // Returns pointer to the TrackSegmentMaker task
312 AliPHOSTrackSegmentMaker * rv ;
313 rv = dynamic_cast<AliPHOSTrackSegmentMaker *>(PhosLoader()->TrackSegmentMaker()) ;
316 rv = dynamic_cast<AliPHOSTrackSegmentMaker *>(PhosLoader()->TrackSegmentMaker()) ;
321 //____________________________________________________________________________
322 TClonesArray * AliPHOSGetter::RecParticles() const
324 // asks the Loader to return the TrackSegments container
326 TClonesArray * rv = 0 ;
328 rv = PhosLoader()->RecParticles() ;
330 PhosLoader()->MakeRecParticlesArray() ;
331 rv = PhosLoader()->RecParticles() ;
335 //____________________________________________________________________________
336 void AliPHOSGetter::Event(Int_t event, const char* opt)
338 // Reads the content of all Tree's S, D and R
340 // if ( event >= MaxEvent() ) {
341 // Error("Event", "%d not found in TreeE !", event) ;
345 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
347 // // checks if we are dealing with test-beam data
348 // TBranch * btb = rl->TreeE()->GetBranch("AliPHOSBeamTestEvent") ;
351 // fBTE = new AliPHOSBeamTestEvent() ;
352 // btb->SetAddress(&fBTE) ;
353 // btb->GetEntry(event) ;
362 // Loads the type of object(s) requested
364 rl->GetEvent(event) ;
366 if(strstr(opt,"X") || (strcmp(opt,"")==0)){
370 if(strstr(opt,"H") ){
374 if(strstr(opt,"S") ){
378 if(strstr(opt,"D") ){
382 if(strstr(opt,"R") ){
386 if( strstr(opt,"T") ){
390 if( strstr(opt,"P") ){
394 if( strstr(opt,"E") ){
401 //____________________________________________________________________________
402 void AliPHOSGetter::Event(AliRawReader *rawReader, const char* opt, Bool_t isOldRCUFormat)
404 // Reads the raw event from rawReader
405 // isOldRCUFormat defines whenever to assume
406 // the old RCU format or not
408 if( strstr(opt,"W") ){
409 rawReader->NextEvent();
410 ReadRaw(rawReader,isOldRCUFormat) ;
416 //____________________________________________________________________________
417 Int_t AliPHOSGetter::EventNumber() const
419 // return the current event number
420 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
421 return static_cast<Int_t>(rl->GetEventNumber()) ;
424 //____________________________________________________________________________
425 TClonesArray * AliPHOSGetter::Hits() const
427 // asks the loader to return the Hits container
429 TClonesArray * rv = 0 ;
431 rv = PhosLoader()->Hits() ;
433 PhosLoader()->LoadHits("read");
434 rv = PhosLoader()->Hits() ;
439 //____________________________________________________________________________
440 AliPHOSGetter * AliPHOSGetter::Instance(const char* alirunFileName, const char* version, Option_t * openingOption)
442 // Creates and returns the pointer of the unique instance
443 // Must be called only when the environment has changed
445 if(!fgObjGetter){ // first time the getter is called
446 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
448 else { // the getter has been called previously
449 AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle());
450 if ( rl->GetFileName() == alirunFileName ) {// the alirunFile has the same name
451 // check if the file is already open
452 TFile * galiceFile = dynamic_cast<TFile *>(gROOT->FindObject(rl->GetFileName()) ) ;
455 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
457 else { // the file is already open check the version name
458 TString currentVersionName = rl->GetEventFolder()->GetName() ;
459 TString newVersionName(version) ;
460 if (currentVersionName == newVersionName)
462 ::Warning( "Instance", "Files with version %s already open", currentVersionName.Data() ) ;
464 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
469 rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle()) ;
470 if ( strstr(version, AliConfig::GetDefaultEventFolderName()) ) // false in case of merging
472 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
476 ::Error("AliPHOSGetter::Instance", "Failed to create the PHOS Getter object") ;
484 //____________________________________________________________________________
485 AliPHOSGetter * AliPHOSGetter::Instance()
487 // Returns the pointer of the unique instance already defined
489 if(!fgObjGetter && fgDebug)
490 ::Warning("AliPHOSGetter::Instance", "Getter not initialized") ;
496 //____________________________________________________________________________
497 Int_t AliPHOSGetter::MaxEvent() const
499 // returns the number of events in the run (from TE)
501 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
502 return static_cast<Int_t>(rl->GetNumberOfEvents()) ;
505 //____________________________________________________________________________
506 TParticle * AliPHOSGetter::Primary(Int_t index) const
508 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
509 return rl->Stack()->Particle(index) ;
512 //____________________________________________________________________________
513 AliPHOS * AliPHOSGetter:: PHOS() const
515 // returns the PHOS object
516 AliPHOSLoader * loader = 0;
517 static AliPHOSLoader * oldloader = 0;
518 static AliPHOS * phos = 0;
520 loader = PhosLoader();
522 if ( loader != oldloader) {
523 phos = dynamic_cast<AliPHOS*>(loader->GetModulesFolder()->FindObject("PHOS")) ;
528 Warning("PHOS", "PHOS module not found in module folders: %s", PhosLoader()->GetModulesFolder()->GetName() ) ;
534 //____________________________________________________________________________
535 AliPHOSPID * AliPHOSGetter::PID()
537 // Returns pointer to the PID task
539 rv = dynamic_cast<AliPHOSPID *>(PhosLoader()->PIDTask()) ;
542 rv = dynamic_cast<AliPHOSPID *>(PhosLoader()->PIDTask()) ;
547 //____________________________________________________________________________
548 AliPHOSGeometry * AliPHOSGetter::PHOSGeometry() const
550 // Returns PHOS geometry
552 AliPHOSGeometry * rv = 0 ;
554 rv = PHOS()->GetGeometry() ;
556 rv = AliPHOSGeometry::GetInstance();
558 AliError("Could not find PHOS geometry! Loading the default one !");
559 rv = AliPHOSGeometry::GetInstance("IHEP","");
565 //____________________________________________________________________________
566 TClonesArray * AliPHOSGetter::Primaries()
568 // creates the Primaries container if needed
571 Info("Primaries", "Creating a new TClonesArray for primaries") ;
572 fPrimaries = new TClonesArray("TParticle", 1000) ;
577 //____________________________________________________________________________
578 void AliPHOSGetter::Print()
580 // Print usefull information about the getter
582 AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle());
583 ::Info( "Print", "gAlice file is %s -- version name is %s", (rl->GetFileName()).Data(), rl->GetEventFolder()->GetName() ) ;
586 //____________________________________________________________________________
587 void AliPHOSGetter::ReadPrimaries()
589 // Read Primaries from Kinematics.root
591 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
593 // gets kine tree from the root file (Kinematics.root)
594 if ( ! rl->TreeK() ) { // load treeK the first time
595 rl->LoadKinematics() ;
598 fNPrimaries = (rl->GetHeader())->GetNtrack();
600 Info( "ReadTreeK", "Found %d particles in event # %d", fNPrimaries, EventNumber() ) ;
603 // first time creates the container
605 fPrimaries->Clear() ;
608 for (index = 0 ; index < fNPrimaries; index++) {
609 new ((*fPrimaries)[index]) TParticle(*(Primary(index)));
613 //____________________________________________________________________________
614 Bool_t AliPHOSGetter::OpenESDFile()
619 fESDFile = TFile::Open(fESDFileName) ;
623 else if (fESDFile->IsOpen()) {
625 fESDFile = TFile::Open(fESDFileName) ;
627 if (!fESDFile->IsOpen())
632 //____________________________________________________________________________
633 void AliPHOSGetter::FitRaw(Bool_t lowGainFlag, TGraph * gLowGain, TGraph * gHighGain, TF1* signalF, Double_t & energy, Double_t & time) const
635 // Fits the raw signal time distribution
637 const Int_t kNoiseThreshold = 0 ;
638 Double_t timezero1 = 0., timezero2 = 0., timemax = 0. ;
639 Double_t signal = 0., signalmax = 0. ;
643 // Create a shaper pulse object which contains all the shaper parameters
644 AliPHOSPulseGenerator pulse;
647 timezero1 = timezero2 = signalmax = timemax = 0. ;
648 signalF->FixParameter(0, pulse.GetRawFormatLowCharge()) ;
649 signalF->FixParameter(1, pulse.GetRawFormatLowGain()) ;
651 for (index = 0; index < pulse.GetRawFormatTimeBins(); index++) {
652 gLowGain->GetPoint(index, time, signal) ;
653 if (signal > kNoiseThreshold && timezero1 == 0.)
655 if (signal <= kNoiseThreshold && timezero1 > 0. && timezero2 == 0.)
657 if (signal > signalmax) {
663 pulse.RawResponseFunctionMax(pulse.GetRawFormatLowCharge(),
664 pulse.GetRawFormatLowGain()) ;
665 if ( timezero1 + pulse.GetRawFormatTimePeak() < pulse.GetRawFormatTimeMax() * 0.4 ) { // else its noise
666 signalF->SetParameter(2, signalmax) ;
667 signalF->SetParameter(3, timezero1) ;
668 gLowGain->Fit(signalF, "QRO", "", 0., timezero2); //, "QRON") ;
669 energy = signalF->GetParameter(2) ;
670 time = signalF->GetMaximumX() - pulse.GetRawFormatTimePeak() - pulse.GetRawFormatTimeTrigger() ;
673 timezero1 = timezero2 = signalmax = timemax = 0. ;
674 signalF->FixParameter(0, pulse.GetRawFormatHighCharge()) ;
675 signalF->FixParameter(1, pulse.GetRawFormatHighGain()) ;
677 for (index = 0; index < pulse.GetRawFormatTimeBins(); index++) {
678 gHighGain->GetPoint(index, time, signal) ;
679 if (signal > kNoiseThreshold && timezero1 == 0.)
681 if (signal <= kNoiseThreshold && timezero1 > 0. && timezero2 == 0.)
683 if (signal > signalmax) {
688 signalmax /= pulse.RawResponseFunctionMax(pulse.GetRawFormatHighCharge(),
689 pulse.GetRawFormatHighGain()) ;;
690 if ( timezero1 + pulse.GetRawFormatTimePeak() < pulse.GetRawFormatTimeMax() * 0.4 ) { // else its noise
691 signalF->SetParameter(2, signalmax) ;
692 signalF->SetParameter(3, timezero1) ;
693 gHighGain->Fit(signalF, "QRO", "", 0., timezero2) ;
694 energy = signalF->GetParameter(2) ;
695 time = signalF->GetMaximumX() - pulse.GetRawFormatTimePeak() - pulse.GetRawFormatTimeTrigger() ;
698 if (time == 0) energy = 0 ;
701 //____________________________________________________________________________
702 Int_t AliPHOSGetter::CalibrateRaw(Double_t energy, Int_t *relId)
704 // Convert energy into digitized amplitude for a cell relId
705 // It is a user responsilibity to open CDB and set
706 // AliPHOSCalibData object by the following operators:
708 // AliCDBLocal *loc = new AliCDBLocal("deCalibDB");
709 // AliPHOSCalibData* clb = (AliPHOSCalibData*)AliCDBStorage::Instance()
710 // ->Get(path_to_calibdata,run_number);
711 // AliPHOSGetter* gime = AliPHOSGetter::Instance("galice.root");
712 // gime->SetCalibData(clb);
714 if (CalibData() == 0)
715 Warning("CalibrateRaw","Calibration DB is not initiated!");
717 Int_t module = relId[0];
718 Int_t column = relId[3];
719 Int_t row = relId[2];
721 Float_t gainFactor = 0.0015; // width of one Emc ADC channel in GeV
722 Float_t pedestal = 0.005; // Emc pedestals
725 gainFactor = CalibData()->GetADCchannelEmc (module,column,row);
726 pedestal = CalibData()->GetADCpedestalEmc(module,column,row);
729 Int_t amp = static_cast<Int_t>( (energy - pedestal) / gainFactor + 0.5 ) ;
732 //____________________________________________________________________________
733 Int_t AliPHOSGetter::ReadRaw(AliRawReader *rawReader,Bool_t isOldRCUFormat)
735 // reads the raw format data, converts it into digits format and store digits in Digits()
737 // isOldRCUFormat = kTRUE in case of the old RCU
738 // format used in the raw data readout.
739 // Reimplemented by Boris Polichtchouk (Jul 2006)
740 // to make it working with the Jul-Aug 2006 beam test data.
742 //Create raw decoder.
744 AliPHOSRawDecoder dc(rawReader);
745 dc.SetOldRCUFormat(isOldRCUFormat);
746 dc.SubtractPedestals(kTRUE);
748 TClonesArray * digits = Digits() ;
749 AliPHOSRawDigiProducer pr;
750 pr.MakeDigits(digits,&dc);
760 for(Int_t iDigit=0; iDigit<digits->GetEntries(); iDigit++) {
761 AliPHOSDigit* digit = (AliPHOSDigit*)digits->At(iDigit);
762 if(digit->GetEnergy()>eMax) {
763 PHOSGeometry()->AbsToRelNumbering(digit->GetId(),relId);
764 eMax=digit->GetEnergy();
771 AliDebug(1,Form("Digit with max. energy: modMax %d colMax %d rowMax %d eMax %f\n\n",
772 modMax,colMax,rowMax,eMax));
774 return digits->GetEntriesFast() ;
777 //____________________________________________________________________________
778 Int_t AliPHOSGetter::ReadTreeD() const
782 PhosLoader()->CleanDigits() ;
783 PhosLoader()->LoadDigits("UPDATE") ;
784 PhosLoader()->LoadDigitizer("UPDATE") ;
785 return Digits()->GetEntries() ;
788 //____________________________________________________________________________
789 Int_t AliPHOSGetter::ReadTreeH() const
792 PhosLoader()->CleanHits() ;
793 // gets TreeH from the root file (PHOS.Hit.root)
794 //if ( !IsLoaded("H") ) {
795 PhosLoader()->LoadHits("UPDATE") ;
798 return Hits()->GetEntries() ;
801 //____________________________________________________________________________
802 Int_t AliPHOSGetter::ReadTreeR() const
804 // Read the RecPoints
806 PhosLoader()->CleanRecPoints() ;
807 // gets TreeR from the root file (PHOS.RecPoints.root)
808 //if ( !IsLoaded("R") ) {
809 PhosLoader()->LoadRecPoints("UPDATE") ;
810 PhosLoader()->LoadClusterizer("UPDATE") ;
814 return EmcRecPoints()->GetEntries() ;
817 //____________________________________________________________________________
818 Int_t AliPHOSGetter::ReadTreeT() const
820 // Read the TrackSegments
822 PhosLoader()->CleanTracks() ;
823 // gets TreeT from the root file (PHOS.TrackSegments.root)
824 //if ( !IsLoaded("T") ) {
825 PhosLoader()->LoadTracks("UPDATE") ;
826 PhosLoader()->LoadTrackSegmentMaker("UPDATE") ;
830 return TrackSegments()->GetEntries() ;
832 //____________________________________________________________________________
833 Int_t AliPHOSGetter::ReadTreeP() const
835 // Read the RecParticles
837 PhosLoader()->CleanRecParticles() ;
839 // gets TreeT from the root file (PHOS.TrackSegments.root)
840 // if ( !IsLoaded("P") ) {
841 PhosLoader()->LoadRecParticles("UPDATE") ;
842 PhosLoader()->LoadPID("UPDATE") ;
846 return RecParticles()->GetEntries() ;
848 //____________________________________________________________________________
849 Int_t AliPHOSGetter::ReadTreeS() const
853 PhosLoader()->CleanSDigits() ;
854 // gets TreeS from the root file (PHOS.SDigits.root)
855 //if ( !IsLoaded("S") ) {
856 PhosLoader()->LoadSDigits("READ") ;
857 PhosLoader()->LoadSDigitizer("READ") ;
861 return SDigits()->GetEntries() ;
864 //____________________________________________________________________________
865 Int_t AliPHOSGetter::ReadTreeE(Int_t event)
869 // gets esdTree from the root file (AliESDs.root)
871 if ( !OpenESDFile() )
874 fESDTree = static_cast<TTree*>(fESDFile->Get("esdTree")) ;
878 Error("ReadTreeE", "no ESD tree found");
881 fESDTree->SetBranchAddress("ESD", &fESD);
882 fESDTree->GetEvent(event);
887 //____________________________________________________________________________
888 TClonesArray * AliPHOSGetter::SDigits() const
890 // asks the Loader to return the Digits container
892 TClonesArray * rv = 0 ;
894 rv = PhosLoader()->SDigits() ;
896 PhosLoader()->MakeSDigitsArray() ;
897 rv = PhosLoader()->SDigits() ;
902 //____________________________________________________________________________
903 AliPHOSSDigitizer * AliPHOSGetter::SDigitizer()
905 // Returns pointer to the SDigitizer task
906 AliPHOSSDigitizer * rv ;
907 rv = dynamic_cast<AliPHOSSDigitizer *>(PhosLoader()->SDigitizer()) ;
910 rv = dynamic_cast<AliPHOSSDigitizer *>(PhosLoader()->SDigitizer()) ;
915 //____________________________________________________________________________
916 TParticle * AliPHOSGetter::Secondary(const TParticle* p, Int_t index) const
918 // Return first (index=1) or second (index=2) secondary particle of primary particle p
926 Int_t daughterIndex = p->GetDaughter(index-1) ;
927 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
928 return rl->GetAliRun()->GetMCApp()->Particle(daughterIndex) ;
934 //____________________________________________________________________________
935 void AliPHOSGetter::Track(Int_t itrack)
937 // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
939 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
941 if( !TreeH() ) // load treeH the first time
944 // first time create the container
945 TClonesArray * hits = Hits() ;
949 TBranch * phosbranch = dynamic_cast<TBranch*>(TreeH()->GetBranch("PHOS")) ;
950 phosbranch->SetAddress(&hits) ;
951 phosbranch->GetEntry(itrack) ;
954 //____________________________________________________________________________
955 TTree * AliPHOSGetter::TreeD() const
957 // Returns pointer to the Digits Tree
959 rv = PhosLoader()->TreeD() ;
961 PhosLoader()->MakeTree("D");
962 rv = PhosLoader()->TreeD() ;
968 //____________________________________________________________________________
969 TTree * AliPHOSGetter::TreeH() const
971 // Returns pointer to the Hits Tree
973 rv = PhosLoader()->TreeH() ;
975 PhosLoader()->MakeTree("H");
976 rv = PhosLoader()->TreeH() ;
982 //____________________________________________________________________________
983 TTree * AliPHOSGetter::TreeR() const
985 // Returns pointer to the RecPoints Tree
987 rv = PhosLoader()->TreeR() ;
989 PhosLoader()->MakeTree("R");
990 rv = PhosLoader()->TreeR() ;
996 //____________________________________________________________________________
997 TTree * AliPHOSGetter::TreeT() const
999 // Returns pointer to the TrackSegments Tree
1001 rv = PhosLoader()->TreeT() ;
1003 PhosLoader()->MakeTree("T");
1004 rv = PhosLoader()->TreeT() ;
1009 //____________________________________________________________________________
1010 TTree * AliPHOSGetter::TreeP() const
1012 // Returns pointer to the RecParticles Tree
1014 rv = PhosLoader()->TreeP() ;
1016 PhosLoader()->MakeTree("P");
1017 rv = PhosLoader()->TreeP() ;
1023 //____________________________________________________________________________
1024 TTree * AliPHOSGetter::TreeS() const
1026 // Returns pointer to the SDigits Tree
1028 rv = PhosLoader()->TreeS() ;
1030 PhosLoader()->MakeTree("S");
1031 rv = PhosLoader()->TreeS() ;
1037 //____________________________________________________________________________
1038 Bool_t AliPHOSGetter::VersionExists(TString & opt) const
1040 // checks if the version with the present name already exists in the same directory
1042 Bool_t rv = kFALSE ;
1044 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
1045 TString version( rl->GetEventFolder()->GetName() ) ;
1049 if ( opt == "sdigits") {
1050 // add the version name to the root file name
1051 TString fileName( PhosLoader()->GetSDigitsFileName() ) ;
1052 if (version != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
1053 fileName = fileName.ReplaceAll(".root", "") + "_" + version + ".root" ;
1054 if ( !(gSystem->AccessPathName(fileName)) ) {
1055 Warning("VersionExists", "The file %s already exists", fileName.Data()) ;
1058 PhosLoader()->SetSDigitsFileName(fileName) ;
1061 if ( opt == "digits") {
1062 // add the version name to the root file name
1063 TString fileName( PhosLoader()->GetDigitsFileName() ) ;
1064 if (version != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
1065 fileName = fileName.ReplaceAll(".root", "") + "_" + version + ".root" ;
1066 if ( !(gSystem->AccessPathName(fileName)) ) {
1067 Warning("VersionExists", "The file %s already exists", fileName.Data()) ;
1076 //____________________________________________________________________________
1077 UShort_t AliPHOSGetter::EventPattern(void) const
1079 // Return the pattern (trigger bit register) of the beam-test event
1081 return fBTE->GetPattern() ;
1085 //____________________________________________________________________________
1086 Float_t AliPHOSGetter::BeamEnergy(void) const
1088 // Return the beam energy of the beam-test event
1090 return fBTE->GetBeamEnergy() ;
1094 //____________________________________________________________________________
1096 AliPHOSCalibData* AliPHOSGetter::CalibData()
1098 // Check if the instance of AliPHOSCalibData exists, and return it