ATLAS Offline Software
Loading...
Searching...
No Matches
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
9
10#include <iostream>
11#include <string>
12#include <cstdlib>
13
14#include "TPython.h"
18
19namespace {
20
21int usage( const std::string& command_name, int exit_code );
22
23struct 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
37int 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
72namespace {
73
74int 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
95int 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
int main(int, char **)
Main class for all the CppUnit test classes.
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
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)
const std::string & getCondition() const
virtual int Analyze(const std::string &configName_, const std::string &inputName_, const std::string &outputName_, const std::string &path_="")
Definition HanApp.cxx:86
std::map< std::string, std::string > parse(const std::string &list)
StatusCode usage()