CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
trklet::DR Class Reference

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. More...

#include <DR.h>

Classes

struct  Stub
 
struct  Track
 

Public Member Functions

void consume (const tt::StreamsTrack &streamsTrack, const tt::StreamsStub &streamsStub)
 
 DR (const edm::ParameterSet &iConfig, const tt::Setup *setup_, const trackerTFP::DataFormats *dataFormats, const ChannelAssignment *channelAssignment, int region)
 
void produce (tt::StreamsStub &accpetedStubs, tt::StreamsTrack &acceptedTracks, tt::StreamsStub &lostStubs, tt::StreamsTrack &lostTracks)
 
 ~DR ()
 

Private Member Functions

bool equalEnough (Track *t0, Track *t1) const
 

Private Attributes

const ChannelAssignmentchannelAssignment_
 
const trackerTFP::DataFormatsdataFormats_
 
bool enableTruncation_
 
std::vector< std::vector< Track * > > input_
 
const int region_
 
const tt::Setupsetup_
 
std::vector< Stubstubs_
 
std::vector< Tracktracks_
 

Detailed Description

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

Definition at line 19 of file DR.h.

Constructor & Destructor Documentation

◆ DR()

trklet::DR::DR ( const edm::ParameterSet iConfig,
const tt::Setup setup_,
const trackerTFP::DataFormats dataFormats,
const ChannelAssignment channelAssignment,
int  region 
)

Definition at line 14 of file DR.cc.

19  : enableTruncation_(iConfig.getParameter<bool>("EnableTruncation")),
20  setup_(setup),
21  dataFormats_(dataFormats),
22  channelAssignment_(channelAssignment),
23  region_(region),
std::vector< std::vector< Track * > > input_
Definition: DR.h:70
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
bool enableTruncation_
Definition: DR.h:56
const int region_
Definition: DR.h:64
const tt::Setup * setup_
Definition: DR.h:58
const ChannelAssignment * channelAssignment_
Definition: DR.h:62
const trackerTFP::DataFormats * dataFormats_
Definition: DR.h:60

◆ ~DR()

trklet::DR::~DR ( )
inline

Definition at line 26 of file DR.h.

26 {}

Member Function Documentation

◆ consume()

void trklet::DR::consume ( const tt::StreamsTrack streamsTrack,
const tt::StreamsStub streamsStub 
)

Definition at line 27 of file DR.cc.

References channelAssignment_, dataFormats_, trackerTFP::DataFormats::format(), amptDefault_cfi::frame, input, input_, createfilelist::int, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, tt::Setup::numLayers(), trklet::ChannelAssignment::numNodesDR(), PVValHelper::phi, alignCSCRings::r, region_, setup_, stubs_, tracks_, trackerTFP::DataFormat::width(), trklet::ChannelAssignment::widthLayerId(), trklet::ChannelAssignment::widthPSTilt(), trklet::ChannelAssignment::widthSeedStubId(), and detailsBasic3DVector::z.

