CMS 3D CMS Logo

DTTPGParameters.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( 25.0 / 32.0 ),
35  clockLength( 32 ),
36  dBuf(new DTBufferTree<int,int>) {
37  dataList.reserve( 250 );
38 }
39 
40 
42  dataVersion( version ),
43  nsPerCount( 25.0 / 32.0 ),
44  clockLength( 32 ),
45  dBuf(new DTBufferTree<int,int>) {
46  dataList.reserve( 250 );
47 }
48 
49 
51  if (this != &rhs) {
53  nsPerCount = rhs.nsPerCount;
55  dataList = rhs.dataList;
56  initialize();
57  }
58  return *this;
59 }
60 
61 
63  wheelId( 0 ),
64  stationId( 0 ),
65  sectorId( 0 ) {
66 }
67 
68 
70  nClock( 0 ),
71  tPhase( 0.0 ) {
72 }
73 
74 
75 //--------------
76 // Destructor --
77 //--------------
79 }
80 
81 
83 }
84 
85 
87 }
88 
89 
90 //--------------
91 // Operations --
92 //--------------
93 int DTTPGParameters::get( int wheelId,
94  int stationId,
95  int sectorId,
96  int& nc,
97  float& ph,
98  DTTimeUnits::type unit ) const {
99 
100  nc = 0;
101  ph = 0.0;
102 
103  std::vector<int> chanKey;
104  chanKey.reserve(3);
105  chanKey.push_back( wheelId );
106  chanKey.push_back( stationId );
107  chanKey.push_back( sectorId );
108  int ientry;
109  int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), ientry );
110  if ( !searchStatus ) {
111  const DTTPGParametersData& data( dataList[ientry].second );
112  nc = data.nClock;
113  ph = data.tPhase;
114  if ( unit == DTTimeUnits::ns ) {
115  ph *= nsPerCount;
116  }
117  }
118 
119  return searchStatus;
120 
121 }
122 
123 
125  int& nc,
126  float& ph,
127  DTTimeUnits::type unit ) const {
128  return get( id.wheel(),
129  id.station(),
130  id.sector(),
131  nc, ph, unit );
132 }
133 
134 
135 float DTTPGParameters::totalTime( int wheelId,
136  int stationId,
137  int sectorId,
138  DTTimeUnits::type unit ) const {
139  int cl = 0;
140  float ph = 0.0;
141  get( wheelId, stationId, sectorId, cl, ph, unit );
142  if ( unit == DTTimeUnits::ns ) return ( cl * clock() * nsPerCount ) + ph;
143  else return ( cl * clock() ) + ph;
144 }
145 
146 
148  DTTimeUnits::type unit ) const {
149  return totalTime( id.wheel(),
150  id.station(),
151  id.sector(),
152  unit );
153 }
154 
155 
157  return clockLength;
158 }
159 
160 
161 float DTTPGParameters::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 DTTPGParameters::set( int wheelId,
185  int stationId,
186  int sectorId,
187  int nc,
188  float ph,
190 
191  if ( unit == DTTimeUnits::ns ) {
192  ph /= nsPerCount;
193  }
194 
195  std::vector<int> chanKey;
196  chanKey.reserve(3);
197  chanKey.push_back( wheelId );
198  chanKey.push_back( stationId );
199  chanKey.push_back( sectorId );
200  int ientry;
201  int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), ientry );
202 
203  if ( !searchStatus ) {
204  DTTPGParametersData& data( dataList[ientry].second );
205  data.nClock = nc;
206  data.tPhase = ph;
207  return -1;
208  }
209  else {
211  key. wheelId = wheelId;
212  key.stationId = stationId;
213  key. sectorId = sectorId;
215  data.nClock = nc;
216  data.tPhase = ph;
217  ientry = dataList.size();
218  dataList.push_back( std::pair<DTTPGParametersId,
219  DTTPGParametersData>( key, data ) );
220  dBuf->insert( chanKey.begin(), chanKey.end(), ientry );
221  return 0;
222  }
223 
224  return 99;
225 
226 }
227 
228 
230  int nc,
231  float ph,
233  return set( id.wheel(),
234  id.station(),
235  id.sector(),
236  nc, ph, unit );
237 }
238 
239 
240 void DTTPGParameters::setClock( int clock ) {
241  clockLength = clock;
242 }
243 
244 
246  nsPerCount = unit;
247 }
248 
249 
251  return dataList.begin();
252 }
253 
254 
256  return dataList.end();
257 }
258 
259 
261  std::stringstream name;
262  name << dataVersion << "_map_TTPG" << this;
263  return name.str();
264 }
265 
266 
268 
269  dBuf->clear();
270 
271  int entryNum = 0;
272  int entryMax = dataList.size();
273  std::vector<int> chanKey;
274  chanKey.reserve(3);
275  while ( entryNum < entryMax ) {
276 
277  const DTTPGParametersId& chan = dataList[entryNum].first;
278 
279  chanKey.clear();
280  chanKey.push_back( chan. wheelId );
281  chanKey.push_back( chan.stationId );
282  chanKey.push_back( chan. sectorId );
283  dBuf->insert( chanKey.begin(), chanKey.end(), entryNum++ );
284 
285  }
286 
287  return;
288 
289 }
290 
std::vector< std::pair< DTTPGParametersId, DTTPGParametersData > >::const_iterator const_iterator
Access methods to data.
void clear()
reset content
static AlgebraicMatrix initialize()
void setUnit(float unit)
edm::ConstRespectingPtr< DTBufferTree< int, int > > dBuf
int clock() const
const std::string & version() const
access version
const_iterator begin() const
int set(int wheelId, int stationId, int sectorId, int nc, float ph, DTTimeUnits::type unit)
void setClock(int clock)
U second(std::pair< T, U > const &p)
const_iterator end() const
float totalTime(int wheelId, int stationId, int sectorId, DTTimeUnits::type unit) const
std::string dataVersion
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi...
DTTPGParameters & operator=(DTTPGParameters const &)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
std::string mapName() const
float unit() const
std::vector< std::pair< DTTPGParametersId, DTTPGParametersData > > dataList
int get(int wheelId, int stationId, int sectorId, int &nc, float &ph, DTTimeUnits::type unit) const
get content