]> jspc29.x-matter.uni-frankfurt.de Git - daqtools.git/commitdiff
added gsi_rich, mt
authorHADES DAQ <hadaq@hadesp43.gsi.de>
Wed, 28 Sep 2016 13:55:07 +0000 (15:55 +0200)
committerHADES DAQ <hadaq@hadesp43.gsi.de>
Wed, 28 Sep 2016 13:55:07 +0000 (15:55 +0200)
12 files changed:
users/gsi_rich/TdcEventBuilder.xml [new file with mode: 0644]
users/gsi_rich/check_ping.pl [new file with mode: 0755]
users/gsi_rich/db/addresses_dirich.db [new file with mode: 0644]
users/gsi_rich/db/addresses_dirich_concentrator.db [new file with mode: 0644]
users/gsi_rich/db/addresses_trb3.db [new file with mode: 0644]
users/gsi_rich/db/register_configgbe.db [new file with mode: 0644]
users/gsi_rich/db/register_configgbe_ip.db [new file with mode: 0644]
users/gsi_rich/db/register_configtdc.db [new file with mode: 0644]
users/gsi_rich/first.C [new file with mode: 0644]
users/gsi_rich/second.C [new file with mode: 0644]
users/gsi_rich/startup.sh [new file with mode: 0755]
users/gsi_rich/trbreset_loop.pl [new file with mode: 0755]

