CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
trackerDTC::DTC Class Reference

#include <DTC.h>

Public Member Functions

 DTC (const edm::ParameterSet &iConfig, const Setup &setup, 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< SensorModule * > modules_
 
int region_
 
const Setupsetup_
 
std::vector< Stubstubs_
 

Detailed Description

Definition at line 13 of file DTC.h.

Member Typedef Documentation

◆ Stubs

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

Definition at line 15 of file DTC.h.

◆ Stubss

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

Definition at line 16 of file DTC.h.

◆ Stubsss

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

Definition at line 17 of file DTC.h.

Constructor & Destructor Documentation

◆ DTC()

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

Definition at line 13 of file DTC.cc.

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

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

◆ ~DTC()

trackerDTC::DTC::~DTC ( )
inline

Definition at line 24 of file DTC.h.

24 {}

Member Function Documentation

◆ merge()

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

Definition at line 85 of file DTC.cc.

85  {
86  // for each input one fifo
87  Stubss stacks(inputs.size());
88  // clock accurate firmware emulation, each while trip describes one clock tick
89  while (!all_of(inputs.begin(), inputs.end(), [](const Stubs& channel) { return channel.empty(); }) or
90  !all_of(stacks.begin(), stacks.end(), [](const Stubs& channel) { return channel.empty(); })) {
91  // fill fifos
92  for (int iInput = 0; iInput < (int)inputs.size(); iInput++) {
93  Stubs& input = inputs[iInput];
94  Stubs& stack = stacks[iInput];
95  if (input.empty())
96  continue;
97  Stub* stub = pop_front(input);
98  if (stub) {
99  if (enableTruncation_ && (int)stack.size() == setup_->dtcDepthMemory() - 1)
100  // kill current first stub when fifo overflows
101  lost.push_back(pop_front(stack));
102  stack.push_back(stub);
103  }
104  }
105  // route stub from a fifo to output if possible
106  bool nothingToRoute(true);
107  for (int iInput = inputs.size() - 1; iInput >= 0; iInput--) {
108  Stubs& stack = stacks[iInput];
109  if (stack.empty())
110  continue;
111  nothingToRoute = false;
112  output.push_back(pop_front(stack));
113  // only one stub can be routed to output per clock tick
114  break;
115  }
116  // each clock tick output will grow by one, if no stub is available then by a gap
117  if (nothingToRoute)
118  output.push_back(nullptr);
119  }
120  // truncate if desired
121  if (enableTruncation_ && (int)output.size() > setup_->numFramesIO()) {
122  const auto limit = next(output.begin(), setup_->numFramesIO());
123  copy_if(limit, output.end(), back_inserter(lost), [](Stub* stub) { return stub; });
124  output.erase(limit, output.end());
125  }
126  // remove all gaps between end and last stub
127  for (auto it = output.end(); it != output.begin();)
128  it = (*--it) ? output.begin() : output.erase(it);
129  }

References trackerDTC::Setup::dtcDepthMemory(), enableTruncation_, input, PixelMapPlotter::inputs, createfilelist::int, remoteMonitoring_LED_IterMethod_cfg::limit, GetRecoTauVFromDQM_MC_cff::next, trackerDTC::Setup::numFramesIO(), or, convertSQLitetoXML_cfg::output, pop_front(), setup_, and svgfig::stack.

Referenced by produce(), and split().

◆ pop_front()

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

Definition at line 164 of file DTC.cc.

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

Referenced by merge().

◆ produce() [1/2]

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

Definition at line 150 of file DTC.cc.

150  {
151  int channel(0);
152  auto toFrame = [&channel](Stub* stub) {
153  return stub ? make_pair(stub->ttStubRef(), stub->frame(channel)) : TTDTC::Frame();
154  };
155  for (const Stubs& stubs : stubss) {
157  stream.reserve(stubs.size());
158  transform(stubs.begin(), stubs.end(), back_inserter(stream), toFrame);
159  product.setStream(region_, board_, channel++, stream);
160  }
161  }

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

◆ produce() [2/2]

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

Definition at line 65 of file DTC.cc.

65  {
66  // router step 1: merges stubs of all modules connected to one routing block into one stream
67  Stubs lost;
68  Stubss blockStubs(setup_->dtcNumRoutingBlocks());
69  for (int routingBlock = 0; routingBlock < setup_->dtcNumRoutingBlocks(); routingBlock++)
70  merge(input_[routingBlock], blockStubs[routingBlock], lost);
71  // copy lost stubs during merge into lost output channel
72  for (int region = 0; region < setup_->numOverlappingRegions(); region++) {
73  auto inRegion = [region](Stub* stub) { return stub->inRegion(region); };
74  copy_if(lost.begin(), lost.end(), back_inserter(lost_[region]), inRegion);
75  }
76  // router step 2: merges stubs of all routing blocks and splits stubs into one stream per overlapping region
77  Stubss regionStubs(setup_->numOverlappingRegions());
78  split(blockStubs, regionStubs);
79  // fill products
80  produce(regionStubs, productAccepted);
81  produce(lost_, productLost);
82  }

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

Referenced by trackerDTC::ProducerED::produce().

◆ split()

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

Definition at line 132 of file DTC.cc.

132  {
133  int region(0);
134  auto regionMask = [&region](Stub* stub) { return stub && stub->inRegion(region) ? stub : nullptr; };
135  for (Stubs& output : outputs) {
136  // copy of masked inputs for each output
137  Stubss streams(inputs.size());
138  int i(0);
139  for (Stubs& input : inputs) {
140  Stubs& stream = streams[i++];
141  transform(input.begin(), input.end(), back_inserter(stream), regionMask);
142  for (auto it = stream.end(); it != stream.begin();)
143  it = (*--it) ? stream.begin() : stream.erase(it);
144  }
146  }
147  }

References mps_fire::i, input, PixelMapPlotter::inputs, lost_, merge(), convertSQLitetoXML_cfg::output, PatBasicFWLiteJetAnalyzer_Selector_cfg::outputs, HLT_FULL_cff::region, cms::cuda::stream, HLT_Fake1_cff::streams, and HcalDetIdTransform::transform().

Referenced by produce().

Member Data Documentation

◆ board_

int trackerDTC::DTC::board_
private

Definition at line 45 of file DTC.h.

Referenced by produce().

◆ enableTruncation_

bool trackerDTC::DTC::enableTruncation_
private

Definition at line 41 of file DTC.h.

Referenced by DTC(), and merge().

◆ input_

Stubsss trackerDTC::DTC::input_
private

Definition at line 51 of file DTC.h.

Referenced by DTC(), and produce().

◆ lost_

Stubss trackerDTC::DTC::lost_
private

Definition at line 53 of file DTC.h.

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

◆ modules_

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

Definition at line 47 of file DTC.h.

Referenced by DTC().

◆ region_

int trackerDTC::DTC::region_
private

Definition at line 43 of file DTC.h.

Referenced by produce().

◆ setup_

const Setup* trackerDTC::DTC::setup_
private

Definition at line 39 of file DTC.h.

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

◆ stubs_

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

Definition at line 49 of file DTC.h.

Referenced by DTC().

mps_fire.i
i
Definition: mps_fire.py:428
input
static const std::string input
Definition: EdmProvDump.cc:48
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
cms::cuda::stream
cudaStream_t stream
Definition: HistoContainer.h:57
PatBasicFWLiteJetAnalyzer_Selector_cfg.outputs
outputs
Definition: PatBasicFWLiteJetAnalyzer_Selector_cfg.py:48
trackerDTC::Setup::numOverlappingRegions
int numOverlappingRegions() const
Definition: Setup.h:221
trackerDTC::DTC::produce
void produce(TTDTC &accepted, TTDTC &lost)
Definition: DTC.cc:65
trackerDTC::DTC::split
void split(Stubss &inputs, Stubss &outputs)
Definition: DTC.cc:132
trackerDTC::DTC::enableTruncation_
bool enableTruncation_
Definition: DTC.h:41
trackerDTC::DTC::stubs_
std::vector< Stub > stubs_
Definition: DTC.h:49
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
edm::Ref< TTStubDetSetVec, TTStub< Ref_Phase2TrackerDigi_ > >
trackerDTC::DTC::pop_front
Stub * pop_front(Stubs &stubs)
Definition: DTC.cc:164
TTDTC::Stream
std::vector< Frame > Stream
Definition: TTDTC.h:24
trackerDTC::DTC::modules_
std::vector< SensorModule * > modules_
Definition: DTC.h:47
trackerDTC::DTC::Stubss
std::vector< Stubs > Stubss
Definition: DTC.h:16
trackerDTC::DTC::lost_
Stubss lost_
Definition: DTC.h:53
HcalDetIdTransform::transform
unsigned transform(const HcalDetId &id, unsigned transformCode)
Definition: HcalDetIdTransform.cc:7
HLT_Fake1_cff.streams
streams
Definition: HLT_Fake1_cff.py:13
svgfig.stack
stack
Definition: svgfig.py:559
trackerDTC::Setup::dtcNumRoutingBlocks
int dtcNumRoutingBlocks() const
Definition: Setup.h:227
trackerDTC::DTC::region_
int region_
Definition: DTC.h:43
HLT_FULL_cff.region
region
Definition: HLT_FULL_cff.py:88272
createfilelist.int
int
Definition: createfilelist.py:10
PixelMapPlotter.inputs
inputs
Definition: PixelMapPlotter.py:490
trackerDTC::DTC::input_
Stubsss input_
Definition: DTC.h:51
remoteMonitoring_LED_IterMethod_cfg.limit
limit
Definition: remoteMonitoring_LED_IterMethod_cfg.py:427
trackerDTC::Setup::dtcDepthMemory
int dtcDepthMemory() const
Definition: Setup.h:229
trackerDTC::DTC::Stubs
std::deque< Stub * > Stubs
Definition: DTC.h:15
TTDTC::Frame
std::pair< TTStubRef, BV > Frame
Definition: TTDTC.h:22
or
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
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
trackerDTC::DTC::setup_
const Setup * setup_
Definition: DTC.h:39
TTDTC::setStream
void setStream(int dtcRegion, int dtcBoard, int dtcChannel, const Stream &stream)
Definition: TTDTC.cc:23
trackerDTC::Setup::numFramesIO
int numFramesIO() const
Definition: Setup.h:92
trackerDTC::DTC::board_
int board_
Definition: DTC.h:45
trackerDTC::DTC::merge
void merge(Stubss &inputs, Stubs &output, Stubs &lost)
Definition: DTC.cc:85
GetRecoTauVFromDQM_MC_cff.next
next
Definition: GetRecoTauVFromDQM_MC_cff.py:31