CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EERecoSummary.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: EERecoSummary
4 // Class: EERecoSummary
5 // Original Author: Martina Malberti
6 //
7 // system include files
8 #include <memory>
9 
10 // user include files
13 
18 
21 
30 
43 
46 
49 
54 
55 #include "TVector3.h"
56 
57 #include <iostream>
58 #include <cmath>
59 #include <fstream>
60 
61 //
62 // constructors and destructor
63 //
65 {
66 
67  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
68 
69  //now do what ever initialization is needed
70  recHitCollection_EE_ = consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("recHitCollection_EE"));
71  redRecHitCollection_EE_ = consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("redRecHitCollection_EE"));
72  basicClusterCollection_EE_ = consumes<edm::View<reco::CaloCluster> >(ps.getParameter<edm::InputTag>("basicClusterCollection_EE"));
73  superClusterCollection_EE_ = consumes<reco::SuperClusterCollection>(ps.getParameter<edm::InputTag>("superClusterCollection_EE"));
74 
75  ethrEE_ = ps.getParameter<double>("ethrEE");
76 
77  scEtThrEE_ = ps.getParameter<double>("scEtThrEE");
78 
79  // DQM Store -------------------
81 
82  // Monitor Elements (ex THXD)
83  dqmStore_->setCurrentFolder(prefixME_ + "/EERecoSummary"); // to organise the histos in folders
84 
85  // ReducedRecHits ----------------------------------------------
86  // ... endcap
87  h_redRecHits_EE_recoFlag = dqmStore_->book1D("redRecHits_EE_recoFlag","redRecHits_EE_recoFlag",16,-0.5,15.5);
88 
89  // RecHits ----------------------------------------------
90  // ... endcap
91  h_recHits_EE_recoFlag = dqmStore_->book1D("recHits_EE_recoFlag","recHits_EE_recoFlag",16,-0.5,15.5);
92 
93  // ... endcap +
94  h_recHits_EEP_energyMax = dqmStore_->book1D("recHits_EEP_energyMax","recHitsEEP_energyMax",110,-10,100);
95  h_recHits_EEP_Chi2 = dqmStore_->book1D("recHits_EEP_Chi2","recHits_EEP_Chi2",200,0,100);
96  h_recHits_EEP_time = dqmStore_->book1D("recHits_EEP_time","recHits_EEP_time",200,-50,50);
97 
98  // ... endcap -
99  h_recHits_EEM_energyMax = dqmStore_->book1D("recHits_EEM_energyMax","recHits_EEM_energyMax",110,-10,100);
100  h_recHits_EEM_Chi2 = dqmStore_->book1D("recHits_EEM_Chi2","recHits_EEM_Chi2",200,0,100);
101  h_recHits_EEM_time = dqmStore_->book1D("recHits_EEM_time","recHits_EEM_time",200,-50,50);
102 
103  // Basic Clusters ----------------------------------------------
104  // ... associated endcap rec hits
105  h_basicClusters_recHits_EE_recoFlag = dqmStore_->book1D("basicClusters_recHits_EE_recoFlag","basicClusters_recHits_EE_recoFlag",16,-0.5,15.5);
106 
107  // Super Clusters ----------------------------------------------
108  // ... endcap
109  h_superClusters_EEP_nBC = dqmStore_->book1D("superClusters_EEP_nBC","superClusters_EEP_nBC",100,0.,100.);
110  h_superClusters_EEM_nBC = dqmStore_->book1D("superClusters_EEM_nBC","superClusters_EEM_nBC",100,0.,100.);
111 
112  h_superClusters_eta = dqmStore_->book1D("superClusters_eta","superClusters_eta",150,-3.,3.);
113  h_superClusters_EE_phi = dqmStore_->book1D("superClusters_EE_phi","superClusters_EE_phi",360,-3.1415927,3.1415927);
114 
115 }
116 
117 
118 
120 {
121  // do anything here that needs to be done at desctruction time
122  // (e.g. close files, deallocate resources etc.)
123 }
124 
125 
126 //
127 // member functions
128 //
129 
130 // ------------ method called to for each event ------------
131 void EERecoSummary::analyze(const edm::Event& ev, const edm::EventSetup& iSetup)
132 {
133 
134  //Get the magnetic field
135  edm::ESHandle<MagneticField> theMagField;
136  iSetup.get<IdealMagneticFieldRecord>().get(theMagField);
137 
138  // --- REDUCED REC HITS -------------------------------------------------------------------------------------
139  // ... endcap
141  ev.getByToken( redRecHitCollection_EE_, redRecHitsEE );
142  const EcalRecHitCollection* theEndcapEcalredRecHits = redRecHitsEE.product () ;
143  if ( ! redRecHitsEE.isValid() ) {
144  edm::LogWarning("EERecoSummary") << "redRecHitsEE not found";
145  }
146 
147  for ( EcalRecHitCollection::const_iterator itr = theEndcapEcalredRecHits->begin () ;
148  itr != theEndcapEcalredRecHits->end () ; ++itr)
149  {
150 
151  EEDetId eeid( itr -> id() );
152 
153  h_redRecHits_EE_recoFlag->Fill( itr -> recoFlag() );
154 
155  }
156 
157  // --- REC HITS -------------------------------------------------------------------------------------
158 
159  // ... endcap
161  ev.getByToken( recHitCollection_EE_, recHitsEE );
162  const EcalRecHitCollection* theEndcapEcalRecHits = recHitsEE.product () ;
163  if ( ! recHitsEE.isValid() ) {
164  edm::LogWarning("EERecoSummary") << "recHitsEE not found";
165  }
166 
167  float maxRecHitEnergyEEP = -999.;
168  float maxRecHitEnergyEEM = -999.;
169 
170  EEDetId eeid_MrecHitEEM;
171  EEDetId eeid_MrecHitEEP;
172 
173  for ( EcalRecHitCollection::const_iterator itr = theEndcapEcalRecHits->begin () ;
174  itr != theEndcapEcalRecHits->end () ; ++itr)
175  {
176 
177  EEDetId eeid( itr -> id() );
178 
179  // EE+
180  if ( eeid.zside() > 0 ){
181 
182  h_recHits_EE_recoFlag -> Fill( itr -> recoFlag() );
183 
184  // max E rec hit
185  if (itr -> energy() > maxRecHitEnergyEEP &&
186  !(eeid.ix()>=41 && eeid.ix()<=60 && eeid.iy()>=41 && eeid.iy()<=60) ) {
187  maxRecHitEnergyEEP = itr -> energy() ;
188  }
189 
190  // only channels above noise
191  if ( itr -> energy() > ethrEE_ ){
192  h_recHits_EEP_Chi2 -> Fill( itr -> chi2() );
193  h_recHits_EEP_time -> Fill( itr -> time() );
194  }
195  }
196 
197  // EE-
198  if ( eeid.zside() < 0 ){
199 
200  h_recHits_EE_recoFlag -> Fill( itr -> recoFlag() );
201 
202  // max E rec hit
203  if (itr -> energy() > maxRecHitEnergyEEM &&
204  !(eeid.ix()>=41 && eeid.ix()<=60 && eeid.iy()>=41 && eeid.iy()<=60) ) {
205  maxRecHitEnergyEEM = itr -> energy() ;
206  }
207 
208  // only channels above noise
209  if ( itr -> energy() > ethrEE_ ) {
210  h_recHits_EEM_Chi2 -> Fill( itr -> chi2() );
211  h_recHits_EEM_time -> Fill( itr -> time() );
212  }
213 
214  }
215  } // end loop over EE rec hits
216 
217  // energy
218  h_recHits_EEP_energyMax -> Fill( maxRecHitEnergyEEP );
219  h_recHits_EEM_energyMax -> Fill( maxRecHitEnergyEEM );
220 
221  //--- BASIC CLUSTERS --------------------------------------------------------------
222 
223  // ... endcap
224  edm::Handle<edm::View<reco::CaloCluster> > basicClusters_EE_h;
225  if(ev.getByToken( basicClusterCollection_EE_, basicClusters_EE_h )){
226 
227  for (unsigned int icl = 0; icl < basicClusters_EE_h->size(); ++icl) {
228 
229  //Get the associated RecHits
230  const std::vector<std::pair<DetId,float> > & hits= (*basicClusters_EE_h)[icl].hitsAndFractions();
231  for (std::vector<std::pair<DetId,float> > ::const_iterator rh = hits.begin(); rh!=hits.end(); ++rh){
232 
233  EBRecHitCollection::const_iterator itrechit = theEndcapEcalRecHits->find((*rh).first);
234  if (itrechit==theEndcapEcalRecHits->end()) continue;
235  h_basicClusters_recHits_EE_recoFlag -> Fill ( itrechit -> recoFlag() );
236  }
237 
238  }
239  }
240  else{
241  // edm::LogWarning("EERecoSummary") << "basicClusters_EE_h not found";
242  }
243 
244  // Super Clusters
245  // ... endcap
247  ev.getByToken( superClusterCollection_EE_, superClusters_EE_h );
248  const reco::SuperClusterCollection* theEndcapSuperClusters = superClusters_EE_h.product () ;
249  if ( ! superClusters_EE_h.isValid() ) {
250  edm::LogWarning("EERecoSummary") << "superClusters_EE_h not found";
251  }
252 
253  for (reco::SuperClusterCollection::const_iterator itSC = theEndcapSuperClusters->begin();
254  itSC != theEndcapSuperClusters->end(); ++itSC ) {
255 
256  double scEt = itSC -> energy() * sin(2.*atan( exp(- itSC->position().eta() )));
257 
258  if (scEt < scEtThrEE_ ) continue;
259 
260  h_superClusters_eta -> Fill( itSC -> eta() );
261  h_superClusters_EE_phi -> Fill( itSC -> phi() );
262 
263  if ( itSC -> z() > 0 ){
264  h_superClusters_EEP_nBC -> Fill( itSC -> clustersSize() );
265  }
266 
267  if ( itSC -> z() < 0 ){
268  h_superClusters_EEM_nBC -> Fill( itSC -> clustersSize() );
269  }
270  }
271 
272  //--------------------------------------------------------
273 
274 }
275 
276 
277 // ------------ method called once each job just before starting event loop ------------
278 void
280 {
281 }
282 
283 // ------------ method called once each job just after ending the event loop ------------
284 void
286 {}
287 
288 
289 //define this as a plug-in
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
double scEtThrEE_
Definition: EERecoSummary.h:97
MonitorElement * h_redRecHits_EE_recoFlag
Definition: EERecoSummary.h:62
int ix() const
Definition: EEDetId.h:76
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void beginJob()
EERecoSummary(const edm::ParameterSet &)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::string prefixME_
Definition: EERecoSummary.h:56
std::vector< EcalRecHit >::const_iterator const_iterator
MonitorElement * h_basicClusters_recHits_EE_recoFlag
Definition: EERecoSummary.h:77
MonitorElement * h_recHits_EEM_Chi2
Definition: EERecoSummary.h:73
T eta() const
MonitorElement * h_recHits_EE_recoFlag
Definition: EERecoSummary.h:66
float float float z
edm::EDGetTokenT< EcalRecHitCollection > recHitCollection_EE_
Definition: EERecoSummary.h:90
MonitorElement * h_recHits_EEP_Chi2
Definition: EERecoSummary.h:69
void Fill(long long x)
MonitorElement * h_recHits_EEP_time
Definition: EERecoSummary.h:70
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
edm::EDGetTokenT< EcalRecHitCollection > redRecHitCollection_EE_
Definition: EERecoSummary.h:91
int zside() const
Definition: EEDetId.h:70
MonitorElement * h_superClusters_EEM_nBC
Definition: EERecoSummary.h:82
MonitorElement * h_recHits_EEM_energyMax
Definition: EERecoSummary.h:72
int iy() const
Definition: EEDetId.h:82
MonitorElement * h_superClusters_eta
Definition: EERecoSummary.h:84
bool isValid() const
Definition: HandleBase.h:76
MonitorElement * h_superClusters_EEP_nBC
Definition: EERecoSummary.h:81
MonitorElement * h_recHits_EEM_time
Definition: EERecoSummary.h:74
const_iterator end() const
DQMStore * dqmStore_
Definition: EERecoSummary.h:54
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: Handle.h:81
iterator find(key_type k)
edm::EDGetTokenT< reco::SuperClusterCollection > superClusterCollection_EE_
Definition: EERecoSummary.h:93
MonitorElement * h_recHits_EEP_energyMax
Definition: EERecoSummary.h:68
virtual void endJob()
edm::EDGetTokenT< edm::View< reco::CaloCluster > > basicClusterCollection_EE_
Definition: EERecoSummary.h:92
MonitorElement * h_superClusters_EE_phi
Definition: EERecoSummary.h:85
const_iterator begin() const
virtual void analyze(const edm::Event &, const edm::EventSetup &)
Definition: DDAxes.h:10