CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
PedsFullNoiseTask Class Reference

#include <PedsFullNoiseTask.h>

Inheritance diagram for PedsFullNoiseTask:
CommissioningTask

Public Member Functions

 PedsFullNoiseTask (DQMStore *dqm, const FedChannelConnection &conn, const edm::ParameterSet &pset)
 
 ~PedsFullNoiseTask () override
 
- Public Member Functions inherited from CommissioningTask
void bookHistograms ()
 
 CommissioningTask (DQMStore *, const FedChannelConnection &, const std::string &my_name)
 
void eventSetup (const edm::EventSetup *)
 
const uint32_t & fillCntr () const
 
void fillHistograms (const SiStripEventSummary &, const edm::DetSet< SiStripRawDigi > &)
 
void fillHistograms (const SiStripEventSummary &, const edm::DetSet< SiStripRawDigi > &, const edm::DetSet< SiStripRawDigi > &)
 
void fillHistograms (const SiStripEventSummary &, const edm::DetSet< SiStripRawDigi > &, const edm::DetSet< SiStripRawDigi > &, const std::vector< uint16_t > &)
 
void fillHistograms (const SiStripEventSummary &, const uint16_t &fed_id, const std::map< uint16_t, float > &fed_ch)
 
const std::string & myName () const
 
const uint32_t & updateFreq () const
 
void updateFreq (const uint32_t &)
 
void updateHistograms ()
 
virtual ~CommissioningTask ()
 

Private Member Functions

void book () override
 
void fill (const SiStripEventSummary &, const edm::DetSet< SiStripRawDigi > &) override
 
void update () override
 

Private Attributes

bool fillnoiseprofile_
 
TH2S * hist2d_
 
uint16_t nadcnoise_
 
uint16_t nevpeds_
 
CompactHistoSet noisehist_
 
HistoSet noiseprof_
 
uint16_t nskip_
 
uint16_t nstrips_
 
HistoSet pedhist_
 
std::vector< int16_t > peds_
 
bool pedsdone_
 
std::vector< float > pedsfl_
 
bool skipped_
 
bool useavgcm_
 
bool usefloatpeds_
 

Additional Inherited Members

- Public Types inherited from CommissioningTask
typedef dqm::legacy::DQMStore DQMStore
 
typedef dqm::legacy::MonitorElement MonitorElement
 
- Protected Member Functions inherited from CommissioningTask
const FedChannelConnectionconnection () const
 
DQMStore *const dqm () const
 
const edm::EventSetup *const eventSetup () const
 
const uint32_t & fecKey () const
 
const uint32_t & fedKey () const
 
void updateHistoSet (HistoSet &, const uint32_t &bin, const float &value)
 
void updateHistoSet (CompactHistoSet &, const uint32_t &bin, const short &value)
 
void updateHistoSet (HistoSet &, const uint32_t &bin)
 
void updateHistoSet (CompactHistoSet &, const uint32_t &bin)
 
void updateHistoSet (HistoSet &, const float &value)
 
void updateHistoSet (CompactHistoSet &)
 
void updateHistoSet (HistoSet &)
 

Detailed Description

Definition at line 22 of file PedsFullNoiseTask.h.

Constructor & Destructor Documentation

PedsFullNoiseTask::PedsFullNoiseTask ( DQMStore dqm,
const FedChannelConnection conn,
const edm::ParameterSet pset 
)

Definition at line 14 of file PedsFullNoiseTask.cc.

References fillnoiseprofile_, edm::ParameterSet::getParameter(), LogTrace, sistrip::mlDqmSource_, nadcnoise_, nevpeds_, nskip_, submitPVValidationJobs::params, pedsdone_, skipped_, useavgcm_, and usefloatpeds_.

15  : CommissioningTask(dqm, conn, "PedsFullNoiseTask"), nstrips_(256) {
16  LogTrace(sistrip::mlDqmSource_) << "[PedsFullNoiseTask::" << __func__ << "]"
17  << " Constructing object...";
18  edm::ParameterSet params = pset.getParameter<edm::ParameterSet>("PedsFullNoiseParameters");
19  nskip_ = params.getParameter<int>("NrEvToSkipAtStart");
20  skipped_ = false;
21  nevpeds_ = params.getParameter<int>("NrEvForPeds");
22  pedsdone_ = false;
23  nadcnoise_ = params.getParameter<int>("NrPosBinsNoiseHist");
24  fillnoiseprofile_ = params.getParameter<bool>("FillNoiseProfile");
25  useavgcm_ = params.getParameter<bool>("UseAverageCommonMode");
26  usefloatpeds_ = params.getParameter<bool>("UseFloatPedestals");
27 }
static const char mlDqmSource_[]
#define LogTrace(id)
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
PedsFullNoiseTask::~PedsFullNoiseTask ( )
override

