35 {
36
37 std::cout << std::endl << "*** Running the calibration ***" << std::endl << std::endl;
38
39 std::string configfile("");
40 TString inputfile("");
41 int part = -1;
42 std::string parfile("parameters.txt");
43 int ask = 1;
44
45
46
47
48
49 for (int i = 1; i < argc; i++){
50
51 std::string
arg(argv[i]);
52
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;
75 exit(1);
76 }
77 }
78
79 if( configfile == "" && inputfile == "" ){
80 std::cout << "ERROR: No input file was given..." << std::endl;
81 return 1;
82 }
83
84
85 std::string ready("y");
86
87
89
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");
96
97
98
99
100 if( configfile != "" ){
103 }
104 else{
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;
109
110 int bgbins[5];
111 double bgmax[5];
112 double bgmin[5];
113
114
115 bgbins[0] = 30;
116 bgmax[0] = 2.12/Widget::mpion;
117 bgmin[0] = 0.12/Widget::mpion;
118 bgbins[1] = 10;
119 bgmax[1] = 1.8/Widget::mkaon;
120 bgmin[1] = 0.35/Widget::mkaon;
121 bgbins[2] = 10;
122 bgmax[2] = 1.7/Widget::mproton;
123 bgmin[2] = 0.5/Widget::mproton;
124 bgbins[3] = 15;
125 bgmax[3] = 1.92/Widget::mmuon;
126 bgmin[3] = 1.76/Widget::mmuon;
127 bgbins[4] = 30;
128 bgmax[4] = 2.3/Widget::melectron;
129 bgmin[4] = 0.3/Widget::melectron;
130
131 int cosbins[5];
132 double cosmax[5];
133 double cosmin[5];
134 for( int i = 0; i < 4; ++i ){
135 cosbins[i] = 18;
136 cosmax[i] = 0.93;
137 cosmin[i] = 0.0;
138 }
139 cosbins[4] = 18;
140 cosmax[4] = 0.93;
141 cosmin[4] = 0.5;
142
143
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]);
149 else
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]);
153 }
154 }
155
156
158
159
160
161
162 std::streambuf *coutbuf = std::cout.rdbuf();
163 std::ofstream out("widget.log");
164
165
166
167
168 if( ask == 1 ){
169 std::cout << "Do you want to make quality plots (y/n)? ";
170 std::cin >> ready; std::cout << std::endl;
171 }
172 if( ask == 0 || ready == "y" )
174
175
176
177
178
179
180 if( ask == 1 ){
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;
183 }
184 if( ask == 0 || ready == "y" ){
185 std::cout.rdbuf( out.rdbuf() );
186 if( part == -1 )
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;
196 }
197 return 1;
198 }
199 else{
200 widget.
PrepareSample(
"widget.uncorrected.root",
false, part );
201 return 1;
202 }
203 std::cout.rdbuf( coutbuf );
204 }
205
206
207
208
209
210
211 if( ask == 1 ){
212 std::cout << "Do you want to do to the hadron correction (y/n)? ";
213 std::cin >> ready; std::cout << std::endl;
214 }
215 if( ask == 0 || ready == "y" ){
216 std::cout.rdbuf( out.rdbuf() );
219 std::cout.rdbuf( coutbuf );
220 }
221
222
223
224
225
226 if( ask == 1 ){
227 std::cout << "Do you want to repeat to the hadron correction (y/n)? ";
228 std::cin >> ready; std::cout << std::endl;
229 }
230 if( ask == 0 || ready == "y" ){
231 std::cout.rdbuf( out.rdbuf() );
234 std::cout.rdbuf( coutbuf );
235 }
236
237
238
239
240
241 if( ask == 1 ){
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;
244 }
245 if( ask == 0 || ready == "y" ){
246 std::cout.rdbuf( out.rdbuf() );
249 std::cout.rdbuf( coutbuf );
250 }
251
252
253
254
255
256 if( ask == 1 ){
257 std::cout << "Do you want to fit the beta-gamma curve (y/n)? ";
258 std::cin >> ready; std::cout << std::endl;
259 }
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 );
267 }
268
269
270
271
272 if( ask == 1 ){
273 std::cout << "Do you want to plot the beta-gamma curve (y/n)? ";
274 std::cin >> ready; std::cout << std::endl;
275 }
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 );
280 }
281
282
283
284
285
286
287 if( ask == 1 ){
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;
290 }
291 if( ask == 0 || ready == "y" ){
292 std::cout.rdbuf( out.rdbuf() );
295 widget.
SigmaFits(
"widget.corrected.root");
298 std::cout.rdbuf( coutbuf );
299 }
300
301}
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)