CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
egammaisolation::EgammaRecHitExtractor Class Reference

#include <EgammaRecHitExtractor.h>

Inheritance diagram for egammaisolation::EgammaRecHitExtractor:
reco::isodeposit::IsoDepositExtractor

Public Member Functions

reco::IsoDeposit deposit (const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Track &track) const override
 
reco::IsoDeposit deposit (const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Candidate &c) const override
 
 EgammaRecHitExtractor (const edm::ParameterSet &par, edm::ConsumesCollector &&iC)
 
 EgammaRecHitExtractor (const edm::ParameterSet &par, edm::ConsumesCollector &iC)
 
void fillVetos (const edm::Event &ev, const edm::EventSetup &evSetup, const reco::TrackCollection &tracks) override
 
 ~EgammaRecHitExtractor () override
 
- Public Member Functions inherited from reco::isodeposit::IsoDepositExtractor
virtual reco::IsoDeposit deposit (const edm::Event &ev, const edm::EventSetup &evSetup, const reco::TrackBaseRef &track) const
 make single IsoDeposit based on trackRef as input More...
 
virtual reco::IsoDeposit deposit (const edm::Event &ev, const edm::EventSetup &evSetup, const reco::CandidateBaseRef &track) const
 make single IsoDeposit based on a CandidateBaseRef as input More...
 
virtual std::vector< reco::IsoDepositdeposits (const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Track &track) const
 
virtual std::vector< reco::IsoDepositdeposits (const edm::Event &ev, const edm::EventSetup &evSetup, const reco::TrackBaseRef &track) const
 
virtual std::vector< reco::IsoDepositdeposits (const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Candidate &track) const
 
virtual std::vector< reco::IsoDepositdeposits (const edm::Event &ev, const edm::EventSetup &evSetup, const reco::CandidateBaseRef &track) const
 
virtual void initEvent (const edm::Event &, const edm::EventSetup &)
 perform some constly initialization More...
 
virtual ~IsoDepositExtractor ()
 Destructor. More...
 

Private Member Functions

void collect (reco::IsoDeposit &deposit, const reco::SuperClusterRef &sc, const CaloSubdetectorGeometry *subdet, const CaloGeometry *caloGeom, const EcalRecHitCollection &hits, const EcalSeverityLevelAlgo *sevLevel, bool barrel) const
 

Private Attributes

edm::InputTag barrelEcalHitsTag_
 
edm::EDGetTokenT< EcalRecHitCollectionbarrelEcalHitsToken_
 
edm::InputTag endcapEcalHitsTag_
 
edm::EDGetTokenT< EcalRecHitCollectionendcapEcalHitsToken_
 
double energyMin_
 
double etMin_
 
double extRadius_
 
bool fakeNegativeDeposit_
 
std::vector< int > flagsexclEB_
 
std::vector< int > flagsexclEE_
 
double intRadius_
 
double intStrip_
 
bool sameTag_
 
std::vector< int > severitiesexclEB_
 
std::vector< int > severitiesexclEE_
 
bool tryBoth_
 
bool useEt_
 
bool vetoClustered_
 

Detailed Description

Definition at line 41 of file EgammaRecHitExtractor.h.

Constructor & Destructor Documentation

egammaisolation::EgammaRecHitExtractor::EgammaRecHitExtractor ( const edm::ParameterSet par,
edm::ConsumesCollector &&  iC 
)
inline

Definition at line 43 of file EgammaRecHitExtractor.h.

References ~EgammaRecHitExtractor().

43  :
44  EgammaRecHitExtractor(par, iC) {}
EgammaRecHitExtractor(const edm::ParameterSet &par, edm::ConsumesCollector &&iC)
EgammaRecHitExtractor::EgammaRecHitExtractor ( const edm::ParameterSet par,
edm::ConsumesCollector iC 
)

Definition at line 41 of file EgammaRecHitExtractor.cc.

References barrelEcalHitsTag_, edm::InputTag::encode(), endcapEcalHitsTag_, Exception, fakeNegativeDeposit_, flagsexclEB_, flagsexclEE_, edm::ParameterSet::getParameter(), intRadius_, sameTag_, severitiesexclEB_, severitiesexclEE_, AlCaHLTBitMon_QueryRunRegistry::string, tryBoth_, and useEt_.

