Functions | Variables
Utilities.h File Reference
#include "OscLib/OscCalcSterile.h"
#include "CAFAna/Core/LoadFromFile.h"
#include "CAFAna/Core/Sample.h"
#include "CAFAna/Core/Registry.h"
#include "NuXAna/Vars/FitVarsSterile.h"
#include "CAFAna/Systs/XSecSystLists.h"
#include "CAFAna/Prediction/PredictionInterp.h"
#include "CAFAna/Prediction/CovarianceMatrix.h"
#include "CAFAna/Experiment/GaussianConstraint.h"
#include "CAFAna/Analysis/Exposures.h"
#include "3FlavorAna/Vars/HistAxes.h"
#include "3FlavorAna/Cuts/QuantileCuts.h"
#include "3FlavorAna/Cuts/NumuCuts2020.h"
#include "3FlavorAna/Cuts/NueCuts2020.h"
#include "NuXAna/Core/Utilities.h"
#include "NuXAna/Vars/HistAxes.h"
#include "NuXAna/Cuts/NusCuts20.h"
#include "NuXAna/Systs/NusAna2020Systs.h"
#include "NuXAna/Prediction/NDPredictionSterile.h"
#include "NuXAna/Prediction/FDPredictionSterile.h"
#include "NuXAna/Analysis/SystMaker.h"
#include "TFile.h"
#include "TKey.h"

Go to the source code of this file.

Functions

const covmx::Sample kNusFHCNearDet (covmx::kNC, covmx::kFHC, covmx::kNearDet)
 
const covmx::Sample kNusFHCFarDet (covmx::kNC, covmx::kFHC, covmx::kFarDet)
 
const covmx::Sample kNumuQ1FHCNearDet (covmx::kCCNumu, covmx::kFHC, covmx::kNearDet, covmx::kQ1)
 
const covmx::Sample kNumuQ1FHCFarDet (covmx::kCCNumu, covmx::kFHC, covmx::kFarDet, covmx::kQ1)
 
const covmx::Sample kNumuQ2FHCNearDet (covmx::kCCNumu, covmx::kFHC, covmx::kNearDet, covmx::kQ2)
 
const covmx::Sample kNumuQ2FHCFarDet (covmx::kCCNumu, covmx::kFHC, covmx::kFarDet, covmx::kQ2)
 
const covmx::Sample kNumuQ3FHCNearDet (covmx::kCCNumu, covmx::kFHC, covmx::kNearDet, covmx::kQ3)
 
const covmx::Sample kNumuQ3FHCFarDet (covmx::kCCNumu, covmx::kFHC, covmx::kFarDet, covmx::kQ3)
 
const covmx::Sample kNumuQ4FHCNearDet (covmx::kCCNumu, covmx::kFHC, covmx::kNearDet, covmx::kQ4)
 
const covmx::Sample kNumuQ4FHCFarDet (covmx::kCCNumu, covmx::kFHC, covmx::kFarDet, covmx::kQ4)
 
const covmx::Sample kNumuFHCNearDet (covmx::kCCNumu, covmx::kFHC, covmx::kNearDet)
 
const covmx::Sample kNumuFHCFarDet (covmx::kCCNumu, covmx::kFHC, covmx::kFarDet)
 
const covmx::Sample kNumuRHCNearDet (covmx::kCCNumu, covmx::kRHC, covmx::kNearDet)
 
const covmx::Sample kNumuRHCFarDet (covmx::kCCNumu, covmx::kRHC, covmx::kFarDet)
 
bool CheckOption (TString opts, TString opt)
 
template<class T >
T ParseOption (std::vector< std::pair< std::string, T >> opts, TString optString, T def)
 
template<class T >
std::vector< TParseOptions (std::vector< std::pair< std::string, T >> opts, TString optString)
 
std::vector< covmx::SampleGetNumuNDSamples ()
 
std::vector< covmx::SampleGetNumuFDSamples ()
 
std::vector< covmx::SampleGetNumuSamples ()
 
std::vector< covmx::SampleGetNCNDSamples ()
 
std::vector< covmx::SampleGetNCFDSamples ()
 
std::vector< covmx::SampleGetNCSamples ()
 
std::vector< covmx::SampleGetAllSamples ()
 
double GetDefaultPOT (covmx::Sample sample)
 
void SetPOT (covmx::Sample &sample)
 
double GetDefaultLivetime (covmx::Sample sample)
 
void SetLivetime (covmx::Sample &sample)
 
const HistAxisGetDefaultAxis (covmx::Sample sample, double res=0)
 
void SetAxis (covmx::Sample &sample, double res=0)
 
void SetCut (covmx::Sample &sample)
 
void SetCuts (std::vector< covmx::Sample > &samples)
 
covmx::Sample GetSampleFromOptString (TString optString)
 Function to take an option TString and return a single associated covmx::Sample. More...
 
std::vector< covmx::SampleGetSamplesFromOptString (TString optString)
 Function to take an option TString and return a vector of associated covmx::Samples. More...
 
std::vector< bool > GetOptionConfig (TString opt, std::vector< std::string > options)
 
void AssertSupported (covmx::Sample sample)
 
std::unique_ptr< SpectrumLoadCosmic (covmx::Sample sample)
 Get cosmics for a given sample. More...
 
void SetCosmic (covmx::Sample &sample)
 Set cosmics in a given sample. More...
 
void SetInfo (covmx::Sample &sample, double res=0)
 
void SetPrediction (covmx::Sample &sample, bool systs=true)
 
void SetEverything (covmx::Sample &sample, bool systs=false, double res=0)
 
std::string GetSystBaseName (std::string name)
 Get the last part of a systematic's ShortName. More...
 
void SetNus20Params (osc::OscCalcSterile *calc, std::string type="3flav")
 
void SetFakeSignalParams (osc::OscCalcSterile *calc, size_t type)
 
void PrintOscParams (osc::OscCalcSterile *calc)
 
std::vector< const IExperiment * > GetConstraints ()
 Gaussian constraints on atmospheric parameters. More...
 
const IExperimentGetConstraintLoose ()
 Loose Gaussian constraint on atmospheric mass splitting. More...
 
std::vector< Spectrum * > LoadFakeData (std::vector< covmx::Sample > samples, size_t universe, bool systs)
 Load fake data from file. More...
 
TMatrixD PackMatrix (TMatrixD mx)
 
TMatrixD UnpackMatrix (TMatrixD mx)
 

Variables

const double kNux20Dm21 = 7.53e-5
 
const double kNux20Dm32 = 2.60e-3
 
const double kNux20Dm32Sigma = 0.08e-3
 
const double kNux20Dm32LooseSigma = 0.15e-3
 
const double kNux20Th12 = 0.587
 
const double kNux20Th13 = 0.145
 
const double kNux20Th23 = 0.844
 
const double kNux20Th23Sigma = 0.042
 
const double kNux20Delta13 = 1.21*M_PI
 
const double kNux20Delta24 = M_PI/2
 
const double kNux20FHCNDPOT = 11e20
 
const double kNux20FHCFDPOT = kAna2020FHCPOT
 
const double kNux20RHCNDPOT = 11.8e20
 
const double kNux20RHCFDPOT = kAna2020RHCPOT
 
const double kNux20FHCLivetime = kAna2020FHCLivetime
 
const double kNux20RHCLivetime = kAna2020RHCLivetime
 

Function Documentation

void AssertSupported ( covmx::Sample  sample)

Definition at line 463 of file Utilities.h.

References ana::assert(), ana::covmx::kCCNumu, kFHC, ana::covmx::kNC, ana::covmx::Sample::polarity, and ana::covmx::Sample::selection.

463  {
465  or sample.polarity != covmx::Polarity::kFHC) {
466  assert(false and "Nus20 currently only supports up to FHC NC + Numu.");
467  }
468 }
Selection selection
Definition: Sample.h:95
assert(nhit_max >=nhit_nbins)
Polarity polarity
Definition: Sample.h:96
bool CheckOption ( TString  opts,
TString  opt 
)

Definition at line 74 of file Utilities.h.

74  {
75 
76  if (opts.Contains(opt, TString::ECaseCompare::kIgnoreCase))
77  return true;
78  else return false;
79 
80 }
std::vector<covmx::Sample> GetAllSamples ( )

Definition at line 178 of file Utilities.h.

References GetNCSamples(), GetNumuSamples(), runNovaSAM::ret, and tmp.

