Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:06:51

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/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 // class declaration
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   // BeginJob
0039   void beginJob() override;
0040 
0041   // BeginRun
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   // EndRun
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_;  // beam spot
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_;   //counter
0075   int countLumi_;  //counter
0076   int beginLumiOfBSFit_;
0077   int endLumiOfBSFit_;
0078   int lastlumi_;   // previous LS processed
0079   int nextlumi_;   // next LS of Fit
0080   int firstlumi_;  // first LS with good fit
0081   int countGoodFit_;
0082   std::time_t refBStime[2];
0083 
0084   bool resetHistos_;
0085   bool processed_;
0086   // ----------member data ---------------------------
0087   BeamSpotMapBx fbspotMap;  //for weighted beam spots of each bunch
0088   std::map<std::string, std::string> varMap;
0089   std::map<std::string, std::string> varMap1;
0090   // MonitorElements:
0091   std::map<TString, MonitorElement*> hs;   // Tables
0092   std::map<TString, MonitorElement*> hst;  // Trending Histos
0093 
0094   //Test
0095   //  MonitorElement * h_x0;
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