CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 26 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< class >::product(), subdet_, and theCaloGeom_.

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

Definition at line 65 of file EgammaRecHitIsolation.cc.

65 {}

Member Function Documentation

void EgammaRecHitIsolation::doFlagChecks ( const std::vector< int > &  v)
inline

Definition at line 54 of file EgammaRecHitIsolation.h.

References flags_.

Referenced by ConversionTrackCandidateProducer::buildCollections(), and PhotonIsolationCalculator::calculateEcalRecHitIso().

54  {
55  flags_.clear();
56  flags_.insert(flags_.begin(), v.begin(), v.end());
57  std::sort(flags_.begin(), flags_.end());
58  }
std::vector< int > flags_
void EgammaRecHitIsolation::doSeverityChecks ( const EcalRecHitCollection *const  recHits,
const std::vector< int > &  v 
)
inline

Definition at line 47 of file EgammaRecHitIsolation.h.

References ecalBarHits_, HLT_FULL_cff::recHits, and severitiesexcl_.

Referenced by ConversionTrackCandidateProducer::buildCollections(), and PhotonIsolationCalculator::calculateEcalRecHitIso().

47  {
49  severitiesexcl_.clear();
50  severitiesexcl_.insert(severitiesexcl_.begin(), v.begin(), v.end());
51  std::sort(severitiesexcl_.begin(), severitiesexcl_.end());
52  }
std::vector< int > severitiesexcl_
const EcalRecHitCollection * ecalBarHits_
double EgammaRecHitIsolation::getEnergySum ( const reco::Candidate emObject) const
inline

Definition at line 40 of file EgammaRecHitIsolation.h.

References getSum_().

Referenced by EgammaEcalRecHitIsolationProducer::produce().

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

Definition at line 43 of file EgammaRecHitIsolation.h.

References getSum_().

