Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
ana::FCCollection Class Reference

Collection of FCPoint. Serializable to/from a file. More...

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-11-28/CAFAna/FC/FCCollection.h"

Public Member Functions

 FCCollection ()
 
void AddPoint (const FCPoint &p)
 
void AddFiles (const std::string &wildcard)
 
void SaveToFile (const std::string &fname) const
 
unsigned int NPoints () const
 
const FCPointPoint (int n) const
 

Static Public Member Functions

static std::unique_ptr< FCCollectionLoadFromFile (const std::string &wildcard)
 

Protected Attributes

std::vector< FCPointfPts
 

Detailed Description

Collection of FCPoint. Serializable to/from a file.

Definition at line 12 of file FCCollection.h.

Constructor & Destructor Documentation

ana::FCCollection::FCCollection ( )

Definition at line 15 of file FCCollection.cxx.

16  {
17  }

Member Function Documentation

void ana::FCCollection::AddFiles ( const std::string wildcard)
Parameters
wildcardWildcard or single file name

Definition at line 20 of file FCCollection.cxx.

References ana::assert(), om::cout, allTimeWatchdog::endl, fin, plot_validation_datamc::fname, genie::utils::style::Format(), fPts, ana::FCPoint::FromTree(), ana::FCPoint::InitFromTree(), getGoodRuns4SAM::n, ana::pnfs2xrootd(), cacheDefinitionData::prog, string, make_root_from_grid_output::tr, and ana::Wildcard().

Referenced by AddPoint().

21  {
22  const std::vector<std::string> fnames = Wildcard(wildcard);
23  if(fnames.empty()){
24  std::cout << "No files matching " << wildcard << std::endl;
25  abort();
26  }
27 
28  Progress prog(TString::Format("Loading FCCollection from %lu files matching '%s'", fnames.size(), wildcard.c_str()).Data());
29 
30  for(const std::string& fname: fnames){
31  const double fileFrac = double(&fname - &fnames.front())/fnames.size();
32 
33  TFile* fin = TFile::Open(pnfs2xrootd(fname).c_str());
34  assert(!fin->IsZombie());
35  TTree* tr = (TTree*)fin->Get("fc");
36  assert(tr);
37 
39  const unsigned int N = tr->GetEntries();
40 
41  fPts.reserve(fPts.size()+N);
42  for(unsigned int n = 0; n < N; ++n){
43  fPts.push_back(FCPoint::FromTree(tr, n));
44 
45  if(n % 1000 == 0)
46  prog.SetProgress(fileFrac + double(n)/(N*fnames.size()));
47  }
48 
49  delete fin;
50  } // end for fname
51 
52  prog.Done();
53  std::cout << "Loaded " << fPts.size() << " experiments." << std::endl;
54  }
TString fin
Definition: Style.C:24
std::vector< FCPoint > fPts
Definition: FCCollection.h:29
std::string pnfs2xrootd(std::string loc, bool unauth)
Definition: UtilsExt.cxx:237
std::vector< std::string > Wildcard(const std::string &wildcardString)
Find files matching a UNIX glob, plus expand environment variables.
Definition: UtilsExt.cxx:268
std::vector< std::string > wildcard(const std::string &wildcardString)
Definition: convert.C:9
OStream cout
Definition: OStream.cxx:6
static void InitFromTree(TTree *tr)
Definition: FCPoint.cxx:75
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
static FCPoint FromTree(TTree *tr, int idx)
Definition: FCPoint.cxx:101
enum BeamMode string
void ana::FCCollection::AddPoint ( const FCPoint p)
inline
std::unique_ptr< FCCollection > ana::FCCollection::LoadFromFile ( const std::string wildcard)
static
Parameters
wildcardWildcard or single file name

Definition at line 67 of file FCCollection.cxx.

References runNovaSAM::ret.

Referenced by AddPoint(), FCCorrectSlice(), joint_fit_2017_contours(), joint_fit_2018_contours(), joint_fit_2019_contours(), nova_official_data_release(), plot_joint_fit_2020_contours(), and plots().

68  {
69  std::unique_ptr<FCCollection> ret(new FCCollection);
70  ret->AddFiles(wildcard);
71  return ret;
72  }
std::vector< std::string > wildcard(const std::string &wildcardString)
Definition: convert.C:9
unsigned int ana::FCCollection::NPoints ( ) const
inline
const FCPoint& ana::FCCollection::Point ( int  n) const
inline

Definition at line 27 of file FCCollection.h.

References fPts, and getGoodRuns4SAM::n.

Referenced by ana::FCSurface::Add().

27 {return fPts[n];}
std::vector< FCPoint > fPts
Definition: FCCollection.h:29
void ana::FCCollection::SaveToFile ( const std::string fname) const

Member Data Documentation

std::vector<FCPoint> ana::FCCollection::fPts
protected

Definition at line 29 of file FCCollection.h.

Referenced by AddFiles(), AddPoint(), NPoints(), Point(), and SaveToFile().


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