CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
StringCutEventSelector< Object, any > Class Template Reference

#include <StringCutEventSelector.h>

Inheritance diagram for StringCutEventSelector< Object, any >:
EventSelector

Public Member Functions

bool select (const edm::Event &e) const override
 decision of the selector module More...
 
 StringCutEventSelector (const edm::ParameterSet &pset, edm::ConsumesCollector &&iC)
 
 StringCutEventSelector (const edm::ParameterSet &pset, edm::ConsumesCollector &iC)
 
- Public Member Functions inherited from EventSelector
const std::vector< std::string > & description ()
 
 EventSelector ()
 
 EventSelector (const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
 
 EventSelector (const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
 
const std::string & name () const
 name of the module (from configuration) More...
 
virtual ~EventSelector ()
 

Private Attributes

StringCutObjectSelector< Object > f_
 
unsigned int nFirst_
 
StringObjectFunction< Object > * order_
 
edm::InputTag src_
 
edm::EDGetTokenT< edm::View< Object > > srcToken_
 

Additional Inherited Members

- Protected Attributes inherited from EventSelector
std::vector< std::string > description_
 
std::string name_
 

Detailed Description

template<typename Object, bool any = false>
class StringCutEventSelector< Object, any >

Definition at line 12 of file StringCutEventSelector.h.

Constructor & Destructor Documentation

◆ StringCutEventSelector() [1/2]

template<typename Object , bool any = false>
StringCutEventSelector< Object, any >::StringCutEventSelector ( const edm::ParameterSet pset,
edm::ConsumesCollector &&  iC 
)
inline

Definition at line 14 of file StringCutEventSelector.h.

StringCutEventSelector(const edm::ParameterSet &pset, edm::ConsumesCollector &&iC)

◆ StringCutEventSelector() [2/2]

template<typename Object , bool any = false>
StringCutEventSelector< Object, any >::StringCutEventSelector ( const edm::ParameterSet pset,
edm::ConsumesCollector iC 
)
inline

Definition at line 16 of file StringCutEventSelector.h.

References EventSelector::description_, StringCutEventSelector< Object, any >::order_, muonDTDigis_cfi::pset, StringCutEventSelector< Object, any >::src_, contentValuesCheck::ss, and AlCaHLTBitMon_QueryRunRegistry::string.

17  : EventSelector(pset, iC),
20  f_(pset.getParameter<std::string>("cut")),
21  //put this guy to 0 to do the check on "all" object in the collection
22  nFirst_(pset.getParameter<unsigned int>("nFirst")),
23  order_(nullptr) {
24  std::stringstream ss;
25  ss << "string cut based selection on collection: " << src_;
26  description_.push_back(ss.str());
27  ss.str("");
28  description_.push_back(std::string("selection cut is: ") + pset.getParameter<std::string>("cut"));
29  if (pset.exists("order"))
30  order_ = new StringObjectFunction<Object>(pset.getParameter<std::string>("order"));
31  }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< edm::View< Object > > srcToken_
StringObjectFunction< Object > * order_
StringCutObjectSelector< Object > f_
std::vector< std::string > description_
Definition: EventSelector.h:33

Member Function Documentation

◆ select()

template<typename Object , bool any = false>
bool StringCutEventSelector< Object, any >::select ( const edm::Event ) const
inlineoverridevirtual

decision of the selector module

Implements EventSelector.

Definition at line 33 of file StringCutEventSelector.h.

References any(), MillePedeFileConverter_cfg::e, StringCutEventSelector< Object, any >::f_, newFWLiteAna::found, mps_fire::i, StringCutEventSelector< Object, any >::nFirst_, EcalTangentSkim_cfg::o, StringCutEventSelector< Object, any >::order_, jetUpdater_cfi::sort, StringCutEventSelector< Object, any >::srcToken_, and parallelization::uint.

33  {
35  e.getByToken(srcToken_, oH);
36  std::vector<const Object*> copyToSort(oH->size());
37  for (uint i = 0; i != oH->size(); ++i)
38  copyToSort[i] = &(*oH)[i];
39  if (order_)
40  std::sort(copyToSort.begin(), copyToSort.end(), sortByStringFunction<Object>(order_));
41 
42  //reject events if not enough object in collection
43  // if ((nFirst_!=0) && (oH->size()<nFirst_)) return false;
44  unsigned int i = 0;
45  unsigned int found = 0;
46  for (; i != oH->size(); i++) {
47  const Object& o = *(copyToSort[i]);
48  if (any) {
49  if (f_(o))
50  ++found;
51  if (found >= nFirst_)
52  return true;
53  } else {
54  //stop doing the check if reaching too far in the collection
55  if ((nFirst_ != 0) && (i >= nFirst_))
56  break;
57  if (!f_(o))
58  return false;
59  }
60  }
61  return !any;
62  }
bool any(const std::vector< T > &v, const T &what)
Definition: ECalSD.cc:37
edm::EDGetTokenT< edm::View< Object > > srcToken_
StringObjectFunction< Object > * order_
StringCutObjectSelector< Object > f_

Member Data Documentation

◆ f_

template<typename Object , bool any = false>
StringCutObjectSelector<Object> StringCutEventSelector< Object, any >::f_
private

◆ nFirst_

template<typename Object , bool any = false>
unsigned int StringCutEventSelector< Object, any >::nFirst_
private

◆ order_

template<typename Object , bool any = false>
StringObjectFunction<Object>* StringCutEventSelector< Object, any >::order_
private

◆ src_

template<typename Object , bool any = false>
edm::InputTag StringCutEventSelector< Object, any >::src_
private

◆ srcToken_

template<typename Object , bool any = false>
edm::EDGetTokenT<edm::View<Object> > StringCutEventSelector< Object, any >::srcToken_
private