-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38858 from makortel/edmProvDumpProductID
Add printout of BranchID (or optionally ProductID) to edmProvDump
- Loading branch information
Showing
5 changed files
with
176 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#ifndef DataFormats_Provenance_branchIDToProductID_h | ||
#define DataFormats_Provenance_branchIDToProductID_h | ||
|
||
#include "DataFormats/Provenance/interface/BranchID.h" | ||
#include "DataFormats/Provenance/interface/BranchIDListHelper.h" | ||
#include "DataFormats/Provenance/interface/ProductID.h" | ||
|
||
#include <vector> | ||
|
||
namespace edm { | ||
// Fill in helper map for Branch to ProductID mapping | ||
std::vector<ProcessIndex> makeBranchListIndexToProcessIndex(BranchListIndexes const& branchListIndexes); | ||
|
||
ProductID branchIDToProductID(BranchID const& bid, | ||
BranchIDListHelper const& branchIDListHelper, | ||
std::vector<ProcessIndex> const& branchListIndexToProcessIndex); | ||
} // namespace edm | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include "DataFormats/Provenance/interface/branchIDToProductID.h" | ||
#include "FWCore/Utilities/interface/EDMException.h" | ||
|
||
#include <algorithm> | ||
|
||
namespace edm { | ||
std::vector<ProcessIndex> makeBranchListIndexToProcessIndex(BranchListIndexes const& branchListIndexes) { | ||
ProcessIndex pix = 0; | ||
auto const nelem = 1 + *std::max_element(branchListIndexes.begin(), branchListIndexes.end()); | ||
std::vector<ProcessIndex> branchListIndexToProcessIndex(nelem, std::numeric_limits<BranchListIndex>::max()); | ||
for (auto const& blindex : branchListIndexes) { | ||
branchListIndexToProcessIndex[blindex] = pix; | ||
++pix; | ||
} | ||
return branchListIndexToProcessIndex; | ||
} | ||
|
||
ProductID branchIDToProductID(BranchID const& bid, | ||
BranchIDListHelper const& branchIDListHelper, | ||
std::vector<ProcessIndex> const& branchListIndexToProcessIndex) { | ||
if (not bid.isValid()) { | ||
throw Exception(errors::NotFound, "InvalidID") << "branchIDToProductID: invalid BranchID supplied\n"; | ||
} | ||
|
||
auto range = branchIDListHelper.branchIDToIndexMap().equal_range(bid); | ||
for (auto it = range.first; it != range.second; ++it) { | ||
edm::BranchListIndex blix = it->second.first; | ||
if (blix < branchListIndexToProcessIndex.size()) { | ||
auto v = branchListIndexToProcessIndex[blix]; | ||
if (v != std::numeric_limits<edm::BranchListIndex>::max()) { | ||
edm::ProductIndex productIndex = it->second.second; | ||
edm::ProcessIndex processIndex = v; | ||
return edm::ProductID(processIndex + 1, productIndex + 1); | ||
} | ||
} | ||
} | ||
// cannot throw, because some products may legitimately not have product ID's (e.g. pile-up). | ||
return edm::ProductID(); | ||
} | ||
|
||
} // namespace edm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters