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
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::IsoDeposit
deposits (const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Track &track) const
 
virtual std::vector
< reco::IsoDeposit
deposits (const edm::Event &ev, const edm::EventSetup &evSetup, const reco::TrackBaseRef &track) const
 
virtual std::vector
< reco::IsoDeposit
deposits (const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Candidate &track) const
 
virtual std::vector
< reco::IsoDeposit
deposits (const edm::Event &ev, const edm::EventSetup &evSetup, const reco::CandidateBaseRef &track) const
 
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
< EcalRecHitCollection
barrelEcalHitsToken_
 
edm::InputTag endcapEcalHitsTag_
 
edm::EDGetTokenT
< EcalRecHitCollection
endcapEcalHitsToken_
 
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 42 of file EgammaRecHitExtractor.h.

Constructor & Destructor Documentation

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

Definition at line 44 of file EgammaRecHitExtractor.h.

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

Definition at line 42 of file EgammaRecHitExtractor.cc.

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

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

Definition at line 108 of file EgammaRecHitExtractor.cc.

109 {}

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

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

Referenced by deposit().

175  {
176 
177  GlobalPoint caloPosition(sc->position().x(), sc->position().y() , sc->position().z());
178  CaloSubdetectorGeometry::DetIdSet chosen = subdet->getCells(caloPosition,extRadius_);
180  double caloeta=caloPosition.eta();
181  double calophi=caloPosition.phi();
182  double r2 = intRadius_*intRadius_;
183 
184  std::vector< std::pair<DetId, float> >::const_iterator rhIt;
185 
186 
187  for (CaloSubdetectorGeometry::DetIdSet::const_iterator i = chosen.begin(), end = chosen.end() ; i != end; ++i) {
188  j = hits.find(*i);
189  if (j != hits.end()) {
190  const GlobalPoint & position = caloGeom->getPosition(*i);
191  double eta = position.eta();
192  double phi = position.phi();
193  double energy = j->energy();
194  double et = energy*position.perp()/position.mag();
195  double phiDiff= reco::deltaPhi(phi,calophi);
196 
197  //check if we are supposed to veto clustered and then do so
198  if(vetoClustered_) {
199 
200  //Loop over basic clusters:
201  bool isClustered = false;
202  for( reco::CaloCluster_iterator bcIt = sc->clustersBegin();bcIt != sc->clustersEnd(); ++bcIt) {
203  for(rhIt = (*bcIt)->hitsAndFractions().begin();rhIt != (*bcIt)->hitsAndFractions().end(); ++rhIt) {
204  if( rhIt->first == *i ) isClustered = true;
205  if( isClustered ) break;
206  }
207  if( isClustered ) break;
208  } //end loop over basic clusters
209 
210  if(isClustered) continue;
211  } //end if removeClustered
212 
213  std::vector<int>::const_iterator sit;
214  int severityFlag = sevLevel->severityLevel(j->detid(), hits);
215  if (barrel) {
216  sit = std::find(severitiesexclEB_.begin(), severitiesexclEB_.end(), severityFlag);
217  if (sit != severitiesexclEB_.end())
218  continue;
219  } else {
220  sit = std::find(severitiesexclEE_.begin(), severitiesexclEE_.end(), severityFlag);
221  if (sit != severitiesexclEE_.end())
222  continue;
223  }
224 
225  std::vector<int>::const_iterator vit;
226  if (barrel) {
227  // new rechit flag checks
228  //vit = std::find(flagsexclEB_.begin(), flagsexclEB_.end(), ((EcalRecHit*)(&*j))->recoFlag());
229  //if (vit != flagsexclEB_.end())
230  // continue;
231  if (!((EcalRecHit*)(&*j))->checkFlag(EcalRecHit::kGood)) {
232  if (((EcalRecHit*)(&*j))->checkFlags(flagsexclEB_)) {
233  continue;
234  }
235  }
236  } else {
237  // new rechit flag checks
238  //vit = std::find(flagsexclEE_.begin(), flagsexclEE_.end(), ((EcalRecHit*)(&*j))->recoFlag());
239  //if (vit != flagsexclEE_.end())
240  // continue;
241  if (!((EcalRecHit*)(&*j))->checkFlag(EcalRecHit::kGood)) {
242  if (((EcalRecHit*)(&*j))->checkFlags(flagsexclEE_)) {
243  continue;
244  }
245  }
246  }
247 
248  if(et > etMin_
249  && energy > energyMin_ //Changed to fabs - then changed back to energy
250  && fabs(eta-caloeta) > intStrip_
251  && (eta-caloeta)*(eta-caloeta) + phiDiff*phiDiff >r2 ) {
252 
253  deposit.addDeposit( Direction(eta, phi), (useEt_ ? et : energy));
254  }
255  }
256  }
257 }
int i
Definition: DBlmapReader.cc:9
T perp() const
Definition: PV3DBase.h:72
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
std::vector< EcalRecHit >::const_iterator const_iterator
T eta() const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
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
int j
Definition: DBlmapReader.cc:9
const GlobalPoint & getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:68
#define end
Definition: vmac.h:37
const_iterator end() const
double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:12
T eta() const
Definition: PV3DBase.h:76
iterator find(key_type k)
EcalSeverityLevel::SeverityLevel severityLevel(const DetId &id, const EcalRecHitCollection &rhs) const
Evaluate status from id.
Definition: DDAxes.h:10
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 49 of file EgammaRecHitExtractor.h.

References edm::hlt::Exception, and mergeVDriftHistosByStation::name.

Referenced by deposit().

