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

Just return the MC prediction for the background. More...

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-11-28/CAFAna/XSec/TrivialBkgdEstimator.h"

Inheritance diagram for ana::TrivialBkgdEstimator:
ana::IBkgdEstimator

Public Member Functions

 TrivialBkgdEstimator (SpectrumLoaderBase &lMC, const HistAxis &axis, const Cut &sel, std::vector< Cut > trueBkgds, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
 
Spectrum Background () const override
 
const SpectrumGetComponent (int) const
 
int GetNComponents () const
 
void SaveTo (TDirectory *dir, const std::string &name) const override
 
 ~TrivialBkgdEstimator ()
 
 TrivialBkgdEstimator (const TrivialBkgdEstimator &copy)
 
TrivialBkgdEstimatoroperator= (const TrivialBkgdEstimator &rhs)
 

Static Public Member Functions

static std::unique_ptr< TrivialBkgdEstimatorLoadFrom (TDirectory *dir, const std::string &name)
 

Private Member Functions

 TrivialBkgdEstimator (std::vector< Spectrum * > mcbkgd)
 

Private Attributes

std::vector< Spectrum * > fMCBkgd
 

Detailed Description

Just return the MC prediction for the background.

Definition at line 11 of file TrivialBkgdEstimator.h.

Constructor & Destructor Documentation

ana::TrivialBkgdEstimator::TrivialBkgdEstimator ( SpectrumLoaderBase lMC,
const HistAxis axis,
const Cut sel,
std::vector< Cut trueBkgds,
const SystShifts shift = kNoShift,
const Var wei = kUnweighted 
)
inline

Definition at line 14 of file TrivialBkgdEstimator.h.

References Background(), dir, fMCBkgd, GetComponent(), GetNComponents(), MECModelEnuComparisons::i, makeTrainCVSamples::int, LoadFrom(), operator=(), SaveTo(), string, and ~TrivialBkgdEstimator().

Referenced by LoadFrom().

20  {
21  for (int i = 0; i < int(trueBkgds.size()); i++)
22  fMCBkgd.push_back(new Spectrum(lMC, axis, sel && trueBkgds[i],
23  shift,wei));
24  }
std::vector< float > Spectrum
Definition: Constants.h:610
std::vector< Spectrum * > fMCBkgd
ana::TrivialBkgdEstimator::~TrivialBkgdEstimator ( )

Definition at line 75 of file TrivialBkgdEstimator.cxx.

References fMCBkgd, MECModelEnuComparisons::i, and makeTrainCVSamples::int.

Referenced by TrivialBkgdEstimator().

75  {
76  for(int i = 0; i < (int) fMCBkgd.size(); i++) {
77  delete fMCBkgd[i];
78  }
79  }
std::vector< Spectrum * > fMCBkgd
ana::TrivialBkgdEstimator::TrivialBkgdEstimator ( const TrivialBkgdEstimator copy)

Definition at line 81 of file TrivialBkgdEstimator.cxx.

References fMCBkgd.

81  {
82  fMCBkgd = copy.fMCBkgd;
83  }
std::vector< Spectrum * > fMCBkgd
ana::TrivialBkgdEstimator::TrivialBkgdEstimator ( std::vector< Spectrum * >  mcbkgd)
inlineprivate

Definition at line 34 of file TrivialBkgdEstimator.h.

35  : fMCBkgd(mcbkgd)
36  {}
std::vector< Spectrum * > fMCBkgd

Member Function Documentation

Spectrum ana::TrivialBkgdEstimator::Background ( ) const
overridevirtual

Implements ana::IBkgdEstimator.

Definition at line 22 of file TrivialBkgdEstimator.cxx.

References ana::assert(), fMCBkgd, MECModelEnuComparisons::i, makeTrainCVSamples::int, and runNovaSAM::ret.

Referenced by ana::TrivialSignalEstimator::Background(), ana::TrivialSignalEstimator::Signal(), TrivialBkgdEstimator(), Unfold1D(), and Unfold3D().

23  {
24  assert(fMCBkgd.size() > 0 && "No background given to estimator");
25  Spectrum ret = *fMCBkgd[0];
26  for (int i = 1; i < int(fMCBkgd.size()); i++)
27  ret += *fMCBkgd[i];
28  return ret;
29  }
std::vector< float > Spectrum
Definition: Constants.h:610
assert(nhit_max >=nhit_nbins)
std::vector< Spectrum * > fMCBkgd
const Spectrum * ana::TrivialBkgdEstimator::GetComponent ( int  n) const

Definition at line 16 of file TrivialBkgdEstimator.cxx.

References fMCBkgd, and getGoodRuns4SAM::n.

Referenced by ana::TrivialSignalEstimator::BackgroundComponent(), and TrivialBkgdEstimator().

17  {
18  // assert(n < (int) fMCBkgd.size() && "Index out of range");
19  return fMCBkgd[n];
20  }
std::vector< Spectrum * > fMCBkgd
int ana::TrivialBkgdEstimator::GetNComponents ( ) const

Definition at line 10 of file TrivialBkgdEstimator.cxx.

References fMCBkgd.

Referenced by ana::TrivialSignalEstimator::GetNBkgdComponents(), and TrivialBkgdEstimator().

11  {
12  return fMCBkgd.size();
13  }
std::vector< Spectrum * > fMCBkgd
std::unique_ptr< TrivialBkgdEstimator > ana::TrivialBkgdEstimator::LoadFrom ( TDirectory *  dir,
const std::string name 
)
static

Definition at line 55 of file TrivialBkgdEstimator.cxx.

References ana::assert(), dir, MECModelEnuComparisons::i, runNovaSAM::release, art::to_string(), and TrivialBkgdEstimator().

Referenced by ana::TrivialSignalEstimator::LoadFrom(), ana::LoadFrom< IBkgdEstimator >(), TrivialBkgdEstimator(), Unfold1D(), and Unfold3D().

56  {
57  dir = dir->GetDirectory(name.c_str()); // switch to subdir
58  assert(dir);
59 
60  TVectorD* nmcbkgd = (TVectorD*)dir->Get("nmcbkgd");
61  assert(nmcbkgd->GetNoElements()==1 && "N MCBkgds is not 1.");
62  std::vector<Spectrum*> mcbkgd;
63  dir->cd();
64  for (int i = 0; i < (*nmcbkgd)[0]; i++){
65  mcbkgd.push_back(ana::LoadFrom<Spectrum>(dir, "fMCBkgd_"+std::to_string(i)).release());
66  }
67 
68  delete dir;
69 
70  return std::unique_ptr<TrivialBkgdEstimator>(
71  new TrivialBkgdEstimator(mcbkgd));
72  }
const XML_Char * name
Definition: expat.h:151
TDirectory * dir
Definition: macro.C:5
TrivialBkgdEstimator(SpectrumLoaderBase &lMC, const HistAxis &axis, const Cut &sel, std::vector< Cut > trueBkgds, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
assert(nhit_max >=nhit_nbins)
std::string to_string(ModuleType mt)
Definition: ModuleType.h:32
TrivialBkgdEstimator & ana::TrivialBkgdEstimator::operator= ( const TrivialBkgdEstimator rhs)

Definition at line 86 of file TrivialBkgdEstimator.cxx.

References fMCBkgd.

Referenced by TrivialBkgdEstimator().

86  {
87  if(this == & rhs) return *this;
88  else {
89  fMCBkgd = rhs.fMCBkgd;
90  return *this;
91  }
92  }
std::vector< Spectrum * > fMCBkgd
void ana::TrivialBkgdEstimator::SaveTo ( TDirectory *  dir,
const std::string name 
) const
overridevirtual

Implements ana::IBkgdEstimator.

Definition at line 31 of file TrivialBkgdEstimator.cxx.

References dir, fMCBkgd, MECModelEnuComparisons::i, makeTrainCVSamples::int, tmp, and art::to_string().

Referenced by ana::TrivialSignalEstimator::SaveTo(), and TrivialBkgdEstimator().

32  {
33  TDirectory *tmp = gDirectory;
34 
35  dir = dir->mkdir(name.c_str()); // switch to subdir
36  dir->cd();
37 
38  TObjString("TrivialBkgdEstimator").Write("type");
39 
40  // Need a way to save a vector of Spectrum*
41  TVectorD nmcbkgd(1);
42  nmcbkgd[0] = fMCBkgd.size();
43  nmcbkgd.Write("nmcbkgd");
44  for (int i = 0; i < int(fMCBkgd.size()); i++){
45  fMCBkgd[i]->SaveTo(dir, "fMCBkgd_"+std::to_string(i));
46  }
47 
48  dir->Write();
49  delete dir;
50 
51  tmp->cd();
52  }
const XML_Char * name
Definition: expat.h:151
Float_t tmp
Definition: plot.C:36
TDirectory * dir
Definition: macro.C:5
std::string to_string(ModuleType mt)
Definition: ModuleType.h:32
std::vector< Spectrum * > fMCBkgd

Member Data Documentation

std::vector<Spectrum*> ana::TrivialBkgdEstimator::fMCBkgd
private

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