CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
miscalibExample.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: miscalibExample
4 // Class: miscalibExample
5 //
13 //
14 // Original Author: Lorenzo AGOSTINO
15 // Created: Tue Jul 18 12:17:01 CEST 2006
16 //
17 //
18 
19 // system include files
20 
21 // user include files
23 
27 
28 #include <iostream>
29 #include <stdexcept>
30 #include <vector>
31 
33  : rootfile_{iConfig.getUntrackedParameter<std::string>("rootfile", "ecalSimpleTBanalysis.root")},
34  correctedHybridSuperClusterProducer_{iConfig.getParameter<std::string>("correctedHybridSuperClusterProducer")},
36  iConfig.getParameter<std::string>("correctedHybridSuperClusterCollection")},
37  correctedHybridSuperClusterToken_{consumes<reco::SuperClusterCollection>(
39 
41 
42 //========================================================================
44  //========================================================================
45 
46  // Book histograms
47  scEnergy = new TH1F("scEnergy", "SuperCluster energy", 100, 20., 80.);
48  read_events = 0;
49 }
50 
51 //========================================================================
53  //========================================================================
54 
55  std::cout << "************* STATISTICS **************" << std::endl;
56  std::cout << "Read Events: " << read_events << std::endl;
57 
59 
60  TFile f(rootfile_.c_str(), "RECREATE");
61 
62  scEnergy->Write();
63  f.Close();
64  delete scEnergy;
65 }
66 
67 //=================================================================================
69  //=================================================================================
70  using namespace edm;
71  using namespace std;
72 
73  read_events++;
74 
75  // Get hybrid super clusters after energy correction
76 
77  Handle<reco::SuperClusterCollection> pCorrectedHybridSuperClusters;
78 
79  iEvent.getByToken(correctedHybridSuperClusterToken_, pCorrectedHybridSuperClusters);
80 
81  if (!pCorrectedHybridSuperClusters.isValid()) {
82  LogError("EgammaSimpleAnalyzer") << "Error! can't get collection with label "
84  }
85  const reco::SuperClusterCollection* correctedHybridSuperClusters = pCorrectedHybridSuperClusters.product();
86 
87  reco::SuperClusterCollection::const_iterator superClusterIt;
88  for (superClusterIt = correctedHybridSuperClusters->begin(); superClusterIt != correctedHybridSuperClusters->end();
89  superClusterIt++) {
90  scEnergy->Fill(superClusterIt->energy());
91  }
92 }
T getUntrackedParameter(std::string const &, T const &) const
const std::string correctedHybridSuperClusterProducer_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
Log< level::Error, false > LogError
void analyze(const edm::Event &, const edm::EventSetup &) override
const std::string correctedHybridSuperClusterCollection_
int iEvent
Definition: GenABIO.cc:224
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
const std::string rootfile_
const edm::EDGetTokenT< reco::SuperClusterCollection > correctedHybridSuperClusterToken_
void endJob() override
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void beginJob() override
miscalibExample(const edm::ParameterSet &)
~miscalibExample() override
tuple cout
Definition: gather_cfg.py:144