File indexing completed on 2024-04-06 12:03:18
0001 #include "FWCore/Framework/interface/Frameworkfwd.h"
0002 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0003 #include "FWCore/Framework/interface/Event.h"
0004 #include "FWCore/Framework/interface/EventSetup.h"
0005 #include "FWCore/Framework/interface/ESWatcher.h"
0006 #include "FWCore/Framework/interface/MakerMacros.h"
0007
0008 #include "CondFormats/RunInfo/interface/LHCInfoPerFill.h"
0009 #include "CondFormats/DataRecord/interface/LHCInfoPerFillRcd.h"
0010
0011 #include <memory>
0012 #include <iostream>
0013 #include <vector>
0014 #include <cassert>
0015
0016 class LHCInfoPerFillAnalyzer : public edm::one::EDAnalyzer<> {
0017 public:
0018 explicit LHCInfoPerFillAnalyzer(const edm::ParameterSet&)
0019 : tokenInfoPerFill_(esConsumes<LHCInfoPerFill, LHCInfoPerFillRcd>()) {}
0020
0021 private:
0022 void beginJob() override {}
0023 void analyze(const edm::Event&, const edm::EventSetup&) override;
0024 void endJob() override {}
0025
0026 edm::ESWatcher<LHCInfoPerFillRcd> infoPerFillWatcher_;
0027
0028 edm::ESGetToken<LHCInfoPerFill, LHCInfoPerFillRcd> tokenInfoPerFill_;
0029 };
0030
0031 void LHCInfoPerFillAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0032 assert(infoPerFillWatcher_.check(iSetup));
0033
0034 LHCInfoPerFill lhcInfoPerFill = iSetup.getData(tokenInfoPerFill_);
0035 const float EPS = 1E-4;
0036 assert(lhcInfoPerFill.fillNumber() == 3);
0037 assert(lhcInfoPerFill.bunchesInBeam1() == 10);
0038 assert(lhcInfoPerFill.bunchesInBeam2() == 8);
0039 assert(lhcInfoPerFill.collidingBunches() == 5);
0040 assert(lhcInfoPerFill.targetBunches() == 4);
0041 assert(lhcInfoPerFill.fillType() == lhcInfoPerFill.PROTONS);
0042 assert(lhcInfoPerFill.particleTypeForBeam1() == lhcInfoPerFill.PROTON);
0043 assert(lhcInfoPerFill.particleTypeForBeam2() == lhcInfoPerFill.PROTON);
0044 assert(abs(lhcInfoPerFill.intensityForBeam1() - 1016.5) < EPS);
0045 assert(abs(lhcInfoPerFill.intensityForBeam2() - 1096.66) < EPS);
0046 assert(abs(lhcInfoPerFill.energy() - 7000) < EPS);
0047 assert(abs(lhcInfoPerFill.delivLumi() - 2E-07) < EPS);
0048 assert(abs(lhcInfoPerFill.recLumi() - 2E-07) < EPS);
0049 assert(abs(lhcInfoPerFill.instLumi() - 0) < EPS);
0050 assert(abs(lhcInfoPerFill.instLumiError() - 0) < EPS);
0051 assert(lhcInfoPerFill.createTime() == 6561530930997627120);
0052 assert(lhcInfoPerFill.beginTime() == 6561530930997627120);
0053 assert(lhcInfoPerFill.endTime() == 6561530930997627120);
0054 assert(lhcInfoPerFill.injectionScheme() == "None");
0055 assert(lhcInfoPerFill.lumiPerBX().size() == 2);
0056 assert(abs(lhcInfoPerFill.lumiPerBX()[0] - 0.000114139) < EPS);
0057 assert(abs(lhcInfoPerFill.lumiPerBX()[1] - 0.000114139) < EPS);
0058 assert(lhcInfoPerFill.lhcState() == "some lhcState");
0059 assert(lhcInfoPerFill.lhcComment() == "some lhcComment");
0060 assert(lhcInfoPerFill.ctppsStatus() == "some ctppsStatus");
0061 edm::LogInfo("LHCInfoPerFillAnalyzer") << "LHCInfoPerFill retrieved:\n" << lhcInfoPerFill;
0062 }
0063
0064 DEFINE_FWK_MODULE(LHCInfoPerFillAnalyzer);