Skip to content

Commit 412fdbd

Browse files
committed
improvements and add unit tests
1 parent c5dad5c commit 412fdbd

File tree

3 files changed

+107
-33
lines changed

3 files changed

+107
-33
lines changed

CondCore/RunInfoPlugins/plugins/LHCInfoPerFill_PayloadInspector.cc

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,55 @@ namespace {
2323
return false;
2424
}
2525

26-
std::vector<std::string> lines;
27-
lines.push_back("LHCInfoPerFill Inspector");
28-
lines.push_back("");
29-
lines.push_back("Fill Number: " + std::to_string(payload->fillNumber()));
30-
lines.push_back("Beam Energy: " + std::to_string(payload->energy()));
31-
lines.push_back("Deliv Lumi: " + std::to_string(payload->delivLumi()));
32-
lines.push_back("Rec Lumi: " + std::to_string(payload->recLumi()));
33-
lines.push_back("Inst Lumi: " + std::to_string(payload->instLumi()));
34-
lines.push_back("Injection Scheme: " + payload->injectionScheme());
35-
lines.push_back("Colliding Bunches: " + std::to_string(payload->collidingBunches()));
36-
lines.push_back("Target Bunches: " + std::to_string(payload->targetBunches()));
37-
38-
TCanvas canvas("c","c",800,600);
26+
std::vector<std::pair<std::string, std::string>> items;
27+
items.push_back({"Fill Number: ", std::to_string(payload->fillNumber())});
28+
items.push_back({"Beam Energy: ", std::to_string(payload->energy())});
29+
items.push_back({"Deliv Lumi: ", std::to_string(payload->delivLumi())});
30+
items.push_back({"Rec Lumi: ", std::to_string(payload->recLumi())});
31+
items.push_back({"Inst Lumi: ", std::to_string(payload->instLumi())});
32+
items.push_back({"Injection Scheme: ", payload->injectionScheme()});
33+
items.push_back({"Colliding Bunches: ", std::to_string(payload->collidingBunches())});
34+
items.push_back({"Target Bunches: ", std::to_string(payload->targetBunches())});
35+
36+
TCanvas canvas("c", "c", 800, 600);
3937
canvas.cd();
4038
TLatex latex;
4139
latex.SetTextSize(0.03);
42-
40+
4341
float startY = 0.95;
4442
float stepY = 0.06;
45-
for (std::size_t i = 0; i < lines.size(); ++i) {
46-
latex.DrawLatexNDC(0.05, startY - i * stepY, lines[i].c_str());
43+
44+
// Print the title
45+
latex.SetTextColor(kBlack);
46+
latex.DrawLatexNDC(0.05, startY, "LHCInfoPerFill Inspector");
47+
48+
// Print the fields with values in red
49+
for (std::size_t i = 0; i < items.size(); ++i) {
50+
float y = startY - (i + 2) * stepY; // +2 to skip title and add a blank line
51+
// Print key in black
52+
latex.SetTextColor(kBlack);
53+
latex.DrawLatexNDC(0.05, y, items[i].first.c_str());
54+
// Print value in red, offset to the right (adjust offset as needed)
55+
latex.SetTextColor(kRed);
56+
latex.DrawLatexNDC(0.30, y, items[i].second.c_str());
4757
}
48-
std::string fileName = "LHCInfoPerFill.png";
58+
59+
// info
60+
TLatex t1;
61+
t1.SetNDC();
62+
t1.SetTextAlign(12);
63+
t1.SetTextSize(0.04);
64+
t1.DrawLatex(0.1, 0.18, "LHCInfo parameters:");
65+
t1.DrawLatex(0.1, 0.15, "payload:");
66+
67+
t1.SetTextFont(42);
68+
t1.SetTextColor(4);
69+
t1.DrawLatex(0.37, 0.182, Form("IOV %s", std::to_string(+std::get<0>(iov)).c_str()));
70+
t1.DrawLatex(0.21, 0.152, Form(" %s", (std::get<1>(iov)).c_str()));
71+
72+
std::string fileName(m_imageFileName);
4973
canvas.SaveAs(fileName.c_str());
74+
5075
return true;
5176
}
5277
};

