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,
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() <<
"'"; } }
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() ) {
302 deviceFactory(__func__)->setFecDeviceDescriptions( devs,
303 iter->second.partitionName(),
305 &(fecVersion.second),
309 std::stringstream ss;
310 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
311 <<
" Uploaded " << devs.size()
312 <<
" device descriptions to database for partition \""
313 << iter->second.partitionName() <<
"\".";
318 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
319 <<
" Vector of device descriptions is empty for partition \""
320 << iter->second.partitionName()
321 <<
"\", therefore aborting upload for this partition!";
338 }
catch (...) { handleException( __func__ ); }
340 allowCalibUpload_ =
true;
349 if ( devices_.empty() ) {
351 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
352 <<
" Found no cached device descriptions!";
361 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
362 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
363 for ( ; iter != jter; ++iter ) {
364 if ( partition != iter->second.partitionName() ) {
366 if ( range != devices_.emptyRange() ) {
381 if ( partition ==
"" ) {
382 if ( !devices_.empty() ) {
384 devices_.find( (--(dbParams_.partitions().end()))->second.partitionName() ).
end() );
385 }
else { devs = devices_.emptyRange(); }
387 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
388 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
389 for ( ; iter != jter; ++iter ) {
if ( partition == iter->second.partitionName() ) {
break; } }
390 devs = devices_.find( iter->second.partitionName() );
393 if ( devs != devices_.emptyRange() ) {
394 DeviceDescriptionsV::const_iterator ifed = devs.begin();
395 DeviceDescriptionsV::const_iterator jfed = devs.end();
396 for ( ; ifed != jfed; ++ifed ) {
if ( *ifed ) {
delete *ifed; } }
399 ss <<
"[SiStripConfigDb::" << __func__ <<
"]";
400 if ( partition ==
"" ) { ss <<
" Found no device descriptions in local cache!"; }
401 else { ss <<
" Found no device descriptions in local cache for partition \"" << partition <<
"\"!"; }
406 devices_ = temporary_cache;
414 std::stringstream ss;
415 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
416 <<
" Contents of DeviceDescriptions container:" << std::endl;
417 ss <<
" Number of partitions: " << devices_.size() << std::endl;
423 for ( ; idev != jdev; ++idev ) {
426 if ( partition ==
"" || partition == idev->first ) {
428 ss <<
" Partition number : " << cntr <<
" (out of " << devices_.size() <<
")" << std::endl;
429 ss <<
" Partition name : \"" << idev->first <<
"\"" << std::endl;
430 ss <<
" Num of devices : " << idev->second.size() << std::endl;
433 std::map< uint32_t, vector<std::string> > devices;
434 DeviceDescriptionsV::const_iterator iter = idev->second.begin();
435 DeviceDescriptionsV::const_iterator jter = idev->second.end();
436 for ( ; iter != jter; ++iter ) {
446 std::stringstream
data;
447 data << (*iter)->getDeviceType()
456 if (
find( devices[key].
begin(), devices[key].
end(), data.str() ) == devices[key].
end() ) {
457 devices[
key].push_back( data.str() );
463 std::map< uint32_t, std::vector<std::string> >
tmp;
464 std::map< uint32_t, std::vector<std::string> >::const_iterator
ii = devices.begin();
465 std::map< uint32_t, std::vector<std::string> >::const_iterator
jj = devices.end();
466 for ( ; ii !=
jj; ++
ii ) {
467 std::vector<std::string>
temp = ii->second;
469 std::vector<std::string>::const_iterator iii = temp.begin();
470 std::vector<std::string>::const_iterator jjj = temp.end();
471 for ( ; iii != jjj; ++iii ) { tmp[ii->first].push_back( *iii ); }
477 std::map< uint32_t, std::vector<std::string> >::const_iterator idev = devices.begin();
478 std::map< uint32_t, std::vector<std::string> >::const_iterator jdev = devices.end();
479 for ( ; idev != jdev; ++idev ) {
481 ss <<
" Found " << std::setw(3) << idev->second.size()
482 <<
" devices for FEC crate/slot/ring "
516 deviceDescription& desc =
const_cast<deviceDescription&
>(
description);
521 addr.
fecSlot_ =
static_cast<uint16_t
>( desc.getFecSlot() );
523 addr.
ccuAddr_ =
static_cast<uint16_t
>( desc.getCcuAddress() );
524 addr.
ccuChan_ =
static_cast<uint16_t
>( desc.getChannel() );
526 addr.
i2cAddr_ =
static_cast<uint16_t
>( desc.getAddress() );
527 }
catch (...) { handleException( __func__ ); }
535 if ( device_type == PLL ) {
return "PLL"; }
536 else if ( device_type == LASERDRIVER ) {
return "LLD"; }
537 else if ( device_type == DOH ) {
return "DOH"; }
538 else if ( device_type == APVMUX ) {
return "MUX"; }
539 else if ( device_type == APV25 ) {
return "APV"; }
540 else if ( device_type == DCU ) {
return "DCU"; }
541 else if ( device_type == GOH ) {
return "GOH"; }
542 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
DeviceDescriptionsRange getDeviceDescriptions(std::string partition="")
void uploadDeviceDescriptions(std::string partition="")
std::vector< DeviceDescription * > DeviceDescriptionsV