CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
CandIsolatorFromDeposits::SingleDeposit Class Reference

Public Member Functions

void cleanup ()
 
double compute (const reco::CandidateBaseRef &cand)
 
const reco::IsoDepositMapmap ()
 
void open (const edm::Event &iEvent, const edm::EventSetup &iSetup)
 
 SingleDeposit (const edm::ParameterSet &, edm::ConsumesCollector &&iC)
 

Private Attributes

double deltaR_
 
reco::isodeposit::EventDependentAbsVetos evdepVetos_
 
edm::Handle< reco::IsoDepositMaphDeps_
 
Mode mode_
 
bool skipDefaultVeto_
 
edm::EDGetTokenT< reco::IsoDepositMapsrcToken_
 
bool usesFunction_
 
reco::isodeposit::AbsVetos vetos_
 
double weight_
 
StringObjectFunction< reco::CandidateweightExpr_
 

Detailed Description

Definition at line 39 of file CandIsolatorFromDeposits.h.

Constructor & Destructor Documentation

CandIsolatorFromDeposits::SingleDeposit::SingleDeposit ( const edm::ParameterSet iConfig,
edm::ConsumesCollector &&  iC 
)

Definition at line 36 of file CandIsolatorFromDeposits.cc.

References CandIsolatorFromDeposits::Count, evdepVetos_, Exception, edm::ParameterSet::getParameter(), isNumber(), IsoDepositVetoFactory::make(), CandIsolatorFromDeposits::Max, CandIsolatorFromDeposits::MaxRelative, CandIsolatorFromDeposits::MeanDR, ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, mode_, CandIsolatorFromDeposits::NearestDR, AlCaHLTBitMon_QueryRunRegistry::string, CandIsolatorFromDeposits::Sum, CandIsolatorFromDeposits::Sum2, CandIsolatorFromDeposits::Sum2Relative, CandIsolatorFromDeposits::SumDR, CandIsolatorFromDeposits::SumRelative, toNumber(), usesFunction_, boostedElectronIsolation_cff::vetos, vetos_, and weight_.

Referenced by CandIsolatorFromDeposits::CandIsolatorFromDeposits().

38  deltaR_(iConfig.getParameter<double>("deltaR")),
39  weightExpr_(iConfig.getParameter<std::string>("weight")),
40  skipDefaultVeto_(iConfig.getParameter<bool>("skipDefaultVeto"))
41 //,vetos_(new AbsVetos())
42 {
43  std::string mode = iConfig.getParameter<std::string>("mode");
44  if (mode == "sum")
45  mode_ = Sum;
46  else if (mode == "sumRelative")
48  else if (mode == "sum2")
49  mode_ = Sum2;
50  else if (mode == "sum2Relative")
52  else if (mode == "max")
53  mode_ = Max;
54  else if (mode == "maxRelative")
56  else if (mode == "nearestDR")
57  mode_ = NearestDR;
58  else if (mode == "count")
59  mode_ = Count;
60  else if (mode == "meanDR")
61  mode_ = MeanDR;
62  else if (mode == "sumDR")
63  mode_ = SumDR;
64  else
65  throw cms::Exception("Not Implemented") << "Mode '" << mode << "' not implemented. "
66  << "Supported modes are 'sum', 'sumRelative', 'count'." <<
67  //"Supported modes are 'sum', 'sumRelative', 'max', 'maxRelative', 'count'." << // TODO: on request only
68  "New methods can be easily implemented if requested.";
69  typedef std::vector<std::string> vstring;
70  vstring vetos = iConfig.getParameter<vstring>("vetos");
72  for (vstring::const_iterator it = vetos.begin(), ed = vetos.end(); it != ed; ++it) {
73  vetos_.push_back(IsoDepositVetoFactory::make(it->c_str(), evdep, iC));
74  if (evdep)
75  evdepVetos_.push_back(evdep);
76  }
77  std::string weight = iConfig.getParameter<std::string>("weight");
78  if (isNumber(weight)) {
79  //std::cout << "Weight is a simple number, " << toNumber(weight) << std::endl;
80  weight_ = toNumber(weight);
81  usesFunction_ = false;
82  } else {
83  usesFunction_ = true;
84  //std::cout << "Weight is a function, this might slow you down... " << std::endl;
85  }
86  //std::cout << "CandIsolatorFromDeposits::SingleDeposit::SingleDeposit: Total of " << vetos_.size() << " vetos" << std::endl;
87 }
static reco::isodeposit::AbsVeto * make(const char *string, edm::ConsumesCollector &iC)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
bool isNumber(const std::string &str)
vector< string > vstring
Definition: ExoticaDQM.cc:8
StringObjectFunction< reco::Candidate > weightExpr_
Definition: weight.py:1
double toNumber(const std::string &str)
edm::EDGetTokenT< reco::IsoDepositMap > srcToken_
reco::isodeposit::EventDependentAbsVetos evdepVetos_

