Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:05:05

0001 #include "DataFormats/Provenance/interface/Provenance.h"
0002 
0003 #include "DataFormats/Provenance/interface/MergeableRunProductMetadataBase.h"
0004 #include "DataFormats/Provenance/interface/ProductProvenanceLookup.h"
0005 #include "DataFormats/Provenance/interface/ProcessConfiguration.h"
0006 
0007 #include <algorithm>
0008 #include <cassert>
0009 
0010 /*----------------------------------------------------------------------
0011 
0012 ----------------------------------------------------------------------*/
0013 
0014 namespace edm {
0015 
0016   Provenance::Provenance() : Provenance{StableProvenance()} {}
0017 
0018   Provenance::Provenance(std::shared_ptr<BranchDescription const> const& p, ProductID const& pid)
0019       : stableProvenance_(p, pid), store_(), mergeableRunProductMetadata_() {}
0020 
0021   Provenance::Provenance(StableProvenance const& stable)
0022       : stableProvenance_(stable), store_(), mergeableRunProductMetadata_() {}
0023 
0024   ProductProvenance const* Provenance::productProvenance() const {
0025     if (!store_) {
0026       return nullptr;
0027     }
0028     return store_->branchIDToProvenance(originalBranchID());
0029   }
0030 
0031   bool Provenance::knownImproperlyMerged() const {
0032     if (mergeableRunProductMetadata_ && branchDescription().isMergeable()) {
0033       // This part handles the cases where the product is
0034       // a mergeable run product from the input.
0035       return mergeableRunProductMetadata_->knownImproperlyMerged(processName());
0036     }
0037     // All other cases
0038     return false;
0039   }
0040 
0041   void Provenance::write(std::ostream& os) const {
0042     // This is grossly inadequate, but it is not critical for the
0043     // first pass.
0044     stable().write(os);
0045     auto pp = productProvenance();
0046     if (pp != nullptr) {
0047       pp->write(os);
0048     }
0049   }
0050 
0051   bool operator==(Provenance const& a, Provenance const& b) { return a.stable() == b.stable(); }
0052 
0053   void Provenance::swap(Provenance& iOther) {
0054     stableProvenance_.swap(iOther.stableProvenance_);
0055     std::swap(store_, iOther.store_);
0056     std::swap(mergeableRunProductMetadata_, iOther.mergeableRunProductMetadata_);
0057   }
0058 }  // namespace edm