File indexing completed on 2024-04-06 12:06:50
0001
0002
0003
0004
0005
0006
0007
0008 #include "DQM/BeamMonitor/plugins/BeamConditionsMonitor.h"
0009 #include "FWCore/ServiceRegistry/interface/Service.h"
0010 #include "FWCore/Framework/interface/MakerMacros.h"
0011 #include "FWCore/Framework/interface/IOVSyncValue.h"
0012 #include "CondFormats/DataRecord/interface/BeamSpotObjectsRcd.h"
0013 #include "FWCore/Framework/interface/ESHandle.h"
0014 #include "FWCore/Framework/interface/EventSetup.h"
0015 #include <numeric>
0016 #include <cmath>
0017 #include <TMath.h>
0018 #include <iostream>
0019 #include "TStyle.h"
0020
0021 using namespace std;
0022 using namespace edm;
0023
0024
0025
0026
0027 BeamConditionsMonitor::BeamConditionsMonitor(const ParameterSet& ps) : countEvt_(0), countLumi_(0) {
0028 parameters_ = ps;
0029 monitorName_ = parameters_.getUntrackedParameter<string>("monitorName", "YourSubsystemName");
0030 bsSrc_ = parameters_.getUntrackedParameter<InputTag>("beamSpot");
0031 debug_ = parameters_.getUntrackedParameter<bool>("Debug");
0032 beamSpotToken_ = esConsumes();
0033 usesResource("DQMStore");
0034 dbe_ = Service<DQMStore>().operator->();
0035
0036 if (!monitorName_.empty())
0037 monitorName_ = monitorName_ + "/";
0038 }
0039
0040 BeamConditionsMonitor::~BeamConditionsMonitor() {}
0041
0042
0043 void BeamConditionsMonitor::beginJob() {
0044
0045
0046 dbe_->setCurrentFolder(monitorName_ + "Conditions");
0047
0048 h_x0_lumi = dbe_->book1D("x0_lumi_cond", "x coordinate of beam spot vs lumi (Cond)", 10, 0, 10);
0049 h_x0_lumi->setAxisTitle("Lumisection", 1);
0050 h_x0_lumi->setAxisTitle("x_{0} (cm)", 2);
0051 h_x0_lumi->getTH1()->SetOption("E1");
0052
0053 h_y0_lumi = dbe_->book1D("y0_lumi_cond", "y coordinate of beam spot vs lumi (Cond)", 10, 0, 10);
0054 h_y0_lumi->setAxisTitle("Lumisection", 1);
0055 h_y0_lumi->setAxisTitle("y_{0} (cm)", 2);
0056 h_y0_lumi->getTH1()->SetOption("E1");
0057 }
0058
0059
0060 void BeamConditionsMonitor::beginRun(const edm::Run& r, const EventSetup& context) {}
0061
0062
0063 void BeamConditionsMonitor::beginLuminosityBlock(const LuminosityBlock& lumiSeg, const EventSetup& context) {
0064 countLumi_++;
0065 }
0066
0067
0068 void BeamConditionsMonitor::analyze(const Event& iEvent, const EventSetup& iSetup) {
0069 countEvt_++;
0070 condBeamSpot = iSetup.getData(beamSpotToken_);
0071 }
0072
0073
0074 void BeamConditionsMonitor::endLuminosityBlock(const LuminosityBlock& lumiSeg, const EventSetup& iSetup) {
0075 LogInfo("BeamConditions") << "[BeamConditionsMonitor]:" << condBeamSpot << endl;
0076 h_x0_lumi->ShiftFillLast(condBeamSpot.x(), condBeamSpot.xError(), 1);
0077 h_y0_lumi->ShiftFillLast(condBeamSpot.y(), condBeamSpot.yError(), 1);
0078 }
0079
0080 void BeamConditionsMonitor::endRun(const Run& r, const EventSetup& context) {}
0081
0082 void BeamConditionsMonitor::endJob() {}
0083
0084 DEFINE_FWK_MODULE(BeamConditionsMonitor);