Skip to content

Commit e13898f

Browse files
committed
LHCInfo* validation tools
add printLHCInfoPerPayloads disable unecessary logs from LHCInfoPerFillAnalyzer Add lumiid timetype support for LHCInfoPerLS and LHCInfoPerFill printing fix isseus related to DumpStats argument
1 parent e04f43e commit e13898f

14 files changed

+571
-64
lines changed

CondTools/RunInfo/plugins/BuildFile.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,18 @@
5151
<flags EDM_PLUGIN="1"/>
5252
</library>
5353

54+
<library file="LHCInfoPerLSWriter.cc" name="LHCInfoPerLSWriter">
55+
<flags EDM_PLUGIN="1"/>
56+
</library>
57+
5458
<library file="LHCInfoPerLSAnalyzer.cc" name="LHCInfoPerLSAnalyzer">
5559
<flags EDM_PLUGIN="1"/>
5660
</library>
5761

62+
<library file="LHCInfoPerLSTester.cc" name="LHCInfoPerLSTester">
63+
<flags EDM_PLUGIN="1"/>
64+
</library>
65+
5866
<library file="LHCInfoPerFillWriter.cc" name="LHCInfoPerFillWriter">
5967
<flags EDM_PLUGIN="1"/>
6068
</library>
@@ -67,6 +75,14 @@
6775
<flags EDM_PLUGIN="1"/>
6876
</library>
6977

78+
<library file="LHCInfoPerFillTester.cc" name="LHCInfoPerFillTester">
79+
<flags EDM_PLUGIN="1"/>
80+
</library>
81+
82+
<library file="LHCInfoAnalyzer.cc" name="LHCInfoAnalyzer">
83+
<flags EDM_PLUGIN="1"/>
84+
</library>
85+
7086
<library file="LHCInfoPerLSPopConAnalyzer.cc" name="CondToolsLHCInfoPerLSPopConAnalyzer">
7187
<flags EDM_PLUGIN="1"/>
7288
</library>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include "FWCore/Framework/interface/Frameworkfwd.h"
2+
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
3+
#include "FWCore/Framework/interface/Event.h"
4+
#include "FWCore/Framework/interface/EventSetup.h"
5+
#include "FWCore/Framework/interface/ESHandle.h"
6+
#include "FWCore/Framework/interface/ESWatcher.h"
7+
#include "FWCore/Framework/interface/MakerMacros.h"
8+
9+
#include "FWCore/ParameterSet/interface/ParameterSet.h"
10+
#include "FWCore/ServiceRegistry/interface/Service.h"
11+
12+
#include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
13+
14+
#include "CondFormats/RunInfo/interface/LHCInfo.h"
15+
#include "CondFormats/DataRecord/interface/LHCInfoRcd.h"
16+
17+
#include <memory>
18+
#include <iostream>
19+
20+
class LHCInfoAnalyzer : public edm::one::EDAnalyzer<> {
21+
public:
22+
explicit LHCInfoAnalyzer(const edm::ParameterSet&) : tokenInfo_(esConsumes<LHCInfo, LHCInfoRcd>()) {}
23+
24+
private:
25+
void beginJob() override {}
26+
void analyze(const edm::Event&, const edm::EventSetup&) override;
27+
void endJob() override {}
28+
29+
edm::ESWatcher<LHCInfoRcd> InfoWatcher_;
30+
31+
edm::ESGetToken<LHCInfo, LHCInfoRcd> tokenInfo_;
32+
};
33+
34+
void LHCInfoAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
35+
// get Info
36+
if (InfoWatcher_.check(iSetup)) {
37+
const auto& lhcInfo = iSetup.getData(tokenInfo_);
38+
std::cout << "LHCInfo;" << iEvent.time().unixTime() << ";" << lhcInfo.lumiSection() << ";"
39+
<< lhcInfo.crossingAngle() << ";" << lhcInfo.betaStar() << ";" << lhcInfo.delivLumi() << ";" << std::endl;
40+
}
41+
}
42+
43+
DEFINE_FWK_MODULE(LHCInfoAnalyzer);
Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "CondFormats/Common/interface/Time.h"
12
#include "FWCore/Framework/interface/Frameworkfwd.h"
23
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
34
#include "FWCore/Framework/interface/Event.h"
@@ -15,8 +16,9 @@
1516

