Skip to content

Commit

Permalink
Use Redefine for pmID if a column with same name already exists
Browse files Browse the repository at this point in the history
  • Loading branch information
AlvaroEzq committed Oct 6, 2023
1 parent 243241d commit a50485d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions source/framework/analysis/src/TRestDataSetGainMap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,16 @@ void TRestDataSetGainMap::CalibrateDataSet(const std::string& dataSetFileName, s
auto dataFrame = dataSet.GetDataFrame();

// Define a new column with the identifier (pmID) of the module for each row (event)
std::string modCut = fModulesCal[0].GetModuleDefinitionCut();
std::string pmIDname = (std::string)GetName() + "_pmID";
std::string modCut = fModulesCal[0].GetModuleDefinitionCut();
int pmID = fModulesCal[0].GetPlaneId() * 10 + fModulesCal[0].GetModuleId();
dataFrame = dataFrame.Define(pmIDname, modCut + " ? " + std::to_string(pmID) + " : -1");

auto columnList = dataFrame.GetColumnNames();
if (std::find(columnList.begin(), columnList.end(), pmIDname) == columnList.end())
dataFrame = dataFrame.Define(pmIDname, modCut + " ? " + std::to_string(pmID) + " : -1");
else
dataFrame = dataFrame.Redefine(pmIDname, modCut + " ? " + std::to_string(pmID) + " : -1");

for (size_t n = 1; n < fModulesCal.size(); n++) {
modCut = fModulesCal[n].GetModuleDefinitionCut();
pmID = fModulesCal[n].GetPlaneId() * 10 + fModulesCal[n].GetModuleId();
Expand Down

0 comments on commit a50485d

Please sign in to comment.