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

◆ SingleDeposit()

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

Definition at line 36 of file CandIsolatorFromDeposits.cc.

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;
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 }

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_.

Member Function Documentation

◆ cleanup()

void CandIsolatorFromDeposits::SingleDeposit::cleanup ( )

Definition at line 88 of file CandIsolatorFromDeposits.cc.

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 }

◆ compute()

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

Definition at line 103 of file CandIsolatorFromDeposits.cc.

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:
114  case Sum:
116  case SumRelative:
117  return weight * dep.sumWithin(deltaR_, vetos_, skipDefaultVeto_) / dep.candEnergy();
118  case Sum2:
120  case Sum2Relative:
121  return weight * dep.sum2Within(deltaR_, vetos_, skipDefaultVeto_) / (dep.candEnergy() * dep.candEnergy());
122  case Max:
124  case NearestDR:
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 }

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

◆ map()

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

Definition at line 45 of file CandIsolatorFromDeposits.h.

45 { return *hDeps_; }

References hDeps_.

◆ open()

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

Definition at line 96 of file CandIsolatorFromDeposits.cc.

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 }

References iEvent.

Member Data Documentation

◆ deltaR_

double CandIsolatorFromDeposits::SingleDeposit::deltaR_
private

Definition at line 50 of file CandIsolatorFromDeposits.h.

◆ evdepVetos_

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

Definition at line 55 of file CandIsolatorFromDeposits.h.

Referenced by SingleDeposit().

◆ hDeps_

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

Definition at line 57 of file CandIsolatorFromDeposits.h.

Referenced by map().

◆ mode_

Mode CandIsolatorFromDeposits::SingleDeposit::mode_
private

Definition at line 48 of file CandIsolatorFromDeposits.h.

Referenced by SingleDeposit().

◆ skipDefaultVeto_

bool CandIsolatorFromDeposits::SingleDeposit::skipDefaultVeto_
private

Definition at line 56 of file CandIsolatorFromDeposits.h.

◆ srcToken_

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

Definition at line 49 of file CandIsolatorFromDeposits.h.

◆ usesFunction_

bool CandIsolatorFromDeposits::SingleDeposit::usesFunction_
private

Definition at line 51 of file CandIsolatorFromDeposits.h.

Referenced by SingleDeposit().

◆ vetos_

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

Definition at line 54 of file CandIsolatorFromDeposits.h.

Referenced by SingleDeposit().

◆ weight_

double CandIsolatorFromDeposits::SingleDeposit::weight_
private

Definition at line 52 of file CandIsolatorFromDeposits.h.

Referenced by SingleDeposit().

◆ weightExpr_

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

Definition at line 53 of file CandIsolatorFromDeposits.h.

