CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
EgammaRecHitIsolation Class Reference

#include <EgammaRecHitIsolation.h>

Public Member Functions

void doFlagChecks (const std::vector< int > &v)
 
void doSeverityChecks (const EcalRecHitCollection *const recHits, const std::vector< int > &v)
 
 EgammaRecHitIsolation (double extRadius, double intRadius, double etaSlice, double etLow, double eLow, edm::ESHandle< CaloGeometry >, const EcalRecHitCollection &, const EcalSeverityLevelAlgo *, DetId::Detector detector)
 
double getEnergySum (const reco::Candidate *emObject) const
 
double getEnergySum (const reco::SuperCluster *emObject) const
 
double getEtSum (const reco::Candidate *emObject) const
 
double getEtSum (const reco::SuperCluster *emObject) const
 
void setUseNumCrystals (bool b=true)
 
void setVetoClustered (bool b=true)
 
 ~EgammaRecHitIsolation ()
 

Private Member Functions

double getSum_ (const reco::Candidate *, bool returnEt) const
 
double getSum_ (const reco::SuperCluster *, bool returnEt) const
 

Private Attributes

const EcalRecHitCollectioncaloHits_
 
const EcalRecHitCollectionecalBarHits_
 
double eLow_
 
double etaSlice_
 
double etLow_
 
double extRadius_
 
std::vector< int > flags_
 
double intRadius_
 
std::vector< int > severitiesexcl_
 
const EcalSeverityLevelAlgosevLevel_
 
const CaloSubdetectorGeometrysubdet_ [2]
 
edm::ESHandle< CaloGeometrytheCaloGeom_
 
bool useNumCrystals_
 
bool vetoClustered_
 

Detailed Description

Definition at line 28 of file EgammaRecHitIsolation.h.

Constructor & Destructor Documentation

EgammaRecHitIsolation::EgammaRecHitIsolation ( double  extRadius,
double  intRadius,
double  etaSlice,
double  etLow,
double  eLow,
edm::ESHandle< CaloGeometry theCaloGeom,
const EcalRecHitCollection caloHits,
const EcalSeverityLevelAlgo sl,
DetId::Detector  detector 
)

Definition at line 32 of file EgammaRecHitIsolation.cc.

References DetId::Ecal, EcalBarrel, EcalEndcap, CaloGeometry::getSubdetectorGeometry(), edm::ESHandle< T >::product(), subdet_, and theCaloGeom_.

