#include <TH3F.h>
#include <TProfile.h>
#include <TList.h>
+#include <TKey.h>
#include <TLorentzVector.h>
#include <TClonesArray.h>
#include "TDatabasePDG.h"
Bool_t AliAnalysisTaskJFSystematics::Notify()
{
-
- //
+//
// Implemented Notify() to read the cross sections
// and number of trials from pyxsec.root
//
TTree *tree = AliAnalysisManager::GetAnalysisManager()->GetTree();
Double_t xsection = 0;
UInt_t ntrials = 0;
+ Float_t ftrials = 0;
if(tree){
TFile *curfile = tree->GetCurrentFile();
if (!curfile) {
TString fileName(curfile->GetName());
if(fileName.Contains("AliESDs.root")){
- fileName.ReplaceAll("AliESDs.root", "pyxsec.root");
+ fileName.ReplaceAll("AliESDs.root", "");
}
- else if(fileName.Contains("AliAOD.root")){
- fileName.ReplaceAll("AliAOD.root", "pyxsec.root");
+ else if(fileName.Contains("AliAODs.root")){
+ fileName.ReplaceAll("AliAODs.root", "");
}
else if(fileName.Contains("galice.root")){
// for running with galice and kinematics alone...
- fileName.ReplaceAll("galice.root", "pyxsec.root");
+ fileName.ReplaceAll("galice.root", "");
}
-
- TFile *fxsec = TFile::Open(fileName.Data());
+ TFile *fxsec = TFile::Open(Form("%s%s",fileName.Data(),"pyxsec.root"));
if(!fxsec){
- Printf("%s:%d %s not found in the Input",(char*)__FILE__,__LINE__,fileName.Data());
- // no a severe condition, will happen for minbias data
- return kTRUE;
+ if(fDebug>0)Printf("%s:%d %s not found in the Input",(char*)__FILE__,__LINE__,Form("%s%s",fileName.Data(),"pyxsec.root"));
+ // next trial fetch the histgram file
+ fxsec = TFile::Open(Form("%s%s",fileName.Data(),"pyxsec_hists.root"));
+ if(!fxsec){
+ // not a severe condition
+ if(fDebug>0)Printf("%s:%d %s not found in the Input",(char*)__FILE__,__LINE__,Form("%s%s",fileName.Data(),"pyxsec_hists.root"));
+ return kTRUE;
+ }
+ else{
+ // find the tlist we want to be independtent of the name so use the Tkey
+ TKey* key = (TKey*)fxsec->GetListOfKeys()->At(0);
+ if(!key){
+ if(fDebug>0)Printf("%s:%d key not found in the file",(char*)__FILE__,__LINE__);
+ return kTRUE;
+ }
+ TList *list = dynamic_cast<TList*>(key->ReadObj());
+ if(!list){
+ if(fDebug>0)Printf("%s:%d key is not a tlist",(char*)__FILE__,__LINE__);
+ return kTRUE;
+ }
+ xsection = ((TProfile*)list->FindObject("h1Xsec"))->GetBinContent(1);
+ ftrials = ((TH1F*)list->FindObject("h1Trials"))->GetBinContent(1);
+ }
}
- TTree *xtree = (TTree*)fxsec->Get("Xsection");
- if(!xtree){
- Printf("%s:%d tree not found in the pyxsec.root",(char*)__FILE__,__LINE__);
+ else{
+ TTree *xtree = (TTree*)fxsec->Get("Xsection");
+ if(!xtree){
+ Printf("%s:%d tree not found in the pyxsec.root",(char*)__FILE__,__LINE__);
+ }
+ xtree->SetBranchAddress("xsection",&xsection);
+ xtree->SetBranchAddress("ntrials",&ntrials);
+ ftrials = ntrials;
+ xtree->GetEntry(0);
}
- xtree->SetBranchAddress("xsection",&xsection);
- xtree->SetBranchAddress("ntrials",&ntrials);
- xtree->GetEntry(0);
fh1Xsec->Fill("<#sigma>",xsection);
- fh1Trials->Fill("#sum{ntrials}",ntrials);
+ fh1Trials->Fill("#sum{ntrials}",ftrials);
}
return kTRUE;
}
#include <TInterpreter.h>
#include <TChain.h>
#include <TFile.h>
+#include <TKey.h>
#include <TH1F.h>
#include <TH2F.h>
#include <TH3F.h>
TTree *tree = AliAnalysisManager::GetAnalysisManager()->GetTree();
Double_t xsection = 0;
UInt_t ntrials = 0;
+ Float_t ftrials = 0;
if(tree){
TFile *curfile = tree->GetCurrentFile();
if (!curfile) {
TString fileName(curfile->GetName());
if(fileName.Contains("AliESDs.root")){
- fileName.ReplaceAll("AliESDs.root", "pyxsec.root");
+ fileName.ReplaceAll("AliESDs.root", "");
}
- else if(fileName.Contains("AliAOD.root")){
- fileName.ReplaceAll("AliAOD.root", "pyxsec.root");
+ else if(fileName.Contains("AliAODs.root")){
+ fileName.ReplaceAll("AliAODs.root", "");
}
else if(fileName.Contains("galice.root")){
// for running with galice and kinematics alone...
- fileName.ReplaceAll("galice.root", "pyxsec.root");
+ fileName.ReplaceAll("galice.root", "");
}
- TFile *fxsec = TFile::Open(fileName.Data());
+ TFile *fxsec = TFile::Open(Form("%s%s",fileName.Data(),"pyxsec.root"));
if(!fxsec){
- Printf("%s:%d %s not found in the Input",(char*)__FILE__,__LINE__,fileName.Data());
- // no a severe condition
- return kTRUE;
+ if(fDebug>0)Printf("%s:%d %s not found in the Input",(char*)__FILE__,__LINE__,Form("%s%s",fileName.Data(),"pyxsec.root"));
+ // next trial fetch the histgram file
+ fxsec = TFile::Open(Form("%s%s",fileName.Data(),"pyxsec_hists.root"));
+ if(!fxsec){
+ // not a severe condition
+ if(fDebug>0)Printf("%s:%d %s not found in the Input",(char*)__FILE__,__LINE__,Form("%s%s",fileName.Data(),"pyxsec_hists.root"));
+ return kTRUE;
+ }
+ else{
+ // find the tlist we want to be independtent of the name so use the Tkey
+ TKey* key = (TKey*)fxsec->GetListOfKeys()->At(0);
+ if(!key){
+ if(fDebug>0)Printf("%s:%d key not found in the file",(char*)__FILE__,__LINE__);
+ return kTRUE;
+ }
+ TList *list = dynamic_cast<TList*>(key->ReadObj());
+ if(!list){
+ if(fDebug>0)Printf("%s:%d key is not a tlist",(char*)__FILE__,__LINE__);
+ return kTRUE;
+ }
+ xsection = ((TProfile*)list->FindObject("h1Xsec"))->GetBinContent(1);
+ ftrials = ((TH1F*)list->FindObject("h1Trials"))->GetBinContent(1);
+ }
}
- TTree *xtree = (TTree*)fxsec->Get("Xsection");
- if(!xtree){
- Printf("%s:%d tree not found in the pyxsec.root",(char*)__FILE__,__LINE__);
+ else{
+ TTree *xtree = (TTree*)fxsec->Get("Xsection");
+ if(!xtree){
+ Printf("%s:%d tree not found in the pyxsec.root",(char*)__FILE__,__LINE__);
+ }
+ xtree->SetBranchAddress("xsection",&xsection);
+ xtree->SetBranchAddress("ntrials",&ntrials);
+ ftrials = ntrials;
+ xtree->GetEntry(0);
}
- xtree->SetBranchAddress("xsection",&xsection);
- xtree->SetBranchAddress("ntrials",&ntrials);
- xtree->GetEntry(0);
fh1Xsec->Fill("<#sigma>",xsection);
- fh1Trials->Fill("#sum{ntrials}",ntrials);
+ fh1Trials->Fill("#sum{ntrials}",ftrials);
}
return kTRUE;