ATLAS Offline Software
Loading...
Searching...
No Matches
CaloSamplingHelper Class Reference

algorithmic methods of the legacy CaloSampling.h class used by the legacy CaloCluster object More...

#include <CaloSamplingHelper.h>

Inheritance diagram for CaloSamplingHelper:
Collaboration diagram for CaloSamplingHelper:

Public Types

enum  CaloSample
enum  CaloSample

Public Member Functions

 CaloSamplingHelper ()=default
 ~CaloSamplingHelper ()=default
 CaloSamplingHelper (const CaloSamplingHelper &rhs)=delete
CaloSamplingHelperoperator= (const CaloSamplingHelper &rhs)=delete

Static Public Member Functions

static CaloSample getSampling (const CaloCell &c)
 Retrieves the sampling indicator for a cell.
static unsigned int getSamplingBit (const CaloSample &rSample)
 Return a unique bit set for a given sampling.
static unsigned int getSamplingBit (const CaloCell &rCell)
 Return a unique bit set for a given sampling.
static bool isEMSampling (const CaloSample &rSample)
 Get sampling characteristics.
static bool isHADSampling (const CaloSample &rSample)
static bool isBarrelSampling (const CaloSample &rSample)
static bool isEndCapSampling (const CaloSample &rSample)
static bool isLArSampling (const CaloSample &rSample)
static bool isTileSampling (const CaloSample &rSample)
static const std::string & getSamplingName (const CaloSampling::CaloSample theSample)
 Returns a string (name) for each CaloSampling.
static CaloSampling::CaloSample getSamplingId (const std::string &samplingName)
 Returns the CaloSampling::CaloSample enumerator value.
static bool getSamplings (const std::vector< CaloCell_ID::SUBCALO > &theCalos, std::vector< CaloSampling::CaloSample > &theSamplings)
 Returns a list of samplings enumerators for a list of sub-calos.
static bool getSamplings (const CaloCell_ID::SUBCALO &theCalo, std::vector< CaloSampling::CaloSample > &theSamplings)
 Returns a list of samplings enumerators for a list of sub-calos This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
static bool getCalos (const std::vector< CaloSampling::CaloSample > &theSamplings, std::vector< CaloCell_ID::SUBCALO > &theCalos)
 Returns a list of sub-calos for a list of samplings.
static constexpr unsigned int getNumberOfSamplings ()
 Get number of available samplings.
static unsigned int getNumberOfSamplings ()
 Get number of available samplings.
static unsigned int getSamplingPattern (const CaloSample s)
 Get a unsigned with one bit set.
static unsigned int getSamplingPattern (const CaloSample s)
 Get a unsigned with one bit set.
static constexpr unsigned int barrelPattern ()
 Get the bit-pattern for barrel samplings.
static unsigned int barrelPattern ()
 Get the bit-pattern for barrel samplings.
static constexpr unsigned int endcapPattern ()
 Get the bit-pattern for endcap samplings.
static unsigned int endcapPattern ()
 Get the bit-pattern for endcap samplings.
static std::string getSamplingName (unsigned int theSample)
 Returns a string (name) for each CaloSampling.
static CaloSample getSampling (const std::string &name)
 Return the sampling code for a given name.

Static Private Member Functions

static bool matchPattern (const CaloSample &rSample, const unsigned int &mask)

Static Private Attributes

static const unsigned int m_EMMask = 0x000000ff
static const unsigned int m_HADMask = 0x00ffff00
static const unsigned int m_BarrelMask = 0x001ff00f
static const unsigned int m_EndCapMask = 0x00e00ff0
static const unsigned int m_LArMask = 0x00e00fff
static const unsigned int m_TileMask = 0x001ff000
static const std::map< std::string, CaloSampling::CaloSamplem_lookUp
static const std::string m_unknown ="Unknown"

Detailed Description

algorithmic methods of the legacy CaloSampling.h class used by the legacy CaloCluster object

Definition at line 19 of file CaloEvent/CaloEvent/CaloSamplingHelper.h.

Member Enumeration Documentation

◆ CaloSample [1/2]

enum CaloSampling::CaloSample
inherited

Definition at line 22 of file Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h.

22 {
23#define CALOSAMPLING(NAME, ISBARREL, ISENDCAP) NAME,
24#include "CaloGeoHelpers/CaloSampling.def"
25#undef CALOSAMPLING
26 };

◆ CaloSample [2/2]

enum CaloSampling::CaloSample
inherited

Definition at line 22 of file Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/CaloGeoHelpers/CaloSampling.h.

