#include "AliPHOSPIDv1.h"
#include "AliPHOSGeometry.h"
#include "AliPHOSRaw2Digits.h"
-#include "AliPHOSCalibrationDB.h"
+//#include "AliPHOSCalibrationDB.h"
+#include "AliPHOSBeamTestEvent.h"
ClassImp(AliPHOSGetter)
AliPHOSGetter * AliPHOSGetter::fgObjGetter = 0 ;
fFailed = kFALSE ;
fDebug = 0 ;
fAlice = 0 ;
+ fBTE = 0 ;
fToSplit = toSplit ;
fHeaderFile = headerFile ;
//Set titles to branches and create PHOS specific folders
SetTitle(branchTitle) ;
-
+
if ( fHeaderFile != "aliroot" ) { // to call the getter without a file
//open headers file
fFile = static_cast<TFile*>(gROOT->GetFile(fHeaderFile.Data() ) ) ;
-
+
if(!fFile) { //if file was not opened yet, read gAlice
- fFile = TFile::Open(fHeaderFile.Data(),"update") ;
+ fFile = TFile::Open(fHeaderFile.Data(),"update") ;
if (!fFile->IsOpen()) {
Error("AliPHOSGetter", "Cannot open %s", fHeaderFile.Data() ) ;
fFailed = kTRUE ;
return ;
}
- gAlice = static_cast<AliRun *>(fFile->Get("gAlice")) ;
- }
+ }
+ gAlice = dynamic_cast<AliRun *>(fFile->Get("gAlice")) ;
}
if (!gAlice) {
//____________________________________________________________________________
void AliPHOSGetter::CloseFile()
{
- delete gAlice ;
+ if(gAlice)
+ delete gAlice ;
gAlice = 0 ;
- delete fAlice ;
+ if(fAlice)
+ delete fAlice ;
fAlice = 0 ;
}
}
}
else{ //Close already opened files, clean memory and open new header file
- if(gAlice)
- delete gAlice ;
- gAlice= 0;
+ if(gAlice){ //should first delete gAlice, then close file
+ //Should be in dtor of PHOS, but if one changes path ...
+ fgObjGetter->fModuleFolder->Remove(fgObjGetter->fModuleFolder->FindObject("PHOS")) ;
+ delete gAlice ;
+ }
if(fgObjGetter->fFile){
fgObjGetter->fFile->Close() ;
fgObjGetter->fFile=0;
fgObjGetter->CloseSplitFiles() ;
fgObjGetter->CleanWhiteBoard() ;
fgObjGetter = new AliPHOSGetter(headerFile,branchTitle,toSplit) ;
+
}
return fgObjGetter ;
}
return phosFolder->GetListOfFolders()->GetObjectRef(tss) ;
}
-
+//____________________________________________________________________________
+const UShort_t AliPHOSGetter::EventPattern(void){
+ if(fBTE)
+ return fBTE->GetPattern() ;
+ else
+ return 0 ;
+}
+//____________________________________________________________________________
+const Float_t AliPHOSGetter::BeamEnergy(void){
+ if(fBTE)
+ return fBTE->GetBeamEnergy() ;
+ else
+ return 0 ;
+}
//____________________________________________________________________________
const Bool_t AliPHOSGetter::PostPID(AliPHOSPID * pid) const
{ // ------------AliPHOS PID -----------------------------
TFile * file = 0 ;
file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
- if (file && (filename != fHeaderFile) ) { // file already open
- file->Close() ;
- delete fAlice ;
- }
- file = TFile::Open(filename.Data(), "read") ;
- fAlice = static_cast<AliRun *>(file->Get("gAlice")) ;
+// if (file && (filename != fHeaderFile) ) { // file already open
+// file->Close() ;
+// //delete fAlice ;
+// }
+ if(!file || !file->IsOpen())
+ file = TFile::Open(filename.Data(), "read") ;
+ if(filename != fHeaderFile ){
+ fAlice = dynamic_cast<AliRun *>(file->Get("gAlice")) ;
+ }
TString treeName("TreeK") ;
treeName += EventNumber() ;
- TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
+ TTree * tree = dynamic_cast<TTree *>(file->Get(treeName.Data())) ;
if (!tree && fDebug)
Warning("TreeK", "-> %s not found in %s", treeName.Data(), filename.Data()) ;
digitsbranch->SetAddress(DigitsRef(fDigitsTitle)) ;
digitsbranch->GetEntry(0) ;
-
// read the Digitizer
if(Digitizer()){
if(strcmp(Digitizer()->IsA()->GetName(),digitizerbranch->GetName())!=0){
digitizerbranch->GetEntry(0) ;
- if((!fcdb)&&(strcmp(digitizerbranch->GetName(), "AliPHOSRaw2Digits")==0))
- ReadCalibrationDB("Primordial","beamtest.root") ;
-
+// if((!fcdb)&&(strcmp(digitizerbranch->GetName(), "AliPHOSRaw2Digits")==0))
+// ReadCalibrationDB("Primordial","beamtest.root") ;
+
+
if(gAlice->TreeD()!=treeD)
treeD->Delete();
return 0 ;
}
//____________________________________________________________________________
-void AliPHOSGetter::ReadCalibrationDB(const char * database,const char * filename){
-
- if(fcdb && (strcmp(database,fcdb->GetTitle())==0))
- return ;
-
- TFile * file = gROOT->GetFile(filename) ;
- if(!file)
- file = TFile::Open(filename);
- if(!file){
- Error ("ReadCalibrationDB", "Cannot open file %s", filename) ;
- return ;
- }
- if(fcdb)
- fcdb->Delete() ;
- fcdb = dynamic_cast<AliPHOSCalibrationDB *>(file->Get("AliPHOSCalibrationDB")) ;
- if(!fcdb)
- Error ("ReadCalibrationDB", "No database %s in file %s", database, filename) ;
-}
+//void AliPHOSGetter::ReadCalibrationDB(const char * database,const char * filename){
+//
+// if(fcdb && (strcmp(database,fcdb->GetTitle())==0))
+// return ;
+//
+// TFile * file = gROOT->GetFile(filename) ;
+// if(!file)
+// file = TFile::Open(filename);
+// if(!file){
+// Error ("ReadCalibrationDB", "Cannot open file %s", filename) ;
+// return ;
+// }
+// if(fcdb)
+// fcdb->Delete() ;
+// fcdb = dynamic_cast<AliPHOSCalibrationDB *>(file->Get("AliPHOSCalibrationDB")) ;
+// if(!fcdb)
+// Error ("ReadCalibrationDB", "No database %s in file %s", database, filename) ;
+//}
//____________________________________________________________________________
Int_t AliPHOSGetter::ReadTreeH()
fAlice = 0 ;
} else { // treeK not found in header file
-
Error("ReadPrimaries", "TreeK not found") ;
- return ;
-
+ return ;
}
+
Int_t index = 0 ;
for (index = 0 ; index < fNPrimaries; index++) {
new ((*ar)[index]) TParticle(*(Primary(index)));
return ;
}
+ TBranch * btb = gAlice->TreeE()->GetBranch("AliPHOSBeamTestEvent") ;
+ if(btb){
+ if(!fBTE)
+ fBTE = new AliPHOSBeamTestEvent() ;
+ btb->SetAddress(&fBTE) ;
+ btb->GetEntry(event) ;
+ }
+ else{
+ if(fBTE){
+ delete fBTE ;
+ fBTE = 0 ;
+ }
+ }
+
Bool_t any = kFALSE ;
if (strstr(opt,"A") ) // do not check the title of the branches
any = kTRUE;
if( strstr(opt,"Q") )
ReadTreeQA() ;
-
+
if( strstr(opt,"P") || (strcmp(opt,"")==0) )
ReadPrimaries() ;
-
+
+
}
//____________________________________________________________________________
class AliPHOSClusterizer ;
class AliPHOSTrackSegmentMaker ;
class AliPHOSPID ;
-class AliPHOSCalibrationDB ;
+//class AliPHOSCalibrationDB ;
+class AliPHOSConTableDB ;
+class AliPHOSBeamTestEvent ;
class AliPHOSGetter : public TObject {
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 ;
+ const UShort_t EventPattern(void) ;
+ const Float_t BeamEnergy(void) ;
//========== PHOSGeometry and PHOS =============
const AliPHOS * PHOS() ;
const TTask * QATasks(const char * name = 0) const { return ReturnT("QATasks", name) ; }
//-----------------now getter's data--------------------------------------
-
+// AliPHOSCalibrationDB * CalibrationDB(){return fcdb; }
+// void ReadCalibrationDB(const char * name, const char * filename) ;
+
//=========== Primaries ============
TTree * TreeK(TString filename="") ;
TClonesArray * Primaries(void) const { return dynamic_cast<TClonesArray*>(ReturnO("Primaries")) ; }
//const AliPHOSDigit * Digit(Int_t index) { return static_cast<const AliPHOSDigit *>(Digits()->At(index)) ;} !!! why no such method ?
const TTask * Digitizer(const char * name = 0) const {
return ReturnT("Digitizer", name) ; }
- AliPHOSCalibrationDB * CalibrationDB(){return fcdb; }
- void ReadCalibrationDB(const char * name, const char * filename) ;
//========== RecPoints =============
TObjArray * EmcRecPoints(const char * name = 0) {
static TFile * fFile; //!
Bool_t fToSplit ; //! Do we work in the split mode
+ AliPHOSBeamTestEvent * fBTE ; //! Header if BeamTest Event
TString fHeaderFile ; //! File in which gAlice lives
TString fBranchTitle ; //!
TString fTrackSegmentsTitle ; //!
TFolder * fQAFolder ; //!Folder that contains the QA objects
TFolder * fTasksFolder ; //!Folder that contains the Tasks (sdigitizer, digitizer, reconstructioner)
- AliPHOSCalibrationDB * fcdb ; //!
+// AliPHOSCalibrationDB * fcdb ; //!
static AliPHOSGetter * fgObjGetter; // pointer to the unique instance of the singleton