27  {
28  const int offsetTrack = region_ * channelAssignment_->numNodesDR();
29  auto nonNullTrack = [](int sum, const FrameTrack& frame) { return sum + (frame.first.isNonnull() ? 1 : 0); };
30  auto nonNullStub = [](int sum, const FrameStub& frame) { return sum + (frame.first.isNonnull() ? 1 : 0); };
31  // count tracks and stubs and reserve corresponding vectors
32  int sizeTracks(0);
33  int sizeStubs(0);
34  for (int channel = 0; channel < channelAssignment_->numNodesDR(); channel++) {
35  const int streamTrackId = offsetTrack + channel;
36  const int offsetStub = streamTrackId * setup_->numLayers();
37  const StreamTrack& streamTrack = streamsTrack[streamTrackId];
38  input_[channel].reserve(streamTrack.size());
39  sizeTracks += accumulate(streamTrack.begin(), streamTrack.end(), 0, nonNullTrack);
40  for (int layer = 0; layer < setup_->numLayers(); layer++) {
41  const StreamStub& streamStub = streamsStub[offsetStub + layer];
42  sizeStubs += accumulate(streamStub.begin(), streamStub.end(), 0, nonNullStub);
43  }
44  }
45  tracks_.reserve(sizeTracks);
46  stubs_.reserve(sizeStubs);
47  // transform input data into handy structs
48  for (int channel = 0; channel < channelAssignment_->numNodesDR(); channel++) {
49  vector<Track*>& input = input_[channel];
50  const int streamTrackId = offsetTrack + channel;
51  const int offsetStub = streamTrackId * setup_->numLayers();
52  const StreamTrack& streamTrack = streamsTrack[streamTrackId];
53  for (int frame = 0; frame < (int)streamTrack.size(); frame++) {
54  const FrameTrack& frameTrack = streamTrack[frame];
55  if (frameTrack.first.isNull()) {
56  input.push_back(nullptr);
57  continue;
58  }
59  vector<Stub*> stubs;
60  stubs.reserve(setup_->numLayers());
61  for (int layer = 0; layer < setup_->numLayers(); layer++) {
62  const FrameStub& frameStub = streamsStub[offsetStub + layer][frame];
63  if (frameStub.first.isNull())
64  continue;
65  TTBV ttBV = frameStub.second;
66  const TTBV z(ttBV, dataFormats_->format(Variable::z, Process::kfin).width(), 0, true);
67  ttBV >>= dataFormats_->format(Variable::z, Process::kfin).width();
68  const TTBV phi(ttBV, dataFormats_->format(Variable::phi, Process::kfin).width(), 0, true);
69  ttBV >>= dataFormats_->format(Variable::phi, Process::kfin).width();
70  const TTBV r(ttBV, dataFormats_->format(Variable::r, Process::kfin).width(), 0, true);
71  ttBV >>= dataFormats_->format(Variable::r, Process::kfin).width();
72  const TTBV stubId(ttBV, channelAssignment_->widthSeedStubId(), 0);
74  const TTBV layerId(ttBV, channelAssignment_->widthLayerId(), 0);
75  ttBV >>= channelAssignment_->widthLayerId();
76  const TTBV tilt(ttBV, channelAssignment_->widthPSTilt(), 0);
77  const FrameStub frame(frameStub.first,
78  Frame("1" + tilt.str() + layerId.str() + r.str() + phi.str() + z.str()));
79  stubs_.emplace_back(frame, stubId.val(), layer);
80  stubs.push_back(&stubs_.back());
81  }
82  tracks_.emplace_back(frameTrack, stubs);
83  input.push_back(&tracks_.back());
84  }
85  // remove all gaps between end and last track
86  for (auto it = input.end(); it != input.begin();)
87  it = (*--it) ? input.begin() : input.erase(it);
88  }
89  }
std::vector< std::vector< Track * > > input_
Definition: DR.h:70
std::bitset< TTBV::S_ > Frame
Definition: TTTypes.h:58
Bit vector used by Track Trigger emulators. Mainly used to convert integers into arbitrary (within ma...
Definition: TTBV.h:20
std::pair< TTStubRef, Frame > FrameStub
Definition: TTTypes.h:60
std::vector< FrameStub > StreamStub
Definition: TTTypes.h:63
float float float z
std::vector< FrameTrack > StreamTrack
Definition: TTTypes.h:64
static std::string const input
Definition: EdmProvDump.cc:50
std::pair< TTTrackRef, Frame > FrameTrack
Definition: TTTypes.h:62
const int region_
Definition: DR.h:64
const tt::Setup * setup_
Definition: DR.h:58
int numLayers() const
Definition: Setup.h:215
const ChannelAssignment * channelAssignment_
Definition: DR.h:62
std::vector< Track > tracks_
Definition: DR.h:66
std::vector< Stub > stubs_
Definition: DR.h:68
const trackerTFP::DataFormats * dataFormats_
Definition: DR.h:60
const DataFormat & format(Variable v, Process p) const
Definition: DataFormats.h:506

◆ equalEnough()

bool trklet::DR::equalEnough ( Track t0,
Track t1 
) const
private

Definition at line 148 of file DR.cc.

References channelAssignment_, trklet::ChannelAssignment::minIdenticalStubs(), tt::Setup::numLayers(), setup_, FrontierCondition_GT_autoExpress_cfi::t0, and RandomServiceHelper::t1.

Referenced by produce().

148  {
149  int same(0);
150  for (int layer = 0; layer < setup_->numLayers(); layer++) {
151  auto onLayer = [layer](Stub* stub) { return stub->channel_ == layer; };
152  const auto s0 = find_if(t0->stubs_.begin(), t0->stubs_.end(), onLayer);
153  const auto s1 = find_if(t1->stubs_.begin(), t1->stubs_.end(), onLayer);
154  if (s0 != t0->stubs_.end() && s1 != t1->stubs_.end() && **s0 == **s1)
155  same++;
156  }
157  return same >= channelAssignment_->minIdenticalStubs();
158  }
const tt::Setup * setup_
Definition: DR.h:58
int numLayers() const
Definition: Setup.h:215
const ChannelAssignment * channelAssignment_
Definition: DR.h:62

◆ produce()

void trklet::DR::produce ( tt::StreamsStub accpetedStubs,
tt::StreamsTrack acceptedTracks,
tt::StreamsStub lostStubs,
tt::StreamsTrack lostTracks 
)

Definition at line 92 of file DR.cc.

References trklet::DR::Stub::channel_, channelAssignment_, equalEnough(), trklet::DR::Stub::frame_, trackerTFP::hitPattern, input_, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, trklet::ChannelAssignment::numComparisonModules(), tt::Setup::numLayers(), trklet::ChannelAssignment::numNodesDR(), region_, setup_, HLT_2023v12_cff::track, and DiMuonV_cfg::tracks.

95  {
96  const int offsetTrack = region_ * channelAssignment_->numNodesDR();
97  for (int node = 0; node < channelAssignment_->numNodesDR(); node++) {
98  const int channelTrack = offsetTrack + node;
99  const int offsetStub = channelTrack * setup_->numLayers();
100  // remove duplicated tracks, no merge of stubs, one stub per layer expected
101  vector<Track*> cms(channelAssignment_->numComparisonModules(), nullptr);
102  vector<Track*>& tracks = input_[node];
103  for (Track*& track : tracks) {
104  if (!track)
105  // gaps propagate trough chain and appear in output stream
106  continue;
107  for (Track*& trackCM : cms) {
108  if (!trackCM) {
109  // tracks used in CMs propagate trough chain and appear in output stream unaltered
110  trackCM = track;
111  break;
112  }
113  if (equalEnough(track, trackCM)) {
114  // tracks compared in CMs propagate trough chain and appear in output stream as gap if identified as duplicate or unaltered elsewise
115  track = nullptr;
116  break;
117  }
118  }
119  }
120  // remove all gaps between end and last track
121  for (auto it = tracks.end(); it != tracks.begin();)
122  it = (*--it) ? tracks.begin() : tracks.erase(it);
123  // store output
124  StreamTrack& streamTrack = acceptedTracks[channelTrack];
125  streamTrack.reserve(tracks.size());
126  for (int layer = 0; layer < setup_->numLayers(); layer++)
127  accpetedStubs[offsetStub + layer].reserve(tracks.size());
128  for (Track* track : tracks) {
129  if (!track) {
130  streamTrack.emplace_back(FrameTrack());
131  for (int layer = 0; layer < setup_->numLayers(); layer++)
132  accpetedStubs[offsetStub + layer].emplace_back(FrameStub());
133  continue;
134  }
135  streamTrack.push_back(track->frame_);
137  for (Stub* stub : track->stubs_) {
138  hitPattern.set(stub->channel_);
139  accpetedStubs[offsetStub + stub->channel_].push_back(stub->frame_);
140  }
141  for (int layer : hitPattern.ids(false))
142  accpetedStubs[offsetStub + layer].emplace_back(FrameStub());
143  }
144  }
145  }
std::vector< std::vector< Track * > > input_
Definition: DR.h:70
Bit vector used by Track Trigger emulators. Mainly used to convert integers into arbitrary (within ma...
Definition: TTBV.h:20
std::pair< TTStubRef, Frame > FrameStub
Definition: TTTypes.h:60
std::vector< FrameTrack > StreamTrack
Definition: TTTypes.h:64
std::pair< TTTrackRef, Frame > FrameTrack
Definition: TTTypes.h:62
const int region_
Definition: DR.h:64
bool equalEnough(Track *t0, Track *t1) const
Definition: DR.cc:148
const tt::Setup * setup_
Definition: DR.h:58
int numLayers() const
Definition: Setup.h:215
Namespace of DDCMS conversion namespace.
const ChannelAssignment * channelAssignment_
Definition: DR.h:62
tt::FrameStub frame_
Definition: DataFormats.h:596

Member Data Documentation

◆ channelAssignment_

const ChannelAssignment* trklet::DR::channelAssignment_
private

Definition at line 62 of file DR.h.

Referenced by consume(), equalEnough(), and produce().

◆ dataFormats_

const trackerTFP::DataFormats* trklet::DR::dataFormats_
private

Definition at line 60 of file DR.h.

Referenced by consume().

◆ enableTruncation_

bool trklet::DR::enableTruncation_
private

Definition at line 56 of file DR.h.

◆ input_

std::vector<std::vector<Track*> > trklet::DR::input_
private

Definition at line 70 of file DR.h.

Referenced by consume(), and produce().

◆ region_

const int trklet::DR::region_
private

Definition at line 64 of file DR.h.

Referenced by consume(), and produce().

◆ setup_

const tt::Setup* trklet::DR::setup_
private

◆ stubs_

std::vector<Stub> trklet::DR::stubs_
private

Definition at line 68 of file DR.h.

Referenced by consume().

◆ tracks_

std::vector<Track> trklet::DR::tracks_
private

Definition at line 66 of file DR.h.

Referenced by consume().