7 using namespace sistrip;
14 if ( ( !dbParams_.usingDbCache() && !deviceFactory(__func__) ) ||
15 ( dbParams_.usingDbCache() && !databaseCache(__func__) ) ) {
16 return devices_.emptyRange();
21 if ( !dbParams_.usingDbCache() ) {
23 SiStripDbParams::SiStripPartitions::const_iterator
iter = dbParams_.partitions().begin();
24 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
25 for ( ; iter != jter; ++
iter ) {
27 if ( partition ==
"" || partition == iter->second.partitionName() ) {
32 if ( range == devices_.emptyRange() ) {
36 deviceFactory(__func__)->getFecDeviceDescriptions( iter->second.partitionName(),
38 iter->second.fecVersion().first,
39 iter->second.fecVersion().second,
41 iter->second.maskVersion().first,
42 iter->second.maskVersion().second,
48 FecFactory::vectorCopyI( tmp2, tmp1,
true );
51 devices_.loadNext( iter->second.partitionName(), tmp2 );
56 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
57 <<
" Downloaded " << range.size()
58 <<
" device descriptions to local cache for partition \""
59 << iter->second.partitionName() <<
"\"" << std::endl;
60 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
61 <<
" Cache holds device descriptions for "
62 << devices_.size() <<
" partitions.";
79 FecFactory::vectorCopyI( tmp2, *tmp1,
true );
86 <<
"[SiStripConfigDb::" << __func__ <<
"]"
87 <<
" NULL pointer to DeviceDescriptions vector!";
92 }
catch (...) { handleException( __func__ ); }
98 if ( partition !=
"" ) {
99 devs = devices_.find( partition );
103 if ( !devices_.empty() ) {
105 devices_.find( (--(dbParams_.partitions().end()))->second.partitionName() ).
end() );
106 }
else { devs = devices_.emptyRange(); }
107 np = devices_.size();
112 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
113 <<
" Found " << nc <<
" device descriptions";
114 if ( !dbParams_.usingDb() ) { ss <<
" in " << dbParams_.inputFecXmlFiles().size() <<
" 'fec.xml' file(s)"; }
115 else {
if ( !dbParams_.usingDbCache() ) { ss <<
" in " << np <<
" database partition(s)"; }
116 else { ss <<
" from shared memory name '" << dbParams_.sharedMemory() <<
"'"; } }
129 typedDevices_.clear();
139 if ( ( !dbParams_.usingDbCache() && !deviceFactory(__func__) ) ||
140 ( dbParams_.usingDbCache() && !databaseCache(__func__) ) ) {
146 if ( !devs.empty() ) {
148 typedDevices_ = FecFactory::getDeviceFromDeviceVector(
tmp, device_type );
150 }
catch (...) { handleException( __func__ ); }
152 if ( device_type == APV25 ) {
153 apvDevices_.swap( typedDevices_ );
155 }
else if ( device_type == APVMUX ) {
156 muxDevices_.swap( typedDevices_ );
158 }
else if ( device_type == DCU ) {
159 dcuDevices_.swap( typedDevices_ );
161 }
else if ( device_type == LASERDRIVER ) {
162 lldDevices_.swap( typedDevices_ );
164 }
else if ( device_type == PLL ) {
165 pllDevices_.swap( typedDevices_ );
167 }
else if ( device_type == DOH ) {
168 dohDevices_.swap( typedDevices_ );
187 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
188 <<
" Extracted " <<
tmp.size()
189 <<
" device descriptions (for devices of type "
190 << deviceType( device_type ) <<
")";
201 if ( !deviceFactory(__func__) ) {
return; }
203 if ( partition.empty() ) {
205 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
206 <<
" Partition string is empty,"
207 <<
" therefore cannot add device descriptions to local cache!";
212 if ( devs.empty() ) {
214 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
215 <<
" Vector of device descriptions is empty,"
216 <<
" therefore cannot add device descriptions to local cache!";
221 SiStripDbParams::SiStripPartitions::const_iterator
iter = dbParams_.partitions().begin();
222 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
223 for ( ; iter != jter; ++
iter ) {
if ( partition == iter->second.partitionName() ) {
break; } }
224 if ( iter == dbParams_.partitions().end() ) {
226 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
227 <<
" Partition \"" << partition
228 <<
"\" not found in partition list, "
229 <<
" therefore cannot add device descriptions!";
235 if ( range == devices_.emptyRange() ) {
239 FecFactory::vectorCopyI( tmp, devs,
true );
242 devices_.loadNext( partition, tmp );
245 std::stringstream
ss;
246 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
247 <<
" Added " << devs.size()
248 <<
" device descriptions to local cache for partition \""
249 << partition <<
"\"."
250 <<
" (Cache holds device descriptions for "
251 << devices_.size() <<
" partitions.)";
256 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
257 <<
" Partition \"" << partition
258 <<
"\" already found in local cache, "
259 <<
" therefore cannot add device descriptions!";
270 if ( dbParams_.usingDbCache() ) {
272 <<
"[SiStripConfigDb::" << __func__ <<
"]"
273 <<
" Using database cache! No uploads allowed!";
277 if ( !deviceFactory(__func__) ) {
return; }
279 if ( devices_.empty() ) {
281 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
282 <<
" Found no cached device descriptions, therefore no upload!";
289 SiStripDbParams::SiStripPartitions::const_iterator
iter = dbParams_.partitions().begin();
290 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
291 for ( ; iter != jter; ++
iter ) {
293 if ( partition ==
"" || partition == iter->second.partitionName() ) {
296 if ( range != devices_.emptyRange() ) {
301 deviceFactory(__func__)->setFecDeviceDescriptions( devs,
302 iter->second.partitionName(),
304 &(fecVersion.second),
308 std::stringstream
ss;
309 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
310 <<
" Uploaded " << devs.size()
311 <<
" device descriptions to database for partition \""
312 << iter->second.partitionName() <<
"\".";
317 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
318 <<
" Vector of device descriptions is empty for partition \""
319 << iter->second.partitionName()
320 <<
"\", therefore aborting upload for this partition!";
337 }
catch (...) { handleException( __func__ ); }
339 allowCalibUpload_ =
true;
348 if ( devices_.empty() ) {
350 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
351 <<
" Found no cached device descriptions!";
360 SiStripDbParams::SiStripPartitions::const_iterator
iter = dbParams_.partitions().begin();
361 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
362 for ( ; iter != jter; ++
iter ) {
363 if ( partition != iter->second.partitionName() ) {
365 if ( range != devices_.emptyRange() ) {
380 if ( partition ==
"" ) {
381 if ( !devices_.empty() ) {
383 devices_.find( (--(dbParams_.partitions().end()))->second.partitionName() ).
end() );
384 }
else { devs = devices_.emptyRange(); }
386 SiStripDbParams::SiStripPartitions::const_iterator
iter = dbParams_.partitions().begin();
387 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
388 for ( ; iter != jter; ++
iter ) {
if ( partition == iter->second.partitionName() ) {
break; } }
389 devs = devices_.find( iter->second.partitionName() );
392 if ( devs != devices_.emptyRange() ) {
393 DeviceDescriptionsV::const_iterator ifed = devs.begin();
394 DeviceDescriptionsV::const_iterator jfed = devs.end();
395 for ( ; ifed != jfed; ++ifed ) {
if ( *ifed ) {
delete *ifed; } }
398 ss <<
"[SiStripConfigDb::" << __func__ <<
"]";
399 if ( partition ==
"" ) { ss <<
" Found no device descriptions in local cache!"; }
400 else { ss <<
" Found no device descriptions in local cache for partition \"" << partition <<
"\"!"; }
405 devices_ = temporary_cache;
413 std::stringstream
ss;
414 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
415 <<
" Contents of DeviceDescriptions container:" << std::endl;
416 ss <<
" Number of partitions: " << devices_.size() << std::endl;
422 for ( ; idev != jdev; ++idev ) {
425 if ( partition ==
"" || partition == idev->first ) {
427 ss <<
" Partition number : " << cntr <<
" (out of " << devices_.size() <<
")" << std::endl;
428 ss <<
" Partition name : \"" << idev->first <<
"\"" << std::endl;
429 ss <<
" Num of devices : " << idev->second.size() << std::endl;
432 std::map< uint32_t, vector<std::string> > devices;
433 DeviceDescriptionsV::const_iterator
iter = idev->second.begin();
434 DeviceDescriptionsV::const_iterator jter = idev->second.end();
435 for ( ; iter != jter; ++
iter ) {
445 std::stringstream
data;
446 data << (*iter)->getDeviceType()
455 if (
find( devices[key].
begin(), devices[key].
end(), data.str() ) == devices[key].
end() ) {
456 devices[
key].push_back( data.str() );
462 std::map< uint32_t, std::vector<std::string> >
tmp;
463 std::map< uint32_t, std::vector<std::string> >::const_iterator
ii = devices.begin();
464 std::map< uint32_t, std::vector<std::string> >::const_iterator
jj = devices.end();
465 for ( ; ii !=
jj; ++
ii ) {
466 std::vector<std::string>
temp = ii->second;
468 std::vector<std::string>::const_iterator iii = temp.begin();
469 std::vector<std::string>::const_iterator jjj = temp.end();
470 for ( ; iii != jjj; ++iii ) { tmp[ii->first].push_back( *iii ); }
476 std::map< uint32_t, std::vector<std::string> >::const_iterator idev = devices.begin();
477 std::map< uint32_t, std::vector<std::string> >::const_iterator jdev = devices.end();
478 for ( ; idev != jdev; ++idev ) {
480 ss <<
" Found " << std::setw(3) << idev->second.size()
481 <<
" devices for FEC crate/slot/ring "
515 deviceDescription& desc =
const_cast<deviceDescription&
>(
description);
520 addr.
fecSlot_ =
static_cast<uint16_t
>( desc.getFecSlot() );
522 addr.
ccuAddr_ =
static_cast<uint16_t
>( desc.getCcuAddress() );
523 addr.
ccuChan_ =
static_cast<uint16_t
>( desc.getChannel() );
525 addr.
i2cAddr_ =
static_cast<uint16_t
>( desc.getAddress() );
526 }
catch (...) { handleException( __func__ ); }
534 if ( device_type == PLL ) {
return "PLL"; }
535 else if ( device_type == LASERDRIVER ) {
return "LLD"; }
536 else if ( device_type == DOH ) {
return "DOH"; }
537 else if ( device_type == APVMUX ) {
return "MUX"; }
538 else if ( device_type == APV25 ) {
return "APV"; }
539 else if ( device_type == DCU ) {
return "DCU"; }
540 else if ( device_type == GOH ) {
return "GOH"; }
541 else {
return "UNKNOWN DEVICE!"; }
static std::string defaultPartitionName_
const uint16_t & fecRing() const
void loadNext(K const &k, std::vector< T > const &v)
void addDeviceDescriptions(std::string partition, DeviceDescriptionsV &)
static const uint16_t FEC_RING_OFFSET
const uint16_t & lldChan() const
const uint16_t & fecSlot() const
void clearDeviceDescriptions(std::string partition="")
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::pair< uint32_t, uint32_t > Versions
const uint32_t & key() const
static const char mlConfigDb_[]
Utility class that identifies a position within the strip tracker control structure, down to the level of an APV25.
enumDeviceType DeviceType
DeviceDescriptions::range DeviceDescriptionsRange
DeviceAddress deviceAddress(const deviceDescription &)
const uint16_t & fecCrate() const
std::string deviceType(const enumDeviceType &device_type) const
std::vector< std::vector< double > > tmp
char data[epos_bytes_allocation]
void printDeviceDescriptions(std::string partition="")
static const uint16_t FEC_CRATE_OFFSET
volatile std::atomic< bool > shutdown_flag false
DeviceDescriptionsRange getDeviceDescriptions(std::string partition="")
void uploadDeviceDescriptions(std::string partition="")
std::vector< DeviceDescription * > DeviceDescriptionsV