Member Function Documentation

void CandIsolatorFromDeposits::SingleDeposit::cleanup ( )

Definition at line 88 of file CandIsolatorFromDeposits.cc.

References evdepVetos_, and vetos_.

88  {
89  for (AbsVetos::iterator it = vetos_.begin(), ed = vetos_.end(); it != ed; ++it) {
90  delete *it;
91  }
92  vetos_.clear();
93  // NOTE: we DON'T have to delete the evdepVetos_, they have already been deleted above. We just clear the vectors
94  evdepVetos_.clear();
95 }
reco::isodeposit::EventDependentAbsVetos evdepVetos_
double CandIsolatorFromDeposits::SingleDeposit::compute ( const reco::CandidateBaseRef cand)

Definition at line 103 of file CandIsolatorFromDeposits.cc.

References reco::IsoDeposit::algoWithin(), reco::IsoDeposit::candEnergy(), CandIsolatorFromDeposits::Count, reco::IsoDeposit::countWithin(), deltaR_, PVValHelper::eta, reco::IsoDeposit::eta(), Exception, CandIsolatorFromDeposits::Max, CandIsolatorFromDeposits::MaxRelative, reco::IsoDeposit::maxWithin(), CandIsolatorFromDeposits::MeanDR, mode_, CandIsolatorFromDeposits::NearestDR, reco::IsoDeposit::nearestDR(), phi, reco::IsoDeposit::phi(), skipDefaultVeto_, CandIsolatorFromDeposits::Sum, CandIsolatorFromDeposits::Sum2, CandIsolatorFromDeposits::Sum2Relative, reco::IsoDeposit::sum2Within(), CandIsolatorFromDeposits::SumDR, CandIsolatorFromDeposits::SumRelative, reco::IsoDeposit::sumWithin(), usesFunction_, vetos_, weight_, and weightExpr_.

