Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:25:26

0001 // CaloTowersExample.cc

0002 // Description:  Example of simple EDAnalyzer for CaloTowers.

0003 // Author: Robert M. Harris

0004 // Date:  8 - September - 2006

0005 //

0006 #include "RecoJets/JetAnalyzers/interface/CaloTowersExample.h"
0007 #include "DataFormats/CaloTowers/interface/CaloTowerCollection.h"
0008 #include "FWCore/Framework/interface/Event.h"
0009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0010 #include <TROOT.h>
0011 #include <TSystem.h>
0012 #include <TFile.h>
0013 #include <TCanvas.h>
0014 #include <cmath>
0015 using namespace edm;
0016 using namespace std;
0017 
0018 // Get the algorithm of the jet collections we will read from the .cfg file

0019 // which defines the value of the strings CaloJetAlgorithm and GenJetAlgorithm.

0020 CaloTowersExample::CaloTowersExample(const ParameterSet& cfg)
0021     : CaloTowersAlgorithm(cfg.getParameter<string>("CaloTowersAlgorithm")) {}
0022 
0023 void CaloTowersExample::beginJob() {
0024   // Open the histogram file and book some associated histograms

0025   m_file = new TFile("histo.root", "RECREATE");
0026   h_et = TH1F("et", "E_{T} of leading CaloTowers", 50, 0, 25);
0027 }
0028 
0029 void CaloTowersExample::analyze(const Event& evt, const EventSetup& es) {
0030   //Get the CaloTower collection

0031   Handle<CaloTowerCollection> caloTowers;
0032   evt.getByLabel(CaloTowersAlgorithm, caloTowers);
0033 
0034   //Loop over the two leading CaloJets and fill some histograms

0035   for (CaloTowerCollection::const_iterator cal = caloTowers->begin(); cal != caloTowers->end(); ++cal) {
0036     h_et.Fill(cal->et());
0037   }
0038 }
0039 
0040 void CaloTowersExample::endJob() {
0041   //Write out the histogram file.

0042   m_file->Write();
0043 }
0044 #include "FWCore/Framework/interface/MakerMacros.h"
0045 DEFINE_FWK_MODULE(CaloTowersExample);