From d9a0ea407e388bb3eaf98862c8cc7d818c360dec Mon Sep 17 00:00:00 2001 From: Zaher Salman Date: Mon, 31 Aug 2009 08:28:57 +0000 Subject: [PATCH] Implimented defaul t0,Bg and Data in MSR module --- src/external/MuSRFitGUI/MSR.pm | 48 +++++++++++++++ src/external/MuSRFitGUI/MuSRFit.pl | 91 +++++++++++----------------- src/external/MuSRFitGUI/MuSRFit.ui | 21 ++++--- src/external/MuSRFitGUI/MuSRFit.ui.h | 73 +++++++++------------- 4 files changed, 125 insertions(+), 108 deletions(-) diff --git a/src/external/MuSRFitGUI/MSR.pm b/src/external/MuSRFitGUI/MSR.pm index fec16b0a..8d0d5229 100755 --- a/src/external/MuSRFitGUI/MSR.pm +++ b/src/external/MuSRFitGUI/MSR.pm @@ -1183,4 +1183,52 @@ sub ExtractParamBlk { } +######################## +# T0BgData +# Function return the defaul value of t0, Bg and Data bin +# input should be +# $Name is t0,Bg1,Bg2,Data1,Data2 +# $Hist is the histogram number +# $BeamLine in the name of beamline +######################## +sub T0BgData { +# Take this information as input arguments + (my $Name, my $Hist, my $BeamLine) = @_; + +# These are the default values, ordered by beamline +# Comma at the beginning means take default t0 from file +# The order is pairs of "HistNumber","t0,Bg1,Bg2,Data1,Data2" + my %LEM=("1",",66000,66500,3419,63000", + "2",",66000,66500,3419,63000", + "3",",66000,66500,3419,63000", + "4",",66000,66500,3419,63000"); + + my %GPS=("1",",40,120,135,8000", + "2",",40,120,135,8000", + "3",",40,120,135,8000", + "4",",40,120,135,8000"); + + my %Dolly=("1",",50,250,297,8000", + "2",",50,250,297,8000", + "3",",50,250,297,8000", + "4",",50,250,297,8000"); + + my %RV=(); + + if ($BeamLine eq "LEM") { + my $HistParams=$LEM{$Hist}; + ($RV{"t0"},$RV{"Bg1"},$RV{"Bg2"},$RV{"Data1"},$RV{"Data2"})=split(/,/,$HistParams); + } + elsif ($BeamLine eq "Dolly") { + my $HistParams=$Dolly{$Hist}; + ($RV{"t0"},$RV{"Bg1"},$RV{"Bg2"},$RV{"Data1"},$RV{"Data2"})=split(/,/,$HistParams); + } + elsif ($BeamLine eq "GPS") { + my $HistParams=$GPS{$Hist}; + ($RV{"t0"},$RV{"Bg1"},$RV{"Bg2"},$RV{"Data1"},$RV{"Data2"})=split(/,/,$HistParams); + } + return $RV{$Name}; + +} + 1; diff --git a/src/external/MuSRFitGUI/MuSRFit.pl b/src/external/MuSRFitGUI/MuSRFit.pl index 4e9d60b1..e24f61c4 100755 --- a/src/external/MuSRFitGUI/MuSRFit.pl +++ b/src/external/MuSRFitGUI/MuSRFit.pl @@ -1,6 +1,6 @@ # Form implementation generated from reading ui file 'MuSRFit.ui' # -# Created: Sun Aug 30 22:23:26 2009 +# Created: Mon Aug 31 10:21:34 2009 # by: The PerlQt User Interface Compiler (puic) # # WARNING! All changes made in this file will be lost! @@ -27,7 +27,6 @@ use Qt::slots helpIndex => [], helpContents => [], helpAbout => [], - T0BgData => [], CreateAllInput => [], CallMSRCreate => [], UpdateMSRFileInitTable => [], @@ -37,7 +36,8 @@ use Qt::slots TabChanged => [], GoFit => [], GoPlot => [], - ShowMuSRT0 => []; + ShowMuSRT0 => [], + T0Update => []; use Qt::attributes qw( textLabel2_2 musrfit_tabs @@ -556,7 +556,7 @@ sub NEW setName("MuSRFitform" ); } setSizePolicy(Qt::SizePolicy(3, 3, 1, 1, this->sizePolicy()->hasHeightForWidth()) ); - setMinimumSize(Qt::Size(23, 222) ); + setMinimumSize(Qt::Size(21, 227) ); setIcon($image0 ); setCentralWidget(Qt::Widget(this, "qt_central_widget")); @@ -1032,8 +1032,8 @@ sub NEW groupHist0->setMinimumSize( Qt::Size(0, 0) ); my $LayoutWidget_9 = Qt::Widget(groupHist0, '$LayoutWidget_9'); - $LayoutWidget_9->setGeometry( Qt::Rect(5, 28, 100, 135) ); - my $layout16_2 = Qt::VBoxLayout($LayoutWidget_9, 11, 0, '$layout16_2'); + $LayoutWidget_9->setGeometry( Qt::Rect(5, 18, 100, 150) ); + my $layout16_2 = Qt::VBoxLayout($LayoutWidget_9, 11, 6, '$layout16_2'); textLabel2 = Qt::Label($LayoutWidget_9, "textLabel2"); $layout16_2->addWidget(textLabel2); @@ -1212,7 +1212,7 @@ sub NEW MenuBar= Qt::MenuBar( this, "MenuBar"); MenuBar->setEnabled( 1 ); - MenuBar->setGeometry( Qt::Rect(0, 0, 575, 25) ); + MenuBar->setGeometry( Qt::Rect(0, 0, 575, 27) ); fileMenu = Qt::PopupMenu( this ); fileOpenAction->addTo( fileMenu ); @@ -1271,6 +1271,7 @@ sub NEW Qt::Object::connect(TableUpdate, SIGNAL "clicked()", this, SLOT "CallMSRCreate()"); Qt::Object::connect(ShowT0, SIGNAL "clicked()", this, SLOT "ShowMuSRT0()"); Qt::Object::connect(PlotMSR, SIGNAL "clicked()", this, SLOT "GoPlot()"); + Qt::Object::connect(BeamLine, SIGNAL "activated(int)", this, SLOT "T0Update()"); setTabOrder(musrfit_tabs, TITLE); setTabOrder(TITLE, FILENAME); @@ -1689,50 +1690,6 @@ Copyright 2009 by Zaher Salman and the LEM Group. } -sub T0BgData -{ - -# Take this information as input arguments - (my $Name, my $Hist, my $BeamLine) = @_; - -# These are the default values, ordered by beamline -# Comma at the beginning means take default t0 from file -# The order is pairs of "HistNumber","t0,Bg1,Bg2,Data1,Data2" - my %LEM=("1",",66000,66500,3419,63000", - "2",",66000,66500,3419,63000", - "3",",66000,66500,3419,63000", - "4",",66000,66500,3419,63000"); - - my %GPS=("1",",40,120,135,8000", - "2",",40,120,135,8000", - "3",",40,120,135,8000", - "4",",40,120,135,8000"); - - my %Dolly=("1",",50,250,297,8000", - "2",",50,250,297,8000", - "3",",50,250,297,8000", - "4",",50,250,297,8000"); - - my %RV=(); - - print "Name = $Name,Hist= $Hist, BeamLine= $BeamLine \n"; - if ($BeamLine = "LEM") { - my $HistParams=$LEM{$Hist}; - ($RV{"t0"},$RV{"Bg1"},$RV{"Bg2"},$RV{"Data1"},$RV{"Data2"})=split(/,/,$HistParams); - } - elsif ($BeamLine = "Dolly") { - my $HistParams=$Dolly{$Hist}; - ($RV{"t0"},$RV{"Bg1"},$RV{"Bg2"},$RV{"Data1"},$RV{"Data2"})=split(/,/,$HistParams); - } - elsif ($BeamLine = "GPS") { - my $HistParams=$GPS{$Hist}; - ($RV{"t0"},$RV{"Bg1"},$RV{"Bg2"},$RV{"Data1"},$RV{"Data2"})=split(/,/,$HistParams); - } - - return $RV{$Name}; - -} - sub CreateAllInput { @@ -1766,7 +1723,7 @@ sub CreateAllInput $All{$Name}=child($Name)->text; # TODO: If empty fill with defaults if ($All{$Name} eq "") { - $All{$Name}=T0BgData($_,$Hist,$All{"BeamLine"}); + $All{$Name}=MSR::T0BgData($_,$Hist,$All{"BeamLine"}); child($Name)->setText($All{$Name}); } } @@ -1955,8 +1912,8 @@ sub UpdateMSRFileInitTable my $PCount=0; foreach my $line (@FPBloc) { $PCount++; -# print "line $PCount: $line \n"; my @Param=split(/\s+/,$line); + # Depending on home many elements in @Param determine what they mean # 0th element is empty (always) # 1st element is the order (always) @@ -1984,7 +1941,7 @@ sub UpdateMSRFileInitTable $minvalue=1.0*$Param[6]; $maxvalue=1.0*$Param[7]; } -# print "$Param[2]=$Param[3]+-$Param[4] from $Param[5] to $Param[6]\n"; +# Now update the initialization tabel InitParamTable->setText($PCount-1,0,$value); InitParamTable->setText($PCount-1,1,$error); InitParamTable->setText($PCount-1,2,$minvalue); @@ -2319,7 +2276,33 @@ sub GoPlot sub ShowMuSRT0 { + my %All=CreateAllInput(); # Create MSR file and then run musrt0 + CallMSRCreate(); + my $FILENAME=$All{"FILENAME"}.".msr"; + my $cmd="musrt0 $FILENAME &"; + my $pid = system($cmd); + return; + +} + +sub T0Update +{ + + my %All = CreateAllInput(); + my @Hists = split(/,/, $All{"LRBF"} ); + +# Get values of t0 and Bg/Data bins if given + my $NHist = 1; + foreach my $Hist (@Hists) { + foreach ("t0","Bg1","Bg2","Data1","Data2") { + my $Name = "$_$NHist"; + my $tmp=MSR::T0BgData($_,$Hist,$All{"BeamLine"}); + child($Name)->setText($tmp); + } + $NHist++ + } + } diff --git a/src/external/MuSRFitGUI/MuSRFit.ui b/src/external/MuSRFitGUI/MuSRFit.ui index ff35fa6c..75291fa4 100755 --- a/src/external/MuSRFitGUI/MuSRFit.ui +++ b/src/external/MuSRFitGUI/MuSRFit.ui @@ -22,8 +22,8 @@ - 23 - 222 + 21 + 227 @@ -2070,18 +2070,15 @@ 5 - 28 + 18 100 - 135 + 150 unnamed_2 - - 0 - textLabel2 @@ -2425,7 +2422,7 @@ 0 0 575 - 25 + 27 @@ -2974,6 +2971,12 @@ MuSRFitform GoPlot() + + BeamLine + activated(int) + MuSRFitform + T0Update() + musrfit_tabs @@ -3025,7 +3028,6 @@ helpIndex() helpContents() helpAbout() - T0BgData() CreateAllInput() CallMSRCreate() UpdateMSRFileInitTable() @@ -3036,6 +3038,7 @@ GoFit() GoPlot() ShowMuSRT0() + T0Update() diff --git a/src/external/MuSRFitGUI/MuSRFit.ui.h b/src/external/MuSRFitGUI/MuSRFit.ui.h index 58e8fc24..be6a2404 100755 --- a/src/external/MuSRFitGUI/MuSRFit.ui.h +++ b/src/external/MuSRFitGUI/MuSRFit.ui.h @@ -156,48 +156,6 @@ Copyright 2009 by Zaher Salman and the LEM Group. my $AboutWindow = Qt::MessageBox::information( this, "About MuSRFit GUI",$AboutText); } -void MuSRFitform::T0BgData() -{ -# Take this information as input arguments - (my $Name, my $Hist, my $BeamLine) = @_; - -# These are the default values, ordered by beamline -# Comma at the beginning means take default t0 from file -# The order is pairs of "HistNumber","t0,Bg1,Bg2,Data1,Data2" - my %LEM=("1",",66000,66500,3419,63000", - "2",",66000,66500,3419,63000", - "3",",66000,66500,3419,63000", - "4",",66000,66500,3419,63000"); - - my %GPS=("1",",40,120,135,8000", - "2",",40,120,135,8000", - "3",",40,120,135,8000", - "4",",40,120,135,8000"); - - my %Dolly=("1",",50,250,297,8000", - "2",",50,250,297,8000", - "3",",50,250,297,8000", - "4",",50,250,297,8000"); - - my %RV=(); - - print "Name = $Name,Hist= $Hist, BeamLine= $BeamLine \n"; - if ($BeamLine = "LEM") { - my $HistParams=$LEM{$Hist}; - ($RV{"t0"},$RV{"Bg1"},$RV{"Bg2"},$RV{"Data1"},$RV{"Data2"})=split(/,/,$HistParams); - } - elsif ($BeamLine = "Dolly") { - my $HistParams=$Dolly{$Hist}; - ($RV{"t0"},$RV{"Bg1"},$RV{"Bg2"},$RV{"Data1"},$RV{"Data2"})=split(/,/,$HistParams); - } - elsif ($BeamLine = "GPS") { - my $HistParams=$GPS{$Hist}; - ($RV{"t0"},$RV{"Bg1"},$RV{"Bg2"},$RV{"Data1"},$RV{"Data2"})=split(/,/,$HistParams); - } - - return $RV{$Name}; -} - void MuSRFitform::CreateAllInput() { # TODO: Need to deliver shared parameters also @@ -230,7 +188,7 @@ void MuSRFitform::CreateAllInput() $All{$Name}=child($Name)->text; # TODO: If empty fill with defaults if ($All{$Name} eq "") { - $All{$Name}=T0BgData($_,$Hist,$All{"BeamLine"}); + $All{$Name}=MSR::T0BgData($_,$Hist,$All{"BeamLine"}); child($Name)->setText($All{$Name}); } } @@ -415,8 +373,8 @@ void MuSRFitform::UpdateMSRFileInitTable() my $PCount=0; foreach my $line (@FPBloc) { $PCount++; -# print "line $PCount: $line \n"; my @Param=split(/\s+/,$line); + # Depending on home many elements in @Param determine what they mean # 0th element is empty (always) # 1st element is the order (always) @@ -444,7 +402,7 @@ void MuSRFitform::UpdateMSRFileInitTable() $minvalue=1.0*$Param[6]; $maxvalue=1.0*$Param[7]; } -# print "$Param[2]=$Param[3]+-$Param[4] from $Param[5] to $Param[6]\n"; +# Now update the initialization tabel InitParamTable->setText($PCount-1,0,$value); InitParamTable->setText($PCount-1,1,$error); InitParamTable->setText($PCount-1,2,$minvalue); @@ -766,5 +724,30 @@ void MuSRFitform::GoPlot() void MuSRFitform::ShowMuSRT0() { + my %All=CreateAllInput(); # Create MSR file and then run musrt0 + CallMSRCreate(); + my $FILENAME=$All{"FILENAME"}.".msr"; + my $cmd="musrt0 $FILENAME &"; + my $pid = system($cmd); + return; +} + + +void MuSRFitform::T0Update() +{ + my %All = CreateAllInput(); + my @Hists = split(/,/, $All{"LRBF"} ); + +# Get values of t0 and Bg/Data bins if given + my $NHist = 1; + foreach my $Hist (@Hists) { + foreach ("t0","Bg1","Bg2","Data1","Data2") { + my $Name = "$_$NHist"; + my $tmp=MSR::T0BgData($_,$Hist,$All{"BeamLine"}); + child($Name)->setText($tmp); + } + $NHist++ + } + }