228 std::variant<std::monostate, CheckReady, CheckProcessing>
check;
239 constexpr operator bool()
241 return std::holds_alternative<Process>(
callback);
247 if (std::holds_alternative<Process>(
callback)) {
248 std::get<Process>(
callback)(context);
258 template <
typename T,
typename _ =
void>
261 template <
typename T>
264 std::enable_if_t<std::is_same_v<std::decay_t<T>, char const*> ||
265 std::is_same_v<std::decay_t<T>, char*> ||
266 std::is_same_v<std::decay_t<T>, std::string>>> :
public std::true_type {
272 template <
typename T>
276 template <typename KeyType, typename Arg = const char*, std::enable_if_t<StringAssignable<Arg>::value,
int> = 0>
283 template <typename KeyType, typename Arg = const char*, std::enable_if_t<StringAssignable<Arg>::value,
int> = 0>
290 template <
typename KeyType,
typename Arg,
typename... Args, std::enable_if_t<StringAssignable<Arg>::value,
int> = 0>
296 template <
typename KeyType,
typename Arg,
typename... Args, std::enable_if_t<!StringAssignable<Arg>::value,
int> = 0>
326 template <
typename... Args>
329 parseConstructorArgs<0>(std::forward<Args>(args)...);
337 std::shared_ptr<WriterType> writer;
339 std::vector<std::pair<std::string, std::string>> branchNameOptions;
343 int nEventsAutoSave = -1;
345 std::unordered_set<std::string> activeInputs;
357 auto processAttributes = std::make_shared<ProcessAttributes>();
358 processAttributes->writer = mWriter;
359 processAttributes->branchNameOptions = mBranchNameOptions;
360 processAttributes->terminationCondition = std::move(mTerminationCondition);
361 processAttributes->preprocessor = std::move(mPreprocessor);
365 for (
auto const& input : mInputs) {
366 processAttributes->activeInputs.emplace(input.binding);
368 processAttributes->nofBranches = mNofBranches;
372 auto& branchNameOptions = processAttributes->branchNameOptions;
373 auto filename = ic.options().get<std::string>(
"outfile");
374 auto treename = ic.options().get<std::string>(
"treename");
375 auto treetitle = ic.options().get<std::string>(
"treetitle");
376 auto outdir = ic.options().get<std::string>(
"output-dir");
377 processAttributes->nEvents = ic.options().get<
int>(
"nevents");
378 if (processAttributes->nEvents > 0 && processAttributes->activeInputs.size() != processAttributes->nofBranches) {
379 LOG(warning) <<
"the n inputs serve in total m branches with n != m, this means that there will be data for\n"
380 <<
"different branches on the same input. Be aware that the --nevents option might lead to incomplete\n"
381 <<
"data in the output file as the number of processed input sets is counted";
383 processAttributes->nEventsAutoSave = ic.options().get<
int>(
"autosave");
385 processAttributes->terminationPolicy =
TerminationPolicyMap.at(ic.options().get<std::string>(
"terminate"));
386 }
catch (std::out_of_range&) {
387 throw std::invalid_argument(std::string(
"invalid termination policy: ") + ic.options().get<std::string>(
"terminate"));
389 if (
filename.empty() || treename.empty()) {
390 throw std::invalid_argument(
"output file name and tree name are mandatory options");
392 for (
size_t branchIndex = 0; branchIndex < branchNameOptions.size(); branchIndex++) {
394 if (branchNameOptions[branchIndex].
first.empty()) {
397 auto branchName = ic.options().get<std::string>(branchNameOptions[branchIndex].first.c_str());
398 processAttributes->writer->setBranchName(branchIndex, branchName.c_str());
400 if (!outdir.empty() && outdir !=
"none") {
401 if (outdir.back() !=
'/') {
406 processAttributes->writer->init(
filename.c_str(), treename.c_str(), treetitle.c_str());
408 auto finishWriting = [processAttributes]() {
409 processAttributes->writer->close();
412 ic.services().get<
CallbackService>().set<CallbackService::Id::Stop>(finishWriting);
415 auto& writer = processAttributes->writer;
416 auto& terminationPolicy = processAttributes->terminationPolicy;
417 auto& terminationCondition = processAttributes->terminationCondition;
418 auto& preprocessor = processAttributes->preprocessor;
419 auto& activeInputs = processAttributes->activeInputs;
420 auto&
counter = processAttributes->counter;
421 auto&
nEvents = processAttributes->nEvents;
422 auto& nEventsAutoSave = processAttributes->nEventsAutoSave;
423 if (writer->isClosed()) {
431 auto checkProcessing = [&terminationCondition, &activeInputs](
auto const& inputs) {
432 bool doProcessing =
true;
433 if (std::holds_alternative<TerminationCondition::CheckProcessing>(terminationCondition.check)) {
434 auto&
check = std::get<TerminationCondition::CheckProcessing>(terminationCondition.check);
435 for (
auto const&
ref : inputs) {
436 auto iter = activeInputs.find(
ref.spec->binding);
440 doProcessing =
false;
442 if (iter != activeInputs.end() && ready) {
444 activeInputs.erase(iter);
453 auto checkReady = [&terminationCondition, &activeInputs](
auto const& inputs) {
454 if (std::holds_alternative<TerminationCondition::CheckReady>(terminationCondition.check)) {
455 auto&
check = std::get<TerminationCondition::CheckReady>(terminationCondition.check);
456 for (
auto const&
ref : inputs) {
457 auto iter = activeInputs.find(
ref.spec->binding);
458 if (iter != activeInputs.end() &&
check(
ref)) {
460 activeInputs.erase(iter);
464 return activeInputs.size() == 0;
470 if (checkProcessing(pc.inputs())) {
471 (*writer)(pc.inputs());
478 }
else if (nEventsAutoSave > 0 &&
counter && (
counter % nEventsAutoSave) == 0) {
483 return processingFct;
492 {
"nevents",
VariantType::Int, mDefaultNofEvents, {
"Number of events to execute"}},
493 {
"autosave",
VariantType::Int, mDefaultAutoSave, {
"Autosave after number of events"}},
494 {
"terminate",
VariantType::String, mDefaultTerminationPolicy.c_str(), {
"Terminate the 'process' or 'workflow'"}},
496 for (
size_t branchIndex = 0; branchIndex < mBranchNameOptions.size(); branchIndex++) {
498 if (mBranchNameOptions[branchIndex].
first.empty()) {
503 mBranchNameOptions[branchIndex].second.c_str(),
504 {
"configurable branch name"}
508 mInputRoutes.insert(mInputRoutes.end(), mInputs.begin(), mInputs.end());
511 mProcessName.c_str(),
522 template <
size_t N,
typename... Args>
523 void parseConstructorArgs(
const char*
name, Args&&... args)
525 static_assert(N == 0,
"wrong argument order, default file and tree options must come before branch specs");
528 if (mDefaultFileName.empty()) {
529 mDefaultFileName =
name;
531 mDefaultTreeName =
name;
532 mDefaultTreeTitle =
name;
535 parseConstructorArgs<N>(std::forward<Args>(args)...);
540 template <
size_t N,
typename... Args>
541 void parseConstructorArgs(
int arg, Args&&... args)
543 static_assert(N == 0,
"wrong argument order, default file and tree options must come before branch specs");
544 if (mNIntArgCounter == 0) {
545 mDefaultNofEvents = arg;
546 }
else if (mNIntArgCounter == 1) {
547 mDefaultAutoSave = arg;
549 throw std::logic_error(
"Too many integer arguments in the constructor");
552 parseConstructorArgs<N>(std::forward<Args>(args)...);
556 template <
size_t N,
typename... Args>
559 static_assert(N == 0,
"wrong argument order, default file and tree, and all options must come before branch specs");
561 if (policy.second == arg) {
562 mDefaultTerminationPolicy = policy.first;
563 return parseConstructorArgs<N>(std::forward<Args>(args)...);
567 throw std::logic_error(
"Internal mismatch of policy ids and keys");
571 template <
size_t N,
typename... Args>
572 void parseConstructorArgs(TerminationCondition&& arg, Args&&... args)
574 static_assert(N == 0,
"wrong argument order, default file and tree, and all options must come before branch specs");
575 mTerminationCondition = std::move(arg);
576 parseConstructorArgs<N>(std::forward<Args>(args)...);
580 template <
size_t N,
typename... Args>
581 void parseConstructorArgs(Preprocessor&& arg, Args&&... args)
583 static_assert(N == 0,
"wrong argument order, default file and tree, and all options must come before branch specs");
584 mPreprocessor = std::move(arg);
585 parseConstructorArgs<N>(std::forward<Args>(args)...);
588 template <
size_t N,
typename... Args>
589 void parseConstructorArgs(AuxInputRoute&& aux, Args&&... args)
591 mInputRoutes.emplace_back(aux);
592 parseConstructorArgs<N>(std::forward<Args>(args)...);
595 template <
size_t N,
typename... Args>
596 void parseConstructorArgs(
CustomClose&& callback, Args&&... args)
598 mCustomClose = callback;
599 parseConstructorArgs<N>(std::forward<Args>(args)...);
602 template <
size_t N,
typename... Args>
603 void parseConstructorArgs(TreeAttributes&& att, Args&&... args)
605 mDefaultTreeName = att.name;
606 mDefaultTreeTitle = att.title.empty() ? att.name : att.title;
607 parseConstructorArgs<N>(std::forward<Args>(args)...);
614 template <
size_t N,
typename T,
typename... Args>
617 if (
def.nofBranches > 0) {
621 mInputs.insert(mInputs.end(),
def.keys.begin(),
def.keys.end());
622 mBranchNameOptions.emplace_back(
def.optionKey,
def.branchName);
623 mNofBranches +=
def.nofBranches;
626 mBranchNameOptions.emplace_back(
"",
"");
628 parseConstructorArgs<N + 1>(std::forward<Args>(args)...);
629 if constexpr (N == 0) {
630 mWriter = std::make_shared<WriterType>(
nullptr,
nullptr, mCustomClose, std::forward<
BranchDefinition<T>>(
def), std::forward<Args>(args)...);
636 void parseConstructorArgs()
640 std::shared_ptr<WriterType> mWriter;
641 std::string mProcessName;
642 std::vector<InputSpec> mInputs;
643 std::vector<InputSpec> mInputRoutes;
644 std::vector<std::pair<std::string, std::string>> mBranchNameOptions;
645 std::string mDefaultFileName;
646 std::string mDefaultTreeName;
647 std::string mDefaultTreeTitle;
648 std::string mDefaultDir =
"none";
649 int mDefaultNofEvents = -1;
650 int mDefaultAutoSave = -1;
651 std::string mDefaultTerminationPolicy =
"process";
652 TerminationCondition mTerminationCondition;
653 Preprocessor mPreprocessor;
654 size_t mNofBranches = 0;
655 int mNIntArgCounter = 0;
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 Print launch bounds used for RTC code as debugging for exit after def(1)) AddOption(allowOptimizedSlaveReconstruction