CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
TopProjector< Top, Bottom, Matcher > Class Template Reference

#include <TopProjector.h>

Inheritance diagram for TopProjector< Top, Bottom, Matcher >:
edm::stream::EDProducer<>

Public Types

typedef std::vector< Bottom > BottomCollection
 
typedef edm::FwdPtr< Bottom > BottomFwdPtr
 
typedef std::vector< BottomFwdPtrBottomFwdPtrCollection
 
typedef edm::Handle< BottomFwdPtrCollectionBottomFwdPtrHandle
 
typedef edm::Handle< std::vector< Bottom > > BottomHandle
 
typedef edm::Ptr< Bottom > BottomPtr
 
typedef edm::Ref< BottomCollectionBottomRef
 
typedef std::vector< Top > TopCollection
 
typedef edm::FwdPtr< Top > TopFwdPtr
 
typedef std::vector< TopFwdPtrTopFwdPtrCollection
 
typedef edm::Handle< TopFwdPtrCollectionTopFwdPtrHandle
 
typedef edm::Handle< std::vector< Top > > TopHandle
 
- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Public Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 
 TopProjector (const edm::ParameterSet &)
 
 ~TopProjector () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Attributes

bool enable_
 enable? if not, all candidates in the bottom collection are copied to the output collection More...
 
edm::InputTag inputTagBottom_
 input tag for the masked collection. More...
 
edm::InputTag inputTagTop_
 input tag for the top (masking) collection More...
 
Matcher match_
 Matching method. More...
 
std::string name_
 name of the top projection More...
 
edm::EDGetTokenT< BottomFwdPtrCollectiontokenBottom_
 
edm::EDGetTokenT< TopFwdPtrCollectiontokenTop_
 

Detailed Description

template<class Top, class Bottom, class Matcher = TopProjectorFwdPtrOverlap<Top, Bottom>>
class TopProjector< Top, Bottom, Matcher >

Author
Colin Bernet
Date
february 2008

Definition at line 140 of file TopProjector.h.

Member Typedef Documentation

template<class Top , class Bottom , class Matcher = TopProjectorFwdPtrOverlap<Top, Bottom>>
typedef std::vector<Bottom> TopProjector< Top, Bottom, Matcher >::BottomCollection

Definition at line 148 of file TopProjector.h.

template<class Top , class Bottom , class Matcher = TopProjectorFwdPtrOverlap<Top, Bottom>>
typedef edm::FwdPtr<Bottom> TopProjector< Top, Bottom, Matcher >::BottomFwdPtr

Definition at line 152 of file TopProjector.h.

template<class Top , class Bottom , class Matcher = TopProjectorFwdPtrOverlap<Top, Bottom>>
typedef std::vector<BottomFwdPtr> TopProjector< Top, Bottom, Matcher >::BottomFwdPtrCollection

Definition at line 153 of file TopProjector.h.

template<class Top , class Bottom , class Matcher = TopProjectorFwdPtrOverlap<Top, Bottom>>
typedef edm::Handle<BottomFwdPtrCollection> TopProjector< Top, Bottom, Matcher >::BottomFwdPtrHandle

Definition at line 154 of file TopProjector.h.

template<class Top , class Bottom , class Matcher = TopProjectorFwdPtrOverlap<Top, Bottom>>
typedef edm::Handle<std::vector<Bottom> > TopProjector< Top, Bottom, Matcher >::BottomHandle

Definition at line 149 of file TopProjector.h.

template<class Top , class Bottom , class Matcher = TopProjectorFwdPtrOverlap<Top, Bottom>>
typedef edm::Ptr<Bottom> TopProjector< Top, Bottom, Matcher >::BottomPtr

Definition at line 150 of file TopProjector.h.

template<class Top , class Bottom , class Matcher = TopProjectorFwdPtrOverlap<Top, Bottom>>
typedef edm::Ref<BottomCollection> TopProjector< Top, Bottom, Matcher >::BottomRef

