Skip to content

Commit dcb6e10

Browse files
committed
Fixes for LHCIF -> GRPLHCIFData processing
1 parent 4e31171 commit dcb6e10

2 files changed

Lines changed: 56 additions & 43 deletions

File tree

Detectors/GRP/calibration/include/GRPCalibration/LHCIFfileReader.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ void LHCIFfileReader::readValue(const std::string& alias, std::string& type, int
5858
}
5959
std::string subStr = mFileBuffStr.substr(posStart, posEnd - posStart);
6060
LOG(debug) << "subStr = " << subStr;
61-
auto tokensStr = o2::utils::Str::tokenize(subStr, '\t');
61+
auto tokensStr = o2::utils::Str::tokenize(subStr, '\t', true, false);
6262
LOG(debug) << "size of tokensStr = " << tokensStr.size();
6363
if (tokensStr.size() < 5) {
6464
LOG(fatal) << "Number of tokens too small: " << tokensStr.size() << ", should be at 5 (alias, type, nelements, value(s), timestamp(s)";
6565
}
66-
auto tokensStr_type = o2::utils::Str::tokenize(tokensStr[1], ':');
66+
auto tokensStr_type = o2::utils::Str::tokenize(tokensStr[1], ':', true, false);
6767
LOG(debug) << "size of tokensStr_type = " << tokensStr_type.size();
6868

