All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AsymGaussPulseFunctionTool_tool.cc
Go to the documentation of this file.
1 /**
2  * @file icaruscode/PMT/AsymGaussPulseFunctionTool_tool.cc
3  * @brief Toolization of `icarus::opdet::AsymGaussPulseFunction<nanosecond>`.
4  * @author Gianluca Petrillo (petrillo@slac.stanford.edu)
5  * @date March 17, 2020
6  * @see `icaruscode/PMT/Algorithms/AsymGaussPulseFunction.h`
7  *
8  * This is an implementation of tool interface
9  * `icarus::opdet::SinglePhotonPulseFunctionTool`.
10  */
11 
12 
13 // ICARUS libraries
16 
17 // LArSoft libraries
19 #include "lardataalg/Utilities/quantities_fhicl.h" // nanoseconds from FHiCL
20 
21 // framework libraries
22 #include "art/Utilities/ToolConfigTable.h"
23 #include "art/Utilities/ToolMacros.h"
24 
25 // framework libraries
26 #include "fhiclcpp/types/Atom.h"
27 
28 // C/C++ standard libraries
29 #include <memory> // std::unique_ptr()
30 #include <cassert>
31 
32 
33 //------------------------------------------------------------------------------
34 namespace icarus::opdet { struct AsymGaussPulseFunctionTool; }
35 /**
36  * @brief Creates a `AsymGaussPulseFunction` pulse shape.
37  * @see `icarus::opdet::SinglePhotonPulseFunctionTool`
38  *
39  * This tool creates a `icarus::opdet::AsymGaussPulseFunction<nanosecond>`
40  * function to describe a R5912 PMT pulse.
41  *
42  * See `icarus::opdet::AsymGaussPulseFunction` for the details of the function.
43  *
44  *
45  * Configuration
46  * --------------
47  *
48  * Run `lar --print-description AsymGaussPulseFunctionTool` (or read `Config`
49  * data structure) for a short explanation of the meaning of the parameters.
50  *
51  * In addition, note that the actual amplitude in ADC counts of the pulse is
52  * composed as the product of the amplitude in charge (`MeanAmplitude`) and
53  * the charge-to-ADC conversion factor (`ADC`).
54  *
55  */
58 {
59 
60  /// Configuration parameters.
61  struct Config {
62 
63  using Name = fhicl::Name;
64  using Comment = fhicl::Comment;
65 
66  fhicl::Atom<nanoseconds> TransitTime {
67  Name("TransitTime"),
68  Comment("peak time from the beginning of the waveform [ns]")
69  // mandatory
70  };
71  fhicl::Atom<util::quantities::picocoulomb> MeanAmplitude {
72  Name("MeanAmplitude"),
73  Comment("signal amplitude at peak [pC]")
74  // mandatory
75  };
76  fhicl::Atom<nanoseconds> RaiseTime {
77  Name("RaiseTime"),
78  Comment("rise time (10% to 90%, sigma * ~1.687) [ns]")
79  // mandatory
80  };
81  fhicl::Atom<nanoseconds> FallTime {
82  Name("FallTime"),
83  Comment("fall time (90% to 10%, sigma * ~1.687) [ns]")
84  // mandatory
85  };
86  fhicl::Atom<float> ADC {
87  Name("ADC"),
88  Comment("Charge to ADC conversion factor [ADC counts/pC]")
89  // mandatory
90  };
91 
92  }; // struct Config
93 
94 
95  /// Tool parameter configuration.
96  using Parameters = art::ToolConfigTable<Config>;
97 
98  /// Constructor: sets the configuration.
100  : fPulseFunction(makePulseFunction(config())) {}
101 
102 
103  private:
104 
105  // --- BEGIN -- Virtual interface --------------------------------------------
106 
107  /// Returns the function that was created at construction time.
108  virtual std::unique_ptr<PulseFunction_t> doGetPulseFunction() override
109  { return std::move(fPulseFunction); }
110 
111  // --- END -- Virtual interface ----------------------------------------------
112 
113  /// Function stored while waiting to be delivered.
114  std::unique_ptr<PulseFunction_t> fPulseFunction;
115 
116 
117  /// Creates and returns a pulse function with the specified configuration.
118  static std::unique_ptr<PulseFunction_t> makePulseFunction
119  (Config const& config);
120 
121 
122 }; // icarus::opdet::AsymGaussPulseFunctionTool
123 
124 
125 //------------------------------------------------------------------------------
126 //--- icarus::opdet::AsymGaussPulseFunctionTool implementation
127 //------------------------------------------------------------------------------
129  (Config const& config) -> std::unique_ptr<PulseFunction_t>
130 {
131 
133  using ADCcount = MyFunction_t::ADCcount;
134 
135  auto raiseTimeToRMS = [](auto raiseTime)
136  {
137  return raiseTime / (
138  std::sqrt(2.0)
139  * (std::sqrt(-std::log(0.1)) - std::sqrt(-std::log(0.9)))
140  );
141  };
142 
143  return std::make_unique<MyFunction_t>(
144  // amplitude is a charge, so we have to twist the arm of the constructor to
145  // accept it as ADC count (`value()` makes `meanAmplitude` lose its unit)
146  ADCcount(config.ADC() * config.MeanAmplitude().value()), // amplitude
147  config.TransitTime(), // peakTime
148  raiseTimeToRMS(config.RaiseTime()), // sigmaLeft
149  raiseTimeToRMS(config.FallTime()) // sigmaRight
150  );
151 
152 } // icarus::opdet::AsymGaussPulseFunctionTool::makePulseFunction()
153 
154 
155 //------------------------------------------------------------------------------
156 DEFINE_ART_CLASS_TOOL(icarus::opdet::AsymGaussPulseFunctionTool)
157 
158 
159 //------------------------------------------------------------------------------
160 
std::unique_ptr< PulseFunction_t > fPulseFunction
Function stored while waiting to be delivered.
virtual std::unique_ptr< PulseFunction_t > doGetPulseFunction() override
Returns the function that was created at construction time.
Dimensioned variables representing electromagnetic quantities.
Tool to create a pulse function for PMT single photon response.
Creates a PhotoelectronPulseFunction pulse shape.
art::ToolConfigTable< Config > Parameters
Tool parameter configuration.
Utilities to read and write quantities in FHiCL configuration.
BEGIN_PROLOG vertical distance to the surface Name
Creates a AsymGaussPulseFunction pulse shape.
AsymGaussPulseFunctionTool(Parameters const &config)
Constructor: sets the configuration.
Pulse from one photoelectron as two half Gaussian functions.
fhicl::Atom< util::quantities::picocoulomb > MeanAmplitude
static std::unique_ptr< PulseFunction_t > makePulseFunction(Config const &config)
Creates and returns a pulse function with the specified configuration.
Describes the waveform from a single photoelectron.