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/N20-11-30/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 37 of file BeamSysts.h.

Member Enumeration Documentation

anonymous enum
protectedinherited
anonymous enum
protectedinherited
Enumerator
kFHC 
kRHC 
kNumFluxType 

Definition at line 21 of file BeamSysts.h.

anonymous enum
protectedinherited
Enumerator
kND 
kFD 
kNumDets 

Definition at line 22 of file BeamSysts.h.

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

Definition at line 23 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 368 of file BeamSysts.cxx.

371  : ISyst(shortname, latexname),
372  BeamSystOrWeightBase(fname, shortname)
373  {
374  }
BeamSystOrWeightBase(const std::string &fname, const std::string &shortName)
Definition: BeamSysts.cxx:223
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 376 of file BeamSysts.cxx.

380  : ISyst(shortname, latexname),
381  BeamSystOrWeightBase(fname, histname)
382  {
383  }
BeamSystOrWeightBase(const std::string &fname, const std::string &shortName)
Definition: BeamSysts.cxx:223
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 314 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().

316  {
318 
319  int flux = kFHC;
320  if(nu->isRHC) flux = kRHC;
321 
322  // Need different histogram per detector
323  int det = 0;
324  switch (nu->det)
325  {
326  case caf::kNEARDET : det = kND; break;
327  case caf::kFARDET : det = kFD; break;
328  default: std::cerr <<"Wrong detector; ignore" << std::endl; return 1;
329  }
330 
331  //Set the different weights for p/m sigma and neutrino flavor/energy
332 
333  double energy = nu->E; // True neutrino energy
334 
335  //Find the neutrino flavor
336  int flav = 0;
337  switch(nu->pdgorig)
338  {
339  case 14: flav = kNumu; break;
340  case 12: flav = kNue; break;
341  case -14: flav = kAntiNumu; break;
342  case -12: flav = kAntiNue; break;
343  default: std::cerr << "Wrong nu flavor; ignore" << std::endl; return 1;
344  }
345 
346  //Find the right histogram for the detector and sign
347  TH1D* h = fHistos[flux][det][sign][flav];
348  if (h == 0){
349  std::cerr << fHistName+": Can't find desired histogram; ignore"<< std:: endl;
350  return 1;
351  }
352  //Only use weights if the energy is in the range of the histogram
353  if (energy > h->GetXaxis()->GetXmin() &&
354  energy < h->GetXaxis()->GetXmax() ){
355  return h->Interpolate(energy);
356  }
357 
358  //Main use case is for PPFX smoothened weights.
359  //Return the weight in the last bin if the energy is larger than the range of the histogram
360  //Generalized for all BeamWeightFuncs and BeamSysts
361  if (energy > h->GetXaxis()->GetXmax())
362  return h->GetBinContent(h->GetNbinsX());
363 
364  return 1;
365  }
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:245
TH1D * fHistos[kNumFluxType][kNumDets][kNumSigns][kNumFlavors]
Definition: BeamSysts.h:33
def sign(x)
Definition: canMan.py:197
void ana::BeamSystOrWeightBase::InitializeHistograms ( ) const
protectedinherited

Definition at line 245 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().

246  {
247  // Already been called
248  if(fHistos[0][0][0][0]) return;
249 
250  //open file
251  TFile fin (fFileName.c_str(),"read");
252  if(fin.IsZombie()){
253  std::cerr << "Warning: couldn't open " << fFileName << std::endl;
254  return;
255  }
256 
257  //Check that desired systematic is in file
258  // Loop through the detector folder, over all histograms
259 
260  TIter iterHist(gDirectory->GetListOfKeys());
261  TKey* keyHist;
262  int foundHisto=0;
263  bool isSeparatedByFlavor = false;
264 
265  while((keyHist = (TKey*)iterHist())) {
266  TString histName = keyHist->GetName(); // Get a histogram name
267  if(histName.Contains(fHistName)){ //is it the desired syst
268  foundHisto++;
269 
270  int flux=0;
271  if(histName.Contains("FHC")) flux = kFHC;
272  if(histName.Contains("RHC")) flux = kRHC;
273 
274  int det = 0;
275  if(histName.Contains("ND")) det = kND;
276  if(histName.Contains("FD")) det = kFD;
277 
278  int sign = 0;
279  if(histName.Contains("minus")) sign = kMinus;
280  if(histName.Contains("plus" )) sign = kPlus;
281 
282  int flav = 0;
283  if(histName.Contains("numu")) flav = kNumu;
284  if(histName.Contains("nue")) flav = kNue;
285  if(histName.Contains("anumu")) flav = kAntiNumu;
286  if(histName.Contains("anue")) flav = kAntiNue;
287 
288  //store relevant histograms
289  fHistos[flux][det][sign][flav] = (TH1D*) fin.Get(histName)->Clone();
290  // disassociate it from the file it came from
291  fHistos[flux][det][sign][flav]->SetDirectory(0);
292  }
293  if(histName.Contains("numu")){
294  isSeparatedByFlavor=true;
295  }
296  }
297 
298  if (foundHisto==0) {
299  std::cerr << "Beam systematic histogram " << fHistName
300  << " is not in file " << fFileName <<"; aborting" << std::endl;
301  abort();
302  }
303 
304  if (!isSeparatedByFlavor) {
305  std::cerr << "Beam systematic "<< fHistName
306  << " doesn't have required flavor information; aborting"
307  << std::endl;
308  abort();
309  }
310  fin.Close();
311  }
TString fin
Definition: Style.C:24
OStream cerr
Definition: OStream.cxx:7
Loaders::FluxType flux
TH1D * fHistos[kNumFluxType][kNumDets][kNumSigns][kNumFlavors]
Definition: BeamSysts.h:33
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::MECGaussEnhSyst, ana::MECDoubleGaussEnhSystNux, jw::MECInitStateNPFracShift, jw::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::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::NusFlatSyst, ana::RelMuEScaleSyst2017, ana::Nus17FlatSyst, ana::Numutest, ana::NumuSummedSmallGENIESyst, ana::Nus18SystFromHist, ana::NueAcceptSystSignalKin2020FHC, ana::WrongSignEnergyBin, ana::RelNormSyst, ana::MichelTaggingSyst2018, ana::Nuetest, ana::NusAna2020TauSyst, ana::GenericSystComponentScale< T >, ana::CorrMuEScaleSyst2019, ana::CorrMuEScaleSyst2020, ana::NumuGEANTScaleSyst, ana::GenericSystComponentScale< T >, ana::HadEnergyScaleSyst, ana::NueAcceptSystSignalKin2018FHC, ana::NormSyst, ana::WrongSignEnergyBinRHC, ana::NuWROSyst, 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::NusAna2020KaonSyst, 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 fnex::CAFToEventList::FillMCVarVals(), 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 386 of file BeamSysts.cxx.

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

388  {
389  if(sigma == 0) return;
390 
391  // Need different histogram for plus or minus sigma
392  ESign sign = kPlus;
393  if(sigma<0) sign = kMinus;
394 
395  weight *=1+(GetWeight(sr, sign)-1.)*TMath::Abs(sigma);
396  weight = std::max(0., weight);
397  }
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:314
def sign(x)
Definition: canMan.py:197

Member Data Documentation

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

Definition at line 30 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: