Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-04-06 08:08:19

0001 #!/usr/bin/perl
0002 
0003 use strict;
0004 use DBI; # Database interface 
0005 
0006 # Read file
0007 my $filename = 'RunList_golden.txt';
0008 open(my $fh,'<',$filename) or die "Could not open file '$filename' $!";
0009 
0010 # connect to the database Production_read
0011 my $dbh = DBI->connect("dbi:ODBC:RawdataCatalog_read","") || die $DBI::error;
0012 
0013 my @hostnames = ("seb00","seb01","seb02","seb03","seb04","seb05","seb06","seb07","seb08",
0014                  "seb09","seb10","seb11","seb12","seb13","seb14","seb15","seb16","seb17", "seb18", "seb19", "seb20"); # All SEBS (EMCal, IHCAL, OHCAL, MBD)
0015 
0016 while (my $line = <$fh>) {
0017     chomp($line);
0018 
0019     my $file_path = "../FEM_folder/fem_${line}.txt";
0020     if -f $file_path {
0021         next;
0022     }
0023 
0024     my $fem_matching = 2;
0025     # select the number of events for each hostname in the given runnumber
0026 
0027     #print "line = $line\n";
0028     my $gettab = $dbh->prepare("SELECT filename,hostname FROM filelist WHERE runnumber=$line AND filename LIKE '%0000.prdf';");
0029     $gettab->execute();
0030 
0031     # Fetch hostname, filename and store them in a hash
0032     my %values;
0033     while (my ($rawfilename, $hostname) = $gettab->fetchrow_array) {
0034         $values{$hostname} = $rawfilename;
0035         #print "values($hostname) = $rawfilename\n";
0036     }
0037     
0038     my $clock_value = -1;
0039     open(outfh, ">", "fem_$line.txt");
0040     foreach my $host(@hostnames) {
0041         unless (exists($values{$host})) {
0042             $fem_matching = 0;
0043         }
0044 
0045         my $rawfilename = $values{$host};
0046 
0047         # By default, the bufferbox content is manually transferred to /sphenix/lustre01/sphnxpro.
0048         # RawdataCatalog does not account for that
0049         $rawfilename =~ s{^/bbox/bbox\d+/}{/sphenix/lustre01/sphnxpro/physics/};
0050         
0051         my $output = `ddump -i -e 10 $rawfilename | grep "FEM Clock"`;
0052         
0053         print "rawfilename = $rawfilename\n";
0054         print outfh "$host\n";
0055         print outfh "$output\n";
0056     }
0057     close(outfh);
0058 }
0059 
0060 close($fh); # Close the file handle.
0061 
0062 $dbh->disconnect;