Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:11:38

0001 #include "CalibTracker/SiStripAPVAnalysis/interface/ApvAnalysisFactory.h"
0002 #include "CalibTracker/SiStripAPVAnalysis/interface/ApvFactoryService.h"
0003 #include "DataFormats/SiStripCommon/interface/SiStripConstants.h"
0004 #include "DataFormats/SiStripCommon/interface/SiStripHistoTitle.h"
0005 #include "DQM/SiStripCommon/interface/ExtractTObject.h"
0006 #include "DQM/SiStripCommon/interface/UpdateTProfile.h"
0007 #include "DQMServices/Core/interface/DQMStore.h"
0008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0009 #include "FWCore/ServiceRegistry/interface/Service.h"
0010 
0011 #include "DQM/SiStripCommissioningSources/interface/PedsOnlyTask.h"
0012 
0013 using namespace sistrip;
0014 
0015 // -----------------------------------------------------------------------------
0016 //
0017 PedsOnlyTask::PedsOnlyTask(DQMStore *dqm, const FedChannelConnection &rCONN)
0018     : CommissioningTask(dqm, rCONN, "PedsOnlyTask") {
0019   //@@ NOT GUARANTEED TO BE THREAD SAFE!
0020   pApvFactory_ = edm::Service<ApvFactoryService>().operator->()->getApvFactory();
0021 
0022   LogTrace(mlDqmSource_) << "[PedsOnlyTask::" << __func__ << "]"
0023                          << " Constructing object...";
0024 }
0025 
0026 // -----------------------------------------------------------------------------
0027 //
0028 PedsOnlyTask::~PedsOnlyTask() {
0029   LogTrace(mlDqmSource_) << "[PedsOnlyTask::" << __func__ << "]"
0030                          << " Destructing object...";
0031 
0032   // Have to delete pApvFactory_ manually even though we didn't create it
0033   // ourself. :(
0034   if (pApvFactory_) {
0035     delete pApvFactory_;
0036   }
0037 }
0038 
0039 // -----------------------------------------------------------------------------
0040 //
0041 void PedsOnlyTask::book() {
0042   LogTrace(mlDqmSource_) << "[PedsOnlyTask::" << __func__ << "]";
0043 
0044   const uint16_t nBINS = 256;
0045 
0046   {
0047     // Pedestals
0048     std::string title = SiStripHistoTitle(sistrip::EXPERT_HISTO,
0049                                           sistrip::PEDS_ONLY,
0050                                           sistrip::FED_KEY,
0051                                           fedKey(),
0052                                           sistrip::LLD_CHAN,
0053                                           connection().lldChannel(),
0054                                           sistrip::extrainfo::pedestals_)
0055                             .title();
0056 
0057     HistoSet oHSet;
0058     oHSet.isProfile_ = true;
0059 
0060     oHSet.vNumOfEntries_.resize(nBINS, 0);
0061     oHSet.vSumOfContents_.resize(nBINS, 0);
0062     oHSet.vSumOfSquares_.resize(nBINS, 0);
0063 
0064     oHSet.histo(dqm()->bookProfile(title, title, nBINS, -0.5, nBINS * 1. - 0.5, 1025, 0., 1025.));
0065 
0066     peds_.push_back(oHSet);
0067   }
0068 
0069   {
0070     // Raw Noise
0071     std::string title = SiStripHistoTitle(sistrip::EXPERT_HISTO,
0072                                           sistrip::PEDS_ONLY,
0073                                           sistrip::FED_KEY,
0074                                           fedKey(),
0075                                           sistrip::LLD_CHAN,
0076                                           connection().lldChannel(),
0077                                           sistrip::extrainfo::rawNoise_)
0078                             .title();
0079 
0080     HistoSet oHSet;
0081     oHSet.isProfile_ = true;
0082 
0083     oHSet.vNumOfEntries_.resize(nBINS, 0);
0084     oHSet.vSumOfContents_.resize(nBINS, 0);
0085     oHSet.vSumOfSquares_.resize(nBINS, 0);
0086 
0087     oHSet.histo(dqm()->bookProfile(title, title, nBINS, -0.5, nBINS * 1. - 0.5, 1025, 0., 1025.));
0088 
0089     peds_.push_back(oHSet);
0090   }
0091 
0092   pApvFactory_->instantiateApvs(connection().detId(), connection().nApvs());
0093 }
0094 
0095 // -----------------------------------------------------------------------------
0096 //
0097 void PedsOnlyTask::fill(const SiStripEventSummary &rSummary, const edm::DetSet<SiStripRawDigi> &rDigis) {
0098   pApvFactory_->updatePair(connection().detId(), connection().apvPairNumber(), rDigis);
0099 }
0100 
0101 // -----------------------------------------------------------------------------
0102 //
0103 void PedsOnlyTask::update() {
0104   static UpdateTProfile updateTProfile;
0105 
0106   TProfile *pedsProf = ExtractTObject<TProfile>().extract(peds_[0].histo());
0107   TProfile *noiseProf = ExtractTObject<TProfile>().extract(peds_[1].histo());
0108 
0109   for (uint16_t nLclApv = 2 * connection().apvPairNumber(), nMaxLclApv = nLclApv + 2; nMaxLclApv > nLclApv; ++nLclApv) {
0110     ApvAnalysis::PedestalType lclPedestals;
0111     ApvAnalysis::PedestalType lclNoises;
0112 
0113     pApvFactory_->getPedestal(connection().detId(), nLclApv, lclPedestals);
0114     pApvFactory_->getRawNoise(connection().detId(), nLclApv, lclNoises);
0115 
0116     const uint16_t nSTART_BIN = 128 * (nLclApv % 2);
0117 
0118     for (uint16_t nBin = 0, nAbsBin = nSTART_BIN + nBin + 1; 128 > nBin; ++nBin, ++nAbsBin) {
0119       updateTProfile.setBinContent(pedsProf, nAbsBin, 5, lclPedestals[nBin], lclNoises[nBin]);
0120       updateTProfile.setBinContent(noiseProf, nAbsBin, 5, lclNoises[nBin], 0);
0121     }  // End loop over BINs
0122   }    // End loop over Local Apvs
0123 }
0124 // -----------------------------------------------------------------------------