Skip to content

Commit ce5b9b4

Browse files
committed
Merge branch 'dev' into cholmcc_aod_producers_refactor
2 parents a43300e + 6cc46bd commit ce5b9b4

168 files changed

Lines changed: 2842 additions & 2040 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.

Algorithm/include/Algorithm/PageParser.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,12 +255,12 @@ class PageParser
255255
return mElement;
256256
}
257257
// comparison
258-
bool operator==(const SelfType& rh)
258+
bool operator==(const SelfType& rh) const
259259
{
260260
return mPosition == rh.mPosition;
261261
}
262262
// comparison
263-
bool operator!=(const SelfType& rh)
263+
bool operator!=(const SelfType& rh) const
264264
{
265265
return mPosition != rh.mPosition;
266266
}

CCDB/include/CCDB/CCDBDownloader.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ typedef struct DownloaderRequestData {
5151
long timestamp;
5252
HeaderObjectPair_t hoPair;
5353
std::map<std::string, std::string>* headers;
54+
std::string userAgent;
5455

5556
std::function<bool(std::string)> localContentCallback;
5657
bool errorflag = false;
@@ -208,12 +209,17 @@ class CCDBDownloader
208209
*/
209210
void runLoop(bool noWait);
210211

211-
private:
212+
/**
213+
* Returns a message describing the transfer an it's result.
214+
*/
215+
std::string prepareLogMessage(std::string host_url, std::string userAgent, const std::string& path, long ts, const std::map<std::string, std::string>* headers, long httpCode) const;
216+
212217
/**
213218
* Leaves only the protocol and host part of the url, discrading path and metadata.
214219
*/
215220
std::string trimHostUrl(std::string full_host_url) const;
216221

222+
private:
217223
/**
218224
* Recognizes whether the address is a full url, or a partial one (like for example "/Task/Detector/1") and combines it with potentialHost if needed.
219225
*/

CCDB/include/CCDB/CcdbApi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ class CcdbApi //: public DatabaseInterface
373373
void scheduleDownload(RequestContext& requestContext, size_t* requestCounter) const;
374374

375375
void getFromSnapshot(bool createSnapshot, std::string const& path,
376-
long timestamp, std::map<std::string, std::string> headers,
376+
long timestamp, std::map<std::string, std::string>& headers,
377377
std::string& snapshotpath, o2::pmr::vector<char>& dest, int& fromSnapshot, std::string const& etag) const;
378378
void releaseNamedSemaphore(boost::interprocess::named_semaphore* sem, std::string path) const;
379379
boost::interprocess::named_semaphore* createNamedSempahore(std::string path) const;

CCDB/src/CCDBDownloader.cxx

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ std::string CCDBDownloader::trimHostUrl(std::string full_host_url) const
408408
char* host;
409409
CURLUcode host_result = curl_url_get(host_url, CURLUPART_HOST, &host, 0);
410410
if (host_result != CURLUE_OK) {
411-
LOG(error) << "CCDBDownloader: Malformed url detected when processing redirect, could not identify the host part: " << host;
411+
LOG(error) << "CCDBDownloader: Malformed url detected when processing redirect, could not identify the host part: " << full_host_url;
412412
curl_url_cleanup(host_url);
413413
return "";
414414
}
@@ -493,21 +493,25 @@ void CCDBDownloader::transferFinished(CURL* easy_handle, CURLcode curlCode)
493493
curl_easy_getinfo(easy_handle, CURLINFO_EFFECTIVE_URL, &url);
494494
LOG(debug) << "Transfer for " << url << " finished with code " << httpCode << "\n";
495495

496+
std::string currentHost = requestData->hosts[performData->hostInd];
497+
std::string loggingMessage = prepareLogMessage(currentHost, requestData->userAgent, requestData->path, requestData->timestamp, requestData->headers, httpCode);
498+
496499
// Get alternative locations for the same host
497500
auto locations = getLocations(&(requestData->hoPair.header));
498501

499502
// React to received http code
500-
if (404 == httpCode) {
501-
LOG(error) << "Requested resource does not exist: " << url;
502-
} else if (304 == httpCode) {
503-
LOGP(debug, "Object exists but I am not serving it since it's already in your possession");
504-
contentRetrieved = true;
505-
} else if (300 <= httpCode && httpCode < 400 && performData->locInd < locations.size()) {
506-
followRedirect(performData, easy_handle, locations, rescheduled, contentRetrieved);
507-
} else if (200 <= httpCode && httpCode < 300) {
508-
contentRetrieved = true;
503+
if (200 <= httpCode && httpCode < 400) {
504+
LOG(debug) << loggingMessage;
505+
if (304 == httpCode) {
506+
LOGP(debug, "Object exists but I am not serving it since it's already in your possession");
507+
contentRetrieved = true;
508+
} else if (300 <= httpCode && httpCode < 400 && performData->locInd < locations.size()) {
509+
followRedirect(performData, easy_handle, locations, rescheduled, contentRetrieved);
510+
} else if (200 <= httpCode && httpCode < 300) {
511+
contentRetrieved = true;
512+
}
509513
} else {
510-
LOG(error) << "Error in fetching object " << url << ", curl response code:" << httpCode;
514+
LOG(error) << loggingMessage;
511515
}
512516

513517
// Check if content was retrieved, or scheduled to be retrieved
@@ -694,4 +698,21 @@ void CCDBDownloader::asynchSchedule(CURL* handle, size_t* requestCounter)
694698
// return codeVector;
695699
}
696700

701+
std::string CCDBDownloader::prepareLogMessage(std::string host_url, std::string userAgent, const std::string& path, long ts, const std::map<std::string, std::string>* headers, long httpCode) const
702+
{
703+
std::string upath{path};
704+
if (headers) {
705+
auto ent = headers->find("Valid-From");
706+
if (ent != headers->end()) {
707+
upath += "/" + ent->second;
708+
}
709+
ent = headers->find("ETag");
710+
if (ent != headers->end()) {
711+
upath += "/" + ent->second;
712+
}
713+
}
714+
upath.erase(remove(upath.begin(), upath.end(), '\"'), upath.end());
715+
return fmt::format("CcdbDownloader finished transfer {}{}{} for {} (agent_id: {}) with http code: {}", host_url, (host_url.back() == '/') ? "" : "/", upath, (ts < 0) ? getCurrentTimestamp() : ts, userAgent, httpCode);
716+
}
717+
697718
} // namespace o2