Definition at line 31 of file PedsFullNoiseTask.cc.

References LogTrace, and sistrip::mlDqmSource_.

31  {
32  LogTrace(sistrip::mlDqmSource_) << "[PedsFullNoiseTask::" << __func__ << "]"
33  << " Destructing object...";
34 }
static const char mlDqmSource_[]
#define LogTrace(id)

Member Function Documentation

void PedsFullNoiseTask::book ( )
overrideprivatevirtual

Reimplemented from CommissioningTask.

Definition at line 38 of file PedsFullNoiseTask.cc.

References CommissioningTask::connection(), CommissioningTask::dqm(), sistrip::EXPERT_HISTO, CommissioningTask::HistoSet::explicitFill_, CommissioningTask::CompactHistoSet::explicitFill_, sistrip::FED_KEY, CommissioningTask::fedKey(), hist2d_, CommissioningTask::HistoSet::histo(), CommissioningTask::CompactHistoSet::histo(), CommissioningTask::HistoSet::isProfile_, sistrip::LLD_CHAN, LogTrace, sistrip::mlDqmSource_, nadcnoise_, sistrip::extrainfo::noise2D_, noisehist_, noiseprof_, sistrip::extrainfo::noiseProfile_, nstrips_, sistrip::extrainfo::pedestals_, pedhist_, sistrip::PEDS_FULL_NOISE, AlCaHLTBitMon_QueryRunRegistry::string, SiStripHistoTitle::title(), CommissioningTask::HistoSet::vNumOfEntries_, CommissioningTask::CompactHistoSet::vNumOfEntries_, CommissioningTask::HistoSet::vSumOfContents_, and CommissioningTask::HistoSet::vSumOfSquares_.

38  {
39  LogTrace(sistrip::mlDqmSource_) << "[PedsFullNoiseTask::" << __func__ << "]";
40 
41  // pedestal profile histo
42  pedhist_.isProfile_ = true;
43  pedhist_.explicitFill_ = false;
44  if (!pedhist_.explicitFill_) {
45  pedhist_.vNumOfEntries_.resize(nstrips_, 0);
47  pedhist_.vSumOfSquares_.resize(nstrips_, 0);
48  }
52  fedKey(),
54  connection().lldChannel(),
56  .title();
57  pedhist_.histo(dqm()->bookProfile(titleped, titleped, nstrips_, -0.5, nstrips_ * 1. - 0.5, 1025, 0., 1025.));
58 
59  // Noise profile
60  noiseprof_.isProfile_ = true;
61  noiseprof_.explicitFill_ = false;
66  }
70  fedKey(),
72  connection().lldChannel(),
74  .title();
75  noiseprof_.histo(dqm()->bookProfile(titlenoise, titlenoise, nstrips_, -0.5, nstrips_ * 1. - 0.5, 1025, 0., 1025.));
76 
77  // noise 2D compact histo
78  noisehist_.explicitFill_ = false;
80  noisehist_.vNumOfEntries_.resize((nstrips_ + 2) * 2 * (nadcnoise_ + 2), 0);
81  }
85  fedKey(),
87  connection().lldChannel(),
89  .title();
90  noisehist_.histo(dqm()->book2S(
91  titlenoise2d, titlenoise2d, 2 * nadcnoise_, -nadcnoise_, nadcnoise_, nstrips_, -0.5, nstrips_ * 1. - 0.5));
92  hist2d_ = (TH2S*)noisehist_.histo()->getTH2S();
93 }
std::vector< float > vNumOfEntries_
Utility class that holds histogram title.
const std::string & title() const
static const char mlDqmSource_[]
std::vector< float > vSumOfContents_
#define LogTrace(id)
static const char noise2D_[]
DQMStore *const dqm() const
static const char noiseProfile_[]
static const char pedestals_[]
CompactHistoSet noisehist_
void histo(MonitorElement *)
const uint32_t & fedKey() const
std::vector< double > vSumOfSquares_
const FedChannelConnection & connection() const
void PedsFullNoiseTask::fill ( const SiStripEventSummary summary,
const edm::DetSet< SiStripRawDigi > &  digis 
)
overrideprivatevirtual

