forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeadChannelMapCreator.h
More file actions
117 lines (91 loc) · 4.55 KB
/
DeadChannelMapCreator.h
File metadata and controls
117 lines (91 loc) · 4.55 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
// 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.
#ifndef ALICEO2_TPC_DeadChannelMapCreator_H_
#define ALICEO2_TPC_DeadChannelMapCreator_H_
#include <string_view>
#include <unordered_map>
#include <memory>
#include <string_view>
#include "Rtypes.h"
#include "CCDB/CcdbApi.h"
#include "TPCBaseRecSim/PadFlags.h"
#include "TPCBaseRecSim/CDBTypes.h"
#include "TPCBase/CalDet.h"
#include "TPCBase/FEEConfig.h"
namespace o2::tpc
{
enum class SourcesDeadMap : unsigned short {
None = 0, ///< no inputs
IDCPadStatus = 1 << 0, ///< use idc pad status map
FEEConfig = 1 << 1, ///< use fee config
All = IDCPadStatus | FEEConfig, ///< all sources
};
inline SourcesDeadMap operator&(SourcesDeadMap a, SourcesDeadMap b) { return static_cast<SourcesDeadMap>(static_cast<unsigned short>(a) & static_cast<unsigned short>(b)); }
inline SourcesDeadMap operator~(SourcesDeadMap a) { return static_cast<SourcesDeadMap>(~static_cast<unsigned short>(a)); }
inline SourcesDeadMap operator|(SourcesDeadMap a, SourcesDeadMap b) { return static_cast<SourcesDeadMap>(static_cast<unsigned short>(a) | static_cast<unsigned short>(b)); }
struct FEEConfig;
class DeadChannelMapCreator
{
struct ValidityRange {
long startvalidity = 0;
long endvalidity = -1;
bool isValid(long ts) const { return ts < endvalidity && ts > startvalidity; }
};
public:
using CalDetFlag_t = o2::tpc::CalDet<o2::tpc::PadFlags>;
void reset();
void init(std::string_view url = "");
void load(long timeStampOrRun);
void loadFEEConfigViaRunInfoTS(long timeStamp);
void loadFEEConfigViaRunInfo(long timeStampOrRun);
void loadFEEConfig(long timeStamp = -1);
void loadIDCPadFlags(long timeStampOrRun);
void setDeadChannelMapIDCPadStatus(const CalDetFlag_t& padStatusMap, PadFlags mask = PadFlags::flagAllNoneGood);
void setDeadChannelMapFEEConfig(const FEEConfig& feeConfig) { mDeadChannelMapFEE = feeConfig.getDeadChannelMap(); }
const CalDet<bool>& getDeadChannelMapIDC() const { return mDeadChannelMapIDC; }
const CalDet<bool>& getDeadChannelMapFEE() const { return mDeadChannelMapFEE; }
const CalDet<bool>& getDeadChannelMap() const { return mDeadChannelMap; }
const FEEConfig* getFEEConfig() const { return mFEEConfig.get(); }
const CalDetFlag_t* getPadFlags() const { return mPadStatusMap.get(); }
void drawDeadChannelMapIDC();
void drawDeadChannelMapFEE();
void drawDeadChannelMap();
long getTimeStamp(long timeStampOrRun) const;
void finalizeDeadChannelMap();
void resetDeadChannelMap() { mDeadChannelMap = false; }
void setSource(SourcesDeadMap s) { mSources = s; }
void addSource(SourcesDeadMap s) { mSources = s | mSources; }
bool useSource(SourcesDeadMap s) const { return (mSources & s) == s; }
SourcesDeadMap getSources() const { return mSources; }
private:
std::unique_ptr<FEEConfig> mFEEConfig; ///< Electronics configuration, manually loaded
std::unique_ptr<CalDetFlag_t> mPadStatusMap; ///< Pad status map from IDCs, manually loaded
// FEEConfig::CalPadMapType* mPulserData; ///< Pulser information
// FEEConfig::CalPadMapType* mCEData; ///< CE information
std::unordered_map<CDBType, ValidityRange> mObjectValidity; ///< validity range of internal objects
SourcesDeadMap mSources = SourcesDeadMap::All; ///< Inputs to use to create the map
ccdb::CcdbApi mCCDBApi; ///< CCDB Api
CalDet<bool> mDeadChannelMapIDC{"DeadChannelMapIDC"}; ///< Combined dead channel map
CalDet<bool> mDeadChannelMapFEE{"DeadChannelMapFEE"}; ///< Dead Channel map from FEE configuration
CalDet<bool> mDeadChannelMap{"DeadChannelMap"}; ///< Combined dead channel map
ClassDefNV(DeadChannelMapCreator, 0);
};
inline long DeadChannelMapCreator::getTimeStamp(long timeStampOrRun) const
{
if (timeStampOrRun < 1000000) {
// assume run number
const auto c = mCCDBApi.retrieveHeaders("RCT/Info/RunInformation", {}, timeStampOrRun);
timeStampOrRun = (std::stol(c.at("SOR")) + std::stol(c.at("EOR"))) / 2;
}
return timeStampOrRun;
}
} // namespace o2::tpc
#endif