178  {
179  std::vector<covmx::Sample> ret;
180  for (auto tmp : { GetNumuSamples(), GetNCSamples() }) {
181  ret.insert(ret.end(), tmp.begin(), tmp.end());
182  }
183  return ret;
184 }
std::vector< covmx::Sample > GetNumuSamples()
Definition: Utilities.h:142
Float_t tmp
Definition: plot.C:36
std::vector< covmx::Sample > GetNCSamples()
Definition: Utilities.h:169
const IExperiment* GetConstraintLoose ( )

Loose Gaussian constraint on atmospheric mass splitting.

Definition at line 668 of file Utilities.h.

References ana::kFitDmSq32Sterile, kNux20Dm32, and kNux20Dm32LooseSigma.

Referenced by MakeSurface().

668  {
669 
670  return new const GaussianConstraint(&kFitDmSq32Sterile,
672 
673 }
A simple Gaussian constraint on an arbitrary IFitVar.
const FitDmSq32Sterile kFitDmSq32Sterile
const double kNux20Dm32LooseSigma
Definition: Utilities.h:40
const double kNux20Dm32
Definition: Utilities.h:38
std::vector<const IExperiment*> GetConstraints ( )

Gaussian constraints on atmospheric parameters.

Definition at line 657 of file Utilities.h.

References ana::kFitDmSq32Sterile, ana::kFitTheta23Sterile, kNux20Dm32, kNux20Dm32Sigma, kNux20Th23, kNux20Th23Sigma, and runNovaSAM::ret.

657  {
658 
659  std::vector<const IExperiment*> ret;
661  ret.push_back(new const GaussianConstraint(&kFitDmSq32Sterile, kNux20Dm32, kNux20Dm32Sigma));
662  return ret;
663 
664 }
const double kNux20Th23
Definition: Utilities.h:44
A simple Gaussian constraint on an arbitrary IFitVar.
const FitDmSq32Sterile kFitDmSq32Sterile
const double kNux20Dm32Sigma
Definition: Utilities.h:39
const double kNux20Th23Sigma
Definition: Utilities.h:45
const double kNux20Dm32
Definition: Utilities.h:38
const FitTheta23Sterile kFitTheta23Sterile
const HistAxis* GetDefaultAxis ( covmx::Sample  sample,
double  res = 0 
)

Definition at line 217 of file Utilities.h.

References ana::assert(), bin, ana::bins, om::cout, ana::Binning::Custom(), ana::covmx::Sample::detector, allTimeWatchdog::endl, ana::covmx::Sample::GetName(), ana::covmx::kCCNue, ana::covmx::kCCNumu, ana::covmx::kFarDet, ana::covmx::kNC, ana::kNC20FDAxisE, ana::kNC20NDAxisE, ana::covmx::kNearDet, ana::kNue2020Axis, ana::kNumuCCOptimisedAxis2020, ana::kNus20Energy, next(), and ana::covmx::Sample::selection.

Referenced by SetAxis().

217  {
218 
219  if (sample.selection == covmx::kNC) {
220  if (res != 0) { // Resolution-based binning
221  std::vector<double> bins = { 0.5 };
222  while (true) {
223  double next = (1 + (res/100)) * bins.back();
224  double nextnext = (1 + (res/100)) * next;
225  if (nextnext > 20.) {
226  bins.push_back(20);
227  break;
228  } else {
229  bins.push_back(next);
230  }
231  } // while true
232  std::cout << "Created dynamic binning scheme with resolution " << res << ", and edges:";
233  for (double bin : bins) std::cout << " " << bin;
234  std::cout << endl;
235  return new HistAxis("Energy Deposited in Scintillator (GeV)",
236  Binning::Custom(bins), kNus20Energy);
237  } else {
238  if ( sample.detector == covmx::kNearDet ) return &kNC20NDAxisE;
239  else if ( sample.detector == covmx::kFarDet ) return &kNC20FDAxisE;
240  }
241  }
242  else if (sample.selection == covmx::kCCNumu){
243  return &kNumuCCOptimisedAxis2020;
244  }
245  else if (sample.selection == covmx::kCCNue){
246  return &kNue2020Axis;
247  }
248  else{
249  std::cout << "No default binning for " << sample.GetName() << std::endl;
250  assert(false);
251  }
252  return &kNC20NDAxisE; // moot return to avoid -Wreturn-type non-void warning
253 
254 }
_HistAxis< Var > HistAxis
Definition: HistAxis.h:103
const Var kNus20Energy([](const caf::SRProxy *sr){if(sr->hdr.det!=caf::kNEARDET &&sr->hdr.det!=caf::kFARDET) return(double) sr->slc.calE;double pars[4][6]={{1.049, 0.795, 0.8409, 0.17, 0.82,-1.00},{1.025, 0.797, 0.9162, 0.53,-0.26,-1.48},{1.000, 1.000, 1.0000, 0.00, 0.00, 0.00},{1.000, 1.000, 1.0000, 0.00, 0.00, 0.00}};int detCur=(sr->hdr.det==caf::kFARDET)+((sr->spill.isRHC)<< 1);double e_EM=ana::kEME_2020(sr);double e_Had=ana::kHADE_2020(sr);double e_Cal=sr->slc.calE;return(e_EM/pars[detCur][0]+e_Had/pars[detCur][1])/(pars[detCur][2]+pars[detCur][3]*std::pow(e_Cal+pars[detCur][4], 2)*std::exp(pars[detCur][5]*e_Cal));})
Definition: NusVars.h:64
const HistAxis kNumuCCOptimisedAxis2020("Reconstructed Neutrino Energy (GeV)", kNumuCCEOptimisedBinning, kNumuE2020)
Definition: HistAxes.h:25
const HistAxis kNC20FDAxisE("Energy Deposited in Scintillator (GeV)", kNCFDBinning, kNus20Energy)
Definition: HistAxes.h:21
Selection selection
Definition: Sample.h:95
const HistAxis kNue2020Axis("NuE Energy / Analysis Bin", kNue2020Binning, kNue2020AnaBin)
Use this Axis for Ana2020, official Axis.
Definition: NueCuts2020.h:195
Detector detector
Definition: Sample.h:97
const Binning bins
float bin[41]
Definition: plottest35.C:14
OStream cout
Definition: OStream.cxx:6
const HistAxis kNC20NDAxisE("Energy Deposited in Scintillator (GeV)", kNCNDBinning, kNus20Energy)
NC covariance hist axes.
Definition: HistAxes.h:20
std::string GetName() const
Definition: Sample.cxx:72
assert(nhit_max >=nhit_nbins)
void next()
Definition: show_event.C:84
double GetDefaultLivetime ( covmx::Sample  sample)

Definition at line 203 of file Utilities.h.

References ana::covmx::Sample::detector, ana::covmx::kFHC, ana::covmx::kNearDet, kNux20FHCLivetime, kNux20RHCLivetime, and ana::covmx::Sample::polarity.

Referenced by SetLivetime().

203  {
204  if (sample.detector == covmx::kNearDet) return -1; // no livetime at ND
205  else {
206  if (sample.polarity == covmx::kFHC) return kNux20FHCLivetime;
207  else return kNux20RHCLivetime;
208  }
209 }
const double kNux20RHCLivetime
Definition: Utilities.h:55
const double kNux20FHCLivetime
Definition: Utilities.h:54
Detector detector
Definition: Sample.h:97
Polarity polarity
Definition: Sample.h:96
double GetDefaultPOT ( covmx::Sample  sample)

Definition at line 187 of file Utilities.h.

References ana::covmx::Sample::detector, ana::covmx::kFHC, ana::covmx::kNearDet, kNux20FHCFDPOT, kNux20FHCNDPOT, kNux20RHCFDPOT, kNux20RHCNDPOT, and ana::covmx::Sample::polarity.

Referenced by SetPOT().

187  {
188  if (sample.detector == covmx::kNearDet) {
189  if (sample.polarity == covmx::kFHC) return kNux20FHCNDPOT;
190  else return kNux20RHCNDPOT;
191  } else {
192  if (sample.polarity == covmx::kFHC) return kNux20FHCFDPOT;
193  else return kNux20RHCFDPOT;
194  }
195 }
const double kNux20RHCNDPOT
Definition: Utilities.h:52
const double kNux20RHCFDPOT
Definition: Utilities.h:53
const double kNux20FHCFDPOT
Definition: Utilities.h:51
Detector detector
Definition: Sample.h:97
Polarity polarity
Definition: Sample.h:96
const double kNux20FHCNDPOT
Definition: Utilities.h:50
std::vector<covmx::Sample> GetNCFDSamples ( )

Definition at line 160 of file Utilities.h.

References ana::covmx::kFarDet, ana::covmx::kFHC, ana::covmx::kNC, ana::covmx::kRHC, and runNovaSAM::ret.

Referenced by GetNCSamples().

160  {
161  std::vector<covmx::Sample> ret;
163  ret.push_back(covmx::Sample(covmx::kNC, p, covmx::kFarDet));
164  }
165  return ret;
166 }
const char * p
Definition: xmltok.h:285
std::vector<covmx::Sample> GetNCNDSamples ( )