CandIsolatorFromDeposits::SingleDeposit::mode_
Mode mode_
Definition: CandIsolatorFromDeposits.h:48
reco::IsoDeposit::nearestDR
double nearestDR(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
Definition: IsoDeposit.cc:150
CandIsolatorFromDeposits::SingleDeposit::deltaR_
double deltaR_
Definition: CandIsolatorFromDeposits.h:50
CandIsolatorFromDeposits::SingleDeposit::weightExpr_
StringObjectFunction< reco::Candidate > weightExpr_
Definition: CandIsolatorFromDeposits.h:53
ALCARECOPromptCalibProdSiPixelAli0T_cff.mode
mode
Definition: ALCARECOPromptCalibProdSiPixelAli0T_cff.py:96
CandIsolatorFromDeposits::SingleDeposit::usesFunction_
bool usesFunction_
Definition: CandIsolatorFromDeposits.h:51
CandIsolatorFromDeposits::Sum
Definition: CandIsolatorFromDeposits.h:31
CandIsolatorFromDeposits::SumRelative
Definition: CandIsolatorFromDeposits.h:31
reco::IsoDeposit::sum2Within
double sum2Within(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
Definition: IsoDeposit.cc:143
CandIsolatorFromDeposits::SingleDeposit::hDeps_
edm::Handle< reco::IsoDepositMap > hDeps_
Definition: CandIsolatorFromDeposits.h:57
reco::IsoDeposit::countWithin
double countWithin(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
Definition: IsoDeposit.cc:134
PVValHelper::eta
Definition: PVValidationHelpers.h:69
CandIsolatorFromDeposits::NearestDR
Definition: CandIsolatorFromDeposits.h:31
edm::ConsumesCollector::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: ConsumesCollector.h:55
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
CandIsolatorFromDeposits::SingleDeposit::skipDefaultVeto_
bool skipDefaultVeto_
Definition: CandIsolatorFromDeposits.h:56
CandIsolatorFromDeposits::Max
Definition: CandIsolatorFromDeposits.h:31
reco::IsoDeposit::SumDRAlgo
Definition: IsoDeposit.h:237
CandIsolatorFromDeposits::SingleDeposit::vetos_
reco::isodeposit::AbsVetos vetos_
Definition: CandIsolatorFromDeposits.h:54
cand
Definition: decayParser.h:32
iEvent
int iEvent
Definition: GenABIO.cc:224
reco::IsoDeposit::sumWithin
double sumWithin(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
Definition: IsoDeposit.cc:137
toNumber
double toNumber(const std::string &str)
Definition: CandIsolatorFromDeposits.cc:34
reco::IsoDeposit::candEnergy
double candEnergy() const
Get energy or pT attached to cand trajectory.
Definition: IsoDeposit.h:129
CandIsolatorFromDeposits::Sum2
Definition: CandIsolatorFromDeposits.h:31
CandIsolatorFromDeposits::SingleDeposit::srcToken_
edm::EDGetTokenT< reco::IsoDepositMap > srcToken_
Definition: CandIsolatorFromDeposits.h:49
reco::IsoDeposit::algoWithin
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
DDAxes::phi
reco::IsoDeposit::eta
double eta() const
Definition: IsoDeposit.h:76
reco::IsoDeposit::maxWithin
double maxWithin(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
Definition: IsoDeposit.cc:146
isNumber
bool isNumber(const std::string &str)
Definition: CandIsolatorFromDeposits.cc:30
edm::ValueMap
Definition: ValueMap.h:107
CandIsolatorFromDeposits::MaxRelative
Definition: CandIsolatorFromDeposits.h:31
Exception
Definition: hltDiff.cc:246
vstring
vector< string > vstring
Definition: ExoticaDQM.cc:8
reco::IsoDeposit
Definition: IsoDeposit.h:49
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
CandIsolatorFromDeposits::SingleDeposit::weight_
double weight_
Definition: CandIsolatorFromDeposits.h:52
reco::IsoDeposit::phi
double phi() const
Definition: IsoDeposit.h:77
CandIsolatorFromDeposits::SumDR
Definition: CandIsolatorFromDeposits.h:31
CandIsolatorFromDeposits::Count
Definition: CandIsolatorFromDeposits.h:31
IsoDepositVetoFactory::make
static reco::isodeposit::AbsVeto * make(const char *string, edm::ConsumesCollector &iC)
Definition: IsoDepositVetoFactory.cc:72
reco::IsoDeposit::MeanDRAlgo
Definition: IsoDeposit.h:223
CandIsolatorFromDeposits::Sum2Relative
Definition: CandIsolatorFromDeposits.h:31
CandIsolatorFromDeposits::SingleDeposit::evdepVetos_
reco::isodeposit::EventDependentAbsVetos evdepVetos_
Definition: CandIsolatorFromDeposits.h:55
reco::isodeposit::EventDependentAbsVeto
Definition: EventDependentAbsVeto.h:10
boostedElectronIsolation_cff.vetos
vetos
Definition: boostedElectronIsolation_cff.py:79
edm::InputTag
Definition: InputTag.h:15
weight
Definition: weight.py:1
CandIsolatorFromDeposits::MeanDR
Definition: CandIsolatorFromDeposits.h:31