All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Protected Types | Protected Attributes | List of all members
ana::Loaders Class Reference

Collection of SpectrumLoaders for many configurations. More...

#include <Loaders.h>

Public Types

enum  DataMC { kData, kMC }
 
enum  SwappingConfig { kNonSwap, kNueSwap, kNuTauSwap, kIntrinsic }
 

Public Member Functions

 Loaders ()
 No loaders initialized. Use SetLoaderPath to configure. More...
 
 ~Loaders ()
 
void SetLoaderPath (const std::string &path, DataMC datamc, DataSource src=kBeam, SwappingConfig swap=kNonSwap)
 Configure loader via wildcard path. More...
 
void SetLoaderFiles (const std::vector< std::string > &files, DataMC datamc, DataSource src=kBeam, SwappingConfig swap=kNonSwap)
 Configure loader via explicit file list. More...
 
void AddLoader (SpectrumLoaderBase *, DataMC datamc, DataSource src=kBeam, SwappingConfig swap=kNonSwap)
 
void DisableLoader (DataMC datamc, DataSource src=kBeam, SwappingConfig swap=kNonSwap)
 
SpectrumLoaderBaseGetLoader (DataMC datamc, DataSource src=kBeam, SwappingConfig swap=kNonSwap)
 Retrieve a specific loader. More...
 
void Go ()
 Call Go() on all the loaders. More...
 

Protected Types

typedef std::tuple< DataMC,
DataSource, SwappingConfig
Key_t
 

Protected Attributes

std::map< Key_t, std::string > fLoaderPaths
 
std::map< Key_t, std::vector
< std::string > > 
fLoaderFiles
 
std::map< Key_t,
SpectrumLoaderBase * > 
fLoaders
 
NullLoader fNull
 We give this back when a loader isn't set for some configuration. More...
 

Detailed Description

Collection of SpectrumLoaders for many configurations.

Definition at line 12 of file Loaders.h.

Member Typedef Documentation

typedef std::tuple<DataMC, DataSource, SwappingConfig> ana::Loaders::Key_t
protected

Definition at line 52 of file Loaders.h.

Member Enumeration Documentation

Enumerator
kData 
kMC 

Definition at line 15 of file Loaders.h.

Enumerator
kNonSwap 
kNueSwap 
kNuTauSwap 
kIntrinsic 

Definition at line 16 of file Loaders.h.

Constructor & Destructor Documentation

ana::Loaders::Loaders ( )

No loaders initialized. Use SetLoaderPath to configure.

Definition at line 12 of file Loaders.cxx.

13  {
14  }
ana::Loaders::~Loaders ( )

Definition at line 17 of file Loaders.cxx.

18  {
19  // for(auto it: fLoaders) delete it.second;
20  }

Member Function Documentation

void ana::Loaders::AddLoader ( SpectrumLoaderBase file,
DataMC  datamc,
DataSource  src = kBeam,
SwappingConfig  swap = kNonSwap 
)

Definition at line 57 of file Loaders.cxx.

61  {
62  assert(datamc == kMC || swap == kNonSwap);
63  assert(src == kBeam || swap == kNonSwap);
64 
65  const Key_t key(datamc, src, swap);
66 
67  // Clear out the old one if necessary
68  DisableLoader(datamc, src, swap);
69 
70  fLoaders[key] = file;
71  }
void DisableLoader(DataMC datamc, DataSource src=kBeam, SwappingConfig swap=kNonSwap)
Definition: Loaders.cxx:74
* file
Definition: file_to_url.sh:69
std::map< Key_t, SpectrumLoaderBase * > fLoaders
Definition: Loaders.h:58
std::tuple< DataMC, DataSource, SwappingConfig > Key_t
Definition: Loaders.h:52
void ana::Loaders::DisableLoader ( DataMC  datamc,
DataSource  src = kBeam,
SwappingConfig  swap = kNonSwap 
)

Definition at line 74 of file Loaders.cxx.

77  {
78  assert(datamc == kMC || swap == kNonSwap);
79  assert(src == kBeam || swap == kNonSwap);
80 
81  const Key_t key(datamc, src, swap);
82 
83  // Clear out the current one if possible
84  auto it = fLoaders.find(key);
85  if(it != fLoaders.end()){
86  delete it->second;
87  fLoaders.erase(it);
88  }
89 
90  fLoaderPaths.erase(key);
91  fLoaderFiles.erase(key);
92  }
std::map< Key_t, std::string > fLoaderPaths
Definition: Loaders.h:55
std::map< Key_t, SpectrumLoaderBase * > fLoaders
Definition: Loaders.h:58
std::tuple< DataMC, DataSource, SwappingConfig > Key_t
Definition: Loaders.h:52
std::map< Key_t, std::vector< std::string > > fLoaderFiles
Definition: Loaders.h:56
SpectrumLoaderBase & ana::Loaders::GetLoader ( DataMC  datamc,
DataSource  src = kBeam,
SwappingConfig  swap = kNonSwap 
)