Definition at line 151 of file Utilities.h.

References ana::covmx::kFHC, ana::covmx::kNC, ana::covmx::kNearDet, ana::covmx::kRHC, and runNovaSAM::ret.

Referenced by GetNCSamples().

151  {
152  std::vector<covmx::Sample> ret;
154  ret.push_back(covmx::Sample(covmx::kNC, p, covmx::kNearDet));
155  }
156  return ret;
157 }
const char * p
Definition: xmltok.h:285
std::vector<covmx::Sample> GetNCSamples ( )

Definition at line 169 of file Utilities.h.

References GetNCFDSamples(), GetNCNDSamples(), runNovaSAM::ret, and tmp.

Referenced by GetAllSamples().

169  {
170  std::vector<covmx::Sample> ret;
171  for (auto tmp : { GetNCNDSamples(), GetNCFDSamples() }) {
172  ret.insert(ret.end(), tmp.begin(), tmp.end());
173  }
174  return ret;
175 }
std::vector< covmx::Sample > GetNCFDSamples()
Definition: Utilities.h:160
Float_t tmp
Definition: plot.C:36
std::vector< covmx::Sample > GetNCNDSamples()
Definition: Utilities.h:151
std::vector<covmx::Sample> GetNumuFDSamples ( )

Definition at line 131 of file Utilities.h.

References ana::covmx::kCCNumu, ana::covmx::kFarDet, ana::covmx::kFHC, ana::covmx::kQ1, ana::covmx::kQ2, ana::covmx::kQ3, ana::covmx::kQ4, ana::covmx::kRHC, and runNovaSAM::ret.

Referenced by GetNumuSamples().

131  {
132  std::vector<covmx::Sample> ret;
135  ret.push_back(covmx::Sample(covmx::kCCNumu, p, covmx::kFarDet, q));
136  }
137  }
138  return ret;
139 }
const char * p
Definition: xmltok.h:285
std::vector<covmx::Sample> GetNumuNDSamples ( )

Definition at line 120 of file Utilities.h.

References ana::covmx::kCCNumu, ana::covmx::kFHC, ana::covmx::kNearDet, ana::covmx::kQ1, ana::covmx::kQ2, ana::covmx::kQ3, ana::covmx::kQ4, ana::covmx::kRHC, and runNovaSAM::ret.

Referenced by GetNumuSamples().

120  {
121  std::vector<covmx::Sample> ret;
124  ret.push_back(covmx::Sample(covmx::kCCNumu, p, covmx::kNearDet, q));
125  }
126  }
127  return ret;
128 }
const char * p
Definition: xmltok.h:285
std::vector<covmx::Sample> GetNumuSamples ( )

Definition at line 142 of file Utilities.h.

References GetNumuFDSamples(), GetNumuNDSamples(), runNovaSAM::ret, and tmp.

Referenced by GetAllSamples(), and ValidatePredictions().

142  {
143  std::vector<covmx::Sample> ret;
144  for (auto tmp : { GetNumuNDSamples(), GetNumuFDSamples() }) {
145  ret.insert(ret.end(), tmp.begin(), tmp.end());
146  }
147  return ret;
148 }
std::vector< covmx::Sample > GetNumuNDSamples()
Definition: Utilities.h:120
Float_t tmp
Definition: plot.C:36
std::vector< covmx::Sample > GetNumuFDSamples()
Definition: Utilities.h:131
std::vector<bool> GetOptionConfig ( TString  opt,
std::vector< std::string options 
)

Definition at line 432 of file Utilities.h.

References CheckOption(), om::cout, allTimeWatchdog::endl, MECModelEnuComparisons::i, string, and registry_explorer::v.

432  {
433 
434  size_t n_opts = options.size();
435 
436  std::vector<bool> vec(n_opts);
437  for (size_t i = 0; i < n_opts; ++i)
438  if (CheckOption(opt, options[i]))
439  vec[i] = true;
440 
441  if (std::none_of(vec.begin(), vec.end(), [](bool v) { return v; })) {
442  std::string err = "Option string must contain ";
443  for (size_t i = 0; i < n_opts-2; ++i)
444  err += "\"" + options[i] + "\", ";
445  err += options[n_opts-2] + " or " + options[n_opts-1] + ".";
446  throw std::runtime_error(err);
447  }
448 
449  else {
450  std::cout << "Running for";
451  for (size_t i = 0; i < n_opts; ++i)
452  if (vec[i])
453  std::cout << " " << options[i];
454  std::cout << std::endl;
455  }
456 
457  return vec;
458 
459 } // function GetOptionConfig
bool CheckOption(TString opts, TString opt)
Definition: Utilities.h:47
Eigen::VectorXd vec
OStream cout
Definition: OStream.cxx:6
enum BeamMode string
covmx::Sample GetSampleFromOptString ( TString  optString)

Function to take an option TString and return a single associated covmx::Sample.

Definition at line 344 of file Utilities.h.

References fillBadChanDBTables::det, ana::covmx::kCCNue, ana::covmx::kCCNumu, ana::covmx::kFarDet, ana::covmx::kFHC, ana::covmx::kNC, ana::covmx::kNearDet, ana::covmx::kNoDet, ana::covmx::kNoPol, ana::covmx::kNoQ, ana::covmx::kNoSel, ana::covmx::kQ1, ana::covmx::kQ2, ana::covmx::kQ3, ana::covmx::kQ4, ana::covmx::kRHC, and runNovaSAM::ret.

Referenced by MakeCosmicSpectra(), MakeISysts(), MakePrediction(), MakePredictionNoOsc_FHC_FD(), MakePredictionNoOsc_FHC_ND(), MakePredictionNoOsc_RHC_FD(), MakePredictionNoOsc_RHC_ND(), MakeSysts(), MakeSystsPDF(), and MergePredictions().

344  {
345 
346  // Get selection
347  std::vector<std::pair<std::string, covmx::Selection>> selOpts
348  = { {"nuesel", covmx::kCCNue}, {"numusel", covmx::kCCNumu}, {"ncsel", covmx::kNC} };
349  covmx::Selection sel = ParseOption<covmx::Selection>(selOpts, optString, covmx::kNoSel);
350  // Get polarity
351  std::vector<std::pair<std::string, covmx::Polarity>> polOpts
352  = { {"fhc", covmx::kFHC}, {"rhc", covmx::kRHC } };
353  covmx::Polarity pol = ParseOption<covmx::Polarity>(polOpts, optString, covmx::kNoPol);
354  // Get detector
355  std::vector<std::pair<std::string, covmx::Detector>> detOpts
356  = { {"neardet", covmx::kNearDet}, {"fardet", covmx::kFarDet} };
357  covmx::Detector det = ParseOption<covmx::Detector>(detOpts, optString, covmx::kNoDet);
358  // Define sample
359  covmx::Sample ret(sel, pol, det);
360  // Get quantile if applicable
361  if (sel == covmx::kCCNumu) {
362  std::vector<std::pair<std::string, covmx::Quantile>> qOpts
363  = { {"q0", covmx::kQ1}, {"q1", covmx::kQ2}, {"q2", covmx::kQ3}, {"q3", covmx::kQ4} };
364  covmx::Quantile q = ParseOption<covmx::Quantile>(qOpts, optString, covmx::kNoQ);
365  ret.quantile = q;
366  }
367  return ret;
368 
369 } // function GetSampleFromOptString
std::vector<covmx::Sample> GetSamplesFromOptString ( TString  optString)

Function to take an option TString and return a vector of associated covmx::Samples.

Definition at line 373 of file Utilities.h.

