CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 &)
 
virtual ~NoiseTask ()
 
- 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 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

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

Private Attributes

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

Additional Inherited Members

- 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 19 of file NoiseTask.h.

Constructor & Destructor Documentation

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

Definition at line 37 of file NoiseTask.cc.

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

39  : CommissioningTask( dqm, conn, "NoiseTask")
40 {
41  //@@ NOT GUARANTEED TO BE THREAD SAFE!
42  pApvFactory_ = edm::Service<ApvFactoryService>().operator->()->getApvFactory();
43 
45  << "[NoiseTask::" << __func__ << "]"
46  << " Constructing object...";
47 }
static const char mlDqmSource_[]
ApvAnalysisFactory * pApvFactory_
Definition: NoiseTask.h:34
#define LogTrace(id)
DQMStore *const dqm() const
NoiseTask::~NoiseTask ( )
virtual

Definition at line 51 of file NoiseTask.cc.

References LogTrace, sistrip::mlDqmSource_, and pApvFactory_.

52 {
54  << "[NoiseTask::" << __func__ << "]"
55  << " Destructing object...";
56 
57  // Have to delete pApvFactory_ manually even though we didn't create it
58  // ourself. :(
59  if( pApvFactory_) { delete pApvFactory_; }
60 }
static const char mlDqmSource_[]
ApvAnalysisFactory * pApvFactory_
Definition: NoiseTask.h:34
#define LogTrace(id)

Member Function Documentation

void NoiseTask::book ( )
privatevirtual

Reimplemented from CommissioningTask.

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

