Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HGCal trigger] Remove deprecated v8 geometry code + Add new trigger geometry class #34608

Merged
merged 5 commits into from Aug 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,6 @@
#ifndef DataFormats_ForwardDetId_HGCalTriggerBackendCommon_H
#define DataFormats_ForwardDetId_HGCalTriggerBackendCommon_H 1

enum HGCalTriggerClassIdentifier { ModuleDetId, BackendDetId };

#endif
76 changes: 76 additions & 0 deletions DataFormats/ForwardDetId/interface/HGCalTriggerBackendDetId.h
@@ -0,0 +1,76 @@
#ifndef DataFormats_ForwardDetId_HGCalTriggerBackendDetId_H
#define DataFormats_ForwardDetId_HGCalTriggerBackendDetId_H 1

#include "DataFormats/DetId/interface/DetId.h"
#include "DataFormats/ForwardDetId/interface/HGCalTriggerBackendCommon.h"
#include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h"

/* \brief description of the bit assigment
[0:10] ID of the lpGBT or Stage 1 FPGA in sector 0
[11:12] sector (0,1,2 counter-clockwise from u-axis)
[13:15] Type (0 lpGBT
1 Stage 1 FPGA
2 Stage 1 link
3 Stage 2 FPGA)
[16:16] z-side (0 for +z; 1 for -z)
[19:23] reserved for future use
[24:24] Class identifier (0 for HGCalTriggerModuleDetID, 1 for HGCalTriggerBackendDetID)
[25:27] Subdetector Type (HGCTrigger)
[28:31] Detector type (Forward)
*/

class HGCalTriggerBackendDetId : public DetId {
public:
/** Create a null backend id*/
HGCalTriggerBackendDetId();
/** Create backend id from raw id (0=invalid id) */
HGCalTriggerBackendDetId(uint32_t rawid);
/** Constructor from zplus, type, sector, label */
HGCalTriggerBackendDetId(int zp, int type, int sector, int label);
/** Constructor from a generic det id */
HGCalTriggerBackendDetId(const DetId& id);
/** Assignment from a generic det id */
HGCalTriggerBackendDetId& operator=(const DetId& id);

/// get the class
int classId() const { return (id_ >> kHGCalTriggerClassIdentifierOffset) & kHGCalTriggerClassIdentifierMask; }

/// get the type
int type() const { return (id_ >> kHGCalTypeOffset) & kHGCalTypeMask; }

/// get the z-side of the backend object (1/-1)
int zside() const { return ((id_ >> kHGCalZsideOffset) & kHGCalZsideMask ? -1 : 1); }

/// get the sector #
int sector() const { return (id_ >> kHGCalSectorOffset) & kHGCalSectorMask; }

/// get the value
int label() const { return (id_ >> kHGCalLabelOffset) & kHGCalLabelMask; }

bool isLpGBT() const { return (type() == BackendType::LpGBT); }
bool isStage1FPGA() const { return (type() == BackendType::Stage1FPGA); }
bool isStage1Link() const { return (type() == BackendType::Stage1Link); }
bool isStage2FPGA() const { return (type() == BackendType::Stage2FPGA); }
bool isForward() const { return true; }
bool isHGCalModuleDetId() const { return (classId() == HGCalTriggerClassIdentifier::ModuleDetId); }
bool isHGCalBackendDetId() const { return (classId() == HGCalTriggerClassIdentifier::BackendDetId); }

static const HGCalTriggerBackendDetId Undefined;

static const int kHGCalLabelOffset = 0;
static const int kHGCalLabelMask = 0x7FF;
static const int kHGCalSectorOffset = 11;
static const int kHGCalSectorMask = 0x3;
static const int kHGCalTypeOffset = 13;
static const int kHGCalTypeMask = 0x7;
static const int kHGCalZsideOffset = 16;
static const int kHGCalZsideMask = 0x1;
static const int kHGCalTriggerClassIdentifierOffset = 24;
static const int kHGCalTriggerClassIdentifierMask = 0x1;

enum BackendType { LpGBT, Stage1FPGA, Stage1Link, Stage2FPGA };
};

