Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:01:51

0001 /*!
0002   \file SiStripThreshold_PayloadInspector
0003   \Payload Inspector Plugin for SiStrip Threshold 
0004   \author J. Prisciandaro
0005   \version $Revision: 1.0 $
0006   \date $Date: 2018/02/22 $
0007 */
0008 
0009 #include "CondCore/Utilities/interface/PayloadInspectorModule.h"
0010 #include "CondCore/Utilities/interface/PayloadInspector.h"
0011 #include "CondCore/CondDB/interface/Time.h"
0012 
0013 // the data format of the condition to be inspected
0014 #include "CondFormats/SiStripObjects/interface/SiStripThreshold.h"
0015 #include "DataFormats/DetId/interface/DetId.h"
0016 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
0017 #include "CondFormats/SiStripObjects/interface/SiStripDetSummary.h"
0018 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0019 
0020 // needed for the tracker map
0021 #include "CommonTools/TrackerMap/interface/TrackerMap.h"
0022 
0023 // auxilliary functions
0024 #include "CondCore/SiStripPlugins/interface/SiStripPayloadInspectorHelper.h"
0025 #include "CalibTracker/StandaloneTrackerTopology/interface/StandaloneTrackerTopology.h"
0026 
0027 #include "CalibTracker/SiStripCommon/interface/SiStripDetInfoFileReader.h"
0028 
0029 #include <memory>
0030 #include <sstream>
0031 #include <iostream>
0032 
0033 // include ROOT
0034 #include "TH2F.h"
0035 #include "TLegend.h"
0036 #include "TCanvas.h"
0037 #include "TLine.h"
0038 #include "TStyle.h"
0039 #include "TLatex.h"
0040 #include "TPave.h"
0041 #include "TPaveStats.h"
0042 
0043 using namespace std;
0044 
0045 namespace {
0046 
0047   using namespace cond::payloadInspector;
0048 
0049   /************************************************
0050     test class
0051   *************************************************/
0052 
0053   class SiStripThresholdTest : public Histogram1D<SiStripThreshold, SINGLE_IOV> {
0054   public:
0055     SiStripThresholdTest()
0056         : Histogram1D<SiStripThreshold, SINGLE_IOV>("SiStrip Threshold test", "SiStrip Threshold test", 10, 0.0, 10.0),
0057           m_trackerTopo{StandaloneTrackerTopology::fromTrackerParametersXMLFile(
0058               edm::FileInPath("Geometry/TrackerCommonData/data/trackerParameters.xml").fullPath())} {}
0059 
0060     bool fill() override {
0061       auto tag = PlotBase::getTag<0>();
0062       for (auto const& iov : tag.iovs) {
0063         std::shared_ptr<SiStripThreshold> payload = Base::fetchPayload(std::get<1>(iov));
0064         if (payload.get()) {
0065           fillWithValue(1.);
0066 
0067           std::stringstream ss;
0068           ss << "Summary of strips threshold:" << std::endl;
0069 
0070           payload->printSummary(ss, &m_trackerTopo);
0071 
0072           std::vector<uint32_t> detid;
0073           payload->getDetIds(detid);
0074 
0075           std::cout << ss.str() << std::endl;
0076         }
0077       }
0078       return true;
0079     }  // fill
0080   private:
0081     TrackerTopology m_trackerTopo;
0082   };
0083 
0084   /************************************************************
0085     1d histogram of SiStripThresholds of 1 IOV - High Threshold 
0086   *************************************************************/
0087 
0088   class SiStripThresholdValueHigh : public Histogram1D<SiStripThreshold, SINGLE_IOV> {
0089   public:
0090     SiStripThresholdValueHigh()
0091         : Histogram1D<SiStripThreshold, SINGLE_IOV>("SiStrip High threshold values (checked per APV)",
0092                                                     "SiStrip High threshold values (cheched per APV)",
0093                                                     10,
0094                                                     0.0,
0095                                                     10) {}
0096     bool fill() override {
0097       auto tag = PlotBase::getTag<0>();
0098       const auto detInfo =
0099           SiStripDetInfoFileReader::read(edm::FileInPath(SiStripDetInfoFileReader::kDefaultFile).fullPath());
0100       for (auto const& iov : tag.iovs) {
0101         std::shared_ptr<SiStripThreshold> payload = Base::fetchPayload(std::get<1>(iov));
0102         if (payload.get()) {
0103           std::vector<uint32_t> detid;
0104           payload->getDetIds(detid);
0105 
0106           for (const auto& d : detid) {
0107             //std::cout<<d<<std::endl;
0108             SiStripThreshold::Range range = payload->getRange(d);
0109 
0110             int nAPVs = detInfo.getNumberOfApvsAndStripLength(d).first;
0111 
0112             for (int it = 0; it < nAPVs; ++it) {
0113               auto hth = payload->getData(it * 128, range).getHth();
0114               //std::cout<<hth<<std::endl;
0115               fillWithValue(hth);
0116             }
0117           }
0118         }
0119       }
0120 
0121       return true;
0122     }
0123   };
0124 
0125   /************************************************************
0126     1d histogram of SiStripThresholds of 1 IOV - Low Threshold 
0127   *************************************************************/
0128 
0129   class SiStripThresholdValueLow : public Histogram1D<SiStripThreshold, SINGLE_IOV> {
0130   public:
0131     SiStripThresholdValueLow()
0132         : Histogram1D<SiStripThreshold, SINGLE_IOV>("SiStrip Low threshold values (checked per APV)",
0133                                                     "SiStrip Low threshold values (cheched per APV)",
0134                                                     10,
0135                                                     0.0,
0136                                                     10) {}
0137     bool fill() override {
0138       auto tag = PlotBase::getTag<0>();
0139       const auto detInfo =
0140           SiStripDetInfoFileReader::read(edm::FileInPath(SiStripDetInfoFileReader::kDefaultFile).fullPath());
0141       for (auto const& iov : tag.iovs) {
0142         std::shared_ptr<SiStripThreshold> payload = Base::fetchPayload(std::get<1>(iov));
0143         if (payload.get()) {
0144           std::vector<uint32_t> detid;
0145           payload->getDetIds(detid);
0146 
0147           for (const auto& d : detid) {
0148             //std::cout<<d<<std::endl;
0149             SiStripThreshold::Range range = payload->getRange(d);
0150 
0151             int nAPVs = detInfo.getNumberOfApvsAndStripLength(d).first;
0152 
0153             for (int it = 0; it < nAPVs; ++it) {
0154               auto lth = payload->getData(it * 128, range).getLth();
0155               //std::cout<<hth<<std::endl;
0156               fillWithValue(lth);
0157             }
0158           }
0159         }
0160       }
0161 
0162       return true;
0163     }
0164   };
0165 
0166 }  // namespace
0167 
0168 PAYLOAD_INSPECTOR_MODULE(SiStripThreshold) {
0169   PAYLOAD_INSPECTOR_CLASS(SiStripThresholdTest);
0170   PAYLOAD_INSPECTOR_CLASS(SiStripThresholdValueHigh);
0171   PAYLOAD_INSPECTOR_CLASS(SiStripThresholdValueLow);
0172 }