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

References CandIsolatorFromDeposits::Count, evdepVetos_, Exception, edm::ParameterSet::getParameter(), mkLumiAveragedPlots::isNumber(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, 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, usesFunction_, boostedElectronIsolation_cff::vetos, vetos_, and weight_.

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

Member Function Documentation

◆ cleanup()

void CandIsolatorFromDeposits::SingleDeposit::cleanup ( )

Definition at line 123 of file CandIsolatorFromDeposits.cc.

References ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it.

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

◆ compute()

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

Definition at line 138 of file CandIsolatorFromDeposits.cc.

References reco::IsoDeposit::algoWithin(), reco::IsoDeposit::candEnergy(), CandIsolatorFromDeposits::Count, reco::IsoDeposit::countWithin(), PVValHelper::eta, reco::IsoDeposit::eta(), Exception, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, 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().

138  {
139  const IsoDeposit &dep = (*hDeps_)[cand];
140  double eta = dep.eta(), phi = dep.phi(); // better to center on the deposit direction
141  // that could be, e.g., the impact point at calo
142  for (AbsVetos::iterator it = vetos_.begin(), ed = vetos_.end(); it != ed; ++it) {
143  (*it)->centerOn(eta, phi);
144  }
145  double weight = (usesFunction_ ? weightExpr_(*cand) : weight_);
146  switch (mode_) {
147  case Count:
149  case Sum:
151  case SumRelative:
152  return weight * dep.sumWithin(deltaR_, vetos_, skipDefaultVeto_) / dep.candEnergy();
153  case Sum2:
155  case Sum2Relative:
156  return weight * dep.sum2Within(deltaR_, vetos_, skipDefaultVeto_) / (dep.candEnergy() * dep.candEnergy());
157  case Max:
159  case NearestDR:
161  case MaxRelative:
162  return weight * dep.maxWithin(deltaR_, vetos_, skipDefaultVeto_) / dep.candEnergy();
163  case MeanDR:
165  case SumDR:
167  }
168  throw cms::Exception("Logic error") << "Should not happen at " << __FILE__ << ", line "
169  << __LINE__; // avoid gcc warning
170 }
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 131 of file CandIsolatorFromDeposits.cc.

References iEvent, and ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it.

131  {
132  iEvent.getByToken(srcToken_, hDeps_);
133  for (EventDependentAbsVetos::iterator it = evdepVetos_.begin(), ed = evdepVetos_.end(); it != ed; ++it) {
134  (*it)->setEvent(iEvent, iSetup);
135  }
136 }
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.