26 #include "AliAnalysisManager.h" 28 #include "AliGenPythiaEventHeader.h" 41 fhCentralityWeight(0),
43 fUseCentralityWeight(0),
44 fDoMCParticlePtWeights(1),
45 fEtaFunction(0), fPi0Function(0),
48 fCheckMCCrossSection(kFALSE),
49 fJustFillCrossSecHist(0),
53 fCheckPythiaEventHeader(0)
76 outputContainer->SetName(
"MCWeightHistogram") ;
80 outputContainer->SetOwner(kFALSE);
82 fhXsec =
new TH1F(
"hXsec",
"xsec from pyxsec.root",1,0,1);
83 fhXsec->GetXaxis()->SetBinLabel(1,
"<#sigma>");
84 outputContainer->Add(
fhXsec);
86 fhTrials =
new TH1F(
"hTrials",
"trials root file",1,0,1);
87 fhTrials->GetXaxis()->SetBinLabel(1,
"#sum{ntrials}");
90 return outputContainer ;
107 AliDebug(1,Form(
"MC pT-hard weight: %e",temp));
116 AliDebug(1,Form(
"Centrality %2.1f, weight: %2.2f",
fCentrality,temp));
121 AliDebug(1,Form(
"Event weight %e",weight));
147 (genName.Contains(
"Pi0") || genName.Contains(
"pi0") || genName.Contains(
"PARAM") || genName.Contains(
"BOX")))
150 (genName.Contains(
"Eta") || genName.Contains(
"eta") || genName.Contains(
"PARAM") || genName.Contains(
"BOX")))
153 AliDebug(1,Form(
"MC particle pdg %d, pt %2.2f, generator %s with index %d: weight %f",pdg,pt,genName.Data(),igen, weight));
197 TTree *tree = AliAnalysisManager::GetAnalysisManager()->GetTree();
198 if ( !tree )
return 1;
200 TFile *curfile = tree->GetCurrentFile();
202 if ( !curfile )
return 1;
214 AliWarning(
"Parameters from file not recovered properly");
218 fhXsec->Fill(
"<#sigma>",xsection);
223 if(trials >= nEntries && nEntries > 0.) avgTrials = trials/nEntries;
225 fhTrials->Fill(
"#sum{ntrials}",avgTrials);
227 AliInfo(Form(
"xs %2.2e, trial %e, avg trials %2.2e, events per file %e",
228 xsection,trials,avgTrials,nEntries));
230 AliDebug(1,Form(
"Reading File %s",curfile->GetName()));
238 AliInfo(Form(
"MC Weight: %e",
fMCWeight));
244 AliWarning(Form(
"Average number of trials is NULL!! Set weight to 1: xs : %e, trials %e, entries %e",
245 xsection,trials,nEntries));
266 if(file.Contains(
"root_archive.zip#"))
268 Ssiz_t pos1 = file.Index(
"root_archive",12,0,TString::kExact);
269 Ssiz_t pos = file.Index(
"#",1,pos1,TString::kExact);
270 Ssiz_t pos2 = file.Index(
".root",5,TString::kExact);
271 file.Replace(pos+1,pos2-pos1,
"");
276 file.ReplaceAll(
gSystem->BaseName(file.Data()),
"");
281 TFile *fxsec = TFile::Open(Form(
"%s%s",file.Data(),
"pyxsec.root"));
285 fxsec = TFile::Open(Form(
"%s%s",file.Data(),
"pyxsec_hists.root"));
294 TKey* key = (TKey*)fxsec->GetListOfKeys()->At(0);
301 TList *list =
dynamic_cast<TList*
>(key->ReadObj());
308 xsec = ((TProfile*)list->FindObject(
"h1Xsec")) ->GetBinContent(1);
309 trials = ((TH1F*) list->FindObject(
"h1Trials"))->GetBinContent(1);
315 TTree *xtree = (
TTree*)fxsec->Get(
"Xsection");
324 xtree->SetBranchAddress(
"xsection",&xsection);
325 xtree->SetBranchAddress(
"ntrials",&ntrials);
346 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.
Double_t GetParticlePtWeight(Float_t pt, Int_t pdg, TString genName, Int_t igen) const
Float_t fCentrality
Container of centrality percentile.
Bool_t fJustFillCrossSecHist
Do not provide a weight, just fill cross section histograms.
virtual ~AliAnaWeights()
Destructor.
void InitCentralityWeightsHistogram(Int_t nbins=100, Int_t minCen=0, Int_t maxCen=100)
TF1 * fPi0Function
! pi0 spectrum parametrization
TH1F * GetCentralityWeightsHistogram()
AliAnaWeights()
Constructor.
TH1F * fhXsec
! Cross section in PYTHIA.
TF1 * fEtaFunction
! eta spectrum parametrization
Double_t fMCWeight
pT-hard bin MC weight. It is used only internally.
TFile * file
TList with histograms for a given trigger.
AliGenPythiaEventHeader * fPyEventHeader
! Pythia event header, needed to retrieve cross section, only in recent MC
TString fCurrFileName
Current file path name.
Bool_t fDoMCParticlePtWeights
activate the generation of a pT weight depending on MC particle pdg and generator ...
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.