ATLAS Offline Software
SCT_CalibDefectData.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 //----------------------------------------------------------------------
6 //Implementation file for the data object class
7 //The object is a map of channel number<->status and defect type/values
8 // P. Johansson
9 //----------------------------------------------------------------------
11 
12 #include <iomanip>
13 #include <iostream>
14 #include <sstream>
15 #include <utility>
16 
17 //----------------------------------------------------------------------
18 //constructor
20  m_defectMap{}
21 {}
22 
23 //----------------------------------------------------------------------
24 // Add map entries of defects on module
25 bool SCT_CalibDefectData::addModule(const Identifier & moduleId, const CalibModuleDefects & moduleDefects)
26 {
27  return (m_defectMap.insert(std::make_pair(moduleId, moduleDefects))).second;
28 }
29 
30 //----------------------------------------------------------------------
31 // Search the maps for a module, returns empty module container if not found
33 {
34  // Create container for the defect data
36  // Iterate over the map and look for the requested module
37  CalibConditions::const_iterator iter(m_defectMap.find(moduleId));
38  if (iter not_eq m_defectMap.end()){
39  ModuleDefects = iter->second;
40  }
41  return ModuleDefects;
42 }
43 
44 //----------------------------------------------------------------------
45 // Method to print the map - useful debug tool
47 {
48  std::ostringstream txt;
49  if (m_defectMap.empty()){
50  txt << "No modules are in the SCT Calibration defect data map.\n";
51  } else {
52  CalibConditions::const_iterator itr(m_defectMap.begin());
53  for (; itr!=m_defectMap.end(); ++itr){
54  txt << itr->first << " " << moduleText(itr->first);
55  }
56  }
57  return txt.str();
58 }
59 
60 //----------------------------------------------------------------------
61 // Print data for one module
62 std::string SCT_CalibDefectData::moduleText( const Identifier & moduleId ) const{
63  CalibModuleDefects thisModuleDefects = findModule( moduleId );
64  std::ostringstream txt;
65  std::ostringstream tmp;
66 
67  if ( thisModuleDefects.begDefects.empty() ){
68  txt << "The SCT module Calibration defect data map is empty for module " << moduleId <<".\n";
69  } else {
70  txt << "\n" << std::left << std::setw(15) << "Bad strips" << std::setw(15) << "Defect type" << std::setw(15) << "Value:" << "\n";
71  for ( unsigned int i = 0; i < thisModuleDefects.begDefects.size(); i++){
72  if ( thisModuleDefects.begDefects[i] == thisModuleDefects.endDefects[i] ){
73  txt << std::left << std::setw(15) << thisModuleDefects.begDefects[i];
74  }
75  else{
76  tmp << thisModuleDefects.begDefects[i] << " - " << thisModuleDefects.endDefects[i];
77  txt << std::left << std::setw(15) << tmp.str();
78  }
79  txt << std::left << std::setw(15) << thisModuleDefects.typeOfDefect[i];
80  txt << std::left << std::setw(15) << thisModuleDefects.parValue[i] << "\n";
81  tmp.str("");
82  }
83  }
84  return txt.str();
85 }
86 
87 //----------------------------------------------------------------------
88 // Is the map empty?
90  return m_defectMap.empty();
91 }
92 
93 //----------------------------------------------------------------------
94 // Clear map
96  m_defectMap.clear();
97 }
98 
99 //----------------------------------------------------------------------
100 // The size of the map
101 unsigned long int SCT_CalibDefectData::size() const{
102  return m_defectMap.size();
103 }
104 
105 
SCT_CalibDefectData.h
SCT_CalibDefectData::findModule
CalibModuleDefects findModule(const Identifier &moduleId) const
Search the map for a module.
Definition: SCT_CalibDefectData.cxx:32
SCT_CalibDefectData::CalibModuleDefects::begDefects
std::vector< unsigned int > begDefects
Definition: SCT_CalibDefectData.h:33
SCT_CalibDefectData::SCT_CalibDefectData
SCT_CalibDefectData()
Constructor.
Definition: SCT_CalibDefectData.cxx:19
SCT_CalibDefectData::size
unsigned long int size() const
Return the size of the map.
Definition: SCT_CalibDefectData.cxx:101
lumiFormat.i
int i
Definition: lumiFormat.py:85
SCT_CalibDefectData::moduleText
std::string moduleText(const Identifier &moduleId) const
Print data for one module.
Definition: SCT_CalibDefectData.cxx:62
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
SCT_CalibDefectData::CalibModuleDefects::typeOfDefect
std::vector< std::string > typeOfDefect
Definition: SCT_CalibDefectData.h:35
SCT_CalibDefectData::CalibModuleDefects
Definition: SCT_CalibDefectData.h:32
SCT_CalibDefectData::CalibModuleDefects::parValue
std::vector< float > parValue
Definition: SCT_CalibDefectData.h:36
SCT_CalibDefectData::str
std::string str()
Print the map - might be useful.
Definition: SCT_CalibDefectData.cxx:46
SCT_CalibDefectData::addModule
bool addModule(const Identifier &moduleId, const CalibModuleDefects &defects)
Add defects for a module.
Definition: SCT_CalibDefectData.cxx:25
SCT_CalibDefectData::clear
void clear()
Clear the map.
Definition: SCT_CalibDefectData.cxx:95
SCT_CalibDefectData::empty
bool empty() const
Return whether the map is empty.
Definition: SCT_CalibDefectData.cxx:89
SCT_CalibDefectData::m_defectMap
CalibConditions m_defectMap
Definition: SCT_CalibDefectData.h:70
SCT_CalibDefectData::CalibModuleDefects::endDefects
std::vector< unsigned int > endDefects
Definition: SCT_CalibDefectData.h:34
Identifier
Definition: IdentifierFieldParser.cxx:14