CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
NoiseTask Class Reference

#include <NoiseTask.h>

Inheritance diagram for NoiseTask:
CommissioningTask

Public Member Functions

 NoiseTask (DQMStore *, const FedChannelConnection &)
 
 ~NoiseTask () 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

std::vector< HistoSetcm_
 
ApvAnalysisFactorypApvFactory_
 
std::vector< HistoSetpeds_
 

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 (CompactHistoSet &)
 
void updateHistoSet (CompactHistoSet &, const uint32_t &bin)
 
void updateHistoSet (CompactHistoSet &, const uint32_t &bin, const short &value)
 
void updateHistoSet (HistoSet &)
 
void updateHistoSet (HistoSet &, const float &value)
 
void updateHistoSet (HistoSet &, const uint32_t &bin)
 
void updateHistoSet (HistoSet &, const uint32_t &bin, const float &value)
 

Detailed Description

Definition at line 19 of file NoiseTask.h.

Constructor & Destructor Documentation

◆ NoiseTask()

NoiseTask::NoiseTask ( DQMStore dqm,
const FedChannelConnection conn 
)

Definition at line 32 of file NoiseTask.cc.

32  : CommissioningTask(dqm, conn, "NoiseTask") {
33  //@@ NOT GUARANTEED TO BE THREAD SAFE!
34  pApvFactory_ = edm::Service<ApvFactoryService>().operator->()->getApvFactory();
35 
36  LogTrace(mlDqmSource_) << "[NoiseTask::" << __func__ << "]"
37  << " Constructing object...";
38 }

References LogTrace, sistrip::mlDqmSource_, and pApvFactory_.

◆ ~NoiseTask()

NoiseTask::~NoiseTask ( )
override

Definition at line 42 of file NoiseTask.cc.

42  {
43  LogTrace(mlDqmSource_) << "[NoiseTask::" << __func__ << "]"
44  << " Destructing object...";
45 
46  // Have to delete pApvFactory_ manually even though we didn't create it
47  // ourself. :(
48  if (pApvFactory_) {
49  delete pApvFactory_;
50  }
51 }

References LogTrace, sistrip::mlDqmSource_, and pApvFactory_.

Member Function Documentation

◆ book()

void NoiseTask::book ( )
overrideprivatevirtual

Reimplemented from CommissioningTask.

Definition at line 55 of file NoiseTask.cc.