65 {
66  LogTrace( mlDqmSource_) << "[NoiseTask::" << __func__ << "]";
67 
68  // CACHING
69  static std::auto_ptr<SiStripPedestals> pDBPedestals;
70  static std::auto_ptr<SiStripNoises> pDBNoises;
71 
72  const uint16_t nBINS = 256;
73 
74  {
75  // Pedestals
79  fedKey(),
81  connection().lldChannel(),
83 
84  HistoSet oHSet;
85  oHSet.isProfile_ = true;
86 
87  oHSet.vNumOfEntries_.resize( nBINS, 0);
88  oHSet.vSumOfContents_.resize( nBINS, 0);
89  oHSet.vSumOfSquares_.resize( nBINS, 0);
90 
91  oHSet.histo( dqm()->bookProfile( title, title,
92  nBINS, -0.5, nBINS * 1. - 0.5,
93  1025, 0., 1025.) );
94 
95  peds_.push_back( oHSet);
96  }
97 
98  {
99  // Corrected Noise
103  fedKey(),
105  connection().lldChannel(),
107 
108  HistoSet oHSet;
109  oHSet.isProfile_ = true;
110 
111  oHSet.vNumOfEntries_.resize( nBINS, 0);
112  oHSet.vSumOfContents_.resize( nBINS, 0);
113  oHSet.vSumOfSquares_.resize( nBINS, 0);
114 
115  oHSet.histo( dqm()->bookProfile( title, title,
116  nBINS, -0.5, nBINS * 1. - 0.5,
117  1025, 0., 1025.) );
118 
119  peds_.push_back( oHSet);
120  }
121 
122  const uint16_t nCM_BINS = 1024;
123  for( uint16_t nApv = 0; 2 > nApv; ++nApv)
124  {
128  fedKey(),
129  sistrip::APV,
130  connection().i2cAddr( nApv),
132 
133  HistoSet oHSet;
134 
135  oHSet.isProfile_ = false;
136 
137  oHSet.vNumOfEntries_.resize( nCM_BINS, 0);
138 
139  oHSet.histo( dqm()->book1D( title, title,
140  nCM_BINS,
141  nCM_BINS/2 * -1. - 0.5,
142  nCM_BINS/2 * 1. - 0.5 ) );
143 
144  cm_.push_back( oHSet);
145  }
146 
147  // Initialize Apv
148  pApvFactory_->instantiateApvs( connection().detId(), connection().nApvs() );
149 
150  // --[ RETRIEVE PEDESTALS FROM DB ]--
151  // Operation should be performed only once
152  if( !pDBPedestals.get()) {
154  << "[NoiseTask::" << __func__ << "] "
155  << "Retrieving Pedestals from DB";
156 
157  // Directly retrieve Pedestals from EventSetup
159  eventSetup()->get<SiStripPedestalsRcd>().get( pedestals);
160 
161  // Cache Pedestals
162  pDBPedestals.reset( new SiStripPedestals( *pedestals) );
163 
165  << "[NoiseTask::" << __func__ << "] "
166  << "Done Retrieving Pedestals from DB";
167  } // End retrieve Pedestals from DB
168 
169  // --[ RETRIEVE NOISES FROM DB ]--
170  // Operation should be performed only once
171  if( !pDBNoises.get()) {
173  << "[NoiseTask::" << __func__ << "] "
174  << "Retrieving Noises from DB";
175 
176  // Directly retrieve Noises from EventSetup
178  eventSetup()->get<SiStripNoisesRcd>().get( noises);
179 
180  // Cache Pedestals
181  pDBNoises.reset( new SiStripNoises( *noises) );
182 
184  << "[NoiseTask::" << __func__ << "] "
185  << "Done Retrieving Noises from DB";
186  } // End retrieve Noises from DB
187 
188 
189  // Get ApvAnalysis associated with given DetId
191  apvAnalysisVector( pApvFactory_->getApvAnalysis( connection().detId()));
192 
193  SiStripPedestals::Range pedestalsRange(
194  pDBPedestals->getRange( connection().detId() ) );
195  SiStripNoises::Range noisesRange(
196  pDBNoises->getRange( connection().detId() ) );
197 
198  // Cache Apv Pair #
199  const uint16_t nAPV_PAIR = connection().apvPairNumber();
200 
201  for( uint16_t nLclApv = 0; 2 > nLclApv; ++nLclApv) {
202  // Retrieve pedestals and noises associated with given DetId/Apv
203  ApvAnalysis::PedestalType pedestals;
205  for( uint16_t nStrip = nAPV_PAIR * 256 + nLclApv * 128,
206  nMaxStrip = nStrip + 128;
207  nMaxStrip > nStrip;
208  ++nStrip)
209  {
210  pedestals.push_back( pDBPedestals->getPed( nStrip, pedestalsRange));
211  noises.push_back( pDBNoises->getNoise( nStrip, noisesRange));
212  }
213 
214  try {
215  // Checked access
217  apvAnalysisVector.at( nAPV_PAIR * 2 + nLclApv);
218 
219  rApvAnalysis->pedestalCalculator().setPedestals( pedestals);
220  rApvAnalysis->pedestalCalculator().setNoise( noises);
221 
222  /*
223  std::stringstream out;
224  LogTrace( mlDqmSource_)
225  << "[NoiseTask::" << __func__ << "] "
226  << "DetId|Apv# -> "
227  << connection().detId() << '|' << ( nAPV_PAIR * 2 + nLclApv)
228  << " Pedestals: "
229  << ( out << pedestals
230  << " Noises: " << noises, out.str());
231  */
232  } catch( std::out_of_range) {
233  // Hmm, didn't find appropriate Apv :((( -> VERY, VERY BAD
235  << "[NoiseTask::" << __func__ << "] "
236  << "Could not set Pedestals/Noises for DetId|Apv# -> "
237  << connection().detId() << '|' << ( nAPV_PAIR * 2 + nLclApv)
238  << ". !!! POSSIBLE BUG !!!";
239  } // End Try block
240  } // End Local Apvs loop
241 }
static const char noise_[]
std::vector< float > PedestalType
Definition: ApvAnalysis.h:48
Utility class that holds histogram title.
const std::string & title() const
static const char mlDqmSource_[]
uint16_t apvPairNumber() const
ApvAnalysisFactory * pApvFactory_
Definition: NoiseTask.h:34
std::pair< ContainerIterator, ContainerIterator > Range
const uint32_t & detId() const
bool instantiateApvs(uint32_t det_id, int numberOfApvs)
std::vector< HistoSet > cm_
Definition: NoiseTask.h:32
static const char commonMode_[]
#define LogTrace(id)
std::vector< HistoSet > peds_
Definition: NoiseTask.h:31
static const char pedestals_[]
DQMStore *const dqm() const
const T & get() const
Definition: EventSetup.h:55
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:48
std::vector< ApvAnalysis * > ApvAnalysisVector
void NoiseTask::fill ( const SiStripEventSummary rSummary,
const edm::DetSet< SiStripRawDigi > &  rDigis 
)
privatevirtual

Reimplemented from CommissioningTask.

Definition at line 245 of file NoiseTask.cc.

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

247 {
248  pApvFactory_->updatePair( connection().detId(),
249  connection().apvPairNumber(),
250  rDigis);
251 }
ApvAnalysisFactory * pApvFactory_
Definition: NoiseTask.h:34
void updatePair(uint32_t det_id, size_t apvPair, const edm::DetSet< SiStripRawDigi > &in)
const FedChannelConnection & connection() const
void NoiseTask::update ( )
privatevirtual

