All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Functions
core Namespace Reference

Classes

struct  export_table
 Struct containing (macro defined) creation/deletion operations. More...
 
struct  export_table_postprocess
 Struct containing (macro defined) creation/deletion operations. More...
 
class  ProcessorDef
 Definition for a dynamically-loaded Processor. More...
 
class  PostProcessorBase
 A generic tree-reading event-by-event processor. More...
 
class  ProcessorBase
 A generic tree-writing event-by-event processor. More...
 
class  ProcessorBlock
 A set of Processors. More...
 
class  ProviderManager
 Interface to LArSoft services. More...
 
class  SelectionBase
 Base class for event selections. More...
 

Functions

export_tableLoadProcessor (char *libname)
 
export_table_postprocessLoadPostProcessor (char *libname)
 
fhicl::ParameterSet * LoadConfig (char *configfile)
 
const simb::MCParticle * Genie2G4MCParticle (const simb::MCParticle &genie_part, const simb::MCTruth &mctruth, const std::vector< art::Ptr< simb::MCParticle >> &g4_mcparticles, const std::vector< const sim::GeneratedParticleInfo * > infos)
 

Detailed Description

Core framework functionality.

A generic processor that writes an sbnanalysis tree.

Author: A. Mastbaum mastb.nosp@m.aum@.nosp@m.uchic.nosp@m.ago..nosp@m.edu, 2018/01/25

Function Documentation

const simb::MCParticle* core::Genie2G4MCParticle ( const simb::MCParticle &  genie_part,
const simb::MCTruth &  mctruth,
const std::vector< art::Ptr< simb::MCParticle >> &  g4_mcparticles,
const std::vector< const sim::GeneratedParticleInfo * >  infos 
)

Definition at line 318 of file ProcessorBase.cxx.

322  {
323 
324  const simb::MCParticle *ret = NULL;
325  for (int iparticle = 0; iparticle < g4_mcparticles.size(); iparticle++) {
326  if (infos[iparticle]->hasGeneratedParticleIndex() &&
327  infos[iparticle]->generatedParticleIndex() < mctruth.NParticles() && // TODO: why is this number sometimes bigger than the number of particles?
328  mctruth.GetParticle(infos[iparticle]->generatedParticleIndex()).TrackId() == genie_part.TrackId() &&
329  g4_mcparticles[iparticle]->Process() == "primary" /* TODO: will have to remove this restriction to include secondary particles*/) {
330 
331  // if a genie particle re-scatters in g4 and makes more particles, then multiple g4 particles can match to a
332  // genie particle. Thus, we also check that the start location of the associated genie particle matches the g4
333  // and that the pdgid matches (to be on the safe side)
334  //
335  // Note that this should be accounted for by requiring the process to be primary. This is a bit of redundancy.
336  const simb::MCParticle& matched_genie_particle = mctruth.GetParticle(infos[iparticle]->generatedParticleIndex());
337  if ((matched_genie_particle.Position().Vect() - g4_mcparticles[iparticle]->Position().Vect()).Mag() < 1e-4 &&
338  matched_genie_particle.PdgCode() == g4_mcparticles[iparticle]->PdgCode()) {
339 
340  // this should only be true for one particle
341  assert(ret == NULL);
342  ret = g4_mcparticles[iparticle].get();
343  }
344  }
345  }
346  return ret;
347 }
do i e
fhicl::ParameterSet * core::LoadConfig ( char *  configfile)

Load configuration from JSON file to object.

Parameters
configPath to the JSON file
Returns
Configuration as a JSON object

Definition at line 80 of file Loader.cxx.

80  {
81  fhicl::ParameterSet* config = NULL;
82 
83  if (configfile) {
84  std::cout << "Loading configuration: " << configfile << "... ";
85  config = new fhicl::ParameterSet;
86  cet::filepath_lookup_nonabsolute maker("FHICL_FILE_PATH");
87  fhicl::make_ParameterSet(configfile, maker, *config);
88  std::cout << "OK" << std::endl;
89  }
90 
91  return config;
92 }
BEGIN_PROLOG could also be cout
export_table_postprocess * core::LoadPostProcessor ( char *  libname)

Load a post-processor from a shared library.

Parameters
libpathPath to the shared library
Returns
A table of exported hooks for creating/deleting instances

Definition at line 47 of file Loader.cxx.

47  {
48  std::cout << "Loading post-processor: " << libname << "... ";
49 
50  char* libdir = getenv("SBN_LIB_DIR");
51  char libpath[1000];
52  snprintf(libpath, 1000, "%s/libsbnanalysis_%s.so", libdir, libname);
53 
54  void* handle = dlopen(libpath, RTLD_NOW);
55  if (!handle) {
56  std::cout << "ERROR" << std::endl;
57  std::cerr << "Error loading post-processor " << libname << ": \n\n"
58  << dlerror()
59  << "\n\nSBN_LIB_DIR = " << libdir
60  << std::endl;
61  exit(1);
62  }
63 
64  export_table_postprocess* exports = (export_table_postprocess*) dlsym(handle, "exports");
65 
66  if (exports) {
67  std::cout << "OK" << std::endl;
68  }
69  else {
70  std::cout << "ERROR" << std::endl;
71  std::cerr << "Invalid library " << libpath << ". "
72  << "Not a PostProcessor?" << std::endl;
73  exit(1);
74  }
75 
76  return exports;
77 }
BEGIN_PROLOG could also be cerr
struct core::export_table exports
BEGIN_PROLOG could also be cout
export_table * core::LoadProcessor ( char *  libname)

Load a processor from a shared library.

Parameters
libpathPath to the shared library
Returns
A table of exported hooks for creating/deleting instances

Definition at line 15 of file Loader.cxx.

15  {
16  std::cout << "Loading processor: " << libname << "... ";
17 
18  char* libdir = getenv("SBN_LIB_DIR");
19  char libpath[1000];
20  snprintf(libpath, 1000, "%s/libsbnanalysis_%s.so", libdir, libname);
21 
22  void* handle = dlopen(libpath, RTLD_NOW);
23  if (!handle) {
24  std::cout << "ERROR" << std::endl;
25  std::cerr << "Error loading processor " << libname << ": \n\n"
26  << dlerror()
27  << "\n\nSBN_LIB_DIR = " << libdir
28  << std::endl;
29  exit(1);
30  }
31 
32  export_table* exports = (export_table*) dlsym(handle, "exports");
33 
34  if (exports) {
35  std::cout << "OK" << std::endl;
36  }
37  else {
38  std::cout << "ERROR" << std::endl;
39  std::cerr << "Invalid library " << libpath << ". "
40  << "Not a Processor?" << std::endl;
41  exit(1);
42  }
43 
44  return exports;
45 }
BEGIN_PROLOG could also be cerr
struct core::export_table exports
BEGIN_PROLOG could also be cout