All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
geo::AuxDetGeometry Class Reference

The geometry of one entire detector, as served by art. More...

#include <AuxDetGeometry.h>

Public Member Functions

 AuxDetGeometry (fhicl::ParameterSet const &pset, art::ActivityRegistry &reg)
 
AuxDetGeometryCore const & GetProvider () const
 Returns a constant reference to the service provider. More...
 
AuxDetGeometryCore const * GetProviderPtr () const
 Returns a constant pointer to the service provider. More...
 

Private Member Functions

void preBeginRun (art::Run const &run)
 Updates the geometry if needed at the beginning of each new run. More...
 
void LoadNewGeometry (std::string gdmlfile, std::string rootfile)
 Expands the provided paths and loads the geometry description(s) More...
 
void InitializeChannelMap ()
 
AuxDetGeometryCoreGetProvider ()
 Returns a reference to the service provider. More...
 
AuxDetGeometryCoreGetProviderPtr ()
 Returns a pointer to the service provider. More...
 

Private Attributes

AuxDetGeometryCore fProvider
 the actual service provider More...
 
std::string fRelPath
 
bool fForceUseFCLOnly
 
fhicl::ParameterSet fSortingParameters
 Parameter set to define the channel map sorting. More...
 

Detailed Description

The geometry of one entire detector, as served by art.

This class extends the interface of the geometry service provider, GeometryCore, to the one of an art service. It handles the correct initialization of the provider using information

It relies on geo::ExptGeoHelperInterface service to obtain the channel mapping algorithm proper for the selected geometry.

The geometry initialization happens immediately on construction. Optionally, the geometry is automatically reinitialized on each run based on the information contained in the art::Run object.

Configuration

In addition to the parameters documented in geo::GeometryCore, the following parameters are supported:

Note
Currently, the file defined by GDML parameter is also served to ROOT for the internal geometry representation.

Definition at line 84 of file AuxDetGeometry.h.

Constructor & Destructor Documentation

geo::AuxDetGeometry::AuxDetGeometry ( fhicl::ParameterSet const &  pset,
art::ActivityRegistry &  reg 
)

Definition at line 32 of file AuxDetGeometry.cc.

33  : fProvider (pset)
34  , fRelPath (pset.get< std::string >("RelativePath", "" ))
35  , fForceUseFCLOnly (pset.get< bool >("ForceUseFCLOnly" , false))
36  , fSortingParameters(pset.get<fhicl::ParameterSet>("SortingParameters", {}))
fhicl::ParameterSet fSortingParameters
Parameter set to define the channel map sorting.
AuxDetGeometryCore fProvider
the actual service provider

Member Function Documentation

AuxDetGeometryCore const& geo::AuxDetGeometry::GetProvider ( ) const
inline

Returns a constant reference to the service provider.

Definition at line 91 of file AuxDetGeometry.h.

91 { return fProvider; }
AuxDetGeometryCore fProvider
the actual service provider
AuxDetGeometryCore& geo::AuxDetGeometry::GetProvider ( )
inlineprivate

Returns a reference to the service provider.

Definition at line 107 of file AuxDetGeometry.h.

107 { return fProvider; }
AuxDetGeometryCore fProvider
the actual service provider
AuxDetGeometryCore const* geo::AuxDetGeometry::GetProviderPtr ( ) const
inline

Returns a constant pointer to the service provider.

Definition at line 94 of file AuxDetGeometry.h.

94 { return &GetProvider(); }
AuxDetGeometryCore const & GetProvider() const
Returns a constant reference to the service provider.
AuxDetGeometryCore* geo::AuxDetGeometry::GetProviderPtr ( )
inlineprivate

Returns a pointer to the service provider.

Definition at line 110 of file AuxDetGeometry.h.

110 { return &GetProvider(); }
AuxDetGeometryCore const & GetProvider() const
Returns a constant reference to the service provider.
void geo::AuxDetGeometry::InitializeChannelMap ( )
private

Definition at line 96 of file AuxDetGeometry.cc.

97  {
98  // the channel map is responsible of calling the channel map configuration
99  // of the geometry
100  auto channelMap = art::ServiceHandle<geo::AuxDetExptGeoHelperInterface>()->ConfigureAuxDetChannelMapAlg(fSortingParameters);
101  if (!channelMap) {
102  throw cet::exception("ChannelMapLoadFail") << " failed to load new channel map";
103  }
104  fProvider.ApplyChannelMap(move(channelMap));
105  } // Geometry::InitializeChannelMap()
void ApplyChannelMap(std::unique_ptr< geo::AuxDetChannelMapAlg > pChannelMap)
Initializes the geometry to work with this channel map.
fhicl::ParameterSet fSortingParameters
Parameter set to define the channel map sorting.
AuxDetGeometryCore fProvider
the actual service provider
void geo::AuxDetGeometry::LoadNewGeometry ( std::string  gdmlfile,
std::string  rootfile 
)
private

