Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
ana::SpectrumLoaderBase Class Referenceabstract

Base class for the various types of spectrum loader. More...

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-10-23/CAFAna/Core/SpectrumLoaderBase.h"

Inheritance diagram for ana::SpectrumLoaderBase:
ana::FileReducer ana::NullLoader ana::SpectrumLoader ana::ASCIIMaker ana::CSVMaker ana::SpectrumLoaderNuTreeSpillCuts ana::TreeMaker CAFTreeMaker CAFTreeMaker DecTreeLoader

Classes

struct  NuHistDef
 Histograms that are filled from the nuTree. More...
 
struct  SpillHistDef
 Helper for SpectrumLoaderBase. Details of SpillVar plots. More...
 

Public Member Functions

virtual ~SpectrumLoaderBase ()
 
void SetSpillCut (const SpillCut &cut)
 
virtual void AddSpectrum (Spectrum &spect, const Var &var, const Cut &cut, const SystShifts &shift, const Var &wei=kUnweighted)
 For use by the Spectrum constructor. More...
 
virtual void AddSpectrum (Spectrum &spect, const MultiVar &var, const Cut &cut, const SystShifts &shift, const Var &wei=kUnweighted)
 For use by the Spectrum constructor. More...
 
virtual void AddSpectrum (Spectrum &spect, const NuTruthVar &var, const NuTruthCut &cut, const SystShifts &shift, const NuTruthVar &wei=kNuTruthUnweighted)
 For use by the Spectrum constructor. More...
 
virtual void AddReweightableSpectrum (ReweightableSpectrum &spect, const Var &xvar, const Var &yvar, const Cut &cut, const SystShifts &shift, const Var &wei)
 For use by the constructors of ReweightableSpectrum subclasses. More...
 
virtual void AddSpillHistogram (TH1 *h, const SpillVar &var, const SpillCut &cut, const SpillVar &wei=kSpillUnweighted)
 Uses include counting the total POT or spills in a run. More...
 
virtual void Go ()=0
 Load all the registered spectra. More...
 
virtual bool Gone () const
 Indicate whether or not Go has been called. More...
 
double GetWeightedPOT ()
 

Protected Member Functions

 SpectrumLoaderBase ()
 Component of other constructors. More...
 
 SpectrumLoaderBase (const std::string &wildcard)
 Construct from a filename, wildcard, SAM definition, or SAM query. More...
 
 SpectrumLoaderBase (const std::vector< std::string > &fnames)
 Construct from an explicit list of files. More...
 
 SpectrumLoaderBase (SpectrumLoaderBase &&)=default
 
SpectrumLoaderBaseoperator= (SpectrumLoaderBase &&)=default
 
 SpectrumLoaderBase (const SpectrumLoaderBase &)=delete
 
SpectrumLoaderBaseoperator= (const SpectrumLoaderBase &)=delete
 
IFileSourceWildcardOrSAMQuery (const std::string &str) const
 Figure out if str is a wildcard or SAM query and return a source. More...
 
virtual void AccumulateExposures (const caf::SRSpillProxy *spill)=0
 
int NFiles () const
 Forwards to fFileSource. More...
 
TFile * GetNextFile ()
 Forwards to fFileSource but also accumulates POT and livetime. More...
 
WeightApplierGetSinkSCW (const SystShifts &shift, const Cut &cut, const Var &wei)
 

Protected Attributes

std::string fWildcard
 
std::unique_ptr< IFileSourcefFileSource
 
bool fGone
 Has Go() been called? Can't add more histograms after that. More...
 
double fPOT
 Accumulated by calls to GetNextFile. More...
 
double fRunPOT
 Crude measure, not including spill cuts. More...
 
double fSinglePOT
 
double fBeamNue
 
double fSingleNue
 
double fWeightedPOT
 
std::set< IRecordSink * > fSpectrumSinks
 
std::unordered_map< std::tuple< int, int, int >, WeightApplier * > fSinksSCW
 
std::unordered_map< std::pair< int, int >, CutApplier * > fSinksSC
 
std::unordered_map< int, SystApplier * > fSinksS
 
RecordMultiSink fSink
 
ExposureSource fExposureSource
 
std::list< SpillHistDeffSpillHistDefs
 
std::list< NuHistDeffNuHistDefs
 
std::unique_ptr< SpillCutfSpillCut
 Cut applied to the spill branch for every event. More...
 

Friends

class ReweightableSpectrum
 
class NDOscillatableSpectrum
 
class OscillatableSpectrum
 
class Spectrum
 

Detailed Description

Base class for the various types of spectrum loader.

Definition at line 63 of file SpectrumLoaderBase.h.

Constructor & Destructor Documentation

ana::SpectrumLoaderBase::~SpectrumLoaderBase ( )
virtual

Definition at line 59 of file SpectrumLoaderBase.cxx.

60  {
61  }
ana::SpectrumLoaderBase::SpectrumLoaderBase ( )
protected

Component of other constructors.

