SiStripThresholdTest

SiStripThresholdValueHigh

SiStripThresholdValueLow

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 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
/*!
  \file SiStripThreshold_PayloadInspector
  \Payload Inspector Plugin for SiStrip Threshold 
  \author J. Prisciandaro
  \version $Revision: 1.0 $
  \date $Date: 2018/02/22 $
*/

#include "CondCore/Utilities/interface/PayloadInspectorModule.h"
#include "CondCore/Utilities/interface/PayloadInspector.h"
#include "CondCore/CondDB/interface/Time.h"

// the data format of the condition to be inspected
#include "CondFormats/SiStripObjects/interface/SiStripThreshold.h"
#include "DataFormats/DetId/interface/DetId.h"
#include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
#include "CondFormats/SiStripObjects/interface/SiStripDetSummary.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

// needed for the tracker map
#include "CommonTools/TrackerMap/interface/TrackerMap.h"

// auxilliary functions
#include "CondCore/SiStripPlugins/interface/SiStripPayloadInspectorHelper.h"
#include "CalibTracker/StandaloneTrackerTopology/interface/StandaloneTrackerTopology.h"

#include "CalibTracker/SiStripCommon/interface/SiStripDetInfoFileReader.h"

#include <memory>
#include <sstream>
#include <iostream>

// include ROOT
#include "TH2F.h"
#include "TLegend.h"
#include "TCanvas.h"
#include "TLine.h"
#include "TStyle.h"
#include "TLatex.h"
#include "TPave.h"
#include "TPaveStats.h"

using namespace std;

namespace {

  using namespace cond::payloadInspector;

  /************************************************
    test class
  *************************************************/

  class SiStripThresholdTest : public Histogram1D<SiStripThreshold, SINGLE_IOV> {
  public:
    SiStripThresholdTest()
        : Histogram1D<SiStripThreshold, SINGLE_IOV>("SiStrip Threshold test", "SiStrip Threshold test", 10, 0.0, 10.0),
          m_trackerTopo{StandaloneTrackerTopology::fromTrackerParametersXMLFile(
              edm::FileInPath("Geometry/TrackerCommonData/data/trackerParameters.xml").fullPath())} {}

    bool fill() override {
      auto tag = PlotBase::getTag<0>();
      for (auto const& iov : tag.iovs) {
        std::shared_ptr<SiStripThreshold> payload = Base::fetchPayload(std::get<1>(iov));
        if (payload.get()) {
          fillWithValue(1.);

          std::stringstream ss;
          ss << "Summary of strips threshold:" << std::endl;

          payload->printSummary(ss, &m_trackerTopo);

          std::vector<uint32_t> detid;
          payload->getDetIds(detid);

          std::cout << ss.str() << std::endl;
        }
      }
      return true;
    }  // fill
  private:
    TrackerTopology m_trackerTopo;
  };

  /************************************************************
    1d histogram of SiStripThresholds of 1 IOV - High Threshold 
  *************************************************************/

  class SiStripThresholdValueHigh : public Histogram1D<SiStripThreshold, SINGLE_IOV> {
  public:
    SiStripThresholdValueHigh()
        : Histogram1D<SiStripThreshold, SINGLE_IOV>("SiStrip High threshold values (checked per APV)",
                                                    "SiStrip High threshold values (cheched per APV)",
                                                    10,
                                                    0.0,
                                                    10) {}
    bool fill() override {
      auto tag = PlotBase::getTag<0>();
      const auto detInfo =
          SiStripDetInfoFileReader::read(edm::FileInPath(SiStripDetInfoFileReader::kDefaultFile).fullPath());
      for (auto const& iov : tag.iovs) {
        std::shared_ptr<SiStripThreshold> payload = Base::fetchPayload(std::get<1>(iov));
        if (payload.get()) {
          std::vector<uint32_t> detid;
          payload->getDetIds(detid);

          for (const auto& d : detid) {
            //std::cout<<d<<std::endl;
            SiStripThreshold::Range range = payload->getRange(d);

            int nAPVs = detInfo.getNumberOfApvsAndStripLength(d).first;

            for (int it = 0; it < nAPVs; ++it) {
              auto hth = payload->getData(it * 128, range).getHth();
              //std::cout<<hth<<std::endl;
              fillWithValue(hth);
            }
          }
        }
      }

      return true;
    }
  };

  /************************************************************
    1d histogram of SiStripThresholds of 1 IOV - Low Threshold 
  *************************************************************/

  class SiStripThresholdValueLow : public Histogram1D<SiStripThreshold, SINGLE_IOV> {
  public:
    SiStripThresholdValueLow()
        : Histogram1D<SiStripThreshold, SINGLE_IOV>("SiStrip Low threshold values (checked per APV)",
                                                    "SiStrip Low threshold values (cheched per APV)",
                                                    10,
                                                    0.0,
                                                    10) {}
    bool fill() override {
      auto tag = PlotBase::getTag<0>();
      const auto detInfo =
          SiStripDetInfoFileReader::read(edm::FileInPath(SiStripDetInfoFileReader::kDefaultFile).fullPath());
      for (auto const& iov : tag.iovs) {
        std::shared_ptr<SiStripThreshold> payload = Base::fetchPayload(std::get<1>(iov));
        if (payload.get()) {
          std::vector<uint32_t> detid;
          payload->getDetIds(detid);

          for (const auto& d : detid) {
            //std::cout<<d<<std::endl;
            SiStripThreshold::Range range = payload->getRange(d);

            int nAPVs = detInfo.getNumberOfApvsAndStripLength(d).first;

            for (int it = 0; it < nAPVs; ++it) {
              auto lth = payload->getData(it * 128, range).getLth();
              //std::cout<<hth<<std::endl;
              fillWithValue(lth);
            }
          }
        }
      }

      return true;
    }
  };

}  // namespace

PAYLOAD_INSPECTOR_MODULE(SiStripThreshold) {
  PAYLOAD_INSPECTOR_CLASS(SiStripThresholdTest);
  PAYLOAD_INSPECTOR_CLASS(SiStripThresholdValueHigh);
  PAYLOAD_INSPECTOR_CLASS(SiStripThresholdValueLow);
}