CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTTtrig.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * $Date: 2010/01/20 18:20:08 $
5  * $Revision: 1.17 $
6  * \author Paolo Ronchese INFN Padova
7  *
8  */
9 
10 //----------------------
11 // This Class' Header --
12 //----------------------
14 
15 //-------------------------------
16 // Collaborating Class Headers --
17 //-------------------------------
18 //#include "CondFormats/DTObjects/interface/DTDataBuffer.h"
19 
20 //---------------
21 // C++ Headers --
22 //---------------
23 #include <iostream>
24 #include <sstream>
25 
26 //-------------------
27 // Initializations --
28 //-------------------
29 
30 
31 //----------------
32 // Constructors --
33 //----------------
35  dataVersion( " " ),
36  nsPerCount( 25.0 / 32.0 ) {
37  dataList.reserve( 1000 );
38  dBuf = 0;
39 }
40 
41 
42 DTTtrig::DTTtrig( const std::string& version ):
43  dataVersion( version ),
44  nsPerCount( 25.0 / 32.0 ) {
45  dataList.reserve( 1000 );
46  dBuf = 0;
47 }
48 
49 
51  wheelId( 0 ),
52  stationId( 0 ),
53  sectorId( 0 ),
54  slId( 0 ),
55  layerId( 0 ),
56  cellId( 0 ) {
57 }
58 
59 
61  tTrig( 0.0 ),
62  tTrms( 0.0 ),
63  kFact( 0.0 ) {
64 }
65 
66 
67 //--------------
68 // Destructor --
69 //--------------
71 // DTDataBuffer<int,int>::dropBuffer( mapName() );
72  delete dBuf;
73 }
74 
75 
77 }
78 
79 
81 }
82 
83 
84 //--------------
85 // Operations --
86 //--------------
87 int DTTtrig::get( int wheelId,
88  int stationId,
89  int sectorId,
90  int slId,
91  float& tTrig,
92  float& tTrms,
93  float& kFact,
94  DTTimeUnits::type unit ) const {
95  return get( wheelId, stationId, sectorId,
96  slId, 0, 0,
97  tTrig, tTrms, kFact, unit );
98 
99 }
100 
101 
102 int DTTtrig::get( int wheelId,
103  int stationId,
104  int sectorId,
105  int slId,
106  int layerId,
107  int cellId,
108  float& tTrig,
109  float& tTrms,
110  float& kFact,
111  DTTimeUnits::type unit ) const {
112 
113  tTrig =
114  tTrms =
115  kFact = 0.0;
116 
117 // std::string mName = mapName();
118 // DTBufferTree<int,int>* dBuf =
119 // DTDataBuffer<int,int>::findBuffer( mName );
120 // if ( dBuf == 0 ) {
121 // cacheMap();
122 // dBuf =
123 // DTDataBuffer<int,int>::findBuffer( mName );
124 // }
125  if ( dBuf == 0 ) cacheMap();
126 
127  std::vector<int> chanKey;
128  chanKey.reserve(6);
129  chanKey.push_back( wheelId );
130  chanKey.push_back( stationId );
131  chanKey.push_back( sectorId );
132  chanKey.push_back( slId );
133  chanKey.push_back( layerId );
134  chanKey.push_back( cellId );
135  int ientry;
136  int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), ientry );
137  if ( !searchStatus ) {
138  const DTTtrigData& data( dataList[ientry].second );
139  tTrig = data.tTrig;
140  tTrms = data.tTrms;
141  kFact = data.kFact;
142  if ( unit == DTTimeUnits::ns ) {
143  tTrig *= nsPerCount;
144  tTrms *= nsPerCount;
145  }
146  }
147 
148  return searchStatus;
149 
150 }
151 
152 
154  float& tTrig,
155  float& tTrms,
156  float& kFact,
157  DTTimeUnits::type unit ) const {
158  return get( id.wheel(),
159  id.station(),
160  id.sector(),
161  id.superLayer(), 0, 0,
162  tTrig, tTrms, kFact, unit );
163 }
164 
165 
166 int DTTtrig::get( const DetId& id,
167  float& tTrig,
168  float& tTrms,
169  float& kFact,
170  DTTimeUnits::type unit ) const {
171  DTWireId wireId( id.rawId() );
172  return get( wireId.wheel(),
173  wireId.station(),
174  wireId.sector(),
175  wireId.superLayer(),
176  wireId.layer(),
177  wireId.wire(),
178  tTrig, tTrms, kFact, unit );
179 }
180 
181 
182 int DTTtrig::get( int wheelId,
183  int stationId,
184  int sectorId,
185  int slId,
186  float& tTrig,
187  DTTimeUnits::type unit ) const {
188  return get( wheelId, stationId, sectorId,
189  slId, 0, 0, tTrig, unit );
190 }
191 
192 
193 int DTTtrig::get( int wheelId,
194  int stationId,
195  int sectorId,
196  int slId,
197  int layerId,
198  int cellId,
199  float& tTrig,
200  DTTimeUnits::type unit ) const {
201  float tMean;
202  float tTrms;
203  float kFact;
204  int status = get( wheelId, stationId, sectorId,
205  slId, layerId, cellId,
206  tMean, tTrms, kFact, unit );
207  tTrig = tMean + ( kFact * tTrms );
208  return status;
209 }
210 
211 
213  float& tTrig,
214  DTTimeUnits::type unit ) const {
215  return get( id.wheel(),
216  id.station(),
217  id.sector(),
218  id.superLayer(), 0, 0,
219  tTrig, unit );
220 }
221 
222 
223 int DTTtrig::get( const DetId& id,
224  float& tTrig,
225  DTTimeUnits::type unit ) const {
226  DTWireId wireId( id.rawId() );
227  return get( wireId.wheel(),
228  wireId.station(),
229  wireId.sector(),
230  wireId.superLayer(),
231  wireId.layer(),
232  wireId.wire(),
233  tTrig, unit );
234 }
235 
236 
237 float DTTtrig::unit() const {
238  return nsPerCount;
239 }
240 
241 
242 const
243 std::string& DTTtrig::version() const {
244  return dataVersion;
245 }
246 
247 
248 std::string& DTTtrig::version() {
249  return dataVersion;
250 }
251 
252 
254 // DTDataBuffer<int,int>::dropBuffer( mapName() );
255  delete dBuf;
256  dBuf = 0;
257  dataList.clear();
258  return;
259 }
260 
261 
262 int DTTtrig::set( int wheelId,
263  int stationId,
264  int sectorId,
265  int slId,
266  float tTrig,
267  float tTrms,
268  float kFact,
270  return set( wheelId, stationId, sectorId,
271  slId, 0, 0,
272  tTrig, tTrms, kFact, unit );
273 
274 }
275 
276 
277 int DTTtrig::set( int wheelId,
278  int stationId,
279  int sectorId,
280  int slId,
281  int layerId,
282  int cellId,
283  float tTrig,
284  float tTrms,
285  float kFact,
287 
288  if ( unit == DTTimeUnits::ns ) {
289  tTrig /= nsPerCount;
290  tTrms /= nsPerCount;
291  }
292 
293 // std::string mName = mapName();
294 // DTBufferTree<int,int>* dBuf =
295 // DTDataBuffer<int,int>::findBuffer( mName );
296 // if ( dBuf == 0 ) {
297 // cacheMap();
298 // dBuf =
299 // DTDataBuffer<int,int>::findBuffer( mName );
300 // }
301  if ( dBuf == 0 ) cacheMap();
302  std::vector<int> chanKey;
303  chanKey.reserve(6);
304  chanKey.push_back( wheelId );
305  chanKey.push_back( stationId );
306  chanKey.push_back( sectorId );
307  chanKey.push_back( slId );
308  chanKey.push_back( layerId );
309  chanKey.push_back( cellId );
310  int ientry;
311  int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), ientry );
312 
313  if ( !searchStatus ) {
314  DTTtrigData& data( dataList[ientry].second );
315  data.tTrig = tTrig;
316  data.tTrms = tTrms;
317  data.kFact = kFact;
318  return -1;
319  }
320  else {
321  DTTtrigId key;
322  key. wheelId = wheelId;
323  key.stationId = stationId;
324  key. sectorId = sectorId;
325  key. slId = slId;
326  key. layerId = layerId;
327  key. cellId = cellId;
329  data.tTrig = tTrig;
330  data.tTrms = tTrms;
331  data.kFact = kFact;
332  ientry = dataList.size();
333  dataList.push_back( std::pair<DTTtrigId,DTTtrigData>( key, data ) );
334  dBuf->insert( chanKey.begin(), chanKey.end(), ientry );
335  return 0;
336  }
337 
338  return 99;
339 
340 }
341 
342 
344  float tTrig,
345  float tTrms,
346  float kFact,
348  return set( id.wheel(),
349  id.station(),
350  id.sector(),
351  id.superLayer(), 0, 0,
352  tTrig, tTrms, kFact, unit );
353 }
354 
355 
356 int DTTtrig::set( const DetId& id,
357  float tTrig,
358  float tTrms,
359  float kFact,
361  DTWireId wireId( id.rawId() );
362  return set( wireId.wheel(),
363  wireId.station(),
364  wireId.sector(),
365  wireId.superLayer(),
366  wireId.layer(),
367  wireId.wire(),
368  tTrig, tTrms, kFact, unit );
369 }
370 
371 
372 void DTTtrig::setUnit( float unit ) {
373  nsPerCount = unit;
374 }
375 
376 
378  return dataList.begin();
379 }
380 
381 
383  return dataList.end();
384 }
385 
386 
387 std::string DTTtrig::mapName() const {
388  std::stringstream name;
389  name << dataVersion << "_map_Ttrig" << this;
390  return name.str();
391 }
392 
393 
394 void DTTtrig::cacheMap() const {
395 
396 // std::string mName = mapName();
397 // DTBufferTree<int,int>* dBuf =
398 // DTDataBuffer<int,int>::openBuffer( mName );
399  DTBufferTree<int,int>** pBuf;
400  pBuf = const_cast<DTBufferTree<int,int>**>( &dBuf );
401  *pBuf = new DTBufferTree<int,int>;
402 
403  int entryNum = 0;
404  int entryMax = dataList.size();
405  std::vector<int> chanKey;
406  chanKey.reserve(6);
407  while ( entryNum < entryMax ) {
408 
409  const DTTtrigId& chan = dataList[entryNum].first;
410 
411  chanKey.clear();
412  chanKey.push_back( chan. wheelId );
413  chanKey.push_back( chan.stationId );
414  chanKey.push_back( chan. sectorId );
415  chanKey.push_back( chan. slId );
416  chanKey.push_back( chan. layerId );
417  chanKey.push_back( chan. cellId );
418  dBuf->insert( chanKey.begin(), chanKey.end(), entryNum++ );
419 
420  }
421 
422  return;
423 
424 }
425 
~DTTtrigId()
Definition: DTTtrig.cc:76
int set(int wheelId, int stationId, int sectorId, int slId, float tTrig, float tTrms, float kFact, DTTimeUnits::type unit)
Definition: DTTtrig.cc:262
DTTtrigId()
Definition: DTTtrig.cc:50
DTTtrig()
Definition: DTTtrig.cc:34
~DTTtrig()
Definition: DTTtrig.cc:70
~DTTtrigData()
Definition: DTTtrig.cc:80
int insert(ElementKey fKey, ElementKey lKey, const Content &cont)
float nsPerCount
Definition: DTTtrig.h:183
float tTrms
Definition: DTTtrig.h:63
void setUnit(float unit)
Definition: DTTtrig.cc:372
const std::string & version() const
access version
Definition: DTTtrig.cc:243
int stationId
Definition: DTTtrig.h:46
int layer() const
Return the layer number.
Definition: DTLayerId.h:55
std::vector< std::pair< DTTtrigId, DTTtrigData > > dataList
Definition: DTTtrig.h:185
DTTtrigData()
Definition: DTTtrig.cc:60
void clear()
reset content
Definition: DTTtrig.cc:253
std::vector< std::pair< DTTtrigId, DTTtrigData > >::const_iterator const_iterator
Access methods to data.
Definition: DTTtrig.h:176
DTBufferTree< int, int > * dBuf
Definition: DTTtrig.h:187
U second(std::pair< T, U > const &p)
string unit
Definition: csvLumiCalc.py:46
int superLayer() const
Return the superlayer number.
std::string mapName() const
Definition: DTTtrig.cc:387
float unit() const
Definition: DTTtrig.cc:237
void cacheMap() const
read and store full content
Definition: DTTtrig.cc:394
int wire() const
Return the wire number.
Definition: DTWireId.h:58
float kFact
Definition: DTTtrig.h:64
Definition: DetId.h:20
std::string dataVersion
Definition: DTTtrig.h:182
int get(int wheelId, int stationId, int sectorId, int slId, float &tTrig, float &tTrms, float &kFact, DTTimeUnits::type unit) const
get content
Definition: DTTtrig.cc:87
int find(ElementKey fKey, ElementKey lKey, Content &cont)
float tTrig
Definition: DTTtrig.h:62
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
list key
Definition: combine.py:13
int sector() const
Definition: DTChamberId.h:63
const_iterator begin() const
Definition: DTTtrig.cc:377
tuple status
Definition: ntuplemaker.py:245
int station() const
Return the station number.
Definition: DTChamberId.h:53
const_iterator end() const
Definition: DTTtrig.cc:382
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:47