Definition at line 33 of file SpectrumLoaderBase.cxx.

34  : fGone(false),
35  fPOT(0), fRunPOT(0), fSinglePOT(0), fBeamNue(0), fSingleNue(0), fWeightedPOT(0)
36  {
37  }
bool fGone
Has Go() been called? Can&#39;t add more histograms after that.
double fRunPOT
Crude measure, not including spill cuts.
double fPOT
Accumulated by calls to GetNextFile.
ana::SpectrumLoaderBase::SpectrumLoaderBase ( const std::string &  wildcard)
protected

Construct from a filename, wildcard, SAM definition, or SAM query.

Definition at line 40 of file SpectrumLoaderBase.cxx.

References fFileSource, fWildcard, wildcard(), and WildcardOrSAMQuery().

42  {
44  fFileSource = std::unique_ptr<IFileSource>(WildcardOrSAMQuery(wildcard));
45  }
std::vector< std::string > wildcard(const std::string &wildcardString)
Definition: convert.C:9
SpectrumLoaderBase()
Component of other constructors.
std::unique_ptr< IFileSource > fFileSource
IFileSource * WildcardOrSAMQuery(const std::string &str) const
Figure out if str is a wildcard or SAM query and return a source.
ana::SpectrumLoaderBase::SpectrumLoaderBase ( const std::vector< std::string > &  fnames)
protected

Construct from an explicit list of files.

Definition at line 48 of file SpectrumLoaderBase.cxx.

References ana::assert(), om::cout, allTimeWatchdog::endl, fFileSource, and fWildcard.

50  {
51  fWildcard = "file list";
52  fFileSource = std::unique_ptr<IFileSource>(new FileListSource(fnames));
53 
54  assert(!fnames.empty());
55  std::cout << "Loading from " << fnames.size() << " files" << std::endl;
56  }
OStream cout
Definition: OStream.cxx:6
SpectrumLoaderBase()
Component of other constructors.
std::unique_ptr< IFileSource > fFileSource
assert(nhit_max >=nhit_nbins)
ana::SpectrumLoaderBase::SpectrumLoaderBase ( SpectrumLoaderBase &&  )
protecteddefault
ana::SpectrumLoaderBase::SpectrumLoaderBase ( const SpectrumLoaderBase )
protecteddelete

Member Function Documentation

virtual void ana::SpectrumLoaderBase::AccumulateExposures ( const caf::SRSpillProxy spill)
protectedpure virtual
void ana::SpectrumLoaderBase::AddReweightableSpectrum ( ReweightableSpectrum spect,
const Var xvar,
const Var yvar,
const Cut cut,
const SystShifts shift,
const Var wei 
)
virtual

For use by the constructors of ReweightableSpectrum subclasses.

Reimplemented in ana::NullLoader.

Definition at line 201 of file SpectrumLoaderBase.cxx.

References ana::RecordMultiSink::AddSink(), ana::ExposureSource::AddSink(), om::cerr, allTimeWatchdog::endl, fExposureSource, fGone, fSink, fSpectrumSinks, and GetSinkSCW().

Referenced by ana::FluxReweight::FluxReweight(), ana::NoReweight::NoReweight(), and ana::RecoReweight::RecoReweight().

207  {
208  if(fGone){
209  std::cerr << "Error: can't add Spectra after the call to Go()" << std::endl;
210  abort();
211  }
212 
213  ReweightableSpectrumSink* sink = new ReweightableSpectrumSink(xvar, yvar, &spect);
214  fSpectrumSinks.insert(sink);
215  GetSinkSCW(shift, cut, wei)->AddSink(sink);
216  fExposureSource.AddSink(cut, sink);
217  fSink.AddSink(sink);
218  }
bool fGone
Has Go() been called? Can&#39;t add more histograms after that.
OStream cerr
Definition: OStream.cxx:7
void AddSink(const Cut &cut, IExposureSink *s)
std::set< IRecordSink * > fSpectrumSinks
void AddSink(IRecordSink *s)
WeightApplier * GetSinkSCW(const SystShifts &shift, const Cut &cut, const Var &wei)
const Cut cut
Definition: exporter_fd.C:30
void ana::SpectrumLoaderBase::AddSpectrum ( Spectrum spect,
const Var var,
const Cut cut,
const SystShifts shift,
const Var wei = kUnweighted 
)
virtual

For use by the Spectrum constructor.

Reimplemented in ana::NullLoader, and ana::SpectrumLoaderNuTreeSpillCuts.

Definition at line 154 of file SpectrumLoaderBase.cxx.

References ana::RecordMultiSink::AddSink(), ana::ExposureSource::AddSink(), om::cerr, allTimeWatchdog::endl, fExposureSource, fGone, fSpectrumSinks, and GetSinkSCW().

Referenced by ana::SpectrumLoaderNuTreeSpillCuts::AddSpectrum(), and ana::TrivialExtrap::TrivialExtrap().