6969
type = tokensStr_type[0];
@@ -73,9 +73,11 @@ void LHCIFfileReader::readValue(const std::string& alias, std::string& type, int
7373
nmeas = std::stoi(tokensStr[2]); // number of measurements
7474
LOG(debug) << "nele = " << nele << ", nmeas = " << nmeas;
7575
int shift = 3; // number of tokens that are not measurments (alias, type, number of measurements)
76-
if ((tokensStr.size() - shift) != (nele + 1) * nmeas) { // +1 to account for the timestamp
77-
LOG(fatal) << "Wrong number of pairs (value(s), timestamp): " << tokensStr.size() - 3 << ", should be " << (nele + 1) * nmeas;
78-
}
76+
77+
// RS: this check is wrong: the provided pair might be simply empty, but they are requested by the check above (Number of tokens too small...)
78+
// if ((tokensStr.size() - shift) != (nele + 1) * nmeas) { // +1 to account for the timestamp
79+
// LOG(fatal) << "Wrong number of pairs (value(s), timestamp): " << tokensStr.size() - 3 << ", should be " << (nele + 1) * nmeas;
80+
// }
7981
meas.reserve(nmeas);
8082

8183
for (int idx = 0; idx < nmeas; ++idx) {

Detectors/GRP/workflows/src/GRPLHCIFfileSpec.cxx

Lines changed: 49 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -67,89 +67,100 @@ void GRPLHCIFfileProcessor::run(o2::framework::ProcessingContext& pc)
6767
// Beam Energy
6868
mReader.readValue<int32_t>("BEAM_ENERGY", type, nEle, nMeas, beamEnergy);
6969
if (nMeas == 0) {
70-
LOG(fatal) << "Beam energy not present";
70+
LOG(warn) << "Beam energy not present/empty"; // RS: in absence of the beam it is empty, don't produce an error
7171
}
72-
if (nEle != 1 || nMeas != 1) {
73-
LOG(error) << "More than one value/measurement found for Beam Energy, keeping the last one";
72+
if (nEle > 1 || nMeas > 1) {
73+
LOGP(warn, "More than one value/measurement {}/{} found for Beam Energy, keeping the last one", nEle, nMeas);
74+
}
75+
if (!beamEnergy.empty()) {
76+
lhcifdata.setBeamEnergyPerZWithTime(beamEnergy.back().first, beamEnergy.back().second.back());
7477
}
75-
LOG(info) << "beam energy size = " << beamEnergy.size();
76-
lhcifdata.setBeamEnergyPerZWithTime(beamEnergy.back().first, beamEnergy.back().second.back());
77-
7878
// Injection scheme
7979
mReader.readValue<std::string>("INJECTION_SCHEME", type, nEle, nMeas, injScheme);
8080
if (nMeas == 0) {
81-
LOG(fatal) << "Injection scheme not present";
81+
LOG(warn) << "Injection scheme not present/empty"; // RS: same comment
82+
}
83+
if (nEle > 1 || nMeas > 1) {
84+
LOGP(warn, "More than one value/measurement {}/{} found for Injection Scheme, keeping the last one", nEle, nMeas);
8285
}
83-
if (nEle != 1 || nMeas != 1) {
84-
LOG(error) << "More than one value/measurement found for Injection Scheme, keeping the last one";
86+
if (!injScheme.empty()) {
87+
lhcifdata.setInjectionSchemeWithTime(injScheme.back().first, injScheme.back().second.back());
8588
}
86-
lhcifdata.setInjectionSchemeWithTime(injScheme.back().first, injScheme.back().second.back());
8789

8890
// fill number
8991
mReader.readValue<std::string>("FILL_NUMBER", type, nEle, nMeas, fillNb);
9092
if (nMeas == 0) {
91-
LOG(fatal) << "Fill Number not present";
93+
LOG(warn) << "Fill Number not present/empty";
9294
}
93-
if (nEle != 1 || nMeas != 1) {
94-
LOG(error) << "More than one value/measurement found for Fill Number, keeping the last one";
95+
if (nEle > 1 || nMeas > 1) {
96+
LOG(warn) << "More than one value/measurement found for Fill Number, keeping the last one";
97+
}
98+
if (!fillNb.empty()) {
99+
lhcifdata.setFillNumberWithTime(fillNb.back().first, atoi(fillNb.back().second.back().c_str()));
95100
}
96-
lhcifdata.setFillNumberWithTime(fillNb.back().first, atoi(fillNb.back().second.back().c_str()));
97101

98102
// Atomic Number (Z) for B1
99103
mReader.readValue<int32_t>("ATOMIC_NUMBER_B1", type, nEle, nMeas, atomicNbB1);
100104
if (nMeas == 0) {
101-
LOG(fatal) << "Atomic Number Beam 1 (clockwise) not present";
105+
LOG(warn) << "Atomic Number Beam 1 (clockwise) not present/empty"; // RS same comment
106+
}
107+
if (nEle > 1 || nMeas > 1) {
108+
LOGP(warn, "More than one value/measurement {}/{} found for Atomic Number Beam 1 (clockwise), keeping the last one", nEle, nMeas);
102109
}
103-
if (nEle != 1 || nMeas != 1) {
104-
LOG(error) << "More than one value/measurement found for Atomic Number Beam 1 (clockwise), keeping the last one";
110+
if (!atomicNbB1.empty()) {
111+
lhcifdata.setAtomicNumberB1WithTime(atomicNbB1.back().first, atomicNbB1.back().second.back());
105112
}
106-
lhcifdata.setAtomicNumberB1WithTime(atomicNbB1.back().first, atomicNbB1.back().second.back());
107113

108114
// Atomic Number (Z) for B2
109115
mReader.readValue<int32_t>("ATOMIC_NUMBER_B2", type, nEle, nMeas, atomicNbB2);
110116
if (nMeas == 0) {
111-
LOG(fatal) << "Atomic Number Beam 2 (anticlockwise) not present";
117+
LOG(warn) << "Atomic Number Beam 2 (anticlockwise) not present/empty";
112118
}
113-
if (nEle != 1 || nMeas != 1) {
114-
LOG(error) << "More than one value/measurement found for Atomic Number Beam 2 (anticlockwise), keeping the last one";
119+
if (nEle > 1 || nMeas > 1) {
120+
LOGP(warn, "More than one value/measurement {}/{} found for Atomic Number Beam 2 (anticlockwise), keeping the last one", nEle, nMeas);
121+
}
122+
if (!atomicNbB2.empty()) {
123+
lhcifdata.setAtomicNumberB2WithTime(atomicNbB2.back().first, atomicNbB2.back().second.back());
115124
}
116-
lhcifdata.setAtomicNumberB2WithTime(atomicNbB2.back().first, atomicNbB2.back().second.back());
117125

118126
// Crossing Angle
119127
mReader.readValue<float>("IP2_XING_V_MURAD", type, nEle, nMeas, crossAngle);
120128
if (nMeas == 0) {
121-
LOG(fatal) << "Crossing Angle not present";
129+
LOG(warn) << "Crossing Angle not present/empty";
130+
}
131+
if (nEle > 1 || nMeas > 1) {
132+
LOGP(warn, "More than one value/measurement {}/{} found for Crossing Angle, keeping the last one", nEle, nMeas);
122133
}
123-
if (nEle != 1 || nMeas != 1) {
124-
LOG(error) << "More than one value/measurement found for Crossing Angle, keeping the last one";
134+
if (!crossAngle.empty()) {
135+
lhcifdata.setCrossingAngleWithTime(crossAngle.back().first, crossAngle.back().second.back());
125136
}
126-
lhcifdata.setCrossingAngleWithTime(crossAngle.back().first, crossAngle.back().second.back());
127137

128138
// Bunch Config for B1
129139
mReader.readValue<int>("CIRCULATING_BUNCH_CONFIG_BEAM1", type, nEle, nMeas, bunchConfigB1);
130140
if (nMeas == 0) {
131-
LOG(fatal) << "Bunch Config Beam 1 not present";
141+
LOG(warn) << "Bunch Config Beam 1 not present/empty";
132142
}
133-
if (nMeas != 1) {
134-
LOG(error) << "More than one value/measurement found for Bunch Config Beam 1, keeping the last one";
143+
if (nMeas > 1) {
144+
LOGP(warn, "More than one measurement {} found for Bunch Config Beam 1, keeping the last one", nMeas);
135145
}
136146

137147
// Bunch Config for B2
138148
mReader.readValue<int>("CIRCULATING_BUNCH_CONFIG_BEAM2", type, nEle, nMeas, bunchConfigB2);
139149
if (nMeas == 0) {
140-
LOG(fatal) << "Bunch Config Beam 2 not present";
150+
LOG(warn) << "Bunch Config Beam 2 not present/empty";
141151
}
142-
if (nMeas != 1) {
143-
LOG(error) << "More than one value/measurement found for Bunch Config Beam 2, keeping the last one";
152+
if (nMeas > 1) {
153+
LOGP(warn, "More than one measurement {} found for Bunch Config Beam 2, keeping the last one", nMeas);
144154
}
145155

146156
// Building Bunch Filling
147-
o2::BunchFilling bunchFilling;
148-
bunchFilling.buckets2BeamPattern(bunchConfigB1.back().second, 0);
149-
bunchFilling.buckets2BeamPattern(bunchConfigB2.back().second, 1);
150-
bunchFilling.setInteractingBCsFromBeams();
151-
152-
lhcifdata.setBunchFillingWithTime((bunchConfigB1.back().first + bunchConfigB2.back().first) / 2, bunchFilling);
157+
if (!bunchConfigB1.empty() && !bunchConfigB2.empty()) {
158+
o2::BunchFilling bunchFilling;
159+
bunchFilling.buckets2BeamPattern(bunchConfigB1.back().second, 0);
160+
bunchFilling.buckets2BeamPattern(bunchConfigB2.back().second, 1);
161+
bunchFilling.setInteractingBCsFromBeams();
162+
lhcifdata.setBunchFillingWithTime((bunchConfigB1.back().first + bunchConfigB2.back().first) / 2, bunchFilling);
163+
}
153164

154165
if (mVerbose) {
155166
LOG(info) << " **** Beam Energy ****";

0 commit comments

Comments
 (0)