41  :
42  etMin_(par.getParameter<double>("etMin")),
43  energyMin_(par.getParameter<double>("energyMin")),
44  extRadius_(par.getParameter<double>("extRadius")),
45  intRadius_(par.getParameter<double>("intRadius")),
46  intStrip_(par.getParameter<double>("intStrip")),
47  barrelEcalHitsTag_(par.getParameter<edm::InputTag>("barrelEcalHits")),
48  endcapEcalHitsTag_(par.getParameter<edm::InputTag>("endcapEcalHits")),
51  fakeNegativeDeposit_(par.getParameter<bool>("subtractSuperClusterEnergy")),
52  tryBoth_(par.getParameter<bool>("tryBoth")),
53  vetoClustered_(par.getParameter<bool>("vetoClustered")),
54  sameTag_(false)
55  //severityLevelCut_(par.getParameter<int>("severityLevelCut"))
56  //severityRecHitThreshold_(par.getParameter<double>("severityRecHitThreshold")),
57  //spIdString_(par.getParameter<std::string>("spikeIdString")),
58  //spIdThreshold_(par.getParameter<double>("spikeIdThreshold")),
59 {
60 
61  const std::vector<std::string> flagnamesEB =
62  par.getParameter<std::vector<std::string> >("RecHitFlagToBeExcludedEB");
63 
64  const std::vector<std::string> flagnamesEE =
65  par.getParameter<std::vector<std::string> >("RecHitFlagToBeExcludedEE");
66 
68  StringToEnumValue<EcalRecHit::Flags>(flagnamesEB);
69 
71  StringToEnumValue<EcalRecHit::Flags>(flagnamesEE);
72 
73  const std::vector<std::string> severitynamesEB =
74  par.getParameter<std::vector<std::string> >("RecHitSeverityToBeExcludedEB");
75 
77  StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEB);
78 
79  const std::vector<std::string> severitynamesEE =
80  par.getParameter<std::vector<std::string> >("RecHitSeverityToBeExcludedEE");
81 
83  StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEE);
84 
85  if ((intRadius_ != 0.0) && (fakeNegativeDeposit_)) {
86  throw cms::Exception("Configuration Error") << "EgammaRecHitExtractor: " <<
87  "If you use 'subtractSuperClusterEnergy', you *must* set 'intRadius' to ZERO; it does not make sense, otherwise.";
88  }
89  std::string isoVariable = par.getParameter<std::string>("isolationVariable");
90  if (isoVariable == "et") {
91  useEt_ = true;
92  } else if (isoVariable == "energy") {
93  useEt_ = false;
94  } else {
95  throw cms::Exception("Configuration Error") << "EgammaRecHitExtractor: isolationVariable '" << isoVariable << "' not known. "
96  << " Supported values are 'et', 'energy'. ";
97  }
99  sameTag_ = true;
100  if (tryBoth_) {
101  edm::LogWarning("EgammaRecHitExtractor") << "If you have configured 'barrelRecHits' == 'endcapRecHits', so I'm switching 'tryBoth' to FALSE.";
102  tryBoth_ = false;
103  }
104  }
105 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
std::string encode() const
Definition: InputTag.cc:166
edm::EDGetTokenT< EcalRecHitCollection > endcapEcalHitsToken_
edm::EDGetTokenT< EcalRecHitCollection > barrelEcalHitsToken_
EgammaRecHitExtractor::~EgammaRecHitExtractor ( )
override

Definition at line 107 of file EgammaRecHitExtractor.cc.

Referenced by EgammaRecHitExtractor().

108 {}

Member Function Documentation

void EgammaRecHitExtractor::collect ( reco::IsoDeposit deposit,
const reco::SuperClusterRef sc,
const CaloSubdetectorGeometry subdet,
const CaloGeometry caloGeom,
const EcalRecHitCollection hits,
const EcalSeverityLevelAlgo sevLevel,
bool  barrel 
) const
private

Definition at line 166 of file EgammaRecHitExtractor.cc.

References reco::IsoDeposit::addDeposit(), reco::deltaPhi(), end, edm::SortedCollection< T, SORT >::end(), energyMin_, stringResolutionProvider_cfi::et, PVValHelper::eta, PV3DBase< T, PVType, FrameType >::eta(), etMin_, extRadius_, spr::find(), edm::SortedCollection< T, SORT >::find(), flagsexclEB_, flagsexclEE_, CaloSubdetectorGeometry::getCells(), CaloGeometry::getPosition(), hfClusterShapes_cfi::hits, mps_fire::i, intRadius_, intStrip_, EcalRecHit::kGood, PV3DBase< T, PVType, FrameType >::mag(), PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), position, diffTwoXMLs::r2, severitiesexclEB_, severitiesexclEE_, EcalSeverityLevelAlgo::severityLevel(), useEt_, and vetoClustered_.

