Project
Loading...
Searching...
No Matches
ProcessingHelpers.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 <string>
13
14#include <fairmq/Device.h>
15#include "Headers/DataHeader.h"
16#include "Framework/Logger.h"
24
26
27using namespace o2::framework;
28using namespace o2::tpc;
29
30// taken from CTFWriterSpec, TODO: should this be put to some more general location?
32{
33 const std::string NAStr = "NA";
34
35 uint64_t run = 0;
36 const auto& tinfo = pc.services().get<o2::framework::TimingInfo>();
37 if (tinfo.runNumber != 0) {
38 run = tinfo.runNumber;
39 }
40 // check runNumber with FMQ property, if set, override DH number
41 {
42 auto runNStr = pc.services().get<RawDeviceService>().device()->fConfig->GetProperty<std::string>("runNumber", NAStr);
43 if (runNStr != NAStr) {
44 size_t nc = 0;
45 long runNProp = 0;
46 try {
47 runNProp = std::stol(runNStr, &nc);
48 } catch (...) {
49 nc = (size_t)-1; // makes the next check fail if stol throws when it cannot parse the number
50 }
51 if (nc != runNStr.size()) {
52 LOGP(error, "Property runNumber={} is provided but is not a number, ignoring", runNStr);
53 } else {
54 run = runNProp;
55 }
56 }
57 }
58
59 return run;
60}
61
66
71
76
78{
79 return getTimeStamp(orbitReset, getFirstTForbit(pc));
80}
81
82uint64_t processing_helpers::getTimeStamp(const Long64_t orbitReset, const uint32_t tfOrbitFirst)
83{
84 const long tPrec = orbitReset + tfOrbitFirst * o2::constants::lhc::LHCOrbitMUS; // microsecond-precise time stamp
85 return tPrec;
86}
87
92
94{
95 auto tv = pc.inputs().get<std::vector<Long64_t>*>("orbitreset");
96 const auto orbitReset = tv->front();
97 return orbitReset;
98}
Header to collect LHC related constants.
decltype(auto) get(R binding, int part=0) const
InputRecord & inputs()
The inputs associated with this processing context.
ServiceRegistryRef services()
The services registry associated with this processing context.
constexpr double LHCOrbitMUS
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
uint32_t getCurrentTF(o2::framework::ProcessingContext &pc)
Long64_t getOrbitReset(o2::framework::ProcessingContext &pc)
uint32_t getFirstTForbit(o2::framework::ProcessingContext &pc)
uint64_t getTimeStamp(o2::framework::ProcessingContext &pc)
uint64_t getRunNumber(o2::framework::ProcessingContext &pc)
uint64_t getCreationTime(o2::framework::ProcessingContext &pc)
Global TPC definitions and constants.
Definition SimTraits.h:167