CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
egammaisolation::EgammaRecHitExtractor Class Reference
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_
 
edm::ESGetToken< CaloGeometry, CaloGeometryRecordgeometryToken_
 
double intRadius_
 
double intStrip_
 
bool sameTag_
 
std::vector< int > severitiesexclEB_
 
std::vector< int > severitiesexclEE_
 
edm::ESGetToken< EcalSeverityLevelAlgo, EcalSeverityLevelAlgoRcdsevlvToken_
 
bool tryBoth_
 
bool useEt_
 
bool vetoClustered_
 

Detailed Description

Definition at line 43 of file EgammaRecHitExtractor.cc.

Constructor & Destructor Documentation

◆ EgammaRecHitExtractor() [1/2]

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

Definition at line 45 of file EgammaRecHitExtractor.cc.

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

◆ EgammaRecHitExtractor() [2/2]

EgammaRecHitExtractor::EgammaRecHitExtractor ( const edm::ParameterSet par,
edm::ConsumesCollector iC 
)

Definition at line 107 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_.

108  : etMin_(par.getParameter<double>("etMin")),
109  energyMin_(par.getParameter<double>("energyMin")),
110  extRadius_(par.getParameter<double>("extRadius")),
111  intRadius_(par.getParameter<double>("intRadius")),
112  intStrip_(par.getParameter<double>("intStrip")),
113  barrelEcalHitsTag_(par.getParameter<edm::InputTag>("barrelEcalHits")),
114  endcapEcalHitsTag_(par.getParameter<edm::InputTag>("endcapEcalHits")),
118  sevlvToken_(iC.esConsumes()),
119  fakeNegativeDeposit_(par.getParameter<bool>("subtractSuperClusterEnergy")),
120  tryBoth_(par.getParameter<bool>("tryBoth")),
121  vetoClustered_(par.getParameter<bool>("vetoClustered")),
122  sameTag_(false)
123 //severityLevelCut_(par.getParameter<int>("severityLevelCut"))
124 //severityRecHitThreshold_(par.getParameter<double>("severityRecHitThreshold")),
125 //spIdString_(par.getParameter<std::string>("spikeIdString")),
126 //spIdThreshold_(par.getParameter<double>("spikeIdThreshold")),
127 {
128  const std::vector<std::string> flagnamesEB = par.getParameter<std::vector<std::string> >("RecHitFlagToBeExcludedEB");
129 
130  const std::vector<std::string> flagnamesEE = par.getParameter<std::vector<std::string> >("RecHitFlagToBeExcludedEE");
131 
132  flagsexclEB_ = StringToEnumValue<EcalRecHit::Flags>(flagnamesEB);
133 
134  flagsexclEE_ = StringToEnumValue<EcalRecHit::Flags>(flagnamesEE);
135 
136  const std::vector<std::string> severitynamesEB =
137  par.getParameter<std::vector<std::string> >("RecHitSeverityToBeExcludedEB");
138 
139  severitiesexclEB_ = StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEB);
140 
141  const std::vector<std::string> severitynamesEE =
142  par.getParameter<std::vector<std::string> >("RecHitSeverityToBeExcludedEE");
143 
144  severitiesexclEE_ = StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEE);
145 
146  if ((intRadius_ != 0.0) && (fakeNegativeDeposit_)) {
147  throw cms::Exception("Configuration Error") << "EgammaRecHitExtractor: "
148  << "If you use 'subtractSuperClusterEnergy', you *must* set "
149  "'intRadius' to ZERO; it does not make sense, otherwise.";
150  }
151  std::string isoVariable = par.getParameter<std::string>("isolationVariable");
152  if (isoVariable == "et") {
153  useEt_ = true;
154  } else if (isoVariable == "energy") {
155  useEt_ = false;
156  } else {
157  throw cms::Exception("Configuration Error")
158  << "EgammaRecHitExtractor: isolationVariable '" << isoVariable << "' not known. "
159  << " Supported values are 'et', 'energy'. ";
160  }
162  sameTag_ = true;
163  if (tryBoth_) {
164  edm::LogWarning("EgammaRecHitExtractor")
165  << "If you have configured 'barrelRecHits' == 'endcapRecHits', so I'm switching 'tryBoth' to FALSE.";
166  tryBoth_ = false;
167  }
168  }
169 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::string encode() const
Definition: InputTag.cc:159
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geometryToken_
edm::EDGetTokenT< EcalRecHitCollection > endcapEcalHitsToken_
edm::EDGetTokenT< EcalRecHitCollection > barrelEcalHitsToken_
edm::ESGetToken< EcalSeverityLevelAlgo, EcalSeverityLevelAlgoRcd > sevlvToken_
Log< level::Warning, false > LogWarning

