1 void subtractPileup(
const char *pileupCutFile,
const char *noPileupCutFile,
const char *subFile,
double eff=0.75) {
14 TFile *tfCut, *tfNoCut, *tfOut;
15 TH2D *cut, *noCut, *noPileup, *pileup;
17 const char* binName[]={
"all",
"awayside",
"nearside",
"soft",
"softAS",
"softNS",
"neck",
"neckAS",
"neckNS",
"hard",
"hardAS",
"hardNS",
"softHard",
"softHardAS",
"softHardNS"};
18 const char* type[] = {
"PP",
"PM",
"MP",
"MM",
"LS",
"US",
"CD",
"CI"};
20 const char* knd[]={
"YtYt",
"SYtDYt",
"PtPt",
21 "NEtaEta",
"PtEtaEta",
"NPhiPhi",
"PtPhiPhi",
22 "NDEtaDPhi",
"PtDEtaDPhi",
"NSEtaDPhi",
"PtSEtaDPhi"};
25 TFile *tfCut =
new TFile(pileupCutFile);
26 TFile *tfNoCut =
new TFile(noPileupCutFile);
27 TFile *tfOut =
new TFile(subFile,
"RECREATE");
31 for (
int it=0;it<8;it++) {
32 for (
int ik=0;ik<11;ik++) {
33 for (
int ibin=0;ibin<15;ibin++) {
35 sprintf(buffer,
"%s_%s_%s_%i",binName[ibin],knd[ik],type[it],ic);
36 tfCut->GetObject(buffer,cut);
37 tfNoCut->GetObject(buffer,noCut);
38 while (cut && noCut) {
40 noPileup = (TH2D *) cut->Clone();
41 pileup = (TH2D *) cut->Clone();
44 sprintf(buffer,
"%s_%s_%s_%i_pileup",binName[ibin],knd[ik],type[it],ic);
45 pileup->SetName(buffer);
47 noPileup->Add(cut,noCut,1,-(1-eff));
48 noPileup->Scale(1/eff);
49 pileup->Add(noCut,cut,1,-1);
52 for (
int ix=1;ix<=noCut->GetNbinsX();ix++) {
53 for (
int iy=1;iy<=noCut->GetNbinsY();iy++) {
54 double err = cut->GetBinError(ix,iy);
55 noPileup->SetBinError(ix,iy,err);
56 pileup->SetBinError(ix,iy,err);
69 sprintf(buffer,
"%s_%s_%s_%i",binName[ibin],knd[ik],type[it],ic);
70 tfCut->GetObject(buffer,cut);
71 tfNoCut->GetObject(buffer,noCut);