Skip to content

Commit e72eaa5

Browse files
authored
Merge branch 'AliceO2Group:dev' into dev2
2 parents c7c62a5 + 8bd9492 commit e72eaa5

42 files changed

Lines changed: 930 additions & 1203 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CCDB/include/CCDB/CcdbApi.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ class CcdbApi //: public DatabaseInterface
371371
*/
372372
void initInSnapshotMode(std::string const& snapshotpath)
373373
{
374-
mSnapshotTopPath = snapshotpath;
374+
mSnapshotTopPath = snapshotpath.empty() ? "." : snapshotpath;
375375
mInSnapshotMode = true;
376376
}
377377

@@ -510,8 +510,11 @@ class CcdbApi //: public DatabaseInterface
510510
*/
511511
void checkMetadataKeys(std::map<std::string, std::string> const& metadata) const;
512512

513-
std::string getSnapshotDir(const std::string& topdir, const string& path) const { return topdir + "/" + path; }
514-
std::string getSnapshotFile(const std::string& topdir, const string& path) const { return getSnapshotDir(topdir, path) + "/snapshot.root"; }
513+
std::string getSnapshotDir(const std::string& topdir, const std::string& path) const { return topdir + "/" + path; }
514+
std::string getSnapshotFile(const std::string& topdir, const std::string& path, const std::string& sfile = "snapshot.root") const
515+
{
516+
return getSnapshotDir(topdir, path) + '/' + sfile;
517+
}
515518

516519
/// Base URL of the CCDB (with port)
517520
std::string mUniqueAgentID{}; // Unique User-Agent ID communicated to server for logging

CCDB/src/CcdbApi.cxx

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ int CcdbApi::storeAsBinaryFile(const char* buffer, size_t size, const std::strin
187187
LOGP(alarm, "Object will not be uploaded to {} since its size {} exceeds max allowed {}", path, size, maxSize);
188188
return -1;
189189
}
190+
int returnValue = 0;
190191

191192
// Prepare URL
192193
long sanitizedStartValidityTimestamp = startValidityTimestamp;
@@ -199,11 +200,37 @@ int CcdbApi::storeAsBinaryFile(const char* buffer, size_t size, const std::strin
199200
LOGP(info, "End of Validity not set, start of validity plus 1 day used.");
200201
sanitizedEndValidityTimestamp = getFutureTimestamp(60 * 60 * 24 * 1);
201202
}
203+
if (mInSnapshotMode) { // write local file
204+
auto pthLoc = getSnapshotDir(mSnapshotTopPath, path);
205+
o2::utils::createDirectoriesIfAbsent(pthLoc);
206+
auto flLoc = getSnapshotFile(mSnapshotTopPath, path, filename);
207+
// add the timestamps to the end
208+
auto pent = flLoc.find_last_of('.');
209+
if (pent == std::string::npos) {
210+
pent = flLoc.size();
211+
}
212+
flLoc.insert(pent, fmt::format("_{}_{}", startValidityTimestamp, endValidityTimestamp));
213+
ofstream outf(flLoc.c_str(), ios::out | ios::binary);
214+
outf.write(buffer, size);
215+
outf.close();
216+
if (!outf.good()) {
217+
throw std::runtime_error(fmt::format("Failed to write local CCDB file {}", flLoc));
218+
} else {
219+
std::string metaStr{};
220+
for (const auto& mentry : metadata) {
221+
metaStr += fmt::format("{}={};", mentry.first, mentry.second);
222+
}
223+
metaStr += "$USER_META;";
224+
LOGP(info, "Created local snapshot {}", flLoc);
225+
LOGP(info, R"(Upload with: o2-ccdb-upload --host "$ccdbhost" -p {} -f {} -k {} --starttimestamp {} --endtimestamp {} -m "{}")",
226+
path, flLoc, CCDBOBJECT_ENTRY, startValidityTimestamp, endValidityTimestamp, metaStr);
227+
}
228+
return returnValue;
229+
}
202230

