00001 #include "DQM/SiStripCommissioningSources/interface/LatencyTask.h"
00002 #include "DataFormats/SiStripCommon/interface/SiStripHistoTitle.h"
00003 #include <DataFormats/SiStripDetId/interface/SiStripDetId.h>
00004 #include "DQMServices/Core/interface/DQMStore.h"
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006
00007 #define NBINS (192)
00008 #define LOWBIN (-4800)
00009 #define HIGHBIN (0)
00010
00011
00012
00013 std::map<std::string, CommissioningTask::HistoSet> LatencyTask::timingMap_;
00014 std::map<std::string, CommissioningTask::HistoSet> LatencyTask::clusterMap_;
00015
00016
00017
00018 LatencyTask::LatencyTask( DQMStore* dqm,
00019 const FedChannelConnection& conn ) :
00020 CommissioningTask( dqm, conn, "LatencyTask" ),timing_(0),cluster_(0),firstReading_(-1)
00021 {
00022 LogDebug("Commissioning") << "[LatencyTask::LatencyTask] Constructing object...";
00023 }
00024
00025
00026
00027 LatencyTask::~LatencyTask() {
00028 LogDebug("Commissioning") << "[LatencyTask::LatencyTask] Destructing object...";
00029 }
00030
00031
00032
00033 void LatencyTask::book() {
00034 LogDebug("Commissioning") << "[LatencyTask::book]";
00035
00036
00037
00038
00039 std::string title = SiStripHistoTitle( sistrip::EXPERT_HISTO,
00040 sistrip::APV_LATENCY,
00041 sistrip::DET_KEY,
00042 0,
00043 sistrip::TRACKER,
00044 0,
00045 sistrip::extrainfo::clusterCharge_).title();
00046
00047 if(timingMap_.find(title)!=timingMap_.end()) {
00048
00049 LogDebug("Commissioning") << "[LatencyTask::book] using existing histogram.";
00050 } else {
00051
00052 timingMap_[title] = HistoSet();
00053 int nBins = NBINS;
00054 std::string pwd = dqm()->pwd();
00055 std::string rootDir = pwd.substr(0,pwd.find(sistrip::root_ + "/")+sistrip::root_.size());
00056 rootDir += "/"; rootDir += sistrip::controlView_;
00057 dqm()->setCurrentFolder( rootDir );
00058 LogDebug("Commissioning") << "[LatencyTask::book] booking a new histogram in " << dqm()->pwd();
00059 timingMap_[title].histo( dqm()->bookProfile( title, title,
00060 nBins, LOWBIN, HIGHBIN,
00061 100, 0., -1.,"s" ) );
00062 dqm()->setCurrentFolder( pwd );
00063
00064 timingMap_[title].vNumOfEntries_.resize(nBins,0);
00065 timingMap_[title].vSumOfContents_.resize(nBins,0);
00066 timingMap_[title].vSumOfSquares_.resize(nBins,0);
00067 }
00068 timing_ = &(timingMap_[title]);
00069
00070 title = SiStripHistoTitle( sistrip::EXPERT_HISTO,
00071 sistrip::APV_LATENCY,
00072 sistrip::DET_KEY,
00073 int(SiStripDetId(connection().detId()).subDetector()),
00074 sistrip::PARTITION,
00075 0,
00076 sistrip::extrainfo::clusterCharge_).title();
00077
00078 if(timingMap_.find(title)!=timingMap_.end()) {
00079
00080 LogDebug("Commissioning") << "[LatencyTask::book] using existing histogram.";
00081 } else {
00082
00083 timingMap_[title] = HistoSet();
00084 int nBins = NBINS;
00085 LogDebug("Commissioning") << "[LatencyTask::book] booking a new histogram in " << dqm()->pwd();
00086 timingMap_[title].histo( dqm()->bookProfile( title, title,
00087 nBins, LOWBIN, HIGHBIN,
00088 100, 0., -1.,"s" ) );
00089
00090 timingMap_[title].vNumOfEntries_.resize(nBins,0);
00091 timingMap_[title].vSumOfContents_.resize(nBins,0);
00092 timingMap_[title].vSumOfSquares_.resize(nBins,0);
00093 }
00094 timingPartition_ = &(timingMap_[title]);
00095
00096
00097
00098 title = SiStripHistoTitle( sistrip::EXPERT_HISTO,
00099 sistrip::APV_LATENCY,
00100 sistrip::DET_KEY,
00101 0,
00102 sistrip::TRACKER,
00103 0,
00104 sistrip::extrainfo::occupancy_).title();
00105
00106 if(clusterMap_.find(title)!=clusterMap_.end()) {
00107
00108 LogDebug("Commissioning") << "[LatencyTask::book] using existing histogram.";
00109 } else {
00110
00111 clusterMap_[title] = HistoSet();
00112 int nBins = NBINS;
00113 std::string pwd = dqm()->pwd();
00114 std::string rootDir = pwd.substr(0,pwd.find(sistrip::root_ + "/")+sistrip::root_.size());
00115 rootDir += "/"; rootDir += sistrip::controlView_;
00116 dqm()->setCurrentFolder( rootDir );
00117 LogDebug("Commissioning") << "[LatencyTask::book] booking a new histogram in " << dqm()->pwd();
00118 clusterMap_[title].histo( dqm()->book1D( title, title,
00119 nBins, LOWBIN, HIGHBIN ));
00120 dqm()->setCurrentFolder( pwd );
00121
00122 clusterMap_[title].isProfile_=false;
00123 clusterMap_[title].vNumOfEntries_.resize(nBins,0);
00124 clusterMap_[title].vSumOfContents_.resize(nBins,0);
00125 clusterMap_[title].vSumOfSquares_.resize(nBins,0);
00126 }
00127 cluster_ = &(clusterMap_[title]);
00128
00129 title = SiStripHistoTitle( sistrip::EXPERT_HISTO,
00130 sistrip::APV_LATENCY,
00131 sistrip::DET_KEY,
00132 int(SiStripDetId(connection().detId()).subDetector()),
00133 sistrip::PARTITION,
00134 0,
00135 sistrip::extrainfo::occupancy_).title();
00136
00137 if(clusterMap_.find(title)!=clusterMap_.end()) {
00138
00139 LogDebug("Commissioning") << "[LatencyTask::book] using existing histogram.";
00140 } else {
00141
00142 clusterMap_[title] = HistoSet();
00143 int nBins = NBINS;
00144 LogDebug("Commissioning") << "[LatencyTask::book] booking a new histogram in " << dqm()->pwd();
00145 clusterMap_[title].histo( dqm()->book1D( title, title,
00146 nBins, LOWBIN, HIGHBIN ));
00147
00148 clusterMap_[title].isProfile_=false;
00149 clusterMap_[title].vNumOfEntries_.resize(nBins,0);
00150 clusterMap_[title].vSumOfContents_.resize(nBins,0);
00151 clusterMap_[title].vSumOfSquares_.resize(nBins,0);
00152 }
00153 clusterPartition_ = &(clusterMap_[title]);
00154
00155 LogDebug("Commissioning") << "[LatencyTask::book] done";
00156 }
00157
00158
00159
00160 void LatencyTask::fill( const SiStripEventSummary& summary,
00161 const edm::DetSet<SiStripRawDigi>& digis ) {
00162 LogDebug("Commissioning") << "[LatencyTask::fill]";
00163
00164 int32_t delay = static_cast<int32_t>( const_cast<SiStripEventSummary&>(summary).latency() );
00165 if(firstReading_==-1) firstReading_ = delay;
00166 float correctedDelay = 0.;
00167 LogDebug("Commissioning") << "[LatencyTask::fill]; the delay is " << delay;
00168
00169 unsigned int nclusters = 0;
00170 for(unsigned int strip=0;strip<digis.data.size();strip++) {
00171 if(digis.data[strip].adc()!=0) {
00172
00173 ++nclusters;
00174
00175
00176
00177 correctedDelay = delay*(-25.);
00178
00179 int bin = int((correctedDelay-LOWBIN)/((HIGHBIN-LOWBIN)/NBINS));
00180 LogDebug("Commissioning") << "[LatencyTask::fill]; using a hit with value " << ( digis.data[strip].adc()&0xff )
00181 << " at corrected delay of " << correctedDelay
00182 << " in bin " << bin ;
00183 updateHistoSet( *timing_,bin,digis.data[strip].adc()&0xff);
00184 updateHistoSet( *timingPartition_,bin,digis.data[strip].adc()&0xff);
00185 }
00186 }
00187
00188 int bin = int((delay*(-25.)-LOWBIN)/((HIGHBIN-LOWBIN)/NBINS));
00189 LogDebug("Commissioning") << "[LatencyTask::fill]; occupancy is " << nclusters;
00190 updateHistoSet( *cluster_,bin,nclusters );
00191 updateHistoSet( *clusterPartition_,bin,nclusters );
00192 }
00193
00194
00195
00196 void LatencyTask::update() {
00197 LogDebug("Commissioning") << "[LatencyTask::update]";
00198 updateHistoSet( *timing_ );
00199 updateHistoSet( *timingPartition_ );
00200 updateHistoSet( *cluster_ );
00201 updateHistoSet( *clusterPartition_ );
00202 }
00203