Skip to content

Commit

Permalink
Merge pull request #37693 from Dr15Jones/handleEmptyTable
Browse files Browse the repository at this point in the history
Handle empty table when writing NanoAOD
  • Loading branch information
cmsbuild authored Apr 26, 2022
2 parents 30a3ff5 + f726ecd commit 37b90ad
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion PhysicsTools/NanoAOD/plugins/TableOutputBranches.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ class TableOutputBranches {
int idx = tab.columnIndex(pair.name);
if (idx == -1)
throw cms::Exception("LogicError", "Missing column in input for " + m_baseName + "_" + pair.name);
pair.branch->SetAddress(const_cast<T *>(&tab.columnData<T>(idx).front())); // SetAddress should take a const * !
pair.branch->SetAddress(
tab.size() == 0 ? static_cast<T *>(nullptr)
: const_cast<T *>(&tab.columnData<T>(idx).front())); // SetAddress should take a const * !
}
};

Expand Down

0 comments on commit 37b90ad

Please sign in to comment.