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 void readOneRandom(EventPrincipal& cache) = 0;
41  virtual bool readOneRandomWithID(EventPrincipal& cache, LuminosityBlockID const& id) = 0;
42  virtual bool readOneSequential(EventPrincipal& cache) = 0;
43  virtual bool readOneSequentialWithID(EventPrincipal& cache, LuminosityBlockID const& id) = 0;
44  virtual void 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  readOneRandom(cache);
55  eventOperator(cache);
56  }
57  return i;
58  }
59 
60  template<typename T>
61  size_t VectorInputSource::loopSequential(EventPrincipal& cache, size_t number, T eventOperator) {
62  size_t i = 0U;
63  for(; i < number; ++i) {
64  clearEventPrincipal(cache);
65  bool found = readOneSequential(cache);
66  if(!found) break;
67  eventOperator(cache);
68  }
69  return i;
70  }
71 
72  template<typename T>
73  size_t VectorInputSource::loopRandomWithID(EventPrincipal& cache, LuminosityBlockID const& id, size_t number, T eventOperator) {
74  size_t i = 0U;
75  for(; i < number; ++i) {
76  clearEventPrincipal(cache);
77  bool found = readOneRandomWithID(cache, id);
78  if(!found) break;
79  eventOperator(cache);
80  }
81  return i;
82  }
83 
84  template<typename T>
85  size_t VectorInputSource::loopSequentialWithID(EventPrincipal& cache, LuminosityBlockID const& id, size_t number, T eventOperator) {
86  size_t i = 0U;
87  for(; i < number; ++i) {
88  clearEventPrincipal(cache);
89  bool found = readOneSequentialWithID(cache, id);
90  if(!found) break;
91  eventOperator(cache);
92  }
93  return i;
94  }
95 
96  template<typename T, typename Collection>
97  size_t VectorInputSource::loopSpecified(EventPrincipal& cache, Collection const& events, T eventOperator) {
98  size_t i = 0U;
99  for(typename Collection::const_iterator it = events.begin(), itEnd = events.end(); it != itEnd; ++it) {
100  clearEventPrincipal(cache);
101  readOneSpecified(cache, *it);
102  eventOperator(cache);
103  ++i;
104  }
105  return i;
106  }
107 }
108 #endif
int i
Definition: DBlmapReader.cc:9
void dropUnwantedBranches(std::vector< std::string > const &wantedBranches)
void clearEventPrincipal(EventPrincipal &cache)
virtual bool readOneSequentialWithID(EventPrincipal &cache, LuminosityBlockID const &id)=0
size_t loopRandom(EventPrincipal &cache, size_t number, T eventOperator)
size_t loopRandomWithID(EventPrincipal &cache, LuminosityBlockID const &id, size_t number, T eventOperator)
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
virtual void readOneRandom(EventPrincipal &cache)=0
VectorInputSource(ParameterSet const &pset, InputSourceDescription const &desc)
virtual void readOneSpecified(EventPrincipal &cache, EventID const &event)=0
size_t loopSequentialWithID(EventPrincipal &cache, LuminosityBlockID const &id, size_t number, T eventOperator)
tuple events
Definition: patZpeak.py:19
virtual bool readOneRandomWithID(EventPrincipal &cache, LuminosityBlockID const &id)=0
virtual bool readOneSequential(EventPrincipal &cache)=0
virtual void dropUnwantedBranches_(std::vector< std::string > const &wantedBranches)=0
long double T
size_t loopSpecified(EventPrincipal &cache, Collection const &events, T eventOperator)
size_t loopSequential(EventPrincipal &cache, size_t number, T eventOperator)