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

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.

14  :
15  StringCutEventSelector(pset, iC) {}
StringCutEventSelector(const edm::ParameterSet &pset, edm::ConsumesCollector &&iC)
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_, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), StringCutEventSelector< Object, any >::order_, StringCutEventSelector< Object, any >::src_, and AlCaHLTBitMon_QueryRunRegistry::string.

16  :
17  EventSelector(pset, iC),
18  src_(edm::Service<InputTagDistributorService>()->retrieve("src",pset)),
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  {
25  std::stringstream ss;
26  ss<<"string cut based selection on collection: "<<src_;
27  description_.push_back(ss.str());
28  ss.str("");
29  description_.push_back(std::string("selection cut is: ")+pset.getParameter<std::string>("cut"));
30  if (pset.exists("order"))
32  }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::EDGetTokenT< edm::View< Object > > srcToken_
StringObjectFunction< Object > * order_
StringCutObjectSelector< Object > f_
std::vector< std::string > description_
Definition: EventSelector.h:34

Member Function Documentation

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 34 of file StringCutEventSelector.h.

References any(), StringCutEventSelector< Object, any >::f_, runEdmFileComparison::found, edm::Event::getByToken(), mps_fire::i, StringCutEventSelector< Object, any >::nFirst_, connectstrParser::o, StringCutEventSelector< Object, any >::order_, StringCutEventSelector< Object, any >::srcToken_, and parallelization::uint().

Referenced by Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::find(), Vispa.Views.LineDecayView.LineDecayContainer::mousePressEvent(), Vispa.Gui.PortConnection.PointToPointConnection::mousePressEvent(), Vispa.Gui.VispaWidget.VispaWidget::mousePressEvent(), and Vispa.Views.AbstractView.AbstractView::restoreSelection().

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

Member Data Documentation

template<typename Object , bool any = false>
StringCutObjectSelector<Object> StringCutEventSelector< Object, any >::f_
private
template<typename Object , bool any = false>
unsigned int StringCutEventSelector< Object, any >::nFirst_
private
template<typename Object , bool any = false>
StringObjectFunction<Object>* StringCutEventSelector< Object, any >::order_
private
template<typename Object , bool any = false>
edm::InputTag StringCutEventSelector< Object, any >::src_
private
template<typename Object , bool any = false>
edm::EDGetTokenT<edm::View<Object> > StringCutEventSelector< Object, any >::srcToken_
private