std::ostream& operator<<(std::ostream&, const HGCalTriggerBackendDetId& id);

#endif
107 changes: 107 additions & 0 deletions DataFormats/ForwardDetId/interface/HGCalTriggerModuleDetId.h
@@ -0,0 +1,107 @@
#ifndef DataFormats_ForwardDetId_HGCalTriggerModuleDetId_H
#define DataFormats_ForwardDetId_HGCalTriggerModuleDetId_H 1

#include "DataFormats/DetId/interface/DetId.h"
#include "DataFormats/ForwardDetId/interface/HGCalTriggerBackendCommon.h"
#include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h"

/* \brief description of the bit assigment
[0:3] u-coordinate of the silicon module (u-axis points along -x axis)
or eta-coordinate of the scintillator module
[4:7] v-coordinate of the silicon module (v-axis points 60-degree wrt x-axis)
or phi-coordinate of the scintillator module
[8:9] sector (0,1,2 counter-clockwise from u-axis)

[10:13] reserved for future use

[14:18] layer number
[19:20] 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
0 fine divisions of scintillators
1 coarse divisions of scintillators)

[21:21] z-side (0 for +z; 1 for -z)
[22:23] Trigger Subdetector Type(HGCEE/HGCHEF/HGCHEB/HFNose)
[24:24] Class identifier (0 for HGCalTriggerModuleDetID, 1 for HGCalTriggerBackendDetID)
[25:27] Subdetector Type (HGCTrigger)
[28:31] Detector type (Forward)
*/

class HGCalTriggerModuleDetId : public DetId {
public:
/** Create a null module id*/
HGCalTriggerModuleDetId();
/** Create module id from raw id (0=invalid id) */
HGCalTriggerModuleDetId(uint32_t rawid);
/** Constructor from subdetector, zplus, type, layer, sector, module numbers */
HGCalTriggerModuleDetId(
HGCalTriggerSubdetector subdet, int zp, int type, int layer, int sector, int moduleU, int moduleV);
/** Constructor from a generic det id */
HGCalTriggerModuleDetId(const DetId& id);
/** Assignment from a generic det id */
HGCalTriggerModuleDetId& operator=(const DetId& id);

/// get the trigger sub-detector
int triggerSubdetId() const { return (id_ >> kHGCalTriggerSubdetOffset) & kHGCalTriggerSubdetMask; }

/// get the class
int classId() const { return (id_ >> kHGCalTriggerClassIdentifierOffset) & kHGCalTriggerClassIdentifierMask; }

/// get the type
int type() const { return (id_ >> kHGCalTypeOffset) & kHGCalTypeMask; }

/// get the z-side of the module (1/-1)
int zside() const { return ((id_ >> kHGCalZsideOffset) & kHGCalZsideMask ? -1 : 1); }

/// get the layer #
int layer() const { return (id_ >> kHGCalLayerOffset) & kHGCalLayerMask; }

/// get the sector #
int sector() const { return (id_ >> kHGCalSectorOffset) & kHGCalSectorMask; }

/// get the module U
int moduleU() const { return (id_ >> kHGCalModuleUOffset) & kHGCalModuleUMask; }

/// get the module V
int moduleV() const { return (id_ >> kHGCalModuleVOffset) & kHGCalModuleVMask; }

/// get the scintillator panel eta
int eta() const { return moduleU(); }

/// get the scintillator panel phi
int phi() const { return moduleV(); }

/// consistency check : no bits left => no overhead
bool isHFNose() const { return (triggerSubdetId() == HFNoseTrigger); }
bool isEE() const { return (triggerSubdetId() == HGCalEETrigger); }
bool isHSilicon() const { return (triggerSubdetId() == HGCalHSiTrigger); }
bool isHScintillator() const { return (triggerSubdetId() == HGCalHScTrigger); }
bool isForward() const { return true; }
bool isHGCTrigger() const { return true; }
bool isHGCalModuleDetId() const { return (classId() == HGCalTriggerClassIdentifier::ModuleDetId); }
bool isHGCalBackendDetId() const { return (classId() == HGCalTriggerClassIdentifier::BackendDetId); }

static const HGCalTriggerModuleDetId Undefined;

static const int kHGCalModuleUOffset = 0;
static const int kHGCalModuleUMask = 0xF;
static const int kHGCalModuleVOffset = 4;
static const int kHGCalModuleVMask = 0xF;
static const int kHGCalSectorOffset = 8;
static const int kHGCalSectorMask = 0x3;
static const int kHGCalLayerOffset = 14;
static const int kHGCalLayerMask = 0x1F;
static const int kHGCalTypeOffset = 19;
static const int kHGCalTypeMask = 0x3;
static const int kHGCalZsideOffset = 24;
static const int kHGCalZsideMask = 0x1;
static const int kHGCalTriggerSubdetOffset = 22;
static const int kHGCalTriggerSubdetMask = 0x3;
static const int kHGCalTriggerClassIdentifierOffset = 24;
static const int kHGCalTriggerClassIdentifierMask = 0x1;
};

