Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
ana::SystematicsMaker Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-12-03/NuXAna/Analysis/SystMaker.h"

Public Member Functions

 SystematicsMaker (std::string name, SystPredType predType)
 SystematicsMaker constructor. More...
 
 ~SystematicsMaker ()
 SystematicsMaker destructor. More...
 
std::string Name ()
 
void AddSystematic (SystMaker *syst)
 
std::map< std::string, SystMaker * > GetSystMakers ()
 
void Go (const covmx::Sample sample, osc::IOscCalc *calc)
 
void SetAxes (const HistAxis *axis, const HistAxis *numuAxis=nullptr)
 
void SetCuts (const Cut *fd_cut, const Cut *nd_cut, const Cut *numu_cut=nullptr)
 
void SetNominalLoaders (Loaders *loader, Loaders *loader_light=nullptr)
 
void SetNominalWeight (const Var *weight)
 
std::vector< std::stringGetSystematicsNames ()
 Get the names of all attached systematics. More...
 
std::vector< NuISyst * > MakeISysts ()
 Make ISyst objects for each attached systematic and return them. More...
 
void DrawSysts (TDirectory *outDir)
 
void PrintSysts (std::ostream &os=std::cout)
 
void Add (SystematicsMaker *systMaker, bool overwrite)
 function to add another SystematicsMaker to this one More...
 
void SaveTo (TDirectory *dir, bool separate=false) const
 

Static Public Member Functions

static std::unique_ptr< SystematicsMakerLoadFrom (TDirectory *dir)
 

Private Attributes

std::string fName
 
SystPredType fPredType
 
std::map< std::string, SystMaker * > fSystMakers
 
const HistAxisfAxis
 
const HistAxisfNuMuAxis
 
const CutfNDCut
 
const CutfFDCut
 
const CutfNuMuCut
 
LoadersfLoaders
 
LoadersfLightLoaders
 
const VarfWeight
 
covmx::Sample fSample
 

Detailed Description

Definition at line 255 of file SystMaker.h.

Constructor & Destructor Documentation

ana::SystematicsMaker::SystematicsMaker ( std::string  name,
SystPredType  predType 
)

SystematicsMaker constructor.

Definition at line 1527 of file SystMaker.cxx.

References om::cout, allTimeWatchdog::endl, ana::kExtrap, ana::kFD, and ana::kND.

1527  :
1528  fName(name),
1529  fPredType(predType),
1530  fAxis(nullptr),
1531  fNuMuAxis(nullptr),
1532  fNDCut(nullptr),
1533  fFDCut(nullptr),
1534  fNuMuCut(nullptr),
1535  fLoaders(nullptr),
1536  fLightLoaders(nullptr),
1537  fWeight(nullptr),
1539  {
1540  vector<SystPredType> supportedPredTypes = {SystPredType::kExtrap, SystPredType::kFD, SystPredType::kND};
1541  if (find(supportedPredTypes.begin(), supportedPredTypes.end(), predType) == supportedPredTypes.end()) {
1542  cout << "SystematicsMaker error: Unsupported prediction type. Aborting..." << endl;
1543  abort();
1544  }
1545  } // SystematicsMaker constructor
const XML_Char * name
Definition: expat.h:151
const Var * fWeight
Definition: SystMaker.h:296
std::string fName
Definition: SystMaker.h:287
Loaders * fLightLoaders
Definition: SystMaker.h:295
SystPredType fPredType
Definition: SystMaker.h:288
covmx::Sample fSample
Definition: SystMaker.h:297
const Cut * fFDCut
Definition: SystMaker.h:293
const HistAxis * fNuMuAxis
Definition: SystMaker.h:292
OStream cout
Definition: OStream.cxx:6
const HistAxis * fAxis
Definition: SystMaker.h:292
const Cut * fNDCut
Definition: SystMaker.h:293
const Cut * fNuMuCut
Definition: SystMaker.h:293
const covmx::Sample NullSample(covmx::Selection::kNoSel, covmx::Polarity::kNoPol, covmx::Detector::kNoDet)
ana::SystematicsMaker::~SystematicsMaker ( )

SystematicsMaker destructor.

Definition at line 1549 of file SystMaker.cxx.

References fSystMakers.

1549  {
1550  for (auto systMaker : fSystMakers) {
1551  if (systMaker.second) delete systMaker.second;
1552  }
1553  } // function SystematicsMaker::~SystematicsMaker
std::map< std::string, SystMaker * > fSystMakers
Definition: SystMaker.h:290

Member Function Documentation

void ana::SystematicsMaker::Add ( SystematicsMaker systMaker,
bool  overwrite 
)

function to add another SystematicsMaker to this one

