Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:15:33

0001 -- ====== Expected name tables ======
0002 
0003 -- TPC: ebdc00_0 to ebdc23_1 (48 total)
0004 SELECT 'ebdc' || LPAD(i::text, 2, '0') || '_' || j AS name
0005 INTO TEMP expected_names_tpc
0006 FROM generate_series(0, 23) AS i,
0007      generate_series(0, 1) AS j;
0008 
0009 -- MVTX: mvtx0 to mvtx5
0010 SELECT 'mvtx' || i || '_0' AS name
0011 INTO TEMP expected_names_mvtx
0012 FROM generate_series(0, 5) AS i;
0013 
0014 -- INTT: intt0 to intt7
0015 SELECT 'intt' || i || '_0' AS name
0016 INTO TEMP expected_names_intt
0017 FROM generate_series(0, 7) AS i;
0018 
0019 -- ====== Extract relevant DST entries ======
0020 
0021 CREATE TEMP TABLE all_streams AS
0022 SELECT 
0023   ps.run,
0024   ps.segment,
0025   ps.status,
0026   CASE
0027     WHEN ps.dsttype LIKE 'DST_STREAMING_EVENT_ebdc%' THEN regexp_replace(ps.dsttype, '^DST_STREAMING_EVENT_(ebdc\d{2}_\d)_run3auau$', '\1')
0028     WHEN ps.dsttype LIKE 'DST_STREAMING_EVENT_mvtx%' THEN regexp_replace(ps.dsttype, '^DST_STREAMING_EVENT_(mvtx\d+_0)_run3auau$', '\1')
0029     WHEN ps.dsttype LIKE 'DST_STREAMING_EVENT_intt%' THEN regexp_replace(ps.dsttype, '^DST_STREAMING_EVENT_(intt\d+_0)_run3auau$', '\1')
0030   END AS name
0031 FROM production_status ps
0032 WHERE ps.dsttype ~ '^DST_STREAMING_EVENT_(ebdc|mvtx|intt)'
0033   AND ps.dsttype LIKE '%run3auau'
0034   AND ps.run IN (SELECT run FROM transferred_runs);
0035 
0036 -- ====== Run summaries ======
0037 
0038 -- Generic summary function
0039 CREATE TEMP TABLE run_summary_tpc AS
0040 SELECT
0041   s.run,
0042   COUNT(*) FILTER (WHERE s.segment = 0 AND s.name IN (SELECT name FROM expected_names_tpc)) AS seg0_total,
0043   COUNT(*) FILTER (WHERE s.segment = 0 AND s.status = 'finished' AND s.name IN (SELECT name FROM expected_names_tpc)) AS seg0_finished,
0044   COUNT(DISTINCT s.name) FILTER (WHERE s.segment = 0 AND s.status = 'finished' AND s.name IN (SELECT name FROM expected_names_tpc)) AS seg0_unique_names,
0045   COUNT(*) FILTER (WHERE s.status = 'running' AND s.name IN (SELECT name FROM expected_names_tpc)) AS running_count,
0046   COUNT(*) FILTER (WHERE s.status != 'finished' AND s.name IN (SELECT name FROM expected_names_tpc)) AS not_finished_count
0047 FROM all_streams s GROUP BY s.run;
0048 
0049 CREATE TEMP TABLE run_summary_mvtx AS
0050 SELECT
0051   s.run,
0052   COUNT(*) FILTER (WHERE s.segment = 0 AND s.name IN (SELECT name FROM expected_names_mvtx)) AS seg0_total,
0053   COUNT(*) FILTER (WHERE s.segment = 0 AND s.status = 'finished' AND s.name IN (SELECT name FROM expected_names_mvtx)) AS seg0_finished,
0054   COUNT(DISTINCT s.name) FILTER (WHERE s.segment = 0 AND s.status = 'finished' AND s.name IN (SELECT name FROM expected_names_mvtx)) AS seg0_unique_names,
0055   COUNT(*) FILTER (WHERE s.status = 'running' AND s.name IN (SELECT name FROM expected_names_mvtx)) AS running_count,
0056   COUNT(*) FILTER (WHERE s.status != 'finished' AND s.name IN (SELECT name FROM expected_names_mvtx)) AS not_finished_count
0057 FROM all_streams s GROUP BY s.run;
0058 
0059 CREATE TEMP TABLE run_summary_intt AS
0060 SELECT
0061   s.run,
0062   COUNT(*) FILTER (WHERE s.segment = 0 AND s.name IN (SELECT name FROM expected_names_intt)) AS seg0_total,
0063   COUNT(*) FILTER (WHERE s.segment = 0 AND s.status = 'finished' AND s.name IN (SELECT name FROM expected_names_intt)) AS seg0_finished,
0064   COUNT(DISTINCT s.name) FILTER (WHERE s.segment = 0 AND s.status = 'finished' AND s.name IN (SELECT name FROM expected_names_intt)) AS seg0_unique_names,
0065   COUNT(*) FILTER (WHERE s.status = 'running' AND s.name IN (SELECT name FROM expected_names_intt)) AS running_count,
0066   COUNT(*) FILTER (WHERE s.status != 'finished' AND s.name IN (SELECT name FROM expected_names_intt)) AS not_finished_count
0067 FROM all_streams s GROUP BY s.run;
0068 
0069 -- ====== Individual classification ======
0070 
0071 -- TPC
0072 SELECT run INTO TEMP tpc_fully_finished FROM run_summary_tpc WHERE seg0_total = 48 AND seg0_finished = 48 AND seg0_unique_names = 48 AND running_count = 0 AND not_finished_count = 0;
0073 SELECT run INTO TEMP tpc_segment0_finished FROM run_summary_tpc WHERE seg0_finished = 48;
0074 SELECT run INTO TEMP tpc_still_running FROM run_summary_tpc WHERE running_count > 0 AND not_finished_count > 0;
0075 
0076 -- MVTX
0077 SELECT run INTO TEMP mvtx_fully_finished FROM run_summary_mvtx WHERE seg0_total = 6 AND seg0_finished = 6 AND seg0_unique_names = 6 AND running_count = 0 AND not_finished_count = 0;
0078 SELECT run INTO TEMP mvtx_segment0_finished FROM run_summary_mvtx WHERE seg0_finished = 6;
0079 SELECT run INTO TEMP mvtx_still_running FROM run_summary_mvtx WHERE running_count > 0 AND not_finished_count > 0;
0080 
0081 -- INTT
0082 SELECT run INTO TEMP intt_fully_finished FROM run_summary_intt WHERE seg0_total = 8 AND seg0_finished = 8 AND seg0_unique_names = 8 AND running_count = 0 AND not_finished_count = 0;
0083 SELECT run INTO TEMP intt_segment0_finished FROM run_summary_intt WHERE seg0_finished = 8;
0084 SELECT run INTO TEMP intt_still_running FROM run_summary_intt WHERE running_count > 0 AND not_finished_count > 0;
0085 
0086 -- ====== Global AND classification ======
0087 
0088 SELECT run INTO TEMP fully_finished_global
0089 FROM tpc_fully_finished
0090 INTERSECT
0091 SELECT run FROM mvtx_fully_finished
0092 INTERSECT
0093 SELECT run FROM intt_fully_finished;
0094 
0095 SELECT run INTO TEMP segment0_finished_global
0096 FROM tpc_segment0_finished
0097 INTERSECT
0098 SELECT run FROM mvtx_segment0_finished
0099 INTERSECT
0100 SELECT run FROM intt_segment0_finished;
0101 
0102 SELECT run INTO TEMP still_running_global
0103 FROM tpc_still_running
0104 UNION
0105 SELECT run FROM mvtx_still_running
0106 UNION
0107 SELECT run FROM intt_still_running;
0108 
0109 --SELECT run FROM still_running_global ORDER BY run DESC \g /dev/null
0110 -- TPC
0111 CREATE TEMP VIEW ordered_tpc_fully_finished AS SELECT run FROM tpc_fully_finished ORDER BY run DESC;
0112 CREATE TEMP VIEW ordered_tpc_segment0_finished AS SELECT run FROM tpc_segment0_finished ORDER BY run DESC;
0113 CREATE TEMP VIEW ordered_tpc_still_running AS SELECT run FROM tpc_still_running ORDER BY run DESC;
0114 
0115 -- MVTX
0116 CREATE TEMP VIEW ordered_mvtx_fully_finished AS SELECT run FROM mvtx_fully_finished ORDER BY run DESC;
0117 CREATE TEMP VIEW ordered_mvtx_segment0_finished AS SELECT run FROM mvtx_segment0_finished ORDER BY run DESC;
0118 CREATE TEMP VIEW ordered_mvtx_still_running AS SELECT run FROM mvtx_still_running ORDER BY run DESC;
0119 
0120 -- INTT
0121 CREATE TEMP VIEW ordered_intt_fully_finished AS SELECT run FROM intt_fully_finished ORDER BY run DESC;
0122 CREATE TEMP VIEW ordered_intt_segment0_finished AS SELECT run FROM intt_segment0_finished ORDER BY run DESC;
0123 CREATE TEMP VIEW ordered_intt_still_running AS SELECT run FROM intt_still_running ORDER BY run DESC;
0124 
0125 -- GLOBAL
0126 CREATE TEMP VIEW ordered_fully_finished_global AS SELECT run FROM fully_finished_global ORDER BY run DESC;
0127 CREATE TEMP VIEW ordered_segment0_finished_global AS SELECT run FROM segment0_finished_global ORDER BY run DESC;
0128 CREATE TEMP VIEW ordered_still_running_global AS SELECT run FROM still_running_global ORDER BY run DESC \g /dev/null