115int main(
int argc,
char *argv[] ) {
118 std::cout <<
"usage: mb_angle_fit <settings_file> <reaction_file> <centroids_file>" << std::endl << std::endl;
119 std::cout <<
"where centroids_file contains the un-doppler corrected centroids for cores gated on each segment" << std::endl;
120 std::cout <<
"for some reference transition. The format for centroids_file is" << std::endl << std::endl;
121 std::cout <<
"cluster crystal segment energy uncertainty" << std::endl << std::endl;
122 std::cout <<
"beta (v/c), as well as the theta, phi, alpha, and R values for each detector present are varied." << std::endl;
123 std::cout <<
"The reference energy is set at 440.2 keV, this can be varied but will need to be recompiled." << std::endl;
130 TFile *file =
new TFile(
"MiniballAngleFits.root",
"recreate");
133 std::vector<double> pars(1+7*4);
134 std::vector<std::string> names(1+7*4);
135 std::vector<double> LL(1+7*4);
136 std::vector<double> UL(1+7*4);
138 pars[0] = ff.
myreact->GetBeta();
143 TEnv *config =
new TEnv( argv[2] );
146 for(
unsigned int clu=0; clu<8; ++clu ) {
148 if (ff.
cluster[clu] == 0) {
continue; }
151 pars[indx] = config->GetValue( Form(
"MiniballCluster_%d.Theta", clu ), 0. );
152 pars[indx+1] = config->GetValue( Form(
"MiniballCluster_%d.Phi", clu ), 0. );
153 pars[indx+2] = config->GetValue( Form(
"MiniballCluster_%d.Alpha", clu ), 0. );
154 pars[indx+3] = config->GetValue( Form(
"MiniballCluster_%d.R", clu ), 0. );
156 names[indx] =
"theta"+std::to_string(clu);
157 names[indx+1] =
"phi"+std::to_string(clu);
158 names[indx+2] =
"alpha"+std::to_string(clu);
159 names[indx+3] =
"r"+std::to_string(clu);
176 ROOT::Math::Minimizer *min =
177 ROOT::Math::Factory::CreateMinimizer(
"Minuit2",
"Migrad");
179 ROOT::Math::Functor f_init(ff,4*nClusters+1);
181 min->SetErrorDef(1.);
182 min->SetMaxFunctionCalls(1000);
183 min->SetMaxIterations(1000);
184 min->SetTolerance(0.001);
185 min->SetPrecision(1e-6);
186 min->SetFunction(f_init);
188 for(
unsigned int i = 0; i < pars.size(); ++i ) {
189 min->SetLimitedVariable(i, names.at(i), pars.at(i), 0.0001, LL.at(i), UL.at(i));
190 min->SetVariableStepSize(i, 1.0);
192 min->SetVariableStepSize(0, 0.001);
201 for(
unsigned int clu = 0; clu < 8 ; ++clu ) {
202 if (ff.
cluster[clu] == 0) {
continue; }
203 ff.
myreact->SetupCluster(clu, min->X()[indx], min->X()[indx+1], min->X()[indx+2], min->X()[indx+3], 0.0);
208 TGraphErrors *engraph =
new TGraphErrors();
209 engraph->SetName(
"engraph; Experimental energies; Channel index; Energy [keV]");
210 TGraph *calcgraph =
new TGraph();
211 calcgraph->SetName(
"calcgraph; Calculated energies; Channel index; Energy [keV]");
212 TGraphErrors *resgraph =
new TGraphErrors();
213 resgraph->SetName(
"resgraph; Residuals; Channel index; Energy [keV]"");");
214 TGraphErrors *corrgraph =
new TGraphErrors();
215 corrgraph->SetName(
"corrgraph; Doppler-corrected energies; Channel index; Energy [keV]"");");
218 engraph->GetXaxis()->SetTitle(
"Channel index");
219 engraph->GetYaxis()->SetTitle(
"Energy [keV]");
221 corrgraph->GetXaxis()->SetTitle(
"Channel index");
222 corrgraph->GetYaxis()->SetTitle(
"Doppler-corrected energy [keV]");
224 resgraph->GetXaxis()->SetTitle(
"Channel index");
225 resgraph->GetYaxis()->SetTitle(
"Energy Residual [keV]");
228 for(
unsigned int clu = 0; clu < 8; ++clu ) {
229 for(
unsigned int cry = 0; cry < 3; ++cry ) {
230 for(
unsigned int seg = 0; seg < 7; ++seg ) {
232 if (ff.
present[clu][cry][seg] == 0) {
continue; }
233 double beta = min->X()[0];
234 double theta = ff.
myreact->GetGammaTheta(clu ,cry, seg);
235 double corr = 1. - beta * std::cos(theta);
236 corr *= 1./(std::sqrt(1.-std::pow(beta, 2.)));
237 double edop = ff.
eref/corr;
239 engraph->AddPoint(indx, ff.
energy[clu][cry][seg]);
240 engraph->SetPointError(engraph->GetN()-1, 0, ff.
err[clu][cry][seg]);
242 corrgraph->AddPoint(indx, ff.
energy[clu][cry][seg]*corr);
243 corrgraph->SetPointError(engraph->GetN()-1, 0, ff.
err[clu][cry][seg]);
245 calcgraph->AddPoint(indx, edop);
246 resgraph->AddPoint(indx, edop - ff.
energy[clu][cry][seg]);
247 resgraph->SetPointError(resgraph->GetN()-1, 0, ff.
err[clu][cry][seg]);
252 TCanvas *c1 =
new TCanvas();
253 engraph->SetMarkerStyle(kFullCircle);
254 engraph->SetMarkerSize(0.5);
255 engraph->SetMarkerColor(kRed);
256 engraph->SetLineColor(kRed);
259 calcgraph->SetMarkerStyle(kFullCircle);
260 calcgraph->SetMarkerSize(0.5);
261 calcgraph->Draw(
"P");
264 TLegend *leg =
new TLegend(0.1,0.75,0.3,0.9);
265 leg->AddEntry(engraph,
"Experimental energies");
266 leg->AddEntry(calcgraph,
"Calculated energies");
269 c1->Print(
"position_cal.pdf(");
271 resgraph->SetMarkerStyle(kFullCircle);
272 resgraph->SetMarkerSize(0.5);
273 resgraph->Draw(
"AP");
275 TF1 *func =
new TF1(
"func",
"[0]", 0, 168);
276 func->SetParameter(0, 0.0);
279 c1->Print(
"position_cal.pdf");
281 corrgraph->SetMarkerStyle(kFullCircle);
282 corrgraph->SetMarkerSize(0.5);
283 corrgraph->Draw(
"AP");
285 func->SetParameter(0, ff.
eref);
288 c1->Print(
"position_cal.pdf");
292 int colors[8] = {632, 416, 600, 400, 616, 432, 800, 900};
294 TMultiGraph *tp_mg =
new TMultiGraph();
295 tp_mg->SetName(
"theta_phi_map");
296 TGraph *theta_phi[8][3];
297 for(
unsigned int clu = 0; clu < 8; ++clu ) {
298 if (ff.
cluster[clu] == 0) {
continue; }
299 for(
unsigned int cry = 0; cry < 3; ++cry ) {
300 theta_phi[clu][cry] =
new TGraph();
301 for(
unsigned int seg = 0; seg < 7; ++seg ) {
302 double theta = ff.
myreact->GetGammaTheta(clu,cry,seg)*180./TMath::Pi();
303 double phi = ff.
myreact->GetGammaPhi(clu,cry,seg)*180./TMath::Pi();
304 theta_phi[clu][cry]->AddPoint(theta, phi);
306 theta_phi[clu][cry]->SetMarkerSize(1.0);
307 theta_phi[clu][cry]->SetMarkerStyle(kFullCircle);
308 theta_phi[clu][cry]->SetMarkerColor(colors[clu]+cry);
309 tp_mg->Add(theta_phi[clu][cry]);
313 tp_mg->GetXaxis()->SetLimits(0,180);
314 tp_mg->GetYaxis()->SetLimits(-180,180);
315 tp_mg->GetXaxis()->SetTitle(
"Reaction Theta [deg]");
316 tp_mg->GetYaxis()->SetTitle(
"Reaction Phi [deg]");
318 c1->Print(
"position_cal.pdf");
320 TMultiGraph *xy_f_mg =
new TMultiGraph();
321 TMultiGraph *xy_b_mg =
new TMultiGraph();
322 TMultiGraph *xz_r_mg =
new TMultiGraph();
323 TMultiGraph *xz_l_mg =
new TMultiGraph();
324 xy_f_mg->SetName(
"xy_f_mg");
325 xy_b_mg->SetName(
"xy_b_mg");
326 xz_r_mg->SetName(
"xz_r_mg");
327 xz_l_mg->SetName(
"xz_l_mg");
332 for(
unsigned int clu = 0; clu < 8; ++clu ) {
333 if (ff.
cluster[clu] == 0) {
continue; }
334 for(
unsigned int cry = 0; cry < 3; ++cry ) {
335 xy_f[clu][cry] =
new TGraph();
336 xy_b[clu][cry] =
new TGraph();
337 xz_r[clu][cry] =
new TGraph();
338 xz_l[clu][cry] =
new TGraph();
339 for(
unsigned int seg = 0; seg < 7; ++seg ) {
340 double x = ff.
myreact->GetGammaX(clu,cry,seg);
341 double y = ff.
myreact->GetGammaY(clu,cry,seg);
342 double z = ff.
myreact->GetGammaZ(clu,cry,seg);
344 xy_f[clu][cry]->AddPoint(y,x);
347 xy_b[clu][cry]->AddPoint(y,x);
351 xz_r[clu][cry]->AddPoint(z,x);
354 xz_l[clu][cry]->AddPoint(z,x);
357 xy_f[clu][cry]->SetMarkerSize(1.0);
358 xy_f[clu][cry]->SetMarkerStyle(kFullCircle);
359 xy_f[clu][cry]->SetMarkerColor(colors[clu]+cry);
360 xy_b[clu][cry]->SetMarkerSize(1.0);
361 xy_b[clu][cry]->SetMarkerStyle(kFullCircle);
362 xy_b[clu][cry]->SetMarkerColor(colors[clu]+cry);
363 xz_r[clu][cry]->SetMarkerSize(1.0);
364 xz_r[clu][cry]->SetMarkerStyle(kFullCircle);
365 xz_r[clu][cry]->SetMarkerColor(colors[clu]+cry);
366 xz_l[clu][cry]->SetMarkerSize(1.0);
367 xz_l[clu][cry]->SetMarkerStyle(kFullCircle);
368 xz_l[clu][cry]->SetMarkerColor(colors[clu]+cry);
370 xy_f_mg->Add(xy_f[clu][cry]);
371 xy_b_mg->Add(xy_b[clu][cry]);
372 xz_r_mg->Add(xz_r[clu][cry]);
373 xz_l_mg->Add(xz_l[clu][cry]);
377 xy_f_mg->GetYaxis()->SetTitle(
"x [mm]");
378 xy_f_mg->GetXaxis()->SetTitle(
"y [mm]");
380 c1->Print(
"position_cal.pdf");
383 xy_b_mg->GetYaxis()->SetTitle(
"x [mm]");
384 xy_b_mg->GetXaxis()->SetTitle(
"y [mm]");
386 c1->Print(
"position_cal.pdf");
389 xz_r_mg->GetYaxis()->SetTitle(
"x [mm]");
390 xz_r_mg->GetXaxis()->SetTitle(
"z [mm]");
392 c1->Print(
"position_cal.pdf");
395 xz_l_mg->GetYaxis()->SetTitle(
"x [mm]");
396 xz_l_mg->GetXaxis()->SetTitle(
"z [mm]");
398 c1->Print(
"position_cal.pdf)");
404 std::cout <<
"fitted beta = " << min->X()[0] << std::endl;
406 printf(
" theta phi alpha R\n");
407 for(
unsigned int clu = 0; clu < 8 ; ++clu ) {
408 if (ff.
cluster[clu] == 0) {
continue; }
409 printf(
"Cl%i %6.2f %6.2f %6.2f %6.2f\n", clu, min->X()[indx], min->X()[indx+1], min->X()[indx+2], min->X()[indx+3]);
412 std::cout << std::endl << std::endl;
414 for(
unsigned int clu = 0; clu < 8 ; ++clu ) {
415 if (ff.
cluster[clu] == 0) {
continue; }
416 printf(
"MiniballCluster_%d.Theta %6.2f\n", clu, min->X()[indx]);
417 printf(
"MiniballCluster_%d.Phi %6.2f\n", clu, min->X()[indx+1]);
418 printf(
"MiniballCluster_%d.Alpha %6.2f\n", clu, min->X()[indx+2]);
419 printf(
"MiniballCluster_%d.R %6.2f\n", clu, min->X()[indx+3]);