Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:08:31

0001 #include "DQM/SiStripCommissioningClients/interface/FedTimingHistograms.h"
0002 #include "CondFormats/SiStripObjects/interface/FedTimingAnalysis.h"
0003 #include "DataFormats/SiStripCommon/interface/SiStripEnumsAndStrings.h"
0004 #include "DQM/SiStripCommissioningAnalysis/interface/FedTimingAlgorithm.h"
0005 #include "DQM/SiStripCommissioningSummary/interface/SummaryGenerator.h"
0006 #include <iostream>
0007 #include <sstream>
0008 #include <iomanip>
0009 
0010 using namespace std;
0011 
0012 // -----------------------------------------------------------------------------
0013 /** */
0014 FedTimingHistograms::FedTimingHistograms(const edm::ParameterSet& pset, DQMStore* bei)
0015     : CommissioningHistograms(pset.getParameter<edm::ParameterSet>("FedTimingParameters"), bei, sistrip::FED_TIMING),
0016       factory_(new Factory),
0017       optimumSamplingPoint_(15.),
0018       minDelay_(sistrip::invalid_),
0019       maxDelay_(-1. * sistrip::invalid_),
0020       deviceWithMinDelay_(sistrip::invalid_),
0021       deviceWithMaxDelay_(sistrip::invalid_) {
0022   cout << "[" << __PRETTY_FUNCTION__ << "]"
0023        << " Created object for APV TIMING histograms" << endl;
0024 }
0025 
0026 // -----------------------------------------------------------------------------
0027 /** */
0028 FedTimingHistograms::~FedTimingHistograms() { cout << "[" << __PRETTY_FUNCTION__ << "]" << endl; }
0029 
0030 // -----------------------------------------------------------------------------
0031 /** */
0032 void FedTimingHistograms::histoAnalysis(bool debug) {
0033   // Clear std::map holding analysis objects
0034   data_.clear();
0035 
0036   // Reset minimum / maximum delays
0037   float time_min = 1. * sistrip::invalid_;
0038   float time_max = -1. * sistrip::invalid_;
0039   uint32_t device_min = sistrip::invalid_;
0040   uint32_t device_max = sistrip::invalid_;
0041 
0042   //   // Iterate through std::map containing std::vectors of profile histograms
0043   //   CollationsMap::const_iterator iter = collations().begin();
0044   //   for ( ; iter != collations().end(); iter++ ) {
0045 
0046   //     // Check std::vector of histos is not empty (should be 2 histos)
0047   //     if ( iter->second.empty() ) {
0048   //       cerr << "[" << __PRETTY_FUNCTION__ << "]"
0049   //       << " Zero collation histograms found!" << endl;
0050   //       continue;
0051   //     }
0052 
0053   //     // Retrieve pointers to profile histos for this FED channel
0054   //     std::vector<TH1*> profs;
0055   //     Collations::const_iterator ihis = iter->second.begin();
0056   //     for ( ; ihis != iter->second.end(); ihis++ ) {
0057   // OBSOLETE!!!
0058   //       TProfile* prof = ExtractTObject<TProfile>().extract( mui()->get( ihis->first ) );
0059   //       if ( prof ) { profs.push_back(prof); }
0060   //     }
0061 
0062   //     // Perform histo analysis
0063   //     FedTimingAnalysis anal( iter->first );
0064   //     FedTimingAlgorithm algo( &anal );
0065   //     algo.analysis( profs );
0066   //     data_[iter->first] = anal;
0067 
0068   //     // Check tick height is valid
0069   //     if ( anal.height() < 100. ) {
0070   //       cerr << "[" << __PRETTY_FUNCTION__ << "]"
0071   //       << " Tick mark height too small: " << anal.height() << endl;
0072   //       continue;
0073   //     }
0074 
0075   //     // Check time of rising edge
0076   //     if ( anal.time() > sistrip::maximum_ ) { continue; }
0077 
0078   //     // Find maximum time
0079   //     if ( anal.time() > time_max ) {
0080   //       time_max = anal.time();
0081   //       device_max = iter->first;
0082   //     }
0083 
0084   //     // Find minimum time
0085   //     if ( anal.time() < time_min ) {
0086   //       time_min = anal.time();
0087   //       device_min = iter->first;
0088   //     }
0089 
0090   //   }
0091 
0092   //   cout << "[" << __PRETTY_FUNCTION__ << "]"
0093   //        << " Analyzed histograms for "
0094   //        << collations().size()
0095   //        << " FED channels" << endl;
0096 
0097   // Adjust maximum (and minimum) delay(s) to find optimum sampling point(s)
0098   if (time_max > sistrip::maximum_ || time_max < -1. * sistrip::maximum_) {
0099     cerr << "[" << __PRETTY_FUNCTION__ << "]"
0100          << " Unable to set maximum time! Found unexpected value: " << time_max << endl;
0101     return;
0102   }
0103 
0104   SiStripFecKey max(device_max);
0105   cout << " Device (FEC/slot/ring/CCU/module/channel) " << max.fecCrate() << "/" << max.fecSlot() << "/"
0106        << max.fecRing() << "/" << max.ccuAddr() << "/" << max.ccuChan() << "/"
0107        << " has maximum delay (rising edge) [ns]:" << time_max << endl;
0108 
0109   SiStripFecKey min(device_min);
0110   cout << " Device (FEC/slot/ring/CCU/module/channel): " << min.fecCrate() << "/" << min.fecSlot() << "/"
0111        << min.fecRing() << "/" << min.ccuAddr() << "/" << min.ccuChan() << "/"
0112        << " has minimum delay (rising edge) [ns]:" << time_min << endl;
0113 
0114   // Set maximum time for all analysis objects
0115   std::map<uint32_t, FedTimingAnalysis>::iterator ianal = data_.begin();
0116   for (; ianal != data_.end(); ianal++) {
0117     ianal->second.max(time_max);
0118     if (debug) {
0119       std::stringstream ss;
0120       ianal->second.print(ss);
0121       cout << ss.str() << endl;
0122     }
0123   }
0124 }
0125 
0126 // -----------------------------------------------------------------------------
0127 /** */
0128 void FedTimingHistograms::createSummaryHisto(const sistrip::Monitorable& histo,
0129                                              const sistrip::Presentation& type,
0130                                              const std::string& directory,
0131                                              const sistrip::Granularity& gran) {
0132   cout << "[" << __PRETTY_FUNCTION__ << "]" << endl;
0133 
0134   // Check view
0135   sistrip::View view = SiStripEnumsAndStrings::view(directory);
0136   if (view == sistrip::UNKNOWN_VIEW) {
0137     return;
0138   }
0139 
0140   // Analyze histograms
0141   histoAnalysis(false);
0142 
0143   // Extract data to be histogrammed
0144   factory_->init(histo, type, view, directory, gran);
0145   uint32_t xbins = factory_->extract(data_);
0146 
0147   // Create summary histogram (if it doesn't already exist)
0148   TH1* summary = histogram(histo, type, view, directory, xbins);
0149 
0150   // Fill histogram with data
0151   factory_->fill(*summary);
0152 }