CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions | Private Attributes

pf2pat::TopProjectorAlgo< Top, Bottom > Class Template Reference

#include <TopProjectorAlgo.h>

List of all members.

Public Types

typedef std::vector< Bottom > BottomCollection
typedef edm::Handle
< std::vector< Bottom > > 
BottomHandle
typedef edm::Ptr< Bottom > BottomPtr
typedef std::vector< Top > TopCollection
typedef edm::Handle
< std::vector< Top > > 
TopHandle

Public Member Functions

BottomCollection produce (const TopHandle &topHandle, const BottomHandle &bottomHandle, const edm::EventBase &iEvent)
 TopProjectorAlgo (const edm::ParameterSet &)
 ~TopProjectorAlgo ()

Private Member Functions

void maskAncestors (const reco::CandidatePtrVector &ancestors, std::vector< bool > &masked) const
void printAncestors (const reco::CandidatePtrVector &ancestors, const edm::Handle< std::vector< Bottom > > &allPFCandidates) const
void processCollection (const edm::Handle< std::vector< Top > > &handle, const edm::Handle< std::vector< Bottom > > &allPFCandidates, std::vector< bool > &masked, const char *objectName, const edm::EventBase &iEvent) const
void ptrToAncestor (reco::CandidatePtr candRef, reco::CandidatePtrVector &ancestors, const edm::ProductID &ancestorsID, const edm::EventBase &iEvent) const

Private Attributes

std::string name_
bool verbose_
 verbose ?

Detailed Description

template<class Top, class Bottom>
class pf2pat::TopProjectorAlgo< Top, Bottom >

Definition at line 36 of file TopProjectorAlgo.h.


Member Typedef Documentation

template<class Top , class Bottom >
typedef std::vector<Bottom> pf2pat::TopProjectorAlgo< Top, Bottom >::BottomCollection

Definition at line 42 of file TopProjectorAlgo.h.

template<class Top , class Bottom >
typedef edm::Handle< std::vector<Bottom> > pf2pat::TopProjectorAlgo< Top, Bottom >::BottomHandle

Definition at line 43 of file TopProjectorAlgo.h.

template<class Top , class Bottom >
typedef edm::Ptr<Bottom> pf2pat::TopProjectorAlgo< Top, Bottom >::BottomPtr

Definition at line 44 of file TopProjectorAlgo.h.

template<class Top , class Bottom >
typedef std::vector<Top> pf2pat::TopProjectorAlgo< Top, Bottom >::TopCollection

Definition at line 40 of file TopProjectorAlgo.h.

template<class Top , class Bottom >
typedef edm::Handle< std::vector<Top> > pf2pat::TopProjectorAlgo< Top, Bottom >::TopHandle

Definition at line 41 of file TopProjectorAlgo.h.


Constructor & Destructor Documentation

template<class Top , class Bottom >
TopProjectorAlgo::TopProjectorAlgo ( const edm::ParameterSet iConfig)

Definition at line 96 of file TopProjectorAlgo.h.

References edm::ParameterSet::getUntrackedParameter().

                                                                                {

  verbose_ = iConfig.getUntrackedParameter<bool>("verbose",false);
  name_ = iConfig.getUntrackedParameter<std::string>("name","No Name");
}
template<class Top , class Bottom >
pf2pat::TopProjectorAlgo< Top, Bottom >::~TopProjectorAlgo ( ) [inline]

Definition at line 48 of file TopProjectorAlgo.h.

{};

Member Function Documentation

template<class Top , class Bottom >
void TopProjectorAlgo::maskAncestors ( const reco::CandidatePtrVector ancestors,
std::vector< bool > &  masked 
) const [private]

ancestors is a RefToBase vector. For each object in this vector get the index and set the corresponding slot to true in the masked vector

Definition at line 282 of file TopProjectorAlgo.h.

References i, getHLTprescales::index, and edm::PtrVectorBase::size().

                                                                         {
  
  for(unsigned i=0; i<ancestors.size(); i++) {
    unsigned index = ancestors[i].key();
    assert( index<masked.size() );
    
    //     if(verbose_) {
    //       ProductID id = ancestors[i].id();
    //       cout<<"\tmasking "<<index<<", ancestor "<<id<<"/"<<index<<endl;
    //     }
    masked[index] = true;
  }
}
template<class Top , class Bottom >
void TopProjectorAlgo::printAncestors ( const reco::CandidatePtrVector ancestors,
const edm::Handle< std::vector< Bottom > > &  allPFCandidates 
) const [private]

