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

List of cross section vs energy splines. More...

#include <XSecSplineList.h>

Collaboration diagram for genie::XSecSplineList:
Collaboration graph
[legend]

Classes

struct  Cleaner
 

Public Member Functions

void SaveAsXml (const string &filename, bool save_init=true) const
 
XmlParserStatus_t LoadFromXml (const string &filename, bool keep=false)
 
void Print (ostream &stream) const
 
void SetCurrentTune (const string &tune)
 
string CurrentTune (void) const
 
bool HasSplineFromTune (const string &tune) const
 
bool SplineExists (const XSecAlgorithmI *alg, const Interaction *i) const
 
bool SplineExists (string spline_key) const
 
const SplineGetSpline (const XSecAlgorithmI *alg, const Interaction *i) const
 
const SplineGetSpline (string spline_key) const
 
void CreateSpline (const XSecAlgorithmI *alg, const Interaction *i, int nknots=-1, double e_min=-1, double e_max=-1)
 
int NSplines (void) const
 
bool IsEmpty (void) const
 
string BuildSplineKey (const XSecAlgorithmI *alg, const Interaction *i) const
 
const vector< string > * GetSplineKeys (void) const
 
void SetLogE (bool on)
 set opt to build splines as f(E) or as f(logE) More...
 
void SetNKnots (int nk)
 set default number of knots for building the spline More...
 
void SetMinE (double Ev)
 set default minimum energy for xsec splines More...
 
void SetMaxE (double Ev)
 set default maximum energy for xsec splines More...
 
bool UseLogE (void) const
 
int NKnots (void) const
 
double Emin (void) const
 
double Emax (void) const
 

Static Public Member Functions

static XSecSplineListInstance ()
 

Private Member Functions

 XSecSplineList ()
 
 XSecSplineList (const XSecSplineList &spline_list)
 
virtual ~XSecSplineList ()
 

Private Attributes

bool fUseLogE
 
int fNKnots
 
double fEmin
 
double fEmax
 
string fCurrentTune
 The `active' tune, out the many that can co-exist. More...
 
map< string, map< string,
Spline * > > 
fSplineMap
 tune -> { xsec_alg/xsec_config/interaction -> Spline } More...
 
map< string, set< string > > fLoadedSplineSet
 tune -> { set of initialy loaded splines } More...
 

Static Private Attributes

static XSecSplineListfInstance = 0
 

Friends

struct Cleaner
 
ostream & operator<< (ostream &stream, const XSecSplineList &xsl)
 

Detailed Description

List of cross section vs energy splines.

Author
Costas Andreopoulos <c.andreopoulos cern.ch> University of Liverpool
Created:
May 12, 2005
License:
Copyright (c) 2003-2024, The GENIE Collaboration For the full text of the license visit http://copyright.genie-mc.org

Definition at line 45 of file XSecSplineList.h.

Constructor & Destructor Documentation

genie::XSecSplineList::XSecSplineList ( )
private

Definition at line 52 of file XSecSplineList.cxx.

53 {
54  fInstance = 0;
55  fCurrentTune = "";
56  fUseLogE = true;
57  fNKnots = 100;
58  fEmin = 0.01; // GeV
59  fEmax = 100.00; // GeV
60 }
string fCurrentTune
The `active&#39; tune, out the many that can co-exist.
static XSecSplineList * fInstance
genie::XSecSplineList::XSecSplineList ( const XSecSplineList spline_list)
private
genie::XSecSplineList::~XSecSplineList ( )
privatevirtual

Definition at line 62 of file XSecSplineList.cxx.

63 {
64 // Clean up.
65 
66  map<string, map<string, Spline *> >::iterator mm_iter = fSplineMap.begin();
67  for( ; mm_iter != fSplineMap.end(); ++mm_iter) {
68  // loop over splines for given tune
69  map<string, Spline *> & spl_map_curr_tune = mm_iter->second;
70  map<string, Spline *>::iterator m_iter = spl_map_curr_tune.begin();
71  for( ; m_iter != spl_map_curr_tune.end(); ++m_iter) {
72  Spline * spline = m_iter->second;
73  delete spline;
74  spline = 0;
75  }
76  spl_map_curr_tune.clear();
77  }
78  fSplineMap.clear();
79  fInstance = 0;
80 }
map< string, map< string, Spline * > > fSplineMap
tune -&gt; { xsec_alg/xsec_config/interaction -&gt; Spline }
static XSecSplineList * fInstance

Member Function Documentation

