Project
Loading...
Searching...
No Matches
TimingSpec.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
18
19#include <vector>
20#include <gsl/gsl>
21#include "Framework/Output.h"
22#include "Framework/Task.h"
26
27namespace of = o2::framework;
28
29namespace o2
30{
31namespace mid
32{
33
35{
36 public:
37 TimingDeviceDPL(int16_t localToBC, std::vector<of::OutputSpec> outputSpecs) : mLocalToBC(localToBC)
38 {
39 mOutputs = specs::buildOutputs(outputSpecs);
40 }
41
43 {
44 }
45
47 {
48
49 auto inRofs = specs::getRofs(pc, "mid_timing_in");
50 std::array<std::vector<ROFRecord>, NEvTypes> outRofs;
51
52 for (size_t idx = 0; idx < NEvTypes; ++idx) {
53 if (idx == static_cast<size_t>(EventType::Calib)) {
54 // Delays do not apply to triggered events
55 outRofs[idx].insert(outRofs[idx].end(), inRofs[idx].begin(), inRofs[idx].end());
56 } else {
57 for (auto rof : inRofs[idx]) {
58 applyElectronicsDelay(rof.interactionRecord.orbit, rof.interactionRecord.bc, mLocalToBC, mMaxBunches);
59 outRofs[idx].emplace_back(rof);
60 }
61 }
62 pc.outputs().snapshot(mOutputs[idx], outRofs[idx]);
63 }
64 }
65
66 private:
67 int16_t mLocalToBC = 0;
68 uint16_t mMaxBunches = constants::lhc::LHCMaxBunches;
69 std::vector<of::Output> mOutputs;
70};
71
72of::DataProcessorSpec getTimingSpec(int localToBC, std::string_view inRofDesc)
73{
74 auto inputSpecs = specs::buildInputSpecs("mid_timing_in", "", inRofDesc, "", false);
75 auto outputSpecs = specs::buildOutputSpecs("mid_timing_out", "TDATAROF");
76
78 "MIDTiming",
79 {inputSpecs},
80 {outputSpecs},
81 of::AlgorithmSpec{of::adaptFromTask<o2::mid::TimingDeviceDPL>(static_cast<int16_t>(localToBC), outputSpecs)}};
82}
83} // namespace mid
84} // namespace o2
Utilities for MID Column Data Specs.
Delay parameters for MID electronics.
Definition of the MID event record.
Device to synchronize MID clock with collision BC.
void snapshot(const Output &spec, T const &object)
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
TimingDeviceDPL(int16_t localToBC, std::vector< of::OutputSpec > outputSpecs)
void init(o2::framework::InitContext &ic)
void run(o2::framework::ProcessingContext &pc)
GLuint GLuint end
Definition glcorearb.h:469
constexpr int LHCMaxBunches
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< framework::InputSpec > buildInputSpecs(std::string_view dataBind, std::string_view dataDesc, bool useMC)
std::vector< framework::Output > buildOutputs(std::vector< framework::OutputSpec > outputSpecs)
std::vector< framework::OutputSpec > buildOutputSpecs(std::string_view bind, std::string_view description)
std::array< gsl::span< const ROFRecord >, NEvTypes > getRofs(framework::ProcessingContext &pc, std::string_view dataBind)
void applyElectronicsDelay(uint32_t &orbit, uint16_t &bc, int16_t delay, uint16_t maxBunches=constants::lhc::LHCMaxBunches)
framework::DataProcessorSpec getTimingSpec(int localToBC, std::string_view inRofDesc)
constexpr uint32_t NEvTypes
Definition ROFRecord.h:37
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...