CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
L1MuDTDataBuffer.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // Class: L1MuDTDataBuffer
4 //
5 // Description: Data Buffer
6 //
7 //
8 //
9 // Author :
10 // N. Neumeister CERN EP
11 //
12 //--------------------------------------------------
13 
14 //-----------------------
15 // This Class's Header --
16 //-----------------------
17 
19 
20 //---------------
21 // C++ Headers --
22 //---------------
23 
24 #include <iostream>
25 #include <vector>
26 #include <cmath>
27 
28 //-------------------------------
29 // Collaborating Class Headers --
30 //-------------------------------
31 
36 
37 using namespace std;
38 
39 // --------------------------------
40 // class L1MuDTDataBuffer
41 //---------------------------------
42 
43 //----------------
44 // Constructors --
45 //----------------
46 L1MuDTDataBuffer::L1MuDTDataBuffer(const L1MuDTSectorProcessor& sp) : m_sp(sp), m_tsphi(nullptr) {
47  m_tsphi = new TSPhivector(38);
48  m_tsphi->reserve(38);
49 }
50 
51 //--------------
52 // Destructor --
53 //--------------
55 
56 //--------------
57 // Operations --
58 //--------------
59 
60 //
61 // clear buffer
62 //
64  TSPhivector::iterator iter = m_tsphi->begin();
65  while (iter != m_tsphi->end()) {
66  if (*iter) {
67  delete *iter;
68  *iter = nullptr;
69  }
70  iter++;
71  }
72 }
73 
74 //
75 // get phi track segment of a given station
76 //
77 const L1MuDTTrackSegPhi* L1MuDTDataBuffer::getTSphi(int station, int reladr) const {
78  int address = (station == 1) ? reladr : reladr + (station - 2) * 12 + 2;
79  return (*m_tsphi)[address];
80 }
81 
82 //
83 // add new phi track segment to the buffer
84 //
86  L1MuDTTrackSegPhi* tmpts = new L1MuDTTrackSegPhi(ts);
87  (*m_tsphi)[adr] = tmpts;
88 }
89 
90 //
91 // print all phi track segments in the buffer
92 //
94  TSPhivector::const_iterator iter = m_tsphi->begin();
95  while (iter != m_tsphi->end()) {
96  if (*iter)
97  cout << *(*iter) << endl;
98  iter++;
99  }
100 }
101 
102 //
103 // count number of non empty phi track segments
104 //
106  int count = 0;
107  TSPhivector::iterator iter = m_tsphi->begin();
108  while (iter != m_tsphi->end()) {
109  if (*iter && !(*iter)->empty())
110  count++;
111  iter++;
112  }
113  return count;
114 }
void printTSphi() const
print all phi track segments which are in the buffer
L1MuDTDataBuffer(const L1MuDTSectorProcessor &)
constructor
virtual ~L1MuDTDataBuffer()
destructor
void reset()
clear Data Buffer
const TSPhivector & getTSphi() const
get all track segments from the buffer
TSPhivector * m_tsphi
int numberTSphi() const
return number of non-empty phi track segments
void addTSphi(int adr, const L1MuDTTrackSegPhi &)
add new phi track segment to the Data Buffer
std::vector< L1MuDTTrackSegPhi * > TSPhivector
container to store phi track segments
tuple cout
Definition: gather_cfg.py:144