10 using namespace sistrip;
24 std::string partition ) {
27 if ( ( !dbParams_.usingDbCache() && !deviceFactory(__func__) ) ||
28 ( dbParams_.usingDbCache() && !databaseCache(__func__) ) ) {
29 return analyses_.emptyRange();
34 if ( !dbParams_.usingDbCache() ) {
36 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
37 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
38 for ( ; iter != jter; ++iter ) {
40 if ( partition ==
"" || partition == iter->second.partitionName() ) {
45 if ( range == analyses_.emptyRange() ) {
48 if ( analysis_type == AnalysisDescription::T_ANALYSIS_FASTFEDCABLING ) {
49 tmp1 = deviceFactory(__func__)->getAnalysisHistory( iter->second.partitionName(),
50 iter->second.fastCablingVersion().first,
51 iter->second.fastCablingVersion().second,
53 }
else if ( analysis_type == AnalysisDescription::T_ANALYSIS_TIMING ) {
54 tmp1 = deviceFactory(__func__)->getAnalysisHistory( iter->second.partitionName(),
55 iter->second.apvTimingVersion().first,
56 iter->second.apvTimingVersion().second,
58 }
else if ( analysis_type == AnalysisDescription::T_ANALYSIS_OPTOSCAN ) {
59 tmp1 = deviceFactory(__func__)->getAnalysisHistory( iter->second.partitionName(),
60 iter->second.optoScanVersion().first,
61 iter->second.optoScanVersion().second,
63 }
else if ( analysis_type == AnalysisDescription::T_ANALYSIS_VPSPSCAN ) {
64 tmp1 = deviceFactory(__func__)->getAnalysisHistory( iter->second.partitionName(),
65 iter->second.vpspScanVersion().first,
66 iter->second.vpspScanVersion().second,
68 }
else if ( analysis_type == AnalysisDescription::T_ANALYSIS_CALIBRATION ) {
69 tmp1 = deviceFactory(__func__)->getAnalysisHistory( iter->second.partitionName(),
70 iter->second.apvCalibVersion().first,
71 iter->second.apvCalibVersion().second,
73 }
else if ( analysis_type == AnalysisDescription::T_ANALYSIS_PEDESTALS ) {
74 tmp1 = deviceFactory(__func__)->getAnalysisHistory( iter->second.partitionName(),
75 iter->second.pedestalsVersion().first,
76 iter->second.pedestalsVersion().second,
78 }
else if ( analysis_type == AnalysisDescription::T_ANALYSIS_APVLATENCY ) {
79 tmp1 = deviceFactory(__func__)->getAnalysisHistory( iter->second.partitionName(),
80 iter->second.apvLatencyVersion().first,
81 iter->second.apvLatencyVersion().second,
83 }
else if ( analysis_type == AnalysisDescription::T_ANALYSIS_FINEDELAY ) {
84 tmp1 = deviceFactory(__func__)->getAnalysisHistory( iter->second.partitionName(),
85 iter->second.fineDelayVersion().first,
86 iter->second.fineDelayVersion().second,
90 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
91 <<
" Unexpected analysis type \""
92 << analysisType( analysis_type )
93 <<
"\"! Aborting download...";
95 return analyses_.emptyRange();
100 CommissioningAnalysisFactory::vectorCopy( tmp1, tmp2 );
103 analyses_.loadNext( iter->second.partitionName(), tmp2 );
107 std::stringstream ss;
108 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
109 <<
" Downloaded " << anals.size()
110 <<
" analysis descriptions of type \""
111 << analysisType( analysis_type )
112 <<
"\" to local cache for partition \""
113 << iter->second.partitionName() <<
"\"" << std::endl;
114 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
115 <<
" Cache holds analysis descriptions for "
116 << analyses_.size() <<
" partitions.";
124 std::stringstream ss;
125 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
126 <<
" No database cache for analysis objects!";
130 }
catch (...) { handleException( __func__ ); }
136 if ( partition !=
"" ) {
137 anals = analyses_.find( partition );
141 if ( !analyses_.empty() ) {
143 analyses_.find( (--(dbParams_.partitions().end()))->second.partitionName() ).
end() );
144 }
else { anals = analyses_.emptyRange(); }
145 np = analyses_.size();
150 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
151 <<
" Found " << nc <<
" analysis descriptions";
152 if ( !dbParams_.usingDbCache() ) { ss <<
" in " << np <<
" database partition(s)"; }
153 else { ss <<
" from shared memory name '" << dbParams_.sharedMemory() <<
"'"; }
165 if ( !deviceFactory(__func__) ) {
return; }
167 if ( partition.empty() ) {
169 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
170 <<
" Partition string is empty,"
171 <<
" therefore cannot add analysis descriptions to local cache!";
176 if ( anals.empty() ) {
178 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
179 <<
" Vector of analysis descriptions is empty,"
180 <<
" therefore cannot add analysis descriptions to local cache!";
185 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
186 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
187 for ( ; iter != jter; ++iter ) {
if ( partition == iter->second.partitionName() ) {
break; } }
188 if ( iter == dbParams_.partitions().end() ) {
190 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
191 <<
" Partition \"" << partition
192 <<
"\" not found in partition list, "
193 <<
" therefore cannot add analysis descriptions!";
199 if ( range == analyses_.emptyRange() ) {
203 CommissioningAnalysisFactory::vectorCopy( anals, tmp );
206 analyses_.loadNext( partition, tmp );
209 std::stringstream ss;
210 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
211 <<
" Added " << anals.size()
212 <<
" analysis descriptions to local cache for partition \""
213 << partition <<
"\"."
214 <<
" (Cache holds analysis descriptions for "
215 << analyses_.size() <<
" partitions.)";
220 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
221 <<
" Partition \"" << partition
222 <<
"\" already found in local cache, "
223 <<
" therefore cannot add analysis descriptions!";
233 std::string partition ) {
235 if ( dbParams_.usingDbCache() ) {
237 <<
"[SiStripConfigDb::" << __func__ <<
"]"
238 <<
" Using database cache! No uploads allowed!";
242 if ( !deviceFactory(__func__) ) {
return; }
244 if ( analyses_.empty() ) {
246 <<
"[SiStripConfigDb::" << __func__ <<
"]"
247 <<
" Found no cached analysis descriptions, therefore no upload!";
251 if ( calibration_for_physics && !allowCalibUpload_ ) {
253 <<
"[SiStripConfigDb::" << __func__ <<
"]"
254 <<
" Attempting to upload calibration constants"
255 <<
" without uploading any hardware descriptions!"
256 <<
" Aborting upload...";
258 }
else { allowCalibUpload_ =
false; }
262 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
263 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
264 for ( ; iter != jter; ++iter ) {
266 if ( partition ==
"" || partition == iter->second.partitionName() ) {
269 if ( range != analyses_.emptyRange() ) {
273 AnalysisType analysis_type = AnalysisDescription::T_UNKNOWN;
274 if ( anals.front() ) { analysis_type = anals.front()->getType(); }
275 if ( analysis_type == AnalysisDescription::T_UNKNOWN ) {
277 <<
"[SiStripConfigDb::" << __func__ <<
"]"
278 <<
" Analysis type is UNKNOWN. Aborting upload!";
282 uint32_t
version = deviceFactory(__func__)->uploadAnalysis( iter->second.runNumber(),
283 iter->second.partitionName(),
286 calibration_for_physics );
289 if ( calibration_for_physics ) { deviceFactory(__func__)->uploadAnalysisState( version ); }
292 std::stringstream ss;
293 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
294 <<
" Uploaded " << anals.size()
295 <<
" device descriptions to database for partition \""
296 << iter->second.partitionName() <<
"\".";
301 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
302 <<
" Vector of device descriptions is empty for partition \""
303 << iter->second.partitionName()
304 <<
"\", therefore aborting upload for this partition!";
321 }
catch (...) { handleException( __func__ ); }
323 allowCalibUpload_ =
true;
332 if ( analyses_.empty() ) {
334 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
335 <<
" Found no cached analysis descriptions!";
344 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
345 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
346 for ( ; iter != jter; ++iter ) {
347 if ( partition != iter->second.partitionName() ) {
349 if ( range != analyses_.emptyRange() ) {
364 if ( partition ==
"" ) {
365 if ( !analyses_.empty() ) {
367 analyses_.find( (--(dbParams_.partitions().end()))->second.partitionName() ).
end() );
368 }
else { anals = analyses_.emptyRange(); }
370 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
371 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
372 for ( ; iter != jter; ++iter ) {
if ( partition == iter->second.partitionName() ) {
break; } }
373 anals = analyses_.find( iter->second.partitionName() );
376 if ( anals != analyses_.emptyRange() ) {
377 AnalysisDescriptionsV::const_iterator ianal = anals.begin();
378 AnalysisDescriptionsV::const_iterator janal = anals.end();
379 for ( ; ianal != janal; ++ianal ) {
if ( *ianal ) {
delete *ianal; } }
382 ss <<
"[SiStripConfigDb::" << __func__ <<
"]";
383 if ( partition ==
"" ) { ss <<
" Found no analysis descriptions in local cache!"; }
384 else { ss <<
" Found no analysis descriptions in local cache for partition \"" << partition <<
"\"!"; }
389 analyses_ = temporary_cache;
397 std::stringstream ss;
398 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
399 <<
" Contents of AnalysisDescriptions container:" << std::endl;
400 ss <<
" Number of partitions: " << analyses_.size() << std::endl;
406 for ( ; ianal != janal; ++ianal ) {
409 if ( partition ==
"" || partition == ianal->first ) {
411 ss <<
" Partition number : " << cntr <<
" (out of " << analyses_.size() <<
")" << std::endl;
412 ss <<
" Partition name : \"" << ianal->first <<
"\"" << std::endl;
413 ss <<
" Num of analyses : " << ianal->second.size() << std::endl;
416 std::map< uint32_t, vector<uint32_t> > analyses;
417 AnalysisDescriptionsV::const_iterator iter = ianal->second.begin();
418 AnalysisDescriptionsV::const_iterator jter = ianal->second.end();
419 for ( ; iter != jter; ++iter ) {
436 if (
find( analyses[key].
begin(), analyses[key].
end(), data ) == analyses[key].
end() ) {
437 analyses[
key].push_back( data );
443 std::map< uint32_t, std::vector<uint32_t> >
tmp;
444 std::map< uint32_t, std::vector<uint32_t> >::const_iterator ii = analyses.begin();
445 std::map< uint32_t, std::vector<uint32_t> >::const_iterator
jj = analyses.end();
446 for ( ; ii !=
jj; ++ii ) {
447 std::vector<uint32_t>
temp = ii->second;
449 std::vector<uint32_t>::const_iterator iii = temp.begin();
450 std::vector<uint32_t>::const_iterator jjj = temp.end();
451 for ( ; iii != jjj; ++iii ) { tmp[ii->first].push_back( *iii ); }
457 std::map< uint32_t, std::vector<uint32_t> >::const_iterator ianal = analyses.begin();
458 std::map< uint32_t, std::vector<uint32_t> >::const_iterator janal = analyses.end();
459 for ( ; ianal != janal; ++ianal ) {
461 ss <<
" Found " << std::setw(3) << ianal->second.size()
462 <<
" analyses for FEC crate/slot/ring "
499 addr.
fecSlot_ =
static_cast<uint16_t
>( desc.getSlot() );
501 addr.
ccuAddr_ =
static_cast<uint16_t
>( desc.getCcuAdr() );
502 addr.
ccuChan_ =
static_cast<uint16_t
>( desc.getCcuChan() );
504 addr.
i2cAddr_ =
static_cast<uint16_t
>( desc.getI2cAddr() );
505 addr.
fedId_ =
static_cast<uint16_t
>( desc.getFedId() );
506 addr.
feUnit_ =
static_cast<uint16_t
>( desc.getFeUnit() );
507 addr.
feChan_ =
static_cast<uint16_t
>( desc.getFeChan() );
508 }
catch (...) { handleException( __func__ ); }
516 if ( analysis_type == AnalysisDescription::T_ANALYSIS_FASTFEDCABLING ) {
return "FAST_CABLING"; }
517 else if ( analysis_type == AnalysisDescription::T_ANALYSIS_TIMING ) {
return "APV_TIMING"; }
518 else if ( analysis_type == AnalysisDescription::T_ANALYSIS_OPTOSCAN ) {
return "OPTO_SCAN"; }
519 else if ( analysis_type == AnalysisDescription::T_ANALYSIS_PEDESTALS ) {
return "PEDESTALS"; }
520 else if ( analysis_type == AnalysisDescription::T_ANALYSIS_APVLATENCY ) {
return "APV_LATENCY"; }
521 else if ( analysis_type == AnalysisDescription::T_ANALYSIS_FINEDELAY ) {
return "FINE_DELAY"; }
522 else if ( analysis_type == AnalysisDescription::T_ANALYSIS_CALIBRATION ) {
return "CALIBRATION"; }
523 else if ( analysis_type == AnalysisDescription::T_UNKNOWN ) {
return "UNKNOWN ANALYSIS TYPE"; }
524 else {
return "UNDEFINED ANALYSIS TYPE"; }
static 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="")