Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
osc::OscCalcPMNSOptEigen Class Reference

A re-optimized version of OscCalcPMNSOpt. More...

#include "/cvmfs/nova.opensciencegrid.org/externals/osclib/v00.07/src/OscLib/OscCalcPMNSOptEigen.h"

Inheritance diagram for osc::OscCalcPMNSOptEigen:
osc::_IOscCalcAdjustable< double > osc::_IOscCalc< T >

Public Member Functions

 OscCalcPMNSOptEigen ()
 
 OscCalcPMNSOptEigen (std::vector< double > energies)
 
 ~OscCalcPMNSOptEigen ()=default
 
IOscCalcAdjustableCopy () const override
 
double P (int flavBefore, int flavAfter, double E) override
 E in GeV; flavors as PDG codes (so, neg==>antinu) More...
 
double P (int flavBefore, int flavAfter, double E, bool fast_and_loose)
 
Eigen::ArrayXd P (int flavBefore, int flavAfter, const std::vector< double > &E) override
 
void SetL (double L) override
 
void SetRho (double rho) override
 
void SetDmsq21 (const double &dmsq21) override
 
void SetDmsq32 (const double &dmsq32) override
 
void SetTh12 (const double &th12) override
 
void SetTh13 (const double &th13) override
 
void SetTh23 (const double &th23) override
 
void SetdCP (const double &dCP) override
 
TMD5 * GetParamsHash () const override
 Use to check two calculators are in the same state. More...
 
std::string Name () const
 
virtual double GetL () const
 
virtual double GetRho () const
 
virtual double GetDmsq21 () const
 
virtual double GetDmsq32 () const
 
virtual double GetTh12 () const
 
virtual double GetTh13 () const
 
virtual double GetTh23 () const
 
virtual double GetdCP () const
 
virtual void InvalidateCache ()
 Invalidate any caching used internally by the calculator. More...
 
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
 
double fDmsq21
 
double fDmsq32
 
double fTh12
 
double fTh13
 
double fTh23
 
double fdCP
 

Private Member Functions

void FillCache (const std::vector< double > &energies)
 
int ChannelCacheIdx (int flavBefore, int flavAfter) const
 
void FillCache ()
 
void SaveLastParams ()
 
void SetCachedEnergies (std::vector< double > const &energies)
 
Eigen::Matrix3cd BuildHam (const OscParameters &params) const
 
Eigen::Matrix3cd AddMatterEffects (const Eigen::Matrix3cd &ham, const double &E, const int &anti, const OscParameters &params) const
 
Eigen::Matrix3cd AddMatterEffects (const Eigen::Matrix3cd &ham, const double &E, const OscParameters &params) const
 
Eigen::Matrix3cd AddMatterEffectsAnti (const Eigen::Matrix3cd &ham, const double &E, const OscParameters &params) const
 
Eigen::Matrix3cd MatterHamiltonian (const double &E, const int &anti, const OscParameters &params) const
 
EigenSystem Solve (Eigen::Matrix3cd const &ham) const
 
Eigen::Matrix3cd PropMatter (Eigen::Matrix3cd const &evec, Eigen::Vector3d const &evals, const OscParameters &params) const
 
void PrintArrayAddresses (const double *data, int size) const
 
void PrintMatrixAddresses (const double *data, int nrows, int ncols) const
 
void PrintMatrixAddresses (const Eigen::ArrayXXd &mat) const
 
bool ParamsAreCached ()
 

Private Attributes

_OscCache< double > fCache
 
std::string name = "OscCalcPMNSOptEigen"
 
OscParameters fLastParams
 

Detailed Description

A re-optimized version of OscCalcPMNSOpt.

Uses a faster caching scheme than OscCalcPMNSOpt

Definition at line 76 of file OscCalcPMNSOptEigen.h.

Constructor & Destructor Documentation

osc::OscCalcPMNSOptEigen::OscCalcPMNSOptEigen ( )
inline

Definition at line 79 of file OscCalcPMNSOptEigen.h.

Referenced by Copy().

79 {}
osc::OscCalcPMNSOptEigen::OscCalcPMNSOptEigen ( std::vector< double >  energies)
inline

Definition at line 80 of file OscCalcPMNSOptEigen.h.

References E, and P.

80  {
81  this->SetCachedEnergies(energies);
82  }
void SetCachedEnergies(std::vector< double > const &energies)
osc::OscCalcPMNSOptEigen::~OscCalcPMNSOptEigen ( )
default

Member Function Documentation

Eigen::Matrix3cd osc::OscCalcPMNSOptEigen::AddMatterEffects ( const Eigen::Matrix3cd &  ham,
const double &  E,
const int anti,
const OscParameters params 
) const
private

Definition at line 341 of file OscCalcPMNSOptEigen.cxx.

