Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0002 
0003 #include "CondCore/Utilities/interface/PayloadInspectorModule.h"
0004 #include "CondCore/Utilities/interface/PayloadInspector.h"
0005 #include "CondCore/CondDB/interface/Time.h"
0006 
0007 #include "CondFormats/Luminosity/interface/LumiCorrections.h"
0008 
0009 #include <memory>
0010 #include <sstream>
0011 #include <iostream>
0012 
0013 #include "TCanvas.h"
0014 #include "TGraph.h"
0015 #include "TAxis.h"
0016 
0017 namespace {
0018 
0019   /************************************************
0020     summary class
0021   *************************************************/
0022 
0023   class LumiCorrectionsSummary : public cond::payloadInspector::PlotImage<LumiCorrections> {
0024   public:
0025     LumiCorrectionsSummary() : cond::payloadInspector::PlotImage<LumiCorrections>("LumiCorrections Summary") {}
0026 
0027     bool fill() override {
0028       auto tag = cond::payloadInspector::PlotBase::getTag<0>();
0029       auto tagname = tag.name;
0030       auto iov = tag.iovs.front();
0031 
0032       std::shared_ptr<LumiCorrections> payload = fetchPayload(std::get<1>(iov));
0033       auto unpacked = unpack(std::get<0>(iov));
0034       if (payload != nullptr) {
0035         TCanvas canvas(Form("LumiCorrectionsSummary per BX Run %d Lumi %d", unpacked.first, unpacked.second),
0036                        Form("LumiCorrectionsSummary per BX Run %d Lumi %d", unpacked.first, unpacked.second),
0037                        1200,
0038                        600);
0039         canvas.cd();
0040         const int nBX = 3564;
0041         std::vector<float> correctionScaleFactors_ = payload->getCorrectionsBX();
0042         Double_t x[nBX];
0043         Double_t y[nBX];
0044         for (int i = 0; i < nBX; i++) {
0045           x[i] = i;
0046           y[i] = correctionScaleFactors_[i];
0047         }
0048         TGraph* gr = new TGraph(nBX, x, y);
0049         gr->SetTitle(Form("LumiCorrectionsSummary per BX Run %d Lumi %d", unpacked.first, unpacked.second));
0050         gr->Draw("AP");
0051         std::string fileName(this->m_imageFileName);
0052         canvas.SaveAs(fileName.c_str());
0053 
0054         return true;
0055       } else {
0056         return false;
0057       }
0058     }
0059 
0060     std::pair<unsigned int, unsigned int> unpack(cond::Time_t since) {
0061       auto kLowMask = 0XFFFFFFFF;
0062       auto run = (since >> 32);
0063       auto lumi = (since & kLowMask);
0064       return std::make_pair(run, lumi);
0065     }
0066   };
0067 }  // namespace
0068 
0069 // Register the classes as boost python plugin
0070 PAYLOAD_INSPECTOR_MODULE(LumiCorrections) { PAYLOAD_INSPECTOR_CLASS(LumiCorrectionsSummary); }