Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
ana::BeamSyst Class Reference

Beam systematics: More...

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N21-03-08/CAFAna/Systs/BeamSysts.h"

Inheritance diagram for ana::BeamSyst:
ana::ISyst ana::BeamSystOrWeightBase

Public Member Functions

 BeamSyst (const std::string &fname, const std::string &shortname, const std::string &latexname)
 
 BeamSyst (const std::string &fname, const std::string &histname, const std::string &shortname, const std::string &latexname)
 
void TruthShift (double sigma, caf::SRNeutrinoProxy *sr, double &weight) const override
 
virtual const std::stringShortName () const final
 The name printed out to the screen. More...
 
virtual const std::stringLatexName () const final
 The name used on plots (ROOT's TLatex syntax) More...
 
virtual void Shift (double sigma, caf::SRProxy *sr, double &weight) const
 Perform the systematic shift. More...
 
virtual bool IsGenieReweight () const
 GENIE reweights can only provide +/-1,2sigma. More...
 

Private Types

enum  { kFHC, kRHC, kNumFluxType }
 
enum  { kND, kFD, kNumDets }
 
enum  ESign { kMinus, kPlus, kNumSigns }
 
enum  {
  kNue, kAntiNue, kNumu, kAntiNumu,
  kNumFlavors
}
 

Private Member Functions

void InitializeHistograms () const
 
double GetWeight (const caf::SRNeutrinoProxy *nu, ESign sign) const
 

Private Attributes

std::string fFileName
 
std::string fHistName
 
TH1D * fHistos [kNumFluxType][kNumDets][kNumSigns][kNumFlavors]
 

Detailed Description

Beam systematics:

Definition at line 38 of file BeamSysts.h.

Member Enumeration Documentation

anonymous enum
protectedinherited
anonymous enum
protectedinherited
Enumerator
kFHC 
kRHC 
kNumFluxType 

Definition at line 22 of file BeamSysts.h.

anonymous enum
protectedinherited
Enumerator
kND 
kFD 
kNumDets 

Definition at line 23 of file BeamSysts.h.

enum ana::BeamSystOrWeightBase::ESign
protectedinherited
Enumerator
kMinus 
kPlus 
kNumSigns 

Definition at line 24 of file BeamSysts.h.

Constructor & Destructor Documentation

ana::BeamSyst::BeamSyst ( const std::string fname,
const std::string shortname,
const std::string latexname 
)

Definition at line 404 of file BeamSysts.cxx.

407  : ISyst(shortname, latexname),
408  BeamSystOrWeightBase(fname, shortname)
409  {
410  }
BeamSystOrWeightBase(const std::string &fname, const std::string &shortName)
Definition: BeamSysts.cxx:259
ISyst(const std::string &shortName, const std::string &latexName)
Definition: ISyst.cxx:10
ana::BeamSyst::BeamSyst ( const std::string fname,
const std::string histname,
const std::string shortname,
const std::string latexname 
)

Definition at line 412 of file BeamSysts.cxx.

416  : ISyst(shortname, latexname),
417  BeamSystOrWeightBase(fname, histname)
418  {
419  }
BeamSystOrWeightBase(const std::string &fname, const std::string &shortName)
Definition: BeamSysts.cxx:259
ISyst(const std::string &shortName, const std::string &latexName)
Definition: ISyst.cxx:10

Member Function Documentation

double ana::BeamSystOrWeightBase::GetWeight ( const caf::SRNeutrinoProxy nu,
ESign  sign 
) const
protectedinherited

Definition at line 350 of file BeamSysts.cxx.

References om::cerr, fillBadChanDBTables::det, caf::Proxy< caf::SRNeutrino >::det, caf::Proxy< caf::SRNeutrino >::E, allTimeWatchdog::endl, energy, ana::BeamSystOrWeightBase::fHistName, ana::BeamSystOrWeightBase::fHistos, flux, make_syst_table_plots::h, ana::BeamSystOrWeightBase::InitializeHistograms(), caf::Proxy< caf::SRNeutrino >::isRHC, ana::BeamSystOrWeightBase::kAntiNue, ana::BeamSystOrWeightBase::kAntiNumu, caf::kFARDET, ana::BeamSystOrWeightBase::kFD, ana::BeamSystOrWeightBase::kFHC, ana::BeamSystOrWeightBase::kND, caf::kNEARDET, ana::BeamSystOrWeightBase::kNue, ana::BeamSystOrWeightBase::kNumu, ana::BeamSystOrWeightBase::kRHC, caf::Proxy< caf::SRNeutrino >::pdgorig, and canMan::sign().

Referenced by ana::BeamWeightFunc::operator()(), and TruthShift().

352  {
354 
355  int flux = kFHC;
356  if(nu->isRHC) flux = kRHC;
357 
358  // Need different histogram per detector
359  int det = 0;
360  switch (nu->det)
361  {
362  case caf::kNEARDET : det = kND; break;
363  case caf::kFARDET : det = kFD; break;
364  default: std::cerr <<"Wrong detector; ignore" << std::endl; return 1;
365  }
366 
367  //Set the different weights for p/m sigma and neutrino flavor/energy
368 
369  double energy = nu->E; // True neutrino energy
370 
371  //Find the neutrino flavor
372  int flav = 0;
373  switch(nu->pdgorig)
374  {
375  case 14: flav = kNumu; break;
376  case 12: flav = kNue; break;
377  case -14: flav = kAntiNumu; break;
378  case -12: flav = kAntiNue; break;
379  default: std::cerr << "Wrong nu flavor; ignore" << std::endl; return 1;
380  }
381 
382  //Find the right histogram for the detector and sign
383  TH1D* h = fHistos[flux][det][sign][flav];
384  if (h == 0){
385  std::cerr << fHistName+": Can't find desired histogram; ignore"<< std:: endl;
386  return 1;
387  }
388  //Only use weights if the energy is in the range of the histogram
389  if (energy > h->GetXaxis()->GetXmin() &&
390  energy < h->GetXaxis()->GetXmax() ){
391  return h->Interpolate(energy);
392  }
393 
394  //Main use case is for PPFX smoothened weights.
395  //Return the weight in the last bin if the energy is larger than the range of the histogram
396  //Generalized for all BeamWeightFuncs and BeamSysts
397  if (energy > h->GetXaxis()->GetXmax())
398  return h->GetBinContent(h->GetNbinsX());
399 
400  return 1;
401  }
Near Detector underground.
Definition: SREnums.h:10
Far Detector at Ash River.
Definition: SREnums.h:11
caf::Proxy< bool > isRHC
Definition: SRProxy.h:537
caf::Proxy< caf::Det_t > det
Definition: SRProxy.h:525
OStream cerr
Definition: OStream.cxx:7
caf::Proxy< float > E
Definition: SRProxy.h:520
Loaders::FluxType flux
double energy
Definition: plottest35.C:25
caf::Proxy< short int > pdgorig
Definition: SRProxy.h:553
void InitializeHistograms() const
Definition: BeamSysts.cxx:281
TH1D * fHistos[kNumFluxType][kNumDets][kNumSigns][kNumFlavors]
Definition: BeamSysts.h:34
def sign(x)
Definition: canMan.py:197
void ana::BeamSystOrWeightBase::InitializeHistograms ( ) const
protectedinherited

Definition at line 281 of file BeamSysts.cxx.

References om::cerr, fillBadChanDBTables::det, allTimeWatchdog::endl, ana::BeamSystOrWeightBase::fFileName, ana::BeamSystOrWeightBase::fHistName, ana::BeamSystOrWeightBase::fHistos, fin, flux, compareCafs::histName, ana::BeamSystOrWeightBase::kAntiNue, ana::BeamSystOrWeightBase::kAntiNumu, ana::BeamSystOrWeightBase::kFD, ana::BeamSystOrWeightBase::kFHC, ana::BeamSystOrWeightBase::kMinus, ana::BeamSystOrWeightBase::kND, ana::BeamSystOrWeightBase::kNue, ana::BeamSystOrWeightBase::kNumu, ana::BeamSystOrWeightBase::kPlus, ana::BeamSystOrWeightBase::kRHC, and canMan::sign().

Referenced by ana::BeamSystOrWeightBase::GetWeight().

282  {
283  // Already been called
284  if(fHistos[0][0][0][0]) return;
285 
286  //open file
287  TFile fin (fFileName.c_str(),"read");
288  if(fin.IsZombie()){
289  std::cerr << "Warning: couldn't open " << fFileName << std::endl;
290  return;
291  }
292 
293  //Check that desired systematic is in file
294  // Loop through the detector folder, over all histograms
295 
296  TIter iterHist(gDirectory->GetListOfKeys());
297  TKey* keyHist;
298  int foundHisto=0;
299  bool isSeparatedByFlavor = false;
300 
301  while((keyHist = (TKey*)iterHist())) {
302  TString histName = keyHist->GetName(); // Get a histogram name
303  if(histName.Contains(fHistName)){ //is it the desired syst
304  foundHisto++;
305 
306  int flux=0;
307  if(histName.Contains("FHC")) flux = kFHC;
308  if(histName.Contains("RHC")) flux = kRHC;
309 
310  int det = 0;
311  if(histName.Contains("ND")) det = kND;
312  if(histName.Contains("FD")) det = kFD;
313 
314  int sign = 0;
315  if(histName.Contains("minus")) sign = kMinus;
316  if(histName.Contains("plus" )) sign = kPlus;
317 
318  int flav = 0;
319  if(histName.Contains("numu")) flav = kNumu;
320  if(histName.Contains("nue")) flav = kNue;
321  if(histName.Contains("anumu")) flav = kAntiNumu;
322  if(histName.Contains("anue")) flav = kAntiNue;
323 
324  //store relevant histograms
325  fHistos[flux][det][sign][flav] = (TH1D*) fin.Get(histName)->Clone();
326  // disassociate it from the file it came from
327  fHistos[flux][det][sign][flav]->SetDirectory(0);
328  }
329  if(histName.Contains("numu")){
330  isSeparatedByFlavor=true;
331  }
332  }
333 
334  if (foundHisto==0) {
335  std::cerr << "Beam systematic histogram " << fHistName
336  << " is not in file " << fFileName <<"; aborting" << std::endl;
337  abort();
338  }
339 
340  if (!isSeparatedByFlavor) {
341  std::cerr << "Beam systematic "<< fHistName
342  << " doesn't have required flavor information; aborting"
343  << std::endl;
344  abort();
345  }
346  fin.Close();
347  }
TString fin
Definition: Style.C:24
OStream cerr
Definition: OStream.cxx:7
Loaders::FluxType flux
TH1D * fHistos[kNumFluxType][kNumDets][kNumSigns][kNumFlavors]
Definition: BeamSysts.h:34
def sign(x)
Definition: canMan.py:197
virtual bool ana::ISyst::IsGenieReweight ( ) const
inlinevirtualinherited

GENIE reweights can only provide +/-1,2sigma.

Reimplemented in ana::SummedSyst.

Definition at line 56 of file ISyst.h.

56 {return false;}
virtual const std::string& ana::ISyst::LatexName ( ) const
inlinefinalvirtualinherited

The name used on plots (ROOT's TLatex syntax)

Definition at line 30 of file ISyst.h.

References ana::ISyst::fLatexName, ana::ISyst::Shift(), sigma(), sr, and ana::weight.

Referenced by ana::PredictionInterp::DebugPlotColz(), GetGENIEShiftLabels(), ana::NuISyst::SaveTo(), SystsGENIEAna(), and WriteSystName().

30 {return fLatexName;}
std::string fLatexName
Definition: ISyst.h:60
void ana::ISyst::Shift ( double  sigma,
caf::SRProxy sr,
double &  weight 
) const
virtualinherited

Perform the systematic shift.

Override this function if your systematic depends on non-SRNeutrino quantities. If it is SRNeutrino-only, implement the other function, and let this default forward to you when necessary.

Parameters
sigmaNumber of sigma to shift record by
srThe record to inspect and alter
weightScale this weight for reweighting systematics

Reimplemented in ana::MinosResSuppSyst, ana::MECDoubleGaussEnhSystDOWN, ana::MECDoubleGaussEnhSystUP, ana::MECDoubleGaussEnhSyst, ana::MinosResSuppSyst, ana::MECGaussEnhSyst, ana::MECGaussEnhSyst, ana::MECDoubleGaussEnhSystNux, jw::MECInitStateNPFracShift, jw::CompNormSyst, ana::CompNormSyst, ana::CompNormSyst, ana::BolombMuESyst2019, ana::DISHighWScaleSyst, ana::ContainmentSyst, ana::PileupMuESyst2019, ana::PileupMuESyst2020, ana::NumuRelEnergyScaleSyst, ana::RockMuonNormSyst, ana::NumuEnergyScaleSyst, ana::RemIDScaleSyst, ana::UnCorrMuCatMuESyst2019, ana::LEMScaleSyst, ana::NumuRelNormSyst, ana::UnCorrMuCatMuESyst2020, demo::DemoSyst2, ana::DirectRelHadEScaleSyst2017, ana::BeamIntensitySyst, ana::NumuNormSyst, ana::Nus18BaseSyst, ana::UnCorrNDMuEScaleSyst2019, ana::KaonScaleSyst, ana::FDMuEnergyScaleSyst, ana::UnCorrNDMuEScaleSyst2020, ana::NumuTauContaminationSyst, ana::MyWrongSignScale, ana::MECDoubleGaussEnhSyst, ana::NueAcceptSystSignalKin2020RHC, ana::DirectHadEScaleSyst2017, ana::NumuCCScaleSyst, ana::Nus18FlatSyst, ana::FDHadEnergyScaleSyst, ana::NumuNCScaleSyst, ana::NueAcceptSystSignalKin2018RHC, ana::BeamNueScaleSyst, ana::NueAcceptSystBkg2018RHC, ana::UnCorrFDMuEScaleSyst2019, ana::UnCorrFDMuEScaleSyst2020, ana::MuEnergyScaleSyst, ana::WrongSignScale100, ana::NCScaleSyst, ana::covmx::NormSyst, ana::NusFlatSyst, ana::RelMuEScaleSyst2017, ana::Nus17FlatSyst, ana::Numutest, ana::NumuSummedSmallGENIESyst, ana::Nus18SystFromHist, ana::NusAna2020TauSyst, ana::NueAcceptSystSignalKin2020FHC, ana::WrongSignEnergyBin, ana::RelNormSyst, ana::MichelTaggingSyst2018, ana::Nuetest, ana::GenericSystComponentScale< T >, ana::CorrMuEScaleSyst2019, ana::CorrMuEScaleSyst2020, ana::NumuGEANTScaleSyst, ana::GenericSystComponentScale< T >, ana::HadEnergyScaleSyst, ana::NueAcceptSystSignalKin2018FHC, ana::NormSyst, ana::WrongSignEnergyBinRHC, ana::NuWROSyst, ana::NusAna2020KaonSyst, ana::GenericSystComponentScale< T >, ana::LeptonAngleSyst, ana::NueExtrapSystSignalKin2017, ana::SystFromWeight, ana::MuEScaleSyst2017, ana::NCtest, ana::NusSystFromHist, ana::NueSyst, ana::Nus17SystFromHist, ana::SummedSyst, ana::DummyNue2017Syst, ana::DummyNumu2017Syst, ana::GeniePCASyst, ana::NueAcceptSystBkg2018FHC, ana::NumuGEANTNormSyst, ana::DummyAnaSyst, ana::NeutronVisEScaleSyst2018, ana::NueExtrapSystBkg2017, ana::DummyRockScaleSyst, ana::MichelTaggingSyst2020, ana::CosmicBkgScaleSyst, ana::WrongSignScale, ana::WrongSignContamination, ana::NCSyst, and ana::NumuSyst.

Definition at line 26 of file ISyst.cxx.

References caf::Proxy< caf::StandardRecord >::mc, caf::Proxy< caf::SRTruthBranch >::nnu, caf::Proxy< caf::SRTruthBranch >::nu, and ana::ISyst::TruthShift().

Referenced by ana::ISyst::LatexName(), and ana::GenericSystComponentScale< T >::Shift().

27  {
28  // Override this function if your systematic depends on non-SRNeutrino
29  // quantities. If it is SRNeutrino-only, implement the other function,
30  // and let this default forward to you when necessary.
31  if(sr->mc.nnu > 0) TruthShift(sigma, &sr->mc.nu[0], weight);
32  }
const Var weight
caf::Proxy< std::vector< caf::SRNeutrino > > nu
Definition: SRProxy.h:618
caf::Proxy< short int > nnu
Definition: SRProxy.h:617
virtual void TruthShift(double sigma, caf::SRNeutrinoProxy *nu, double &weight) const
Definition: ISyst.h:46
double sigma(TH1F *hist, double percentile)
caf::Proxy< caf::SRTruthBranch > mc
Definition: SRProxy.h:2138
virtual const std::string& ana::ISyst::ShortName ( ) const
inlinefinalvirtualinherited
void ana::BeamSyst::TruthShift ( double  sigma,
caf::SRNeutrinoProxy nu,
double &  weight 
) const
overridevirtual

For systematics that deal only with the neutrino truth and not any reconstruction/PID details. Systematics defined this way will work on nuTree-derived spectra too (e.g. denominators of efficiencies).

Reimplemented from ana::ISyst.

Definition at line 422 of file BeamSysts.cxx.

References ana::BeamSystOrWeightBase::GetWeight(), ana::BeamSystOrWeightBase::kMinus, ana::BeamSystOrWeightBase::kPlus, std::max(), and canMan::sign().

424  {
425  if(sigma == 0) return;
426 
427  // Need different histogram for plus or minus sigma
428  ESign sign = kPlus;
429  if(sigma<0) sign = kMinus;
430 
431  weight *=1+(GetWeight(sr, sign)-1.)*TMath::Abs(sigma);
432  weight = std::max(0., weight);
433  }
T max(const caf::Proxy< T > &a, T b)
const Var weight
caf::StandardRecord * sr
double sigma(TH1F *hist, double percentile)
double GetWeight(const caf::SRNeutrinoProxy *nu, ESign sign) const
Definition: BeamSysts.cxx:350
def sign(x)
Definition: canMan.py:197

Member Data Documentation

std::string ana::BeamSystOrWeightBase::fFileName
protectedinherited

Definition at line 31 of file BeamSysts.h.

Referenced by ana::BeamSystOrWeightBase::InitializeHistograms().

std::string ana::BeamSystOrWeightBase::fHistName
protectedinherited
TH1D* ana::BeamSystOrWeightBase::fHistos[kNumFluxType][kNumDets][kNumSigns][kNumFlavors]
mutableprotectedinherited

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