References om::cout, fillBadChanDBTables::det, msf_helper::dets, allTimeWatchdog::endl, ana::covmx::kCCNue, ana::covmx::kCCNumu, ana::covmx::kFarDet, ana::covmx::kFHC, ana::covmx::kNC, ana::covmx::kNearDet, ana::covmx::kQ1, ana::covmx::kQ2, ana::covmx::kQ3, ana::covmx::kQ4, ana::covmx::kRHC, quantiles(), runNovaSAM::ret, ana::sels, SetAxis(), SetLivetime(), and SetPOT().

Referenced by DrawCovMx(), GenerateCovMx(), GetConfig(), MakeCovMx(), MakeFakeData(), MakePlots(), SaveSpectrum(), ScaleCovarianceMatrix(), and TestCovMxNew().

373  {
374 
375  // Get selections
376  std::vector<std::pair<std::string, covmx::Selection>> selOpts
377  = { {"nuesel", covmx::kCCNue}, {"numusel", covmx::kCCNumu}, {"ncsel", covmx::kNC} };
378  std::vector<covmx::Selection> sels
379  = ParseOptions<covmx::Selection>(selOpts, optString);
380  // Get polarities
381  std::vector<std::pair<std::string, covmx::Polarity>> polOpts
382  = { {"fhc", covmx::kFHC}, {"rhc", covmx::kRHC } };
383  std::vector<covmx::Polarity> pols
384  = ParseOptions<covmx::Polarity>(polOpts, optString);
385  // Get detectors
386  std::vector<std::pair<std::string, covmx::Detector>> detOpts
387  = { {"neardet", covmx::kNearDet}, {"fardet", covmx::kFarDet} };
388  std::vector<covmx::Detector> dets
389  = ParseOptions<covmx::Detector>(detOpts, optString);
390  bool quantiles = optString.Contains("quantiles");
391  // Check for optional no-quantile config
392  // std::vector<std::pair<std::string, covmx::Quantile>> qOpts
393  // = { {"noquantiles", covmx::kNoQ}, {"q0", covmx::kQ1}, {"q1", covmx::kQ2},
394  // {"q2", covmx::kQ3}, {"q3", covmx::kQ4} };
395  // std::vector<covmx::Quantile> quantiles
396  // = ParseOptions<covmx::Quantile>(qOpts, optString);
397 
398  // Loop over samples and add to vector
399  std::vector<covmx::Sample> ret;
400  for (covmx::Selection sel : sels) {
401  for (covmx::Polarity pol : pols) {
402  for (covmx::Detector det : dets) {
403  // If it's numu, add all the quantiles unless configured for no quantiles
404  if (sel == covmx::kCCNumu && quantiles) {
405  // if (quantiles.empty()) {
406  // ret.push_back(covmx::Sample(sel, pol, det, covmx::kNoQ));
407  // } else {
409  ret.push_back(covmx::Sample(sel, pol, det, q));
410  }
411  // }
412  }
413  else {
414  ret.push_back(covmx::Sample(sel, pol, det));
415  }
416  } // for detector
417  } // for polarity
418  } // for selection
419 
420  std::cout << "Samples: " << std::endl;
421  for(auto& s : ret){
422  SetAxis(s);
423  SetPOT(s);
424  SetLivetime(s);
425  std::cout << s.GetTag() << " (" << s.GetBinning().NBins() << " bins)" << std::endl;
426  }
427  return ret;
428 
429 } // function GetSampleFromOptString
std::vector< double > quantiles(TH1D *h)
Definition: absCal.cxx:528
void SetPOT(covmx::Sample &sample)
Definition: Utilities.h:198
const XML_Char * s
Definition: expat.h:262
const Cut sels[kNumSels]
Definition: vars.h:44
void SetLivetime(covmx::Sample &sample)
Definition: Utilities.h:212
OStream cout
Definition: OStream.cxx:6
void SetAxis(covmx::Sample &sample, double res=0)
Definition: Utilities.h:257
std::string GetSystBaseName ( std::string  name)

Get the last part of a systematic's ShortName.

Definition at line 535 of file Utilities.h.

References elec2geo::pos.

535  {
536 
537  size_t pos = name.find("_");
538  if (pos == std::string::npos) return name;
539 
540  while (pos != std::string::npos) {
541  size_t tmppos = name.find("_", pos+1);
542  if (tmppos == std::string::npos) break;
543  pos = tmppos;
544  }
545 
546  return name.substr(pos+1);
547 
548 } // function GetSystBaseName
const XML_Char * name
Definition: expat.h:151
const covmx::Sample kNumuFHCFarDet ( covmx::kCCNumu  ,
covmx::kFHC  ,
covmx::kFarDet   
)
const covmx::Sample kNumuFHCNearDet ( covmx::kCCNumu  ,
covmx::kFHC  ,
covmx::kNearDet   
)
const covmx::Sample kNumuQ1FHCFarDet ( covmx::kCCNumu  ,
covmx::kFHC  ,
covmx::kFarDet  ,
covmx::kQ1   
)
const covmx::Sample kNumuQ1FHCNearDet ( covmx::kCCNumu  ,
covmx::kFHC  ,
covmx::kNearDet  ,
covmx::kQ1   
)
const covmx::Sample kNumuQ2FHCFarDet ( covmx::kCCNumu  ,
covmx::kFHC  ,
covmx::kFarDet  ,
covmx::kQ2   
)
const covmx::Sample kNumuQ2FHCNearDet ( covmx::kCCNumu  ,
covmx::kFHC  ,
covmx::kNearDet  ,
covmx::kQ2   
)
const covmx::Sample kNumuQ3FHCFarDet ( covmx::kCCNumu  ,
covmx::kFHC  ,
covmx::kFarDet  ,
covmx::kQ3   
)
const covmx::Sample kNumuQ3FHCNearDet ( covmx::kCCNumu  ,
covmx::kFHC  ,
covmx::kNearDet  ,
covmx::kQ3   
)
const covmx::Sample kNumuQ4FHCFarDet ( covmx::kCCNumu  ,
covmx::kFHC  ,
covmx::kFarDet  ,
covmx::kQ4   
)
const covmx::Sample kNumuQ4FHCNearDet ( covmx::kCCNumu  ,
covmx::kFHC  ,
covmx::kNearDet  ,
covmx::kQ4   
)
const covmx::Sample kNumuRHCFarDet ( covmx::kCCNumu  ,
covmx::kRHC  ,
covmx::kFarDet   
)
const covmx::Sample kNumuRHCNearDet ( covmx::kCCNumu  ,
covmx::kRHC  ,
covmx::kNearDet   
)
const covmx::Sample kNusFHCFarDet ( covmx::kNC  ,
covmx::kFHC  ,
covmx::kFarDet   
)
const covmx::Sample kNusFHCNearDet ( covmx::kNC  ,
covmx::kFHC  ,
covmx::kNearDet   
)
std::unique_ptr<Spectrum> LoadCosmic ( covmx::Sample  sample)

Get cosmics for a given sample.

Definition at line 472 of file Utilities.h.

References ana::covmx::Sample::detector, MakeMiniprodValidationCuts::f, shutoffs::filename, ana::covmx::Sample::GetTag(), ana::InputPath(), ana::covmx::kNearDet, ana::Spectrum::LoadFrom(), runNovaSAM::ret, and string.

472  {
473 
474  DontAddDirectory guard;
475 
476  // No cosmics for ND
477  if (sample.detector == covmx::kNearDet)
478  return nullptr;
479 
480  std::string filename = InputPath() + "/cosmics/cosmics.root";
481  TFile* f = TFile::Open(filename.c_str(), "read");
482  auto ret = Spectrum::LoadFrom(f, sample.GetTag());
483  delete f;
484  return ret;
485 
486 } // function LoadCosmic
std::string GetTag() const
Definition: Sample.cxx:94
string filename
Definition: shutoffs.py:106
std::unique_ptr< T > LoadFrom(TDirectory *dir, const std::string &label)
Definition: LoadFromFile.h:17
Detector detector
Definition: Sample.h:97
string InputPath()
Definition: Utilities.cxx:12
Prevent histograms being added to the current directory.
Definition: UtilsExt.h:46
enum BeamMode string
std::vector<Spectrum*> LoadFakeData ( std::vector< covmx::Sample samples,
size_t  universe,
bool  systs 
)

Load fake data from file.

Definition at line 677 of file Utilities.h.

References dir, MakeMiniprodValidationCuts::f, make_cached_def::filepath, MECModelEnuComparisons::i, ana::InputPath(), ana::Spectrum::LoadFrom(), runNovaSAM::ret, and string.

