CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/DQM/SiStripCommissioningSources/src/PedsOnlyTask.cc

Go to the documentation of this file.
00001 #include "CalibTracker/SiStripAPVAnalysis/interface/ApvAnalysisFactory.h"
00002 #include "CalibTracker/SiStripAPVAnalysis/interface/ApvFactoryService.h"
00003 #include "DataFormats/SiStripCommon/interface/SiStripConstants.h"
00004 #include "DataFormats/SiStripCommon/interface/SiStripHistoTitle.h"
00005 #include "DQM/SiStripCommon/interface/ExtractTObject.h"
00006 #include "DQM/SiStripCommon/interface/UpdateTProfile.h"
00007 #include "DQMServices/Core/interface/DQMStore.h"
00008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00009 #include "FWCore/ServiceRegistry/interface/Service.h"
00010 
00011 #include "DQM/SiStripCommissioningSources/interface/PedsOnlyTask.h"
00012 
00013 using namespace sistrip;
00014 
00015 // -----------------------------------------------------------------------------
00016 //
00017 PedsOnlyTask::PedsOnlyTask( DQMStore *dqm,
00018                             const FedChannelConnection &rCONN)
00019   : CommissioningTask( dqm, rCONN, "PedsOnlyTask")
00020 {
00021   //@@ NOT GUARANTEED TO BE THREAD SAFE! 
00022   pApvFactory_ = edm::Service<ApvFactoryService>().operator->()->getApvFactory();
00023                                
00024   LogTrace( mlDqmSource_)
00025     << "[PedsOnlyTask::" << __func__ << "]"
00026     << " Constructing object...";
00027 }
00028 
00029 // -----------------------------------------------------------------------------
00030 //
00031 PedsOnlyTask::~PedsOnlyTask()
00032 {
00033   LogTrace( mlDqmSource_)
00034     << "[PedsOnlyTask::" << __func__ << "]"
00035     << " Destructing object...";
00036 
00037   // Have to delete pApvFactory_ manually even though we didn't create it
00038   // ourself. :(
00039   if( pApvFactory_) { delete pApvFactory_; } 
00040 }
00041 
00042 // -----------------------------------------------------------------------------
00043 //
00044 void PedsOnlyTask::book()
00045 {
00046   LogTrace( mlDqmSource_) << "[PedsOnlyTask::" << __func__ << "]";
00047 
00048   const uint16_t nBINS = 256;
00049 
00050   {
00051     // Pedestals
00052     std::string title = SiStripHistoTitle( sistrip::EXPERT_HISTO,
00053                                            sistrip::PEDS_ONLY,
00054                                            sistrip::FED_KEY,
00055                                            fedKey(),
00056                                            sistrip::LLD_CHAN,
00057                                            connection().lldChannel(),
00058                                            sistrip::extrainfo::pedestals_).title();
00059 
00060     HistoSet oHSet;
00061     oHSet.isProfile_ = true;
00062 
00063     oHSet.vNumOfEntries_.resize( nBINS, 0);
00064     oHSet.vSumOfContents_.resize( nBINS, 0);
00065     oHSet.vSumOfSquares_.resize( nBINS, 0);
00066 
00067     oHSet.histo( dqm()->bookProfile( title, title,
00068                                      nBINS, -0.5, nBINS * 1. - 0.5,
00069                                      1025, 0., 1025.) );
00070                  
00071     peds_.push_back( oHSet);
00072   }
00073   
00074   {
00075     // Raw Noise
00076     std::string title = SiStripHistoTitle( sistrip::EXPERT_HISTO,
00077                                            sistrip::PEDS_ONLY,
00078                                            sistrip::FED_KEY,
00079                                            fedKey(),
00080                                            sistrip::LLD_CHAN,
00081                                            connection().lldChannel(),
00082                                            sistrip::extrainfo::rawNoise_).title();
00083 
00084     HistoSet oHSet;
00085     oHSet.isProfile_ = true;
00086 
00087     oHSet.vNumOfEntries_.resize( nBINS, 0);
00088     oHSet.vSumOfContents_.resize( nBINS, 0);
00089     oHSet.vSumOfSquares_.resize( nBINS, 0);
00090 
00091     oHSet.histo( dqm()->bookProfile( title, title,
00092                                      nBINS, -0.5, nBINS * 1. - 0.5,
00093                                      1025, 0., 1025.) );
00094 
00095     peds_.push_back( oHSet);
00096   }
00097 
00098   pApvFactory_->instantiateApvs( connection().detId(), 
00099                                  connection().nApvs());
00100 }
00101 
00102 // -----------------------------------------------------------------------------
00103 //
00104 void PedsOnlyTask::fill( const SiStripEventSummary         &rSummary,
00105                          const edm::DetSet<SiStripRawDigi> &rDigis )
00106 {
00107   pApvFactory_->updatePair( connection().detId(), 
00108                            connection().apvPairNumber(), 
00109                            rDigis);
00110 }
00111 
00112 // -----------------------------------------------------------------------------
00113 //
00114 void PedsOnlyTask::update()
00115 {
00116   static UpdateTProfile updateTProfile;
00117 
00118   TProfile *pedsProf  = ExtractTObject<TProfile>().extract( peds_[0].histo() );
00119   TProfile *noiseProf = ExtractTObject<TProfile>().extract( peds_[1].histo() );
00120 
00121   for( uint16_t nLclApv = 2 * connection().apvPairNumber(),
00122                 nMaxLclApv = nLclApv + 2;
00123        nMaxLclApv > nLclApv;
00124        ++nLclApv)
00125   {
00126     ApvAnalysis::PedestalType lclPedestals;
00127     ApvAnalysis::PedestalType lclNoises;
00128 
00129     pApvFactory_->getPedestal( connection().detId(), nLclApv, lclPedestals);
00130     pApvFactory_->getRawNoise( connection().detId(), nLclApv, lclNoises );
00131 
00132     const uint16_t nSTART_BIN = 128 * ( nLclApv % 2);
00133 
00134     for( uint16_t nBin = 0,
00135                   nAbsBin = nSTART_BIN + nBin + 1; 
00136          128 > nBin; 
00137          ++nBin, ++nAbsBin)
00138     {
00139       updateTProfile.setBinContent( pedsProf, nAbsBin, 5, 
00140                                     lclPedestals[nBin], lclNoises[nBin]);
00141       updateTProfile.setBinContent( noiseProf, nAbsBin, 5,
00142                                     lclNoises[nBin], 0);
00143     } // End loop over BINs
00144   } // End loop over Local Apvs
00145 }
00146 // -----------------------------------------------------------------------------