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 
5 
6 // A simple constructor which takes as inoput only the name of the PF jet collection
8  :ScoutingAnalyzerBase(conf) {
9  m_pfJetsCollectionTag = conf.getUntrackedParameter<edm::InputTag>("pfJetsCollectionName");
10  //set Token(-s)
11  m_pfJetsCollectionTagToken_ = consumes<reco::CaloJetCollection>(conf.getUntrackedParameter<edm::InputTag>("pfJetsCollectionName"));
12 }
13 
15 
16 // Function to book the Monitoring Elements.
19  std::string collection_name = m_pfJetsCollectionTag.label();
20 
21  /* This method allows us to book an Histogram in one line in a completely
22  * transparent way. Take your time to put axis titles!!!!*/
24  iBooker,
25  collection_name+"_pt",
26  collection_name+" Jet P_{T}",
27  50,0.,500.,
28  "Jet P_{T} [GeV]");
29 
31  iBooker,
32  collection_name+"_etaphi",
33  collection_name+" #eta #phi",
34  50,-5,5,
35  50,-3.1415,+3.1415,
36  "#eta^{Jet}",
37  "#phi^{Jet}");
38 }
39 
40 // Usual analyze method
42  edm::Handle<reco::CaloJetCollection> calojets_handle ;
43  iEvent.getByToken(m_pfJetsCollectionTagToken_, calojets_handle);
44  /* This is an example of how C++11 can simplify or lifes. The auto keyword
45  make the compiler figure out by itself which is the type of the pfjets object.
46  The qualifier const of course still apply.
47  Poor's man explaination: "compiler, make pfjets a const ref and figure out
48  for me the type"*/
49  auto const& calojets = *calojets_handle;
50 
51  // Again, C++11. A loop on a std::vector becomes as simple as this!
52  for (auto const & calojet: calojets){
53  m_jetPt->Fill(calojet.pt());
54  m_jetEtaPhi->Fill(calojet.eta(),calojet.phi());
55  }
56 }
57 
58 /* Method called at the end of the Run. Ideal to finalise stuff within the
59  * DQM infrastructure, which is entirely Run based. */
61  std::string collection_name = m_pfJetsCollectionTag.label();
62  /* This function is specific of this class and allows us to make a
63  * projection in one line
64  * The following code form the original TestAnalyser tried to book histograms
65  * in the endRun step. This is not allowed anymore.
66  * Since this is just a test class, there is no point in trying to fix the impossible.
67  * The profileX and profileY methods are only used in this test class anyway.
68  * */
75 }
T getUntrackedParameter(std::string const &, T const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
void prepareBooking(DQMStore::IBooker &)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
MonitorElement * m_jetEtaPhi
edm::InputTag m_pfJetsCollectionTag
void Fill(long long x)
int iEvent
Definition: GenABIO.cc:230
MonitorElement * bookH1withSumw2(DQMStore::IBooker &, 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")
edm::EDGetTokenT< reco::CaloJetCollection > m_pfJetsCollectionTagToken_
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:43
MonitorElement * bookH2withSumw2(DQMStore::IBooker &, 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")
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: Run.h:43