string genie::XSecSplineList::BuildSplineKey ( const XSecAlgorithmI alg,
const Interaction i 
) const

Definition at line 539 of file XSecSplineList.cxx.

References genie::Interaction::AsString(), genie::AlgId::Config(), genie::Algorithm::Id(), LOG, genie::AlgId::Name(), and pWARN.

541 {
542  if(!alg) {
543  LOG("XSecSplLst", pWARN)
544  << "Null XSecAlgorithmI - Returning empty spline key";
545  return "";
546  }
547 
548  if(!interaction) {
549  LOG("XSecSplLst", pWARN)
550  << "Null Interaction - Returning empty spline key";
551  return "";
552  }
553 
554  string alg_name = alg->Id().Name();
555  string param_set = alg->Id().Config();
556  string intkey = interaction->AsString();
557 
558  string key = alg_name + "/" + param_set + "/" + intkey;
559 
560  return key;
561 }
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
#define pWARN
Definition: Messenger.h:60
void genie::XSecSplineList::CreateSpline ( const XSecAlgorithmI alg,
const Interaction i,
int  nknots = -1,
double  e_min = -1,
double  e_max = -1 
)

Definition at line 160 of file XSecSplineList.cxx.

References genie::units::cm2, genie::Interaction::InitStatePtr(), genie::XSecAlgorithmI::Integral(), pFATAL, genie::Interaction::PhaseSpace(), pNOTICE, genie::InitialState::Probe(), pWARN, genie::InitialState::SetProbeP4(), SLOG, and genie::KPhaseSpace::Threshold().

Referenced by genie::GEVGDriver::CreateSplines().

