82 auto& dec = ic.
services().get<DanglingEdgesContext>();
87 std::unordered_map<std::string, std::string> ccdbUrls;
88 std::unordered_map<std::string, std::string> runDependent;
89 for (
auto& input : dec.analysisCCDBInputs) {
90 for (
auto&
m : input.metadata) {
91 if (
m.name.starts_with(
"ccdb-run-dependent:")) {
92 runDependent.emplace(
m.name,
m.defaultValue.asString());
95 if (!
m.name.starts_with(
"ccdb:") || ccdbUrls.count(
m.name)) {
98 std::string
url =
m.defaultValue.asString();
100 url = options.
get<std::string>(
m.name.c_str());
102 LOGP(info,
"CCDB path resolved for {}: {}",
m.name,
url);
103 ccdbUrls.emplace(
m.name, std::move(
url));
106 std::vector<std::shared_ptr<arrow::Schema>> schemas;
107 for (
auto& input : dec.analysisCCDBInputs) {
108 auto schemaMetadata = std::make_shared<arrow::KeyValueMetadata>();
109 std::vector<std::shared_ptr<arrow::Field>>
fields;
111 schemaMetadata->Append(
"outputBinding", input.binding);
112 for (
auto&
m : input.metadata) {
113 if (
m.name.starts_with(
"input:")) {
114 auto name =
m.name.substr(6);
115 schemaMetadata->Append(
"sourceTable",
name);
119 if (
m.name ==
"timestamp-column" ||
m.name ==
"uniformity-column") {
120 schemaMetadata->Append(
m.name,
m.defaultValue.asString());
123 if (!
m.name.starts_with(
"ccdb:")) {
126 auto fieldMetadata = std::make_shared<arrow::KeyValueMetadata>();
127 auto it = ccdbUrls.find(
m.name);
128 fieldMetadata->Append(
"url", it != ccdbUrls.end() ? it->second :
m.defaultValue.asString());
129 auto runDep = runDependent.find(
"ccdb-run-dependent:" +
m.name.substr(strlen(
"ccdb:")));
130 fieldMetadata->Append(
"runDependent", runDep != runDependent.end() ? runDep->second :
"0");
131 auto pos =
m.name.rfind(std::string_view{
"::"});
132 auto columnName = fmt::format(
"f{}",
m.name.substr(
pos + 2,
m.name.size()));
135 schemas.emplace_back(std::make_shared<arrow::Schema>(
fields, schemaMetadata));
139 std::vector<std::vector<PathTable>> pathTables;
140 for (
auto const&
schema : schemas) {
141 auto& tables = pathTables.emplace_back();
142 for (
auto const& field :
schema->fields()) {
147 std::vector<std::pair<uint32_t, std::shared_ptr<arrow::FixedSizeListBuilder>>> allbuilders;
148 allbuilders.resize([&schemas]() {
size_t size = 0;
for (
auto&
schema : schemas) {
size +=
schema->num_fields(); };
return size; }());
149 auto* pool = arrow::default_memory_pool();
153 for (
auto const&
schema : schemas) {
154 for (
auto const& _ :
schema->fields()) {
155 auto value_builder = std::make_shared<arrow::Int64Builder>();
156 allbuilders[idx] = std::make_pair(sidx, std::make_shared<arrow::FixedSizeListBuilder>(pool, std::move(value_builder), 3));
162 std::shared_ptr<CCDBFetcherHelper> helper = std::make_shared<CCDBFetcherHelper>();
164 std::unordered_map<std::string, int> bindings;
165 fillValidRoutes(*helper, spec.
outputs, bindings);
170 std::ranges::for_each(allbuilders, [](
auto& builder) { builder.second->Reset(); });
171 for (
auto i = 0U;
i < schemas.size(); ++
i) {
173 std::vector<CCDBFetcherHelper::FetchOp> ops;
174 auto inputBinding = *
schema->metadata()->Get(
"sourceTable");
175 auto outRouteDesc = *
schema->metadata()->Get(
"outputRoute");
176 std::string outBinding = *
schema->metadata()->Get(
"outputBinding");
177 auto timestampColumnName =
schema->metadata()->Contains(
"timestamp-column") ? *
schema->metadata()->Get(
"timestamp-column") : std::string{
"fTimestamp"};
178 auto uniformityColumnName =
schema->metadata()->Contains(
"uniformity-column") ? *
schema->metadata()->Get(
"uniformity-column") : timestampColumnName;
180 "Fetching CCDB objects for %{public}s's columns with timestamps from %{public}s and putting them in route %{public}s",
181 outBinding.c_str(), inputBinding.c_str(), outRouteDesc.c_str());
185 std::shared_ptr<arrow::ChunkedArray> timestampColumn;
186 std::shared_ptr<arrow::ChunkedArray> uniformityColumn;
187 auto const& schemaKeys =
schema->metadata()->keys();
188 auto const& schemaValues =
schema->metadata()->values();
189 for (
size_t mi = 0; mi < schemaKeys.size(); ++mi) {
190 if (schemaKeys[mi] !=
"sourceMatcher") {
194 if (
auto column = sourceTable->GetColumnByName(timestampColumnName); column && !timestampColumn) {
195 timestampColumn = column;
197 if (
auto column = sourceTable->GetColumnByName(uniformityColumnName); column && !uniformityColumn) {
198 uniformityColumn = column;
201 if (!timestampColumn) {
202 LOGP(fatal,
"No source table of {} provides the timestamp column \"{}\"", outBinding, timestampColumnName);
204 if (!uniformityColumn) {
205 LOGP(fatal,
"No source table of {} provides the uniformity column \"{}\"", outBinding, uniformityColumnName);
209 if (uniformityColumn->length() != timestampColumn->length()) {
210 LOGP(fatal,
"Uniformity column \"{}\" has {} rows but timestamp column \"{}\" has {}; the two sources of {} are not row-aligned",
211 uniformityColumnName, uniformityColumn->length(), timestampColumnName, timestampColumn->length(), outBinding);
213 auto reserveSize = timestampColumn->length();
215 "There are %zu bindings available", bindings.size());
216 for (
auto const&
binding : bindings) {
221 int outputRouteIndex = bindings.at(outRouteDesc);
222 auto& spec = helper->routes[outputRouteIndex].matcher;
225 auto builders = allbuilders | std::views::filter([&
i](
auto const& builder) {
return builder.first ==
i; });
226 unsigned int numBuilders = std::ranges::count_if(allbuilders, [&
i](
auto const& builder) {
return builder.first ==
i; });
227 arrow::Status status;
228 std::ranges::for_each(builders, [&status, &reserveSize](
auto& builder) {
229 if (reserveSize > builder.second->capacity()) {
230 status &= builder.second->Reserve(reserveSize - builder.second->capacity());
238 std::vector<DataAllocator::CacheId> referenced;
244 std::vector<int64_t> uniformity;
245 bool const shortCircuit = uniformityColumn.get() != timestampColumn.get();
247 uniformity.reserve(reserveSize);
248 for (
auto uci = 0; uci < uniformityColumn->num_chunks(); ++uci) {
249 auto uchunk = uniformityColumn->chunk(uci);
250 auto const length = uchunk->data()->length;
251 switch (uchunk->type_id()) {
252 case arrow::Type::INT32:
253 for (int64_t ui = 0; ui <
length; ++ui) {
254 uniformity.push_back(uchunk->data()->GetValuesSafe<
int32_t>(1)[ui]);
257 case arrow::Type::INT64:
258 case arrow::Type::UINT64:
259 for (int64_t ui = 0; ui <
length; ++ui) {
260 uniformity.push_back(uchunk->data()->GetValuesSafe<int64_t>(1)[ui]);
264 LOGP(fatal,
"Uniformity column \"{}\" of {} has unsupported arrow type {}",
265 uniformityColumnName, outBinding, uchunk->type()->ToString());
270 int64_t previousUniformity = 0;
271 bool haveResponses =
false;
272 std::vector<CCDBFetcherHelper::Response> responses;
274 for (
auto ci = 0; ci < timestampColumn->num_chunks(); ++ci) {
275 std::shared_ptr<arrow::Array> chunk = timestampColumn->chunk(ci);
276 auto const* timestamps = chunk->data()->GetValuesSafe<
size_t>(1);
278 for (int64_t ri = 0; ri < chunk->data()->length; ri++) {
281 int64_t timestamp = timestamps[ri];
284 int64_t
const uniformityKey = shortCircuit ? uniformity[
row] : timestamp;
285 bool const sameAsPrevious = haveResponses && uniformityKey == previousUniformity;
286 previousUniformity = uniformityKey;
288 for (
auto& field :
schema->fields()) {
289 auto const&
url = pathTables[
i][fi++].resolve(uniformityKey, field->name());
294 int const fieldRunDependent = field->metadata()->Contains(
"runDependent")
295 ? std::stoi(*field->metadata()->Get(
"runDependent"))
297 if (fieldRunDependent != 0 && uniformityColumnName !=
"fRunNumber") {
298 LOGP(fatal, R
"(Column "{}" of {} is declared run-dependent, but its table is uniform in "{}" rather than fRunNumber, so no run number is available to query with. Declare the table with DECLARE_SOA_UNIFORM_TABLE(..., aod::BCs, o2::aod::bc::RunNumber, ...).)",
299 field->name(), outBinding, uniformityColumnName);
304 .timestamp = timestamp,
305 .runNumber = fieldRunDependent != 0 ? static_cast<int>(uniformityKey) : 1,
306 .runDependent = fieldRunDependent,
310 if (!sameAsPrevious) {
312 haveResponses =
true;
315 "Got %zu responses from server.",
317 if (numBuilders != responses.size()) {
318 LOGP(fatal,
"Not enough responses (expected {}, found {})", numBuilders, responses.size());
323 for (
auto& builder : builders) {
324 auto& response = responses[bi];
325 auto& lastId = lastIds[bi];
326 if (response.id.value != lastId.value) {
327 lastId.value = response.id.value;
328 referenced.push_back(response.id);
330 result &= builder.second->Append();
331 auto* value_builder =
dynamic_cast<arrow::Int64Builder*
>(builder.second->value_builder());
332 result &= value_builder->Append(response.id.handle);
333 result &= value_builder->Append(response.id.segment);
334 result &= value_builder->Append(response.size);
338 LOGP(fatal,
"Error adding results from CCDB");
340 O2_SIGNPOST_END(ccdb, sid,
"handlingResponses",
"Done processing responses");
343 arrow::ArrayVector
arrays;
344 std::ranges::for_each(builders, [&
arrays](
auto& builder) {
arrays.push_back(*builder.second->Finish()); });
348 auto stream = arrow::io::BufferOutputStream::Create().ValueOrDie();
349 auto writer = arrow::ipc::MakeStreamWriter(
stream,
schema).ValueOrDie();
350 if (!writer->WriteRecordBatch(*arrow::RecordBatch::Make(
schema, reserveSize,
arrays)).ok()) {
351 LOGP(fatal,
"Unable to serialise the table of {}", outBinding);
361 for (
auto const&
id : referenced) {
368 O2_SIGNPOST_END(ccdb, sid,
"fetchFromAnalysisCCDB",
"Fetching CCDB objects");
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc Replace constant variables static by constexpr expressions Compile RTC in deterministic with NO_FAST_MATH flags and GPUCA_DETERMINISTIC_MODE define Use RTC to optimize GPU code h configStandalone Processing proc_rtctech Use a file lock to serialize access to the cache folder int32_t