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;
77 AliPHOSAlignData* AliPHOSGetter::fAlignData = 0;
79 // TFile * AliPHOSGetter::fgFile = 0 ;
81 //____________________________________________________________________________
82 AliPHOSGetter::AliPHOSGetter(const char* headerFile, const char* version, Option_t * openingOption)
84 // ctor only called by Instance()
86 AliRunLoader* rl = AliRunLoader::GetRunLoader(version) ;
88 rl = AliRunLoader::Open(headerFile, version, openingOption);
90 Fatal("AliPHOSGetter", "Could not find the Run Loader for %s - %s",headerFile, version) ;
93 if (rl->GetAliRun() == 0x0) {
95 gAlice = rl->GetAliRun(); // should be removed
99 fgPhosLoader = dynamic_cast<AliPHOSLoader*>(rl->GetLoader("PHOSLoader"));
101 Error("AliPHOSGetter", "Could not find PHOSLoader") ;
103 fgPhosLoader->SetTitle(version);
105 // initialize data members
109 fLoadingStatus = "" ;
111 fESDFileName = rl->GetFileName() ; // this should be the galice.root file
112 fESDFileName.ReplaceAll("galice.root", "AliESDs.root") ;
116 fRawDigits = kFALSE ;
120 //____________________________________________________________________________
121 AliPHOSGetter::~AliPHOSGetter()
125 delete fgPhosLoader ;
133 fPrimaries->Delete() ;
144 //____________________________________________________________________________
145 void AliPHOSGetter::Reset()
147 // resets things in case the getter is called consecutively with different files
148 // the PHOS Loader is already deleted by the Run Loader
151 fPrimaries->Delete() ;
158 //____________________________________________________________________________
159 AliPHOSClusterizer * AliPHOSGetter::Clusterizer()
161 // Returns pointer to the Clusterizer task
162 AliPHOSClusterizer * rv ;
163 rv = dynamic_cast<AliPHOSClusterizer *>(PhosLoader()->Reconstructioner()) ;
166 rv = dynamic_cast<AliPHOSClusterizer*>(PhosLoader()->Reconstructioner()) ;
171 //____________________________________________________________________________
172 TObjArray * AliPHOSGetter::CpvRecPoints()
174 // asks the Loader to return the CPV RecPoints container
178 rv = PhosLoader()->CpvRecPoints() ;
180 PhosLoader()->MakeRecPointsArray() ;
181 rv = PhosLoader()->CpvRecPoints() ;
186 //____________________________________________________________________________
187 TClonesArray * AliPHOSGetter::Digits()
189 // asks the Loader to return the Digits container
191 TClonesArray * rv = 0 ;
192 rv = PhosLoader()->Digits() ;
195 PhosLoader()->MakeDigitsArray() ;
196 rv = PhosLoader()->Digits() ;
201 //____________________________________________________________________________
202 AliPHOSDigitizer * AliPHOSGetter::Digitizer()
204 // Returns pointer to the Digitizer task
205 AliPHOSDigitizer * rv ;
206 rv = dynamic_cast<AliPHOSDigitizer *>(PhosLoader()->Digitizer()) ;
209 rv = dynamic_cast<AliPHOSDigitizer *>(PhosLoader()->Digitizer()) ;
215 //____________________________________________________________________________
216 TObjArray * AliPHOSGetter::EmcRecPoints()
218 // asks the Loader to return the EMC RecPoints container
222 rv = PhosLoader()->EmcRecPoints() ;
224 PhosLoader()->MakeRecPointsArray() ;
225 rv = PhosLoader()->EmcRecPoints() ;
230 //____________________________________________________________________________
231 TClonesArray * AliPHOSGetter::TrackSegments()
233 // asks the Loader to return the TrackSegments container
235 TClonesArray * rv = 0 ;
237 rv = PhosLoader()->TrackSegments() ;
239 PhosLoader()->MakeTrackSegmentsArray() ;
240 rv = PhosLoader()->TrackSegments() ;
245 //____________________________________________________________________________
246 AliPHOSTrackSegmentMaker * AliPHOSGetter::TrackSegmentMaker()
248 // Returns pointer to the TrackSegmentMaker task
249 AliPHOSTrackSegmentMaker * rv ;
250 rv = dynamic_cast<AliPHOSTrackSegmentMaker *>(PhosLoader()->TrackSegmentMaker()) ;
253 rv = dynamic_cast<AliPHOSTrackSegmentMaker *>(PhosLoader()->TrackSegmentMaker()) ;
258 //____________________________________________________________________________
259 TClonesArray * AliPHOSGetter::RecParticles()
261 // asks the Loader to return the TrackSegments container
263 TClonesArray * rv = 0 ;
265 rv = PhosLoader()->RecParticles() ;
267 PhosLoader()->MakeRecParticlesArray() ;
268 rv = PhosLoader()->RecParticles() ;
272 //____________________________________________________________________________
273 void AliPHOSGetter::Event(Int_t event, const char* opt)
275 // Reads the content of all Tree's S, D and R
277 // if ( event >= MaxEvent() ) {
278 // Error("Event", "%d not found in TreeE !", event) ;
282 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
284 // // checks if we are dealing with test-beam data
285 // TBranch * btb = rl->TreeE()->GetBranch("AliPHOSBeamTestEvent") ;
288 // fBTE = new AliPHOSBeamTestEvent() ;
289 // btb->SetAddress(&fBTE) ;
290 // btb->GetEntry(event) ;
299 // Loads the type of object(s) requested
301 rl->GetEvent(event) ;
303 if(strstr(opt,"X") || (strcmp(opt,"")==0)){
307 if(strstr(opt,"H") ){
311 if(strstr(opt,"S") ){
315 if(strstr(opt,"D") ){
319 if(strstr(opt,"R") ){
323 if( strstr(opt,"T") ){
327 if( strstr(opt,"P") ){
331 if( strstr(opt,"E") ){
338 //____________________________________________________________________________
339 void AliPHOSGetter::Event(AliRawReader *rawReader, const char* opt)
341 // Reads the raw event from rawReader
343 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
345 if( strstr(opt,"W") ){
346 rawReader->NextEvent();
347 Int_t iEvent = rl->GetEventNumber();
348 rl->GetEvent(iEvent);
350 rl->SetEventNumber(++iEvent);
356 //____________________________________________________________________________
357 Int_t AliPHOSGetter::EventNumber() const
359 // return the current event number
360 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
361 return static_cast<Int_t>(rl->GetEventNumber()) ;
364 //____________________________________________________________________________
365 TClonesArray * AliPHOSGetter::Hits()
367 // asks the loader to return the Hits container
369 TClonesArray * rv = 0 ;
371 rv = PhosLoader()->Hits() ;
373 PhosLoader()->LoadHits("read");
374 rv = PhosLoader()->Hits() ;
379 //____________________________________________________________________________
380 AliPHOSGetter * AliPHOSGetter::Instance(const char* alirunFileName, const char* version, Option_t * openingOption)
382 // Creates and returns the pointer of the unique instance
383 // Must be called only when the environment has changed
385 if(!fgObjGetter){ // first time the getter is called
386 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
388 else { // the getter has been called previously
389 AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle());
390 if ( rl->GetFileName() == alirunFileName ) {// the alirunFile has the same name
391 // check if the file is already open
392 TFile * galiceFile = dynamic_cast<TFile *>(gROOT->FindObject(rl->GetFileName()) ) ;
395 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
397 else { // the file is already open check the version name
398 TString currentVersionName = rl->GetEventFolder()->GetName() ;
399 TString newVersionName(version) ;
400 if (currentVersionName == newVersionName)
402 ::Warning( "Instance", "Files with version %s already open", currentVersionName.Data() ) ;
404 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
409 AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle()) ;
410 if ( strstr(version, AliConfig::GetDefaultEventFolderName()) ) // false in case of merging
412 fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
416 ::Error("AliPHOSGetter::Instance", "Failed to create the PHOS Getter object") ;
424 //____________________________________________________________________________
425 AliPHOSGetter * AliPHOSGetter::Instance()
427 // Returns the pointer of the unique instance already defined
429 if(!fgObjGetter && fgDebug)
430 ::Warning("AliPHOSGetter::Instance", "Getter not initialized") ;
436 //____________________________________________________________________________
437 Int_t AliPHOSGetter::MaxEvent() const
439 // returns the number of events in the run (from TE)
441 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
442 return static_cast<Int_t>(rl->GetNumberOfEvents()) ;
445 //____________________________________________________________________________
446 TParticle * AliPHOSGetter::Primary(Int_t index) const
448 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
449 return rl->Stack()->Particle(index) ;
452 //____________________________________________________________________________
453 AliPHOS * AliPHOSGetter:: PHOS() const
455 // returns the PHOS object
456 AliPHOSLoader * loader = 0;
457 static AliPHOSLoader * oldloader = 0;
458 static AliPHOS * phos = 0;
460 loader = PhosLoader();
462 if ( loader != oldloader) {
463 phos = dynamic_cast<AliPHOS*>(loader->GetModulesFolder()->FindObject("PHOS")) ;
468 Warning("PHOS", "PHOS module not found in module folders: %s", PhosLoader()->GetModulesFolder()->GetName() ) ;
474 //____________________________________________________________________________
475 AliPHOSPID * AliPHOSGetter::PID()
477 // Returns pointer to the PID task
479 rv = dynamic_cast<AliPHOSPID *>(PhosLoader()->PIDTask()) ;
482 rv = dynamic_cast<AliPHOSPID *>(PhosLoader()->PIDTask()) ;
487 //____________________________________________________________________________
488 AliPHOSGeometry * AliPHOSGetter::PHOSGeometry() const
490 // Returns PHOS geometry
492 AliPHOSGeometry * rv = 0 ;
494 rv = PHOS()->GetGeometry() ;
498 //____________________________________________________________________________
499 TClonesArray * AliPHOSGetter::Primaries()
501 // creates the Primaries container if needed
504 Info("Primaries", "Creating a new TClonesArray for primaries") ;
505 fPrimaries = new TClonesArray("TParticle", 1000) ;
510 //____________________________________________________________________________
511 void AliPHOSGetter::Print()
513 // Print usefull information about the getter
515 AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle());
516 ::Info( "Print", "gAlice file is %s -- version name is %s", (rl->GetFileName()).Data(), rl->GetEventFolder()->GetName() ) ;
519 //____________________________________________________________________________
520 void AliPHOSGetter::ReadPrimaries()
522 // Read Primaries from Kinematics.root
524 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
526 // gets kine tree from the root file (Kinematics.root)
527 if ( ! rl->TreeK() ) { // load treeK the first time
528 rl->LoadKinematics() ;
531 fNPrimaries = (rl->GetHeader())->GetNtrack();
533 Info( "ReadTreeK", "Found %d particles in event # %d", fNPrimaries, EventNumber() ) ;
536 // first time creates the container
538 fPrimaries->Clear() ;
541 for (index = 0 ; index < fNPrimaries; index++) {
542 new ((*fPrimaries)[index]) TParticle(*(Primary(index)));
546 //____________________________________________________________________________
547 Bool_t AliPHOSGetter::OpenESDFile()
552 fESDFile = TFile::Open(fESDFileName) ;
556 else if (fESDFile->IsOpen()) {
558 fESDFile = TFile::Open(fESDFileName) ;
560 if (!fESDFile->IsOpen())
565 //____________________________________________________________________________
566 void AliPHOSGetter::FitRaw(Bool_t lowGainFlag, TGraph * gLowGain, TGraph * gHighGain, TF1* signalF, Double_t & energy, Double_t & time)
568 // Fits the raw signal time distribution
570 const Int_t kNoiseThreshold = 0 ;
571 Double_t timezero1 = 0., timezero2 = 0., timemax = 0. ;
572 Double_t signal = 0., signalmax = 0. ;
577 timezero1 = timezero2 = signalmax = timemax = 0. ;
578 signalF->FixParameter(0, PHOS()->GetRawFormatLowCharge()) ;
579 signalF->FixParameter(1, PHOS()->GetRawFormatLowGain()) ;
581 for (index = 0; index < PHOS()->GetRawFormatTimeBins(); index++) {
582 gLowGain->GetPoint(index, time, signal) ;
583 if (signal > kNoiseThreshold && timezero1 == 0.)
585 if (signal <= kNoiseThreshold && timezero1 > 0. && timezero2 == 0.)
587 if (signal > signalmax) {
592 signalmax /= PHOS()->RawResponseFunctionMax(PHOS()->GetRawFormatLowCharge(),
593 PHOS()->GetRawFormatLowGain()) ;
594 if ( timezero1 + PHOS()->GetRawFormatTimePeak() < PHOS()->GetRawFormatTimeMax() * 0.4 ) { // else its noise
595 signalF->SetParameter(2, signalmax) ;
596 signalF->SetParameter(3, timezero1) ;
597 gLowGain->Fit(signalF, "QRON", "", 0., timezero2); //, "QRON") ;
598 energy = signalF->GetParameter(2) ;
599 time = signalF->GetMaximumX() - PHOS()->GetRawFormatTimePeak() - PHOS()->GetRawFormatTimeTrigger() ;
602 timezero1 = timezero2 = signalmax = timemax = 0. ;
603 signalF->FixParameter(0, PHOS()->GetRawFormatHighCharge()) ;
604 signalF->FixParameter(1, PHOS()->GetRawFormatHighGain()) ;
606 for (index = 0; index < PHOS()->GetRawFormatTimeBins(); index++) {
607 gHighGain->GetPoint(index, time, signal) ;
608 if (signal > kNoiseThreshold && timezero1 == 0.)
610 if (signal <= kNoiseThreshold && timezero1 > 0. && timezero2 == 0.)
612 if (signal > signalmax) {
617 signalmax /= PHOS()->RawResponseFunctionMax(PHOS()->GetRawFormatHighCharge(),
618 PHOS()->GetRawFormatHighGain()) ;;
619 if ( timezero1 + PHOS()->GetRawFormatTimePeak() < PHOS()->GetRawFormatTimeMax() * 0.4 ) { // else its noise
620 signalF->SetParameter(2, signalmax) ;
621 signalF->SetParameter(3, timezero1) ;
622 gHighGain->Fit(signalF, "QRON", "", 0., timezero2) ;
623 energy = signalF->GetParameter(2) ;
624 time = signalF->GetMaximumX() - PHOS()->GetRawFormatTimePeak() - PHOS()->GetRawFormatTimeTrigger() ;
627 if (time == 0) energy = 0 ;
630 //____________________________________________________________________________
631 Int_t AliPHOSGetter::CalibrateRaw(Double_t energy, Int_t *relId)
633 // Convert energy into digitized amplitude for a cell relId
634 // It is a user responsilibity to open CDB and set
635 // AliPHOSCalibData object by the following operators:
637 // AliCDBLocal *loc = new AliCDBLocal("deCalibDB");
638 // AliPHOSCalibData* clb = (AliPHOSCalibData*)AliCDBStorage::Instance()
639 // ->Get(path_to_calibdata,run_number);
640 // AliPHOSGetter* gime = AliPHOSGetter::Instance("galice.root");
641 // gime->SetCalibData(clb);
643 if (CalibData() == 0)
644 Warning("CalibrateRaw","Calibration DB is not initiated!");
646 Int_t module = relId[0];
647 Int_t column = relId[3];
648 Int_t row = relId[2];
650 Float_t gainFactor = 0.0015; // width of one Emc ADC channel in GeV
651 Float_t pedestal = 0.005; // Emc pedestals
654 gainFactor = CalibData()->GetADCchannelEmc (module,column,row);
655 pedestal = CalibData()->GetADCpedestalEmc(module,column,row);
658 Int_t amp = static_cast<Int_t>( (energy - pedestal) / gainFactor + 0.5 ) ;
661 //____________________________________________________________________________
662 Int_t AliPHOSGetter::ReadRaw(AliRawReader *rawReader)
664 // reads the raw format data, converts it into digits format and store digits in Digits()
667 AliPHOSRawStream in(rawReader);
669 Bool_t first = kTRUE ;
671 TF1 * signalF = new TF1("signal", AliPHOS::RawResponseFunction, 0, PHOS()->GetRawFormatTimeMax(), 4);
672 signalF->SetParNames("Charge", "Gain", "Amplitude", "TimeZero") ;
674 Int_t relId[4], id =0;
675 Bool_t lowGainFlag = kFALSE ;
677 TClonesArray * digits = Digits() ;
681 Double_t energy = 0. ;
684 TGraph * gLowGain = new TGraph(PHOS()->GetRawFormatTimeBins()) ;
685 TGraph * gHighGain= new TGraph(PHOS()->GetRawFormatTimeBins()) ;
687 while ( in.Next() ) { // PHOS entries loop
688 if ( (in.IsNewRow() || in.IsNewColumn() || in.IsNewModule()) ) {
689 relId[0] = in.GetModule() ;
690 if ( relId[0] >= PHOS()->GetRawFormatLowGainOffset() ) {
691 relId[0] -= PHOS()->GetRawFormatLowGainOffset() ;
692 lowGainFlag = kTRUE ;
694 lowGainFlag = kFALSE ;
696 relId[2] = in.GetRow() ;
697 relId[3] = in.GetColumn() ;
698 PHOSGeometry()->RelToAbsNumbering(relId, id) ;
700 FitRaw(lowGainFlag, gLowGain, gHighGain, signalF, energy, time) ;
701 amp = CalibrateRaw(energy,relId);
703 new((*digits)[idigit]) AliPHOSDigit( -1, id, amp, time) ;
707 for (index = 0; index < PHOS()->GetRawFormatTimeBins(); index++) {
708 gLowGain->SetPoint(index, index * PHOS()->GetRawFormatTimeMax() / PHOS()->GetRawFormatTimeBins(), 0) ;
709 gHighGain->SetPoint(index, index * PHOS()->GetRawFormatTimeMax() / PHOS()->GetRawFormatTimeBins(), 0) ;
715 gLowGain->SetPoint(in.GetTime(),
716 in.GetTime()* PHOS()->GetRawFormatTimeMax() / PHOS()->GetRawFormatTimeBins(),
719 gHighGain->SetPoint(in.GetTime(),
720 in.GetTime() * PHOS()->GetRawFormatTimeMax() / PHOS()->GetRawFormatTimeBins(),
723 } // PHOS entries loop
725 FitRaw(lowGainFlag, gLowGain, gHighGain, signalF, energy, time) ;
726 amp = CalibrateRaw(energy,relId);
728 new((*digits)[idigit]) AliPHOSDigit( -1, id, amp, time) ;
737 // AliInfo(Form("Event %d, digits: %d\n", EventNumber(),digits->GetEntries())); //bvp
738 return digits->GetEntriesFast() ;
741 // TClonesArray * digits = Digits() ;
743 // Int_t idigit = 0 ;
745 // while ( in.Next() ) { // PHOS entries loop
747 // Int_t amp = in.GetSignal() ;
748 // Double_t time = in.GetTime() ;
749 // Int_t relId[4], id ;
751 // relId[0] = in.GetModule() ;
752 // if ( relId[0] >= PHOS()->GetRawFormatLowGainOffset() ) {
753 // relId[0] -= PHOS()->GetRawFormatLowGainOffset() ;
756 // relId[2] = in.GetRow() ;
757 // relId[3] = in.GetColumn() ;
758 // PHOSGeometry()->RelToAbsNumbering(relId, id) ;
760 // if (amp > 0 && id >=0 ) {
761 // new((*digits)[idigit]) AliPHOSDigit( -1, id, amp, time) ;
765 // } // PHOS entries loop
769 // return digits->GetEntriesFast() ;
771 //____________________________________________________________________________
772 Int_t AliPHOSGetter::ReadTreeD()
776 PhosLoader()->CleanDigits() ;
777 PhosLoader()->LoadDigits("UPDATE") ;
778 PhosLoader()->LoadDigitizer("UPDATE") ;
779 return Digits()->GetEntries() ;
782 //____________________________________________________________________________
783 Int_t AliPHOSGetter::ReadTreeH()
786 PhosLoader()->CleanHits() ;
787 // gets TreeH from the root file (PHOS.Hit.root)
788 //if ( !IsLoaded("H") ) {
789 PhosLoader()->LoadHits("UPDATE") ;
792 return Hits()->GetEntries() ;
795 //____________________________________________________________________________
796 Int_t AliPHOSGetter::ReadTreeR()
798 // Read the RecPoints
800 PhosLoader()->CleanRecPoints() ;
801 // gets TreeR from the root file (PHOS.RecPoints.root)
802 //if ( !IsLoaded("R") ) {
803 PhosLoader()->LoadRecPoints("UPDATE") ;
804 PhosLoader()->LoadClusterizer("UPDATE") ;
808 return EmcRecPoints()->GetEntries() ;
811 //____________________________________________________________________________
812 Int_t AliPHOSGetter::ReadTreeT()
814 // Read the TrackSegments
816 PhosLoader()->CleanTracks() ;
817 // gets TreeT from the root file (PHOS.TrackSegments.root)
818 //if ( !IsLoaded("T") ) {
819 PhosLoader()->LoadTracks("UPDATE") ;
820 PhosLoader()->LoadTrackSegmentMaker("UPDATE") ;
824 return TrackSegments()->GetEntries() ;
826 //____________________________________________________________________________
827 Int_t AliPHOSGetter::ReadTreeP()
829 // Read the RecParticles
831 PhosLoader()->CleanRecParticles() ;
833 // gets TreeT from the root file (PHOS.TrackSegments.root)
834 // if ( !IsLoaded("P") ) {
835 PhosLoader()->LoadRecParticles("UPDATE") ;
836 PhosLoader()->LoadPID("UPDATE") ;
840 return RecParticles()->GetEntries() ;
842 //____________________________________________________________________________
843 Int_t AliPHOSGetter::ReadTreeS()
847 PhosLoader()->CleanSDigits() ;
848 // gets TreeS from the root file (PHOS.SDigits.root)
849 //if ( !IsLoaded("S") ) {
850 PhosLoader()->LoadSDigits("READ") ;
851 PhosLoader()->LoadSDigitizer("READ") ;
855 return SDigits()->GetEntries() ;
858 //____________________________________________________________________________
859 Int_t AliPHOSGetter::ReadTreeE(Int_t event)
863 // gets esdTree from the root file (AliESDs.root)
865 if ( !OpenESDFile() )
868 fESDTree = static_cast<TTree*>(fESDFile->Get("esdTree")) ;
872 Error("ReadTreeE", "no ESD tree found");
875 fESDTree->SetBranchAddress("ESD", &fESD);
876 fESDTree->GetEvent(event);
881 //____________________________________________________________________________
882 TClonesArray * AliPHOSGetter::SDigits()
884 // asks the Loader to return the Digits container
886 TClonesArray * rv = 0 ;
888 rv = PhosLoader()->SDigits() ;
890 PhosLoader()->MakeSDigitsArray() ;
891 rv = PhosLoader()->SDigits() ;
896 //____________________________________________________________________________
897 AliPHOSSDigitizer * AliPHOSGetter::SDigitizer()
899 // Returns pointer to the SDigitizer task
900 AliPHOSSDigitizer * rv ;
901 rv = dynamic_cast<AliPHOSSDigitizer *>(PhosLoader()->SDigitizer()) ;
904 rv = dynamic_cast<AliPHOSSDigitizer *>(PhosLoader()->SDigitizer()) ;
909 //____________________________________________________________________________
910 TParticle * AliPHOSGetter::Secondary(const TParticle* p, Int_t index) const
912 // Return first (index=1) or second (index=2) secondary particle of primary particle p
920 Int_t daughterIndex = p->GetDaughter(index-1) ;
921 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
922 return rl->GetAliRun()->GetMCApp()->Particle(daughterIndex) ;
928 //____________________________________________________________________________
929 void AliPHOSGetter::Track(Int_t itrack)
931 // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
933 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
935 if( !TreeH() ) // load treeH the first time
938 // first time create the container
939 TClonesArray * hits = Hits() ;
943 TBranch * phosbranch = dynamic_cast<TBranch*>(TreeH()->GetBranch("PHOS")) ;
944 phosbranch->SetAddress(&hits) ;
945 phosbranch->GetEntry(itrack) ;
948 //____________________________________________________________________________
949 TTree * AliPHOSGetter::TreeD() const
951 // Returns pointer to the Digits Tree
953 rv = PhosLoader()->TreeD() ;
955 PhosLoader()->MakeTree("D");
956 rv = PhosLoader()->TreeD() ;
962 //____________________________________________________________________________
963 TTree * AliPHOSGetter::TreeH() const
965 // Returns pointer to the Hits Tree
967 rv = PhosLoader()->TreeH() ;
969 PhosLoader()->MakeTree("H");
970 rv = PhosLoader()->TreeH() ;
976 //____________________________________________________________________________
977 TTree * AliPHOSGetter::TreeR() const
979 // Returns pointer to the RecPoints Tree
981 rv = PhosLoader()->TreeR() ;
983 PhosLoader()->MakeTree("R");
984 rv = PhosLoader()->TreeR() ;
990 //____________________________________________________________________________
991 TTree * AliPHOSGetter::TreeT() const
993 // Returns pointer to the TrackSegments Tree
995 rv = PhosLoader()->TreeT() ;
997 PhosLoader()->MakeTree("T");
998 rv = PhosLoader()->TreeT() ;
1003 //____________________________________________________________________________
1004 TTree * AliPHOSGetter::TreeP() const
1006 // Returns pointer to the RecParticles Tree
1008 rv = PhosLoader()->TreeP() ;
1010 PhosLoader()->MakeTree("P");
1011 rv = PhosLoader()->TreeP() ;
1017 //____________________________________________________________________________
1018 TTree * AliPHOSGetter::TreeS() const
1020 // Returns pointer to the SDigits Tree
1022 rv = PhosLoader()->TreeS() ;
1024 PhosLoader()->MakeTree("S");
1025 rv = PhosLoader()->TreeS() ;
1031 //____________________________________________________________________________
1032 Bool_t AliPHOSGetter::VersionExists(TString & opt) const
1034 // checks if the version with the present name already exists in the same directory
1036 Bool_t rv = kFALSE ;
1038 AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
1039 TString version( rl->GetEventFolder()->GetName() ) ;
1043 if ( opt == "sdigits") {
1044 // add the version name to the root file name
1045 TString fileName( PhosLoader()->GetSDigitsFileName() ) ;
1046 if (version != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
1047 fileName = fileName.ReplaceAll(".root", "") + "_" + version + ".root" ;
1048 if ( !(gSystem->AccessPathName(fileName)) ) {
1049 Warning("VersionExists", "The file %s already exists", fileName.Data()) ;
1052 PhosLoader()->SetSDigitsFileName(fileName) ;
1055 if ( opt == "digits") {
1056 // add the version name to the root file name
1057 TString fileName( PhosLoader()->GetDigitsFileName() ) ;
1058 if (version != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
1059 fileName = fileName.ReplaceAll(".root", "") + "_" + version + ".root" ;
1060 if ( !(gSystem->AccessPathName(fileName)) ) {
1061 Warning("VersionExists", "The file %s already exists", fileName.Data()) ;
1070 //____________________________________________________________________________
1071 UShort_t AliPHOSGetter::EventPattern(void) const
1073 // Return the pattern (trigger bit register) of the beam-test event
1075 return fBTE->GetPattern() ;
1079 //____________________________________________________________________________
1080 Float_t AliPHOSGetter::BeamEnergy(void) const
1082 // Return the beam energy of the beam-test event
1084 return fBTE->GetBeamEnergy() ;
1088 //____________________________________________________________________________
1090 AliPHOSCalibData* AliPHOSGetter::CalibData()
1092 // Check if the instance of AliPHOSCalibData exists, and return it
1094 if( !(AliCDBManager::Instance()->IsDefaultStorageSet()) )
1098 //____________________________________________________________________________
1100 AliPHOSAlignData* AliPHOSGetter::AlignData()
1102 // Check if the instance of AliPHOSAlignData exists, and return it
1104 if( !(AliCDBManager::Instance()->IsDefaultStorageSet()) )