55  {
56  LogTrace(mlDqmSource_) << "[NoiseTask::" << __func__ << "]";
57 
58  // CACHING
59  static std::unique_ptr<SiStripPedestals> pDBPedestals;
60  static std::unique_ptr<SiStripNoises> pDBNoises;
61 
62  const uint16_t nBINS = 256;
63 
64  {
65  // Pedestals
69  fedKey(),
71  connection().lldChannel(),
73  .title();
74 
75  HistoSet oHSet;
76  oHSet.isProfile_ = true;
77 
78  oHSet.vNumOfEntries_.resize(nBINS, 0);
79  oHSet.vSumOfContents_.resize(nBINS, 0);
80  oHSet.vSumOfSquares_.resize(nBINS, 0);
81 
82  oHSet.histo(dqm()->bookProfile(title, title, nBINS, -0.5, nBINS * 1. - 0.5, 1025, 0., 1025.));
83 
84  peds_.push_back(oHSet);
85  }
86 
87  {
88  // Corrected Noise
92  fedKey(),
94  connection().lldChannel(),
96  .title();
97 
98  HistoSet oHSet;
99  oHSet.isProfile_ = true;
100 
101  oHSet.vNumOfEntries_.resize(nBINS, 0);
102  oHSet.vSumOfContents_.resize(nBINS, 0);
103  oHSet.vSumOfSquares_.resize(nBINS, 0);
104 
105  oHSet.histo(dqm()->bookProfile(title, title, nBINS, -0.5, nBINS * 1. - 0.5, 1025, 0., 1025.));
106 
107  peds_.push_back(oHSet);
108  }
109 
110  const uint16_t nCM_BINS = 1024;
111  for (uint16_t nApv = 0; 2 > nApv; ++nApv) {
115  fedKey(),
116  sistrip::APV,
117  connection().i2cAddr(nApv),
119  .title();
120 
121  HistoSet oHSet;
122 
123  oHSet.isProfile_ = false;
124 
125  oHSet.vNumOfEntries_.resize(nCM_BINS, 0);
126 
127  oHSet.histo(dqm()->book1D(title, title, nCM_BINS, nCM_BINS / 2 * -1. - 0.5, nCM_BINS / 2 * 1. - 0.5));
128 
129  cm_.push_back(oHSet);
130  }
131 
132  // Initialize Apv
133  pApvFactory_->instantiateApvs(connection().detId(), connection().nApvs());
134 
135  // --[ RETRIEVE PEDESTALS FROM DB ]--
136  // Operation should be performed only once
137  if (!pDBPedestals.get()) {
138  LogTrace(mlDqmSource_) << "[NoiseTask::" << __func__ << "] "
139  << "Retrieving Pedestals from DB";
140 
141  // Directly retrieve Pedestals from EventSetup
143  eventSetup()->get<SiStripPedestalsRcd>().get(pedestals);
144 
145  // Cache Pedestals
146  pDBPedestals.reset(new SiStripPedestals(*pedestals));
147 
148  LogTrace(mlDqmSource_) << "[NoiseTask::" << __func__ << "] "
149  << "Done Retrieving Pedestals from DB";
150  } // End retrieve Pedestals from DB
151 
152  // --[ RETRIEVE NOISES FROM DB ]--
153  // Operation should be performed only once
154  if (!pDBNoises.get()) {
155  LogTrace(mlDqmSource_) << "[NoiseTask::" << __func__ << "] "
156  << "Retrieving Noises from DB";
157 
158  // Directly retrieve Noises from EventSetup
161 
162  // Cache Pedestals
163  pDBNoises.reset(new SiStripNoises(*noises));
164 
165  LogTrace(mlDqmSource_) << "[NoiseTask::" << __func__ << "] "
166  << "Done Retrieving Noises from DB";
167  } // End retrieve Noises from DB
168 
169  // Get ApvAnalysis associated with given DetId
171 
172  SiStripPedestals::Range pedestalsRange(pDBPedestals->getRange(connection().detId()));
173  SiStripNoises::Range noisesRange(pDBNoises->getRange(connection().detId()));
174 
175  // Cache Apv Pair #
176  const uint16_t nAPV_PAIR = connection().apvPairNumber();
177 
178  for (uint16_t nLclApv = 0; 2 > nLclApv; ++nLclApv) {
179  // Retrieve pedestals and noises associated with given DetId/Apv
180  ApvAnalysis::PedestalType pedestals;
182  for (uint16_t nStrip = nAPV_PAIR * 256 + nLclApv * 128, nMaxStrip = nStrip + 128; nMaxStrip > nStrip; ++nStrip) {
183  pedestals.push_back(pDBPedestals->getPed(nStrip, pedestalsRange));
184  noises.push_back(pDBNoises->getNoise(nStrip, noisesRange));
185  }
186 
187  try {
188  // Checked access
189  ApvAnalysisFactory::ApvAnalysisVector::reference rApvAnalysis = apvAnalysisVector.at(nAPV_PAIR * 2 + nLclApv);
190 
191  rApvAnalysis->pedestalCalculator().setPedestals(pedestals);
192  rApvAnalysis->pedestalCalculator().setNoise(noises);
193 
194  /*
195  std::stringstream out;
196  LogTrace( mlDqmSource_)
197  << "[NoiseTask::" << __func__ << "] "
198  << "DetId|Apv# -> "
199  << connection().detId() << '|' << ( nAPV_PAIR * 2 + nLclApv)
200  << " Pedestals: "
201  << ( out << pedestals
202  << " Noises: " << noises, out.str());
203  */
204  } catch (std::out_of_range const &) {
205  // Hmm, didn't find appropriate Apv :((( -> VERY, VERY BAD
206  LogTrace(mlDqmSource_) << "[NoiseTask::" << __func__ << "] "
207  << "Could not set Pedestals/Noises for DetId|Apv# -> " << connection().detId() << '|'
208  << (nAPV_PAIR * 2 + nLclApv) << ". !!! POSSIBLE BUG !!!";
209  } // End Try block
210  } // End Local Apvs loop
211 }

References sistrip::APV, FedChannelConnection::apvPairNumber(), cm_, sistrip::extrainfo::commonMode_, CommissioningTask::connection(), FedChannelConnection::detId(), CommissioningTask::dqm(), CommissioningTask::eventSetup(), sistrip::EXPERT_HISTO, sistrip::FED_KEY, CommissioningTask::fedKey(), edm::EventSetup::get(), get, ApvAnalysisFactory::getApvAnalysis(), CommissioningTask::HistoSet::histo(), ApvAnalysisFactory::instantiateApvs(), CommissioningTask::HistoSet::isProfile_, sistrip::LLD_CHAN, LogTrace, sistrip::mlDqmSource_, sistrip::NOISE, sistrip::extrainfo::noise_, hgcalLayerClusters_cfi::noises, pApvFactory_, sistrip::PEDESTALS, sistrip::extrainfo::pedestals_, peds_, RecoTauValidation_cfi::reference, AlCaHLTBitMon_QueryRunRegistry::string, overlapproblemtsosanalyzer_cfi::title, SiStripHistoTitle::title(), CommissioningTask::HistoSet::vNumOfEntries_, CommissioningTask::HistoSet::vSumOfContents_, and CommissioningTask::HistoSet::vSumOfSquares_.

