Skip to content

Commit 7d4f5e4

Browse files
authored
Merge 610fb48 into sapling-pr-archive-ktf
2 parents e07b87a + 610fb48 commit 7d4f5e4

Some content is hidden

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

56 files changed

+764
-649
lines changed

CCDB/include/CCDB/BasicCCDBManager.h

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,20 @@ class CCDBManagerInstance
108108

109109
/// retrieve an object of type T from CCDB as stored under path, timestamp and metaData
110110
template <typename T>
111-
T* getSpecific(std::string const& path, long timestamp = -1, MD metaData = MD())
111+
T* getSpecific(std::string const& path, long timestamp = -1, MD metaData = MD(), std::map<std::string, std::string>* headers = nullptr)
112112
{
113113
// TODO: add some error info/handling when failing
114114
mMetaData = metaData;
115-
return getForTimeStamp<T>(path, timestamp);
115+
auto obj = getForTimeStamp<T>(path, timestamp);
116+
if (headers) {
117+
*headers = mHeaders;
118+
}
119+
return obj;
116120
}
117121

118122
/// retrieve an object of type T from CCDB as stored under path and using the timestamp in the middle of the run + metadata. The run number is provided separately to conform to typical analysis use (in which case metadata does not include runNumber)
119123
template <typename T>
120-
T* getSpecificForRun(std::string const& path, int runNumber, MD metaData = MD());
124+
T* getSpecificForRun(std::string const& path, int runNumber, MD const& metaData = MD());
121125

122126
/// detect online processing modes (i.e. CCDB objects may be updated in the lifetime of the manager)
123127
bool isOnline() const { return mDeplMode == o2::framework::DeploymentMode::OnlineAUX || mDeplMode == o2::framework::DeploymentMode::OnlineDDS || mDeplMode == o2::framework::DeploymentMode::OnlineECS; }
@@ -129,6 +133,9 @@ class CCDBManagerInstance
129133
return getForTimeStamp<T>(path, mTimestamp);
130134
}
131135

136+
// gain access to underlaying CCDB layer (to allow for more complex queries without need to reinit another API)
137+
CcdbApi& getCCDBAccessor() { return mCCDBAccessor; }
138+
132139
bool isHostReachable() const { return mCCDBAccessor.isHostReachable(); }
133140

