Skip to content

Commit

Permalink
Merge pull request #42663 from cms-L1TK/L1TK-PR-13_3_0_pre2
Browse files Browse the repository at this point in the history
Improvements to L1 tracking code
  • Loading branch information
cmsbuild authored Dec 11, 2023
2 parents bb13ad1 + faa3fde commit afa2d7c
Show file tree
Hide file tree
Showing 78 changed files with 3,733 additions and 1,337 deletions.
17 changes: 12 additions & 5 deletions L1Trigger/TrackFindingTMTT/interface/L1fittedTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,18 @@ namespace tmtt {

// Is the fitted track trajectory within the same (eta,phi) sector of the HT used to find it?
bool consistentSector() const {
bool insidePhi =
(std::abs(reco::deltaPhi(this->phiAtChosenR(done_bcon_), secTmp_->phiCentre())) < secTmp_->sectorHalfWidth());
bool insideEta =
(this->zAtChosenR() > secTmp_->zAtChosenR_Min() && this->zAtChosenR() < secTmp_->zAtChosenR_Max());
return (insidePhi && insideEta);
if (settings_->hybrid()) {
float phiCentre = 2. * M_PI * iPhiSec() / settings_->numPhiSectors();
float sectorHalfWidth = M_PI / settings_->numPhiSectors();
bool insidePhi = (std::abs(reco::deltaPhi(this->phiAtChosenR(done_bcon_), phiCentre)) < sectorHalfWidth);
return insidePhi;
} else {
bool insidePhi = (std::abs(reco::deltaPhi(this->phiAtChosenR(done_bcon_), secTmp_->phiCentre())) <
secTmp_->sectorHalfWidth());
bool insideEta =
(this->zAtChosenR() > secTmp_->zAtChosenR_Min() && this->zAtChosenR() < secTmp_->zAtChosenR_Max());
return (insidePhi && insideEta);
}
}

// Digitize track and degrade helix parameter resolution according to effect of digitisation.
Expand Down
12 changes: 6 additions & 6 deletions L1Trigger/TrackFindingTMTT/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<use name="L1Trigger/TrackFindingTMTT"/>
<use name="MagneticField/Engine"/>
<use name="MagneticField/Records"/>

<flags CXXFLAGS="-g -Wno-unused-variable -Wno-misleading-indentation"/>
<flags EDM_PLUGIN="1"/>
<library file="*.cc" name="TrackFindingTMTTPlugins">
<use name="L1Trigger/TrackFindingTMTT"/>
<use name="MagneticField/Engine"/>
<use name="MagneticField/Records"/>
<flags EDM_PLUGIN="1"/>
</library>

1 change: 0 additions & 1 deletion L1Trigger/TrackFindingTMTT/plugins/TMTrackProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ namespace tmtt {

namespace {
std::once_flag printOnce;
std::once_flag callOnce;
} // namespace

std::unique_ptr<GlobalCacheTMTT> TMTrackProducer::initializeGlobalCache(edm::ParameterSet const& iConfig) {
Expand Down
6 changes: 3 additions & 3 deletions L1Trigger/TrackFindingTMTT/test/tmtt_tf_analysis_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@

if GEOMETRY == "D88":
# Read data from card files (defines getCMSdataFromCards()):
#from MCsamples.RelVal_1130_D76.PU200_TTbar_14TeV_cfi import *
#from MCsamples.RelVal_1260_D88.PU200_TTbar_14TeV_cfi import *
#inputMC = getCMSdataFromCards()

# Or read .root files from directory on local computer:
#dirName = "$myDir/whatever/"
#inputMC=getCMSlocaldata(dirName)

# Or read specified dataset (accesses CMS DB, so use this method only occasionally):
#dataName="/RelValTTbar_14TeV/CMSSW_11_3_0_pre6-PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/GEN-SIM-DIGI-RAW"
#dataName="/RelValTTbar_14TeV/CMSSW_12_6_0-PU_125X_mcRun4_realistic_v5_2026D88PU200RV183v2-v1/GEN-SIM-DIGI-RAW"
#inputMC=getCMSdata(dataName)

# Or read specified .root file:
inputMC = ["/store/relval/CMSSW_12_6_0_pre4/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_125X_mcRun4_realistic_v2_2026D88PU200-v1/2590000/00b3d04b-4c7b-4506-8d82-9538fb21ee19.root"]
inputMC = ["/store/mc/CMSSW_12_6_0/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_125X_mcRun4_realistic_v5_2026D88PU200RV183v2-v1/30000/0959f326-3f52-48d8-9fcf-65fc41de4e27.root"]

else:
print("this is not a valid geometry!!!")
Expand Down
2 changes: 1 addition & 1 deletion L1Trigger/TrackFindingTracklet/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<use name="root"/>
<use name="rootrflx"/>
<use name="xerces-c"/>
<use name="DataFormats/L1TrackTrigger"/>
<use name="FWCore/MessageLogger"/>
<use name="FWCore/Utilities"/>
<use name="L1Trigger/TrackTrigger"/>
<use name="L1Trigger/TrackFindingTMTT"/>
<use name="L1Trigger/TrackerTFP"/>
<flags CXXFLAGS="-DUSEHYBRID"/>
Expand Down
14 changes: 6 additions & 8 deletions L1Trigger/TrackFindingTracklet/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
To run L1 tracking & create TTree of tracking performance:
To run the L1 tracking & create a TTree of tracking performance:

cmsRun L1TrackNtupleMaker_cfg.py

By setting variable L1TRKALGO inside this script, you can change the
L1 tracking algo used.
By setting variable L1TRKALGO inside this script, you can change which
L1 tracking algo is used. It defaults to HYBRID.

For the baseline HYBRID algo, which runs Tracklet pattern reco followed
by KF track fit, TrackFindingTracklet/interface/Settings.h configures the pattern reco, (although some
parameters there are overridden by l1tTTTracksFromTrackletEmulation_cfi.py).
The KF fit is configued by the constructor of TrackFindingTMTT/src/Settings.cc.
by KF track fit, TrackFindingTracklet/interface/Settings.h configures the pattern reco stage, (although some parameters there are overridden by l1tTTTracksFromTrackletEmulation_cfi.py).
The KF fit is configured by the constructor of TrackFindingTMTT/src/Settings.cc.

The ROOT macros L1TrackNtuplePlot.C & L1TrackQualityPlot.C make tracking
performance & BDT track quality performance plots from the TTree.
Both can be run via makeHists.csh .

The optional "NewKF" track fit, (which is not yet baseline, as no duplicate
track removal is compatible with it), is configured via
The optional "NewKF" track fit can be run by changing L1TRKALGO=HYBRID_NEWKF. It corresponds to the curent FW, but is is not yet the default, as only a basic duplicate track removal is available for it. It is configured via
TrackTrigger/python/ProducerSetup_cfi.py, (which also configures the DTC).
64 changes: 50 additions & 14 deletions L1Trigger/TrackFindingTracklet/interface/ChannelAssignment.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,28 @@ namespace trklet {
ChannelAssignment() {}
ChannelAssignment(const edm::ParameterSet& iConfig, const tt::Setup* setup);
~ChannelAssignment() {}
// sets channelId of given TTTrackRef from TrackBuilder or PurgeDuplicate (if enabled), return false if track outside pt range
bool channelId(const TTTrackRef& ttTrackRef, int& channelId);
// number of used channels for tracks
// returns channelId of given TTTrackRef from TrackBuilder
int channelId(const TTTrackRef& ttTrackRef) const;
// number of used TB channels for tracks
int numChannelsTrack() const { return numChannelsTrack_; }
// number of used channels for stubs
// number of used TB channels for stubs
int numChannelsStub() const { return numChannelsStub_; }
// number of bits used to represent layer id [barrel: 0-5, discs: 6-10]
int widthLayerId() const { return widthLayerId_; }
// number of bits used to represent stub id for projected stubs
int widthStubId() const { return widthStubId_; }
// number of bits used to represent stub id for seed stubs
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_; }
// 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 @@ -42,29 +58,49 @@ namespace trklet {
int offsetStub(int channelTrack) const;
// seed layers for given seed type id
const std::vector<int>& seedingLayers(int seedType) const { return seedTypesSeedLayers_.at(seedType); }
//
// returns SensorModule::Type for given TTStubRef
tt::SensorModule::Type type(const TTStubRef& ttStubRef) const { return setup_->type(ttStubRef); }
//
int layerId(int seedType, int channel) const { return seedTypesProjectionLayers_.at(seedType).at(channel); }
//
// layers a seed types can project to using default layer id [barrel: 1-6, discs: 11-15]
int layerId(int seedType, int channel) const;
// returns TBout channel Id for given seed type and default layer id [barrel: 1-6, discs: 11-15], returns -1 if layerId and seedType are inconsistent
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
const tt::Setup* setup_;
// use tracklet seed type as channel id if False, binned track pt used if True
bool useDuplicateRemoval_;
// pt Boundaries in GeV, last boundary is infinity
std::vector<double> boundaries_;
// DRin parameter
edm::ParameterSet pSetDRin_;
// number of bits used to represent layer id [barrel: 0-5, discs: 6-10]
int widthLayerId_;
// number of bits used to represent stub id for projected stubs
int widthStubId_;
// number of bits used to represent stub id for seed stubs
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_;
// 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
int numSeedTypes_;
// number of used channels for tracks
// number of used TB channels for tracks
int numChannelsTrack_;
// number of used channels for stubs
// number of used TB channels for stubs
int numChannelsStub_;
// seeding layers of seed types using default layer id [barrel: 1-6, discs: 11-15]
std::vector<std::vector<int>> seedTypesSeedLayers_;
Expand Down
75 changes: 75 additions & 0 deletions L1Trigger/TrackFindingTracklet/interface/DR.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#ifndef L1Trigger_TrackFindingTracklet_DR_h
#define L1Trigger_TrackFindingTracklet_DR_h

#include "L1Trigger/TrackTrigger/interface/Setup.h"
#include "L1Trigger/TrackerTFP/interface/DataFormats.h"
#include "L1Trigger/TrackFindingTracklet/interface/ChannelAssignment.h"

#include <vector>

namespace trklet {

/*! \class trklet::DR
* \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.
* \author Thomas Schuh
* \date 2023, Feb
*/
class DR {
public:
DR(const edm::ParameterSet& iConfig,
const tt::Setup* setup_,
const trackerTFP::DataFormats* dataFormats,
const ChannelAssignment* channelAssignment,
int region);
~DR() {}
// 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);

private:
struct Stub {
Stub(const tt::FrameStub& frame, int stubId, int channel) : frame_(frame), stubId_(stubId), channel_(channel) {}
bool operator==(const Stub& s) const { return s.stubId_ == stubId_; }
tt::FrameStub frame_;
// all stubs id
int stubId_;
// kf layer id
int channel_;
};
struct Track {
// max number of stubs a track may formed of (we allow only one stub per layer)
static constexpr int max_ = 7;
Track() { stubs_.reserve(max_); }
Track(const tt::FrameTrack& frame, const std::vector<Stub*>& stubs) : frame_(frame), stubs_(stubs) {}
tt::FrameTrack frame_;
std::vector<Stub*> stubs_;
};
// compares two tracks, returns true if those are considered duplicates
bool equalEnough(Track* t0, Track* t1) const;
// true if truncation is enbaled
bool enableTruncation_;
// provides run-time constants
const tt::Setup* setup_;
// provides dataformats
const trackerTFP::DataFormats* dataFormats_;
// helper class to assign tracks to channel
const ChannelAssignment* channelAssignment_;
// processing region (0 - 8) aka processing phi nonant
const int region_;
// storage of input tracks
std::vector<Track> tracks_;
// storage of input stubs
std::vector<Stub> stubs_;
// h/w liked organized pointer to input tracks
std::vector<std::vector<Track*>> input_;
};

} // namespace trklet

#endif
Loading

0 comments on commit afa2d7c

Please sign in to comment.