159  {
160  if(fGone){
161  std::cerr << "Error: can't add Spectra after the call to Go()" << std::endl;
162  abort();
163  }
164 
165  SpectrumSink* sink = new SpectrumSink(var, &spect);
166  fSpectrumSinks.insert(sink);
167  GetSinkSCW(shift, cut, wei)->AddSink(sink);
168  fExposureSource.AddSink(cut, sink);
169  }
bool fGone
Has Go() been called? Can&#39;t add more histograms after that.
OStream cerr
Definition: OStream.cxx:7
void AddSink(const Cut &cut, IExposureSink *s)
std::set< IRecordSink * > fSpectrumSinks
void AddSink(IRecordSink *s)
WeightApplier * GetSinkSCW(const SystShifts &shift, const Cut &cut, const Var &wei)
const Cut cut
Definition: exporter_fd.C:30
void ana::SpectrumLoaderBase::AddSpectrum ( Spectrum spect,
const MultiVar var,
const Cut cut,
const SystShifts shift,
const Var wei = kUnweighted 
)
virtual

For use by the Spectrum constructor.

Reimplemented in ana::NullLoader, and ana::SpectrumLoaderNuTreeSpillCuts.

Definition at line 172 of file SpectrumLoaderBase.cxx.

References ana::RecordMultiSink::AddSink(), ana::ExposureSource::AddSink(), om::cerr, allTimeWatchdog::endl, fExposureSource, fGone, fSpectrumSinks, and GetSinkSCW().

177  {
178  if(fGone){
179  std::cerr << "Error: can't add Spectra after the call to Go()" << std::endl;
180  abort();
181  }
182 
183  MultiVarSpectrumSink* sink = new MultiVarSpectrumSink(var, &spect);
184  fSpectrumSinks.insert(sink);
185  GetSinkSCW(shift, cut, wei)->AddSink(sink);
186  fExposureSource.AddSink(cut, sink);
187  }
bool fGone
Has Go() been called? Can&#39;t add more histograms after that.
OStream cerr
Definition: OStream.cxx:7
void AddSink(const Cut &cut, IExposureSink *s)
std::set< IRecordSink * > fSpectrumSinks
void AddSink(IRecordSink *s)
WeightApplier * GetSinkSCW(const SystShifts &shift, const Cut &cut, const Var &wei)
const Cut cut
Definition: exporter_fd.C:30
void ana::SpectrumLoaderBase::AddSpectrum ( Spectrum spect,
const NuTruthVar var,
const NuTruthCut cut,
const SystShifts shift,
const NuTruthVar wei = kNuTruthUnweighted 
)
virtual

For use by the Spectrum constructor.

Reimplemented in ana::NullLoader, and ana::SpectrumLoaderNuTreeSpillCuts.

Definition at line 190 of file SpectrumLoaderBase.cxx.

References fNuHistDefs.

195  {
196  // TODO - implement with the same source/sink deal as regular spectra
197  fNuHistDefs.emplace_back(spect, var, cut, shift, wei);
198  }
const Cut cut
Definition: exporter_fd.C:30
std::list< NuHistDef > fNuHistDefs
void ana::SpectrumLoaderBase::AddSpillHistogram ( TH1 *  h,
const SpillVar var,
const SpillCut cut,
const SpillVar wei = kSpillUnweighted 
)
virtual
TFile * ana::SpectrumLoaderBase::GetNextFile ( )
protected

Forwards to fFileSource but also accumulates POT and livetime.

Definition at line 237 of file SpectrumLoaderBase.cxx.

References AccumulateExposures(), ana::assert(), caf::SRProxySystController::BeginTransaction(), om::cout, fillBadChanDBTables::det, allTimeWatchdog::endl, MakeMiniprodValidationCuts::f, fBeamNue, fFileSource, fNuHistDefs, genie::utils::style::Format(), fPOT, fRunPOT, fSingleNue, fSinglePOT, fSpillCut, fSpillHistDefs, fWildcard, hd, isFHC, make_mec_shifts_plots::isRHC, findDuplicateFiles::key, caf::kUNKNOWN, getGoodRuns4SAM::n, cacheDefinitionData::prog, caf::SRProxySystController::Rollback(), ana::Progress::SetProgress(), caf_analysis::spill, and febshutoff_auto::val.

Referenced by ana::SpectrumLoader::Go(), and ana::FileReducer::Go().

