GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
genie::flux::GFlavorMap Class Reference

GENIE interface for flavor modification. More...

#include <GFlavorMap.h>

Inheritance diagram for genie::flux::GFlavorMap:
Inheritance graph
[legend]
Collaboration diagram for genie::flux::GFlavorMap:
Collaboration graph
[legend]

Public Member Functions

 GFlavorMap ()
 
 ~GFlavorMap ()
 
void Config (std::string config)
 
double Probability (int pdg_initial, int pdg_final, double energy, double dist)
 
void PrintConfig (bool verbose=true)
 provide a means of printing the configuration More...
 
- Public Member Functions inherited from genie::flux::GFlavorMixerI
 GFlavorMixerI ()
 
virtual ~GFlavorMixerI ()
 

Private Member Functions

void ParseMapString (std::string config)
 
void ParseFixedfracString (std::string config)
 
int PDG2Indx (int pdg)
 
int Indx2PDG (int indx)
 
const char * IndxName (int indx)
 
const char * NuName (int pdg)
 

Private Attributes

double fProb [7][7]
 

Detailed Description

GENIE interface for flavor modification.

     Concrete instance of GFlavorMixerI that maps from
     one flavor to another independent of energy or distance.
     Users specify the transition probability from one flavor
     to any of the PDG codes { 0, 12, 14, 16, -12, -14, -16 }
     where 0 represents the complete disappearance (decay, sterile, ...).

     Probability is expected to be normalized (that is, the sum
     of all possible outcomes, including 0, must be 1).

     Supported config string formats:
     1)  " swap pdg1:pdg2  pdg3:pdg4 "
         Map all neutrinos of flavor "pdg1" to "pdg2",  "pdg3" to "pdg4"
         Use PDG values { 0, 12, 14, 16, -12, -14, -16 }
           for { sterile, nu_e, nu_mu, nu_tau, nu_e_bar, ...}
         Unnamed initial flavors are left unmodified.
         Use numeric values with spaces only between pairs.
         Must start with the literal "swap"
         (FMWK note:  param must be surrounded by explicit "'s)
     2)  " fixedfrac {pdg1:f0,f12,f14,f16,f-12,f-14,f-16} ..."
         For each group delineated by {}'s the map the "pdg1"
         by each pdg by the fraction given [0-1, sum=1].
         So {12:0.5,0.5,0,0,0,0,0} means nu_e => 50/50% nu_e/nu_mu.
         Each list *must* have an int + 7 fractions.
Author
Robert Hatcher <rhatcher fnal.gov> Fermi National Accelerator Laboratory
Created:
2010-10-31
License:
Copyright (c) 2003-2024, The GENIE Collaboration for the full text of the license visit http://copyright.genie-mc.org

Definition at line 51 of file GFlavorMap.h.

Constructor & Destructor Documentation

genie::flux::GFlavorMap::GFlavorMap ( )

Definition at line 31 of file GFlavorMap.cxx.

References fProb.

32 {
33  // Initialize with identity matrix
34  size_t jin, jout;
35  for (jin=0; jin<7; ++jin) {
36  for (jout=0; jout<7; ++jout ) {
37  fProb[jin][jout] = ( (jin==jout) ? 1. : 0. );
38  }
39  }
40 }
double fProb[7][7]
Definition: GFlavorMap.h:87
genie::flux::GFlavorMap::~GFlavorMap ( )

Definition at line 42 of file GFlavorMap.cxx.

42 { ; }

Member Function Documentation

void genie::flux::GFlavorMap::Config ( std::string  config)
virtual

each schema must take a string that configures it it is up to the individual model to parse said string and extract parameters (e.g. sin2th23, deltam12, etc)

Implements genie::flux::GFlavorMixerI.

Definition at line 45 of file GFlavorMap.cxx.

References LOG_BEGIN, LOG_END, ParseFixedfracString(), ParseMapString(), pINFO, pWARN, and genie::utils::str::TrimSpaces().

46 {
47  std::string config = genie::utils::str::TrimSpaces(configIn);
48  LOG_BEGIN("FluxBlender", pINFO)
49  << "GFlavorMap::Config \"" << config << "\"" << LOG_END;
50 
51  if ( config.find("swap") == 0 ||
52  config.find("map") == 0 ||
53  config.find("genie::flux::GFlavorMap") == 0 ) {
54  ParseMapString(config);
55  } else if ( config.find("fixedfrac") == 0 ) {
56  ParseFixedfracString(config);
57  } else {
58  LOG_BEGIN("FluxBlender", pWARN)
59  << "GFlavorMap::Config don't know how to parse \""
60  << config << "\"" << LOG_END;
61  LOG_BEGIN("FluxBlender", pWARN)
62  << " ... will attempt \"map\" strategy" << LOG_END;
63 
64  }
65 
66 }
#define LOG_END
Definition: GFlavorMap.cxx:23
#define LOG_BEGIN(a, b)
Definition: GFlavorMap.cxx:22
void ParseMapString(std::string config)
Definition: GFlavorMap.cxx:69
#define pINFO
Definition: Messenger.h:62
#define pWARN
Definition: Messenger.h:60
string TrimSpaces(string input)
Definition: StringUtils.cxx:18
void ParseFixedfracString(std::string config)
Definition: GFlavorMap.cxx:99
int genie::flux::GFlavorMap::Indx2PDG ( int  indx)
inlineprivate

