Project
Loading...
Searching...
No Matches
tfidinfo-writer-workflow.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
16
17using namespace o2::framework;
18
19void customize(std::vector<o2::framework::CompletionPolicy>& policies)
20{
21 // ordered policies for the writers
22 policies.push_back(CompletionPolicyHelpers::consumeWhenAllOrdered(".*tfid-info-writer.*"));
23}
24
25// we need to add workflow options before including Framework/runDataProcessing
26void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
27{
28 // option allowing to set parameters
29 std::vector<ConfigParamSpec> options{ConfigParamSpec{"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings"}}};
30
31 std::swap(workflowOptions, options);
32}
33
36#include "Framework/Task.h"
42#include <vector>
43#include <TFile.h>
44
46{
47 public:
48 ~TFIDInfoWriter() override = default;
49
51 {
52 mOutFileName = ic.options().get<std::string>("tfidinfo-file-name");
53 }
54
56 {
57 const auto& tinfo = pc.services().get<o2::framework::TimingInfo>();
58 if (tinfo.globalRunNumberChanged) { // new run is starting
59 auto v = pc.inputs().get<std::vector<Long64_t>*>("orbitReset");
60 mOrbitReset = (*v)[0];
61 }
62 o2::base::TFIDInfoHelper::fillTFIDInfo(pc, mData.emplace_back());
63 }
64
66 {
68 TFile fl(mOutFileName.c_str(), "recreate");
69 fl.WriteObjectAny(&mData, "std::vector<o2::dataformats::TFIDInfo>", "tfidinfo");
70 pcstream.SetFile(&fl);
71 for (const auto& info : mData) {
72 long ts = (mOrbitReset + long(info.firstTForbit * o2::constants::lhc::LHCOrbitMUS)) / 1000;
73 pcstream << "tfidTree"
74 << "tfidinfo=" << info << "ts=" << ts << "\n";
75 }
76 pcstream.Close();
77 LOGP(info, "Wrote tfidinfo vector and tfidTree with {} entries to {}", mData.size(), fl.GetName());
78 }
79
80 private:
81 long mOrbitReset = 0;
82 std::string mOutFileName{};
83 std::vector<o2::dataformats::TFIDInfo> mData;
84};
85
87{
88 WorkflowSpec wf;
89 o2::conf::ConfigurableParam::updateFromString(cfgc.options().get<std::string>("configKeyValues"));
90 wf.emplace_back(DataProcessorSpec{"tfid-info-writer",
91 {{"orbitReset", "CTP", "ORBITRESET", 0, Lifetime::Condition, ccdbParamSpec("CTP/Calib/OrbitReset")}},
92 std::vector<OutputSpec>{},
93 AlgorithmSpec{adaptFromTask<TFIDInfoWriter>()},
94 Options{{"tfidinfo-file-name", VariantType::String, o2::base::NameConf::getTFIDInfoFileName(), {"output file for TFIDInfo"}}}});
95 return wf;
96}
Header to collect LHC related constants.
Definition of the Names Generator class.
void init(o2::framework::InitContext &ic) final
void endOfStream(EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
~TFIDInfoWriter() override=default
void run(o2::framework::ProcessingContext &pc) final
static std::string getTFIDInfoFileName(const std::string_view prefix="o2")
Definition NameConf.cxx:104
static void updateFromString(std::string const &)
ConfigParamRegistry & options() const
const GLdouble * v
Definition glcorearb.h:832
constexpr double LHCOrbitMUS
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< ConfigParamSpec > ccdbParamSpec(std::string const &path, int runDependent, std::vector< CCDBMetadata > metadata={}, int qrate=0)
std::vector< DataProcessorSpec > WorkflowSpec
static void fillTFIDInfo(o2::framework::ProcessingContext &pc, o2::dataformats::TFIDInfo &ti)
static CompletionPolicy consumeWhenAllOrdered(const char *name, CompletionPolicy::Matcher matcher)
as consumeWhenAll, but ensures that records are processed with incremental timeSlice (DataHeader::sta...
WorkflowSpec defineDataProcessing(ConfigContext const &cfgc)
void customize(std::vector< o2::framework::CompletionPolicy > &policies)