Skip to content

Commit 35f4857

Browse files
matthiasrichtersawenzel
authored andcommitted
Added command line option to specify the OCDB configuration
- the OCDB URI can now be specified as command line option --ocdb, the existence of ALIHLT_HCDBDIR is checked otherwise - logging through the FairMQ logging channel - minor code cleanup
1 parent e32336f commit 35f4857

8 files changed

Lines changed: 73 additions & 20 deletions

File tree

Utilities/aliceHLTwrapper/doc/AliceHLTWrapperDevice.1.in

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,52 @@ of multiple strings
6060
.TP 2
6161
.B --run \fIn\fR
6262
Run number
63+
.TP 2
64+
.B --ocdb \fIuri\fR
65+
Set the OCDB URI and override the value of environment variable ALIHLT_HCDBDIR
6366

6467
.SS Other Options
6568
.B --poll-period \fIperiod\fR
6669
Polling period on the input channel
70+
.B --output-mode \fImode\fR
71+
The output mode of the device, default is O2 format (3)
72+
.RS 2
73+
.B 0
74+
- HOMER format
75+
.br
76+
.B 1
77+
- blocks in multiple messages
78+
.br
79+
.B 2
80+
- blocks concatenated in one message (default)
81+
.br
82+
.B 3
83+
- O2 format
84+
.RE
85+
86+
.SH FEATURES
87+
.SS Message channels
88+
The device supports input and output channels with the names
89+
.IR --data-in /
90+
.I --data-out
91+
respectively. All input channels are treated equally and the device expects messages
92+
from all channels before data is processed.
93+
94+
If no input channel is specified the device will run in a self-triggered mode
95+
and call the component processing repeatedly with the period specified by
96+
.IR --poll-period .
97+
98+
.SS Configuration database
99+
HLT components need the Alice OCDB to load the configuration. The path to the OCDB
100+
must be set in environment variable
101+
.B ALIHLT_HCDBDIR
102+
or via option
103+
.BR --ocdb .
67104

68-
.SH CONFIGURATION DATABASE
69-
HLT components need the Alice OCDB to load the configuration. The path to the OCDB must be set in environment variable \fBALIHLT_HCDBDIR\fR.
105+
.SS Heartbeat information
106+
The device interprets Heartbeat frame data blocks at the input channel. If this
107+
information is available at the input, all output blocks will be wrapped into
108+
Haertbeat frames.
70109

71110
.SH EXAMPLES
72111
.B AliceHLTWrapperDevice

Utilities/aliceHLTwrapper/include/aliceHLTwrapper/Component.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//-*- Mode: C++ -*-
12
// Copyright CERN and copyright holders of ALICE O2. This software is
23
// distributed under the terms of the GNU General Public License v3 (GPL
34
// Version 3), copied verbatim in the file "COPYING".
@@ -8,8 +9,6 @@
89
// granted to it by virtue of its status as an Intergovernmental Organization
910
// or submit itself to any jurisdiction.
1011

