Skip to content

Commit

Permalink
squashed commits.
Browse files Browse the repository at this point in the history
  • Loading branch information
tschuh committed Sep 10, 2024
1 parent 8befcea commit 2a119b3
Show file tree
Hide file tree
Showing 175 changed files with 9,969 additions and 9,730 deletions.
4 changes: 2 additions & 2 deletions Configuration/StandardSequences/python/L1TrackTrigger_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

from L1Trigger.TrackTrigger.TrackTrigger_cff import *
from SimTracker.TrackTriggerAssociation.TrackTriggerAssociator_cff import *
from L1Trigger.TrackerDTC.ProducerED_cff import *
from L1Trigger.TrackerDTC.DTC_cff import *
from L1Trigger.TrackFindingTracklet.L1HybridEmulationTracks_cff import *

L1TrackTrigger=cms.Sequence(TrackTriggerClustersStubs*TrackTriggerAssociatorClustersStubs*TrackerDTCProducer)
L1TrackTrigger=cms.Sequence(TrackTriggerClustersStubs*TrackTriggerAssociatorClustersStubs*ProducerDTC)

# Customisation to enable TTTracks in geometry D41 and later (corresponding to phase2_trackerV14 or later). Includes the HGCAL L1 trigger
_tttracks_l1tracktrigger = L1TrackTrigger.copy()
Expand Down
110 changes: 81 additions & 29 deletions DataFormats/L1TrackTrigger/interface/TTBV.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,13 @@
class TTBV {
public:
static constexpr int S_ = 64; // Frame width of emp infrastructure f/w, max number of bits a TTBV can handle

private:
bool twos_; // Two's complement (true) or binary (false)
int size_; // number or bits
std::bitset<S_> bs_; // underlying storage

public:
// constructor: default
TTBV() : twos_(false), size_(0), bs_() {}

// constructor: double precision (IEEE 754); from most to least significant bit: 1 bit sign + 11 bit binary exponent + 52 bit binary mantisse
TTBV(const double d) : twos_(false), size_(S_) {
int index(0);
Expand All @@ -42,11 +39,13 @@ class TTBV {
}

// constructor: unsigned int value
TTBV(unsigned long long int value, int size) : twos_(false), size_(size), bs_(value) {}
TTBV(unsigned long long int value, int size) : twos_(false), size_(size), bs_(value) { checkU(value); }

// constructor: int value
TTBV(int value, int size, bool twos = false)
: twos_(twos), size_(size), bs_((!twos || value >= 0) ? value : value + iMax()) {}
: twos_(twos), size_(size), bs_((!twos || value >= 0) ? value : value + iMax()) {
checkI(value);
}

// constructor: double value + precision, biased (floor) representation
TTBV(double value, double base, int size, bool twos = false) : TTBV((int)std::floor(value / base), size, twos) {}
Expand All @@ -70,10 +69,15 @@ class TTBV {
// underlying storage
const std::bitset<S_>& bs() const { return bs_; }

// access: single bit
// access: single bit value
bool operator[](int pos) const { return bs_[pos]; }

// access: single bit reference
std::bitset<S_>::reference operator[](int pos) { return bs_[pos]; }

// access: single bit value with bounds check
bool test(int pos) const { return bs_.test(pos); }

// access: most significant bit copy
bool msb() const { return bs_[size_ - 1]; }

Expand All @@ -95,31 +99,31 @@ class TTBV {

// operator: boolean and
TTBV& operator&=(const TTBV& rhs) {
const int m(std::max(size_, rhs.size()));
this->resize(m);
TTBV bv(rhs);
bv.resize(m);
bs_ &= bv.bs_;
bs_ &= rhs.bs_;
return *this;
}

// operator: boolean and
TTBV operator&&(const TTBV& rhs) {
TTBV copy(*this);
return copy &= rhs;
}

// operator: boolean or
TTBV& operator|=(const TTBV& rhs) {
const int m(std::max(size_, rhs.size()));
this->resize(m);
TTBV bv(rhs);
bv.resize(m);
bs_ |= bv.bs_;
bs_ |= rhs.bs_;
return *this;
}

// operator: boolean or
TTBV operator||(const TTBV& rhs) {
TTBV copy(*this);
return copy |= rhs;
}

// operator: boolean xor
TTBV& operator^=(const TTBV& rhs) {
const int m(std::max(size_, rhs.size()));
this->resize(m);
TTBV bv(rhs);
bv.resize(m);
bs_ ^= bv.bs_;
bs_ ^= rhs.bs_;
return *this;
}

Expand Down Expand Up @@ -242,7 +246,7 @@ class TTBV {
bs_.set(n, msb);
size_ = size;
} else if (size < size_ && size > 0) {
this->operator<<=(size - size_);
this->operator<<=(size_ - size);
if (twos_)
this->msb() = msb;
}
Expand Down Expand Up @@ -281,11 +285,18 @@ class TTBV {

// maniplulation and conversion: extracts range based to int reinterpret sign and removes these bits
int extract(int size, bool twos = false) {
double val = this->val(size, 0, twos);
int val = this->val(size, 0, twos);
this->operator>>=(size);
return val;
}

// maniplulation and conversion: extracts bool and removes this bit
bool extract() {
bool val = bs_[0];
this->operator>>=(1);
return val;
}

// manipulation: extracts slice and removes these bits
TTBV slice(int size, bool twos = false) {
TTBV ttBV(*this, size, 0, twos);
Expand Down Expand Up @@ -344,17 +355,58 @@ class TTBV {

private:
// look up table initializer for powers of 2
constexpr std::array<unsigned long long int, S_> powersOfTwo() const {
std::array<unsigned long long int, S_> lut = {};
for (int i = 0; i < S_; i++)
constexpr std::array<double, S_ + 1> powersOfTwo() const {
std::array<double, S_ + 1> lut = {};
for (int i = 0; i <= S_; i++)
lut[i] = std::pow(2, i);
return lut;
}

// returns 2 ** size_
unsigned long long int iMax() const {
static const std::array<unsigned long long int, S_> lut = powersOfTwo();
return lut[size_];
double iMax() const {
static const std::array<double, S_ + 1> lut = powersOfTwo();
return std::round(lut[size_]);
}

// check if value fits into binary BV
void checkU(unsigned long long int value) {
if (size_ == 0)
return;
if (value < iMax())
return;
cms::Exception exception("RunTimeError.");
exception << "Value " << value << " does not fit into a " << size_ << "b binary.";
exception.addContext("TTBV::checkU");
throw exception;
}

// check if value fits into twos's complement BV
void checkT(int value) {
if (size_ == 0)
return;
static const std::array<double, S_ + 1> lut = powersOfTwo();
auto abs = [](int val) { return val < 0 ? std::abs(val) - 1 : val; };
if (abs(value) < std::round(lut[size_ - 1]))
return;
cms::Exception exception("RunTimeError.");
exception << "Value " << value << " does not fit into a " << size_ << "b two's complement.";
exception.addContext("TTBV::checkT");
throw exception;
}

// check if value fits into twos complement / binary BV
void checkI(int value) {
if (size_ == 0)
return;
if (twos_)
checkT(value);
else if (value < 0) {
cms::Exception exception("RunTimeError.");
exception << size_ << "b Binary TTBV constructor called with negative value (" << value << ").";
exception.addContext("TTBV::checkI");
throw exception;
} else
checkU(value);
}
};

Expand Down
2 changes: 2 additions & 0 deletions DataFormats/L1TrackTrigger/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,7 @@
<class name="edm::Wrapper<tt::TTTrackRefMap>"/>
<class name="TTDTC"/>
<class name="edm::Wrapper<TTDTC>"/>
<class name="std::vector<std::pair<double, double>>"/>
<class name="edm::Wrapper<std::vector<std::pair<double, double>>>"/>
</lcgdict>

4 changes: 2 additions & 2 deletions L1Trigger/L1TTrackMatch/test/L1TrackObjectNtupleMaker_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@


# DTC emulation
process.load('L1Trigger.TrackerDTC.ProducerED_cff')
process.dtc = cms.Path(process.TrackerDTCProducer)
process.load('L1Trigger.TrackerDTC.DTC_cff')
process.dtc = cms.Path(process.ProducerDTC)

process.load("L1Trigger.TrackFindingTracklet.L1HybridEmulationTracks_cff")
process.load("L1Trigger.L1TTrackMatch.l1tTrackSelectionProducer_cfi")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
process.load('Configuration.StandardSequences.SimL1Emulator_cff')
process.load('L1Trigger.TrackTrigger.TrackTrigger_cff')
process.load("L1Trigger.TrackFindingTracklet.L1HybridEmulationTracks_cff")
process.load("L1Trigger.TrackerDTC.ProducerES_cff")
process.load("L1Trigger.TrackerDTC.ProducerED_cff")
process.load("L1Trigger.TrackerDTC.DTC_cff")
process.load("RecoVertex.BeamSpotProducer.BeamSpot_cfi")

process.l1tLayer1Barrel9 = process.l1tLayer1Barrel.clone()
Expand All @@ -52,7 +51,7 @@
process.PFInputsTask = cms.Task(
process.TTClustersFromPhase2TrackerDigis,
process.TTStubsFromPhase2TrackerDigis,
process.TrackerDTCProducer,
process.ProducerDTC,
process.offlineBeamSpot,
process.l1tTTTracksFromTrackletEmulation,
process.SimL1EmulatorTask
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
process.load('Configuration.StandardSequences.SimL1Emulator_cff')
process.load('L1Trigger.TrackTrigger.TrackTrigger_cff')
process.load("L1Trigger.TrackFindingTracklet.L1HybridEmulationTracks_cff")
process.load("L1Trigger.TrackerDTC.ProducerES_cff")
process.load("L1Trigger.TrackerDTC.ProducerED_cff")
process.load("L1Trigger.TrackerDTC.DTC_cff")
process.load("RecoVertex.BeamSpotProducer.BeamSpot_cfi")

from L1Trigger.Phase2L1ParticleFlow.l1tSeedConePFJetProducer_cfi import l1tSeedConePFJetEmulatorProducer
Expand Down Expand Up @@ -69,7 +68,7 @@
process.PFInputsTask = cms.Task(
process.TTClustersFromPhase2TrackerDigis,
process.TTStubsFromPhase2TrackerDigis,
process.TrackerDTCProducer,
process.ProducerDTC,
process.offlineBeamSpot,
process.l1tTTTracksFromTrackletEmulation,
process.SimL1EmulatorTask
Expand Down
16 changes: 4 additions & 12 deletions L1Trigger/TrackFindingTracklet/interface/ChannelAssignment.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,12 @@ namespace trklet {
int widthSeedStubId() const { return widthSeedStubId_; }
// number of bits used to distinguish between tilted and untilded barrel modules or 2S and PS endcap modules
int widthPSTilt() const { return widthPSTilt_; }
// depth of fifos within systolic array
int depthMemory() const { return depthMemory_; }
//
int widthCot() const { return widthCot_; }
// number of comparison modules used in each DR node
int numComparisonModules() const { return numComparisonModules_; }
// min number of shared stubs to identify duplicates
int minIdenticalStubs() const { return minIdenticalStubs_; }
// number of DR nodes
int numNodesDR() const { return numNodesDR_; }
// number of used seed types in tracklet algorithm
int numSeedTypes() const { return numSeedTypes_; }
// sets layerId (0-7 in sequence the seed type projects to) of given TTStubRef and seedType, returns false if seeed stub
Expand All @@ -66,8 +64,6 @@ namespace trklet {
int channelId(int seedType, int layerId) const;
// max number of seeding layers
int numSeedingLayers() const { return numSeedingLayers_; }
// return DR node for given ttTrackRef
int nodeDR(const TTTrackRef& ttTrackRef) const;

private:
// helper class to store configurations
Expand All @@ -82,18 +78,14 @@ namespace trklet {
int widthSeedStubId_;
// number of bits used to distinguish between tilted and untilded barrel modules or 2S and PS endcap modules
int widthPSTilt_;
// depth of fifos within systolic array
int depthMemory_;
// positive pt Boundaries in GeV (symmetric negatives are assumed), first boundary is pt cut, last boundary is infinity, defining ot bins used by DR
std::vector<double> ptBoundaries_;
//
int widthCot_;
// DRin parameter
edm::ParameterSet pSetDR_;
// number of comparison modules used in each DR node
int numComparisonModules_;
// min number of shared stubs to identify duplicates [default: 3]
int minIdenticalStubs_;
// number of DR nodes
int numNodesDR_;
// seed type names
std::vector<std::string> seedTypeNames_;
// number of used seed types in tracklet algorithm
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef L1Trigger_TrackFindingTracklet_DR_h
#define L1Trigger_TrackFindingTracklet_DR_h
#ifndef L1Trigger_TrackFindingTracklet_DuplicateRemoval_h
#define L1Trigger_TrackFindingTracklet_DuplicateRemoval_h

#include "L1Trigger/TrackTrigger/interface/Setup.h"
#include "L1Trigger/TrackerTFP/interface/DataFormats.h"
Expand All @@ -9,42 +9,39 @@

namespace trklet {

/*! \class trklet::DR
/*! \class trklet::DuplicateRemoval
* \brief Class to bit- and clock-accurate emulate duplicate removal
* DR identifies duplicates based on pairs of tracks that share stubs in at least 3 layers.
* It keeps the first such track in each pair.
* It keeps the first such track in each pair. The Track order is determined by TrackMultiplexer.
* \author Thomas Schuh
* \date 2023, Feb
*/
class DR {
class DuplicateRemoval {
public:
DR(const edm::ParameterSet& iConfig,
const tt::Setup* setup_,
const trackerTFP::DataFormats* dataFormats,
const ChannelAssignment* channelAssignment,
int region);
~DR() {}
DuplicateRemoval(const edm::ParameterSet& iConfig,
const tt::Setup* setup_,
const trackerTFP::DataFormats* dataFormats,
const ChannelAssignment* channelAssignment,
int region);
~DuplicateRemoval() {}
// read in and organize input tracks and stubs
void consume(const tt::StreamsTrack& streamsTrack, const tt::StreamsStub& streamsStub);
// fill output products
void produce(tt::StreamsStub& accpetedStubs,
tt::StreamsTrack& acceptedTracks,
tt::StreamsStub& lostStubs,
tt::StreamsTrack& lostTracks);
void produce(tt::StreamsTrack& acceptedTracks, tt::StreamsStub& accpetedStubs);

private:
struct Stub {
Stub(const tt::FrameStub& frame, int stubId, int channel) : frame_(frame), stubId_(stubId), channel_(channel) {}
Stub(const tt::FrameStub& frame, int stubId, int layer) : frame_(frame), stubId_(stubId), layer_(layer) {}
bool operator==(const Stub& s) const { return s.stubId_ == stubId_; }
tt::FrameStub frame_;
// all stubs id
int stubId_;
// kf layer id
int channel_;
int layer_;
};
struct Track {
// max number of stubs a track may formed of (we allow only one stub per layer)
static constexpr int max_ = 7;
static constexpr int max_ = 8;
Track() { stubs_.reserve(max_); }
Track(const tt::FrameTrack& frame, const std::vector<Stub*>& stubs) : frame_(frame), stubs_(stubs) {}
tt::FrameTrack frame_;
Expand All @@ -67,7 +64,7 @@ namespace trklet {
// storage of input stubs
std::vector<Stub> stubs_;
// h/w liked organized pointer to input tracks
std::vector<std::vector<Track*>> input_;
std::vector<Track*> input_;
};

} // namespace trklet
Expand Down
10 changes: 6 additions & 4 deletions L1Trigger/TrackFindingTracklet/interface/HitPatternHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,13 @@ namespace hph {
int etaRegion(double z0, double cot, bool useNewKF) const;
int digiCot(double cot, int binEta) const;
int digiZT(double z0, double cot, int binEta) const;
const std::vector<int>& layerEncoding(int binEta, int binZT, int binCot) const {
return layerEncoding_.layerEncoding(binEta, binZT, binCot);
const std::vector<int> layerEncoding(int binEta, int binZT, int binCot) const {
//return layerEncoding_.layerEncoding(binEta, binZT, binCot);
return std::vector<int>();
}
const std::map<int, const tt::SensorModule*>& layerEncodingMap(int binEta, int binZT, int binCot) const {
return layerEncoding_.layerEncodingMap(binEta, binZT, binCot);
const std::map<int, const tt::SensorModule*> layerEncodingMap(int binEta, int binZT, int binCot) const {
//return layerEncoding_.layerEncodingMap(binEta, binZT, binCot);
return std::map<int, const tt::SensorModule*>();
}

private:
Expand Down
Loading

0 comments on commit 2a119b3

Please sign in to comment.