References osc::_OscParameters< T >::Dmsq31(), osc::kGeV2eV, osc::kGf, osc::kK2, and osc::_OscParameters< T >::rho.

Referenced by FillCache().

345  {
346  double lv = 2 * kGeV2eV*E / params.Dmsq31(); // Osc. length in eV^-1
347  double kr2GNe = kK2*M_SQRT2*kGf * params.rho/2; // Matter potential in eV
348 
349  Eigen::Matrix3cd green_eggs(ham);
350  green_eggs.triangularView<Eigen::Upper>()/=lv;
351 
352  if (anti>0) {
353  // FIXME we only transposehere to be consistent with the original implementation
354  // --- resulting in all that mangling of eigenvectors later
355  green_eggs.transposeInPlace();
356  green_eggs(0,0) += kr2GNe;
357  }
358  else {
359  green_eggs.adjointInPlace();
360  green_eggs(0,0) -= kr2GNe;
361  }
362  return green_eggs;
363  }
static const double kK2
mole/GeV^2/cm^3 to eV
Definition: PMNSOpt.h:42
static const double kGeV2eV
GeV to eV.
Definition: PMNSOpt.h:43
Float_t E
Definition: plot.C:20
static const double kGf
Definition: PMNSOpt.h:46
Eigen::Matrix3cd osc::OscCalcPMNSOptEigen::AddMatterEffects ( const Eigen::Matrix3cd &  ham,
const double &  E,
const OscParameters params 
) const
private

Definition at line 384 of file OscCalcPMNSOptEigen.cxx.

References osc::_OscParameters< T >::Dmsq31(), osc::kGeV2eV, osc::kGf, osc::kK2, and osc::_OscParameters< T >::rho.

387  {
388  double lv = 2 * kGeV2eV*E / params.Dmsq31(); // Osc. length in eV^-1
389  double kr2GNe = kK2*M_SQRT2*kGf * params.rho/2; // Matter potential in eV
390 
391  Eigen::Matrix3cd green_eggs(ham);
392  green_eggs.triangularView<Eigen::Upper>()/=lv;
393 
394  // FIXME we only transposehere to be consistent with the original implementation
395  // --- resulting in all that mangling of eigenvectors later
396  green_eggs.transposeInPlace();
397  green_eggs(0,0) += kr2GNe;
398 
399  return green_eggs;
400  }
static const double kK2
mole/GeV^2/cm^3 to eV
Definition: PMNSOpt.h:42
static const double kGeV2eV
GeV to eV.
Definition: PMNSOpt.h:43
Float_t E
Definition: plot.C:20
static const double kGf
Definition: PMNSOpt.h:46
Eigen::Matrix3cd osc::OscCalcPMNSOptEigen::AddMatterEffectsAnti ( const Eigen::Matrix3cd &  ham,
const double &  E,
const OscParameters params 
) const
private

Definition at line 366 of file OscCalcPMNSOptEigen.cxx.

References osc::_OscParameters< T >::Dmsq31(), osc::kGeV2eV, osc::kGf, osc::kK2, and osc::_OscParameters< T >::rho.

369  {
370  double lv = 2 * kGeV2eV*E / params.Dmsq31(); // Osc. length in eV^-1
371  double kr2GNe = kK2*M_SQRT2*kGf * params.rho/2; // Matter potential in eV
372 
373  Eigen::Matrix3cd green_eggs(ham);
374  green_eggs.triangularView<Eigen::Upper>()/=lv;
375 
376  green_eggs.adjointInPlace();
377  green_eggs(0,0) -= kr2GNe;
378 
379  return green_eggs;
380  }
static const double kK2
mole/GeV^2/cm^3 to eV
Definition: PMNSOpt.h:42
static const double kGeV2eV
GeV to eV.
Definition: PMNSOpt.h:43
Float_t E
Definition: plot.C:20
static const double kGf
Definition: PMNSOpt.h:46
Eigen::Matrix3cd osc::OscCalcPMNSOptEigen::BuildHam ( const OscParameters params) const
private

Definition at line 430 of file OscCalcPMNSOptEigen.cxx.

References osc::_sincos(), osc::_OscParameters< T >::deltacp, osc::_OscParameters< T >::dmsq21, osc::_OscParameters< T >::Dmsq31(), h11, h12, osc::_OscParameters< T >::th12, osc::_OscParameters< T >::th13, and osc::_OscParameters< T >::th23.

Referenced by FillCache(), and MatterHamiltonian().

