CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ESRecoSummary.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: ESRecoSummary
4 // Class: ESRecoSummary
5 // Original Author: Martina Malberti
6 //
7 // system include files
8 #include <memory>
9 
10 // user include files
13 
18 
22 
23 
32 
48 
51 
54 
59 
60 #include "TVector3.h"
61 
62 #include <iostream>
63 #include <cmath>
64 #include <fstream>
65 
66 //
67 // constructors and destructor
68 //
70 {
71 
72  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
73 
74  //now do what ever initialization is needed
75  esRecHitCollection_ = ps.getParameter<edm::InputTag>("recHitCollection_ES");
76  esClusterCollectionX_ = ps.getParameter<edm::InputTag>("ClusterCollectionX_ES");
77  esClusterCollectionY_ = ps.getParameter<edm::InputTag>("ClusterCollectionY_ES");
78 
80 
81  // Monitor Elements (ex THXD)
82  dqmStore_->setCurrentFolder(prefixME_ + "/ESRecoSummary"); // to organise the histos in folders
83 
84  superClusterCollection_EE_ = ps.getParameter<edm::InputTag>("superClusterCollection_EE");
85 
86  // Preshower ----------------------------------------------
87  h_recHits_ES_energyMax = dqmStore_->book1D("recHits_ES_energyMax","recHits_ES_energyMax",200,0.,0.01);
88  h_recHits_ES_time = dqmStore_->book1D("recHits_ES_time","recHits_ES_time",200,-100.,100.);
89 
90  h_esClusters_energy_plane1 = dqmStore_->book1D("esClusters_energy_plane1","esClusters_energy_plane1",200,0.,0.01);
91  h_esClusters_energy_plane2 = dqmStore_->book1D("esClusters_energy_plane2","esClusters_energy_plane2",200,0.,0.01);
92  h_esClusters_energy_ratio = dqmStore_->book1D("esClusters_energy_ratio","esClusters_energy_ratio",200,0.,20.);
93 
94 }
95 
96 
97 
99 {
100  // do anything here that needs to be done at desctruction time
101  // (e.g. close files, deallocate resources etc.)
102 }
103 
104 
105 //
106 // member functions
107 //
108 
109 // ------------ method called to for each event ------------
110 void ESRecoSummary::analyze(const edm::Event& ev, const edm::EventSetup& iSetup)
111 {
112 
113  //Get the magnetic field
114  edm::ESHandle<MagneticField> theMagField;
115  iSetup.get<IdealMagneticFieldRecord>().get(theMagField);
116 
117  //Preshower RecHits
119  ev.getByLabel (esRecHitCollection_, recHitsES) ;
120  const ESRecHitCollection* thePreShowerRecHits = recHitsES.product () ;
121 
122  if ( ! recHitsES.isValid() ) {
123  std::cerr << "ESRecoSummary::analyze --> recHitsES not found" << std::endl;
124  }
125 
126  float maxRecHitEnergyES = -999.;
127 
128  for (ESRecHitCollection::const_iterator esItr = thePreShowerRecHits->begin(); esItr != thePreShowerRecHits->end(); ++esItr)
129  {
130 
131  h_recHits_ES_time -> Fill(esItr->time());
132  if (esItr -> energy() > maxRecHitEnergyES ) maxRecHitEnergyES = esItr -> energy() ;
133 
134  } // end loop over ES rec Hits
135 
136  h_recHits_ES_energyMax -> Fill(maxRecHitEnergyES );
137 
138  // ES clusters in X plane
140  ev.getByLabel( esClusterCollectionX_, esClustersX);
141  const reco::PreshowerClusterCollection *ESclustersX = esClustersX.product();
142 
143  // ES clusters in Y plane
145  ev.getByLabel( esClusterCollectionY_, esClustersY);
146  const reco::PreshowerClusterCollection *ESclustersY = esClustersY.product();
147 
148 
149  // ... endcap
151  ev.getByLabel( superClusterCollection_EE_, superClusters_EE_h );
152  const reco::SuperClusterCollection* theEndcapSuperClusters = superClusters_EE_h.product () ;
153  if ( ! superClusters_EE_h.isValid() ) {
154  std::cerr << "EcalRecHitSummary::analyze --> superClusters_EE_h not found" << std::endl;
155  }
156 
157  // loop over all super clusters
158  for (reco::SuperClusterCollection::const_iterator itSC = theEndcapSuperClusters->begin();
159  itSC != theEndcapSuperClusters->end(); ++itSC ) {
160 
161  if ( fabs(itSC->eta()) < 1.65 || fabs(itSC->eta()) > 2.6 ) continue;
162 
163  // Loop over all ECAL Basic clusters in the supercluster
164  for (reco::CaloCluster_iterator ecalBasicCluster = itSC->clustersBegin(); ecalBasicCluster!= itSC->clustersEnd();
165  ecalBasicCluster++) {
166  const reco::CaloClusterPtr ecalBasicClusterPtr = *(ecalBasicCluster);
167 
168  float ESenergyPlane1 = -999.;
169  float ESenergyPlane2 = -999.;
170 
171  for (reco::PreshowerClusterCollection::const_iterator iESClus = ESclustersX->begin(); iESClus != ESclustersX->end();
172  ++iESClus) {
173  const reco::CaloClusterPtr preshBasicCluster = iESClus->basicCluster();
174  const reco::PreshowerCluster *esCluster = &*iESClus;
175  if (preshBasicCluster == ecalBasicClusterPtr) {
176  ESenergyPlane1 = esCluster->energy();
177  h_esClusters_energy_plane1 ->Fill(esCluster->energy());
178  }
179  } // end of x loop
180 
181  for (reco::PreshowerClusterCollection::const_iterator iESClus = ESclustersY->begin(); iESClus != ESclustersY->end();
182  ++iESClus) {
183  const reco::CaloClusterPtr preshBasicCluster = iESClus->basicCluster();
184  const reco::PreshowerCluster *esCluster = &*iESClus;
185  if (preshBasicCluster == ecalBasicClusterPtr) {
186  ESenergyPlane2 = esCluster->energy();
187  h_esClusters_energy_plane2 -> Fill(esCluster->energy());
188  }
189  } // end of y loop
190 
191  if ( ESenergyPlane1 != -999. && ESenergyPlane2 != -999. )
192  h_esClusters_energy_ratio -> Fill(ESenergyPlane1/ESenergyPlane2);
193 
194 
195  } // end loop over all basic clusters in the supercluster
196  }// end loop over superclusters
197 
198 }
199 
200 
201 // ------------ method called once each job just before starting event loop ------------
202  void
204 {
205 }
206 
207 // ------------ method called once each job just after ending the event loop ------------
208 void
210 {}
211 
212 //define this as a plug-in
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< EcalRecHit >::const_iterator const_iterator
DQMStore * dqmStore_
Definition: ESRecoSummary.h:55
MonitorElement * h_esClusters_energy_plane1
Definition: ESRecoSummary.h:63
MonitorElement * h_recHits_ES_time
Definition: ESRecoSummary.h:61
edm::InputTag esClusterCollectionY_
Definition: ESRecoSummary.h:74
MonitorElement * h_esClusters_energy_ratio
Definition: ESRecoSummary.h:65
void Fill(long long x)
edm::InputTag superClusterCollection_EE_
Definition: ESRecoSummary.h:71
ESRecoSummary(const edm::ParameterSet &)
std::string prefixME_
Definition: ESRecoSummary.h:57
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
edm::InputTag esRecHitCollection_
Definition: ESRecoSummary.h:72
MonitorElement * h_recHits_ES_energyMax
Definition: ESRecoSummary.h:60
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
std::vector< PreshowerCluster > PreshowerClusterCollection
collection of PreshowerCluster objects
double energy() const
cluster energy
Definition: CaloCluster.h:120
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
const_iterator end() const
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: Handle.h:74
MonitorElement * h_esClusters_energy_plane2
Definition: ESRecoSummary.h:64
virtual void analyze(const edm::Event &, const edm::EventSetup &)
edm::InputTag esClusterCollectionX_
Definition: ESRecoSummary.h:73
const_iterator begin() const
virtual void endJob()
virtual void beginJob()