File indexing completed on 2024-04-06 11:57:57
0001
0002
0003
0004
0005
0006
0007
0008 $datadir = @ARGV[0];
0009 $dir = @ARGV[1];
0010 $firstRun = @ARGV[2];
0011 $lastRun = @ARGV[3];
0012
0013 $laserdir = "${datadir}/Laser/Analyzed";
0014 $testpulsedir = "${datadir}/TestPulse/Analyzed";
0015 $runsdir = "${datadir}/Runs";
0016 $listdir = "$dir";
0017
0018 if( $firstRun eq "" )
0019 {
0020 $firstRun = "0"; $lastRun = "100000000";
0021 }
0022 elsif( $lastRun eq "+" )
0023 {
0024 $lastRun = "100000000";
0025 }
0026 elsif( $lastRun eq "" )
0027 {
0028 $lastRun = $firstRun;
0029 }
0030
0031
0032 open( LREDLIST, ">${listdir}/runlist_Red_Laser") || die "cannot open output file\n";
0033 open( LBLUELIST, ">${listdir}/runlist_Blue_Laser") || die "cannot open output file\n";
0034 open( TPLIST, ">${listdir}/runlist_Test_Pulse") || die "cannot open output file\n";
0035
0036 $firstLaser = 1;
0037 $firstTP = 1;
0038 $firstTS = 0;
0039
0040 opendir( RUNSDIR, $laserdir) || die "cannot open directory $laserdir\n";
0041 @runsdir = sort readdir( RUNSDIR );
0042 foreach my $rundir (@runsdir)
0043 {
0044 next unless( $rundir =~ /Run(\d*)_LB(.*)/ );
0045 $run = $1;
0046 $lumiblock = $2;
0047
0048 my $curtype = "LASER";
0049 next if( $run < $firstRun || $run > $lastRun );
0050 next if( !open( HEADERFILE, "${laserdir}/${rundir}/header.txt") );
0051
0052 my $timestampbeg = 0;
0053 my $timestampend = 0;
0054 my $mgpagain = -1;
0055 my $memgain = -1;
0056
0057 my $blueevents = 0;
0058 my $bluepower = -10;
0059 my $bluefilter = -10;
0060 my $bluedelay = -10;
0061
0062 my $redevents = 0;
0063 my $redpower = -10;
0064 my $redfilter = -10;
0065 my $reddelay = -10;
0066
0067 my $curcolor = "NOCOLOR";
0068
0069 while ( <HEADERFILE> )
0070 {
0071 chomp($_);
0072 $theLine = $_;
0073
0074 if( $theLine =~ /RUN = (.*)/ )
0075 {
0076 if ( $run != $1 ) {
0077 print "Run number not properly filled: $run versus $1 \n";
0078 }
0079 }
0080 if( $theLine =~ /(.*) Events/ )
0081 {
0082 $curtype = $1;
0083 ($curtype =~ /LASER/) || last;
0084 }
0085
0086 if( $theLine =~ /RUNTYPE = (\d*)/ )
0087 {
0088 $runtype = $1;
0089 ( $runtype == 4 || $runtype == 5 || $runtype == 6 || $runtype == 16 ) || last;
0090 }
0091 if( $theLine =~ /TIMESTAMP_BEG = (.*)/ ){ $timestampbeg = $1; }
0092 if( $theLine =~ /TIMESTAMP_END = (.*)/ ){ $timestampend = $1; }
0093 if( $theLine =~ /MPGA_GAIN = (.*)/ ){ $mgpagain = $1; }
0094 if( $theLine =~ /MEM_GAIN = (.*)/ ){ $memgain = $1; }
0095 if( $theLine =~ /blue laser/ ){ $curcolor = "BLUE"; }
0096 if( $theLine =~ /red laser/ ){ $curcolor = "RED"; }
0097
0098 if( $theLine =~ /events = (.*)/ ){
0099 if( $curcolor eq "BLUE" ){
0100 $blueevents = $1;
0101 }elsif ( $curcolor eq "RED" ){
0102 $redevents = $1;
0103 }
0104 }
0105
0106 if( $theLine =~ /power = (.*)/ ){
0107 if( $curcolor eq "BLUE" ){
0108 $bluepower = $1;
0109 }elsif ( $curcolor eq "RED" ){
0110 $redpower = $1;
0111 }
0112 }
0113 if( $theLine =~ /filter = (.*)/ ){
0114 if( $curcolor eq "BLUE" ){
0115 $bluefilter = $1;
0116 }elsif ( $curcolor eq "RED" ){
0117 $redfilter = $1;
0118 }
0119 }
0120
0121 if( $theLine =~ /delay = (.*)/ ){
0122 if( $curcolor eq "BLUE" ){
0123 $bluedelay = $1;
0124 }elsif ( $curcolor eq "RED" ){
0125 $reddelay = $1;
0126 }
0127 }
0128 }
0129
0130 if( $firstLaser )
0131 {
0132 $firstLaser = 0;
0133 if( $firstTP )
0134 {
0135 $firstTS = $timestampbeg;
0136 }
0137 }
0138 $diffTS = $timestampbeg - $firstTS ;
0139 if($redevents >0 ){
0140 print LREDLIST "Run${run}_LB${lumiblock}\t$run\t$lumiblock\t$redevents\t$timestampbeg\t$timestampend\t$mgpagain\t$memgain\t$redpower\t$redfilter\t$reddelay\n";
0141 }
0142 if($blueevents > 0 ){
0143 print LBLUELIST "Run${run}_LB${lumiblock}\t$run\t$lumiblock\t$blueevents\t$timestampbeg\t$timestampend\t$mgpagain\t$memgain\t$bluepower\t$bluefilter\t$bluedelay\n";
0144 }
0145 }
0146 closedir( RUNSDIR );
0147 close( LBLUELIST );
0148 close( LREDLIST );
0149
0150 opendir( RUNSDIR, $testpulsedir ) || die "cannot open directory $dir\n";
0151 @runsdir = sort readdir( RUNSDIR );
0152 foreach my $rundir (@runsdir)
0153 {
0154 next unless( $rundir =~ /Run(\d*)_LB(.*)/ );
0155 $run = $1;
0156 $lumiblock = $2;
0157
0158 my $curtype = "LASER";
0159 next if( $run < $firstRun || $run > $lastRun );
0160 next if ( !open( HEADERFILE, "${testpulsedir}/${rundir}/header.txt") );
0161
0162 my $timestampbeg = 0;
0163 my $timestampend = 0;
0164 my $mgpagain = -1;
0165 my $memgain = -1;
0166 my $events = 0;
0167
0168 while (<HEADERFILE>)
0169 {
0170 chomp($_);
0171 $theLine = $_;
0172 if( $theLine =~ /(.*) Events/ )
0173 {
0174 $curtype = $1;
0175 ( ($curtype =~ /LASER/) || ($curtype =~ /TESTPULSE/) ) || last;
0176 }
0177 if( $theLine =~ /RUN = (\d*)/ )
0178 {
0179 if ( $run != $1 ) {
0180 print "Run number not properly filled: $run versus $1 \n";
0181 }
0182 }
0183
0184 if( $theLine =~ /RUNTYPE = (\d*)/ )
0185 {
0186 $runtype = $1;
0187 if( $curtype =~ /TESTPULSE/ ){
0188 ( $runtype == 7 || $runtype == 8 || $runtype == 17 ) || last;
0189 }
0190 }
0191
0192 if($curtype =~ /TESTPULSE/) {
0193
0194 if( $theLine =~ /TIMESTAMP_BEG = (\d*)/ ){ $timestampbeg = $1; }
0195 if( $theLine =~ /TIMESTAMP_END = (\d*)/ ){ $timestampend = $1; }
0196 if( $theLine =~ /MPGA_GAIN = (.*)/ ){ $mgpagain = $1; }
0197 if( $theLine =~ /MEM_GAIN = (.*)/ ){ $memgain = $1; }
0198 if( $theLine =~ /EVENTS = (\d*)/ ){ $events = $1; }
0199 }
0200 }
0201
0202 if( $firstTP )
0203 {
0204 $firstTP = 0;
0205 if( $firstLaser )
0206 {
0207 $firstTS = $timestamp_beg;
0208 }
0209 }
0210 if($events > 0 ){
0211 print TPLIST "Run${run}_LB${lumiblock}\t$run\t$lumiblock\t$events\t$timestampbeg\t$timestampend\t$mgpagain\t$memgain -1 -1 -1\n";
0212 }
0213 }
0214 closedir( RUNSDIR );
0215 close( TPLIST );