Public Member Functions | Private Member Functions | Private Attributes | List of all members
ana::SpectrumHandler Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-11-30/CAFAna/Analysis/SpectrumHandler.h"

Public Member Functions

 SpectrumHandler ()
 
 SpectrumHandler (const std::vector< SpectrumLoaderBase * > ls, const std::vector< std::string > dsls)
 
bool SetLoaders (const std::vector< std::string > &ds, const std::vector< std::string > &dsnames)
 
bool SetLoader (const std::string ds, const std::string dslab="")
 
bool SetLoaders (const std::vector< SpectrumLoaderBase * > ls, const std::vector< std::string > llabels)
 
bool SetLoader (SpectrumLoaderBase *l, const std::string llabel="")
 
bool SetSpillCuts (const std::vector< SpillCut > spillcuts)
 
bool SetSpillCuts (const SpillCut cut)
 
std::vector< SpectrumLoaderBase * > GetLoaders (const std::vector< std::string > labels)
 
SpectrumLoaderBaseGetLoader (const std::string label)
 
bool SetVars (const std::vector< Var > v, const std::vector< std::string > vl, const std::vector< std::string > vt, const std::vector< Binning > vb)
 
bool SetCuts (const std::vector< Cut > c, const std::vector< std::string > cl)
 
bool SetWeights (const std::vector< Var > w, const std::vector< std::string > wl)
 
bool SetWeights (const Var w, const std::string wl="")
 
bool SetShifts (const std::vector< SystShifts > s, const std::vector< std::string > sl)
 
bool SetShifts (const SystShifts s, const std::string sl="")
 
bool SetHistAxes (const std::vector< HistAxis > h, const std::vector< std::string > hl)
 
bool SetHistAxes (const HistAxis h, const std::string hl="")
 
bool CheckReady ()
 
bool CreateSpectrums ()
 
bool Go ()
 
bool Gone ()
 
bool SaveSpectrums (TFile *f)
 
int GetStatus ()
 

Private Member Functions

void CreateVarSpectrums ()
 
void CreateHistAxisSpectrums ()
 
void SaveVarSpectrums (TDirectory *d, unsigned int il)
 
void SaveHistAxisSpectrums (TDirectory *d, unsigned int il)
 

Private Attributes

int fStatus = kSpecHelpUnloaded
 
unsigned int fNLoaders = 0
 
unsigned int fNVars = 0
 
unsigned int fNCuts = 0
 
unsigned int fNWeights = 0
 
unsigned int fNShifts = 0
 
unsigned int fNHistAxes = 0
 
std::vector< std::stringfLoader_labels
 
std::vector< std::stringfVar_labels
 
std::vector< std::stringfVar_titles
 
std::vector< std::stringfCut_labels
 
std::vector< std::stringfWeight_labels
 
std::vector< std::stringfShift_labels
 
std::vector< std::stringfHistAxis_labels
 
std::vector< SpectrumLoaderBase * > fLoaders
 
std::vector< VarfVars
 
std::vector< BinningfVar_bins
 
std::vector< CutfCuts
 
std::vector< VarfWeights
 
std::vector< SystShiftsfShifts
 
std::vector< HistAxisfHistAxes
 
std::vector< std::vector< std::vector< std::vector< std::vector< Spectrum * > > > > > fSpecs
 
std::vector< std::vector< std::vector< std::vector< std::vector< Spectrum * > > > > > fHistAxisSpecs
 

Detailed Description

Definition at line 78 of file SpectrumHandler.h.

Constructor & Destructor Documentation

ana::SpectrumHandler::SpectrumHandler ( )
inline

Definition at line 89 of file SpectrumHandler.h.

References g4zmq::ls(), and SetLoaders().

89 {};
ana::SpectrumHandler::SpectrumHandler ( const std::vector< SpectrumLoaderBase * >  ls,
const std::vector< std::string dsls 
)

Definition at line 23 of file SpectrumHandler.cxx.

References fLoader_labels, fLoaders, fNLoaders, fStatus, ana::kSpecHelpLoaders, and loaders.

23  {
24  // this->SetLoaders(loaders, dataset_labels);
25  fNLoaders = loaders.size();
26  fLoaders = loaders;
27  fLoader_labels = dataset_labels;
28 
30 }
std::vector< SpectrumLoaderBase * > fLoaders
std::vector< Loaders * > loaders
Definition: syst_header.h:386
std::vector< std::string > fLoader_labels

Member Function Documentation

bool ana::SpectrumHandler::CheckReady ( )

Definition at line 203 of file SpectrumHandler.cxx.

References fCut_labels, fCuts, fHistAxes, fHistAxis_labels, fLoader_labels, fLoaders, fShift_labels, fShifts, fStatus, fVar_bins, fVar_labels, fVar_titles, fVars, fWeight_labels, fWeights, ana::kSpecHelpLoaders, and ana::kSpecHelpReady.

Referenced by CreateSpectrums(), and SetHistAxes().