1617
class LHCInfoPerFillAnalyzer : public edm::one::EDAnalyzer<> {
1718
public:
18-
explicit LHCInfoPerFillAnalyzer(const edm::ParameterSet&)
19-
: tokenInfoPerFill_(esConsumes<LHCInfoPerFill, LHCInfoPerFillRcd>()) {}
19+
explicit LHCInfoPerFillAnalyzer(const edm::ParameterSet& pset)
20+
: tokenInfoPerFill_(esConsumes<LHCInfoPerFill, LHCInfoPerFillRcd>()),
21+
iov_(pset.getUntrackedParameter<cond::Time_t>("iov")) {}
2022

2123
private:
2224
void beginJob() override {}
@@ -26,39 +28,15 @@ class LHCInfoPerFillAnalyzer : public edm::one::EDAnalyzer<> {
2628
edm::ESWatcher<LHCInfoPerFillRcd> infoPerFillWatcher_;
2729

2830
edm::ESGetToken<LHCInfoPerFill, LHCInfoPerFillRcd> tokenInfoPerFill_;
31+
const cond::Time_t iov_;
2932
};
3033

3134
void LHCInfoPerFillAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
3235
assert(infoPerFillWatcher_.check(iSetup));
3336

34-
LHCInfoPerFill lhcInfoPerFill = iSetup.getData(tokenInfoPerFill_);
35-
const float EPS = 1E-4;
36-
assert(lhcInfoPerFill.fillNumber() == 3);
37-
assert(lhcInfoPerFill.bunchesInBeam1() == 10);
38-
assert(lhcInfoPerFill.bunchesInBeam2() == 8);
39-
assert(lhcInfoPerFill.collidingBunches() == 5);
40-
assert(lhcInfoPerFill.targetBunches() == 4);
41-
assert(lhcInfoPerFill.fillType() == lhcInfoPerFill.PROTONS);
42-
assert(lhcInfoPerFill.particleTypeForBeam1() == lhcInfoPerFill.PROTON);
43-
assert(lhcInfoPerFill.particleTypeForBeam2() == lhcInfoPerFill.PROTON);
44-
assert(abs(lhcInfoPerFill.intensityForBeam1() - 1016.5) < EPS);
45-
assert(abs(lhcInfoPerFill.intensityForBeam2() - 1096.66) < EPS);
46-
assert(abs(lhcInfoPerFill.energy() - 7000) < EPS);
47-
assert(abs(lhcInfoPerFill.delivLumi() - 2E-07) < EPS);
48-
assert(abs(lhcInfoPerFill.recLumi() - 2E-07) < EPS);
49-
assert(abs(lhcInfoPerFill.instLumi() - 0) < EPS);
50-
assert(abs(lhcInfoPerFill.instLumiError() - 0) < EPS);
51-
assert(lhcInfoPerFill.createTime() == 6561530930997627120);
52-
assert(lhcInfoPerFill.beginTime() == 6561530930997627120);
53-
assert(lhcInfoPerFill.endTime() == 6561530930997627120);
54-
assert(lhcInfoPerFill.injectionScheme() == "None");
55-
assert(lhcInfoPerFill.lumiPerBX().size() == 2);
56-
assert(abs(lhcInfoPerFill.lumiPerBX()[0] - 0.000114139) < EPS);
57-
assert(abs(lhcInfoPerFill.lumiPerBX()[1] - 0.000114139) < EPS);
58-
assert(lhcInfoPerFill.lhcState() == "some lhcState");
59-
assert(lhcInfoPerFill.lhcComment() == "some lhcComment");
60-
assert(lhcInfoPerFill.ctppsStatus() == "some ctppsStatus");
61-
edm::LogInfo("LHCInfoPerFillAnalyzer") << "LHCInfoPerFill retrieved:\n" << lhcInfoPerFill;
37+
const LHCInfoPerFill& lhcInfoPerFill = iSetup.getData(tokenInfoPerFill_);
38+
39+
std::cout << "IOV " << iov_ << "\nLHCInfoPerFill retrieved:\n" << lhcInfoPerFill;
6240
}
6341

