Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
JES_Sub1rhoA.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file JES_Sub1rhoA.cc
1 #define Sub1rhoA_cxx
2 #include "Sub1rhoA.h"
3 #include <TH2.h>
4 #include <TStyle.h>
5 #include <TCanvas.h>
6 
7 void Sub1rhoA::Loop(string str_inp)
8 {
9  if (fChain == 0) return;
10 
11  Long64_t nentries = fChain->GetEntriesFast();
12 
13 
14  JetIndicesMatcher jetmatcher{0.4, 30., 5.};
15 
16  TFile* fout = new TFile(voi_stem(str_inp,".root").c_str(),"recreate");
17 
18  array<TH1D*,10> harr_sub1, harr_rhoA;
19  for (int i=0; i<10; ++i) {
20  int i0 = i*10;
21  int i1 = i*10+10;
22  harr_sub1[i] = new TH1D(Form("JES_sub1_%i",i),
23  Form("JES %i-%i%% MBD Centrality;p_{T}_{truth};#frac{p_{T}^{jet,calo}_{SUB1}-p_{T}^{truth}}{p_{T}^{truth}}",
24  i0,i1), 300, -3., 3.);
25  harr_rhoA[i] = new TH1D(Form("JES_rhoA_%i",i),
26  Form("JES %i-%i%% MBD Centrality;p_{T}_{truth};#frac{(p_{T}^{jet,calo}-#rho^{md.bkgd}A_{jet})-p_{T}^{truth}}{p_{T}^{truth}}",
27  i0,i1), 300, -3., 3.);
28  }
29 
30 
31  Long64_t nbytes = 0, nb = 0;
32  for (Long64_t jentry=0; jentry<nentries;jentry++) {
33  Long64_t ientry = LoadTree(jentry);
34  if (ientry < 0) break;
35  nb = fChain->GetEntry(jentry); nbytes += nb;
36  // if (Cut(ientry) < 0) continue;
37 
38  int k = ((int) cent_mdb)/10;
39  if (k < 0 || k > 9) {
40  cout << " WARNING centrality in un expected bin" << endl;
41  continue;
42  }
43 
44  // match the sub1 jets
45  jetmatcher.reset();
46  jetmatcher.add_truth (*TruthJetEta, *TruthJetPhi, *TruthJetPt);
47  jetmatcher.add_reco (*sub1JetEta, *sub1JetPhi, *sub1JetPt);
48  jetmatcher.do_matching();
49 
50  for (auto pp : jetmatcher.match) {
51  auto T = (*TruthJetPt)[pp.first];
52  if (T<30) continue;
53  auto M = (*sub1JetPt)[pp.second];
54  harr_sub1[k]->Fill((M-T)/T);
55  }
56 
57  // match rhoA jets
58  jetmatcher.reset();
59  jetmatcher.add_truth (*TruthJetEta, *TruthJetPhi, *TruthJetPt);
60  jetmatcher.add_reco (*rhoAJetEta, *rhoAJetPhi, *rhoAJetPtLessRhoA);
61  jetmatcher.do_matching();
62 
63  for (auto pp : jetmatcher.match) {
64  auto T = (*TruthJetPt)[pp.first];
65  if (T<30) continue;
66  auto M = (*rhoAJetPtLessRhoA)[pp.second];
67  harr_rhoA[k]->Fill((M-T)/T);
68  }
69 
70  // if (Cut(ientry) < 0) continue;
71  if (false) if (jentry>10) {
72  cout << " Breaking on jentry(" << jentry << ")" << endl;
73  break;
74  }
75  }
76 
77  for (int k=0;k<10;++k) {
78  harr_sub1[k]->Write();
79  harr_rhoA[k]->Write();
80  }
81  fout->Close();
82 }