22 {
23#define CALOSAMPLING(NAME, ISBARREL, ISENDCAP) NAME,
24#include "CaloGeoHelpers/CaloSampling.def"
25#undef CALOSAMPLING
26 };

Constructor & Destructor Documentation

◆ CaloSamplingHelper() [1/2]

CaloSamplingHelper::CaloSamplingHelper ( )
default

◆ ~CaloSamplingHelper()

CaloSamplingHelper::~CaloSamplingHelper ( )
default

◆ CaloSamplingHelper() [2/2]

CaloSamplingHelper::CaloSamplingHelper ( const CaloSamplingHelper & rhs)
delete

Member Function Documentation

◆ barrelPattern() [1/2]

unsigned int CaloSampling::barrelPattern ( )
inlinestaticconstexprinherited

Get the bit-pattern for barrel samplings.

Definition at line 75 of file Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h.

75 {
76 return (//EM Barrel
77#define CALOSAMPLING(NAME, ISBARREL, ISENDCAP) (((unsigned)ISBARREL)<<NAME) |
78#include "CaloGeoHelpers/CaloSampling.def"
79#undef CALOSAMPLING
80 0 );
81}

◆ barrelPattern() [2/2]

unsigned int CaloSampling::barrelPattern ( )
staticinherited

Get the bit-pattern for barrel samplings.

◆ endcapPattern() [1/2]

unsigned int CaloSampling::endcapPattern ( )
inlinestaticconstexprinherited

Get the bit-pattern for endcap samplings.

Definition at line 84 of file Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h.

84 {
85 return (//EMEC:
86#define CALOSAMPLING(NAME, ISBARREL, ISENDCAP) (((unsigned)ISENDCAP)<<NAME) |
87#include "CaloGeoHelpers/CaloSampling.def"
88#undef CALOSAMPLING
89 0 );
90}

◆ endcapPattern() [2/2]

unsigned int CaloSampling::endcapPattern ( )
staticinherited

Get the bit-pattern for endcap samplings.

◆ getCalos()

bool CaloSamplingHelper::getCalos ( const std::vector< CaloSampling::CaloSample > & theSamplings,
std::vector< CaloCell_ID::SUBCALO > & theCalos )
static

Returns a list of sub-calos for a list of samplings.

Parameters
[in]theSamplingsvector of sampling enumerators
[out]theCalosvector of calo enumerators

Definition at line 127 of file CaloUtils/src/CaloSamplingHelper.cxx.

127 {
128 const size_t oldSize = theCalos.size();
129 for (auto fSample : theSamplings) {
131 switch (fSample) {
132 case PreSamplerB:
133 case EMB1:
134 case EMB2:
135 case EMB3:
136 case PreSamplerE:
137 case EME1:
138 case EME2:
139 case EME3:
140 theCaloId = CaloCell_ID::LAREM;
141 break;
142 case HEC0:
143 case HEC1:
144 case HEC2:
145 case HEC3:
146 theCaloId = CaloCell_ID::LARHEC;
147 break;
148 case FCAL0:
149 case FCAL1:
150 case FCAL2:
151 theCaloId = CaloCell_ID::LARFCAL;
152 break;
153 case TileBar0:
154 case TileBar1:
155 case TileBar2:
156 case TileGap1:
157 case TileGap2:
158 case TileGap3:
159 case TileExt0:
160 case TileExt1:
161 case TileExt2:
162 theCaloId = CaloCell_ID::TILE;
163 break;
164 case MINIFCAL0:
165 case MINIFCAL1:
166 case MINIFCAL2:
167 case MINIFCAL3:
168 theCaloId = CaloCell_ID::LARMINIFCAL;
169 break;
170 default:
171 break;
172 }
173 // check if not there yet (actually a std::set would be better than a
174 // vector)
175 if (std::find(theCalos.begin(), theCalos.end(), theCaloId) == theCalos.end()) {
176 theCalos.push_back(theCaloId);
177 }
178 }
179 return theCalos.size() > oldSize;
180}
CaloCell_Base_ID::SUBCALO SUBCALO
Definition CaloCell_ID.h:50

◆ getNumberOfSamplings() [1/2]

unsigned int CaloSampling::getNumberOfSamplings ( )
inlinestaticconstexprinherited

Get number of available samplings.

Definition at line 30 of file Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h.

31 {
32 return static_cast<unsigned int>(Unknown);
33 }
@ Unknown
Definition TruthClasses.h:9

◆ getNumberOfSamplings() [2/2]

unsigned int CaloSampling::getNumberOfSamplings ( )
staticinherited

Get number of available samplings.

◆ getSampling() [1/2]

CaloSampling::CaloSample CaloSampling::getSampling ( const std::string & name)
staticinherited