679 {
680  DontAddDirectory guard;
681  std::vector<Spectrum*> ret(samples.size());
682 
683  std::string filepath = InputPath() + "/fakedata/FakeData" + (systs ? "Systs" : "Stats") + ".root";
684  //if (not cvmfs) filepath = pnfs2xrootd(filepath);
685  TFile* f = TFile::Open(filepath.c_str(), "read");
686 
687  // Get universe and spectra
688  TDirectory* dir = f->GetDirectory(Form("universe_%zu", universe));
689  for (size_t i = 0; i < ret.size(); ++i) {
690  ret[i] = Spectrum::LoadFrom(dir, samples[i].GetTag()).release();
691  }
692  return ret;
693 
694 } // function LoadFakeData
std::vector< SystGroupDef > systs
Definition: syst_header.h:385
std::unique_ptr< T > LoadFrom(TDirectory *dir, const std::string &label)
Definition: LoadFromFile.h:17
string InputPath()
Definition: Utilities.cxx:12
TDirectory * dir
Definition: macro.C:5
Prevent histograms being added to the current directory.
Definition: UtilsExt.h:46
enum BeamMode string
TMatrixD PackMatrix ( TMatrixD  mx)

Definition at line 828 of file Utilities.h.

References ana::bins, MECModelEnuComparisons::i, calib::j, ana::kNCFDBinning, ana::kNCNDBinning, ana::Binning::NBins(), ndComps, and runNovaSAM::ret.

828  {
829 
830  size_t mxSize = mx.GetNrows();
831  size_t nComps = 13; // if this is a hardcoded hack, may as well go all in
832  std::vector<Binning> bins = { kNCNDBinning, kNCFDBinning };
833  size_t nSamples = bins.size();
834  size_t nBinsPerComp = kNCNDBinning.NBins() + kNCFDBinning.NBins();
835  std::vector<size_t> ndComps = { 0, 1, 8, 9, 12 };
836  size_t mxPackedSize = mxSize - ((8*bins[0].NBins())+1);
837  TMatrixD ret(mxPackedSize, mxPackedSize);
838  ret.Zero();
839  size_t iPack = 0;
840  // Loop over all components, samples, bins
841  for (size_t iComp = 0; iComp < nComps; ++iComp) {
842  for (size_t iSample = 0; iSample < nSamples; ++iSample) {
843  // If we're in an ND flux swap component, throw it away
844  if (iSample == 0 && std::find(ndComps.begin(), ndComps.end(), iComp) == ndComps.end()) {
845  // std::cout << "Skipping component " << iComp << ", sample " << iSample << std::endl;
846  continue;
847  }
848  for (size_t iBin = 0; iBin < (size_t)bins[iSample].NBins(); ++iBin) {
849  size_t i = (iComp*nBinsPerComp) + (iSample*kNCNDBinning.NBins()) + iBin;
850  if (i == 124) continue; // awful hack to remove problem bin
851  size_t jPack = 0;
852  for (size_t jComp = 0; jComp < nComps; ++jComp) {
853  for (size_t jSample = 0; jSample < nSamples; ++jSample) {
854  // If we're in an ND flux swap component, throw it away
855  if (jSample == 0 && std::find(ndComps.begin(), ndComps.end(), jComp) == ndComps.end()) {
856  // std::cout << "Skipping component " << jComp << ", sample " << jSample << std::endl;
857  continue;
858  }
859  for (size_t jBin = 0; jBin < (size_t)bins[jSample].NBins(); ++jBin) {
860  size_t j = (jComp*nBinsPerComp) + (jSample*kNCNDBinning.NBins()) + jBin;
861  if (j == 124) continue; // awful hack to remove problem bin
862  ret(iPack,jPack) = mx(i,j);
863  ++jPack;
864  } // for bin j
865  } // for sample j
866  } // for component j
867  ++iPack;
868  } // for bin i
869  } // for sample i
870  } // for component i
871 
872  return ret;
873 
874 } // function PackMatrix
const std::vector< std::string > ndComps
Definition: TestCovMxNew.C:12
const double j
Definition: BetheBloch.cxx:29
const Binning bins
const Binning kNCNDBinning
NC custom binning.
Definition: Binning.cxx:104
int NBins() const
Definition: Binning.h:29
const Binning kNCFDBinning
Definition: Binning.cxx:105
template<class T >
T ParseOption ( std::vector< std::pair< std::string, T >>  opts,
TString  optString,
T  def 
)

Definition at line 84 of file Utilities.h.

References ana::assert(), om::cerr, allTimeWatchdog::endl, MECModelEnuComparisons::opt, plot_validation_datamc::opts, runNovaSAM::ret, and T.

84  {
85 
86  T ret = def;
87  size_t nOpts = 0;
88  for (auto opt : opts) {
89  if (optString.Contains(opt.first.c_str(), TString::kIgnoreCase)) {
90  ++nOpts;
91  ret = opt.second;
92  }
93  }
94  if (nOpts > 1) {
95  std::ostringstream err;
96  err << "Option string must include one of: ";
97  for (auto opt : opts) err << "\"" << opt.first << "\", ";
98  std::cerr << err.str().substr(0, err.str().size()-2) << std::endl;
99  assert(false);
100  }
101  return ret;
102 
103 } // template function ParseOption
OStream cerr
Definition: OStream.cxx:7
assert(nhit_max >=nhit_nbins)
double T
Definition: Xdiff_gwt.C:5
template<class T >
std::vector<T> ParseOptions ( std::vector< std::pair< std::string, T >>  opts,
TString  optString 
)

Definition at line 107 of file Utilities.h.

References MECModelEnuComparisons::opt, plot_validation_datamc::opts, and runNovaSAM::ret.

107  {
108 
109  std::vector<T> ret;
110  for (auto opt : opts) {
111  if (optString.Contains(opt.first.c_str(), TString::kIgnoreCase)) {
112  ret.push_back(opt.second);
113  }
114  }
115  return ret;
116 
117 } // template function ParseOption
void PrintOscParams ( osc::OscCalcSterile calc)

Definition at line 639 of file Utilities.h.

References om::cout, allTimeWatchdog::endl, osc::OscCalcSterile::GetAngle(), osc::OscCalcSterile::GetDelta(), and osc::OscCalcSterile::GetDm().

639  {
640 
641  std::cout << "---------- OSCILLATION PARAMETERS ----------" << std::endl
642  << "Dm21: " << calc->GetDm(2) << std::endl
643  << "Dm31: " << calc->GetDm(3) << std::endl
644  << "Dm41: " << calc->GetDm(4) << std::endl
645  << "Theta 13: " << calc->GetAngle(1, 3) << std::endl
646  << "Theta 23: " << calc->GetAngle(2, 3) << std::endl
647  << "Theta 14: " << calc->GetAngle(1, 4) << std::endl
648  << "Theta 24: " << calc->GetAngle(2, 4) << std::endl
649  << "Theta 34: " << calc->GetAngle(3, 4) << std::endl
650  << "Delta 13: " << calc->GetDelta(1, 3) << std::endl
651  << "Delta 24: " << calc->GetDelta(2, 4) << std::endl
652  << "--------------------------------------------" << std::endl;
653 }
double GetDelta(int i, int j) const
OStream cout
Definition: OStream.cxx:6
double GetDm(int i) const
double GetAngle(int i, int j) const
void SetAxis ( covmx::Sample sample,
double  res = 0 
)

Definition at line 257 of file Utilities.h.

References GetDefaultAxis(), and ana::covmx::Sample::SetAxis().

Referenced by GetSamplesFromOptString(), and SetInfo().

257  {
258  sample.SetAxis(GetDefaultAxis(sample, res));
259 }
void SetAxis(const HistAxis *a)
Definition: Sample.h:50
const HistAxis * GetDefaultAxis(covmx::Sample sample, double res=0)
Definition: Utilities.h:217
void SetCosmic ( covmx::Sample sample)

Set cosmics in a given sample.

Definition at line 490 of file Utilities.h.

References LoadCosmic(), runNovaSAM::release, and ana::covmx::Sample::SetCosmic().

Referenced by MakeFakeData(), MakeSurface(), and SaveSpectrum().

490  {
491 
492  sample.SetCosmic(LoadCosmic(sample).release());
493 
494 } // function LoadCosmic
void SetCosmic(Spectrum *s)
Definition: Sample.cxx:108
std::unique_ptr< Spectrum > LoadCosmic(covmx::Sample sample, bool cvmfs=true)
Get cosmics for a given sample.
Definition: Utilities.h:145
void SetCut ( covmx::Sample sample)

