-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also define Trigger DetId class for HFNose
- Loading branch information
Sunanda
committed
Aug 23, 2019
1 parent
ef142d9
commit 9f5cb2a
Showing
8 changed files
with
285 additions
and
3 deletions.
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
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
109 changes: 109 additions & 0 deletions
109
DataFormats/ForwardDetId/interface/HFNoseTriggerDetId.h
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,109 @@ | ||
#ifndef DataFormats_ForwardDetId_HFNoseTriggerDetId_H | ||
#define DataFormats_ForwardDetId_HFNoseTriggerDetId_H 1 | ||
|
||
#include <iosfwd> | ||
#include <vector> | ||
#include "DataFormats/DetId/interface/DetId.h" | ||
#include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h" | ||
|
||
/* \brief description of the bit assigment | ||
[0:3] u-coordinate of the cell (measured from the lower left | ||
[4:7] v-coordinate of the cell corner of the wafer) | ||
[8:11] abs(u) of the wafer (u-axis points along -x axis) | ||
[12:12] sign of u (0:+u; 1:-u) (u=0 is at the center of beam line) | ||
[13:16] abs(v) of the wafer (v-axis points 60-degree wrt x-axis) | ||
[17:17] sign of v (0:+v; 1:-v) (v=0 is at the center of beam line) | ||
[18:22] layer number | ||
[23:24] 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) | ||
[25:26] Subdetector Type (HFNoseTrigger) | ||
[27:27] z-side (0 for +z; 1 for -z) | ||
[28:31] Detector type (HGCalTrigger) | ||
*/ | ||
|
||
class HFNoseTriggerDetId : public DetId { | ||
public: | ||
static const int HFNoseTriggerCell = 4; | ||
|
||
/** Create a null cellid*/ | ||
HFNoseTriggerDetId(); | ||
/** Create cellid from raw id (0=invalid tower id) */ | ||
HFNoseTriggerDetId(uint32_t rawid); | ||
/** Constructor from subdetector, zplus, layer, module, cell numbers */ | ||
HFNoseTriggerDetId(int subdet, int zp, int type, int layer, int waferU, int waferV, int cellU, int cellV); | ||
/** Constructor from a generic cell id */ | ||
HFNoseTriggerDetId(const DetId& id); | ||
/** Assignment from a generic cell id */ | ||
HFNoseTriggerDetId& operator=(const DetId& id); | ||
|
||
/// get the subdetector | ||
HGCalTriggerSubdetector subdet() const { | ||
return (HGCalTriggerSubdetector)((id_ >> kHFNoseSubdetOffset) & kHFNoseSubdetMask); | ||
} | ||
|
||
/// get the type | ||
int type() const { return (id_ >> kHFNoseTypeOffset) & kHFNoseTypeMask; } | ||
|
||
/// get the z-side of the cell (1/-1) | ||
int zside() const { return (((id_ >> kHFNoseZsideOffset) & kHFNoseZsideMask) ? -1 : 1); } | ||
|
||
/// get the layer # | ||
int layer() const { return (id_ >> kHFNoseLayerOffset) & kHFNoseLayerMask; } | ||
|
||
/// get the cell #'s in u,v or in x,y | ||
int triggerCellU() const { return (id_ >> kHFNoseCellUOffset) & kHFNoseCellUMask; } | ||
int triggerCellV() const { return (id_ >> kHFNoseCellVOffset) & kHFNoseCellVMask; } | ||
std::pair<int, int> triggerCellUV() const { return std::pair<int, int>(triggerCellU(), triggerCellV()); } | ||
int triggerCellX() const; | ||
int triggerCellY() const; | ||
std::pair<int, int> triggerCellXY() const { return std::pair<int, int>(triggerCellX(), triggerCellY()); } | ||
|
||
/// get the wafer #'s in u,v or in x,y | ||
int waferUAbs() const { return (id_ >> kHFNoseWaferUOffset) & kHFNoseWaferUMask; } | ||
int waferVAbs() const { return (id_ >> kHFNoseWaferVOffset) & kHFNoseWaferVMask; } | ||
int waferU() const { return (((id_ >> kHFNoseWaferUSignOffset) & kHFNoseWaferUSignMask) ? -waferUAbs() : waferUAbs()); } | ||
int waferV() const { return (((id_ >> kHFNoseWaferVSignOffset) & kHFNoseWaferVSignMask) ? -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 | ||
std::vector<int> cellU() const; | ||
std::vector<int> cellV() const; | ||
std::vector<std::pair<int, int> > cellUV() const; | ||
|
||
/// consistency check : no bits left => no overhead | ||
bool isEE() const { return (layer() <= kHFNoseMaxEELayer); } | ||
bool isHSilicon() const { return (layer() > kHFNoseMaxEELayer); } | ||
bool isForward() const { return true; } | ||
|
||
static const HFNoseTriggerDetId Undefined; | ||
|
||
static const int kHFNoseCellUOffset = 0; | ||
static const int kHFNoseCellUMask = 0xF; | ||
static const int kHFNoseCellVOffset = 4; | ||
static const int kHFNoseCellVMask = 0xF; | ||
static const int kHFNoseWaferUOffset = 8; | ||
static const int kHFNoseWaferUMask = 0xF; | ||
static const int kHFNoseWaferUSignOffset = 12; | ||
static const int kHFNoseWaferUSignMask = 0x1; | ||
static const int kHFNoseWaferVOffset = 13; | ||
static const int kHFNoseWaferVMask = 0xF; | ||
static const int kHFNoseWaferVSignOffset = 17; | ||
static const int kHFNoseWaferVSignMask = 0x1; | ||
static const int kHFNoseLayerOffset = 18; | ||
static const int kHFNoseLayerMask = 0x1F; | ||
static const int kHFNoseTypeOffset = 23; | ||
static const int kHFNoseTypeMask = 0x3; | ||
static const int kHFNoseZsideOffset = 27; | ||
static const int kHFNoseZsideMask = 0x1; | ||
static const int kHFNoseSubdetOffset = 25; | ||
static const int kHFNoseSubdetMask = 0x3; | ||
static const int kHFNoseMaxEELayer = 6; | ||
}; | ||
|
||
std::ostream& operator<<(std::ostream&, const HFNoseTriggerDetId& 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
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,151 @@ | ||
#include "DataFormats/ForwardDetId/interface/HFNoseTriggerDetId.h" | ||
#include "DataFormats/ForwardDetId/interface/HFNoseDetId.h" | ||
#include "FWCore/Utilities/interface/Exception.h" | ||
#include <ostream> | ||
#include <iostream> | ||
|
||
const HFNoseTriggerDetId HFNoseTriggerDetId::Undefined(HFNoseTrigger, 0, 0, 0, 0, 0, 0, 0); | ||
|
||
HFNoseTriggerDetId::HFNoseTriggerDetId() : DetId() {} | ||
|
||
HFNoseTriggerDetId::HFNoseTriggerDetId(uint32_t rawid) : DetId(rawid) {} | ||
|
||
HFNoseTriggerDetId::HFNoseTriggerDetId( | ||
int subdet, int zp, int type, int layer, int waferU, int waferV, int cellU, int cellV) | ||
: DetId(HGCalTrigger, 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 & kHFNoseCellUMask) << kHFNoseCellUOffset) | ((cellV & kHFNoseCellVMask) << kHFNoseCellVOffset) | | ||
((waferUabs & kHFNoseWaferUMask) << kHFNoseWaferUOffset) | | ||
((waferUsign & kHFNoseWaferUSignMask) << kHFNoseWaferUSignOffset) | | ||
((waferVabs & kHFNoseWaferVMask) << kHFNoseWaferVOffset) | | ||
((waferVsign & kHFNoseWaferVSignMask) << kHFNoseWaferVSignOffset) | | ||
((layer & kHFNoseLayerMask) << kHFNoseLayerOffset) | ((zside & kHFNoseZsideMask) << kHFNoseZsideOffset) | | ||
((type & kHFNoseTypeMask) << kHFNoseTypeOffset) | ((subdet & kHFNoseSubdetMask) << kHFNoseSubdetOffset)); | ||
} | ||
|
||
HFNoseTriggerDetId::HFNoseTriggerDetId(const DetId& gen) { | ||
if (!gen.null()) { | ||
if ((gen.det() != HGCalTrigger) || ((gen.subdetId() & kHFNoseSubdetMask) != HFNoseTrigger)) { | ||
throw cms::Exception("Invalid DetId") | ||
<< "Cannot initialize HFNoseTriggerDetId from " << std::hex << gen.rawId() << std::dec; | ||
} | ||
} | ||
id_ = gen.rawId(); | ||
} | ||
|
||
HFNoseTriggerDetId& HFNoseTriggerDetId::operator=(const DetId& gen) { | ||
if (!gen.null()) { | ||
if ((gen.det() != HGCalTrigger) || ((gen.subdetId() & kHFNoseSubdetMask) != HFNoseTrigger)) { | ||
throw cms::Exception("Invalid DetId") | ||
<< "Cannot assign HFNoseTriggerDetId from " << std::hex << gen.rawId() << std::dec; | ||
} | ||
} | ||
id_ = gen.rawId(); | ||
return (*this); | ||
} | ||
|
||
int HFNoseTriggerDetId::triggerCellX() const { | ||
int nT = | ||
(type() == HFNoseDetId::HFNoseFine) ? HFNoseDetId::HFNoseFineTrigger : HFNoseDetId::HFNoseCoarseTrigger; | ||
int N = nT * HFNoseTriggerCell; | ||
std::vector<int> vc = cellV(); | ||
int x(0); | ||
for (auto const& v : vc) { | ||
x += (3 * (v - N) + 2); | ||
} | ||
return (x / vc.size()); | ||
} | ||
|
||
int HFNoseTriggerDetId::triggerCellY() const { | ||
int nT = | ||
(type() == HFNoseDetId::HFNoseFine) ? HFNoseDetId::HFNoseFineTrigger : HFNoseDetId::HFNoseCoarseTrigger; | ||
int N = nT * HFNoseTriggerCell; | ||
std::vector<int> uc = cellU(); | ||
std::vector<int> vc = cellV(); | ||
int y(0); | ||
for (unsigned int k = 0; k < uc.size(); ++k) { | ||
y += (2 * uc[k] - (N + vc[k])); | ||
} | ||
return (y / vc.size()); | ||
} | ||
|
||
std::vector<int> HFNoseTriggerDetId::cellU() const { | ||
std::vector<int> uc; | ||
int nT = | ||
(type() == HFNoseDetId::HFNoseFine) ? HFNoseDetId::HFNoseFineTrigger : HFNoseDetId::HFNoseCoarseTrigger; | ||
if ((triggerCellU() >= HFNoseTriggerCell) && (triggerCellV() >= HFNoseTriggerCell)) { | ||
int u0 = nT * triggerCellU(); | ||
for (int i = 0; i < nT; ++i) { | ||
for (int j = 0; j < nT; ++j) { | ||
uc.emplace_back(u0 + i); | ||
} | ||
} | ||
} else if ((triggerCellU() < HFNoseTriggerCell) && (triggerCellU() <= triggerCellV())) { | ||
int u0 = nT * triggerCellU(); | ||
for (int i = 0; i < nT; ++i) { | ||
for (int j = 0; j < nT; ++j) { | ||
uc.emplace_back(u0 + i); | ||
} | ||
} | ||
} else { | ||
int u0 = nT * (triggerCellU() - 1) + 1; | ||
for (int i = 0; i < nT; ++i) { | ||
for (int j = 0; j < nT; ++j) { | ||
uc.emplace_back(u0 + j); | ||
} | ||
++u0; | ||
} | ||
} | ||
return uc; | ||
} | ||
|
||
std::vector<int> HFNoseTriggerDetId::cellV() const { | ||
std::vector<int> vc; | ||
int nT = | ||
(type() == HFNoseDetId::HFNoseFine) ? HFNoseDetId::HFNoseFineTrigger : HFNoseDetId::HFNoseCoarseTrigger; | ||
if ((triggerCellU() >= HFNoseTriggerCell) && (triggerCellV() >= HFNoseTriggerCell)) { | ||
int v0 = nT * triggerCellV(); | ||
for (int i = 0; i < nT; ++i) { | ||
for (int j = 0; j < nT; ++j) { | ||
vc.emplace_back(v0 + j); | ||
} | ||
} | ||
} else if ((triggerCellU() < HFNoseTriggerCell) && (triggerCellU() <= triggerCellV())) { | ||
int v0 = nT * triggerCellV(); | ||
for (int i = 0; i < nT; ++i) { | ||
for (int j = 0; j < nT; ++j) { | ||
vc.emplace_back(v0 + j); | ||
} | ||
++v0; | ||
} | ||
} else { | ||
int v0 = nT * triggerCellV(); | ||
for (int i = 0; i < nT; ++i) { | ||
for (int j = 0; j < nT; ++j) { | ||
vc.emplace_back(v0 + i); | ||
} | ||
} | ||
} | ||
return vc; | ||
} | ||
|
||
std::vector<std::pair<int, int> > HFNoseTriggerDetId::cellUV() const { | ||
std::vector<int> uc = cellU(); | ||
std::vector<int> vc = cellV(); | ||
std::vector<std::pair<int, int> > uv; | ||
for (unsigned int k = 0; k < uc.size(); ++k) { | ||
uv.emplace_back(std::pair<int, int>(uc[k], vc[k])); | ||
} | ||
return uv; | ||
} | ||
|
||
std::ostream& operator<<(std::ostream& s, const HFNoseTriggerDetId& id) { | ||
return s << " EE:HSil= " << id.isEE() << ":" << id.isHSilicon() << " type= " << id.type() << " z= " << id.zside() | ||
<< " layer= " << id.layer() << " wafer(u,v:x,y)= (" << id.waferU() << "," << id.waferV() << ":" | ||
<< id.waferX() << "," << id.waferY() << ")" | ||
<< " triggerCell(u,v:x,y)= (" << id.triggerCellU() << "," << id.triggerCellV() << ":" << id.triggerCellX() | ||
<< "," << id.triggerCellY() << ")"; | ||
} |
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
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
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