FitVarsCPT.cxx
Go to the documentation of this file.
2 
3 #include "Utilities/func/MathUtil.h"
4 
5 #include <cassert>
6 
7 namespace ana
8 {
9  // declared as 'extern' in FitVarsCPT.h
10  const FitDmSq32CPT kFitDmSq32nu(osc::ENuSign::kNu);
11  const FitDmSq32CPT kFitDmSq32bar(osc::ENuSign::kNuBar);
12  const FitDmSq32ScaledCPT kFitDmSq32Scalednu(osc::ENuSign::kNu);
13  const FitDmSq32ScaledCPT kFitDmSq32Scaledbar(osc::ENuSign::kNuBar);
14  const FitDmSq32CPTHierarchy kFitDmSq32nuNorm( osc::ENuSign::kNu, false );
15  const FitDmSq32CPTHierarchy kFitDmSq32barNorm(osc::ENuSign::kNuBar, false );
16  const FitDmSq32CPTHierarchy kFitDmSq32nuInv( osc::ENuSign::kNu, true );
17  const FitDmSq32CPTHierarchy kFitDmSq32barInv( osc::ENuSign::kNuBar, true );
18  const FitDmSq21CPT kFitDmSq21nu(osc::ENuSign::kNu);
19  const FitDmSq21CPT kFitDmSq21bar(osc::ENuSign::kNuBar);
20  const FitSinSq2Theta23CPT kFitSinSq2Theta23nu(osc::ENuSign::kNu);
21  const FitSinSq2Theta23CPT kFitSinSq2Theta23bar(osc::ENuSign::kNuBar);
22  const FitSinSqTheta23CPT kFitSinSqTheta23nu(osc::ENuSign::kNu);
23  const FitSinSqTheta23CPT kFitSinSqTheta23bar(osc::ENuSign::kNuBar);
24  const FitSinSqTheta23CPTOctant kFitSinSqTheta23nuFirst(osc::ENuSign::kNu, false);
25  const FitSinSqTheta23CPTOctant kFitSinSqTheta23barFirst(osc::ENuSign::kNuBar, false);
26  const FitSinSqTheta23CPTOctant kFitSinSqTheta23nuSecond(osc::ENuSign::kNu, true);
27  const FitSinSqTheta23CPTOctant kFitSinSqTheta23barSecond(osc::ENuSign::kNuBar, true);
28  const FitSinSq2Theta13CPT kFitSinSq2Theta13nu(osc::ENuSign::kNu);
29  const FitSinSq2Theta13CPT kFitSinSq2Theta13bar(osc::ENuSign::kNuBar);
30  const FitSinSq2Theta12CPT kFitSinSq2Theta12nu(osc::ENuSign::kNu);
31  const FitSinSq2Theta12CPT kFitSinSq2Theta12bar(osc::ENuSign::kNuBar);
32 
33 
34  //---------------------------------------------------------------------------
36  { return osc::DowncastToCPT(osc)->GetDmsq21(fNuSign); }
37 
39  double val) const
40  { osc::DowncastToCPT(osc)->SetDmsq21(Clamp(val), fNuSign); }
41 
42 
43  //---------------------------------------------------------------------------
45  { return osc::DowncastToCPT(osc)->GetDmsq32(fNuSign); }
46 
48  double val) const
49  { osc::DowncastToCPT(osc)->SetDmsq32(Clamp(val), fNuSign); }
50 
51 
52  //---------------------------------------------------------------------------
54  { return osc::DowncastToCPT(osc)->GetDmsq32(fNuSign)*1000.0; }
55 
57  double val) const
58  { osc::DowncastToCPT(osc)->SetDmsq32(Clamp(val)/1000.0, fNuSign); }
59 
60  //---------------------------------------------------------------------------
61 
63  {
64  return util::sqr(sin(2*osc::DowncastToCPT(osc)->GetTh23(fNuSign) )); }
65 
67  double val) const
68  {
69  osc::DowncastToCPT(osc)->SetTh23(asin(sqrt( Clamp(val) ))/2, fNuSign); }
70 
71  //---------------------------------------------------------------------------
72 
74  const osc::IOscCalcAdjustable* osc) const
75  { return util::sqr(sin( osc::DowncastToCPT(osc)->GetTh23(fNuSign) )); }
76 
78  double val) const
79  { osc::DowncastToCPT(osc)->SetTh23(asin(sqrt( Clamp(val) )), fNuSign); }
80 
81  //---------------------------------------------------------------------------
82 
84  {
85  return util::sqr(sin(2*osc::DowncastToCPT(osc)->GetTh13(fNuSign) )); }
87  double val) const
88  { osc::DowncastToCPT(osc)->SetTh13(asin(sqrt( Clamp(val) ))/2, fNuSign); }
89 
90  //---------------------------------------------------------------------------
91 
93  const osc::IOscCalcAdjustable* osc) const
94  { return util::sqr(sin(2*osc::DowncastToCPT(osc)->GetTh12(fNuSign) )); }
95 
97  double val) const
98  { osc::DowncastToCPT(osc)->SetTh12(asin(sqrt( Clamp(val) ))/2, fNuSign); }
99 
100  //---------------------------------------------------------------------------
101  //---------------------------------------------------------------------------
102 
104  const IConstrainedFitVar &x,
105  const IConstrainedFitVar &y)
106  : fXvar(x), fYvar(y),
107  fCenterDelta(fXvar.HighLimit() - fYvar.HighLimit()),
108  fCenterSigma(fXvar.HighLimit() + fYvar.LowLimit())
109  {
110  // Check to make sure the allowed area is square. If not, the logic is
111  // more complicated, but most pairs of CPT FitVars have matched ranges.
114  osc->fSigDel[this] = {fXvar.GetValue(osc)+fYvar.GetValue(osc),
115  fXvar.GetValue(osc)-fYvar.GetValue(osc)};
116  }
117 
119  { return osc::DowncastToCPT(osc)->fSigDel[this].first; }
121  { return osc::DowncastToCPT(osc)->fSigDel[this].second; }
122 
124  {
126  cpt->fSigDel[this].first = val;
127  SetFitVars(cpt);
128  }
129 
131  {
133  cpt->fSigDel[this].second = val;
134  SetFitVars(cpt);
135  }
136 
137  double SigmaDelta::DeltaPenalty(double val) const
138  {
139  return 0; //have to check both vars, so just apply the penalty in sigma
140  }
141 
144  {
146  double delta = cpt->fSigDel[this].second;
147 
148  return ( fXvar.Penalty( (val+delta)/2 , osc)
149  + fYvar.Penalty( (val-delta)/2 , osc)
150  + 1000*(delta > (fXvar.HighLimit()-fYvar.LowLimit()) )
151  + 1000*(delta < (fXvar.LowLimit()-fYvar.HighLimit()) )
152  ); //extra 1000 is in case contour hits impossible region
153  }
154 
156  {
157  double sigma = osc->fSigDel[this].first;
158  double delta = osc->fSigDel[this].second;
159  //if requested value is impossible, try to at least maintain delta
160  if( (delta>fCenterDelta)==(sigma>fCenterSigma) )
161  {
162  fXvar.SetValue(osc, (sigma+delta)/2);
163  double xc = fXvar.GetValue(osc);
164  fYvar.SetValue(osc, xc-delta);
165  }
166  else
167  {
168  fYvar.SetValue(osc, (sigma-delta)/2);
169  double yc = fYvar.GetValue(osc);
170  fXvar.SetValue(osc, yc+delta);
171  }
172  }
173 
174 } //namespace
const double fCenterSigma
Definition: FitVarsCPT.h:265
void SetDmsq21(const double &dmsq21) override
Definition: OscCalcCPT.h:66
virtual double HighLimit() const =0
double DeltaPenalty(double val) const
Definition: FitVarsCPT.cxx:137
double GetSigma(const osc::IOscCalcAdjustable *osc) const
Definition: FitVarsCPT.cxx:118
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
void SetValue(osc::IOscCalcAdjustable *osc, double val) const override
Definition: FitVarsCPT.cxx:38
void SetValue(osc::IOscCalcAdjustable *osc, double val) const override
Definition: FitVarsCPT.cxx:77
const OscCalcCPT * DowncastToCPT(const IOscCalcAdjustable *osc)
Definition: OscCalcCPT.cxx:232
void SetDmsq32(const double &dmsq32) override
Definition: OscCalcCPT.h:68
const FitSinSq2Theta12CPT kFitSinSq2Theta12bar(osc::ENuSign::kNuBar)
Definition: FitVarsCPT.h:239
void SetValue(osc::IOscCalcAdjustable *osc, double val) const override
Definition: FitVarsCPT.cxx:66
double delta
Definition: runWimpSim.h:98
T sqrt(T number)
Definition: d0nt_math.hpp:156
virtual double LowLimit() const =0
const FitSinSq2Theta13CPT kFitSinSq2Theta13bar(osc::ENuSign::kNuBar)
Definition: FitVarsCPT.h:216
double GetValue(const osc::IOscCalcAdjustable *osc) const override
Definition: FitVarsCPT.cxx:73
void SetDelta(osc::IOscCalcAdjustable *osc, double val)
Definition: FitVarsCPT.cxx:130
double Penalty(double val, osc::IOscCalcAdjustable *) const override
Override the default implementation with one that pushes back towards the center of the constrained s...
Definition: IFitVar.cxx:8
T sqr(T x)
More efficient square function than pow(x,2)
Definition: MathUtil.h:23
const double fCenterDelta
Definition: FitVarsCPT.h:264
const FitSinSqTheta23CPT kFitSinSqTheta23bar(osc::ENuSign::kNuBar)
Definition: FitVarsCPT.h:164
const FitSinSq2Theta23CPT kFitSinSq2Theta23bar(osc::ENuSign::kNuBar)
Definition: FitVarsCPT.h:137
double SigmaPenalty(double val, osc::IOscCalcAdjustable *) const
Definition: FitVarsCPT.cxx:142
void SetValue(osc::IOscCalcAdjustable *osc, double val) const override
Definition: FitVarsCPT.cxx:96
void SetTh12(const double &th12) override
Definition: OscCalcCPT.h:70
const FitSinSqTheta23CPTOctant kFitSinSqTheta23nuSecond(osc::ENuSign::kNu, true)
Definition: FitVarsCPT.h:192
const FitSinSq2Theta12CPT kFitSinSq2Theta12nu(osc::ENuSign::kNu)
Definition: FitVarsCPT.h:238
const FitDmSq32ScaledCPT kFitDmSq32Scalednu(osc::ENuSign::kNu)
Definition: FitVarsCPT.h:55
void SetTh13(const double &th13) override
Definition: OscCalcCPT.h:72
const FitDmSq32ScaledCPT kFitDmSq32Scaledbar(osc::ENuSign::kNuBar)
Definition: FitVarsCPT.h:56
void SetFitVars(osc::OscCalcCPT *)
Definition: FitVarsCPT.cxx:155
double GetValue(const osc::IOscCalcAdjustable *osc) const override
Definition: FitVarsCPT.cxx:83
const FitSinSq2Theta13CPT kFitSinSq2Theta13nu(osc::ENuSign::kNu)
Definition: FitVarsCPT.h:215
const FitSinSqTheta23CPTOctant kFitSinSqTheta23barSecond(osc::ENuSign::kNuBar, true)
Definition: FitVarsCPT.h:193
void SetValue(osc::IOscCalcAdjustable *osc, double val) const override
Definition: FitVarsCPT.cxx:86
const FitDmSq32CPTHierarchy kFitDmSq32nuNorm(osc::ENuSign::kNu, false)
Definition: FitVarsCPT.h:89
double GetDmsq32() const override
Definition: OscCalcCPT.cxx:116
double GetDelta(const osc::IOscCalcAdjustable *osc) const
Definition: FitVarsCPT.cxx:120
const FitSinSq2Theta23CPT kFitSinSq2Theta23nu(osc::ENuSign::kNu)
Definition: FitVarsCPT.h:136
double GetValue(const osc::IOscCalcAdjustable *osc) const override
Definition: FitVarsCPT.cxx:35
const FitDmSq21CPT kFitDmSq21bar(osc::ENuSign::kNuBar)
Definition: FitVarsCPT.h:114
const FitSinSqTheta23CPTOctant kFitSinSqTheta23barFirst(osc::ENuSign::kNuBar, false)
Definition: FitVarsCPT.h:191
T Clamp(T val) const
Definition: IFitVar.h:60
const osc::ENuSign fNuSign
Definition: FitVarsCPT.h:110
double HighLimit() const override
Definition: FitVars.h:302
const IConstrainedFitVar & fYvar
Definition: FitVarsCPT.h:262
Oscillation probability calculators.
Definition: Calcs.h:5
double sigma(TH1F *hist, double percentile)
void SetTh23(const double &th23) override
Definition: OscCalcCPT.h:74
const FitDmSq32CPT kFitDmSq32nu(osc::ENuSign::kNu)
Definition: FitVarsCPT.h:28
double GetValue(const osc::IOscCalcAdjustable *osc) const override
Definition: FitVarsCPT.cxx:44
double GetDmsq21() const override
Definition: OscCalcCPT.cxx:109
void SetValue(osc::IOscCalcAdjustable *osc, double val) const override
Definition: FitVarsCPT.cxx:47
const FitSinSqTheta23CPTOctant kFitSinSqTheta23nuFirst(osc::ENuSign::kNu, false)
Definition: FitVarsCPT.h:190
T sin(T number)
Definition: d0nt_math.hpp:132
double GetValue(const osc::IOscCalcAdjustable *osc) const override
Definition: FitVarsCPT.cxx:92
virtual void SetValue(osc::IOscCalcAdjustable *osc, double val) const =0
void SetSigma(osc::IOscCalcAdjustable *osc, double val)
Definition: FitVarsCPT.cxx:123
const FitSinSqTheta23CPT kFitSinSqTheta23nu(osc::ENuSign::kNu)
Definition: FitVarsCPT.h:163
assert(nhit_max >=nhit_nbins)
double GetValue(const osc::IOscCalcAdjustable *osc) const override
Definition: FitVarsCPT.cxx:53
double LowLimit() const override
Definition: FitVars.h:301
const IConstrainedFitVar & fXvar
Definition: FitVarsCPT.h:261
const FitDmSq32CPTHierarchy kFitDmSq32nuInv(osc::ENuSign::kNu, true)
Definition: FitVarsCPT.h:91
const FitDmSq32CPTHierarchy kFitDmSq32barNorm(osc::ENuSign::kNuBar, false)
Definition: FitVarsCPT.h:90
const FitDmSq21CPT kFitDmSq21nu(osc::ENuSign::kNu)
Definition: FitVarsCPT.h:113
SigmaDelta(osc::OscCalcCPT *osc, const IConstrainedFitVar &x, const IConstrainedFitVar &y)
Definition: FitVarsCPT.cxx:103
const FitDmSq32CPT kFitDmSq32bar(osc::ENuSign::kNuBar)
Definition: FitVarsCPT.h:29
void SetValue(osc::IOscCalcAdjustable *osc, double val) const override
Definition: FitVarsCPT.cxx:56
const FitDmSq32CPTHierarchy kFitDmSq32barInv(osc::ENuSign::kNuBar, true)
Definition: FitVarsCPT.h:92
double GetValue(const osc::IOscCalcAdjustable *osc) const override
Definition: FitVarsCPT.cxx:62
T asin(T number)
Definition: d0nt_math.hpp:60
virtual double GetValue(const osc::IOscCalcAdjustable *osc) const =0