CMS 3D CMS Logo

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);
111  mTime = 2.1 / mTime;
112  mTrms *= mTime;
113  }
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,
237  mTrms /= mTime;
238  mTime = 2.1 / mTime;
239  }
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 }
DTSuperLayerId
Definition: DTSuperLayerId.h:12
DTWireId::wire
int wire() const
Return the wire number.
Definition: DTWireId.h:42
DTMtimeData::~DTMtimeData
~DTMtimeData()
Definition: DTMtime.cc:51
DTMtime::mapName
std::string mapName() const
read and store full content
Definition: DTMtime.cc:288
DTMtime.h
DTMtime::~DTMtime
~DTMtime()
Definition: DTMtime.cc:47
mps_update.status
status
Definition: mps_update.py:69
DTMtime::initialize
void initialize()
Definition: DTMtime.cc:294
relativeConstraints.station
station
Definition: relativeConstraints.py:67
DTBufferTree::clear
void clear()
DTMtime::DTMtime
DTMtime()
Definition: DTMtime.cc:31
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:215
DTSuperLayerId::superLayer
int superLayer() const
Return the superlayer number.
Definition: DTSuperLayerId.h:39
DTMtime::set
int set(int wheelId, int stationId, int sectorId, int slId, float mTime, float mTrms, DTTimeUnits::type unit)
Definition: DTMtime.cc:168
DTVelocityUnits::type
type
Definition: DTVelocityUnits.h:32
DTMtime::end
const_iterator end() const
Definition: DTMtime.cc:286
DetId
Definition: DetId.h:17
DTMtimeId::DTMtimeId
DTMtimeId()
Definition: DTMtime.cc:40
DTBufferTree::insert
int insert(ElementKey fKey, ElementKey lKey, Content cont)
DTMtime::clear
void clear()
reset content
Definition: DTMtime.cc:162
DTWireId
Definition: DTWireId.h:12
DTMtimeData
Definition: DTMtime.h:57
DTTimeUnits::ns
Definition: DTTimeUnits.h:32
DTMtime::setUnit
void setUnit(float unit)
Definition: DTMtime.cc:282
DTMtime::dataList
std::vector< std::pair< DTMtimeId, DTMtimeData > > dataList
Definition: DTMtime.h:197
DTTimeUnits::type
type
Definition: DTTimeUnits.h:32
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DTBufferTree.h
DTMtime::nsPerCount
float nsPerCount
Definition: DTMtime.h:195
DTMtimeData::DTMtimeData
DTMtimeData()
Definition: DTMtime.cc:42
DTVelocityUnits::cm_per_ns
Definition: DTVelocityUnits.h:32
makeMuonMisalignmentScenario.wheel
wheel
Definition: makeMuonMisalignmentScenario.py:319
createfilelist.int
int
Definition: createfilelist.py:10
DTMtime::version
const std::string & version() const
access version
Definition: DTMtime.cc:158
DTBufferTree
Definition: DTBufferTree.h:42
DTMtime::begin
const_iterator begin() const
Definition: DTMtime.cc:284
DTVelocityUnits::cm_per_count
Definition: DTVelocityUnits.h:32
unit
Basic3DVector unit() const
Definition: Basic3DVectorLD.h:162
DTMtime::dataVersion
std::string dataVersion
Definition: DTMtime.h:194
DTChamberId::sector
int sector() const
Definition: DTChamberId.h:49
DTTimeUnits::counts
Definition: DTTimeUnits.h:32
officialStyle.chan
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi....
Definition: officialStyle.py:106
DTMtimeId::~DTMtimeId
~DTMtimeId()
Definition: DTMtime.cc:49
DTMtime::const_iterator
std::vector< std::pair< DTMtimeId, DTMtimeData > >::const_iterator const_iterator
Access methods to data.
Definition: DTMtime.h:184
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
DTMtime::unit
float unit() const
Definition: DTMtime.cc:156
DTMtimeId
Definition: DTMtime.h:42
DTMtime::dBuf
edm::ConstRespectingPtr< DTBufferTree< int, int > > dBuf
Definition: DTMtime.h:199
DTBufferTree::find
int find(ElementKey fKey, ElementKey lKey, typename DTBufferTreeTrait< Content >::outputTypeOfConstFind &cont) const
DTLayerId::layer
int layer() const
Return the layer number.
Definition: DTLayerId.h:42
crabWrapper.key
key
Definition: crabWrapper.py:19
BeamSplash_cfg.version
version
Definition: BeamSplash_cfg.py:45
DTMtime::get
int get(int wheelId, int stationId, int sectorId, int slId, float &mTime, float &mTrms, DTTimeUnits::type unit) const
Definition: DTMtime.cc:56
DTChamberId::wheel
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
DTChamberId::station
int station() const
Return the station number.
Definition: DTChamberId.h:42