std::ostream& operator<<(std::ostream&, const HGCalTriggerModuleDetId& id);

#endif
43 changes: 43 additions & 0 deletions DataFormats/ForwardDetId/src/HGCalTriggerBackendDetId.cc
@@ -0,0 +1,43 @@
#include "DataFormats/ForwardDetId/interface/HGCalTriggerBackendDetId.h"
#include "FWCore/Utilities/interface/Exception.h"
#include <iostream>

HGCalTriggerBackendDetId::HGCalTriggerBackendDetId() : DetId() {}

HGCalTriggerBackendDetId::HGCalTriggerBackendDetId(uint32_t rawid) : DetId(rawid) {}

HGCalTriggerBackendDetId::HGCalTriggerBackendDetId(int zp, int type, int sector, int label)
: DetId(Forward, HGCTrigger) {
int classid = HGCalTriggerClassIdentifier::ModuleDetId;
int zside = (zp < 0) ? 1 : 0;
id_ |= (((label & kHGCalLabelMask) << kHGCalLabelOffset) | ((sector & kHGCalSectorMask) << kHGCalSectorOffset) |
((zside & kHGCalZsideMask) << kHGCalZsideOffset) | ((type & kHGCalTypeMask) << kHGCalTypeOffset) |
((classid & kHGCalTriggerClassIdentifierMask) << kHGCalTriggerClassIdentifierOffset));
}

HGCalTriggerBackendDetId::HGCalTriggerBackendDetId(const DetId& gen) {
if (!gen.null()) {
if (gen.det() != Forward) {
throw cms::Exception("Invalid DetId")
<< "Cannot initialize HGCalTriggerBackendDetId from " << std::hex << gen.rawId() << std::dec;
}
}
id_ = gen.rawId();
}

HGCalTriggerBackendDetId& HGCalTriggerBackendDetId::operator=(const DetId& gen) {
if (!gen.null()) {
if (gen.det() != Forward) {
throw cms::Exception("Invalid DetId")
<< "Cannot assign HGCalTriggerBackendDetId from " << std::hex << gen.rawId() << std::dec;
}
}
id_ = gen.rawId();
return (*this);
}

std::ostream& operator<<(std::ostream& s, const HGCalTriggerBackendDetId& id) {
return s << "HGCalTriggerBackendDetId::lpGBT:Stage1 FPGA:Stage2 FPGA= " << id.isLpGBT() << ":" << id.isStage1FPGA()
<< ":" << id.isStage1Link() << ":" << id.isStage2FPGA() << " z= " << id.zside() << " sector= " << id.sector()
<< " id= " << id.label();
}
49 changes: 49 additions & 0 deletions DataFormats/ForwardDetId/src/HGCalTriggerModuleDetId.cc
@@ -0,0 +1,49 @@
#include "DataFormats/ForwardDetId/interface/HGCalTriggerModuleDetId.h"
#include "FWCore/Utilities/interface/Exception.h"
#include <iostream>

HGCalTriggerModuleDetId::HGCalTriggerModuleDetId() : DetId() {}

HGCalTriggerModuleDetId::HGCalTriggerModuleDetId(uint32_t rawid) : DetId(rawid) {}

