21int main(
int argc,
char* argv[] ) {
23 std::cout << std::endl <<
"*** Running the electron calibration ***" << std::endl << std::endl;
25 std::string configfile(
"electron.template.txt");
32 for (
int i = 1; i < argc; i++){
34 std::string
arg(argv[i]);
37 if ((i+1 == argc) || (argv[i+1][0] ==
'-'))
arg =
"-h";
38 else configfile = argv[++i]; }
40 if ((i+1 == argc) || (argv[i+1][0] ==
'-'))
arg =
"-h";
41 else ask = argv[++i]; }
43 std::cout << std::endl <<
" Usage for: " << argv[0] << std::endl << std::endl;
44 std::cout <<
"\t -c <file>\t Configuration file" << std::endl;
45 std::cout <<
"\t -i <int>\t Ask before each step (y/n)" << std::endl;
50 if( configfile ==
"" ){
51 std::cout <<
"ERROR: No configuration file was given..." << std::endl;
56 std::string ready(
"y");
65 if( configfile !=
"" )
68 std::cout <<
"ElectronCalibration ERROR: No configuration file provided";
72 std::cout <<
"Done configuring settings. Output redirected to log file." << std::endl;
76 std::streambuf *coutbuf = std::cout.rdbuf();
77 std::ofstream out(
"widget.electron.log");
84 std::cout <<
"Do you want to generate the sample (y/n)? ";
85 std::cin >> ready; std::cout << std::endl;
88 std::cout <<
"Generating the sample..." << std::endl;
90 std::cout.rdbuf( out.rdbuf() );
92 std::cout.rdbuf( coutbuf );
105 std::cout <<
"Do you want to apply the old constants (y/n)? ";
106 std::cin >> ready; std::cout << std::endl;
109 std::cout <<
"Applying old constants..." << std::endl;
111 std::cout.rdbuf( out.rdbuf() );
114 std::cout.rdbuf( coutbuf );
124 std::cout <<
"Do you want to determine the run gains (y/n)? ";
125 std::cin >> ready; std::cout << std::endl;
128 std::cout <<
"Getting run gains..." << std::endl;
130 std::cout.rdbuf( out.rdbuf() );
138 std::cout.rdbuf( coutbuf );
148 std::cout <<
"Do you want to do the 2d correction (y/n)? ";
149 std::cin >> ready; std::cout << std::endl;
152 std::cout <<
"Doing 2d correction..." << std::endl;
154 std::cout.rdbuf( out.rdbuf() );
162 std::cout.rdbuf( coutbuf );
171 std::cout <<
"Do you want to do the saturation correction (y/n)? ";
172 std::cin >> ready; std::cout << std::endl;
175 std::cout <<
"Doing saturation correction..." << std::endl;
177 std::cout.rdbuf( out.rdbuf() );
185 std::cout.rdbuf( coutbuf );
189 std::cout << std::endl << std::endl <<
"DONE ELECTRON CALIBRATION" << std::endl;