Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
caf::VectorProxyBase Class Reference

#include "SRProxy/BasicTypesProxy.h"

Inheritance diagram for caf::VectorProxyBase:
caf::ArrayVectorProxyBase caf::Proxy< std::vector< T > >

Public Member Functions

size_t size () const
 
bool empty () const
 
void resize (size_t i)
 
std::string Name () const
 

Protected Member Functions

 VectorProxyBase (TDirectory *d, TTree *tr, const std::string &name, const long &base, int offset)
 
std::string LengthField () const
 
std::string NName () const
 Helper for LengthField() More...
 
void CheckIndex (size_t i, size_t size) const
 
TTree * GetTreeForName () const
 
std::string IndexField () const
 
std::string Subscript (int i) const
 add [i], or something more complex for nested CAFs More...
 

Protected Attributes

Proxy< intfSize
 
bool fWarn
 
TDirectory * fDir
 
TTree * fTree
 
std::string fName
 
CAFType fType
 
const long & fBase
 
int fOffset
 
Proxy< long long > * fIdxP
 
long fIdx
 

Detailed Description

Definition at line 144 of file BasicTypesProxy.h.

Constructor & Destructor Documentation

caf::VectorProxyBase::VectorProxyBase ( TDirectory *  d,
TTree *  tr,
const std::string name,
const long &  base,
int  offset 
)
protected

Definition at line 497 of file BasicTypesProxy.cxx.

501  fSize(d, tr, LengthField(), base, offset),
502  fWarn(false)
503  {
504  }
const XML_Char * name
Definition: expat.h:151
ArrayVectorProxyBase(TDirectory *d, TTree *tr, const std::string &name, const long &base, int offset)
std::string LengthField() const
const XML_Char int const XML_Char int const XML_Char * base
Definition: expat.h:331
Float_t d
Definition: plot.C:236

Member Function Documentation

void caf::ArrayVectorProxyBase::CheckIndex ( size_t  i,
size_t  size 
) const
protectedinherited

Definition at line 404 of file BasicTypesProxy.cxx.

References om::cout, allTimeWatchdog::endl, and caf::ArrayVectorProxyBase::fName.

405  {
406  // This is the only way to get good error messages. But it also seems like
407  // the call to size() here is necessary in Nested mode to trigger some
408  // side-effect within ROOT, otherwise we get some bogus index out-of-range
409  // crashes.
410  if(i >= size){
411  std::cout << std::endl << fName << "[" << (signed)i << "] out of range (size() == " << size << "). Aborting." << std::endl;
412  abort();
413  }
414  }
OStream cout
Definition: OStream.cxx:6
bool caf::VectorProxyBase::empty ( ) const

Definition at line 530 of file BasicTypesProxy.cxx.

References size().

531  {
532  return size() == 0;
533  }
TTree * caf::ArrayVectorProxyBase::GetTreeForName ( ) const
protectedinherited

Definition at line 482 of file BasicTypesProxy.cxx.

References om::cout, allTimeWatchdog::endl, caf::ArrayVectorProxyBase::fDir, caf::ArrayVectorProxyBase::fName, caf::ArrayVectorProxyBase::fTree, caf::ArrayVectorProxyBase::fType, caf::kFlatMultiTree, string, caf::StripSubscripts(), and make_root_from_grid_output::tr.

483  {
484  if(fType != kFlatMultiTree) return fTree; // all in the same tree
485 
486  const std::string sname = StripSubscripts(fName);
487  TTree* tr = (TTree*)fDir->Get(sname.c_str());
488  if(!tr){
489  std::cout << "Couldn't find TTree " << sname
490  << " in " << fDir->GetName() << std::endl;
491  abort();
492  }
493  return tr;
494  }
std::string StripSubscripts(const std::string &s)
OStream cout
Definition: OStream.cxx:6
enum BeamMode string
std::string caf::ArrayVectorProxyBase::IndexField ( ) const
protectedinherited
std::string caf::VectorProxyBase::LengthField ( ) const
protected

Definition at line 425 of file BasicTypesProxy.cxx.

References caf::ArrayVectorProxyBase::fName, caf::ArrayVectorProxyBase::fTree, caf::ArrayVectorProxyBase::fType, runNovaSAM::gErrorIgnoreLevel, compare_h5_caf::idx, caf::kFlatMultiTree, caf::kFlatSingleTree, and string.