Expands the provided paths and loads the geometry description(s)

Definition at line 108 of file AuxDetGeometry.cc.

109  {
110  // start with the relative path
112 
113  // add the base file names
114  ROOTFileName.append(gdmlfile); // not rootfile (why?)
115  GDMLFileName.append(gdmlfile);
116 
117  // Search all reasonable locations for the GDML file that contains
118  // the detector geometry.
119  // cet::search_path constructor decides if initialized value is a path
120  // or an environment variable
121  cet::search_path sp("FW_SEARCH_PATH");
122 
123  std::string GDMLfile;
124  if( !sp.find_file(GDMLFileName, GDMLfile) ) {
125  throw cet::exception("AuxDetGeometry") << "cannot find the gdml geometry file:"
126  << "\n" << GDMLFileName
127  << "\nbail ungracefully.\n";
128  }
129 
130  std::string ROOTfile;
131  if( !sp.find_file(ROOTFileName, ROOTfile) ) {
132  throw cet::exception("AuxDetGeometry") << "cannot find the root geometry file:\n"
133  << "\n" << ROOTFileName
134  << "\nbail ungracefully.\n";
135  }
136 
137  // initialize the geometry with the files we have found
138  GetProvider().LoadGeometryFile(GDMLfile, ROOTfile);
139 
140  // now update the channel map
142 
143  } // Geometry::LoadNewGeometry()
void LoadGeometryFile(std::string gdmlfile, std::string rootfile)
Loads the geometry information from the specified files.
AuxDetGeometryCore const & GetProvider() const
Returns a constant reference to the service provider.
std::string ROOTFileName
std::string GDMLFileName
void geo::AuxDetGeometry::preBeginRun ( art::Run const &  run)
private

Updates the geometry if needed at the beginning of each new run.

Definition at line 59 of file AuxDetGeometry.cc.

60  {
61  // FIXME this seems utterly wrong: constructor loads geometry based on an
62  // explicit parameter, whereas here we load it by detector name
63 
64  // if we are requested to stick to the configured geometry, do nothing
65  if (fForceUseFCLOnly) return;
66 
67  // check here to see if we need to load a new geometry.
68  // get the detector id from the run object
69  //std::vector< art::Handle<sumdata::RunData> > rdcol;
70  //run.getManyByType(rdcol);
71  auto rdcol = run.getMany<sumdata::RunData>();
72  if (rdcol.empty()) {
73  mf::LogWarning("LoadNewGeometry") << "cannot find sumdata::RunData object to grab detector name\n"
74  << "this is expected if generating MC files\n"
75  << "using default geometry from configuration file\n";
76  return;
77  }
78 
79  // if the detector name is still the same, everything is fine
80  std::string newDetectorName = rdcol.front()->DetName();
81  if (GetProvider().DetectorName() == newDetectorName) return;
82 
83  // else {
84  // // the detector name is specified in the RunData object
85  // SetDetectorName(newDetectorName);
86  // }
87 
89  GetProvider().DetectorName() + ".gdml",
90  GetProvider().DetectorName() + ".gdml"
91  );
92  } // Geometry::preBeginRun()
std::string const & DetName() const
Definition: RunData.h:39
AuxDetGeometryCore const & GetProvider() const
Returns a constant reference to the service provider.
void LoadNewGeometry(std::string gdmlfile, std::string rootfile)
Expands the provided paths and loads the geometry description(s)

Member Data Documentation

bool geo::AuxDetGeometry::fForceUseFCLOnly
private

Force Geometry to only use the geometry files specified in the fcl file

Definition at line 116 of file AuxDetGeometry.h.

AuxDetGeometryCore geo::AuxDetGeometry::fProvider
private

the actual service provider

Definition at line 112 of file AuxDetGeometry.h.

std::string geo::AuxDetGeometry::fRelPath
private

Relative path added to FW_SEARCH_PATH to search for geometry file

Definition at line 114 of file AuxDetGeometry.h.

fhicl::ParameterSet geo::AuxDetGeometry::fSortingParameters
private

Parameter set to define the channel map sorting.

Definition at line 118 of file AuxDetGeometry.h.


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