CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
TTDTC Class Reference

Class to store hardware like structured TTStub Collection used by Track Trigger emulators. More...

#include <TTDTC.h>

Public Member Functions

int nGaps () const
 
int nStubs () const
 
void setStream (int dtcRegion, int dtcBoard, int dtcChannel, const tt::StreamStub &stream)
 
int size () const
 
const tt::StreamStubstream (int tfpRegion, int tfpChannel) const
 
const std::vector< int > & tfpChannels () const
 
const std::vector< int > & tfpRegions () const
 
 TTDTC ()
 
 TTDTC (int numRegions, int numOverlappingRegions, int numDTCsPerRegion)
 
 ~TTDTC ()
 

Private Member Functions

int index (int dtcRegion, int dtcBoard, int dtcChannel) const
 
int index (int tfpRegion, int tfpChannel) const
 

Private Attributes

std::vector< int > channels_
 
int numDTCsPerRegion_
 
int numDTCsPerTFP_
 
int numOverlappingRegions_
 
int numRegions_
 
std::vector< int > regions_
 
tt::StreamsStub streams_
 

Detailed Description

Class to store hardware like structured TTStub Collection used by Track Trigger emulators.

Author
Thomas Schuh
Date
2020, Jan

Definition at line 17 of file TTDTC.h.

Constructor & Destructor Documentation

◆ TTDTC() [1/2]

TTDTC::TTDTC ( )
inline

Definition at line 19 of file TTDTC.h.

19 {}

◆ TTDTC() [2/2]

TTDTC::TTDTC ( int  numRegions,
int  numOverlappingRegions,
int  numDTCsPerRegion 
)

Definition at line 10 of file TTDTC.cc.

References channels_, and regions_.

11  : numRegions_(numRegions),
12  numOverlappingRegions_(numOverlappingRegions),
13  numDTCsPerRegion_(numDTCsPerRegion),
14  numDTCsPerTFP_(numOverlappingRegions * numDTCsPerRegion),
18  iota(regions_.begin(), regions_.end(), 0);
19  iota(channels_.begin(), channels_.end(), 0);
20 }
std::vector< int > regions_
Definition: TTDTC.h:54
std::vector< int > channels_
Definition: TTDTC.h:56
int numOverlappingRegions_
Definition: TTDTC.h:48
int numDTCsPerRegion_
Definition: TTDTC.h:50
int numRegions_
Definition: TTDTC.h:46
tt::StreamsStub streams_
Definition: TTDTC.h:58
int numDTCsPerTFP_
Definition: TTDTC.h:52

◆ ~TTDTC()

TTDTC::~TTDTC ( )
inline

Definition at line 21 of file TTDTC.h.

21 {}

Member Function Documentation

◆ index() [1/2]

int TTDTC::index ( int  dtcRegion,
int  dtcBoard,
int  dtcChannel 
) const
private

Definition at line 91 of file TTDTC.cc.

References numDTCsPerRegion_, and numOverlappingRegions_.

Referenced by index(), BeautifulSoup.PageElement::insert(), setStream(), and stream().

91  {
92  return (dtcRegion * numDTCsPerRegion_ + dtcBoard) * numOverlappingRegions_ + dtcChannel;
93 }
int numOverlappingRegions_
Definition: TTDTC.h:48
int numDTCsPerRegion_
Definition: TTDTC.h:50

◆ index() [2/2]

int TTDTC::index ( int  tfpRegion,
int  tfpChannel 
) const
private

Definition at line 96 of file TTDTC.cc.

References index(), numDTCsPerRegion_, numOverlappingRegions_, and numRegions_.

Referenced by BeautifulSoup.PageElement::insert().

96  {
97  const int dtcChannel = numOverlappingRegions_ - (tfpChannel / numDTCsPerRegion_) - 1;
98  const int dtcBoard = tfpChannel % numDTCsPerRegion_;
99  const int dtcRegion = tfpRegion - dtcChannel >= 0 ? tfpRegion - dtcChannel : tfpRegion - dtcChannel + numRegions_;
100  return index(dtcRegion, dtcBoard, dtcChannel);
101 }
int numOverlappingRegions_
Definition: TTDTC.h:48
int numDTCsPerRegion_
Definition: TTDTC.h:50
int numRegions_
Definition: TTDTC.h:46
int index(int dtcRegion, int dtcBoard, int dtcChannel) const
Definition: TTDTC.cc:91

