All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
ana::ReweightableSpectrum Class Reference

Spectrum with the value of a second variable, allowing for reweighting More...

#include <ReweightableSpectrum.h>

Inheritance diagram for ana::ReweightableSpectrum:
ana::OscillatableSpectrum

Public Member Functions

 ReweightableSpectrum (SpectrumLoaderBase &loader, const HistAxis &recoAxis, const HistAxis &trueAxis, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
 
 ReweightableSpectrum (SpectrumLoaderBase &loader, const HistAxis &recoAxis, const HistAxis &trueAxis, const SpillCut &spillcut, const SliceCut &slicecut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
 
 ReweightableSpectrum (const Var &rwVar, const std::string &xlabel, const std::string &ylabel, double pot, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax)
 
 ReweightableSpectrum (const Var &rwVar, TH2 *h, const std::vector< std::string > &labels, const std::vector< Binning > &bins, double pot, double livetime)
 
 ReweightableSpectrum (const Var &rwVar, std::unique_ptr< TH2D > h, const std::vector< std::string > &labels, const std::vector< Binning > &bins, double pot, double livetime)
 
virtual ~ReweightableSpectrum ()
 
 ReweightableSpectrum (const ReweightableSpectrum &rhs)
 
ReweightableSpectrumoperator= (const ReweightableSpectrum &rhs)
 
const VarReweightVar () const
 The variable that will be used to fill the y-axis. More...
 
void Fill (double x, double y, double w=1)
 
TH2D * ToTH2 (double pot) const
 
Spectrum UnWeighted () const
 
Spectrum WeightingVariable () const
 
Spectrum WeightedBy (const TH1 *weights) const
 
void ReweightToTrueSpectrum (const Spectrum &target)
 Rescale bins so that WeightingVariable will return target. More...
 
void ReweightToRecoSpectrum (const Spectrum &target)
 Recale bins so that Unweighted will return target. More...
 
void Clear ()
 
void SaveTo (TDirectory *dir) const
 
unsigned int NDimensions () const
 
std::vector< std::string > GetLabels () const
 
std::vector< BinningGetBinnings () const
 

Static Public Member Functions

static std::unique_ptr
< ReweightableSpectrum
LoadFrom (TDirectory *dir)
 

Protected Member Functions

 ReweightableSpectrum (const std::vector< std::string > &labels, const std::vector< Binning > &bins, const Var &rwVar)
 
 ReweightableSpectrum (const std::string &label, const Binning &bins, const Var &rwVar)
 
 ReweightableSpectrum (TH2 *h, const std::vector< std::string > &labels, const std::vector< Binning > &bins, double pot, double livetime)
 
void RemoveLoader (SpectrumLoaderBase *)
 
void AddLoader (SpectrumLoaderBase *)
 

Protected Attributes

Var fRWVar
 What goes on the y axis? More...
 
TH2D * fHist
 
double fPOT
 
double fLivetime
 
std::vector< std::string > fLabels
 
std::vector< BinningfBins
 
std::string fTrueLabel
 
std::set< SpectrumLoaderBase * > fLoaderCount
 This count is maintained by SpectrumLoader, as a sanity check. More...
 

Friends

class SpectrumLoaderBase
 
class SpectrumLoader
 
class NullLoader
 
class MRCCLoader
 

Detailed Description

Spectrum with the value of a second variable, allowing for reweighting

Definition at line 14 of file ReweightableSpectrum.h.

Constructor & Destructor Documentation

ana::ReweightableSpectrum::ReweightableSpectrum ( SpectrumLoaderBase loader,
const HistAxis recoAxis,
const HistAxis trueAxis,
const Cut cut,
const SystShifts shift = kNoShift,
const Var wei = kUnweighted 
)

Definition at line 21 of file ReweightableSpectrum.cxx.

27  : ReweightableSpectrum(loader, recoAxis, trueAxis, kNoSpillCut, cut, shift, wei)
28  {
29  }
tuple loader
Definition: demo.py:7
shift
Definition: fcl_checks.sh:26
const SpillCut kNoSpillCut([](const caf::SRSpillProxy *){return true;})
The simplest possible cut: pass everything, used as a default.
ReweightableSpectrum(SpectrumLoaderBase &loader, const HistAxis &recoAxis, const HistAxis &trueAxis, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
ana::ReweightableSpectrum::ReweightableSpectrum ( SpectrumLoaderBase loader,
const HistAxis recoAxis,
const HistAxis trueAxis,
const SpillCut spillcut,
const SliceCut slicecut,
const SystShifts shift = kNoShift,
const Var wei = kUnweighted 
)

Definition at line 32 of file ReweightableSpectrum.cxx.

39  : ReweightableSpectrum(recoAxis.GetLabels(), recoAxis.GetBinnings(),
40  trueAxis.GetVars()[0])
41  {
42  assert(trueAxis.NDimensions() == 1);
43 
44  fTrueLabel = trueAxis.GetLabels()[0];
45 
46  DontAddDirectory guard;
47 
48  // Can't use HistCache here because y-axis is not necessarily
49  // TrueEnergyBinning. TODO - that should maybe be generalized.
50 
51  const std::string name = UniqueName();
52 
53  Binning xbins = fBins[0];
54  if(fBins.size() > 1){
55  int n = 1;
56  for(const Binning& b: fBins) n *= b.NBins();
57  xbins = Binning::Simple(n, 0, n);
58  }
59 
60  const Binning ybins = trueAxis.GetBinnings()[0];
61 
62 
63  // Ugh combinatorics
64  if(xbins.IsSimple() && ybins.IsSimple())
65  fHist = new TH2D(name.c_str(), "",
66  xbins.NBins(), xbins.Min(), xbins.Max(),
67  ybins.NBins(), ybins.Min(), ybins.Max());
68 
69  if(xbins.IsSimple() && !ybins.IsSimple())
70  fHist = new TH2D(name.c_str(), "",
71  xbins.NBins(), xbins.Min(), xbins.Max(),
72  ybins.NBins(), &ybins.Edges()[0]);
73 
74  if(!xbins.IsSimple() && ybins.IsSimple())
75  fHist = new TH2D(name.c_str(), "",
76  xbins.NBins(), &xbins.Edges()[0],
77  ybins.NBins(), ybins.Min(), ybins.Max());
78 
79  if(!xbins.IsSimple() && !ybins.IsSimple())
80  fHist = new TH2D(name.c_str(), "",
81  xbins.NBins(), &xbins.Edges()[0],
82  ybins.NBins(), &ybins.Edges()[0]);
83 
84  loader.AddReweightableSpectrum(*this, recoAxis.GetMultiDVar(), spillcut, slicecut, shift, wei);
85  }
tuple loader
Definition: demo.py:7
shift
Definition: fcl_checks.sh:26
std::vector< Binning > fBins
then echo fcl name
ReweightableSpectrum(SpectrumLoaderBase &loader, const HistAxis &recoAxis, const HistAxis &trueAxis, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
Definition: Binning.cxx:38
std::string UniqueName()
Return a different string each time, for creating histograms.
ana::ReweightableSpectrum::ReweightableSpectrum ( const Var rwVar,
const std::string &  xlabel,
const std::string &  ylabel,
double  pot,
int  nbinsx,
double  xmin,
double  xmax,
int  nbinsy,
double  ymin,
double  ymax 
)

Definition at line 88 of file ReweightableSpectrum.cxx.

93  : ReweightableSpectrum(xlabel,
94  Binning::Simple(nbinsx, xmin, xmax),
95  rwVar)
96  {
97  DontAddDirectory guard;
98 
99  fHist = new TH2D(UniqueName().c_str(), "",
100  nbinsx, xmin, xmax, nbinsy, ymin, ymax);
101 
102  fTrueLabel = ylabel;
103 
104  // Ensure errors get accumulated properly
105  fHist->Sumw2();
106  }
process_name pandoraGausCryo1 vertexChargeCryo1 vertexStubCryo1 xmin
ReweightableSpectrum(SpectrumLoaderBase &loader, const HistAxis &recoAxis, const HistAxis &trueAxis, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
Definition: Binning.cxx:38
std::string UniqueName()
Return a different string each time, for creating histograms.
ana::ReweightableSpectrum::ReweightableSpectrum ( const Var rwVar,
TH2 *  h,
const std::vector< std::string > &  labels,
const std::vector< Binning > &  bins,
double  pot,
double  livetime 
)

Definition at line 109 of file ReweightableSpectrum.cxx.

113  : ReweightableSpectrum(labels, bins, rwVar)
114  {
115  fPOT = pot;
116  fLivetime = livetime;
117 
118  if(!h){
119  fHist = 0;
120  return;
121  }
122 
123  DontAddDirectory guard;
124 
125  const TString className = h->ClassName();
126 
127  if(className == "TH2D"){
128  // Shortcut if types match
129  fHist = new TH2D(*((TH2D*)h));
130  }
131  else{
132  const TAxis* ax = h->GetXaxis();
133  const TAxis* ay = h->GetYaxis();
134  // Must have both or neither
135  assert(bool(ax->GetXbins()->GetArray()) == bool(ay->GetXbins()->GetArray()));
136 
137  if(ax->GetXbins()->GetArray()){
138  fHist = new TH2D(UniqueName().c_str(), "",
139  ax->GetNbins(), ax->GetXbins()->GetArray(),
140  ay->GetNbins(), ay->GetXbins()->GetArray());
141  }
142  else{
143  fHist = new TH2D(UniqueName().c_str(), "",
144  ax->GetNbins(), ax->GetXmin(), ax->GetXmax(),
145  ay->GetNbins(), ay->GetXmin(), ay->GetXmax());
146  }
147 
148  fHist->Add(h);
149  }
150 
151  fTrueLabel = h->GetYaxis()->GetTitle();
152  }
while getopts h
ReweightableSpectrum(SpectrumLoaderBase &loader, const HistAxis &recoAxis, const HistAxis &trueAxis, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
std::string UniqueName()
Return a different string each time, for creating histograms.
ana::ReweightableSpectrum::ReweightableSpectrum ( const Var rwVar,
std::unique_ptr< TH2D >  h,
const std::vector< std::string > &  labels,
const std::vector< Binning > &  bins,
double  pot,
double  livetime 
)

Definition at line 155 of file ReweightableSpectrum.cxx.

160  : ReweightableSpectrum(labels, bins, rwVar)
161  {
162  fHist = h.release();
163  fPOT = pot;
164  fLivetime = livetime;
165 
166  fTrueLabel = fHist->GetYaxis()->GetTitle();
167  }
ReweightableSpectrum(SpectrumLoaderBase &loader, const HistAxis &recoAxis, const HistAxis &trueAxis, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
ana::ReweightableSpectrum::~ReweightableSpectrum ( )
virtual

Definition at line 170 of file ReweightableSpectrum.cxx.

171  {
172  if(fHist && fHist->GetDirectory()){
173  static bool once = true;
174  if(once){
175  once = false;
176  std::cerr << "ReweightableSpectrum's fHist is associated with a directory. How did that happen?" << std::endl;
177  }
178  }
179 
180  // Can't use HistCache here because that expects all 2D spectra have the
181  // usual true energy binning on their y-axis. In the case that we're
182  // actually an OscillatableSpectrum that destructor will indeed take care
183  // of invoking HistCache.
184  delete fHist;
185  }
BEGIN_PROLOG could also be cerr
ana::ReweightableSpectrum::ReweightableSpectrum ( const ReweightableSpectrum rhs)

Definition at line 188 of file ReweightableSpectrum.cxx.

189  : fRWVar(rhs.fRWVar), fLabels(rhs.fLabels), fBins(rhs.fBins)
190  {
191  DontAddDirectory guard;
192 
193  fHist = new TH2D(*rhs.fHist);
194 
195  fPOT = rhs.fPOT;
196  fLivetime = rhs.fLivetime;
197 
198  assert( rhs.fLoaderCount.empty() ); // Copying with pending loads is unexpected
199  }
Var fRWVar
What goes on the y axis?
std::vector< std::string > fLabels
std::vector< Binning > fBins
ana::ReweightableSpectrum::ReweightableSpectrum ( const std::vector< std::string > &  labels,
const std::vector< Binning > &  bins,
const Var rwVar 
)
inlineprotected

Definition at line 97 of file ReweightableSpectrum.h.

100  : fRWVar(rwVar),
101  fHist(0), fPOT(0), fLivetime(0),
102  fLabels(labels), fBins(bins)
103  {
104  }
Var fRWVar
What goes on the y axis?
std::vector< std::string > fLabels
std::vector< Binning > fBins
ana::ReweightableSpectrum::ReweightableSpectrum ( const std::string &  label,
const Binning bins,
const Var rwVar 
)
inlineprotected

Definition at line 106 of file ReweightableSpectrum.h.

109  : fRWVar(rwVar),
110  fHist(0), fPOT(0), fLivetime(0),
111  fLabels(1, label), fBins(1, bins)
112  {
113  }
Var fRWVar
What goes on the y axis?
std::vector< std::string > fLabels
std::vector< Binning > fBins
ana::ReweightableSpectrum::ReweightableSpectrum ( TH2 *  h,
const std::vector< std::string > &  labels,
const std::vector< Binning > &  bins,
double  pot,
double  livetime 
)
inlineprotected

Constructor needed by LoadFrom. Since there's no good way to store a Var, ReweightVar will return nonsense for ReweightableSpectrum that are loaded from a file

Definition at line 118 of file ReweightableSpectrum.h.

122  : ReweightableSpectrum(kUnweighted, h, labels, bins, pot, livetime)
123  {
124  }
while getopts h
const Var kUnweighted([](const caf::SRSliceProxy *){return 1;})
The simplest possible Var, always 1. Used as a default weight.
ReweightableSpectrum(SpectrumLoaderBase &loader, const HistAxis &recoAxis, const HistAxis &trueAxis, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)

Member Function Documentation

void ana::ReweightableSpectrum::AddLoader ( SpectrumLoaderBase p)
protected

Definition at line 456 of file ReweightableSpectrum.cxx.

457  { fLoaderCount.insert(p); }
pdgs p
Definition: selectors.fcl:22
std::set< SpectrumLoaderBase * > fLoaderCount
This count is maintained by SpectrumLoader, as a sanity check.
void ana::ReweightableSpectrum::Clear ( )

Definition at line 446 of file ReweightableSpectrum.cxx.

447  {
448  fHist->Reset();
449  }
void ana::ReweightableSpectrum::Fill ( double  x,
double  y,
double  w = 1 
)

Definition at line 249 of file ReweightableSpectrum.cxx.

250  {
251  fHist->Fill(x, y, w);
252  }
process_name opflash particleana ie x
process_name opflash particleana ie ie y
std::vector<Binning> ana::ReweightableSpectrum::GetBinnings ( ) const
inline

Definition at line 93 of file ReweightableSpectrum.h.

93 {return fBins;}
std::vector< Binning > fBins
std::vector<std::string> ana::ReweightableSpectrum::GetLabels ( ) const
inline

Definition at line 92 of file ReweightableSpectrum.h.

92 {return fLabels;}
std::vector< std::string > fLabels
std::unique_ptr< ReweightableSpectrum > ana::ReweightableSpectrum::LoadFrom ( TDirectory *  dir)
static

Definition at line 485 of file ReweightableSpectrum.cxx.

486  {
487  TObjString* tag = (TObjString*)dir->Get("type");
488  assert(tag);
489  assert(tag->GetString() == "ReweightableSpectrum");
490 
491  TH2D* spect = (TH2D*)dir->Get("hist");
492  assert(spect);
493  TH1* hPot = (TH1*)dir->Get("pot");
494  assert(hPot);
495  TH1* hLivetime = (TH1*)dir->Get("livetime");
496  assert(hLivetime);
497 
498  std::vector<std::string> labels;
499  std::vector<Binning> bins;
500 
501  for(int i = 0; ; ++i){
502  TDirectory* subdir = dir->GetDirectory(TString::Format("bins%d", i));
503  if(!subdir) break;
504  bins.push_back(*Binning::LoadFrom(subdir));
505  TObjString* label = (TObjString*)dir->Get(TString::Format("label%d", i));
506  labels.push_back(label ? label->GetString().Data() : "");
507  }
508 
509  if(bins.empty() && labels.empty()){
510  // Must be an old file. Make an attempt at backwards compatibility.
511  bins.push_back(Binning::FromTAxis(spect->GetXaxis()));
512  labels.push_back(spect->GetXaxis()->GetTitle());
513  }
514 
515  return std::make_unique<ReweightableSpectrum>(kUnweighted,
516  spect,
517  labels, bins,
518  hPot->GetBinContent(1),
519  hLivetime->GetBinContent(1));
520  }
* labels
static Binning FromTAxis(const TAxis *ax)
Definition: Binning.cxx:122
tuple dir
Definition: dropbox.py:28
const Var kUnweighted([](const caf::SRSliceProxy *){return 1;})
The simplest possible Var, always 1. Used as a default weight.
static std::unique_ptr< Binning > LoadFrom(TDirectory *dir)
Definition: Binning.cxx:229
unsigned int ana::ReweightableSpectrum::NDimensions ( ) const
inline

Definition at line 91 of file ReweightableSpectrum.h.

91 {return fLabels.size();}
std::vector< std::string > fLabels
ReweightableSpectrum & ana::ReweightableSpectrum::operator= ( const ReweightableSpectrum rhs)

Definition at line 202 of file ReweightableSpectrum.cxx.

203  {
204  if(this == &rhs) return *this;
205 
206  DontAddDirectory guard;
207 
208  fRWVar = rhs.fRWVar;
209  fLabels = rhs.fLabels;
210  fBins = rhs.fBins;
211 
212  delete fHist;
213  fHist = new TH2D(*rhs.fHist);
214  fPOT = rhs.fPOT;
215  fLivetime = rhs.fLivetime;
216 
217  assert( fLoaderCount.empty() ); // Copying with pending loads is unexpected
218 
219  return *this;
220  }
Var fRWVar
What goes on the y axis?
std::set< SpectrumLoaderBase * > fLoaderCount
This count is maintained by SpectrumLoader, as a sanity check.
std::vector< std::string > fLabels
std::vector< Binning > fBins
void ana::ReweightableSpectrum::RemoveLoader ( SpectrumLoaderBase p)
protected

Definition at line 452 of file ReweightableSpectrum.cxx.

453  { fLoaderCount.erase(p); }
pdgs p
Definition: selectors.fcl:22
std::set< SpectrumLoaderBase * > fLoaderCount
This count is maintained by SpectrumLoader, as a sanity check.
void ana::ReweightableSpectrum::ReweightToRecoSpectrum ( const Spectrum target)

Recale bins so that Unweighted will return target.

Definition at line 410 of file ReweightableSpectrum.cxx.

411  {
412  // This is a big component of what extrapolations do, so it has been
413  // optimized for speed
414 
415  Ratio corr(target, UnWeighted());
416  std::unique_ptr<TH1D> hcorr(corr.ToTH1());
417 
418  assert(hcorr->GetNbinsX() == fHist->GetNbinsX());
419 
420  const int X = fHist->GetNbinsX();
421  const int Y = fHist->GetNbinsY();
422 
423  // Direct access to the bins is faster
424  double* histArr = fHist->GetArray();
425  double* corrArr = hcorr->GetArray();
426 
427  int bin = 0;
428  for(int y = 0; y < Y+2; ++y){
429  for(int x = 0; x < X+2; ++x){
430  // Our loops go over the bins in the order they are internally in
431  // fHist, and we do overflows, so we keep up exactly. If you get
432  // paranoid, reenable this briefly.
433 
434  // assert(bin == fHist->GetBin(x, y));
435 
436  histArr[bin] *= corrArr[x];
437  ++bin;
438  }
439  }
440 
441  TH1D* todel = hcorr.release();
442  HistCache::Delete(todel);
443  }
process_name opflash particleana ie x
then echo echo For and will not be changed by echo further linking echo echo B echo The symbol is in the uninitialized data multiple common symbols may appear with the echo same name If the symbol is defined the common echo symbols are treated as undefined references For more echo details on common see the discussion of warn common echo in *Note Linker see the discussion of warn common echo in *Note Linker such as a global int variable echo as opposed to a large global array echo echo I echo The symbol is an indirect reference to another symbol This echo is a GNU extension to the a out object file format which is echo rarely used echo echo N echo The symbol is a debugging symbol echo echo R echo The symbol is in a read only data section echo echo S echo The symbol is in an uninitialized data section for small echo objects echo echo T echo The symbol is in the the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo W echo The symbol is a weak symbol that has not been specifically echo tagged as a weak object symbol When a weak defined symbol echo is linked with a normal defined the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo echo The symbol is a stabs symbol in an a out object file In echo this the next values printed are the stabs other echo the stabs desc and the stab type Stabs symbols are echo used to hold debugging information For more echo see *Note or object file format specific echo echo For Mac OS X
constexpr details::BinObj< T > bin(T value)
Returns a wrapper to print the specified data in binary format.
process_name opflash particleana ie ie y
static void Delete(TH1D *&h)
Definition: HistCache.cxx:92
void ana::ReweightableSpectrum::ReweightToTrueSpectrum ( const Spectrum target)

Rescale bins so that WeightingVariable will return target.

Definition at line 373 of file ReweightableSpectrum.cxx.

374  {
375  // This is a big component of what extrapolations do, so it has been
376  // optimized for speed
377 
378  Ratio corr(target, WeightingVariable());
379  std::unique_ptr<TH1D> hcorr(corr.ToTH1());
380 
381  assert(hcorr->GetNbinsX() == fHist->GetNbinsY());
382 
383  const int X = fHist->GetNbinsX();
384  const int Y = fHist->GetNbinsY();
385 
386  // Direct access to the bins is faster
387  double* histArr = fHist->GetArray();
388  double* corrArr = hcorr->GetArray();
389 
390  int bin = 0;
391  for(int y = 0; y < Y+2; ++y){
392  const double w = corrArr[y];
393  for(int x = 0; x < X+2; ++x){
394  // Our loops go over the bins in the order they are internally in
395  // fHist, and we do overflows, so we keep up exactly. If you get
396  // paranoid, reenable this briefly.
397 
398  // assert(bin == fHist->GetBin(x, y));
399 
400  histArr[bin] *= w;
401  ++bin;
402  }
403  }
404 
405  TH1D* todel = hcorr.release();
406  HistCache::Delete(todel);
407  }
process_name opflash particleana ie x
then echo echo For and will not be changed by echo further linking echo echo B echo The symbol is in the uninitialized data multiple common symbols may appear with the echo same name If the symbol is defined the common echo symbols are treated as undefined references For more echo details on common see the discussion of warn common echo in *Note Linker see the discussion of warn common echo in *Note Linker such as a global int variable echo as opposed to a large global array echo echo I echo The symbol is an indirect reference to another symbol This echo is a GNU extension to the a out object file format which is echo rarely used echo echo N echo The symbol is a debugging symbol echo echo R echo The symbol is in a read only data section echo echo S echo The symbol is in an uninitialized data section for small echo objects echo echo T echo The symbol is in the the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo W echo The symbol is a weak symbol that has not been specifically echo tagged as a weak object symbol When a weak defined symbol echo is linked with a normal defined the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo echo The symbol is a stabs symbol in an a out object file In echo this the next values printed are the stabs other echo the stabs desc and the stab type Stabs symbols are echo used to hold debugging information For more echo see *Note or object file format specific echo echo For Mac OS X
constexpr details::BinObj< T > bin(T value)
Returns a wrapper to print the specified data in binary format.
process_name opflash particleana ie ie y
static void Delete(TH1D *&h)
Definition: HistCache.cxx:92
const Var& ana::ReweightableSpectrum::ReweightVar ( ) const
inline

The variable that will be used to fill the y-axis.

By convention, return zero if the information can't be obtained, and this event will be skipped.

Definition at line 64 of file ReweightableSpectrum.h.

64 {return fRWVar;}
Var fRWVar
What goes on the y axis?
void ana::ReweightableSpectrum::SaveTo ( TDirectory *  dir) const

Function to save a ReweightableSpectrum to file the fRWVar member is not written to file, so when the spectrum is loaded back from file, ReweightVar should not be accessed, but reweighting still works

Definition at line 460 of file ReweightableSpectrum.cxx.

461  {
462  TDirectory* tmp = gDirectory;
463  dir->cd();
464 
465  TObjString("ReweightableSpectrum").Write("type");
466 
467  fHist->GetYaxis()->SetTitle(fTrueLabel.c_str());
468  fHist->Write("hist");
469  TH1D hPot("", "", 1, 0, 1);
470  hPot.Fill(.5, fPOT);
471  hPot.Write("pot");
472  TH1D hLivetime("", "", 1, 0, 1);
473  hLivetime.Fill(.5, fLivetime);
474  hLivetime.Write("livetime");
475 
476  for(unsigned int i = 0; i < fBins.size(); ++i){
477  TObjString(fLabels[i].c_str()).Write(TString::Format("label%d", i).Data());
478  fBins[i].SaveTo(dir->mkdir(TString::Format("bins%d", i)));
479  }
480 
481  tmp->cd();
482  }
std::vector< std::string > fLabels
tuple dir
Definition: dropbox.py:28
std::vector< Binning > fBins
TH2D * ana::ReweightableSpectrum::ToTH2 ( double  pot) const

Definition at line 223 of file ReweightableSpectrum.cxx.

224  {
225  // Could have a file temporarily open
226  DontAddDirectory guard;
227 
228  TH2D* ret = new TH2D(*fHist);
229  ret->SetName(UniqueName().c_str());
230  if(fPOT){
231  ret->Scale(pot/fPOT);
232  }
233  else{
234  // How did it get events with no POT?
235  assert(ret->Integral() == 0);
236  }
237 
238 
239  std::string label;
240  for(const std::string& l: fLabels) label += l + " and ";
241  label.resize(label.size()-5); // drop the last "and"
242  ret->GetXaxis()->SetTitle(label.c_str());
243  ret->GetYaxis()->SetTitle(fTrueLabel.c_str());
244 
245  return ret;
246  }
std::vector< std::string > fLabels
std::string UniqueName()
Return a different string each time, for creating histograms.
Spectrum ana::ReweightableSpectrum::UnWeighted ( ) const

Definition at line 281 of file ReweightableSpectrum.cxx.

282  {
283  DontAddDirectory guard;
284 
285  // Create a suitably-sized space for the result
286  std::unique_ptr<TH1D> h(HistCache::New("", fHist->GetXaxis()));
287 
288  ProjectionX(fHist, h.get());
289 
290  return Spectrum(std::move(h), fLabels, fBins, fPOT, fLivetime);
291  }
while getopts h
std::vector< std::string > fLabels
void ProjectionX(TH2D *from, TH1D *to)
Helper for Unweighted.
static TH1D * New(const std::string &title, const Binning &bins)
Definition: HistCache.cxx:21
std::vector< Binning > fBins
Spectrum ana::ReweightableSpectrum::WeightedBy ( const TH1 *  weights) const

Definition at line 333 of file ReweightableSpectrum.cxx.

334  {
335  // This function is in the inner loop of oscillation fits, so some
336  // optimization has been done.
337 
338  DontAddDirectory guard;
339 
340  assert(ws->GetNbinsX() == fHist->GetNbinsY());
341 
342  TAxis* ax = fHist->GetXaxis();
343  TH1D* hRet = HistCache::New("", ax);
344 
345  const int X = fHist->GetNbinsX();
346  const int Y = fHist->GetNbinsY();
347 
348  // Direct access to the bins is faster
349  double* retArr = hRet->GetArray();
350  double* histArr = fHist->GetArray();
351 
352  int bin = 0;
353  for(int y = 0; y < Y+2; ++y){
354  const double w = ws->GetBinContent(y);
355  for(int x = 0; x < X+2; ++x){
356  // Our loops go over the bins in the order they are internally in
357  // fHist, and we do overflows, so we keep up exactly. If you get
358  // paranoid, reenable this briefly.
359 
360  // assert(bin == fHist->GetBin(x, y));
361 
362  retArr[x] += histArr[bin]*w;
363  ++bin;
364  }
365  }
366 
367  // TODO: can this all be more efficient?
368  return Spectrum(std::unique_ptr<TH1D>(hRet), fLabels, fBins, fPOT, fLivetime);
369  }
process_name opflash particleana ie x
then echo echo For and will not be changed by echo further linking echo echo B echo The symbol is in the uninitialized data multiple common symbols may appear with the echo same name If the symbol is defined the common echo symbols are treated as undefined references For more echo details on common see the discussion of warn common echo in *Note Linker see the discussion of warn common echo in *Note Linker such as a global int variable echo as opposed to a large global array echo echo I echo The symbol is an indirect reference to another symbol This echo is a GNU extension to the a out object file format which is echo rarely used echo echo N echo The symbol is a debugging symbol echo echo R echo The symbol is in a read only data section echo echo S echo The symbol is in an uninitialized data section for small echo objects echo echo T echo The symbol is in the the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo W echo The symbol is a weak symbol that has not been specifically echo tagged as a weak object symbol When a weak defined symbol echo is linked with a normal defined the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo echo The symbol is a stabs symbol in an a out object file In echo this the next values printed are the stabs other echo the stabs desc and the stab type Stabs symbols are echo used to hold debugging information For more echo see *Note or object file format specific echo echo For Mac OS X
constexpr details::BinObj< T > bin(T value)
Returns a wrapper to print the specified data in binary format.
process_name opflash particleana ie ie y
std::vector< std::string > fLabels
static TH1D * New(const std::string &title, const Binning &bins)
Definition: HistCache.cxx:21
std::vector< Binning > fBins
Spectrum ana::ReweightableSpectrum::WeightingVariable ( ) const

Definition at line 320 of file ReweightableSpectrum.cxx.

321  {
322  DontAddDirectory guard;
323 
324  // Create a suitably-sized space for the result
325  std::unique_ptr<TH1D> h(HistCache::New("", fHist->GetYaxis()));
326 
327  ProjectionY(fHist, h.get());
328 
329  return Spectrum(std::move(h), fLabels, fBins, fPOT, fLivetime);
330  }
void ProjectionY(TH2D *from, TH1D *to)
Helper for WeightingVariable.
while getopts h
std::vector< std::string > fLabels
static TH1D * New(const std::string &title, const Binning &bins)
Definition: HistCache.cxx:21
std::vector< Binning > fBins

Friends And Related Function Documentation

friend class MRCCLoader
friend

Definition at line 20 of file ReweightableSpectrum.h.

friend class NullLoader
friend

Definition at line 19 of file ReweightableSpectrum.h.

friend class SpectrumLoader
friend

Definition at line 18 of file ReweightableSpectrum.h.

friend class SpectrumLoaderBase
friend

Definition at line 17 of file ReweightableSpectrum.h.

Member Data Documentation

std::vector<Binning> ana::ReweightableSpectrum::fBins
protected

Definition at line 136 of file ReweightableSpectrum.h.

TH2D* ana::ReweightableSpectrum::fHist
protected

Definition at line 131 of file ReweightableSpectrum.h.

std::vector<std::string> ana::ReweightableSpectrum::fLabels
protected

Definition at line 135 of file ReweightableSpectrum.h.

double ana::ReweightableSpectrum::fLivetime
protected

Definition at line 133 of file ReweightableSpectrum.h.

std::set<SpectrumLoaderBase*> ana::ReweightableSpectrum::fLoaderCount
protected

This count is maintained by SpectrumLoader, as a sanity check.

Definition at line 141 of file ReweightableSpectrum.h.

double ana::ReweightableSpectrum::fPOT
protected

Definition at line 132 of file ReweightableSpectrum.h.

Var ana::ReweightableSpectrum::fRWVar
protected

What goes on the y axis?

Definition at line 129 of file ReweightableSpectrum.h.

std::string ana::ReweightableSpectrum::fTrueLabel
protected

Definition at line 138 of file ReweightableSpectrum.h.


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