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

virtual reco::IsoDeposit deposit (const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Track &track) const
 
virtual reco::IsoDeposit deposit (const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Candidate &c) const
 
 EgammaRecHitExtractor (const edm::ParameterSet &par, edm::ConsumesCollector &&iC)
 
 EgammaRecHitExtractor (const edm::ParameterSet &par, edm::ConsumesCollector &iC)
 
virtual void fillVetos (const edm::Event &ev, const edm::EventSetup &evSetup, const reco::TrackCollection &tracks)
 
virtual ~EgammaRecHitExtractor ()
 
- 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:165
edm::EDGetTokenT< EcalRecHitCollection > endcapEcalHitsToken_
edm::EDGetTokenT< EcalRecHitCollection > barrelEcalHitsToken_
EgammaRecHitExtractor::~EgammaRecHitExtractor ( )
virtual

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, stringResolutionProvider_cfi::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().

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

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
virtual

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 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:45
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_
virtual reco::IsoDeposit deposit(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Track &track) const
T const * product() const
Definition: ESHandle.h:86
virtual void egammaisolation::EgammaRecHitExtractor::fillVetos ( const edm::Event ev,
const edm::EventSetup evSetup,
const reco::TrackCollection tracks 
)
inlinevirtual

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().