#!/usr/bin/perl # # Copyright Zaher Salman and PSI LEM Group 2009. # zaher.salman@psi.ch ######## Relevant subdirectories and urls ######## # May need modification on different servers $WEBDIR = "/~l_salman"; $REALDIR = "/home/l_salman/public_html"; $BINDIR = "/usr/local/bin"; $MAINPAGE = "/cgi-bin/musrfit.cgi"; $OUTPUT = $WEBDIR . "/msrfit_out"; $OUTPUT_REAL = $REALDIR . "/msrfit_out"; $SUMM_DIR = "/mnt/data/nemu/summ"; # Programs used if ( $TITLE eq $EMPTY || $TITLE eq "TITLE" ) { $MUSRFIT = $BINDIR . "/musrfit -t"; } else { $MUSRFIT = $BINDIR . "/musrfit"; } $MUSRVIEW = $BINDIR . "/musrview --png"; $DUMPASCII = "$MUSRFIT --dump ascii"; $MSR2DAT = $BINDIR . "/msr2dat"; ####################################################################### # Nothing need to be changed from here on $EMPTY=q{}; $SPACE=q{ }; $COMMA=q{,}; # Additions to paremeters' names $erradd = "d"; $minadd = "_min"; $maxadd = "_max"; %BeamLines = ( "LEM", "MUE4", "GPS", "PIM3", "LTF", "PIM3", "Dolly", "PIE1" , "GPD", "PIE1"); # Commands used often $cln_out = "rm -f $OUTPUT_REAL/FILENAME*"; $cln = "rm -f MINUIT2.* $OUTPUT_REAL/FILENAME* FILENAME.*"; $plotonly = "$MUSRVIEW FILENAME.msr >> $OUTPUT_REAL/FILENAME.out; convert FILENAME\_0.png -crop 590x460+1+50 $OUTPUT_REAL/FILENAME.png; rm -f FILENAME\_0.png"; $fitplot = "$MUSRFIT FILENAME.msr > $OUTPUT_REAL/FILENAME.out; $MUSRVIEW FILENAME.msr >> $OUTPUT_REAL/FILENAME.out; convert FILENAME\_0.png -crop 590x460+1+50 $OUTPUT_REAL/FILENAME.png; rm -f FILENAME\_0.png"; $dumpascii = "$DUMPASCII FILENAME.msr > $OUTPUT_REAL/FILENAME_ascii.out; /bin/tar -cvzf $OUTPUT_REAL/FILENAME.tgz FILENAME*.dat >> $OUTPUT_REAL/FILENAME_ascii.out; rm -f FILENAME*.dat"; # TODO: Replace this with a call to $TABLE=MSR::ExportParams $AllParameters{"Header"}=1; $TABLE=MSR::ExportParams(\%AllParameters); $msr2dat = "$MSR2DAT FILENAME.msr > $OUTPUT_REAL/FILENAME_par.dat"; # "Smart" default value of the fit parameters. %Defaults = ( "Asy", "0.15", "dAsy", "0.01", "Asy_min", "0", "Asy_max", "0", "Alpha", "1.0", "dAlpha", "0.01", "Alpha_min", "0", "Alpha_max", "0", "N0", "300.0", "dN0", "0.01", "N0_min", "0", "N0_max", "0", "NBg", "30.0", "dNBg", "0.01", "NBg_min", "0", "NBg_max", "0", "Lam", "1.0", "dLam", "0.01", "Lam_min", "0", "Lam_max", "0", "Gam", "1.0", "dGam", "0.01", "Gam_min", "0", "Gam_max", "0", "Bet", "0.5", "dBet", "0.01", "Bet_min", "0", "Bet_max", "0", "Two", "2.0", "dTwo", "0.0", "Two_min", "0", "Two_max", "0", "Del", "0.1", "dDel", "0.01", "Del_min", "0", "Del_max", "0", "Sgm", "0.1", "dSgm", "0.01", "Sgm_min", "0", "Sgm_max", "0", "Aa", "0.1", "dAa", "0.01", "Aa_min", "0", "Aa_max", "0", "q", "0.1", "dq", "0.01", "q_min", "0", "q_max", "0", "Bg", "0.036", "dBg", "0.01", "Bg_min", "0", "Bg_max", "0", "bgrlx", "0.", "dbgrlx", "0.0", "bgrlx_min", "0", "bgrlx_max", "0", "Frq", "1.0", "dFrq", "1.", "Frq_min", "0", "Frq_max", "0", "Field", "100.0", "dField", "1.", "Field_min", "0", "Field_max", "0", "Energy", "14.1", "dEnergy", "0.", "Energy_min", "0", "Energy_max", "0", "DeadLayer", "10.", "dDeadLayer", "0.1", "DeadLayer_min", "0", "DeadLayer_max", "0", "Lambda", "128.1", "dLambda", "0.1", "Lambda_min", "0", "Lambda_max", "0", "Phi", "1.", "dPhi", "0.01", "Phi_min", "0", "Phi_max", "0" ); ####################################################################### ######## Main body of code ######## use CGI; use MSR; my $in = new CGI; ####################################################################### # Common to all steps # If you are coming from a previous round pass in various parameters PassIn(); # This is the content of the html page.. $Content = $EMPTY; # This is just for temporary debugging html text $TC = $EMPTY; # Put all input values in a hash @All = $in->param(); $N = $#All; $i = 0; while ( $i <= $N ) { $One = $All[$i]; $AllParameters{ $One } = $in->param($One); # $TC=$TC."$One=".$AllParameters{ $One }."
"; ++$i; } # See which step or command we are coming from # Step Value Command # # -1 CLEAR/START NEW # 1 Defin Shared # 2 Initialize parameters # 3 PLOT # 4 MIGRAD # 5 MINOS # 6 SIMPLEX ####################################################################### $Step = $in->param("go"); $FITMINTTYPE = "PLOT"; if ( $Step eq "PLOT" ) { $Step = 3; $FITMINTYPE = $EMPTY; } elsif ( $Step eq "MIGRAD" || $Step eq "FIT") { $Step = 4; $FITMINTYPE = "MINIMIZE\nMIGRAD\nHESSE"; } elsif ( $Step eq "MINOS" ) { $Step = 5; $FITMINTYPE = "MIGRAD\nMINOS"; } elsif ( $Step eq "SIMPLEX" ) { $Step = 6; $FITMINTYPE = "SCAN\nSIMPLEX"; } elsif ( $Step eq "Restart" ) { $Step = -1; } if ( $All{"Minimization"} ne "" && $All{"ErrorCalc"} ne "" && $Step ne "PLOT" ) { $FITMINTYPE = $All{"Minimization"}."\n".$All{"ErrorCalc"}; } #$TC=$TC."OUT:
".MSR::Test(\%AllParameters); #$tmp="Frq"; #$TC=$TC."Sh_Frq= ".$AllParameters{"Sh_$tmp"}."
"; # Skip the shared parameters step if you have only one if ( $Step == 1 && $#RUNS == 0 ) { $Step = 2; } ####################################################################### # Choose shared parameters if you have multiple runs ####################################################################### if ( $Step == 1 ) { # First create the THEORY block to get a parameters list ($Full_T_Block,$Paramcomp_ref)=MSR::CreateTheory(@FitTypes); @Paramcomp = @$Paramcomp_ref; StepShared(); } ####################################################################### ####################################################################### # Initialize/Fix parameters values ####################################################################### elsif ( $Step == 2 ) { $RUN = $RUNS[0]; if ( $RUN < 10 ) { $RUN = "000" . $RUN; } elsif ( $RUN < 100 ) { $RUN = "00" . $RUN; } elsif ( $RUN < 1000 ) { $RUN = "0" . $RUN; } # First create the THEORY block to get a parameters list ($Full_T_Block,$Paramcomp_ref)=MSR::CreateTheory(@FitTypes); @Paramcomp = @$Paramcomp_ref; if ( $BeamLine eq "LEM" ) { # Take the temperature from data file if you can ExtractInfo( $RUN, $YEAR, "Temp" ); $TEMPERATURE = $RTRN_Val; } # If TITLE is empty or eq TITLE get it from the first run if you can if ( $TITLE eq $EMPTY || $TITLE eq "TITLE" ) { # This is a flag to keep setting TITLE to default $T_Keep = 1; } else { $T_Keep = 0; } # If the filename is empty or eq RUN put default if ( $FILENAME eq $EMPTY || $FILENAME eq "RUN" || $FILENAME eq "0" ) { # Flag to keep default filename $FN_Keep = 1; if ( $RUNS[0] ne $EMPTY ) { ( $TMP1, $TMP2, $BLine ) = split( /\//, $BeamLine ); $FILENAME = $RUNS[0] . "_" . $BeamLine . "_" . $YEAR; } } else { $FN_Keep = 0; } # If the file already exists do not continue running. The file may be # used by someone else. # TODO: Maybe create a different name and not die. # if (-e "$FILENAME.msr") { # $Content = $Content."The file name \"$FILENAME\" is being used, choose another name or delete it!"; # &SpitHTML; # die; # } InitFixStep(); } ####################################################################### ####################################################################### # Create musrfit .msr file and fit/plot the result ####################################################################### elsif ( $Step <= 6 && $Step >= 3 ) { # Then create appropriate file if ($FitAsyType eq "SingleHist") { ($Full_T_Block,$Paramcomp_ref)= MSR::CreateMSRSingleHist(\%AllParameters); } else { ($Full_T_Block,$Paramcomp_ref)= MSR::CreateMSR(\%AllParameters); } @Paramcomp = @$Paramcomp_ref; if ( $Step == 3 ) { $cmd = $plotonly; } elsif ( $Step <=6 && $Step >= 4 ) { $cmd = $fitplot; } # Fit and plot results $cmd =~ s/FILENAME/$FILENAME/g; $tmp = system("$cmd"); # Generate ascii data and fit $cmd = $dumpascii; $cmd =~ s/FILENAME/$FILENAME/g; $tmp = system("$cmd"); # Generate parameters table $cmd = $msr2dat; $cmd =~ s/FILENAME/$FILENAME/g; $tmp = system("$cmd"); $Spectra = ( $#RUNS + 1 ) * ( $#TiVals + 1 ); if ( $RRF != 0 && $Spectra == 1 ) { $Spectra = 2; } PrintOut(); } else { if ( $Step == -1 ) { # Clean up $cmd = $cln; $cmd =~ s/FILENAME/$FILENAME/g; $tmp = system("$cmd"); # Check flag for default $T_Keep = $in->param("T_Keep"); if ( $T_Keep == 1 ) { $TITLE = "TITLE"; } # Check flag for default $FN_Keep = $in->param("FN_Keep"); if ( $FN_Keep == 1 ) { $FILENAME = "RUN"; } $Step = 0; $Content = $EMPTY; } # Take title, runnumber, ti, tf, bin ... Step0(); } # Insert passed on variables into the HTML code PassOn(); SpitHTML(); exit(0); ######## Split functions and subroutines ######## ######################## #sub SpitHTML # #This function prints the start of the feedback form web page. ######################## sub SpitHTML { print("Content-type: text/html; charset=iso-8859-1 \n\n"); print( " $TITLE $TC $Content

