File indexing completed on 2023-03-17 10:53:49
0001 #ifndef DQM_BeamMonitor__BeamSpotDipServer_h
0002 #define DQM_BeamMonitor__BeamSpotDipServer_h
0003
0004 #include "FWCore/Framework/interface/Frameworkfwd.h"
0005 #include "FWCore/Framework/interface/ESHandle.h"
0006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0007 #include "FWCore/Framework/interface/EventSetup.h"
0008
0009 #include "FWCore/Utilities/interface/ESGetToken.h"
0010
0011 #include "DataFormats/Scalers/interface/BeamSpotOnline.h"
0012 #include "DataFormats/OnlineMetaData/interface/DCSRecord.h"
0013
0014 #include "DQMServices/Core/interface/DQMStore.h"
0015 #include "DQMServices/Core/interface/DQMOneEDAnalyzer.h"
0016
0017 #include "CondFormats/BeamSpotObjects/interface/BeamSpotOnlineObjects.h"
0018 #include "CondFormats/DataRecord/interface/BeamSpotOnlineLegacyObjectsRcd.h"
0019
0020 #include <string>
0021 #include <bits/stdc++.h>
0022
0023 class DipFactory;
0024 class DipData;
0025 class DipPublication;
0026
0027 class LuminosityBlock;
0028
0029 class BeamSpotDipServer : public DQMOneLumiEDAnalyzer<> {
0030 public:
0031 explicit BeamSpotDipServer(const edm::ParameterSet&);
0032
0033 protected:
0034 void bookHistograms(DQMStore::IBooker&, const edm::Run&, const edm::EventSetup&) override;
0035 void dqmBeginRun(const edm::Run& r, const edm::EventSetup&) override;
0036 void analyze(const edm::Event& e, const edm::EventSetup&) override;
0037 void dqmBeginLuminosityBlock(const edm::LuminosityBlock& lumiSeg, const edm::EventSetup&) override;
0038 void dqmEndLuminosityBlock(const edm::LuminosityBlock& lumiSeg, const edm::EventSetup&) override;
0039 void dqmEndRun(const edm::Run&, const edm::EventSetup& iSetup) override;
0040
0041 private:
0042 long getFileSize(std::string filename);
0043 time_t getLastTime(std::string filename);
0044
0045 std::vector<std::string> parse(std::string line, const std::string& delimiter);
0046 std::string tkStatus();
0047
0048 bool readRcd(const BeamSpotOnlineObjects& bs);
0049 bool readRcd(std::ifstream& file);
0050
0051 void problem();
0052 void CMS2LHCRF_POS(float x, float y, float z);
0053
0054 void trueRcd();
0055 void fakeRcd();
0056 void publishRcd(std::string qlty, std::string err, bool pubCMS, bool fitTime);
0057
0058 std::string getDateTime();
0059 std::string getDateTime(long epoch);
0060
0061
0062 const char* qualities[3] = {"Uncertain", "Bad", "Good"};
0063 const bool publishStatErrors = true;
0064 const int rad2urad = 1000000;
0065 const int cm2um = 10000;
0066 const int cm2mm = 10;
0067 const int intLS = 1;
0068
0069
0070 long lastFitTime = 0;
0071 long lastModTime = 0;
0072 std::bitset<8> alive;
0073 int lsCount = 0;
0074 int currentLS = 0;
0075
0076
0077 DipFactory* dip;
0078 DipData* messageCMS;
0079 DipData* messageLHC;
0080 DipData* messagePV;
0081 DipPublication* publicationCMS;
0082 DipPublication* publicationLHC;
0083 DipPublication* publicationPV;
0084
0085
0086 int runnum;
0087 std::string startTime = getDateTime();
0088 std::string endTime = getDateTime();
0089 time_t startTimeStamp = 0;
0090 time_t endTimeStamp = 0;
0091 std::string lumiRange = "0 - 0";
0092 std::string quality = "Uncertain";
0093 int type = -1;
0094 float x = 0;
0095 float y = 0;
0096 float z = 0;
0097 float dxdz = 0;
0098 float dydz = 0;
0099 float err_x = 0;
0100 float err_y = 0;
0101 float err_z = 0;
0102 float err_dxdz = 0;
0103 float err_dydz = 0;
0104 float width_x = 0;
0105 float width_y = 0;
0106 float sigma_z = 0;
0107 float err_width_x = 0;
0108 float err_width_y = 0;
0109 float err_sigma_z = 0;
0110
0111
0112 int events = 0;
0113 float meanPV = 0;
0114 float err_meanPV = 0;
0115 float rmsPV = 0;
0116 float err_rmsPV = 0;
0117 int maxPV = 0;
0118 int nPV = 0;
0119
0120
0121 float Size[3];
0122 float Centroid[3];
0123 float Tilt[2];
0124
0125
0126 edm::InputTag dcsRecordInputTag_;
0127 edm::EDGetTokenT<DCSRecord> dcsRecordToken_;
0128
0129 int lastlumi = -1;
0130 bool wholeTrackerOn = false;
0131
0132
0133 edm::ESGetToken<BeamSpotOnlineObjects, BeamSpotOnlineLegacyObjectsRcd> bsLegacyToken_;
0134
0135
0136 bool verbose;
0137 bool testing;
0138
0139 std::string subjectCMS;
0140 std::string subjectLHC;
0141 std::string subjectPV;
0142
0143 bool readFromNFS;
0144
0145 std::string sourceFile;
0146 std::string sourceFile1;
0147
0148 std::vector<int> timeoutLS;
0149 };
0150
0151 #endif