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>
34  size_t& fileNameHash,
35  size_t number,
36  T eventOperator,
37  CLHEP::HepRandomEngine* = nullptr,
38  EventID const* id = nullptr,
39  bool recycleFiles = true);
40 
41  template <typename T, typename Iterator>
42  size_t loopSpecified(
43  EventPrincipal& cache, size_t& fileNameHash, Iterator const& begin, Iterator const& end, T eventOperator);
44 
45  void dropUnwantedBranches(std::vector<std::string> const& wantedBranches);
46  //
48  void doBeginJob();
49 
51  void doEndJob();
52 
53  std::shared_ptr<ProductRegistry const> productRegistry() const { return get_underlying_safe(productRegistry_); }
54  std::shared_ptr<ProductRegistry>& productRegistry() { return get_underlying_safe(productRegistry_); }
58 
59  private:
61 
62  private:
63  virtual bool readOneEvent(
64  EventPrincipal& cache, size_t& fileNameHash, CLHEP::HepRandomEngine*, EventID const* id, bool recycleFiles) = 0;
66  size_t& fileNameHash,
68  void readOneSpecified(EventPrincipal& cache, size_t& fileNameHash, EventID const& event) {
69  SecondaryEventIDAndFileInfo info(event, fileNameHash);
70  readOneSpecified(cache, fileNameHash, info);
71  }
72 
73  virtual void dropUnwantedBranches_(std::vector<std::string> const& wantedBranches) = 0;
74  virtual void beginJob() = 0;
75  virtual void endJob() = 0;
76 
77  void throwIfOverLimit(unsigned int consecutiveRejections) const;
78 
82  };
83 
84  template <typename T>
86  size_t& fileNameHash,
87  size_t number,
88  T eventOperator,
89  CLHEP::HepRandomEngine* engine,
90  EventID const* id,
91  bool recycleFiles) {
92  size_t i = 0U;
93  unsigned int consecutiveRejections = 0U;
94  while (i < number) {
96  bool found = readOneEvent(cache, fileNameHash, engine, id, recycleFiles);
97  if (!found)
98  break;
99  bool used = eventOperator(cache, fileNameHash);
100  if (used) {
101  ++i;
102  consecutiveRejections = 0U;
103  } else if (consecutiveRejectionsLimit_ > 0) {
104  ++consecutiveRejections;
105  throwIfOverLimit(consecutiveRejections);
106  }
107  }
108  return i;
109  }
110 
111  template <typename T, typename Iterator>
113  EventPrincipal& cache, size_t& fileNameHash, Iterator const& begin, Iterator const& end, T eventOperator) {
114  size_t i = 0U;
115  for (Iterator iter = begin; iter != end; ++iter) {
117  readOneSpecified(cache, fileNameHash, *iter);
118  eventOperator(cache, fileNameHash);
119  ++i;
120  }
121  return i;
122  }
123 } // namespace edm
124 #endif
edm::VectorInputSource::productRegistry
std::shared_ptr< ProductRegistry > & productRegistry()
Definition: VectorInputSource.h:54
edm::VectorInputSource::doEndJob
void doEndJob()
Called at end of job.
Definition: VectorInputSource.cc:27
edm::VectorInputSource::dropUnwantedBranches
void dropUnwantedBranches(std::vector< std::string > const &wantedBranches)
Definition: VectorInputSource.cc:19
edm::VectorInputSource::dropUnwantedBranches_
virtual void dropUnwantedBranches_(std::vector< std::string > const &wantedBranches)=0
mps_fire.i
i
Definition: mps_fire.py:428
edm::VectorInputSource::consecutiveRejectionsLimit_
unsigned int consecutiveRejectionsLimit_
Definition: VectorInputSource.h:81
edm::VectorInputSource::processHistoryRegistry_
edm::propagate_const< std::unique_ptr< ProcessHistoryRegistry > > processHistoryRegistry_
Definition: VectorInputSource.h:80
edm::VectorInputSource::readOneEvent
virtual bool readOneEvent(EventPrincipal &cache, size_t &fileNameHash, CLHEP::HepRandomEngine *, EventID const *id, bool recycleFiles)=0
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::VectorInputSource::processHistoryRegistry
ProcessHistoryRegistry const & processHistoryRegistry() const
Definition: VectorInputSource.h:56
edm::VectorInputSourceDescription
Definition: VectorInputSourceDescription.h:18
edm::VectorInputSource
Definition: VectorInputSource.h:27
edm::VectorInputSource::readOneSpecified
virtual void readOneSpecified(EventPrincipal &cache, size_t &fileNameHash, SecondaryEventIDAndFileInfo const &event)=0
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
ProcessHistoryRegistry.h
edm::get_underlying_safe
constexpr std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
Definition: get_underlying_safe.h:41
ProductRegistry.h
edm::VectorInputSource::clearEventPrincipal
void clearEventPrincipal(EventPrincipal &cache)
Definition: VectorInputSource.cc:23
Iterator
Definition: DQMStoreStats.h:94
edm::SecondaryEventIDAndFileInfo
Definition: SecondaryEventIDAndFileInfo.h:8
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
edm::ProductRegistry
Definition: ProductRegistry.h:37
edm::propagate_const
Definition: propagate_const.h:32
edm::EventPrincipal
Definition: EventPrincipal.h:46
contentValuesFiles.number
number
Definition: contentValuesFiles.py:53
edm::VectorInputSource::throwIfOverLimit
void throwIfOverLimit(unsigned int consecutiveRejections) const
Definition: VectorInputSource.cc:29
mps_fire.end
end
Definition: mps_fire.py:242
edm::VectorInputSource::productRegistry_
edm::propagate_const< std::shared_ptr< ProductRegistry > > productRegistry_
Definition: VectorInputSource.h:79
edm::VectorInputSource::loopSpecified
size_t loopSpecified(EventPrincipal &cache, size_t &fileNameHash, Iterator const &begin, Iterator const &end, T eventOperator)
Definition: VectorInputSource.h:112
utilities.cache
def cache(function)
Definition: utilities.py:3
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
CLHEP
Definition: CocoaGlobals.h:27
edm::VectorInputSource::processHistoryRegistryForUpdate
ProcessHistoryRegistry & processHistoryRegistryForUpdate()
Definition: VectorInputSource.h:57
edm::ParameterSet
Definition: ParameterSet.h:47
edm::VectorInputSource::productRegistryUpdate
ProductRegistry & productRegistryUpdate()
Definition: VectorInputSource.h:55
ParameterSet
Definition: Functions.h:16
edm::VectorInputSource::loopOverEvents
size_t loopOverEvents(EventPrincipal &cache, size_t &fileNameHash, size_t number, T eventOperator, CLHEP::HepRandomEngine *=nullptr, EventID const *id=nullptr, bool recycleFiles=true)
Definition: VectorInputSource.h:85
edm::VectorInputSource::readOneSpecified
void readOneSpecified(EventPrincipal &cache, size_t &fileNameHash, EventID const &event)
Definition: VectorInputSource.h:68
edm::VectorInputSource::~VectorInputSource
virtual ~VectorInputSource()
Definition: VectorInputSource.cc:17
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
T
long double T
Definition: Basic3DVectorLD.h:48
edm::VectorInputSource::VectorInputSource
VectorInputSource(ParameterSet const &pset, VectorInputSourceDescription const &desc)
Definition: VectorInputSource.cc:12
edm::VectorInputSource::endJob
virtual void endJob()=0
edm::VectorInputSource::beginJob
virtual void beginJob()=0
edm::ProcessHistoryRegistry
Definition: ProcessHistoryRegistry.h:18
edm::VectorInputSource::productRegistry
std::shared_ptr< ProductRegistry const > productRegistry() const
Definition: VectorInputSource.h:53
ParameterSet.h
event
Definition: event.py:1
edm::EventID
Definition: EventID.h:31
get_underlying_safe.h
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
edm::VectorInputSource::doBeginJob
void doBeginJob()
Called at beginning of job.
Definition: VectorInputSource.cc:25
SecondaryEventIDAndFileInfo.h