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