Definition at line 117 of file GFlavorMap.h.

Referenced by PrintConfig().

118 {
119  switch ( indx ) {
120  case 1: return 12; break;
121  case 2: return 14; break;
122  case 3: return 16; break;
123  case 4: return -12; break;
124  case 5: return -14; break;
125  case 6: return -16; break;
126  default: return 0; break;
127  }
128  return 0;
129 }
const char * genie::flux::GFlavorMap::IndxName ( int  indx)
private

Definition at line 180 of file GFlavorMap.cxx.

Referenced by NuName(), and PrintConfig().

181 {
182  static const char* name[] = { "sterile",
183  "nu_e", "nu_mu", "nu_tau",
184  "nu_e_bar", "nu_mu_bar", "nu_tau_bar" };
185  return name[indx];
186 
187 }
const char * name
const char* genie::flux::GFlavorMap::NuName ( int  pdg)
inlineprivate

Definition at line 85 of file GFlavorMap.h.

References IndxName(), and PDG2Indx().

85 { return IndxName(PDG2Indx(pdg)); }
int PDG2Indx(int pdg)
Definition: GFlavorMap.h:104
const char * IndxName(int indx)
Definition: GFlavorMap.cxx:180
void genie::flux::GFlavorMap::ParseFixedfracString ( std::string  config)
private

Definition at line 99 of file GFlavorMap.cxx.

References fProb, LOG_BEGIN, LOG_END, PDG2Indx(), pINFO, pWARN, genie::utils::str::Split(), and genie::utils::str::TrimSpaces().

Referenced by Config().

100 {
101  LOG_BEGIN("FluxBlender", pINFO)
102  << "GFlavorMap::ParseFixedFracString \"" << config << "\"" << LOG_END;
103  vector<string> tokens = genie::utils::str::Split(config,"{}");
104  for (unsigned int jtok = 0; jtok< tokens.size(); ++jtok ) {
105  string tok1 = genie::utils::str::TrimSpaces(tokens[jtok]);
106  if ( tok1 == "" ) continue;
107  if ( tok1 == "fixedfrac" ) continue;
108  // should have the form pdg:f0,f12,f14,f16,f-12,f-14,f-16
109  vector<string> pair = genie::utils::str::Split(tok1,":");
110  if ( pair.size() != 2 ) {
111  LOG_BEGIN("FluxBlender", pWARN)
112  << "could not parse \"" << tok1 << "\" split size=" << pair.size()
113  << LOG_END;
114  continue;
115  }
116  int pdg_in = strtol(pair[0].c_str(),NULL,0);
117  int indx_in = PDG2Indx(pdg_in);
118  vector<string> fracs = genie::utils::str::Split(pair[1],",");
119  if ( fracs.size() != 7 ) {
120  LOG_BEGIN("FluxBlender", pWARN)
121  << "could not parse frac list \"" << pair[1] << "\" split size=" << fracs.size()
122  << LOG_END;
123  continue;
124  }
125  // set each value
126  double psum = 0;
127  for (int indx_out = 0; indx_out < 7; ++indx_out ) {
128  double p = strtod(fracs[indx_out].c_str(),NULL);
129  psum += p;
130  fProb[indx_in][indx_out] = p;
131  }
132  if ( psum > 0 ) {
133  // normalize to 1.0
134  for (int indx_out = 0; indx_out < 7; ++indx_out )
135  fProb[indx_in][indx_out] /= psum;
136  }
137  }
138 }
int PDG2Indx(int pdg)
Definition: GFlavorMap.h:104
#define LOG_END
Definition: GFlavorMap.cxx:23
#define LOG_BEGIN(a, b)
Definition: GFlavorMap.cxx:22
#define pINFO
Definition: Messenger.h:62
double fProb[7][7]
Definition: GFlavorMap.h:87
#define pWARN
Definition: Messenger.h:60
string TrimSpaces(string input)
Definition: StringUtils.cxx:18
vector< string > Split(string input, string delim)
Definition: StringUtils.cxx:36
void genie::flux::GFlavorMap::ParseMapString ( std::string  config)
private

Definition at line 69 of file GFlavorMap.cxx.

References fProb, LOG_BEGIN, LOG_END, PDG2Indx(), pINFO, pWARN, and genie::utils::str::Split().

Referenced by Config().