238  {
239  TFile* f = fFileSource->GetNextFile();
240  if(!f) return 0; // out of files
241 
242  if(f->IsZombie()){
243  std::cout << "Bad file (zombie): " << f->GetName() << std::endl;
244  abort();
245  }
246 
247  // Crude way to count POT, at a file level without referring to spill cuts
248  TH1* hPOT = (TH1*)f->Get("TotalPOT");
249 
250  if(!hPOT){
251  std::cout << "Bad file (no POT tree): " << f->GetName() << std::endl;
252  abort();
253  }
254 
255  fRunPOT += hPOT->Integral();
256 
257  TKey *key = f->FindKey("TotalSinglePOT");
258 
259  // Initialise and only fill these histos if they exist
260  // We know they exist for nue overlay files
261  TH1* hSinglePOT = 0;
262  TH1* hTotalTrueSingleNue = 0;
263  TH1* hTotalTrueNonswapNue = 0;
264  if(key != 0){
265  hSinglePOT = (TH1*)f->Get("TotalSinglePOT");
266  assert(hSinglePOT);
267  fSinglePOT = hSinglePOT->Integral();
268 
269  hTotalTrueNonswapNue = (TH1*)f->Get("TotalTrueNonswapNue");
270  assert(hTotalTrueNonswapNue);
271  fBeamNue = hTotalTrueNonswapNue->Integral();
272 
273  hTotalTrueSingleNue = (TH1*)f->Get("TotalTrueSingleNue");
274  assert(hTotalTrueSingleNue);
275  fSingleNue = hTotalTrueSingleNue->Integral();
276  }
277  else{
278  delete hSinglePOT;
279  delete hTotalTrueSingleNue;
280  delete hTotalTrueNonswapNue;
281  }
282 
283  // Test for flat (trees are inside a directory) or nested (tree is at top
284  // level) cases.
285  TDirectory* spillDir = 0;
286  TTree* spillTree = 0;
287 
288  TObject* obj = f->Get("spillTree");
289  assert(obj); // Must exist in one form or the other
290 
291  // It might seem like you could use GetObject() to do the type-checking
292  // directly, but that method seems to have a memory leak in the case that
293  // the types don't match.
294  if(obj->ClassName() == std::string("TTree")){
295  // nested case
296  spillTree = (TTree*)obj;
297  }
298  else{
299  // FlatCAF case
300  spillDir = (TDirectory*)obj;
301  spillTree = (TTree*)spillDir->Get("spill");
302  assert(spillTree);
303  }
304 
305  // These aren't set in SRNeutrino, but we need them for flux systs, so
306  // learn them from SRSpill and copy them over.
307  //
308  // TODO TODO - remove this hack (and the equivalent in SpectrumLoader.cxx
309  // once they're available in the CAFs
310  bool isFHC = false, is0HC = false, isRHC = false;
312 
313  long n = 0;
314  caf::SRSpillProxy spill(spillDir, spillTree, "spill", n, 0);
315 
316  // FloatingExceptionOnNaN fpnan;
317 
318  // With multiple files exposure counting alternates with histogram filling,
319  // but with one file they deserve to be reported as two separate steps.
320  Progress* prog = 0;
321  if(fFileSource->NFiles() == 1)
322  prog = new Progress(TString::Format("Counting exposure from 1 file matching '%s'", fWildcard.c_str()).Data());
323 
324  const int Nentries = spillTree->GetEntries();
325 
326  double totFilePOT = 0;
327 
328  for(n = 0; n < Nentries; ++n){
329  if(!spillDir) spillTree->LoadTree(n); // nested mode
330 
331  if(!fSpillCut || (*fSpillCut)(&spill)){
333 
334  totFilePOT += spill.spillpot;
335 
336  // Only learn from good spills (bad spill could have bad beam?), and
337  // only once (efficiency)
338  if(!isFHC && !is0HC && !isRHC){
339  isFHC = spill.isFHC;
340  is0HC = spill.is0HC;
341  isRHC = spill.isRHC;
342  }
343  if (det == caf::kUNKNOWN)
344  det = spill.det;
345 
346  for(const SpillHistDef& hd: fSpillHistDefs){
347  // No cut, or cut passes
348  if(hd.cut(&spill)){
349  const double wei = hd.wei(&spill);
350  if(wei){
351  const double val = hd.var(&spill);
352  hd.h->Fill(val, wei);
353  }
354  } // end if(cut passes)
355  } // end for hd
356  }
357 
358  if(prog && n%100 == 0) prog->SetProgress(double(n)/Nentries);
359  } // end for n
360 
361  // The POT we want to use is either the singles POT in case of overlay files
362  // i.e the singlepot histo exists, or the standard after spill cuts
363  // Note: must be sure to run spill cuts for the overlays otherwise this gets
364  // reset to the fRunPOT
365  if(key != 0) fPOT += fSinglePOT;
366  else fPOT += totFilePOT;
367 
368  delete prog;
369  prog = 0;
370 
371  if(!fNuHistDefs.empty()){
372  // Test for flat (trees are inside a directory) or nested (tree is at top
373  // level) cases.
374 
375  TDirectory* nuDir = 0;
376  TTree* nuTree = 0;
377 
378  TObject* obj = f->Get("nuTree");
379  assert(obj); // Must exist in one form or the other
380 
381  // It might seem like you could use GetObject() to do the type-checking
382  // directly, but that method seems to have a memory leak in the case that
383  // the types don't match.
384  if(obj->ClassName() == std::string("TTree")){
385  // nested case
386  nuTree = (TTree*)obj;
387  }
388  else{
389  // FlatCAF case
390  nuDir = (TDirectory*)obj;
391  nuTree = (TTree*)spillDir->Get("nu");
392  assert(nuTree);
393  }
394 
395  const int NNuEntries = nuTree->GetEntries();
396 
397  long n = 0;
398  caf::SRNeutrinoProxy nu(nuDir, nuTree, nuDir ? "nu" : "mc.nu", n, 0);
399 
400  if(fFileSource->NFiles() == 1)
401  prog = new Progress(TString::Format("Filling from nuTree from 1 file matching '%s'", fWildcard.c_str()).Data());
402 
403 
404  for(n = 0; n < NNuEntries; ++n){
405  if(!nuDir) nuTree->LoadTree(n); // nested mode
406 
407  nu.isFHC = isFHC;
408  nu.is0HC = is0HC;
409  nu.isRHC = isRHC;
410  nu.det = det;
411 
412  for(const NuHistDef& hd: fNuHistDefs){
414 
415  double systWeight = 1;
416  // Can special-case nominal to not pay cost of Shift()
417  if(!hd.shift.IsNominal()){
418  hd.shift.Shift(&nu, systWeight);
419  }
420 
421  if(hd.cut(&nu)){
422  const double wei = hd.wei(&nu)*systWeight;
423  if(wei){
424  const double val = hd.var(&nu);
425  hd.spect.Fill(val, wei);
426  }
427  }
428 
429  // Return SRNeutrino to its unshifted form ready for the next
430  // histogram.
432  } // end for hd
433 
434  if(prog && n%10000 == 0) prog->SetProgress(double(n)/NNuEntries);
435  } // end for n
436 
437  for(const NuHistDef& hd: fNuHistDefs) hd.spect.fPOT += totFilePOT;
438 
439  delete prog;
440  } // end if NuHistDefs
441 
442  return f;
443  }
Unknown detector.
Definition: SREnums.h:9
Det_t
Which NOvA detector?
Definition: SREnums.h:7
double fRunPOT
Crude measure, not including spill cuts.
std::unique_ptr< SpillCut > fSpillCut
Cut applied to the spill branch for every event.
virtual void AccumulateExposures(const caf::SRSpillProxy *spill)=0
std::list< SpillHistDef > fSpillHistDefs
static bool isFHC
OStream cout
Definition: OStream.cxx:6
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
std::unique_ptr< IFileSource > fFileSource
assert(nhit_max >=nhit_nbins)
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
double fPOT
Accumulated by calls to GetNextFile.
std::list< NuHistDef > fNuHistDefs
TH1F * hd
Definition: Xdiff_gwt.C:57
WeightApplier * ana::SpectrumLoaderBase::GetSinkSCW ( const SystShifts shift,
const Cut cut,
const Var wei 
)
protected

