CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DijetMass.cc
Go to the documentation of this file.
1 // DijetMass.cc
2 // Description: Some Basic validation plots for jets.
3 // Author: Robert M. Harris
4 // Date: 30 - August - 2006
5 // Kalanand Mishra (November 22, 2009):
6 // Modified and cleaned up to work in 3.3.X
7 //
9 
19 #include <TROOT.h>
20 #include <TSystem.h>
21 #include <TFile.h>
22 #include <TCanvas.h>
23 #include <cmath>
24 using namespace edm;
25 using namespace reco;
26 using namespace std;
27 
28 
29 template<class Jet>
31  PtHistMax = cfg.getUntrackedParameter<double>( "PtHistMax", 3000.0);
32  EtaMax = cfg.getUntrackedParameter<double> ("EtaMax", 1.3);
33  histogramFile = cfg.getUntrackedParameter<std::string>("HistoFileName",
34  "DijetMassHistos.root");
35 
36  AKJets = cfg.getParameter<std::string> ("AKJets");
37  AKCorJets = cfg.getParameter<std::string> ("AKCorrectedJets");
38  ICJets = cfg.getParameter<std::string> ("ICJets");
39  ICCorJets = cfg.getParameter<std::string> ("ICCorrectedJets");
40  SCJets = cfg.getParameter<std::string> ("SCJets");
41  SCCorJets = cfg.getParameter<std::string> ("SCCorrectedJets");
42  KTJets = cfg.getParameter<std::string> ("KTJets");
43  KTCorJets = cfg.getParameter<std::string> ("KTCorrectedJets");
44 }
45 
46 template<class Jet>
48  cout << "DijetMass: Maximum bin edge for Pt Hists = " << PtHistMax << endl;
49  numJets=2;
50 
51  //Initialize some stuff
52  evtCount = 0;
53 
54  // Open the histogram file and book some associated histograms
55  m_file=new TFile( histogramFile.c_str(),"RECREATE" );
56 
57  //Simple histos
58 
59  //AK unc
60  ptAKunc = TH1F("ptAKunc","p_{T} of leading Jets (AK)",50,0.0,PtHistMax);
61  etaAKunc = TH1F("etaAKunc","#eta of leading Jets (AK)",23,-1.0,1.0);
62  phiAKunc = TH1F("phiAKunc","#phi of leading Jets (AK)",72,-M_PI, M_PI);
63  m2jAKunc = TH1F("m2jAKunc","Dijet Mass of leading Jets (AK)",100,0.0,2*PtHistMax);
64 
65 
66  //AK cor
67  ptAKcor = TH1F("ptAKcor","p_{T} of leading Corrected Jets (AK)",50,0.0,PtHistMax);
68  etaAKcor = TH1F("etaAKcor","#eta of leading Corrected Jets (AK)",23,-1.0,1.0);
69  phiAKcor = TH1F("phiAKcor","#phi of leading Corrected Jets (AK)",72,-M_PI, M_PI);
70  m2jAKcor = TH1F("m2jAKcor","Dijet Mass of leading Corrected Jets (AK)",100,0.0,2*PtHistMax);
71 
72  //IC unc
73  ptICunc = TH1F("ptICunc","p_{T} of leading Jets (IC)",50,0.0,PtHistMax);
74  etaICunc = TH1F("etaICunc","#eta of leading Jets (IC)",23,-1.0,1.0);
75  phiICunc = TH1F("phiICunc","#phi of leading Jets (IC)",72,-M_PI, M_PI);
76  m2jICunc = TH1F("m2jICunc","Dijet Mass of leading Jets (IC)",100,0.0,2*PtHistMax);
77 
78 
79  //IC cor
80  ptICcor = TH1F("ptICcor","p_{T} of leading Corrected Jets (IC)",50,0.0,PtHistMax);
81  etaICcor = TH1F("etaICcor","#eta of leading Corrected Jets (IC)",23,-1.0,1.0);
82  phiICcor = TH1F("phiICcor","#phi of leading Corrected Jets (IC)",72,-M_PI, M_PI);
83  m2jICcor = TH1F("m2jICcor","Dijet Mass of leading Corrected Jets (IC)",100,0.0,2*PtHistMax);
84 
85  //KT unc
86  ptKTunc = TH1F("ptKTunc","p_{T} of leading Jets (KT)",50,0.0,PtHistMax);
87  etaKTunc = TH1F("etaKTunc","#eta of leading Jets (KT)",23,-1.0,1.0);
88  phiKTunc = TH1F("phiKTunc","#phi of leading Jets (KT)",72,-M_PI, M_PI);
89  m2jKTunc = TH1F("m2jKTunc","Dijet Mass of leading Jets (KT)",100,0.0,2*PtHistMax);
90 
91 
92  //KT cor
93  ptKTcor = TH1F("ptKTcor","p_{T} of leading Corrected Jets (KT)",50,0.0,PtHistMax);
94  etaKTcor = TH1F("etaKTcor","#eta of leading Corrected Jets (KT)",23,-1.0,1.0);
95  phiKTcor = TH1F("phiKTcor","#phi of leading Corrected Jets (KT)",72,-M_PI, M_PI);
96  m2jKTcor = TH1F("m2jKTcor","Dijet Mass of leading Corrected Jets (KT)",100,0.0,2*PtHistMax);
97 
98  //SC unc
99  ptSCunc = TH1F("ptSCunc","p_{T} of leading Jets (SC)",50,0.0,PtHistMax);
100  etaSCunc = TH1F("etaSCunc","#eta of leading Jets (SC)",23,-1.0,1.0);
101  phiSCunc = TH1F("phiSCunc","#phi of leading Jets (SC)",72,-M_PI, M_PI);
102  m2jSCunc = TH1F("m2jSCunc","Dijet Mass of leading Jets (SC)",100,0.0,2*PtHistMax);
103 
104  //SC cor
105  ptSCcor = TH1F("ptSCcor","p_{T} of leading Corrected Jets (SC)",50,0.0,PtHistMax);
106  etaSCcor = TH1F("etaSCcor","#eta of leading Corrected Jets (SC)",23,-1.0,1.0);
107  phiSCcor = TH1F("phiSCcor","#phi of leading Corrected Jets (SC)",72,-M_PI, M_PI);
108  m2jSCcor = TH1F("m2jSCcor","Dijet Mass of leading Corrected Jets (SC)",100,0.0,2*PtHistMax);
109 
110 }
111 
112 
113 
114 template<class Jet>
115 void DijetMass<Jet>::analyze( const Event& evt, const EventSetup& es ) {
116 
117  evtCount++;
118  math::XYZTLorentzVector p4jet[2];
119  int jetInd;
121 
122 
123  //Fill Simple Histos
124  typename JetCollection::const_iterator i_jet;
125 
126  //AK unc
127  evt.getByLabel( AKJets, Jets );
128  jetInd = 0;
129  for( i_jet = Jets->begin(); i_jet != Jets->end() && jetInd<2; ++ i_jet ) {
130  p4jet[jetInd] = i_jet->p4();
131  jetInd++;
132  }
133  if(jetInd==2&&abs(p4jet[0].eta())<EtaMax &&abs(p4jet[1].eta())<EtaMax ){
134  m2jAKunc.Fill( (p4jet[0]+p4jet[1]).mass() );
135  ptAKunc.Fill( p4jet[0].Pt() ); ptAKunc.Fill( p4jet[1].Pt() );
136  etaAKunc.Fill( p4jet[0].eta() ); etaAKunc.Fill( p4jet[1].eta() );
137  phiAKunc.Fill( p4jet[0].phi() ); phiAKunc.Fill( p4jet[1].phi() );
138  }
139 
140 
141  //AK corrected
142  evt.getByLabel( AKCorJets, Jets );
143  jetInd = 0;
144  for( i_jet = Jets->begin(); i_jet != Jets->end() && jetInd<2; ++ i_jet ) {
145  p4jet[jetInd] = i_jet->p4();
146  jetInd++;
147  }
148  if(jetInd==2&&abs(p4jet[0].eta())<EtaMax &&abs(p4jet[1].eta())<EtaMax ){
149  m2jAKcor.Fill( (p4jet[0]+p4jet[1]).mass() );
150  ptAKcor.Fill( p4jet[0].Pt() ); ptAKcor.Fill( p4jet[1].Pt() );
151  etaAKcor.Fill( p4jet[0].eta() ); etaAKcor.Fill( p4jet[1].eta() );
152  phiAKcor.Fill( p4jet[0].phi() ); phiAKcor.Fill( p4jet[1].phi() );
153  }
154 
155 
156  //IC unc
157  evt.getByLabel( ICJets, Jets );
158  jetInd = 0;
159  for( i_jet = Jets->begin(); i_jet != Jets->end() && jetInd<2; ++ i_jet ) {
160  p4jet[jetInd] = i_jet->p4();
161  jetInd++;
162  }
163  if(jetInd==2&&abs(p4jet[0].eta())<EtaMax &&abs(p4jet[1].eta())<EtaMax ){
164  m2jICunc.Fill( (p4jet[0]+p4jet[1]).mass() );
165  ptICunc.Fill( p4jet[0].Pt() ); ptICunc.Fill( p4jet[1].Pt() );
166  etaICunc.Fill( p4jet[0].eta() ); etaICunc.Fill( p4jet[1].eta() );
167  phiICunc.Fill( p4jet[0].phi() ); phiICunc.Fill( p4jet[1].phi() );
168  }
169 
170 
171  //IC corrected
172  evt.getByLabel( ICCorJets, Jets );
173  jetInd = 0;
174  for( i_jet = Jets->begin(); i_jet != Jets->end() && jetInd<2; ++ i_jet ) {
175  p4jet[jetInd] = i_jet->p4();
176  jetInd++;
177  }
178  if(jetInd==2&&abs(p4jet[0].eta())<EtaMax &&abs(p4jet[1].eta())<EtaMax ){
179  m2jICcor.Fill( (p4jet[0]+p4jet[1]).mass() );
180  ptICcor.Fill( p4jet[0].Pt() ); ptICcor.Fill( p4jet[1].Pt() );
181  etaICcor.Fill( p4jet[0].eta() ); etaICcor.Fill( p4jet[1].eta() );
182  phiICcor.Fill( p4jet[0].phi() ); phiICcor.Fill( p4jet[1].phi() );
183  }
184 
185  //KT unc
186  evt.getByLabel( KTJets, Jets );
187  jetInd = 0;
188  for( i_jet = Jets->begin(); i_jet != Jets->end() && jetInd<2; ++ i_jet ) {
189  p4jet[jetInd] = i_jet->p4();
190  jetInd++;
191  }
192  if(jetInd==2&&abs(p4jet[0].eta())<EtaMax &&abs(p4jet[1].eta())<EtaMax ){
193  m2jKTunc.Fill( (p4jet[0]+p4jet[1]).mass() );
194  ptKTunc.Fill( p4jet[0].Pt() ); ptKTunc.Fill( p4jet[1].Pt() );
195  etaKTunc.Fill( p4jet[0].eta() ); etaKTunc.Fill( p4jet[1].eta() );
196  phiKTunc.Fill( p4jet[0].phi() ); phiKTunc.Fill( p4jet[1].phi() );
197  }
198 
199 
200  //KT corrected
201  evt.getByLabel( KTCorJets, Jets );
202  jetInd = 0;
203  for( i_jet = Jets->begin(); i_jet != Jets->end() && jetInd<2; ++i_jet ) {
204  p4jet[jetInd] = i_jet->p4();
205  jetInd++;
206  }
207  if(jetInd==2&&abs(p4jet[0].eta())<EtaMax &&abs(p4jet[1].eta())<EtaMax ){
208  m2jKTcor.Fill( (p4jet[0]+p4jet[1]).mass() );
209  ptKTcor.Fill( p4jet[0].Pt() ); ptKTcor.Fill( p4jet[1].Pt() );
210  etaKTcor.Fill( p4jet[0].eta() ); etaKTcor.Fill( p4jet[1].eta() );
211  phiKTcor.Fill( p4jet[0].phi() ); phiKTcor.Fill( p4jet[1].phi() );
212  }
213 
214 
215  //SC unc
216  evt.getByLabel( SCJets, Jets );
217  jetInd = 0;
218  for( i_jet = Jets->begin(); i_jet != Jets->end() && jetInd<2; ++i_jet ) {
219  p4jet[jetInd] = i_jet->p4();
220  jetInd++;
221  }
222  if(jetInd==2&&abs(p4jet[0].eta())<EtaMax &&abs(p4jet[1].eta())<EtaMax ){
223  m2jSCunc.Fill( (p4jet[0]+p4jet[1]).mass() );
224  ptSCunc.Fill( p4jet[0].Pt() ); ptSCunc.Fill( p4jet[1].Pt() );
225  etaSCunc.Fill( p4jet[0].eta() ); etaSCunc.Fill( p4jet[1].eta() );
226  phiSCunc.Fill( p4jet[0].phi() ); phiSCunc.Fill( p4jet[1].phi() );
227  }
228 
229 
230  //SC corrected
231  evt.getByLabel( SCCorJets, Jets );
232  jetInd = 0;
233  for( i_jet = Jets->begin(); i_jet != Jets->end() && jetInd<2; ++i_jet ) {
234  p4jet[jetInd] = i_jet->p4();
235  jetInd++;
236  }
237  if(jetInd==2&&abs(p4jet[0].eta())<EtaMax &&abs(p4jet[1].eta())<EtaMax ){
238  m2jSCcor.Fill( (p4jet[0]+p4jet[1]).mass() );
239  ptSCcor.Fill( p4jet[0].Pt() ); ptSCcor.Fill( p4jet[1].Pt() );
240  etaSCcor.Fill( p4jet[0].eta() ); etaSCcor.Fill( p4jet[1].eta() );
241  phiSCcor.Fill( p4jet[0].phi() ); phiSCcor.Fill( p4jet[1].phi() );
242  }
243 
244 }
245 
246 template<class Jet>
248 
249  //Write out the histogram file.
250  m_file->cd();
251 
252  ptAKunc.Write();
253  etaAKunc.Write();
254  phiAKunc.Write();
255  m2jAKunc.Write();
256 
257  ptAKcor.Write();
258  etaAKcor.Write();
259  phiAKcor.Write();
260  m2jAKcor.Write();
261 
262  ptICunc.Write();
263  etaICunc.Write();
264  phiICunc.Write();
265  m2jICunc.Write();
266 
267 
268  ptICcor.Write();
269  etaICcor.Write();
270  phiICcor.Write();
271  m2jICcor.Write();
272 
273  ptKTunc.Write();
274  etaKTunc.Write();
275  phiKTunc.Write();
276  m2jKTunc.Write();
277 
278 
279  ptKTcor.Write();
280  etaKTcor.Write();
281  phiKTcor.Write();
282  m2jKTcor.Write();
283 
284  ptSCunc.Write();
285  etaSCunc.Write();
286  phiSCunc.Write();
287  m2jSCunc.Write();
288 
289  ptSCcor.Write();
290  etaSCcor.Write();
291  phiSCcor.Write();
292  m2jSCcor.Write();
293 
294  m_file->Close();
295 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
#define abs(x)
Definition: mlp_lapack.h:159
DijetMass< GenJet > DijetMassGenJets
Definition: DijetMass.cc:301
const double EtaMax[kNumberCalorimeter]
DEFINE_FWK_MODULE(HiMixingModule)
T eta() const
void analyze(const edm::Event &, const edm::EventSetup &)
Definition: DijetMass.cc:115
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:30
DijetMass< PFJet > DijetMassPFJets
Definition: DijetMass.cc:304
tuple Jets
Definition: METSkim_cff.py:17
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
DijetMass(const edm::ParameterSet &)
Definition: DijetMass.cc:30
#define M_PI
Definition: BFit3D.cc:3
void endJob()
Definition: DijetMass.cc:247
tuple cout
Definition: gather_cfg.py:121
DijetMass< CaloJet > DijetMassCaloJets
Definition: DijetMass.cc:298
Definition: DDAxes.h:10
void beginJob()
Definition: DijetMass.cc:47