Public Member Functions | Public Attributes | Private Attributes | List of all members
ana::covmx::Sample Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-10-23/CAFAna/Core/Sample.h"

Public Member Functions

 Sample (Selection s, Polarity p, Detector d, Quantile q=kNoQ)
 
 Sample (Sample const &sample)
 
 Sample (unsigned int id)
 
 ~Sample ()
 
std::string GetSelection () const
 
std::string GetPolarity () const
 
std::string GetDetector () const
 
std::string GetQuantile () const
 
std::string GetName () const
 
std::string GetTag () const
 
std::string GetLatexName () const
 
void SetAxis (const HistAxis *a)
 
void SetCut (const Cut *c)
 
void SetPOT (double d)
 
void SetLivetime (double l)
 
void SetPrediction (IPrediction *p)
 
void SetCosmic (Spectrum *s)
 
void SetData (Spectrum *s)
 
void SetSystAlias (const ISyst *key, const ISyst *val)
 
const HistAxisGetAxis () const
 
Binning GetBinning () const
 
const CutGetCut () const
 
double GetPOT () const
 
double GetLivetime () const
 
IPredictionGetPrediction () const
 
SpectrumGetCosmic () const
 
SpectrumGetData () const
 
SystShifts GetSystShifts (SystShifts shifts) const
 
bool HasPrediction () const
 
void ResetPrediction ()
 
bool HasCosmic () const
 
void ResetCosmic ()
 
bool HasData () const
 
void ResetData ()
 
unsigned int GetID () const
 
bool operator< (const Sample &lhs) const
 
bool operator== (const Sample &lhs)
 
bool operator!= (const Sample &lhs)
 

Public Attributes

Selection selection
 
Polarity polarity
 
Detector detector
 
Quantile quantile
 

Private Attributes

const HistAxisaxis
 
const Cutcut
 
double pot
 
double livetime
 
IPredictionprediction
 
Spectrumdata
 
Spectrumcosmic
 
std::map< const ISyst *, const ISyst * > systMap
 

Detailed Description

Definition at line 33 of file Sample.h.

Constructor & Destructor Documentation

Sample::Sample ( Selection  s,
Polarity  p,
Detector  d,
Quantile  q = kNoQ 
)

Definition at line 18 of file Sample.cxx.

19  : selection(s), polarity(p), detector(d), quantile(q), axis(nullptr),
20  cut(nullptr), pot(-1), livetime(-1), prediction(nullptr),
21  data(nullptr), cosmic(nullptr) {}
IPrediction * prediction
Definition: Sample.h:111
const HistAxis * axis
Definition: Sample.h:106
const char * p
Definition: xmltok.h:285
Spectrum * data
Definition: Sample.h:112
Selection selection
Definition: Sample.h:98
Detector detector
Definition: Sample.h:100
const Cut * cut
Definition: Sample.h:107
Quantile quantile
Definition: Sample.h:101
double livetime
Definition: Sample.h:109
Spectrum * cosmic
Definition: Sample.h:113
Polarity polarity
Definition: Sample.h:99
Sample::Sample ( Sample const &  sample)

Definition at line 24 of file Sample.cxx.

25  : selection(sample.selection), polarity(sample.polarity),
26  detector(sample.detector), quantile(sample.quantile),
27  axis(sample.axis), cut(sample.cut), pot(sample.pot),
28  livetime(sample.livetime), prediction(sample.prediction),
29  data(sample.data), cosmic(sample.cosmic), systMap(sample.systMap)
30  {}
std::map< const ISyst *, const ISyst * > systMap
Definition: Sample.h:115
IPrediction * prediction
Definition: Sample.h:111
const HistAxis * axis
Definition: Sample.h:106
Spectrum * data
Definition: Sample.h:112
Selection selection
Definition: Sample.h:98
Detector detector
Definition: Sample.h:100
const Cut * cut
Definition: Sample.h:107
Quantile quantile
Definition: Sample.h:101
double livetime
Definition: Sample.h:109
Spectrum * cosmic
Definition: Sample.h:113
Polarity polarity
Definition: Sample.h:99
Sample::Sample ( unsigned int  id)

