7 using namespace sistrip;
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 ==
"" || 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_APVLATENCY ) {
76 tmp1 = deviceFactory(__func__)->getAnalysisHistory( iter->second.partitionName(),
77 iter->second.apvLatencyVersion().first,
78 iter->second.apvLatencyVersion().second,
80 }
else if ( analysis_type == AnalysisDescription::T_ANALYSIS_FINEDELAY ) {
81 tmp1 = deviceFactory(__func__)->getAnalysisHistory( iter->second.partitionName(),
82 iter->second.fineDelayVersion().first,
83 iter->second.fineDelayVersion().second,
87 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
88 <<
" Unexpected analysis type \""
89 << analysisType( analysis_type )
90 <<
"\"! Aborting download...";
92 return analyses_.emptyRange();
97 CommissioningAnalysisFactory::vectorCopy( tmp1, tmp2 );
100 analyses_.loadNext( iter->second.partitionName(), tmp2 );
104 std::stringstream
ss;
105 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
106 <<
" Downloaded " << anals.size()
107 <<
" analysis descriptions of type \""
108 << analysisType( analysis_type )
109 <<
"\" to local cache for partition \""
110 << iter->second.partitionName() <<
"\"" << std::endl;
111 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
112 <<
" Cache holds analysis descriptions for "
113 << analyses_.size() <<
" partitions.";
121 std::stringstream
ss;
122 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
123 <<
" No database cache for analysis objects!";
127 }
catch (...) { handleException( __func__ ); }
133 if ( partition !=
"" ) {
134 anals = analyses_.find( partition );
138 if ( !analyses_.empty() ) {
140 analyses_.find( (--(dbParams_.partitions().end()))->second.partitionName() ).
end() );
141 }
else { anals = analyses_.emptyRange(); }
142 np = analyses_.size();
147 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
148 <<
" Found " << nc <<
" analysis descriptions";
149 if ( !dbParams_.usingDbCache() ) { ss <<
" in " << np <<
" database partition(s)"; }
150 else { ss <<
" from shared memory name '" << dbParams_.sharedMemory() <<
"'"; }
162 if ( !deviceFactory(__func__) ) {
return; }
164 if ( partition.empty() ) {
166 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
167 <<
" Partition string is empty,"
168 <<
" therefore cannot add analysis descriptions to local cache!";
173 if ( anals.empty() ) {
175 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
176 <<
" Vector of analysis descriptions is empty,"
177 <<
" therefore cannot add analysis descriptions to local cache!";
182 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
183 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
184 for ( ; iter != jter; ++iter ) {
if ( partition == iter->second.partitionName() ) {
break; } }
185 if ( iter == dbParams_.partitions().end() ) {
187 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
188 <<
" Partition \"" << partition
189 <<
"\" not found in partition list, "
190 <<
" therefore cannot add analysis descriptions!";
196 if ( range == analyses_.emptyRange() ) {
200 CommissioningAnalysisFactory::vectorCopy( anals, tmp );
203 analyses_.loadNext( partition, tmp );
206 std::stringstream
ss;
207 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
208 <<
" Added " << anals.size()
209 <<
" analysis descriptions to local cache for partition \""
210 << partition <<
"\"."
211 <<
" (Cache holds analysis descriptions for "
212 << analyses_.size() <<
" partitions.)";
217 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
218 <<
" Partition \"" << partition
219 <<
"\" already found in local cache, "
220 <<
" therefore cannot add analysis descriptions!";
232 if ( dbParams_.usingDbCache() ) {
234 <<
"[SiStripConfigDb::" << __func__ <<
"]"
235 <<
" Using database cache! No uploads allowed!";
239 if ( !deviceFactory(__func__) ) {
return; }
241 if ( analyses_.empty() ) {
243 <<
"[SiStripConfigDb::" << __func__ <<
"]"
244 <<
" Found no cached analysis descriptions, therefore no upload!";
248 if ( calibration_for_physics && !allowCalibUpload_ ) {
250 <<
"[SiStripConfigDb::" << __func__ <<
"]"
251 <<
" Attempting to upload calibration constants"
252 <<
" without uploading any hardware descriptions!"
253 <<
" Aborting upload...";
255 }
else { allowCalibUpload_ =
false; }
259 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
260 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
261 for ( ; iter != jter; ++iter ) {
263 if ( partition ==
"" || partition == iter->second.partitionName() ) {
266 if ( range != analyses_.emptyRange() ) {
270 AnalysisType analysis_type = AnalysisDescription::T_UNKNOWN;
271 if ( anals.front() ) { analysis_type = anals.front()->getType(); }
272 if ( analysis_type == AnalysisDescription::T_UNKNOWN ) {
274 <<
"[SiStripConfigDb::" << __func__ <<
"]"
275 <<
" Analysis type is UNKNOWN. Aborting upload!";
279 uint32_t
version = deviceFactory(__func__)->uploadAnalysis( iter->second.runNumber(),
280 iter->second.partitionName(),
283 calibration_for_physics );
286 if ( calibration_for_physics ) { deviceFactory(__func__)->uploadAnalysisState( version ); }
289 std::stringstream
ss;
290 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
291 <<
" Uploaded " << anals.size()
292 <<
" device descriptions to database for partition \""
293 << iter->second.partitionName() <<
"\".";
298 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
299 <<
" Vector of device descriptions is empty for partition \""
300 << iter->second.partitionName()
301 <<
"\", therefore aborting upload for this partition!";
318 }
catch (...) { handleException( __func__ ); }
320 allowCalibUpload_ =
true;
329 if ( analyses_.empty() ) {
331 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
332 <<
" Found no cached analysis descriptions!";
341 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
342 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
343 for ( ; iter != jter; ++iter ) {
344 if ( partition != iter->second.partitionName() ) {
346 if ( range != analyses_.emptyRange() ) {
361 if ( partition ==
"" ) {
362 if ( !analyses_.empty() ) {
364 analyses_.find( (--(dbParams_.partitions().end()))->second.partitionName() ).
end() );
365 }
else { anals = analyses_.emptyRange(); }
367 SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
368 SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
369 for ( ; iter != jter; ++iter ) {
if ( partition == iter->second.partitionName() ) {
break; } }
370 anals = analyses_.find( iter->second.partitionName() );
373 if ( anals != analyses_.emptyRange() ) {
374 AnalysisDescriptionsV::const_iterator ianal = anals.begin();
375 AnalysisDescriptionsV::const_iterator janal = anals.end();
376 for ( ; ianal != janal; ++ianal ) {
if ( *ianal ) {
delete *ianal; } }
379 ss <<
"[SiStripConfigDb::" << __func__ <<
"]";
380 if ( partition ==
"" ) { ss <<
" Found no analysis descriptions in local cache!"; }
381 else { ss <<
" Found no analysis descriptions in local cache for partition \"" << partition <<
"\"!"; }
386 analyses_ = temporary_cache;
394 std::stringstream
ss;
395 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
396 <<
" Contents of AnalysisDescriptions container:" << std::endl;
397 ss <<
" Number of partitions: " << analyses_.size() << std::endl;
403 for ( ; ianal != janal; ++ianal ) {
406 if ( partition ==
"" || partition == ianal->first ) {
408 ss <<
" Partition number : " << cntr <<
" (out of " << analyses_.size() <<
")" << std::endl;
409 ss <<
" Partition name : \"" << ianal->first <<
"\"" << std::endl;
410 ss <<
" Num of analyses : " << ianal->second.size() << std::endl;
413 std::map< uint32_t, vector<uint32_t> > analyses;
414 AnalysisDescriptionsV::const_iterator iter = ianal->second.begin();
415 AnalysisDescriptionsV::const_iterator jter = ianal->second.end();
416 for ( ; iter != jter; ++iter ) {
433 if (
find( analyses[key].
begin(), analyses[key].
end(), data ) == analyses[key].
end() ) {
434 analyses[
key].push_back( data );
440 std::map< uint32_t, std::vector<uint32_t> >
tmp;
441 std::map< uint32_t, std::vector<uint32_t> >::const_iterator
ii = analyses.begin();
442 std::map< uint32_t, std::vector<uint32_t> >::const_iterator
jj = analyses.end();
443 for ( ; ii !=
jj; ++
ii ) {
444 std::vector<uint32_t>
temp = ii->second;
445 std::sort( temp.begin(), temp.end() );
446 std::vector<uint32_t>::const_iterator iii = temp.begin();
447 std::vector<uint32_t>::const_iterator jjj = temp.end();
448 for ( ; iii != jjj; ++iii ) { tmp[ii->first].push_back( *iii ); }
454 std::map< uint32_t, std::vector<uint32_t> >::const_iterator ianal = analyses.begin();
455 std::map< uint32_t, std::vector<uint32_t> >::const_iterator janal = analyses.end();
456 for ( ; ianal != janal; ++ianal ) {
458 ss <<
" Found " << std::setw(3) << ianal->second.size()
459 <<
" analyses for FEC crate/slot/ring "
496 addr.
fecSlot_ =
static_cast<uint16_t
>( desc.getSlot() );
498 addr.
ccuAddr_ =
static_cast<uint16_t
>( desc.getCcuAdr() );
499 addr.
ccuChan_ =
static_cast<uint16_t
>( desc.getCcuChan() );
501 addr.
i2cAddr_ =
static_cast<uint16_t
>( desc.getI2cAddr() );
502 addr.
fedId_ =
static_cast<uint16_t
>( desc.getFedId() );
503 addr.
feUnit_ =
static_cast<uint16_t
>( desc.getFeUnit() );
504 addr.
feChan_ =
static_cast<uint16_t
>( desc.getFeChan() );
505 }
catch (...) { handleException( __func__ ); }
513 if ( analysis_type == AnalysisDescription::T_ANALYSIS_FASTFEDCABLING ) {
return "FAST_CABLING"; }
514 else if ( analysis_type == AnalysisDescription::T_ANALYSIS_TIMING ) {
return "APV_TIMING"; }
515 else if ( analysis_type == AnalysisDescription::T_ANALYSIS_OPTOSCAN ) {
return "OPTO_SCAN"; }
516 else if ( analysis_type == AnalysisDescription::T_ANALYSIS_PEDESTALS ) {
return "PEDESTALS"; }
517 else if ( analysis_type == AnalysisDescription::T_ANALYSIS_APVLATENCY ) {
return "APV_LATENCY"; }
518 else if ( analysis_type == AnalysisDescription::T_ANALYSIS_FINEDELAY ) {
return "FINE_DELAY"; }
519 else if ( analysis_type == AnalysisDescription::T_ANALYSIS_CALIBRATION ) {
return "CALIBRATION"; }
520 else if ( analysis_type == AnalysisDescription::T_UNKNOWN ) {
return "UNKNOWN ANALYSIS TYPE"; }
521 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 &)
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
AnalysisDescriptionsRange getAnalysisDescriptions(AnalysisType, std::string partition="")
const uint16_t & fecCrate() const
AnalysisDescriptions::range AnalysisDescriptionsRange
CommissioningAnalysisDescription::commissioningType AnalysisType
std::vector< std::vector< double > > tmp
std::string analysisType(AnalysisType) const
std::vector< AnalysisDescription * > AnalysisDescriptionsV
static const uint16_t FEC_CRATE_OFFSET
void printAnalysisDescriptions(std::string partition="")