CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTCCBConfig.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 
22 //-------------------
23 // Initializations --
24 //-------------------
25 
26 
27 //----------------
28 // Constructors --
29 //----------------
31  timeStamp(0),
32  dataVersion( " " ),
33  dBuf(new DTBufferTreeUniquePtr) {
34  dataList.reserve( 1000 );
35 }
36 
37 
39  timeStamp(0),
40  dataVersion( version ),
41  dBuf(new DTBufferTreeUniquePtr) {
42  dataList.reserve( 1000 );
43 }
44 
45 
47  wheelId( 0 ),
48  stationId( 0 ),
49  sectorId( 0 ) {
50 }
51 
52 
54  confType( 0 ),
55  confKey ( 0 ) {
56 }
57 
58 
59 //--------------
60 // Destructor --
61 //--------------
63 }
64 
65 
67 }
68 
69 
71 }
72 
73 
74 //--------------
75 // Operations --
76 //--------------
77 std::vector<DTConfigKey> DTCCBConfig::fullKey() const {
78  return fullConfigKey;
79 }
80 
81 
82 int DTCCBConfig::stamp() const {
83  return timeStamp;
84 }
85 
86 
87 int DTCCBConfig::configKey( int wheelId,
88  int stationId,
89  int sectorId,
90  std::vector<int>& confKey ) const {
91 
92  confKey.clear();
93 
94  std::vector<int> chanKey { wheelId, stationId, sectorId };
95  std::vector<int> const* confPtr;
96  int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), confPtr );
97  if ( !searchStatus ) confKey = *confPtr;
98 
99  return searchStatus;
100 }
101 
102 
104  std::vector<int>& confKey ) const {
105  return configKey( id.wheel(),
106  id.station(),
107  id.sector(),
108  confKey );
109 }
110 
111 
114 
115  ccb_config_map keyList;
116  std::vector< std::pair<DTCCBId,int>* > tempList;
117  const_iterator d_iter = begin();
118  const_iterator d_iend = end();
119  while ( d_iter != d_iend ) tempList.push_back(
120  new std::pair<DTCCBId,int>( *d_iter++ ) );
121  std::vector< std::pair<DTCCBId,int>* >::iterator t_iter = tempList.begin();
122  std::vector< std::pair<DTCCBId,int>* >::iterator t_iend = tempList.end();
123  while ( t_iter != t_iend ) {
124  std::pair<DTCCBId,int>* ptr = *t_iter++;
125  if ( ptr == 0 ) continue;
126  DTCCBId& ccbId = ptr->first;
127  std::vector<int> cfgKeys;
128  cfgKeys.push_back( ptr->second );
129  std::vector< std::pair<DTCCBId,int>* >::iterator n_iter( t_iter );
130  while( n_iter != t_iend ) {
131  std::pair<DTCCBId,int>*& pck = *n_iter++;
132  if ( pck == 0 ) continue;
133  DTCCBId& chkId = pck->first;
134  if ( ( chkId. wheelId == ccbId. wheelId ) &&
135  ( chkId.stationId == ccbId.stationId ) &&
136  ( chkId. sectorId == ccbId. sectorId ) ) {
137  cfgKeys.push_back( pck->second );
138  delete pck;
139  pck = 0;
140  }
141  }
142  keyList.push_back( std::pair< DTCCBId,std::vector<int> >( ccbId,
143  cfgKeys ) );
144  delete ptr;
145  }
146  return keyList;
147 
148 }
149 
150 
151 const
153  return dataVersion;
154 }
155 
156 
158  return dataVersion;
159 }
160 
161 
163  dataList.clear();
164  initialize();
165  return;
166 }
167 
168 
169 void DTCCBConfig::setFullKey( const std::vector<DTConfigKey>& key ) {
170  fullConfigKey = key;
171 }
172 
173 
175  timeStamp = s;
176 }
177 
178 
179 int DTCCBConfig::setConfigKey( int wheelId,
180  int stationId,
181  int sectorId,
182  const std::vector<int>& confKey ) {
183 
184  std::vector<int> chanKey { wheelId, stationId, sectorId };
185 
186  std::vector<int>* confPtr;
187  int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), confPtr );
188 
189  if ( !searchStatus ) {
190  std::vector< std::pair<DTCCBId,int> > tempList;
191  const_iterator iter = dataList.begin();
192  const_iterator iend = dataList.end();
193  while ( iter != iend ) {
194  const DTCCBId& ccbId( iter->first );
195  if ( ( ccbId. wheelId != wheelId ) ||
196  ( ccbId.stationId != stationId ) ||
197  ( ccbId. sectorId != sectorId ) ) tempList.push_back( *iter );
198  ++iter;
199  }
200  dataList = tempList;
201  DTCCBId ccbId;
202  ccbId. wheelId = wheelId;
203  ccbId.stationId = stationId;
204  ccbId. sectorId = sectorId;
205  std::vector<int>::const_iterator cfgIter = confKey.begin();
206  std::vector<int>::const_iterator cfgIend = confKey.end();
207  while ( cfgIter != cfgIend ) dataList.push_back( std::pair<DTCCBId,int>(
208  ccbId, *cfgIter++ ) );
209  *confPtr = confKey;
210  return -1;
211  }
212  else {
213  dBuf->insert( chanKey.begin(),
214  chanKey.end(), std::unique_ptr<std::vector<int> >(new std::vector<int>( confKey ) ) );
215  DTCCBId ccbId;
216  ccbId. wheelId = wheelId;
217  ccbId.stationId = stationId;
218  ccbId. sectorId = sectorId;
219  std::vector<int>::const_iterator cfgIter = confKey.begin();
220  std::vector<int>::const_iterator cfgIend = confKey.end();
221  while ( cfgIter != cfgIend ) dataList.push_back( std::pair<DTCCBId,int>(
222  ccbId, *cfgIter++ ) );
223  return 0;
224  }
225 
226 }
227 
228 
230  const std::vector<int>& confKey ) {
231  return setConfigKey( id.wheel(),
232  id.station(),
233  id.sector(),
234  confKey );
235 }
236 
237 
239  int stationId,
240  int sectorId,
241  const std::vector<int>& confKey ) {
242 
243  std::vector<int> chanKey { wheelId, stationId, sectorId };
244 
245  DTCCBId ccbId;
246  ccbId. wheelId = wheelId;
247  ccbId.stationId = stationId;
248  ccbId. sectorId = sectorId;
249  std::vector<int>::const_iterator iter = confKey.begin();
250  std::vector<int>::const_iterator iend = confKey.end();
251  int key;
252 
253  std::vector<int>* confPtr;
254  int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), confPtr );
255 
256  if ( searchStatus ) {
257  std::unique_ptr<std::vector<int> > newVector(new std::vector<int>);
258  confPtr = newVector.get();
259  dBuf->insert( chanKey.begin(),
260  chanKey.end(), std::move(newVector) );
261  }
262 
263  while ( iter != iend ) {
264  key = *iter++;
265  dataList.push_back( std::pair<DTCCBId,int>( ccbId, key ) );
266  confPtr->push_back( key );
267  }
268 
269  if ( !searchStatus ) {
270  return -1;
271  }
272  else {
273  return 0;
274  }
275 
276 }
277 
279  const std::vector<int>& confKey ) {
280  return appendConfigKey( id.wheel(),
281  id.station(),
282  id.sector(),
283  confKey );
284 }
285 
287  return dataList.begin();
288 }
289 
290 
292  return dataList.end();
293 }
294 
296 
297  dBuf->clear();
298 
299  const_iterator iter = dataList.begin();
300  const_iterator iend = dataList.end();
301  std::vector<int> chanKey;
302  chanKey.reserve(3);
303  while ( iter != iend ) {
304 
305  const DTCCBId& chan = iter->first;
306 
307  chanKey.clear();
308  chanKey.push_back( chan. wheelId );
309  chanKey.push_back( chan.stationId );
310  chanKey.push_back( chan. sectorId );
311  std::vector<int>* ccbConfPtr;
312  int searchStatus = dBuf->find( chanKey.begin(),
313  chanKey.end(), ccbConfPtr );
314 
315  if ( searchStatus ) {
316  std::unique_ptr<std::vector<int> > newVector(new std::vector<int>);
317  ccbConfPtr = newVector.get();
318  dBuf->insert( chanKey.begin(), chanKey.end(), std::move(newVector) );
319  }
320  ccbConfPtr->push_back( iter->second );
321 
322  iter++;
323 
324  }
325 }
void setStamp(int s)
Definition: DTCCBConfig.cc:174
std::vector< std::pair< DTCCBId, int > > dataList
Definition: DTCCBConfig.h:131
std::vector< DTConfigKey > fullConfigKey
Definition: DTCCBConfig.h:130
const std::string & version() const
access version
Definition: DTCCBConfig.cc:152
int configKey(int wheelId, int stationId, int sectorId, std::vector< int > &confKey) const
Definition: DTCCBConfig.cc:87
const_iterator end() const
Definition: DTCCBConfig.cc:291
ccb_config_map configKeyMap() const
Definition: DTCCBConfig.cc:113
std::vector< std::pair< DTCCBId, int > >::const_iterator const_iterator
Access methods to data.
Definition: DTCCBConfig.h:117
int find(ElementKey fKey, ElementKey lKey, typename DTBufferTreeTrait< Content >::outputTypeOfConstFind &cont) const
int stationId
Definition: DTCCBConfig.h:46
def move
Definition: eostools.py:510
std::vector< std::pair< DTCCBId, std::vector< int > > > ccb_config_map
Definition: DTCCBConfig.h:86
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
std::vector< DTConfigKey > fullKey() const
Definition: DTCCBConfig.cc:77
std::string dataVersion
Definition: DTCCBConfig.h:129
virtual ~DTCCBConfig()
Definition: DTCCBConfig.cc:62
int stamp() const
Definition: DTCCBConfig.cc:82
void initialize()
Definition: DTCCBConfig.cc:295
int insert(ElementKey fKey, ElementKey lKey, Content cont)
void clear()
reset content
Definition: DTCCBConfig.cc:162
edm::ConstRespectingPtr< DTBufferTreeUniquePtr > dBuf
Definition: DTCCBConfig.h:133
int setConfigKey(int wheelId, int stationId, int sectorId, const std::vector< int > &confKey)
Definition: DTCCBConfig.cc:179
void setFullKey(const std::vector< DTConfigKey > &)
Definition: DTCCBConfig.cc:169
const_iterator begin() const
Definition: DTCCBConfig.cc:286
int appendConfigKey(int wheelId, int stationId, int sectorId, const std::vector< int > &confKey)
Definition: DTCCBConfig.cc:238