Definition at line 123 of file SpectrumLoaderBase.cxx.

References ana::RecordMultiSink::AddSink(), PandAna.Demos.tute_pid_validation::cid, fSink, fSinksS, fSinksSC, fSinksSCW, ana::SystShifts::ID(), ana::_Var< T >::ID(), and ana::_Cut< T >::ID().

Referenced by AddReweightableSpectrum(), and AddSpectrum().

126  {
127  const int sid = shift.ID();
128  const int cid = cut.ID();
129  const int wid = wei.ID();
130 
131  const std::pair<int, int> sc(sid, cid);
132  const std::tuple<int, int, int> scw(sid, cid, wid);
133 
134  if(fSinksS.find(sid) == fSinksS.end()){
135  SystApplier* sa = new SystApplier(shift);
136  fSinksS[sid] = sa;
137  fSink.AddSink(sa);
138  }
139  if(fSinksSC.find(sc) == fSinksSC.end()){
140  CutApplier* ca = new CutApplier(cut);
141  fSinksS[sid]->AddSink(ca);
142  fSinksSC[sc] = ca;
143  }
144  if(fSinksSCW.find(scw) == fSinksSCW.end()){
145  WeightApplier* wa = new WeightApplier(wei);
146  fSinksSC[sc]->AddSink(wa);
147  fSinksSCW[scw] = wa;
148  }
149 
150  return fSinksSCW[scw];
151  }
void AddSink(IRecordSink *s)
std::unordered_map< int, SystApplier * > fSinksS
std::unordered_map< std::pair< int, int >, CutApplier * > fSinksSC
const Cut cut
Definition: exporter_fd.C:30
std::unordered_map< std::tuple< int, int, int >, WeightApplier * > fSinksSCW
double ana::SpectrumLoaderBase::GetWeightedPOT ( )

Definition at line 446 of file SpectrumLoaderBase.cxx.

References om::cout, allTimeWatchdog::endl, fBeamNue, fPOT, fSingleNue, fSinglePOT, and fWeightedPOT.

Referenced by ana::NDExtrap::GetWeightedPOT().