If you have any problems please send me an email about it
" ); return; } ######################## ######################## # Step 0 # # Is the begining of the fitting pocess # Take title and run numbers and the type of fitting function ######################## sub Step0 { # Prepare body of the HTML code $Content = $Content . " Enter the label (default is run title)



Enter [name] for output [name].msr file (optional)

Input the RUN numbers separated with commas

On beam line Year

Chose type of fitting function:

First Component Second Component Third Component


From time ti=
\[μsec\]
To time tf=
\[μsec\]
Binning factor=
[points]

Fit type Histograms:


PASS_ON_HTML_CODE
\">
"; # Get current year ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) = localtime( time() ); $year = $year + 1900; $Years = $EMPTY; # Creat a drop down menu for years from 1994 until current for ( $i = $year ; $i >= 1994 ; $i-- ) { # for ($i=1994..$year) { $Years = $Years . " "; } for my $BeamLine ( keys %BeamLines ) { $BeamLineDDM = $BeamLineDDM . "\n"; } # Insert the years into the HTML code $Content =~ s/INSERT_YEARS_HERE/$Years/g; # Insert the beamlines into the HTML code $Content =~ s/INSERT_BEAMLINES_HERE/$BeamLineDDM/g; return; } ######################## ######################## # StepShared # # Choose shared parameters if applicable # ######################## sub StepShared { # Here we need first a list of parameters which depends # on the functions chosen and number of components $Content = $Content . " Choose the shared parameters

