CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
trackerDTC::DTC Class Reference

Class to represent an outer tracker DTC board. More...

#include <DTC.h>

Public Member Functions

 DTC (const edm::ParameterSet &iConfig, const tt::Setup *setup, const LayerEncoding *layerEncoding, int dtcId, const std::vector< std::vector< TTStubRef >> &stubsDTC)
 
void produce (TTDTC &accepted, TTDTC &lost)
 
 ~DTC ()
 

Private Types

typedef std::deque< Stub * > Stubs
 
typedef std::vector< StubsStubss
 
typedef std::vector< StubssStubsss
 

Private Member Functions

void merge (Stubss &inputs, Stubs &output, Stubs &lost)
 
Stubpop_front (Stubs &stubs)
 
void produce (const Stubss &stubss, TTDTC &product)
 
void split (Stubss &inputs, Stubss &outputs)
 

Private Attributes

int board_
 
bool enableTruncation_
 
Stubsss input_
 
Stubss lost_
 
std::vector< tt::SensorModule * > modules_
 
int region_
 
const tt::Setupsetup_
 
std::vector< Stubstubs_
 

Detailed Description

Class to represent an outer tracker DTC board.

Author
Thomas Schuh
Date
2020, Jan

Definition at line 19 of file DTC.h.

Member Typedef Documentation

◆ Stubs

typedef std::deque<Stub*> trackerDTC::DTC::Stubs
private

Definition at line 21 of file DTC.h.

◆ Stubss

typedef std::vector<Stubs> trackerDTC::DTC::Stubss
private

Definition at line 22 of file DTC.h.

◆ Stubsss

typedef std::vector<Stubss> trackerDTC::DTC::Stubsss
private

Definition at line 23 of file DTC.h.

Constructor & Destructor Documentation

◆ DTC()

trackerDTC::DTC::DTC ( const edm::ParameterSet iConfig,
const tt::Setup setup,
const LayerEncoding layerEncoding,
int  dtcId,
const std::vector< std::vector< TTStubRef >> &  stubsDTC 
)

Definition at line 14 of file DTC.cc.

References funct::abs(), trackerDTC::Stub::bend(), enableTruncation_, input_, remoteMonitoring_LASER_era2018_cfg::limit, lost_, modules_, GetRecoTauVFromDQM_MC_cff::next, nano_mu_digi_cff::region, singleTopDQM_cfi::setup, jetUpdater_cfi::sort, stubs_, and trackerDTC::Stub::valid().

19  : setup_(setup),
20  enableTruncation_(iConfig.getParameter<bool>("EnableTruncation")),
21  region_(dtcId / setup->numDTCsPerRegion()),
22  board_(dtcId % setup->numDTCsPerRegion()),
23  modules_(setup->dtcModules(dtcId)),
24  input_(setup->dtcNumRoutingBlocks(), Stubss(setup->dtcNumModulesPerRoutingBlock())),
25  lost_(setup->numOverlappingRegions()) {
26  // count number of stubs on this dtc
27  auto acc = [](int sum, const vector<TTStubRef>& stubsModule) { return sum + stubsModule.size(); };
28  const int nStubs = accumulate(stubsDTC.begin(), stubsDTC.end(), 0, acc);
29  stubs_.reserve(nStubs);
30  // convert and assign Stubs to DTC routing block channel
31  for (int modId = 0; modId < setup->numModulesPerDTC(); modId++) {
32  const vector<TTStubRef>& ttStubRefs = stubsDTC[modId];
33  if (ttStubRefs.empty())
34  continue;
35  // Module which produced this ttStubRefs
36  SensorModule* module = modules_.at(modId);
37  // DTC routing block id [0-1]
38  const int blockId = modId / setup->dtcNumModulesPerRoutingBlock();
39  // DTC routing blockc channel id [0-35]
40  const int channelId = modId % setup->dtcNumModulesPerRoutingBlock();
41  // convert TTStubs and fill input channel
42  Stubs& stubs = input_[blockId][channelId];
43  for (const TTStubRef& ttStubRef : ttStubRefs) {
44  stubs_.emplace_back(iConfig, setup, layerEncoding, module, ttStubRef);
45  Stub& stub = stubs_.back();
46  if (stub.valid())
47  // passed pt and eta cut
48  stubs.push_back(&stub);
49  }
50  // sort stubs by bend
51  sort(stubs.begin(), stubs.end(), [](Stub* lhs, Stub* rhs) { return abs(lhs->bend()) < abs(rhs->bend()); });
52  // truncate stubs if desired
53  if (!enableTruncation_ || (int)stubs.size() <= setup->numFramesFE())
54  continue;
55  // begin of truncated stubs
56  const auto limit = next(stubs.begin(), setup->numFramesFE());
57  // copy truncated stubs into lost output channel
58  for (int region = 0; region < setup->numOverlappingRegions(); region++)
59  copy_if(
60  limit, stubs.end(), back_inserter(lost_[region]), [region](Stub* stub) { return stub->inRegion(region); });
61  // remove truncated stubs form input channel
62  stubs.erase(limit, stubs.end());
63  }
64  }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::vector< Stub > stubs_
Definition: DTC.h:55
std::vector< Stubs > Stubss
Definition: DTC.h:22
bool enableTruncation_
Definition: DTC.h:47
Stubss lost_
Definition: DTC.h:59
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int region_
Definition: DTC.h:49
const tt::Setup * setup_
Definition: DTC.h:45
Stubsss input_
Definition: DTC.h:57
int board_
Definition: DTC.h:51
std::vector< tt::SensorModule * > modules_
Definition: DTC.h:53
std::deque< Stub * > Stubs
Definition: DTC.h:21