◆ ~EgammaRecHitExtractor()

EgammaRecHitExtractor::~EgammaRecHitExtractor ( )
override

Definition at line 171 of file EgammaRecHitExtractor.cc.

171 {}

Member Function Documentation

◆ collect()

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 217 of file EgammaRecHitExtractor.cc.

References reco::IsoDeposit::addDeposit(), Reference_intrackfit_cff::barrel, reco::deltaPhi(), deposit(), hcalRecHitTable_cff::energy, energyMin_, l1tnanotables_cff::et, PVValHelper::eta, etMin_, extRadius_, spr::find(), flagsexclEB_, flagsexclEE_, CaloSubdetectorGeometry::getCells(), CaloGeometry::getPosition(), hfClusterShapes_cfi::hits, mps_fire::i, intRadius_, intStrip_, dqmiolumiharvest::j, EcalRecHit::kGood, position, diffTwoXMLs::r2, severitiesexclEB_, severitiesexclEE_, EcalSeverityLevelAlgo::severityLevel(), useEt_, and vetoClustered_.

Referenced by deposit().

224  {
225  GlobalPoint caloPosition(sc->position().x(), sc->position().y(), sc->position().z());
226  CaloSubdetectorGeometry::DetIdSet chosen = subdet->getCells(caloPosition, extRadius_);
228  double caloeta = caloPosition.eta();
229  double calophi = caloPosition.phi();
230  double r2 = intRadius_ * intRadius_;
231 
232  std::vector<std::pair<DetId, float> >::const_iterator rhIt;
233 
234  for (CaloSubdetectorGeometry::DetIdSet::const_iterator i = chosen.begin(), end = chosen.end(); i != end; ++i) {
235  j = hits.find(*i);
236  if (j != hits.end()) {
237  const GlobalPoint& position = caloGeom->getPosition(*i);
238  double eta = position.eta();
239  double phi = position.phi();
240  double energy = j->energy();
241  double et = energy * position.perp() / position.mag();
242  double phiDiff = reco::deltaPhi(phi, calophi);
243 
244  //check if we are supposed to veto clustered and then do so
245  if (vetoClustered_) {
246  //Loop over basic clusters:
247  bool isClustered = false;
248  for (auto bcIt = sc->clustersBegin(); bcIt != sc->clustersEnd(); ++bcIt) {
249  for (rhIt = (*bcIt)->hitsAndFractions().begin(); rhIt != (*bcIt)->hitsAndFractions().end(); ++rhIt) {
250  if (rhIt->first == *i)
251  isClustered = true;
252  if (isClustered)
253  break;
254  }
255  if (isClustered)
256  break;
257  } //end loop over basic clusters
258 
259  if (isClustered)
260  continue;
261  } //end if removeClustered
262 
263  std::vector<int>::const_iterator sit;
264  int severityFlag = sevLevel->severityLevel(j->detid(), hits);
265  if (barrel) {
266  sit = std::find(severitiesexclEB_.begin(), severitiesexclEB_.end(), severityFlag);
267  if (sit != severitiesexclEB_.end())
268  continue;
269  } else {
270  sit = std::find(severitiesexclEE_.begin(), severitiesexclEE_.end(), severityFlag);
271  if (sit != severitiesexclEE_.end())
272  continue;
273  }
274 
275  if (barrel) {
276  // new rechit flag checks
277  if (!j->checkFlag(EcalRecHit::kGood)) {
278  if (j->checkFlags(flagsexclEB_)) {
279  continue;
280  }
281  }
282  } else {
283  // new rechit flag checks
284  if (!j->checkFlag(EcalRecHit::kGood)) {
285  if (j->checkFlags(flagsexclEE_)) {
286  continue;
287  }
288  }
289  }
290 
291  if (et > etMin_ && energy > energyMin_ //Changed to fabs - then changed back to energy
292  && fabs(eta - caloeta) > intStrip_ && (eta - caloeta) * (eta - caloeta) + phiDiff * phiDiff > r2) {
294  }
295  }
296  }
297 }
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
reco::IsoDeposit deposit(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Track &track) const override
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:19
void addDeposit(double dr, double deposit)
Add deposit (ie. transverse energy or pT)
Definition: IsoDeposit.cc:19
EcalSeverityLevel::SeverityLevel severityLevel(const DetId &id) const
Evaluate status from id use channelStatus from DB.
virtual DetIdSet getCells(const GlobalPoint &r, double dR) const
Get a list of all cells within a dR of the given cell.
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:50
static int position[264][3]
Definition: ReadPGInfo.cc:289