CondCore/RunInfoPlugins/plugins/LHCInfoPerLS_PayloadInspector.cc

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,57 @@ namespace {
2121
if (!payload) {
2222
return false;
2323
}
24-
// Prepare lines for printing
25-
std::vector<std::string> lines;
26-
lines.push_back("LHCInfoPerLS Inspector");
27-
lines.push_back("");
28-
lines.push_back("LS: " + std::to_string(payload->lumiSection()));
29-
lines.push_back("crossingAngleX: " + std::to_string(payload->crossingAngleX()));
30-
lines.push_back("crossingAngleY: " + std::to_string(payload->crossingAngleY()));
31-
lines.push_back("betaStarX: " + std::to_string(payload->betaStarX()));
32-
lines.push_back("betaStarY: " + std::to_string(payload->betaStarY()));
33-
lines.push_back("runNumber: " + std::to_string(payload->runNumber()));
24+
25+
// Prepare label-value pairs for printing
26+
std::vector<std::pair<std::string, std::string>> items;
27+
items.push_back({"LS: ", std::to_string(payload->lumiSection())});
28+
items.push_back({"crossingAngleX: ", std::to_string(payload->crossingAngleX())});
29+
items.push_back({"crossingAngleY: ", std::to_string(payload->crossingAngleY())});
30+
items.push_back({"betaStarX: ", std::to_string(payload->betaStarX())});
31+
items.push_back({"betaStarY: ", std::to_string(payload->betaStarY())});
32+
items.push_back({"runNumber: ", std::to_string(payload->runNumber())});
3433
// Add more fields as needed
3534

36-
TCanvas canvas("c","c",800,600);
35+
TCanvas canvas("c", "c", 800, 600);
3736
canvas.cd();
3837
TLatex latex;
3938
latex.SetTextSize(0.03);
40-
39+
4140
float startY = 0.95;
4241
float stepY = 0.06;
43-
for (std::size_t i = 0; i < lines.size(); ++i) {
44-
latex.DrawLatexNDC(0.05, startY - i * stepY, lines[i].c_str());
42+
43+
// Print the title
44+
latex.SetTextColor(kBlack);
45+
latex.DrawLatexNDC(0.05, startY, "LHCInfoPerLS Inspector");
46+
47+
// Leave a blank line under the title
48+
std::size_t offset = 2;
49+
50+
// Print each item: label in black, value in red
51+
for (std::size_t i = 0; i < items.size(); ++i) {
52+
float y = startY - (i + offset) * stepY;
53+
latex.SetTextColor(kBlack);
54+
latex.DrawLatexNDC(0.05, y, items[i].first.c_str());
55+
latex.SetTextColor(kRed);
56+
latex.DrawLatexNDC(0.30, y, items[i].second.c_str());
4557
}
46-
std::string fileName = "LHCInfoPerLS.png";
58+
59+
// info
60+
TLatex t1;
61+
t1.SetNDC();
62+
t1.SetTextAlign(12);
63+
t1.SetTextSize(0.04);
64+
t1.DrawLatex(0.1, 0.18, "LHCInfo parameters:");
65+
t1.DrawLatex(0.1, 0.15, "payload:");
66+
67+
t1.SetTextFont(42);
68+
t1.SetTextColor(4);
69+
t1.DrawLatex(0.37, 0.182, Form("IOV %s", std::to_string(+std::get<0>(iov)).c_str()));
70+
t1.DrawLatex(0.21, 0.152, Form(" %s", (std::get<1>(iov)).c_str()));
71+
72+
std::string fileName(m_imageFileName);
4773
canvas.SaveAs(fileName.c_str());
74+
4875
return true;
4976
}
5077
};

CondCore/RunInfoPlugins/test/testRunInfoPayloadInspector.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
#include <sstream>
33
#include "CondCore/Utilities/interface/PayloadInspector.h"
44
#include "CondCore/RunInfoPlugins/plugins/RunInfo_PayloadInspector.cc"
5-
5+
#include "CondCore/RunInfoPlugins/plugins/LHCInfoPerFill_PayloadInspector.cc"
6+
#include "CondCore/RunInfoPlugins/plugins/LHCInfoPerLS_PayloadInspector.cc"
67
#include "FWCore/PluginManager/interface/PluginManager.h"
78
#include "FWCore/PluginManager/interface/standard.h"
89
#include "FWCore/ServiceRegistry/interface/ServiceRegistry.h"
@@ -38,5 +39,26 @@ int main(int argc, char** argv) {
3839
RunInfoBFieldHistory histo2;
3940
histo2.process(connectionString, PI::mk_input(tag, start, end));
4041
std::cout << histo2.data() << std::endl;
42+
43+
std::cout << "## LHCInfoPerFill testing" << std::endl;
44+
45+
tag = "LHCInfoPerFill_duringFill_hlt_v1";
46+
start = static_cast<unsigned long long>(1686852700471354);
47+
end = static_cast<unsigned long long>(1686852700471354);
48+
49+
LHCInfoPerFill_Display histo3;
50+
histo3.process(connectionString, PI::mk_input(tag, end, end));
51+
std::cout << histo3.data() << std::endl;
52+
53+
std::cout << "## LHCInfoPerLS testing" << std::endl;
54+
55+
tag = "LHCInfoPerLS_duringFill_hlt_v1";
56+
start = static_cast<unsigned long long>(1690138350452868);
57+
end = static_cast<unsigned long long>(1690138350452868);
58+
59+
LHCInfoPerLS_Display histo4;
60+
histo4.process(connectionString, PI::mk_input(tag, end, end));
61+
std::cout << histo4.data() << std::endl;
62+
4163
Py_Finalize();
4264
}

0 commit comments

Comments
 (0)