CMS 3D CMS Logo

PedestalsHistosUsingDb.cc
Go to the documentation of this file.
1 
8 #include <iostream>
9 
10 using namespace sistrip;
11 
12 // -----------------------------------------------------------------------------
15  : CommissioningHistograms(pset.getParameter<edm::ParameterSet>("PedestalsParameters"), bei, sistrip::PEDESTALS),
17  PedestalsHistograms(pset.getParameter<edm::ParameterSet>("PedestalsParameters"), bei) {
18  LogTrace(mlDqmClient_) << "[PedestalsHistosUsingDb::" << __func__ << "]"
19  << " Constructing object...";
20  highThreshold_ = this->pset().getParameter<double>("HighThreshold");
21  lowThreshold_ = this->pset().getParameter<double>("LowThreshold");
22  LogTrace(mlDqmClient_) << "[PedestalsHistosUsingDb::" << __func__ << "]"
23  << " Set FED zero suppression high/low threshold to " << highThreshold_ << "/"
24  << lowThreshold_;
25  disableBadStrips_ = this->pset().getParameter<bool>("DisableBadStrips");
26  keepStripsDisabled_ = this->pset().getParameter<bool>("KeepStripsDisabled");
27  LogTrace(mlDqmClient_) << "[PedestalsHistosUsingDb::" << __func__ << "]"
28  << " Disabling strips: " << disableBadStrips_
29  << " ; keeping previously disabled strips: " << keepStripsDisabled_;
30 
32  this->pset().existsAs<bool>("doSelectiveUpload") ? this->pset().getParameter<bool>("doSelectiveUpload") : false;
33  LogTrace(mlDqmClient_) << "[PedestalsHistosUsingDb::" << __func__ << "]"
34  << " Selective upload of modules set to : " << allowSelectiveUpload_;
35 }
36 
37 // -----------------------------------------------------------------------------
40  LogTrace(mlDqmClient_) << "[PedestalsHistosUsingDb::" << __func__ << "]"
41  << " Destructing object...";
42 }
43 
44 // -----------------------------------------------------------------------------
47  LogTrace(mlDqmClient_) << "[PedestalsHistosUsingDb::" << __func__ << "]";
48 
49  if (!db()) {
50  edm::LogError(mlDqmClient_) << "[PedestalsHistosUsingDb::" << __func__ << "]"
51  << " NULL pointer to SiStripConfigDb interface!"
52  << " Aborting upload...";
53  return;
54  }
55 
56  // Update FED descriptions with new peds/noise values
58  update(feds);
59  if (doUploadConf()) {
60  edm::LogVerbatim(mlDqmClient_) << "[PedestalsHistosUsingDb::" << __func__ << "]"
61  << " Uploading pedestals/noise to DB...";
63  edm::LogVerbatim(mlDqmClient_) << "[PedestalsHistosUsingDb::" << __func__ << "]"
64  << " Completed database upload of " << feds.size() << " FED descriptions!";
65  } else {
66  edm::LogWarning(mlDqmClient_) << "[PedestalsHistosUsingDb::" << __func__ << "]"
67  << " TEST! No pedestals/noise values will be uploaded to DB...";
68  }
69 }
70 
71 // -----------------------------------------------------------------------------
74  // Iterate through feds and update fed descriptions
75  uint16_t updated = 0;
76  SiStripConfigDb::FedDescriptionsV::const_iterator ifed;
77  for (ifed = feds.begin(); ifed != feds.end(); ifed++) {
78  for (uint16_t ichan = 0; ichan < sistrip::FEDCH_PER_FED; ichan++) {
79  // Build FED and FEC keys
80  const FedChannelConnection& conn = cabling()->fedConnection((*ifed)->getFedId(), ichan);
81  if (conn.fecCrate() == sistrip::invalid_ || conn.fecSlot() == sistrip::invalid_ ||
82  conn.fecRing() == sistrip::invalid_ || conn.ccuAddr() == sistrip::invalid_ ||
83  conn.ccuChan() == sistrip::invalid_ || conn.lldChannel() == sistrip::invalid_) {
84  continue;
85  }
86  SiStripFedKey fed_key(conn.fedId(), SiStripFedKey::feUnit(conn.fedCh()), SiStripFedKey::feChan(conn.fedCh()));
87  SiStripFecKey fec_key(
88  conn.fecCrate(), conn.fecSlot(), conn.fecRing(), conn.ccuAddr(), conn.ccuChan(), conn.lldChannel());
89 
90  // Locate appropriate analysis object
91  Analyses::const_iterator iter = data(allowSelectiveUpload_).find(fec_key.key());
92  if (iter != data(allowSelectiveUpload_).end()) {
93  // Check if analysis is valid
94  if (!iter->second->isValid()) {
95  continue;
96  }
97 
98  PedestalsAnalysis* anal = dynamic_cast<PedestalsAnalysis*>(iter->second);
99  if (!anal) {
100  edm::LogError(mlDqmClient_) << "[PedestalsHistosUsingDb::" << __func__ << "]"
101  << " NULL pointer to analysis object!";
102  continue;
103  }
104 
105  // Determine the pedestal shift to apply
106  uint32_t pedshift = 127;
107  for (uint16_t iapv = 0; iapv < sistrip::APVS_PER_FEDCH; iapv++) {
108  uint32_t pedmin = (uint32_t)anal->pedsMin()[iapv];
109  pedshift = pedmin < pedshift ? pedmin : pedshift;
110  std::stringstream ss;
111  ss << "iapv: " << iapv << " pedsMin()[iapv]: " << anal->pedsMin()[iapv] << " pedmin: " << pedmin
112  << " pedshift: " << pedshift;
113  edm::LogWarning(mlDqmClient_) << ss.str();
114  }
115 
116  // Iterate through APVs and strips
117  for (uint16_t iapv = 0; iapv < sistrip::APVS_PER_FEDCH; iapv++) {
118  for (uint16_t istr = 0; istr < anal->peds()[iapv].size(); istr++) {
119  // get the information on the strip as it was on the db
120  Fed9U::Fed9UAddress addr(ichan, iapv, istr);
121  Fed9U::Fed9UStripDescription temp = (*ifed)->getFedStrips().getStrip(addr);
122 
123  if (anal->peds()[iapv][istr] < 1.) { //@@ ie, zero
125  << "[PedestalsHistosUsingDb::" << __func__ << "]"
126  << " Skipping ZERO pedestal value (ie, NO UPLOAD TO DB!) for FedKey/Id/Ch: " << hex << setw(8)
127  << setfill('0') << fed_key.key() << dec << "/" << (*ifed)->getFedId() << "/" << ichan
128  << " and device with FEC/slot/ring/CCU/LLD " << fec_key.fecCrate() << "/" << fec_key.fecSlot() << "/"
129  << fec_key.fecRing() << "/" << fec_key.ccuAddr() << "/" << fec_key.ccuChan() << "/"
130  << fec_key.channel();
131  continue; //@@ do not upload
132  }
133 
134  // determine whether we need to disable the strip
135  bool disableStrip = false;
136  if (keepStripsDisabled_) {
137  disableStrip = temp.getDisable();
138  } else if (disableBadStrips_) {
139  PedestalsAnalysis::VInt dead = anal->dead()[iapv];
140  if (find(dead.begin(), dead.end(), istr) != dead.end())
141  disableStrip = true;
142  PedestalsAnalysis::VInt noisy = anal->noisy()[iapv];
143  if (find(noisy.begin(), noisy.end(), istr) != noisy.end())
144  disableStrip = true;
145  }
146 
147  Fed9U::Fed9UStripDescription data(static_cast<uint32_t>(anal->peds()[iapv][istr] - pedshift),
150  anal->noise()[iapv][istr],
151  disableStrip);
152 
153  std::stringstream ss;
154  if (data.getDisable() && edm::isDebugEnabled()) {
155  ss << "[PedestalsHistosUsingDb::" << __func__ << "]"
156  << " Disabling strip in Fed9UStripDescription object..." << std::endl
157  << " for FED id/channel and APV/strip : " << fed_key.fedId() << "/" << fed_key.fedChannel() << " "
158  << iapv << "/" << istr << std::endl
159  << " and crate/FEC/ring/CCU/module : " << fec_key.fecCrate() << "/" << fec_key.fecSlot() << "/"
160  << fec_key.fecRing() << "/" << fec_key.ccuAddr() << "/" << fec_key.ccuChan() << std::endl
161  << " from ped/noise/high/low/disable : " << static_cast<uint16_t>(temp.getPedestal()) << "/"
162  << static_cast<uint16_t>(temp.getHighThreshold()) << "/"
163  << static_cast<uint16_t>(temp.getLowThreshold()) << "/" << static_cast<uint16_t>(temp.getNoise())
164  << "/" << static_cast<uint16_t>(temp.getDisable()) << std::endl;
165  }
166  (*ifed)->getFedStrips().setStrip(addr, data);
167  if (data.getDisable() && edm::isDebugEnabled()) {
168  ss << " to ped/noise/high/low/disable : " << static_cast<uint16_t>(data.getPedestal()) << "/"
169  << static_cast<uint16_t>(data.getHighThreshold()) << "/"
170  << static_cast<uint16_t>(data.getLowThreshold()) << "/" << static_cast<uint16_t>(data.getNoise())
171  << "/" << static_cast<uint16_t>(data.getDisable()) << std::endl;
172  LogTrace(mlDqmClient_) << ss.str();
173  }
174 
175  } // end loop on strips
176  } // end loop on apvs
177  updated++;
178 
179  } else {
180  if (deviceIsPresent(fec_key)) {
181  edm::LogWarning(mlDqmClient_) << "[PedestalsHistosUsingDb::" << __func__ << "]"
182  << " Unable to find pedestals/noise for FedKey/Id/Ch: " << hex << setw(8)
183  << setfill('0') << fed_key.key() << dec << "/" << (*ifed)->getFedId() << "/"
184  << ichan << " and device with FEC/slot/ring/CCU/LLD " << fec_key.fecCrate()
185  << "/" << fec_key.fecSlot() << "/" << fec_key.fecRing() << "/"
186  << fec_key.ccuAddr() << "/" << fec_key.ccuChan() << "/" << fec_key.channel();
187  }
188  }
189  }
190  }
191 
192  edm::LogVerbatim(mlDqmClient_) << "[PedestalsHistosUsingDb::" << __func__ << "]"
193  << " Updated FED pedestals/noise for " << updated << " channels";
194 }
195 
196 // -----------------------------------------------------------------------------
199  PedestalsAnalysis* anal = dynamic_cast<PedestalsAnalysis*>(analysis->second);
200  if (!anal) {
201  return;
202  }
203 
204  SiStripFecKey fec_key(anal->fecKey());
205  SiStripFedKey fed_key(anal->fedKey());
206 
207  for (uint16_t iapv = 0; iapv < 2; ++iapv) {
208  // Create description
209  PedestalsAnalysisDescription* tmp;
210  tmp = new PedestalsAnalysisDescription(anal->dead()[iapv],
211  anal->noisy()[iapv],
212  anal->pedsMean()[iapv],
213  anal->pedsSpread()[iapv],
214  anal->noiseMean()[iapv],
215  anal->noiseSpread()[iapv],
216  anal->rawMean()[iapv],
217  anal->rawSpread()[iapv],
218  anal->pedsMax()[iapv],
219  anal->pedsMin()[iapv],
220  anal->noiseMax()[iapv],
221  anal->noiseMin()[iapv],
222  anal->rawMax()[iapv],
223  anal->rawMin()[iapv],
224  fec_key.fecCrate(),
225  fec_key.fecSlot(),
226  fec_key.fecRing(),
227  fec_key.ccuAddr(),
228  fec_key.ccuChan(),
229  SiStripFecKey::i2cAddr(fec_key.lldChan(), !iapv),
230  db()->dbParams().partitions().begin()->second.partitionName(),
231  db()->dbParams().partitions().begin()->second.runNumber(),
232  anal->isValid(),
233  "",
234  fed_key.fedId(),
235  fed_key.feUnit(),
236  fed_key.feChan(),
237  fed_key.fedApv());
238 
239  // Add comments
240  typedef std::vector<std::string> Strings;
241  Strings errors = anal->getErrorCodes();
242  Strings::const_iterator istr = errors.begin();
243  Strings::const_iterator jstr = errors.end();
244  for (; istr != jstr; ++istr) {
245  tmp->addComments(*istr);
246  }
247 
248  // Store description
249  desc.push_back(tmp);
250  }
251 }
PedestalsHistosUsingDb::highThreshold_
float highThreshold_
Definition: PedestalsHistosUsingDb.h:22
l1tstage2emulator_dqm_sourceclient-live_cfg.feds
feds
Definition: l1tstage2emulator_dqm_sourceclient-live_cfg.py:153
MessageLogger.h
PedestalsHistograms
Definition: PedestalsHistograms.h:7
PedestalsHistosUsingDb.h
PedestalsHistosUsingDb::~PedestalsHistosUsingDb
~PedestalsHistosUsingDb() override
Definition: PedestalsHistosUsingDb.cc:39
PedestalsHistosUsingDb::lowThreshold_
float lowThreshold_
Definition: PedestalsHistosUsingDb.h:23
CommissioningHistograms::pset
const edm::ParameterSet & pset() const
Definition: CommissioningHistograms.h:163
SiStripConfigDb::dbParams
const SiStripDbParams & dbParams() const
Definition: SiStripConfigDb.h:421
PedestalsHistosUsingDb::PedestalsHistosUsingDb
PedestalsHistosUsingDb(const edm::ParameterSet &pset, DQMStore *, SiStripConfigDb *const)
Definition: PedestalsHistosUsingDb.cc:14
SiStripKey::key
const uint32_t & key() const
Definition: SiStripKey.h:120
edm
HLT enums.
Definition: AlignableModifier.h:19
SiStripConfigDb::getFedDescriptions
FedDescriptionsRange getFedDescriptions(std::string partition="")
Definition: FedDescriptions.cc:12
SiStripConfigDb::uploadFedDescriptions
void uploadFedDescriptions(std::string partition="")
Definition: FedDescriptions.cc:197
CommissioningHistosUsingDb::cabling
SiStripFedCabling *const cabling() const
Definition: CommissioningHistosUsingDb.h:94
SiStripCommissioningClient_cfg.conn
conn
Definition: SiStripCommissioningClient_cfg.py:5
SiStripFedCabling::fedConnection
FedChannelConnection fedConnection(uint16_t fed_id, uint16_t fed_ch) const
Definition: SiStripFedCabling.cc:171
PedestalsHistosUsingDb::uploadConfigurations
void uploadConfigurations() override
Definition: PedestalsHistosUsingDb.cc:46
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
PedestalsHistosUsingDb::disableBadStrips_
bool disableBadStrips_
Definition: PedestalsHistosUsingDb.h:24
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
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
PedestalsAnalysis
Histogram-based analysis for pedestal run.
Definition: PedestalsAnalysis.h:15
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
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
SiStripConfigDb::FedDescriptionsRange
FedDescriptions::range FedDescriptionsRange
Definition: SiStripConfigDb.h:116
generateTowerEtThresholdLUT.addr
addr
Definition: generateTowerEtThresholdLUT.py:57
dqm::legacy::DQMStore
Definition: DQMStore.h:727
errors
Definition: errors.py:1
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
FedChannelConnection
Class containning control, module, detector and connection information, at the level of a FED channel...
Definition: FedChannelConnection.h:26
SiStripConstants.h
PedestalsHistosUsingDb::create
void create(SiStripConfigDb::AnalysisDescriptionsV &, Analysis) override
Definition: PedestalsHistosUsingDb.cc:198
SiStripFedKey.h
edm::ParameterSet
Definition: ParameterSet.h:47
ParameterSet
Definition: Functions.h:16
sistrip::PEDESTALS
Definition: ConstantsForRunType.h:72
SiStripDbParams::partitions
const_iterator_range partitions() const
Definition: SiStripDbParams.h:178
SiStripFedKey::feUnit
const uint16_t & feUnit() const
Definition: SiStripFedKey.h:189
PedestalsHistosUsingDb::allowSelectiveUpload_
bool allowSelectiveUpload_
Definition: PedestalsHistosUsingDb.h:27
CommissioningHistosUsingDb::doUploadConf
bool doUploadConf() const
Definition: CommissioningHistosUsingDb.h:91
sistrip::invalid_
static const uint16_t invalid_
Definition: Constants.h:16
CommissioningHistograms
Definition: CommissioningHistograms.h:23
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
CommissioningAnalysis::VInt
std::vector< uint16_t > VInt
Definition: CommissioningAnalysis.h:34
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
SiStripFecKey::i2cAddr
const uint16_t & i2cAddr() const
Definition: SiStripFecKey.h:204
SiStripFedKey::fedChannel
uint16_t fedChannel() const
Definition: SiStripFedKey.h:192
sistrip::APVS_PER_FEDCH
static const uint16_t APVS_PER_FEDCH
Definition: ConstantsForHardwareSystems.h:34
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
SiStripConfigDb::AnalysisDescriptionsV
std::vector< AnalysisDescription * > AnalysisDescriptionsV
Definition: SiStripConfigDb.h:135
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
PedestalsAnalysis.h
sistrip::FEDCH_PER_FED
static const uint16_t FEDCH_PER_FED
Definition: ConstantsForHardwareSystems.h:30
CommissioningHistosUsingDb::db
SiStripConfigDb *const db() const
Definition: CommissioningHistosUsingDb.h:93
edm::isDebugEnabled
bool isDebugEnabled()
Definition: MessageLogger.cc:12
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:224
CommissioningHistosUsingDb::deviceIsPresent
bool deviceIsPresent(const SiStripFecKey &)
Definition: CommissioningHistosUsingDb.cc:369
PedestalsHistosUsingDb::update
void update(SiStripConfigDb::FedDescriptionsRange)
Definition: PedestalsHistosUsingDb.cc:73
sistrip
sistrip classes
Definition: SiStripQualityHelpers.h:14
conversion_template_cfg.anal
anal
Definition: conversion_template_cfg.py:16
PedestalsHistosUsingDb::keepStripsDisabled_
bool keepStripsDisabled_
Definition: PedestalsHistosUsingDb.h:25
CommissioningHistograms::Analysis
Analyses::iterator Analysis
Definition: CommissioningHistograms.h:58
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
SiStripFedKey::fedId
const uint16_t & fedId() const
Definition: SiStripFedKey.h:188
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
SiStripFedKey::feChan
const uint16_t & feChan() const
Definition: SiStripFedKey.h:190