Reimplemented from CommissioningTask.

Definition at line 97 of file PedsFullNoiseTask.cc.

References gpuClustering::adc, edm::DetSet< T >::data, SiStripEventSummary::event(), fillnoiseprofile_, hist2d_, LogTrace, sistrip::mlDqmSource_, nadcnoise_, hlt_dqm_clientPB-live_cfg::nbins, nevpeds_, noisehist_, noiseprof_, nskip_, nstrips_, pedhist_, peds_, pedsdone_, pedsfl_, skipped_, CommissioningTask::updateHistoSet(), useavgcm_, usefloatpeds_, CommissioningTask::HistoSet::vNumOfEntries_, and CommissioningTask::HistoSet::vSumOfContents_.

97  {
98  // Check number of digis
99  uint16_t nbins = digis.data.size();
100  if (nbins != nstrips_) {
101  edm::LogWarning(sistrip::mlDqmSource_) << "[PedsFullNoiseTask::" << __func__ << "]"
102  << " " << nstrips_ << " digis expected, but got " << nbins << ". Skipping.";
103  return;
104  }
105 
106  // get the event number of the first event, not necessarily 1 (parallel processing on FUs)
107  static int32_t firstev = summary.event();
108 
109  // skipping events
110  if (!skipped_) {
111  if (static_cast<int32_t>(summary.event()) - firstev < nskip_) {
112  return;
113  } else { // when all events are skipped
114  skipped_ = true;
115  if (nskip_ > 0)
116  LogTrace(sistrip::mlDqmSource_) << "[PedsFullNoiseTask::" << __func__ << "]"
117  << " Done skipping events. Now starting pedestals.";
118  }
119  }
120 
121  // determine pedestals - decoupled from noise determination
122  if (!pedsdone_) {
123  if (static_cast<int32_t>(summary.event()) - firstev < nskip_ + nevpeds_) {
124  // estimate the pedestals
125  for (uint16_t istrip = 0; istrip < nstrips_; ++istrip) {
126  updateHistoSet(pedhist_, istrip, digis.data[istrip].adc());
127  }
128  return;
129  } else { // when pedestals are done
130  pedsdone_ = true;
131  // cache the pedestal values for use in the 2D noise estimation
132  peds_.clear();
133  pedsfl_.clear();
134  for (uint16_t iapv = 0; iapv < 2; ++iapv) {
135  for (uint16_t ibin = 0; ibin < 128; ++ibin) {
136  uint16_t istrip = (iapv * 128) + ibin;
137  if (usefloatpeds_) {
138  pedsfl_.push_back(1. * pedhist_.vSumOfContents_.at(istrip) / pedhist_.vNumOfEntries_.at(istrip));
139  } else {
140  peds_.push_back(
141  static_cast<int16_t>(1. * pedhist_.vSumOfContents_.at(istrip) / pedhist_.vNumOfEntries_.at(istrip)));
142  }
143  }
144  }
145  LogTrace(sistrip::mlDqmSource_) << "[PedsFullNoiseTask::" << __func__ << "]"
146  << " Rough pedestals done. Now starting noise measurements.";
147  }
148  }
149 
150  // fill (or not) the old-style niose profile
151  if (fillnoiseprofile_) {
152  // Calc common mode for both APVs
153  std::vector<int32_t> cm;
154  cm.resize(2, 0);
155  std::vector<uint16_t> adc;
156  for (uint16_t iapv = 0; iapv < 2; iapv++) {
157  adc.clear();
158  adc.reserve(128);
159  for (uint16_t ibin = 0; ibin < 128; ibin++) {
160  if ((iapv * 128) + ibin < nbins) {
161  adc.push_back(digis.data.at((iapv * 128) + ibin).adc());
162  }
163  }
164  sort(adc.begin(), adc.end());
165  // take median as common mode
166  uint16_t index = adc.size() % 2 ? adc.size() / 2 : adc.size() / 2 - 1;
167  cm[iapv] = static_cast<int16_t>(adc[index]);
168  }
169  // 1D noise profile - see also further processing in the update() method
170  for (uint16_t istrip = 0; istrip < nstrips_; ++istrip) {
171  // calculate the noise in the old way, by subtracting the common mode, but without pedestal subtraction
172  int16_t noiseval = static_cast<int16_t>(digis.data.at(istrip).adc()) - cm[istrip / 128];
173  updateHistoSet(noiseprof_, istrip, noiseval);
174  }
175  }
176 
177  // 2D noise histogram
178  std::vector<int16_t> noisevals, noisevalssorted;
179  std::vector<float> noisevalsfl, noisevalssortedfl;
180  for (uint16_t iapv = 0; iapv < 2; ++iapv) {
181  float totadc = 0;
182  noisevals.clear();
183  noisevalsfl.clear();
184  noisevalssorted.clear();
185  noisevalssortedfl.clear();
186  for (uint16_t ibin = 0; ibin < 128; ++ibin) {
187  uint16_t istrip = (iapv * 128) + ibin;
188  // calculate the noise after subtracting the pedestal
189  if (usefloatpeds_) { // if float pedestals -> before FED processing
190  noisevalsfl.push_back(static_cast<float>(digis.data.at(istrip).adc()) - pedsfl_.at(istrip));
191  // now we still have a possible constant shift of the adc values with respect to 0, so we prepare to calculate the median of this shift
192  if (useavgcm_) { // if average CM -> before FED processing
193  totadc += noisevalsfl[ibin];
194  } else { // if median CM -> after FED processing
195  noisevalssortedfl.push_back(noisevalsfl[ibin]);
196  }
197  } else { // if integer pedestals -> after FED processing
198  noisevals.push_back(static_cast<int16_t>(digis.data.at(istrip).adc()) - peds_.at(istrip));
199  // now we still have a possible constant shift of the adc values with respect to 0, so we prepare to calculate the median of this shift
200  if (useavgcm_) { // if average CM -> before FED processing
201  totadc += noisevals[ibin];
202  } else { // if median CM -> after FED processing
203  noisevalssorted.push_back(noisevals[ibin]);
204  }
205  }
206  }
207  // calculate the common mode shift to apply
208  float cmshift = 0;
209  if (useavgcm_) { // if average CM -> before FED processing
210  if (usefloatpeds_) { // if float pedestals -> before FED processing
211  cmshift = totadc / 128;
212  } else { // if integer pedestals -> after FED processing
213  cmshift = static_cast<int16_t>(totadc / 128);
214  }
215  } else { // if median CM -> after FED processing
216  if (usefloatpeds_) { // if float pedestals -> before FED processing
217  // get the median common mode
218  sort(noisevalssortedfl.begin(), noisevalssortedfl.end());
219  uint16_t index = noisevalssortedfl.size() % 2 ? noisevalssortedfl.size() / 2 : noisevalssortedfl.size() / 2 - 1;
220  cmshift = noisevalssortedfl[index];
221  } else { // if integer pedestals -> after FED processing
222  // get the median common mode
223  sort(noisevalssorted.begin(), noisevalssorted.end());
224  uint16_t index = noisevalssorted.size() % 2 ? noisevalssorted.size() / 2 : noisevalssorted.size() / 2 - 1;
225  cmshift = noisevalssorted[index];
226  }
227  }
228  // now loop again to calculate the CM+pedestal subtracted noise values
229  for (uint16_t ibin = 0; ibin < 128; ++ibin) {
230  uint16_t istrip = (iapv * 128) + ibin;
231  // subtract the remaining common mode after subtraction of the rough pedestals
232  float noiseval = (usefloatpeds_ ? noisevalsfl[ibin] : noisevals[ibin]) - cmshift;
233  // retrieve the linear binnr through the histogram
234  uint32_t binnr = hist2d_->GetBin(static_cast<int>(noiseval + nadcnoise_), istrip + 1);
235  // store the noise value in the 2D histo
236  updateHistoSet(noisehist_, binnr); // no value, so weight 1
237  }
238  }
239 }
std::vector< float > vNumOfEntries_
static const char mlDqmSource_[]
std::vector< float > vSumOfContents_
#define LogTrace(id)
void updateHistoSet(HistoSet &, const uint32_t &bin, const float &value)
const uint32_t & event() const
CompactHistoSet noisehist_
std::vector< int16_t > peds_
collection_type data
Definition: DetSet.h:80
Log< level::Warning, false > LogWarning
uint16_t *__restrict__ uint16_t const *__restrict__ adc
std::vector< float > pedsfl_
void PedsFullNoiseTask::update ( )
overrideprivatevirtual

