ATLAS Offline Software
Loading...
Searching...
No Matches
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
22
23//----------------------------------------------------------------------
24// Add map entries of defects on module
25bool 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
62std::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
101unsigned long int SCT_CalibDefectData::size() const{
102 return m_defectMap.size();
103}
104
105
header file for data object
std::string str()
Print the map - might be useful.
void clear()
Clear the map.
CalibModuleDefects findModule(const Identifier &moduleId) const
Search the map for a module.
bool addModule(const Identifier &moduleId, const CalibModuleDefects &defects)
Add defects for a module.
bool empty() const
Return whether the map is empty.
std::string moduleText(const Identifier &moduleId) const
Print data for one module.
SCT_CalibDefectData()
Constructor.
unsigned long int size() const
Return the size of the map.
CalibConditions m_defectMap