CMS 3D CMS Logo

DTCCBConfig.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 
22 //-------------------
23 // Initializations --
24 //-------------------
25 
26 //----------------
27 // Constructors --
28 //----------------
29 DTCCBConfig::DTCCBConfig() : timeStamp(0), dataVersion(" "), dBuf(new DTBufferTreeUniquePtr) { dataList.reserve(1000); }
30 
32  : timeStamp(0), dataVersion(version), dBuf(new DTBufferTreeUniquePtr) {
33  dataList.reserve(1000);
34 }
35 
36 DTCCBId::DTCCBId() : wheelId(0), stationId(0), sectorId(0) {}
37 
38 DTConfigKey::DTConfigKey() : confType(0), confKey(0) {}
39 
40 //--------------
41 // Destructor --
42 //--------------
44 
46 
48 
49 //--------------
50 // Operations --
51 //--------------
52 std::vector<DTConfigKey> DTCCBConfig::fullKey() const { return fullConfigKey; }
53 
54 int DTCCBConfig::stamp() const { return timeStamp; }
55 
56 int DTCCBConfig::configKey(int wheelId, int stationId, int sectorId, std::vector<int>& confKey) const {
57  confKey.clear();
58 
59  std::vector<int> chanKey{wheelId, stationId, sectorId};
60  std::vector<int> const* confPtr;
61  int searchStatus = dBuf->find(chanKey.begin(), chanKey.end(), confPtr);
62  if (!searchStatus)
63  confKey = *confPtr;
64 
65  return searchStatus;
66 }
67 
68 int DTCCBConfig::configKey(const DTChamberId& id, std::vector<int>& confKey) const {
69  return configKey(id.wheel(), id.station(), id.sector(), confKey);
70 }
71 
73  ccb_config_map keyList;
74  std::vector<std::pair<DTCCBId, int>*> tempList;
75  const_iterator d_iter = begin();
76  const_iterator d_iend = end();
77  while (d_iter != d_iend)
78  tempList.push_back(new std::pair<DTCCBId, int>(*d_iter++));
79  std::vector<std::pair<DTCCBId, int>*>::iterator t_iter = tempList.begin();
80  std::vector<std::pair<DTCCBId, int>*>::iterator t_iend = tempList.end();
81  while (t_iter != t_iend) {
82  std::pair<DTCCBId, int>* ptr = *t_iter++;
83  if (ptr == nullptr)
84  continue;
85  DTCCBId& ccbId = ptr->first;
86  std::vector<int> cfgKeys;
87  cfgKeys.push_back(ptr->second);
88  std::vector<std::pair<DTCCBId, int>*>::iterator n_iter(t_iter);
89  while (n_iter != t_iend) {
90  std::pair<DTCCBId, int>*& pck = *n_iter++;
91  if (pck == nullptr)
92  continue;
93  DTCCBId& chkId = pck->first;
94  if ((chkId.wheelId == ccbId.wheelId) && (chkId.stationId == ccbId.stationId) &&
95  (chkId.sectorId == ccbId.sectorId)) {
96  cfgKeys.push_back(pck->second);
97  delete pck;
98  pck = nullptr;
99  }
100  }
101  keyList.push_back(std::pair<DTCCBId, std::vector<int> >(ccbId, cfgKeys));
102  delete ptr;
103  }
104  return keyList;
105 }
106 
107 const std::string& DTCCBConfig::version() const { return dataVersion; }
108 
110 
112  dataList.clear();
113  initialize();
114  return;
115 }
116 
117 void DTCCBConfig::setFullKey(const std::vector<DTConfigKey>& key) { fullConfigKey = key; }
118 
120 
121 int DTCCBConfig::setConfigKey(int wheelId, int stationId, int sectorId, const std::vector<int>& confKey) {
122  std::vector<int> chanKey{wheelId, stationId, sectorId};
123 
124  std::vector<int>* confPtr;
125  int searchStatus = dBuf->find(chanKey.begin(), chanKey.end(), confPtr);
126 
127  if (!searchStatus) {
128  std::vector<std::pair<DTCCBId, int> > tempList;
129  const_iterator iter = dataList.begin();
130  const_iterator iend = dataList.end();
131  while (iter != iend) {
132  const DTCCBId& ccbId(iter->first);
133  if ((ccbId.wheelId != wheelId) || (ccbId.stationId != stationId) || (ccbId.sectorId != sectorId))
134  tempList.push_back(*iter);
135  ++iter;
136  }
137  dataList = tempList;
138  DTCCBId ccbId;
139  ccbId.wheelId = wheelId;
140  ccbId.stationId = stationId;
141  ccbId.sectorId = sectorId;
142  std::vector<int>::const_iterator cfgIter = confKey.begin();
143  std::vector<int>::const_iterator cfgIend = confKey.end();
144  while (cfgIter != cfgIend)
145  dataList.push_back(std::pair<DTCCBId, int>(ccbId, *cfgIter++));
146  *confPtr = confKey;
147  return -1;
148  } else {
149  dBuf->insert(chanKey.begin(), chanKey.end(), std::unique_ptr<std::vector<int> >(new std::vector<int>(confKey)));
150  DTCCBId ccbId;
151  ccbId.wheelId = wheelId;
152  ccbId.stationId = stationId;
153  ccbId.sectorId = sectorId;
154  std::vector<int>::const_iterator cfgIter = confKey.begin();
155  std::vector<int>::const_iterator cfgIend = confKey.end();
156  while (cfgIter != cfgIend)
157  dataList.push_back(std::pair<DTCCBId, int>(ccbId, *cfgIter++));
158  return 0;
159  }
160 }
161 
162 int DTCCBConfig::setConfigKey(const DTChamberId& id, const std::vector<int>& confKey) {
163  return setConfigKey(id.wheel(), id.station(), id.sector(), confKey);
164 }
165 
166 int DTCCBConfig::appendConfigKey(int wheelId, int stationId, int sectorId, const std::vector<int>& confKey) {
167  std::vector<int> chanKey{wheelId, stationId, sectorId};
168 
169  DTCCBId ccbId;
170  ccbId.wheelId = wheelId;
171  ccbId.stationId = stationId;
172  ccbId.sectorId = sectorId;
173  std::vector<int>::const_iterator iter = confKey.begin();
174  std::vector<int>::const_iterator iend = confKey.end();
175  int key;
176 
177  std::vector<int>* confPtr;
178  int searchStatus = dBuf->find(chanKey.begin(), chanKey.end(), confPtr);
179 
180  if (searchStatus) {
181  std::unique_ptr<std::vector<int> > newVector(new std::vector<int>);
182  confPtr = newVector.get();
183  dBuf->insert(chanKey.begin(), chanKey.end(), std::move(newVector));
184  }
185 
186  while (iter != iend) {
187  key = *iter++;
188  dataList.push_back(std::pair<DTCCBId, int>(ccbId, key));
189  confPtr->push_back(key);
190  }
191 
192  if (!searchStatus) {
193  return -1;
194  } else {
195  return 0;
196  }
197 }
198 
199 int DTCCBConfig::appendConfigKey(const DTChamberId& id, const std::vector<int>& confKey) {
200  return appendConfigKey(id.wheel(), id.station(), id.sector(), confKey);
201 }
202 
204 
206 
208  dBuf->clear();
209 
210  const_iterator iter = dataList.begin();
211  const_iterator iend = dataList.end();
212  std::vector<int> chanKey;
213  chanKey.reserve(3);
214  while (iter != iend) {
215  const DTCCBId& chan = iter->first;
216 
217  chanKey.clear();
218  chanKey.push_back(chan.wheelId);
219  chanKey.push_back(chan.stationId);
220  chanKey.push_back(chan.sectorId);
221  std::vector<int>* ccbConfPtr;
222  int searchStatus = dBuf->find(chanKey.begin(), chanKey.end(), ccbConfPtr);
223 
224  if (searchStatus) {
225  std::unique_ptr<std::vector<int> > newVector(new std::vector<int>);
226  ccbConfPtr = newVector.get();
227  dBuf->insert(chanKey.begin(), chanKey.end(), std::move(newVector));
228  }
229  ccbConfPtr->push_back(iter->second);
230 
231  iter++;
232  }
233 }
DTCCBConfig::end
const_iterator end() const
Definition: DTCCBConfig.cc:205
DTCCBConfig::ccb_config_map
std::vector< std::pair< DTCCBId, std::vector< int > > > ccb_config_map
Definition: DTCCBConfig.h:71
DTCCBId
Definition: DTCCBConfig.h:37
DTCCBId::DTCCBId
DTCCBId()
Definition: DTCCBConfig.cc:36
DTCCBConfig::appendConfigKey
int appendConfigKey(int wheelId, int stationId, int sectorId, const std::vector< int > &confKey)
Definition: DTCCBConfig.cc:166
relativeConstraints.station
station
Definition: relativeConstraints.py:67
DTBufferTree::clear
void clear()
DTCCBConfig::fullConfigKey
std::vector< DTConfigKey > fullConfigKey
Definition: DTCCBConfig.h:104
DTCCBConfig::dataList
std::vector< std::pair< DTCCBId, int > > dataList
Definition: DTCCBConfig.h:105
DTCCBConfig::DTCCBConfig
DTCCBConfig()
Definition: DTCCBConfig.cc:29
DTCCBId::wheelId
int wheelId
Definition: DTCCBConfig.h:42
DTCCBConfig::timeStamp
int timeStamp
Definition: DTCCBConfig.h:102
DTCCBId::~DTCCBId
~DTCCBId()
Definition: DTCCBConfig.cc:45
DTConfigKey::~DTConfigKey
~DTConfigKey()
Definition: DTCCBConfig.cc:47
DTCCBConfig::const_iterator
std::vector< std::pair< DTCCBId, int > >::const_iterator const_iterator
Access methods to data.
Definition: DTCCBConfig.h:92
alignCSCRings.s
s
Definition: alignCSCRings.py:92
DTBufferTree::insert
int insert(ElementKey fKey, ElementKey lKey, Content cont)
DTBufferTreeUniquePtr
Definition: DTBufferTree.h:78
DTConfigKey::DTConfigKey
DTConfigKey()
Definition: DTCCBConfig.cc:38
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DTCCBId::stationId
int stationId
Definition: DTCCBConfig.h:43
DTBufferTree.h
DTCCBConfig::configKeyMap
ccb_config_map configKeyMap() const
Definition: DTCCBConfig.cc:72
makeMuonMisalignmentScenario.wheel
wheel
Definition: makeMuonMisalignmentScenario.py:319
DTCCBConfig::stamp
int stamp() const
Definition: DTCCBConfig.cc:54
DTCCBConfig::~DTCCBConfig
virtual ~DTCCBConfig()
Definition: DTCCBConfig.cc:43
DTCCBConfig::clear
void clear()
reset content
Definition: DTCCBConfig.cc:111
DTCCBId::sectorId
int sectorId
Definition: DTCCBConfig.h:44
DTCCBConfig::dataVersion
std::string dataVersion
Definition: DTCCBConfig.h:103
DTCCBConfig::configKey
int configKey(int wheelId, int stationId, int sectorId, std::vector< int > &confKey) const
Definition: DTCCBConfig.cc:56
eostools.move
def move(src, dest)
Definition: eostools.py:511
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
DTCCBConfig::setFullKey
void setFullKey(const std::vector< DTConfigKey > &)
Definition: DTCCBConfig.cc:117
DTCCBConfig::begin
const_iterator begin() const
Definition: DTCCBConfig.cc:203
DTCCBConfig::initialize
void initialize()
Definition: DTCCBConfig.cc:207
DTChamberId
Definition: DTChamberId.h:14
DTCCBConfig::fullKey
std::vector< DTConfigKey > fullKey() const
Definition: DTCCBConfig.cc:52
DTCCBConfig::dBuf
edm::ConstRespectingPtr< DTBufferTreeUniquePtr > dBuf
Definition: DTCCBConfig.h:107
DTBufferTree::find
int find(ElementKey fKey, ElementKey lKey, typename DTBufferTreeTrait< Content >::outputTypeOfConstFind &cont) const
DTCCBConfig::setConfigKey
int setConfigKey(int wheelId, int stationId, int sectorId, const std::vector< int > &confKey)
Definition: DTCCBConfig.cc:121
crabWrapper.key
key
Definition: crabWrapper.py:19
BeamSplash_cfg.version
version
Definition: BeamSplash_cfg.py:45
DTCCBConfig::version
const std::string & version() const
access version
Definition: DTCCBConfig.cc:107
DTCCBConfig::setStamp
void setStamp(int s)
Definition: DTCCBConfig.cc:119
DTCCBConfig.h