Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
osc::_OscCalcDMP< T > Class Template Reference

Helper struct for the cache. Might not need this. More...

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N21-03-03/CAFAna/Core/StanTypedefs.h"

Inheritance diagram for osc::_OscCalcDMP< T >:
osc::_IOscCalcAdjustable< T > osc::_IOscCalc< T >

Public Member Functions

 _OscCalcDMP ()
 
 _OscCalcDMP (std::vector< double > energies)
 
 ~_OscCalcDMP ()=default
 
_IOscCalcAdjustable< T > * Copy () const override
 
T P (int flavBefore, int flavAfter, double E) override
 E in GeV; flavors as PDG codes (so, neg==>antinu) More...
 
T P (int flavBefore, int flavAfter, double E, bool fast_and_loose)
 
Array< T, Dynamic, Dynamic > P ()
 
Array< T, Dynamic, 1 > P (int flavBefore, int flavAfter, const std::vector< double > &E) override
 
void SetL (double L) override
 
void SetRho (double rho) override
 
void SetDmsq21 (const T &dmsq21) override
 
void SetDmsq32 (const T &dmsq32) override
 
void SetTh12 (const T &th12) override
 
void SetTh13 (const T &th13) override
 
void SetTh23 (const T &th23) override
 
void SetdCP (const T &dCP) override
 
void InvalidateCache () override
 Invalidate any caching used internally by the calculator. More...
 
std::string Name () const
 
virtual double GetL () const
 
virtual double GetRho () const
 
virtual T GetDmsq21 () const
 
virtual T GetDmsq32 () const
 
virtual T GetTh12 () const
 
virtual T GetTh13 () const
 
virtual T GetTh23 () const
 
virtual T GetdCP () const
 
virtual Eigen::Array< T, Eigen::Dynamic, 1 > P (int flavBefore, int flavAfter, const Eigen::ArrayXd &E)
 

Protected Member Functions

TMD5 * GetParamsHashDefault (const std::string &txt) const
 This is only a safe implementation if your calculator only depends on these eight parameters. More...
 

Protected Attributes

double fRho
 
double fL
 
T fDmsq21
 
T fDmsq32
 
T fTh12
 
T fTh13
 
T fTh23
 
T fdCP
 

Private Member Functions

void FillCache (std::vector< double > const &energies)
 
TMD5 * GetParamsHash () const override
 Use to check two calculators are in the same state. More...
 
int ChannelCacheIdx (int flavBefore, int flavAfter) const
 
virtual void FillCache ()
 
void SaveLastParams ()
 
void SetCachedEnergies (std::vector< double > const &energies)
 
bool ParamsAreCached ()
 

Private Attributes

_OscCache< TfCache
 
std::string name = "OscCalcDMP"
 
_OscParameters< TfLastParams
 

Detailed Description

template<typename T>
class osc::_OscCalcDMP< T >

Helper struct for the cache. Might not need this.

Struct of the cache A DMP based implementation of OscCalcPMNS

Uses DMP

Definition at line 25 of file StanTypedefs.h.

Constructor & Destructor Documentation

template<typename T>
osc::_OscCalcDMP< T >::_OscCalcDMP ( )
inline

Definition at line 38 of file OscCalcDMP.h.

38 {}
template<typename T>
osc::_OscCalcDMP< T >::_OscCalcDMP ( std::vector< double >  energies)
inline

Definition at line 39 of file OscCalcDMP.h.

References E, P, and T.

39  {
40  this->SetCachedEnergies(energies);
41  }
void SetCachedEnergies(std::vector< double > const &energies)
Definition: OscCalcDMP.cxx:172
template<typename T>
osc::_OscCalcDMP< T >::~_OscCalcDMP ( )
default

Member Function Documentation

template<typename T >
int osc::_OscCalcDMP< T >::ChannelCacheIdx ( int  flavBefore,
int  flavAfter 
) const
inlineprivate

Definition at line 67 of file OscCalcDMP.cxx.

References abs(), MECModelEnuComparisons::i, compare_h5_caf::idx, and calib::j.

68  {
69  // rows in the cache are arranged in the following order
70  // 11 21 31 12 22 32 13 23 33 -11 -21 -31 -12 -22 -32 -13 -23 -33
71  // where nue = 1
72  // numu = 2
73  // nutau = 3
74  // and negative is for antineutrino
75  int anti = flavBefore / abs(flavBefore);
76  int i = (abs(flavBefore) - 12) / 2;
77  int j = (abs(flavAfter) - 12) / 2;
78  int idx = (1 - anti) / 2 * 9 + (3 * j + i);
79  return idx;
80  }
void abs(TH1 *hist)
const double j
Definition: BetheBloch.cxx:29
template<typename T >
_IOscCalcAdjustable< T > * osc::_OscCalcDMP< T >::Copy ( ) const
overridevirtual

