ATLAS Offline Software
han.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
10 #include <iostream>
11 #include <string>
12 #include <cstdlib>
13 
14 #include "TPython.h"
18 
19 namespace {
20 
21 int usage( const std::string& command_name, int exit_code );
22 
23 struct CmdLineArgs {
24  int parse( int argc, char *argv[] );
25 
26  std::string command;
27  std::string hconfig;
28  std::string data;
29  std::string path;
30  std::string output;
31  std::string cmdlineConditions;
32 };
33 
34 } // unnamed namespace
35 
36 
37 int main ATLAS_NOT_THREAD_SAFE ( int argc, char *argv[] )
38 {
39  TPython::Exec("import logging; logging.basicConfig()");
40  CmdLineArgs arg;
41  int rc = arg.parse( argc, argv );
42  if (rc!=0) return rc;
43 
44  std::string inputName( arg.data );
45  std::string configName( arg.hconfig );
46  std::string pathName( arg.path );
47  std::string outputName;
48  if( arg.output != "" ) {
49  outputName = arg.output;
50  }
51  else {
52  std::string::size_type s = inputName.size();
53  std::string::size_type p = inputName.rfind( '.', s );
54  outputName = inputName.substr( 0, p );
55  outputName += "_han.root";
56  }
57 
59  if (arg.cmdlineConditions != "") {
60  std::cout<<"Input Conditions="<<dqi::ConditionsSingleton::getInstance().getCondition()
61  <<std::endl;
62  }
63  dqi::HanApp app;
64  return app.Analyze( configName, inputName, outputName, pathName );
65 }
66 
67 
68 // ************************************************************
69 // Private Functions
70 // ************************************************************
71 
72 namespace {
73 
74 int usage( const std::string& command_name, int exit_code )
75 {
76  std::string message;
77  message += "\n";
78  message += "This program takes as arguments the name of a configuration\n";
79  message += "file and the name of the data file to be analyzed.\n";
80  message += "One may optionally specify a path within the data file to analyze\n";
81  message += "and additionally the name of the file with the output results.\n";
82  message += "If no output file is specified, a name based on the input is used.\n";
83 
84  std::string::size_type s = command_name.size();
85  std::string::size_type p = command_name.rfind( '/', s );
86  std::string short_name = command_name.substr( p+1, s );
87 
88  std::cout << "\n";
89  std::cout << "Usage: " << short_name << " <config_file> <data_file> [path [results_file]]\n";
90  std::cout << message << "\n";
91  return exit_code;
92 }
93 
94 
95 int CmdLineArgs::parse( int argc, char *argv[] )
96 {
97  command = argv[0];
98  if( argc > 6 ) return usage( command, 1 );
99  if( argc < 3 ) return usage( command, 0 );
100 
101  hconfig = argv[1];
102  data = argv[2];
103  path = (argc == 4 || argc == 5 ||argc ==6) ? argv[3] : "";
104  output = (argc == 5 || argc== 6) ? argv[4] : "";
105  cmdlineConditions = (argc == 6) ? argv[5] : "";
106  return 0;
107 }
108 
109 } // unnamed namespace
110 
AtlCoolConsole.usage
tuple usage
Definition: AtlCoolConsole.py:443
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
HanApp.h
dqi::ConditionsSingleton::getInstance
static ConditionsSingleton & getInstance()
Definition: ConditionsSingleton.cxx:20
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:126
ATLAS_NOT_THREAD_SAFE
int main ATLAS_NOT_THREAD_SAFE(int argc, char *argv[])
Definition: han.cxx:37
dqi::HanApp::Analyze
virtual int Analyze(const std::string &configName_, const std::string &inputName_, const std::string &outputName_, const std::string &path_="")
Definition: HanApp.cxx:86
parse
std::map< std::string, std::string > parse(const std::string &list)
Definition: egammaLayerRecalibTool.cxx:983
LArCellConditions.argv
argv
Definition: LArCellConditions.py:112
dqi::ConditionsSingleton::getCondition
const std::string & getCondition() const
Definition: ConditionsSingleton.cxx:29
ReweightUtils.message
message
Definition: ReweightUtils.py:15
main
int main(int, char **)
Main class for all the CppUnit test classes
Definition: CppUnit_SGtestdriver.cxx:141
covarianceTool.pathName
pathName
Definition: covarianceTool.py:704
ConditionsSingleton.h
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
create_dcsc_inputs_sqlite.arg
list arg
Definition: create_dcsc_inputs_sqlite.py:48
merge.output
output
Definition: merge.py:17
dqi::HanApp
Definition: HanApp.h:21
lumiFormat.outputName
string outputName
Definition: lumiFormat.py:71
dqi::ConditionsSingleton::setCondition
void setCondition(const std::string &c)
Definition: ConditionsSingleton.cxx:25
checker_macros.h
Define macros for attributes used to control the static checker.
get_generator_info.command
string command
Definition: get_generator_info.py:38