CMS 3D CMS Logo

Classes | Public Types | Public Member Functions | Private Attributes

PFCandIsolatorFromDeposits Class Reference

#include <PFCandIsolatorFromDeposit.h>

Inheritance diagram for PFCandIsolatorFromDeposits:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Classes

class  SingleDeposit

Public Types

typedef edm::ValueMap< double > CandDoubleMap
enum  Mode {
  Sum, SumRelative, Sum2, Sum2Relative,
  Max, MaxRelative, Count, NearestDR
}

Public Member Functions

 PFCandIsolatorFromDeposits (const edm::ParameterSet &)
 constructor with config
virtual void produce (edm::Event &, const edm::EventSetup &)
 build deposits
virtual ~PFCandIsolatorFromDeposits ()
 destructor

Private Attributes

std::vector< SingleDepositsources_

Detailed Description

Definition at line 22 of file PFCandIsolatorFromDeposit.h.


Member Typedef Documentation

Definition at line 25 of file PFCandIsolatorFromDeposit.h.


Member Enumeration Documentation

Enumerator:
Sum 
SumRelative 
Sum2 
Sum2Relative 
Max 
MaxRelative 
Count 
NearestDR 

Definition at line 27 of file PFCandIsolatorFromDeposit.h.


Constructor & Destructor Documentation

PFCandIsolatorFromDeposits::PFCandIsolatorFromDeposits ( const edm::ParameterSet par)

constructor with config

Definition at line 163 of file PFCandIsolatorFromDeposit.cc.

References edm::ParameterSet::getParameter(), and sources_.

                                                                              {
  typedef std::vector<edm::ParameterSet> VPSet;
  VPSet depPSets = par.getParameter<VPSet>("deposits");
  for (VPSet::const_iterator it = depPSets.begin(), ed = depPSets.end(); it != ed; ++it) {
    sources_.push_back(SingleDeposit(*it));
  }
  if (sources_.size() == 0) throw cms::Exception("Configuration Error") << "Please specify at least one deposit!";
  produces<CandDoubleMap>();
}
PFCandIsolatorFromDeposits::~PFCandIsolatorFromDeposits ( ) [virtual]

destructor

Definition at line 174 of file PFCandIsolatorFromDeposit.cc.

References begin, end, and sources_.

                                                        {
  std::vector<SingleDeposit>::iterator it, begin = sources_.begin(), end = sources_.end();
  for (it = begin; it != end; ++it) it->cleanup();
}

Member Function Documentation

void PFCandIsolatorFromDeposits::produce ( edm::Event event,
const edm::EventSetup eventSetup 
) [virtual]

build deposits

Implements edm::EDProducer.

Definition at line 180 of file PFCandIsolatorFromDeposit.cc.

References edm::View< T >::begin(), edm::ValueMap< T >::begin(), begin, end, edm::ValueMap< T >::end(), edm::helper::Filler< Map >::fill(), edm::helper::Filler< Map >::insert(), edm::View< T >::refAt(), run_regression::ret, edm::ValueMap< T >::size(), and sources_.

                                                                                  {

  std::vector<SingleDeposit>::iterator it, begin = sources_.begin(), end = sources_.end();
  for (it = begin; it != end; ++it) it->open(event, eventSetup);

  const IsoDepositMap & map = begin->map();

  if (map.size()==0) { // !!???
        event.put(std::auto_ptr<CandDoubleMap>(new CandDoubleMap()));
        return;
  }
  std::auto_ptr<CandDoubleMap> ret(new CandDoubleMap());
  CandDoubleMap::Filler filler(*ret);

  typedef reco::IsoDepositMap::const_iterator iterator_i; 
  typedef reco::IsoDepositMap::container::const_iterator iterator_ii; 
  iterator_i depI = map.begin(); 
  iterator_i depIEnd = map.end(); 
  for (; depI != depIEnd; ++depI){ 
    std::vector<double> retV(depI.size(),0);
    edm::Handle<edm::View<reco::Candidate> > candH;
    event.get(depI.id(), candH);
    const edm::View<reco::Candidate>& candV = *candH;

    iterator_ii depII = depI.begin(); 
    iterator_ii depIIEnd = depI.end(); 
    size_t iRet = 0;
    for (; depII != depIIEnd; ++depII,++iRet){ 
      double sum=0;
      for (it = begin; it != end; ++it) sum += it->compute(candV.refAt(iRet)); 
      retV[iRet] = sum;
    }
    filler.insert(candH, retV.begin(), retV.end());
  }
  filler.fill();
  event.put(ret);
}

Member Data Documentation