CMS 3D CMS Logo

Public Member Functions | Private Attributes

CandIsolatorFromDeposits::SingleDeposit Class Reference

List of all members.

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_, Exception, edm::ParameterSet::getParameter(), isNumber(), IsoDepositVetoFactory::make(), CandIsolatorFromDeposits::Max, CandIsolatorFromDeposits::MaxRelative, mode, mode_, CandIsolatorFromDeposits::NearestDR, CandIsolatorFromDeposits::Sum, CandIsolatorFromDeposits::Sum2, CandIsolatorFromDeposits::Sum2Relative, CandIsolatorFromDeposits::SumRelative, toNumber(), usesFunction_, vetos_, CommonMethods::weight(), and weight_.

                                                                                   :
  src_(iConfig.getParameter<edm::InputTag>("src")),
  deltaR_(iConfig.getParameter<double>("deltaR")),
  weightExpr_(iConfig.getParameter<std::string>("weight")),
  skipDefaultVeto_(iConfig.getParameter<bool>("skipDefaultVeto"))
                                                      //,vetos_(new AbsVetos())
{
  std::string mode = iConfig.getParameter<std::string>("mode");
  if (mode == "sum") mode_ = Sum; 
  else if (mode == "sumRelative") mode_ = SumRelative; 
  else if (mode == "sum2") mode_ = Sum2;                  
  else if (mode == "sum2Relative") mode_ = Sum2Relative;
  else if (mode == "max") mode_ = Max;                  
  else if (mode == "maxRelative") mode_ = MaxRelative;
  else if (mode == "nearestDR") mode_ = NearestDR;
  else if (mode == "count") mode_ = Count;
  else throw cms::Exception("Not Implemented") << "Mode '" << mode << "' not implemented. " <<
    "Supported modes are 'sum', 'sumRelative', 'count'." << 
    //"Supported modes are 'sum', 'sumRelative', 'max', 'maxRelative', 'count'." << // TODO: on request only
    "New methods can be easily implemented if requested.";
  typedef std::vector<std::string> vstring;
  vstring vetos = iConfig.getParameter< vstring >("vetos");
  reco::isodeposit::EventDependentAbsVeto *evdep; 
  for (vstring::const_iterator it = vetos.begin(), ed = vetos.end(); it != ed; ++it) {
    vetos_.push_back(IsoDepositVetoFactory::make(it->c_str(), evdep));
    if (evdep) evdepVetos_.push_back(evdep);
  }
  std::string weight = iConfig.getParameter<std::string>("weight");
  if (isNumber(weight)) {
    //std::cout << "Weight is a simple number, " << toNumber(weight) << std::endl;
    weight_ = toNumber(weight);
    usesFunction_ = false;
  } else {
    usesFunction_ = true;
    //std::cout << "Weight is a function, this might slow you down... " << std::endl;
  }
  //std::cout << "CandIsolatorFromDeposits::SingleDeposit::SingleDeposit: Total of " << vetos_.size() << " vetos" << std::endl;
}

Member Function Documentation

void CandIsolatorFromDeposits::SingleDeposit::cleanup ( void  )

Definition at line 76 of file CandIsolatorFromDeposits.cc.

                                                    {
    for (AbsVetos::iterator it = vetos_.begin(), ed = vetos_.end(); it != ed; ++it) {
        delete *it;
    }
    vetos_.clear();
    // NOTE: we DON'T have to delete the evdepVetos_, they have already been deleted above. We just clear the vectors
    evdepVetos_.clear();
}
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_, eta(), reco::IsoDeposit::eta(), 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().

                                                                                      {
    const IsoDeposit &dep = (*hDeps_)[cand];
    double eta = dep.eta(), phi = dep.phi(); // better to center on the deposit direction
                                             // that could be, e.g., the impact point at calo
    for (AbsVetos::iterator it = vetos_.begin(), ed = vetos_.end(); it != ed; ++it) {
        (*it)->centerOn(eta, phi);
    }
    double weight = (usesFunction_ ? weightExpr_(*cand) : weight_);
    switch (mode_) {
        case Count:        return weight * dep.countWithin(deltaR_, vetos_, skipDefaultVeto_);
        case Sum:          return weight * dep.sumWithin(deltaR_, vetos_, skipDefaultVeto_);
        case SumRelative:  return weight * dep.sumWithin(deltaR_, vetos_, skipDefaultVeto_) / dep.candEnergy() ;
        case Sum2:         return weight * dep.sum2Within(deltaR_, vetos_, skipDefaultVeto_);
        case Sum2Relative: return weight * dep.sum2Within(deltaR_, vetos_, skipDefaultVeto_) / (dep.candEnergy() * dep.candEnergy()) ;
        case Max:          return weight * dep.maxWithin(deltaR_, vetos_, skipDefaultVeto_);
        case NearestDR:    return weight * dep.nearestDR(deltaR_, vetos_, skipDefaultVeto_);
        case MaxRelative:  return weight * dep.maxWithin(deltaR_, vetos_, skipDefaultVeto_) / dep.candEnergy() ;
    }
    throw cms::Exception("Logic error") << "Should not happen at " << __FILE__ << ", line " << __LINE__; // avoid gcc warning
}
const reco::IsoDepositMap& CandIsolatorFromDeposits::SingleDeposit::map ( ) [inline]

Definition at line 41 of file CandIsolatorFromDeposits.h.

References hDeps_.

{ return *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().

                                                                                                    {
    iEvent.getByLabel(src_, hDeps_);
    for (EventDependentAbsVetos::iterator it = evdepVetos_.begin(), ed = evdepVetos_.end(); it != ed; ++it) {
        (*it)->setEvent(iEvent,iSetup);
    }
}

Member Data Documentation

Definition at line 45 of file CandIsolatorFromDeposits.h.

Definition at line 50 of file CandIsolatorFromDeposits.h.

Referenced by SingleDeposit().

Definition at line 52 of file CandIsolatorFromDeposits.h.

Referenced by map().

Definition at line 43 of file CandIsolatorFromDeposits.h.

Referenced by SingleDeposit().

Definition at line 51 of file CandIsolatorFromDeposits.h.

Definition at line 44 of file CandIsolatorFromDeposits.h.

Definition at line 46 of file CandIsolatorFromDeposits.h.

Referenced by SingleDeposit().

Definition at line 49 of file CandIsolatorFromDeposits.h.

Referenced by SingleDeposit().

Definition at line 47 of file CandIsolatorFromDeposits.h.

Referenced by SingleDeposit().

Definition at line 48 of file CandIsolatorFromDeposits.h.