CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

PedestalsTask Class Reference

#include <PedestalsTask.h>

Inheritance diagram for PedestalsTask:
CommissioningTask

List of all members.

Public Member Functions

 PedestalsTask (DQMStore *, const FedChannelConnection &)
virtual ~PedestalsTask ()

Private Member Functions

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

Private Attributes

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

Detailed Description

Definition at line 10 of file PedestalsTask.h.


Constructor & Destructor Documentation

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

Definition at line 15 of file PedestalsTask.cc.

References LogTrace, and sistrip::mlDqmSource_.

                                                                       :
  CommissioningTask( dqm, conn, "PedestalsTask" ),
  peds_(),
  cm_()
{
  LogTrace(mlDqmSource_)
    << "[PedestalsTask::" << __func__ << "]"
    << " Constructing object...";
}
PedestalsTask::~PedestalsTask ( ) [virtual]

Definition at line 28 of file PedestalsTask.cc.

References LogTrace, and sistrip::mlDqmSource_.

                              {
  LogTrace(mlDqmSource_)
    << "[PedestalsTask::" << __func__ << "]"
    << " Destructing object...";
}

Member Function Documentation

void PedestalsTask::book ( ) [private, virtual]

Reimplemented from CommissioningTask.

Definition at line 36 of file PedestalsTask.cc.

References sistrip::APV, cm_, sistrip::extrainfo::commonMode_, CommissioningTask::connection(), CommissioningTask::dqm(), sistrip::EXPERT_HISTO, sistrip::FED_KEY, CommissioningTask::fedKey(), sistrip::LLD_CHAN, LogTrace, sistrip::mlDqmSource_, pileupCalc::nbins, sistrip::extrainfo::noise_, sistrip::PEDESTALS, sistrip::extrainfo::pedestals_, peds_, SiStripHistoTitle::title(), and indexGen::title.

                         {
  LogTrace(mlDqmSource_) << "[PedestalsTask::" << __func__ << "]";
  
  uint16_t nbins;
  std::string title;
  std::string extra_info;
  peds_.resize(2);
  nbins = 256;
  
  // Pedestals histogram
  extra_info = sistrip::extrainfo::pedestals_; 
  peds_[0].isProfile_ = true;
  
  title = SiStripHistoTitle( sistrip::EXPERT_HISTO, 
                             sistrip::PEDESTALS, 
                             sistrip::FED_KEY, 
                             fedKey(),
                             sistrip::LLD_CHAN, 
                             connection().lldChannel(),
                             extra_info ).title();
  
  peds_[0].histo( dqm()->bookProfile( title, title, 
                                      nbins, -0.5, nbins*1.-0.5,
                                      1025, 0., 1025. ) );
  
  peds_[0].vNumOfEntries_.resize(nbins,0);
  peds_[0].vSumOfContents_.resize(nbins,0);
  peds_[0].vSumOfSquares_.resize(nbins,0);

  // Noise histogram
  extra_info = sistrip::extrainfo::noise_; 
  peds_[1].isProfile_ = true;
  
  title = SiStripHistoTitle( sistrip::EXPERT_HISTO, 
                             sistrip::PEDESTALS, 
                             sistrip::FED_KEY, 
                             fedKey(),
                             sistrip::LLD_CHAN, 
                             connection().lldChannel(),
                             extra_info ).title();
  
  peds_[1].histo( dqm()->bookProfile( title, title, 
                                      nbins, -0.5, nbins*1.-0.5,
                                      1025, 0., 1025. ) );
  
  peds_[1].vNumOfEntries_.resize(nbins,0);
  peds_[1].vSumOfContents_.resize(nbins,0);
  peds_[1].vSumOfSquares_.resize(nbins,0);

  // Common mode histograms
  cm_.resize(2);
  nbins = 1024;
  for ( uint16_t iapv = 0; iapv < 2; iapv++ ) { 
    
    title = SiStripHistoTitle( sistrip::EXPERT_HISTO, 
                               sistrip::PEDESTALS, 
                               sistrip::FED_KEY, 
                               fedKey(),
                               sistrip::APV, 
                               connection().i2cAddr(iapv),
                               sistrip::extrainfo::commonMode_ ).title();
    
    cm_[iapv].histo( dqm()->book1D( title, title, nbins, -0.5, nbins*1.-0.5 ) );
    cm_[iapv].isProfile_ = false;
    
    cm_[iapv].vNumOfEntries_.resize(nbins,0);
    cm_[iapv].vNumOfEntries_.resize(nbins,0);
    
  }
  
}
void PedestalsTask::fill ( const SiStripEventSummary summary,
const edm::DetSet< SiStripRawDigi > &  digis 
) [private, virtual]