Return the sampling code for a given name.

Parameters
[in]nameThe name to translate.

Returns Unknown if the name is not known.

Definition at line 32 of file Calorimeter/CaloGeoHelpers/Root/CaloSampling.cxx.

33{
34 for (int samp = 0; samp != static_cast<int>(Unknown); ++samp) {
35 if (sample_names[samp] == name) {
36 return static_cast<CaloSample> (samp);
37 }
38 }
39 return Unknown;
40}

◆ getSampling() [2/2]

CaloSamplingHelper::CaloSample CaloSamplingHelper::getSampling ( const CaloCell & c)
static

Retrieves the sampling indicator for a cell.

Parameters
creference to a non-modifiable CaloCell

Returns CaloSampling::Unknown if sampling cannot be found.

Definition at line 39 of file CaloEvent/src/CaloSamplingHelper.cxx.

39 {
40
41 const CaloDetDescrElement * theCaloDDE= cell.caloDDE() ;
42 if (theCaloDDE!=nullptr) {
43 return (CaloSamplingHelper::CaloSample) theCaloDDE->getSampling();
44 }
45 else{
46 return Unknown;
47
48 }
49}
CaloCell_ID::CaloSample getSampling() const
cell sampling

◆ getSamplingBit() [1/2]

unsigned int CaloSamplingHelper::getSamplingBit ( const CaloCell & rCell)
static

Return a unique bit set for a given sampling.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
rCellconst reference to a CaloCell object

Returns 0 if cell has CaloSampling::Unknown indicator.

Definition at line 51 of file CaloEvent/src/CaloSamplingHelper.cxx.

52{
53 return getSamplingBit(getSampling(rCell));
54}
static unsigned int getSamplingBit(const CaloSample &rSample)
Return a unique bit set for a given sampling.
static CaloSample getSampling(const CaloCell &c)
Retrieves the sampling indicator for a cell.

◆ getSamplingBit() [2/2]

unsigned int CaloSamplingHelper::getSamplingBit ( const CaloSample & rSample)
inlinestatic

Return a unique bit set for a given sampling.

Parameters
rSamplereference to a non-modifiable sampling indicator

Returns 0 for CaloSampling::Unknown .

Definition at line 48 of file CaloEvent/CaloEvent/CaloSamplingHelper.h.

48 {
50 }
static unsigned int getSamplingPattern(const CaloSample s)
Get a unsigned with one bit set.

◆ getSamplingId()

CaloSampling::CaloSample CaloSamplingHelper::getSamplingId ( const std::string & samplingName)
static

Returns the CaloSampling::CaloSample enumerator value.

Parameters
[in]samplingNamestring with sampling name

Definition at line 63 of file CaloUtils/src/CaloSamplingHelper.cxx.

64{
65 return m_lookUp.find(name) != m_lookUp.end()
66 ? (*m_lookUp.find(name)).second
67 : CaloSampling::Unknown;
68}
static const std::map< std::string, CaloSampling::CaloSample > m_lookUp

◆ getSamplingName() [1/2]

std::string CaloSampling::getSamplingName ( unsigned int theSample)
staticinherited

Returns a string (name) for each CaloSampling.

Parameters
[in]theSampleCaloSampling::CaloSample enumerator value

Definition at line 24 of file Calorimeter/CaloGeoHelpers/Root/CaloSampling.cxx.

25{
26 if (theSample >= getNumberOfSamplings())
27 return "";
28 return sample_names[theSample];
29}
static constexpr unsigned int getNumberOfSamplings()
Get number of available samplings.

◆ getSamplingName() [2/2]

const std::string & CaloSamplingHelper::getSamplingName ( const CaloSampling::CaloSample theSample)
static

Returns a string (name) for each CaloSampling.

Parameters
[in]theSampleCaloSampling::CaloSample enumerator value

Definition at line 44 of file CaloUtils/src/CaloSamplingHelper.cxx.

44 {
45 //Linear search for the value in the std::map m_lookUp.
46 //Slow, but acceptable because:
47 // 1. The map has only 28 entries
48 // 2. It's and integer-comparision
49 // 3. The method is only use for log-output (eg not too often)
50
51 //Implementation uses a C++11 lambda function
52 //[&theSample] defines the lambda function and says that it depends on the external variable theSampling (captured by reference)
53 //(std::pair<std::string,CaloSample> i) is the parameter of the function
54 //{return (i.second==theSample);} Is the code of the function
55 auto it=std::find_if(m_lookUp.begin(),m_lookUp.end(),[&theSample](const std::pair<std::string,CaloSampling::CaloSample>& i) {return (i.second==theSample);});
56 if (it==m_lookUp.end())
57 return m_unknown;
58 else
59 return it->first;
60}

