00001 #include "DQM/SiStripCommissioningClients/interface/SamplingHistograms.h" 00002 #include "CondFormats/SiStripObjects/interface/SamplingAnalysis.h" 00003 #include "DataFormats/SiStripCommon/interface/SiStripConstants.h" 00004 #include "DataFormats/SiStripCommon/interface/SiStripEnumsAndStrings.h" 00005 #include "DQM/SiStripCommissioningAnalysis/interface/SamplingAlgorithm.h" 00006 #include "DQM/SiStripCommissioningSummary/interface/SummaryGenerator.h" 00007 #include "DQM/SiStripCommon/interface/ExtractTObject.h" 00008 #include "FWCore/MessageLogger/interface/MessageLogger.h" 00009 #include <iostream> 00010 #include <sstream> 00011 #include <iomanip> 00012 #include "TProfile.h" 00013 00014 using namespace std; 00015 using namespace sistrip; 00016 00017 // ----------------------------------------------------------------------------- 00019 SamplingHistograms::SamplingHistograms( const edm::ParameterSet& pset, 00020 DQMStore* bei, 00021 const sistrip::RunType& task ) 00022 : CommissioningHistograms( pset.getParameter<edm::ParameterSet>("SamplingParameters"), 00023 bei, 00024 task ), 00025 sOnCut_(3) 00026 { 00027 LogTrace(mlDqmClient_) 00028 << "[SamplingHistograms::" << __func__ << "]" 00029 << " Constructing object..."; 00030 factory_ = auto_ptr<SamplingSummaryFactory>( new SamplingSummaryFactory ); 00031 // retreive the latency code from the root file 00032 std::string dataPath = std::string(sistrip::collate_) + "/" + sistrip::root_ + "/latencyCode"; 00033 MonitorElement* codeElement = bei->get(dataPath); 00034 if(codeElement) latencyCode_ = codeElement->getIntValue() ; 00035 else latencyCode_ = 0; 00036 } 00037 00038 // ----------------------------------------------------------------------------- 00040 SamplingHistograms::~SamplingHistograms() { 00041 LogTrace(mlDqmClient_) 00042 << "[SamplingHistograms::" << __func__ << "]" 00043 << " Deleting object..."; 00044 } 00045 00046 // ----------------------------------------------------------------------------- 00048 void SamplingHistograms::histoAnalysis( bool debug ) { 00049 00050 // Clear map holding analysis objects 00051 Analyses::iterator ianal; 00052 for ( ianal = data().begin(); ianal != data().end(); ianal++ ) { 00053 if ( ianal->second ) { delete ianal->second; } 00054 } 00055 data().clear(); 00056 00057 // Iterate through map containing vectors of profile histograms 00058 HistosMap::const_iterator iter = histos().begin(); 00059 for ( ; iter != histos().end(); iter++ ) { 00060 // Check vector of histos is not empty (should be 1 histo) 00061 if ( iter->second.empty() ) { 00062 edm::LogWarning(mlDqmClient_) 00063 << "[SamplingHistograms::" << __func__ << "]" 00064 << " Zero collation histograms found!"; 00065 continue; 00066 } 00067 00068 // Retrieve pointers to profile histos for this FED channel 00069 vector<TH1*> profs; 00070 Histos::const_iterator ihis = iter->second.begin(); 00071 for ( ; ihis != iter->second.end(); ihis++ ) { 00072 TProfile* prof = ExtractTObject<TProfile>().extract( (*ihis)->me_ ); 00073 if ( prof ) { profs.push_back(prof); } 00074 } 00075 00076 // Perform histo analysis 00077 SamplingAnalysis* anal = new SamplingAnalysis( iter->first ); 00078 anal->setSoNcut(sOnCut_); 00079 SamplingAlgorithm algo( this->pset(), anal, latencyCode_ ); 00080 algo.analysis( profs ); 00081 data()[iter->first] = anal; 00082 00083 } 00084 00085 } 00086 00087 void SamplingHistograms::configure( const edm::ParameterSet& pset, const edm::EventSetup& ) 00088 { 00089 //TODO: should use the parameter set. Why is this crashing ??? 00090 // sOnCut_ = pset.getParameter<double>("SignalToNoiseCut"); 00091 sOnCut_ = 3.; 00092 } 00093