CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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::IsoDepositMap
srcToken_
 
bool usesFunction_
 
reco::isodeposit::AbsVetos vetos_
 
double weight_
 
StringObjectFunction
< reco::Candidate
weightExpr_
 

Detailed Description

Definition at line 38 of file CandIsolatorFromDeposits.cc.

Constructor & Destructor Documentation

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

Definition at line 72 of file CandIsolatorFromDeposits.cc.

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

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

Member Function Documentation

void CandIsolatorFromDeposits::SingleDeposit::cleanup ( )

Definition at line 124 of file CandIsolatorFromDeposits.cc.

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

Definition at line 139 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, reco::IsoDeposit::sumWithin(), and histoStyle::weight.

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

Definition at line 44 of file CandIsolatorFromDeposits.cc.

References hDeps_.

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

Definition at line 132 of file CandIsolatorFromDeposits.cc.

References edm::Event::getByToken().

132  {
133  iEvent.getByToken(srcToken_, hDeps_);
134  for (EventDependentAbsVetos::iterator it = evdepVetos_.begin(), ed = evdepVetos_.end(); it != ed; ++it) {
135  (*it)->setEvent(iEvent, iSetup);
136  }
137 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
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 49 of file CandIsolatorFromDeposits.cc.

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

Definition at line 54 of file CandIsolatorFromDeposits.cc.

Referenced by SingleDeposit().

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

Definition at line 56 of file CandIsolatorFromDeposits.cc.

Referenced by map().

Mode CandIsolatorFromDeposits::SingleDeposit::mode_
private

Definition at line 47 of file CandIsolatorFromDeposits.cc.

Referenced by SingleDeposit().

bool CandIsolatorFromDeposits::SingleDeposit::skipDefaultVeto_
private

Definition at line 55 of file CandIsolatorFromDeposits.cc.

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

Definition at line 48 of file CandIsolatorFromDeposits.cc.

bool CandIsolatorFromDeposits::SingleDeposit::usesFunction_
private

Definition at line 50 of file CandIsolatorFromDeposits.cc.

Referenced by SingleDeposit().

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

Definition at line 53 of file CandIsolatorFromDeposits.cc.

Referenced by SingleDeposit().

double CandIsolatorFromDeposits::SingleDeposit::weight_
private

Definition at line 51 of file CandIsolatorFromDeposits.cc.

Referenced by SingleDeposit().

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

Definition at line 52 of file CandIsolatorFromDeposits.cc.