Implements osc::_IOscCalcAdjustable< T >.

Definition at line 48 of file OscCalcDMP.cxx.

49  {
50  return new _OscCalcDMP<T>(*this);
51  }
template<typename T >
void osc::_OscCalcDMP< T >::FillCache ( std::vector< double > const &  energies)
private

Definition at line 165 of file OscCalcDMP.cxx.

166  {
167  this->SetCachedEnergies(energies);
168  this->FillCache();
169  }
virtual void FillCache()
Definition: OscCalcDMP.cxx:145
void SetCachedEnergies(std::vector< double > const &energies)
Definition: OscCalcDMP.cxx:172
template<typename T >
void osc::_OscCalcDMP< T >::FillCache ( )
privatevirtual

Definition at line 145 of file OscCalcDMP.cxx.

References nbins, and osc::_PMNS_DMP< T >::P().

146  {
147  using ArrayXXT = Array<T, Dynamic, Dynamic>;
148 
149  const _OscParameters<T> params{this->fDmsq21, this->fDmsq32, this->fTh12, this->fTh13, this->fTh23, this->fdCP,
150  this->fL, this->fRho};
151  _PMNS_DMP<T> OO(this->fCache.ENERGIES, this->fRho, this->fL);
152  ArrayXXT _cache = OO.P(params);
153 
154  int nbins = this->fCache.energies.size();
155  ArrayXXT cache(nbins, 18);
156  cache.block(0, 0, nbins, 9) = _cache.block(0, 0, nbins, 9);
157  cache.block(0, 9, nbins, 9) = _cache.block(nbins, 0, nbins, 9);
158 
159  this->fCache.probabilities = cache;
160  this->fCache.parameters = params;
161  this->fCache.iter++;
162  }
const int nbins
Definition: cellShifts.C:15
_OscCache< T > fCache
Definition: OscCalcDMP.h:68
template<typename T>
virtual T osc::_IOscCalcAdjustable< T >::GetdCP ( ) const
inlinevirtualinherited
template<typename T>
virtual T osc::_IOscCalcAdjustable< T >::GetDmsq21 ( ) const
inlinevirtualinherited
template<typename T>
virtual T osc::_IOscCalcAdjustable< T >::GetDmsq32 ( ) const
inlinevirtualinherited
template<typename T>
virtual double osc::_IOscCalcAdjustable< T >::GetL ( ) const
inlinevirtualinherited
template<typename T >
TMD5 * osc::_OscCalcDMP< T >::GetParamsHash ( ) const
overrideprivatevirtual

Use to check two calculators are in the same state.

Returns
Null means not implemented for this calculator

Reimplemented from osc::_IOscCalc< T >.

Definition at line 10 of file OscCalcDMP.cxx.

References runNovaSAM::ret, string, and T.

11  {
12  std::string txt = "DMP";
13  TMD5* ret = new TMD5;
14  ret->Update((unsigned char*)txt.c_str(), txt.size());
15  const int kNumParams = 8;
16  T buf[kNumParams] = {this->fRho, this->fL, this->fDmsq21, this->fDmsq32,
17  this->fTh12, this->fTh13, this->fTh23, this->fdCP};
18  ret->Update((unsigned char*)buf, sizeof(T)*kNumParams);
19  ret->Final();
20  return ret;
21  }
double T
Definition: Xdiff_gwt.C:5
enum BeamMode string
template<typename T >
TMD5 * osc::_IOscCalcAdjustable< T >::GetParamsHashDefault ( const std::string txt) const
protectedinherited

This is only a safe implementation if your calculator only depends on these eight parameters.

Parameters
txtA string to uniquely identify your calculator class

Definition at line 49 of file IOscCalc.cxx.

References runNovaSAM::ret, and T.

Referenced by osc::_OscCalcPMNS< T >::GetParamsHash(), osc::_OscCalcPMNSOpt< T >::GetParamsHash(), and osc::analytic::_OscCalc< T >::GetParamsHash().

