CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  {
23 }
24 
26 
27  // Open the histogram file and book some associated histograms
28  m_file=new TFile("histo.root","RECREATE");
29  h_et = TH1F( "et", "E_{T} of leading CaloTowers", 50, 0, 25 );
30 }
31 
32 void CaloTowersExample::analyze( const Event& evt, const EventSetup& es ) {
33 
34  //Get the CaloTower collection
36  evt.getByLabel( CaloTowersAlgorithm, caloTowers );
37 
38  //Loop over the two leading CaloJets and fill some histograms
39  for( CaloTowerCollection::const_iterator cal = caloTowers->begin(); cal != caloTowers->end(); ++ cal ) {
40  h_et.Fill( cal->et() );
41  }
42 
43 }
44 
46 
47  //Write out the histogram file.
48  m_file->Write();
49 
50 }
std::string CaloTowersAlgorithm
CaloTowersExample(const edm::ParameterSet &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< CaloTower >::const_iterator const_iterator
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
void analyze(const edm::Event &, const edm::EventSetup &)