#include "TROOT.h"
+#include "TKey.h"
#include "TList.h"
+#include "TSystem.h"
#include "TH1F.h"
#include "TProfile.h"
#include "THnSparse.h"
#include "TFile.h"
+#include "TString.h"
#include "AliMCEvent.h"
#include "AliLog.h"
#include "AliAODJet.h"
lOut->Write(lOut->GetName(),TObject::kSingleKey);
fOut->Close();
}
+
+Bool_t AliAnalysisHelperJetTasks::PythiaInfoFromFile(const char* currFile,Float_t &fXsec,Float_t &fTrials){
+ //
+ // get the cross section and the trails either from pyxsec.root or from pysec_hists.root
+ // This is to called in Notify and should provide the path to the AOD/ESD file
+
+ TString file(currFile);
+ fXsec = 0;
+ fTrials = 1;
+
+ if(file.Contains("root_archive.zip#")){
+ Ssiz_t pos1 = file.Index("root_archive",12,TString::kExact);
+ Ssiz_t pos = file.Index("#",1,pos1,TString::kExact);
+ file.Replace(pos+1,20,"");
+ }
+ else {
+ // not an archive take the basename....
+ file.ReplaceAll(gSystem->BaseName(file.Data()),"");
+ }
+ Printf("%s",file.Data());
+
+
+
+
+ TFile *fxsec = TFile::Open(Form("%s%s",file.Data(),"pyxsec.root")); // problem that we cannot really test the existance of a file in a archive so we have to lvie with open error message from root
+ if(!fxsec){
+ // next trial fetch the histgram file
+ fxsec = TFile::Open(Form("%s%s",file.Data(),"pyxsec_hists.root"));
+ if(!fxsec){
+ // not a severe condition but inciate that we have no information
+ return kFALSE;
+ }
+ 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){
+ fxsec->Close();
+ return kFALSE;
+ }
+ TList *list = dynamic_cast<TList*>(key->ReadObj());
+ if(!list){
+ fxsec->Close();
+ return kFALSE;
+ }
+ fXsec = ((TProfile*)list->FindObject("h1Xsec"))->GetBinContent(1);
+ fTrials = ((TH1F*)list->FindObject("h1Trials"))->GetBinContent(1);
+ fxsec->Close();
+ }
+ } // no tree pyxsec.root
+ else {
+ TTree *xtree = (TTree*)fxsec->Get("Xsection");
+ if(!xtree){
+ fxsec->Close();
+ return kFALSE;
+ }
+ UInt_t ntrials = 0;
+ Double_t xsection = 0;
+ xtree->SetBranchAddress("xsection",&xsection);
+ xtree->SetBranchAddress("ntrials",&ntrials);
+ xtree->GetEntry(0);
+ fTrials = ntrials;
+ fXsec = xsection;
+ fxsec->Close();
+ }
+ return kTRUE;
+}
#include "TObject.h"
class AliMCEvent;
class AliAODJet;
+class TString;
class AliGenPythiaEventHeader;
// Helper Class that contains a lot of usefull static functions (i.e. for Flavor selection.
Int_t iDebug, Float_t maxDist = 0.5);
static void MergeOutput(char* cFiles, char* cList = "pwg4spec"); // Merges the files in the input text file needs the two histograms fh1PtHard_Trials, fh1Xsec and the name of the input list
+ static Bool_t PythiaInfoFromFile(const char* currFile,Float_t &fXsec,Float_t &fTrials);// get the cross section and the trails either from pyxsec.root or from pysec_hists.root
+
enum {kMaxJets = 6}; // needed for array size not to fragemnt memory on the heap by many new/delete
private:
fAnalysisType(0),
fExternalWeight(1),
fRecEtaWindow(0.5),
+ fAvgTrials(1),
fh1Xsec(0x0),
fh1Trials(0x0),
fh1PtHard(0x0),
fAnalysisType(0),
fExternalWeight(1),
fRecEtaWindow(0.5),
+ fAvgTrials(1),
fh1Xsec(0x0),
fh1Trials(0x0),
fh1PtHard(0x0),
// and number of trials from pyxsec.root
//
TTree *tree = AliAnalysisManager::GetAnalysisManager()->GetTree();
- Double_t xsection = 0;
- UInt_t ntrials = 0;
- Float_t ftrials = 0;
+ Float_t xsection = 0;
+ Float_t ftrials = 1;
if(tree){
TFile *curfile = tree->GetCurrentFile();
if (!curfile) {
Printf("%s%d No Histogram fh1Xsec",(char*)__FILE__,__LINE__);
return kFALSE;
}
-
- TString fileName(curfile->GetName());
- if(fileName.Contains("AliESDs.root")){
- fileName.ReplaceAll("AliESDs.root", "");
- }
- else if(fileName.Contains("AliAOD.root")){
- fileName.ReplaceAll("AliAOD.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", "");
- }
- TFile *fxsec = TFile::Open(Form("%s%s",fileName.Data(),"pyxsec.root"));
- if(!fxsec){
- 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);
- }
- }
- 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);
- }
+ AliAnalysisHelperJetTasks::PythiaInfoFromFile(curfile->GetName(),xsection,ftrials);
fh1Xsec->Fill("<#sigma>",xsection);
- fh1Trials->Fill("#sum{ntrials}",ftrials);
+ // construct a poor man average trials
+ Float_t nEntries = (Float_t)tree->GetTree()->GetEntries();
+ if(ftrials>=nEntries)fAvgTrials = ftrials/nEntries;
}
return kTRUE;
}
fh1Xsec = new TProfile("fh1Xsec","xsec from pyxsec.root",1,0,1);
fh1Xsec->GetXaxis()->SetBinLabel(1,"<#sigma>");
- fh1Trials = new TH1F("fh1Trials","trials from pyxsec.root",1,0,1);
+ fh1Trials = new TH1F("fh1Trials","trials event header or pyxsec file",1,0,1);
fh1Trials->GetXaxis()->SetBinLabel(1,"#sum{ntrials}");
fh1PtHard = new TH1F("fh1PtHard","PYTHIA Pt hard;p_{T,hard}",nBinPt,binLimitsPt);
}
}
-
-
-
if (fDebug > 1)printf("AliAnalysisTaskJFSystematics::Analysing event # %5d\n", (Int_t) fEntry);
// ========= These pointers need to be valid in any case =======
}
}// if we had the MCEvent
+ if(nTrials==1&&fAvgTrials>1) fh1Trials->Fill("#sum{ntrials}",fAvgTrials);
+ else fh1Trials->Fill("#sum{ntrials}",nTrials);
+
fh1PtHard->Fill(ptHard,eventW);
fh1PtHardNoW->Fill(ptHard,1);
fh1PtHardTrials->Fill(ptHard,nTrials);
Bool_t fUseAODInput; // use AOD input
Bool_t fUseExternalWeightOnly; // use only external weight
Bool_t fLimitGenJetEta; // Limit the eta of the generated jets
- UInt_t fAnalysisType; // Analysis type
+ UInt_t fAnalysisType; // Analysis type
Float_t fExternalWeight; // external weight
Float_t fRecEtaWindow; // eta window used for corraltion plots between rec and gen
-
+ Float_t fAvgTrials; // average number of trials from pyxsec.root or pysec_hists.root in case trials are not avaiable from the MC Header
// Event histograms
TProfile* fh1Xsec; // pythia cross section and trials
TH1F* fh1Trials; // trials are added
TList *fHistList; // Output list
- ClassDef(AliAnalysisTaskJFSystematics, 1) // Analysis task for standard jet analysis
+ ClassDef(AliAnalysisTaskJFSystematics, 2) // Analysis task for standard jet analysis
};
#endif
fJet3PtCut(15.),
fTrackPtCut(0.),
fTrackEtaCut(0.9),
+ fAvgTrials(1),
fhNJets(0x0),
fhEleadingPt(0x0),
fhMinRegPtDist(0x0),
//
// Implemented Notify() to read the cross sections
// and number of trials from pyxsec.root
- // Copy from AliAnalysisTaskJetSpectrum
+ // Copy from AliAnalysisTaskJFSystematics
+ //
+
TTree *tree = AliAnalysisManager::GetAnalysisManager()->GetTree();
- Double_t xsection = 0;
- UInt_t ntrials = 0;
+ Float_t xsection = 0;
+ Float_t ftrials = 1;
if(tree){
TFile *curfile = tree->GetCurrentFile();
if (!curfile) {
Printf("%s%d No Histogram fh1Xsec",(char*)__FILE__,__LINE__);
return kFALSE;
}
-
- TString fileName(curfile->GetName());
- 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){
- Printf("%s:%d %s not found in the Input",(char*)__FILE__,__LINE__,fileName.Data());
- // no a severe condition
- return kTRUE;
- }
- 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);
- xtree->GetEntry(0);
+ AliAnalysisHelperJetTasks::PythiaInfoFromFile(curfile->GetName(),xsection,ftrials);
fh1Xsec->Fill("<#sigma>",xsection);
- fh1Trials->Fill("#sum{ntrials}",ntrials);
- }
-
+ // construct average trials
+ Float_t nEntries = (Float_t)tree->GetTree()->GetEntries();
+ if(ftrials>=nEntries)fAvgTrials = ftrials/nEntries;
+ }
return kTRUE;
}
// Execute analysis for current event
//
if ( fDebug > 3 ) AliInfo( " Processing event..." );
+
+ // fetch the pythia header info and get the trials
+ AliMCEventHandler* mcHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
+ Float_t nTrials = 1;
+ if (mcHandler) {
+ AliMCEvent* mcEvent = mcHandler->MCEvent();
+ if (mcEvent) {
+ AliGenPythiaEventHeader* pythiaGenHeader = AliAnalysisHelperJetTasks::GetPythiaEventHeader(mcEvent);
+ if(pythiaGenHeader){
+ nTrials = pythiaGenHeader->Trials();
+ }
+ }
+ }
+
+ if(nTrials==1&&fAvgTrials>1) fh1Trials->Fill("#sum{ntrials}",fAvgTrials);
+ else fh1Trials->Fill("#sum{ntrials}",nTrials);
+
+
AnalyseUE();
// Post the data
// track cuts
Double_t fTrackPtCut; // Pt cut of tracks in the regions
Double_t fTrackEtaCut; // Eta cut on tracks in the regions (fRegionType=1)
+ Double_t fAvgTrials; // average trials used to fill the fh1Triasl histogram in case we do not have trials on a event by event basis
// Histograms ( are owned by fListOfHistos TList )
TH1F* fhNJets; //!
- ClassDef( AliAnalysisTaskUE, 1); // Analysis task for Underlying Event analysis
+ ClassDef( AliAnalysisTaskUE, 2); // Analysis task for Underlying Event analysis
};
#endif