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() [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.

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  }

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

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.

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  }

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.

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
mps_fire.i
i
Definition: mps_fire.py:428
StringObjectFunction< Object >
StringCutEventSelector::order_
StringObjectFunction< Object > * order_
Definition: StringCutEventSelector.h:69
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
edm::Handle
Definition: AssociativeIterator.h:50
parallelization.uint
uint
Definition: parallelization.py:124
EcalTangentSkim_cfg.o
o
Definition: EcalTangentSkim_cfg.py:42
EventSelector::description_
std::vector< std::string > description_
Definition: EventSelector.h:33
any
bool any(const std::vector< T > &v, const T &what)
Definition: ECalSD.cc:37
StringCutEventSelector::srcToken_
edm::EDGetTokenT< edm::View< Object > > srcToken_
Definition: StringCutEventSelector.h:66
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
sortByStringFunction
Definition: StringObjectFunction.h:34
edm::ConsumesCollector::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: ConsumesCollector.h:55
edm::View
Definition: CaloClusterFwd.h:14
EventSelector::EventSelector
EventSelector()
Definition: EventSelector.h:18
StringCutEventSelector::StringCutEventSelector
StringCutEventSelector(const edm::ParameterSet &pset, edm::ConsumesCollector &&iC)
Definition: StringCutEventSelector.h:14
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
edm::Service
Definition: Service.h:30
StringCutEventSelector::nFirst_
unsigned int nFirst_
Definition: StringCutEventSelector.h:68
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
StringCutEventSelector::src_
edm::InputTag src_
Definition: StringCutEventSelector.h:65
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
StringCutEventSelector::f_
StringCutObjectSelector< Object > f_
Definition: StringCutEventSelector.h:67
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37