CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EgammaSimpleAnalyzer.cc
Go to the documentation of this file.
1 
8 //
9 // Original Author: Shahram Rahatlou
10 // Created: 10 May 2006
11 // $Id: EgammaSimpleAnalyzer.cc,v 1.14 2009/12/18 20:45:01 wmtan Exp $
12 //
13 
15 
19 
20 #include "TFile.h"
26 
27 
28 //========================================================================
30 //========================================================================
31 {
32 
33  xMinHist_ = ps.getParameter<double>("xMinHist");
34  xMaxHist_ = ps.getParameter<double>("xMaxHist");
35  nbinHist_ = ps.getParameter<int>("nbinHist");
36 
37  islandBarrelBasicClusterCollection_ = ps.getParameter<std::string>("islandBarrelBasicClusterCollection");
38  islandBarrelBasicClusterProducer_ = ps.getParameter<std::string>("islandBarrelBasicClusterProducer");
39  islandBarrelBasicClusterShapes_ = ps.getParameter<std::string>("islandBarrelBasicClusterShapes");
40 
41  islandEndcapBasicClusterCollection_ = ps.getParameter<std::string>("islandEndcapBasicClusterCollection");
42  islandEndcapBasicClusterProducer_ = ps.getParameter<std::string>("islandEndcapBasicClusterProducer");
43  islandEndcapBasicClusterShapes_ = ps.getParameter<std::string>("islandEndcapBasicClusterShapes");
44 
45  islandEndcapSuperClusterCollection_ = ps.getParameter<std::string>("islandEndcapSuperClusterCollection");
46  islandEndcapSuperClusterProducer_ = ps.getParameter<std::string>("islandEndcapSuperClusterProducer");
47 
48  correctedIslandEndcapSuperClusterCollection_ = ps.getParameter<std::string>("correctedIslandEndcapSuperClusterCollection");
49  correctedIslandEndcapSuperClusterProducer_ = ps.getParameter<std::string>("correctedIslandEndcapSuperClusterProducer");
50 
51  hybridSuperClusterCollection_ = ps.getParameter<std::string>("hybridSuperClusterCollection");
52  hybridSuperClusterProducer_ = ps.getParameter<std::string>("hybridSuperClusterProducer");
53 
54  correctedHybridSuperClusterCollection_ = ps.getParameter<std::string>("correctedHybridSuperClusterCollection");
55  correctedHybridSuperClusterProducer_ = ps.getParameter<std::string>("correctedHybridSuperClusterProducer");
56 
57  outputFile_ = ps.getParameter<std::string>("outputFile");
58  rootFile_ = TFile::Open(outputFile_.c_str(),"RECREATE"); // open output file to store histograms
59 
60 }
61 
62 
63 //========================================================================
65 //========================================================================
66 {
67 
68  // apparently ROOT takes ownership of histograms
69  // created after opening a new TFile... no delete is needed
70  // ... mysteries of root...
71  /*
72  delete h1_islandBCEnergy_;
73  delete h1_islandSCEnergy_;
74  delete h1_corrIslandSCEnergy_;
75  delete h1_hybridSCEnergy_;
76  delete h1_corrHybridSCEnergy_;
77  delete h1_corrHybridSCEta_;
78  delete h1_corrHybridSCPhi_;
79  */
80  delete rootFile_;
81 }
82 
83 //========================================================================
84 void
86 //========================================================================
87 
88  // go to *OUR* rootfile and book histograms
89  rootFile_->cd();
90 
91  h1_nIslandEBBC_ = new TH1F("nIslandEBBC","# basic clusters with island in barrel",11,-0.5,10.5);
92  h1_nIslandEEBC_ = new TH1F("nIslandEEBC","# basic clusters with island in endcap",11,-0.5,10.5);
93 
94  h1_nIslandEESC_ = new TH1F("nIslandEESC","# super clusters with island in endcap",11,-0.5,10.5);
95  h1_nHybridSC_ = new TH1F("nHybridSC","# super clusters with hybrid",11,-0.5,10.5);
96 
97  h1_islandEBBCEnergy_ = new TH1F("islandEBBCEnergy","Energy of basic clusters with island algo - barrel",nbinHist_,xMinHist_,xMaxHist_);
98  h1_islandEBBCXtals_ = new TH1F("islandEBBCXtals","#xtals in basic cluster - island barrel",51,-0.5,50.5);
99 
100  h1_islandEBBCe9over25_= new TH1F("islandEBBCe9over25","e3x3/e5x5 of basic clusters with island algo - barrel",35,0.5,1.2);
101  h1_islandEBBCe5x5_ = new TH1F("islandEBBCe5x5","e5x5 of basic clusters with island algo - barrel",nbinHist_,xMinHist_,xMaxHist_);
102  h1_islandEEBCe5x5_ = new TH1F("islandEEBCe5x5","e5x5 of basic clusters with island algo - endcap",nbinHist_,xMinHist_,xMaxHist_);
103  h1_islandEEBCEnergy_ = new TH1F("islandEEBCEnergy","Energy of basic clusters with island algo - endcap",nbinHist_,xMinHist_,xMaxHist_);
104  h1_islandEEBCXtals_ = new TH1F("islandEEBCXtals","#xtals in basic cluster - island endcap",51,-0.5,50.5);
105 
106  h1_islandEESCEnergy_ = new TH1F("islandEESCEnergy","Energy of super clusters with island algo - endcap",nbinHist_,xMinHist_,xMaxHist_);
107  h1_corrIslandEESCEnergy_ = new TH1F("corrIslandEESCEnergy","Corrected Energy of super clusters with island algo - endcap",nbinHist_,xMinHist_,xMaxHist_);
108  h1_corrIslandEESCET_ = new TH1F("corrIslandEESCET","Corrected Transverse Energy of super clusters with island algo - endcap",nbinHist_,xMinHist_,xMaxHist_);
109  h1_islandEESCClusters_ = new TH1F("islandEESCClusters","# basic clusters in super cluster - island endcap",11,-0.5,10.5);
110 
111  h1_hybridSCEnergy_ = new TH1F("hybridSCEnergy","Energy of super clusters with hybrid algo",nbinHist_,xMinHist_,xMaxHist_);
112  h1_corrHybridSCEnergy_ = new TH1F("corrHybridSCEnergy","Corrected Energy of super clusters with hybrid algo",nbinHist_,xMinHist_,xMaxHist_);
113  h1_corrHybridSCET_ = new TH1F("corrHybridSCET","Corrected Transverse Energy of super clusters with hybrid algo",nbinHist_,xMinHist_,xMaxHist_);
114  h1_corrHybridSCEta_ = new TH1F("corrHybridSCEta","Eta of super clusters with hybrid algo",40,-3.,3.);
115  h1_corrHybridSCPhi_ = new TH1F("corrHybridSCPhi","Phi of super clusters with hybrid algo",40,0.,6.28);
116  h1_hybridSCClusters_ = new TH1F("hybridSCClusters","# basic clusters in super cluster - hybrid",11,-0.5,10.5);
117 
118 }
119 
120 
121 //========================================================================
122 void
124 //========================================================================
125 
126  using namespace edm; // needed for all fwk related classes
127 
128 
129  // ----- barrel with island
130 
131  // Get island basic clusters
132  Handle<reco::BasicClusterCollection> pIslandBarrelBasicClusters;
134  const reco::BasicClusterCollection* islandBarrelBasicClusters = pIslandBarrelBasicClusters.product();
135  h1_nIslandEBBC_->Fill(islandBarrelBasicClusters->size());
136 
137  // fetch cluster shapes of island basic clusters in barrel
138  Handle<reco::ClusterShapeCollection> pIslandEBShapes;
140  const reco::ClusterShapeCollection* islandEBShapes = pIslandEBShapes.product();
141 
142  std::ostringstream str;
143  str << "# island basic clusters in barrel: " << islandBarrelBasicClusters->size()
144  << "\t# associated cluster shapes: " << islandEBShapes->size() << "\n"
145  << "Loop over island basic clusters in barrel" << "\n";
146 
147  // loop over the Basic clusters and fill the histogram
148  int iClus=0;
149  for(reco::BasicClusterCollection::const_iterator aClus = islandBarrelBasicClusters->begin();
150  aClus != islandBarrelBasicClusters->end(); aClus++) {
151  h1_islandEBBCEnergy_->Fill( aClus->energy() );
152  h1_islandEBBCXtals_->Fill( aClus->size() );
153  str << "energy: " << aClus->energy()
154  << "\te5x5: " << (*islandEBShapes)[iClus].e5x5()
155  << "\te2x2: " << (*islandEBShapes)[iClus].e2x2()
156  << "\n";
157  h1_islandEBBCe5x5_->Fill( (*islandEBShapes)[iClus].e5x5() );
158 
159  iClus++;
160  }
161  edm::LogInfo("EgammaSimpleAnalyzer") << str.str();
162 
163  // extract energy corrections applied
164 
165  // ---- island in endcap
166 
167  // Get island basic clusters
168  Handle<reco::BasicClusterCollection> pIslandEndcapBasicClusters;
170  const reco::BasicClusterCollection* islandEndcapBasicClusters = pIslandEndcapBasicClusters.product();
171  h1_nIslandEEBC_->Fill(islandEndcapBasicClusters->size());
172 
173  // fetch cluster shapes of island basic clusters in endcap
174  Handle<reco::ClusterShapeCollection> pIslandEEShapes;
176  const reco::ClusterShapeCollection* islandEEShapes = pIslandEEShapes.product();
177 
178  // loop over the Basic clusters and fill the histogram
179  iClus=0;
180  for(reco::BasicClusterCollection::const_iterator aClus = islandEndcapBasicClusters->begin();
181  aClus != islandEndcapBasicClusters->end(); aClus++) {
182  h1_islandEEBCEnergy_->Fill( aClus->energy() );
183  h1_islandEEBCXtals_->Fill( aClus->size() );
184  h1_islandEEBCe5x5_->Fill( (*islandEEShapes)[iClus].e5x5() );
185  h1_islandEBBCe9over25_->Fill( (*islandEEShapes)[iClus].e3x3()/(*islandEEShapes)[iClus].e5x5() );
186  iClus++;
187  }
188  edm::LogInfo("EgammaSimpleAnalyzer") << str.str();
189 
190  // Get island super clusters
191  Handle<reco::SuperClusterCollection> pIslandEndcapSuperClusters;
193  const reco::SuperClusterCollection* islandEndcapSuperClusters = pIslandEndcapSuperClusters.product();
194 
195  // loop over the super clusters and fill the histogram
196  for(reco::SuperClusterCollection::const_iterator aClus = islandEndcapSuperClusters->begin();
197  aClus != islandEndcapSuperClusters->end(); aClus++) {
198  h1_islandEESCEnergy_->Fill( aClus->energy() );
199  }
200 
201 
202  // Get island super clusters after energy correction
203  Handle<reco::SuperClusterCollection> pCorrectedIslandEndcapSuperClusters;
205  const reco::SuperClusterCollection* correctedIslandEndcapSuperClusters = pCorrectedIslandEndcapSuperClusters.product();
206  h1_nIslandEESC_->Fill(islandEndcapSuperClusters->size());
207 
208  // loop over the super clusters and fill the histogram
209  for(reco::SuperClusterCollection::const_iterator aClus = correctedIslandEndcapSuperClusters->begin();
210  aClus != correctedIslandEndcapSuperClusters->end(); aClus++) {
211  h1_corrIslandEESCEnergy_->Fill( aClus->energy() );
212  h1_corrIslandEESCET_->Fill( aClus->energy()*sin(aClus->position().theta()) );
213  h1_islandEESCClusters_->Fill( aClus->clustersSize() );
214  }
215 
216  // extract energy corrections applied
217 
218 
219  // ----- hybrid
220 
221  // Get hybrid super clusters
222  Handle<reco::SuperClusterCollection> pHybridSuperClusters;
224  const reco::SuperClusterCollection* hybridSuperClusters = pHybridSuperClusters.product();
225 
226  // loop over the super clusters and fill the histogram
227  for(reco::SuperClusterCollection::const_iterator aClus = hybridSuperClusters->begin();
228  aClus != hybridSuperClusters->end(); aClus++) {
229  h1_hybridSCEnergy_->Fill( aClus->energy() );
230  }
231 
232 
233  // Get hybrid super clusters after energy correction
234  Handle<reco::SuperClusterCollection> pCorrectedHybridSuperClusters;
236  const reco::SuperClusterCollection* correctedHybridSuperClusters = pCorrectedHybridSuperClusters.product();
238 
239 
240  // loop over the super clusters and fill the histogram
241  for(reco::SuperClusterCollection::const_iterator aClus = correctedHybridSuperClusters->begin();
242  aClus != correctedHybridSuperClusters->end(); aClus++) {
243  h1_hybridSCClusters_->Fill( aClus->clustersSize() );
244  h1_corrHybridSCEnergy_->Fill( aClus->energy() );
245  h1_corrHybridSCET_->Fill( aClus->energy()*sin(aClus->position().theta()) );
246  h1_corrHybridSCEta_->Fill( aClus->position().eta() );
247  h1_corrHybridSCPhi_->Fill( aClus->position().phi() );
248  }
249 
250 }
251 
252 //========================================================================
253 void
255 //========================================================================
256 
257  // go to *OUR* root file and store histograms
258  rootFile_->cd();
259 
260  h1_nIslandEBBC_->Write();
261  h1_nIslandEEBC_->Write();
262  h1_nIslandEESC_->Write();
263  h1_nHybridSC_->Write();
264 
265  h1_islandEBBCe9over25_->Write();
266  h1_islandEBBCe5x5_->Write();
267  h1_islandEBBCEnergy_->Write();
268  h1_islandEBBCXtals_->Write();
269 
270  h1_islandEEBCe5x5_->Write();
271  h1_islandEEBCEnergy_->Write();
272  h1_islandEEBCXtals_->Write();
273 
274  h1_islandEESCEnergy_->Write();
275  h1_corrIslandEESCEnergy_->Write();
276  h1_corrIslandEESCET_->Write();
277  h1_islandEESCClusters_->Write();
278 
279  h1_hybridSCClusters_->Write();
280  h1_hybridSCEnergy_->Write();
281  h1_corrHybridSCEnergy_->Write();
282  h1_corrHybridSCET_->Write();
283  h1_corrHybridSCEta_->Write();
284  h1_corrHybridSCPhi_->Write();
285 
286  rootFile_->Close();
287 }
std::string islandEndcapSuperClusterCollection_
T getParameter(std::string const &) const
std::string correctedHybridSuperClusterProducer_
EgammaSimpleAnalyzer(const edm::ParameterSet &)
std::string islandEndcapBasicClusterShapes_
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::string correctedIslandEndcapSuperClusterCollection_
std::vector< ClusterShape > ClusterShapeCollection
collection of ClusterShape objects
std::string islandEndcapSuperClusterProducer_
std::string islandEndcapBasicClusterProducer_
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
std::string islandBarrelBasicClusterCollection_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
std::string islandEndcapBasicClusterCollection_
std::string islandBarrelBasicClusterProducer_
std::string islandBarrelBasicClusterShapes_
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
std::string hybridSuperClusterProducer_
std::string hybridSuperClusterCollection_
std::string correctedHybridSuperClusterCollection_
std::string correctedIslandEndcapSuperClusterProducer_
virtual void analyze(const edm::Event &, const edm::EventSetup &)