File indexing completed on 2024-04-06 12:25:26
0001
0002
0003
0004
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
0019
0020 CaloTowersExample::CaloTowersExample(const ParameterSet& cfg)
0021 : CaloTowersAlgorithm(cfg.getParameter<string>("CaloTowersAlgorithm")) {}
0022
0023 void CaloTowersExample::beginJob() {
0024
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
0031 Handle<CaloTowerCollection> caloTowers;
0032 evt.getByLabel(CaloTowersAlgorithm, caloTowers);
0033
0034
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
0042 m_file->Write();
0043 }
0044 #include "FWCore/Framework/interface/MakerMacros.h"
0045 DEFINE_FWK_MODULE(CaloTowersExample);