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: 2008/12/11 09:44:53 $
5  * $Revision: 1.16 $
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"
20 
21 //---------------
22 // C++ Headers --
23 //---------------
24 #include <iostream>
25 #include <sstream>
26 
27 //-------------------
28 // Initializations --
29 //-------------------
30 
31 
32 //----------------
33 // Constructors --
34 //----------------
36  dataVersion( " " ),
37  nsPerCount( 25.0 / 32.0 ),
38  dBuf(new DTBufferTree<int,int>) {
39  dataList.reserve( 1000 );
40 }
41 
42 
44  dataVersion( version ),
45  nsPerCount( 25.0 / 32.0 ),
46  dBuf(new DTBufferTree<int,int>) {
47  dataList.reserve( 1000 );
48 }
49 
50 
52  wheelId( 0 ),
53  stationId( 0 ),
54  sectorId( 0 ),
55  slId( 0 ),
56  layerId( 0 ),
57  cellId( 0 ) {
58 }
59 
60 
62  tTrig( 0.0 ),
63  tTrms( 0.0 ),
64  kFact( 0.0 ) {
65 }
66 
67 
68 //--------------
69 // Destructor --
70 //--------------
72 }
73 
74 
76 }
77 
78 
80 }
81 
82 //--------------
83 // Operations --
84 //--------------
85 int DTTtrig::get( int wheelId,
86  int stationId,
87  int sectorId,
88  int slId,
89  float& tTrig,
90  float& tTrms,
91  float& kFact,
92  DTTimeUnits::type unit ) const {
93  return get( wheelId, stationId, sectorId,
94  slId, 0, 0,
95  tTrig, tTrms, kFact, unit );
96 
97 }
98 
99 
100 int DTTtrig::get( int wheelId,
101  int stationId,
102  int sectorId,
103  int slId,
104  int layerId,
105  int cellId,
106  float& tTrig,
107  float& tTrms,
108  float& kFact,
109  DTTimeUnits::type unit ) const {
110 
111  tTrig =
112  tTrms =
113  kFact = 0.0;
114 
115  std::vector<int> chanKey;
116  chanKey.reserve(6);
117  chanKey.push_back( wheelId );
118  chanKey.push_back( stationId );
119  chanKey.push_back( sectorId );
120  chanKey.push_back( slId );
121  chanKey.push_back( layerId );
122  chanKey.push_back( cellId );
123  int ientry;
124  int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), ientry );
125  if ( !searchStatus ) {
126  const DTTtrigData& data( dataList[ientry].second );
127  tTrig = data.tTrig;
128  tTrms = data.tTrms;
129  kFact = data.kFact;
130  if ( unit == DTTimeUnits::ns ) {
131  tTrig *= nsPerCount;
132  tTrms *= nsPerCount;
133  }
134  }
135 
136  return searchStatus;
137 
138 }
139 
140 
142  float& tTrig,
143  float& tTrms,
144  float& kFact,
145  DTTimeUnits::type unit ) const {
146  return get( id.wheel(),
147  id.station(),
148  id.sector(),
149  id.superLayer(), 0, 0,
150  tTrig, tTrms, kFact, unit );
151 }
152 
153 
154 int DTTtrig::get( const DetId& id,
155  float& tTrig,
156  float& tTrms,
157  float& kFact,
158  DTTimeUnits::type unit ) const {
159  DTWireId wireId( id.rawId() );
160  return get( wireId.wheel(),
161  wireId.station(),
162  wireId.sector(),
163  wireId.superLayer(),
164  wireId.layer(),
165  wireId.wire(),
166  tTrig, tTrms, kFact, unit );
167 }
168 
169 
170 int DTTtrig::get( int wheelId,
171  int stationId,
172  int sectorId,
173  int slId,
174  float& tTrig,
175  DTTimeUnits::type unit ) const {
176  return get( wheelId, stationId, sectorId,
177  slId, 0, 0, tTrig, unit );
178 }
179 
180 
181 int DTTtrig::get( int wheelId,
182  int stationId,
183  int sectorId,
184  int slId,
185  int layerId,
186  int cellId,
187  float& tTrig,
188  DTTimeUnits::type unit ) const {
189  float tMean;
190  float tTrms;
191  float kFact;
192  int status = get( wheelId, stationId, sectorId,
193  slId, layerId, cellId,
194  tMean, tTrms, kFact, unit );
195  tTrig = tMean + ( kFact * tTrms );
196  return status;
197 }
198 
199 
201  float& tTrig,
202  DTTimeUnits::type unit ) const {
203  return get( id.wheel(),
204  id.station(),
205  id.sector(),
206  id.superLayer(), 0, 0,
207  tTrig, unit );
208 }
209 
210 
211 int DTTtrig::get( const DetId& id,
212  float& tTrig,
213  DTTimeUnits::type unit ) const {
214  DTWireId wireId( id.rawId() );
215  return get( wireId.wheel(),
216  wireId.station(),
217  wireId.sector(),
218  wireId.superLayer(),
219  wireId.layer(),
220  wireId.wire(),
221  tTrig, unit );
222 }
223 
224 
225 float DTTtrig::unit() const {
226  return nsPerCount;
227 }
228 
229 
230 const
232  return dataVersion;
233 }
234 
235 
237  return dataVersion;
238 }
239 
240 
242  dataList.clear();
243  initialize();
244  return;
245 }
246 
247 
248 int DTTtrig::set( int wheelId,
249  int stationId,
250  int sectorId,
251  int slId,
252  float tTrig,
253  float tTrms,
254  float kFact,
256  return set( wheelId, stationId, sectorId,
257  slId, 0, 0,
258  tTrig, tTrms, kFact, unit );
259 
260 }
261 
262 
263 int DTTtrig::set( int wheelId,
264  int stationId,
265  int sectorId,
266  int slId,
267  int layerId,
268  int cellId,
269  float tTrig,
270  float tTrms,
271  float kFact,
273 
274  if ( unit == DTTimeUnits::ns ) {
275  tTrig /= nsPerCount;
276  tTrms /= nsPerCount;
277  }
278 
279  std::vector<int> chanKey;
280  chanKey.reserve(6);
281  chanKey.push_back( wheelId );
282  chanKey.push_back( stationId );
283  chanKey.push_back( sectorId );
284  chanKey.push_back( slId );
285  chanKey.push_back( layerId );
286  chanKey.push_back( cellId );
287  int ientry;
288  int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), ientry );
289 
290  if ( !searchStatus ) {
291  DTTtrigData& data( dataList[ientry].second );
292  data.tTrig = tTrig;
293  data.tTrms = tTrms;
294  data.kFact = kFact;
295  return -1;
296  }
297  else {
298  DTTtrigId key;
299  key. wheelId = wheelId;
300  key.stationId = stationId;
301  key. sectorId = sectorId;
302  key. slId = slId;
303  key. layerId = layerId;
304  key. cellId = cellId;
306  data.tTrig = tTrig;
307  data.tTrms = tTrms;
308  data.kFact = kFact;
309  ientry = dataList.size();
310  dataList.push_back( std::pair<DTTtrigId,DTTtrigData>( key, data ) );
311  dBuf->insert( chanKey.begin(), chanKey.end(), ientry );
312  return 0;
313  }
314 
315  return 99;
316 
317 }
318 
319 
321  float tTrig,
322  float tTrms,
323  float kFact,
325  return set( id.wheel(),
326  id.station(),
327  id.sector(),
328  id.superLayer(), 0, 0,
329  tTrig, tTrms, kFact, unit );
330 }
331 
332 
333 int DTTtrig::set( const DetId& id,
334  float tTrig,
335  float tTrms,
336  float kFact,
338  DTWireId wireId( id.rawId() );
339  return set( wireId.wheel(),
340  wireId.station(),
341  wireId.sector(),
342  wireId.superLayer(),
343  wireId.layer(),
344  wireId.wire(),
345  tTrig, tTrms, kFact, unit );
346 }
347 
348 
349 void DTTtrig::setUnit( float unit ) {
350  nsPerCount = unit;
351 }
352 
353 
355  return dataList.begin();
356 }
357 
358 
360  return dataList.end();
361 }
362 
363 
365  std::stringstream name;
366  name << dataVersion << "_map_Ttrig" << this;
367  return name.str();
368 }
369 
370 
372 
373  dBuf->clear();
374 
375  int entryNum = 0;
376  int entryMax = dataList.size();
377  std::vector<int> chanKey;
378  chanKey.reserve(6);
379  while ( entryNum < entryMax ) {
380 
381  const DTTtrigId& chan = dataList[entryNum].first;
382 
383  chanKey.clear();
384  chanKey.push_back( chan. wheelId );
385  chanKey.push_back( chan.stationId );
386  chanKey.push_back( chan. sectorId );
387  chanKey.push_back( chan. slId );
388  chanKey.push_back( chan. layerId );
389  chanKey.push_back( chan. cellId );
390  dBuf->insert( chanKey.begin(), chanKey.end(), entryNum++ );
391  }
392  return;
393 }
~DTTtrigId()
Definition: DTTtrig.cc:75
void initialize()
Definition: DTTtrig.cc:371
int set(int wheelId, int stationId, int sectorId, int slId, float tTrig, float tTrms, float kFact, DTTimeUnits::type unit)
Definition: DTTtrig.cc:248
DTTtrigId()
Definition: DTTtrig.cc:51
DTTtrig()
Definition: DTTtrig.cc:35
~DTTtrig()
Definition: DTTtrig.cc:71
~DTTtrigData()
Definition: DTTtrig.cc:79
edm::ConstRespectingPtr< DTBufferTree< int, int > > dBuf
Definition: DTTtrig.h:199
float nsPerCount
Definition: DTTtrig.h:195
float tTrms
Definition: DTTtrig.h:68
void setUnit(float unit)
Definition: DTTtrig.cc:349
const std::string & version() const
access version
Definition: DTTtrig.cc:231
int stationId
Definition: DTTtrig.h:49
int layer() const
Return the layer number.
Definition: DTLayerId.h:53
std::vector< std::pair< DTTtrigId, DTTtrigData > > dataList
Definition: DTTtrig.h:197
DTTtrigData()
Definition: DTTtrig.cc:61
void clear()
reset content
Definition: DTTtrig.cc:241
std::vector< std::pair< DTTtrigId, DTTtrigData > >::const_iterator const_iterator
Access methods to data.
Definition: DTTtrig.h:183
int find(ElementKey fKey, ElementKey lKey, typename DTBufferTreeTrait< Content >::outputTypeOfConstFind &cont) const
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:364
float unit() const
Definition: DTTtrig.cc:225
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
int wire() const
Return the wire number.
Definition: DTWireId.h:56
float kFact
Definition: DTTtrig.h:69
Definition: DetId.h:18
std::string dataVersion
Definition: DTTtrig.h:194
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:85
float tTrig
Definition: DTTtrig.h:67
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
int insert(ElementKey fKey, ElementKey lKey, Content cont)
int sector() const
Definition: DTChamberId.h:61
const_iterator begin() const
Definition: DTTtrig.cc:354
tuple status
Definition: ntuplemaker.py:245
int station() const
Return the station number.
Definition: DTChamberId.h:51
const_iterator end() const
Definition: DTTtrig.cc:359
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:45