CMS 3D CMS Logo

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