PASS_ON_HTML_CODE INSERT_PARAMETERS_TABLE_HERE
\">
"; # Prepare table of parameters $component = 0; $Param_Table = $EMPTY; foreach my $FitType (@FitTypes) { ++$component; $Parameters = $Paramcomp[ $component - 1 ]; $Param_Table = $Param_Table . " Component $component: $FitType "; @Params = split( /\s+/, $Parameters ); # For the first component we need Alpha for Asymmetry fits if ( $component == 1 && $FitAsyType eq "Asymmetry" ) { unshift( @Params, "Alpha" ); } elsif ( $component == 1 && $FitAsyType eq "SingleHist" ) { unshift( @Params, ( "N0", "NBg" ) ); } foreach my $Param (@Params) { if ( ($#FitTypes != 0) && ( $Param ne "Alpha" && $Param ne "N0" && $Param ne "NBg" ) ) { $Param = join( $EMPTY, $Param, "_", "$component"); } $ischecked = $in->param("Sh_$Param"); if ($ischecked) { $checked = "checked"; } else { $checked = $EMPTY; } $Param_Table = $Param_Table . " "; } $Param_Table = $Param_Table . "
Parameter
Share
$Param


"; } # Insert the table of parameters into the HTML code $Content =~ s/INSERT_PARAMETERS_TABLE_HERE/$Param_Table/g; return; } ######################## ######################## # InitFixStep ######################## sub InitFixStep { $Content = $Content . " Initialize parameters:

