hpstr
The Heavy Photon Search Toolkit for Reconstruction (hpstr) provides an interface to physics data from the HPS experiment saved in the LCIO format and converts it into an ROOT based format.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
hpstr.cxx
Go to the documentation of this file.
1
8//----------------//
9// C++ StdLib //
10//----------------//
11#include <csignal>
12#include <cstdlib>
13#include <cstring>
14#include <iostream>
15#include <stdexcept>
16
17//-----------//
18// hpstr //
19//-----------//
20#include "ConfigurePython.h"
21
22using namespace std;
23
24void displayUsage();
25
26int main(int argc, char **argv) {
27
28 if (argc < 2) {
29 displayUsage();
30 return EXIT_FAILURE;
31 }
32
33 int ptrpy = 1;
34 for (ptrpy = 1; ptrpy < argc; ptrpy++) {
35 std::cout << argv[ptrpy] << std::endl;
36 if (strstr(argv[ptrpy], ".py"))
37 break;
38 }
39
40 if (ptrpy == argc) {
41 displayUsage();
42 printf(" ** No python script provided. **\n");
43 return EXIT_FAILURE;
44 }
45
46 try {
47
48 std::cout << "---- [ hpstr ]: Loading configuration --------" << std::endl;
49
50 ConfigurePython cfg(argv[ptrpy], argv + ptrpy + 1, argc - ptrpy -1);
51
52 std::cout << "---- [ hpstr ]: Configuration load complete --------" << std::endl;
53
54 Process* p = cfg.makeProcess();
55 int run_mode = p->getRunMode();
56
57 std::cout << "---- [ hpstr ]: Process mode " << run_mode << " initialized. --------" << std::endl;
58
59 // If Ctrl-c is used, immediately exit the application.
60 struct sigaction act;
61 memset (&act, '\0', sizeof(act));
62 if (sigaction(SIGINT, &act, NULL) < 0) {
63 perror ("sigaction");
64 return 1;
65 }
66
67 std::cout << "---- [ hpstr ]: Start of processing --------" << std::endl;
68
69 //TODO Make this better
70 if (run_mode == 0)
71 {
72 std::cout<<"---- [ hpstr ]: Running LCIO -> ROOT Process --------" << std::endl;
73 p->run();
74 }
75 else if (run_mode == 1)
76 {
77 std::cout<<"---- [ hpstr ]: Running ROOT -> Histo Process --------" << std::endl;
78 p->runOnRoot();
79 }
80 else if (run_mode == 2)
81 {
82 std::cout<<"---- [ hpstr ]: Running Histo Analysis Process --------" << std::endl;
83 p->runOnHisto();
84 }
85 else
86 {
87 std::cout<<"---- [ hpstr ]: Run Mode " << run_mode << " does not exist! --------" << std::endl;
88 }
89
90 std::cout << "---- [ hpstr ]: Event processing complete --------" << std::endl;
91
92 } catch (exception& e) {
93 std::cerr << "Error! [" << e.what() << "] \n";
94 std::cerr << "Program aborted. " << std::endl;
95
96 }
97
98 return EXIT_SUCCESS;
99
100}
101
103 printf("Usage: hpstr [application arguments] {configuration_script.py}"
104 " [arguments to configuration script]\n");
105}
Utility class that reads/executes a python script and creates a Process object based on the input.
Process * makeProcess()
int main(int argc, char **argv)
Definition hpstr.cxx:26
void displayUsage()
Definition hpstr.cxx:102