◆ nGaps()

int TTDTC::nGaps ( ) const

Definition at line 82 of file TTDTC.cc.

References amptDefault_cfi::frame, dqmiodumpmetadata::n, stream(), and streams_.

82  {
83  auto gaps = [](int& sum, const FrameStub& frame) { return sum += frame.first.isNull(); };
84  int n(0);
85  for (const StreamStub& stream : streams_)
86  n += accumulate(stream.begin(), stream.end(), 0, gaps);
87  return n;
88 }
std::pair< TTStubRef, Frame > FrameStub
Definition: TTTypes.h:60
std::vector< FrameStub > StreamStub
Definition: TTTypes.h:63
tt::StreamsStub streams_
Definition: TTDTC.h:58
const tt::StreamStub & stream(int tfpRegion, int tfpChannel) const
Definition: TTDTC.cc:48

◆ nStubs()

int TTDTC::nStubs ( ) const

Definition at line 73 of file TTDTC.cc.

References amptDefault_cfi::frame, dqmiodumpmetadata::n, stream(), and streams_.

73  {
74  auto stubs = [](int& sum, const FrameStub& frame) { return sum += frame.first.isNonnull(); };
75  int n(0);
76  for (const StreamStub& stream : streams_)
77  n += accumulate(stream.begin(), stream.end(), 0, stubs);
78  return n;
79 }
std::pair< TTStubRef, Frame > FrameStub
Definition: TTTypes.h:60
std::vector< FrameStub > StreamStub
Definition: TTTypes.h:63
tt::StreamsStub streams_
Definition: TTDTC.h:58
const tt::StreamStub & stream(int tfpRegion, int tfpChannel) const
Definition: TTDTC.cc:48

◆ setStream()

void TTDTC::setStream ( int  dtcRegion,
int  dtcBoard,
int  dtcChannel,
const tt::StreamStub stream 
)

Definition at line 24 of file TTDTC.cc.

References cppFunctionSkipper::exception, index(), numDTCsPerRegion_, numOverlappingRegions_, numRegions_, stream(), and streams_.

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

24  {
25  // check arguments
26  const bool oorRegion = dtcRegion >= numRegions_ || dtcRegion < 0;
27  const bool oorBoard = dtcBoard >= numDTCsPerRegion_ || dtcBoard < 0;
28  const bool oorChannel = dtcChannel >= numOverlappingRegions_ || dtcChannel < 0;
29  if (oorRegion || oorBoard || oorChannel) {
30  cms::Exception exception("out_of_range");
31  exception.addContext("TTDTC::setStream");
32  if (oorRegion)
33  exception << "Requested Detector Region "
34  << "(" << dtcRegion << ") is out of range 0 to " << numRegions_ - 1 << ".";
35  if (oorBoard)
36  exception << "Requested DTC Board "
37  << "(" << dtcBoard << ") is out of range 0 to " << numDTCsPerRegion_ - 1 << ".";
38  if (oorChannel)
39  exception << "Requested DTC Channel "
40  << "(" << dtcChannel << ") is out of range 0 to " << numOverlappingRegions_ - 1 << ".";
41  throw exception;
42  }
43  streams_[index(dtcRegion, dtcBoard, dtcChannel)] = stream;
44 }
int numOverlappingRegions_
Definition: TTDTC.h:48
int numDTCsPerRegion_
Definition: TTDTC.h:50
int numRegions_
Definition: TTDTC.h:46
tt::StreamsStub streams_
Definition: TTDTC.h:58
int index(int dtcRegion, int dtcBoard, int dtcChannel) const
Definition: TTDTC.cc:91
const tt::StreamStub & stream(int tfpRegion, int tfpChannel) const
Definition: TTDTC.cc:48

◆ size()

int TTDTC::size ( void  ) const

Definition at line 67 of file TTDTC.cc.

