CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/DQM/SiStripCommissioningClients/src/FedTimingHistograms.cc

Go to the documentation of this file.
00001 #include "DQM/SiStripCommissioningClients/interface/FedTimingHistograms.h"
00002 #include "CondFormats/SiStripObjects/interface/FedTimingAnalysis.h"
00003 #include "DataFormats/SiStripCommon/interface/SiStripEnumsAndStrings.h"
00004 #include "DQM/SiStripCommissioningAnalysis/interface/FedTimingAlgorithm.h"
00005 #include "DQM/SiStripCommissioningSummary/interface/SummaryGenerator.h"
00006 #include <iostream>
00007 #include <sstream>
00008 #include <iomanip>
00009 
00010 using namespace std;
00011 
00012 // -----------------------------------------------------------------------------
00014 FedTimingHistograms::FedTimingHistograms( const edm::ParameterSet& pset,
00015                                           DQMStore* bei )
00016   : CommissioningHistograms( pset.getParameter<edm::ParameterSet>("FedTimingParameters"),
00017                              bei,
00018                              sistrip::FED_TIMING ),
00019     factory_( new Factory ),
00020     optimumSamplingPoint_(15.),
00021     minDelay_(sistrip::invalid_),
00022     maxDelay_(-1.*sistrip::invalid_),
00023     deviceWithMinDelay_(sistrip::invalid_),
00024     deviceWithMaxDelay_(sistrip::invalid_)
00025 {
00026   cout << "[" << __PRETTY_FUNCTION__ << "]"
00027        << " Created object for APV TIMING histograms" << endl;
00028 }
00029 
00030 // -----------------------------------------------------------------------------
00032 FedTimingHistograms::~FedTimingHistograms() {
00033   cout << "[" << __PRETTY_FUNCTION__ << "]" << endl;
00034 }
00035 
00036 // -----------------------------------------------------------------------------         
00038 void FedTimingHistograms::histoAnalysis( bool debug ) {
00039   
00040   // Clear std::map holding analysis objects
00041   data_.clear();
00042 
00043   // Reset minimum / maximum delays
00044   float time_min =  1. * sistrip::invalid_;
00045   float time_max = -1. * sistrip::invalid_;
00046   uint32_t device_min = sistrip::invalid_;
00047   uint32_t device_max = sistrip::invalid_;
00048   
00049 //   // Iterate through std::map containing std::vectors of profile histograms
00050 //   CollationsMap::const_iterator iter = collations().begin();
00051 //   for ( ; iter != collations().end(); iter++ ) {
00052     
00053 //     // Check std::vector of histos is not empty (should be 2 histos)
00054 //     if ( iter->second.empty() ) {
00055 //       cerr << "[" << __PRETTY_FUNCTION__ << "]"
00056 //         << " Zero collation histograms found!" << endl;
00057 //       continue;
00058 //     }
00059     
00060 //     // Retrieve pointers to profile histos for this FED channel 
00061 //     std::vector<TH1*> profs;
00062 //     Collations::const_iterator ihis = iter->second.begin(); 
00063 //     for ( ; ihis != iter->second.end(); ihis++ ) {
00064 // OBSOLETE!!!
00065 //       TProfile* prof = ExtractTObject<TProfile>().extract( mui()->get( ihis->first ) );
00066 //       if ( prof ) { profs.push_back(prof); }
00067 //     } 
00068     
00069 //     // Perform histo analysis
00070 //     FedTimingAnalysis anal( iter->first );
00071 //     FedTimingAlgorithm algo( &anal );
00072 //     algo.analysis( profs );
00073 //     data_[iter->first] = anal; 
00074     
00075 //     // Check tick height is valid
00076 //     if ( anal.height() < 100. ) { 
00077 //       cerr << "[" << __PRETTY_FUNCTION__ << "]"
00078 //         << " Tick mark height too small: " << anal.height() << endl;
00079 //       continue; 
00080 //     }
00081 
00082 //     // Check time of rising edge
00083 //     if ( anal.time() > sistrip::maximum_ ) { continue; }
00084     
00085 //     // Find maximum time
00086 //     if ( anal.time() > time_max ) { 
00087 //       time_max = anal.time(); 
00088 //       device_max = iter->first;
00089 //     }
00090     
00091 //     // Find minimum time
00092 //     if ( anal.time() < time_min ) { 
00093 //       time_min = anal.time(); 
00094 //       device_min = iter->first;
00095 //     }
00096 
00097 //   }
00098 
00099 //   cout << "[" << __PRETTY_FUNCTION__ << "]"
00100 //        << " Analyzed histograms for " 
00101 //        << collations().size() 
00102 //        << " FED channels" << endl;
00103 
00104   // Adjust maximum (and minimum) delay(s) to find optimum sampling point(s)
00105   if ( time_max > sistrip::maximum_ ||
00106        time_max < -1.*sistrip::maximum_ ) { 
00107     cerr << "[" << __PRETTY_FUNCTION__ << "]"
00108          << " Unable to set maximum time! Found unexpected value: "
00109          << time_max << endl;
00110     return; 
00111   }
00112   
00113   SiStripFecKey max( device_max );
00114   cout << " Device (FEC/slot/ring/CCU/module/channel) " 
00115        << max.fecCrate() << "/" 
00116        << max.fecSlot() << "/" 
00117        << max.fecRing() << "/" 
00118        << max.ccuAddr() << "/"
00119        << max.ccuChan() << "/"
00120        << " has maximum delay (rising edge) [ns]:" << time_max << endl;
00121   
00122   SiStripFecKey min( device_min );
00123   cout << " Device (FEC/slot/ring/CCU/module/channel): " 
00124        << min.fecCrate() << "/" 
00125        << min.fecSlot() << "/" 
00126        << min.fecRing() << "/" 
00127        << min.ccuAddr() << "/"
00128        << min.ccuChan() << "/"
00129        << " has minimum delay (rising edge) [ns]:" << time_min << endl;
00130  
00131   // Set maximum time for all analysis objects
00132   std::map<uint32_t,FedTimingAnalysis>::iterator ianal = data_.begin();
00133   for ( ; ianal != data_.end(); ianal++ ) { 
00134     ianal->second.max( time_max ); 
00135     static uint16_t cntr = 0;
00136     if ( debug ) {
00137       std::stringstream ss;
00138       ianal->second.print( ss ); 
00139       cout << ss.str() << endl;
00140       cntr++;
00141     }
00142   }
00143 
00144 }
00145 
00146 // -----------------------------------------------------------------------------
00148 void FedTimingHistograms::createSummaryHisto( const sistrip::Monitorable& histo, 
00149                                               const sistrip::Presentation& type, 
00150                                               const std::string& directory,
00151                                               const sistrip::Granularity& gran ) {
00152   cout << "[" << __PRETTY_FUNCTION__ <<"]" << endl;
00153   
00154   // Check view 
00155   sistrip::View view = SiStripEnumsAndStrings::view(directory);
00156   if ( view == sistrip::UNKNOWN_VIEW ) { return; }
00157   
00158   // Analyze histograms
00159   histoAnalysis( false );
00160 
00161   // Extract data to be histogrammed
00162   factory_->init( histo, type, view, directory, gran );
00163   uint32_t xbins = factory_->extract( data_ );
00164 
00165   // Create summary histogram (if it doesn't already exist)
00166   TH1* summary = histogram( histo, type, view, directory, xbins );
00167 
00168   // Fill histogram with data
00169   factory_->fill( *summary );
00170   
00171 }