◆ ~DTC()

trackerDTC::DTC::~DTC ( )
inline

Definition at line 31 of file DTC.h.

31 {}

Member Function Documentation

◆ merge()

void trackerDTC::DTC::merge ( Stubss inputs,
Stubs output,
Stubs lost 
)
private

Definition at line 87 of file DTC.cc.

References tt::Setup::dtcDepthMemory(), enableTruncation_, input, PixelMapPlotter::inputs, createfilelist::int, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, remoteMonitoring_LASER_era2018_cfg::limit, GetRecoTauVFromDQM_MC_cff::next, tt::Setup::numFramesIO(), or, pop_front(), setup_, and svgfig::stack.

Referenced by produce(), and split().

87  {
88  // for each input one fifo
89  Stubss stacks(inputs.size());
90  // clock accurate firmware emulation, each while trip describes one clock tick
91  while (!all_of(inputs.begin(), inputs.end(), [](const Stubs& channel) { return channel.empty(); }) or
92  !all_of(stacks.begin(), stacks.end(), [](const Stubs& channel) { return channel.empty(); })) {
93  // fill fifos
94  for (int iInput = 0; iInput < (int)inputs.size(); iInput++) {
95  Stubs& input = inputs[iInput];
96  Stubs& stack = stacks[iInput];
97  if (input.empty())
98  continue;
99  Stub* stub = pop_front(input);
100  if (stub) {
101  if (enableTruncation_ && (int)stack.size() == setup_->dtcDepthMemory() - 1)
102  // kill current first stub when fifo overflows
103  lost.push_back(pop_front(stack));
104  stack.push_back(stub);
105  }
106  }
107  // route stub from a fifo to output if possible
108  bool nothingToRoute(true);
109  for (int iInput = inputs.size() - 1; iInput >= 0; iInput--) {
110  Stubs& stack = stacks[iInput];
111  if (stack.empty())
112  continue;
113  nothingToRoute = false;
114  output.push_back(pop_front(stack));
115  // only one stub can be routed to output per clock tick
116  break;
117  }
118  // each clock tick output will grow by one, if no stub is available then by a gap
119  if (nothingToRoute)
120  output.push_back(nullptr);
121  }
122  // truncate if desired
123  if (enableTruncation_ && (int)output.size() > setup_->numFramesIO()) {
124  const auto limit = next(output.begin(), setup_->numFramesIO());
125  copy_if(limit, output.end(), back_inserter(lost), [](Stub* stub) { return stub; });
126  output.erase(limit, output.end());
127  }
128  // remove all gaps between end and last stub
129  for (auto it = output.end(); it != output.begin();)
130  it = (*--it) ? output.begin() : output.erase(it);
131  }
int dtcDepthMemory() const
Definition: Setup.h:361
std::vector< Stubs > Stubss
Definition: DTC.h:22
Stub * pop_front(Stubs &stubs)
Definition: DTC.cc:166
bool enableTruncation_
Definition: DTC.h:47
static std::string const input
Definition: EdmProvDump.cc:50
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
stack
Definition: svgfig.py:559
const tt::Setup * setup_
Definition: DTC.h:45
Definition: output.py:1
int numFramesIO() const
Definition: Setup.h:157
std::deque< Stub * > Stubs
Definition: DTC.h:21

◆ pop_front()

Stub * trackerDTC::DTC::pop_front ( Stubs stubs)
private

Definition at line 166 of file DTC.cc.

Referenced by merge().

166  {
167  Stub* stub = deque.front();
168  deque.pop_front();
169  return stub;
170  }

◆ produce() [1/2]

void trackerDTC::DTC::produce ( TTDTC accepted,
TTDTC lost 
)

Definition at line 67 of file DTC.cc.

References tt::Setup::dtcNumRoutingBlocks(), input_, lost_, merge(), tt::Setup::numOverlappingRegions(), nano_mu_digi_cff::region, setup_, and split().

