CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTRangeT0.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * \author Paolo Ronchese INFN Padova
5  *
6  */
7 
8 //----------------------
9 // This Class' Header --
10 //----------------------
12 
13 //-------------------------------
14 // Collaborating Class Headers --
15 //-------------------------------
17 
18 //---------------
19 // C++ Headers --
20 //---------------
21 #include <iostream>
22 #include <sstream>
23 
24 //-------------------
25 // Initializations --
26 //-------------------
27 
28 
29 //----------------
30 // Constructors --
31 //----------------
33  dataVersion( " " ),
34  dBuf(new DTBufferTree<int,int>) {
35  dataList.reserve( 1000 );
36 }
37 
38 
40  dataVersion( version ),
41  dBuf(new DTBufferTree<int,int>) {
42  dataList.reserve( 1000 );
43 }
44 
45 
47  wheelId( 0 ),
48  stationId( 0 ),
49  sectorId( 0 ),
50  slId( 0 ) {
51 }
52 
53 
55  t0min( 0 ),
56  t0max( 0 ) {
57 }
58 
59 
60 //--------------
61 // Destructor --
62 //--------------
64 }
65 
66 
68 }
69 
70 
72 }
73 
74 
75 //--------------
76 // Operations --
77 //--------------
78 int DTRangeT0::get( int wheelId,
79  int stationId,
80  int sectorId,
81  int slId,
82  int& t0min,
83  int& t0max ) const {
84 
85  t0min =
86  t0max = 0;
87 
88  std::vector<int> chanKey;
89  chanKey.reserve(4);
90  chanKey.push_back( wheelId );
91  chanKey.push_back( stationId );
92  chanKey.push_back( sectorId );
93  chanKey.push_back( slId );
94  int ientry;
95  int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), ientry );
96  if ( !searchStatus ) {
97  const DTRangeT0Data& data( dataList[ientry].second );
98  t0min = data.t0min;
99  t0max = data.t0max;
100  }
101 
102  return searchStatus;
103 
104 }
105 
106 
108  int& t0min,
109  int& t0max ) const {
110  return get( id.wheel(),
111  id.station(),
112  id.sector(),
113  id.superLayer(),
114  t0min, t0max );
115 }
116 
117 
118 const
120  return dataVersion;
121 }
122 
123 
125  return dataVersion;
126 }
127 
128 
130  dataList.clear();
131  initialize();
132  return;
133 }
134 
135 
136 int DTRangeT0::set( int wheelId,
137  int stationId,
138  int sectorId,
139  int slId,
140  int t0min,
141  int t0max ) {
142 
143  std::vector<int> chanKey;
144  chanKey.reserve(4);
145  chanKey.push_back( wheelId );
146  chanKey.push_back( stationId );
147  chanKey.push_back( sectorId );
148  chanKey.push_back( slId );
149  int ientry;
150  int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), ientry );
151 
152  if ( !searchStatus ) {
153  DTRangeT0Data& data( dataList[ientry].second );
154  data.t0min = t0min;
155  data.t0max = t0max;
156  return -1;
157  }
158  else {
160  key. wheelId = wheelId;
161  key.stationId = stationId;
162  key. sectorId = sectorId;
163  key. slId = slId;
165  data.t0min = t0min;
166  data.t0max = t0max;
167  ientry = dataList.size();
168  dataList.push_back( std::pair<DTRangeT0Id,DTRangeT0Data>( key, data ) );
169  dBuf->insert( chanKey.begin(), chanKey.end(), ientry );
170  return 0;
171  }
172 
173  return 99;
174 
175 }
176 
177 
179  int t0min,
180  int t0max ) {
181  return set( id.wheel(),
182  id.station(),
183  id.sector(),
184  id.superLayer(),
185  t0min, t0max );
186 }
187 
188 
190  return dataList.begin();
191 }
192 
193 
195  return dataList.end();
196 }
197 
198 
200  std::stringstream name;
201  name << dataVersion << "_map_RangeT0" << this;
202  return name.str();
203 }
204 
205 
207 
208  dBuf->clear();
209 
210  int entryNum = 0;
211  int entryMax = dataList.size();
212  std::vector<int> chanKey;
213  chanKey.reserve(4);
214  while ( entryNum < entryMax ) {
215 
216  const DTRangeT0Id& chan = dataList[entryNum].first;
217 
218  chanKey.clear();
219  chanKey.push_back( chan. wheelId );
220  chanKey.push_back( chan.stationId );
221  chanKey.push_back( chan. sectorId );
222  chanKey.push_back( chan. slId );
223  dBuf->insert( chanKey.begin(), chanKey.end(), entryNum++ );
224  }
225  return;
226 }
std::string mapName() const
read and store full content
Definition: DTRangeT0.cc:199
const_iterator end() const
Definition: DTRangeT0.cc:194
std::vector< std::pair< DTRangeT0Id, DTRangeT0Data > >::const_iterator const_iterator
Access methods to data.
Definition: DTRangeT0.h:141
int get(int wheelId, int stationId, int sectorId, int slId, int &t0min, int &t0max) const
Definition: DTRangeT0.cc:78
std::string dataVersion
Definition: DTRangeT0.h:152
const std::string & version() const
access version
Definition: DTRangeT0.cc:119
int find(ElementKey fKey, ElementKey lKey, typename DTBufferTreeTrait< Content >::outputTypeOfConstFind &cont) const
U second(std::pair< T, U > const &p)
void initialize()
Definition: DTRangeT0.cc:206
std::vector< std::pair< DTRangeT0Id, DTRangeT0Data > > dataList
Definition: DTRangeT0.h:154
~DTRangeT0()
Definition: DTRangeT0.cc:63
void clear()
reset content
Definition: DTRangeT0.cc:129
const_iterator begin() const
Definition: DTRangeT0.cc:189
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
int insert(ElementKey fKey, ElementKey lKey, Content cont)
list key
Definition: combine.py:13
int set(int wheelId, int stationId, int sectorId, int slId, int t0min, int t0max)
Definition: DTRangeT0.cc:136
int stationId
Definition: DTRangeT0.h:47
DTBufferTree< int, int > * dBuf
Definition: DTRangeT0.h:156