Skip to content

Commit 2a92e5e

Browse files
committed
Use O2LongInt aliased to long int instead of int64_t in persistent objects with pair<...>
This is to make readable on the MacOS the CCDB objects with pair<std::int64_t,...> (stored as pair<long int, ...>). A static_assert is added to ensure that the long int is at least 8 bytes long.
1 parent 4ebf849 commit 2a92e5e

File tree

9 files changed

+102
-52
lines changed

9 files changed

+102
-52
lines changed

DataFormats/Detectors/FIT/common/include/DataFormatsFIT/DCSDPValues.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,23 @@
1414

1515
#include <Rtypes.h>
1616
#include "Framework/Logger.h"
17+
#include "Framework/O2LongInt.h"
1718

1819
namespace o2
1920
{
2021
namespace fit
2122
{
2223
struct DCSDPValues {
23-
std::vector<std::pair<uint64_t, int64_t>> values;
24+
std::vector<std::pair<O2LongUInt, O2LongInt>> values;
2425

2526
DCSDPValues()
2627
{
27-
values = std::vector<std::pair<uint64_t, int64_t>>();
28+
values = std::vector<std::pair<O2LongUInt, O2LongInt>>();
2829
}
2930

3031
void add(uint64_t timestamp, int64_t value)
3132
{
32-
values.push_back(std::pair<uint64_t, int64_t>(timestamp, value));
33+
values.push_back(std::pair<O2LongUInt, O2LongInt>(timestamp, value));
3334
}
3435

3536
bool empty()
@@ -63,4 +64,4 @@ struct DCSDPValues {
6364
} // namespace fit
6465
} // namespace o2
6566

66-
#endif
67+
#endif

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

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <unordered_map>
1717
#include <deque>
1818
#include "Framework/Logger.h"
19+
#include "Framework/O2LongInt.h"
1920
#include "DetectorsDCS/DataPointCompositeObject.h"
2021
#include "DetectorsDCS/DataPointIdentifier.h"
2122
#include "DetectorsDCS/DataPointValue.h"
@@ -37,11 +38,11 @@ using DPID = o2::dcs::DataPointIdentifier;
3738
using DPVAL = o2::dcs::DataPointValue;
3839
using DPCOM = o2::dcs::DataPointCompositeObject;
3940

40-
inline unsigned long llu2lu(std::uint64_t v) { return (unsigned long)v; }
41+
inline O2LongUInt llu2lu(std::uint64_t v) { return (O2LongUInt)v; }
4142

4243
struct GRPEnvVariables {
4344

44-
std::unordered_map<std::string, std::vector<std::pair<uint64_t, double>>> mEnvVars;
45+
std::unordered_map<std::string, std::vector<std::pair<O2LongUInt, double>>> mEnvVars;
4546
size_t totalEntries() const
4647
{
4748
size_t s = 0;
@@ -60,7 +61,7 @@ struct GRPEnvVariables {
6061
}
6162
}
6263

63-
ClassDefNV(GRPEnvVariables, 1);
64+
ClassDefNV(GRPEnvVariables, 2);
6465
};
6566

6667
struct MagFieldHelper {
@@ -122,7 +123,7 @@ struct MagFieldHelper {
122123

123124
struct GRPCollimators {
124125

125-
std::unordered_map<std::string, std::vector<std::pair<uint64_t, double>>> mCollimators;
126+
std::unordered_map<std::string, std::vector<std::pair<O2LongUInt, double>>> mCollimators;
126127
size_t totalEntries() const
127128
{
128129
size_t s = 0;
@@ -141,7 +142,7 @@ struct GRPCollimators {
141142
}
142143
}
143144

144-
ClassDefNV(GRPCollimators, 1);
145+
ClassDefNV(GRPCollimators, 2);
145146
};
146147

147148
struct GRPLHCInfo {
@@ -191,19 +192,19 @@ struct GRPLHCInfo {
191192
static constexpr std::string_view lhcStringAliases[NLHCStringAliases] = {"ALI_Lumi_Source_Name", "BEAM_MODE", "MACHINE_MODE"};
192193
static constexpr int nAliasesLHC = (int)NCollimatorAliases + (int)NBeamAliases + (int)NBkgAliases + (int)NBPTXAliases + (int)NBPTXPhaseAliases + (int)NBPTXPhaseRMSAliases + (int)NBPTXPhaseShiftAliases + (int)NLumiAliases + (int)NLHCStringAliases;
193194

194-
std::array<std::vector<std::pair<uint64_t, double>>, 2> mIntensityBeam;
195-
std::array<std::vector<std::pair<uint64_t, double>>, 3> mBackground;
196-
std::vector<std::pair<uint64_t, double>> mInstLumi;
197-
std::vector<std::pair<uint64_t, double>> mBPTXdeltaT;
198-
std::vector<std::pair<uint64_t, double>> mBPTXdeltaTRMS;
199-
std::array<std::vector<std::pair<uint64_t, double>>, 2> mBPTXPhase;
200-
std::array<std::vector<std::pair<uint64_t, double>>, 2> mBPTXPhaseRMS;
201-
std::array<std::vector<std::pair<uint64_t, double>>, 2> mBPTXPhaseShift;
202-
std::pair<uint64_t, std::string> mLumiSource; // only one value per object: when there is a change, a new object is stored
203-
std::pair<uint64_t, std::string> mMachineMode; // only one value per object: when there is a change, a new object is stored
204-
std::pair<uint64_t, std::string> mBeamMode; // only one value per object: when there is a change, a new object is stored
205-
206-
void resetAndKeepLastVector(std::vector<std::pair<uint64_t, double>>& vect)
195+
std::array<std::vector<std::pair<O2LongUInt, double>>, 2> mIntensityBeam;
196+
std::array<std::vector<std::pair<O2LongUInt, double>>, 3> mBackground;
197+
std::vector<std::pair<O2LongUInt, double>> mInstLumi;
198+
std::vector<std::pair<O2LongUInt, double>> mBPTXdeltaT;
199+
std::vector<std::pair<O2LongUInt, double>> mBPTXdeltaTRMS;
200+
std::array<std::vector<std::pair<O2LongUInt, double>>, 2> mBPTXPhase;
201+
std::array<std::vector<std::pair<O2LongUInt, double>>, 2> mBPTXPhaseRMS;
202+
std::array<std::vector<std::pair<O2LongUInt, double>>, 2> mBPTXPhaseShift;
203+
std::pair<O2LongUInt, std::string> mLumiSource; // only one value per object: when there is a change, a new object is stored
204+
std::pair<O2LongUInt, std::string> mMachineMode; // only one value per object: when there is a change, a new object is stored
205+
std::pair<O2LongUInt, std::string> mBeamMode; // only one value per object: when there is a change, a new object is stored
206+
207+
void resetAndKeepLastVector(std::vector<std::pair<O2LongUInt, double>>& vect)
207208
{
208209
// always check that the size is > 0 (--> begin != end) for all vectors
209210
if (vect.begin() != vect.end()) {
@@ -291,16 +292,16 @@ class GRPDCSDPsProcessor
291292
void init(const std::vector<DPID>& pids);
292293
int process(const gsl::span<const DPCOM> dps);
293294
int processDP(const DPCOM& dpcom);
294-
uint64_t processFlags(uint64_t flag, const char* pid) { return 0; } // for now it is not really implemented
295+
O2LongUInt processFlags(O2LongUInt flag, const char* pid) { return 0; } // for now it is not really implemented
295296
bool processCollimators(const DPCOM& dpcom);
296297
bool processEnvVar(const DPCOM& dpcom);
297-
bool processPairD(const DPCOM& dpcom, const std::string& alias, std::unordered_map<std::string, std::vector<std::pair<uint64_t, double>>>& mapToUpdate);
298-
bool processPairS(const DPCOM& dpcom, const std::string& alias, std::pair<uint64_t, std::string>& p, bool& flag);
299-
bool compareToLatest(std::pair<uint64_t, double>& p, double val);
298+
bool processPairD(const DPCOM& dpcom, const std::string& alias, std::unordered_map<std::string, std::vector<std::pair<O2LongUInt, double>>>& mapToUpdate);
299+
bool processPairS(const DPCOM& dpcom, const std::string& alias, std::pair<O2LongUInt, std::string>& p, bool& flag);
300+
bool compareToLatest(std::pair<O2LongUInt, double>& p, double val);
300301
bool processLHCIFDPs(const DPCOM& dpcom);
301302

302303
void resetAndKeepLastLHCIFDPs() { mLHCInfo.resetAndKeepLast(); }
303-
void resetAndKeepLast(std::unordered_map<std::string, std::vector<std::pair<uint64_t, double>>>& mapToReset)
304+
void resetAndKeepLast(std::unordered_map<std::string, std::vector<std::pair<O2LongUInt, double>>>& mapToReset)
304305
{
305306
// keep only the latest measurement
306307
for (auto& el : mapToReset) {
@@ -366,8 +367,8 @@ class GRPDCSDPsProcessor
366367
void useVerboseMode() { mVerbose = true; }
367368
void clearVectors() { mClearVectors = true; }
368369

369-
void printVectorInfo(const std::vector<std::pair<uint64_t, double>>& vect, bool afterUpdate);
370-
void updateVector(const DPID& dpid, std::vector<std::pair<uint64_t, double>>& vect, std::string alias, uint64_t timestamp, double val);
370+
void printVectorInfo(const std::vector<std::pair<O2LongUInt, double>>& vect, bool afterUpdate);
371+
void updateVector(const DPID& dpid, std::vector<std::pair<O2LongUInt, double>>& vect, std::string alias, O2LongUInt timestamp, double val);
371372

372373
private:
373374
std::unordered_map<DPID, bool> mPids; // contains all PIDs for the processor, the bool

Detectors/GRP/calibration/src/GRPDCSDPsProcessor.cxx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ bool GRPDCSDPsProcessor::processEnvVar(const DPCOM& dpcom)
185185
}
186186

187187
//______________________________________________________________________
188-
bool GRPDCSDPsProcessor::processPairD(const DPCOM& dpcom, const std::string& alias, std::unordered_map<std::string, std::vector<std::pair<uint64_t, double>>>& mapToUpdate)
188+
bool GRPDCSDPsProcessor::processPairD(const DPCOM& dpcom, const std::string& alias, std::unordered_map<std::string, std::vector<std::pair<O2LongUInt, double>>>& mapToUpdate)
189189
{
190190

191191
// function to process Data Points that is stored in a pair
@@ -207,7 +207,7 @@ bool GRPDCSDPsProcessor::processPairD(const DPCOM& dpcom, const std::string& ali
207207
}
208208

209209
//______________________________________________________________________
210-
bool GRPDCSDPsProcessor::processPairS(const DPCOM& dpcom, const std::string& alias, std::pair<uint64_t, std::string>& p, bool& flag)
210+
bool GRPDCSDPsProcessor::processPairS(const DPCOM& dpcom, const std::string& alias, std::pair<O2LongUInt, std::string>& p, bool& flag)
211211
{
212212

213213
// function to process string Data Points that is stored in a pair
@@ -237,7 +237,7 @@ bool GRPDCSDPsProcessor::processPairS(const DPCOM& dpcom, const std::string& ali
237237

238238
//______________________________________________________________________
239239

240-
bool GRPDCSDPsProcessor::compareToLatest(std::pair<uint64_t, double>& p, double val)
240+
bool GRPDCSDPsProcessor::compareToLatest(std::pair<O2LongUInt, double>& p, double val)
241241
{
242242

243243
// check if the content of the pair should be updated
@@ -408,7 +408,7 @@ void GRPDCSDPsProcessor::updateCollimatorsCCDB()
408408

409409
//______________________________________________________________________
410410

411-
void GRPDCSDPsProcessor::printVectorInfo(const std::vector<std::pair<uint64_t, double>>& vect, bool afterUpdate)
411+
void GRPDCSDPsProcessor::printVectorInfo(const std::vector<std::pair<O2LongUInt, double>>& vect, bool afterUpdate)
412412
{
413413

414414
std::string stage = afterUpdate ? "after update" : "before update";
@@ -422,7 +422,7 @@ void GRPDCSDPsProcessor::printVectorInfo(const std::vector<std::pair<uint64_t, d
422422

423423
//______________________________________________________________________
424424

425-
void GRPDCSDPsProcessor::updateVector(const DPID& dpid, std::vector<std::pair<uint64_t, double>>& vect, std::string alias, uint64_t timestamp, double val)
425+
void GRPDCSDPsProcessor::updateVector(const DPID& dpid, std::vector<std::pair<O2LongUInt, double>>& vect, std::string alias, O2LongUInt timestamp, double val)
426426
{
427427
printVectorInfo(vect, 0);
428428
bool updateFlag = false;

Detectors/ITSMFT/MFT/condition/include/MFTCondition/MFTDCSProcessor.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "DetectorsDCS/DataPointIdentifier.h"
2323
#include "DetectorsDCS/DataPointValue.h"
2424
#include "DetectorsDCS/DeliveryType.h"
25+
#include "Framework/O2LongInt.h"
2526
#include "CCDB/CcdbObjectInfo.h"
2627
#include "CommonUtils/MemFileHelper.h"
2728
#include "CCDB/CcdbApi.h"
@@ -40,13 +41,13 @@ using DPCOM = o2::dcs::DataPointCompositeObject;
4041

4142
struct MFTDCSinfo {
4243

43-
std::pair<uint64_t, double> firstValue; // first value seen by the MFT DCS processor
44-
std::pair<uint64_t, double> lastValue; // last value seen by the MFT DCS processor
45-
std::pair<uint64_t, double> meanValue; // mean value seen by the MFT DCS processor
46-
std::pair<uint64_t, double> stddevValue; // standard deviation value seen by the MFT DCS processor
47-
std::pair<uint64_t, double> midValue; // mid value seen by the MFT DCS processor
48-
std::pair<uint64_t, double> maxChange; // maximum variation seen by the MFT DCS processor
49-
std::pair<uint64_t, double> summary; // number of entries by the MFT DCS processor
44+
std::pair<O2LongUInt, double> firstValue; // first value seen by the MFT DCS processor
45+
std::pair<O2LongUInt, double> lastValue; // last value seen by the MFT DCS processor
46+
std::pair<O2LongUInt, double> meanValue; // mean value seen by the MFT DCS processor
47+
std::pair<O2LongUInt, double> stddevValue; // standard deviation value seen by the MFT DCS processor
48+
std::pair<O2LongUInt, double> midValue; // mid value seen by the MFT DCS processor
49+
std::pair<O2LongUInt, double> maxChange; // maximum variation seen by the MFT DCS processor
50+
std::pair<O2LongUInt, double> summary; // number of entries by the MFT DCS processor
5051

5152
MFTDCSinfo()
5253
{

Detectors/TOF/calibration/include/TOFCalibration/TOFDCSProcessor.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <deque>
1919
#include <numeric>
2020
#include "Framework/Logger.h"
21+
#include "Framework/O2LongInt.h"
2122
#include "DetectorsDCS/DataPointCompositeObject.h"
2223
#include "DetectorsDCS/DataPointIdentifier.h"
2324
#include "DetectorsDCS/DataPointValue.h"
@@ -40,19 +41,19 @@ using DPVAL = o2::dcs::DataPointValue;
4041
using DPCOM = o2::dcs::DataPointCompositeObject;
4142

4243
struct TOFDCSinfo {
43-
std::pair<uint64_t, double> firstValue; // first value seen by the TOF DCS processor
44-
std::pair<uint64_t, double> lastValue; // last value seen by the TOF DCS processor
45-
std::pair<uint64_t, double> midValue; // mid value seen by the TOF DCS processor
46-
std::pair<std::array<uint64_t, 2>, double> maxChange; // maximum variation seen by the TOF DCS processor (previous - subsequent value)
47-
std::pair<uint64_t, double> minValue; // smallest measurement seen by the TOF DCS processor
48-
std::pair<uint64_t, double> maxValue; // largest measurement seen by the TOF DCS processor
44+
std::pair<O2LongUInt, double> firstValue; // first value seen by the TOF DCS processor
45+
std::pair<O2LongUInt, double> lastValue; // last value seen by the TOF DCS processor
46+
std::pair<O2LongUInt, double> midValue; // mid value seen by the TOF DCS processor
47+
std::pair<std::array<O2LongUInt, 2>, double> maxChange; // maximum variation seen by the TOF DCS processor (previous - subsequent value)
48+
std::pair<O2LongUInt, double> minValue; // smallest measurement seen by the TOF DCS processor
49+
std::pair<O2LongUInt, double> maxValue; // largest measurement seen by the TOF DCS processor
4950
bool updated = false;
5051
TOFDCSinfo()
5152
{
5253
firstValue = std::make_pair(0, -999999999);
5354
lastValue = std::make_pair(0, -999999999);
5455
midValue = std::make_pair(0, -999999999);
55-
std::array<uint64_t, 2> atmp = {0, 0};
56+
std::array<O2LongUInt, 2> atmp = {0, 0};
5657
maxChange = std::make_pair(atmp, 0);
5758
minValue = std::make_pair(0, 99999999999);
5859
maxValue = std::make_pair(0, -99999999999);

Detectors/ZDC/calib/include/ZDCCalib/ZDCDCSProcessor.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <deque>
1616
#include <numeric>
1717
#include "Framework/Logger.h"
18+
#include "Framework/O2LongInt.h"
1819
#include "DetectorsDCS/DataPointCompositeObject.h"
1920
#include "DetectorsDCS/DataPointIdentifier.h"
2021
#include "DetectorsDCS/DataPointValue.h"
@@ -39,10 +40,10 @@ using DPVAL = o2::dcs::DataPointValue;
3940
using DPCOM = o2::dcs::DataPointCompositeObject;
4041

4142
struct ZDCDCSinfo {
42-
std::pair<uint64_t, double> firstValue; // first value seen by the ZDC DCS processor
43-
std::pair<uint64_t, double> lastValue; // last value seen by the ZDC DCS processor
44-
std::pair<uint64_t, double> midValue; // mid value seen by the ZDC DCS processor
45-
std::pair<uint64_t, double> maxChange; // maximum variation seen by the ZDC DCS processor
43+
std::pair<O2LongUInt, double> firstValue; // first value seen by the ZDC DCS processor
44+
std::pair<O2LongUInt, double> lastValue; // last value seen by the ZDC DCS processor
45+
std::pair<O2LongUInt, double> midValue; // mid value seen by the ZDC DCS processor
46+
std::pair<O2LongUInt, double> maxChange; // maximum variation seen by the ZDC DCS processor
4647

4748
ZDCDCSinfo()
4849
{

Framework/Foundation/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ o2_add_library(FrameworkFoundation
1717
SOURCES src/RuntimeError.cxx
1818
src/Signpost.cxx
1919
src/BacktraceHelpers.cxx
20+
src/O2LongInt.cxx
2021
TARGETVARNAME targetName
2122
PUBLIC_LINK_LIBRARIES O2::FrameworkFoundation3rdparty
2223
)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
/*
13+
Due to the root bug https://github.com/root-project/root/issues/17216
14+
we cannot safely use std::pair<std::int64_t,...> since it is saved in the
15+
root file as long int, on the MacOS considered to be different from int64_t or
16+
UInt64_t. Thererefor, we define out own O2LongInt and make sure that it is at
17+
least 8 bytes long.
18+
*/
19+
20+
#ifndef O2_FRAMEWORK_O2LONGINT_H_
21+
#define O2_FRAMEWORK_O2LONGINT_H_
22+
23+
namespace o2
24+
{
25+
26+
static_assert(sizeof(long int) >= 8, "long int on this machine is < 8 bytes.");
27+
28+
using O2LongInt = long int;
29+
using O2LongUInt = unsigned long int;
30+
31+
} // namespace o2
32+
#endif // O2_FRAMEWORK_O2LONGINT_H_
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
#include "Framework/O2LongInt.h"

0 commit comments

Comments
 (0)