Definition at line 33 of file Sample.cxx.

References detector, polarity, quantile, and selection.

34  : axis(nullptr), cut(nullptr), pot(-1), livetime(-1),\
35  prediction(nullptr), data(nullptr), cosmic(nullptr) {
36  selection = (covmx::Selection)((id & (3 << 7)) >> 7);
37  polarity = (covmx::Polarity) ((id & (3 << 5)) >> 5);
38  detector = (covmx::Detector) ((id & (3 << 3)) >> 3);
39  quantile = (covmx::Quantile) (id & 7);
40  }
const HistAxis * axis
Definition: Sample.h:106
Spectrum * data
Definition: Sample.h:112
Selection selection
Definition: Sample.h:98
Detector detector
Definition: Sample.h:100
const Cut * cut
Definition: Sample.h:107
Quantile quantile
Definition: Sample.h:101
double livetime
Definition: Sample.h:109
Spectrum * cosmic
Definition: Sample.h:113
Polarity polarity
Definition: Sample.h:99
Sample::~Sample ( )

Definition at line 43 of file Sample.cxx.

43 {}

Member Function Documentation

const HistAxis * Sample::GetAxis ( ) const

Definition at line 118 of file Sample.cxx.

References axis.

Referenced by SetSystAlias().

118  {
119  if (!axis) throw runtime_error("Axis not set in sample!");
120  return axis;
121  }
const HistAxis * axis
Definition: Sample.h:106
Binning Sample::GetBinning ( ) const

Definition at line 124 of file Sample.cxx.

References axis, and ana::LabelsAndBins::GetBinnings().

Referenced by SetSystAlias().

124  {
125  if (!axis) throw runtime_error("Axis not set in sample!");
126  return axis->GetBinnings()[0];
127  }
const HistAxis * axis
Definition: Sample.h:106
const std::vector< Binning > & GetBinnings() const
Definition: LabelsAndBins.h:69
Spectrum * Sample::GetCosmic ( ) const

Definition at line 158 of file Sample.cxx.

References cosmic.

Referenced by SetSystAlias().

158  {
159  if (!cosmic) throw runtime_error("Cosmic spectrum not set in sample!");
160  return cosmic;
161  }
Sum up livetimes from individual cosmic triggers.
Spectrum * cosmic
Definition: Sample.h:113
const Cut * Sample::GetCut ( ) const

Definition at line 130 of file Sample.cxx.

References cut.

Referenced by SetSystAlias().

130  {
131  if (!cut) throw runtime_error("Cut not set in sample!");
132  return cut;
133  }
const Cut * cut
Definition: Sample.h:107
Spectrum * Sample::GetData ( ) const

Definition at line 164 of file Sample.cxx.

References data.

Referenced by SetSystAlias().

164  {
165  if (!data) throw runtime_error("Data spectrum not set in sample!");
166  return data;
167  }
Spectrum * data
Definition: Sample.h:112
const XML_Char const XML_Char * data
Definition: expat.h:268
string Sample::GetDetector ( ) const

Definition at line 58 of file Sample.cxx.

References detector.

Referenced by GetName(), GetSystsFromFile(), and GetTag().

58  {
59  vector<string> pol = { "neardet", "fardet" };
60  return pol[detector];
61  }
Detector detector
Definition: Sample.h:100
unsigned int Sample::GetID ( ) const

Definition at line 185 of file Sample.cxx.

References detector, polarity, quantile, and selection.

Referenced by operator!=(), operator<(), operator==(), and ResetData().