447  {
449  std::cout << " beam nue: " << fBeamNue << " single nue: " << fSingleNue << " fPOT: " << fPOT << " fSinglePOT: " << fSinglePOT << std::endl;
450  return fWeightedPOT;
451  }
OStream cout
Definition: OStream.cxx:6
double fPOT
Accumulated by calls to GetNextFile.
virtual void ana::SpectrumLoaderBase::Go ( )
pure virtual
virtual bool ana::SpectrumLoaderBase::Gone ( ) const
inlinevirtual

Indicate whether or not Go has been called.

Definition at line 115 of file SpectrumLoaderBase.h.

References caf_analysis::spill, submit_syst::str, and wildcard().

Referenced by ana::TwoSampleDecomp::Decomp(), ana::CSVMaker::Go(), and ana::SpectrumHandler::Go().

115 {return fGone;}
bool fGone
Has Go() been called? Can&#39;t add more histograms after that.
int ana::SpectrumLoaderBase::NFiles ( ) const
protected

Forwards to fFileSource.

Definition at line 231 of file SpectrumLoaderBase.cxx.

References fFileSource.

Referenced by ana::SpectrumLoader::Go(), and ana::FileReducer::Go().

232  {
233  return fFileSource->NFiles();
234  }
std::unique_ptr< IFileSource > fFileSource
SpectrumLoaderBase& ana::SpectrumLoaderBase::operator= ( SpectrumLoaderBase &&  )
protecteddefault
SpectrumLoaderBase& ana::SpectrumLoaderBase::operator= ( const SpectrumLoaderBase )
protecteddelete
void ana::SpectrumLoaderBase::SetSpillCut ( const SpillCut cut)

Definition at line 64 of file SpectrumLoaderBase.cxx.

References ana::assert(), cut, fGone, fSpillCut, and WildcardOrSAMQuery().

Referenced by Ana2017_box_opening_macro(), Ana2017_sb_opening_macro(), Ana2018_box_opening_macro(), AnaResultsLoad(), BlessedPlotsLoad(), caf_nue_data_mc(), caf_numu_fd_validation_data(), caf_numu_fd_validation_MC(), caf_numu_fd_validation_MC_no_tau(), caf_numu_nd_cutflow(), caf_numu_nuenergy_vs_xy(), caf_numu_reco_minus_true(), caf_numu_sensitivity(), caf_numu_sensitivity_no_tau(), caf_numu_validation(), caf_numu_vars(), CalcCutVals(), compare_cos_numi(), Compare_Spectra(), ComparisonPlots_Data(), CosmicPred(), CreateAndFillSpectra(), CutFlow_Cosmic(), CutFlow_Data(), CutFlow_NearDet(), CutTableLoad(), datamc_ND_numu_kinematics(), datamc_ND_numu_kinematics_FHC(), datamc_ND_numu_kinematics_FHC_pTBins(), datamc_ND_numu_kinematics_FHC_REW(), datamc_ND_numu_kinematics_FHC_REW_pTBins(), datamc_ND_numu_kinematics_REW(), datamc_ND_numu_kinematics_RHC(), datamc_ND_numu_kinematics_RHC_pTBins(), datamc_ND_numu_kinematics_RHC_REW(), datamc_ND_numu_kinematics_RHC_REW_pTBins(), dataprocess_numuccinc(), DataVtxDistributionLoad(), demo_trivial_xsec_analysis(), drawIntensityEffect_2019(), drawLongTerm(), drawLongTerm_2019(), drawShortTerm_2019(), drawTimePlots(), drawVsPOT(), EnergyCont_macro(), energyResolution(), estimate_energy(), Evaluate_BDTMLP_Algs_Spectra(), ExampleCode(), exporter_fd(), exporter_nd(), ExtendedAxesLoad(), FD_Data_PosComp(), FDDataMC(), FDDataMCSystBandLoad(), FillSpectra(), FitSystEffectsLoad(), genie_syst_make(), get_cosmic_sample(), get_cosmic_spectra(), get_data_and_cosmic(), get_data_histogram(), get_fd_dataspectrum(), get_numi_data_histogram(), get_numu_data_histogram(), get_spectra_2dplots(), getCrossSectionAnalysis_Spectra(), getCrossSectionAnalysis_Spectra_systematics(), getCrossSectionAnalysisSpectra(), getData(), getFitTemplates(), GetHistsFD(), GetHistsND(), getSpectra_ForFitting(), getStabilitySpectra(), hadEFrac_nd_data_mc_systs(), hyperon_nom_macro(), make_DataMCComp_numu(), make_decomp(), make_michel(), make_nue_ana2018_pot(), make_nue_ana2019_epoch7d_pot(), make_nue_ana2019_epoch8b_pot(), make_nue_ana2019_fhc_ub_pot(), make_nue_ana2019_rhc_ub_pot(), make_nue_thirdana_pot(), make_numu_thirdana_pot(), make_nus17_pot(), make_pi0_xcheck(), make_pid(), make_quantiles_histogram_2020(), make_RHC_WrongSign_Nue(), make_RHC_WrongSign_Numu_MC(), make_RHC_WrongSign_Numu_Pd4_6Data(), make_RHC_WrongSign_Numu_Pd7dData(), make_RHC_WrongSign_Numu_Pd8Data(), make_RHC_WrongSign_NumuQ1(), make_RHC_WrongSign_NumuQ2(), make_RHC_WrongSign_NumuQ3(), make_RHC_WrongSign_NumuQ4(), make_rhcpred_2017(), make_rockpred_2017(), make_xsec_tuning_hists_mp5(), make_xsec_wgts_2018_hists(), MakeCosmics(), MakeNus17CosBkgd(), MakeNus17Prediction(), MakeNus18CosBkgd(), MakeNus18ExtrapPred(), MakeNus18SidebandPred(), MakeNusPrediction(), ana::MakeQuantileHistogram(), ana::MakeTextListFileHelper(), MakeUnoscPlots(), mrbrem_get_initial_spectra(), mrbrem_get_reweighted_spectra(), MRDiFStudy_FHC_Step1(), MRDiFStudy_FHC_Step2(), MRDiFStudy_RHC_Step1(), MRDiFStudy_RHC_Step2(), mre_blessed(), mre_comp_split(), ND_DataMC(), ND_DataMC_Comp_Systs(), NDDataMC(), NDDataMCSystBandLoad(), neutKEsyst(), neutronE_macro(), nue_data_mc_validation(), nue_decomp_scales(), nue_fd_mc_validation(), nue_michelDataMC(), NuMu2019_BasicPIDPlots_ND(), NuMu2019_BasicPIDPlots_Spectrum(), NuMu2020_BasicPIDPlots_FD(), NuMu2020_BasicPIDPlots_ND(), NuMu2020_BasicPIDPlots_Spectrum(), NuMu2020_TrimCAFs(), numu_cut_flow(), numu_data_mc_validation(), numu_validation_numuvars(), NumuCosmic(), nus17_box_opening(), nus17_fd_cut_tables(), nus17_fd_cut_tables2D(), nus17_fiducial_accounting(), nus18_box_opening(), nus_ana01_box_opening(), nus_ana01_sideband_box_opening(), pi0_xcheck(), PositionComparison(), ppfx_make_systs(), ppfx_smooth_weights_save(), preselection_cutflow(), resolutionscript(), resolutionspectrums(), rock(), saveSpectraForUnf(), sidebandfittest(), SideBandLoad(), signal_count(), specprod_numuccinc(), specprod_systematics(), Syst(), SystematicComp(), SystsBirksLoad(), SystsCalibAbsLoad(), SystsCalibAbsLoad17(), SystsCalibAbsMethod17(), SystsCalibRelLoad(), SystsCalibRelLoad17(), SystsNoiseLoad(), SystsPPFXLoad17(), test_genieweights(), test_predictionscalecomp(), test_xsecanalysis(), TrimCAFs(), uncertainty1png(), uncertainty2png(), and validation_numu_nd().

