CMS 3D CMS Logo

Classes | Public Types | Public Member Functions | Private Attributes

CandIsolatorFromDeposits Class Reference

#include <CandIsolatorFromDeposits.h>

Inheritance diagram for CandIsolatorFromDeposits:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase 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,
  MeanDR, SumDR
}

Public Member Functions

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

Private Attributes

std::vector< SingleDepositsources_

Detailed Description

Definition at line 22 of file CandIsolatorFromDeposits.h.


Member Typedef Documentation

Definition at line 25 of file CandIsolatorFromDeposits.h.


Member Enumeration Documentation

Enumerator:
Sum 
SumRelative 
Sum2 
Sum2Relative 
Max 
MaxRelative 
Count 
NearestDR 
MeanDR 
SumDR 

Definition at line 27 of file CandIsolatorFromDeposits.h.


Constructor & Destructor Documentation

CandIsolatorFromDeposits::CandIsolatorFromDeposits ( const edm::ParameterSet par)

constructor with config

Definition at line 118 of file CandIsolatorFromDeposits.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>();
}
CandIsolatorFromDeposits::~CandIsolatorFromDeposits ( ) [virtual]

destructor

Definition at line 129 of file CandIsolatorFromDeposits.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 CandIsolatorFromDeposits::produce ( edm::Event event,
const edm::EventSetup eventSetup 
) [virtual]

build deposits

Implements edm::EDProducer.

Definition at line 135 of file CandIsolatorFromDeposits.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