diff --git a/general_codes/genki/DST_viewer/intt_check_dst.py b/general_codes/genki/DST_viewer/intt_check_dst.py new file mode 100755 index 00000000..85afd1c8 --- /dev/null +++ b/general_codes/genki/DST_viewer/intt_check_dst.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python3 + +import os +import sys +import subprocess as sp + +SCRIPT_PATH = "" +ROOT_MACRO_NAME = "show_dst_contents.cc" +KEYWORD = "List of Nodes in Fun4AllServer:" + +def Check( data = "", debug=False ) : + """ + @brief A function to check nodes in the given DST file + """ + + # Argument to root command depends on debug/normal mode + if debug is False : + # It's something like: root aaa.cc("data.root") + root_macro = SCRIPT_PATH + "/" + ROOT_MACRO_NAME + "(\"" + data + "\")" + else : + # Here is for debug mode + # It's something like: root aaa.cc + root_macro = SCRIPT_PATH + "/" + ROOT_MACRO_NAME + + proc = sp.Popen( ["root", "-l", "-q", "-b", root_macro ], stdout=sp.PIPE ) + # I can add timeout feature.. + proc.wait() + + # Get stdout ans show only the node information + results = proc.communicate()[0].decode( "utf-8" ) + is_started = False + print( "DST:", data ) + for line in results.split( "\n" ) : + if line == KEYWORD : + is_started = True + elif is_started == True and line == "" : + break + + if is_started is True : + # Cool tre structure... not made yet + # words = line.replace( " ", "aa" ) + # print( words ) + print( line ) + # End of for line in results.split( "\n" ) + +def HowToUse() : + print( "Usage:", script_name, "[path to the DST to be checked]" ) + print( "For exmple:\n $", script_name, + "/sphenix/lustre01/sphnxpro/physics/slurp/streaming/physics/inttonlyrun_00051100_00051200/DST_INTT_EVENT_run2pp_new_2024p002-00051100-00000.root" ) + +if __name__ == "__main__" : + args = sys.argv + + # This script requires a path to the DST. If the format is different from the requirement, show how to use and exit + if len( args ) != 2 : + script_name = args[0].split( "/" )[-1] + HowToUse() + os.sys.exit() + + # Is global-like use OK? + SCRIPT_PATH = os.path.dirname( args[0] ) + data = args[1] + debug = False + + # Argument modification for the debug mode + if data == "debug" : + print( "Debug mode" ) + data = "" + debug = True + elif os.path.exists( data ) is False : + # If the given DST is not found, do nothing + print( data, "is not found" ) + HowToUse() + os.sys.exit() + + Check( data, debug=debug ) diff --git a/general_codes/genki/DST_viewer/intt_check_dst.sh b/general_codes/genki/DST_viewer/intt_check_dst.sh new file mode 100755 index 00000000..a09e2ea7 --- /dev/null +++ b/general_codes/genki/DST_viewer/intt_check_dst.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# If a single argument is not given, show how to use it +if [ $# -ne 1 ] ; +then + echo " [Usage]: ${0##*/} [path to a DST file]" + exit +fi + +if [ ${1} == "debug" ] ; +then + time root -l -q -b /sphenix/tg/tg01/commissioning/INTT/work/genki/repos/INTT/general_codes/genki/DST_viewer/show_dst_contents.cc +elif [ ! -f ${1} ] ; +then + echo "${1} is not found." + exit +fi + +#time root -l -q -b /sphenix/tg/tg01/commissioning/INTT/work/genki/repos/INTT/general_codes/genki/DST_viewer/show_dst_contents.cc diff --git a/general_codes/genki/DST_viewer/show_dst_contents.cc b/general_codes/genki/DST_viewer/show_dst_contents.cc new file mode 100644 index 00000000..8d99738a --- /dev/null +++ b/general_codes/genki/DST_viewer/show_dst_contents.cc @@ -0,0 +1,21 @@ +#include + +#include +R__LOAD_LIBRARY(libfun4all.so) +R__LOAD_LIBRARY( libffarawobjects.so ) // OK + +int show_dst_contents( const string &data = "/sphenix/lustre01/sphnxpro/physics/slurp/streaming/physics/inttonlyrun_00051100_00051200/DST_INTT_EVENT_run2pp_new_2024p002-00051100-00000.root" ) +{ + + Fun4AllServer *se = Fun4AllServer::instance(); + + auto *in = new Fun4AllDstInputManager("DSTin"); + in->fileopen( data ); // this is an old method but supports skip function + se->registerInputManager(in); + + se->run( 1 ); + delete se; + + gSystem->Exit(0); + return 0; +}