Definition at line 263 of file Utilities.h.

References ana::covmx::Sample::detector, cet::getenv(), ana::covmx::Sample::GetPolarity(), infile, ana::covmx::kCCNue, ana::covmx::kCCNumu, ana::kHadEFracAxis, ana::covmx::kNC, ana::covmx::kNearDet, ana::covmx::kNoQ, ana::kNue2020FDAllSamples_ML, ana::kNue2020ND, ana::kNumu2020FD_ML, ana::kNumu2020ND, ana::kNumuCCOptimisedAxis2020, ana::kNus20FDCuts_ML, ana::kNus20NDCuts, ana::pnfs2xrootd(), ana::covmx::Sample::quantile, ana::QuantileCutsFromTH2(), ana::covmx::Sample::selection, ana::covmx::Sample::SetCut(), and string.

Referenced by MakeCosmicSpectra(), MakePrediction(), MakePredictionNoOsc_FHC_FD(), MakePredictionNoOsc_FHC_ND(), MakePredictionNoOsc_RHC_FD(), MakePredictionNoOsc_RHC_ND(), and SetInfo().

263  {
264 
265  // Neutral current cuts
266  if (sample.selection == covmx::kNC) {
267  if (sample.detector == covmx::kNearDet) sample.SetCut(&kNus20NDCuts);
268  else sample.SetCut(&kNus20FDCuts_ML);
269  }
270 
271  else if (sample.selection == covmx::kCCNue) {
272  if (sample.detector == covmx::kNearDet) sample.SetCut(&kNue2020ND);
273  else sample.SetCut(&kNue2020FDAllSamples_ML);
274  }
275 
276  else if (sample.selection == covmx::kCCNumu) {
277  if (sample.quantile == covmx::kNoQ) {
278  if (sample.detector == covmx::kNearDet) sample.SetCut(&kNumu2020ND);
279  else sample.SetCut(&kNumu2020FD_ML);
280  } else {
281  std::string quantDir = std::getenv("NUMUDATA_DIR");
282  std::string infileQuant = quantDir + "/lib/ana2020/Quantiles/quantiles_" + sample.GetPolarity() + "_full_numu2020.root";
283  TFile* infile = TFile::Open( pnfs2xrootd(infileQuant).c_str() );
284  TH2* spec2DFD = (TH2*)infile->FindObjectAny("FDSpec2D");
285  std::vector<Cut> HadEFracQuantCuts = QuantileCutsFromTH2(spec2DFD, kNumuCCOptimisedAxis2020, kHadEFracAxis, 4);
286  infile->Close();
287  if (sample.detector == covmx::kNearDet) {
288  sample.SetCut(new const Cut(kNumu2020ND && HadEFracQuantCuts[sample.quantile]));
289  } else {
290  sample.SetCut(new const Cut(kNumu2020FD_ML && HadEFracQuantCuts[sample.quantile]));
291  }
292  } // if using quantiles
293  } // numu selection
294 
295 } // function SetCut
const HistAxis kHadEFracAxis("E_{had.} / E_{#nu}", Binning::Simple(200, 0, 1), kHadEFrac)
HistAxis that implements Hadronic Energy fraction binning used by L.Vinton to derive Hadronic Energy ...
Definition: HistAxes.h:30
const Cut kNumu2020ND
Definition: NumuCuts2020.h:57
std::string pnfs2xrootd(std::string loc, bool unauth)
Definition: UtilsExt.cxx:237
const HistAxis kNumuCCOptimisedAxis2020("Reconstructed Neutrino Energy (GeV)", kNumuCCEOptimisedBinning, kNumuE2020)
Definition: HistAxes.h:25
const Cut kNue2020ND
Definition: NueCuts2020.h:178
void SetCut(const Cut *c)
Definition: Sample.h:51
const Cut kNus20NDCuts
Definition: NusCuts20.h:102
std::string GetPolarity() const
Definition: Sample.cxx:52
void Cut(double x)
Definition: plot_outliers.C:1
string infile
std::string getenv(std::string const &name)
Selection selection
Definition: Sample.h:95
Detector detector
Definition: Sample.h:97
Quantile quantile
Definition: Sample.h:98
std::vector< Cut > QuantileCutsFromTH2(TH2 *quantileHist, const HistAxis &independentAxis, const HistAxis &quantileAxis, const unsigned int &numQuantiles, const bool verbose)
: Do the same as the QuantileCuts function but taking in the TH2 instead of making it...
const Cut kNue2020FDAllSamples_ML
const Cut kNus20FDCuts_ML
const Cut kNumu2020FD_ML
enum BeamMode string
void SetCuts ( std::vector< covmx::Sample > &  samples)

Definition at line 298 of file Utilities.h.

References cet::getenv(), infile, ana::covmx::kCCNue, ana::covmx::kCCNumu, ana::kHadEFracAxis, ana::covmx::kNC, ana::covmx::kNearDet, ana::covmx::kNoQ, ana::kNue2020FDAllSamples_ML, ana::kNue2020ND, ana::kNumu2020FD_ML, ana::kNumu2020ND, ana::kNumuCCOptimisedAxis2020, ana::kNus20FDCuts_ML, ana::kNus20NDCuts, ana::pnfs2xrootd(), ana::QuantileCutsFromTH2(), and string.

Referenced by ana::SystMaker::GetNominal(), and ana::SystematicsMaker::GetSystMakers().

298  {
299 
300  // Instantiate this once so we can reuse it if necessary without reloading
301  std::vector<Cut> HadEFracQuantCuts;
302 
303  for (covmx::Sample& sample : samples) {
304 
305  // Neutral current cuts
306 
307  if (sample.selection == covmx::kNC) {
308  if (sample.detector == covmx::kNearDet) sample.SetCut(&kNus20NDCuts);
309  else sample.SetCut(&kNus20FDCuts_ML);
310  }
311 
312  else if (sample.selection == covmx::kCCNue) {
313  if (sample.detector == covmx::kNearDet) sample.SetCut(&kNue2020ND);
314  else sample.SetCut(&kNue2020FDAllSamples_ML);
315  }
316 
317  else if (sample.selection == covmx::kCCNumu) {
318  if (sample.quantile == covmx::kNoQ) {
319  if (sample.detector == covmx::kNearDet) sample.SetCut(&kNumu2020ND);
320  else sample.SetCut(&kNumu2020FD_ML);
321  } else {
322  if (HadEFracQuantCuts.size() == 0) { // Load quantiles
323  std::string quantDir = std::getenv("NUMUDATA_DIR");
324  std::string infileQuant = quantDir + "/lib/ana2020/Quantiles/quantiles_" + sample.GetPolarity() + "_full_numu2020.root";
325  TFile* infile = TFile::Open( pnfs2xrootd(infileQuant).c_str() );
326  TH2* spec2DFD = (TH2*)infile->FindObjectAny("FDSpec2D");
327  HadEFracQuantCuts = QuantileCutsFromTH2(spec2DFD, kNumuCCOptimisedAxis2020, kHadEFracAxis, 4);
328  infile->Close();
329  }
330 
331  if (sample.detector == covmx::kNearDet) {
332  sample.SetCut(new const Cut(kNumu2020ND && HadEFracQuantCuts[sample.quantile]));
333  } else {
334  sample.SetCut(new const Cut(kNumu2020FD_ML && HadEFracQuantCuts[sample.quantile]));
335  }
336  } // if using quantiles
337  } // numu selection
338  } // for sample
339 
340 } // function SetCuts
const HistAxis kHadEFracAxis("E_{had.} / E_{#nu}", Binning::Simple(200, 0, 1), kHadEFrac)
HistAxis that implements Hadronic Energy fraction binning used by L.Vinton to derive Hadronic Energy ...
Definition: HistAxes.h:30
const Cut kNumu2020ND
Definition: NumuCuts2020.h:57
std::string pnfs2xrootd(std::string loc, bool unauth)
Definition: UtilsExt.cxx:237
const HistAxis kNumuCCOptimisedAxis2020("Reconstructed Neutrino Energy (GeV)", kNumuCCEOptimisedBinning, kNumuE2020)
Definition: HistAxes.h:25
const Cut kNue2020ND
Definition: NueCuts2020.h:178
const Cut kNus20NDCuts
Definition: NusCuts20.h:102
void Cut(double x)
Definition: plot_outliers.C:1
string infile
std::string getenv(std::string const &name)
std::vector< Cut > QuantileCutsFromTH2(TH2 *quantileHist, const HistAxis &independentAxis, const HistAxis &quantileAxis, const unsigned int &numQuantiles, const bool verbose)
: Do the same as the QuantileCuts function but taking in the TH2 instead of making it...
const Cut kNue2020FDAllSamples_ML
const Cut kNus20FDCuts_ML
const Cut kNumu2020FD_ML
enum BeamMode string
void SetEverything ( covmx::Sample sample,
bool  systs = false,
double  res = 0 
)

