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 
12 
13 #include <memory>
14 #include <string>
15 #include <vector>
16 
17 namespace CLHEP {
18  class HepRandomEngine;
19 }
20 
21 namespace edm {
22  class EventPrincipal;
23  struct VectorInputSourceDescription;
24  class EventID;
25  class ParameterSet;
27  public:
28  explicit VectorInputSource(ParameterSet const& pset, VectorInputSourceDescription const& desc);
29  virtual ~VectorInputSource();
30 
31  template<typename T>
32  size_t loopOverEvents(EventPrincipal& cache, size_t& fileNameHash, size_t number, T eventOperator, CLHEP::HepRandomEngine* = nullptr, EventID const* id = nullptr);
33 
34  template<typename T, typename Iterator>
35  size_t loopSpecified(EventPrincipal& cache, size_t& fileNameHash, Iterator const& begin, Iterator const& end, T eventOperator);
36 
37  void dropUnwantedBranches(std::vector<std::string> const& wantedBranches);
38  //
40  void doBeginJob();
41 
43  void doEndJob();
44 
45  std::shared_ptr<ProductRegistry const> productRegistry() const {return productRegistry_;}
49 
50  private:
51 
53 
54  private:
55  virtual bool readOneEvent(EventPrincipal& cache, size_t& fileNameHash, CLHEP::HepRandomEngine*, EventID const* id) = 0;
56  virtual void readOneSpecified(EventPrincipal& cache, size_t& fileNameHash, SecondaryEventIDAndFileInfo const& event) = 0;
57  void readOneSpecified(EventPrincipal& cache, size_t& fileNameHash, EventID const& event) {
58  SecondaryEventIDAndFileInfo info(event, fileNameHash);
59  readOneSpecified(cache, fileNameHash, info);
60  }
61 
62  virtual void dropUnwantedBranches_(std::vector<std::string> const& wantedBranches) = 0;
63  virtual void beginJob() = 0;
64  virtual void endJob() = 0;
65 
66  std::shared_ptr<ProductRegistry> productRegistry_;
67  std::unique_ptr<ProcessHistoryRegistry> processHistoryRegistry_;
68  };
69 
70  template<typename T>
71  size_t VectorInputSource::loopOverEvents(EventPrincipal& cache, size_t& fileNameHash, size_t number, T eventOperator, CLHEP::HepRandomEngine* engine, EventID const* id) {
72  size_t i = 0U;
73  for(; i < number; ++i) {
74  clearEventPrincipal(cache);
75  bool found = readOneEvent(cache, fileNameHash, engine, id);
76  if(!found) break;
77  eventOperator(cache, fileNameHash);
78  }
79  return i;
80  }
81 
82  template<typename T, typename Iterator>
83  size_t VectorInputSource::loopSpecified(EventPrincipal& cache, size_t& fileNameHash, Iterator const& begin, Iterator const& end, T eventOperator) {
84  size_t i = 0U;
85  for(Iterator iter = begin; iter != end; ++iter) {
86  clearEventPrincipal(cache);
87  readOneSpecified(cache, fileNameHash, *iter);
88  eventOperator(cache, fileNameHash);
89  ++i;
90  }
91  return i;
92  }
93 }
94 #endif
int i
Definition: DBlmapReader.cc:9
static const TGPicture * info(bool iBackgroundIsBlack)
ProcessHistoryRegistry & processHistoryRegistryForUpdate()
ProcessHistoryRegistry const & processHistoryRegistry() const
void dropUnwantedBranches(std::vector< std::string > const &wantedBranches)
void clearEventPrincipal(EventPrincipal &cache)
std::shared_ptr< ProductRegistry > productRegistry_
VectorInputSource(ParameterSet const &pset, VectorInputSourceDescription const &desc)
void doEndJob()
Called at end of job.
ProductRegistry & productRegistryUpdate() const
std::unique_ptr< ProcessHistoryRegistry > processHistoryRegistry_
size_t loopOverEvents(EventPrincipal &cache, size_t &fileNameHash, size_t number, T eventOperator, CLHEP::HepRandomEngine *=nullptr, EventID const *id=nullptr)
std::shared_ptr< ProductRegistry const > productRegistry() const
void readOneSpecified(EventPrincipal &cache, size_t &fileNameHash, EventID const &event)
#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
virtual bool readOneEvent(EventPrincipal &cache, size_t &fileNameHash, CLHEP::HepRandomEngine *, EventID const *id)=0
size_t loopSpecified(EventPrincipal &cache, size_t &fileNameHash, Iterator const &begin, Iterator const &end, T eventOperator)
void doBeginJob()
Called at beginning of job.
#define begin
Definition: vmac.h:30
virtual void dropUnwantedBranches_(std::vector< std::string > const &wantedBranches)=0
long double T
virtual void beginJob()=0
virtual void endJob()=0
virtual void readOneSpecified(EventPrincipal &cache, size_t &fileNameHash, SecondaryEventIDAndFileInfo const &event)=0