9 #define MAXFEDCOARSE 15 20 <<
" Constructing object...";
27 <<
" Destructing object...";
35 <<
" NULL pointer to SiStripConfigDb interface!" 36 <<
" Aborting upload...";
46 <<
" Found invalid PLL settings (coarse > 15)" 47 <<
" Aborting update to database...";
54 <<
" Uploading APV settings to DB...";
57 <<
" Upload of APV settings to DB finished!";
60 <<
" Uploading FED delays to DB...";
63 <<
" Upload of FED delays to DB finished!";
66 <<
" TEST only! No APV settings will be uploaded to DB...";
77 <<
" Updated NO Latency settings. No analysis result available !";
82 uint16_t minCoarseDelay = 256;
83 SiStripConfigDb::DeviceDescriptionsV::const_iterator idevice;
84 for (idevice = devices.begin(); idevice != devices.end(); idevice++) {
86 if ((*idevice)->getDeviceType() == PLL) {
88 pllDescription* desc =
dynamic_cast<pllDescription*
>(*idevice);
96 int delayCoarse = desc->getDelayCoarse();
97 minCoarseDelay = minCoarseDelay < delayCoarse ? minCoarseDelay : delayCoarse;
105 if (dynamic_cast<SamplingAnalysis*>(it->second) &&
107 anal = dynamic_cast<SamplingAnalysis*>(it->second);
111 uint16_t globalLatency = uint16_t(
ceil(anal->
maximum() / (-25.)));
112 float globalShift = anal->
maximum() - (globalLatency * (-25));
115 uint16_t
latency = globalLatency;
116 float shift[5] = {0.};
118 if (dynamic_cast<SamplingAnalysis*>(it->second) &&
125 if (dynamic_cast<SamplingAnalysis*>(it->second) &&
132 latency = globalLatency;
133 for (
int i = 0;
i < 5;
i++)
134 shift[
i] = globalShift;
139 latency -= minCoarseDelay;
142 uint16_t updatedAPV = 0;
143 uint16_t updatedPLL = 0;
144 std::vector<SiStripFecKey>
invalid;
145 for (idevice = devices.begin(); idevice != devices.end(); idevice++) {
147 if ((*idevice)->getDeviceType() != APV25) {
151 apvDescription* desc =
dynamic_cast<apvDescription*
>(*idevice);
158 std::stringstream
ss;
159 ss <<
"[LatencyHistosUsingDb::" << __func__ <<
"]" 160 <<
" Updating latency APV settings for crate/FEC/slot/ring/CCU/i2cAddr " << addr.
fecCrate_ <<
"/" 162 <<
" from " <<
static_cast<uint16_t
>(desc->getLatency());
163 desc->setLatency(latency);
164 ss <<
" to " <<
static_cast<uint16_t
>(desc->getLatency());
170 for (idevice = devices.begin(); idevice != devices.end(); idevice++) {
172 if ((*idevice)->getDeviceType() != PLL) {
176 pllDescription* desc =
dynamic_cast<pllDescription*
>(*idevice);
180 if (desc->getDelayCoarse() >= 15) {
190 float delay = desc->getDelayCoarse() * 25 + desc->getDelayFine() * 25. / 24. + shift[addr.
fecCrate_];
191 int delayCoarse =
int(delay / 25);
192 int delayFine =
int(round((delay - 25 * delayCoarse) * 24. / 25.));
193 if (delayFine == 24) {
197 delayCoarse -= minCoarseDelay;
199 if (delayCoarse > 15) {
200 invalid.push_back(fec_key);
205 std::stringstream
ss;
206 ss <<
"[LatencyHistosUsingDb::" << __func__ <<
"]" 207 <<
" Updating coarse/fine PLL settings" 208 <<
" for Crate/FEC/slot/ring/CCU " << fec_path.
fecCrate() <<
"/" << fec_path.
fecSlot() <<
"/" 210 <<
static_cast<uint16_t
>(desc->getDelayCoarse()) <<
"/" << static_cast<uint16_t>(desc->getDelayFine());
211 desc->setDelayCoarse(delayCoarse);
212 desc->setDelayFine(delayFine);
214 ss <<
" to " <<
static_cast<uint16_t
>(desc->getDelayCoarse()) <<
"/" 215 << static_cast<uint16_t>(desc->getDelayFine());
224 uint16_t minDelay = 256;
225 uint16_t maxDelay = 0;
226 uint16_t fedDelayCoarse = 0;
227 for (
auto ifed = feds.begin(); ifed != feds.end(); ifed++) {
229 if (
find(
ids.begin(),
ids.end(), (*ifed)->getFedId()) ==
ids.end()) {
234 for (
auto iconn = conns.begin(); iconn != conns.end(); iconn++) {
239 Fed9U::Fed9UAddress fedChannel = Fed9U::Fed9UAddress(iconn->fedCh());
241 fedDelayCoarse = (*ifed)->getCoarseDelay(fedChannel);
243 minDelay = minDelay < fedDelayCoarse ? minDelay : fedDelayCoarse;
244 maxDelay = maxDelay > fedDelayCoarse ? maxDelay : fedDelayCoarse;
249 int offset = (10 - minDelay) * 25;
254 for (SiStripConfigDb::FedDescriptionsV::const_iterator ifed = feds.begin(); ifed != feds.end(); ifed++) {
256 if (
find(
ids.begin(),
ids.end(), (*ifed)->getFedId()) ==
ids.end()) {
261 for (
auto iconn = conns.begin(); iconn != conns.end(); iconn++) {
266 Fed9U::Fed9UAddress fedChannel = Fed9U::Fed9UAddress(iconn->fedCh());
268 int fedDelayCoarse = (*ifed)->getCoarseDelay(fedChannel);
269 int fedDelayFine = (*ifed)->getFineDelay(fedChannel);
272 int fedDelay =
int(fedDelayCoarse * 25. - fedDelayFine * 24. / 25. - round(shift[iconn->fecCrate()]) + offset);
273 fedDelayCoarse = (fedDelay / 25) + 1;
274 fedDelayFine = fedDelayCoarse * 25 - fedDelay;
275 if (fedDelayFine == 25) {
280 std::stringstream
ss;
281 ss <<
"[LatencyHistosUsingDb::" << __func__ <<
"]" 282 <<
" Updating the FED delay" 283 <<
" for loop FED id/ch " << (*ifed)->getFedId() <<
"/" << iconn->fedCh() <<
" from " 284 << (*ifed)->getCoarseDelay(fedChannel) <<
"/" << (*ifed)->getFineDelay(fedChannel) <<
" to ";
285 (*ifed)->setDelay(fedChannel, fedDelayCoarse, fedDelayFine);
286 ss << (*ifed)->getCoarseDelay(fedChannel) <<
"/" << (*ifed)->getFineDelay(fedChannel);
293 <<
" Updated FED delays for " <<
ids.size() <<
" FEDs!";
296 if (!invalid.empty()) {
297 std::stringstream
ss;
298 ss <<
"[LatencyHistosUsingDb::" << __func__ <<
"]" 299 <<
" Found PLL coarse setting of 15" 300 <<
" (not allowed!) for following channels" 301 <<
" (Crate/FEC/slot/ring/CCU/LLD): ";
302 std::vector<SiStripFecKey>::iterator ikey = invalid.begin();
303 std::vector<SiStripFecKey>::iterator jkey = invalid.end();
304 for (; ikey != jkey; ++ikey) {
305 ss << ikey->fecCrate() <<
"/" << ikey->fecSlot() <<
"/" << ikey->fecRing() <<
"/" << ikey->ccuAddr() <<
"/" 306 << ikey->ccuChan() <<
", ";
314 <<
"Updated settings for " << updatedAPV <<
" APV devices and " << updatedPLL
330 uint16_t
latency =
static_cast<uint16_t
>((anal->
maximum() / (-25.)) + 0.5);
332 ApvLatencyAnalysisDescription*
tmp;
333 tmp =
new ApvLatencyAnalysisDescription(latency,
350 typedef std::vector<std::string>
Strings;
352 Strings::const_iterator istr = errors.begin();
353 Strings::const_iterator jstr = errors.end();
354 for (; istr != jstr; ++istr) {
355 tmp->addComments(*istr);
def upload(url, args, files)
T getParameter(std::string const &) const
Analysis for latency run.
const uint32_t & fedKey() const
Analyses::iterator Analysis
Analyses & data(bool getMaskedData=false)
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)
constexpr int32_t ceil(float num)
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
FedsConstIterRange fedIds() const
DeviceDescriptions::range DeviceDescriptionsRange
An interface class to the DeviceFactory.
bool doUploadConf() const
const uint32_t & fecKey() const
DeviceAddress deviceAddress(const deviceDescription &)
LatencyHistosUsingDb(const edm::ParameterSet &pset, DQMStore *, SiStripConfigDb *const)
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< 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