Definition at line 151 of file TopProjector.h.

template<class Top , class Bottom , class Matcher = TopProjectorFwdPtrOverlap<Top, Bottom>>
typedef std::vector<Top> TopProjector< Top, Bottom, Matcher >::TopCollection

Definition at line 142 of file TopProjector.h.

template<class Top , class Bottom , class Matcher = TopProjectorFwdPtrOverlap<Top, Bottom>>
typedef edm::FwdPtr<Top> TopProjector< Top, Bottom, Matcher >::TopFwdPtr

Definition at line 144 of file TopProjector.h.

template<class Top , class Bottom , class Matcher = TopProjectorFwdPtrOverlap<Top, Bottom>>
typedef std::vector<TopFwdPtr> TopProjector< Top, Bottom, Matcher >::TopFwdPtrCollection

Definition at line 145 of file TopProjector.h.

template<class Top , class Bottom , class Matcher = TopProjectorFwdPtrOverlap<Top, Bottom>>
typedef edm::Handle<TopFwdPtrCollection> TopProjector< Top, Bottom, Matcher >::TopFwdPtrHandle

Definition at line 146 of file TopProjector.h.

template<class Top , class Bottom , class Matcher = TopProjectorFwdPtrOverlap<Top, Bottom>>
typedef edm::Handle<std::vector<Top> > TopProjector< Top, Bottom, Matcher >::TopHandle

Definition at line 143 of file TopProjector.h.

Constructor & Destructor Documentation

template<class Top , class Bottom , class Matcher >
TopProjector< Top, Bottom, Matcher >::TopProjector ( const edm::ParameterSet iConfig)

Definition at line 182 of file TopProjector.h.

References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), TopProjector< Top, Bottom, Matcher >::inputTagBottom_, TopProjector< Top, Bottom, Matcher >::inputTagTop_, TopProjector< Top, Bottom, Matcher >::name_, AlCaHLTBitMon_QueryRunRegistry::string, TopProjector< Top, Bottom, Matcher >::tokenBottom_, and TopProjector< Top, Bottom, Matcher >::tokenTop_.

