OscCalcCPT.cxx
Go to the documentation of this file.
1 #include "OscLib/OscCalcCPT.h"
2 
3 #include <cassert>
4 #include <cstdlib>
5 
6 namespace osc
7 {
8 
10  {
11  fCalc = new OscCalcPMNSOpt;
13  fSigDel = {};
14  }
15 
17  IOscCalcAdjustable* barcalc,
18  SDMap sigdel)
19  {
20  fCalc = calc;
21  fBarCalc = barcalc;
22  fSigDel = sigdel;
23  }
24 
26  {
27  delete fCalc;
28  delete fBarCalc;
29  }
30 
32  {
33  return new OscCalcCPT(fCalc->Copy(),
34  fBarCalc->Copy(),
35  fSigDel);
36  }
37 
38  double OscCalcCPT::P(int flavBefore, int flavAfter, double E)
39  {
40  assert(flavBefore*flavAfter > 0); // check for matter<->anti-matter
41  return ( (flavBefore > 0) ? fCalc->P(flavBefore, flavAfter, E)
42  : fBarCalc->P(flavBefore, flavAfter, E) );
43  }
44 
45  // asymmetric setters
47  {
48  (sign==ENuSign::kNu) ? fCalc->SetL(L) :
49  fBarCalc->SetL(L) ;
50  }
51 
52  void OscCalcCPT::SetRho(double rho, ENuSign sign)
53  {
54  (sign==ENuSign::kNu) ? fCalc->SetRho(rho) :
55  fBarCalc->SetRho(rho) ;
56  }
57 
58  void OscCalcCPT::SetDmsq21(double dmsq21, ENuSign sign)
59  {
60  (sign==ENuSign::kNu) ? fCalc->SetDmsq21(dmsq21) :
61  fBarCalc->SetDmsq21(dmsq21) ;
62  }
63 
65  {
66  (sign==ENuSign::kNu) ? fCalc->SetDmsq32(dmsq32) :
67  fBarCalc->SetDmsq32(dmsq32) ;
68  }
69 
71  {
72  (sign==ENuSign::kNu) ? fCalc->SetTh12(th12) :
73  fBarCalc->SetTh12(th12) ;
74  }
75 
77  {
78  (sign==ENuSign::kNu) ? fCalc->SetTh13(th13) :
79  fBarCalc->SetTh13(th13) ;
80  }
81 
83  {
84  (sign==ENuSign::kNu) ? fCalc->SetTh23(th23) :
85  fBarCalc->SetTh23(th23) ;
86  }
87 
89  {
90  (sign==ENuSign::kNu) ? fCalc->SetdCP(dCP) :
91  fBarCalc->SetdCP(dCP) ;
92  }
93 
94  // symmetric getters
95  double OscCalcCPT::GetL() const
96  {
97  double L = GetL(ENuSign::kNu);
98  assert( L == GetL(ENuSign::kNuBar) );
99  return L;
100  }
101 
102  double OscCalcCPT::GetRho() const
103  {
104  double rho = GetRho(ENuSign::kNu);
105  assert( rho == GetRho(ENuSign::kNuBar) );
106  return rho;
107  }
108 
109  double OscCalcCPT::GetDmsq21() const
110  {
111  double dmsq21 = GetDmsq21(ENuSign::kNu);
112  assert( dmsq21 == GetDmsq21(ENuSign::kNuBar) );
113  return dmsq21;
114  }
115 
116  double OscCalcCPT::GetDmsq32() const
117  {
118  double dmsq32 = GetDmsq32(ENuSign::kNu);
119  assert( dmsq32 == GetDmsq32(ENuSign::kNuBar) );
120  return dmsq32;
121  }
122 
123  double OscCalcCPT::GetTh12() const
124  {
125  double th12 = GetTh12(ENuSign::kNu);
126  assert( th12 == GetTh12(ENuSign::kNuBar) );
127  return th12;
128  }
129 
130  double OscCalcCPT::GetTh13() const
131  {
132  double th13 = GetTh13(ENuSign::kNu);
133  assert( th13 == GetTh13(ENuSign::kNuBar) );
134  return th13;
135  }
136 
137  double OscCalcCPT::GetTh23() const
138  {
139  double th23 = GetTh23(ENuSign::kNu);
140  assert( th23 == GetTh23(ENuSign::kNuBar) );
141  return th23;
142  }
143 
144  double OscCalcCPT::GetdCP() const
145  {
146  double dCP = GetdCP(ENuSign::kNu);
147  assert( dCP == GetdCP(ENuSign::kNuBar) );
148  return dCP;
149  }
150 
151  // asymmetric getters
153  {
154  return ( (sign==ENuSign::kNu) ? fCalc->GetL()
155  : fBarCalc->GetL() );
156  }
157 
159  {
160  return ( (sign==ENuSign::kNu) ? fCalc->GetRho()
161  : fBarCalc->GetRho() );
162  }
163 
165  {
166  return ( (sign==ENuSign::kNu) ? fCalc->GetDmsq21()
167  : fBarCalc->GetDmsq21() );
168  }
169 
171  {
172  return ( (sign==ENuSign::kNu) ? fCalc->GetDmsq32()
173  : fBarCalc->GetDmsq32() );
174  }
175 
177  {
178  return ( (sign==ENuSign::kNu) ? fCalc->GetTh12()
179  : fBarCalc->GetTh12() );
180  }
181 
183  {
184  return ( (sign==ENuSign::kNu) ? fCalc->GetTh13()
185  : fBarCalc->GetTh13() );
186  }
187 
189  {
190  return ( (sign==ENuSign::kNu) ? fCalc->GetTh23()
191  : fBarCalc->GetTh23() );
192  }
193 
195  {
196  return ( (sign==ENuSign::kNu) ? fCalc->GetdCP()
197  : fBarCalc->GetdCP() );
198  }
199 
200 
202  {
203  TMD5* hash = fCalc->GetParamsHash();
204  TMD5* barhash = fBarCalc->GetParamsHash();
205 
206  // don't provide hash unless both sub-cals do
207  if ( !(hash && barhash) )
208  {
209  delete hash;
210  delete barhash;
211  return 0;
212  }
213 
214  TMD5* ret = new TMD5;
215 
216  //hash together sub-hashes
217  ret->Update( (unsigned char*)hash->AsString(), 16);
218  ret->Update( (unsigned char*)barhash->AsString(), 16);
219 
220  delete hash;
221  delete barhash;
222 
223  //also hash in class name in case another CPT class has same idea
224  ret->Update( (unsigned char*)"OscCalcCPT", 16);
225 
226  ret->Final();
227  return ret;
228  }
229 
230  //---------------------------------------------------------------------------
231 
233  {
234  const OscCalcCPT* cpt = dynamic_cast<const OscCalcCPT*>(osc);
235  assert( cpt && "Must use OscCalcCPT with CPT FitVars." );
236  return cpt;
237  }
238 
240  {
241  OscCalcCPT* cpt = dynamic_cast<OscCalcCPT*>(osc);
242  assert( cpt && "Must use OscCalcCPT with CPT FitVars." );
243  return cpt;
244  }
245 
246 } // namespace
void SetDmsq21(const double &dmsq21) override
Definition: OscCalcCPT.h:66
virtual void SetL(double L)=0
virtual _IOscCalcAdjustable< T > * Copy() const =0
_OscCalcPMNSOpt< double > OscCalcPMNSOpt
const OscCalcCPT * DowncastToCPT(const IOscCalcAdjustable *osc)
Definition: OscCalcCPT.cxx:232
void SetDmsq32(const double &dmsq32) override
Definition: OscCalcCPT.h:68
double GetTh13() const override
Definition: OscCalcCPT.cxx:130
virtual void SetDmsq21(const T &dmsq21)=0
double th23
Definition: runWimpSim.h:98
~OscCalcCPT() override
Definition: OscCalcCPT.cxx:25
double GetRho() const override
Definition: OscCalcCPT.cxx:102
TMD5 * GetParamsHash() const override
Use to check two calculators are in the same state.
Definition: OscCalcCPT.cxx:201
virtual double GetL() const
Definition: IOscCalc.h:88
virtual void SetTh13(const T &th13)=0
virtual T GetTh23() const
Definition: IOscCalc.h:94
double th12
Definition: runWimpSim.h:98
osc::OscCalcDumb calc
virtual void SetDmsq32(const T &dmsq32)=0
IOscCalcAdjustable * Copy() const override
Definition: OscCalcCPT.cxx:31
double GetL() const override
Definition: OscCalcCPT.cxx:95
void SetTh12(const double &th12) override
Definition: OscCalcCPT.h:70
IOscCalcAdjustable * fCalc
Definition: OscCalcCPT.h:114
OscCalcCPT()
default, uses OscCalcPMNSOpt for sub-calculators
Definition: OscCalcCPT.cxx:9
double GetTh23() const override
Definition: OscCalcCPT.cxx:137
void SetTh13(const double &th13) override
Definition: OscCalcCPT.h:72
void SetRho(double rho) override
Definition: OscCalcCPT.h:64
double GetdCP() const override
Definition: OscCalcCPT.cxx:144
static constexpr double L
Float_t E
Definition: plot.C:20
std::map< const ana::SigmaDelta *, std::pair< double, double > > SDMap
Definition: OscCalcCPT.h:33
double dCP
double GetDmsq32() const override
Definition: OscCalcCPT.cxx:116
void SetdCP(const double &dCP) override
Definition: OscCalcCPT.h:76
virtual T GetDmsq32() const
Definition: IOscCalc.h:91
virtual T GetTh12() const
Definition: IOscCalc.h:92
ENuSign
Simple neutrino/anti-neutrino enum.
Definition: OscCalcCPT.h:28
Oscillation probability calculators.
Definition: Calcs.h:5
virtual TMD5 * GetParamsHash() const
Use to check two calculators are in the same state.
Definition: IOscCalc.h:39
void SetTh23(const double &th23) override
Definition: OscCalcCPT.h:74
virtual T GetdCP() const
Definition: IOscCalc.h:95
virtual T GetTh13() const
Definition: IOscCalc.h:93
virtual T P(int flavBefore, int flavAfter, double E)=0
E in GeV; flavors as PDG codes (so, neg==>antinu)
double GetDmsq21() const override
Definition: OscCalcCPT.cxx:109
virtual T GetDmsq21() const
Definition: IOscCalc.h:90
virtual void SetRho(double rho)=0
double dmsq32
virtual void SetTh23(const T &th23)=0
void SetL(double L) override
Definition: OscCalcCPT.h:62
assert(nhit_max >=nhit_nbins)
double P(int flavBefore, int flavAfter, double E) override
E in GeV; flavors as PDG codes (so, neg==>antinu)
Definition: OscCalcCPT.cxx:38
double GetTh12() const override
Definition: OscCalcCPT.cxx:123
virtual double GetRho() const
Definition: IOscCalc.h:89
IOscCalcAdjustable * fBarCalc
Definition: OscCalcCPT.h:115
double th13
Definition: runWimpSim.h:98
def sign(x)
Definition: canMan.py:197
virtual void SetTh12(const T &th12)=0
virtual void SetdCP(const T &dCP)=0