186  {
187  unsigned int id = selection;
188  id <<= 2;
189  id += polarity;
190  id <<= 2;
191  id += detector;
192  id <<= 3;
193  id += quantile;
194  return id;
195 
196  } // function Sample::GetID
::xsd::cxx::tree::id< char, ncname > id
Definition: Database.h:165
Selection selection
Definition: Sample.h:98
Detector detector
Definition: Sample.h:100
Quantile quantile
Definition: Sample.h:101
Polarity polarity
Definition: Sample.h:99
string Sample::GetLatexName ( ) const

Definition at line 81 of file Sample.cxx.

References fillBadChanDBTables::det, detector, ana::covmx::kNoQ, polarity, quantile, and selection.

81  {
82  ostringstream name;
83  vector<string> sel = { "CC $\\nu_{\\mu}$", "CC $\\nu_{e}$", "NC" };
84  name << sel[selection];
85  vector<string> pol = { "FHC", "RHC" };
86  name << " " << pol[polarity];
87  vector<string> det = { "ND", "FD" };
88  name << " " << det[detector];
89  if (quantile != kNoQ) name << " Quantile " << quantile+1;
90  return name.str();
91  }
const XML_Char * name
Definition: expat.h:151
Selection selection
Definition: Sample.h:98
Detector detector
Definition: Sample.h:100
Quantile quantile
Definition: Sample.h:101
Polarity polarity
Definition: Sample.h:99
double Sample::GetLivetime ( ) const

Definition at line 142 of file Sample.cxx.

References livetime.

Referenced by MakeFakeData(), and SetSystAlias().

142  {
143  if (livetime == -1) throw runtime_error("Livetime not set in sample!");
144  return livetime;
145  }
double livetime
Definition: Sample.h:109
string Sample::GetName ( ) const

Definition at line 72 of file Sample.cxx.

References GetDetector(), GetPolarity(), GetQuantile(), GetSelection(), ana::covmx::kNoQ, and quantile.

Referenced by GetDefaultAxis().

72  {
73  ostringstream name;
74  name << GetSelection() << " " << GetPolarity() << " " << GetDetector();
75  if (quantile != Quantile::kNoQ)
76  name << " " << GetQuantile();
77  return name.str();
78  }
const XML_Char * name
Definition: expat.h:151
std::string GetQuantile() const
Definition: Sample.cxx:64
std::string GetPolarity() const
Definition: Sample.cxx:52
std::string GetSelection() const
Definition: Sample.cxx:46
std::string GetDetector() const
Definition: Sample.cxx:58
Quantile quantile
Definition: Sample.h:101
string Sample::GetPolarity ( ) const

Definition at line 52 of file Sample.cxx.

References polarity.

Referenced by GetName(), GetTag(), MakeSysts(), and SetCut().

52  {
53  vector<string> pol = { "fhc", "rhc" };
54  return pol[polarity];
55  }
Polarity polarity
Definition: Sample.h:99
double Sample::GetPOT ( ) const

Definition at line 136 of file Sample.cxx.

References pot.

Referenced by MakeFakeData(), and SetSystAlias().

136  {
137  if (pot == -1) throw runtime_error("POT not set in sample!");
138  return pot;
139  }
IPrediction * Sample::GetPrediction ( ) const

Definition at line 148 of file Sample.cxx.

References prediction.

Referenced by MakeFakeData(), and SetSystAlias().

148  {
149  // For what it's worth, I know having a const member function that
150  // returns a bare pointer to a member is extremely not good. If you
151  // feel strongly about this, please come yell at me and perhaps you'll
152  // inspire me to be better
153  if (!prediction) throw runtime_error("Prediction not set in sample!");
154  return prediction;
155  }
IPrediction * prediction
Definition: Sample.h:111
string Sample::GetQuantile ( ) const

Definition at line 64 of file Sample.cxx.

References ana::covmx::kNoQ, and quantile.

Referenced by GetName(), and GetTag().

64  {
65  if (quantile == Quantile::kNoQ)
66  throw runtime_error("This sample does not have quantiles.");
67  vector<string> qnt = { "q0", "q1", "q2", "q3" };
68  return qnt[quantile];
69  }
Quantile quantile
Definition: Sample.h:101
string Sample::GetSelection ( ) const

