Skip to content

Commit a60bdb7

Browse files
Elros60ktf
authored andcommitted
Fix bug when reading input string for chamber fixing
1 parent 9ef74a0 commit a60bdb7

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

Detectors/MUON/MCH/Align/src/AlignRecordSpec.cxx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// granted to it by virtue of its status as an Intergovernmental Organization
1010
// or submit itself to any jurisdiction.
1111
#include <filesystem>
12+
#include <sstream>
1213

1314
#include "MCHAlign/AlignRecordSpec.h"
1415

@@ -120,14 +121,14 @@ class AlignRecordTask
120121
mImproveCutChi2 = 2. * trackerParam.sigmaCutForImprovement * trackerParam.sigmaCutForImprovement;
121122

122123
// Configuration for chamber fixing
123-
auto chambers = ic.options().get<string>("fix-chamber");
124-
for (int i = 0; i < chambers.length(); ++i) {
125-
if (chambers[i] == ',') {
126-
continue;
127-
}
128-
int chamber = chambers[i] - '0';
129-
LOG(info) << Form("%s%d", "Fixing chamber: ", chamber);
130-
mAlign.FixChamber(chamber);
124+
auto input_fixchambers = ic.options().get<string>("fix-chamber");
125+
std::stringstream string_chambers(input_fixchambers);
126+
string_chambers >> std::ws;
127+
while (string_chambers.good()) {
128+
string substr;
129+
std::getline(string_chambers, substr, ',');
130+
LOG(info) << Form("%s%d", "Fixing chamber: ", std::stoi(substr));
131+
mAlign.FixChamber(std::stoi(substr));
131132
}
132133

133134
// Init for output saving

Detectors/MUON/MCH/Align/src/AlignmentSpec.cxx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <chrono>
2424
#include <iostream>
2525
#include <filesystem>
26+
#include <sstream>
2627

2728
#include <TCanvas.h>
2829
#include <TChain.h>
@@ -222,14 +223,14 @@ class AlignmentTask
222223
mImproveCutChi2 = 2. * trackerParam.sigmaCutForImprovement * trackerParam.sigmaCutForImprovement;
223224

224225
// Fix chambers
225-
auto chambers = ic.options().get<string>("fix-chamber");
226-
for (int i = 0; i < chambers.length(); ++i) {
227-
if (chambers[i] == ',') {
228-
continue;
229-
}
230-
int chamber = chambers[i] - '0';
231-
LOG(info) << Form("%s%d", "Fixing chamber: ", chamber);
232-
mAlign.FixChamber(chamber);
226+
auto input_fixchambers = ic.options().get<string>("fix-chamber");
227+
std::stringstream string_chambers(input_fixchambers);
228+
string_chambers >> std::ws;
229+
while (string_chambers.good()) {
230+
string substr;
231+
std::getline(string_chambers, substr, ',');
232+
LOG(info) << Form("%s%d", "Fixing chamber: ", std::stoi(substr));
233+
mAlign.FixChamber(std::stoi(substr));
233234
}
234235

235236
doMatched = ic.options().get<bool>("matched");

0 commit comments

Comments
 (0)