ATLAS Offline Software
Loading...
Searching...
No Matches
CaloRings_v1.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5// standard library includes:
6#include <iostream>
7#include <stdexcept>
8#include <sstream>
9
10// EDM include(s):
12
13// Local include(s):
16
17namespace xAOD {
18
20 accRingSetLinks( "ringSetLinks" );
22 constAccRingSetLinks( "ringSetLinks" );
23
26//==============================================================================
29 ringSetLinks,
30 setRingSetLinks)
31
32//==============================================================================
33unsigned CaloRings_v1::nRingSets() const
34{
35 return (constAccRingSetLinks.isAvailable( *this ) )?
36 (constAccRingSetLinks( *this ).size()):
37 (0);
38}
39
40
41//==============================================================================
43{
44 accRingSetLinks( *this ).push_back(rsEL);
45}
46//==============================================================================
48{
49 accRingSetLinks( *this ).clear();
50}
51
52//==============================================================================
53RingSetLinks::iterator CaloRings_v1::begin()
54{
55 return (accRingSetLinks.isAvailable( *this ) )?
56 (accRingSetLinks( *this ).begin()):
57 (RingSetLinks::iterator());
58}
59
60//==============================================================================
61RingSetLinks::iterator CaloRings_v1::end()
62{
63 return (accRingSetLinks.isAvailable( *this ) )?
64 (accRingSetLinks( *this ).end()):
65 (RingSetLinks::iterator());
66}
67
68//==============================================================================
69RingSetLinks::const_iterator CaloRings_v1::begin() const
70{
71 return (constAccRingSetLinks.isAvailable( *this ) )?
72 (constAccRingSetLinks( *this ).begin()):
73 (RingSetLinks::const_iterator());
74}
75
76//==============================================================================
77RingSetLinks::const_iterator CaloRings_v1::end() const
78{
79 return (constAccRingSetLinks.isAvailable( *this ) )?
80 (constAccRingSetLinks( *this ).end()):
81 (RingSetLinks::const_iterator());
82}
83
84//==============================================================================
85const RingSet *CaloRings_v1::at(const unsigned int i) const
86{
87 if ( i > nRingSets() )
88 return nullptr;
90 constAccRingSetLinks( *this ).at(i);
91 if ( !rsEL.isValid() ) {
92 return nullptr;
93 }
94 return *rsEL;
95}
96
97//==============================================================================
98const RingSet *CaloRings_v1::operator[](const unsigned int i) const
99{
100 if ( i > nRingSets() )
101 return nullptr;
103 constAccRingSetLinks( *this )[i];
104 if ( !rsEL.isValid() ) {
105 return nullptr;
106 }
107 return *rsEL;
108}
109
110
113//==============================================================================
114float CaloRings_v1::ringAt(const unsigned rsIdx, const unsigned ringIdx) const
115{
116 const RingSet *rs = this->at(rsIdx);
117 if (!rs) {
118 throw std::runtime_error("The element link is invalid.");
119 }
120 return rs->at(ringIdx);
121}
122
123//==============================================================================
124float CaloRings_v1::ringAt(const unsigned ringIdx) const
125{
126 unsigned ringStripPartialSize = 0;
127 for (unsigned rsELIdx = 0; rsELIdx < this->nRingSets(); ++rsELIdx){
128 const RingSet *rs = this->at(rsELIdx);
129 if ( !rs ) {
130 throw std::runtime_error("There is an invalid element link.");
131 }
132 unsigned cRsSize = rs->size();
133 if ( ringStripPartialSize + cRsSize > ringIdx ) {
134 // Found the RingSet that contains the nth ring, return it using the
135 // amount that lacks from the previous RingSet to give the nth Ring:
136 return rs->at( ringIdx - ( ringStripPartialSize ) );
137 }
138 ringStripPartialSize += cRsSize;
139 }
140 // If we reached here, then the requested size is greater than the total ring
141 // strip
142 std::stringstream ss;
143 ss << "Requested ring at index: \""
144 << ringIdx << "\", but total rings size is: "
145 << ringStripPartialSize;
146 throw std::overflow_error( ss.str() );
147}
149
152//==============================================================================
154 std::vector<float> &ringStrip,
155 const unsigned rsIdxStart,
156 const unsigned rsIdxEnd) const
157{
158
159 // Check if arguments are within range:
162
163 // Prepare RingStrip vector to receive ring strip information:
164 ringStrip.clear();
165
166 for ( unsigned idx = rsIdxStart; idx <= rsIdxEnd ; ++idx ) {
167 const RingSet *rs = this->at( idx );
168 if ( !rs ) {
169 throw std::runtime_error("Found invalid ElementLink");
170 }
171 rs->copyTo(ringStrip);
172 }
173}
174
175//==============================================================================
177 std::vector<float> &ringStrip,
178 const RingSetConf_v1::RawConfCollection &clRingsRawConfCol,
179 const Ringer::CalJointLayer layerTypeStart,
180 const Ringer::CalJointLayer layerTypeEnd) const
181{
182
183 if ( layerTypeEnd < layerTypeStart ) {
184 throw std::invalid_argument( std::string(
185 "Input layerTypeStart greater than layerTypeEnd") );
186 }
187
188 unsigned nRingSets = this->nRingSets();
189
190 if ( nRingSets && clRingsRawConfCol.size() != nRingSets ) {
191 throw std::invalid_argument( std::string(
192 "The configuration struct seems not to be valid."));
193 }
194
195 // Prepare RingStrip vector to receive Rings energy vectorized representation
196 ringStrip.clear();
197
198 bool foundStartLayer = false;
199
200 for ( unsigned rsIdx = 0; rsIdx < nRingSets; ++rsIdx ) {
201 const RingSet* rs = this->at(rsIdx);
202 if ( !rs ) {
203 throw std::runtime_error( std::string(
204 "Found invalid ElementLink") );
205 }
206 if ( !foundStartLayer ) {
207 // Check if we found start layer:
208 if ( clRingsRawConfCol[rsIdx].calJointLayer == layerTypeStart )
209 {
210 foundStartLayer = true;
211 rs->copyTo(ringStrip);
212 }
213 } else {
214 rs->copyTo(ringStrip);
215 }
216 // Check if we are at the last requested layer:
217 if ( clRingsRawConfCol[rsIdx].calJointLayer == layerTypeEnd ) {
218 break;
219 }
220 }
221}
222
223//==============================================================================
225 std::vector<float> &ringStrip,
226 const RingSetConf_v1::RawConfCollection &clRingsRawConfCol,
227 const Ringer::CalJointSection sectionType) const
228{
229
230 unsigned nRingSets = this->nRingSets();
231
232 if ( nRingSets && clRingsRawConfCol.size() != nRingSets ) {
233 throw std::invalid_argument( std::string(
234 "The configuration struct seems not to be valid."));
235 }
236
237 // Prepare RingStrip vector to receive Rings energy vectorized representation
238 ringStrip.clear();
239
240 bool foundSection = false;
241
242 for ( unsigned rsIdx = 0; rsIdx < nRingSets; ++rsIdx) {
243 if ( clRingsRawConfCol[rsIdx].calJointSection == sectionType) {
244 foundSection = true;
245 const RingSet* rs = this->at(rsIdx);
246 if ( !rs ) {
247 throw std::runtime_error( std::string(
248 "Found invalid ElementLink") );
249 }
250 rs->copyTo(ringStrip);
251 } else if (foundSection) {
252 break;
253 }
254 }
255
256}
257
258
261//==============================================================================
263{
264 if (this != &cl_rings){ // protect against invalid self-assignment
265 if (!this->container() && !this->hasStore() ) {
267 }
268 this->SG::AuxElement::operator=( cl_rings );
269 }
270 // by convention, always return *this
271 return *this;
272}
273
274
275
278
279//==============================================================================
280void CaloRings_v1::print( std::ostream &stream ) const
281{
282 stream << "CaloRings are : " << std::endl;
283 for (unsigned rsIdx = 0; rsIdx < this->nRingSets(); ++rsIdx) {
284 stream << "Ringset #" << rsIdx << " : ";
285 const RingSet* rs = this->at(rsIdx);
286 if ( !rs ) {
287 throw std::runtime_error( std::string(
288 "Found invalid ElementLink") );
289 }
290 rs->print(stream);
291 }
292}
293
294
297//==============================================================================
299{
300 if ( index >= this->nRingSets() ) {
301 throw std::overflow_error("Out of RingSet ElementLink vector range.");
302 }
303}
304
305//
306} // End of namespace xAOD
#define AUXSTORE_OBJECT_SETTER_AND_GETTER(CL, TYPE, NAME, SETTER)
Macro creating the accessors of complex auxiliary properties.
static Double_t rs
static Double_t ss
void makePrivateStore()
Create a new (empty) private store for this object.
AuxElement & operator=(const AuxElement &other)
Assignment.
SG::ConstAccessor< T, ALLOC > ConstAccessor
Definition AuxElement.h:569
bool hasStore() const
Return true if this object has an associated store.
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
const SG::AuxVectorData * container() const
Return the container holding this element.
Class summarizing the particle interaction throughout the Calorimeter (its shower shape).
void clear()
Clear RingSet EL Collection.
const RingSet * operator[](const unsigned index) const
Return ith RingSet.
unsigned nRingSets() const
Number of RingSets ElementLinks available.
const RingSet * at(const unsigned index) const
Return ith RingSet.
void print(std::ostream &stream) const
Print-out methods:
void checkRingSetIndexWithinRange(unsigned index) const
Check if index is within range, otherwise throws overflow_error:
float ringAt(const unsigned int rsIdx, const unsigned int ringIdx) const
Navigate through eT rings methods.
RingSetLinks::iterator begin()
returns iterator to the beginning of RingSet Collection.
void addRingSetEL(const ElementLink< RingSetContainer_v1 > &rsEL)
Add ElementLink to holden vector.
CaloRings_v1()
Default empty ctor.
RingSetLinks::iterator end()
returns iterator to the ending of RingSet EL Collection.
void exportRingsTo(std::vector< float > &ringStrip) const
Export rings eT in vectorized representation.
CaloRings_v1 & operator=(const CaloRings_v1 &clrings)
Assignment Operator.
std::vector< RawConf > RawConfCollection
typedef The raw configuration structure data holder
CalJointLayer
the joint calorimeter layers.
CalJointSection
the joint calorimeter sections.
Definition index.py:1
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
RingSet_v1 RingSet
Definition of the current "RingSet version".
Definition RingSet.h:15
static const SG::AuxElement::ConstAccessor< RingSetLinks > constAccRingSetLinks("ringSetLinks")
static const SG::AuxElement::Accessor< RingSetLinks > accRingSetLinks("ringSetLinks")
std::vector< ElementLink< RingSetContainer > > RingSetLinks
Declare element links vector.