Reimplemented from CommissioningTask.

Definition at line 243 of file PedsFullNoiseTask.cc.

References relativeConstraints::error, extract(), fillnoiseprofile_, CommissioningTask::HistoSet::histo(), timingPdfMaker::histo, cuy::ii, SiStripPI::mean, noisehist_, noiseprof_, pedhist_, UpdateTProfile::setBinContent(), mathSSE::sqrt(), CommissioningTask::updateHistoSet(), CommissioningTask::HistoSet::vNumOfEntries_, CommissioningTask::HistoSet::vSumOfContents_, and CommissioningTask::HistoSet::vSumOfSquares_.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), dqm-mbProfile.Profile::finish(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

243  {
244  // pedestals
246 
247  if (fillnoiseprofile_) {
248  // noise profile (does not use HistoSet directly, as want to plot noise as "contents", not "error")
250  for (uint16_t ii = 0; ii < noiseprof_.vNumOfEntries_.size(); ++ii) {
251  float mean = 0.;
252  float spread = 0.;
253  float entries = noiseprof_.vNumOfEntries_[ii];
254  if (entries > 0.) {
255  mean = noiseprof_.vSumOfContents_[ii] / entries;
256  spread = sqrt(noiseprof_.vSumOfSquares_[ii] / entries -
257  mean * mean); // nice way to calculate std dev: Sum (x-<x>)^2 / N
258  }
259  float error = spread / sqrt(entries); // uncertainty on std.dev. when no uncertainty on mean
260  UpdateTProfile::setBinContent(histo, ii + 1, entries, spread, error);
261  }
262  }
263 
264  // noise 2D histo
266 }
std::vector< float > vNumOfEntries_
std::vector< float > vSumOfContents_
int ii
Definition: cuy.py:589
void updateHistoSet(HistoSet &, const uint32_t &bin, const float &value)
T sqrt(T t)
Definition: SSEVec.h:19
static void setBinContent(TProfile *const profile, const uint32_t &bin, const double &entries, const double &mean, const double &spread)
int extract(std::vector< int > *output, const std::string &dati)
CompactHistoSet noisehist_
void histo(MonitorElement *)
std::vector< double > vSumOfSquares_

Member Data Documentation

bool PedsFullNoiseTask::fillnoiseprofile_
private

Definition at line 51 of file PedsFullNoiseTask.h.

Referenced by fill(), PedsFullNoiseTask(), and update().

TH2S* PedsFullNoiseTask::hist2d_
private

Definition at line 35 of file PedsFullNoiseTask.h.

Referenced by book(), and fill().

uint16_t PedsFullNoiseTask::nadcnoise_
private

Definition at line 47 of file PedsFullNoiseTask.h.

Referenced by book(), fill(), and PedsFullNoiseTask().

uint16_t PedsFullNoiseTask::nevpeds_
private

Definition at line 45 of file PedsFullNoiseTask.h.

Referenced by fill(), and PedsFullNoiseTask().

CompactHistoSet PedsFullNoiseTask::noisehist_
private

Definition at line 34 of file PedsFullNoiseTask.h.

Referenced by book(), fill(), and update().

HistoSet PedsFullNoiseTask::noiseprof_
private

Definition at line 33 of file PedsFullNoiseTask.h.

Referenced by book(), fill(), and update().

uint16_t PedsFullNoiseTask::nskip_
private

Definition at line 41 of file PedsFullNoiseTask.h.

Referenced by fill(), and PedsFullNoiseTask().

uint16_t PedsFullNoiseTask::nstrips_
private

Definition at line 49 of file PedsFullNoiseTask.h.

Referenced by book(), and fill().

HistoSet PedsFullNoiseTask::pedhist_
private

Definition at line 33 of file PedsFullNoiseTask.h.

Referenced by book(), fill(), and update().

std::vector<int16_t> PedsFullNoiseTask::peds_
private

Definition at line 36 of file PedsFullNoiseTask.h.

Referenced by fill().

bool PedsFullNoiseTask::pedsdone_
private

Definition at line 43 of file PedsFullNoiseTask.h.

Referenced by fill(), and PedsFullNoiseTask().

std::vector<float> PedsFullNoiseTask::pedsfl_
private

Definition at line 37 of file PedsFullNoiseTask.h.

Referenced by fill().

bool PedsFullNoiseTask::skipped_
private

Definition at line 39 of file PedsFullNoiseTask.h.

Referenced by fill(), and PedsFullNoiseTask().

bool PedsFullNoiseTask::useavgcm_
private

Definition at line 53 of file PedsFullNoiseTask.h.

Referenced by fill(), and PedsFullNoiseTask().

bool PedsFullNoiseTask::usefloatpeds_
private

Definition at line 55 of file PedsFullNoiseTask.h.

Referenced by fill(), and PedsFullNoiseTask().