Definition at line 46 of file Sample.cxx.

References selection.

Referenced by GetName(), and GetTag().

46  {
47  vector<string> sel = { "numusel", "nuesel", "ncsel" };
48  return sel[selection];
49  }
Selection selection
Definition: Sample.h:98
SystShifts Sample::GetSystShifts ( SystShifts  shifts) const

Definition at line 170 of file Sample.cxx.

References ana::SystShifts::ActiveSysts(), ana::SystShifts::GetShift(), runNovaSAM::ret, ana::SystShifts::SetShift(), and systMap.

Referenced by SetSystAlias().

170  {
171  SystShifts ret;
172  for (const ISyst* syst : shifts.ActiveSysts()) {
173  if (systMap.count(syst)) {
174  if (systMap.at(syst)) { // If there's a nullptr here, skip it
175  ret.SetShift(systMap.at(syst), shifts.GetShift(syst));
176  }
177  } else {
178  ret.SetShift(syst, shifts.GetShift(syst));
179  }
180  }
181  return ret;
182  } // function Sample::GetSystShifts
std::map< const ISyst *, const ISyst * > systMap
Definition: Sample.h:115
string Sample::GetTag ( ) const

Definition at line 94 of file Sample.cxx.

References GetDetector(), GetPolarity(), GetQuantile(), GetSelection(), ana::covmx::kNoQ, quantile, and getGoodRuns4SAM::tag.

Referenced by GetSystsFromFile(), LoadCosmic(), LoadPrediction(), LoadSysts(), MakeCovMx(), MakeFakeData(), MakePPFXRatios(), MakeSysts(), SetPrediction(), and SetSystAlias().

94  {
95  ostringstream tag;
96  tag << GetSelection() << "_" << GetPolarity() << "_" << GetDetector();
97  if (quantile != Quantile::kNoQ)
98  tag << "_" << GetQuantile();
99  return tag.str();
100  }
std::string GetQuantile() const
Definition: Sample.cxx:64
std::string GetPolarity() const
Definition: Sample.cxx:52
std::string GetSelection() const
Definition: Sample.cxx:46
std::string GetDetector() const
Definition: Sample.cxx:58
Quantile quantile
Definition: Sample.h:101
bool ana::covmx::Sample::HasCosmic ( ) const
inline

Definition at line 78 of file Sample.h.

78 { return (cosmic!=nullptr); };
Sum up livetimes from individual cosmic triggers.
bool ana::covmx::Sample::HasData ( ) const
inline

Definition at line 80 of file Sample.h.

80 { return (data!=nullptr); };
const XML_Char const XML_Char * data
Definition: expat.h:268
bool ana::covmx::Sample::HasPrediction ( ) const
inline

Definition at line 76 of file Sample.h.

References prediction.

76 { return (prediction!=nullptr); };
IPrediction * prediction
Definition: Sample.h:111
bool ana::covmx::Sample::operator!= ( const Sample lhs)
inline

Definition at line 93 of file Sample.h.

References GetID().

93  {
94  return lhs.GetID() != this->GetID();
95  }
unsigned int GetID() const
Definition: Sample.cxx:185
bool ana::covmx::Sample::operator< ( const Sample lhs) const
inline

Definition at line 85 of file Sample.h.

References GetID().

85  {
86  return lhs.GetID() < this->GetID();
87  }
unsigned int GetID() const
Definition: Sample.cxx:185
bool ana::covmx::Sample::operator== ( const Sample lhs)
inline

Definition at line 89 of file Sample.h.

References GetID().

89  {
90  return lhs.GetID() == this->GetID();
91  }
unsigned int GetID() const
Definition: Sample.cxx:185
void ana::covmx::Sample::ResetCosmic ( )
inline

Definition at line 79 of file Sample.h.

79 { cosmic = nullptr; };
Sum up livetimes from individual cosmic triggers.
void ana::covmx::Sample::ResetData ( )
inline

