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 
20 // system include files
21 
22 // user include files
24 
25 
26 //
27 
31 
32 
33 #include <iostream>
34 #include <stdexcept>
35 #include <vector>
36 
37 
38 
39 // class declaration
40 //
41 /*
42 class miscalibExample : public edm::EDAnalyzer {
43  public:
44  explicit miscalibExample(const edm::ParameterSet&);
45  ~miscalibExample();
46 
47  virtual void analyze(const edm::Event&, const edm::EventSetup&);
48  virtual void beginJob();
49  virtual void endJob();
50  private:
51 
52 
53  // ----------member data ---------------------------
54  std::string rootfile_;
55  std::string correctedHybridSuperClusterProducer_;
56  std::string correctedHybridSuperClusterCollection_;
57  std::string BarrelHitsCollection_;
58  std::string ecalHitsProducer_ ;
59  int read_events;
60 
61  TH1F* scEnergy;
62 };
63 
64 */
66 {
67 
68  rootfile_ = iConfig.getUntrackedParameter<std::string>("rootfile","ecalSimpleTBanalysis.root");
69  correctedHybridSuperClusterProducer_ = iConfig.getParameter<std::string>("correctedHybridSuperClusterProducer");
70  correctedHybridSuperClusterCollection_ = iConfig.getParameter<std::string>("correctedHybridSuperClusterCollection");
71 
72 }
73 
74 
76 {
77 
78 
79 }
80 
81 //========================================================================
82 void
84 //========================================================================
85 
86  // Book histograms
87  scEnergy = new TH1F("scEnergy","SuperCluster energy", 100, 20., 80.);
88  read_events=0;
89 
90  }
91 
92 //========================================================================
93 void
95 //========================================================================
96 
97  std::cout << "************* STATISTICS **************" << std::endl;
98  std::cout << "Read Events: " << read_events << std::endl;
99 
100 
102 
103  TFile f(rootfile_.c_str(),"RECREATE");
104 
105  scEnergy->Write();
106  f.Close();
107 
108 }
109 
110 
111 
112 //=================================================================================
113 void
115 {
116 //=================================================================================
117  using namespace edm;
118  using namespace std;
119 
120  read_events++;
121 
122  // Get hybrid super clusters after energy correction
123 
124  Handle<reco::SuperClusterCollection> pCorrectedHybridSuperClusters;
126  if (!pCorrectedHybridSuperClusters.isValid()) {
127  LogError("EgammaSimpleAnalyzer") << "Error! can't get collection with label " << correctedHybridSuperClusterCollection_.c_str() ;
128  }
129  const reco::SuperClusterCollection* correctedHybridSuperClusters = pCorrectedHybridSuperClusters.product();
130 
131 
132  reco::SuperClusterCollection::const_iterator superClusterIt;
133  for(superClusterIt=correctedHybridSuperClusters->begin(); superClusterIt!=correctedHybridSuperClusters->end(); superClusterIt++ )
134  {
135 
136  scEnergy->Fill(superClusterIt->energy());
137 
138  }
139 
140 }
141 
142 //define this as a plug-in
143 //DEFINE_FWK_MODULE(miscalibExample);
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::string correctedHybridSuperClusterProducer_
void analyze(const edm::Event &, const edm::EventSetup &) override
int iEvent
Definition: GenABIO.cc:230
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
std::string correctedHybridSuperClusterCollection_
double f[11][100]
bool isValid() const
Definition: HandleBase.h:74
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:535
std::string rootfile_
T const * product() const
Definition: Handle.h:81
void endJob() override
void beginJob() override
miscalibExample(const edm::ParameterSet &)
HLT enums.
~miscalibExample() override