21 {
22
23 std::cout << std::endl << "*** Running the electron calibration ***" << std::endl << std::endl;
24
25 std::string configfile("electron.template.txt");
26 std::string ask("y");
27
28
29
30
31
32 for (int i = 1; i < argc; i++){
33
34 std::string
arg(argv[i]);
35
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;
46 exit(1);
47 }
48 }
49
50 if( configfile == "" ){
51 std::cout << "ERROR: No configuration file was given..." << std::endl;
52 return 1;
53 }
54
55
56 std::string ready("y");
57
58
60
61
62
63
64
65 if( configfile != "" )
67 else{
68 std::cout << "ElectronCalibration ERROR: No configuration file provided";
69 return 1;
70 }
71
72 std::cout << "Done configuring settings. Output redirected to log file." << std::endl;
73
74
75
76 std::streambuf *coutbuf = std::cout.rdbuf();
77 std::ofstream out("widget.electron.log");
78
79
80
81
82
83 if( ask == "y" ){
84 std::cout << "Do you want to generate the sample (y/n)? ";
85 std::cin >> ready; std::cout << std::endl;
86 }
87 if( ready == "y" ){
88 std::cout << "Generating the sample..." << std::endl;
89
90 std::cout.rdbuf( out.rdbuf() );
92 std::cout.rdbuf( coutbuf );
93 }
94
95
96
98
99
100
101
102
103
104 if( ask == "y" ){
105 std::cout << "Do you want to apply the old constants (y/n)? ";
106 std::cin >> ready; std::cout << std::endl;
107 }
108 if( ready == "y" ){
109 std::cout << "Applying old constants..." << std::endl;
110
111 std::cout.rdbuf( out.rdbuf() );
114 std::cout.rdbuf( coutbuf );
115 }
116
117
118
119
120
121
122
123 if( ask == "y" ){
124 std::cout << "Do you want to determine the run gains (y/n)? ";
125 std::cin >> ready; std::cout << std::endl;
126 }
127 if( ready == "y" ){
128 std::cout << "Getting run gains..." << std::endl;
129
130 std::cout.rdbuf( out.rdbuf() );
132
133
137
138 std::cout.rdbuf( coutbuf );
139 }
140
141
142
143
144
145
146
147 if( ask == "y" ){
148 std::cout << "Do you want to do the 2d correction (y/n)? ";
149 std::cin >> ready; std::cout << std::endl;
150 }
151 if( ready == "y" ){
152 std::cout << "Doing 2d correction..." << std::endl;
153
154 std::cout.rdbuf( out.rdbuf() );
156
157
161
162 std::cout.rdbuf( coutbuf );
163 }
164
165
166
167
168
169
170 if( ask == "y" ){
171 std::cout << "Do you want to do the saturation correction (y/n)? ";
172 std::cin >> ready; std::cout << std::endl;
173 }
174 if( ready == "y" ){
175 std::cout << "Doing saturation correction..." << std::endl;
176
177 std::cout.rdbuf( out.rdbuf() );
179
180
184
185 std::cout.rdbuf( coutbuf );
186 }
187
188
189 std::cout << std::endl << std::endl << "DONE ELECTRON CALIBRATION" << std::endl;
190
191 out.close();
192}
double arg(const EvtComplex &c)
void SetupFromConfigFile(std::string configfile)
void RunGains(TString outfilename)
void ApplyCorrections(TString outfile)
void SaturationCorrection(TString outfilename)
void SetFileName(TString newfilename)
void TwoDCorrection(TString outfilename)
void GenerateSample(TString outfile)