203  {
204  if (fStatus != kSpecHelpLoaders)
205  return false;
206  bool loadersgood = fLoaders.size() && fLoaders.size() == fLoader_labels.size();
207  bool varsgood = fVars.size() > 0 && fVars.size() == fVar_labels.size() && fVars.size() == fVar_titles.size() && fVars.size() == fVar_bins.size();
208  bool histaxesgood = fHistAxes.size() > 0 && fHistAxes.size() == fHistAxis_labels.size();
209  bool cutsgood = fCuts.size() > 0 && fCuts.size() == fCut_labels.size();
210  bool weightsgood = fWeights.size() > 0 && fWeight_labels.size() == fWeights.size();
211  bool shiftsgood = fShifts.size() > 0 && fShift_labels.size() == fShifts.size();
212 
213  bool allready = loadersgood && (varsgood || histaxesgood) && cutsgood && weightsgood && shiftsgood;
214  if (allready)
216  return allready;
217 }
std::vector< std::string > fHistAxis_labels
std::vector< Binning > fVar_bins
std::vector< Var > fWeights
std::vector< SpectrumLoaderBase * > fLoaders
std::vector< std::string > fWeight_labels
std::vector< Cut > fCuts
std::vector< std::string > fShift_labels
std::vector< std::string > fVar_titles
std::vector< SystShifts > fShifts
std::vector< std::string > fVar_labels
std::vector< std::string > fLoader_labels
std::vector< HistAxis > fHistAxes
std::vector< std::string > fCut_labels
std::vector< Var > fVars
void ana::SpectrumHandler::CreateHistAxisSpectrums ( )
private

Definition at line 278 of file SpectrumHandler.cxx.

References fCuts, fHistAxes, fHistAxisSpecs, fLoaders, fNCuts, fNHistAxes, fNLoaders, fNShifts, fNWeights, fShifts, and fWeights.

Referenced by CreateSpectrums().

278  {
279  // Loop through loaders
280  for (unsigned int iloader = 0; iloader < fNLoaders; iloader++){
281  std::vector<std::vector<std::vector<std::vector<Spectrum* > > > > lspecs;
282  // Loop through vars
283  for (unsigned int ihaxis = 0; ihaxis < fNHistAxes; ihaxis++){
284  std::vector<std::vector<std::vector<Spectrum* > > > hspecs;
285  // Loop through cuts
286  for (unsigned int icut = 0; icut < fNCuts; icut++){
287  std::vector<std::vector<Spectrum* > > cspecs;
288  // Now some actual logic.
289  for (unsigned int iweight = 0; iweight < fNWeights; iweight++){
290  std::vector<Spectrum* > wspecs;
291  // Loop through shifts
292  for (unsigned int ishift = 0; ishift < fNShifts; ishift++)
293  wspecs.push_back(new Spectrum(
294  *fLoaders[iloader],
295  fHistAxes[ihaxis],
296  fCuts[icut],
297  fShifts[ishift],
298  fWeights[iweight] ));
299  cspecs.push_back(wspecs);
300  }
301  hspecs.push_back(cspecs);
302  }
303  lspecs.push_back(hspecs);
304  }
305  fHistAxisSpecs.push_back(lspecs); // Put into the actual spec holder (5D std::vector: loader -> var -> cut -> weight -> shift)
306  }
307 }
std::vector< Var > fWeights
std::vector< SpectrumLoaderBase * > fLoaders
std::vector< Cut > fCuts
std::vector< float > Spectrum
Definition: Constants.h:610
std::vector< SystShifts > fShifts
std::vector< std::vector< std::vector< std::vector< std::vector< Spectrum * > > > > > fHistAxisSpecs
std::vector< HistAxis > fHistAxes
bool ana::SpectrumHandler::CreateSpectrums ( )

Definition at line 219 of file SpectrumHandler.cxx.

References ana::assert(), om::cerr, CheckReady(), om::cout, CreateHistAxisSpectrums(), CreateVarSpectrums(), allTimeWatchdog::endl, fNCuts, fNHistAxes, fNLoaders, fNShifts, fNVars, fNWeights, fStatus, ana::kSpecHelpLoaders, ana::kSpecHelpReady, and art::to_string().

Referenced by muonid_fhc_dist(), muonid_opt(), muonid_rhc_dist(), SetHistAxes(), and vertex_optimize().

