CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/DQM/DataScouting/plugins/ScoutingTestAnalyzer.cc

Go to the documentation of this file.
00001 // This class is used to test the functionalities of the package
00002 
00003 #include "DQM/DataScouting/plugins/ScoutingTestAnalyzer.h"
00004 
00005 
00006 #include "DataFormats/JetReco/interface/CaloJet.h"
00007 
00008 //------------------------------------------------------------------------------
00009 // A simple constructor which takes as inoput only the name of the PF jet collection
00010 ScoutingTestAnalyzer::ScoutingTestAnalyzer( const edm::ParameterSet & conf )
00011    :ScoutingAnalyzerBase(conf){
00012   m_pfJetsCollectionTag = conf.getUntrackedParameter<edm::InputTag>("pfJetsCollectionName");
00013   }
00014 
00015 //------------------------------------------------------------------------------
00016 // Nothing to destroy: the DQM service thinks about everything
00017 ScoutingTestAnalyzer::~ScoutingTestAnalyzer(){}
00018 
00019 //------------------------------------------------------------------------------
00020 // Usual analyze method
00021 void ScoutingTestAnalyzer::analyze( const edm::Event & iEvent, const edm::EventSetup & c ){
00022   
00023   
00024   edm::Handle<reco::CaloJetCollection> calojets_handle ;
00025   iEvent.getByLabel(m_pfJetsCollectionTag,calojets_handle) ;
00026   /* This is an example of how C++11 can simplify or lifes. The auto keyword 
00027    make the compiler figure out by itself which is the type of the pfjets object.
00028    The qualifier const of course still apply.
00029    Poor's man explaination: "compiler, make pfjets a const ref and figure out 
00030    for me the type"*/
00031   auto const& calojets = *calojets_handle;
00032   
00033   // Again, C++11. A loop on a std::vector becomes as simple as this!
00034   for (auto const & calojet: calojets){
00035     m_jetPt->Fill(calojet.pt());
00036     m_jetEtaPhi->Fill(calojet.eta(),calojet.phi());
00037   }
00038   
00039   
00040 }
00041 
00042 //------------------------------------------------------------------------------
00043 /* Method called at the end of the Run. Ideal to finalise stuff within the 
00044  * DQM infrastructure, which is entirely Run based. */
00045 void ScoutingTestAnalyzer::endRun( edm::Run const &, edm::EventSetup const & ){
00046     
00047     std::string collection_name = m_pfJetsCollectionTag.label();
00048     /* This function is specific of this class and allows us to make a 
00049      * projection in one line */
00050     
00051     profileX(m_jetEtaPhi,
00052              collection_name+" Jets #eta (projection)",
00053              "#eta^{Jet}");
00054     
00055     profileY(m_jetEtaPhi,
00056              collection_name+" Jets phi (projection)",
00057              "#phi^{Jet}");
00058 
00059     
00060 }
00061 
00062 //------------------------------------------------------------------------------
00063 // Function to book the Monitoring Elements.
00064 void ScoutingTestAnalyzer::bookMEs(){
00065   std::string collection_name = m_pfJetsCollectionTag.label();
00066 
00067   /* This method allows us to book an Histogram in one line in a completely 
00068    * transparent way. Take your time to put axis titles!!!!*/
00069   m_jetPt = bookH1withSumw2(collection_name+"_pt",
00070                             collection_name+" Jet P_{T}",
00071                             50,0.,500.,
00072                             "Jet P_{T} [GeV]");
00073 
00074   m_jetEtaPhi = bookH2withSumw2(collection_name+"_etaphi",
00075                                 collection_name+" #eta #phi",
00076                                 50,-5,5,
00077                                 50,-3.1415,+3.1415,
00078                                 "#eta^{Jet}",
00079                                 "#phi^{Jet}");
00080 }
00081 
00082 //------------------------------------------------------------------------------
00083