CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

PedsFullNoiseHistosUsingDb Class Reference

#include <PedsFullNoiseHistosUsingDb.h>

Inheritance diagram for PedsFullNoiseHistosUsingDb:
CommissioningHistosUsingDb PedsFullNoiseHistograms CommissioningHistograms CommissioningHistograms

List of all members.

Public Member Functions

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

Private Member Functions

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

Private Attributes

bool addBadStrips_
bool disableBadStrips_
float highThreshold_
bool keepStripsDisabled_
float lowThreshold_

Detailed Description

Definition at line 9 of file PedsFullNoiseHistosUsingDb.h.


Constructor & Destructor Documentation

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

Definition at line 15 of file PedsFullNoiseHistosUsingDb.cc.

References addBadStrips_, disableBadStrips_, edm::ParameterSet::getParameter(), highThreshold_, keepStripsDisabled_, LogTrace, lowThreshold_, sistrip::mlDqmClient_, and CommissioningHistograms::pset().

  : CommissioningHistograms( pset.getParameter<edm::ParameterSet>("PedsFullNoiseParameters"),
                             bei,
                             sistrip::PEDS_FULL_NOISE ),
    CommissioningHistosUsingDb( db,
                                sistrip::PEDS_FULL_NOISE ),
    PedsFullNoiseHistograms( pset.getParameter<edm::ParameterSet>("PedsFullNoiseParameters"),
                             bei )
{
    LogTrace(mlDqmClient_) 
    << "[PedsFullNoiseHistosUsingDb::" << __func__ << "]"
    << " Constructing object...";
  highThreshold_ = this->pset().getParameter<double>("HighThreshold");
  lowThreshold_ = this->pset().getParameter<double>("LowThreshold");
  LogTrace(mlDqmClient_)
    << "[PedsFullNoiseHistosUsingDb::" << __func__ << "]"
    << " Set FED zero suppression high/low threshold to "
    << highThreshold_ << "/" << lowThreshold_;
  disableBadStrips_ = this->pset().getParameter<bool>("DisableBadStrips");
  keepStripsDisabled_ = this->pset().getParameter<bool>("KeepStripsDisabled");
  addBadStrips_ = this->pset().getParameter<bool>("AddBadStrips");
  LogTrace(mlDqmClient_)
    << "[PedestalsHistosUsingDb::" << __func__ << "]"
    << " Disabling strips: " << disableBadStrips_
    << " ; keeping previously disabled strips: " << keepStripsDisabled_;
}
PedsFullNoiseHistosUsingDb::~PedsFullNoiseHistosUsingDb ( ) [virtual]

Definition at line 46 of file PedsFullNoiseHistosUsingDb.cc.

References LogTrace, and sistrip::mlDqmClient_.

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

Member Function Documentation

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

Reimplemented from CommissioningHistosUsingDb.

