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 >
146 iEvent.
getByLabel( inputTagBottom_, bottoms );
164 std::cout<<
"Inputs --------------------"<<std::endl;
166 <<tops.
id()<<
"\t"<<tops->size()<<std::endl
169 <<bottoms.
id()<<
"\t"<<bottoms->size()<<std::endl
177 std::auto_ptr< BottomCollection >
182 std::vector<bool> masked( bottoms->size(),
false);
185 processCollection( tops, bottoms, masked, name_.c_str(),
iEvent );
190 std::cout<<
" Remaining candidates in the bottom collection ------ "<<std::endl;
192 for(
unsigned i=0;
i<inCands.size();
i++) {
196 std::cout<<
"X "<<i<<
" "<<inCands[
i]<<std::endl;
201 std::cout<<
"O "<<i<<
" "<<inCands[
i]<<std::endl;
203 pBottomOutput->push_back( inCands[i] );
205 pBottomOutput->back().setSourceCandidatePtr(motherPtr);
209 iEvent.
put( pBottomOutput );
214 template<
class Top,
class Bottom >
216 const edm::Handle< std::vector<Bottom> >& bottoms ,
217 std::vector<bool>& masked,
221 if( tops.isValid() && bottoms.isValid() ) {
225 std::cout<<
"******* TopProjector "<<objectName
226 <<
" size = "<<topCollection.size()<<
" ******** "<<std::endl;
228 for(
unsigned i=0;
i<topCollection.size();
i++) {
236 ptrToAncestor( basePtr,
249 printAncestors( ancestors, bottoms );
252 maskAncestors( ancestors, masked );
259 template<
class Top,
class Bottom >
261 const edm::Handle< std::vector<Bottom> >& allPFCandidates )
const {
264 std::vector<Bottom> pfs = *allPFCandidates;
266 for(
unsigned i=0;
i<ancestors.
size();
i++) {
269 assert(
id == allPFCandidates.id() );
271 unsigned index = ancestors[
i].key();
272 assert( index < pfs.size() );
280 template<
class Top,
class Bottom >
288 unsigned nSources = candPtr->numberOfSourceCandidatePtrs();
294 <<
"/"<<candPtr.
key()<<
" #mothers "<<nSources
295 <<
" ancestor id "<<ancestorsID<<std::endl
299 for(
unsigned i=0;
i<nSources;
i++) {
306 if( mother.
id() != ancestorsID ) {
308 ptrToAncestor( mother, ancestors, ancestorsID, iEvent );
320 template<
class Top,
class Bottom >
322 std::vector<bool>& masked )
const {
324 for(
unsigned i=0;
i<ancestors.
size();
i++) {
325 unsigned index = ancestors[
i].key();
326 assert( index<masked.size() );
332 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