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  DQMStore* bei,
15  SiStripConfigDb* const db,
17  : CommissioningHistograms(pset.getParameter<edm::ParameterSet>("OptoScanParameters"), bei, sistrip::OPTO_SCAN),
19  OptoScanHistograms(pset.getParameter<edm::ParameterSet>("OptoScanParameters"), bei) {
20  LogTrace(mlDqmClient_) << "[OptoScanHistosUsingDb::" << __func__ << "]"
21  << " Constructing object...";
22  skipGainUpdate_ = this->pset().getParameter<bool>("SkipGainUpdate");
23  if (skipGainUpdate_)
24  LogTrace(mlDqmClient_) << "[OptoScanHistosUsingDb::" << __func__ << "]"
25  << " Skipping db update of gain parameters.";
26 
28  this->pset().existsAs<bool>("doSelectiveUpload") ? this->pset().getParameter<bool>("doSelectiveUpload") : false;
30  LogTrace(mlDqmClient_) << "[OptoScanHistosUsingDb::" << __func__ << "]"
31  << " Enabling selective upload of gain parameters";
32 }
33 
34 // -----------------------------------------------------------------------------
37  LogTrace(mlDqmClient_) << "[OptoScanHistosUsingDb::" << __func__ << "]"
38  << " Destructing object...";
39 }
40 
41 // -----------------------------------------------------------------------------
44  LogTrace(mlDqmClient_) << "[OptoScanHistosUsingDb::" << __func__ << "]";
45 
46  if (!db()) {
47  edm::LogError(mlDqmClient_) << "[OptoScanHistosUsingDb::" << __func__ << "]"
48  << " NULL pointer to SiStripConfigDb interface!"
49  << " Aborting upload...";
50  return;
51  }
52 
53  // Update LLD descriptions with new bias/gain settings
55  update(devices);
56  if (doUploadConf()) {
57  edm::LogVerbatim(mlDqmClient_) << "[OptoScanHistosUsingDb::" << __func__ << "]"
58  << " Uploading LLD settings to DB...";
60  edm::LogVerbatim(mlDqmClient_) << "[OptoScanHistosUsingDb::" << __func__ << "]"
61  << " Upload of LLD settings to DB finished!";
62  } else {
63  edm::LogWarning(mlDqmClient_) << "[OptoScanHistosUsingDb::" << __func__ << "]"
64  << " TEST only! No LLD settings will be uploaded to DB...";
65  }
66 }
67 
68 // -----------------------------------------------------------------------------
71  // Iterate through devices and update device descriptions
72  uint16_t updated = 0;
73  SiStripConfigDb::DeviceDescriptionsV::const_iterator idevice;
74  for (idevice = devices.begin(); idevice != devices.end(); idevice++) {
75  if ((*idevice)->getDeviceType() != LASERDRIVER) {
76  continue;
77  }
78 
79  // Cast to retrieve appropriate description object
80  laserdriverDescription* desc = dynamic_cast<laserdriverDescription*>(*idevice);
81  if (!desc) {
82  continue;
83  }
84 
85  // Retrieve device addresses from device description
87 
88  // Iterate through LLD channels
89  for (uint16_t ichan = 0; ichan < sistrip::CHANS_PER_LLD; ichan++) {
90  // Construct key from device description
91  SiStripFecKey fec_key(addr.fecCrate_, addr.fecSlot_, addr.fecRing_, addr.ccuAddr_, addr.ccuChan_, ichan + 1);
92 
93  // Iterate through all channels and extract LLD settings
94  Analyses::const_iterator iter = data(allowSelectiveUpload_).find(fec_key.key());
95  if (iter != data(allowSelectiveUpload_).end()) {
96  OptoScanAnalysis* anal = dynamic_cast<OptoScanAnalysis*>(iter->second);
97  if (!anal) {
98  edm::LogError(mlDqmClient_) << "[OptoScanHistosUsingDb::" << __func__ << "]"
99  << " NULL pointer to analysis object!";
100  continue;
101  }
102 
103  uint16_t gain = anal->gain();
104  std::stringstream ss;
105  ss << "[OptoScanHistosUsingDb::" << __func__ << "]"
106  << " Updating LLD gain/bias settings for crate/crate/FEC/ring/CCU/module/LLD " << fec_key.fecCrate() << "/"
107  << fec_key.fecSlot() << "/" << fec_key.fecRing() << "/" << fec_key.ccuAddr() << "/" << fec_key.ccuChan()
108  << "/" << fec_key.channel() << " from " << static_cast<uint16_t>(desc->getGain(ichan)) << "/"
109  << static_cast<uint16_t>(desc->getBias(ichan));
110  if (!skipGainUpdate_)
111  desc->setGain(ichan, gain);
112  desc->setBias(ichan, anal->bias()[gain]);
113  updated++;
114  ss << " to " << static_cast<uint16_t>(desc->getGain(ichan)) << "/"
115  << static_cast<uint16_t>(desc->getBias(ichan));
116  LogTrace(mlDqmClient_) << ss.str();
117 
118  } else {
119  if (deviceIsPresent(fec_key)) {
120  edm::LogWarning(mlDqmClient_) << "[OptoScanHistosUsingDb::" << __func__ << "]"
121  << " Unable to find FEC key with params crate/FEC/ring/CCU/module/LLD "
122  << fec_key.fecCrate() << "/" << fec_key.fecSlot() << "/" << fec_key.fecRing()
123  << "/" << fec_key.ccuAddr() << "/" << fec_key.ccuChan() << "/"
124  << fec_key.channel();
125  }
126  }
127  }
128  }
129 
130  edm::LogVerbatim(mlDqmClient_) << "[OptoScanHistosUsingDb::" << __func__ << "]"
131  << " Updated LLD bias/gain settings for " << updated << " modules";
132 }
133 
134 // -----------------------------------------------------------------------------
137  OptoScanAnalysis* anal = dynamic_cast<OptoScanAnalysis*>(analysis->second);
138  if (!anal) {
139  return;
140  }
141 
142  SiStripFecKey fec_key(anal->fecKey());
143  SiStripFedKey fed_key(anal->fedKey());
144 
145  for (uint16_t iapv = 0; iapv < 2; ++iapv) {
146  // Create description
147  OptoScanAnalysisDescription* tmp;
148  tmp = new OptoScanAnalysisDescription(anal->baseSlope()[0],
149  anal->baseSlope()[1],
150  anal->baseSlope()[2],
151  anal->baseSlope()[3],
152  anal->gain(),
153  anal->bias()[0],
154  anal->bias()[1],
155  anal->bias()[2],
156  anal->bias()[3],
157  anal->measGain()[0],
158  anal->measGain()[1],
159  anal->measGain()[2],
160  anal->measGain()[3],
161  anal->zeroLight()[0],
162  anal->zeroLight()[1],
163  anal->zeroLight()[2],
164  anal->zeroLight()[3],
165  anal->linkNoise()[0],
166  anal->linkNoise()[1],
167  anal->linkNoise()[2],
168  anal->linkNoise()[3],
169  anal->liftOff()[0],
170  anal->liftOff()[1],
171  anal->liftOff()[2],
172  anal->liftOff()[3],
173  anal->threshold()[0],
174  anal->threshold()[1],
175  anal->threshold()[2],
176  anal->threshold()[3],
177  anal->tickHeight()[0],
178  anal->tickHeight()[1],
179  anal->tickHeight()[2],
180  anal->tickHeight()[3],
181  fec_key.fecCrate(),
182  fec_key.fecSlot(),
183  fec_key.fecRing(),
184  fec_key.ccuAddr(),
185  fec_key.ccuChan(),
186  SiStripFecKey::i2cAddr(fec_key.lldChan(), !iapv),
187  db()->dbParams().partitions().begin()->second.partitionName(),
188  db()->dbParams().partitions().begin()->second.runNumber(),
189  anal->isValid(),
190  "",
191  fed_key.fedId(),
192  fed_key.feUnit(),
193  fed_key.feChan(),
194  fed_key.fedApv());
195 
196  // Add comments
197  typedef std::vector<std::string> Strings;
198  Strings errors = anal->getErrorCodes();
199  Strings::const_iterator istr = errors.begin();
200  Strings::const_iterator jstr = errors.end();
201  for (; istr != jstr; ++istr) {
202  tmp->addComments(*istr);
203  }
204 
205  // Store description
206  desc.push_back(tmp);
207  }
208 }
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::OptoScanHistosUsingDb
OptoScanHistosUsingDb(const edm::ParameterSet &pset, DQMStore *, SiStripConfigDb *const, edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken)
Definition: OptoScanHistosUsingDb.cc:13
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:136
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:18
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:43
SiStripKey::channel
const uint16_t & channel() const
Definition: SiStripKey.h:123
generateTowerEtThresholdLUT.addr
addr
Definition: generateTowerEtThresholdLUT.py:57
dqm::legacy::DQMStore
Definition: DQMStore.h:728
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:36
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:70
SiStripDbParams::partitions
const_iterator_range partitions() const
Definition: SiStripDbParams.h:178
OptoScanHistograms
Definition: OptoScanHistograms.h:7
CommissioningHistosUsingDb::doUploadConf
bool doUploadConf() const
Definition: CommissioningHistosUsingDb.h:97
CommissioningHistograms
Definition: CommissioningHistograms.h:23
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd >
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:27
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:99
SiStripConfigDb::DeviceAddress
Definition: SiStripConfigDb.h:141
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
CommissioningHistosUsingDb::deviceIsPresent
bool deviceIsPresent(const SiStripFecKey &)
Definition: CommissioningHistosUsingDb.cc:368
sistrip
sistrip classes
Definition: EnsembleCalibrationLA.cc:10
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:25
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27