CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
pf2pat::TopProjectorAlgo< Top, Bottom > Class Template Reference

#include <TopProjectorAlgo.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

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 ? More...
 

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(), and AlCaHLTBitMon_QueryRunRegistry::string.

96  {
97 
98  verbose_ = iConfig.getUntrackedParameter<bool>("verbose",false);
99  name_ = iConfig.getUntrackedParameter<std::string>("name","No Name");
100 }
T getUntrackedParameter(std::string const &, T const &) const
template<class Top , class Bottom >
pf2pat::TopProjectorAlgo< Top, Bottom >::~TopProjectorAlgo ( )
inline

Definition at line 48 of file TopProjectorAlgo.h.

48 {};

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 assert(), i, cmsHarvester::index, and edm::PtrVectorBase::size().

283  {
284 
285  for(unsigned i=0; i<ancestors.size(); i++) {
286  unsigned index = ancestors[i].key();
287  assert( index<masked.size() );
288 
289  // if(verbose_) {
290  // ProductID id = ancestors[i].id();
291  // cout<<"\tmasking "<<index<<", ancestor "<<id<<"/"<<index<<endl;
292  // }
293  masked[index] = true;
294  }
295 }
int i
Definition: DBlmapReader.cc:9
size_type size() const
Size of the RefVector.
Definition: PtrVectorBase.h:78
assert(m_qm.get())
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 assert(), gather_cfg::cout, i, edm::PtrVectorBase::id(), cmsHarvester::index, and edm::PtrVectorBase::size().

220  {
221 
222 
223  std::vector<Bottom> pfs = *allPFCandidates;
224 
225  for(unsigned i=0; i<ancestors.size(); i++) {
226 
227  edm::ProductID id = ancestors[i].id();
228  assert( id == allPFCandidates.id() );
229 
230  unsigned index = ancestors[i].key();
231  assert( index < pfs.size() );
232 
233  std::cout<<"\t\t"<<pfs[index]<<std::endl;
234  }
235 }
int i
Definition: DBlmapReader.cc:9
size_type size() const
Size of the RefVector.
Definition: PtrVectorBase.h:78
ProductID id() const
Definition: HandleBase.cc:15
assert(m_qm.get())
ProductID id() const
Accessor for product ID.
Definition: PtrVectorBase.h:63
tuple cout
Definition: gather_cfg.py:121
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.

178  {
179 
180  if( tops.isValid() && bottoms.isValid() ) {
181  const std::vector<Top>& topCollection = *tops;
182 
183  if(verbose_)
184  std::cout<<" processing: "<<objectName
185  <<" size = "<<topCollection.size()<<std::endl;
186 
187  for(unsigned i=0; i<topCollection.size(); i++) {
188 
189 
190  edm::Ptr<Top> ptr( tops, i);
191  reco::CandidatePtr basePtr( ptr );
192 
193 
194  reco::CandidatePtrVector ancestors;
195  ptrToAncestor( basePtr,
196  ancestors,
197  bottoms.id(),
198  iEvent );
199 
200  if(verbose_) {
201 /* std::cout<<"\t"<<objectName<<" "<<i */
202 /* <<" pt,eta,phi = " */
203 /* <<basePtr->pt()<<"," */
204 /* <<basePtr->eta()<<"," */
205 /* <<basePtr->phi()<<std::endl; */
206 
207  std::cout<<"\t"<<topCollection[i]<<std::endl;
208  printAncestors( ancestors, bottoms );
209  }
210 
211  maskAncestors( ancestors, masked );
212  }
213  }
214 
215 }
int i
Definition: DBlmapReader.cc:9
tuple topCollection
ProductID id() const
Accessor for product ID.
Definition: PtrVectorBase.h:63
int iEvent
Definition: GenABIO.cc:230
void printAncestors(const reco::CandidatePtrVector &ancestors, const edm::Handle< std::vector< Bottom > > &allPFCandidates) const
void maskAncestors(const reco::CandidatePtrVector &ancestors, std::vector< bool > &masked) const
tuple cout
Definition: gather_cfg.py:121
void ptrToAncestor(reco::CandidatePtr candRef, reco::CandidatePtrVector &ancestors, const edm::ProductID &ancestorsID, const edm::EventBase &iEvent) const
template<class Top , class Bottom >
std::vector< Bottom > TopProjectorAlgo::produce ( const TopHandle topHandle,
const BottomHandle bottomHandle,
const edm::EventBase iEvent 
)

Definition at line 104 of file TopProjectorAlgo.h.

