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 (uint32_t rawid)
 
 EcalScDetId (int ix, int iy, int iz)
 
 EcalScDetId (const DetId &id)
 
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 (uint32_t id)
 Create an id from a raw number. More...
 
constexpr DetId (Detector det, int subdet)
 Create an id, filling the detector and subdetector fields as specified. 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
Enumerator
kSizeForDenseIndexing 

Number of dense supercrystal indices.

Definition at line 185 of file EcalScDetId.h.

185  {
189  };
static const int SC_PER_EE_CNT
Definition: EcalScDetId.h:143

Constructor & Destructor Documentation

EcalScDetId::EcalScDetId ( )

Constructor of a null id

Definition at line 12 of file EcalScDetId.cc.

Referenced by checkHashedIndexMap(), and unhashIndex().

12 : DetId() {}
constexpr DetId()
Create an empty or null id (also for persistence)
Definition: DetId.h:30
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) {}
constexpr DetId()
Create an empty or null id (also for persistence)
Definition: DetId.h:30
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.

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

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 }
static bool validDetId(int ix, int iy, int iz)
Definition: EcalScDetId.cc:59
int ix() const
Definition: EcalScDetId.h:70
int iy() const
Definition: EcalScDetId.h:76
uint32_t id_
Definition: DetId.h:62
constexpr DetId()
Create an empty or null id (also for persistence)
Definition: DetId.h:30
EcalScDetId::EcalScDetId ( const DetId id)

Constructor from a raw value

Parameters
iddet ID number

Definition at line 26 of file EcalScDetId.cc.

References DetId::det(), DetId::Ecal, EcalEndcap, Exception, DetId::id_, DetId::null(), DetId::rawId(), and DetId::subdetId().

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

Member Function Documentation

void EcalScDetId::checkHashedIndexMap ( )
staticprivate

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

Definition at line 91 of file EcalScDetId.cc.

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

Referenced by hashedIndex(), and unhashIndex().

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 }
static bool validDetId(int ix, int iy, int iz)
Definition: EcalScDetId.cc:59
static EcalScDetId hashedIndex2DetId[kSizeForDenseIndexing]
Definition: EcalScDetId.h:200
static std::once_flag initializedFlag
Definition: EcalScDetId.cc:90
static const int IY_MIN
Definition: EcalScDetId.h:151
static const int IX_MIN
Definition: EcalScDetId.h:147
static const int IY_MAX
Definition: EcalScDetId.h:159
int hashedIndex() const
Definition: EcalScDetId.h:106
static const int IX_MAX
Definition: EcalScDetId.h:155
static short xyz2HashedIndex[IX_MAX][IY_MAX][nEndcaps]
Definition: EcalScDetId.h:196
uint32_t EcalScDetId::denseIndex ( ) const
inline

Same as hashed index.

Returns
the dense/hashed index

Definition at line 127 of file EcalScDetId.h.

References hashedIndex().

127 { return hashedIndex(); }
int hashedIndex() const
Definition: EcalScDetId.h:106
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.

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

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

106  {
108  if (!validDetId(ix(), iy(), zside()))
109  return -1;
110  return xyz2HashedIndex[ix() - IX_MIN][iy() - IY_MIN][zside() > 0 ? 1 : 0];
111  }
static bool validDetId(int ix, int iy, int iz)
Definition: EcalScDetId.cc:59
static const int IY_MIN
Definition: EcalScDetId.h:151
static const int IX_MIN
Definition: EcalScDetId.h:147
int ix() const
Definition: EcalScDetId.h:70
int iy() const
Definition: EcalScDetId.h:76
static void checkHashedIndexMap()
Definition: EcalScDetId.cc:91
int zside() const
Definition: EcalScDetId.h:64
static short xyz2HashedIndex[IX_MAX][IY_MAX][nEndcaps]
Definition: EcalScDetId.h:196
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.

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

Referenced by iy().

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 }
int ix() const
Definition: EcalScDetId.h:70
static const int IY_MAX
Definition: EcalScDetId.h:159
int iy() const
Definition: EcalScDetId.h:76
static const int IX_MAX
Definition: EcalScDetId.h:155
int EcalScDetId::ix ( ) const
inline
int EcalScDetId::iy ( ) const
inline
EcalScDetId & EcalScDetId::operator= ( const DetId id)

Assignment operator

Parameters
idsource det id

Definition at line 33 of file EcalScDetId.cc.

References DetId::det(), DetId::Ecal, EcalEndcap, Exception, DetId::id_, DetId::null(), DetId::rawId(), and DetId::subdetId().

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 }
uint32_t id_
Definition: DetId.h:62
EcalSubdetector EcalScDetId::subdet ( ) const
inline

Gets the subdetector

Returns
subdetectot ID, that is EcalEndcap

Definition at line 59 of file EcalScDetId.h.

References DetId::subdetId().

59 { return EcalSubdetector(subdetId()); }
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
EcalSubdetector
static EcalScDetId EcalScDetId::unhashIndex ( int  hi)
inlinestatic
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.

References kSizeForDenseIndexing.

Referenced by validHashIndex().

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.

References funct::abs().

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

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 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
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.

References validDenseIndex().

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

139 { return validDenseIndex(hi); }
static bool validDenseIndex(uint32_t din)
Definition: EcalScDetId.h:133
int EcalScDetId::zside ( ) const
inline

Member Data Documentation

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().

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.

const int EcalScDetId::IHASHED_MIN = 0
static

Lower bound for hashed/dense index

Definition at line 163 of file EcalScDetId.h.

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().

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().

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().

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().

const int EcalScDetId::nEndcaps = 2
staticprivate

Definition at line 192 of file EcalScDetId.h.

const int EcalScDetId::SC_PER_EE_CNT = 312
static

Number of supercrystals per endcap

Definition at line 143 of file EcalScDetId.h.

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().