CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/RecoJets/JetAnalyzers/src/CaloTowersExample.cc

Go to the documentation of this file.
00001 // CaloTowersExample.cc
00002 // Description:  Example of simple EDAnalyzer for CaloTowers.
00003 // Author: Robert M. Harris
00004 // Date:  8 - September - 2006
00005 // 
00006 #include "RecoJets/JetAnalyzers/interface/CaloTowersExample.h"
00007 #include "DataFormats/CaloTowers/interface/CaloTowerCollection.h"
00008 #include "FWCore/Framework/interface/Event.h"
00009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00010 #include <TROOT.h>
00011 #include <TSystem.h>
00012 #include <TFile.h>
00013 #include <TCanvas.h>
00014 #include <cmath>
00015 using namespace edm;
00016 using namespace std;
00017 
00018 // Get the algorithm of the jet collections we will read from the .cfg file 
00019 // which defines the value of the strings CaloJetAlgorithm and GenJetAlgorithm.
00020 CaloTowersExample::CaloTowersExample( const ParameterSet & cfg ) :
00021   CaloTowersAlgorithm( cfg.getParameter<string>( "CaloTowersAlgorithm" ) )
00022   {
00023 }
00024 
00025 void CaloTowersExample::beginJob( ) {
00026 
00027   // Open the histogram file and book some associated histograms
00028   m_file=new TFile("histo.root","RECREATE"); 
00029   h_et =  TH1F( "et",  "E_{T} of leading CaloTowers", 50, 0, 25 );
00030 }
00031 
00032 void CaloTowersExample::analyze( const Event& evt, const EventSetup& es ) {
00033 
00034   //Get the CaloTower collection
00035   Handle<CaloTowerCollection> caloTowers;
00036   evt.getByLabel( CaloTowersAlgorithm, caloTowers );
00037 
00038   //Loop over the two leading CaloJets and fill some histograms
00039   for( CaloTowerCollection::const_iterator cal = caloTowers->begin(); cal != caloTowers->end(); ++ cal ) {
00040     h_et.Fill( cal->et() );   
00041   }
00042 
00043 }
00044 
00045 void CaloTowersExample::endJob() {
00046 
00047   //Write out the histogram file.
00048   m_file->Write(); 
00049 
00050 }
00051 #include "FWCore/Framework/interface/MakerMacros.h"
00052 DEFINE_FWK_MODULE(CaloTowersExample);