#include <TopProjector.h>
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 | |
void | produce (edm::Event &, const edm::EventSetup &) |
TopProjector (const edm::ParameterSet &) | |
~TopProjector () | |
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::Event &iEvent) const |
void | ptrToAncestor (reco::CandidatePtr candRef, reco::CandidatePtrVector &ancestors, const edm::ProductID &ancestorsID, const edm::Event &iEvent) const |
Private Attributes | |
bool | enable_ |
enable? if not, all candidates in the bottom collection are copied to the output collection | |
edm::InputTag | inputTagBottom_ |
input tag for the masked collection. | |
edm::InputTag | inputTagTop_ |
input tag for the top (masking) collection | |
std::string | name_ |
name of the top projection | |
bool | verbose_ |
verbose ? |
Definition at line 37 of file TopProjector.h.
typedef std::vector<Bottom> TopProjector< Top, Bottom >::BottomCollection |
Definition at line 43 of file TopProjector.h.
typedef edm::Handle< std::vector<Bottom> > TopProjector< Top, Bottom >::BottomHandle |
Definition at line 44 of file TopProjector.h.
typedef edm::Ptr<Bottom> TopProjector< Top, Bottom >::BottomPtr |
Definition at line 45 of file TopProjector.h.
typedef std::vector<Top> TopProjector< Top, Bottom >::TopCollection |
Definition at line 41 of file TopProjector.h.
typedef edm::Handle< std::vector<Top> > TopProjector< Top, Bottom >::TopHandle |
Definition at line 42 of file TopProjector.h.
TopProjector< Top, Bottom >::TopProjector | ( | const edm::ParameterSet & | iConfig | ) |
Definition at line 103 of file TopProjector.h.
References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), TopProjector< Top, Bottom >::inputTagBottom_, TopProjector< Top, Bottom >::inputTagTop_, TopProjector< Top, Bottom >::name_, and TopProjector< Top, Bottom >::verbose_.
: enable_(iConfig.getParameter<bool>("enable")) { verbose_ = iConfig.getUntrackedParameter<bool>("verbose",false); name_ = iConfig.getUntrackedParameter<std::string>("name","No Name"); inputTagTop_ = iConfig.getParameter<edm::InputTag>("topCollection"); inputTagBottom_ = iConfig.getParameter<edm::InputTag>("bottomCollection"); // will produce a collection of the unmasked candidates in the // bottom collection produces< std::vector<Bottom> >(); }
TopProjector< Top, Bottom >::~TopProjector | ( | ) | [inline] |
Definition at line 49 of file TopProjector.h.
{};
void TopProjector< Top, Bottom >::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 318 of file TopProjector.h.
References i, getHLTprescales::index, and edm::PtrVectorBase::size().
void TopProjector< Top, Bottom >::printAncestors | ( | const reco::CandidatePtrVector & | ancestors, |
const edm::Handle< std::vector< Bottom > > & | allPFCandidates | ||
) | const [private] |
Definition at line 257 of file TopProjector.h.
References gather_cfg::cout, i, edm::PtrVectorBase::id(), getHLTprescales::index, and edm::PtrVectorBase::size().
void TopProjector< Top, Bottom >::processCollection | ( | const edm::Handle< std::vector< Top > > & | handle, |
const edm::Handle< std::vector< Bottom > > & | allPFCandidates, | ||
std::vector< bool > & | masked, | ||
const char * | objectName, | ||
const edm::Event & | iEvent | ||
) | const [private] |
Definition at line 212 of file TopProjector.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<<"******* TopProjector "<<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 ); } } }
void TopProjector< Top, Bottom >::produce | ( | edm::Event & | iEvent, |
const edm::EventSetup & | iSetup | ||
) | [virtual] |
Implements edm::EDProducer.
Definition at line 118 of file TopProjector.h.
References edm::Provenance::branchDescription(), gather_cfg::cout, edm::EventID::event(), edm::Event::getByLabel(), edm::Event::getProvenance(), i, edm::HandleBase::id(), edm::EventBase::id(), iEvent, and edm::Event::put().
{ if( verbose_) std::cout<<"Event -------------------- "<<iEvent.id().event()<<std::endl; // get the various collections // Access the masking collection TopHandle tops; iEvent.getByLabel( inputTagTop_, tops ); /* if( !tops.isValid() ) { */ /* std::ostringstream err; */ /* err<<"The top collection must be supplied."<<std::endl */ /* <<"It is now set to : "<<inputTagTop_<<std::endl; */ /* edm::LogError("PFPAT")<<err.str(); */ /* throw cms::Exception( "MissingProduct", err.str()); */ /* } */ // Access the collection to // be masked by the other ones BottomHandle bottoms; iEvent.getByLabel( inputTagBottom_, bottoms ); /* if( !bottoms.isValid() ) { */ /* std::ostringstream err; */ /* err<<"The bottom collection must be supplied."<<std::endl */ /* <<"It is now set to : "<<inputTagBottom_<<std::endl; */ /* edm::LogError("PFPAT")<<err.str(); */ /* throw cms::Exception( "MissingProduct", err.str()); */ /* } */ if(verbose_) { const edm::Provenance& topProv = iEvent.getProvenance(tops.id()); const edm::Provenance& bottomProv = iEvent.getProvenance(bottoms.id()); std::cout<<"Top projector: event "<<iEvent.id().event()<<std::endl; std::cout<<"Inputs --------------------"<<std::endl; std::cout<<"Top : " <<tops.id()<<"\t"<<tops->size()<<std::endl <<topProv.branchDescription()<<std::endl <<"Bottom : " <<bottoms.id()<<"\t"<<bottoms->size()<<std::endl <<bottomProv.branchDescription()<<std::endl; } // output collection of objects, // selected from the Bottom collection std::auto_ptr< BottomCollection > pBottomOutput( new BottomCollection ); // mask for each bottom object. // at the beginning, all bottom objects are unmasked. std::vector<bool> masked( bottoms->size(), false); if( enable_ ) processCollection( tops, bottoms, masked, name_.c_str(), iEvent ); const BottomCollection& inCands = *bottoms; if(verbose_) std::cout<<" Remaining candidates in the bottom collection ------ "<<std::endl; for(unsigned i=0; i<inCands.size(); i++) { if(masked[i]) { if(verbose_) std::cout<<"X "<<i<<" "<<inCands[i]<<std::endl; continue; } else { if(verbose_) std::cout<<"O "<<i<<" "<<inCands[i]<<std::endl; pBottomOutput->push_back( inCands[i] ); BottomPtr motherPtr( bottoms, i ); pBottomOutput->back().setSourceCandidatePtr(motherPtr); } } iEvent.put( pBottomOutput ); }
void TopProjector< Top, Bottom >::ptrToAncestor | ( | reco::CandidatePtr | candRef, |
reco::CandidatePtrVector & | ancestors, | ||
const edm::ProductID & | ancestorsID, | ||
const edm::Event & | 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 279 of file TopProjector.h.
References edm::Provenance::branchDescription(), gather_cfg::cout, edm::Event::getProvenance(), i, edm::Ptr< T >::id(), edm::Ptr< T >::key(), and edm::PtrVector< T >::push_back().
{ unsigned nSources = candPtr->numberOfSourceCandidatePtrs(); if(verbose_) { const edm::Provenance& hereProv = iEvent.getProvenance(candPtr.id()); std::cout<<"going down from "<<candPtr.id() <<"/"<<candPtr.key()<<" #mothers "<<nSources <<" ancestor id "<<ancestorsID<<std::endl <<hereProv.branchDescription()<<std::endl; } for(unsigned i=0; i<nSources; i++) { reco::CandidatePtr mother = candPtr->sourceCandidatePtr(i); if( verbose_ ) { /* const Provenance& motherProv = iEvent.getProvenance(mother.id()); */ std::cout<<" mother id "<<mother.id()<<std::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 ); } } }
bool TopProjector< Top, Bottom >::enable_ [private] |
enable? if not, all candidates in the bottom collection are copied to the output collection
Definition at line 84 of file TopProjector.h.
edm::InputTag TopProjector< Top, Bottom >::inputTagBottom_ [private] |
input tag for the masked collection.
Definition at line 96 of file TopProjector.h.
Referenced by TopProjector< Top, Bottom >::TopProjector().
edm::InputTag TopProjector< Top, Bottom >::inputTagTop_ [private] |
input tag for the top (masking) collection
Definition at line 93 of file TopProjector.h.
Referenced by TopProjector< Top, Bottom >::TopProjector().
std::string TopProjector< Top, Bottom >::name_ [private] |
name of the top projection
Definition at line 90 of file TopProjector.h.
Referenced by TopProjector< Top, Bottom >::TopProjector().
bool TopProjector< Top, Bottom >::verbose_ [private] |
verbose ?
Definition at line 87 of file TopProjector.h.
Referenced by TopProjector< Top, Bottom >::TopProjector().