134141
/// clear all entries in the cache
@@ -230,11 +237,12 @@ class CCDBManagerInstance
230237
template <typename T>
231238
T* CCDBManagerInstance::getForTimeStamp(std::string const& path, long timestamp)
232239
{
240+
mHeaders.clear(); // we clear at the beginning; to allow to retrieve the header information in a subsequent call
233241
T* ptr = nullptr;
234242
mQueries++;
235243
auto start = std::chrono::system_clock::now();
236244
if (!isCachingEnabled()) {
237-
ptr = mCCDBAccessor.retrieveFromTFileAny<T>(path, mMetaData, timestamp, nullptr, "",
245+
ptr = mCCDBAccessor.retrieveFromTFileAny<T>(path, mMetaData, timestamp, &mHeaders, "",
238246
mCreatedNotAfter ? std::to_string(mCreatedNotAfter) : "",
239247
mCreatedNotBefore ? std::to_string(mCreatedNotBefore) : "");
240248
if (!ptr) {
@@ -305,7 +313,6 @@ T* CCDBManagerInstance::getForTimeStamp(std::string const& path, long timestamp)
305313
} else {
306314
cached.cacheValidUntil = -1;
307315
}
308-
mHeaders.clear();
309316
mMetaData.clear();
310317
if (!ptr) {
311318
if (mFatalWhenNull) {
@@ -328,7 +335,7 @@ T* CCDBManagerInstance::getForRun(std::string const& path, int runNumber, bool s
328335
}
329336

330337
template <typename T>
331-
T* CCDBManagerInstance::getSpecificForRun(std::string const& path, int runNumber, MD metaData)
338+
T* CCDBManagerInstance::getSpecificForRun(std::string const& path, int runNumber, MD const& metaData)
332339
{
333340
auto [start, stop] = getRunDuration(runNumber, mFatalWhenNull);
334341
if (start < 0 || stop < 0) {

DataFormats/Parameters/include/DataFormatsParameters/AggregatedRunInfo.h

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,35 @@ struct AggregatedRunInfo {
3232
int runNumber = 0; // run number
3333
int64_t sor = 0; // best known timestamp for the start of run
3434
int64_t eor = 0; // best known timestamp for end of run
35-
int64_t orbitsPerTF = 0; // number of orbits per TF
35+
int64_t orbitsPerTF = 0; // number of orbits per TF (takes precedence over that in GRPECS)
3636
int64_t orbitReset = 0; // timestamp of orbit reset before run
3737
int64_t orbitSOR = 0; // orbit when run starts after orbit reset
3838
int64_t orbitEOR = 0; // orbit when run ends after orbit reset
3939

4040
// we may have pointers to actual data source objects GRPECS, ...
4141
const o2::parameters::GRPECSObject* grpECS = nullptr; // pointer to GRPECSobject (fetched during struct building)
4242

43-
// fills and returns AggregatedRunInfo for a given run number.
44-
static AggregatedRunInfo buildAggregatedRunInfo(o2::ccdb::CCDBManagerInstance& ccdb, int runnumber);
4543
static AggregatedRunInfo buildAggregatedRunInfo(int runnumber, long sorMS, long eorMS, long orbitResetMUS, const o2::parameters::GRPECSObject* grpecs, const std::vector<Long64_t>* ctfFirstRunOrbitVec);
44+
45+
// fills and returns AggregatedRunInfo for a given data run number.
46+
static AggregatedRunInfo buildAggregatedRunInfo_DATA(o2::ccdb::CCDBManagerInstance& ccdb, int runnumber);
47+
48+
// Returns the meta-data (MCProdInfo) associated to production lpm_prod_tag (performed by username)
49+
static std::map<std::string, std::string> getMCProdInfo(o2::ccdb::CCDBManagerInstance& ccdb, int runnumber,
50+
std::string const& lpm_prod_tag, std::string const& username = "aliprod");
51+
52+
// function that adjusts with values from MC
53+
void adjust_from_MC(o2::ccdb::CCDBManagerInstance& ccdb, int run_number, std::string const& lpm_prod_tag, std::string const& username = "aliprod");
54+
55+
// Fills and returns AggregatedRunInfo for a given run number.
56+
// If a non-empty lpm_prod_tag is given, it will potentially override values with specifics from a
57+
// MC production identified by that tag and username.
58+
static AggregatedRunInfo buildAggregatedRunInfo(o2::ccdb::CCDBManagerInstance& ccdb,
59+
int runnumber,
60+
std::string const& lpm_prod_tag = "",
61+
std::string const& username = "aliprod");
62+
63+
ClassDefNV(AggregatedRunInfo, 1);
4664
};
4765

4866
} // namespace o2::parameters

DataFormats/Parameters/src/AggregatedRunInfo.cxx

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
using namespace o2::parameters;
2323

24-
o2::parameters::AggregatedRunInfo AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::CCDBManagerInstance& ccdb, int runnumber)
24+
o2::parameters::AggregatedRunInfo AggregatedRunInfo::buildAggregatedRunInfo_DATA(o2::ccdb::CCDBManagerInstance& ccdb, int runnumber)
2525
{
2626
// TODO: could think about caching results per runnumber to
2727
// avoid going to CCDB multiple times ---> but should be done inside the CCDBManagerInstance
@@ -83,3 +83,67 @@ o2::parameters::AggregatedRunInfo AggregatedRunInfo::buildAggregatedRunInfo(int
8383
}
8484
return AggregatedRunInfo{runnumber, sorMS, eorMS, nOrbitsPerTF, orbitResetMUS, orbitSOR, orbitEOR, grpecs};
8585
}
86+
87+
namespace
88+
{
89+
90+
// get path where to find MC production info
91+
std::string getFullPath_MC(std::string const& username, std::string const& lpm_prod_tag)
92+
{
93+
// construct the path where to lookup
94+
std::string path = "/Users/" + std::string(1, username[0]) + "/" + username;
95+
std::string fullpath = path + "/" + "MCProdInfo/" + lpm_prod_tag;
96+
return fullpath;
97+
}
98+
99+
} // namespace
100+
101+
std::map<std::string, std::string> AggregatedRunInfo::getMCProdInfo(o2::ccdb::CCDBManagerInstance& ccdb,
102+
int run_number,
103+
std::string const& lpm_prod_tag,
104+
std::string const& username)
105+
{
106+
std::map<std::string, std::string> metaDataFilter;
107+
metaDataFilter["LPMProductionTag"] = lpm_prod_tag;
108+
109+
// fetch the meta information for MC productions
110+
auto header_data = ccdb.getCCDBAccessor().retrieveHeaders(getFullPath_MC(username, lpm_prod_tag), metaDataFilter, run_number);
111+
return header_data;
112+
}
113+
114+
void AggregatedRunInfo::adjust_from_MC(o2::ccdb::CCDBManagerInstance& ccdb,
115+
int run_number,
116+
std::string const& lpm_prod_tag,
117+
std::string const& username)
118+
{
119+
auto header_data = AggregatedRunInfo::getMCProdInfo(ccdb, run_number, lpm_prod_tag, username);
120+
121+
// adjust timeframe length if we find entry for MC production
122+
auto iter = header_data.find("OrbitsPerTF");
123+
if (iter != header_data.end()) {
124+
auto mc_orbitsPerTF = std::stoi(iter->second);
125+
if (mc_orbitsPerTF != orbitsPerTF) {
126+
LOG(info) << "Adjusting OrbitsPerTF from " << orbitsPerTF << " to " << mc_orbitsPerTF << " based on differing MC info";
127+
orbitsPerTF = mc_orbitsPerTF;
128+
}
129+
} else {
130+
LOG(warn) << "No OrbitsPerTF information found for MC production " << lpm_prod_tag << " and run number " << run_number;
131+
}
132+
}
133+
134+
AggregatedRunInfo AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::CCDBManagerInstance& ccdb, int run_number, std::string const& lpm_prod_tag, std::string const& username)
135+
{
136+
// (a) lookup the AggregatedRunInfo for the data run
137+
// (b) modify/overwrite the info object with MC specific settings if lpm_prod_tag is given
138+
139+
auto original_info = buildAggregatedRunInfo_DATA(ccdb, run_number);
140+
141+
if (lpm_prod_tag.size() == 0) {
142+
return original_info;
143+
}
144+
145+
// in this case we adjust the info from MC
146+
original_info.adjust_from_MC(ccdb, run_number, lpm_prod_tag, username);
147+
148+
return original_info;
149+
}

DataFormats/Parameters/src/GRPLHCIFData.cxx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ using namespace o2::constants::lhc;
2828
const std::unordered_map<unsigned int, unsigned int> GRPLHCIFData::mZtoA =
2929
{
3030
{1, 1},
31+
{8, 16},
32+
{10, 20},
3133
{82, 208}};
3234

3335
//_______________________________________________

DataFormats/simulation/include/SimulationDataFormat/TrackReference.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class TrackReference
171171
float mTrackLength = 0; ///< track length from its origin in cm
172172
float mTof = 0; ///< time of flight in cm
173173
Int_t mUserId = 0; ///< optional Id defined by user
174-
Int_t mDetectorId = 0; ///< Detector Id
174+
Int_t mDetectorId = -1; ///< sensitive Detector Id (-1 if unknown or in passive material)
175175
SimTrackStatus mStatus; ///< encoding the track status
176176

177177
friend std::ostream& operator<<(std::ostream&, const TrackReference&);

Detectors/AOD/src/AODProducerWorkflowSpec.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2717,7 +2717,7 @@ AODProducerWorkflowDPL::TrackQA AODProducerWorkflowDPL::processBarrelTrackQA(int
27172717
if (auto itsContGID = data.getITSContributorGID(trackIndex); itsContGID.isIndexSet() && itsContGID.getSource() != GIndex::ITSAB) {
27182718
const auto& itsOrig = data.getITSTrack(itsContGID);
27192719
o2::track::TrackPar gloCopy = trackPar;
2720-
o2::track::TrackPar itsCopy = itsOrig;
2720+
o2::track::TrackPar itsCopy = itsOrig.getParamOut();
27212721
o2::track::TrackPar tpcCopy = tpcOrig;
27222722
if (prop->propagateToX(gloCopy, o2::aod::track::trackQARefRadius, prop->getNominalBz(), o2::base::Propagator::MAX_SIN_PHI, o2::base::Propagator::MAX_STEP, mMatCorr) &&
27232723
prop->propagateToAlphaX(tpcCopy, gloCopy.getAlpha(), o2::aod::track::trackQARefRadius, false, o2::base::Propagator::MAX_SIN_PHI, o2::base::Propagator::MAX_STEP, 1, mMatCorr) &&

Detectors/ITSMFT/ITS/tracking/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ o2_add_library(ITStracking
3636
O2::ITSReconstruction
3737
O2::ITSMFTReconstruction
3838
O2::DataFormatsITS
39-
PRIVATE_LINK_LIBRARIES TBB::tbb)
39+
PRIVATE_LINK_LIBRARIES
40+
O2::Steer
41+
TBB::tbb)
4042

4143
o2_add_library(ITSTrackingInterface
4244
TARGETVARNAME targetName

Detectors/ITSMFT/ITS/tracking/GPU/cuda/TrackerTraitsGPU.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ void TrackerTraitsGPU<nLayers>::findRoads(const int iteration)
246246
this->mTrkParams[0].MaxChi2ClusterAttachment,
247247
this->mTrkParams[0].MaxChi2NDF,
248248
mTimeFrameGPU->getDevicePropagator(),
249-
this->mCorrType,
249+
this->mTrkParams[0].CorrType,
250250
conf.nBlocks,
251251
conf.nThreads);
252252
}
@@ -268,7 +268,7 @@ void TrackerTraitsGPU<nLayers>::findRoads(const int iteration)
268268
this->mTrkParams[0].MaxChi2ClusterAttachment, // float maxChi2ClusterAttachment
269269
this->mTrkParams[0].MaxChi2NDF, // float maxChi2NDF
270270
mTimeFrameGPU->getDevicePropagator(), // const o2::base::Propagator* propagator
271-
this->mCorrType, // o2::base::PropagatorImpl<float>::MatCorrType
271+
this->mTrkParams[0].CorrType, // o2::base::PropagatorImpl<float>::MatCorrType
272272
conf.nBlocks,
273273
conf.nThreads);
274274

Detectors/ITSMFT/ITS/tracking/GPU/cuda/TrackingKernels.cu

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,30 +58,43 @@ namespace gpu
5858
{
5959

6060
template <typename T>
61-
class TypedAllocator : public thrust::device_allocator<T>
62-
{
63-
public:
61+
struct TypedAllocator {
6462
using value_type = T;
65-
using pointer = T*;
63+
using pointer = thrust::device_ptr<T>;
64+
using const_pointer = thrust::device_ptr<const T>;
65+
using size_type = std::size_t;
66+
using difference_type = std::ptrdiff_t;
67+
68+
TypedAllocator() noexcept : mInternalAllocator(nullptr) {}
69+
explicit TypedAllocator(ExternalAllocator* a) noexcept : mInternalAllocator(a) {}
6670

6771
template <typename U>
68-
struct rebind {
69-
using other = TypedAllocator<U>;
70-
};
72+
TypedAllocator(const TypedAllocator<U>& o) noexcept : mInternalAllocator(o.mInternalAllocator)
73+
{
74+
}
7175

72-
explicit TypedAllocator(ExternalAllocator* allocPtr)
73-
: mInternalAllocator(allocPtr) {}
76+
pointer allocate(size_type n)
77+
{
78+
void* raw = mInternalAllocator->allocate(n * sizeof(T));
79+
return thrust::device_pointer_cast(static_cast<T*>(raw));
80+
}
7481

75-
T* allocate(size_t n)
82+
void deallocate(pointer p, size_type n) noexcept
7683
{
77-
return reinterpret_cast<T*>(mInternalAllocator->allocate(n * sizeof(T)));
84+
if (!p) {
85+
return;
86+
}
87+
void* raw = thrust::raw_pointer_cast(p);
88+
mInternalAllocator->deallocate(static_cast<char*>(raw), n * sizeof(T));
7889
}
7990

80-
void deallocate(T* p, size_t n)
91+
bool operator==(TypedAllocator const& o) const noexcept
92+
{
93+
return mInternalAllocator == o.mInternalAllocator;
94+
}
95+
bool operator!=(TypedAllocator const& o) const noexcept
8196
{
82-
char* raw_ptr = reinterpret_cast<char*>(p);
83-
size_t bytes = n * sizeof(T);
84-
mInternalAllocator->deallocate(raw_ptr, bytes); // redundant as internal dealloc is no-op.
97+
return !(*this == o);
8598
}
8699

87100
private:

Detectors/ITSMFT/ITS/tracking/include/ITStracking/Configuration.h

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -26,36 +26,8 @@
2626
#include "DetectorsBase/Propagator.h"
2727
#include "ITStracking/Constants.h"
2828

29-
namespace o2
29+
namespace o2::its
3030
{
31-
namespace its
32-
{
33-
34-
enum class TrackingMode {
35-
Sync,
36-
Async,
37-
Cosmics,
38-
Unset, // Special value to leave a default in case we want to override via Configurable Params
39-
};
40-
41-
std::string asString(TrackingMode mode);
42-
std::ostream& operator<<(std::ostream& os, TrackingMode v);
43-
44-
template <typename Param>
45-
class Configuration : public Param
46-
{
47-
public:
48-
static Configuration<Param>& getInstance()
49-
{
50-
static Configuration<Param> instance;
51-
return instance;
52-
}
53-
Configuration(const Configuration<Param>&) = delete;
54-
const Configuration<Param>& operator=(const Configuration<Param>&) = delete;
55-
56-
private:
57-
Configuration() = default;
58-
};
5931

6032
struct TrackingParameters {
6133
int CellMinimumLevel() const noexcept { return MinTrackLength - constants::ClustersPerCell + 1; }
@@ -140,6 +112,9 @@ struct VertexingParameters {
140112
int zSpan = -1;
141113
bool SaveTimeBenchmarks = false;
142114

115+
bool useTruthSeeding = false; // overwrite found vertices with MC events
116+
bool outputContLabels = false;
117+
143118
int nThreads = 1;
144119
bool PrintMemory = false; // print allocator usage in epilog report
145120
size_t MaxMemory = std::numeric_limits<size_t>::max();
@@ -166,7 +141,24 @@ struct TimeFrameGPUParameters {
166141
int maxGPUMemoryGB = -1;
167142
};
168143

169-
} // namespace its
170-
} // namespace o2
144+
namespace TrackingMode
145+
{
146+
enum Type : int8_t {
147+
Unset = -1, // Special value to leave a default in case we want to override via Configurable Params
148+
Sync = 0,
149+
Async = 1,
150+
Cosmics = 2,
151+
Off = 3,
152+
};
153+
154+
Type fromString(std::string_view str);
155+
std::string toString(Type mode);
156+
157+
std::vector<TrackingParameters> getTrackingParameters(Type mode);
158+
std::vector<VertexingParameters> getVertexingParameters(Type mode);
159+
160+
}; // namespace TrackingMode
161+
162+
} // namespace o2::its
171163

172164
#endif /* TRACKINGITSU_INCLUDE_CONFIGURATION_H_ */

0 commit comments

Comments
 (0)