From: Jan Michel Date: Fri, 14 Oct 2016 15:10:00 +0000 (+0200) Subject: Adding many new scripts to labtools. Part is available in daqtools repository and... X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=e67932b232d2595db0548a4d9fad2680ef5a6a07;p=labtools.git Adding many new scripts to labtools. Part is available in daqtools repository and just linked. --- diff --git a/README.md b/README.md new file mode 100644 index 0000000..5e10f9c --- /dev/null +++ b/README.md @@ -0,0 +1,65 @@ + +#Control Tools + +##cooling +Monitoring and display of Huber cooling system + web interface + + +##keysight_agilent_81150A +Generate binary waveform files for arbitrary waveform generator + + +##opus20 +Temperature and Humidity logging device + + +##peltier_controller +Control system for AVR based Peltier cooling + + +##powersupplies +Talking to those who have the power + +###hameg +basic control for Hameg power supplies + +###powerswitch +control for power switch boards (see trb.gsi.de) (from daqtools repo) + +###tdklambda +basic control of a TDK Lambda supply (from daqtools repo) + +###web_rs232 +web interface to USB/serial power supplies, PSP-405, HMP-4040 and others + + +##presenter +Showing slides in a browser, remotely or on Raspi+Projector + + +##pressure +Monitoring and display of pressure sensor data + web interface + + +##sensors +PT100 read-out via USB + web interface + + +##vxi +Generic interface for all devices speaking the vxi protocol over ethernet (from daqtools repo) + + + +##scopes +###yokogawa +Scripts for basic access to Yokogawa Oscilloscope + +###RhodeSchwarz +####root +Root script for analysis of binary waveform files from scope +####gnuplot +Simple gnuplot example to read csv waveform files + +##root +###gnuplot +Plot examples for csv files exported from root \ No newline at end of file diff --git a/README.txt b/README.txt deleted file mode 100644 index e69de29..0000000 diff --git a/keysight_agilent_81150A/pmt_sig.csv b/keysight_agilent_81150A/pmt_sig.csv new file mode 100644 index 0000000..0684469 --- /dev/null +++ b/keysight_agilent_81150A/pmt_sig.csv @@ -0,0 +1,14 @@ +0.0009049774,-0.0018535277 +0.0696832579,-0.0058136417 +0.0909502262,-0.0447812971 +0.1018099548,-0.1392659628 +0.1122171946,-0.2689341378 +0.121719457,-0.4152656276 +0.1307692308,-0.5745584046 +0.1425339367,-0.7023797553 +0.1538461538,-0.7135327635 +0.165158371,-0.6376487347 +0.1746606335,-0.5191654098 +0.1864253394,-0.3303200938 +0.2013574661,-0.1451902128 +0.9936651584,0 diff --git a/keysight_agilent_81150A/pmt_sig.wfm b/keysight_agilent_81150A/pmt_sig.wfm new file mode 100644 index 0000000..de8146e Binary files /dev/null and b/keysight_agilent_81150A/pmt_sig.wfm differ diff --git a/powersupplies/hameg/powersupply_hameg_hmp40x0.pl b/powersupplies/hameg/powersupply_hameg_hmp40x0.pl new file mode 120000 index 0000000..9a05e8c --- /dev/null +++ b/powersupplies/hameg/powersupply_hameg_hmp40x0.pl @@ -0,0 +1 @@ +../../../daqtools/tools/powersupply_hameg.pl \ No newline at end of file diff --git a/powersupplies/powerswitch/pwrswitch.pl b/powersupplies/powerswitch/pwrswitch.pl new file mode 120000 index 0000000..8ee00b8 --- /dev/null +++ b/powersupplies/powerswitch/pwrswitch.pl @@ -0,0 +1 @@ +../../../daqtools/tools/pwrswitch.pl \ No newline at end of file diff --git a/powersupplies/tdklambda/powersupply_tdklambda.pl b/powersupplies/tdklambda/powersupply_tdklambda.pl new file mode 120000 index 0000000..6d23142 --- /dev/null +++ b/powersupplies/tdklambda/powersupply_tdklambda.pl @@ -0,0 +1 @@ +../../../daqtools/tools/powersupply_tdklambda.pl \ No newline at end of file diff --git a/powersupplies/web_rs232 b/powersupplies/web_rs232 new file mode 120000 index 0000000..ac22cb4 --- /dev/null +++ b/powersupplies/web_rs232 @@ -0,0 +1 @@ +../../../daqtools/web/htdocs/tools/pwr/ \ No newline at end of file diff --git a/root/gnuplot/precisionplot.gp b/root/gnuplot/precisionplot.gp new file mode 100644 index 0000000..962605f --- /dev/null +++ b/root/gnuplot/precisionplot.gp @@ -0,0 +1,59 @@ +set style line 11 lc rgb '#404040' lt 1 +set border 3 back ls 11 +set tics nomirror +set datafile separator " " +set style line 12 lc rgb '#404040' lt 0 lw 2 +set grid back ls 12 +# set style fill transparent solid 0.5 noborder + +# set key $keypos +# set key off +# set size $size +# set size 1,0.7 + +# set terminal png +# set output "test.png" + set terminal postscript enhanced color solid size 10,6 + set output "|ps2pdf - test.pdf" +set tics font ", 15" +# set title "$plotTitle" +# set xlabel "$xLabel" +# set ylabel "$yLabel" + +binwidth=3 +bin(x,width)=width*floor(x/width) + +# set multiplot layout 2,1 +set style textbox opaque noborder + +set xtics 0,100,1200 +set ytics 0,20,100 + +set xrange [0:1200] +set yrange [0:100] +set style fill solid 0.5 noborder + +set object 1 rect from screen 0.77,0.92 to screen 0.935,0.65 fs solid 1 fc rgb 0xffffff + +set label 101 "Time [ps]" at screen 0.87,-0.02 font ",15" +set label 102 "Entries [10^3]" at screen 0.07,0.995 font ",15" +set label 103 "Input Amplitude" at screen 0.78,0.89 font ",15" boxed + +set label 20 '12 ps_{rms}' at screen 0.13,0.9 font ",20" tc rgb "#c96215" boxed +set label 10 '13 ps_{rms}' at screen 0.24,0.78 font ",20" tc rgb "#860047" boxed +set label 5 '18 ps_{rms}' at screen 0.36,0.60 font ",20" tc rgb "#b3062c" boxed +set label 3 '28 ps_{rms}' at screen 0.50,0.43 font ",20" tc rgb "#e3ba0f" boxed +set label 2 '34 ps_{rms}' at screen 0.66,0.33 font ",20" tc rgb "#737c45" boxed +set label 1 '61 ps_{rms}' at screen 0.85,0.25 font ",20" tc rgb "#00618f" boxed + +set key at screen 0.92,0.85 + + +plot \ +"dirich/TDC_1207_Ch4_RisingRef_2_4_20mV_12psRMS.hdat" using (bin($1*1000+1220,binwidth)):($4/1.22/1000) title "20 mV" smooth freq w histeps lw 4 lc rgb "#c96215",\ +"dirich/TDC_1207_Ch4_RisingRef_2_4_10mV.hdat" using (bin($1*1000+1410,binwidth)):($4/1.2/1000) title "10 mV" smooth freq w histeps lw 4 lc rgb "#860047",\ +"dirich/TDC_1207_Ch4_RisingRef_2_4_5mV_18psRMS.hdat" using (bin($1*1000+1620,binwidth)):($4/1.5/1000) title "5 mV" smooth freq w histeps lw 4 lc rgb "#b3062c",\ +"dirich/TDC_1207_Ch4_RisingRef_2_4_3mV_28psRMS.hdat" using (bin($1*1000+1820,binwidth)):($4*1.7/1000) title "3 mV" smooth freq w histeps lw 4 lc rgb "#e3ba0f",\ +"dirich/TDC_1207_Ch4_RisingRef_2_4_2mV_34psRMS.hdat" using (bin($1*1000+2070,binwidth)):($4*1.5/1000) title "2 mV" smooth freq w histeps lw 4 lc rgb "#737c45",\ +"dirich/TDC_1207_Ch4_RisingRef_2_4_1mV_61psRMS.hdat" using (bin($1*1000+2420,binwidth)):($4*1.7/1000) title "1 mV" smooth freq w histeps lw 4 lc rgb "#00618f",\ + diff --git a/root/gnuplot/totplot.gp b/root/gnuplot/totplot.gp new file mode 100644 index 0000000..4efffa9 --- /dev/null +++ b/root/gnuplot/totplot.gp @@ -0,0 +1,51 @@ +set style line 1 lc rgb '#8b1a0e' pt 1 ps 1 lt 1 lw 2 # --- red +set style line 2 lc rgb '#5e9c36' pt 6 ps 1 lt 1 lw 2 # --- green + +set style line 11 lc rgb '#404040' lt 1 +set border 3 back ls 11 +set tics nomirror +set datafile separator " " +set style line 12 lc rgb '#404040' lt 0 lw 2 +set grid back ls 12 +# set style fill transparent solid 0.5 noborder + +# set key $keypos +set key off +# set size $size +# set size 1,0.7 + +# set terminal png +# set output "test.png" + set terminal postscript enhanced color solid size 10,6 + set output "|ps2pdf - totplot.pdf" +set tics font ", 15" +# set title "ToT difference between two channels" +# set xlabel "$xLabel" +# set ylabel "$yLabel" + +binwidth=1 +bin(x,width)=x #width*floor(x/width) + +# set multiplot layout 2,1 +set style textbox opaque noborder + +# set xtics 0,100,1200 +# set ytics 0,20,100 + +set xrange [101:280] +# set yrange [0:100] +set style fill solid 0.5 noborder + + +set label 101 "Time [ps]" at screen 0.87,-0.02 font ",15" +set label 102 "Entries [10^3]" at screen 0.07,0.995 font ",15" + +# set key at screen 0.92,0.85 + + +# set lmargin 0.12 + +plot \ +"dirich/TDC_1207_Ch2_Tot_17.5psRMS.hdat" using (bin($1*1000-20000,binwidth)):($4/1000) title "20 mV" smooth freq w histeps lw 4 lc rgb "#c96215",\ + + diff --git a/scopes/rohdeschwarz/gnuplot/example.gp b/scopes/rohdeschwarz/gnuplot/example.gp new file mode 100644 index 0000000..25fc5bf --- /dev/null +++ b/scopes/rohdeschwarz/gnuplot/example.gp @@ -0,0 +1,45 @@ +set style line 1 lc rgb '#8b1a0e' pt 1 ps 1 lt 1 lw 2 # --- red +set style line 2 lc rgb '#5e9c36' pt 6 ps 1 lt 1 lw 2 # --- green + +set style line 11 lc rgb '#404040' lt 1 +set border 3 back ls 11 +set tics nomirror +set datafile separator ";" +set style line 12 lc rgb '#404040' lt 0 lw 1 +set grid back ls 12 +# set style fill transparent solid 0.5 noborder + +# set key $keypos +set key off +# set size $size +set size 1,1 + +# set terminal png +# set output "test.png" + set terminal postscript enhanced color solid + set output "|ps2pdf - test.pdf" +set tics font ", 18" +# set title "$plotTitle" +# set xlabel "$xLabel" +# set ylabel "$yLabel" + + +set multiplot layout 2,1 +set xrange [0.01:40] + +set label 101 "Time [ns]" at screen 0.87,-0.02 font ",18" +set label 102 "Voltage [mV]" at screen -0.03,1.02 font ",18" +#set xtics + +set lmargin 0.12 +plot \ +"ch1_combined_5mVip.Wfm.csv" using ($0/100):($2*1000) title "Input x20" w l lw 2 lc rgb "#888888",\ +"ch1_combined_50mVip.Wfm.csv" using ($0/100-0.7):($2*1000/4) w l lw 5 lc rgb "#c96215" +#"ch1_combined_50mVip.Wfm.csv" using ($0/100-0.7):($2*1000/4) w lp ps 0.5 pt 7 lc rgb "#c96215" +set lmargin 0.13 +set yrange [980:1350] +plot \ +"ch1_combined_5mVip.Wfm.csv" using ($0/100):($1*1000) title "Output" w l lw 2 lc rgb "#888888",\ +"ch1_combined_50mVip.Wfm.csv" using ($0/100-0.7):((($1-1.09)/2.7+1.09)*1000) w l lw 5 lc rgb "#a5ab52" +#"ch1_combined_50mVip.Wfm.csv" using ($0/100-0.7):((($1-1.09)/2.7+1.09)*1000) w lp ps 0.5 pt 7 lc rgb "#a5ab52" +# "$inputFile" using 1:4:5 title "min/max" w filledcu lc rgb "light-grey",\ diff --git a/scopes/rohdeschwarz/root/RSreader.C b/scopes/rohdeschwarz/root/RSreader.C new file mode 100644 index 0000000..acbae04 --- /dev/null +++ b/scopes/rohdeschwarz/root/RSreader.C @@ -0,0 +1,413 @@ +#include +#include +#include "TXMLEngine.h" +#include "TH2.h" +#include "TString.h" +#include "TGraph.h" + +class RSParameter_t +// Class to read and hold the data from the .bin Parameter file +{ +public: + // Class Variables for storage of XML Parameters with same name + TString fFirmwareVersion; + Int_t fRecordLength; + Int_t fHWRecordLength; + Int_t fSignalRecordLength; // Recordlength in file w/o additional fill-bytes + Int_t fSignalHardwareRecordLength; // physical Record Length in file, incl. fill bytes + Int_t fLeadingSettlingSamples; // Nr of additional fill bytes before each record + Int_t fInterleavedTraceCount; // Nr of y-points / channel / trace + Int_t fSignalFormat; // 1 in ADCraw mode (byte), 4 in standard mode (float) + Bool_t fMultiChannelExport; + Int_t fNrChannels; // Nr of exported channels + Bool_t fChannelsActive[4]; // 0 / 1 if channel is exported or not + Double_t fTimeScale; // Time per division + Int_t fHorizontalDivisionCount; + Double_t fResolution; // Time between two samples + Double_t fXStart; // Start time, + Double_t fXStop; // Stop time + Int_t fNofQuantisationLevels; // Nr of digitization levels, for raw-mode decoding + Double_t fVerticalScale[4]; // Volts/fivision for each channel + Double_t fVerticalOffset[4]; // Offset [Volt] for each channel + Double_t fVerticalPosition[4]; // Vertical Position / shift + Int_t fVerticalDivisionCount; // Nr of vertical divisions + Double_t fBaseYStart[4]; // low amplitude limit for each channel + Double_t fBaseYStop[4]; // high amplitude limit for each channel + + + // Member functions + RSParameter_t(); + virtual ~RSParameter_t(); + Int_t ReadParameterFile(TString filename); // Read in .bin XML-Parameter-file + void Print(); +}; + + + +class RSDatafile_t +// Class to read the .Wfm.bin Data file, using Parameters from the Prameter Class. +{ +public: + TString fFilename; + TString fFilenameWfm; + TString fFilenamePar; + + RSParameter_t* fParameters; + + union { + int8_t* bbyte; + float* bfloat; + } fAcqBuffer; // Buffer for single multi-channel acquisition + // float-data in calibrated mode, byte-data in RAW mode + + + Int_t fBufferSize; // Buffersize in byte + Int_t fBufferOffset; // Nr of leading bytes / floats in buffer not used for trace + + FILE* fWfmFile; + Int_t fFileSize; // Datafile size in bytes + Int_t fFileOffset; // Additional 8 bytes at beginning of each data file + Int_t fFileOverhead; + Int_t fNrAcquisitions; // Nr of individual Acquisitions stored in the file + + TH2F* fFrameHisto[4];// For easy drawing of traces in correct borders + TGraph* fTrace[4]; // Storage for individual signal traces (max 4 channels) + + + // Member functions + RSDatafile_t(); + virtual ~RSDatafile_t(); + Int_t OpenFileSet(TString filename); // Open Fileset (.bin + .Wfm.bin), read Parameters + Int_t ReadAcquisition(Int_t index=-1); // Get a specific acquisition from file. index=-1: get next acq + TH2F* GetFrame(Int_t traceindex); // Get a empty Histogram frame for easy drawing +}; + + + + + +// Code section for Class RDarafile:t +//--------------------------------------------------------------------- + +RSDatafile_t::RSDatafile_t() +{ + fFilename=""; + fFilenameWfm=""; + fFilenamePar=""; + fParameters=0; + + fFileOffset=8; // offset [bytes] at beginning of file + fFileOverhead=8; // Total overhead [bytes] in file + for (Int_t i=0; i<4; i++) { + fTrace[i]=0; + fFrameHisto[i]=0; + } +} + +RSDatafile_t::~RSDatafile_t() +{ + if (fParameters) + delete fParameters; + if (fAcqBuffer.bbyte) + delete[] fAcqBuffer.bbyte; + + for (Int_t i=0; i<4; i++) { + if (fTrace[i]) delete fTrace[i]; + if (fFrameHisto[i]) delete fFrameHisto[i]; + } +} + + +Int_t RSDatafile_t::OpenFileSet(TString filename) +{ + filename.ReplaceAll(".bin",""); filename.ReplaceAll(".Wfm",""); + fFilename=filename; + fFilenameWfm=filename+".Wfm.bin"; + fFilenamePar=filename+".bin"; + + fParameters=new RSParameter_t(); + fParameters->ReadParameterFile(fFilenamePar); + fParameters->Print(); + + fBufferSize=fParameters->fSignalHardwareRecordLength * fParameters->fNrChannels * + fParameters->fInterleavedTraceCount * fParameters->fSignalFormat; + fBufferOffset=fParameters->fLeadingSettlingSamples * fParameters->fNrChannels * + fParameters->fInterleavedTraceCount * fParameters->fSignalFormat; + fAcqBuffer.bbyte=new int8_t[fBufferSize]; + + if(!(fWfmFile=fopen(fFilenameWfm,"rb"))) { + printf("File %s does not exist !\n",fFilenameWfm.Data()); + return -1; + } + + fseek(fWfmFile,0,SEEK_END); + fFileSize=ftell(fWfmFile); + fseek(fWfmFile,fFileOffset,SEEK_SET); //skip first n bytes of file# + + fNrAcquisitions=(fFileSize-fFileOverhead)/fBufferSize; + + // Book TGraphs + for (Int_t i=0; i<4; i++) { + fTrace[i]=new TGraph(fParameters->fSignalRecordLength); + } + + printf("File %s opened: \n",fFilenameWfm.Data()); + printf("FFileSize: %i bytes \n",fFileSize); + printf("Buffer size: %i \n",fBufferSize); + printf("Nr of Acquisitions: %i \n",fNrAcquisitions); + printf("Buffer offset: %i \n",fBufferOffset); + return 0; +} + + +Int_t RSDatafile_t::ReadAcquisition(Int_t index) +{ + if (index!=-1) { + Int_t bytepos=index*fBufferSize+fFileOffset; + fseek(fWfmFile,bytepos,SEEK_SET); + } + if (feof(fWfmFile)) { + printf("Event out of reach !\n"); + return -1; + } + + // Read Acquisition buffer, including all overhead bytes + // -> file position shifts exactly to next event + Int_t bytesread=fread(fAcqBuffer.bbyte,1,fBufferSize, fWfmFile); + if (bytesread != fBufferSize) { + printf("Event not correctly read in \n"); + return -2; + } + + // Reset Graphs + for (Int_t ch=0; ch<4; ch++) + fTrace[ch]->Set(0); + + // Decode acqusition buffer into TGraphs: + for (Int_t i=0; i < fParameters->fSignalRecordLength; i++) { + Double_t x=fParameters->fXStart+ fParameters->fResolution *i; + Double_t y; + + Int_t actchannel=0; + for (Int_t ch=0; ch<4; ch++) { + y=0; + if (fParameters->fChannelsActive[ch]) { + Int_t index=i* (fParameters->fInterleavedTraceCount* fParameters->fNrChannels)+ + (actchannel*fParameters->fInterleavedTraceCount); // index without fBufferOffse ! + + if (fParameters->fSignalFormat==4) { + // get calibrated data from scope + y=fAcqBuffer.bfloat[fBufferOffset/4+index]; + } else { + // rawmode : 1 byte per sample + y=fAcqBuffer.bbyte[fBufferOffset+index]; + Double_t convfactor= + fParameters->fVerticalScale[ch]* fParameters->fVerticalDivisionCount / fParameters->fNofQuantisationLevels; + y=y *convfactor +fParameters->fVerticalOffset[ch]; + y=y- fParameters->fVerticalPosition[ch]*fParameters->fVerticalScale[ch]; // Probably a bug in the firmware! + } + actchannel++; + } + fTrace[ch]->SetPoint(i,x,y); + } + } + return 0; +} + + +TH2F* RSDatafile_t::GetFrame(Int_t traceindex) +{ + if (!fParameters->fChannelsActive[traceindex]) + return 0; + + if (!fFrameHisto[traceindex]) { + fFrameHisto[traceindex] = + new TH2F(Form("channel%i",traceindex),Form("channel%i",traceindex), + 2, fParameters->fXStart, fParameters->fXStop, + 2, fParameters->fBaseYStart[traceindex], fParameters->fBaseYStop[traceindex]); + fFrameHisto[traceindex]->GetXaxis()->SetTitle("Time (ns)"); + fFrameHisto[traceindex]->GetYaxis()->SetTitle("Amplitude (V)"); + } + return fFrameHisto[traceindex]; +} + + + + + +// Code section for Class RSParameter_t +//--------------------------------------------------------------------- + +RSParameter_t::~RSParameter_t() +{ +} + + +RSParameter_t::RSParameter_t() +{ +} + + +Int_t RSParameter_t::ReadParameterFile(TString filename) +{ + TXMLEngine* xml = new TXMLEngine; + XMLDocPointer_t xmldoc = xml->ParseFile(filename); + if (xmldoc==0) { + printf("File %s not found !!!\n",filename.Data()); + delete xml; + return -1; + } + + XMLNodePointer_t mainnode=xml->DocGetRootElement(xmldoc); + XMLNodePointer_t child = xml->GetChild(xml->GetChild(mainnode)); + + //loop over all XML entries + while (child) { + const char* name=xml->GetAttr(child,"Name"); + // General Parameters + if (!strcmp(name,"FirmwareVersion")) + fFirmwareVersion=xml->GetAttr(child,"Value"); + // Record Length, fill-bytes, format + if (!strcmp(name,"RecordLength")) + fRecordLength=xml->GetIntAttr(child,"Value"); + if (!strcmp(name,"HWRecordLength")) + fHWRecordLength=xml->GetIntAttr(child, "Value"); + if (!strcmp(name,"SignalRecordLength")) + fSignalRecordLength=xml->GetIntAttr(child,"Value"); + if (!strcmp(name,"SignalHardwareRecordLength")) + fSignalHardwareRecordLength=xml->GetIntAttr(child,"Value"); + if (!strcmp(name,"LeadingSettlingSamples")) + fLeadingSettlingSamples=xml->GetIntAttr(child,"Value"); + if (!strcmp(name,"InterleavedTraceCount")) + fInterleavedTraceCount=xml->GetIntAttr(child,"Value"); + if (!strcmp(name,"SignalFormat")) { + fSignalFormat=1; + if (!strcmp(xml->GetAttr(child,"Value"),"eRS_SIGNAL_FORMAT_FLOAT")) + fSignalFormat=4; + } + // Horizontal Parameters + if (!strcmp(name,"TimeScale")) + fTimeScale=atof(xml->GetAttr(child,"Value")); + if (!strcmp(name,"HorizontalDivisionCount")) + fHorizontalDivisionCount=xml->GetIntAttr(child,"Value"); + if (!strcmp(name,"Resolution")) + fResolution=atof(xml->GetAttr(child,"Value")); + if (!strcmp(name,"XStart")) + fXStart=atof(xml->GetAttr(child,"Value")); + if (!strcmp(name,"XStop")) + fXStop=atof(xml->GetAttr(child,"Value")); + + // Vertical Parameters (single channel) + if (!strcmp(name,"VerticalScale")) + fVerticalScale[0]=atof(xml->GetAttr(child,"Value")); + if (!strcmp(name,"VerticalOffset")) + fVerticalOffset[0]=atof(xml->GetAttr(child,"Value")); + if (!strcmp(name,"VerticalPosition")) + fVerticalPosition[0]=atof(xml->GetAttr(child,"Value")); + if (!strcmp(name,"VerticalDivisionCount")) + fVerticalDivisionCount=xml->GetIntAttr(child,"Value"); + if (!strcmp(name,"NofQuantisationLevels")) + fNofQuantisationLevels=xml->GetIntAttr(child,"Value"); + + if (!strcmp(name,"BaseYStart")) + fBaseYStart[0]=atof(xml->GetAttr(child,"Value")); + if (!strcmp(name,"BaseYStop")) + fBaseYStop[0]=atof(xml->GetAttr(child,"Value")); + // Check for multiple Channels + if (!strcmp(name,"MultiChannelExport")) { + if (!strcmp(xml->GetAttr(child,"Value"),"eRS_ONOFF_ON")) { + fMultiChannelExport=kTRUE; + } + else { + fMultiChannelExport=kFALSE; + fNrChannels=1; + fChannelsActive[0]=kTRUE; + for (Int_t i=1;i<4;i++) { + fChannelsActive[i]=kFALSE; + fVerticalScale[i]=-1; + fVerticalOffset[i]=0; + fVerticalPosition[i]=0; + fBaseYStart[i]=-1; + fBaseYStop[i]=-1; + } + } + } + // Vertical Scale (multiple channels) + if (fMultiChannelExport && (!strcmp(name,"MultiChannelVerticalScale"))) { + for (Int_t i=0; i<4; i++) + fVerticalScale[i]=atof(xml->GetAttr(child,Form("I_%i",i))); + } + if (fMultiChannelExport && (!strcmp(name,"MultiChannelVerticalOffset"))) { + for (Int_t i=0; i<4; i++) + fVerticalOffset[i]=atof(xml->GetAttr(child,Form("I_%i",i))); + } + if (fMultiChannelExport && (!strcmp(name,"MultiChannelVerticalPosition"))) { + for (Int_t i=0; i<4; i++) + fVerticalPosition[i]=atof(xml->GetAttr(child,Form("I_%i",i))); + } + if (fMultiChannelExport && (!strcmp(name,"MultiChannelBaseYStart"))) { + for (Int_t i=0; i<4; i++) + fBaseYStart[i]=atof(xml->GetAttr(child,Form("I_%i",i))); + } + if (fMultiChannelExport && (!strcmp(name,"MultiChannelBaseYStop"))) { + for (Int_t i=0; i<4; i++) + fBaseYStop[i]=atof(xml->GetAttr(child,Form("I_%i",i))); + } + // Active Channels (multiple channels) + if (fMultiChannelExport && (!strcmp(name,"MultiChannelExportState"))) { + fNrChannels=0; + for (Int_t i=0; i<4; i++) { + if (!strcmp(xml->GetAttr(child,Form("I_%i",i)),"eRS_ONOFF_ON")) { + fNrChannels++; + fChannelsActive[i]=kTRUE; + } + else { + fChannelsActive[i]=kFALSE; + fVerticalScale[i]=-1; + fVerticalOffset[i]=0; + fBaseYStart[i]=-1; + fBaseYStop[i]=-1; + } + } + } + + + + child = xml->GetNext(child); + } + + xml->FreeDoc(xmldoc); + delete xml; + return 0; +} + + +void RSParameter_t::Print() +{ + printf("Parameters read in:\n"); + printf("Rohde&Schwarz Parameter File: Firmware %s:\n",fFirmwareVersion.Data()); + + printf("RecordLength: %i \n",fRecordLength); + printf("HWRecordLength: %i \n",fHWRecordLength); + printf("SignalRecordLength: %i \n",fSignalRecordLength); + printf("SignalHardwareRecordLength: %i \n",fSignalHardwareRecordLength); + printf("LeadingSettlingSamples: %i \n",fLeadingSettlingSamples); + printf("InterleavedFTraceCount %i \n",fInterleavedTraceCount); + printf("SignalFormat %i \n",fSignalFormat); + printf("MultiChannelExport %i \n",fMultiChannelExport); + printf("NrChannels %i \n",fNrChannels); + printf("ChannelsActive %i%i%i%i \n",fChannelsActive[0],fChannelsActive[1],fChannelsActive[2],fChannelsActive[3]); + printf("TimeScale %e \n",fTimeScale); + printf("HorizontalDivisionCount %i \n",fHorizontalDivisionCount); + printf("Resolution %e \n",fResolution); + printf("XStart / fXStop %.2e / %.2e \n",fXStart,fXStop); + + printf("NofQuantisationLevels %i \n",fNofQuantisationLevels); + printf("Vertical Scale %.2e %.2e %.2e %.2e \n",fVerticalScale[0],fVerticalScale[1],fVerticalScale[2],fVerticalScale[3]); + printf("Vertical Offset [V] %.3e %.3e %.3e %.3e \n",fVerticalOffset[0],fVerticalOffset[1],fVerticalOffset[2],fVerticalOffset[3]); + printf("Vertical Position [div] %.3e %.3e %.3e %.3e \n",fVerticalPosition[0],fVerticalPosition[1],fVerticalPosition[2],fVerticalPosition[3]); + printf("VerticalDivisionCount %i \n",fVerticalDivisionCount); + printf("BaseYStart %.2e %.2e %.2e %.2e \n",fBaseYStart[0],fBaseYStart[1],fBaseYStart[2],fBaseYStart[3]); + printf("BaseYStop %.2e %.2e %.2e %.2e \n",fBaseYStop[0],fBaseYStop[1],fBaseYStop[2],fBaseYStop[3]); +} + diff --git a/scopes/rohdeschwarz/root/TraceAnalysis.C b/scopes/rohdeschwarz/root/TraceAnalysis.C new file mode 100644 index 0000000..3bffa74 --- /dev/null +++ b/scopes/rohdeschwarz/root/TraceAnalysis.C @@ -0,0 +1,226 @@ +#include "TMath.h" +#include "TLine.h" + + +class TraceAnalysis_t +{ +public: + // Additional Options + Int_t fSetRisingFalling; //1: rising edge, 2: falling edge + Bool_t fSetAutoBaseline; //1: Get Baseline as Median from 10% sample + Double_t fSetDeadtime; //100ps deadtime before next trigger crossing + Double_t fWindowLow; + Double_t fWindowHigh; + + // Calculated Trace Parameters + Double_t fBaseline; + Double_t fLeadingEdgeTime; + Double_t fTrailingEdgeTime; + Double_t fPulseWidth; + Double_t fPulseMaximum; + Double_t fPulseMinimum; + Double_t fPulseAmplitudePeakPeak; + Double_t fPulseArea; + Double_t fNetPulseMaximum; + Double_t fNetPulseMinimum; + Double_t fNetPulseArea; + Double_t fNetPosPulseArea; + Double_t fNetNegPulseArea; + Double_t fAbsThreshold; + + TraceAnalysis_t(); + virtual ~TraceAnalysis_t(); + void Print(); + void Draw(); + Int_t AnalyzeTrace(TGraph* trace, Double_t AbsThreshold, Double_t RelThreshold=0); +}; + +TraceAnalysis_t::TraceAnalysis_t() +{ + fWindowLow=0.; + fWindowHigh=0.; + fSetRisingFalling=1; + fSetAutoBaseline=0.; + fSetDeadtime=1e-10; + fBaseline=0; + fLeadingEdgeTime=1e19; + fTrailingEdgeTime=-1e19; + fPulseWidth=0.; + fPulseMaximum=-1e19; + fPulseMinimum=1e19; + fPulseAmplitudePeakPeak=0.; + fPulseArea=0.; + fNetPulseMaximum=-1e19; + fNetPulseMinimum=1e19; + fNetPulseArea=0.; + fNetPosPulseArea=0.; + fNetNegPulseArea=0.; + +} + +TraceAnalysis_t::~TraceAnalysis_t() +{ +} + +void TraceAnalysis_t::Print() +{ + printf("Results of Trace Analysis\n"); + printf("Parameters: \n"); + printf("Trigger Window %.3e - %.3e \n",fWindowLow,fWindowHigh); + printf("Rising / Falling Edge: %i \n",fSetRisingFalling); + printf("Auto fBaseline determination: %i \n",fSetAutoBaseline); + printf("Minimum Deadtime betw triggers %.2e \n",fSetDeadtime); + printf("Absolute Threshold %.2f \n",fAbsThreshold); + printf("Results:\n"); + printf("fBaseline: %.2f \n",fBaseline); + printf("Leading/Trailing EdgeTime %.2e / %.2e \n",fLeadingEdgeTime,fTrailingEdgeTime); + printf("Pulse Width %.3e \n",fPulseWidth); + printf("Pulse Maximum / Minimum %.2e / %.2e \n",fPulseMaximum, fPulseMinimum); + printf("Net Pulse Maximum / Minimum %.2e / %.2e \n",fNetPulseMaximum, fNetPulseMinimum); + printf("Pulse Peak-to-Peak Ampltitude %.2e \n",fPulseAmplitudePeakPeak); + printf("Pulse Area / Net Area %.2e / %.2e \n",fPulseArea, fNetPulseArea); + printf("Pos/Neg Net Pulse Area %.2e / %.2e \n",fNetPosPulseArea,fNetNegPulseArea); + printf("\n"); +} + +void TraceAnalysis_t::Draw() +{ + Double_t xmin=gPad->GetUxmin(); + Double_t xmax=gPad->GetUxmax(); + Double_t ymin=gPad->GetUymin(); + Double_t ymax=gPad->GetUymax(); + + // TriggerGate + TLine line; + line.SetLineColor(kBlack); + line.SetLineWidth(3); + if (fWindowLow!=fWindowHigh) { + line.DrawLine(fWindowLow,ymin,fWindowLow,ymax); + line.DrawLine(fWindowHigh,ymin,fWindowHigh,ymax); + } + + // baseline + line.SetLineColor(kBlue); + line.SetLineWidth(3); + line.DrawLine(xmin,fBaseline,xmax,fBaseline); + + // Trigger Points + line.SetLineColor(kRed); + line.SetLineWidth(1); + line.DrawLine(fLeadingEdgeTime,ymin,fLeadingEdgeTime,ymax); + line.DrawLine(fTrailingEdgeTime,ymin,fTrailingEdgeTime,ymax); + + // Pulse Maximum / Minimum + line.SetLineColor(kBlue); + line.SetLineWidth(1); + line.DrawLine(xmin,fPulseMaximum,xmax,fPulseMaximum); + line.DrawLine(xmin,fPulseMinimum,xmax,fPulseMinimum); + + // Abs / Rel Threshold + line.SetLineColor(kRed); + line.SetLineWidth(1); + line.SetLineStyle(kDashed); + line.DrawLine(xmin,fAbsThreshold+fBaseline,xmax,fAbsThreshold+fBaseline); +} + +Int_t TraceAnalysis_t::AnalyzeTrace(TGraph* trace, Double_t AbsThreshold, Double_t RelThreshold) +{ + if (!trace) + return -1; + Int_t NrPoints=trace->GetN(); + Int_t lowbin=0; + Int_t highbin=NrPoints-1; + + // Calculate sample nrs corresponding to given window range + Bool_t WindowOnly= (fWindowLow!=fWindowHigh); + Double_t xfirst,yfirst,xlast,ylast; + trace->GetPoint(0,xfirst,yfirst); + trace->GetPoint(NrPoints-1,xlast,ylast); + Double_t resolutionx=(xlast-xfirst)/(NrPoints-1); + if (WindowOnly) { + lowbin=(fWindowLow-xfirst)/resolutionx; + highbin=(fWindowHigh-xfirst)/resolutionx; + } + + // Calculate baseline as Median from first 10% of sample + if (fSetAutoBaseline) + fBaseline=TMath::Median(NrPoints/10,trace->GetY()); + + fPulseMaximum=TMath::MaxElement(highbin-lowbin+1,&(trace->GetY()[lowbin])); + fPulseMinimum=TMath::MinElement(highbin-lowbin+1,&(trace->GetY()[lowbin])); + fPulseAmplitudePeakPeak=fPulseMaximum-fPulseMinimum; + fNetPulseMaximum=fPulseMaximum-fBaseline; + fNetPulseMinimum=fPulseMinimum-fBaseline; + + // Adjust AbsThreshold if rel threshold is given + if (RelThreshold>0) AbsThreshold=TMath::Max(AbsThreshold,RelThreshold*fNetPulseMaximum); + if (RelThreshold<0) AbsThreshold=TMath::Min(-AbsThreshold,-1*RelThreshold*fNetPulseMinimum); + fAbsThreshold=AbsThreshold; + + fPulseArea=0.; + fNetPulseArea=0.; + fNetPosPulseArea=0.; + fNetNegPulseArea=0.; + fLeadingEdgeTime=1e19; + fTrailingEdgeTime=1e19; + + Double_t x,y; + Bool_t Triggered=kFALSE; + Bool_t Done=kFALSE; // Trigger only on first pulse + + Double_t lastchange=-1e19; + for (Int_t ibin=lowbin; ibinGetPoint(ibin,x,y); + // Get Leading and Trailing Edge Time + if ( ((x-lastchange) > fSetDeadtime) && !Done) { //Hysteresis, 1. pulse only + // For rising edge triggering (positive signals) + if (fSetRisingFalling==1) { + if (!Triggered && (y-fBaseline)>AbsThreshold) { + fLeadingEdgeTime=x; + Triggered=kTRUE; + lastchange=x; + } + if (Triggered && (y-fBaseline)AbsThreshold) { + fTrailingEdgeTime=x; + Triggered=kFALSE; + lastchange=x; + Done=kTRUE; + } + } + } + // Calculate Pulse Area w/wo baseline + fPulseArea+=fabs(y*resolutionx); + fNetPulseArea+=fabs((y-fBaseline)*resolutionx); + if ((y-fBaseline)>0) fNetPosPulseArea+=(y-fBaseline)*resolutionx; + if ((y-fBaseline)<0) fNetNegPulseArea+=-1.*(y-fBaseline)*resolutionx; + } + // fPulseWidth as Difference between first and second trigger crossing + fPulseWidth=fTrailingEdgeTime-fLeadingEdgeTime; + if (!Done) { // No clean pulse with leading & trailing edge detected. S + fPulseArea=1e19; // Skip pulse area, amplitude + fNetPulseArea=1e19; + fNetPosPulseArea=1e19; fNetNegPulseArea=1e19; + fPulseMaximum=1e19; fPulseMinimum=1e19; + fNetPulseMaximum=1e19; fNetPulseMinimum=1e19; + + } + + return 0; +} + + + diff --git a/scopes/rohdeschwarz/root/analyze.C b/scopes/rohdeschwarz/root/analyze.C new file mode 100644 index 0000000..aa8c8af --- /dev/null +++ b/scopes/rohdeschwarz/root/analyze.C @@ -0,0 +1,125 @@ +#include "TCanvas.h" +#include "TH2.h" + +// Class RSreader contains code for reading any specific acquisition +// of scope data out of the .bin file. Data are exported as TGraph. +// Class TraceAnalysis is doing basic measurements on traces, using +// the TGraph as input. +#include "RSreader.C" +#include "TraceAnalysis.C" + +TH1F* hLeadingEdgeTiming; +TH1F* hPositiveAmplitude; +TH1F* hPulseWidth; +TH1F* hNetPosPulseArea; +TH1F* hNetNegPulseArea; +TH1F* hNetPulseArea; +TH2F* hAmplitudevsArea; +TH2F* hAreavsWidth; +TH2F* hAreavsWidth2; + +void BookHistograms() +{ + hLeadingEdgeTiming=new TH1F("LeadingEdgeTiming","LeadingEdgeTiming",200,5e-9,20.e-9); + hPositiveAmplitude=new TH1F("PositiveAmplitude","PositiveAmplitue",100,0.,0.8); + hPulseWidth=new TH1F("PulseWidth","PulseWidth",100,0.,10e-9); + hNetPosPulseArea=new TH1F("NetPosPulseArea","NetPosPulseArea",100,0.,5e-9); + hNetNegPulseArea=new TH1F("NetNegPulseArea","NetNegPulseArea",100,0.,5e-9); + hNetPulseArea=new TH1F("NetPulseArea","NetPulseArea",100,0.,5e-9); + + hAmplitudevsArea=new TH2F("AmplitudevsArea","AmplitudevsArea",50,0.,0.5,50,0.,5e-9); + hAreavsWidth=new TH2F("AreavsWidth","AreavsWidth",50,0.,3.5e-9,50,0.,10e-9); + hAreavsWidth2=new TH2F("AreavsWidth2","AreavsWidth2",50,0.,3.5e-9,50,0.,10e-9); +} + + +void analyze(TString filename) +{ + BookHistograms(); + + TCanvas* cc=new TCanvas("cc","cc",1000,1000); + RSDatafile_t* RSData=new RSDatafile_t(); + RSData->OpenFileSet(filename); + + // Setting up two instances of TraceAnalysis: One for the + // Trigger Channel on scope ch1, one for the actual signal (ch3) + // fSetAutoBaseline=kTRUE: Derive baseline as median of first 10% of sample + // Useful for Signal channel, due to 1.1V offset. + // fSetDeadTime: Minimum time diff betw. leading and trailing edge + // to suppress triggering on noise. + TraceAnalysis_t* TraceAnalysisTrigger=new TraceAnalysis_t(); + TraceAnalysisTrigger->fSetAutoBaseline=kFALSE; + TraceAnalysisTrigger->fSetRisingFalling=1; + TraceAnalysisTrigger->fSetDeadtime=0.5e-9; + + TraceAnalysis_t* TraceAnalysisSignal=new TraceAnalysis_t(); + TraceAnalysisSignal->fSetAutoBaseline=kTRUE; + TraceAnalysisSignal->fSetRisingFalling=1; + TraceAnalysisSignal->fSetDeadtime=0.5e-9; + + + for (Int_t i=0; ifNrAcquisitions; i++) { + // ReadAcquisition() reads always the next acquisition in the file. + // By giving a parameter, one could also read any specific acq in file. + Int_t result=RSData->ReadAcquisition(); + + // Use absolute threshold 2.0V on ch1, 0.08V (above baseline) on ch3 + // A third parameter could define a rel threshold relative to max/min + // (after baseline subtraction). rel overrides abs threshold + TraceAnalysisTrigger->AnalyzeTrace(RSData->fTrace[0],2.0); + TraceAnalysisSignal->AnalyzeTrace(RSData->fTrace[2],0.08); + + // Fill Histograms + hLeadingEdgeTiming->Fill(TraceAnalysisSignal->fLeadingEdgeTime - TraceAnalysisTrigger->fLeadingEdgeTime); + hPositiveAmplitude->Fill(TraceAnalysisSignal->fNetPulseMaximum); + hPulseWidth->Fill(TraceAnalysisSignal->fPulseWidth); + hNetPosPulseArea->Fill(TraceAnalysisSignal->fNetPosPulseArea); + hNetNegPulseArea->Fill(TraceAnalysisSignal->fNetNegPulseArea); + hNetPulseArea->Fill(TraceAnalysisSignal->fNetPulseArea); + hAmplitudevsArea->Fill(TraceAnalysisSignal->fNetPulseMaximum,TraceAnalysisSignal->fNetPulseArea); + hAreavsWidth->Fill(TraceAnalysisSignal->fNetPosPulseArea,TraceAnalysisSignal->fPulseWidth); + if (TraceAnalysisSignal->fPulseWidth >2e-9) + hAreavsWidth2->Fill(TraceAnalysisSignal->fNetPosPulseArea,TraceAnalysisSignal->fPulseWidth); + + // Draw every 500th acquisition + if ((i+1)%50==0) { + cc->Clear(); + cc->Divide(3,3); + cc->cd(1); + // GetFrame provides empty histogram with all axis properly set + RSData->GetFrame(0)->Draw(); + cc->Update(); + RSData->fTrace[0]->Draw("same"); + TraceAnalysisTrigger->Draw(); + TraceAnalysisTrigger->Print(); + + cc->cd(2); + RSData->GetFrame(2)->Draw(); + cc->Update(); + RSData->fTrace[2]->Draw("same"); + TraceAnalysisSignal->Draw(); + TraceAnalysisSignal->Print(); + + cc->cd(3); + hLeadingEdgeTiming->Draw(); + + cc->cd(4); + hPulseWidth->Draw(); + cc->cd(5); + hPositiveAmplitude->Draw(); + cc->cd(6); + hNetPosPulseArea->Draw(); + + + cc->cd(7); + hAmplitudevsArea->Draw("box"); + cc->cd(8); + hAreavsWidth->Draw("box"); + cc->cd(9); + hAreavsWidth2->Draw("box"); + + cc->Update(); + } + } +} + diff --git a/scopes/rohdeschwarz/root/sample_200ev_Rawmode.Wfm.bin b/scopes/rohdeschwarz/root/sample_200ev_Rawmode.Wfm.bin new file mode 100644 index 0000000..d415381 Binary files /dev/null and b/scopes/rohdeschwarz/root/sample_200ev_Rawmode.Wfm.bin differ diff --git a/scopes/rohdeschwarz/root/sample_200ev_Rawmode.bin b/scopes/rohdeschwarz/root/sample_200ev_Rawmode.bin new file mode 100644 index 0000000..bae56c9 --- /dev/null +++ b/scopes/rohdeschwarz/root/sample_200ev_Rawmode.bin @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/scopes/yokogawa/yoko_load b/scopes/yokogawa/yoko_load new file mode 100755 index 0000000..ad9008a --- /dev/null +++ b/scopes/yokogawa/yoko_load @@ -0,0 +1,20 @@ +#!/bin/bash + +yoko_addr="192.168.10.40" + +timestamp=$(date '+%Y-%m-%d_%H:%M:%S') + +yoko_dir="ftp://$yoko_addr/HD/" + +#curl $yoko_dir 2>/dev/null | perl -p -e 's/\S*\s*\S*\s*\S*\s*//;' + +for i in $(curl $yoko_dir 2>/dev/null | perl -p -e 's/\S*\s*\S*\s*\S*\s*//;') +do +if [ -e $i ]; then +echo "$i: file exists" +else +echo "downloading $i" +wget $yoko_dir$i +fi +done + diff --git a/scopes/yokogawa/yoko_load_last b/scopes/yokogawa/yoko_load_last new file mode 100755 index 0000000..de60ee3 --- /dev/null +++ b/scopes/yokogawa/yoko_load_last @@ -0,0 +1,21 @@ +#!/bin/bash + +yoko_addr="192.168.10.40" + + +yoko_dir="ftp://$yoko_addr/HD/" + +#curl $yoko_dir 2>/dev/null | perl -p -e 's/\S*\s*\S*\s*\S*\s*//;' + + +i=$(curl $yoko_dir 2>/dev/null | perl -p -e 's/\S*\s*\S*\s*\S*\s*//;'| tail -n 1) +outfn=$i +if [ $1 ]; then +outfn=$1 +fi +if [ -e $outfn ]; then +echo "$outfn: file exists" +else +echo "downloading $i" +wget $yoko_dir$i -O $outfn +fi diff --git a/scopes/yokogawa/yoko_screen b/scopes/yokogawa/yoko_screen new file mode 100755 index 0000000..c4e71ff --- /dev/null +++ b/scopes/yokogawa/yoko_screen @@ -0,0 +1,11 @@ +#!/bin/bash + +yoko_addr="192.168.10.40" + +timestamp=$(date '+%Y-%m-%d_%H:%M:%S') +outputfn="./yoko_screen_$timestamp.png" +if [ $1 ]; then +outputfn=$1 +fi + +wget ${yoko_addr}/webmonimagefull.png --ignore-length -O $outputfn diff --git a/scopes/yokogawa/yoko_start_acq b/scopes/yokogawa/yoko_start_acq new file mode 100755 index 0000000..1809110 --- /dev/null +++ b/scopes/yokogawa/yoko_start_acq @@ -0,0 +1,3 @@ +#!/bin/bash +yoko_addr="192.168.10.40" +curl $yoko_addr/start.cmd >/dev/null 2>&1 diff --git a/scopes/yokogawa/yoko_stop_acq b/scopes/yokogawa/yoko_stop_acq new file mode 100755 index 0000000..6095ae2 --- /dev/null +++ b/scopes/yokogawa/yoko_stop_acq @@ -0,0 +1,3 @@ +#!/bin/bash +yoko_addr="192.168.10.40" +curl $yoko_addr/stop.cmd >/dev/null 2>&1 diff --git a/vxi b/vxi new file mode 120000 index 0000000..fa8dd33 --- /dev/null +++ b/vxi @@ -0,0 +1 @@ +../../daqtools/web/htdocs/tools/vxi \ No newline at end of file