Project
Loading...
Searching...
No Matches
HVStatusCreator.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
12#include <algorithm>
13#include <map>
14
16
20#include "MCHStatus/StatusMap.h"
22
23using DPMAP2 = std::unordered_map<std::string, std::map<uint64_t, double>>;
24
27{
28 union Converter {
29 uint64_t raw_data;
30 double value;
31 } converter;
32 converter.raw_data = v.payload_pt1;
33 return converter.value;
34};
35
38{
39 DPMAP2 dpsMapPerAlias{};
40
41 auto timeMargin = o2::mch::StatusMapCreatorParam::Instance().timeMargin;
42
43 for (const auto& [dpId, dpsHV] : dpMap) {
44 std::string alias = dpId.get_alias();
45
46 if (alias.find("vMon") != std::string::npos && o2::mch::dcs::isValid(alias)) {
47 auto& dps2 = dpsMapPerAlias[alias];
48
49 // copy first point to the beginning of time + margin (will be subtracted later on)
50 dps2.emplace(timeMargin, dpConverter(dpsHV.front()));
51
52 for (const auto& value : dpsHV) {
53 dps2.emplace(value.get_epoch_time(), dpConverter(value));
54 }
55
56 // copy last point to the end of time - margin (will be added later on)
57 dps2.emplace(std::numeric_limits<uint64_t>::max() - timeMargin, dpConverter(dpsHV.back()));
58 }
59 }
60
61 return dpsMapPerAlias;
62}
63
64namespace o2::mch
65{
66
68{
69 // clear current list of issues
70 mBadHVTimeRanges.clear();
71
72 // decode the DCS DPMAP
73 DPMAP2 dpsMapPerAlias = decodeDPMAP(dpMap);
74
75 auto minDuration = StatusMapCreatorParam::Instance().hvMinDuration;
76 auto timeMargin = StatusMapCreatorParam::Instance().timeMargin;
77
78 // find list of HV issues per alias
79 for (const auto& [alias, dpsHV] : dpsMapPerAlias) {
81 auto chamberThreshold = StatusMapCreatorParam::Instance().hvLimits[chamber];
82
83 std::vector<TimeRange> hvIssuesList{};
84 uint64_t tStart = 0;
85 uint64_t tStop = 0;
86 bool ongoingIssue = false;
87
88 for (auto [timestamp, valueHV] : dpsHV) {
89 if (valueHV < chamberThreshold) {
90 if (!ongoingIssue) {
91 tStart = timestamp;
92 tStop = tStart;
93 ongoingIssue = true;
94 } else {
95 tStop = timestamp;
96 }
97 } else {
98 if (ongoingIssue) {
99 tStop = timestamp;
100 if (tStop - tStart > minDuration) {
101 hvIssuesList.emplace_back(tStart - timeMargin, tStop + timeMargin);
102 }
103 ongoingIssue = false;
104 }
105 }
106 }
107
108 // ongoing issue at the end of the object
109 if (ongoingIssue && tStop - tStart > minDuration) {
110 hvIssuesList.emplace_back(tStart - timeMargin, tStop + timeMargin);
111 }
112
113 // add issues for the alias if non-empty
114 if (!hvIssuesList.empty()) {
115 mBadHVTimeRanges.emplace(alias, hvIssuesList);
116 }
117 }
118}
119
121{
122 // list issues at the given time stamp
123 std::set<std::string> currentBadHVs{};
124 for (const auto& [alias, timeRanges] : mBadHVTimeRanges) {
125 auto it = std::find_if(timeRanges.begin(), timeRanges.end(),
126 [timestamp](const TimeRange& r) { return r.contains(timestamp); });
127 if (it != timeRanges.end()) {
128 currentBadHVs.emplace(alias);
129 }
130 }
131
132 // check if the list of issues has changed and update it in this case
133 if (currentBadHVs != mCurrentBadHVs) {
134 mCurrentBadHVs.swap(currentBadHVs);
135 return true;
136 }
137
138 return false;
139}
140
142{
143 for (const auto& alias : mCurrentBadHVs) {
144 int deId = dcs::aliasToDetElemId(alias).value();
145 if (deId < 500) {
146 for (auto dsIndex : dcs::aliasToDsIndices(alias)) {
147 statusMap.addDS(dsIndex, StatusMap::kBadHV);
148 }
149 } else {
150 statusMap.addDE(deId, StatusMap::kBadHV);
151 }
152 }
153}
154
155} // namespace o2::mch
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
double dpConverter(o2::dcs::DataPointValue v)
Converts DCS data point value to double HV value.
DPMAP2 decodeDPMAP(const o2::mch::HVStatusCreator::DPMAP &dpMap)
Decode the DCS DPMAP to be processed for HV issues.
void findBadHVs(const DPMAP &dpMap)
std::unordered_map< DPID, std::vector< DPVAL > > DPMAP
bool findCurrentBadHVs(uint64_t timestamp)
void updateStatusMap(StatusMap &statusMap) const
void addDS(DsIndex badDS, uint32_t mask)
Definition StatusMap.cxx:58
void addDE(uint16_t badDE, uint32_t mask)
Definition StatusMap.cxx:87
const GLdouble * v
Definition glcorearb.h:832
GLsizei const GLfloat * value
Definition glcorearb.h:819
std::set< DsIndex > aliasToDsIndices(std::string_view alias)
Definition Mapper.cxx:41
int toInt(Chamber chamber)
Definition Chamber.cxx:68
Chamber aliasToChamber(std::string_view alias)
Definition Chamber.cxx:100
std::optional< int > aliasToDetElemId(std::string_view dcsAlias)
bool isValid(std::string_view dcsAlias)
std::map< std::string, std::map< uint64_t, double > > DPMAP2
Internal structure to define a time range.