Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-27 04:04:29

0001 #ifndef FakeBeamMonitor_H
0002 #define FakeBeamMonitor_H
0003 
0004 /** \class FakeBeamMonitor
0005  * *
0006  *  \author  Francesco Brivio - Milano-Bicocca
0007  *  \decription: Same behaviour of BeamMonitor except the
0008  *               beamspot is randomly generated and not fitted from tracks/PVs
0009  *
0010  */
0011 // C++
0012 #include <string>
0013 #include <memory>
0014 // CMS
0015 #include "FWCore/Framework/interface/Frameworkfwd.h"
0016 #include "FWCore/Framework/interface/Event.h"
0017 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0018 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
0019 #include "DataFormats/VertexReco/interface/Vertex.h"
0020 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0021 #include "DataFormats/TrackReco/interface/Track.h"
0022 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0023 #include "DataFormats/Common/interface/TriggerResults.h"
0024 #include "DQMServices/Core/interface/DQMStore.h"
0025 #include "DQMServices/Core/interface/DQMOneEDAnalyzer.h"
0026 #include "CondCore/DBOutputService/interface/OnlineDBOutputService.h"
0027 #include <fstream>
0028 #include "TRandom3.h"
0029 
0030 //
0031 // class declaration
0032 //
0033 
0034 class FakeBeamMonitor : public DQMOneEDAnalyzer<edm::one::WatchLuminosityBlocks> {
0035 public:
0036   FakeBeamMonitor(const edm::ParameterSet&);
0037   ~FakeBeamMonitor() override;
0038 
0039 protected:
0040   //BeginRun
0041   void dqmBeginRun(edm::Run const&, edm::EventSetup const&) override;
0042 
0043   void bookHistograms(DQMStore::IBooker& i, const edm::Run& r, const edm::EventSetup& c) override;
0044 
0045   void analyze(const edm::Event& e, const edm::EventSetup& c) override;
0046 
0047   void beginLuminosityBlock(const edm::LuminosityBlock& lumiSeg, const edm::EventSetup& context) override;
0048 
0049   void endLuminosityBlock(const edm::LuminosityBlock& lumiSeg, const edm::EventSetup& c) override;
0050   // EndRun
0051   void dqmEndRun(const edm::Run& r, const edm::EventSetup& c) override;
0052 
0053 private:
0054   void FitAndFill(const edm::LuminosityBlock& lumiSeg, int&, int&, int&);
0055   void RestartFitting();
0056   void scrollTH1(TH1*, std::time_t);
0057   bool testScroll(std::time_t&, std::time_t&);
0058   void formatFitTime(char*, const std::time_t&);
0059   std::string getGMTstring(const std::time_t&);
0060 
0061   const int dxBin_;
0062   const double dxMin_;
0063   const double dxMax_;
0064 
0065   const int vxBin_;
0066   const double vxMin_;
0067   const double vxMax_;
0068 
0069   const int phiBin_;
0070   const double phiMin_;
0071   const double phiMax_;
0072 
0073   const int dzBin_;
0074   const double dzMin_;
0075   const double dzMax_;
0076   std::string monitorName_;
0077   std::string recordName_;                                              // output BeamSpotOnline Record name
0078   edm::Service<cond::service::OnlineDBOutputService> onlineDbService_;  // DB service
0079   int DBloggerReturn_;                                                  // DB logger return value
0080 
0081   int fitNLumi_;
0082   int fitPVNLumi_;
0083   int resetFitNLumi_;
0084   int resetPVNLumi_;
0085   int intervalInSec_;
0086   bool debug_;
0087   bool onlineMode_;
0088 
0089   int countEvt_;   //counter
0090   int countLumi_;  //counter
0091   int beginLumiOfBSFit_;
0092   int endLumiOfBSFit_;
0093   int beginLumiOfPVFit_;
0094   int endLumiOfPVFit_;
0095   int lastlumi_;  // previous LS processed
0096   int nextlumi_;  // next LS of Fit
0097   std::time_t refBStime[2];
0098   std::time_t refPVtime[2];
0099   unsigned int nthBSTrk_;
0100   int nFitElements_;
0101   int nFits_;
0102   double deltaSigCut_;
0103   unsigned int min_Ntrks_;
0104   double maxZ_;
0105   unsigned int minNrVertices_;
0106   double minVtxNdf_;
0107   double minVtxWgt_;
0108 
0109   bool resetHistos_;
0110   bool StartAverage_;
0111   int firstAverageFit_;
0112   int countGapLumi_;
0113 
0114   bool processed_;
0115   bool useLockRecords_;
0116   // ----------member data ---------------------------
0117 
0118   //   std::vector<BSTrkParameters> fBSvector;
0119   reco::BeamSpot refBS;
0120   reco::BeamSpot preBS;
0121 
0122   // MonitorElements:
0123   MonitorElement* h_nTrk_lumi;
0124   MonitorElement* h_nVtx_lumi;
0125   MonitorElement* h_nVtx_lumi_all;
0126   MonitorElement* h_d0_phi0;
0127   MonitorElement* h_trk_z0;
0128   MonitorElement* h_vx_vy;
0129   MonitorElement* h_vx_dz;
0130   MonitorElement* h_vy_dz;
0131   MonitorElement* h_trkPt;
0132   MonitorElement* h_trkVz;
0133   MonitorElement* fitResults;
0134   MonitorElement* h_x0;
0135   MonitorElement* h_y0;
0136   MonitorElement* h_z0;
0137   MonitorElement* h_sigmaX0;
0138   MonitorElement* h_sigmaY0;
0139   MonitorElement* h_sigmaZ0;
0140   MonitorElement* h_nVtx;
0141   MonitorElement* h_nVtx_st;
0142   MonitorElement* h_PVx[2];
0143   MonitorElement* h_PVy[2];
0144   MonitorElement* h_PVz[2];
0145   MonitorElement* h_PVxz;
0146   MonitorElement* h_PVyz;
0147   MonitorElement* pvResults;
0148   std::vector<MonitorElement*> hs;
0149 
0150   // The histo of the primary vertex for  DQM gui
0151   std::map<int, std::vector<float> > mapPVx, mapPVy, mapPVz;
0152   std::map<int, std::vector<int> > mapNPV;
0153   //keep track of beginLuminosity block and time
0154   std::map<int, int> mapBeginBSLS, mapBeginPVLS;
0155   std::map<int, std::time_t> mapBeginBSTime, mapBeginPVTime;
0156   //these maps are needed to keep track of size of theBSvector and pvStore
0157   std::map<int, std::size_t> mapLSBSTrkSize;
0158   std::map<int, size_t> mapLSPVStoreSize;
0159   //to correct the cutFlot Table
0160   std::map<int, TH1F> mapLSCF;
0161 
0162   // Summary:
0163   Float_t reportSummary_;
0164   Float_t summarySum_;
0165   Float_t summaryContent_[3];
0166   MonitorElement* reportSummary;
0167   MonitorElement* reportSummaryContents[3];
0168   MonitorElement* reportSummaryMap;
0169   MonitorElement* cutFlowTable;
0170   // variables for beam fit
0171 
0172   //
0173   std::time_t tmpTime;
0174   std::time_t startTime;
0175   std::time_t refTime;
0176   edm::TimeValue_t ftimestamp;
0177   // Current run
0178   int frun;
0179   int lastNZbin;  // last non zero bin of time histos
0180 
0181   TRandom3* rndm_;
0182 };
0183 
0184 #endif
0185 
0186 // Local Variables:
0187 // show-trailing-whitespace: t
0188 // truncate-lines: t
0189 // End: