Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "DQM/SiStripCommissioningSources/interface/LatencyTask.h"
0002 #include "DataFormats/SiStripCommon/interface/SiStripHistoTitle.h"
0003 #include <DataFormats/SiStripDetId/interface/SiStripDetId.h>
0004 #include "DQMServices/Core/interface/DQMStore.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 #include "DataFormats/SiStripCommon/interface/SiStripDetKey.h"
0007 
0008 #define NBINS (192)
0009 #define LOWBIN (-4800)
0010 #define HIGHBIN (0)
0011 
0012 // -----------------------------------------------------------------------------
0013 // static initialization
0014 CommissioningTask::HistoSet LatencyTask::timing_;
0015 CommissioningTask::HistoSet LatencyTask::cluster_;
0016 
0017 // -----------------------------------------------------------------------------
0018 //
0019 LatencyTask::LatencyTask(DQMStore* dqm, const FedChannelConnection& conn)
0020     : CommissioningTask(dqm, conn, "LatencyTask"), firstReading_(-1) {
0021   LogDebug("Commissioning") << "[LatencyTask::LatencyTask] Constructing object...";
0022 }
0023 
0024 // -----------------------------------------------------------------------------
0025 //
0026 LatencyTask::~LatencyTask() { LogDebug("Commissioning") << "[LatencyTask::LatencyTask] Destructing object..."; }
0027 
0028 // -----------------------------------------------------------------------------
0029 //
0030 void LatencyTask::book() {
0031   LogDebug("Commissioning") << "[LatencyTask::book]";
0032 
0033   std::string title;
0034   int nBins = NBINS;
0035   SiStripDetKey detkeytracker((uint32_t)0);
0036   SiStripDetKey detkeypartition((uint16_t)(connection().fecCrate()));
0037 
0038   // see if the global timing histogram is already booked
0039   if (timing_.histo()) {
0040     // if already booked, use it
0041     LogDebug("Commissioning") << "[LatencyTask::book] using existing histogram.";
0042   } else {
0043     // make a new histo on the tracker level if not existing yet
0044     LogDebug("Commissioning") << "[LatencyTask::book] booking a new histogram in " << dqm()->pwd();
0045     // construct the histo title
0046     title = SiStripHistoTitle(sistrip::EXPERT_HISTO,
0047                               sistrip::APV_LATENCY,
0048                               sistrip::DET_KEY,
0049                               detkeytracker.key(),
0050                               sistrip::TRACKER,
0051                               0,
0052                               sistrip::extrainfo::clusterCharge_)
0053                 .title();
0054     dqm()->setCurrentFolder(detkeytracker.path());
0055     timing_.histo(dqm()->bookProfile(title,
0056                                      title,  // name and title
0057                                      nBins,
0058                                      LOWBIN,
0059                                      HIGHBIN,  // binning + range
0060                                      100,
0061                                      0.,
0062                                      -1.,
0063                                      "s"));  // Y range : automatic
0064     timing_.vNumOfEntries_.resize(nBins, 0);
0065     timing_.vSumOfContents_.resize(nBins, 0);
0066     timing_.vSumOfSquares_.resize(nBins, 0);
0067   }
0068   // make a new histo on the partition level if not existing yet
0069   LogDebug("Commissioning") << "[LatencyTask::book] booking a new histogram in " << dqm()->pwd();
0070   // histo title
0071   title = SiStripHistoTitle(sistrip::EXPERT_HISTO,
0072                             sistrip::APV_LATENCY,
0073                             sistrip::DET_KEY,
0074                             detkeypartition.key(),
0075                             sistrip::PARTITION,
0076                             0,
0077                             sistrip::extrainfo::clusterCharge_)
0078               .title();
0079   dqm()->setCurrentFolder(detkeypartition.path());
0080   timingPartition_.histo(dqm()->bookProfile(title,
0081                                             title,  // name and title
0082                                             nBins,
0083                                             LOWBIN,
0084                                             HIGHBIN,  // binning + range
0085                                             100,
0086                                             0.,
0087                                             -1.,
0088                                             "s"));  // Y range : automatic
0089   timingPartition_.vNumOfEntries_.resize(nBins, 0);
0090   timingPartition_.vSumOfContents_.resize(nBins, 0);
0091   timingPartition_.vSumOfSquares_.resize(nBins, 0);
0092 
0093   // see if the global cluster histogram is already booked
0094   if (cluster_.histo()) {
0095     // if already booked, use it
0096     LogDebug("Commissioning") << "[LatencyTask::book] using existing histogram.";
0097   } else {
0098     // make a new histo on the tracker level if not existing yet
0099     LogDebug("Commissioning") << "[LatencyTask::book] booking a new histogram in " << dqm()->pwd();
0100     // construct the histo title
0101     title = SiStripHistoTitle(sistrip::EXPERT_HISTO,
0102                               sistrip::APV_LATENCY,
0103                               sistrip::DET_KEY,
0104                               detkeytracker.key(),
0105                               sistrip::TRACKER,
0106                               0,
0107                               sistrip::extrainfo::occupancy_)
0108                 .title();
0109     dqm()->setCurrentFolder(detkeytracker.path());
0110     cluster_.histo(dqm()->book1D(title,
0111                                  title,  // name and title
0112                                  nBins,
0113                                  LOWBIN,
0114                                  HIGHBIN));  // binning + range
0115     cluster_.isProfile_ = false;
0116     cluster_.vNumOfEntries_.resize(nBins, 0);
0117     cluster_.vSumOfContents_.resize(nBins, 0);
0118     cluster_.vSumOfSquares_.resize(nBins, 0);
0119   }
0120   // make a new histo on the partition level if not existing yet
0121   LogDebug("Commissioning") << "[LatencyTask::book] booking a new histogram in " << dqm()->pwd();
0122   // histo title
0123   title = SiStripHistoTitle(sistrip::EXPERT_HISTO,
0124                             sistrip::APV_LATENCY,
0125                             sistrip::DET_KEY,
0126                             detkeypartition.key(),
0127                             sistrip::PARTITION,
0128                             0,
0129                             sistrip::extrainfo::occupancy_)
0130               .title();
0131   dqm()->setCurrentFolder(detkeypartition.path());
0132   clusterPartition_.histo(dqm()->book1D(title,
0133                                         title,  // name and title
0134                                         nBins,
0135                                         LOWBIN,
0136                                         HIGHBIN));  // binning + range
0137   clusterPartition_.isProfile_ = false;
0138   clusterPartition_.vNumOfEntries_.resize(nBins, 0);
0139   clusterPartition_.vSumOfContents_.resize(nBins, 0);
0140   clusterPartition_.vSumOfSquares_.resize(nBins, 0);
0141 
0142   LogDebug("Commissioning") << "[LatencyTask::book] done";
0143 }
0144 
0145 // -----------------------------------------------------------------------------
0146 //
0147 void LatencyTask::fill(const SiStripEventSummary& summary, const edm::DetSet<SiStripRawDigi>& digis) {
0148   LogDebug("Commissioning") << "[LatencyTask::fill]";
0149   // retrieve the delay from the EventSummary
0150   int32_t delay = static_cast<int32_t>(summary.latency());
0151   if (firstReading_ == -1)
0152     firstReading_ = delay;
0153   float correctedDelay = 0.;
0154   LogDebug("Commissioning") << "[LatencyTask::fill]; the delay is " << delay;
0155   // loop on the strips to find the (maybe) non-zero digi
0156   unsigned int nclusters = 0;
0157   for (unsigned int strip = 0; strip < digis.data.size(); strip++) {
0158     if (digis.data[strip].adc() != 0) {
0159       // count the "cluster"
0160       ++nclusters;
0161       // no TOF correction is applied.
0162       // 2 reasons: the effect is a priori to thin to be seen with 25ns steps
0163       // and it biases the result by one clock due to the 25bins in the HistoSet
0164       correctedDelay = delay * (-25.);  // no TOF correction is applied.
0165       // compute the bin
0166       int bin = int((correctedDelay - LOWBIN) / ((HIGHBIN - LOWBIN) / NBINS));
0167       LogDebug("Commissioning") << "[LatencyTask::fill]; using a hit with value " << (digis.data[strip].adc() & 0xff)
0168                                 << " at corrected delay of " << correctedDelay << " in bin " << bin;
0169       updateHistoSet(timing_, bin, digis.data[strip].adc() & 0xff);
0170       LogDebug("Commissioning") << "HistoSet timing Updated " << strip << " " << digis.data.size();
0171       updateHistoSet(timingPartition_, bin, digis.data[strip].adc() & 0xff);
0172       LogDebug("Commissioning") << "HistoSet timingPartition Updated " << strip << " " << digis.data.size();
0173     }
0174   }
0175   // set the occupancy
0176   int bin = int((delay * (-25.) - LOWBIN) / ((HIGHBIN - LOWBIN) / NBINS));
0177   LogDebug("Commissioning") << "[LatencyTask::fill]; occupancy is " << nclusters;
0178   updateHistoSet(cluster_, bin, nclusters);
0179   updateHistoSet(clusterPartition_, bin, nclusters);
0180 }
0181 
0182 // -----------------------------------------------------------------------------
0183 //
0184 void LatencyTask::update() {
0185   LogDebug("Commissioning") << "[LatencyTask::update]";
0186   updateHistoSet(timing_);
0187   updateHistoSet(timingPartition_);
0188   updateHistoSet(cluster_);
0189   updateHistoSet(clusterPartition_);
0190 }