All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SinglePhotonPulseFunctionTool.h
Go to the documentation of this file.
1 /**
2  * @file icaruscode/PMT/SinglePhotonPulseFunctionTool.h
3  * @brief Tool to create a pulse function for PMT single photon response.
4  * @author Gianluca Petrillo (petrillo@slac.stanford.edu)
5  * @date March 17, 2020
6  * @see `icaruscode/PMT/Algorithms/PhotoelectronPulseFunction.h`
7  *
8  * This is a header-only library.
9  */
10 
11 #ifndef ICARUSCODE_PMT_SINGLEPHOTONPULSEFUNCTIONTOOL_H
12 #define ICARUSCODE_PMT_SINGLEPHOTONPULSEFUNCTIONTOOL_H
13 
14 
15 // ICARUS libraries
17 
18 // LArSoft libraries
19 #include "lardataalg/Utilities/quantities/spacetime.h" // nanosecond
20 
21 // C/C++ standard libraries
22 #include <memory> // std::unique_ptr()
23 #include <utility> // std::move()
24 #include <cassert>
25 
26 
27 //------------------------------------------------------------------------------
28 namespace icarus::opdet { struct SinglePhotonPulseFunctionTool; }
29 /**
30  * @brief Creates a `PhotoelectronPulseFunction` pulse shape.
31  *
32  * Implementations of this tool create a function representing the single photon
33  * response of a PMT, as an object derived from
34  * `icarus::opdet::PhotoelectronPulseFunction<nanosecond>`.
35  *
36  * The envisioned usage of this tool is from a temporary, one-time-only call:
37  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
38  * using util::quantities::nanosecond;
39  * std::unique_ptr<icarus::opdet::PhotoelectronPulseFunction<nanosecond>> pulse
40  * = art::make_tool<icarus::opdet::SinglePhotonPulseFunctionTool>(config)
41  * ->getPulseFunction()
42  * ;
43  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
44  * where `pset` is the FHiCL parameter set configuration for the tool
45  * (the type of `pulse` can be safely declared `auto`).
46  * The tool object itself is useless after the first use, and should be
47  * disposed of.
48  *
49  * The configuration of the tool is implementation-dependent.
50  *
51  */
53 
54  /// Convenience definition for time stored in nanoseconds.
56 
57  /// Type of function returned.
58  using PulseFunction_t
60 
61 
62  virtual ~SinglePhotonPulseFunctionTool() = default;
63 
64  /**
65  * @brief Returns an instance of the pulse function.
66  *
67  * This function is guaranteed to return a valid pulse function only once.
68  * The return value on following calls is undefined, but it is considered
69  * an error to return a null pointer.
70  *
71  * See the description of the class for an usage example.
72  */
73  std::unique_ptr<PulseFunction_t> getPulseFunction();
74 
75 
76  private:
77 
78  // --- BEGIN -- Virtual interface --------------------------------------------
79 
80  /**
81  * @brief Returns an instance of the pulse function.
82  *
83  * Only the first call is guaranteed to return a non-null pointer.
84  *
85  */
86  virtual std::unique_ptr<PulseFunction_t> doGetPulseFunction() = 0;
87 
88 
89  // --- END -- Virtual interface ----------------------------------------------
90 
91 
92 }; // icarus::opdet::SinglePhotonPulseFunctionTool
93 
94 
95 //------------------------------------------------------------------------------
96 //--- icarus::opdet::SinglePhotonPulseFunctionTool implementation
97 //------------------------------------------------------------------------------
99  -> std::unique_ptr<PulseFunction_t>
100 {
101  auto ptr = doGetPulseFunction();
102  assert(ptr);
103  return ptr;
104 } // icarus::opdet::SinglePhotonPulseFunctionTool::getPulseFunction() &&
105 
106 
107 //------------------------------------------------------------------------------
108 
109 
110 #endif // ICARUSCODE_PMT_SINGLEPHOTONPULSEFUNCTIONTOOL_H
virtual std::unique_ptr< PulseFunction_t > doGetPulseFunction()=0
Returns an instance of the pulse function.
Abstract interface of shape of a pulse from one photoelectron.
std::unique_ptr< PulseFunction_t > getPulseFunction()
Returns an instance of the pulse function.
Creates a PhotoelectronPulseFunction pulse shape.
A value measured in the specified unit.
Definition: quantities.h:566
Interface for a function describing a pulse from a photoelectron.
Dimensioned variables representing space or time quantities.
nanosecond_as<> nanosecond
Type of time stored in nanoseconds, in double precision.
Definition: spacetime.h:136