Project
Loading...
Searching...
No Matches
MaskHandlerSpec.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 <array>
20#include <vector>
21#include <map>
22#include <chrono>
23#include <gsl/gsl>
26#include "Framework/InputSpec.h"
27#include "Framework/Logger.h"
28#include "Framework/Task.h"
35
36namespace of = o2::framework;
37
38namespace o2
39{
40namespace mid
41{
42
44{
45 public:
47 {
48
49 mOutFilename = ic.options().get<std::string>("mid-mask-outfile");
50
51 auto stop = [this]() {
53 };
54 ic.services().get<of::CallbackService>().set<of::CallbackService::Id::Stop>(stop);
55 }
56
58 {
59 std::string name = "calib";
61 o2::mid::ROBoardConfigHandler roBoardCfgHandler;
62
63 for (auto& masks : mMasksHandlers) {
64 auto maskVec = masks.getMasks();
65 colToBoard.process(maskVec);
66 auto roMasks = colToBoard.getData();
67 if (maskVec.empty()) {
68 LOG(info) << "No problematic digit found in " << name << " events";
69 } else {
70 LOG(info) << "Problematic digits found in " << name << " events. Corresponding masks:";
71 for (auto& mask : maskVec) {
72 LOG(info) << mask;
73 }
74 std::cout << "\nCorresponding boards masks:" << std::endl;
75 for (auto& board : roMasks) {
76 std::cout << board << std::endl;
77 }
78 }
79
80 if (!mOutFilename.empty()) {
81 auto idx = mOutFilename.find_last_of("/");
82 auto insertIdx = (idx == std::string::npos) ? 0 : idx + 1;
83 std::string outFilename = mOutFilename;
84 outFilename.insert(insertIdx, "_");
85 outFilename.insert(insertIdx, name.c_str());
86 auto fullMasks = o2::mid::makeDefaultMasks();
87 for (auto& mask : fullMasks) {
88 masks.applyMask(mask);
89 }
90 colToBoard.process(fullMasks);
91 roBoardCfgHandler.updateMasks(colToBoard.getData());
92 roBoardCfgHandler.write(outFilename.c_str());
93 }
94
95 name = "FET";
96 }
97 }
98
99 void
101 {
102 auto tStart = std::chrono::high_resolution_clock::now();
103
104 std::array<gsl::span<const ColumnData>, 2> masks;
105
106 masks[0] = pc.inputs().get<gsl::span<ColumnData>>("mid_noise_mask");
107 masks[1] = pc.inputs().get<gsl::span<ColumnData>>("mid_dead_mask");
108
109 auto tAlgoStart = std::chrono::high_resolution_clock::now();
110
111 bool isChanged = false;
112 for (int itype = 0; itype < 2; ++itype) {
113 ChannelMasksHandler chMasks;
114 for (auto& mask : masks[itype]) {
115 chMasks.setFromChannelMask(mask);
116 }
117 if (!(chMasks == mMasksHandlers[itype])) {
118 mMasksHandlers[itype] = chMasks;
119 isChanged = true;
120 }
121 }
122
123 if (isChanged) {
124 printSummary();
125 }
126
127 mTimerMaskHandler += std::chrono::high_resolution_clock::now() - tAlgoStart;
128
129 mTimer += std::chrono::high_resolution_clock::now() - tStart;
130 }
131
132 private:
133 std::array<ChannelMasksHandler, 2> mMasksHandlers{};
134 std::chrono::duration<double> mTimer{0};
135 std::chrono::duration<double> mTimerMaskHandler{0};
136 std::string mOutFilename{};
137};
138
140{
141 std::vector<of::InputSpec> inputSpecs{
142 of::InputSpec{"mid_noise_mask", header::gDataOriginMID, "MASKS", 1},
143 of::InputSpec{"mid_dead_mask", header::gDataOriginMID, "MASKS", 2}};
144
146 "MIDMaskHandler",
147 {inputSpecs},
148 {},
149 of::AlgorithmSpec{of::adaptFromTask<o2::mid::MaskHandlerDeviceDPL>()},
151 {"mid-mask-outfile", of::VariantType::String, "", {"Output filename"}}}};
152}
153} // namespace mid
154} // namespace o2
MID channels masks handler.
Converter from ColumnData to raw local boards.
Strip pattern (aka digits)
Definition of the MID event record.
Processor to handle the masks.
Function to produce the MID masks.
ServiceRegistryRef services()
Definition InitContext.h:34
ConfigParamRegistry const & options()
Definition InitContext.h:33
decltype(auto) get(R binding, int part=0) const
InputRecord & inputs()
The inputs associated with this processing context.
void setFromChannelMask(const ColumnData &mask)
std::vector< ROBoard > getData() const
Gets vector of ROBoard.
void process(gsl::span< const ColumnData > data, bool allowEmpty=false)
void init(o2::framework::InitContext &ic)
void run(o2::framework::ProcessingContext &pc)
void write(const char *filename) const
void updateMasks(const std::vector< ROBoard > &masks)
GLuint const GLchar * name
Definition glcorearb.h:781
GLint GLuint mask
Definition glcorearb.h:291
constexpr o2::header::DataOrigin gDataOriginMID
Definition DataHeader.h:573
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< ConfigParamSpec > Options
std::vector< ColumnData > makeDefaultMasks()
Definition MaskMaker.cxx:62
framework::DataProcessorSpec getMaskHandlerSpec()
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"