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 &)
 

Private Attributes

double deltaR_
 
reco::isodeposit::EventDependentAbsVetos evdepVetos_
 
edm::Handle< reco::IsoDepositMaphDeps_
 
Mode mode_
 
bool skipDefaultVeto_
 
edm::InputTag src_
 
bool usesFunction_
 
reco::isodeposit::AbsVetos vetos_
 
double weight_
 
StringObjectFunction
< reco::Candidate
weightExpr_
 

Detailed Description

Definition at line 35 of file CandIsolatorFromDeposits.h.

Constructor & Destructor Documentation

CandIsolatorFromDeposits::SingleDeposit::SingleDeposit ( const edm::ParameterSet iConfig)

Definition at line 38 of file CandIsolatorFromDeposits.cc.

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

38  :
39  src_(iConfig.getParameter<edm::InputTag>("src")),
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 throw cms::Exception("Not Implemented") << "Mode '" << mode << "' not implemented. " <<
55  "Supported modes are 'sum', 'sumRelative', 'count'." <<
56  //"Supported modes are 'sum', 'sumRelative', 'max', 'maxRelative', 'count'." << // TODO: on request only
57  "New methods can be easily implemented if requested.";
58  typedef std::vector<std::string> vstring;
59  vstring vetos = iConfig.getParameter< vstring >("vetos");
61  for (vstring::const_iterator it = vetos.begin(), ed = vetos.end(); it != ed; ++it) {
62  vetos_.push_back(IsoDepositVetoFactory::make(it->c_str(), evdep));
63  if (evdep) evdepVetos_.push_back(evdep);
64  }
65  std::string weight = iConfig.getParameter<std::string>("weight");
66  if (isNumber(weight)) {
67  //std::cout << "Weight is a simple number, " << toNumber(weight) << std::endl;
68  weight_ = toNumber(weight);
69  usesFunction_ = false;
70  } else {
71  usesFunction_ = true;
72  //std::cout << "Weight is a function, this might slow you down... " << std::endl;
73  }
74  //std::cout << "CandIsolatorFromDeposits::SingleDeposit::SingleDeposit: Total of " << vetos_.size() << " vetos" << std::endl;
75 }
T getParameter(std::string const &) const
bool isNumber(const std::string &str)
StringObjectFunction< reco::Candidate > weightExpr_
double toNumber(const std::string &str)
std::vector< std::string > vstring
static reco::isodeposit::AbsVeto * make(const char *string)
reco::isodeposit::EventDependentAbsVetos evdepVetos_

Member Function Documentation

void CandIsolatorFromDeposits::SingleDeposit::cleanup ( void  )

Definition at line 76 of file CandIsolatorFromDeposits.cc.

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

Definition at line 91 of file CandIsolatorFromDeposits.cc.

References reco::IsoDeposit::candEnergy(), CandIsolatorFromDeposits::Count, reco::IsoDeposit::countWithin(), deltaR_, reco::IsoDeposit::eta(), eta(), edm::hlt::Exception, CandIsolatorFromDeposits::Max, CandIsolatorFromDeposits::MaxRelative, reco::IsoDeposit::maxWithin(), CandIsolatorFromDeposits::NearestDR, reco::IsoDeposit::nearestDR(), phi, reco::IsoDeposit::phi(), CandIsolatorFromDeposits::Sum, CandIsolatorFromDeposits::Sum2, CandIsolatorFromDeposits::Sum2Relative, reco::IsoDeposit::sum2Within(), CandIsolatorFromDeposits::SumRelative, reco::IsoDeposit::sumWithin(), and CommonMethods::weight().

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

Definition at line 41 of file CandIsolatorFromDeposits.h.

References hDeps_.

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

Definition at line 84 of file CandIsolatorFromDeposits.cc.

References edm::Event::getByLabel().

84  {
85  iEvent.getByLabel(src_, hDeps_);
86  for (EventDependentAbsVetos::iterator it = evdepVetos_.begin(), ed = evdepVetos_.end(); it != ed; ++it) {
87  (*it)->setEvent(iEvent,iSetup);
88  }
89 }
edm::Handle< reco::IsoDepositMap > hDeps_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
reco::isodeposit::EventDependentAbsVetos evdepVetos_

Member Data Documentation

double CandIsolatorFromDeposits::SingleDeposit::deltaR_
private

Definition at line 45 of file CandIsolatorFromDeposits.h.

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

Definition at line 50 of file CandIsolatorFromDeposits.h.

Referenced by SingleDeposit().

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

Definition at line 52 of file CandIsolatorFromDeposits.h.

Referenced by map().

Mode CandIsolatorFromDeposits::SingleDeposit::mode_
private

Definition at line 43 of file CandIsolatorFromDeposits.h.

Referenced by SingleDeposit().

bool CandIsolatorFromDeposits::SingleDeposit::skipDefaultVeto_
private

Definition at line 51 of file CandIsolatorFromDeposits.h.

edm::InputTag CandIsolatorFromDeposits::SingleDeposit::src_
private

Definition at line 44 of file CandIsolatorFromDeposits.h.

bool CandIsolatorFromDeposits::SingleDeposit::usesFunction_
private

Definition at line 46 of file CandIsolatorFromDeposits.h.

Referenced by SingleDeposit().

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

Definition at line 49 of file CandIsolatorFromDeposits.h.

Referenced by SingleDeposit().

double CandIsolatorFromDeposits::SingleDeposit::weight_
private

Definition at line 47 of file CandIsolatorFromDeposits.h.

Referenced by SingleDeposit().

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

Definition at line 48 of file CandIsolatorFromDeposits.h.