Referenced by deposit().

173  {
174 
175  GlobalPoint caloPosition(sc->position().x(), sc->position().y() , sc->position().z());
176  CaloSubdetectorGeometry::DetIdSet chosen = subdet->getCells(caloPosition,extRadius_);
178  double caloeta=caloPosition.eta();
179  double calophi=caloPosition.phi();
180  double r2 = intRadius_*intRadius_;
181 
182  std::vector< std::pair<DetId, float> >::const_iterator rhIt;
183 
184 
185  for (CaloSubdetectorGeometry::DetIdSet::const_iterator i = chosen.begin(), end = chosen.end() ; i != end; ++i) {
186  j = hits.find(*i);
187  if (j != hits.end()) {
188  const GlobalPoint & position = caloGeom->getPosition(*i);
189  double eta = position.eta();
190  double phi = position.phi();
191  double energy = j->energy();
192  double et = energy*position.perp()/position.mag();
193  double phiDiff= reco::deltaPhi(phi,calophi);
194 
195  //check if we are supposed to veto clustered and then do so
196  if(vetoClustered_) {
197 
198  //Loop over basic clusters:
199  bool isClustered = false;
200  for( reco::CaloCluster_iterator bcIt = sc->clustersBegin();bcIt != sc->clustersEnd(); ++bcIt) {
201  for(rhIt = (*bcIt)->hitsAndFractions().begin();rhIt != (*bcIt)->hitsAndFractions().end(); ++rhIt) {
202  if( rhIt->first == *i ) isClustered = true;
203  if( isClustered ) break;
204  }
205  if( isClustered ) break;
206  } //end loop over basic clusters
207 
208  if(isClustered) continue;
209  } //end if removeClustered
210 
211  std::vector<int>::const_iterator sit;
212  int severityFlag = sevLevel->severityLevel(j->detid(), hits);
213  if (barrel) {
214  sit = std::find(severitiesexclEB_.begin(), severitiesexclEB_.end(), severityFlag);
215  if (sit != severitiesexclEB_.end())
216  continue;
217  } else {
218  sit = std::find(severitiesexclEE_.begin(), severitiesexclEE_.end(), severityFlag);
219  if (sit != severitiesexclEE_.end())
220  continue;
221  }
222 
223  std::vector<int>::const_iterator vit;
224  if (barrel) {
225  // new rechit flag checks
226  //vit = std::find(flagsexclEB_.begin(), flagsexclEB_.end(), j->recoFlag());
227  //if (vit != flagsexclEB_.end())
228  // continue;
229  if (!j->checkFlag(EcalRecHit::kGood)) {
230  if (j->checkFlags(flagsexclEB_)) {
231  continue;
232  }
233  }
234  } else {
235  // new rechit flag checks
236  //vit = std::find(flagsexclEE_.begin(), flagsexclEE_.end(), j->recoFlag());
237  //if (vit != flagsexclEE_.end())
238  // continue;
239  if (!j->checkFlag(EcalRecHit::kGood)) {
240  if (j->checkFlags(flagsexclEE_)) {
241  continue;
242  }
243  }
244  }
245 
246  if(et > etMin_
247  && energy > energyMin_ //Changed to fabs - then changed back to energy
248  && fabs(eta-caloeta) > intStrip_
249  && (eta-caloeta)*(eta-caloeta) + phiDiff*phiDiff >r2 ) {
250 
251  deposit.addDeposit( Direction(eta, phi), (useEt_ ? et : energy));
252  }
253  }
254  }
255 }
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:22
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
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
void addDeposit(double dr, double deposit)
Add deposit (ie. transverse energy or pT)
Definition: IsoDeposit.cc:23
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
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:74
#define end
Definition: vmac.h:39
const_iterator end() const
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
reco::IsoDeposit egammaisolation::EgammaRecHitExtractor::deposit ( const edm::Event ev,
const edm::EventSetup evSetup,
const reco::Track track 
) const
inlineoverridevirtual

make single IsoDeposit based on track as input purely virtual: have to implement in concrete implementations

Implements reco::isodeposit::IsoDepositExtractor.

Definition at line 48 of file EgammaRecHitExtractor.h.