Definition at line 1644 of file SystMaker.cxx.

References fSystMakers, and publish_reco_validation::overwrite.

1644  {
1645 
1646  map<string, SystMaker*> systMakers;
1647  for (const auto& systMaker : systMakers) {
1648  if (fSystMakers.count(systMaker.first) and !overwrite)
1649  continue;
1650  fSystMakers[systMaker.first] = systMaker.second;
1651  }
1652  } // function SystematicsMaker::Add
std::map< std::string, SystMaker * > fSystMakers
Definition: SystMaker.h:290
void ana::SystematicsMaker::AddSystematic ( SystMaker syst)

Definition at line 1580 of file SystMaker.cxx.

References fAxis, fFDCut, fLightLoaders, fLoaders, fNDCut, fNuMuAxis, fNuMuCut, fPredType, fSystMakers, fWeight, ana::SystMaker::GetName(), ana::SystMaker::MakePredictions(), ana::SystMaker::SetAxes(), ana::SystMaker::SetCuts(), ana::SystMaker::SetNominalLoaders(), and ana::SystMaker::SetNominalWeight().

Referenced by MakeSysts().

1580  {
1581 
1582  syst->SetAxes(fAxis, fNuMuAxis);
1583  syst->SetCuts(fFDCut, fNDCut, fNuMuCut);
1584  syst->SetNominalWeight(fWeight);
1585  if (syst->GetName().find("LightLevel") != string::npos)
1586  syst->SetNominalLoaders(fLightLoaders);
1587  else
1588  syst->SetNominalLoaders(fLoaders);
1589  syst->MakePredictions(fPredType);
1590  fSystMakers[syst->GetName()] = syst;
1591  }
const Var * fWeight
Definition: SystMaker.h:296
Loaders * fLightLoaders
Definition: SystMaker.h:295
SystPredType fPredType
Definition: SystMaker.h:288
const Cut * fFDCut
Definition: SystMaker.h:293
const HistAxis * fNuMuAxis
Definition: SystMaker.h:292
std::map< std::string, SystMaker * > fSystMakers
Definition: SystMaker.h:290
const HistAxis * fAxis
Definition: SystMaker.h:292
const Cut * fNDCut
Definition: SystMaker.h:293
const Cut * fNuMuCut
Definition: SystMaker.h:293
void ana::SystematicsMaker::DrawSysts ( TDirectory *  outDir)

Definition at line 1601 of file SystMaker.cxx.

References fSystMakers.

1601  {
1602  for (const auto& syst : fSystMakers)
1603  syst.second->DrawSyst(outDir);
1604  return;
1605  }
std::string outDir
std::map< std::string, SystMaker * > fSystMakers
Definition: SystMaker.h:290
vector< string > ana::SystematicsMaker::GetSystematicsNames ( )

Get the names of all attached systematics.

Definition at line 1557 of file SystMaker.cxx.

References fSystMakers, and systNames.

1557  {
1558 
1559  vector<string> systNames;
1560  for (const auto& syst : fSystMakers)
1561  systNames.push_back(syst.first);
1562  return systNames;
1563 
1564  } // function SystematicsMaker::GetSystematicsNames
std::map< std::string, SystMaker * > fSystMakers
Definition: SystMaker.h:290
std::map< std::string, std::string > systNames
Definition: PlotUnfolding.C:32
std::map<std::string, SystMaker*> ana::SystematicsMaker::GetSystMakers ( )
inline

Definition at line 265 of file SystMaker.h.

References om::cout, dir, demo0::loader, ana::LoadFrom(), MakeISysts(), outDir, publish_reco_validation::overwrite, ana::SaveTo(), and SetCuts().

Referenced by MakeSystsPDF().

266  { return fSystMakers; };
std::map< std::string, SystMaker * > fSystMakers
Definition: SystMaker.h:290
void ana::SystematicsMaker::Go ( const covmx::Sample  sample,
osc::IOscCalc calc 
)

Definition at line 1608 of file SystMaker.cxx.

References fSample, and fSystMakers.

Referenced by MakeISysts(), and MakeSystsPDF().

1608  {
1609 
1610  fSample = sample;
1611  for (const auto& syst : fSystMakers) {
1612  syst.second->ProcessSyst(fSample, calc);
1613  fSystMakers[syst.first] = syst.second;
1614  }
1615  }
covmx::Sample fSample
Definition: SystMaker.h:297
std::map< std::string, SystMaker * > fSystMakers
Definition: SystMaker.h:290
unique_ptr< SystematicsMaker > ana::SystematicsMaker::LoadFrom ( TDirectory *  dir)
static

Definition at line 1692 of file SystMaker.cxx.

