Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22585 from bsunanda/Phase2-hgx103
Phase2-hgx103 Introduce DetId definition for new HGCal cells
- Loading branch information
Showing
7 changed files
with
457 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#ifndef DataFormats_ForwardDetId_ForwardSubDetector_H | ||
#define DataFormats_ForwardDetId_ForwardSubDetector_H 1 | ||
|
||
enum ForwardSubdetector { ForwardEmpty=0, FastTime=1, BHM=2, HGCEE=3, HGCHEF=4, | ||
enum ForwardSubdetector { ForwardEmpty=0, FastTime=1, BHM=2, HGCEE=3, HGCHEF=4, | ||
HGCHEB=5, HGCHET=6, HGCTrigger=7 }; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#ifndef DataFormats_ForwardDetId_HGCScintillatorDetId_H | ||
#define DataFormats_ForwardDetId_HGCScintillatorDetId_H 1 | ||
|
||
#include <iosfwd> | ||
#include "DataFormats/DetId/interface/DetId.h" | ||
#include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h" | ||
|
||
/* \brief description of the bit assigment | ||
[0:8] iphi index wrt x-axis on +z side | ||
[9:16] |ieta| index (starting from |etamin|) | ||
[17:21] Layer # | ||
[22:22] z-side (0 for +z; 1 for -z) | ||
[23:23] Type (0 fine divisions; 1 for coarse division) | ||
[24:24] Reserved for future extension | ||
[28:31] Detector type (HGCalHSc) | ||
*/ | ||
|
||
class HGCScintillatorDetId : public DetId { | ||
|
||
public: | ||
|
||
/** Create a null cellid*/ | ||
HGCScintillatorDetId(); | ||
/** Create cellid from raw id (0=invalid tower id) */ | ||
HGCScintillatorDetId(uint32_t rawid); | ||
/** Constructor from subdetector, zplus, layer, module, cell numbers */ | ||
HGCScintillatorDetId(int type, int layer, int ieta, int iphi); | ||
/** Constructor from a generic cell id */ | ||
HGCScintillatorDetId(const DetId& id); | ||
/** Assignment from a generic cell id */ | ||
HGCScintillatorDetId& operator=(const DetId& id); | ||
|
||
/** Converter for a geometry cell id */ | ||
HGCScintillatorDetId geometryCell () const {return HGCScintillatorDetId (type(), layer(), ieta(), 0);} | ||
|
||
/// get the subdetector | ||
ForwardSubdetector subdet() const { return HGCHEB; } | ||
|
||
/// get the type | ||
int type() const { return (id_>>kHGCalTypeOffset)&kHGCalTypeMask; } | ||
|
||
/// get the z-side of the cell (1/-1) | ||
int zside() const { return (((id_>>kHGCalZsideOffset) & kHGCalZsideMask) ? -1 : 1); } | ||
|
||
/// get the layer # | ||
int layer() const { return (id_>>kHGCalLayerOffset)&kHGCalLayerMask; } | ||
|
||
/// get the eta index | ||
int ietaAbs() const { return (id_>>kHGCalEtaOffset)&kHGCalEtaMask; } | ||
int ieta() const { return zside()*ietaAbs(); } | ||
|
||
/// get the phi index | ||
int iphi() const { return (id_>>kHGCalPhiOffset)&kHGCalPhiMask; } | ||
std::pair<int,int> ietaphi() const { return std::pair<int,int>(ieta(),iphi()); } | ||
|
||
/// consistency check : no bits left => no overhead | ||
bool isEE() const { return false; } | ||
bool isHE() const { return true; } | ||
bool isForward() const { return true; } | ||
|
||
static const HGCScintillatorDetId Undefined; | ||
|
||
private: | ||
|
||
static const int kHGCalPhiOffset = 0; | ||
static const int kHGCalPhiMask = 0x1FF; | ||
static const int kHGCalEtaOffset = 9; | ||
static const int kHGCalEtaMask = 0xFF; | ||
static const int kHGCalLayerOffset = 17; | ||
static const int kHGCalLayerMask = 0x1F; | ||
static const int kHGCalZsideOffset = 22; | ||
static const int kHGCalZsideMask = 0x1; | ||
static const int kHGCalZsideMask2 = 0x400000; | ||
static const int kHGCalTypeOffset = 23; | ||
static const int kHGCalTypeMask = 0x1; | ||
}; | ||
|
||
std::ostream& operator<<(std::ostream&,const HGCScintillatorDetId& id); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
#ifndef DataFormats_ForwardDetId_HGCSiliconDetId_H | ||
#define DataFormats_ForwardDetId_HGCSiliconDetId_H 1 | ||
|
||
#include <iosfwd> | ||
#include "DataFormats/DetId/interface/DetId.h" | ||
#include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h" | ||
|
||
/* \brief description of the bit assigment | ||
[0:4] u-coordinate of the cell (measured from the lower left | ||
[5:9] v-coordinate of the cell corner of the wafer) | ||
[10:13] abs(u) of the wafer (u-axis points along -x axis) | ||
[14:14] sign of u (0:+u; 1:-u) (u=0 is at the center of beam line) | ||
[15:18] abs(v) of the wafer (v-axis points 60-degree wrt x-axis) | ||
[19:19] sign of v (0:+v; 1:-v) (v=0 is at the center of beam line) | ||
[20:24] layer number | ||
[25:25] z-side (0 for +z; 1 for -z) | ||
[26:27] Type (0 fine divisions of wafer with 120 mum thick silicon | ||
1 coarse divisions of wafer with 200 mum thick silicon | ||
2 coarse divisions of wafer with 300 mum thick silicon) | ||
[28:31] Detector type (HGCalEE or HGCalHSi) | ||
*/ | ||
class HGCSiliconDetId : public DetId { | ||
|
||
public: | ||
|
||
enum waferType {HGCalFine=0, HGCalCoarseThin=1, HGCalCoarseThick=2}; | ||
static const int HGCalFineN =12; | ||
static const int HGCalCoarseN=8; | ||
static const int HGCalFineTrigger =3; | ||
static const int HGCalCoarseTrigger=2; | ||
|
||
/** Create a null cellid*/ | ||
HGCSiliconDetId(); | ||
/** Create cellid from raw id (0=invalid tower id) */ | ||
HGCSiliconDetId(uint32_t rawid); | ||
/** Constructor from subdetector, zplus, layer, module, cell numbers */ | ||
HGCSiliconDetId(DetId::Detector det, int zp, int type, int layer, int waferU, | ||
int waferV, int cellU, int cellV); | ||
/** Constructor from a generic cell id */ | ||
HGCSiliconDetId(const DetId& id); | ||
/** Assignment from a generic cell id */ | ||
HGCSiliconDetId& operator=(const DetId& id); | ||
|
||
/** Converter for a geometry cell id */ | ||
HGCSiliconDetId geometryCell () const {return HGCSiliconDetId (det(), zside(), type(), layer(), waferU(), waferV(), 0, 0);} | ||
|
||
/// get the subdetector | ||
DetId::Detector subdet() const { return det(); } | ||
|
||
/// get the type | ||
int type() const { return (id_>>kHGCalTypeOffset)&kHGCalTypeMask; } | ||
|
||
/// get the z-side of the cell (1/-1) | ||
int zside() const { return (((id_>>kHGCalZsideOffset) & kHGCalZsideMask) ? -1 : 1); } | ||
|
||
/// get the layer # | ||
int layer() const { return (id_>>kHGCalLayerOffset)&kHGCalLayerMask; } | ||
|
||
/// get the cell #'s in u,v or in x,y | ||
int cellU() const { return (id_>>kHGCalCellUOffset)&kHGCalCellUMask; } | ||
int cellV() const { return (id_>>kHGCalCellVOffset)&kHGCalCellVMask; } | ||
std::pair<int,int> cellUV() const { return std::pair<int,int>(cellU(),cellV()); } | ||
int cellX() const { | ||
int N = (type() == HGCalFine) ? HGCalFineN : HGCalCoarseN; | ||
return (3*(cellV()-N)+2); | ||
} | ||
int cellY() const { | ||
int N = (type() == HGCalFine) ? HGCalFineN : HGCalCoarseN; | ||
return (2*cellU()-(N+cellV())); | ||
} | ||
std::pair<int,int> cellXY() const { return std::pair<int,int>(cellX(),cellY()); } | ||
|
||
/// get the wafer #'s in u,v or in x,y | ||
int waferUAbs() const { return (id_>>kHGCalWaferUOffset)&kHGCalWaferUMask; } | ||
int waferVAbs() const { return (id_>>kHGCalWaferVOffset)&kHGCalWaferVMask; } | ||
int waferU() const { return (((id_>>kHGCalWaferUSignOffset) & kHGCalWaferUSignMask) ? -waferUAbs() : waferUAbs()); } | ||
int waferV() const { return (((id_>>kHGCalWaferVSignOffset) & kHGCalWaferVSignMask) ? -waferVAbs() : waferVAbs()); } | ||
std::pair<int,int> waferUV() const { return std::pair<int,int>(waferU(),waferV()); } | ||
int waferX() const { return (-2*waferU()+waferV()); } | ||
int waferY() const { return (2*waferV()); } | ||
std::pair<int,int> waferXY() const { return std::pair<int,int>(waferX(),waferY()); } | ||
|
||
// get trigger cell u,v | ||
int triggerCellU() const { | ||
int N = (type() == HGCalFine) ? HGCalFineN : HGCalCoarseN; | ||
int NT = (type() == HGCalFine) ? HGCalFineTrigger : HGCalCoarseTrigger; | ||
return (cellU() >= N && cellV() >= N) ? cellU()/NT : | ||
((cellU() < N && cellU() <= cellV()) ? cellU()/NT : | ||
(1+(cellU()-(cellV()%NT+1))/NT)); | ||
} | ||
int triggerCellV() const { | ||
int N = (type() == HGCalFine) ? HGCalFineN : HGCalCoarseN; | ||
int NT = (type() == HGCalFine) ? HGCalFineTrigger : HGCalCoarseTrigger; | ||
return (cellU() >= N && cellV() >= N) ? cellV()/NT : | ||
((cellU() < N && cellU() <= cellV()) ? ((cellV()-cellU())/NT+cellU()/NT) : | ||
cellV()/NT); | ||
} | ||
std::pair<int,int> triggerCellUV() const { | ||
return std::pair<int,int>(triggerCellU(),triggerCellV()); | ||
} | ||
|
||
/// consistency check : no bits left => no overhead | ||
bool isEE() const { return (det() == HGCalEE); } | ||
bool isHE() const { return (det() == HGCalHSi); } | ||
bool isForward() const { return true; } | ||
|
||
static const HGCSiliconDetId Undefined; | ||
|
||
private: | ||
|
||
static const int kHGCalCellUOffset = 0; | ||
static const int kHGCalCellUMask = 0x1F; | ||
static const int kHGCalCellVOffset = 5; | ||
static const int kHGCalCellVMask = 0x1F; | ||
static const int kHGCalWaferUOffset = 10; | ||
static const int kHGCalWaferUMask = 0xF; | ||
static const int kHGCalWaferUSignOffset = 14; | ||
static const int kHGCalWaferUSignMask = 0x1; | ||
static const int kHGCalWaferVOffset = 15; | ||
static const int kHGCalWaferVMask = 0xF; | ||
static const int kHGCalWaferVSignOffset = 19; | ||
static const int kHGCalWaferVSignMask = 0x1; | ||
static const int kHGCalLayerOffset = 20; | ||
static const int kHGCalLayerMask = 0x1F; | ||
static const int kHGCalZsideOffset = 25; | ||
static const int kHGCalZsideMask = 0x1; | ||
static const int kHGCalTypeOffset = 26; | ||
static const int kHGCalTypeMask = 0x3; | ||
}; | ||
|
||
std::ostream& operator<<(std::ostream&,const HGCSiliconDetId& id); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include "DataFormats/ForwardDetId/interface/HGCScintillatorDetId.h" | ||
#include "FWCore/Utilities/interface/Exception.h" | ||
#include <ostream> | ||
#include <iostream> | ||
|
||
const HGCScintillatorDetId HGCScintillatorDetId::Undefined(0,0,0,0); | ||
|
||
HGCScintillatorDetId::HGCScintillatorDetId() : DetId() { | ||
} | ||
|
||
HGCScintillatorDetId::HGCScintillatorDetId(uint32_t rawid) : DetId(rawid) { | ||
} | ||
|
||
HGCScintillatorDetId::HGCScintillatorDetId(int type, int layer, int eta, | ||
int phi) : DetId(HGCalHSc,HGCHEB) { | ||
|
||
id_ |= ((type&kHGCalTypeMask)<<kHGCalTypeOffset) | | ||
((layer&kHGCalLayerMask)<<kHGCalLayerOffset) | | ||
((eta<0)?(kHGCalZsideMask2|(-eta<<kHGCalEtaOffset)):(eta<<kHGCalEtaOffset)) | | ||
((phi&kHGCalPhiMask)<<kHGCalPhiOffset); | ||
} | ||
|
||
HGCScintillatorDetId::HGCScintillatorDetId(const DetId& gen) { | ||
if (!gen.null()) { | ||
if ((gen.det()!=HGCalHSc) || | ||
(ForwardSubdetector)(gen.subdetId()!=HGCHEB)) { | ||
throw cms::Exception("Invalid DetId") << "Cannot initialize HGCScintillatorDetId from " << std::hex << gen.rawId() << std::dec; | ||
} | ||
} | ||
id_ = gen.rawId(); | ||
} | ||
|
||
HGCScintillatorDetId& HGCScintillatorDetId::operator=(const DetId& gen) { | ||
if (!gen.null()) { | ||
if ((gen.det()!=HGCalHSc) || | ||
(ForwardSubdetector)(gen.subdetId()!=HGCHEB)) { | ||
throw cms::Exception("Invalid DetId") << "Cannot assign HGCScintillatorDetId from " << std::hex << gen.rawId() << std::dec; | ||
} | ||
} | ||
id_ = gen.rawId(); | ||
return (*this); | ||
} | ||
|
||
std::ostream& operator<<(std::ostream& s,const HGCScintillatorDetId& id) { | ||
return s << " EE:HE= " << id.isEE() << ":" << id.isHE() | ||
<< " type= " << id.type() << " layer= " << id.layer() | ||
<< " eta= " << id.ieta() << " phi= " << id.iphi(); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#include "DataFormats/ForwardDetId/interface/HGCSiliconDetId.h" | ||
#include "FWCore/Utilities/interface/Exception.h" | ||
#include <ostream> | ||
#include <iostream> | ||
|
||
const HGCSiliconDetId HGCSiliconDetId::Undefined(HGCalEE,0,0,0,0,0,0,0); | ||
|
||
HGCSiliconDetId::HGCSiliconDetId() : DetId() { | ||
} | ||
|
||
HGCSiliconDetId::HGCSiliconDetId(uint32_t rawid) : DetId(rawid) { | ||
} | ||
|
||
HGCSiliconDetId::HGCSiliconDetId(DetId::Detector det, int zp, int type, | ||
int layer, int waferU, int waferV, int cellU, | ||
int cellV) : DetId(det,ForwardEmpty) { | ||
|
||
int waferUabs(std::abs(waferU)), waferVabs(std::abs(waferV)); | ||
int waferUsign = (waferU >= 0) ? 0 : 1; | ||
int waferVsign = (waferV >= 0) ? 0 : 1; | ||
int zside = (zp < 0) ? 1 : 0; | ||
id_ |= ((cellU & kHGCalCellUMask) << kHGCalCellUOffset); | ||
id_ |= ((cellV & kHGCalCellVMask) << kHGCalCellVOffset); | ||
id_ |= ((waferUabs & kHGCalWaferUMask) << kHGCalWaferUOffset); | ||
id_ |= ((waferUsign& kHGCalWaferUSignMask) << kHGCalWaferUSignOffset); | ||
id_ |= ((waferVabs & kHGCalWaferVMask) << kHGCalWaferVOffset); | ||
id_ |= ((waferVsign& kHGCalWaferVSignMask) << kHGCalWaferVSignOffset); | ||
id_ |= ((layer & kHGCalLayerMask) << kHGCalLayerOffset); | ||
id_ |= ((zside & kHGCalZsideMask) << kHGCalZsideOffset); | ||
id_ |= ((type & kHGCalTypeMask) << kHGCalTypeOffset); | ||
} | ||
|
||
HGCSiliconDetId::HGCSiliconDetId(const DetId& gen) { | ||
if (!gen.null()) { | ||
if ((gen.det()!=HGCalEE) && (gen.det()!=HGCalHSi)) { | ||
throw cms::Exception("Invalid DetId") << "Cannot initialize HGCSiliconDetId from " << std::hex << gen.rawId() << std::dec; | ||
} | ||
} | ||
id_ = gen.rawId(); | ||
} | ||
|
||
HGCSiliconDetId& HGCSiliconDetId::operator=(const DetId& gen) { | ||
if (!gen.null()) { | ||
if ((gen.det()!=HGCalEE) && (gen.det()!=HGCalHSi)) { | ||
throw cms::Exception("Invalid DetId") << "Cannot assign HGCSiliconDetId from " << std::hex << gen.rawId() << std::dec; | ||
} | ||
} | ||
id_ = gen.rawId(); | ||
return (*this); | ||
} | ||
|
||
std::ostream& operator<<(std::ostream& s,const HGCSiliconDetId& id) { | ||
return s << " EE:HE= " << id.isEE() << ":" << id.isHE() | ||
<< " type= " << id.type() << " z= " << id.zside() | ||
<< " layer= " << id.layer() | ||
<< " wafer(u,v:x,y)= (" << id.waferU() << "," << id.waferV() << ":" | ||
<< id.waferX() << "," << id.waferY() << ")" | ||
<< " cell(u,v:x,y)= (" << id.cellU() << "," << id.cellV() << ":" | ||
<< id.cellX() << "," << id.cellY() << ")"; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<use name="DataFormats/ForwardDetId"/> | ||
<bin file="testHGCDetId.cc"> | ||
</bin> |
Oops, something went wrong.