15 if ( ( !dbParams_.usingDbCache() && !deviceFactory(__func__) ) ||
16 ( dbParams_.usingDbCache() && !databaseCache(__func__) ) ) {
17 return feds_.emptyRange();
22 if ( !dbParams_.usingDbCache() ) {
24 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
25 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
26 for ( ; iter != jter; ++iter ) {
28 if ( partition ==
"" || partition == iter->second.partitionName() ) {
33 if ( range == feds_.emptyRange() ) {
36 deviceFactory(__func__)->setUsingStrips( usingStrips_ );
37 int16_t major = iter->second.fedVersion().first;
38 int16_t minor = iter->second.fedVersion().second;
39 if ( iter->second.fedVersion().first == 0 &&
40 iter->second.fedVersion().second == 0 ) {
47 tmp1 = *( deviceFactory(__func__)->getFed9UDescriptions( iter->second.partitionName(),
53 Fed9U::Fed9UDeviceFactory::vectorCopy( tmp2, tmp1 );
56 feds_.loadNext( iter->second.partitionName(), tmp2 );
61 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 62 <<
" Downloaded " << feds.size()
63 <<
" FED descriptions to local cache for partition \"" 64 << iter->second.partitionName() <<
"\"" << std::endl;
65 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 66 <<
" Cache holds FED descriptions for " 67 << feds_.size() <<
" partitions.";
84 Fed9U::Fed9UDeviceFactory::vectorCopy( tmp2, *tmp1 );
91 <<
"[SiStripConfigDb::" << __func__ <<
"]" 92 <<
" NULL pointer to FED descriptions vector!";
97 }
catch (... ) { handleException( __func__ ); }
103 if ( partition !=
"" ) {
104 feds = feds_.find( partition );
108 if ( !feds_.empty() ) {
110 feds_.find( (--(dbParams_.partitions().end()))->second.partitionName() ).
end() );
111 }
else { feds = feds_.emptyRange(); }
117 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 118 <<
" Found " << nc <<
" FED descriptions";
119 if ( !dbParams_.usingDb() ) { ss <<
" in " << dbParams_.inputFedXmlFiles().size() <<
" 'fed.xml' file(s)"; }
120 else {
if ( !dbParams_.usingDbCache() ) { ss <<
" in " << np <<
" database partition(s)"; }
121 else { ss <<
" from shared memory name '" << dbParams_.sharedMemory() <<
"'"; } }
133 if ( !deviceFactory(__func__) ) {
return; }
135 if ( partition.empty() ) {
137 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 138 <<
" Partition string is empty," 139 <<
" therefore cannot add FED descriptions to local cache!";
144 if ( feds.empty() ) {
146 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 147 <<
" Vector of FED descriptions is empty," 148 <<
" therefore cannot add FED descriptions to local cache!";
153 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
154 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
155 for ( ; iter != jter; ++iter ) {
if ( partition == iter->second.partitionName() ) {
break; } }
156 if ( iter == dbParams_.partitions().end() ) {
158 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 159 <<
" Partition \"" << partition
160 <<
"\" not found in partition list, " 161 <<
" therefore cannot add FED descriptions!";
167 if ( range == feds_.emptyRange() ) {
171 Fed9U::Fed9UDeviceFactory::vectorCopy( tmp, feds );
174 feds_.loadNext( partition, tmp );
177 std::stringstream ss;
178 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 179 <<
" Added " << feds.size()
180 <<
" FED descriptions to local cache for partition \"" 181 << iter->second.partitionName() <<
"\"" << std::endl;
182 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 183 <<
" Cache holds FED descriptions for " 184 << feds_.size() <<
" partitions.";
189 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 190 <<
" Partition \"" << partition
191 <<
"\" already found in local cache, " 192 <<
" therefore cannot add new FED descriptions!";
203 if ( dbParams_.usingDbCache() ) {
205 <<
"[SiStripConfigDb::" << __func__ <<
"]" 206 <<
" Using database cache! No uploads allowed!";
210 if ( !deviceFactory(__func__) ) {
return; }
212 if ( feds_.empty() ) {
214 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 215 <<
" Found no cached FED descriptions, therefore no upload!";
222 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
223 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
224 for ( ; iter != jter; ++iter ) {
226 if ( partition ==
"" || partition == iter->second.partitionName() ) {
229 if ( range != feds_.emptyRange() ) {
234 deviceFactory(__func__)->setFed9UDescriptions( feds,
235 iter->second.partitionName(),
236 (uint16_t*)(&(fedVersion.first)),
237 (uint16_t*)(&(fedVersion.second)),
241 std::stringstream ss;
242 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 243 <<
" Uploaded " << feds.size()
244 <<
" FED descriptions to database for partition \"" 245 << iter->second.partitionName() <<
"\"";
250 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 251 <<
" Vector of FED descriptions is empty for partition \"" 252 << iter->second.partitionName()
253 <<
"\", therefore aborting upload for this partition!";
270 }
catch (...) { handleException( __func__ ); }
272 allowCalibUpload_ =
true;
281 if ( feds_.empty() ) {
283 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 284 <<
" Found no cached FED descriptions!";
293 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
294 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
295 for ( ; iter != jter; ++iter ) {
296 if ( partition != iter->second.partitionName() ) {
298 if ( range != feds_.emptyRange() ) {
303 if ( range != feds_.emptyRange() ) {
305 <<
"[SiStripConfigDb::" << __func__ <<
"]" 306 <<
" Deleting FED descriptions for partition \"" 307 << iter->second.partitionName()
308 <<
"\" from local cache...";
316 if ( partition ==
"" ) {
317 if ( !feds_.empty() ) {
319 feds_.find( (--(dbParams_.partitions().end()))->second.partitionName() ).
end() );
320 }
else { feds = feds_.emptyRange(); }
322 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
323 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
324 for ( ; iter != jter; ++iter ) {
if ( partition == iter->second.partitionName() ) {
break; } }
325 feds = feds_.find( iter->second.partitionName() );
328 if ( feds != feds_.emptyRange() ) {
329 FedDescriptionsV::const_iterator ifed = feds.begin();
330 FedDescriptionsV::const_iterator jfed = feds.end();
331 for ( ; ifed != jfed; ++ifed ) {
if ( *ifed ) {
delete *ifed; } }
334 ss <<
"[SiStripConfigDb::" << __func__ <<
"]";
335 if ( partition ==
"" ) { ss <<
" Found no FED descriptions in local cache!"; }
336 else { ss <<
" Found no FED descriptions in local cache for partition \"" << partition <<
"\"!"; }
341 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 if ( partition ==
"" || partition == iconn->first ) {
363 ss <<
" Partition number : " << cntr <<
" (out of " << feds_.size() <<
")" << std::endl;
364 ss <<
" Partition name : \"" << iconn->first <<
"\"" << std::endl;
365 ss <<
" Num of FED ids : " << iconn->second.size() << std::endl;
368 std::map< uint16_t, vector<uint16_t> > feds;
369 FedDescriptionsV::const_iterator iter = iconn->second.begin();
370 FedDescriptionsV::const_iterator jter = iconn->second.end();
371 for ( ; iter != jter; ++iter ) {
373 uint16_t
key = (*iter)->getCrateNumber();
374 uint16_t
data = (*iter)->getFedId();
375 if (
find( feds[key].
begin(), feds[key].
end(), data ) == feds[key].
end() ) {
376 feds[
key].push_back( data );
382 std::map< uint16_t, std::vector<uint16_t> >
tmp;
383 std::map< uint16_t, std::vector<uint16_t> >::const_iterator
ii = feds.begin();
384 std::map< uint16_t, std::vector<uint16_t> >::const_iterator
jj = feds.end();
385 for ( ; ii !=
jj; ++
ii ) {
386 std::vector<uint16_t>
temp = ii->second;
387 std::sort( temp.begin(), temp.end() );
388 std::vector<uint16_t>::const_iterator iii = temp.begin();
389 std::vector<uint16_t>::const_iterator jjj = temp.end();
390 for ( ; iii != jjj; ++iii ) { 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()
400 <<
" FED ids for crate number " << std::setw(2) << 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() ) { first = *(icrate+1); }
415 if ( first != last ) { ss << std::setw(2) << first <<
"->" << std::setw(2) <<
last; }
434 if ( ( !dbParams_.usingDbCache() && !deviceFactory(__func__) ) ||
435 ( dbParams_.usingDbCache() && !databaseCache(__func__) ) ) {
436 return FedIdsRange( fedIds_.end(), fedIds_.end() );
442 bool using_strips = usingStrips_;
443 if ( factory_ ) { factory_->setUsingStrips(
false ); }
445 if ( factory_ ) { factory_->setUsingStrips( using_strips ); }
447 if ( !feds.empty() ) {
448 FedDescriptionsV::const_iterator ifed = feds.begin();
449 FedDescriptionsV::const_iterator jfed = feds.end();
450 for ( ; ifed != jfed; ++ifed ) {
451 if ( *ifed ) { fedIds_.push_back( (*ifed)->getFedId() ); }
454 <<
"[SiStripConfigDb::" << __func__ <<
"]" 455 <<
" NULL pointer to FedDescription!";
461 }
catch (...) { handleException( __func__ ); }
463 if ( fedIds_.empty() ) {
465 <<
"[SiStripConfigDb::" << __func__ <<
"]" 466 <<
" No FED ids found!";
469 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
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::pair< uint32_t, uint32_t > Versions
void addFedDescriptions(std::string partition, FedDescriptionsV &)
static const char mlConfigDb_[]
static const char mlCabling_[]
FedIdsRange getFedIds(std::string partition="")
void printFedDescriptions(std::string partition="")
void uploadFedDescriptions(std::string partition="")
boost::iterator_range< FedIds::const_iterator > FedIdsRange
std::vector< std::vector< double > > tmp
char data[epos_bytes_allocation]
void clearFedDescriptions(std::string partition="")
std::vector< FedDescription * > FedDescriptionsV