6442
DEFINE_FWK_MODULE(LHCInfoPerFillAnalyzer);
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#include "FWCore/Framework/interface/Frameworkfwd.h"
2+
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
3+
#include "FWCore/Framework/interface/Event.h"
4+
#include "FWCore/Framework/interface/EventSetup.h"
5+
#include "FWCore/Framework/interface/ESWatcher.h"
6+
#include "FWCore/Framework/interface/MakerMacros.h"
7+
8+
#include "CondFormats/RunInfo/interface/LHCInfoPerFill.h"
9+
#include "CondFormats/DataRecord/interface/LHCInfoPerFillRcd.h"
10+
11+
#include <memory>
12+
#include <iostream>
13+
#include <vector>
14+
#include <cassert>
15+
16+
class LHCInfoPerFillTester : public edm::one::EDAnalyzer<> {
17+
public:
18+
explicit LHCInfoPerFillTester(const edm::ParameterSet&)
19+
: tokenInfoPerFill_(esConsumes<LHCInfoPerFill, LHCInfoPerFillRcd>()) {}
20+
21+
private:
22+
void beginJob() override {}
23+
void analyze(const edm::Event&, const edm::EventSetup&) override;
24+
void endJob() override {}
25+
26+
edm::ESWatcher<LHCInfoPerFillRcd> infoPerFillWatcher_;
27+
28+
edm::ESGetToken<LHCInfoPerFill, LHCInfoPerFillRcd> tokenInfoPerFill_;
29+
};
30+
31+
void LHCInfoPerFillTester::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
32+
assert(infoPerFillWatcher_.check(iSetup));
33+
34+
const LHCInfoPerFill& lhcInfoPerFill = iSetup.getData(tokenInfoPerFill_);
35+
const float EPS = 1E-4;
36+
assert(lhcInfoPerFill.fillNumber() == 3);
37+
assert(lhcInfoPerFill.bunchesInBeam1() == 10);
38+
assert(lhcInfoPerFill.bunchesInBeam2() == 8);
39+
assert(lhcInfoPerFill.collidingBunches() == 5);
40+
assert(lhcInfoPerFill.targetBunches() == 4);
41+
assert(lhcInfoPerFill.fillType() == lhcInfoPerFill.PROTONS);
42+
assert(lhcInfoPerFill.particleTypeForBeam1() == lhcInfoPerFill.PROTON);
43+
assert(lhcInfoPerFill.particleTypeForBeam2() == lhcInfoPerFill.PROTON);
44+
assert(abs(lhcInfoPerFill.intensityForBeam1() - 1016.5) < EPS);
45+
assert(abs(lhcInfoPerFill.intensityForBeam2() - 1096.66) < EPS);
46+
assert(abs(lhcInfoPerFill.energy() - 7000) < EPS);
47+
assert(abs(lhcInfoPerFill.delivLumi() - 2E-07) < EPS);
48+
assert(abs(lhcInfoPerFill.recLumi() - 2E-07) < EPS);
49+
assert(abs(lhcInfoPerFill.instLumi() - 0) < EPS);
50+
assert(abs(lhcInfoPerFill.instLumiError() - 0) < EPS);
51+
assert(lhcInfoPerFill.createTime() == 6561530930997627120);
52+
assert(lhcInfoPerFill.beginTime() == 6561530930997627120);
53+
assert(lhcInfoPerFill.endTime() == 6561530930997627120);
54+
assert(lhcInfoPerFill.injectionScheme() == "None");
55+
assert(lhcInfoPerFill.lumiPerBX().size() == 2);
56+
assert(abs(lhcInfoPerFill.lumiPerBX()[0] - 0.000114139) < EPS);
57+
assert(abs(lhcInfoPerFill.lumiPerBX()[1] - 0.000114139) < EPS);
58+
assert(lhcInfoPerFill.lhcState() == "some lhcState");
59+
assert(lhcInfoPerFill.lhcComment() == "some lhcComment");
60+
assert(lhcInfoPerFill.ctppsStatus() == "some ctppsStatus");
61+
edm::LogInfo("LHCInfoPerFillTester") << "LHCInfoPerFill retrieved:\n" << lhcInfoPerFill;
62+
}
63+
64+
DEFINE_FWK_MODULE(LHCInfoPerFillTester);
Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
#include "FWCore/Framework/interface/Frameworkfwd.h"
2-
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
1+
#include "CondFormats/Common/interface/Time.h"
2+
#include "FWCore/Framework/interface/ESWatcher.h"
33
#include "FWCore/Framework/interface/Event.h"
44
#include "FWCore/Framework/interface/EventSetup.h"
5-
#include "FWCore/Framework/interface/ESWatcher.h"
5+
#include "FWCore/Framework/interface/Frameworkfwd.h"
66
#include "FWCore/Framework/interface/MakerMacros.h"
7+
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
8+
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
9+
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
710

