72 for (
int i=abs(s1-s2); i<=abs(s1+s2); ++i)
82 if (mult2==0 || mult2>2)
return 0;
89 else if (i==2)
return Mixed2();
91 std::cout <<
"bad argument! " << i << std::endl;
98 fColors = {kBlack, kBlue, kRed, kGreen, kMagenta};
99 for (
int i=0; i<hists.size(); ++i) {
101 double peak = peak2.
Apply(hist);
102 if (peak < 0) { std::cout << angs[i] <<
" " << peak << std::endl; }
105 double norm = angNorm->GetBinContent(angNorm->FindBin(angs[i]));
117 SetData(angs, hists, peak1, peak2, angNorm);
118 std::vector<double> Qks = {1.0, 1.0, 1.0, 1.0, 1.0};
124 SetData(angs, hists, peak1, peak2, angNorm);
125 std::vector<double> Qks = {1.0, 1.0, 1.0, 1.0, 1.0};
151 TGraphErrors *graph =
new TGraphErrors();
154 graph->SetPointError(i, 0,
fErrors[i]);
156 graph->SetTitle(GetTitle());
163 std::vector<double> lowedges;
164 while (start < 180) {
165 lowedges.push_back(start);
168 int nDispPoints = lowedges.size();
169 std::vector<double> dispangs(lowedges.size());
170 std::vector<double> dispints(lowedges.size());
171 std::vector<double> invvars(lowedges.size());
175 for (
int p=0; p<nDispPoints; ++p) {
176 if (
fAngles[i] < lowedges[p]) {
continue; }
177 if (p < nDispPoints - 1) {
178 if (
fAngles[i] >= lowedges[p+1] ) {
182 double oldSumX = dispangs[p]*invvars[p];
183 double oldSumY = dispints[p]*invvars[p];
186 double newVar = invvars[p] + pow(1.0/
fErrors[i],2);
187 dispangs[p] = newSumX/newVar;
188 dispints[p] = newSumY/newVar;
195 TGraphErrors *graph =
new TGraphErrors();
196 for (
int p=0; p<nDispPoints; ++p) {
199 graph->SetPoint(graph->GetN(), dispangs[p], dispints[p]);
200 graph->SetPointError(graph->GetN()-1, 0, sqrt(1.0/invvars[p]));
203 graph->SetTitle(GetTitle());
215 for (
int i = 0; i<
spin1s.size(); ++i) {
216 for (
int j = 0; j<
spin2s.size(); ++j) {
217 for (
int k = 0; k<
spin3s.size(); ++k) {
218 std::string name((std::string)
"AngCorr"+std::to_string(
spin1s[i])+
"_"+std::to_string(
spin2s[j])+
"_"+std::to_string(
spin3s[k]));
220 TF1 *corrFunc =
new TF1(name.c_str(), corr, 0, 181, 3,
"GamR::AngDist::AngCorr");
221 TGraph *chiGraph =
new TGraph();
225 corrFunc->SetParameter(0,
Average());
229 if (
fDel[0] == 1 ) {
233 else if (
fDel[1] == 1 ) {
238 if (
fDel[0] == 0 &&
fDel[1] == 0 ) {
241 std::cout <<
"Two mixed transitions with no fixed delta?" << std::endl;
250 else if (corr->
Mixed1()) {
255 else if (corr->
Mixed2()) {
261 if (
fDel[varpar-1] == 1) {
264 corrFunc->SetParameter(1,
fixDelta[varpar-1]);
265 corrFunc->FixParameter(1,
fixDelta[varpar-1]);
266 graph->Fit(corrFunc,
"Q");
267 chiGraph->SetPoint(0,
fixDelta[varpar-1], corrFunc->GetChisquare());
271 if (corr->
Mixed(varpar) == 0) {
273 corrFunc->SetParameter(1,
fixDelta[0]);
274 corrFunc->SetParameter(2,
fixDelta[1]);
275 corrFunc->FixParameter(1,
fixDelta[0]);
276 corrFunc->FixParameter(2,
fixDelta[1]);
277 graph->Fit(corrFunc,
"Q");
278 chiGraph->SetPoint(0, -TMath::Pi()/2.0+0.01, corrFunc->GetChisquare());
279 chiGraph->SetPoint(1, TMath::Pi()/2.0-0.01, corrFunc->GetChisquare());
286 for (
double d=-TMath::Pi()/2.0+0.01; d<TMath::Pi()/2-0.01; d+=0.3333333*0.01*(TMath::Pi()-0.02))
288 double delta = TMath::Tan(d);
289 corrFunc->SetParameter(varpar, delta);
290 corrFunc->FixParameter(varpar, delta);
292 corrFunc->SetParameter(fixpar,
fixDelta[fixpar-1]);
293 corrFunc->FixParameter(fixpar,
fixDelta[fixpar-1]);
295 graph->Fit(corrFunc,
"Q");
296 chiGraph->SetPoint(count, d, corrFunc->GetChisquare());
303 chiGraph->GetPoint(TMath::LocMin(chiGraph->GetN(), chiGraph->GetY()), d, chi);
304 double delta = TMath::Tan(d);
307 double thresh = chi+1;
313 chiGraph->GetPoint(0, tand_last, chi2_last);
314 for (
int ig=1;
ig<chiGraph->GetN(); ++
ig) {
317 chiGraph->GetPoint(
ig, tand, chi2);
319 if (chi2_last > thresh && chi2 < thresh) {
320 low = TMath::Tan(tand);
322 if (chi2_last < thresh && chi2 > thresh) {
323 high = TMath::Tan(tand);
331 corrFunc->SetParameter(varpar, delta);
332 corrFunc->FixParameter(varpar, delta);
333 corrFunc->SetParameter(fixpar,
fixDelta[fixpar-1]);
334 corrFunc->FixParameter(fixpar,
fixDelta[fixpar-1]);
337 graph->Fit(corrFunc,
"Q");
340 fDelta1Err.push_back({low - delta, high - delta});
343 else if (varpar == 2) {
345 fDelta2Err.push_back({low - delta, high - delta});
362 TMultiGraph *multgraph =
new TMultiGraph();
366 multgraph->SetTitle(GetTitle());
376 double fillareaX[4]={-TMath::Pi()/2.0, -TMath::Pi()/2.0, TMath::Pi()/2.0, TMath::Pi()/2.0};
377 double fillareaY[4]={0, 66.35, 66.35, 0};
378 TGraph *fillgraph =
new TGraph(4, &fillareaX[0], &fillareaY[0]);
379 fillgraph->SetFillColor(kYellow);
380 fillgraph->SetFillStyle(3001);
382 multgraph->GetXaxis()->SetTitle(
"arctan(delta)");
383 multgraph->GetYaxis()->SetTitle(
"chi^2");
384 multgraph->Draw(
"AC");
387 TLegend *legend =
new TLegend(0.75, 0.75, 0.95, 0.95);
390 entry.Form(
"%2.1f->%2.1f->%2.1f",
fCorrs[i]->spin1,
fCorrs[i]->spin2,
fCorrs[i]->spin3);
391 legend->AddEntry(
fChiGraphs[i], entry.Data());
394 multgraph->GetYaxis()->SetRangeUser(ylow, yhigh);
395 fillgraph->Draw(
"F");
403 graph->GetXaxis()->SetLimits(0, 185);
404 TLegend *legend =
new TLegend(0.9, 0.7, 1.0, 0.9);
408 entry.Form(
"%2.1f->%2.1f->%2.1f",
fCorrs[i]->spin1,
fCorrs[i]->spin2,
fCorrs[i]->spin3);
409 legend->AddEntry(
fCorrFuncs[i], entry.Data());
415 std::ofstream ofile(filename);
417 for (
int i = 0; i<graph->GetN(); ++i) {
418 double x, y, xerr, yerr;
419 graph->GetPoint(i, x, y);
420 xerr = graph->GetErrorX(i);
421 yerr = graph->GetErrorY(i);
422 ofile << x <<
" " << y <<
" " << xerr <<
" " << yerr << std::endl;
424 ofile << std::endl << std::endl;
425 for (
int i=0; i<=180; ++i) {
437 std::ofstream ofile(filename);
439 for (
int i=-90; i<=90; ++i) {
443 if (!g) { ofile.close();
return; }
444 ofile << g->Eval(i*TMath::Pi()/180.0) <<
" ";
std::pair< double, double > ig(TCanvas *canvas)
void DrawAngCorr(TCanvas *c1, double start, double interval)
std::vector< double > spin3s
std::vector< Color_t > fColors
std::vector< double > fDelta2
std::vector< double > fAngles
GamR::AngDist::SolidAttenuation * Qk
AngCorrFit(std::vector< double > angs, std::vector< TH2D * > hists, GamR::Nucleus::Transition peak1, GamR::Nucleus::Transition peak2, TH1D *angNorm, const char *name, const char *title)
std::vector< double > fIntensities
void SaveChiGraph(std::string filename)
std::vector< std::pair< double, double > > fDelta2Err
std::vector< double > spin2s
void SetData(std::vector< double > angs, std::vector< TH2D * > hists, GamR::Nucleus::Transition peak1, GamR::Nucleus::Transition peak2, TH1D *angNorm)
std::vector< double > fixDelta
TMultiGraph * GetChiGraph()
std::vector< double > fChiSquared
std::vector< AngCorr * > fCorrs
void ErasePoint(double ang)
std::vector< TGraph * > fChiGraphs
std::vector< double > spin1s
TGraphErrors * GetDispGraph(double start, double interval)
std::vector< TF1 * > fCorrFuncs
std::vector< double > fErrors
std::vector< double > fDelta1
void Save(std::string filename, double start, double interval)
std::vector< std::pair< double, double > > fDelta1Err
void DrawChiGraph(TCanvas *c1, double ylow, double yhigh)
TGraphErrors * GetGraph()
int Mixed(double s1, double s2)
double Ak(double k, double delta1, double delta2)
double Apply(TH1D *hist) const
double ApplyError(TH1D *hist) const
double Ak(double k, double ji, double lambda, double lambdaPrime, double jf, double delta)
double Fk(double k, double jf, double lambda, double lambdaPrime, double ji)
TH1D * BackgroundSubtractY(TH2 *hist, GamR::TK::Gate peak, std::vector< GamR::TK::Gate > background, const char *name)