Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-02 03:45:47

0001 //-------------------------------------------------
0002 //
0003 //   Class: L1MuDTDataBuffer
0004 //
0005 //   Description: Data Buffer
0006 //
0007 //
0008 //
0009 //   Author :
0010 //   N. Neumeister            CERN EP
0011 //
0012 //--------------------------------------------------
0013 
0014 //-----------------------
0015 // This Class's Header --
0016 //-----------------------
0017 
0018 #include "L1Trigger/DTTrackFinder/src/L1MuDTDataBuffer.h"
0019 
0020 //---------------
0021 // C++ Headers --
0022 //---------------
0023 
0024 #include <iostream>
0025 #include <vector>
0026 #include <cmath>
0027 
0028 //-------------------------------
0029 // Collaborating Class Headers --
0030 //-------------------------------
0031 
0032 #include "L1Trigger/DTTrackFinder/interface/L1MuDTTFConfig.h"
0033 #include "L1Trigger/DTTrackFinder/src/L1MuDTSectorProcessor.h"
0034 #include "L1Trigger/DTTrackFinder/interface/L1MuDTTrackSegLoc.h"
0035 #include "L1Trigger/DTTrackFinder/interface/L1MuDTTrackSegPhi.h"
0036 
0037 using namespace std;
0038 
0039 // --------------------------------
0040 //       class L1MuDTDataBuffer
0041 //---------------------------------
0042 
0043 //----------------
0044 // Constructors --
0045 //----------------
0046 L1MuDTDataBuffer::L1MuDTDataBuffer(const L1MuDTSectorProcessor& sp) : m_sp(sp), m_tsphi(nullptr) {
0047   m_tsphi = new TSPhivector(38);
0048   m_tsphi->reserve(38);
0049 }
0050 
0051 //--------------
0052 // Destructor --
0053 //--------------
0054 L1MuDTDataBuffer::~L1MuDTDataBuffer() { delete m_tsphi; }
0055 
0056 //--------------
0057 // Operations --
0058 //--------------
0059 
0060 //
0061 // clear buffer
0062 //
0063 void L1MuDTDataBuffer::reset() {
0064   TSPhivector::iterator iter = m_tsphi->begin();
0065   while (iter != m_tsphi->end()) {
0066     if (*iter) {
0067       delete *iter;
0068       *iter = nullptr;
0069     }
0070     iter++;
0071   }
0072 }
0073 
0074 //
0075 // get phi track segment of a given station
0076 //
0077 const L1MuDTTrackSegPhi* L1MuDTDataBuffer::getTSphi(int station, int reladr) const {
0078   int address = (station == 1) ? reladr : reladr + (station - 2) * 12 + 2;
0079   return (*m_tsphi)[address];
0080 }
0081 
0082 //
0083 // add new phi track segment to the buffer
0084 //
0085 void L1MuDTDataBuffer::addTSphi(int adr, const L1MuDTTrackSegPhi& ts) {
0086   L1MuDTTrackSegPhi* tmpts = new L1MuDTTrackSegPhi(ts);
0087   (*m_tsphi)[adr] = tmpts;
0088 }
0089 
0090 //
0091 // print all phi track segments in the buffer
0092 //
0093 void L1MuDTDataBuffer::printTSphi() const {
0094   TSPhivector::const_iterator iter = m_tsphi->begin();
0095   while (iter != m_tsphi->end()) {
0096     if (*iter)
0097       cout << *(*iter) << endl;
0098     iter++;
0099   }
0100 }
0101 
0102 //
0103 // count number of non empty phi track segments
0104 //
0105 int L1MuDTDataBuffer::numberTSphi() const {
0106   int count = 0;
0107   TSPhivector::iterator iter = m_tsphi->begin();
0108   while (iter != m_tsphi->end()) {
0109     if (*iter && !(*iter)->empty())
0110       count++;
0111     iter++;
0112   }
0113   return count;
0114 }