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 }
Histogram-based analysis for opto bias/gain scan.
const uint16_t & channel() const
Definition: SiStripKey.h:123
Log< level::Info, true > LogVerbatim
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
void uploadConfigurations() override
OptoScanHistosUsingDb(const edm::ParameterSet &pset, DQMStore *, SiStripConfigDb *const, edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken)
Analyses & data(bool getMaskedData=false)
const uint16_t & ccuAddr() const
A container class for generic run and event-related info, information required by the commissioning a...
Definition: SiStripFedKey.h:56
bool deviceIsPresent(const SiStripFecKey &)
std::vector< std::string > Strings
Definition: MsgTools.h:18
const uint16_t & ccuChan() const
void create(SiStripConfigDb::AnalysisDescriptionsV &, Analysis) override
static const char mlDqmClient_[]
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:172
Log< level::Error, false > LogError
const_iterator_range partitions() const
sistrip classes
#define LogTrace(id)
Utility class that identifies a position within the strip tracker control structure, down to the level of an APV25.
Definition: SiStripFecKey.h:45
const uint16_t & i2cAddr() const
void update(SiStripConfigDb::DeviceDescriptionsRange)
SiStripConfigDb *const db() const
DeviceDescriptions::range DeviceDescriptionsRange
static const uint16_t CHANS_PER_LLD
An interface class to the DeviceFactory.
const uint32_t & key() const
Definition: SiStripKey.h:120
DeviceAddress deviceAddress(const deviceDescription &)
const uint16_t & fecSlot() const
HLT enums.
std::vector< AnalysisDescription * > AnalysisDescriptionsV
const edm::ParameterSet & pset() const
Definition: errors.py:1
const SiStripDbParams & dbParams() const
DeviceDescriptionsRange getDeviceDescriptions(std::string partition="")
Log< level::Warning, false > LogWarning
void uploadDeviceDescriptions(std::string partition="")
const uint16_t & fecRing() const
tmp
align.sh
Definition: createJobs.py:716
const uint16_t & fecCrate() const