Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:07:02

0001 // This class is used to test the functionalities of the package
0002 
0003 #include "DQM/DataScouting/plugins/ScoutingTestAnalyzer.h"
0004 #include "DataFormats/JetReco/interface/CaloJet.h"
0005 
0006 // A simple constructor which takes as inoput only the name of the PF jet
0007 // collection
0008 ScoutingTestAnalyzer::ScoutingTestAnalyzer(const edm::ParameterSet &conf) : ScoutingAnalyzerBase(conf) {
0009   m_pfJetsCollectionTag = conf.getUntrackedParameter<edm::InputTag>("pfJetsCollectionName");
0010   // set Token(-s)
0011   m_pfJetsCollectionTagToken_ =
0012       consumes<reco::CaloJetCollection>(conf.getUntrackedParameter<edm::InputTag>("pfJetsCollectionName"));
0013 }
0014 
0015 ScoutingTestAnalyzer::~ScoutingTestAnalyzer() {}
0016 
0017 // Function to book the Monitoring Elements.
0018 void ScoutingTestAnalyzer::bookHistograms(DQMStore::IBooker &iBooker, edm::Run const &, edm::EventSetup const &) {
0019   ScoutingAnalyzerBase::prepareBooking(iBooker);
0020   std::string collection_name = m_pfJetsCollectionTag.label();
0021 
0022   /* This method allows us to book an Histogram in one line in a completely
0023    * transparent way. Take your time to put axis titles!!!!*/
0024   m_jetPt = bookH1withSumw2(
0025       iBooker, collection_name + "_pt", collection_name + " Jet P_{T}", 50, 0., 500., "Jet P_{T} [GeV]");
0026 
0027   m_jetEtaPhi = bookH2withSumw2(iBooker,
0028                                 collection_name + "_etaphi",
0029                                 collection_name + " #eta #phi",
0030                                 50,
0031                                 -5,
0032                                 5,
0033                                 50,
0034                                 -3.1415,
0035                                 +3.1415,
0036                                 "#eta^{Jet}",
0037                                 "#phi^{Jet}");
0038 }
0039 
0040 // Usual analyze method
0041 void ScoutingTestAnalyzer::analyze(const edm::Event &iEvent, const edm::EventSetup &c) {
0042   edm::Handle<reco::CaloJetCollection> calojets_handle;
0043   iEvent.getByToken(m_pfJetsCollectionTagToken_, calojets_handle);
0044   /* This is an example of how C++11 can simplify or lifes. The auto keyword
0045      make the compiler figure out by itself which is the type of the pfjets
0046      object. The qualifier const of course still apply. Poor's man explaination:
0047      "compiler, make pfjets a const ref and figure out for me the type"*/
0048   auto const &calojets = *calojets_handle;
0049 
0050   // Again, C++11. A loop on a std::vector becomes as simple as this!
0051   for (auto const &calojet : calojets) {
0052     m_jetPt->Fill(calojet.pt());
0053     m_jetEtaPhi->Fill(calojet.eta(), calojet.phi());
0054   }
0055 }