OscCalcSterileBeam.cxx
Go to the documentation of this file.
3 
4 #include <cassert>
5 #include <cstdlib>
6 #include <iostream>
7 #include <iomanip>
8 #include <typeinfo>
9 
10 namespace osc
11 {
13  : OscCalcSterile(),
14  fKaonscale(0), fPionscale(0), fMuonscale(0)
15  {
16  //fPMNS_Sterile = new PMNS_Sterile(fNFlavors);
17  }
18 
19  //---------------------------------------------------------------------------
21  {
22  std::cout << " ** OscCalcSterileBeam Destructor is called ** \n";
23  }
24 
25  //---------------------------------------------------------------------------
27  : OscCalcSterile(calc)
28  {
29  std::cout << "copy constructor\n";
30  this->fKaonscale = calc.GetKaonScale();
31  this->fMuonscale = calc.GetMuonScale();
32  this->fPionscale = calc.GetPionScale();
33  }
34 
35  //---------------------------------------------------------------------------
37  {
39  //assert(fKaonscale!=0.0);
40  }
41 
42  //---------------------------------------------------------------------------
44  {
46  //assert(fPionscale!=0.0);
47  }
48 
49  //---------------------------------------------------------------------------
51  {
53  //assert(fMuonscale!=0.0);
54  }
55 
56  //---------------------------------------------------------------------------
58  {
59  return fKaonscale;
60  }
61 
62  //---------------------------------------------------------------------------
64  {
65  return fPionscale;
66  }
67 
68  //---------------------------------------------------------------------------
70  {
71  return fMuonscale;
72  }
73 
74  //---------------------------------------------------------------------------
76  {
77  std::cout << " *** OscCalSterileBeam Copy() is called *** " << std::endl;
78  return new OscCalcSterileBeam(*this);
79  }
80 
81  //---------------------------------------------------------------------------
83  {
84  TMD5* ret = new TMD5;
85  std::string txt = "SterileBeam";
86  ret->Update((unsigned char*)txt.c_str(), txt.size());
87  std::vector<double> buf;
88  buf.push_back(fL);
89  buf.push_back(fRho);
90  buf.push_back(fKaonscale);
91  buf.push_back(fPionscale);
92  buf.push_back(fMuonscale);
93  for(int i = 2; i <= fNFlavors; ++i) buf.push_back(GetDm(i));
94  for(int j = 2; j <= fNFlavors; ++j) {
95  for(int i = 1; i < j; ++i) {
96  buf.push_back(GetAngle(i, j));
97  if(i+1 != j) buf.push_back(GetDelta(i, j));
98  }
99  }
100  ret->Update((unsigned char*)&buf[0], sizeof(double)*buf.size());
101  ret->Final();
102  return ret;
103  }
104  //---------------------------------------------------------------------------
105  /* virtual void OscCalcSterileBeam::SetBeamMode(kBeamMode, double scaleK, double scaleP, double scaleM)
106  {
107  if(kBeamMode=="Kaon") {
108  OscCalcSterileBeam::SetKaonScale(scaleK) ;
109  OscCalcSterileBeam::SetPionScale(1.0) ;
110  OscCalcSterileBeam::SetMuonScale(1.0) ; }
111  else if(kBeamMode=="Pion") {
112  OscCalcSterileBeam::SetKaonScale(1.0) ;
113  OscCalcSterileBeam::SetPionScale(scaleP);
114  OscCalcSterileBeam::SetMuonScale(1.0) ; }
115  else if(kBeamMode=="Muon") {
116  OscCalcSterileBeam::SetKaonScale(1.0) ;
117  OscCalcSterileBeam::SetPionScale(1.0) ;
118  OscCalcSterileBeam::SetMuonScale(scaleM); }
119  else {
120  OscCalcSterileBeam::SetKaonScale(1.0) ;
121  OscCalcSterileBeam::SetKaonScale(1.0) ;
122  OscCalcSterileBeam::SetKaonScale(1.0) ; }
123  }
124 
125  //---------------------------------------------------------------------------
126  virtual double OscCalcSterileBeam::P(int flavBefore, int flavAfter, double E)
127  {
128  double origProb = OscCalcSterile::P(int flavBefore, int flavAfter, double E);
129  double scale = 0.0;
130  double prob=0.0;
131  if(kBeamMode=="Kaon" || kBeamMode=="Pion" || kBeamMode=="Muon") {
132  scale = OscCalcSterileBeam::GetKaonScale() *
133  OscCalcSterileBeam::GetPionScale() *
134  OscCalcSterileBeam::GetMuonScale() ;
135  prob=origProb*scale;
136  }
137  return prob;
138  }
139  */
140  //---------------------------------------------------------------------------
142  {
143  //const IOscCalc* base = new osc::OscCalcSterileBeam();
144  const OscCalcSterileBeam* calc_sterile = dynamic_cast<const OscCalcSterileBeam*>(calc);
145  if(calc_sterile) return calc_sterile;
146  else std::cout << "Input calculator was not of type OscCalcSterileBeam." << std::endl;
147  return nullptr; // If the cast failed, calc_sterile should be nullptr anyway
148  }
149 
150  //---------------------------------------------------------------------------
152  {
153  //IOscCalc* base = new osc::OscCalcSterileBeam();
154  //std::cout << "calc's type is: " << typeid(calc).name() << std::endl;
155  //if (typeid(calc) == typeid(osc::NoOscillations))
156  // {
157  /// std::cout << "calc is a osc::NoOscillations calculator!" << std::endl;
158  //}
159  NoOscillations* calc_noosc = dynamic_cast<NoOscillations*>(calc);
160  if (calc_noosc)
161  {
162  std::cout << "I was successfully cast to NoOscillations" << std::endl;
163  }
164 
165  OscCalcSterileBeam* calc_sterile = dynamic_cast<OscCalcSterileBeam*>(calc);
166  if(calc_sterile) return calc_sterile;
167  else std::cout << "Input calculator was not of type OscCalcSterileBeam." << std::endl;
168  return nullptr; // If the cast failed, calc_sterile should be nullptr anyway
169  }
170 } // namespace
virtual void SetPionScale(double scale)
Pass neutrinos through unchanged.
Definition: IOscCalc.h:40
double GetDelta(int i, int j) const
virtual TMD5 * GetParamsHash() const override
Use to check two calculators are in the same state.
Adapt the PMNS_Sterile calculator to standard interface.
General interface to oscillation calculators.
Definition: StanTypedefs.h:22
virtual IOscCalcAdjustable * Copy() const override
Adapt the PMNS_Sterile calculator to standard interface.
virtual void SetMuonScale(double scale)
osc::OscCalcDumb calc
Double_t scale
Definition: plot.C:25
const double j
Definition: BetheBloch.cxx:29
const OscCalcSterileBeam * DowncastToSterileBeam(const IOscCalc *calc)
Oscillation probability calculators.
Definition: Calcs.h:5
OStream cout
Definition: OStream.cxx:6
virtual void SetKaonScale(double scale)
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
double GetDm(int i) const
double GetAngle(int i, int j) const