68 double low_lim = en*0.92 - 5.;
69 double upp_lim = en*1.08 + 5.;
73 auto c1 = std::make_unique<TCanvas>();
74 h->GetXaxis()->SetRangeUser( low_lim - 20., upp_lim + 20. );
78 auto peakfit = std::make_unique<TF1>(
"peakfit",
"gaus(0)+pol1(3)", low_lim, upp_lim );
81 double en_est = h->GetBinCenter( h->GetMaximumBin() );
83 double bg_est = h->GetBinContent( h->FindBin( en_est - 5.0 * sig_est ) );
84 double amp_est = h->GetBinContent( h->GetMaximumBin() );
86 if( amp_est < 1.0 ) amp_est = h->GetBinContent( h->GetMaximumBin() ) + 1.0;
87 peakfit->SetParameter( 0, amp_est );
88 peakfit->SetParameter( 1, en_est );
89 peakfit->SetParameter( 2, sig_est );
90 peakfit->SetParameter( 3, bg_est );
91 peakfit->SetParameter( 4, 1e-9 );
94 double integral = h->Integral( h->FindBin(low_lim), h->FindBin(upp_lim) );
95 peakfit->SetParLimits( 0, 1.0, integral );
96 peakfit->SetParLimits( 1, low_lim, upp_lim );
97 peakfit->SetParLimits( 2, sig_est*0.25, sig_est*4.0 );
100 gErrorIgnoreLevel = kError;
101 auto res = h->Fit( peakfit.get(),
"LRSQ" );
102 c1->Print(
"peak_fits.pdf");
103 gErrorIgnoreLevel = kInfo;
104 if( res == 0 && integral > 150. ) {
107 en = peakfit->GetParameter(1);
108 er = peakfit->GetParError(1);
532 ROOT::Math::Minimizer *min =
533 ROOT::Math::Factory::CreateMinimizer(
"Minuit2",
"Combined");
539 ROOT::Math::Functor f_init(
ff,
npars );
542 min->SetErrorDef(1.);
543 min->SetMaxFunctionCalls(1e7);
544 min->SetMaxIterations(1e8);
545 min->SetPrecision(1e-12);
546 min->SetTolerance(1e-9);
548 min->SetFunction(f_init);
551 for(
unsigned int i = 0; i <
npars; ++i ) {
552 min->SetLimitedVariable( i,
names.at(i),
pars.at(i), 0.0001,
LL.at(i),
UL.at(i) );
553 min->SetVariableStepSize( i, 1.0 );
557 min->SetVariableStepSize( 0, 0.001 );
560 for(
unsigned int clu = 0; clu <
myset->GetNumberOfMiniballClusters(); ++clu ) {
562 int indx = 1 + 4*clu;
565 min->FixVariable( indx+0 );
566 min->FixVariable( indx+1 );
567 min->FixVariable( indx+2 );
568 min->FixVariable( indx+3 );
584 double beta = min->X()[0];
585 for(
unsigned int clu = 0; clu <
myset->GetNumberOfMiniballClusters(); ++clu ) {
588 int indx = 1 + 4 * clu;
591 myreact->SetupCluster( clu, min->X()[indx], min->X()[indx+1], min->X()[indx+2], min->X()[indx+3], 0.0 );
596 TGraphErrors *engraph =
new TGraphErrors();
597 engraph->SetName(
"engraph");
598 engraph->SetTitle(
"Experimental energies; Channel index; Energy [keV]");
600 TGraph *calcgraph =
new TGraph();
601 calcgraph->SetName(
"calcgraph");
602 calcgraph->SetTitle(
"Calculated energies; Channel index; Energy [keV]");
604 TGraphErrors *resgraph =
new TGraphErrors();
605 resgraph->SetName(
"resgraph");
606 resgraph->SetTitle(
"Residuals; Channel index; Energy [keV]");
608 TGraphErrors *corrgraph =
new TGraphErrors();
609 corrgraph->SetName(
"corrgraph");
610 corrgraph->SetTitle(
"Doppler-corrected energies; Channel index; Energy [keV]");
612 TGraphErrors *phigraph =
new TGraphErrors();
613 phigraph->SetName(
"phigraph");
614 phigraph->SetTitle(
"Phi residuals; Channel index; Energy [keV]");
618 for(
unsigned int clu = 0; clu <
myset->GetNumberOfMiniballClusters(); ++clu ) {
621 for(
unsigned int cry = 0; cry <
myset->GetNumberOfMiniballCrystals(); ++cry ) {
624 for(
unsigned int seg = 0; seg <
myset->GetNumberOfMiniballSegments(); ++seg ) {
630 double theta =
myreact->GetGammaTheta( clu, cry, seg );
631 double phi =
myreact->GetGammaPhi( clu, cry, seg );
632 phi *= TMath::RadToDeg();
633 if( phi < 0.0 ) phi += 360.0;
635 beta, TMath::Cos(theta) );
640 indx += cry *
myset->GetNumberOfMiniballSegments();
641 indx += clu *
myset->GetNumberOfMiniballCrystals() *
myset->GetNumberOfMiniballSegments();
643 engraph->SetPoint(engraph->GetN(), indx,
ff.
GetExpEnergy( clu, cry, seg ) );
644 engraph->SetPointError( engraph->GetN()-1, 0,
ff.
GetExpError( clu, cry, seg ) );
646 corrgraph->SetPoint(corrgraph->GetN(), indx,
ff.
GetExpEnergy( clu, cry, seg ) * corr );
647 corrgraph->SetPointError( engraph->GetN()-1, 0,
ff.
GetExpError( clu, cry, seg ) );
649 calcgraph->SetPoint(calcgraph->GetN(), indx, edop );
651 resgraph->SetPoint(resgraph->GetN(), indx, edop -
ff.
GetExpEnergy( clu, cry, seg ) );
652 resgraph->SetPointError( resgraph->GetN()-1, 0,
ff.
GetExpError( clu, cry, seg ) );
656 phigraph->SetPoint(phigraph->GetN(), indx, phi -
ff.
GetExpPhi( clu, cry, seg ) );
657 phigraph->SetPointError( phigraph->GetN()-1, 0,
ff.
GetExpPhiError( clu, cry, seg ) );
666 auto c1 = std::make_unique<TCanvas>();
667 engraph->SetMarkerStyle(kFullCircle);
668 engraph->SetMarkerSize(0.5);
669 engraph->SetMarkerColor(kRed);
670 engraph->SetLineColor(kRed);
673 calcgraph->SetMarkerStyle(kFullCircle);
674 calcgraph->SetMarkerSize(0.5);
675 calcgraph->Draw(
"P");
679 auto leg = std::make_unique<TLegend>(0.1,0.75,0.3,0.9);
680 leg->AddEntry(engraph,
"Experimental energies");
681 leg->AddEntry(calcgraph,
"Calculated energies");
685 gErrorIgnoreLevel = kWarning;
686 c1->Print(
"position_cal.pdf(",
"pdf");
689 resgraph->SetMarkerStyle(kFullCircle);
690 resgraph->SetMarkerSize(0.5);
691 resgraph->Draw(
"AP");
693 auto func = std::make_unique<TF1>(
"func",
"[0]", 0, 168);
694 func->SetParameter( 0, 0.0 );
698 c1->Print(
"position_cal.pdf",
"pdf");
701 corrgraph->SetMarkerStyle(kFullCircle);
702 corrgraph->SetMarkerSize(0.5);
703 corrgraph->Draw(
"AP");
709 c1->Print(
"position_cal.pdf",
"pdf");
712 phigraph->SetMarkerStyle(kFullCircle);
713 phigraph->SetMarkerSize(0.5);
714 phigraph->Draw(
"AP");
715 func->SetParameter( 0, 0.0 );
719 c1->Print(
"position_cal.pdf",
"pdf");
722 auto tp_mg = std::make_unique<TMultiGraph>();
723 auto xy_f_mg = std::make_unique<TMultiGraph>();
724 auto xy_b_mg = std::make_unique<TMultiGraph>();
725 auto xz_r_mg = std::make_unique<TMultiGraph>();
726 auto xz_l_mg = std::make_unique<TMultiGraph>();
727 tp_mg->SetName(
"theta_phi_map");
728 xy_f_mg->SetName(
"xy_f_mg");
729 xy_b_mg->SetName(
"xy_b_mg");
730 xz_r_mg->SetName(
"xz_r_mg");
731 xz_l_mg->SetName(
"xz_l_mg");
732 std::vector< std::vector<TGraph*> > theta_phi;
733 std::vector< std::vector<TGraph*> > xy_f;
734 std::vector< std::vector<TGraph*> > xy_b;
735 std::vector< std::vector<TGraph*> > xz_l;
736 std::vector< std::vector<TGraph*> > xz_r;
737 theta_phi.resize(
myset->GetNumberOfMiniballClusters() );
738 xy_f.resize(
myset->GetNumberOfMiniballClusters() );
739 xy_b.resize(
myset->GetNumberOfMiniballClusters() );
740 xz_l.resize(
myset->GetNumberOfMiniballClusters() );
741 xz_r.resize(
myset->GetNumberOfMiniballClusters() );
745 auto leg2 = std::make_unique<TLegend>( 0.79, 0.15, 0.95, 0.90 );
747 p1->SetMargin( 0.15, 0.21, 0.15, 0.10 );
750 for(
unsigned int clu = 0; clu <
myset->GetNumberOfMiniballClusters(); ++clu ) {
752 theta_phi[clu].resize(
myset->GetNumberOfMiniballCrystals() );
753 xy_f[clu].resize(
myset->GetNumberOfMiniballCrystals() );
754 xy_b[clu].resize(
myset->GetNumberOfMiniballCrystals() );
755 xz_l[clu].resize(
myset->GetNumberOfMiniballCrystals() );
756 xz_r[clu].resize(
myset->GetNumberOfMiniballCrystals() );
759 for(
unsigned int cry = 0; cry <
myset->GetNumberOfMiniballCrystals(); ++cry ) {
762 theta_phi[clu][cry] =
new TGraph();
763 xy_f[clu][cry] =
new TGraph();
764 xy_b[clu][cry] =
new TGraph();
765 xz_l[clu][cry] =
new TGraph();
766 xz_r[clu][cry] =
new TGraph();
768 leg_lab =
"MB" + std::to_string(clu) +
static_cast<char>(cry+65);
769 leg2->AddEntry( theta_phi[clu][cry], leg_lab.data() );
775 for(
unsigned int seg = 0; seg <
myset->GetNumberOfMiniballSegments(); ++seg ) {
778 double theta =
myreact->GetGammaTheta( clu, cry, seg ) * TMath::RadToDeg();
779 double phi =
myreact->GetGammaPhi( clu, cry, seg ) * TMath::RadToDeg();
780 double x =
myreact->GetGammaX( clu, cry, seg );
781 double y =
myreact->GetGammaY( clu, cry, seg );
782 double z =
myreact->GetGammaZ( clu, cry, seg );
785 theta_phi[clu][cry]->SetPoint(theta_phi[clu][cry]->GetN(), theta, phi );
786 if( z > 0 ) xy_f[clu][cry]->SetPoint(xy_f[clu][cry]->GetN(), y, x );
787 else xy_b[clu][cry]->SetPoint(xy_b[clu][cry]->GetN(), y, x );
788 if( y > 0 ) xz_r[clu][cry]->SetPoint(xz_r[clu][cry]->GetN(), z, x );
789 else xz_l[clu][cry]->SetPoint(xz_l[clu][cry]->GetN(), z, x );
794 theta_phi[clu][cry]->SetMarkerSize(1.0);
795 theta_phi[clu][cry]->SetMarkerStyle(
mystyles[clu]);
796 theta_phi[clu][cry]->SetMarkerColor(
mycolors[cry]);
797 xy_f[clu][cry]->SetMarkerSize(1.0);
798 xy_f[clu][cry]->SetMarkerStyle(
mystyles[clu]);
799 xy_f[clu][cry]->SetMarkerColor(
mycolors[cry]);
800 xy_b[clu][cry]->SetMarkerSize(1.0);
801 xy_b[clu][cry]->SetMarkerStyle(
mystyles[clu]);
802 xy_b[clu][cry]->SetMarkerColor(
mycolors[cry]);
803 xz_r[clu][cry]->SetMarkerSize(1.0);
804 xz_r[clu][cry]->SetMarkerStyle(
mystyles[clu]);
805 xz_r[clu][cry]->SetMarkerColor(
mycolors[cry]);
806 xz_l[clu][cry]->SetMarkerSize(1.0);
807 xz_l[clu][cry]->SetMarkerStyle(
mystyles[clu]);
808 xz_l[clu][cry]->SetMarkerColor(
mycolors[cry]);
811 if( theta_phi[clu][cry]->GetN() > 0 ) tp_mg->Add( theta_phi[clu][cry] );
812 if( xy_f[clu][cry]->GetN() > 0 ) xy_f_mg->Add( xy_f[clu][cry] );
813 if( xy_b[clu][cry]->GetN() > 0 ) xy_b_mg->Add( xy_b[clu][cry] );
814 if( xz_r[clu][cry]->GetN() > 0 ) xz_r_mg->Add( xz_r[clu][cry] );
815 if( xz_l[clu][cry]->GetN() > 0 ) xz_l_mg->Add( xz_l[clu][cry] );
825 tp_mg->GetXaxis()->SetLimits(0,180);
826 tp_mg->GetYaxis()->SetLimits(-180,180);
827 tp_mg->GetXaxis()->SetTitle(
"Reaction Theta [deg]");
828 tp_mg->GetYaxis()->SetTitle(
"Reaction Phi [deg]");
832 c1->Print(
"position_cal.pdf",
"pdf");
835 xy_f_mg->GetYaxis()->SetTitle(
"x [mm]");
836 xy_f_mg->GetXaxis()->SetTitle(
"y [mm]");
840 c1->Print(
"position_cal.pdf",
"pdf");
843 xy_b_mg->GetYaxis()->SetTitle(
"x [mm]");
844 xy_b_mg->GetXaxis()->SetTitle(
"y [mm]");
848 c1->Print(
"position_cal.pdf",
"pdf");
851 xz_r_mg->GetYaxis()->SetTitle(
"x [mm]");
852 xz_r_mg->GetXaxis()->SetTitle(
"z [mm]");
856 c1->Print(
"position_cal.pdf",
"pdf");
859 xz_l_mg->GetYaxis()->SetTitle(
"x [mm]");
860 xz_l_mg->GetXaxis()->SetTitle(
"z [mm]");
864 c1->Print(
"position_cal.pdf)",
"pdf");
865 gErrorIgnoreLevel = kInfo;
868 std::cout <<
"fitted beta = " << beta << std::endl;
869 printf(
" theta phi alpha R\n");
870 for(
unsigned int clu = 0; clu <
myset->GetNumberOfMiniballClusters(); ++clu ) {
873 int indx = 1 + 4*clu;
874 printf(
"MB%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]);
877 std::cout << std::endl << std::endl;
880 myreact->PrintReaction( std::cout,
"a" );