43 tmp.Form(
"cent%06.2f_%06.2f", c1, c2);
44 tmp.ReplaceAll(
".",
"d");
54 void Run(
const char* nFile,
const char* dFile,
const char* oFile=0) {
56 const Color_t
cc[] = { kMagenta+2,
68 if (oN.IsNull()) oN.Form(
"%c2%c.root", dFile[0], nFile[0]);
69 Printf(
"********************************************************\n"
70 " Generating pure MC weights\n"
72 " Numerator (truth) file: %s\n"
73 " Denominator (correction) file: %s\n"
74 " Output (weight) file: %s\n",
75 nFile, dFile, oN.Data());
78 TFile* nF = TFile::Open(nFile,
"READ");
79 TFile* dF = TFile::Open(dFile,
"READ");
80 if (!nF || !dF)
return;
84 if (!nT || !dT)
return;
94 for (
Int_t b = 1; b <= nC->GetNbinsX(); b++) {
95 Double_t c1 = nC->GetXaxis()->GetBinLowEdge(b);
96 Double_t c2 = nC->GetXaxis()->GetBinUpEdge (b);
98 Color_t cC = cc[b%10];
101 if (!nB || !dB)
continue;
105 if (!nG || !dG)
continue;
109 if (!nPt2 || !dPt2)
continue;
111 TH1* nPt = nPt2->ProjectionY(Form(
"n%s",cN)); nPt->SetDirectory(0);
112 TH1* dPt = dPt2->ProjectionY(Form(
"d%s",cN)); dPt->SetDirectory(0);
113 TH1* rPt =
static_cast<TH1*
>(nPt->Clone(Form(
"r%s", cN)));
115 rPt->SetMarkerColor(cC);
116 rPt->SetDirectory(0);
119 pt =
static_cast<TH2D*
>(
Make2D(0,
"pt",
"pt weights",
120 kBlack, 20, *(nC->GetXaxis()),
121 *(nPt->GetXaxis())));
124 for (
Int_t p = 1; p <= rPt->GetNbinsX(); p++) {
125 pt->SetBinContent(b, p, rPt->GetBinContent(p));
126 pt->SetBinError (b, p, rPt->GetBinError (p));
137 if (!nPdg2 || !dPdg2)
continue;
140 for (
Int_t p = 1; p <= nPdg2->GetNbinsY(); p++) {
141 TString sPdg = nPdg2->GetYaxis()->GetBinLabel(p);
142 Int_t iPdg = sPdg.Atoi();
143 if (iPdg < 0)
continue;
145 TH1* nPdg = nPdg2->ProjectionX(
"ntmp", p, p);
146 TH1* dPdg = dPdg2->ProjectionX(
"dtmp", p, p);
147 if (!nPdg || !dPdg)
continue;
150 static_cast<TH1*
>(nPdg->Clone(Form(
"r%s_%s",cN,sPdg.Data())));
152 rPdg->SetDirectory(0);
153 if (rPdg->GetEntries() < 1) {
160 TF1* fPdg =
new TF1(
"fPdg",
"pol0", -5, .5);
161 rPdg->Fit(fPdg,
"NQR",
"", -.5, +.5);
163 TH1* hPdg =
static_cast<TH1*
>(pdg->FindObject(sPdg));
169 hPdg =
Make1D(pdg,sPdg, tmp, c, s, *(nC->GetXaxis()));
170 hPdg->SetBinContent(0, iPdg);
172 hPdg->SetBinContent(b, fPdg->GetParameter(0));
173 hPdg->SetBinError (b, fPdg->GetParError (0));
189 while ((hPdg = static_cast<TH1D*>(next()))) {
190 Int_t iPdg = hPdg->GetBinContent(0);
191 hPdg->SetBinContent(0, 0);
194 TCanvas*
c =
new TCanvas(
"c",
"c");
197 TFile* out = TFile::Open(oN,
"RECREATE");
static void PdgAttr(Int_t pdg, TString &nme, Color_t &c, Style_t &s)
static TH2 * Make2D(Container *c, const TString &name, const TString &title, Color_t color, Style_t style, const TAxis &xAxis, const TAxis &yAxis)
Bool_t AddAbundanceWeight(Short_t pdg, const TH1D *h, UShort_t mode=0)
static TH1 * GetH1(Container *parent, const char *name, Bool_t verb=true)
const char * CentName(Double_t c1, Double_t c2)
void Draw(Option_t *option="")
static Bool_t CheckConsistency(const TH1 *h1, const TH1 *h2)
Utilities for midrapidity analysis.
Encode simulation weights for 2nd pass.
Bool_t SetPtWeight(const TH2D *h, UShort_t mode=0)
static TH2 * GetH2(Container *parent, const char *name, Bool_t verb=true)
static Container * GetC(Container *parent, const char *name, Bool_t verb=true)
static TH1 * Make1D(Container *c, const TString &name, const TString &title, Color_t color, Style_t style, const TAxis &xAxis)
void Run(const char *nFile, const char *dFile, const char *oFile=0)