CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTLVStatus.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 //-------------------------------
18 
19 //---------------
20 // C++ Headers --
21 //---------------
22 #include <iostream>
23 #include <sstream>
24 
25 //-------------------
26 // Initializations --
27 //-------------------
28 
29 
30 //----------------
31 // Constructors --
32 //----------------
34  dataVersion( " " ),
35  dBuf(new DTBufferTree<int,int>) {
36  dataList.reserve( 10 );
37 }
38 
39 
41  dataVersion( version ),
42  dBuf(new DTBufferTree<int,int>) {
43  dataList.reserve( 10 );
44 }
45 
46 
48  wheelId( 0 ),
49  stationId( 0 ),
50  sectorId( 0 ) {
51 }
52 
53 
55  flagCFE( 0 ),
56  flagDFE( 0 ),
57  flagCMC( 0 ),
58  flagDMC( 0 ) {
59 }
60 
61 
62 //--------------
63 // Destructor --
64 //--------------
66 }
67 
68 
70 }
71 
72 
74 }
75 
76 
77 //--------------
78 // Operations --
79 //--------------
80 int DTLVStatus::get( int wheelId,
81  int stationId,
82  int sectorId,
83  int& flagCFE,
84  int& flagDFE,
85  int& flagCMC,
86  int& flagDMC ) const {
87  flagCFE = 0;
88  flagDFE = 0;
89  flagCMC = 0;
90  flagDMC = 0;
91 
92  std::vector<int> chanKey;
93  chanKey.reserve(3);
94  chanKey.push_back( wheelId );
95  chanKey.push_back( stationId );
96  chanKey.push_back( sectorId );
97  int ientry;
98  int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), ientry );
99  if ( !searchStatus ) {
100  const DTLVStatusData& data( dataList[ientry].second );
101  flagCFE = data.flagCFE;
102  flagDFE = data.flagDFE;
103  flagCMC = data.flagCMC;
104  flagDMC = data.flagDMC;
105  }
106 
107  return searchStatus;
108 
109 }
110 
111 
113  int& flagCFE,
114  int& flagDFE,
115  int& flagCMC,
116  int& flagDMC ) const {
117  return get( id.wheel(),
118  id.station(),
119  id.sector(),
120  flagCFE,
121  flagDFE,
122  flagCMC,
123  flagDMC );
124 }
125 
126 
127 const
129  return dataVersion;
130 }
131 
132 
134  return dataVersion;
135 }
136 
137 
139  dataList.clear();
140  initialize();
141  return;
142 }
143 
144 
145 int DTLVStatus::set( int wheelId,
146  int stationId,
147  int sectorId,
148  int flagCFE,
149  int flagDFE,
150  int flagCMC,
151  int flagDMC ) {
152 
153  std::vector<int> chanKey;
154  chanKey.reserve(3);
155  chanKey.push_back( wheelId );
156  chanKey.push_back( stationId );
157  chanKey.push_back( sectorId );
158  int ientry;
159  int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), ientry );
160 
161  if ( !searchStatus ) {
162  DTLVStatusData& data( dataList[ientry].second );
163  data.flagCFE = flagCFE;
164  data.flagDFE = flagDFE;
165  data.flagCMC = flagCMC;
166  data.flagDMC = flagDMC;
167  return -1;
168  }
169  else {
171  key. wheelId = wheelId;
172  key.stationId = stationId;
173  key. sectorId = sectorId;
175  data.flagCFE = flagCFE;
176  data.flagDFE = flagDFE;
177  data.flagCMC = flagCMC;
178  data.flagDMC = flagDMC;
179  ientry = dataList.size();
180  dataList.push_back( std::pair<DTLVStatusId,
181  DTLVStatusData>( key, data ) );
182  dBuf->insert( chanKey.begin(), chanKey.end(), ientry );
183  return 0;
184  }
185 
186  return 99;
187 
188 }
189 
190 
192  int flagCFE,
193  int flagDFE,
194  int flagCMC,
195  int flagDMC ) {
196  return set( id.wheel(),
197  id.station(),
198  id.sector(),
199  flagCFE,
200  flagDFE,
201  flagCMC,
202  flagDMC );
203 }
204 
205 
206 int DTLVStatus::setFlagCFE( int wheelId,
207  int stationId,
208  int sectorId,
209  int flag ) {
210  int flagCFE;
211  int flagDFE;
212  int flagCMC;
213  int flagDMC;
214  get( wheelId,
215  stationId,
216  sectorId,
217  flagCFE,
218  flagDFE,
219  flagCMC,
220  flagDMC );
221  return set( wheelId,
222  stationId,
223  sectorId,
224  flag,
225  flagDFE,
226  flagCMC,
227  flagDMC );
228 }
229 
230 
232  int flag ) {
233  return setFlagCFE( id.wheel(),
234  id.station(),
235  id.sector(),
236  flag );
237 }
238 
239 
240 int DTLVStatus::setFlagDFE( int wheelId,
241  int stationId,
242  int sectorId,
243  int flag ) {
244  int flagCFE;
245  int flagDFE;
246  int flagCMC;
247  int flagDMC;
248  get( wheelId,
249  stationId,
250  sectorId,
251  flagCFE,
252  flagDFE,
253  flagCMC,
254  flagDMC );
255  return set( wheelId,
256  stationId,
257  sectorId,
258  flagCFE,
259  flag,
260  flagCMC,
261  flagDMC );
262 }
263 
264 
266  int flag ) {
267  return setFlagDFE( id.wheel(),
268  id.station(),
269  id.sector(),
270  flag );
271 }
272 
273 
274 int DTLVStatus::setFlagCMC( int wheelId,
275  int stationId,
276  int sectorId,
277  int flag ) {
278  int flagCFE;
279  int flagDFE;
280  int flagCMC;
281  int flagDMC;
282  get( wheelId,
283  stationId,
284  sectorId,
285  flagCFE,
286  flagDFE,
287  flagCMC,
288  flagDMC );
289  return set( wheelId,
290  stationId,
291  sectorId,
292  flagCFE,
293  flagDFE,
294  flag,
295  flagDMC );
296 }
297 
298 
300  int flag ) {
301  return setFlagCMC( id.wheel(),
302  id.station(),
303  id.sector(),
304  flag );
305 }
306 
307 
308 int DTLVStatus::setFlagDMC( int wheelId,
309  int stationId,
310  int sectorId,
311  int flag ) {
312  int flagCFE;
313  int flagDFE;
314  int flagCMC;
315  int flagDMC;
316  get( wheelId,
317  stationId,
318  sectorId,
319  flagCFE,
320  flagDFE,
321  flagCMC,
322  flagDMC );
323  return set( wheelId,
324  stationId,
325  sectorId,
326  flagCFE,
327  flagDFE,
328  flagCMC,
329  flag );
330 }
331 
332 
334  int flag ) {
335  return setFlagDMC( id.wheel(),
336  id.station(),
337  id.sector(),
338  flag );
339 }
340 
341 
343  return dataList.begin();
344 }
345 
346 
348  return dataList.end();
349 }
350 
351 
353  std::stringstream name;
354  name << dataVersion << "_map_Mtime" << this;
355  return name.str();
356 }
357 
358 
360 
361  dBuf->clear();
362 
363  int entryNum = 0;
364  int entryMax = dataList.size();
365  std::vector<int> chanKey;
366  chanKey.reserve(3);
367  while ( entryNum < entryMax ) {
368 
369  const DTLVStatusId& chan = dataList[entryNum].first;
370 
371  chanKey.clear();
372  chanKey.push_back( chan. wheelId );
373  chanKey.push_back( chan.stationId );
374  chanKey.push_back( chan. sectorId );
375  dBuf->insert( chanKey.begin(), chanKey.end(), entryNum++ );
376 
377  }
378 
379  return;
380 
381 }
382 
int get(int wheelId, int stationId, int sectorId, int &flagCFE, int &flagDFE, int &flagCMC, int &flagDMC) const
get content
Definition: DTLVStatus.cc:80
int set(int wheelId, int stationId, int sectorId, int flagCFE, int flagDFE, int flagCMC, int flagDMC)
Definition: DTLVStatus.cc:145
const std::string & version() const
access version
Definition: DTLVStatus.cc:128
std::string dataVersion
Definition: DTLVStatus.h:158
void clear()
reset content
Definition: DTLVStatus.cc:138
void initialize()
Definition: DTLVStatus.cc:359
int setFlagDMC(int wheelId, int stationId, int sectorId, int flag)
Definition: DTLVStatus.cc:308
const_iterator end() const
Definition: DTLVStatus.cc:347
std::vector< std::pair< DTLVStatusId, DTLVStatusData > > dataList
Definition: DTLVStatus.h:160
std::string mapName() const
read and store full content
Definition: DTLVStatus.cc:352
int find(ElementKey fKey, ElementKey lKey, typename DTBufferTreeTrait< Content >::outputTypeOfConstFind &cont) const
U second(std::pair< T, U > const &p)
std::vector< std::pair< DTLVStatusId, DTLVStatusData > >::const_iterator const_iterator
Access methods to data.
Definition: DTLVStatus.h:147
edm::ConstRespectingPtr< DTBufferTree< int, int > > dBuf
Definition: DTLVStatus.h:162
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
int setFlagCFE(int wheelId, int stationId, int sectorId, int flag)
Definition: DTLVStatus.cc:206
const_iterator begin() const
Definition: DTLVStatus.cc:342
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
int insert(ElementKey fKey, ElementKey lKey, Content cont)
int setFlagDFE(int wheelId, int stationId, int sectorId, int flag)
Definition: DTLVStatus.cc:240
int setFlagCMC(int wheelId, int stationId, int sectorId, int flag)
Definition: DTLVStatus.cc:274