CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 >, CaloRecHitMetaCollectionV *, 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

CaloRecHitMetaCollectionVcaloHits_
 
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 27 of file EgammaRecHitIsolation.h.

Constructor & Destructor Documentation

EgammaRecHitIsolation::EgammaRecHitIsolation ( double  extRadius,
double  intRadius,
double  etaSlice,
double  etLow,
double  eLow,
edm::ESHandle< CaloGeometry theCaloGeom,
CaloRecHitMetaCollectionV 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_.

40  : // not used anymore, kept for compatibility
41  extRadius_(extRadius),
42  intRadius_(intRadius),
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_(0),
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:43
const CaloSubdetectorGeometry * subdet_[2]
edm::ESHandle< CaloGeometry > theCaloGeom_
std::vector< int > flags_
CaloRecHitMetaCollectionV * caloHits_
std::vector< int > severitiesexcl_
const EcalRecHitCollection * ecalBarHits_
T const * product() const
Definition: ESHandle.h:62
const EcalSeverityLevelAlgo * sevLevel_
EgammaRecHitIsolation::~EgammaRecHitIsolation ( )

Definition at line 66 of file EgammaRecHitIsolation.cc.

67 {}

Member Function Documentation

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

Definition at line 57 of file EgammaRecHitIsolation.h.

References flags_, and python.multivaluedict::sort().

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

57  {
58  flags_.clear();
59  flags_.insert(flags_.begin(), v.begin(), v.end());
60  std::sort(flags_.begin(), flags_.end() );
61  }
std::vector< int > flags_
mathSSE::Vec4< T > v
void EgammaRecHitIsolation::doSeverityChecks ( const EcalRecHitCollection *const  recHits,
const std::vector< int >  v 
)
inline

Definition at line 49 of file EgammaRecHitIsolation.h.

References ecalBarHits_, severitiesexcl_, and python.multivaluedict::sort().

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

50  {
51  ecalBarHits_ = recHits;
52  severitiesexcl_.clear();
53  severitiesexcl_.insert(severitiesexcl_.begin(), v.begin(), v.end());
55  }
std::vector< int > severitiesexcl_
const EcalRecHitCollection * ecalBarHits_
mathSSE::Vec4< T > v
double EgammaRecHitIsolation::getEnergySum ( const reco::Candidate emObject) const
inline

Definition at line 42 of file EgammaRecHitIsolation.h.

References getSum_().

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

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

Definition at line 45 of file EgammaRecHitIsolation.h.

References getSum_().

45 { 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 44 of file EgammaRecHitIsolation.h.

References getSum_().

44 {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(), cond::rpcobgas::detid, ecalBarHits_, eLow_, CaloRecHitMetaCollectionV::end(), CaloRecHit::energy(), relval_parameters_module::energy, CastorDataFrameFilter_impl::energySum(), PV3DBase< T, PVType, FrameType >::eta(), eta(), etaSlice_, etLow_, extRadius_, spr::find(), CaloRecHitMetaCollectionV::find(), flags_, reco::Candidate::get(), edm::Ref< C, T, F >::get(), CaloSubdetectorGeometry::getCells(), i, intRadius_, j, PV3DBase< T, PVType, FrameType >::mag(), PV3DBase< T, PVType, FrameType >::perp(), phi, PV3DBase< T, PVType, FrameType >::phi(), position, edm::ESHandle< class >::product(), diffTwoXMLs::r2, severitiesexcl_, EcalSeverityLevelAlgo::severityLevel(), sevLevel_, mathSSE::sqrt(), subdet_, theCaloGeom_, useNumCrystals_, and vetoClustered_.

Referenced by getEnergySum(), and getEtSum().

69  {
70 
71  double energySum = 0.;
72  if (caloHits_){
73  //Take the SC position
75  math::XYZPoint theCaloPosition = sc.get()->position();
76  GlobalPoint pclu (theCaloPosition.x () ,
77  theCaloPosition.y () ,
78  theCaloPosition.z () );
79  double etaclus = pclu.eta();
80  double phiclus = pclu.phi();
81  double 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  CaloSubdetectorGeometry::DetIdSet chosen = subdet_[subdetnr]->getCells(pclu,extRadius_);// select cells around cluster
88  for (CaloSubdetectorGeometry::DetIdSet::const_iterator i = chosen.begin ();i != chosen.end (); ++i){ //loop selected cells
89  j = caloHits_->find(*i); // find selected cell among rechits
90  if(j != caloHits_->end()) { // add rechit only if available
91  const GlobalPoint & position = theCaloGeom_.product()->getPosition(*i);
92  double eta = position.eta();
93  double phi = position.phi();
94  double etaDiff = eta - etaclus;
95  double phiDiff= reco::deltaPhi(phi,phiclus);
96  double energy = j->energy();
97 
98  if(useNumCrystals_) {
99  if(fabs(etaclus) < 1.479) { // Barrel num crystals, crystal width = 0.0174
100  if (fabs(etaDiff) < 0.0174*etaSlice_)
101  continue;
102  if (sqrt(etaDiff*etaDiff + phiDiff*phiDiff) < 0.0174*intRadius_)
103  continue;
104  } else { // Endcap num crystals, crystal width = 0.00864*fabs(sinh(eta))
105  if (fabs(etaDiff) < 0.00864*fabs(sinh(eta))*etaSlice_)
106  continue;
107  if (sqrt(etaDiff*etaDiff + phiDiff*phiDiff) < 0.00864*fabs(sinh(eta))*intRadius_)
108  continue;
109  }
110  } else {
111  if (fabs(etaDiff) < etaSlice_)
112  continue; // jurassic strip cut
113  if (etaDiff*etaDiff + phiDiff*phiDiff < r2)
114  continue; // jurassic exclusion cone cut
115  }
116  //Check if RecHit is in SC
117  if(vetoClustered_) {
118 
119  //Loop over basic clusters:
120  bool isClustered = false;
121  for(reco::CaloCluster_iterator bcIt = sc->clustersBegin();bcIt != sc->clustersEnd(); ++bcIt) {
122  for(rhIt = (*bcIt)->hitsAndFractions().begin();rhIt != (*bcIt)->hitsAndFractions().end(); ++rhIt) {
123  if(rhIt->first == *i)
124  isClustered = true;
125  if(isClustered)
126  break;
127  }
128 
129  if(isClustered)
130  break;
131  } //end loop over basic clusters
132 
133  if(isClustered)
134  continue;
135  } //end if removeClustered
136 
137 
138 
139 
140  //std::cout << "detid " << ((EcalRecHit*)(&*j))->detid() << std::endl;
141  int severityFlag = ecalBarHits_ == 0 ? -1 : sevLevel_->severityLevel(((EcalRecHit*)(&*j))->detid(), *ecalBarHits_);
142  std::vector<int>::const_iterator sit = std::find(severitiesexcl_.begin(),
143  severitiesexcl_.end(),
144  severityFlag);
145 
146  if (sit!= severitiesexcl_.end())
147  continue;
148 
149  std::vector<int>::const_iterator vit = std::find(flags_.begin(),
150  flags_.end(),
151  ((EcalRecHit*)(&*j))->recoFlag());
152  if (vit != flags_.end())
153  continue;
154 
155 
156 
157 
158 
159 
160 
161 
162 
163  double et = energy*position.perp()/position.mag();
164  if ( et > etLow_ && energy > eLow_) { //Changed energy --> fabs(energy) - now changed back to energy
165  if(returnEt)
166  energySum += et;
167  else
168  energySum += energy;
169  }
170 
171  } //End if not end of list
172  } //End loop over rechits
173  } //End loop over barrel/endcap
174  } //End if caloHits_
175 
176  return energySum;
177 }
virtual const_iterator find(const DetId &id) const
find by id (default version is very slow unsorted find)
int i
Definition: DBlmapReader.cc:9
const CaloSubdetectorGeometry * subdet_[2]
edm::ESHandle< CaloGeometry > theCaloGeom_
std::vector< int > flags_
CaloRecHitMetaCollectionV * caloHits_
T perp() const
Definition: PV3DBase.h:71
Geom::Phi< T > phi() const
Definition: PV3DBase.h:68
std::vector< int > severitiesexcl_
T eta() const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
const_iterator end() const
get the ending iterator
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:66
float energy() const
Definition: CaloRecHit.h:19
T sqrt(T t)
Definition: SSEVec.h:46
int j
Definition: DBlmapReader.cc:9
const EcalRecHitCollection * ecalBarHits_
double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:12
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
T const * product() const
Definition: ESHandle.h:62
T eta() const
Definition: PV3DBase.h:75
static int position[264][3]
Definition: ReadPGInfo.cc:509
T get() const
get a component
Definition: Candidate.h:216
const EcalSeverityLevelAlgo * sevLevel_
double energySum(const DataFrame &df, int fs, int ls)
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:242
EcalSeverityLevel::SeverityLevel severityLevel(const DetId &id, const EcalRecHitCollection &rhs) const
Evaluate status from id.
Definition: DDAxes.h:10
double EgammaRecHitIsolation::getSum_ ( const reco::SuperCluster sc,
bool  returnEt 
) const
private

Definition at line 181 of file EgammaRecHitIsolation.cc.

References caloHits_, reco::SuperCluster::clustersBegin(), reco::SuperCluster::clustersEnd(), reco::deltaPhi(), cond::rpcobgas::detid, ecalBarHits_, eLow_, CaloRecHitMetaCollectionV::end(), CaloRecHit::energy(), relval_parameters_module::energy, CastorDataFrameFilter_impl::energySum(), PV3DBase< T, PVType, FrameType >::eta(), eta(), etaSlice_, etLow_, extRadius_, spr::find(), CaloRecHitMetaCollectionV::find(), flags_, CaloSubdetectorGeometry::getCells(), i, intRadius_, j, 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_, mathSSE::sqrt(), subdet_, theCaloGeom_, useNumCrystals_, and vetoClustered_.

181  {
182 
183  double energySum = 0.;
184  if (caloHits_){
185  //Take the SC position
186 
187  math::XYZPoint theCaloPosition = sc->position();
188  GlobalPoint pclu (theCaloPosition.x () ,
189  theCaloPosition.y () ,
190  theCaloPosition.z () );
191  double etaclus = pclu.eta();
192  double phiclus = pclu.phi();
193  double r2 = intRadius_*intRadius_;
194 
195  std::vector< std::pair<DetId, float> >::const_iterator rhIt;
196 
197 
198  for(int subdetnr=0; subdetnr<=1 ; subdetnr++){ // look in barrel and endcap
199  CaloSubdetectorGeometry::DetIdSet chosen = subdet_[subdetnr]->getCells(pclu,extRadius_);// select cells around cluster
201  for (CaloSubdetectorGeometry::DetIdSet::const_iterator i = chosen.begin ();i!= chosen.end ();++i){//loop selected cells
202 
203  j=caloHits_->find(*i); // find selected cell among rechits
204  if( j!=caloHits_->end()){ // add rechit only if available
205  const GlobalPoint & position = theCaloGeom_.product()->getPosition(*i);
206  double eta = position.eta();
207  double phi = position.phi();
208  double etaDiff = eta - etaclus;
209  double phiDiff= reco::deltaPhi(phi,phiclus);
210  double energy = j->energy();
211 
212  if(useNumCrystals_) {
213  if( fabs(etaclus) < 1.479 ) { // Barrel num crystals, crystal width = 0.0174
214  if ( fabs(etaDiff) < 0.0174*etaSlice_) continue;
215  if ( sqrt(etaDiff*etaDiff + phiDiff*phiDiff) < 0.0174*intRadius_) continue;
216  } else { // Endcap num crystals, crystal width = 0.00864*fabs(sinh(eta))
217  if ( fabs(etaDiff) < 0.00864*fabs(sinh(eta))*etaSlice_) continue;
218  if ( sqrt(etaDiff*etaDiff + phiDiff*phiDiff) < 0.00864*fabs(sinh(eta))*intRadius_) continue;
219  }
220  } else {
221  if ( fabs(etaDiff) < etaSlice_) continue; // jurassic strip cut
222  if ( etaDiff*etaDiff + phiDiff*phiDiff < r2) continue; // jurassic exclusion cone cut
223  }
224 
225  //Check if RecHit is in SC
226  if(vetoClustered_) {
227 
228  //Loop over basic clusters:
229  bool isClustered = false;
230  for(reco::CaloCluster_iterator bcIt = sc->clustersBegin();bcIt != sc->clustersEnd(); ++bcIt) {
231  for(rhIt = (*bcIt)->hitsAndFractions().begin();rhIt != (*bcIt)->hitsAndFractions().end(); ++rhIt) {
232  if( rhIt->first == *i ) isClustered = true;
233  if( isClustered ) break;
234  }
235  if( isClustered ) break;
236  } //end loop over basic clusters
237 
238  if(isClustered) continue;
239  } //end if removeClustered
240 
241 
242  int severityFlag = sevLevel_->severityLevel(((EcalRecHit*)(&*j))->detid(), *ecalBarHits_);
243  std::vector<int>::const_iterator sit = std::find(severitiesexcl_.begin(),
244  severitiesexcl_.end(),
245  severityFlag);
246 
247  if (sit!= severitiesexcl_.end())
248  continue;
249 
250 
251 
252  //if( severitiesexcl_!=-1 && ecalBarHits_ &&
253  // sevLevel_->severityLevel(EBDetId(j->detid()), *ecalBarHits_) >= severitiesexcl_)
254  // continue;
255 
256  std::vector<int>::const_iterator vit = std::find(flags_.begin(),
257  flags_.end(),
258  ((EcalRecHit*)(&*j))->recoFlag());
259  if (vit != flags_.end())
260  continue;
261 
262 
263 
264  double et = energy*position.perp()/position.mag();
265  if ( et > etLow_ && energy > eLow_){ //Changed energy --> fabs(energy) -- then changed into energy
266  if(returnEt) energySum+=et;
267  else energySum+=energy;
268  }
269 
270  } //End if not end of list
271  } //End loop over rechits
272  } //End loop over barrel/endcap
273  } //End if caloHits_
274 
275  return energySum;
276 }
virtual const_iterator find(const DetId &id) const
find by id (default version is very slow unsorted find)
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:123
int i
Definition: DBlmapReader.cc:9
const CaloSubdetectorGeometry * subdet_[2]
edm::ESHandle< CaloGeometry > theCaloGeom_
std::vector< int > flags_
CaloRecHitMetaCollectionV * caloHits_
T perp() const
Definition: PV3DBase.h:71
Geom::Phi< T > phi() const
Definition: PV3DBase.h:68
std::vector< int > severitiesexcl_
T eta() const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
const_iterator end() const
get the ending iterator
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:66
float energy() const
Definition: CaloRecHit.h:19
T sqrt(T t)
Definition: SSEVec.h:46
int j
Definition: DBlmapReader.cc:9
const EcalRecHitCollection * ecalBarHits_
double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:12
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
T const * product() const
Definition: ESHandle.h:62
T eta() const
Definition: PV3DBase.h:75
static int position[264][3]
Definition: ReadPGInfo.cc:509
CaloCluster_iterator clustersBegin() const
fist iterator over BasicCluster constituents
Definition: SuperCluster.h:65
const EcalSeverityLevelAlgo * sevLevel_
double energySum(const DataFrame &df, int fs, int ls)
EcalSeverityLevel::SeverityLevel severityLevel(const DetId &id, const EcalRecHitCollection &rhs) const
Evaluate status from id.
CaloCluster_iterator clustersEnd() const
last iterator over BasicCluster constituents
Definition: SuperCluster.h:68
Definition: DDAxes.h:10
void EgammaRecHitIsolation::setUseNumCrystals ( bool  b = true)
inline
void EgammaRecHitIsolation::setVetoClustered ( bool  b = true)
inline

Member Data Documentation

CaloRecHitMetaCollectionV* EgammaRecHitIsolation::caloHits_
private

Definition at line 78 of file EgammaRecHitIsolation.h.

Referenced by getSum_().

const EcalRecHitCollection* EgammaRecHitIsolation::ecalBarHits_
private

Definition at line 83 of file EgammaRecHitIsolation.h.

Referenced by doSeverityChecks(), and getSum_().

double EgammaRecHitIsolation::eLow_
private

Definition at line 74 of file EgammaRecHitIsolation.h.

Referenced by getSum_().

double EgammaRecHitIsolation::etaSlice_
private

Definition at line 72 of file EgammaRecHitIsolation.h.

Referenced by getSum_().

double EgammaRecHitIsolation::etLow_
private

Definition at line 73 of file EgammaRecHitIsolation.h.

Referenced by getSum_().

double EgammaRecHitIsolation::extRadius_
private

Definition at line 70 of file EgammaRecHitIsolation.h.

Referenced by getSum_().

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

Definition at line 90 of file EgammaRecHitIsolation.h.

Referenced by doFlagChecks(), and getSum_().

double EgammaRecHitIsolation::intRadius_
private

Definition at line 71 of file EgammaRecHitIsolation.h.

Referenced by getSum_().

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

Definition at line 85 of file EgammaRecHitIsolation.h.

Referenced by doSeverityChecks(), and getSum_().

const EcalSeverityLevelAlgo* EgammaRecHitIsolation::sevLevel_
private

Definition at line 79 of file EgammaRecHitIsolation.h.

Referenced by getSum_().

const CaloSubdetectorGeometry* EgammaRecHitIsolation::subdet_[2]
private

Definition at line 92 of file EgammaRecHitIsolation.h.

Referenced by EgammaRecHitIsolation(), and getSum_().

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

Definition at line 77 of file EgammaRecHitIsolation.h.

Referenced by EgammaRecHitIsolation(), and getSum_().

bool EgammaRecHitIsolation::useNumCrystals_
private

Definition at line 81 of file EgammaRecHitIsolation.h.

Referenced by getSum_(), and setUseNumCrystals().

bool EgammaRecHitIsolation::vetoClustered_
private

Definition at line 82 of file EgammaRecHitIsolation.h.

Referenced by getSum_(), and setVetoClustered().