23#include <rapidjson/reader.h>
24#include <rapidjson/prettywriter.h>
25#include <rapidjson/istreamwrapper.h>
26#include <rapidjson/ostreamwrapper.h>
37using namespace rapidjson;
40struct WorkflowImporter :
public rapidjson::BaseReaderHandler<rapidjson::UTF8<>, WorkflowImporter> {
118 s <<
"IN_DATAPROCESSORS";
121 s <<
"IN_DATAPROCESSOR";
124 s <<
"IN_DATAPROCESSOR_NAME";
127 s <<
"IN_DATAPROCESSOR_RANK";
130 s <<
"IN_DATAPROCESSOR_N_SLOTS";
133 s <<
"IN_DATAPROCESSOR_TIMESLICE_ID";
136 s <<
"IN_DATAPROCESSOR_MAX_TIMESLICES";
154 s <<
"IN_WORKFLOW_OPTIONS";
160 s <<
"IN_INPUT_BINDING";
163 s <<
"IN_INPUT_ORIGIN";
166 s <<
"IN_INPUT_DESCRIPTION";
169 s <<
"IN_INPUT_SUBSPEC";
172 s <<
"IN_INPUT_ORIGIN_REF";
175 s <<
"IN_INPUT_DESCRIPTION_REF";
178 s <<
"IN_INPUT_SUBSPEC_REF";
181 s <<
"IN_INPUT_MATCHER";
184 s <<
"IN_INPUT_MATCHER_OPERATION";
187 s <<
"IN_INPUT_LEFT_MATCHER";
190 s <<
"IN_INPUT_RIGHT_MATCHER";
193 s <<
"IN_INPUT_LIFETIME";
196 s <<
"IN_INPUT_STARTTIME";
199 s <<
"IN_INPUT_OPTIONS";
205 s <<
"IN_OUTPUT_BINDING";
208 s <<
"IN_OUTPUT_ORIGIN";
211 s <<
"IN_OUTPUT_DESCRIPTION";
214 s <<
"IN_OUTPUT_SUBSPEC";
217 s <<
"IN_OUTPUT_LIFETIME";
220 s <<
"IN_OUTPUT_OPTIONS";
226 s <<
"IN_OPTION_NAME";
229 s <<
"IN_OPTION_TYPE";
232 s <<
"IN_OPTION_DEFAULT";
235 s <<
"IN_OPTION_HELP";
238 s <<
"IN_OPTION_KIND";
247 s <<
"IN_METADATUM_KEY";
250 s <<
"IN_METADATUM_VALUE";
256 s <<
"IN_DATAPROCESSOR_INFOS";
259 s <<
"IN_DATAPROCESSOR_INFO";
262 s <<
"IN_DATAPROCESSOR_INFO_NAME";
265 s <<
"IN_DATAPROCESSOR_INFO_EXECUTABLE";
268 s <<
"IN_DATAPROCESSOR_INFO_ARGS";
271 s <<
"IN_DATAPROCESSOR_INFO_ARG";
274 s <<
"IN_DATAPROCESSOR_INFO_CHANNELS";
277 s <<
"IN_DATAPROCESSOR_INFO_CHANNEL";
284 std::vector<DataProcessorInfo>&
m,
296 enter(
"START_OBJECT");
345 auto buildMatcher = [](
auto&
nodes) -> std::unique_ptr<DataDescriptorMatcher> {
347 std::make_unique<DataDescriptorMatcher>(DataDescriptorMatcher::Op::Just,
349 for (
size_t ni = 0, ne =
nodes.size(); ni < ne; ++ni) {
351 auto tmp = std::make_unique<DataDescriptorMatcher>(DataDescriptorMatcher::Op::And,
353 std::move(lastMatcher));
354 assert(lastMatcher.get() ==
nullptr);
355 lastMatcher = std::move(tmp);
360 std::unique_ptr<DataDescriptorMatcher> matcher;
361 if (
auto* pval = std::get_if<std::unique_ptr<DataDescriptorMatcher>>(&
inputMatcherNodes[0])) {
363 matcher = std::move(*pval);
368 if (concrete.has_value()) {
380 auto* matcher = std::get_if<std::unique_ptr<DataDescriptorMatcher>>(&child);
381 assert(matcher !=
nullptr);
382 auto* parent = std::get_if<std::unique_ptr<DataDescriptorMatcher>>(&
inputMatcherNodes.back());
383 assert(parent !=
nullptr);
384 std::unique_ptr<DataDescriptorMatcher>
node;
385 auto mergeDown = [&
node, &parent, &child]() ->
bool {
387 if (
auto* pval1 = std::get_if<ConstantValueMatcher>(&((*parent)->getLeft()))) {
389 node = std::make_unique<DataDescriptorMatcher>((*parent)->getOp(),
391 std::move((*parent)->getRight()));
395 if (
auto* pval2 = std::get_if<ConstantValueMatcher>(&((*parent)->getRight()))) {
397 node = std::make_unique<DataDescriptorMatcher>((*parent)->getOp(),
398 std::move((*parent)->getLeft()),
413 auto* parent = std::get_if<std::unique_ptr<DataDescriptorMatcher>>(&
inputMatcherNodes[nMatchers - 2]);
414 assert(parent !=
nullptr);
415 auto node = std::make_unique<DataDescriptorMatcher>((*parent)->getOp(),
417 std::move((*parent)->getRight()));
424 auto* parent = std::get_if<std::unique_ptr<DataDescriptorMatcher>>(&
inputMatcherNodes.back());
425 assert(parent !=
nullptr);
426 auto node = std::make_unique<DataDescriptorMatcher>((*parent)->getOp(),
427 std::move((*parent)->getLeft()),
440 std::unique_ptr<ConfigParamSpec> opt{
nullptr};
443 std::stringstream is;
528 metadata.back().workflowOptions.push_back(*opt);
545 enter(
"START_ARRAY");
741 std::string
v(
s.c_str(), std::min(
s.size(), 4UL));
745 std::string
v(
s.c_str(), std::min(
s.size(), 16UL));
755 op = DataDescriptorMatcher::Op::And;
756 }
else if (
s ==
"or") {
757 op = DataDescriptorMatcher::Op::Or;
758 }
else if (
s ==
"xor") {
759 op = DataDescriptorMatcher::Op::Xor;
760 }
else if (
s ==
"just") {
761 op = DataDescriptorMatcher::Op::Just;
762 }
else if (
s ==
"not") {
763 op = DataDescriptorMatcher::Op::Not;
797 metadata.back().cmdLineArgs.push_back(
s);
809 std::stringstream errstr;
810 errstr <<
"No string handling for argument '" << std::string(
str,
length) <<
"' in state " <<
states.back() << std::endl;
811 throw std::runtime_error(errstr.str());
898 return states.back() == o;
903 assert(
states.size() > 1);
933 std::vector<DataProcessorSpec>& workflow,
934 std::vector<DataProcessorInfo>& metadata,
943 bool hasFatalImportError =
false;
944 while (
s.peek() !=
'{') {
946 return !hasFatalImportError;
948 if (
s.fail() ||
s.bad()) {
949 throw std::runtime_error(
"Malformatted input workflow");
951 s.getline(
buf, 1024,
'\n');
956 if (strncmp(
buf,
"[ERROR] invalid workflow in", strlen(
"[ERROR] invalid workflow in")) == 0 ||
957 strncmp(
buf,
"[ERROR] error while setting up workflow", strlen(
"[ERROR] error while setting up workflow")) == 0 ||
958 strncmp(
buf,
"[ERROR] error parsing options of", strlen(
"[ERROR] error parsing options of")) == 0) {
959 hasFatalImportError =
true;
961 std::cout <<
buf << std::endl;
966 if (hasFatalImportError) {
969 rapidjson::Reader reader;
971 rapidjson::IStreamWrapper isw(
s);
973 bool ok = reader.Parse(isw, importer);
976 throw std::runtime_error(
"Error while parsing serialised workflow");
981 s.getline(
buf, 1024,
'\n');
985 O2_SIGNPOST_EVENT_EMIT(post_workflow_importer, sid,
"post import",
"Following leftover line found in input stream after parsing workflow: %{public}s",
buf);
992 std::vector<DataProcessorSpec>
const& workflow,
993 std::vector<DataProcessorInfo>
const& metadata,
996 rapidjson::OStreamWrapper osw(out);
997 rapidjson::PrettyWriter<rapidjson::OStreamWrapper>
w(osw);
1005 std::stringstream ss;
1006 ss << action.node->getOp();
1007 w.String(ss.str().c_str());
1008 if (action.node->getOp() == DataDescriptorMatcher::Op::Just ||
1009 action.node->getOp() == DataDescriptorMatcher::Op::Not) {
1010 return ChildAction::VisitLeft;
1012 return ChildAction::VisitBoth;
1037 w.Uint64(
ref.index);
1039 [&
w](
auto const&
value) {
1041 std::stringstream ss;
1043 w.String(ss.str().c_str());
1049 w.Key(
"descriptionRef");
1050 w.Uint64(
ref.index);
1052 [&
w](
auto const&
value) {
1053 w.Key(
"description");
1054 std::stringstream ss;
1056 w.String(ss.str().c_str());
1062 w.Key(
"subspecRef");
1063 w.Uint64(
ref.index);
1065 [&
w](
auto const&
value) {
1067 std::stringstream ss;
1069 w.Uint64(std::stoul(ss.str()));
1074 std::stringstream ss;
1076 w.String(ss.str().c_str());
1085 for (
auto& processor : workflow) {
1086 if (processor.name.rfind(
"internal-dpl", 0) == 0) {
1091 w.String(processor.name.c_str());
1095 for (
auto const& input : processor.inputs) {
1101 w.String(input.binding.c_str());
1102 if (
auto const* concrete = std::get_if<ConcreteDataMatcher>(&input.matcher)) {
1104 w.String(concrete->origin.str, strnlen(concrete->origin.str, 4));
1105 w.Key(
"description");
1106 w.String(concrete->description.str, strnlen(concrete->description.str, 16));
1108 w.Uint64(concrete->subSpec);
1113 }
else if (
auto const* matcher = std::get_if<DataDescriptorMatcher>(&input.matcher)) {
1119 w.Uint((
int)input.lifetime);
1120 if (input.metadata.empty() ==
false) {
1123 for (
auto& metadata : input.metadata) {
1126 w.String(metadata.name.c_str());
1129 w.String(
s.c_str());
1130 std::ostringstream oss;
1131 oss << metadata.defaultValue;
1132 w.Key(
"defaultValue");
1133 w.String(oss.str().c_str());
1135 w.String(metadata.help.c_str());
1146 for (
auto&
output : processor.outputs) {
1149 if (
output.binding.value.empty()) {
1151 w.String(autogenerated.c_str());
1153 w.String(
output.binding.value.c_str());
1158 w.Key(
"description");
1163 if (subSpec.has_value()) {
1169 if (
output.metadata.empty() ==
false) {
1172 for (
auto& metadata :
output.metadata) {
1175 w.String(metadata.name.c_str());
1178 w.String(
s.c_str());
1179 std::ostringstream oss;
1180 oss << metadata.defaultValue;
1181 w.Key(
"defaultValue");
1182 w.String(oss.str().c_str());
1184 w.String(metadata.help.c_str());
1195 for (
auto&
option : processor.options) {
1196 if (
option.name ==
"start-value-enumeration" ||
option.name ==
"end-value-enumeration" ||
option.name ==
"step-value-enumeration" ||
option.name ==
"orbit-offset-enumeration" ||
option.name ==
"orbit-multiplier-enumeration") {
1201 w.String(
option.name.c_str());
1204 w.String(
s.c_str());
1205 std::ostringstream oss;
1223 oss <<
option.defaultValue;
1226 w.Key(
"defaultValue");
1227 w.String(oss.str().c_str());
1229 w.String(
option.help.c_str());
1237 for (
auto&
label : processor.labels) {
1238 w.String(
label.value.c_str());
1243 for (
auto& metadatum : processor.metadata) {
1246 w.String(metadatum.key.c_str());
1248 w.String(metadatum.value.c_str());
1253 w.Int(processor.rank);
1255 w.Int(processor.nSlots);
1256 w.Key(
"inputTimeSliceId");
1257 w.Int(processor.inputTimeSliceId);
1258 w.Key(
"maxInputTimeslices");
1259 w.Int(processor.maxInputTimeslices);
1267 for (
auto& info : metadata) {
1270 w.String(info.name.c_str());
1271 w.Key(
"executable");
1272 w.String(info.executable.c_str());
1273 w.Key(
"cmdLineArgs");
1275 for (
auto& arg : info.cmdLineArgs) {
1276 w.String(arg.c_str());
1279 w.Key(
"workflowOptions");
1281 for (
auto&
option : info.workflowOptions) {
1284 w.String(
option.name.c_str());
1287 w.String(
s.c_str());
1288 std::ostringstream oss;
1289 oss <<
option.defaultValue;
1290 w.Key(
"defaultValue");
1291 w.String(oss.str().c_str());
1293 w.String(
option.help.c_str());
1299 for (
auto& channel : info.channels) {
1300 w.String(channel.c_str());
1308 w.String(commandInfo.
command.c_str());
header::DataOrigin origin
header::DataDescription description
std::unique_ptr< expressions::Node > node
unsigned short int uint16_t
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error s
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events d
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 option
char error[CURL_ERROR_SIZE]
#define O2_DECLARE_DYNAMIC_LOG(name)
#define O2_SIGNPOST_END(log, id, name, format,...)
#define O2_SIGNPOST_ID_GENERATE(name, log)
#define O2_SIGNPOST_EVENT_EMIT(log, id, name, format,...)
#define O2_SIGNPOST_START(log, id, name, format,...)
Something which can be matched against a header::DataDescription.
Something which can be matched against a header::DataOrigin.
Matcher on actual time, as reported in the DataProcessingHeader.
Something which can be matched against a header::SubSpecificationType.
GLsizei const GLfloat * value
GLuint GLsizei GLsizei * length
GLuint GLsizei const GLchar * label
GLenum GLuint GLenum GLsizei const GLchar * buf
GLubyte GLubyte GLubyte GLubyte w
std::variant< OriginValueMatcher, DescriptionValueMatcher, SubSpecificationTypeValueMatcher, std::unique_ptr< DataDescriptorMatcher >, ConstantValueMatcher, StartTimeValueMatcher > Node
Defining ITS Vertex explicitly as messageable.
Lifetime
Possible Lifetime of objects being exchanged by the DPL.
std::string to_string(gsl::span< T, Size > span)
void merge(CommandInfo const &other)
header::DataOrigin origin
header::DataDescription description
static std::string describe(InputSpec const &spec)
static ConcreteDataTypeMatcher asConcreteDataTypeMatcher(OutputSpec const &spec)
static std::optional< header::DataHeader::SubSpecificationType > getOptionalSubSpec(OutputSpec const &spec)
Get the subspec, if available.
static std::optional< framework::ConcreteDataMatcher > optionalConcreteDataMatcherFrom(data_matcher::DataDescriptorMatcher const &matcher)
static void write(std::ostream &o, Variant const &v)
std::vector< DataProcessorInfo > & metadata
header::DataDescription description
header::DataOrigin origin
friend std::ostream & operator<<(std::ostream &s, State state)
void enter(char const *what)
bool EndArray(SizeType count)
std::vector< State > states
bool EndObject(SizeType memberCount)
std::vector< ConfigParamSpec > outputOptions
@ IN_DATAPROCESSOR_INFO_ARG
@ IN_DATAPROCESSOR_INFO_CHANNELS
@ IN_DATAPROCESSOR_INFO_EXECUTABLE
@ IN_DATAPROCESSOR_MAX_TIMESLICES
@ IN_DATAPROCESSOR_INFO_ARGS
@ IN_DATAPROCESSOR_N_SLOTS
@ IN_DATAPROCESSOR_INFO_NAME
@ IN_DATAPROCESSOR_INFO_CHANNEL
@ IN_DATAPROCESSOR_TIMESLICE_ID
@ IN_INPUT_MATCHER_OPERATION
@ IN_INPUT_DESCRIPTION_REF
bool Key(const Ch *str, SizeType length, bool copy)
std::string optionDefault
ConfigParamKind optionKind
std::vector< DataProcessorSpec > & dataProcessors
std::string metadatumValue
std::vector< ConfigParamSpec > inputOptions
bool String(const Ch *str, SizeType length, bool copy)
WorkflowImporter(std::vector< DataProcessorSpec > &o, std::vector< DataProcessorInfo > &m, CommandInfo &c)
std::vector< data_matcher::Node > inputMatcherNodes
static void dump(std::ostream &o, std::vector< DataProcessorSpec > const &workflow, std::vector< DataProcessorInfo > const &metadata, CommandInfo const &commandInfo)
static bool import(std::istream &s, std::vector< DataProcessorSpec > &workflow, std::vector< DataProcessorInfo > &metadata, CommandInfo &command)
A typesafe reference to an element of the context.
static void walk(DataDescriptorMatcher const &top, EDGEWALKER edgeWalker, LEAFWALKER leafWalker)
From https://en.cppreference.com/w/cpp/utility/variant/visit.
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"