References python.cmstools::all(), stream(), and streams_.

Referenced by ntupleDataFormat._Collection::__iter__(), and ntupleDataFormat._Collection::__len__().

67  {
68  auto all = [](int& sum, const StreamStub& stream) { return sum += stream.size(); };
69  return accumulate(streams_.begin(), streams_.end(), 0, all);
70 }
def all(container)
workaround iterator generators for ROOT classes
Definition: cmstools.py:25
std::vector< FrameStub > StreamStub
Definition: TTTypes.h:63
tt::StreamsStub streams_
Definition: TTDTC.h:58
const tt::StreamStub & stream(int tfpRegion, int tfpChannel) const
Definition: TTDTC.cc:48

◆ stream()

const StreamStub & TTDTC::stream ( int  tfpRegion,
int  tfpChannel 
) const

Definition at line 48 of file TTDTC.cc.

References cppFunctionSkipper::exception, index(), numDTCsPerTFP_, numRegions_, and streams_.

Referenced by trackerTFP::GeometricProcessor::consume(), nGaps(), nStubs(), L1FPGATrackProducer::produce(), setStream(), and size().

48  {
49  // check arguments
50  const bool oorRegion = tfpRegion >= numRegions_ || tfpRegion < 0;
51  const bool oorChannel = tfpChannel >= numDTCsPerTFP_ || tfpChannel < 0;
52  if (oorRegion || oorChannel) {
53  cms::Exception exception("out_of_range");
54  exception.addContext("TTDTC::stream");
55  if (oorRegion)
56  exception << "Requested Processing Region "
57  << "(" << tfpRegion << ") is out of range 0 to " << numRegions_ - 1 << ".";
58  if (oorChannel)
59  exception << "Requested TFP Channel "
60  << "(" << tfpChannel << ") is out of range 0 to " << numDTCsPerTFP_ - 1 << ".";
61  throw exception;
62  }
63  return streams_.at(index(tfpRegion, tfpChannel));
64 }
int numRegions_
Definition: TTDTC.h:46
tt::StreamsStub streams_
Definition: TTDTC.h:58
int index(int dtcRegion, int dtcBoard, int dtcChannel) const
Definition: TTDTC.cc:91
int numDTCsPerTFP_
Definition: TTDTC.h:52

◆ tfpChannels()

const std::vector<int>& TTDTC::tfpChannels ( ) const
inline

Definition at line 26 of file TTDTC.h.

References channels_.

Referenced by L1FPGATrackProducer::produce().

26 { return channels_; }
std::vector< int > channels_
Definition: TTDTC.h:56

◆ tfpRegions()

const std::vector<int>& TTDTC::tfpRegions ( ) const
inline

Definition at line 24 of file TTDTC.h.

References regions_.

Referenced by L1FPGATrackProducer::produce().

24 { return regions_; }
std::vector< int > regions_
Definition: TTDTC.h:54

Member Data Documentation

◆ channels_

std::vector<int> TTDTC::channels_
private

Definition at line 56 of file TTDTC.h.

Referenced by tfpChannels(), and TTDTC().

◆ numDTCsPerRegion_

int TTDTC::numDTCsPerRegion_
private

Definition at line 50 of file TTDTC.h.

Referenced by index(), and setStream().

◆ numDTCsPerTFP_

int TTDTC::numDTCsPerTFP_
private

Definition at line 52 of file TTDTC.h.

Referenced by stream().

◆ numOverlappingRegions_

int TTDTC::numOverlappingRegions_
private

Definition at line 48 of file TTDTC.h.

Referenced by index(), and setStream().

◆ numRegions_

int TTDTC::numRegions_
private

Definition at line 46 of file TTDTC.h.

Referenced by index(), setStream(), and stream().

◆ regions_

std::vector<int> TTDTC::regions_
private

Definition at line 54 of file TTDTC.h.

Referenced by tfpRegions(), and TTDTC().

◆ streams_

tt::StreamsStub TTDTC::streams_
private

Definition at line 58 of file TTDTC.h.

Referenced by nGaps(), nStubs(), setStream(), size(), and stream().