File indexing completed on 2024-04-06 12:06:51
0001 #ifndef BeamMonitorBx_H
0002 #define BeamMonitorBx_H
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include <string>
0012
0013 #include "FWCore/Framework/interface/Frameworkfwd.h"
0014 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0015 #include "FWCore/Framework/interface/Event.h"
0016 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0017 #include "DQMServices/Core/interface/DQMStore.h"
0018 #include "RecoVertex/BeamSpotProducer/interface/BeamFitter.h"
0019 #include <fstream>
0020
0021
0022
0023
0024
0025 class BeamMonitorBx
0026 : public edm::one::EDAnalyzer<edm::one::SharedResources, edm::one::WatchRuns, edm::one::WatchLuminosityBlocks> {
0027 public:
0028 typedef dqm::legacy::MonitorElement MonitorElement;
0029 typedef dqm::legacy::DQMStore DQMStore;
0030
0031 BeamMonitorBx(const edm::ParameterSet&);
0032 ~BeamMonitorBx() override;
0033
0034 typedef int BxNum;
0035 typedef std::map<BxNum, reco::BeamSpot> BeamSpotMapBx;
0036
0037 protected:
0038
0039 void beginJob() override;
0040
0041
0042 void beginRun(const edm::Run& r, const edm::EventSetup& c) override;
0043
0044 void analyze(const edm::Event& e, const edm::EventSetup& c) override;
0045
0046 void beginLuminosityBlock(const edm::LuminosityBlock& lumiSeg, const edm::EventSetup& context) override;
0047
0048 void endLuminosityBlock(const edm::LuminosityBlock& lumiSeg, const edm::EventSetup& c) override;
0049
0050 void endRun(const edm::Run& r, const edm::EventSetup& c) override;
0051
0052 private:
0053 void FitAndFill(const edm::LuminosityBlock& lumiSeg, int&, int&, int&);
0054 void BookTables(int, std::map<std::string, std::string>&, std::string);
0055 void BookTrendHistos(bool, int, std::map<std::string, std::string>&, std::string, const TString&, const TString&);
0056 void FillTables(int, int, std::map<std::string, std::string>&, reco::BeamSpot&, std::string);
0057 void FillTrendHistos(int, int, std::map<std::string, std::string>&, reco::BeamSpot&, const TString&);
0058 void weight(BeamSpotMapBx&, const BeamSpotMapBx&);
0059 void weight(double& mean, double& meanError, const double& val, const double& valError);
0060 void formatFitTime(char*, const std::time_t&);
0061
0062 edm::ParameterSet parameters_;
0063 std::string monitorName_;
0064 edm::InputTag bsSrc_;
0065
0066 int fitNLumi_;
0067 int resetFitNLumi_;
0068 bool debug_;
0069
0070 DQMStore* dbe_;
0071 BeamFitter* theBeamFitter;
0072
0073 unsigned int countBx_;
0074 int countEvt_;
0075 int countLumi_;
0076 int beginLumiOfBSFit_;
0077 int endLumiOfBSFit_;
0078 int lastlumi_;
0079 int nextlumi_;
0080 int firstlumi_;
0081 int countGoodFit_;
0082 std::time_t refBStime[2];
0083
0084 bool resetHistos_;
0085 bool processed_;
0086
0087 BeamSpotMapBx fbspotMap;
0088 std::map<std::string, std::string> varMap;
0089 std::map<std::string, std::string> varMap1;
0090
0091 std::map<TString, MonitorElement*> hs;
0092 std::map<TString, MonitorElement*> hst;
0093
0094
0095
0096
0097
0098 std::time_t tmpTime;
0099 std::time_t refTime;
0100 std::time_t startTime;
0101 edm::TimeValue_t ftimestamp;
0102 };
0103
0104 #endif