CCDB/src/CcdbApi.cxx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,6 +1533,7 @@ void CcdbApi::scheduleDownload(RequestContext& requestContext, size_t* requestCo
15331533
data->path = requestContext.path;
15341534
data->timestamp = requestContext.timestamp;
15351535
data->localContentCallback = localContentCallback;
1536+
data->userAgent = mUniqueAgentID;
15361537

15371538
curl_easy_setopt(curl_handle, CURLOPT_URL, fullUrl.c_str());
15381539
initCurlOptionsForRetrieve(curl_handle, (void*)(&data->hoPair), writeCallback, false);
@@ -1570,7 +1571,7 @@ void CcdbApi::releaseNamedSemaphore(boost::interprocess::named_semaphore* sem, s
15701571
}
15711572

15721573
void CcdbApi::getFromSnapshot(bool createSnapshot, std::string const& path,
1573-
long timestamp, std::map<std::string, std::string> headers,
1574+
long timestamp, std::map<std::string, std::string>& headers,
15741575
std::string& snapshotpath, o2::pmr::vector<char>& dest, int& fromSnapshot, std::string const& etag) const
15751576
{
15761577
if (createSnapshot) { // create named semaphore
@@ -1580,9 +1581,10 @@ void CcdbApi::getFromSnapshot(bool createSnapshot, std::string const& path,
15801581
logStream << "CCDB-access[" << getpid() << "] of " << mUniqueAgentID << " to " << path << " timestamp " << timestamp << " for load to memory\n";
15811582
}
15821583
}
1583-
15841584
if (mInSnapshotMode) { // file must be there, otherwise a fatal will be produced;
1585-
loadFileToMemory(dest, getSnapshotFile(mSnapshotTopPath, path), &headers);
1585+
if (etag.empty()) {
1586+
loadFileToMemory(dest, getSnapshotFile(mSnapshotTopPath, path), &headers);
1587+
}
15861588
fromSnapshot = 1;
15871589
} else if (mPreferSnapshotCache && std::filesystem::exists(snapshotpath)) {
15881590
// if file is available, use it, otherwise cache it below from the server. Do this only when etag is empty since otherwise the object was already fetched and cached
@@ -1671,8 +1673,6 @@ void CcdbApi::vectoredLoadFileToMemory(std::vector<RequestContext>& requestConte
16711673
// navigateSourcesAndLoadFile either retrieves file from snapshot immediately, or schedules it to be downloaded when mDownloader->runLoop is ran at a later time
16721674
auto& requestContext = requestContexts.at(i);
16731675
navigateSourcesAndLoadFile(requestContext, fromSnapshots.at(i), &requestCounter);
1674-
logReading(requestContext.path, requestContext.timestamp, &requestContext.headers,
1675-
fmt::format("{}{}", requestContext.considerSnapshot ? "load to memory" : "retrieve", fromSnapshots.at(i) ? " from snapshot" : ""));
16761676
}
16771677

16781678
// Download the rest
@@ -1683,12 +1683,12 @@ void CcdbApi::vectoredLoadFileToMemory(std::vector<RequestContext>& requestConte
16831683
// Save snapshots
16841684
for (int i = 0; i < requestContexts.size(); i++) {
16851685
auto& requestContext = requestContexts.at(i);
1686+
logReading(requestContext.path, requestContext.timestamp, &requestContext.headers,
1687+
fmt::format("{}{}", requestContext.considerSnapshot ? "load to memory" : "retrieve", fromSnapshots.at(i) ? " from snapshot" : ""));
16861688
if (!requestContext.dest.empty()) {
16871689
if (requestContext.considerSnapshot && fromSnapshots.at(i) != 2) {
16881690
saveSnapshot(requestContext);
16891691
}
1690-
} else {
1691-
LOG(warning) << "Did not receive content for " << requestContext.path << "\n"; // Temporarily demoted to warning, since it floods the infologger
16921692
}
16931693
}
16941694
}

CCDB/test/testCcdbApiDownloader.cxx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,5 +381,15 @@ BOOST_AUTO_TEST_CASE(external_loop_test)
381381
delete uvLoop;
382382
}
383383

384+
BOOST_AUTO_TEST_CASE(trim_host_url_test)
385+
{
386+
CCDBDownloader downloader;
387+
BOOST_CHECK(downloader.trimHostUrl("http://localhost:8080") == "http://localhost:8080");
388+
BOOST_CHECK(downloader.trimHostUrl("http://localhost") == "http://localhost");
389+
BOOST_CHECK(downloader.trimHostUrl("http://localhost:8080/some/path") == "http://localhost:8080");
390+
BOOST_CHECK(downloader.trimHostUrl("http://localhost/some/path") == "http://localhost");
391+
BOOST_CHECK(downloader.trimHostUrl("http://localhost:8080/Task/Detector/1?HTTPOnly=true") == "http://localhost:8080");
392+
}
393+
384394
} // namespace ccdb
385395
} // namespace o2

