CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PreshowerAnalyzer.cc
Go to the documentation of this file.
1 
8 //
9 // Original Author: Shahram Rahatlou
10 // Created: 10 May 200
11 // $Id: PreshowerAnalyzer.cc,v 1.6 2009/12/18 20:45:01 wmtan Exp $
12 //
13 
15 
19 
20 #include "TFile.h"
24 
28 
29 //========================================================================
31 //========================================================================
32 {
33 
34  EminDE_ = ps.getParameter<double>("EminDE");
35  EmaxDE_ = ps.getParameter<double>("EmaxDE");
36  nBinDE_ = ps.getParameter<int>("nBinDE");
37 
38  EminSC_ = ps.getParameter<double>("EminSC");
39  EmaxSC_ = ps.getParameter<double>("EmaxSC");
40  nBinSC_ = ps.getParameter<int>("nBinSC");
41 
42  preshClusterCollectionX_ = ps.getParameter<std::string>("preshClusterCollectionX");
43  preshClusterCollectionY_ = ps.getParameter<std::string>("preshClusterCollectionY");
44  preshClusterProducer_ = ps.getParameter<std::string>("preshClusterProducer");
45 
46  islandEndcapSuperClusterCollection1_ = ps.getParameter<std::string>("islandEndcapSuperClusterCollection1");
47  islandEndcapSuperClusterProducer1_ = ps.getParameter<std::string>("islandEndcapSuperClusterProducer1");
48 
49  islandEndcapSuperClusterCollection2_ = ps.getParameter<std::string>("islandEndcapSuperClusterCollection2");
50  islandEndcapSuperClusterProducer2_ = ps.getParameter<std::string>("islandEndcapSuperClusterProducer2");
51 
52  outputFile_ = ps.getParameter<std::string>("outputFile");
53  rootFile_ = TFile::Open(outputFile_.c_str(),"RECREATE"); // open output file to store histograms
54 
55  // calibration parameters:
56  calib_planeX_ = ps.getParameter<double>("preshCalibPlaneX");
57  calib_planeY_ = ps.getParameter<double>("preshCalibPlaneY");
58  gamma_ = ps.getParameter<double>("preshCalibGamma");
59  mip_ = ps.getParameter<double>("preshCalibMIP");
60 
61  nEvt_ = 0;
62 }
63 
64 //========================================================================
66 //========================================================================
67 {
68  delete rootFile_;
69 }
70 
71 //========================================================================
73 //========================================================================
74 
75  rootFile_->cd();
76 
77  h1_esE_x = new TH1F("esE_x"," ES cluster Energy in X-plane",20, 0, 0.03);
78  h1_esE_y = new TH1F("esE_y"," ES cluster Energy in Y-plane",20, 0, 0.03);
79  h1_esEta_x = new TH1F("esEta_x"," ES cluster Eta in X-plane",12, 1.5, 2.7);
80  h1_esEta_y = new TH1F("esEta_y"," ES cluster Eta in Y-plane",12, 1.5, 2.7);
81  h1_esPhi_x = new TH1F("esPhi_x"," ES cluster Phi in X-plane",20, 0, 6.28);
82  h1_esPhi_y = new TH1F("esPhi_y"," ES cluster Phi in Y-plane",20, 0, 6.28);
83  h1_esNhits_x = new TH1F("esNhits_x"," ES cluster Nhits in X-plane",10, 0, 10);
84  h1_esNhits_y = new TH1F("esNhits_y"," ES cluster Nhits in Y-plane",10, 0, 10);
85  h1_esDeltaE = new TH1F("esDeltaE"," DeltaE", nBinDE_, EminDE_, EmaxDE_);
86  h1_nclu_x = new TH1F("esNclu_x"," number of ES clusters (for one SC) in X-plane",20, 0, 80);
87  h1_nclu_y = new TH1F("esNclu_y"," number of ES clusters (for one SC) in Y-plane",20, 0, 80);
88 
89  h1_islandEESCEnergy1 = new TH1F("islandEESCEnergy1","Energy of super clusters with island algo - endcap1",nBinSC_,EminSC_,EmaxSC_);
90  h1_islandEESCEnergy2 = new TH1F("islandEESCEnergy2","Energy of super clusters with island algo - endcap2",nBinSC_,EminSC_,EmaxSC_);
91 }
92 
93 
94 //========================================================================
95 void
97 //========================================================================
98 
99  using namespace edm; // needed for all fwk related classe
100 
101  //std::cout << "\n ....... Event # " << nEvt_+1 << " is analyzing ....... " << std::endl << std::endl;
102 
103  // Get island super clusters
104  Handle<reco::SuperClusterCollection> pIslandEndcapSuperClusters1;
106  const reco::SuperClusterCollection* islandEndcapSuperClusters1 = pIslandEndcapSuperClusters1.product();
107  //std::cout << "\n islandEndcapSuperClusters1->size() = " << islandEndcapSuperClusters1->size() << std::endl;
108 
109  // loop over the super clusters and fill the histogram
110  for(reco::SuperClusterCollection::const_iterator aClus = islandEndcapSuperClusters1->begin();
111  aClus != islandEndcapSuperClusters1->end(); aClus++) {
112  h1_islandEESCEnergy1->Fill( aClus->energy() );
113  }
114 
115  // Get island super clusters
116  Handle<reco::SuperClusterCollection> pIslandEndcapSuperClusters2;
118  const reco::SuperClusterCollection* islandEndcapSuperClusters2 = pIslandEndcapSuperClusters2.product();
119  //std::cout << "\n islandEndcapSuperClusters2->size() = " << islandEndcapSuperClusters2->size() << std::endl;
120 
121  // loop over the super clusters and fill the histogram
122  for(reco::SuperClusterCollection::const_iterator aClus = islandEndcapSuperClusters2->begin();
123  aClus != islandEndcapSuperClusters2->end(); aClus++) {
124  h1_islandEESCEnergy2->Fill( aClus->energy() );
125  }
126 
127 
128  // Get ES clusters in X plane
129  Handle<reco::PreshowerClusterCollection> pPreshowerClustersX;
130  evt.getByLabel(preshClusterProducer_, preshClusterCollectionX_, pPreshowerClustersX);
131  const reco::PreshowerClusterCollection *clustersX = pPreshowerClustersX.product();
132  h1_nclu_x->Fill( clustersX->size() );
133  //std::cout << "\n pPreshowerClustersX->size() = " << clustersX->size() << std::endl;
134 
135  Handle<reco::PreshowerClusterCollection> pPreshowerClustersY;
136  evt.getByLabel(preshClusterProducer_, preshClusterCollectionY_, pPreshowerClustersY);
137  const reco::PreshowerClusterCollection *clustersY = pPreshowerClustersY.product();
138  h1_nclu_y->Fill( clustersY->size() );
139  //std::cout << "\n pPreshowerClustersY->size() = " << clustersY->size() << std::endl;
140 
141 
142  // loop over the ES clusters and fill the histogram
143  float e1 = 0;
144  for(reco::PreshowerClusterCollection::const_iterator esClus = clustersX->begin();
145  esClus !=clustersX->end(); esClus++) {
146  e1 += esClus->energy();
147  h1_esE_x->Fill( esClus->energy() );
148  h1_esEta_x->Fill( esClus->eta() );
149  h1_esPhi_x->Fill( esClus->phi() );
150  h1_esNhits_x->Fill( esClus->nhits() );
151  }
152 
153  float e2 = 0;
154  for(reco::PreshowerClusterCollection::const_iterator esClus = clustersY->begin();
155  esClus !=clustersY->end(); esClus++) {
156  e2 += esClus->energy();
157  h1_esE_y->Fill( esClus->energy() );
158  h1_esEta_y->Fill( esClus->eta() );
159  h1_esPhi_y->Fill( esClus->phi() );
160  h1_esNhits_y->Fill( esClus->nhits() );
161  }
162 
163  float deltaE = 0;
164  if(e1+e2 > 1.0e-10) {
165  // GeV to #MIPs
166  e1 = e1 / mip_;
167  e2 = e2 / mip_;
168  deltaE = gamma_*(calib_planeX_*e1+calib_planeY_*e2);
169  }
170 
171  h1_esDeltaE->Fill(deltaE);
172 
173  nEvt_++;
174 
175 }
176 
177 //========================================================================
179 //========================================================================
180 
181  rootFile_->cd();
182 
183  h1_esE_x->Write();
184  h1_esE_y->Write();
185  h1_esEta_x->Write();
186  h1_esEta_y->Write();
187  h1_esPhi_x->Write();
188  h1_esPhi_y->Write();
189  h1_esNhits_x->Write();
190  h1_esNhits_y->Write();
191  h1_esDeltaE->Write();
192  h1_nclu_x->Write();
193  h1_nclu_y->Write();
194 
195  h1_islandEESCEnergy1->Write();
196  h1_islandEESCEnergy2->Write();
197 
198  rootFile_->Close();
199 }
std::string preshClusterProducer_
T getParameter(std::string const &) const
std::string islandEndcapSuperClusterProducer2_
std::string preshClusterCollectionX_
std::string preshClusterCollectionY_
std::string islandEndcapSuperClusterCollection2_
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
std::string outputFile_
std::vector< PreshowerCluster > PreshowerClusterCollection
collection of PreshowerCluster objects
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
Float e1
Definition: deltaR.h:22
std::string islandEndcapSuperClusterCollection1_
virtual void endJob()
Float e2
Definition: deltaR.h:23
virtual void beginJob()
PreshowerAnalyzer(const edm::ParameterSet &)
std::string islandEndcapSuperClusterProducer1_
virtual void analyze(const edm::Event &, const edm::EventSetup &)