219  {
220  if (fStatus != kSpecHelpReady){
221  if (fStatus != kSpecHelpLoaders || !this->CheckReady()){
222  std::cerr << "Not ready to create spectrums. Doing nothing..." << std::endl;
223  return false;
224  } // We just checked that we had a loader, and CheckReady() returned true. Can continue.
225  assert(fStatus == kSpecHelpReady); // Now we KNOW it is ready... right?
226  }
227 
228  unsigned long numSpec = fNLoaders * (fNVars + fNHistAxes) * fNCuts * fNWeights * fNShifts;
229  std::cout << "Spectrum Helper: Creating all spectrum definitions.\n\tThere are a total of " << std::to_string(numSpec) << " Spectrums from:" <<
230  "\n\tLoaders: " << std::to_string(fNLoaders) <<
231  "\n\tVars: " << std::to_string(fNVars) <<
232  "\n\tHistAxes: " << std::to_string(fNHistAxes) <<
233  "\n\tCuts: " << std::to_string(fNCuts) <<
234  "\n\tWeights: " << std::to_string(fNWeights) <<
235  "\n\tShifts: " << std::to_string(fNShifts) << std::endl;
236 
239 
241 
242  return true;
243 }
OStream cerr
Definition: OStream.cxx:7
OStream cout
Definition: OStream.cxx:6
assert(nhit_max >=nhit_nbins)
std::string to_string(ModuleType mt)
Definition: ModuleType.h:32
void ana::SpectrumHandler::CreateVarSpectrums ( )
private

Definition at line 245 of file SpectrumHandler.cxx.

References fCuts, fLoaders, fNCuts, fNLoaders, fNShifts, fNVars, fNWeights, fShifts, fSpecs, fVar_bins, fVar_titles, fVars, and fWeights.

Referenced by CreateSpectrums().

245  {
246  // Loop through loaders
247  for (unsigned int iloader = 0; iloader < fNLoaders; iloader++){
248  std::vector<std::vector<std::vector<std::vector<Spectrum* > > > > lspecs;
249  // Loop through vars
250  for (unsigned int ivar = 0; ivar < fNVars; ivar++){
251  std::vector<std::vector<std::vector<Spectrum* > > > vspecs;
252  // Loop through cuts
253  for (unsigned int icut = 0; icut < fNCuts; icut++){
254  std::vector<std::vector<Spectrum* > > cspecs;
255  // Now some actual logic.
256  for (unsigned int iweight = 0; iweight < fNWeights; iweight++){
257  std::vector<Spectrum* > wspecs;
258  // Loop through shifts
259  for (unsigned int ishift = 0; ishift < fNShifts; ishift++)
260  wspecs.push_back(new Spectrum(
261  fVar_titles[ivar],
262  fVar_bins[ivar],
263  *fLoaders[iloader],
264  fVars[ivar],
265  fCuts[icut],
266  fShifts[ishift],
267  fWeights[iweight] ));
268  cspecs.push_back(wspecs);
269  }
270  vspecs.push_back(cspecs);
271  }
272  lspecs.push_back(vspecs);
273  }
274  fSpecs.push_back(lspecs); // Put into the actual spec holder (5D std::vector: loader -> var -> cut -> weight -> shift)
275  }
276 }
std::vector< Binning > fVar_bins
std::vector< Var > fWeights
std::vector< SpectrumLoaderBase * > fLoaders
std::vector< Cut > fCuts
std::vector< std::string > fVar_titles
std::vector< float > Spectrum
Definition: Constants.h:610
std::vector< SystShifts > fShifts
std::vector< std::vector< std::vector< std::vector< std::vector< Spectrum * > > > > > fSpecs
std::vector< Var > fVars
ana::SpectrumLoaderBase * ana::SpectrumHandler::GetLoader ( const std::string  label)

Definition at line 98 of file SpectrumHandler.cxx.

References fLoader_labels, fLoaders, and fNLoaders.

Referenced by GetLoaders(), muonid_opt(), and SetLoader().

98  {
99  for (unsigned int iloader = 0; iloader < fNLoaders; iloader++)
100  if (fLoader_labels[iloader] == label)
101  return fLoaders[iloader];
102  return NULL;
103 }
std::vector< SpectrumLoaderBase * > fLoaders
const char * label
std::vector< std::string > fLoader_labels
std::vector< ana::SpectrumLoaderBase * > ana::SpectrumHandler::GetLoaders ( const std::vector< std::string labels)

Definition at line 105 of file SpectrumHandler.cxx.

References GetLoader(), and demo0::loader.

Referenced by SetLoader().

105  {
106  std::vector<SpectrumLoaderBase*> loaderList;
107  for (unsigned int ilabel = 0; ilabel < loader_labels.size(); ilabel++){
108  SpectrumLoaderBase * loader = GetLoader(loader_labels[ilabel]);
109  if (loader == NULL)
110  throw std::runtime_error("Could not find loader with label \"" + loader_labels[ilabel] + "\". Skipping.");
111  loaderList.push_back(loader);
112  }
113  return loaderList;
114 }
SpectrumLoaderBase * GetLoader(const std::string label)
loader
Definition: demo0.py:10
int ana::SpectrumHandler::GetStatus ( )
inline

Definition at line 130 of file SpectrumHandler.h.

References fStatus.

130 {return fStatus;};
bool ana::SpectrumHandler::Go ( )

Definition at line 309 of file SpectrumHandler.cxx.

References om::cerr, om::cout, allTimeWatchdog::endl, fLoader_labels, fLoaders, fNLoaders, fStatus, ana::SpectrumLoaderBase::Gone(), ana::kSpecHelpReady, ana::kSpecHelpWent, demo0::loader, and art::to_string().

