CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
VectorInputSource.h
Go to the documentation of this file.
1 #ifndef FWCore_Sources_VectorInputSource_h
2 #define FWCore_Sources_VectorInputSource_h
3 
4 /*----------------------------------------------------------------------
5 VectorInputSource: Abstract interface for vector input sources.
6 ----------------------------------------------------------------------*/
7 
9 
10 #include <memory>
11 #include <string>
12 #include <vector>
13 
14 namespace edm {
15  class EventPrincipal;
16  struct InputSourceDescription;
17  class LuminosityBlockID;
18  class ParameterSet;
20  public:
21  explicit VectorInputSource(ParameterSet const& pset, InputSourceDescription const& desc);
22  virtual ~VectorInputSource();
23 
24  template<typename T>
25  size_t loopRandom(EventPrincipal& cache, size_t number, T eventOperator);
26  template<typename T>
27  size_t loopSequential(EventPrincipal& cache, size_t number, T eventOperator);
28  template<typename T>
29  size_t loopRandomWithID(EventPrincipal& cache, LuminosityBlockID const& id, size_t number, T eventOperator);
30  template<typename T>
31  size_t loopSequentialWithID(EventPrincipal& cache, LuminosityBlockID const& id, size_t number, T eventOperator);
32  template<typename T, typename Collection>
33  size_t loopSpecified(EventPrincipal& cache, Collection const& events, T eventOperator);
34 
35  void dropUnwantedBranches(std::vector<std::string> const& wantedBranches);
36 
37  private:
38 
40  virtual EventPrincipal* readOneRandom(EventPrincipal& cache) = 0;
42  virtual EventPrincipal* readOneSequential(EventPrincipal& cache) = 0;
44  virtual EventPrincipal* readOneSpecified(EventPrincipal& cache, EventID const& event) = 0;
45 
46  virtual void dropUnwantedBranches_(std::vector<std::string> const& wantedBranches) = 0;
47  };
48 
49  template<typename T>
50  size_t VectorInputSource::loopRandom(EventPrincipal& cache, size_t number, T eventOperator) {
51  size_t i = 0U;
52  for(; i < number; ++i) {
53  clearEventPrincipal(cache);
54  EventPrincipal* ep = readOneRandom(cache);
55  if(!ep) break;
56  eventOperator(*ep);
57  }
58  return i;
59  }
60 
61  template<typename T>
62  size_t VectorInputSource::loopSequential(EventPrincipal& cache, size_t number, T eventOperator) {
63  size_t i = 0U;
64  for(; i < number; ++i) {
65  clearEventPrincipal(cache);
66  EventPrincipal* ep = readOneSequential(cache);
67  if(!ep) break;
68  eventOperator(*ep);
69  }
70  return i;
71  }
72 
73  template<typename T>
74  size_t VectorInputSource::loopRandomWithID(EventPrincipal& cache, LuminosityBlockID const& id, size_t number, T eventOperator) {
75  size_t i = 0U;
76  for(; i < number; ++i) {
77  clearEventPrincipal(cache);
78  EventPrincipal* ep = readOneRandomWithID(cache, id);
79  if(!ep) break;
80  eventOperator(*ep);
81  }
82  return i;
83  }
84 
85  template<typename T>
86  size_t VectorInputSource::loopSequentialWithID(EventPrincipal& cache, LuminosityBlockID const& id, size_t number, T eventOperator) {
87  size_t i = 0U;
88  for(; i < number; ++i) {
89  clearEventPrincipal(cache);
90  EventPrincipal* ep = readOneSequentialWithID(cache, id);
91  if(!ep) break;
92  eventOperator(*ep);
93  }
94  return i;
95  }
96 
97  template<typename T, typename Collection>
98  size_t VectorInputSource::loopSpecified(EventPrincipal& cache, Collection const& events, T eventOperator) {
99  size_t i = 0U;
100  for(typename Collection::const_iterator it = events.begin(), itEnd = events.end(); it != itEnd; ++it) {
101  clearEventPrincipal(cache);
102  EventPrincipal* ep = readOneSpecified(cache, *it);
103  if(!ep) break;
104  eventOperator(*ep);
105  ++i;
106  }
107  return i;
108  }
109 }
110 #endif
int i
Definition: DBlmapReader.cc:9
virtual EventPrincipal * readOneRandomWithID(EventPrincipal &cache, LuminosityBlockID const &id)=0
void dropUnwantedBranches(std::vector< std::string > const &wantedBranches)
void clearEventPrincipal(EventPrincipal &cache)
size_t loopRandom(EventPrincipal &cache, size_t number, T eventOperator)
size_t loopRandomWithID(EventPrincipal &cache, LuminosityBlockID const &id, size_t number, T eventOperator)
virtual EventPrincipal * readOneRandom(EventPrincipal &cache)=0
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
VectorInputSource(ParameterSet const &pset, InputSourceDescription const &desc)
size_t loopSequentialWithID(EventPrincipal &cache, LuminosityBlockID const &id, size_t number, T eventOperator)
virtual EventPrincipal * readOneSequentialWithID(EventPrincipal &cache, LuminosityBlockID const &id)=0
tuple events
Definition: patZpeak.py:19
virtual void dropUnwantedBranches_(std::vector< std::string > const &wantedBranches)=0
virtual EventPrincipal * readOneSequential(EventPrincipal &cache)=0
long double T
size_t loopSpecified(EventPrincipal &cache, Collection const &events, T eventOperator)
size_t loopSequential(EventPrincipal &cache, size_t number, T eventOperator)
virtual EventPrincipal * readOneSpecified(EventPrincipal &cache, EventID const &event)=0