All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Member Functions | Protected Types | 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 <SpectrumLoaderBase.h>

Inheritance diagram for ana::SpectrumLoaderBase:
ana::FileReducer ana::NullLoader ana::SpectrumLoader

Classes

class  _VarOrMultiVar
 
struct  IDMap
 Helper class for SpectrumLoaderBase. More...
 
struct  SpectList
 Helper class for SpectrumLoaderBase. More...
 

Public Member Functions

virtual ~SpectrumLoaderBase ()
 
virtual void AddSpectrum (Spectrum &spect, const Var &var, const SpillCut &spillcut, 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 SpillCut &spillcut, const Cut &cut, const SystShifts &shift, const Var &wei=kUnweighted)
 For use by the Spectrum constructor. More...
 
virtual void AddSpectrum (Spectrum &spect, const SpillVar &var, const SpillCut &cut, const SpillVar &wei=kSpillUnweighted)
 For use by the Spectrum constructor. More...
 
virtual void AddSpectrum (Spectrum &spect, const SpillMultiVar &var, const SpillCut &cut, const SpillVar &wei=kSpillUnweighted)
 For use by the Spectrum constructor. More...
 
virtual void AddReweightableSpectrum (ReweightableSpectrum &spect, const Var &var, const Cut &cut, const SystShifts &shift, const Var &wei)
 For use by the constructors of ReweightableSpectrum subclasses. More...
 
virtual void AddReweightableSpectrum (ReweightableSpectrum &spect, const Var &var, const SpillCut &spillcut, const SliceCut &slicecut, const SystShifts &shift, const Var &wei)
 For use by the constructors of ReweightableSpectrum subclasses. More...
 
virtual void Go ()=0
 Load all the registered spectra. More...
 
virtual bool Gone () const
 Indicate whether or not Go has been called. More...
 

Protected Types

typedef _VarOrMultiVar
< caf::SRSliceProxy
VarOrMultiVar
 
typedef _VarOrMultiVar
< caf::SRSpillProxy
SpillVarOrMultiVar
 

Protected Member Functions

 SpectrumLoaderBase (DataSource src=kBeam)
 Component of other constructors. More...
 
 SpectrumLoaderBase (const std::string &wildcard, DataSource src=kBeam)
 Construct from a filename, wildcard, SAM definition, or SAM query. More...
 
 SpectrumLoaderBase (const std::vector< std::string > &fnames, DataSource src=kBeam)
 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 RemoveSpectrum (Spectrum *)
 
virtual void RemoveReweightableSpectrum (ReweightableSpectrum *)
 
int NFiles () const
 Forwards to fFileSource. More...
 
TFile * GetNextFile ()
 

Protected Attributes

std::string fWildcard
 
std::unique_ptr< IFileSourcefFileSource
 
DataSource fSource
 
bool fGone
 Has Go() been called? Can't add more histograms after that. More...
 
double fPOT
 
double fPOTFromHist
 Accumulated by calls to GetNextFile. More...
 
int fNReadouts
 
IDMap< SpillCut, IDMap
< SystShifts, IDMap< Cut,
IDMap< Var, IDMap
< VarOrMultiVar, SpectList > > > > > 
fHistDefs
 All the spectra that need to be filled. More...
 
IDMap< SpillCut, IDMap
< SpillVar, IDMap
< SpillVarOrMultiVar,
SpectList > > > 
fSpillHistDefs
 [spillcut][spillwei][spillvar] More...
 

Friends

class ReweightableSpectrum
 
class NDOscillatableSpectrum
 
class OscillatableSpectrum
 
class Spectrum
 
class SpectrumLoaderMockData
 

Detailed Description

Base class for the various types of spectrum loader.

Definition at line 36 of file SpectrumLoaderBase.h.

Member Typedef Documentation

Definition at line 210 of file SpectrumLoaderBase.h.

Definition at line 209 of file SpectrumLoaderBase.h.

Constructor & Destructor Documentation

ana::SpectrumLoaderBase::~SpectrumLoaderBase ( )
virtual

Definition at line 149 of file SpectrumLoaderBase.cxx.

150  {
151  fHistDefs.RemoveLoader(this);
152  }
IDMap< SpillCut, IDMap< SystShifts, IDMap< Cut, IDMap< Var, IDMap< VarOrMultiVar, SpectList > > > > > fHistDefs
All the spectra that need to be filled.
ana::SpectrumLoaderBase::SpectrumLoaderBase ( DataSource  src = kBeam)
protected

Component of other constructors.

Definition at line 122 of file SpectrumLoaderBase.cxx.