11-
//-*- Mode: C++ -*-
12-
1312
#ifndef COMPONENT_H
1413
#define COMPONENT_H
1514
//****************************************************************************
@@ -63,6 +62,7 @@ class SystemInterface;
6362
/// Currently, all HLT components need configuration and
6463
/// calibration data from OCDB; OCDB interface needs to
6564
/// be initialized with run number
65+
/// --ocdb uri of the OCDB, e.g. 'local://./OCDB'
6666
/// --msgsize size of the output buffer in byte
6767
/// This overrides the default behavior where output buffer
6868
/// size is determined from the input size and properties
@@ -71,6 +71,7 @@ class SystemInterface;
7171
/// 0 HOMER format
7272
/// 1 blocks in multiple messages
7373
/// 2 blocks concatenated in one message (default)
74+
/// 3 O2 data format (default)
7475
///
7576
class Component {
7677
public:
@@ -95,6 +96,7 @@ class Component {
9596
OptionKeyComponent,
9697
OptionKeyParameter,
9798
OptionKeyRun,
99+
OptionKeyOCDB,
98100
OptionKeyMsgsize,
99101
OptionKeyOutputMode,
100102
OptionKeyInstanceId,
@@ -106,6 +108,7 @@ class Component {
106108
"component",
107109
"parameter",
108110
"run",
111+
"ocdb",
109112
"msgsize",
110113
"output-mode",
111114
"instance-id",

Utilities/aliceHLTwrapper/include/aliceHLTwrapper/EventSampler.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//-*- Mode: C++ -*-
12
// Copyright CERN and copyright holders of ALICE O2. This software is
23
// distributed under the terms of the GNU General Public License v3 (GPL
34
// Version 3), copied verbatim in the file "COPYING".
@@ -8,8 +9,6 @@
89
// granted to it by virtue of its status as an Intergovernmental Organization
910
// or submit itself to any jurisdiction.
1011

11-
//-*- Mode: C++ -*-
12-
1312
#ifndef EVENTSAMPLER_H
1413
#define EVENTSAMPLER_H
1514
//****************************************************************************

Utilities/aliceHLTwrapper/include/aliceHLTwrapper/HOMERFactory.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//-*- Mode: C++ -*-
12
// Copyright CERN and copyright holders of ALICE O2. This software is
23
// distributed under the terms of the GNU General Public License v3 (GPL
34
// Version 3), copied verbatim in the file "COPYING".
@@ -8,8 +9,6 @@
89
// granted to it by virtue of its status as an Intergovernmental Organization
910
// or submit itself to any jurisdiction.
1011

11-
//-*- Mode: C++ -*-
12-
1312
#ifndef HOMERFACTORY_H
1413
#define HOMERFACTORY_H
1514
//****************************************************************************

Utilities/aliceHLTwrapper/include/aliceHLTwrapper/MessageFormat.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//-*- Mode: C++ -*-
12
// Copyright CERN and copyright holders of ALICE O2. This software is
23
// distributed under the terms of the GNU General Public License v3 (GPL
34
// Version 3), copied verbatim in the file "COPYING".
@@ -8,8 +9,6 @@
89
// granted to it by virtue of its status as an Intergovernmental Organization
910
// or submit itself to any jurisdiction.
1011

11-
//-*- Mode: C++ -*-
12-
1312
#ifndef MESSAGEFORMAT_H
1413
#define MESSAGEFORMAT_H
1514
//****************************************************************************

Utilities/aliceHLTwrapper/include/aliceHLTwrapper/SystemInterface.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//-*- Mode: C++ -*-
12
// Copyright CERN and copyright holders of ALICE O2. This software is
23
// distributed under the terms of the GNU General Public License v3 (GPL
34
// Version 3), copied verbatim in the file "COPYING".
@@ -8,8 +9,6 @@
89
// granted to it by virtue of its status as an Intergovernmental Organization
910
// or submit itself to any jurisdiction.
1011

11-
//-*- Mode: C++ -*-
12-
1312
#ifndef SYSTEMINTERFACE_H
1413
#define SYSTEMINTERFACE_H
1514
//****************************************************************************

Utilities/aliceHLTwrapper/include/aliceHLTwrapper/WrapperDevice.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//-*- Mode: C++ -*-
12
// Copyright CERN and copyright holders of ALICE O2. This software is
23
// distributed under the terms of the GNU General Public License v3 (GPL
34
// Version 3), copied verbatim in the file "COPYING".
@@ -8,8 +9,6 @@
89
// granted to it by virtue of its status as an Intergovernmental Organization
910
// or submit itself to any jurisdiction.
1011

11-
//-*- Mode: C++ -*-
12-
1312
#ifndef WRAPPERDEVICE_H
1413
#define WRAPPERDEVICE_H
1514
//****************************************************************************

Utilities/aliceHLTwrapper/src/Component.cxx

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "aliceHLTwrapper/Component.h"
2929
#include "aliceHLTwrapper/AliHLTDataTypes.h"
3030
#include "aliceHLTwrapper/SystemInterface.h"
31+
#include "FairMQLogger.h"
3132

3233
#include <cstdlib>
3334
#include <cerrno>
@@ -40,7 +41,6 @@
4041
using namespace ALICE::HLT;
4142
using namespace o2::AliceHLT;
4243

43-
using std::cerr;
4444
using std::endl;
4545
using std::string;
4646
using std::unique_ptr;
@@ -75,8 +75,11 @@ bpo::options_description Component::GetOptionsDescription()
7575
bpo::value<string>()->default_value(""),
7676
"component command line parameter")
7777
((std::string(OptionKeys[OptionKeyRun]) + ",r").c_str(),
78-
bpo::value<string>()->default_value("-1"),
78+
bpo::value<string>()->required(),
7979
"run number")
80+
((std::string(OptionKeys[OptionKeyOCDB])).c_str(),
81+
bpo::value<string>(),
82+
"ocdb uri")
8083
((std::string(OptionKeys[OptionKeyMsgsize]) + ",s").c_str(),
8184
bpo::value<string>()->default_value("0"),
8285
"maximum size of output buffer/msg")
@@ -126,6 +129,12 @@ int Component::init(int argc, char** argv)
126129
case OptionKeyRun:
127130
stringstream(varmap[OptionKeys[option]].as<string>()) >> runNumber;
128131
break;
132+
case OptionKeyOCDB:
133+
if (getenv("ALIHLT_HCDBDIR") != nullptr) {
134+
LOG(WARN) << "overriding value of ALICEHLT_HCDBDIR by --ocdb command option";
135+
}
136+
setenv("ALIHLT_HCDBDIR", varmap[OptionKeys[option]].as<string>().c_str(), 1);
137+
break;
129138
case OptionKeyMsgsize: {
130139
unsigned size = 0;
131140
stringstream(varmap[OptionKeys[option]].as<string>()) >> size;
@@ -149,10 +158,17 @@ int Component::init(int argc, char** argv)
149158
if (varmap.count(OptionKeys[OptionKeyLibrary]) == 0 ||
150159
varmap.count(OptionKeys[OptionKeyComponent]) == 0 ||
151160
runNumber < 0) {
152-
cerr << "missing argument" << endl;
161+
LOG(ERROR) << "missing argument, required options: library, component,run";
153162
return -EINVAL;
154163
}
155164

165+
// check the OCDB URI
166+
// the HLT code relies on ALIHLT_HCDBDIR environment variable to be set
167+
if (!getenv("ALIHLT_HCDBDIR")) {
168+
LOG(ERROR) << "FATAL: OCDB URI is needed, use option --ocdb or environment variable ALIHLT_HCDBDIR";
169+
return -ENOKEY;
170+
}
171+
156172
int iResult = 0;
157173
// TODO: make the SystemInterface a singleton
158174
unique_ptr<ALICE::HLT::SystemInterface> iface(new SystemInterface);
@@ -229,7 +245,7 @@ int Component::process(vector<MessageFormat::BufferDesc_t>& dataArray,
229245
vector<BlockDescriptor>& inputBlocks = mFormatHandler.getBlockDescriptors();
230246
unsigned nofInputBlocks = inputBlocks.size();
231247
if (dataArray.size() > 0 && nofInputBlocks == 0 && mFormatHandler.getEvtDataList().size() == 0) {
232-
cerr << "warning: none of " << dataArray.size() << " input buffer(s) recognized as valid input" << endl;
248+
LOG(ERROR) << "warning: none of " << dataArray.size() << " input buffer(s) recognized as valid input";
233249
}
234250
dataArray.clear();
235251

@@ -284,7 +300,7 @@ int Component::process(vector<MessageFormat::BufferDesc_t>& dataArray,
284300
&pEventDoneData);
285301
if (outputBufferSize > 0) {
286302
if (outputBufferSize > mOutputBuffer.size()) {
287-
cerr << "fatal error: component writing beyond buffer capacity" << endl;
303+
LOG(ERROR) << "FATAL: fatal error: component writing beyond buffer capacity";
288304
return -EFAULT;
289305
} else if (outputBufferSize < mOutputBuffer.size()) {
290306
mOutputBuffer.resize(outputBufferSize);
@@ -348,7 +364,7 @@ int Component::process(vector<MessageFormat::BufferDesc_t>& dataArray,
348364
memcpy(pFiltered, pOutputBlock, sizeof(AliHLTComponentBlockData));
349365
pFiltered++;
350366
} else {
351-
cerr << "Inconsistent data reference in output block " << blockIndex << endl;
367+
LOG(ERROR) << "Inconsistent data reference in output block " << blockIndex;
352368
}
353369
}
354370
evtData.fBlockCnt=validBlocks;

0 commit comments

Comments
 (0)