70 {
71  LOG_BEGIN("FluxBlender", pINFO)
72  << "GFlavorMap::ParseMapString \"" << config << "\"" << LOG_END;
73  vector<string> tokens = genie::utils::str::Split(config," ");
74  for (unsigned int jtok = 0; jtok < tokens.size(); ++jtok ) {
75  string tok1 = tokens[jtok];
76  if ( tok1 == "" ) continue;
77  if ( tok1 == "swap" || tok1 == "map" ) continue;
78  if ( tok1 == "genie::flux::GFlavorMap" ) continue;
79  // should have the form <int>:<int>
80  vector<string> pair = genie::utils::str::Split(tok1,":");
81  if ( pair.size() != 2 ) {
82  LOG_BEGIN("FluxBlender", pWARN)
83  << "could not parse " << tok1 << " split size=" << pair.size()
84  << LOG_END;
85  continue;
86  }
87  int pdg_in = strtol(pair[0].c_str(),NULL,0);
88  int indx_in = PDG2Indx(pdg_in);
89  int pdg_out = strtol(pair[1].c_str(),NULL,0);
90  int indx_out = PDG2Indx(pdg_out);
91  for (int jout = 0; jout < 7; ++jout ) {
92  fProb[indx_in][jout] = ( ( jout == indx_out ) ? 1 : 0 );
93  }
94 
95  }
96 }
int PDG2Indx(int pdg)
Definition: GFlavorMap.h:104
#define LOG_END
Definition: GFlavorMap.cxx:23
#define LOG_BEGIN(a, b)
Definition: GFlavorMap.cxx:22
#define pINFO
Definition: Messenger.h:62
double fProb[7][7]
Definition: GFlavorMap.h:87
#define pWARN
Definition: Messenger.h:60
vector< string > Split(string input, string delim)
Definition: StringUtils.cxx:36
int genie::flux::GFlavorMap::PDG2Indx ( int  pdg)
inlineprivate

Definition at line 104 of file GFlavorMap.h.

Referenced by NuName(), ParseFixedfracString(), ParseMapString(), and Probability().

105 {
106  switch ( pdg ) {
107  case 12: return 1; break;
108  case 14: return 2; break;
109  case 16: return 3; break;
110  case -12: return 4; break;
111  case -14: return 5; break;
112  case -16: return 6; break;
113  default: return 0; break;
114  }
115  return 0;
116 }
void genie::flux::GFlavorMap::PrintConfig ( bool  verbose = true)
virtual

provide a means of printing the configuration

Implements genie::flux::GFlavorMixerI.

Definition at line 154 of file GFlavorMap.cxx.

References fProb, Indx2PDG(), IndxName(), LOG_BEGIN, LOG_END, and pINFO.

155 {
156  size_t jin, jout;
157  LOG_BEGIN("FluxBlender", pINFO)
158  << "GFlavorMap::PrintConfig():" << LOG_END;
159 
160  // 1234567890[xxx]:
161  std::cout << " in \\ out ";
162  for (jout=0; jout<7; ++jout )
163  std::cout << " " << std::setw(3) << Indx2PDG(jout) << " ";
164  std::cout << std::endl;
165 
166  std::cout << "----------------+";
167  for (jout=0; jout<7; ++jout ) std::cout << "----------";
168  std::cout << std::endl;
169 
170  for (jin=0; jin<7; ++jin) {
171  std::cout << std::setw(10) << IndxName(jin)
172  << "[" << std::setw(3) << Indx2PDG(jin) << "] | ";
173  for (jout=0; jout<7; ++jout )
174  std::cout << std::setw(8) << fProb[jin][jout] << " ";
175  std::cout << std::endl;
176  }
177 
178 }
#define LOG_END
Definition: GFlavorMap.cxx:23
#define LOG_BEGIN(a, b)
Definition: GFlavorMap.cxx:22
const char * IndxName(int indx)
Definition: GFlavorMap.cxx:180
#define pINFO
Definition: Messenger.h:62
double fProb[7][7]
Definition: GFlavorMap.h:87
int Indx2PDG(int indx)
Definition: GFlavorMap.h:117
double genie::flux::GFlavorMap::Probability ( int  pdg_initial,
int  pdg_final,
double  energy,
double  dist 
)
virtual

for any pair of PDG codes the model must calculate the transition probability. This can also depend on neutrino energy (in GeV) and distance (in meters) from the neutrino origin.

Implements genie::flux::GFlavorMixerI.

Definition at line 141 of file GFlavorMap.cxx.

References fProb, LOG_BEGIN, LOG_END, PDG2Indx(), and pINFO.

143 {
144  double prob = fProb[PDG2Indx(pdg_initial)][PDG2Indx(pdg_final)];
145  if ( false ) {
146  LOG_BEGIN("FluxBlender", pINFO)
147  << "Probability " << pdg_initial << "=>" << pdg_final
148  << " = " << prob << LOG_END;
149  }
150  return prob;
151 }
int PDG2Indx(int pdg)
Definition: GFlavorMap.h:104
#define LOG_END
Definition: GFlavorMap.cxx:23
#define LOG_BEGIN(a, b)
Definition: GFlavorMap.cxx:22
#define pINFO
Definition: Messenger.h:62
double fProb[7][7]
Definition: GFlavorMap.h:87

Member Data Documentation

double genie::flux::GFlavorMap::fProb[7][7]
private

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