123  : fSource(src), fGone(false), fPOT(0), fPOTFromHist(0), fNReadouts(0)
124  {
125  }
bool fGone
Has Go() been called? Can&#39;t add more histograms after that.
double fPOTFromHist
Accumulated by calls to GetNextFile.
ana::SpectrumLoaderBase::SpectrumLoaderBase ( const std::string &  wildcard,
DataSource  src = kBeam 
)
protected

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

Definition at line 128 of file SpectrumLoaderBase.cxx.

130  : SpectrumLoaderBase(src)
131  {
132  fWildcard = wildcard;
133  fFileSource = std::unique_ptr<IFileSource>(WildcardOrSAMQuery(wildcard));
134  }
SpectrumLoaderBase(DataSource src=kBeam)
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,
DataSource  src = kBeam 
)
protected

Construct from an explicit list of files.

Definition at line 137 of file SpectrumLoaderBase.cxx.

139  : SpectrumLoaderBase(src)
140  {
141  fWildcard = "file list";
142  fFileSource = std::unique_ptr<IFileSource>(new FileListSource(fnames));
143 
144  assert(!fnames.empty());
145  std::cout << "Loading from " << fnames.size() << " files" << std::endl;
146  }
SpectrumLoaderBase(DataSource src=kBeam)
Component of other constructors.
std::unique_ptr< IFileSource > fFileSource
BEGIN_PROLOG could also be cout
ana::SpectrumLoaderBase::SpectrumLoaderBase ( SpectrumLoaderBase &&  )
protecteddefault
ana::SpectrumLoaderBase::SpectrumLoaderBase ( const SpectrumLoaderBase )
protecteddelete

Member Function Documentation

void ana::SpectrumLoaderBase::AddReweightableSpectrum ( ReweightableSpectrum spect,
const Var var,
const Cut cut,
const SystShifts shift,
const Var wei 
)
virtual

For use by the constructors of ReweightableSpectrum subclasses.

Definition at line 274 of file SpectrumLoaderBase.cxx.

279  {
280  if(fGone){
281  std::cerr << "Error: can't add Spectra after the call to Go()" << std::endl;
282  abort();
283  }
284 
285  fHistDefs[kNoSpillCut][shift][cut][wei][var].rwSpects.push_back(&spect);
286 
287  spect.AddLoader(this); // Remember we have a Go() pending
288  }
BEGIN_PROLOG could also be cerr
bool fGone
Has Go() been called? Can&#39;t add more histograms after that.
shift
Definition: fcl_checks.sh:26
IDMap< SpillCut, IDMap< SystShifts, IDMap< Cut, IDMap< Var, IDMap< VarOrMultiVar, SpectList > > > > > fHistDefs
All the spectra that need to be filled.
const SpillCut kNoSpillCut([](const caf::SRSpillProxy *){return true;})
The simplest possible cut: pass everything, used as a default.
void ana::SpectrumLoaderBase::AddReweightableSpectrum ( ReweightableSpectrum spect,
const Var var,
const SpillCut spillcut,
const SliceCut slicecut,
const SystShifts shift,
const Var wei 
)
virtual

For use by the constructors of ReweightableSpectrum subclasses.

Definition at line 291 of file SpectrumLoaderBase.cxx.

297  {
298  if(fGone){
299  std::cerr << "Error: can't add Spectra after the call to Go()" << std::endl;
300  abort();
301  }
302 
303  fHistDefs[spillcut][shift][slicecut][wei][var].rwSpects.push_back(&spect);
304 
305  spect.AddLoader(this); // Remember we have a Go() pending
306  }
BEGIN_PROLOG could also be cerr
bool fGone
Has Go() been called? Can&#39;t add more histograms after that.
shift
Definition: fcl_checks.sh:26
IDMap< SpillCut, IDMap< SystShifts, IDMap< Cut, IDMap< Var, IDMap< VarOrMultiVar, SpectList > > > > > fHistDefs
All the spectra that need to be filled.
void ana::SpectrumLoaderBase::AddSpectrum ( Spectrum spect,
const Var var,
const SpillCut spillcut,
const Cut cut,
const SystShifts shift,
const Var wei = kUnweighted 
)
virtual

For use by the Spectrum constructor.

Definition at line 200 of file SpectrumLoaderBase.cxx.

206  {
207  if(fGone){
208  std::cerr << "Error: can't add Spectra after the call to Go()" << std::endl;
209  abort();
210  }
211 
212  fHistDefs[spillcut][shift][cut][wei][var].spects.push_back(&spect);
213 
214  spect.AddLoader(this); // Remember we have a Go() pending
215  }
BEGIN_PROLOG could also be cerr
bool fGone
Has Go() been called? Can&#39;t add more histograms after that.
shift
Definition: fcl_checks.sh:26
IDMap< SpillCut, IDMap< SystShifts, IDMap< Cut, IDMap< Var, IDMap< VarOrMultiVar, SpectList > > > > > fHistDefs
All the spectra that need to be filled.
void ana::SpectrumLoaderBase::AddSpectrum ( Spectrum spect,
const MultiVar var,
const SpillCut spillcut,
const Cut cut,
const SystShifts shift,
const Var wei = kUnweighted 
)
virtual