\"> INSERT_PARAMETERS_TABLE_HERE PASS_ON_HTML_CODE \">
"; # Counter for runs $Param_Table = $EMPTY; $i = 0; foreach my $RUN (@RUNS) { ++$i; $Param_Table = $Param_Table . "
Run Number: $RUN
"; $component = 0; foreach my $FitType (@FitTypes) { ++$component; $Parameters = $Paramcomp[ $component - 1 ]; @Params = split( /\s+/, $Parameters ); # For the first component we need Alpha for Asymmetry fits if ( $component == 1 && $FitAsyType eq "Asymmetry" ) { unshift( @Params, "Alpha" ); } elsif ( $component == 1 && $FitAsyType eq "SingleHist" ) { unshift( @Params, ( "N0", "NBg" ) ); } $Param_Table = $Param_Table . " Component $component: $FitType "; foreach my $Param (@Params) { $Param_ORG = $Param; if ( $#FitTypes != 0 && ( $Param ne "Alpha" && $Param ne "N0" && $Param ne "NBg" ) ) { $Param = join( $EMPTY, $Param, "_", "$component" ); } if ( $#RUNS == 0 ) { $Shared = 1; } else { $Shared = $in->param("Sh_$Param"); } if ( ( $Shared && $i == 1 ) || !$Shared ) { $value = $in->param("$Param\_$i"); if ( $value ne $EMPTY ) { $error = $in->param("$erradd$Param\_$i"); $minvalue = $in->param("$Param\_$i$minadd"); $maxvalue = $in->param("$Param\_$i$maxadd"); } else { $value = $Defaults{$Param_ORG}; $error = $Defaults{ join( $EMPTY, $erradd, $Param_ORG ) }; $minvalue = $Defaults{ join( $EMPTY, $Param_ORG, $minadd ) }; $maxvalue = $Defaults{ join( $EMPTY, $Param_ORG, $maxadd ) }; } $Param_Table = $Param_Table . " "; } } $Param_Table = $Param_Table . "
Param
Value
Error (0 for fixed)
Min Value
Max Value
$Param\_$i

