19 bool UseRatioForResponse = c1.
getValue<
bool>(
"UseRatioForResponse",
true);
20 bool IsPFJet = c1.
getValue<
bool>(
"IsPFJet",
false);
21 int NJETS_MAX = c1.
getValue<
int>(
"NJETS_MAX", 2);
22 double JetPT_MIN = c1.
getValue<
double>(
"JetPT_MIN", 1.0);
23 double DR_MIN = c1.
getValue<
double>(
"DR_MIN", 0.25);
24 std::vector<double> pt_vec = c1.
getVector<
double>(
"RefPtBoundaries");
25 std::vector<double> eta_vec = c1.
getVector<
double>(
"EtaBoundaries");
30 const int MAX_NETA = 83;
31 const int MAX_NPT = 30;
32 TH1F *hPtRef[MAX_NPT][MAX_NETA];
33 TH1F *hPtJet[MAX_NPT][MAX_NETA];
34 TH1F *hPtRefBarrel[MAX_NPT];
35 TH1F *hPtJetBarrel[MAX_NPT];
36 TH1F *hResponseBarrel[MAX_NPT];
37 TH1F *hResponse[MAX_NPT][MAX_NETA];
38 int NPT = pt_vec.size() - 1;
39 int NETA = eta_vec.size() - 1;
41 bool cut_ptmin, cut_dR, cut_njets;
42 float ptJet, ptGen, etaJet, emfJet, chfJet, etaGen, phiJet, phiGen, dR, resp;
44 int i,
j, ind_pt, ind_eta, responseBins(2200);
45 double responseLow(-1000.), responseHigh(100.);
47 if (UseRatioForResponse) {
52 std::vector<std::string> HistoNamesList;
53 TFile *
inf =
new TFile(TreeFilename.c_str(),
"R");
56 TFile *outf =
new TFile(HistoFilename.c_str(),
"RECREATE");
58 TTree *tr = (TTree *)inf->Get(
"mcTruthTree");
59 TBranch *br_ptJet = (TBranch *)tr->GetBranch(
"ptJet");
60 br_ptJet->SetAddress(&ptJet);
61 TBranch *br_ptGen = (TBranch *)tr->GetBranch(
"ptGen");
62 br_ptGen->SetAddress(&ptGen);
63 TBranch *br_emfJet, *br_chfJet;
65 br_emfJet = (TBranch *)tr->GetBranch(
"emfJet");
66 br_emfJet->SetAddress(&emfJet);
68 br_chfJet = (TBranch *)tr->GetBranch(
"chfJet");
69 br_chfJet->SetAddress(&chfJet);
71 TBranch *br_etaJet = (TBranch *)tr->GetBranch(
"etaJet");
72 br_etaJet->SetAddress(&etaJet);
73 TBranch *br_etaGen = (TBranch *)tr->GetBranch(
"etaGen");
74 br_etaGen->SetAddress(&etaGen);
75 TBranch *br_phiJet = (TBranch *)tr->GetBranch(
"phiJet");
76 br_phiJet->SetAddress(&phiJet);
77 TBranch *br_phiGen = (TBranch *)tr->GetBranch(
"phiGen");
78 br_phiGen->SetAddress(&phiGen);
79 TBranch *br_dR = (TBranch *)tr->GetBranch(
"dR");
80 br_dR->SetAddress(&dR);
81 TBranch *br_rank = (TBranch *)tr->GetBranch(
"rank");
82 br_rank->SetAddress(&rank);
83 std::cout <<
"Total entries:" << tr->GetEntries() << std::endl;
85 for (i = 0; i < NPT; i++) {
86 sprintf(name,
"ptRef_RefPt%d_Barrel", i);
87 hPtRefBarrel[
i] =
new TH1F(name, name, 2000, 0, 2000);
88 sprintf(name,
"ptJet_RefPt%d_Barrel", i);
89 hPtJetBarrel[
i] =
new TH1F(name, name, 2000, 0, 2000);
90 sprintf(name,
"Response_RefPt%d_Barrel", i);
91 hResponseBarrel[
i] =
new TH1F(name, name, responseBins, responseLow, responseHigh);
92 for (j = 0; j < NETA; j++) {
93 sprintf(name,
"ptRef_RefPt%d_Eta%d", i, j);
94 hPtRef[
i][
j] =
new TH1F(name, name, 2000, 0, 2000);
95 sprintf(name,
"ptCalo_RefPt%d_Eta%d", i, j);
96 hPtJet[
i][
j] =
new TH1F(name, name, 2000, 0, 2000);
97 sprintf(name,
"Response_RefPt%d_Eta%d", i, j);
98 hResponse[
i][
j] =
new TH1F(name, name, responseBins, responseLow, responseHigh);
102 for (i = 0; i < NPT; i++) {
103 sprintf(name,
"ptRef_RefPt%d", i);
104 hPtRefBarrel[
i] =
new TH1F(name, name, 2000, 0, 2000);
105 sprintf(name,
"ptCalo_RefPt%d", i);
106 hPtJetBarrel[
i] =
new TH1F(name, name, 2000, 0, 2000);
107 sprintf(name,
"Response_RefPt%d", i);
108 hResponseBarrel[
i] =
new TH1F(name, name, responseBins, responseLow, responseHigh);
111 std::cout <<
"Histograms booked" << std::endl;
112 for (entry = 0; entry < tr->GetEntries(); entry++) {
113 if (entry % (tr->GetEntries() / 10) == 0)
114 std::cout <<
"Entries: " << entry << std::endl;
116 cut_ptmin = (ptJet > JetPT_MIN);
117 cut_dR = (dR < DR_MIN);
118 cut_njets = (rank < NJETS_MAX);
119 if (cut_ptmin && cut_dR && cut_njets) {
120 ind_pt =
getBin(ptGen, pt_vec);
121 ind_eta =
getBin(etaJet, eta_vec);
123 if (UseRatioForResponse && ptGen > 0)
124 resp = ptJet / ptGen;
126 resp = ptJet - ptGen;
128 if (fabs(etaJet) < 1.3 && ind_pt >= 0) {
129 hPtRefBarrel[ind_pt]->Fill(ptGen);
130 hPtJetBarrel[ind_pt]->Fill(ptJet);
131 hResponseBarrel[ind_pt]->Fill(resp);
133 if (ind_pt >= 0 && ind_eta >= 0 && NETA > 1) {
134 hPtRef[ind_pt][ind_eta]->Fill(ptGen);
135 hPtJet[ind_pt][ind_eta]->Fill(ptJet);
136 hResponse[ind_pt][ind_eta]->Fill(resp);
141 hPtRefBarrel[ind_pt]->Fill(ptGen);
142 hPtJetBarrel[ind_pt]->Fill(ptJet);
143 hResponseBarrel[ind_pt]->Fill(resp);
std::vector< T > getVector(const std::string &name)
T getValue(const std::string &name)
int getBin(double x, std::vector< double > boundaries)
bool parse(int argc, char **argv)