#include "AliRun.h"
#include "AliEMCALClusterizer.h"
#include "AliHeader.h"
+#include "AliEMCALGetter.h"
+#include "AliEMCALSDigitizer.h"
+#include "AliEMCALDigitizer.h"
ClassImp(AliEMCALClusterizer)
{
// ctor
fSplitFile = 0 ;
+ fHitsFileName = "" ;
+ fSDigitsFileName = "" ;
+ fDigitsFileName = "" ;
+
}
//____________________________________________________________________________
{
// ctor
fSplitFile = 0 ;
+ fDigitsFileName = headerFile ;
+ AliEMCALGetter * gime = AliEMCALGetter::GetInstance(headerFile, name) ;
+ gime->Event(0,"D") ;
+ fSDigitsFileName = gime->Digitizer()->GetTitle() ;
+ gime = AliEMCALGetter::GetInstance(fSDigitsFileName, name) ;
+ gime->Event(0,"S") ;
+ fHitsFileName = gime->SDigitizer()->GetTitle() ;
}
//____________________________________________________________________________
// dtor
fSplitFile = 0 ;
-
+
}
//____________________________________________________________________________
AliEMCALClusterizer(const char * headerFile, const char * name) ;
virtual ~AliEMCALClusterizer() ; // dtor
+ const TString GetHitsFileName() const { return fHitsFileName ; }
+ const TString GetSDigitsFileName() const { return fSDigitsFileName ; }
+ const TString GetDigitsFileName() const { return fDigitsFileName ; }
+
virtual Float_t GetEmcClusteringThreshold()const = 0 ;
virtual Float_t GetEmcLocalMaxCut()const = 0 ;
virtual Float_t GetEmcLogWeight()const = 0 ;
protected:
+ TString fHitsFileName ; // file name that contains the original hits
+ TString fSDigitsFileName ; // file name that contains the original SDigits
+ TString fDigitsFileName ; // file name that contains the original Digits
TFile * fSplitFile ; //! file in which RecPoints will eventually be stored
ClassDef(AliEMCALClusterizer,1) // Clusterization algorithm class
InitParameters() ;
fDefaultInit = kTRUE ;
+
+ fHitsFileName = "" ;
+ fSDigitsFileName = "" ;
}
InitParameters() ;
Init() ;
fDefaultInit = kFALSE ;
-
+ fSDigitsFileName = headerFile ;
+ AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ;
+ gime->Event(0, "S") ;
+ fHitsFileName = gime->SDigitizer()->GetTitle() ;
}
//____________________________________________________________________________
SetName("Default");
SetTitle("aliroot") ;
fDefaultInit = kFALSE ;
+
+ const AliRunDigitizer * rd = Manager() ;
+ if (rd) {
+ AliStream * st = static_cast<AliStream*>(rd->GetInputStreams()->At(0)) ;
+ fSDigitsFileName = st->GetFileNames()->At(0)->GetName() ;
+ }
+ AliEMCALGetter * gime = AliEMCALGetter::GetInstance(fSDigitsFileName, GetName()) ;
+ gime->Event(0,"S") ;
+ fHitsFileName = gime->SDigitizer()->GetTitle() ;
}
//____________________________________________________________________________
void Digitize(const Int_t); // Make Digits from SDigits stored in fSDigits
void Exec(Option_t *option); // Supervising method
+ const TString GetHitsFileName() const { return fHitsFileName ; }
+ const TString GetSDigitsFileName() const { return fSDigitsFileName ; }
const Float_t GetTowerThreshold() const { return fTowerDigitThreshold;}
const Float_t GetPedestal() const { return fPedestal; }
const Float_t GetPinNoise() const { return fPinNoise;}
private:
+ TString fHitsFileName ; // file name that contains the original hits
+ TString fSDigitsFileName ; // file name that contains the original SDigits
Bool_t fDefaultInit; //! Says if the task was created by defaut ctor (only parameters are initialized)
// !!! the following is not necessary, it is in the folder !!!!!!!
AliEMCALSDigitizer * fSDigitizer ; // ! SDigitizer to extract some sdigitizing parameters
//Initialize all lists
fDebug = 0 ;
-
+
+ fAlice = 0 ;
+
fHeaderFile = headerFile ;
fBranchTitle = branchTitle ;
fSDigitsTitle = branchTitle ;
fPrimaries = new TObjArray(1) ;
- fModuleFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Configuration/Modules"));
- fHitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data/Hits"));
- fSDigitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data/SDigits"));
- fDigitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Event/Data"));
- fRecoFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Event/RecData"));
+ fModuleFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Configuration/Modules"));
+ fPrimariesFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data"));
+ fHitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data/Hits"));
+ fSDigitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data/SDigits"));
+ fDigitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Event/Data"));
+ fRecoFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Event/RecData"));
//fQAFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Conditions/QA"));
- fTasksFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Tasks")) ;
+ fTasksFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Tasks")) ;
fFailed = kFALSE ;
{
delete gAlice ;
gAlice = 0 ;
+ delete fAlice ;
+ fAlice = 0 ;
}
//____________________________________________________________________________
return rv ;
}
+//____________________________________________________________________________
+Bool_t AliEMCALGetter::PostPrimaries(void) const
+{ //------- Primaries ----------------------
+
+ // the hierarchy is //Folders/RunMC/Event/Data/Primaries
+
+ TFolder * primariesFolder = dynamic_cast<TFolder*>(fPrimariesFolder->FindObject("Primaries")) ;
+ if ( !primariesFolder ) {
+ if (fDebug) {
+ cout << "WARNING: AliEMCALGetter::Post Primaries -> Folder //" << fPrimariesFolder->GetName() << "/Primaries/ not found!" << endl;
+ cout << "INFO: AliEMCALGetter::Post Primaries -> Adding Folder //" << fPrimariesFolder->GetName() << "/Primaries/" << endl;
+ }
+ primariesFolder = fPrimariesFolder->AddFolder("Primaries", "Primaries particles from TreeK") ;
+ }
+ TClonesArray *primaries= new TClonesArray("TParticle",1000) ;
+ primaries->SetName("Primaries") ;
+ primariesFolder->Add(primaries) ;
+
+ return kTRUE;
+}
+
+//____________________________________________________________________________
+TObject** AliEMCALGetter::PrimariesRef(void) const
+{ //------- Primaries ----------------------
+
+
+ // the hierarchy is //Folders/RunMC/Event/Data/Primaries
+ if ( !fPrimariesFolder ) {
+ cerr << "ERROR: AliEMCALGetter::PrimariesRef -> Folder //" << fPrimariesFolder << " not found!" << endl;
+ abort() ;
+ }
+
+ TFolder * primariesFolder = dynamic_cast<TFolder *>(fPrimariesFolder->FindObject("Primaries")) ;
+ if ( !primariesFolder ) {
+ cerr << "ERROR: AliEMCALGetter::PrimariesRef -> Folder //" << fPrimariesFolder << "/Primaries/ not found!" << endl;
+ abort() ;
+ }
+
+ TObject * p = primariesFolder->FindObject("Primaries") ;
+ if(!p) {
+ cerr << "ERROR: AliEMCALGetter::PrimariesRef -> " << primariesFolder->GetName() << "/Primaries not found !" << endl ;
+ abort() ;
+ }
+ else
+ return primariesFolder->GetListOfFolders()->GetObjectRef(p) ;
+}
+
//____________________________________________________________________________
Bool_t AliEMCALGetter::PostHits(void) const
{ //------- Hits ----------------------
if(index < 0)
return 0 ;
-
- Int_t primaryIndex = index % 10000000 ;
- Int_t primaryList = (Int_t ) ((index-primaryIndex)/10000000.) ;
-
- if ( primaryList > 0 ) {
- if (fDebug) {
- cout << " Getter does not support currently Mixing of primary " << endl ;
- cout << " can not return primary: " << index<< " (list "<< primaryList<< " primary # " << primaryIndex << " )"<<endl ;
- }
- return 0;
- }
-
- return gAlice->Particle(primaryIndex) ;
-
+ TParticle * p = 0 ;
+ if (fAlice)
+ p = fAlice->Particle(index) ;
+ else
+ p = gAlice->Particle(index) ;
+ // if (p->GetFirstMother() != -1 ) {
+ // cout << "AliEMCALGetter::Primary : Not a primary " << endl ;
+ // }
+
+ return p ;
+
}
//____________________________________________________________________________
void AliEMCALGetter::ReadTreeD()
{
// Read the digit tree gAlice->TreeD()
- if(gAlice->TreeD()== 0){
- cerr << "ERROR: AliEMCALGetter::ReadTreeD: can not read TreeD " << endl ;
- return ;
- }
+
+ TTree * treeD = gAlice->TreeD() ;
+ if(!treeD) { // TreeD not found in header file
+
+ if (fDebug)
+ cout << "WARNING: AliEMCALGetter::ReadTreeD -> Cannot find TreeD in " << fHeaderFile << endl ;
+
+ TString searchFileName("") ;
+
+ if (Digitizer()) // Digitizer found in header file
+ searchFileName = Digitizer()->GetTitle() ;
+
+ else if (Clusterizer()) // Clusterizer found in header file
+ searchFileName = Clusterizer()->GetDigitsFileName() ;
+
+ if (treeD = TreeD(searchFileName)) { //found TreeD in the file which contains the hits
+ if (fDebug)
+ cout << "INFO: AliEMCALGetter::ReadTreeD -> TreeD found in " << searchFileName.Data() << endl ;
+
+ } else {
+ cerr << "ERROR: AliEMCALGetter::ReadTreeD -> TreeD not found " << endl ;
+ return ;
+ }
+ }
TObjArray * lob = static_cast<TObjArray*>(gAlice->TreeD()->GetListOfBranches()) ;
TIter next(lob) ;
TBranch * branch = 0 ;
{
// Read the first entry of EMCAL branch in hit tree gAlice->TreeH()
- if(gAlice->TreeH()== 0){
- cerr << "ERROR: AliEMCALGetter::ReadTreeH: -> Cannot read TreeH " << endl ;
- return ;
- }
+ TTree * treeH = gAlice->TreeH() ;
+
+ if(!treeH) {// TreeH not found in header file
+
+ if (fDebug)
+ cout << "WARNING: AliEMCALGetter::ReadTreeH -> Cannot find TreeH in " << fHeaderFile << endl ;
+
+ TString searchFileName("") ;
+
+ if (SDigitizer()) // SDigitizer found in header file
+ searchFileName = SDigitizer()->GetTitle() ;
+
+ else if (Digitizer()) // Digitizer found in header file
+ searchFileName = Digitizer()->GetHitsFileName() ;
+
+ else if (Clusterizer()) // Clusterizer found in header file
+ searchFileName = Clusterizer()->GetHitsFileName() ;
+
+ if (treeH = TreeH(searchFileName)) { //found TreeH in the file which contains the hits
+ if (fDebug)
+ cout << "INFO: AliEMCALGetter::ReadTreeH -> TreeH found in " << searchFileName.Data() << endl ;
+
+ } else {
+ cerr << "ERROR: AliEMCALGetter::ReadTreeH -> TreeH not found " << endl ;
+ return ;
+ }
+ }
TBranch * hitsbranch = static_cast<TBranch*>(gAlice->TreeH()->GetBranch("EMCAL")) ;
if ( !hitsbranch ) {
}
+
+
+//____________________________________________________________________________
+TTree * AliEMCALGetter::TreeK(TString filename)
+{
+
+ // returns TreeK from file filename
+ // usefull in case of split file
+
+ if ( filename.IsNull() )
+ filename = fHeaderFile ;
+
+ TFile * file = 0 ;
+ // file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
+ if (!file) { // file not open yet
+ // file->Close() ;
+ file = TFile::Open(filename.Data(), "read") ;
+ delete fAlice ;
+ fAlice = static_cast<AliRun *>(file->Get("gAlice")) ;
+ }
+
+ TString treeName("TreeK") ;
+ treeName += EventNumber() ;
+ TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
+ if (!tree && fDebug)
+ cout << "WARNING: AliEMCALGetter::TreeK -> " << treeName.Data() << " not found in " << filename.Data() << endl ;
+
+ return tree ;
+}
+
+//____________________________________________________________________________
+TTree * AliEMCALGetter::TreeH(TString filename)
+{
+
+ // returns TreeH from file filename
+ // usefull in case of split file
+
+ if ( filename.IsNull() )
+ filename = fHeaderFile ;
+
+ TFile * file = 0 ;
+ file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
+ if (!file) { // file not open yet
+ file = TFile::Open(filename.Data(), "read") ;
+ }
+ TString treeName("TreeH") ;
+ treeName += EventNumber() ;
+ TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
+ if (!tree && fDebug)
+ cout << "WARNING: AliEMCALGetter::TreeH -> " << treeName.Data() << " not found in " << filename.Data() << endl ;
+
+ return tree ;
+}
+
+//____________________________________________________________________________
+TTree * AliEMCALGetter::TreeS(TString filename)
+{
+
+ // returns TreeS from file filename
+ // usefull in case of split file
+
+ if ( filename.IsNull() )
+ filename = fHeaderFile ;
+
+ TFile * file = 0 ;
+ file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
+ if (!file) { // file not open yet
+ file = TFile::Open(filename.Data(), "read") ;
+ }
+ TString treeName("TreeS") ;
+ treeName += EventNumber() ;
+ TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
+ if (!tree && fDebug)
+ cout << "WARNING: AliEMCALGetter::TreeS -> " << treeName.Data() << " not found in " << filename.Data() << endl ;
+
+ return tree ;
+}
+
+//____________________________________________________________________________
+TTree * AliEMCALGetter::TreeD(TString filename)
+{
+
+ // returns TreeD from file filename
+ // usefull in case of split file
+
+ if ( filename.IsNull() )
+ filename = fHeaderFile ;
+
+ TFile * file = 0 ;
+ file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
+ if (!file) { // file not open yet
+ file = TFile::Open(filename.Data(), "read") ;
+ }
+ TString treeName("TreeD") ;
+ treeName += EventNumber() ;
+ TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
+ if (!tree && fDebug)
+ cout << "WARNING: AliEMCALGetter::TreeD -> " << treeName.Data() << " not found in " << filename.Data() << endl ;
+
+ return tree ;
+}
+
//____________________________________________________________________________
// void AliEMCALGetter::ReadTreeQA()
//{
// Read the reconstrunction tree gAlice->TreeR()
if(gAlice->TreeR()== 0){
- cerr << "ERROR: AliEMCALGetter::ReadTreeR: can not read TreeR " << endl ;
+ if (fDebug)
+ cout << "WARNING: AliEMCALGetter::ReadTreeR: can not read TreeR " << endl ;
return ;
}
treeName += event ;
treeS = dynamic_cast<TTree*>(gDirectory->Get(treeName.Data()));
}
- if(treeS==0){
- cerr << "ERROR: AliEMCALGetter::ReadTreeS There is no SDigit Tree" << endl;
- return ;
- }
+ if(!treeS){ // TreeS not found in header file
+
+ if (fDebug)
+ cout << "WARNING: AliEMCALGetter::ReadTreeS -> Cannot find TreeS in " << fHeaderFile << endl;
+
+ TString searchFileName("") ;
+
+ if (SDigitizer()) // SDigitizer found in header file
+ searchFileName = SDigitizer()->GetTitle() ;
+
+ else if (Digitizer()) // Digitizer found in header file
+ searchFileName = Digitizer()->GetSDigitsFileName() ;
+
+ else if (Clusterizer()) // Clusterizer found in header file
+ searchFileName = Clusterizer()->GetSDigitsFileName() ;
+
+ if (treeS = TreeS(searchFileName)) { //found TreeS in the file which contains the hits
+ if (fDebug)
+ cout << "INFO: AliEMCALGetter::ReadTreeS -> TreeS found in " << searchFileName.Data() << endl ;
+
+ } else {
+ cerr << "ERROR: AliEMCALGetter::ReadTreeS -> TreeS not found " << endl ;
+ return ;
+ }
+ }
+
+ //set address of the SDigits and SDigitizer
+ TBranch * sdigitsBranch = 0;
+ TBranch * sdigitizerBranch = 0;
+ TBranch * branch = 0 ;
+ TObjArray * lob = static_cast<TObjArray*>(treeS->GetListOfBranches()) ;
+ TIter next(lob) ;
+ Bool_t emcalfound = kFALSE, sdigitizerfound = kFALSE ;
- //set address of the SDigits and SDigitizer
- TBranch * sdigitsBranch = 0;
- TBranch * sdigitizerBranch = 0;
- TBranch * branch = 0 ;
- TObjArray * lob = static_cast<TObjArray*>(treeS->GetListOfBranches()) ;
- TIter next(lob) ;
- Bool_t emcalfound = kFALSE, sdigitizerfound = kFALSE ;
-
- while ( (branch = static_cast<TBranch*>(next())) && (!emcalfound || !sdigitizerfound) ) {
- if ( (strcmp(branch->GetName(), "EMCAL")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
- emcalfound = kTRUE ;
- sdigitsBranch = branch ;
- }
-
- else if ( (strcmp(branch->GetName(), "AliEMCALSDigitizer")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
- sdigitizerfound = kTRUE ;
- sdigitizerBranch = branch ;
- }
- }
- if ( !emcalfound || !sdigitizerfound ) {
- if (fDebug)
- cout << "WARNING: AliEMCALGetter::ReadSDigits -> Digits and/or Digitizer branch with name " << fSDigitsTitle
- << " not found" << endl ;
- return ;
- }
-
- if ( !folder->FindObject(fSDigitsTitle) )
- PostSDigits(fSDigitsTitle,folder->GetName()) ;
- sdigitsBranch->SetAddress(SDigitsRef(fSDigitsTitle,folder->GetName())) ;
- sdigitsBranch->GetEntry(0) ;
-
- TString sdname(fSDigitsTitle) ;
- sdname+=":" ;
- sdname+=folder->GetName() ;
- if(!SDigitizer(sdname) )
- PostSDigitizer(fSDigitsTitle,folder->GetName()) ;
-
- sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
- sdigitizerBranch->GetEntry(0) ;
-
- }
+ while ( (branch = static_cast<TBranch*>(next())) && (!emcalfound || !sdigitizerfound) ) {
+ if ( (strcmp(branch->GetName(), "EMCAL")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
+ emcalfound = kTRUE ;
+ sdigitsBranch = branch ;
+ }
+
+ else if ( (strcmp(branch->GetName(), "AliEMCALSDigitizer")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
+ sdigitizerfound = kTRUE ;
+ sdigitizerBranch = branch ;
+ }
+ }
+ if ( !emcalfound || !sdigitizerfound ) {
+ if (fDebug)
+ cout << "WARNING: AliEMCALGetter::ReadSDigits -> Digits and/or Digitizer branch with name " << fSDigitsTitle
+ << " not found" << endl ;
+ return ;
+ }
+
+ if ( !folder->FindObject(fSDigitsTitle) )
+ PostSDigits(fSDigitsTitle,folder->GetName()) ;
+ sdigitsBranch->SetAddress(SDigitsRef(fSDigitsTitle,folder->GetName())) ;
+ sdigitsBranch->GetEntry(0) ;
+
+ TString sdname(fSDigitsTitle) ;
+ sdname+=":" ;
+ sdname+=folder->GetName() ;
+ if(!SDigitizer(sdname) )
+ PostSDigitizer(fSDigitsTitle,folder->GetName()) ;
+
+ sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
+ sdigitizerBranch->GetEntry(0) ;
+
+ }
// After SDigits have been read from all files, return to the first one
}
}
+
//____________________________________________________________________________
void AliEMCALGetter::ReadTreeS(TTree * treeS, Int_t input)
{ // Read the summable digits fron treeS()
{
// Reads specific branches of primaries
- fNPrimaries = gAlice->GetNtrack();
+ TClonesArray * ar = 0 ;
+ if(! (ar = Primaries()) ) {
+ PostPrimaries() ;
+ ar = Primaries() ;
+ }
+ ar->Delete() ;
+
+ if (TreeK(fHeaderFile)) { // treeK found in header file
+ if (fDebug)
+ cout << "INFO: AliEMCALGetter::ReadPrimaries -> TreeK found in " << fHeaderFile.Data() << endl ;
+ fNPrimaries = gAlice->GetNtrack() ;
- // //Check, is it necessary to open new files
- // TArrayI* events = fDigitizer->GetCurrentEvents() ;
- // TClonesArray * filenames = fDigitizer->GetHeadersFiles() ;
-// Int_t input ;
-// for(input = 0; input < filenames->GetEntriesFast(); input++){
+ } else { // treeK not found in header file
-// TObjString * filename = (TObjString *) filenames->At(input) ;
+ TString searchFileName("") ;
-// //Test, if this file already open
-// TFile *file = (TFile*) gROOT->GetFile( filename->GetString() ) ;
-// if(file == 0)
-// file = new TFile( filename->GetString()) ;
-// file->cd() ;
-
-// // Get Kine Tree from file
-// // char treeName[20];
-// // sprintf(treeName,"TreeK%d",events->At(input));
-// // TTree * treeK = (TTree*)gDirectory->Get(treeName);
-// // if (treeK)
-// // treeK->SetBranchAddress("Particles", &fParticleBuffer);
-// // else
-// // cout << "AliEMCALGetter: cannot find Kine Tree for event:" << events->At(input) << endl;
-
-// // // Create the particle stack
-// // if(!fParticles) fParticles = new TClonesArray("TParticle",1000);
-// // // Build the pointer list
-// // if(fParticleMap) { <----
-// // fParticleMap->Clear();
-// // fParticleMap->Expand(treeK->GetEntries());
-// // } else
-// // fParticleMap = new TObjArray(treeK->GetEntries());
-
-// // From gAlice->Particle(i)
+ if (SDigitizer()) // SDigitizer found in header file
+ searchFileName = SDigitizer()->GetTitle() ;
+ else if (Digitizer()) // Digitizer found in header file
+ searchFileName = Digitizer()->GetHitsFileName() ;
-// // if(!(*fParticleMap)[i]) {
-// // Int_t nentries = fParticles->GetEntries();
+ else if (Clusterizer()) // Clusterizer found in header file
+ searchFileName = Clusterizer()->GetHitsFileName() ;
-// // // algorithmic way of getting entry index
-// // // (primary particles are filled after secondaries)
-// // Int_t entry;
-// // if (i<fHeader.GetNprimary())
-// // entry = i+fHeader.GetNsecondary();
-// // else
-// // entry = i-fHeader.GetNprimary();
+ if (TreeK(searchFileName)) { //found TreeK in the file which contains the hits
+ if (fDebug)
+ cout << "INFO: AliEMCALGetter::ReadPrimaries -> TreeK found in " << searchFileName.Data() << endl ;
+ fAlice->GetEvent(EventNumber()) ;
+ fNPrimaries = fAlice->GetNtrack() ;
-// // // only check the algorithmic way and give
-// // // the fatal error if it is wrong
-// // if (entry != fParticleFileMap[i]) {
-// // Fatal("Particle",
-// // "!!!! The algorithmic way is WRONG: !!!\n entry: %d map: %d",
-// // entry, fParticleFileMap[i]);
-// // }
-
-// // fTreeK->GetEntry(fParticleFileMap[i]);
-// // new ((*fParticles)[nentries]) TParticle(*fParticleBuffer);
-// // fParticleMap->AddAt((*fParticles)[nentries],i);
-// // }
-// // return (TParticle *) (*fParticleMap)[i];
-
-
+ } else {
+ cerr << "ERROR: AliEMCALGetter::ReadPrimaries -> TreeK not found " << endl ;
+ return ;
+ }
-// }
-
-
-// //scan over opened files and read corresponding TreeK##
-
- return ;
+ }
+ Int_t index = 0 ;
+ for (index = 0 ; index < fNPrimaries; index++) {
+ new ((*ar)[index]) TParticle(*(Primary(index)));
+ }
}
+
//____________________________________________________________________________
void AliEMCALGetter::Event(const Int_t event, const char* opt)
{
}
gAlice->GetEvent(event) ;
- if(strstr(opt,"H") )
- ReadTreeH() ;
+ // Carefull the order of reading is important
- if(strstr(opt,"S") )
- ReadTreeS(event) ;
+ if( strstr(opt,"R") )
+ ReadTreeR() ;
if( strstr(opt,"D") )
ReadTreeD() ;
- if( strstr(opt,"R") )
- ReadTreeR() ;
+ if(strstr(opt,"S") )
+ ReadTreeS(event) ;
+
+ if(strstr(opt,"H") )
+ ReadTreeH() ;
// if( strstr(opt,"Q") )
// ReadTreeQA() ;
- // if( strstr(opt,"P") || (strcmp(opt,"")==0) )
- // ReadPrimaries() ;
-
+ if( strstr(opt,"P") || (strcmp(opt,"")==0) )
+ ReadPrimaries() ;
+
}
//____________________________________________________________________________
*/
if (!emcalO) {
if(fDebug)
- cerr << "WARNING : AliEMCALGetter::ReturnO -> Object " << what << " not found in " << folder->GetName() << endl ;
+ cout << "WARNING : AliEMCALGetter::ReturnO -> Object " << what << " not found in " << folder->GetName() << endl ;
return 0 ;
}
return emcalO ;
void AliEMCALGetter::RemoveTask(TString opt, TString name) const
{
// remove a task from the folder
- // path is fTasksFolder/SDigitizer/PHOS/name
+ // path is fTasksFolder/SDigitizer/EMCAL/name
TTask * task = 0 ;
TTask * emcal = 0 ;
void CloseFile() ;
const TFolder * Folder(const TString what) const ;
const Bool_t HasFailed(void) const {return fFailed ;}
+ Bool_t PostPrimaries(void ) const ;
Bool_t PostHits(void ) const ;
Bool_t PostSDigits( const char * name, const char * file = 0) const ;
Bool_t PostDigits( const char * name ) const ;
// Hits
+ TTree * TreeH(TString filename="") ;
const TClonesArray * Hits(void) { return static_cast<const TClonesArray*>(ReturnO("Hits")) ; }
- const AliEMCALHit * Hit(Int_t index) { return static_cast<const AliEMCALHit*>(Hits()->At(index) );}
+ const AliEMCALHit * Hit(Int_t index) { return static_cast<const AliEMCALHit*>(Hits()->At(index) );}
// SDigits
+ TTree * TreeS(TString filename="") ;
TClonesArray * SDigits(const char * name = 0, const char * file=0) {
return static_cast<TClonesArray*>(ReturnO("SDigits", name, file)) ;
}
}
// Digits
- TClonesArray * Digits(const char * name = 0)const {
+ TTree * TreeD(TString filename="") ;
+ TClonesArray * Digits(const char * name = 0)const {
return static_cast<TClonesArray*>(ReturnO("Digits", name)) ;
}
const AliEMCALDigit * Digit(Int_t index) { return static_cast<const AliEMCALDigit *>(Digits()->At(index)) ;}
// { return (AliEMCALPID*)(ReturnT("PID", name)) ; }
// Primaries
+ TTree * TreeK(TString filename="") ;
const TParticle * Primary(Int_t index) const ;
const Int_t NPrimaries()const { return fNPrimaries; }
//void ReadTreeQA() ;
void ReadPrimaries() ;
+ TObject ** PrimariesRef(void) const ;
TObject ** HitsRef(void) const ;
TObject ** SDigitsRef(const char * name, const char * file = 0 ) const;
TObject ** DigitsRef (const char * name) const ;
Bool_t fFailed ; //! true if file is not opened and/or galice not found
Int_t fDebug ; // Debug level
+ AliRun * fAlice ; //! needed to read TreeK if in an other file than fHeaderFile
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
#include "AliRun.h"
#include "AliPHOSClusterizer.h"
#include "AliHeader.h"
+#include "AliPHOSGetter.h"
+#include "AliPHOSSDigitizer.h"
+#include "AliPHOSDigitizer.h"
ClassImp(AliPHOSClusterizer)
{
// ctor
fSplitFile= 0 ;
+ fHitsFileName = "" ;
+ fSDigitsFileName = "" ;
+ fDigitsFileName = "" ;
+
}
//____________________________________________________________________________
{
// ctor
fSplitFile= 0 ;
-
+ fDigitsFileName = headerFile ;
+ AliPHOSGetter * gime = AliPHOSGetter::GetInstance(headerFile, name) ;
+ gime->Event(0,"D") ;
+ fSDigitsFileName = gime->Digitizer()->GetTitle() ;
+ gime = AliPHOSGetter::GetInstance(fSDigitsFileName, name) ;
+ gime->Event(0,"S") ;
+ fHitsFileName = gime->SDigitizer()->GetTitle() ;
}
//____________________________________________________________________________
AliPHOSClusterizer(const char * headerFile, const char * name) ;
virtual ~AliPHOSClusterizer() ; // dtor
+ const TString GetHitsFileName() const { return fHitsFileName ; }
+ const TString GetSDigitsFileName() const { return fSDigitsFileName ; }
+ const TString GetDigitsFileName() const { return fDigitsFileName ; }
+
virtual Float_t GetEmcClusteringThreshold()const {cout << "Not Defined" << endl ; return 0. ; }
virtual Float_t GetEmcLocalMaxCut()const {cout << "Not Defined" << endl ; return 0. ; }
virtual Float_t GetEmcLogWeight()const {cout << "Not Defined" << endl ; return 0. ; }
protected:
+ TString fHitsFileName ; // file name that contains the original hits
+ TString fSDigitsFileName ; // file name that contains the original SDigits
+ TString fDigitsFileName ; // file name that contains the original Digits
TFile * fSplitFile ; //! file in which RecPoints will eventually be stored
+
ClassDef(AliPHOSClusterizer,2) // Clusterization algorithm class
} ;
// ctor
InitParameters() ;
- fDefaultInit = kTRUE ;
-}
+ fDefaultInit = kTRUE ;
+
+ fHitsFileName = "" ;
+ fSDigitsFileName = "" ;
+ }
//____________________________________________________________________________
AliPHOSDigitizer::AliPHOSDigitizer(const char *headerFile,const char * name)
InitParameters() ;
Init() ;
fDefaultInit = kFALSE ;
-
+ fSDigitsFileName = headerFile ;
+ AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
+ gime->Event(0, "S") ;
+ fHitsFileName = gime->SDigitizer()->GetTitle() ;
}
//____________________________________________________________________________
SetName("Default") ;
InitParameters() ;
fDefaultInit = kTRUE ;
+
+ const AliRunDigitizer * rd = Manager() ;
+ if (rd) {
+ AliStream * st = static_cast<AliStream*>(rd->GetInputStreams()->At(0)) ;
+ fSDigitsFileName = st->GetFileNames()->At(0)->GetName() ;
+ }
+ AliPHOSGetter * gime = AliPHOSGetter::GetInstance(fSDigitsFileName, GetName()) ;
+ gime->Event(0,"S") ;
+ fHitsFileName = gime->SDigitizer()->GetTitle() ;
+
}
//____________________________________________________________________________
//General
const Int_t GetDigitsInRun() const { return fDigitsInRun ;}
+ const TString GetHitsFileName() const { return fHitsFileName ; }
+ const TString GetSDigitsFileName() const { return fSDigitsFileName ; }
void MixWith(const char* HeaderFile) ; // Add another one file to mix
void Print(Option_t* option)const ;
private:
+ TString fHitsFileName ; // file name that contains the original hits
+ TString fSDigitsFileName ; // file name that contains the original SDigits
Bool_t fDefaultInit; //! Says if the task was created by defaut ctor (only parameters are initialized)
Int_t fEmcCrystals ; // Number of EMC crystalls in the given geometry
//Initialize all lists
fDebug = 0 ;
+
+ fAlice = 0 ;
fHeaderFile = headerFile ;
fBranchTitle = branchTitle ;
{
delete gAlice ;
gAlice = 0 ;
+ delete fAlice ;
+ fAlice = 0 ;
}
//____________________________________________________________________________
return fQAFolder->GetListOfFolders()->GetObjectRef(phosFolder) ;
}
+
+//____________________________________________________________________________
+TTree * AliPHOSGetter::TreeK(TString filename)
+{
+
+ // returns TreeK from file filename
+ // usefull in case of split file
+
+ if ( filename.IsNull() )
+ filename = fHeaderFile ;
+
+ TFile * file = 0 ;
+ // file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
+ if (!file) { // file not open yet
+ // file->Close() ;
+ file = TFile::Open(filename.Data(), "read") ;
+ delete fAlice ;
+ fAlice = static_cast<AliRun *>(file->Get("gAlice")) ;
+ }
+
+ TString treeName("TreeK") ;
+ treeName += EventNumber() ;
+ TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
+ if (!tree && fDebug)
+ cout << "WARNING: AliPHOSGetter::TreeK -> " << treeName.Data() << " not found in " << filename.Data() << endl ;
+
+ return tree ;
+}
+
+//____________________________________________________________________________
+TTree * AliPHOSGetter::TreeH(TString filename)
+{
+
+ // returns TreeH from file filename
+ // usefull in case of split file
+
+ if ( filename.IsNull() )
+ filename = fHeaderFile ;
+
+ TFile * file = 0 ;
+ file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
+ if (!file) { // file not open yet
+ file = TFile::Open(filename.Data(), "read") ;
+ }
+ TString treeName("TreeH") ;
+ treeName += EventNumber() ;
+ TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
+ if (!tree && fDebug)
+ cout << "WARNING: AliPHOSGetter::TreeH -> " << treeName.Data() << " not found in " << filename.Data() << endl ;
+
+ return tree ;
+}
+
//____________________________________________________________________________
-const TParticle * AliPHOSGetter::Primary(Int_t index) const
+TTree * AliPHOSGetter::TreeS(TString filename)
+{
+
+ // returns TreeS from file filename
+ // usefull in case of split file
+
+ if ( filename.IsNull() )
+ filename = fHeaderFile ;
+
+ TFile * file = 0 ;
+ file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
+ if (!file) { // file not open yet
+ file = TFile::Open(filename.Data(), "read") ;
+ }
+ TString treeName("TreeS") ;
+ treeName += EventNumber() ;
+ TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
+ if (!tree && fDebug)
+ cout << "WARNING: AliPHOSGetter::TreeS -> " << treeName.Data() << " not found in " << filename.Data() << endl ;
+
+ return tree ;
+}
+
+//____________________________________________________________________________
+TTree * AliPHOSGetter::TreeD(TString filename)
+{
+
+ // returns TreeD from file filename
+ // usefull in case of split file
+
+ if ( filename.IsNull() )
+ filename = fHeaderFile ;
+
+ TFile * file = 0 ;
+ file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
+ if (!file) { // file not open yet
+ file = TFile::Open(filename.Data(), "read") ;
+ }
+ TString treeName("TreeD") ;
+ treeName += EventNumber() ;
+ TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
+ if (!tree && fDebug)
+ cout << "WARNING: AliPHOSGetter::TreeD -> " << treeName.Data() << " not found in " << filename.Data() << endl ;
+
+ return tree ;
+}
+
+//____________________________________________________________________________
+const TParticle * AliPHOSGetter::Primary(Int_t index)
{
// Return primary particle numbered by <index>
if(index < 0)
return 0 ;
- TParticle * p = gAlice->Particle(index) ;
-// if (p->GetFirstMother() != -1 ) {
-// cout << "AliPHOSGetter::Primary : Not a primary " << endl ;
-// }
+ TParticle * p = 0 ;
+ if (fAlice)
+ p = fAlice->Particle(index) ;
+ else
+ p = gAlice->Particle(index) ;
+ // if (p->GetFirstMother() != -1 ) {
+ // cout << "AliPHOSGetter::Primary : Not a primary " << endl ;
+ // }
+
return p ;
+
-// Int_t primaryIndex = index % 10000000 ;
+ // Int_t primaryIndex = index % 10000000 ;
// Int_t primaryList = (Int_t ) ((index-primaryIndex)/10000000.) ;
// if ( primaryList > 0 ) {
Int_t AliPHOSGetter::ReadTreeD()
{
// Read the digit tree gAlice->TreeD()
- if(gAlice->TreeD()== 0){
- cerr << "WARNING: AliPHOSGetter::ReadTreeD: can not read TreeD " << endl ;
- return 1;
+
+ TTree * treeD = gAlice->TreeD() ;
+
+ if(!treeD) { // TreeD not found in header file
+
+ if (fDebug)
+ cout << "WARNING: AliPHOSGetter::ReadTreeD -> Cannot find TreeD in " << fHeaderFile << endl ;
+
+ TString searchFileName("") ;
+
+ if (Digitizer()) // Digitizer found in header file
+ searchFileName = Digitizer()->GetTitle() ;
+
+ else if (Clusterizer()) // Clusterizer found in header file
+ searchFileName = Clusterizer()->GetDigitsFileName() ;
+
+ if (treeD = TreeD(searchFileName)) { //found TreeD in the file which contains the hits
+ if (fDebug)
+ cout << "INFO: AliPHOSGetter::ReadTreeD -> TreeD found in " << searchFileName.Data() << endl ;
+
+ } else {
+ cerr << "ERROR: AliPHOSGetter::ReadTreeD -> TreeD not found " << endl ;
+ return 1;
+ }
}
- TObjArray * lob = static_cast<TObjArray*>(gAlice->TreeD()->GetListOfBranches()) ;
+ TObjArray * lob = static_cast<TObjArray*>(treeD->GetListOfBranches()) ;
TIter next(lob) ;
TBranch * branch = 0 ;
TBranch * digitsbranch = 0 ;
// read the Digitizer
- RemoveTask("D", fDigitsTitle) ;
+ RemoveTask("D", fDigitsTitle) ; // I do not understand why I need that
if(!Digitizer(fDigitsTitle))
PostDigitizer(fDigitsTitle) ;
digitizerbranch->SetAddress(DigitizerRef(fDigitsTitle)) ;
Int_t AliPHOSGetter::ReadTreeH()
{
// Read the first entry of PHOS branch in hit tree gAlice->TreeH()
+
+ TTree * treeH = gAlice->TreeH() ;
- if(gAlice->TreeH()== 0){
- cerr << "WARNING: AliPHOSGetter::ReadTreeH: -> Cannot read TreeH " << endl ;
- return 1;
+ if(!treeH) {// TreeH not found in header file
+
+ if (fDebug)
+ cout << "WARNING: AliPHOSGetter::ReadTreeH -> Cannot find TreeH in " << fHeaderFile << endl ;
+
+ TString searchFileName("") ;
+
+ if (SDigitizer()) // SDigitizer found in header file
+ searchFileName = SDigitizer()->GetTitle() ;
+
+ else if (Digitizer()) // Digitizer found in header file
+ searchFileName = Digitizer()->GetHitsFileName() ;
+
+ else if (Clusterizer()) // Clusterizer found in header file
+ searchFileName = Clusterizer()->GetHitsFileName() ;
+
+ if (treeH = TreeH(searchFileName)) { //found TreeH in the file which contains the hits
+ if (fDebug)
+ cout << "INFO: AliPHOSGetter::ReadTreeH -> TreeH found in " << searchFileName.Data() << endl ;
+
+ } else {
+ cerr << "ERROR: AliPHOSGetter::ReadTreeH -> TreeH not found " << endl ;
+ return 1;
+ }
}
- TBranch * hitsbranch = static_cast<TBranch*>(gAlice->TreeH()->GetBranch("PHOS")) ;
+ TBranch * hitsbranch = static_cast<TBranch*>(treeH->GetBranch("PHOS")) ;
if ( !hitsbranch ) {
if (fDebug)
cout << "WARNING: AliPHOSGetter::ReadTreeH -> Cannot find branch PHOS" << endl ;
// See AliPHOSPIDv1
if(gAlice->TreeR()== 0){
- cerr << "WARNING: AliPHOSGetter::ReadTreeR: can not read TreeR " << endl ;
+ if (fDebug)
+ cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find TreeR" << endl ;
return 1;
}
// RecPoints
treeName += event ;
treeS = dynamic_cast<TTree*>(gDirectory->Get(treeName.Data()));
}
- if(treeS==0){
- cerr << "WARNING: AliPHOSGetter::ReadTreeS There is no SDigit Tree" << endl;
+ if(!treeS){ // TreeS not found in header file
+
+ if (fDebug)
+ cout << "WARNING: AliPHOSGetter::ReadTreeS -> Cannot find TreeS in " << fHeaderFile << endl;
+
+ TString searchFileName("") ;
+
+ if (SDigitizer()) // SDigitizer found in header file
+ searchFileName = SDigitizer()->GetTitle() ;
+
+ else if (Digitizer()) // Digitizer found in header file
+ searchFileName = Digitizer()->GetSDigitsFileName() ;
+
+ else if (Clusterizer()) // Clusterizer found in header file
+ searchFileName = Clusterizer()->GetSDigitsFileName() ;
+
+ if (treeS = TreeS(searchFileName)) { //found TreeS in the file which contains the hits
+ if (fDebug)
+ cout << "INFO: AliPHOSGetter::ReadTreeS -> TreeS found in " << searchFileName.Data() << endl ;
+
+ } else {
+ cerr << "ERROR: AliPHOSGetter::ReadTreeS -> TreeS not found " << endl ;
return 1;
+ }
}
//set address of the SDigits and SDigitizer
}
ar->Delete() ;
- fNPrimaries = gAlice->GetNtrack() ;
+ if (TreeK(fHeaderFile)) { // treeK found in header file
+ if (fDebug)
+ cout << "INFO: AliPHOSGetter::ReadPrimaries -> TreeK found in " << fHeaderFile.Data() << endl ;
+ fNPrimaries = gAlice->GetNtrack() ;
+
+ } else { // treeK not found in header file
+
+ TString searchFileName("") ;
+
+ if (SDigitizer()) // SDigitizer found in header file
+ searchFileName = SDigitizer()->GetTitle() ;
+
+ else if (Digitizer()) // Digitizer found in header file
+ searchFileName = Digitizer()->GetHitsFileName() ;
+
+ else if (Clusterizer()) // Clusterizer found in header file
+ searchFileName = Clusterizer()->GetHitsFileName() ;
+
+ if (TreeK(searchFileName)) { //found TreeK in the file which contains the hits
+ if (fDebug)
+ cout << "INFO: AliPHOSGetter::ReadPrimaries -> TreeK found in " << searchFileName.Data() << endl ;
+ fAlice->GetEvent(EventNumber()) ;
+ fNPrimaries = fAlice->GetNtrack() ;
+
+ } else {
+ cerr << "ERROR: AliPHOSGetter::ReadPrimaries -> TreeK not found " << endl ;
+ return ;
+ }
+
+ }
Int_t index = 0 ;
for (index = 0 ; index < fNPrimaries; index++) {
new ((*ar)[index]) TParticle(*(Primary(index)));
}
}
+
//____________________________________________________________________________
void AliPHOSGetter::Event(const Int_t event, const char* opt)
{
Int_t rvRD = 0 ;
Int_t rvRR = 0 ;
- if(strstr(opt,"H") )
- rvRH = ReadTreeH() ;
-
- if(strstr(opt,"S") )
- rvRS = ReadTreeS(event) ;
+ if( strstr(opt,"R") )
+ rvRR = ReadTreeR(any) ;
if( strstr(opt,"D") )
rvRD = ReadTreeD() ;
- if( strstr(opt,"R") )
- rvRR = ReadTreeR(any) ;
+ if(strstr(opt,"S") )
+ rvRS = ReadTreeS(event) ;
+ if(strstr(opt,"H") )
+ rvRH = ReadTreeH() ;
+
if( strstr(opt,"Q") )
ReadTreeQA() ;
-
+
if( strstr(opt,"P") || (strcmp(opt,"")==0) )
- if ( gAlice->Stack() )
- ReadPrimaries() ;
-
+ ReadPrimaries() ;
+
}
//____________________________________________________________________________
// Primaries
TClonesArray * Primaries(void) const { return (TClonesArray*)(ReturnO("Primaries")) ; }
+
// Hits
+ TTree * TreeH(TString filename="") ;
const TClonesArray * Hits(void) { return static_cast<const TClonesArray*>(ReturnO("Hits")) ; }
- const AliPHOSHit * Hit(Int_t index) { return static_cast<const AliPHOSHit*>(Hits()->At(index) );}
+ const AliPHOSHit * Hit(Int_t index) { return static_cast<const AliPHOSHit*>(Hits()->At(index) );}
// SDigits
+ TTree * TreeS(TString filename="") ;
TClonesArray * SDigits(const char * name = 0, const char * file=0) {
return static_cast<TClonesArray*>(ReturnO("SDigits", name, file)) ;
}
}
// Digits
+ TTree * TreeD(TString filename="") ;
TClonesArray * Digits(const char * name = 0)const {
return static_cast<TClonesArray*>(ReturnO("Digits", name)) ;
}
}
// Primaries
- const TParticle * Primary(Int_t index) const ;
+ TTree * TreeK(TString filename="") ;
+ const TParticle * Primary(Int_t index) ;
const Int_t NPrimaries()const { return fNPrimaries; }
const TParticle * Secondary(TParticle * p, Int_t index=1) const ;
Bool_t fFailed ; //! set if file not opend or galice not found
Int_t fDebug ; // Debug level
+ AliRun * fAlice ; //! needed to read TreeK if in an other file than fHeaderFile
Int_t fNPrimaries ; //! # of primaries
TObjArray * fPrimaries ; //! list of lists of primaries-for the case of mixing
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