50  {
51  TMD5* ret = new TMD5;
52  ret->Update((unsigned char*)txt.c_str(), txt.size());
53  const int kNumParams = 8;
54  T buf[kNumParams] = {fRho, fL, fDmsq21, fDmsq32,
55  fTh12, fTh13, fTh23, fdCP};
56  ret->Update((unsigned char*)buf, sizeof(T)*kNumParams);
57  ret->Final();
58  return ret;
59  }
double T
Definition: Xdiff_gwt.C:5
template<typename T>
virtual double osc::_IOscCalcAdjustable< T >::GetRho ( ) const
inlinevirtualinherited

Reimplemented in osc::OscCalcCPT, and osc::OscCalcSterile.

Definition at line 89 of file IOscCalc.h.

Referenced by osc::CopyParams(), osc::OscCalcCPT::GetRho(), ana::ResetSterileCalcToDefault(), and ana::SaveTo().

89 { return fRho ; }
template<typename T>
virtual T osc::_IOscCalcAdjustable< T >::GetTh12 ( ) const
inlinevirtualinherited
template<typename T>
virtual T osc::_IOscCalcAdjustable< T >::GetTh13 ( ) const
inlinevirtualinherited
template<typename T>
virtual T osc::_IOscCalcAdjustable< T >::GetTh23 ( ) const
inlinevirtualinherited
template<typename T>
void osc::_OscCalcDMP< T >::InvalidateCache ( )
inlineoverridevirtual

Invalidate any caching used internally by the calculator.

Some calculators use a cache that can become stale in ways that the calculator may not know about (e.g., Stan var clearing). Default implementation does nothing.

Reimplemented from osc::_IOscCalcAdjustable< T >.

Definition at line 62 of file OscCalcDMP.h.

62 { this->fCache.clear(); }
_OscCache< T > fCache
Definition: OscCalcDMP.h:68
template<typename T>
std::string osc::_OscCalcDMP< T >::Name ( void  ) const
inline

Definition at line 64 of file OscCalcDMP.h.

64 { return name;}
std::string name
Definition: OscCalcDMP.h:74
template<class T >
Eigen::Array< T, Eigen::Dynamic, 1 > osc::_IOscCalc< T >::P ( int  flavBefore,
int  flavAfter,
const Eigen::ArrayXd &  E 
)
virtualinherited

Default implementation forawrds to vector<double> version. Override if your calculator has a more efficient implementation.

Reimplemented in osc::analytic::_OscCalc< T >.

Definition at line 37 of file IOscCalc.cxx.

References P.

38  {
39  return P(flavBefore, flavAfter, std::vector<double>(&E[0], &E[0]+E.size()));
40  }
Float_t E
Definition: plot.C:20
virtual T P(int flavBefore, int flavAfter, double E)=0
E in GeV; flavors as PDG codes (so, neg==>antinu)
template<typename T >
T osc::_OscCalcDMP< T >::P ( int  flavBefore,
int  flavAfter,
double  E 
)
overridevirtual

E in GeV; flavors as PDG codes (so, neg==>antinu)

Implements osc::_IOscCalc< T >.

Definition at line 117 of file OscCalcDMP.cxx.

References E.

118  {
119  if(std::is_arithmetic_v<T> &&
120  fCache.energies.size() != (size_t) fCache.probabilities.cols() &&
121  fCache.energies.size() != 0)
122  { // does a cache exist
123  if (ParamsAreCached())
124  { // do current params match those cached
125  auto e_it = std::find(fCache.energies.begin(),
126  fCache.energies.end(),
127  E);
128  if (e_it != fCache.energies.end())
129  { // is the given energy cached?
130 
131  return this->fCache.probabilities(e_it - fCache.energies.begin(),
132  ChannelCacheIdx(flavBefore, flavAfter));
133 
134  }
135  }
136  }
137  // if we get here, the cache is stale.
138  // TODO. write function ValidateCache
139  this->FillCache({E});
140  return this->fCache.probabilities(0, ChannelCacheIdx(flavBefore, flavAfter));
141  }
virtual void FillCache()
Definition: OscCalcDMP.cxx:145
bool ParamsAreCached()
Definition: OscCalcDMP.cxx:54
Float_t E
Definition: plot.C:20
_OscCache< T > fCache
Definition: OscCalcDMP.h:68
int ChannelCacheIdx(int flavBefore, int flavAfter) const
Definition: OscCalcDMP.cxx:67
template<typename T >
T osc::_OscCalcDMP< T >::P ( int  flavBefore,
int  flavAfter,
double  E,
bool  fast_and_loose 
)

Definition at line 100 of file OscCalcDMP.cxx.

References E, and P.