203231
// Curl preparation
204232
CURL* curl = nullptr;
205233
curl = curl_easy_init();
206-
int returnValue = 0;
207234

208235
// checking that all metadata keys do not contain invalid characters
209236
checkMetadataKeys(metadata);

CCDB/src/UploadTool.cxx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "CCDB/CcdbApi.h"
1313
#include "CCDB/CCDBQuery.h"
1414
#include "CCDB/CCDBTimeStampUtils.h"
15+
#include "CCDB/CcdbObjectInfo.h"
1516
#include <map>
1617
#include "TFile.h"
1718
#include "TTree.h"
@@ -163,10 +164,14 @@ int main(int argc, char* argv[])
163164
auto ti = tcl->GetTypeInfo();
164165

165166
std::cout << " Uploading an object of type " << key->GetClassName()
166-
<< " to path " << path << " with timestamp validy from " << starttimestamp
167+
<< " to path " << path << " with timestamp validity from " << starttimestamp
167168
<< " to " << endtimestamp << "\n";
168169

169170
api.storeAsTFile_impl(object, *ti, path, meta, starttimestamp, endtimestamp);
171+
if (!api.isSnapshotMode() && meta.find("adjustableEOV") != meta.end() && meta.find("default") == meta.end()) {
172+
o2::ccdb::CcdbObjectInfo oi(path, classname, filename, meta, starttimestamp, endtimestamp);
173+
o2::ccdb::adjustOverriddenEOV(api, oi);
174+
}
170175
} else {
171176
std::cerr << "Key " << keyname << " does not exist\n";
172177
}

DataFormats/Detectors/HMPID/include/DataFormatsHMP/Cluster.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ class Cluster
5050
static void fitFunc(int& iNpars, double* deriv, double& chi2, double* par, int iflag); // fit function to be used by MINUIT
5151
void coG(); // calculates center of gravity
5252
void corrSin(); // sinoidal correction
53-
void digAdd(o2::hmpid::Digit* pDig); // add new digit to the cluster
54-
o2::hmpid::Digit* dig(int i) { return mDigs.at(i); } // pointer to i-th digi
53+
void digAdd(const o2::hmpid::Digit* pDig); // add new digit to the cluster
54+
const o2::hmpid::Digit* dig(int i) const { return mDigs[i]; } // pointer to i-th digi
5555
inline bool isInPc(); // check if is in the current PC
5656
void reset(); // cleans the cluster
5757
// void setClusterParams(float xL, float yL, int iCh); //Set AliCluster3D part
@@ -110,13 +110,13 @@ class Cluster
110110
double mYY; // local y postion, [cm]
111111
double mErrY; // error on y postion, [cm]
112112
double mChi2; // some estimator of the fit quality
113-
std::vector<o2::hmpid::Digit*> mDigs; //! list of digits forming this cluster
113+
std::vector<const o2::hmpid::Digit*> mDigs; //! list of digits forming this cluster
114114

115115
public:
116116
static bool fgDoCorrSin; // flag to switch on/off correction for Sinusoidal to cluster reco
117117
Param* mParam; //! Pointer to AliHMPIDParam
118118

119-
ClassDefNV(Cluster, 2);
119+
ClassDefNV(Cluster, 3);
120120
};
121121

122122
} // namespace hmpid

