CMS 3D CMS Logo

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 16 of file PedsFullNoiseTask.cc.

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

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

Definition at line 33 of file PedsFullNoiseTask.cc.

References LogTrace, and sistrip::mlDqmSource_.

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

Member Function Documentation

void PedsFullNoiseTask::book ( )
overrideprivatevirtual

Reimplemented from CommissioningTask.

Definition at line 40 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_.

40  {
41  LogTrace(sistrip::mlDqmSource_) << "[PedsFullNoiseTask::" << __func__ << "]";
42 
43  // pedestal profile histo
44  pedhist_.isProfile_ = true;
45  pedhist_.explicitFill_ = false;
46  if (!pedhist_.explicitFill_) {
47  pedhist_.vNumOfEntries_.resize(nstrips_, 0);
49  pedhist_.vSumOfSquares_.resize(nstrips_, 0);
50  }
54  fedKey(),
56  connection().lldChannel(),
58  .title();
59  pedhist_.histo(dqm()->bookProfile(titleped, titleped, nstrips_, -0.5, nstrips_ * 1. - 0.5, 1025, 0., 1025.));
60 
61  // Noise profile
62  noiseprof_.isProfile_ = true;
63  noiseprof_.explicitFill_ = false;
68  }
72  fedKey(),
74  connection().lldChannel(),
76  .title();
77  noiseprof_.histo(dqm()->bookProfile(titlenoise, titlenoise, nstrips_, -0.5, nstrips_ * 1. - 0.5, 1025, 0., 1025.));
78 
79  // noise 2D compact histo
80  noisehist_.explicitFill_ = false;
82  noisehist_.vNumOfEntries_.resize((nstrips_ + 2) * 2 * (nadcnoise_ + 2), 0);
83  }
87  fedKey(),
89  connection().lldChannel(),
91  .title();
92  noisehist_.histo(dqm()->book2S(
93  titlenoise2d, titlenoise2d, 2 * nadcnoise_, -nadcnoise_, nadcnoise_, nstrips_, -0.5, nstrips_ * 1. - 0.5));
94  hist2d_ = (TH2S*)noisehist_.histo()->getTH2S();
95 }
std::vector< float > vNumOfEntries_
Utility class that holds histogram title.
const std::string & title() const
static const char mlDqmSource_[]
std::vector< float > vSumOfContents_
static const char noise2D_[]
DQMStore *const dqm() const
static const char noiseProfile_[]
#define LogTrace(id)
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 99 of file PedsFullNoiseTask.cc.

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

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

Reimplemented from CommissioningTask.

Definition at line 245 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__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), dqm-mbProfile.Profile::finish(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), MatrixUtil.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

245  {
246  // pedestals
248 
249  if (fillnoiseprofile_) {
250  // noise profile (does not use HistoSet directly, as want to plot noise as "contents", not "error")
252  for (uint16_t ii = 0; ii < noiseprof_.vNumOfEntries_.size(); ++ii) {
253  float mean = 0.;
254  float spread = 0.;
255  float entries = noiseprof_.vNumOfEntries_[ii];
256  if (entries > 0.) {
257  mean = noiseprof_.vSumOfContents_[ii] / entries;
258  spread = sqrt(noiseprof_.vSumOfSquares_[ii] / entries -
259  mean * mean); // nice way to calculate std dev: Sum (x-<x>)^2 / N
260  }
261  float error = spread / sqrt(entries); // uncertainty on std.dev. when no uncertainty on mean
262  UpdateTProfile::setBinContent(histo, ii + 1, entries, spread, error);
263  }
264  }
265 
266  // noise 2D histo
268 }
std::vector< float > vNumOfEntries_
std::vector< float > vSumOfContents_
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)
ii
Definition: cuy.py:590
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().