65  {
66  assert(!fGone);
67  fSpillCut = std::make_unique<SpillCut>(cut);
68  }
bool fGone
Has Go() been called? Can&#39;t add more histograms after that.
std::unique_ptr< SpillCut > fSpillCut
Cut applied to the spill branch for every event.
const Cut cut
Definition: exporter_fd.C:30
assert(nhit_max >=nhit_nbins)
IFileSource * ana::SpectrumLoaderBase::WildcardOrSAMQuery ( const std::string &  str) const
protected

Figure out if str is a wildcard or SAM query and return a source.

Definition at line 72 of file SpectrumLoaderBase.cxx.

References e, cet::getenv(), MECModelEnuComparisons::i, ProjMan::ifdh, PandAna.Demos.demo_prong::limit, ana::FileListSource::NFiles(), PandAna.reco_validation.add_data::offset, runNovaSAM::ret, and update_sam_good_runs_metadata::stride.

Referenced by ProducingSA(), SetSpillCut(), SpectrumLoaderBase(), and useBDTG().

73  {
74  int stride = -1;
75  int offset = -1;
76  int limit = -1;
77  if(getenv("CAFANA_STRIDE")){
78  stride = atoi(getenv("CAFANA_STRIDE"));
79  if(stride > 1 && getenv("CAFANA_OFFSET")){
80  offset = atoi(getenv("CAFANA_OFFSET"));
81  }
82  }
83  if(getenv("CAFANA_LIMIT")){
84  limit = atoi(getenv("CAFANA_LIMIT"));
85  }
86 
87  // stat() blows up on strings with spaces
88  if(str.find(' ') == std::string::npos){
89  WildcardSource* ret = new WildcardSource(str, stride, offset, limit);
90  if(ret->NFiles() > 0) return ret;
91  delete ret;
92  }
93 
94  // Maybe this the name of a SAM project?
95  {
96  IFDHSilent silent; // the usual case is for this to fail
98 
99  // findProject always gives back an address just by gluing bits together.
100  // (a tad annoying, because it _does_ go and look for the project,
101  // and even would print its 'didn't-find-this-project' error out to stderr
102  // if not for the IFDHSilent, but without scraping its stderr
103  // there's no way to know whether the project is there or not--
104  // you still get the URL.)
105  // however, the WebAPI call looking for the /status will return a 404 if
106  // the project doesn't exist. (suggested by Robert I. in INC000000925362.)
107  try
108  {
109  ifdh_util_ns::WebAPI webapi(i.findProject(str, getenv("SAM_STATION")) + "/status");
110  return new SAMProjectSource(str);
111  }
112  catch (ifdh_util_ns::WebAPIException &e)
113  {
114  ;
115  }
116  }
117 
118  // Maybe this is a SAM dataset or query?
119  return new SAMQuerySource(str, stride, offset, limit);
120  }
std::string getenv(std::string const &name)
ifdh
Definition: ProjMan.py:8
Float_t e
Definition: plot.C:35

