Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MatchFakeMiss_Sub1rhoA.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file MatchFakeMiss_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 
15  TFile* fout = new TFile(voi_stem(str_inp,".root").c_str(),"recreate");
16 
17  array<TH1D*,10> harr_sub1, harr_rhoA;
18 
19 
20  array<TH1D*,10> fake_sub1, fake_rhoA, miss_sub1, miss_rhoA;
21  array<TH2D*,10> match_sub1, match_rhoA;
22 
23  int nbins_fake = 40;
24  float lobin_fake = -20.;
25  float hibin_fake = 80.;
26  int nbins_miss = 40;
27  float lobin_miss = -20.;
28  float hibin_miss = 80.;
29 
30 
31  for (int i=0; i<10; ++i) {
32  int i0 = i*10;
33  int i1 = i*10+10;
34 
35  fake_sub1[i] = new TH1D(Form("fake_sub1_%i",i), Form("cent: %i-%i%% MBC Cent;N_{jets} Fake;p_{T}^{SUB1}",i0, i1), nbins_fake, lobin_fake, hibin_fake);
36  fake_rhoA[i] = new TH1D(Form("fake_rhoA_%i",i), Form("cent: %i-%i%% MBC Cent;N_{jets} Fake;p_{T}-#rho#timesA",i0, i1), nbins_fake, lobin_fake, hibin_fake);
37 
38  miss_sub1[i] = new TH1D(Form("miss_sub1_%i",i), Form("cent: %i-%i%% MBC Cent;N_{jets} miss;p_{T}^{truth}",i0, i1), nbins_miss, lobin_miss, hibin_miss);
39  miss_rhoA[i] = new TH1D(Form("miss_rhoA_%i",i), Form("cent: %i-%i%% MBC Cent;N_{jets} miss;p_{T}^{truth}",i0, i1), nbins_miss, lobin_miss, hibin_miss);
40 
41  match_sub1[i] = new TH2D(Form("match_sub1_%i",i), Form("cent: %i-%i%% MBC Cent;p_{T}^{SUB1};p_{T}^{truth}",i0, i1), nbins_fake, lobin_fake, hibin_fake, nbins_miss, lobin_miss, hibin_miss);
42  match_rhoA[i] = new TH2D(Form("match_rhoA_%i",i), Form("cent: %i-%i%% MBC Cent;p_{T}-#rho#timesA;p_{T}^{truth}",i0, i1), nbins_fake, lobin_fake, hibin_fake, nbins_miss, lobin_miss, hibin_miss);
43  }
44 
45  JetIndicesMatcher jetmatcher{0.4, 30., 5.};
46 
47  Long64_t nbytes = 0, nb = 0;
48  for (Long64_t jentry=0; jentry<nentries;jentry++) {
49  Long64_t ientry = LoadTree(jentry);
50  if (ientry < 0) break;
51  nb = fChain->GetEntry(jentry); nbytes += nb;
52  // if (Cut(ientry) < 0) continue;
53 
54  int k = ((int) cent_mdb)/10;
55  if (k < 0 || k > 9) {
56  cout << " WARNING centrality in un expected bin" << endl;
57  continue;
58  }
59 
60  // match the sub1 jets
61  jetmatcher.reset();
62  jetmatcher.add_truth (*TruthJetEta, *TruthJetPhi, *TruthJetPt);
63  jetmatcher.add_reco (*sub1JetEta, *sub1JetPhi, *sub1JetPt);
64  jetmatcher.do_matching();
65 
66  for (auto pp : jetmatcher.match) {
67  auto T = (*TruthJetPt)[pp.first];
68  if (T<30) {
69  cout << " WARNING WHY HERE!!! A0" << endl;
70  continue;
71  }
72  auto M = (*sub1JetPt)[pp.second];
73  match_sub1[k] ->Fill(M,T);
74  }
75  for (auto F : jetmatcher.indices_fake) {
76  auto M = (*sub1JetPt)[F];
77  fake_sub1[k]->Fill(M);
78  }
79  for (auto M : jetmatcher.indices_miss) {
80  auto T = (*TruthJetPt)[M];
81  miss_sub1[k]->Fill(T);
82  }
83 
84 
85  jetmatcher.reset();
86  jetmatcher.add_truth (*TruthJetEta, *TruthJetPhi, *TruthJetPt);
87  jetmatcher.add_reco (*rhoAJetEta, *rhoAJetPhi, *rhoAJetPtLessRhoA);
88  jetmatcher.do_matching();
89 
90  for (auto pp : jetmatcher.match) {
91  auto T = (*TruthJetPt)[pp.first];
92  if (T<30) {
93  cout << " WARNING WHY HERE!!! A1" << endl;
94  continue;
95  }
96  auto M = (*rhoAJetPtLessRhoA)[pp.second];
97  match_rhoA[k]->Fill(M,T);
98  }
99 
100  for (auto F : jetmatcher.indices_fake) {
101  auto pt = (*rhoAJetPtLessRhoA)[F];
102  /* if (pt<6) cout << " pt["<<F<<"]: " << pt << endl; */
103  fake_rhoA[k]->Fill(pt);
104  }
105 
106  for (auto M : jetmatcher.indices_miss) {
107  auto pt = (*TruthJetPt)[M];
108  miss_rhoA[k]->Fill(pt);
109  }
110 
111  // if (Cut(ientry) < 0) continue;
112  if (false) if (jentry>10) {
113  cout << " Breaking on jentry(" << jentry << ")" << endl;
114  break;
115  }
116  }
117 
118  for (int k=0;k<10;++k) {
119  fake_sub1[k]->Write();
120  miss_sub1[k]->Write();
121  match_sub1[k]->Write();
122  fake_rhoA[k]->Write();
123  miss_rhoA[k]->Write();
124  match_rhoA[k]->Write();
125  }
126  fout->Close();
127 }