CMS 3D CMS Logo

VpspScanHistosUsingDb.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>("VpspScanParameters"), bei, sistrip::VPSP_SCAN),
19  VpspScanHistograms(pset.getParameter<edm::ParameterSet>("VpspScanParameters"), bei) {
20  LogTrace(mlDqmClient_) << "[VpspScanHistosUsingDb::" << __func__ << "]"
21  << " Constructing object...";
22 
24  this->pset().existsAs<bool>("doSelectiveUpload") ? this->pset().getParameter<bool>("doSelectiveUpload") : false;
25  LogTrace(mlDqmClient_) << "[PedestalsHistosUsingDb::" << __func__ << "]"
26  << " Selective upload of modules set to : " << allowSelectiveUpload_;
27 }
28 
29 // -----------------------------------------------------------------------------
32  LogTrace(mlDqmClient_) << "[VpspScanHistosUsingDb::" << __func__ << "]"
33  << " Destructing object...";
34 }
35 
36 // -----------------------------------------------------------------------------
39  LogTrace(mlDqmClient_) << "[VpspScanHistosUsingDb::" << __func__ << "]";
40 
41  if (!db()) {
42  edm::LogError(mlDqmClient_) << "[VpspScanHistosUsingDb::" << __func__ << "]"
43  << " NULL pointer to SiStripConfigDb interface!"
44  << " Aborting upload...";
45  return;
46  }
47 
48  // Update all APV device descriptions with new VPSP settings
50  update(devices);
51  if (doUploadConf()) {
52  edm::LogVerbatim(mlDqmClient_) << "[VpspScanHistosUsingDb::" << __func__ << "]"
53  << " Uploading VPSP settings to DB...";
55  edm::LogVerbatim(mlDqmClient_) << "[VpspScanHistosUsingDb::" << __func__ << "]"
56  << " Uploaded VPSP settings to DB!";
57  } else {
58  edm::LogWarning(mlDqmClient_) << "[VpspScanHistosUsingDb::" << __func__ << "]"
59  << " TEST only! No VPSP settings will be uploaded to DB...";
60  }
61  LogTrace(mlDqmClient_) << "[VpspScanHistosUsingDb::" << __func__ << "]"
62  << " Upload of VPSP settings to DB finished!";
63 }
64 
65 // -----------------------------------------------------------------------------
68  // Iterate through devices and update device descriptions
69  SiStripConfigDb::DeviceDescriptionsV::const_iterator idevice;
70  for (idevice = devices.begin(); idevice != devices.end(); idevice++) {
71  // Check device type
72  if ((*idevice)->getDeviceType() != APV25) {
73  continue;
74  }
75 
76  // Cast to retrieve appropriate description object
77  apvDescription* desc = dynamic_cast<apvDescription*>(*idevice);
78  if (!desc) {
79  continue;
80  }
81 
82  // Retrieve device addresses from device description
84 
85  // Retrieve LLD channel and APV numbers
86  uint16_t ichan = (desc->getAddress() - 0x20) / 2;
87  uint16_t iapv = (desc->getAddress() - 0x20) % 2;
88 
89  // Construct key from device description
90  SiStripFecKey fec_key(addr.fecCrate_, addr.fecSlot_, addr.fecRing_, addr.ccuAddr_, addr.ccuChan_, ichan + 1);
91 
92  // Iterate through all channels and extract LLD settings
93  Analyses::const_iterator iter = data(allowSelectiveUpload_).find(fec_key.key());
94  if (iter != data(allowSelectiveUpload_).end()) {
95  VpspScanAnalysis* anal = dynamic_cast<VpspScanAnalysis*>(iter->second);
96  if (!anal) {
97  edm::LogError(mlDqmClient_) << "[VpspScanHistosUsingDb::" << __func__ << "]"
98  << " NULL pointer to analysis object!";
99  continue;
100  }
101 
102  std::stringstream ss;
103  ss << "[VpspScanHistosUsingDb::" << __func__ << "]"
104  << " Updating VPSP setting for crate/FEC/slot/ring/CCU/LLD/APV " << fec_key.fecCrate() << "/"
105  << fec_key.fecSlot() << "/" << fec_key.fecRing() << "/" << fec_key.ccuAddr() << "/" << fec_key.ccuChan() << "/"
106  << fec_key.channel() << iapv << " from " << static_cast<uint16_t>(desc->getVpsp());
107  if (iapv == 0) {
108  desc->setVpsp(anal->vpsp()[0]);
109  }
110  if (iapv == 1) {
111  desc->setVpsp(anal->vpsp()[1]);
112  }
113  ss << " to " << static_cast<uint16_t>(desc->getVpsp());
114  LogTrace(mlDqmClient_) << ss.str();
115 
116  } else {
117  if (deviceIsPresent(fec_key)) {
118  edm::LogWarning(mlDqmClient_) << "[VpspScanHistosUsingDb::" << __func__ << "]"
119  << " Unable to find FEC key with params FEC/slot/ring/CCU/LLDchan/APV: "
120  << fec_key.fecCrate() << "/" << fec_key.fecSlot() << "/" << fec_key.fecRing()
121  << "/" << fec_key.ccuAddr() << "/" << fec_key.ccuChan() << "/"
122  << fec_key.channel() << "/" << iapv + 1;
123  }
124  }
125  }
126 }
127 
128 // -----------------------------------------------------------------------------
131  VpspScanAnalysis* anal = dynamic_cast<VpspScanAnalysis*>(analysis->second);
132  if (!anal) {
133  return;
134  }
135 
136  SiStripFecKey fec_key(anal->fecKey());
137  SiStripFedKey fed_key(anal->fedKey());
138 
139  for (uint16_t iapv = 0; iapv < 2; ++iapv) {
140  // Create description
141  VpspScanAnalysisDescription* tmp;
142  tmp = new VpspScanAnalysisDescription(anal->vpsp()[iapv],
143  anal->adcLevel()[iapv],
144  anal->fraction()[iapv],
145  anal->topEdge()[iapv],
146  anal->bottomEdge()[iapv],
147  anal->topLevel()[iapv],
148  anal->bottomLevel()[iapv],
149  fec_key.fecCrate(),
150  fec_key.fecSlot(),
151  fec_key.fecRing(),
152  fec_key.ccuAddr(),
153  fec_key.ccuChan(),
154  SiStripFecKey::i2cAddr(fec_key.lldChan(), !iapv),
155  db()->dbParams().partitions().begin()->second.partitionName(),
156  db()->dbParams().partitions().begin()->second.runNumber(),
157  anal->isValid(),
158  "",
159  fed_key.fedId(),
160  fed_key.feUnit(),
161  fed_key.feChan(),
162  fed_key.fedApv());
163 
164  // Add comments
165  typedef std::vector<std::string> Strings;
166  Strings errors = anal->getErrorCodes();
167  Strings::const_iterator istr = errors.begin();
168  Strings::const_iterator jstr = errors.end();
169  for (; istr != jstr; ++istr) {
170  tmp->addComments(*istr);
171  }
172 
173  // Store description
174  desc.push_back(tmp);
175  }
176 }
SiStripConfigDb::getDeviceDescriptions
DeviceDescriptionsRange getDeviceDescriptions(std::string partition="")
Definition: DeviceDescriptions.cc:11
VpspScanHistosUsingDb::uploadConfigurations
void uploadConfigurations() override
Definition: VpspScanHistosUsingDb.cc:38
VpspScanHistosUsingDb::update
void update(SiStripConfigDb::DeviceDescriptionsRange)
Definition: VpspScanHistosUsingDb.cc:67
MessageLogger.h
sistrip::VPSP_SCAN
Definition: ConstantsForRunType.h:82
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
VpspScanHistograms
Definition: VpspScanHistograms.h:7
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
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
VpspScanHistosUsingDb::allowSelectiveUpload_
bool allowSelectiveUpload_
Definition: VpspScanHistosUsingDb.h:25
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
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
VpspScanHistosUsingDb.h
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
SiStripConstants.h
edm::ParameterSet
Definition: ParameterSet.h:47
ParameterSet
Definition: Functions.h:16
SiStripDbParams::partitions
const_iterator_range partitions() const
Definition: SiStripDbParams.h:178
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 >
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
SiStripFecKey::i2cAddr
const uint16_t & i2cAddr() const
Definition: SiStripFecKey.h:204
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
VpspScanHistosUsingDb::VpspScanHistosUsingDb
VpspScanHistosUsingDb(const edm::ParameterSet &pset, DQMStore *, SiStripConfigDb *const, edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken)
Definition: VpspScanHistosUsingDb.cc:13
SiStripFecKey::ccuAddr
const uint16_t & ccuAddr() const
Definition: SiStripFecKey.h:201
VpspScanHistosUsingDb::create
void create(SiStripConfigDb::AnalysisDescriptionsV &, Analysis) override
Definition: VpspScanHistosUsingDb.cc:130
SiStripConfigDb::AnalysisDescriptionsV
std::vector< AnalysisDescription * > AnalysisDescriptionsV
Definition: SiStripConfigDb.h:135
VpspScanAnalysis
Histogram-based analysis for VPSP scan.
Definition: VpspScanAnalysis.h:15
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
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
VpspScanAnalysis.h
VpspScanHistosUsingDb::~VpspScanHistosUsingDb
~VpspScanHistosUsingDb() override
Definition: VpspScanHistosUsingDb.cc:31