For use by the Spectrum constructor.

Definition at line 218 of file SpectrumLoaderBase.cxx.

224  {
225  if(fGone){
226  std::cerr << "Error: can't add Spectra after the call to Go()" << std::endl;
227  abort();
228  }
229 
230  fHistDefs[spillcut][shift][cut][wei][var].spects.push_back(&spect);
231 
232  spect.AddLoader(this); // Remember we have a Go() pending
233  }
BEGIN_PROLOG could also be cerr
bool fGone
Has Go() been called? Can&#39;t add more histograms after that.
shift
Definition: fcl_checks.sh:26
IDMap< SpillCut, IDMap< SystShifts, IDMap< Cut, IDMap< Var, IDMap< VarOrMultiVar, SpectList > > > > > fHistDefs
All the spectra that need to be filled.
void ana::SpectrumLoaderBase::AddSpectrum ( Spectrum spect,
const SpillVar var,
const SpillCut cut,
const SpillVar wei = kSpillUnweighted 
)
virtual

For use by the Spectrum constructor.

Definition at line 236 of file SpectrumLoaderBase.cxx.

240  {
241  if(fGone){
242  std::cerr << "Error: can't add Spectra after the call to Go()" << std::endl;
243  abort();
244  }
245 
246  fSpillHistDefs[cut][wei][var].spects.push_back(&spect);
247 
248  spect.AddLoader(this); // Remember we have a Go() pending
249  }
BEGIN_PROLOG could also be cerr
bool fGone
Has Go() been called? Can&#39;t add more histograms after that.
IDMap< SpillCut, IDMap< SpillVar, IDMap< SpillVarOrMultiVar, SpectList > > > fSpillHistDefs
[spillcut][spillwei][spillvar]
void ana::SpectrumLoaderBase::AddSpectrum ( Spectrum spect,
const SpillMultiVar var,
const SpillCut cut,
const SpillVar wei = kSpillUnweighted 
)
virtual

For use by the Spectrum constructor.

Definition at line 252 of file SpectrumLoaderBase.cxx.

256  {
257  if(fGone){
258  std::cerr << "Error: can't add Spectra after the call to Go()" << std::endl;
259  abort();
260  }
261 
262  fSpillHistDefs[cut][wei][var].spects.push_back(&spect);
263 
264  spect.AddLoader(this); // Remember we have a Go() pending
265  }
BEGIN_PROLOG could also be cerr
bool fGone
Has Go() been called? Can&#39;t add more histograms after that.
IDMap< SpillCut, IDMap< SpillVar, IDMap< SpillVarOrMultiVar, SpectList > > > fSpillHistDefs
[spillcut][spillwei][spillvar]
TFile * ana::SpectrumLoaderBase::GetNextFile ( )
protected

Definition at line 322 of file SpectrumLoaderBase.cxx.

323  {
324  TFile* f = fFileSource->GetNextFile();
325  if(!f) return 0; // out of files
326 
327  TH1* hPOT = (TH1*)f->Get("TotalPOT");
328  assert(hPOT);
329  fPOTFromHist += hPOT->Integral(0, -1);
330 
331  return f;
332  }
double fPOTFromHist
Accumulated by calls to GetNextFile.
std::unique_ptr< IFileSource > fFileSource
virtual void ana::SpectrumLoaderBase::Go ( )
pure virtual

Load all the registered spectra.

Implemented in ana::NullLoader, ana::FileReducer, and ana::SpectrumLoader.

virtual bool ana::SpectrumLoaderBase::Gone ( ) const
inlinevirtual

Indicate whether or not Go has been called.

Definition at line 94 of file SpectrumLoaderBase.h.

