CMS 3D CMS Logo

Public Member Functions | Private Attributes

ObjectViewCleaner< T > Class Template Reference

Inheritance diagram for ObjectViewCleaner< T >:
edm::EDProducer edm::EDProducer edm::ProducerBase edm::ProducerBase edm::ProductRegistryHelper edm::ProductRegistryHelper

List of all members.

Public Member Functions

void endJob ()
void endJob ()
 ObjectViewCleaner (const edm::ParameterSet &iConfig)
 ObjectViewCleaner (const edm::ParameterSet &iConfig)
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)
virtual ~ObjectViewCleaner ()
virtual ~ObjectViewCleaner ()

Private Attributes

double deltaRMin_
std::string moduleLabel_
unsigned int nObjectsClean_
unsigned int nObjectsTot_
StringCutObjectSelector< T, true > objKeepCut_
StringCutObjectSelector
< reco::Candidate, true > 
objRemoveCut_
edm::InputTag srcCands_
std::vector< edm::InputTagsrcObjects_

Detailed Description

template<typename T>
class ObjectViewCleaner< T >

Definition at line 54 of file ObjectViewCleaner.cc.


Constructor & Destructor Documentation

template<typename T >
ObjectViewCleaner< T >::ObjectViewCleaner ( const edm::ParameterSet iConfig)

Definition at line 89 of file ObjectViewCleaner.cc.

  : srcCands_    (iConfig.getParameter<edm::InputTag>         ("srcObject"))
  , srcObjects_ (iConfig.getParameter<vector<edm::InputTag> >("srcObjectsToRemove"))
  , deltaRMin_  (iConfig.getParameter<double>                ("deltaRMin"))
  , moduleLabel_(iConfig.getParameter<string>                ("@module_label"))
  , objKeepCut_(iConfig.existsAs<std::string>("srcObjectSelection") ? iConfig.getParameter<std::string>("srcObjectSelection") : "", true)
  ,objRemoveCut_(iConfig.existsAs<std::string>("srcObjectsToRemoveSelection") ? iConfig.getParameter<std::string>("srcObjectsToRemoveSelection") : "", true)
  , nObjectsTot_(0)
  , nObjectsClean_(0)
{
  produces<edm::RefToBaseVector<T> >();
}
template<typename T >
ObjectViewCleaner< T >::~ObjectViewCleaner ( ) [virtual]

Definition at line 105 of file ObjectViewCleaner.cc.

{
  
}
template<typename T >
ObjectViewCleaner< T >::ObjectViewCleaner ( const edm::ParameterSet iConfig)
template<typename T >
virtual ObjectViewCleaner< T >::~ObjectViewCleaner ( ) [virtual]

Member Function Documentation

template<typename T >
void ObjectViewCleaner< T >::endJob ( void  ) [virtual]

Reimplemented from edm::EDProducer.

Definition at line 160 of file ObjectViewCleaner.cc.

References gather_cfg::cout.

{
  stringstream ss;
  ss<<"nObjectsTot="<<nObjectsTot_<<" nObjectsClean="<<nObjectsClean_
    <<" fObjectsClean="<<100.*(nObjectsClean_/(double)nObjectsTot_)<<"%\n";
  cout<<"++++++++++++++++++++++++++++++++++++++++++++++++++"
      <<"\n"<<moduleLabel_<<"(ObjectViewCleaner) SUMMARY:\n"<<ss.str()
      <<"++++++++++++++++++++++++++++++++++++++++++++++++++"
      <<endl;
}
template<typename T >
void ObjectViewCleaner< T >::endJob ( ) [virtual]

Reimplemented from edm::EDProducer.

template<typename T >
void ObjectViewCleaner< T >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDProducer.

template<typename T >
void ObjectViewCleaner< T >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDProducer.

Definition at line 118 of file ObjectViewCleaner.cc.

References reco::deltaR(), deltaR(), edm::Event::getByLabel(), VarParsing::obj, and edm::Event::put().

{
  auto_ptr<edm::RefToBaseVector<T> >
    cleanObjects(new edm::RefToBaseVector<T >());

  edm::Handle<edm::View<T> > candidates;
  iEvent.getByLabel(srcCands_,candidates);
  
  bool* isClean = new bool[candidates->size()];
  for (unsigned int iObject=0;iObject<candidates->size();iObject++) isClean[iObject] = true;
  
  for (unsigned int iSrc=0;iSrc<srcObjects_.size();iSrc++) {
    edm::Handle<edm::View<reco::Candidate> > objects;
    iEvent.getByLabel(srcObjects_[iSrc],objects);
    
    for (unsigned int iObject=0;iObject<candidates->size();iObject++) {
      const T& candidate = candidates->at(iObject);
      if (!objKeepCut_(candidate)) isClean[iObject] = false;

      for (unsigned int iObj=0;iObj<objects->size();iObj++) {
        const reco::Candidate& obj = objects->at(iObj);
        if (!objRemoveCut_(obj)) continue;

        double deltaR = reco::deltaR(candidate,obj);
        if (deltaR<deltaRMin_)  isClean[iObject] = false;
      }
    }
  }
  
  for (unsigned int iObject=0;iObject<candidates->size();iObject++)
    if (isClean[iObject]) cleanObjects->push_back(candidates->refAt(iObject));
  
  nObjectsTot_  +=candidates->size();
  nObjectsClean_+=cleanObjects->size();

  delete [] isClean;  
  iEvent.put(cleanObjects);
}

Member Data Documentation

template<typename T >
double ObjectViewCleaner< T >::deltaRMin_ [private]

Definition at line 69 of file ObjectViewCleaner.cc.

template<typename T >
std::string ObjectViewCleaner< T >::moduleLabel_ [private]

Definition at line 71 of file ObjectViewCleaner.cc.

template<typename T >
unsigned int ObjectViewCleaner< T >::nObjectsClean_ [private]

Definition at line 76 of file ObjectViewCleaner.cc.

template<typename T >
unsigned int ObjectViewCleaner< T >::nObjectsTot_ [private]

Definition at line 75 of file ObjectViewCleaner.cc.

template<typename T >
StringCutObjectSelector< T, true > ObjectViewCleaner< T >::objKeepCut_ [private]

Definition at line 72 of file ObjectViewCleaner.cc.

template<typename T >
StringCutObjectSelector< reco::Candidate, true > ObjectViewCleaner< T >::objRemoveCut_ [private]

Definition at line 73 of file ObjectViewCleaner.cc.

template<typename T >
edm::InputTag ObjectViewCleaner< T >::srcCands_ [private]

Definition at line 67 of file ObjectViewCleaner.cc.

template<typename T >
std::vector< edm::InputTag > ObjectViewCleaner< T >::srcObjects_ [private]

Definition at line 68 of file ObjectViewCleaner.cc.