GSystSet.cxx
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*
3  Copyright (c) 2003-2017, GENIE Neutrino MC Generator Collaboration
4  For the full text of the license visit http://copyright.genie-mc.org
5  or see $GENIE/LICENSE
6 
7  Author: Costas Andreopoulos <costas.andreopoulos \at stfc.ac.uk>
8  University of Liverpool & STFC Rutherford Appleton Lab
9 
10  For the class documentation see the corresponding header file.
11 
12  Important revisions after version 2.0.0 :
13  @ Aug 01, 2009 - CA
14  Was adapted from Jim's and Costas' T2K-specific GENIE reweighting code.
15  First included in v2.5.1.
16 
17 */
18 //____________________________________________________________________________
19 
20 #include "Messenger/Messenger.h"
21 #include "ReWeight/GSystSet.h"
22 
23 using namespace genie;
24 using namespace genie::rew;
25 
26 //_______________________________________________________________________________________
28 {
29 
30 }
31 //_______________________________________________________________________________________
33 {
34  this->Copy(syst);
35 }
36 //_______________________________________________________________________________________
38 {
39  fSystematics.clear();
40 }
41 //_______________________________________________________________________________________
42 void GSystSet::Init(GSyst_t syst, double init, double min, double max, double step)
43 {
44  if(syst == kNullSystematic) return;
45 
46  if(this->Added(syst)) {
47  this->Remove(syst);
48  }
49 
50  GSystInfo * syst_info = new GSystInfo(init,min,max,step);
51  fSystematics.insert( map<GSyst_t, GSystInfo*>::value_type(syst, syst_info) );
52 }
53 //_______________________________________________________________________________________
55 {
56  fSystematics.erase(syst);
57 }
58 //_______________________________________________________________________________________
59 int GSystSet::Size(void) const
60 {
61  return fSystematics.size();
62 }
63 //_______________________________________________________________________________________
64 bool GSystSet::Added(GSyst_t syst) const
65 {
66  return (fSystematics.find(syst) != fSystematics.end());
67 }
68 //_______________________________________________________________________________________
69 vector<genie::rew::GSyst_t> GSystSet::AllIncluded(void)
70 {
71  vector<GSyst_t> svec;
72 
74  for( ; it != fSystematics.end(); ++it) {
75  GSyst_t syst = it->first;
76  svec.push_back(syst);
77  }
78  return svec;
79 }
80 //_______________________________________________________________________________________
81 const GSystInfo * GSystSet::Info(GSyst_t syst) const
82 {
83  if ( this->Added(syst) ) {
84  return fSystematics.find(syst)->second;
85  }
86  return 0;
87 }
88 //_______________________________________________________________________________________
89 void GSystSet::Set(GSyst_t syst, double val)
90 {
91  if ( this->Added(syst) ) {
92  fSystematics[syst]->CurValue = val;
93  }
94  else {
95  this->Init(syst);
96  this->Set(syst,val);
97  }
98 }
99 //_______________________________________________________________________________________
100 void GSystSet::Print(void)
101 {
102  LOG("ReW", pNOTICE)
103  << "Considering " << this->Size() << " systematics";
104 
105  vector<genie::rew::GSyst_t> svec = this->AllIncluded();
106 
107  unsigned int i=0;
109  for( ; it != svec.end(); ++it) {
110  GSyst_t syst = *it;
111  LOG("ReW", pNOTICE) << "(" << i++ << ") : " << GSyst::AsString(syst);
112  }
113 }
114 //_______________________________________________________________________________________
115 void GSystSet::Copy(const GSystSet & syst_set)
116 {
117  return fSystematics.clear();
118 
120  for( ; it != syst_set.fSystematics.end(); ++it) {
121  GSyst_t syst = it->first;
122  GSystInfo * syst_info = it->second;
123 
124  double cur = syst_info->CurValue;
125  double init = syst_info->InitValue;
126  double min = syst_info->MinValue;
127  double max = syst_info->MaxValue;
128  double step = syst_info->Step;
129 
130  this->Init(syst,init,min,max,step);
131  this->Set(syst,cur);
132  }
133 }
134 //_______________________________________________________________________________________
#include "Numerical/GSFunc.h"
Definition: AlgCmp.h:26
bool Added(GSyst_t syst) const
Definition: GSystSet.cxx:64
void Copy(const GSystSet &syst_set)
Definition: GSystSet.cxx:115
cur
Definition: dbjson.py:21
void Set(GSyst_t syst, double current_value)
Definition: GSystSet.cxx:89
int Size(void) const
Definition: GSystSet.cxx:59
void Remove(GSyst_t syst)
Definition: GSystSet.cxx:54
void Init(GSyst_t syst, double init=0., double min=-1., double max=+1., double step=0.05)
Definition: GSystSet.cxx:42
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:87
intermediate_table::const_iterator const_iterator
An enumeration of systematic parameters.
const GSystInfo * Info(GSyst_t syst) const
Definition: GSystSet.cxx:81
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:57
static string AsString(GSyst_t syst)
Definition: GSyst.h:175
#define pNOTICE
Definition: Messenger.h:52
vector< genie::rew::GSyst_t > AllIncluded(void)
Definition: GSystSet.cxx:69
Set of systematics to be considered by the reweighting package.
Definition: GSystSet.h:37
map< GSyst_t, GSystInfo * > fSystematics
Definition: GSystSet.h:58