CMS 3D CMS Logo

OptoScanHistosUsingDb.cc
Go to the documentation of this file.
1 
7 #include <iostream>
8 
9 using namespace sistrip;
10 
11 // -----------------------------------------------------------------------------
14  : CommissioningHistograms(pset.getParameter<edm::ParameterSet>("OptoScanParameters"), bei, sistrip::OPTO_SCAN),
16  OptoScanHistograms(pset.getParameter<edm::ParameterSet>("OptoScanParameters"), bei) {
17  LogTrace(mlDqmClient_) << "[OptoScanHistosUsingDb::" << __func__ << "]"
18  << " Constructing object...";
19  skipGainUpdate_ = this->pset().getParameter<bool>("SkipGainUpdate");
20  if (skipGainUpdate_)
21  LogTrace(mlDqmClient_) << "[OptoScanHistosUsingDb::" << __func__ << "]"
22  << " Skipping db update of gain parameters.";
23 
25  this->pset().existsAs<bool>("doSelectiveUpload") ? this->pset().getParameter<bool>("doSelectiveUpload") : false;
27  LogTrace(mlDqmClient_) << "[OptoScanHistosUsingDb::" << __func__ << "]"
28  << " Enabling selective upload of gain parameters";
29 }
30 
31 // -----------------------------------------------------------------------------
34  LogTrace(mlDqmClient_) << "[OptoScanHistosUsingDb::" << __func__ << "]"
35  << " Destructing object...";
36 }
37 
38 // -----------------------------------------------------------------------------
41  LogTrace(mlDqmClient_) << "[OptoScanHistosUsingDb::" << __func__ << "]";
42 
43  if (!db()) {
44  edm::LogError(mlDqmClient_) << "[OptoScanHistosUsingDb::" << __func__ << "]"
45  << " NULL pointer to SiStripConfigDb interface!"
46  << " Aborting upload...";
47  return;
48  }
49 
50  // Update LLD descriptions with new bias/gain settings
52  update(devices);
53  if (doUploadConf()) {
54  edm::LogVerbatim(mlDqmClient_) << "[OptoScanHistosUsingDb::" << __func__ << "]"
55  << " Uploading LLD settings to DB...";
57  edm::LogVerbatim(mlDqmClient_) << "[OptoScanHistosUsingDb::" << __func__ << "]"
58  << " Upload of LLD settings to DB finished!";
59  } else {
60  edm::LogWarning(mlDqmClient_) << "[OptoScanHistosUsingDb::" << __func__ << "]"
61  << " TEST only! No LLD settings will be uploaded to DB...";
62  }
63 }
64 
65 // -----------------------------------------------------------------------------
68  // Iterate through devices and update device descriptions
69  uint16_t updated = 0;
70  SiStripConfigDb::DeviceDescriptionsV::const_iterator idevice;
71  for (idevice = devices.begin(); idevice != devices.end(); idevice++) {
72  if ((*idevice)->getDeviceType() != LASERDRIVER) {
73  continue;
74  }
75 
76  // Cast to retrieve appropriate description object
77  laserdriverDescription* desc = dynamic_cast<laserdriverDescription*>(*idevice);
78  if (!desc) {
79  continue;
80  }
81 
82  // Retrieve device addresses from device description
84 
85  // Iterate through LLD channels
86  for (uint16_t ichan = 0; ichan < sistrip::CHANS_PER_LLD; ichan++) {
87  // Construct key from device description
88  SiStripFecKey fec_key(addr.fecCrate_, addr.fecSlot_, addr.fecRing_, addr.ccuAddr_, addr.ccuChan_, ichan + 1);
89 
90  // Iterate through all channels and extract LLD settings
91  Analyses::const_iterator iter = data(allowSelectiveUpload_).find(fec_key.key());
92  if (iter != data(allowSelectiveUpload_).end()) {
93  OptoScanAnalysis* anal = dynamic_cast<OptoScanAnalysis*>(iter->second);
94  if (!anal) {
95  edm::LogError(mlDqmClient_) << "[OptoScanHistosUsingDb::" << __func__ << "]"
96  << " NULL pointer to analysis object!";
97  continue;
98  }
99 
100  uint16_t gain = anal->gain();
101  std::stringstream ss;
102  ss << "[OptoScanHistosUsingDb::" << __func__ << "]"
103  << " Updating LLD gain/bias settings for crate/crate/FEC/ring/CCU/module/LLD " << fec_key.fecCrate() << "/"
104  << fec_key.fecSlot() << "/" << fec_key.fecRing() << "/" << fec_key.ccuAddr() << "/" << fec_key.ccuChan()
105  << "/" << fec_key.channel() << " from " << static_cast<uint16_t>(desc->getGain(ichan)) << "/"
106  << static_cast<uint16_t>(desc->getBias(ichan));
107  if (!skipGainUpdate_)
108  desc->setGain(ichan, gain);
109  desc->setBias(ichan, anal->bias()[gain]);
110  updated++;
111  ss << " to " << static_cast<uint16_t>(desc->getGain(ichan)) << "/"
112  << static_cast<uint16_t>(desc->getBias(ichan));
113  LogTrace(mlDqmClient_) << ss.str();
114 
115  } else {
116  if (deviceIsPresent(fec_key)) {
117  edm::LogWarning(mlDqmClient_) << "[OptoScanHistosUsingDb::" << __func__ << "]"
118  << " Unable to find FEC key with params crate/FEC/ring/CCU/module/LLD "
119  << fec_key.fecCrate() << "/" << fec_key.fecSlot() << "/" << fec_key.fecRing()
120  << "/" << fec_key.ccuAddr() << "/" << fec_key.ccuChan() << "/"
121  << fec_key.channel();
122  }
123  }
124  }
125  }
126 
127  edm::LogVerbatim(mlDqmClient_) << "[OptoScanHistosUsingDb::" << __func__ << "]"
128  << " Updated LLD bias/gain settings for " << updated << " modules";
129 }
130 
131 // -----------------------------------------------------------------------------
134  OptoScanAnalysis* anal = dynamic_cast<OptoScanAnalysis*>(analysis->second);
135  if (!anal) {
136  return;
137  }
138 
139  SiStripFecKey fec_key(anal->fecKey());
140  SiStripFedKey fed_key(anal->fedKey());
141 
142  for (uint16_t iapv = 0; iapv < 2; ++iapv) {
143  // Create description
144  OptoScanAnalysisDescription* tmp;
145  tmp = new OptoScanAnalysisDescription(anal->baseSlope()[0],
146  anal->baseSlope()[1],
147  anal->baseSlope()[2],
148  anal->baseSlope()[3],
149  anal->gain(),
150  anal->bias()[0],
151  anal->bias()[1],
152  anal->bias()[2],
153  anal->bias()[3],
154  anal->measGain()[0],
155  anal->measGain()[1],
156  anal->measGain()[2],
157  anal->measGain()[3],
158  anal->zeroLight()[0],
159  anal->zeroLight()[1],
160  anal->zeroLight()[2],
161  anal->zeroLight()[3],
162  anal->linkNoise()[0],
163  anal->linkNoise()[1],
164  anal->linkNoise()[2],
165  anal->linkNoise()[3],
166  anal->liftOff()[0],
167  anal->liftOff()[1],
168  anal->liftOff()[2],
169  anal->liftOff()[3],
170  anal->threshold()[0],
171  anal->threshold()[1],
172  anal->threshold()[2],
173  anal->threshold()[3],
174  anal->tickHeight()[0],
175  anal->tickHeight()[1],
176  anal->tickHeight()[2],
177  anal->tickHeight()[3],
178  fec_key.fecCrate(),
179  fec_key.fecSlot(),
180  fec_key.fecRing(),
181  fec_key.ccuAddr(),
182  fec_key.ccuChan(),
183  SiStripFecKey::i2cAddr(fec_key.lldChan(), !iapv),
184  db()->dbParams().partitions().begin()->second.partitionName(),
185  db()->dbParams().partitions().begin()->second.runNumber(),
186  anal->isValid(),
187  "",
188  fed_key.fedId(),
189  fed_key.feUnit(),
190  fed_key.feChan(),
191  fed_key.fedApv());
192 
193  // Add comments
194  typedef std::vector<std::string> Strings;
195  Strings errors = anal->getErrorCodes();
196  Strings::const_iterator istr = errors.begin();
197  Strings::const_iterator jstr = errors.end();
198  for (; istr != jstr; ++istr) {
199  tmp->addComments(*istr);
200  }
201 
202  // Store description
203  desc.push_back(tmp);
204  }
205 }
SiStripConfigDb::getDeviceDescriptions
DeviceDescriptionsRange getDeviceDescriptions(std::string partition="")
Definition: DeviceDescriptions.cc:11
MessageLogger.h
SiStripConfigDb::DeviceDescriptionsRange
DeviceDescriptions::range DeviceDescriptionsRange
Definition: SiStripConfigDb.h:110
CommissioningHistograms::pset
const edm::ParameterSet & pset() const
Definition: CommissioningHistograms.h:163
SiStripConfigDb::dbParams
const SiStripDbParams & dbParams() const
Definition: SiStripConfigDb.h:421
SiStripKey::key
const uint32_t & key() const
Definition: SiStripKey.h:120
SiStripConfigDb::deviceAddress
DeviceAddress deviceAddress(const deviceDescription &)
Definition: DeviceDescriptions.cc:503
edm
HLT enums.
Definition: AlignableModifier.h:19
sistrip::OPTO_SCAN
Definition: ConstantsForRunType.h:74
OptoScanHistosUsingDb.h
SiStripFecKey::fecCrate
const uint16_t & fecCrate() const
Definition: SiStripFecKey.h:198
edm::ParameterSet::existsAs
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:171
OptoScanHistosUsingDb::create
void create(SiStripConfigDb::AnalysisDescriptionsV &, Analysis) override
Definition: OptoScanHistosUsingDb.cc:133
OptoScanHistosUsingDb::OptoScanHistosUsingDb
OptoScanHistosUsingDb(const edm::ParameterSet &pset, DQMStore *, SiStripConfigDb *const)
Definition: OptoScanHistosUsingDb.cc:13
SiStripFedKey
A container class for generic run and event-related info, information required by the commissioning a...
Definition: SiStripFedKey.h:56
CommissioningHistograms::data
Analyses & data(bool getMaskedData=false)
Definition: CommissioningHistograms.cc:718
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
Strings
std::vector< std::string > Strings
Definition: MsgTools.h:18
CommissioningHistosUsingDb
Definition: CommissioningHistosUsingDb.h:16
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
sistrip::mlDqmClient_
static const char mlDqmClient_[]
Definition: ConstantsForLogger.h:19
dqmiodatasetharvest.db
db
Definition: dqmiodatasetharvest.py:119
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
OptoScanHistosUsingDb::uploadConfigurations
void uploadConfigurations() override
Definition: OptoScanHistosUsingDb.cc:40
SiStripKey::channel
const uint16_t & channel() const
Definition: SiStripKey.h:123
generateTowerEtThresholdLUT.addr
addr
Definition: generateTowerEtThresholdLUT.py:57
dqm::legacy::DQMStore
Definition: DQMStore.h:727
errors
Definition: errors.py:1
SiStripFecKey::fecRing
const uint16_t & fecRing() const
Definition: SiStripFecKey.h:200
SiStripConfigDb
An interface class to the DeviceFactory.
Definition: SiStripConfigDb.h:47
SiStripFecKey
Utility class that identifies a position within the strip tracker control structure,...
Definition: SiStripFecKey.h:45
SiStripFecKey.h
SiStripConfigDb::uploadDeviceDescriptions
void uploadDeviceDescriptions(std::string partition="")
Definition: DeviceDescriptions.cc:264
SiStripFecKey::ccuChan
const uint16_t & ccuChan() const
Definition: SiStripFecKey.h:202
OptoScanHistosUsingDb::~OptoScanHistosUsingDb
~OptoScanHistosUsingDb() override
Definition: OptoScanHistosUsingDb.cc:33
OptoScanAnalysis.h
sistrip::CHANS_PER_LLD
static const uint16_t CHANS_PER_LLD
Definition: ConstantsForHardwareSystems.h:39
SiStripConstants.h
edm::ParameterSet
Definition: ParameterSet.h:47
ParameterSet
Definition: Functions.h:16
OptoScanHistosUsingDb::update
void update(SiStripConfigDb::DeviceDescriptionsRange)
Definition: OptoScanHistosUsingDb.cc:67
SiStripDbParams::partitions
const_iterator_range partitions() const
Definition: SiStripDbParams.h:178
OptoScanHistograms
Definition: OptoScanHistograms.h:7
CommissioningHistosUsingDb::doUploadConf
bool doUploadConf() const
Definition: CommissioningHistosUsingDb.h:91
CommissioningHistograms
Definition: CommissioningHistograms.h:23
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
PedestalClient_cfi.gain
gain
Definition: PedestalClient_cfi.py:37
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
SiStripFecKey::i2cAddr
const uint16_t & i2cAddr() const
Definition: SiStripFecKey.h:204
OptoScanHistosUsingDb::allowSelectiveUpload_
bool allowSelectiveUpload_
Definition: OptoScanHistosUsingDb.h:24
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
SiStripFecKey::ccuAddr
const uint16_t & ccuAddr() const
Definition: SiStripFecKey.h:201
OptoScanAnalysis
Histogram-based analysis for opto bias/gain scan.
Definition: OptoScanAnalysis.h:15
SiStripConfigDb::AnalysisDescriptionsV
std::vector< AnalysisDescription * > AnalysisDescriptionsV
Definition: SiStripConfigDb.h:135
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
CommissioningHistosUsingDb::db
SiStripConfigDb *const db() const
Definition: CommissioningHistosUsingDb.h:93
SiStripConfigDb::DeviceAddress
Definition: SiStripConfigDb.h:141
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:224
CommissioningHistosUsingDb::deviceIsPresent
bool deviceIsPresent(const SiStripFecKey &)
Definition: CommissioningHistosUsingDb.cc:369
sistrip
sistrip classes
Definition: SiStripQualityHelpers.h:14
conversion_template_cfg.anal
anal
Definition: conversion_template_cfg.py:16
SiStripFecKey::fecSlot
const uint16_t & fecSlot() const
Definition: SiStripFecKey.h:199
CommissioningHistograms::Analysis
Analyses::iterator Analysis
Definition: CommissioningHistograms.h:58
OptoScanHistosUsingDb::skipGainUpdate_
bool skipGainUpdate_
Definition: OptoScanHistosUsingDb.h:22
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27