CMS 3D CMS Logo

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

#include <StringCutEventSelector.h>

Inheritance diagram for StringCutsEventSelector< Object, existenceMatter >:
EventSelector

Public Member Functions

bool select (const edm::Event &e) const override
 decision of the selector module More...
 
 StringCutsEventSelector (const edm::ParameterSet &pset, edm::ConsumesCollector &&iC)
 
 StringCutsEventSelector (const edm::ParameterSet &pset, edm::ConsumesCollector &iC)
 
 ~StringCutsEventSelector () override
 
- 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

std::vector< StringCutObjectSelector< Object > * > f_
 
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 existenceMatter = true>
class StringCutsEventSelector< Object, existenceMatter >

Definition at line 73 of file StringCutEventSelector.h.

Constructor & Destructor Documentation

◆ StringCutsEventSelector() [1/2]

template<typename Object , bool existenceMatter = true>
StringCutsEventSelector< Object, existenceMatter >::StringCutsEventSelector ( const edm::ParameterSet pset,
edm::ConsumesCollector &&  iC 
)
inline

Definition at line 75 of file StringCutEventSelector.h.

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

◆ StringCutsEventSelector() [2/2]

template<typename Object , bool existenceMatter = true>
StringCutsEventSelector< Object, existenceMatter >::StringCutsEventSelector ( const edm::ParameterSet pset,
edm::ConsumesCollector iC 
)
inline

Definition at line 77 of file StringCutEventSelector.h.

References EventSelector::description_, StringCutsEventSelector< Object, existenceMatter >::f_, mps_fire::i, StringCutsEventSelector< Object, existenceMatter >::order_, muonDTDigis_cfi::pset, corrVsCorr::selection, StringCutsEventSelector< Object, existenceMatter >::src_, contentValuesCheck::ss, and AlCaHLTBitMon_QueryRunRegistry::string.

78  : EventSelector(pset, iC),
81  order_(nullptr) {
82  std::vector<std::string> selection = pset.getParameter<std::vector<std::string> >("cut");
83  std::stringstream ss;
84  ss << "string cut based selection on collection: " << src_;
85  description_.push_back(ss.str());
86  ss.str("");
87  description_.push_back("selection cuts are:");
88  for (unsigned int i = 0; i != selection.size(); i++)
89  if (selection[i] != "-") {
91  ss << "[" << i << "]: " << selection[i];
92  description_.push_back(ss.str());
93  ss.str("");
94  } else {
95  f_.push_back(nullptr);
96  ss << "[" << i << "]: no selection";
97  description_.push_back(ss.str());
98  ss.str("");
99  }
100  if (pset.exists("order"))
101  order_ = new StringObjectFunction<Object>(pset.getParameter<std::string>("order"));
102  }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
selection
main part
Definition: corrVsCorr.py:100
std::vector< StringCutObjectSelector< Object > * > f_
StringObjectFunction< Object > * order_
edm::EDGetTokenT< edm::View< Object > > srcToken_
std::vector< std::string > description_
Definition: EventSelector.h:33

◆ ~StringCutsEventSelector()

template<typename Object , bool existenceMatter = true>
StringCutsEventSelector< Object, existenceMatter >::~StringCutsEventSelector ( )
inlineoverride

Definition at line 103 of file StringCutEventSelector.h.

References StringCutsEventSelector< Object, existenceMatter >::f_, mps_fire::i, and StringCutsEventSelector< Object, existenceMatter >::order_.

103  {
104  unsigned int i = 0;
105  for (; i != f_.size(); i++)
106  if (f_[i]) {
107  delete f_[i];
108  f_[i] = nullptr;
109  }
110  if (order_)
111  delete order_;
112  }
std::vector< StringCutObjectSelector< Object > * > f_
StringObjectFunction< Object > * order_

Member Function Documentation

◆ select()

template<typename Object , bool existenceMatter = true>
bool StringCutsEventSelector< Object, existenceMatter >::select ( const edm::Event ) const
inlineoverridevirtual

decision of the selector module

Implements EventSelector.

Definition at line 114 of file StringCutEventSelector.h.

References MillePedeFileConverter_cfg::e, StringCutsEventSelector< Object, existenceMatter >::f_, mps_fire::i, EcalTangentSkim_cfg::o, StringCutsEventSelector< Object, existenceMatter >::order_, jetsAK4_CHS_cff::sort, StringCutsEventSelector< Object, existenceMatter >::srcToken_, and parallelization::uint.

114  {
116  e.getByToken(srcToken_, oH);
117  std::vector<const Object*> copyToSort(oH->size());
118  for (uint i = 0; i != oH->size(); ++i)
119  copyToSort[i] = &(*oH)[i];
120  if (order_)
121  std::sort(copyToSort.begin(), copyToSort.end(), sortByStringFunction<Object>(order_));
122 
123  unsigned int i = 0;
124  if (existenceMatter && oH->size() < f_.size())
125  return false;
126  for (; i != f_.size(); i++) {
127  if (!existenceMatter && i == oH->size())
128  break;
129  if (!f_[i])
130  continue;
131  const Object& o = *(copyToSort[i]);
132  if (!(*f_[i])(o))
133  return false;
134  }
135  return true;
136  }
std::vector< StringCutObjectSelector< Object > * > f_
StringObjectFunction< Object > * order_
edm::EDGetTokenT< edm::View< Object > > srcToken_

Member Data Documentation

◆ f_

template<typename Object , bool existenceMatter = true>
std::vector<StringCutObjectSelector<Object>*> StringCutsEventSelector< Object, existenceMatter >::f_
private

◆ order_

template<typename Object , bool existenceMatter = true>
StringObjectFunction<Object>* StringCutsEventSelector< Object, existenceMatter >::order_
private

◆ src_

template<typename Object , bool existenceMatter = true>
edm::InputTag StringCutsEventSelector< Object, existenceMatter >::src_
private

◆ srcToken_

template<typename Object , bool existenceMatter = true>
edm::EDGetTokenT<edm::View<Object> > StringCutsEventSelector< Object, existenceMatter >::srcToken_
private