Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
#include "DQM/SiStripCommissioningSummary/interface/NoiseSummaryFactory.h"
#include "CondFormats/SiStripObjects/interface/NoiseAnalysis.h"
#include "DataFormats/SiStripCommon/interface/SiStripEnumsAndStrings.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include <iostream>
#include <sstream>

using namespace sistrip;

// -----------------------------------------------------------------------------
//
void NoiseSummaryFactory::extract(Iterator iter) {
  NoiseAnalysis* anal = dynamic_cast<NoiseAnalysis*>(iter->second);
  if (!anal) {
    return;
  }

  std::vector<float> temp(128, 1. * sistrip::invalid_);
  std::vector<std::vector<float> > value(2, temp);
  std::vector<std::vector<float> > peds(2, temp);
  std::vector<std::vector<float> > noise(2, temp);
  peds[0] = anal->peds()[0];
  peds[1] = anal->peds()[1];
  noise[0] = anal->noise()[0];
  noise[1] = anal->noise()[1];

  bool all_strips = false;
  if (mon_ == sistrip::PEDESTALS_ALL_STRIPS) {
    all_strips = true;
    uint16_t bins = peds[0].size();
    if (peds[0].size() < peds[1].size()) {
      bins = peds[1].size();
    }
    for (uint16_t iped = 0; iped < bins; iped++) {
      value[0][iped] = peds[0][iped];
      value[1][iped] = peds[1][iped];
    }
  } else if (mon_ == sistrip::PEDESTALS_MEAN) {
    value[0][0] = anal->pedsMean()[0];
    value[1][0] = anal->pedsMean()[1];
  } else if (mon_ == sistrip::PEDESTALS_SPREAD) {
    value[0][0] = anal->pedsSpread()[0];
    value[1][0] = anal->pedsSpread()[1];
  } else if (mon_ == sistrip::PEDESTALS_MAX) {
    value[0][0] = anal->pedsMax()[0];
    value[1][0] = anal->pedsMax()[1];
  } else if (mon_ == sistrip::PEDESTALS_MIN) {
    value[0][0] = anal->pedsMin()[0];
    value[1][0] = anal->pedsMin()[1];
  } else if (mon_ == sistrip::NOISE_ALL_STRIPS) {
    all_strips = true;
    uint16_t bins = noise[0].size();
    if (noise[0].size() < noise[1].size()) {
      bins = noise[1].size();
    }
    for (uint16_t inoise = 0; inoise < bins; inoise++) {
      value[0][inoise] = noise[0][inoise];
      value[1][inoise] = noise[1][inoise];
    }
  } else if (mon_ == sistrip::NOISE_MEAN) {
    value[0][0] = anal->noiseMean()[0];
    value[1][0] = anal->noiseMean()[1];
  } else if (mon_ == sistrip::NOISE_SPREAD) {
    value[0][0] = anal->noiseSpread()[0];
    value[1][0] = anal->noiseSpread()[1];
  } else if (mon_ == sistrip::NOISE_MAX) {
    value[0][0] = anal->noiseMax()[0];
    value[1][0] = anal->noiseMax()[1];
  } else if (mon_ == sistrip::NOISE_MIN) {
    value[0][0] = anal->noiseMin()[0];
    value[1][0] = anal->noiseMin()[1];
  } else if (mon_ == sistrip::NUM_OF_DEAD) {
    value[0][0] = 1. * anal->dead()[0].size();
    value[1][0] = 1. * anal->dead()[1].size();
  } else if (mon_ == sistrip::NUM_OF_NOISY) {
    value[0][0] = 1. * anal->noisy()[0].size();
    value[1][0] = 1. * anal->noisy()[1].size();
  } else {
    edm::LogWarning(mlSummaryPlots_) << "[SummaryPlotFactory::" << __func__ << "]"
                                     << " Unexpected monitorable: "
                                     << SiStripEnumsAndStrings::monitorable(SummaryPlotFactoryBase::mon_);
    return;
  }

  if (!all_strips) {
    SummaryPlotFactoryBase::generator_->fillMap(
        SummaryPlotFactoryBase::level_, SummaryPlotFactoryBase::gran_, iter->first, value[0][0]);

    SummaryPlotFactoryBase::generator_->fillMap(
        SummaryPlotFactoryBase::level_, SummaryPlotFactoryBase::gran_, iter->first, value[1][0]);

  } else {
    for (uint16_t istr = 0; istr < value[0].size(); istr++) {
      SummaryPlotFactoryBase::generator_->fillMap(
          SummaryPlotFactoryBase::level_, SummaryPlotFactoryBase::gran_, iter->first, value[0][istr]);
    }

    for (uint16_t istr = 0; istr < value[1].size(); istr++) {
      SummaryPlotFactoryBase::generator_->fillMap(
          SummaryPlotFactoryBase::level_, SummaryPlotFactoryBase::gran_, iter->first, value[1][istr]);
    }
  }
}

// -----------------------------------------------------------------------------
//
void NoiseSummaryFactory::format() {
  if (mon_ == sistrip::PEDESTALS_ALL_STRIPS) {
    generator_->axisLabel("Pedestal value [adc]");
  } else if (mon_ == sistrip::PEDESTALS_MEAN) {
  } else if (mon_ == sistrip::PEDESTALS_SPREAD) {
  } else if (mon_ == sistrip::PEDESTALS_MAX) {
  } else if (mon_ == sistrip::PEDESTALS_MIN) {
  } else if (mon_ == sistrip::NOISE_ALL_STRIPS) {
    generator_->axisLabel("Noise [adc]");
  } else if (mon_ == sistrip::NOISE_MEAN) {
  } else if (mon_ == sistrip::NOISE_SPREAD) {
  } else if (mon_ == sistrip::NOISE_MAX) {
  } else if (mon_ == sistrip::NOISE_MIN) {
  } else if (mon_ == sistrip::NUM_OF_DEAD) {
  } else if (mon_ == sistrip::NUM_OF_NOISY) {
  } else {
    edm::LogWarning(mlSummaryPlots_) << "[SummaryPlotFactory::" << __func__ << "]"
                                     << " Unexpected SummaryHisto value:"
                                     << SiStripEnumsAndStrings::monitorable(SummaryPlotFactoryBase::mon_);
  }
}