Skip to content

Commit

Permalink
f/w sync
Browse files Browse the repository at this point in the history
  • Loading branch information
tschuh committed Nov 22, 2024
1 parent c4d3a11 commit d0a5b1b
Show file tree
Hide file tree
Showing 28 changed files with 826 additions and 1,014 deletions.
6 changes: 3 additions & 3 deletions L1Trigger/TrackTrigger/interface/Setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ namespace tt {
// number of finer phiT bins inside HT bin
int ctbNumBinsPhiT() const { return ctbNumBinsPhiT_; }
// number of used z0 bins inside GP ZT bin
int ctbNumBinsZ0() const { return ctbNumBinsZ0_; }
int ctbNumBinsCot() const { return ctbNumBinsCot_; }
//number of used zT bins inside GP ZT bin
int ctbNumBinsZT() const { return ctbNumBinsZT_; }
// required number of stub layers to form a candidate
Expand Down Expand Up @@ -784,8 +784,8 @@ namespace tt {
int ctbNumBinsInv2R_;
// number of finer phiT bins inside HT bin
int ctbNumBinsPhiT_;
// number of used z0 bins inside GP ZT bin
int ctbNumBinsZ0_;
// number of used cot bins inside GP ZT bin
int ctbNumBinsCot_;
//number of used zT bins inside GP ZT bin
int ctbNumBinsZT_;
// required number of stub layers to form a candidate
Expand Down
3 changes: 1 addition & 2 deletions L1Trigger/TrackTrigger/python/Setup_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@
NumBinsPhiT = cms.int32 ( 2 ), # number of phi sectors used in hough transform
NumBinsZT = cms.int32 ( 32 ), # number of eta sectors used in hough transform
ChosenRofZ = cms.double( 57.76 ), # critical radius defining r-z sector shape in cm
#ChosenRofZ = cms.double( 90.37 ), # critical radius defining r-z sector shape in cm
DepthMemory = cms.int32 ( 32 ), # fifo depth in stub router firmware
WidthModule = cms.int32 ( 3 ), #
PosPS = cms.int32 ( 2 ), #
Expand All @@ -162,7 +161,7 @@
CleanTrackBuilder = cms.PSet (
NumBinsInv2R = cms.int32( 4 ), # number of inv2R bins
NumBinsPhiT = cms.int32( 4 ), # number of phiT bins
NumBinsZ0 = cms.int32( 4 ), # number of z0 bins
NumBinsCot = cms.int32( 4 ), # number of cot bins
NumBinsZT = cms.int32( 4 ), # number of zT bins
MinLayers = cms.int32( 4 ), # required number of stub layers to form a candidate
MaxTracks = cms.int32( 16 ), # max number of output tracks per node
Expand Down
2 changes: 1 addition & 1 deletion L1Trigger/TrackTrigger/src/Setup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ namespace tt {
pSetCTB_(iConfig.getParameter<ParameterSet>("CleanTrackBuilder")),
ctbNumBinsInv2R_(pSetCTB_.getParameter<int>("NumBinsInv2R")),
ctbNumBinsPhiT_(pSetCTB_.getParameter<int>("NumBinsPhiT")),
ctbNumBinsZ0_(pSetCTB_.getParameter<int>("NumBinsZ0")),
ctbNumBinsCot_(pSetCTB_.getParameter<int>("NumBinsCot")),
ctbNumBinsZT_(pSetCTB_.getParameter<int>("NumBinsZT")),
ctbMinLayers_(pSetCTB_.getParameter<int>("MinLayers")),
ctbMaxTracks_(pSetCTB_.getParameter<int>("MaxTracks")),
Expand Down
3 changes: 3 additions & 0 deletions L1Trigger/TrackerTFP/interface/CleanTrackBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace trackerTFP {
const tt::Setup* setup,
const DataFormats* dataFormats,
const LayerEncoding* layerEncoding,
const DataFormat& cot,
std::vector<StubCTB>& stubs,
std::vector<TrackCTB>& tracks);
~CleanTrackBuilder() {}
Expand Down Expand Up @@ -120,6 +121,8 @@ namespace trackerTFP {
const DataFormats* dataFormats_;
//
const LayerEncoding* layerEncoding_;
//
DataFormat cot_;
// container of internal stubs
std::vector<Stub> stubs_;
// container of internal tracks
Expand Down
32 changes: 11 additions & 21 deletions L1Trigger/TrackerTFP/interface/DataFormats.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ namespace trackerTFP {
//Base class representing format of a variable
class DataFormat {
public:
DataFormat() {}
DataFormat(bool twos, bool biased = true) : twos_(twos), width_(0), base_(1.), range_(0.) {}
DataFormat(bool twos, int width, double base, double range) : twos_(twos), width_(width), base_(base), range_(range) {}
~DataFormat() {}
// converts int to bitvector
TTBV ttBV(int i) const { return TTBV(i, width_, twos_); }
Expand Down Expand Up @@ -155,11 +157,7 @@ namespace trackerTFP {
Format<Variable::dZ, Process::ctb>::Format(const tt::Setup* setup);
template <>
Format<Variable::layer, Process::ctb>::Format(const tt::Setup* setup);
template <>
Format<Variable::inv2R, Process::ctb>::Format(const tt::Setup* setup);

template <>
Format<Variable::phi, Process::kf>::Format(const tt::Setup* setup);
template <>
Format<Variable::inv2R, Process::kf>::Format(const tt::Setup* setup);
template <>
Expand All @@ -169,20 +167,12 @@ namespace trackerTFP {
template <>
Format<Variable::zT, Process::kf>::Format(const tt::Setup* setup);
template <>
Format<Variable::phi, Process::kf>::Format(const tt::Setup* setup);
template <>
Format<Variable::match, Process::kf>::Format(const tt::Setup* setup);

template <>
Format<Variable::phi, Process::dr>::Format(const tt::Setup* setup);
template <>
Format<Variable::z, Process::dr>::Format(const tt::Setup* setup);
template <>
Format<Variable::inv2R, Process::dr>::Format(const tt::Setup* setup);
template <>
Format<Variable::phiT, Process::dr>::Format(const tt::Setup* setup);
template <>
Format<Variable::cot, Process::dr>::Format(const tt::Setup* setup);
template <>
Format<Variable::zT, Process::dr>::Format(const tt::Setup* setup);

/*! \class trackerTFP::DataFormats
* \brief Class to calculate and provide dataformats used by Track Trigger emulator
Expand All @@ -208,15 +198,15 @@ namespace trackerTFP {
Process::ht,
Process::ht,
Process::kf,
Process::dr,
Process::kf,
Process::x}}, // Variable::phi
{{Process::dtc,
Process::dtc,
Process::gp,
Process::gp,
Process::gp,
Process::gp,
Process::dr,
Process::gp,
Process::x}}, // Variable::z
{{Process::x,
Process::x,
Expand All @@ -238,17 +228,17 @@ namespace trackerTFP {
Process::ht,
Process::ht,
Process::ht,
Process::ctb,
Process::ht,
Process::kf,
Process::kf,
Process::dr,
Process::tfp}}, // Variable::inv2R
{{Process::gp,
Process::gp,
Process::gp,
Process::ht,
Process::ht,
Process::kf,
Process::dr,
Process::kf,
Process::tfp}}, // Variable::phiT
{{Process::x,
Process::x,
Expand All @@ -264,7 +254,7 @@ namespace trackerTFP {
Process::gp,
Process::gp,
Process::kf,
Process::dr,
Process::kf,
Process::tfp}}, // Variable::zT
{{Process::dtc,
Process::dtc,
Expand Down Expand Up @@ -314,7 +304,7 @@ namespace trackerTFP {
{Variable::inv2R, Variable::phiT, Variable::zT}, // Process::ctb
{Variable::inv2R, Variable::phiT, Variable::cot, Variable::zT, Variable::match}, // Process::kf
{Variable::inv2R, Variable::phiT, Variable::cot, Variable::zT}, // Process::dr
{} // Process::dr
{} // Process::tfp
}};

public:
Expand Down
116 changes: 67 additions & 49 deletions L1Trigger/TrackerTFP/interface/KalmanFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace trackerTFP {
// Class to do helix fit to all tracks in a region.
class KalmanFilter {
public:
typedef State::Stub Stub;
KalmanFilter(const edm::ParameterSet& iConfig,
const tt::Setup* setup,
const DataFormats* dataFormats,
Expand All @@ -28,31 +29,89 @@ namespace trackerTFP {

// fill output products
void produce(const std::vector<std::vector<TrackCTB*>>& tracksIn,
const std::vector<std::vector<StubCTB*>>& stubsIn,
const std::vector<std::vector<Stub*>>& stubsIn,
std::vector<std::vector<TrackKF*>>& tracksOut,
std::vector<std::vector<std::vector<StubKF*>>>& stubsOut,
int& numAcceptedStates,
int& numLostStates,
std::deque<std::pair<double, double>>& chi2s);

private:
//
struct Track {
Track() {}
Track(int trackId,
int numConsistent,
int numConsistentPS,
double inv2R,
double phiT,
double cot,
double zT,
double chi20,
double chi21,
const TTBV& hitPattern,
TrackCTB* track,
const std::vector<StubCTB*>& stubs,
const std::vector<double>& phi,
const std::vector<double>& z)
: trackId_(trackId),
numConsistent_(numConsistent),
numConsistentPS_(numConsistentPS),
inv2R_(inv2R),
phiT_(phiT),
cot_(cot),
zT_(zT),
chi20_(chi20),
chi21_(chi21),
hitPattern_(hitPattern),
track_(track),
stubs_(stubs),
phi_(phi),
z_(z) {}
int trackId_;
int numConsistent_;
int numConsistentPS_;
double inv2R_;
double phiT_;
double cot_;
double zT_;
double chi20_;
double chi21_;
TTBV hitPattern_;
TrackCTB* track_;
std::vector<StubCTB*> stubs_;
std::vector<double> phi_;
std::vector<double> z_;
};
// remove and return first element of deque, returns nullptr if empty
template <class T>
T* pop_front(std::deque<T*>& ts) const;
// constraints double precision
double digi(VariableKF var, double val) const { return kalmanFilterFormats_->format(var).digi(val); }
//
int integer(VariableKF var, double val) const { return kalmanFilterFormats_->format(var).integer(val); }
//
void updateRangeActual(VariableKF var, double val) {
return kalmanFilterFormats_->format(var).updateRangeActual(val);
}
//
double base(VariableKF var) const { return kalmanFilterFormats_->format(var).base(); }
//
double digi(double val, double base) const { return (floor(val / base + 1.e-11) + .5) * base; }
int width(VariableKF var) const { return kalmanFilterFormats_->format(var).width(); }
//
int inRange(VariableKF var, double val) const { return kalmanFilterFormats_->format(var).inRange(val); }

// create Proto States
void createProtoStates(const std::vector<std::vector<TrackCTB*>>& tracksIn,
const std::vector<std::vector<StubCTB*>>& stubsIn,
const std::vector<std::vector<Stub*>>& stubsIn,
int channel,
std::deque<State*>& stream);
// calulcate seed parameter
void calcSeeds(std::deque<State*>& stream);
// apply final cuts
void finalize(std::deque<State*>& stream);
void finalize(const std::deque<State*>& stream, std::vector<Track>& finals);
// Transform States into Tracks
void conv(const std::deque<State*>& states,
void conv(const std::vector<Track*>& best,
std::vector<TrackKF*>& tracks,
std::vector<std::vector<StubKF*>>& stubs);
// adds a layer to states
Expand All @@ -62,7 +121,7 @@ namespace trackerTFP {
// Assign next combinatoric (i.e. not first in layer) stub to state
void comb(State*& state);
// best state selection
void accumulator(std::deque<State*>& stream);
void accumulator(std::vector<Track>& finals, std::vector<Track*>& best);
// updates state
void update(State*& state);

Expand All @@ -82,51 +141,10 @@ namespace trackerTFP {
std::vector<StubKF>& stubs_;
// container of all Kalman Filter states
std::deque<State> states_;
//
std::vector<Track> finals_;
// current layer used during state propagation
int layer_;

// dataformats of Kalman filter internals

DataFormatKF* x0_;
DataFormatKF* x1_;
DataFormatKF* x2_;
DataFormatKF* x3_;
DataFormatKF* H00_;
DataFormatKF* H12_;
DataFormatKF* m0_;
DataFormatKF* m1_;
DataFormatKF* v0_;
DataFormatKF* v1_;
DataFormatKF* r0_;
DataFormatKF* r1_;
DataFormatKF* S00_;
DataFormatKF* S01_;
DataFormatKF* S12_;
DataFormatKF* S13_;
DataFormatKF* K00_;
DataFormatKF* K10_;
DataFormatKF* K21_;
DataFormatKF* K31_;
DataFormatKF* R00_;
DataFormatKF* R11_;
DataFormatKF* R00Rough_;
DataFormatKF* R11Rough_;
DataFormatKF* invR00Approx_;
DataFormatKF* invR11Approx_;
DataFormatKF* invR00Cor_;
DataFormatKF* invR11Cor_;
DataFormatKF* invR00_;
DataFormatKF* invR11_;
DataFormatKF* C00_;
DataFormatKF* C01_;
DataFormatKF* C11_;
DataFormatKF* C22_;
DataFormatKF* C23_;
DataFormatKF* C33_;
DataFormatKF* r02_;
DataFormatKF* r12_;
DataFormatKF* chi20_;
DataFormatKF* chi21_;
};

} // namespace trackerTFP
Expand Down
Loading

0 comments on commit d0a5b1b

Please sign in to comment.