3 #include "CAFAna/Core/HistAxis.h" 28 #include "boost/algorithm/string.hpp" 35 fPOT(0), fRunPOT(0), fSinglePOT(0), fBeamNue(0), fSingleNue(0), fWeightedPOT(0)
75 if(str.find(
' ') == std::string::npos){
77 if(ret->
NFiles() > 0)
return ret;
96 ifdh_util_ns::WebAPI webapi(i.findProject(str,
getenv(
"SAM_STATION")) +
"/status");
99 catch (ifdh_util_ns::WebAPIException &
e)
114 const int sid = shift.
ID();
115 const int cid = cut.
ID();
116 const int wid = wei.
ID();
118 const std::pair<int, int> sc(sid, cid);
119 const std::tuple<int, int, int> scw(sid, cid, wid);
184 fNuHistDefs.emplace_back(spect, var, cut, shift, wei);
195 fNuHistDefs.emplace_back(spect, multivar, cut, shift, wei);
245 TH1* hPOT = (TH1*)f->Get(
"TotalPOT");
254 TKey *
key = f->FindKey(
"TotalSinglePOT");
259 TH1* hTotalTrueSingleNue = 0;
260 TH1* hTotalTrueNonswapNue = 0;
262 hSinglePOT = (TH1*)f->Get(
"TotalSinglePOT");
266 hTotalTrueNonswapNue = (TH1*)f->Get(
"TotalTrueNonswapNue");
267 assert(hTotalTrueNonswapNue);
268 fBeamNue = hTotalTrueNonswapNue->Integral();
270 hTotalTrueSingleNue = (TH1*)f->Get(
"TotalTrueSingleNue");
271 assert(hTotalTrueSingleNue);
276 delete hTotalTrueSingleNue;
277 delete hTotalTrueNonswapNue;
280 TDirectory* spillDir = 0;
281 TTree* spillTree = 0;
283 TObject* obj = f->Get(
"spillTree");
290 spillTree = (TTree*)obj;
293 spillDir = (TDirectory*)obj;
294 spillTree = (TTree*)spillDir->Get(
"spill");
311 const int Nentries = spillTree->GetEntries();
313 double totFilePOT = 0;
315 for(n = 0; n < Nentries; ++
n){
326 const double wei =
hd.wei(&spill);
328 const double val =
hd.var(&spill);
329 hd.h->Fill(val, wei);
335 if(prog && n%100 == 0) prog->
SetProgress(
double(n)/Nentries);
343 else fPOT += totFilePOT;
349 TDirectory* nuDir = 0;
352 TObject* obj = f->Get(
"nuTree");
359 nuTree = (TTree*)obj;
362 nuDir = (TDirectory*)obj;
363 nuTree = (TTree*)spillDir->Get(
"nu");
369 const int NNuEntries = nuTree->GetEntries();
378 for(n = 0; n < NNuEntries; ++
n){
384 double systWeight = 1;
386 if(!
hd.shift.IsNominal()){
387 hd.shift.Shift(&nu, systWeight);
391 const double wei =
hd.wei(&nu)*systWeight;
394 const double val = (*
hd.var)(&nu);
395 hd.spect.Fill(val, wei);
398 for(
double val: (*
hd.multivar)(&nu))
hd.spect.Fill(
val, wei);
408 if(prog && n%10000 == 0) prog->
SetProgress(
double(n)/NNuEntries);
virtual ~SpectrumLoaderBase()
Histograms that are filled from the nuTree.
Cuts and Vars for the 2020 FD DiF Study.
int ID() const
Vars with the same definition will have the same ID.
TFile * GetNextFile()
Forwards to fFileSource but also accumulates POT and livetime.
const SpillVar fPOT([](const caf::SRSpillProxy *spill){return spill->spillpot;})
bool fGone
Has Go() been called? Can't add more histograms after that.
virtual void AddSpectrum(Spectrum &spect, const Var &var, const Cut &cut, const SystShifts &shift, const Var &wei=kUnweighted)
For use by the Spectrum constructor.
Proxy for caf::SRNeutrino.
Simple record of shifts applied to systematic parameters.
caf::Proxy< float > spillpot
static void BeginTransaction()
Spectrum with the value of a second variable, allowing for reweighting
double fRunPOT
Crude measure, not including spill cuts.
void SetSpillCut(const SpillCut &cut)
ifdh calls between construction and destruction produce no output
virtual void Go() override
Load all the registered spectra.
void AddSink(const Cut &cut, IExposureSink *s)
Representation of a spectrum in any variable, with associated POT.
CAFType GetCAFType(const TDirectory *dir, TTree *tr)
std::unique_ptr< SpillCut > fSpillCut
Cut applied to the spill branch for every event.
std::set< IRecordSink * > fSpectrumSinks
virtual void AccumulateExposures(const caf::SRSpillProxy *spill)=0
int Limit()
Value passed to –limit, or -1 if not specified.
int ID() const
SystShifts with the same set of systs should have the same ID.
void AddSink(IRecordSink *s)
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.
int NFiles() const override
May return -1 indicating the number of files is not known.
std::vector< std::string > wildcard(const std::string &wildcardString)
std::string getenv(std::string const &name)
ExposureSource fExposureSource
std::unordered_map< int, SystApplier * > fSinksS
WeightApplier * GetSinkSCW(const SystShifts &shift, const Cut &cut, const Var &wei)
int ID() const
Cuts with the same definition will have the same ID.
size_t Stride(bool allow_default)
Value passed to –stride, or 1 if not specified.
File source based on a SAM query or dataset (definition)
std::list< SpillHistDef > fSpillHistDefs
std::unordered_map< std::pair< int, int >, CutApplier * > fSinksSC
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.
Base class for the various types of spectrum loader.
SpectrumLoaderBase()
Component of other constructors.
size_t Offset(bool allow_default)
Value passed to –offset, or 0 if not specified.
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 SetProgress(double frac)
Update the progress fraction between zero and one.
IFileSource * WildcardOrSAMQuery(const std::string &str) const
Figure out if str is a wildcard or SAM query and return a source.
assert(nhit_max >=nhit_nbins)
Helper for SpectrumLoaderBase. Details of SpillVar plots.
A simple ascii-art progress bar.
Fetch files from a pre-existing SAM project.
std::unordered_map< std::tuple< int, int, int >, WeightApplier * > fSinksSCW
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
int NFiles() const
Forwards to fFileSource.
File source based on a wildcard (glob)
Template for Cut and SpillCut.
double fPOT
Accumulated by calls to GetNextFile.
std::list< NuHistDef > fNuHistDefs