162 {
163 // Build a cross section spline for the input interaction using the input
164 // cross section algorithm and store in the list.
165 // For building this specific entry of the spline list, the user is allowed
166 // to override the list-wide nknots,e_min,e_max
167 
168  // FE_ALL_EXCEPT FE_INEXACT FE_UNDERFLOW
169  // FE_DIVBYZERO FE_INVALID FE_OVERFLO
170  // rwh -- uncomment to catch NaN
171  // feenableexcept(FE_DIVBYZERO|FE_INVALID|FE_OVERFLOW);
172 
173 
174  SLOG("XSecSplLst", pNOTICE)
175  << "Creating cross section spline using the algorithm: " << *alg;
176 
177  string key = this->BuildSplineKey(alg,interaction);
178 
179  // If any of the nknots,e_min,e_max was not set or its value is not acceptable
180  // use the list values
181  //
182  if (e_min < 0.) e_min = this->Emin();
183  if (e_max < 0.) e_max = this->Emax();
184  if (nknots <= 2) nknots = this->NKnots();
185  assert( e_min < e_max );
186 
187  std::vector<double> xsec( nknots, 0. ) ;
188  std::vector<double> E( nknots, 0. ) ;
189 
190  // Distribute the knots in the energy range (e_min,e_max) :
191  // - Will use 5 knots linearly spaced below the energy thresholds so that the
192  // spline behaves correctly in (e_min,Ethr)
193  // - Place 1 knot exactly on the input interaction threshold
194  // - Place the remaining n-6 knots spaced either linearly or logarithmically
195  // above the input interaction threshold
196  // The above scheme schanges appropriately if Ethr<e_min (i.e. no knots
197  // are computed below threshold)
198  //
199  double Ethr = interaction->PhaseSpace().Threshold();
200  SLOG("XSecSplLst", pNOTICE)
201  << "Energy threshold for current interaction = " << Ethr << " GeV";
202 
203  if (Ethr>e_max) {
204  SLOG("XSecSplLst", pFATAL) << "Energy threshold higher than maximum.";
205  SLOG("XSecSplLst", pFATAL) << "Energy threshold = " << Ethr << " GeV";
206  SLOG("XSecSplLst", pFATAL) << "Energy maximum = " << e_max << " GeV";
207  return;
208  }
209 
210  int nkb = (Ethr>e_min) ? 5 : 0; // number of knots < threshold
211  int nka = nknots-nkb; // number of knots >= threshold
212 
213  // knots < energy threshold
214  double dEb = (Ethr>e_min) ? (Ethr - e_min) / nkb : 0;
215  for(int i=0; i<nkb; i++) {
216  E[i] = e_min + i*dEb;
217  }
218  // knots >= energy threshold
219  double E0 = TMath::Max(Ethr,e_min);
220  double dEa = 0;
221  if(this->UseLogE())
222  dEa = (TMath::Log10(e_max) - TMath::Log10(E0)) /(nka-1);
223  else
224  dEa = (e_max-E0) /(nka-1);
225 
226  for(int i=0; i<nka; i++) {
227  if(this->UseLogE())
228  E[i+nkb] = TMath::Power(10., TMath::Log10(E0) + i * dEa);
229  else
230  E[i+nkb] = E0 + i * dEa;
231  }
232  // force last point to avoid floating point cumulative slew
233  E[nknots-1] = e_max;
234 
235  // Compute cross sections for the input interaction at the selected
236  // set of energies
237  //
238  double pr_mass = interaction->InitStatePtr()->Probe()->Mass();
239  for (int i = 0; i < nknots; i++) {
240  TLorentzVector p4(0,0,E[i],E[i]);
241  if (pr_mass > 0.) {
242  double pz = TMath::Max(0.,E[i]*E[i] - pr_mass*pr_mass);
243  pz = TMath::Sqrt(pz);
244  p4.SetPz(pz);
245  }
246  interaction->InitStatePtr()->SetProbeP4(p4);
247 
248  steady_clock::time_point start = steady_clock::now();
249 
250  xsec[i] = alg->Integral(interaction);
251 
252  steady_clock::time_point end = steady_clock::now();
253 
254  duration<double> time_span = duration_cast<duration<double>>(end - start);
255 
256  SLOG("XSecSplLst", pNOTICE)
257  << "xsec(E = " << E[i] << ") = "
258  << (1E+38/units::cm2)*xsec[i] << " x 1E-38 cm^2, evaluated in " << time_span.count() << " s";
259  if ( std::isnan(xsec[i]) ) {
260  // this sometimes happens near threshold, warn and move on
261  SLOG("XSecSplLst", pWARN)
262  << "xsec(E = " << E[i] << ") = "
263  << (1E+38/units::cm2)*xsec[i] << " x 1E-38 cm^2"
264  << " : converting NaN to 0.0";
265  xsec[i] = 0.0;
266  }
267 
268  }
269 
270  // Warn about odd case of decreasing cross section
271  // but allow for small variation due to integration errors
272  const double eps_xsec = 1.0e-5;
273  const double xsec_scale = (1.0-eps_xsec);
274  if ( xsec[nknots-1] < xsec[nknots-2]*xsec_scale ) {
275  SLOG("XSecSplLst", pWARN)
276  << "Last point oddity: " << key << " has "
277  << " xsec[nknots-1] " << xsec[nknots-1] << " < "
278  << " xsec[nknots-2] " << xsec[nknots-2];
279  }
280 
281  // Build
282  //
283  Spline * spline = new Spline(nknots, E.data(), xsec.data());
284 
285  // Save
286  //
287  map<string, map<string, Spline *> >::iterator //\/
288  mm_iter = fSplineMap.find(fCurrentTune);
289  if(mm_iter == fSplineMap.end()) {
290  map<string, Spline *> spl_map_curr_tune;
291  fSplineMap.insert( map<string, map<string, Spline *> >::value_type(
292  fCurrentTune, spl_map_curr_tune) );
293  mm_iter = fSplineMap.find(fCurrentTune);
294  }
295  map<string, Spline *> & spl_map_curr_tune = mm_iter->second;
296  spl_map_curr_tune.insert( map<string, Spline *>::value_type(key, spline) );
297 }
string BuildSplineKey(const XSecAlgorithmI *alg, const Interaction *i) const
bool UseLogE(void) const
#define pFATAL
Definition: Messenger.h:56
double Emin(void) const
static constexpr double cm2
Definition: Units.h:69
map< string, map< string, Spline * > > fSplineMap
tune -&gt; { xsec_alg/xsec_config/interaction -&gt; Spline }
int NKnots(void) const
string fCurrentTune
The `active&#39; tune, out the many that can co-exist.
#define pWARN
Definition: Messenger.h:60
double Emax(void) const
#define pNOTICE
Definition: Messenger.h:61
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition: Messenger.h:84
string genie::XSecSplineList::CurrentTune ( void  ) const
inline

Definition at line 63 of file XSecSplineList.h.

References fCurrentTune.

63 { return fCurrentTune; }
string fCurrentTune
The `active&#39; tune, out the many that can co-exist.
double genie::XSecSplineList::Emax ( void  ) const
inline

Definition at line 91 of file XSecSplineList.h.

References fEmax.

91 { return fEmax; }
double genie::XSecSplineList::Emin ( void  ) const
inline

