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 35 of file CandIsolatorFromDeposits.cc.

Constructor & Destructor Documentation

◆ SingleDeposit()

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

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

71  deltaR_(iConfig.getParameter<double>("deltaR")),
72  weightExpr_(iConfig.getParameter<std::string>("weight")),
73  skipDefaultVeto_(iConfig.getParameter<bool>("skipDefaultVeto"))
74 //,vetos_(new AbsVetos())
75 {
76  std::string mode = iConfig.getParameter<std::string>("mode");
77  if (mode == "sum")
78  mode_ = Sum;
79  else if (mode == "sumRelative")
81  else if (mode == "sum2")
82  mode_ = Sum2;
83  else if (mode == "sum2Relative")
85  else if (mode == "max")
86  mode_ = Max;
87  else if (mode == "maxRelative")
89  else if (mode == "nearestDR")
90  mode_ = NearestDR;
91  else if (mode == "count")
92  mode_ = Count;
93  else if (mode == "meanDR")
94  mode_ = MeanDR;
95  else if (mode == "sumDR")
96  mode_ = SumDR;
97  else
98  throw cms::Exception("Not Implemented") << "Mode '" << mode << "' not implemented. "
99  << "Supported modes are 'sum', 'sumRelative', 'count'." <<
100  //"Supported modes are 'sum', 'sumRelative', 'max', 'maxRelative', 'count'." << // TODO: on request only
101  "New methods can be easily implemented if requested.";
102  typedef std::vector<std::string> vstring;
103  vstring vetos = iConfig.getParameter<vstring>("vetos");
105  for (vstring::const_iterator it = vetos.begin(), ed = vetos.end(); it != ed; ++it) {
106  vetos_.push_back(IsoDepositVetoFactory::make(it->c_str(), evdep, iC));
107  if (evdep)
108  evdepVetos_.push_back(evdep);
109  }
110  std::string weight = iConfig.getParameter<std::string>("weight");
111  if (isNumber(weight)) {
112  //std::cout << "Weight is a simple number, " << toNumber(weight) << std::endl;
114  usesFunction_ = false;
115  } else {
116  usesFunction_ = true;
117  //std::cout << "Weight is a function, this might slow you down... " << std::endl;
118  }
119  //std::cout << "CandIsolatorFromDeposits::SingleDeposit::SingleDeposit: Total of " << vetos_.size() << " vetos" << std::endl;
120 }
static reco::isodeposit::AbsVeto * make(const char *string, edm::ConsumesCollector &iC)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
bool isNumber(const std::string &str)
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
vector< string > vstring
Definition: ExoticaDQM.cc:7
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

◆ cleanup()

void CandIsolatorFromDeposits::SingleDeposit::cleanup ( )

Definition at line 121 of file CandIsolatorFromDeposits.cc.

121  {
122  for (AbsVetos::iterator it = vetos_.begin(), ed = vetos_.end(); it != ed; ++it) {
123  delete *it;
124  }
125  vetos_.clear();
126  // NOTE: we DON'T have to delete the evdepVetos_, they have already been deleted above. We just clear the vectors
127  evdepVetos_.clear();
128 }
reco::isodeposit::EventDependentAbsVetos evdepVetos_

◆ compute()

double CandIsolatorFromDeposits::SingleDeposit::compute ( const reco::CandidateBaseRef cand)

Definition at line 136 of file CandIsolatorFromDeposits.cc.

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

