Public Member Functions | Private Member Functions | Private Attributes | List of all members
genie::flux::GFlavorMap Class Reference

GENIE interface for flavor modification. More...

#include "/cvmfs/nova.opensciencegrid.org/externals/genie/v3_00_06_p01/Linux64bit+2.6-2.12-e17-debug/GENIE-Generator/src/Tools/Flux/GFlavorMap.h"

Inheritance diagram for genie::flux::GFlavorMap:
genie::flux::GFlavorMixerI

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...
 

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

2010-10-31

Version
Id
GFlavorMap.h,v 1.1.1.1 2010/12/22 16:18:52 p-nusoftart Exp

Definition at line 46 of file GFlavorMap.h.

Constructor & Destructor Documentation

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

Definition at line 32 of file GFlavorMap.cxx.

References fProb.

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

Definition at line 43 of file GFlavorMap.cxx.

43 { ; }

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 46 of file GFlavorMap.cxx.

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

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

Definition at line 112 of file GFlavorMap.h.

Referenced by PrintConfig().

113 {
114  switch ( indx ) {
115  case 1: return 12; break;
116  case 2: return 14; break;
117  case 3: return 16; break;
118  case 4: return -12; break;
119  case 5: return -14; break;
120  case 6: return -16; break;
121  default: return 0; break;
122  }
123  return 0;
124 }
const char * genie::flux::GFlavorMap::IndxName ( int  indx)
private

Definition at line 181 of file GFlavorMap.cxx.

Referenced by NuName(), and PrintConfig().

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

Definition at line 80 of file GFlavorMap.h.

References IndxName(), and PDG2Indx().

void genie::flux::GFlavorMap::ParseFixedfracString ( std::string  config)
private

Definition at line 100 of file GFlavorMap.cxx.

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

Referenced by Config().

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

Definition at line 70 of file GFlavorMap.cxx.

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

Referenced by Config().

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

Definition at line 99 of file GFlavorMap.h.

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

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

provide a means of printing the configuration

Implements genie::flux::GFlavorMixerI.

Definition at line 155 of file GFlavorMap.cxx.

References om::cout, allTimeWatchdog::endl, fProb, Indx2PDG(), IndxName(), LOG_BEGIN, LOG_END, and pINFO.

156 {
157  size_t jin, jout;
158  LOG_BEGIN("FluxBlender", pINFO)
159  << "GFlavorMap::PrintConfig():" << LOG_END;
160 
161  // 1234567890[xxx]:
162  std::cout << " in \\ out ";
163  for (jout=0; jout<7; ++jout )
164  std::cout << " " << std::setw(3) << Indx2PDG(jout) << " ";
165  std::cout << std::endl;
166 
167  std::cout << "----------------+";
168  for (jout=0; jout<7; ++jout ) std::cout << "----------";
169  std::cout << std::endl;
170 
171  for (jin=0; jin<7; ++jin) {
172  std::cout << std::setw(10) << IndxName(jin)
173  << "[" << std::setw(3) << Indx2PDG(jin) << "] | ";
174  for (jout=0; jout<7; ++jout )
175  std::cout << std::setw(8) << fProb[jin][jout] << " ";
176  std::cout << std::endl;
177  }
178 
179 }
#define LOG_END
Definition: GFlavorMap.cxx:24
#define LOG_BEGIN(a, b)
Definition: GFlavorMap.cxx:23
const char * IndxName(int indx)
Definition: GFlavorMap.cxx:181
#define pINFO
Definition: Messenger.h:63
double fProb[7][7]
Definition: GFlavorMap.h:82
OStream cout
Definition: OStream.cxx:6
int Indx2PDG(int indx)
Definition: GFlavorMap.h:112
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 142 of file GFlavorMap.cxx.

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

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

Member Data Documentation

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

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