20 {
21
22 std::cout << std::endl << "*** Running the electron calibration ***" << std::endl << std::endl;
23
24 std::string configfile("electron.template.txt");
25 int ask = 0;
26
27
28
29
30
31 for (int i = 1; i < argc; i++){
32
33 std::string
arg(argv[i]);
34
36 if ((i+1 == argc) || (argv[i+1][0] ==
'-'))
arg =
"-h";
37 else configfile = argv[++i]; }
39 if ((i+1 == argc) || (argv[i+1][0] ==
'-'))
arg =
"-h";
40 else ask = atoi(argv[++i]); }
42 std::cout << std::endl << " Usage for: " << argv[0] << std::endl << std::endl;
43 std::cout << "\t -c <file>\t Configuration file" << std::endl;
44 std::cout << "\t -i <int>\t Ask before each step? (0 = no, 1 = yes)" << std::endl;
45 exit(1);
46 }
47 }
48
49 if( configfile == "" ){
50 std::cout << "ERROR: No configuration file was given..." << std::endl;
51 return 1;
52 }
53
54
55 std::string ready("y");
56
57
59
60
61
62
63
64 if( configfile != "" )
66 else{
67 std::cout << "ElectronCorrection ERROR: No configuration file provided";
68 return 1;
69 }
70
71 std::cout << "Done configuring settings..." << std::endl;
72
73
74
75 std::streambuf *coutbuf = std::cout.rdbuf();
76 std::ofstream out("widget.electron.log");
77
78
79
80
81
82 if( ask == 1 ){
83 std::cout << "Do you want to apply corrections (y/n)? ";
84 std::cin >> ready; std::cout << std::endl;
85 }
86 if( ask == 0 || ready == "y" ){
87 std::cout << "Applying corrections..." << std::endl;
88
89 std::cout.rdbuf( out.rdbuf() );
91 std::cout.rdbuf( coutbuf );
92 }
93
94
95 std::cout << std::endl << std::endl << "DONE ELECTRON CORRECTION" << std::endl;
96
97 out.close();
98}
double arg(const EvtComplex &c)
void SetupFromConfigFile(std::string configfile)
void ApplyCorrections(TString outfile)