CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Static Private Member Functions | Static Private Attributes
EcalScDetId Class Reference

#include <EcalScDetId.h>

Inheritance diagram for EcalScDetId:
DetId

Public Types

enum  { kSizeForDenseIndexing = SC_PER_EE_CNT * 2 }
 
- Public Types inherited from DetId
enum  Detector {
  Tracker = 1, Muon = 2, Ecal = 3, Hcal = 4,
  Calo = 5, Forward = 6, VeryForward = 7, HGCalEE = 8,
  HGCalHSi = 9, HGCalHSc = 10, HGCalTrigger = 11
}
 

Public Member Functions

uint32_t denseIndex () const
 
 EcalScDetId ()
 
 EcalScDetId (const DetId &id)
 
 EcalScDetId (int ix, int iy, int iz)
 
 EcalScDetId (uint32_t rawid)
 
int hashedIndex () const
 
int iquadrant () const
 
int ix () const
 
int iy () const
 
EcalScDetIdoperator= (const DetId &id)
 
EcalSubdetector subdet () const
 
int zside () const
 
- Public Member Functions inherited from DetId
constexpr Detector det () const
 get the detector field from this detid More...
 
constexpr DetId ()
 Create an empty or null id (also for persistence) More...
 
constexpr DetId (Detector det, int subdet)
 Create an id, filling the detector and subdetector fields as specified. More...
 
constexpr DetId (uint32_t id)
 Create an id from a raw number. More...
 
constexpr bool null () const
 is this a null id ? More...
 
constexpr operator uint32_t () const
 
constexpr bool operator!= (DetId id) const
 inequality More...
 
constexpr uint32_t operator() () const
 
constexpr bool operator< (DetId id) const
 comparison More...
 
constexpr bool operator== (DetId id) const
 equality More...
 
constexpr uint32_t rawId () const
 get the raw id More...
 