References ana::assert(), ana::SystMaker::GetName(), ana::kExtrap, findDuplicateFiles::key, ana::kFD, ana::kND, ana::kUnknown, ana::SystMaker::LoadFrom(), next(), runNovaSAM::release, stan::math::round(), and getGoodRuns4SAM::tag.

Referenced by MakeISysts().

1693  {
1694 
1695  DontAddDirectory guard;
1696 
1697  TObjString* tag = (TObjString*)dir->Get("type");
1698  assert(tag);
1699  assert(tag->GetString() == "SystematicsMaker");
1700 
1701  TObjString* tsName = (TObjString*)dir->Get("name");
1702  assert(tsName);
1703  string name(tsName->GetString().Data());
1704 
1705  const TVectorD predtype = *(TVectorD*)dir->Get("predtype");
1707  switch (static_cast<int>(std::round(predtype[0]))) {
1708  case 0:
1709  predType = SystPredType::kExtrap;
1710  break;
1711  case 1:
1712  predType = SystPredType::kFD;
1713  break;
1714  case 2:
1715  predType = SystPredType::kND;
1716  break;
1717  }
1718 
1719  unique_ptr<SystematicsMaker> systsMaker = make_unique<SystematicsMaker>(name, predType);
1720 
1721  map<string, SystMaker*> systMakers;
1722  TIter next(dir->GetDirectory("SystMakers")->GetListOfKeys());
1723  TKey* key;
1724  while ((key = (TKey*)next())) {
1725  SystMaker* systMaker
1726  = SystMaker::LoadFrom((TDirectory*)key->ReadObj()).release();
1727  systMakers[systMaker->GetName()] = systMaker;
1728  }
1729 
1730  systsMaker->fSystMakers = systMakers;
1731 
1732  return move(systsMaker);
1733 
1734  } // function SystematicsMaker::LoadFrom
const XML_Char * name
Definition: expat.h:151
fvar< T > round(const fvar< T > &x)
Definition: round.hpp:23
static std::unique_ptr< SystMaker > LoadFrom(TDirectory *dir)
LoadFrom implementation for SystMaker.
Definition: SystMaker.cxx:1477
TDirectory * dir
Definition: macro.C:5
assert(nhit_max >=nhit_nbins)
void next()
Definition: show_event.C:84
SystPredType
Definition: SystMaker.h:39
vector< NuISyst * > ana::SystematicsMaker::MakeISysts ( )

Make ISyst objects for each attached systematic and return them.

Definition at line 1568 of file SystMaker.cxx.

References fSample, fSystMakers, generic.controllers.MakeCanvases::maker, and systs.

Referenced by MakeISysts().

1568  {
1569 
1570  vector<NuISyst*> systs;
1571  for (const auto& maker : fSystMakers) {
1572  NuISyst* syst = maker.second->MakeISyst(fSample);
1573  systs.push_back(syst);
1574  }
1575  return systs;
1576 
1577  } // function SystematicsMaker::MakeISysts
std::vector< SystGroupDef > systs
Definition: syst_header.h:385
covmx::Sample fSample
Definition: SystMaker.h:297
std::map< std::string, SystMaker * > fSystMakers
Definition: SystMaker.h:290
std::string ana::SystematicsMaker::Name ( )
inline

Definition at line 262 of file SystMaker.h.

262 { return fName; }
std::string fName
Definition: SystMaker.h:287
void ana::SystematicsMaker::PrintSysts ( std::ostream &  os = std::cout)

Definition at line 1594 of file SystMaker.cxx.

References fSystMakers.

1594  {
1595  for (const auto& syst : fSystMakers)
1596  syst.second->PrintSyst(os);
1597  return;
1598  }
std::map< std::string, SystMaker * > fSystMakers
Definition: SystMaker.h:290
void ana::SystematicsMaker::SaveTo ( TDirectory *  dir,
bool  separate = false 
) const

Definition at line 1655 of file SystMaker.cxx.

References fName, fPredType, fSystMakers, ana::kExtrap, ana::kFD, ana::kND, tmp, and Write().

Referenced by MakeSysts().

