CMS 3D CMS Logo

PedestalsTask.cc
Go to the documentation of this file.
8 #include <algorithm>
9 #include <cmath>
10 
11 using namespace sistrip;
12 
13 // -----------------------------------------------------------------------------
14 //
16  : CommissioningTask(dqm, conn, "PedestalsTask"), peds_(), cm_() {
17  LogTrace(mlDqmSource_) << "[PedestalsTask::" << __func__ << "]"
18  << " Constructing object...";
19 }
20 
21 // -----------------------------------------------------------------------------
22 //
24  LogTrace(mlDqmSource_) << "[PedestalsTask::" << __func__ << "]"
25  << " Destructing object...";
26 }
27 
28 // -----------------------------------------------------------------------------
29 //
31  LogTrace(mlDqmSource_) << "[PedestalsTask::" << __func__ << "]";
32 
33  uint16_t nbins;
35  std::string extra_info;
36  peds_.resize(2);
37  nbins = 256;
38 
39  // Pedestals histogram
40  extra_info = sistrip::extrainfo::pedestals_;
41  peds_[0].isProfile_ = true;
42 
46  fedKey(),
48  connection().lldChannel(),
49  extra_info)
50  .title();
51 
52  peds_[0].histo(dqm()->bookProfile(title, title, nbins, -0.5, nbins * 1. - 0.5, 1025, 0., 1025.));
53 
54  peds_[0].vNumOfEntries_.resize(nbins, 0);
55  peds_[0].vSumOfContents_.resize(nbins, 0);
56  peds_[0].vSumOfSquares_.resize(nbins, 0);
57 
58  // Noise histogram
59  extra_info = sistrip::extrainfo::noise_;
60  peds_[1].isProfile_ = true;
61 
65  fedKey(),
67  connection().lldChannel(),
68  extra_info)
69  .title();
70 
71  peds_[1].histo(dqm()->bookProfile(title, title, nbins, -0.5, nbins * 1. - 0.5, 1025, 0., 1025.));
72 
73  peds_[1].vNumOfEntries_.resize(nbins, 0);
74  peds_[1].vSumOfContents_.resize(nbins, 0);
75  peds_[1].vSumOfSquares_.resize(nbins, 0);
76 
77  // Common mode histograms
78  cm_.resize(2);
79  nbins = 1024;
80  for (uint16_t iapv = 0; iapv < 2; iapv++) {
84  fedKey(),
86  connection().i2cAddr(iapv),
88  .title();
89 
90  cm_[iapv].histo(dqm()->book1D(title, title, nbins, -0.5, nbins * 1. - 0.5));
91  cm_[iapv].isProfile_ = false;
92 
93  cm_[iapv].vNumOfEntries_.resize(nbins, 0);
94  cm_[iapv].vNumOfEntries_.resize(nbins, 0);
95  }
96 }
97 
98 // -----------------------------------------------------------------------------
99 //
101  if (digis.data.size() != peds_[0].vNumOfEntries_.size()) {
102  edm::LogWarning(mlDqmSource_) << "[PedestalsTask::" << __func__ << "]"
103  << " Unexpected number of digis: " << digis.data.size();
104  return;
105  }
106 
107  // Check number of digis
108  uint16_t nbins = peds_[0].vNumOfEntries_.size();
109  if (digis.data.size() < nbins) {
110  nbins = digis.data.size();
111  }
112 
113  //@@ Inefficient!!!
114  uint16_t napvs = nbins / 128;
115  std::vector<uint32_t> cm;
116  cm.resize(napvs, 0);
117 
118  // Calc common mode for both APVs
119  std::vector<uint16_t> adc;
120  for (uint16_t iapv = 0; iapv < napvs; iapv++) {
121  adc.clear();
122  adc.reserve(128);
123  for (uint16_t ibin = 0; ibin < 128; ibin++) {
124  if ((iapv * 128) + ibin < nbins) {
125  adc.push_back(digis.data[(iapv * 128) + ibin].adc()); //@@ VIRGIN RAW DATA (MUX, APV READOUT)
126  }
127  }
128  sort(adc.begin(), adc.end());
129  uint16_t index = adc.size() % 2 ? adc.size() / 2 : adc.size() / 2 - 1;
130  if (!adc.empty()) {
131  cm[iapv] = static_cast<uint32_t>(adc[index]);
132  }
133  }
134 
135  for (uint16_t ibin = 0; ibin < nbins; ibin++) {
136  updateHistoSet(peds_[0], ibin, digis.data[ibin].adc()); // peds and raw noise
137  float diff = static_cast<float>(digis.data[ibin].adc()) - static_cast<float>(cm[ibin / 128]);
138  updateHistoSet(peds_[1], ibin, diff); // residuals and real noise
139  }
140 
141  if (cm.size() < cm_.size()) {
142  edm::LogWarning(mlDqmSource_) << "[PedestalsTask::" << __func__ << "]"
143  << " Fewer CM values than expected: " << cm.size();
144  }
145 
146  updateHistoSet(cm_[0], cm[0]);
147  updateHistoSet(cm_[1], cm[1]);
148 }
149 
150 // -----------------------------------------------------------------------------
151 //
153  // Pedestals
154  updateHistoSet(peds_[0]);
155 
156  // Noise (cannot use HistoSet directly, as want to plot noise as "contents", not "error")
157  TProfile* histo = ExtractTObject<TProfile>().extract(peds_[1].histo());
158  for (uint16_t ii = 0; ii < peds_[1].vNumOfEntries_.size(); ++ii) {
159  float mean = 0.;
160  float spread = 0.;
161  float entries = peds_[1].vNumOfEntries_[ii];
162  if (entries > 0.) {
163  mean = peds_[1].vSumOfContents_[ii] / entries;
164  spread = sqrt(peds_[1].vSumOfSquares_[ii] / entries - mean * mean);
165  }
166 
167  float noise = spread;
168  float error = 0; // sqrt(entries) / entries;
169 
171  }
172 
173  // Common mode
174  updateHistoSet(cm_[0]);
175  updateHistoSet(cm_[1]);
176 }
change_name.diff
diff
Definition: change_name.py:13
ecalMGPA::adc
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
Definition: EcalMGPASample.h:11
sistrip::mlDqmSource_
static const char mlDqmSource_[]
Definition: ConstantsForLogger.h:20
sistrip::extrainfo::commonMode_
static const char commonMode_[]
Definition: ConstantsForDqm.h:48
sistrip::extrainfo::noise_
static const char noise_[]
Definition: ConstantsForDqm.h:47
MessageLogger.h
SiStripPI::mean
Definition: SiStripPayloadInspectorHelper.h:169
PedestalsTask::PedestalsTask
PedestalsTask(DQMStore *, const FedChannelConnection &)
Definition: PedestalsTask.cc:15
edm::DetSet
Definition: DetSet.h:23
CommissioningTask::connection
const FedChannelConnection & connection() const
Definition: CommissioningTask.h:189
SiStripCommissioningClient_cfg.conn
conn
Definition: SiStripCommissioningClient_cfg.py:5
timingPdfMaker.histo
histo
Definition: timingPdfMaker.py:279
DQMStore.h
ExtractTObject.h
CommissioningTask
Definition: CommissioningTask.h:24
ExtractTObject
Definition: ExtractTObject.h:9
relativeConstraints.error
error
Definition: relativeConstraints.py:53
CommissioningTask::fedKey
const uint32_t & fedKey() const
Definition: CommissioningTask.h:192
PedestalsTask::fill
void fill(const SiStripEventSummary &, const edm::DetSet< SiStripRawDigi > &) override
Definition: PedestalsTask.cc:100
dqm::legacy::DQMStore
Definition: DQMStore.h:727
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
sistrip::EXPERT_HISTO
Definition: ConstantsForHistoType.h:29
LaserClient_cfi.nbins
nbins
Definition: LaserClient_cfi.py:51
sistrip::extrainfo::pedestals_
static const char pedestals_[]
Definition: ConstantsForDqm.h:45
PedestalsTask::update
void update() override
Definition: PedestalsTask.cc:152
PedestalsTask::cm_
std::vector< HistoSet > cm_
Definition: PedestalsTask.h:21
PedestalsTask.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::LogWarning
Definition: MessageLogger.h:141
FedChannelConnection
Class containning control, module, detector and connection information, at the level of a FED channel...
Definition: FedChannelConnection.h:26
SiStripConstants.h
PedestalsTask::peds_
std::vector< HistoSet > peds_
Definition: PedestalsTask.h:20
sistrip::PEDESTALS
Definition: ConstantsForRunType.h:72
sistrip::APV
Definition: ConstantsForGranularity.h:79
PedestalsTask::~PedestalsTask
~PedestalsTask() override
Definition: PedestalsTask.cc:23
edmLumisInFiles.summary
summary
Definition: edmLumisInFiles.py:39
CommissioningTask::updateHistoSet
void updateHistoSet(HistoSet &, const uint32_t &bin, const float &value)
Definition: CommissioningTask.cc:274
UpdateTProfile.h
ExtractTObject::extract
static T * extract(MonitorElement *me)
Definition: ExtractTObject.cc:21
overlapproblemtsosanalyzer_cfi.title
title
Definition: overlapproblemtsosanalyzer_cfi.py:7
CommissioningTask::dqm
DQMStore *const dqm() const
Definition: CommissioningTask.h:188
SiStripHistoTitle.h
SiStripHistoTitle::title
const std::string & title() const
Definition: SiStripHistoTitle.h:109
edm::DetSet::data
collection_type data
Definition: DetSet.h:80
PedestalsTask::book
void book() override
Definition: PedestalsTask.cc:30
SiStripHistoTitle
Utility class that holds histogram title.
Definition: SiStripHistoTitle.h:20
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
dqm
Definition: DQMStore.h:18
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
hgchebackDigitizer_cfi.noise
noise
Definition: hgchebackDigitizer_cfi.py:42
sistrip::FED_KEY
Definition: ConstantsForKeyType.h:30
sistrip
sistrip classes
Definition: SiStripQualityHelpers.h:14
SiStripEventSummary
Definition: SiStripEventSummary.h:22
UpdateTProfile::setBinContent
static void setBinContent(TProfile *const profile, const uint32_t &bin, const double &entries, const double &mean, const double &spread)
Definition: UpdateTProfile.cc:80
cuy.ii
ii
Definition: cuy.py:590
sistrip::LLD_CHAN
Definition: ConstantsForGranularity.h:78