CMS 3D CMS Logo

AlcaBeamMonitor.h
Go to the documentation of this file.
1 #ifndef DQM_BeamMonitor_AlcaBeamMonitor_h
2 #define DQM_BeamMonitor_AlcaBeamMonitor_h
3 
9 // C++
10 #include <map>
11 #include <array>
12 #include <vector>
13 #include <string>
14 #include <utility>
15 
16 // CMS
29 
30 class BeamFitter;
31 class PVFitter;
32 
33 namespace alcabeammonitor {
34 
35  struct pvPosAndErr {
36  // Array of pairs: (value, error) for x, y, z
37  std::array<std::pair<double, double>, 3> data;
38 
39  // Constructor initializes the array with values and errors from a reco::Vertex
41  : data{{{vertex.x(), vertex.xError()}, {vertex.y(), vertex.yError()}, {vertex.z(), vertex.zError()}}} {}
42 
43  // Accessor functions that return pairs (value, error) directly
44  std::pair<double, double> xWithError() const { return data[0]; }
45  std::pair<double, double> yWithError() const { return data[1]; }
46  std::pair<double, double> zWithError() const { return data[2]; }
47  };
48 
49  struct BeamSpotInfo {
50  std::vector<std::vector<pvPosAndErr>> vertices_;
51  typedef std::map<std::string, reco::BeamSpot> BeamSpotContainer;
53  };
54 } // namespace alcabeammonitor
55 
56 class AlcaBeamMonitor : public DQMOneEDAnalyzer<edm::LuminosityBlockCache<alcabeammonitor::BeamSpotInfo>> {
57 public:
60 
61 protected:
62  void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
63  void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override;
64  std::shared_ptr<alcabeammonitor::BeamSpotInfo> globalBeginLuminosityBlock(
65  const edm::LuminosityBlock& iLumi, const edm::EventSetup& iSetup) const override;
66  void globalEndLuminosityBlock(const edm::LuminosityBlock& iLumi, const edm::EventSetup& iSetup) override;
67  void dqmEndRun(edm::Run const&, edm::EventSetup const&) override;
68 
69 private:
70  //Typedefs
71  // BF,BS...
72  typedef std::map<std::string, reco::BeamSpot> BeamSpotContainer;
73  // x,y,z,sigmax(y,z)... [run,lumi] Histo name
74  typedef std::map<std::string, std::map<std::string, std::map<std::string, MonitorElement*>>> HistosContainer;
75  // x,y,z,sigmax(y,z)... [run,lumi] Histo name
76  typedef std::map<std::string, std::map<std::string, std::map<std::string, int>>> PositionContainer;
77 
78  //Parameters
84  bool perLSsaving_; //to avoid nanoDQMIO crashing, driven by DQMServices/Core/python/DQMStore_cfi.py
85 
86  //Service variables
88  std::unique_ptr<BeamFitter> theBeamFitter_;
89  std::unique_ptr<PVFitter> thePVFitter_;
90  std::vector<int> processedLumis_;
91 
92  // MonitorElements:
95  //mutable MonitorElement* theValuesContainer_;
96 
97  //Containers
100  std::vector<std::string> varNamesV_; //x,y,z,sigmax(y,z)
101  std::multimap<std::string, std::string> histoByCategoryNames_; //run, lumi
102 };
103 
104 #endif
MonitorElement * hD0Phi0_
std::map< std::string, reco::BeamSpot > BeamSpotContainer
MonitorElement * hDxyBS_
static void fillDescriptions(edm::ConfigurationDescriptions &)
std::multimap< std::string, std::string > histoByCategoryNames_
PositionContainer positionsMap_
BeamSpotContainer beamSpotMap_
std::map< std::string, std::map< std::string, std::map< std::string, MonitorElement * > > > HistosContainer
std::pair< double, double > zWithError() const
std::vector< std::vector< pvPosAndErr > > vertices_
std::vector< std::string > varNamesV_
int iEvent
Definition: GenABIO.cc:224
AlcaBeamMonitor(const edm::ParameterSet &)
pvPosAndErr(const reco::Vertex &vertex)
std::shared_ptr< alcabeammonitor::BeamSpotInfo > globalBeginLuminosityBlock(const edm::LuminosityBlock &iLumi, const edm::EventSetup &iSetup) const override
std::vector< int > processedLumis_
std::map< std::string, reco::BeamSpot > BeamSpotContainer
const edm::ESGetToken< BeamSpotObjects, BeamSpotObjectsRcd > beamSpotToken_
std::unique_ptr< PVFitter > thePVFitter_
std::unique_ptr< BeamFitter > theBeamFitter_
HistosContainer histosMap_
std::pair< double, double > xWithError() const
void globalEndLuminosityBlock(const edm::LuminosityBlock &iLumi, const edm::EventSetup &iSetup) override
std::array< std::pair< double, double >, 3 > data
std::string monitorName_
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) override
const edm::EDGetTokenT< reco::BeamSpot > scalerLabel_
std::pair< double, double > yWithError() const
std::map< std::string, std::map< std::string, std::map< std::string, int > > > PositionContainer
const edm::EDGetTokenT< reco::TrackCollection > trackLabel_
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
const edm::EDGetTokenT< reco::VertexCollection > primaryVertexLabel_
Definition: Run.h:45
void dqmEndRun(edm::Run const &, edm::EventSetup const &) override