Definition at line 90 of file XSecSplineList.h.

References fEmin.

90 { return fEmin; }
const Spline * genie::XSecSplineList::GetSpline ( const XSecAlgorithmI alg,
const Interaction i 
) const
const Spline * genie::XSecSplineList::GetSpline ( string  spline_key) const

Definition at line 131 of file XSecSplineList.cxx.

References pDEBUG, pFATAL, pWARN, and SLOG.

132 {
133 
134  if ( fCurrentTune.size() == 0 ) {
135  SLOG("XSecSplLst", pFATAL) << "Spline requested while CurrentTune not set" ;
136  exit(0) ;
137  }
138 
139  SLOG("XSecSplLst", pDEBUG)
140  << "Getting spline: " << key << " in tune: " << fCurrentTune;
141 
142  map<string, map<string, Spline *> >::const_iterator //\/
143  mm_iter = fSplineMap.find(fCurrentTune);
144  if(mm_iter == fSplineMap.end()) {
145  SLOG("XSecSplLst", pWARN)
146  << "No splines for tune " << fCurrentTune << " were found!";
147  return 0;
148  }
149  const map<string, Spline *> & spl_map_curr_tune = mm_iter->second;
150  map<string, Spline *>::const_iterator //\/
151  m_iter = spl_map_curr_tune.find(key);
152  if(m_iter == spl_map_curr_tune.end()) {
153  SLOG("XSecSplLst", pWARN)
154  << "Couldn't find spline: " << key << " in tune: " << fCurrentTune;
155  return 0;
156  }
157  return m_iter->second;
158 }
#define pFATAL
Definition: Messenger.h:56
map< string, map< string, Spline * > > fSplineMap
tune -&gt; { xsec_alg/xsec_config/interaction -&gt; Spline }
string fCurrentTune
The `active&#39; tune, out the many that can co-exist.
#define pWARN
Definition: Messenger.h:60
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition: Messenger.h:84
#define pDEBUG
Definition: Messenger.h:63
const vector< string > * genie::XSecSplineList::GetSplineKeys ( void  ) const

Definition at line 563 of file XSecSplineList.cxx.

References pWARN, and SLOG.

564 {
565  map<string, map<string, Spline *> >::const_iterator //\/
566  mm_iter = fSplineMap.find(fCurrentTune);
567  if(mm_iter == fSplineMap.end()) {
568  SLOG("XSecSplLst", pWARN)
569  << "No splines for tune " << fCurrentTune << " were found!";
570  return 0;
571  }
572  const map<string, Spline *> & spl_map_curr_tune = mm_iter->second;
573  vector<string> * keyv = new vector<string>(spl_map_curr_tune.size());
574  unsigned int i=0;
575  map<string, Spline *>::const_iterator m_iter = spl_map_curr_tune.begin();
576  for( ; m_iter != spl_map_curr_tune.end(); ++m_iter) {
577  string key = m_iter->first;
578  (*keyv)[i++]=key;
579  }
580  return keyv;
581 }
map< string, map< string, Spline * > > fSplineMap
tune -&gt; { xsec_alg/xsec_config/interaction -&gt; Spline }
string fCurrentTune
The `active&#39; tune, out the many that can co-exist.
#define pWARN
Definition: Messenger.h:60
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition: Messenger.h:84
bool genie::XSecSplineList::HasSplineFromTune ( const string &  tune) const
inline

Definition at line 64 of file XSecSplineList.h.

References fSplineMap.

64 { return fSplineMap.count(tune) > 0 ; }
map< string, map< string, Spline * > > fSplineMap
tune -&gt; { xsec_alg/xsec_config/interaction -&gt; Spline }
XSecSplineList * genie::XSecSplineList::Instance ( void  )
static
bool genie::XSecSplineList::IsEmpty ( void  ) const
XmlParserStatus_t genie::XSecSplineList::LoadFromXml ( const string &  filename,
bool  keep = false 
)

Load XSecSplineList from ROOT file. If keep = true, then the loaded splines are added to the existing list. If false, then the existing list is reset before loading the splines.

Definition at line 402 of file XSecSplineList.cxx.

References genie::kXmlInvalidRoot, genie::kXmlNotParsed, genie::kXmlOK, LOG, pDEBUG, pERROR, pINFO, pNOTICE, SLOG, and genie::utils::str::TrimSpaces().

Referenced by LoadSplines(), main(), and genie::utils::app_init::XSecTable().