67  {
68  // router step 1: merges stubs of all modules connected to one routing block into one stream
69  Stubs lost;
70  Stubss blockStubs(setup_->dtcNumRoutingBlocks());
71  for (int routingBlock = 0; routingBlock < setup_->dtcNumRoutingBlocks(); routingBlock++)
72  merge(input_[routingBlock], blockStubs[routingBlock], lost);
73  // copy lost stubs during merge into lost output channel
74  for (int region = 0; region < setup_->numOverlappingRegions(); region++) {
75  auto inRegion = [region](Stub* stub) { return stub->inRegion(region); };
76  copy_if(lost.begin(), lost.end(), back_inserter(lost_[region]), inRegion);
77  }
78  // router step 2: merges stubs of all routing blocks and splits stubs into one stream per overlapping region
79  Stubss regionStubs(setup_->numOverlappingRegions());
80  split(blockStubs, regionStubs);
81  // fill products
82  produce(regionStubs, productAccepted);
83  produce(lost_, productLost);
84  }
void produce(TTDTC &accepted, TTDTC &lost)
Definition: DTC.cc:67
void split(Stubss &inputs, Stubss &outputs)
Definition: DTC.cc:134
std::vector< Stubs > Stubss
Definition: DTC.h:22
Stubss lost_
Definition: DTC.h:59
const tt::Setup * setup_
Definition: DTC.h:45
Stubsss input_
Definition: DTC.h:57
int numOverlappingRegions() const
Definition: Setup.h:351
int dtcNumRoutingBlocks() const
Definition: Setup.h:359
void merge(Stubss &inputs, Stubs &output, Stubs &lost)
Definition: DTC.cc:87
std::deque< Stub * > Stubs
Definition: DTC.h:21

◆ produce() [2/2]

void trackerDTC::DTC::produce ( const Stubss stubss,
TTDTC product 
)
private

Definition at line 152 of file DTC.cc.

References board_, region_, TTDTC::setStream(), cms::cuda::stream, and HcalDetIdTransform::transform().

152  {
153  int channel(0);
154  auto toFrame = [&channel](Stub* stub) {
155  return stub ? make_pair(stub->ttStubRef(), stub->frame(channel)) : FrameStub();
156  };
157  for (const Stubs& stubs : stubss) {
159  stream.reserve(stubs.size());
160  transform(stubs.begin(), stubs.end(), back_inserter(stream), toFrame);
161  product.setStream(region_, board_, channel++, stream);
162  }
163  }
void setStream(int dtcRegion, int dtcBoard, int dtcChannel, const tt::StreamStub &stream)
Definition: TTDTC.cc:24
std::pair< TTStubRef, Frame > FrameStub
Definition: TTTypes.h:60
std::vector< FrameStub > StreamStub
Definition: TTTypes.h:63
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
int region_
Definition: DTC.h:49
int board_
Definition: DTC.h:51
std::deque< Stub * > Stubs
Definition: DTC.h:21
unsigned transform(const HcalDetId &id, unsigned transformCode)

◆ split()

void trackerDTC::DTC::split ( Stubss inputs,
Stubss outputs 
)
private

Definition at line 134 of file DTC.cc.

References mps_fire::i, input, PixelMapPlotter::inputs, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, lost_, merge(), PatBasicFWLiteJetAnalyzer_Selector_cfg::outputs, nano_mu_digi_cff::region, cms::cuda::stream, HLT_2024v11_cff::streams, and HcalDetIdTransform::transform().

Referenced by produce().

134  {
135  int region(0);
136  auto regionMask = [&region](Stub* stub) { return stub && stub->inRegion(region) ? stub : nullptr; };
137  for (Stubs& output : outputs) {
138  // copy of masked inputs for each output
139  Stubss streams(inputs.size());
140  int i(0);
141  for (Stubs& input : inputs) {
142  Stubs& stream = streams[i++];
143  transform(input.begin(), input.end(), back_inserter(stream), regionMask);
144  for (auto it = stream.end(); it != stream.begin();)
145  it = (*--it) ? stream.begin() : stream.erase(it);
146  }
148  }
149  }
std::vector< Stubs > Stubss
Definition: DTC.h:22
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
static std::string const input
Definition: EdmProvDump.cc:50
Stubss lost_
Definition: DTC.h:59
Definition: output.py:1
void merge(Stubss &inputs, Stubs &output, Stubs &lost)
Definition: DTC.cc:87
std::deque< Stub * > Stubs
Definition: DTC.h:21
unsigned transform(const HcalDetId &id, unsigned transformCode)

Member Data Documentation

◆ board_

int trackerDTC::DTC::board_
private

Definition at line 51 of file DTC.h.

Referenced by produce().

◆ enableTruncation_

bool trackerDTC::DTC::enableTruncation_
private

Definition at line 47 of file DTC.h.

Referenced by DTC(), and merge().

◆ input_

Stubsss trackerDTC::DTC::input_
private

Definition at line 57 of file DTC.h.

Referenced by DTC(), and produce().

◆ lost_

Stubss trackerDTC::DTC::lost_
private

Definition at line 59 of file DTC.h.

Referenced by DTC(), produce(), and split().

◆ modules_

std::vector<tt::SensorModule*> trackerDTC::DTC::modules_
private

Definition at line 53 of file DTC.h.

Referenced by DTC().

◆ region_

int trackerDTC::DTC::region_
private

Definition at line 49 of file DTC.h.

Referenced by produce().

◆ setup_

const tt::Setup* trackerDTC::DTC::setup_
private

Definition at line 45 of file DTC.h.

Referenced by merge(), produce(), and upgradeWorkflowComponents.UpgradeWorkflow::setup().

◆ stubs_

std::vector<Stub> trackerDTC::DTC::stubs_
private

Definition at line 55 of file DTC.h.

Referenced by DTC().