Referenced by muonid_fhc_dist(), muonid_opt(), muonid_rhc_dist(), SetHistAxes(), and vertex_optimize().

309  {
310  if (fStatus != kSpecHelpReady){
311  std::cerr << "You didn't create any spectrums yet." << std::endl;
312  return false;
313  }
314  for (unsigned int iloader = 0; iloader < fNLoaders; iloader++){
315  SpectrumLoaderBase * loader = fLoaders[iloader];
316  if (!loader || loader == NULL)
317  throw std::runtime_error("Trying to call Go() on Loader[" + std::to_string(iloader) + "], which was not defined.");
318  else if (loader->Gone()){
319  std::cout << "Loader: \"" + fLoader_labels[iloader] + "\" has already Gone() (likely by another instance of SpectrumHandler)." << std::endl;
320  continue;
321  }
322  fLoaders[iloader]->Go();
323  }
324 
326  return true;
327 }
OStream cerr
Definition: OStream.cxx:7
std::vector< SpectrumLoaderBase * > fLoaders
loader
Definition: demo0.py:10
OStream cout
Definition: OStream.cxx:6
std::vector< std::string > fLoader_labels
std::string to_string(ModuleType mt)
Definition: ModuleType.h:32
bool ana::SpectrumHandler::Gone ( )

Definition at line 329 of file SpectrumHandler.cxx.

References om::cerr, allTimeWatchdog::endl, fLoaders, fStatus, ana::kSpecHelpUnloaded, and submit_hadd::l.

Referenced by SetHistAxes().

329  {
330  if (fStatus == kSpecHelpUnloaded){
331  std::cerr << "No loaders have been set yet." << std::endl;
332  return false;
333  }
334  // Loop throuh all loaders
335  for (SpectrumLoaderBase * l : fLoaders)
336  // If any loader has had Go() already called, return true
337  if (l->Gone())
338  return true;
339 
340  // No loaders had Go() called yet.
341  return false;
342 }
OStream cerr
Definition: OStream.cxx:7
std::vector< SpectrumLoaderBase * > fLoaders
void ana::SpectrumHandler::SaveHistAxisSpectrums ( TDirectory *  d,
unsigned int  il 
)
private

Definition at line 405 of file SpectrumHandler.cxx.

References fCut_labels, fHistAxis_labels, fHistAxisSpecs, fNCuts, fNHistAxes, fNShifts, fNWeights, fShift_labels, fWeight_labels, and string.

Referenced by SaveSpectrums().

405  {
406  // Loop through hist axes
407  for (unsigned int ihaxis = 0; ihaxis < fNHistAxes; ihaxis++){
408  std::string hlabel = fHistAxis_labels[ihaxis];
409 
410  // Loop through cuts
411  for (unsigned int icut = 0; icut < fNCuts; icut++){
412  std::string clabel = fCut_labels[icut];
413 
414  // Loop through weights
415  for (unsigned int iweight = 0; iweight < fNWeights; iweight++){
416  std::string wlabel = fWeight_labels[iweight];
417 
418  // Loop through shifts
419  for (unsigned int ishift = 0; ishift < fNShifts; ishift++){
420  std::string slabel = fShift_labels[ishift];
421 
422  std::string specname = hlabel + "_" + clabel;
423  if (!wlabel.empty())
424  specname = specname + "_" + wlabel;
425  if (!slabel.empty())
426  specname = specname + "_" + slabel;
427 
428  fHistAxisSpecs[iloader][ihaxis][icut][iweight][ishift]->SaveTo(loaderDir, specname);
429 
430  }
431 
432  }
433  }
434  }
435 }
std::vector< std::string > fHistAxis_labels
std::vector< std::string > fWeight_labels
std::vector< std::string > fShift_labels
std::vector< std::vector< std::vector< std::vector< std::vector< Spectrum * > > > > > fHistAxisSpecs
std::vector< std::string > fCut_labels
enum BeamMode string
bool ana::SpectrumHandler::SaveSpectrums ( TFile *  f)

Definition at line 344 of file SpectrumHandler.cxx.

References om::cerr, allTimeWatchdog::endl, fLoader_labels, fNLoaders, fStatus, ana::kSpecHelpWent, SaveHistAxisSpectrums(), and SaveVarSpectrums().

Referenced by muonid_fhc_dist(), muonid_opt(), muonid_rhc_dist(), SetHistAxes(), and vertex_optimize().