Definition at line 278 of file PedsFullNoiseHistosUsingDb.cc.

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

                                                             {

  PedsFullNoiseAnalysis* anal = dynamic_cast<PedsFullNoiseAnalysis*>( 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 PedsFullNoiseHistosUsingDb::update ( SiStripConfigDb::FedDescriptionsRange  feds) [private]

Definition at line 88 of file PedsFullNoiseHistosUsingDb.cc.

References addBadStrips_, sistrip::APVS_PER_FEDCH, CommissioningHistosUsingDb::cabling(), FedChannelConnection::ccuAddr(), FedChannelConnection::ccuChan(), results_mgr::conn, SiStripFedCabling::connection(), gather_cfg::cout, CommissioningHistograms::data(), PedsFullNoiseAnalysis::dead(), CommissioningHistosUsingDb::deviceIsPresent(), disableBadStrips_, FedChannelConnection::fecCrate(), SiStripFedKey::feChan(), FedChannelConnection::fecRing(), FedChannelConnection::fecSlot(), FedChannelConnection::fedCh(), sistrip::FEDCH_PER_FED, SiStripFedKey::fedChannel(), SiStripFedKey::fedId(), FedChannelConnection::fedId(), CommissioningAnalysis::fedKey(), SiStripFedKey::feUnit(), spr::find(), highThreshold_, sistrip::invalid_, edm::isDebugEnabled(), keepStripsDisabled_, SiStripKey::key(), FedChannelConnection::lldChannel(), LogTrace, lowThreshold_, sistrip::mlDqmClient_, PedsFullNoiseAnalysis::noise(), PedsFullNoiseAnalysis::noisy(), PedsFullNoiseAnalysis::peds(), PedsFullNoiseAnalysis::pedsMin(), and groupFilesInBlocks::temp.

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() ) {
      
        PedsFullNoiseAnalysis* anal = dynamic_cast<PedsFullNoiseAnalysis*>( iter->second );
        if ( !anal ) { 
          edm::LogError(mlDqmClient_)
            << "[PedsFullNoiseHistosUsingDb::" << __func__ << "]"
            << " NULL pointer to analysis object!";
          continue; 
        }

        // Determine the pedestal shift to apply
        uint32_t pedshift = 127;
        for ( uint16_t iapv = 0; iapv < sistrip::APVS_PER_FEDCH; iapv++ ) {
          uint32_t pedmin = (uint32_t) anal->pedsMin()[iapv];
          pedshift = pedmin < pedshift ? pedmin : pedshift;
        }

        // 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++ ) { 

            // get the information on the strip as it was on the db
            Fed9U::Fed9UAddress addr( ichan, iapv, istr );
            Fed9U::Fed9UStripDescription temp = (*ifed)->getFedStrips().getStrip( addr );
                                                if(temp.getDisable()) {
                std::cout<<"Already Disabled: "<<conn.fecCrate()
                                                        <<" "<<conn.fecSlot()
                                                        <<" "<<conn.fecRing()
                                                        <<" "<<conn.ccuAddr()
                                                        <<" "<<conn.ccuChan()
                                                        <<" "<<conn.lldChannel()
              <<" "<<iapv*128+istr<<std::endl;
            }
            // determine whether we need to disable the strip
            bool disableStrip = false;
            if ( addBadStrips_ ) {
              disableStrip = temp.getDisable();
              SiStripFedKey fed_key(anal->fedKey());              
              if(!disableStrip){
                PedsFullNoiseAnalysis::VInt dead = anal->dead()[iapv];
                if ( find( dead.begin(), dead.end(), istr ) != dead.end() ) {
                        disableStrip = true;
                  std::cout<<"Disabling Dead: "<<conn.fecCrate()
                                                                        <<" "<<conn.fecSlot()
                                                                        <<" "<<conn.fecRing()
                                                                        <<" "<<conn.ccuAddr()
                                                                        <<" "<<conn.ccuChan()
                                                                        <<" "<<conn.lldChannel()
                        <<" "<<iapv*128+istr<<std::endl;
                }
                PedsFullNoiseAnalysis::VInt noisy = anal->noisy()[iapv];
                if ( find( noisy.begin(), noisy.end(), istr ) != noisy.end() ) {
                        disableStrip = true;
                  std::cout<<"Disabling Noisy: "<<conn.fecCrate()
                                                                        <<" "<<conn.fecSlot()
                                                                        <<" "<<conn.fecRing()
                                                                        <<" "<<conn.ccuAddr()
                                                                        <<" "<<conn.ccuChan()
                                                                        <<" "<<conn.lldChannel()
                        <<" "<<iapv*128+istr<<std::endl;
                }
              }
            } else if ( keepStripsDisabled_ ) {
              disableStrip = temp.getDisable();
            } else if (disableBadStrips_) {
              PedsFullNoiseAnalysis::VInt dead = anal->dead()[iapv];
              if ( find( dead.begin(), dead.end(), istr ) != dead.end() ) {
                disableStrip = true;              
                std::cout<<"Disabling Dead: "<<conn.fecCrate()
                                                                <<" "<<conn.fecSlot()
                                                                <<" "<<conn.fecRing()
                                                                <<" "<<conn.ccuAddr()
                                                                <<" "<<conn.ccuChan()
                                                                <<" "<<conn.lldChannel()
                <<" "<<iapv*128+istr<<std::endl;
              }
              PedsFullNoiseAnalysis::VInt noisy = anal->noisy()[iapv];
              if ( find( noisy.begin(), noisy.end(), istr ) != noisy.end() ) {
                disableStrip = true;                
                std::cout<<"Disabling Noisy: "<<conn.fecCrate()
                                                                <<" "<<conn.fecSlot()
                                                                <<" "<<conn.fecRing()
                                                                <<" "<<conn.ccuAddr()
                                                                <<" "<<conn.ccuChan()
                                                                <<" "<<conn.lldChannel()
                <<" "<<iapv*128+istr<<std::endl;
              }
            }

            Fed9U::Fed9UStripDescription data( static_cast<uint32_t>( anal->peds()[iapv][istr]-pedshift ),
                                               highThreshold_,
                                               lowThreshold_,
                                               anal->noise()[iapv][istr],
                                               disableStrip );

            std::stringstream ss;
            if ( data.getDisable() && edm::isDebugEnabled() ) {
              ss << "[PedsFullNoiseHistosUsingDb::" << __func__ << "]"
                 << " Disabling strip in Fed9UStripDescription object..." << std::endl
                 << " for FED id/channel and APV/strip : "
                 << fed_key.fedId() << "/"
                 << fed_key.fedChannel() << " "
                 << iapv << "/"
                 << istr << std::endl 
                 << " and crate/FEC/ring/CCU/module    : "
                 << fec_key.fecCrate() << "/"
                 << fec_key.fecSlot() << "/"
                 << fec_key.fecRing() << "/"
                 << fec_key.ccuAddr() << "/"
                 << fec_key.ccuChan() << std::endl 
                 << " from ped/noise/high/low/disable  : "
                 << static_cast<uint16_t>( temp.getPedestal() ) << "/" 
                 << static_cast<uint16_t>( temp.getHighThreshold() ) << "/" 
                 << static_cast<uint16_t>( temp.getLowThreshold() ) << "/" 
                 << static_cast<uint16_t>( temp.getNoise() ) << "/" 
                 << static_cast<uint16_t>( temp.getDisable() ) << std::endl;
            }
            (*ifed)->getFedStrips().setStrip( addr, data );
            if ( data.getDisable() && edm::isDebugEnabled() ) {
              ss << " to ped/noise/high/low/disable    : "
                 << static_cast<uint16_t>( data.getPedestal() ) << "/" 
                 << static_cast<uint16_t>( data.getHighThreshold() ) << "/" 
                 << static_cast<uint16_t>( data.getLowThreshold() ) << "/" 
                 << static_cast<uint16_t>( data.getNoise() ) << "/" 
                 << static_cast<uint16_t>( data.getDisable() ) << std::endl;
              LogTrace(mlDqmClient_) << ss.str();
            }

          } // end loop on strips
        } // end loop on apvs
        updated++;

      } else {
        if ( deviceIsPresent(fec_key) ) {
          edm::LogWarning(mlDqmClient_) 
            << "[PedsFullNoiseHistosUsingDb::" << __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_) 
    << "[PedsFullNoiseHistosUsingDb::" << __func__ << "]"
    << " Updated FED pedestals/noise for " 
    << updated << " channels";
}
void PedsFullNoiseHistosUsingDb::uploadConfigurations ( ) [virtual]