102  {
103  if (fast_and_loose)
104  {
105  auto e_it = std::find(fCache.energies.begin(),
106  fCache.energies.end(),
107  E);
108  return fCache.probabilities(e_it - fCache.energies.begin(),
109  ChannelCacheIdx(flavBefore, flavAfter));
110  } else
111  {
112  return P(flavBefore, flavAfter, E);
113  }
114  }
Array< T, Dynamic, Dynamic > P()
Definition: OscCalcDMP.h:49
Float_t E
Definition: plot.C:20
_OscCache< T > fCache
Definition: OscCalcDMP.h:68
int ChannelCacheIdx(int flavBefore, int flavAfter) const
Definition: OscCalcDMP.cxx:67
template<typename T>
Array<T,Dynamic,Dynamic> osc::_OscCalcDMP< T >::P ( )
inline

Definition at line 49 of file OscCalcDMP.h.

References P.

49 {return this->fCache.probabilities;}
_OscCache< T > fCache
Definition: OscCalcDMP.h:68
template<typename T >
Array< T, Dynamic, 1 > osc::_OscCalcDMP< T >::P ( int  flavBefore,
int  flavAfter,
const std::vector< double > &  E 
)
overridevirtual

Default implementation forwards to non-vector version using a simple loop. Override if your calculator has a more efficient implementation.

Reimplemented from osc::_IOscCalc< T >.

Definition at line 84 of file OscCalcDMP.cxx.

85  {
86  if (fCache.energies.size() != (size_t) fCache.probabilities.cols() &&
87  fCache.energies.size() != 0)
88  { // does a cache exist
89  if (ParamsAreCached())
90  {
91  if (this->fCache.energies == E)
92  return this->fCache.probabilities.col(ChannelCacheIdx(flavBefore, flavAfter));
93  }
94  }
95  FillCache(E);
96  return this->fCache.probabilities.col(ChannelCacheIdx(flavBefore, flavAfter));
97  }
virtual void FillCache()
Definition: OscCalcDMP.cxx:145
bool ParamsAreCached()
Definition: OscCalcDMP.cxx:54
Float_t E
Definition: plot.C:20
_OscCache< T > fCache
Definition: OscCalcDMP.h:68
int ChannelCacheIdx(int flavBefore, int flavAfter) const
Definition: OscCalcDMP.cxx:67
template<typename T >
bool osc::_OscCalcDMP< T >::ParamsAreCached ( )
private

Definition at line 54 of file OscCalcDMP.cxx.

55  {
56  return this->fDmsq21 == this->fCache.parameters.dmsq21 &&
57  this->fDmsq32 == this->fCache.parameters.dmsq32 &&
58  this->fTh12 == this->fCache.parameters.th12 &&
59  this->fTh13 == this->fCache.parameters.th13 &&
60  this->fTh23 == this->fCache.parameters.th23 &&
61  this->fdCP == this->fCache.parameters.deltacp &&
62  this->fL == this->fCache.parameters.L &&
63  this->fRho == this->fCache.parameters.rho;
64  }
_OscCache< T > fCache
Definition: OscCalcDMP.h:68
template<typename T >
void osc::_OscCalcDMP< T >::SaveLastParams ( )
private

Definition at line 25 of file OscCalcDMP.cxx.

26  {
27  this->fLastParams.L = this->fL;
28  this->fLastParams.rho = this->fRho;
29  this->fLastParams.dmsq21 = this->fDmsq21;
30  this->fLastParams.dmsq32 = this->fDmsq32;
31  this->fLastParams.th12 = this->fTh12;
32  this->fLastParams.th13 = this->fTh13;
33  this->fLastParams.th23 = this->fTh23;
34  this->fLastParams.deltacp = this->fdCP;
35  }
_OscParameters< T > fLastParams
Definition: OscCalcDMP.h:82
template<typename T >
void osc::_OscCalcDMP< T >::SetCachedEnergies ( std::vector< double > const &  energies)
private

Definition at line 172 of file OscCalcDMP.cxx.

References nbins.

173  {
174  this->fCache.energies = energies;
175  int nbins = energies.size();
176  ArrayXd EE(2 * nbins);
177  EE.segment(0, nbins) = Map<const ArrayXd>(energies.data(), energies.size());
178  EE.segment(nbins, nbins) = -1 * Map<const ArrayXd>(energies.data(), energies.size());
179  this->fCache.ENERGIES = EE;
180  }
const int nbins
Definition: cellShifts.C:15
_OscCache< T > fCache
Definition: OscCalcDMP.h:68
template<typename T>
void osc::_OscCalcDMP< T >::SetdCP ( const T dCP)
inlineoverridevirtual