◆ deposit() [1/2]

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 50 of file EgammaRecHitExtractor.cc.

References Exception, and Skims_PA_cff::name.

Referenced by collect(), and deposit().

52  {
53  throw cms::Exception("Configuration Error")
54  << "This extractor " << (typeid(this).name()) << " is not made for tracks";
55  }

◆ deposit() [2/2]

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 173 of file EgammaRecHitExtractor.cc.

References funct::abs(), reco::IsoDeposit::addCandEnergy(), reco::IsoDeposit::addDeposit(), barrelEcalHitsToken_, collect(), deposit(), DetId::Ecal, EcalBarrel, EcalEndcap, endcapEcalHitsToken_, JetChargeProducer_cfi::exp, fakeNegativeDeposit_, geometryToken_, reco::Candidate::get(), edm::EventSetup::getData(), CaloGeometry::getSubdetectorGeometry(), iEvent, intRadius_, metname, sameTag_, reco::IsoDeposit::setVeto(), sevlvToken_, funct::sin(), AlCaHLTBitMon_QueryRunRegistry::string, tryBoth_, and useEt_.

175  {
176  //Get the channel status from the db
177  //edm::ESHandle<EcalChannelStatus> chStatus;
178  //iSetup.get<EcalChannelStatusRcd>().get(chStatus);
179 
180  const EcalSeverityLevelAlgo* sevLevel = &iSetup.getData(sevlvToken_);
181 
182  const CaloGeometry* caloGeom = &iSetup.getData(geometryToken_);
185 
186  static const std::string metname = "EgammaIsolationAlgos|EgammaRecHitExtractor";
187 
188  //define isodeposit starting from candidate
190  math::XYZPoint caloPosition = sc->position();
191 
192  Direction candDir(caloPosition.eta(), caloPosition.phi());
193  reco::IsoDeposit deposit(candDir);
195  double sinTheta = sin(2 * atan(exp(-sc->eta())));
196  deposit.addCandEnergy(sc->energy() * (useEt_ ? sinTheta : 1.0));
197 
198  // subtract supercluster if desired
199  double fakeEnergy = -sc->rawEnergy();
200  if (fakeNegativeDeposit_) {
201  deposit.addDeposit(candDir, fakeEnergy * (useEt_ ? sinTheta : 1.0)); // not exactly clean...
202  }
203 
204  // fill rechits
205  bool inBarrel = sameTag_ || (abs(sc->eta()) < 1.479); //check for barrel. If only one collection is used, use barrel
206  if (inBarrel || tryBoth_) {
207  collect(deposit, sc, barrelgeom, caloGeom, iEvent.get(barrelEcalHitsToken_), sevLevel, true);
208  }
209 
210  if ((!inBarrel) || tryBoth_) {
211  collect(deposit, sc, endcapgeom, caloGeom, iEvent.get(endcapEcalHitsToken_), sevLevel, false);
212  }
213 
214  return deposit;
215 }
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:82
const std::string metname
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
void addDeposit(double dr, double deposit)
Add deposit (ie. transverse energy or pT)
Definition: IsoDeposit.cc:19
int iEvent
Definition: GenABIO.cc:224
void addCandEnergy(double et)
Set energy or pT attached to cand trajectory.
Definition: IsoDeposit.h:132
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
void collect(reco::IsoDeposit &deposit, const reco::SuperClusterRef &sc, const CaloSubdetectorGeometry *subdet, const CaloGeometry *caloGeom, const EcalRecHitCollection &hits, const EcalSeverityLevelAlgo *sevLevel, bool barrel) const
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geometryToken_
edm::EDGetTokenT< EcalRecHitCollection > endcapEcalHitsToken_
edm::EDGetTokenT< EcalRecHitCollection > barrelEcalHitsToken_
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
edm::ESGetToken< EcalSeverityLevelAlgo, EcalSeverityLevelAlgoRcd > sevlvToken_
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34

