9 #define MAXFEDCOARSE 15 28 <<
"[LatencyHistosUsingDb::" << __func__ <<
"]" 29 <<
" Constructing object...";
36 <<
"[LatencyHistosUsingDb::" << __func__ <<
"]" 37 <<
" Destructing object...";
46 <<
"[LatencyHistosUsingDb::" << __func__ <<
"]" 47 <<
" NULL pointer to SiStripConfigDb interface!" 48 <<
" Aborting upload...";
58 <<
"[LatencyHistosUsingDb::" << __func__ <<
"]" 59 <<
" Found invalid PLL settings (coarse > 15)" 60 <<
" Aborting update to database...";
67 <<
"[LatencyHistosUsingDb::" << __func__ <<
"]" 68 <<
" Uploading APV settings to DB...";
71 <<
"[LatencyHistosUsingDb::" << __func__ <<
"]" 72 <<
" Upload of APV settings to DB finished!";
75 <<
"[LatencyHistosUsingDb::" << __func__ <<
"]" 76 <<
" Uploading FED delays to DB...";
79 <<
"[LatencyHistosUsingDb::" << __func__ <<
"]" 80 <<
" Upload of FED delays to DB finished!";
83 <<
"[LatencyHistosUsingDb::" << __func__ <<
"]" 84 <<
" TEST only! No APV settings will be uploaded to DB...";
97 <<
"[LatencyHistosUsingDb::" << __func__ <<
"]" 98 <<
" Updated NO Latency settings. No analysis result available !" ;
103 uint16_t minCoarseDelay = 256;
104 SiStripConfigDb::DeviceDescriptionsV::const_iterator idevice;
105 for ( idevice = devices.begin(); idevice != devices.end(); idevice++ ) {
107 if ( (*idevice)->getDeviceType() == PLL ) {
109 pllDescription* desc =
dynamic_cast<pllDescription*
>( *idevice );
117 int delayCoarse = desc->getDelayCoarse();
118 minCoarseDelay = minCoarseDelay < delayCoarse ? minCoarseDelay : delayCoarse;
126 if(dynamic_cast<SamplingAnalysis*>( it->second ) &&
128 anal = dynamic_cast<SamplingAnalysis*>( it->second );
130 if(!anal)
return false;
131 uint16_t globalLatency = uint16_t(ceil(anal->
maximum()/(-25.)));
132 float globalShift = anal->
maximum()-(globalLatency*(-25));
135 uint16_t
latency = globalLatency;
136 float shift[5] = {0.};
138 if(dynamic_cast<SamplingAnalysis*>( it->second ) &&
142 latency = uint16_t(ceil(anal->
maximum()/(-25.)))>latency ? uint16_t(ceil(anal->
maximum()/(-25.))) :
latency;
146 if(dynamic_cast<SamplingAnalysis*>( it->second ) &&
154 latency = globalLatency;
155 for(
int i=0;
i<5;
i++) shift[
i] = globalShift;
160 latency -= minCoarseDelay;
163 uint16_t updatedAPV = 0;
164 uint16_t updatedPLL = 0;
165 std::vector<SiStripFecKey>
invalid;
166 for ( idevice = devices.begin(); idevice != devices.end(); idevice++ ) {
168 if ( (*idevice)->getDeviceType() != APV25 ) {
continue; }
170 apvDescription* desc =
dynamic_cast<apvDescription*
>( *idevice );
171 if ( !desc ) {
continue; }
175 std::stringstream ss;
176 ss <<
"[LatencyHistosUsingDb::" << __func__ <<
"]" 177 <<
" Updating latency APV settings for crate/FEC/slot/ring/CCU/i2cAddr " 185 <<
static_cast<uint16_t
>(desc->getLatency());
186 desc->setLatency(latency);
188 <<
static_cast<uint16_t
>(desc->getLatency());
194 for ( idevice = devices.begin(); idevice != devices.end(); idevice++ ) {
196 if ( (*idevice)->getDeviceType() != PLL ) {
continue; }
198 pllDescription* desc =
dynamic_cast<pllDescription*
>( *idevice );
199 if ( !desc ) {
continue; }
200 if ( desc->getDelayCoarse() >= 15 ) {
continue; }
212 float delay = desc->getDelayCoarse()*25+desc->getDelayFine()*25./24. + shift[addr.
fecCrate_];
213 int delayCoarse =
int(delay/25);
214 int delayFine =
int(round((delay-25*delayCoarse)*24./25.));
215 if(delayFine==24) { delayFine=0; ++delayCoarse; }
216 delayCoarse -= minCoarseDelay;
218 if ( delayCoarse > 15 ) { invalid.push_back(fec_key); delayCoarse =
sistrip::invalid_; }
222 std::stringstream ss;
223 ss <<
"[LatencyHistosUsingDb::" << __func__ <<
"]" 224 <<
" Updating coarse/fine PLL settings" 225 <<
" for Crate/FEC/slot/ring/CCU " 232 <<
static_cast<uint16_t
>( desc->getDelayCoarse() ) <<
"/" 233 << static_cast<uint16_t>( desc->getDelayFine() );
234 desc->setDelayCoarse(delayCoarse);
235 desc->setDelayFine(delayFine);
238 <<
static_cast<uint16_t
>( desc->getDelayCoarse() ) <<
"/" 239 << static_cast<uint16_t>( desc->getDelayFine() );
248 uint16_t minDelay = 256;
249 uint16_t maxDelay = 0;
250 uint16_t fedDelayCoarse = 0;
251 for (
auto ifed = feds.begin(); ifed != feds.end(); ifed++ ) {
253 if (
find(
ids.begin(),
ids.end(), (*ifed)->getFedId() ) ==
ids.end() ) {
continue; }
256 for (
auto iconn = conns.begin(); iconn != conns.end(); iconn++ ) {
260 Fed9U::Fed9UAddress fedChannel = Fed9U::Fed9UAddress(iconn->fedCh());
262 fedDelayCoarse = (*ifed)->getCoarseDelay(fedChannel);
264 minDelay = minDelay<fedDelayCoarse ? minDelay : fedDelayCoarse;
265 maxDelay = maxDelay>fedDelayCoarse ? maxDelay : fedDelayCoarse;
270 int offset = (10-minDelay)*25;
274 for ( SiStripConfigDb::FedDescriptionsV::const_iterator ifed = feds.begin(); ifed != feds.end(); ifed++ ) {
276 if (
find(
ids.begin(),
ids.end(), (*ifed)->getFedId() ) ==
ids.end() ) {
continue; }
279 for (
auto iconn = conns.begin(); iconn != conns.end(); iconn++ ) {
283 Fed9U::Fed9UAddress fedChannel = Fed9U::Fed9UAddress(iconn->fedCh());
285 int fedDelayCoarse = (*ifed)->getCoarseDelay(fedChannel);
286 int fedDelayFine = (*ifed)->getFineDelay(fedChannel);
289 int fedDelay =
int(fedDelayCoarse*25. - fedDelayFine*24./25. - round(shift[iconn->fecCrate()]) + offset);
290 fedDelayCoarse = (fedDelay/25)+1;
291 fedDelayFine = fedDelayCoarse*25-fedDelay;
292 if(fedDelayFine==25) { fedDelayFine = 0; --fedDelayCoarse; }
294 std::stringstream ss;
295 ss <<
"[LatencyHistosUsingDb::" << __func__ <<
"]" 296 <<
" Updating the FED delay" 297 <<
" for loop FED id/ch " 298 << (*ifed)->getFedId() <<
"/" << iconn->fedCh()
300 << (*ifed)->getCoarseDelay( fedChannel) <<
"/" << (*ifed)->getFineDelay( fedChannel)
302 (*ifed)->setDelay(fedChannel, fedDelayCoarse, fedDelayFine);
303 ss << (*ifed)->getCoarseDelay(fedChannel) <<
"/" << (*ifed)->getFineDelay( fedChannel);
310 <<
"[LatencyHistosUsingDb::" << __func__ <<
"]" 311 <<
" Updated FED delays for " <<
ids.size() <<
" FEDs!";
314 if ( !invalid.empty() ) {
315 std::stringstream ss;
316 ss <<
"[LatencyHistosUsingDb::" << __func__ <<
"]" 317 <<
" Found PLL coarse setting of 15" 318 <<
" (not allowed!) for following channels" 319 <<
" (Crate/FEC/slot/ring/CCU/LLD): ";
320 std::vector<SiStripFecKey>::iterator ikey = invalid.begin();
321 std::vector<SiStripFecKey>::iterator jkey = invalid.end();
322 for ( ; ikey != jkey; ++ikey ) {
323 ss << ikey->fecCrate() <<
"/" 324 << ikey->fecSlot() <<
"/" 325 << ikey->fecRing() <<
"/" 326 << ikey->ccuAddr() <<
"/" 327 << ikey->ccuChan() <<
", ";
335 <<
"[LatencyHistosUsingDb::" << __func__ <<
"] " 336 <<
"Updated settings for " << updatedAPV <<
" APV devices and " << updatedPLL <<
" PLL devices.";
346 if ( !anal ) {
return; }
351 uint16_t
latency =
static_cast<uint16_t
>( ( anal->
maximum() / (-25.) ) + 0.5 );
353 ApvLatencyAnalysisDescription*
tmp;
354 tmp =
new ApvLatencyAnalysisDescription( latency,
371 typedef std::vector<std::string>
Strings;
373 Strings::const_iterator istr = errors.begin();
374 Strings::const_iterator jstr = errors.end();
375 for ( ; istr != jstr; ++istr ) { tmp->addComments( *istr ); }
378 desc.push_back( tmp );
def upload(url, args, files)
T getParameter(std::string const &) const
Analysis for latency run.
const uint32_t & fedKey() const
Analyses::iterator Analysis
const uint16_t & fecRing() const
~LatencyHistosUsingDb() override
A container class for generic run and event-related info, information required by the commissioning a...
const edm::ParameterSet & pset() const
virtual bool isValid() const
FedDescriptionsRange getFedDescriptions(std::string partition="")
bool update(SiStripConfigDb::DeviceDescriptionsRange, SiStripConfigDb::FedDescriptionsRange)
FedDescriptions::range FedDescriptionsRange
static const char mlDqmClient_[]
void uploadConfigurations() override
const uint16_t & fecSlot() const
void configure(const edm::ParameterSet &, const edm::EventSetup &) override
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
const uint32_t & key() const
Utility class that identifies a position within the strip tracker control structure, down to the level of an APV25.
U second(std::pair< T, U > const &p)
const_iterator_range partitions() const
LatencyHistosUsingDb(const edm::ParameterSet &pset, DQMStore *, SiStripConfigDb *const )
FedsConstIterRange fedIds() const
DeviceDescriptions::range DeviceDescriptionsRange
An interface class to the DeviceFactory.
bool doUploadConf() const
const uint32_t & fecKey() const
DeviceAddress deviceAddress(const deviceDescription &)
const uint16_t & fecCrate() const
void create(SiStripConfigDb::AnalysisDescriptionsV &, Analysis) override
const SiStripDbParams & dbParams() const
void configure(const edm::ParameterSet &, const edm::EventSetup &) override
void uploadFedDescriptions(std::string partition="")
const uint16_t & ccuAddr() const
static const uint16_t invalid_
ConnsConstIterRange fedConnections(uint16_t fed_id) const
std::vector< std::vector< double > > tmp
std::vector< AnalysisDescription * > AnalysisDescriptionsV
static unsigned int const shift
const uint16_t & ccuChan() const
const float & maximum() const
SiStripConfigDb *const db() const
DeviceDescriptionsRange getDeviceDescriptions(std::string partition="")
void uploadDeviceDescriptions(std::string partition="")
SiStripFedCabling *const cabling() const
const VString & getErrorCodes() const