ATLAS Offline Software
Loading...
Searching...
No Matches
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
14namespace 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
friend std::ostream & operator<<(std::ostream &os, OptionalToolProperty< V > const &obj)
A Range describes the possible ranges for the field values of an ExpandedIdentifier.
unsigned int ZDCSideToSideIndex(int const ZDCSide)
Definition RPDUtils.cxx:7
unsigned int constexpr nRows
Definition RPDUtils.h:24
int constexpr ZDCSumsGlobalZDCSide
Definition RPDUtils.h:19
unsigned int constexpr nChannels
Definition RPDUtils.h:23
unsigned int constexpr ZDCModuleRPDType
Definition RPDUtils.h:21
std::ostream & operator<<(std::ostream &os, const std::vector< T > &v)
Definition RPDUtils.cxx:19
unsigned int constexpr sideC
Definition RPDUtils.h:15
unsigned int constexpr ZDCModuleZDCType
Definition RPDUtils.h:20
unsigned int constexpr sideA
Definition RPDUtils.h:16
unsigned int constexpr nCols
Definition RPDUtils.h:25
std::initializer_list< unsigned int > constexpr sides
Definition RPDUtils.h:17
void helpZero(Range &v)
Definition RPDUtils.h:27
unsigned int constexpr ZDCModuleEMModule
Definition RPDUtils.h:22
std::string vecToString(std::vector< T > const &v)
Definition RPDUtils.cxx:57