103  {
104  const IsoDeposit &dep = (*hDeps_)[cand];
105  double eta = dep.eta(), phi = dep.phi(); // better to center on the deposit direction
106  // that could be, e.g., the impact point at calo
107  for (AbsVetos::iterator it = vetos_.begin(), ed = vetos_.end(); it != ed; ++it) {
108  (*it)->centerOn(eta, phi);
109  }
110  double weight = (usesFunction_ ? weightExpr_(*cand) : weight_);
111  switch (mode_) {
112  case Count:
113  return weight * dep.countWithin(deltaR_, vetos_, skipDefaultVeto_);
114  case Sum:
115  return weight * dep.sumWithin(deltaR_, vetos_, skipDefaultVeto_);
116  case SumRelative:
117  return weight * dep.sumWithin(deltaR_, vetos_, skipDefaultVeto_) / dep.candEnergy();
118  case Sum2:
119  return weight * dep.sum2Within(deltaR_, vetos_, skipDefaultVeto_);
120  case Sum2Relative:
121  return weight * dep.sum2Within(deltaR_, vetos_, skipDefaultVeto_) / (dep.candEnergy() * dep.candEnergy());
122  case Max:
123  return weight * dep.maxWithin(deltaR_, vetos_, skipDefaultVeto_);
124  case NearestDR:
125  return weight * dep.nearestDR(deltaR_, vetos_, skipDefaultVeto_);
126  case MaxRelative:
127  return weight * dep.maxWithin(deltaR_, vetos_, skipDefaultVeto_) / dep.candEnergy();
128  case MeanDR:
130  case SumDR:
132  }
133  throw cms::Exception("Logic error") << "Should not happen at " << __FILE__ << ", line "
134  << __LINE__; // avoid gcc warning
135 }
double candEnergy() const
Get energy or pT attached to cand trajectory.
Definition: IsoDeposit.h:129
double sum2Within(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
Definition: IsoDeposit.cc:143
double eta() const
Definition: IsoDeposit.h:76
double algoWithin(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
Get some info about the deposit (e.g. sum, max, sum2, count)
Definition: IsoDeposit.h:309
double phi() const
Definition: IsoDeposit.h:77
StringObjectFunction< reco::Candidate > weightExpr_
Definition: weight.py:1
double countWithin(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
Definition: IsoDeposit.cc:134
double maxWithin(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
Definition: IsoDeposit.cc:146
double sumWithin(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
Definition: IsoDeposit.cc:137
double nearestDR(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
Definition: IsoDeposit.cc:150
const reco::IsoDepositMap& CandIsolatorFromDeposits::SingleDeposit::map ( )
inline

Definition at line 45 of file CandIsolatorFromDeposits.h.

Referenced by CandIsolatorFromDeposits::produce().

45 { return *hDeps_; }
edm::Handle< reco::IsoDepositMap > hDeps_
void CandIsolatorFromDeposits::SingleDeposit::open ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)

Definition at line 96 of file CandIsolatorFromDeposits.cc.

References evdepVetos_, edm::Event::getByToken(), hDeps_, and srcToken_.

96  {
97  iEvent.getByToken(srcToken_, hDeps_);
98  for (EventDependentAbsVetos::iterator it = evdepVetos_.begin(), ed = evdepVetos_.end(); it != ed; ++it) {
99  (*it)->setEvent(iEvent, iSetup);
100  }
101 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
edm::Handle< reco::IsoDepositMap > hDeps_
edm::EDGetTokenT< reco::IsoDepositMap > srcToken_
reco::isodeposit::EventDependentAbsVetos evdepVetos_

Member Data Documentation

double CandIsolatorFromDeposits::SingleDeposit::deltaR_
private

Definition at line 50 of file CandIsolatorFromDeposits.h.

Referenced by compute().

reco::isodeposit::EventDependentAbsVetos CandIsolatorFromDeposits::SingleDeposit::evdepVetos_
private

Definition at line 55 of file CandIsolatorFromDeposits.h.

Referenced by cleanup(), open(), and SingleDeposit().

edm::Handle<reco::IsoDepositMap> CandIsolatorFromDeposits::SingleDeposit::hDeps_
private

Definition at line 57 of file CandIsolatorFromDeposits.h.

Referenced by open().

Mode CandIsolatorFromDeposits::SingleDeposit::mode_
private

Definition at line 48 of file CandIsolatorFromDeposits.h.

Referenced by compute(), and SingleDeposit().

bool CandIsolatorFromDeposits::SingleDeposit::skipDefaultVeto_
private

Definition at line 56 of file CandIsolatorFromDeposits.h.

Referenced by compute().

edm::EDGetTokenT<reco::IsoDepositMap> CandIsolatorFromDeposits::SingleDeposit::srcToken_
private

Definition at line 49 of file CandIsolatorFromDeposits.h.

Referenced by open().

bool CandIsolatorFromDeposits::SingleDeposit::usesFunction_
private

Definition at line 51 of file CandIsolatorFromDeposits.h.

Referenced by compute(), and SingleDeposit().

reco::isodeposit::AbsVetos CandIsolatorFromDeposits::SingleDeposit::vetos_
private

Definition at line 54 of file CandIsolatorFromDeposits.h.

Referenced by cleanup(), compute(), and SingleDeposit().

double CandIsolatorFromDeposits::SingleDeposit::weight_
private

Definition at line 52 of file CandIsolatorFromDeposits.h.

Referenced by compute(), and SingleDeposit().

StringObjectFunction<reco::Candidate> CandIsolatorFromDeposits::SingleDeposit::weightExpr_
private

Definition at line 53 of file CandIsolatorFromDeposits.h.

Referenced by compute().