Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-24 02:18:57

0001 #ifndef FWCore_Sources_DaqProvenanceHelper_h
0002 #define FWCore_Sources_DaqProvenanceHelper_h
0003 
0004 #include <map>
0005 #include <string>
0006 #include <vector>
0007 #include "oneapi/tbb/concurrent_unordered_map.h"
0008 
0009 #include "DataFormats/Provenance/interface/BranchDescription.h"
0010 #include "DataFormats/Provenance/interface/ParentageID.h"
0011 #include "DataFormats/Provenance/interface/ProcessConfiguration.h"
0012 #include "DataFormats/Provenance/interface/ProcessHistoryID.h"
0013 #include "DataFormats/Provenance/interface/ProductProvenance.h"
0014 #include "DataFormats/Provenance/interface/BranchID.h"
0015 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0016 
0017 namespace edm {
0018   class BranchChildren;
0019   class ProcessHistoryRegistry;
0020 
0021   namespace dqh {
0022     struct parentage_hash {
0023       std::size_t operator()(edm::ParentageID const& iKey) const { return iKey.smallHash(); }
0024     };
0025   }  // namespace dqh
0026 
0027   struct DaqProvenanceHelper {
0028     typedef std::map<ProcessHistoryID, ProcessHistoryID> ProcessHistoryIDMap;
0029     typedef oneapi::tbb::concurrent_unordered_map<ParentageID, ParentageID, dqh::parentage_hash> ParentageIDMap;
0030     explicit DaqProvenanceHelper(TypeID const& rawDataType);
0031     ProcessHistoryID daqInit(ProductRegistry& productRegistry, ProcessHistoryRegistry& processHistoryRegistry) const;
0032     void saveInfo(BranchDescription const& oldBD, BranchDescription const& newBD) {
0033       oldProcessName_ = oldBD.processName();
0034       oldBranchID_ = oldBD.branchID();
0035       newBranchID_ = newBD.branchID();
0036     }
0037     bool matchProcesses(ProcessConfiguration const& pc, ProcessHistory const& ph) const;
0038     void fixMetaData(ProcessConfigurationVector& pcv, std::vector<ProcessHistory>& phv);
0039     void fixMetaData(std::vector<BranchID>& branchIDs) const;
0040     void fixMetaData(BranchIDLists const&) const;
0041     void fixMetaData(BranchChildren& branchChildren) const;
0042     ProcessHistoryID const& mapProcessHistoryID(ProcessHistoryID const& phid);
0043     ParentageID const& mapParentageID(ParentageID const& phid) const;
0044     BranchID const& mapBranchID(BranchID const& branchID) const;
0045 
0046     BranchDescription const& branchDescription() const { return constBranchDescription_; }
0047     ProcessHistoryID const* oldProcessHistoryID() const { return oldProcessHistoryID_; }
0048     ProductProvenance const& dummyProvenance() const { return dummyProvenance_; }
0049 
0050     void setOldParentageIDToNew(ParentageID const& iOld, ParentageID const& iNew);
0051 
0052   private:
0053     BranchDescription const constBranchDescription_;
0054     ProductProvenance dummyProvenance_;
0055     ParameterSet processParameterSet_;
0056 
0057     std::string oldProcessName_;
0058     BranchID oldBranchID_;
0059     BranchID newBranchID_;
0060     ProcessHistoryID const* oldProcessHistoryID_;
0061     ProcessHistoryIDMap phidMap_;
0062     ParentageIDMap parentageIDMap_;
0063   };
0064 }  // namespace edm
0065 #endif