1 #ifndef PhysicsTools_PFCandProducer_TopProjector_
2 #define PhysicsTools_PFCandProducer_TopProjector_
36 template<
class Top,
class Bottom>
70 std::vector<bool>& masked )
const;
74 const edm::Handle< std::vector<Bottom> >& allPFCandidates ,
75 std::vector<bool>& masked,
80 const edm::Handle< std::vector<Bottom> >& allPFCandidates )
const;
102 template<
class Top,
class Bottom>
104 enable_(iConfig.getParameter<bool>(
"enable")) {
113 produces< std::vector<Bottom> >();
117 template<
class Top,
class Bottom >
145 iEvent.
getByLabel( inputTagBottom_, bottoms );
161 std::cout<<
"Inputs --------------------"<<std::endl;
163 <<tops.
id()<<
"\t"<<tops->size()<<std::endl
166 <<bottoms.
id()<<
"\t"<<bottoms->size()<<std::endl
174 std::auto_ptr< BottomCollection >
179 std::vector<bool> masked( bottoms->size(),
false);
182 processCollection( tops, bottoms, masked, name_.c_str(),
iEvent );
187 std::cout<<
" Remaining candidates in the bottom collection ------ "<<std::endl;
189 for(
unsigned i=0;
i<inCands.size();
i++) {
193 std::cout<<
"X "<<i<<
" "<<inCands[
i]<<std::endl;
198 std::cout<<
"O "<<i<<
" "<<inCands[
i]<<std::endl;
200 pBottomOutput->push_back( inCands[i] );
202 pBottomOutput->back().setSourceCandidatePtr(motherPtr);
206 iEvent.
put( pBottomOutput );
211 template<
class Top,
class Bottom >
213 const edm::Handle< std::vector<Bottom> >& bottoms ,
214 std::vector<bool>& masked,
218 if( tops.isValid() && bottoms.isValid() ) {
222 std::cout<<
"******* TopProjector "<<objectName
223 <<
" size = "<<topCollection.size()<<
" ******** "<<std::endl;
225 for(
unsigned i=0;
i<topCollection.size();
i++) {
233 ptrToAncestor( basePtr,
246 printAncestors( ancestors, bottoms );
249 maskAncestors( ancestors, masked );
256 template<
class Top,
class Bottom >
258 const edm::Handle< std::vector<Bottom> >& allPFCandidates )
const {
261 std::vector<Bottom> pfs = *allPFCandidates;
263 for(
unsigned i=0;
i<ancestors.
size();
i++) {
266 assert(
id == allPFCandidates.id() );
268 unsigned index = ancestors[
i].key();
269 assert( index < pfs.size() );
277 template<
class Top,
class Bottom >
285 unsigned nSources = candPtr->numberOfSourceCandidatePtrs();
291 <<
"/"<<candPtr.
key()<<
" #mothers "<<nSources
292 <<
" ancestor id "<<ancestorsID<<std::endl
296 for(
unsigned i=0;
i<nSources;
i++) {
303 if( mother.
id() != ancestorsID ) {
305 ptrToAncestor( mother, ancestors, ancestorsID, iEvent );
317 template<
class Top,
class Bottom >
319 std::vector<bool>& masked )
const {
321 for(
unsigned i=0;
i<ancestors.
size();
i++) {
322 unsigned index = ancestors[
i].key();
323 assert( index<masked.size() );
329 masked[
index] =
true;
T getParameter(std::string const &) const
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
edm::Handle< std::vector< Top > > TopHandle
size_type size() const
Size of the RefVector.
std::vector< Bottom > BottomCollection
std::vector< Top > TopCollection
void push_back(Ptr< T > const &iPtr)
edm::InputTag inputTagTop_
input tag for the top (masking) collection
ProductID id() const
Accessor for product ID.
bool enable_
enable? if not, all candidates in the bottom collection are copied to the output collection ...
edm::Handle< std::vector< Bottom > > BottomHandle
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
ProductID id() const
Accessor for product ID.
TopProjector(const edm::ParameterSet &)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
void ptrToAncestor(reco::CandidatePtr candRef, reco::CandidatePtrVector &ancestors, const edm::ProductID &ancestorsID, const edm::Event &iEvent) 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
BranchDescription const & branchDescription() const
edm::InputTag inputTagBottom_
input tag for the masked collection.
std::string name_
name of the top projection
void produce(edm::Event &, const edm::EventSetup &)
edm::Ptr< Bottom > BottomPtr
Provenance getProvenance(BranchID const &theID) const
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