6 #include <fmt/printf.h> 21 class AlCaRecoTriggerBits_Display :
public PlotImage<AlCaRecoTriggerBits, SINGLE_IOV> {
25 bool fill()
override {
26 auto tag = PlotBase::getTag<0>();
27 auto iov =
tag.iovs.front();
28 std::shared_ptr<AlCaRecoTriggerBits>
payload = fetchPayload(std::get<1>(iov));
33 typedef std::map<std::string, std::string> TriggerMap;
34 const TriggerMap &triggerMap =
payload->m_alcarecoToTrig;
36 unsigned int mapsize = triggerMap.size();
37 float pitch = 1. / (mapsize * 1.1);
40 std::vector<float> y_x1, y_x2, y_line;
41 std::vector<std::string> s_x1, s_x2, s_x3;
51 s_x1.push_back(
"#scale[1.2]{Key}");
53 s_x2.push_back(
"#scale[1.2]{tag: " +
tag.name +
" in IOV: " + IOVsince +
"}");
58 for (
const auto &element : triggerMap) {
61 s_x1.push_back(element.first);
63 std::vector<std::string>
output;
65 const std::vector<std::string>
paths =
payload->decompose(element.second);
66 for (
unsigned int iPath = 0; iPath <
paths.size(); ++iPath) {
68 if ((toAppend +
paths[iPath]).length() < 60) {
69 toAppend +=
paths[iPath] +
";";
72 output.push_back(toAppend);
74 toAppend +=
paths[iPath] +
";";
77 if (iPath ==
paths.size() - 1)
78 output.push_back(toAppend);
83 s_x2.push_back(
"#color[2]{" +
output[
br] +
"}");
88 y_line.push_back(y - (pitch / 2.));
91 TCanvas
canvas(
"AlCaRecoTriggerBits",
"AlCaRecoTriggerBits", 2000,
std::max(y_x1.size(), y_x2.size()) * 40);
96 float newpitch = 1 / (
std::max(y_x1.size(), y_x2.size()) * 1.1);
97 float factor = newpitch / pitch;
98 l.SetTextSize(newpitch - 0.002);
100 for (
unsigned int i = 0;
i < y_x1.size();
i++) {
101 l.DrawLatexNDC(
x1, 1 - (1 - y_x1[
i]) *
factor, s_x1[
i].c_str());
104 for (
unsigned int i = 0;
i < y_x2.size();
i++) {
105 l.DrawLatexNDC(
x2, 1 - (1 - y_x2[
i]) *
factor, s_x2[
i].c_str());
111 TLine
lines[y_line.size()];
113 for (
const auto &
line : y_line) {
115 lines[iL].SetLineWidth(1);
116 lines[iL].SetLineStyle(9);
117 lines[iL].SetLineColor(2);
118 lines[iL].Draw(
"same");
131 template <IOVMultiplicity nIOVs,
int ntags>
132 class AlCaRecoTriggerBits_CompareBase :
public PlotImage<AlCaRecoTriggerBits, nIOVs, ntags> {
134 AlCaRecoTriggerBits_CompareBase()
137 bool fill()
override {
139 auto theIOVs = PlotBase::getTag<0>().iovs;
140 auto f_tagname = PlotBase::getTag<0>().
name;
142 auto firstiov = theIOVs.front();
143 std::tuple<cond::Time_t, cond::Hash> lastiov;
146 assert(this->m_plotAnnotations.ntags < 3);
148 if (this->m_plotAnnotations.ntags == 2) {
149 auto tag2iovs = PlotBase::getTag<1>().iovs;
150 l_tagname = PlotBase::getTag<1>().
name;
151 lastiov = tag2iovs.front();
153 lastiov = theIOVs.back();
156 std::shared_ptr<AlCaRecoTriggerBits> last_payload = this->fetchPayload(std::get<1>(lastiov));
157 std::shared_ptr<AlCaRecoTriggerBits> first_payload = this->fetchPayload(std::get<1>(firstiov));
163 typedef std::map<std::string, std::string> TriggerMap;
164 const TriggerMap &first_triggerMap = first_payload->m_alcarecoToTrig;
165 const TriggerMap &last_triggerMap = last_payload->m_alcarecoToTrig;
167 std::vector<std::string> first_keys, not_in_first_keys;
168 std::vector<std::string> last_keys, not_in_last_keys;
171 for (
const auto &element : first_triggerMap) {
172 first_keys.push_back(element.first);
176 for (
const auto &element : last_triggerMap) {
177 last_keys.push_back(element.first);
185 std::inserter(not_in_last_keys, not_in_last_keys.begin()));
191 std::inserter(not_in_first_keys, not_in_first_keys.begin()));
196 std::vector<float> y_x1, y_x2, y_x3, y_line;
197 std::vector<std::string> s_x1, s_x2, s_x3;
206 s_x1.push_back(
"#scale[1.2]{Key}");
208 s_x2.push_back(fmt::sprintf(
"#scale[1.2]{%s in IOV: %s}", f_tagname, firstIOVsince));
210 s_x3.push_back(fmt::sprintf(
"#scale[1.2]{%s in IOV: %s}", l_tagname, lastIOVsince));
214 for (
const auto &
key : not_in_last_keys) {
219 const std::vector<std::string> missing_in_last_paths = first_payload->decompose(first_triggerMap.at(
key));
221 std::vector<std::string>
output;
223 for (
unsigned int iPath = 0; iPath < missing_in_last_paths.size(); ++iPath) {
225 if ((toAppend + missing_in_last_paths[iPath]).length() < 60) {
226 toAppend += missing_in_last_paths[iPath] +
";";
229 output.push_back(toAppend);
231 toAppend += missing_in_last_paths[iPath] +
";";
234 if (iPath == missing_in_last_paths.size() - 1)
235 output.push_back(toAppend);
240 s_x2.push_back(
"#color[2]{" +
output[
br] +
"}");
244 y_line.push_back(y - 0.008);
248 for (
const auto &
key : not_in_first_keys) {
252 const std::vector<std::string> missing_in_first_paths = last_payload->decompose(last_triggerMap.at(
key));
254 std::vector<std::string>
output;
256 for (
unsigned int iPath = 0; iPath < missing_in_first_paths.size(); ++iPath) {
258 if ((toAppend + missing_in_first_paths[iPath]).length() < 60) {
259 toAppend += missing_in_first_paths[iPath] +
";";
262 output.push_back(toAppend);
264 toAppend += missing_in_first_paths[iPath] +
";";
267 if (iPath == missing_in_first_paths.size() - 1)
268 output.push_back(toAppend);
273 s_x3.push_back(
"#color[4]{" +
output[
br] +
"}");
277 y_line.push_back(y - 0.008);
280 for (
const auto &element : first_triggerMap) {
281 if (last_triggerMap.find(element.first) != last_triggerMap.end()) {
282 auto lastElement = last_triggerMap.find(element.first);
285 const std::vector<std::string> first_paths = first_payload->decompose(element.second);
286 const std::vector<std::string> last_paths = last_payload->decompose(lastElement->second);
288 std::vector<std::string> not_in_first;
289 std::vector<std::string> not_in_last;
295 std::inserter(not_in_last, not_in_last.begin()));
301 std::inserter(not_in_first, not_in_first.begin()));
303 if (!not_in_last.empty() || !not_in_first.empty()) {
306 s_x1.push_back(element.first);
308 std::vector<std::string>
output;
310 for (
unsigned int iPath = 0; iPath < not_in_last.size(); ++iPath) {
312 if ((toAppend + not_in_last[iPath]).length() < 60) {
313 toAppend += not_in_last[iPath] +
";";
316 output.push_back(toAppend);
318 toAppend += not_in_last[iPath] +
";";
321 if (toAppend.length() > 0 && iPath == not_in_last.size() - 1)
322 output.push_back(toAppend);
328 y_x2.push_back(y - (
br * pitch));
329 s_x2.push_back(
"#color[6]{" +
output[
br] +
"}");
335 for (
unsigned int jPath = 0; jPath < not_in_first.size(); ++jPath) {
337 if ((toAppend + not_in_first[jPath]).length() < 60) {
338 toAppend += not_in_first[jPath] +
";";
341 output.push_back(toAppend);
343 toAppend += not_in_first[jPath] +
";";
346 if (toAppend.length() > 0 && jPath == not_in_first.size() - 1)
347 output.push_back(toAppend);
350 unsigned int count1 =
output.size();
352 for (
unsigned int br = 0;
br < count1;
br++) {
353 y_x3.push_back(y - (
br * pitch));
354 s_x3.push_back(
"#color[8]{" +
output[
br] +
"}");
360 y_line.push_back(y - 0.008);
366 TCanvas
canvas(
"AlCaRecoTriggerBits",
"AlCaRecoTriggerBits", 2500.,
std::max(y_x1.size(), y_x2.size()) * 40);
373 float newpitch = 1 / (
std::max(y_x1.size(), y_x2.size()) * 1.65);
374 float factor = newpitch / pitch;
375 l.SetTextSize(newpitch - 0.002);
377 for (
unsigned int i = 0;
i < y_x1.size();
i++) {
378 l.DrawLatexNDC(
x1, 1 - (1 - y_x1[
i]) *
factor, s_x1[
i].c_str());
381 for (
unsigned int i = 0;
i < y_x2.size();
i++) {
382 l.DrawLatexNDC(
x2, 1 - (1 - y_x2[
i]) *
factor, s_x2[
i].c_str());
385 for (
unsigned int i = 0;
i < y_x3.size();
i++) {
386 l.DrawLatexNDC(x3, 1 - (1 - y_x3[
i]) *
factor, s_x3[
i].c_str());
392 TLine
lines[y_line.size()];
394 for (
const auto &
line : y_line) {
396 lines[iL].SetLineWidth(1);
397 lines[iL].SetLineStyle(9);
398 lines[iL].SetLineColor(2);
399 lines[iL].Draw(
"same");
410 using AlCaRecoTriggerBits_Compare = AlCaRecoTriggerBits_CompareBase<MULTI_IOV, 1>;
411 using AlCaRecoTriggerBits_CompareTwoTags = AlCaRecoTriggerBits_CompareBase<SINGLE_IOV, 2>;
std::string to_string(const V &value)
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)