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
NoiseTask Class Reference

#include <NoiseTask.h>

Inheritance diagram for NoiseTask:
CommissioningTask

Public Member Functions

 NoiseTask (DQMStore *, const FedChannelConnection &, edm::ESGetToken< SiStripPedestals, SiStripPedestalsRcd > pedestalToken, edm::ESGetToken< SiStripNoises, SiStripNoisesRcd > noiseToken)
 
 ~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_
 
edm::ESGetToken< SiStripNoises,
SiStripNoisesRcd
noiseToken_
 
ApvAnalysisFactorypApvFactory_
 
edm::ESGetToken
< SiStripPedestals,
SiStripPedestalsRcd
pedestalToken_
 
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 (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 23 of file NoiseTask.h.

Constructor & Destructor Documentation

NoiseTask::NoiseTask ( DQMStore dqm,
const FedChannelConnection conn,
edm::ESGetToken< SiStripPedestals, SiStripPedestalsRcd pedestalToken,
edm::ESGetToken< SiStripNoises, SiStripNoisesRcd noiseToken 
)

Definition at line 32 of file NoiseTask.cc.

References LogTrace, sistrip::mlDqmSource_, Utilities::operator, and pApvFactory_.

36  : CommissioningTask(dqm, conn, "NoiseTask"), pedestalToken_(pedestalToken), noiseToken_(noiseToken) {
37  //@@ NOT GUARANTEED TO BE THREAD SAFE!
38  pApvFactory_ = edm::Service<ApvFactoryService>().operator->()->getApvFactory();
39 
40  LogTrace(mlDqmSource_) << "[NoiseTask::" << __func__ << "]"
41  << " Constructing object...";
42 }
static const char mlDqmSource_[]
edm::ESGetToken< SiStripPedestals, SiStripPedestalsRcd > pedestalToken_
Definition: NoiseTask.h:40
ApvAnalysisFactory * pApvFactory_
Definition: NoiseTask.h:39
#define LogTrace(id)
edm::ESGetToken< SiStripNoises, SiStripNoisesRcd > noiseToken_
Definition: NoiseTask.h:41
NoiseTask::~NoiseTask ( )
override

Definition at line 46 of file NoiseTask.cc.

References LogTrace, sistrip::mlDqmSource_, and pApvFactory_.

46  {
47  LogTrace(mlDqmSource_) << "[NoiseTask::" << __func__ << "]"
48  << " Destructing object...";
49 
50  // Have to delete pApvFactory_ manually even though we didn't create it
51  // ourself. :(
52  if (pApvFactory_) {
53  delete pApvFactory_;
54  }
55 }
static const char mlDqmSource_[]
ApvAnalysisFactory * pApvFactory_
Definition: NoiseTask.h:39
#define LogTrace(id)

Member Function Documentation

void NoiseTask::book ( )
overrideprivatevirtual

Reimplemented from CommissioningTask.

Definition at line 59 of file NoiseTask.cc.

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(), ApvAnalysisFactory::getApvAnalysis(), edm::EventSetup::getData(), CommissioningTask::HistoSet::histo(), ApvAnalysisFactory::instantiateApvs(), CommissioningTask::HistoSet::isProfile_, sistrip::LLD_CHAN, LogTrace, sistrip::mlDqmSource_, sistrip::NOISE, sistrip::extrainfo::noise_, noiseToken_, pApvFactory_, sistrip::PEDESTALS, sistrip::extrainfo::pedestals_, pedestalToken_, peds_, RecoTauValidation_cfi::reference, AlCaHLTBitMon_QueryRunRegistry::string, SiStripHistoTitle::title(), runGCPTkAlMap::title, CommissioningTask::HistoSet::vNumOfEntries_, CommissioningTask::HistoSet::vSumOfContents_, and CommissioningTask::HistoSet::vSumOfSquares_.

59  {
60  LogTrace(mlDqmSource_) << "[NoiseTask::" << __func__ << "]";
61 
62  // CACHING
63  static std::unique_ptr<SiStripPedestals> pDBPedestals;
64  static std::unique_ptr<SiStripNoises> pDBNoises;
65 
66  const uint16_t nBINS = 256;
67 
68  {
69  // Pedestals
73  fedKey(),
75  connection().lldChannel(),
77  .title();
78 
79  HistoSet oHSet;
80  oHSet.isProfile_ = true;
81 
82  oHSet.vNumOfEntries_.resize(nBINS, 0);
83  oHSet.vSumOfContents_.resize(nBINS, 0);
84  oHSet.vSumOfSquares_.resize(nBINS, 0);
85 
86  oHSet.histo(dqm()->bookProfile(title, title, nBINS, -0.5, nBINS * 1. - 0.5, 1025, 0., 1025.));
87 
88  peds_.push_back(oHSet);
89  }
90 
91  {
92  // Corrected Noise
96  fedKey(),
98  connection().lldChannel(),
100  .title();
101 
102  HistoSet oHSet;
103  oHSet.isProfile_ = true;
104 
105  oHSet.vNumOfEntries_.resize(nBINS, 0);
106  oHSet.vSumOfContents_.resize(nBINS, 0);
107  oHSet.vSumOfSquares_.resize(nBINS, 0);
108 
109  oHSet.histo(dqm()->bookProfile(title, title, nBINS, -0.5, nBINS * 1. - 0.5, 1025, 0., 1025.));
110 
111  peds_.push_back(oHSet);
112  }
113 
114  const uint16_t nCM_BINS = 1024;
115  for (uint16_t nApv = 0; 2 > nApv; ++nApv) {
119  fedKey(),
120  sistrip::APV,
121  connection().i2cAddr(nApv),
123  .title();
124 
125  HistoSet oHSet;
126 
127  oHSet.isProfile_ = false;
128 
129  oHSet.vNumOfEntries_.resize(nCM_BINS, 0);
130 
131  oHSet.histo(dqm()->book1D(title, title, nCM_BINS, nCM_BINS / 2 * -1. - 0.5, nCM_BINS / 2 * 1. - 0.5));
132 
133  cm_.push_back(oHSet);
134  }
135 
136  // Initialize Apv
137  pApvFactory_->instantiateApvs(connection().detId(), connection().nApvs());
138 
139  // --[ RETRIEVE PEDESTALS FROM DB ]--
140  // Operation should be performed only once
141  if (!pDBPedestals.get()) {
142  LogTrace(mlDqmSource_) << "[NoiseTask::" << __func__ << "] "
143  << "Retrieving Pedestals from DB";
144 
145  // Directly retrieve Pedestals from EventSetup, and cache
146  pDBPedestals = std::make_unique<SiStripPedestals>(eventSetup()->getData(pedestalToken_));
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, and cache
159  pDBNoises = std::make_unique<SiStripNoises>(eventSetup()->getData(noiseToken_));
160 
161  LogTrace(mlDqmSource_) << "[NoiseTask::" << __func__ << "] "
162  << "Done Retrieving Noises from DB";
163  } // End retrieve Noises from DB
164 
165  // Get ApvAnalysis associated with given DetId
167 
168  SiStripPedestals::Range pedestalsRange(pDBPedestals->getRange(connection().detId()));
169  SiStripNoises::Range noisesRange(pDBNoises->getRange(connection().detId()));
170 
171  // Cache Apv Pair #
172  const uint16_t nAPV_PAIR = connection().apvPairNumber();
173 
174  for (uint16_t nLclApv = 0; 2 > nLclApv; ++nLclApv) {
175  // Retrieve pedestals and noises associated with given DetId/Apv
176  ApvAnalysis::PedestalType pedestals;
178  for (uint16_t nStrip = nAPV_PAIR * 256 + nLclApv * 128, nMaxStrip = nStrip + 128; nMaxStrip > nStrip; ++nStrip) {
179  pedestals.push_back(pDBPedestals->getPed(nStrip, pedestalsRange));
180  noises.push_back(pDBNoises->getNoise(nStrip, noisesRange));
181  }
182 
183  try {
184  // Checked access
185  ApvAnalysisFactory::ApvAnalysisVector::reference rApvAnalysis = apvAnalysisVector.at(nAPV_PAIR * 2 + nLclApv);
186 
187  rApvAnalysis->pedestalCalculator().setPedestals(pedestals);
188  rApvAnalysis->pedestalCalculator().setNoise(noises);
189 
190  /*
191  std::stringstream out;
192  LogTrace( mlDqmSource_)
193  << "[NoiseTask::" << __func__ << "] "
194  << "DetId|Apv# -> "
195  << connection().detId() << '|' << ( nAPV_PAIR * 2 + nLclApv)
196  << " Pedestals: "
197  << ( out << pedestals
198  << " Noises: " << noises, out.str());
199  */
200  } catch (std::out_of_range const &) {
201  // Hmm, didn't find appropriate Apv :((( -> VERY, VERY BAD
202  LogTrace(mlDqmSource_) << "[NoiseTask::" << __func__ << "] "
203  << "Could not set Pedestals/Noises for DetId|Apv# -> " << connection().detId() << '|'
204  << (nAPV_PAIR * 2 + nLclApv) << ". !!! POSSIBLE BUG !!!";
205  } // End Try block
206  } // End Local Apvs loop
207 }
static const char noise_[]
std::vector< float > PedestalType
Definition: ApvAnalysis.h:44
Utility class that holds histogram title.
const std::string & title() const
static const char mlDqmSource_[]
uint16_t apvPairNumber() const
edm::ESGetToken< SiStripPedestals, SiStripPedestalsRcd > pedestalToken_
Definition: NoiseTask.h:40
ApvAnalysisFactory * pApvFactory_
Definition: NoiseTask.h:39
std::pair< ContainerIterator, ContainerIterator > Range
#define LogTrace(id)
bool getData(T &iHolder) const
Definition: EventSetup.h:128
const uint32_t & detId() const
DQMStore *const dqm() const
bool instantiateApvs(uint32_t det_id, int numberOfApvs)
std::vector< HistoSet > cm_
Definition: NoiseTask.h:37
static const char commonMode_[]
std::vector< ApvAnalysis * > ApvAnalysisVector
std::vector< HistoSet > peds_
Definition: NoiseTask.h:36
static const char pedestals_[]
edm::ESGetToken< SiStripNoises, SiStripNoisesRcd > noiseToken_
Definition: NoiseTask.h:41
ApvAnalysisVector getApvAnalysis(const uint32_t nDET_ID)
const edm::EventSetup *const eventSetup() const
const uint32_t & fedKey() const
const FedChannelConnection & connection() const
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripNoises.h:47
void NoiseTask::fill ( const SiStripEventSummary rSummary,
const edm::DetSet< SiStripRawDigi > &  rDigis 
)
overrideprivatevirtual

Reimplemented from CommissioningTask.

Definition at line 211 of file NoiseTask.cc.

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

211  {
212  pApvFactory_->updatePair(connection().detId(), connection().apvPairNumber(), rDigis);
213 }
ApvAnalysisFactory * pApvFactory_
Definition: NoiseTask.h:39
void updatePair(uint32_t det_id, size_t apvPair, const edm::DetSet< SiStripRawDigi > &in)
const FedChannelConnection & connection() const
void NoiseTask::update ( )
overrideprivatevirtual

Reimplemented from CommissioningTask.

Definition at line 217 of file NoiseTask.cc.

References FedChannelConnection::apvPairNumber(), cm_, CommissioningTask::connection(), FedChannelConnection::detId(), extract(), ApvAnalysisFactory::getCommonMode(), ApvAnalysisFactory::getNoise(), ApvAnalysisFactory::getPedestal(), timingPdfMaker::histo, LogTrace, sistrip::mlDqmSource_, submitPVResolutionJobs::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().

217  {
218  static UpdateTProfile updateTProfile;
219 
220  TProfile *pedsProf = ExtractTObject<TProfile>().extract(peds_[0].histo());
221  TProfile *noiseProf = ExtractTObject<TProfile>().extract(peds_[1].histo());
222 
223  for (uint16_t nLclApv = 2 * connection().apvPairNumber(), nMaxLclApv = nLclApv + 2, nApv = 0; nMaxLclApv > nLclApv;
224  ++nLclApv, ++nApv) {
225  ApvAnalysis::PedestalType lclPedestals;
226  ApvAnalysis::PedestalType lclNoises;
227  ApvAnalysis::PedestalType lclCommonMode(pApvFactory_->getCommonMode(connection().detId(), nLclApv));
228 
229  pApvFactory_->getPedestal(connection().detId(), nLclApv, lclPedestals);
230  pApvFactory_->getNoise(connection().detId(), nLclApv, lclNoises);
231 
232  const uint16_t nSTART_BIN = 128 * (nLclApv % 2);
233 
234  for (uint16_t nBin = 0, nAbsBin = nSTART_BIN + nBin + 1; 128 > nBin; ++nBin, ++nAbsBin) {
235  updateTProfile.setBinContent(pedsProf, nAbsBin, 5, lclPedestals[nBin], lclNoises[nBin]);
236  updateTProfile.setBinContent(noiseProf, nAbsBin, 5, lclNoises[nBin], 0);
237  } // End loop over BINs
238 
239  // Samvel: Assume Once CM value is calculated per chip.
240  // In principle Chip can be divided into a several ranges. Then CM
241  // will be calculated per range. !!! UPDATE CODE THEN !!!
242  for (ApvAnalysis::PedestalType::const_iterator cmIterator = lclCommonMode.begin();
243  cmIterator != lclCommonMode.end();
244  ++cmIterator) {
245  //uint32_t nCM = static_cast<uint32_t>( *cmIterator);
246  //if( nCM >= 1024) nCM = 1023;
247  //updateHistoSet( cm_[nApv], nCM);
248  float nCM = static_cast<float>(*cmIterator);
249  updateHistoSet(cm_[nApv], nCM);
250  }
251 
252  std::stringstream out;
253  LogTrace(mlDqmSource_) << "[NoiseTask::" << __func__ << "] "
254  << "DET ID [" << connection().detId() << "] has Common Mode size " << lclCommonMode.size()
255  << " : " << (out << lclCommonMode, out.str());
256  } // End loop over Local Apvs
257 
258  updateHistoSet(cm_[0]);
259  updateHistoSet(cm_[1]);
260 }
std::vector< float > PedestalType
Definition: ApvAnalysis.h:44
void getPedestal(uint32_t det_id, int apvNumber, ApvAnalysis::PedestalType &peds)
void getNoise(uint32_t det_id, int apvNumber, ApvAnalysis::PedestalType &noise)
static const char mlDqmSource_[]
uint16_t apvPairNumber() const
ApvAnalysisFactory * pApvFactory_
Definition: NoiseTask.h:39
#define LogTrace(id)
void updateHistoSet(HistoSet &, const uint32_t &bin, const float &value)
const uint32_t & detId() const
std::vector< HistoSet > cm_
Definition: NoiseTask.h:37
static void setBinContent(TProfile *const profile, const uint32_t &bin, const double &entries, const double &mean, const double &spread)
void getCommonMode(uint32_t det_id, ApvAnalysis::PedestalType &tmp)
std::vector< HistoSet > peds_
Definition: NoiseTask.h:36
int extract(std::vector< int > *output, const std::string &dati)
const FedChannelConnection & connection() const

Member Data Documentation

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

Definition at line 37 of file NoiseTask.h.

Referenced by book(), and update().

edm::ESGetToken<SiStripNoises, SiStripNoisesRcd> NoiseTask::noiseToken_
private

Definition at line 41 of file NoiseTask.h.

Referenced by book().

ApvAnalysisFactory* NoiseTask::pApvFactory_
private

Definition at line 39 of file NoiseTask.h.

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

edm::ESGetToken<SiStripPedestals, SiStripPedestalsRcd> NoiseTask::pedestalToken_
private

Definition at line 40 of file NoiseTask.h.

Referenced by book().

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

Definition at line 36 of file NoiseTask.h.

Referenced by book(), and update().