ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/UHHAnalysis/SFrameAnalysis/src/AnalysisHists.cxx
Revision: 1.2
Committed: Wed Jun 12 12:37:29 2013 UTC (11 years, 10 months ago) by peiffer
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -1 lines
Error occurred while calculating annotation data.
Log Message:
removed ObjectHandler

File Contents

# Content
1 #include "include/AnalysisHists.h"
2 #include "include/EventCalc.h"
3 #include <iostream>
4
5 using namespace std;
6
7 AnalysisHists::AnalysisHists(const char* name, HypothesisDiscriminator *discr) : BaseHists(name)
8 {
9 // named default constructor
10 m_discr = discr;
11 }
12
13 AnalysisHists::~AnalysisHists()
14 {
15 // default destructor, does nothing
16 }
17
18 void AnalysisHists::Init()
19 {
20 // missing ET and HT
21 double* logMET_bins = MakeLogBinning(50, 0, 1500);
22 Book( TH1F( "MET", "missing E_{T} [GeV]", 1500, 0, 1500) );//50, logMET_bins ) );
23 double* logHT_bins = MakeLogBinning(100, 0, 3000);
24 Book( TH1F( "HT", "H_{T} [GeV]", 3000, 0, 3000) );//100, logHT_bins ) );
25 double* logHTlep_bins = MakeLogBinning(50, 0, 1500);
26 Book( TH1F( "HTlep", "H_{T}^{lep} [GeV]", 1500, 0, 1500) );//50, logHTlep_bins ) );
27
28 // jets
29 Book( TH1F( "N_jets", "N^{jets}", 20, 0, 20 ) );
30 /* double* logPtjet1_bins = MakeLogBinning(50, 0, 1500);
31 double* logPtjet2_bins = MakeLogBinning(50, 0, 1500);
32 double* logPtjet3_bins = MakeLogBinning(50, 0, 1500);
33 double* logPtjet4_bins = MakeLogBinning(50, 0, 1500);
34 double* logMjet1_bins = MakeLogBinning(50, 0, 1500);
35 double* logMjet2_bins = MakeLogBinning(50, 0, 1500);
36 double* logMjet3_bins = MakeLogBinning(50, 0, 1500);
37 double* logMjet4_bins = MakeLogBinning(50, 0, 1500);*/
38 Book( TH1F( "pt_jet1", "p_{T}^{jet 1} [GeV/c]", 1500, 0, 1500) );// logPtjet1_bins ) );
39 Book( TH1F( "pt_jet2", "p_{T}^{jet 2} [GeV/c]", 1500, 0, 1500) );//, logPtjet2_bins ) );
40 Book( TH1F( "pt_jet3", "p_{T}^{jet 3} [GeV/c]", 1500, 0, 1500) );//50, logPtjet3_bins ) );
41 Book( TH1F( "pt_jet4", "p_{T}^{jet 4} [GeV/c]", 1500, 0, 1500) );//50, logPtjet4_bins ) );
42 Book( TH1F( "m_jet1", "M^{jet 1} [GeV/c]", 1500, 0, 1500) );//50, logMjet1_bins ) );
43 Book( TH1F( "m_jet2", "M^{jet 2} [GeV/c]", 1500, 0, 1500) );//50, logMjet2_bins ) );
44 Book( TH1F( "m_jet3", "M^{jet 3} [GeV/c]", 1500, 0, 1500) );//50, logMjet3_bins ) );
45 Book( TH1F( "m_jet4", "M^{jet 4} [GeV/c]", 1500, 0, 1500) );//50, logMjet4_bins ) );
46 Book( TH1F( "eta_jet1", "#eta^{jet 1}", 50, -2.5, 2.5) );
47 Book( TH1F( "eta_jet2", "#eta^{jet 2}", 50, -2.5, 2.5) );
48 Book( TH1F( "eta_jet3", "#eta^{jet 3}", 50, -2.5, 2.5) );
49 Book( TH1F( "eta_jet4", "#eta^{jet 4}", 50, -2.5, 2.5) );
50
51 // leptons
52 Book( TH1F( "N_ele", "N^{e}", 10, 0, 10 ) );
53 double* logPtlep_bins = MakeLogBinning(50, 45, 500);
54 Book( TH1F( "pt_ele", "p_{T}^{e} [GeV/c]", 50, logPtlep_bins ) );
55 Book( TH1F( "eta_ele", "#eta^{e}", 50, -2.1, 2.1) );
56
57 // primary vertices
58 Book( TH1F( "N_pv", "N^{PV}", 50, 0, 50 ) );
59
60 Book( TH1F( "M_ttbar_rec", "M_{t#bar{t}}^{rec} [GeV/c^{2}]", 150, 0, 3000 ) );
61
62 Book( TH1F( "M_toplep_rec", "M^{top,lep} [GeV/c^{2}]", 70, 0, 700 ) );
63 Book( TH1F( "M_tophad_rec", "M^{top,had} [GeV/c^{2}]", 50, 0, 500 ) );
64
65 Book( TH1F( "Pt_toplep_rec", "P_{T}^{top,lep} [GeV/c]", 60, 0, 1200 ) );
66 Book( TH1F( "Pt_tophad_rec", "P_{T}^{top,had} [GeV/c]", 60, 0, 1200 ) );
67
68 TString name = m_discr->GetLabel();
69 name += " discriminator";
70 double min=0;
71 double max=500;
72 if( m_discr->GetLabel()=="BestPossible"){
73 min=0;
74 max=6;
75 }
76 Book( TH1F("Discriminator", name , 100, min,max) );
77
78 // Book( TH2F("M_ttbar_rec_vs_M_ttbar_gen","M_{t#bar{t}}^{rec} [GeV/c^{2}] vs M_{t#bar{t}}^{gen} [GeV/c^{2}]",100,0,3000,100,0,3000));
79 // Book( TH1F("M_ttbar_resolution", "(M_{t#bar{t}}^{gen} - M_{t#bar{t}}^{rec})/M_{t#bar{t}}^{rec}", 100, -5,5) );
80 }
81
82 void AnalysisHists::Fill()
83 {
84 // fill the histograms
85
86 EventCalc* calc = EventCalc::Instance();
87 bool IsRealData = calc->IsRealData();
88 LuminosityHandler* lumih = calc->GetLumiHandler();
89 // important: get the event weight
90 double weight = calc->GetWeight();
91
92 int run = calc->GetRunNum();
93 int lumiblock = calc->GetLumiBlock();
94 int Npvs = calc->GetPrimaryVertices()->size();
95
96 Hist("N_pv")->Fill(Npvs, weight);
97 // if(IsRealData){
98 // Hist( "N_pv_perLumiBin")->Fill( lumih->GetLumiBin(run, lumiblock), Npvs*weight);
99 // Hist( "N_events_perLumiBin")->Fill( lumih->GetLumiBin(run, lumiblock), weight);
100 // }
101
102 //double npu = bcc.genInfo->pileup_TrueNumInteractions();
103 //if(npu>50) npu=49.9999;
104 //Hist( "N_pileup_hist" )->Fill( npu, weight );
105
106 MET* met = calc->GetMET();
107 Hist("MET")->Fill(met->pt(), weight);
108
109 double HT = calc->GetHT();
110 Hist("HT")->Fill(HT, weight);
111
112 double HTlep = calc->GetHTlep();
113 Hist("HTlep")->Fill(HTlep, weight);
114
115 std::vector<Jet>* jets = calc->GetJets();
116 int Njets = jets->size();
117 Hist("N_jets")->Fill(Njets, weight);
118
119 if(Njets>=1){
120 Hist("pt_jet1")->Fill(jets->at(0).pt(), weight);
121 Hist("eta_jet1")->Fill(jets->at(0).eta(), weight);
122 if(jets->at(0).v4().isTimelike())
123 Hist("m_jet1")->Fill(jets->at(0).v4().M(), weight);
124 }
125 if(Njets>=2){
126 Hist("pt_jet2")->Fill(jets->at(1).pt(), weight);
127 Hist("eta_jet2")->Fill(jets->at(1).eta(), weight);
128 if(jets->at(1).v4().isTimelike())
129 Hist("m_jet2")->Fill(jets->at(1).v4().M(), weight);
130 }
131 if(Njets>=3){
132 Hist("pt_jet3")->Fill(jets->at(2).pt(), weight);
133 Hist("eta_jet3")->Fill(jets->at(2).eta(), weight);
134 if(jets->at(2).v4().isTimelike())
135 Hist("m_jet3")->Fill(jets->at(2).v4().M(), weight);
136 }
137 if(Njets>=4){
138 Hist("pt_jet4")->Fill(jets->at(3).pt(), weight);
139 Hist("eta_jet4")->Fill(jets->at(3).eta(), weight);
140 if(jets->at(3).v4().isTimelike())
141 Hist("m_jet4")->Fill(jets->at(3).v4().M(), weight);
142 }
143
144
145 std::vector<Electron>* electrons = calc->GetElectrons();
146 int Nelectrons = electrons->size();
147 Hist("N_ele")->Fill(Nelectrons, weight);
148 for (int i=0; i<Nelectrons; ++i){
149 Electron thisele = electrons->at(i);
150 Hist("pt_ele")->Fill(thisele.pt(), weight);
151 Hist("eta_ele")->Fill(thisele.eta(), weight);
152 }
153
154
155
156 ReconstructionHypothesis* hyp = m_discr->GetBestHypothesis();
157
158 double mttbar_rec = 0;
159 if( (hyp->top_v4()+hyp->antitop_v4()).isTimelike() )
160 mttbar_rec = (hyp->top_v4()+hyp->antitop_v4()).M();
161 else
162 mttbar_rec = -sqrt( (hyp->top_v4()+hyp->antitop_v4()).mass2());
163 double mttbar_gen = 0;
164 if(calc->GetGenParticles() )
165 mttbar_gen = ( calc->GetTTbarGen()->Top().v4() + calc->GetTTbarGen()->Antitop().v4()).M();
166
167 Hist("M_ttbar_rec")->Fill(mttbar_rec, weight);
168 // Hist("M_ttbar_rec_vs_M_ttbar_gen")->Fill(mttbar_rec, mttbar_gen);
169 // Hist("M_ttbar_resolution")->Fill( (mttbar_gen-mttbar_rec)/mttbar_gen, weight);
170 Hist("Discriminator")->Fill(hyp->discriminator(m_discr->GetLabel()), weight);
171
172 double mtoplep=0;
173 double mtophad=0;
174 if(hyp->toplep_v4().isTimelike()) mtoplep = hyp->toplep_v4().M();
175 if(hyp->tophad_v4().isTimelike()) mtophad = hyp->tophad_v4().M();
176 Hist("M_toplep_rec")->Fill(mtoplep,weight);
177 Hist("M_tophad_rec")->Fill(mtophad,weight);
178
179 Hist("Pt_toplep_rec")->Fill( hyp->toplep_v4().Pt(),weight );
180 Hist("Pt_tophad_rec")->Fill( hyp->tophad_v4().Pt(),weight );
181
182 }
183
184 void AnalysisHists::Finish()
185 {
186 // final calculations, like division and addition of certain histograms
187
188
189 }
190