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