--- /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="2"/>
+ <NumOutputs value="1"/>
+
+ <InputPort name="Input0" url="hadaq://host:50084" urlopt1=""/>
+ <InputPort name="Input1" url="hadaq://host:50061" urlopt1=""/>
+ <InputPort name="Input2" url="hadaq://host:50096" urlopt1=""/>
+ <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="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=200000&mtu=64512&flush=2.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/dabc.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 => 84, addr => "0xc001", sys => "CTS"},
+ 1 => { trb => 61, addr => "0x8000", 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 $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.db
+# maps trbnet-addresses to serial number + FPGA numbers
+
+# Address # S/N # FPGA
+# 0x1234 14 0
+#CTS
+
+0x0840 84 0
+0x0841 84 1
+0x0842 84 2
+0x0843 84 3
+0xc001 84 5
+
+#slave
+0x0610 61 0
+0x0611 61 1
+0x0612 61 2
+0x0613 61 3
+0x8000 61 5
--- /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
+ 0x8000 0 0x8000 0x00020001 0x00030062 0xEA60 0x578 1 0 0 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 #
+########################################################################################################################################
+
+ 0xc001 0 0x214397EA 0x001b 0xc0a80002 0xc3a4 0xDEADc000 0x001B 0xc0a80154 0xc350 0x0578
+ 0x8000 0 0x214397EA 0x001b 0xc0a80002 0xc38d 0xDEADc000 0x001c 0xc0a80155 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
+
+#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
hadaq::TdcMessage::SetFineLimits(31, 491);
// default channel numbers and edges mask
- hadaq::TrbProcessor::SetDefaults(17, 1);
+ hadaq::TrbProcessor::SetDefaults(33, 1);
// [min..max] range for TDC ids
hadaq::TrbProcessor::SetTDCRange(0x610, 0x613);
// try to build abs time difference between 0 channels
if (tdc->GetID() != firsttdc)
- tdc->SetRefChannel(0, 0, (0x70000 | firsttdc), 6000, -30., 30.);
+ tdc->SetRefChannel(0, 0, (0x70000 | firsttdc), 6000, -20., 20.);
- tdc->SetRefChannel(2,1, 0xffff, 2000, -50, 50); // TOT
- tdc->SetRefChannel(6,5, 0xffff, 2000, -50, 50); // TOT
+ /*
+ 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, 2000, -50, 50);
+ tdc->SetRefChannel(5,1, 0xffff, 6000, -20, 20); // LED DIFF
+
+ */
+
+ tdc->SetRefChannel(28,27, 0xffff, 6000, -20, 20); // TOT
+ tdc->SetRefChannel(32,28, 0xffff, 6000, -20, 20); // TOT
+
+ tdc->SetRefChannel(31,27, 0xffff, 6000, -20, 20); // LED DIFF
// tdc->SetRefChannel(1, 0, 0xffff, 6000, -160., -100.);
--- /dev/null
+void first()
+{
+
+ base::ProcMgr::instance()->SetRawAnalysis(true);
+
+ // this limits used for liner calibrations when nothing else is available
+ hadaq::TdcMessage::SetFineLimits(31, 470);
+
+ // default channel numbers and edges mask
+ hadaq::TrbProcessor::SetDefaults(65, 0x1);
+ // hadaq::TrbProcessor::SetDefaults(49, 0x2);
+
+
+ hadaq::HldProcessor* hld = new hadaq::HldProcessor();
+
+ // About time calibration - there are two possibilities
+ // 1) automatic calibration after N hits in every enabled channel.
+ // Just use SetAutoCalibrations method for this
+ // 2) generate calibration on base of provided data and than use it later statically for analysis
+ // Than one makes special run with SetWriteCalibrations() enabled.
+ // Later one reuse such calibrations enabling only LoadCalibrations() call
+
+ /*
+ hadaq::TrbProcessor* trb3_1 = new hadaq::TrbProcessor(0xc001, hld);
+ trb3_1->SetHistFilling(4);
+ trb3_1->SetCrossProcess(false);
+ trb3_1->CreateTDC(0x0840);
+ // enable automatic calibration, specify required number of hits in each channel
+ trb3_1->SetAutoCalibrations(100000);
+ // calculate and write static calibration at the end of the run
+ //trb3_1->SetWriteCalibrations("run1");
+ //trb3_1->LoadCalibrations("run1");
+ */
+
+ hadaq::TrbProcessor* trb3_2 = new hadaq::TrbProcessor(0x8000, hld);
+ trb3_2->SetHistFilling(4);
+ trb3_2->SetCrossProcess(true);
+ trb3_2->CreateTDC(0x0610, 0x0611, 0x0612, 0x0613);
+ trb3_2->SetAutoCalibrations(100000);
+ // trb3_2->SetWriteCalibrations("run1");
+ //trb3_2->LoadCalibrations("run1");
+
+ // this is array with available TDCs ids
+ int tdcmap[4] = { 0x0610, 0x0611, 0x0612, 0x0613 };
+
+ // TDC subevent header id
+
+ for (int cnt=0;cnt<4;cnt++) {
+
+ hadaq::TdcProcessor* tdc = hld->FindTDC(tdcmap[cnt]);
+ //if (tdc==0) continue;
+
+ // specify reference channel
+ //tdc->SetRefChannel(0, 0, 0x202c, 20000, 9597E6., 9603E6., true);
+ // if(cnt==0) {
+ //tdc->SetRefChannel(1, 0, 0xffff, 4000, -500., 500., true);
+ //tdc->SetRefChannel(2, 6, 0xffff, 10000, -50., 50., true);
+ // tdc->SetRefChannel(3, 1, 0x0610, 10000, -50., 50., true);
+ if (cnt==0) {
+ tdc->SetRefChannel(1, 0, 0xffff, 10000, -50., 50., true);
+ tdc->SetRefChannel(2, 0, 0xffff, 10000, -50., 50., true);
+
+ tdc->SetRefChannel(5, 1, 0xffff, 10000, -50., 50., true);
+
+ tdc->SetRefChannel(6, 2, 0xffff, 10000, -50., 50., true);
+ }
+
+ //tdc->SetRefChannel(6, 2, 0x0610, 10000, -50., 50., true);
+ //tdc->SetRefChannel(46, 46, 0xffff, 4000, -50., 50., true);
+
+
+ // } else {
+ // tdc->SetRefChannel(46, 0, 0xffff, 40000, -300., 100., true);
+ // }
+
+ //tdc->SetRefChannel(3, 1, 0xffff, 20000, -10., 10., true);
+ // continue;
+
+ //tdc->SetRefChannel(4, 2, 0xffff, 20000, -10., 10., true);
+// tdc->SetRefChannel(6, 4, 0xc010, 20000, -20., 20., true);
+// tdc->SetRefChannel(7, 5, 0xc010, 20000, -20., 20., true);
+// tdc->SetRefChannel(8, 0, 0xc010, 20000, -90., 80., true);
+// tdc->SetRefChannel(9, 0, 0xc010, 20000, -200., 200., true);
+
+// continue;
+
+
+ if (cnt==1) {
+ tdc->SetRefChannel(0, 0, 0x0610, 10000, -50., 50., true);
+ // specify reference channel from other TDC
+ //tdc->SetRefChannel(0, 0, 0xc000, 20000, -30., 30., true);
+ //tdc->SetRefChannel(0, 0, 0x2000, 20000, -20., 20., true);
+ //tdc->SetRefChannel(6, 6, 0xc000, 20000, -20., 20., true);
+ //tdc->SetRefChannel(7, 7, 0x2000, 20000, -20., 20., true);
+ }
+
+ if (cnt==2) {
+ tdc->SetRefChannel(0, 0, 0x0610, 10000, -50., 50., true);
+ }
+
+ if (cnt==3) {
+ tdc->SetRefChannel(0, 0, 0x0610, 10000, -50., 50., true);
+ }
+
+
+ //if (cnt>1) continue;
+
+ // specify reference channel
+
+ /*
+ tdc->SetRefChannel(0, 0, 0x202d, 20000, -100., 100., true);
+ tdc->SetRefChannel(1, 0, 0xffff, 20000, -800., 800., true);
+ tdc->SetRefChannel(2, 0, 0xffff, 20000, -200., 200., true);
+ tdc->SetRefChannel(3, 0, 0xffff, 20000, -200., 200., true);
+ tdc->SetRefChannel(4, 0, 0xffff, 20000, -200., 200., true);
+ */
+
+ // for old FPGA code one should have epoch for each hit, no longer necessary
+ // tdc->SetEveryEpoch(true);
+
+ // When enabled, time of last hit will be used for reference calculations
+ // tdc->SetUseLastHit(true);
+
+ }
+
+}
+
+
+
--- /dev/null
+#!/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=kp1pc105: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
+
+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
+
+# 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
+
+echo "pulser"
+# pulser #0 to 10 kHz
+trbcmd w 0xc001 0xa156 0x0000270f
+
+echo "trigger type"
+# set trigger type to 0x1
+trbcmd setbit 0xc001 0xa15e 0x10
+
+echo "pulser enable"
+# pulser enable
+trbcmd setbit 0xc001 0xa101 0x2
+
--- /dev/null
+// Automatically generated startup script
+// Do not change it!
+
+go4->SetMainWindowState(4,"000000ff00000000fd00000002000000000000016e00000202fc0200000001fb0000001600420072006f00770073006500720044006f0063006b0100000056000002020000007900ffffff000000030000063d000000d5fc0100000001fc000000000000063d0000044900fffffffa000000000200000003fb00000016004c006f00670049006e0066006f0044006f0063006b0100000000ffffffff0000005200fffffffb0000001a004d006200730056006900650077006500720044006f0063006b0100000000ffffffff0000006400fffffffb0000001e0044004100420043004d006f006e00690074006f00720044006f0063006b0000000279000000ce0000000000000000000004c90000020200000004000000040000000800000008fc0000000800000002000000050000001600460069006c00650054006f006f006c0042006100720100000000ffffffff0000000000000000000000160047006f00340054006f006f006c00730042006100720100000106ffffffff00000000000000000000001e0041006e0061006c00790073006900730054006f006f006c004200610072010000024affffffff00000000000000000000001a0044006900760069006400650050006100640044006f0063006b0000000395000000e40000000000000000000000240048006900730044007200610077004f007000740069006f006e00730044006f0063006b010000036f000004110000000000000000000000020000000000000002000000030000002400420072006f0077007300650072004f007000740069006f006e00730044006f0063006b01000000000000010200000000000000000000001e0044007200610077004f007000740069006f006e00730044006f0063006b0100000102ffffffff000000000000000000000020005300630061006c0065004f007000740069006f006e00730044006f0063006b010000039c000003e400000000000000000000000200000001000000180047006f0034005300740079006c00650044006f0063006b0000000000000004b100000000000000000000000200000000000000030000000000000003000000010000001e0043006f006d006d0061006e0064004c0069006e00650044006f0063006b0000000000000004b1000000000000000000000003000000010000001c00540072006500650056006900650077006500720044006f0063006b0000000000000004b10000000000000000");
+go4->SetMainWindowGeometry(4,"01d9d0cb0001000000000000000000000000063c0000036b00000000000000140000076400000477000000000200");
+
+go4->LaunchAnalysis("trb3_test", ".", "libGo4UserAnalysis", "localhost", Go4_sh, Go4_qt, Go4_lib);
+go4->WaitAnalysis(300);
+
+// configuration of analysis
+go4->AnalysisAutoSave("Go4AutoSave.root", 500, 5, kTRUE, kFALSE);
+go4->AnalysisConfigName("Go4AnalysisPrefs.root");
+
+// step Analysis
+go4->ConfigStep("Analysis", kTRUE, kTRUE, kFALSE);
+go4->StepMbsStreamSource("Analysis", "localhost:6789", 1);
+go4->StepFileStore("Analysis", "NoOutputDefined", kTRUE, 32000, 99, 5, 10000);
+
+go4->SubmitAnalysisConfig(20);
+
+go4->SetAnalysisConfigMode(-1);
+go4->SetAnalysisTerminalMode(0);
+
+go4->StartAnalysis();
+
+// in some analysis one requires to wait several seconds before new histograms appears
+// go4->Wait(1);
+go4->RefreshNamesList();
+
+TGo4Picture *pic1 = new TGo4Picture("pic1", "temporary object to setup viewpanel");
+pic1->SetCrosshair(false);
+pic1->SetRangeX(1.205, 2.645);
+pic1->SetRangeY(0, 32526.9);
+pic1->SetLineAtt(1, 1, 1, -1);
+pic1->SetFillAtt(10, 1001, -1);
+pic1->SetHisStats(true);
+pic1->SetStatsAttr(0.646552, 0.504651, 0.979885, 0.937209, 1000111110, "6.4g", 0, "5.4g");
+pic1->SetHisTitle(true);
+pic1->SetTitleAttr(0.15, 0.933605, 0.85, 0.995);
+pic1->SetTitleTime(true);
+pic1->SetTitleDate(true);
+pic1->SetTitleItem(true);
+pic1->SetAutoScale(true);
+pic1->SetXYRatioOne(false);
+pic1->SetPadAtt(0, 2, 0, 0, 30, 30, 0, 0);
+pic1->SetXAxisAttTime(0, "%H:%M:%S%F1995-01-01 00:00:00s0", -1);
+pic1->AddObjName("Analysis/Histograms/TDC_0612/Ch0/TDC_0612_Ch0_RisingRef", "HIST");
+pic1->SetLineAtt(602, 1, 1, 0);
+pic1->SetFillAtt(0, 1001, 0);
+pic1->SetMarkerAtt(1, 1, 1, 0);
+pic1->SetAxisAtt(0, 1, 1, 42, 0.005, 0.035, 510, 0.03, 1, 42, 1, 0.035, kFALSE, "+", 2048, 0);
+pic1->SetAxisAtt(1, 1, 1, 42, 0.005, 0.035, 510, 0.03, 1, 42, 1, 0.035, kFALSE, "+", 0, 0);
+pic1->SetAxisAtt(2, 1, 1, 42, 0.005, 0.035, 510, 0.03, 1, 42, 1, 0.035, kFALSE, "+", 0, 0);
+go4->StartViewPanel(33, 24, 709, 484, Go4_normal, pic1);
+delete pic1;
+
+TGo4Picture *pic2 = new TGo4Picture("pic2", "temporary object to setup viewpanel");
+pic2->SetCrosshair(false);
+pic2->SetRangeX(1.685, 2.895);
+pic2->SetRangeY(0, 14101.5);
+pic2->SetLineAtt(1, 1, 1, -1);
+pic2->SetFillAtt(10, 1001, -1);
+pic2->SetHisStats(true);
+pic2->SetStatsAttr(0.68, 0.535, 0.98, 0.935, 1000111110, "6.4g", 0, "5.4g");
+pic2->SetHisTitle(true);
+pic2->SetTitleAttr(0.15, 0.933605, 0.85, 0.995);
+pic2->SetTitleTime(true);
+pic2->SetTitleDate(true);
+pic2->SetTitleItem(true);
+pic2->SetAutoScale(true);
+pic2->SetXYRatioOne(false);
+pic2->SetPadAtt(0, 2, 0, 0, 30, 30, 0, 0);
+pic2->SetXAxisAttTime(0, "%H:%M:%S%F1995-01-01 00:00:00s0", -1);
+pic2->AddObjName("Analysis/Histograms/TDC_0611/Ch0/TDC_0611_Ch0_RisingRef", "HIST");
+pic2->SetLineAtt(602, 1, 1, 0);
+pic2->SetFillAtt(0, 1001, 0);
+pic2->SetMarkerAtt(1, 1, 1, 0);
+pic2->SetAxisAtt(0, 1, 1, 42, 0.005, 0.035, 510, 0.03, 1, 42, 1, 0.035, kFALSE, "+", 2048, 0);
+pic2->SetAxisAtt(1, 1, 1, 42, 0.005, 0.035, 510, 0.03, 1, 42, 1, 0.035, kFALSE, "+", 0, 0);
+pic2->SetAxisAtt(2, 1, 1, 42, 0.005, 0.035, 510, 0.03, 1, 42, 1, 0.035, kFALSE, "+", 0, 0);
+go4->StartViewPanel(270, 30, 709, 484, Go4_normal, pic2);
+delete pic2;
+
+TGo4Picture *pic3 = new TGo4Picture("pic3", "temporary object to setup viewpanel");
+pic3->SetCrosshair(false);
+pic3->SetRangeX(4.285, 6.335);
+pic3->SetRangeY(0, 28665);
+pic3->SetLineAtt(1, 1, 1, -1);
+pic3->SetFillAtt(10, 1001, -1);
+pic3->SetHisStats(true);
+pic3->SetStatsAttr(0.68, 0.535, 0.98, 0.935, 1000111110, "6.4g", 0, "5.4g");
+pic3->SetHisTitle(true);
+pic3->SetTitleAttr(0.15, 0.933605, 0.85, 0.995);
+pic3->SetTitleTime(true);
+pic3->SetTitleDate(true);
+pic3->SetTitleItem(true);
+pic3->SetAutoScale(true);
+pic3->SetXYRatioOne(false);
+pic3->SetPadAtt(0, 2, 0, 0, 30, 30, 0, 0);
+pic3->SetXAxisAttTime(0, "%H:%M:%S%F1995-01-01 00:00:00s0", -1);
+pic3->AddObjName("Analysis/Histograms/TDC_0613/Ch0/TDC_0613_Ch0_RisingRef", "HIST");
+pic3->SetLineAtt(602, 1, 1, 0);
+pic3->SetFillAtt(0, 1001, 0);
+pic3->SetMarkerAtt(1, 1, 1, 0);
+pic3->SetAxisAtt(0, 1, 1, 42, 0.005, 0.035, 510, 0.03, 1, 42, 1, 0.035, kFALSE, "+", 2048, 0);
+pic3->SetAxisAtt(1, 1, 1, 42, 0.005, 0.035, 510, 0.03, 1, 42, 1, 0.035, kFALSE, "+", 0, 0);
+pic3->SetAxisAtt(2, 1, 1, 42, 0.005, 0.035, 510, 0.03, 1, 42, 1, 0.035, kFALSE, "+", 0, 0);
+go4->StartViewPanel(300, 0, 709, 484, Go4_normal, pic3);
+delete pic3;
+
+TGo4Picture *pic4 = new TGo4Picture("pic4", "temporary object to setup viewpanel");
+pic4->SetCrosshair(false);
+pic4->SetRangeX(1.97667, 5.62333);
+pic4->SetRangeY(0, 6081.6);
+pic4->SetLineAtt(1, 1, 1, -1);
+pic4->SetFillAtt(10, 1001, -1);
+pic4->SetHisStats(true);
+pic4->SetStatsAttr(0.68, 0.535, 0.98, 0.935, 1000111110, "6.4g", 0, "5.4g");
+pic4->SetHisTitle(true);
+pic4->SetTitleAttr(0.15, 0.933605, 0.85, 0.995);
+pic4->SetTitleTime(true);
+pic4->SetTitleDate(true);
+pic4->SetTitleItem(true);
+pic4->SetAutoScale(true);
+pic4->SetXYRatioOne(false);
+pic4->SetPadAtt(0, 2, 0, 0, 30, 30, 0, 0);
+pic4->SetXAxisAttTime(0, "%H:%M:%S%F1995-01-01 00:00:00s0", -1);
+pic4->AddObjName("Analysis/Histograms/TDC_0610/Ch5/TDC_0610_Ch5_RisingRef", "HIST");
+pic4->SetLineAtt(602, 1, 1, 0);
+pic4->SetFillAtt(0, 1001, 0);
+pic4->SetMarkerAtt(1, 1, 1, 0);
+pic4->SetAxisAtt(0, 1, 1, 42, 0.005, 0.035, 510, 0.03, 1, 42, 1, 0.035, kFALSE, "+", 2048, 0);
+pic4->SetAxisAtt(1, 1, 1, 42, 0.005, 0.035, 510, 0.03, 1, 42, 1, 0.035, kFALSE, "+", 0, 0);
+pic4->SetAxisAtt(2, 1, 1, 42, 0.005, 0.035, 510, 0.03, 1, 42, 1, 0.035, kFALSE, "+", 0, 0);
+go4->StartViewPanel(150, 30, 709, 484, Go4_normal, pic4);
+delete pic4;
+
+TGo4Picture *pic5 = new TGo4Picture("pic5", "temporary object to setup viewpanel");
+pic5->SetCrosshair(false);
+pic5->SetRangeX(1.67667, 5.67667);
+pic5->SetRangeY(0, 8049.3);
+pic5->SetLineAtt(1, 1, 1, -1);
+pic5->SetFillAtt(10, 1001, -1);
+pic5->SetHisStats(true);
+pic5->SetStatsAttr(0.68, 0.535, 0.98, 0.935, 1000111110, "6.4g", 0, "5.4g");
+pic5->SetHisTitle(true);
+pic5->SetTitleAttr(0.15, 0.933605, 0.85, 0.995);
+pic5->SetTitleTime(true);
+pic5->SetTitleDate(true);
+pic5->SetTitleItem(true);
+pic5->SetAutoScale(true);
+pic5->SetXYRatioOne(false);
+pic5->SetPadAtt(0, 2, 0, 0, 30, 30, 0, 0);
+pic5->SetXAxisAttTime(0, "%H:%M:%S%F1995-01-01 00:00:00s0", -1);
+pic5->AddObjName("Analysis/Histograms/TDC_0610/Ch6/TDC_0610_Ch6_RisingRef", "HIST");
+pic5->SetLineAtt(602, 1, 1, 0);
+pic5->SetFillAtt(0, 1001, 0);
+pic5->SetMarkerAtt(1, 1, 1, 0);
+pic5->SetAxisAtt(0, 1, 1, 42, 0.005, 0.035, 510, 0.03, 1, 42, 1, 0.035, kFALSE, "+", 2048, 0);
+pic5->SetAxisAtt(1, 1, 1, 42, 0.005, 0.035, 510, 0.03, 1, 42, 1, 0.035, kFALSE, "+", 0, 0);
+pic5->SetAxisAtt(2, 1, 1, 42, 0.005, 0.035, 510, 0.03, 1, 42, 1, 0.035, kFALSE, "+", 0, 0);
+go4->StartViewPanel(180, 0, 709, 484, Go4_normal, pic5);
+delete pic5;
+
+go4->StartMonitoring(2);
--- /dev/null
+// Automatically generated startup script
+// Do not change it!
+
+go4->SetMainWindowState(4,"000000ff00000000fd00000002000000000000016e0000032efc0200000001fb0000001600420072006f00770073006500720044006f0063006b01000000560000032e0000007900ffffff0000000300000640000000d3fc0100000001fc00000000000006400000044900fffffffa000000000200000003fb00000016004c006f00670049006e0066006f0044006f0063006b0100000000ffffffff0000005200fffffffb0000001a004d006200730056006900650077006500720044006f0063006b0100000000ffffffff0000006400fffffffb0000001e0044004100420043004d006f006e00690074006f00720044006f0063006b0000000279000000ce0000000000000000000004cc0000032e00000004000000040000000800000008fc0000000800000002000000050000001600460069006c00650054006f006f006c0042006100720100000000ffffffff0000000000000000000000160047006f00340054006f006f006c00730042006100720100000106ffffffff00000000000000000000001e0041006e0061006c00790073006900730054006f006f006c004200610072010000024affffffff00000000000000000000001a0044006900760069006400650050006100640044006f0063006b0000000395000000e40000000000000000000000240048006900730044007200610077004f007000740069006f006e00730044006f0063006b010000036f000004110000000000000000000000020000000000000002000000030000002400420072006f0077007300650072004f007000740069006f006e00730044006f0063006b01000000000000010200000000000000000000001e0044007200610077004f007000740069006f006e00730044006f0063006b0100000102ffffffff000000000000000000000020005300630061006c0065004f007000740069006f006e00730044006f0063006b010000039c000003e400000000000000000000000200000001000000180047006f0034005300740079006c00650044006f0063006b0000000000000004b100000000000000000000000200000000000000030000000000000003000000010000001e0043006f006d006d0061006e0064004c0069006e00650044006f0063006b0000000000000004b1000000000000000000000003000000010000001c00540072006500650056006900650077006500720044006f0063006b0000000000000004b10000000000000000");
+go4->SetMainWindowGeometry(4,"01d9d0cb0001000000000000000000000000063f000004950000000000000000fffffffefffffffe000000000200");
+
+go4->LaunchAnalysis("trb3_test", ".", "libGo4UserAnalysis", "localhost", Go4_sh, Go4_qt, Go4_lib);
+go4->WaitAnalysis(300);
+
+// configuration of analysis
+go4->AnalysisAutoSave("Go4AutoSave.root", 500, 5, kTRUE, kFALSE);
+go4->AnalysisConfigName("Go4AnalysisPrefs.root");
+
+// step Analysis
+go4->ConfigStep("Analysis", kTRUE, kTRUE, kFALSE);
+go4->StepMbsStreamSource("Analysis", "localhost:6789", 1);
+go4->StepFileStore("Analysis", "NoOutputDefined", kTRUE, 32000, 99, 5, 10000);
+
+go4->SubmitAnalysisConfig(20);
+
+go4->SetAnalysisConfigMode(-1);
+go4->SetAnalysisTerminalMode(0);
+
+go4->StartAnalysis();
+
+// in some analysis one requires to wait several seconds before new histograms appears
+// go4->Wait(1);
+go4->RefreshNamesList();
+
+TGo4Picture *pic1 = new TGo4Picture("pic1", "temporary object to setup viewpanel");
+pic1->SetCrosshair(false);
+pic1->SetRangeX(1.20333, 2.64333);
+pic1->SetRangeY(0, 1.05);
+pic1->SetFrameAttr(0.0989848, 0.0985222, 0.101523, 0.103448);
+pic1->SetLineAtt(1, 1, 1, -1);
+pic1->SetFillAtt(10, 1001, -1);
+pic1->SetHisStats(true);
+pic1->SetStatsAttr(0.646552, 0.504651, 0.979885, 0.937209, 1000111110, "6.4g", 0, "5.4g");
+pic1->SetHisTitle(true);
+pic1->SetTitleAttr(0.15, 0.933605, 0.85, 0.995);
+pic1->SetTitleTime(true);
+pic1->SetTitleDate(true);
+pic1->SetTitleItem(true);
+pic1->SetAutoScale(true);
+pic1->SetXYRatioOne(false);
+pic1->SetPadAtt(0, 2, 0, 0, 30, 30, 0, 0);
+pic1->SetXAxisAttTime(0, "%H:%M:%S%F1995-01-01 00:00:00s0", -1);
+pic1->AddObjName("Analysis/Histograms/TDC_0612/Ch0/TDC_0612_Ch0_RisingRef", "HIST");
+pic1->SetLineAtt(602, 1, 1, 0);
+pic1->SetFillAtt(0, 1001, 0);
+pic1->SetMarkerAtt(1, 1, 1, 0);
+pic1->SetAxisAtt(0, 1, 1, 42, 0.005, 0.035, 510, 0.03, 1, 42, 1, 0.035, kFALSE, "+", 2048, 0);
+pic1->SetAxisAtt(1, 1, 1, 42, 0.005, 0.035, 510, 0.03, 1, 42, 1, 0.035, kFALSE, "+", 0, 0);
+pic1->SetAxisAtt(2, 1, 1, 42, 0.005, 0.035, 510, 0.03, 1, 42, 1, 0.035, kFALSE, "+", 0, 0);
+go4->StartViewPanel(818, 259, 407, 257, Go4_normal, pic1);
+delete pic1;
+
+TGo4Picture *pic2 = new TGo4Picture("pic2", "temporary object to setup viewpanel");
+pic2->SetCrosshair(false);
+pic2->SetRangeX(1.68333, 2.89667);
+pic2->SetRangeY(0, 1.05);
+pic2->SetLineAtt(1, 1, 1, -1);
+pic2->SetFillAtt(10, 1001, -1);
+pic2->SetHisStats(true);
+pic2->SetStatsAttr(0.68, 0.535, 0.98, 0.935, 1000111110, "6.4g", 0, "5.4g");
+pic2->SetHisTitle(true);
+pic2->SetTitleAttr(0.147989, 0.934884, 0.847701, 0.995349);
+pic2->SetTitleTime(true);
+pic2->SetTitleDate(true);
+pic2->SetTitleItem(true);
+pic2->SetAutoScale(true);
+pic2->SetXYRatioOne(false);
+pic2->SetPadAtt(0, 2, 0, 0, 30, 30, 0, 0);
+pic2->SetXAxisAttTime(0, "%H:%M:%S%F1995-01-01 00:00:00s0", -1);
+pic2->AddObjName("Analysis/Histograms/TDC_0611/Ch0/TDC_0611_Ch0_RisingRef", "HIST");
+pic2->SetLineAtt(602, 1, 1, 0);
+pic2->SetFillAtt(0, 1001, 0);
+pic2->SetMarkerAtt(1, 1, 1, 0);
+pic2->SetAxisAtt(0, 1, 1, 42, 0.005, 0.035, 510, 0.03, 1, 42, 1, 0.035, kFALSE, "+", 2048, 0);
+pic2->SetAxisAtt(1, 1, 1, 42, 0.005, 0.035, 510, 0.03, 1, 42, 1, 0.035, kFALSE, "+", 0, 0);
+pic2->SetAxisAtt(2, 1, 1, 42, 0.005, 0.035, 510, 0.03, 1, 42, 1, 0.035, kFALSE, "+", 0, 0);
+go4->StartViewPanel(0, 0, 409, 259, Go4_normal, pic2);
+delete pic2;
+
+TGo4Picture *pic3 = new TGo4Picture("pic3", "temporary object to setup viewpanel");
+pic3->SetCrosshair(false);
+pic3->SetLogScale(1, 1);
+pic3->SetRangeX(-19.9967, 19.9967);
+pic3->SetRangeY(0, 1);
+pic3->SetLineAtt(1, 1, 1, -1);
+pic3->SetFillAtt(10, 1001, -1);
+pic3->SetHisStats(true);
+pic3->SetStatsAttr(0.68, 0.535, 0.98, 0.935, 1000111110, "6.4g", 0, "5.4g");
+pic3->SetHisTitle(true);
+pic3->SetTitleAttr(0.15, 0.933605, 0.85, 0.995);
+pic3->SetTitleTime(true);
+pic3->SetTitleDate(true);
+pic3->SetTitleItem(true);
+pic3->SetAutoScale(true);
+pic3->SetXYRatioOne(false);
+pic3->SetPadAtt(0, 2, 0, 0, 30, 30, 0, 0);
+pic3->SetXAxisAttTime(0, "%H:%M:%S%F1995-01-01 00:00:00s0", -1);
+pic3->AddObjName("Analysis/Histograms/TDC_0613/Ch0/TDC_0613_Ch0_RisingRef", "HIST");
+pic3->SetLineAtt(602, 1, 1, 0);
+pic3->SetFillAtt(0, 1001, 0);
+pic3->SetMarkerAtt(1, 1, 1, 0);
+pic3->SetAxisAtt(0, 1, 1, 42, 0.005, 0.035, 510, 0.03, 1, 42, 1, 0.035, kFALSE, "+", 2048, 0);
+pic3->SetAxisAtt(1, 1, 1, 42, 0.005, 0.035, 510, 0.03, 1, 42, 1, 0.035, kFALSE, "+", 0, 0);
+pic3->SetAxisAtt(2, 1, 1, 42, 0.005, 0.035, 510, 0.03, 1, 42, 1, 0.035, kFALSE, "+", 0, 0);
+go4->StartViewPanel(409, 259, 409, 257, Go4_normal, pic3);
+delete pic3;
+
+TGo4Picture *pic4 = new TGo4Picture("pic4", "temporary object to setup viewpanel");
+pic4->SetCrosshair(false);
+pic4->SetRangeX(-5.68333, -0.756667);
+pic4->SetLineAtt(1, 1, 1, -1);
+pic4->SetFillAtt(10, 1001, -1);
+pic4->SetHisStats(true);
+pic4->SetStatsAttr(0.68, 0.535, 0.98, 0.935, 1000111110, "6.4g", 0, "5.4g");
+pic4->SetHisTitle(true);
+pic4->SetTitleAttr(0.15, 0.933605, 0.85, 0.995);
+pic4->SetTitleTime(true);
+pic4->SetTitleDate(true);
+pic4->SetTitleItem(true);
+pic4->SetAutoScale(true);
+pic4->SetXYRatioOne(false);
+pic4->SetPadAtt(0, 2, 0, 0, 30, 30, 0, 0);
+pic4->SetXAxisAttTime(0, "%H:%M:%S%F1995-01-01 00:00:00s0", -1);
+pic4->AddObjName("Analysis/Histograms/TDC_0610/Ch5/TDC_0610_Ch5_RisingRef", "HIST");
+pic4->SetLineAtt(602, 1, 1, 0);
+pic4->SetFillAtt(0, 1001, 0);
+pic4->SetMarkerAtt(1, 1, 1, 0);
+pic4->SetAxisAtt(0, 1, 1, 42, 0.005, 0.035, 510, 0.03, 1, 42, 1, 0.035, kFALSE, "+", 2048, 0);
+pic4->SetAxisAtt(1, 1, 1, 42, 0.005, 0.035, 510, 0.03, 1, 42, 1, 0.035, kFALSE, "+", 0, 0);
+pic4->SetAxisAtt(2, 1, 1, 42, 0.005, 0.035, 510, 0.03, 1, 42, 1, 0.035, kFALSE, "+", 0, 0);
+go4->StartViewPanel(0, 259, 409, 257, Go4_normal, pic4);
+delete pic4;
+
+TGo4Picture *pic5 = new TGo4Picture("pic5", "temporary object to setup viewpanel");
+pic5->SetCrosshair(false);
+pic5->SetRangeX(-19.9967, 19.9967);
+pic5->SetLineAtt(1, 1, 1, -1);
+pic5->SetFillAtt(10, 1001, -1);
+pic5->SetHisStats(true);
+pic5->SetStatsAttr(0.68, 0.535, 0.98, 0.935, 1000111110, "6.4g", 0, "5.4g");
+pic5->SetHisTitle(true);
+pic5->SetTitleAttr(0.15, 0.933605, 0.85, 0.995);
+pic5->SetTitleTime(true);
+pic5->SetTitleDate(true);
+pic5->SetTitleItem(true);
+pic5->SetAutoScale(true);
+pic5->SetXYRatioOne(false);
+pic5->SetPadAtt(0, 2, 0, 0, 30, 30, 0, 0);
+pic5->SetXAxisAttTime(0, "%H:%M:%S%F1995-01-01 00:00:00s0", -1);
+pic5->AddObjName("Analysis/Histograms/TDC_0610/Ch6/TDC_0610_Ch6_RisingRef", "HIST");
+pic5->SetLineAtt(602, 1, 1, 0);
+pic5->SetFillAtt(0, 1001, 0);
+pic5->SetMarkerAtt(1, 1, 1, 0);
+pic5->SetAxisAtt(0, 1, 1, 42, 0.005, 0.035, 510, 0.03, 1, 42, 1, 0.035, kFALSE, "+", 2048, 0);
+pic5->SetAxisAtt(1, 1, 1, 42, 0.005, 0.035, 510, 0.03, 1, 42, 1, 0.035, kFALSE, "+", 0, 0);
+pic5->SetAxisAtt(2, 1, 1, 42, 0.005, 0.035, 510, 0.03, 1, 42, 1, 0.035, kFALSE, "+", 0, 0);
+go4->StartViewPanel(818, 0, 407, 259, Go4_normal, pic5);
+delete pic5;
+
+TGo4Picture *pic6 = new TGo4Picture("pic6", "temporary object to setup viewpanel");
+pic6->SetCrosshair(false);
+pic6->SetRangeX(-4.35, 1.45);
+pic6->SetFrameAttr(0.0909091, 0.097561, 0.108586, 0.102439);
+pic6->SetLineAtt(1, 1, 1, -1);
+pic6->SetFillAtt(10, 1001, -1);
+pic6->SetHisStats(true);
+pic6->SetStatsAttr(0.68, 0.535, 0.98, 0.935, 1000111110, "6.4g", 0, "5.4g");
+pic6->SetHisTitle(true);
+pic6->SetTitleAttr(0.15, 0.933605, 0.85, 0.995);
+pic6->SetTitleTime(true);
+pic6->SetTitleDate(true);
+pic6->SetTitleItem(true);
+pic6->SetAutoScale(true);
+pic6->SetXYRatioOne(false);
+pic6->SetPadAtt(0, 2, 0, 0, 30, 30, 0, 0);
+pic6->SetXAxisAttTime(0, "%H:%M:%S%F1995-01-01 00:00:00s0", -1);
+pic6->AddObjName("Analysis/Histograms/TDC_0610/Ch1/TDC_0610_Ch1_RisingRef", "HIST");
+pic6->SetLineAtt(602, 1, 1, 0);
+pic6->SetFillAtt(0, 1001, 0);
+pic6->SetMarkerAtt(1, 1, 1, 0);
+pic6->SetAxisAtt(0, 1, 1, 42, 0.005, 0.035, 510, 0.03, 1, 42, 1, 0.035, kFALSE, "+", 2048, 0);
+pic6->SetAxisAtt(1, 1, 1, 42, 0.005, 0.035, 510, 0.03, 1, 42, 1, 0.035, kFALSE, "+", 0, 0);
+pic6->SetAxisAtt(2, 1, 1, 42, 0.005, 0.035, 510, 0.03, 1, 42, 1, 0.035, kFALSE, "+", 0, 0);
+go4->StartViewPanel(409, 0, 409, 259, Go4_normal, pic6);
+delete pic6;
+
+go4->StartMonitoring(2);
--- /dev/null
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+### Change THIS!
+my $required_endpoints = 10;
+
+
+
+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);
+}