ATLAS Offline Software
Loading...
Searching...
No Matches
TGCDatabaseSLBToROD.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include <fstream>
8#include <sstream>
9
10namespace MuonTGC_Cabling {
11
12TGCDatabaseSLBToROD::TGCDatabaseSLBToROD(const std::string& filename,
13 const std::string& blockname)
14 : TGCDatabase(TGCDatabase::SLBToROD, filename, blockname)
15{
16 // read out ascii file and fill database
18}
19
21 std::ifstream file(m_filename.c_str());
22 std::string buf;
23
24 unsigned int space = m_blockname.find(' ');
25 std::string_view module = std::string_view(m_blockname).substr(0,space);
26 std::string_view type = std::string_view(m_blockname).substr(space+1);
27
28 while(getline(file,buf)){
29 if(buf.compare(0,module.size(),module)==0) break;
30 }
31
32 while(getline(file,buf)){
33 if(buf.compare(1,type.size(),type)==0) break;
34 }
35
36 while(getline(file,buf)){
37 if(buf.compare(0,2," ")!=0) break;
38 std::istringstream line(buf);
39 std::vector<int> entry;
40 for(int i=0; i<6; i++){
41 int temp=-1;
42 line >> temp;
43 entry.push_back(temp);
44 }
45 m_database.emplace_back(std::move(entry));
46 }
47
48 file.close();
49}
50
54
55bool TGCDatabaseSLBToROD::update(const std::vector<int>& input)
56{
57 int ip = find(input);
58 if(ip<0) return false;
59
60 if(input.size()<6) {
61 // SSW block
62 m_database[ip].at(1) = input.at(1);
63 } else {
64 // SLB block
65 m_database[ip].at(4) = input.at(4);
66 m_database[ip].at(5) = input.at(5);
67 }
68
69 return true;
70}
71
72int TGCDatabaseSLBToROD::find(const std::vector<int>& channel) const
73{
74 int index=-1;
75
76 const unsigned int size = m_database.size();
77
78 if(channel.size()<4) {
79 // SSW block
80 for(unsigned int i=0; i<size; i++){
81 if(m_database[i].at(0) == channel.at(0)){
82 index = i;
83 break;
84 }
85 }
86 } else {
87 // SLB block
88 for(unsigned int i=0; i<size; i++){
89 if(m_database[i].at(3) == channel.at(3) &&
90 m_database[i].at(2) == channel.at(2) &&
91 m_database[i].at(1) == channel.at(1) &&
92 m_database[i].at(0) == channel.at(0)){
93 index = i;
94 break;
95 }
96 }
97 }
98
99 return index;
100}
101
102} // end of namespace
virtual bool update(const std::vector< int > &)
virtual int find(const std::vector< int > &) const
std::vector< std::vector< int > > m_database
Definition TGCDatabase.h:54
TGCDatabase(DatabaseType type=NoDatabaseType)
Definition index.py:1
TFile * file