9 using namespace sistrip;
16 if ( ( !dbParams_.usingDbCache() && !deviceFactory(__func__) ) ||
17 ( dbParams_.usingDbCache() && !databaseCache(__func__) ) ) {
18 return feds_.emptyRange();
23 if ( !dbParams_.usingDbCache() ) {
25 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
26 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
27 for ( ; iter != jter; ++iter ) {
29 if ( partition ==
"" || partition == iter->second.partitionName() ) {
34 if ( range == feds_.emptyRange() ) {
37 deviceFactory(__func__)->setUsingStrips( usingStrips_ );
38 int16_t major = iter->second.fedVersion().first;
39 int16_t minor = iter->second.fedVersion().second;
40 if ( iter->second.fedVersion().first == 0 &&
41 iter->second.fedVersion().second == 0 ) {
48 tmp1 = *( deviceFactory(__func__)->getFed9UDescriptions( iter->second.partitionName(),
54 Fed9U::Fed9UDeviceFactory::vectorCopy( tmp2, tmp1 );
57 feds_.loadNext( iter->second.partitionName(), tmp2 );
62 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
63 <<
" Downloaded " << feds.size()
64 <<
" FED descriptions to local cache for partition \""
65 << iter->second.partitionName() <<
"\"" << std::endl;
66 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
67 <<
" Cache holds FED descriptions for "
68 << feds_.size() <<
" partitions.";
85 Fed9U::Fed9UDeviceFactory::vectorCopy( tmp2, *tmp1 );
92 <<
"[SiStripConfigDb::" << __func__ <<
"]"
93 <<
" NULL pointer to FED descriptions vector!";
98 }
catch (... ) { handleException( __func__ ); }
104 if ( partition !=
"" ) {
105 feds = feds_.find( partition );
109 if ( !feds_.empty() ) {
111 feds_.find( (--(dbParams_.partitions().end()))->second.partitionName() ).
end() );
112 }
else { feds = feds_.emptyRange(); }
118 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
119 <<
" Found " << nc <<
" FED descriptions";
120 if ( !dbParams_.usingDb() ) { ss <<
" in " << dbParams_.inputFedXmlFiles().size() <<
" 'fed.xml' file(s)"; }
121 else {
if ( !dbParams_.usingDbCache() ) { ss <<
" in " << np <<
" database partition(s)"; }
122 else { ss <<
" from shared memory name '" << dbParams_.sharedMemory() <<
"'"; } }
134 if ( !deviceFactory(__func__) ) {
return; }
136 if ( partition.empty() ) {
138 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
139 <<
" Partition string is empty,"
140 <<
" therefore cannot add FED descriptions to local cache!";
145 if ( feds.empty() ) {
147 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
148 <<
" Vector of FED descriptions is empty,"
149 <<
" therefore cannot add FED descriptions to local cache!";
154 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
155 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
156 for ( ; iter != jter; ++iter ) {
if ( partition == iter->second.partitionName() ) {
break; } }
157 if ( iter == dbParams_.partitions().end() ) {
159 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
160 <<
" Partition \"" << partition
161 <<
"\" not found in partition list, "
162 <<
" therefore cannot add FED descriptions!";
168 if ( range == feds_.emptyRange() ) {
172 Fed9U::Fed9UDeviceFactory::vectorCopy( tmp, feds );
175 feds_.loadNext( partition, tmp );
178 std::stringstream ss;
179 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
180 <<
" Added " << feds.size()
181 <<
" FED descriptions to local cache for partition \""
182 << iter->second.partitionName() <<
"\"" << std::endl;
183 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
184 <<
" Cache holds FED descriptions for "
185 << feds_.size() <<
" partitions.";
190 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
191 <<
" Partition \"" << partition
192 <<
"\" already found in local cache, "
193 <<
" therefore cannot add new FED descriptions!";
204 if ( dbParams_.usingDbCache() ) {
206 <<
"[SiStripConfigDb::" << __func__ <<
"]"
207 <<
" Using database cache! No uploads allowed!";
211 if ( !deviceFactory(__func__) ) {
return; }
213 if ( feds_.empty() ) {
215 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
216 <<
" Found no cached FED descriptions, therefore no upload!";
223 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
224 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
225 for ( ; iter != jter; ++iter ) {
227 if ( partition ==
"" || partition == iter->second.partitionName() ) {
230 if ( range != feds_.emptyRange() ) {
235 deviceFactory(__func__)->setFed9UDescriptions( feds,
236 iter->second.partitionName(),
237 (uint16_t*)(&(fedVersion.first)),
238 (uint16_t*)(&(fedVersion.second)),
242 std::stringstream ss;
243 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
244 <<
" Uploaded " << feds.size()
245 <<
" FED descriptions to database for partition \""
246 << iter->second.partitionName() <<
"\"";
251 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
252 <<
" Vector of FED descriptions is empty for partition \""
253 << iter->second.partitionName()
254 <<
"\", therefore aborting upload for this partition!";
271 }
catch (...) { handleException( __func__ ); }
273 allowCalibUpload_ =
true;
282 if ( feds_.empty() ) {
284 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
285 <<
" Found no cached FED descriptions!";
294 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
295 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
296 for ( ; iter != jter; ++iter ) {
297 if ( partition != iter->second.partitionName() ) {
299 if ( range != feds_.emptyRange() ) {
304 if ( range != feds_.emptyRange() ) {
306 <<
"[SiStripConfigDb::" << __func__ <<
"]"
307 <<
" Deleting FED descriptions for partition \""
308 << iter->second.partitionName()
309 <<
"\" from local cache...";
317 if ( partition ==
"" ) {
318 if ( !feds_.empty() ) {
320 feds_.find( (--(dbParams_.partitions().end()))->second.partitionName() ).
end() );
321 }
else { feds = feds_.emptyRange(); }
323 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
324 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
325 for ( ; iter != jter; ++iter ) {
if ( partition == iter->second.partitionName() ) {
break; } }
326 feds = feds_.find( iter->second.partitionName() );
329 if ( feds != feds_.emptyRange() ) {
330 FedDescriptionsV::const_iterator ifed = feds.begin();
331 FedDescriptionsV::const_iterator jfed = feds.end();
332 for ( ; ifed != jfed; ++ifed ) {
if ( *ifed ) {
delete *ifed; } }
335 ss <<
"[SiStripConfigDb::" << __func__ <<
"]";
336 if ( partition ==
"" ) { ss <<
" Found no FED descriptions in local cache!"; }
337 else { ss <<
" Found no FED descriptions in local cache for partition \"" << partition <<
"\"!"; }
342 feds_ = temporary_cache;
350 std::stringstream ss;
351 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
352 <<
" Contents of FedDescriptions container:" << std::endl;
353 ss <<
" Number of partitions: " << feds_.size() << std::endl;
359 for ( ; iconn != jconn; ++iconn ) {
362 if ( partition ==
"" || partition == iconn->first ) {
364 ss <<
" Partition number : " << cntr <<
" (out of " << feds_.size() <<
")" << std::endl;
365 ss <<
" Partition name : \"" << iconn->first <<
"\"" << std::endl;
366 ss <<
" Num of FED ids : " << iconn->second.size() << std::endl;
369 std::map< uint16_t, vector<uint16_t> > feds;
370 FedDescriptionsV::const_iterator iter = iconn->second.begin();
371 FedDescriptionsV::const_iterator jter = iconn->second.end();
372 for ( ; iter != jter; ++iter ) {
374 uint16_t
key = (*iter)->getCrateNumber();
375 uint16_t
data = (*iter)->getFedId();
376 if (
find( feds[key].
begin(), feds[key].
end(), data ) == feds[key].
end() ) {
377 feds[
key].push_back( data );
383 std::map< uint16_t, std::vector<uint16_t> >
tmp;
384 std::map< uint16_t, std::vector<uint16_t> >::const_iterator ii = feds.begin();
385 std::map< uint16_t, std::vector<uint16_t> >::const_iterator
jj = feds.end();
386 for ( ; ii !=
jj; ++ii ) {
387 std::vector<uint16_t>
temp = ii->second;
389 std::vector<uint16_t>::const_iterator iii = temp.begin();
390 std::vector<uint16_t>::const_iterator jjj = temp.end();
391 for ( ; iii != jjj; ++iii ) { tmp[ii->first].push_back( *iii ); }
397 std::map< uint16_t, std::vector<uint16_t> >::const_iterator ifed = feds.begin();
398 std::map< uint16_t, std::vector<uint16_t> >::const_iterator jfed = feds.end();
399 for ( ; ifed != jfed; ++ifed ) {
400 ss <<
" Found " << std::setw(2) << ifed->second.size()
401 <<
" FED ids for crate number " << std::setw(2) << ifed->first <<
" : ";
402 if ( !ifed->second.empty() ) {
403 uint16_t
first = ifed->second.front();
404 uint16_t
last = ifed->second.front();
405 std::vector<uint16_t>::const_iterator icrate = ifed->second.begin();
406 std::vector<uint16_t>::const_iterator jcrate = ifed->second.end();
407 for ( ; icrate != jcrate; ++icrate ) {
408 if ( icrate != ifed->second.begin() ) {
409 if ( *icrate != last+1 ) {
410 ss << std::setw(2) << first <<
"->" << std::setw(2) << last <<
", ";
411 if ( icrate != ifed->second.end() ) { first = *(icrate+1); }
416 if ( first != last ) { ss << std::setw(2) << first <<
"->" << std::setw(2) <<
last; }
435 if ( ( !dbParams_.usingDbCache() && !deviceFactory(__func__) ) ||
436 ( dbParams_.usingDbCache() && !databaseCache(__func__) ) ) {
437 return FedIdsRange( fedIds_.end(), fedIds_.end() );
443 bool using_strips = usingStrips_;
444 if ( factory_ ) { factory_->setUsingStrips(
false ); }
446 if ( factory_ ) { factory_->setUsingStrips( using_strips ); }
448 if ( !feds.empty() ) {
449 FedDescriptionsV::const_iterator ifed = feds.begin();
450 FedDescriptionsV::const_iterator jfed = feds.end();
451 for ( ; ifed != jfed; ++ifed ) {
452 if ( *ifed ) { fedIds_.push_back( (*ifed)->getFedId() ); }
455 <<
"[SiStripConfigDb::" << __func__ <<
"]"
456 <<
" NULL pointer to FedDescription!";
462 }
catch (...) { handleException( __func__ ); }
464 if ( fedIds_.empty() ) {
466 <<
"[SiStripConfigDb::" << __func__ <<
"]"
467 <<
" No FED ids found!";
470 return FedIdsRange( fedIds_.begin(), fedIds_.end() );
static 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