From: Maps Date: Tue, 18 Apr 2023 14:41:19 +0000 (+0200) Subject: added options to dac_scan.pl X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=aec574a1f10035797ba04fe76ea114267437142d;p=mimosis_chain.git added options to dac_scan.pl --- diff --git a/analysis/rawreader/second.C b/analysis/rawreader/second.C index 8d4ae19..a8f7363 100644 --- a/analysis/rawreader/second.C +++ b/analysis/rawreader/second.C @@ -1,6 +1,6 @@ #include "base/EventProc.h" #include "hadaq/TdcSubEvent.h" -#include "hadaq/HldProcessor.h" +#include "hadaq/HldProcessor.h" #include "TString.h" //#include "base/Event.h" @@ -12,18 +12,18 @@ class SecondProc : public base::EventProc { protected: std::string fTdcId; //!< tdc id where channels will be selected - base::H2handle hDiff; - base::H2handle hPrevDiff; - base::H2handle hRiseRef; - + base::H2handle hDiff; + base::H2handle hPrevDiff; + base::H2handle hRiseRef; + base::H2handle hFineCh; base::H2handle hFineRiseCh; base::H2handle hFineFallCh; base::H2handle hDiffToScint[17]; base::H1handle hScintCor; base::H2handle hSciTot[4]; - - + + public: SecondProc(const char* procname, const char* _tdcid); @@ -43,7 +43,7 @@ SecondProc::SecondProc(const char* procname, const char* _tdcid) : hFineCh = MakeH2("Finech","Fine distribution channels", MAXCH, 0, MAXCH, 600, 0, 600, ""); hFineRiseCh = MakeH2("FineRisech","Fine rising", MAXCH, 0, MAXCH, 600, 0, 600, ""); hFineFallCh = MakeH2("FineFallch","Fine falling", MAXCH, 0, MAXCH, 600, 0, 600, ""); -// +// // hScintCor = MakeH1("ScintCor","Scint Cor",10000,-100,100,"ns"); // for(unsigned i = 9; i<=16; i++) { // hDiffToScint[i] = MakeH2(TString::Format("DiffToScint_%d", i),"to sum26/27", 1000, -50, 0, 150, 0, 50, "ns"); @@ -74,10 +74,10 @@ bool SecondProc::Process(base::Event* ev) hadaq::HldSubEvent *hld = dynamic_cast (ev->GetSubEvent("HLD")); // if (hld) // printf("HLD: type %u seq %u run %u\n", hld->fMsg.trig_type, -// hld->fMsg.seq_nr, hld->fMsg.run_nr); - - unsigned trigtype = hld->fMsg.trig_type; - +// hld->fMsg.seq_nr, hld->fMsg.run_nr); + + unsigned trigtype = hld->fMsg.trig_type; + double last_stamp[2000][64]; unsigned id = std::stoi(fTdcId.substr(4).c_str()); // printf("%u",id); @@ -89,44 +89,44 @@ bool SecondProc::Process(base::Event* ev) // double lead = 0; for (unsigned ihit=0;ihitSize();ihit++) { hadaq::TdcMessageExt &ext = sub->msg(ihit); - + unsigned ch = ext.msg().getHitChannel(); unsigned edge = ext.msg().getHitEdge(); - double stamp = ext.GetGlobalTime(); // here in seconds + double stamp = ext.GetGlobalTime(); // here in seconds if(edge == 1) { last_stamp[id][ch] = stamp; } - } - + } + // if(ch==26 && edge == 1) {ch26 = stamp;} // if(ch==26 && edge == 0) {tot26 = stamp-ch26;} // if(ch==25 && edge == 1) {ch25 = stamp;} -// +// // if(ch==17 && edge == 1) {ch17 = stamp;} // if(ch==17 && edge == 0) {tot17 = stamp-ch17;} -// if(ch==24 && edge == 1) {ch24 = stamp;} -// -// +// if(ch==24 && edge == 1) {ch24 = stamp;} +// +// // if(ch==26 && edge == 0 && ch25 != 0 && ch24!=0 && ch17 !=0) { -// FillH2(hSciTot[0], ((ch26-ch25))*1E9,(tot26)*1E9); -// FillH2(hSciTot[1], ((ch26+ch25)/2-(ch24+ch17)/2)*1E9,(tot26)*1E9); -// FillH2(hSciTot[2], ((ch26+ch25)/2-(ch24+ch17)/2)*1E9,(tot17)*1E9); +// FillH2(hSciTot[0], ((ch26-ch25))*1E9,(tot26)*1E9); +// FillH2(hSciTot[1], ((ch26+ch25)/2-(ch24+ch17)/2)*1E9,(tot26)*1E9); +// FillH2(hSciTot[2], ((ch26+ch25)/2-(ch24+ch17)/2)*1E9,(tot17)*1E9); // } -// -// } +// +// } // ch0tm = (ch26+ch25)/2; // ch1tm = (ch17+ch24)/2; // if (ch26 != 0 && ch25 != 0 && ch24 != 0 && ch17 != 0) { // FillH1(hScintCor,(ch0tm-ch1tm)*1E9); // } - + // if(ch1tm != 0) { // for (unsigned ihit=0;ihitSize();ihit++) { // hadaq::TdcMessageExt &ext = sub->msg(ihit); // unsigned ch = ext.msg().getHitChannel(); -// +// // if(ch >= 9 && ch <= 16) { // unsigned edge = ext.msg().getHitEdge(); // double stamp = ext.GetGlobalTime(); // here in seconds @@ -139,11 +139,11 @@ bool SecondProc::Process(base::Event* ev) // } // } // } - - - - - + + + + + for (unsigned ihit=0;ihitSize();ihit++) { hadaq::TdcMessageExt &ext = sub->msg(ihit); @@ -160,9 +160,9 @@ bool SecondProc::Process(base::Event* ev) if(ch > 1 && edge == 1) { FillH2(hPrevDiff, ch, (last_stamp[id][ch-1]-stamp)*1E9); } - + // if (ch==0) { ch0tm = stamp; } // ch0 has absolute time, all other channels relative to ch0 - + if( (stamp < 50e-9 && stamp > -10e-9) || ch == 0 || trigtype != 0xd) { if(edge == 1) { @@ -171,31 +171,31 @@ bool SecondProc::Process(base::Event* ev) FillH2(hDiff, ch, (last_stamp[0][0]-stamp)*1E9); last_stamp[id][ch] = stamp; last_stamp[0][0] = stamp; - - FillH2(hRiseRef, ch, stamp*1E9); + + FillH2(hRiseRef, ch, stamp*1E9); } - + if(edge == 0) FillH2(hFineFallCh, ch, fine); - + FillH2(hFineCh, ch, fine); - + } } - - - - + + + + // // failure, but just keep it here // // if (ch>=MAXCH) continue; -// +// // // printf("ch %u edge %u stamp %f\n", ch, edge, stamp*1e9); // if (edge==0) { // last_rising[ch] = stamp; -// +// // } // } else if (!last_rising[ch]) { // // printf(" ToT %f\n", stamp - last_rising[ch]); @@ -209,10 +209,10 @@ bool SecondProc::Process(base::Event* ev) // void second() // { -// +// // // for (auto &entry : ev->GetEventsMap()) -// // printf("Name %s Instance %p\n", entry.first.c_str(), entry.second); -// +// // printf("Name %s Instance %p\n", entry.first.c_str(), entry.second); +// // // new SecondProc("x0050", "TDC_0050"); // // new SecondProc("x0507", "TDC_0507"); // // new SecondProc("x0303", "TDC_0303"); diff --git a/scripts/dac_scan/dac_scan.pl b/scripts/dac_scan/dac_scan.pl index 29e7c4f..f3ba6a1 100755 --- a/scripts/dac_scan/dac_scan.pl +++ b/scripts/dac_scan/dac_scan.pl @@ -2,11 +2,11 @@ use warnings; use lib "../"; +use Getopt::Long; use Mimosis; use HADES::TrbNet; use Time::HiRes qw(usleep); -my $fpga = 0xa000; my %vdac = ( 3 => 0x004c, @@ -52,15 +52,42 @@ my %odac_reset = ( 6 => 0xab, ); +my $fpga; +my $m; +my $s; + +Getopt::Long::Configure(qw(gnu_getopt)); +GetOptions( + "fpga|f=s" => \$fpga, + "imagefile-only|m" => \$m, + "singleaccess|s" =>\$s, + "help|h" => \$help, +); + +if ($help) { + my $message = <<'END_MESSAGE'; +-f, --fpga HEX -> Hex address of the FPGA. Optional. Default is 0xa000. +-m, --imagefile-only -> Print only image files, don't open gnuplot terminal. +-s, --singleaccess -> Use I2C single access mode for Probestation +-h, --help -> Print this help. + +Usage: ./dac_scan.pl --fpga 0xa000 or ./dac_scan.pl +END_MESSAGE + print $message; + exit(); +} + +$fpga = defined($fpga) ? hex($fpga) : 0xa000; +$s = !defined($s) ? 0 : 1; $conv_f = ( 2 * 4096 ) / 2**16; trb_init_ports() or die trb_strerror(); trb_register_write( $fpga, 0xd680, 0x1e ); #write speed 30 to adc -my $vmon_file = "vmon_data.csv"; -my $imon_file = "imon_data.csv"; -my $other_file = "other_data.csv"; +my $vmon_file = "data/vmon_data.csv"; +my $imon_file = "data/imon_data.csv"; +my $other_file = "data/other_data.csv"; open( v_FH, '>', $vmon_file ) or die $!; @@ -69,12 +96,12 @@ for my $dac ( sort keys %vdac ) { #loop over voltage DACs printf "Scan: %x\n", $vdac{$dac}; - Mimosis::mimosis_register_write( $fpga, 0x0026, $dac ); + Mimosis::mimosis_register_write( $fpga, 0x0026, $dac, $s ); usleep(1000); for my $setv ( 0 .. 2**8 - 1 ) { #loop over settings - Mimosis::mimosis_register_write( $fpga, $vdac{$dac}, $setv ); + Mimosis::mimosis_register_write( $fpga, $vdac{$dac}, $setv, $s ); usleep(10000); Mimosis::adc_i2c_command( $fpga, 0x48, 0x01, 0xa380, 0, 0, 1 ); usleep(10000); @@ -84,7 +111,7 @@ for my $dac ( sort keys %vdac ) { #loop over voltage DACs printf( v_FH "%x\t%f\t%i\n", $vdac{$dac}, $setv, $volt_raw * $conv_f ); } - Mimosis::mimosis_register_write( $fpga, $vdac{$dac}, $vdac_reset{$dac} ); + Mimosis::mimosis_register_write( $fpga, $vdac{$dac}, $vdac_reset{$dac}, $s ); usleep(10000); @@ -101,12 +128,12 @@ for my $dac ( sort keys %idac ) { #loop over current DACs printf "Scan: %x\n", $idac{$dac}; - Mimosis::mimosis_register_write( $fpga, 0x0025, $dac ); + Mimosis::mimosis_register_write( $fpga, 0x0025, $dac, $s ); usleep(1000); for my $seti ( 0 .. 2**8 - 1 ) { #loop over settings - Mimosis::mimosis_register_write( $fpga, $idac{$dac}, $seti ); + Mimosis::mimosis_register_write( $fpga, $idac{$dac}, $seti, $s ); usleep(10000); Mimosis::adc_i2c_command( $fpga, 0x48, 0x01, 0x9380, 0, 0, 1 ); usleep(10000); @@ -116,7 +143,7 @@ for my $dac ( sort keys %idac ) { #loop over current DACs printf( i_FH "%x\t%i\t%i\n", $idac{$dac}, $seti, $curr_raw * $conv_f ); } - Mimosis::mimosis_register_write( $fpga, $idac{$dac}, $idac_reset{$dac} ); + Mimosis::mimosis_register_write( $fpga, $idac{$dac}, $idac_reset{$dac}, $s ); usleep(10000); # printf("\n\n"); @@ -132,12 +159,12 @@ for my $dac ( sort keys %odac ) { printf "Scan: %x\n", $odac{$dac}; - Mimosis::mimosis_register_write( $fpga, 0x0026, $dac ); + Mimosis::mimosis_register_write( $fpga, 0x0026, $dac, $s ); usleep(1000); for my $setv ( 0 .. 2**8 - 1 ) { #loop over settings - Mimosis::mimosis_register_write( $fpga, $odac{$dac}, $setv ); + Mimosis::mimosis_register_write( $fpga, $odac{$dac}, $setv, $s ); usleep(10000); Mimosis::adc_i2c_command( $fpga, 0x48, 0x01, 0xa380, 0, 0, 1 ); usleep(10000); @@ -147,7 +174,7 @@ for my $dac ( sort keys %odac ) { printf( o_FH "%x\t%i\t%i\n", $odac{$dac}, $setv, $volt_raw * $conv_f ); } - Mimosis::mimosis_register_write( $fpga, $odac{$dac}, $odac_reset{$dac} ); + Mimosis::mimosis_register_write( $fpga, $odac{$dac}, $odac_reset{$dac}, $s ); usleep(10000); # printf("\n\n"); @@ -156,4 +183,8 @@ for my $dac ( sort keys %odac ) { close(o_FH); -system("gnuplot -p plotdac.gp"); + +system("gnuplot -p plotdacpng.gp"); +if(!defined($m)) { + system("gnuplot -p plotdac.gp"); +} diff --git a/scripts/dac_scan/plotdac.gp b/scripts/dac_scan/plotdac.gp index 9f89b54..8fd3e28 100755 --- a/scripts/dac_scan/plotdac.gp +++ b/scripts/dac_scan/plotdac.gp @@ -1,18 +1,18 @@ -set terminal pngcairo size 1000,1000 -set output strftime('img/%F_%H-%M-%S.png', time(0)) +#set terminal pngcairo size 1000,1000 +#set output strftime('img/%F_%H-%M-%S.png', time(0)) set multiplot layout 2,2 set key Left left top box set xlabel "set." set ylabel "[mV]" array names0[7] = ["VCASP", "VCASNA", "VCASNB", "VCASNC", "VCASND", "VCASN2", "VCLIP"] -plot for [i=0:6] 'vmon_data.csv' using 2:3 index i with l title names0[i+1] +plot for [i=0:6] 'data/vmon_data.csv' using 2:3 index i with l title names0[i+1] array names1[3] = ["IBIAS", "ITHR", "IDB"] -plot for [i=0:2] 'imon_data.csv' using 2:3 index i with l title names1[i+1] +plot for [i=0:2] 'data/imon_data.csv' using 2:3 index i with l title names1[i+1] array names2[3] = ["VRESET", "VPH", "VPL"] -plot for [i=0:2] 'other_data.csv' using 2:3 index i with l title names2[i+1] -plot 'vphfine_data.csv' using 2:3 with l title "VPH\\\_FINE (VPH)" +plot for [i=0:2] 'data/other_data.csv' using 2:3 index i with l title names2[i+1] +#plot 'data/vphfine_data.csv' using 2:3 with l title "VPH\\\_FINE (VPH)" -# set terminal qt +# set terminal x11 # set output # replot diff --git a/scripts/dac_scan/plotdacpng.gp b/scripts/dac_scan/plotdacpng.gp new file mode 100755 index 0000000..4c4f19d --- /dev/null +++ b/scripts/dac_scan/plotdacpng.gp @@ -0,0 +1,15 @@ +set terminal pngcairo size 1000,1000 +set output strftime('img/%F_%H-%M-%S.png', time(0)) +set multiplot layout 2,2 +set key Left left top box +set xlabel "set." +set ylabel "[mV]" + +array names0[7] = ["VCASP", "VCASNA", "VCASNB", "VCASNC", "VCASND", "VCASN2", "VCLIP"] +plot for [i=0:6] 'data/vmon_data.csv' using 2:3 index i with l title names0[i+1] +array names1[3] = ["IBIAS", "ITHR", "IDB"] +plot for [i=0:2] 'data/imon_data.csv' using 2:3 index i with l title names1[i+1] +array names2[3] = ["VRESET", "VPH", "VPL"] +plot for [i=0:2] 'data/other_data.csv' using 2:3 index i with l title names2[i+1] +#plot 'vphfine_data.csv' using 2:3 with l title "VPH\\\_FINE (VPH)" + diff --git a/scripts/dac_scan/dac_scan_cleanroom.pl b/scripts/legacy/dac_scan_cleanroom.pl similarity index 100% rename from scripts/dac_scan/dac_scan_cleanroom.pl rename to scripts/legacy/dac_scan_cleanroom.pl