14 if ((!dbParams_.usingDbCache() && !deviceFactory(__func__)) ||
15 (dbParams_.usingDbCache() && !databaseCache(__func__))) {
16 return feds_.emptyRange();
20 if (!dbParams_.usingDbCache()) {
21 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
22 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
23 for (; iter != jter; ++iter) {
30 if (
range == feds_.emptyRange()) {
32 deviceFactory(__func__)->setUsingStrips(usingStrips_);
33 int16_t major = iter->second.fedVersion().first;
34 int16_t minor = iter->second.fedVersion().second;
35 if (iter->second.fedVersion().first == 0 && iter->second.fedVersion().second == 0) {
42 tmp1 = *(deviceFactory(__func__)->getFed9UDescriptions(iter->second.partitionName(), major, minor));
46 Fed9U::Fed9UDeviceFactory::vectorCopy(tmp2, tmp1);
49 feds_.loadNext(iter->second.partitionName(), tmp2);
54 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 55 <<
" Downloaded " <<
feds.size() <<
" FED descriptions to local cache for partition \"" 56 << iter->second.partitionName() <<
"\"" << std::endl;
57 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 58 <<
" Cache holds FED descriptions for " << feds_.size() <<
" partitions.";
71 Fed9U::Fed9UDeviceFactory::vectorCopy(tmp2, *tmp1);
78 <<
" NULL pointer to FED descriptions vector!";
83 handleException(__func__);
97 feds_.find((--(dbParams_.partitions().end()))->second.partitionName()).end());
99 feds = feds_.emptyRange();
106 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 107 <<
" Found " << nc <<
" FED descriptions";
108 if (!dbParams_.usingDb()) {
109 ss <<
" in " << dbParams_.inputFedXmlFiles().size() <<
" 'fed.xml' file(s)";
111 if (!dbParams_.usingDbCache()) {
112 ss <<
" in " <<
np <<
" database partition(s)";
114 ss <<
" from shared memory name '" << dbParams_.sharedMemory() <<
"'";
129 if (!deviceFactory(__func__)) {
135 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 136 <<
" Partition string is empty," 137 <<
" therefore cannot add FED descriptions to local cache!";
144 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 145 <<
" Vector of FED descriptions is empty," 146 <<
" therefore cannot add FED descriptions to local cache!";
151 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
152 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
153 for (; iter != jter; ++iter) {
154 if (
partition == iter->second.partitionName()) {
158 if (iter == dbParams_.partitions().end()) {
160 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 161 <<
" Partition \"" <<
partition <<
"\" not found in partition list, " 162 <<
" therefore cannot add FED descriptions!";
168 if (
range == feds_.emptyRange()) {
171 Fed9U::Fed9UDeviceFactory::vectorCopy(
tmp,
feds);
177 std::stringstream
ss;
178 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 179 <<
" Added " <<
feds.size() <<
" FED descriptions to local cache for partition \"" 180 << iter->second.partitionName() <<
"\"" << std::endl;
181 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 182 <<
" Cache holds FED descriptions for " << feds_.size() <<
" partitions.";
187 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 188 <<
" Partition \"" <<
partition <<
"\" already found in local cache, " 189 <<
" therefore cannot add new FED descriptions!";
198 if (dbParams_.usingDbCache()) {
200 <<
" Using database cache! No uploads allowed!";
204 if (!deviceFactory(__func__)) {
210 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 211 <<
" Found no cached FED descriptions, therefore no upload!";
217 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
218 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
219 for (; iter != jter; ++iter) {
222 if (
range != feds_.emptyRange()) {
226 deviceFactory(__func__)->setFed9UDescriptions(
feds,
227 iter->second.partitionName(),
228 (uint16_t*)(&(fedVersion.first)),
229 (uint16_t*)(&(fedVersion.second)),
233 std::stringstream
ss;
234 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 235 <<
" Uploaded " <<
feds.size() <<
" FED descriptions to database for partition \"" 236 << iter->second.partitionName() <<
"\"";
241 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 242 <<
" Vector of FED descriptions is empty for partition \"" << iter->second.partitionName()
243 <<
"\", therefore aborting upload for this partition!";
260 handleException(__func__);
263 allowCalibUpload_ =
true;
273 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 274 <<
" Found no cached FED descriptions!";
284 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
285 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
286 for (; iter != jter; ++iter) {
287 if (
partition != iter->second.partitionName()) {
289 if (
range != feds_.emptyRange()) {
294 if (
range != feds_.emptyRange()) {
296 <<
" Deleting FED descriptions for partition \"" << iter->second.partitionName()
297 <<
"\" from local cache...";
306 if (!feds_.empty()) {
308 feds_.find((--(dbParams_.partitions().end()))->second.partitionName()).end());
310 feds = feds_.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 feds = feds_.find(iter->second.partitionName());
323 if (
feds != feds_.emptyRange()) {
324 FedDescriptionsV::const_iterator ifed =
feds.begin();
325 FedDescriptionsV::const_iterator jfed =
feds.end();
326 for (; ifed != jfed; ++ifed) {
333 ss <<
"[SiStripConfigDb::" << __func__ <<
"]";
335 ss <<
" Found no FED descriptions in local cache!";
337 ss <<
" Found no FED descriptions in local cache for partition \"" <<
partition <<
"\"!";
343 feds_ = temporary_cache;
349 std::stringstream
ss;
350 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 351 <<
" Contents of FedDescriptions container:" << std::endl;
352 ss <<
" Number of partitions: " << feds_.size() << std::endl;
358 for (; iconn != jconn; ++iconn) {
361 ss <<
" Partition number : " << cntr <<
" (out of " << feds_.size() <<
")" << std::endl;
362 ss <<
" Partition name : \"" << iconn->first <<
"\"" << std::endl;
363 ss <<
" Num of FED ids : " << iconn->second.size() << std::endl;
366 std::map<uint16_t, vector<uint16_t> >
feds;
367 FedDescriptionsV::const_iterator iter = iconn->second.begin();
368 FedDescriptionsV::const_iterator jter = iconn->second.end();
369 for (; iter != jter; ++iter) {
371 uint16_t
key = (*iter)->getCrateNumber();
372 uint16_t
data = (*iter)->getFedId();
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() <<
" FED ids for crate number " << std::setw(2)
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 icrate = ifed->second.begin();
405 std::vector<uint16_t>::const_iterator jcrate = ifed->second.end();
406 for (; icrate != jcrate; ++icrate) {
407 if (icrate != ifed->second.begin()) {
408 if (*icrate !=
last + 1) {
409 ss << std::setw(2) <<
first <<
"->" << std::setw(2) <<
last <<
", ";
410 if (icrate != ifed->second.end()) {
411 first = *(icrate + 1);
418 ss << std::setw(2) <<
first <<
"->" << std::setw(2) <<
last;
434 if ((!dbParams_.usingDbCache() && !deviceFactory(__func__)) ||
435 (dbParams_.usingDbCache() && !databaseCache(__func__))) {
441 bool using_strips = usingStrips_;
443 factory_->setUsingStrips(
false);
447 factory_->setUsingStrips(using_strips);
451 FedDescriptionsV::const_iterator ifed =
feds.begin();
452 FedDescriptionsV::const_iterator jfed =
feds.end();
453 for (; ifed != jfed; ++ifed) {
455 fedIds_.push_back((*ifed)->getFedId());
458 <<
" NULL pointer to FedDescription!";
465 handleException(__func__);
468 if (fedIds_.empty()) {
470 <<
" No FED ids found!";
473 return FedIdsRange(fedIds_.begin(), fedIds_.end());
static const std::string defaultPartitionName_
void loadNext(K const &k, std::vector< T > const &v)
FedDescriptionsRange getFedDescriptions(std::string partition="")
FedDescriptions::range FedDescriptionsRange
Log< level::Error, false > LogError
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
void addFedDescriptions(std::string partition, FedDescriptionsV &)
static const char mlConfigDb_[]
static const char mlCabling_[]
FedIdsRange getFedIds(std::string partition="")
void printFedDescriptions(std::string partition="")
std::pair< uint32_t, uint32_t > Versions
void uploadFedDescriptions(std::string partition="")
boost::iterator_range< FedIds::const_iterator > FedIdsRange
char data[epos_bytes_allocation]
void clearFedDescriptions(std::string partition="")
Log< level::Warning, false > LogWarning
std::vector< FedDescription * > FedDescriptionsV