CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DTMtime.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 DTMtime::DTMtime() : dataVersion(" "), nsPerCount(25.0 / 32.0), dBuf(new DTBufferTree<int, int>) {
32  dataList.reserve(1000);
33 }
34 
36  : dataVersion(version), nsPerCount(25.0 / 32.0), dBuf(new DTBufferTree<int, int>) {
37  dataList.reserve(1000);
38 }
39 
40 DTMtimeId::DTMtimeId() : wheelId(0), stationId(0), sectorId(0), slId(0), layerId(0), cellId(0) {}
41 
42 DTMtimeData::DTMtimeData() : mTime(0.0), mTrms(0.0) {}
43 
44 //--------------
45 // Destructor --
46 //--------------
48 
50 
52 
53 //--------------
54 // Operations --
55 //--------------
57  int wheelId, int stationId, int sectorId, int slId, float& mTime, float& mTrms, DTTimeUnits::type unit) const {
58  return get(wheelId, stationId, sectorId, slId, 0, 0, mTime, mTrms, unit);
59 }
60 
62  int wheelId, int stationId, int sectorId, int slId, float& mTime, float& mTrms, DTVelocityUnits::type unit) const {
63  return get(wheelId, stationId, sectorId, slId, 0, 0, mTime, mTrms, unit);
64 }
65 
66 int DTMtime::get(int wheelId,
67  int stationId,
68  int sectorId,
69  int slId,
70  int layerId,
71  int cellId,
72  float& mTime,
73  float& mTrms,
74  DTTimeUnits::type unit) const {
75  mTime = mTrms = 0.0;
76 
77  std::vector<int> chanKey;
78  chanKey.reserve(6);
79  chanKey.push_back(wheelId);
80  chanKey.push_back(stationId);
81  chanKey.push_back(sectorId);
82  chanKey.push_back(slId);
83  chanKey.push_back(layerId);
84  chanKey.push_back(cellId);
85  int ientry;
86  int searchStatus = dBuf->find(chanKey.begin(), chanKey.end(), ientry);
87  if (!searchStatus) {
88  const DTMtimeData& data(dataList[ientry].second);
89  mTime = data.mTime;
90  mTrms = data.mTrms;
91  if (unit == DTTimeUnits::ns) {
92  mTime *= nsPerCount;
93  mTrms *= nsPerCount;
94  }
95  }
96 
97  return searchStatus;
98 }
99 
100 int DTMtime::get(int wheelId,
101  int stationId,
102  int sectorId,
103  int slId,
104  int layerId,
105  int cellId,
106  float& mTime,
107  float& mTrms,
108  DTVelocityUnits::type unit) const {
109  int status = get(wheelId, stationId, sectorId, slId, layerId, cellId, mTime, mTrms, DTTimeUnits::counts);
110  if (unit == DTVelocityUnits::cm_per_count) {
111  mTime = 2.1 / mTime;
112  mTrms *= mTime;
113  }
114  if (unit == DTVelocityUnits::cm_per_ns) {
115  mTime = 2.1 / mTime;
116  mTrms *= mTime;
117  mTime /= nsPerCount;
118  }
119  return status;
120 }
121 
122 int DTMtime::get(const DTSuperLayerId& id, float& mTime, float& mTrms, DTTimeUnits::type unit) const {
123  return get(id.wheel(), id.station(), id.sector(), id.superLayer(), 0, 0, mTime, mTrms, unit);
124 }
125 
126 int DTMtime::get(const DTSuperLayerId& id, float& mTime, float& mTrms, DTVelocityUnits::type unit) const {
127  return get(id.wheel(), id.station(), id.sector(), id.superLayer(), 0, 0, mTime, mTrms, unit);
128 }
129 
130 int DTMtime::get(const DetId& id, float& mTime, float& mTrms, DTTimeUnits::type unit) const {
131  DTWireId wireId(id.rawId());
132  return get(wireId.wheel(),
133  wireId.station(),
134  wireId.sector(),
135  wireId.superLayer(),
136  wireId.layer(),
137  wireId.wire(),
138  mTime,
139  mTrms,
140  unit);
141 }
142 
143 int DTMtime::get(const DetId& id, float& mTime, float& mTrms, DTVelocityUnits::type unit) const {
144  DTWireId wireId(id.rawId());
145  return get(wireId.wheel(),
146  wireId.station(),
147  wireId.sector(),
148  wireId.superLayer(),
149  wireId.layer(),
150  wireId.wire(),
151  mTime,
152  mTrms,
153  unit);
154 }
155 
156 float DTMtime::unit() const { return nsPerCount; }
157 
158 const std::string& DTMtime::version() const { return dataVersion; }
159 
161 
163  dataList.clear();
164  initialize();
165  return;
166 }
167 
168 int DTMtime::set(int wheelId, int stationId, int sectorId, int slId, float mTime, float mTrms, DTTimeUnits::type unit) {
169  return set(wheelId, stationId, sectorId, slId, 0, 0, mTime, mTrms, unit);
170 }
171 
173  int wheelId, int stationId, int sectorId, int slId, float mTime, float mTrms, DTVelocityUnits::type unit) {
174  return set(wheelId, stationId, sectorId, slId, 0, 0, mTime, mTrms, unit);
175 }
176 
177 int DTMtime::set(int wheelId,
178  int stationId,
179  int sectorId,
180  int slId,
181  int layerId,
182  int cellId,
183  float mTime,
184  float mTrms,
186  if (unit == DTTimeUnits::ns) {
187  mTime /= nsPerCount;
188  mTrms /= nsPerCount;
189  }
190 
191  std::vector<int> chanKey;
192  chanKey.reserve(6);
193  chanKey.push_back(wheelId);
194  chanKey.push_back(stationId);
195  chanKey.push_back(sectorId);
196  chanKey.push_back(slId);
197  chanKey.push_back(layerId);
198  chanKey.push_back(cellId);
199  int ientry;
200  int searchStatus = dBuf->find(chanKey.begin(), chanKey.end(), ientry);
201 
202  if (!searchStatus) {
203  DTMtimeData& data(dataList[ientry].second);
204  data.mTime = mTime;
205  data.mTrms = mTrms;
206  return -1;
207  } else {
208  DTMtimeId key;
209  key.wheelId = wheelId;
210  key.stationId = stationId;
211  key.sectorId = sectorId;
212  key.slId = slId;
213  key.layerId = layerId;
214  key.cellId = cellId;
216  data.mTime = mTime;
217  data.mTrms = mTrms;
218  ientry = dataList.size();
219  dataList.push_back(std::pair<DTMtimeId, DTMtimeData>(key, data));
220  dBuf->insert(chanKey.begin(), chanKey.end(), ientry);
221  return 0;
222  }
223 
224  return 99;
225 }
226 
227 int DTMtime::set(int wheelId,
228  int stationId,
229  int sectorId,
230  int slId,
231  int layerId,
232  int cellId,
233  float mTime,
234  float mTrms,
236  if (unit == DTVelocityUnits::cm_per_count) {
237  mTrms /= mTime;
238  mTime = 2.1 / mTime;
239  }
240  if (unit == DTVelocityUnits::cm_per_ns) {
241  mTime *= nsPerCount;
242  mTrms /= mTime;
243  mTime = 2.1 / mTime;
244  }
245  return set(wheelId, stationId, sectorId, slId, layerId, cellId, mTime, mTrms, DTTimeUnits::counts);
246 }
247 
248 int DTMtime::set(const DTSuperLayerId& id, float mTime, float mTrms, DTTimeUnits::type unit) {
249  return set(id.wheel(), id.station(), id.sector(), id.superLayer(), 0, 0, mTime, mTrms, unit);
250 }
251 
252 int DTMtime::set(const DTSuperLayerId& id, float mTime, float mTrms, DTVelocityUnits::type unit) {
253  return set(id.wheel(), id.station(), id.sector(), id.superLayer(), 0, 0, mTime, mTrms, unit);
254 }
255 
256 int DTMtime::set(const DetId& id, float mTime, float mTrms, DTTimeUnits::type unit) {
257  DTWireId wireId(id.rawId());
258  return set(wireId.wheel(),
259  wireId.station(),
260  wireId.sector(),
261  wireId.superLayer(),
262  wireId.layer(),
263  wireId.wire(),
264  mTime,
265  mTrms,
266  unit);
267 }
268 
269 int DTMtime::set(const DetId& id, float mTime, float mTrms, DTVelocityUnits::type unit) {
270  DTWireId wireId(id.rawId());
271  return set(wireId.wheel(),
272  wireId.station(),
273  wireId.sector(),
274  wireId.superLayer(),
275  wireId.layer(),
276  wireId.wire(),
277  mTime,
278  mTrms,
279  unit);
280 }
281 
283 
285 
287 
289  std::stringstream name;
290  name << dataVersion << "_map_Mtime" << this;
291  return name.str();
292 }
293 
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  const DTMtimeId& chan = dataList[entryNum].first;
303 
304  chanKey.clear();
305  chanKey.push_back(chan.wheelId);
306  chanKey.push_back(chan.stationId);
307  chanKey.push_back(chan.sectorId);
308  chanKey.push_back(chan.slId);
309  chanKey.push_back(chan.layerId);
310  chanKey.push_back(chan.cellId);
311  dBuf->insert(chanKey.begin(), chanKey.end(), entryNum++);
312  }
313 
314  return;
315 }
int stationId
Definition: DTMtime.h:48
float nsPerCount
Definition: DTMtime.h:194
~DTMtimeData()
Definition: DTMtime.cc:51
int set(int wheelId, int stationId, int sectorId, int slId, float mTime, float mTrms, DTTimeUnits::type unit)
Definition: DTMtime.cc:168
tuple chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, &quot;NDC&quot;) lumi.SetBorderSize( 0 ) lumi...
list status
Definition: mps_update.py:107
int wheelId
Definition: DTMtime.h:47
int layer() const
Return the layer number.
Definition: DTLayerId.h:42
void setUnit(float unit)
Definition: DTMtime.cc:282
int find(ElementKey fKey, ElementKey lKey, typename DTBufferTreeTrait< Content >::outputTypeOfConstFind &cont) const
U second(std::pair< T, U > const &p)
int cellId
Definition: DTMtime.h:52
void initialize()
Definition: DTMtime.cc:294
DTMtimeData()
Definition: DTMtime.cc:42
tuple key
prepare the HTCondor submission files and eventually submit them
int superLayer() const
Return the superlayer number.
float mTrms
Definition: DTMtime.h:63
int wire() const
Return the wire number.
Definition: DTWireId.h:42
Definition: DetId.h:17
const_iterator begin() const
Definition: DTMtime.cc:284
std::string mapName() const
read and store full content
Definition: DTMtime.cc:288
std::vector< std::pair< DTMtimeId, DTMtimeData > >::const_iterator const_iterator
Access methods to data.
Definition: DTMtime.h:186
DTMtime()
Definition: DTMtime.cc:31
int sectorId
Definition: DTMtime.h:49
int slId
Definition: DTMtime.h:50
float unit() const
Definition: DTMtime.cc:156
const std::string & version() const
access version
Definition: DTMtime.cc:158
edm::ConstRespectingPtr< DTBufferTree< int, int > > dBuf
Definition: DTMtime.h:198
int get(int wheelId, int stationId, int sectorId, int slId, float &mTime, float &mTrms, DTTimeUnits::type unit) const
Definition: DTMtime.cc:56
~DTMtime()
Definition: DTMtime.cc:47
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
int insert(ElementKey fKey, ElementKey lKey, Content cont)
float mTime
Definition: DTMtime.h:62
DTMtimeId()
Definition: DTMtime.cc:40
int sector() const
Definition: DTChamberId.h:49
const_iterator end() const
Definition: DTMtime.cc:286
int layerId
Definition: DTMtime.h:51
~DTMtimeId()
Definition: DTMtime.cc:49
std::string dataVersion
Definition: DTMtime.h:193
void clear()
reset content
Definition: DTMtime.cc:162
int station() const
Return the station number.
Definition: DTChamberId.h:42
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
std::vector< std::pair< DTMtimeId, DTMtimeData > > dataList
Definition: DTMtime.h:196
Basic3DVector unit() const