◆ getSamplingPattern() [1/2]

unsigned int CaloSampling::getSamplingPattern ( const CaloSample s)
inlinestaticinherited

Get a unsigned with one bit set.

Definition at line 36 of file Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h.

36 {
37 return (0x1U << s);
38 }

◆ getSamplingPattern() [2/2]

unsigned int CaloSampling::getSamplingPattern ( const CaloSample s)
inlinestaticinherited

Get a unsigned with one bit set.

Definition at line 33 of file Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/CaloGeoHelpers/CaloSampling.h.

33 {
34 return (0x1U << s);
35 }

◆ getSamplings() [1/2]

bool CaloSamplingHelper::getSamplings ( const CaloCell_ID::SUBCALO & theCalo,
std::vector< CaloSampling::CaloSample > & theSamplings )
static

Returns a list of samplings enumerators for a list of sub-calos This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
[in]theCalocalo enumerator

Definition at line 122 of file CaloUtils/src/CaloSamplingHelper.cxx.

122 {
123 const std::vector<CaloCell_ID::SUBCALO> caloVector = {theCalo};
124 return getSamplings(caloVector, theSamplings);
125}
static bool getSamplings(const std::vector< CaloCell_ID::SUBCALO > &theCalos, std::vector< CaloSampling::CaloSample > &theSamplings)
Returns a list of samplings enumerators for a list of sub-calos.

◆ getSamplings() [2/2]

bool CaloSamplingHelper::getSamplings ( const std::vector< CaloCell_ID::SUBCALO > & theCalos,
std::vector< CaloSampling::CaloSample > & theSamplings )
static

Returns a list of samplings enumerators for a list of sub-calos.

Parameters
[in]theCalosvector of calo enumerators
[out]theSamplingsvector of sampling enumerators

Definition at line 70 of file CaloUtils/src/CaloSamplingHelper.cxx.

72 {
73
74 const size_t oldSize = theSamplings.size();
75 for (auto fCalo : theCalos) {
76 switch (fCalo) {
78 theSamplings.push_back(PreSamplerB);
79 theSamplings.push_back(EMB1);
80 theSamplings.push_back(EMB2);
81 theSamplings.push_back(EMB3);
82 theSamplings.push_back(PreSamplerE);
83 theSamplings.push_back(EME1);
84 theSamplings.push_back(EME2);
85 theSamplings.push_back(EME3);
86 break;
88 theSamplings.push_back(HEC0);
89 theSamplings.push_back(HEC1);
90 theSamplings.push_back(HEC2);
91 theSamplings.push_back(HEC3);
92 break;
94 theSamplings.push_back(FCAL0);
95 theSamplings.push_back(FCAL1);
96 theSamplings.push_back(FCAL2);
97 break;
99 theSamplings.push_back(TileBar0);
100 theSamplings.push_back(TileBar1);
101 theSamplings.push_back(TileBar2);
102 theSamplings.push_back(TileExt0);
103 theSamplings.push_back(TileExt1);
104 theSamplings.push_back(TileExt2);
105 theSamplings.push_back(TileGap1);
106 theSamplings.push_back(TileGap2);
107 theSamplings.push_back(TileGap3);
108 break;
110 theSamplings.push_back(MINIFCAL0);
111 theSamplings.push_back(MINIFCAL1);
112 theSamplings.push_back(MINIFCAL2);
113 theSamplings.push_back(MINIFCAL3);
114 break;
115 default:
116 break;
117 }
118 }
119 return oldSize < theSamplings.size();
120}

◆ isBarrelSampling()

bool CaloSamplingHelper::isBarrelSampling ( const CaloSample & rSample)
static

Definition at line 67 of file CaloEvent/src/CaloSamplingHelper.cxx.

68{
69 return matchPattern(rSample,m_BarrelMask);
70}
static bool matchPattern(const CaloSample &rSample, const unsigned int &mask)

◆ isEMSampling()

bool CaloSamplingHelper::isEMSampling ( const CaloSample & rSample)
static

Get sampling characteristics.

Definition at line 57 of file CaloEvent/src/CaloSamplingHelper.cxx.

58{
59 return matchPattern(rSample,m_EMMask);
60}

◆ isEndCapSampling()

bool CaloSamplingHelper::isEndCapSampling ( const CaloSample & rSample)
static

Definition at line 72 of file CaloEvent/src/CaloSamplingHelper.cxx.

73{
74 return matchPattern(rSample,m_EndCapMask);
75}