References Reference_intrackfit_cff::barrel, EnergyCorrector::c, collect(), ev, Exception, hfClusterShapes_cfi::hits, dataset::name, and SimDataFormats::CaloAnalysis::sc.

Referenced by deposit().

48  {
49  throw cms::Exception("Configuration Error") << "This extractor " << (typeid(this).name()) << " is not made for tracks";
50  }
reco::IsoDeposit EgammaRecHitExtractor::deposit ( const edm::Event ev,
const edm::EventSetup evSetup,
const reco::Candidate track 
) const
overridevirtual

make single IsoDeposit based on a candidate as input purely virtual: have to implement in concrete implementations

Reimplemented from reco::isodeposit::IsoDepositExtractor.

Definition at line 110 of file EgammaRecHitExtractor.cc.

References funct::abs(), barrelEcalHitsToken_, collect(), deposit(), DetId::Ecal, EcalBarrel, EcalEndcap, endcapEcalHitsToken_, JetChargeProducer_cfi::exp, fakeNegativeDeposit_, edm::EventSetup::get(), reco::Candidate::get(), edm::Event::getByToken(), CaloGeometry::getSubdetectorGeometry(), intRadius_, metname, edm::ESHandle< T >::product(), sameTag_, SimDataFormats::CaloAnalysis::sc, funct::sin(), AlCaHLTBitMon_QueryRunRegistry::string, tryBoth_, and useEt_.