431  {
432  // Create temp variables
433  double sij, cij, h00, h11, h01;
434  std::complex<double> expCP, h02, h12;
435 
436  // Hamiltonian in mass base. Only one entry is variable.
437  h11 = params.dmsq21 / params.Dmsq31();
438 
439  // Rotate over theta12
440  _sincos(params.th12, sij, cij);
441 
442  // There are 3 non-zero entries after rephasing so that h22 = 0
443  h00 = h11 * sij * sij - 1;
444  h01 = h11 * sij * cij;
445  h11 = h11 * cij * cij - 1;
446 
447  // Rotate over theta13 with deltaCP
448  _sincos(params.deltacp, sij, cij);
449  expCP = std::complex<double>(cij, -sij);
450 
451  _sincos(params.th13, sij, cij);
452 
453 
454  // There are 5 non-zero entries after rephasing so that h22 = 0
455  h02 = (-h00 * sij * cij) * expCP;
456  h12 = (-h01 * sij) * expCP;
457  h11 -= h00 * sij * sij;
458  h00 *= cij * cij - sij * sij;
459  h01 *= cij;
460 
461  // Finally, rotate over theta23
462  _sincos(params.th23, sij, cij);
463 
464 
465  // Fill the Hamiltonian rephased so that h22 = -h11
466  Eigen::Matrix3cd mHlv;
467  mHlv(0,0) = h00 - 0.5 * h11;
468  mHlv(1,1) = 0.5 * h11 * (cij * cij - sij * sij) + 2 * real(h12) * cij * sij;
469  mHlv(2,2) = -mHlv(1,1);
470 
471  mHlv(0,1) = h02 * sij + h01 * cij;
472  mHlv(0,2) = h02 * cij - h01 * sij;
473  mHlv(1,2) = h12 - (h11 * cij + 2 * real(h12) * sij) * sij;
474 
475  return mHlv;
476  }
void _sincos(double theta, double &s, double &c)
Definition: OscCalcDMP.cxx:37
TH1F * h11
Definition: plot.C:43
TH1D * h12
Definition: plot_hist.C:27
int osc::OscCalcPMNSOptEigen::ChannelCacheIdx ( int  flavBefore,
int  flavAfter 
) const
inlineprivate

Definition at line 80 of file OscCalcPMNSOptEigen.cxx.

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

Referenced by P().

81  {
82  // rows in the cache are arranged in the following order
83  // 11 21 31 12 22 32 13 23 33 -11 -21 -31 -12 -22 -32 -13 -23 -33
84  // where nue = 1
85  // numu = 2
86  // nutau = 3
87  // and negative is for antineutrino
88  int anti = flavBefore / abs(flavBefore);
89  int i = (abs(flavBefore) - 12) / 2;
90  int j = (abs(flavAfter) - 12) / 2;
91  int idx = (1-anti)/2*9 + (3 * j + i);
92  return idx;
93  }
void abs(TH1 *hist)
const double j
Definition: BetheBloch.cxx:29
IOscCalcAdjustable * osc::OscCalcPMNSOptEigen::Copy ( ) const
overridevirtual

Implements osc::_IOscCalcAdjustable< double >.

Definition at line 58 of file OscCalcPMNSOptEigen.cxx.

References osc::_OscCache< T >::clear(), fCache, OscCalcPMNSOptEigen(), and runNovaSAM::ret.

59  {
61  ret->fCache.clear();
62  return ret;
63  }
void osc::OscCalcPMNSOptEigen::FillCache ( const std::vector< double > &  energies)
private
void osc::OscCalcPMNSOptEigen::FillCache ( )
private

probabilities returned are in columns of energy and rows of flavors: 0-2 [nue, numu, nutau] : 3-5 [antinue, antinumu, antinutau] Dimension two is the "from" flavor Dimension three is the "to" flavor ie. P(numu->nue) is probabilities[energy_idx][0][1] P(antinumu-> antinutau) is probabilities[energy_idx][4][5]

Definition at line 174 of file OscCalcPMNSOptEigen.cxx.

References AddMatterEffects(), BuildHam(), osc::_OscCache< T >::energies, fCache, osc::_IOscCalcAdjustable< double >::fdCP, osc::_IOscCalcAdjustable< double >::fDmsq21, osc::_IOscCalcAdjustable< double >::fDmsq32, osc::_IOscCalcAdjustable< double >::fL, osc::_IOscCalcAdjustable< double >::fRho, osc::_IOscCalcAdjustable< double >::fTh12, osc::_IOscCalcAdjustable< double >::fTh13, osc::_IOscCalcAdjustable< double >::fTh23, MECModelEnuComparisons::i, osc::_OscCache< T >::iter, osc::_OscCache< T >::parameters, osc::Probabilities(), osc::_OscCache< T >::probabilities, PropMatter(), check_grl::row, Solve(), osc::EigenSystem::values, osc::EigenSystem::vectors, and Zero().

Referenced by P(), and PropMatter().

