CMS 3D CMS Logo

DaqScopeModeHistosUsingDb.cc
Go to the documentation of this file.
7 #include <iostream>
8 
9 using namespace sistrip;
10 
11 // -----------------------------------------------------------------------------
13  DQMStore* bei,
14  SiStripConfigDb* const db)
16  pset.getParameter<edm::ParameterSet>("DaqScopeModeParameters"), bei, sistrip::DAQ_SCOPE_MODE),
18  DaqScopeModeHistograms(pset.getParameter<edm::ParameterSet>("DaqScopeModeParameters"), bei) {
19  LogTrace(mlDqmClient_) << "[DaqScopeModeHistosUsingDb::" << __func__ << "]"
20  << " Constructing object...";
21  highThreshold_ = this->pset().getParameter<double>("HighThreshold");
22  lowThreshold_ = this->pset().getParameter<double>("LowThreshold");
23  LogTrace(mlDqmClient_) << "[DaqScopeModeHistosUsingDb::" << __func__ << "]"
24  << " Set FED zero suppression high/low threshold to " << highThreshold_ << "/"
25  << lowThreshold_;
26  disableBadStrips_ = this->pset().getParameter<bool>("DisableBadStrips");
27  keepStripsDisabled_ = this->pset().getParameter<bool>("KeepStripsDisabled");
28  LogTrace(mlDqmClient_) << "[DaqScopeModeHistosUsingDb::" << __func__ << "]"
29  << " Disabling strips: " << disableBadStrips_
30  << " ; keeping previously disabled strips: " << keepStripsDisabled_;
32  this->pset().existsAs<bool>("doSelectiveUpload") ? this->pset().getParameter<bool>("doSelectiveUpload") : false;
33  LogTrace(mlDqmClient_) << "[DaqScopeModeHistosUsingDb::" << __func__ << "]"
34  << " Selective upload of modules set to : " << allowSelectiveUpload_;
35 
37  this->pset().existsAs<bool>("SkipPedestalUpdate") ? this->pset().getParameter<bool>("SkipPedestalUpdate") : false;
39  this->pset().existsAs<bool>("SkipTickUpdate") ? this->pset().getParameter<bool>("SkipTickUpdate") : false;
40  LogTrace(mlDqmClient_) << "[DaqScopeModeHistosUsingDb::" << __func__ << "]"
41  << " Perform pedestal upload set to : " << skipPedestalUpdate_;
42  LogTrace(mlDqmClient_) << "[DaqScopeModeHistosUsingDb::" << __func__ << "]"
43  << " Perform tick-mark upload set to : " << skipTickUpdate_;
44 }
45 
46 // -----------------------------------------------------------------------------
48  LogTrace(mlDqmClient_) << "[DaqScopeModeHistosUsingDb::" << __func__ << "]"
49  << " Destructing object...";
50 }
51 
52 // -----------------------------------------------------------------------------
54  LogTrace(mlDqmClient_) << "[DaqScopeModeHistosUsingDb::" << __func__ << "]";
55 
56  if (!db()) {
57  edm::LogError(mlDqmClient_) << "[DaqScopeModeHistosUsingDb::" << __func__ << "]"
58  << " NULL pointer to SiStripConfigDb interface!"
59  << " Aborting upload...";
60  return;
61  }
62 
63  // Update FED descriptions with new peds/noise values as well as tick-marks (no PLL delays, for these ones please use the Timing run
65  update(feds);
66 
67  if (doUploadConf()) {
68  edm::LogVerbatim(mlDqmClient_) << "[DaqScopeModeHistosUsingDb::" << __func__ << "]"
69  << " Uploading FED information to DB...";
71  edm::LogVerbatim(mlDqmClient_) << "[DaqScopeModeHistosUsingDb::" << __func__ << "]"
72  << " Completed database upload of " << feds.size() << " FED descriptions!";
73  } else {
74  edm::LogWarning(mlDqmClient_) << "[DaqScopeModeHistosUsingDb::" << __func__ << "]"
75  << " No FED values will be uploaded to DB...";
76  }
77 }
78 
79 // -----------------------------------------------------------------------------
81  // Retrieve FED ids from cabling
82  auto ids = cabling()->fedIds();
83 
84  // Iterate through feds and update fed descriptions
85  uint16_t updated_peds = 0;
86  uint16_t updated_ticks = 0;
87  SiStripConfigDb::FedDescriptionsV::const_iterator ifed;
88  for (ifed = feds.begin(); ifed != feds.end(); ifed++) {
89  // If FED id not found in list (from cabling), then continue
90  if (find(ids.begin(), ids.end(), (*ifed)->getFedId()) == ids.end()) {
91  continue;
92  }
93 
94  for (uint16_t ichan = 0; ichan < sistrip::FEDCH_PER_FED; ichan++) {
95  // Build FED and FEC keys
96  const FedChannelConnection& conn = cabling()->fedConnection((*ifed)->getFedId(), ichan);
97 
98  if (conn.fecCrate() == sistrip::invalid_ || conn.fecSlot() == sistrip::invalid_ ||
99  conn.fecRing() == sistrip::invalid_ || conn.ccuAddr() == sistrip::invalid_ ||
100  conn.ccuChan() == sistrip::invalid_ || conn.lldChannel() == sistrip::invalid_) {
101  continue;
102  }
103 
104  SiStripFedKey fed_key(conn.fedId(), SiStripFedKey::feUnit(conn.fedCh()), SiStripFedKey::feChan(conn.fedCh()));
105 
106  SiStripFecKey fec_key(
107  conn.fecCrate(), conn.fecSlot(), conn.fecRing(), conn.ccuAddr(), conn.ccuChan(), conn.lldChannel());
108 
109  // Locate appropriate analysis object
110  Analyses::const_iterator iter = data(allowSelectiveUpload_).find(fec_key.key());
111 
112  if (iter != data(allowSelectiveUpload_).end()) {
113  // Check if analysis is valid
114  if (!iter->second->isValid()) {
115  edm::LogWarning(mlDqmClient_) << "[DaqScopeModeHistosUsingDb::" << __func__ << "]"
116  << " Skipping invalid channel with coordinates: FedKey/Id/Ch: " << hex
117  << setw(8) << setfill('0') << fed_key.key() << dec << "/" << (*ifed)->getFedId()
118  << "/" << ichan << " and device with FEC/slot/ring/CCU/LLD "
119  << fec_key.fecCrate() << "/" << fec_key.fecSlot() << "/" << fec_key.fecRing()
120  << "/" << fec_key.ccuAddr() << "/" << fec_key.ccuChan() << "/"
121  << fec_key.channel();
122  continue;
123  }
124 
125  DaqScopeModeAnalysis* anal = dynamic_cast<DaqScopeModeAnalysis*>(iter->second);
126  if (!anal) {
127  edm::LogError(mlDqmClient_) << "[DaqScopeModeHistosUsingDb::" << __func__ << "]"
128  << " NULL pointer to analysis object!";
129  continue;
130  }
131 
133  if (not skipPedestalUpdate_) {
134  // Determine the pedestal shift to apply
135  uint32_t pedshift = 127;
136  for (uint16_t iapv = 0; iapv < sistrip::APVS_PER_FEDCH; iapv++) {
137  uint32_t pedmin = (uint32_t)anal->pedsMin()[iapv];
138  pedshift = pedmin < pedshift ? pedmin : pedshift;
139  std::stringstream ss;
140  ss << "iapv: " << iapv << " pedsMin()[iapv]: " << anal->pedsMin()[iapv] << " pedmin: " << pedmin
141  << " pedshift: " << pedshift;
142  edm::LogWarning(mlDqmClient_) << ss.str();
143  }
144 
145  // Iterate through APVs and strips
146  for (uint16_t iapv = 0; iapv < sistrip::APVS_PER_FEDCH; iapv++) {
147  for (uint16_t istr = 0; istr < anal->peds()[iapv].size(); istr++) {
148  // Patch added by R.B. (I'm back! ;-), requested by J.F. and S.L. (04/11/2010)
149  if (anal->peds()[iapv][istr] < 1.) { //@@ ie, zero
151  << "[DaqScopeModeHistosUsingDb::" << __func__ << "]"
152  << " Skipping ZERO pedestal value (ie, NO UPLOAD TO DB!) for FedKey/Id/Ch: " << hex << setw(8)
153  << setfill('0') << fed_key.key() << dec << "/" << (*ifed)->getFedId() << "/" << ichan
154  << " and device with FEC/slot/ring/CCU/LLD " << fec_key.fecCrate() << "/" << fec_key.fecSlot()
155  << "/" << fec_key.fecRing() << "/" << fec_key.ccuAddr() << "/" << fec_key.ccuChan() << "/"
156  << fec_key.channel();
157  continue; //@@ do not upload
158  }
159 
160  // get the information on the strip as it was on the db
161  Fed9U::Fed9UAddress addr(ichan, iapv, istr);
162  Fed9U::Fed9UStripDescription temp = (*ifed)->getFedStrips().getStrip(addr);
163 
164  // determine whether we need to disable the strip
165  bool disableStrip = false;
166  if (keepStripsDisabled_) {
167  disableStrip = temp.getDisable();
168  } else if (disableBadStrips_) {
169  DaqScopeModeAnalysis::VInt dead = anal->dead()[iapv];
170  if (find(dead.begin(), dead.end(), istr) != dead.end())
171  disableStrip = true;
172  DaqScopeModeAnalysis::VInt noisy = anal->noisy()[iapv];
173  if (find(noisy.begin(), noisy.end(), istr) != noisy.end())
174  disableStrip = true;
175  }
176 
177  Fed9U::Fed9UStripDescription data(static_cast<uint32_t>(anal->peds()[iapv][istr] - pedshift),
180  anal->noise()[iapv][istr],
181  disableStrip);
182 
183  std::stringstream ss;
184  if (data.getDisable() && edm::isDebugEnabled()) {
185  ss << "[DaqScopeModeHistosUsingDb::" << __func__ << "]"
186  << " Disabling strip in Fed9UStripDescription object..." << std::endl
187  << " for FED id/channel and APV/strip : " << fed_key.fedId() << "/" << fed_key.fedChannel() << " "
188  << iapv << "/" << istr << std::endl
189  << " and crate/FEC/ring/CCU/module : " << fec_key.fecCrate() << "/" << fec_key.fecSlot() << "/"
190  << fec_key.fecRing() << "/" << fec_key.ccuAddr() << "/" << fec_key.ccuChan() << std::endl
191  << " from ped/noise/high/low/disable : " << static_cast<uint16_t>(temp.getPedestal()) << "/"
192  << static_cast<uint16_t>(temp.getHighThreshold()) << "/"
193  << static_cast<uint16_t>(temp.getLowThreshold()) << "/" << static_cast<uint16_t>(temp.getNoise())
194  << "/" << static_cast<uint16_t>(temp.getDisable()) << std::endl;
195  }
196 
197  // update strip inf
198  (*ifed)->getFedStrips().setStrip(addr, data);
199 
200  if (data.getDisable() && edm::isDebugEnabled()) {
201  ss << " to ped/noise/high/low/disable : " << static_cast<uint16_t>(data.getPedestal()) << "/"
202  << static_cast<uint16_t>(data.getHighThreshold()) << "/"
203  << static_cast<uint16_t>(data.getLowThreshold()) << "/" << static_cast<uint16_t>(data.getNoise())
204  << "/" << static_cast<uint16_t>(data.getDisable()) << std::endl;
205  LogTrace(mlDqmClient_) << ss.str();
206  }
207  } // end loop on strips
208  } // end loop on apvs
209  updated_peds++;
210  }
211 
212  // if one wants to update the frame finding threhsolds
213  if (not skipTickUpdate_) {
214  // Update frame finding threshold
215  Fed9U::Fed9UAddress addr(ichan);
216  uint16_t old_threshold = static_cast<uint16_t>((*ifed)->getFrameThreshold(addr));
217  if (anal->isValid()) {
218  (*ifed)->setFrameThreshold(addr, anal->frameFindingThreshold());
219  updated_ticks++;
220  }
221  uint16_t new_threshold = static_cast<uint16_t>((*ifed)->getFrameThreshold(addr));
222 
223  std::stringstream ss;
224  ss << "LLD channel : old frame threshold " << old_threshold << " new frame threshold " << new_threshold
225  << std::endl;
226  edm::LogWarning(mlDqmClient_) << ss.str();
227 
228  // Debug
229  ss.clear();
230  ss << "[DaqScopeModeHistosUsingDb::" << __func__ << "]";
231  if (anal->isValid()) {
232  ss << " Updating the frame-finding threshold"
233  << " from " << old_threshold << " to " << new_threshold << " using tick mark base/peak/height "
234  << anal->base() << "/" << anal->peak() << "/" << anal->height();
235  } else {
236  ss << " Cannot update the frame-finding threshold"
237  << " from " << old_threshold << " to a new value using invalid analysis ";
238  }
239  ss << " for crate/FEC/ring/CCU/module/LLD " << fec_key.fecCrate() << "/" << fec_key.fecSlot() << "/"
240  << fec_key.fecRing() << "/" << fec_key.ccuAddr() << "/" << fec_key.ccuChan() << fec_key.channel()
241  << " and FED id/ch " << fed_key.fedId() << "/" << fed_key.fedChannel();
242  anal->print(ss);
243  LogTrace(mlDqmClient_) << ss.str();
244  }
245  } else {
246  if (deviceIsPresent(fec_key)) {
247  edm::LogWarning(mlDqmClient_) << "[DaqScopeModeHistosUsingDb::" << __func__ << "]"
248  << " Unable to find pedestals/noise for FedKey/Id/Ch: " << hex << setw(8)
249  << setfill('0') << fed_key.key() << dec << "/" << (*ifed)->getFedId() << "/"
250  << ichan << " and device with FEC/slot/ring/CCU/LLD " << fec_key.fecCrate()
251  << "/" << fec_key.fecSlot() << "/" << fec_key.fecRing() << "/"
252  << fec_key.ccuAddr() << "/" << fec_key.ccuChan() << "/" << fec_key.channel();
253  }
254  }
255  }
256  }
257 
258  edm::LogVerbatim(mlDqmClient_) << "[DaqScopeModeHistosUsingDb::" << __func__ << "]"
259  << " Updated FED parameters for pedestal/noise " << updated_peds << " channels"
260  << " Updated FED parameters for frame finding thresholds " << updated_ticks
261  << " channels";
262 }
263 
264 // -----------------------------------------------------------------------------
266  DaqScopeModeAnalysis* anal = dynamic_cast<DaqScopeModeAnalysis*>(analysis->second);
267  if (!anal) {
268  return;
269  }
270 
271  SiStripFecKey fec_key(anal->fecKey());
272  SiStripFedKey fed_key(anal->fedKey());
273 
274  for (uint16_t iapv = 0; iapv < 2; ++iapv) {
275  // Create description for the pedestal table
276  PedestalsAnalysisDescription* peds_tmp;
277  peds_tmp = new PedestalsAnalysisDescription(anal->dead()[iapv],
278  anal->noisy()[iapv],
279  anal->pedsMean()[iapv],
280  anal->pedsSpread()[iapv],
281  anal->noiseMean()[iapv],
282  anal->noiseSpread()[iapv],
283  anal->rawMean()[iapv],
284  anal->rawSpread()[iapv],
285  anal->pedsMax()[iapv],
286  anal->pedsMin()[iapv],
287  anal->noiseMax()[iapv],
288  anal->noiseMin()[iapv],
289  anal->rawMax()[iapv],
290  anal->rawMin()[iapv],
291  fec_key.fecCrate(),
292  fec_key.fecSlot(),
293  fec_key.fecRing(),
294  fec_key.ccuAddr(),
295  fec_key.ccuChan(),
296  SiStripFecKey::i2cAddr(fec_key.lldChan(), !iapv),
297  db()->dbParams().partitions().begin()->second.partitionName(),
298  db()->dbParams().partitions().begin()->second.runNumber(),
299  anal->isValid(),
300  "",
301  fed_key.fedId(),
302  fed_key.feUnit(),
303  fed_key.feChan(),
304  fed_key.fedApv());
305 
306  // Add comments
307  typedef std::vector<std::string> Strings;
308  Strings errors = anal->getErrorCodes();
309  Strings::const_iterator istr = errors.begin();
310  Strings::const_iterator jstr = errors.end();
311  for (; istr != jstr; ++istr) {
312  peds_tmp->addComments(*istr);
313  }
314 
315  // Store description
316  desc.push_back(peds_tmp);
317 
318  // Create description
319  TimingAnalysisDescription* timing_tmp;
320  timing_tmp = new TimingAnalysisDescription(-1.,
321  -1.,
322  -1.,
323  anal->height(),
324  anal->base(),
325  anal->peak(),
326  anal->frameFindingThreshold(),
327  -1.,
329  true, //@@ APV timing analysis (not FED timing)
330  fec_key.fecCrate(),
331  fec_key.fecSlot(),
332  fec_key.fecRing(),
333  fec_key.ccuAddr(),
334  fec_key.ccuChan(),
335  SiStripFecKey::i2cAddr(fec_key.lldChan(), !iapv),
336  db()->dbParams().partitions().begin()->second.partitionName(),
337  db()->dbParams().partitions().begin()->second.runNumber(),
338  anal->isValid(),
339  "",
340  fed_key.fedId(),
341  fed_key.feUnit(),
342  fed_key.feChan(),
343  fed_key.fedApv());
344 
345  istr = errors.begin();
346  jstr = errors.end();
347  for (; istr != jstr; ++istr) {
348  timing_tmp->addComments(*istr);
349  }
350  desc.push_back(timing_tmp);
351  }
352 }
const uint16_t & fecSlot() const
T getParameter(std::string const &) const
bool isDebugEnabled()
const VFloat & noiseMean() const
const uint16_t & fecCrate() const
const VVInt & dead() const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:160
const uint32_t & fedKey() const
Analyses & data(bool getMaskedData=false)
FedChannelConnection fedConnection(uint16_t fed_id, uint16_t fed_ch) const
A container class for generic run and event-related info, information required by the commissioning a...
Definition: SiStripFedKey.h:56
const uint16_t & fedCh() const
const edm::ParameterSet & pset() const
bool deviceIsPresent(const SiStripFecKey &)
bool isValid() const override
const VFloat & noiseSpread() const
FedDescriptionsRange getFedDescriptions(std::string partition="")
std::vector< std::string > Strings
Definition: MsgTools.h:18
DaqScopeModeHistosUsingDb(const edm::ParameterSet &pset, DQMStore *, SiStripConfigDb *const)
FedDescriptions::range FedDescriptionsRange
uint16_t frameFindingThreshold() const
static const char mlDqmClient_[]
uint16_t lldChannel() const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
const VFloat & noiseMax() const
const uint16_t & i2cAddr() const
const uint16_t & fedId() const
sistrip classes
const uint32_t & key() const
Definition: SiStripKey.h:120
static const float tickMarkHeightThreshold_
Utility class that identifies a position within the strip tracker control structure, down to the level of an APV25.
Definition: SiStripFecKey.h:45
const_iterator_range partitions() const
const uint16_t & fecRing() const
const VFloat & pedsSpread() const
Class containning control, module, detector and connection information, at the level of a FED channel...
FedsConstIterRange fedIds() const
const VVFloat & noise() const
const VFloat & rawMean() const
An interface class to the DeviceFactory.
const uint16_t & ccuChan() const
const float & base() const
const uint32_t & fecKey() const
const VVFloat & peds() const
void create(SiStripConfigDb::AnalysisDescriptionsV &, Analysis) override
const float & height() const
void print(std::stringstream &, uint32_t apv_number=0) override
uint16_t fedChannel() const
const uint16_t & ccuAddr() const
#define LogTrace(id)
const VFloat & rawSpread() const
std::vector< uint16_t > VInt
const VFloat & noiseMin() const
const float & peak() const
const VFloat & pedsMean() const
const uint16_t & feUnit() const
const SiStripDbParams & dbParams() const
const VVInt & noisy() const
void uploadFedDescriptions(std::string partition="")
static const uint16_t invalid_
Definition: Constants.h:16
void update(SiStripConfigDb::FedDescriptionsRange)
HLT enums.
static const uint16_t FEDCH_PER_FED
std::vector< AnalysisDescription * > AnalysisDescriptionsV
const uint16_t & feChan() const
const VFloat & pedsMax() const
const uint16_t & fedId() const
Definition: errors.py:1
SiStripConfigDb *const db() const
const VFloat & pedsMin() const
const VFloat & rawMax() const
const VFloat & rawMin() const
SiStripFedCabling *const cabling() const
const VString & getErrorCodes() const
static const uint16_t APVS_PER_FEDCH
Analysis for scope mode data.