Skip to content

Commit bd8e7a9

Browse files
committed
address comments
1 parent 0f61387 commit bd8e7a9

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

‎PWGDQ/Tasks/tableReader_withAssoc.h‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
#include <RtypesCore.h>
6969

7070
#include <algorithm>
71+
#include <charconv>
7172
#include <chrono>
7273
#include <cmath>
7374
#include <cstdint>
@@ -78,6 +79,7 @@
7879
#include <map>
7980
#include <memory>
8081
#include <string>
82+
#include <system_error>
8183
#include <utility>
8284
#include <variant>
8385
#include <vector>
@@ -1511,7 +1513,7 @@ struct AnalysisSameEventPairing {
15111513
o2::framework::Configurable<std::string> fConfigMixingVariables{"cfgMixingVars", "", "Mixing configs separated by a comma, default no mixing"};
15121514
o2::framework::Configurable<std::string> fConfigMixingVariablesJson{"cfgMixingVarsJSON", "", "Mixing configs in JSON format"};
15131515
o2::framework::Configurable<bool> fConfigRunMixingAcrossTFs{"cfgRunMixingAcrossTFs", false, "If true, run event mixing using the MixingHandler which accumulates events across multiple TFs"};
1514-
o2::framework::Configurable<std::string> fConfigMixingNSelEdges{"cfgMixingNSelEdges", "", "Comma separated class edges in the number of selected pairing tracks per event"};
1516+
o2::framework::Configurable<std::string> fConfigMixingNSelEdges{"cfgMixingNSelEdges", "", "Comma separated class edges in the number of selected pairing tracks per event, (e.g. 2,3,4,1000)"};
15151517
// o2::framework::Configurable<std::string> fConfigAddEventMixingHistogram{"cfgAddEventMixingHistogram", "", "Comma separated list of histograms"};
15161518
o2::framework::Configurable<std::string> fConfigAddSEPHistogram{"cfgAddSEPHistogram", "", "Comma separated list of histograms"};
15171519
o2::framework::Configurable<std::string> fConfigAddJSONHistograms{"cfgAddJSONHistograms", "", "Histograms in JSON format"};
@@ -1865,7 +1867,16 @@ struct AnalysisSameEventPairing {
18651867
if (!fConfigMixingNSelEdges.value.empty()) {
18661868
std::unique_ptr<TObjArray> edgeArr(TString(fConfigMixingNSelEdges.value).Tokenize(","));
18671869
for (int ie = 0; ie < edgeArr->GetEntries(); ++ie) {
1868-
fMixNSelEdges.push_back(static_cast<TObjString*>(edgeArr->At(ie))->GetString().Atoi());
1870+
const std::string edgeStr = dynamic_cast<TObjString*>(edgeArr->At(ie))->GetString().Data();
1871+
int edge = 0;
1872+
const auto [ptr, ec] = std::from_chars(edgeStr.data(), edgeStr.data() + edgeStr.size(), edge);
1873+
if (ec != std::errc() || ptr != edgeStr.data() + edgeStr.size()) {
1874+
LOG(fatal) << "Edges must be integers: '" << fConfigMixingNSelEdges.value << "'";
1875+
}
1876+
fMixNSelEdges.push_back(edge);
1877+
}
1878+
if (fMixNSelEdges.size() < 2 || !std::is_sorted(fMixNSelEdges.begin(), fMixNSelEdges.end()) || std::adjacent_find(fMixNSelEdges.begin(), fMixNSelEdges.end()) != fMixNSelEdges.end()) {
1879+
LOG(fatal) << "cfgMixingNSelEdges needs at least two edges in strictly increasing order: '" << fConfigMixingNSelEdges.value << "'";
18691880
}
18701881
LOGF(info, "Event mixing restricted to classes of selected pairing tracks per event: %s", fConfigMixingNSelEdges.value.c_str());
18711882
}

0 commit comments

Comments
 (0)