26 #include "AliAnalysisManager.h"
28 #include "AliGenPythiaEventHeader.h"
40 : TObject(), fDebug(0),
41 fhCentralityWeight(0),
43 fUseCentralityWeight(0),
45 fCheckMCCrossSection(kFALSE),
46 fJustFillCrossSecHist(0),
50 fCheckPythiaEventHeader(0)
60 TList * outputContainer =
new TList() ;
61 outputContainer->SetName(
"MCWeightHistogram") ;
65 outputContainer->SetOwner(kFALSE);
67 fhXsec =
new TH1F(
"hXsec",
"xsec from pyxsec.root",1,0,1);
68 fhXsec->GetXaxis()->SetBinLabel(1,
"<#sigma>");
69 outputContainer->Add(
fhXsec);
71 fhTrials =
new TH1F(
"hTrials",
"trials root file",1,0,1);
72 fhTrials->GetXaxis()->SetBinLabel(1,
"#sum{ntrials}");
75 return outputContainer ;
92 AliDebug(1,Form(
"MC pT-hard weight: %e",temp));
101 AliDebug(1,Form(
"Centrality %2.1f, weight: %2.2f",
fCentrality,temp));
106 AliDebug(1,Form(
"Event weight %e",weight));
124 Float_t xsection = 0;
126 Float_t avgTrials = 0;
150 TTree *tree = AliAnalysisManager::GetAnalysisManager()->GetTree();
151 if ( !tree )
return 1;
153 TFile *curfile = tree->GetCurrentFile();
155 if ( !curfile )
return 1;
167 AliWarning(
"Parameters from file not recovered properly");
171 fhXsec->Fill(
"<#sigma>",xsection);
174 Float_t nEntries = (Float_t)tree->GetTree()->GetEntries();
176 if(trials >= nEntries && nEntries > 0.) avgTrials = trials/nEntries;
178 fhTrials->Fill(
"#sum{ntrials}",avgTrials);
180 AliInfo(Form(
"xs %2.2e, trial %e, avg trials %2.2e, events per file %e",
181 xsection,trials,avgTrials,nEntries));
183 AliDebug(1,Form(
"Reading File %s",curfile->GetName()));
191 AliInfo(Form(
"MC Weight: %e",
fMCWeight));
197 AliWarning(Form(
"Average number of trials is NULL!! Set weight to 1: xs : %e, trials %e, entries %e",
198 xsection,trials,nEntries));
219 if(file.Contains(
"root_archive.zip#"))
221 Ssiz_t pos1 = file.Index(
"root_archive",12,0,TString::kExact);
222 Ssiz_t pos = file.Index(
"#",1,pos1,TString::kExact);
223 Ssiz_t pos2 = file.Index(
".root",5,TString::kExact);
224 file.Replace(pos+1,pos2-pos1,
"");
229 file.ReplaceAll(
gSystem->BaseName(file.Data()),
"");
234 TFile *fxsec = TFile::Open(Form(
"%s%s",file.Data(),
"pyxsec.root"));
238 fxsec = TFile::Open(Form(
"%s%s",file.Data(),
"pyxsec_hists.root"));
247 TKey* key = (TKey*)fxsec->GetListOfKeys()->At(0);
254 TList *
list =
dynamic_cast<TList*
>(key->ReadObj());
261 xsec = ((TProfile*)list->FindObject(
"h1Xsec")) ->GetBinContent(1);
262 trials = ((TH1F*) list->FindObject(
"h1Trials"))->GetBinContent(1);
268 TTree *xtree = (TTree*)fxsec->Get(
"Xsection");
276 Double_t xsection = 0;
277 xtree->SetBranchAddress(
"xsection",&xsection);
278 xtree->SetBranchAddress(
"ntrials",&ntrials);
299 fhCentralityWeight =
new TH1F(
"hCentralityWeights",
"Centrality weights",nbins,minCen,maxCen);
TList * GetCreateOutputHistograms()
Calculate the weight to the event to be applied when filling histograms.
TH1F * fhCentralityWeight
Container of centrality weights.
Float_t fCentrality
Container of centrality percentile.
Bool_t fJustFillCrossSecHist
Do not provide a weight, just fill cross section histograms.
void InitCentralityWeightsHistogram(Int_t nbins=100, Int_t minCen=0, Int_t maxCen=100)
TH1F * GetCentralityWeightsHistogram()
AliAnaWeights()
Constructor.
TH1F * fhXsec
! Cross section in PYTHIA.
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
Double_t fMCWeight
pT-hard bin MC weight. It is used only internally.
AliGenPythiaEventHeader * fPyEventHeader
! Pythia event header, needed to retrieve cross section, only in recent MC
TString fCurrFileName
Current file path name.
virtual Double_t GetWeight()
Bool_t fUseCentralityWeight
Return the centratlity weight.
Bool_t fCheckPythiaEventHeader
Get cross section from pythia event header.
Bool_t fCheckMCCrossSection
Retrieve from the pyxsec.root file the cross section, only if requested.
virtual Double_t GetPythiaCrossSection()
static Bool_t GetPythiaInfoFromFile(TString currFile, Float_t &xsec, Float_t &trials)
TH1F * fhTrials
! Number of event trials in PYTHIA.