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 #include <iostream>
10 
11 // user include files
14 
19 
23 
24 
33 
49 
52 
55 
60 
61 #include "TVector3.h"
62 
63 #include <iostream>
64 #include <cmath>
65 #include <fstream>
66 //using namespace std;
67 //
68 // constructors and destructor
69 //
71 {
72 
73  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
74 
75  //now do what ever initialization is needed
76  esRecHitCollection_ = consumes<ESRecHitCollection>(ps.getParameter<edm::InputTag>("recHitCollection_ES"));
77  esClusterCollectionX_ = consumes<reco::PreshowerClusterCollection>(ps.getParameter<edm::InputTag>("ClusterCollectionX_ES"));
78  esClusterCollectionY_ = consumes<reco::PreshowerClusterCollection>(ps.getParameter<edm::InputTag>("ClusterCollectionY_ES"));
79 
81 
82  // Monitor Elements (ex THXD)
83  dqmStore_->setCurrentFolder(prefixME_ + "/ESRecoSummary"); // to organise the histos in folders
84 
85  superClusterCollection_EE_ = consumes<reco::SuperClusterCollection>(ps.getParameter<edm::InputTag>("superClusterCollection_EE"));
86 
87  // Preshower ----------------------------------------------
88  h_recHits_ES_energyMax = dqmStore_->book1D("recHits_ES_energyMax","recHits_ES_energyMax",200,0.,0.01);
89  h_recHits_ES_time = dqmStore_->book1D("recHits_ES_time","recHits_ES_time",200,-100.,100.);
90 
91  h_esClusters_energy_plane1 = dqmStore_->book1D("esClusters_energy_plane1","esClusters_energy_plane1",200,0.,0.01);
92  h_esClusters_energy_plane2 = dqmStore_->book1D("esClusters_energy_plane2","esClusters_energy_plane2",200,0.,0.01);
93  h_esClusters_energy_ratio = dqmStore_->book1D("esClusters_energy_ratio","esClusters_energy_ratio",200,0.,20.);
94 
95 }
96 
97 
98 
100 {
101  // do anything here that needs to be done at desctruction time
102  // (e.g. close files, deallocate resources etc.)
103 }
104 
105 
106 //
107 // member functions
108 //
109 
110 // ------------ method called to for each event ------------
111 void ESRecoSummary::analyze(const edm::Event& ev, const edm::EventSetup& iSetup)
112 {
113 
114  //Get the magnetic field
115  edm::ESHandle<MagneticField> theMagField;
116  iSetup.get<IdealMagneticFieldRecord>().get(theMagField);
117 
118  //Preshower RecHits
120  ev.getByToken (esRecHitCollection_, recHitsES) ;
121  const ESRecHitCollection* thePreShowerRecHits = recHitsES.product () ;
122 
123  if ( ! recHitsES.isValid() ) {
124  std::cerr << "ESRecoSummary::analyze --> recHitsES not found" << std::endl;
125  }
126 
127  float maxRecHitEnergyES = -999.;
128 
129  for (ESRecHitCollection::const_iterator esItr = thePreShowerRecHits->begin(); esItr != thePreShowerRecHits->end(); ++esItr)
130  {
131 
132  h_recHits_ES_time -> Fill(esItr->time());
133  if (esItr -> energy() > maxRecHitEnergyES ) maxRecHitEnergyES = esItr -> energy() ;
134 
135  } // end loop over ES rec Hits
136 
137  h_recHits_ES_energyMax -> Fill(maxRecHitEnergyES );
138 
139  // ES clusters in X plane
141  ev.getByToken( esClusterCollectionX_, esClustersX);
142  const reco::PreshowerClusterCollection *ESclustersX = esClustersX.product();
143 
144  // ES clusters in Y plane
146  ev.getByToken( esClusterCollectionY_, esClustersY);
147  const reco::PreshowerClusterCollection *ESclustersY = esClustersY.product();
148 
149 
150  // ... endcap
152  ev.getByToken( superClusterCollection_EE_, superClusters_EE_h );
153  const reco::SuperClusterCollection* theEndcapSuperClusters = superClusters_EE_h.product () ;
154  if ( ! superClusters_EE_h.isValid() ) {
155  std::cerr << "EcalRecHitSummary::analyze --> superClusters_EE_h not found" << std::endl;
156  }
157 
158  // loop over all super clusters
159  for (reco::SuperClusterCollection::const_iterator itSC = theEndcapSuperClusters->begin();
160  itSC != theEndcapSuperClusters->end(); ++itSC ) {
161 
162  if ( fabs(itSC->eta()) < 1.65 || fabs(itSC->eta()) > 2.6 ) continue;
163 
164  float ESenergyPlane1 = 0.;
165  float ESenergyPlane2 = 0.;
166 
167 
168  // Loop over all ECAL Basic clusters in the supercluster
169  for (reco::CaloCluster_iterator ecalBasicCluster = itSC->clustersBegin(); ecalBasicCluster!= itSC->clustersEnd();
170  ecalBasicCluster++) {
171  const reco::CaloClusterPtr ecalBasicClusterPtr = *(ecalBasicCluster);
172 
173  for (reco::PreshowerClusterCollection::const_iterator iESClus = ESclustersX->begin(); iESClus != ESclustersX->end();
174  ++iESClus) {
175  const reco::CaloClusterPtr preshBasicCluster = iESClus->basicCluster();
176  const reco::PreshowerCluster *esCluster = &*iESClus;
177  if (preshBasicCluster == ecalBasicClusterPtr) {
178  ESenergyPlane1 += esCluster->energy();
179  }
180  } // end of x loop
181 
182  for (reco::PreshowerClusterCollection::const_iterator iESClus = ESclustersY->begin(); iESClus != ESclustersY->end();
183  ++iESClus) {
184  const reco::CaloClusterPtr preshBasicCluster = iESClus->basicCluster();
185  const reco::PreshowerCluster *esCluster = &*iESClus;
186  if (preshBasicCluster == ecalBasicClusterPtr) {
187  ESenergyPlane2 += esCluster->energy();
188  }
189  } // end of y loop
190  } // end loop over all basic clusters in the supercluster
191 
192  //cout<<"DQM : "<<ESenergyPlane1<<" "<<ESenergyPlane2<<endl;
193  h_esClusters_energy_plane1->Fill(ESenergyPlane1);
194  h_esClusters_energy_plane2->Fill(ESenergyPlane2);
195  if (ESenergyPlane1 > 0 && ESenergyPlane2 > 0) h_esClusters_energy_ratio -> Fill(ESenergyPlane1/ESenergyPlane2);
196 
197  }// end loop over superclusters
198 
199 }
200 
201 
202 // ------------ method called once each job just before starting event loop ------------
203  void
205 {
206 }
207 
208 // ------------ method called once each job just after ending the event loop ------------
209 void
211 {}
212 
213 //define this as a plug-in
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:872
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
#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::EDGetTokenT< ESRecHitCollection > esRecHitCollection_
Definition: ESRecoSummary.h:72
MonitorElement * h_esClusters_energy_ratio
Definition: ESRecoSummary.h:65
void Fill(long long x)
ESRecoSummary(const edm::ParameterSet &)
edm::EDGetTokenT< reco::PreshowerClusterCollection > esClusterCollectionY_
Definition: ESRecoSummary.h:74
std::string prefixME_
Definition: ESRecoSummary.h:57
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
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
const_iterator end() const
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: Handle.h:81
edm::EDGetTokenT< reco::PreshowerClusterCollection > esClusterCollectionX_
Definition: ESRecoSummary.h:73
MonitorElement * h_esClusters_energy_plane2
Definition: ESRecoSummary.h:64
edm::EDGetTokenT< reco::SuperClusterCollection > superClusterCollection_EE_
Definition: ESRecoSummary.h:71
virtual void analyze(const edm::Event &, const edm::EventSetup &)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:584
const_iterator begin() const
virtual void endJob()
virtual void beginJob()