8 using namespace sistrip;
15 if ( ( !dbParams_.usingDbCache() && !deviceFactory(__func__) ) ||
16 ( dbParams_.usingDbCache() && !databaseCache(__func__) ) ) {
17 return devices_.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 == devices_.emptyRange() ) {
37 deviceFactory(__func__)->getFecDeviceDescriptions( iter->second.partitionName(),
39 iter->second.fecVersion().first,
40 iter->second.fecVersion().second,
41 #ifdef USING_DATABASE_MASKING
42 iter->second.maskVersion().first,
43 iter->second.maskVersion().second,
49 FecFactory::vectorCopyI( tmp2, tmp1,
true );
52 devices_.loadNext( iter->second.partitionName(), tmp2 );
57 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
58 <<
" Downloaded " << range.size()
59 <<
" device descriptions to local cache for partition \""
60 << iter->second.partitionName() <<
"\"" << std::endl;
61 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
62 <<
" Cache holds device descriptions for "
63 << devices_.size() <<
" partitions.";
80 FecFactory::vectorCopyI( tmp2, *tmp1,
true );
87 <<
"[SiStripConfigDb::" << __func__ <<
"]"
88 <<
" NULL pointer to DeviceDescriptions vector!";
93 }
catch (...) { handleException( __func__ ); }
99 if ( partition !=
"" ) {
100 devs = devices_.find( partition );
104 if ( !devices_.empty() ) {
106 devices_.find( (--(dbParams_.partitions().end()))->second.partitionName() ).
end() );
107 }
else { devs = devices_.emptyRange(); }
108 np = devices_.size();
113 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
114 <<
" Found " << nc <<
" device descriptions";
115 if ( !dbParams_.usingDb() ) { ss <<
" in " << dbParams_.inputFecXmlFiles().size() <<
" 'fec.xml' file(s)"; }
116 else {
if ( !dbParams_.usingDbCache() ) { ss <<
" in " << np <<
" database partition(s)"; }
117 else { ss <<
" from shared memory name '" << dbParams_.sharedMemory() <<
"'"; } }
128 std::string partition ) {
130 typedDevices_.clear();
140 if ( ( !dbParams_.usingDbCache() && !deviceFactory(__func__) ) ||
141 ( dbParams_.usingDbCache() && !databaseCache(__func__) ) ) {
147 if ( !devs.empty() ) {
149 typedDevices_ = FecFactory::getDeviceFromDeviceVector(
tmp, device_type );
151 }
catch (...) { handleException( __func__ ); }
153 if ( device_type == APV25 ) {
154 apvDevices_.swap( typedDevices_ );
156 }
else if ( device_type == APVMUX ) {
157 muxDevices_.swap( typedDevices_ );
159 }
else if ( device_type == DCU ) {
160 dcuDevices_.swap( typedDevices_ );
162 }
else if ( device_type == LASERDRIVER ) {
163 lldDevices_.swap( typedDevices_ );
165 }
else if ( device_type == PLL ) {
166 pllDevices_.swap( typedDevices_ );
168 }
else if ( device_type == DOH ) {
169 dohDevices_.swap( typedDevices_ );
188 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
189 <<
" Extracted " <<
tmp.size()
190 <<
" device descriptions (for devices of type "
191 << deviceType( device_type ) <<
")";
202 if ( !deviceFactory(__func__) ) {
return; }
204 if ( partition.empty() ) {
206 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
207 <<
" Partition string is empty,"
208 <<
" therefore cannot add device descriptions to local cache!";
213 if ( devs.empty() ) {
215 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
216 <<
" Vector of device descriptions is empty,"
217 <<
" therefore cannot add device descriptions to local cache!";
222 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
223 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
224 for ( ; iter != jter; ++iter ) {
if ( partition == iter->second.partitionName() ) {
break; } }
225 if ( iter == dbParams_.partitions().end() ) {
227 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
228 <<
" Partition \"" << partition
229 <<
"\" not found in partition list, "
230 <<
" therefore cannot add device descriptions!";
236 if ( range == devices_.emptyRange() ) {
240 FecFactory::vectorCopyI( tmp, devs,
true );
243 devices_.loadNext( partition, tmp );
246 std::stringstream ss;
247 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
248 <<
" Added " << devs.size()
249 <<
" device descriptions to local cache for partition \""
250 << partition <<
"\"."
251 <<
" (Cache holds device descriptions for "
252 << devices_.size() <<
" partitions.)";
257 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
258 <<
" Partition \"" << partition
259 <<
"\" already found in local cache, "
260 <<
" therefore cannot add device descriptions!";
271 if ( dbParams_.usingDbCache() ) {
273 <<
"[SiStripConfigDb::" << __func__ <<
"]"
274 <<
" Using database cache! No uploads allowed!";
278 if ( !deviceFactory(__func__) ) {
return; }
280 if ( devices_.empty() ) {
282 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
283 <<
" Found no cached device descriptions, therefore no upload!";
290 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
291 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
292 for ( ; iter != jter; ++iter ) {
294 if ( partition ==
"" || partition == iter->second.partitionName() ) {
297 if ( range != devices_.emptyRange() ) {
301 deviceFactory(__func__)->setFecDeviceDescriptions( devs,
302 iter->second.partitionName(),
303 &(iter->second.fecVersion().first),
304 &(iter->second.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)
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
void printDeviceDescriptions(std::string partition="")
static const uint16_t FEC_CRATE_OFFSET
DeviceDescriptionsRange getDeviceDescriptions(std::string partition="")
void uploadDeviceDescriptions(std::string partition="")
std::vector< DeviceDescription * > DeviceDescriptionsV