CMS 3D CMS Logo

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 
24 //
25 
29 
30 #include <iostream>
31 #include <stdexcept>
32 #include <vector>
33 
34 // class declaration
35 //
36 /*
37 class miscalibExample : public edm::EDAnalyzer {
38  public:
39  explicit miscalibExample(const edm::ParameterSet&);
40  ~miscalibExample();
41 
42  virtual void analyze(const edm::Event&, const edm::EventSetup&);
43  virtual void beginJob();
44  virtual void endJob();
45  private:
46 
47 
48  // ----------member data ---------------------------
49  std::string rootfile_;
50  std::string correctedHybridSuperClusterProducer_;
51  std::string correctedHybridSuperClusterCollection_;
52  std::string BarrelHitsCollection_;
53  std::string ecalHitsProducer_ ;
54  int read_events;
55 
56  TH1F* scEnergy;
57 };
58 
59 */
61  rootfile_ = iConfig.getUntrackedParameter<std::string>("rootfile", "ecalSimpleTBanalysis.root");
62  correctedHybridSuperClusterProducer_ = iConfig.getParameter<std::string>("correctedHybridSuperClusterProducer");
63  correctedHybridSuperClusterCollection_ = iConfig.getParameter<std::string>("correctedHybridSuperClusterCollection");
64 }
65 
67 
68 //========================================================================
70  //========================================================================
71 
72  // Book histograms
73  scEnergy = new TH1F("scEnergy", "SuperCluster energy", 100, 20., 80.);
74  read_events = 0;
75 }
76 
77 //========================================================================
79  //========================================================================
80 
81  std::cout << "************* STATISTICS **************" << std::endl;
82  std::cout << "Read Events: " << read_events << std::endl;
83 
85 
86  TFile f(rootfile_.c_str(), "RECREATE");
87 
88  scEnergy->Write();
89  f.Close();
90 }
91 
92 //=================================================================================
94  //=================================================================================
95  using namespace edm;
96  using namespace std;
97 
98  read_events++;
99 
100  // Get hybrid super clusters after energy correction
101 
102  Handle<reco::SuperClusterCollection> pCorrectedHybridSuperClusters;
103  iEvent.getByLabel(
105  if (!pCorrectedHybridSuperClusters.isValid()) {
106  LogError("EgammaSimpleAnalyzer") << "Error! can't get collection with label "
108  }
109  const reco::SuperClusterCollection* correctedHybridSuperClusters = pCorrectedHybridSuperClusters.product();
110 
111  reco::SuperClusterCollection::const_iterator superClusterIt;
112  for (superClusterIt = correctedHybridSuperClusters->begin(); superClusterIt != correctedHybridSuperClusters->end();
113  superClusterIt++) {
114  scEnergy->Fill(superClusterIt->energy());
115  }
116 }
117 
118 //define this as a plug-in
119 //DEFINE_FWK_MODULE(miscalibExample);
miscalibExample::~miscalibExample
~miscalibExample() override
Definition: miscalibExample.cc:66
MessageLogger.h
edm::Handle::product
T const * product() const
Definition: Handle.h:70
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
edm
HLT enums.
Definition: AlignableModifier.h:19
miscalibExample::correctedHybridSuperClusterCollection_
std::string correctedHybridSuperClusterCollection_
Definition: miscalibExample.h:46
gather_cfg.cout
cout
Definition: gather_cfg.py:144
miscalibExample::correctedHybridSuperClusterProducer_
std::string correctedHybridSuperClusterProducer_
Definition: miscalibExample.h:45
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::Handle
Definition: AssociativeIterator.h:50
reco::SuperClusterCollection
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
Definition: SuperClusterFwd.h:9
miscalibExample::endJob
void endJob() override
Definition: miscalibExample.cc:78
miscalibExample::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: miscalibExample.cc:93
miscalibExample::rootfile_
std::string rootfile_
Definition: miscalibExample.h:44
miscalibExample::beginJob
void beginJob() override
Definition: miscalibExample.cc:69
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
miscalibExample::read_events
int read_events
Definition: miscalibExample.h:49
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:57
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
std
Definition: JetResolutionObject.h:76
SuperClusterFwd.h
miscalibExample::miscalibExample
miscalibExample(const edm::ParameterSet &)
Definition: miscalibExample.cc:60
SuperCluster.h
miscalibExample::scEnergy
TH1F * scEnergy
Definition: miscalibExample.h:51
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
miscalibExample.h
correctedHybridSuperClusters_cfi.correctedHybridSuperClusters
correctedHybridSuperClusters
Definition: correctedHybridSuperClusters_cfi.py:4