403 {
404 //! Load XSecSplineList from ROOT file. If keep = true, then the loaded splines
405 //! are added to the existing list. If false, then the existing list is reset
406 //! before loading the splines.
407 
408  SLOG("XSecSplLst", pNOTICE)
409  << "Loading splines from: " << filename;
410  SLOG("XSecSplLst", pINFO)
411  << "Option to keep pre-existing splines is switched "
412  << ( (keep) ? "ON" : "OFF" );
413 
414  if(!keep) fSplineMap.clear();
415 
416  const int kNodeTypeStartElement = 1;
417  const int kNodeTypeEndElement = 15;
418  const int kKnotX = 0;
419  const int kKnotY = 1;
420 
421  xmlTextReaderPtr reader;
422 
423  int ret = 0, val_type = -1, iknot = 0, nknots = 0;
424  double * E = 0, * xsec = 0;
425  string spline_name = "";
426  string temp_tune ;
427 
428  reader = xmlNewTextReaderFilename(filename.c_str());
429  if (reader != NULL) {
430  ret = xmlTextReaderRead(reader);
431  while (ret == 1) {
432  xmlChar * name = xmlTextReaderName (reader);
433  xmlChar * value = xmlTextReaderValue (reader);
434  int type = xmlTextReaderNodeType (reader);
435  int depth = xmlTextReaderDepth (reader);
436 
437  if(depth==0 && type==kNodeTypeStartElement) {
438  LOG("XSecSplLst", pDEBUG) << "Root element = " << name;
439  if(xmlStrcmp(name, (const xmlChar *) "genie_xsec_spline_list")) {
440  LOG("XSecSplLst", pERROR)
441  << "\nXML doc. has invalid root element! [filename: " << filename << "]";
442  return kXmlInvalidRoot;
443  }
444 
445  xmlChar * xvrs = xmlTextReaderGetAttribute(reader,(const xmlChar*)"version");
446  xmlChar * xinlog = xmlTextReaderGetAttribute(reader,(const xmlChar*)"uselog");
447  string svrs = utils::str::TrimSpaces((const char *)xvrs);
448  string sinlog = utils::str::TrimSpaces((const char *)xinlog);
449 
450  LOG("XSecSplLst", pNOTICE)
451  << "Input x-section spline XML file format version: " << svrs;
452 
453  if (atoi(sinlog.c_str()) == 1) this->SetLogE(true);
454  else this->SetLogE(false);
455 
456  xmlFree(xvrs);
457  xmlFree(xinlog);
458  }
459 
460  if( (!xmlStrcmp(name, (const xmlChar *) "genie_tune")) && type==kNodeTypeStartElement) {
461  xmlChar * xtune = xmlTextReaderGetAttribute(reader,(const xmlChar*)"name");
462  temp_tune = utils::str::TrimSpaces((const char *)xtune);
463  SLOG("XSecSplLst", pNOTICE) << "Loading x-section splines for GENIE tune: " << temp_tune;
464  xmlFree(xtune);
465  }
466 
467  if( (!xmlStrcmp(name, (const xmlChar *) "spline")) && type==kNodeTypeStartElement) {
468  xmlChar * xname = xmlTextReaderGetAttribute(reader,(const xmlChar*)"name");
469  xmlChar * xnkn = xmlTextReaderGetAttribute(reader,(const xmlChar*)"nknots");
470  string sname = utils::str::TrimSpaces((const char *)xname);
471  string snkn = utils::str::TrimSpaces((const char *)xnkn);
472 
473  spline_name = sname;
474  SLOG("XSecSplLst", pNOTICE) << "Loading spline: " << spline_name;
475 
476  nknots = atoi( snkn.c_str() );
477  iknot=0;
478  E = new double[nknots];
479  xsec = new double[nknots];
480 
481  xmlFree(xname);
482  xmlFree(xnkn);
483  }
484 
485  if( (!xmlStrcmp(name, (const xmlChar *) "E")) && type==kNodeTypeStartElement) { val_type = kKnotX; }
486  if( (!xmlStrcmp(name, (const xmlChar *) "xsec")) && type==kNodeTypeStartElement) { val_type = kKnotY; }
487 
488  if( (!xmlStrcmp(name, (const xmlChar *) "#text")) && depth==5) {
489  if (val_type==kKnotX) E [iknot] = atof((const char *)value);
490  else if (val_type==kKnotY) xsec[iknot] = atof((const char *)value);
491  }
492  if( (!xmlStrcmp(name, (const xmlChar *) "knot")) && type==kNodeTypeEndElement) {
493  iknot++;
494  }
495  if( (!xmlStrcmp(name, (const xmlChar *) "spline")) && type==kNodeTypeEndElement) {
496 #ifdef __GENIE_LOW_LEVEL_MESG_ENABLED__
497  LOG("XSecSplLst", pINFO) << "Done with current spline";
498  for(int i=0; i<nknots; i++) {
499  LOG("XSecSplLst", pINFO) << "xsec[E = " << E[i] << "] = " << xsec[i];
500  }
501 #endif
502  // done looping over knots - build the spline
503  Spline * spline = new Spline(nknots, E, xsec);
504  delete [] E;
505  delete [] xsec;
506 
507  // insert the spline to the map
508  map<string, map<string, Spline *> >::iterator //\/
509  mm_iter = fSplineMap.find( temp_tune );
510  if(mm_iter == fSplineMap.end()) {
511  map<string, Spline *> spl_map_curr_tune;
512  fSplineMap.insert( map<string, map<string, Spline *> >::value_type(
513  temp_tune, spl_map_curr_tune) );
514  mm_iter = fSplineMap.find( temp_tune );
515  }
516  map<string, Spline *> & spl_map_curr_tune = mm_iter->second;
517  spl_map_curr_tune.insert(
518  map<string, Spline *>::value_type(spline_name, spline) );
519  fLoadedSplineSet[temp_tune].insert(spline_name);
520  }
521  xmlFree(name);
522  xmlFree(value);
523  ret = xmlTextReaderRead(reader);
524  }
525  xmlFreeTextReader(reader);
526  if (ret != 0) {
527  LOG("XSecSplLst", pERROR)
528  << "\nXML file could not be parsed! [filename: " << filename << "]";
529  return kXmlNotParsed;
530  }
531  } else {
532  LOG("XSecSplLst", pERROR)
533  << "\nXML file could not be found! [filename: " << filename << "]";
534  }
535 
536  return kXmlOK;
537 }
#define pERROR
Definition: Messenger.h:59
map< string, set< string > > fLoadedSplineSet
tune -&gt; { set of initialy loaded splines }
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
#define pINFO
Definition: Messenger.h:62
map< string, map< string, Spline * > > fSplineMap
tune -&gt; { xsec_alg/xsec_config/interaction -&gt; Spline }
string TrimSpaces(string input)
Definition: StringUtils.cxx:18
const char * name
void SetLogE(bool on)
set opt to build splines as f(E) or as f(logE)
#define pNOTICE
Definition: Messenger.h:61
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition: Messenger.h:84
#define pDEBUG
Definition: Messenger.h:63
int genie::XSecSplineList::NKnots ( void  ) const
inline