175  {
176  // std::cout << "Using OscCalcPMNSOptEigen\n";
177  // std::cout << "Filling cache" << std::endl;
178  const OscParameters params{fDmsq21, fDmsq32,
179  fTh12, fTh13, fTh23,
180  fdCP, fL, fRho};
181  /// probabilities returned are in columns of energy and rows of
182  /// flavors: 0-2 [nue, numu, nutau]
183  /// : 3-5 [antinue, antinumu, antinutau]
184  /// Dimension two is the "from" flavor
185  /// Dimension three is the "to" flavor
186  /// ie. P(numu->nue) is probabilities[energy_idx][0][1]
187  /// P(antinumu-> antinutau) is probabilities[energy_idx][4][5]
188  Eigen::ArrayXXd cache = Eigen::ArrayXXd::Zero(this->fCache.energies.size(), 18);
189 
190  Eigen::Matrix3cd const ham = BuildHam(params);
191  // matter hamiltonian is energy and flavor dependent
192  for(int anti : {-1, 1}) {
193 
194  //#pragma omp parallel for
195  for(unsigned int i = 0; i < this->fCache.energies.size(); i++) {
196  if(fCache.energies[i] <= 0) continue;
197 
198  // solve for flavor eigenstates. This part is expensive
199  EigenSystem const flavor_states =
200  Solve(AddMatterEffects(ham,
201  this->fCache.energies[i],
202  anti,
203  params));
204 
205  // returns Eigen Matrix of probabilities for each transition
206  auto const probabilities = Probabilities(PropMatter(flavor_states.vectors,
207  flavor_states.values,
208  params),
209  flavor_states.vectors);
210 
211  // reshape to a row vector
212  auto const row = Eigen::Map<const Eigen::Matrix<double, 1, 9> >(probabilities.data(), probabilities.size());
213 
214  // insert the matrix of probabilties into cache as a row
215  cache.block(i, (1-anti)/2 * 9, 1, 9) = row;// Eigen::Map<const Eigen::Matrix<double, 1, 9> >(probabilities.data(), probabilities.size());// row;
216  }
217  }
218 
219  this->fCache.probabilities = cache;
220  this->fCache.parameters = params;
221  this->fCache.iter++;
222 
223 // PrintMatrixAddresses(fCache.probabilities.data(),
224 // fCache.probabilities.rows(),
225 // fCache.probabilities.cols());
226 // PrintMatrixAddresses(this->fCache.probabilities);
227  }
unsigned int iter
Definition: OscParameters.h:67
Eigen::Matrix3cd BuildHam(const OscParameters &params) const
Eigen::Matrix3cd AddMatterEffects(const Eigen::Matrix3cd &ham, const double &E, const int &anti, const OscParameters &params) const
_OscParameters< double > OscParameters
Definition: OscParameters.h:33
Eigen::Matrix3cd PropMatter(Eigen::Matrix3cd const &evec, Eigen::Vector3d const &evals, const OscParameters &params) const
EigenSystem Solve(Eigen::Matrix3cd const &ham) const
Eigen::Array33d Probabilities(const Eigen::Matrix3cd &to, const Eigen::Matrix3cd &from)
_OscCache< double > fCache
std::vector< double > energies
Definition: OscParameters.h:63
void Zero()
Array< T, Dynamic, Dynamic > probabilities
Definition: OscParameters.h:65
_OscParameters< T > parameters
Definition: OscParameters.h:66
virtual double osc::_IOscCalcAdjustable< double >::GetdCP ( ) const
inlinevirtualinherited

Reimplemented in osc::OscCalcCPT.

Definition at line 95 of file IOscCalc.h.

95 { return fdCP ; }
virtual double osc::_IOscCalcAdjustable< double >::GetDmsq21 ( ) const
inlinevirtualinherited

Reimplemented in osc::OscCalcCPT.

Definition at line 90 of file IOscCalc.h.

90 { return fDmsq21 ; }
virtual double osc::_IOscCalcAdjustable< double >::GetDmsq32 ( ) const
inlinevirtualinherited

Reimplemented in osc::OscCalcCPT.

Definition at line 91 of file IOscCalc.h.

91 { return fDmsq32 ; }
virtual double osc::_IOscCalcAdjustable< double >::GetL ( ) const
inlinevirtualinherited

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

Definition at line 88 of file IOscCalc.h.

88 { return fL ; }
TMD5 * osc::OscCalcPMNSOptEigen::GetParamsHash ( ) const
overridevirtual

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 15 of file OscCalcPMNSOptEigen.cxx.

References osc::_IOscCalcAdjustable< double >::fdCP, osc::_IOscCalcAdjustable< double >::fDmsq21, osc::_IOscCalcAdjustable< double >::fDmsq32, osc::_IOscCalcAdjustable< double >::fL, osc::_IOscCalcAdjustable< double >::fRho, osc::_IOscCalcAdjustable< double >::fTh12, osc::_IOscCalcAdjustable< double >::fTh13, osc::_IOscCalcAdjustable< double >::fTh23, runNovaSAM::ret, and string.