Friends And Related Function Documentation

friend class NDOscillatableSpectrum
friend

Definition at line 68 of file SpectrumLoaderBase.h.

friend class OscillatableSpectrum
friend

Definition at line 69 of file SpectrumLoaderBase.h.

friend class ReweightableSpectrum
friend

Definition at line 67 of file SpectrumLoaderBase.h.

friend class Spectrum
friend

Definition at line 70 of file SpectrumLoaderBase.h.

Member Data Documentation

double ana::SpectrumLoaderBase::fBeamNue
protected

Definition at line 155 of file SpectrumLoaderBase.h.

Referenced by GetNextFile(), and GetWeightedPOT().

ExposureSource ana::SpectrumLoaderBase::fExposureSource
protected
std::unique_ptr<IFileSource> ana::SpectrumLoaderBase::fFileSource
protected
bool ana::SpectrumLoaderBase::fGone
protected

Has Go() been called? Can't add more histograms after that.

Definition at line 149 of file SpectrumLoaderBase.h.

Referenced by AddReweightableSpectrum(), AddSpectrum(), ana::SpectrumLoader::Go(), ana::FileReducer::Go(), and SetSpillCut().

std::list<NuHistDef> ana::SpectrumLoaderBase::fNuHistDefs
protected

Definition at line 210 of file SpectrumLoaderBase.h.

Referenced by AddSpectrum(), GetNextFile(), and ana::SpectrumLoader::Go().

double ana::SpectrumLoaderBase::fPOT
protected

Accumulated by calls to GetNextFile.

Definition at line 151 of file SpectrumLoaderBase.h.

Referenced by GetNextFile(), and GetWeightedPOT().

double ana::SpectrumLoaderBase::fRunPOT
protected

Crude measure, not including spill cuts.

Definition at line 152 of file SpectrumLoaderBase.h.

Referenced by GetNextFile(), ana::SpectrumLoader::Go(), and DecTreeLoader::HandlePOT().

double ana::SpectrumLoaderBase::fSingleNue
protected

Definition at line 156 of file SpectrumLoaderBase.h.

Referenced by GetNextFile(), and GetWeightedPOT().

double ana::SpectrumLoaderBase::fSinglePOT
protected

Definition at line 154 of file SpectrumLoaderBase.h.

Referenced by GetNextFile(), and GetWeightedPOT().

RecordMultiSink ana::SpectrumLoaderBase::fSink
protected
std::unordered_map<int, SystApplier*> ana::SpectrumLoaderBase::fSinksS
protected

Definition at line 167 of file SpectrumLoaderBase.h.

Referenced by GetSinkSCW(), and ana::SpectrumLoader::Go().

std::unordered_map<std::pair<int, int>, CutApplier*> ana::SpectrumLoaderBase::fSinksSC
protected

Definition at line 166 of file SpectrumLoaderBase.h.

Referenced by GetSinkSCW(), and ana::SpectrumLoader::Go().

std::unordered_map<std::tuple<int, int, int>, WeightApplier*> ana::SpectrumLoaderBase::fSinksSCW
protected

Definition at line 165 of file SpectrumLoaderBase.h.

Referenced by GetSinkSCW(), and ana::SpectrumLoader::Go().

std::set<IRecordSink*> ana::SpectrumLoaderBase::fSpectrumSinks
protected
std::unique_ptr<SpillCut> ana::SpectrumLoaderBase::fSpillCut
protected
std::list<SpillHistDef> ana::SpectrumLoaderBase::fSpillHistDefs
protected

Definition at line 209 of file SpectrumLoaderBase.h.

Referenced by AddSpillHistogram(), GetNextFile(), and ana::SpectrumLoader::Go().

double ana::SpectrumLoaderBase::fWeightedPOT
protected

Definition at line 157 of file SpectrumLoaderBase.h.

Referenced by GetWeightedPOT().

std::string ana::SpectrumLoaderBase::fWildcard
protected

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