// --- ROOT system ---
-#include "TClonesArray.h"
-#include "TFolder.h"
-#include "TTree.h"
-#include "TFile.h"
-class TString ;
+#include "TObject.h"
class TParticle ;
-class TTask ;
+class TTree ;
+class TGraph ;
+class TF1 ;
// --- Standard library ---
-#include <stdlib.h>
-#include <iostream.h>
// --- AliRoot header files ---
-
-#include "AliRun.h"
-#include "AliPHOS.h"
+#include "AliConfig.h"
+#include "AliPHOSLoader.h"
#include "AliPHOSHit.h"
#include "AliPHOSDigit.h"
-#include "AliPHOSEmcRecPoint.h"
-#include "AliPHOSCpvRecPoint.h"
-#include "AliPHOSTrackSegment.h"
-#include "AliPHOSRecParticle.h"
+#include "AliPHOSEmcRecPoint.h"
+#include "AliPHOSCpvRecPoint.h"
+#include "AliPHOSTrackSegment.h"
+#include "AliPHOSRecParticle.h"
+#include "AliPHOSDigitizer.h"
+#include "AliPHOSSDigitizer.h"
+#include "AliPHOSCalibData.h"
+
+class AliPHOS ;
class AliPHOSGeometry ;
-class AliPHOSDigitizer ;
-class AliPHOSSDigitizer ;
class AliPHOSClusterizer ;
-class AliPHOSTrackSegmentMaker ;
-class AliPHOSPID ;
+class AliPHOSTrackSegmentMaker ;
+class AliPHOSPID ;
+class AliPHOSBeamTestEvent ;
+class AliESD ;
+class AliRawReader ;
class AliPHOSGetter : public TObject {
- public:
-
- AliPHOSGetter(){ // ctor: this is a singleton, the ctor should never be called but cint needs it as public
- cerr << "ERROR: AliPHOSGetter is a singleton default ctor not callable" << endl ;
- abort() ;
- }
- AliPHOSGetter(const AliPHOSGetter & obj) {
- // cpy ctor requested by Coding Convention
- // but not yet needed
- abort() ;
- }
-
+public:
+ // ctor: this is a singleton, the ctor should never be called but cint needs it as public
+ AliPHOSGetter() ;
+
+public:
+ AliPHOSGetter(const AliPHOSGetter & obj) ;
AliPHOSGetter & operator = (const AliPHOSGetter & ) {
// assignement operator requested by coding convention, but not needed
- abort() ;
+ Fatal("operator =", "not implemented") ;
return *this ;
}
virtual ~AliPHOSGetter() ;
//=========== Instantiators ================
- static AliPHOSGetter * GetInstance(const char* headerFile,
- const char* branchTitle = "Default",
- const Bool_t toSplit = kFALSE ) ;
- static AliPHOSGetter * GetInstance() ;
+ static AliPHOSGetter * Instance(const char* headerFile,
+ const char* version = AliConfig::GetDefaultEventFolderName(),
+ Option_t * openingOption = "READ" ) ;
+ static AliPHOSGetter * Instance() ;
+
+ void Print(const Option_t *)const{}
+ static void Print() ;
//=========== General information about run ==============
- const Int_t MaxEvent() const { return static_cast<Int_t>(gAlice->TreeE()->GetEntries()) ; }
- const Int_t EventNumber() const { return static_cast<Int_t>(gAlice->GetEvNumber()) ; }
- const Bool_t BranchExists(const TString tree) const ;
+ virtual Bool_t IsLoaded(TString tree) const { return fLoadingStatus.Contains(tree) ; }
+ virtual void SetLoaded(TString tree) { fLoadingStatus += tree ; }
+
+ virtual Int_t MaxEvent() const ;
+ virtual Int_t EventNumber() const ;
+ virtual Bool_t VersionExists(TString & opt) const ;
+ virtual UShort_t EventPattern(void) const ;
+ virtual Float_t BeamEnergy(void) const ;
//========== PHOSGeometry and PHOS =============
- const AliPHOS * PHOS() ;
- const AliPHOSGeometry * PHOSGeometry() ;
+ virtual AliPHOS * PHOS() const ;
+ virtual AliPHOSGeometry * PHOSGeometry() const ;
//========== Methods to read something from file ==========
- void Event(const Int_t event, const char * opt = "HSDRP") ;
- void Track(const Int_t itrack) ;
- void ReadTreeS(TTree * treeS,Int_t input) ; //Method to be used when
- //digitizing is under the control ofAliRunDigitizer,
- //which opens all files etc.
- //========== Alarms ======================
- TFolder * Alarms() const { return dynamic_cast<TFolder*>(ReturnO("Alarms", 0)) ; }
- const TObjArray * Alarms(const char * name ) const { return dynamic_cast<const TObjArray*>(ReturnO("Alarms", name)) ; }
- const TTask * QATasks(const char * name = 0) const { return ReturnT("QATasks", name) ; }
+ virtual void Event(Int_t event, const char * opt = "HSDRTP") ;
+ void Event(AliRawReader *rawReader, const char * opt = "W",Bool_t isOldRCUFormat = kFALSE) ;
+ virtual void Track(Int_t itrack) ;
+
//-----------------now getter's data--------------------------------------
+ AliPHOSCalibrationDB * CalibrationDB(){return fcdb; }
+ void ReadCalibrationDB(const char * /*name*/, const char * /*filename*/){ ;}
+ void SetCalibrationDB(AliPHOSCalibrationDB * cdb) {fcdb = cdb ;}
+ void SetCalibData(AliPHOSCalibData* calibda) { fgCalibData = calibda; }
+ AliPHOSCalibData * CalibData();
+
//=========== Primaries ============
- TTree * TreeK(TString filename="") ;
- TClonesArray * Primaries(void) const { return dynamic_cast<TClonesArray*>(ReturnO("Primaries")) ; }
- const TParticle * Primary(Int_t index) const ;
- const Int_t NPrimaries()const { return fNPrimaries; }
- const TParticle * Secondary(TParticle * p, Int_t index=1) const ;
+ virtual TClonesArray * Primaries(void) ;
+ virtual TParticle * Primary(Int_t index) const ;
+ virtual Int_t NPrimaries()const { return fNPrimaries; }
+ virtual TParticle * Secondary(const TParticle * p, Int_t index=1) const ;
//=========== Hits =================
- TTree * TreeH(TString filename="") ;
- const TClonesArray * Hits(void) { return dynamic_cast<const TClonesArray*>(ReturnO("Hits")) ; }
- const AliPHOSHit * Hit(Int_t index) { return dynamic_cast<const AliPHOSHit*>(Hits()->At(index) );}
+ virtual TClonesArray * Hits(void) const ;
+ virtual AliPHOSHit * Hit(Int_t index) const { return dynamic_cast<AliPHOSHit*>(Hits()->At(index) );}
+ virtual TTree * TreeH() const ;
//=========== SDigits ==============
- TTree * TreeS(TString filename="") ;
- TClonesArray * SDigits(const char * name = 0, const char * file=0) {
- return dynamic_cast<TClonesArray*>(ReturnO("SDigits", name, file)) ; }
- //const AliPHOSDigit * SDigit(Int_t index) { return static_cast<const AliPHOSDigit *>(SDigits()->At(index)) ;} !!! why no such method ?
- const AliPHOSSDigitizer * SDigitizer(const char * name =0) const {
- return (const AliPHOSSDigitizer *) ReturnT("SDigitizer", name) ; // here static or dynamic cast does not work ! why ?
- }
+ virtual TClonesArray * SDigits() const ;
+ virtual AliPHOSDigit * SDigit(Int_t index) const { return static_cast<AliPHOSDigit *>(SDigits()->At(index)) ;}
+ virtual TTree * TreeS() const ;
+ virtual AliPHOSSDigitizer * SDigitizer() ;
+
+ virtual TString GetSDigitsFileName() const { return PhosLoader()->GetSDigitsFileName() ; }
+ virtual Int_t LoadSDigits(Option_t* opt="") const { return PhosLoader()->LoadSDigits(opt) ; }
+ virtual Int_t LoadSDigitizer(Option_t* opt="") const { return PhosLoader()->LoadSDigitizer(opt) ; }
+ virtual Int_t WriteSDigits(Option_t* opt="") const { return PhosLoader()->WriteSDigits(opt) ; }
+ virtual Int_t WriteSDigitizer(Option_t* opt="") const {
+ return PhosLoader()->WriteSDigitizer(opt) ; }
//========== Digits ================
- TTree * TreeD(TString filename="") ;
- TClonesArray * Digits(const char * name = 0)const {
- return dynamic_cast<TClonesArray*>(ReturnO("Digits", name)) ; }
- //const AliPHOSDigit * Digit(Int_t index) { return static_cast<const AliPHOSDigit *>(Digits()->At(index)) ;} !!! why no such method ?
- const AliPHOSDigitizer * Digitizer(const char * name = 0) const {
- return (const AliPHOSDigitizer*)(ReturnT("Digitizer", name)) ; }
+ virtual TClonesArray * Digits() const ;
+ virtual AliPHOSDigit * Digit(Int_t index) const { return static_cast<AliPHOSDigit *>(Digits()->At(index)) ;}
+ virtual TTree * TreeD() const ;
+ virtual AliPHOSDigitizer * Digitizer() ;
+ virtual TString GetDigitsFileName() const { return PhosLoader()->GetDigitsFileName() ; }
+ virtual Int_t LoadDigits(Option_t* opt="") const { return PhosLoader()->LoadDigits(opt) ; }
+ virtual Int_t LoadDigitizer(Option_t* opt="") const {
+ return PhosLoader()->LoadDigitizer(opt) ; }
+ virtual Int_t WriteDigits(Option_t* opt="") const { return PhosLoader()->WriteDigits(opt) ; }
+ virtual Int_t WriteDigitizer(Option_t* opt="") const {
+ return PhosLoader()->WriteDigitizer(opt) ; }
+
+ //Methods to distinguish raw and simulated digits
+ virtual Bool_t IsRawDigits(void) const {return fRawDigits;}
+ virtual void SetRawDigits(Bool_t isRaw = kTRUE){fRawDigits = isRaw;}
//========== RecPoints =============
- TObjArray * EmcRecPoints(const char * name = 0) {
- return dynamic_cast<TObjArray*>(ReturnO("EmcRecPoints", name)) ; }
- //const AliPHOSEmcRecPoint * EmcRecPoint(Int_t index) { return static_cast<const AliPHOSEmcRecPoint *>(EmcRecPoints()->At(index)) ;} !!! why no such method ?
- TObjArray * CpvRecPoints(const char * name = 0) {
- return dynamic_cast<TObjArray*>(ReturnO("CpvRecPoints", name)) ; }
- const AliPHOSClusterizer * Clusterizer (const char * name =0) const {
- return (const AliPHOSClusterizer*)(ReturnT("Clusterizer", name)) ; // here static or dynamic cast does not work ! why ?
- }
-
- //========== TrackSegments ==========
- TClonesArray * TrackSegments(const char * name = 0) {
- return static_cast<TClonesArray*>(ReturnO("TrackSegments", name)) ; }
- const AliPHOSTrackSegmentMaker * TrackSegmentMaker (const char * name =0) const {
- return (const AliPHOSTrackSegmentMaker*)(ReturnT("TrackSegmentMaker", name)) ; }
+ virtual TObjArray * EmcRecPoints() const;
+ virtual AliPHOSEmcRecPoint * EmcRecPoint(Int_t index) const { return static_cast<AliPHOSEmcRecPoint *>(EmcRecPoints()->At(index)) ;}
+ virtual TObjArray * CpvRecPoints() const ;
+ virtual AliPHOSCpvRecPoint * CpvRecPoint(Int_t index) const { return static_cast<AliPHOSCpvRecPoint *>(CpvRecPoints()->At(index)) ;}
+ virtual TTree * TreeR() const ;
+ virtual AliPHOSClusterizer * Clusterizer() ;
+ virtual TString GetRecPointsFileName() const { return PhosLoader()->GetRecPointsFileName() ; }
+ virtual Int_t LoadRecPoints(Option_t* opt="") const { return PhosLoader()->LoadRecPoints(opt) ; }
+ virtual Int_t WriteRecPoints(Option_t* opt="") const { return PhosLoader()->WriteRecPoints(opt) ; }
+
+ //========== TrackSegments TClonesArray * TrackSegments(const char * name = 0) {
+ virtual TClonesArray * TrackSegments() const;
+ virtual AliPHOSTrackSegment * TrackSegment(Int_t index) const { return static_cast<AliPHOSTrackSegment *>(TrackSegments()->At(index)) ;}
+ virtual TTree * TreeT() const ;
+ virtual AliPHOSTrackSegmentMaker * TrackSegmentMaker() ;
+ virtual TString GetTracksFileName() const { return PhosLoader()->GetTracksFileName() ; }
+ virtual Int_t LoadTracks(Option_t* opt="") const { return PhosLoader()->LoadTracks(opt) ; }
+ virtual Int_t LoadTrackSegementMaker(Option_t* opt="") const {
+ return PhosLoader()->LoadTrackSegmentMaker(opt) ; }
+ virtual Int_t WriteTracks(Option_t* opt="") const { return PhosLoader()->WriteTracks(opt) ; }
+ virtual Int_t WriteTrackSegmentMaker(Option_t* opt="") const {
+ return PhosLoader()->WriteTracker(opt) ; }
//========== RecParticles ===========
- TClonesArray * RecParticles(const char * name = 0) {
- return static_cast<TClonesArray*>(ReturnO("RecParticles", name)) ; }
- const AliPHOSPID * PID(const char * name =0) const {
- return (const AliPHOSPID*)(ReturnT("PID", name)) ; } // here static or dynamic cast does not work ! why ?
-
- //-----------------Auxiliary methods: cleaners-----------------
- void RemoveTask(TString opt, TString name) const ;
- void RemoveObjects(TString opt, TString name) const ;
- void RemoveSDigits() const ;
-
- //----------------Auxiliary methods: miscellana----------------
- void CloseFile() ;
- const TFolder * Folder(const TString what) const ;
- const Bool_t HasFailed() const { return fFailed ; }
- void ListBranches(Int_t event=0) const ;
- void NewBranch(TString name, Int_t event = 0) ;
- Bool_t NewFile(TString name) ;
- TFolder * SDigitsFolder() { return dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("PHOS")) ; }
- void SetDebug(Int_t level) {fDebug = level;} // Set debug level
- void SetRecParticlesTitle(const TString title) { fRecParticlesTitle = title ; }
-
- //------------Auxiliary methods: Posters--------------------
- const Bool_t PostPrimaries(void ) const ;
- const Bool_t PostHits(void ) const ;
- const Bool_t PostSDigits( const char * name, const char * file = 0) const ;
- const Bool_t PostDigits( const char * name ) const ;
- const Bool_t PostRecPoints( const char * name ) const ;
- const Bool_t PostTrackSegments(const char * name) const ;
- const Bool_t PostRecParticles( const char * name) const ;
- const Bool_t PostClusterizer( const char * name) const ;
- const Bool_t PostClusterizer(AliPHOSClusterizer * clu) const ;
- const Bool_t PostSDigitizer (AliPHOSSDigitizer * sdigitizer) const ;
- const Bool_t PostSDigitizer ( const char * name, const char * file ) const ;
- const Bool_t PostDigitizer (AliPHOSDigitizer * digitizer) const ;
- const Bool_t PostDigitizer ( const char * name) const ;
- const Bool_t PostTrackSegmentMaker(AliPHOSTrackSegmentMaker * tsm) const ;
- const Bool_t PostTrackSegmentMaker(const char * name ) const ;
- const Bool_t PostPID (AliPHOSPID * pid) const ;
- const Bool_t PostPID (const char * name ) const ;
- const Bool_t PostQA (void) const ;
-
+ virtual TClonesArray * RecParticles() const;
+ virtual AliPHOSRecParticle * RecParticle(Int_t index) const { return static_cast<AliPHOSRecParticle *>(RecParticles()->At(index)) ;}
+ virtual TTree * TreeP() const ;
+ virtual AliPHOSPID * PID() ;
+ virtual TString GetRecParticlesFileName() const { return PhosLoader()->GetRecParticlesFileName() ; }
+ virtual Int_t LoadRecParticles(Option_t* opt="") const { return PhosLoader()->LoadRecParticles(opt) ; }
+ virtual Int_t LoadPID(Option_t* opt="") const {
+ return PhosLoader()->LoadPID(opt) ; }
+ virtual Int_t WriteRecParticles(Option_t* opt="") const { return PhosLoader()->WriteRecParticles(opt) ; }
+ virtual Int_t WritePID(Option_t* opt="") const {
+ return PhosLoader()->WritePID(opt) ; }
+
+ //========== Raw ===========
+ virtual Int_t ReadRaw(AliRawReader *rawReader,Bool_t isOldRCUFormat) ;
+
+ void SetDebug(Int_t level) {fgDebug = level;} // Set debug level
+ virtual void PostSDigitizer (AliPHOSSDigitizer * sdigitizer)
+ const {PhosLoader()->PostSDigitizer(sdigitizer);}
+ virtual void PostDigitizer (AliPHOSDigitizer * digitizer)
+ const {PhosLoader()->PostDigitizer(digitizer);}
+
+ virtual TString Version() const { return PhosLoader()->GetTitle() ; }
+ virtual AliPHOSLoader * PhosLoader() const { return fgPhosLoader ; }
+ virtual void Reset() ;
+
+ virtual AliESD * ESD() const { return fESD ; }
+
+protected :
+ AliPHOSGetter(Int_t /*i*/) ;
+
+protected:
+ static AliPHOSGetter * fgObjGetter; // pointer to the unique instance of the singleton
+
+private:
+ AliPHOSGetter(const char* headerFile,
+ const char* version = AliConfig::GetDefaultEventFolderName(),
+ Option_t * openingOption = "READ") ;
private:
- AliPHOSGetter(const char* headerFile, const char* branchTitle ="Default", const Bool_t toSplit = kFALSE) ;
- TObject * ReturnO(TString what, TString name=0, TString file=0) const ;
- const TTask * ReturnT(TString what,TString name=0) const ;
- void DefineBranchTitles(char* branch, char* branchTitle) ;
- Int_t ReadTreeD(const Int_t event) ;
- Int_t ReadTreeH(void) ;
- Int_t ReadTreeR(const Int_t event) ;
- Int_t ReadTreeS(const Int_t event) ;
- void ReadTreeQA(void) ;
+ Int_t ReadTreeD(void) const ;
+ Int_t ReadTreeH(void) const ;
+ Int_t ReadTreeR(void) const ;
+ Int_t ReadTreeT(void) const ;
+ Int_t ReadTreeS(void) const ;
+ Int_t ReadTreeP(void) const ;
+
+ Int_t ReadTreeE(Int_t event) ;
+ Bool_t OpenESDFile() ;
void ReadPrimaries(void) ;
- void CleanWhiteBoard(void) ;
- void CloseSplitFiles(void) ;
- void SetTitle(const char * title) ;
-
- TObject** PrimariesRef(void) const ;
- TObject** HitsRef(void) const ;
- TObject** SDigitsRef(const char * name, const char * file = 0 ) const;
- TObject** DigitsRef (const char * name) const ;
- TObject** EmcRecPointsRef (const char * name) const ;
- TObject** CpvRecPointsRef (const char * name) const ;
- TObject** TrackSegmentsRef(const char * name) const ;
- TObject** RecParticlesRef (const char * name) const ;
- TObject** AlarmsRef (void) const ;
-
- TObject** SDigitizerRef (const char * name) const ;
- TObject** DigitizerRef (const char * name) const ;
- TObject** ClusterizerRef(const char * name) const ;
- TObject** TSMakerRef (const char * name) const ;
- TObject** PIDRef (const char * name) const ;
-
- private:
-
- static TFile * fFile; //!
- Bool_t fToSplit ; //! Do we work in the split mode
- TString fHeaderFile ; //! File in which gAlice lives
- TString fBranchTitle ; //!
- TString fTrackSegmentsTitle ; //!
- TString fTrackSegmentsFileName ;//!
- TString fRecPointsTitle ; //!
- TString fRecPointsFileName ; //!
- TString fRecParticlesTitle ; //!
- TString fRecParticlesFileName ; //!
- TString fDigitsTitle ; //! TDirectory tempo(gDirectory)
- TString fDigitsFileName ; //! TDirectory tempo(gDirectory)
- TString fSDigitsTitle ; //!
- TString fSDigitsFileName ; //!
- Bool_t fFailed ; //! set if file not opend or galice not found
- Int_t fDebug ; //! Debug level
- Int_t fNPrimaries ; //! # of primaries
- TObjArray * fPrimaries ; //! list of lists of primaries-for the case of mixing
- TFolder * fModuleFolder ; //!Folder that contains the modules
- TFolder * fPrimariesFolder ; //!Folder that contains the Primary Particles
- TFolder * fHitsFolder ; //!Folder that contains the Hits
- TFolder * fSDigitsFolder ; //!Folder that contains the SDigits
- TFolder * fDigitsFolder ; //!Folder that contains the Digits
- TFolder * fRecoFolder ; //!Folder that contains the reconstructed objects (RecPoints, TrackSegments, RecParticles)
- TFolder * fQAFolder ; //!Folder that contains the QA objects
- TFolder * fTasksFolder ; //!Folder that contains the Tasks (sdigitizer, digitizer, reconstructioner)
-
- static AliPHOSGetter * fgObjGetter; // pointer to the unique instance of the singleton
- ClassDef(AliPHOSGetter,1) // Algorithm class that provides methods to retrieve objects from a list knowing the index
+ void FitRaw(Bool_t lowGainFlag, TGraph * gLowGain, TGraph * gHighGain, TF1* signalF, Double_t & energy, Double_t & time) const;
+
+ Int_t CalibrateRaw (Double_t energy, Int_t *relId);
+
+private:
+
+ AliPHOSBeamTestEvent * fBTE ; //! Header if BeamTest Event
+ static Int_t fgDebug ; //! Debug level
+
+ TString fLoadingStatus ; //! tells which trees are loaded
+ Int_t fNPrimaries ; //! # of primaries
+ TClonesArray * fPrimaries ; //! list of lists of primaries
+ TFile * fESDFile ; //! ESD file
+ TString fESDFileName ; //! ESD File Name
+ AliESD * fESD ; //! ESD object
+ TTree * fESDTree ; //! ESD Tree
+
+ Bool_t fRawDigits ; //! true is raw data
+
+ AliPHOSCalibrationDB * fcdb ; //! Calibration DB for beam test run 2004
+ static AliPHOSCalibData * fgCalibData; //! instance of AliPHOSCalibData
-};
+ static AliPHOSLoader * fgPhosLoader ; // the loader for the NewIO
+
+ enum EDataTypes{kHits,kSDigits,kDigits,kRecPoints,kTracks,kNDataTypes};
+
+
+ ClassDef(AliPHOSGetter,2) // Algorithm class that provides methods to retrieve objects from a list knowing the index
+
+ };
#endif // AliPHOSGETTER_H