ATLAS Offline Software
Loading...
Searching...
No Matches
han_config_gen.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include <iostream>
6#include <string>
7#include <cstdlib>
8
11
14#include "TInterpreter.h"
15
16namespace {
17
18int usage( const std::string& command_name, int exit_code );
19
20struct CmdLineArgs {
21 int parse( int argc, char *argv[] );
22
23 std::string m_connectionString = "sqlite://;schema=/afs/cern.ch/user/a/atlasdqm/dqmdisk1/cherrypy-devel/RefDB.db;dbname=REFDB";
24 long m_runNumber = 2147483646;
25 bool m_bulk = false;
26
27 std::string command;
28 std::string mconfig;
29 std::string conds;
30};
31
32} // unnamed namespace
33
34
35int main ATLAS_NOT_THREAD_SAFE ( int argc, char *argv[] )
36{
37 CxxUtils::ubsan_suppress ([]() { TInterpreter::Instance(); });
38
39 CmdLineArgs arg;
40 int rc = arg.parse( argc, argv );
41 if (rc!=0) return rc;
42
43 std::string infileName( arg.mconfig );
45 //std::cout<<__PRETTY_FUNCTION__<<"Input Conditions="<<dqi::ConditionsSingleton::getInstance().getCondition()
46 //<<std::endl;
47 std::string outfileName;
48
49 std::string::size_type s = infileName.size();
50 std::string::size_type p = infileName.rfind( '.', s );
51 outfileName = infileName.substr( 0, p );
52 outfileName += ".hcfg";
53
55 config.AssembleAndSave( infileName, outfileName, arg.m_connectionString, arg.m_runNumber, arg.m_bulk);
56 return 0;
57}
58
59
60// ************************************************************
61// Private Functions
62// ************************************************************
63
64namespace {
65
66int CmdLineArgs::parse( int argc, char *argv[] )
67{
68 command = argv[0];
69 if( argc > 10 ) return usage( command, 1 );
70 if( argc < 2 ) return usage( command, 0 );
71
72 mconfig = argv[1];
73
74 if(argc >= 3) {
75 int ic = 2;
76 while(ic < argc) {
77 int ir = argc - ic;
78 std::string par0 = argv[ic];
79 if(par0 == "-c") {
80 if(ir > 1) {
81 m_connectionString = argv[ic + 1];
82 std::cout << "Setting DB connection string to " << m_connectionString << std::endl;
83 ++ic;
84 }
85 } else if(par0 == "-r") {
86 if(ir > 1) {
87 try {
88 m_runNumber = std::stol(argv[ic + 1]);
89 std::cout << "Setting run number to " << m_runNumber << std::endl;
90 ++ic;
91 } catch(std::exception& e) {
92 std::cout << "Error with input arguments, specified run " << argv[ic+1] << " not a long" << '\n';
93 }
94 }
95 } else if(par0 == "-b") {
96 if(ir > 1) {
97 m_bulk = (strcmp(argv[ic+1], "true") == 0);
98 std::cout << "Setting bulk processing mode to " << (m_bulk ? "true" : "false") << std::endl;
99 ++ic;
100 }
101 } else {
102 conds = argv[ic];
103 }
104 ++ic;
105 }
106 }
107 return 0;
108}
109
110
111int usage( const std::string& command_name, int exit_code )
112{
113 std::string message;
114 message += "\n";
115 message += "This program takes as an argument the name of a file containing\n";
116 message += "a MiniConfig configuration and produces a similarly named Root file\n";
117 message += "containing a configuration for the \'han\' application\n";
118
119 std::string::size_type s = command_name.size();
120 std::string::size_type p = command_name.rfind( '/', s );
121 std::string short_name = command_name.substr( p+1, s );
122
123 std::cout << "\n";
124 std::cout << "Usage: " << short_name << " <filename>\n";
125 std::cout << message << "\n";
126 return exit_code;
127}
128
129
130} // 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)
int ir
counter of the current depth
Definition fastadd.cxx:49
StatusCode usage()
void ubsan_suppress(void(*func)())
Helper for suppressing ubsan warnings.
int ic
Definition grepfile.py:33
Helper for suppressing ubsan warnings.