Definition at line 527 of file Utilities.h.

References ana::getNusAna2020AllSysts(), SetInfo(), SetPrediction(), and systs.

Referenced by DrawCovMx(), MakeFakeData(), MakePlots(), and ValidatePredictions().

527  {
528  SetInfo(sample, res);
529  getNusAna2020AllSysts(sample);
530  SetPrediction(sample, systs);
531 }
std::vector< SystGroupDef > systs
Definition: syst_header.h:385
vector< const ISyst * > getNusAna2020AllSysts(covmx::Sample &s)
void SetPrediction(covmx::Sample &sample, bool systs=true)
Definition: Utilities.h:505
void SetInfo(covmx::Sample &sample, double res=0)
Definition: Utilities.h:497
void SetFakeSignalParams ( osc::OscCalcSterile calc,
size_t  type 
)

Definition at line 616 of file Utilities.h.

References osc::OscCalcSterile::SetAngle(), osc::OscCalcSterile::SetDm(), SetNus20Params(), and ana::Sqrt().

Referenced by MakeSurfaceBinningStudy().

616  {
617 
618  SetNus20Params(calc); // Start with nominal parameters always
619 
620  if (type == 1 || type == 2) { // fake signal 1 & 2: MiniBooNE sterile parameters
621  Double_t dm41 = 0.041;
622  Double_t theta_24 = TMath::ASin(TMath::Sqrt(0.9580));
623  Double_t theta_34 = TMath::ASin(TMath::Sqrt(0.9580));
624  calc->SetDm(4, dm41);
625  calc->SetAngle(2, 4, theta_24);
626  calc->SetAngle(3, 4, theta_34);
627  } else if (type == 3) {
628  return; // Use nominal parameters for this set!
629  } else { // Throw an error if fake signal type not recognised.
630  std::ostringstream err;
631  err << "Error in SetFakeSignalParams! Invalid fake signal set "
632  << type << " was requested!";
633  throw std::runtime_error(err.str());
634  }
635 
636 } // function SetFakeSignalParams
void SetNus20Params(osc::OscCalcSterile *calc, std::string type="3flav")
Definition: Utilities.h:551
void SetAngle(int i, int j, double th)
void SetDm(int i, double dm)
Var Sqrt(const Var &v)
Use to take sqrt of a var.
Definition: Var.cxx:326
void SetInfo ( covmx::Sample sample,
double  res = 0 
)

Definition at line 497 of file Utilities.h.

References SetAxis(), SetCut(), SetLivetime(), and SetPOT().

Referenced by GenerateCovMx(), MakeISysts(), MakeSystsPDF(), and SetEverything().

497  {
498  SetAxis(sample, res);
499  SetPOT(sample);
500  SetCut(sample);
501  SetLivetime(sample);
502 }
void SetPOT(covmx::Sample &sample)
Definition: Utilities.h:198
void SetCut(covmx::Sample &sample)
Definition: Utilities.h:263
void SetLivetime(covmx::Sample &sample)
Definition: Utilities.h:212
void SetAxis(covmx::Sample &sample, double res=0)
Definition: Utilities.h:257
void SetLivetime ( covmx::Sample sample)

Definition at line 212 of file Utilities.h.

References GetDefaultLivetime(), and ana::covmx::Sample::SetLivetime().

Referenced by GetSamplesFromOptString(), SaveSpectrum(), and SetInfo().

212  {
213  sample.SetLivetime(GetDefaultLivetime(sample));
214 }
void SetLivetime(double l)
Definition: Sample.h:53
double GetDefaultLivetime(covmx::Sample sample)
Definition: Utilities.h:203
void SetNus20Params ( osc::OscCalcSterile calc,
std::string  type = "3flav" 
)

Definition at line 551 of file Utilities.h.

References ana::assert(), om::cout, allTimeWatchdog::endl, kNux20Delta13, kNux20Delta24, kNux20Dm21, kNux20Dm32, kNux20Th13, kNux20Th23, osc::OscCalcSterile::SetAngle(), osc::OscCalcSterile::SetDelta(), osc::OscCalcSterile::SetDm(), and ana::Sqrt().

Referenced by CompareBinningSchemes(), CompareMissingLeptons(), DecorrelateFD(), DrawBackgrounds(), DrawBins(), DrawCCOscillations(), DrawCovMx(), DrawPulls(), DrawSensitivityDip(), DrawSystShifts(), MakeFakeData(), MakeISysts(), MakeNumuCovMx(), MakePlots(), MakeSurface(), MakeSurfaceBinningStudy(), MakeSystsPDF(), MatrixDeterminant(), SaveSpectrum(), ScaleCovarianceMatrix(), SetFakeSignalParams(), and TestCovMxNew().

551  {
552 
553  if(type=="3flav"){
554  // Mass splittings
555  std::cout<<" 3-Flavor signal"<<std::endl;
556  calc->SetDm(2, kNux20Dm21);
557  calc->SetDm(3, kNux20Dm21 + kNux20Dm32);
558  calc->SetDm(4, 0.);
559 
560  // Angles
561  calc->SetAngle(1, 3, kNux20Th13);
562  calc->SetAngle(2, 3, kNux20Th23);
563  calc->SetAngle(3, 4, 0.);
564  calc->SetAngle(2, 4, 0.);
565  calc->SetAngle(1, 4, 0.);
566 
567  // Phases
568  calc->SetDelta(1, 3, kNux20Delta13);
569  calc->SetDelta(2, 4, kNux20Delta24);
570 
571  }
572  else if (type == "lsnd") { // fake signal 1: LSND
573  // Mass splittings
574  std::cout<<" LSND Like signal"<<std::endl;
575  calc->SetDm(2, kNux20Dm21);
576  calc->SetDm(3, kNux20Dm21 + kNux20Dm32);
577  calc->SetDm(4, 1.2);
578  // Angles
579  Double_t theta_24 = TMath::ASin(TMath::Sqrt(0.0166));
580  Double_t theta_14 = TMath::ASin(TMath::Sqrt(0.18))/2;
581  calc->SetAngle(1, 3, kNux20Th13);
582  calc->SetAngle(2, 3, kNux20Th23);
583  calc->SetAngle(3, 4, 0.);
584  calc->SetAngle(2, 4, theta_24);
585  calc->SetAngle(1, 4, theta_14);
586 
587  // Phases
588  calc->SetDelta(1, 3, kNux20Delta13);
589  calc->SetDelta(2, 4, kNux20Delta24);
590 
591  }
592  else if (type=="miniboone"){
593  std::cout<<" MiniBooNE Like signal"<<std::endl;
594  // Mass splittings
595  calc->SetDm(2, kNux20Dm21);
596  calc->SetDm(3, kNux20Dm21 + kNux20Dm32);
597  calc->SetDm(4, 0.041);
598 
599  // Angles
600  Double_t theta_24 = TMath::ASin(TMath::Sqrt(0.95));
601  calc->SetAngle(1, 3, kNux20Th13);
602  calc->SetAngle(2, 3, kNux20Th23);
603  calc->SetAngle(3, 4, 0.);
604  calc->SetAngle(2, 4, theta_24);
605  calc->SetAngle(1, 4, 0.785398);
606 
607  // Phases
608  calc->SetDelta(1, 3, kNux20Delta13);
609  calc->SetDelta(2, 4, kNux20Delta24);
610  }
611  else assert(false && ("Oscillation parameter set \"" + type + "\" not recognised.").c_str());
612 
613 }
const double kNux20Th23
Definition: Utilities.h:44
void SetDelta(int i, int j, double delta)
const double kNux20Th13
Definition: Utilities.h:43
const double kNux20Delta24
Definition: Utilities.h:48
OStream cout
Definition: OStream.cxx:6
void SetAngle(int i, int j, double th)
void SetDm(int i, double dm)
Var Sqrt(const Var &v)
Use to take sqrt of a var.
Definition: Var.cxx:326
assert(nhit_max >=nhit_nbins)
const double kNux20Dm32
Definition: Utilities.h:38
const double kNux20Delta13
Definition: Utilities.h:47
const double kNux20Dm21
Definition: Utilities.h:37
void SetPOT ( covmx::Sample sample)

