Go to the documentation of this file.00001 #include "DQM/SiStripCommissioningSources/interface/FineDelayTask.h"
00002 #include "DataFormats/SiStripCommon/interface/SiStripHistoTitle.h"
00003 #include "DQMServices/Core/interface/DQMStore.h"
00004 #include "DQMServices/Core/interface/MonitorElement.h"
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006 #include "DataFormats/SiStripCommon/interface/SiStripDetKey.h"
00007
00008 #define NBINS (500)
00009 #define LOWBIN (-125)
00010 #define HIGHBIN (125)
00011
00012
00013
00014
00015 CommissioningTask::HistoSet FineDelayTask::timing_;
00016 MonitorElement* FineDelayTask::mode_ = NULL;
00017
00018
00019
00020 FineDelayTask::FineDelayTask( DQMStore* dqm,
00021 const FedChannelConnection& conn ) :
00022 CommissioningTask( dqm, conn, "FineDelayTask" )
00023 {
00024 LogDebug("Commissioning") << "[FineDelayTask::FineDelayTask] Constructing object...";
00025 }
00026
00027
00028
00029 FineDelayTask::~FineDelayTask() {
00030 LogDebug("Commissioning") << "[FineDelayTask::FineDelayTask] Destructing object...";
00031 }
00032
00033
00034
00035 void FineDelayTask::book() {
00036 LogDebug("Commissioning") << "[FineDelayTask::book]";
00037
00038 std::string title;
00039 int nBins = NBINS;
00040 SiStripDetKey detkeytracker((uint32_t) 0);
00041
00042
00043 if (timing_.histo()) {
00044
00045 LogDebug("Commissioning") << "[FineDelayTask::book] using existing histogram.";
00046 } else {
00047
00048 LogDebug("Commissioning") << "[LatencyTask::book] booking a new histogram.";
00049
00050 title = SiStripHistoTitle( sistrip::EXPERT_HISTO,
00051 sistrip::FINE_DELAY,
00052 sistrip::DET_KEY,
00053 detkeytracker.key(),
00054 sistrip::TRACKER,
00055 0,
00056 sistrip::extrainfo::clusterCharge_ ).title();
00057 dqm()->setCurrentFolder( detkeytracker.path() );
00058 timing_.histo( dqm()->bookProfile( title, title,
00059 nBins, LOWBIN, HIGHBIN,
00060 100, 0., -1., "s" ) );
00061 timing_.vNumOfEntries_.resize(nBins,0);
00062 timing_.vSumOfContents_.resize(nBins,0);
00063 timing_.vSumOfSquares_.resize(nBins,0);
00064 }
00065 LogDebug("Commissioning") << "Binning is " << timing_.vNumOfEntries_.size();
00066 LogDebug("Commissioning") << "[FineDelayTask::book] done";
00067 if(!mode_) {
00068 std::string pwd = dqm()->pwd();
00069 std::string rootDir = pwd.substr(0,pwd.find(std::string(sistrip::root_) + "/")+(sizeof(sistrip::root_)));
00070 dqm()->setCurrentFolder( rootDir );
00071 mode_ = dqm()->bookInt("latencyCode");
00072 }
00073
00074 }
00075
00076
00077
00078 void FineDelayTask::fill( const SiStripEventSummary& summary,
00079 const edm::DetSet<SiStripRawDigi>& digis ) {
00080 LogDebug("Commissioning") << "[FineDelayTask::fill]";
00081
00082 float delay = const_cast<SiStripEventSummary&>(summary).ttcrx();
00083 uint32_t latencyCode = (const_cast<SiStripEventSummary&>(summary).layerScanned()>>24)&0xff;
00084 LogDebug("Commissioning") << "[FineDelayTask::fill]: layerScanned() is " << const_cast<SiStripEventSummary&>(summary).layerScanned();
00085 int latencyShift = latencyCode & 0x3f;
00086 if(latencyShift>32) latencyShift -=64;
00087 if((latencyCode>>6)==2) latencyShift -= 3;
00088 if((latencyCode>>6)==1) latencyShift += 3;
00089 float correctedDelay = delay - (latencyShift*25.);
00090
00091 LogDebug("Commissioning") << "[FineDelayTask::fill]; the delay is " << delay;
00092
00093 for(unsigned int strip=0;strip<digis.data.size();strip++) {
00094 if(digis.data[strip].adc()!=0) {
00095
00096 float tof = (digis.data[strip].adc()>>8)/10.;
00097 correctedDelay = delay - (latencyShift*25.) - tof;
00098 if((digis.data[strip].adc()>>8)==255) continue;
00099
00100 float nbins = NBINS;
00101 float lowbin = LOWBIN;
00102 float highbin = HIGHBIN;
00103 int bin = int((correctedDelay-lowbin)/((highbin-lowbin)/nbins));
00104 LogDebug("Commissioning") << "[FineDelayTask::fill]; using a hit with value " << ( digis.data[strip].adc()&0xff )
00105 << " at corrected delay of " << correctedDelay
00106 << " in bin " << bin << " (tof is " << tof << "( since adc = " << digis.data[strip].adc() << "))";
00107 updateHistoSet( timing_,bin,digis.data[strip].adc()&0xff);
00108 if(mode_) mode_->Fill(latencyCode);
00109 }
00110 }
00111 }
00112
00113
00114
00115 void FineDelayTask::update() {
00116 LogDebug("Commissioning") << "[FineDelayTask::update]";
00117 updateHistoSet( timing_ );
00118 }
00119