CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTPerformance.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:37:53 $
5  * $Revision: 1.7 $
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  dataList.reserve( 1000 );
37  dBuf = 0;
38 }
39 
40 
41 DTPerformance::DTPerformance( const std::string& version ):
42  dataVersion( version ) {
43  dataList.reserve( 1000 );
44  dBuf = 0;
45 }
46 
47 
49  wheelId( 0 ),
50  stationId( 0 ),
51  sectorId( 0 ),
52  slId( 0 ) {
53 }
54 
55 
57  meanT0( 0.0 ),
58  meanTtrig( 0.0 ),
59  meanMtime( 0.0 ),
60  meanNoise( 0.0 ),
61  meanAfterPulse( 0.0 ),
62  meanResolution( 0.0 ),
63  meanEfficiency( 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 DTPerformance::get( int wheelId,
88  int stationId,
89  int sectorId,
90  int slId,
91  float& meanT0,
92  float& meanTtrig,
93  float& meanMtime,
94  float& meanNoise,
95  float& meanAfterPulse,
96  float& meanResolution,
97  float& meanEfficiency,
98  DTTimeUnits::type unit ) const {
99 
100  meanT0 =
101  meanTtrig =
102  meanMtime =
103  meanNoise =
104  meanAfterPulse =
105  meanResolution =
106  meanEfficiency = 0.0;
107 
108 // std::string mName = mapName();
109 // DTBufferTree<int,int>* dBuf =
110 // DTDataBuffer<int,int>::findBuffer( mName );
111 // if ( dBuf == 0 ) {
112 // cacheMap();
113 // dBuf =
114 // DTDataBuffer<int,int>::findBuffer( mName );
115 // }
116  if ( dBuf == 0 ) cacheMap();
117 
118  std::vector<int> chanKey;
119  chanKey.reserve(4);
120  chanKey.push_back( wheelId );
121  chanKey.push_back( stationId );
122  chanKey.push_back( sectorId );
123  chanKey.push_back( slId );
124  int ientry;
125  int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), ientry );
126  if ( !searchStatus ) {
127  const DTPerformanceData& data( dataList[ientry].second );
128  meanT0 = data.meanT0;
129  meanTtrig = data.meanTtrig;
130  meanMtime = data.meanMtime;
131  meanNoise = data.meanNoise;
132  meanAfterPulse = data.meanAfterPulse;
133  meanResolution = data.meanResolution;
134  meanEfficiency = data.meanEfficiency;
135  if ( unit == DTTimeUnits::ns ) {
136  meanT0 *= nsPerCount;
137  meanTtrig *= nsPerCount;
138  meanMtime *= nsPerCount;
139  }
140  }
141 
142  return searchStatus;
143 
144 }
145 
146 
148  float& meanT0,
149  float& meanTtrig,
150  float& meanMtime,
151  float& meanNoise,
152  float& meanAfterPulse,
153  float& meanResolution,
154  float& meanEfficiency,
155  DTTimeUnits::type unit ) const {
156  return get( id.wheel(),
157  id.station(),
158  id.sector(),
159  id.superLayer(),
160  meanT0,
161  meanTtrig,
162  meanMtime,
163  meanNoise,
164  meanAfterPulse,
165  meanResolution,
166  meanEfficiency,
167  unit );
168 }
169 
170 
171 float DTPerformance::unit() const {
172  return nsPerCount;
173 }
174 
175 
176 const
177 std::string& DTPerformance::version() const {
178  return dataVersion;
179 }
180 
181 
182 std::string& DTPerformance::version() {
183  return dataVersion;
184 }
185 
186 
188 // DTDataBuffer<int,int>::dropBuffer( mapName() );
189  delete dBuf;
190  dBuf = 0;
191  dataList.clear();
192  return;
193 }
194 
195 
196 int DTPerformance::set( int wheelId,
197  int stationId,
198  int sectorId,
199  int slId,
200  float meanT0,
201  float meanTtrig,
202  float meanMtime,
203  float meanNoise,
204  float meanAfterPulse,
205  float meanResolution,
206  float meanEfficiency,
208 
209  if ( unit == DTTimeUnits::ns ) {
210  meanT0 /= nsPerCount;
211  meanTtrig /= nsPerCount;
212  meanMtime /= nsPerCount;
213  }
214 
215 // std::string mName = mapName();
216 // DTBufferTree<int,int>* dBuf =
217 // DTDataBuffer<int,int>::findBuffer( mName );
218 // if ( dBuf == 0 ) {
219 // cacheMap();
220 // dBuf =
221 // DTDataBuffer<int,int>::findBuffer( mName );
222 // }
223  if ( dBuf == 0 ) cacheMap();
224  std::vector<int> chanKey;
225  chanKey.reserve(4);
226  chanKey.push_back( wheelId );
227  chanKey.push_back( stationId );
228  chanKey.push_back( sectorId );
229  chanKey.push_back( slId );
230  int ientry;
231  int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), ientry );
232 
233  if ( !searchStatus ) {
235  data.meanT0 = meanT0;
236  data.meanTtrig = meanTtrig;
237  data.meanMtime = meanMtime;
238  data.meanNoise = meanNoise;
239  data.meanAfterPulse = meanAfterPulse;
240  data.meanResolution = meanResolution;
241  data.meanEfficiency = meanEfficiency;
242  return -1;
243  }
244  else {
246  key. wheelId = wheelId;
247  key.stationId = stationId;
248  key. sectorId = sectorId;
249  key. slId = slId;
251  data.meanT0 = meanT0;
252  data.meanTtrig = meanTtrig;
253  data.meanMtime = meanMtime;
254  data.meanNoise = meanNoise;
255  data.meanAfterPulse = meanAfterPulse;
256  data.meanResolution = meanResolution;
257  data.meanEfficiency = meanEfficiency;
258  ientry = dataList.size();
259  dataList.push_back( std::pair<DTPerformanceId,DTPerformanceData>(
260  key, data ) );
261  dBuf->insert( chanKey.begin(), chanKey.end(), ientry );
262  return 0;
263  }
264 
265  return 99;
266 
267 }
268 
269 
271  float meanT0,
272  float meanTtrig,
273  float meanMtime,
274  float meanNoise,
275  float meanAfterPulse,
276  float meanResolution,
277  float meanEfficiency,
279  return set( id.wheel(),
280  id.station(),
281  id.sector(),
282  id.superLayer(),
283  meanT0,
284  meanTtrig,
285  meanMtime,
286  meanNoise,
287  meanAfterPulse,
288  meanResolution,
289  meanEfficiency,
290  unit );
291 }
292 
293 
295  nsPerCount = unit;
296 }
297 
298 
300  return dataList.begin();
301 }
302 
303 
305  return dataList.end();
306 }
307 
308 
309 std::string DTPerformance::mapName() const {
310  std::stringstream name;
311  name << dataVersion << "_map_Performance" << this;
312  return name.str();
313 }
314 
315 
317 
318 // std::string mName = mapName();
319 // DTBufferTree<int,int>* dBuf =
320 // DTDataBuffer<int,int>::openBuffer( mName );
321  DTBufferTree<int,int>** pBuf;
322  pBuf = const_cast<DTBufferTree<int,int>**>( &dBuf );
323  *pBuf = new DTBufferTree<int,int>;
324 
325  int entryNum = 0;
326  int entryMax = dataList.size();
327  std::vector<int> chanKey;
328  chanKey.reserve(6);
329  while ( entryNum < entryMax ) {
330 
331  const DTPerformanceId& chan = dataList[entryNum].first;
332 
333  chanKey.clear();
334  chanKey.push_back( chan. wheelId );
335  chanKey.push_back( chan.stationId );
336  chanKey.push_back( chan. sectorId );
337  chanKey.push_back( chan. slId );
338  dBuf->insert( chanKey.begin(), chanKey.end(), entryNum++ );
339 
340  }
341 
342  return;
343 
344 }
345 
const std::string & version() const
access version
const_iterator begin() const
std::string mapName() const
int insert(ElementKey fKey, ElementKey lKey, const Content &cont)
void setUnit(float unit)
void clear()
reset content
std::vector< std::pair< DTPerformanceId, DTPerformanceData > > dataList
U second(std::pair< T, U > const &p)
std::vector< std::pair< DTPerformanceId, DTPerformanceData > >::const_iterator const_iterator
Access methods to data.
string unit
Definition: csvLumiCalc.py:46
int set(int wheelId, int stationId, int sectorId, int slId, float meanT0, float meanTtrig, float meanMtime, float meanNoise, float meanAfterPulse, float meanResolution, float meanEfficiency, DTTimeUnits::type unit)
const_iterator end() const
float unit() const
void cacheMap() const
read and store full content
int find(ElementKey fKey, ElementKey lKey, Content &cont)
DTBufferTree< int, int > * dBuf
std::string dataVersion
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
list key
Definition: combine.py:13
int get(int wheelId, int stationId, int sectorId, int slId, float &meanT0, float &meanTtrig, float &meanMtime, float &meanNoise, float &meanAfterPulse, float &meanResolution, float &meanEfficiency, DTTimeUnits::type unit) const