344  {
345  if (fStatus != kSpecHelpWent){
346  std::cerr << "You didn't create the spectrums and fill them yet!!! Create them, and call Go() on loaders." << std::endl;
347  return false;
348  }
349  // Check file exists, is writable here?
350  if (!fout || fout == NULL || fout->IsZombie()){
351  std::cerr << "File not writable. Aborting save." << std::endl;
352  return false;
353  }
354 
355  // Only loop through loaders once to prevent trying to make directories twice
356  for (unsigned int iloader = 0; iloader < fNLoaders; iloader++){
357  // Switch to the top-level directory of the output file.
358  fout->cd();
359  TDirectory* loaderDir = fout->GetDirectory("/");
360 
361  // If multiple loaders, each gets its own directory for simplicity.
362  if (fLoader_labels.size() > iloader && !fLoader_labels[iloader].empty())
363  loaderDir = fout->mkdir(fLoader_labels[iloader].c_str());
364 
365  SaveVarSpectrums(loaderDir, iloader);
366  SaveHistAxisSpectrums(loaderDir, iloader);
367 
368  } // End loop through loaders
369 
370  return true;
371 }
OStream cerr
Definition: OStream.cxx:7
void SaveVarSpectrums(TDirectory *d, unsigned int il)
void SaveHistAxisSpectrums(TDirectory *d, unsigned int il)
std::vector< std::string > fLoader_labels
void ana::SpectrumHandler::SaveVarSpectrums ( TDirectory *  d,
unsigned int  il 
)
private

Definition at line 373 of file SpectrumHandler.cxx.

References fCut_labels, fNCuts, fNShifts, fNVars, fNWeights, fShift_labels, fSpecs, fVar_labels, fWeight_labels, and string.

Referenced by SaveSpectrums().

373  {
374  // Loop through vars
375  for (unsigned int ivar = 0; ivar < fNVars; ivar++){
376  std::string vlabel = fVar_labels[ivar];
377 
378  // Loop through cuts
379  for (unsigned int icut = 0; icut < fNCuts; icut++){
380  std::string clabel = fCut_labels[icut];
381 
382  // Loop through weights
383  for (unsigned int iweight = 0; iweight < fNWeights; iweight++){
384  std::string wlabel = fWeight_labels[iweight];
385 
386  // Loop through shifts
387  for (unsigned int ishift = 0; ishift < fNShifts; ishift++){
388  std::string slabel = fShift_labels[ishift];
389 
390  std::string specname = vlabel + "_" + clabel;
391  if (!wlabel.empty())
392  specname = specname + "_" + wlabel;
393  if (!slabel.empty())
394  specname = specname + "_" + slabel;
395 
396  fSpecs[iloader][ivar][icut][iweight][ishift]->SaveTo(loaderDir, specname);
397 
398  }
399 
400  }
401  }
402  }
403 }
std::vector< std::string > fWeight_labels
std::vector< std::string > fShift_labels
std::vector< std::string > fVar_labels
std::vector< std::vector< std::vector< std::vector< std::vector< Spectrum * > > > > > fSpecs
std::vector< std::string > fCut_labels
enum BeamMode string
bool ana::SpectrumHandler::SetCuts ( const std::vector< Cut c,
const std::vector< std::string cl 
)

Definition at line 135 of file SpectrumHandler.cxx.

References om::cerr, cut_labels, update_sam_good_runs_metadata::cuts, allTimeWatchdog::endl, fCut_labels, fCuts, fNCuts, fStatus, ana::kSpecHelpLoaders, and ana::kSpecHelpUnloaded.

Referenced by muonid_fhc_dist(), muonid_opt(), muonid_rhc_dist(), SetLoader(), and vertex_optimize().

135  {
137  throw std::runtime_error("Attempt to set the vars too late. The spectrums are either ready, or already had go() called on them.");
138 
139  if (cuts.size() != cut_labels.size()){
140  std::cerr << "Number of cuts not equal to number of cut labels. Fix that." << std::endl;
141  return false;
142  }
143 
144  fCuts = cuts;
146 
147  fNCuts = fCuts.size();
148 
149  return true;
150 }
OStream cerr
Definition: OStream.cxx:7
std::vector< std::string > cut_labels
std::vector< Cut > fCuts
std::vector< std::string > fCut_labels
bool ana::SpectrumHandler::SetHistAxes ( const std::vector< HistAxis h,
const std::vector< std::string hl 
)

Definition at line 186 of file SpectrumHandler.cxx.

References om::cerr, allTimeWatchdog::endl, fHistAxes, fHistAxis_labels, fNHistAxes, fStatus, ana::kSpecHelpLoaders, and ana::kSpecHelpUnloaded.

Referenced by SetShifts(), and vertex_optimize().

186  {
188  throw std::runtime_error("Attempt to set the vars too late. The spectrums are either ready, or already had go() called on them.");
189 
190  if (haxes.size() != haxis_labels.size()){
191  std::cerr << "Number of HistAxis not equal to number of HistAxis labels. Ignoring HistAxes." << std::endl;
192  return false;
193  }
194 
195  fHistAxes = haxes;
196  fHistAxis_labels = haxis_labels;
197 
198  fNHistAxes = fHistAxes.size();
199 
200  return true;
201 }
std::vector< std::string > fHistAxis_labels
OStream cerr
Definition: OStream.cxx:7
std::vector< HistAxis > fHistAxes
bool ana::SpectrumHandler::SetHistAxes ( const HistAxis  h,
const std::string  hl = "" 
)
inline

Definition at line 120 of file SpectrumHandler.h.

References CheckReady(), CreateSpectrums(), MakeMiniprodValidationCuts::f, Go(), Gone(), SaveSpectrums(), and SetHistAxes().

