All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
icarusalg/icarusalg/Utilities/DetectorClocksHelpers.h
Go to the documentation of this file.
1 /**
2  * @file icarusalg/Utilities/DetectorClocksHelpers.h
3  * @brief Simple functions to streamline the creation of `DetectorClocksData`.
4  * @author Gianluca Petrillo (petrillo@slac.stanford.edu)
5  * @date September 16, 2020
6  */
7 
8 #ifndef ICARUSALG_UTILITIES_DETECTORCLOCKSHELPERS_H
9 #define ICARUSALG_UTILITIES_DETECTORCLOCKSHELPERS_H
10 
11 // LArSoft libraries
15 
16 // framework libraries
17 #include "art/Framework/Services/Registry/ServiceHandle.h"
18 
19 
20 // -----------------------------------------------------------------------------
21 // forward declarations
22 namespace art { class Event; }
23 
24 // -----------------------------------------------------------------------------
25 namespace icarus::ns::util {
26 
27  // --- BEGIN -- DetectorClocksData helpers -----------------------------------
28  /// @name DetectorClocksData helpers
29  /// @{
30  /**
31  * @brief Returns a `detinfo::DetectorClocksData` from
32  * `DetectorClocksService`.
33  * @param event pointer to an _art_ event
34  * @return a `detinfo::DetectorClocksData` object (see the details below)
35  *
36  * The `detinfo::DetectorClocksService` is queried to obtain a
37  * `detinfo::DetectorClocksData` object. The returned object is a static copy
38  * whose values will never update, even if the `DetectorClocksService` state
39  * changes.
40  *
41  * If the `event` pointer is valid (i.e. not `nullptr`), the event is passed
42  * to the service `DataFor()` method for a complete timing record.
43  * Otherwise, `DataForJob()` is used, and the information might be incomplete
44  * or become outdated by the time a new event, run or file is accessed.
45  *
46  * @note This function is _art_ dependent and accesses `DetectorClocksService`
47  * service.
48  */
50  {
51  auto const& detClocks
52  = *(art::ServiceHandle<detinfo::DetectorClocksService const>());
53  return event? detClocks.DataFor(*event): detClocks.DataForJob();
54  } // makeDetClockData()
55 
56  /// Returns detector clock data for the specified event.
57  /// @see `makeDetClockData(art::Event const*)`
59  { return makeDetClockData(&event); }
60 
61  /// Returns generic detector clock data for the job.
62  /// @see `makeDetClockData(art::Event const*)`
64  { return makeDetClockData(nullptr); }
65 
66  /// @}
67  // --- END -- DetectorClocksData helpers -------------------------------------
68 
69 
70  // --- BEGIN -- DetectorTimings helpers --------------------------------------
71  /// @name DetectorTimings helpers
72  /// @{
73 
74  /**
75  * @brief Returns a `detinfo::DetectorTimings` from `DetectorClocksService`.
76  * @param event pointer to an _art_ event
77  * @return a `detinfo::DetectorTimings` object (see the details below)
78  * @see `makeDetClockData(art::Event const*)`
79  *
80  * A `detinfo::DetectorTimings` object is created out of information obtained
81  * from `detinfo::DetectorClocksService`.
82  *
83  * All the considerations described in `makeDetClockData(art::Event const*)`
84  * also hold for this function.
85  */
86  detinfo::DetectorTimings makeDetTimings(art::Event const* event)
87  { return detinfo::DetectorTimings{ makeDetClockData(event) }; }
88 
89  /// Returns detector clock data for the specified event.
90  /// @see `makeDetTimings(art::Event const*)`
91  detinfo::DetectorTimings makeDetTimings(art::Event const& event)
92  { return makeDetTimings(&event); }
93 
94  /// Returns generic detector clock data for the job.
95  /// @see `makeDetTimings(art::Event const*)`
97  { return makeDetTimings(nullptr); }
98 
99 
100  /// @}
101  // --- END -- DetectorTimings helpers ----------------------------------------
102 
103 
104 } // namespace icarus::ns::util
105 
106 
107 #endif // ICARUSALG_UTILITIES_DETECTORCLOCKSHELPERS_H
Interface to detinfo::DetectorClocks.
Contains all timing reference information for the detector.
A class exposing an upgraded interface of detinfo::DetectorClocksData.
detinfo::DetectorClocksData makeDetClockData(art::Event const *event)
Returns a detinfo::DetectorClocksData from DetectorClocksService.
detinfo::DetectorTimings makeDetTimings(art::Event const *event)
Returns a detinfo::DetectorTimings from DetectorClocksService.