CMS 3D CMS Logo

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 {
31  // setup file service
33 
34  const int NBINS=36;
35  Double_t BOUNDARIES[NBINS] = { 220, 244, 270, 296, 325, 354, 386, 419, 453,
36  489, 526, 565, 606, 649, 693, 740, 788, 838,
37  890, 944, 1000, 1058, 1118, 1181, 1246, 1313, 1383,
38  1455, 1530, 1607, 1687, 1770, 1856, 1945, 2037, 2132 };
39 
40  // setup histograms
41  hVertexZ = fs->make<TH1D>("hVertexZ", "Z position of the Vertex",50,-20,20);
42  hJetRawPt = fs->make<TH1D>("hJetRawPt","Raw Jet Pt",50,0,1000);
43  hJetCorrPt = fs->make<TH1D>("hJetCorrPt","Corrected Jet Pt",50,0,1000);
44  hJet1Pt = fs->make<TH1D>("hJet1Pt","Corrected Jet1 Pt",50,0,1000);
45  hJet2Pt = fs->make<TH1D>("hJet2Pt","Corrected Jet2 Pt",50,0,1000);
46 
47  hJetEta = fs->make<TH1D>("hJetEta","Corrected Jet Eta", 50,-5,5);
48  hJet1Eta = fs->make<TH1D>("hJet1Eta","Corrected Jet1 Eta",50,-5,5);
49  hJet2Eta = fs->make<TH1D>("hJet2Eta","Corrected Jet2 Eta",50,-5,5);
50 
51  hJetPhi = fs->make<TH1D>("hJetPhi","Corrected Jet Phi", 50,-3.1415,3.1415);
52  hJet1Phi = fs->make<TH1D>("hJet1Phi","Corrected Jet1 Phi",50,-3.1415,3.1415);
53  hJet2Phi = fs->make<TH1D>("hJet2Phi","Corrected Jet2 Phi",50,-3.1415,3.1415);
54 
55  hJetEMF = fs->make<TH1D>("hJetEMF","EM Fraction of Jets",50,0,1);
56  hJet1EMF = fs->make<TH1D>("hJet1EMF","EM Fraction of Jet1",50,0,1);
57  hJet2EMF = fs->make<TH1D>("hJet2EMF","EM Fraction of Jet2",50,0,1);
58 
59  hCorDijetMass = fs->make<TH1D>("hCorDijetMass","Corrected Dijet Mass",NBINS-1,BOUNDARIES);
60  hDijetDeltaPhi= fs->make<TH1D>("hDijetDeltaPhi","Dijet |#Delta #phi|",50,0,3.1415);
61  hDijetDeltaEta= fs->make<TH1D>("hDijetDeltaEta","Dijet |#Delta #eta|",50,0,1.3);
62  hDijetDeltaPhiNJets= fs->make<TH2D>("hDijetDeltaPhiNJets","Dijet |#Delta #phi| v. the number of jets",50,0,3.1415,7,0.5,7.5);
63  hDijetEta1Eta2=fs->make<TH2D>("hDijetEta1Eta2","Eta 1 versus Eta 2 of dijet events",50,-5,5,50,-5,5);
64 
65  hInnerDijetMass = fs->make<TH1D>("hInnerDijetMass","Corrected Inner Dijet Mass",NBINS-1,BOUNDARIES);
66  hOuterDijetMass = fs->make<TH1D>("hOuterDijetMass","Corrected Outer Dijet Mass",NBINS-1,BOUNDARIES);
67 }
68 
70 }
71 
73 {
75  double mWeight;
77  iEvent.getByLabel("generator", hEventInfo);
78  if (hEventInfo.isValid()) {
79  mWeight = hEventInfo->weight();
80  }
81  else
82  mWeight = 1.;
83 
85  // Get event ID information
87  //int nrun=iEvent.id().run();
88  //int nlumi=iEvent.luminosityBlock();
89  //int nevent=iEvent.id().event();
90 
92  // Get Primary Vertex Information
94 
95  // magic to get the vertices from EDM
97  iEvent.getByLabel(vertexSrc, vertices_h);
98  if (!vertices_h.isValid()) {
99  std::cout<<"Didja hear the one about the empty vertex collection?\n";
100  return;
101  }
102 
103  // require in the event that there is at least one reconstructed vertex
104  if(vertices_h->size()<=0) return;
105 
106  // pick the first (i.e. highest sum pt) verte
107  const reco::Vertex* theVertex=&(vertices_h->front());
108 
109  // require that the vertex meets certain criteria
110  if(theVertex->ndof()<5) return;
111  if(fabs(theVertex->z())>24.0) return;
112  if(fabs(theVertex->position().rho())>2.0) 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 
144 
CMSDAS11DijetTestAnalyzer(const edm::ParameterSet &)
Jets made from CaloTowers.
Definition: CaloJet.h:29
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
double weight() const
const Point & position() const
position
Definition: Vertex.h:109
int iEvent
Definition: GenABIO.cc:230
double z() const
z coordinate
Definition: Vertex.h:115
bool isValid() const
Definition: HandleBase.h:74
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:413
double ndof() const
Definition: Vertex.h:105
virtual bool vectorialCorrection() const
if vectorial correction is provided
Definition: JetCorrector.h:66
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:50
HLT enums.
const int NBINS
void analyze(const edm::Event &, const edm::EventSetup &)