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 }
DTTPGParameters::set
int set(int wheelId, int stationId, int sectorId, int nc, float ph, DTTimeUnits::type unit)
Definition: DTTPGParameters.cc:123
DTTPGParameters::initialize
void initialize()
Definition: DTTPGParameters.cc:176
DTTPGParametersData::~DTTPGParametersData
~DTTPGParametersData()
Definition: DTTPGParameters.cc:63
DTTPGParameters::clock
int clock() const
Definition: DTTPGParameters.cc:109
relativeConstraints.station
station
Definition: relativeConstraints.py:67
DTTPGParameters::setClock
void setClock(int clock)
Definition: DTTPGParameters.cc:162
DTBufferTree::clear
void clear()
DTTPGParametersId::DTTPGParametersId
DTTPGParametersId()
Definition: DTTPGParameters.cc:52
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
DTTPGParameters::get
int get(int wheelId, int stationId, int sectorId, int &nc, float &ph, DTTimeUnits::type unit) const
get content
Definition: DTTPGParameters.cc:68
GetRecoTauVFromDQM_MC_cff.cl
cl
Definition: GetRecoTauVFromDQM_MC_cff.py:38
DTTPGParameters::mapName
std::string mapName() const
Definition: DTTPGParameters.cc:170
DTTPGParametersData
Definition: DTTPGParameters.h:51
DTBufferTree::insert
int insert(ElementKey fKey, ElementKey lKey, Content cont)
DTTimeUnits::ns
Definition: DTTimeUnits.h:32
DTTPGParameters::const_iterator
std::vector< std::pair< DTTPGParametersId, DTTPGParametersData > >::const_iterator const_iterator
Access methods to data.
Definition: DTTPGParameters.h:96
DTTPGParametersData::DTTPGParametersData
DTTPGParametersData()
Definition: DTTPGParameters.cc:54
DTTPGParametersId::~DTTPGParametersId
~DTTPGParametersId()
Definition: DTTPGParameters.cc:61
DTTimeUnits::type
type
Definition: DTTimeUnits.h:32
DTBufferTree.h
DTTPGParameters::nsPerCount
float nsPerCount
Definition: DTTPGParameters.h:108
DTTPGParameters
Definition: DTTPGParameters.h:62
DTTPGParameters::begin
const_iterator begin() const
Definition: DTTPGParameters.cc:166
DTTPGParameters::setUnit
void setUnit(float unit)
Definition: DTTPGParameters.cc:164
makeMuonMisalignmentScenario.wheel
wheel
Definition: makeMuonMisalignmentScenario.py:319
createfilelist.int
int
Definition: createfilelist.py:10
DTBufferTree
Definition: DTBufferTree.h:42
DTTPGParameters::operator=
DTTPGParameters & operator=(DTTPGParameters const &)
Definition: DTTPGParameters.cc:41
DTTPGParameters.h
DTTPGParameters::~DTTPGParameters
~DTTPGParameters()
Definition: DTTPGParameters.cc:59
DTTPGParameters::version
const std::string & version() const
access version
Definition: DTTPGParameters.cc:113
DTTPGParameters::clockLength
int clockLength
Definition: DTTPGParameters.h:109
DTTPGParameters::dataList
std::vector< std::pair< DTTPGParametersId, DTTPGParametersData > > dataList
Definition: DTTPGParameters.h:111
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
unit
Basic3DVector unit() const
Definition: Basic3DVectorLD.h:162
DTTPGParameters::dBuf
edm::ConstRespectingPtr< DTBufferTree< int, int > > dBuf
Definition: DTTPGParameters.h:113
DTTPGParameters::end
const_iterator end() const
Definition: DTTPGParameters.cc:168
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
DTTPGParameters::unit
float unit() const
Definition: DTTPGParameters.cc:111
DTTPGParameters::dataVersion
std::string dataVersion
Definition: DTTPGParameters.h:107
DTTPGParametersId
Definition: DTTPGParameters.h:39
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
DTTPGParameters::totalTime
float totalTime(int wheelId, int stationId, int sectorId, DTTimeUnits::type unit) const
Definition: DTTPGParameters.cc:95
DTChamberId
Definition: DTChamberId.h:14
DTTPGParameters::clear
void clear()
reset content
Definition: DTTPGParameters.cc:117
DTBufferTree::find
int find(ElementKey fKey, ElementKey lKey, typename DTBufferTreeTrait< Content >::outputTypeOfConstFind &cont) const
crabWrapper.key
key
Definition: crabWrapper.py:19
BeamSplash_cfg.version
version
Definition: BeamSplash_cfg.py:45
DTTPGParameters::DTTPGParameters
DTTPGParameters()
Definition: DTTPGParameters.cc:31