24 if ( ( !dbParams_.usingDbCache() && !deviceFactory(__func__) ) ||
25 ( dbParams_.usingDbCache() && !databaseCache(__func__) ) ) {
26 return analyses_.emptyRange();
31 if ( !dbParams_.usingDbCache() ) {
33 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
34 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
35 for ( ; iter != jter; ++iter ) {
37 if ( partition.empty() || partition == iter->second.partitionName() ) {
42 if ( range == analyses_.emptyRange() ) {
45 if ( analysis_type == AnalysisDescription::T_ANALYSIS_FASTFEDCABLING ) {
46 tmp1 = deviceFactory(__func__)->getAnalysisHistory( iter->second.partitionName(),
47 iter->second.fastCablingVersion().first,
48 iter->second.fastCablingVersion().second,
50 }
else if ( analysis_type == AnalysisDescription::T_ANALYSIS_TIMING ) {
51 tmp1 = deviceFactory(__func__)->getAnalysisHistory( iter->second.partitionName(),
52 iter->second.apvTimingVersion().first,
53 iter->second.apvTimingVersion().second,
55 }
else if ( analysis_type == AnalysisDescription::T_ANALYSIS_OPTOSCAN ) {
56 tmp1 = deviceFactory(__func__)->getAnalysisHistory( iter->second.partitionName(),
57 iter->second.optoScanVersion().first,
58 iter->second.optoScanVersion().second,
60 }
else if ( analysis_type == AnalysisDescription::T_ANALYSIS_VPSPSCAN ) {
61 tmp1 = deviceFactory(__func__)->getAnalysisHistory( iter->second.partitionName(),
62 iter->second.vpspScanVersion().first,
63 iter->second.vpspScanVersion().second,
65 }
else if ( analysis_type == AnalysisDescription::T_ANALYSIS_CALIBRATION ) {
66 tmp1 = deviceFactory(__func__)->getAnalysisHistory( iter->second.partitionName(),
67 iter->second.apvCalibVersion().first,
68 iter->second.apvCalibVersion().second,
70 }
else if ( analysis_type == AnalysisDescription::T_ANALYSIS_PEDESTALS ) {
71 tmp1 = deviceFactory(__func__)->getAnalysisHistory( iter->second.partitionName(),
72 iter->second.pedestalsVersion().first,
73 iter->second.pedestalsVersion().second,
75 }
else if ( analysis_type == AnalysisDescription::T_ANALYSIS_PEDSFULLNOISE ) {
76 tmp1 = deviceFactory(__func__)->getAnalysisHistory( iter->second.partitionName(),
77 iter->second.pedestalsVersion().first,
78 iter->second.pedestalsVersion().second,
80 }
else if ( analysis_type == AnalysisDescription::T_ANALYSIS_APVLATENCY ) {
81 tmp1 = deviceFactory(__func__)->getAnalysisHistory( iter->second.partitionName(),
82 iter->second.apvLatencyVersion().first,
83 iter->second.apvLatencyVersion().second,
85 }
else if ( analysis_type == AnalysisDescription::T_ANALYSIS_FINEDELAY ) {
86 tmp1 = deviceFactory(__func__)->getAnalysisHistory( iter->second.partitionName(),
87 iter->second.fineDelayVersion().first,
88 iter->second.fineDelayVersion().second,
92 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 93 <<
" Unexpected analysis type \"" 94 << analysisType( analysis_type )
95 <<
"\"! Aborting download...";
97 return analyses_.emptyRange();
102 CommissioningAnalysisFactory::vectorCopy( tmp1, tmp2 );
105 analyses_.loadNext( iter->second.partitionName(), tmp2 );
109 std::stringstream ss;
110 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 111 <<
" Downloaded " << anals.size()
112 <<
" analysis descriptions of type \"" 113 << analysisType( analysis_type )
114 <<
"\" to local cache for partition \"" 115 << iter->second.partitionName() <<
"\"" << std::endl;
116 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 117 <<
" Cache holds analysis descriptions for " 118 << analyses_.size() <<
" partitions.";
126 std::stringstream ss;
127 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 128 <<
" No database cache for analysis objects!";
132 }
catch (...) { handleException( __func__ ); }
138 if ( !partition.empty() ) {
139 anals = analyses_.find( partition );
143 if ( !analyses_.empty() ) {
145 analyses_.find( (--(dbParams_.partitions().end()))->second.partitionName() ).
end() );
146 }
else { anals = analyses_.emptyRange(); }
147 np = analyses_.size();
152 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 153 <<
" Found " << nc <<
" analysis descriptions";
154 if ( !dbParams_.usingDbCache() ) { ss <<
" in " << np <<
" database partition(s)"; }
155 else { ss <<
" from shared memory name '" << dbParams_.sharedMemory() <<
"'"; }
167 if ( !deviceFactory(__func__) ) {
return; }
169 if ( partition.empty() ) {
171 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 172 <<
" Partition string is empty," 173 <<
" therefore cannot add analysis descriptions to local cache!";
178 if ( anals.empty() ) {
180 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 181 <<
" Vector of analysis descriptions is empty," 182 <<
" therefore cannot add analysis descriptions to local cache!";
187 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
188 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
189 for ( ; iter != jter; ++iter ) {
if ( partition == iter->second.partitionName() ) {
break; } }
190 if ( iter == dbParams_.partitions().end() ) {
192 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 193 <<
" Partition \"" << partition
194 <<
"\" not found in partition list, " 195 <<
" therefore cannot add analysis descriptions!";
201 if ( range == analyses_.emptyRange() ) {
205 CommissioningAnalysisFactory::vectorCopy( anals, tmp );
208 analyses_.loadNext( partition, tmp );
211 std::stringstream ss;
212 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 213 <<
" Added " << anals.size()
214 <<
" analysis descriptions to local cache for partition \"" 215 << partition <<
"\"." 216 <<
" (Cache holds analysis descriptions for " 217 << analyses_.size() <<
" partitions.)";
221 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 222 <<
" Partition \"" << partition
223 <<
"\" already found in local cache, " 224 <<
" therefore cannot add analysis descriptions!";
236 if ( dbParams_.usingDbCache() ) {
238 <<
"[SiStripConfigDb::" << __func__ <<
"]" 239 <<
" Using database cache! No uploads allowed!";
243 if ( !deviceFactory(__func__) ) {
return; }
245 if ( analyses_.empty() ) {
247 <<
"[SiStripConfigDb::" << __func__ <<
"]" 248 <<
" Found no cached analysis descriptions, therefore no upload!";
252 if ( calibration_for_physics && !allowCalibUpload_ ) {
254 <<
"[SiStripConfigDb::" << __func__ <<
"]" 255 <<
" Attempting to upload calibration constants" 256 <<
" without uploading any hardware descriptions!" 257 <<
" Aborting upload...";
259 }
else { allowCalibUpload_ =
false; }
263 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
264 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
265 for ( ; iter != jter; ++iter ) {
267 if ( partition.empty() || partition == iter->second.partitionName() ) {
270 if ( range != analyses_.emptyRange() ) {
274 vector<AnalysisType> analysis_type;
275 for(
auto element : anals){
276 if(
std::find(analysis_type.begin(),analysis_type.end(),element->getType()) == analysis_type.end() and element->getType() != AnalysisDescription::T_UNKNOWN){
277 analysis_type.push_back(element->getType());
279 else if(element->getType() == AnalysisDescription::T_UNKNOWN){
281 <<
"[SiStripConfigDb::" << __func__ <<
"]" 282 <<
" Analysis type is UNKNOWN. Aborting upload!";
287 vector<AnalysisDescriptionsV> analysisToUpload;
288 for(
auto type : analysis_type){
290 for(
auto element : anals){
291 if(element->getType() ==
type)
292 ana_temp.push_back(element);
294 analysisToUpload.push_back(ana_temp);
298 for(
auto analysis : analysisToUpload){
300 uint32_t
version = deviceFactory(__func__)->uploadAnalysis( iter->second.runNumber(),
301 iter->second.partitionName(),
302 analysis.front()->getType(),
304 calibration_for_physics);
306 if ( calibration_for_physics ) { deviceFactory(__func__)->uploadAnalysisState( version );}
310 std::stringstream ss;
311 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 312 <<
" Uploaded " << anals.size()
313 <<
" device descriptions to database for partition \"" 314 << iter->second.partitionName() <<
"\".";
319 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 320 <<
" Vector of device descriptions is empty for partition \"" 321 << iter->second.partitionName()
322 <<
"\", therefore aborting upload for this partition!";
337 }
catch (...) { handleException( __func__ ); }
339 allowCalibUpload_ =
true;
348 if ( analyses_.empty() ) {
350 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 351 <<
" Found no cached analysis 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 != analyses_.emptyRange() ) {
380 if ( partition.empty() ) {
381 if ( !analyses_.empty() ) {
383 analyses_.find( (--(dbParams_.partitions().end()))->second.partitionName() ).
end() );
384 }
else { anals = analyses_.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 anals = analyses_.find( iter->second.partitionName() );
392 if ( anals != analyses_.emptyRange() ) {
393 AnalysisDescriptionsV::const_iterator ianal = anals.begin();
394 AnalysisDescriptionsV::const_iterator janal = anals.end();
395 for ( ; ianal != janal; ++ianal ) {
if ( *ianal ) {
delete *ianal; } }
398 ss <<
"[SiStripConfigDb::" << __func__ <<
"]";
399 if ( partition.empty() ) { ss <<
" Found no analysis descriptions in local cache!"; }
400 else { ss <<
" Found no analysis descriptions in local cache for partition \"" << partition <<
"\"!"; }
405 analyses_ = temporary_cache;
413 std::stringstream ss;
414 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 415 <<
" Contents of AnalysisDescriptions container:" << std::endl;
416 ss <<
" Number of partitions: " << analyses_.size() << std::endl;
422 for ( ; ianal != janal; ++ianal ) {
425 if ( partition.empty() || partition == ianal->first ) {
427 ss <<
" Partition number : " << cntr <<
" (out of " << analyses_.size() <<
")" << std::endl;
428 ss <<
" Partition name : \"" << ianal->first <<
"\"" << std::endl;
429 ss <<
" Num of analyses : " << ianal->second.size() << std::endl;
432 std::map< uint32_t, vector<uint32_t> > analyses;
433 AnalysisDescriptionsV::const_iterator iter = ianal->second.begin();
434 AnalysisDescriptionsV::const_iterator jter = ianal->second.end();
435 for ( ; iter != jter; ++iter ) {
452 if (
find( analyses[key].
begin(), analyses[key].
end(), data ) == analyses[key].
end() ) {
453 analyses[
key].push_back( data );
459 std::map< uint32_t, std::vector<uint32_t> >
tmp;
460 std::map< uint32_t, std::vector<uint32_t> >::const_iterator
ii = analyses.begin();
461 std::map< uint32_t, std::vector<uint32_t> >::const_iterator
jj = analyses.end();
462 for ( ; ii !=
jj; ++
ii ) {
463 std::vector<uint32_t>
temp = ii->second;
464 std::sort( temp.begin(), temp.end() );
465 std::vector<uint32_t>::const_iterator iii = temp.begin();
466 std::vector<uint32_t>::const_iterator jjj = temp.end();
467 for ( ; iii != jjj; ++iii ) { tmp[ii->first].push_back( *iii ); }
473 std::map< uint32_t, std::vector<uint32_t> >::const_iterator ianal = analyses.begin();
474 std::map< uint32_t, std::vector<uint32_t> >::const_iterator janal = analyses.end();
475 for ( ; ianal != janal; ++ianal ) {
477 ss <<
" Found " << std::setw(3) << ianal->second.size()
478 <<
" analyses for FEC crate/slot/ring " 515 addr.
fecSlot_ =
static_cast<uint16_t
>( desc.getSlot() );
517 addr.
ccuAddr_ =
static_cast<uint16_t
>( desc.getCcuAdr() );
518 addr.
ccuChan_ =
static_cast<uint16_t
>( desc.getCcuChan() );
520 addr.
i2cAddr_ =
static_cast<uint16_t
>( desc.getI2cAddr() );
521 addr.
fedId_ =
static_cast<uint16_t
>( desc.getFedId() );
522 addr.
feUnit_ =
static_cast<uint16_t
>( desc.getFeUnit() );
523 addr.
feChan_ =
static_cast<uint16_t
>( desc.getFeChan() );
524 }
catch (...) { handleException( __func__ ); }
532 if ( analysis_type == AnalysisDescription::T_ANALYSIS_FASTFEDCABLING ) {
return "FAST_CABLING"; }
533 else if ( analysis_type == AnalysisDescription::T_ANALYSIS_TIMING ) {
return "APV_TIMING"; }
534 else if ( analysis_type == AnalysisDescription::T_ANALYSIS_OPTOSCAN ) {
return "OPTO_SCAN"; }
535 else if ( analysis_type == AnalysisDescription::T_ANALYSIS_PEDESTALS ) {
return "PEDESTALS"; }
536 else if ( analysis_type == AnalysisDescription::T_ANALYSIS_PEDSFULLNOISE ) {
return "PEDSFULLNOISE"; }
537 else if ( analysis_type == AnalysisDescription::T_ANALYSIS_APVLATENCY ) {
return "APV_LATENCY"; }
538 else if ( analysis_type == AnalysisDescription::T_ANALYSIS_FINEDELAY ) {
return "FINE_DELAY"; }
539 else if ( analysis_type == AnalysisDescription::T_ANALYSIS_CALIBRATION ) {
return "CALIBRATION"; }
540 else if ( analysis_type == AnalysisDescription::T_UNKNOWN ) {
return "UNKNOWN ANALYSIS TYPE"; }
541 else {
return "UNDEFINED ANALYSIS TYPE"; }
static const std::string defaultPartitionName_
const uint16_t & fecRing() const
void loadNext(K const &k, std::vector< T > const &v)
void uploadAnalysisDescriptions(bool calibration_for_physics=false, std::string partition="")
void addAnalysisDescriptions(std::string partition, AnalysisDescriptionsV &)
static const uint16_t FEC_RING_OFFSET
const uint16_t & lldChan() const
const uint16_t & fecSlot() const
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.
CommissioningAnalysisDescription AnalysisDescription
void clearAnalysisDescriptions(std::string partition="")
DeviceAddress deviceAddress(const deviceDescription &)
AnalysisDescriptionsRange getAnalysisDescriptions(AnalysisType, std::string partition="")
const uint16_t & fecCrate() const
AnalysisDescriptions::range AnalysisDescriptionsRange
CommissioningAnalysisDescription::commissioningType AnalysisType
std::vector< std::vector< double > > tmp
char data[epos_bytes_allocation]
std::string analysisType(AnalysisType) const
std::vector< AnalysisDescription * > AnalysisDescriptionsV
static const uint16_t FEC_CRATE_OFFSET
void printAnalysisDescriptions(std::string partition="")