ATLAS Offline Software
Loading...
Searching...
No Matches
han_config_print.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
7
8#include <iostream>
9#include <string>
10#include <cstdlib>
11
12#include <TFile.h>
13#include <TKey.h>
14
16
20
21namespace {
22
23int usage( const std::string& command_name, int exit_code );
24
25struct CmdLineArgs {
26 int parse( int argc, char *argv[] );
27
28 std::string command;
29 std::string hconfig;
30 std::string conditions;
31};
32
33} // unnamed namespace
34
35
36int main ATLAS_NOT_THREAD_SAFE ( int argc, char *argv[] )
37{
38 CmdLineArgs arg;
39 int rc = arg.parse( argc, argv );
40 if (rc!=0) return rc;
41
43 //std::cout<<__PRETTY_FUNCTION__<<"Input Conditions="<<dqi::ConditionsSingleton::getInstance().getCondition()
44 // <<std::endl;
45 std::string configName( arg.hconfig );
46 TFile* config = TFile::Open( configName.c_str() );
47 if( config == 0 ) {
48 std::cerr << "Cannot open file \"" << configName << "\"\n";
49 return 1;
50 }
51
52 TKey* key = config->FindKey("HanMetadata");
53 if (key) {
54 std::cout << "Metadata:\n";
55 TDirectory* metadatadir = dynamic_cast<TDirectory*>(key->ReadObj());
56 if (! metadatadir) {
57 std::cerr << "Metadata directory is malformed\n";
58 return 1;
59 }
60 dqi::HanConfigMetadata* hcm(0); TKey* mdkey(0);
61 TIter next(metadatadir->GetListOfKeys());
62 while ((mdkey = dynamic_cast<TKey*>(next()))) {
63 metadatadir->GetObject(mdkey->GetName(), hcm);
64 if (hcm) {
65 std::cout << *hcm << std::endl;
66 }
67 }
68 delete metadatadir;
69 }
70
71 key = config->FindKey("top_level");
72 if( key == 0 ) {
73 std::cerr << "Cannot find configuration in file \"" << configName << "\"\n";
74 return 1;
75 }
76
77 dqi::HanConfigGroup* g = dynamic_cast<dqi::HanConfigGroup*>( key->ReadObj() );
78 if( g == 0 ) {
79 std::cerr << "Cannot find configuration in file \"" << configName << "\"\n";
80 return 1;
81 }
82
83 std::cout << g;
84 return 0;
85}
86
87
88// ************************************************************
89// Private Functions
90// ************************************************************
91
92namespace {
93
94int CmdLineArgs::parse( int argc, char *argv[] )
95{
96 command = argv[0];
97 if( argc > 3 ) return usage( command, 1 );
98 if( argc < 2 ) return usage( command, 0 );
99
100 hconfig = argv[1];
101 if(argc==3)conditions = argv[2];
102 return 0;
103}
104
105
106int usage( const std::string& command_name, int exit_code )
107{
108 std::string message;
109 message += "\n";
110 message += "This program takes as an argument the name of a \'han\' configuration\n";
111 message += "file and prints the configuration.\n";
112
113 std::string::size_type s = command_name.size();
114 std::string::size_type p = command_name.rfind( '/', s );
115 std::string short_name = command_name.substr( p+1, s );
116
117 std::cout << "\n";
118 std::cout << "Usage: " << short_name << " <filename>\n";
119 std::cout << message << "\n";
120 return exit_code;
121}
122
123
124} // unnamed namespace
int main(int, char **)
Main class for all the CppUnit test classes.
static Double_t rc
Define macros for attributes used to control the static checker.
#define ATLAS_NOT_THREAD_SAFE
getNoisyStrip() Find noisy strips from hitmaps and write out into xml/db formats
static ConditionsSingleton & getInstance()
void setCondition(const std::string &c)
std::map< std::string, std::string > parse(const std::string &list)
StatusCode usage()