GENIEGenerator
Loading...
Searching...
No Matches
XSecSplineList.cxx
Go to the documentation of this file.
1//____________________________________________________________________________
2/*
3 Copyright (c) 2003-2025, The GENIE Collaboration
4 For the full text of the license visit http://copyright.genie-mc.org
5
6 Costas Andreopoulos <c.andreopoulos \at cern.ch>
7 University of Liverpool
8*/
9//____________________________________________________________________________
10
11#include <fenv.h> //provides: int feenableexcept(int excepts);
12#include <cmath> //provides: std::isnan()
13
14#include <chrono>
15
16#include <fstream>
17#include <cstdlib>
18
19#include "libxml/parser.h"
20#include "libxml/xmlmemory.h"
21#include "libxml/xmlreader.h"
22
23#include <TMath.h>
24#include <TLorentzVector.h>
25
28#include "Framework/Conventions/GBuild.h"
35
36using std::ofstream;
37using std::endl;
38
39namespace genie {
40
41 using namespace std::chrono ;
42
43//____________________________________________________________________________
44ostream & operator << (ostream & stream, const XSecSplineList & list)
45{
46 list.Print(stream);
47 return stream;
48}
49//____________________________________________________________________________
51//____________________________________________________________________________
53{
54 fInstance = 0;
55 fCurrentTune = "";
56 fUseLogE = true;
57 fNKnots = 100;
58 fEmin = 0.01; // GeV
59 fEmax = 100.00; // GeV
60}
61//____________________________________________________________________________
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}
81//____________________________________________________________________________
83{
84 if(fInstance == 0) {
85 static XSecSplineList::Cleaner cleaner;
88 }
89 return fInstance;
90}
91//____________________________________________________________________________
93 const XSecAlgorithmI * alg, const Interaction * interaction) const
94{
95 string key = this->BuildSplineKey(alg,interaction);
96 return this->SplineExists(key);
97}
98//____________________________________________________________________________
99bool XSecSplineList::SplineExists(string key) const
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}
123//____________________________________________________________________________
125 const XSecAlgorithmI * alg, const Interaction * interaction) const
126{
127 string key = this->BuildSplineKey(alg,interaction);
128 return this->GetSpline(key);
129}
130//____________________________________________________________________________
131const Spline * XSecSplineList::GetSpline(string key) const
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}
159//____________________________________________________________________________
161 const Interaction * interaction, int nknots, double e_min, double e_max)
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}
298//____________________________________________________________________________
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}
311//____________________________________________________________________________
313{
314 int n = this->NSplines();
315 return (n == 0);
316}
317//____________________________________________________________________________
319{
320 fUseLogE = on;
321}
322//____________________________________________________________________________
324{
325 fNKnots = nk;
326 if(fNKnots<10) fNKnots = 10; // minimum acceptable number of knots
327}
328//____________________________________________________________________________
330{
331 if(Ev>0) fEmin = Ev;
332}
333//____________________________________________________________________________
335{
336 if(Ev>0) fEmax = Ev;
337}
338//____________________________________________________________________________
339void XSecSplineList::SaveAsXml(const string & filename, bool save_init) const
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}
401//____________________________________________________________________________
402XmlParserStatus_t XSecSplineList::LoadFromXml(const string & filename, bool keep)
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}
538//____________________________________________________________________________
540 const XSecAlgorithmI * alg, const Interaction * interaction) const
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}
562//____________________________________________________________________________
563const vector<string> * XSecSplineList::GetSplineKeys(void) const
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}
582//____________________________________________________________________________
583void XSecSplineList::Print(ostream & stream) const
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}
610//___________________________________________________________________________
611
612} // genie namespace
#define pNOTICE
Definition Messenger.h:61
#define pINFO
Definition Messenger.h:62
#define pERROR
Definition Messenger.h:59
#define pFATAL
Definition Messenger.h:56
#define pDEBUG
Definition Messenger.h:63
#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
#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 Config(void) const
Definition AlgId.h:45
string Name(void) const
Definition AlgId.h:44
virtual const AlgId & Id(void) const
Get algorithm ID.
Definition Algorithm.h:98
void SetProbeP4(const TLorentzVector &P4)
TParticlePDG * Probe(void) const
Summary information for an interaction.
Definition Interaction.h:56
string AsString(void) const
InitialState * InitStatePtr(void) const
Definition Interaction.h:74
const KPhaseSpace & PhaseSpace(void) const
Definition Interaction.h:73
double Threshold(void) const
Energy threshold.
A numeric analysis tool class for interpolating 1-D functions.
Definition Spline.h:58
void SaveAsXml(string filename, string xtag, string ytag, string name="") const
Definition Spline.cxx:419
Cross Section Calculation Interface.
virtual double Integral(const Interaction *i) const =0
List of cross section vs energy splines.
void SetMinE(double Ev)
set default minimum energy for xsec splines
void SaveAsXml(const string &filename, bool save_init=true) const
void SetLogE(bool on)
set opt to build splines as f(E) or as f(logE)
map< string, map< string, Spline * > > fSplineMap
tune -> { xsec_alg/xsec_config/interaction -> Spline }
bool UseLogE(void) const
string fCurrentTune
The ‘active’ tune, out the many that can co-exist.
bool SplineExists(const XSecAlgorithmI *alg, const Interaction *i) const
double Emax(void) const
const Spline * GetSpline(const XSecAlgorithmI *alg, const Interaction *i) const
bool IsEmpty(void) const
string BuildSplineKey(const XSecAlgorithmI *alg, const Interaction *i) const
XmlParserStatus_t LoadFromXml(const string &filename, bool keep=false)
map< string, set< string > > fLoadedSplineSet
tune -> { set of initialy loaded splines }
static XSecSplineList * Instance()
void SetMaxE(double Ev)
set default maximum energy for xsec splines
void CreateSpline(const XSecAlgorithmI *alg, const Interaction *i, int nknots=-1, double e_min=-1, double e_max=-1)
void SetNKnots(int nk)
set default number of knots for building the spline
double Emin(void) const
static XSecSplineList * fInstance
void Print(ostream &stream) const
int NKnots(void) const
const vector< string > * GetSplineKeys(void) const
static constexpr double cm2
Definition Units.h:69
string BoolAsYNString(bool b)
string TrimSpaces(string input)
THE MAIN GENIE PROJECT NAMESPACE
Definition AlgCmp.h:25
enum genie::EXmlParseStatus XmlParserStatus_t
ostream & operator<<(ostream &stream, const AlgConfigPool &config_pool)
@ kXmlInvalidRoot