CMS 3D CMS Logo

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 // Constructors --
30 //----------------
31 DTPerformance::DTPerformance() : dataVersion(" "), nsPerCount(0.0), dBuf(new DTBufferTree<int, int>) {
32  dataList.reserve(1000);
33 }
34 
36  : dataVersion(version), nsPerCount(0.0), dBuf(new DTBufferTree<int, int>) {
37  dataList.reserve(1000);
38 }
39 
40 DTPerformanceId::DTPerformanceId() : wheelId(0), stationId(0), sectorId(0), slId(0) {}
41 
43  : meanT0(0.0),
44  meanTtrig(0.0),
45  meanMtime(0.0),
46  meanNoise(0.0),
47  meanAfterPulse(0.0),
48  meanResolution(0.0),
49  meanEfficiency(0.0) {}
50 
51 //--------------
52 // Destructor --
53 //--------------
55 
57 
59 
60 //--------------
61 // Operations --
62 //--------------
63 int DTPerformance::get(int wheelId,
64  int stationId,
65  int sectorId,
66  int slId,
67  float& meanT0,
68  float& meanTtrig,
69  float& meanMtime,
70  float& meanNoise,
71  float& meanAfterPulse,
72  float& meanResolution,
73  float& meanEfficiency,
74  DTTimeUnits::type unit) const {
75  meanT0 = meanTtrig = meanMtime = meanNoise = meanAfterPulse = meanResolution = meanEfficiency = 0.0;
76 
77  std::vector<int> chanKey;
78  chanKey.reserve(4);
79  chanKey.push_back(wheelId);
80  chanKey.push_back(stationId);
81  chanKey.push_back(sectorId);
82  chanKey.push_back(slId);
83  int ientry;
84  //Guarantee const correctness for thread-safety
85  const DTBufferTree<int, int>* constDBuf = dBuf;
86  int searchStatus = constDBuf->find(chanKey.begin(), chanKey.end(), ientry);
87  if (!searchStatus) {
88  const DTPerformanceData& data(dataList[ientry].second);
89  meanT0 = data.meanT0;
90  meanTtrig = data.meanTtrig;
91  meanMtime = data.meanMtime;
92  meanNoise = data.meanNoise;
93  meanAfterPulse = data.meanAfterPulse;
94  meanResolution = data.meanResolution;
95  meanEfficiency = data.meanEfficiency;
96  if (unit == DTTimeUnits::ns) {
97  meanT0 *= nsPerCount;
98  meanTtrig *= nsPerCount;
99  meanMtime *= nsPerCount;
100  }
101  }
102 
103  return searchStatus;
104 }
105 
107  float& meanT0,
108  float& meanTtrig,
109  float& meanMtime,
110  float& meanNoise,
111  float& meanAfterPulse,
112  float& meanResolution,
113  float& meanEfficiency,
114  DTTimeUnits::type unit) const {
115  return get(id.wheel(),
116  id.station(),
117  id.sector(),
118  id.superLayer(),
119  meanT0,
120  meanTtrig,
121  meanMtime,
122  meanNoise,
123  meanAfterPulse,
124  meanResolution,
125  meanEfficiency,
126  unit);
127 }
128 
129 float DTPerformance::unit() const { return nsPerCount; }
130 
132 
134 
136  dataList.clear();
137  initialize();
138  return;
139 }
140 
141 int DTPerformance::set(int wheelId,
142  int stationId,
143  int sectorId,
144  int slId,
145  float meanT0,
146  float meanTtrig,
147  float meanMtime,
148  float meanNoise,
149  float meanAfterPulse,
150  float meanResolution,
151  float meanEfficiency,
153  if (unit == DTTimeUnits::ns) {
154  meanT0 /= nsPerCount;
155  meanTtrig /= nsPerCount;
156  meanMtime /= nsPerCount;
157  }
158 
159  std::vector<int> chanKey;
160  chanKey.reserve(4);
161  chanKey.push_back(wheelId);
162  chanKey.push_back(stationId);
163  chanKey.push_back(sectorId);
164  chanKey.push_back(slId);
165  int ientry;
166  int searchStatus = dBuf->find(chanKey.begin(), chanKey.end(), ientry);
167 
168  if (!searchStatus) {
170  data.meanT0 = meanT0;
171  data.meanTtrig = meanTtrig;
172  data.meanMtime = meanMtime;
173  data.meanNoise = meanNoise;
174  data.meanAfterPulse = meanAfterPulse;
175  data.meanResolution = meanResolution;
176  data.meanEfficiency = meanEfficiency;
177  return -1;
178  } else {
180  key.wheelId = wheelId;
181  key.stationId = stationId;
182  key.sectorId = sectorId;
183  key.slId = slId;
185  data.meanT0 = meanT0;
186  data.meanTtrig = meanTtrig;
187  data.meanMtime = meanMtime;
188  data.meanNoise = meanNoise;
189  data.meanAfterPulse = meanAfterPulse;
190  data.meanResolution = meanResolution;
191  data.meanEfficiency = meanEfficiency;
192  ientry = dataList.size();
193  dataList.push_back(std::pair<DTPerformanceId, DTPerformanceData>(key, data));
194  dBuf->insert(chanKey.begin(), chanKey.end(), ientry);
195  return 0;
196  }
197 
198  return 99;
199 }
200 
202  float meanT0,
203  float meanTtrig,
204  float meanMtime,
205  float meanNoise,
206  float meanAfterPulse,
207  float meanResolution,
208  float meanEfficiency,
210  return set(id.wheel(),
211  id.station(),
212  id.sector(),
213  id.superLayer(),
214  meanT0,
215  meanTtrig,
216  meanMtime,
217  meanNoise,
218  meanAfterPulse,
219  meanResolution,
220  meanEfficiency,
221  unit);
222 }
223 
225 
227 
229 
231  std::stringstream name;
232  name << dataVersion << "_map_Performance" << this;
233  return name.str();
234 }
235 
237  dBuf->clear();
238 
239  int entryNum = 0;
240  int entryMax = dataList.size();
241  std::vector<int> chanKey;
242  chanKey.reserve(6);
243  while (entryNum < entryMax) {
244  const DTPerformanceId& chan = dataList[entryNum].first;
245 
246  chanKey.clear();
247  chanKey.push_back(chan.wheelId);
248  chanKey.push_back(chan.stationId);
249  chanKey.push_back(chan.sectorId);
250  chanKey.push_back(chan.slId);
251  dBuf->insert(chanKey.begin(), chanKey.end(), entryNum++);
252  }
253  return;
254 }
const std::string & version() const
access version
void setUnit(float unit)
void clear()
reset content
const_iterator end() const
U second(std::pair< T, U > const &p)
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
Basic3DVector unit() const
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)
std::string dataVersion
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi...
int find(ElementKey fKey, ElementKey lKey, typename DTBufferTreeTrait< Content >::outputTypeOfConstFind &cont) const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
int insert(ElementKey fKey, ElementKey lKey, Content cont)
DTBufferTree< int, int > * dBuf
const_iterator begin() const
std::string mapName() const
read and store full content
std::vector< std::pair< DTPerformanceId, DTPerformanceData > >::const_iterator const_iterator
Access methods to data.
std::vector< std::pair< DTPerformanceId, DTPerformanceData > > dataList
float unit() const