CMS 3D CMS Logo

ProductProvenanceRetriever.h
Go to the documentation of this file.
1 #ifndef DataFormats_Provenance_BranchMapper_h
2 #define DataFormats_Provenance_BranchMapper_h
3 
4 /*----------------------------------------------------------------------
5 
6 ProductProvenanceRetriever: Manages the per event/lumi/run per product provenance.
7 
8 ----------------------------------------------------------------------*/
16 
17 #include <vector>
18 #include <memory>
19 #include <set>
20 #include <atomic>
21 #include <string_view>
22 
23 /*
24  ProductProvenanceRetriever
25 */
26 
27 namespace edm {
28  class ProvenanceReaderBase;
29  class ModuleCallingContext;
30  class ProductRegistry;
31 
33  size_t operator()(ProductProvenance const& tid) const { return tid.branchID().id(); }
34  };
35 
37  //The default operator== for ProductProvenance does not work for this case
38  // Since (a<b)==false and (a>b)==false does not mean a==b for the operators
39  // defined for ProductProvenance
40  bool operator()(ProductProvenance const& iLHS, ProductProvenance const iRHS) const {
41  return iLHS.branchID().id() == iRHS.branchID().id();
42  }
43  };
44 
46  public:
48  virtual ~ProvenanceReaderBase();
49  virtual std::set<ProductProvenance> readProvenance(unsigned int transitionIndex) const = 0;
51  ModuleCallingContext const* moduleCallingContext,
52  unsigned int transitionIndex,
53  std::atomic<const std::set<ProductProvenance>*>& writeTo) const = 0;
54  };
55 
57  public:
58  explicit ProductProvenanceRetriever(unsigned int iTransitionIndex);
59  ProductProvenanceRetriever(unsigned int iTransitionIndex, edm::ProductRegistry const&);
60  explicit ProductProvenanceRetriever(std::unique_ptr<ProvenanceReaderBase> reader);
61 
63 
65 
66  ProductProvenance const* branchIDToProvenance(BranchID const& bid) const;
67 
69 
70  void insertIntoSet(ProductProvenance provenanceProduct) const;
71 
72  void mergeProvenanceRetrievers(std::shared_ptr<ProductProvenanceRetriever> other);
73 
75 
77 
78  void reset();
79 
80  void readProvenanceAsync(WaitingTaskHolder task, ModuleCallingContext const* moduleCallingContext) const;
81 
82  void update(edm::ProductRegistry const&);
83 
85  public:
88  : provenance_{std::move(iOther.provenance_)},
89  isParentageSet_{iOther.isParentageSet_.load(std::memory_order_acquire)} {}
91  bool isSet = iOther.isParentageSet_.load(std::memory_order_acquire);
92  if (isSet) {
93  provenance_.set(iOther.provenance_.parentageID());
94  }
95  isParentageSet_.store(isSet, std::memory_order_release);
96  }
97 
99  provenance_ = std::move(iOther.provenance_);
100  isParentageSet_.store(iOther.isParentageSet_.load(std::memory_order_acquire), std::memory_order_release);
101  return *this;
102  }
104  bool isSet = iOther.isParentageSet_.load(std::memory_order_acquire);
105  if (isSet) {
106  provenance_ = iOther.provenance_;
107  } else {
109  }
110  isParentageSet_.store(isSet, std::memory_order_release);
111  return *this;
112  }
113 
115  if (LIKELY(isParentageSet())) {
116  return &provenance_;
117  }
118  return nullptr;
119  }
120  BranchID branchID() const noexcept { return provenance_.branchID(); }
121 
122  bool isParentageSet() const noexcept { return isParentageSet_.load(std::memory_order_acquire); }
123 
124  void threadsafe_set(ParentageID id) const {
126  isParentageSet_.store(true, std::memory_order_release);
127  }
128 
129  void resetParentage() { isParentageSet_.store(false, std::memory_order_release); }
130 
131  private:
133  mutable std::atomic<bool> isParentageSet_;
134  };
135 
136  private:
137  void readProvenance() const;
138  void setTransitionIndex(unsigned int transitionIndex) { transitionIndex_ = transitionIndex; }
140 
141  std::vector<ProducedProvenanceInfo> entryInfoSet_;
142  mutable std::atomic<const std::set<ProductProvenance>*> readEntryInfoSet_;
145  std::shared_ptr<const ProvenanceReaderBase> provenanceReader_;
146  unsigned int transitionIndex_;
147  };
148 
149 } // namespace edm
150 #endif
Likely.h
ProcessHistoryID.h
edm::ProductProvenanceRetriever::ProducedProvenanceInfo::provenance_
ProductProvenance provenance_
Definition: ProductProvenanceRetriever.h:132
propagate_const.h
WaitingTaskHolder.h
edm::ProductProvenanceRetriever::readProvenanceAsync
void readProvenanceAsync(WaitingTaskHolder task, ModuleCallingContext const *moduleCallingContext) const
Definition: ProductProvenanceRetriever.cc:76
edm::ProvenanceReaderBase
Definition: ProductProvenanceRetriever.h:45
edm::ProductProvenanceRetriever::ProducedProvenanceInfo::isParentageSet
bool isParentageSet() const noexcept
Definition: ProductProvenanceRetriever.h:122
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ProductProvenanceRetriever::operator=
ProductProvenanceRetriever & operator=(ProductProvenanceRetriever const &)=delete
edm::ProductProvenanceRetriever::ProducedProvenanceInfo::operator=
ProducedProvenanceInfo & operator=(ProducedProvenanceInfo &&iOther)
Definition: ProductProvenanceRetriever.h:98
edm::ProductProvenanceRetriever::ProducedProvenanceInfo::operator=
ProducedProvenanceInfo & operator=(ProducedProvenanceInfo const &iOther)
Definition: ProductProvenanceRetriever.h:103
BranchID.h
edm::ProvenanceReaderBase::readProvenanceAsync
virtual void readProvenanceAsync(WaitingTaskHolder task, ModuleCallingContext const *moduleCallingContext, unsigned int transitionIndex, std::atomic< const std::set< ProductProvenance > * > &writeTo) const =0
edm::ProductProvenanceRetriever::readEntryInfoSet_
std::atomic< const std::set< ProductProvenance > * > readEntryInfoSet_
Definition: ProductProvenanceRetriever.h:142
edm::ProductProvenanceHasher::operator()
size_t operator()(ProductProvenance const &tid) const
Definition: ProductProvenanceRetriever.h:33
edm::ProductProvenanceRetriever::ProducedProvenanceInfo::resetParentage
void resetParentage()
Definition: ProductProvenanceRetriever.h:129
watchdog.const
const
Definition: watchdog.py:83
edm::BranchID::id
unsigned int id() const
Definition: BranchID.h:21
edm::ProductProvenanceRetriever::ProducedProvenanceInfo::ProducedProvenanceInfo
ProducedProvenanceInfo(ProducedProvenanceInfo &&iOther)
Definition: ProductProvenanceRetriever.h:87
edm::ProductProvenanceRetriever::update
void update(edm::ProductRegistry const &)
Definition: ProductProvenanceRetriever.cc:71
edm::ProductRegistry
Definition: ProductRegistry.h:37
edm::ProductProvenanceRetriever::ProducedProvenanceInfo::ProducedProvenanceInfo
ProducedProvenanceInfo(BranchID iBid)
Definition: ProductProvenanceRetriever.h:86
edm::propagate_const
Definition: propagate_const.h:32
edm::ProductProvenanceRetriever::insertIntoSet
void insertIntoSet(ProductProvenance provenanceProduct) const
Definition: ProductProvenanceRetriever.cc:121
edm::ProductProvenance
Definition: ProductProvenance.h:24
edm::ProductProvenanceHasher
Definition: ProductProvenanceRetriever.h:32
DQM.reader
reader
Definition: DQM.py:105
edm::ProductProvenanceRetriever::mergeParentProcessRetriever
void mergeParentProcessRetriever(ProductProvenanceRetriever const &provRetriever)
Definition: ProductProvenanceRetriever.cc:142
ProductProvenance.h
edm::BranchID
Definition: BranchID.h:14
edm::ProductProvenance::set
void set(ParentageID id)
Definition: ProductProvenance.h:42
TrackValidation_cff.task
task
Definition: TrackValidation_cff.py:252
edm::ProductProvenanceEqual::operator()
bool operator()(ProductProvenance const &iLHS, ProductProvenance const iRHS) const
Definition: ProductProvenanceRetriever.h:40
edm::ProductProvenance::branchID
BranchID const & branchID() const
Definition: ProductProvenance.h:38
edm::Hash< ParentageType >
trackingPlots.other
other
Definition: trackingPlots.py:1460
edm::ProductProvenanceRetriever::reset
void reset()
Definition: ProductProvenanceRetriever.cc:109
edm::ProductProvenanceRetriever::entryInfoSet_
std::vector< ProducedProvenanceInfo > entryInfoSet_
Definition: ProductProvenanceRetriever.h:141
edm::ProductProvenanceRetriever::~ProductProvenanceRetriever
~ProductProvenanceRetriever()
Definition: ProductProvenanceRetriever.cc:43
edm::ProductProvenanceRetriever::ProducedProvenanceInfo::threadsafe_set
void threadsafe_set(ParentageID id) const
Definition: ProductProvenanceRetriever.h:124
edm::ProductProvenanceRetriever::ProducedProvenanceInfo::ProducedProvenanceInfo
ProducedProvenanceInfo(ProducedProvenanceInfo const &iOther)
Definition: ProductProvenanceRetriever.h:90
edm::ProductProvenanceRetriever::ProducedProvenanceInfo::isParentageSet_
std::atomic< bool > isParentageSet_
Definition: ProductProvenanceRetriever.h:133
edm::ProductProvenanceRetriever::mergeProvenanceRetrievers
void mergeProvenanceRetrievers(std::shared_ptr< ProductProvenanceRetriever > other)
Definition: ProductProvenanceRetriever.cc:138
edm::ProductProvenanceRetriever::readProvenance
void readProvenance() const
Definition: ProductProvenanceRetriever.cc:45
edm::WaitingTaskHolder
Definition: WaitingTaskHolder.h:32
edm::ProductProvenanceRetriever::setupEntryInfoSet
void setupEntryInfoSet(edm::ProductRegistry const &)
Definition: ProductProvenanceRetriever.cc:56
edm::ProductProvenanceEqual
Definition: ProductProvenanceRetriever.h:36
thread_safety_macros.h
edm::ProvenanceReaderBase::~ProvenanceReaderBase
virtual ~ProvenanceReaderBase()
Definition: ProductProvenanceRetriever.cc:194
edm::ProductProvenanceRetriever::ProducedProvenanceInfo::productProvenance
ProductProvenance const * productProvenance() const noexcept
Definition: ProductProvenanceRetriever.h:114
edm::ProductProvenanceRetriever::ProducedProvenanceInfo::branchID
BranchID branchID() const noexcept
Definition: ProductProvenanceRetriever.h:120
edm::ProvenanceReaderBase::readProvenance
virtual std::set< ProductProvenance > readProvenance(unsigned int transitionIndex) const =0
edm::ProductProvenanceRetriever::deepCopy
void deepCopy(ProductProvenanceRetriever const &)
Definition: ProductProvenanceRetriever.cc:86
edm::ProductProvenanceRetriever
Definition: ProductProvenanceRetriever.h:56
edm::ProductProvenanceRetriever::nextRetriever_
edm::propagate_const< std::shared_ptr< ProductProvenanceRetriever > > nextRetriever_
Definition: ProductProvenanceRetriever.h:143
eostools.move
def move(src, dest)
Definition: eostools.py:511
LIKELY
#define LIKELY(x)
Definition: Likely.h:20
edm::ProductProvenanceRetriever::setTransitionIndex
void setTransitionIndex(unsigned int transitionIndex)
Definition: ProductProvenanceRetriever.h:138
edm::ProductProvenanceRetriever::branchIDToProvenance
ProductProvenance const * branchIDToProvenance(BranchID const &bid) const
Definition: ProductProvenanceRetriever.cc:146
edm::ProductProvenanceRetriever::transitionIndex_
unsigned int transitionIndex_
Definition: ProductProvenanceRetriever.h:146
edm::ProductProvenanceRetriever::branchIDToProvenanceForProducedOnly
ProductProvenance const * branchIDToProvenanceForProducedOnly(BranchID const &bid) const
Definition: ProductProvenanceRetriever.cc:175
edm::ProductProvenanceRetriever::ProductProvenanceRetriever
ProductProvenanceRetriever(unsigned int iTransitionIndex)
Definition: ProductProvenanceRetriever.cc:14
edm::ProvenanceReaderBase::ProvenanceReaderBase
ProvenanceReaderBase()
Definition: ProductProvenanceRetriever.h:47
edm::ProductProvenanceRetriever::provenanceReader_
std::shared_ptr< const ProvenanceReaderBase > provenanceReader_
Definition: ProductProvenanceRetriever.h:145
edm::ProductProvenanceRetriever::ProducedProvenanceInfo
Definition: ProductProvenanceRetriever.h:84
edm::ProductProvenanceRetriever::parentProcessRetriever_
edm::propagate_const< ProductProvenanceRetriever const * > parentProcessRetriever_
Definition: ProductProvenanceRetriever.h:144
CMS_THREAD_GUARD
#define CMS_THREAD_GUARD(_var_)
Definition: thread_safety_macros.h:6
edm::ModuleCallingContext
Definition: ModuleCallingContext.h:29