CMS 3D CMS Logo

PedsOnlyHistosUsingDb.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>("PedsOnlyParameters"), bei, sistrip::PEDS_ONLY),
17  PedsOnlyHistograms(pset.getParameter<edm::ParameterSet>("PedsOnlyParameters"), bei) {
18  LogTrace(mlDqmClient_) << "[PedsOnlyHistosUsingDb::" << __func__ << "]"
19  << " Constructing object...";
20 }
21 
22 // -----------------------------------------------------------------------------
25  LogTrace(mlDqmClient_) << "[PedsOnlyHistosUsingDb::" << __func__ << "]"
26  << " Destructing object...";
27 }
28 
29 // -----------------------------------------------------------------------------
32  LogTrace(mlDqmClient_) << "[PedsOnlyHistosUsingDb::" << __func__ << "]";
33 
34  if (!db()) {
35  edm::LogError(mlDqmClient_) << "[PedsOnlyHistosUsingDb::" << __func__ << "]"
36  << " NULL pointer to SiStripConfigDb interface!"
37  << " Aborting upload...";
38  return;
39  }
40 
41  // Update FED descriptions with new peds/noise values
43  update(feds);
44  if (doUploadConf()) {
45  edm::LogVerbatim(mlDqmClient_) << "[PedsOnlyHistosUsingDb::" << __func__ << "]"
46  << " Uploading pedestals/noise to DB...";
48  edm::LogVerbatim(mlDqmClient_) << "[PedsOnlyHistosUsingDb::" << __func__ << "]"
49  << " Completed database upload of " << feds.size() << " FED descriptions!";
50  } else {
51  edm::LogWarning(mlDqmClient_) << "[PedsOnlyHistosUsingDb::" << __func__ << "]"
52  << " TEST only! No pedestals/noise values will be uploaded to DB...";
53  }
54 }
55 
56 // -----------------------------------------------------------------------------
59  // Iterate through feds and update fed descriptions
60  uint16_t updated = 0;
61  SiStripConfigDb::FedDescriptionsV::const_iterator ifed;
62  for (ifed = feds.begin(); ifed != feds.end(); ifed++) {
63  for (uint16_t ichan = 0; ichan < sistrip::FEDCH_PER_FED; ichan++) {
64  // Build FED and FEC keys
65  const FedChannelConnection& conn = cabling()->fedConnection((*ifed)->getFedId(), ichan);
66  if (conn.fecCrate() == sistrip::invalid_ || conn.fecSlot() == sistrip::invalid_ ||
67  conn.fecRing() == sistrip::invalid_ || conn.ccuAddr() == sistrip::invalid_ ||
68  conn.ccuChan() == sistrip::invalid_ || conn.lldChannel() == sistrip::invalid_) {
69  continue;
70  }
72  SiStripFecKey fec_key(
73  conn.fecCrate(), conn.fecSlot(), conn.fecRing(), conn.ccuAddr(), conn.ccuChan(), conn.lldChannel());
74 
75  // Locate appropriate analysis object
76  Analyses::const_iterator iter = data().find(fec_key.key());
77  if (iter != data().end()) {
78  // Check if analysis is valid
79  if (!iter->second->isValid()) {
80  continue;
81  }
82 
83  PedsOnlyAnalysis* anal = dynamic_cast<PedsOnlyAnalysis*>(iter->second);
84  if (!anal) {
85  edm::LogError(mlDqmClient_) << "[PedsOnlyHistosUsingDb::" << __func__ << "]"
86  << " NULL pointer to analysis object!";
87  continue;
88  }
89 
90  // Determine the pedestal shift to apply
91  uint32_t pedshift = 127;
92  for (uint16_t iapv = 0; iapv < sistrip::APVS_PER_FEDCH; iapv++) {
93  uint32_t pedmin = (uint32_t)anal->pedsMin()[iapv];
94  pedshift = pedmin < pedshift ? pedmin : pedshift;
95  }
96 
97  // Iterate through APVs and strips
98  for (uint16_t iapv = 0; iapv < sistrip::APVS_PER_FEDCH; iapv++) {
99  for (uint16_t istr = 0; istr < anal->peds()[iapv].size(); istr++) {
100  constexpr float high_threshold = 5.;
101  constexpr float low_threshold = 2.;
102  constexpr bool disable_strip = false;
103  Fed9U::Fed9UStripDescription data(static_cast<uint32_t>(anal->peds()[iapv][istr] - pedshift),
104  high_threshold,
105  low_threshold,
106  anal->raw()[iapv][istr], //@@ raw noise!
107  disable_strip);
108  Fed9U::Fed9UAddress addr(ichan, iapv, istr);
109  (*ifed)->getFedStrips().setStrip(addr, data);
110  }
111  }
112  updated++;
113 
114  } else {
115  edm::LogWarning(mlDqmClient_) << "[PedsOnlyHistosUsingDb::" << __func__ << "]"
116  << " Unable to find pedestals/noise for FedKey/Id/Ch: " << hex << setw(8)
117  << setfill('0') << fed_key.key() << dec << "/" << (*ifed)->getFedId() << "/"
118  << ichan << " and device with FEC/slot/ring/CCU/LLD " << fec_key.fecCrate() << "/"
119  << fec_key.fecSlot() << "/" << fec_key.fecRing() << "/" << fec_key.ccuAddr()
120  << "/" << fec_key.ccuChan() << "/" << fec_key.channel();
121  }
122  }
123  }
124 
125  edm::LogVerbatim(mlDqmClient_) << "[PedsOnlyHistosUsingDb::" << __func__ << "]"
126  << " Updated FED pedestals/noise for " << updated << " channels";
127 }
128 
129 // -----------------------------------------------------------------------------
132  PedsOnlyAnalysis* anal = dynamic_cast<PedsOnlyAnalysis*>(analysis->second);
133  if (!anal) {
134  return;
135  }
136 
137  SiStripFecKey fec_key(anal->fecKey());
138  SiStripFedKey fed_key(anal->fedKey());
139 
140  for (uint16_t iapv = 0; iapv < 2; ++iapv) {
141  // Create description
142  PedestalsAnalysisDescription* tmp;
143  tmp = new PedestalsAnalysisDescription(std::vector<uint16_t>(0, 0), //@@
144  std::vector<uint16_t>(0, 0), //@@
145  anal->pedsMean()[iapv],
146  anal->pedsSpread()[iapv],
147  1. * sistrip::invalid_, //@@
148  1. * sistrip::invalid_, //@@
149  anal->rawMean()[iapv],
150  anal->rawSpread()[iapv],
151  anal->pedsMax()[iapv],
152  anal->pedsMin()[iapv],
153  1. * sistrip::invalid_, //@@
154  1. * sistrip::invalid_, //@@
155  anal->rawMax()[iapv],
156  anal->rawMin()[iapv],
157  fec_key.fecCrate(),
158  fec_key.fecSlot(),
159  fec_key.fecRing(),
160  fec_key.ccuAddr(),
161  fec_key.ccuChan(),
162  SiStripFecKey::i2cAddr(fec_key.lldChan(), !iapv),
163  db()->dbParams().partitions().begin()->second.partitionName(),
164  db()->dbParams().partitions().begin()->second.runNumber(),
165  anal->isValid(),
166  "",
167  fed_key.fedId(),
168  fed_key.feUnit(),
169  fed_key.feChan(),
170  fed_key.fedApv());
171 
172  // Add comments
173  typedef std::vector<std::string> Strings;
174  Strings errors = anal->getErrorCodes();
175  Strings::const_iterator istr = errors.begin();
176  Strings::const_iterator jstr = errors.end();
177  for (; istr != jstr; ++istr) {
178  tmp->addComments(*istr);
179  }
180 
181  // Store description
182  desc.push_back(tmp);
183  }
184 }
const uint16_t & fecSlot() const
const uint16_t & fecCrate() const
Histogram-based analysis for pedestal run.
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
FedDescriptionsRange getFedDescriptions(std::string partition="")
std::vector< std::string > Strings
Definition: MsgTools.h:18
bool isValid() const override
FedDescriptions::range FedDescriptionsRange
static const char mlDqmClient_[]
uint16_t lldChannel() const
void uploadConfigurations() override
const uint16_t & i2cAddr() const
const uint16_t & fedId() const
sistrip classes
const uint32_t & key() const
Definition: SiStripKey.h:120
const VFloat & rawSpread() const
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 VVFloat & raw() const
const uint16_t & fecRing() const
void update(SiStripConfigDb::FedDescriptionsRange)
Class containning control, module, detector and connection information, at the level of a FED channel...
const VFloat & rawMin() const
const VFloat & pedsMin() const
An interface class to the DeviceFactory.
const uint16_t & ccuChan() const
const VFloat & pedsMax() const
const uint32_t & fecKey() const
const uint16_t & ccuAddr() const
#define LogTrace(id)
const VFloat & rawMax() const
const uint16_t & feUnit() const
const SiStripDbParams & dbParams() const
void uploadFedDescriptions(std::string partition="")
static const uint16_t invalid_
Definition: Constants.h:16
PedsOnlyHistosUsingDb(const edm::ParameterSet &pset, DQMStore *, SiStripConfigDb *const)
const VVFloat & peds() const
HLT enums.
static const uint16_t FEDCH_PER_FED
std::vector< AnalysisDescription * > AnalysisDescriptionsV
const uint16_t & feChan() const
const VFloat & pedsSpread() const
const VFloat & pedsMean() const
Definition: errors.py:1
SiStripConfigDb *const db() const
void create(SiStripConfigDb::AnalysisDescriptionsV &, Analysis) override
tmp
align.sh
Definition: createJobs.py:716
SiStripFedCabling *const cabling() const
const VString & getErrorCodes() const
static const uint16_t APVS_PER_FEDCH
const VFloat & rawMean() const
#define constexpr