Implements osc::_IOscCalcAdjustable< T >.

Definition at line 60 of file OscCalcDMP.h.

References dCP.

60 {SaveLastParams(); this->fdCP = dCP;}
double dCP
void SaveLastParams()
Definition: OscCalcDMP.cxx:25
template<typename T>
void osc::_OscCalcDMP< T >::SetDmsq21 ( const T dmsq21)
inlineoverridevirtual

Implements osc::_IOscCalcAdjustable< T >.

Definition at line 55 of file OscCalcDMP.h.

55 {SaveLastParams(); this->fDmsq21 = dmsq21;}
void SaveLastParams()
Definition: OscCalcDMP.cxx:25
template<typename T>
void osc::_OscCalcDMP< T >::SetDmsq32 ( const T dmsq32)
inlineoverridevirtual

Implements osc::_IOscCalcAdjustable< T >.

Definition at line 56 of file OscCalcDMP.h.

References dmsq32.

Referenced by test_stanfit_statsonly().

56 {SaveLastParams(); this->fDmsq32 = dmsq32;}
double dmsq32
void SaveLastParams()
Definition: OscCalcDMP.cxx:25
template<typename T>
void osc::_OscCalcDMP< T >::SetL ( double  L)
inlineoverridevirtual

Implements osc::_IOscCalcAdjustable< T >.

Definition at line 53 of file OscCalcDMP.h.

References CLHEP::L.

53 {SaveLastParams(); this->fL = L;}
static constexpr double L
void SaveLastParams()
Definition: OscCalcDMP.cxx:25
template<typename T>
void osc::_OscCalcDMP< T >::SetRho ( double  rho)
inlineoverridevirtual

Implements osc::_IOscCalcAdjustable< T >.

Definition at line 54 of file OscCalcDMP.h.

54 {SaveLastParams(); this->fRho = rho;}
void SaveLastParams()
Definition: OscCalcDMP.cxx:25
template<typename T>
void osc::_OscCalcDMP< T >::SetTh12 ( const T th12)
inlineoverridevirtual

Implements osc::_IOscCalcAdjustable< T >.

Definition at line 57 of file OscCalcDMP.h.

References th12.

57 {SaveLastParams(); this->fTh12 = th12;}
double th12
Definition: runWimpSim.h:98
void SaveLastParams()
Definition: OscCalcDMP.cxx:25
template<typename T>
void osc::_OscCalcDMP< T >::SetTh13 ( const T th13)
inlineoverridevirtual

Implements osc::_IOscCalcAdjustable< T >.

Definition at line 58 of file OscCalcDMP.h.

References th13.

58 {SaveLastParams(); this->fTh13 = th13;}
void SaveLastParams()
Definition: OscCalcDMP.cxx:25
double th13
Definition: runWimpSim.h:98
template<typename T>
void osc::_OscCalcDMP< T >::SetTh23 ( const T th23)
inlineoverridevirtual

Implements osc::_IOscCalcAdjustable< T >.

Definition at line 59 of file OscCalcDMP.h.

References th23.

Referenced by test_stanfit_statsonly().

59 {SaveLastParams(); this->fTh23 = th23;}
double th23
Definition: runWimpSim.h:98
void SaveLastParams()
Definition: OscCalcDMP.cxx:25

Member Data Documentation

template<typename T>
_OscCache<T> osc::_OscCalcDMP< T >::fCache
private

Definition at line 68 of file OscCalcDMP.h.

template<typename T>
T osc::_IOscCalcAdjustable< T >::fdCP
protectedinherited
template<typename T>
T osc::_IOscCalcAdjustable< T >::fDmsq21
protectedinherited
template<typename T>
T osc::_IOscCalcAdjustable< T >::fDmsq32
protectedinherited
template<typename T>
double osc::_IOscCalcAdjustable< T >::fL
protectedinherited
template<typename T>
_OscParameters<T> osc::_OscCalcDMP< T >::fLastParams
private

Definition at line 82 of file OscCalcDMP.h.

template<typename T>
double osc::_IOscCalcAdjustable< T >::fRho
protectedinherited
template<typename T>
T osc::_IOscCalcAdjustable< T >::fTh12
protectedinherited
template<typename T>
T osc::_IOscCalcAdjustable< T >::fTh13
protectedinherited
template<typename T>
T osc::_IOscCalcAdjustable< T >::fTh23
protectedinherited
template<typename T>
std::string osc::_OscCalcDMP< T >::name = "OscCalcDMP"
private

The documentation for this class was generated from the following files: