CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/DQM/SiStripCommissioningClients/src/CalibrationHistograms.cc

Go to the documentation of this file.
00001 #include "DQM/SiStripCommissioningClients/interface/CalibrationHistograms.h"
00002 #include "CondFormats/SiStripObjects/interface/CalibrationAnalysis.h"
00003 #include "DQM/SiStripCommissioningAnalysis/interface/CalibrationAlgorithm.h"
00004 #include "DQM/SiStripCommissioningSummary/interface/CalibrationSummaryFactory.h"
00005 #include "DataFormats/SiStripCommon/interface/SiStripConstants.h"
00006 #include "DQM/SiStripCommon/interface/ExtractTObject.h"
00007 #include "DQMServices/Core/interface/DQMStore.h"
00008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00009 #include <iostream>
00010 #include <sstream>
00011 #include <iomanip>
00012 #include "TH1F.h"
00013 
00014 using namespace std;
00015 using namespace sistrip;
00016 
00017 // -----------------------------------------------------------------------------
00019 CalibrationHistograms::CalibrationHistograms( const edm::ParameterSet& pset,
00020                                               DQMStore* bei,
00021                                               const sistrip::RunType& task )
00022   : CommissioningHistograms( pset.getParameter<edm::ParameterSet>("CalibrationParameters"),
00023                              bei,
00024                              task ),
00025     calchan_(0),
00026     isha_(-1),
00027     vfs_(-1)
00028 {
00029   LogTrace(mlDqmClient_) 
00030        << "[CalibrationHistograms::" << __func__ << "]"
00031        << " Constructing object...";
00032   std::string temp = std::string(sistrip::collate_) + "/" + sistrip::root_;
00033   factory_ = auto_ptr<CalibrationSummaryFactory>( new CalibrationSummaryFactory );
00034   MonitorElement* calchanElement = bei->get(temp + "/calchan");
00035   if(calchanElement) {
00036     calchan_ = calchanElement->getIntValue();
00037     edm::LogVerbatim(mlDqmClient_)
00038       << "[CalibrationHistograms::" << __func__ << "]"
00039       << "CalChan value is " << calchan_;
00040   } else {
00041     edm::LogWarning(mlDqmClient_)
00042       << "[CalibrationHistograms::" << __func__ << "]"
00043       << "CalChan value not found. Using " << calchan_;
00044   }
00045   MonitorElement* ishaElement = bei->get(temp + "/isha");
00046   if(ishaElement) isha_ = ishaElement->getIntValue() ;
00047   MonitorElement* vfsElement = bei->get(temp + "/vfs");
00048   if(vfsElement) vfs_ = vfsElement->getIntValue() ;
00049 }
00050 
00051 // -----------------------------------------------------------------------------
00053 CalibrationHistograms::~CalibrationHistograms() {
00054   LogTrace(mlDqmClient_) 
00055        << "[CalibrationHistograms::" << __func__ << "]"
00056        << " Deleting object...";
00057 }
00058 
00059 // -----------------------------------------------------------------------------         
00061 void CalibrationHistograms::histoAnalysis( bool debug ) {
00062 
00063   // Clear map holding analysis objects
00064   Analyses::iterator ianal;
00065   for ( ianal = data().begin(); ianal != data().end(); ianal++ ) {
00066     if ( ianal->second ) { delete ianal->second; }
00067   }
00068   data().clear();
00069   
00070   // Iterate through map containing vectors of profile histograms
00071   HistosMap::const_iterator iter = histos().begin();
00072   for ( ; iter != histos().end(); iter++ ) {
00073     // Check vector of histos is not empty (should be 1 histo)
00074     if ( iter->second.empty() ) {
00075       edm::LogWarning(mlDqmClient_)
00076            << "[CalibrationHistograms::" << __func__ << "]"
00077            << " Zero collation histograms found!";
00078       continue;
00079     }
00080     
00081     // Retrieve pointers to 1D histos for this FED channel 
00082     vector<TH1*> profs;
00083     Histos::const_iterator ihis = iter->second.begin();
00084     for ( ; ihis != iter->second.end(); ihis++ ) {
00085       TH1F* prof = ExtractTObject<TH1F>().extract( (*ihis)->me_ );
00086       if ( prof ) { profs.push_back(prof); }
00087     } 
00088     // Perform histo analysis 
00089     CalibrationAnalysis* anal = new CalibrationAnalysis( iter->first, (task()==sistrip::CALIBRATION_DECO), calchan_ );
00090     CalibrationAlgorithm algo( this->pset(), anal );
00091     algo.analysis( profs );
00092     data()[iter->first] = anal; 
00093     
00094  }
00095  
00096 }
00097 
00098 // -----------------------------------------------------------------------------
00100 void CalibrationHistograms::printAnalyses() {
00101   Analyses::iterator ianal = data().begin();
00102   Analyses::iterator janal = data().end();
00103   for ( ; ianal != janal; ++ianal ) {
00104     if ( ianal->second ) {
00105       std::stringstream ss;
00106       ianal->second->print( ss,0 );
00107       ianal->second->print( ss,1 );
00108       if ( ianal->second->isValid() ) { LogTrace(mlDqmClient_) << ss.str();
00109       } else { edm::LogWarning(mlDqmClient_) << ss.str(); }
00110     }
00111   }
00112 }
00113