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 CLHEP {
15  class HepRandomEngine;
16 }
17 
18 namespace edm {
19  class EventPrincipal;
20  struct InputSourceDescription;
21  class LuminosityBlockID;
22  class ParameterSet;
24  public:
25  explicit VectorInputSource(ParameterSet const& pset, InputSourceDescription const& desc);
26  virtual ~VectorInputSource();
27 
28  template<typename T>
29  size_t loopRandom(EventPrincipal& cache, size_t number, T eventOperator, CLHEP::HepRandomEngine*);
30  template<typename T>
31  size_t loopSequential(EventPrincipal& cache, size_t number, T eventOperator);
32  template<typename T>
33  size_t loopRandomWithID(EventPrincipal& cache, LuminosityBlockID const& id, size_t number, T eventOperator, CLHEP::HepRandomEngine*);
34  template<typename T>
35  size_t loopSequentialWithID(EventPrincipal& cache, LuminosityBlockID const& id, size_t number, T eventOperator);
36  template<typename T, typename Collection>
37  size_t loopSpecified(EventPrincipal& cache, Collection const& events, T eventOperator);
38 
39  void dropUnwantedBranches(std::vector<std::string> const& wantedBranches);
40 
41  private:
42 
44  virtual void readOneRandom(EventPrincipal& cache, CLHEP::HepRandomEngine*) = 0;
45  virtual bool readOneRandomWithID(EventPrincipal& cache, LuminosityBlockID const& id, CLHEP::HepRandomEngine*) = 0;
46  virtual bool readOneSequential(EventPrincipal& cache) = 0;
47  virtual bool readOneSequentialWithID(EventPrincipal& cache, LuminosityBlockID const& id) = 0;
48  virtual void readOneSpecified(EventPrincipal& cache, EventID const& event) = 0;
49 
50  virtual void dropUnwantedBranches_(std::vector<std::string> const& wantedBranches) = 0;
51  };
52 
53  template<typename T>
54  size_t VectorInputSource::loopRandom(EventPrincipal& cache, size_t number, T eventOperator, CLHEP::HepRandomEngine* engine) {
55  size_t i = 0U;
56  for(; i < number; ++i) {
57  clearEventPrincipal(cache);
58  readOneRandom(cache, engine);
59  eventOperator(cache);
60  }
61  return i;
62  }
63 
64  template<typename T>
65  size_t VectorInputSource::loopSequential(EventPrincipal& cache, size_t number, T eventOperator) {
66  size_t i = 0U;
67  for(; i < number; ++i) {
68  clearEventPrincipal(cache);
69  bool found = readOneSequential(cache);
70  if(!found) break;
71  eventOperator(cache);
72  }
73  return i;
74  }
75 
76  template<typename T>
77  size_t VectorInputSource::loopRandomWithID(EventPrincipal& cache, LuminosityBlockID const& id, size_t number, T eventOperator, CLHEP::HepRandomEngine* engine) {
78  size_t i = 0U;
79  for(; i < number; ++i) {
80  clearEventPrincipal(cache);
81  bool found = readOneRandomWithID(cache, id, engine);
82  if(!found) break;
83  eventOperator(cache);
84  }
85  return i;
86  }
87 
88  template<typename T>
89  size_t VectorInputSource::loopSequentialWithID(EventPrincipal& cache, LuminosityBlockID const& id, size_t number, T eventOperator) {
90  size_t i = 0U;
91  for(; i < number; ++i) {
92  clearEventPrincipal(cache);
93  bool found = readOneSequentialWithID(cache, id);
94  if(!found) break;
95  eventOperator(cache);
96  }
97  return i;
98  }
99 
100  template<typename T, typename Collection>
101  size_t VectorInputSource::loopSpecified(EventPrincipal& cache, Collection const& events, T eventOperator) {
102  size_t i = 0U;
103  for(typename Collection::const_iterator it = events.begin(), itEnd = events.end(); it != itEnd; ++it) {
104  clearEventPrincipal(cache);
105  readOneSpecified(cache, *it);
106  eventOperator(cache);
107  ++i;
108  }
109  return i;
110  }
111 }
112 #endif
int i
Definition: DBlmapReader.cc:9
virtual bool readOneRandomWithID(EventPrincipal &cache, LuminosityBlockID const &id, CLHEP::HepRandomEngine *)=0
void dropUnwantedBranches(std::vector< std::string > const &wantedBranches)
void clearEventPrincipal(EventPrincipal &cache)
virtual bool readOneSequentialWithID(EventPrincipal &cache, LuminosityBlockID const &id)=0
size_t loopRandomWithID(EventPrincipal &cache, LuminosityBlockID const &id, size_t number, T eventOperator, CLHEP::HepRandomEngine *)
size_t loopRandom(EventPrincipal &cache, size_t number, T eventOperator, CLHEP::HepRandomEngine *)
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)
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 readOneSequential(EventPrincipal &cache)=0
virtual void readOneRandom(EventPrincipal &cache, CLHEP::HepRandomEngine *)=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)