From: HADES DAQ Date: Wed, 28 Sep 2016 13:55:07 +0000 (+0200) Subject: added gsi_rich, mt X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=02a7f7abeecb79edf1b61c106a0911b9ce1171b8;p=daqtools.git added gsi_rich, mt --- diff --git a/users/gsi_rich/TdcEventBuilder.xml b/users/gsi_rich/TdcEventBuilder.xml new file mode 100644 index 0000000..e1bd0fb --- /dev/null +++ b/users/gsi_rich/TdcEventBuilder.xml @@ -0,0 +1,154 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/users/gsi_rich/check_ping.pl b/users/gsi_rich/check_ping.pl new file mode 100755 index 0000000..ff146b6 --- /dev/null +++ b/users/gsi_rich/check_ping.pl @@ -0,0 +1,230 @@ +#!/usr/bin/perl + +use warnings; +use strict; +use Parallel::ForkManager; +use Net::Ping; +use Getopt::Long; +use Data::Dumper; + +my $power; +my $reboot; +my $help; + +my $result = GetOptions ( + "h|help" => \$help, + "p|powercycle" => \$power, + "r|reboot" => \$reboot + ); + + +my $map = { + 0 => { trb => 84, addr => "0xc001", sys => "CTS"}, + 1 => { trb => 61, addr => "0x8000", sys => "TOF"}, + 2 => { trb => 113, addr => "0x8001", sys => "TOF"}, + 3 => { trb => 158, addr => "0x8002", sys => "TOF"}, + +}; +my $MAX_PROCESSES=50; +my $pm = Parallel::ForkManager->new($MAX_PROCESSES); +my $maximal_reboot_counter = 4; +my $number_of_reboots_done = 0; + +my $rh_unsuccessful = {}; + +$pm->run_on_finish( + sub { my ($pid, $exit_code, $ident, $exit_signal, $core_dump, $data_structure_reference) = @_; + #print "** $ident just got out of the pool ". + # "with PID $pid and exit code: $exit_code\n"; + #print Dumper ($pid, $exit_code, $ident, $exit_signal, $core_dump, $data_structure_reference); + if ($exit_code == 0) { + $rh_unsuccessful->{$ident} = $$data_structure_reference; + } + } + ); + +#my $p = Net::Ping->new(); + +my $first_iteration = 1; + +#print Dumper keys %$rh_unsuccessful; + +while ( (($first_iteration == 1) || keys %$rh_unsuccessful) && + ($number_of_reboots_done < $maximal_reboot_counter) ) { + #print Dumper $rh_unsuccessful; + #print Dumper keys %$rh_unsuccessful; + + $rh_unsuccessful = {}; + $first_iteration = 0; + foreach my $ct (keys %$map) { + my $success = 0; + #my $num = sprintf "%3.3d", $ct; + my $trbnum= $map->{$ct}->{trb}; + my $num = sprintf "%3.3d", $trbnum; + my $host= "trb" . $num; + #my $host= "trb" . $num ."b"; + my $system = $map->{$ct}->{sys}; + #print "192.168.0.$ct $host.gsi.de $host\n"; + #my $r = $p->ping($host,1); + my $c= "ping -W1 -c2 $host"; + + # my $sysnum = sprintf "0x80%.2x", $ct; + my $sysnum = $map->{$ct}->{addr}; + #$sysnum = "0x7999" if $ct == -1; + + my $pid = $pm->start("$sysnum") and next; + + #my $p = Net::Ping->new("udp", 1); + #my $r = $p->ping("192.168.0.56"); + #$p->close(); + #print "result: $r\n"; + + my $r = qx($c); + #printf "$sysnum, system: %-8s, trb: $host ", $system; + printf "$sysnum $host %-8s ", $system; + if (grep /64 bytes/, $r) { + print "is alive.\n"; + $success = $trbnum; + } else { + print "is not alive.\n"; + } + + my $str = "jhhj"; + $pm->finish($success, \$host); # Terminates the child process + } + + $pm->wait_all_children; + + #$rh_unsuccessful = { "0x8007"=>"hh", "0x8001"=>"jjhj"} ; + + if ($reboot && ($number_of_reboots_done < $maximal_reboot_counter) && keys %$rh_unsuccessful) { + #print Dumper $rh_unsuccessful; + print "have to reboot FPGAs, first make a reset and reassign the addresses.\n"; + my $cmd = "trbcmd reset; sleep 2; merge_serial_address.pl ~/trbsoft/daqtools/base/serials_trb3.db ~/trbsoft/userscript/db/addresses_trb3.db"; + qx($cmd); + sleep 3; + # test trbnet: + my $error_str = "ERROR: read_uid failed: Termination Status Error"; + $cmd = "trbcmd i 0xffff 2>&1"; + my $r = qx($cmd); + if ($r=~/$error_str/) { + print "could not access trbnet, so have to reboot all FPGAs.\n"; + $rh_unsuccessful = { "0xffff"=>"all"} ; + } + + my $ctsnum = $map->{0}->{addr}; + if ($rh_unsuccessful->{ $ctsnum } || (scalar keys %$rh_unsuccessful) > 5) { + print "many TRBs (or CTS: ". $ctsnum . ") are not alive, so let us make a reload of all FPGAs.\n"; + $rh_unsuccessful = { "0xffff"=>"all"} ; + } + + foreach my $cur (keys %$rh_unsuccessful) { + my $host = $rh_unsuccessful->{$cur}; + #my $cmd = "trbcmd reload " . $cur; + $cmd = "trbcmd reload $cur"; + print "rebooting: $cur\n"; + #print "$cmd\n"; + qx($cmd); + #print "number of reboots done: $number_of_reboots_done\n"; + } + print "wait 9 seconds\n"; + sleep 9; + $number_of_reboots_done++; + } + + + +} + +exit 1 if(scalar keys %$rh_unsuccessful > 0); + +#$p->close(); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +# #!/usr/bin/perl + +# use warnings; +# use strict; +# use Parallel::ForkManager; +# use Net::Ping; +# use Data::Dumper; + +# my @trbs = (21, 94, 96); + +# my $map = { +# 1 => { trb => 94, addr => 0x8940, sys => "TDC lnr"}, +# 2 => { trb => 96, addr => 0x8960, sys => "TDC orig"}, +# 0 => { trb => 21, addr => 0xc210, sys => "CTS"}, +# }; + + +# my $MAX_PROCESSES=50; +# my $pm = Parallel::ForkManager->new($MAX_PROCESSES); + +# #my $p = Net::Ping->new(); + +# #print Dumper keys %$map; +# #exit; +# foreach my $ct (keys %$map) { +# #my $num = sprintf "%3.3d", $ct; +# my $trbnum= $map->{$ct}->{trb}; +# my $num = sprintf "%3.3d", $trbnum; +# my $host= "trb" . $num; +# my $system = $map->{$ct}->{sys}; +# #print "192.168.0.$ct $host.gsi.de $host\n"; +# #my $r = $p->ping($host,1); +# my $c= "ping -W1 -c1 $host"; + +# my $pid = $pm->start and next; + + +# #my $p = Net::Ping->new("udp", 1); +# #my $r = $p->ping("192.168.0.56"); +# #$p->close(); +# #print "result: $r\n"; + +# my $r = qx($c); +# my $sysnum = sprintf ("0x%x", $map->{$ct}->{addr}); +# $sysnum = "0x7999" if $ct == -1; +# #printf "$sysnum, system: %-8s, trb: $host ", $system; +# printf "$sysnum $host %-8s ", $system; +# if (grep /64 bytes/, $r) { +# print "is alive.\n"; +# } +# else { +# print "is not alive.\n"; +# } + +# $pm->finish; # Terminates the child process +# } + +# $pm->wait_all_children; +# #$p->close(); diff --git a/users/gsi_rich/db/addresses_dirich.db b/users/gsi_rich/db/addresses_dirich.db new file mode 100644 index 0000000..6613a19 --- /dev/null +++ b/users/gsi_rich/db/addresses_dirich.db @@ -0,0 +1,14 @@ +# addresses_dirich.db +# maps trbnet-addresses to serial number + FPGA number + +# Address # S/N # FPGA + +0x1201 0001 1 +0x1202 0002 1 +0x1203 0003 1 +0x1204 0004 1 +0x1205 0005 1 +0x1206 0006 1 +0x1207 0007 1 +0x1208 0008 1 + diff --git a/users/gsi_rich/db/addresses_dirich_concentrator.db b/users/gsi_rich/db/addresses_dirich_concentrator.db new file mode 100644 index 0000000..f95bf2b --- /dev/null +++ b/users/gsi_rich/db/addresses_dirich_concentrator.db @@ -0,0 +1,4 @@ + +# concentrator/combiner +0x8300 0001 0 +0x8300 0002 0 diff --git a/users/gsi_rich/db/addresses_trb3.db b/users/gsi_rich/db/addresses_trb3.db new file mode 100644 index 0000000..a480b5f --- /dev/null +++ b/users/gsi_rich/db/addresses_trb3.db @@ -0,0 +1,34 @@ +# addresses.db +# maps trbnet-addresses to serial number + FPGA numbers + +# Address # S/N # FPGA +# 0x1234 14 0 +#CTS + +0x0840 84 0 +0x8841 84 1 # hub +0x0842 84 2 +0x0843 84 3 +0xc001 84 5 + +#slave +0x0610 61 0 +0x0611 61 1 +0x0612 61 2 +0x0613 61 3 +0x8610 61 5 + +#slave +0x1130 113 0 +0x1131 113 1 +0x1132 113 2 +0x1133 113 3 +0x8113 113 5 + +#slave +0x1580 158 0 +0x1581 158 1 +0x1582 158 2 +0x1583 158 3 +0x8158 158 5 + diff --git a/users/gsi_rich/db/register_configgbe.db b/users/gsi_rich/db/register_configgbe.db new file mode 100644 index 0000000..ff87483 --- /dev/null +++ b/users/gsi_rich/db/register_configgbe.db @@ -0,0 +1,15 @@ +!Register table +# Type # C0 # C1 # C2 # C3 # C4 # C5 # C6 # C7 # C8 # C9 # C10 +########################################################################################################### + 0 0x8300 0x8301 0x8302 0x8303 0x8304 0x8305 0x8306 0x8307 0x8308 0x830b 0x830d + + +!Value table +# Enable +# SubEvtId SubEvtDec QueDec PackSize FrameSize UseGbE UseTrbNet MultiQueue Trig. Num. MinEvtSize Readout Bit +# Hub # Type # C0 # C1 # C2 # C3 # C4 # C5 # C6 # C7 # C8 # C9 # C10 # +################################################################################################################################################################# + 0xc001 0 0xc001 0x00020001 0x00030062 0xEA60 0x578 1 0 1 0xffffff 0x7 0x1 + 0x8610 0 0x8000 0x00020001 0x00030062 0xEA60 0x578 1 0 1 0xffffff 0x7 0x1 + 0x8113 0 0x8001 0x00020001 0x00030062 0xEA60 0x578 1 0 1 0xffffff 0x7 0x1 + 0x8158 0 0x8002 0x00020001 0x00030062 0xEA60 0x578 1 0 1 0xffffff 0x7 0x1 diff --git a/users/gsi_rich/db/register_configgbe_ip.db b/users/gsi_rich/db/register_configgbe_ip.db new file mode 100644 index 0000000..93d22ed --- /dev/null +++ b/users/gsi_rich/db/register_configgbe_ip.db @@ -0,0 +1,39 @@ +########################################################################################### +#Eventbuilders: +# EB 0: kp1pc105 eth1 00:1B:21:43:97:EA 192.168.0.2 ports 50000 - 50099 + +!Register table +# Type # C0 # C1 # C2 # C3 # C4 # C5 # C6 # C7 # C8 # +########################################################################################### +#new memory locations + 0 0x8100 0x8101 0x8102 0x8103 0x8104 0x8105 0x8106 0x8107 0x8108 + 1 0x8110 0x8111 0x8112 0x8113 0x8114 0x8115 0x8116 0x8117 0x8118 + 2 0x8120 0x8121 0x8122 0x8123 0x8124 0x8125 0x8126 0x8127 0x8128 + 3 0x8130 0x8131 0x8132 0x8133 0x8134 0x8135 0x8136 0x8137 0x8138 + 4 0x8140 0x8141 0x8142 0x8143 0x8144 0x8145 0x8146 0x8147 0x8148 + 5 0x8150 0x8151 0x8152 0x8153 0x8154 0x8155 0x8156 0x8157 0x8158 + 6 0x8160 0x8161 0x8162 0x8163 0x8164 0x8165 0x8166 0x8167 0x8168 + 7 0x8170 0x8171 0x8172 0x8173 0x8174 0x8175 0x8176 0x8177 0x8178 + 8 0x8180 0x8181 0x8182 0x8183 0x8184 0x8185 0x8186 0x8187 0x8188 + 9 0x8190 0x8191 0x8192 0x8193 0x8194 0x8195 0x8196 0x8197 0x8198 + 10 0x81A0 0x81A1 0x81A2 0x81A3 0x81A4 0x81A5 0x81A6 0x81A7 0x81A8 + 11 0x81B0 0x81B1 0x81B2 0x81B3 0x81B4 0x81B5 0x81B6 0x81B7 0x81B8 + 12 0x81C0 0x81C1 0x81C2 0x81C3 0x81C4 0x81C5 0x81C6 0x81C7 0x81C8 + 13 0x81D0 0x81D1 0x81D2 0x81D3 0x81D4 0x81D5 0x81D6 0x81D7 0x81D8 + 14 0x81E0 0x81E1 0x81E2 0x81E3 0x81E4 0x81E5 0x81E6 0x81E7 0x81E8 + 15 0x81F0 0x81F1 0x81F2 0x81F3 0x81F4 0x81F5 0x81F6 0x81F7 0x81F8 + +!Value table +# Dest MAC Dest MAC Dest IP Dest Port Src MAC Src MAC Src IP Src Port Packet Size +# Hub # Type # C0 # C1 # C2 # C3 # C4 # C5 # C6 # C7 # C8 # +######################################################################################################################################## + +# kp1pc105 +#0xc001 0 0x214397EA 0x001b 0xc0a80002 0xc3a4 0xDEADc000 0x001B 0xc0a80154 0xc350 0x0578 +#0x8000 0 0x214397EA 0x001b 0xc0a80002 0xc38d 0xDEADc000 0x001c 0xc0a80155 0xc350 0x0578 + +#14:dd:a9:d3:f4:b8 # hadesp39 + 0xc001 0 0xa9d3f4b8 0x14dd 0xc0a800b1 0xc3a4 0xDEADc000 0x001B 0xc0a80154 0xc350 0x0578 + 0x8610 0 0xa9d3f4b8 0x14dd 0xc0a800b1 0xc38d 0xDEADc001 0x001d 0xc0a80155 0xc350 0x0578 + 0x8113 0 0xa9d3f4b8 0x14dd 0xc0a800b1 0xc3c1 0xDEADc002 0x001d 0xc0a80156 0xc350 0x0578 + 0x8158 0 0xa9d3f4b8 0x14dd 0xc0a800b1 0xc3ee 0xDEADc003 0x001d 0xc0a80157 0xc350 0x0578 diff --git a/users/gsi_rich/db/register_configtdc.db b/users/gsi_rich/db/register_configtdc.db new file mode 100644 index 0000000..a5655d7 --- /dev/null +++ b/users/gsi_rich/db/register_configtdc.db @@ -0,0 +1,27 @@ +# TDC config registers + +!Register table +# Type # C0 # C1 # C2 # C3 # C4 # C5 # +################################################################ + 0 0xc800 0xc801 0xc802 0xc803 0xc804 0xc805 + +!Value table +# Gnl Conf Trg Window Ch En 1-32 Ch En 33-64 RingBufSize Invert +# TDC # Type # C0 # C1 # C2 # C3 # C4 # C5 # +################################################################################################# + +#0xfe48 0 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 +#0xfe4a 0 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 # gpin addon +0xfe4c 0 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 # padiwa addon +#0xfe4e 0 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 # ADA addon +#0xfe50 0 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 # cbmtof +#0xfe62 0 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 # trb3sc +0xfe51 0 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 # dirich + +#0xfe48 0 0x50003000 0x80640064 0x00000000 0x00000000 0x0000007c 0x00000000 +#0xfe4a 0 0x50003000 0x80640064 0x00000000 0x00000000 0x0000007c 0x00000000 # gpin addon +0xfe4c 0 0x50003000 0x80640064 0x00000000 0x00000000 0x0000007c 0x00000000 # padiwa addon +#0xfe4e 0 0x50003000 0x80640064 0x00000000 0x00000000 0x0000007c 0x00000000 # ADA addon +#0xfe50 0 0x50003000 0x80640064 0x00000000 0x00000000 0x0000007c 0x00000000 # cbmtof +#0xfe62 0 0x50003000 0x80640064 0x00000000 0x00000000 0x0000007c 0x00000000 # trb3sc +0xfe51 0 0x50003000 0x00640064 0x00000000 0x00000000 0x00000078 0x00000000 # dirich diff --git a/users/gsi_rich/first.C b/users/gsi_rich/first.C new file mode 100644 index 0000000..d805e1d --- /dev/null +++ b/users/gsi_rich/first.C @@ -0,0 +1,110 @@ +// this is example for + + +void first() +{ + //base::ProcMgr::instance()->SetRawAnalysis(true); + base::ProcMgr::instance()->SetTriggeredAnalysis(true); + + // all new instances get this value + base::ProcMgr::instance()->SetHistFilling(4); + + // configure bubbles + hadaq::TdcProcessor::SetBubbleMode(3, 18); + + // this limits used for liner calibrations when nothing else is available + hadaq::TdcMessage::SetFineLimits(31, 491); + + // default channel numbers and edges mask + hadaq::TrbProcessor::SetDefaults(5, 1); + + // [min..max] range for TDC ids + hadaq::TrbProcessor::SetTDCRange(0x1200, 0x12FF); + + // [min..max] range for HUB ids + hadaq::TrbProcessor::SetHUBRange(0x8000, 0x8fff); + + // when first argument true - TRB/TDC will be created on-the-fly + // second parameter is function name, called after elements are created + hadaq::HldProcessor* hld = new hadaq::HldProcessor(true, "after_create"); + + const char* calname = getenv("CALNAME"); + if ((calname==0) || (*calname==0)) calname = "test_"; + const char* calmode = getenv("CALMODE"); + int cnt = (calmode && *calmode) ? atoi(calmode) : 10000; + cnt=100000; + const char* caltrig = getenv("CALTRIG"); + unsigned trig = (caltrig && *caltrig) ? atoi(caltrig) : 0x1; + const char* uset = getenv("USETEMP"); + unsigned use_temp = 0; // 0x80000000; + if ((uset!=0) && (*uset!=0) && (strcmp(uset,"1")==0)) use_temp = 0x80000000; + + printf("TDC CALIBRATION MODE %d\n", cnt); + + //printf("HLD configure calibration calfile:%s cnt:%d trig:%X temp:%X\n", calname, cnt, trig, use_temp); + + // first parameter if filename prefix for calibration files + // and calibration mode (empty string - no file I/O) + // second parameter is hits count for autocalibration + // 0 - only load calibration + // -1 - accumulate data and store calibrations only at the end + // >0 - automatic calibration after N hits in each active channel + // third parameter is trigger type mask used for calibration + // (1 << 0xD) - special 0XD trigger with internal pulser, used also for TOT calibration + // 0x3FFF - all kinds of trigger types will be used for calibration (excluding 0xE and 0xF) + // 0x80000000 in mask enables usage of temperature correction + hld->ConfigureCalibration(calname, cnt, (1 << trig) | use_temp); + + // only accept trigger type 0x1 when storing file + // new hadaq::HldFilter(0x1); + + // create ROOT file store + base::ProcMgr::instance()->CreateStore("td.root"); + + // 0 - disable store + // 1 - std::vector - includes original TDC message + // 2 - std::vector - compact form, without channel 0, stamp as float (relative to ch0) + // 3 - std::vector - compact form, with channel 0, absolute time stamp as double + base::ProcMgr::instance()->SetStoreKind(2); + + + // when configured as output in DABC, one specifies: + // + + +} + +// extern "C" required by DABC to find function from compiled code + +extern "C" void after_create(hadaq::HldProcessor* hld) +{ + printf("Called after all sub-components are created\n"); + + if (hld==0) return; + + for (unsigned k=0;kNumberOfTRB();k++) { + hadaq::TrbProcessor* trb = hld->GetTRB(k); + if (trb==0) continue; + printf("Configure %s!\n", trb->GetName()); + trb->SetPrintErrors(100); + } + + for (unsigned k=0;kNumberOfTDC();k++) { + hadaq::TdcProcessor* tdc = hld->GetTDC(k); + if (tdc==0) continue; + + printf("Configure %s!\n", tdc->GetName()); + + // tdc->SetUseLastHit(true); + + // tdc->SetStoreEnabled(); + for (unsigned nch=2;nchNumChannels();nch++) + tdc->SetRefChannel(nch, nch-2, 0xffff, 20000, -10., 10.); + + tdc->SetRefChannel(1, tdc->NumChannels() -1 , 0xffff, 20000, -10., 10.); + + + } +} + + diff --git a/users/gsi_rich/second.C b/users/gsi_rich/second.C new file mode 100644 index 0000000..71fdcc5 --- /dev/null +++ b/users/gsi_rich/second.C @@ -0,0 +1,118 @@ +#include + +// #include "TTree.h" + +#include "base/EventProc.h" +#include "base/Event.h" +#include "hadaq/TdcSubEvent.h" + +class SecondProc : public base::EventProc { + protected: + + std::string fTdcId; //!< tdc id where channels will be selected + + double fHits[33][2]; //!< 33 channel, abstract hits, two dges + + base::H1handle hNumHits; //!< histogram with hits number + base::H1handle hDif1; //!< histogram with hits number + base::H1handle hDif2; //!< histogram with hits number + base::H2handle hUser; //!< user-defined 2D histogram + + public: + SecondProc(const char* procname, const char* _tdcid) : + base::EventProc(procname), + fTdcId(_tdcid), + hUser(0) + { + printf("Create %s for %s\n", GetName(), fTdcId.c_str()); + + hNumHits = MakeH1("NumHits","Num hits", 100, 0, 100, "number"); + + /* + hDif1 = MakeH1("ToT1","ToT of channel 17 (18)", 1000, 0.5, 3.0, "ns"); + hDif2 = MakeH1("LED_diff1","LED diff channel 17 - 21", 1000, -2., -1., "ns"); + hUser = MakeH2("ToT_vs_LED","ToT versus LED difference", 500, -4, 0, 500, -2, -1, "ToT/ns;LED diff/ns"); + */ + + hDif1 = MakeH1("LE1","1 vs. 2", 30000, -90, 90, "ns"); + hDif2 = MakeH1("TE2","1 vs. 2", 30000, -90, 90, "ns"); + + + /* + hDif1 = MakeH1("ToT1","ToT of channel 9", 1000, 32, 40, "ns"); + hDif2 = MakeH1("LED_diff1","LED diff channel 9 - 11", 1000, -3, -1, "ns"); + hUser = MakeH2("ToT_vs_LED","ToT versus LED difference", 500, 32, 40, 500, -4, -0, "ToT/ns;LED diff/ns"); + */ + + // enable storing already in constructor + // SetStoreEnabled(); + } + + virtual void CreateBranch(TTree* t) + { + // only called when tree is created in first.C + // one can ignore + // t->Branch(GetName(), fHits, "hits[8]/D"); + } + + unsigned eventnumber = 0; + virtual bool Process(base::Event* ev) + { + for (unsigned n=0;n<33;n++) { + fHits[n][0] = 0.; + fHits[n][1] = 0.; + } + + eventnumber++; + hadaq::TdcSubEventFloat* sub = + dynamic_cast (ev->GetSubEvent(fTdcId)); + + //printf("%s process sub %p %s\n", GetName(), sub, fTdcId.c_str()); + + // when return false, event processing is cancelled + if (sub==0) return true; + + double num(0); + + for (unsigned cnt=0;cntSize();cnt++) { + const hadaq::MessageFloat& msg = sub->msg(cnt); + + unsigned chid = msg.getCh(); + unsigned edge = msg.getEdge(); // 0 - rising, 1 - falling + // if (chid==0) { ch0tm = ext.GetGlobalTime(); continue; } + + // time relative ch0 + double tm = msg.stamp; + + if (chid<33) fHits[chid][edge] = tm; + + //printf(" ch:%3d tm:%f, edge:%d\n", chid, tm, edge); + num+=1; + } + + //printf("tot(%d): %f %f\n", eventnumber, (fHits[9][0] - fHits[9][1]), (fHits[11][0] - fHits[11][1])); + //printf("led(%d): %f %f\n", eventnumber, (fHits[9][0] - fHits[11][0]), (fHits[9][1] - fHits[11][1])); + + FillH1(hNumHits, num); + + /* + FillH1(hDif1, (fHits[9][1] - fHits[9][0]) ); + FillH1(hDif2, (fHits[9][0] - fHits[11][0]) ); + FillH2(hUser, (fHits[9][1] - fHits[9][0]) , (fHits[9][0] - fHits[11][0]) ); + */ + + + FillH1(hDif1, (fHits[1][0] - fHits[2][0]) ); + FillH1(hDif2, (fHits[1][1] - fHits[2][1]) ); + + return true; + } +}; + + +void second() +{ + //new SecondProc("A", "TDC_1133"); + //new SecondProc("A", "TDC_1580"); + new SecondProc("A", "TDC_1207"); +} diff --git a/users/gsi_rich/startup.sh b/users/gsi_rich/startup.sh new file mode 100755 index 0000000..ef5c93a --- /dev/null +++ b/users/gsi_rich/startup.sh @@ -0,0 +1,116 @@ +#!/bin/bash + +DAQ_TOOLS_PATH=~/trbsoft/daqtools +USER_DIR=~/trbsoft/daqtools/users/gsi_ee_trb84 +TRB_WEB_DIR=$DAQ_TOOLS_PATH/web + +export PATH=$PATH:$DAQ_TOOLS_PATH +export PATH=$PATH:$DAQ_TOOLS_PATH/tools +export PATH=$PATH:$USER_DIR + +export TRB3_SERVER=trb084:26000 +export TRBNETDPID=$(pgrep -f "trbnetd -i 84") +#export DAQOPSERVER=hadeb05:84 +export DAQOPSERVER=hades39:84 + +echo "- trbnetd pid: $TRBNETDPID" + +if [[ -z "$TRBNETDPID" ]] +then + ~/trbsoft/trbnettools/bin/trbnetd -i 84 +fi + +./check_ping.pl --reboot + + +echo "reset" +./trbreset_loop.pl +sleep 1; + +################################################## +## Set addresses +################################################## +merge_serial_address.pl $DAQ_TOOLS_PATH/base/serials_trb3.db $USER_DIR/db/addresses_trb3.db +merge_serial_address.pl $DAQ_TOOLS_PATH/base/serials_dirich.db $USER_DIR/db/addresses_dirich.db +merge_serial_address.pl $DAQ_TOOLS_PATH/base/serials_dirich_concentrator.db $USER_DIR/db/addresses_dirich_concentrator.db + + +#echo "disable port 6 on hub 0x8841" +#trbcmd clearbit 0x8841 0xc0 0x40 +#trbcmd clearbit 0x8841 0xc1 0x40 +#trbcmd clearbit 0x8841 0xc3 0x40 + + +echo "GbE settings" +loadregisterdb.pl db/register_configgbe.db +loadregisterdb.pl db/register_configgbe_ip.db + +echo "TDC settings" +loadregisterdb.pl db/register_configtdc.db +echo "TDC settings end" + +# setup central FPGA - enable peripherial signals +#switchport.pl 0x8841 6 off + + + + + + +# pulser to 100kHz and 50kHz +#trbcmd w 0xc840 0xa156 0x0000270f #10khz pulser 0 + +#trbcmd w 0xc840 0xa150 0x000003e7 #100khz +#trbcmd w 0xc840 0xa150 0x0001869f #1khz +#trbcmd w 0xc840 0xa150 0x00001387 #20khz +#trbcmd w 0xc840 0xa150 0x00000d04 #30khz +#trbcmd w 0xc840 0xa150 0x000007cf #50khz +#trbcmd w 0xc840 0xa157 0x0000270f #10khz + +#trbcmd setbit 0xc840 0xa101 0x2 #enable pulser 0 +#trbcmd setbit 0xc840 0xa101 0x2 #enable pulser 1 +#trbcmd setbit 0xc840 0xa101 0x20 #enable Addon Multiplexer 1 +#trbcmd setbit 0xc840 0xa101 0x8 #enable CTS Addon 0 +#trbcmd setbit 0xc840 0xa101 0x200 #enable periph fpga input as trigger + + +# trigger on TDC channel 1 +#trbcmd setbit 0x0810 0xcf00 0x1 #direct TDC input to CTS +#trbcmd setbit 0xc001 0xa14d 0x2 #select F5_COMM input +#trbcmd setbit 0xc840 0xa101 0x200 #enable input at CTS + +# set correct timeout: off for channel 0, 1, 2sec for 2 +trbcmd w 0xfffe 0xc5 0x50ff + +#Dirich-Concentrator: enable reference time from RJ45 +trbcmd loadbit 0x8300 0xd580 0x6 0x6 + +echo "pulser" +# pulser #0 to 10 kHz +trbcmd w 0xc001 0xa150 0x0000270f +#trbcmd w 0xc001 0xa150 0x0022270f + +echo "trigger type" +# set trigger type to 0x1 +trbcmd setbit 0xc001 0xa155 0x10 + +echo "pulser enable" +# pulser enable +#trbcmd setbit 0xc001 0xa101 0x1 + +#trbcmd clearbit 0x1130 0xc801 0x80000000 # disable window +#trbcmd w 0x1130 0xc802 0xffff0000 # enable upper 16 channels for padiwa +#trbcmd w 0x1580 0xc802 0xffffffff # enable upper 16 channels for padiwa + + +cd ~/trbsoft/daqtools/xml-db +./put.pl Readout 0xfe51 SetMaxEventSize 500 +cd $USER_DIR + +trbcmd w 0xfe51 0xdf80 0xffffffff # enable monitor counters + +trbcmd w 0x1133 0xc804 0x7c # max number of words +trbcmd clearbit 0x1133 0xc801 0x80000000 # disable window +trbcmd w 0x1133 0xc802 0x00000c03 # enable pulser + +#trbcmd setbit 0xc001 0xa101 0x8 # enable external trigger in of CTS diff --git a/users/gsi_rich/trbreset_loop.pl b/users/gsi_rich/trbreset_loop.pl new file mode 100755 index 0000000..82b7efe --- /dev/null +++ b/users/gsi_rich/trbreset_loop.pl @@ -0,0 +1,29 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +### Change THIS! +my $required_endpoints = 20; + + + +my $max_counter = 10; +my $counter = 0; +my $number = 0; + + +#js while (($number != 65) || ($counter > $max_counter)) { +while (($number < $required_endpoints) || ($counter > $max_counter)) { + my $c; my $res; + + $counter++; + $c= "trbcmd reset"; + $res = qx($c); + + $c = "trbcmd i 0xffff | wc -l"; + $res = qx($c), + print "- number of trb endpoints in the system: $res"; + ($number) = $res =~ /(\d+)/; + print "number of enpoints is not equal to the required enpoints $required_endpoints, so try next reset!\n" if ($number !=$required_endpoints); +}