Retrieve a specific loader.

Definition at line 95 of file Loaders.cxx.

98  {
99  assert(datamc == kMC || swap == kNonSwap);
100  assert(src == kBeam || swap == kNonSwap);
101 
102  const Key_t key(datamc, src, swap);
103 
104  // Look up and return. Use fNull if no loader is set for this config
105  auto itLoader = fLoaders.find(key);
106  if(itLoader != fLoaders.end()) return *itLoader->second;
107 
108  auto itPath = fLoaderPaths.find(key);
109  if(itPath != fLoaderPaths.end()){
110  fLoaders[key] = new SpectrumLoader(itPath->second, src);
111  return *fLoaders[key];
112  }
113  auto itFiles = fLoaderFiles.find(key);
114  if(itFiles != fLoaderFiles.end()){
115  fLoaders[key] = new SpectrumLoader(itFiles->second, src);
116  return *fLoaders[key];
117  }
118 
119  return fNull;
120  }
std::map< Key_t, std::string > fLoaderPaths
Definition: Loaders.h:55
NullLoader fNull
We give this back when a loader isn&#39;t set for some configuration.
Definition: Loaders.h:61
std::map< Key_t, SpectrumLoaderBase * > fLoaders
Definition: Loaders.h:58
std::tuple< DataMC, DataSource, SwappingConfig > Key_t
Definition: Loaders.h:52
std::map< Key_t, std::vector< std::string > > fLoaderFiles
Definition: Loaders.h:56
void ana::Loaders::Go ( )

Call Go() on all the loaders.

Definition at line 123 of file Loaders.cxx.

124  {
125  for(auto it: fLoaders) it.second->Go();
126  }
std::map< Key_t, SpectrumLoaderBase * > fLoaders
Definition: Loaders.h:58
void ana::Loaders::SetLoaderFiles ( const std::vector< std::string > &  files,
DataMC  datamc,
DataSource  src = kBeam,
SwappingConfig  swap = kNonSwap 
)

Configure loader via explicit file list.

Definition at line 40 of file Loaders.cxx.

44  {
45  assert(datamc == kMC || swap == kNonSwap);
46  assert(src == kBeam || swap == kNonSwap);
47 
48  const Key_t key(datamc, src, swap);
49 
50  // Clear out the old one if necessary
51  DisableLoader(datamc, src, swap);
52 
53  fLoaderFiles[key] = files;
54  }
void DisableLoader(DataMC datamc, DataSource src=kBeam, SwappingConfig swap=kNonSwap)
Definition: Loaders.cxx:74
std::tuple< DataMC, DataSource, SwappingConfig > Key_t
Definition: Loaders.h:52
std::map< Key_t, std::vector< std::string > > fLoaderFiles
Definition: Loaders.h:56
void ana::Loaders::SetLoaderPath ( const std::string &  path,
DataMC  datamc,
DataSource  src = kBeam,
SwappingConfig  swap = kNonSwap 
)

Configure loader via wildcard path.

Definition at line 23 of file Loaders.cxx.

27  {
28  assert(datamc == kMC || swap == kNonSwap);
29  assert(src == kBeam || swap == kNonSwap);
30 
31  const Key_t key(datamc, src, swap);
32 
33  // Clear out the old one if necessary
34  DisableLoader(datamc, src, swap);
35 
36  fLoaderPaths[key] = path;
37  }
std::map< Key_t, std::string > fLoaderPaths
Definition: Loaders.h:55
void DisableLoader(DataMC datamc, DataSource src=kBeam, SwappingConfig swap=kNonSwap)
Definition: Loaders.cxx:74
BEGIN_PROLOG triggeremu_data_config_icarus settings PMTADCthresholds sequence::icarus_stage0_multiTPC_TPC physics sequence::icarus_stage0_EastHits_TPC physics sequence::icarus_stage0_WestHits_TPC physics producers purityana0 caloskimCalorimetryCryoE physics caloskimCalorimetryCryoW physics path
std::tuple< DataMC, DataSource, SwappingConfig > Key_t
Definition: Loaders.h:52

Member Data Documentation

std::map<Key_t, std::vector<std::string> > ana::Loaders::fLoaderFiles
protected

Definition at line 56 of file Loaders.h.

std::map<Key_t, std::string> ana::Loaders::fLoaderPaths
protected

Definition at line 55 of file Loaders.h.

std::map<Key_t, SpectrumLoaderBase*> ana::Loaders::fLoaders
protected

Definition at line 58 of file Loaders.h.

NullLoader ana::Loaders::fNull
protected

We give this back when a loader isn't set for some configuration.

Definition at line 61 of file Loaders.h.


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