ATLAS Offline Software
Loading...
Searching...
No Matches
SCT_DCSStatCondData.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5//Implementation file for the data object class
6//The object is a map of channel number<->vector<string>
7//Each string is the name of the guilty DCS parameter
8
10
11#include <iostream>
12#include <algorithm>
13
15//constructor
20
21//add map entries
22void SCT_DCSStatCondData::fill(const CondAttrListCollection::ChanNum& chanNum, const std::string& param) {
23 if (m_bad_channels.find(chanNum)!=m_bad_channels.end()) {
24 // chan num has an entry already
25 //get the parameter list for this chan num
26
27 std::vector<std::string> par{(*m_bad_channels.find(chanNum)).second};
28
29 std::vector<std::string>::iterator par_itr{std::find(par.begin(), par.end(), param)};
30 if (par_itr==par.end()) {
31 // if this parameter (hv, chanstat etc) doesn't exist in the list add it to the param std::vector
32 par.push_back(param);
33 //don't insert! not a new map entry, just update the std::vector
34 (*m_bad_channels.find(chanNum)).second = std::move(par);
35 }
36 } else {
37 // no entry yet for this chan num, so start fresh
38 std::vector<std::string> par;
39 par.push_back(param);
40 std::pair<std::map<CondAttrListCollection::ChanNum, std::vector<std::string> >::iterator, bool> successfulInsert{m_bad_channels.insert(make_pair(chanNum, par))};
41 if (not successfulInsert.second) std::cout << "WARNING: SCT_ConditionsData map insert failed" << std::endl;
42 }
43}
44
45//remove entries in map vector
46void SCT_DCSStatCondData::remove(const CondAttrListCollection::ChanNum& chanNum, const std::string& param) {
47 std::map<CondAttrListCollection::ChanNum, std::vector<std::string> >::iterator itr{m_bad_channels.find(chanNum)};
48 if (itr!=m_bad_channels.end()) {
49 std::vector<std::string>::iterator vec_itr{std::find((*itr).second.begin(), (*itr).second.end(), param)};
50 if (vec_itr!=(*itr).second.end()) {
51 if ((*itr).second.size()>1) (*itr).second.erase(vec_itr);
52 else m_bad_channels.erase(itr);
53 }
54 }
55}
56
57//output map vector
58int SCT_DCSStatCondData::output(const CondAttrListCollection::ChanNum& chanNum, std::vector<std::string>& usersVector) const {
59 DCSConditions::const_iterator pPair{m_bad_channels.find(chanNum)};
60 if (pPair!=m_bad_channels.end()) {
61 const std::vector<std::string>& v{pPair->second};
62 usersVector.insert(usersVector.begin(), v.begin(), v.end());
63 }
64 return usersVector.size();
65}
66
67//output map size
69 DCSConditions::const_iterator pPair{m_bad_channels.find(chanNum)};
70 return (pPair!=m_bad_channels.end()) ? (pPair->second.size()) : 0;
71}
header file for data object for SCT_DCSConditionsStatCondAlg, SCT_DCSConditionsTool,...
SCT_DCSStatCondData()
Constructor.
void remove(const CondAttrListCollection::ChanNum &chanNum, const std::string &param)
Remove a defect.
void fill(const CondAttrListCollection::ChanNum &chanNum, const std::string &param)
Add defect.
int output(const CondAttrListCollection::ChanNum &chanNum, std::vector< std::string > &usersVector) const
Copy all defects to a users vector, the return value is the size.