StandaloneGeometrySetup.h
Go to the documentation of this file.
1 /**
2  * @file larcorealg/Geometry/StandaloneGeometrySetup.h
3  * @brief Utilities for one-line geometry initialization.
4  * @author Gianluca Petrillo (petrillo@fnal.gov)
5  * @date June 22, 2017
6  * @ingroup Geometry
7  *
8  * The main entry point for initializing the geometry is `SetupGeometry()`.
9  *
10  */
11 
12 
13 #ifndef LARCOREALG_GEOMETRY_STANDALONEGEOMETRYSETUP_H
14 #define LARCOREALG_GEOMETRY_STANDALONEGEOMETRYSETUP_H
15 
16 // LArSoft libraries
19 
20 // art-provided libraries
21 #include "fhiclcpp/ParameterSet.h"
22 
23 // C/C++ standard libraries
24 #include <string>
25 #include <set>
26 #include <memory> // std::make_unique()
27 
28 namespace lar::standalone {
29 
30  // --- BEGIN Geometry group ------------------------------------------------
31  /// @ingroup Geometry
32  /// @{
33 
34  //--------------------------------------------------------------------------
35  /**
36  * @brief Initializes a LArSoft geometry object.
37  * @param pset parameters for geometry configuration
38  * @param channelMap channel mapping object to be used, already constructed
39  * @return the geometry object, fully initialized
40  * @see SetupGeometry()
41  *
42  * This function creates, sets up and returns a geometry object using the
43  * specified channel mapping.
44  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
45  * // create a channel mapping algorithm
46  * std::make_unique<geo::StandardChannelMapAlg> channelMap
47  * (pset.get<fhicl::ParameterSet>("SortingParameters"));
48  *
49  * std::unique_ptr<geo::GeometryCore> geom
50  * = SetupGeometryWithChannelMapping(pset, channelMap);
51  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
52  * If no set up is required for channel mapping after construction, the use
53  * of `SetupGeometry()` is preferred over this function.
54  *
55  *
56  * Configuration parameters
57  * =========================
58  *
59  * It is expected that a standard `geo::Geometry` service configuration will
60  * correctly set up the geometry.
61  *
62  * In addition to the parameters documented in `geo::GeometryCore`, the
63  * following parameters are supported:
64  *
65  * - *RelativePath* (string, default: no path): this path is prepended to
66  * the geometry file names before searching from them; the path string
67  * does not affect the file name
68  * - *GDML* (string, mandatory): path of the GDML file to be served to
69  * GEANT4 * for detector simulation. The full file is composed out of
70  * the optional relative path specified by `RelativePath` path and the
71  * base name specified in `GDML` parameter; this path is searched for in
72  * the directories configured in the `FW_SEARCH_PATH` environment
73  * variable;
74  * - *ROOT* (string, mandatory): currently overridden by `GDML` parameter,
75  * whose value is used instead;
76  * this path is assembled in the same way as the one for `GDML` parameter,
77  * except that no alternative (wireless) geometry is used even if
78  * `DisableWiresInG4` is specified (see below); this file is used to load
79  * the geometry used in the internal simulation and reconstruction,
80  * basically everywhere except for the GEANT4 simulation
81  * - *DisableWiresInG4* (boolean, default: false): if true, GEANT4 is loaded
82  * with an alternative geometry from a file with the standard name as
83  * configured with the /GDML/ parameter, but with an additional `_nowires`
84  * appended before the `.gdml` suffix
85  * - *SortingParameters* (a parameter set; default: empty): this
86  * configuration is directly passed to the channel mapping algorithm (see
87  * `geo::ChannelMapAlg`); its content is dependent on the chosen
88  * implementation of `geo::ChannelMapAlg`
89  */
90  std::unique_ptr<geo::GeometryCore>
92  std::unique_ptr<geo::ChannelMapAlg> channelMap);
93 
94  //--------------------------------------------------------------------------
95  /**
96  * @brief Initializes a LArSoft geometry object.
97  * @tparam ChannelMapClass type of `geo::ChannelMapAlg` to be used
98  * @tparam Args (optional) arguments for the construction of channel mapping
99  * @param pset complete set of parameters for geometry configuration
100  * @param args arguments to the channel mapping object constructor
101  * @return the geometry object, fully initialized
102  *
103  * This function creates, sets up and returns a geometry object using the
104  * specified channel mapping.
105  * This is a simplified version of `SetupGeometryWithChannelMapping()`,
106  * that can be used if no special treatment is needed for the channel
107  * mapping after construction and before it is made to interact with the
108  * geometry.
109  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
110  * // read FHiCL configuration from a configuration file:
111  * fhicl::ParameterSet pset;
112  * cet::filepath_lookup_after1 policy("FHICL_FILE_PATH");
113  * pset = fhicl::_ParameterSet::make(configPath, policy);
114  *
115  * // set up message facility
116  * mf::StartMessageFacility
117  * (pset.get<fhicl::ParameterSet>("services.message"));
118  *
119  * // geometry setup
120  * std::unique_ptr<geo::GeometryCore> geom
121  * = SetupGeometry<geo::StandardChannelMapAlg>(pset);
122  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
123  * Note that this function constructs the channel mapping object using a
124  * constructor with arguments a parameter set and in addition, optionally,
125  * any other argument specified in `args`.
126  *
127  */
128  template <typename ChannelMapClass, typename... Args>
129  std::unique_ptr<geo::GeometryCore>
130  SetupGeometry(fhicl::ParameterSet const& pset, Args&&... args);
131 
132  //--------------------------------------------------------------------------
133 
134  // --- END Geometry group --------------------------------------------------
135  /// @}
136 
137 } // namespace lar::standalone
138 
139 
140 //------------------------------------------------------------------------------
141 //--- template implementation
142 //---
143 template <typename ChannelMapClass, typename... Args>
144 std::unique_ptr<geo::GeometryCore>
146 {
147  auto const SortingParameters = pset.get<fhicl::ParameterSet>("SortingParameters", {});
148  auto channelMap = std::make_unique<ChannelMapClass>(SortingParameters,
149  std::forward<Args>(args)...);
150  return SetupGeometryWithChannelMapping(pset, move(channelMap));
151 } // lar::standalone::SetupGeometry()
152 
153 //------------------------------------------------------------------------------
154 
155 #endif // LARCOREALG_GEOMETRY_STANDALONEGEOMETRYSETUP_H
static QCString args
Definition: declinfo.cpp:674
def move(depos, offset)
Definition: depos.py:107
T get(std::string const &key) const
Definition: ParameterSet.h:271
Utilities for use in an environment without art.
std::unique_ptr< geo::GeometryCore > SetupGeometryWithChannelMapping(fhicl::ParameterSet const &pset, std::unique_ptr< geo::ChannelMapAlg > channelMap)
Initializes a LArSoft geometry object.
std::unique_ptr< geo::GeometryCore > SetupGeometry(fhicl::ParameterSet const &pset, Args &&...args)
Initializes a LArSoft geometry object.
Access the description of detector geometry.
Interface to algorithm class for a specific detector channel mapping.