CMS 3D CMS Logo

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