constexpr int subdetId () const
 get the contents of the subdetector field (not cast into any detector's numbering enum) More...
 

Static Public Member Functions

static EcalScDetId unhashIndex (int hi)
 
static bool validDenseIndex (uint32_t din)
 
static bool validDetId (int ix, int iy, int iz)
 
static bool validHashIndex (int hi)
 

Static Public Attributes

static const int IHASHED_MAX = SC_PER_EE_CNT * 2 - 1
 
static const int IHASHED_MIN = 0
 
static const int IX_MAX = 20
 
static const int IX_MIN = 1
 
static const int IY_MAX = 20
 
static const int IY_MIN = 1
 
static const int SC_PER_EE_CNT = 312
 
- Static Public Attributes inherited from DetId
static const int kDetMask = 0xF
 
static const int kDetOffset = 28
 
static const int kSubdetMask = 0x7
 
static const int kSubdetOffset = 25
 

Static Private Member Functions

static void checkHashedIndexMap ()
 

Static Private Attributes

static EcalScDetId hashedIndex2DetId [kSizeForDenseIndexing]
 
static const int nEndcaps = 2
 
static short xyz2HashedIndex [IX_MAX][IY_MAX][nEndcaps]
 

Additional Inherited Members

- Protected Attributes inherited from DetId
uint32_t id_
 

Detailed Description

Supercrystal identifier class for the ECAL endcap.

Note: internal representation of ScDetId:

*  31              .               15              .              0
*  |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-| 
*  |  det  |sudet|         0       |1|z|     ix      |     iy      |
*  +-------+-----+-----------------+-+-+-------------+-------------+
*  

Definition at line 24 of file EcalScDetId.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
kSizeForDenseIndexing 

Number of dense supercrystal indices.

Definition at line 185 of file EcalScDetId.h.

185  {
189  };

Constructor & Destructor Documentation

◆ EcalScDetId() [1/4]

EcalScDetId::EcalScDetId ( )

Constructor of a null id

Definition at line 12 of file EcalScDetId.cc.

12 : DetId() {}

Referenced by checkHashedIndexMap(), and unhashIndex().

◆ EcalScDetId() [2/4]

EcalScDetId::EcalScDetId ( uint32_t  rawid)

Constructor from a raw value

Parameters
rawiddet ID number of the supecrystal, as defined in this class description.

Definition at line 14 of file EcalScDetId.cc.

14 : DetId(rawid) {}

◆ EcalScDetId() [3/4]

EcalScDetId::EcalScDetId ( int  ix,
int  iy,
int  iz 
)

Constructor from supercrystal ix,iy,iz (iz=+1/-1) ix x-index runs from 1 to 20 along x-axis of standard CMS coordinates iy y-index runs from 1 to 20 along y-axis of standard CMS coordinates iz z-index (also called "z-side") is -1 for EE- and +1 for EE+

Parameters
ixx-index
iyy-index
izz-side /z-index: -1 for EE-, +1 for EE+

Definition at line 16 of file EcalScDetId.cc.

16  : DetId(Ecal, EcalEndcap) {
17  if (!validDetId(ix, iy, iz)) {
18  throw cms::Exception("InvalidDetId") << "EcalScDetId: Cannot create object. Indexes out of bounds \n"
19  << "x = " << ix << " y = " << iy << " z = " << iz;
20  }
21  const int scBit = 1 << 15; //bit set to 1 to distinguish from crystal id (EEDetId)
22  // and for a reasonale behaviour of DetId ccomparison operators.
23  id_ |= (iy & 0x7f) | ((ix & 0x7f) << 7) | ((iz > 0) ? (1 << 14) : (0)) | scBit;
24 }

References Exception, DetId::id_, ix(), iy(), and validDetId().

◆ EcalScDetId() [4/4]

EcalScDetId::EcalScDetId ( const DetId id)

Constructor from a raw value

Parameters
iddet ID number

Definition at line 26 of file EcalScDetId.cc.

26  {
27  if (!gen.null() && (gen.det() != Ecal || gen.subdetId() != EcalEndcap)) {
28  throw cms::Exception("InvalidDetId");
29  }
30  id_ = gen.rawId();
31 }

References DetId::Ecal, EcalEndcap, Exception, and DetId::id_.

Member Function Documentation

◆ checkHashedIndexMap()

void EcalScDetId::checkHashedIndexMap ( )
staticprivate

Initializes x,y,z <-> hashed index map if not yet done.

Definition at line 91 of file EcalScDetId.cc.

91  {
92  std::call_once(initializedFlag, []() {
93  int hashedIndex = -1;
94  for (int iZ = -1; iZ <= +1; iZ += 2) {
95  for (int iY = IY_MIN; iY <= IY_MAX; ++iY) {
96  for (int iX = IX_MIN; iX <= IX_MAX; ++iX) {
97  if (validDetId(iX, iY, iZ)) {
98  xyz2HashedIndex[iX - IX_MIN][iY - IY_MIN][iZ > 0 ? 1 : 0] = ++hashedIndex;
99  assert((unsigned)hashedIndex < sizeof(hashedIndex2DetId) / sizeof(hashedIndex2DetId[0]));
101  }
102  }
103  }
104  }
105  });
106 }

References cms::cuda::assert(), EcalScDetId(), hashedIndex(), hashedIndex2DetId, initializedFlag, IX_MAX, IX_MIN, IY_MAX, IY_MIN, validDetId(), and xyz2HashedIndex.

Referenced by hashedIndex(), and unhashIndex().

◆ denseIndex()

uint32_t EcalScDetId::denseIndex ( ) const
inline

Same as hashed index.

Returns
the dense/hashed index

Definition at line 127 of file EcalScDetId.h.

127 { return hashedIndex(); }

References hashedIndex().

◆ hashedIndex()

int EcalScDetId::hashedIndex ( ) const
inline

Gets a compact index for arrays. Index runs from 0 to 623. They are ordered by increasing z (EE- then EE+), then for same z by increasing y. then for same z and y by increasing x

Definition at line 106 of file EcalScDetId.h.

106  {
108  if (!validDetId(ix(), iy(), zside()))
109  return -1;
110  return xyz2HashedIndex[ix() - IX_MIN][iy() - IY_MIN][zside() > 0 ? 1 : 0];
111  }

References checkHashedIndexMap(), ix(), IX_MIN, iy(), IY_MIN, validDetId(), xyz2HashedIndex, and zside().

Referenced by checkHashedIndexMap(), denseIndex(), ecaldqm::SelectiveReadoutTask::runOnDigis(), and ecaldqm::SelectiveReadoutTask::runOnSrFlags().

◆ iquadrant()

int EcalScDetId::iquadrant ( ) const

Gets the quadrant of the DetId.

Quadrant number definition for EE+, x and y in std CMS coordinates:

*                 A y
*                 |
*          Q2     |    Q1
*                 |
*       ----------o---------> x
*                 |
*          Q3     |    Q4
*                 |
* 

This method will return the same quadrant number independently of z: that is two supercrystals which are face to face will be considered will have the same quadrant number. It is not clear it is the correct or usual definition.

See also
EEDetId::iquadrant()
Returns
quadrant number, from 1 to 4.

Definition at line 41 of file EcalScDetId.cc.

41  {
42  const int xMiddle = IX_MAX / 2; //y = 0 between xMiddle and xMiddle+1
43  const int yMiddle = IY_MAX / 2; //x = 0 between yMiddle and yMiddle+1
44  if (iy() > yMiddle) { // y>0
45  if (ix() > xMiddle) // A y
46  return 1; // |
47  else // Q2 | Q1
48  return 2; // |
49  } else { // y<0 // ----------o---------> x
50  if (ix() > xMiddle) // |
51  return 4; // Q3 | Q4
52  else // |
53  return 3;
54  }
55  //Should never be reached
56  return -1;
57 }

References ix(), IX_MAX, iy(), and IY_MAX.

◆ ix()

int EcalScDetId::ix ( ) const
inline

◆ iy()

int EcalScDetId::iy ( ) const
inline

◆ operator=()

EcalScDetId & EcalScDetId::operator= ( const DetId id)

Assignment operator

Parameters
idsource det id

Definition at line 33 of file EcalScDetId.cc.

33  {
34  if (!gen.null() && (gen.det() != Ecal || gen.subdetId() != EcalEndcap)) {
35  throw cms::Exception("InvalidDetId");
36  }
37  id_ = gen.rawId();
38  return *this;
39 }

References DetId::Ecal, EcalEndcap, Exception, and DetId::id_.

◆ subdet()

EcalSubdetector EcalScDetId::subdet ( ) const
inline

Gets the subdetector

Returns
subdetectot ID, that is EcalEndcap

Definition at line 59 of file EcalScDetId.h.

59 { return EcalSubdetector(subdetId()); }

References DetId::subdetId().

◆ unhashIndex()

static EcalScDetId EcalScDetId::unhashIndex ( int  hi)
inlinestatic

◆ validDenseIndex()

static bool EcalScDetId::validDenseIndex ( uint32_t  din)
inlinestatic

Validates a hashed index.

Parameters
dinhashed index to validate
Returns
true if the index is valid, false if it is invalid.

Definition at line 133 of file EcalScDetId.h.

133 { return din < kSizeForDenseIndexing; }

References cropTnPTrees::din, and kSizeForDenseIndexing.

Referenced by validHashIndex().

◆ validDetId()

bool EcalScDetId::validDetId ( int  ix,
int  iy,
int  iz 
)
static

Checks validity of a crystal (x,y.z) index triplet.

Parameters
ixsupercrystal x-index
iysupercrystal y-index
izsupercrystal z-index (aka z-side)
See also
EEDetId(int, int, int) for index definition
Returns
true if valid, false otherwise

Definition at line 59 of file EcalScDetId.cc.

59  {
60  static const char endcapMap[401] = {
61  " XXXXXX "
62  " XXXXXXXXXXXX "
63  " XXXXXXXXXXXXXX "
64  " XXXXXXXXXXXXXXXX "
65  " XXXXXXXXXXXXXXXXXX "
66  " XXXXXXXXXXXXXXXXXX " // Z
67  " XXXXXXXXXXXXXXXXXX " // x-----> X
68  "XXXXXXXXXXXXXXXXXXXX" // |
69  "XXXXXXXXX XXXXXXXXX" // |
70  "XXXXXXXX XXXXXXXX" //_ // |
71  "XXXXXXXX XXXXXXXX" // V Y
72  "XXXXXXXXX XXXXXXXXX"
73  "XXXXXXXXXXXXXXXXXXXX"
74  " XXXXXXXXXXXXXXXXXX "
75  " XXXXXXXXXXXXXXXXXX "
76  " XXXXXXXXXXXXXXXXXX "
77  " XXXXXXXXXXXXXXXX "
78  " XXXXXXXXXXXXXX "
79  " XXXXXXXXXXXX "
80  " XXXXXX "};
81 
82  return abs(iZ) == 1 && endcapMap[iX - 1 + (iY - 1) * 20] != ' ';
83 }

References funct::abs().

Referenced by checkHashedIndexMap(), EcalScDetId(), popcon::EcalDAQHandler::getNewObjects(), popcon::EcalDCSHandler::getNewObjects(), hashedIndex(), popcon::EcalDCSHandler::insertHVDataSetToOffline(), popcon::EcalDCSHandler::insertLVDataSetToOffline(), ecaldqm::binning::isValidIdBin(), EcalSelectiveReadout::printEndcap(), EcalTrivialConditionRetriever::produceEcalDAQTowerStatus(), EcalTrivialConditionRetriever::produceEcalDCSTowerStatus(), EcalTrivialConditionRetriever::produceEcalDQMTowerStatus(), and EcalSelectiveReadoutSuppressor::run().

◆ validHashIndex()

static bool EcalScDetId::validHashIndex ( int  hi)
inlinestatic

Validates a hashed index.

Parameters
hihashed index to validate
Returns
true if the index is valid, false if it is invalid.

Definition at line 139 of file EcalScDetId.h.

139 { return validDenseIndex(hi); }

References validDenseIndex().

Referenced by EcalDAQTowerStatusXMLTranslator::dumpXML(), EcalDCSTowerStatusXMLTranslator::dumpXML(), EcalDCSTowerStatusXMLTranslator::plot(), and EcalDAQTowerStatusXMLTranslator::plot().

◆ zside()

int EcalScDetId::zside ( ) const
inline

Member Data Documentation

◆ hashedIndex2DetId

EcalScDetId EcalScDetId::hashedIndex2DetId
staticprivate

Map of hased index to x,y,z. See hashedIndex/

Definition at line 200 of file EcalScDetId.h.

Referenced by checkHashedIndexMap(), and unhashIndex().

◆ IHASHED_MAX

const int EcalScDetId::IHASHED_MAX = SC_PER_EE_CNT * 2 - 1
static

Upper bound for hashed/dense index

Definition at line 167 of file EcalScDetId.h.

◆ IHASHED_MIN

const int EcalScDetId::IHASHED_MIN = 0
static

Lower bound for hashed/dense index

Definition at line 163 of file EcalScDetId.h.

◆ IX_MAX

const int EcalScDetId::IX_MAX = 20
static

Upper bound of EE crystal y-index

Definition at line 155 of file EcalScDetId.h.

Referenced by checkHashedIndexMap(), and iquadrant().

◆ IX_MIN

const int EcalScDetId::IX_MIN = 1
static

Lower bound of EE supercrystal x-index

Definition at line 147 of file EcalScDetId.h.

Referenced by checkHashedIndexMap(), and hashedIndex().

◆ IY_MAX

const int EcalScDetId::IY_MAX = 20
static

Upper bound of EE crystal y-index

Definition at line 159 of file EcalScDetId.h.

Referenced by checkHashedIndexMap(), and iquadrant().

◆ IY_MIN

const int EcalScDetId::IY_MIN = 1
static

Lower bound of EE supercrystal y-index

Definition at line 151 of file EcalScDetId.h.

Referenced by checkHashedIndexMap(), and hashedIndex().

◆ nEndcaps

const int EcalScDetId::nEndcaps = 2
staticprivate

Definition at line 192 of file EcalScDetId.h.

◆ SC_PER_EE_CNT

const int EcalScDetId::SC_PER_EE_CNT = 312
static

Number of supercrystals per endcap

Definition at line 143 of file EcalScDetId.h.

◆ xyz2HashedIndex

short EcalScDetId::xyz2HashedIndex
staticprivate

Map of z,x,y index to hashed index. See hashedIndex/

Definition at line 196 of file EcalScDetId.h.

Referenced by checkHashedIndexMap(), and hashedIndex().

EcalScDetId::EcalScDetId
EcalScDetId()
Definition: EcalScDetId.cc:12
EcalScDetId::xyz2HashedIndex
static short xyz2HashedIndex[IX_MAX][IY_MAX][nEndcaps]
Definition: EcalScDetId.h:196
initializedFlag
static std::once_flag initializedFlag
Definition: EcalScDetId.cc:90
EcalScDetId::zside
int zside() const
Definition: EcalScDetId.h:64
EcalScDetId::validDetId
static bool validDetId(int ix, int iy, int iz)
Definition: EcalScDetId.cc:59
cms::cuda::assert
assert(be >=bs)
EcalScDetId::SC_PER_EE_CNT
static const int SC_PER_EE_CNT
Definition: EcalScDetId.h:143
EcalSubdetector
EcalSubdetector
Definition: EcalSubdetector.h:10
EcalScDetId::hashedIndex2DetId
static EcalScDetId hashedIndex2DetId[kSizeForDenseIndexing]
Definition: EcalScDetId.h:200
EcalScDetId::IY_MIN
static const int IY_MIN
Definition: EcalScDetId.h:151
gen
Definition: PythiaDecays.h:13
DetId::subdetId
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
Definition: DetId.h:48
EcalEndcap
Definition: EcalSubdetector.h:10
EcalScDetId::hashedIndex
int hashedIndex() const
Definition: EcalScDetId.h:106
EcalScDetId::IX_MIN
static const int IX_MIN
Definition: EcalScDetId.h:147
cropTnPTrees.din
din
Definition: cropTnPTrees.py:30
DetId::id_
uint32_t id_
Definition: DetId.h:69
EcalScDetId::IX_MAX
static const int IX_MAX
Definition: EcalScDetId.h:155
EcalScDetId::iy
int iy() const
Definition: EcalScDetId.h:76
EcalScDetId::checkHashedIndexMap
static void checkHashedIndexMap()
Definition: EcalScDetId.cc:91
DetId::Ecal
Definition: DetId.h:27
hi
Definition: EPCuts.h:4
EcalScDetId::IY_MAX
static const int IY_MAX
Definition: EcalScDetId.h:159
EcalScDetId::validDenseIndex
static bool validDenseIndex(uint32_t din)
Definition: EcalScDetId.h:133
Exception
Definition: hltDiff.cc:246
DetId::DetId
constexpr DetId()
Create an empty or null id (also for persistence)
Definition: DetId.h:38
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
EcalScDetId::kSizeForDenseIndexing
Definition: EcalScDetId.h:188
EcalScDetId::ix
int ix() const
Definition: EcalScDetId.h:70