Reimplemented from CommissioningTask.

Definition at line 255 of file NoiseTask.cc.

References FedChannelConnection::apvPairNumber(), cm_, CommissioningTask::connection(), FedChannelConnection::detId(), extract(), ApvAnalysisFactory::getCommonMode(), ApvAnalysisFactory::getNoise(), ApvAnalysisFactory::getPedestal(), timingPdfMaker::histo, LogTrace, sistrip::mlDqmSource_, dbtoconf::out, pApvFactory_, peds_, UpdateTProfile::setBinContent(), and CommissioningTask::updateHistoSet().

Referenced by progressbar.ProgressBar::__next__(), relval_steps.Matrix::__setitem__(), relval_steps.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(), 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(), relval_steps.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().

256 {
257  static UpdateTProfile updateTProfile;
258 
259  TProfile *pedsProf = ExtractTObject<TProfile>().extract( peds_[0].histo() );
260  TProfile *noiseProf = ExtractTObject<TProfile>().extract( peds_[1].histo() );
261 
262  for( uint16_t nLclApv = 2 * connection().apvPairNumber(),
263  nMaxLclApv = nLclApv + 2,
264  nApv = 0;
265  nMaxLclApv > nLclApv;
266  ++nLclApv, ++nApv)
267  {
268  ApvAnalysis::PedestalType lclPedestals;
269  ApvAnalysis::PedestalType lclNoises;
270  ApvAnalysis::PedestalType lclCommonMode(
271  pApvFactory_->getCommonMode( connection().detId(), nLclApv) );
272 
273  pApvFactory_->getPedestal ( connection().detId(), nLclApv, lclPedestals);
274  pApvFactory_->getNoise ( connection().detId(), nLclApv, lclNoises );
275 
276  const uint16_t nSTART_BIN = 128 * ( nLclApv % 2);
277 
278  for( uint16_t nBin = 0,
279  nAbsBin = nSTART_BIN + nBin + 1;
280  128 > nBin;
281  ++nBin, ++nAbsBin)
282  {
283  updateTProfile.setBinContent( pedsProf, nAbsBin, 5,
284  lclPedestals[nBin], lclNoises[nBin]);
285  updateTProfile.setBinContent( noiseProf, nAbsBin, 5,
286  lclNoises[nBin], 0);
287  } // End loop over BINs
288 
289  // Samvel: Assume Once CM value is calculated per chip.
290  // In principle Chip can be divided into a several ranges. Then CM
291  // will be calculated per range. !!! UPDATE CODE THEN !!!
292  for( ApvAnalysis::PedestalType::const_iterator cmIterator
293  = lclCommonMode.begin();
294  cmIterator != lclCommonMode.end();
295  ++cmIterator)
296  {
297  //uint32_t nCM = static_cast<uint32_t>( *cmIterator);
298  //if( nCM >= 1024) nCM = 1023;
299  //updateHistoSet( cm_[nApv], nCM);
300  float nCM = static_cast<float>( *cmIterator );
301  updateHistoSet( cm_[nApv], nCM );
302  }
303 
304  std::stringstream out;
306  << "[NoiseTask::" << __func__ << "] "
307  << "DET ID [" << connection().detId()
308  << "] has Common Mode size " << lclCommonMode.size() << " : "
309  << ( out << lclCommonMode, out.str());
310  } // End loop over Local Apvs
311 
312  updateHistoSet( cm_[0]);
313  updateHistoSet( cm_[1]);
314 }
std::vector< float > PedestalType
Definition: ApvAnalysis.h:48
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:34
void updateHistoSet(HistoSet &, const uint32_t &bin, const float &value)
const uint32_t & detId() const
std::vector< HistoSet > cm_
Definition: NoiseTask.h:32
static void setBinContent(TProfile *const profile, const uint32_t &bin, const double &entries, const double &mean, const double &spread)
#define LogTrace(id)
void getCommonMode(uint32_t det_id, ApvAnalysis::PedestalType &tmp)
std::vector< HistoSet > peds_
Definition: NoiseTask.h:31
int extract(std::vector< int > *output, const std::string &dati)
tuple out
Definition: dbtoconf.py:99
const FedChannelConnection & connection() const

Member Data Documentation

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

Definition at line 32 of file NoiseTask.h.

Referenced by book(), and update().

ApvAnalysisFactory* NoiseTask::pApvFactory_
private

Definition at line 34 of file NoiseTask.h.

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

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

Definition at line 31 of file NoiseTask.h.

Referenced by book(), and update().