Reimplemented from CommissioningTask.

Definition at line 110 of file PedestalsTask.cc.

References ecalMGPA::adc(), cm_, edm::DetSet< T >::data, diffTreeTool::diff, getHLTprescales::index, sistrip::mlDqmSource_, pileupCalc::nbins, peds_, python::multivaluedict::sort(), and CommissioningTask::updateHistoSet().

                                                                   {
  
  if ( digis.data.size() != peds_[0].vNumOfEntries_.size() ) {
    edm::LogWarning(mlDqmSource_)
      << "[PedestalsTask::" << __func__ << "]"
      << " Unexpected number of digis: " 
      << digis.data.size(); 
    return;
  }
  
  // Check number of digis
  uint16_t nbins = peds_[0].vNumOfEntries_.size();
  if ( digis.data.size() < nbins ) { nbins = digis.data.size(); }

  //@@ Inefficient!!!
  uint16_t napvs = nbins / 128;
  std::vector<uint32_t> cm; cm.resize(napvs,0);
  
  // Calc common mode for both APVs
  std::vector<uint16_t> adc;
  for ( uint16_t iapv = 0; iapv < napvs; iapv++ ) { 
    adc.clear(); adc.reserve(128);
    for ( uint16_t ibin = 0; ibin < 128; ibin++ ) { 
      if ( (iapv*128)+ibin < nbins ) { 
        adc.push_back( digis.data[(iapv*128)+ibin].adc() );  //@@ VIRGIN RAW DATA (MUX, APV READOUT)
      }
    }
    sort( adc.begin(), adc.end() ); 
    uint16_t index = adc.size()%2 ? adc.size()/2 : adc.size()/2-1;
    if ( !adc.empty() ) { cm[iapv] = static_cast<uint32_t>( adc[index] ); }
  }
  
  for ( uint16_t ibin = 0; ibin < nbins; ibin++ ) {
    updateHistoSet( peds_[0], ibin, digis.data[ibin].adc() ); // peds and raw noise
    float diff = static_cast<float>( digis.data[ibin].adc() ) - static_cast<float>( cm[ibin/128] );
    updateHistoSet( peds_[1], ibin, diff ); // residuals and real noise
  }
  
  if ( cm.size() < cm_.size() ) {
    edm::LogWarning(mlDqmSource_)
      << "[PedestalsTask::" << __func__ << "]"
      << " Fewer CM values than expected: " << cm.size();
  }
  
  updateHistoSet( cm_[0], cm[0] );
  updateHistoSet( cm_[1], cm[1] );
  
}
void PedestalsTask::update ( void  ) [private, virtual]

Reimplemented from CommissioningTask.

Definition at line 162 of file PedestalsTask.cc.

References cm_, python::tagInventory::entries, error, extract(), timingPdfMaker::histo, timingPdfMaker::mean, peds_, UpdateTProfile::setBinContent(), mathSSE::sqrt(), and CommissioningTask::updateHistoSet().

                           {
  
  // Pedestals 
  updateHistoSet( peds_[0] );
  
  // Noise (cannot use HistoSet directly, as want to plot noise as "contents", not "error")
  TProfile* histo = ExtractTObject<TProfile>().extract( peds_[1].histo() );
  for ( uint16_t ii = 0; ii < peds_[1].vNumOfEntries_.size(); ++ii ) {
    
    float mean    = 0.;
    float spread  = 0.;
    float entries = peds_[1].vNumOfEntries_[ii];
    if ( entries > 0. ) {
      mean = peds_[1].vSumOfContents_[ii] / entries;
      spread = sqrt( peds_[1].vSumOfSquares_[ii] / entries - mean * mean ); 
    }
    
    float noise = spread;
    float error = 0; // sqrt(entries) / entries;
    
    UpdateTProfile::setBinContent( histo, ii+1, entries, noise, error );
    
  }
  
  // Common mode
  updateHistoSet( cm_[0] );
  updateHistoSet( cm_[1] );
  
}

Member Data Documentation

std::vector<HistoSet> PedestalsTask::cm_ [private]

Definition at line 25 of file PedestalsTask.h.

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

std::vector<HistoSet> PedestalsTask::peds_ [private]

Definition at line 24 of file PedestalsTask.h.

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