Reimplemented from CommissioningHistosUsingDb.

Definition at line 54 of file PedsFullNoiseHistosUsingDb.cc.

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

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

  if ( !db() ) {
    edm::LogError(mlDqmClient_) 
      << "[PedsFullNoiseHistosUsingDb::" << __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_) 
      << "[PedsFullNoiseHistosUsingDb::" << __func__ << "]"
      << " Uploading pedestals/noise to DB...";
    db()->uploadFedDescriptions();
    edm::LogVerbatim(mlDqmClient_) 
      << "[PedsFullNoiseHistosUsingDb::" << __func__ << "]"
      << " Completed database upload of " << feds.size() 
      << " FED descriptions!";
  } else {
    edm::LogWarning(mlDqmClient_) 
      << "[PedsFullNoiseHistosUsingDb::" << __func__ << "]"
      << " TEST! No pedestals/noise values will be uploaded to DB...";
  }
  
}

Member Data Documentation

Definition at line 32 of file PedsFullNoiseHistosUsingDb.h.

Referenced by PedsFullNoiseHistosUsingDb(), and update().

Definition at line 30 of file PedsFullNoiseHistosUsingDb.h.

Referenced by PedsFullNoiseHistosUsingDb(), and update().

Definition at line 28 of file PedsFullNoiseHistosUsingDb.h.

Referenced by PedsFullNoiseHistosUsingDb(), and update().

Definition at line 31 of file PedsFullNoiseHistosUsingDb.h.

Referenced by PedsFullNoiseHistosUsingDb(), and update().

Definition at line 29 of file PedsFullNoiseHistosUsingDb.h.

Referenced by PedsFullNoiseHistosUsingDb(), and update().