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 // Constructors --
30 //----------------
32  : dataVersion(" "), nsPerCount(25.0 / 32.0), clockLength(32), dBuf(new DTBufferTree<int, int>) {
33  dataList.reserve(250);
34 }
35 
37  : dataVersion(version), nsPerCount(25.0 / 32.0), clockLength(32), dBuf(new DTBufferTree<int, int>) {
38  dataList.reserve(250);
39 }
40 
42  if (this != &rhs) {
44  nsPerCount = rhs.nsPerCount;
46  dataList = rhs.dataList;
47  initialize();
48  }
49  return *this;
50 }
51 
52 DTTPGParametersId::DTTPGParametersId() : wheelId(0), stationId(0), sectorId(0) {}
53 
54 DTTPGParametersData::DTTPGParametersData() : nClock(0), tPhase(0.0) {}
55 
56 //--------------
57 // Destructor --
58 //--------------
60 
62 
64 
65 //--------------
66 // Operations --
67 //--------------
68 int DTTPGParameters::get(int wheelId, int stationId, int sectorId, int& nc, float& ph, DTTimeUnits::type unit) const {
69  nc = 0;
70  ph = 0.0;
71 
72  std::vector<int> chanKey;
73  chanKey.reserve(3);
74  chanKey.push_back(wheelId);
75  chanKey.push_back(stationId);
76  chanKey.push_back(sectorId);
77  int ientry;
78  int searchStatus = dBuf->find(chanKey.begin(), chanKey.end(), ientry);
79  if (!searchStatus) {
80  const DTTPGParametersData& data(dataList[ientry].second);
81  nc = data.nClock;
82  ph = data.tPhase;
83  if (unit == DTTimeUnits::ns) {
84  ph *= nsPerCount;
85  }
86  }
87 
88  return searchStatus;
89 }
90 
91 int DTTPGParameters::get(const DTChamberId& id, int& nc, float& ph, DTTimeUnits::type unit) const {
92  return get(id.wheel(), id.station(), id.sector(), nc, ph, unit);
93 }
94 
95 float DTTPGParameters::totalTime(int wheelId, int stationId, int sectorId, DTTimeUnits::type unit) const {
96  int cl = 0;
97  float ph = 0.0;
98  get(wheelId, stationId, sectorId, cl, ph, unit);
99  if (unit == DTTimeUnits::ns)
100  return (cl * clock() * nsPerCount) + ph;
101  else
102  return (cl * clock()) + ph;
103 }
104 
106  return totalTime(id.wheel(), id.station(), id.sector(), unit);
107 }
108 
109 int DTTPGParameters::clock() const { return clockLength; }
110 
111 float DTTPGParameters::unit() const { return nsPerCount; }
112 
114 
116 
118  dataList.clear();
119  initialize();
120  return;
121 }
122 
123 int DTTPGParameters::set(int wheelId, int stationId, int sectorId, int nc, float ph, DTTimeUnits::type unit) {
124  if (unit == DTTimeUnits::ns) {
125  ph /= nsPerCount;
126  }
127 
128  std::vector<int> chanKey;
129  chanKey.reserve(3);
130  chanKey.push_back(wheelId);
131  chanKey.push_back(stationId);
132  chanKey.push_back(sectorId);
133  int ientry;
134  int searchStatus = dBuf->find(chanKey.begin(), chanKey.end(), ientry);
135 
136  if (!searchStatus) {
138  data.nClock = nc;
139  data.tPhase = ph;
140  return -1;
141  } else {
143  key.wheelId = wheelId;
144  key.stationId = stationId;
145  key.sectorId = sectorId;
147  data.nClock = nc;
148  data.tPhase = ph;
149  ientry = dataList.size();
150  dataList.push_back(std::pair<DTTPGParametersId, DTTPGParametersData>(key, data));
151  dBuf->insert(chanKey.begin(), chanKey.end(), ientry);
152  return 0;
153  }
154 
155  return 99;
156 }
157 
158 int DTTPGParameters::set(const DTChamberId& id, int nc, float ph, DTTimeUnits::type unit) {
159  return set(id.wheel(), id.station(), id.sector(), nc, ph, unit);
160 }
161 
163 
165 
167 
169 
171  std::stringstream name;
172  name << dataVersion << "_map_TTPG" << this;
173  return name.str();
174 }
175 
177  dBuf->clear();
178 
179  int entryNum = 0;
180  int entryMax = dataList.size();
181  std::vector<int> chanKey;
182  chanKey.reserve(3);
183  while (entryNum < entryMax) {
184  const DTTPGParametersId& chan = dataList[entryNum].first;
185 
186  chanKey.clear();
187  chanKey.push_back(chan.wheelId);
188  chanKey.push_back(chan.stationId);
189  chanKey.push_back(chan.sectorId);
190  dBuf->insert(chanKey.begin(), chanKey.end(), entryNum++);
191  }
192 
193  return;
194 }
void clear()
reset content
void setUnit(float unit)
const_iterator end() const
int set(int wheelId, int stationId, int sectorId, int nc, float ph, DTTimeUnits::type unit)
std::vector< std::pair< DTTPGParametersId, DTTPGParametersData > >::const_iterator const_iterator
Access methods to data.
const_iterator begin() const
edm::ConstRespectingPtr< DTBufferTree< int, int > > dBuf
std::string mapName() const
float unit() const
void setClock(int clock)
U second(std::pair< T, U > const &p)
int get(int wheelId, int stationId, int sectorId, int &nc, float &ph, DTTimeUnits::type unit) const
get content
std::vector< std::pair< DTTPGParametersId, DTTPGParametersData > > dataList
float totalTime(int wheelId, int stationId, int sectorId, DTTimeUnits::type unit) const
Basic3DVector unit() const
std::string dataVersion
const std::string & version() const
access version
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi...
DTTPGParameters & operator=(DTTPGParameters const &)
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)