CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CMSDAS11DijetTestAnalyzer.cc
Go to the documentation of this file.
1 // CMSDAS11DijetTestAnalyzer.cc
2 // Description: A basic dijet analyzer for the CMSDAS 2011
3 // Author: John Paul Chou
4 // Date: January 12, 2011
5 
7 
12 
15 
18 
19 #include <TH1D.h>
20 #include <TH2D.h>
21 
23  : edm::EDAnalyzer(),
24  jetSrc(params.getParameter<edm::InputTag>("jetSrc")),
25  vertexSrc(params.getParameter<edm::InputTag>("vertexSrc")),
26  jetCorrections(params.getParameter<std::string>("jetCorrections")),
27  innerDeltaEta(params.getParameter<double>("innerDeltaEta")),
28  outerDeltaEta(params.getParameter<double>("outerDeltaEta")),
29  JESbias(params.getParameter<double>("JESbias")) {
30  // setup file service
32 
33  const int NBINS = 36;
34  Double_t BOUNDARIES[NBINS] = {220, 244, 270, 296, 325, 354, 386, 419, 453, 489, 526, 565,
35  606, 649, 693, 740, 788, 838, 890, 944, 1000, 1058, 1118, 1181,
36  1246, 1313, 1383, 1455, 1530, 1607, 1687, 1770, 1856, 1945, 2037, 2132};
37 
38  // setup histograms
39  hVertexZ = fs->make<TH1D>("hVertexZ", "Z position of the Vertex", 50, -20, 20);
40  hJetRawPt = fs->make<TH1D>("hJetRawPt", "Raw Jet Pt", 50, 0, 1000);
41  hJetCorrPt = fs->make<TH1D>("hJetCorrPt", "Corrected Jet Pt", 50, 0, 1000);
42  hJet1Pt = fs->make<TH1D>("hJet1Pt", "Corrected Jet1 Pt", 50, 0, 1000);
43  hJet2Pt = fs->make<TH1D>("hJet2Pt", "Corrected Jet2 Pt", 50, 0, 1000);
44 
45  hJetEta = fs->make<TH1D>("hJetEta", "Corrected Jet Eta", 50, -5, 5);
46  hJet1Eta = fs->make<TH1D>("hJet1Eta", "Corrected Jet1 Eta", 50, -5, 5);
47  hJet2Eta = fs->make<TH1D>("hJet2Eta", "Corrected Jet2 Eta", 50, -5, 5);
48 
49  hJetPhi = fs->make<TH1D>("hJetPhi", "Corrected Jet Phi", 50, -3.1415, 3.1415);
50  hJet1Phi = fs->make<TH1D>("hJet1Phi", "Corrected Jet1 Phi", 50, -3.1415, 3.1415);
51  hJet2Phi = fs->make<TH1D>("hJet2Phi", "Corrected Jet2 Phi", 50, -3.1415, 3.1415);
52 
53  hJetEMF = fs->make<TH1D>("hJetEMF", "EM Fraction of Jets", 50, 0, 1);
54  hJet1EMF = fs->make<TH1D>("hJet1EMF", "EM Fraction of Jet1", 50, 0, 1);
55  hJet2EMF = fs->make<TH1D>("hJet2EMF", "EM Fraction of Jet2", 50, 0, 1);
56 
57  hCorDijetMass = fs->make<TH1D>("hCorDijetMass", "Corrected Dijet Mass", NBINS - 1, BOUNDARIES);
58  hDijetDeltaPhi = fs->make<TH1D>("hDijetDeltaPhi", "Dijet |#Delta #phi|", 50, 0, 3.1415);
59  hDijetDeltaEta = fs->make<TH1D>("hDijetDeltaEta", "Dijet |#Delta #eta|", 50, 0, 1.3);
61  fs->make<TH2D>("hDijetDeltaPhiNJets", "Dijet |#Delta #phi| v. the number of jets", 50, 0, 3.1415, 7, 0.5, 7.5);
62  hDijetEta1Eta2 = fs->make<TH2D>("hDijetEta1Eta2", "Eta 1 versus Eta 2 of dijet events", 50, -5, 5, 50, -5, 5);
63 
64  hInnerDijetMass = fs->make<TH1D>("hInnerDijetMass", "Corrected Inner Dijet Mass", NBINS - 1, BOUNDARIES);
65  hOuterDijetMass = fs->make<TH1D>("hOuterDijetMass", "Corrected Outer Dijet Mass", NBINS - 1, BOUNDARIES);
66 }
67 
69 
72  double mWeight;
74  iEvent.getByLabel("generator", hEventInfo);
75  if (hEventInfo.isValid()) {
76  mWeight = hEventInfo->weight();
77  } else
78  mWeight = 1.;
79 
81  // Get event ID information
83  //int nrun=iEvent.id().run();
84  //int nlumi=iEvent.luminosityBlock();
85  //int nevent=iEvent.id().event();
86 
88  // Get Primary Vertex Information
90 
91  // magic to get the vertices from EDM
93  iEvent.getByLabel(vertexSrc, vertices_h);
94  if (!vertices_h.isValid()) {
95  std::cout << "Didja hear the one about the empty vertex collection?\n";
96  return;
97  }
98 
99  // require in the event that there is at least one reconstructed vertex
100  if (vertices_h->empty())
101  return;
102 
103  // pick the first (i.e. highest sum pt) verte
104  const reco::Vertex* theVertex = &(vertices_h->front());
105 
106  // require that the vertex meets certain criteria
107  if (theVertex->ndof() < 5)
108  return;
109  if (fabs(theVertex->z()) > 24.0)
110  return;
111  if (fabs(theVertex->position().rho()) > 2.0)
112  return;
113 
115  // Get Jet Information
117 
118  // magic to get the jets from EDM
120  iEvent.getByLabel(jetSrc, jets_h);
121  if (!jets_h.isValid()) {
122  std::cout << "Didja hear the one about the empty jet collection?\n";
123  return;
124  }
125 
126  // magic to get the jet energy corrections
128  corrector->vectorialCorrection();
129  // collection of selected jets
130  std::vector<reco::CaloJet> selectedJets;
131 
132  // loop over the jet collection
133  for (reco::CaloJetCollection::const_iterator j_it = jets_h->begin(); j_it != jets_h->end(); j_it++) {
134  reco::CaloJet jet = *j_it;
135 
136  // put the selected jets into a collection
137  selectedJets.push_back(jet);
138  }
139 
140  hVertexZ->Fill(theVertex->z(), mWeight);
141  return;
142 }
143 
CMSDAS11DijetTestAnalyzer(const edm::ParameterSet &)
Jets made from CaloTowers.
Definition: CaloJet.h:27
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
const Point & position() const
position
Definition: Vertex.h:127
int iEvent
Definition: GenABIO.cc:224
double z() const
z coordinate
Definition: Vertex.h:133
void analyze(const edm::Event &, const edm::EventSetup &) override
bool isValid() const
Definition: HandleBase.h:70
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:500
double ndof() const
Definition: Vertex.h:123
virtual bool vectorialCorrection() const
if vectorial correction is provided
Definition: JetCorrector.h:62
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
tuple cout
Definition: gather_cfg.py:144
const int NBINS