File indexing completed on 2024-08-08 22:57:13
0001 #include "DQM/SiStripCommissioningSources/interface/FineDelayTask.h"
0002 #include "DataFormats/SiStripCommon/interface/SiStripHistoTitle.h"
0003 #include "DQMServices/Core/interface/DQMStore.h"
0004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0005 #include "DataFormats/SiStripCommon/interface/SiStripDetKey.h"
0006
0007 #define NBINS (500)
0008 #define LOWBIN (-125)
0009 #define HIGHBIN (125)
0010
0011
0012
0013 CommissioningTask::HistoSet FineDelayTask::timing_;
0014 CommissioningTask::MonitorElement* FineDelayTask::mode_ = nullptr;
0015
0016
0017
0018 FineDelayTask::FineDelayTask(DQMStore* dqm, const FedChannelConnection& conn)
0019 : CommissioningTask(dqm, conn, "FineDelayTask") {
0020 LogDebug("Commissioning") << "[FineDelayTask::FineDelayTask] Constructing object...";
0021 }
0022
0023
0024
0025 FineDelayTask::~FineDelayTask() { LogDebug("Commissioning") << "[FineDelayTask::FineDelayTask] Destructing object..."; }
0026
0027
0028
0029 void FineDelayTask::book() {
0030 LogDebug("Commissioning") << "[FineDelayTask::book]";
0031
0032 std::string title;
0033 int nBins = NBINS;
0034 SiStripDetKey detkeytracker((uint32_t)0);
0035
0036
0037 if (timing_.histo()) {
0038
0039 LogDebug("Commissioning") << "[FineDelayTask::book] using existing histogram.";
0040 } else {
0041
0042 LogDebug("Commissioning") << "[LatencyTask::book] booking a new histogram.";
0043
0044 title = SiStripHistoTitle(sistrip::EXPERT_HISTO,
0045 sistrip::FINE_DELAY,
0046 sistrip::DET_KEY,
0047 detkeytracker.key(),
0048 sistrip::TRACKER,
0049 0,
0050 sistrip::extrainfo::clusterCharge_)
0051 .title();
0052 dqm()->setCurrentFolder(detkeytracker.path());
0053 timing_.histo(dqm()->bookProfile(title,
0054 title,
0055 nBins,
0056 LOWBIN,
0057 HIGHBIN,
0058 100,
0059 0.,
0060 -1.,
0061 "s"));
0062 timing_.vNumOfEntries_.resize(nBins, 0);
0063 timing_.vSumOfContents_.resize(nBins, 0);
0064 timing_.vSumOfSquares_.resize(nBins, 0);
0065 }
0066 LogDebug("Commissioning") << "Binning is " << timing_.vNumOfEntries_.size();
0067 LogDebug("Commissioning") << "[FineDelayTask::book] done";
0068 if (!mode_) {
0069 std::string pwd = dqm()->pwd();
0070 std::string rootDir = pwd.substr(0, pwd.find(std::string(sistrip::root_) + "/") + (sizeof(sistrip::root_)));
0071 dqm()->setCurrentFolder(rootDir);
0072 mode_ = dqm()->bookInt("latencyCode");
0073 }
0074 }
0075
0076
0077
0078 void FineDelayTask::fill(const SiStripEventSummary& summary, const edm::DetSet<SiStripRawDigi>& digis) {
0079 LogDebug("Commissioning") << "[FineDelayTask::fill]";
0080
0081 float delay = summary.ttcrx();
0082 uint32_t latencyCode = (summary.layerScanned() >> 24) & 0xff;
0083 LogDebug("Commissioning") << "[FineDelayTask::fill]: layerScanned() is " << summary.layerScanned();
0084 int latencyShift =
0085 latencyCode & 0x3f;
0086 if (latencyShift > 32)
0087 latencyShift -= 64;
0088 if ((latencyCode >> 6) == 2)
0089 latencyShift -= 3;
0090 else if ((latencyCode >> 6) == 1)
0091 latencyShift += 3;
0092 float correctedDelayBase =
0093 delay - (latencyShift * 25.);
0094
0095 LogDebug("Commissioning") << "[FineDelayTask::fill]; the delay is " << delay;
0096
0097 for (unsigned int strip = 0; strip < digis.data.size(); strip++) {
0098 if (digis.data[strip].adc() != 0) {
0099 if ((digis.data[strip].adc() >> 8) == 255)
0100 continue;
0101
0102 float tof = (digis.data[strip].adc() >> 8) / 10.;
0103 float correctedDelay = correctedDelayBase - tof;
0104
0105 float nbins = NBINS;
0106 float lowbin = LOWBIN;
0107 float highbin = HIGHBIN;
0108 int bin = int((correctedDelay - lowbin) / ((highbin - lowbin) / nbins));
0109 LogDebug("Commissioning") << "[FineDelayTask::fill]; using a hit with value " << (digis.data[strip].adc() & 0xff)
0110 << " at corrected delay of " << correctedDelay << " in bin " << bin << " (tof is "
0111 << tof << "( since adc = " << digis.data[strip].adc() << "))";
0112 updateHistoSet(timing_, bin, digis.data[strip].adc() & 0xff);
0113 if (mode_)
0114 mode_->Fill(latencyCode);
0115 }
0116 }
0117 }
0118
0119
0120
0121 void FineDelayTask::update() {
0122 LogDebug("Commissioning") << "[FineDelayTask::update]";
0123 updateHistoSet(timing_);
0124 }