183  : match_(iConfig), enable_(iConfig.getParameter<bool>("enable")) {
184  name_ = iConfig.getUntrackedParameter<std::string>("name", "No Name");
185  inputTagTop_ = iConfig.getParameter<edm::InputTag>("topCollection");
186  tokenTop_ = consumes<TopFwdPtrCollection>(inputTagTop_);
187  inputTagBottom_ = iConfig.getParameter<edm::InputTag>("bottomCollection");
188  tokenBottom_ = consumes<BottomFwdPtrCollection>(inputTagBottom_);
189 
190  // will produce a collection of the unmasked candidates in the
191  // bottom collection
192  produces<BottomFwdPtrCollection>();
193 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< BottomFwdPtrCollection > tokenBottom_
Definition: TopProjector.h:178
Matcher match_
Matching method.
Definition: TopProjector.h:164
bool enable_
enable? if not, all candidates in the bottom collection are copied to the output collection ...
Definition: TopProjector.h:167
edm::InputTag inputTagBottom_
input tag for the masked collection.
Definition: TopProjector.h:177
std::string name_
name of the top projection
Definition: TopProjector.h:170
edm::InputTag inputTagTop_
input tag for the top (masking) collection
Definition: TopProjector.h:173
edm::EDGetTokenT< TopFwdPtrCollection > tokenTop_
Definition: TopProjector.h:174
template<class Top , class Bottom , class Matcher = TopProjectorFwdPtrOverlap<Top, Bottom>>
TopProjector< Top, Bottom, Matcher >::~TopProjector ( )
inlineoverride

Definition at line 158 of file TopProjector.h.

158 {};

Member Function Documentation

template<class Top , class Bottom , class Matcher >
void TopProjector< Top, Bottom, Matcher >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 196 of file TopProjector.h.

References TopProjector< Top, Bottom, Matcher >::enable_, newFWLiteAna::found, edm::Event::getByToken(), mps_fire::i, LogDebug, TopProjector< Top, Bottom, Matcher >::match_, eostools::move(), edm::Event::put(), TopProjector< Top, Bottom, Matcher >::tokenBottom_, and TopProjector< Top, Bottom, Matcher >::tokenTop_.

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

196  {
197  // get the various collections
198 
199  // Access the masking collection
200  TopFwdPtrHandle tops;
201  iEvent.getByToken(tokenTop_, tops);
202  std::list<TopFwdPtr> topsList;
203 
204  for (typename TopFwdPtrCollection::const_iterator ibegin = tops->begin(), iend = tops->end(), i = ibegin; i != iend;
205  ++i) {
206  topsList.push_back(*i);
207  }
208 
209  /* if( !tops.isValid() ) { */
210  /* std::ostringstream err; */
211  /* err<<"The top collection must be supplied."<<std::endl */
212  /* <<"It is now set to : "<<inputTagTop_<<std::endl; */
213  /* edm::LogError("PFPAT")<<err.str(); */
214  /* throw cms::Exception( "MissingProduct", err.str()); */
215  /* } */
216 
217  // Access the collection to
218  // be masked by the other ones
219  BottomFwdPtrHandle bottoms;
220  iEvent.getByToken(tokenBottom_, bottoms);
221 
222  /* if( !bottoms.isValid() ) { */
223  /* std::ostringstream err; */
224  /* err<<"The bottom collection must be supplied."<<std::endl */
225  /* <<"It is now set to : "<<inputTagBottom_<<std::endl; */
226  /* edm::LogError("PFPAT")<<err.str(); */
227  /* throw cms::Exception( "MissingProduct", err.str()); */
228  /* } */
229 
230  /* if(verbose_) { */
231  /* const edm::Provenance& topProv = iEvent.getProvenance(tops.id()); */
232  /* const edm::Provenance& bottomProv = iEvent.getProvenance(bottoms.id()); */
233 
234  /* edm::LogDebug("TopProjection")<<"Top projector: event "<<iEvent.id().event()<<std::endl; */
235  /* edm::LogDebug("TopProjection")<<"Inputs --------------------"<<std::endl; */
236  /* edm::LogDebug("TopProjection")<<"Top : " */
237  /* <<tops.id()<<"\t"<<tops->size()<<std::endl */
238  /* <<topProv.branchDescription()<<std::endl; */
239 
240  /* for(unsigned i=0; i<tops->size(); i++) { */
241  /* TopFwdPtr top = (*tops)[i]; */
242  /* edm::LogDebug("TopProjection") << "< " << i << " " << top.key() << " : " << *top << std::endl; */
243  /* } */
244 
245  /* edm::LogDebug("TopProjection")<<"Bottom : " */
246  /* <<bottoms.id()<<"\t"<<bottoms->size()<<std::endl */
247  /* <<bottomProv.branchDescription()<<std::endl; */
248 
249  /* for(unsigned i=0; i<bottoms->size(); i++) { */
250  /* BottomFwdPtr bottom = (*bottoms)[i]; */
251  /* edm::LogDebug("TopProjection") << "> " << i << " " << bottom.key() << " : " << *bottom << std::endl; */
252  /* } */
253 
254  /* } */
255 
256  // output collection of FwdPtrs to objects,
257  // selected from the Bottom collection
258  std::unique_ptr<BottomFwdPtrCollection> pBottomFwdPtrOutput(new BottomFwdPtrCollection);
259 
260  LogDebug("TopProjection") << " Remaining candidates in the bottom collection ------ ";
261 
262  for (typename BottomFwdPtrCollection::const_iterator i = bottoms->begin(), iend = bottoms->end(), ibegin = i;
263  i != iend;
264  ++i) {
265  BottomFwdPtr const& bottom = *i;
266  match_.setBottom(bottom);
267  typename std::list<TopFwdPtr>::iterator found = topsList.end();
268  if (enable_) {
269  found = std::find_if(topsList.begin(), topsList.end(), match_);
270  }
271 
272  // If this is masked in the top projection, we remove it.
273  if (found != topsList.end()) {
274  LogDebug("TopProjection") << "X " << i - ibegin << **i;
275  topsList.erase(found);
276  continue;
277  }
278  // otherwise, we keep it.
279  else {
280  LogDebug("TopProjection") << "O " << i - ibegin << **i;
281  pBottomFwdPtrOutput->push_back(bottom);
282  }
283  }
284 
285  iEvent.put(std::move(pBottomFwdPtrOutput));
286 }
#define LogDebug(id)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
edm::FwdPtr< Bottom > BottomFwdPtr
Definition: TopProjector.h:152
edm::EDGetTokenT< BottomFwdPtrCollection > tokenBottom_
Definition: TopProjector.h:178
Matcher match_
Matching method.
Definition: TopProjector.h:164
bool enable_
enable? if not, all candidates in the bottom collection are copied to the output collection ...
Definition: TopProjector.h:167
edm::Handle< TopFwdPtrCollection > TopFwdPtrHandle
Definition: TopProjector.h:146
edm::Handle< BottomFwdPtrCollection > BottomFwdPtrHandle
Definition: TopProjector.h:154
edm::EDGetTokenT< TopFwdPtrCollection > tokenTop_
Definition: TopProjector.h:174
std::vector< BottomFwdPtr > BottomFwdPtrCollection
Definition: TopProjector.h:153
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

template<class Top , class Bottom , class Matcher = TopProjectorFwdPtrOverlap<Top, Bottom>>
bool TopProjector< Top, Bottom, Matcher >::enable_
private

enable? if not, all candidates in the bottom collection are copied to the output collection

Definition at line 167 of file TopProjector.h.

Referenced by TopProjector< Top, Bottom, Matcher >::produce().

template<class Top , class Bottom , class Matcher = TopProjectorFwdPtrOverlap<Top, Bottom>>
edm::InputTag TopProjector< Top, Bottom, Matcher >::inputTagBottom_
private

input tag for the masked collection.

Definition at line 177 of file TopProjector.h.

Referenced by TopProjector< Top, Bottom, Matcher >::TopProjector().

template<class Top , class Bottom , class Matcher = TopProjectorFwdPtrOverlap<Top, Bottom>>
edm::InputTag TopProjector< Top, Bottom, Matcher >::inputTagTop_
private

input tag for the top (masking) collection

Definition at line 173 of file TopProjector.h.

Referenced by TopProjector< Top, Bottom, Matcher >::TopProjector().

template<class Top , class Bottom , class Matcher = TopProjectorFwdPtrOverlap<Top, Bottom>>
Matcher TopProjector< Top, Bottom, Matcher >::match_
private

Matching method.

Definition at line 164 of file TopProjector.h.

Referenced by TopProjector< Top, Bottom, Matcher >::produce().

template<class Top , class Bottom , class Matcher = TopProjectorFwdPtrOverlap<Top, Bottom>>
std::string TopProjector< Top, Bottom, Matcher >::name_
private

name of the top projection

Definition at line 170 of file TopProjector.h.

Referenced by TopProjector< Top, Bottom, Matcher >::TopProjector().

template<class Top , class Bottom , class Matcher = TopProjectorFwdPtrOverlap<Top, Bottom>>
edm::EDGetTokenT<BottomFwdPtrCollection> TopProjector< Top, Bottom, Matcher >::tokenBottom_
private
template<class Top , class Bottom , class Matcher = TopProjectorFwdPtrOverlap<Top, Bottom>>
edm::EDGetTokenT<TopFwdPtrCollection> TopProjector< Top, Bottom, Matcher >::tokenTop_
private