Project
Loading...
Searching...
No Matches
DeadMapBuilderSpec.h
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
13
14#ifndef O2_ITSMFT_DEADMAP_BUILDER_
15#define O2_ITSMFT_DEADMAP_BUILDER_
16
17#include <sys/stat.h>
18#include <filesystem>
19#include <string>
20#include <vector>
21#include <array>
22#include <set>
23#include <deque>
24
25#include <iostream>
26#include <fstream>
27#include <sstream>
28
29// Boost library for easy access of host name
30#include <boost/asio/ip/host_name.hpp>
31
34#include "Framework/Task.h"
39#include "Framework/Task.h"
42#include <fairmq/Device.h>
43
44#include <ITSMFTReconstruction/RawPixelDecoder.h> //o2::itsmft::RawPixelDecoder
50#include "CCDB/CcdbApi.h"
52
53// ROOT includes
54#include "TTree.h"
55#include "TH1F.h"
56#include "TH2F.h"
57#include "TF1.h"
58#include "TFile.h"
59
60using namespace o2::framework;
61using namespace o2::itsmft;
62
63namespace o2
64{
65namespace itsmft
66{
67
69{
70 public:
71 ITSMFTDeadMapBuilder(std::string datasource, bool doMFT);
72 ~ITSMFTDeadMapBuilder() override;
73
74 void init(InitContext& ic) final;
75 void run(ProcessingContext& pc) final;
76 void endOfStream(EndOfStreamContext& ec) final;
77
78 void stop() final;
79
81 private:
82 std::string mSelfName;
83
84 bool mRunMFT = false;
85 bool mDoLocalOutput = false;
86 bool mSkipStaticMap = false;
87 bool mNoGroupITSLanes = false;
88 uint16_t N_CHIPS;
89 uint16_t N_CHIPS_ITSIB = o2::itsmft::ChipMappingITS::getNChips(0);
90 int mTFLength = 32; // TODO find utility for proper value -- o2::base::GRPGeomHelper::getNHBFPerTF() returns 128 see https://github.com/AliceO2Group/AliceO2/blob/051b56f9f136e7977e83f5d26d922db9bd6ecef5/Detectors/Base/src/GRPGeomHelper.cxx#L233 and correct also default option is getSpec
91
92 uint mStepCounter = 0;
93 uint mTFCounter = 0;
94
95 long mTimeStart = -1; // TODO: better to use RCT info?
96
97 std::string mCCDBUrl = "";
98 std::string mObjectName;
99 std::string mLocalOutputDir;
100
101 std::string MAP_VERSION = "4"; // to change in case the encoding or the format change
102
103 std::vector<bool> mStaticChipStatus{};
104
105 std::vector<uint16_t> mDeadMapTF{};
106
107 int mRunNumber = -1;
108 unsigned long mFirstOrbitTF = 0x0;
109 unsigned long mFirstOrbitRun = 0x0;
110
111 std::string mDataSource = "chipsstatus";
112
113 int mTFSampling = 350;
114
115 // utils for an improved sampling algorithm
116 std::unordered_set<long> mSampledTFs{};
117 std::deque<long> mSampledHistory{};
118 int mTFSamplingTolerance = 20;
119 int mSampledSlidingWindowSize = 1000; // units: mTFSampling
120
121 o2::itsmft::TimeDeadMap mMapObject;
122
123 void finalizeOutput();
124 void PrepareOutputCcdb(EndOfStreamContext* ec, std::string ccdburl);
125
126 // Utils
127
128 std::vector<uint16_t> getChipIDsOnSameCable(uint16_t);
129 bool acceptTF(long);
130
131 o2::framework::DataTakingContext mDataTakingContext{};
132 o2::framework::TimingInfo mTimingInfo{};
133
134 // Flag to avoid that endOfStream and stop are both done
135 bool isEnded = false;
136
137 // Stuck pixel related members
138 bool mDoStuckPixels = false;
139 std::string mStuckPixelFileName = "";
140 o2::itsmft::StuckPixelData mStuckPixelData;
141
142 Long64_t mErrOrbit = 0;
143 UShort_t mErrChipID = 0;
144 UShort_t mErrRow = 0;
145 UShort_t mErrCol = 0;
146};
147
148// Create a processor spec
149o2::framework::DataProcessorSpec getITSMFTDeadMapBuilderSpec(std::string datasource, bool doMFT);
150
151} // namespace itsmft
152} // namespace o2
153
154#endif
Utils and constants for calibration and related workflows.
Helper for geometry and GRP related CCDB requests.
Definition of the Alpide pixel reader for raw data processing.
CCDB-serializable container for stuck (repeating) pixel error records.
Definition of the ITSMFT time-dependend dead map.
static constexpr int getNChips()
number of chips per barrel
void endOfStream(EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void stop() final
This is invoked on stop.
void init(InitContext &ic) final
void run(ProcessingContext &pc) final
CCDB payload object: a run-level collection of stuck-pixel records.
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
o2::framework::DataProcessorSpec getITSMFTDeadMapBuilderSpec(std::string datasource, bool doMFT)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...