◆ fill()

void NoiseTask::fill ( const SiStripEventSummary rSummary,
const edm::DetSet< SiStripRawDigi > &  rDigis 
)
overrideprivatevirtual

Reimplemented from CommissioningTask.

Definition at line 215 of file NoiseTask.cc.

215  {
216  pApvFactory_->updatePair(connection().detId(), connection().apvPairNumber(), rDigis);
217 }

References CommissioningTask::connection(), pApvFactory_, and ApvAnalysisFactory::updatePair().

◆ update()

void NoiseTask::update ( )
overrideprivatevirtual

Reimplemented from CommissioningTask.

Definition at line 221 of file NoiseTask.cc.

221  {
222  static UpdateTProfile updateTProfile;
223 
224  TProfile *pedsProf = ExtractTObject<TProfile>().extract(peds_[0].histo());
225  TProfile *noiseProf = ExtractTObject<TProfile>().extract(peds_[1].histo());
226 
227  for (uint16_t nLclApv = 2 * connection().apvPairNumber(), nMaxLclApv = nLclApv + 2, nApv = 0; nMaxLclApv > nLclApv;
228  ++nLclApv, ++nApv) {
229  ApvAnalysis::PedestalType lclPedestals;
230  ApvAnalysis::PedestalType lclNoises;
231  ApvAnalysis::PedestalType lclCommonMode(pApvFactory_->getCommonMode(connection().detId(), nLclApv));
232 
233  pApvFactory_->getPedestal(connection().detId(), nLclApv, lclPedestals);
234  pApvFactory_->getNoise(connection().detId(), nLclApv, lclNoises);
235 
236  const uint16_t nSTART_BIN = 128 * (nLclApv % 2);
237 
238  for (uint16_t nBin = 0, nAbsBin = nSTART_BIN + nBin + 1; 128 > nBin; ++nBin, ++nAbsBin) {
239  updateTProfile.setBinContent(pedsProf, nAbsBin, 5, lclPedestals[nBin], lclNoises[nBin]);
240  updateTProfile.setBinContent(noiseProf, nAbsBin, 5, lclNoises[nBin], 0);
241  } // End loop over BINs
242 
243  // Samvel: Assume Once CM value is calculated per chip.
244  // In principle Chip can be divided into a several ranges. Then CM
245  // will be calculated per range. !!! UPDATE CODE THEN !!!
246  for (ApvAnalysis::PedestalType::const_iterator cmIterator = lclCommonMode.begin();
247  cmIterator != lclCommonMode.end();
248  ++cmIterator) {
249  //uint32_t nCM = static_cast<uint32_t>( *cmIterator);
250  //if( nCM >= 1024) nCM = 1023;
251  //updateHistoSet( cm_[nApv], nCM);
252  float nCM = static_cast<float>(*cmIterator);
253  updateHistoSet(cm_[nApv], nCM);
254  }
255 
256  std::stringstream out;
257  LogTrace(mlDqmSource_) << "[NoiseTask::" << __func__ << "] "
258  << "DET ID [" << connection().detId() << "] has Common Mode size " << lclCommonMode.size()
259  << " : " << (out << lclCommonMode, out.str());
260  } // End loop over Local Apvs
261 
262  updateHistoSet(cm_[0]);
263  updateHistoSet(cm_[1]);
264 }

References cm_, CommissioningTask::connection(), FedChannelConnection::detId(), ExtractTObject< T >::extract(), ApvAnalysisFactory::getCommonMode(), ApvAnalysisFactory::getNoise(), ApvAnalysisFactory::getPedestal(), timingPdfMaker::histo, LogTrace, sistrip::mlDqmSource_, PFElectronDQMAnalyzer_cfi::nBin, MillePedeFileConverter_cfg::out, pApvFactory_, peds_, UpdateTProfile::setBinContent(), and CommissioningTask::updateHistoSet().

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

Member Data Documentation

◆ cm_

std::vector<HistoSet> NoiseTask::cm_
private

Definition at line 30 of file NoiseTask.h.

Referenced by book(), and update().

◆ pApvFactory_

ApvAnalysisFactory* NoiseTask::pApvFactory_
private

Definition at line 32 of file NoiseTask.h.

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

◆ peds_

std::vector<HistoSet> NoiseTask::peds_
private

Definition at line 29 of file NoiseTask.h.

Referenced by book(), and update().