111  {
113  iSetup.get<CaloGeometryRecord>().get(pG);
114 
115  //Get the channel status from the db
116  //edm::ESHandle<EcalChannelStatus> chStatus;
117  //iSetup.get<EcalChannelStatusRcd>().get(chStatus);
118 
120  iSetup.get<EcalSeverityLevelAlgoRcd>().get(sevlv);
121  const EcalSeverityLevelAlgo* sevLevel = sevlv.product();
122 
123  const CaloGeometry* caloGeom = pG.product();
126 
127  static const std::string metname = "EgammaIsolationAlgos|EgammaRecHitExtractor";
128 
129  //Get barrel ECAL RecHits
130  edm::Handle<EcalRecHitCollection> barrelEcalRecHitsH;
131  iEvent.getByToken(barrelEcalHitsToken_, barrelEcalRecHitsH);
132 
133  //Get endcap ECAL RecHits
134  edm::Handle<EcalRecHitCollection> endcapEcalRecHitsH;
135  iEvent.getByToken(endcapEcalHitsToken_, endcapEcalRecHitsH);
136 
137  //define isodeposit starting from candidate
139  math::XYZPoint caloPosition = sc->position();
140 
141  Direction candDir(caloPosition.eta(), caloPosition.phi());
142  reco::IsoDeposit deposit( candDir );
144  double sinTheta = sin(2*atan(exp(-sc->eta())));
145  deposit.addCandEnergy(sc->energy() * (useEt_ ? sinTheta : 1.0)) ;
146 
147  // subtract supercluster if desired
148  double fakeEnergy = -sc->rawEnergy();
149  if (fakeNegativeDeposit_) {
150  deposit.addDeposit(candDir, fakeEnergy * (useEt_ ? sinTheta : 1.0)); // not exactly clean...
151  }
152 
153  // fill rechits
154  bool inBarrel = sameTag_ || ( abs(sc->eta()) < 1.479 ); //check for barrel. If only one collection is used, use barrel
155  if (inBarrel || tryBoth_) {
156  collect(deposit, sc, barrelgeom, caloGeom, *barrelEcalRecHitsH, sevLevel, true);
157  }
158 
159  if ((!inBarrel) || tryBoth_) {
160  collect(deposit, sc, endcapgeom, caloGeom, *endcapEcalRecHitsH, sevLevel, false);
161  }
162 
163  return deposit;
164 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:49
reco::IsoDeposit deposit(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Track &track) const override
void setVeto(const Veto &aVeto)
Set veto.
Definition: IsoDeposit.h:80
const std::string metname
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
void collect(reco::IsoDeposit &deposit, const reco::SuperClusterRef &sc, const CaloSubdetectorGeometry *subdet, const CaloGeometry *caloGeom, const EcalRecHitCollection &hits, const EcalSeverityLevelAlgo *sevLevel, bool barrel) const
void addDeposit(double dr, double deposit)
Add deposit (ie. transverse energy or pT)
Definition: IsoDeposit.cc:23
int iEvent
Definition: GenABIO.cc:230
void addCandEnergy(double et)
Set energy or pT attached to cand trajectory.
Definition: IsoDeposit.h:139
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
edm::EDGetTokenT< EcalRecHitCollection > endcapEcalHitsToken_
edm::EDGetTokenT< EcalRecHitCollection > barrelEcalHitsToken_
T const * product() const
Definition: ESHandle.h:84
void egammaisolation::EgammaRecHitExtractor::fillVetos ( const edm::Event ev,
const edm::EventSetup evSetup,
const reco::TrackCollection tracks 
)
inlineoverridevirtual

fill vetoes: to exclude deposits at IsoDeposit creation stage check concrete extractors if it's no-op !

Implements reco::isodeposit::IsoDepositExtractor.

Definition at line 47 of file EgammaRecHitExtractor.h.

47 { }

Member Data Documentation

edm::InputTag egammaisolation::EgammaRecHitExtractor::barrelEcalHitsTag_
private

Definition at line 67 of file EgammaRecHitExtractor.h.

Referenced by EgammaRecHitExtractor().

edm::EDGetTokenT<EcalRecHitCollection> egammaisolation::EgammaRecHitExtractor::barrelEcalHitsToken_
private

Definition at line 69 of file EgammaRecHitExtractor.h.

Referenced by deposit().

edm::InputTag egammaisolation::EgammaRecHitExtractor::endcapEcalHitsTag_
private

Definition at line 68 of file EgammaRecHitExtractor.h.

Referenced by EgammaRecHitExtractor().

edm::EDGetTokenT<EcalRecHitCollection> egammaisolation::EgammaRecHitExtractor::endcapEcalHitsToken_
private

Definition at line 70 of file EgammaRecHitExtractor.h.

Referenced by deposit().

double egammaisolation::EgammaRecHitExtractor::energyMin_
private

Definition at line 63 of file EgammaRecHitExtractor.h.

Referenced by collect().

double egammaisolation::EgammaRecHitExtractor::etMin_
private

Definition at line 62 of file EgammaRecHitExtractor.h.

Referenced by collect().

double egammaisolation::EgammaRecHitExtractor::extRadius_
private

Definition at line 64 of file EgammaRecHitExtractor.h.

Referenced by collect().

bool egammaisolation::EgammaRecHitExtractor::fakeNegativeDeposit_
private

Definition at line 71 of file EgammaRecHitExtractor.h.

Referenced by deposit(), and EgammaRecHitExtractor().

std::vector<int> egammaisolation::EgammaRecHitExtractor::flagsexclEB_
private

Definition at line 84 of file EgammaRecHitExtractor.h.

Referenced by collect(), and EgammaRecHitExtractor().

std::vector<int> egammaisolation::EgammaRecHitExtractor::flagsexclEE_
private

Definition at line 85 of file EgammaRecHitExtractor.h.

Referenced by collect(), and EgammaRecHitExtractor().

double egammaisolation::EgammaRecHitExtractor::intRadius_
private

Definition at line 65 of file EgammaRecHitExtractor.h.

Referenced by collect(), deposit(), and EgammaRecHitExtractor().

double egammaisolation::EgammaRecHitExtractor::intStrip_
private

Definition at line 66 of file EgammaRecHitExtractor.h.

Referenced by collect().

bool egammaisolation::EgammaRecHitExtractor::sameTag_
private

Definition at line 75 of file EgammaRecHitExtractor.h.

Referenced by deposit(), and EgammaRecHitExtractor().

std::vector<int> egammaisolation::EgammaRecHitExtractor::severitiesexclEB_
private

Definition at line 82 of file EgammaRecHitExtractor.h.

Referenced by collect(), and EgammaRecHitExtractor().

std::vector<int> egammaisolation::EgammaRecHitExtractor::severitiesexclEE_
private

Definition at line 83 of file EgammaRecHitExtractor.h.

Referenced by collect(), and EgammaRecHitExtractor().

bool egammaisolation::EgammaRecHitExtractor::tryBoth_
private

Definition at line 72 of file EgammaRecHitExtractor.h.

Referenced by deposit(), and EgammaRecHitExtractor().

bool egammaisolation::EgammaRecHitExtractor::useEt_
private

Definition at line 73 of file EgammaRecHitExtractor.h.

Referenced by collect(), deposit(), and EgammaRecHitExtractor().

bool egammaisolation::EgammaRecHitExtractor::vetoClustered_
private

Definition at line 74 of file EgammaRecHitExtractor.h.

Referenced by collect().