Project
Loading...
Searching...
No Matches
digits-r23-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
20#include "Framework/Lifetime.h"
21#include "Framework/Output.h"
22#include "Framework/Task.h"
27#include <fmt/format.h>
28#include "Framework/Logger.h"
29
30using namespace o2::framework;
31
33
35 bool mVerbose{false};
36
37 void init(InitContext& ic)
38 {
39 mVerbose = ic.options().get<bool>("verbose");
40 fair::Logger::SetConsoleColor(true);
41 }
42
44 {
45 auto digitsR2 = pc.inputs().get<gsl::span<o2::mch::Digit>>("digits");
46 auto& digitsR3 = pc.outputs().make<std::vector<o2::mch::Digit>>(OutputRef{"digits"});
47 for (const auto d2 : digitsR2) {
48 auto digit = d2;
49 int deID = digit.getDetID();
50 int digitID = digit.getPadID();
51 int manuID = (digitID & 0xFFF000) >> 12;
52 int manuCh = (digitID & 0x3F000000) >> 24;
53
54 int padID = o2::mch::mapping::segmentation(deID).findPadByFEE(manuID, manuCh);
55 if (mVerbose) {
56 LOGP(warn, "DEID {:4d} DIGITID {:10d} MANUID {:4d} CH {:2} PADID {:10d}",
57 deID, digitID, manuID, manuCh, padID);
58 }
59 if (padID < 0) {
60 throw std::runtime_error(fmt::format("digitID {} does not exist in the mapping", digitID));
61 }
62 digit.setPadID(padID);
63 digitsR3.push_back(digit);
64 }
65 }
66};
67
69{
70 WorkflowSpec specs;
71
72 std::string inputConfig = fmt::format("digits:MCH/DIGITSR2/0");
73 inputConfig += ";rofs:MCH/DIGITROFS/0";
74
75 DataProcessorSpec padIdConverter{
76 "mch-digits-r23",
77 Inputs{o2::framework::select(inputConfig.c_str())},
78 Outputs{OutputSpec{{"digits"}, "MCH", "DIGITS", 0, Lifetime::Timeframe}},
79 AlgorithmSpec{adaptFromTask<DigitConverter>()},
80 Options{
81 {"verbose", VariantType::Bool, false, {"print ids being converted"}}}};
82 specs.push_back(padIdConverter);
83 return specs;
84}
decltype(auto) make(const Output &spec, Args... args)
ConfigParamRegistry const & options()
Definition InitContext.h:33
decltype(auto) get(R binding, int part=0) const
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
InputRecord & inputs()
The inputs associated with this processing context.
int findPadByFEE(int dualSampaId, int dualSampaChannel) const
WorkflowSpec defineDataProcessing(const ConfigContext &cc)
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< DataProcessorSpec > WorkflowSpec
std::vector< InputSpec > select(char const *matcher="")
std::vector< InputSpec > Inputs
std::vector< OutputSpec > Outputs
O2MCHMAPPINGIMPL3_EXPORT const Segmentation & segmentation(int detElemId)
void init(InitContext &ic)
void run(ProcessingContext &pc)
std::vector< o2::mch::ChannelCode > cc