43 { 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 42 of file EgammaRecHitIsolation.h.

References getSum_().

42 { 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 67 of file EgammaRecHitIsolation.cc.

References caloHits_, reco::deltaPhi(), ecalBarHits_, eLow_, edm::SortedCollection< T, SORT >::empty(), edm::SortedCollection< T, SORT >::end(), relval_parameters_module::energy, CastorDataFrameFilter_impl::energySum(), 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(), mps_fire::i, intRadius_, dqmiolumiharvest::j, EcalRecHit::kGood, phi, diffTwoXMLs::r2, severitiesexcl_, EcalSeverityLevelAlgo::severityLevel(), sevLevel_, mathSSE::sqrt(), subdet_, theCaloGeom_, useNumCrystals_, and vetoClustered_.

Referenced by getEnergySum(), and getEtSum().

67  {
68  double energySum = 0.;
69  if (!caloHits_.empty()) {
70  //Take the SC position
72  math::XYZPoint const& theCaloPosition = sc.get()->position();
73  GlobalPoint pclu(theCaloPosition.x(), theCaloPosition.y(), theCaloPosition.z());
74  float etaclus = pclu.eta();
75  float phiclus = pclu.phi();
76  float r2 = intRadius_ * intRadius_;
77 
78  std::vector<std::pair<DetId, float> >::const_iterator rhIt;
79 
80  for (int subdetnr = 0; subdetnr <= 1; subdetnr++) { // look in barrel and endcap
81  if (nullptr == subdet_[subdetnr])
82  continue;
83 
85  subdet_[subdetnr]->getCells(pclu, extRadius_); // select cells around cluster
87 
88  for (CaloSubdetectorGeometry::DetIdSet::const_iterator i = chosen.begin(); i != chosen.end();
89  ++i) { //loop selected cells
90  j = caloHits_.find(*i); // find selected cell among rechits
91  if (j != caloHits_.end()) { // add rechit only if available
92  auto cell = theCaloGeom_->getGeometry(*i);
93  float eta = cell->etaPos();
94  float phi = cell->phiPos();
95  float etaDiff = eta - etaclus;
96  float phiDiff = reco::deltaPhi(phi, phiclus);
97  float energy = j->energy();
98 
99  if (useNumCrystals_) {
100  if (fabs(etaclus) < 1.479) { // Barrel num crystals, crystal width = 0.0174
101  if (fabs(etaDiff) < 0.0174 * etaSlice_)
102  continue;
103  //if (sqrt(etaDiff*etaDiff + phiDiff*phiDiff) < 0.0174*intRadius_)
104  //continue;
105  if ((etaDiff * etaDiff + phiDiff * phiDiff) < 0.00030276 * r2)
106  continue;
107  } else { // Endcap num crystals, crystal width = 0.00864*fabs(sinh(eta))
108  if (fabs(etaDiff) < 0.00864 * fabs(sinh(eta)) * etaSlice_)
109  continue;
110  //if (sqrt(etaDiff*etaDiff + phiDiff*phiDiff) < 0.00864*fabs(sinh(eta))*intRadius_)
111  // continue;
112  if ((etaDiff * etaDiff + phiDiff * phiDiff) < (0.000037325 * (cosh(2 * eta) - 1) * r2))
113  continue;
114  }
115  } else {
116  if (fabs(etaDiff) < etaSlice_)
117  continue; // jurassic strip cut
118  if (etaDiff * etaDiff + phiDiff * phiDiff < r2)
119  continue; // jurassic exclusion cone cut
120  }
121  //Check if RecHit is in SC
122  if (vetoClustered_) {
123  //Loop over basic clusters:
124  bool isClustered = false;
125  for (reco::CaloCluster_iterator bcIt = sc->clustersBegin(); bcIt != sc->clustersEnd(); ++bcIt) {
126  for (rhIt = (*bcIt)->hitsAndFractions().begin(); rhIt != (*bcIt)->hitsAndFractions().end(); ++rhIt) {
127  if (rhIt->first == *i)
128  isClustered = true;
129  if (isClustered)
130  break;
131  }
132 
133  if (isClustered)
134  break;
135  } //end loop over basic clusters
136 
137  if (isClustered)
138  continue;
139  } //end if removeClustered
140 
141  //std::cout << "detid " << j->detid() << std::endl;
142  int severityFlag = ecalBarHits_ == nullptr ? -1 : sevLevel_->severityLevel(j->detid(), *ecalBarHits_);
143  std::vector<int>::const_iterator sit =
144  std::find(severitiesexcl_.begin(), severitiesexcl_.end(), severityFlag);
145 
146  if (sit != severitiesexcl_.end())
147  continue;
148 
149  // new rechit flag checks
150  //std::vector<int>::const_iterator vit = std::find(flags_.begin(),
151  // flags_.end(),
152  // j->recoFlag());
153  //if (vit != flags_.end())
154  // continue;
155  if (!j->checkFlag(EcalRecHit::kGood)) {
156  if (j->checkFlags(flags_)) {
157  continue;
158  }
159  }
160 
161  float et = energy * std::sqrt(cell->getPosition().perp2() / cell->getPosition().mag2());
162  if (et > etLow_ && energy > eLow_) { //Changed energy --> fabs(energy) - now changed back to energy
163  if (returnEt)
164  energySum += et;
165  else
166  energySum += energy;
167  }
168 
169  } //End if not end of list
170  } //End loop over rechits
171  } //End loop over barrel/endcap
172  } //End if caloHits_
173 
174  return energySum;
175 }
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
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:19
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:19
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
const EcalRecHitCollection * ecalBarHits_
const_iterator end() const
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
T eta() const
Definition: PV3DBase.h:73
iterator find(key_type k)
T get() const
get a component
Definition: Candidate.h:221
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 177 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(), relval_parameters_module::energy, CastorDataFrameFilter_impl::energySum(), PVValHelper::eta, PV3DBase< T, PVType, FrameType >::eta(), etaSlice_, etLow_, extRadius_, spr::find(), edm::SortedCollection< T, SORT >::find(), flags_, CaloSubdetectorGeometry::getCells(), mps_fire::i, intRadius_, dqmiolumiharvest::j, EcalRecHit::kGood, PV3DBase< T, PVType, FrameType >::mag(), PV3DBase< T, PVType, FrameType >::perp(), phi, PV3DBase< T, PVType, FrameType >::phi(), reco::CaloCluster::position(), position, edm::ESHandle< class >::product(), diffTwoXMLs::r2, severitiesexcl_, EcalSeverityLevelAlgo::severityLevel(), sevLevel_, subdet_, theCaloGeom_, useNumCrystals_, and vetoClustered_.

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

Referenced by getSum_().

const EcalRecHitCollection* EgammaRecHitIsolation::ecalBarHits_
private

Definition at line 79 of file EgammaRecHitIsolation.h.

Referenced by doSeverityChecks(), and getSum_().

double EgammaRecHitIsolation::eLow_
private

Definition at line 71 of file EgammaRecHitIsolation.h.

Referenced by getSum_().

double EgammaRecHitIsolation::etaSlice_
private

Definition at line 69 of file EgammaRecHitIsolation.h.

Referenced by getSum_().

double EgammaRecHitIsolation::etLow_
private

Definition at line 70 of file EgammaRecHitIsolation.h.

Referenced by getSum_().

double EgammaRecHitIsolation::extRadius_
private

Definition at line 67 of file EgammaRecHitIsolation.h.

Referenced by getSum_().

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

Definition at line 81 of file EgammaRecHitIsolation.h.

Referenced by doFlagChecks(), and getSum_().

double EgammaRecHitIsolation::intRadius_
private

Definition at line 68 of file EgammaRecHitIsolation.h.

Referenced by getSum_().

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

Definition at line 80 of file EgammaRecHitIsolation.h.

Referenced by doSeverityChecks(), and getSum_().

const EcalSeverityLevelAlgo* EgammaRecHitIsolation::sevLevel_
private

Definition at line 75 of file EgammaRecHitIsolation.h.

Referenced by getSum_().

const CaloSubdetectorGeometry* EgammaRecHitIsolation::subdet_[2]
private

Definition at line 83 of file EgammaRecHitIsolation.h.

Referenced by EgammaRecHitIsolation(), and getSum_().

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

Definition at line 73 of file EgammaRecHitIsolation.h.

Referenced by EgammaRecHitIsolation(), and getSum_().

bool EgammaRecHitIsolation::useNumCrystals_
private

Definition at line 77 of file EgammaRecHitIsolation.h.

Referenced by getSum_(), and setUseNumCrystals().

bool EgammaRecHitIsolation::vetoClustered_
private

Definition at line 78 of file EgammaRecHitIsolation.h.

Referenced by getSum_(), and setVetoClustered().