HGCalTriggerModuleDetId::HGCalTriggerModuleDetId(
HGCalTriggerSubdetector subdet, int zp, int type, int layer, int sector, int moduleU, int moduleV)
: DetId(Forward, HGCTrigger) {
int classid = HGCalTriggerClassIdentifier::ModuleDetId;
int zside = (zp < 0) ? 1 : 0;

id_ |=
(((moduleU & kHGCalModuleUMask) << kHGCalModuleUOffset) | ((moduleV & kHGCalModuleVMask) << kHGCalModuleVOffset) |
((sector & kHGCalSectorMask) << kHGCalSectorOffset) | ((layer & kHGCalLayerMask) << kHGCalLayerOffset) |
((zside & kHGCalZsideMask) << kHGCalZsideOffset) | ((type & kHGCalTypeMask) << kHGCalTypeOffset) |
((subdet & kHGCalTriggerSubdetMask) << kHGCalTriggerSubdetOffset) |
((classid & kHGCalTriggerClassIdentifierMask) << kHGCalTriggerClassIdentifierOffset));
}

HGCalTriggerModuleDetId::HGCalTriggerModuleDetId(const DetId& gen) {
if (!gen.null()) {
if (gen.det() != Forward) {
throw cms::Exception("Invalid DetId")
<< "Cannot initialize HGCalTriggerModuleDetId from " << std::hex << gen.rawId() << std::dec;
}
}
id_ = gen.rawId();
}

HGCalTriggerModuleDetId& HGCalTriggerModuleDetId::operator=(const DetId& gen) {
if (!gen.null()) {
if (gen.det() != Forward) {
throw cms::Exception("Invalid DetId")
<< "Cannot assign HGCalTriggerModuleDetId from " << std::hex << gen.rawId() << std::dec;
}
}
id_ = gen.rawId();
return (*this);
}

std::ostream& operator<<(std::ostream& s, const HGCalTriggerModuleDetId& id) {
return s << "HGCalTriggerModuleDetId::HFNose:EE:HSil:HScin= " << id.isHFNose() << ":" << id.isEE() << ":"
<< id.isHSilicon() << ":" << id.isHScintillator() << " type= " << id.type() << " z= " << id.zside()
<< " layer= " << id.layer() << " sector= " << id.sector() << " module(u,v)= (" << id.moduleU() << ","
<< id.moduleV() << ")";
}
7 changes: 2 additions & 5 deletions DataFormats/L1THGCal/interface/HGCalClusterT.h
Expand Up @@ -7,7 +7,6 @@
#include "DataFormats/L1Trigger/interface/L1Candidate.h"
#include "DataFormats/L1THGCal/interface/HGCalTriggerCell.h"
#include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h"
#include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
#include "DataFormats/ForwardDetId/interface/HGCalTriggerDetId.h"
#include "DataFormats/ForwardDetId/interface/HFNoseTriggerDetId.h"

