8 using namespace sistrip;
15 if ( ( !dbParams_.usingDbCache() && !deviceFactory(__func__) ) ||
16 ( dbParams_.usingDbCache() && !databaseCache(__func__) ) ) {
17 return connections_.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 == connections_.emptyRange() ) {
39 deviceFactory(__func__)->getConnectionDescriptions( iter->second.partitionName(),
41 iter->second.cabVersion().first,
42 iter->second.cabVersion().second,
44 iter->second.maskVersion().first,
45 iter->second.maskVersion().second,
50 ConnectionFactory::vectorCopyI( tmp2, tmp1,
true );
53 connections_.loadNext( iter->second.partitionName(), tmp2 );
58 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
59 <<
" Downloaded " << conns.size()
60 <<
" FED connections to local cache for partition \""
61 << iter->second.partitionName() <<
"\"" << std::endl;
62 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
63 <<
" Cache holds FED connections for "
64 << connections_.size() <<
" partitions.";
81 ConnectionFactory::vectorCopyI( tmp2, *tmp1,
true );
88 <<
"[SiStripConfigDb::" << __func__ <<
"]"
89 <<
" NULL pointer to FedConnections vector!";
94 }
catch (...) { handleException( __func__ ); }
100 if ( partition !=
"" ) {
101 conns = connections_.find( partition );
105 if ( !connections_.empty() ) {
107 connections_.find( (--(dbParams_.partitions().end()))->second.partitionName() ).
end() );
108 }
else { conns = connections_.emptyRange(); }
109 np = connections_.size();
114 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
115 <<
" Found " << nc <<
" FED connections";
116 if ( !dbParams_.usingDb() ) { ss <<
" in " << dbParams_.inputModuleXmlFiles().size() <<
" 'module.xml' file(s)"; }
117 else {
if ( !dbParams_.usingDbCache() ) { ss <<
" in " << np <<
" database partition(s)"; }
118 else { ss <<
" from shared memory name '" << dbParams_.sharedMemory() <<
"'"; } }
130 if ( !deviceFactory(__func__) ) {
return; }
132 if ( partition.empty() ) {
134 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
135 <<
" Partition string is empty,"
136 <<
" therefore cannot add FED connections to local cache!";
141 if ( conns.empty() ) {
143 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
144 <<
" Vector of FED connections is empty,"
145 <<
" therefore cannot add FED connections to local cache!";
150 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
151 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
152 for ( ; iter != jter; ++iter ) {
if ( partition == iter->second.partitionName() ) {
break; } }
153 if ( iter == dbParams_.partitions().end() ) {
155 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
156 <<
" Partition \"" << partition
157 <<
"\" not found in partition list, "
158 <<
" therefore cannot add FED connections!";
164 if ( range == connections_.emptyRange() ) {
168 ConnectionFactory::vectorCopyI( tmp, conns,
true );
171 connections_.loadNext( partition, tmp );
174 std::stringstream ss;
175 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
176 <<
" Added " << conns.size()
177 <<
" FED connections to local cache for partition \""
178 << partition <<
"\"" << std::endl;
179 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
180 <<
" Cache holds FED connections for "
181 << connections_.size() <<
" partitions.";
186 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
187 <<
" Partition \"" << partition
188 <<
"\" already found in local cache, "
189 <<
" therefore cannot add new FED connections!";
200 if ( dbParams_.usingDbCache() ) {
202 <<
"[SiStripConfigDb::" << __func__ <<
"]"
203 <<
" Using database cache! No uploads allowed!";
207 if ( !deviceFactory(__func__) ) {
return; }
209 if ( connections_.empty() ) {
211 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
212 <<
" Found no cached FED connections, therefore no upload!";
217 if ( dbParams_.usingDb() ) {
221 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
222 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
223 for ( ; iter != jter; ++iter ) {
225 if ( partition ==
"" || partition == iter->second.partitionName() ) {
228 if ( range != connections_.emptyRange() ) {
233 deviceFactory(__func__)->setConnectionDescriptions( conns,
234 iter->second.partitionName(),
236 &(cabVersion.second),
240 std::stringstream ss;
241 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
242 <<
" Uploaded " << conns.size()
243 <<
" FED connections to database for partition \""
244 << iter->second.partitionName() <<
"\".";
249 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
250 <<
" Vector of FED connections is empty for partition \""
251 << iter->second.partitionName()
252 <<
"\", therefore aborting upload for this partition!";
269 }
catch (...) { handleException( __func__ ); }
273 allowCalibUpload_ =
true;
282 if ( connections_.empty() ) {
284 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
285 <<
" Found no cached FED connections!";
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 != connections_.emptyRange() ) {
314 if ( partition ==
"" ) {
315 if ( !connections_.empty() ) {
317 connections_.find( (--(dbParams_.partitions().end()))->second.partitionName() ).
end() );
318 }
else { conns = connections_.emptyRange(); }
320 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
321 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
322 for ( ; iter != jter; ++iter ) {
if ( partition == iter->second.partitionName() ) {
break; } }
323 conns = connections_.find( iter->second.partitionName() );
326 if ( conns != connections_.emptyRange() ) {
327 FedConnectionsV::const_iterator ifed = conns.begin();
328 FedConnectionsV::const_iterator jfed = conns.end();
329 for ( ; ifed != jfed; ++ifed ) {
if ( *ifed ) {
delete *ifed; } }
332 ss <<
"[SiStripConfigDb::" << __func__ <<
"]";
333 if ( partition ==
"" ) { ss <<
" Found no FED connections in local cache!"; }
334 else { ss <<
" Found no FED connections in local cache for partition \"" << partition <<
"\"!"; }
339 connections_ = temporary_cache;
347 std::stringstream ss;
348 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
349 <<
" Contents of FedConnections container:" << std::endl;
350 ss <<
" Number of partitions: " << connections_.size() << std::endl;
356 for ( ; iconn != jconn; ++iconn ) {
359 if ( partition ==
"" || partition == iconn->first ) {
361 ss <<
" Partition number : " << cntr <<
" (out of " << connections_.size() <<
")" << std::endl;
362 ss <<
" Partition name : \"" << iconn->first <<
"\"" << std::endl;
363 ss <<
" Num of connections : " << iconn->second.size() << std::endl;
366 std::map< uint16_t, vector<uint16_t> > feds;
367 FedConnectionsV::const_iterator iter = iconn->second.begin();
368 FedConnectionsV::const_iterator jter = iconn->second.end();
369 for ( ; iter != jter; ++iter ) {
371 uint16_t fed_id = (*iter)->getFedId();
372 uint16_t fed_ch = (*iter)->getFedChannel();
373 if (
find( feds[fed_id].
begin(), feds[fed_id].
end(), fed_ch ) == feds[fed_id].
end() ) {
374 feds[fed_id].push_back( fed_ch );
380 std::map< uint16_t, std::vector<uint16_t> >
tmp;
381 std::map< uint16_t, std::vector<uint16_t> >::const_iterator ii = feds.begin();
382 std::map< uint16_t, std::vector<uint16_t> >::const_iterator
jj = feds.end();
383 for ( ; ii !=
jj; ++ii ) {
384 std::vector<uint16_t>
temp = ii->second;
386 std::vector<uint16_t>::const_iterator iii = temp.begin();
387 std::vector<uint16_t>::const_iterator jjj = temp.end();
388 for ( ; iii != jjj; ++iii ) { tmp[ii->first].push_back( *iii ); }
394 std::map< uint16_t, std::vector<uint16_t> >::const_iterator ifed = feds.begin();
395 std::map< uint16_t, std::vector<uint16_t> >::const_iterator jfed = feds.end();
396 for ( ; ifed != jfed; ++ifed ) {
397 ss <<
" Found " << std::setw(2) << ifed->second.size()
398 <<
" channels for FED id " << std::setw(3) << ifed->first <<
" : ";
399 if ( !ifed->second.empty() ) {
400 uint16_t
first = ifed->second.front();
401 uint16_t
last = ifed->second.front();
402 std::vector<uint16_t>::const_iterator ichan = ifed->second.begin();
403 std::vector<uint16_t>::const_iterator jchan = ifed->second.end();
404 for ( ; ichan != jchan; ++ichan ) {
405 if ( ichan != ifed->second.begin() ) {
406 if ( *ichan != last+1 ) {
407 ss << std::setw(2) << first <<
"->" << std::setw(2) << last <<
", ";
408 if ( ichan != ifed->second.end() ) { first = *(ichan+1); }
413 if ( first != last ) { ss << std::setw(2) << first <<
"->" << std::setw(2) <<
last; }
static 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 &)