16  {
17  std::string txt = "PMNSOptEigen";
18  TMD5* ret = new TMD5;
19  ret->Update((unsigned char*)txt.c_str(), txt.size());
20  const int kNumParams = 8;
21  double buf[kNumParams] = {fRho, fL, fDmsq21, fDmsq32,
22  fTh12, fTh13, fTh23, fdCP};
23  ret->Update((unsigned char*)buf, sizeof(double)*kNumParams);
24  ret->Final();
25  return ret;
26  }
enum BeamMode string
TMD5* osc::_IOscCalcAdjustable< double >::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

Referenced by osc::OscCalcGeneral::GetParamsHash(), osc::OscCalcPMNS_CPT::GetParamsHash(), and osc::OscCalc::GetParamsHash().

virtual double osc::_IOscCalcAdjustable< double >::GetRho ( ) const
inlinevirtualinherited

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

Definition at line 89 of file IOscCalc.h.

89 { return fRho ; }
virtual double osc::_IOscCalcAdjustable< double >::GetTh12 ( ) const
inlinevirtualinherited

Reimplemented in osc::OscCalcCPT.

Definition at line 92 of file IOscCalc.h.

92 { return fTh12 ; }
virtual double osc::_IOscCalcAdjustable< double >::GetTh13 ( ) const
inlinevirtualinherited

Reimplemented in osc::OscCalcCPT.

Definition at line 93 of file IOscCalc.h.

93 { return fTh13 ; }
virtual double osc::_IOscCalcAdjustable< double >::GetTh23 ( ) const
inlinevirtualinherited

Reimplemented in osc::OscCalcCPT.

Definition at line 94 of file IOscCalc.h.

94 { return fTh23 ; }
virtual void osc::_IOscCalcAdjustable< double >::InvalidateCache ( )
inlinevirtualinherited

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.

Definition at line 102 of file IOscCalc.h.

References string.

102 {};
Eigen::Matrix3cd osc::OscCalcPMNSOptEigen::MatterHamiltonian ( const double &  E,
const int anti,
const OscParameters params 
) const
private

Definition at line 407 of file OscCalcPMNSOptEigen.cxx.

References BuildHam(), osc::_OscParameters< T >::Dmsq31(), osc::kGeV2eV, osc::kGf, osc::kK2, and osc::_OscParameters< T >::rho.

Referenced by P().

410  {
411  double lv = 2 * kGeV2eV*E / params.Dmsq31(); // Osc. length in eV^-1
412  double kr2GNe = kK2*M_SQRT2*kGf * params.rho/2; // Matter potential in eV
413 
414  auto HLV = BuildHam(params);
415  HLV.triangularView<Eigen::Upper>()/=lv;
416 
417  if (anti>0) {
418  HLV.transposeInPlace(); // FIXME we only transposehere to be consistent with the original implementation --- resulting in all that mangling of eigenvectors later
419  HLV(0,0) += kr2GNe;
420  }
421  else {
422  HLV.adjointInPlace();
423  HLV(0,0) -= kr2GNe;
424  }
425  return HLV;
426  }
Eigen::Matrix3cd BuildHam(const OscParameters &params) const
static const double kK2
mole/GeV^2/cm^3 to eV
Definition: PMNSOpt.h:42
static const double kGeV2eV
GeV to eV.
Definition: PMNSOpt.h:43
Float_t E
Definition: plot.C:20
static const double kGf
Definition: PMNSOpt.h:46
std::string osc::OscCalcPMNSOptEigen::Name ( void  ) const
inline

Definition at line 103 of file OscCalcPMNSOptEigen.h.

103 { return name; }
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)
double osc::OscCalcPMNSOptEigen::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 128 of file OscCalcPMNSOptEigen.cxx.

References abs(), ChannelCacheIdx(), E, osc::_OscCache< T >::energies, fCache, osc::_IOscCalcAdjustable< double >::fdCP, osc::_IOscCalcAdjustable< double >::fDmsq21, osc::_IOscCalcAdjustable< double >::fDmsq32, osc::_IOscCalcAdjustable< double >::fL, osc::_IOscCalcAdjustable< double >::fRho, osc::_IOscCalcAdjustable< double >::fTh12, osc::_IOscCalcAdjustable< double >::fTh13, osc::_IOscCalcAdjustable< double >::fTh23, MatterHamiltonian(), ParamsAreCached(), osc::Probabilities(), osc::_OscCache< T >::probabilities, PropMatter(), and Solve().

Referenced by P().

