7 #include <TEfficiency.h>
29 m_cl_file =
new TFile(fn_clean);
30 m_cl_tree = (TTree*)m_cl_file->Get(
"tree");
36 m_cl_tree->SetBranchAddress(
"evt" , &m_cl_evt);
37 m_cl_tree->SetBranchAddress(
"trk_true", &m_cl_trk_true);
38 m_cl_tree->SetBranchAddress(
"trk_reco", &m_cl_trk_reco);
39 m_cl_tree->SetBranchAddress(
"dim_true", &m_cl_dim_true);
40 m_cl_tree->SetBranchAddress(
"dim_reco", &m_cl_dim_reco);
42 m_me_file =
new TFile(fn_messy);
43 m_me_tree = (TTree*)m_me_file->Get(
"tree");
49 m_me_tree->SetBranchAddress(
"evt" , &m_me_evt);
50 m_me_tree->SetBranchAddress(
"trk_true", &m_me_trk_true);
51 m_me_tree->SetBranchAddress(
"trk_reco", &m_me_trk_reco);
52 m_me_tree->SetBranchAddress(
"dim_true", &m_me_dim_true);
53 m_me_tree->SetBranchAddress(
"dim_reco", &m_me_dim_reco);
55 gSystem->mkdir(
"result",
true);
56 m_out_file =
new TFile(
"result/output.root",
"RECREATE");
57 m_h1_trk_pos_cl =
new TH1D(
"h1_trk_pos_cl",
";RF+00;", 20, 0, 1000);
58 m_h1_trk_pos_me =
new TH1D(
"h1_trk_pos_me",
";RF+00;", 20, 0, 1000);
59 m_h1_trk_neg_cl =
new TH1D(
"h1_trk_neg_cl",
";RF+00;", 20, 0, 1000);
60 m_h1_trk_neg_me =
new TH1D(
"h1_trk_neg_me",
";RF+00;", 20, 0, 1000);
61 m_h1_dim_cl =
new TH1D(
"h1_dim_cl" ,
";RF+00;", 20, 0, 1000);
62 m_h1_dim_me =
new TH1D(
"h1_dim_me" ,
";RF+00;", 20, 0, 1000);
71 int n_cl_evt = m_cl_tree->GetEntries();
72 int n_me_evt = m_me_tree->GetEntries();
76 bool no_event =
false;
78 if (i_cl_evt >= n_cl_evt || i_me_evt >= n_me_evt)
return;
79 m_cl_tree->GetEntry(i_cl_evt);
80 m_me_tree->GetEntry(i_me_evt);
84 while (job_evt_cl != job_evt_me) {
85 if (job_evt_cl < job_evt_me) {
87 if (i_cl_evt >= n_cl_evt)
return;
88 m_cl_tree->GetEntry(i_cl_evt);
92 if (i_me_evt >= n_me_evt)
return;
93 m_me_tree->GetEntry(i_me_evt);
99 cout <<
"AnaCleanAndMessyData::Analyze(): Job ID " << m_cl_evt->
job_id <<
", Event ID " << m_cl_evt->
event_id <<
": Clean " << i_cl_evt <<
"/" << n_cl_evt <<
", Messy " << i_me_evt <<
"/" << n_me_evt << endl;
109 if (m_cl_file) m_cl_file->Close();
110 if (m_me_file) m_me_file->Close();
111 if (m_out_file) DrawAndWriteOutput();
118 void AnaCleanAndMessyData::AnalyzeEvent()
120 double ww = m_cl_evt->
weight;
121 int rfp01 = m_me_evt->
rfp01;
122 int rfp00 = m_me_evt->
rfp00;
123 int rfm01 = m_me_evt->
rfm01;
124 int n_h1x = m_me_evt->
n_h1x;
125 int n_h2x = m_me_evt->
n_h2x;
126 int n_h3x = m_me_evt->
n_h3x;
127 int n_h4x = m_me_evt->
n_h4x;
129 int n_trk_pos_cl = 0;
130 int n_trk_neg_cl = 0;
131 for (
int ii = 0; ii < m_cl_trk_reco->size(); ii++) {
133 if (td->
charge > 0) n_trk_pos_cl++;
137 int n_trk_pos_me = 0;
138 int n_trk_neg_me = 0;
139 for (
int ii = 0; ii < m_me_trk_reco->size(); ii++) {
141 if (td->
charge > 0) n_trk_pos_me++;
145 int n_dim_cl = m_cl_dim_reco->size();
146 int n_dim_me = m_me_dim_reco->size();
148 m_h1_trk_pos_cl->Fill(rfp00, n_trk_pos_cl);
149 m_h1_trk_pos_me->Fill(rfp00, n_trk_pos_me);
150 m_h1_trk_neg_cl->Fill(rfp00, n_trk_neg_cl);
151 m_h1_trk_neg_me->Fill(rfp00, n_trk_neg_me);
152 m_h1_dim_cl ->Fill(rfp00, n_dim_cl );
153 m_h1_dim_me ->Fill(rfp00, n_dim_me );
157 void AnaCleanAndMessyData::DrawAndWriteOutput()
161 TEfficiency* teff_trk_pos =
new TEfficiency(*m_h1_trk_pos_me, *m_h1_trk_pos_cl);
162 TEfficiency* teff_trk_neg =
new TEfficiency(*m_h1_trk_neg_me, *m_h1_trk_neg_cl);
163 TEfficiency* teff_dim =
new TEfficiency(*m_h1_dim_me , *m_h1_dim_cl );
164 teff_trk_pos->SetName(
"teff_trk_pos");
165 teff_trk_neg->SetName(
"teff_trk_neg");
166 teff_dim ->SetName(
"teff_dim");
167 teff_trk_pos->SetTitle(
";RF+00;Reco. efficiency of #mu^{#plus}");
168 teff_trk_neg->SetTitle(
";RF+00;Reco. efficiency of #mu^{#minus}");
169 teff_dim ->SetTitle(
";RF+00;Reco. efficiency of dimuon");
171 TCanvas* c1 =
new TCanvas(
"c1",
"");
173 teff_trk_pos->Draw();
174 c1->SaveAs(
"result/teff_trk_pos.png");
175 teff_trk_neg->Draw();
176 c1->SaveAs(
"result/teff_trk_neg.png");
178 c1->SaveAs(
"result/teff_dim.png");
181 teff_trk_pos->Write();
182 teff_trk_neg->Write();
std::vector< DimuonData > DimuonList
std::vector< TrackData > TrackList
virtual ~AnaCleanAndMessyData()
void Init(const char *fn_clean, const char *fn_messy)
void Analyze()
Function to analyze a pair of non-embedded and embedded (i.e. clean and messy) data.