7 using namespace sistrip;
14 if ( ( !dbParams_.usingDbCache() && !deviceFactory(__func__) ) ||
15 ( dbParams_.usingDbCache() && !databaseCache(__func__) ) ) {
16 return connections_.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 == connections_.emptyRange() ) {
38 deviceFactory(__func__)->getConnectionDescriptions( iter->second.partitionName(),
40 iter->second.cabVersion().first,
41 iter->second.cabVersion().second,
43 iter->second.maskVersion().first,
44 iter->second.maskVersion().second,
49 ConnectionFactory::vectorCopyI( tmp2, tmp1,
true );
52 connections_.loadNext( iter->second.partitionName(), tmp2 );
57 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
58 <<
" Downloaded " << conns.size()
59 <<
" FED connections to local cache for partition \""
60 << iter->second.partitionName() <<
"\"" << std::endl;
61 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
62 <<
" Cache holds FED connections for "
63 << connections_.size() <<
" partitions.";
80 ConnectionFactory::vectorCopyI( tmp2, *tmp1,
true );
87 <<
"[SiStripConfigDb::" << __func__ <<
"]"
88 <<
" NULL pointer to FedConnections vector!";
93 }
catch (...) { handleException( __func__ ); }
99 if ( partition !=
"" ) {
100 conns = connections_.find( partition );
104 if ( !connections_.empty() ) {
106 connections_.find( (--(dbParams_.partitions().end()))->second.partitionName() ).
end() );
107 }
else { conns = connections_.emptyRange(); }
108 np = connections_.size();
113 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
114 <<
" Found " << nc <<
" FED connections";
115 if ( !dbParams_.usingDb() ) { ss <<
" in " << dbParams_.inputModuleXmlFiles().size() <<
" 'module.xml' file(s)"; }
116 else {
if ( !dbParams_.usingDbCache() ) { ss <<
" in " << np <<
" database partition(s)"; }
117 else { ss <<
" from shared memory name '" << dbParams_.sharedMemory() <<
"'"; } }
129 if ( !deviceFactory(__func__) ) {
return; }
131 if ( partition.empty() ) {
133 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
134 <<
" Partition string is empty,"
135 <<
" therefore cannot add FED connections to local cache!";
140 if ( conns.empty() ) {
142 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
143 <<
" Vector of FED connections is empty,"
144 <<
" therefore cannot add FED connections to local cache!";
149 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
150 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
151 for ( ; iter != jter; ++iter ) {
if ( partition == iter->second.partitionName() ) {
break; } }
152 if ( iter == dbParams_.partitions().end() ) {
154 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
155 <<
" Partition \"" << partition
156 <<
"\" not found in partition list, "
157 <<
" therefore cannot add FED connections!";
163 if ( range == connections_.emptyRange() ) {
167 ConnectionFactory::vectorCopyI( tmp, conns,
true );
170 connections_.loadNext( partition, tmp );
173 std::stringstream
ss;
174 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
175 <<
" Added " << conns.size()
176 <<
" FED connections to local cache for partition \""
177 << partition <<
"\"" << std::endl;
178 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
179 <<
" Cache holds FED connections for "
180 << connections_.size() <<
" partitions.";
185 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
186 <<
" Partition \"" << partition
187 <<
"\" already found in local cache, "
188 <<
" therefore cannot add new FED connections!";
199 if ( dbParams_.usingDbCache() ) {
201 <<
"[SiStripConfigDb::" << __func__ <<
"]"
202 <<
" Using database cache! No uploads allowed!";
206 if ( !deviceFactory(__func__) ) {
return; }
208 if ( connections_.empty() ) {
210 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
211 <<
" Found no cached FED connections, therefore no upload!";
216 if ( dbParams_.usingDb() ) {
220 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
221 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
222 for ( ; iter != jter; ++iter ) {
224 if ( partition ==
"" || partition == iter->second.partitionName() ) {
227 if ( range != connections_.emptyRange() ) {
232 deviceFactory(__func__)->setConnectionDescriptions( conns,
233 iter->second.partitionName(),
235 &(cabVersion.second),
239 std::stringstream
ss;
240 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
241 <<
" Uploaded " << conns.size()
242 <<
" FED connections to database for partition \""
243 << iter->second.partitionName() <<
"\".";
248 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
249 <<
" Vector of FED connections is empty for partition \""
250 << iter->second.partitionName()
251 <<
"\", therefore aborting upload for this partition!";
268 }
catch (...) { handleException( __func__ ); }
272 allowCalibUpload_ =
true;
281 if ( connections_.empty() ) {
283 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
284 <<
" Found no cached FED connections!";
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 != connections_.emptyRange() ) {
313 if ( partition ==
"" ) {
314 if ( !connections_.empty() ) {
316 connections_.find( (--(dbParams_.partitions().end()))->second.partitionName() ).
end() );
317 }
else { conns = connections_.emptyRange(); }
319 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
320 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
321 for ( ; iter != jter; ++iter ) {
if ( partition == iter->second.partitionName() ) {
break; } }
322 conns = connections_.find( iter->second.partitionName() );
325 if ( conns != connections_.emptyRange() ) {
326 FedConnectionsV::const_iterator ifed = conns.begin();
327 FedConnectionsV::const_iterator jfed = conns.end();
328 for ( ; ifed != jfed; ++ifed ) {
if ( *ifed ) {
delete *ifed; } }
331 ss <<
"[SiStripConfigDb::" << __func__ <<
"]";
332 if ( partition ==
"" ) { ss <<
" Found no FED connections in local cache!"; }
333 else { ss <<
" Found no FED connections in local cache for partition \"" << partition <<
"\"!"; }
338 connections_ = temporary_cache;
346 std::stringstream
ss;
347 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
348 <<
" Contents of FedConnections container:" << std::endl;
349 ss <<
" Number of partitions: " << connections_.size() << std::endl;
355 for ( ; iconn != jconn; ++iconn ) {
358 if ( partition ==
"" || partition == iconn->first ) {
360 ss <<
" Partition number : " << cntr <<
" (out of " << connections_.size() <<
")" << std::endl;
361 ss <<
" Partition name : \"" << iconn->first <<
"\"" << std::endl;
362 ss <<
" Num of connections : " << iconn->second.size() << std::endl;
365 std::map< uint16_t, vector<uint16_t> >
feds;
366 FedConnectionsV::const_iterator iter = iconn->second.begin();
367 FedConnectionsV::const_iterator jter = iconn->second.end();
368 for ( ; iter != jter; ++iter ) {
370 uint16_t fed_id = (*iter)->getFedId();
371 uint16_t fed_ch = (*iter)->getFedChannel();
372 if (
find( feds[fed_id].
begin(), feds[fed_id].
end(), fed_ch ) == feds[fed_id].
end() ) {
373 feds[fed_id].push_back( fed_ch );
379 std::map< uint16_t, std::vector<uint16_t> >
tmp;
380 std::map< uint16_t, std::vector<uint16_t> >::const_iterator
ii = feds.begin();
381 std::map< uint16_t, std::vector<uint16_t> >::const_iterator
jj = feds.end();
382 for ( ; ii !=
jj; ++
ii ) {
383 std::vector<uint16_t>
temp = ii->second;
384 std::sort( temp.begin(), temp.end() );
385 std::vector<uint16_t>::const_iterator iii = temp.begin();
386 std::vector<uint16_t>::const_iterator jjj = temp.end();
387 for ( ; iii != jjj; ++iii ) { tmp[ii->first].push_back( *iii ); }
393 std::map< uint16_t, std::vector<uint16_t> >::const_iterator ifed = feds.begin();
394 std::map< uint16_t, std::vector<uint16_t> >::const_iterator jfed = feds.end();
395 for ( ; ifed != jfed; ++ifed ) {
396 ss <<
" Found " << std::setw(2) << ifed->second.size()
397 <<
" channels for FED id " << std::setw(3) << ifed->first <<
" : ";
398 if ( !ifed->second.empty() ) {
399 uint16_t
first = ifed->second.front();
400 uint16_t
last = ifed->second.front();
401 std::vector<uint16_t>::const_iterator ichan = ifed->second.begin();
402 std::vector<uint16_t>::const_iterator jchan = ifed->second.end();
403 for ( ; ichan != jchan; ++ichan ) {
404 if ( ichan != ifed->second.begin() ) {
405 if ( *ichan != last+1 ) {
406 ss << std::setw(2) << first <<
"->" << std::setw(2) << last <<
", ";
407 if ( ichan != ifed->second.end() ) { first = *(ichan+1); }
412 if ( first != last ) { ss << std::setw(2) << first <<
"->" << std::setw(2) <<
last; }
static const std::string defaultPartitionName_
void loadNext(K const &k, std::vector< T > const &v)
void uploadFedConnections(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
FedConnections::range FedConnectionsRange
static const char mlConfigDb_[]
FedConnectionsRange getFedConnections(std::string partition="")
void clearFedConnections(std::string partition="")
void printFedConnections(std::string partition="")
std::vector< std::vector< double > > tmp
std::vector< FedConnection * > FedConnectionsV
void addFedConnections(std::string partition, FedConnectionsV &)
volatile std::atomic< bool > shutdown_flag false