File indexing completed on 2024-04-06 12:08:37
0001 #include "DQM/SiStripCommissioningSummary/interface/PedestalsSummaryFactory.h"
0002 #include "CondFormats/SiStripObjects/interface/PedestalsAnalysis.h"
0003 #include "DataFormats/SiStripCommon/interface/SiStripEnumsAndStrings.h"
0004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0005 #include <iostream>
0006 #include <sstream>
0007
0008 using namespace sistrip;
0009
0010
0011
0012 void PedestalsSummaryFactory::extract(Iterator iter) {
0013 PedestalsAnalysis* anal = dynamic_cast<PedestalsAnalysis*>(iter->second);
0014 if (!anal) {
0015 return;
0016 }
0017
0018 std::vector<float> temp(128, 1. * sistrip::invalid_);
0019 std::vector<std::vector<float> > value(2, temp);
0020 std::vector<std::vector<float> > peds(2, temp);
0021 std::vector<std::vector<float> > noise(2, temp);
0022 peds[0] = anal->peds()[0];
0023 peds[1] = anal->peds()[1];
0024 noise[0] = anal->noise()[0];
0025 noise[1] = anal->noise()[1];
0026
0027 bool all_strips = false;
0028 if (mon_ == sistrip::PEDESTALS_ALL_STRIPS) {
0029 all_strips = true;
0030 uint16_t bins = peds[0].size();
0031 if (peds[0].size() < peds[1].size()) {
0032 bins = peds[1].size();
0033 }
0034 for (uint16_t iped = 0; iped < bins; iped++) {
0035 value[0][iped] = peds[0][iped];
0036 value[1][iped] = peds[1][iped];
0037 }
0038 } else if (mon_ == sistrip::PEDESTALS_MEAN) {
0039 value[0][0] = anal->pedsMean()[0];
0040 value[1][0] = anal->pedsMean()[1];
0041 } else if (mon_ == sistrip::PEDESTALS_SPREAD) {
0042 value[0][0] = anal->pedsSpread()[0];
0043 value[1][0] = anal->pedsSpread()[1];
0044 } else if (mon_ == sistrip::PEDESTALS_MAX) {
0045 value[0][0] = anal->pedsMax()[0];
0046 value[1][0] = anal->pedsMax()[1];
0047 } else if (mon_ == sistrip::PEDESTALS_MIN) {
0048 value[0][0] = anal->pedsMin()[0];
0049 value[1][0] = anal->pedsMin()[1];
0050 } else if (mon_ == sistrip::NOISE_ALL_STRIPS) {
0051 all_strips = true;
0052 uint16_t bins = noise[0].size();
0053 if (noise[0].size() < noise[1].size()) {
0054 bins = noise[1].size();
0055 }
0056 for (uint16_t inoise = 0; inoise < bins; inoise++) {
0057 value[0][inoise] = noise[0][inoise];
0058 value[1][inoise] = noise[1][inoise];
0059 }
0060 } else if (mon_ == sistrip::NOISE_MEAN) {
0061 value[0][0] = anal->noiseMean()[0];
0062 value[1][0] = anal->noiseMean()[1];
0063 } else if (mon_ == sistrip::NOISE_SPREAD) {
0064 value[0][0] = anal->noiseSpread()[0];
0065 value[1][0] = anal->noiseSpread()[1];
0066 } else if (mon_ == sistrip::NOISE_MAX) {
0067 value[0][0] = anal->noiseMax()[0];
0068 value[1][0] = anal->noiseMax()[1];
0069 } else if (mon_ == sistrip::NOISE_MIN) {
0070 value[0][0] = anal->noiseMin()[0];
0071 value[1][0] = anal->noiseMin()[1];
0072 } else if (mon_ == sistrip::NUM_OF_DEAD) {
0073 value[0][0] = 1. * anal->dead()[0].size();
0074 value[1][0] = 1. * anal->dead()[1].size();
0075 } else if (mon_ == sistrip::NUM_OF_NOISY) {
0076 value[0][0] = 1. * anal->noisy()[0].size();
0077 value[1][0] = 1. * anal->noisy()[1].size();
0078 } else {
0079 edm::LogWarning(mlSummaryPlots_) << "[SummaryPlotFactory::" << __func__ << "]"
0080 << " Unexpected monitorable: "
0081 << SiStripEnumsAndStrings::monitorable(SummaryPlotFactoryBase::mon_);
0082 return;
0083 }
0084
0085 if (!all_strips) {
0086 SummaryPlotFactoryBase::generator_->fillMap(
0087 SummaryPlotFactoryBase::level_, SummaryPlotFactoryBase::gran_, iter->first, value[0][0]);
0088
0089 SummaryPlotFactoryBase::generator_->fillMap(
0090 SummaryPlotFactoryBase::level_, SummaryPlotFactoryBase::gran_, iter->first, value[1][0]);
0091
0092 } else {
0093 for (uint16_t istr = 0; istr < value[0].size(); istr++) {
0094 SummaryPlotFactoryBase::generator_->fillMap(
0095 SummaryPlotFactoryBase::level_, SummaryPlotFactoryBase::gran_, iter->first, value[0][istr]);
0096 }
0097
0098 for (uint16_t istr = 0; istr < value[1].size(); istr++) {
0099 SummaryPlotFactoryBase::generator_->fillMap(
0100 SummaryPlotFactoryBase::level_, SummaryPlotFactoryBase::gran_, iter->first, value[1][istr]);
0101 }
0102 }
0103 }
0104
0105
0106
0107 void PedestalsSummaryFactory::format() {
0108 if (mon_ == sistrip::PEDESTALS_ALL_STRIPS) {
0109 generator_->axisLabel("Pedestal value [adc]");
0110 } else if (mon_ == sistrip::PEDESTALS_MEAN) {
0111 } else if (mon_ == sistrip::PEDESTALS_SPREAD) {
0112 } else if (mon_ == sistrip::PEDESTALS_MAX) {
0113 } else if (mon_ == sistrip::PEDESTALS_MIN) {
0114 } else if (mon_ == sistrip::NOISE_ALL_STRIPS) {
0115 generator_->axisLabel("Noise [adc]");
0116 } else if (mon_ == sistrip::NOISE_MEAN) {
0117 } else if (mon_ == sistrip::NOISE_SPREAD) {
0118 } else if (mon_ == sistrip::NOISE_MAX) {
0119 } else if (mon_ == sistrip::NOISE_MIN) {
0120 } else if (mon_ == sistrip::NUM_OF_DEAD) {
0121 } else if (mon_ == sistrip::NUM_OF_NOISY) {
0122 } else {
0123 edm::LogWarning(mlSummaryPlots_) << "[SummaryPlotFactory::" << __func__ << "]"
0124 << " Unexpected SummaryHisto value:"
0125 << SiStripEnumsAndStrings::monitorable(SummaryPlotFactoryBase::mon_);
0126 }
0127 }