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  * \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(0.0),
35  dBuf(new DTBufferTree<int,int>) {
36  dataList.reserve( 1000 );
37 }
38 
39 
41  dataVersion( version ),
42  nsPerCount(0.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 }
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 }
72 
73 
75 }
76 
77 
79 }
80 
81 
82 //--------------
83 // Operations --
84 //--------------
85 int DTPerformance::get( int wheelId,
86  int stationId,
87  int sectorId,
88  int slId,
89  float& meanT0,
90  float& meanTtrig,
91  float& meanMtime,
92  float& meanNoise,
93  float& meanAfterPulse,
94  float& meanResolution,
95  float& meanEfficiency,
96  DTTimeUnits::type unit ) const {
97 
98  meanT0 =
99  meanTtrig =
100  meanMtime =
101  meanNoise =
102  meanAfterPulse =
103  meanResolution =
104  meanEfficiency = 0.0;
105 
106  std::vector<int> chanKey;
107  chanKey.reserve(4);
108  chanKey.push_back( wheelId );
109  chanKey.push_back( stationId );
110  chanKey.push_back( sectorId );
111  chanKey.push_back( slId );
112  int ientry;
113  int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), ientry );
114  if ( !searchStatus ) {
115  const DTPerformanceData& data( dataList[ientry].second );
116  meanT0 = data.meanT0;
117  meanTtrig = data.meanTtrig;
118  meanMtime = data.meanMtime;
119  meanNoise = data.meanNoise;
120  meanAfterPulse = data.meanAfterPulse;
121  meanResolution = data.meanResolution;
122  meanEfficiency = data.meanEfficiency;
123  if ( unit == DTTimeUnits::ns ) {
124  meanT0 *= nsPerCount;
125  meanTtrig *= nsPerCount;
126  meanMtime *= nsPerCount;
127  }
128  }
129 
130  return searchStatus;
131 
132 }
133 
134 
136  float& meanT0,
137  float& meanTtrig,
138  float& meanMtime,
139  float& meanNoise,
140  float& meanAfterPulse,
141  float& meanResolution,
142  float& meanEfficiency,
143  DTTimeUnits::type unit ) const {
144  return get( id.wheel(),
145  id.station(),
146  id.sector(),
147  id.superLayer(),
148  meanT0,
149  meanTtrig,
150  meanMtime,
151  meanNoise,
152  meanAfterPulse,
153  meanResolution,
154  meanEfficiency,
155  unit );
156 }
157 
158 
159 float DTPerformance::unit() const {
160  return nsPerCount;
161 }
162 
163 
164 const
166  return dataVersion;
167 }
168 
169 
171  return dataVersion;
172 }
173 
174 
176  dataList.clear();
177  initialize();
178  return;
179 }
180 
181 
182 int DTPerformance::set( int wheelId,
183  int stationId,
184  int sectorId,
185  int slId,
186  float meanT0,
187  float meanTtrig,
188  float meanMtime,
189  float meanNoise,
190  float meanAfterPulse,
191  float meanResolution,
192  float meanEfficiency,
194 
195  if ( unit == DTTimeUnits::ns ) {
196  meanT0 /= nsPerCount;
197  meanTtrig /= nsPerCount;
198  meanMtime /= nsPerCount;
199  }
200 
201  std::vector<int> chanKey;
202  chanKey.reserve(4);
203  chanKey.push_back( wheelId );
204  chanKey.push_back( stationId );
205  chanKey.push_back( sectorId );
206  chanKey.push_back( slId );
207  int ientry;
208  int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), ientry );
209 
210  if ( !searchStatus ) {
212  data.meanT0 = meanT0;
213  data.meanTtrig = meanTtrig;
214  data.meanMtime = meanMtime;
215  data.meanNoise = meanNoise;
216  data.meanAfterPulse = meanAfterPulse;
217  data.meanResolution = meanResolution;
218  data.meanEfficiency = meanEfficiency;
219  return -1;
220  }
221  else {
223  key. wheelId = wheelId;
224  key.stationId = stationId;
225  key. sectorId = sectorId;
226  key. slId = slId;
228  data.meanT0 = meanT0;
229  data.meanTtrig = meanTtrig;
230  data.meanMtime = meanMtime;
231  data.meanNoise = meanNoise;
232  data.meanAfterPulse = meanAfterPulse;
233  data.meanResolution = meanResolution;
234  data.meanEfficiency = meanEfficiency;
235  ientry = dataList.size();
236  dataList.push_back( std::pair<DTPerformanceId,DTPerformanceData>(
237  key, data ) );
238  dBuf->insert( chanKey.begin(), chanKey.end(), ientry );
239  return 0;
240  }
241 
242  return 99;
243 
244 }
245 
246 
248  float meanT0,
249  float meanTtrig,
250  float meanMtime,
251  float meanNoise,
252  float meanAfterPulse,
253  float meanResolution,
254  float meanEfficiency,
256  return set( id.wheel(),
257  id.station(),
258  id.sector(),
259  id.superLayer(),
260  meanT0,
261  meanTtrig,
262  meanMtime,
263  meanNoise,
264  meanAfterPulse,
265  meanResolution,
266  meanEfficiency,
267  unit );
268 }
269 
270 
272  nsPerCount = unit;
273 }
274 
275 
277  return dataList.begin();
278 }
279 
280 
282  return dataList.end();
283 }
284 
285 
287  std::stringstream name;
288  name << dataVersion << "_map_Performance" << this;
289  return name.str();
290 }
291 
292 
294 
295  dBuf->clear();
296 
297  int entryNum = 0;
298  int entryMax = dataList.size();
299  std::vector<int> chanKey;
300  chanKey.reserve(6);
301  while ( entryNum < entryMax ) {
302 
303  const DTPerformanceId& chan = dataList[entryNum].first;
304 
305  chanKey.clear();
306  chanKey.push_back( chan. wheelId );
307  chanKey.push_back( chan.stationId );
308  chanKey.push_back( chan. sectorId );
309  chanKey.push_back( chan. slId );
310  dBuf->insert( chanKey.begin(), chanKey.end(), entryNum++ );
311  }
312  return;
313 }
const std::string & version() const
access version
const_iterator begin() const
std::string mapName() const
read and store full content
void setUnit(float unit)
void clear()
reset content
std::vector< std::pair< DTPerformanceId, DTPerformanceData > > dataList
int find(ElementKey fKey, ElementKey lKey, typename DTBufferTreeTrait< Content >::outputTypeOfConstFind &cont) const
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
DTBufferTree< int, int > * dBuf
std::string dataVersion
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
int insert(ElementKey fKey, ElementKey lKey, Content cont)
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