1 #ifndef CommonTools_ParticleFlow_TopProjectorAlgo
2 #define CommonTools_ParticleFlow_TopProjectorAlgo
35 template<
class Top,
class Bottom>
71 std::vector<bool>& masked )
const;
75 const edm::Handle< std::vector<Bottom> >& allPFCandidates ,
76 std::vector<bool>& masked,
81 const edm::Handle< std::vector<Bottom> >& allPFCandidates )
const;
95 template<
class Top,
class Bottom>
103 template<
class Top,
class Bottom >
111 cout<<
"produce "<<tops.id()<<
" "<<bottoms.id()<<endl;
135 bottomOutput.reserve( bottoms->size() );
142 vector<bool> masked( bottoms->size(),
false);
144 processCollection( tops, bottoms, masked, name_.c_str(),
iEvent );
149 cout<<
" Remaining candidates in the bottom collection ------ "<<endl;
151 for(
unsigned i=0;
i<inCands.size();
i++) {
155 cout<<
"X "<<i<<
" "<<inCands[
i]<<endl;
160 cout<<
"O "<<i<<
" "<<inCands[
i]<<endl;
162 pBottomOutput->push_back( inCands[i] );
164 pBottomOutput->back().setSourceCandidatePtr(motherPtr);
173 template<
class Top,
class Bottom >
175 const edm::Handle< std::vector<Bottom> >& bottoms ,
176 std::vector<bool>& masked,
180 if( tops.isValid() && bottoms.isValid() ) {
185 <<
" size = "<<topCollection.size()<<std::endl;
187 for(
unsigned i=0;
i<topCollection.size();
i++) {
195 ptrToAncestor( basePtr,
208 printAncestors( ancestors, bottoms );
211 maskAncestors( ancestors, masked );
218 template<
class Top,
class Bottom >
220 const edm::Handle< std::vector<Bottom> >& allPFCandidates )
const {
223 std::vector<Bottom> pfs = *allPFCandidates;
225 for(
unsigned i=0;
i<ancestors.
size();
i++) {
228 assert(
id == allPFCandidates.id() );
230 unsigned index = ancestors[
i].key();
231 assert( index < pfs.size() );
239 template<
class Top,
class Bottom >
248 unsigned nSources = candPtr->numberOfSourceCandidatePtrs();
259 for(
unsigned i=0;
i<nSources;
i++) {
267 if( mother.id() != ancestorsID ) {
269 ptrToAncestor( mother, ancestors, ancestorsID, iEvent );
281 template<
class Top,
class Bottom >
283 std::vector<bool>& masked )
const {
285 for(
unsigned i=0;
i<ancestors.
size();
i++) {
286 unsigned index = ancestors[
i].key();
287 assert( index<masked.size() );
293 masked[
index] =
true;
T getUntrackedParameter(std::string const &, T const &) const
edm::Ptr< Bottom > BottomPtr
size_type size() const
Size of the RefVector.
void push_back(Ptr< T > const &iPtr)
BottomCollection produce(const TopHandle &topHandle, const BottomHandle &bottomHandle, const edm::EventBase &iEvent)
TopProjectorAlgo(const edm::ParameterSet &)
edm::Handle< std::vector< Top > > TopHandle
ProductID id() const
Accessor for product ID.
std::vector< Top > TopCollection
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 printAncestors(const reco::CandidatePtrVector &ancestors, const edm::Handle< std::vector< Bottom > > &allPFCandidates) const
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
void maskAncestors(const reco::CandidatePtrVector &ancestors, std::vector< bool > &masked) const
std::vector< Bottom > BottomCollection
edm::Handle< std::vector< Bottom > > BottomHandle
void ptrToAncestor(reco::CandidatePtr candRef, reco::CandidatePtrVector &ancestors, const edm::ProductID &ancestorsID, const edm::EventBase &iEvent) const