diff --git a/users/gsi_rich/TdcEventBuilder.xml b/users/gsi_rich/TdcEventBuilder.xml
new file mode 100644 (file)
index 0000000..e1bd0fb
--- /dev/null
@@ -0,0 +1,154 @@
+<?xml version="1.0"?>
+
+<!-- 
+This is example file how HADAQ event building should be configured in DABC.
+Event building process implemented in Combiner module of hadaq::CombinerModule class.
+Module can have several inputs, each with separate port number for receiving data 
+from TRB boards. For every input one could configure only UDP port number - host name is ignored.
+First output of combiner module reserved for the connection to the MBS transmitter module. 
+Second output can be use to store data in hld files. 
+To enable HLD file storage one should specify NumOutputs for Combiner module
+and provide hld file name for Output1 port   
+
+     <NumOutputs value="2"/>
+     <OutputPort name="Output1" url="hld://dabc.hld?maxsize=2000"/>
+     
+File name fill be extended according to HADAQ naming convetion.       
+
+Optionally one can enable MBS transmitter module, which converts HLD to LMD format.
+To enable transmitter, one should specify auto="true" in configuration which says DABC
+to automatically create module when starting application. 
+First output of the module reserved for stream server, second output can be used to
+store data in lmd files. 
+
+By default, HTTP server is enabled. Do disable it, remove <HttpServer> section or
+put <HttpServer name="http" auto="false">. One could change http port number. 
+When dabc runs, in any browser address like
+http://your_dabc_host_name:8090 can be opened. At the moment http server provides: 
+  - ratemeters from EventBuilder and Transmitter
+  - log fields 
+  - commands to start/stop hld and lmd files from browser
+
+It is also possible to attach go4 analysis to that server, that also histograms
+from online analysis will appear. For that one should specify 
+"-dabc your_dabc_host_name" argument when starting analysis. Like:
+   [shell] go4analysis -stream dabc_node -dabc dabc_node
+When launching analysis from the gui, extra arguments "-dabc your_dabc_host_name" 
+should be specified.
+
+There is well-known problem with using VNC viewer and mbs stream server. 
+Both by default are using port 6002. One could change port number for stream server.
+Just set other number in configuration of output port of transmitter module, for instance
+       <OutputPort name="Output0" url="mbs://Stream:6789"/>
+In this case one should specify that port number when starting go4 analysis like:
+   [shell] go4analysis -stream dabc_node:6789 -dabc dabc_node:4444 
+When starting analysis from the go4 gui, one should specify stream server with port number too.
+
+-->
+
+<dabc version="2">
+  <Context host="localhost" name="EventBuilder">
+    <Run>
+      <lib value="libDabcMbs.so"/>
+      <lib value="libDabcHadaq.so"/>  
+      <lib value="libDabcHttp.so"/>  
+      <lib value="libDabcStream.so"/>  
+      <logfile value="hadaqevtbuild.log"/>
+      <loglevel value="-1"/>
+      <loglimit value="1000"/>
+      <control value="true"/>
+      <threads_layout value="balanced"/>
+    </Run>
+    
+    <HttpServer name="http" port="8091"/>
+    
+    <!-- If uncommented, all internal manager structures will be published in the web server -->
+    <!-- Publisher name="publ" manager="true"/ -->
+    
+    <!-- If uncommented, profiling will be enabled for all threads -->
+    <!-- Thread name="*" publ="true" prof="true"/ -->
+    
+    <MemoryPool name="Pool">
+       <BufferSize value="200000"/>
+       <NumBuffers value="1000"/>
+    </MemoryPool>
+    
+    <!-- these are default parameters for TDC calibration modules -->
+    <Module name="Input*TdcCal">    
+       <InputPort name="Input*" queue="30"/>
+
+       <FineMin value="31"/>
+       <FineMax value="515"/>
+       <NumChannels value="33"/>
+       <EdgeMask value="2"/> <!-- 1: only leading edge 2:leading/trailing individual 3:statistics from leading used 4:statistics merged -->
+       <HistFilling value="4"/>
+       <CalibrFile value="local"/>
+       <!--DisableCalibrationFor value="0"/-->  
+       <Auto value="100000"/>
+       
+       <!-- TRB value="0x8010"/-->
+       <!-- HUB value="0x9000"/-->
+       <!-- TDC value="[0x8a00,0x8a01,0x8a02,0x8a03]"/-->
+       <Dummy value="true"/>
+    </Module>
+    
+
+    <Module name="Combiner" class="hadaq::CombinerModule">    
+        <!-- these parameters will force to create inputs/outputs of module -->
+       <NumInputs value="4"/>
+       <NumOutputs value="2"/>
+
+       <InputPort name="Input0" url="hadaq://host:50061" urlopt1=""/>
+       <InputPort name="Input1" url="hadaq://host:50113" urlopt1=""/>
+       <InputPort name="Input2" url="hadaq://host:50084" urlopt1=""/>
+       <InputPort name="Input3" url="hadaq://host:50158" urlopt1=""/>
+
+       <InputPort name="Input4" url="hadaq://host:10104" urlopt1="trb=0x8030&tdc=[0x3030,0x3031,0x3032,0x3033]&dummy"/>
+       <InputPort name="Input5" url="hadaq://host:10105" urlopt1="trb=0x8040&tdc=[0x3040,0x3041,0x3042,0x3043]&dummy"/>
+
+       <!-- <InputPort name="Input0" url="hadaq://host:50021" urlopt1="trb=0x8000&hub=0x8100&tdc=[0xC000,0xC001,0xC003]&dummy"/> -->
+       <!-- <InputPort name="Input1" url="hadaq://host:50094" urlopt1="trb=0x8003&tdc=[0xC00C,0xC00D,0xC00E,0xC00F]&dummy"/> -->
+       <!-- <InputPort name="Input2" url="hadaq://host:50096" urlopt1="trb=0x8002&tdc=[0xC008,0xC009,0xC00A,0xC00B]&dummy"/> -->
+       <!-- <InputPort name="Input3" url="hadaq://host:10104" urlopt1="trb=0x8030&tdc=[0x3030,0x3031,0x3032,0x3033]&dummy"/> -->
+       <!-- <InputPort name="Input4" url="hadaq://host:10105" urlopt1="trb=0x8040&tdc=[0x3040,0x3041,0x3042,0x3043]&dummy"/> -->
+
+       <InputPort name="Input*" queue="30" urlopt="udpbuf=2000000&mtu=64512&flush=2.0&observer=false&debug&resort"/>
+
+       <ExtraDebug value="false"/>
+
+       <!--  this is stream server for online monitoring, normally always on -->
+       <OutputPort name="Output0" url="mbs://Stream:6789?iter=hadaq_iter&subid=0x1f"/>
+
+       <!--  this is example of HLD file storage - local and RFIO -->
+       <OutputPort name="Output1" url="hld:///d/trashcan/pulser.hld?maxsize=2000"/>
+       <!--OutputPort name="Output1" url="hld:///linev/path/dabc.hld?maxsize=1900&rfio"/-->
+
+       <DoShmControl value="false"/>  
+       <FlushTimeout value="2.0"/>   
+
+       <!-- take event sequence number from vulom/roc sync message at cts -->
+       <UseSyncSequenceNumber value="false"/>
+       <SyncSubeventId value="0x8000"/>
+       <SyncTriggerMask value="0x01"/>
+       <PrintSync value="false"/>
+       <FlushBySync value="false"/>
+       
+       <!--TriggerNumRange: defines when trigger sequence number wraps. only 16 bit for HADES EBs, 24 bit for trb3!  -->
+       <TriggerNumRange value="0x10000"/>
+       
+       <!--AccountLostEventDiff: if true, missing trigger sequence number are added as lost events to stats. Disabled for multiple event builder mode!  -->
+       <AccountLostEventDiff value="true"/>
+       
+       <!-- rate meters configuration -->
+       <HadaqData width="4" prec="2" low="0" up="10" debug="1"/>
+       <HadaqEvents width="5" prec="1" low="0" up="1000" debug="1"/>
+       <HadaqDroppedData width="5" prec="3" low="0" up="1" debug="1"/>
+       <HadaqLostEvents width="4" prec="2" low="0" up="100" debug="1"/>
+     </Module>
+     
+     <!--  Uncomment to see terminal output like old event builder -->
+     <Module name="Term" class="hadaq::TerminalModule" period="0.3" clear="false"/>
+
+  </Context>
+
+</dabc>
diff --git a/users/gsi_rich/check_ping.pl b/users/gsi_rich/check_ping.pl
new file mode 100755 (executable)
index 0000000..ff146b6
--- /dev/null
@@ -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 (file)
index 0000000..6613a19
--- /dev/null
@@ -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 (file)
index 0000000..f95bf2b
--- /dev/null
@@ -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 (file)
index 0000000..a480b5f
--- /dev/null
@@ -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 (file)
index 0000000..ff87483
--- /dev/null
@@ -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 (file)
index 0000000..93d22ed
--- /dev/null
@@ -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 (file)
index 0000000..a5655d7
--- /dev/null
@@ -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 (file)
index 0000000..d805e1d
--- /dev/null
@@ -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<hadaq::TdcMessageExt> - includes original TDC message
+   // 2 - std::vector<hadaq::MessageFloat>  - compact form, without channel 0, stamp as float (relative to ch0)
+   // 3 - std::vector<hadaq::MessageDouble> - compact form, with channel 0, absolute time stamp as double
+   base::ProcMgr::instance()->SetStoreKind(2);
+
+
+   // when configured as output in DABC, one specifies:
+   // <OutputPort name="Output2" url="stream://file.root?maxsize=5000&kind=3"/>
+
+
+}
+
+// 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;k<hld->NumberOfTRB();k++) {
+      hadaq::TrbProcessor* trb = hld->GetTRB(k);
+      if (trb==0) continue;
+      printf("Configure %s!\n", trb->GetName());
+      trb->SetPrintErrors(100);
+   }
+
+   for (unsigned k=0;k<hld->NumberOfTDC();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;nch<tdc->NumChannels();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 (file)
index 0000000..71fdcc5
--- /dev/null
@@ -0,0 +1,118 @@
+#include <stdio.h>
+
+// #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<hadaq::TdcSubEventFloat*> (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;cnt<sub->Size();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 (executable)
index 0000000..ef5c93a
--- /dev/null
@@ -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 (executable)
index 0000000..82b7efe
--- /dev/null
@@ -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);
+}