Referenced by SetHistAxes().

120 {return SetHistAxes(std::vector<HistAxis> {h}, std::vector<std::string> {hl});};
bool SetHistAxes(const std::vector< HistAxis > h, const std::vector< std::string > hl)
bool ana::SpectrumHandler::SetLoader ( const std::string  ds,
const std::string  dslab = "" 
)
inline

Definition at line 101 of file SpectrumHandler.h.

References SetLoaders().

Referenced by muonid_opt(), and vertex_optimize().

101 {return SetLoaders(std::vector<std::string> {ds}, std::vector<std::string> {dslab});};
A very simple service to remember what detector we&#39;re working in.
bool SetLoaders(const std::vector< std::string > &ds, const std::vector< std::string > &dsnames)
bool ana::SpectrumHandler::SetLoader ( SpectrumLoaderBase l,
const std::string  llabel = "" 
)
inline

Definition at line 103 of file SpectrumHandler.h.

References plot_validation_datamc::c, cut, GetLoader(), GetLoaders(), label, PandAna.Demos.pi0_spectra::labels, SetCuts(), SetLoaders(), SetSpillCuts(), SetVars(), SetWeights(), string, registry_explorer::v, APDInfo::vb, and w.

103 {return SetLoaders(std::vector<SpectrumLoaderBase*> {l}, std::vector<std::string> {llabel});};
bool SetLoaders(const std::vector< std::string > &ds, const std::vector< std::string > &dsnames)
bool ana::SpectrumHandler::SetLoaders ( const std::vector< std::string > &  ds,
const std::vector< std::string > &  dsnames 
)

Definition at line 32 of file SpectrumHandler.cxx.

References om::cerr, allTimeWatchdog::endl, fLoader_labels, fLoaders, fNLoaders, fStatus, ana::kSpecHelpLoaders, ana::kSpecHelpUnloaded, and demo0::loader.

Referenced by muonid_fhc_dist(), muonid_opt(), muonid_rhc_dist(), SetLoader(), and SpectrumHandler().

32  {
34  throw std::runtime_error("Attempt to set loaders while SpecHelper is not unloaded.");
35 
36  if (datasets.size() != dataset_labels.size()){
37  std::cerr << "Number of datasets not equal to number of dataset labels. Please fix that." << std::endl;
38  return false;
39  }
40 
41  fNLoaders = datasets.size();
42  for (unsigned int idataset = 0; idataset < fNLoaders; idataset++){
43  SpectrumLoaderBase * loader;
44  loader = new SpectrumLoader(datasets[idataset]);
45  fLoaders.push_back(loader);
46  fLoader_labels.push_back(dataset_labels[idataset]);
47  }
49  return true;
50 }
OStream cerr
Definition: OStream.cxx:7
std::vector< SpectrumLoaderBase * > fLoaders
loader
Definition: demo0.py:10
std::vector< std::string > fLoader_labels
std::vector< Dataset > datasets
Definition: Periods.h:3
bool ana::SpectrumHandler::SetLoaders ( const std::vector< SpectrumLoaderBase * >  ls,
const std::vector< std::string llabels 
)

Definition at line 52 of file SpectrumHandler.cxx.

References om::cerr, allTimeWatchdog::endl, fLoader_labels, fLoaders, fNLoaders, fStatus, ana::kSpecHelpLoaders, ana::kSpecHelpUnloaded, and demo0::loader.

52  {
54  throw std::runtime_error("Attempt to set loaders while SpecHelper is not unloaded.");
55 
56  if (loaders.size() != loader_labels.size()){
57  std::cerr << "Number of loaders not equal to number of loader labels." << std::endl;
58  return false;
59  }
60 
61  fNLoaders = loaders.size();
62  for (unsigned int iloader = 0; iloader < fNLoaders; iloader++){
63  SpectrumLoaderBase * loader = loaders[iloader];
64  if (!loader || loader == NULL)
65  throw std::runtime_error("Attempt to use a non-existent loader: " + loader_labels[iloader]);
66  fLoaders.push_back(loader);
67  fLoader_labels.push_back(loader_labels[iloader]);
68  }
70  return true;
71 }
OStream cerr
Definition: OStream.cxx:7
std::vector< SpectrumLoaderBase * > fLoaders
loader
Definition: demo0.py:10
std::vector< Loaders * > loaders
Definition: syst_header.h:386
std::vector< std::string > fLoader_labels
bool ana::SpectrumHandler::SetShifts ( const std::vector< SystShifts s,
const std::vector< std::string sl 
)

Definition at line 169 of file SpectrumHandler.cxx.

References om::cerr, allTimeWatchdog::endl, fNShifts, fShift_labels, fShifts, fStatus, ana::kSpecHelpLoaders, and ana::kSpecHelpUnloaded.

Referenced by muonid_fhc_dist(), muonid_opt(), muonid_rhc_dist(), SetWeights(), and vertex_optimize().

