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  //Guarantee const correctness for thread-safety
114  const DTBufferTree<int,int>* constDBuf = dBuf;
115  int searchStatus = constDBuf->find( chanKey.begin(), chanKey.end(), ientry );
116  if ( !searchStatus ) {
117  const DTPerformanceData& data( dataList[ientry].second );
118  meanT0 = data.meanT0;
119  meanTtrig = data.meanTtrig;
120  meanMtime = data.meanMtime;
121  meanNoise = data.meanNoise;
122  meanAfterPulse = data.meanAfterPulse;
123  meanResolution = data.meanResolution;
124  meanEfficiency = data.meanEfficiency;
125  if ( unit == DTTimeUnits::ns ) {
126  meanT0 *= nsPerCount;
127  meanTtrig *= nsPerCount;
128  meanMtime *= nsPerCount;
129  }
130  }
131 
132  return searchStatus;
133 
134 }
135 
136 
138  float& meanT0,
139  float& meanTtrig,
140  float& meanMtime,
141  float& meanNoise,
142  float& meanAfterPulse,
143  float& meanResolution,
144  float& meanEfficiency,
145  DTTimeUnits::type unit ) const {
146  return get( id.wheel(),
147  id.station(),
148  id.sector(),
149  id.superLayer(),
150  meanT0,
151  meanTtrig,
152  meanMtime,
153  meanNoise,
154  meanAfterPulse,
155  meanResolution,
156  meanEfficiency,
157  unit );
158 }
159 
160 
161 float DTPerformance::unit() const {
162  return nsPerCount;
163 }
164 
165 
166 const
168  return dataVersion;
169 }
170 
171 
173  return dataVersion;
174 }
175 
176 
178  dataList.clear();
179  initialize();
180  return;
181 }
182 
183 
184 int DTPerformance::set( int wheelId,
185  int stationId,
186  int sectorId,
187  int slId,
188  float meanT0,
189  float meanTtrig,
190  float meanMtime,
191  float meanNoise,
192  float meanAfterPulse,
193  float meanResolution,
194  float meanEfficiency,
196 
197  if ( unit == DTTimeUnits::ns ) {
198  meanT0 /= nsPerCount;
199  meanTtrig /= nsPerCount;
200  meanMtime /= nsPerCount;
201  }
202 
203  std::vector<int> chanKey;
204  chanKey.reserve(4);
205  chanKey.push_back( wheelId );
206  chanKey.push_back( stationId );
207  chanKey.push_back( sectorId );
208  chanKey.push_back( slId );
209  int ientry;
210  int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), ientry );
211 
212  if ( !searchStatus ) {
214  data.meanT0 = meanT0;
215  data.meanTtrig = meanTtrig;
216  data.meanMtime = meanMtime;
217  data.meanNoise = meanNoise;
218  data.meanAfterPulse = meanAfterPulse;
219  data.meanResolution = meanResolution;
220  data.meanEfficiency = meanEfficiency;
221  return -1;
222  }
223  else {
225  key. wheelId = wheelId;
226  key.stationId = stationId;
227  key. sectorId = sectorId;
228  key. slId = slId;
230  data.meanT0 = meanT0;
231  data.meanTtrig = meanTtrig;
232  data.meanMtime = meanMtime;
233  data.meanNoise = meanNoise;
234  data.meanAfterPulse = meanAfterPulse;
235  data.meanResolution = meanResolution;
236  data.meanEfficiency = meanEfficiency;
237  ientry = dataList.size();
238  dataList.push_back( std::pair<DTPerformanceId,DTPerformanceData>(
239  key, data ) );
240  dBuf->insert( chanKey.begin(), chanKey.end(), ientry );
241  return 0;
242  }
243 
244  return 99;
245 
246 }
247 
248 
250  float meanT0,
251  float meanTtrig,
252  float meanMtime,
253  float meanNoise,
254  float meanAfterPulse,
255  float meanResolution,
256  float meanEfficiency,
258  return set( id.wheel(),
259  id.station(),
260  id.sector(),
261  id.superLayer(),
262  meanT0,
263  meanTtrig,
264  meanMtime,
265  meanNoise,
266  meanAfterPulse,
267  meanResolution,
268  meanEfficiency,
269  unit );
270 }
271 
272 
274  nsPerCount = unit;
275 }
276 
277 
279  return dataList.begin();
280 }
281 
282 
284  return dataList.end();
285 }
286 
287 
289  std::stringstream name;
290  name << dataVersion << "_map_Performance" << this;
291  return name.str();
292 }
293 
294 
296 
297  dBuf->clear();
298 
299  int entryNum = 0;
300  int entryMax = dataList.size();
301  std::vector<int> chanKey;
302  chanKey.reserve(6);
303  while ( entryNum < entryMax ) {
304 
305  const DTPerformanceId& chan = dataList[entryNum].first;
306 
307  chanKey.clear();
308  chanKey.push_back( chan. wheelId );
309  chanKey.push_back( chan.stationId );
310  chanKey.push_back( chan. sectorId );
311  chanKey.push_back( chan. slId );
312  dBuf->insert( chanKey.begin(), chanKey.end(), entryNum++ );
313  }
314  return;
315 }
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
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
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)
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