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 ----------------------------------------------------------------------*/
13 
14 #include "tbb/concurrent_unordered_set.h"
15 #include <memory>
16 #include <set>
17 #include <atomic>
18 
19 /*
20  ProductProvenanceRetriever
21 */
22 
23 namespace edm {
24  class ProvenanceReaderBase;
25  class WaitingTask;
26  class ModuleCallingContext;
27 
29  size_t operator()(ProductProvenance const& tid) const {
30  return tid.branchID().id();
31  }
32  };
33 
35  //The default operator== for ProductProvenance does not work for this case
36  // Since (a<b)==false and (a>b)==false does not mean a==b for the operators
37  // defined for ProductProvenance
38  bool operator()(ProductProvenance const& iLHS, ProductProvenance const iRHS) const {
39  return iLHS.branchID().id()== iRHS.branchID().id();
40  }
41  };
42 
44  public:
46  virtual ~ProvenanceReaderBase();
47  virtual std::set<ProductProvenance> readProvenance(unsigned int transitionIndex) const = 0;
48  virtual void readProvenanceAsync(WaitingTask* task,
49  ModuleCallingContext const* moduleCallingContext,
50  unsigned int transitionIndex,
51  std::atomic<const std::set<ProductProvenance>*>& writeTo
52  ) const = 0;
53  };
54 
56  public:
57  explicit ProductProvenanceRetriever(unsigned int iTransitionIndex);
58  explicit ProductProvenanceRetriever(std::unique_ptr<ProvenanceReaderBase> reader);
59 
60  ProductProvenanceRetriever& operator=(ProductProvenanceRetriever const&) = delete;
61 
63 
64  ProductProvenance const* branchIDToProvenance(BranchID const& bid) const;
65 
66  ProductProvenance const* branchIDToProvenanceForProducedOnly(BranchID const& bid) const;
67 
68  void insertIntoSet(ProductProvenance const& provenanceProduct) const;
69 
70  void mergeProvenanceRetrievers(std::shared_ptr<ProductProvenanceRetriever> other);
71 
72  void mergeParentProcessRetriever(ProductProvenanceRetriever const& provRetriever);
73 
74  void deepCopy(ProductProvenanceRetriever const&);
75 
76  void reset();
77 
78  void readProvenanceAsync(WaitingTask* task, ModuleCallingContext const* moduleCallingContext) const;
79 
80  private:
81  void readProvenance() const;
82  void setTransitionIndex(unsigned int transitionIndex) {
83  transitionIndex_=transitionIndex;
84  }
85 
86  mutable tbb::concurrent_unordered_set<ProductProvenance, ProductProvenanceHasher, ProductProvenanceEqual> entryInfoSet_;
87  mutable std::atomic<const std::set<ProductProvenance>*> readEntryInfoSet_;
90  std::shared_ptr<const ProvenanceReaderBase> provenanceReader_;
91  unsigned int transitionIndex_;
92  };
93 
94 }
95 #endif
BranchID const & branchID() const
tbb::concurrent_unordered_set< ProductProvenance, ProductProvenanceHasher, ProductProvenanceEqual > entryInfoSet_
unsigned int id() const
Definition: BranchID.h:23
size_t operator()(ProductProvenance const &tid) const
std::shared_ptr< const ProvenanceReaderBase > provenanceReader_
edm::propagate_const< ProductProvenanceRetriever const * > parentProcessRetriever_
bool operator()(ProductProvenance const &iLHS, ProductProvenance const iRHS) const
std::atomic< const std::set< ProductProvenance > * > readEntryInfoSet_
HLT enums.
edm::propagate_const< std::shared_ptr< ProductProvenanceRetriever > > nextRetriever_
void setTransitionIndex(unsigned int transitionIndex)
void reset(double vett[256])
Definition: TPedValues.cc:11