-
Notifications
You must be signed in to change notification settings - Fork 494
Expand file tree
/
Copy pathProcessingHelpers.cxx
More file actions
98 lines (84 loc) · 3.15 KB
/
ProcessingHelpers.cxx
File metadata and controls
98 lines (84 loc) · 3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#include <string>
#include <fairmq/Device.h>
#include "Headers/DataHeader.h"
#include "Framework/Logger.h"
#include "Framework/ProcessingContext.h"
#include "Framework/TimingInfo.h"
#include "Framework/RawDeviceService.h"
#include "Framework/DataRefUtils.h"
#include "Framework/InputRecord.h"
#include "Framework/ServiceRegistry.h"
#include "CommonConstants/LHCConstants.h"
#include "TPCWorkflow/ProcessingHelpers.h"
using namespace o2::framework;
using namespace o2::tpc;
// taken from CTFWriterSpec, TODO: should this be put to some more general location?
uint64_t processing_helpers::getRunNumber(ProcessingContext& pc)
{
const std::string NAStr = "NA";
uint64_t run = 0;
const auto& tinfo = pc.services().get<o2::framework::TimingInfo>();
if (tinfo.runNumber != 0) {
run = tinfo.runNumber;
}
// check runNumber with FMQ property, if set, override DH number
{
auto runNStr = pc.services().get<RawDeviceService>().device()->fConfig->GetProperty<std::string>("runNumber", NAStr);
if (runNStr != NAStr) {
size_t nc = 0;
long runNProp = 0;
try {
runNProp = std::stol(runNStr, &nc);
} catch (...) {
nc = (size_t)-1; // makes the next check fail if stol throws when it cannot parse the number
}
if (nc != runNStr.size()) {
LOGP(error, "Property runNumber={} is provided but is not a number, ignoring", runNStr);
} else {
run = runNProp;
}
}
}
return run;
}
uint32_t processing_helpers::getCurrentTF(o2::framework::ProcessingContext& pc)
{
return pc.services().get<o2::framework::TimingInfo>().tfCounter;
}
uint32_t processing_helpers::getFirstTForbit(o2::framework::ProcessingContext& pc)
{
return pc.services().get<o2::framework::TimingInfo>().firstTForbit;
}
uint64_t processing_helpers::getCreationTime(o2::framework::ProcessingContext& pc)
{
return pc.services().get<o2::framework::TimingInfo>().creation;
}
uint64_t processing_helpers::getTimeStamp(o2::framework::ProcessingContext& pc, const Long64_t orbitReset)
{
return getTimeStamp(orbitReset, getFirstTForbit(pc));
}
uint64_t processing_helpers::getTimeStamp(const Long64_t orbitReset, const uint32_t tfOrbitFirst)
{
const long tPrec = orbitReset + tfOrbitFirst * o2::constants::lhc::LHCOrbitMUS; // microsecond-precise time stamp
return tPrec;
}
uint64_t processing_helpers::getTimeStamp(o2::framework::ProcessingContext& pc)
{
return getTimeStamp(pc, getOrbitReset(pc));
}
Long64_t processing_helpers::getOrbitReset(o2::framework::ProcessingContext& pc)
{
auto tv = pc.inputs().get<std::vector<Long64_t>*>("orbitreset");
const auto orbitReset = tv->front();
return orbitReset;
}