11 #include "sbnanaobj/StandardRecord/Proxy/SRProxy.h"
22 #include "boost/algorithm/string.hpp"
36 auto it = std::find(rwSpects.begin(), rwSpects.end(), rs);
37 if(it != rwSpects.end()) rwSpects.erase(it);
50 return spects.size() + rwSpects.size();
56 ss.insert(ss.end(), spects.begin(), spects.end());
63 ss.insert(ss.end(), rwSpects.begin(), rwSpects.end());
70 for(
auto& it: fElems){
71 if(it.first.ID() == key.ID())
return it.second;
73 fElems.push_back(std::make_pair(key, U()));
74 return fElems.back().second;
80 for(
auto& it: fElems) it.second.Erase(v);
87 for(
auto& it: fElems) it.second.RemoveLoader(l);
101 for(
auto& it: fElems) ret += it.second.TotalSize();
109 for(
auto& it: fElems) it.second.GetSpectra(ss);
116 for(
auto& it: fElems) it.second.GetReweightableSpectra(ss);
144 assert(!fnames.empty());
145 std::cout <<
"Loading from " << fnames.size() <<
" files" << std::endl;
160 if(getenv(
"CAFANA_STRIDE")){
161 stride = atoi(getenv(
"CAFANA_STRIDE"));
162 if(stride > 1 && getenv(
"CAFANA_OFFSET")){
163 offset = atoi(getenv(
"CAFANA_OFFSET"));
168 if(str.find(
' ') == std::string::npos){
170 if(ret->
NFiles() > 0)
return ret;
187 ifdh_util_ns::WebAPI webapi(i.findProject(str,
SAMExperiment()) +
"/status");
190 catch(ifdh_util_ns::WebAPIException &
e){
208 std::cerr <<
"Error: can't add Spectra after the call to Go()" << std::endl;
212 fHistDefs[spillcut][
shift][cut][wei][var].spects.push_back(&spect);
226 std::cerr <<
"Error: can't add Spectra after the call to Go()" << std::endl;
230 fHistDefs[spillcut][
shift][cut][wei][var].spects.push_back(&spect);
242 std::cerr <<
"Error: can't add Spectra after the call to Go()" << std::endl;
258 std::cerr <<
"Error: can't add Spectra after the call to Go()" << std::endl;
281 std::cerr <<
"Error: can't add Spectra after the call to Go()" << std::endl;
299 std::cerr <<
"Error: can't add Spectra after the call to Go()" << std::endl;
303 fHistDefs[spillcut][
shift][slicecut][wei][var].rwSpects.push_back(&spect);
327 TH1* hPOT = (TH1*)f->Get(
"TotalPOT");
virtual ~SpectrumLoaderBase()
BEGIN_PROLOG TPC Trig offset(g4 rise time) ProjectToHeight
BEGIN_PROLOG could also be cerr
Helper class for SpectrumLoaderBase.
bool fGone
Has Go() been called? Can't add more histograms after that.
Simple record of shifts applied to systematic parameters.
Spectrum with the value of a second variable, allowing for reweighting
void AddLoader(SpectrumLoaderBase *)
process_name opflashCryoW ana
ifdh calls between construction and destruction produce no output
virtual void Go() override
Load all the registered spectra.
U & operator[](const T &key)
Representation of a spectrum in any variable, with associated POT.
std::vector< Spectrum * > spects
double fPOTFromHist
Accumulated by calls to GetNextFile.
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.
IDMap< SpillCut, IDMap< SpillVar, IDMap< SpillVarOrMultiVar, SpectList > > > fSpillHistDefs
[spillcut][spillwei][spillvar]
IDMap< SpillCut, IDMap< SystShifts, IDMap< Cut, IDMap< Var, IDMap< VarOrMultiVar, SpectList > > > > > fHistDefs
All the spectra that need to be filled.
void GetSpectra(std::vector< Spectrum * > &ss)
DataSource
Is this data-file representing beam spills or cosmic spills?
void GetReweightableSpectra(std::vector< ReweightableSpectrum * > &ss)
virtual void RemoveReweightableSpectrum(ReweightableSpectrum *)
SpectrumLoaderBase(DataSource src=kBeam)
Component of other constructors.
const SpillCut kNoSpillCut([](const caf::SRSpillProxy *){return true;})
The simplest possible cut: pass everything, used as a default.
File source based on a SAM query or dataset (definition)
void RemoveLoader(SpectrumLoaderBase *l)
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.
Base class for the various types of spectrum loader.
Interface class for accessing ROOT files in sequence.
Simple file source based on an explicit list provided by the user.
std::unique_ptr< IFileSource > fFileSource
void GetSpectra(std::vector< Spectrum * > &ss)
then echo File list $list not found else cat $list while read file do echo $file sed s
IFileSource * WildcardOrSAMQuery(const std::string &str) const
Figure out if str is a wildcard or SAM query and return a source.
std::string SAMExperiment()
$SAM_EXPERIMENT or a nice error message and abort
int NFiles() const override
May return -1 indicating the number of files is not known.
virtual void RemoveSpectrum(Spectrum *)
Fetch files from a pre-existing SAM project.
void RemoveLoader(SpectrumLoaderBase *l)
int NFiles() const
Forwards to fFileSource.
File source based on a wildcard (glob)
Template for Cut and SpillCut.
Most useful for combining weights.
void AddLoader(SpectrumLoaderBase *)
void GetReweightableSpectra(std::vector< ReweightableSpectrum * > &ss)
BEGIN_PROLOG could also be cout