Skip to content

Commit

Permalink
Merge pull request #27697 from bsunanda/Run3-TB40
Browse files Browse the repository at this point in the history
Run3-TB40 Correct AHCal DetId for # of row/column and apply smearing for position/time
  • Loading branch information
cmsbuild committed Aug 12, 2019
2 parents 36f4410 + b52895d commit 027ecee
Show file tree
Hide file tree
Showing 3 changed files with 315 additions and 83 deletions.
23 changes: 11 additions & 12 deletions SimG4CMS/HGCalTestBeam/plugins/AHCalDetId.cc
Expand Up @@ -9,11 +9,10 @@ AHCalDetId::AHCalDetId() : DetId() {}
AHCalDetId::AHCalDetId(uint32_t rawid) : DetId(rawid) {}

AHCalDetId::AHCalDetId(int row, int col, int depth) : DetId(Hcal, HcalOther) {
int icol = (col > 0) ? col : 10 - col;
int irow = (row > 0) ? row : 10 - row;
id_ |= (HcalDetId::kHcalIdFormat2) | ((depth & HcalDetId::kHcalDepthMask2) << HcalDetId::kHcalDepthOffset2) |
(HcalDetId::kHcalZsideMask2) | ((irow & HcalDetId::kHcalEtaMask2) << HcalDetId::kHcalEtaOffset2) |
(icol & HcalDetId::kHcalPhiMask2);
int icol = (col > 0) ? col : kMaxRowCol - col;
int irow = (row > 0) ? row : kMaxRowCol - row;
id_ |= ((depth & kHcalDepthMask) << HcalDetId::kHcalDepthOffset1) | (HcalDetId::kHcalZsideMask1) |
((irow & HcalDetId::kHcalEtaMask1) << HcalDetId::kHcalEtaOffset1) | (icol & HcalDetId::kHcalPhiMask1);
}

AHCalDetId::AHCalDetId(const DetId& gen) {
Expand All @@ -28,20 +27,20 @@ AHCalDetId::AHCalDetId(const DetId& gen) {
}

int AHCalDetId::irow() const {
int value = ((id_ >> HcalDetId::kHcalEtaOffset2) & HcalDetId::kHcalEtaMask2);
if (value >= 10)
value = -(value % 10);
int value = ((id_ >> HcalDetId::kHcalEtaOffset1) & HcalDetId::kHcalEtaMask1);
if (value >= kMaxRowCol)
value = (kMaxRowCol - value);
return value;
}

int AHCalDetId::icol() const {
int value = (id_ & HcalDetId::kHcalPhiMask2);
if (value >= 10)
value = -(value % 10);
int value = (id_ & HcalDetId::kHcalPhiMask1);
if (value >= kMaxRowCol)
value = (kMaxRowCol - value);
return value;
}

int AHCalDetId::depth() const { return ((id_ >> HcalDetId::kHcalDepthOffset2) & HcalDetId::kHcalDepthMask2); }
int AHCalDetId::depth() const { return ((id_ >> HcalDetId::kHcalDepthOffset1) & kHcalDepthMask); }

std::ostream& operator<<(std::ostream& s, const AHCalDetId& id) {
return s << "(AHCal " << id.irow() << ',' << id.icol() << ',' << id.depth() << ')';
Expand Down
8 changes: 6 additions & 2 deletions SimG4CMS/HGCalTestBeam/plugins/AHCalDetId.h
Expand Up @@ -32,14 +32,18 @@ class AHCalDetId : public DetId {
int zside() const { return 1; }
/// get the row number
int irow() const;
int irowAbs() const { return ((id_ >> HcalDetId::kHcalEtaOffset2) & HcalDetId::kHcalEtaMask2); }
int irowAbs() const { return ((id_ >> HcalDetId::kHcalEtaOffset1) & HcalDetId::kHcalEtaMask1); }
/// get the column number
int icol() const;
int icolAbs() const { return (id_ & HcalDetId::kHcalPhiMask2); }
int icolAbs() const { return (id_ & HcalDetId::kHcalPhiMask1); }
/// get the layer number
int depth() const;

static const AHCalDetId Undefined;

private:
static constexpr int kMaxRowCol = 16;
static constexpr uint32_t kHcalDepthMask = 0x3F;
};

std::ostream& operator<<(std::ostream&, const AHCalDetId& id);
Expand Down

0 comments on commit 027ecee

Please sign in to comment.