CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/DQM/SiStripCommissioningSources/src/VpspScanTask.cc

Go to the documentation of this file.
00001 #include "DQM/SiStripCommissioningSources/interface/VpspScanTask.h"
00002 #include "DataFormats/SiStripCommon/interface/SiStripConstants.h"
00003 #include "DataFormats/SiStripCommon/interface/SiStripFecKey.h"
00004 #include "DataFormats/SiStripCommon/interface/SiStripHistoTitle.h"
00005 #include "DQMServices/Core/interface/DQMStore.h"
00006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00007 #include <algorithm>
00008 
00009 using namespace sistrip;
00010 
00011 // -----------------------------------------------------------------------------
00012 //
00013 VpspScanTask::VpspScanTask( DQMStore* dqm,
00014                             const FedChannelConnection& conn ) :
00015   CommissioningTask( dqm, conn, "VpspScanTask" ),
00016   vpsp_()
00017 {}
00018 
00019 // -----------------------------------------------------------------------------
00020 //
00021 VpspScanTask::~VpspScanTask() {
00022 }
00023 
00024 // -----------------------------------------------------------------------------
00025 //
00026 void VpspScanTask::book() {
00027   
00028   uint16_t nbins = 60;
00029  
00030   std::string title;
00031 
00032   vpsp_.resize(2);
00033   for ( uint16_t iapv = 0; iapv < 2; iapv++ ) {
00034     if ( connection().i2cAddr(iapv) ) { 
00035 
00036       std::stringstream extra_info; 
00037       extra_info << sistrip::apv_ << iapv;
00038       
00039       title = SiStripHistoTitle( sistrip::EXPERT_HISTO, 
00040                                  sistrip::VPSP_SCAN, 
00041                                  sistrip::FED_KEY, 
00042                                  fedKey(),
00043                                  sistrip::LLD_CHAN, 
00044                                  connection().lldChannel(),
00045                                  extra_info.str() ).title();
00046       
00047       vpsp_[iapv].histo( dqm()->bookProfile( title, title, 
00048                                              nbins, -0.5, nbins*1.-0.5,
00049                                              1025, 0., 1025. ) );
00050       
00051       vpsp_[iapv].vNumOfEntries_.resize(nbins,0);
00052       vpsp_[iapv].vSumOfContents_.resize(nbins,0);
00053       vpsp_[iapv].vSumOfSquares_.resize(nbins,0);
00054       
00055     }
00056   }
00057   
00058 }
00059 
00060 // -----------------------------------------------------------------------------
00061 //
00062 void VpspScanTask::fill( const SiStripEventSummary& summary,
00063                          const edm::DetSet<SiStripRawDigi>& digis ) {
00064 
00065   // Retrieve VPSP setting and CCU channel
00066   uint32_t vpsp = const_cast<SiStripEventSummary&>(summary).vpsp();
00067   uint32_t ccu_chan = const_cast<SiStripEventSummary&>(summary).vpspCcuChan();
00068 
00069   // Check CCU channel from EventSummary is consistent with this module
00070   if ( SiStripFecKey( fecKey() ).ccuChan() != ccu_chan ) { return; }
00071 
00072   if ( digis.data.size() != 256 ) {
00073     edm::LogWarning(mlDqmSource_)
00074       << "[VpspScanTask::" << __func__ << "]"
00075       << " Unexpected number of digis! " 
00076       << digis.data.size(); 
00077     return;
00078   }
00079 
00080   // Fill histo with baseline(calc'ed from median value of data)
00081   for ( uint16_t iapv = 0; iapv < 2; iapv++ ) {
00082     
00083     if ( vpsp >= vpsp_[iapv].vNumOfEntries_.size() ) { 
00084       edm::LogWarning(mlDqmSource_)
00085         << "[VpspScanTask::" << __func__ << "]"
00086         << " Unexpected VPSP value! " << vpsp;
00087       return;
00088     }
00089     
00090     std::vector<uint16_t> baseline;
00091     baseline.reserve(128); 
00092     for ( uint16_t idigi = 128*iapv; idigi < 128*(iapv+1); idigi++ ) {
00093       baseline.push_back( digis.data[idigi].adc() ); 
00094     }
00095     sort( baseline.begin(), baseline.end() ); 
00096     uint16_t index = baseline.size()%2 ? baseline.size()/2 : baseline.size()/2-1;
00097     
00098     if ( !baseline.empty() ) { 
00099       updateHistoSet( vpsp_[iapv], vpsp, baseline[index] );
00100     }
00101     
00102   }
00103 
00104 }
00105 
00106 // -----------------------------------------------------------------------------
00107 //
00108 void VpspScanTask::update() {
00109   for ( uint32_t iapv = 0; iapv < vpsp_.size(); iapv++ ) {
00110     updateHistoSet( vpsp_[iapv] );
00111   }
00112 }
00113 
00114