20 bool UseRatioForResponse = c1.
getValue<
bool> (
"UseRatioForResponse",
true);
21 bool IsPFJet = c1.
getValue<
bool> (
"IsPFJet",
false);
22 int NJETS_MAX = c1.
getValue<
int> (
"NJETS_MAX", 2);
23 double JetPT_MIN = c1.
getValue<
double> (
"JetPT_MIN", 1.0);
24 double DR_MIN = c1.
getValue<
double> (
"DR_MIN", 0.25);
25 std::vector<double> pt_vec = c1.
getVector<
double>(
"RefPtBoundaries" );
26 std::vector<double> eta_vec = c1.
getVector<
double>(
"EtaBoundaries" );
27 if (!c1.
check())
return 0;
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)
53 std::vector<std::string> HistoNamesList;
54 TFile *
inf =
new TFile(TreeFilename.c_str(),
"R");
55 if (inf->IsZombie())
return 0;
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;
66 br_emfJet = (TBranch*)tr->GetBranch(
"emfJet");
67 br_emfJet->SetAddress(&emfJet);
71 br_chfJet = (TBranch*)tr->GetBranch(
"chfJet");
72 br_chfJet->SetAddress(&chfJet);
74 TBranch *br_etaJet = (TBranch*)tr->GetBranch(
"etaJet");
75 br_etaJet->SetAddress(&etaJet);
76 TBranch *br_etaGen = (TBranch*)tr->GetBranch(
"etaGen");
77 br_etaGen->SetAddress(&etaGen);
78 TBranch *br_phiJet = (TBranch*)tr->GetBranch(
"phiJet");
79 br_phiJet->SetAddress(&phiJet);
80 TBranch *br_phiGen = (TBranch*)tr->GetBranch(
"phiGen");
81 br_phiGen->SetAddress(&phiGen);
82 TBranch *br_dR = (TBranch*)tr->GetBranch(
"dR");
83 br_dR->SetAddress(&dR);
84 TBranch *br_rank = (TBranch*)tr->GetBranch(
"rank");
85 br_rank->SetAddress(&rank);
86 std::cout<<
"Total entries:"<<tr->GetEntries()<<std::endl;
91 sprintf(name,
"ptRef_RefPt%d_Barrel",i);
92 hPtRefBarrel[
i] =
new TH1F(name,name,2000,0,2000);
93 sprintf(name,
"ptJet_RefPt%d_Barrel",i);
94 hPtJetBarrel[
i] =
new TH1F(name,name,2000,0,2000);
95 sprintf(name,
"Response_RefPt%d_Barrel",i);
96 hResponseBarrel[
i] =
new TH1F(name,name,responseBins,responseLow,responseHigh);
99 sprintf(name,
"ptRef_RefPt%d_Eta%d",i,j);
100 hPtRef[
i][j] =
new TH1F(name,name,2000,0,2000);
101 sprintf(name,
"ptCalo_RefPt%d_Eta%d",i,j);
102 hPtJet[
i][j] =
new TH1F(name,name,2000,0,2000);
103 sprintf(name,
"Response_RefPt%d_Eta%d",i,j);
104 hResponse[
i][j] =
new TH1F(name,name,responseBins,responseLow,responseHigh);
112 sprintf(name,
"ptRef_RefPt%d",i);
113 hPtRefBarrel[
i] =
new TH1F(name,name,2000,0,2000);
114 sprintf(name,
"ptCalo_RefPt%d",i);
115 hPtJetBarrel[
i] =
new TH1F(name,name,2000,0,2000);
116 sprintf(name,
"Response_RefPt%d",i);
117 hResponseBarrel[
i] =
new TH1F(name,name,responseBins,responseLow,responseHigh);
120 std::cout<<
"Histograms booked"<<std::endl;
121 for(entry=0;entry<tr->GetEntries();entry++)
123 if (entry % (tr->GetEntries()/10) == 0)
124 std::cout<<
"Entries: "<<entry<<std::endl;
126 cut_ptmin = (ptJet>JetPT_MIN);
127 cut_dR = (dR<DR_MIN);
128 cut_njets = (rank<NJETS_MAX);
129 if (cut_ptmin && cut_dR && cut_njets)
131 ind_pt =
getBin(ptGen,pt_vec);
132 ind_eta =
getBin(etaJet,eta_vec);
134 if (UseRatioForResponse && ptGen>0)
137 resp = ptJet - ptGen;
140 if (fabs(etaJet)<1.3 && ind_pt>=0)
142 hPtRefBarrel[ind_pt]->Fill(ptGen);
143 hPtJetBarrel[ind_pt]->Fill(ptJet);
144 hResponseBarrel[ind_pt]->Fill(resp);
146 if (ind_pt>=0 && ind_eta>=0 && NETA>1)
148 hPtRef[ind_pt][ind_eta]->Fill(ptGen);
149 hPtJet[ind_pt][ind_eta]->Fill(ptJet);
150 hResponse[ind_pt][ind_eta]->Fill(resp);
156 hPtRefBarrel[ind_pt]->Fill(ptGen);
157 hPtJetBarrel[ind_pt]->Fill(ptJet);
158 hResponseBarrel[ind_pt]->Fill(resp);
std::vector< T > getVector(const std::string &name)
int main(int argc, char **argv)
T getValue(const std::string &name)
int getBin(double x, std::vector< double > boundaries)
bool parse(int argc, char **argv)