"; } } # Insert the table of parameters into the HTML code $Content =~ s/INSERT_PARAMETERS_TABLE_HERE/$Param_Table/g; return; } ######################## ######################## # PrintOut # # Make nice plot and preset values of fit parameters nicely ######################## sub PrintOut { $Content = $Content . "
INSERT_PARAMETERS_TABLE_HERE
$TITLE
RUN numbers separated with commas
ti= tf= Bin=
Log x
Log y
τ cor.
X,Y range
Xi=
Xf=
Yi=
Yf=
View Bin

INSERT_CHI_LINE_HERE
RUN \#NameValueErrorMinMax
PASS_ON_HTML_CODE

Download $FILENAME.msr.
Download ascii files $FILENAME.tgz.
Download parameters table file $FILENAME\_par.dat. "; # Initialize the extra pass on parameters system("cp -f $FILENAME.* $OUTPUT_REAL/.; chmod -R a+r $OUTPUT_REAL"); # Reset the values of the TITLE and FILENAME if default was chosen if ( $T_Keep == 1 ) { $TITLE = "TITLE"; } if ( $FN_Keep == 1 ) { $FILENAME = "RUN"; } # Check log x and/or log y by default depending on previous setting if ( $logx eq "y" ) { $logxcheck = "checked"; } else { $logxcheck = $EMPTY; } if ( $logy eq "y" ) { $logycheck = "checked"; } else { $logycheck = $EMPTY; } # Check lifetime correction by default depending on previous settings if ( $ltc eq "y" ) { $ltccheck = "checked"; } else { $ltccheck = $EMPTY; } # Reset log x and log y flags $logx = "n"; $logy = "n"; $ltc = "n"; $Param_Table = $EMPTY; open( IFILE,q{<}, "$FILENAME.msr" ); @lines = ; close(IFILE); # Get Chi line and reformat @Chi_Line = grep { /chisq/ } @lines; if ( $TITLE eq $EMPTY || $TITLE eq "TITLE" ) { $TITLE = $lines[0]; } if ( $Chi_Line[0] eq $EMPTY ) { $Chi_Line[0] = "Fit did not converge yet"; } # Remove comment lines @lines = grep {!/^\#/} @lines; # Remove empty lines @lines = grep {/\S/} @lines; # Identify different blocks $i=0; foreach $line (@lines) { if (grep {/FITPARAMETER/} $line) {$NFITPARAMETERS=$i;} if (grep {/THEORY/} $line) { $NTHEORY=$i;} if ((grep {/RUN/} $line) & $NRUN==0) { $NRUN=$i;} $i++; } @FPBlock=@lines[$NFITPARAMETERS+1..$NTHEORY-1]; @TBlock=@lines[$NTHEORY+1..$NRUN-1]; foreach my $line (@FPBlock) { # TODO: Better treatement for FPBlock is to remove lines starting with # or empty. $line =~ s/\n//g; ( $tmp, $order, $Param, $value, $error, $errorp, $minvalue, $maxvalue ) = split(/\s+/,$line); # $TC=$TC.$line."
"; # $TC=$TC."$tmp,$order,$Param,$value,$error,$errorp,$minvalue,$maxvalue
"; # Take the number/order of the spectrum @itmp = split( /\_/, $Param ); # If it is a multiple fit take also the run number if ( $itmp[1] ne $EMPTY ) { if ( $RUNS[ $itmp[1] - 1 ] ne $RUN ) { $RUN = $RUNS[ $itmp[1] - 1 ]; $PRUN = $RUN; } else { $PRUN = $SPACE; } } # Keep the values from the fit for the next round.. $errParam = $erradd . $Param; $minParam = $Param . $minadd; $maxParam = $Param . $maxadd; if ( $value eq $EMPTY ) { # Take original defaults ( $Param_ORG, $tmp ) = split( '_', $Param ); $value = $Defaults{$Param_ORG}; $error = $Defaults{ join( $EMPTY, $erradd, $Param_ORG ) }; $minvalue = $Defaults{ join( $EMPTY, $Param_ORG, $minadd ) }; $maxvalue = $Defaults{ join( $EMPTY, $Param_ORG, $maxadd ) }; } else { # This is the trick to make an expression from the names :) $$Param = $value; $$errParam = $error; $$minParam = $minvalue; $$maxParam = $maxvalue; } # $TC=$TC."$order,$Param,$value,$error,$errorp,$minvalue,$maxvalue
"; $Param_Table = $Param_Table . " $order $PRUN $Param "; } $Content =~ s/INSERT_PARAMETERS_TABLE_HERE/$Param_Table/g; $Content =~ s/INSERT_CHI_LINE_HERE/$Chi_Line[0]/g; return; } #PrintOut ######################## ######################## #This subroutine adds the parameters to pass on ######################## sub PassOn { @All = $in->param(); $N = $#All; # For the initialize parameters step do not pass the parameters themselves if ( $in->param("go") == 2 ) { for ($i=0..$N) { $find = substr( $All[$i], 0, 5 ); if ( $find eq "Alpha" || $find eq "N0" || $find eq "NBg" ) { $tmp = $i; $i = $N; $N = $tmp - 1; } } } $PassOn = $EMPTY; $i = 0; while ( $i <= $N ) { $One = $All[$i]; if ( $One ne $EMPTY && $One ne "go" ) { if ( $$One ne $EMPTY ) { $OneValue = $$One; } else { $OneValue = $in->param($One); if ( $OneValue == 0 && $One ne "TITLE" ) { $OneValue = 0; } } # Exclude logx logy ltx # if ($One ne "ltc" && $One ne "logx" && $One ne "logy") { $skip=0; # Skip Sh_ variables during shared skip if ($Step == 1 && substr($One,0,3) eq "Sh\_") { $skip=1 } if ($skip != 1) { $PassOn = $PassOn . "\n"; } } ++$i; } $Content =~ s/PASS_ON_HTML_CODE/$PassOn/g; return; } ######################## #This subroutine takes the parameters to pass in ######################## sub PassIn { $RunNumbers = $in->param("RunNumbers"); $RunNumbers =~ s/[\ \.\~\/\&\*\[\;\>\<\^\$\(\)\`\|\]\'\@]/,/g; @RUNS = split( /,/, $RunNumbers ); # $TC=$TC."
RunNumbers=".$RunNumbers." \@RUNS=".$RUNS[0]."
"; $YEAR = $in->param("YEAR"); %YEARSel = ( "$YEAR", "selected=\"selected\"" ); $BeamLine = $in->param("BeamLine"); if ( $BeamLine eq "LEM" ) { $LEMSel = "selected=\"selected\""; } elsif ( $BeamLine eq "GPS" ) { $GPSSel = "selected=\"selected\""; } elsif ( $BeamLine eq "LTF" ) { $LTFSel = "selected=\"selected\""; } elsif ( $BeamLine eq "GPD" ) { $GPDSel = "selected=\"selected\""; } else { $BeamLine eq "Dolly"; $DollySel = "selected=\"selected\""; } # Take the values which were passed on... $TITLE = $in->param("TITLE"); $TEMPERATURE = $in->param("TEMPERATURE"); $FILENAME = $in->param("FILENAME"); $FILENAME =~ s/[\.\~\/\&\*\[\;\>\<\^\$\(\)\`\|\]\'\@]//g; $FILENAME =~ s/ /_/g; $BeamLine = $in->param("BeamLine"); if ( $BeamLine eq $EMPTY ) { %BeamSel = ( "LEM", "selected=\"selected\"" ); } else { %BeamSel = ( "$BeamLine", "selected=\"selected\"" ); } $Minimization = $in->param("Minimization"); if ( $Minimization eq $EMPTY ) { %MinSel = ("MIGRAD", "selected=\"selected\"" ); } else { %MinSel = ( "$Minimization", "selected=\"selected\"" ); } $ErrorCalc = $in->param("ErrorCalc"); if ( $ErrorCalc eq $EMPTY ) { %ErrSel = ("HESSE", "selected=\"selected\"" ); } else { %ErrSel = ( "$ErrorCalc", "selected=\"selected\"" ); } $FitType1 = $in->param("FitType1"); $FitType2 = $in->param("FitType2"); $FitType3 = $in->param("FitType3"); if ( $FitType1 eq $EMPTY ) { %FitSel1 = ( "ExponentialCos", "selected=\"selected\"" ); } else { %FitSel1 = ( "$FitType1", "selected=\"selected\"" ); } if ( $FitType2 eq $EMPTY ) { %FitSel2 = ( "None", "selected=\"selected\"" ); } else { %FitSel2 = ( "$FitType2", "selected=\"selected\"" ); } if ( $FitType3 eq $EMPTY ) { %FitSel3 = ( "None", "selected=\"selected\"" ); } else { %FitSel3 = ( "$FitType3", "selected=\"selected\"" ); } foreach my $FitType ( $FitType1, $FitType2, $FitType3 ) { if ( $FitType ne "None" ) { push( @FitTypes, $FitType ); } } $BINS = $in->param("BINS"); $Tis = $in->param("Tis"); $Tfs = $in->param("Tfs"); $Xi = $in->param("Xi"); $Xf = $in->param("Xf"); $Yi = $in->param("Yi"); $Yf = $in->param("Yf"); $ViewBin = $in->param("ViewBin"); # Initail value if empty if ( $BINS eq $EMPTY ) { $BINS = 100; } if ( $Tis eq $EMPTY ) { $Tis = 0; } if ( $Tfs eq $EMPTY ) { $Tfs = 8; } $BINS =~ s/[\ \~\/\&\*\[\;\>\<\^\$\(\)\`\|\]\'\@]/,/g; $Tis =~ s/[\ \~\/\&\*\[\;\>\<\^\$\(\)\`\|\]\'\@]/,/g; $Tfs =~ s/[\ \~\/\&\*\[\;\>\<\^\$\(\)\`\|\]\'\@]/,/g; @BINVals = split( /,/, $BINS ); @TiVals = split( /,/, $Tis ); @TfVals = split( /,/, $Tfs ); $j = 0; foreach my $Ti (@TiVals) { #Check conditions on numbers # $BINS = int($BINS); $BIN = $BINVals[$j]; $Tf = $TfVals[$j]; if ( $BIN <= 0 ) { $BINVals[$j] = 100; } if ( $Ti > $Tf ) { $tmp = $Tf; $TfVals[$j] = $Ti; $TiVals[$j] = $tmp; } if ( $Ti < 0 || $Ti > 13 ) { $TiVals[$j] = 0.0; } if ( $Tf <= 0 || $Tf > 13 ) { $TfVals[$j] = 10; } $LRBF = $in->param("LRBF"); if ( $LRBF eq $EMPTY ) { $LRBF = "1,3"; } @Hists = split( /,/, $LRBF ); $RRF = $in->param("RRF"); ++$j; } $BINS = join( $COMMA, @BINVals ); $Tis = join( $COMMA, @TiVals ); $Tfs = join( $COMMA, @TfVals ); $logx = $in->param("logx"); $logy = $in->param("logy"); $ltc = $in->param("ltc"); # Initail value if empty if ( $logx ne "y" ) { $logx = "n"; } else { $logxcheck = "checked"; } if ( $logy ne "y" ) { $logy = "n"; } else { $logycheck = "checked"; } if ( $ltc ne "y" ) { $ltc = "n"; } else { $ltccheck = "checked"; } # Fit type: Asymmetry, Single Histogram, or Rotatting Reference Frame $FitAsyType = $in->param("FitAsyType"); if ( $FitAsyType eq $EMPTY ) { %FitAsyType = ( "Asymmetry", "selected=\"selected\"" ); } else { %FitAsyType = ( "$FitAsyType", "selected=\"selected\"" ); } return; } ######################## # ExtractInfo ######################## # Uset to extract information from summary files sub ExtractInfo { my ($RUN,$YEAR,$Arg) = @_; my $Summ_File_Name = "lem" . substr( $YEAR, 2 ) . "_" . $RUN . ".summ"; my $SummFile = "$SUMM_DIR/$YEAR/$Summ_File_Name"; open( SFILE,q{<}, "$SummFile" ); my @lines = ; close(SFILE); if ( $Arg eq "TITLE" ) { $RTRN_Val = $lines[3]; $RTRN_Val =~ s/\n//g; # $RTRN_Val =~ s/[\.\~\/\&\*\[\;\>\<\^\$\(\)\`\|\]\'\@]//g; } elsif ( $Arg eq "Temp" ) { foreach my $line (@lines) { if ( $line =~ /Mean Sample_CF1/ ) { ( my $tmp, my $T ) = split( /=/, $line ); ( $T, $tmp ) = split( /\(/, $T ); $RTRN_Val = $T; } } } elsif ( $Arg eq "Field" ) { foreach my $line (@lines) { if ( $line =~ /Mean B field/ ) { ( $tmp, my $B ) = split( /=/, $line ); ( $B, $tmp ) = split( /\(/, $B ); $RTRN_Val = $B; } } } elsif ( $Arg eq "Energy" ) { foreach my $line (@lines) { if ( $line =~ /implantation energy/ ) { ( my $tmp1, my $tmp2, my $E ) = split( /=/, $line ); ( $E, $tmp ) = split( /keV/, $E ); $RTRN_Val = $E; } } } return; } # Uset to extract information from log files sub ExtractInfoBulk { my ($RUN,$YEAR,$Arg) = @_; my $Summ_File_Name = "lem" . substr( $YEAR, 2 ) . "_" . $RUN . ".summ"; my $SummFile = "$SUMM_DIR/$YEAR/$Summ_File_Name"; open( SFILE,q{<}, "$SummFile" ); @lines = ; close(SFILE); if ( $Arg eq "TITLE" ) { $RTRN_Val = $lines[3]; $RTRN_Val =~ s/\n//g; # $RTRN_Val =~ s/[\.\~\/\&\*\[\;\>\<\^\$\(\)\`\|\]\'\@]//g; } elsif ( $Arg eq "Temp" ) { foreach my $line (@lines) { if ( $line =~ /Mean Sample_CF1/ ) { ( my $tmp, my $T ) = split( /=/, $line ); ( $T, $tmp ) = split( /\(/, $T ); $RTRN_Val = $T; } } } elsif ( $Arg eq "Field" ) { foreach my $line (@lines) { if ( $line =~ /Mean B field/ ) { ( $tmp, my $B ) = split( /=/, $line ); ( $B, $tmp ) = split( /\(/, $B ); $RTRN_Val = $B; } } } elsif ( $Arg eq "Energy" ) { foreach my $line (@lines) { if ( $line =~ /implantation energy/ ) { ( my $tmp1, my $tmp2, my $E ) = split( /=/, $line ); ( $E, $tmp ) = split( /keV/, $E ); $RTRN_Val = $E; } } } return; }