Definition at line 198 of file Utilities.h.

References GetDefaultPOT(), and ana::covmx::Sample::SetPOT().

Referenced by GetSamplesFromOptString(), and SetInfo().

198  {
199  sample.SetPOT(GetDefaultPOT(sample));
200 }
double GetDefaultPOT(covmx::Sample sample)
Definition: Utilities.h:187
void SetPOT(double d)
Definition: Sample.h:52
void SetPrediction ( covmx::Sample sample,
bool  systs = true 
)

Definition at line 505 of file Utilities.h.

References ana::covmx::Sample::detector, MakeMiniprodValidationCuts::f, shutoffs::filename, ana::getNusAna2020AllSysts(), ana::covmx::Sample::GetTag(), ana::InputPath(), ana::covmx::kNearDet, ana::FDPredictionSterile::LoadFrom(), ana::NDPredictionSterile::LoadFrom(), ana::PredictionInterp::LoadFrom(), runNovaSAM::release, ana::covmx::Sample::SetPrediction(), and systs.

Referenced by GenerateCovMx(), MakeSurface(), SaveSpectrum(), SetEverything(), and TestCovMxNew().

505  {
506 
507  string filename = InputPath() + "/pred/pred_" + sample.GetTag() + ".root";
508 
509  // Load prediction from file
510  TFile* f = TFile::Open(filename.c_str(), "read");
511  IPrediction* p = nullptr;
512  if (systs) {
513  getNusAna2020AllSysts(sample);
514  p = PredictionInterp::LoadFrom(f, (sample.GetTag()+"/pred_interp").c_str()).release();
515  }
516  else {
517  p = (sample.detector == covmx::kNearDet) ?
518  (IPrediction*)NDPredictionSterile::LoadFrom(f, (sample.GetTag()+"/pred").c_str()).release() :
519  (IPrediction*)FDPredictionSterile::LoadFrom(f, (sample.GetTag()+"/pred").c_str()).release();
520  }
521  sample.SetPrediction(p);
522  delete f;
523 
524 }
std::vector< SystGroupDef > systs
Definition: syst_header.h:385
vector< const ISyst * > getNusAna2020AllSysts(covmx::Sample &s)
const char * p
Definition: xmltok.h:285
std::string GetTag() const
Definition: Sample.cxx:94
string filename
Definition: shutoffs.py:106
std::unique_ptr< T > LoadFrom(TDirectory *dir, const std::string &label)
Definition: LoadFromFile.h:17
void SetPrediction(IPrediction *p)
Definition: Sample.cxx:103
Detector detector
Definition: Sample.h:97
string InputPath()
Definition: Utilities.cxx:12
Standard interface to all prediction techniques.
Definition: IPrediction.h:57
Take the output of an extrapolation and oscillate it as required.
TMatrixD UnpackMatrix ( TMatrixD  mx)

Definition at line 878 of file Utilities.h.

References ana::bins, MECModelEnuComparisons::i, calib::j, ana::kNCFDBinning, ana::kNCNDBinning, ana::Binning::NBins(), ndComps, and runNovaSAM::ret.

878  {
879 
880  size_t nComps = 13; // if this is a hardcoded hack, may as well go all in
881  std::vector<Binning> bins = { kNCNDBinning, kNCFDBinning };
882  size_t nSamples = bins.size();
883  size_t nBinsPerComp = kNCNDBinning.NBins() + kNCFDBinning.NBins();
884  std::vector<size_t> ndComps = { 0, 1, 8, 9, 12 };
885  size_t mxSize = nBinsPerComp * nComps;
886  TMatrixD ret(mxSize, mxSize);
887  ret.Zero();
888 
889  // Now if we packed the matrix, we need to unpack it!
890  size_t iPack = 0;
891  // Loop over all components, samples, bins
892  for (size_t iComp = 0; iComp < nComps; ++iComp) {
893  for (size_t iSample = 0; iSample < nSamples; ++iSample) {
894  // If we're in an ND flux swap component, throw it away
895  if (iSample == 0 && std::find(ndComps.begin(), ndComps.end(), iComp) == ndComps.end()) {
896  // std::cout << "Skipping component " << iComp << ", sample " << iSample << std::endl;
897  continue;
898  }
899  for (size_t iBin = 0; iBin < (size_t)bins[iSample].NBins(); ++iBin) {
900  size_t i = (iComp*nBinsPerComp) + (iSample*kNCNDBinning.NBins()) + iBin;
901  if (i == 124) continue; // awful hack to remove problem bin
902  size_t jPack = 0;
903  for (size_t jComp = 0; jComp < nComps; ++jComp) {
904  for (size_t jSample = 0; jSample < nSamples; ++jSample) {
905  // If we're in an ND flux swap component, throw it away
906  if (jSample == 0 && std::find(ndComps.begin(), ndComps.end(), jComp) == ndComps.end()) {
907  // std::cout << "Skipping component " << jComp << ", sample " << jSample << std::endl;
908  continue;
909  }
910  for (size_t jBin = 0; jBin < (size_t)bins[jSample].NBins(); ++jBin) {
911  size_t j = (jComp*nBinsPerComp) + (jSample*kNCNDBinning.NBins()) + jBin;
912  if (j == 124) continue; // awful hack to remove problem bin
913  ret(i,j) = mx(iPack,jPack);
914  ++jPack;
915  } // for bin j
916  } // for sample j
917  } // for component j
918  ++iPack;
919  } // for bin i
920  } // for sample i
921  } // for component i
922 
923  return ret;
924 
925 } // function UnpackMatrix
const std::vector< std::string > ndComps
Definition: TestCovMxNew.C:12
const double j
Definition: BetheBloch.cxx:29
const Binning bins
const Binning kNCNDBinning
NC custom binning.
Definition: Binning.cxx:104
int NBins() const
Definition: Binning.h:29
const Binning kNCFDBinning
Definition: Binning.cxx:105

Variable Documentation

const double kNux20Delta13 = 1.21*M_PI

Definition at line 47 of file Utilities.h.

Referenced by SetNus20Params().

const double kNux20Delta24 = M_PI/2

Definition at line 48 of file Utilities.h.

Referenced by GetConfig(), and SetNus20Params().

const double kNux20Dm21 = 7.53e-5

Definition at line 37 of file Utilities.h.

Referenced by SetNus20Params().

const double kNux20Dm32 = 2.60e-3

Definition at line 38 of file Utilities.h.

Referenced by GetConfig(), GetConstraintLoose(), GetConstraints(), and SetNus20Params().

const double kNux20Dm32LooseSigma = 0.15e-3

Definition at line 40 of file Utilities.h.

Referenced by GetConstraintLoose().

const double kNux20Dm32Sigma = 0.08e-3

Definition at line 39 of file Utilities.h.

Referenced by GetConstraints().

const double kNux20FHCFDPOT = kAna2020FHCPOT

Definition at line 51 of file Utilities.h.

Referenced by GetDefaultPOT(), and MakeSysts().

const double kNux20FHCLivetime = kAna2020FHCLivetime

Definition at line 54 of file Utilities.h.

Referenced by GetDefaultLivetime().

const double kNux20FHCNDPOT = 11e20

Definition at line 50 of file Utilities.h.

Referenced by GetDefaultPOT(), and MakeSysts().

const double kNux20RHCFDPOT = kAna2020RHCPOT

Definition at line 53 of file Utilities.h.

Referenced by GetDefaultPOT().

const double kNux20RHCLivetime = kAna2020RHCLivetime

Definition at line 55 of file Utilities.h.

Referenced by GetDefaultLivetime().

const double kNux20RHCNDPOT = 11.8e20

Definition at line 52 of file Utilities.h.

Referenced by GetDefaultPOT().

const double kNux20Th12 = 0.587

Definition at line 42 of file Utilities.h.

const double kNux20Th13 = 0.145

Definition at line 43 of file Utilities.h.

Referenced by SetNus20Params().

const double kNux20Th23 = 0.844

Definition at line 44 of file Utilities.h.

Referenced by GetConfig(), GetConstraints(), and SetNus20Params().

const double kNux20Th23Sigma = 0.042

Definition at line 45 of file Utilities.h.

Referenced by GetConstraints().