ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
ForwardDetectors
ZDC
ZdcUtils
ZdcUtils
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>
44
class
OptionalToolProperty
{
45
public
:
46
OptionalToolProperty
();
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::OptionalToolProperty::has_value
bool has_value() const
Definition
RPDUtils.cxx:28
RPDUtils::OptionalToolProperty::m_hasValue
bool m_hasValue
Definition
RPDUtils.h:57
RPDUtils::OptionalToolProperty::m_value
T m_value
Definition
RPDUtils.h:56
RPDUtils::OptionalToolProperty::OptionalToolProperty
OptionalToolProperty()
RPDUtils::OptionalToolProperty::value
T const & value() const
Definition
RPDUtils.cxx:31
RPDUtils::OptionalToolProperty::operator<<
friend std::ostream & operator<<(std::ostream &os, OptionalToolProperty< V > const &obj)
Range
A Range describes the possible ranges for the field values of an ExpandedIdentifier.
Definition
DetectorDescription/Identifier/Identifier/Range.h:31
RPDUtils
Definition
RPDUtils.cxx:6
RPDUtils::ZDCSideToSideIndex
unsigned int ZDCSideToSideIndex(int const ZDCSide)
Definition
RPDUtils.cxx:7
RPDUtils::nRows
unsigned int constexpr nRows
Definition
RPDUtils.h:24
RPDUtils::ZDCSumsGlobalZDCSide
int constexpr ZDCSumsGlobalZDCSide
Definition
RPDUtils.h:19
RPDUtils::nChannels
unsigned int constexpr nChannels
Definition
RPDUtils.h:23
RPDUtils::ZDCModuleRPDType
unsigned int constexpr ZDCModuleRPDType
Definition
RPDUtils.h:21
RPDUtils::operator<<
std::ostream & operator<<(std::ostream &os, const std::vector< T > &v)
Definition
RPDUtils.cxx:19
RPDUtils::sideC
unsigned int constexpr sideC
Definition
RPDUtils.h:15
RPDUtils::ZDCModuleZDCType
unsigned int constexpr ZDCModuleZDCType
Definition
RPDUtils.h:20
RPDUtils::sideA
unsigned int constexpr sideA
Definition
RPDUtils.h:16
RPDUtils::nCols
unsigned int constexpr nCols
Definition
RPDUtils.h:25
RPDUtils::sides
std::initializer_list< unsigned int > constexpr sides
Definition
RPDUtils.h:17
RPDUtils::helpZero
void helpZero(Range &v)
Definition
RPDUtils.h:27
RPDUtils::ZDCModuleEMModule
unsigned int constexpr ZDCModuleEMModule
Definition
RPDUtils.h:22
RPDUtils::vecToString
std::string vecToString(std::vector< T > const &v)
Definition
RPDUtils.cxx:57
Generated on
for ATLAS Offline Software by
1.17.0