136  {
137  const IsoDeposit &dep = (*hDeps_)[cand];
138  double eta = dep.eta(), phi = dep.phi(); // better to center on the deposit direction
139  // that could be, e.g., the impact point at calo
140  for (AbsVetos::iterator it = vetos_.begin(), ed = vetos_.end(); it != ed; ++it) {
141  (*it)->centerOn(eta, phi);
142  }
143  double weight = (usesFunction_ ? weightExpr_(*cand) : weight_);
144  switch (mode_) {
145  case Count:
147  case Sum:
149  case SumRelative:
150  return weight * dep.sumWithin(deltaR_, vetos_, skipDefaultVeto_) / dep.candEnergy();
151  case Sum2:
153  case Sum2Relative:
154  return weight * dep.sum2Within(deltaR_, vetos_, skipDefaultVeto_) / (dep.candEnergy() * dep.candEnergy());
155  case Max:
157  case NearestDR:
159  case MaxRelative:
160  return weight * dep.maxWithin(deltaR_, vetos_, skipDefaultVeto_) / dep.candEnergy();
161  case MeanDR:
163  case SumDR:
165  }
166  throw cms::Exception("Logic error") << "Should not happen at " << __FILE__ << ", line "
167  << __LINE__; // avoid gcc warning
168 }
double sumWithin(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
Definition: IsoDeposit.cc:137
double phi() const
Definition: IsoDeposit.h:77
double sum2Within(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
Definition: IsoDeposit.cc:143
double nearestDR(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
Definition: IsoDeposit.cc:150
StringObjectFunction< reco::Candidate > weightExpr_
Definition: weight.py:1
double maxWithin(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
Definition: IsoDeposit.cc:146
double candEnergy() const
Get energy or pT attached to cand trajectory.
Definition: IsoDeposit.h:129
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 countWithin(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
Definition: IsoDeposit.cc:134

◆ map()

const reco::IsoDepositMap& CandIsolatorFromDeposits::SingleDeposit::map ( )
inline

Definition at line 41 of file CandIsolatorFromDeposits.cc.

References hDeps_.

41 { return *hDeps_; }
edm::Handle< reco::IsoDepositMap > hDeps_

◆ open()

void CandIsolatorFromDeposits::SingleDeposit::open ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)

Definition at line 129 of file CandIsolatorFromDeposits.cc.

References iEvent.

129  {
130  iEvent.getByToken(srcToken_, hDeps_);
131  for (EventDependentAbsVetos::iterator it = evdepVetos_.begin(), ed = evdepVetos_.end(); it != ed; ++it) {
132  (*it)->setEvent(iEvent, iSetup);
133  }
134 }
edm::Handle< reco::IsoDepositMap > hDeps_
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< reco::IsoDepositMap > srcToken_
reco::isodeposit::EventDependentAbsVetos evdepVetos_

Member Data Documentation

◆ deltaR_

double CandIsolatorFromDeposits::SingleDeposit::deltaR_
private

Definition at line 46 of file CandIsolatorFromDeposits.cc.

◆ evdepVetos_

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

Definition at line 51 of file CandIsolatorFromDeposits.cc.

Referenced by SingleDeposit().

◆ hDeps_

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

Definition at line 53 of file CandIsolatorFromDeposits.cc.

Referenced by map().

◆ mode_

Mode CandIsolatorFromDeposits::SingleDeposit::mode_
private

Definition at line 44 of file CandIsolatorFromDeposits.cc.

Referenced by SingleDeposit().

◆ skipDefaultVeto_

bool CandIsolatorFromDeposits::SingleDeposit::skipDefaultVeto_
private

Definition at line 52 of file CandIsolatorFromDeposits.cc.

◆ srcToken_

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

Definition at line 45 of file CandIsolatorFromDeposits.cc.

◆ usesFunction_

bool CandIsolatorFromDeposits::SingleDeposit::usesFunction_
private

Definition at line 47 of file CandIsolatorFromDeposits.cc.

Referenced by SingleDeposit().

◆ vetos_

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

Definition at line 50 of file CandIsolatorFromDeposits.cc.

Referenced by SingleDeposit().

◆ weight_

double CandIsolatorFromDeposits::SingleDeposit::weight_
private

Definition at line 48 of file CandIsolatorFromDeposits.cc.

Referenced by SingleDeposit().

◆ weightExpr_

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

Definition at line 49 of file CandIsolatorFromDeposits.cc.