Definition at line 89 of file XSecSplineList.h.

References fNKnots.

89 { return fNKnots; }
int genie::XSecSplineList::NSplines ( void  ) const

Definition at line 299 of file XSecSplineList.cxx.

References pWARN, and SLOG.

300 {
301  map<string, map<string, Spline *> >::const_iterator //
302  mm_iter = fSplineMap.find(fCurrentTune);
303  if(mm_iter == fSplineMap.end()) {
304  SLOG("XSecSplLst", pWARN)
305  << "No splines for tune " << fCurrentTune << " were found!";
306  return 0;
307  }
308  const map<string, Spline *> & spl_map_curr_tune = mm_iter->second;
309  return (int) spl_map_curr_tune.size();
310 }
map< string, map< string, Spline * > > fSplineMap
tune -&gt; { xsec_alg/xsec_config/interaction -&gt; Spline }
string fCurrentTune
The `active&#39; tune, out the many that can co-exist.
#define pWARN
Definition: Messenger.h:60
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition: Messenger.h:84
void genie::XSecSplineList::Print ( ostream &  stream) const

Definition at line 583 of file XSecSplineList.cxx.

Referenced by genie::operator<<().

584 {
585  stream << "\n ******************* XSecSplineList *************************";
586  stream << "\n [-] Options:";
587  stream << "\n |";
588  stream << "\n |-----o UseLogE..................." << fUseLogE;
589  stream << "\n |-----o Spline Emin..............." << fEmin;
590  stream << "\n |-----o Spline Emax..............." << fEmax;
591  stream << "\n |-----o Spline NKnots............." << fNKnots;
592  stream << "\n |";
593 
594  map<string, map<string, Spline *> >::const_iterator mm_iter;
595  for(mm_iter = fSplineMap.begin(); mm_iter != fSplineMap.end(); ++mm_iter) {
596 
597  string curr_tune = mm_iter->first;
598  stream << "\n [-] Available x-section splines for tune: " << curr_tune ;
599  stream << "\n |";
600 
601  const map<string, Spline *> & spl_map_curr_tune = mm_iter->second;
602  map<string, Spline *>::const_iterator m_iter = spl_map_curr_tune.begin();
603  for( ; m_iter != spl_map_curr_tune.end(); ++m_iter) {
604  string key = m_iter->first;
605  stream << "\n |-----o " << key;
606  }
607  stream << "\n";
608  }
609 }
map< string, map< string, Spline * > > fSplineMap
tune -&gt; { xsec_alg/xsec_config/interaction -&gt; Spline }
void genie::XSecSplineList::SaveAsXml ( const string &  filename,
bool  save_init = true 
) const

Save XSecSplineList to XML file

Definition at line 339 of file XSecSplineList.cxx.

References pERROR, pNOTICE, genie::Spline::SaveAsXml(), and SLOG.

Referenced by main().

340 {
341 //! Save XSecSplineList to XML file
342 
343  SLOG("XSecSplLst", pNOTICE)
344  << "Saving XSecSplineList as XML in file: " << filename;
345 
346  ofstream outxml(filename.c_str());
347  if(!outxml.is_open()) {
348  SLOG("XSecSplLst", pERROR) << "Couldn't create file = " << filename;
349  return;
350  }
351  outxml << "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
352  outxml << endl << endl;
353  outxml << "<!-- generated by genie::XSecSplineList::SaveSplineList() -->";
354  outxml << endl << endl;
355 
356  int uselog = (fUseLogE ? 1 : 0);
357  outxml << "<genie_xsec_spline_list "
358  << "version=\"3.00\" uselog=\"" << uselog << "\">";
359  outxml << endl << endl;
360 
361  // loop over tunes
362  map<string, map<string, Spline *> >::const_iterator //\/
363  mm_iter = fSplineMap.begin();
364  for( ; mm_iter != fSplineMap.end(); ++mm_iter) {
365 
366  string tune_name = mm_iter->first;
367  outxml << " <genie_tune name=\"" << tune_name << "\">";
368  outxml << endl << endl;
369 
370  // loop over splines for given tune
371  const map<string, Spline *> & spl_map_curr_tune = mm_iter->second;
372  map<string, Spline *>::const_iterator //\/
373  m_iter = spl_map_curr_tune.begin();
374  for( ; m_iter != spl_map_curr_tune.end(); ++m_iter) {
375  string key = m_iter->first;
376 
377  // If current spline is from the initial loaded set,
378  // look-up input option to decide whether to write out in
379  // new output file or not
380  bool from_init_set = false;
381  map<string, set<string> >::const_iterator //\/
382  it = fLoadedSplineSet.find(tune_name);
383  if(it != fLoadedSplineSet.end()) {
384  const set<string> & init_set_curr_tune = it->second;
385  from_init_set = (init_set_curr_tune.count(key) == 1);
386  }
387  if(from_init_set && !save_init) continue;
388 
389  // Add current spline to output file
390  Spline * spline = m_iter->second;
391  spline->SaveAsXml(outxml,"E","xsec", key);
392  }//spline loop
393 
394  outxml << " </genie_tune>" << endl;
395  }//tune loop
396 
397  outxml << "</genie_xsec_spline_list>" << endl;
398 
399  outxml.close();
400 }
#define pERROR
Definition: Messenger.h:59
map< string, set< string > > fLoadedSplineSet
tune -&gt; { set of initialy loaded splines }
map< string, map< string, Spline * > > fSplineMap
tune -&gt; { xsec_alg/xsec_config/interaction -&gt; Spline }
#define pNOTICE
Definition: Messenger.h:61
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition: Messenger.h:84
void genie::XSecSplineList::SetCurrentTune ( const string &  tune)
inline

Definition at line 62 of file XSecSplineList.h.

References fCurrentTune.

Referenced by genie::RunOpt::BuildTune().

62 { fCurrentTune = tune; }
string fCurrentTune
The `active&#39; tune, out the many that can co-exist.
void genie::XSecSplineList::SetLogE ( bool  on)