94 {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 316 of file SpectrumLoaderBase.cxx.

317  {
318  return fFileSource->NFiles();
319  }
std::unique_ptr< IFileSource > fFileSource
SpectrumLoaderBase& ana::SpectrumLoaderBase::operator= ( SpectrumLoaderBase &&  )
protecteddefault
SpectrumLoaderBase& ana::SpectrumLoaderBase::operator= ( const SpectrumLoaderBase )
protecteddelete
void ana::SpectrumLoaderBase::RemoveReweightableSpectrum ( ReweightableSpectrum spect)
protectedvirtual

Definition at line 310 of file SpectrumLoaderBase.cxx.

311  {
312  fHistDefs.Erase(spect);
313  }
IDMap< SpillCut, IDMap< SystShifts, IDMap< Cut, IDMap< Var, IDMap< VarOrMultiVar, SpectList > > > > > fHistDefs
All the spectra that need to be filled.
void ana::SpectrumLoaderBase::RemoveSpectrum ( Spectrum spect)
protectedvirtual

Definition at line 268 of file SpectrumLoaderBase.cxx.

269  {
270  fHistDefs.Erase(spect);
271  }
IDMap< SpillCut, IDMap< SystShifts, IDMap< Cut, IDMap< Var, IDMap< VarOrMultiVar, SpectList > > > > > fHistDefs
All the spectra that need to be filled.
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 156 of file SpectrumLoaderBase.cxx.

157  {
158  int stride = -1;
159  int offset = -1;
160  if(getenv("CAFANA_STRIDE")){
161  stride = atoi(getenv("CAFANA_STRIDE"));
162  if(stride > 1 && getenv("CAFANA_OFFSET")){
163  offset = atoi(getenv("CAFANA_OFFSET"));
164  }
165  }
166 
167  // stat() blows up on strings with spaces
168  if(str.find(' ') == std::string::npos){
169  WildcardSource* ret = new WildcardSource(str, stride, offset);
170  if(ret->NFiles() > 0) return ret;
171  delete ret;
172  }
173 
174  // Maybe this the name of a SAM project?
175  {
176  IFDHSilent silent; // the usual case is for this to fail
177  ifdh_ns::ifdh i;
178  // findProject always gives back an address just by gluing bits together.
179  // (a tad annoying, because it _does_ go and look for the project, and
180  // even would print its 'didn't-find-this-project' error out to stderr if
181  // not for the IFDHSilent, but without scraping its stderr there's no way
182  // to know whether the project is there or not -- you still get the URL.)
183  // however, the WebAPI call looking for the /status will return a 404 if
184  // the project doesn't exist. (suggested by Robert I. in
185  // INC000000925362)
186  try{
187  ifdh_util_ns::WebAPI webapi(i.findProject(str, SAMExperiment()) + "/status");
188  return new SAMProjectSource(str);
189  }
190  catch(ifdh_util_ns::WebAPIException &e){
191  ;
192  }
193  }
194 
195  // Maybe this is a SAM dataset or query?
196  return new SAMQuerySource(str, stride, offset);
197  }
BEGIN_PROLOG TPC Trig offset(g4 rise time) ProjectToHeight
Definition: CORSIKAGen.fcl:7
std::string SAMExperiment()
$SAM_EXPERIMENT or a nice error message and abort
do i e

Friends And Related Function Documentation

friend class NDOscillatableSpectrum
friend

Definition at line 41 of file SpectrumLoaderBase.h.

friend class OscillatableSpectrum
friend

Definition at line 42 of file SpectrumLoaderBase.h.

friend class ReweightableSpectrum
friend

Definition at line 40 of file SpectrumLoaderBase.h.

friend class Spectrum
friend

Definition at line 43 of file SpectrumLoaderBase.h.

friend class SpectrumLoaderMockData
friend

Definition at line 115 of file SpectrumLoaderBase.h.

Member Data Documentation

std::unique_ptr<IFileSource> ana::SpectrumLoaderBase::fFileSource
protected

Definition at line 125 of file SpectrumLoaderBase.h.

bool ana::SpectrumLoaderBase::fGone
protected

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

Definition at line 129 of file SpectrumLoaderBase.h.

IDMap<SpillCut, IDMap<SystShifts, IDMap<Cut, IDMap<Var, IDMap<VarOrMultiVar, SpectList> > > > > ana::SpectrumLoaderBase::fHistDefs
protected

All the spectra that need to be filled.

[spillcut][shift][cut][wei][var]

Definition at line 215 of file SpectrumLoaderBase.h.

int ana::SpectrumLoaderBase::fNReadouts
protected

Definition at line 133 of file SpectrumLoaderBase.h.

double ana::SpectrumLoaderBase::fPOT
protected

Definition at line 131 of file SpectrumLoaderBase.h.

double ana::SpectrumLoaderBase::fPOTFromHist
protected

Accumulated by calls to GetNextFile.

Definition at line 132 of file SpectrumLoaderBase.h.

DataSource ana::SpectrumLoaderBase::fSource
protected

Definition at line 127 of file SpectrumLoaderBase.h.

IDMap<SpillCut, IDMap<SpillVar, IDMap<SpillVarOrMultiVar, SpectList> > > ana::SpectrumLoaderBase::fSpillHistDefs
protected

[spillcut][spillwei][spillvar]

Definition at line 217 of file SpectrumLoaderBase.h.

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

Definition at line 124 of file SpectrumLoaderBase.h.


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