Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /*!
0002   \file SiStripLatency_PayloadInspector
0003   \Payload Inspector Plugin for SiStrip Latency
0004   \author Jessica Prisciandaro
0005   \version $Revision: 1.0 $
0006   \date $Date: 2018/05/22 17:59:56 $
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/SiStripLatency.h"
0015 #include "DataFormats/DetId/interface/DetId.h"
0016 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
0017 #include "CondFormats/SiStripObjects/interface/SiStripDetSummary.h"
0018 
0019 // needed for the tracker map
0020 #include "CommonTools/TrackerMap/interface/TrackerMap.h"
0021 
0022 // auxilliary functions
0023 #include "CondCore/SiStripPlugins/interface/SiStripPayloadInspectorHelper.h"
0024 #include "CalibTracker/StandaloneTrackerTopology/interface/StandaloneTrackerTopology.h"
0025 
0026 #include <memory>
0027 #include <sstream>
0028 #include <iostream>
0029 
0030 // include ROOT
0031 #include "TProfile.h"
0032 #include "TH2F.h"
0033 #include "TLegend.h"
0034 #include "TCanvas.h"
0035 #include "TLine.h"
0036 #include "TStyle.h"
0037 #include "TLatex.h"
0038 #include "TPave.h"
0039 #include "TPaveStats.h"
0040 
0041 namespace {
0042 
0043   using namespace cond::payloadInspector;
0044 
0045   /************************************************
0046   // test class
0047   *************************************************/
0048   class SiStripLatencyTest : public Histogram1D<SiStripLatency, SINGLE_IOV> {
0049   public:
0050     SiStripLatencyTest()
0051         : Histogram1D<SiStripLatency, SINGLE_IOV>("SiStripLatency values", "SiStripLatency values", 5, 0.0, 5.0) {}
0052 
0053     bool fill() override {
0054       auto tag = PlotBase::getTag<0>();
0055       for (auto const& iov : tag.iovs) {
0056         std::shared_ptr<SiStripLatency> payload = Base::fetchPayload(std::get<1>(iov));
0057         if (payload.get()) {
0058           std::vector<SiStripLatency::Latency> lat = payload->allLatencyAndModes();
0059           fillWithValue(lat.size());
0060         }
0061       }
0062       return true;
0063     }  // fill
0064   };
0065 
0066   /***********************************************
0067   // 1d histogram of mode  of 1 IOV 
0068   ************************************************/
0069   class SiStripLatencyMode : public Histogram1D<SiStripLatency, SINGLE_IOV> {
0070   public:
0071     SiStripLatencyMode() : Histogram1D<SiStripLatency>("SiStripLatency mode", "SiStripLatency mode", 70, -10, 60) {}
0072 
0073     bool fill() override {
0074       auto tag = PlotBase::getTag<0>();
0075       for (auto const& iov : tag.iovs) {
0076         std::shared_ptr<SiStripLatency> payload = Base::fetchPayload(std::get<1>(iov));
0077         if (payload.get()) {
0078           std::vector<uint16_t> modes;
0079           payload->allModes(modes);
0080 
0081           for (const auto& mode : modes) {
0082             if (mode != 0)
0083               fillWithValue(mode);
0084             else
0085               fillWithValue(-1);
0086           }
0087         }
0088       }
0089       return true;
0090     }
0091   };
0092 
0093   /************************************************
0094   // historic trend plot of mode as a function of the run
0095   ************************************************/
0096   class SiStripLatencyModeHistory : public HistoryPlot<SiStripLatency, uint16_t> {
0097   public:
0098     SiStripLatencyModeHistory() : HistoryPlot<SiStripLatency, uint16_t>("Mode vs run number", "Mode vs run number") {}
0099 
0100     uint16_t getFromPayload(SiStripLatency& payload) override {
0101       uint16_t singlemode = payload.singleMode();
0102       return singlemode;
0103     }
0104   };
0105 
0106   /************************************************
0107   // historic trend plot of mode as a function of the run
0108   ************************************************/
0109   class SiStripIsPeakModeHistory : public HistoryPlot<SiStripLatency, int16_t> {
0110   public:
0111     SiStripIsPeakModeHistory() : HistoryPlot<SiStripLatency, int16_t>("Mode vs run number", "Mode vs run number") {}
0112     int16_t getFromPayload(SiStripLatency& payload) override {
0113       uint16_t mode = payload.singleReadOutMode();
0114       return mode;
0115     }
0116   };
0117 
0118   /************************************************
0119   // historic trend plot of number of modes per run
0120   ************************************************/
0121   class SiStripLatencyNumbOfModeHistory : public HistoryPlot<SiStripLatency, int> {
0122   public:
0123     SiStripLatencyNumbOfModeHistory()
0124         : HistoryPlot<SiStripLatency, int>("Number of modes vs run ", "Number of modes vs run") {}
0125 
0126     int getFromPayload(SiStripLatency& payload) override {
0127       std::vector<uint16_t> modes;
0128       payload.allModes(modes);
0129 
0130       return modes.size();
0131     }
0132   };
0133 }  // namespace
0134 
0135 // Register the classes as boost python plugin
0136 PAYLOAD_INSPECTOR_MODULE(SiStripLatency) {
0137   PAYLOAD_INSPECTOR_CLASS(SiStripLatencyTest);
0138   PAYLOAD_INSPECTOR_CLASS(SiStripLatencyMode);
0139   PAYLOAD_INSPECTOR_CLASS(SiStripLatencyModeHistory);
0140   PAYLOAD_INSPECTOR_CLASS(SiStripIsPeakModeHistory);
0141   PAYLOAD_INSPECTOR_CLASS(SiStripLatencyNumbOfModeHistory);
0142 }