CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ScoutingTestAnalyzer.cc
Go to the documentation of this file.
1 // This class is used to test the functionalities of the package
2 
4 
5 
7 
8 //------------------------------------------------------------------------------
9 // A simple constructor which takes as inoput only the name of the PF jet collection
11  :ScoutingAnalyzerBase(conf){
12  m_pfJetsCollectionTag = conf.getUntrackedParameter<edm::InputTag>("pfJetsCollectionName");
13 
14  //set Token(-s)
15  m_pfJetsCollectionTagToken_ = consumes<reco::CaloJetCollection>(conf.getUntrackedParameter<edm::InputTag>("pfJetsCollectionName"));
16  }
17 
18 //------------------------------------------------------------------------------
19 // Nothing to destroy: the DQM service thinks about everything
21 
22 //------------------------------------------------------------------------------
23 // Usual analyze method
25 
26 
27  edm::Handle<reco::CaloJetCollection> calojets_handle ;
28  iEvent.getByToken(m_pfJetsCollectionTagToken_, calojets_handle);
29 
30  /* This is an example of how C++11 can simplify or lifes. The auto keyword
31  make the compiler figure out by itself which is the type of the pfjets object.
32  The qualifier const of course still apply.
33  Poor's man explaination: "compiler, make pfjets a const ref and figure out
34  for me the type"*/
35  auto const& calojets = *calojets_handle;
36 
37  // Again, C++11. A loop on a std::vector becomes as simple as this!
38  for (auto const & calojet: calojets){
39  m_jetPt->Fill(calojet.pt());
40  m_jetEtaPhi->Fill(calojet.eta(),calojet.phi());
41  }
42 
43 
44 }
45 
46 //------------------------------------------------------------------------------
47 /* Method called at the end of the Run. Ideal to finalise stuff within the
48  * DQM infrastructure, which is entirely Run based. */
50 
51  std::string collection_name = m_pfJetsCollectionTag.label();
52  /* This function is specific of this class and allows us to make a
53  * projection in one line */
54 
56  collection_name+" Jets #eta (projection)",
57  "#eta^{Jet}");
58 
60  collection_name+" Jets phi (projection)",
61  "#phi^{Jet}");
62 
63 
64 }
65 
66 //------------------------------------------------------------------------------
67 // Function to book the Monitoring Elements.
69  std::string collection_name = m_pfJetsCollectionTag.label();
70 
71  /* This method allows us to book an Histogram in one line in a completely
72  * transparent way. Take your time to put axis titles!!!!*/
73  m_jetPt = bookH1withSumw2(collection_name+"_pt",
74  collection_name+" Jet P_{T}",
75  50,0.,500.,
76  "Jet P_{T} [GeV]");
77 
78  m_jetEtaPhi = bookH2withSumw2(collection_name+"_etaphi",
79  collection_name+" #eta #phi",
80  50,-5,5,
81  50,-3.1415,+3.1415,
82  "#eta^{Jet}",
83  "#phi^{Jet}");
84 }
85 
86 //------------------------------------------------------------------------------
87 
T getUntrackedParameter(std::string const &, T const &) const
MonitorElement * bookH2withSumw2(const std::string &name, const std::string &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, const std::string &titleX="", const std::string &titleY="", Option_t *option="COLZ")
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
MonitorElement * bookH1withSumw2(const std::string &name, const std::string &title, int nchX, double lowX, double highX, const std::string &titleX="", const std::string &titleY="Events", Option_t *option="E1 P")
virtual void analyze(const edm::Event &, const edm::EventSetup &)
MonitorElement * m_jetEtaPhi
edm::InputTag m_pfJetsCollectionTag
void Fill(long long x)
MonitorElement * profileY(MonitorElement *me2d, const std::string &title="", const std::string &titleX="", const std::string &titleY="", Double_t minimum=-1111, Double_t maximum=-1111)
int iEvent
Definition: GenABIO.cc:230
edm::EDGetTokenT< reco::CaloJetCollection > m_pfJetsCollectionTagToken_
MonitorElement * profileX(MonitorElement *me2d, const std::string &title="", const std::string &titleX="", const std::string &titleY="", Double_t minimum=-1111, Double_t maximum=-1111)
ScoutingTestAnalyzer(const edm::ParameterSet &)
MonitorElement * m_jetPt
tuple conf
Definition: dbtoconf.py:185
virtual void endRun(edm::Run const &, edm::EventSetup const &)
std::string const & label() const
Definition: InputTag.h:42
Definition: Run.h:41