File indexing completed on 2025-08-03 08:20:57
0001
0002
0003 use strict;
0004 use warnings;
0005
0006 sub findruns;
0007
0008 my $stopthis = sprintf("stopthis");
0009 my $histodir = sprintf("/sphenix/lustre01/sphnxpro/commissioning/online_monitoring/histograms");
0010 my @subsystems = ("BBCMON", "CEMCMON", "DAQMON", "IHCALMON", "INTTMON", "LL1MON", "LOCALPOLMON", "MVTXMON", "OHCALMON", "SPINMON", "SEPDMON", "TPCMON", "TPOTMON", "ZDCMON");
0011
0012
0013 for my $subsys (@subsystems)
0014 {
0015 if (-e $stopthis)
0016 {
0017 last;
0018 }
0019 my %donehash = ();
0020 my $rundone = sprintf("%s.done",$subsys);
0021 if (-f $rundone)
0022 {
0023 open(F,"$rundone");
0024 while (my $run = <F>)
0025 {
0026 chomp $run;
0027 $donehash{$run} = 1;
0028 }
0029 close(F);
0030 }
0031 my $subsysdir = sprintf("%s/%s",$histodir,$subsys);
0032 my %todoruns = findruns($subsysdir,$subsys, \%donehash );
0033
0034
0035
0036 my $lastrun = 0;
0037 for my $run (sort { $a <=> $b } keys %todoruns)
0038 {
0039 if ($run < 80000)
0040 {
0041 my $listfile = sprintf("%s.list",$subsys);
0042 my $cmd = sprintf("ls -1 /sphenix/lustre01/sphnxpro/commissioning/online_monitoring/histograms/%s/Run_%d-* > %s.list",$subsys,$run,$subsys);
0043 print "$cmd\n";
0044 system($cmd);
0045 my $rootcmd = sprintf("root.exe -q makehtml.C\\\(\\\"%s.list\\\",\\\"%s\\\"\\\)",$subsys,$subsys);
0046 print "$rootcmd\n";
0047 system($rootcmd);
0048 print "handled $run for $subsys\n";
0049 $lastrun = $run;
0050 }
0051 if (-e $stopthis)
0052 {
0053 last;
0054 }
0055 }
0056 for my $run (sort { $a <=> $b } keys %todoruns)
0057 {
0058 if ($lastrun == $run)
0059 {
0060 next;
0061 }
0062 my $updatedone = sprintf("echo %d >> %s",$run,$rundone);
0063 system($updatedone);
0064 }
0065 unlink $stopthis;
0066 }
0067
0068 sub findruns
0069 {
0070 my $subsysdir = shift;
0071 my $subsys = shift;
0072 my %donehash = %{$_[0]};
0073 opendir my $dir, $subsysdir or die "Cannot open directory: $!";
0074 my @files = readdir $dir;
0075 closedir $dir;
0076 my %todoruns = ();
0077 for my $file (@files)
0078 {
0079 if ($file =~ /$subsys/)
0080 {
0081
0082 if ($file =~ /(\S+)_(\d+)-(\S+).*\..*/ )
0083 {
0084 my $run = int($2);
0085
0086 if (exists $donehash{$run})
0087 {
0088 next;
0089 }
0090 if ($run > 80000)
0091 {
0092 next;
0093 }
0094 $todoruns{$run} = 1;
0095 }
0096 }
0097 }
0098 return %todoruns;
0099 }
0100