: Fills summary histograms. More...
#include <SummaryGenerator.h>
Public Types | |
typedef std::vector< Data > | BinData |
typedef std::pair< float, float > | Data |
typedef std::map< std::string, BinData > | HistoData |
Public Member Functions | |
void | axisLabel (const std::string &) |
void | clearMap () |
void | fillMap (const std::string &top_level_dir, const sistrip::Granularity &, const uint32_t &key, const float &value, const float &error=0.) |
void | format (const sistrip::RunType &, const sistrip::Monitorable &, const sistrip::Presentation &, const sistrip::View &, const std::string &directory, const sistrip::Granularity &, TH1 &) |
void | histo1D (TH1 &) |
void | histo2DScatter (TH1 &) |
void | histo2DSum (TH1 &) |
const std::string & | myName () const |
uint32_t | nBins () const |
void | printMap () |
void | profile1D (TH1 &) |
uint32_t | size () const |
SummaryGenerator (std::string name) | |
virtual | ~SummaryGenerator () |
Static Public Member Functions | |
static TH1 * | histogram (const sistrip::Presentation &, const uint32_t &xbins) |
static SummaryGenerator * | instance (const sistrip::View &) |
static std::string | name (const sistrip::RunType &, const sistrip::Monitorable &, const sistrip::Presentation &, const sistrip::View &, const std::string &directory) |
Protected Member Functions | |
virtual void | fill (const std::string &top_level_dir, const sistrip::Granularity &, const uint32_t &key, const float &value, const float &error) |
Protected Attributes | |
float | entries_ |
std::string | label_ |
HistoData | map_ |
float | max_ |
float | min_ |
Private Attributes | |
std::string | myName_ |
: Fills summary histograms.
Definition at line 19 of file SummaryGenerator.h.
typedef std::vector<Data> SummaryGenerator::BinData |
Definition at line 30 of file SummaryGenerator.h.
typedef std::pair<float,float> SummaryGenerator::Data |
Definition at line 29 of file SummaryGenerator.h.
typedef std::map<std::string,BinData> SummaryGenerator::HistoData |
Definition at line 31 of file SummaryGenerator.h.
SummaryGenerator::SummaryGenerator | ( | std::string | name | ) |
Definition at line 16 of file SummaryGenerator.cc.
: map_(), entries_(-1.), max_(-1.*sistrip::invalid_), min_(1.*sistrip::invalid_), label_(""), myName_(name) { // TH1::SetDefaultSumw2(true); // use square of weights to calc error }
virtual SummaryGenerator::~SummaryGenerator | ( | ) | [inline, virtual] |
Definition at line 26 of file SummaryGenerator.h.
{;}
void SummaryGenerator::axisLabel | ( | const std::string & | label | ) | [inline] |
Optionally set axis label
Definition at line 142 of file SummaryGenerator.h.
Referenced by SummaryHistogramFactory< DaqScopeModeAnalysis >::fill(), SummaryPlotFactory< FedCablingAnalysis * >::fill(), ApvTimingSummaryFactory::format(), and FastFedCablingSummaryFactory::format().
void SummaryGenerator::clearMap | ( | ) |
Clear the map that is used to generate the histogram(s).
Definition at line 195 of file SummaryGenerator.cc.
References entries_, sistrip::invalid_, map_, max_, and min_.
Referenced by SummaryHistogramFactory< DaqScopeModeAnalysis >::extract(), SummaryHistogramFactory< FedTimingAnalysis >::extract(), and SummaryPlotFactoryBase::init().
{ HistoData::iterator iter = map_.begin(); for ( ; iter != map_.end(); iter++ ) { iter->second.clear(); } map_.clear(); entries_ = -1.; max_ = -1.*sistrip::invalid_; min_ = 1.*sistrip::invalid_; }
void SummaryGenerator::fill | ( | const std::string & | top_level_dir, |
const sistrip::Granularity & | gran, | ||
const uint32_t & | key, | ||
const float & | value, | ||
const float & | error | ||
) | [protected, virtual] |
Fills the map used to generate the histogram.
Reimplemented in SummaryGeneratorControlView, and SummaryGeneratorReadoutView.
Definition at line 258 of file SummaryGenerator.cc.
References LogTrace, and sistrip::mlSummaryPlots_.
Referenced by fillMap().
{ LogTrace(mlSummaryPlots_) << "[SummaryGenerator::" << __func__ << "]" << " Derived implementation does not exist!..."; }
void SummaryGenerator::fillMap | ( | const std::string & | top_level_dir, |
const sistrip::Granularity & | gran, | ||
const uint32_t & | key, | ||
const float & | value, | ||
const float & | error = 0. |
||
) |
Fills the map that is used to generate the histogram(s).
Definition at line 234 of file SummaryGenerator.cc.
References fill(), max_, min_, sistrip::valid_, and relativeConstraints::value.
Referenced by ApvTimingSummaryFactory::extract(), PedsFullNoiseSummaryFactory::extract(), PedsOnlySummaryFactory::extract(), FastFedCablingSummaryFactory::extract(), NoiseSummaryFactory::extract(), OptoScanSummaryFactory::extract(), CalibrationSummaryFactory::extract(), SummaryHistogramFactory< DaqScopeModeAnalysis >::extract(), SummaryHistogramFactory< FedTimingAnalysis >::extract(), PedestalsSummaryFactory::extract(), VpspScanSummaryFactory::extract(), SummaryPlotFactory< FedCablingAnalysis * >::init(), and SummaryPlotFactory< T >::init().
{ // Check if value is valid if ( value > 1. * sistrip::valid_ ) { return; } // Calculate maximum and minimum values in std::map if ( value > max_ ) { max_ = value; } if ( value < min_ ) { min_ = value; } // Check if error is valid if ( error < 1. * sistrip::valid_ ) { fill( top_level_dir, gran, device_key, value, error ); } else { fill( top_level_dir, gran, device_key, value, 0. ); } }
void SummaryGenerator::format | ( | const sistrip::RunType & | run_type, |
const sistrip::Monitorable & | mon, | ||
const sistrip::Presentation & | pres, | ||
const sistrip::View & | view, | ||
const std::string & | directory, | ||
const sistrip::Granularity & | gran, | ||
TH1 & | summary_histo | ||
) |
Some generic formatting of histogram.
Definition at line 117 of file SummaryGenerator.cc.
References createBeamHaloJobs::directory, entries_, SiStripEnumsAndStrings::granularity(), sistrip::HISTO_1D, sistrip::HISTO_2D_SCATTER, sistrip::HISTO_2D_SUM, label_, and sistrip::PROFILE_1D.
Referenced by SummaryHistogramFactory< DaqScopeModeAnalysis >::fill(), SummaryHistogramFactory< FedTimingAnalysis >::fill(), and SummaryPlotFactoryBase::fill().
{ // Set name, title and entries //std::stringstream ss; //std::string name = SummaryGenerator::name( run_type, mon, pres, view, directory ); //summary_histo.SetName( name.c_str() ); //summary_histo.SetTitle( name.c_str() ); if ( entries_ >= 0. ) { summary_histo.SetEntries( entries_ ); } // X axis summary_histo.GetXaxis()->SetLabelSize(0.03); summary_histo.GetXaxis()->SetTitleSize(0.03); summary_histo.GetXaxis()->SetTitleOffset(3.5); //gPad->SetBottomMargin(0.2); // Y axis summary_histo.GetYaxis()->SetLabelSize(0.03); summary_histo.GetYaxis()->SetTitleSize(0.03); summary_histo.GetYaxis()->SetTitleOffset(1.5); //gPad->SetLeftMargin(0.2); // Axis label if ( pres == sistrip::HISTO_1D ) { std::string xtitle = label_ + " (for " + directory + ")"; summary_histo.GetXaxis()->SetTitle( xtitle.c_str() ); summary_histo.GetYaxis()->SetTitle( "Frequency" ); summary_histo.GetXaxis()->SetTitleOffset(1.5); //@@ override value set above } else { std::string xtitle = SiStripEnumsAndStrings::granularity( gran ) + " within " + directory; summary_histo.GetXaxis()->SetTitle( xtitle.c_str() ); summary_histo.GetYaxis()->SetTitle( label_.c_str() ); //summary_histo.GetXaxis()->SetTitleOffset(1.5); //@@ override value set above (3.5?) } // Formatting for 2D plots if ( pres == sistrip::HISTO_2D_SCATTER ) { // Markers (open circles) summary_histo.SetMarkerStyle(2); summary_histo.SetMarkerSize(0.6); } // Semi-generic formatting if ( pres == sistrip::HISTO_2D_SUM || pres == sistrip::HISTO_2D_SCATTER || pres == sistrip::PROFILE_1D ) { /* //put solid and dotted lines on summary to separate top- and //2nd-from-top- level bin groups. uint16_t topLevel = 0, topLevelOld = 0, secondLevel = 0, secondLevelOld = 0; std::string::size_type pos = 0; for ( HistoData::iterator ibin = map_.begin(); ibin != map_.end(); ibin++) { //draw line if top and second level numbers change. pos = ibin->first.find(sistrip::dot_,0); if (pos != std::string::npos) { if ((topLevel=atoi(std::string(ibin->first,0,pos).c_str())) != topLevelOld) { topLevel = topLevelOld; // } else if (ibin->first.find(sistrip::dot_,pos+1) != std::string::npos) { if ((secondLevelOld=atoi(std::string(ibin->first,pos+1,(ibin->first.find(sistrip::dot_,pos+1)- (pos+1))).c_str())) != secondLevel) { secondLevel = secondLevelOld; // }}} } */ } }
void SummaryGenerator::histo1D | ( | TH1 & | his | ) |
Creates simple 1D histogram of the parameter values.
Definition at line 271 of file SummaryGenerator.cc.
References entries_, timingPdfMaker::histo, map_, max_, min_, and sistrip::mlSummaryPlots_.
Referenced by SummaryHistogramFactory< DaqScopeModeAnalysis >::fill(), SummaryHistogramFactory< FedTimingAnalysis >::fill(), and SummaryPlotFactoryBase::fill().
{ // Check number of entries in map if ( map_.empty() ) { edm::LogWarning(mlSummaryPlots_) << "[SummaryGenerator::" << __func__ << "]" << " No contents in std::map to histogram!"; return; } // Retrieve histogram TH1F* histo = dynamic_cast<TH1F*>(&his); if ( !histo ) { edm::LogWarning(mlSummaryPlots_) << "[SummaryGenerator::" << __func__ << "]" << " NULL pointer to TH1F histogram!"; return; } // Calculate bin range int32_t high = static_cast<int32_t>( fabs(max_) > 20. ? max_ + 0.05 * fabs(max_) : max_ + 1. ); int32_t low = static_cast<int32_t>( fabs(min_) > 20. ? min_ - 0.05 * fabs(min_) : min_ - 1. ); int32_t range = high - low; // increase number of bins for floats // if ( max_ - static_cast<int32_t>(max_) > 1.e-6 && // min_ - static_cast<int32_t>(min_) > 1.e-6 ) { // range = 100 * range; // } // Set histogram binning histo->SetBins( range, static_cast<float>(low), static_cast<float>(high) ); // Iterate through std::map, set bin labels and fill histogram entries_ = 0.; HistoData::const_iterator ibin = map_.begin(); for ( ; ibin != map_.end(); ibin++ ) { if ( ibin->second.empty() ) { continue; } BinData::const_iterator ii = ibin->second.begin(); for ( ; ii != ibin->second.end(); ii++ ) { // bin (value) and weight (error) histo->Fill( ii->first ); //, ii->second ); entries_++; } } }
void SummaryGenerator::histo2DScatter | ( | TH1 & | his | ) |
Creates a 2D scatter histogram, with individual values of the parameter (y-axis) binned as a function of position within the given logical structure, which is view-dependent (x-axis).
Definition at line 361 of file SummaryGenerator.cc.
References newFWLiteAna::bin, entries_, timingPdfMaker::histo, map_, and sistrip::mlSummaryPlots_.
Referenced by SummaryHistogramFactory< DaqScopeModeAnalysis >::fill(), SummaryHistogramFactory< FedTimingAnalysis >::fill(), and SummaryPlotFactoryBase::fill().
{ // Check number of entries in map if ( map_.empty() ) { edm::LogWarning(mlSummaryPlots_) << "[SummaryGenerator::" << __func__ << "]" << " No contents in std::map to histogram!"; return; } // Retrieve histogram TH2F* histo = dynamic_cast<TH2F*>(&his); if ( !histo ) { edm::LogWarning(mlSummaryPlots_) << "[SummaryGenerator::" << __func__ << "]" << " NULL pointer to TH2F histogram!"; return; } // Iterate through std::map, set bin labels and fill histogram entries_ = 0.; uint16_t bin = 0; HistoData::const_iterator ibin = map_.begin(); for ( ; ibin != map_.end(); ibin++ ) { bin++; histo->GetXaxis()->SetBinLabel( static_cast<Int_t>(bin), ibin->first.c_str() ); if ( ibin->second.empty() ) { continue; } BinData::const_iterator ii = ibin->second.begin(); for ( ; ii != ibin->second.end(); ii++ ) { // x (bin), y (value) and weight (error) histo->Fill( static_cast<Double_t>(bin-0.5), static_cast<Double_t>(ii->first) ); // , ii->second ); entries_++; } } }
void SummaryGenerator::histo2DSum | ( | TH1 & | his | ) |
Creates a 1D histogram, with the weighted sum of the parameter (y-axis) binned as a function of position within the given logical structure, which is view-dependent (x-axis).
Definition at line 321 of file SummaryGenerator.cc.
References newFWLiteAna::bin, entries_, timingPdfMaker::histo, map_, and sistrip::mlSummaryPlots_.
Referenced by SummaryHistogramFactory< DaqScopeModeAnalysis >::fill(), SummaryHistogramFactory< FedTimingAnalysis >::fill(), and SummaryPlotFactoryBase::fill().
{ // Check number of entries in map if ( map_.empty() ) { edm::LogWarning(mlSummaryPlots_) << "[SummaryGenerator::" << __func__ << "]" << " No contents in std::map to histogram!"; return; } // Retrieve histogram TH1F* histo = dynamic_cast<TH1F*>(&his); if ( !histo ) { edm::LogWarning(mlSummaryPlots_) << "[SummaryGenerator::" << __func__ << "]" << " NULL pointer to TH1F histogram!"; return; } // Iterate through map, set bin labels and fill histogram entries_ = 0.; uint16_t bin = 0; HistoData::const_iterator ibin = map_.begin(); for ( ; ibin != map_.end(); ibin++ ) { bin++; histo->GetXaxis()->SetBinLabel( static_cast<Int_t>(bin), ibin->first.c_str() ); if ( ibin->second.empty() ) { continue; } BinData::const_iterator ii = ibin->second.begin(); for ( ; ii != ibin->second.end(); ii++ ) { // x (bin), y (value) and weight (error) histo->Fill( static_cast<Double_t>(bin-0.5), static_cast<Double_t>(ii->first) ); //, ii->second ); entries_ += 1. * ii->first; } } }
TH1 * SummaryGenerator::histogram | ( | const sistrip::Presentation & | pres, |
const uint32_t & | xbins | ||
) | [static] |
Creates instance of derived class based on view parameter.
Definition at line 83 of file SummaryGenerator.cc.
References sistrip::HISTO_1D, sistrip::HISTO_2D_SCATTER, sistrip::HISTO_2D_SUM, LogTrace, sistrip::mlSummaryPlots_, SiStripEnumsAndStrings::presentation(), sistrip::PROFILE_1D, and edmLumisInFiles::summary.
{ if ( !xbins ) { return 0; } TH1* summary = 0; if ( pres == sistrip::HISTO_1D ) { summary = new TH1F( "", "", 1024, 0., static_cast<float>(1024) ); } else if ( pres == sistrip::HISTO_2D_SUM ) { summary = new TH1F( "", "", xbins, 0., static_cast<float>(xbins) ); } else if ( pres == sistrip::HISTO_2D_SCATTER ) { summary = new TH2F( "", "", 100*xbins, 0., static_cast<float>(100*xbins), 1025, 0., 1025. ); } else if ( pres == sistrip::PROFILE_1D ) { summary = new TProfile( "", "", xbins, 0., static_cast<float>(xbins), 0., 1025. ); } else { summary = 0; } if ( summary ) { LogTrace(mlSummaryPlots_) << "[SummaryGenerator::" << __func__ << "]" << " Histogram name: \"" << summary->GetName() << "\""; } else { edm::LogVerbatim(mlSummaryPlots_) << "[SummaryGenerator::" << __func__ << "]" << " Unexpected presentation: \"" << SiStripEnumsAndStrings::presentation( pres ) << "\" Unable to build summary plot!" << " Returning NULL pointer!"; } return summary; }
SummaryGenerator * SummaryGenerator::instance | ( | const sistrip::View & | view | ) | [static] |
Creates instance of derived class based on view parameter.
Definition at line 29 of file SummaryGenerator.cc.
References sistrip::CONTROL_VIEW, python::IdGenerator::generator, LogTrace, sistrip::mlSummaryPlots_, myName(), sistrip::READOUT_VIEW, and SiStripEnumsAndStrings::view().
Referenced by SummaryHistogramFactory< T >::init().
{ SummaryGenerator* generator = 0; if ( view == sistrip::CONTROL_VIEW ) { generator = new SummaryGeneratorControlView(); } else if ( view == sistrip::READOUT_VIEW ) { generator = new SummaryGeneratorReadoutView(); } else { generator = 0; } if ( generator ) { LogTrace(mlSummaryPlots_) << "[SummaryGenerator::" << __func__ << "]" << " Built \"" << generator->myName() << "\" object!"; } else { edm::LogWarning(mlSummaryPlots_) << "[SummaryGenerator::" << __func__ << "]" << " Unexpected view: \"" << SiStripEnumsAndStrings::view( view ) << "\" Unable to build Generator!" << " Returning NULL pointer!"; } return generator; }
const std::string & SummaryGenerator::myName | ( | void | ) | const [inline] |
Returns name of generator object.
Definition at line 140 of file SummaryGenerator.h.
References myName_.
Referenced by instance().
{ return myName_; }
std::string SummaryGenerator::name | ( | const sistrip::RunType & | run_type, |
const sistrip::Monitorable & | mon, | ||
const sistrip::Presentation & | pres, | ||
const sistrip::View & | view, | ||
const std::string & | directory | ||
) | [static] |
Constructs the summary histogram name.
Definition at line 57 of file SummaryGenerator.cc.
References SiStripEnumsAndStrings::monitorable(), SiStripEnumsAndStrings::presentation(), environment_file_cff::runType, sistrip::sep_, sistrip::summaryHisto_, and SiStripEnumsAndStrings::view().
{ std::stringstream ss; ss << sistrip::summaryHisto_ << sistrip::sep_; ss << SiStripEnumsAndStrings::presentation( pres ) << sistrip::sep_; ss << SiStripEnumsAndStrings::runType( run_type ) << sistrip::sep_; ss << SiStripEnumsAndStrings::view( view ) << sistrip::sep_; ss << SiStripEnumsAndStrings::monitorable( mon ); //LogTrace(mlSummaryPlots_) //<< "[SummaryGenerator::" << __func__ << "]" //<< " Histogram name: \"" << ss.str() << "\""; return ss.str(); }
uint32_t SummaryGenerator::nBins | ( | ) | const [inline] |
Retrieve size of map (ie, number of bins).
Definition at line 141 of file SummaryGenerator.h.
References map_.
Referenced by SummaryPlotFactoryBase::fill(), SummaryPlotFactory< FedCablingAnalysis * >::init(), SummaryPlotFactory< CommissioningAnalysis * >::init(), SummaryPlotFactory< T >::init(), and size().
{ return map_.size(); }
void SummaryGenerator::printMap | ( | ) |
Print contents of map used to generate the histogram(s).
Definition at line 206 of file SummaryGenerator.cc.
References LogTrace, map_, max_, min_, and sistrip::mlSummaryPlots_.
{ std::stringstream ss; ss << "[SummaryGenerator::" << __func__ << "]" << " Printing contents of map: " << std::endl; HistoData::iterator iter = map_.begin(); for ( ; iter != map_.end(); iter++ ) { ss << " bin/entries: " << iter->first << "/" << iter->second.size() << " "; if ( !iter->second.empty() ) { ss << " value/error: "; std::vector<Data>::const_iterator jter = iter->second.begin(); for ( ; jter != iter->second.end(); jter++ ) { ss << jter->first << "/" << jter->second << " "; } } ss << std::endl; } ss << " Max value: " << max_ << std::endl << " Min value: " << min_ << std::endl; LogTrace(mlSummaryPlots_) << ss.str(); }
void SummaryGenerator::profile1D | ( | TH1 & | his | ) |
Creates a profile histogram, with the mean and spread of the parameter (y-axis) binned as a function of position within the given logical structure, which is view-dependent (x-axis).
Definition at line 401 of file SummaryGenerator.cc.
References newFWLiteAna::bin, entries_, timingPdfMaker::histo, map_, and sistrip::mlSummaryPlots_.
Referenced by SummaryHistogramFactory< DaqScopeModeAnalysis >::fill(), SummaryHistogramFactory< FedTimingAnalysis >::fill(), and SummaryPlotFactoryBase::fill().
{ // Check number of entries in map if ( map_.empty() ) { edm::LogWarning(mlSummaryPlots_) << "[SummaryGenerator::" << __func__ << "]" << " No contents in std::map to histogram!"; return; } // Retrieve histogram TProfile* histo = dynamic_cast<TProfile*>(&his); if ( !histo ) { edm::LogWarning(mlSummaryPlots_) << "[SummaryGenerator::" << __func__ << "]" << " NULL pointer to TProfile histogram!"; return; } // Iterate through std::map, set bin labels and fill histogram entries_ = 0.; uint16_t bin = 0; HistoData::const_iterator ibin = map_.begin(); for ( ; ibin != map_.end(); ibin++ ) { bin++; histo->GetXaxis()->SetBinLabel( static_cast<Int_t>(bin), ibin->first.c_str() ); if ( ibin->second.empty() ) { continue; } BinData::const_iterator ii = ibin->second.begin(); for ( ; ii != ibin->second.end(); ii++ ) { // x (bin), y (value) and weight (error) histo->Fill( static_cast<Double_t>(bin-.5), static_cast<Double_t>(ii->first) ); //, ii->second ); entries_++; } } }
uint32_t SummaryGenerator::size | ( | void | ) | const [inline] |
Definition at line 98 of file SummaryGenerator.h.
References nBins().
Referenced by SummaryHistogramFactory< DaqScopeModeAnalysis >::extract(), SummaryHistogramFactory< FedTimingAnalysis >::extract(), SummaryHistogramFactory< DaqScopeModeAnalysis >::fill(), and SummaryHistogramFactory< FedTimingAnalysis >::fill().
{ return nBins(); } //@@ TEMPORARY!!!
float SummaryGenerator::entries_ [protected] |
Definition at line 124 of file SummaryGenerator.h.
Referenced by clearMap(), SummaryGeneratorReadoutView::fill(), SummaryGeneratorControlView::fill(), format(), histo1D(), histo2DScatter(), histo2DSum(), and profile1D().
std::string SummaryGenerator::label_ [protected] |
Definition at line 130 of file SummaryGenerator.h.
Referenced by axisLabel(), and format().
HistoData SummaryGenerator::map_ [protected] |
A map designed to holds a set of values. The map containing these values should be indexed by a key.
Definition at line 122 of file SummaryGenerator.h.
Referenced by clearMap(), SummaryGeneratorReadoutView::fill(), SummaryGeneratorControlView::fill(), histo1D(), histo2DScatter(), histo2DSum(), nBins(), printMap(), and profile1D().
float SummaryGenerator::max_ [protected] |
Definition at line 126 of file SummaryGenerator.h.
Referenced by clearMap(), fillMap(), histo1D(), and printMap().
float SummaryGenerator::min_ [protected] |
Definition at line 128 of file SummaryGenerator.h.
Referenced by clearMap(), fillMap(), histo1D(), and printMap().
std::string SummaryGenerator::myName_ [private] |
Definition at line 136 of file SummaryGenerator.h.
Referenced by myName().