CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 36 of file CandIsolatorFromDeposits.h.

Constructor & Destructor Documentation

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

Definition at line 38 of file CandIsolatorFromDeposits.cc.

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

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

Member Function Documentation

void CandIsolatorFromDeposits::SingleDeposit::cleanup ( void  )

Definition at line 78 of file CandIsolatorFromDeposits.cc.

78  {
79  for (AbsVetos::iterator it = vetos_.begin(), ed = vetos_.end(); it != ed; ++it) {
80  delete *it;
81  }
82  vetos_.clear();
83  // NOTE: we DON'T have to delete the evdepVetos_, they have already been deleted above. We just clear the vectors
84  evdepVetos_.clear();
85 }
reco::isodeposit::EventDependentAbsVetos evdepVetos_
double CandIsolatorFromDeposits::SingleDeposit::compute ( const reco::CandidateBaseRef cand)

Definition at line 93 of file CandIsolatorFromDeposits.cc.

References reco::IsoDeposit::algoWithin(), reco::IsoDeposit::candEnergy(), CandIsolatorFromDeposits::Count, reco::IsoDeposit::countWithin(), deltaR_, 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.

93  {
94  const IsoDeposit &dep = (*hDeps_)[cand];
95  double eta = dep.eta(), phi = dep.phi(); // better to center on the deposit direction
96  // that could be, e.g., the impact point at calo
97  for (AbsVetos::iterator it = vetos_.begin(), ed = vetos_.end(); it != ed; ++it) {
98  (*it)->centerOn(eta, phi);
99  }
100  double weight = (usesFunction_ ? weightExpr_(*cand) : weight_);
101  switch (mode_) {
102  case Count: return weight * dep.countWithin(deltaR_, vetos_, skipDefaultVeto_);
103  case Sum: return weight * dep.sumWithin(deltaR_, vetos_, skipDefaultVeto_);
104  case SumRelative: return weight * dep.sumWithin(deltaR_, vetos_, skipDefaultVeto_) / dep.candEnergy() ;
105  case Sum2: return weight * dep.sum2Within(deltaR_, vetos_, skipDefaultVeto_);
106  case Sum2Relative: return weight * dep.sum2Within(deltaR_, vetos_, skipDefaultVeto_) / (dep.candEnergy() * dep.candEnergy()) ;
107  case Max: return weight * dep.maxWithin(deltaR_, vetos_, skipDefaultVeto_);
108  case NearestDR: return weight * dep.nearestDR(deltaR_, vetos_, skipDefaultVeto_);
109  case MaxRelative: return weight * dep.maxWithin(deltaR_, vetos_, skipDefaultVeto_) / dep.candEnergy() ;
112  }
113  throw cms::Exception("Logic error") << "Should not happen at " << __FILE__ << ", line " << __LINE__; // avoid gcc warning
114 }
double candEnergy() const
Get energy or pT attached to cand trajectory.
Definition: IsoDeposit.h:136
double sum2Within(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
Definition: IsoDeposit.cc:146
double eta() const
Definition: IsoDeposit.h:74
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:288
double phi() const
Definition: IsoDeposit.h:75
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:150
double sumWithin(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
Definition: IsoDeposit.cc:138
double nearestDR(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
Definition: IsoDeposit.cc:155
int weight
Definition: histoStyle.py:50
const reco::IsoDepositMap& CandIsolatorFromDeposits::SingleDeposit::map ( )
inline

Definition at line 42 of file CandIsolatorFromDeposits.h.

References hDeps_.

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

Definition at line 86 of file CandIsolatorFromDeposits.cc.

References edm::Event::getByToken().

86  {
87  iEvent.getByToken(srcToken_, hDeps_);
88  for (EventDependentAbsVetos::iterator it = evdepVetos_.begin(), ed = evdepVetos_.end(); it != ed; ++it) {
89  (*it)->setEvent(iEvent,iSetup);
90  }
91 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
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 46 of file CandIsolatorFromDeposits.h.

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

Definition at line 51 of file CandIsolatorFromDeposits.h.

Referenced by SingleDeposit().

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

Definition at line 53 of file CandIsolatorFromDeposits.h.

Referenced by map().

Mode CandIsolatorFromDeposits::SingleDeposit::mode_
private

Definition at line 44 of file CandIsolatorFromDeposits.h.

Referenced by SingleDeposit().

bool CandIsolatorFromDeposits::SingleDeposit::skipDefaultVeto_
private

Definition at line 52 of file CandIsolatorFromDeposits.h.

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

Definition at line 45 of file CandIsolatorFromDeposits.h.

bool CandIsolatorFromDeposits::SingleDeposit::usesFunction_
private

Definition at line 47 of file CandIsolatorFromDeposits.h.

Referenced by SingleDeposit().

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

Definition at line 50 of file CandIsolatorFromDeposits.h.

Referenced by SingleDeposit().

double CandIsolatorFromDeposits::SingleDeposit::weight_
private

Definition at line 48 of file CandIsolatorFromDeposits.h.

Referenced by SingleDeposit().

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

Definition at line 49 of file CandIsolatorFromDeposits.h.