44 tmp.Form(
"cent%06.2f_%06.2f", c1, c2);
45 tmp.ReplaceAll(
".",
"d");
55 void Run(
const char* nFile,
const char* dFile,
const char* oFile=0) {
57 const Color_t
cc[] = { kMagenta+2,
69 if (oN.IsNull()) oN.Form(
"%c2%c.root", dFile[0], nFile[0]);
70 Printf(
"********************************************************\n" 71 " Generating pure MC weights\n" 73 " Numerator (truth) file: %s\n" 74 " Denominator (correction) file: %s\n" 75 " Output (weight) file: %s\n",
76 nFile, dFile, oN.Data());
79 TFile* nF = TFile::Open(nFile,
"READ");
80 TFile* dF = TFile::Open(dFile,
"READ");
81 if (!nF || !dF)
return;
85 if (!nT || !dT)
return;
95 for (
Int_t b = 1; b <= nC->GetNbinsX(); b++) {
96 Double_t c1 = nC->GetXaxis()->GetBinLowEdge(b);
97 Double_t c2 = nC->GetXaxis()->GetBinUpEdge (b);
99 Color_t cC = cc[b%10];
102 if (!nB || !dB)
continue;
106 if (!nG || !dG)
continue;
110 if (!nPt2 || !dPt2)
continue;
112 TH1* nPt = nPt2->ProjectionY(Form(
"n%s",cN)); nPt->SetDirectory(0);
113 TH1* dPt = dPt2->ProjectionY(Form(
"d%s",cN)); dPt->SetDirectory(0);
114 TH1* rPt =
static_cast<TH1*
>(nPt->Clone(Form(
"r%s", cN)));
116 rPt->SetMarkerColor(cC);
117 rPt->SetDirectory(0);
120 pt =
static_cast<TH2D*
>(
Make2D(0,
"pt",
"pt weights",
121 kBlack, 20, *(nC->GetXaxis()),
122 *(nPt->GetXaxis())));
125 for (
Int_t p = 1; p <= rPt->GetNbinsX(); p++) {
126 pt->SetBinContent(b, p, rPt->GetBinContent(p));
127 pt->SetBinError (b, p, rPt->GetBinError (p));
138 if (!nPdg2 || !dPdg2)
continue;
141 for (
Int_t p = 1; p <= nPdg2->GetNbinsY(); p++) {
142 TString sPdg = nPdg2->GetYaxis()->GetBinLabel(p);
143 Int_t iPdg = sPdg.Atoi();
144 if (iPdg < 0)
continue;
146 TH1* nPdg = nPdg2->ProjectionX(
"ntmp", p, p);
147 TH1* dPdg = dPdg2->ProjectionX(
"dtmp", p, p);
148 if (!nPdg || !dPdg)
continue;
151 static_cast<TH1*
>(nPdg->Clone(Form(
"r%s_%s",cN,sPdg.Data())));
153 rPdg->SetDirectory(0);
154 if (rPdg->GetEntries() < 1) {
161 TF1* fPdg =
new TF1(
"fPdg",
"pol0", -5, .5);
162 rPdg->Fit(fPdg,
"NQR",
"", -.5, +.5);
164 TH1* hPdg =
static_cast<TH1*
>(pdg->FindObject(sPdg));
170 hPdg =
Make1D(pdg,sPdg, tmp, c, s, *(nC->GetXaxis()));
171 hPdg->SetBinContent(0, iPdg);
173 hPdg->SetBinContent(b, fPdg->GetParameter(0));
174 hPdg->SetBinError (b, fPdg->GetParError (0));
190 while ((hPdg = static_cast<TH1D*>(next()))) {
191 Int_t iPdg = hPdg->GetBinContent(0);
192 hPdg->SetBinContent(0, 0);
195 TCanvas*
c =
new TCanvas(
"c",
"c");
198 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)