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 "AliRunLoader.h"
65 #include "AliPHOSRawStream.h"
66 #include "AliRawReaderFile.h"
68 #include "AliCDBLocal.h"
69 #include "AliCDBStorage.h"
70 #include "AliCDBManager.h"
72 ClassImp(AliPHOSGetter)
74 AliPHOSGetter * AliPHOSGetter::fgObjGetter = 0 ;
75 AliPHOSLoader * AliPHOSGetter::fgPhosLoader = 0;
76 AliPHOSCalibData* AliPHOSGetter::fgCalibData = 0;
77 Int_t AliPHOSGetter::fgDebug = 0;
79 // TFile * AliPHOSGetter::fgFile = 0 ;
81 AliPHOSGetter::AliPHOSGetter() :
93 // ctor: this is a singleton, the ctor should never be called but cint needs it as public
94 Fatal("ctor", "AliPHOSGetter is a singleton default ctor not callable") ;
98 //____________________________________________________________________________
99 AliPHOSGetter::AliPHOSGetter(const char* headerFile, const char* version, Option_t * openingOption) :
111 // ctor only called by Instance()
113 AliRunLoader* rl = AliRunLoader::GetRunLoader(version) ;
115 rl = AliRunLoader::Open(headerFile, version, openingOption);
117 Fatal("AliPHOSGetter", "Could not find the Run Loader for %s - %s",headerFile, version) ;
120 if (rl->GetAliRun() == 0x0) {
122 gAlice = rl->GetAliRun(); // should be removed
126 fgPhosLoader = dynamic_cast<AliPHOSLoader*>(rl->GetLoader("PHOSLoader"));
128 Error("AliPHOSGetter", "Could not find PHOSLoader") ;
130 fgPhosLoader->SetTitle(version);
132 // initialize data members
136 fLoadingStatus = "" ;
138 fESDFileName = rl->GetFileName() ; // this should be the galice.root file
139 fESDFileName.ReplaceAll("galice.root", "AliESDs.root") ;
143 fRawDigits = kFALSE ;
147 AliPHOSGetter::AliPHOSGetter(const AliPHOSGetter & obj) :
160 // cpy ctor requested by Coding Convention
161 Fatal("cpy ctor", "not implemented") ;
164 //____________________________________________________________________________
165 AliPHOSGetter::AliPHOSGetter(Int_t /*i*/) :
177 // special constructor for onflight
181 //____________________________________________________________________________
182 AliPHOSGetter::~AliPHOSGetter()
186 delete fgPhosLoader ;
194 fPrimaries->Delete() ;
205 //____________________________________________________________________________
206 void AliPHOSGetter::Reset()
208 // resets things in case the getter is called consecutively with different files
209 // the PHOS Loader is already deleted by the Run Loader
212 fPrimaries->Delete() ;
219 //____________________________________________________________________________
220 AliPHOSClusterizer * AliPHOSGetter::Clusterizer()
222 // Returns pointer to the Clusterizer task
223 AliPHOSClusterizer * rv ;
224 rv = dynamic_cast<AliPHOSClusterizer *>(PhosLoader()->Reconstructioner()) ;
227 rv = dynamic_cast<AliPHOSClusterizer*>(PhosLoader()->Reconstructioner()) ;
232 //____________________________________________________________________________
233 TObjArray * AliPHOSGetter::CpvRecPoints() const
235 // asks the Loader to return the CPV RecPoints container
239 rv = PhosLoader()->CpvRecPoints() ;
241 PhosLoader()->MakeRecPointsArray() ;
242 rv = PhosLoader()->CpvRecPoints() ;
247 //____________________________________________________________________________
248 TClonesArray * AliPHOSGetter::Digits() const
250 // asks the Loader to return the Digits container
252 TClonesArray * rv = 0 ;
253 rv = PhosLoader()->Digits() ;
256 PhosLoader()->MakeDigitsArray() ;
257 rv = PhosLoader()->Digits() ;
262 //____________________________________________________________________________
263 AliPHOSDigitizer * AliPHOSGetter::Digitizer()
265 // Returns pointer to the Digitizer task
266 AliPHOSDigitizer * rv ;
267 rv = dynamic_cast<AliPHOSDigitizer *>(PhosLoader()->Digitizer()) ;
270 rv = dynamic_cast<AliPHOSDigitizer *>(PhosLoader()->Digitizer()) ;
276 //____________________________________________________________________________
277 TObjArray * AliPHOSGetter::EmcRecPoints() const
279 // asks the Loader to return the EMC RecPoints container
283 rv = PhosLoader()->EmcRecPoints() ;
285 PhosLoader()->MakeRecPointsArray() ;
286 rv = PhosLoader()->EmcRecPoints() ;
291 //____________________________________________________________________________
292 TClonesArray * AliPHOSGetter::TrackSegments() const
294 // asks the Loader to return the TrackSegments container
296 TClonesArray * rv = 0 ;
298 rv = PhosLoader()->TrackSegments() ;
300 PhosLoader()->MakeTrackSegmentsArray() ;
301 rv = PhosLoader()->TrackSegments() ;
306 //____________________________________________________________________________
307 AliPHOSTrackSegmentMaker * AliPHOSGetter::TrackSegmentMaker()
309 // Returns pointer to the TrackSegmentMaker task
310 AliPHOSTrackSegmentMaker * rv ;
311 rv = dynamic_cast<AliPHOSTrackSegmentMaker *>(PhosLoader()->TrackSegmentMaker()) ;
314 rv = dynamic_cast<AliPHOSTrackSegmentMaker *>(PhosLoader()->TrackSegmentMaker()) ;
319 //____________________________________________________________________________
320 TClonesArray * AliPHOSGetter::RecParticles() const
322 // asks the Loader to return the TrackSegments container
324 TClonesArray * rv = 0 ;
326 rv = PhosLoader()->RecParticles() ;
328 PhosLoader()->MakeRecParticlesArray() ;
329 rv = PhosLoader()->RecParticles() ;
333 //____________________________________________________________________________
334 void AliPHOSGetter::Event(Int_t event, const char* opt)
336 // Reads the content of all Tree's S, D and R
338 // if ( event >= MaxEvent() ) {
339 // Error("Event", "%d not found in TreeE !", event) ;
343 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
345 // // checks if we are dealing with test-beam data
346 // TBranch * btb = rl->TreeE()->GetBranch("AliPHOSBeamTestEvent") ;
349 // fBTE = new AliPHOSBeamTestEvent() ;
350 // btb->SetAddress(&fBTE) ;
351 // btb->GetEntry(event) ;
360 // Loads the type of object(s) requested
362 rl->GetEvent(event) ;
364 if(strstr(opt,"X") || (strcmp(opt,"")==0)){
368 if(strstr(opt,"H") ){
372 if(strstr(opt,"S") ){
376 if(strstr(opt,"D") ){
380 if(strstr(opt,"R") ){
384 if( strstr(opt,"T") ){
388 if( strstr(opt,"P") ){
392 if( strstr(opt,"E") ){
399 //____________________________________________________________________________
400 void AliPHOSGetter::Event(AliRawReader *rawReader, const char* opt, Bool_t isOldRCUFormat)
402 // Reads the raw event from rawReader
403 // isOldRCUFormat defines whenever to assume
404 // the old RCU format or not
406 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
408 if( strstr(opt,"W") ){
409 rawReader->NextEvent();
410 Int_t iEvent = rl->GetEventNumber();
411 rl->GetEvent(iEvent);
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 AliRunLoader * 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 AliPHOSGeometry * AliPHOSGetter::PHOSGeometry() const
552 // Returns PHOS geometry
554 AliPHOSGeometry * rv = 0 ;
556 rv = PHOS()->GetGeometry() ;
558 rv = AliPHOSGeometry::GetInstance();
560 AliError("Could not find PHOS geometry! Loading the default one !");
561 rv = AliPHOSGeometry::GetInstance("IHEP","");
567 //____________________________________________________________________________
568 TClonesArray * AliPHOSGetter::Primaries()
570 // creates the Primaries container if needed
573 Info("Primaries", "Creating a new TClonesArray for primaries") ;
574 fPrimaries = new TClonesArray("TParticle", 1000) ;
579 //____________________________________________________________________________
580 void AliPHOSGetter::Print()
582 // Print usefull information about the getter
584 AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle());
585 ::Info( "Print", "gAlice file is %s -- version name is %s", (rl->GetFileName()).Data(), rl->GetEventFolder()->GetName() ) ;
588 //____________________________________________________________________________
589 void AliPHOSGetter::ReadPrimaries()
591 // Read Primaries from Kinematics.root
593 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
595 // gets kine tree from the root file (Kinematics.root)
596 if ( ! rl->TreeK() ) { // load treeK the first time
597 rl->LoadKinematics() ;
600 fNPrimaries = (rl->GetHeader())->GetNtrack();
602 Info( "ReadTreeK", "Found %d particles in event # %d", fNPrimaries, EventNumber() ) ;
605 // first time creates the container
607 fPrimaries->Clear() ;
610 for (index = 0 ; index < fNPrimaries; index++) {
611 new ((*fPrimaries)[index]) TParticle(*(Primary(index)));
615 //____________________________________________________________________________
616 Bool_t AliPHOSGetter::OpenESDFile()
621 fESDFile = TFile::Open(fESDFileName) ;
625 else if (fESDFile->IsOpen()) {
627 fESDFile = TFile::Open(fESDFileName) ;
629 if (!fESDFile->IsOpen())
634 //____________________________________________________________________________
635 void AliPHOSGetter::FitRaw(Bool_t lowGainFlag, TGraph * gLowGain, TGraph * gHighGain, TF1* signalF, Double_t & energy, Double_t & time) const
637 // Fits the raw signal time distribution
639 const Int_t kNoiseThreshold = 0 ;
640 Double_t timezero1 = 0., timezero2 = 0., timemax = 0. ;
641 Double_t signal = 0., signalmax = 0. ;
646 timezero1 = timezero2 = signalmax = timemax = 0. ;
647 signalF->FixParameter(0, PHOS()->GetRawFormatLowCharge()) ;
648 signalF->FixParameter(1, PHOS()->GetRawFormatLowGain()) ;
650 for (index = 0; index < PHOS()->GetRawFormatTimeBins(); index++) {
651 gLowGain->GetPoint(index, time, signal) ;
652 if (signal > kNoiseThreshold && timezero1 == 0.)
654 if (signal <= kNoiseThreshold && timezero1 > 0. && timezero2 == 0.)
656 if (signal > signalmax) {
661 signalmax /= PHOS()->RawResponseFunctionMax(PHOS()->GetRawFormatLowCharge(),
662 PHOS()->GetRawFormatLowGain()) ;
663 if ( timezero1 + PHOS()->GetRawFormatTimePeak() < PHOS()->GetRawFormatTimeMax() * 0.4 ) { // else its noise
664 signalF->SetParameter(2, signalmax) ;
665 signalF->SetParameter(3, timezero1) ;
666 gLowGain->Fit(signalF, "QRO", "", 0., timezero2); //, "QRON") ;
667 energy = signalF->GetParameter(2) ;
668 time = signalF->GetMaximumX() - PHOS()->GetRawFormatTimePeak() - PHOS()->GetRawFormatTimeTrigger() ;
671 timezero1 = timezero2 = signalmax = timemax = 0. ;
672 signalF->FixParameter(0, PHOS()->GetRawFormatHighCharge()) ;
673 signalF->FixParameter(1, PHOS()->GetRawFormatHighGain()) ;
675 for (index = 0; index < PHOS()->GetRawFormatTimeBins(); index++) {
676 gHighGain->GetPoint(index, time, signal) ;
677 if (signal > kNoiseThreshold && timezero1 == 0.)
679 if (signal <= kNoiseThreshold && timezero1 > 0. && timezero2 == 0.)
681 if (signal > signalmax) {
686 signalmax /= PHOS()->RawResponseFunctionMax(PHOS()->GetRawFormatHighCharge(),
687 PHOS()->GetRawFormatHighGain()) ;;
688 if ( timezero1 + PHOS()->GetRawFormatTimePeak() < PHOS()->GetRawFormatTimeMax() * 0.4 ) { // else its noise
689 signalF->SetParameter(2, signalmax) ;
690 signalF->SetParameter(3, timezero1) ;
691 gHighGain->Fit(signalF, "QRO", "", 0., timezero2) ;
692 energy = signalF->GetParameter(2) ;
693 time = signalF->GetMaximumX() - PHOS()->GetRawFormatTimePeak() - PHOS()->GetRawFormatTimeTrigger() ;
696 if (time == 0) energy = 0 ;
699 //____________________________________________________________________________
700 Int_t AliPHOSGetter::CalibrateRaw(Double_t energy, Int_t *relId)
702 // Convert energy into digitized amplitude for a cell relId
703 // It is a user responsilibity to open CDB and set
704 // AliPHOSCalibData object by the following operators:
706 // AliCDBLocal *loc = new AliCDBLocal("deCalibDB");
707 // AliPHOSCalibData* clb = (AliPHOSCalibData*)AliCDBStorage::Instance()
708 // ->Get(path_to_calibdata,run_number);
709 // AliPHOSGetter* gime = AliPHOSGetter::Instance("galice.root");
710 // gime->SetCalibData(clb);
712 if (CalibData() == 0)
713 Warning("CalibrateRaw","Calibration DB is not initiated!");
715 Int_t module = relId[0];
716 Int_t column = relId[3];
717 Int_t row = relId[2];
719 Float_t gainFactor = 0.0015; // width of one Emc ADC channel in GeV
720 Float_t pedestal = 0.005; // Emc pedestals
723 gainFactor = CalibData()->GetADCchannelEmc (module,column,row);
724 pedestal = CalibData()->GetADCpedestalEmc(module,column,row);
727 Int_t amp = static_cast<Int_t>( (energy - pedestal) / gainFactor + 0.5 ) ;
730 //____________________________________________________________________________
731 Int_t AliPHOSGetter::ReadRaw(AliRawReader *rawReader,Bool_t isOldRCUFormat)
733 // reads the raw format data, converts it into digits format and store digits in Digits()
735 // isOldRCUFormat = kTRUE in case of the old RCU
736 // format used in the raw data readout.
737 // Reimplemented by Boris Polichtchouk (Jul 2006)
738 // to make it working with the Jul-Aug 2006 beam test data.
741 AliPHOSRawStream in(rawReader);
742 in.SetOldRCUFormat(isOldRCUFormat);
744 TF1 * signalF = new TF1("signal", AliPHOS::RawResponseFunction, 0, PHOS()->GetRawFormatTimeMax(), 4);
745 signalF->SetParNames("Charge", "Gain", "Amplitude", "TimeZero") ;
747 Int_t relId[4], id =0;
748 Bool_t lowGainFlag = kFALSE ;
750 TClonesArray * digits = Digits() ;
755 Double_t energy = 0. ;
765 while ( in.Next() ) { // PHOS entries loop
767 if(!ampLG) ampLG = new Float_t[in.GetTimeLength()];
768 if(!ampHG) ampHG = new Float_t[in.GetTimeLength()];
769 if(!timeLH) timeLH = new Float_t[in.GetTimeLength()];
771 timeLH[in.GetTimeLength()-iBin-1] = in.GetTime();
773 lowGainFlag = in.IsLowGain();
776 ampLG[in.GetTimeLength()-iBin-1] = in.GetSignal(); //low gain
778 ampHG[in.GetTimeLength()-iBin-1] = in.GetSignal(); //high gain
781 if(iBin==in.GetTimeLength()) {
784 TGraph gLowGain(in.GetTimeLength(),timeLH,ampLG);
785 TGraph gHighGain(in.GetTimeLength(),timeLH,ampHG);
787 if(lowGainFlag) iDigLow++;
790 // Temporarily we do not fit the sample graph, but
791 // take the energy from the graph maximum, and the pedestal from the 0th point
794 //FitRaw(lowGainFlag, gLowGain, gHighGain, signalF, energy, time);
796 energy = gHighGain.GetHistogram()->GetMaximum();
797 energy -= gHighGain.Eval(0); // "pedestal subtraction"
800 energy = gLowGain.GetHistogram()->GetMaximum();
801 energy -= gLowGain.Eval(0); // "pedestal subtraction"
806 relId[0] = in.GetModule();
808 relId[2] = in.GetRow();
809 relId[3] = in.GetColumn();
810 if(!PHOSGeometry()) Fatal("ReadRaw","Couldn't find PHOSGeometry!");
811 PHOSGeometry()->RelToAbsNumbering(relId, id);
814 new((*digits)[idigit]) AliPHOSDigit(-1,id,(Float_t)energy,time);
818 delete timeLH; timeLH=0;
819 delete ampHG; ampHG=0;
820 delete ampLG; ampLG=0;
827 //printf("\t\t\t------ %d Digits: %d LowGain + %d HighGain.\n",
828 // digits->GetEntriesFast(),iDigLow,iDigHigh);
831 return digits->GetEntriesFast() ;
834 //____________________________________________________________________________
835 Int_t AliPHOSGetter::ReadTreeD() const
839 PhosLoader()->CleanDigits() ;
840 PhosLoader()->LoadDigits("UPDATE") ;
841 PhosLoader()->LoadDigitizer("UPDATE") ;
842 return Digits()->GetEntries() ;
845 //____________________________________________________________________________
846 Int_t AliPHOSGetter::ReadTreeH() const
849 PhosLoader()->CleanHits() ;
850 // gets TreeH from the root file (PHOS.Hit.root)
851 //if ( !IsLoaded("H") ) {
852 PhosLoader()->LoadHits("UPDATE") ;
855 return Hits()->GetEntries() ;
858 //____________________________________________________________________________
859 Int_t AliPHOSGetter::ReadTreeR() const
861 // Read the RecPoints
863 PhosLoader()->CleanRecPoints() ;
864 // gets TreeR from the root file (PHOS.RecPoints.root)
865 //if ( !IsLoaded("R") ) {
866 PhosLoader()->LoadRecPoints("UPDATE") ;
867 PhosLoader()->LoadClusterizer("UPDATE") ;
871 return EmcRecPoints()->GetEntries() ;
874 //____________________________________________________________________________
875 Int_t AliPHOSGetter::ReadTreeT() const
877 // Read the TrackSegments
879 PhosLoader()->CleanTracks() ;
880 // gets TreeT from the root file (PHOS.TrackSegments.root)
881 //if ( !IsLoaded("T") ) {
882 PhosLoader()->LoadTracks("UPDATE") ;
883 PhosLoader()->LoadTrackSegmentMaker("UPDATE") ;
887 return TrackSegments()->GetEntries() ;
889 //____________________________________________________________________________
890 Int_t AliPHOSGetter::ReadTreeP() const
892 // Read the RecParticles
894 PhosLoader()->CleanRecParticles() ;
896 // gets TreeT from the root file (PHOS.TrackSegments.root)
897 // if ( !IsLoaded("P") ) {
898 PhosLoader()->LoadRecParticles("UPDATE") ;
899 PhosLoader()->LoadPID("UPDATE") ;
903 return RecParticles()->GetEntries() ;
905 //____________________________________________________________________________
906 Int_t AliPHOSGetter::ReadTreeS() const
910 PhosLoader()->CleanSDigits() ;
911 // gets TreeS from the root file (PHOS.SDigits.root)
912 //if ( !IsLoaded("S") ) {
913 PhosLoader()->LoadSDigits("READ") ;
914 PhosLoader()->LoadSDigitizer("READ") ;
918 return SDigits()->GetEntries() ;
921 //____________________________________________________________________________
922 Int_t AliPHOSGetter::ReadTreeE(Int_t event)
926 // gets esdTree from the root file (AliESDs.root)
928 if ( !OpenESDFile() )
931 fESDTree = static_cast<TTree*>(fESDFile->Get("esdTree")) ;
935 Error("ReadTreeE", "no ESD tree found");
938 fESDTree->SetBranchAddress("ESD", &fESD);
939 fESDTree->GetEvent(event);
944 //____________________________________________________________________________
945 TClonesArray * AliPHOSGetter::SDigits() const
947 // asks the Loader to return the Digits container
949 TClonesArray * rv = 0 ;
951 rv = PhosLoader()->SDigits() ;
953 PhosLoader()->MakeSDigitsArray() ;
954 rv = PhosLoader()->SDigits() ;
959 //____________________________________________________________________________
960 AliPHOSSDigitizer * AliPHOSGetter::SDigitizer()
962 // Returns pointer to the SDigitizer task
963 AliPHOSSDigitizer * rv ;
964 rv = dynamic_cast<AliPHOSSDigitizer *>(PhosLoader()->SDigitizer()) ;
967 rv = dynamic_cast<AliPHOSSDigitizer *>(PhosLoader()->SDigitizer()) ;
972 //____________________________________________________________________________
973 TParticle * AliPHOSGetter::Secondary(const TParticle* p, Int_t index) const
975 // Return first (index=1) or second (index=2) secondary particle of primary particle p
983 Int_t daughterIndex = p->GetDaughter(index-1) ;
984 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
985 return rl->GetAliRun()->GetMCApp()->Particle(daughterIndex) ;
991 //____________________________________________________________________________
992 void AliPHOSGetter::Track(Int_t itrack)
994 // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
996 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
998 if( !TreeH() ) // load treeH the first time
1001 // first time create the container
1002 TClonesArray * hits = Hits() ;
1006 TBranch * phosbranch = dynamic_cast<TBranch*>(TreeH()->GetBranch("PHOS")) ;
1007 phosbranch->SetAddress(&hits) ;
1008 phosbranch->GetEntry(itrack) ;
1011 //____________________________________________________________________________
1012 TTree * AliPHOSGetter::TreeD() const
1014 // Returns pointer to the Digits Tree
1016 rv = PhosLoader()->TreeD() ;
1018 PhosLoader()->MakeTree("D");
1019 rv = PhosLoader()->TreeD() ;
1025 //____________________________________________________________________________
1026 TTree * AliPHOSGetter::TreeH() const
1028 // Returns pointer to the Hits Tree
1030 rv = PhosLoader()->TreeH() ;
1032 PhosLoader()->MakeTree("H");
1033 rv = PhosLoader()->TreeH() ;
1039 //____________________________________________________________________________
1040 TTree * AliPHOSGetter::TreeR() const
1042 // Returns pointer to the RecPoints Tree
1044 rv = PhosLoader()->TreeR() ;
1046 PhosLoader()->MakeTree("R");
1047 rv = PhosLoader()->TreeR() ;
1053 //____________________________________________________________________________
1054 TTree * AliPHOSGetter::TreeT() const
1056 // Returns pointer to the TrackSegments Tree
1058 rv = PhosLoader()->TreeT() ;
1060 PhosLoader()->MakeTree("T");
1061 rv = PhosLoader()->TreeT() ;
1066 //____________________________________________________________________________
1067 TTree * AliPHOSGetter::TreeP() const
1069 // Returns pointer to the RecParticles Tree
1071 rv = PhosLoader()->TreeP() ;
1073 PhosLoader()->MakeTree("P");
1074 rv = PhosLoader()->TreeP() ;
1080 //____________________________________________________________________________
1081 TTree * AliPHOSGetter::TreeS() const
1083 // Returns pointer to the SDigits Tree
1085 rv = PhosLoader()->TreeS() ;
1087 PhosLoader()->MakeTree("S");
1088 rv = PhosLoader()->TreeS() ;
1094 //____________________________________________________________________________
1095 Bool_t AliPHOSGetter::VersionExists(TString & opt) const
1097 // checks if the version with the present name already exists in the same directory
1099 Bool_t rv = kFALSE ;
1101 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
1102 TString version( rl->GetEventFolder()->GetName() ) ;
1106 if ( opt == "sdigits") {
1107 // add the version name to the root file name
1108 TString fileName( PhosLoader()->GetSDigitsFileName() ) ;
1109 if (version != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
1110 fileName = fileName.ReplaceAll(".root", "") + "_" + version + ".root" ;
1111 if ( !(gSystem->AccessPathName(fileName)) ) {
1112 Warning("VersionExists", "The file %s already exists", fileName.Data()) ;
1115 PhosLoader()->SetSDigitsFileName(fileName) ;
1118 if ( opt == "digits") {
1119 // add the version name to the root file name
1120 TString fileName( PhosLoader()->GetDigitsFileName() ) ;
1121 if (version != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
1122 fileName = fileName.ReplaceAll(".root", "") + "_" + version + ".root" ;
1123 if ( !(gSystem->AccessPathName(fileName)) ) {
1124 Warning("VersionExists", "The file %s already exists", fileName.Data()) ;
1133 //____________________________________________________________________________
1134 UShort_t AliPHOSGetter::EventPattern(void) const
1136 // Return the pattern (trigger bit register) of the beam-test event
1138 return fBTE->GetPattern() ;
1142 //____________________________________________________________________________
1143 Float_t AliPHOSGetter::BeamEnergy(void) const
1145 // Return the beam energy of the beam-test event
1147 return fBTE->GetBeamEnergy() ;
1151 //____________________________________________________________________________
1153 AliPHOSCalibData* AliPHOSGetter::CalibData()
1155 // Check if the instance of AliPHOSCalibData exists, and return it