DataFormats/Detectors/HMPID/src/Cluster.cxx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ void Cluster::print(Option_t* opt) const
304304
if (mDigs.size() > 0) {
305305
std::cout << "Digits of Cluster" << std::endl;
306306
for (int i; i < mDigs.size(); i++) {
307-
std::cout << mDigs.at(i) << std::endl;
307+
std::cout << mDigs[i] << std::endl;
308308
}
309309
}
310310
return;
@@ -352,13 +352,13 @@ int Cluster::solve(std::vector<o2::hmpid::Cluster>* pCluLst, float* pSigmaCut, b
352352
// Phase 1. Find number of local maxima. Strategy is to check if the current pad has QDC more then all neigbours. Also find the box contaning the cluster
353353
mNlocMax = 0;
354354
for (int iDig1 = 0; iDig1 < rawSize; iDig1++) { // first digits loop
355-
o2::hmpid::Digit* pDig1 = mDigs.at(iDig1); // take next digit
355+
auto pDig1 = mDigs.at(iDig1); // take next digit
356356
int iCnt = 0; // counts how many neighbouring pads has QDC more then current one
357357
for (int iDig2 = 0; iDig2 < rawSize; iDig2++) { // loop on all digits again
358358
if (iDig1 == iDig2) {
359359
continue;
360360
} // the same digit, no need to compare
361-
o2::hmpid::Digit* pDig2 = mDigs.at(iDig2); // take second digit to compare with the first one
361+
auto pDig2 = mDigs.at(iDig2); // take second digit to compare with the first one
362362
int dist = TMath::Sign(int(pDig1->mX - pDig2->mX), 1) + TMath::Sign(int(pDig1->mY - pDig2->mY), 1); // distance between pads
363363
if (dist == 1) { // means dig2 is a neighbour of dig1
364364
if (pDig2->mQ >= pDig1->mQ) {
@@ -462,7 +462,7 @@ void Cluster::findClusterSize(int i, float* pSigmaCut)
462462
{
463463
int size = 0;
464464
for (int iDig = 0; iDig < mSi; iDig++) { // digits loop
465-
o2::hmpid::Digit* pDig = dig(iDig); // take digit
465+
auto pDig = dig(iDig); // take digit
466466
int iCh = pDig->mCh;
467467
double qPad = mQ * o2::hmpid::Digit::intMathieson(x(), y(), pDig->getPadID()); // pad charge pDig->
468468
// AliDebug(1,Form("Chamber %i X %i Y %i SigmaCut %i pad %i qpadMath %8.2f qPadRaw %8.2f Qtotal %8.2f cluster n.%i",
@@ -483,7 +483,7 @@ Bool_t Cluster::isInPc()
483483
// Check if (X,Y) position is inside the PC limits
484484
// Arguments:
485485
// Returns: True or False
486-
int pc = ((o2::hmpid::Digit*)&mDigs.at(0))->getPh(); // (o2::hmpid::Digit*)&mDigs.at(iDig)
486+
int pc = mDigs[0]->getPh(); // (o2::hmpid::Digit*)&mDigs.at(iDig)
487487

488488
if (mXX < Param::minPcX(pc) || mXX > Param::maxPcX(pc) || mYY < Param::minPcY(pc) || mYY > Param::maxPcY(pc)) {
489489
return false;
@@ -492,7 +492,7 @@ Bool_t Cluster::isInPc()
492492
return true;
493493
}
494494
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
495-
void Cluster::digAdd(Digit* pDig)
495+
void Cluster::digAdd(const Digit* pDig)
496496
{
497497
// Adds a given digit to the list of digits belonging to this cluster, cluster is not owner of digits
498498
// Arguments: pDig - pointer to digit to be added

DataFormats/Parameters/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ o2_add_library(DataFormatsParameters
1919
O2::DetectorsCommonDataFormats O2::SimConfig)
2020

2121
o2_target_root_dictionary(DataFormatsParameters
22-
HEADERS include/DataFormatsParameters/GRPObject.h
22+
HEADERS include/DataFormatsParameters/ECSDataAdapters.h
23+
include/DataFormatsParameters/GRPObject.h
2324
include/DataFormatsParameters/GRPLHCIFData.h
2425
include/DataFormatsParameters/GRPECSObject.h
2526
include/DataFormatsParameters/GRPMagField.h
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
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+
/// \file ECSDataAdapter
13+
/// \brief Header only, adapter methods without external dependencies
14+
/// \author ruben.shahoyan@cern.ch, gvozden.neskovic@cern.ch
15+
16+
#ifndef ALICEO2_ECSADAPTERS_H_
17+
#define ALICEO2_ECSADAPTERS_H_
18+
19+
// NOTE: please only stdlib includes here!
20+
#include <string>
21+
#include <string_view>
22+
#include <array>
23+
24+
namespace o2
25+
{
26+
namespace parameters
27+
{
28+
29+
namespace GRPECS
30+
{
31+
32+
enum RunType : int {
33+
NONE,
34+
PHYSICS,
35+
TECHNICAL,
36+
PEDESTAL,
37+
PULSER,
38+
LASER,
39+
CALIBRATION_ITHR_TUNING,
40+
CALIBRATION_VCASN_TUNING,
41+
CALIBRATION_THR_SCAN,
42+
CALIBRATION_DIGITAL_SCAN,
43+
CALIBRATION_ANALOG_SCAN,
44+
CALIBRATION_FHR,
45+
CALIBRATION_ALPIDE_SCAN,
46+
CALIBRATION,
47+
COSMICS,
48+
SYNTHETIC,
49+
NRUNTYPES
50+
};
51+
static constexpr std::array<std::string_view, NRUNTYPES> RunTypeNames = {
52+
"NONE",
53+
"PHYSICS",
54+
"TECHNICAL",
55+
"PEDESTAL",
56+
"PULSER",
57+
"LASER",
58+
"CALIBRATION_ITHR_TUNING",
59+
"CALIBRATION_VCASN_TUNING",
60+
"CALIBRATION_THR_SCAN",
61+
"CALIBRATION_DIGITAL_SCAN",
62+
"CALIBRATION_ANALOG_SCAN",
63+
"CALIBRATION_FHR",
64+
"CALIBRATION_ALPIDE_SCAN",
65+
"CALIBRATION",
66+
"COSMICS",
67+
"SYNTHETIC"};
68+
69+
//_______________________________________________
70+
static RunType string2RunType(const std::string& rts)
71+
{
72+
int rt = -1;
73+
for (int i = 0; i < int(RunType::NRUNTYPES); i++) {
74+
if (rts == RunTypeNames[i]) {
75+
rt = i;
76+
break;
77+
}
78+
}
79+
return RunType(rt);
80+
}
81+
82+
//_______________________________________________
83+
static std::string getRawDataPersistencyMode(const std::string& runType, bool imposeRaw = false)
84+
{
85+
if (imposeRaw) {
86+
return "raw";
87+
}
88+
std::string ret = "other";
89+
auto rt = string2RunType(runType);
90+
switch (rt) {
91+
case RunType::PHYSICS:
92+
case RunType::COSMICS:
93+
ret = "raw";
94+
break;
95+
case RunType::PEDESTAL:
96+
case RunType::PULSER:
97+
case RunType::LASER:
98+
case RunType::CALIBRATION_ITHR_TUNING:
99+
case RunType::CALIBRATION_VCASN_TUNING:
100+
case RunType::CALIBRATION_THR_SCAN:
101+
case RunType::CALIBRATION_DIGITAL_SCAN:
102+
case RunType::CALIBRATION_ANALOG_SCAN:
103+
case RunType::CALIBRATION_FHR:
104+
case RunType::CALIBRATION_ALPIDE_SCAN:
105+
case RunType::CALIBRATION:
106+
ret = "calib";
107+
default:
108+
break;
109+
}
110+
return ret;
111+
}
112+
113+
} // namespace GRPECS
114+
} // namespace parameters
115+
} // namespace o2
116+
117+
#endif

DataFormats/Parameters/include/DataFormatsParameters/GRPECSObject.h

Lines changed: 9 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <Rtypes.h>
2020
#include <cstdint>
2121
#include <ctime>
22+
#include "DataFormatsParameters/ECSDataAdapters.h"
2223
#include "DetectorsCommonDataFormats/DetID.h"
2324

2425
namespace o2
@@ -35,48 +36,12 @@ class GRPECSObject
3536

3637
public:
3738
using timePoint = uint64_t;
39+
using RunType = o2::parameters::GRPECS::RunType;
3840

3941
enum ROMode : int { ABSENT = 0,
4042
PRESENT = 0x1,
4143
CONTINUOUS = PRESENT + (0x1 << 1),
4244
TRIGGERING = PRESENT + (0x1 << 2) };
43-
enum RunType : int {
44-
NONE,
45-
PHYSICS,
46-
TECHNICAL,
47-
PEDESTAL,
48-
PULSER,
49-
LASER,
50-
CALIBRATION_ITHR_TUNING,
51-
CALIBRATION_VCASN_TUNING,
52-
CALIBRATION_THR_SCAN,
53-
CALIBRATION_DIGITAL_SCAN,
54-
CALIBRATION_ANALOG_SCAN,
55-
CALIBRATION_FHR,
56-
CALIBRATION_ALPIDE_SCAN,
57-
CALIBRATION,
58-
COSMICS,
59-
SYNTHETIC,
60-
NRUNTYPES
61-
};
62-
static constexpr std::array<std::string_view, NRUNTYPES> RunTypeNames = {
63-
"NONE",
64-
"PHYSICS",
65-
"TECHNICAL",
66-
"PEDESTAL",
67-
"PULSER",
68-
"LASER",
69-
"CALIBRATION_ITHR_TUNING",
70-
"CALIBRATION_VCASN_TUNING",
71-
"CALIBRATION_THR_SCAN",
72-
"CALIBRATION_DIGITAL_SCAN",
73-
"CALIBRATION_ANALOG_SCAN",
74-
"CALIBRATION_FHR",
75-
"CALIBRATION_ALPIDE_SCAN",
76-
"CALIBRATION",
77-
"COSMICS",
78-
"SYNTHETIC"};
79-
8045
GRPECSObject() = default;
8146
~GRPECSObject() = default;
8247

@@ -149,22 +114,20 @@ class GRPECSObject
149114

150115
static GRPECSObject* loadFrom(const std::string& grpecsFileName = "");
151116
static constexpr bool alwaysTriggeredRO(DetID::ID det) { return DefTriggeredDets[det]; }
152-
static RunType string2RunType(const std::string& rts);
153-
static std::string getRawDataPersistencyMode(const std::string& runType, bool imposeRaw = false);
154117

155118
private:
156119
timePoint mTimeStart = 0; ///< DAQ_time_start entry from DAQ logbook
157120
timePoint mTimeEnd = 0; ///< DAQ_time_end entry from DAQ logbook
158121

159122
uint32_t mNHBFPerTF = 128; /// Number of HBFrames per TF
160123

161-
DetID::mask_t mDetsReadout; ///< mask of detectors which are read out
162-
DetID::mask_t mDetsContinuousRO; ///< mask of detectors read out in continuos mode
163-
DetID::mask_t mDetsTrigger; ///< mask of detectors which provide trigger input to CTP
164-
bool mIsMC = false; ///< flag GRP for MC
165-
int mRun = 0; ///< run identifier
166-
RunType mRunType = NONE; ///< run type
167-
std::string mDataPeriod{}; ///< name of the period
124+
DetID::mask_t mDetsReadout; ///< mask of detectors which are read out
125+
DetID::mask_t mDetsContinuousRO; ///< mask of detectors read out in continuos mode
126+
DetID::mask_t mDetsTrigger; ///< mask of detectors which provide trigger input to CTP
127+
bool mIsMC = false; ///< flag GRP for MC
128+
int mRun = 0; ///< run identifier
129+
RunType mRunType = RunType::NONE; ///< run type
130+
std::string mDataPeriod{}; ///< name of the period
168131

169132
// detectors which are always readout in triggered mode. Others are continuous by default but exceptionally can be triggered
170133
static constexpr DetID::mask_t DefTriggeredDets = DetID::getMask(DetID::TRD) | DetID::getMask(DetID::PHS) | DetID::getMask(DetID::CPV) | DetID::getMask(DetID::EMC) | DetID::getMask(DetID::HMP);

0 commit comments

Comments
 (0)