Definition at line 219 of file TopProjectorAlgo.h.

References gather_cfg::cout, i, edm::PtrVectorBase::id(), getHLTprescales::index, and edm::PtrVectorBase::size().

                                                                                                    {
  

  std::vector<Bottom> pfs = *allPFCandidates;

  for(unsigned i=0; i<ancestors.size(); i++) {

    edm::ProductID id = ancestors[i].id();
    assert( id == allPFCandidates.id() );
 
    unsigned index = ancestors[i].key();
    assert( index < pfs.size() );
    
    std::cout<<"\t\t"<<pfs[index]<<std::endl;
  }
}
template<class Top , class Bottom >
void TopProjectorAlgo::processCollection ( const edm::Handle< std::vector< Top > > &  handle,
const edm::Handle< std::vector< Bottom > > &  allPFCandidates,
std::vector< bool > &  masked,
const char *  objectName,
const edm::EventBase iEvent 
) const [private]

Definition at line 174 of file TopProjectorAlgo.h.

References gather_cfg::cout, i, edm::PtrVectorBase::id(), iEvent, and benchmark_cfg::topCollection.

                                                                                           {

  if( tops.isValid() && bottoms.isValid() ) {
    const std::vector<Top>& topCollection = *tops;
    
    if(verbose_) 
      std::cout<<" processing: "<<objectName
               <<" size = "<<topCollection.size()<<std::endl;
    
    for(unsigned i=0; i<topCollection.size(); i++) {
      
      
      edm::Ptr<Top>   ptr( tops, i);
      reco::CandidatePtr basePtr( ptr );
 
      
      reco::CandidatePtrVector ancestors;
      ptrToAncestor( basePtr,
                     ancestors,
                     bottoms.id(), 
                     iEvent );
      
      if(verbose_) {
/*      std::cout<<"\t"<<objectName<<" "<<i */
/*               <<" pt,eta,phi = " */
/*               <<basePtr->pt()<<"," */
/*               <<basePtr->eta()<<"," */
/*               <<basePtr->phi()<<std::endl; */
        
        std::cout<<"\t"<<topCollection[i]<<std::endl;
        printAncestors( ancestors, bottoms );
      }
  
      maskAncestors( ancestors, masked );
    }
  }

}
template<class Top , class Bottom >
BottomCollection pf2pat::TopProjectorAlgo< Top, Bottom >::produce ( const TopHandle topHandle,
const BottomHandle bottomHandle,
const edm::EventBase iEvent 
)
template<class Top , class Bottom >
void TopProjectorAlgo::ptrToAncestor ( reco::CandidatePtr  candRef,
reco::CandidatePtrVector ancestors,
const edm::ProductID ancestorsID,
const edm::EventBase iEvent 
) const [private]

fills ancestors with ptrs to the PFCandidates that in one way or another contribute to the candidate pointed to by candPtr

Definition at line 241 of file TopProjectorAlgo.h.

References i, and edm::PtrVector< T >::push_back().

                                                                           {

  

  unsigned nSources = candPtr->numberOfSourceCandidatePtrs();

/*   if(verbose_) { */
/*     const Provenance& hereProv = iEvent.getProvenance(candPtr.id()); */

/*     cout<<"going down from "<<candPtr.id() */
/*      <<"/"<<candPtr.key()<<" #mothers "<<nSources */
/*      <<" ancestor id "<<ancestorsID<<endl */
/*      <<hereProv.branchDescription()<<endl; */
/*   }   */

  for(unsigned i=0; i<nSources; i++) {
    
    CandidatePtr mother = candPtr->sourceCandidatePtr(i);
/*     if( verbose_ ) { */
/*       const Provenance& motherProv = iEvent.getProvenance(mother.id()); */
/*       cout<<"  mother id "<<mother.id()<<endl */
/*        <<motherProv<<endl; */
/*     } */
    if(  mother.id() != ancestorsID ) {
      // the mother is not yet at lowest level
      ptrToAncestor( mother, ancestors, ancestorsID, iEvent );
    }
    else {
      // adding mother to the list of ancestors
      ancestors.push_back( mother ); 
    }
  }
}

Member Data Documentation

template<class Top , class Bottom >
std::string pf2pat::TopProjectorAlgo< Top, Bottom >::name_ [private]

Definition at line 88 of file TopProjectorAlgo.h.

template<class Top , class Bottom >
bool pf2pat::TopProjectorAlgo< Top, Bottom >::verbose_ [private]

verbose ?

Definition at line 85 of file TopProjectorAlgo.h.