Skip to content

Commit d3b0b47

Browse files
authored
Merge pull request #48451 from mmusich/mm_LHCInfo_PI
Introduce a stub of `LHCInfoPer*` Payload Inspector
2 parents 6953b9f + 412fdbd commit d3b0b47

File tree

5 files changed

+205
-1
lines changed

5 files changed

+205
-1
lines changed

CondCore/RunInfoPlugins/plugins/BuildFile.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,14 @@
33
<use name="CondCore/Utilities"/>
44
<use name="CondCore/CondDB"/>
55
</library>
6+
7+
<library file="LHCInfoPerFill_PayloadInspector.cc" name="LHCInfoPerFill_PayloadInspector">
8+
<use name="CondCore/Utilities"/>
9+
<use name="CondCore/CondDB"/>
10+
</library>
11+
12+
<library file="LHCInfoPerLS_PayloadInspector.cc" name="LHCInfoPerLS_PayloadInspector">
13+
<use name="CondCore/Utilities"/>
14+
<use name="CondCore/CondDB"/>
15+
</library>
16+
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#include "CondCore/Utilities/interface/PayloadInspectorModule.h"
2+
#include "CondCore/Utilities/interface/PayloadInspector.h"
3+
#include "CondFormats/RunInfo/interface/LHCInfoPerFill.h"
4+
#include "FWCore/MessageLogger/interface/MessageLogger.h"
5+
6+
#include <sstream>
7+
#include <memory>
8+
#include "TLatex.h"
9+
#include "TCanvas.h"
10+
11+
namespace {
12+
13+
class LHCInfoPerFill_Display : public cond::payloadInspector::PlotImage<LHCInfoPerFill> {
14+
public:
15+
LHCInfoPerFill_Display()
16+
: cond::payloadInspector::PlotImage<LHCInfoPerFill>("LHCInfoPerFill Inspector - Display") {}
17+
18+
bool fill() override {
19+
auto tag = PlotBase::getTag<0>();
20+
auto iov = tag.iovs.front();
21+
std::shared_ptr<LHCInfoPerFill> payload = fetchPayload(std::get<1>(iov));
22+
if (!payload) {
23+
return false;
24+
}
25+
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);
37+
canvas.cd();
38+
TLatex latex;
39+
latex.SetTextSize(0.03);
40+
41+
float startY = 0.95;
42+
float stepY = 0.06;
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());
57+
}
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);
73+
canvas.SaveAs(fileName.c_str());
74+
75+
return true;
76+
}
77+
};
78+
79+
} // namespace
80+
81+
PAYLOAD_INSPECTOR_MODULE(LHCInfoPerFill) { PAYLOAD_INSPECTOR_CLASS(LHCInfoPerFill_Display); }
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#include "CondCore/Utilities/interface/PayloadInspectorModule.h"
2+
#include "CondCore/Utilities/interface/PayloadInspector.h"
3+
#include "CondFormats/RunInfo/interface/LHCInfoPerLS.h"
4+
#include "FWCore/MessageLogger/interface/MessageLogger.h"
5+
6+
#include <sstream>
7+
#include <memory>
8+
#include "TLatex.h"
9+
#include "TCanvas.h"
10+
11+
namespace {
12+
13+
class LHCInfoPerLS_Display : public cond::payloadInspector::PlotImage<LHCInfoPerLS> {
14+
public:
15+
LHCInfoPerLS_Display() : cond::payloadInspector::PlotImage<LHCInfoPerLS>("LHCInfoPerLS Inspector - Display") {}
16+
17+
bool fill() override {
18+
auto tag = PlotBase::getTag<0>();
19+
auto iov = tag.iovs.front();
20+
std::shared_ptr<LHCInfoPerLS> payload = fetchPayload(std::get<1>(iov));
21+
if (!payload) {
22+
return false;
23+
}
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())});
33+
// Add more fields as needed
34+
35+
TCanvas canvas("c", "c", 800, 600);
36+
canvas.cd();
37+
TLatex latex;
38+
latex.SetTextSize(0.03);
39+
40+
float startY = 0.95;
41+
float stepY = 0.06;
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());
57+
}
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);
73+
canvas.SaveAs(fileName.c_str());
74+
75+
return true;
76+
}
77+
};
78+
79+
} // namespace
80+
81+
PAYLOAD_INSPECTOR_MODULE(LHCInfoPerLS) { PAYLOAD_INSPECTOR_CLASS(LHCInfoPerLS_Display); }

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
}

CondCore/RunInfoPlugins/test/testRunInfoPayloadInspector.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,12 @@ mv *.png $W_DIR/plots/fake_payload.png
2727

2828
getPayloadData.py --plugin pluginRunInfo_PayloadInspector --plot plot_RunInfoParameters --tag runinfo_31X_hlt --time_type Run --iovs '{"start_iov": "312259", "end_iov": "312259"}' --db Prod --test ;
2929
mv *.png $W_DIR/plots/OK_payload.png
30+
31+
####################
32+
# Test LHCInfo
33+
####################
34+
getPayloadData.py --plugin pluginLHCInfoPerLS_PayloadInspector --plot plot_LHCInfoPerLS_Display --tag LHCInfoPerLS_duringFill_hlt_v1 --time_type LS --iovs '{"start_iov": "1690138350452868", "end_iov": "1690138350452868"}' --db Prod --test ;
35+
mv *.png $W_DIR/plots/LHCInfoPerLS.png
36+
37+
getPayloadData.py --plugin pluginLHCInfoPerFill_PayloadInspector --plot plot_LHCInfoPerFill_Display --tag LHCInfoPerFill_duringFill_hlt_v1 --time_type LS --iovs '{"start_iov": "1686852700471354", "end_iov": "1686852700471354"}' --db Prod --test ;
38+
mv *.png $W_DIR/plots/LHCInfoPerFill.png

0 commit comments

Comments
 (0)