Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:09:21

0001 #ifndef BeamMonitorBx_H
0002 #define BeamMonitorBx_H
0003 
0004 /** \class BeamMonitorBx
0005  * *
0006  *  \author  Geng-yuan Jeng/UC Riverside
0007  *           Francisco Yumiceva/FNAL
0008  *   
0009  */
0010 // C++
0011 #include <string>
0012 // CMS
0013 #include "FWCore/Framework/interface/Frameworkfwd.h"
0014 #include "FWCore/Framework/interface/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 // class declaration
0023 //
0024 
0025 class BeamMonitorBx : public edm::EDAnalyzer {
0026 public:
0027   typedef dqm::legacy::MonitorElement MonitorElement;
0028   typedef dqm::legacy::DQMStore DQMStore;
0029 
0030   BeamMonitorBx(const edm::ParameterSet&);
0031   ~BeamMonitorBx() override;
0032 
0033   typedef int BxNum;
0034   typedef std::map<BxNum, reco::BeamSpot> BeamSpotMapBx;
0035 
0036 protected:
0037   // BeginJob
0038   void beginJob() override;
0039 
0040   // BeginRun
0041   void beginRun(const edm::Run& r, const edm::EventSetup& c) override;
0042 
0043   void analyze(const edm::Event& e, const edm::EventSetup& c) override;
0044 
0045   void beginLuminosityBlock(const edm::LuminosityBlock& lumiSeg, const edm::EventSetup& context) override;
0046 
0047   void endLuminosityBlock(const edm::LuminosityBlock& lumiSeg, const edm::EventSetup& c) override;
0048   // EndRun
0049   void endRun(const edm::Run& r, const edm::EventSetup& c) override;
0050 
0051 private:
0052   void FitAndFill(const edm::LuminosityBlock& lumiSeg, int&, int&, int&);
0053   void BookTables(int, std::map<std::string, std::string>&, std::string);
0054   void BookTrendHistos(bool, int, std::map<std::string, std::string>&, std::string, const TString&, const TString&);
0055   void FillTables(int, int, std::map<std::string, std::string>&, reco::BeamSpot&, std::string);
0056   void FillTrendHistos(int, int, std::map<std::string, std::string>&, reco::BeamSpot&, const TString&);
0057   void weight(BeamSpotMapBx&, const BeamSpotMapBx&);
0058   void weight(double& mean, double& meanError, const double& val, const double& valError);
0059   void formatFitTime(char*, const std::time_t&);
0060 
0061   edm::ParameterSet parameters_;
0062   std::string monitorName_;
0063   edm::InputTag bsSrc_;  // beam spot
0064 
0065   int fitNLumi_;
0066   int resetFitNLumi_;
0067   bool debug_;
0068 
0069   DQMStore* dbe_;
0070   BeamFitter* theBeamFitter;
0071 
0072   unsigned int countBx_;
0073   int countEvt_;   //counter
0074   int countLumi_;  //counter
0075   int beginLumiOfBSFit_;
0076   int endLumiOfBSFit_;
0077   int lastlumi_;   // previous LS processed
0078   int nextlumi_;   // next LS of Fit
0079   int firstlumi_;  // first LS with good fit
0080   int countGoodFit_;
0081   std::time_t refBStime[2];
0082 
0083   bool resetHistos_;
0084   bool processed_;
0085   // ----------member data ---------------------------
0086   BeamSpotMapBx fbspotMap;  //for weighted beam spots of each bunch
0087   std::map<std::string, std::string> varMap;
0088   std::map<std::string, std::string> varMap1;
0089   // MonitorElements:
0090   std::map<TString, MonitorElement*> hs;   // Tables
0091   std::map<TString, MonitorElement*> hst;  // Trending Histos
0092 
0093   //Test
0094   //  MonitorElement * h_x0;
0095 
0096   //
0097   std::time_t tmpTime;
0098   std::time_t refTime;
0099   std::time_t startTime;
0100   edm::TimeValue_t ftimestamp;
0101 };
0102 
0103 #endif