811
#include "CondFormats/RunInfo/interface/LHCInfoPerLS.h"
912
#include "CondFormats/DataRecord/interface/LHCInfoPerLSRcd.h"
@@ -14,8 +17,14 @@
1417

1518
class LHCInfoPerLSAnalyzer : public edm::one::EDAnalyzer<> {
1619
public:
17-
explicit LHCInfoPerLSAnalyzer(const edm::ParameterSet&)
18-
: tokenInfoPerLS_(esConsumes<LHCInfoPerLS, LHCInfoPerLSRcd>()) {}
20+
explicit LHCInfoPerLSAnalyzer(const edm::ParameterSet& pset)
21+
: tokenInfoPerLS_(esConsumes<LHCInfoPerLS, LHCInfoPerLSRcd>()),
22+
csvFormat_(pset.getUntrackedParameter<bool>("csvFormat")),
23+
header_(pset.getUntrackedParameter<bool>("header")),
24+
iov_(pset.getUntrackedParameter<cond::Time_t>("iov")),
25+
separator_(pset.getUntrackedParameter<std::string>("separator")) {}
26+
27+
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
1928

2029
private:
2130
void beginJob() override {}
@@ -24,22 +33,39 @@ class LHCInfoPerLSAnalyzer : public edm::one::EDAnalyzer<> {
2433

2534
edm::ESWatcher<LHCInfoPerLSRcd> infoPerLSWatcher_;
2635

27-
edm::ESGetToken<LHCInfoPerLS, LHCInfoPerLSRcd> tokenInfoPerLS_;
36+
const edm::ESGetToken<LHCInfoPerLS, LHCInfoPerLSRcd> tokenInfoPerLS_;
37+
const bool csvFormat_;
38+
const bool header_;
39+
const cond::Time_t iov_;
40+
const std::string separator_;
2841
};
2942

43+
void LHCInfoPerLSAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
44+
edm::ParameterSetDescription desc;
45+
desc.addUntracked<bool>("csvFormat", false);
46+
desc.addUntracked<bool>("header", false);
47+
desc.addUntracked<std::string>("separator", ",");
48+
desc.addUntracked<cond::Time_t>("iov", 0);
49+
descriptions.add("LHCInfoPerLSAnalyzer", desc);
50+
}
51+
3052
void LHCInfoPerLSAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
3153
// get InfoPerLS
3254
assert(infoPerLSWatcher_.check(iSetup));
3355
const LHCInfoPerLS& infoPerLS = iSetup.getData(tokenInfoPerLS_);
3456

35-
assert(infoPerLS.fillNumber() == 7066);
36-
assert(infoPerLS.lumiSection() == 1);
37-
assert(infoPerLS.crossingAngleX() == 170);
38-
assert(infoPerLS.crossingAngleY() == 170);
39-
assert(infoPerLS.betaStarX() == 11);
40-
assert(infoPerLS.betaStarY() == 11);
41-
assert(infoPerLS.runNumber() == 301765);
42-
edm::LogInfo("LHCInfoPerLSAnalyzer") << "LHCInfoPerLS retrieved:\n" << infoPerLS;
57+
if (csvFormat_) {
58+
auto s = separator_;
59+
if (header_) {
60+
std::cout << "IOV" << s << "class" << s << "timestamp" << s << "runNumber" << s << "LS" << s << "xangleX" << s
61+
<< "xangleY" << s << "beta*X" << s << "beta*Y" << s << std::endl;
62+
}
63+
std::cout << iov_ << s << "LHCInfoPerLS" << s << iEvent.time().unixTime() << s << infoPerLS.runNumber() << s
64+
<< infoPerLS.lumiSection() << s << infoPerLS.crossingAngleX() << s << infoPerLS.crossingAngleY() << s
65+
<< infoPerLS.betaStarX() << s << infoPerLS.betaStarY() << s << std::endl;
66+
} else {
67+
std::cout << infoPerLS << std::endl;
68+
}
4369
}
4470

