CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTMtime.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  nsPerCount( 25.0 / 32.0 ),
35  dBuf(new DTBufferTree<int,int>) {
36  dataList.reserve( 1000 );
37 }
38 
39 
41  dataVersion( version ),
42  nsPerCount( 25.0 / 32.0 ),
43  dBuf(new DTBufferTree<int,int>) {
44  dataList.reserve( 1000 );
45 }
46 
47 
49  wheelId( 0 ),
50  stationId( 0 ),
51  sectorId( 0 ),
52  slId( 0 ),
53  layerId( 0 ),
54  cellId( 0 ) {
55 }
56 
57 
59  mTime( 0.0 ),
60  mTrms( 0.0 ) {
61 }
62 
63 
64 //--------------
65 // Destructor --
66 //--------------
68 }
69 
70 
72 }
73 
74 
76 }
77 
78 
79 //--------------
80 // Operations --
81 //--------------
82 int DTMtime::get( int wheelId,
83  int stationId,
84  int sectorId,
85  int slId,
86  float& mTime,
87  float& mTrms,
88  DTTimeUnits::type unit ) const {
89  return get( wheelId, stationId, sectorId,
90  slId, 0, 0,
91  mTime, mTrms, unit );
92 
93 }
94 
95 
96 int DTMtime::get( int wheelId,
97  int stationId,
98  int sectorId,
99  int slId,
100  float& mTime,
101  float& mTrms,
102  DTVelocityUnits::type unit ) const {
103  return get( wheelId, stationId, sectorId,
104  slId, 0, 0,
105  mTime, mTrms, unit );
106 
107 }
108 
109 
110 int DTMtime::get( int wheelId,
111  int stationId,
112  int sectorId,
113  int slId,
114  int layerId,
115  int cellId,
116  float& mTime,
117  float& mTrms,
118  DTTimeUnits::type unit ) const {
119 
120  mTime =
121  mTrms = 0.0;
122 
123  std::vector<int> chanKey;
124  chanKey.reserve(6);
125  chanKey.push_back( wheelId );
126  chanKey.push_back( stationId );
127  chanKey.push_back( sectorId );
128  chanKey.push_back( slId );
129  chanKey.push_back( layerId );
130  chanKey.push_back( cellId );
131  int ientry;
132  int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), ientry );
133  if ( !searchStatus ) {
134  const DTMtimeData& data( dataList[ientry].second );
135  mTime = data.mTime;
136  mTrms = data.mTrms;
137  if ( unit == DTTimeUnits::ns ) {
138  mTime *= nsPerCount;
139  mTrms *= nsPerCount;
140  }
141  }
142 
143  return searchStatus;
144 
145 }
146 
147 
148 int DTMtime::get( int wheelId,
149  int stationId,
150  int sectorId,
151  int slId,
152  int layerId,
153  int cellId,
154  float& mTime,
155  float& mTrms,
156  DTVelocityUnits::type unit ) const {
157  int status = get( wheelId, stationId, sectorId,
158  slId, layerId, cellId,
159  mTime, mTrms, DTTimeUnits::counts );
160  if ( unit == DTVelocityUnits::cm_per_count ) {
161  mTime = 2.1 / mTime;
162  mTrms *= mTime;
163  }
164  if ( unit == DTVelocityUnits::cm_per_ns ) {
165  mTime = 2.1 / mTime;
166  mTrms *= mTime;
167  mTime /= nsPerCount;
168  }
169  return status;
170 }
171 
172 
174  float& mTime,
175  float& mTrms,
176  DTTimeUnits::type unit ) const {
177  return get( id.wheel(),
178  id.station(),
179  id.sector(),
180  id.superLayer(), 0, 0,
181  mTime, mTrms, unit );
182 }
183 
184 
186  float& mTime,
187  float& mTrms,
188  DTVelocityUnits::type unit ) const {
189  return get( id.wheel(),
190  id.station(),
191  id.sector(),
192  id.superLayer(), 0, 0,
193  mTime, mTrms, unit );
194 }
195 
196 
197 int DTMtime::get( const DetId& id,
198  float& mTime,
199  float& mTrms,
200  DTTimeUnits::type unit ) const {
201  DTWireId wireId( id.rawId() );
202  return get( wireId.wheel(),
203  wireId.station(),
204  wireId.sector(),
205  wireId.superLayer(),
206  wireId.layer(),
207  wireId.wire(),
208  mTime, mTrms, unit );
209 }
210 
211 
212 int DTMtime::get( const DetId& id,
213  float& mTime,
214  float& mTrms,
215  DTVelocityUnits::type unit ) const {
216  DTWireId wireId( id.rawId() );
217  return get( wireId.wheel(),
218  wireId.station(),
219  wireId.sector(),
220  wireId.superLayer(),
221  wireId.layer(),
222  wireId.wire(),
223  mTime, mTrms, unit );
224 }
225 
226 
227 float DTMtime::unit() const {
228  return nsPerCount;
229 }
230 
231 
232 const
234  return dataVersion;
235 }
236 
237 
239  return dataVersion;
240 }
241 
242 
244  dataList.clear();
245  initialize();
246  return;
247 }
248 
249 
250 int DTMtime::set( int wheelId,
251  int stationId,
252  int sectorId,
253  int slId,
254  float mTime,
255  float mTrms,
257  return set( wheelId, stationId, sectorId,
258  slId, 0, 0,
259  mTime, mTrms, unit );
260 }
261 
262 
263 int DTMtime::set( int wheelId,
264  int stationId,
265  int sectorId,
266  int slId,
267  float mTime,
268  float mTrms,
270  return set( wheelId, stationId, sectorId,
271  slId, 0, 0,
272  mTime, mTrms, unit );
273 }
274 
275 
276 int DTMtime::set( int wheelId,
277  int stationId,
278  int sectorId,
279  int slId,
280  int layerId,
281  int cellId,
282  float mTime,
283  float mTrms,
285 
286  if ( unit == DTTimeUnits::ns ) {
287  mTime /= nsPerCount;
288  mTrms /= nsPerCount;
289  }
290 
291  std::vector<int> chanKey;
292  chanKey.reserve(6);
293  chanKey.push_back( wheelId );
294  chanKey.push_back( stationId );
295  chanKey.push_back( sectorId );
296  chanKey.push_back( slId );
297  chanKey.push_back( layerId );
298  chanKey.push_back( cellId );
299  int ientry;
300  int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), ientry );
301 
302  if ( !searchStatus ) {
303  DTMtimeData& data( dataList[ientry].second );
304  data.mTime = mTime;
305  data.mTrms = mTrms;
306  return -1;
307  }
308  else {
309  DTMtimeId key;
310  key. wheelId = wheelId;
311  key.stationId = stationId;
312  key. sectorId = sectorId;
313  key. slId = slId;
314  key. layerId = layerId;
315  key. cellId = cellId;
317  data.mTime = mTime;
318  data.mTrms = mTrms;
319  ientry = dataList.size();
320  dataList.push_back( std::pair<DTMtimeId,DTMtimeData>( key, data ) );
321  dBuf->insert( chanKey.begin(), chanKey.end(), ientry );
322  return 0;
323  }
324 
325  return 99;
326 
327 }
328 
329 
330 int DTMtime::set( int wheelId,
331  int stationId,
332  int sectorId,
333  int slId,
334  int layerId,
335  int cellId,
336  float mTime,
337  float mTrms,
339  if ( unit == DTVelocityUnits::cm_per_count ) {
340  mTrms /= mTime;
341  mTime = 2.1 / mTime;
342  }
343  if ( unit == DTVelocityUnits::cm_per_ns ) {
344  mTime *= nsPerCount;
345  mTrms /= mTime;
346  mTime = 2.1 / mTime;
347  }
348  return set( wheelId, stationId, sectorId,
349  slId, layerId, cellId,
350  mTime, mTrms, DTTimeUnits::counts );
351 
352 }
353 
354 
356  float mTime,
357  float mTrms,
359  return set( id.wheel(),
360  id.station(),
361  id.sector(),
362  id.superLayer(), 0, 0,
363  mTime, mTrms, unit );
364 }
365 
366 
368  float mTime,
369  float mTrms,
371  return set( id.wheel(),
372  id.station(),
373  id.sector(),
374  id.superLayer(), 0, 0,
375  mTime, mTrms, unit );
376 }
377 
378 
379 int DTMtime::set( const DetId& id,
380  float mTime,
381  float mTrms,
383  DTWireId wireId( id.rawId() );
384  return set( wireId.wheel(),
385  wireId.station(),
386  wireId.sector(),
387  wireId.superLayer(),
388  wireId.layer(),
389  wireId.wire(),
390  mTime, mTrms, unit );
391 }
392 
393 
394 int DTMtime::set( const DetId& id,
395  float mTime,
396  float mTrms,
398  DTWireId wireId( id.rawId() );
399  return set( wireId.wheel(),
400  wireId.station(),
401  wireId.sector(),
402  wireId.superLayer(),
403  wireId.layer(),
404  wireId.wire(),
405  mTime, mTrms, unit );
406 }
407 
408 
409 void DTMtime::setUnit( float unit ) {
410  nsPerCount = unit;
411 }
412 
413 
415  return dataList.begin();
416 }
417 
418 
420  return dataList.end();
421 }
422 
423 
425  std::stringstream name;
426  name << dataVersion << "_map_Mtime" << this;
427  return name.str();
428 }
429 
430 
432 
433  dBuf->clear();
434 
435  int entryNum = 0;
436  int entryMax = dataList.size();
437  std::vector<int> chanKey;
438  chanKey.reserve(6);
439  while ( entryNum < entryMax ) {
440 
441  const DTMtimeId& chan = dataList[entryNum].first;
442 
443  chanKey.clear();
444  chanKey.push_back( chan. wheelId );
445  chanKey.push_back( chan.stationId );
446  chanKey.push_back( chan. sectorId );
447  chanKey.push_back( chan. slId );
448  chanKey.push_back( chan. layerId );
449  chanKey.push_back( chan. cellId );
450  dBuf->insert( chanKey.begin(), chanKey.end(), entryNum++ );
451 
452  }
453 
454  return;
455 
456 }
457 
int stationId
Definition: DTMtime.h:50
float nsPerCount
Definition: DTMtime.h:275
~DTMtimeData()
Definition: DTMtime.cc:75
int set(int wheelId, int stationId, int sectorId, int slId, float mTime, float mTrms, DTTimeUnits::type unit)
Definition: DTMtime.cc:250
int layer() const
Return the layer number.
Definition: DTLayerId.h:53
void setUnit(float unit)
Definition: DTMtime.cc:409
int find(ElementKey fKey, ElementKey lKey, typename DTBufferTreeTrait< Content >::outputTypeOfConstFind &cont) const
U second(std::pair< T, U > const &p)
edm::ConstRespectingPtr< DTBufferTree< int, int > > dBuf
Definition: DTMtime.h:279
void initialize()
Definition: DTMtime.cc:431
string unit
Definition: csvLumiCalc.py:46
DTMtimeData()
Definition: DTMtime.cc:58
int superLayer() const
Return the superlayer number.
float mTrms
Definition: DTMtime.h:69
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
int wire() const
Return the wire number.
Definition: DTWireId.h:56
Definition: DetId.h:18
std::vector< std::pair< DTMtimeId, DTMtimeData > > dataList
Definition: DTMtime.h:277
const_iterator begin() const
Definition: DTMtime.cc:414
std::vector< std::pair< DTMtimeId, DTMtimeData > >::const_iterator const_iterator
Access methods to data.
Definition: DTMtime.h:263
std::string mapName() const
read and store full content
Definition: DTMtime.cc:424
DTMtime()
Definition: DTMtime.cc:32
float unit() const
Definition: DTMtime.cc:227
const std::string & version() const
access version
Definition: DTMtime.cc:233
int get(int wheelId, int stationId, int sectorId, int slId, float &mTime, float &mTrms, DTTimeUnits::type unit) const
Definition: DTMtime.cc:82
~DTMtime()
Definition: DTMtime.cc:67
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
int insert(ElementKey fKey, ElementKey lKey, Content cont)
float mTime
Definition: DTMtime.h:68
DTMtimeId()
Definition: DTMtime.cc:48
int sector() const
Definition: DTChamberId.h:61
const_iterator end() const
Definition: DTMtime.cc:419
~DTMtimeId()
Definition: DTMtime.cc:71
std::string dataVersion
Definition: DTMtime.h:274
void clear()
reset content
Definition: DTMtime.cc:243
tuple status
Definition: ntuplemaker.py:245
int station() const
Return the station number.
Definition: DTChamberId.h:51
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:45