ATLAS Offline Software
Loading...
Searching...
No Matches
RpdSubtractCentroidTool.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 ZDCANALYSIS_RPDSUBTRACTCENTROIDTOOL_H
6#define ZDCANALYSIS_RPDSUBTRACTCENTROIDTOOL_H
7
8
12#include "ZdcUtils/RPDUtils.h"
13
14#include "AsgTools/AsgTool.h"
20
21#include <vector>
22#include <array>
23#include <bitset>
24#include <optional>
25
26namespace ZDC {
27
30 public:
31 enum {
32 ValidBit = 0, // analysis and output are valid
33 HasCentroidBit = 1, // centroid was calculated but analysis is invalid
34 ZDCInvalidBit = 2, // ZDC analysis on this side failed => analysis is invalid
35 InsufficientZDCEnergyBit = 3, // ZDC energy on this side is below minimum => analysis is invalid
36 ExcessiveZDCEnergyBit = 4, // ZDC energy on this side is above maximum => analysis is invalid
37 EMInvalidBit = 5, // EM analysis on this side failed => analysis is invalid
38 InsufficientEMEnergyBit = 6, // EM energy on this side is below minimum => analysis is invalid
39 ExcessiveEMEnergyBit = 7, // EM energy on this side is above maximum => analysis is invalid
40 RPDInvalidBit = 8, // RPD analysis on this side was invalid => calculation stopped and analysis is invalid
41 PileupBit = 9, // pileup was detected in RPD on this side
42 ExcessivePileupBit = 10, // pileup was detected in RPD on this side and a channel exceeded the fractional limit => analysis is invalid
43 ZeroSumBit = 11, // sum of subtracted RPD amplitudes on this side was not positive => calculation stopped and analysis is invalid
44 ExcessiveSubtrUnderflowBit = 12, // a subtracted RPD amplitude on this side was negative and exceeded the fractional limit => analysis is invalid
45
46 Row0ValidBit = 13, // row 0 x centroid is valid
47 Row1ValidBit = 14, // row 1 x centroid is valid
48 Row2ValidBit = 15, // row 2 x centroid is valid
49 Row3ValidBit = 16, // row 3 x centroid is valid
50 Col0ValidBit = 17, // column 0 y centroid is valid
51 Col1ValidBit = 18, // column 1 y centroid is valid
52 Col2ValidBit = 19, // column 2 y centroid is valid
53 Col3ValidBit = 20, // column 3 y centroid is valid
54
56 };
57
58 explicit RpdSubtractCentroidTool(const std::string& name);
59 ~RpdSubtractCentroidTool() override = default;
60
61 // this tool should never be copied or moved
66
67 // interface from AsgTool and IZdcAnalysisTool
68 StatusCode initialize() override;
69 StatusCode recoZdcModules(const xAOD::ZdcModuleContainer& moduleContainer, const xAOD::ZdcModuleContainer& moduleSumContainer) override;
70 StatusCode reprocessZdc() override;
71
72 private:
73 // tool properties to be configured in Python
74 std::string m_configuration;
77 bool m_writeAux{};
78 std::string m_auxSuffix;
79 // these are optional and null by default; if their values are set, they will overwrite the bulk configuration from config string
88
89 // these are the final reconstruction parameters
90 std::vector<float> m_minZDCEnergy;
91 std::vector<float> m_maxZDCEnergy;
92 std::vector<float> m_minEMEnergy;
93 std::vector<float> m_maxEMEnergy;
94 std::vector<float> m_pileupMaxFrac;
98
99 StatusCode initializeKey(std::string const& containerName, SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> & writeHandleKey, std::string const& key);
100 static bool nonNegative(float const x) { return x >= 0; }
101 static bool anyNonNegative(std::vector<float> const& v) { return std::any_of(v.begin(), v.end(), nonNegative); }
102
103 // internal properties
104 //
105 bool m_initialized = false;
107
108 // results from RPD analysis needed for centroid calculation (read from AOD)
109 //
111 unsigned int channel;
112 float xposRel{};
113 float yposRel{};
114 unsigned short row{};
115 unsigned short col{};
116 float amp{};
117 float subtrAmp{};
118 float pileupFrac{};
119 unsigned int status{};
120 };
121 std::array<std::bitset<RPDDataAnalyzer::N_STATUS_BITS>, 2> m_RPDSideStatus {};
122 std::optional<std::array<unsigned int, 2>> m_ZDCSideStatus;
123 std::optional<std::array<float, 2>> m_ZDCFinalEnergy;
124 std::optional<std::array<float, 2>> m_EMCalibEnergy;
125 std::optional<std::array<std::bitset<ZDCPulseAnalyzer::N_STATUS_BITS>, 2>> m_EMStatus;
126 std::array<std::array<std::array<RPDChannelData, RPDUtils::nCols>, RPDUtils::nRows>, 2> m_RPDChannelData {};
127
128 // alignment (geometry) and crossing angle correction, to be read from ZdcConditions
129 //
130 std::array<float, 2> m_alignmentXOffset {};
131 std::array<float, 2> m_alignmentYOffset {};
133
134 // average centroids, to be read from monitoring histograms
135 //
136 std::array<float, 2> m_avgXCentroid {};
137 std::array<float, 2> m_avgYCentroid {};
138
139 // centroid calculation results (reset each event)
140 //
141 bool m_eventValid = false;
142 std::array<std::bitset<N_STATUS_BITS>, 2> m_centroidStatus {1 << ValidBit, 1 << ValidBit};
143 std::array<std::vector<float>, 2> m_subtrAmp = {
144 std::vector<float>(RPDUtils::nChannels, 0.0),
145 std::vector<float>(RPDUtils::nChannels, 0.0)
146 };
147 std::array<std::array<float, RPDUtils::nRows>, 2> m_subtrAmpRowSum {};
148 std::array<std::array<float, RPDUtils::nCols>, 2> m_subtrAmpColSum {};
149 std::array<float, 2> m_subtrAmpSum {};
150 std::array<float, 2> m_xCentroidPreGeomCorPreAvgSubtr {};
151 std::array<float, 2> m_yCentroidPreGeomCorPreAvgSubtr {};
152 std::array<float, 2> m_xCentroidPreAvgSubtr {};
153 std::array<float, 2> m_yCentroidPreAvgSubtr {};
154 std::array<float, 2> m_xCentroid {};
155 std::array<float, 2> m_yCentroid {};
156 std::array<std::vector<float>, 2> m_xRowCentroid = {
157 std::vector<float>(RPDUtils::nRows, 0.0),
158 std::vector<float>(RPDUtils::nRows, 0.0)
159 };
160 std::array<std::vector<float>, 2> m_yColCentroid = {
161 std::vector<float>(RPDUtils::nCols, 0.0),
162 std::vector<float>(RPDUtils::nCols, 0.0)
163 };
164 std::array<float, 2> m_reactionPlaneAngle {};
166
167 // methods used for centroid calculation
168 //
169 enum class SubstepStatus {
170 Success, // continue to next step
171 Failure, // stop (do not proceed to next step) and propagate error to Athena
172 SkipEvent, // stop (do not proceed to next step) and tell Athena the event was a success
173 };
174 void reset();
175 SubstepStatus readAOD(xAOD::ZdcModuleContainer const& moduleContainer, xAOD::ZdcModuleContainer const& moduleSumContainer);
176 bool checkZdcRpdValidity(unsigned int side);
177 bool subtractRpdAmplitudes(unsigned int side);
178 void calculateDetectorCentroid(unsigned int side);
179 void geometryCorrection(unsigned int side);
180 void subtractAverageCentroid(unsigned int side);
181 void calculateReactionPlaneAngle(unsigned int side);
182 void writeAOD(xAOD::ZdcModuleContainer const& moduleSumContainer) const;
183
184 // note that we leave the keys of read/write decor handle keys unset here since they will be set
185 // by this tool's initialize(); this is because container names (and suffix) are taken as tool properties
186 // and cannot be used in an in-class initializer (before constructor, where properties are declared)
187
189 this, "EventInfoKey", "EventInfo",
190 "Location of the event info"
191 };
192
194 this, "centroidEventValidKey", "",
195 "Event status: true if both centroids are valid, else false"
196 };
198 this, "centroidStatusKey", "",
199 "Centroid status word"
200 };
202 this, "RPDChannelSubtrAmpKey", "",
203 "RPD channel subtracted amplitudes (tile mass) used in centroid calculation"
204 };
206 this, "RPDSubtrAmpSumKey", "",
207 "Sum of RPD channel subtracted amplitudes (total mass) used in centroid calculation"
208 };
210 this, "xCentroidPreGeomCorPreAvgSubtrKey", "",
211 "X centroid before geometry corrections and before average centroid subtraction (RPD detector coordinates)"
212 };
214 this, "yCentroidPreGeomCorPreAvgSubtrKey", "",
215 "Y centroid before geometry corrections and before average centroid subtraction (RPD detector coordinates)"
216 };
218 this, "xCentroidPreAvgSubtrKey", "",
219 "X centroid after geometry corrections and before average centroid subtraction"
220 };
222 this, "yCentroidPreAvgSubtrKey", "",
223 "Y centroid after geometry corrections and before average centroid subtraction"
224 };
226 this, "xCentroidKey", "",
227 "X centroid after geometry corrections and after average centroid subtraction"
228 };
230 this, "yCentroidKey", "",
231 "Y centroid after geometry corrections and after average centroid subtraction"
232 };
234 this, "xRowCentroidKey", "",
235 "Row X centroids before geometry corrections and before average centroid subtraction (RPD detector coordinates)"
236 };
238 this, "yColCentroidKey", "",
239 "Column Y centroids before geometry corrections and before average centroid subtraction (RPD detector coordinates)"
240 };
242 this, "reactionPlaneAngleKey", "",
243 "Reaction plane angle in [-pi, pi) from the positive x axis"
244 };
246 this, "cosDeltaReactionPlaneAngleKey", "",
247 "Cosine of the difference between the reaction plane angles of the two sides"
248 };
249};
250
251} // namespace ZDC
252
253#endif
#define ASG_TOOL_CLASS(CLASSNAME, INT1)
Property holding a SG store/key/clid/attr name from which a ReadDecorHandle is made.
Property holding a SG store/key/clid from which a ReadHandle is made.
#define x
Property holding a SG store/key/clid from which a ReadHandle is made.
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_centroidStatusKey
StatusCode recoZdcModules(const xAOD::ZdcModuleContainer &moduleContainer, const xAOD::ZdcModuleContainer &moduleSumContainer) override
std::array< float, 2 > m_reactionPlaneAngle
the y centroid for each column on each side
std::array< float, 2 > m_xCentroidPreAvgSubtr
y centroid before geomerty correction and before average subtraction (RPD detector coordinates) on ea...
std::array< float, 2 > m_avgYCentroid
average x centroid
RPDUtils::OptionalToolProperty< std::vector< float > > m_forceMinZDCEnergy
bool subtractRpdAmplitudes(unsigned int side)
void geometryCorrection(unsigned int side)
std::optional< std::array< float, 2 > > m_EMCalibEnergy
ZDC final (calibrated) energy on each side.
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
std::array< std::array< std::array< RPDChannelData, RPDUtils::nCols >, RPDUtils::nRows >, 2 > m_RPDChannelData
EM modlue status word on each side.
SubstepStatus
cosine of difference between reaction plane angles of the two sides
RPDUtils::OptionalToolProperty< std::vector< float > > m_forceMaximumNegativeSubtrAmpFrac
SubstepStatus readAOD(xAOD::ZdcModuleContainer const &moduleContainer, xAOD::ZdcModuleContainer const &moduleSumContainer)
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_xCentroidPreGeomCorPreAvgSubtrKey
std::array< float, 2 > m_xCentroid
y centroid after geomerty correction and before average subtraction on each side
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_yCentroidPreGeomCorPreAvgSubtrKey
void writeAOD(xAOD::ZdcModuleContainer const &moduleSumContainer) const
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_RPDChannelSubtrAmpKey
std::array< std::array< float, RPDUtils::nRows >, 2 > m_subtrAmpRowSum
subtracted amplitude for each channel on each side
RpdSubtractCentroidTool(RpdSubtractCentroidTool &&)=delete
RPDUtils::OptionalToolProperty< bool > m_forceUseCalibDecorations
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_xRowCentroidKey
RPDUtils::OptionalToolProperty< std::vector< float > > m_forcePileupMaxFrac
std::optional< std::array< unsigned int, 2 > > m_ZDCSideStatus
RPD analysis status word on each side.
std::array< std::vector< float >, 2 > m_subtrAmp
centroid status (valid by default) on each side
std::array< std::vector< float >, 2 > m_yColCentroid
the x centroid for each row on each side
StatusCode initializeKey(std::string const &containerName, SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > &writeHandleKey, std::string const &key)
RpdSubtractCentroidTool(RpdSubtractCentroidTool const &)=delete
std::vector< float > m_maximumNegativeSubtrAmpFrac
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_yColCentroidKey
void subtractAverageCentroid(unsigned int side)
RpdSubtractCentroidTool & operator=(RpdSubtractCentroidTool const &)=delete
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_cosDeltaReactionPlaneAngleKey
RPDUtils::OptionalToolProperty< bool > m_forceUseRPDSumAdc
static bool nonNegative(float const x)
void calculateDetectorCentroid(unsigned int side)
std::array< float, 2 > m_xCentroidPreGeomCorPreAvgSubtr
subtracted amplitude sum on each side
std::array< float, 2 > m_yCentroidPreGeomCorPreAvgSubtr
x centroid before geomerty correction and before average subtraction (RPD detector coordinates) on ea...
RpdSubtractCentroidTool & operator=(RpdSubtractCentroidTool &&)=delete
std::array< std::array< float, RPDUtils::nCols >, 2 > m_subtrAmpColSum
subtracted amplitude for each row on each side
std::optional< std::array< std::bitset< ZDCPulseAnalyzer::N_STATUS_BITS >, 2 > > m_EMStatus
EM calibrated energy on each side.
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_centroidEventValidKey
~RpdSubtractCentroidTool() override=default
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_yCentroidPreAvgSubtrKey
std::array< float, 2 > m_alignmentYOffset
geometry + crossing angle correction in x (ATLAS coordinates)
static bool anyNonNegative(std::vector< float > const &v)
RPDUtils::OptionalToolProperty< std::vector< float > > m_forceMinEMEnergy
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_reactionPlaneAngleKey
RpdSubtractCentroidTool(const std::string &name)
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_RPDSubtrAmpSumKey
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_xCentroidKey
std::optional< std::array< float, 2 > > m_ZDCFinalEnergy
ZDC analysis status on each side.
void calculateReactionPlaneAngle(unsigned int side)
std::array< float, 2 > m_yCentroidPreAvgSubtr
x centroid after geomerty correction and before average subtraction on each side
std::array< float, 2 > m_subtrAmpSum
subtracted amplitude for each column on each side
StatusCode initialize() override
Dummy implementation of the initialisation function.
RPDUtils::OptionalToolProperty< std::vector< float > > m_forceMaxZDCEnergy
std::array< float, 2 > m_alignmentXOffset
RPD channel data for each channel (first index row, then index column) on each side.
std::array< std::bitset< N_STATUS_BITS >, 2 > m_centroidStatus
event status
float m_cosDeltaReactionPlaneAngle
reaction plane angle on each side
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_xCentroidPreAvgSubtrKey
std::array< float, 2 > m_yCentroid
x centroid after geomerty correction and after average subtraction on each side
RPDUtils::OptionalToolProperty< std::vector< float > > m_forceMaxEMEnergy
std::array< std::vector< float >, 2 > m_xRowCentroid
y centroid after geomerty correction and after average subtraction on each side
std::array< std::bitset< RPDDataAnalyzer::N_STATUS_BITS >, 2 > m_RPDSideStatus
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_yCentroidKey
std::array< float, 2 > m_avgXCentroid
geometry + crossing angle correction in y (ATLAS coordinates)
bool checkZdcRpdValidity(unsigned int side)
Base class for the dual-use tool implementation classes.
Definition AsgTool.h:47
unsigned int constexpr nRows
Definition RPDUtils.h:24
unsigned int constexpr nChannels
Definition RPDUtils.h:23
unsigned int constexpr nCols
Definition RPDUtils.h:25
ZdcModuleContainer_v1 ZdcModuleContainer