169  {
171  throw std::runtime_error("Attempt to set the vars too late. The spectrums are either ready, or already had go() called on them.");
172 
173  if (shifts.size() != shift_labels.size()){
174  std::cerr << "Number of shifts not equal to number of shift labels. Ignoring shifts." << std::endl;
175  return false;
176  }
177 
178  fShifts = shifts;
179  fShift_labels = shift_labels;
180 
181  fNShifts = fShifts.size();
182 
183  return true;
184 }
OStream cerr
Definition: OStream.cxx:7
std::vector< std::string > fShift_labels
std::vector< SystShifts > fShifts
bool ana::SpectrumHandler::SetShifts ( const SystShifts  s,
const std::string  sl = "" 
)
inline

Definition at line 117 of file SpectrumHandler.h.

References make_syst_table_plots::h, SetHistAxes(), and SetShifts().

Referenced by SetShifts().

117 {return SetShifts(std::vector<SystShifts> {s}, std::vector<std::string> {sl});};
bool SetShifts(const std::vector< SystShifts > s, const std::vector< std::string > sl)
const XML_Char * s
Definition: expat.h:262
bool ana::SpectrumHandler::SetSpillCuts ( const std::vector< SpillCut spillcuts)

Definition at line 73 of file SpectrumHandler.cxx.

References om::cerr, allTimeWatchdog::endl, fLoaders, fNLoaders, fStatus, ana::kSpecHelpLoaders, and art::to_string().

Referenced by muonid_fhc_dist(), muonid_opt(), muonid_rhc_dist(), and SetLoader().

73  {
75  throw std::runtime_error("Attempt to set spill cuts sometime NOT right after setting loaders. Only allow setting spill cuts IMMEDIATELY after setting loaders.");
76 
77  if (fNLoaders != spillcuts.size()){
78  std::cerr << "Warning: Number of spill cuts ( " << std::to_string(spillcuts.size()) << " ) not equal to number of loaders ( " << std::to_string(fNLoaders) << " ).\n\tFailed to set spill cuts." << std::endl;
79  return false;
80  }
81 
82  for (unsigned int iloader = 0; iloader < fNLoaders; iloader++)
83  fLoaders[iloader]->SetSpillCut(spillcuts[iloader]);
84 
85  return true;
86 }
OStream cerr
Definition: OStream.cxx:7
std::vector< SpectrumLoaderBase * > fLoaders
std::string to_string(ModuleType mt)
Definition: ModuleType.h:32
bool ana::SpectrumHandler::SetSpillCuts ( const SpillCut  cut)

Definition at line 88 of file SpectrumHandler.cxx.

References fLoaders, fNLoaders, fStatus, and ana::kSpecHelpLoaders.

88  {
90  throw std::runtime_error("Attempt to set spill cuts sometime NOT right after setting loaders. Only allow setting spill cuts IMMEDIATELY after setting loaders.");
91 
92  for (unsigned int iloader = 0; iloader < fNLoaders; iloader++)
93  fLoaders[iloader]->SetSpillCut(cut);
94 
95  return true;
96 }
std::vector< SpectrumLoaderBase * > fLoaders
const Cut cut
Definition: exporter_fd.C:30
bool ana::SpectrumHandler::SetVars ( const std::vector< Var v,
const std::vector< std::string vl,
const std::vector< std::string vt,
const std::vector< Binning vb 
)

Definition at line 116 of file SpectrumHandler.cxx.

References om::cerr, allTimeWatchdog::endl, fNVars, fStatus, fVar_bins, fVar_labels, fVar_titles, fVars, ana::kSpecHelpLoaders, ana::kSpecHelpUnloaded, and vars.

Referenced by muonid_fhc_dist(), muonid_opt(), muonid_rhc_dist(), and SetLoader().

116  {
118  throw std::runtime_error("Attempt to set the vars too late. The spectrums are either ready, or already had go() called on them.");
119 
120  if (vars.size() != var_labels.size() || vars.size() != var_titles.size() || vars.size() != var_bins.size()){
121  std::cerr << "Number of vars not equal to number of var labels / titles. Fix that." << std::endl;
122  return false;
123  }
124 
125  fVars = vars;
126  fVar_labels = var_labels;
127  fVar_titles = var_titles;
128  fVar_bins = var_bins;
129 
130  fNVars = fVars.size();
131 
132  return true;
133 }
std::vector< Binning > fVar_bins
OStream cerr
Definition: OStream.cxx:7
std::vector< std::string > fVar_titles
const std::map< std::pair< std::string, std::string >, Variable > vars
std::vector< std::string > fVar_labels
std::vector< Var > fVars
bool ana::SpectrumHandler::SetWeights ( const std::vector< Var w,
const std::vector< std::string wl 
)

Definition at line 152 of file SpectrumHandler.cxx.

References om::cerr, allTimeWatchdog::endl, fNWeights, fStatus, fWeight_labels, fWeights, ana::kSpecHelpLoaders, ana::kSpecHelpUnloaded, and weights.

Referenced by muonid_fhc_dist(), muonid_opt(), muonid_rhc_dist(), SetLoader(), and vertex_optimize().

