forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeadMapBuilderSpec.h
More file actions
154 lines (118 loc) · 4.29 KB
/
Copy pathDeadMapBuilderSpec.h
File metadata and controls
154 lines (118 loc) · 4.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
/// @file DeadMapBuilderSpec.h
#ifndef O2_ITSMFT_DEADMAP_BUILDER_
#define O2_ITSMFT_DEADMAP_BUILDER_
#include <sys/stat.h>
#include <filesystem>
#include <string>
#include <vector>
#include <array>
#include <set>
#include <deque>
#include <iostream>
#include <fstream>
#include <sstream>
// Boost library for easy access of host name
#include <boost/asio/ip/host_name.hpp>
#include "Framework/CCDBParamSpec.h"
#include "Framework/DataProcessorSpec.h"
#include "Framework/Task.h"
#include "Framework/ControlService.h"
#include "Framework/ConfigParamRegistry.h"
#include "Framework/RawDeviceService.h"
#include "Framework/WorkflowSpec.h"
#include "Framework/Task.h"
#include "Framework/DataTakingContext.h"
#include "Framework/TimingInfo.h"
#include <fairmq/Device.h>
#include <ITSMFTReconstruction/RawPixelDecoder.h> //o2::itsmft::RawPixelDecoder
#include "DataFormatsITSMFT/TimeDeadMap.h"
#include "DataFormatsITSMFT/StuckPixelData.h"
#include "DetectorsCalibration/Utils.h"
#include "DetectorsCommonDataFormats/FileMetaData.h"
#include "DetectorsBase/GRPGeomHelper.h"
#include "CCDB/CcdbApi.h"
#include "CommonUtils/MemFileHelper.h"
// ROOT includes
#include "TTree.h"
#include "TH1F.h"
#include "TH2F.h"
#include "TF1.h"
#include "TFile.h"
using namespace o2::framework;
using namespace o2::itsmft;
namespace o2
{
namespace itsmft
{
class ITSMFTDeadMapBuilder : public Task
{
public:
ITSMFTDeadMapBuilder(std::string datasource, bool doMFT);
~ITSMFTDeadMapBuilder() override;
void init(InitContext& ic) final;
void run(ProcessingContext& pc) final;
void endOfStream(EndOfStreamContext& ec) final;
void stop() final;
//////////////////////////////////////////////////////////////////
private:
std::string mSelfName;
bool mRunMFT = false;
bool mDoLocalOutput = false;
bool mSkipStaticMap = false;
bool mNoGroupITSLanes = false;
uint16_t N_CHIPS;
uint16_t N_CHIPS_ITSIB = o2::itsmft::ChipMappingITS::getNChips(0);
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
uint mStepCounter = 0;
uint mTFCounter = 0;
long mTimeStart = -1; // TODO: better to use RCT info?
std::string mCCDBUrl = "";
std::string mObjectName;
std::string mLocalOutputDir;
std::string MAP_VERSION = "4"; // to change in case the encoding or the format change
std::vector<bool> mStaticChipStatus{};
std::vector<uint16_t> mDeadMapTF{};
int mRunNumber = -1;
unsigned long mFirstOrbitTF = 0x0;
unsigned long mFirstOrbitRun = 0x0;
std::string mDataSource = "chipsstatus";
int mTFSampling = 350;
// utils for an improved sampling algorithm
std::unordered_set<long> mSampledTFs{};
std::deque<long> mSampledHistory{};
int mTFSamplingTolerance = 20;
int mSampledSlidingWindowSize = 1000; // units: mTFSampling
o2::itsmft::TimeDeadMap mMapObject;
void finalizeOutput();
void PrepareOutputCcdb(EndOfStreamContext* ec, std::string ccdburl);
// Utils
std::vector<uint16_t> getChipIDsOnSameCable(uint16_t);
bool acceptTF(long);
o2::framework::DataTakingContext mDataTakingContext{};
o2::framework::TimingInfo mTimingInfo{};
// Flag to avoid that endOfStream and stop are both done
bool isEnded = false;
// Stuck pixel related members
bool mDoStuckPixels = false;
std::string mStuckPixelFileName = "";
o2::itsmft::StuckPixelData mStuckPixelData;
Long64_t mErrOrbit = 0;
UShort_t mErrChipID = 0;
UShort_t mErrRow = 0;
UShort_t mErrCol = 0;
};
// Create a processor spec
o2::framework::DataProcessorSpec getITSMFTDeadMapBuilderSpec(std::string datasource, bool doMFT);
} // namespace itsmft
} // namespace o2
#endif