CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EBRecoSummary.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: EBRecoSummary
4 // Class: EBRecoSummary
5 // Original Author: Martina Malberti
6 //
7 // system include files
8 #include <memory>
9 
10 // user include files
13 
18 
22 
31 
42 
45 
48 
53 
54 #include "TVector3.h"
55 
56 #include <iostream>
57 #include <cmath>
58 #include <fstream>
59 #include <string>
60 
61 //
62 // constructors and destructor
63 //
65 {
66 
67  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
68 
69  //now do what ever initialization is needed
70  recHitCollection_EB_ = consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("recHitCollection_EB"));
71  redRecHitCollection_EB_ = consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("redRecHitCollection_EB"));
72  basicClusterCollection_EB_ = consumes<edm::View<reco::CaloCluster> >(ps.getParameter<edm::InputTag>("basicClusterCollection_EB"));
73  superClusterCollection_EB_ = consumes<reco::SuperClusterCollection>(ps.getParameter<edm::InputTag>("superClusterCollection_EB"));
74 
75  std::cout << "EBRecoSummary " << ps.getParameter<edm::InputTag>("basicClusterCollection_EB") << std::endl;
76 
77  ethrEB_ = ps.getParameter<double>("ethrEB");
78 
79  scEtThrEB_ = ps.getParameter<double>("scEtThrEB");
80 
81  // DQM Store -------------------
83 
84  // Monitor Elements (ex THXD)
85  dqmStore_->setCurrentFolder(prefixME_ + "/EBRecoSummary"); // to organise the histos in folders
86 
87  // ReducedRecHits ----------------------------------------------
88  // ... barrel
89  h_redRecHits_EB_recoFlag = dqmStore_->book1D("redRecHits_EB_recoFlag","redRecHits_EB_recoFlag",16,-0.5,15.5);
90 
91  // RecHits ----------------------------------------------
92  // ... barrel
93  h_recHits_EB_energyMax = dqmStore_->book1D("recHits_EB_energyMax","recHitsEB_energyMax",110,-10,100);
94  h_recHits_EB_Chi2 = dqmStore_->book1D("recHits_EB_Chi2","recHits_EB_Chi2",200,0,100);
95  h_recHits_EB_time = dqmStore_->book1D("recHits_EB_time","recHits_EB_time",200,-50,50);
96  h_recHits_EB_E1oE4 = dqmStore_->book1D("recHits_EB_E1oE4","recHitsEB_E1oE4",150, 0, 1.5);
97  h_recHits_EB_recoFlag = dqmStore_->book1D("recHits_EB_recoFlag","recHits_EB_recoFlag",16,-0.5,15.5);
98 
99  // Basic Clusters ----------------------------------------------
100  // ... associated barrel rec hits
101  h_basicClusters_recHits_EB_recoFlag = dqmStore_->book1D("basicClusters_recHits_EB_recoFlag","basicClusters_recHits_EB_recoFlag",16,-0.5,15.5);
102 
103  // Super Clusters ----------------------------------------------
104  // ... barrel
105  h_superClusters_EB_nBC = dqmStore_->book1D("superClusters_EB_nBC","superClusters_EB_nBC",100,0.,100.);
106  h_superClusters_EB_E1oE4 = dqmStore_->book1D("superClusters_EB_E1oE4","superClusters_EB_E1oE4",150,0,1.5);
107 
108  h_superClusters_eta = dqmStore_->book1D("superClusters_eta","superClusters_eta",150,-3.,3.);
109  h_superClusters_EB_phi = dqmStore_->book1D("superClusters_EB_phi","superClusters_EB_phi",360,-3.1415927,3.1415927);
110 
111 }
112 
113 
114 
116 {
117  // do anything here that needs to be done at desctruction time
118  // (e.g. close files, deallocate resources etc.)
119 }
120 
121 
122 //
123 // member functions
124 //
125 
126 // ------------ method called to for each event ------------
127 void EBRecoSummary::analyze(const edm::Event& ev, const edm::EventSetup& iSetup)
128 {
129 
130  //Get the magnetic field
131  edm::ESHandle<MagneticField> theMagField;
132  iSetup.get<IdealMagneticFieldRecord>().get(theMagField);
133 
134  // calo topology
135  edm::ESHandle<CaloTopology> pTopology;
136  iSetup.get<CaloTopologyRecord>().get(pTopology);
137  const CaloTopology *topology = pTopology.product();
138 
139  // --- REDUCED REC HITS -------------------------------------------------------------------------------------
141  ev.getByToken( redRecHitCollection_EB_, redRecHitsEB );
142  const EcalRecHitCollection* theBarrelEcalredRecHits = redRecHitsEB.product () ;
143  if ( ! redRecHitsEB.isValid() ) {
144  edm::LogWarning("EBRecoSummary") << "redRecHitsEB not found";
145  }
146 
147  for ( EcalRecHitCollection::const_iterator itr = theBarrelEcalredRecHits->begin () ;
148  itr != theBarrelEcalredRecHits->end () ;++itr)
149  {
150 
151  h_redRecHits_EB_recoFlag->Fill( itr -> recoFlag() );
152 
153  }
154 
155  // --- REC HITS -------------------------------------------------------------------------------------
156 
157  // ... barrel
159  ev.getByToken( recHitCollection_EB_, recHitsEB );
160  const EcalRecHitCollection* theBarrelEcalRecHits = recHitsEB.product () ;
161  if ( ! recHitsEB.isValid() ) {
162  edm::LogWarning("EBRecoSummary") << "recHitsEB not found";
163  }
164 
165  float maxRecHitEnergyEB = -999.;
166 
167  EBDetId ebid_MrecHitEB;
168 
169  for ( EcalRecHitCollection::const_iterator itr = theBarrelEcalRecHits->begin () ;
170  itr != theBarrelEcalRecHits->end () ;++itr)
171  {
172 
173  EBDetId ebid( itr -> id() );
174 
175  h_recHits_EB_recoFlag -> Fill( itr -> recoFlag() );
176 
177  // max E rec hit
178  if (itr -> energy() > maxRecHitEnergyEB ){
179  maxRecHitEnergyEB = itr -> energy() ;
180  }
181 
182  if ( itr -> energy() > ethrEB_ ){
183  h_recHits_EB_Chi2 -> Fill( itr -> chi2() );
184  h_recHits_EB_time -> Fill( itr -> time() );
185  }
186 
187  float R4 = EcalTools::swissCross( ebid, *theBarrelEcalRecHits, 0. );
188 
189  if ( itr -> energy() > 3. && abs(ebid.ieta())!=85 ) h_recHits_EB_E1oE4-> Fill( R4 );
190 
191  }
192 
193  h_recHits_EB_energyMax -> Fill( maxRecHitEnergyEB );
194 
195  //--- BASIC CLUSTERS --------------------------------------------------------------
196 
197  // ... barrel
198  edm::Handle<edm::View<reco::CaloCluster> > basicClusters_EB_h;
199  if(ev.getByToken( basicClusterCollection_EB_, basicClusters_EB_h )){
200 
201  const edm::View<reco::CaloCluster>* theBarrelBasicClusters = basicClusters_EB_h.product () ;
202 
203  for (edm::View<reco::CaloCluster>::const_iterator itBC = theBarrelBasicClusters->begin();
204  itBC != theBarrelBasicClusters->end(); ++itBC ) {
205 
206  //Get the associated RecHits
207  const std::vector<std::pair<DetId,float> > & hits= itBC->hitsAndFractions();
208  for (std::vector<std::pair<DetId,float> > ::const_iterator rh = hits.begin(); rh!=hits.end(); ++rh){
209 
210  EBRecHitCollection::const_iterator itrechit = theBarrelEcalRecHits->find((*rh).first);
211  if (itrechit==theBarrelEcalRecHits->end()) continue;
212  h_basicClusters_recHits_EB_recoFlag -> Fill ( itrechit -> recoFlag() );
213 
214  }
215 
216  }
217  }
218  else{
219  // edm::LogWarning("EBRecoSummary") << "basicClusters_EB_h not found";
220  }
221 
222  // Super Clusters
223  // ... barrel
225  ev.getByToken( superClusterCollection_EB_, superClusters_EB_h );
226  const reco::SuperClusterCollection* theBarrelSuperClusters = superClusters_EB_h.product () ;
227  if ( ! superClusters_EB_h.isValid() ) {
228  edm::LogWarning("EBRecoSummary") << "superClusters_EB_h not found";
229  }
230 
231  for (reco::SuperClusterCollection::const_iterator itSC = theBarrelSuperClusters->begin();
232  itSC != theBarrelSuperClusters->end(); ++itSC ) {
233 
234  double scEt = itSC -> energy() * sin(2.*atan( exp(- itSC->position().eta() )));
235 
236  if (scEt < scEtThrEB_ ) continue;
237 
238  h_superClusters_EB_nBC -> Fill( itSC -> clustersSize());
239  h_superClusters_eta -> Fill( itSC -> eta() );
240  h_superClusters_EB_phi -> Fill( itSC -> phi() );
241 
242  float E1 = EcalClusterTools::eMax ( *itSC, theBarrelEcalRecHits);
243  float E4 = EcalClusterTools::eTop ( *itSC, theBarrelEcalRecHits, topology )+
244  EcalClusterTools::eRight ( *itSC, theBarrelEcalRecHits, topology )+
245  EcalClusterTools::eBottom( *itSC, theBarrelEcalRecHits, topology )+
246  EcalClusterTools::eLeft ( *itSC, theBarrelEcalRecHits, topology );
247 
248  if ( E1 > 3. ) h_superClusters_EB_E1oE4 -> Fill( 1.- E4/E1);
249 
250  }
251 
252 }
253 
254 
255 // ------------ method called once each job just before starting event loop ------------
256  void
258 {
259 }
260 
261 // ------------ method called once each job just after ending the event loop ------------
262 void
264 {}
265 
266 // ----------additional functions-------------------
267 
268 void EBRecoSummary::convxtalid(Int_t &nphi,Int_t &neta)
269 {
270  // Barrel only
271  // Output nphi 0...359; neta 0...84; nside=+1 (for eta>0), or 0 (for eta<0).
272  // neta will be [-85,-1] , or [0,84], the minus sign indicates the z<0 side.
273 
274  if(neta > 0) neta -= 1;
275  if(nphi > 359) nphi=nphi-360;
276 
277 } //end of convxtalid
278 
279 int EBRecoSummary::diff_neta_s(Int_t neta1, Int_t neta2){
280  Int_t mdiff;
281  mdiff=(neta1-neta2);
282  return mdiff;
283 }
284 
285 // Calculate the distance in xtals taking into account the periodicity of the Barrel
286 int EBRecoSummary::diff_nphi_s(Int_t nphi1,Int_t nphi2) {
287  Int_t mdiff;
288  if(abs(nphi1-nphi2) < (360-abs(nphi1-nphi2))) {
289  mdiff=nphi1-nphi2;
290  }
291  else {
292  mdiff=360-abs(nphi1-nphi2);
293  if(nphi1>nphi2) mdiff=-mdiff;
294  }
295  return mdiff;
296 }
297 
298 //define this as a plug-in
MonitorElement * h_recHits_EB_time
Definition: EBRecoSummary.h:73
static float eBottom(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
T getParameter(std::string const &) const
MonitorElement * h_recHits_EB_energyMax
Definition: EBRecoSummary.h:71
std::string prefixME_
Definition: EBRecoSummary.h:61
T getUntrackedParameter(std::string const &, T const &) const
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
edm::EDGetTokenT< edm::View< reco::CaloCluster > > basicClusterCollection_EB_
Definition: EBRecoSummary.h:93
MonitorElement * h_recHits_EB_Chi2
Definition: EBRecoSummary.h:72
double scEtThrEB_
Definition: EBRecoSummary.h:98
MonitorElement * h_superClusters_EB_nBC
Definition: EBRecoSummary.h:82
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
MonitorElement * h_superClusters_EB_E1oE4
Definition: EBRecoSummary.h:83
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::vector< EcalRecHit >::const_iterator const_iterator
DQMStore * dqmStore_
Definition: EBRecoSummary.h:59
MonitorElement * h_recHits_EB_E1oE4
Definition: EBRecoSummary.h:74
T eta() const
edm::EDGetTokenT< EcalRecHitCollection > redRecHitCollection_EB_
Definition: EBRecoSummary.h:92
MonitorElement * h_recHits_EB_recoFlag
Definition: EBRecoSummary.h:75
MonitorElement * h_superClusters_eta
Definition: EBRecoSummary.h:85
int diff_neta_s(int, int)
void Fill(long long x)
virtual void beginJob()
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
EBRecoSummary(const edm::ParameterSet &)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
virtual void analyze(const edm::Event &, const edm::EventSetup &)
virtual void endJob()
int ieta() const
get the crystal ieta
Definition: EBDetId.h:51
bool isValid() const
Definition: HandleBase.h:76
const_iterator end() const
static float eRight(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
static float eTop(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
static float eMax(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
T const * product() const
Definition: Handle.h:81
void convxtalid(int &, int &)
static float swissCross(const DetId &id, const EcalRecHitCollection &recHits, float recHitThreshold, bool avoidIeta85=true)
the good old 1-e4/e1. Ignore hits below recHitThreshold
Definition: EcalTools.cc:11
iterator find(key_type k)
edm::EDGetTokenT< EcalRecHitCollection > recHitCollection_EB_
Definition: EBRecoSummary.h:91
MonitorElement * h_superClusters_EB_phi
Definition: EBRecoSummary.h:86
edm::EDGetTokenT< reco::SuperClusterCollection > superClusterCollection_EB_
Definition: EBRecoSummary.h:94
const_iterator begin() const
tuple cout
Definition: gather_cfg.py:121
const_iterator end() const
static float eLeft(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
MonitorElement * h_redRecHits_EB_recoFlag
Definition: EBRecoSummary.h:67
MonitorElement * h_basicClusters_recHits_EB_recoFlag
Definition: EBRecoSummary.h:78
int diff_nphi_s(int, int)
const_iterator begin() const
Definition: DDAxes.h:10