Project
Loading...
Searching...
No Matches
Plugin.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11//
12#include "Framework/Plugins.h"
18#include <InfoLogger/InfoLogger.hxx>
19#include <fairlogger/Logger.h>
20#include <fairmq/Device.h>
21#include <fairmq/shmem/Monitor.h>
22#include <fairmq/shmem/Common.h>
23#include <fairmq/ProgOptions.h>
24
25using AliceO2::InfoLogger::InfoLogger;
26using AliceO2::InfoLogger::InfoLoggerContext;
27
28using namespace o2::framework;
29
30namespace o2::framework
31{
33template <>
34struct ServiceKindExtractor<InfoLoggerContext> {
36};
37
38} // namespace o2::framework
39
41};
42
45 {
46 return new ServiceSpec{
47 .name = "infologger-contex",
48 .init = CommonServices::simpleServiceInit<InfoLoggerContext, InfoLoggerContext>(),
50 .start = [](ServiceRegistryRef services, void* service) {
51 auto& infoLoggerContext = services.get<InfoLoggerContext>();
52 auto run = services.get<RawDeviceService>().device()->fConfig->GetProperty<std::string>("runNumber", "unspecified");
53 infoLoggerContext.setField(InfoLoggerContext::FieldName::Run, run);
54 auto partition = services.get<RawDeviceService>().device()->fConfig->GetProperty<std::string>("environment_id", "unspecified");
55 infoLoggerContext.setField(InfoLoggerContext::FieldName::Partition, partition);
56 },
57 .kind = ServiceKind::Serial};
58 }
59};
60
61// Creates the sink for FairLogger / InfoLogger integration
62auto createInfoLoggerSinkHelper(InfoLogger* logger, InfoLoggerContext* ctx)
63{
64 return [logger,
65 ctx](const std::string& content, const fair::LogMetaData& metadata) {
66 // translate FMQ metadata
67 InfoLogger::InfoLogger::Severity severity = InfoLogger::Severity::Undefined;
68 int level = InfoLogger::undefinedMessageOption.level;
69
70 switch (metadata.severity) {
71 case fair::Severity::fatal:
72 severity = InfoLogger::Severity::Fatal;
73 level = 1;
74 break;
75 case fair::Severity::critical:
76 severity = InfoLogger::Severity::Error;
77 level = 1;
78 break;
79 case fair::Severity::error:
80 severity = InfoLogger::Severity::Error;
81 level = 2;
82 break;
83 case fair::Severity::alarm:
84 severity = InfoLogger::Severity::Warning;
85 level = 6;
86 break;
87 case fair::Severity::important:
88 severity = InfoLogger::Severity::Info;
89 level = 7;
90 break;
91 case fair::Severity::warn:
92 severity = InfoLogger::Severity::Warning;
93 level = 11;
94 break;
95 case fair::Severity::state:
96 severity = InfoLogger::Severity::Info;
97 level = 12;
98 break;
99 case fair::Severity::info:
100 severity = InfoLogger::Severity::Info;
101 level = 13;
102 break;
103 case fair::Severity::debug:
104 severity = InfoLogger::Severity::Debug;
105 level = 14;
106 break;
107 case fair::Severity::detail:
108 severity = InfoLogger::Severity::Debug;
109 level = 15;
110 break;
111 case fair::Severity::debug1:
112 severity = InfoLogger::Severity::Debug;
113 level = 16;
114 break;
115 case fair::Severity::debug2:
116 severity = InfoLogger::Severity::Debug;
117 level = 17;
118 break;
119 case fair::Severity::debug3:
120 severity = InfoLogger::Severity::Debug;
121 level = 18;
122 break;
123 case fair::Severity::debug4:
124 severity = InfoLogger::Severity::Debug;
125 level = 19;
126 break;
127 case fair::Severity::trace:
128 severity = InfoLogger::Severity::Debug;
129 level = 21;
130 break;
131 case fair::Severity::nolog: // discard
132 return;
133 }
134
135 if (logger) {
136 logger->log({severity,
137 level,
138 InfoLogger::undefinedMessageOption.errorCode,
139 std::string(metadata.file).c_str(),
140 atoi(std::string(metadata.line).c_str())},
141 *ctx, "%s", content.c_str());
142 }
143 };
144};
145
148 {
149 return new ServiceSpec{
150 .name = "infologger",
151 .init = [](ServiceRegistryRef services, DeviceState&, fair::mq::ProgOptions& options) -> ServiceHandle {
152 auto infoLoggerMode = options.GetPropertyAsString("infologger-mode");
153 auto infoLoggerSeverity = options.GetPropertyAsString("infologger-severity");
154 if (infoLoggerSeverity.empty() == false && options.GetPropertyAsString("infologger-mode") == "") {
155 LOGP(info, "Using O2_INFOLOGGER_MODE=infoLoggerD since infologger-severity is set");
156 infoLoggerMode = "infoLoggerD";
157 }
158 if (infoLoggerMode != "") {
159 setenv("O2_INFOLOGGER_MODE", infoLoggerMode.c_str(), 1);
160 }
161 char const* infoLoggerEnv = getenv("O2_INFOLOGGER_MODE");
162 if (infoLoggerEnv == nullptr || strcmp(infoLoggerEnv, "none") == 0) {
163 return ServiceHandle{.hash = TypeIdHelpers::uniqueId<MissingService>(),
164 .instance = nullptr,
165 .kind = ServiceKind::Serial,
166 .name = "infologger"};
167 }
168 InfoLogger* infoLoggerService = nullptr;
169 try {
170 infoLoggerService = new InfoLogger;
171 } catch (...) {
172 LOGP(error, "Unable to initialise InfoLogger with O2_INFOLOGGER_MODE={}.", infoLoggerMode);
173 return ServiceHandle{.hash = TypeIdHelpers::uniqueId<MissingService>(),
174 .instance = nullptr,
175 .kind = ServiceKind::Serial,
176 .name = "infologger"};
177 }
178 auto infoLoggerContext = &services.get<InfoLoggerContext>();
179 // Only print the first 10 characters and the last 18 if the
180 // string length is greater than 32 bytes.
181 auto truncate = [](std::string in) -> std::string {
182 if (in.size() < 32) {
183 return in;
184 }
185 char name[32];
186 memcpy(name, in.data(), 10);
187 name[10] = '.';
188 name[11] = '.';
189 name[12] = '.';
190 memcpy(name + 13, in.data() + in.size() - 18, 18);
191 name[31] = 0;
192 return name;
193 };
194 infoLoggerContext->setField(InfoLoggerContext::FieldName::Facility, truncate(services.get<DeviceSpec const>().name));
195 infoLoggerContext->setField(InfoLoggerContext::FieldName::System, std::string("DPL"));
196 infoLoggerService->setContext(*infoLoggerContext);
197
198 if (infoLoggerSeverity != "") {
199 fair::Logger::AddCustomSink("infologger", infoLoggerSeverity, createInfoLoggerSinkHelper(infoLoggerService, infoLoggerContext));
200 }
201 return ServiceHandle{.hash = TypeIdHelpers::uniqueId<InfoLogger>(),
202 .instance = infoLoggerService,
203 .kind = ServiceKind::Serial,
204 .name = "infologger"};
205 },
206 .configure = CommonServices::noConfiguration(),
207 .kind = ServiceKind::Serial};
208 }
209};
210
auto createInfoLoggerSinkHelper(InfoLogger *logger, InfoLoggerContext *ctx)
Definition Plugin.cxx:62
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 Allow RTC with slave GPUReconstruction instances with optConstexpr and optSpecialcode Maximum number of RTC cache files per backend in the cache the oldest are Prepend RTC compilation commands by this string Load a parameter object containing the launch bounds from a file h configStandalone Processing proc_param TPC Cluster Z Error Parameterization h configStandalone Processing settings for neural network proc_nn std::string Specify inference device(cpu(default), rocm, cuda)") AddOption(nnInferenceDeviceId
char error[CURL_ERROR_SIZE]
#define DEFINE_DPL_PLUGIN_INSTANCE(NAME, KIND)
Definition Plugins.h:112
#define DEFINE_DPL_PLUGINS_END
Definition Plugins.h:115
#define DEFINE_DPL_PLUGINS_BEGIN
Definition Plugins.h:107
GLuint const GLchar * name
Definition glcorearb.h:781
GLint level
Definition glcorearb.h:275
GLenum GLenum severity
Definition glcorearb.h:2513
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
ServiceKind
The kind of service we are asking for.
o2::framework::ServiceSpec * create() final
Definition Plugin.cxx:44
o2::framework::ServiceSpec * create() final
Definition Plugin.cxx:147
static ServiceConfigureCallback noConfiguration()
std::string name
The name of the associated DataProcessorSpec.
Definition DeviceSpec.h:50
Running state information of a given device.
Definition DeviceState.h:34
unsigned int hash
Unique hash associated to the type of service.
static constexpr ServiceKind kind
std::string name
Name of the service.