Definition at line 81 of file Sample.h.

References GetID().

81 { data = nullptr; };
const XML_Char const XML_Char * data
Definition: expat.h:268
void ana::covmx::Sample::ResetPrediction ( )
inline

Definition at line 77 of file Sample.h.

References prediction.

77 { prediction = nullptr; };
IPrediction * prediction
Definition: Sample.h:111
void ana::covmx::Sample::SetAxis ( const HistAxis a)
inline

Definition at line 53 of file Sample.h.

References a, and axis.

Referenced by SetAxis().

53 { axis = a; };
const HistAxis * axis
Definition: Sample.h:106
const double a
void Sample::SetCosmic ( Spectrum s)

Definition at line 108 of file Sample.cxx.

Referenced by SetLivetime().

108  {
109  cosmic = s;
110  }
const XML_Char * s
Definition: expat.h:262
Sum up livetimes from individual cosmic triggers.
void ana::covmx::Sample::SetCut ( const Cut c)
inline

Definition at line 54 of file Sample.h.

References plot_validation_datamc::c, and cut.

Referenced by SetCut().

void Sample::SetData ( Spectrum s)

Definition at line 113 of file Sample.cxx.

Referenced by SetLivetime().

113  {
114  data = s;
115  }
const XML_Char const XML_Char * data
Definition: expat.h:268
const XML_Char * s
Definition: expat.h:262
void ana::covmx::Sample::SetLivetime ( double  l)
inline

Definition at line 56 of file Sample.h.

References submit_hadd::l, livetime, SetCosmic(), SetData(), and SetPrediction().

Referenced by MakeFakeData(), and SetLivetime().

56 { livetime = l; };
double livetime
Definition: Sample.h:109
void ana::covmx::Sample::SetPOT ( double  d)
inline

Definition at line 55 of file Sample.h.

References d, and pot.

Referenced by MakeFakeData(), and SetPOT().

55 { pot = d; };
Float_t d
Definition: plot.C:236
void Sample::SetPrediction ( IPrediction p)

Definition at line 103 of file Sample.cxx.

References prediction.

Referenced by SetLivetime(), and SetPrediction().

103  {
104  prediction = p;
105  }
IPrediction * prediction
Definition: Sample.h:111
const char * p
Definition: xmltok.h:285
void ana::covmx::Sample::SetSystAlias ( const ISyst key,
const ISyst val 
)
inline

Member Data Documentation

const HistAxis* ana::covmx::Sample::axis
private

Definition at line 106 of file Sample.h.

Referenced by GetAxis(), GetBinning(), and SetAxis().

Spectrum* ana::covmx::Sample::cosmic
private

Definition at line 113 of file Sample.h.

Referenced by GetCosmic().

const Cut* ana::covmx::Sample::cut
private

Definition at line 107 of file Sample.h.

Referenced by GetCut(), and SetCut().

Spectrum* ana::covmx::Sample::data
private

Definition at line 112 of file Sample.h.

Referenced by GetData().

Detector ana::covmx::Sample::detector
double ana::covmx::Sample::livetime
private

Definition at line 109 of file Sample.h.

Referenced by GetLivetime(), and SetLivetime().

Polarity ana::covmx::Sample::polarity
double ana::covmx::Sample::pot
private
IPrediction* ana::covmx::Sample::prediction
private

Definition at line 111 of file Sample.h.

Referenced by GetPrediction(), HasPrediction(), ResetPrediction(), and SetPrediction().

Quantile ana::covmx::Sample::quantile

Definition at line 101 of file Sample.h.

Referenced by GetID(), GetLatexName(), GetName(), GetQuantile(), GetTag(), MakeSysts(), Sample(), and SetCut().

Selection ana::covmx::Sample::selection
std::map<const ISyst*, const ISyst*> ana::covmx::Sample::systMap
private

Definition at line 115 of file Sample.h.

Referenced by GetSystShifts(), and SetSystAlias().


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