152  {
154  throw std::runtime_error("Attempt to set the vars too late. The spectrums are either ready, or already had go() called on them.");
155 
156  if (weights.size() != weight_labels.size()){
157  std::cerr << "Number of Weights not equal to number of weight labels. Fix that." << std::endl;
158  return false;
159  }
160 
161  fWeights = weights;
162  fWeight_labels = weight_labels;
163 
164  fNWeights = fWeights.size();
165 
166  return true;
167 }
std::vector< Var > fWeights
OStream cerr
Definition: OStream.cxx:7
std::vector< std::string > fWeight_labels
Var weights
bool ana::SpectrumHandler::SetWeights ( const Var  w,
const std::string  wl = "" 
)
inline

Definition at line 115 of file SpectrumHandler.h.

References SetShifts(), SetWeights(), and datagram_client::sl.

Referenced by SetWeights().

115 {return SetWeights(std::vector<Var> {w}, std::vector<std::string> {wl});};
Float_t w
Definition: plot.C:20
bool SetWeights(const std::vector< Var > w, const std::vector< std::string > wl)

Member Data Documentation

std::vector<std::string> ana::SpectrumHandler::fCut_labels
private

Definition at line 152 of file SpectrumHandler.h.

Referenced by CheckReady(), SaveHistAxisSpectrums(), SaveVarSpectrums(), and SetCuts().

std::vector<Cut> ana::SpectrumHandler::fCuts
private
std::vector<HistAxis> ana::SpectrumHandler::fHistAxes
private

Definition at line 164 of file SpectrumHandler.h.

Referenced by CheckReady(), CreateHistAxisSpectrums(), and SetHistAxes().

std::vector<std::string> ana::SpectrumHandler::fHistAxis_labels
private

Definition at line 155 of file SpectrumHandler.h.

Referenced by CheckReady(), SaveHistAxisSpectrums(), and SetHistAxes().

std::vector< std::vector< std::vector< std::vector< std::vector< Spectrum* > > > > > ana::SpectrumHandler::fHistAxisSpecs
private

Definition at line 170 of file SpectrumHandler.h.

Referenced by CreateHistAxisSpectrums(), and SaveHistAxisSpectrums().

std::vector<std::string> ana::SpectrumHandler::fLoader_labels
private

Definition at line 149 of file SpectrumHandler.h.

Referenced by CheckReady(), GetLoader(), Go(), SaveSpectrums(), SetLoaders(), and SpectrumHandler().

std::vector<SpectrumLoaderBase*> ana::SpectrumHandler::fLoaders
private
unsigned int ana::SpectrumHandler::fNCuts = 0
private
unsigned int ana::SpectrumHandler::fNHistAxes = 0
private
unsigned int ana::SpectrumHandler::fNLoaders = 0
private
unsigned int ana::SpectrumHandler::fNShifts = 0
private
unsigned int ana::SpectrumHandler::fNVars = 0
private

Definition at line 142 of file SpectrumHandler.h.

Referenced by CreateSpectrums(), CreateVarSpectrums(), SaveVarSpectrums(), and SetVars().

unsigned int ana::SpectrumHandler::fNWeights = 0
private
std::vector<std::string> ana::SpectrumHandler::fShift_labels
private

Definition at line 154 of file SpectrumHandler.h.

Referenced by CheckReady(), SaveHistAxisSpectrums(), SaveVarSpectrums(), and SetShifts().

std::vector<SystShifts> ana::SpectrumHandler::fShifts
private
std::vector< std::vector< std::vector< std::vector< std::vector< Spectrum* > > > > > ana::SpectrumHandler::fSpecs
private

Definition at line 169 of file SpectrumHandler.h.

Referenced by CreateVarSpectrums(), and SaveVarSpectrums().

int ana::SpectrumHandler::fStatus = kSpecHelpUnloaded
private
std::vector<Binning> ana::SpectrumHandler::fVar_bins
private

Definition at line 160 of file SpectrumHandler.h.

Referenced by CheckReady(), CreateVarSpectrums(), and SetVars().

std::vector<std::string> ana::SpectrumHandler::fVar_labels
private

Definition at line 150 of file SpectrumHandler.h.

Referenced by CheckReady(), SaveVarSpectrums(), and SetVars().

std::vector<std::string> ana::SpectrumHandler::fVar_titles
private

Definition at line 151 of file SpectrumHandler.h.

Referenced by CheckReady(), CreateVarSpectrums(), and SetVars().

std::vector<Var> ana::SpectrumHandler::fVars
private

Definition at line 159 of file SpectrumHandler.h.

Referenced by CheckReady(), CreateVarSpectrums(), and SetVars().

std::vector<std::string> ana::SpectrumHandler::fWeight_labels
private

Definition at line 153 of file SpectrumHandler.h.

Referenced by CheckReady(), SaveHistAxisSpectrums(), SaveVarSpectrums(), and SetWeights().

std::vector<Var> ana::SpectrumHandler::fWeights
private

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