All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ProviderManager.cxx
Go to the documentation of this file.
1 #include <cstdlib>
2 #include <iostream>
3 #include <string>
4 #include "ubcore/Geometry/UBooNEGeometryHelper.h"
8 #include "icaruscode/Geometry/ChannelMapIcarusAlg.h"
10 #include "ubcore/Geometry/ChannelMapUBooNEAlg.h"
22 #include "fhiclcpp/ParameterSet.h"
23 #include "cetlib/filepath_maker.h"
24 #include "fhiclcpp/make_ParameterSet.h"
25 #include "core/ProviderManager.hh"
26 #include "core/Experiment.hh"
27 
28 namespace core {
29 
30 ProviderManager::ProviderManager(Experiment det, std::string fcl, bool setup_event_services) {
31  // Configuration look up policy: allow absolute paths, and search in the
32  // $FHICL_FILE_PATH for non-absolute paths.
33  const char* fhicl_file_path = getenv("FHICL_FILE_PATH");
34  assert(fhicl_file_path);
35  cet::filepath_lookup_nonabsolute policy(fhicl_file_path);
36 
37  fhicl::ParameterSet cfg;
38 
39  // Geometry: Load the correct geo::GeometryCore subclass for each detector
40  switch (det) {
41  case kExpSBND: {
42  fcl = (fcl == "" ? "gallery_services_sbnd.fcl" : fcl);
43  cfg = lar::standalone::ParseConfiguration(fcl, policy);
45  lar::standalone::SetupGeometry<geo::ChannelMapSBNDAlg>(
46  cfg.get<fhicl::ParameterSet>("services.Geometry"));
47  }
48  break;
49  case kExpMicroBooNE: {
50  fcl = (fcl == "" ? "gallery_services_uboone.fcl" : fcl);
51  cfg = lar::standalone::ParseConfiguration(fcl, policy);
52  fhicl::ParameterSet pset = \
53  cfg.get<fhicl::ParameterSet>("services.Geometry");
54  // For MicroBooNE, we also need to initialize the channel map with the
55  // optical detector channel mapping
56  std::unique_ptr<geo::ChannelMapAlg> channelMap = \
57  std::make_unique<geo::ChannelMapUBooNEAlg>(
58  cfg.get<fhicl::ParameterSet>("services.ExptGeoHelperInterface"), pset);
60  lar::standalone::SetupGeometryWithChannelMapping(pset, std::move(channelMap));
61  }
62  break;
63  case kExpICARUS: {
64  fcl = (fcl == "" ? "gallery_services_icarus.fcl" : fcl);
65  cfg = lar::standalone::ParseConfiguration(fcl, policy);
67  lar::standalone::SetupGeometry<geo::ChannelMapIcarusAlg>(
68  cfg.get<fhicl::ParameterSet>("services.Geometry"));
69  }
70  break;
71  default:
72  std::cerr << "ProviderManager: Unknown detector ID" << std::endl;
73  assert(false);
74  break;
75  }
76  config = new fhicl::ParameterSet(cfg);
77 
78  // AuxDetGeometry
79  fAuxDetGeometryProvider = std::make_unique<geo::AuxDetGeometryCore>(cfg.get<fhicl::ParameterSet>("services.AuxDetGeometry"));
80 
81  // find the GDML and load it
82  std::string relPath = config->get<std::string>("services.AuxDetGeometry.RelativePath", "" );
83  const std::string GDMLFileName = config->get<std::string>("services.AuxDetGeometry.GDML" );
84 
85  cet::search_path sp("FW_SEARCH_PATH");
86 
87  std::string GDMLFilePathHint = relPath + GDMLFileName;
88  std::string GDMLFilePath;
89  if( !sp.find_file(GDMLFilePathHint, GDMLFilePath) ) {
90  throw cet::exception("StaticLoadGeometry")
91  << "Can't find geometry file '" << GDMLFilePathHint << std::endl;
92  }
93 
94  std::string ROOTFilePathHint = relPath + GDMLFileName;
95  std::string ROOTFilePath;
96  if( !sp.find_file(ROOTFilePathHint, ROOTFilePath) ) {
97  throw cet::exception("StaticLoadGeometry")
98  << "Can't find geometry file '" << ROOTFilePathHint
99  << "' (for geometry)!\n";
100  }
101  fAuxDetGeometryProvider->LoadGeometryFile(GDMLFilePath, ROOTFilePath);
102 
103  // LArProperties
105  testing::setupProvider<detinfo::LArPropertiesStandard>(
106  cfg.get<fhicl::ParameterSet>("services.LArPropertiesService"));
107 
108  // DetectorClocks
110  testing::setupProvider<detinfo::DetectorClocksStandard>(
111  cfg.get<fhicl::ParameterSet>("services.DetectorClocksService"));
112 
113  // DetectorProperties
115  testing::setupProvider<detinfo::DetectorPropertiesStandard>(
116  cfg.get<fhicl::ParameterSet>("services.DetectorPropertiesService"),
118  fGeometryProvider.get(),
119  static_cast<const detinfo::LArProperties*>(fLArPropertiesProvider.get()),
120  static_cast<const detinfo::DetectorClocks*>(fDetectorClocksProvider.get())
121  });
122 
124  fBackTrackerProvider = NULL;
126  if (!setup_event_services) {
127  return;
128  }
129 
130  // ParticleInventory
131  if (cfg.has_key("services.ParticleInventoryService")) {
132  fParticleInventoryProvider = testing::setupProvider<cheat::ParticleInventory>(
133  cfg.get<fhicl::ParameterSet>("services.ParticleInventoryService"));
134  }
135  else {
136  std::cerr << "Warning: Particle inventory service is missing from fhicl config (" << fcl << ")." \
137  << " Setting ParticleInventoryService to NULL" << std::endl;
138  }
139 
140  // BackTracker
141  if (cfg.has_key("services.BackTrackerService")) {
143  testing::setupProvider<cheat::BackTracker>(
144  cfg.get<fhicl::ParameterSet>("services.BackTrackerService"),
147  }
148  else {
149  std::cerr << "Warning: BackTracker service is missing from fhicl config (" << fcl << ")." \
150  << " Setting BackTrackerService to NULL" << std::endl;
151  }
152 
153  // Photon BackTracker
154  if (cfg.has_key("services.PhotonBackTrackerService")) {
156  testing::setupProvider<cheat::PhotonBackTracker>(
157  cfg.get<fhicl::ParameterSet>("services.PhotonBackTrackerService"),
159  }
160  else {
161  std::cerr << "Warning: PhotonBackTracker service is missing from fhicl config (" << fcl <<")." \
162  << " Setting PhotonBackTrackerService to NULL" << std::endl;
163  }
164 
165  std::cout << "ProviderManager: Loaded configuration for: "
166  << fGeometryProvider.get()->DetectorName() << std::endl;
167 }
168 
169 void ProviderManager::SetupServices(gallery::Event &ev) {
170  // reset the channels of the back tracker
171  if (GetBackTrackerProvider() != NULL) {
174  }
175 
176  // reset information in particle inventory
177  if (GetParticleInventoryProvider() != NULL) {
182  }
183 
184  // reset information in the photon back tracker
185  if (GetPhotonBackTrackerProvider() != NULL) {
188  // GetPhotonBackTrackerProvider()->PrepOpFlashToOpHits(ev);
189  }
190 }
191 
192 
193 std::vector<Experiment> ProviderManager::GetValidExperiments() {
194  static std::vector<Experiment> ex = {
196  };
197  return ex;
198 }
199 
200 } // namespace core
201 
process_name standard_reco_uboone fcl
void PrepParticleList(const Evt &evt) const
A function to load the ParticleList and cache it This function will find the particle list and load i...
std::unique_ptr< cheat::PhotonBackTracker > fPhotonBackTrackerProvider
Experiment
Definition: Experiment.hh:13
void PrepSimChannels(const Evt &evt)
Utilities for one-line geometry initialization.
Service provider with utility LAr functions.
BEGIN_PROLOG could also be cerr
Helper functions for support of LArPropertiesService in LArSoft tests.
std::unique_ptr< detinfo::DetectorClocksStandard > fDetectorClocksProvider
fhicl::ParameterSet * config
std::unique_ptr< geo::GeometryCore > fGeometryProvider
std::unique_ptr< cheat::ParticleInventory > fParticleInventoryProvider
cheat::BackTracker * GetBackTrackerProvider() const
cheat::ParticleInventory * GetParticleInventoryProvider() const
std::unique_ptr< geo::AuxDetGeometryCore > fAuxDetGeometryProvider
Access the description of auxiliary detector geometry.
void PrepTrackIdToMCTruthIndex(const Evt &evt) const
A function to prepare and cache a map of TrackIds and MCTruth object indicies from fMCTruthList...
Helper functions for support of DetectorClocksService in LArSoft tests.
Access the description of detector geometry.
void PrepMCTruthList(const Evt &evt) const
A function to load and cache the MCTruthList of the event.
Collection of functions for quick setup of basic facilities.
void PrepOpDetBTRs(Evt const &evt)
ProviderManager(Experiment det, std::string fcl="", bool setup_event_services=true)
back track the reconstruction to the simulation
Helpers for support of DetectorPropertiesService in LArSoft tests.
std::unique_ptr< cheat::BackTracker > fBackTrackerProvider
std::unique_ptr< detinfo::LArPropertiesStandard > fLArPropertiesProvider
std::unique_ptr< geo::GeometryCore > SetupGeometryWithChannelMapping(fhicl::ParameterSet const &pset, std::unique_ptr< geo::ChannelMapAlg > channelMap)
Initializes a LArSoft geometry object.
std::string GDMLFileName
Container for a list of pointers to providers.
Definition: ProviderPack.h:114
static std::vector< Experiment > GetValidExperiments()
Header for the ParticleInvenotry Service Provider.
cheat::PhotonBackTracker * GetPhotonBackTrackerProvider() const
void SetupServices(gallery::Event &ev)
fhicl::ParameterSet ParseConfiguration(std::string configPath, cet::filepath_maker &lookupPolicy)
Parses a FHiCL configuration file.
std::unique_ptr< detinfo::DetectorPropertiesStandard > fDetectorPropertiesProvider
BEGIN_PROLOG could also be cout
Channel mapping for SBND.