set opt to build splines as f(E) or as f(logE)

Definition at line 318 of file XSecSplineList.cxx.

Referenced by genie::GEVGDriver::CreateSplines().

319 {
320  fUseLogE = on;
321 }
void genie::XSecSplineList::SetMaxE ( double  Ev)

set default maximum energy for xsec splines

Definition at line 334 of file XSecSplineList.cxx.

335 {
336  if(Ev>0) fEmax = Ev;
337 }
void genie::XSecSplineList::SetMinE ( double  Ev)

set default minimum energy for xsec splines

Definition at line 329 of file XSecSplineList.cxx.

330 {
331  if(Ev>0) fEmin = Ev;
332 }
void genie::XSecSplineList::SetNKnots ( int  nk)

set default number of knots for building the spline

Definition at line 323 of file XSecSplineList.cxx.

324 {
325  fNKnots = nk;
326  if(fNKnots<10) fNKnots = 10; // minimum acceptable number of knots
327 }
bool genie::XSecSplineList::SplineExists ( const XSecAlgorithmI alg,
const Interaction i 
) const
bool genie::XSecSplineList::SplineExists ( string  spline_key) const

Definition at line 99 of file XSecSplineList.cxx.

References genie::utils::print::BoolAsYNString(), pDEBUG, pERROR, pWARN, and SLOG.

