CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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() != "")
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  //Vertex collection:
236  //-----------------------------------------
238  e.getByToken(VertexCollection_,PVCollection_h);
239  if ( ! PVCollection_h.isValid() ) {
240  edm::LogWarning("VertexCollection") << "VertexCollection not found";
241  }
242  //-----------------gsfElectrons -------------------------
243  edm::Handle<reco::GsfElectronCollection> electronCollection_h;
244  e.getByToken(EleTag_, electronCollection_h);
245  if( !electronCollection_h.isValid()){
246  edm::LogWarning("EBRecoSummary") << "Electrons not found";
247  }
248 
250  //----------------- Basic Cluster Collection Ecal Barrel ---------
251  edm::Handle<edm::View<reco::CaloCluster> > basicClusters_EB_h;
252  e.getByToken( basicClusterCollection_EB_, basicClusters_EB_h );
253  if ( ! basicClusters_EB_h.isValid() ) {
254  edm::LogWarning("EBRecoSummary") << "basicClusters_EB_h not found";
255  }
256 
257  bcEB_PV->Fill(PVCollection_h->size(), basicClusters_EB_h->size());
258 
259  //----------------- Basic Cluster Collection Ecal Endcal ---------
260 
261  edm::Handle<edm::View<reco::CaloCluster> > basicClusters_EE_h;
262  e.getByToken( basicClusterCollection_EE_, basicClusters_EE_h );
263  if ( ! basicClusters_EE_h.isValid() ) {
264  edm::LogWarning("EERecoSummary") << "basicClusters_EE_h not found";
265  }
266 
267  bcEE_PV->Fill(PVCollection_h->size(), basicClusters_EE_h->size());
268  }
269  else{
270  //----------------- Basic Cluster Collection Ecal Barrel ---------
272  e.getByToken( basicClusterCollection_, basicClusters_h );
273  if ( ! basicClusters_h.isValid() ) {
274  edm::LogWarning("EBRecoSummary") << "basicClusters_h not found";
275  }
276 
277  int nBarrel(0);
278  int nEndcap(0);
279  for(edm::View<reco::CaloCluster>::const_iterator bcItr(basicClusters_h->begin()); bcItr != basicClusters_h->end(); ++bcItr){
280  if(bcItr->caloID().detector(reco::CaloID::DET_ECAL_BARREL)) ++nBarrel;
281  if(bcItr->caloID().detector(reco::CaloID::DET_ECAL_ENDCAP)) ++nEndcap;
282  }
283 
284  bcEB_PV->Fill(PVCollection_h->size(), nBarrel);
285  bcEE_PV->Fill(PVCollection_h->size(), nEndcap);
286  }
287 
288  //----------------- Reconstructed Hit Ecal barrel
289 
291  e.getByToken( RecHitCollection_EB_,RecHitsEB );
292  if ( ! RecHitsEB.isValid() ) {
293  edm::LogWarning("EBRecoSummary") << "RecHitsEB not found";
294  }
295 
296  //----------------- Reconstructed Hit Ecal Endcap
297 
299  e.getByToken( RecHitCollection_EE_, RecHitsEE );
300  if ( ! RecHitsEE.isValid() ) {
301  edm::LogWarning("EBRecoSummary") << "RecHitsEB not found";
302  }
303  //----------------- Super Cluster Collection Ecal Endcap ---------
304 
306  e.getByToken( superClusterCollection_EE_, superClusters_EE_h );
307  if ( ! superClusters_EE_h.isValid() ) {
308  edm::LogWarning("EERecoSummary") << "superClusters_EE_h not found";
309  }
310 
311  //--------- Fill Isolation -----------------
312 
313  if(electronCollection_h.isValid()){
314  for (reco::GsfElectronCollection::const_iterator recoElectron = electronCollection_h->begin ();
315  recoElectron != electronCollection_h->end ();
316  recoElectron++) {
317  double IsoEcal =recoElectron->dr03EcalRecHitSumEt();
318  emIso_PV->Fill(PVCollection_h->size(),IsoEcal);
319  emIso->Fill(IsoEcal);
320  }
321  }
322 
323  //fill super clusters EE
324  scEE_PV->Fill(PVCollection_h->size(), superClusters_EE_h->size());
325 
326  for (reco::SuperClusterCollection::const_iterator itSC = superClusters_EE_h->begin();
327  itSC != superClusters_EE_h->end();
328  ++itSC ) {
329  double scEE_Et= itSC -> energy() * sin(2.*atan( exp(- itSC->position().eta() )));
330  // double scEE_E=itSC->energy();
331 
332  //fill super cluster endcap eta/phi
333 // scEta_EE->Fill(itSC->position().eta());
334 // scPhi_EE->Fill(itSC->position().phi());
335 
336  //get sigma eta_eta etc
337 
338  CaloTopology const* p_topology = caloTop.product();//get calo topology
339  const EcalRecHitCollection* eeRecHits = RecHitsEE.product();
340 
341  reco::BasicCluster const& seedCluster(*itSC->seed());
342  std::vector<float> cov = EcalClusterTools::localCovariances(seedCluster, eeRecHits, p_topology);
343  float sigmaIetaIeta = std::sqrt(cov[0]);
344  float sigmaIetaIphi = cov[1];
345 
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 
362  //----------------- Super Cluster Collection Ecal Barrel ---------
363 
365  e.getByToken( superClusterCollection_EB_, superClusters_EB_h );
366  if ( ! superClusters_EB_h.isValid() ) {
367  edm::LogWarning("EBRecoSummary") << "superClusters_EB_h not found";
368  }
369  scEB_PV->Fill(PVCollection_h->size(), superClusters_EB_h->size());
370 
371  for (reco::SuperClusterCollection::const_iterator itSC = superClusters_EB_h->begin();
372  itSC != superClusters_EB_h->end();
373  ++itSC ) {
374  double scEB_Et= itSC -> energy() * sin(2.*atan( exp(- itSC->position().eta() ))); // super cluster transverse energy
375  // double scEB_E= itSC->energy(); // super cluster energy
376 
377  //fill super cluster Barrel eta/phi
378 // scEta_EB->Fill(itSC->position().eta()); //super cluster eta
379 // scPhi_EB->Fill(itSC->position().phi()); // super cluster phi
380 
381  //sigma ietaieta etc
382 
383  CaloTopology const* p_topology = caloTop.product();//get calo topology
384  const EcalRecHitCollection* ebRecHits = RecHitsEB.product();
385 
386  reco::BasicCluster const& seedCluster(*itSC->seed());
387  std::vector<float> cov = EcalClusterTools::localCovariances(seedCluster, ebRecHits, p_topology);
388  float sigmaIetaIeta = std::sqrt(cov[0]);
389  float sigmaIetaIphi = cov[1];
390 
391 
392  float e3x3 = EcalClusterTools::e3x3(seedCluster, ebRecHits, p_topology);
393  float r9 = e3x3 / itSC->rawEnergy();
394 
395  r9_EB->Fill(r9);
396  scSigmaIetaIeta_EB->Fill(sigmaIetaIeta);
397  scSigmaIetaIphi_EB->Fill(sigmaIetaIphi);
398 
399  scEtEB_PV->Fill(PVCollection_h->size(),scEB_Et);
400  scHitEtEB->Fill(scEB_Et);
401  // scHitE_EB->Fill(scEB_E);
402  }//sc-EB loop
403 
404 
405  //-------------------Compute scalar sum of reconstructed hit Et
406  double RecHitEt_EB=0;
407 
408  for ( EcalRecHitCollection::const_iterator itr = RecHitsEB->begin () ;
409  itr != RecHitsEB->end () ;
410  ++itr) {
411  //RecHitEt_EB +=itr->energy();
412 
413  GlobalPoint const& position = geomH->getGeometry(itr->detid())->getPosition();
414  RecHitEt_EB += itr -> energy() * sin(position.theta()) ;
415  }//EB Rec Hit
416 
417  recHitEtEB->Fill(RecHitEt_EB);
418  recHitEtEB_PV->Fill(PVCollection_h->size(),RecHitEt_EB);
419 
420 
421  //-------------------Compute scalar sum of reconstructed hit Et
422  double RecHitEt_EE=0;
423 
424  for ( EcalRecHitCollection::const_iterator itr = RecHitsEE->begin () ;
425  itr != RecHitsEE->end () ;
426  ++itr) {
427  GlobalPoint const& position = geomH->getGeometry(itr->detid())->getPosition();
428  RecHitEt_EE += itr -> energy() * sin(position.theta()) ;
429  }//EB Rec Hit
430 
431  recHitEtEE->Fill(RecHitEt_EE);
432  recHitEtEE_PV->Fill(PVCollection_h->size(),RecHitEt_EE);
433 }
434 
435 void
437 {
438 }
439 
441 
MonitorElement * recHitEtEE_PV
MonitorElement * recHitEtEB
T getParameter(std::string const &) const
void endLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) override
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:157
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
MonitorElement * scHitEtEE
edm::EDGetTokenT< EcalRecHitCollection > RecHitCollection_EE_
void cd(void)
Definition: DQMStore.cc:265
#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
virtual ~EcalPileUpDepMonitor()
Destructor.
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:115
MonitorElement * scEE_PV
bool isValid() const
Definition: HandleBase.h:75
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:273
T const * product() const
Definition: Handle.h:81
const T & get() const
Definition: EventSetup.h:56
MonitorElement * scSigmaIetaIeta_EE
T const * product() const
Definition: ESHandle.h:86
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:81
static int position[264][3]
Definition: ReadPGInfo.cc:509
MonitorElement * scSigmaIetaIeta_EB
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)
edm::EDGetTokenT< edm::View< reco::CaloCluster > > basicClusterCollection_EE_
Definition: Run.h:43