23 if ((!dbParams_.usingDbCache() && !deviceFactory(__func__)) ||
24 (dbParams_.usingDbCache() && !databaseCache(__func__))) {
25 return analyses_.emptyRange();
29 if (!dbParams_.usingDbCache()) {
30 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
31 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
32 for (; iter != jter; ++iter) {
33 if (partition.empty() || partition == iter->second.partitionName()) {
39 if (
range == analyses_.emptyRange()) {
41 if (analysis_type == AnalysisDescription::T_ANALYSIS_FASTFEDCABLING) {
42 tmp1 = deviceFactory(__func__)->getAnalysisHistory(iter->second.partitionName(),
43 iter->second.fastCablingVersion().first,
44 iter->second.fastCablingVersion().second,
46 }
else if (analysis_type == AnalysisDescription::T_ANALYSIS_TIMING) {
47 tmp1 = deviceFactory(__func__)->getAnalysisHistory(iter->second.partitionName(),
48 iter->second.apvTimingVersion().first,
49 iter->second.apvTimingVersion().second,
51 }
else if (analysis_type == AnalysisDescription::T_ANALYSIS_OPTOSCAN) {
52 tmp1 = deviceFactory(__func__)->getAnalysisHistory(iter->second.partitionName(),
53 iter->second.optoScanVersion().first,
54 iter->second.optoScanVersion().second,
56 }
else if (analysis_type == AnalysisDescription::T_ANALYSIS_VPSPSCAN) {
57 tmp1 = deviceFactory(__func__)->getAnalysisHistory(iter->second.partitionName(),
58 iter->second.vpspScanVersion().first,
59 iter->second.vpspScanVersion().second,
61 }
else if (analysis_type == AnalysisDescription::T_ANALYSIS_CALIBRATION) {
62 tmp1 = deviceFactory(__func__)->getAnalysisHistory(iter->second.partitionName(),
63 iter->second.apvCalibVersion().first,
64 iter->second.apvCalibVersion().second,
66 }
else if (analysis_type == AnalysisDescription::T_ANALYSIS_PEDESTALS) {
67 tmp1 = deviceFactory(__func__)->getAnalysisHistory(iter->second.partitionName(),
68 iter->second.pedestalsVersion().first,
69 iter->second.pedestalsVersion().second,
71 }
else if (analysis_type == AnalysisDescription::T_ANALYSIS_PEDSFULLNOISE) {
72 tmp1 = deviceFactory(__func__)->getAnalysisHistory(iter->second.partitionName(),
73 iter->second.pedestalsVersion().first,
74 iter->second.pedestalsVersion().second,
76 }
else if (analysis_type == AnalysisDescription::T_ANALYSIS_APVLATENCY) {
77 tmp1 = deviceFactory(__func__)->getAnalysisHistory(iter->second.partitionName(),
78 iter->second.apvLatencyVersion().first,
79 iter->second.apvLatencyVersion().second,
81 }
else if (analysis_type == AnalysisDescription::T_ANALYSIS_FINEDELAY) {
82 tmp1 = deviceFactory(__func__)->getAnalysisHistory(iter->second.partitionName(),
83 iter->second.fineDelayVersion().first,
84 iter->second.fineDelayVersion().second,
88 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
89 <<
" Unexpected analysis type \"" << analysisType(analysis_type) <<
"\"! Aborting download...";
91 return analyses_.emptyRange();
96 CommissioningAnalysisFactory::vectorCopy(tmp1, tmp2);
99 analyses_.loadNext(iter->second.partitionName(), tmp2);
103 std::stringstream
ss;
104 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
105 <<
" Downloaded " << anals.size() <<
" analysis descriptions of type \"" << analysisType(analysis_type)
106 <<
"\" to local cache for partition \"" << iter->second.partitionName() <<
"\"" << std::endl;
107 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
108 <<
" Cache holds analysis descriptions for " << analyses_.size() <<
" partitions.";
115 std::stringstream
ss;
116 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
117 <<
" No database cache for analysis objects!";
122 handleException(__func__);
129 if (!partition.empty()) {
130 anals = analyses_.find(partition);
134 if (!analyses_.empty()) {
137 analyses_.find((--(dbParams_.partitions().end()))->second.partitionName()).
end());
139 anals = analyses_.emptyRange();
141 np = analyses_.size();
146 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
147 <<
" Found " << nc <<
" analysis descriptions";
148 if (!dbParams_.usingDbCache()) {
149 ss <<
" in " <<
np <<
" database partition(s)";
151 ss <<
" from shared memory name '" << dbParams_.sharedMemory() <<
"'";
153 if (analyses_.empty()) {
165 if (!deviceFactory(__func__)) {
169 if (partition.empty()) {
171 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
172 <<
" Partition string is empty,"
173 <<
" therefore cannot add analysis descriptions to local cache!";
180 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
181 <<
" Vector of analysis descriptions is empty,"
182 <<
" therefore cannot add analysis descriptions to local cache!";
187 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
188 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
189 for (; iter != jter; ++iter) {
190 if (partition == iter->second.partitionName()) {
194 if (iter == dbParams_.partitions().end()) {
196 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
197 <<
" Partition \"" << partition <<
"\" not found in partition list, "
198 <<
" therefore cannot add analysis descriptions!";
204 if (
range == analyses_.emptyRange()) {
207 CommissioningAnalysisFactory::vectorCopy(anals,
tmp);
210 analyses_.loadNext(partition,
tmp);
213 std::stringstream
ss;
214 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
215 <<
" Added " << anals.size() <<
" analysis descriptions to local cache for partition \"" << partition <<
"\"."
216 <<
" (Cache holds analysis descriptions for " << analyses_.size() <<
" partitions.)";
220 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
221 <<
" Partition \"" << partition <<
"\" already found in local cache, "
222 <<
" therefore cannot add analysis descriptions!";
231 if (dbParams_.usingDbCache()) {
233 <<
" Using database cache! No uploads allowed!";
237 if (!deviceFactory(__func__)) {
241 if (analyses_.empty()) {
243 <<
" Found no cached analysis descriptions, therefore no upload!";
247 if (calibration_for_physics && !allowCalibUpload_) {
249 <<
" Attempting to upload calibration constants"
250 <<
" without uploading any hardware descriptions!"
251 <<
" Aborting upload...";
254 allowCalibUpload_ =
false;
258 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
259 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
260 for (; iter != jter; ++iter) {
261 if (partition.empty() || partition == iter->second.partitionName()) {
263 if (
range != analyses_.emptyRange()) {
268 for (
auto element : anals) {
269 if (
std::find(analysis_type.begin(), analysis_type.end(), element->getType()) == analysis_type.end() and
270 element->getType() != AnalysisDescription::T_UNKNOWN) {
271 analysis_type.push_back(element->getType());
272 }
else if (element->getType() == AnalysisDescription::T_UNKNOWN) {
274 <<
" Analysis type is UNKNOWN. Aborting upload!";
279 vector<AnalysisDescriptionsV> analysisToUpload;
280 for (
auto type : analysis_type) {
282 for (
auto element : anals) {
283 if (element->getType() ==
type)
284 ana_temp.push_back(element);
286 analysisToUpload.push_back(ana_temp);
290 for (
auto analysis : analysisToUpload) {
291 uint32_t
version = deviceFactory(__func__)->uploadAnalysis(iter->second.runNumber(),
292 iter->second.partitionName(),
293 analysis.front()->getType(),
295 calibration_for_physics);
297 if (calibration_for_physics) {
298 deviceFactory(__func__)->uploadAnalysisState(
version);
303 std::stringstream
ss;
304 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
305 <<
" Uploaded " << anals.size() <<
" device descriptions to database for partition \""
306 << iter->second.partitionName() <<
"\".";
311 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
312 <<
" Vector of device descriptions is empty for partition \"" << iter->second.partitionName()
313 <<
"\", therefore aborting upload for this partition!";
329 handleException(__func__);
332 allowCalibUpload_ =
true;
340 if (analyses_.empty()) {
342 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
343 <<
" Found no cached analysis descriptions!";
350 if (partition.empty()) {
353 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
354 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
355 for (; iter != jter; ++iter) {
356 if (partition != iter->second.partitionName()) {
358 if (
range != analyses_.emptyRange()) {
373 if (partition.empty()) {
374 if (!analyses_.empty()) {
377 analyses_.find((--(dbParams_.partitions().end()))->second.partitionName()).
end());
379 anals = analyses_.emptyRange();
382 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
383 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
384 for (; iter != jter; ++iter) {
385 if (partition == iter->second.partitionName()) {
389 anals = analyses_.find(iter->second.partitionName());
392 if (anals != analyses_.emptyRange()) {
393 AnalysisDescriptionsV::const_iterator ianal = anals.begin();
394 AnalysisDescriptionsV::const_iterator janal = anals.end();
395 for (; ianal != janal; ++ianal) {
402 ss <<
"[SiStripConfigDb::" << __func__ <<
"]";
403 if (partition.empty()) {
404 ss <<
" Found no analysis descriptions in local cache!";
406 ss <<
" Found no analysis descriptions in local cache for partition \"" << partition <<
"\"!";
412 analyses_ = temporary_cache;
418 std::stringstream
ss;
419 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
420 <<
" Contents of AnalysisDescriptions container:" << std::endl;
421 ss <<
" Number of partitions: " << analyses_.size() << std::endl;
427 for (; ianal != janal; ++ianal) {
429 if (partition.empty() || partition == ianal->first) {
430 ss <<
" Partition number : " << cntr <<
" (out of " << analyses_.size() <<
")" << std::endl;
431 ss <<
" Partition name : \"" << ianal->first <<
"\"" << std::endl;
432 ss <<
" Num of analyses : " << ianal->second.size() << std::endl;
435 std::map<uint32_t, vector<uint32_t> >
analyses;
436 AnalysisDescriptionsV::const_iterator iter = ianal->second.begin();
437 AnalysisDescriptionsV::const_iterator jter = ianal->second.end();
438 for (; iter != jter; ++iter) {
457 std::map<uint32_t, std::vector<uint32_t> >
tmp;
458 std::map<uint32_t, std::vector<uint32_t> >::const_iterator
ii =
analyses.begin();
459 std::map<uint32_t, std::vector<uint32_t> >::const_iterator
jj =
analyses.end();
461 std::vector<uint32_t>
temp =
ii->second;
462 std::sort(
temp.begin(),
temp.end());
463 std::vector<uint32_t>::const_iterator iii =
temp.begin();
464 std::vector<uint32_t>::const_iterator jjj =
temp.end();
465 for (; iii != jjj; ++iii) {
466 tmp[
ii->first].push_back(*iii);
473 std::map<uint32_t, std::vector<uint32_t> >::const_iterator ianal =
analyses.begin();
474 std::map<uint32_t, std::vector<uint32_t> >::const_iterator janal =
analyses.end();
475 for (; ianal != janal; ++ianal) {
477 ss <<
" Found " << std::setw(3) << ianal->second.size() <<
" analyses for FEC crate/slot/ring "
478 <<
key.fecCrate() <<
"/" <<
key.fecSlot() <<
"/" <<
key.fecRing();
508 addr.fecSlot_ = static_cast<uint16_t>(
desc.getSlot());
510 addr.ccuAddr_ = static_cast<uint16_t>(
desc.getCcuAdr());
511 addr.ccuChan_ = static_cast<uint16_t>(
desc.getCcuChan());
513 addr.i2cAddr_ = static_cast<uint16_t>(
desc.getI2cAddr());
514 addr.fedId_ = static_cast<uint16_t>(
desc.getFedId());
515 addr.feUnit_ = static_cast<uint16_t>(
desc.getFeUnit());
516 addr.feChan_ = static_cast<uint16_t>(
desc.getFeChan());
518 handleException(__func__);
527 if (analysis_type == AnalysisDescription::T_ANALYSIS_FASTFEDCABLING) {
528 return "FAST_CABLING";
529 }
else if (analysis_type == AnalysisDescription::T_ANALYSIS_TIMING) {
531 }
else if (analysis_type == AnalysisDescription::T_ANALYSIS_OPTOSCAN) {
533 }
else if (analysis_type == AnalysisDescription::T_ANALYSIS_PEDESTALS) {
535 }
else if (analysis_type == AnalysisDescription::T_ANALYSIS_PEDSFULLNOISE) {
536 return "PEDSFULLNOISE";
537 }
else if (analysis_type == AnalysisDescription::T_ANALYSIS_APVLATENCY) {
538 return "APV_LATENCY";
539 }
else if (analysis_type == AnalysisDescription::T_ANALYSIS_FINEDELAY) {
541 }
else if (analysis_type == AnalysisDescription::T_ANALYSIS_CALIBRATION) {
542 return "CALIBRATION";
543 }
else if (analysis_type == AnalysisDescription::T_UNKNOWN) {
544 return "UNKNOWN ANALYSIS TYPE";
546 return "UNDEFINED ANALYSIS TYPE";