◆ fillVetos()

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 48 of file EgammaRecHitExtractor.cc.

48  {
49  }

Member Data Documentation

◆ barrelEcalHitsTag_

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

Definition at line 75 of file EgammaRecHitExtractor.cc.

Referenced by EgammaRecHitExtractor().

◆ barrelEcalHitsToken_

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

Definition at line 77 of file EgammaRecHitExtractor.cc.

Referenced by deposit().

◆ endcapEcalHitsTag_

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

Definition at line 76 of file EgammaRecHitExtractor.cc.

Referenced by EgammaRecHitExtractor().

◆ endcapEcalHitsToken_

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

Definition at line 78 of file EgammaRecHitExtractor.cc.

Referenced by deposit().

◆ energyMin_

double egammaisolation::EgammaRecHitExtractor::energyMin_
private

Definition at line 71 of file EgammaRecHitExtractor.cc.

Referenced by collect().

◆ etMin_

double egammaisolation::EgammaRecHitExtractor::etMin_
private

Definition at line 70 of file EgammaRecHitExtractor.cc.

Referenced by collect().

◆ extRadius_

double egammaisolation::EgammaRecHitExtractor::extRadius_
private

Definition at line 72 of file EgammaRecHitExtractor.cc.

Referenced by collect().

◆ fakeNegativeDeposit_

bool egammaisolation::EgammaRecHitExtractor::fakeNegativeDeposit_
private

Definition at line 81 of file EgammaRecHitExtractor.cc.

Referenced by deposit(), and EgammaRecHitExtractor().

◆ flagsexclEB_

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

Definition at line 94 of file EgammaRecHitExtractor.cc.

Referenced by collect(), and EgammaRecHitExtractor().

◆ flagsexclEE_

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

Definition at line 95 of file EgammaRecHitExtractor.cc.

Referenced by collect(), and EgammaRecHitExtractor().

◆ geometryToken_

edm::ESGetToken<CaloGeometry, CaloGeometryRecord> egammaisolation::EgammaRecHitExtractor::geometryToken_
private

Definition at line 79 of file EgammaRecHitExtractor.cc.

Referenced by deposit().

◆ intRadius_

double egammaisolation::EgammaRecHitExtractor::intRadius_
private

Definition at line 73 of file EgammaRecHitExtractor.cc.

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

◆ intStrip_

double egammaisolation::EgammaRecHitExtractor::intStrip_
private

Definition at line 74 of file EgammaRecHitExtractor.cc.

Referenced by collect().

◆ sameTag_

bool egammaisolation::EgammaRecHitExtractor::sameTag_
private

Definition at line 85 of file EgammaRecHitExtractor.cc.

Referenced by deposit(), and EgammaRecHitExtractor().

◆ severitiesexclEB_

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

Definition at line 92 of file EgammaRecHitExtractor.cc.

Referenced by collect(), and EgammaRecHitExtractor().

◆ severitiesexclEE_

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

Definition at line 93 of file EgammaRecHitExtractor.cc.

Referenced by collect(), and EgammaRecHitExtractor().

◆ sevlvToken_

edm::ESGetToken<EcalSeverityLevelAlgo, EcalSeverityLevelAlgoRcd> egammaisolation::EgammaRecHitExtractor::sevlvToken_
private

Definition at line 80 of file EgammaRecHitExtractor.cc.

Referenced by deposit().

◆ tryBoth_

bool egammaisolation::EgammaRecHitExtractor::tryBoth_
private

Definition at line 82 of file EgammaRecHitExtractor.cc.

Referenced by deposit(), and EgammaRecHitExtractor().

◆ useEt_

bool egammaisolation::EgammaRecHitExtractor::useEt_
private

Definition at line 83 of file EgammaRecHitExtractor.cc.

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

◆ vetoClustered_

bool egammaisolation::EgammaRecHitExtractor::vetoClustered_
private

Definition at line 84 of file EgammaRecHitExtractor.cc.

Referenced by collect().