4571
DEFINE_FWK_MODULE(LHCInfoPerLSAnalyzer);
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#include "FWCore/Framework/interface/Frameworkfwd.h"
2+
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
3+
#include "FWCore/Framework/interface/Event.h"
4+
#include "FWCore/Framework/interface/EventSetup.h"
5+
#include "FWCore/Framework/interface/ESWatcher.h"
6+
#include "FWCore/Framework/interface/MakerMacros.h"
7+
8+
#include "CondFormats/RunInfo/interface/LHCInfoPerLS.h"
9+
#include "CondFormats/DataRecord/interface/LHCInfoPerLSRcd.h"
10+
11+
#include <memory>
12+
#include <iostream>
13+
#include <cassert>
14+
15+
class LHCInfoPerLSTester : public edm::one::EDAnalyzer<> {
16+
public:
17+
explicit LHCInfoPerLSTester(const edm::ParameterSet&)
18+
: tokenInfoPerLS_(esConsumes<LHCInfoPerLS, LHCInfoPerLSRcd>()) {}
19+
20+
private:
21+
void beginJob() override {}
22+
void analyze(const edm::Event&, const edm::EventSetup&) override;
23+
void endJob() override {}
24+
25+
edm::ESWatcher<LHCInfoPerLSRcd> infoPerLSWatcher_;
26+
27+
edm::ESGetToken<LHCInfoPerLS, LHCInfoPerLSRcd> tokenInfoPerLS_;
28+
};
29+
30+
void LHCInfoPerLSTester::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
31+
// get InfoPerLS
32+
assert(infoPerLSWatcher_.check(iSetup));
33+
const LHCInfoPerLS& infoPerLS = iSetup.getData(tokenInfoPerLS_);
34+
35+
assert(infoPerLS.fillNumber() == 7066);
36+
assert(infoPerLS.lumiSection() == 1);
37+
assert(infoPerLS.crossingAngleX() == 170);
38+
assert(infoPerLS.crossingAngleY() == 170);
39+
assert(infoPerLS.betaStarX() == 11);
40+
assert(infoPerLS.betaStarY() == 11);
41+
assert(infoPerLS.runNumber() == 301765);
42+
edm::LogInfo("LHCInfoPerLSTester") << "LHCInfoPerLS retrieved:\n" << infoPerLS;
43+
}
44+
45+
DEFINE_FWK_MODULE(LHCInfoPerLSTester);
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import sys
2+
3+
import FWCore.ParameterSet.Config as cms
4+
import FWCore.ParameterSet.VarParsing as VarParsing
5+
process = cms.Process('test')
6+
7+
options = VarParsing.VarParsing()
8+
options.register( 'source'
9+
, 'sqlite_file:lhcinfo_pop_test.db' #default value
10+
, VarParsing.VarParsing.multiplicity.singleton
11+
, VarParsing.VarParsing.varType.string
12+
, "Connection string to the DB where payloads are going to be read from"
13+
)
14+
options.register( 'tag'
15+
, 'LHCInfo_PopCon_test'
16+
, VarParsing.VarParsing.multiplicity.singleton
17+
, VarParsing.VarParsing.varType.string
18+
, "Tag to read from in source"
19+
)
20+
options.register( 'timestamp'
21+
, 7133428598295232512
22+
, VarParsing.VarParsing.multiplicity.singleton
23+
, VarParsing.VarParsing.varType.int
24+
, "Timestamp to which payload with relavant IOV will be read"
25+
)
26+
options.parseArguments()
27+
28+
# minimum logging
29+
process.MessageLogger = cms.Service("MessageLogger",
30+
cerr = cms.untracked.PSet(
31+
enable = cms.untracked.bool(False)
32+
),
33+
cout = cms.untracked.PSet(
34+
enable = cms.untracked.bool(True),
35+
threshold = cms.untracked.string('ERROR')
36+
)
37+
)
38+
39+
process.source = cms.Source('EmptyIOVSource',
40+
timetype = cms.string('timestamp'),
41+
firstValue = cms.uint64(options.timestamp),
42+
lastValue = cms.uint64(options.timestamp),
43+
interval = cms.uint64(1)
44+
)
45+
46+
# load info from database
47+
process.load('CondCore.CondDB.CondDB_cfi')
48+
process.CondDB.connect= options.source # SQLite input
49+
50+
process.PoolDBESSource = cms.ESSource('PoolDBESSource',
51+
process.CondDB,
52+
DumpStats = cms.untracked.bool(True),
53+
toGet = cms.VPSet(
54+
cms.PSet(
55+
record = cms.string('LHCInfoRcd'),
56+
tag = cms.string(options.tag)
57+
)
58+
)
59+
)
60+
61+
process.LHCInfoAnalyzer = cms.EDAnalyzer('LHCInfoAnalyzer')
62+
63+
process.path = cms.Path(
64+
process.LHCInfoAnalyzer
65+
)

0 commit comments

Comments
 (0)