CMS 3D CMS Logo

Public Member Functions | Private Member Functions

NoiseHistosUsingDb Class Reference

#include <NoiseHistosUsingDb.h>

Inheritance diagram for NoiseHistosUsingDb:
CommissioningHistosUsingDb NoiseHistograms CommissioningHistograms CommissioningHistograms

List of all members.

Public Member Functions

 NoiseHistosUsingDb (const edm::ParameterSet &pset, DQMStore *, SiStripConfigDb *const )
virtual void uploadConfigurations ()
virtual ~NoiseHistosUsingDb ()

Private Member Functions

void create (SiStripConfigDb::AnalysisDescriptionsV &, Analysis)
void update (SiStripConfigDb::FedDescriptionsRange)

Detailed Description

Definition at line 9 of file NoiseHistosUsingDb.h.


Constructor & Destructor Documentation

NoiseHistosUsingDb::NoiseHistosUsingDb ( const edm::ParameterSet pset,
DQMStore bei,
SiStripConfigDb * const  db 
)

Definition at line 15 of file NoiseHistosUsingDb.cc.

References LogTrace, and sistrip::mlDqmClient_.

  : CommissioningHistograms( pset.getParameter<edm::ParameterSet>("NoiseParameters"),
                             bei,
                             sistrip::NOISE ),
    CommissioningHistosUsingDb( db,
                                sistrip::NOISE ),
    NoiseHistograms( pset.getParameter<edm::ParameterSet>("NoiseParameters"),
                     bei )
{
  LogTrace(mlDqmClient_) 
    << "[NoiseHistosUsingDb::" << __func__ << "]"
    << " Constructing object...";
}
NoiseHistosUsingDb::~NoiseHistosUsingDb ( ) [virtual]

Definition at line 33 of file NoiseHistosUsingDb.cc.

References LogTrace, and sistrip::mlDqmClient_.

                                        {
  LogTrace(mlDqmClient_) 
    << "[NoiseHistosUsingDb::" << __func__ << "]"
    << " Destructing object...";
}

Member Function Documentation

void NoiseHistosUsingDb::create ( SiStripConfigDb::AnalysisDescriptionsV desc,
Analysis  analysis 
) [private, virtual]

Reimplemented from CommissioningHistosUsingDb.

Definition at line 163 of file NoiseHistosUsingDb.cc.