1655  {
1656 
1657  TDirectory* tmp = gDirectory;
1658 
1659  dir->cd();
1660  TObjString("SystematicsMaker").Write("type");
1661 
1662  TObjString(fName.c_str()).Write("name");
1663 
1664  int predType = -1;
1665  switch (fPredType) {
1666  case SystPredType::kExtrap:
1667  predType = 0;
1668  break;
1669  case SystPredType::kFD:
1670  predType = 1;
1671  break;
1672  case SystPredType::kND:
1673  predType = 2;
1674  break;
1675  default:
1676  break;
1677  }
1678  TVectorD predtype(1);
1679  predtype[0] = predType;
1680  predtype.Write("predtype");
1681 
1682  TDirectory* systMakersDir = dir->mkdir("SystMakers");
1683  for (const auto& systMaker : fSystMakers) {
1684  systMaker.second->SaveTo(systMakersDir->mkdir(systMaker.first.c_str()));
1685  }
1686 
1687  tmp->cd();
1688 
1689  } // function SystematicsMaker::SaveTo
Float_t tmp
Definition: plot.C:36
std::string fName
Definition: SystMaker.h:287
SystPredType fPredType
Definition: SystMaker.h:288
std::map< std::string, SystMaker * > fSystMakers
Definition: SystMaker.h:290
TDirectory * dir
Definition: macro.C:5
gm Write()
void ana::SystematicsMaker::SetAxes ( const HistAxis axis,
const HistAxis numuAxis = nullptr 
)

Definition at line 1618 of file SystMaker.cxx.

References allInOneTrainingPlots::axis, fAxis, and fNuMuAxis.

Referenced by MakeSysts().

1618  {
1619  fAxis = axis;
1620  fNuMuAxis = numuAxis;
1621  }
const HistAxis * fNuMuAxis
Definition: SystMaker.h:292
const HistAxis * fAxis
Definition: SystMaker.h:292
void ana::SystematicsMaker::SetCuts ( const Cut fd_cut,
const Cut nd_cut,
const Cut numu_cut = nullptr 
)

Definition at line 1624 of file SystMaker.cxx.

References fFDCut, fNDCut, and fNuMuCut.

Referenced by MakeSysts().

1625  {
1626  fNDCut = NDCut;
1627  fFDCut = FDCut;
1628  fNuMuCut = numuCut;
1629  }
const Cut * fFDCut
Definition: SystMaker.h:293
const Cut * fNDCut
Definition: SystMaker.h:293
const Cut * fNuMuCut
Definition: SystMaker.h:293
void ana::SystematicsMaker::SetNominalLoaders ( Loaders loader,
Loaders loader_light = nullptr 
)

Definition at line 1632 of file SystMaker.cxx.

References fLightLoaders, fLoaders, and loaders.

Referenced by MakeSysts().

1632  {
1633  fLoaders = loaders;
1634  fLightLoaders = loaders_light;
1635  }
Loaders * fLightLoaders
Definition: SystMaker.h:295
std::vector< Loaders * > loaders
Definition: syst_header.h:386
void ana::SystematicsMaker::SetNominalWeight ( const Var weight)

Definition at line 1638 of file SystMaker.cxx.

References fWeight, and ana::weight.

Referenced by MakeSysts().

1638  {
1639  fWeight = weight;
1640  }
const Var weight
const Var * fWeight
Definition: SystMaker.h:296

Member Data Documentation

const HistAxis* ana::SystematicsMaker::fAxis
private

Definition at line 292 of file SystMaker.h.

Referenced by AddSystematic(), and SetAxes().

const Cut * ana::SystematicsMaker::fFDCut
private

Definition at line 293 of file SystMaker.h.

Referenced by AddSystematic(), and SetCuts().

Loaders* ana::SystematicsMaker::fLightLoaders
private

Definition at line 295 of file SystMaker.h.

Referenced by AddSystematic(), and SetNominalLoaders().

Loaders* ana::SystematicsMaker::fLoaders
private

Definition at line 294 of file SystMaker.h.

Referenced by AddSystematic(), and SetNominalLoaders().

std::string ana::SystematicsMaker::fName
private

Definition at line 287 of file SystMaker.h.

Referenced by SaveTo().

const Cut* ana::SystematicsMaker::fNDCut
private

Definition at line 293 of file SystMaker.h.

Referenced by AddSystematic(), and SetCuts().

const HistAxis * ana::SystematicsMaker::fNuMuAxis
private

Definition at line 292 of file SystMaker.h.

Referenced by AddSystematic(), and SetAxes().

const Cut * ana::SystematicsMaker::fNuMuCut
private

Definition at line 293 of file SystMaker.h.

Referenced by AddSystematic(), and SetCuts().

SystPredType ana::SystematicsMaker::fPredType
private

Definition at line 288 of file SystMaker.h.

Referenced by AddSystematic(), and SaveTo().

covmx::Sample ana::SystematicsMaker::fSample
private

Definition at line 297 of file SystMaker.h.

Referenced by Go(), and MakeISysts().

std::map<std::string, SystMaker*> ana::SystematicsMaker::fSystMakers
private
const Var* ana::SystematicsMaker::fWeight
private

Definition at line 296 of file SystMaker.h.

Referenced by AddSystematic(), and SetNominalWeight().


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