129  {
130  // Are there probabilities cached and can we use them?
131  if(fCache.energies.size() != (size_t) fCache.probabilities.cols() &&
132  fCache.energies.size() != 0) { // does a cache exist
133  if(ParamsAreCached()) { // do current params match those cached
134  auto e_it = std::find(fCache.energies.begin(),
135  fCache.energies.end(),
136  E);
137  if(e_it != fCache.energies.end()) { // is the given energy cached?
138 
139  return this->fCache.probabilities(e_it - fCache.energies.begin(),
140  ChannelCacheIdx(flavBefore, flavAfter));
141 
142  }
143  }
144  }
145 
146 
147  // If we make it through this logic, just calculate it from scratch
148  const OscParameters params{fDmsq21, fDmsq32,
149  fTh12, fTh13, fTh23,
150  fdCP, fL, fRho};
151 
152  auto anti = 1;
153  if(flavBefore < 0) anti = -1;
154  EigenSystem flavor_states{Solve(MatterHamiltonian(E, anti, params))};
155 
156 
157  // returns Eigen Matrix of probabilities for each transition
158  auto probabilities = Probabilities(PropMatter(flavor_states.vectors,
159  flavor_states.values,
160  params),
161  flavor_states.vectors);
162  return probabilities((abs(flavBefore)-12)/2, (abs(flavAfter)-12)/2);
163 
164  /*
165  auto row = Eigen::Map<const Eigen::RowVectorXd>(probabilities.data(),
166  probabilities.size());
167  return row(ChannelCacheIdx(flavBefore, flavAfter));
168  */
169  }
_OscParameters< double > OscParameters
Definition: OscParameters.h:33
Eigen::Matrix3cd PropMatter(Eigen::Matrix3cd const &evec, Eigen::Vector3d const &evals, const OscParameters &params) const
void abs(TH1 *hist)
EigenSystem Solve(Eigen::Matrix3cd const &ham) const
Eigen::Matrix3cd MatterHamiltonian(const double &E, const int &anti, const OscParameters &params) const
Float_t E
Definition: plot.C:20
int ChannelCacheIdx(int flavBefore, int flavAfter) const
Eigen::Array33d Probabilities(const Eigen::Matrix3cd &to, const Eigen::Matrix3cd &from)
_OscCache< double > fCache
std::vector< double > energies
Definition: OscParameters.h:63
Array< T, Dynamic, Dynamic > probabilities
Definition: OscParameters.h:65
double osc::OscCalcPMNSOptEigen::P ( int  flavBefore,
int  flavAfter,
double  E,
bool  fast_and_loose 
)

Definition at line 112 of file OscCalcPMNSOptEigen.cxx.

References ChannelCacheIdx(), E, osc::_OscCache< T >::energies, fCache, P(), and osc::_OscCache< T >::probabilities.

114  {
115  if(fast_and_loose) {
116  auto e_it = std::find(fCache.energies.begin(),
117  fCache.energies.end(),
118  E);
119  return fCache.probabilities(e_it - fCache.energies.begin(),
120  ChannelCacheIdx(flavBefore, flavAfter));
121  }
122  else {
123  return P(flavBefore, flavAfter, E);
124  }
125  }
double P(int flavBefore, int flavAfter, double E) override
E in GeV; flavors as PDG codes (so, neg==>antinu)
Float_t E
Definition: plot.C:20
int ChannelCacheIdx(int flavBefore, int flavAfter) const
_OscCache< double > fCache
std::vector< double > energies
Definition: OscParameters.h:63
Array< T, Dynamic, Dynamic > probabilities
Definition: OscParameters.h:65
Eigen::ArrayXd osc::OscCalcPMNSOptEigen::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 97 of file OscCalcPMNSOptEigen.cxx.

References ChannelCacheIdx(), osc::_OscCache< T >::energies, fCache, FillCache(), ParamsAreCached(), and osc::_OscCache< T >::probabilities.

98  {
99  // Are there probabilities cached and can we use them?
100  if(fCache.energies.size() != (size_t) fCache.probabilities.cols() &&
101  fCache.energies.size() != 0) { // does a cache exist
102  if(ParamsAreCached()) {
103  if(this->fCache.energies == E)
104  return this->fCache.probabilities.col(ChannelCacheIdx(flavBefore, flavAfter));
105  }
106  }
107  FillCache(E);
108  return this->fCache.probabilities.col(ChannelCacheIdx(flavBefore, flavAfter));
109  }
Float_t E
Definition: plot.C:20
int ChannelCacheIdx(int flavBefore, int flavAfter) const
_OscCache< double > fCache
std::vector< double > energies
Definition: OscParameters.h:63
Array< T, Dynamic, Dynamic > probabilities
Definition: OscParameters.h:65
bool osc::OscCalcPMNSOptEigen::ParamsAreCached ( )
private

Definition at line 66 of file OscCalcPMNSOptEigen.cxx.

