Skip to content

Commit

Permalink
Some dtcId conversion functions added to TTDTC.
Browse files Browse the repository at this point in the history
  • Loading branch information
tschuh committed Apr 29, 2020
1 parent 73fea7d commit c7442df
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 50 deletions.
83 changes: 52 additions & 31 deletions DataFormats/L1TrackTrigger/interface/TTDTC.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,59 +16,80 @@
*/
class TTDTC {
public:
// outer tracker DTC types
typedef std::bitset<TTBV::S> BV; // bit accurate Stub
typedef std::pair<TTStubRef, BV> Frame; // TTStub with bit accurate Stub
typedef std::vector<Frame> Stream; // stub collection transported over an optical link between DTC and TFP
typedef std::vector<Stream> Streams; // collection of optical links
// bit accurate Stub
typedef std::bitset<TTBV::S> BV;
// TTStub with bit accurate Stub
typedef std::pair<TTStubRef, BV> Frame;
// stub collection transported over an optical link between DTC and TFP
typedef std::vector<Frame> Stream;
// collection of optical links
typedef std::vector<Stream> Streams;

private:
// number of ATCA slots per shelf
static constexpr int numSlots_ = 12;

public:
TTDTC() {}

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

~TTDTC() {}

// Access to product configurations
int numRegions() const;
int numDTCBoards() const;
int numDTCChannel() const;
int numTFPChannel() const;

// number of phi slices the outer tracker readout is organized in [default 9]
int numRegions() const { return numRegions_; }
// number of DTC boards used to readout a detector region [default 24]
int numDTCBoards() const { return numDTCsPerRegion_; }
// number of regions a reconstructable particle may cross [default 2]
int numDTCChannel() const { return numOverlappingRegions_; }
// number of DTC boards connected to one TFP [default 48]
int numTFPChannel() const { return numDTCsPerTFP_; }
// all regions [default 0..8]
const std::vector<int>& tfpRegions() const { return regions_; }
// all TFP channel [default 0..47]
const std::vector<int>& tfpChannels() const { return channels_; }
// write one specific stream of TTStubRefs using DTC identifier (region[0-8], board[0-23], channel[0-1])
// dtcRegions aka detector regions are defined by tk layout
void setStream(int dtcRegion, int dtcBoard, int dtcChannel, const Stream& stream);

// all TFP identifier (region[0-8], channel[0-47])
std::vector<int> tfpRegions() const;
std::vector<int> tfpChannels() const;

// read one specific stream of TTStubRefs using TFP identifier (region[0-8], channel[0-47])
// tfpRegions aka processing regions are rotated by -0.5 region width w.r.t detector regions
const Stream& stream(int tfpRegion, int tfpChannel) const;

// total number of frames
int size() const;
// total number of stubs
int nStubs() const;
// total number of gaps
int nGaps() const;
// converts dtc id into tk layout scheme
int tkLayoutId(int dtcId) const;

// converts tk layout id into dtc id
int dtcId(int tkLayoutId) const;
// converts TFP identifier (region[0-8], channel[0-47]) into dtcId [0-215]
int dtcId(int tfpRegion, int tfpChannel) const;
// checks if given dtcId is connected to PS or 2S sensormodules
bool psModlue(int dtcId) const;
// checks if given dtcId is connected to -z (false) or +z (true)
bool side(int dtcId) const;
// ATCA slot number [0-11] of given dtcId
int slot(int dtcId) const;

private:
// converts DTC identifier (region[0-8], board[0-23], channel[0-1]) into allStreams_ index [0-431]
int index(int dtcRegion, int dtcBoard, int dtcChannel) const;

// converts TFP identifier (region[0-8], channel[0-47]) into allStreams_ index [0-431]
int index(int tfpRegion, int tfpChannel) const;

private:
static constexpr int numSlots_ = 12; // number of ATCA slots per shelf

int numRegions_; // number of phi slices the outer tracker readout is organized in [default 9]
int numOverlappingRegions_; // number of regions a reconstructable particle may cross [default 2]
int numDTCsPerRegion_; // number of DTC boards used to readout a detector region [default 24]
int numDTCsPerTFP_; // number of DTC boards connected to one TFP [default 48]

Streams streams_; // collection of all optical links between DTC and TFP [default 432 links]
// number of phi slices the outer tracker readout is organized in [default 9]
int numRegions_;
// number of regions a reconstructable particle may cross [default 2]
int numOverlappingRegions_;
// number of DTC boards used to readout a detector region [default 24]
int numDTCsPerRegion_;
// number of DTC boards connected to one TFP [default 48]
int numDTCsPerTFP_;
// all regions [default 0..8]
std::vector<int> regions_;
// all TFP channel [default 0..47]
std::vector<int> channels_;
// collection of all optical links between DTC and TFP [default 432 links]
Streams streams_;
};

