0xc003 130 3
0x8000 130 5
+0xc000 131 0
+0xc001 131 1
+0xc002 131 2
+0xc003 131 3
+0x8000 131 5
+
+0xc000 132 0
+0xc001 132 1
+0xc002 132 2
+0xc003 132 3
+0x8000 132 5
+
+0xc000 133 0
+0xc001 133 1
+0xc002 133 2
+0xc003 133 3
+0x8000 133 5
+
+0xc000 134 0
+0xc001 134 1
+0xc002 134 2
+0xc003 134 3
+0x8000 134 5
+
+0xc000 135 0
+0xc001 135 1
+0xc002 135 2
+0xc003 135 3
+0x8000 135 5
+
+0xc000 136 0
+0xc001 136 1
+0xc002 136 2
+0xc003 136 3
+0x8000 136 5
+
+0xc000 137 0
+0xc001 137 1
+0xc002 137 2
+0xc003 137 3
+0x8000 137 5
+
+0xc000 138 0
+0xc001 138 1
+0xc002 138 2
+0xc003 138 3
+0x8000 138 5
+
+0xc000 139 0
+0xc001 139 1
+0xc002 139 2
+0xc003 139 3
+0x8000 139 5
+
+0xc000 140 0
+0xc001 140 1
+0xc002 140 2
+0xc003 140 3
+0x8000 140 5
+
+0xc000 141 0
+0xc001 141 1
+0xc002 141 2
+0xc003 141 3
+0x8000 141 5
+
+0xc000 142 0
+0xc001 142 1
+0xc002 142 2
+0xc003 142 3
+0x8000 142 5
+
+0xc000 143 0
+0xc001 143 1
+0xc002 143 2
+0xc003 143 3
+0x8000 143 5
+
+0xc000 144 0
+0xc001 144 1
+0xc002 144 2
+0xc003 144 3
+0x8000 144 5
+
+0xc000 145 0
+0xc001 145 1
+0xc002 145 2
+0xc003 145 3
+0x8000 145 5
+
+0xc000 146 0
+0xc001 146 1
+0xc002 146 2
+0xc003 146 3
+0x8000 146 5
+
+0xc000 147 0
+0xc001 147 1
+0xc002 147 2
+0xc003 147 3
+0x8000 147 5
+
+0xc000 148 0
+0xc001 148 1
+0xc002 148 2
+0xc003 148 3
+0x8000 148 5
+
+0xc000 149 0
+0xc001 149 1
+0xc002 149 2
+0xc003 149 3
+0x8000 149 5
+
+0xc000 150 0
+0xc001 150 1
+0xc002 150 2
+0xc003 150 3
+0x8000 150 5
+
+0xc000 151 0
+0xc001 151 1
+0xc002 151 2
+0xc003 151 3
+0x8000 151 5
+
+0xc000 152 0
+0xc001 152 1
+0xc002 152 2
+0xc003 152 3
+0x8000 152 5
+
+0xc000 153 0
+0xc001 153 1
+0xc002 153 2
+0xc003 153 3
+0x8000 153 5
+
+0xc000 154 0
+0xc001 154 1
+0xc002 154 2
+0xc003 154 3
+0x8000 154 5
+
+0xc000 155 0
+0xc001 155 1
+0xc002 155 2
+0xc003 155 3
+0x8000 155 5
+
+0xc000 156 0
+0xc001 156 1
+0xc002 156 2
+0xc003 156 3
+0x8000 156 5
+
+0xc000 157 0
+0xc001 157 1
+0xc002 157 2
+0xc003 157 3
+0x8000 157 5
+
+0xc000 158 0
+0xc001 158 1
+0xc002 158 2
+0xc003 158 3
+0x8000 158 5
+
+0xc000 159 0
+0xc001 159 1
+0xc002 159 2
+0xc003 159 3
+0x8000 159 5
+
+0xc000 160 0
+0xc001 160 1
+0xc002 160 2
+0xc003 160 3
+0x8000 160 5
+
+0xc000 161 0
+0xc001 161 1
+0xc002 161 2
+0xc003 161 3
+0x8000 161 5
+
+0xc000 162 0
+0xc001 162 1
+0xc002 162 2
+0xc003 162 3
+0x8000 162 5
+
+0xc000 163 0
+0xc001 163 1
+0xc002 163 2
+0xc003 163 3
+0x8000 163 5
+
+0xc000 164 0
+0xc001 164 1
+0xc002 164 2
+0xc003 164 3
+0x8000 164 5
+
+0xc000 165 0
+0xc001 165 1
+0xc002 165 2
+0xc003 165 3
+0x8000 165 5
+
+0xc000 166 0
+0xc001 166 1
+0xc002 166 2
+0xc003 166 3
+0x8000 166 5
+
+0xc000 167 0
+0xc001 167 1
+0xc002 167 2
+0xc003 167 3
+0x8000 167 5
+
+0xc000 168 0
+0xc001 168 1
+0xc002 168 2
+0xc003 168 3
+0x8000 168 5
+
+0xc000 169 0
+0xc001 169 1
+0xc002 169 2
+0xc003 169 3
+0x8000 169 5
+
+0xc000 170 0
+0xc001 170 1
+0xc002 170 2
+0xc003 170 3
+0x8000 170 5
+
+0xc000 171 0
+0xc001 171 1
+0xc002 171 2
+0xc003 171 3
+0x8000 171 5
+
+0xc000 172 0
+0xc001 172 1
+0xc002 172 2
+0xc003 172 3
+0x8000 172 5
+
+0xc000 173 0
+0xc001 173 1
+0xc002 173 2
+0xc003 173 3
+0x8000 173 5
+
+0xc000 174 0
+0xc001 174 1
+0xc002 174 2
+0xc003 174 3
+0x8000 174 5
+
+0xc000 175 0
+0xc001 175 1
+0xc002 175 2
+0xc003 175 3
+0x8000 175 5
+
+0xc000 176 0
+0xc001 176 1
+0xc002 176 2
+0xc003 176 3
+0x8000 176 5
+
+0xc000 177 0
+0xc001 177 1
+0xc002 177 2
+0xc003 177 3
+0x8000 177 5
+
+0xc000 178 0
+0xc001 178 1
+0xc002 178 2
+0xc003 178 3
+0x8000 178 5
+
+0xc000 179 0
+0xc001 179 1
+0xc002 179 2
+0xc003 179 3
+0x8000 179 5
+
+0xc000 180 0
+0xc001 180 1
+0xc002 180 2
+0xc003 180 3
+0x8000 180 5
+
+
--- /dev/null
+<?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="1"/>
+ <NumOutputs value="2"/>
+
+ <InputPort name="Input0" url="hadaq://host:50170" urlopt1=""/>
+<!-- <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=20000&mtu=64512&flush=3.0&observer=false&debug&resort"/>
+ -->
+
+ <InputPort name="Input*" queue="30" urlopt="udpbuf=20000&mtu=64512&flush=3.0&observer=false&debug"/>
+
+ <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/cosmic_48pf_250mV_thresh.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>
--- /dev/null
+#!/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 => 150, 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();
--- /dev/null
+# 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
+
--- /dev/null
+# 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
+
+
+0x0840 170 0
+0x0841 170 1 # GP IN
+0x0842 170 2
+0x0843 170 3
+0xc001 170 5
+
+0x0840 150 0
+0x0841 150 1 # GP IN
+0x0842 150 2
+0x0843 150 3
+0xc001 150 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
+
+
+# concentrator/combiner
+0x8300 10000 0
--- /dev/null
+!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 0 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
--- /dev/null
+###########################################################################################
+#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 0x8e4e966b 0x9c5c 0xc0a80002 0xc3fa 0xDEADc000 0x00aa 0xc0a801aa 0xc350 0x0578
+# 0x8610 0 0x8e4e966b 0x14dd 0xc0a800b1 0xc38d 0xDEADc001 0x001d 0xc0a80155 0xc350 0x0578
+# 0x8113 0 0x8e4e966b 0x14dd 0xc0a800b1 0xc3c1 0xDEADc002 0x001d 0xc0a80156 0xc350 0x0578
+# 0x8158 0 0x8e4e966b 0x14dd 0xc0a800b1 0xc3ee 0xDEADc003 0x001d 0xc0a80157 0xc350 0x0578
--- /dev/null
+# 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
--- /dev/null
+// this is example for
+
+#include <stdlib.h>
+
+void first()
+{
+ //base::ProcMgr::instance()->SetRawAnalysis(true);
+ base::ProcMgr::instance()->SetTriggeredAnalysis(true);
+
+ // all new instances get this value
+ base::ProcMgr::instance()->SetHistFilling(4);
+
+ // 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(49, 2);
+
+ // [min..max] range for TDC ids
+ //hadaq::TrbProcessor::SetTDCRange(0x610, 0x613);
+ hadaq::TrbProcessor::SetTDCRange(0x0000, 0x1fff);
+
+ // [min..max] range for HUB ids
+ hadaq::TrbProcessor::SetHUBRange(0x8001, 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) : 300000;
+ const char* caltrig = getenv("CALTRIG");
+ unsigned trig = (caltrig && *caltrig) ? atoi(caltrig) : 0xd;
+ const char* uset = getenv("USETEMP");
+ unsigned use_temp = 0; // 0x80000000;
+ if ((uset!=0) && (*uset!=0) && (strcmp(uset,"1")==0)) use_temp = 0x80000000;
+
+ 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(10);
+ }
+
+ unsigned firsttdc = 0;
+
+ for (unsigned k=0;k<hld->NumberOfTDC();k++) {
+ hadaq::TdcProcessor* tdc = hld->GetTDC(k);
+ if (tdc==0) continue;
+
+ if (firsttdc == 0) firsttdc = tdc->GetID();
+
+ printf("Configure %s!\n", tdc->GetName());
+
+ // try to build abs time difference between 0 channels
+ // if (tdc->GetID() != firsttdc)
+ // tdc->SetRefChannel(0, 0, (0x70000 | firsttdc), 6000, -20., 20.);
+
+ tdc->SetUseLastHit(false);
+
+
+ /*
+ tdc->SetRefChannel(1,6, 0xffff, 6000, -20, 20); // trigger
+ tdc->SetRefChannel(2,1, 0xffff, 6000, -20, 20); // TOT
+ tdc->SetRefChannel(6,1, 0xffff, 6000, -20, 20); // TOT
+
+ tdc->SetRefChannel(5,1, 0xffff, 6000, -20, 20); // LED DIFF
+
+ */
+
+ //tdc->SetRefChannel(14,16, 0xffff, 6000, -20, 20); // TOT
+ //tdc->SetRefChannel(16,14, 0xffff, 6000, -20, 20); // TOT
+
+ //tdc->SetRefChannel(16,0, 0xffff, 6000, -20, 20); // TOT
+ //tdc->SetRefChannel(14,0, 0xffff, 6000, -20, 20); // TOT
+ //tdc->SetRefChannel(16,14, 0xffff, 6000, -20, 20); // TOT
+
+ /*
+ tdc->SetRefChannel(27,32, 0xffff, 6000, -20, 20); // TOT
+ tdc->SetRefChannel(28,27, 0xffff, 6000, -20, 20); // TOT
+ tdc->SetRefChannel(32,28, 0xffff, 6000, -20, 20); // TOT
+ */
+ // tdc->SetRefChannel(11,1, 0xffff, 6000, -20, 20); // LED DIFF
+ //tdc->SetRefChannel(2,1, 0xffff, 6000, -20, 20); // LED DIFF
+ //tdc->SetRefChannel(12,2, 0xffff, 6000, -20, 20); // LED DIFF
+
+ if (tdc->GetID() == 0x1130) {
+ // tdc->SetRefChannel(31,1, 0x1130, 6000, -20, 20); // LED DIFF
+ //tdc->SetRefChannel(32,2, 0x1130, 6000, -20, 20); // LED DIFF
+ //tdc->SetRefChannel(1,2, 0x1130, 6000, -20, 20); // LED DIFF
+ //tdc->SetRefChannel(2,31, 0x1130, 6000, -20, 20); // LED DIFF
+ }
+
+ /*
+ if (tdc->GetID() == 0x1580) {
+ tdc->SetRefChannel(31,1, 0x1580, 20000, -20, 20); // LED DIFF
+ tdc->SetRefChannel(32,2, 0x1580, 20000, -20, 20); // LED DIFF
+ tdc->SetRefChannel( 1,2, 0x1580, 20000, -20, 20); // LED DIFF
+ tdc->SetRefChannel(2,31, 0x1580, 20000, -20, 20); // LED DIFF
+ }
+ */
+
+ /*
+ if (tdc->GetID() == 0x1580) {
+ tdc->SetRefChannel(21,17, 0x1580, 20000, -20, 20); // LED DIFF
+ tdc->SetRefChannel(22,18, 0x1580, 20000, -20, 20); // LED DIFF
+ tdc->SetRefChannel(17,18, 0x1580, 20000, -20, 20); // LED DIFF
+ tdc->SetRefChannel(18,21, 0x1580, 20000, -20, 20); // LED DIFF
+ }
+ */
+
+ if (tdc->GetID() == 0x0840) {
+ // tdc->SetRefChannel(9,11, 0x1580, 20000, -20, 20); // LED DIFF
+ // tdc->SetRefChannel(11,9, 0x1580, 20000, -20, 20); // LED DIFF
+ tdc->SetRefChannel(2,6, 0x0840, 20000, -20, 20); // LED DIFF
+ tdc->SetRefChannel(4,2, 0x0840, 20000, -20, 20); // LED DIFF
+ tdc->SetRefChannel(6,4, 0x0840, 20000, -20, 20); // LED DIFF
+ }
+
+
+ if (tdc->GetID() == 0x1133) {
+ //tdc->SetRefChannel(1,0, 0x1133, 6000, -200, -100); // LED DIFF
+ tdc->SetRefChannel(1,31, 0x1130, 6000, -20, 20); // LED DIFF
+ tdc->SetRefChannel(11,1, 0x1133, 6000, -20, 20); // LED DIFF
+ }
+
+ if (tdc->GetID() == 0x1340) {
+ for (unsigned nch=1;nch<tdc->NumChannels();nch++) {
+ tdc->SetRefChannel(nch,0, 0x1340, 10000, -100, 100); // LED DIFF
+ }
+
+ //tdc->SetRefChannel(1,31, 0x1130, 6000, -20, 20); // LED DIFF
+ //tdc->SetRefChannel(11,1, 0x1133, 6000, -20, 20); // LED DIFF
+ }
+
+
+ //tdc->SetRefChannel(31,27, 0xffff, 6000, -20, 20); // LED DIFF
+
+
+ // tdc->SetRefChannel(1, 0, 0xffff, 6000, -160., -100.);
+
+ // if (tdc->GetID() != firsttdc)
+ // tdc->SetDoubleRefChannel(1, (firsttdc << 16) | 1, 6000, -30., 30., 0, 0, 0);
+
+ // tdc->SetUseLastHit(true);
+ //for (unsigned nch=1;nch<tdc->NumChannels();nch++) {
+ // double shift = 0;
+ // if (nch % 2 == 0) shift = 100.;
+ // tdc->SetRefChannel(nch, 0, 0xffff, 6000, shift, shift + 60);
+ // }
+ }
+}
+
+
--- /dev/null
+#!/bin/bash
+
+# CALTRIG = 1 | 13 1-daten, 13-internal pulser for TOT calibration
+
+# make TDC calibration
+# rm -f *.root *.cal;
+# export CALMODE=-1; export CALTRIG=1; go4analysis -rate -user $1 -number 50000000
+
+# make TOT calibration
+# rm -f *.root;
+# export CALMODE=-1; CALTRIG=1; go4analysis -rate -user $1 -number 50000000
+
+rm -f *.root;
+export CALMODE=0; CALTRIG=1; go4analysis -rate -user $1 -number 50000000
+
--- /dev/null
+#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
+
+ unsigned eventnumber;
+
+ base::H1handle hNumHits; //!< histogram with hits number
+ base::H1handle hDif1; //!< histogram with hits number
+ base::H1handle hDif2; //!< histogram with hits number
+ base::H1handle hDif3; //!< histogram with hits number
+ base::H1handle hDif4; //!< histogram with hits number
+ base::H1handle hDif5; //!< histogram with hits number
+ base::H1handle hDif6; //!< histogram with hits number
+ base::H1handle hDif7; //!< histogram with hits number
+ base::H1handle hTot1; //!< histogram with hits number
+ base::H1handle hTot2; //!< histogram with hits number
+ base::H1handle hTot3; //!< histogram with hits number
+ base::H1handle hTot4; //!< histogram with hits number
+ base::H1handle hTot5; //!< histogram with hits number
+ base::H1handle hTot6; //!< 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");
+
+ eventnumber = 0;
+
+ /*
+ 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","2 vs. 4", 1800, -90, 90, "ns");
+ hDif2 = MakeH1("LE2","4 vs. 6", 1800, -90, 90, "ns");
+ hDif3 = MakeH1("LE3","6 vs. 2", 1800, -90, 90, "ns");
+ hDif4 = MakeH1("LETR1","2 vs. 4 trip", 1800, -90, 90, "ns");
+ hDif5 = MakeH1("LETR2","4 vs. 6 trip", 1800, -90, 90, "ns");
+ hDif6 = MakeH1("LETR3","6 vs. 2 trip", 1800, -90, 90, "ns");
+
+ hDif7 = MakeH1("LE4", "Mean vs. middle (chan.2)", 1800, -90, 90, "ns");
+
+ hTot1 = MakeH1("ToT1","ToT 2", 1800, -90, 90, "ns");
+ hTot2 = MakeH1("ToT2","ToT 4", 1800, -90, 90, "ns");
+ hTot3 = MakeH1("ToT3","ToT 6", 1800, -90, 90, "ns");
+
+ hTot4 = MakeH1("ToT4","ToT 2, all 3", 1800, -90, 90, "ns");
+ hTot5 = MakeH1("ToT5","ToT 4, all 3", 1800, -90, 90, "ns");
+ hTot6 = MakeH1("ToT6","ToT 6, all 3", 1800, -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");
+ }
+
+ 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;
+
+ hadaq::HldProcessor* hld = dynamic_cast<hadaq::HldProcessor*> (base::ProcMgr::instance()->FindProc("HLD"));
+ hadaq::TrbProcessor* trb = hld ? hld->FindTRB(0x8000) : 0;
+ // hadaq::TdcProcessor* tdc = hld ? hld->FindTDC(0x1340) : 0;
+ //if (hld) printf("HLD event header %u\n", hld->GetLastEventHdr().GetSeqNr());
+ //if (trb) printf("TRB subevent header trig:%x decoding:%x\n", trb->GetLastSubeventHdr().GetTrigNr(), trb->GetLastSubeventHdr().GetDecoding());
+ // if (tdc) printf("TDC header/trailer messages raw %x %x\n", tdc->GetLastTdcHeader().getData(), tdc->GetLastTdcTrailer().getData());
+
+ //if ()
+
+ 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;
+
+ // use only first hit in each channel
+ if ((chid<33) && (fHits[chid][edge]==0.)) 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]) );
+ */
+
+ //printf("tot: %f\n", (fHits[6][1] - fHits[6][0]));
+ double tot2;
+ double tot4;
+ double tot6;
+
+ tot2 = fHits[2][1] - fHits[2][0];
+ tot4 = fHits[4][1] - fHits[4][0];
+ tot6 = fHits[6][1] - fHits[6][0];
+
+
+ if (tot2 > 2 && tot2 < 20)
+ FillH1(hTot1, tot2);
+
+ if (tot4 > 1 && tot4 < 18)
+ FillH1(hTot2, tot4);
+
+ if (tot6 > 35 && tot6 < 55)
+ FillH1(hTot3, tot6);
+
+
+ if( fHits[6][0]!=0 && fHits[2][0]!=0 && fHits[4][0]!=0) {
+ FillH1(hTot4, tot2);
+ FillH1(hTot5, tot4);
+ FillH1(hTot6, tot6);
+ }
+
+
+
+ if (fHits[4][0]!=0 && fHits[2][0]!=0 )
+ FillH1(hDif1, (fHits[4][0] - fHits[2][0]));
+
+ if (fHits[6][0]!=0 && fHits[4][0]!=0 )
+ FillH1(hDif2, (fHits[6][0] - fHits[4][0]));
+
+ if (fHits[6][0]!=0 && fHits[2][0]!=0 )
+ FillH1(hDif3, (fHits[6][0] - fHits[2][0]));
+
+ if (fHits[4][0]!=0 && fHits[2][0]!=0 && fHits[6][0]!=0 )
+ FillH1(hDif4, (fHits[4][0] - fHits[2][0]));
+
+ if (fHits[6][0]!=0 && fHits[4][0]!=0 && fHits[2][0]!=0 )
+ FillH1(hDif5, (fHits[6][0] - fHits[4][0]));
+
+ if (fHits[6][0]!=0 && fHits[2][0]!=0 && fHits[4][0]!=0)
+ FillH1(hDif6, (fHits[6][0] - fHits[2][0]));
+
+
+ if (fHits[6][0]!=0 && fHits[2][0]!=0 && fHits[4][0]!=0 &&
+
+
+ tot2 > 8.0 && tot2 < 10.0 &&
+ tot4 > 8 && tot4 < 14 &&
+ tot6 > 45.0 && tot6 < 51.0
+
+ /*
+ tot2 > 7. && tot2 < 12. &&
+ tot4 > 8. && tot4 < 13.0 &&
+ tot6 > 46.0 && tot6 < 50.0
+ */
+
+
+
+
+ )
+ FillH1(hDif7, (fHits[6][0] + fHits[4][0])/2 - fHits[2][0] );
+
+
+
+
+ // cuts no longer needed - one see only normal triggers here
+ /* if(
+ ((fHits[6][1] - fHits[6][0]) > 38) && ((fHits[6][1] - fHits[6][0])<48) &&
+ ((fHits[4][1] - fHits[4][0]) > 35) && ((fHits[4][1] - fHits[4][0])<42) &&
+ ((fHits[2][1] - fHits[2][0]) > 35) && ((fHits[2][1] - fHits[2][0])<42)
+ ) {
+ //FillH1(hDif1, (fHits[6][0] + fHits[4][0])/2 - fHits[2][0] );
+ FillH1(hDif1, (fHits[6][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_0840");
+}
--- /dev/null
+#!/bin/bash
+
+DAQ_TOOLS_PATH=~/trbsoft/daqtools
+USER_DIR=~/trbsoft/daqtools/users/gsi_dlab_hades41
+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=trb150:26000
+export TRBNETDPID=$(pgrep -f "trbnetd -i 84")
+#export DAQOPSERVER=hadeb05:84
+export DAQOPSERVER=hades41:170
+
+echo "- trbnetd pid: $TRBNETDPID"
+
+if [[ -z "$TRBNETDPID" ]]
+then
+ ~/trbsoft/trbnettools/bin/trbnetd -i 170
+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
+
+
+#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 0x8840 5 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
+
+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 -
+
+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
+
+# trbcmd w 0x0840 0xcf00 0x2a # enable channel 2,4,6 in slave to serve as trigger to CTS
+
+
+trbcmd setbit 0xc001 0xa101 0x200 # enable trigger on TDCs hits
+
--- /dev/null
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+### Change THIS!
+my $required_endpoints = 5;
+
+
+
+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);
+}