31#include "TApplication.h"
35int main(
int argc,
char* argv[] ) {
37 std::cout << std::endl <<
"*** Running the calibration ***" << std::endl << std::endl;
39 std::string configfile(
"");
40 TString inputfile(
"");
42 std::string parfile(
"parameters.txt");
49 for (
int i = 1; i < argc; i++){
51 std::string
arg(argv[i]);
54 if ((i+1 == argc) || (argv[i+1][0] ==
'-'))
arg =
"-h";
55 else configfile = argv[++i]; }
57 if ((i+1 == argc) || (argv[i+1][0] ==
'-'))
arg =
"-h";
58 else inputfile = argv[++i]; }
60 if ((i+1 == argc) || (argv[i+1][0] ==
'-'))
arg =
"-h";
61 else parfile = argv[++i]; }
63 if ((i+1 == argc) || (argv[i+1][0] ==
'-'))
arg =
"-h";
64 else part = atoi(argv[++i]); }
66 if ((i+1 == argc) || (argv[i+1][0] ==
'-'))
arg =
"-h";
67 else ask = atoi(argv[++i]); }
69 std::cout << std::endl <<
" Usage for: " << argv[0] << std::endl << std::endl;
70 std::cout <<
"\t -c <file>\t Configuration file" << std::endl;
71 std::cout <<
"\t -f <file>\t Input file" << std::endl;
72 std::cout <<
"\t -p <file>\t Curve parameter file" << std::endl;
73 std::cout <<
"\t -t <int>\t Particle type (-1 = all)" << std::endl;
74 std::cout <<
"\t -i <int>\t Ask before each step? (0 = no, 1 = yes)" << std::endl;
79 if( configfile ==
"" && inputfile ==
"" ){
80 std::cout <<
"ERROR: No input file was given..." << std::endl;
85 std::string ready(
"y");
90 std::vector< TString > types;
91 types.push_back(
"pion");
92 types.push_back(
"kaon");
93 types.push_back(
"proton");
94 types.push_back(
"muon");
95 types.push_back(
"electron");
100 if( configfile !=
"" ){
105 std::cout <<
"No configuration file provided, ";
106 std::cout <<
"are you sure you want to use the default values (y/n)? ";
107 std::cin >> ready; std::cout << std::endl;
108 if( ready !=
"y" )
return 1;
116 bgmax[0] = 2.12/Widget::mpion;
117 bgmin[0] = 0.12/Widget::mpion;
119 bgmax[1] = 1.8/Widget::mkaon;
120 bgmin[1] = 0.35/Widget::mkaon;
122 bgmax[2] = 1.7/Widget::mproton;
123 bgmin[2] = 0.5/Widget::mproton;
125 bgmax[3] = 1.92/Widget::mmuon;
126 bgmin[3] = 1.76/Widget::mmuon;
128 bgmax[4] = 2.3/Widget::melectron;
129 bgmin[4] = 0.3/Widget::melectron;
134 for(
int i = 0; i < 4; ++i ){
144 for(
int i = 0; i < 5; ++i ){
145 if( inputfile !=
"" )
146 widget.
AddParticle(types[i],inputfile+types[i]+
".root",0.0,
147 bgbins[i],bgmax[i],bgmin[i],
148 cosbins[i],cosmax[i],cosmin[i]);
150 widget.
AddParticle(types[i],
"widget."+types[i]+
".root",0.0,
151 bgbins[i],bgmax[i],bgmin[i],
152 cosbins[i],cosmax[i],cosmin[i]);
162 std::streambuf *coutbuf = std::cout.rdbuf();
163 std::ofstream out(
"widget.log");
169 std::cout <<
"Do you want to make quality plots (y/n)? ";
170 std::cin >> ready; std::cout << std::endl;
172 if( ask == 0 || ready ==
"y" )
181 std::cout <<
"Do you want to fit in bins of beta-gamma and cos(theta) (y/n)? ";
182 std::cin >> ready; std::cout << std::endl;
184 if( ask == 0 || ready ==
"y" ){
185 std::cout.rdbuf( out.rdbuf() );
187 widget.
PrepareSample(
"widget.uncorrected.root",
false, -1 );
188 else if( part == -2 ){
189 for(
int i = 0; i < 4; ++i ){
191 std::cout.rdbuf( out.rdbuf() );
192 std::cout <<
"Ready to move on to the next particle (y/n)? ";
193 std::cin >> ready; std::cout << std::endl;
194 std::cout.rdbuf( coutbuf );
195 if( ready !=
"y" )
return 1;
200 widget.
PrepareSample(
"widget.uncorrected.root",
false, part );
203 std::cout.rdbuf( coutbuf );
212 std::cout <<
"Do you want to do to the hadron correction (y/n)? ";
213 std::cin >> ready; std::cout << std::endl;
215 if( ask == 0 || ready ==
"y" ){
216 std::cout.rdbuf( out.rdbuf() );
219 std::cout.rdbuf( coutbuf );
227 std::cout <<
"Do you want to repeat to the hadron correction (y/n)? ";
228 std::cin >> ready; std::cout << std::endl;
230 if( ask == 0 || ready ==
"y" ){
231 std::cout.rdbuf( out.rdbuf() );
234 std::cout.rdbuf( coutbuf );
242 std::cout <<
"Do you want to perform the fits in bins of beta-gamma (y/n)? ";
243 std::cin >> ready; std::cout << std::endl;
245 if( ask == 0 || ready ==
"y" ){
246 std::cout.rdbuf( out.rdbuf() );
249 std::cout.rdbuf( coutbuf );
257 std::cout <<
"Do you want to fit the beta-gamma curve (y/n)? ";
258 std::cin >> ready; std::cout << std::endl;
260 if( ask == 0 || ready ==
"y" ){
261 std::cout.rdbuf( out.rdbuf() );
263 widget.
SigmaFits(
"widget.corrected.root");
264 widget.
SigmaFits(
"widget.corrected.root");
265 widget.
SigmaFits(
"widget.corrected.root");
266 std::cout.rdbuf( coutbuf );
273 std::cout <<
"Do you want to plot the beta-gamma curve (y/n)? ";
274 std::cin >> ready; std::cout << std::endl;
276 if( ask == 0 || ready ==
"y" ){
277 std::cout.rdbuf( out.rdbuf() );
278 widget.
PlotBGCurve(types,
"widget.corrected_bgbins.root");
279 std::cout.rdbuf( coutbuf );
288 std::cout <<
"Do you want to repeat the fits in bins of beta-gamma (y/n)? ";
289 std::cin >> ready; std::cout << std::endl;
291 if( ask == 0 || ready ==
"y" ){
292 std::cout.rdbuf( out.rdbuf() );
295 widget.
SigmaFits(
"widget.corrected.root");
298 std::cout.rdbuf( coutbuf );
double arg(const EvtComplex &c)
void BetaGammaFits(std::vector< TString > particles, TString filename)
void SetParamFile(std::string paramfile)
void QualityCheck(TString outfilename)
void PrepareResults(TString outfilename, bool correct)
void PrepareSample(TString outfilename, bool correct, int particle)
void SaturationCorrection(TString prepfilename, std::string parfile)
void PlotBGCurve(std::vector< TString > particles, TString filename)
void SetupFromConfigFile(std::string configfile)
void AddParticle(TString particle, TString filename, int nevents, int bgbins, double upperbg, double lowerbg, int cosbins, double uppercos, double lowercos)
void SigmaFits(TString filename)