CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/DQM/SiStripCommissioningSources/src/LatencyTask.cc

Go to the documentation of this file.
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 #include "DataFormats/SiStripCommon/interface/SiStripDetKey.h"
00007 
00008 #define NBINS (192)
00009 #define LOWBIN (-4800)
00010 #define HIGHBIN (0)
00011 
00012 // -----------------------------------------------------------------------------
00013 // static initialization
00014 CommissioningTask::HistoSet LatencyTask::timing_;
00015 CommissioningTask::HistoSet LatencyTask::cluster_;
00016 
00017 // -----------------------------------------------------------------------------
00018 //
00019 LatencyTask::LatencyTask( DQMStore* dqm,
00020                               const FedChannelConnection& conn ) :
00021   CommissioningTask( dqm, conn, "LatencyTask" ),firstReading_(-1)
00022 {
00023   LogDebug("Commissioning") << "[LatencyTask::LatencyTask] Constructing object...";
00024 }
00025 
00026 // -----------------------------------------------------------------------------
00027 //
00028 LatencyTask::~LatencyTask() {
00029   LogDebug("Commissioning") << "[LatencyTask::LatencyTask] Destructing object...";
00030 }
00031 
00032 // -----------------------------------------------------------------------------
00033 //
00034 void LatencyTask::book() {
00035   LogDebug("Commissioning") << "[LatencyTask::book]";
00036 
00037   std::string title;
00038   int nBins = NBINS;
00039   SiStripDetKey detkeytracker((uint32_t) 0);
00040   SiStripDetKey detkeypartition((uint16_t) (connection().fecCrate()));
00041 
00042   // see if the global timing histogram is already booked
00043   if (timing_.histo()) {
00044     // if already booked, use it
00045     LogDebug("Commissioning") << "[LatencyTask::book] using existing histogram.";
00046   } else {
00047     // make a new histo on the tracker level if not existing yet
00048     LogDebug("Commissioning") << "[LatencyTask::book] booking a new histogram in " << dqm()->pwd();
00049     // construct the histo title
00050     title = SiStripHistoTitle( sistrip::EXPERT_HISTO,
00051                                sistrip::APV_LATENCY,
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,            // name and title
00059                                        nBins, LOWBIN, HIGHBIN,  // binning + range
00060                                        100, 0., -1., "s" ) );    // Y range : automatic
00061     timing_.vNumOfEntries_.resize(nBins,0);
00062     timing_.vSumOfContents_.resize(nBins,0);
00063     timing_.vSumOfSquares_.resize(nBins,0);
00064   }
00065   // make a new histo on the partition level if not existing yet
00066   LogDebug("Commissioning") << "[LatencyTask::book] booking a new histogram in " << dqm()->pwd();
00067   // histo title
00068   title = SiStripHistoTitle( sistrip::EXPERT_HISTO,
00069                              sistrip::APV_LATENCY,
00070                              sistrip::DET_KEY,
00071                              detkeypartition.key(),
00072                              sistrip::PARTITION,
00073                              0,
00074                              sistrip::extrainfo::clusterCharge_ ).title();
00075   dqm()->setCurrentFolder( detkeypartition.path() );
00076   timingPartition_.histo( dqm()->bookProfile( title, title,            // name and title
00077                                               nBins, LOWBIN, HIGHBIN,  // binning + range
00078                                               100, 0., -1., "s" ) );    // Y range : automatic
00079   timingPartition_.vNumOfEntries_.resize(nBins,0);
00080   timingPartition_.vSumOfContents_.resize(nBins,0);
00081   timingPartition_.vSumOfSquares_.resize(nBins,0);
00082 
00083   // see if the global cluster histogram is already booked
00084   if (cluster_.histo()) {
00085     // if already booked, use it
00086     LogDebug("Commissioning") << "[LatencyTask::book] using existing histogram.";
00087   } else {
00088     // make a new histo on the tracker level if not existing yet
00089     LogDebug("Commissioning") << "[LatencyTask::book] booking a new histogram in " << dqm()->pwd();
00090     // construct the histo title
00091     title = SiStripHistoTitle( sistrip::EXPERT_HISTO,
00092                                sistrip::APV_LATENCY,
00093                                sistrip::DET_KEY,
00094                                detkeytracker.key(),
00095                                sistrip::TRACKER,
00096                                0,
00097                                sistrip::extrainfo::occupancy_).title();
00098     dqm()->setCurrentFolder( detkeytracker.path() );
00099     cluster_.histo( dqm()->book1D( title, title,               // name and title
00100                                    nBins, LOWBIN, HIGHBIN ));  // binning + range
00101     cluster_.isProfile_ = false;
00102     cluster_.vNumOfEntries_.resize(nBins,0);
00103     cluster_.vSumOfContents_.resize(nBins,0);
00104     cluster_.vSumOfSquares_.resize(nBins,0);
00105   }
00106   // make a new histo on the partition level if not existing yet
00107   LogDebug("Commissioning") << "[LatencyTask::book] booking a new histogram in " << dqm()->pwd();
00108   // histo title
00109   title = SiStripHistoTitle( sistrip::EXPERT_HISTO, 
00110                              sistrip::APV_LATENCY, 
00111                              sistrip::DET_KEY, 
00112                              detkeypartition.key(),
00113                              sistrip::PARTITION,
00114                              0,
00115                              sistrip::extrainfo::occupancy_ ).title(); 
00116   dqm()->setCurrentFolder( detkeypartition.path() );
00117   clusterPartition_.histo( dqm()->book1D( title, title,                // name and title
00118                                           nBins, LOWBIN, HIGHBIN ) );  // binning + range
00119   clusterPartition_.isProfile_ = false;
00120   clusterPartition_.vNumOfEntries_.resize(nBins,0);
00121   clusterPartition_.vSumOfContents_.resize(nBins,0);
00122   clusterPartition_.vSumOfSquares_.resize(nBins,0);
00123 
00124   LogDebug("Commissioning") << "[LatencyTask::book] done";
00125 }
00126 
00127 // -----------------------------------------------------------------------------
00128 //
00129 void LatencyTask::fill( const SiStripEventSummary& summary,
00130                         const edm::DetSet<SiStripRawDigi>& digis ) {
00131   LogDebug("Commissioning") << "[LatencyTask::fill]";
00132   // retrieve the delay from the EventSummary
00133   int32_t delay = static_cast<int32_t>( const_cast<SiStripEventSummary&>(summary).latency() );
00134   if(firstReading_==-1) firstReading_ = delay;
00135   float correctedDelay = 0.;
00136   LogDebug("Commissioning") << "[LatencyTask::fill]; the delay is " << delay;
00137   // loop on the strips to find the (maybe) non-zero digi
00138   unsigned int nclusters = 0;
00139   for(unsigned int strip=0;strip<digis.data.size();strip++) {
00140     if(digis.data[strip].adc()!=0) {
00141       // count the "cluster"
00142       ++nclusters;
00143       // no TOF correction is applied.
00144       // 2 reasons: the effect is a priori to thin to be seen with 25ns steps
00145       // and it biases the result by one clock due to the 25bins in the HistoSet
00146       correctedDelay = delay*(-25.); // no TOF correction is applied. 
00147       // compute the bin
00148       int bin = int((correctedDelay-LOWBIN)/((HIGHBIN-LOWBIN)/NBINS));
00149       LogDebug("Commissioning") << "[LatencyTask::fill]; using a hit with value " << ( digis.data[strip].adc()&0xff )
00150                                 << " at corrected delay of " << correctedDelay
00151                                 << " in bin " << bin ;
00152       updateHistoSet( timing_,bin,digis.data[strip].adc()&0xff);
00153       LogDebug("Commissioning") << "HistoSet timing Updated " << strip << " " << digis.data.size();
00154       updateHistoSet( timingPartition_,bin,digis.data[strip].adc()&0xff);
00155       LogDebug("Commissioning") << "HistoSet timingPartition Updated " << strip << " " << digis.data.size();
00156     }
00157   }
00158   // set the occupancy
00159   int bin = int((delay*(-25.)-LOWBIN)/((HIGHBIN-LOWBIN)/NBINS));
00160   LogDebug("Commissioning") << "[LatencyTask::fill]; occupancy is " << nclusters;
00161   updateHistoSet( cluster_,bin,nclusters );
00162   updateHistoSet( clusterPartition_,bin,nclusters );
00163 }
00164 
00165 // -----------------------------------------------------------------------------
00166 //
00167 void LatencyTask::update() {
00168   LogDebug("Commissioning") << "[LatencyTask::update]";
00169   updateHistoSet( timing_ );
00170   updateHistoSet( timingPartition_ );
00171   updateHistoSet( cluster_ );
00172   updateHistoSet( clusterPartition_ );
00173 }
00174