+Bool_t AliAnalysisTaskMCParticleFilter::Notify()
+{
+ //
+ // Implemented Notify() to read the cross sections
+ // from pyxsec.root
+ //
+ AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+ TTree *tree = mgr->GetTree();
+ Double_t xsection = 0;
+ UInt_t ntrials = 0;
+ if(tree){
+ TFile *curfile = tree->GetCurrentFile();
+ if (!curfile) {
+ Error("Notify","No current file");
+ return kFALSE;
+ }
+
+ TString fileName(curfile->GetName());
+ TString datafile = mgr->GetInputEventHandler()->GetInputFileName();
+ if (fileName.Contains(datafile)) {
+ fileName.ReplaceAll(datafile, "pyxsec.root");
+ }
+ else if(fileName.Contains("AliESDs.root")){
+ fileName.ReplaceAll("AliESDs.root", "pyxsec.root");
+ }
+ else if(fileName.Contains("AliAOD.root")){
+ fileName.ReplaceAll("AliAOD.root", "pyxsec.root");
+ }
+ else if(fileName.Contains("galice.root")){
+ // for running with galice and kinematics alone...
+ fileName.ReplaceAll("galice.root", "pyxsec.root");
+ }
+
+
+ TFile *fxsec = TFile::Open(fileName.Data());
+ if(!fxsec){
+ AliInfo(Form("%s:%d %s not found in the Input",(char*)__FILE__,__LINE__,fileName.Data()));
+ // not a severe condition we just do not have the information...
+ return kTRUE;
+ }
+ TTree *xtree = (TTree*)fxsec->Get("Xsection");
+ if(!xtree){
+ AliWarning(Form("%s:%d tree not found in the pyxsec.root",(char*)__FILE__,__LINE__));
+ return kTRUE;
+ }
+ xtree->SetBranchAddress("xsection",&xsection);
+ xtree->SetBranchAddress("ntrials",&ntrials);
+ xtree->GetEntry(0);
+ ((TProfile*)(fHistList->FindObject("h1Xsec")))->Fill("<#sigma>",xsection);
+ }
+ return kTRUE;
+}
+
+
+