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