CMS 3D CMS Logo

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 #include <cmath>
11 
12 // user include files
14 
16 
19 
21 
28 
39 
40 // Less than operator for sorting EcalRecHits according to energy.
41 class ecalRecHitLess : public std::binary_function<EcalRecHit, EcalRecHit, bool>
42 {
43 public:
45  {
46  return (x.energy() > y.energy());
47  }
48 };
49 
50 //
51 // constructors and destructor
52 //
54 {
55  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
56 
57  //now do what ever initialization is needed
58  esRecHitCollection_ = consumes<ESRecHitCollection>(ps.getParameter<edm::InputTag>("recHitCollection_ES"));
59  esClusterCollectionX_ = consumes<reco::PreshowerClusterCollection>(ps.getParameter<edm::InputTag>("ClusterCollectionX_ES"));
60  esClusterCollectionY_ = consumes<reco::PreshowerClusterCollection>(ps.getParameter<edm::InputTag>("ClusterCollectionY_ES"));
61 
62  superClusterCollection_EE_ = consumes<reco::SuperClusterCollection>(ps.getParameter<edm::InputTag>("superClusterCollection_EE"));
63 }
64 
65 void
67 {
68  // Monitor Elements (ex THXD)
69  iBooker.setCurrentFolder(prefixME_ + "/ESRecoSummary"); // to organise the histos in folders
70 
71 
72  // Preshower ----------------------------------------------
73  h_recHits_ES_energyMax = iBooker.book1D("recHits_ES_energyMax","recHits_ES_energyMax",200,0.,0.01);
74  h_recHits_ES_time = iBooker.book1D("recHits_ES_time","recHits_ES_time",200,-100.,100.);
75 
76  h_esClusters_energy_plane1 = iBooker.book1D("esClusters_energy_plane1","esClusters_energy_plane1",200,0.,0.01);
77  h_esClusters_energy_plane2 = iBooker.book1D("esClusters_energy_plane2","esClusters_energy_plane2",200,0.,0.01);
78  h_esClusters_energy_ratio = iBooker.book1D("esClusters_energy_ratio","esClusters_energy_ratio",200,0.,20.);
79 }
80 
81 //
82 // member functions
83 //
84 
85 // ------------ method called to for each event ------------
87 {
88  //Preshower RecHits
90  ev.getByToken (esRecHitCollection_, recHitsES) ;
91  const ESRecHitCollection* thePreShowerRecHits = recHitsES.product () ;
92 
93  if ( ! recHitsES.isValid() ) {
94  std::cerr << "ESRecoSummary::analyze --> recHitsES not found" << std::endl;
95  }
96 
97  float maxRecHitEnergyES = -999.;
98 
99  for (ESRecHitCollection::const_iterator esItr = thePreShowerRecHits->begin(); esItr != thePreShowerRecHits->end(); ++esItr)
100  {
101 
102  h_recHits_ES_time -> Fill(esItr->time());
103  if (esItr -> energy() > maxRecHitEnergyES ) maxRecHitEnergyES = esItr -> energy() ;
104 
105  } // end loop over ES rec Hits
106 
107  h_recHits_ES_energyMax -> Fill(maxRecHitEnergyES );
108 
109  // ES clusters in X plane
111  ev.getByToken( esClusterCollectionX_, esClustersX);
112  const reco::PreshowerClusterCollection *ESclustersX = esClustersX.product();
113 
114  // ES clusters in Y plane
116  ev.getByToken( esClusterCollectionY_, esClustersY);
117  const reco::PreshowerClusterCollection *ESclustersY = esClustersY.product();
118 
119 
120  // ... endcap
122  ev.getByToken( superClusterCollection_EE_, superClusters_EE_h );
123  const reco::SuperClusterCollection* theEndcapSuperClusters = superClusters_EE_h.product () ;
124  if ( ! superClusters_EE_h.isValid() ) {
125  std::cerr << "EcalRecHitSummary::analyze --> superClusters_EE_h not found" << std::endl;
126  }
127 
128  // loop over all super clusters
129  for (reco::SuperClusterCollection::const_iterator itSC = theEndcapSuperClusters->begin();
130  itSC != theEndcapSuperClusters->end(); ++itSC ) {
131 
132  if ( fabs(itSC->eta()) < 1.65 || fabs(itSC->eta()) > 2.6 ) continue;
133 
134  float ESenergyPlane1 = 0.;
135  float ESenergyPlane2 = 0.;
136 
137 
138  // Loop over all ECAL Basic clusters in the supercluster
139  for (reco::CaloCluster_iterator ecalBasicCluster = itSC->clustersBegin(); ecalBasicCluster!= itSC->clustersEnd();
140  ecalBasicCluster++) {
141  const reco::CaloClusterPtr ecalBasicClusterPtr = *(ecalBasicCluster);
142 
143  for (reco::PreshowerClusterCollection::const_iterator iESClus = ESclustersX->begin(); iESClus != ESclustersX->end();
144  ++iESClus) {
145  const reco::CaloClusterPtr preshBasicCluster = iESClus->basicCluster();
146  const reco::PreshowerCluster *esCluster = &*iESClus;
147  if (preshBasicCluster == ecalBasicClusterPtr) {
148  ESenergyPlane1 += esCluster->energy();
149  }
150  } // end of x loop
151 
152  for (reco::PreshowerClusterCollection::const_iterator iESClus = ESclustersY->begin(); iESClus != ESclustersY->end();
153  ++iESClus) {
154  const reco::CaloClusterPtr preshBasicCluster = iESClus->basicCluster();
155  const reco::PreshowerCluster *esCluster = &*iESClus;
156  if (preshBasicCluster == ecalBasicClusterPtr) {
157  ESenergyPlane2 += esCluster->energy();
158  }
159  } // end of y loop
160  } // end loop over all basic clusters in the supercluster
161 
162  //cout<<"DQM : "<<ESenergyPlane1<<" "<<ESenergyPlane2<<endl;
163  h_esClusters_energy_plane1->Fill(ESenergyPlane1);
164  h_esClusters_energy_plane2->Fill(ESenergyPlane2);
165  if (ESenergyPlane1 > 0 && ESenergyPlane2 > 0) h_esClusters_energy_ratio -> Fill(ESenergyPlane1/ESenergyPlane2);
166 
167  }// end loop over superclusters
168 
169 }
170 
171 //define this as a plug-in
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< EcalRecHit >::const_iterator const_iterator
bool ev
ESRecoSummary(const edm::ParameterSet &)
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
float energy() const
Definition: EcalRecHit.h:68
std::vector< PreshowerCluster > PreshowerClusterCollection
collection of PreshowerCluster objects
double energy() const
cluster energy
Definition: CaloCluster.h:124
bool isValid() const
Definition: HandleBase.h:74
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
const_iterator end() const
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
T const * product() const
Definition: Handle.h:81
void analyze(const edm::Event &, const edm::EventSetup &) override
bool operator()(EcalRecHit x, EcalRecHit y)
const_iterator begin() const
Definition: Run.h:43