Expand Down Expand Up @@ -110,17 +109,15 @@ namespace l1t {
DetId id(id_constituent.first);
auto id_fraction = constituentsFraction_.find(id_constituent.first);
double fraction = (id_fraction != constituentsFraction_.end() ? id_fraction->second : 1.);
if ((id.det() == DetId::Forward && id.subdetId() == HGCEE) || (id.det() == DetId::HGCalEE) ||
if ((id.det() == DetId::HGCalEE) ||
(id.det() == DetId::HGCalTrigger &&
HGCalTriggerDetId(id).subdet() == HGCalTriggerSubdetector::HGCalEETrigger) ||
(id.det() == DetId::Forward && id.subdetId() == ForwardSubdetector::HFNose && HFNoseDetId(id).isEE()) ||
(id.det() == DetId::HGCalTrigger &&
HGCalTriggerDetId(id).subdet() == HGCalTriggerSubdetector::HFNoseTrigger &&
HFNoseTriggerDetId(id).isEE())) {
pt_em += id_constituent.second->pt() * fraction;
} else if ((id.det() == DetId::Forward && id.subdetId() == HGCHEF) ||
(id.det() == DetId::Hcal && id.subdetId() == HcalEndcap) || (id.det() == DetId::HGCalHSi) ||
(id.det() == DetId::HGCalHSc) ||
} else if ((id.det() == DetId::HGCalHSi) || (id.det() == DetId::HGCalHSc) ||
(id.det() == DetId::HGCalTrigger &&
HGCalTriggerDetId(id).subdet() == HGCalTriggerSubdetector::HGCalHSiTrigger) ||
(id.det() == DetId::Forward && id.subdetId() == ForwardSubdetector::HFNose &&
Expand Down
1 change: 1 addition & 0 deletions L1Trigger/L1THGCal/BuildFile.xml
Expand Up @@ -6,6 +6,7 @@
<use name="Geometry/HcalTowerAlgo"/>
<use name="SimDataFormats/CaloTest"/>
<use name="PhysicsTools/TensorFlow" />
<use name="json" />
<export>
<lib name="1"/>
</export>
Expand Down
34 changes: 14 additions & 20 deletions L1Trigger/L1THGCal/interface/HGCalCoarseTriggerCellMapping.h
Expand Up @@ -24,28 +24,22 @@ class HGCalCoarseTriggerCellMapping {

private:
static const std::map<int, int> kSplit_;
static const std::map<int, int> kSplit_v9_;
static const std::map<int, int> kSplit_v9_Scin_;
static constexpr int kSTCidMaskInv_ = ~0x3f;
static constexpr int kSTCidMaskInv_v9_ = ~0xf;
static constexpr int kSplit_v8_Coarse_ = 0x30;
static constexpr int kSplit_v8_Mid_ = 0x38;
static constexpr int kSplit_v8_Fine_ = 0x3a;
static constexpr int kSplit_v8_VeryFine_ = 0x3e;
static constexpr int kSplit_v8_Individual_ = 0x3f;
static const std::map<int, int> kSplit_Scin_;
static constexpr int kSTCidMaskInv_ = ~0xf;
static constexpr int kNThicknesses_ = 4;
static constexpr int kNHGCalLayersMax_ = 52;
static constexpr int kSplit_v9_Coarse_ = 0;
static constexpr int kSplit_v9_Mid_ = 0x2;
static constexpr int kSplit_v9_Fine_ = 0xa;
static constexpr int kSplit_v9_VeryFine_ = 0xb;
static constexpr int kSplit_v9_Individual_ = 0xf;

static constexpr int kSplit_v9_Scin_Coarse_ = 0x1f9fc;
static constexpr int kSplit_v9_Scin_Mid_ = 0x1fdfc;
static constexpr int kSplit_v9_Scin_Fine_ = 0x1fdfe;
static constexpr int kSplit_v9_Scin_VeryFine_ = 0x1fffe;
static constexpr int kSplit_v9_Scin_Individual_ = 0x1ffff;
static constexpr int kSplit_Coarse_ = 0;
static constexpr int kSplit_Mid_ = 0x2;
static constexpr int kSplit_Fine_ = 0xa;
static constexpr int kSplit_VeryFine_ = 0xb;
static constexpr int kSplit_Individual_ = 0xf;

static constexpr int kSplit_Scin_Coarse_ = 0x1f9fc;
static constexpr int kSplit_Scin_Mid_ = 0x1fdfc;
static constexpr int kSplit_Scin_Fine_ = 0x1fdfe;
static constexpr int kSplit_Scin_VeryFine_ = 0x1fffe;
static constexpr int kSplit_Scin_Individual_ = 0x1ffff;

//For coarse TCs
static constexpr int kRocShift_ = 4;
Expand All @@ -56,7 +50,7 @@ class HGCalCoarseTriggerCellMapping {
static constexpr int kVShift_ = 0;
static constexpr int kUMask_ = 0x3;
static constexpr int kVMask_ = 0x3;
static constexpr int kHGCalCellMaskV9Inv_ = ~0xff;
static constexpr int kHGCalCellMaskInv_ = ~0xff;
static constexpr int kHGCalScinCellMaskInv_ = ~0x1ffff;

static constexpr int kRoc0deg_ = 1;
Expand Down