CMS 3D CMS Logo

CaloTowersExample.cc
Go to the documentation of this file.
1 // CaloTowersExample.cc
2 // Description: Example of simple EDAnalyzer for CaloTowers.
3 // Author: Robert M. Harris
4 // Date: 8 - September - 2006
5 //
10 #include <TROOT.h>
11 #include <TSystem.h>
12 #include <TFile.h>
13 #include <TCanvas.h>
14 #include <cmath>
15 using namespace edm;
16 using namespace std;
17 
18 // Get the algorithm of the jet collections we will read from the .cfg file
19 // which defines the value of the strings CaloJetAlgorithm and GenJetAlgorithm.
21  : CaloTowersAlgorithm(cfg.getParameter<string>("CaloTowersAlgorithm")) {}
22 
24  // Open the histogram file and book some associated histograms
25  m_file = new TFile("histo.root", "RECREATE");
26  h_et = TH1F("et", "E_{T} of leading CaloTowers", 50, 0, 25);
27 }
28 
29 void CaloTowersExample::analyze(const Event& evt, const EventSetup& es) {
30  //Get the CaloTower collection
32  evt.getByLabel(CaloTowersAlgorithm, caloTowers);
33 
34  //Loop over the two leading CaloJets and fill some histograms
35  for (CaloTowerCollection::const_iterator cal = caloTowers->begin(); cal != caloTowers->end(); ++cal) {
36  h_et.Fill(cal->et());
37  }
38 }
39 
41  //Write out the histogram file.
42  m_file->Write();
43 }
std::string CaloTowersAlgorithm
CaloTowersExample(const edm::ParameterSet &)
std::vector< CaloTower >::const_iterator const_iterator
void beginJob() override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void analyze(const edm::Event &, const edm::EventSetup &) override
void endJob() override
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:488
const_iterator end() const
HLT enums.
const_iterator begin() const