Skip to content

Commit

Permalink
Merge pull request #120 from gpetruc/multiboard_correlator
Browse files Browse the repository at this point in the history
Updates for Multiboard correlator tests
  • Loading branch information
gpetruc authored Aug 23, 2023
2 parents 9f0a3a2 + dfbebc1 commit b275c12
Show file tree
Hide file tree
Showing 91 changed files with 7,328 additions and 708 deletions.
2 changes: 1 addition & 1 deletion DQMOffline/L1Trigger/python/L1TPhase2Offline_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
OuterTrackerTkMET = DQMEDAnalyzer('L1TPhase2OuterTrackerTkMET',
TopFolderName = cms.string('L1T/L1TPhase2/'),
TTTracksTag = cms.InputTag("l1tTTTracksFromTrackletEmulation", "Level1TTTracks"),
L1VertexInputTag = cms.InputTag("l1tVertexFinderEmulator", "l1verticesEmulation"),
L1VertexInputTag = cms.InputTag("l1tVertexFinderEmulator", "L1VerticesEmulation"),
maxZ0 = cms.double ( 15. ) , # in cm
maxEta = cms.double ( 2.4 ) ,
chi2dofMax = cms.double( 10. ),
Expand Down
1 change: 1 addition & 0 deletions DataFormats/L1TCalorimeterPhase2/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<use name="DataFormats/DetId"/>
<use name="FWCore/MessageLogger"/>
<use name="rootrflx"/>
<use name="hls"/>
<export>
<lib name="1"/>
</export>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef DataFormats_L1TCalorimeterPhase2_CaloCrystalsCluster_h
#define DataFormats_L1TCalorimeterPhase2_CaloCrystalsCluster_h

#include <ap_int.h>
#include <vector>
#include <map>
#include <string>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
#ifndef DataFormats_L1TCalorimeterPhase2_DigitizedClusterCorrelator_h
#define DataFormats_L1TCalorimeterPhase2_DigitizedClusterCorrelator_h

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

namespace l1tp2 {

class DigitizedClusterCorrelator {
private:
// Data
ap_uint<64> clusterData;
unsigned int idxGCTCard; // 0, 1, or 2

// Constants
static constexpr unsigned int n_towers_eta = 34; // in GCT card unique region
static constexpr unsigned int n_towers_phi = 24; // in GCT card unique region
static constexpr unsigned int n_crystals_in_tower = 5;
static constexpr float LSB_PT = 0.5; // 0.5 GeV
static constexpr unsigned int n_bits_pt = 12; // 12 bits allocated for pt
static constexpr unsigned int n_bits_unused_start = 49; // unused bits start at bit 49

// Private member functions to perform digitization
ap_uint<12> digitizePt(float pt_f) {
float maxPt_f = (std::pow(2, n_bits_pt) - 1) * LSB_PT;
// If pT exceeds the maximum (extremely unlikely), saturate the value
if (pt_f >= maxPt_f) {
return (ap_uint<12>)0xFFF;
}

return (ap_uint<12>)(pt_f / LSB_PT);
}

//
ap_uint<6> digitizeIEta(unsigned int iEta) {
assert(iEta < n_towers_eta);
return (ap_uint<6>)iEta;
}

// This is tower iPhi in the unique region of the GCT card, so this only goes from 0-23
ap_uint<5> digitizeIPhi(unsigned int iPhi) {
assert(iPhi < n_towers_phi);
return (ap_uint<5>)iPhi;
}

ap_uint<3> digitizeIEtaCr(unsigned int iEtaCr) {
assert(iEtaCr < n_crystals_in_tower);
return (ap_uint<3>)iEtaCr;
}

ap_uint<3> digitizeIPhiCr(unsigned int iPhiCr) {
assert(iPhiCr < n_crystals_in_tower);
return (ap_uint<3>)iPhiCr;
}

// To-do: HoE is not defined for clusters
ap_uint<4> digitizeHoE(unsigned int hoe) { return (ap_uint<4>)hoe; }

//
ap_uint<3> digitizeIso(bool iso) { return (ap_uint<3>)iso; }

// To-do: fb: no information yet
ap_uint<6> digitizeFb(unsigned int fb) { return (ap_uint<6>)fb; }

// To-do: timing: no information yet
ap_uint<5> digitizeTiming(unsigned int timing) { return (ap_uint<5>)timing; }

// Shape: shower shape working point
ap_uint<1> digitizeShape(bool is_ss) { return (ap_uint<1>)is_ss; }

// TO-DO: Brems: was brems applied (NOT STORED YET IN GCT)
ap_uint<1> digitizeBrems(bool brems_applied) { return (ap_uint<1>)brems_applied; }

public:
DigitizedClusterCorrelator() { clusterData = 0x0; }

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

// Constructor from digitized inputs
DigitizedClusterCorrelator(ap_uint<12> pt,
ap_uint<6> eta,
ap_uint<5> phi,
ap_uint<3> etaCr,
ap_uint<3> phiCr,
ap_uint<4> hoe,
ap_uint<3> iso,
ap_uint<6> fb,
ap_uint<5> timing,
ap_uint<1> shape,
ap_uint<1> brems,
int iGCTCard,
bool fullydigitizedInputs) {
(void)fullydigitizedInputs;

clusterData = ((ap_uint<64>)pt) | (((ap_uint<64>)eta) << 12) | (((ap_uint<64>)phi) << 18) |
(((ap_uint<64>)etaCr) << 23) | (((ap_uint<64>)phiCr) << 26) | (((ap_uint<64>)hoe) << 29) |
(((ap_uint<64>)iso << 33)) | (((ap_uint<64>)fb << 36)) | (((ap_uint<64>)timing << 42)) |
(((ap_uint<64>)shape << 47)) | (((ap_uint<64>)brems << 48));
idxGCTCard = iGCTCard;
}

// Constructor from float inputs
DigitizedClusterCorrelator(float pt_f,
unsigned int iEta,
unsigned int iPhi,
unsigned int iEtaCr,
unsigned int iPhiCr,
unsigned int hoe,
bool iso,
unsigned int fb,
unsigned int timing,
bool shape,
unsigned int brems,
int iGCTCard) {
clusterData = (((ap_uint<64>)digitizePt(pt_f)) | ((ap_uint<64>)digitizeIEta(iEta) << 12) |
((ap_uint<64>)digitizeIPhi(iPhi) << 18) | ((ap_uint<64>)digitizeIEtaCr(iEtaCr) << 23) |
((ap_uint<64>)digitizeIPhiCr(iPhiCr) << 26) | ((ap_uint<64>)digitizeHoE(hoe) << 29) |
((ap_uint<64>)digitizeIso(iso) << 33) | ((ap_uint<64>)digitizeFb(fb) << 36) |
((ap_uint<64>)digitizeTiming(timing) << 42) | ((ap_uint<64>)digitizeShape(shape) << 47) |
((ap_uint<64>)digitizeBrems(brems) << 48));
idxGCTCard = iGCTCard;
}

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

// Other getters
float ptLSB() const { return LSB_PT; }
ap_uint<12> pt() const { return (clusterData & 0xFFF); }
ap_uint<6> eta() const { return ((clusterData >> 12) & 0x3F); } // (six 1's) 0b111111 = 0x3F
ap_uint<5> phi() const { return ((clusterData >> 18) & 0x1F); } // (five 1's) 0b11111 = 0x1F
ap_uint<3> etaCr() const { return ((clusterData >> 23) & 0x7); } // (three 1's) 0b111 = 0x7
ap_uint<3> phiCr() const { return ((clusterData >> 26) & 0x7); }
ap_uint<4> hoe() const { return ((clusterData >> 29) & 0xF); } // (four 1's) 0b1111 = 0xF
ap_uint<3> iso() const { return ((clusterData >> 33) & 0x7); }
ap_uint<6> fb() const { return ((clusterData >> 36) & 0x3F); }
ap_uint<5> timing() const { return ((clusterData >> 42) & 0x1F); }
ap_uint<1> shape() const { return ((clusterData >> 47) & 0x1); }
ap_uint<1> brems() const { return ((clusterData >> 48) & 0x1); }
unsigned int cardNumber() const { return idxGCTCard; } // which GCT card (0, 1, or 2)

const int unusedBitsStart() const { return 49; } // unused bits start at bit 49

// Other checks
bool passNullBitsCheck(void) const { return ((data() >> unusedBitsStart()) == 0x0); }
};

// Collection typedef
typedef std::vector<l1tp2::DigitizedClusterCorrelator> DigitizedClusterCorrelatorCollection;

} // namespace l1tp2

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

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

namespace l1tp2 {

class DigitizedClusterGT {
private:
// Data
ap_uint<64> clusterData;

// Constants
static constexpr float LSB_PT = 0.03125; // 0.03125 GeV
static constexpr unsigned int n_bits_eta_pi = 12; // 12 bits corresponds to pi in eta
static constexpr unsigned int n_bits_phi_pi = 12; // 12 bits corresponds to pi in phi
static constexpr unsigned int n_bits_pt = 16; // 12 bits allocated for pt
static constexpr unsigned int n_bits_unused_start = 44; // unused bits start at bit number 44

float LSB_ETA = (M_PI / std::pow(2, n_bits_eta_pi));
float LSB_PHI = (M_PI / std::pow(2, n_bits_phi_pi));

// Private member functions to perform digitization
ap_uint<1> digitizeIsValid(bool isValid) { return (ap_uint<1>)isValid; }

ap_uint<16> digitizePt(float pt_f) {
float maxPt_f = (std::pow(2, n_bits_pt) - 1) * LSB_PT;
// If pT exceeds the maximum, saturate the value
if (pt_f >= maxPt_f) {
return (ap_uint<16>)0xFFFF;
}
return (ap_uint<16>)(pt_f / LSB_PT);
}

// Use two's complements representation
ap_int<13> digitizePhi(float phi_f) {
ap_int<13> phi_digitized = (phi_f / LSB_PHI);
return phi_digitized;
}

// Use two's complements representation
ap_int<14> digitizeEta(float eta_f) {
ap_int<14> eta_digitized = (eta_f / LSB_ETA);
return eta_digitized;
}

public:
DigitizedClusterGT() { clusterData = 0x0; }

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

// Constructor from digitized inputs
DigitizedClusterGT(ap_uint<1> isValid, ap_uint<16> pt, ap_int<13> phi, ap_int<14> eta, bool fullyDigitizedInputs) {
(void)fullyDigitizedInputs;
clusterData =
((ap_uint<64>)isValid) | (((ap_uint<64>)pt) << 1) | (((ap_uint<64>)phi) << 17) | (((ap_uint<64>)eta) << 30);
}

// Constructor from float inputs that will perform digitization
DigitizedClusterGT(bool isValid, float pt_f, float phi_f, float eta_f) {
// N.b.: For eta/phi, after shifting the bits to the correct place and casting to ap_uint<64>,
// we have an additional bit mask
// e.g. 0x3FFE0000 for phi. This mask is all zero's except for 1 in the phi bits (bits 17 through 29):
// bit mask = 0x3FFE0000 = 0b111111111111100000000000000000
// Applying the "and" of this bitmask, avoids bogus 1's in the case where phi is negative

clusterData = ((ap_uint<64>)digitizeIsValid(isValid)) | ((ap_uint<64>)digitizePt(pt_f) << 1) |
(((ap_uint<64>)digitizePhi(phi_f) << 17) &
0x3FFE0000) | // 0x3FFE0000 is all zero's except the phi bits (bits 17 through 29)
(((ap_uint<64>)digitizeEta(eta_f) << 30) &
0xFFFC0000000); // 0xFFFC0000000 is all zero's except the eta bits (bits 30 through 32)
}

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

// Other getters
float ptLSB() const { return LSB_PT; }
float phiLSB() const { return LSB_PHI; }
float etaLSB() const { return LSB_ETA; }
ap_uint<1> isValid() const { return (clusterData & 0x1); }
ap_uint<16> pt() const { return ((clusterData >> 1) & 0xFFFF); } // 16 1's = 0xFFFF
ap_int<13> phi() const { return ((clusterData >> 17) & 0x1FFF); } // (thirteen 1's)= 0x1FFF
ap_int<14> eta() const { return ((clusterData >> 30) & 0x3FFF); } // (fourteen 1's) = 0x3FFF

float ptFloat() const { return (pt() * ptLSB()); }
float realPhi() const { // convert from signed int to float
return (phi() * phiLSB());
}
float realEta() const { // convert from signed int to float
return (eta() * etaLSB());
}
const int unusedBitsStart() const { return n_bits_unused_start; } // unused bits start at bit 44

// Other checks
bool passNullBitsCheck(void) const { return ((data() >> unusedBitsStart()) == 0x0); }
};

// Collection typedef
typedef std::vector<l1tp2::DigitizedClusterGT> DigitizedClusterGTCollection;

} // namespace l1tp2

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#ifndef DataFormats_L1TCalorimeterPhase2_DigitizedTowerCorrelator_h
#define DataFormats_L1TCalorimeterPhase2_DigitizedTowerCorrelator_h

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

namespace l1tp2 {

class DigitizedTowerCorrelator {
private:
// Data
ap_uint<16> towerData;
unsigned int idxCard; // 0, 1, or 2 (there are three GCT cards)
unsigned int idxFiber; // 0 to 47 (there are 48 fibers in one GCT card)
unsigned int idxTower; // 0 to 16 (there are 17 towers in one fiber)

// Constants
static constexpr float LSB_ET = 0.5; // 0.5 GeV, so max value is (2^10 - 1) * 0.5 = 511.5 GeV
static constexpr unsigned int n_bits_pt = 10;
static constexpr unsigned int n_towers_in_fiber = 17;
static constexpr unsigned int n_fibers_in_card = 48;
static constexpr unsigned int n_cards = 3;

// Private member functions to perform digitization
ap_uint<10> digitizeEt(float et_f) {
float maxEt_f = (std::pow(2, n_bits_pt) - 1) * LSB_ET;
// If pT exceeds the maximum, saturate the value
if (et_f >= maxEt_f) {
return (ap_uint<10>)0x3FF;
}
return (ap_uint<10>)(et_f / LSB_ET);
}

ap_uint<4> digitizeHoE(ap_uint<4> hoe) { return (ap_uint<4>)hoe; }

// To-do: FB not implemented yet
ap_uint<2> digitizeFB(ap_uint<2> fb) { return (ap_uint<2>)fb; }

public:
DigitizedTowerCorrelator() { towerData = 0x0; }

DigitizedTowerCorrelator(ap_uint<16> data) { towerData = data; }

// Constructor from digitized inputs
DigitizedTowerCorrelator(ap_uint<10> et,
ap_uint<4> hoe,
ap_uint<2> fb,
unsigned int indexCard,
unsigned int indexFiber,
unsigned int indexTower,
bool fullyDigitizedInputs) {
(void)fullyDigitizedInputs;
towerData = ((ap_uint<16>)et) | (((ap_uint<16>)hoe) << 10) | (((ap_uint<16>)fb) << 14);
idxCard = indexCard;
idxFiber = indexFiber;
idxTower = indexTower;
assert(hasValidIndices());
}

// Constructor from float inputs
DigitizedTowerCorrelator(float et_f,
ap_uint<4> hoe,
ap_uint<2> fb,
unsigned int indexCard,
unsigned int indexFiber,
unsigned int indexTower) {
towerData = ((ap_uint<16>)digitizeEt(et_f)) | (((ap_uint<16>)hoe) << 10) | (((ap_uint<16>)fb) << 14);
idxCard = indexCard;
idxFiber = indexFiber;
idxTower = indexTower;
assert(hasValidIndices());
}

ap_uint<16> data() const { return towerData; }

// Other getters
float etLSB() const { return LSB_ET; }
ap_uint<10> et() const { return (towerData & 0x3FF); } // ten 1's = 0x3FF
ap_uint<4> hoe() const { return ((towerData >> 10) & 0xF); } // four 1's= 0xF
ap_uint<2> fb() const { return ((towerData >> 14) & 0x3); } // two 1's = 0x3
float etFloat() const { return et() * etLSB(); }
unsigned int cardNumber() const { return idxCard; } // GCT card number
unsigned int fiberNumber() const { return idxFiber; } // fiber number in card (hardware convention)
unsigned int towerNumber() const { return idxTower; } // tower number in fiber (hardware convention)

// Other checks
bool hasValidIndices(void) const {
return (idxTower < n_towers_in_fiber) && (idxFiber < n_fibers_in_card) && (idxCard < n_cards);
}
};

// Collection typedef
typedef std::vector<l1tp2::DigitizedTowerCorrelator> DigitizedTowerCorrelatorCollection;

} // namespace l1tp2

#endif
3 changes: 3 additions & 0 deletions DataFormats/L1TCalorimeterPhase2/src/classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@
#include "DataFormats/L1TCalorimeterPhase2/interface/CaloCrystalCluster.h"
#include "DataFormats/L1TCalorimeterPhase2/interface/CaloTower.h"
#include "DataFormats/L1TCalorimeterPhase2/interface/CaloJet.h"
#include "DataFormats/L1TCalorimeterPhase2/interface/DigitizedClusterCorrelator.h"
#include "DataFormats/L1TCalorimeterPhase2/interface/DigitizedTowerCorrelator.h"
#include "DataFormats/L1TCalorimeterPhase2/interface/DigitizedClusterGT.h"
Loading

0 comments on commit b275c12

Please sign in to comment.