ATLAS Offline Software
RPDUtils.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef ZDCUTILS_RPDUTILS_H
6 #define ZDCUTILS_RPDUTILS_H
7 
8 #include <initializer_list>
9 #include <ranges>
10 #include <iostream>
11 #include <sstream>
12 #include <vector>
13 
14 namespace RPDUtils {
15  unsigned int constexpr sideC = 0;
16  unsigned int constexpr sideA = 1;
17  std::initializer_list<unsigned int> constexpr sides {sideC, sideA};
18  unsigned int ZDCSideToSideIndex(int);
19  int constexpr ZDCSumsGlobalZDCSide = 0;
20  unsigned int constexpr ZDCModuleZDCType = 0;
21  unsigned int constexpr ZDCModuleRPDType = 1;
22  unsigned int constexpr ZDCModuleEMModule = 0;
23  unsigned int constexpr nChannels = 16;
24  unsigned int constexpr nRows = 4;
25  unsigned int constexpr nCols = 4;
26  template <std::ranges::contiguous_range Range, typename T = std::ranges::range_value_t<Range>>
27  void helpZero(Range & v) requires (std::is_arithmetic_v<T>) {
28  std::fill(v.begin(), v.end(), 0);
29  };
30  template <std::ranges::contiguous_range OuterRange, typename InnerRange = std::ranges::range_value_t<OuterRange>, typename T = std::ranges::range_value_t<InnerRange>>
31  void helpZero(OuterRange & vv) requires (std::ranges::contiguous_range<InnerRange> && std::is_arithmetic_v<T>) {
32  for (auto & v : vv) {
33  helpZero(v);
34  }
35  };
36  // implement printing of vector, required for gaudi property of type OptionalToolProperty<std::vector<T>>
37  template<typename T>
38  std::ostream & operator <<(std::ostream & os, const std::vector<T> & v);
39  // the configuration string for RPD and centroid tools handles bulk setting of default reconstruction parameters
40  // then, we would like the option to override each parameter in python configuration
41  // therefore, we provide an std::optional-like implementation which
42  // has the necessary interface to be a gaudi property
43  template <class T>
45  public:
47  explicit OptionalToolProperty(T value);
48  bool has_value() const;
49  T const& value() const;
50  // enable printing; required for a gaudi property
51  template <class V> friend std::ostream & operator<<(std::ostream &os, OptionalToolProperty<V> const& obj);
52  // conversion to inner type for compatibility with gaudi parsers (reference to allow filling value);
53  // this enables Python configuration (ZdcRecConfig.py) to set the corresponding tool property
54  operator T&();
55  private:
56  T m_value {};
57  bool m_hasValue = false;
58  };
59  // for debug printouts in RPD reconstruction
60  template <typename T>
61  std::string vecToString(std::vector<T> const& v);
62 } // namespace RPDUtils
63 
64 #endif
RPDUtils::vecToString
std::string vecToString(std::vector< T > const &v)
Definition: RPDUtils.cxx:57
RPDUtils::nChannels
unsigned constexpr int nChannels
Definition: RPDUtils.h:23
RPDUtils::OptionalToolProperty::m_value
T m_value
Definition: RPDUtils.h:56
RPDUtils::sides
constexpr std::initializer_list< unsigned int > sides
Definition: RPDUtils.h:17
RPDUtils::ZDCSumsGlobalZDCSide
constexpr int ZDCSumsGlobalZDCSide
Definition: RPDUtils.h:19
RPDUtils
Definition: RPDUtils.cxx:6
RPDUtils::OptionalToolProperty
Definition: RPDUtils.h:44
RPDUtils::OptionalToolProperty::m_hasValue
bool m_hasValue
Definition: RPDUtils.h:57
RPDUtils::OptionalToolProperty::has_value
bool has_value() const
Definition: RPDUtils.cxx:28
RPDUtils::OptionalToolProperty::OptionalToolProperty
OptionalToolProperty()
RPDUtils::OptionalToolProperty::value
T const & value() const
Definition: RPDUtils.cxx:31
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
RPDUtils::sideA
unsigned constexpr int sideA
Definition: RPDUtils.h:16
fill
void fill(H5::Group &out_file, size_t iterations)
Definition: test-hdf5-writer.cxx:95
RPDUtils::nCols
unsigned constexpr int nCols
Definition: RPDUtils.h:25
RPDUtils::OptionalToolProperty::operator<<
friend std::ostream & operator<<(std::ostream &os, OptionalToolProperty< V > const &obj)
RPDUtils::ZDCModuleZDCType
unsigned constexpr int ZDCModuleZDCType
Definition: RPDUtils.h:20
RPDUtils::ZDCModuleEMModule
unsigned constexpr int ZDCModuleEMModule
Definition: RPDUtils.h:22
Range
A Range describes the possible ranges for the field values of an ExpandedIdentifier.
Definition: DetectorDescription/Identifier/Identifier/Range.h:29
python.PyAthena.v
v
Definition: PyAthena.py:154
RPDUtils::operator<<
std::ostream & operator<<(std::ostream &os, const std::vector< T > &v)
Definition: RPDUtils.cxx:19
RPDUtils::sideC
unsigned constexpr int sideC
Definition: RPDUtils.h:15
RPDUtils::nRows
unsigned constexpr int nRows
Definition: RPDUtils.h:24
RPDUtils::ZDCSideToSideIndex
unsigned int ZDCSideToSideIndex(int const ZDCSide)
Definition: RPDUtils.cxx:7
python.PyAthena.obj
obj
Definition: PyAthena.py:132
PlotCalibFromCool.vv
vv
Definition: PlotCalibFromCool.py:716
RPDUtils::helpZero
void helpZero(Range &v) requires(std
Definition: RPDUtils.h:27
RPDUtils::ZDCModuleRPDType
unsigned constexpr int ZDCModuleRPDType
Definition: RPDUtils.h:21