426  {
427  if(fType == kFlatMultiTree) return fName+"_length";
428  if(fType == kFlatSingleTree) return fName+"..length";
429 
430  // Counts exist, but with non-systematic names
431  if(fName == "rec.me.trkkalman" ) return "rec.me.nkalman";
432  if(fName == "rec.me.trkdiscrete") return "rec.me.ndiscrete";
433  if(fName == "rec.me.trkcosmic" ) return "rec.me.ncosmic";
434  if(fName == "rec.me.trkbpf" ) return "rec.me.nbpf";
435 
436  const int idx = fName.find_last_of('.');
437  // foo.bar.baz -> foo.bar.nbaz
438  const std::string nname = NName();
439 
440  if(!fTree) return nname; // doesn't matter if leaf exists or not
441 
442  int olderr = gErrorIgnoreLevel;
443  gErrorIgnoreLevel = 99999999;
444  TTreeFormula ttf(("TTFProxySize-"+fName).c_str(), nname.c_str(), fTree);
445  TString junks = nname.c_str();
446  int junki;
447  const int def = ttf.DefinedVariable(junks, junki);
448  gErrorIgnoreLevel = olderr;
449 
450  if(def >= 0) return nname;
451 
452  // Otherwise fallback and make a note to warn the first time we're accessed
453  fWarn = true;
454 
455  // foo.bar.baz -> foo.bar.@baz.size()
456  return fName.substr(0, idx+1)+"@"+fName.substr(idx+1)+".size()";
457  }
std::string NName() const
Helper for LengthField()
enum BeamMode string
std::string caf::ArrayVectorProxyBase::Name ( void  ) const
inlineinherited
std::string caf::VectorProxyBase::NName ( ) const
protected

Helper for LengthField()

Definition at line 417 of file BasicTypesProxy.cxx.

References caf::ArrayVectorProxyBase::fName, and compare_h5_caf::idx.

Referenced by size().

418  {
419  const int idx = fName.find_last_of('.');
420  // foo.bar.baz -> foo.bar.nbaz
421  return fName.substr(0, idx)+".n"+fName.substr(idx+1);
422  }
void caf::VectorProxyBase::resize ( size_t  i)

Definition at line 536 of file BasicTypesProxy.cxx.

References fSize, and MECModelEnuComparisons::i.

537  {
538  fSize = i;
539  }
size_t caf::VectorProxyBase::size ( void  ) const

Definition at line 507 of file BasicTypesProxy.cxx.

References om::cout, allTimeWatchdog::endl, fSize, fWarn, findDuplicateFiles::key, caf::Proxy< T >::Name(), NName(), string, and caf::StripSubscripts().

Referenced by empty().

508  {
509  if(fWarn){
510  fWarn = false;
511 
512  // Don't emit the same warning more than once
513  static std::set<std::string> already;
514 
516  if(already.count(key) == 0){
517  already.insert(key);
518  std::cout << std::endl;
519  std::cout << "Warning: field '" << key << "' does not exist in file. "
520  << "Falling back to '" << StripSubscripts(fSize.Name()) << "' which is less efficient. "
521  << "Consider updating StandardRecord to include '" << key << "'." << std::endl;
522  std::cout << std::endl;
523  }
524  }
525 
526  return fSize;
527  }
std::string StripSubscripts(const std::string &s)
std::string Name() const
OStream cout
Definition: OStream.cxx:6
std::string NName() const
Helper for LengthField()
enum BeamMode string
std::string caf::ArrayVectorProxyBase::Subscript ( int  i) const
protectedinherited

add [i], or something more complex for nested CAFs

Definition at line 468 of file BasicTypesProxy.cxx.

References caf::ArrayVectorProxyBase::fName, caf::ArrayVectorProxyBase::fType, compare_h5_caf::idx, caf::kNested, caf::NSubscripts(), and art::to_string().

469  {
470  // Only have to do the at() business for the nested case for subscripts
471  // from the 3rd one on
472  if(fType != kNested || NSubscripts(fName) < 2){
473  return fName+"["+std::to_string(i)+"]";
474  }
475 
476  const int idx = fName.find_last_of('.');
477 
478  return fName.substr(0, idx)+".@"+fName.substr(idx+1)+".at("+std::to_string(i)+")";
479  }
int NSubscripts(const std::string &name)
Count the subscripts in the name.
std::string to_string(ModuleType mt)
Definition: ModuleType.h:32

Member Data Documentation

const long& caf::ArrayVectorProxyBase::fBase
protectedinherited

Definition at line 137 of file BasicTypesProxy.h.

TDirectory* caf::ArrayVectorProxyBase::fDir
protectedinherited

Definition at line 133 of file BasicTypesProxy.h.

Referenced by caf::ArrayVectorProxyBase::GetTreeForName().

long caf::ArrayVectorProxyBase::fIdx
mutableprotectedinherited

Definition at line 140 of file BasicTypesProxy.h.

Proxy<long long>* caf::ArrayVectorProxyBase::fIdxP
protectedinherited
std::string caf::ArrayVectorProxyBase::fName
protectedinherited
int caf::ArrayVectorProxyBase::fOffset
protectedinherited

Definition at line 138 of file BasicTypesProxy.h.

Proxy<int> caf::VectorProxyBase::fSize
protected

Definition at line 158 of file BasicTypesProxy.h.

Referenced by resize(), and size().

TTree* caf::ArrayVectorProxyBase::fTree
protectedinherited

Definition at line 134 of file BasicTypesProxy.h.

Referenced by caf::ArrayVectorProxyBase::GetTreeForName(), and LengthField().

CAFType caf::ArrayVectorProxyBase::fType
protectedinherited
bool caf::VectorProxyBase::fWarn
mutableprotected

Definition at line 160 of file BasicTypesProxy.h.

Referenced by size().


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