References CommissioningHistosUsingDb::db(), SiStripConfigDb::dbParams(), NoiseAnalysis::dead(), benchmark_cfg::errors, CommissioningAnalysis::fecKey(), CommissioningAnalysis::fedKey(), CommissioningAnalysis::getErrorCodes(), SiStripFecKey::i2cAddr(), NoiseAnalysis::isValid(), NoiseAnalysis::noiseMax(), NoiseAnalysis::noiseMean(), NoiseAnalysis::noiseMin(), NoiseAnalysis::noiseSpread(), NoiseAnalysis::noisy(), SiStripDbParams::partitions(), NoiseAnalysis::pedsMax(), NoiseAnalysis::pedsMean(), NoiseAnalysis::pedsMin(), NoiseAnalysis::pedsSpread(), NoiseAnalysis::rawMax(), NoiseAnalysis::rawMean(), NoiseAnalysis::rawMin(), NoiseAnalysis::rawSpread(), and tmp.

                                                     {

  NoiseAnalysis* anal = dynamic_cast<NoiseAnalysis*>( analysis->second );
  if ( !anal ) { return; }
  
  SiStripFecKey fec_key( anal->fecKey() );
  SiStripFedKey fed_key( anal->fedKey() );
  
  for ( uint16_t iapv = 0; iapv < 2; ++iapv ) {
    
    // Create description
    PedestalsAnalysisDescription* tmp;
    tmp = new PedestalsAnalysisDescription( anal->dead()[iapv],
                                            anal->noisy()[iapv],
                                            anal->pedsMean()[iapv],
                                            anal->pedsSpread()[iapv],
                                            anal->noiseMean()[iapv],
                                            anal->noiseSpread()[iapv],
                                            anal->rawMean()[iapv],
                                            anal->rawSpread()[iapv],
                                            anal->pedsMax()[iapv], 
                                            anal->pedsMin()[iapv], 
                                            anal->noiseMax()[iapv],
                                            anal->noiseMin()[iapv],
                                            anal->rawMax()[iapv],
                                            anal->rawMin()[iapv],
                                            fec_key.fecCrate(),
                                            fec_key.fecSlot(),
                                            fec_key.fecRing(),
                                            fec_key.ccuAddr(),
                                            fec_key.ccuChan(),
                                            SiStripFecKey::i2cAddr( fec_key.lldChan(), !iapv ), 
                                            db()->dbParams().partitions().begin()->second.partitionName(),
                                            db()->dbParams().partitions().begin()->second.runNumber(),
                                            anal->isValid(),
                                            "",
                                            fed_key.fedId(),
                                            fed_key.feUnit(),
                                            fed_key.feChan(),
                                            fed_key.fedApv() );
    
    // Add comments
    typedef std::vector<std::string> Strings;
    Strings errors = anal->getErrorCodes();
    Strings::const_iterator istr = errors.begin();
    Strings::const_iterator jstr = errors.end();
    for ( ; istr != jstr; ++istr ) { tmp->addComments( *istr ); }

    // Store description
    desc.push_back( tmp );
      
  }

}
void NoiseHistosUsingDb::update ( SiStripConfigDb::FedDescriptionsRange  feds) [private]

Definition at line 75 of file NoiseHistosUsingDb.cc.

References sistrip::APVS_PER_FEDCH, CommissioningHistosUsingDb::cabling(), FedChannelConnection::ccuAddr(), FedChannelConnection::ccuChan(), results_mgr::conn, SiStripFedCabling::connection(), CommissioningHistograms::data(), FedChannelConnection::fecCrate(), SiStripFedKey::feChan(), FedChannelConnection::fecRing(), FedChannelConnection::fecSlot(), FedChannelConnection::fedCh(), sistrip::FEDCH_PER_FED, FedChannelConnection::fedId(), SiStripFedKey::feUnit(), sistrip::invalid_, SiStripKey::key(), FedChannelConnection::lldChannel(), sistrip::mlDqmClient_, NoiseAnalysis::noise(), and NoiseAnalysis::peds().