sistrip::mlDqmSource_
static const char mlDqmSource_[]
Definition: ConstantsForLogger.h:20
sistrip::extrainfo::commonMode_
static const char commonMode_[]
Definition: ConstantsForDqm.h:48
ApvAnalysisFactory::getNoise
void getNoise(uint32_t det_id, int apvNumber, ApvAnalysis::PedestalType &noise)
Definition: ApvAnalysisFactory.cc:230
sistrip::extrainfo::noise_
static const char noise_[]
Definition: ConstantsForDqm.h:47
UpdateTProfile
Definition: UpdateTProfile.h:8
SiStripNoises
Definition: SiStripNoises.h:25
NoiseTask::pApvFactory_
ApvAnalysisFactory * pApvFactory_
Definition: NoiseTask.h:32
SiStripPedestals::Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripPedestals.h:51
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
ApvAnalysisFactory::getPedestal
void getPedestal(uint32_t det_id, int apvNumber, ApvAnalysis::PedestalType &peds)
Definition: ApvAnalysisFactory.cc:198
ExtractTObject
Definition: ExtractTObject.h:9
SiStripPedestalsRcd
Definition: SiStripCondDataRecords.h:44
PFElectronDQMAnalyzer_cfi.nBin
nBin
Definition: PFElectronDQMAnalyzer_cfi.py:25
SiStripNoisesRcd
Definition: SiStripCondDataRecords.h:40
CommissioningTask::fedKey
const uint32_t & fedKey() const
Definition: CommissioningTask.h:192
ApvAnalysisFactory::updatePair
void updatePair(uint32_t det_id, size_t apvPair, const edm::DetSet< SiStripRawDigi > &in)
Definition: ApvAnalysisFactory.cc:136
ApvAnalysisFactory::instantiateApvs
bool instantiateApvs(uint32_t det_id, int numberOfApvs)
Definition: ApvAnalysisFactory.cc:57
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
SiStripNoises::Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripNoises.h:47
sistrip::EXPERT_HISTO
Definition: ConstantsForHistoType.h:29
edm::ESHandle< SiStripPedestals >
sistrip::extrainfo::pedestals_
static const char pedestals_[]
Definition: ConstantsForDqm.h:45
CommissioningTask::CommissioningTask
CommissioningTask()
Definition: CommissioningTask.h:143
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
ApvAnalysisFactory::getApvAnalysis
ApvAnalysisVector getApvAnalysis(const uint32_t nDET_ID)
Definition: ApvAnalysisFactory.cc:75
FedChannelConnection::detId
const uint32_t & detId() const
Definition: FedChannelConnection.h:212
sistrip::PEDESTALS
Definition: ConstantsForRunType.h:72
CommissioningTask::eventSetup
const edm::EventSetup *const eventSetup() const
Definition: CommissioningTask.h:195
sistrip::APV
Definition: ConstantsForGranularity.h:79
RecoTauValidation_cfi.reference
reference
Definition: RecoTauValidation_cfi.py:234
edm::Service
Definition: Service.h:30
CommissioningTask::updateHistoSet
void updateHistoSet(HistoSet &, const uint32_t &bin, const float &value)
Definition: CommissioningTask.cc:274
ExtractTObject::extract
static T * extract(MonitorElement *me)
Definition: ExtractTObject.cc:21
get
#define get
hgcalLayerClusters_cfi.noises
noises
Definition: hgcalLayerClusters_cfi.py:40
overlapproblemtsosanalyzer_cfi.title
title
Definition: overlapproblemtsosanalyzer_cfi.py:7
CommissioningTask::dqm
DQMStore *const dqm() const
Definition: CommissioningTask.h:188
NoiseTask::peds_
std::vector< HistoSet > peds_
Definition: NoiseTask.h:29
sistrip::NOISE
Definition: ConstantsForRunType.h:91
SiStripHistoTitle::title
const std::string & title() const
Definition: SiStripHistoTitle.h:109
SiStripHistoTitle
Utility class that holds histogram title.
Definition: SiStripHistoTitle.h:20
ApvAnalysisFactory::getCommonMode
void getCommonMode(uint32_t det_id, ApvAnalysis::PedestalType &tmp)
Definition: ApvAnalysisFactory.cc:311
ApvAnalysisFactory::ApvAnalysisVector
std::vector< ApvAnalysis * > ApvAnalysisVector
Definition: ApvAnalysisFactory.h:24
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
FedChannelConnection::apvPairNumber
uint16_t apvPairNumber() const
Definition: FedChannelConnection.cc:125
SiStripPedestals
Definition: SiStripPedestals.h:27
dqm
Definition: DQMStore.h:18
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
sistrip::FED_KEY
Definition: ConstantsForKeyType.h:30
ApvAnalysis::PedestalType
std::vector< float > PedestalType
Definition: ApvAnalysis.h:44
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
sistrip::LLD_CHAN
Definition: ConstantsForGranularity.h:78
NoiseTask::cm_
std::vector< HistoSet > cm_
Definition: NoiseTask.h:30