#endif
67 changes: 48 additions & 19 deletions DataFormats/L1TrackTrigger/src/TTDTC.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ TTDTC::TTDTC(int numRegions, int numOverlappingRegions, int numDTCsPerRegion)
numOverlappingRegions_(numOverlappingRegions),
numDTCsPerRegion_(numDTCsPerRegion),
numDTCsPerTFP_(numOverlappingRegions * numDTCsPerRegion),
streams_(numRegions_ * numDTCsPerRegion_ * numOverlappingRegions_) {}

// Access to product configurations
int TTDTC::numRegions() const { return numRegions_; }
int TTDTC::numDTCBoards() const { return numDTCsPerRegion_; }
int TTDTC::numDTCChannel() const { return numOverlappingRegions_; }
int TTDTC::numTFPChannel() const { return numDTCsPerTFP_; }
regions_(numRegions_),
channels_(numDTCsPerRegion_ * numOverlappingRegions_),
streams_(numRegions_ * channels_.size()) {
iota(regions_.begin(), regions_.end(), 0);
iota(channels_.begin(), channels_.end(), 0);
}

// write one specific stream of TTStubRefs using DTC identifier (region[0-8], board[0-23], channel[0-1])
// dtcRegions aka detector regions are defined by tk layout
Expand All @@ -43,18 +42,6 @@ void TTDTC::setStream(int dtcRegion, int dtcBoard, int dtcChannel, const Stream&
streams_[index(dtcRegion, dtcBoard, dtcChannel)] = move(stream);
}

// all TFP identifier (region[0-8], channel[0-47])
vector<int> TTDTC::tfpRegions() const {
vector<int> vec(numRegions_);
iota(vec.begin(), vec.end(), 0);
return vec;
}
vector<int> TTDTC::tfpChannels() const {
vector<int> vec(numDTCsPerTFP_);
iota(vec.begin(), vec.end(), 0);
return vec;
}

// read one specific stream of TTStubRefs using TFP identifier (region[0-8], channel[0-47])
// tfpRegions aka processing regions are rotated by -0.5 region width w.r.t detector regions
const TTDTC::Stream& TTDTC::stream(int tfpRegion, int tfpChannel) const {
Expand All @@ -75,6 +62,30 @@ const TTDTC::Stream& TTDTC::stream(int tfpRegion, int tfpChannel) const {
return streams_.at(index(tfpRegion, tfpChannel));
}

// total number of frames
int TTDTC::size() const {
auto all = [](int& sum, const Stream& stream) { return sum += stream.size(); };
return accumulate(streams_.begin(), streams_.end(), 0, all);
}

// total number of stubs
int TTDTC::nStubs() const {
auto stubs = [](int& sum, const Frame& frame) { return sum += frame.first.isNonnull(); };
int n(0);
for (const Stream& stream : streams_)
n += accumulate(stream.begin(), stream.end(), 0, stubs);
return n;
}

// total number of gaps
int TTDTC::nGaps() const {
auto gaps = [](int& sum, const Frame& frame) { return sum += frame.first.isNull(); };
int n(0);
for (const Stream& stream : streams_)
n += accumulate(stream.begin(), stream.end(), 0, gaps);
return n;
}

// converts dtc id into tk layout scheme
int TTDTC::tkLayoutId(int dtcId) const {
// check argument
Expand Down Expand Up @@ -107,6 +118,24 @@ int TTDTC::dtcId(int tkLayoutId) const {
return region * numDTCsPerRegion_ + side * numSlots_ + slot;
}

// converts TFP identifier (region[0-8], channel[0-47]) into dtc id
int TTDTC::dtcId(int tfpRegion, int tfpChannel) const { return index(tfpRegion, tfpChannel) / numOverlappingRegions_; }

// checks if given DTC id is connected to PS or 2S sensormodules
bool TTDTC::psModlue(int dtcId) const {
// from tklayout: first 3 are 10 gbps PS, next 3 are 5 gbps PS and residual 6 are 5 gbps 2S modules
return slot(dtcId) < numSlots_ / 2;
}

// checks if given dtcId is connected to -z (false) or +z (true)
bool TTDTC::side(int dtcId) const {
const int side = (dtcId % numDTCsPerRegion_) / numSlots_;
// from tkLayout: first 12 +z, next 12 -z
return side == 0;
}
// ATCA slot number [0-11] of given dtcId
int TTDTC::slot(int dtcId) const { return dtcId % numSlots_; }

// converts DTC identifier (region[0-8], board[0-23], channel[0-1]) into streams_ index [0-431]
int TTDTC::index(int dtcRegion, int dtcBoard, int dtcChannel) const {
return (dtcRegion * numDTCsPerRegion_ + dtcBoard) * numOverlappingRegions_ + dtcChannel;
Expand Down

0 comments on commit c7442df

Please sign in to comment.