13 if ((!dbParams_.usingDbCache() && !deviceFactory(__func__)) ||
14 (dbParams_.usingDbCache() && !databaseCache(__func__))) {
15 return connections_.emptyRange();
19 if (!dbParams_.usingDbCache()) {
20 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
21 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
22 for (; iter != jter; ++iter) {
23 if (partition.empty() || partition == iter->second.partitionName()) {
29 if (
range == connections_.emptyRange()) {
34 deviceFactory(__func__)->getConnectionDescriptions(iter->second.partitionName(),
36 iter->second.cabVersion().first,
37 iter->second.cabVersion().second,
39 iter->second.maskVersion().first,
40 iter->second.maskVersion().second,
45 ConnectionFactory::vectorCopyI(tmp2, tmp1,
true);
48 connections_.loadNext(iter->second.partitionName(), tmp2);
53 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
54 <<
" Downloaded " << conns.size() <<
" FED connections to local cache for partition \""
55 << iter->second.partitionName() <<
"\"" << std::endl;
56 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
57 <<
" Cache holds FED connections for " << connections_.size() <<
" partitions.";
70 ConnectionFactory::vectorCopyI(tmp2, *tmp1,
true);
77 <<
" NULL pointer to FedConnections vector!";
82 handleException(__func__);
89 if (!partition.empty()) {
90 conns = connections_.find(partition);
94 if (!connections_.empty()) {
95 conns =
FedConnectionsRange(connections_.find(dbParams_.partitions().begin()->second.partitionName()).begin(),
96 connections_.find((--(dbParams_.partitions().end()))->second.partitionName()).
end());
98 conns = connections_.emptyRange();
100 np = connections_.size();
105 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
106 <<
" Found " << nc <<
" FED connections";
107 if (!dbParams_.usingDb()) {
108 ss <<
" in " << dbParams_.inputModuleXmlFiles().size() <<
" 'module.xml' file(s)";
110 if (!dbParams_.usingDbCache()) {
111 ss <<
" in " <<
np <<
" database partition(s)";
113 ss <<
" from shared memory name '" << dbParams_.sharedMemory() <<
"'";
116 if (connections_.empty()) {
128 if (!deviceFactory(__func__)) {
132 if (partition.empty()) {
134 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
135 <<
" Partition string is empty,"
136 <<
" therefore cannot add FED connections to local cache!";
143 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
144 <<
" Vector of FED connections is empty,"
145 <<
" therefore cannot add FED connections to local cache!";
150 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
151 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
152 for (; iter != jter; ++iter) {
153 if (partition == iter->second.partitionName()) {
157 if (iter == dbParams_.partitions().end()) {
159 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
160 <<
" Partition \"" << partition <<
"\" not found in partition list, "
161 <<
" therefore cannot add FED connections!";
167 if (
range == connections_.emptyRange()) {
170 ConnectionFactory::vectorCopyI(
tmp, conns,
true);
173 connections_.loadNext(partition,
tmp);
176 std::stringstream
ss;
177 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
178 <<
" Added " << conns.size() <<
" FED connections to local cache for partition \"" << partition <<
"\""
180 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
181 <<
" Cache holds FED connections for " << connections_.size() <<
" partitions.";
186 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
187 <<
" Partition \"" << partition <<
"\" already found in local cache, "
188 <<
" therefore cannot add new FED connections!";
197 if (dbParams_.usingDbCache()) {
199 <<
" Using database cache! No uploads allowed!";
203 if (!deviceFactory(__func__)) {
207 if (connections_.empty()) {
209 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
210 <<
" Found no cached FED connections, therefore no upload!";
215 if (dbParams_.usingDb()) {
217 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
218 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
219 for (; iter != jter; ++iter) {
220 if (partition.empty() || partition == iter->second.partitionName()) {
222 if (
range != connections_.emptyRange()) {
226 deviceFactory(__func__)->setConnectionDescriptions(conns,
227 iter->second.partitionName(),
229 &(cabVersion.second),
233 std::stringstream
ss;
234 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
235 <<
" Uploaded " << conns.size() <<
" FED connections to database for partition \""
236 << iter->second.partitionName() <<
"\".";
241 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
242 <<
" Vector of FED connections is empty for partition \"" << iter->second.partitionName()
243 <<
"\", therefore aborting upload for this partition!";
260 handleException(__func__);
264 allowCalibUpload_ =
true;
272 if (connections_.empty()) {
274 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
275 <<
" Found no cached FED connections!";
282 if (partition.empty()) {
285 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
286 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
287 for (; iter != jter; ++iter) {
288 if (partition != iter->second.partitionName()) {
290 if (
range != connections_.emptyRange()) {
305 if (partition.empty()) {
306 if (!connections_.empty()) {
307 conns =
FedConnectionsRange(connections_.find(dbParams_.partitions().begin()->second.partitionName()).begin(),
308 connections_.find((--(dbParams_.partitions().end()))->second.partitionName()).
end());
310 conns = connections_.emptyRange();
313 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
314 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
315 for (; iter != jter; ++iter) {
316 if (partition == iter->second.partitionName()) {
320 conns = connections_.find(iter->second.partitionName());
323 if (conns != connections_.emptyRange()) {
324 FedConnectionsV::const_iterator ifed = conns.begin();
325 FedConnectionsV::const_iterator jfed = conns.end();
326 for (; ifed != jfed; ++ifed) {
333 ss <<
"[SiStripConfigDb::" << __func__ <<
"]";
334 if (partition.empty()) {
335 ss <<
" Found no FED connections in local cache!";
337 ss <<
" Found no FED connections in local cache for partition \"" << partition <<
"\"!";
343 connections_ = temporary_cache;
349 std::stringstream
ss;
350 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
351 <<
" Contents of FedConnections container:" << std::endl;
352 ss <<
" Number of partitions: " << connections_.size() << std::endl;
358 for (; iconn != jconn; ++iconn) {
360 if (partition.empty() || partition == iconn->first) {
361 ss <<
" Partition number : " << cntr <<
" (out of " << connections_.size() <<
")" << std::endl;
362 ss <<
" Partition name : \"" << iconn->first <<
"\"" << std::endl;
363 ss <<
" Num of connections : " << iconn->second.size() << std::endl;
366 std::map<uint16_t, vector<uint16_t> >
feds;
367 FedConnectionsV::const_iterator iter = iconn->second.begin();
368 FedConnectionsV::const_iterator jter = iconn->second.end();
369 for (; iter != jter; ++iter) {
371 uint16_t fed_id = (*iter)->getFedId();
372 uint16_t fed_ch = (*iter)->getFedChannel();
374 feds[fed_id].push_back(fed_ch);
380 std::map<uint16_t, std::vector<uint16_t> >
tmp;
381 std::map<uint16_t, std::vector<uint16_t> >::const_iterator
ii =
feds.begin();
382 std::map<uint16_t, std::vector<uint16_t> >::const_iterator
jj =
feds.end();
384 std::vector<uint16_t>
temp =
ii->second;
386 std::vector<uint16_t>::const_iterator iii =
temp.begin();
387 std::vector<uint16_t>::const_iterator jjj =
temp.end();
388 for (; iii != jjj; ++iii) {
389 tmp[
ii->first].push_back(*iii);
396 std::map<uint16_t, std::vector<uint16_t> >::const_iterator ifed =
feds.begin();
397 std::map<uint16_t, std::vector<uint16_t> >::const_iterator jfed =
feds.end();
398 for (; ifed != jfed; ++ifed) {
399 ss <<
" Found " << std::setw(2) << ifed->second.size() <<
" channels for FED id " << std::setw(3)
400 << ifed->first <<
" : ";
401 if (!ifed->second.empty()) {
402 uint16_t
first = ifed->second.front();
403 uint16_t
last = ifed->second.front();
404 std::vector<uint16_t>::const_iterator ichan = ifed->second.begin();
405 std::vector<uint16_t>::const_iterator jchan = ifed->second.end();
406 for (; ichan != jchan; ++ichan) {
407 if (ichan != ifed->second.begin()) {
408 if (*ichan !=
last + 1) {
409 ss << std::setw(2) <<
first <<
"->" << std::setw(2) <<
last <<
", ";
410 if (ichan != ifed->second.end()) {
411 first = *(ichan + 1);
418 ss << std::setw(2) <<
first <<
"->" << std::setw(2) <<
last;