ATLAS Offline Software
Loading...
Searching...
No Matches
RingSetConf_v1.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5// Local include(s).
8
9// System include(s).
10#include <iostream>
11
12namespace xAOD {
13
14
15//==============================================================================
18
22 const std::vector<CaloSampling::CaloSample> &layers)
23{
24 if (layers.empty()) return false;
25 for (const auto &layer : layers){
26 if ( (layer != CaloSampling::CaloSample::PreSamplerB ) &&
27 (layer != CaloSampling::CaloSample::PreSamplerE ) &&
28 (layer != CaloSampling::CaloSample::EMB1 ) &&
29 (layer != CaloSampling::CaloSample::EMB2 ) &&
30 (layer != CaloSampling::CaloSample::EMB3 ) &&
31 (layer != CaloSampling::CaloSample::EME1 ) &&
32 (layer != CaloSampling::CaloSample::EME2 ) &&
33 (layer != CaloSampling::CaloSample::EME3 ) ){
34 return false;
35 }
36 }
37 return true;
38}
39
40//==============================================================================
42 const std::vector<CaloSampling::CaloSample> &layers)
43{
44 if (layers.empty()) return false;
45 for (const auto &layer : layers){
46 if ( (layer != CaloSampling::CaloSample::HEC0 ) &&
47 (layer != CaloSampling::CaloSample::HEC1 ) &&
48 (layer != CaloSampling::CaloSample::HEC2 ) &&
49 (layer != CaloSampling::CaloSample::HEC3 ) &&
50 (layer != CaloSampling::CaloSample::TileBar0 ) &&
51 (layer != CaloSampling::CaloSample::TileBar1 ) &&
52 (layer != CaloSampling::CaloSample::TileBar2 ) &&
53 (layer != CaloSampling::CaloSample::TileGap1 ) &&
54 (layer != CaloSampling::CaloSample::TileGap2 ) &&
55 (layer != CaloSampling::CaloSample::TileGap3 ) &&
56 (layer != CaloSampling::CaloSample::TileExt0 ) &&
57 (layer != CaloSampling::CaloSample::TileExt1 ) &&
58 (layer != CaloSampling::CaloSample::TileExt2 ) ){
59 return false;
60 }
61 }
62 return true;
63}
64
65//==============================================================================
67 const std::vector<CaloSampling::CaloSample> &layers)
68{
69 if (layers.empty()) return false;
70 for (const CaloSampling::CaloSample &layer : layers){
71 if ( (layer != CaloSampling::CaloSample::PreSamplerB ) &&
72 (layer != CaloSampling::CaloSample::PreSamplerE ) ){
73 return false;
74 }
75 }
76 return true;
77}
78
79//==============================================================================
81 const std::vector<CaloSampling::CaloSample> &layers)
82{
83 if (layers.empty()) return false;
84 for (const CaloSampling::CaloSample layer : layers){
85 if ( (layer != CaloSampling::CaloSample::EMB1 ) &&
86 (layer != CaloSampling::CaloSample::EME1 ) ){
87 return false;
88 }
89 }
90 return true;
91}
92
93//==============================================================================
95 const std::vector<CaloSampling::CaloSample> &layers)
96{
97 if (layers.empty()) return false;
98 for (const auto &layer : layers){
99 if ( (layer != CaloSampling::CaloSample::EMB2 ) &&
100 (layer != CaloSampling::CaloSample::EME2 ) ){
101 return false;
102 }
103 }
104 return true;
105}
106
107//==============================================================================
109 const std::vector<CaloSampling::CaloSample> &layers)
110{
111 if (layers.empty()) return false;
112 for (const auto &layer : layers){
113 if ( (layer != CaloSampling::CaloSample::EMB3 ) &&
114 (layer != CaloSampling::CaloSample::EME3 ) ){
115 return false;
116 }
117 }
118 return true;
119}
120
121//==============================================================================
123 const std::vector<CaloSampling::CaloSample> &layers)
124{
125 if (layers.empty()) return false;
126 for (const auto &layer : layers){
127 if ( (layer != CaloSampling::CaloSample::HEC0 ) &&
128 (layer != CaloSampling::CaloSample::HEC1 ) && // Added for flexibility
129 (layer != CaloSampling::CaloSample::TileBar0 ) &&
130 (layer != CaloSampling::CaloSample::TileGap1 ) && // Added for flexibility
131 (layer != CaloSampling::CaloSample::TileGap2 ) && // Added for flexibility
132 (layer != CaloSampling::CaloSample::TileGap3 ) &&
133 (layer != CaloSampling::CaloSample::TileExt0 ) ){
134 return false;
135 }
136 }
137 return true;
138}
139
140//==============================================================================
142 const std::vector<CaloSampling::CaloSample> &layers)
143{
144 if (layers.empty()) return false;
145 for (const auto &layer : layers){
146 if ( (layer != CaloSampling::CaloSample::HEC1 ) &&
147 (layer != CaloSampling::CaloSample::HEC2 ) &&
148 (layer != CaloSampling::CaloSample::TileBar1 ) &&
149 (layer != CaloSampling::CaloSample::TileGap1 ) &&
150 (layer != CaloSampling::CaloSample::TileGap2 ) && // Added for flexibility
151 (layer != CaloSampling::CaloSample::TileGap3 ) && // Added for flexibility
152 (layer != CaloSampling::CaloSample::TileExt1 ) ){
153 return false;
154 }
155 }
156 return true;
157}
158
159//==============================================================================
161 const std::vector<CaloSampling::CaloSample> &layers)
162{
163 if (layers.empty()) return false;
164 for (const auto &layer : layers){
165 if ( (layer != CaloSampling::CaloSample::HEC2 ) && // Added for flexibility
166 (layer != CaloSampling::CaloSample::HEC3 ) &&
167 (layer != CaloSampling::CaloSample::TileBar2 ) &&
168 (layer != CaloSampling::CaloSample::TileGap1 ) && // Added for flexibility
169 (layer != CaloSampling::CaloSample::TileGap2 ) &&
170 (layer != CaloSampling::CaloSample::TileGap3 ) && // Added for flexibility
171 (layer != CaloSampling::CaloSample::TileExt2 ) ){
172 return false;
173 }
174 }
175 return true;
176}
177
178//==============================================================================
180 const std::vector<CaloSampling::CaloSample> &layers)
181{
185}
186
187//==============================================================================
200
201
204
205//==============================================================================
206void RingSetConf_v1::print( const RawConf &raw, std::ostream &stream )
207{
208 stream << "| ";
209
210 stream << raw.nRings << " Rings, Layer: " << raw.calJointLayer <<
211 " (" << raw.layerStartIdx << " -> " << raw.layerEndIdx <<
212 ") Section: " << raw.calJointSection <<
213 " (" << raw.sectionStartIdx << " -> " << raw.sectionEndIdx <<
214 "), etaWidth = " << raw.etaWidth << ", phiWidth = " << raw.phiWidth <<
215 ", cellMaxDEtaDist = " << raw.cellMaxDEtaDist <<
216 ", cellMaxDPhiDist = " << raw.cellMaxDPhiDist <<
217 ", doEtaAxesDivision = " << raw.doEtaAxesDivision <<
218 ", doPhiAxesDivision = " << raw.doPhiAxesDivision;
219
220 stream << "|" << std::endl;
221}
222
223
226//==============================================================================
228 const RawConfCollection &rawConfCol )
229{
230 unsigned totalNumberOfRings(0);
231 for ( const auto &rsRawConfCol : rawConfCol )
232 {
233 totalNumberOfRings += rsRawConfCol.nRings;
234 }
235 return totalNumberOfRings;
236}
237
238//==============================================================================
240{
241 if ( clRingsConf.empty() ) {
242 throw std::runtime_error(std::string(
243 "Cannot add the JointLayer/JointSection bounderies "
244 "into an empty RawConfCollection."));
245 }
246
247 unsigned startOfEMJointSection(0),
248 endOfEMJointSection(0),
249 startOfHADJointSection(0),
250 endOfHADJointSection(0),
251 currentRingIdx(0);
252
253 bool isWithinEMJointSection(false),
254 isWithinHADJointSection(false);
255
256 // Get the section start, end indexes:
257 for ( const auto &rawConf : clRingsConf ){
258 Ringer::CalJointSection secType = rawConf.calJointSection;
259 bool isEM = secType == Ringer::CalJointSection::EM;
260 bool isHAD = secType == Ringer::CalJointSection::HAD;
261 // Check if we are entering a new section:
262 if ( !isWithinEMJointSection && isEM ) {
263 startOfEMJointSection = currentRingIdx;
264 isWithinEMJointSection = true;
265 }
266 if ( !isWithinHADJointSection && isHAD ) {
267 startOfHADJointSection = currentRingIdx;
268 isWithinHADJointSection = true;
269 }
270 // Check if we left a section:
271 if ( isWithinEMJointSection && !isEM ) {
272 endOfEMJointSection = currentRingIdx;
273 isWithinEMJointSection = false;
274 }
275 if ( isWithinHADJointSection && !isHAD ) {
276 endOfHADJointSection = currentRingIdx;
277 isWithinHADJointSection = false;
278 }
279 // Increment current index by the layer size:
280 currentRingIdx += rawConf.nRings;
281 }
282 // We finished looping, close the contained section boundery with the last
283 // ring index:
284 if ( isWithinEMJointSection ) {
285 endOfEMJointSection = currentRingIdx;
286 } else if ( isWithinHADJointSection ) {
287 endOfHADJointSection = currentRingIdx;
288 }
289
290 currentRingIdx = 0;
291 // Now fill the indexes:
292 for ( auto &rawConf : clRingsConf ){
293 // Fill the layer indexes:
294 rawConf.layerStartIdx = currentRingIdx;
295 currentRingIdx += rawConf.nRings;
296 rawConf.layerEndIdx = currentRingIdx;
297 // Fill the section indexes:
298 switch (rawConf.calJointSection) {
300 {
301 rawConf.sectionStartIdx = startOfEMJointSection;
302 rawConf.sectionEndIdx = endOfEMJointSection;
303 break;
304 }
306 {
307 rawConf.sectionStartIdx = startOfHADJointSection;
308 rawConf.sectionEndIdx = endOfHADJointSection;
309 break;
310 }
311 default:
312 throw std::runtime_error(std::string(
313 "Found unknown JointSection type."));
314 }
315 }
316}
317
318//==============================================================================
320 std::ostream &stream )
321{
322 stream << "RawConfCollection is : " << std::endl;
323 for (unsigned rsIdx = 0; rsIdx < rawCol.size(); ++rsIdx) {
324 stream << "RawConf #" << rsIdx << " : ";
325 RingSetConf_v1::print(rawCol.at(rsIdx),stream);
326 }
327}
328
329//==============================================================================
331 const Ringer::CalJointSection sec,
332 unsigned &startEdge,
333 unsigned &endEdge)
334{
335 for( const auto &rsConf : clRingsConf ) {
336 if ( rsConf.calJointSection == sec ) {
337 startEdge = rsConf.sectionStartIdx;
338 endEdge = rsConf.sectionEndIdx;
339 return;
340 }
341 }
342}
343
344//==============================================================================
346 const Ringer::CalJointLayer layer,
347 unsigned &startEdge,
348 unsigned &endEdge)
349{
350 for( const auto &rsConf : clRingsConf ) {
351 if ( rsConf.calJointLayer == layer ) {
352 startEdge = rsConf.layerStartIdx;
353 endEdge = rsConf.layerEndIdx;
354 return;
355 }
356 }
357}
358
359//==============================================================================
361 const RawConfCollection &rawConfCol,
363{
364
365 // Loop through RawConfCollection and build true RingSetConf_v1 objects from
366 // them:
367 for ( const auto& rsRawConf : rawConfCol ) {
368 container.push_back(std::make_unique<RingSetConf_v1>( rsRawConf ));
369 }
370
371}
372
373//==============================================================================
375 RawConfCollection &rawConfCol,
377{
378 // Protect against bad pointers:
379 if ( container == nullptr ) {
380 throw std::runtime_error(std::string("Retrieved nullptr when trying to create"
381 " RawConfCollection."));
382 }
383
384 // Clear previous collection
385 rawConfCol.clear();
386 // Push back new configuration
387 for ( const auto *const rsConf : *container ) {
388 rawConfCol.push_back( rsConf->getRawConf() );
389 }
390}
391
392
395//==============================================================================
421
422//==============================================================================
424 const RingSetConf_v1::RawConf &confStruct)
425{
427 setNRings(confStruct.nRings);
428 setLayers(confStruct.layers);
429 setEtaWidth(confStruct.etaWidth);
430 setPhiWidth(confStruct.phiWidth);
438 setLayerEndIdx(confStruct.layerEndIdx);
441}
442
443//==============================================================================
467
468//==============================================================================
496
497//==============================================================================
499 const RingSetConf_v1 &rsConf):
500 nRings(rsConf.nRings()),
501 layers(rsConf.layers()),
502 etaWidth(rsConf.etaWidth()),
503 phiWidth(rsConf.phiWidth()),
511 layerEndIdx(rsConf.layerEndIdx()),
513 sectionEndIdx(rsConf.sectionEndIdx()){;}
514
515
516
519//==============================================================================
521 unsigned,
522 nRings,
523 setNRings)
525
526
528//==============================================================================
529const std::vector<CaloSampling::CaloSample>& RingSetConf_v1::layers() const {
531 return reinterpret_cast<const std::vector<CaloSampling::CaloSample>& >(
532 acc( *this ) );
533}
534
535//==============================================================================
537 const std::vector<CaloSampling::CaloSample>& layers) {
539 acc.set( *this , reinterpret_cast<const std::vector<unsigned>&>(layers) );
540}
541
542//==============================================================================
543unsigned RingSetConf_v1::nLayers() const {
545 return acc( *this ).size();
546}
547
548//==============================================================================
551 return static_cast<CaloSampling::CaloSample>( acc( *this ).at(idx) );
552}
553
554//==============================================================================
557 acc( *this ).push_back(c);
558}
559
560//==============================================================================
563 acc( *this ).clear();
564}
565
566
569//==============================================================================
571 static const SG::AuxElement::ConstAccessor< unsigned > acc("calJointLayer");
572 return static_cast<Ringer::CalJointLayer>( acc( *this ) );
573}
574
575//==============================================================================
580
581//==============================================================================
583 static const SG::AuxElement::ConstAccessor< unsigned > acc("calJointSection");
584 return static_cast<Ringer::CalJointSection>( acc( *this ) );
585}
586
587//==============================================================================
593
594
597//==============================================================================
599 float,
600 etaWidth,
602
603//==============================================================================
605 float,
608
609//==============================================================================
611 float,
614
615//==============================================================================
617 float,
620
621//==============================================================================
623 static const SG::AuxElement::ConstAccessor< char > acc("doEtaAxesDivision");
624 return static_cast<bool>( acc( *this) );
625}
626
627//==============================================================================
629 static const SG::AuxElement::Accessor< char > acc("doEtaAxesDivision");
630 acc( *this) = static_cast<char>(doEtaAxesDivision);
631}
632
633//==============================================================================
635 static const SG::AuxElement::ConstAccessor< char > acc("doPhiAxesDivision");
636 return static_cast<bool>( acc( *this ) );
637}
638
639//==============================================================================
641 static const SG::AuxElement::Accessor< char > acc("doPhiAxesDivision");
642 acc( *this ) = static_cast<char>(doPhiAxesDivision);
643}
644
645
648//==============================================================================
650 unsigned,
653
654//==============================================================================
656 unsigned,
659
660//==============================================================================
662 unsigned,
665
666//==============================================================================
668 unsigned,
672
675//==============================================================================
677 return RawConf( *this );
678}
679
680
681//==============================================================================
683 if (this != &rsConf ){ // protect against invalid self-assignment
684 if (!this->container() && !this->hasStore() ) {
686 }
687 this->SG::AuxElement::operator=( rsConf );
688 }
689 // by convention, always return *this
690 return *this;
691}
692
693//==============================================================================
694void RingSetConf_v1::print( std::ostream &stream ) const {
695 stream << "| ";
696
697 stream << nRings() << " Rings, Layer: " << calJointLayer() <<
698 " (" << layerStartIdx() << " -> " << layerEndIdx() <<
699 ") Section: " << calJointSection() <<
700 " (" << sectionStartIdx() << " -> " << sectionEndIdx() <<
701 "), etaWidth = " << etaWidth() << ", phiWidth = " << phiWidth() <<
702 ", cellMaxDEtaDist = " << cellMaxDEtaDist() <<
703 ", cellMaxDPhiDist = " << cellMaxDPhiDist() <<
704 ", doEtaAxesDivision = " << doEtaAxesDivision() <<
705 ", doPhiAxesDivision = " << doPhiAxesDivision();
706
707 stream << "|" << std::endl;
708}
709
710} // namespace xAOD
711
#define AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(CL, TYPE, NAME, SETTER)
Macro creating the accessors of primitive auxiliary properties.
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 holding the RingSet configuration used for the Reconstruction.
Ringer::CalJointSection calJointSection() const
Retrieve this RingSet conf CalJointSection.
unsigned layerEndIdx() const
Returns end of section index for this RingSet Configuration when this configuration is concatened int...
void setEtaWidth(float etaWidth)
Set etaWidth.
unsigned layerStartIdx() const
Returns start of layer index for this RingSet Configuration when this configuration is concatened int...
const RingSetConf_v1::RawConf getRawConf() const
Retrieve raw RingSet Configuration struct.
CaloSampling::CaloSample layerAt(const unsigned idx) const
Get ith layer.
std::vector< RawConf > RawConfCollection
typedef The raw configuration structure data holder
static bool isPSLayer(const std::vector< CaloSampling::CaloSample > &layers)
void setCellMaxDEtaDist(float cellMaxDEtaDist)
Set maxCellDEtaDist.
static bool isEMSection(const std::vector< CaloSampling::CaloSample > &layers)
Static methods:
static bool isHADSection(const std::vector< CaloSampling::CaloSample > &layers)
unsigned nRings() const
Get nRings.
static bool isEM3Layer(const std::vector< CaloSampling::CaloSample > &layers)
float cellMaxDEtaDist() const
Return the maximun cell distance in eta w.r.t seed.
static Ringer::CalJointLayer whichLayer(const std::vector< CaloSampling::CaloSample > &layers)
unsigned sectionEndIdx() const
Returns end of section index for this RingSet Configuration when this configuration is concatened int...
static void print(const RawConf &raw, std::ostream &stream)
Prints rawConf.
unsigned nLayers() const
RingSet layers size:
RingSetConf_v1 & operator=(const RingSetConf_v1 &clrings)
Assignment Operator.
float cellMaxDPhiDist() const
Return the maximun cell distance in phi w.r.t seed.
static Ringer::CalJointSection whichSection(const std::vector< CaloSampling::CaloSample > &layers)
void setLayerEndIdx(unsigned layerEndIdx)
Set end layer configuration index.
static void getRawConfCol(RawConfCollection &rawConfCol, const RingSetConfContainer_v1 *container)
Retrieve RawConfCollection from RingSetConf container.
void addLayer(const CaloSampling::CaloSample c)
Add layer.
static bool isHAD2Layer(const std::vector< CaloSampling::CaloSample > &layers)
void setSectionEndIdx(unsigned sectionEndIdx)
Set end section configuration index.
static bool isHAD3Layer(const std::vector< CaloSampling::CaloSample > &layers)
static bool isHAD1Layer(const std::vector< CaloSampling::CaloSample > &layers)
void setCalJointSection(Ringer::CalJointSection calJointSection)
Set this RingSet CalJointSection.
float etaWidth() const
Returns the etaWidth configuration step used for this RingSet.
void setdoPhiAxesDivision(bool doPhiAxesDivision)
Set doPhiAxesDivision.
bool doEtaAxesDivision() const
Return the etaAxesDivision configuration.
void clearLayers()
Clear layers.
unsigned sectionStartIdx() const
Returns start of section index for this RingSet Configuration when this configuration is concatened i...
void setSectionStartIdx(unsigned sectionEndIdx)
Set start section configuration index.
void setLayers(const std::vector< CaloSampling::CaloSample > &layers)
set layers
RingSetConf_v1()
Empty ctor:
static bool isEM1Layer(const std::vector< CaloSampling::CaloSample > &layers)
static void getEdges(const RawConfCollection &clRingsConf, const Ringer::CalJointSection sec, unsigned &startEdge, unsigned &endEdge)
Get CalJointSection start and end edges.
float phiWidth() const
Returns the phiWidth configuration step used for this RingSet.
void setLayerStartIdx(unsigned layerStartIdx)
Set start layer configuration index.
static void fillRingSetConfContainer(const RawConfCollection &rawConfCol, RingSetConfContainer_v1 &container)
Creates RingSetConfContainer from RawConfCollection.
void setCellMaxDPhiDist(float cellMaxDPhiDist)
Set maxCellDPhiDist.
static void addRawConfColBounderies(RawConfCollection &clRingsConf)
Add to RawConfCollection its JointLayer/JointSection bounderies.
const std::vector< CaloSampling::CaloSample > & layers() const
get layers
Ringer::CalJointLayer calJointLayer() const
Retrieve this RingSet conf CalJointLayer.
void setPhiWidth(float phiWidth)
Set phiWidth.
bool doPhiAxesDivision() const
Return the phiAxesDivision configuration.
void setNRings(unsigned nRings)
Set nRings.
void setCalJointLayer(Ringer::CalJointLayer calJointLayer)
Set this RingSet CalJointLayer.
void setdoEtaAxesDivision(bool doEtaAxesDivision)
Set doEtaAxesDivision.
static bool isEM2Layer(const std::vector< CaloSampling::CaloSample > &layers)
static unsigned totalNumberOfRings(const RawConfCollection &clRingsConf)
Get the totalNumber of Rings contained in this configuration:
CalJointLayer
the joint calorimeter layers.
@ UnknownJointLayer
CalJointSection
the joint calorimeter sections.
@ UnknownJointSection
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
setPhiWidth cellMaxDPhiDist
setLayerEndIdx sectionEndIdx
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(BTagging_v1, float, IP2D_pb, setIP2D_pb) AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(BTagging_v1
static const SG::AuxElement::Accessor< ElementLink< IParticleContainer > > acc("originalObjectLink")
Object used for setting/getting the dynamic decoration in question.
DataVector< xAOD::RingSetConf_v1 > RingSetConfContainer_v1
The container is a simple typedef for now.
unsigned sectionEndIdx
Hold the end of this section on a non-segmented representation:
float cellMaxDEtaDist
Maximum distance cell in eta to seed.
unsigned sectionStartIdx
Hold the start of this section on a non-segmented representation:
bool doPhiAxesDivision
Hold the option of phi axes division.
float cellMaxDPhiDist
Maximum distance cell in phi to seed.
bool doEtaAxesDivision
Hold the option of eta axes division.
Ringer::CalJointSection calJointSection
The Calorimeter Joint Section (see CaloRingsDefs.h)
RawConf()
Configuration Struct ctors.
Ringer::CalJointLayer calJointLayer
The Calorimeter Joint Layer of this RingSet (see CaloRingsDefs.h)
unsigned nRings
Ringset number of Rings.
float etaWidth
Ring Width in eta.
unsigned layerStartIdx
Hold the start of this layer on a non-segmented representation:
float phiWidth
Ring Width in phi.
std::vector< CaloSampling::CaloSample > layers
Ringset layers.
unsigned layerEndIdx
Hold the end of this layer on a non-segmented representation: