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

update GCT eg and hadronic cluster interface to Correlator #47193

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ namespace l1tp2 {
// Other getters
float ptLSB() const { return LSB_PT; }
ap_uint<12> pt() const { return (clusterData & 0xFFF); }
float ptFloat() const { return (pt() * ptLSB()); }

// crystal eta in the correlator region (LSB: 2.8/170)
ap_uint<8> eta() const { return ((clusterData >> 12) & 0xFF); } // (eight 1's) 0b11111111 = 0xFF
Expand Down Expand Up @@ -161,7 +162,8 @@ namespace l1tp2 {
bool passNullBitsCheck(void) const { return ((data() >> unusedBitsStart()) == 0x0); }

// Get real eta (does not depend on card number). crystal iEta = 0 starts at real eta -1.4841.
float realEta() const { return (float)((-1 * ETA_RANGE_ONE_SIDE) + (eta() * LSB_ETA)); }
// LSB_ETA/2 is to add half a crystal width to get the center of the crystal in eta
float realEta() const { return (float)((-1 * ETA_RANGE_ONE_SIDE) + (eta() * LSB_ETA) + (LSB_ETA / 2)); }

// Get real phi (uses card number).
float realPhi() const {
Expand All @@ -176,7 +178,8 @@ namespace l1tp2 {
}
int thisPhi = (phi() + (offset_tower * n_crystals_in_tower));
// crystal iPhi = 0 starts at real phi = -180 degrees
return (float)((-1 * M_PI) + (thisPhi * LSB_PHI));
// LSB_PHI/2 is to add half a crystal width to get the center of the crystal in phi
return (float)((-1 * M_PI) + (thisPhi * LSB_PHI) + (LSB_PHI / 2));
}
};

Expand Down
137 changes: 137 additions & 0 deletions DataFormats/L1TCalorimeterPhase2/interface/GCTEmDigiCluster.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
#ifndef DataFormats_L1TCalorimeterPhase2_GCTEmDigiCluster_h
#define DataFormats_L1TCalorimeterPhase2_GCTEmDigiCluster_h

#include <ap_int.h>
#include <vector>

#include "DataFormats/L1TCalorimeterPhase2/interface/CaloCrystalCluster.h"
#include "DataFormats/L1TCalorimeterPhase2/interface/DigitizedClusterCorrelator.h"

namespace l1tp2 {

class GCTEmDigiCluster {
private:
// Data
unsigned long long int clusterData;

// Constants
static constexpr float LSB_PT = 0.5; // 0.5 GeV

// start of the unused bits
static constexpr int n_bits_unused_start = 52;

// Reference to the original float cluster
edm::Ref<l1tp2::CaloCrystalClusterCollection> clusterRef_;

// reference to the original digitized cluster (before duplication in the output links)
edm::Ref<l1tp2::DigitizedClusterCorrelatorCollection> digiClusterRef_;

public:
GCTEmDigiCluster() { clusterData = 0; }

GCTEmDigiCluster(ap_uint<64> data) { clusterData = data; }

GCTEmDigiCluster(ap_uint<12> pt,
int etaCr,
int phiCr,
ap_uint<4> hoe,
ap_uint<2> hoeFlag,
ap_uint<3> iso,
ap_uint<2> isoFlag,
ap_uint<6> fb,
ap_uint<5> timing,
ap_uint<2> shapeFlag,
ap_uint<2> brems) {
// To use .range() we need an ap class member
ap_uint<64> temp_data;
ap_uint<7> etaCrDigitized = abs(etaCr);
ap_int<7> phiCrDigitized = phiCr;

temp_data.range(11, 0) = pt.range();
temp_data.range(18, 12) = etaCrDigitized.range();
temp_data.range(25, 19) = phiCrDigitized.range();
temp_data.range(29, 26) = hoe.range();
temp_data.range(31, 30) = hoeFlag.range();
temp_data.range(34, 32) = iso.range();
temp_data.range(36, 35) = isoFlag.range();
temp_data.range(42, 37) = fb.range();
temp_data.range(47, 43) = timing.range();
temp_data.range(49, 48) = shapeFlag.range();
temp_data.range(51, 50) = brems.range();

clusterData = temp_data;
}

// Setters
void setRef(const edm::Ref<l1tp2::CaloCrystalClusterCollection>& clusterRef) { clusterRef_ = clusterRef; }

void setDigiRef(const edm::Ref<l1tp2::DigitizedClusterCorrelatorCollection>& digiClusterRef) {
digiClusterRef_ = digiClusterRef;
}

// Getters
ap_uint<64> data() const { return clusterData; }

// Other getters
float ptLSB() const { return LSB_PT; }
ap_uint<12> pt() const { return data().range(11, 0); }
float ptFloat() const { return pt() * ptLSB(); }

// crystal eta (unsigned, 7 bits), starting at 0 at real eta = 0, and increasing in the direction of larger abs(real eta)
// to convert to real eta, need to know which link this cluster is in
int eta() const { return (ap_uint<7>)data().range(18, 12); }

// crystal phi (signed, 7 bits), relative to center of the SLR
// to convert to real phi, need to know which SLR this cluster is in
int phi() const { return (ap_int<7>)data().range(25, 19); }

// HoE value and flag: not defined yet in the emulator
ap_uint<4> hoe() const { return data().range(29, 26); }
ap_uint<2> hoeFlag() const { return data().range(31, 30); }

// Raw isolation sum: not saved in the emulator
ap_uint<3> iso() const { return data().range(34, 32); }

// iso flag: two bits, least significant bit is the standalone WP (true or false), second bit is the looseTk WP (true or false)
// e.g. 0b01 : standalone iso flag passed, loose Tk iso flag did not pass
ap_uint<2> isoFlags() const { return data().range(36, 35); }
bool passes_iso() const { return (isoFlags() & 0x1); } // standalone iso WP
bool passes_looseTkiso() const { return (isoFlags() & 0x2); } // loose Tk iso WP

// fb and timing: not saved in the current emulator
ap_uint<6> fb() const { return data().range(42, 37); }
ap_uint<5> timing() const { return data().range(47, 43); }

// shower shape shape flag: two bits, least significant bit is the standalone WP, second bit is the looseTk WP
// e.g. 0b01 : standalone shower shape flag passed, loose Tk shower shape flag did not pass
ap_uint<2> shapeFlags() const { return data().range(49, 48); }

bool passes_ss() const { return (shapeFlags() & 0x1); } // standalone shower shape WP
bool passes_looseTkss() const { return (shapeFlags() & 0x2); } // loose Tk shower shape WP

// brems: not saved in the current emulator
ap_uint<2> brems() const { return data().range(51, 50); }

// Check that unused bits are zero
const int unusedBitsStart() const { return n_bits_unused_start; }
bool passNullBitsCheck(void) const { return ((data() >> unusedBitsStart()) == 0); }

// Get the underlying float cluster
const edm::Ref<l1tp2::CaloCrystalClusterCollection>& clusterRef() const { return clusterRef_; }
// Get the underlying digitized cluster (before duplication and zero-padding)
const edm::Ref<l1tp2::DigitizedClusterCorrelatorCollection>& digiClusterRef() const { return digiClusterRef_; }
};

// Collection typedefs

// This represents the 36 GCTEmDigiClusters in one link (one link spans 4 RCT cards, each RCT card sends 9 clusters (zero-padded and sorted by decreasing pT))
// The ordering of the 4 RCT cards in the link is, e.g. for GCT1.SLR3, real phi -50 to -20 degrees, then real phi -20 to 10 degrees, then real phi 10 to 40 degrees, and lastly real phi 40 to 70 degrees
typedef std::vector<l1tp2::GCTEmDigiCluster> GCTEmDigiClusterLink;

// This represents the 12 links sending GCTEmDigiClusters in the full barrel: there are 12 links = (3 GCT cards) * (two SLRs per GCT) * (one positive eta link and one negative eta link)
// The ordering of the links in this std::vector is (GCT1.SLR1 negEta, GCT.SLR1 posEta, GCT1.SLR3 negEta, GCT1.SLR3 posEta, then analogously for GCT2 and GCT3)
typedef std::vector<l1tp2::GCTEmDigiClusterLink> GCTEmDigiClusterCollection;

} // namespace l1tp2

#endif
84 changes: 84 additions & 0 deletions DataFormats/L1TCalorimeterPhase2/interface/GCTHadDigiCluster.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#ifndef DataFormats_L1TCalorimeterPhase2_GCTHadDigiCluster_h
#define DataFormats_L1TCalorimeterPhase2_GCTHadDigiCluster_h

#include <ap_int.h>
#include <vector>

#include "DataFormats/L1TCalorimeterPhase2/interface/CaloPFCluster.h"

namespace l1tp2 {

class GCTHadDigiCluster {
private:
// Data
unsigned long long int clusterData;

// Constants
static constexpr float LSB_PT = 0.5; // 0.5 GeV

// start of the unused bits
static constexpr int n_bits_unused_start = 31;

// reference to corresponding float cluster
edm::Ref<l1tp2::CaloPFClusterCollection> clusterRef_;

public:
GCTHadDigiCluster() { clusterData = 0; }

GCTHadDigiCluster(ap_uint<64> data) { clusterData = data; }

// Note types of the constructor
GCTHadDigiCluster(ap_uint<12> pt, int etaCr, int phiCr, ap_uint<4> hoe) {
// To use .range() we need an ap class member
ap_uint<64> temp_data;

ap_uint<7> etaCrDigitized = abs(etaCr);
ap_int<7> phiCrDigitized = phiCr;

temp_data.range(11, 0) = pt.range();
temp_data.range(18, 12) = etaCrDigitized.range();
temp_data.range(25, 19) = phiCrDigitized.range();

clusterData = temp_data;
}

// Setters
void setRef(const edm::Ref<l1tp2::CaloPFClusterCollection> &clusterRef) { clusterRef_ = clusterRef; }
// Getters
ap_uint<64> data() const { return clusterData; }

// Other getters
float ptLSB() const { return LSB_PT; }
ap_uint<12> pt() const { return data().range(11, 0); }
float ptFloat() const { return pt() * ptLSB(); }

// crystal eta (unsigned 7 bits)
int eta() const { return (ap_uint<7>)data().range(18, 12); }

// crystal phi (signed 7 bits)
int phi() const { return (ap_int<7>)data().range(25, 19); }

// HoE value
ap_uint<4> hoe() const { return data().range(30, 26); }

// Check that unused bits are zero
const int unusedBitsStart() const { return n_bits_unused_start; }
bool passNullBitsCheck(void) const { return ((data() >> unusedBitsStart()) == 0); }

// Get the underlying ref
edm::Ref<l1tp2::CaloPFClusterCollection> clusterRef() const { return clusterRef_; }
};

// Collection typedefs

// This represents the 36 GCTHadDigiClusters in one link (one link spans 4 RCT cards, each RCT card sends 9 clusters (zero-padded and sorted by decreasing pT)
// The ordering of the 4 RCT cards in this std::vector is, e.g. for GCT1.SLR3, real phi -50 to -20 degrees, then real phi -20 to 10 degrees, then real phi 10 to 40 degrees, and lastly real phi 40 to 70 degrees
typedef std::vector<l1tp2::GCTHadDigiCluster> GCTHadDigiClusterLink;

// This represents the 12 links sending GCTHadDigiClusters in the full barrel: there are 12 links = (3 GCT cards) * (two SLRs per GCT) * (one positive eta link and one negative eta link)
// The ordering of the links in this std::vector is (GCT1.SLR1 negEta, GCT.SLR1 posEta, GCT1.SLR3 negEta, GCT1.SLR3 posEta, then analogously for GCT2 and GCT3)
typedef std::vector<l1tp2::GCTHadDigiClusterLink> GCTHadDigiClusterCollection;

} // namespace l1tp2

#endif
8 changes: 5 additions & 3 deletions DataFormats/L1TCalorimeterPhase2/src/classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
/*********************/

#include "DataFormats/L1TCalorimeterPhase2/interface/CaloCrystalCluster.h"
#include "DataFormats/L1TCalorimeterPhase2/interface/CaloTower.h"
#include "DataFormats/L1TCalorimeterPhase2/interface/CaloPFCluster.h"
#include "DataFormats/L1TCalorimeterPhase2/interface/CaloJet.h"
#include "DataFormats/L1TCalorimeterPhase2/interface/CaloTower.h"
#include "DataFormats/L1TCalorimeterPhase2/interface/DigitizedClusterCorrelator.h"
#include "DataFormats/L1TCalorimeterPhase2/interface/DigitizedTowerCorrelator.h"
#include "DataFormats/L1TCalorimeterPhase2/interface/DigitizedClusterGT.h"
#include "DataFormats/L1TCalorimeterPhase2/interface/CaloPFCluster.h"
#include "DataFormats/L1TCalorimeterPhase2/interface/DigitizedTowerCorrelator.h"
#include "DataFormats/L1TCalorimeterPhase2/interface/GCTEmDigiCluster.h"
#include "DataFormats/L1TCalorimeterPhase2/interface/GCTHadDigiCluster.h"
#include "DataFormats/L1TCalorimeterPhase2/interface/Phase2L1CaloJet.h"
56 changes: 37 additions & 19 deletions DataFormats/L1TCalorimeterPhase2/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,7 @@
<class name="std::vector<l1tp2::CaloCrystalCluster>" />
<class name="l1tp2::CaloCrystalClusterCollection" />
<class name="edm::Wrapper<l1tp2::CaloCrystalClusterCollection>" />

<class name="l1tp2::CaloTower" ClassVersion="3">
<version ClassVersion="3" checksum="2608605419"/>
</class>
<class name="std::vector<l1tp2::CaloTower>" />
<class name="l1tp2::CaloTowerCollection" />
<class name="edm::Wrapper<l1tp2::CaloTowerCollection>" />
<class name="edm::Ref<l1tp2::CaloCrystalClusterCollection>" />

<class name="l1tp2::CaloJet" ClassVersion="3">
<version ClassVersion="3" checksum="2520028496"/>
Expand All @@ -25,19 +19,35 @@
<class name="l1tp2::CaloJetsCollection" />
<class name="edm::Wrapper<l1tp2::CaloJetsCollection>" />

<class name="l1tp2::CaloPFCluster" ClassVersion="3">
<version ClassVersion="3" checksum="4176166177"/>
</class>
<class name="std::vector<l1tp2::CaloPFCluster>" />
<class name="l1tp2::CaloPFClusterCollection" />
<class name="edm::Wrapper<l1tp2::CaloPFClusterCollection>" />
<class name="edm::Ref<l1tp2::CaloPFClusterCollection>" />

<class name="l1tp2::GCTHadDigiCluster" />
<class name="std::vector<l1tp2::GCTHadDigiCluster>" />
<class name="l1tp2::GCTHadDigiClusterLink" />
<class name="edm::Wrapper<l1tp2::GCTHadDigiClusterLink>" />
<class name="l1tp2::GCTHadDigiClusterCollection" />
<class name="edm::Wrapper<std::vector<std::vector<l1tp2::GCTHadDigiCluster> > >" />

<class name="l1tp2::CaloTower" ClassVersion="3">
<version ClassVersion="3" checksum="2608605419"/>
</class>
<class name="std::vector<l1tp2::CaloTower>" />
<class name="l1tp2::CaloTowerCollection" />
<class name="edm::Wrapper<l1tp2::CaloTowerCollection>" />

<class name="l1tp2::DigitizedClusterCorrelator" ClassVersion="4">
<version ClassVersion="4" checksum="838642806"/>
<version ClassVersion="3" checksum="1943292648"/>
</class>
<class name="l1tp2::DigitizedClusterCorrelatorCollection" />
<class name="edm::Wrapper<l1tp2::DigitizedClusterCorrelatorCollection>" />

<class name="l1tp2::DigitizedTowerCorrelator" ClassVersion="4">
<version ClassVersion="4" checksum="1597735835"/>
<version ClassVersion="3" checksum="3734711406"/>
</class>
<class name="l1tp2::DigitizedTowerCorrelatorCollection" />
<class name="edm::Wrapper<l1tp2::DigitizedTowerCorrelatorCollection>" />
<class name="edm::Ref<l1tp2::DigitizedClusterCorrelatorCollection>" />

<class name="l1tp2::DigitizedClusterGT" ClassVersion="4">
<version ClassVersion="4" checksum="2603854524"/>
Expand All @@ -46,12 +56,19 @@
<class name="l1tp2::DigitizedClusterGTCollection" />
<class name="edm::Wrapper<l1tp2::DigitizedClusterGTCollection>" />

<class name="l1tp2::CaloPFCluster" ClassVersion="3">
<version ClassVersion="3" checksum="4176166177"/>

<class name="l1tp2::DigitizedTowerCorrelator" ClassVersion="4">
<version ClassVersion="4" checksum="1597735835"/>
<version ClassVersion="3" checksum="3734711406"/>
</class>
<class name="std::vector<l1tp2::CaloPFCluster>" />
<class name="l1tp2::CaloPFClusterCollection" />
<class name="edm::Wrapper<l1tp2::CaloPFClusterCollection>" />
<class name="l1tp2::DigitizedTowerCorrelatorCollection" />
<class name="edm::Wrapper<l1tp2::DigitizedTowerCorrelatorCollection>" />

<class name="l1tp2::GCTEmDigiCluster" />
<class name="std::vector<l1tp2::GCTEmDigiCluster>" />
<class name="l1tp2::GCTEmDigiClusterLink" />
<class name="std::vector<l1tp2::GCTEmDigiClusterLink>" />
<class name="edm::Wrapper<std::vector<std::vector<l1tp2::GCTEmDigiCluster> > >" />

<class name="l1tp2::Phase2L1CaloJet" ClassVersion="3">
<version ClassVersion="3" checksum="289384850"/>
Expand All @@ -60,5 +77,6 @@
<class name="l1tp2::Phase2L1CaloJetCollection" />
<class name="edm::Wrapper<l1tp2::Phase2L1CaloJetCollection>" />


</lcgdict>

Loading