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