References osc::_OscParameters< T >::deltacp, osc::_OscParameters< T >::dmsq21, osc::_OscParameters< T >::dmsq32, fCache, osc::_IOscCalcAdjustable< double >::fdCP, osc::_IOscCalcAdjustable< double >::fDmsq21, osc::_IOscCalcAdjustable< double >::fDmsq32, osc::_IOscCalcAdjustable< double >::fL, osc::_IOscCalcAdjustable< double >::fRho, osc::_IOscCalcAdjustable< double >::fTh12, osc::_IOscCalcAdjustable< double >::fTh13, osc::_IOscCalcAdjustable< double >::fTh23, osc::_OscParameters< T >::L, osc::_OscCache< T >::parameters, osc::_OscParameters< T >::rho, osc::_OscParameters< T >::th12, osc::_OscParameters< T >::th13, and osc::_OscParameters< T >::th23.

Referenced by P().

67  {
68  return
69  fDmsq21 == this->fCache.parameters.dmsq21 &&
70  fDmsq32 == this->fCache.parameters.dmsq32 &&
71  fTh12 == this->fCache.parameters.th12 &&
72  fTh13 == this->fCache.parameters.th13 &&
73  fTh23 == this->fCache.parameters.th23 &&
74  fdCP == this->fCache.parameters.deltacp &&
75  fL == this->fCache.parameters.L &&
76  fRho == this->fCache.parameters.rho;
77  }
_OscCache< double > fCache
_OscParameters< T > parameters
Definition: OscParameters.h:66
void osc::OscCalcPMNSOptEigen::PrintArrayAddresses ( const double *  data,
int  size 
) const
private

Definition at line 242 of file OscCalcPMNSOptEigen.cxx.

References om::cout, allTimeWatchdog::endl, MECModelEnuComparisons::i, and gen_hdf5record::size.

244  {
245  for(int i = 0; i < size; i++)
246  std::cout << data + i << ", (" << data[i] << ") ";
247  std::cout << std::endl;
248  }
const XML_Char const XML_Char * data
Definition: expat.h:268
OStream cout
Definition: OStream.cxx:6
void osc::OscCalcPMNSOptEigen::PrintMatrixAddresses ( const double *  data,
int  nrows,
int  ncols 
) const
private

Definition at line 251 of file OscCalcPMNSOptEigen.cxx.

References om::cout, allTimeWatchdog::endl, MECModelEnuComparisons::i, calib::j, ncols, and fillBadChanDBTables::nrows.

253  {
254  for(int i = 0; i < nrows; i++) {
255  for(int j = 0; j < ncols; j++) {
256  std::cout << data + i * ncols + j << " ";
257  }
258  std::cout << std::endl;
259  }
260  }
const XML_Char const XML_Char * data
Definition: expat.h:268
const double j
Definition: BetheBloch.cxx:29
OStream cout
Definition: OStream.cxx:6
Int_t ncols
Definition: plot.C:53
void osc::OscCalcPMNSOptEigen::PrintMatrixAddresses ( const Eigen::ArrayXXd &  mat) const
private

Definition at line 230 of file OscCalcPMNSOptEigen.cxx.

References om::cout, allTimeWatchdog::endl, MECModelEnuComparisons::i, and calib::j.

231  {
232 
233  for(int j = 0; j < mat.cols(); j++) {
234  for(int i = 0; i < mat.rows(); i++) {
235  std::cout << &mat(i, j) << " ";
236  }
237  std::cout << std::endl;
238  }
239  }
const double j
Definition: BetheBloch.cxx:29
OStream cout
Definition: OStream.cxx:6
Eigen::MatrixXd mat
Eigen::Matrix3cd osc::OscCalcPMNSOptEigen::PropMatter ( Eigen::Matrix3cd const &  evec,
Eigen::Vector3d const &  evals,
const OscParameters params 
) const
private

Definition at line 263 of file OscCalcPMNSOptEigen.cxx.

References FillCache(), osc::kKm2eV, osc::_OscParameters< T >::L, SetCachedEnergies(), and APDHVSetting::temp.

Referenced by FillCache(), and P().

266  {
267  const Eigen::Array3d temp = evals.array()*kKm2eV*(-1)*params.L;
268  //Eigen::Array3d temp(evals.array());
269 
270  //// propagation phase
271  //temp *= (-1) * kKm2eV * params.L; // NOTE
272  const Eigen::Array3d SIN = temp.sin();
273  const Eigen::Array3d COS = temp.cos();
274  Eigen::Vector3cd PPT;
275  PPT <<
276  //std::complex<double>(std::cos(temp[0]), std::sin(temp[0])),
277  //std::complex<double>(std::cos(temp[1]), std::sin(temp[1])),
278  //std::complex<double>(std::cos(temp[2]), std::sin(temp[2]));
279  std::complex<double>(COS[0], SIN[0]),
280  std::complex<double>(COS[1], SIN[1]),
281  std::complex<double>(COS[2], SIN[2]);
282 
283  // propagated
284  return evec * PPT.asDiagonal();
285  }
static const double kKm2eV
km to eV^-1
Definition: PMNSOpt.h:41
void osc::OscCalcPMNSOptEigen::SaveLastParams ( )
private

Definition at line 36 of file OscCalcPMNSOptEigen.cxx.