49  {
50  throw cms::Exception("Configuration Error") << "This extractor " << (typeid(this).name()) << " is not made for tracks";
51  }
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 111 of file EgammaRecHitExtractor.cc.

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

112  {
114  iSetup.get<CaloGeometryRecord>().get(pG);
115 
116  //Get the channel status from the db
117  //edm::ESHandle<EcalChannelStatus> chStatus;
118  //iSetup.get<EcalChannelStatusRcd>().get(chStatus);
119 
121  iSetup.get<EcalSeverityLevelAlgoRcd>().get(sevlv);
122  const EcalSeverityLevelAlgo* sevLevel = sevlv.product();
123 
124  const CaloGeometry* caloGeom = pG.product();
127 
128  static std::string metname = "EgammaIsolationAlgos|EgammaRecHitExtractor";
129 
130  std::auto_ptr<const CaloRecHitMetaCollectionV> barrelRecHits(0), endcapRecHits(0);
131 
132  //Get barrel ECAL RecHits
133  edm::Handle<EcalRecHitCollection> barrelEcalRecHitsH;
134  iEvent.getByToken(barrelEcalHitsToken_, barrelEcalRecHitsH);
135 
136  //Get endcap ECAL RecHits
137  edm::Handle<EcalRecHitCollection> endcapEcalRecHitsH;
138  iEvent.getByToken(endcapEcalHitsToken_, endcapEcalRecHitsH);
139 
140  //define isodeposit starting from candidate
142  math::XYZPoint caloPosition = sc->position();
143 
144  Direction candDir(caloPosition.eta(), caloPosition.phi());
145  reco::IsoDeposit deposit( candDir );
147  double sinTheta = sin(2*atan(exp(-sc->eta())));
148  deposit.addCandEnergy(sc->energy() * (useEt_ ? sinTheta : 1.0)) ;
149 
150  // subtract supercluster if desired
151  double fakeEnergy = -sc->rawEnergy();
152  if (fakeNegativeDeposit_) {
153  deposit.addDeposit(candDir, fakeEnergy * (useEt_ ? sinTheta : 1.0)); // not exactly clean...
154  }
155 
156  // fill rechits
157  bool inBarrel = sameTag_ || ( abs(sc->eta()) < 1.479 ); //check for barrel. If only one collection is used, use barrel
158  if (inBarrel || tryBoth_) {
159  collect(deposit, sc, barrelgeom, caloGeom, *barrelEcalRecHitsH, sevLevel, true);
160  }
161 
162  if ((!inBarrel) || tryBoth_) {
163  collect(deposit, sc, endcapgeom, caloGeom, *endcapEcalRecHitsH, sevLevel, false);
164  }
165 
166  return deposit;
167 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:43
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:243
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
T const * product() const
Definition: ESHandle.h:62
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 * get() const
Returns C++ pointer to the item.
Definition: Ref.h:242
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 48 of file EgammaRecHitExtractor.h.

48 { }

Member Data Documentation

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

Definition at line 68 of file EgammaRecHitExtractor.h.

Referenced by EgammaRecHitExtractor().

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

Definition at line 70 of file EgammaRecHitExtractor.h.

Referenced by deposit().

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

Definition at line 69 of file EgammaRecHitExtractor.h.

Referenced by EgammaRecHitExtractor().

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

Definition at line 71 of file EgammaRecHitExtractor.h.

Referenced by deposit().

double egammaisolation::EgammaRecHitExtractor::energyMin_
private

Definition at line 64 of file EgammaRecHitExtractor.h.

Referenced by collect().

double egammaisolation::EgammaRecHitExtractor::etMin_
private

Definition at line 63 of file EgammaRecHitExtractor.h.

Referenced by collect().

double egammaisolation::EgammaRecHitExtractor::extRadius_
private

Definition at line 65 of file EgammaRecHitExtractor.h.

Referenced by collect().

bool egammaisolation::EgammaRecHitExtractor::fakeNegativeDeposit_
private

Definition at line 72 of file EgammaRecHitExtractor.h.

Referenced by deposit(), and EgammaRecHitExtractor().

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

Definition at line 85 of file EgammaRecHitExtractor.h.

Referenced by collect(), and EgammaRecHitExtractor().

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

Definition at line 86 of file EgammaRecHitExtractor.h.

Referenced by collect(), and EgammaRecHitExtractor().

double egammaisolation::EgammaRecHitExtractor::intRadius_
private

Definition at line 66 of file EgammaRecHitExtractor.h.

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

double egammaisolation::EgammaRecHitExtractor::intStrip_
private

Definition at line 67 of file EgammaRecHitExtractor.h.

Referenced by collect().

bool egammaisolation::EgammaRecHitExtractor::sameTag_
private

Definition at line 76 of file EgammaRecHitExtractor.h.

Referenced by deposit(), and EgammaRecHitExtractor().

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

Definition at line 83 of file EgammaRecHitExtractor.h.

Referenced by collect(), and EgammaRecHitExtractor().

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

Definition at line 84 of file EgammaRecHitExtractor.h.

Referenced by collect(), and EgammaRecHitExtractor().

bool egammaisolation::EgammaRecHitExtractor::tryBoth_
private

Definition at line 73 of file EgammaRecHitExtractor.h.

Referenced by deposit(), and EgammaRecHitExtractor().

bool egammaisolation::EgammaRecHitExtractor::useEt_
private

Definition at line 74 of file EgammaRecHitExtractor.h.

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

bool egammaisolation::EgammaRecHitExtractor::vetoClustered_
private

Definition at line 75 of file EgammaRecHitExtractor.h.

Referenced by collect().