40  : // not used anymore, kept for compatibility
43  etaSlice_(etaSlice),
44  etLow_(etLow),
45  eLow_(eLow),
46  theCaloGeom_(theCaloGeom) ,
47  caloHits_(caloHits),
48  sevLevel_(sl),
49  useNumCrystals_(false),
50  vetoClustered_(false),
51  ecalBarHits_(nullptr),
52  //chStatus_(0),
53  severitiesexcl_(0),
54  //severityRecHitThreshold_(0),
55  //spId_(EcalSeverityLevelAlgo::kSwissCross),
56  //spIdThreshold_(0),
57  flags_(0)
58 {
59  //set up the geometry and selector
60  const CaloGeometry* caloGeom = theCaloGeom_.product();
63 
64 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:49
const CaloSubdetectorGeometry * subdet_[2]
edm::ESHandle< CaloGeometry > theCaloGeom_
std::vector< int > flags_
std::vector< int > severitiesexcl_
const EcalRecHitCollection * ecalBarHits_
const EcalSeverityLevelAlgo * sevLevel_
T const * product() const
Definition: ESHandle.h:86
const EcalRecHitCollection & caloHits_
EgammaRecHitIsolation::~EgammaRecHitIsolation ( )

Definition at line 66 of file EgammaRecHitIsolation.cc.

Referenced by doFlagChecks().

67 {}

Member Function Documentation

void EgammaRecHitIsolation::doFlagChecks ( const std::vector< int > &  v)
inline
void EgammaRecHitIsolation::doSeverityChecks ( const EcalRecHitCollection *const  recHits,
const std::vector< int > &  v 
)
inline
double EgammaRecHitIsolation::getEnergySum ( const reco::Candidate emObject) const
inline

Definition at line 43 of file EgammaRecHitIsolation.h.

References getSum_().

Referenced by EgammaHLTEcalRecIsolationProducer::produce(), and EgammaEcalRecHitIsolationProducer::produce().

43 { return getSum_(emObject,false);}
double getSum_(const reco::Candidate *, bool returnEt) const
double EgammaRecHitIsolation::getEnergySum ( const reco::SuperCluster emObject) const
inline

Definition at line 46 of file EgammaRecHitIsolation.h.

References getSum_().

46 { return getSum_(emObject,false);}
double getSum_(const reco::Candidate *, bool returnEt) const
double EgammaRecHitIsolation::getEtSum ( const reco::Candidate emObject) const
inline
double EgammaRecHitIsolation::getEtSum ( const reco::SuperCluster emObject) const
inline

Definition at line 45 of file EgammaRecHitIsolation.h.

References getSum_().

45 {return getSum_(emObject,true);}
double getSum_(const reco::Candidate *, bool returnEt) const
double EgammaRecHitIsolation::getSum_ ( const reco::Candidate emObject,
bool  returnEt 
) const
private

Definition at line 69 of file EgammaRecHitIsolation.cc.

References caloHits_, reco::deltaPhi(), ecalBarHits_, eLow_, edm::SortedCollection< T, SORT >::empty(), edm::SortedCollection< T, SORT >::end(), CastorDataFrameFilter_impl::energySum(), stringResolutionProvider_cfi::et, PVValHelper::eta, PV3DBase< T, PVType, FrameType >::eta(), etaSlice_, etLow_, extRadius_, spr::find(), edm::SortedCollection< T, SORT >::find(), flags_, reco::Candidate::get(), edm::Ref< C, T, F >::get(), CaloSubdetectorGeometry::getCells(), CaloGeometry::getGeometry(), mps_fire::i, intRadius_, EcalRecHit::kGood, phi, diffTwoXMLs::r2, SimDataFormats::CaloAnalysis::sc, severitiesexcl_, EcalSeverityLevelAlgo::severityLevel(), sevLevel_, mathSSE::sqrt(), subdet_, theCaloGeom_, useNumCrystals_, and vetoClustered_.

Referenced by doFlagChecks(), getEnergySum(), and getEtSum().

69  {
70 
71  double energySum = 0.;
72  if (! caloHits_.empty()) {
73  //Take the SC position
75  math::XYZPoint const & theCaloPosition = sc.get()->position();
76  GlobalPoint pclu (theCaloPosition.x () ,
77  theCaloPosition.y () ,
78  theCaloPosition.z () );
79  float etaclus = pclu.eta();
80  float phiclus = pclu.phi();
81  float r2 = intRadius_*intRadius_;
82 
83  std::vector< std::pair<DetId, float> >::const_iterator rhIt;
84 
85  for(int subdetnr=0; subdetnr<=1 ; subdetnr++){ // look in barrel and endcap
86  if( nullptr == subdet_[subdetnr] ) continue;
87 
88  CaloSubdetectorGeometry::DetIdSet chosen = subdet_[subdetnr]->getCells(pclu,extRadius_);// select cells around cluster
90 
91  for (CaloSubdetectorGeometry::DetIdSet::const_iterator i = chosen.begin ();i != chosen.end (); ++i){ //loop selected cells
92  j = caloHits_.find(*i); // find selected cell among rechits
93  if(j != caloHits_.end()) { // add rechit only if available
94  auto cell = theCaloGeom_->getGeometry(*i);
95  float eta = cell->etaPos();
96  float phi = cell->phiPos();
97  float etaDiff = eta - etaclus;
98  float phiDiff= reco::deltaPhi(phi,phiclus);
99  float energy = j->energy();
100 
101  if(useNumCrystals_) {
102  if(fabs(etaclus) < 1.479) { // Barrel num crystals, crystal width = 0.0174
103  if (fabs(etaDiff) < 0.0174*etaSlice_)
104  continue;
105  //if (sqrt(etaDiff*etaDiff + phiDiff*phiDiff) < 0.0174*intRadius_)
106  //continue;
107  if ((etaDiff*etaDiff + phiDiff*phiDiff) < 0.00030276*r2)
108  continue;
109  } else { // Endcap num crystals, crystal width = 0.00864*fabs(sinh(eta))
110  if (fabs(etaDiff) < 0.00864*fabs(sinh(eta))*etaSlice_)
111  continue;
112  //if (sqrt(etaDiff*etaDiff + phiDiff*phiDiff) < 0.00864*fabs(sinh(eta))*intRadius_)
113  // continue;
114  if ((etaDiff*etaDiff + phiDiff*phiDiff) < (0.000037325*(cosh(2*eta)-1)*r2))
115  continue;
116  }
117  } else {
118  if (fabs(etaDiff) < etaSlice_)
119  continue; // jurassic strip cut
120  if (etaDiff*etaDiff + phiDiff*phiDiff < r2)
121  continue; // jurassic exclusion cone cut
122  }
123  //Check if RecHit is in SC
124  if(vetoClustered_) {
125 
126  //Loop over basic clusters:
127  bool isClustered = false;
128  for(reco::CaloCluster_iterator bcIt = sc->clustersBegin();bcIt != sc->clustersEnd(); ++bcIt) {
129  for(rhIt = (*bcIt)->hitsAndFractions().begin();rhIt != (*bcIt)->hitsAndFractions().end(); ++rhIt) {
130  if(rhIt->first == *i)
131  isClustered = true;
132  if(isClustered)
133  break;
134  }
135 
136  if(isClustered)
137  break;
138  } //end loop over basic clusters
139 
140  if(isClustered)
141  continue;
142  } //end if removeClustered
143 
144 
145 
146 
147  //std::cout << "detid " << j->detid() << std::endl;
148  int severityFlag = ecalBarHits_ == nullptr ? -1 : sevLevel_->severityLevel(j->detid(), *ecalBarHits_);
149  std::vector<int>::const_iterator sit = std::find(severitiesexcl_.begin(),
150  severitiesexcl_.end(),
151  severityFlag);
152 
153  if (sit!= severitiesexcl_.end())
154  continue;
155 
156  // new rechit flag checks
157  //std::vector<int>::const_iterator vit = std::find(flags_.begin(),
158  // flags_.end(),
159  // j->recoFlag());
160  //if (vit != flags_.end())
161  // continue;
162  if (!j->checkFlag(EcalRecHit::kGood)) {
163  if (j->checkFlags(flags_)) {
164  continue;
165  }
166  }
167 
168  float et = energy*std::sqrt(cell->getPosition().perp2()/cell->getPosition().mag2());
169  if ( et > etLow_ && energy > eLow_) { //Changed energy --> fabs(energy) - now changed back to energy
170  if(returnEt)
171  energySum += et;
172  else
173  energySum += energy;
174  }
175 
176  } //End if not end of list
177  } //End loop over rechits
178  } //End loop over barrel/endcap
179  } //End if caloHits_
180 
181  return energySum;
182 }
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:22
const CaloSubdetectorGeometry * subdet_[2]
edm::ESHandle< CaloGeometry > theCaloGeom_
std::vector< int > flags_
EcalSeverityLevel::SeverityLevel severityLevel(const DetId &id) const
Evaluate status from id use channelStatus from DB.
std::vector< EcalRecHit >::const_iterator const_iterator
std::vector< int > severitiesexcl_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
virtual DetIdSet getCells(const GlobalPoint &r, double dR) const
Get a list of all cells within a dR of the given cell.
T sqrt(T t)
Definition: SSEVec.h:18
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:243
const EcalRecHitCollection * ecalBarHits_
const_iterator end() const
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
et
define resolution functions of each parameter
T eta() const
Definition: PV3DBase.h:76
iterator find(key_type k)
T get() const
get a component
Definition: Candidate.h:217
std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id.
Definition: CaloGeometry.cc:85
const EcalSeverityLevelAlgo * sevLevel_
double energySum(const DataFrame &df, int fs, int ls)
const EcalRecHitCollection & caloHits_
double EgammaRecHitIsolation::getSum_ ( const reco::SuperCluster sc,
bool  returnEt 
) const
private

Definition at line 186 of file EgammaRecHitIsolation.cc.

References caloHits_, reco::SuperCluster::clustersBegin(), reco::SuperCluster::clustersEnd(), reco::deltaPhi(), ecalBarHits_, eLow_, edm::SortedCollection< T, SORT >::empty(), edm::SortedCollection< T, SORT >::end(), CastorDataFrameFilter_impl::energySum(), stringResolutionProvider_cfi::et, PVValHelper::eta, PV3DBase< T, PVType, FrameType >::eta(), etaSlice_, etLow_, extRadius_, spr::find(), edm::SortedCollection< T, SORT >::find(), flags_, CaloSubdetectorGeometry::getCells(), mps_fire::i, intRadius_, EcalRecHit::kGood, PV3DBase< T, PVType, FrameType >::mag(), PV3DBase< T, PVType, FrameType >::perp(), phi, PV3DBase< T, PVType, FrameType >::phi(), reco::CaloCluster::position(), position, edm::ESHandle< T >::product(), diffTwoXMLs::r2, severitiesexcl_, EcalSeverityLevelAlgo::severityLevel(), sevLevel_, subdet_, theCaloGeom_, useNumCrystals_, and vetoClustered_.

186  {
187 
188  double energySum = 0.;
189  if (! caloHits_.empty()){
190  //Take the SC position
191 
192  const math::XYZPoint& theCaloPosition = sc->position();
193  GlobalPoint pclu (theCaloPosition.x () ,
194  theCaloPosition.y () ,
195  theCaloPosition.z () );
196  double etaclus = pclu.eta();
197  double phiclus = pclu.phi();
198  double r2 = intRadius_*intRadius_;
199 
200  std::vector< std::pair<DetId, float> >::const_iterator rhIt;
201 
202 
203  for(int subdetnr=0; subdetnr<=1 ; subdetnr++){ // look in barrel and endcap
204  if( nullptr == subdet_[subdetnr] ) continue;
205  CaloSubdetectorGeometry::DetIdSet chosen = subdet_[subdetnr]->getCells(pclu,extRadius_);// select cells around cluster
207  for (CaloSubdetectorGeometry::DetIdSet::const_iterator i = chosen.begin ();i!= chosen.end ();++i){//loop selected cells
208 
209  j=caloHits_.find(*i); // find selected cell among rechits
210  if( j!=caloHits_.end()){ // add rechit only if available
211  const GlobalPoint & position = (theCaloGeom_.product())->getPosition(*i);
212  double eta = position.eta();
213  double phi = position.phi();
214  double etaDiff = eta - etaclus;
215  double phiDiff= reco::deltaPhi(phi,phiclus);
216  double energy = j->energy();
217 
218  if(useNumCrystals_) {
219  if( fabs(etaclus) < 1.479 ) { // Barrel num crystals, crystal width = 0.0174
220  if ( fabs(etaDiff) < 0.0174*etaSlice_) continue;
221  // if ( sqrt(etaDiff*etaDiff + phiDiff*phiDiff) < 0.0174*intRadius_) continue;
222  if ((etaDiff*etaDiff + phiDiff*phiDiff) < 0.00030276*r2) continue;
223  } else { // Endcap num crystals, crystal width = 0.00864*fabs(sinh(eta))
224  if ( fabs(etaDiff) < 0.00864*fabs(sinh(eta))*etaSlice_) continue;
225  // if ( sqrt(etaDiff*etaDiff + phiDiff*phiDiff) < 0.00864*fabs(sinh(eta))*intRadius_) continue;
226  if ((etaDiff*etaDiff + phiDiff*phiDiff) < (0.000037325*(cosh(2*eta)-1)*r2)) continue;
227  }
228  } else {
229  if ( fabs(etaDiff) < etaSlice_) continue; // jurassic strip cut
230  if ( etaDiff*etaDiff + phiDiff*phiDiff < r2) continue; // jurassic exclusion cone cut
231  }
232 
233  //Check if RecHit is in SC
234  if(vetoClustered_) {
235 
236  //Loop over basic clusters:
237  bool isClustered = false;
238  for(reco::CaloCluster_iterator bcIt = sc->clustersBegin();bcIt != sc->clustersEnd(); ++bcIt) {
239  for(rhIt = (*bcIt)->hitsAndFractions().begin();rhIt != (*bcIt)->hitsAndFractions().end(); ++rhIt) {
240  if( rhIt->first == *i ) isClustered = true;
241  if( isClustered ) break;
242  }
243  if( isClustered ) break;
244  } //end loop over basic clusters
245 
246  if(isClustered) continue;
247  } //end if removeClustered
248 
249 
250  int severityFlag = sevLevel_->severityLevel(j->detid(), *ecalBarHits_);
251  std::vector<int>::const_iterator sit = std::find(severitiesexcl_.begin(),
252  severitiesexcl_.end(),
253  severityFlag);
254 
255  if (sit!= severitiesexcl_.end())
256  continue;
257 
258  // new rechit flag checks
259  //std::vector<int>::const_iterator vit = std::find(flags_.begin(),
260  // flags_.end(),
261  // j->recoFlag());
262  //if (vit != flags_.end())
263  // continue;
264  if (!j->checkFlag(EcalRecHit::kGood)) {
265  if (j->checkFlags(flags_)) {
266  continue;
267  }
268  }
269 
270 
271  double et = energy*position.perp()/position.mag();
272  if ( et > etLow_ && energy > eLow_){ //Changed energy --> fabs(energy) -- then changed into energy
273  if(returnEt) energySum+=et;
274  else energySum+=energy;
275  }
276 
277  } //End if not end of list
278  } //End loop over rechits
279  } //End loop over barrel/endcap
280  } //End if caloHits_
281 
282  return energySum;
283 }
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:22
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:131
const CaloSubdetectorGeometry * subdet_[2]
edm::ESHandle< CaloGeometry > theCaloGeom_
std::vector< int > flags_
T perp() const
Definition: PV3DBase.h:72
EcalSeverityLevel::SeverityLevel severityLevel(const DetId &id) const
Evaluate status from id use channelStatus from DB.
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
std::vector< EcalRecHit >::const_iterator const_iterator
std::vector< int > severitiesexcl_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
virtual DetIdSet getCells(const GlobalPoint &r, double dR) const
Get a list of all cells within a dR of the given cell.
T mag() const
Definition: PV3DBase.h:67
const EcalRecHitCollection * ecalBarHits_
const_iterator end() const
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
et
define resolution functions of each parameter
T eta() const
Definition: PV3DBase.h:76
iterator find(key_type k)
static int position[264][3]
Definition: ReadPGInfo.cc:509
CaloCluster_iterator clustersBegin() const
fist iterator over BasicCluster constituents
Definition: SuperCluster.h:75
const EcalSeverityLevelAlgo * sevLevel_
double energySum(const DataFrame &df, int fs, int ls)
T const * product() const
Definition: ESHandle.h:86
const EcalRecHitCollection & caloHits_
CaloCluster_iterator clustersEnd() const
last iterator over BasicCluster constituents
Definition: SuperCluster.h:78
void EgammaRecHitIsolation::setUseNumCrystals ( bool  b = true)
inline
void EgammaRecHitIsolation::setVetoClustered ( bool  b = true)
inline

Member Data Documentation

const EcalRecHitCollection& EgammaRecHitIsolation::caloHits_
private

Definition at line 79 of file EgammaRecHitIsolation.h.

Referenced by getSum_().

const EcalRecHitCollection* EgammaRecHitIsolation::ecalBarHits_
private

Definition at line 84 of file EgammaRecHitIsolation.h.

Referenced by doSeverityChecks(), and getSum_().

double EgammaRecHitIsolation::eLow_
private

Definition at line 75 of file EgammaRecHitIsolation.h.

Referenced by getSum_().

double EgammaRecHitIsolation::etaSlice_
private

Definition at line 73 of file EgammaRecHitIsolation.h.

Referenced by getSum_().

double EgammaRecHitIsolation::etLow_
private

Definition at line 74 of file EgammaRecHitIsolation.h.

Referenced by getSum_().

double EgammaRecHitIsolation::extRadius_
private

Definition at line 71 of file EgammaRecHitIsolation.h.

Referenced by getSum_().

std::vector<int> EgammaRecHitIsolation::flags_
private

Definition at line 91 of file EgammaRecHitIsolation.h.

Referenced by doFlagChecks(), and getSum_().

double EgammaRecHitIsolation::intRadius_
private

Definition at line 72 of file EgammaRecHitIsolation.h.

Referenced by getSum_().

std::vector<int> EgammaRecHitIsolation::severitiesexcl_
private

Definition at line 86 of file EgammaRecHitIsolation.h.

Referenced by doSeverityChecks(), and getSum_().

const EcalSeverityLevelAlgo* EgammaRecHitIsolation::sevLevel_
private

Definition at line 80 of file EgammaRecHitIsolation.h.

Referenced by getSum_().

const CaloSubdetectorGeometry* EgammaRecHitIsolation::subdet_[2]
private

Definition at line 93 of file EgammaRecHitIsolation.h.

Referenced by EgammaRecHitIsolation(), and getSum_().

edm::ESHandle<CaloGeometry> EgammaRecHitIsolation::theCaloGeom_
private

Definition at line 78 of file EgammaRecHitIsolation.h.

Referenced by EgammaRecHitIsolation(), and getSum_().

bool EgammaRecHitIsolation::useNumCrystals_
private

Definition at line 82 of file EgammaRecHitIsolation.h.

Referenced by getSum_(), and setUseNumCrystals().

bool EgammaRecHitIsolation::vetoClustered_
private

Definition at line 83 of file EgammaRecHitIsolation.h.

Referenced by getSum_(), and setVetoClustered().