◆ isHADSampling()

bool CaloSamplingHelper::isHADSampling ( const CaloSample & rSample)
static

Definition at line 62 of file CaloEvent/src/CaloSamplingHelper.cxx.

63{
64 return matchPattern(rSample,m_HADMask);
65}

◆ isLArSampling()

bool CaloSamplingHelper::isLArSampling ( const CaloSample & rSample)
static

Definition at line 77 of file CaloEvent/src/CaloSamplingHelper.cxx.

78{
79 return matchPattern(rSample,m_LArMask);
80}

◆ isTileSampling()

bool CaloSamplingHelper::isTileSampling ( const CaloSample & rSample)
static

Definition at line 82 of file CaloEvent/src/CaloSamplingHelper.cxx.

83{
84 return matchPattern(rSample,m_TileMask);
85}

◆ matchPattern()

bool CaloSamplingHelper::matchPattern ( const CaloSample & rSample,
const unsigned int & mask )
staticprivate

Definition at line 87 of file CaloEvent/src/CaloSamplingHelper.cxx.

89{
90 unsigned int bitPattern = getSamplingBit(rSample);
91 return ( bitPattern & mask ) == bitPattern;
92}

◆ operator=()

CaloSamplingHelper & CaloSamplingHelper::operator= ( const CaloSamplingHelper & rhs)
delete

Member Data Documentation

◆ m_BarrelMask

const unsigned int CaloSamplingHelper::m_BarrelMask = 0x001ff00f
staticprivate

Definition at line 79 of file CaloEvent/CaloEvent/CaloSamplingHelper.h.

◆ m_EMMask

const unsigned int CaloSamplingHelper::m_EMMask = 0x000000ff
staticprivate

Definition at line 77 of file CaloEvent/CaloEvent/CaloSamplingHelper.h.

◆ m_EndCapMask

const unsigned int CaloSamplingHelper::m_EndCapMask = 0x00e00ff0
staticprivate

Definition at line 80 of file CaloEvent/CaloEvent/CaloSamplingHelper.h.

◆ m_HADMask

const unsigned int CaloSamplingHelper::m_HADMask = 0x00ffff00
staticprivate

Definition at line 78 of file CaloEvent/CaloEvent/CaloSamplingHelper.h.

◆ m_LArMask

const unsigned int CaloSamplingHelper::m_LArMask = 0x00e00fff
staticprivate

Definition at line 81 of file CaloEvent/CaloEvent/CaloSamplingHelper.h.

◆ m_lookUp

const std::map< std::string, CaloSampling::CaloSample > CaloSamplingHelper::m_lookUp
staticprivate
Initial value:
{
{"PreSamplerB", PreSamplerB},
{"EMB1", EMB1},
{"EMB2", EMB2},
{"EMB3", EMB3},
{"PreSamplerE", PreSamplerE},
{"EME1", EME1},
{"EME2", EME2},
{"EME3", EME3},
{"HEC0", HEC0},
{"HEC1", HEC1},
{"HEC2", HEC2},
{"HEC3", HEC3},
{"TileBar0", TileBar0},
{"TileBar1", TileBar1},
{"TileBar2", TileBar2},
{"TileGap1", TileGap1},
{"TileGap2", TileGap2},
{"TileGap3", TileGap3},
{"TileExt0", TileExt0},
{"TileExt1", TileExt1},
{"TileExt2", TileExt2},
{"FCal1", FCAL0},
{"FCal2", FCAL1},
{"FCal3", FCAL2},
{"MiniFCal0", MINIFCAL0},
{"MiniFCal1", MINIFCAL1},
{"MiniFCal2", MINIFCAL2},
{"MiniFCal3", MINIFCAL3}
}

Definition at line 11 of file CaloUtils/CaloUtils/CaloSamplingHelper.h.

19 {
20
21public:
25 static const std::string& getSamplingName(const CaloSampling::CaloSample theSample);
26
30 static CaloSampling::CaloSample getSamplingId(const std::string& samplingName);
31
36 static bool getSamplings(const std::vector<CaloCell_ID::SUBCALO>& theCalos,
37 std::vector<CaloSampling::CaloSample>& theSamplings);
38

◆ m_TileMask

const unsigned int CaloSamplingHelper::m_TileMask = 0x001ff000
staticprivate

Definition at line 82 of file CaloEvent/CaloEvent/CaloSamplingHelper.h.

◆ m_unknown

const std::string CaloSamplingHelper::m_unknown ="Unknown"
staticprivate

Definition at line 56 of file CaloUtils/CaloUtils/CaloSamplingHelper.h.


The documentation for this class was generated from the following files: