ATLAS Offline Software
SCT_DCSStatCondData.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 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
17  m_bad_channels{}
18 {
19 }
21 //add map entries
22 void 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 = 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 }
45 //remove entries in map vector
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 }
57 //output map vector
58 int 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 }
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 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
SCT_DCSStatCondData::m_bad_channels
DCSConditions m_bad_channels
Definition: SCT_DCSStatCondData.h:51
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
SCT_DCSStatCondData::SCT_DCSStatCondData
SCT_DCSStatCondData()
Constructor.
Definition: SCT_DCSStatCondData.cxx:16
SCT_DCSStatCondData::fill
void fill(const CondAttrListCollection::ChanNum &chanNum, const std::string &param)
Add defect.
Definition: SCT_DCSStatCondData.cxx:22
SCT_DCSStatCondData::remove
void remove(const CondAttrListCollection::ChanNum &chanNum, const std::string &param)
Remove a defect.
Definition: SCT_DCSStatCondData.cxx:46
checkCoolLatestUpdate.chanNum
chanNum
Definition: checkCoolLatestUpdate.py:27
SCT_DCSStatCondData::output
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.
Definition: SCT_DCSStatCondData.cxx:58
CondAttrListCollection::ChanNum
unsigned int ChanNum
Definition: CondAttrListCollection.h:55
createCoolChannelIdFile.par
par
Definition: createCoolChannelIdFile.py:29
SCT_DCSStatCondData.h
header file for data object for SCT_DCSConditionsStatCondAlg, SCT_DCSConditionsTool,...
python.PyAthena.v
v
Definition: PyAthena.py:154