1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 //_________________________________________________________________________
19 // A singleton. This class should be used in the analysis stage to get
20 // reconstructed objects: Digits, RecPoints, TrackSegments and RecParticles,
21 // instead of directly reading them from galice.root file. This container
22 // ensures, that one reads Digits, made of these particular digits, RecPoints,
23 // made of these particular RecPoints, TrackSegments and RecParticles.
24 // This becomes non trivial if there are several identical branches, produced with
25 // different set of parameters.
27 // An example of how to use (see also class AliPHOSAnalyser):
28 // AliPHOSGetter * gime = AliPHOSGetter::GetInstance("galice.root","test") ;
29 // for(Int_t irecp = 0; irecp < gime->NRecParticles() ; irecp++)
30 // AliPHOSRecParticle * part = gime->RecParticle(1) ;
32 // gime->Event(event) ; // reads new event from galice.root
34 //*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
35 //*-- Completely redesigned by Dmitri Peressounko March 2001
37 //*-- YS June 2001 : renamed the original AliPHOSIndexToObject and make
38 //*-- systematic usage of TFolders without changing the interface
39 //////////////////////////////////////////////////////////////////////////////
41 // --- ROOT system ---
46 #include <TParticle.h>
49 //#include <TCanvas.h>
52 // --- Standard library ---
54 // --- AliRoot header files ---
56 #include "AliHeader.h"
59 #include "AliPHOSBeamTestEvent.h"
60 #include "AliPHOSGetter.h"
61 #include "AliPHOSLoader.h"
62 #include "AliRunLoader.h"
64 #include "AliPHOSRawStream.h"
65 #include "AliRawReaderFile.h"
67 #include "AliCDBLocal.h"
68 #include "AliCDBStorage.h"
69 #include "AliCDBManager.h"
71 ClassImp(AliPHOSGetter)
73 AliPHOSGetter * AliPHOSGetter::fgObjGetter = 0 ;
74 AliPHOSLoader * AliPHOSGetter::fgPhosLoader = 0;
75 Int_t AliPHOSGetter::fgDebug = 0;
76 AliPHOSCalibData* AliPHOSGetter::fCalibData = 0;
78 // TFile * AliPHOSGetter::fgFile = 0 ;
80 //____________________________________________________________________________
81 AliPHOSGetter::AliPHOSGetter(const char* headerFile, const char* version, Option_t * openingOption)
83 // ctor only called by Instance()
85 AliRunLoader* rl = AliRunLoader::GetRunLoader(version) ;
87 rl = AliRunLoader::Open(headerFile, version, openingOption);
89 Fatal("AliPHOSGetter", "Could not find the Run Loader for %s - %s",headerFile, version) ;
92 if (rl->GetAliRun() == 0x0) {
94 gAlice = rl->GetAliRun(); // should be removed
98 fgPhosLoader = dynamic_cast<AliPHOSLoader*>(rl->GetLoader("PHOSLoader"));
100 Error("AliPHOSGetter", "Could not find PHOSLoader") ;
102 fgPhosLoader->SetTitle(version);
104 // initialize data members
108 fLoadingStatus = "" ;
110 fESDFileName = rl->GetFileName() ; // this should be the galice.root file
111 fESDFileName.ReplaceAll("galice.root", "AliESDs.root") ;
115 fRawDigits = kFALSE ;
119 //____________________________________________________________________________
120 AliPHOSGetter::~AliPHOSGetter()
124 delete fgPhosLoader ;
132 fPrimaries->Delete() ;
143 //____________________________________________________________________________
144 void AliPHOSGetter::Reset()
146 // resets things in case the getter is called consecutively with different files
147 // the PHOS Loader is already deleted by the Run Loader
150 fPrimaries->Delete() ;
157 //____________________________________________________________________________
158 AliPHOSClusterizer * AliPHOSGetter::Clusterizer()
160 // Returns pointer to the Clusterizer task
161 AliPHOSClusterizer * rv ;
162 rv = dynamic_cast<AliPHOSClusterizer *>(PhosLoader()->Reconstructioner()) ;
165 rv = dynamic_cast<AliPHOSClusterizer*>(PhosLoader()->Reconstructioner()) ;
170 //____________________________________________________________________________
171 TObjArray * AliPHOSGetter::CpvRecPoints()
173 // asks the Loader to return the CPV RecPoints container
177 rv = PhosLoader()->CpvRecPoints() ;
179 PhosLoader()->MakeRecPointsArray() ;
180 rv = PhosLoader()->CpvRecPoints() ;
185 //____________________________________________________________________________
186 TClonesArray * AliPHOSGetter::Digits()
188 // asks the Loader to return the Digits container
190 TClonesArray * rv = 0 ;
191 rv = PhosLoader()->Digits() ;
194 PhosLoader()->MakeDigitsArray() ;
195 rv = PhosLoader()->Digits() ;
200 //____________________________________________________________________________
201 AliPHOSDigitizer * AliPHOSGetter::Digitizer()
203 // Returns pointer to the Digitizer task
204 AliPHOSDigitizer * rv ;
205 rv = dynamic_cast<AliPHOSDigitizer *>(PhosLoader()->Digitizer()) ;
208 rv = dynamic_cast<AliPHOSDigitizer *>(PhosLoader()->Digitizer()) ;
214 //____________________________________________________________________________
215 TObjArray * AliPHOSGetter::EmcRecPoints()
217 // asks the Loader to return the EMC RecPoints container
221 rv = PhosLoader()->EmcRecPoints() ;
223 PhosLoader()->MakeRecPointsArray() ;
224 rv = PhosLoader()->EmcRecPoints() ;
229 //____________________________________________________________________________
230 TClonesArray * AliPHOSGetter::TrackSegments()
232 // asks the Loader to return the TrackSegments container
234 TClonesArray * rv = 0 ;
236 rv = PhosLoader()->TrackSegments() ;
238 PhosLoader()->MakeTrackSegmentsArray() ;
239 rv = PhosLoader()->TrackSegments() ;
244 //____________________________________________________________________________
245 AliPHOSTrackSegmentMaker * AliPHOSGetter::TrackSegmentMaker()
247 // Returns pointer to the TrackSegmentMaker task
248 AliPHOSTrackSegmentMaker * rv ;
249 rv = dynamic_cast<AliPHOSTrackSegmentMaker *>(PhosLoader()->TrackSegmentMaker()) ;
252 rv = dynamic_cast<AliPHOSTrackSegmentMaker *>(PhosLoader()->TrackSegmentMaker()) ;
257 //____________________________________________________________________________
258 TClonesArray * AliPHOSGetter::RecParticles()
260 // asks the Loader to return the TrackSegments container
262 TClonesArray * rv = 0 ;
264 rv = PhosLoader()->RecParticles() ;
266 PhosLoader()->MakeRecParticlesArray() ;
267 rv = PhosLoader()->RecParticles() ;
271 //____________________________________________________________________________
272 void AliPHOSGetter::Event(Int_t event, const char* opt)
274 // Reads the content of all Tree's S, D and R
276 // if ( event >= MaxEvent() ) {
277 // Error("Event", "%d not found in TreeE !", event) ;
281 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
283 // // checks if we are dealing with test-beam data
284 // TBranch * btb = rl->TreeE()->GetBranch("AliPHOSBeamTestEvent") ;
287 // fBTE = new AliPHOSBeamTestEvent() ;
288 // btb->SetAddress(&fBTE) ;
289 // btb->GetEntry(event) ;
298 // Loads the type of object(s) requested
300 rl->GetEvent(event) ;
302 if(strstr(opt,"X") || (strcmp(opt,"")==0)){
306 if(strstr(opt,"H") ){
310 if(strstr(opt,"S") ){
314 if(strstr(opt,"D") ){
318 if(strstr(opt,"R") ){
322 if( strstr(opt,"T") ){
326 if( strstr(opt,"P") ){
330 if( strstr(opt,"E") ){
337 //____________________________________________________________________________
338 void AliPHOSGetter::Event(AliRawReader *rawReader, const char* opt)
340 // Reads the raw event from rawReader
342 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
344 if( strstr(opt,"W") ){
345 rawReader->NextEvent();
346 Int_t iEvent = rl->GetEventNumber();
347 rl->GetEvent(iEvent);
349 rl->SetEventNumber(++iEvent);
355 //____________________________________________________________________________
356 Int_t AliPHOSGetter::EventNumber() const
358 // return the current event number
359 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
360 return static_cast<Int_t>(rl->GetEventNumber()) ;
363 //____________________________________________________________________________
364 TClonesArray * AliPHOSGetter::Hits()
366 // asks the loader to return the Hits container
368 TClonesArray * rv = 0 ;
370 rv = PhosLoader()->Hits() ;
372 PhosLoader()->LoadHits("read");
373 rv = PhosLoader()->Hits() ;
378 //____________________________________________________________________________
379 AliPHOSGetter * AliPHOSGetter::Instance(const char* alirunFileName, const char* version, Option_t * openingOption)
381 // Creates and returns the pointer of the unique instance
382 // Must be called only when the environment has changed
384 if(!fgObjGetter){ // first time the getter is called
385 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
387 else { // the getter has been called previously
388 AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle());
389 if ( rl->GetFileName() == alirunFileName ) {// the alirunFile has the same name
390 // check if the file is already open
391 TFile * galiceFile = dynamic_cast<TFile *>(gROOT->FindObject(rl->GetFileName()) ) ;
394 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
396 else { // the file is already open check the version name
397 TString currentVersionName = rl->GetEventFolder()->GetName() ;
398 TString newVersionName(version) ;
399 if (currentVersionName == newVersionName)
401 ::Warning( "Instance", "Files with version %s already open", currentVersionName.Data() ) ;
403 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
408 AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle()) ;
409 if ( strstr(version, AliConfig::GetDefaultEventFolderName()) ) // false in case of merging
411 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
415 ::Error("AliPHOSGetter::Instance", "Failed to create the PHOS Getter object") ;
423 //____________________________________________________________________________
424 AliPHOSGetter * AliPHOSGetter::Instance()
426 // Returns the pointer of the unique instance already defined
428 if(!fgObjGetter && fgDebug)
429 ::Warning("AliPHOSGetter::Instance", "Getter not initialized") ;
435 //____________________________________________________________________________
436 Int_t AliPHOSGetter::MaxEvent() const
438 // returns the number of events in the run (from TE)
440 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
441 return static_cast<Int_t>(rl->GetNumberOfEvents()) ;
444 //____________________________________________________________________________
445 TParticle * AliPHOSGetter::Primary(Int_t index) const
447 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
448 return rl->Stack()->Particle(index) ;
451 //____________________________________________________________________________
452 AliPHOS * AliPHOSGetter:: PHOS() const
454 // returns the PHOS object
455 AliPHOSLoader * loader = 0;
456 static AliPHOSLoader * oldloader = 0;
457 static AliPHOS * phos = 0;
459 loader = PhosLoader();
461 if ( loader != oldloader) {
462 phos = dynamic_cast<AliPHOS*>(loader->GetModulesFolder()->FindObject("PHOS")) ;
467 Warning("PHOS", "PHOS module not found in module folders: %s", PhosLoader()->GetModulesFolder()->GetName() ) ;
473 //____________________________________________________________________________
474 AliPHOSPID * AliPHOSGetter::PID()
476 // Returns pointer to the PID task
478 rv = dynamic_cast<AliPHOSPID *>(PhosLoader()->PIDTask()) ;
481 rv = dynamic_cast<AliPHOSPID *>(PhosLoader()->PIDTask()) ;
486 //____________________________________________________________________________
487 AliPHOSGeometry * AliPHOSGetter::PHOSGeometry() const
489 // Returns PHOS geometry
491 AliPHOSGeometry * rv = 0 ;
493 rv = PHOS()->GetGeometry() ;
497 //____________________________________________________________________________
498 TClonesArray * AliPHOSGetter::Primaries()
500 // creates the Primaries container if needed
503 Info("Primaries", "Creating a new TClonesArray for primaries") ;
504 fPrimaries = new TClonesArray("TParticle", 1000) ;
509 //____________________________________________________________________________
510 void AliPHOSGetter::Print()
512 // Print usefull information about the getter
514 AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle());
515 ::Info( "Print", "gAlice file is %s -- version name is %s", (rl->GetFileName()).Data(), rl->GetEventFolder()->GetName() ) ;
518 //____________________________________________________________________________
519 void AliPHOSGetter::ReadPrimaries()
521 // Read Primaries from Kinematics.root
523 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
525 // gets kine tree from the root file (Kinematics.root)
526 if ( ! rl->TreeK() ) { // load treeK the first time
527 rl->LoadKinematics() ;
530 fNPrimaries = (rl->GetHeader())->GetNtrack();
532 Info( "ReadTreeK", "Found %d particles in event # %d", fNPrimaries, EventNumber() ) ;
535 // first time creates the container
537 fPrimaries->Clear() ;
540 for (index = 0 ; index < fNPrimaries; index++) {
541 new ((*fPrimaries)[index]) TParticle(*(Primary(index)));
545 //____________________________________________________________________________
546 Bool_t AliPHOSGetter::OpenESDFile()
551 fESDFile = TFile::Open(fESDFileName) ;
555 else if (fESDFile->IsOpen()) {
557 fESDFile = TFile::Open(fESDFileName) ;
559 if (!fESDFile->IsOpen())
564 //____________________________________________________________________________
565 void AliPHOSGetter::FitRaw(Bool_t lowGainFlag, TGraph * gLowGain, TGraph * gHighGain, TF1* signalF, Double_t & energy, Double_t & time)
567 // Fits the raw signal time distribution
569 const Int_t kNoiseThreshold = 0 ;
570 Double_t timezero1 = 0., timezero2 = 0., timemax = 0. ;
571 Double_t signal = 0., signalmax = 0. ;
576 timezero1 = timezero2 = signalmax = timemax = 0. ;
577 signalF->FixParameter(0, PHOS()->GetRawFormatLowCharge()) ;
578 signalF->FixParameter(1, PHOS()->GetRawFormatLowGain()) ;
580 for (index = 0; index < PHOS()->GetRawFormatTimeBins(); index++) {
581 gLowGain->GetPoint(index, time, signal) ;
582 if (signal > kNoiseThreshold && timezero1 == 0.)
584 if (signal <= kNoiseThreshold && timezero1 > 0. && timezero2 == 0.)
586 if (signal > signalmax) {
591 signalmax /= PHOS()->RawResponseFunctionMax(PHOS()->GetRawFormatLowCharge(),
592 PHOS()->GetRawFormatLowGain()) ;
593 if ( timezero1 + PHOS()->GetRawFormatTimePeak() < PHOS()->GetRawFormatTimeMax() * 0.4 ) { // else its noise
594 signalF->SetParameter(2, signalmax) ;
595 signalF->SetParameter(3, timezero1) ;
596 gLowGain->Fit(signalF, "QRON", "", 0., timezero2); //, "QRON") ;
597 energy = signalF->GetParameter(2) ;
598 time = signalF->GetMaximumX() - PHOS()->GetRawFormatTimePeak() - PHOS()->GetRawFormatTimeTrigger() ;
601 timezero1 = timezero2 = signalmax = timemax = 0. ;
602 signalF->FixParameter(0, PHOS()->GetRawFormatHighCharge()) ;
603 signalF->FixParameter(1, PHOS()->GetRawFormatHighGain()) ;
605 for (index = 0; index < PHOS()->GetRawFormatTimeBins(); index++) {
606 gHighGain->GetPoint(index, time, signal) ;
607 if (signal > kNoiseThreshold && timezero1 == 0.)
609 if (signal <= kNoiseThreshold && timezero1 > 0. && timezero2 == 0.)
611 if (signal > signalmax) {
616 signalmax /= PHOS()->RawResponseFunctionMax(PHOS()->GetRawFormatHighCharge(),
617 PHOS()->GetRawFormatHighGain()) ;;
618 if ( timezero1 + PHOS()->GetRawFormatTimePeak() < PHOS()->GetRawFormatTimeMax() * 0.4 ) { // else its noise
619 signalF->SetParameter(2, signalmax) ;
620 signalF->SetParameter(3, timezero1) ;
621 gHighGain->Fit(signalF, "QRON", "", 0., timezero2) ;
622 energy = signalF->GetParameter(2) ;
623 time = signalF->GetMaximumX() - PHOS()->GetRawFormatTimePeak() - PHOS()->GetRawFormatTimeTrigger() ;
626 if (time == 0) energy = 0 ;
629 //____________________________________________________________________________
630 Int_t AliPHOSGetter::CalibrateRaw(Double_t energy, Int_t *relId)
632 // Convert energy into digitized amplitude for a cell relId
633 // It is a user responsilibity to open CDB and set
634 // AliPHOSCalibData object by the following operators:
636 // AliCDBLocal *loc = new AliCDBLocal("deCalibDB");
637 // AliPHOSCalibData* clb = (AliPHOSCalibData*)AliCDBStorage::Instance()
638 // ->Get(path_to_calibdata,run_number);
639 // AliPHOSGetter* gime = AliPHOSGetter::Instance("galice.root");
640 // gime->SetCalibData(clb);
642 if (CalibData() == 0)
643 Warning("CalibrateRaw","Calibration DB is not initiated!");
645 Int_t module = relId[0];
646 Int_t column = relId[3];
647 Int_t row = relId[2];
649 Float_t gainFactor = 0.0015; // width of one Emc ADC channel in GeV
650 Float_t pedestal = 0.005; // Emc pedestals
653 gainFactor = CalibData()->GetADCchannelEmc (module,column,row);
654 pedestal = CalibData()->GetADCpedestalEmc(module,column,row);
657 Int_t amp = static_cast<Int_t>( (energy - pedestal) / gainFactor + 0.5 ) ;
660 //____________________________________________________________________________
661 Int_t AliPHOSGetter::ReadRaw(AliRawReader *rawReader)
663 // reads the raw format data, converts it into digits format and store digits in Digits()
666 AliPHOSRawStream in(rawReader);
668 Bool_t first = kTRUE ;
670 TF1 * signalF = new TF1("signal", AliPHOS::RawResponseFunction, 0, PHOS()->GetRawFormatTimeMax(), 4);
671 signalF->SetParNames("Charge", "Gain", "Amplitude", "TimeZero") ;
673 Int_t relId[4], id =0;
674 Bool_t lowGainFlag = kFALSE ;
676 TClonesArray * digits = Digits() ;
680 Double_t energy = 0. ;
683 TGraph * gLowGain = new TGraph(PHOS()->GetRawFormatTimeBins()) ;
684 TGraph * gHighGain= new TGraph(PHOS()->GetRawFormatTimeBins()) ;
686 while ( in.Next() ) { // PHOS entries loop
687 if ( (in.IsNewRow() || in.IsNewColumn() || in.IsNewModule()) ) {
688 relId[0] = in.GetModule() ;
689 if ( relId[0] >= PHOS()->GetRawFormatLowGainOffset() ) {
690 relId[0] -= PHOS()->GetRawFormatLowGainOffset() ;
691 lowGainFlag = kTRUE ;
693 lowGainFlag = kFALSE ;
695 relId[2] = in.GetRow() ;
696 relId[3] = in.GetColumn() ;
697 PHOSGeometry()->RelToAbsNumbering(relId, id) ;
699 FitRaw(lowGainFlag, gLowGain, gHighGain, signalF, energy, time) ;
700 amp = CalibrateRaw(energy,relId);
702 new((*digits)[idigit]) AliPHOSDigit( -1, id, amp, time) ;
706 for (index = 0; index < PHOS()->GetRawFormatTimeBins(); index++) {
707 gLowGain->SetPoint(index, index * PHOS()->GetRawFormatTimeMax() / PHOS()->GetRawFormatTimeBins(), 0) ;
708 gHighGain->SetPoint(index, index * PHOS()->GetRawFormatTimeMax() / PHOS()->GetRawFormatTimeBins(), 0) ;
714 gLowGain->SetPoint(in.GetTime(),
715 in.GetTime()* PHOS()->GetRawFormatTimeMax() / PHOS()->GetRawFormatTimeBins(),
718 gHighGain->SetPoint(in.GetTime(),
719 in.GetTime() * PHOS()->GetRawFormatTimeMax() / PHOS()->GetRawFormatTimeBins(),
722 } // PHOS entries loop
724 FitRaw(lowGainFlag, gLowGain, gHighGain, signalF, energy, time) ;
725 amp = CalibrateRaw(energy,relId);
727 new((*digits)[idigit]) AliPHOSDigit( -1, id, amp, time) ;
736 // AliInfo(Form("Event %d, digits: %d\n", EventNumber(),digits->GetEntries())); //bvp
737 return digits->GetEntriesFast() ;
740 // TClonesArray * digits = Digits() ;
742 // Int_t idigit = 0 ;
744 // while ( in.Next() ) { // PHOS entries loop
746 // Int_t amp = in.GetSignal() ;
747 // Double_t time = in.GetTime() ;
748 // Int_t relId[4], id ;
750 // relId[0] = in.GetModule() ;
751 // if ( relId[0] >= PHOS()->GetRawFormatLowGainOffset() ) {
752 // relId[0] -= PHOS()->GetRawFormatLowGainOffset() ;
755 // relId[2] = in.GetRow() ;
756 // relId[3] = in.GetColumn() ;
757 // PHOSGeometry()->RelToAbsNumbering(relId, id) ;
759 // if (amp > 0 && id >=0 ) {
760 // new((*digits)[idigit]) AliPHOSDigit( -1, id, amp, time) ;
764 // } // PHOS entries loop
768 // return digits->GetEntriesFast() ;
770 //____________________________________________________________________________
771 Int_t AliPHOSGetter::ReadTreeD()
775 PhosLoader()->CleanDigits() ;
776 PhosLoader()->LoadDigits("UPDATE") ;
777 PhosLoader()->LoadDigitizer("UPDATE") ;
778 return Digits()->GetEntries() ;
781 //____________________________________________________________________________
782 Int_t AliPHOSGetter::ReadTreeH()
785 PhosLoader()->CleanHits() ;
786 // gets TreeH from the root file (PHOS.Hit.root)
787 //if ( !IsLoaded("H") ) {
788 PhosLoader()->LoadHits("UPDATE") ;
791 return Hits()->GetEntries() ;
794 //____________________________________________________________________________
795 Int_t AliPHOSGetter::ReadTreeR()
797 // Read the RecPoints
799 PhosLoader()->CleanRecPoints() ;
800 // gets TreeR from the root file (PHOS.RecPoints.root)
801 //if ( !IsLoaded("R") ) {
802 PhosLoader()->LoadRecPoints("UPDATE") ;
803 PhosLoader()->LoadClusterizer("UPDATE") ;
807 return EmcRecPoints()->GetEntries() ;
810 //____________________________________________________________________________
811 Int_t AliPHOSGetter::ReadTreeT()
813 // Read the TrackSegments
815 PhosLoader()->CleanTracks() ;
816 // gets TreeT from the root file (PHOS.TrackSegments.root)
817 //if ( !IsLoaded("T") ) {
818 PhosLoader()->LoadTracks("UPDATE") ;
819 PhosLoader()->LoadTrackSegmentMaker("UPDATE") ;
823 return TrackSegments()->GetEntries() ;
825 //____________________________________________________________________________
826 Int_t AliPHOSGetter::ReadTreeP()
828 // Read the RecParticles
830 PhosLoader()->CleanRecParticles() ;
832 // gets TreeT from the root file (PHOS.TrackSegments.root)
833 // if ( !IsLoaded("P") ) {
834 PhosLoader()->LoadRecParticles("UPDATE") ;
835 PhosLoader()->LoadPID("UPDATE") ;
839 return RecParticles()->GetEntries() ;
841 //____________________________________________________________________________
842 Int_t AliPHOSGetter::ReadTreeS()
846 PhosLoader()->CleanSDigits() ;
847 // gets TreeS from the root file (PHOS.SDigits.root)
848 //if ( !IsLoaded("S") ) {
849 PhosLoader()->LoadSDigits("READ") ;
850 PhosLoader()->LoadSDigitizer("READ") ;
854 return SDigits()->GetEntries() ;
857 //____________________________________________________________________________
858 Int_t AliPHOSGetter::ReadTreeE(Int_t event)
862 // gets esdTree from the root file (AliESDs.root)
864 if ( !OpenESDFile() )
867 fESDTree = static_cast<TTree*>(fESDFile->Get("esdTree")) ;
871 Error("ReadTreeE", "no ESD tree found");
874 fESDTree->SetBranchAddress("ESD", &fESD);
875 fESDTree->GetEvent(event);
880 //____________________________________________________________________________
881 TClonesArray * AliPHOSGetter::SDigits()
883 // asks the Loader to return the Digits container
885 TClonesArray * rv = 0 ;
887 rv = PhosLoader()->SDigits() ;
889 PhosLoader()->MakeSDigitsArray() ;
890 rv = PhosLoader()->SDigits() ;
895 //____________________________________________________________________________
896 AliPHOSSDigitizer * AliPHOSGetter::SDigitizer()
898 // Returns pointer to the SDigitizer task
899 AliPHOSSDigitizer * rv ;
900 rv = dynamic_cast<AliPHOSSDigitizer *>(PhosLoader()->SDigitizer()) ;
903 rv = dynamic_cast<AliPHOSSDigitizer *>(PhosLoader()->SDigitizer()) ;
908 //____________________________________________________________________________
909 TParticle * AliPHOSGetter::Secondary(const TParticle* p, Int_t index) const
911 // Return first (index=1) or second (index=2) secondary particle of primary particle p
919 Int_t daughterIndex = p->GetDaughter(index-1) ;
920 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
921 return rl->GetAliRun()->GetMCApp()->Particle(daughterIndex) ;
927 //____________________________________________________________________________
928 void AliPHOSGetter::Track(Int_t itrack)
930 // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
932 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
934 if( !TreeH() ) // load treeH the first time
937 // first time create the container
938 TClonesArray * hits = Hits() ;
942 TBranch * phosbranch = dynamic_cast<TBranch*>(TreeH()->GetBranch("PHOS")) ;
943 phosbranch->SetAddress(&hits) ;
944 phosbranch->GetEntry(itrack) ;
947 //____________________________________________________________________________
948 TTree * AliPHOSGetter::TreeD() const
950 // Returns pointer to the Digits Tree
952 rv = PhosLoader()->TreeD() ;
954 PhosLoader()->MakeTree("D");
955 rv = PhosLoader()->TreeD() ;
961 //____________________________________________________________________________
962 TTree * AliPHOSGetter::TreeH() const
964 // Returns pointer to the Hits Tree
966 rv = PhosLoader()->TreeH() ;
968 PhosLoader()->MakeTree("H");
969 rv = PhosLoader()->TreeH() ;
975 //____________________________________________________________________________
976 TTree * AliPHOSGetter::TreeR() const
978 // Returns pointer to the RecPoints Tree
980 rv = PhosLoader()->TreeR() ;
982 PhosLoader()->MakeTree("R");
983 rv = PhosLoader()->TreeR() ;
989 //____________________________________________________________________________
990 TTree * AliPHOSGetter::TreeT() const
992 // Returns pointer to the TrackSegments Tree
994 rv = PhosLoader()->TreeT() ;
996 PhosLoader()->MakeTree("T");
997 rv = PhosLoader()->TreeT() ;
1002 //____________________________________________________________________________
1003 TTree * AliPHOSGetter::TreeP() const
1005 // Returns pointer to the RecParticles Tree
1007 rv = PhosLoader()->TreeP() ;
1009 PhosLoader()->MakeTree("P");
1010 rv = PhosLoader()->TreeP() ;
1016 //____________________________________________________________________________
1017 TTree * AliPHOSGetter::TreeS() const
1019 // Returns pointer to the SDigits Tree
1021 rv = PhosLoader()->TreeS() ;
1023 PhosLoader()->MakeTree("S");
1024 rv = PhosLoader()->TreeS() ;
1030 //____________________________________________________________________________
1031 Bool_t AliPHOSGetter::VersionExists(TString & opt) const
1033 // checks if the version with the present name already exists in the same directory
1035 Bool_t rv = kFALSE ;
1037 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
1038 TString version( rl->GetEventFolder()->GetName() ) ;
1042 if ( opt == "sdigits") {
1043 // add the version name to the root file name
1044 TString fileName( PhosLoader()->GetSDigitsFileName() ) ;
1045 if (version != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
1046 fileName = fileName.ReplaceAll(".root", "") + "_" + version + ".root" ;
1047 if ( !(gSystem->AccessPathName(fileName)) ) {
1048 Warning("VersionExists", "The file %s already exists", fileName.Data()) ;
1051 PhosLoader()->SetSDigitsFileName(fileName) ;
1054 if ( opt == "digits") {
1055 // add the version name to the root file name
1056 TString fileName( PhosLoader()->GetDigitsFileName() ) ;
1057 if (version != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
1058 fileName = fileName.ReplaceAll(".root", "") + "_" + version + ".root" ;
1059 if ( !(gSystem->AccessPathName(fileName)) ) {
1060 Warning("VersionExists", "The file %s already exists", fileName.Data()) ;
1069 //____________________________________________________________________________
1070 UShort_t AliPHOSGetter::EventPattern(void) const
1072 // Return the pattern (trigger bit register) of the beam-test event
1074 return fBTE->GetPattern() ;
1078 //____________________________________________________________________________
1079 Float_t AliPHOSGetter::BeamEnergy(void) const
1081 // Return the beam energy of the beam-test event
1083 return fBTE->GetBeamEnergy() ;
1087 //____________________________________________________________________________
1089 AliPHOSCalibData* AliPHOSGetter::CalibData()
1092 if( !(AliCDBManager::Instance()->IsDefaultStorageSet()) ) {
1094 Warning("CalibData","Calibration DB is not initiated!");