00001 #include "DQM/SiStripCommissioningClients/interface/FastFedCablingHistograms.h" 00002 #include "CondFormats/SiStripObjects/interface/FastFedCablingAnalysis.h" 00003 #include "DataFormats/SiStripCommon/interface/SiStripConstants.h" 00004 #include "DQM/SiStripCommissioningAnalysis/interface/FastFedCablingAlgorithm.h" 00005 #include "DQM/SiStripCommissioningSummary/interface/FastFedCablingSummaryFactory.h" 00006 #include "DQM/SiStripCommon/interface/ExtractTObject.h" 00007 #include "FWCore/MessageLogger/interface/MessageLogger.h" 00008 #include "TProfile.h" 00009 #include <iostream> 00010 #include <sstream> 00011 #include <iomanip> 00012 00013 using namespace std; 00014 using namespace sistrip; 00015 00016 // ----------------------------------------------------------------------------- 00018 FastFedCablingHistograms::FastFedCablingHistograms( DQMOldReceiver* mui ) 00019 : CommissioningHistograms( mui, sistrip::FAST_CABLING ) 00020 { 00021 factory_ = auto_ptr<FastFedCablingSummaryFactory>( new FastFedCablingSummaryFactory ); 00022 LogTrace(mlDqmClient_) 00023 << "[FastFedCablingHistograms::" << __func__ << "]" 00024 << " Constructing object..."; 00025 } 00026 00027 // ----------------------------------------------------------------------------- 00029 FastFedCablingHistograms::FastFedCablingHistograms( DQMStore* bei ) 00030 : CommissioningHistograms( bei, sistrip::FAST_CABLING ) 00031 { 00032 LogTrace(mlDqmClient_) 00033 << "[FastFedCablingHistograms::" << __func__ << "]" 00034 << " Constructing object..."; 00035 } 00036 00037 // ----------------------------------------------------------------------------- 00039 FastFedCablingHistograms::~FastFedCablingHistograms() { 00040 LogTrace(mlDqmClient_) 00041 << "[FastFedCablingHistograms::" << __func__ << "]" 00042 << " Destructing object..."; 00043 } 00044 00045 // ----------------------------------------------------------------------------- 00047 void FastFedCablingHistograms::histoAnalysis( bool debug ) { 00048 LogTrace(mlDqmClient_) 00049 << "[FastFedCablingHistograms::" << __func__ << "]"; 00050 00051 // Some initialisation 00052 uint16_t valid = 0; 00053 HistosMap::const_iterator iter; 00054 Analyses::iterator ianal; 00055 std::map<std::string,uint16_t> errors; 00056 00057 // Clear map holding analysis objects 00058 for ( ianal = data().begin(); ianal != data().end(); ianal++ ) { 00059 if ( ianal->second ) { delete ianal->second; } 00060 } 00061 data().clear(); 00062 00063 // Iterate through map containing histograms 00064 for ( iter = histos().begin(); 00065 iter != histos().end(); iter++ ) { 00066 00067 // Check vector of histos is not empty 00068 if ( iter->second.empty() ) { 00069 edm::LogWarning(mlDqmClient_) 00070 << "[FastFedCablingHistograms::" << __func__ << "]" 00071 << " Zero histograms found!"; 00072 continue; 00073 } 00074 00075 // Retrieve pointers to histos 00076 std::vector<TH1*> profs; 00077 Histos::const_iterator ihis = iter->second.begin(); 00078 for ( ; ihis != iter->second.end(); ihis++ ) { 00079 TProfile* prof = ExtractTObject<TProfile>().extract( (*ihis)->me_ ); 00080 if ( prof ) { profs.push_back(prof); } 00081 } 00082 00083 // Perform histo analysis 00084 FastFedCablingAnalysis* anal = new FastFedCablingAnalysis( iter->first ); 00085 FastFedCablingAlgorithm algo( anal ); 00086 FedToFecMap::const_iterator ifed = mapping().find( iter->first ); 00087 if ( ifed != mapping().end() ) { anal->fecKey( ifed->second ); } 00088 algo.analysis( profs ); 00089 data()[iter->first] = anal; 00090 if ( anal->isValid() ) { valid++; } 00091 if ( !anal->getErrorCodes().empty() ) { 00092 errors[anal->getErrorCodes()[0]]++; 00093 } 00094 00095 } 00096 00097 if ( !histos().empty() ) { 00098 edm::LogVerbatim(mlDqmClient_) 00099 << "[FastFedCablingHistograms::" << __func__ << "]" 00100 << " Analyzed histograms for " << histos().size() 00101 << " FED channels, of which " << valid 00102 << " (" << 100 * valid / histos().size() 00103 << "%) are valid."; 00104 if ( !errors.empty() ) { 00105 uint16_t count = 0; 00106 std::stringstream ss; 00107 ss << std::endl; 00108 std::map<std::string,uint16_t>::const_iterator ii; 00109 for ( ii = errors.begin(); ii != errors.end(); ++ii ) { 00110 ss << " " << ii->first << ": " << ii->second << std::endl; 00111 count += ii->second; 00112 } 00113 edm::LogWarning(mlDqmClient_) 00114 << "[FastFedCablingHistograms::" << __func__ << "]" 00115 << " Found " << count << " error strings: " 00116 << ss.str(); 00117 } 00118 } else { 00119 edm::LogWarning(mlDqmClient_) 00120 << "[FastFedCablingHistograms::" << __func__ << "]" 00121 << " No histograms to analyze!"; 00122 } 00123 00124 } 00125 00126 // ----------------------------------------------------------------------------- 00128 void FastFedCablingHistograms::printAnalyses() { 00129 Analyses::iterator ianal = data().begin(); 00130 Analyses::iterator janal = data().end(); 00131 for ( ; ianal != janal; ++ianal ) { 00132 00133 FastFedCablingAnalysis* anal = dynamic_cast<FastFedCablingAnalysis*>( ianal->second ); 00134 if ( !anal ) { 00135 edm::LogError(mlDqmClient_) 00136 << "[FastFedCablingHistograms::" << __func__ << "]" 00137 << " NULL pointer to analysis object!"; 00138 continue; 00139 } 00140 00141 std::stringstream ss; 00142 anal->print( ss ); 00143 if ( anal->isValid() && 00144 !(anal->isDirty()) && 00145 !(anal->badTrimDac()) ) { LogTrace(mlDqmClient_) << ss.str(); 00146 } else { edm::LogWarning(mlDqmClient_) << ss.str(); } 00147 00148 } 00149 00150 } 00151 00152 // ----------------------------------------------------------------------------- 00154 void FastFedCablingHistograms::printSummary() { 00155 00156 std::stringstream good; 00157 std::stringstream bad; 00158 00159 Analyses::iterator ianal = data().begin(); 00160 Analyses::iterator janal = data().end(); 00161 for ( ; ianal != janal; ++ianal ) { 00162 00163 FastFedCablingAnalysis* anal = dynamic_cast<FastFedCablingAnalysis*>( ianal->second ); 00164 if ( !anal ) { 00165 edm::LogError(mlDqmClient_) 00166 << "[FastFedCablingHistograms::" << __func__ << "]" 00167 << " NULL pointer to analysis object!"; 00168 continue; 00169 } 00170 00171 if ( anal->isValid() && 00172 !(anal->isDirty()) && 00173 !(anal->badTrimDac()) ) { 00174 anal->summary( good ); 00175 } else { anal->summary( bad ); } 00176 00177 } 00178 00179 if ( good.str().empty() ) { good << "None found!"; } 00180 LogTrace(mlDqmClient_) 00181 << "[FastFedCablingHistograms::" << __func__ << "]" 00182 << " Printing summary of good analyses:" << "\n" 00183 << good.str(); 00184 00185 if ( bad.str().empty() ) { return; } //@@ bad << "None found!"; } 00186 LogTrace(mlDqmClient_) 00187 << "[FastFedCablingHistograms::" << __func__ << "]" 00188 << " Printing summary of bad analyses:" << "\n" 00189 << bad.str(); 00190 00191 }