CMS 3D CMS Logo

CMSDAS11DijetAnalyzer.cc
Go to the documentation of this file.
1 // CMSDAS11DijetAnalyzer.cc
2 // Description: A basic dijet analyzer for the CMSDAS 2011
3 // Author: John Paul Chou
4 // Date: January 12, 2011
5 
7 
12 
17 
18 #include <TH1D.h>
19 
21  : edm::EDAnalyzer(),
22  jetSrc(params.getParameter<edm::InputTag>("jetSrc")),
23  vertexSrc(params.getParameter<edm::InputTag>("vertexSrc")),
24  jetCorrections(params.getParameter<std::string>("jetCorrections")),
25  innerDeltaEta(params.getParameter<double>("innerDeltaEta")),
26  outerDeltaEta(params.getParameter<double>("outerDeltaEta")),
27  JESbias(params.getParameter<double>("JESbias")) {
28  // setup file service
30 
31  const int NBINS = 36;
32  Double_t BOUNDARIES[NBINS] = {220, 244, 270, 296, 325, 354, 386, 419, 453, 489, 526, 565,
33  606, 649, 693, 740, 788, 838, 890, 944, 1000, 1058, 1118, 1181,
34  1246, 1313, 1383, 1455, 1530, 1607, 1687, 1770, 1856, 1945, 2037, 2132};
35 
36  // setup histograms
37  hVertexZ = fs->make<TH1D>("hVertexZ", "Z position of the Vertex", 50, -20, 20);
38  hJetRawPt = fs->make<TH1D>("hJetRawPt", "Raw Jet Pt", 50, 0, 1000);
39  hJetCorrPt = fs->make<TH1D>("hJetCorrPt", "Corrected Jet Pt", 50, 0, 1000);
40  hJet1Pt = fs->make<TH1D>("hJet1Pt", "Corrected Jet1 Pt", 50, 0, 1000);
41  hJet2Pt = fs->make<TH1D>("hJet2Pt", "Corrected Jet2 Pt", 50, 0, 1000);
42 
43  hJetEta = fs->make<TH1D>("hJetEta", "Corrected Jet Eta", 10, -5, 5);
44  hJet1Eta = fs->make<TH1D>("hJet1Eta", "Corrected Jet1 Eta", 10, -5, 5);
45  hJet2Eta = fs->make<TH1D>("hJet2Eta", "Corrected Jet2 Eta", 10, -5, 5);
46 
47  hJetPhi = fs->make<TH1D>("hJetPhi", "Corrected Jet Phi", 10, -3.1415, 3.1415);
48  hJet1Phi = fs->make<TH1D>("hJet1Phi", "Corrected Jet1 Phi", 10, -3.1415, 3.1415);
49  hJet2Phi = fs->make<TH1D>("hJet2Phi", "Corrected Jet2 Phi", 10, -3.1415, 3.1415);
50 
51  hJetEMF = fs->make<TH1D>("hJetEMF", "EM Fraction of Jets", 50, 0, 1);
52  hJet1EMF = fs->make<TH1D>("hJet1EMF", "EM Fraction of Jet1", 50, 0, 1);
53  hJet2EMF = fs->make<TH1D>("hJet2EMF", "EM Fraction of Jet2", 50, 0, 1);
54 
55  hCorDijetMass = fs->make<TH1D>("hCorDijetMass", "Corrected Dijet Mass", NBINS - 1, BOUNDARIES);
56  hDijetDeltaPhi = fs->make<TH1D>("hDijetDeltaPhi", "Dijet |#Delta #phi|", 50, 0, 3.1415);
57  hDijetDeltaEta = fs->make<TH1D>("hDijetDeltaEta", "Dijet |#Delta #eta|", 50, 0, 6);
58 
59  hInnerDijetMass = fs->make<TH1D>("hInnerDijetMass", "Corrected Inner Dijet Mass", NBINS - 1, BOUNDARIES);
60  hOuterDijetMass = fs->make<TH1D>("hOuterDijetMass", "Corrected Outer Dijet Mass", NBINS - 1, BOUNDARIES);
61 }
62 
64 
67  double mWeight;
69  iEvent.getByLabel("generator", hEventInfo);
70  if (hEventInfo.isValid())
71  mWeight = hEventInfo->weight();
72  else
73  mWeight = 1.;
74 
76  // Get event ID information
78  //int nrun=iEvent.id().run();
79  //int nlumi=iEvent.luminosityBlock();
80  //int nevent=iEvent.id().event();
81 
83  // Get Primary Vertex Information
85 
86  // magic to get the vertices from EDM
88  iEvent.getByLabel(vertexSrc, vertices_h);
89  if (!vertices_h.isValid()) {
90  std::cout << "Didja hear the one about the empty vertex collection?\n";
91  return;
92  }
93 
94  // require in the event that there is at least one reconstructed vertex
95  if (vertices_h->empty())
96  return;
97 
98  // pick the first (i.e. highest sum pt) verte
99  const reco::Vertex* theVertex = &(vertices_h->front());
100 
101  // require that the vertex meets certain criteria
102  if (theVertex->ndof() < 5)
103  return;
104  if (fabs(theVertex->z()) > 24.0)
105  return;
106  if (fabs(theVertex->position().rho()) > 2.0)
107  return;
108 
110  // Get Jet Information
112 
113  // magic to get the jets from EDM
115  iEvent.getByLabel(jetSrc, jets_h);
116  if (!jets_h.isValid()) {
117  std::cout << "Didja hear the one about the empty jet collection?\n";
118  return;
119  }
120 
121  // magic to get the jet energy corrections
123 
124  // collection of selected jets
125  std::vector<reco::CaloJet> selectedJets;
126 
127  // loop over the jet collection
128  for (reco::CaloJetCollection::const_iterator j_it = jets_h->begin(); j_it != jets_h->end(); j_it++) {
129  reco::CaloJet jet = *j_it;
130 
131  // calculate and apply the correction
132  double scale = corrector->correction(jet.p4());
133 
134  // Introduce a purposeful bias to the correction, to show what happens
135  scale *= JESbias;
136 
137  // fill the histograms
138  hJetRawPt->Fill(jet.pt(), mWeight);
139  hJetEta->Fill(jet.eta(), mWeight);
140  hJetPhi->Fill(jet.phi(), mWeight);
141  hJetEMF->Fill(jet.emEnergyFraction(), mWeight);
142 
143  // correct the jet energy
144  jet.scaleEnergy(scale);
145 
146  // now fill the correct jet pt after the correction
147  hJetCorrPt->Fill(jet.pt(), mWeight);
148 
149  // put the selected jets into a collection
150  selectedJets.push_back(jet);
151  }
152 
153  // require at least two jets to continue
154  if (selectedJets.size() < 2)
155  return;
156 
157  //sort by corrected pt (not the same order as raw pt, sometimes)
158  sort(selectedJets.begin(), selectedJets.end(), compare_JetPt);
159 
160  // select high pt, central, non-noise-like jets
161  if (selectedJets[0].pt() < 50.0)
162  return;
163  if (fabs(selectedJets[0].eta()) > 2.5)
164  return;
165  if (selectedJets[0].emEnergyFraction() < 0.01)
166  return;
167  if (selectedJets[1].pt() < 50.0)
168  return;
169  if (fabs(selectedJets[1].eta()) > 2.5)
170  return;
171  if (selectedJets[1].emEnergyFraction() < 0.01)
172  return;
173 
174  // fill histograms for the jets in our dijets, only
175  hJet1Pt->Fill(selectedJets[0].pt(), mWeight);
176  hJet1Eta->Fill(selectedJets[0].eta(), mWeight);
177  hJet1Phi->Fill(selectedJets[0].phi(), mWeight);
178  hJet1EMF->Fill(selectedJets[0].emEnergyFraction(), mWeight);
179  hJet2Pt->Fill(selectedJets[1].pt(), mWeight);
180  hJet2Eta->Fill(selectedJets[1].eta(), mWeight);
181  hJet2Phi->Fill(selectedJets[1].phi(), mWeight);
182  hJet2EMF->Fill(selectedJets[1].emEnergyFraction(), mWeight);
183 
184  //Get the mass of the two leading jets. Needs their 4-vectors...
185  double corMass = (selectedJets[0].p4() + selectedJets[1].p4()).M();
186  double deltaEta = fabs(selectedJets[0].eta() - selectedJets[1].eta());
187  if (corMass < 489)
188  return;
189  if (deltaEta > 1.3)
190  return;
191  hCorDijetMass->Fill(corMass, mWeight);
192  hDijetDeltaPhi->Fill(fabs(selectedJets[0].phi() - selectedJets[1].phi()), mWeight);
193  hDijetDeltaEta->Fill(deltaEta, mWeight);
194 
195  //Fill the inner and outer dijet mass spectra, to make the ratio from
196  if (deltaEta < innerDeltaEta)
197  hInnerDijetMass->Fill(corMass, mWeight);
198  else if (deltaEta < outerDeltaEta)
199  hOuterDijetMass->Fill(corMass, mWeight);
200 
201  hVertexZ->Fill(theVertex->z(), mWeight);
202  return;
203 }
204 
CMSDAS11DijetAnalyzer::hCorDijetMass
TH1D * hCorDijetMass
Definition: CMSDAS11DijetAnalyzer.h:48
CMSDAS11DijetAnalyzer::hJetPhi
TH1D * hJetPhi
Definition: CMSDAS11DijetAnalyzer.h:44
reco::CaloJet
Jets made from CaloTowers.
Definition: CaloJet.h:27
CMSDAS11DijetAnalyzer::hDijetDeltaEta
TH1D * hDijetDeltaEta
Definition: CMSDAS11DijetAnalyzer.h:59
MessageLogger.h
NBINS
const int NBINS
Definition: CaloCachedShapeIntegrator.cc:3
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
reco::Vertex::z
double z() const
z coordinate
Definition: Vertex.h:120
JetCorrector.h
edm
HLT enums.
Definition: AlignableModifier.h:19
CMSDAS11DijetAnalyzer::hJetCorrPt
TH1D * hJetCorrPt
Definition: CMSDAS11DijetAnalyzer.h:41
gather_cfg.cout
cout
Definition: gather_cfg.py:144
CMSDAS11DijetAnalyzer::hJet2Pt
TH1D * hJet2Pt
Definition: CMSDAS11DijetAnalyzer.h:54
CMSDAS11DijetAnalyzer::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: CMSDAS11DijetAnalyzer.cc:65
reco::Vertex::position
const Point & position() const
position
Definition: Vertex.h:114
CMSDAS11DijetAnalyzer::hJet1Phi
TH1D * hJet1Phi
Definition: CMSDAS11DijetAnalyzer.h:52
CMSDAS11DijetAnalyzer::hJet1Eta
TH1D * hJet1Eta
Definition: CMSDAS11DijetAnalyzer.h:51
HLT_2018_cff.vertexSrc
vertexSrc
Definition: HLT_2018_cff.py:31413
edm::Handle
Definition: AssociativeIterator.h:50
CMSDAS11DijetAnalyzer::compare_JetPt
static bool compare_JetPt(const reco::CaloJet &jet1, const reco::CaloJet &jet2)
Definition: CMSDAS11DijetAnalyzer.h:28
GenRunInfoProduct.h
CMSDAS11DijetAnalyzer::hJet2EMF
TH1D * hJet2EMF
Definition: CMSDAS11DijetAnalyzer.h:57
CMSDAS11DijetAnalyzer::innerDeltaEta
double innerDeltaEta
Definition: CMSDAS11DijetAnalyzer.h:35
JetCorrector
Definition: JetCorrector.h:19
pfClustersFromHGC3DClusters_cfi.corrector
corrector
Definition: pfClustersFromHGC3DClusters_cfi.py:5
MakerMacros.h
CMSDAS11DijetAnalyzer::outerDeltaEta
double outerDeltaEta
Definition: CMSDAS11DijetAnalyzer.h:36
CMSDAS11DijetAnalyzer
Definition: CMSDAS11DijetAnalyzer.h:20
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
spr::deltaEta
static const double deltaEta
Definition: CaloConstants.h:8
Service.h
PVValHelper::eta
Definition: PVValidationHelpers.h:69
CMSDAS11DijetAnalyzer::endJob
void endJob(void) override
Definition: CMSDAS11DijetAnalyzer.cc:63
CMSDAS11DijetAnalyzer::hJet1EMF
TH1D * hJet1EMF
Definition: CMSDAS11DijetAnalyzer.h:53
CMSDAS11DijetAnalyzer::vertexSrc
edm::InputTag vertexSrc
Definition: CMSDAS11DijetAnalyzer.h:33
CMSDAS11DijetAnalyzer::hJetRawPt
TH1D * hJetRawPt
Definition: CMSDAS11DijetAnalyzer.h:42
CMSDAS11DijetAnalyzer::jetCorrections
std::string jetCorrections
Definition: CMSDAS11DijetAnalyzer.h:34
CMSDAS11DijetAnalyzer::hJetEta
TH1D * hJetEta
Definition: CMSDAS11DijetAnalyzer.h:43
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
Vertex.h
CMSDAS11DijetAnalyzer.h
TFileService.h
CMSDAS11DijetAnalyzer::hVertexZ
TH1D * hVertexZ
Definition: CMSDAS11DijetAnalyzer.h:40
Scenarios_cff.scale
scale
Definition: Scenarios_cff.py:2186
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
GenEventInfoProduct.h
CMSDAS11DijetAnalyzer::hJet2Eta
TH1D * hJet2Eta
Definition: CMSDAS11DijetAnalyzer.h:55
edm::Service< TFileService >
iEvent
int iEvent
Definition: GenABIO.cc:224
CMSDAS11DijetAnalyzer::CMSDAS11DijetAnalyzer
CMSDAS11DijetAnalyzer(const edm::ParameterSet &)
Definition: CMSDAS11DijetAnalyzer.cc:20
JetCorrector::getJetCorrector
static const JetCorrector * getJetCorrector(const std::string &fName, const edm::EventSetup &fSetup)
retrieve corrector from the event setup. troughs exception if something is missing
Definition: JetCorrector.cc:48
edm::EventSetup
Definition: EventSetup.h:57
CMSDAS11DijetAnalyzer::jetSrc
edm::InputTag jetSrc
Definition: CMSDAS11DijetAnalyzer.h:32
CMSDAS11DijetAnalyzer::JESbias
double JESbias
Definition: CMSDAS11DijetAnalyzer.h:37
DDAxes::phi
CMSDAS11DijetAnalyzer::hJet2Phi
TH1D * hJet2Phi
Definition: CMSDAS11DijetAnalyzer.h:56
std
Definition: JetResolutionObject.h:76
CMSDAS11DijetAnalyzer::hInnerDijetMass
TH1D * hInnerDijetMass
Definition: CMSDAS11DijetAnalyzer.h:61
CMSDAS11DijetAnalyzer::hDijetDeltaPhi
TH1D * hDijetDeltaPhi
Definition: CMSDAS11DijetAnalyzer.h:58
metsig::jet
Definition: SignAlgoResolutions.h:47
CMSDAS11DijetAnalyzer::hOuterDijetMass
TH1D * hOuterDijetMass
Definition: CMSDAS11DijetAnalyzer.h:62
CMSDAS11DijetAnalyzer::hJet1Pt
TH1D * hJet1Pt
Definition: CMSDAS11DijetAnalyzer.h:50
CMSDAS11DijetAnalyzer::hJetEMF
TH1D * hJetEMF
Definition: CMSDAS11DijetAnalyzer.h:45
objectSelection_cff.selectedJets
selectedJets
Definition: objectSelection_cff.py:99
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
DisplacedJet_Monitor_cff.jetSrc
jetSrc
Definition: DisplacedJet_Monitor_cff.py:79
reco::Vertex::ndof
double ndof() const
Definition: Vertex.h:110
reco::Vertex
Definition: Vertex.h:35
TFileService::make
T * make(const Args &... args) const
make new ROOT object
Definition: TFileService.h:64
GenEventInfoProduct::weight
double weight() const
Definition: GenEventInfoProduct.h:35