CMS 3D CMS Logo

EcalPileUpDepMonitor.cc
Go to the documentation of this file.
1 /*
2  * \file EcalPileUpDepMonitor.cc
3  * \author Ben Carlson - CMU
4  * Last Update:
5  *
6  */
7 
9 
16 
20 
22 
26 
28 
29 #include <cmath>
30 
31 // Framework
32 
34 {
35  VertexCollection_ = consumes<reco::VertexCollection>(ps.getParameter<edm::InputTag>("VertexCollection"));
36 
37  if(ps.existsAs<edm::InputTag>("basicClusterCollection") && !ps.getParameter<edm::InputTag>("basicClusterCollection").label().empty())
39  else{
40  basicClusterCollection_EE_ = consumes<edm::View<reco::CaloCluster> >(ps.getParameter<edm::InputTag>("basicClusterCollection_EE"));
41  basicClusterCollection_EB_ = consumes<edm::View<reco::CaloCluster> >(ps.getParameter<edm::InputTag>("basicClusterCollection_EB"));
42  }
43  superClusterCollection_EB_ = consumes<reco::SuperClusterCollection>(ps.getParameter<edm::InputTag>("superClusterCollection_EB"));
44  superClusterCollection_EE_ = consumes<reco::SuperClusterCollection>(ps.getParameter<edm::InputTag>("superClusterCollection_EE"));
45 
46  RecHitCollection_EB_ = consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("RecHitCollection_EB"));
47  RecHitCollection_EE_ = consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("RecHitCollection_EE"));
48  EleTag_ = consumes<reco::GsfElectronCollection>(ps.getParameter<edm::InputTag>("EleTag"));
49 }
50 
52 {
53 }
54 
56  edm::Run const&,
57  edm::EventSetup const& eventSetup)
58 {
59  eventSetup.get<CaloGeometryRecord>().get(geomH);
60  eventSetup.get<CaloTopologyRecord>().get(caloTop);
61 
62  ibooker.cd();
63  ibooker.setCurrentFolder("Ecal/EcalPileUpDepMonitor");
64 
65  std::string prof_name="bcEB_PV";
66  std::string title="Basic clusters EB vs. PV";
67  bcEB_PV=ibooker.bookProfile(prof_name,title,50,0.,50.,50,0.,350.);
68  bcEB_PV->setAxisTitle("N_{pv}",1);
69  bcEB_PV->setAxisTitle("Basic Clusters", 2);
70 
71  prof_name="bcEE_PV";
72  title="Basic Clusters EE vs. PV";
73  bcEE_PV=ibooker.bookProfile(prof_name,title,50,0.,50.,50,0.,350.);
74  bcEE_PV->setAxisTitle("N_{pv}",1);
75  bcEE_PV->setAxisTitle("Basic Clusters", 2);
76 
77  prof_name="scEB_PV";
78  title="Super Clusters EB vs. PV";
79  scEB_PV=ibooker.bookProfile(prof_name,title,50,0.,50.,50,0.,350.);
80  scEB_PV->setAxisTitle("N_{pv}",1);
81  scEB_PV->setAxisTitle("Super Clusters", 2);
82 
83  prof_name="scEE_PV";
84  title="Super Clusters EE vs. PV";
85  scEE_PV=ibooker.bookProfile(prof_name,title,50,0.,50.,50,0.,350.);
86  scEE_PV->setAxisTitle("N_{pv}",1);
87  scEE_PV->setAxisTitle("Super Clusters", 2);
88 
89  prof_name="scEtEB_PV";
90  title="Super Clusters Et EB vs. PV";
91  scEtEB_PV=ibooker.bookProfile(prof_name,title,50,0.,50.,50,0.,350.);
92  scEtEB_PV->setAxisTitle("N_{pv}",1);
93  scEtEB_PV->setAxisTitle("Super Cluster E_{T} [GeV]", 2);
94 
95 
96  prof_name="scEtEE_PV";
97  title="Super Clusters Et EE vs. PV";
98  scEtEE_PV=ibooker.bookProfile(prof_name,title,50,0.,50.,50,0.,350.);
99  scEtEE_PV->setAxisTitle("N_{pv}",1);
100  scEtEE_PV->setAxisTitle("Super Cluster E_{T} [GeV]", 2);
101 
102  prof_name="recHitEtEB_PV";
103  title="Reconstructed Hit Et EB vs. PV";
104  recHitEtEB_PV=ibooker.bookProfile(prof_name,title,50,0.,50.,50,0.,350.);
105  recHitEtEB_PV->setAxisTitle("N_{pv}",1);
106  recHitEtEB_PV->setAxisTitle("Reconstructed hit E_{T} [GeV]", 2);
107 
108  prof_name="recHitEtEE_PV";
109  title="Reconstructed Hit Et EE vs. PV";
110  recHitEtEE_PV=ibooker.bookProfile(prof_name,title,50,0.,50.,50,0.,350.);
111  recHitEtEE_PV->setAxisTitle("N_{pv}",1);
112  recHitEtEE_PV->setAxisTitle("Reconstructed hit E_{T} [GeV]", 2);
113 
114  prof_name="emIso_PV";
115  title="EM Isolation vs. PV";
116  emIso_PV=ibooker.bookProfile(prof_name,title,50,0.,50.,50,0.,350);
117  emIso_PV->setAxisTitle("N_{pv}",1);
118  emIso_PV->setAxisTitle("EM_{Isolation} [GeV]", 2);
119 
120  prof_name="emIso";
121  title="EM Isolation";
122  emIso=ibooker.book1D(prof_name,title,50,0,50);
123  emIso->setAxisTitle("EM_{Isolation} [GeV]",1);
124  emIso->setAxisTitle("Events",2);
125 
126  prof_name="scHitEtEB";
127  title="Super Cluster Hit Et EB";
128  scHitEtEB=ibooker.book1D(prof_name,title,50,0,100);
129  scHitEtEB->setAxisTitle("super cluster hit E_{T} [GeV]",1);
130  scHitEtEB->setAxisTitle("Events",2);
131 
132  prof_name="scHitEtEE";
133  title="Super Cluster Hit Et EE";
134  scHitEtEE=ibooker.book1D(prof_name,title,50,0,100);
135  scHitEtEE->setAxisTitle("super cluster hit E_{T} [GeV]",1);
136  scHitEtEE->setAxisTitle("Events",2);
137 
138 
139 // prof_name="scHitE_EB";
140 // title="Super Cluster Hit E EB";
141 // scHitE_EB=ibooker.book1D(prof_name,title,50,0,100);
142 // scHitE_EB->setAxisTitle("super cluster hit E [GeV]",1);
143 // scHitE_EB->setAxisTitle("Events",2);
144 
145 
146 // prof_name="scHitE_EE";
147 // title="Super Cluster Hit E EE";
148 // scHitE_EE=ibooker.book1D(prof_name,title,50,0,100);
149 // scHitE_EE->setAxisTitle("super cluster hit E [GeV]",1);
150 // scHitE_EE->setAxisTitle("Events",2);
151 
152  //SC eta
153 // prof_name="scEta_EB";
154 // title="Super Cluster #eta EB";
155 // scEta_EB=ibooker.book1D(prof_name,title,50,-6,6);
156 // scEta_EB->setAxisTitle("#eta",1);
157 // scEta_EB->setAxisTitle("Events",2);
158 
159 // prof_name="scEta_EE";
160 // title="Super Cluster #eta EE";
161 // scEta_EE=ibooker.book1D(prof_name,title,50,-6,6);
162 // scEta_EE->setAxisTitle("#eta",1);
163 // scEta_EE->setAxisTitle("Events",2);
164 
165  //SC phi
166 // prof_name="scPhi_EB";
167 // title="Super Cluster #phi EB";
168 // scPhi_EB=ibooker.book1D(prof_name,title,50,-3.14,3.14);
169 // scPhi_EB->setAxisTitle("super cluster #phi",1);
170 // scPhi_EB->setAxisTitle("Events",2);
171 
172 // prof_name="scPhi_EE";
173 // title="Super Cluster #phi EE";
174 // scPhi_EE=ibooker.book1D(prof_name,title,50,-3.14,3.14);
175 // scPhi_EE->setAxisTitle("super cluster #phi",1);
176 // scPhi_EE->setAxisTitle("Events",2);
177 
178  //sc sigma eta eta / eta phi
179 
180  prof_name="scSigmaIetaIeta_EB";
181  title="Super Cluster sigmaIetaIeta EB";
182  scSigmaIetaIeta_EB=ibooker.book1D(prof_name,title,50,0,0.03);
183  scSigmaIetaIeta_EB->setAxisTitle("#sigma_{i#etai#eta}",1);
184  scSigmaIetaIeta_EB->setAxisTitle("Events",2);
185 
186  prof_name="scSigmaIetaIeta_EE";
187  title="Super Cluster sigmaIetaIeta EE";
188  scSigmaIetaIeta_EE=ibooker.book1D(prof_name,title,50,0,0.1);
189  scSigmaIetaIeta_EE->setAxisTitle("#sigma_{i#etai#eta}",1);
190  scSigmaIetaIeta_EE->setAxisTitle("Events",2);
191 
192  //phi
193  prof_name="scSigmaIetaIphi_EB";
194  title="Super Cluster sigmaIetaIphi EB";
195  scSigmaIetaIphi_EB=ibooker.book1D(prof_name,title,50,-5.e-4,5.e-4);
196  scSigmaIetaIphi_EB->setAxisTitle("#sigma_{i#etai#phi}",1);
197  scSigmaIetaIphi_EB->setAxisTitle("Events",2);
198 
199  prof_name="scSigmaIetaIphi_EE";
200  title="Super Cluster sigmaIetaIphi EE";
201  scSigmaIetaIphi_EE=ibooker.book1D(prof_name,title,50,-2.5e-3,2.5e-3);
202  scSigmaIetaIphi_EE->setAxisTitle("#sigma_{i#etai#phi}",1);
203  scSigmaIetaIphi_EE->setAxisTitle("Events",2);
204 
205  //R9
206  prof_name="r9_EB";
207  title="r9 EB";
208  r9_EB=ibooker.book1D(prof_name,title,50,0,1.5);
209  r9_EB->setAxisTitle("R_{9}",1);
210  r9_EB->setAxisTitle("Events",2);
211 
212  prof_name="r9_EE";
213  title="r9 EE";
214  r9_EE=ibooker.book1D(prof_name,title,50,0,1.5);
215  r9_EE->setAxisTitle("R_{9}",1);
216  r9_EE->setAxisTitle("Events",2);
217 
218  //Rec Hit
219 
220  prof_name="recHitEtEB";
221  title="RecHit Et EB";
222  recHitEtEB=ibooker.book1D(prof_name,title,50,0,400);
223  recHitEtEB->setAxisTitle("Reconstructed Hit E_{T} [GeV]",1);
224  recHitEtEB->setAxisTitle("Events",2);
225 
226  prof_name="recHitEtEE";
227  title="RecHit Et EE";
228  recHitEtEE=ibooker.book1D(prof_name,title,50,0,400);
229  recHitEtEE->setAxisTitle("Reconstructed Hit E_{T} [GeV]",1);
230  recHitEtEE->setAxisTitle("Events",2);
231 }
232 
234 {
235 
236  const CaloGeometry* geom = geomH.product();
237  //Vertex collection:
238  //-----------------------------------------
240  e.getByToken(VertexCollection_,PVCollection_h);
241  if ( ! PVCollection_h.isValid() ) {
242  edm::LogWarning("VertexCollection") << "VertexCollection not found";
243  }
244  //-----------------gsfElectrons -------------------------
245  edm::Handle<reco::GsfElectronCollection> electronCollection_h;
246  e.getByToken(EleTag_, electronCollection_h);
247  if( !electronCollection_h.isValid()){
248  edm::LogWarning("EBRecoSummary") << "Electrons not found";
249  }
250 
252  //----------------- Basic Cluster Collection Ecal Barrel ---------
253  edm::Handle<edm::View<reco::CaloCluster> > basicClusters_EB_h;
254  e.getByToken( basicClusterCollection_EB_, basicClusters_EB_h );
255  if ( ! basicClusters_EB_h.isValid() ) {
256  edm::LogWarning("EBRecoSummary") << "basicClusters_EB_h not found";
257  }
258 
259  bcEB_PV->Fill(PVCollection_h->size(), basicClusters_EB_h->size());
260 
261  //----------------- Basic Cluster Collection Ecal Endcal ---------
262 
263  edm::Handle<edm::View<reco::CaloCluster> > basicClusters_EE_h;
264  e.getByToken( basicClusterCollection_EE_, basicClusters_EE_h );
265  if ( ! basicClusters_EE_h.isValid() ) {
266  edm::LogWarning("EERecoSummary") << "basicClusters_EE_h not found";
267  }
268 
269  bcEE_PV->Fill(PVCollection_h->size(), basicClusters_EE_h->size());
270  }
271  else{
272  //----------------- Basic Cluster Collection Ecal Barrel ---------
274  e.getByToken( basicClusterCollection_, basicClusters_h );
275  if ( ! basicClusters_h.isValid() ) {
276  edm::LogWarning("EBRecoSummary") << "basicClusters_h not found";
277  }
278 
279  int nBarrel(0);
280  int nEndcap(0);
281  for(edm::View<reco::CaloCluster>::const_iterator bcItr(basicClusters_h->begin()); bcItr != basicClusters_h->end(); ++bcItr){
282  if(bcItr->caloID().detector(reco::CaloID::DET_ECAL_BARREL)) ++nBarrel;
283  if(bcItr->caloID().detector(reco::CaloID::DET_ECAL_ENDCAP)) ++nEndcap;
284  }
285 
286  bcEB_PV->Fill(PVCollection_h->size(), nBarrel);
287  bcEE_PV->Fill(PVCollection_h->size(), nEndcap);
288  }
289 
290  //----------------- Reconstructed Hit Ecal barrel
291 
293  e.getByToken( RecHitCollection_EB_,RecHitsEB );
294  if ( ! RecHitsEB.isValid() ) {
295  edm::LogWarning("EBRecoSummary") << "RecHitsEB not found";
296  }
297 
298  //----------------- Reconstructed Hit Ecal Endcap
299 
301  e.getByToken( RecHitCollection_EE_, RecHitsEE );
302  if ( ! RecHitsEE.isValid() ) {
303  edm::LogWarning("EBRecoSummary") << "RecHitsEB not found";
304  }
305  //----------------- Super Cluster Collection Ecal Endcap ---------
306 
308  e.getByToken( superClusterCollection_EE_, superClusters_EE_h );
309  if ( ! superClusters_EE_h.isValid() ) {
310  edm::LogWarning("EERecoSummary") << "superClusters_EE_h not found";
311  }
312 
313  //--------- Fill Isolation -----------------
314 
315  if(electronCollection_h.isValid()){
316  for (reco::GsfElectronCollection::const_iterator recoElectron = electronCollection_h->begin ();
317  recoElectron != electronCollection_h->end ();
318  recoElectron++) {
319  double IsoEcal =recoElectron->dr03EcalRecHitSumEt();
320  emIso_PV->Fill(PVCollection_h->size(),IsoEcal);
321  emIso->Fill(IsoEcal);
322  }
323  }
324 
325  //fill super clusters EE
326  scEE_PV->Fill(PVCollection_h->size(), superClusters_EE_h->size());
327 
328  for (reco::SuperClusterCollection::const_iterator itSC = superClusters_EE_h->begin();
329  itSC != superClusters_EE_h->end();
330  ++itSC ) {
331  double scEE_Et= itSC -> energy() * sin(2.*atan( exp(- itSC->position().eta() )));
332  // double scEE_E=itSC->energy();
333 
334  //fill super cluster endcap eta/phi
335 // scEta_EE->Fill(itSC->position().eta());
336 // scPhi_EE->Fill(itSC->position().phi());
337 
338  //get sigma eta_eta etc
339 
340  CaloTopology const* p_topology = caloTop.product();//get calo topology
341  const EcalRecHitCollection* eeRecHits = RecHitsEE.product();
342 
343  reco::BasicCluster const& seedCluster(*itSC->seed());
344  std::vector<float> cov = EcalClusterTools::localCovariances(seedCluster, eeRecHits, p_topology);
345  float sigmaIetaIeta = std::sqrt(cov[0]);
346  float sigmaIetaIphi = cov[1];
347 
348 
349  float e3x3 = EcalClusterTools::e3x3(seedCluster, eeRecHits, p_topology);
350  float r9 = e3x3 / itSC->rawEnergy();
351 
352  r9_EE->Fill(r9);
353  scSigmaIetaIeta_EE->Fill(sigmaIetaIeta);
354  scSigmaIetaIphi_EE->Fill(sigmaIetaIphi);
355 
356  //std::cout << " sigmaIetaIeta: " << sigmaIetaIeta << std::endl;
357  scEtEE_PV->Fill(PVCollection_h->size(),scEE_Et);
358  scHitEtEE->Fill(scEE_Et); //super cluster Et historam
359  // scHitE_EE->Fill(scEE_E); //super cluster energy histogram
360 
361  }//sc-EE loop
362 
363 
364  //----------------- Super Cluster Collection Ecal Barrel ---------
365 
367  e.getByToken( superClusterCollection_EB_, superClusters_EB_h );
368  if ( ! superClusters_EB_h.isValid() ) {
369  edm::LogWarning("EBRecoSummary") << "superClusters_EB_h not found";
370  }
371  scEB_PV->Fill(PVCollection_h->size(), superClusters_EB_h->size());
372 
373  for (reco::SuperClusterCollection::const_iterator itSC = superClusters_EB_h->begin();
374  itSC != superClusters_EB_h->end();
375  ++itSC ) {
376  double scEB_Et= itSC -> energy() * sin(2.*atan( exp(- itSC->position().eta() ))); // super cluster transverse energy
377  // double scEB_E= itSC->energy(); // super cluster energy
378 
379  //fill super cluster Barrel eta/phi
380 // scEta_EB->Fill(itSC->position().eta()); //super cluster eta
381 // scPhi_EB->Fill(itSC->position().phi()); // super cluster phi
382 
383  //sigma ietaieta etc
384 
385  CaloTopology const* p_topology = caloTop.product();//get calo topology
386  const EcalRecHitCollection* ebRecHits = RecHitsEB.product();
387 
388  reco::BasicCluster const& seedCluster(*itSC->seed());
389  std::vector<float> cov = EcalClusterTools::localCovariances(seedCluster, ebRecHits, p_topology);
390  float sigmaIetaIeta = std::sqrt(cov[0]);
391  float sigmaIetaIphi = cov[1];
392 
393 
394  float e3x3 = EcalClusterTools::e3x3(seedCluster, ebRecHits, p_topology);
395  float r9 = e3x3 / itSC->rawEnergy();
396 
397  r9_EB->Fill(r9);
398  scSigmaIetaIeta_EB->Fill(sigmaIetaIeta);
399  scSigmaIetaIphi_EB->Fill(sigmaIetaIphi);
400 
401  scEtEB_PV->Fill(PVCollection_h->size(),scEB_Et);
402  scHitEtEB->Fill(scEB_Et);
403  // scHitE_EB->Fill(scEB_E);
404  }//sc-EB loop
405 
406 
407  //-------------------Compute scalar sum of reconstructed hit Et
408  double RecHitEt_EB=0;
409 
410  for ( EcalRecHitCollection::const_iterator itr = RecHitsEB->begin () ;
411  itr != RecHitsEB->end () ;
412  ++itr) {
413  //RecHitEt_EB +=itr->energy();
414 
415  GlobalPoint const& position = geom->getGeometry(itr->detid())->getPosition();
416  RecHitEt_EB += itr -> energy() * sin(position.theta()) ;
417  }//EB Rec Hit
418 
419  recHitEtEB->Fill(RecHitEt_EB);
420  recHitEtEB_PV->Fill(PVCollection_h->size(),RecHitEt_EB);
421 
422 
423  //-------------------Compute scalar sum of reconstructed hit Et
424  double RecHitEt_EE=0;
425 
426  for ( EcalRecHitCollection::const_iterator itr = RecHitsEE->begin () ;
427  itr != RecHitsEE->end () ;
428  ++itr) {
429  GlobalPoint const& position = geom->getGeometry(itr->detid())->getPosition();
430  RecHitEt_EE += itr -> energy() * sin(position.theta()) ;
431  }//EB Rec Hit
432 
433  recHitEtEE->Fill(RecHitEt_EE);
434  recHitEtEE_PV->Fill(PVCollection_h->size(),RecHitEt_EE);
435 }
436 
438 
MonitorElement * recHitEtEE_PV
MonitorElement * recHitEtEB
~EcalPileUpDepMonitor() override
Destructor.
T getParameter(std::string const &) const
MonitorElement * scEtEB_PV
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:186
edm::EDGetTokenT< reco::GsfElectronCollection > EleTag_
edm::EDGetTokenT< edm::View< reco::CaloCluster > > basicClusterCollection_
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:160
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
MonitorElement * scHitEtEE
edm::EDGetTokenT< EcalRecHitCollection > RecHitCollection_EE_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
MonitorElement * scSigmaIetaIphi_EB
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
MonitorElement * recHitEtEE
std::vector< EcalRecHit >::const_iterator const_iterator
edm::EDGetTokenT< EcalRecHitCollection > RecHitCollection_EB_
edm::EDGetTokenT< reco::VertexCollection > VertexCollection_
edm::EDGetTokenT< edm::View< reco::CaloCluster > > basicClusterCollection_EB_
edm::ESHandle< CaloTopology > caloTop
MonitorElement * scEB_PV
MonitorElement * scHitEtEB
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
void Fill(long long x)
edm::EDGetTokenT< reco::SuperClusterCollection > superClusterCollection_EB_
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
MonitorElement * bcEE_PV
void analyze(const edm::Event &, const edm::EventSetup &) override
Analyze.
MonitorElement * emIso_PV
EcalPileUpDepMonitor(const edm::ParameterSet &ps)
Constructor.
T sqrt(T t)
Definition: SSEVec.h:18
MonitorElement * recHitEtEB_PV
MonitorElement * scSigmaIetaIphi_EE
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:118
MonitorElement * scEE_PV
bool isValid() const
Definition: HandleBase.h:74
const_iterator end() const
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
T const * product() const
Definition: Handle.h:81
MonitorElement * scSigmaIetaIeta_EE
edm::ESHandle< CaloGeometry > geomH
MonitorElement * bcEB_PV
std::string const & label() const
Definition: InputTag.h:36
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
MonitorElement * scEtEE_PV
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
static int position[264][3]
Definition: ReadPGInfo.cc:509
T get() const
Definition: EventSetup.h:63
MonitorElement * scSigmaIetaIeta_EB
std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id.
Definition: CaloGeometry.cc:85
bool isUninitialized() const
Definition: EDGetToken.h:73
edm::EDGetTokenT< reco::SuperClusterCollection > superClusterCollection_EE_
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
T const * product() const
Definition: ESHandle.h:86
const_iterator begin() const
edm::EDGetTokenT< edm::View< reco::CaloCluster > > basicClusterCollection_EE_
Definition: Run.h:44