100 {
101 
102  if ( fCurrentTune.size() == 0 ) {
103  SLOG("XSecSplLst", pERROR) << "Spline requested while CurrentTune not set" ;
104  return false ;
105  }
106 
107  SLOG("XSecSplLst", pDEBUG)
108  << "Checking for spline: " << key << " in tune: " << fCurrentTune;
109 
110  map<string, map<string, Spline *> >::const_iterator //
111  mm_iter = fSplineMap.find(fCurrentTune);
112  if(mm_iter == fSplineMap.end()) {
113  SLOG("XSecSplLst", pWARN)
114  << "No splines for tune " << fCurrentTune << " were found!";
115  return false;
116  }
117  const map<string, Spline *> & spl_map_curr_tune = mm_iter->second;
118  bool exists = (spl_map_curr_tune.count(key) == 1);
119  SLOG("XSecSplLst", pDEBUG)
120  << "Spline found?...." << utils::print::BoolAsYNString(exists);
121  return exists;
122 }
#define pERROR
Definition: Messenger.h:59
string BoolAsYNString(bool b)
Definition: PrintUtils.cxx:108
map< string, map< string, Spline * > > fSplineMap
tune -&gt; { xsec_alg/xsec_config/interaction -&gt; Spline }
string fCurrentTune
The `active&#39; tune, out the many that can co-exist.
#define pWARN
Definition: Messenger.h:60
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition: Messenger.h:84
#define pDEBUG
Definition: Messenger.h:63
bool genie::XSecSplineList::UseLogE ( void  ) const
inline

Definition at line 88 of file XSecSplineList.h.

References fUseLogE.

88 { return fUseLogE; }

Friends And Related Function Documentation

friend struct Cleaner
friend

Definition at line 120 of file XSecSplineList.h.

ostream& operator<< ( ostream &  stream,
const XSecSplineList xsl 
)
friend

Definition at line 44 of file XSecSplineList.cxx.

45 {
46  list.Print(stream);
47  return stream;
48 }

Member Data Documentation

string genie::XSecSplineList::fCurrentTune
private

The `active' tune, out the many that can co-exist.

Definition at line 106 of file XSecSplineList.h.

Referenced by CurrentTune(), and SetCurrentTune().

double genie::XSecSplineList::fEmax
private

Definition at line 104 of file XSecSplineList.h.

Referenced by Emax().

double genie::XSecSplineList::fEmin
private

Definition at line 103 of file XSecSplineList.h.

Referenced by Emin().

XSecSplineList * genie::XSecSplineList::fInstance = 0
staticprivate

Definition at line 99 of file XSecSplineList.h.

Referenced by genie::XSecSplineList::Cleaner::~Cleaner().

map<string, set<string> > genie::XSecSplineList::fLoadedSplineSet
private

tune -> { set of initialy loaded splines }

Definition at line 109 of file XSecSplineList.h.

int genie::XSecSplineList::fNKnots
private

Definition at line 102 of file XSecSplineList.h.

Referenced by NKnots().

map<string, map<string, Spline *> > genie::XSecSplineList::fSplineMap
private

tune -> { xsec_alg/xsec_config/interaction -> Spline }

Definition at line 108 of file XSecSplineList.h.

Referenced by HasSplineFromTune().

bool genie::XSecSplineList::fUseLogE
private

Definition at line 101 of file XSecSplineList.h.

Referenced by UseLogE().


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