Common/Constants/include/CommonConstants/PhysicsConstants.h

Lines changed: 153 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,40 +12,167 @@
1212
/// \file PhysicsConstants.h
1313
/// \brief Header to collect physics constants
1414
/// \author ruben.shahoyan@cern.ch
15+
/// \author Vít Kučera <vit.kucera@cern.ch>, Inha University
16+
/// \note Use the make_pdg_header.py script to generate the enums and mass declarations.
1517

1618
#ifndef ALICEO2_PHYSICSCONSTANTS_H_
1719
#define ALICEO2_PHYSICSCONSTANTS_H_
1820

19-
namespace o2
20-
{
21-
namespace constants
22-
{
23-
namespace physics
21+
namespace o2::constants::physics
2422
{
2523
// particles masses
26-
constexpr float MassPhoton = 0.0;
27-
constexpr float MassElectron = 0.000511;
28-
constexpr float MassMuon = 0.105658;
29-
constexpr float MassPionCharged = 0.139570;
30-
constexpr float MassPionNeutral = 0.134976;
31-
constexpr float MassKaonCharged = 0.493677;
32-
constexpr float MassKaonNeutral = 0.497648;
33-
constexpr float MassProton = 0.938272;
34-
constexpr float MassLambda = 1.115683;
35-
constexpr float MassDeuteron = 1.8756129;
36-
constexpr float MassTriton = 2.8089211;
37-
constexpr float MassHelium3 = 2.8083916;
38-
constexpr float MassAlpha = 3.7273794;
39-
constexpr float MassHyperTriton = 2.992;
40-
constexpr float MassHyperhydrog4 = 3.931;
41-
constexpr float MassHyperhelium4 = 3.9218;
42-
constexpr float MassXiMinus = 1.32171;
43-
constexpr float MassOmegaMinus = 1.67245;
24+
25+
// BEGINNING OF THE GENERATED BLOCK.
26+
// DO NOT EDIT THIS BLOCK DIRECTLY!
27+
// It has been generated by the make_pdg_header.py script.
28+
// For modifications, edit the script and generate this block again.
29+
30+
/// \brief Declarations of named PDG codes of particles missing in ROOT PDG_t
31+
/// \note Follow kCamelCase naming convention
32+
/// \link https://root.cern/doc/master/TPDGCode_8h.html
33+
enum Pdg {
34+
kB0 = 511,
35+
kB0Bar = -511,
36+
kBPlus = 521,
37+
kBS = 531,
38+
kBSBar = -531,
39+
kD0 = 421,
40+
kD0Bar = -421,
41+
kDMinus = -411,
42+
kDPlus = 411,
43+
kDS = 431,
44+
kDSBar = -431,
45+
kDStar = 413,
46+
kChiC1 = 20443,
47+
kJPsi = 443,
48+
kLambdaB0 = 5122,
49+
kLambdaCPlus = 4122,
50+
kOmegaC0 = 4332,
51+
kPhi = 333,
52+
kSigmaC0 = 4112,
53+
kSigmaCPlusPlus = 4222,
54+
kX3872 = 9920443,
55+
kXi0 = 3322,
56+
kXiB0 = 5232,
57+
kXiCCPlusPlus = 4422,
58+
kXiCPlus = 4232,
59+
kXiCZero = 4132,
60+
kDeuteron = 1000010020,
61+
kTriton = 1000010030,
62+
kHelium3 = 1000020030,
63+
kAlpha = 1000020040,
64+
kHyperTriton = 1010010030,
65+
kHyperHydrogen4 = 1010010040,
66+
kHyperHelium4 = 1010020040
67+
};
68+
69+
/// \brief Declarations of masses for additional particles
70+
constexpr double MassB0 = 5.27953;
71+
constexpr double MassB0Bar = 5.27953;
72+
constexpr double MassBPlus = 5.27915;
73+
constexpr double MassBS = 5.3663;
74+
constexpr double MassBSBar = 5.3663;
75+
constexpr double MassD0 = 1.86484;
76+
constexpr double MassD0Bar = 1.86484;
77+
constexpr double MassDMinus = 1.86962;
78+
constexpr double MassDPlus = 1.86962;
79+
constexpr double MassDS = 1.9685;
80+
constexpr double MassDSBar = 1.9685;
81+
constexpr double MassDStar = 2.01027;
82+
constexpr double MassChiC1 = 3.51066;
83+
constexpr double MassJPsi = 3.096916;
84+
constexpr double MassLambdaB0 = 5.6202;
85+
constexpr double MassLambdaCPlus = 2.28646;
86+
constexpr double MassOmegaC0 = 2.6975;
87+
constexpr double MassPhi = 1.019455;
88+
constexpr double MassSigmaC0 = 2.45376;
89+
constexpr double MassSigmaCPlusPlus = 2.45402;
90+
constexpr double MassX3872 = 3.87165;
91+
constexpr double MassXi0 = 1.31486;
92+
constexpr double MassXiB0 = 5.7924;
93+
constexpr double MassXiCCPlusPlus = 3.59798;
94+
constexpr double MassXiCPlus = 2.4679;
95+
constexpr double MassXiCZero = 2.471;
96+
constexpr double MassDeuteron = 1.87561294257;
97+
constexpr double MassTriton = 2.80892113298;
98+
constexpr double MassHelium3 = 2.80839160743;
99+
constexpr double MassAlpha = 3.7273794066;
100+
constexpr double MassHyperTriton = 2.99131;
101+
constexpr double MassHyperHydrogen4 = 3.9226;
102+
constexpr double MassHyperHelium4 = 3.9217;
103+
104+
/// \brief Declarations of masses for particles in ROOT PDG_t
105+
constexpr double MassDown = 0.0048;
106+
constexpr double MassDownBar = 0.0048;
107+
constexpr double MassUp = 0.0024;
108+
constexpr double MassUpBar = 0.0024;
109+
constexpr double MassStrange = 0.104;
110+
constexpr double MassStrangeBar = 0.104;
111+
constexpr double MassCharm = 1.27;
112+
constexpr double MassCharmBar = 1.27;
113+
constexpr double MassBottom = 4.68;
114+
constexpr double MassBottomBar = 4.68;
115+
constexpr double MassTop = 171.2;
116+
constexpr double MassTopBar = 171.2;
117+
constexpr double MassGluon = 0.0;
118+
constexpr double MassElectron = 0.00051099891;
119+
constexpr double MassPositron = 0.00051099891;
120+
constexpr double MassNuE = 0.0;
121+
constexpr double MassNuEBar = 0.0;
122+
constexpr double MassMuonMinus = 0.105658;
123+
constexpr double MassMuonPlus = 0.105658;
124+
constexpr double MassNuMu = 0.0;
125+
constexpr double MassNuMuBar = 0.0;
126+
constexpr double MassTauMinus = 1.77684;
127+
constexpr double MassTauPlus = 1.77684;
128+
constexpr double MassNuTau = 0.0;
129+
constexpr double MassNuTauBar = 0.0;
130+
constexpr double MassGamma = 0.0;
131+
constexpr double MassZ0 = 91.187;
132+
constexpr double MassWPlus = 80.398;
133+
constexpr double MassWMinus = 80.398;
134+
constexpr double MassPi0 = 0.134977;
135+
constexpr double MassK0Long = 0.497614;
136+
constexpr double MassPiPlus = 0.13957;
137+
constexpr double MassPiMinus = 0.13957;
138+
constexpr double MassProton = 0.938272;
139+
constexpr double MassProtonBar = 0.938272;
140+
constexpr double MassNeutron = 0.939565;
141+
constexpr double MassNeutronBar = 0.939565;
142+
constexpr double MassK0Short = 0.497614;
143+
constexpr double MassK0 = 0.497614;
144+
constexpr double MassK0Bar = 0.497614;
145+
constexpr double MassKPlus = 0.493677;
146+
constexpr double MassKMinus = 0.493677;
147+
constexpr double MassLambda0 = 1.11568;
148+
constexpr double MassLambda0Bar = 1.11568;
149+
constexpr double MassLambda1520 = 1.5195;
150+
constexpr double MassSigmaMinus = 1.19744;
151+
constexpr double MassSigmaBarPlus = 1.19744;
152+
constexpr double MassSigmaPlus = 1.18937;
153+
constexpr double MassSigmaBarMinus = 1.18937;
154+
constexpr double MassSigma0 = 1.192642;
155+
constexpr double MassSigma0Bar = 1.192642;
156+
constexpr double MassXiMinus = 1.32171;
157+
constexpr double MassXiPlusBar = 1.32171;
158+
constexpr double MassOmegaMinus = 1.67245;
159+
constexpr double MassOmegaPlusBar = 1.67245;
160+
161+
// END OF THE GENERATED BLOCK
162+
163+
// legacy names
164+
constexpr double MassPhoton = MassGamma;
165+
constexpr double MassMuon = MassMuonMinus;
166+
constexpr double MassPionCharged = MassPiPlus;
167+
constexpr double MassPionNeutral = MassPi0;
168+
constexpr double MassKaonCharged = MassKPlus;
169+
constexpr double MassKaonNeutral = MassK0;
170+
constexpr double MassLambda = MassLambda0;
171+
constexpr double MassHyperhydrog4 = MassHyperHydrogen4;
172+
constexpr double MassHyperhelium4 = MassHyperHelium4;
44173

45174
constexpr float LightSpeedCm2S = 299792458.e2; // C in cm/s
46175
constexpr float LightSpeedCm2NS = LightSpeedCm2S * 1e-9; // C in cm/ns
47-
} // namespace physics
48-
} // namespace constants
49-
} // namespace o2
176+
} // namespace o2::constants::physics
50177

51178
#endif

0 commit comments

Comments
 (0)