Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-14 02:27:47

0001 #ifndef DQM_BeamMonitor_AlcaBeamMonitor_h
0002 #define DQM_BeamMonitor_AlcaBeamMonitor_h
0003 
0004 /** \class AlcaBeamMonitor
0005  * *
0006  *  \author  Lorenzo Uplegger/FNAL
0007  *   modified by Simone Gennai INFN/Bicocca
0008  */
0009 // C++
0010 #include <map>
0011 #include <vector>
0012 #include <string>
0013 // CMS
0014 #include "FWCore/Framework/interface/Frameworkfwd.h"
0015 #include "FWCore/Framework/interface/Event.h"
0016 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0017 #include "FWCore/Utilities/interface/ESGetToken.h"
0018 #include "DQMServices/Core/interface/DQMStore.h"
0019 #include "DQMServices/Core/interface/DQMOneEDAnalyzer.h"
0020 #include "DataFormats/Provenance/interface/LuminosityBlockID.h"
0021 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
0022 #include "DataFormats/VertexReco/interface/Vertex.h"
0023 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0024 #include "CondFormats/DataRecord/interface/BeamSpotObjectsRcd.h"
0025 #include "CondFormats/BeamSpotObjects/interface/BeamSpotObjects.h"
0026 
0027 class BeamFitter;
0028 class PVFitter;
0029 
0030 namespace alcabeammonitor {
0031   struct NoCache {};
0032 }  // namespace alcabeammonitor
0033 
0034 class AlcaBeamMonitor : public DQMOneEDAnalyzer<edm::LuminosityBlockCache<alcabeammonitor::NoCache>> {
0035 public:
0036   AlcaBeamMonitor(const edm::ParameterSet&);
0037   static void fillDescriptions(edm::ConfigurationDescriptions&);
0038 
0039 protected:
0040   void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
0041   void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override;
0042   std::shared_ptr<alcabeammonitor::NoCache> globalBeginLuminosityBlock(const edm::LuminosityBlock& iLumi,
0043                                                                        const edm::EventSetup& iSetup) const override;
0044   void globalEndLuminosityBlock(const edm::LuminosityBlock& iLumi, const edm::EventSetup& iSetup) override;
0045   void dqmEndRun(edm::Run const&, edm::EventSetup const&) override;
0046 
0047 private:
0048   //Typedefs
0049   //                BF,BS...
0050   typedef std::map<std::string, reco::BeamSpot> BeamSpotContainer;
0051   //                x,y,z,sigmax(y,z)... [run,lumi]          Histo name
0052   typedef std::map<std::string, std::map<std::string, std::map<std::string, MonitorElement*>>> HistosContainer;
0053   //                x,y,z,sigmax(y,z)... [run,lumi]          Histo name
0054   typedef std::map<std::string, std::map<std::string, std::map<std::string, int>>> PositionContainer;
0055 
0056   //Parameters
0057   std::string monitorName_;
0058   const edm::EDGetTokenT<reco::VertexCollection> primaryVertexLabel_;
0059   const edm::EDGetTokenT<reco::TrackCollection> trackLabel_;
0060   const edm::EDGetTokenT<reco::BeamSpot> scalerLabel_;
0061   const edm::ESGetToken<BeamSpotObjects, BeamSpotObjectsRcd> beamSpotToken_;
0062   bool perLSsaving_;  //to avoid nanoDQMIO crashing, driven by  DQMServices/Core/python/DQMStore_cfi.py
0063 
0064   //Service variables
0065   int numberOfValuesToSave_;
0066   std::unique_ptr<BeamFitter> theBeamFitter_;
0067   std::unique_ptr<PVFitter> thePVFitter_;
0068   mutable int numberOfProcessedLumis_;
0069   mutable std::vector<int> processedLumis_;
0070 
0071   // MonitorElements:
0072   MonitorElement* hD0Phi0_;
0073   MonitorElement* hDxyBS_;
0074   //mutable MonitorElement* theValuesContainer_;
0075 
0076   //Containers
0077   mutable BeamSpotContainer beamSpotsMap_;
0078   HistosContainer histosMap_;
0079   PositionContainer positionsMap_;
0080   std::vector<std::string> varNamesV_;                            //x,y,z,sigmax(y,z)
0081   std::multimap<std::string, std::string> histoByCategoryNames_;  //run, lumi
0082   mutable std::vector<reco::VertexCollection> vertices_;
0083 };
0084 
0085 #endif