ATLAS Offline Software
Loading...
Searching...
No Matches
TGCCablingDbTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "TGCCablingDbTool.h"
6
7#include "PathResolver/PathResolver.h" // needed for readASD2PP_DIFF_12FromText()
8#include <fstream> // needed for readASD2PP_DIFF_12FromText()
9
10//**********************************************************
11//* Author Monica Verducci monica.verducci@cern.ch
12//* Author Susumu Oda Susumu.Oda@cern.ch
13//*
14//* Tool to retrieve the TGC Cabling Map from COOL DB
15//* one callback aganist the class
16//* retrieving of tables from DB
17//*********************************************************
18
20 const std::string& name,
21 const IInterface* parent)
22 : base_class(type, name, parent),
23 m_DataLocation ("keyTGC")
24{
25 declareProperty("Folder", m_Folder="/TGC/CABLING/MAP_SCHEMA");
26
27 // ASD2PP_diff_12.db is the text database for the TGCcabling12 package
28 declareProperty("filename_ASD2PP_DIFF_12", m_filename="ASD2PP_diff_12_ONL.db");
29 declareProperty("readASD2PP_DIFF_12FromText", m_readASD2PP_DIFF_12FromText=true);
30}
31
33 ATH_MSG_INFO("initialize");
34 return StatusCode::SUCCESS;
35}
36
38 return m_Folder;
39}
40
41std::vector<std::string>* TGCCablingDbTool::giveASD2PP_DIFF_12() {
42 ATH_MSG_INFO("giveASD2PP_DIFF_12 (m_ASD2PP_DIFF_12 is " << (!m_ASD2PP_DIFF_12 ? "NULL" : "not NULL") << ")");
43
44 // If no database found, null pointer is returned.
45 if(!m_ASD2PP_DIFF_12) {
46 return nullptr;
47 }
48
49 // Copy the database
50 return new std::vector<std::string> (*m_ASD2PP_DIFF_12);
51}
52
54 ATH_MSG_INFO("readTGCMap from text");
55
56 // PathResolver finds the full path of the file (default file name is ASD2PP_diff_12.db)
57 std::string location = PathResolver::find_file(m_filename, "DATAPATH");
58 if(location.empty()) {
59 ATH_MSG_ERROR("Could not find " << m_filename.c_str());
60 return StatusCode::FAILURE;
61 }
62
63 // ASD2PP_diff_12.db is opened as inASDToPP
64 std::ifstream inASDToPP;
65 inASDToPP.open(location.c_str());
66 if(inASDToPP.bad()) {
67 ATH_MSG_ERROR("Could not open file " << location.c_str());
68 return StatusCode::FAILURE;
69 }
70
71 ATH_MSG_INFO("readTGCMap found file " << location.c_str());
72
73 // New database is created
74 m_ASD2PP_DIFF_12.reset(new std::vector<std::string>);
75
76 unsigned int nLines = 0;
77 std::string buf;
78 // Copy database into m_ASD2PP_DIFF_12
79 while(getline(inASDToPP, buf)){
80 m_ASD2PP_DIFF_12->push_back(buf);
81 ATH_MSG_DEBUG(m_filename.c_str() << " L" << ++nLines << ": " << buf.c_str());
82 }
83
84 inASDToPP.close();
85 return StatusCode::SUCCESS;
86}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
std::unique_ptr< std::vector< std::string > > m_ASD2PP_DIFF_12
Database as strings.
std::string m_filename
File name of the text database.
std::string m_DataLocation
Data location.
virtual std::string getFolderName() const override
Get the folder name.
virtual std::vector< std::string > * giveASD2PP_DIFF_12() override
Method to provide database.
std::string m_Folder
Folder name.
bool m_readASD2PP_DIFF_12FromText
Flag for readASD2PP_DIFF_12FromText()
TGCCablingDbTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor.
virtual StatusCode initialize() override
Initilize.
virtual StatusCode readASD2PP_DIFF_12FromText() override
Load parameters from text database.