References osc::_sincos(), plot_validation_datamc::c, osc::_OscParameters< T >::deltacp, osc::_OscParameters< T >::dmsq21, osc::_OscParameters< T >::dmsq32, osc::_IOscCalcAdjustable< double >::fdCP, osc::_IOscCalcAdjustable< double >::fDmsq21, osc::_IOscCalcAdjustable< double >::fDmsq32, osc::_IOscCalcAdjustable< double >::fL, fLastParams, osc::_IOscCalcAdjustable< double >::fRho, osc::_IOscCalcAdjustable< double >::fTh12, osc::_IOscCalcAdjustable< double >::fTh13, osc::_IOscCalcAdjustable< double >::fTh23, osc::_OscParameters< T >::L, osc::_OscParameters< T >::rho, sincos(), osc::_OscParameters< T >::th12, osc::_OscParameters< T >::th13, osc::_OscParameters< T >::th23, and chisquared::theta.

37  {
38  fLastParams.L = fL;
46  }
void osc::OscCalcPMNSOptEigen::SetCachedEnergies ( std::vector< double > const &  energies)
private

Definition at line 297 of file OscCalcPMNSOptEigen.cxx.

References osc::_OscCache< T >::energies, and fCache.

Referenced by PropMatter().

298  {
299  this->fCache.energies = energies;
300  }
_OscCache< double > fCache
std::vector< double > energies
Definition: OscParameters.h:63
void osc::OscCalcPMNSOptEigen::SetdCP ( const double &  dCP)
inlineoverridevirtual

Implements osc::_IOscCalcAdjustable< double >.

Definition at line 100 of file OscCalcPMNSOptEigen.h.

References dCP.

void osc::OscCalcPMNSOptEigen::SetDmsq21 ( const double &  dmsq21)
inlineoverridevirtual
void osc::OscCalcPMNSOptEigen::SetDmsq32 ( const double &  dmsq32)
inlineoverridevirtual
void osc::OscCalcPMNSOptEigen::SetL ( double  L)
inlineoverridevirtual

Implements osc::_IOscCalcAdjustable< double >.

Definition at line 93 of file OscCalcPMNSOptEigen.h.

References CLHEP::L.

93 {SaveLastParams(); fL = L;}
static constexpr double L
void osc::OscCalcPMNSOptEigen::SetRho ( double  rho)
inlineoverridevirtual
void osc::OscCalcPMNSOptEigen::SetTh12 ( const double &  th12)
inlineoverridevirtual

Implements osc::_IOscCalcAdjustable< double >.

Definition at line 97 of file OscCalcPMNSOptEigen.h.

References th12.

void osc::OscCalcPMNSOptEigen::SetTh13 ( const double &  th13)
inlineoverridevirtual

Implements osc::_IOscCalcAdjustable< double >.

Definition at line 98 of file OscCalcPMNSOptEigen.h.

References th13.

void osc::OscCalcPMNSOptEigen::SetTh23 ( const double &  th23)
inlineoverridevirtual

Implements osc::_IOscCalcAdjustable< double >.

Definition at line 99 of file OscCalcPMNSOptEigen.h.

References th23.

EigenSystem osc::OscCalcPMNSOptEigen::Solve ( Eigen::Matrix3cd const &  ham) const
private

Definition at line 333 of file OscCalcPMNSOptEigen.cxx.

Referenced by FillCache(), and P().

334  {
335  Eigen::SelfAdjointEigenSolver<Eigen::Matrix3cd> eig;
336  eig.computeDirect(ham);
337  return EigenSystem{eig.eigenvectors(), eig.eigenvalues()};
338  }

Member Data Documentation

_OscCache<double> osc::OscCalcPMNSOptEigen::fCache
private

Definition at line 107 of file OscCalcPMNSOptEigen.h.

Referenced by Copy(), FillCache(), P(), ParamsAreCached(), and SetCachedEnergies().

double osc::_IOscCalcAdjustable< double >::fdCP
protectedinherited
double osc::_IOscCalcAdjustable< double >::fDmsq21
protectedinherited
double osc::_IOscCalcAdjustable< double >::fDmsq32
protectedinherited
double osc::_IOscCalcAdjustable< double >::fL
protectedinherited
OscParameters osc::OscCalcPMNSOptEigen::fLastParams
private

Definition at line 166 of file OscCalcPMNSOptEigen.h.

Referenced by SaveLastParams().

double osc::_IOscCalcAdjustable< double >::fRho
protectedinherited
double osc::_IOscCalcAdjustable< double >::fTh12
protectedinherited
double osc::_IOscCalcAdjustable< double >::fTh13
protectedinherited
double osc::_IOscCalcAdjustable< double >::fTh23
protectedinherited
std::string osc::OscCalcPMNSOptEigen::name = "OscCalcPMNSOptEigen"
private

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