References gather_cfg::cout, i, edm::ProductID::id(), and iEvent.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

106  {
107 
108  edm::ProductID topsID = tops.id();
109  edm::ProductID bottomsID = bottoms.id();
110 
111  cout<<"produce "<<tops.id()<<" "<<bottoms.id()<<endl;
112 
113  //COLIN had to comment all verbose stuff cause EventBase::getProvenance does not exist...
114 /* if(verbose_) { */
115 /* const Provenance& topProv = iEvent.getProvenance(tops.id()); */
116 /* const Provenance& bottomProv = iEvent.getProvenance(bottoms.id()); */
117 
118 /* cout<<"Top projector: event "<<iEvent.id().event()<<endl; */
119 /* cout<<"Inputs --------------------"<<endl; */
120 /* cout<<"Top : " */
121 /* <<tops.id()<<"\t"<<tops->size()<<endl */
122 /* <<topProv.branchDescription()<<endl */
123 /* <<"Bottom : " */
124 /* <<bottoms.id()<<"\t"<<bottoms->size()<<endl */
125 /* <<bottomProv.branchDescription()<<endl; */
126 /* } */
127 
128 
129  // output collection of objects,
130  // selected from the Bottom collection
131 
132 /* auto_ptr< BottomCollection > */
133 /* pBottomOutput( new BottomCollection ); */
134  BottomCollection bottomOutput;
135  bottomOutput.reserve( bottoms->size() );
136 
137  //COLIN to be cleaned up lated.
138  BottomCollection* pBottomOutput = &bottomOutput;
139 
140  // mask for each bottom object.
141  // at the beginning, all bottom objects are unmasked.
142  vector<bool> masked( bottoms->size(), false);
143 
144  processCollection( tops, bottoms, masked, name_.c_str(), iEvent );
145 
146  const BottomCollection& inCands = *bottoms;
147 
148  if(verbose_)
149  cout<<" Remaining candidates in the bottom collection ------ "<<endl;
150 
151  for(unsigned i=0; i<inCands.size(); i++) {
152 
153  if(masked[i]) {
154  if(verbose_)
155  cout<<"X "<<i<<" "<< *(inCands[i].get())<<endl;
156  continue;
157  }
158  else {
159  if(verbose_)
160  cout<<"O "<<i<<" "<< *(inCands[i].get())<<endl;
161 
162  pBottomOutput->push_back( inCands[i] );
163  BottomPtr motherPtr( bottoms, i );
164  pBottomOutput->back().setSourceCandidatePtr(motherPtr);
165  }
166  }
167 
168  return bottomOutput;
169 }
int i
Definition: DBlmapReader.cc:9
edm::Ptr< Bottom > BottomPtr
int iEvent
Definition: GenABIO.cc:230
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
std::vector< Bottom > BottomCollection
tuple cout
Definition: gather_cfg.py:121
ProductIndex id() const
Definition: ProductID.h:38
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().

244  {
245 
246 
247 
248  unsigned nSources = candPtr->numberOfSourceCandidatePtrs();
249 
250 /* if(verbose_) { */
251 /* const Provenance& hereProv = iEvent.getProvenance(candPtr.id()); */
252 
253 /* cout<<"going down from "<<candPtr.id() */
254 /* <<"/"<<candPtr.key()<<" #mothers "<<nSources */
255 /* <<" ancestor id "<<ancestorsID<<endl */
256 /* <<hereProv.branchDescription()<<endl; */
257 /* } */
258 
259  for(unsigned i=0; i<nSources; i++) {
260 
261  CandidatePtr mother = candPtr->sourceCandidatePtr(i);
262 /* if( verbose_ ) { */
263 /* const Provenance& motherProv = iEvent.getProvenance(mother.id()); */
264 /* cout<<" mother id "<<mother.id()<<endl */
265 /* <<motherProv<<endl; */
266 /* } */
267  if( mother.id() != ancestorsID ) {
268  // the mother is not yet at lowest level
269  ptrToAncestor( mother, ancestors, ancestorsID, iEvent );
270  }
271  else {
272  // adding mother to the list of ancestors
273  ancestors.push_back( mother );
274  }
275  }
276 }
int i
Definition: DBlmapReader.cc:9
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:141
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
Definition: CandidateFwd.h:25
void ptrToAncestor(reco::CandidatePtr candRef, reco::CandidatePtrVector &ancestors, const edm::ProductID &ancestorsID, const edm::EventBase &iEvent) const

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.