Referenced by uploadConfigurations().

                                                                          {
 
  // Iterate through feds and update fed descriptions
  uint16_t updated = 0;
  SiStripConfigDb::FedDescriptionsV::const_iterator ifed;
  for ( ifed = feds.begin(); ifed != feds.end(); ifed++ ) {
    
    for ( uint16_t ichan = 0; ichan < sistrip::FEDCH_PER_FED; ichan++ ) {

      // Build FED and FEC keys
      const FedChannelConnection& conn = cabling()->connection( (*ifed)->getFedId(), ichan );
      if ( conn.fecCrate() == sistrip::invalid_ ||
           conn.fecSlot() == sistrip::invalid_ ||
           conn.fecRing() == sistrip::invalid_ ||
           conn.ccuAddr() == sistrip::invalid_ ||
           conn.ccuChan() == sistrip::invalid_ ||
           conn.lldChannel() == sistrip::invalid_ ) { continue; }
      SiStripFedKey fed_key( conn.fedId(), 
                             SiStripFedKey::feUnit( conn.fedCh() ),
                             SiStripFedKey::feChan( conn.fedCh() ) );
      SiStripFecKey fec_key( conn.fecCrate(), 
                             conn.fecSlot(), 
                             conn.fecRing(), 
                             conn.ccuAddr(), 
                             conn.ccuChan(), 
                             conn.lldChannel() );

      // Locate appropriate analysis object 
      Analyses::const_iterator iter = data().find( fec_key.key() );
      if ( iter != data().end() ) {

        // Check if analysis is valid
        if ( !iter->second->isValid() ) { continue; }
        
        NoiseAnalysis* anal = dynamic_cast<NoiseAnalysis*>( iter->second );
        if ( !anal ) { 
          edm::LogError(mlDqmClient_)
            << "[NoiseHistosUsingDb::" << __func__ << "]"
            << " NULL pointer to analysis object!";
          continue; 
        }
        
        // Iterate through APVs and strips
        for ( uint16_t iapv = 0; iapv < sistrip::APVS_PER_FEDCH; iapv++ ) {
          for ( uint16_t istr = 0; istr < anal->peds()[iapv].size(); istr++ ) { 
            
            static float high_threshold = 5.;
            static float low_threshold  = 2.;
            static bool  disable_strip  = false;
            Fed9U::Fed9UStripDescription data( static_cast<uint32_t>( anal->peds()[iapv][istr] ), 
                                               high_threshold, 
                                               low_threshold, 
                                               anal->noise()[iapv][istr],
                                               disable_strip );
            Fed9U::Fed9UAddress addr( ichan, iapv, istr );
            (*ifed)->getFedStrips().setStrip( addr, data );
            
          }
        }
        updated++;
      
      } else {
        edm::LogWarning(mlDqmClient_) 
          << "[NoiseHistosUsingDb::" << __func__ << "]"
          << " Unable to find pedestals/noise for FedKey/Id/Ch: " 
          << hex << setw(8) << setfill('0') << fed_key.key() << dec << "/"
          << (*ifed)->getFedId() << "/"
          << ichan
          << " and device with FEC/slot/ring/CCU/LLD " 
          << fec_key.fecCrate() << "/"
          << fec_key.fecSlot() << "/"
          << fec_key.fecRing() << "/"
          << fec_key.ccuAddr() << "/"
          << fec_key.ccuChan() << "/"
          << fec_key.channel();
      }
    }
  }

  edm::LogVerbatim(mlDqmClient_) 
    << "[NoiseHistosUsingDb::" << __func__ << "]"
    << " Updated FED pedestals/noise for " 
    << updated << " channels";

}
void NoiseHistosUsingDb::uploadConfigurations ( ) [virtual]

Reimplemented from CommissioningHistosUsingDb.

Definition at line 41 of file NoiseHistosUsingDb.cc.

References CommissioningHistosUsingDb::db(), CommissioningHistosUsingDb::doUploadConf(), SiStripConfigDb::getFedDescriptions(), LogTrace, sistrip::mlDqmClient_, update(), and SiStripConfigDb::uploadFedDescriptions().

                                              {
  LogTrace(mlDqmClient_) 
    << "[NoiseHistosUsingDb::" << __func__ << "]";

  if ( !db() ) {
    edm::LogError(mlDqmClient_) 
      << "[NoiseHistosUsingDb::" << __func__ << "]"
      << " NULL pointer to SiStripConfigDb interface!"
      << " Aborting upload...";
    return;
  }
  
  // Update FED descriptions with new peds/noise values
  SiStripConfigDb::FedDescriptionsRange feds = db()->getFedDescriptions(); 
  update( feds );
  if ( doUploadConf() ) { 
    edm::LogVerbatim(mlDqmClient_) 
      << "[NoiseHistosUsingDb::" << __func__ << "]"
      << " Uploading pedestals/noise to DB...";
    db()->uploadFedDescriptions();
    edm::LogVerbatim(mlDqmClient_) 
      << "[NoiseHistosUsingDb::" << __func__ << "]"
      << " Completed database upload of " << feds.size() 
      << " FED descriptions!";
  } else {
    edm::LogWarning(mlDqmClient_) 
      << "[NoiseHistosUsingDb::" << __func__ << "]"
      << " TEST only! No pedestals/noise values will be uploaded to DB...";
  }
  
}