From: Hades DAQ Date: Fri, 1 Mar 2019 10:22:08 +0000 (+0100) Subject: ... still some tests, do not use yet X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=54971901ace860d643f8a51c57edcf906ae0496d;p=dockerfiles.git ... still some tests, do not use yet --- diff --git a/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/Dockerfile b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/Dockerfile new file mode 100644 index 0000000..d1bf4f6 --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/Dockerfile @@ -0,0 +1,148 @@ +################################################## +## get minimal distro from cloud ## +################################################## + +FROM opensuse/leap:15.0 + + + +################################################## +## prerequisites ## +################################################## + +### install system packages with opensuse package manager +RUN zypper ref && zypper --non-interactive in \ + wget curl \ + tar zlib \ + cmake gcc gcc-c++ \ + libX11-devel libXext-devel libXft-devel libXpm-devel\ + git subversion \ + libqt4-devel\ + git bash cmake gcc-c++ gcc binutils \ + xorg-x11-libX11-devel xorg-x11-libXpm-devel xorg-x11-devel \ + xorg-x11-proto-devel xorg-x11-libXext-devel \ + gcc-fortran libopenssl-devel \ + pcre-devel Mesa glew-devel pkg-config libmysqlclient-devel \ + fftw3-devel libcfitsio-devel graphviz-devel \ + libdns_sd avahi-compat-mDNSResponder-devel openldap2-devel \ + python-devel libxml2-devel krb5-devel gsl-devel libqt4-devel \ + glu-devel \ + xterm screen xvfb-run x11vnc openbox \ + boost-devel \ + vim \ + dhcp-server\ + rpcbind \ + gnuplot \ + ImageMagick \ + perl-XML-LibXML \ + glibc-locale \ + tmux \ + xorg-x11-Xvnc \ + emacs \ + htop \ + ncdu \ + psmisc \ + python-pip \ + firefox \ + lxpanel \ + libtirpc-devel \ + perl-File-chdir \ + perl-TimeDate \ + gzip \ + tig + + +### install perl modules from cpan ### +RUN cpan Data::TreeDumper CGI::Carp + +### install python modules from pip ### +RUN pip install --upgrade pip && pip install prettytable python2-pythondialog + + + +################################################## +## select stable repositories ## +################################################## + +### stable versions of git/svn repos to checkout ### + +#ENV TRBNET_COMMIT=master + +ENV TRBNET_COMMIT=02cf41a486d64bc894986fe87c174bfe1b07fc9b +# newest version of trbnettools does not work with this system ... revert to older commit ### +# has something to do with commit 0cd022a9b0bda2213989eef118a1dda077794ba9 +# 2019-01-24 00:17 Michael Traxler ---- added -ltirpc in Makesfiles for a working RPC implementation, mt +# commit breaks rpc communication + + +################################################## + + +#ENV DAQTOOLS_COMMIT=master + +ENV DAQTOOLS_COMMIT=4840d304ad9cce93ffe972ef8cff4c325d7ac198 +# newest commit from 2018-02-28 + + +################################################## + +#ENV DABC_TRB3_REV=HEAD + +ENV DABC_TRB3_REV=4242 +# newest commit from 2018-02-28 + + +################################################## +## Go4 + dabc + root ## +################################################## + +### check out revision 4242, newest revision from today 2019-02-28 ### +RUN svn checkout -r $DABC_TRB3_REV https://subversion.gsi.de/dabc/trb3 + +RUN cd /trb3; make -j2; make_exit_value=$?; \ + echo -e "\n\n---- display make log: ----\n\n"; \ + cat $(find . -iname "makelog.txt"); \ + $( exit $make_exit_value ) + + + +################################################## +## trbnet ## +################################################## + + + +RUN git clone git://jspc29.x-matter.uni-frankfurt.de/projects/trbnettools.git &&\ + cd /trbnettools &&\ + git checkout $TRBNET_COMMIT &&\ + cd /trbnettools/libtrbnet_perl && \ + perl Makefile.PL && \ + cd /trbnettools && \ + make clean && \ + make TRB3=1 && \ + make TRB3=1 install && \ + echo "/trbnettools/liblocal" >> /etc/ld.so.conf.d/trbnet.conf && \ + ldconfig -v + +ENV PATH=$PATH:/trbnettools/bin + + + + +################################################## +## daqtools ## +################################################## + +RUN git clone git://jspc29.x-matter.uni-frankfurt.de/projects/daqtools.git && \ + cd /daqtools && \ +### check out newest commit 4840d3... as today: 2019-02-28 ### + git checkout $DAQTOOLS_COMMIT && \ + cd /daqtools/xml-db && \ + ./xml-db.pl + +### replace httpi with a modified version, because the httpi in daqtools won't run as root +COPY build_files/httpi /daqtools/web/httpi + + + + diff --git a/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/build.sh b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/build.sh new file mode 100755 index 0000000..abffd2d --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/build.sh @@ -0,0 +1,6 @@ + +name=$(basename $(pwd)) + +docker build -t $name . || exit + + diff --git a/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/build_and_run.sh b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/build_and_run.sh new file mode 100755 index 0000000..377875b --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/build_and_run.sh @@ -0,0 +1,9 @@ + +name=$(basename $(pwd)) + +docker build -t $name . || exit + +docker run --net host -v $(pwd)/conf:/conf -v $(pwd)/workdir:/workdir --rm -it \ +--name $name \ +$name /workdir/start.sh + diff --git a/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/build_and_shell.sh b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/build_and_shell.sh new file mode 100755 index 0000000..74ee374 --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/build_and_shell.sh @@ -0,0 +1,9 @@ + +name=$(basename $(pwd)) + +docker build -t $name . || exit + +docker run --net host -v $(pwd)/conf:/conf -v $(pwd)/workdir:/workdir --rm -it \ +--name $name \ +$name /bin/bash + diff --git a/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/build_files/httpi b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/build_files/httpi new file mode 100755 index 0000000..06f15cc --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/build_files/httpi @@ -0,0 +1,538 @@ +#!/usr/bin/perl +use POSIX qw(SIGALRM SIGTERM sigaction); + +use lib "./"; +use lib "./include"; +use Digest::SHA::PurePerl qw(sha1_base64); + + +$VERSION = "1.7 (Demonic/Linux)"; + +# HTTPi Hypertext Tiny Truncated Process Implementation +# Copyright 1999-2010 Cameron Kaiser and Contributors # All rights reserved +# Please read LICENSE # Do not strip this copyright message. + +############################################################### +# WHITE HATS ONLY BELOW THIS POINT -- SEE DOCUMENTATION FIRST # +############################################################### + +%system_content_types = + ("html" => "text/html", + "htm" => "text/html", + "txt" => "text/plain", + "xml" => "text/xml", + "xsl" => "text/xml", + "xhtml" => "application/xhtml+xml", + "css" => "text/css", + "gif" => "image/gif", + "jpeg" => "image/jpeg", + "jpg" => "image/jpeg", + "bmp" => "image/bmp", + "png" => "image/png", + "tif" => "image/tiff", + "tiff" => "image/tiff", + "ico" => "image/x-icon", + "svg" => "image/svg+xml", + "svgz" => "image/svg+xml", + "wbmp" => "image/vnd.wap.wbmp", + "wbm" => "image/vnd.wap.wbmp", + "xbm" => "image/x-xbitmap", + "mp3" => "audio/x-mpeg", + "wma" => "audio/x-ms-wma", + "wav" => "audio/x-wav", + "au" => "audio/basic", + "aif" => "audio/x-aiff", + "aiff" => "audio/x-aiff", + "ogg" => "audio/x-ogg", + "oga" => "audio/x-ogg", + "mid" => "audio/midi", + "wma" => "audio/x-ms-wma", + "mpeg" => "video/mpeg", + "mpg" => "video/mpeg", + "aac" => "audio/aac", + "ogv" => "video/x-ogg", + "ogx" => "application/x-ogg", + "avi" => "video/x-msvideo", + "wmv" => "video/x-ms-wmv", + "asf" => "video/x-ms-asf", + "mov" => "video/quicktime", + "mp4" => "video/mp4", + "rv" => "video/vnd.m-realvideo", + "rm" => "application/vnd.m-realmedia", + "ra" => "audio/vnd.m-realaudio", + "ram" => "audio/vnd.m-realaudio", + "pdf" => "application/pdf", + "fdf" => "application/vnd.fdf", + "class" => "application/octet-stream", + "jar" => "application/octet-stream", + "js" => "application/x-javascript", + "lnk" => "application/x-hyperlink", + "prg" => "application/x-c64-prg-binary", + "d64" => "application/x-c64-disk-image", + "tar" => "application/x-tar", + "sit" => "application/x-stuffit", + "Z" => "application/x-compress", + "gz" => "application/x-gzip", + "dmg" => "application/octet-stream", + "img" => "application/octet-stream", + "lzh" => "application/octet-stream", + "lha" => "application/octet-stream", + "exe" => "application/octet-stream", + "com" => "application/octet-stream", + "zip" => "application/x-zip-compressed", + "hqx" => "application/x-binhex", + "swf" => "x-shockwave-flash", + "flv" => "video/x-flv", + + "bin" => "application/octet-stream"); + +# comment in to enable logs +#$logfile = "./access.log"; +$path = "./htdocs"; +$sockaddr = 'S n a4 x8'; + +$server_host = $ARGV[0]; +$server_port = $ARGV[1]; + +die("$0 [host] [port] required. got >$server_host< >$server_port<") unless ($server_host and $server_port); + +%content_types = + ("html" => "text/html", + "htm" => "text/html", + "shtml" => "text/html" + ); +%restrictions = ( + "/nw" => "^10\.##^Mozilla#MSIE", + "/status" => "####voyeur:daNrZR3TcSwD2", + "/" => "###(NPBot|WebZIP|HTTrack|eCatch|Offline Explorer|UdmSearch|WebCopier|internetseer|MSIECrawler|SuperBot|LinkWalker|Tutorial Crawler|WebReaper)", + ); + # See documentation for interpreting this string. + +$headers = <<"EOF"; +Server: TRB3-DAQ based on HTTPi/$VERSION +MIME-Version: 1.0 +EOF + + +%content_types = (%system_content_types, %content_types); +undef %system_content_types; + +#if ($pid = fork()) { exit; } +$0 = "dhttpi: binding port ..."; +$bindthis = pack($sockaddr, 2, $server_port, pack('C4', 0, 0, 0, 0)); +socket(S, 2, 1, 6); +setsockopt(S, 1, 2, 1); +bind(S, $bindthis) || die("$0: while binding port $server_port:\n\"$!\"\n"); +listen(S, 128); +$0 = "dhttpi: connected and waiting ANY:$server_port"; + +$statiosuptime = time(); + +sub sock_to_host { + return ($cache_hn, $cache_port, $cache_ip) + if (length($cache_ip)); + + return (undef, undef, undef) if (!$sock); + my($AFC, $cache_port, $thataddr, $zero) = unpack($sockaddr, $sock); + $cache_ip = join('.', unpack("C4", $thataddr)); + $cache_hn = + gethostbyaddr($thataddr, 2) || + $cache_ip; + return ($cache_hn, $cache_port, $cache_ip); +} + + +sub htsponse { + ($currentcode, $currentstring) = (@_); + return if (0+$httpver < 1); + my($what) = <<"EOF"; +HTTP/$httpver $currentcode $currentstring +${headers}Date: $rfcdate +EOF + $what =~ s/\n/\r\n/g; + print STDOUT $what; + &hthead("Connection: close") if (0+$httpver > 1); +} + +sub hthead { + my($header, $term) = (@_); + return if (0+$httpver < 1); + print STDOUT "$header\r\n" , ($term) ? "\r\n" : ""; +} + +sub htcontent { + my($what, $ctype, $mode) = (@_); + ($contentlength) = $mode || length($what); + &hthead("Content-Length: $contentlength"); + &hthead("Content-Type: $ctype", 1); + return if ($method eq 'HEAD' || $mode); + print STDOUT $what; +} + +sub log { + if ($logfile && open(J, ">>$logfile")) { + my $q = $address . (($variables) ? "?$variables" : ""); + $contentlength += 0; + $contentlength = 0 if ($method eq 'HEAD'); + my ($hostname, $port, $ip) = &sock_to_host(); + $hostname ||= "-"; + $httpuser ||= "-"; + print J <<"EOF"; +$hostname - $httpuser [$date] "$method $q HTTP/$httpver" $currentcode $contentlength "$httpref" "$httpua" +EOF + close(J); + } +} + + +sub bye { exit; } +sub byebye { kill(9,$secondary_pid) if ($secondary_pid); exit; } + +sub dead { + &htsponse(500, "Server Error"); + &hterror("Server Error", <<"EOF"); +The server cannot comply with your request for resource $::address. +Please attempt to notify the administrators. +

Useful(?) debugging information: +

+@_
+
+EOF + &log; exit; +} + +sub defaultsignals { + $SIG{'__DIE__'} = \&dead; + sigaction SIGALRM, new POSIX::SigAction \&bye + or die "sigalrm failed: $!\n"; + sigaction SIGTERM, new POSIX::SigAction \&byebye + or die "sigterm failed: $!\n"; +} +&defaultsignals; + +sub alarmsignals { + undef $SIG{'__DIE__'}; + sigaction SIGALRM, new POSIX::SigAction sub { die; } + or die "sigalrm failed: $!\n"; +} + +sub master { + $0 = "dhttpi: handling request"; +$sock = getpeername(STDIN); +$rfcdate = &rfctime(scalar gmtime, 1); +$date = scalar localtime; +($dow, $mon, $dt, $tm, $yr) = ($date =~ + m/(...) (...) (..) (..:..:..) (....)/); +$dt += 0; +$dt = substr("0$dt", length("0$dt") - 2, 2); +$date = "$dt/$mon/$yr:$tm +0000"; + +select(STDOUT); $|=1; $address = 0; +alarm 5; +while () { + if(/^([A-Z]+)\s+([^\s]+)\s+([^\s\r\l\n]*)/) { + $method = $1; + $address = $2; + $httpver = $3; + $httpref = ''; + $httpua = ''; + $httpver = ($httpver =~ m#HTTP/([0-9]\.[0-9]+)#) ? + ($1) : (0.9); + $address =~ s#^http://[^/]+/#/#; + $0 = $execstring = "dhttpi: $method $address $httpver"; + next unless ($httpver < 1); + } else { + s/[\r\l\n\s]+$//; + (/^Host:\s+(.+)/i) && ($httphost = substr($1, 0, 255)) + && ($httphost =~ s/:\d+$//); + (/^Referer:\s+(.+)/i) && ($httpref = substr($1, 0, 1024)); + (/^User-agent:\s+(.+)/i) && ($httpua = substr($1, 0, 1024)); + (/^Content-length:\s+(\d+)/i) && + ($ENV{'CONTENT_LENGTH'} = $httpcl = 0+$1); + (/^Content-type:\s+(.+)/i) && + ($ENV{'CONTENT_TYPE'} = $httpct = substr($1, 0, 255)); + (/^Expect:\s+/) && ($expect = 1); + (/^Cookie:\s+(.+)/i) && + ($ENV{'HTTP_COOKIE'} = substr($1, 0, 16384)); + (/^Authorization:\s+Basic (.+)/i) && + ($httprawu = substr($1, 0, 1024)); + (/^Range:\s+(.+)/i) && + ($ENV{'CONTENT_RANGE'} = substr($1, 0, 255)); + (/^If-Modified-Since:\s+(.+)/i) && + ($modsince = $ENV{'HTTP_IF_MODIFIED_SINCE'} = + substr($1, 0, 255)); + (/^Accept:\s+(.+)/i) && + ($ENV{'HTTP_ACCEPT'} = substr($1, 0, 255)); + (/^Accept-([a-zA-Z0-9]+):\s+(.+)/i) && + ($ENV{'HTTP_ACCEPT_'.uc(substr($1, 0, 16))} = + substr($2, 0, 255)); + (/^X-Requested-With:\s+(.+)/i) && + ($ENV{'HTTP_X_REQUESTED_WITH'} = substr($1, 0, 1024)); + + (/^Origin:\s+(.+)/i) && + ($ENV{'HTTP_ORIGIN'} = substr($1, 0, 1024)); + (/^Upgrade:\s+(.+)/i) && + ($ENV{'HTTP_UPGRADE'} = substr($1, 0, 1024)); + (/^Sec-WebSocket-Protocol:\s+(.+)/i) && + ($ENV{'WEBSOCKET_PROTOCOL'} = substr($1, 0, 1024)); + (/^Sec-WebSocket-Version:\s+(-?\d+)/i) && + ($ENV{'WEBSOCKET_VERSION'} = substr($1, 0, 8)); + (/^Sec-WebSocket-Extensions:\s+(-?\d+)/i) && + ($ENV{'WEBSOCKET_EXTENSIONS'} = substr($1, 0, 1024)); + (/^Sec-WebSocket-Key:\s+(\S+)/i) && + ($ENV{'WEBSOCKET_KEY'} = substr($1, 0, 1024)); + + next unless (/^$/); + } + if ($expect) { + &htsponse(417, "Expectation Failed"); + &hterror("Expectation Failed", + "The server does not support this method."); + &log; exit; + } + if (!length($address) || (0+$httpver > 1 && !$httphost)) { + &htsponse(400, "Bad Request"); + &hterror("Bad Request", + "The server cannot understand your request."); + &log; exit; + } + if ($method !~ /^(GET|HEAD|POST)$/) { + &htsponse(501, "Not Implemented"); + &hterror("Not Implemented", + "Only GET, HEAD and POST are supported."); + &log; exit; + } + + + if ($ENV{'HTTP_UPGRADE'} eq 'websocket') { + if ($method ne "GET" || !$ENV{'WEBSOCKET_KEY'}) { + &htsponse(400, "Bad request"); + &hterror("Bad request", + "Illegal websocket opening handshake"); + &log; exit; + } + + $ENV{'WEBSOCKET_ACCEPT'} = + sha1_base64($ENV{'WEBSOCKET_KEY'} . "258EAFA5-E914-47DA-95CA-C5AB0DC85B11") . "="; + + + } + + + + ($address, $variables) = split(/\?/, $address); + $address =~ s/%([0-9a-fA-F]{2})/pack("H2", $1)/eg; + $address=~ s#^/?#/#; + 1 while $address =~ s#/\.(/|$)#\1#; + 1 while $address =~ s#/[^/]*/\.\.(/|$)#\1#; + 1 while $address =~ s#^/\.\.(/|$)#\1#; + $fail = 0; + J: foreach(sort { length $a <=> length $b } + keys %restrictions) { + next if ($address !~ /^$_/); + ($allowip, $denyip, $allowua, $denyua, $auser) = + split(/#/, $restrictions{$_}); + if ($allowip || $denyip) { + ($hostname, $port, $ip) = &sock_to_host(); + ($allowip && $ip !~ /$allowip/) && ($fail = 1, + last J); + ($denyip && $ip =~ /$denyip/) && ($fail = 1, + last J); + } + ($allowua && $httpua !~ /$allowua/) && + ($fail = 2, last J); + ($denyua && $httpua =~ /$denyua/) && + ($fail = 2, last J); + } + if ($fail) { + &htsponse(403, "Forbidden"); + if ($fail == 1) { + &hterror("Forbidden (Client Disallowed)", <<"EOF"); +Your network address ($ip) is not allowed to access this resource. +EOF + &log; exit; + } else { + &hterror("Forbidden (Browser Disallowed)", <<"EOF"); +The browser you are using ($httpua) is not capable of or +is not allowed access to this resource. +EOF + &log; exit; + } + } + if ($auser) { + $httprawu =~ tr#A-Za-z0-9+/##cd; + $httprawu =~ tr#A-Za-z0-9+/# -_#; + $httprawu = unpack("u", pack("c", 32+0.75*length($httprawu)) + . $httprawu); + ($httpuser, $httppw) = split(/:/, $httprawu); + $fail = 1; + foreach $user (split(/,/, $auser)) { + ($user, $pw) = split(/:/, $user); + ($fail = 0, last) if ($user eq $httpuser && + crypt($httppw, substr($pw, 0, 2)) eq $pw); + } + if ($fail) { + $httpuser = ''; + &htsponse(401, "Authorization Required"); + &hthead("WWW-Authenticate: Basic realm=\"$address\""); + &hterror("Authorization Required", <<"EOF"); +You must provide a username and password to use this resource. Either you +entered this information incorrectly, or your browser does not know how to +present the credentials required. +EOF + &log; exit; + } + } + + alarm 0; + + + + + $raddress = "$path$address" + ; + 1 while ($raddress =~ s#//#/#); + &hterror301("http://$server_host:$server_port$address/") + if ($address !~ m#/$# && -d $raddress); + $raddress = (-r "${raddress}index.shtml") ? + "${raddress}index.shtml" : "${raddress}index.html" + if (-d $raddress); + IRED: ($hostname, $port, $ip) = &sock_to_host(); + if(!sysopen(S, $raddress, 0)) { &hterror404; } else { + if ((-x $raddress) + ) { + $currentcode = 100; &nsecmodel; + $ENV{'REQUEST_METHOD'} = $method; + $ENV{'SERVER_NAME'} = $server_host; + $ENV{'SERVER_PROTOCOL'} = "HTTP/$httpver"; + $ENV{'SERVER_SOFTWARE'} = "HTTPi/$VERSION"; + $ENV{'SERVER_PORT'} = "$server_port"; + $ENV{'SERVER_URL'} = "http://$server_host:$server_port/"; + $ENV{'SCRIPT_FILENAME'} = $raddress; + $ENV{'SCRIPT_NAME'} = $address; + $ENV{'REMOTE_HOST'} = $hostname; + $ENV{'REMOTE_ADDR'} = $ip; + $ENV{'REMOTE_PORT'} = $port; + $ENV{'QUERY_STRING'} = $variables; + $ENV{'HTTP_USER_AGENT'} = $httpua; + $ENV{'HTTP_REFERER'} = $httpref; + undef $pid; + if ($pid = fork()) { kill 15, $$; exit; } + elsif (!defined($pid)) { + die + "temporary(?) fork error, please retry request: $!\n"; + } else { + require $raddress; + exit; + } + } + ($x,$x,$x,$x,$x,$x,$x,$length,$x,$mtime) = stat(S); + $ctype = 0; + foreach(keys %content_types) { + if ($raddress =~ /\.$_$/i) { + $ctype = $content_types{$_}; + } + } + $mtime = &rfctime($mtime); +SERVEIT: + if ($mtime eq $modsince) { + &htsponse(304, "Not Modified"); + &hthead("Last-Modified: $mtime", 1); + &log; exit; + } + $ctype ||= 'text/plain'; + if ($pid = fork()) { kill 15, $$; exit; } + $contentlength ||= $length; + &htsponse(200, "OK"); + &hthead("Last-Modified: $mtime"); + &htcontent("", $ctype, $length); + &nsecmodel; + $bytecount = 0; + unless ($method eq 'HEAD') { + while(!eof(S)) { + read(S, $q, 32768); + print STDOUT $q; + $bytecount += 32768; + $0 = $execstring . + " ($bytecount bytes sent)"; + } + } + alarm 0; + } + exit; +} + +exit; +} + + +sub nsecmodel { + &log; + ($x,$x,$x,$x,$uid,$gid) = stat(S); + #(!$uid || !$gid || $uid < 2 ) && +# die "resource is root-owned, secured or not stat-able\n"; +# if (!$<) { +# ($) = "$gid $gid") || die "can't set egid to $gid"; +# ($> = $uid) || die "can't set euid to $uid"; +# ($( = "$gid $gid") || die "can't set rgid to $gid"; +# ($< = $uid) || die "can't set ruid to $uid"; +# } +} + +sub rfctime { + my $mtime = shift; + $mtime = (scalar gmtime $mtime) if (!(shift)); + my ($dow, $mon, $dt, $tm, $yr) = + ($mtime =~ m/(...) (...) (..) (..:..:..) (....)/); + $dt += 0; $yr += 0; + return "$dow, $dt $mon $yr $tm GMT"; +} + +sub hterror { + my($errstr, @expl) = (@_); + &htcontent(<<"EOF", "text/html"); + + +

$errstr

+@expl +
+
httpi/$VERSION +by Cameron Kaiser
+ + +EOF + } + +sub hterror404 { + &htsponse(404, "Not Found"); + &hterror("Not Found", + "The resource $address was not found on this system."); + &log; exit; +} + +sub hterror301 { + &htsponse(301, "Moved Permanently"); + &hthead("Location: @_"); + &hterror("Resource Moved Permanently", + "This resource has moved here."); + &log; exit; +} + + +$0 = "dhttpi: on ANY:$server_port, ready!"; +$master_pid = $$; +for (;;) { + if ($secondary_pid = fork()) { + waitpid($secondary_pid, 0); + $0 = "dhttpi: on ANY:$server_port, last request " . + scalar localtime; + } else { + $0 = "dhttpi (child of $master_pid): waiting for connect"; + $addr=accept(NS,S); + open(STDIN, "<&NS"); + open(STDOUT, ">&NS"); + &defaultsignals; + &master; + exit; + } +} diff --git a/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/conf/.register_configgbe.db.swp b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/conf/.register_configgbe.db.swp new file mode 100644 index 0000000..78f7831 Binary files /dev/null and b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/conf/.register_configgbe.db.swp differ diff --git a/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/conf/addresses.sh b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/conf/addresses.sh new file mode 100755 index 0000000..e935b37 --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/conf/addresses.sh @@ -0,0 +1,10 @@ +#!/bin/bash + + +trbcmd s 0x7100000390255228 0x00 0x0350 +trbcmd s 0x8c0000039025fa28 0x01 0x0351 +trbcmd s 0xb00000039053e328 0x02 0x0352 +trbcmd s 0x790000039053dc28 0x03 0x0353 +trbcmd s 0x920000039053d928 0x05 0xc035 +echo "FPGAs after addressing" +trbcmd i 0xffff diff --git a/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/conf/conf.sh b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/conf/conf.sh new file mode 100755 index 0000000..3bc6482 --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/conf/conf.sh @@ -0,0 +1,100 @@ +#!/bin/bash + +cd /conf + + + +echo "configure container" + +export TRB3_PORT=35 +export DAQOPSERVER=localhost:$TRB3_PORT +export TRB3_SERVER=192.168.4.240 +export CTS_GUI_PORT=1148 +export CTS_ENDPOINT=0xc035 +export DISPLAY=:2 # go4 window will be sent to $DISPLAY, if provide_vnc == yes , then it will be this x11 display + +export PULSER=192.168.103.74 + +> conf_log.txt + +provide_dhcp=yes +#edit conf/dhcpd.conf, enter your trb3 MAC address ### +provide_trbnetd=yes + +provide_cts_gui=yes + +provide_vnc=yes +vnc_password= +vnc_port=5902 +vnc_geometry=1500x1024 + + +# tmux new-session -d -s x11vnc -n x11vnc "x11vnc -forever -create -rfbport 5902 #(nopasswd)" + +# set paths for go4/dabc/stream +. /trb3/trb3login + + + +### no need to touch the rest of the file ### + + echo ... >> conf_log.txt + echo DAQOPSERVER=$DAQOPSERVER >> conf_log.txt + echo >> conf_log.txt + +if [ $provide_dhcp == "yes" ]; then + echo starting dhcp server + cp dhcpd.conf /etc/dhcpd.conf + > /tmp/dhcp_leasefile + dhcpd -lf /tmp/dhcp_leasefile + echo ... >> conf_log.txt + echo dhcp server started >> conf_log.txt + echo using config file /conf/dhcpd.conf >> conf_log.txt + echo >> conf_log.txt +fi + +if [ $provide_trbnetd == "yes" ]; then + trbnetd -i $TRB3_PORT + echo ... >> conf_log.txt + echo started trbnetd >> conf_log.txt + echo TRB3_SERVER=$TRB3_SERVER >> conf_log.txt + echo port $TRB3_PORT >> conf_log.txt + echo >> conf_log.txt +fi + +if [ $provide_cts_gui == "yes" ]; then +# screen -S cts_gui -d -m ./start_cts_gui.sh + tmux new-session -d -s cts_gui -n cts_gui "cd /daqtools/web; perl ./cts_gui --endpoint $CTS_ENDPOINT --quiet --noopenxterm --port $CTS_GUI_PORT" +# tmux new-window -t main:1 -n "cts_gui" "cd /daqtools/web; perl ./cts_gui --endpoint $CTS_ENDPOINT --quiet --noopenxterm --port $CTS_GUI_PORT" + echo ... >> conf_log.txt + echo started cts_gui with following parameters:>> conf_log.txt + echo --endpoint $CTS_ENDPOINT >> conf_log.txt + echo --port $CTS_GUI_PORT >> conf_log.txt + echo >> conf_log.txt +fi + +if [ $provide_vnc == "yes" ]; then + mkdir -p $HOME/.vnc/ + echo $vnc_password | vncpasswd -f > $HOME/.vnc/passwd + tmux new-session -d -s vnc -n vnc "echo starting vnc server on port $vnc_port for display $DISPLAY; vncserver $DISPLAY -rfbauth $HOME/.vnc/passwd -rfbport $vnc_port -geometry $vnc_geometry ;/bin/bash" + + echo ... >> conf_log.txt + echo "started vnc server (e.g. for Go4 window)" >> conf_log.txt + echo port=$vnc_port >> conf_log.txt + echo DISPLAY=$DISPLAY >> conf_log.txt + echo password=$vnc_password >> conf_log.txt + echo >> conf_log.txt + echo connect with: vncviewer localhost:$vnc_port >> conf_log.txt + echo >> conf_log.txt +fi + +./addresses.sh + +/daqtools/tools/loadregisterdb.pl register_configgbe.db +/daqtools/tools/loadregisterdb.pl register_configgbe_ip.db +sleep 1 +./conf_cts.sh +./conf_tdcs.sh + + +echo "done" diff --git a/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/conf/conf_cts.sh b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/conf/conf_cts.sh new file mode 100755 index 0000000..04cefd1 --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/conf/conf_cts.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +# CTS Configuration dump +# generated: 2019-02-05 15:10 +# CTS Compile time: 2019-01-21 14:47 +# +# trbcmd Dev. Reg. Value +trbcmd setbit 0xc035 0xa00c 0x80000000 # Disable all triggers +trbcmd w 0xc035 0xa008 0xffffffff # cts_fsm_limits: ro=65535, td=65535 +trbcmd w 0xc035 0xa009 0x00000001 # cts_readout_config: + # channel_cnt=false, idle_dead_cnt=false, input_cnt=true + # timestamp=false, trg_cnt=false +trbcmd w 0xc035 0xa00c 0x80000400 # cts_throttle: enable=true, stop=false, threshold=0 +trbcmd w 0xc035 0xa00d 0x00000001 # cts_eventbuilder: + # cal_eb=0, mask=0000 0000 0000 0001, rr_interval=0 + # use_cal_eb=false +trbcmd w 0xc035 0xa101 0xffff0400 # trg_channel_mask: edge=1111 1111 1111 1111, mask=0000 0100 0000 0000 +trbcmd w 0xc035 0xa124 0x00000000 # trg_input_config0: delay=0, invert=false, override=off, spike_rej=0 +trbcmd w 0xc035 0xa125 0x00000000 # trg_input_config1: delay=0, invert=false, override=off, spike_rej=0 +trbcmd w 0xc035 0xa126 0x00000000 # trg_input_config2: delay=0, invert=false, override=off, spike_rej=0 +trbcmd w 0xc035 0xa127 0x00000000 # trg_input_config3: delay=0, invert=false, override=off, spike_rej=0 +trbcmd w 0xc035 0xa128 0x00000000 # trg_input_config4: delay=0, invert=false, override=off, spike_rej=0 +trbcmd w 0xc035 0xa129 0x00000000 # trg_input_config5: delay=0, invert=false, override=off, spike_rej=0 +trbcmd w 0xc035 0xa12a 0x00000000 # trg_input_config6: delay=0, invert=false, override=off, spike_rej=0 +trbcmd w 0xc035 0xa13b 0x000f0000 # trg_coin_config0: + # coin_mask=0000 0000, inhibit_mask=0000 0000 + # window=15 +trbcmd w 0xc035 0xa13c 0x000f0000 # trg_coin_config1: + # coin_mask=0000 0000, inhibit_mask=0000 0000 + # window=15 +trbcmd w 0xc035 0xa13e 0x00000000 # trg_input_mux0: input=extclk[0] +trbcmd w 0xc035 0xa13f 0x00000001 # trg_input_mux1: input=extclk[1] +trbcmd w 0xc035 0xa140 0x00000002 # trg_input_mux2: input=trgext[2] +trbcmd w 0xc035 0xa141 0x00000003 # trg_input_mux3: input=trgext[3] +trbcmd w 0xc035 0xa142 0x00000004 # trg_input_mux4: input=jeclin[0] +trbcmd w 0xc035 0xa143 0x00000005 # trg_input_mux5: input=jeclin[1] +trbcmd w 0xc035 0xa144 0x00000006 # trg_input_mux6: input=jeclin[2] +trbcmd w 0xc035 0xa146 0x00000000 # trg_addon_output_mux0: input=itc[0] +trbcmd w 0xc035 0xa147 0x00000001 # trg_addon_output_mux1: input=itc[1] +trbcmd w 0xc035 0xa148 0x00000002 # trg_addon_output_mux2: input=itc[2] +trbcmd w 0xc035 0xa149 0x00000003 # trg_addon_output_mux3: input=itc[3] +trbcmd w 0xc035 0xa14a 0x00000004 # trg_addon_output_mux4: input=itc[4] +trbcmd w 0xc035 0xa14b 0x00000005 # trg_addon_output_mux5: input=itc[5] +trbcmd w 0xc035 0xa14c 0x00000006 # trg_addon_output_mux6: input=itc[6] +trbcmd w 0xc035 0xa14d 0x00000007 # trg_addon_output_mux7: input=itc[7] +trbcmd w 0xc035 0xa14f 0x00010000 # trg_periph_config0: mask=0001 0000 0000 0000 0000 +trbcmd w 0xc035 0xa150 0x00000000 # trg_periph_config1: mask=0000 0000 0000 0000 0000 +trbcmd w 0xc035 0xa151 0x00000000 # trg_periph_config2: mask=0000 0000 0000 0000 0000 +trbcmd w 0xc035 0xa152 0x00000000 # trg_periph_config3: mask=0000 0000 0000 0000 0000 +trbcmd w 0xc035 0xa154 0x000061a7 # trg_pulser_config0: low_duration=24999 +trbcmd w 0xc035 0xa155 0x00000003 # trg_pulser_config1: low_duration=3 +trbcmd w 0xc035 0xa157 0x00000000 # trg_random_pulser_config0: threshold=0 +trbcmd w 0xc035 0xa159 0x1111111d # _trg_trigger_types0: + # type0=0xd_tdc_calibration_trigger, type1=0x1_physics_trigger + # type2=0x1_physics_trigger, type3=0x1_physics_trigger + # type4=0x1_physics_trigger, type5=0x1_physics_trigger + # type6=0x1_physics_trigger, type7=0x1_physics_trigger +trbcmd w 0xc035 0xa15a 0x11111111 # _trg_trigger_types1: + # type10=0x1_physics_trigger, type11=0x1_physics_trigger + # type12=0x1_physics_trigger, type13=0x1_physics_trigger + # type14=0x1_physics_trigger, type15=0x1_physics_trigger + # type8=0x1_physics_trigger, type9=0x1_physics_trigger +trbcmd clearbit 0xc035 0xa00c 0x80000000 # Enable all triggers + diff --git a/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/conf/conf_log.txt b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/conf/conf_log.txt new file mode 100644 index 0000000..d3ca223 --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/conf/conf_log.txt @@ -0,0 +1,25 @@ +... +DAQOPSERVER=localhost:35 + +... +dhcp server started +using config file /conf/dhcpd.conf + +... +started trbnetd +TRB3_SERVER=192.168.4.240 +port 35 + +... +started cts_gui with following parameters: +--endpoint 0xc035 +--port 1148 + +... +started vnc server (e.g. for Go4 window) +port=5902 +DISPLAY=:2 +password= + +connect with: vncviewer localhost:5902 + diff --git a/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/conf/conf_tdcs.sh b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/conf/conf_tdcs.sh new file mode 100755 index 0000000..a2cc702 --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/conf/conf_tdcs.sh @@ -0,0 +1,55 @@ +#!/bin/bash + + + +### all tdcs ### + +for TDC in 0x0350 0x0351 0x0352 0x0353; do + + # invert the first 32 channels + trbcmd w $TDC 0xc805 0xFFFFFFFF + + # enable trigger windows +-1000 ns + trbcmd w $TDC 0xc801 0x80c800c8 + + # set channel ringbuffer size + trbcmd w $TDC 0xc804 10 + +done + + +### tdcs with pasttrec attached ### + +for TDC in 0x0350 0x0351; do + + # enable the first 16 channels (CONN1) + trbcmd setbit $TDC 0xc802 0x0000FFFF + + # enable the second 16 channels (CONN2) + trbcmd setbit $TDC 0xc802 0xFFFF0000 + +done + + +### reference time TDC ### + +for TDC in 0x0353; do + + # non- invert the first channel + trbcmd clearbit $TDC 0xc805 0x1 + + # enable the first channel + trbcmd setbit $TDC 0xc802 0x1 + + # enable Florian's trigger Logic + trbcmd setbit $TDC 0xe000 0x1 + # enable edge detect + trbcmd setbit $TDC 0xe008 0x1 + # merge outputs + trbcmd setbit $TDC 0xe018 0x1 + # delay 0 cycles + trbcmd setbit $TDC 0xe100 0x0 + # stretcher on, five cycles + #trbcmd setbit $TDC 0xe200 0x10005 + +done diff --git a/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/conf/dhcpd.conf b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/conf/dhcpd.conf new file mode 100644 index 0000000..e361b85 --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/conf/dhcpd.conf @@ -0,0 +1,16 @@ + +shared-network em1 { + subnet 192.168.4.0 netmask 255.255.255.0 { + option subnet-mask 255.255.255.0; + option broadcast-address 192.168.4.255; + option routers 192.168.4.254; + #option domain-name-servers 141.2.242.36; + #option domain-name "x-matter.uni-frankfurt.de"; + default-lease-time 86400; + max-lease-time 172800; + } +} + host trb3_148 { hardware ethernet 02:00:f8:00:be:30; fixed-address 192.168.4.240;} + host trb3_148_new { hardware ethernet da:7a:37:0e:f4:30; fixed-address 192.168.4.240;} + host trb3_148_old { hardware ethernet 02:00:be:30:f4:0e; fixed-address 192.168.4.240;} + host trb3_35 { hardware ethernet da:7a:33:90:53:d9; fixed-address 192.168.4.240;} diff --git a/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/conf/register_configgbe.db b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/conf/register_configgbe.db new file mode 100755 index 0000000..b64cf58 --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/conf/register_configgbe.db @@ -0,0 +1,23 @@ + + + +!Register table +# Type # C0 # C1 # C2 # C3 # C4 # C5 # C6 # C7 # C8 # C9 # +################################################################################################### + 0 0x8300 0x8305 0x8307 0x8308 0x830b + 1 0x8301 0x8302 0x8304 0x8309 0x830c 0x830e 0x830f 0x8310 + + +!Value table +# SubEvtId UseGbE MultiQueue Trig. Num. InclTrgType +# Hub # Type # C0 # C1 # C2 # C3 # C4 # +################################################################################## + 0xc035 0 0xc035 1 0 0xffffff 1 + + + +#These values to not need to be written - for completeness only +# SubEvtDec QueDec FrameSize RX enable SubEvtSize Evt/Queue QueueClose MaxQueueSize +# Hub # Type # C0 # C1 # C2 # C3 # C4 # C5 # C6 # C7 # +########################################################################################################################## +# 0xff7f 1 0x00020001 0x00030062 0x578 1 59800 200 32000 60000 diff --git a/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/conf/register_configgbe_ip.db b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/conf/register_configgbe_ip.db new file mode 100755 index 0000000..c2da36f --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/conf/register_configgbe_ip.db @@ -0,0 +1,34 @@ +########################################################################################### +#Eventbuilders: +# EB 0: hadespc001 eth1 ports 50000 - 50099 + +!Register table +# Type # C0 # C1 # C2 # C3 # C4 # +####################################################### +#new memory locations + 0 0x8100 0x8101 0x8102 0x8103 0x8107 + 1 0x8110 0x8111 0x8112 0x8113 0x8117 + 2 0x8120 0x8121 0x8122 0x8123 0x8127 + 3 0x8130 0x8131 0x8132 0x8133 0x8137 + 4 0x8140 0x8141 0x8142 0x8143 0x8147 + 5 0x8150 0x8151 0x8152 0x8153 0x8157 + 6 0x8160 0x8161 0x8162 0x8163 0x8167 + 7 0x8170 0x8171 0x8172 0x8173 0x8177 + 8 0x8180 0x8181 0x8182 0x8183 0x8187 + 9 0x8190 0x8191 0x8192 0x8193 0x8197 + 10 0x81A0 0x81A1 0x81A2 0x81A3 0x81A7 + 11 0x81B0 0x81B1 0x81B2 0x81B3 0x81B7 + 12 0x81C0 0x81C1 0x81C2 0x81C3 0x81C7 + 13 0x81D0 0x81D1 0x81D2 0x81D3 0x81D7 + 14 0x81E0 0x81E1 0x81E2 0x81E3 0x81E7 + 15 0x81F0 0x81F1 0x81F2 0x81F3 0x81F7 + +!Value table +# Dest MAC Dest MAC Dest IP Dest Port Src Port +# Hub # Type # C0 # C1 # C2 # C3 # C4 # +#################################################################################### + + 0xc035 0 0xBB61482F 0xECF4 0xc0a804fe 50002 0xc350 + + + diff --git a/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/conf/reload_all.sh b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/conf/reload_all.sh new file mode 100755 index 0000000..a016ca9 --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/conf/reload_all.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +trbcmd reload 0x0350 +trbcmd reload 0x0351 +trbcmd reload 0x0352 +trbcmd reload 0x0353 +trbcmd reload 0xc035 + +sleep 4 + +./addresses.sh diff --git a/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/workdir/TdcEventBuilder.xml b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/workdir/TdcEventBuilder.xml new file mode 100644 index 0000000..536498d --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/workdir/TdcEventBuilder.xml @@ -0,0 +1,161 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/workdir/first.C b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/workdir/first.C new file mode 100644 index 0000000..728e429 --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/workdir/first.C @@ -0,0 +1,118 @@ +// this is example for + + +#include + +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(10, 510); + + // default channel numbers and edges mask + hadaq::TrbProcessor::SetDefaults(33, 0x2); +// hadaq::TdcProcessor::SetDefaults(1000); + //hadaq::TdcProcessor::DisableCalibrationFor(0,8); + // [min..max] range for TDC ids + //hadaq::TrbProcessor::SetTDCRange(0x610, 0x613); + hadaq::TrbProcessor::SetTDCRange(0x0350, 0x0353); + + // configure ToT calibration parameters + // first - minimal number of counts in ToT histogram + // second - maximal RMS value + hadaq::TdcProcessor::SetToTCalibr(100, 0.2); + + //hadaq::T + // [min..max] range for HUB ids + hadaq::TrbProcessor::SetHUBRange(0xc001, 0xcfff); + + // 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) : 0; + const char* caltrig = getenv("CALTRIG"); + unsigned trig = (caltrig && *caltrig) ? atoi(caltrig) : 0x0; + 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*/ 0x3fff); + hld->ConfigureCalibration("test_", -1, (1 << 0xD)); + + + // only accept trigger type 0x1 when storing file + //new hadaq::HldFilter(0x0); + + // create ROOT file store +// base::ProcMgr::instance()->CreateStore("td.root"); + + // 0 - disable store + // 1 - std::vector - includes original TDC message + // 2 - std::vector - compact form, without channel 0, stamp as float (relative to ch0) + // 3 - std::vector - compact form, with channel 0, absolute time stamp as double + base::ProcMgr::instance()->SetStoreKind(1); + +} + +// extern "C" required by DABC to find function from compiled code + +extern "C" void after_create(hadaq::HldProcessor* hld) +{ + printf("Called after all sub-components are created\n"); + + if (hld==0) return; + + for (unsigned k=0;kNumberOfTRB();k++) { + hadaq::TrbProcessor* trb = hld->GetTRB(k); + if (trb==0) continue; + printf("Configure %s!\n", trb->GetName()); + trb->SetPrintErrors(10); + } + + unsigned firsttdc = 0; + + for (unsigned k=0;kNumberOfTDC();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->DisableCalibrationFor(0); + + // if (tdc->GetID() == 0x1130); + + for (int n=1;n<49;++n) + tdc->SetRefChannel(n,0, 0xffff, 6000, -200, 200); // LED DIFF + } +} + + diff --git a/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/workdir/my_hotstart.hotstart b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/workdir/my_hotstart.hotstart new file mode 100644 index 0000000..ce6cf0a --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/workdir/my_hotstart.hotstart @@ -0,0 +1,42 @@ +// Automatically generated startup script +// Do not change it! + +go4->SetMainWindowState(4,"000000ff00000000fd000000020000000000000125000002e8fc0200000001fb0000001600420072006f00770073006500720044006f0063006b0100000073000002e80000007a00ffffff000000030000063c00000082fc0100000001fc000000000000063c0000003d00fffffffa000000000200000003fb00000016004c006f00670049006e0066006f0044006f0063006b0100000000ffffffff0000005300fffffffb0000001a004d006200730056006900650077006500720044006f0063006b0000000000ffffffff0000006500fffffffb0000001e0044004100420043004d006f006e00690074006f00720044006f0063006b0000000279000000ce000000000000000000000511000002e800000004000000040000000800000008fc0000000800000002000000040000001600460069006c00650054006f006f006c0042006100720100000000ffffffff0000000000000000000000160047006f00340054006f006f006c00730042006100720100000106ffffffff00000000000000000000001e0041006e0061006c00790073006900730054006f006f006c004200610072010000024a0000025800000000000000000000001a0044006900760069006400650050006100640044006f0063006b0000000395000000e40000000000000000000000020000000000000002000000020000002400420072006f0077007300650072004f007000740069006f006e00730044006f0063006b01000000000000010200000000000000000000001e0044007200610077004f007000740069006f006e00730044006f0063006b01000001020000037e00000000000000000000000200000002000000240048006900730044007200610077004f007000740069006f006e00730044006f0063006b0000000000000001290000000000000000000000180047006f0034005300740079006c00650044006f0063006b0000000000000004b10000000000000000000000020000000200000020005300630061006c0065004f007000740069006f006e00730044006f0063006b0000000000000004b100000000000000000000002c0041006e0061006c00790073006900730043006f006d006d0061006e00640054006f006f006c0042006100720100000000ffffffff0000000000000000000000030000000000000003000000010000001e0043006f006d006d0061006e0064004c0069006e00650044006f0063006b0000000000000004b1000000000000000000000003000000010000001c00540072006500650056006900650077006500720044006f0063006b0000000000000004b10000000000000000"); +go4->SetMainWindowGeometry(4,"01d9d0cb00010000000000140000000c000006570000042d00000018000000240000065300000429000000000000"); +go4->LoadLibrary("/usr/lib64/qt4/plugins/imageformats/libqgif.so"); +go4->LoadLibrary("/usr/lib64/qt4/plugins/imageformats/libqico.so"); +go4->LoadLibrary("/usr/lib64/qt4/plugins/imageformats/libqjpeg.so"); +go4->LoadLibrary("/usr/lib64/qt4/plugins/imageformats/libqmng.so"); +go4->LoadLibrary("/usr/lib64/libmng.so.1"); +go4->LoadLibrary("/usr/lib64/liblcms.so.1"); +go4->LoadLibrary("/usr/lib64/qt4/plugins/imageformats/libqsvg.so"); +go4->LoadLibrary("/usr/lib64/libQtSvg.so.4"); +go4->LoadLibrary("/usr/lib64/qt4/plugins/imageformats/libqtga.so"); +go4->LoadLibrary("/usr/lib64/qt4/plugins/imageformats/libqtiff.so"); +go4->LoadLibrary("/lib64/libnss_mdns_minimal.so.2"); +go4->LoadLibrary("/lib64/libnss_dns.so.2"); +go4->LoadLibrary("/lib64/libresolv.so.2"); + +go4->LaunchAnalysis("MyAnalysis", ".", "", "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(1); + +go4->StartAnalysis(); + +// in some analysis one requires to wait several seconds before new histograms appears +// go4->Wait(1); +go4->RefreshNamesList(); + diff --git a/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/workdir/second.C b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/workdir/second.C new file mode 100644 index 0000000..7a2a4f1 --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/workdir/second.C @@ -0,0 +1,454 @@ +#include +#include +#include +#include + +#include "TTree.h" +#include "TFile.h" +#include "TSystem.h" +#include "TString.h" +#include "TH1.h" +#include "TH2.h" +#include "TCanvas.h" +#include "TGo4AnalysisObjectManager.h" + + +#include "base/EventProc.h" +#include "base/Event.h" +#include "hadaq/TdcSubEvent.h" + +#define CHANNELS 33 +#define REFCHAN 0 +// #define REFCHAN_B 0 + +#define VERBOSE 0 +#define TAKE_FIRST_HIT 1 + + + +// Muentz-Torte +#define t1_L -400 // EE +#define t1_R 400 // EE +#define tot_L -10 // EE +#define tot_R 1000 // EE + +#define ref_channel_offset -75 //ns fine measured ref channel relative to coarse measured cts trigger channel +//#define ref_channel_offset 0 //ns fine measured ref channel relative to coarse measured cts trigger channel + +// in the first iteration, scanning through data in the coincidence window, rejecting hits (fuzzy edges) + +//#define spike_rejection 90 //ns for ASD8 0x72 (25000) with LASER +// #define spike_rejection 90 //ns for PASTTREC pt10 // for t1 calibration +//#define spike_rejection 60 //ns for PASTTREC pt10 +// #define spike_rejection 45 //ns for PASTTREC with all the nice filters +// #define spike_rejection 90 //ns for PASTTREC pt15 +//#define spike_rejection 100 //ns for PASTTREC pt20 +// #define spike_rejection 30 //ns for ASD8 0xA9 +// #define spike_rejection 60 //ns for ASD8 0x72 +// #define spike_rejection 75 //ns for ASD8 0x52 +//#define spike_rejection 47 //ns for ASD8 thr 37000 with LASER +// #define spike_rejection 90 //ns for PASTTREC pt20 with LASER +//#define spike_rejection 90 //ns for PASTTREC pt20 with Fe55 + +#define spike_rejection 30 +#define spike_rejection_refchan 10 + +#define individual_spike_rejection 0 + +//#define ref_spike_rejection 100 + + +//#define t1_accept_L (-250 + ref_channel_offset) //ns // GSI Dlab +//#define t1_accept_L (-1000000 + ref_channel_offset) //ns // HZDR fe55 +#define t1_accept_L (-2000 + ref_channel_offset) //ns // EE +//#define t1_accept_L (-150 + ref_channel_offset) //ns // Muentz-Torte +//#define t1_accept_R (100 + ref_channel_offset)//ns // GSI Dlab +//#define t1_accept_R (1000000 + ref_channel_offset)//ns // HZDR fe55 +#define t1_accept_R (2000 + ref_channel_offset)//ns // EE +// #define t1_accept_R (-130 + ref_channel_offset)//ns // Muentz-Torte +// #define t1_accept_R (-90 + ref_channel_offset)//ns // ASD8 with thr 0x52 + +#define fish_proj_cut 20 + + + +// real cuts on selected data + +#define max_tot 1000000 // Muentz-Torte +#define t1_cut_L -2000 +#define t1_cut_R 2000 + + +// #define coincidence_rejection 7 +#define accept_hits_per_layer 20 + +#define enable_coincidence_rejection 0 + +#define enable_single_hits 0 +#define enable_one_hit_per_layer 1 +#define enable_two_to_one_hits 0 + + + +// TFile* tree_out; +std::map trig_no; +std::map data_tree; +Bool_t write_tree = false; + + + +Bool_t file_exists(TString fname){ + + fstream src_file(fname.Data()); + return src_file.good(); +} + +TString from_env(TString env_var,TString default_val){ + if(gSystem->Getenv(env_var)){ + return gSystem->Getenv(env_var); + } + return default_val; +} + + + +class SecondProc : public base::EventProc { + protected: + + std::string fTdcId; //!< tdc id where channels will be selected + + double fHits[8]; //!< 8 channel, abstract hits + + base::H1handle hNumHits; //!< histogram with hits number +// base::H2handle h2D; + +// base::H1handle totCh1; //!< histogram with hits number +// base::H1handle totCh2; //!< histogram with hits number + + + base::H1handle tot_h[CHANNELS]; + base::H1handle tot_untrig_h[CHANNELS]; + base::H1handle t1_h[CHANNELS]; + base::H1handle potato_h[CHANNELS]; + base::H1handle meta_potato_h; + base::H1handle meta_t1_h; + base::H1handle meta_tot_h; + base::H1handle meta_tot_2d; + base::H1handle meta_t1_2d; + base::H1handle coinc_matrix; +// base::H1handle meta_fish; +// base::H1handle meta_fish_proj; +// base::H1handle fishes[FISHES]; +// base::H1handle fish_proj[FISHES]; + base::H1handle efficiency_h; + base::H1handle ref_counts_h; + base::H1handle dut_counts_h; + + + int entry_chan; + int entry_ref_chan; + double entry_t1; + double entry_tot; + + + + + +// int evt_no; + + public: + SecondProc(const char* procname, const char* _tdcid) : + base::EventProc(procname), + fTdcId(_tdcid), + hNumHits(0) + { + printf("Create %s for %s\n", GetName(), fTdcId.c_str()); + + hNumHits = MakeH1("FineAll","Fine all", 1020, 0, 1020, "fine"); +// h2D = MakeH2("h2d","title", 100, -20, 20, 100, -20,20,"x;y"); +// totCh1 = MakeH1("totCh1","totCh1", 20000, -200, 200, "ns"); +// totCh2 = MakeH1("totCh2","totCh2", 20000, -200, 200, "ns"); + + + if(from_env("tree_out","false") == "true"){ + write_tree = true; + } + + trig_no[fTdcId] = 0; + data_tree[fTdcId] = new TTree((TString) fTdcId,"data recorded"); + data_tree[fTdcId]->Branch("trig_no",&trig_no[fTdcId]); + data_tree[fTdcId]->Branch("t1",&entry_t1); + data_tree[fTdcId]->Branch("tot",&entry_tot); + data_tree[fTdcId]->Branch("chan",&entry_chan); + data_tree[fTdcId]->Branch("ref_chan",&entry_ref_chan); + + + for( unsigned i=0; iSetDrawOption("P0"); + ((TH1F*) efficiency_h)->SetMarkerStyle(22); + ((TH1F*) efficiency_h)->GetXaxis()->SetNdivisions(55); + + coinc_matrix = MakeH2("coinc_matrix","coinc_matrix",12,-2.5,9.5,10,15-0.5,24+0.5, "channels 0-7;channels 16-23"); + //meta_fish = MakeH2("meta_fish","meta_fish",250,-300,200,200,-100,100, "T_A+T_B;T_B-T_A"); + + //meta_fish_proj = MakeH1("meta_fish_proj","meta_fish_proj",250,-300,200, "T_A+T_B;counts"); + + + + // enable storing already in constructor + SetStoreEnabled(); + } + + virtual void UserPostLoop(void) { + + static Int_t was_called_before = 0; + + cout << "--- User Post Loop " << fTdcId << endl; +// TFile* tree_out = new TFile( Form("tree_out_%s.root",fTdcId.c_str()) ,"RECREATE"); + + if(from_env("tree_out","false") == "true"){ + + cout << "write tree_out.root" << endl; + TFile* tree_out; + + + if(was_called_before){ + tree_out = new TFile("tree_out.root","UPDATE"); + } else { + tree_out = new TFile("tree_out.root","RECREATE"); + } + tree_out->cd(); + data_tree[fTdcId]->Write(); + tree_out->Write(); + tree_out->Close(); + delete tree_out; + } + was_called_before ++; + } + + + 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) + { +// printf("### DEBUG ###\n"); + for (unsigned n=0;n<8;n++) fHits[n] = 0.; + + hadaq::TdcSubEvent* sub = + dynamic_cast (ev->GetSubEvent(fTdcId)); + + if(VERBOSE) cout<< "tdc: " << fTdcId << " evt no: " << trig_no[fTdcId] << endl; + if (sub==0) return false; + +// printf("%s process sub %d %s\n", GetName(), sub->Size(), fTdcId.c_str()); + + + static float effective_spike_rejection = from_env("spike_rejection", TString::Itoa(spike_rejection,10) ).Atof(); + + +// static int ref_counts[CHANNELS]; +// static int dut_counts[CHANNELS]; +// static bool is_dut[CHANNELS]; + + + // this is only run once -- + static bool is_initialized=false; + if(not(is_initialized)){ + for( int i = 0; i<31; i++){ +// ref_counts[i] = 0; +// dut_counts[i] = 0; +// is_dut[i] = false; +// if((overlaps[i][0] >= 0) && (overlaps[i][1] >= 0)){ +// is_dut[i] = true; +// } + } + + + + + is_initialized = true; + } + // ------ + + double num(0), ch0tm(0), ch1tm(0), ch2tm(0), ch3tm(0); + double t1_candidate[CHANNELS]; + double t2_candidate[CHANNELS]; + double t1[CHANNELS]; + double t2[CHANNELS]; + bool got_rising[CHANNELS]; + bool got_falling[CHANNELS]; + bool got_real_hit[CHANNELS]; + double tot[CHANNELS]; + for (unsigned i=0; iSize();cnt++) { + const hadaq::TdcMessageExt& ext = sub->msg(cnt); + + unsigned chid = ( ext.msg().getHitChannel() ); + bool rising = ext.msg().isHitRisingEdge(); // use this line for rising edge first/positive pulses + + if (chid==0) { + ch0tm = ext.GetGlobalTime(); + got_real_hit[chid] = true; + t1[chid] = 0; + tot[chid] = 100e-9; + continue; + + } + + + // full time + double tm = ext.GetGlobalTime(); + if((chid) >= CHANNELS) {continue;} // channel out of range of analysis + if(rising){ + + + if( !(TAKE_FIRST_HIT && got_real_hit[chid]) ){ // block subsequent hits if TAKE_FIRST_HIT setting is active + if((( ((tm)*1e9) > t1_accept_L) && (((tm)*1e9) < t1_accept_R )) ) { // this condition sets another coincidence window, except for REFCHAN_A + got_rising[chid] = true; + got_falling[chid] = false; + t1_candidate[chid] = tm; + } + } + }else{ // if falling edge +// printf("got falling edge, ch %d\n",(chid)); + if(got_rising[chid]){ + if(not(got_falling[chid])){ + got_falling[chid] = true; + t2_candidate[chid] = tm; + Double_t candidate_tot_ns = (t2_candidate[chid] - t1_candidate[chid])*1e9; + + if( candidate_tot_ns > effective_spike_rejection || (chid==REFCHAN || candidate_tot_ns > spike_rejection_refchan) ){ + // hit is long enough not to be rejected + t1[chid] = t1_candidate[chid]; + t2[chid] = t2_candidate[chid]; + tot[chid] = t2[chid] - t1[chid]; + got_real_hit[chid] = true; + + // fill untriggered tot histogram + FillH1(tot_untrig_h[chid],tot[chid]*1e9); + } +// printf("got hit, ch %d, tot = %f ns\n",(chid), tot[chid]*1e9); + } + } + } + + } + + + + for( unsigned i=0; i t1_cut_L) && (t1_vs_ref < t1_cut_R) && (tot[i]*1e9 < max_tot) ) { + + // fill histograms + FillH1(tot_h[i],tot[i]*1e9); + FillH2(potato_h[i],t1_vs_ref ,tot[i]*1e9); + FillH1(t1_h[i],t1_vs_ref ); // without cuts +// if(t1_vs_ref < -200 && tot[i]*1e9 > 0 ) FillH1(t1_h[i],t1_vs_ref ); // with noise rejecting cuts + // if( tot[i]*1e9 > 50 ) FillH1(t1_h[i],t1_vs_ref ); // with noise rejecting cuts + + + if( i != 0 ) { + FillH2(meta_potato_h,t1_vs_ref,tot[i]*1e9); + FillH1(meta_tot_h,tot[i]*1e9); + FillH1(meta_t1_h,t1_vs_ref ); + FillH2(meta_tot_2d,tot[i]*1e9,i); + FillH2(meta_t1_2d,t1_vs_ref,i); + entry_chan = i; + entry_t1 = t1_vs_ref; + entry_tot = tot[i]*1e9; + if(write_tree){ + data_tree[fTdcId]->Fill(); + } + } + + // efficiency estimation ... this cell, cell #i, is a reference detector +// ref_counts[i]++; // count up reference counts +// FillH1(counts_h,i-0.5); + } + } + } + + + + for (int i = 1 ; iSetBinContent(i,((float) (((TH1F*) t1_h[i])->GetEntries()) )/((float) (((TH1F*) t1_h[0])->GetEntries()))); + ((TH1F*) efficiency_h)->SetBinContent(i,((float) (((TH1F*) t1_h[i])->Integral()) )/ 600. ); // fixed numer of pulses sent for each channel + // ((TH1F*) efficiency_h)->SetBinContent(i,((float) (((TH1F*) t1_h[i])->Integral()) )/((float) (((TH1F*) tot_h[i])->Integral()))); ; // normalize by number of signals in same channel without couts, as for almost each trigger a noise signal is measured + } + + + + +// if(got_real_hit[0]){ +// FillH1(totCh1,tot[0]*1e9); +// } +// if(got_real_hit[1]){ +// FillH1(totCh2,tot[1]*1e9);ref_counts[i] +// } + +// FillH1(hNumHits, num); + + +// draw_and_save((TH2F*) meta_fish, "meta_fish","./","colz"); + +// tree_out->cd(); +// data_tree[fTdcId]->Write(); + trig_no[fTdcId]++; + + return true; + } + + +}; + + +void second() +{ + //hadaq::TdcProcessor::SetDefaults(700); +// tree_out = new TFile("./tree_out.root","RECREATE"); +// new SecondProc("Sec_1130", "TDC_1130"); +// new SecondProc("Sec_0352", "TDC_0353"); + new SecondProc("Sec_0350", "TDC_0350"); + new SecondProc("Sec_0353", "TDC_0353"); +// tree_out->Write(); +// tree_out->Close(); +} + diff --git a/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/workdir/start.sh b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/workdir/start.sh new file mode 100755 index 0000000..0914180 --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_15.0_stable_2018-03-01/workdir/start.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +echo "container started" + +echo "create main tmux session" + +echo "run /conf/conf.sh" +. /conf/conf.sh + +cd /workdir +tmux new -d -s main + + + +tmux link-window -s cts_gui:cts_gui -t main +tmux link-window -s vnc:vnc -t main + + +tmux new-window -t main -n "dabc" "dabc_exe TdcEventBuilder_noHLD.xml;/bin/bash" + + +#tmux new-window -t main -n "go4" "rm *.root; go4 0350_meta.hotstart;/bin/bash" +tmux new-window -t main -n "go4_ana" "rm *.root; tree_out=false go4analysis -stream localhost:6790 -http localhost:8080;/bin/bash" + +# tmux new-window -t main -n "htop" "htop;/bin/bash" +tmux new-window -t main -n "info" "cat /conf/conf_log.txt; cat info.txt; /bin/bash" +tmux new-window -t main -n "PT_ctrl" "cd /workdir/pasttrec_ctrl; /bin/bash" +tmux new-window -t main -n "new" "/bin/bash" +tmux new-window -t main -n "new" "/bin/bash" +tmux new-window -t main -n "new" "/bin/bash" +tmux new-window -t main -n "new" "/bin/bash" +tmux new-window -t main -n "new" "/bin/bash" +tmux new-window -t main -n "x11_apps" "lxpanel& sleep 10; firefox localhost:8080& /bin/bash" +tmux select-window -t main:info + + +tmux a -t main + + + + +echo "drop user to shell" +/bin/bash + +echo "terminate container" diff --git a/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/Dockerfile b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/Dockerfile new file mode 100644 index 0000000..8071adf --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/Dockerfile @@ -0,0 +1,112 @@ +FROM opensuse:42.3 + + +################################################## +## Go4 + dabc + root ## +################################################## + + + +RUN zypper ref + +RUN zypper --non-interactive in \ + wget curl \ + tar zlib \ + cmake gcc gcc-c++ \ + libX11-devel libXext-devel libXft-devel libXpm-devel\ + git subversion \ + libqt4-devel\ + git bash cmake gcc-c++ gcc binutils \ + xorg-x11-libX11-devel xorg-x11-libXpm-devel xorg-x11-devel \ + xorg-x11-proto-devel xorg-x11-libXext-devel \ + gcc-fortran libopenssl-devel \ + pcre-devel Mesa glew-devel pkg-config libmysqlclient-devel \ + fftw3-devel libcfitsio-devel graphviz-devel \ + libdns_sd avahi-compat-mDNSResponder-devel openldap2-devel \ + python-devel libxml2-devel krb5-devel gsl-devel libqt4-devel \ + glu-devel \ + xterm screen xvfb-run x11vnc openbox \ + boost-devel + +RUN svn co https://subversion.gsi.de/dabc/trb3 + +RUN cd trb3; make -j4; cat $(find . -iname "makelog.txt") +### root, go4, dabc and stream are successfully installed! + + + + +################################################## +## trbnet + daqtools ## +################################################## + + +RUN zypper --non-interactive in \ + vim \ + dhcp-server\ + rpcbind \ + gnuplot \ + ImageMagick \ + perl-XML-LibXML \ + glibc-locale \ + tmux \ + xorg-x11-Xvnc \ + emacs \ + htop \ + ncdu \ + psmisc \ + python-jsonpath-rw \ + python-pip + +RUN pip install --upgrade pip; pip install pandas + +RUN cpan Data::TreeDumper Date::Format File::chdir + +RUN zypper --non-interactive in \ + libtirpc-devel + +RUN git clone git://jspc29.x-matter.uni-frankfurt.de/projects/trbnettools.git;\ + cd /trbnettools; \ + git checkout 02cf + + +RUN cd /trbnettools/libtrbnet_perl; \ + perl Makefile.PL; \ + cd /trbnettools; \ + make clean; + +RUN cd /trbnettools; \ + make TRB3=1 + +RUN cd /trbnettools; \ + make TRB3=1 install + +RUN echo "/trbnettools/liblocal" >> /etc/ld.so.conf.d/trbnet.conf;\ + ldconfig -v + +ENV PATH=$PATH:/trbnettools/bin + +RUN git clone git://jspc29.x-matter.uni-frankfurt.de/projects/daqtools.git + +RUN cd daqtools/xml-db; \ + ./xml-db.pl + +################################################## +## patches + misc ## +################################################## + +### replace httpi with a modified version, because the httpi in daqtools won't run as root +COPY build_files/httpi /daqtools/web/httpi + +RUN . /trb3/trb3login + +RUN cd /trb3/; . /trb3/trb3login; make -j4 update + +## 2019-02-11 - - fix strange dabc error +RUN cd /trb3/; . /trb3/trb3login; make -j4 update + +RUN zypper --non-interactive in \ + firefox \ + lxpanel + +RUN pip install prettytable python2-pythondialog diff --git a/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/build.sh b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/build.sh new file mode 100755 index 0000000..abffd2d --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/build.sh @@ -0,0 +1,6 @@ + +name=$(basename $(pwd)) + +docker build -t $name . || exit + + diff --git a/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/build_and_run.sh b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/build_and_run.sh new file mode 100755 index 0000000..377875b --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/build_and_run.sh @@ -0,0 +1,9 @@ + +name=$(basename $(pwd)) + +docker build -t $name . || exit + +docker run --net host -v $(pwd)/conf:/conf -v $(pwd)/workdir:/workdir --rm -it \ +--name $name \ +$name /workdir/start.sh + diff --git a/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/build_and_shell.sh b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/build_and_shell.sh new file mode 100755 index 0000000..74ee374 --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/build_and_shell.sh @@ -0,0 +1,9 @@ + +name=$(basename $(pwd)) + +docker build -t $name . || exit + +docker run --net host -v $(pwd)/conf:/conf -v $(pwd)/workdir:/workdir --rm -it \ +--name $name \ +$name /bin/bash + diff --git a/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/build_files/httpi b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/build_files/httpi new file mode 100755 index 0000000..06f15cc --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/build_files/httpi @@ -0,0 +1,538 @@ +#!/usr/bin/perl +use POSIX qw(SIGALRM SIGTERM sigaction); + +use lib "./"; +use lib "./include"; +use Digest::SHA::PurePerl qw(sha1_base64); + + +$VERSION = "1.7 (Demonic/Linux)"; + +# HTTPi Hypertext Tiny Truncated Process Implementation +# Copyright 1999-2010 Cameron Kaiser and Contributors # All rights reserved +# Please read LICENSE # Do not strip this copyright message. + +############################################################### +# WHITE HATS ONLY BELOW THIS POINT -- SEE DOCUMENTATION FIRST # +############################################################### + +%system_content_types = + ("html" => "text/html", + "htm" => "text/html", + "txt" => "text/plain", + "xml" => "text/xml", + "xsl" => "text/xml", + "xhtml" => "application/xhtml+xml", + "css" => "text/css", + "gif" => "image/gif", + "jpeg" => "image/jpeg", + "jpg" => "image/jpeg", + "bmp" => "image/bmp", + "png" => "image/png", + "tif" => "image/tiff", + "tiff" => "image/tiff", + "ico" => "image/x-icon", + "svg" => "image/svg+xml", + "svgz" => "image/svg+xml", + "wbmp" => "image/vnd.wap.wbmp", + "wbm" => "image/vnd.wap.wbmp", + "xbm" => "image/x-xbitmap", + "mp3" => "audio/x-mpeg", + "wma" => "audio/x-ms-wma", + "wav" => "audio/x-wav", + "au" => "audio/basic", + "aif" => "audio/x-aiff", + "aiff" => "audio/x-aiff", + "ogg" => "audio/x-ogg", + "oga" => "audio/x-ogg", + "mid" => "audio/midi", + "wma" => "audio/x-ms-wma", + "mpeg" => "video/mpeg", + "mpg" => "video/mpeg", + "aac" => "audio/aac", + "ogv" => "video/x-ogg", + "ogx" => "application/x-ogg", + "avi" => "video/x-msvideo", + "wmv" => "video/x-ms-wmv", + "asf" => "video/x-ms-asf", + "mov" => "video/quicktime", + "mp4" => "video/mp4", + "rv" => "video/vnd.m-realvideo", + "rm" => "application/vnd.m-realmedia", + "ra" => "audio/vnd.m-realaudio", + "ram" => "audio/vnd.m-realaudio", + "pdf" => "application/pdf", + "fdf" => "application/vnd.fdf", + "class" => "application/octet-stream", + "jar" => "application/octet-stream", + "js" => "application/x-javascript", + "lnk" => "application/x-hyperlink", + "prg" => "application/x-c64-prg-binary", + "d64" => "application/x-c64-disk-image", + "tar" => "application/x-tar", + "sit" => "application/x-stuffit", + "Z" => "application/x-compress", + "gz" => "application/x-gzip", + "dmg" => "application/octet-stream", + "img" => "application/octet-stream", + "lzh" => "application/octet-stream", + "lha" => "application/octet-stream", + "exe" => "application/octet-stream", + "com" => "application/octet-stream", + "zip" => "application/x-zip-compressed", + "hqx" => "application/x-binhex", + "swf" => "x-shockwave-flash", + "flv" => "video/x-flv", + + "bin" => "application/octet-stream"); + +# comment in to enable logs +#$logfile = "./access.log"; +$path = "./htdocs"; +$sockaddr = 'S n a4 x8'; + +$server_host = $ARGV[0]; +$server_port = $ARGV[1]; + +die("$0 [host] [port] required. got >$server_host< >$server_port<") unless ($server_host and $server_port); + +%content_types = + ("html" => "text/html", + "htm" => "text/html", + "shtml" => "text/html" + ); +%restrictions = ( + "/nw" => "^10\.##^Mozilla#MSIE", + "/status" => "####voyeur:daNrZR3TcSwD2", + "/" => "###(NPBot|WebZIP|HTTrack|eCatch|Offline Explorer|UdmSearch|WebCopier|internetseer|MSIECrawler|SuperBot|LinkWalker|Tutorial Crawler|WebReaper)", + ); + # See documentation for interpreting this string. + +$headers = <<"EOF"; +Server: TRB3-DAQ based on HTTPi/$VERSION +MIME-Version: 1.0 +EOF + + +%content_types = (%system_content_types, %content_types); +undef %system_content_types; + +#if ($pid = fork()) { exit; } +$0 = "dhttpi: binding port ..."; +$bindthis = pack($sockaddr, 2, $server_port, pack('C4', 0, 0, 0, 0)); +socket(S, 2, 1, 6); +setsockopt(S, 1, 2, 1); +bind(S, $bindthis) || die("$0: while binding port $server_port:\n\"$!\"\n"); +listen(S, 128); +$0 = "dhttpi: connected and waiting ANY:$server_port"; + +$statiosuptime = time(); + +sub sock_to_host { + return ($cache_hn, $cache_port, $cache_ip) + if (length($cache_ip)); + + return (undef, undef, undef) if (!$sock); + my($AFC, $cache_port, $thataddr, $zero) = unpack($sockaddr, $sock); + $cache_ip = join('.', unpack("C4", $thataddr)); + $cache_hn = + gethostbyaddr($thataddr, 2) || + $cache_ip; + return ($cache_hn, $cache_port, $cache_ip); +} + + +sub htsponse { + ($currentcode, $currentstring) = (@_); + return if (0+$httpver < 1); + my($what) = <<"EOF"; +HTTP/$httpver $currentcode $currentstring +${headers}Date: $rfcdate +EOF + $what =~ s/\n/\r\n/g; + print STDOUT $what; + &hthead("Connection: close") if (0+$httpver > 1); +} + +sub hthead { + my($header, $term) = (@_); + return if (0+$httpver < 1); + print STDOUT "$header\r\n" , ($term) ? "\r\n" : ""; +} + +sub htcontent { + my($what, $ctype, $mode) = (@_); + ($contentlength) = $mode || length($what); + &hthead("Content-Length: $contentlength"); + &hthead("Content-Type: $ctype", 1); + return if ($method eq 'HEAD' || $mode); + print STDOUT $what; +} + +sub log { + if ($logfile && open(J, ">>$logfile")) { + my $q = $address . (($variables) ? "?$variables" : ""); + $contentlength += 0; + $contentlength = 0 if ($method eq 'HEAD'); + my ($hostname, $port, $ip) = &sock_to_host(); + $hostname ||= "-"; + $httpuser ||= "-"; + print J <<"EOF"; +$hostname - $httpuser [$date] "$method $q HTTP/$httpver" $currentcode $contentlength "$httpref" "$httpua" +EOF + close(J); + } +} + + +sub bye { exit; } +sub byebye { kill(9,$secondary_pid) if ($secondary_pid); exit; } + +sub dead { + &htsponse(500, "Server Error"); + &hterror("Server Error", <<"EOF"); +The server cannot comply with your request for resource $::address. +Please attempt to notify the administrators. +

Useful(?) debugging information: +

+@_
+
+EOF + &log; exit; +} + +sub defaultsignals { + $SIG{'__DIE__'} = \&dead; + sigaction SIGALRM, new POSIX::SigAction \&bye + or die "sigalrm failed: $!\n"; + sigaction SIGTERM, new POSIX::SigAction \&byebye + or die "sigterm failed: $!\n"; +} +&defaultsignals; + +sub alarmsignals { + undef $SIG{'__DIE__'}; + sigaction SIGALRM, new POSIX::SigAction sub { die; } + or die "sigalrm failed: $!\n"; +} + +sub master { + $0 = "dhttpi: handling request"; +$sock = getpeername(STDIN); +$rfcdate = &rfctime(scalar gmtime, 1); +$date = scalar localtime; +($dow, $mon, $dt, $tm, $yr) = ($date =~ + m/(...) (...) (..) (..:..:..) (....)/); +$dt += 0; +$dt = substr("0$dt", length("0$dt") - 2, 2); +$date = "$dt/$mon/$yr:$tm +0000"; + +select(STDOUT); $|=1; $address = 0; +alarm 5; +while () { + if(/^([A-Z]+)\s+([^\s]+)\s+([^\s\r\l\n]*)/) { + $method = $1; + $address = $2; + $httpver = $3; + $httpref = ''; + $httpua = ''; + $httpver = ($httpver =~ m#HTTP/([0-9]\.[0-9]+)#) ? + ($1) : (0.9); + $address =~ s#^http://[^/]+/#/#; + $0 = $execstring = "dhttpi: $method $address $httpver"; + next unless ($httpver < 1); + } else { + s/[\r\l\n\s]+$//; + (/^Host:\s+(.+)/i) && ($httphost = substr($1, 0, 255)) + && ($httphost =~ s/:\d+$//); + (/^Referer:\s+(.+)/i) && ($httpref = substr($1, 0, 1024)); + (/^User-agent:\s+(.+)/i) && ($httpua = substr($1, 0, 1024)); + (/^Content-length:\s+(\d+)/i) && + ($ENV{'CONTENT_LENGTH'} = $httpcl = 0+$1); + (/^Content-type:\s+(.+)/i) && + ($ENV{'CONTENT_TYPE'} = $httpct = substr($1, 0, 255)); + (/^Expect:\s+/) && ($expect = 1); + (/^Cookie:\s+(.+)/i) && + ($ENV{'HTTP_COOKIE'} = substr($1, 0, 16384)); + (/^Authorization:\s+Basic (.+)/i) && + ($httprawu = substr($1, 0, 1024)); + (/^Range:\s+(.+)/i) && + ($ENV{'CONTENT_RANGE'} = substr($1, 0, 255)); + (/^If-Modified-Since:\s+(.+)/i) && + ($modsince = $ENV{'HTTP_IF_MODIFIED_SINCE'} = + substr($1, 0, 255)); + (/^Accept:\s+(.+)/i) && + ($ENV{'HTTP_ACCEPT'} = substr($1, 0, 255)); + (/^Accept-([a-zA-Z0-9]+):\s+(.+)/i) && + ($ENV{'HTTP_ACCEPT_'.uc(substr($1, 0, 16))} = + substr($2, 0, 255)); + (/^X-Requested-With:\s+(.+)/i) && + ($ENV{'HTTP_X_REQUESTED_WITH'} = substr($1, 0, 1024)); + + (/^Origin:\s+(.+)/i) && + ($ENV{'HTTP_ORIGIN'} = substr($1, 0, 1024)); + (/^Upgrade:\s+(.+)/i) && + ($ENV{'HTTP_UPGRADE'} = substr($1, 0, 1024)); + (/^Sec-WebSocket-Protocol:\s+(.+)/i) && + ($ENV{'WEBSOCKET_PROTOCOL'} = substr($1, 0, 1024)); + (/^Sec-WebSocket-Version:\s+(-?\d+)/i) && + ($ENV{'WEBSOCKET_VERSION'} = substr($1, 0, 8)); + (/^Sec-WebSocket-Extensions:\s+(-?\d+)/i) && + ($ENV{'WEBSOCKET_EXTENSIONS'} = substr($1, 0, 1024)); + (/^Sec-WebSocket-Key:\s+(\S+)/i) && + ($ENV{'WEBSOCKET_KEY'} = substr($1, 0, 1024)); + + next unless (/^$/); + } + if ($expect) { + &htsponse(417, "Expectation Failed"); + &hterror("Expectation Failed", + "The server does not support this method."); + &log; exit; + } + if (!length($address) || (0+$httpver > 1 && !$httphost)) { + &htsponse(400, "Bad Request"); + &hterror("Bad Request", + "The server cannot understand your request."); + &log; exit; + } + if ($method !~ /^(GET|HEAD|POST)$/) { + &htsponse(501, "Not Implemented"); + &hterror("Not Implemented", + "Only GET, HEAD and POST are supported."); + &log; exit; + } + + + if ($ENV{'HTTP_UPGRADE'} eq 'websocket') { + if ($method ne "GET" || !$ENV{'WEBSOCKET_KEY'}) { + &htsponse(400, "Bad request"); + &hterror("Bad request", + "Illegal websocket opening handshake"); + &log; exit; + } + + $ENV{'WEBSOCKET_ACCEPT'} = + sha1_base64($ENV{'WEBSOCKET_KEY'} . "258EAFA5-E914-47DA-95CA-C5AB0DC85B11") . "="; + + + } + + + + ($address, $variables) = split(/\?/, $address); + $address =~ s/%([0-9a-fA-F]{2})/pack("H2", $1)/eg; + $address=~ s#^/?#/#; + 1 while $address =~ s#/\.(/|$)#\1#; + 1 while $address =~ s#/[^/]*/\.\.(/|$)#\1#; + 1 while $address =~ s#^/\.\.(/|$)#\1#; + $fail = 0; + J: foreach(sort { length $a <=> length $b } + keys %restrictions) { + next if ($address !~ /^$_/); + ($allowip, $denyip, $allowua, $denyua, $auser) = + split(/#/, $restrictions{$_}); + if ($allowip || $denyip) { + ($hostname, $port, $ip) = &sock_to_host(); + ($allowip && $ip !~ /$allowip/) && ($fail = 1, + last J); + ($denyip && $ip =~ /$denyip/) && ($fail = 1, + last J); + } + ($allowua && $httpua !~ /$allowua/) && + ($fail = 2, last J); + ($denyua && $httpua =~ /$denyua/) && + ($fail = 2, last J); + } + if ($fail) { + &htsponse(403, "Forbidden"); + if ($fail == 1) { + &hterror("Forbidden (Client Disallowed)", <<"EOF"); +Your network address ($ip) is not allowed to access this resource. +EOF + &log; exit; + } else { + &hterror("Forbidden (Browser Disallowed)", <<"EOF"); +The browser you are using ($httpua) is not capable of or +is not allowed access to this resource. +EOF + &log; exit; + } + } + if ($auser) { + $httprawu =~ tr#A-Za-z0-9+/##cd; + $httprawu =~ tr#A-Za-z0-9+/# -_#; + $httprawu = unpack("u", pack("c", 32+0.75*length($httprawu)) + . $httprawu); + ($httpuser, $httppw) = split(/:/, $httprawu); + $fail = 1; + foreach $user (split(/,/, $auser)) { + ($user, $pw) = split(/:/, $user); + ($fail = 0, last) if ($user eq $httpuser && + crypt($httppw, substr($pw, 0, 2)) eq $pw); + } + if ($fail) { + $httpuser = ''; + &htsponse(401, "Authorization Required"); + &hthead("WWW-Authenticate: Basic realm=\"$address\""); + &hterror("Authorization Required", <<"EOF"); +You must provide a username and password to use this resource. Either you +entered this information incorrectly, or your browser does not know how to +present the credentials required. +EOF + &log; exit; + } + } + + alarm 0; + + + + + $raddress = "$path$address" + ; + 1 while ($raddress =~ s#//#/#); + &hterror301("http://$server_host:$server_port$address/") + if ($address !~ m#/$# && -d $raddress); + $raddress = (-r "${raddress}index.shtml") ? + "${raddress}index.shtml" : "${raddress}index.html" + if (-d $raddress); + IRED: ($hostname, $port, $ip) = &sock_to_host(); + if(!sysopen(S, $raddress, 0)) { &hterror404; } else { + if ((-x $raddress) + ) { + $currentcode = 100; &nsecmodel; + $ENV{'REQUEST_METHOD'} = $method; + $ENV{'SERVER_NAME'} = $server_host; + $ENV{'SERVER_PROTOCOL'} = "HTTP/$httpver"; + $ENV{'SERVER_SOFTWARE'} = "HTTPi/$VERSION"; + $ENV{'SERVER_PORT'} = "$server_port"; + $ENV{'SERVER_URL'} = "http://$server_host:$server_port/"; + $ENV{'SCRIPT_FILENAME'} = $raddress; + $ENV{'SCRIPT_NAME'} = $address; + $ENV{'REMOTE_HOST'} = $hostname; + $ENV{'REMOTE_ADDR'} = $ip; + $ENV{'REMOTE_PORT'} = $port; + $ENV{'QUERY_STRING'} = $variables; + $ENV{'HTTP_USER_AGENT'} = $httpua; + $ENV{'HTTP_REFERER'} = $httpref; + undef $pid; + if ($pid = fork()) { kill 15, $$; exit; } + elsif (!defined($pid)) { + die + "temporary(?) fork error, please retry request: $!\n"; + } else { + require $raddress; + exit; + } + } + ($x,$x,$x,$x,$x,$x,$x,$length,$x,$mtime) = stat(S); + $ctype = 0; + foreach(keys %content_types) { + if ($raddress =~ /\.$_$/i) { + $ctype = $content_types{$_}; + } + } + $mtime = &rfctime($mtime); +SERVEIT: + if ($mtime eq $modsince) { + &htsponse(304, "Not Modified"); + &hthead("Last-Modified: $mtime", 1); + &log; exit; + } + $ctype ||= 'text/plain'; + if ($pid = fork()) { kill 15, $$; exit; } + $contentlength ||= $length; + &htsponse(200, "OK"); + &hthead("Last-Modified: $mtime"); + &htcontent("", $ctype, $length); + &nsecmodel; + $bytecount = 0; + unless ($method eq 'HEAD') { + while(!eof(S)) { + read(S, $q, 32768); + print STDOUT $q; + $bytecount += 32768; + $0 = $execstring . + " ($bytecount bytes sent)"; + } + } + alarm 0; + } + exit; +} + +exit; +} + + +sub nsecmodel { + &log; + ($x,$x,$x,$x,$uid,$gid) = stat(S); + #(!$uid || !$gid || $uid < 2 ) && +# die "resource is root-owned, secured or not stat-able\n"; +# if (!$<) { +# ($) = "$gid $gid") || die "can't set egid to $gid"; +# ($> = $uid) || die "can't set euid to $uid"; +# ($( = "$gid $gid") || die "can't set rgid to $gid"; +# ($< = $uid) || die "can't set ruid to $uid"; +# } +} + +sub rfctime { + my $mtime = shift; + $mtime = (scalar gmtime $mtime) if (!(shift)); + my ($dow, $mon, $dt, $tm, $yr) = + ($mtime =~ m/(...) (...) (..) (..:..:..) (....)/); + $dt += 0; $yr += 0; + return "$dow, $dt $mon $yr $tm GMT"; +} + +sub hterror { + my($errstr, @expl) = (@_); + &htcontent(<<"EOF", "text/html"); + + +

$errstr

+@expl +
+
httpi/$VERSION +by Cameron Kaiser
+ + +EOF + } + +sub hterror404 { + &htsponse(404, "Not Found"); + &hterror("Not Found", + "The resource $address was not found on this system."); + &log; exit; +} + +sub hterror301 { + &htsponse(301, "Moved Permanently"); + &hthead("Location: @_"); + &hterror("Resource Moved Permanently", + "This resource has moved here."); + &log; exit; +} + + +$0 = "dhttpi: on ANY:$server_port, ready!"; +$master_pid = $$; +for (;;) { + if ($secondary_pid = fork()) { + waitpid($secondary_pid, 0); + $0 = "dhttpi: on ANY:$server_port, last request " . + scalar localtime; + } else { + $0 = "dhttpi (child of $master_pid): waiting for connect"; + $addr=accept(NS,S); + open(STDIN, "<&NS"); + open(STDOUT, ">&NS"); + &defaultsignals; + &master; + exit; + } +} diff --git a/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/conf/.register_configgbe.db.swp b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/conf/.register_configgbe.db.swp new file mode 100644 index 0000000..78f7831 Binary files /dev/null and b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/conf/.register_configgbe.db.swp differ diff --git a/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/conf/addresses.sh b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/conf/addresses.sh new file mode 100755 index 0000000..e935b37 --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/conf/addresses.sh @@ -0,0 +1,10 @@ +#!/bin/bash + + +trbcmd s 0x7100000390255228 0x00 0x0350 +trbcmd s 0x8c0000039025fa28 0x01 0x0351 +trbcmd s 0xb00000039053e328 0x02 0x0352 +trbcmd s 0x790000039053dc28 0x03 0x0353 +trbcmd s 0x920000039053d928 0x05 0xc035 +echo "FPGAs after addressing" +trbcmd i 0xffff diff --git a/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/conf/conf.sh b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/conf/conf.sh new file mode 100755 index 0000000..3bc6482 --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/conf/conf.sh @@ -0,0 +1,100 @@ +#!/bin/bash + +cd /conf + + + +echo "configure container" + +export TRB3_PORT=35 +export DAQOPSERVER=localhost:$TRB3_PORT +export TRB3_SERVER=192.168.4.240 +export CTS_GUI_PORT=1148 +export CTS_ENDPOINT=0xc035 +export DISPLAY=:2 # go4 window will be sent to $DISPLAY, if provide_vnc == yes , then it will be this x11 display + +export PULSER=192.168.103.74 + +> conf_log.txt + +provide_dhcp=yes +#edit conf/dhcpd.conf, enter your trb3 MAC address ### +provide_trbnetd=yes + +provide_cts_gui=yes + +provide_vnc=yes +vnc_password= +vnc_port=5902 +vnc_geometry=1500x1024 + + +# tmux new-session -d -s x11vnc -n x11vnc "x11vnc -forever -create -rfbport 5902 #(nopasswd)" + +# set paths for go4/dabc/stream +. /trb3/trb3login + + + +### no need to touch the rest of the file ### + + echo ... >> conf_log.txt + echo DAQOPSERVER=$DAQOPSERVER >> conf_log.txt + echo >> conf_log.txt + +if [ $provide_dhcp == "yes" ]; then + echo starting dhcp server + cp dhcpd.conf /etc/dhcpd.conf + > /tmp/dhcp_leasefile + dhcpd -lf /tmp/dhcp_leasefile + echo ... >> conf_log.txt + echo dhcp server started >> conf_log.txt + echo using config file /conf/dhcpd.conf >> conf_log.txt + echo >> conf_log.txt +fi + +if [ $provide_trbnetd == "yes" ]; then + trbnetd -i $TRB3_PORT + echo ... >> conf_log.txt + echo started trbnetd >> conf_log.txt + echo TRB3_SERVER=$TRB3_SERVER >> conf_log.txt + echo port $TRB3_PORT >> conf_log.txt + echo >> conf_log.txt +fi + +if [ $provide_cts_gui == "yes" ]; then +# screen -S cts_gui -d -m ./start_cts_gui.sh + tmux new-session -d -s cts_gui -n cts_gui "cd /daqtools/web; perl ./cts_gui --endpoint $CTS_ENDPOINT --quiet --noopenxterm --port $CTS_GUI_PORT" +# tmux new-window -t main:1 -n "cts_gui" "cd /daqtools/web; perl ./cts_gui --endpoint $CTS_ENDPOINT --quiet --noopenxterm --port $CTS_GUI_PORT" + echo ... >> conf_log.txt + echo started cts_gui with following parameters:>> conf_log.txt + echo --endpoint $CTS_ENDPOINT >> conf_log.txt + echo --port $CTS_GUI_PORT >> conf_log.txt + echo >> conf_log.txt +fi + +if [ $provide_vnc == "yes" ]; then + mkdir -p $HOME/.vnc/ + echo $vnc_password | vncpasswd -f > $HOME/.vnc/passwd + tmux new-session -d -s vnc -n vnc "echo starting vnc server on port $vnc_port for display $DISPLAY; vncserver $DISPLAY -rfbauth $HOME/.vnc/passwd -rfbport $vnc_port -geometry $vnc_geometry ;/bin/bash" + + echo ... >> conf_log.txt + echo "started vnc server (e.g. for Go4 window)" >> conf_log.txt + echo port=$vnc_port >> conf_log.txt + echo DISPLAY=$DISPLAY >> conf_log.txt + echo password=$vnc_password >> conf_log.txt + echo >> conf_log.txt + echo connect with: vncviewer localhost:$vnc_port >> conf_log.txt + echo >> conf_log.txt +fi + +./addresses.sh + +/daqtools/tools/loadregisterdb.pl register_configgbe.db +/daqtools/tools/loadregisterdb.pl register_configgbe_ip.db +sleep 1 +./conf_cts.sh +./conf_tdcs.sh + + +echo "done" diff --git a/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/conf/conf_cts.sh b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/conf/conf_cts.sh new file mode 100755 index 0000000..04cefd1 --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/conf/conf_cts.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +# CTS Configuration dump +# generated: 2019-02-05 15:10 +# CTS Compile time: 2019-01-21 14:47 +# +# trbcmd Dev. Reg. Value +trbcmd setbit 0xc035 0xa00c 0x80000000 # Disable all triggers +trbcmd w 0xc035 0xa008 0xffffffff # cts_fsm_limits: ro=65535, td=65535 +trbcmd w 0xc035 0xa009 0x00000001 # cts_readout_config: + # channel_cnt=false, idle_dead_cnt=false, input_cnt=true + # timestamp=false, trg_cnt=false +trbcmd w 0xc035 0xa00c 0x80000400 # cts_throttle: enable=true, stop=false, threshold=0 +trbcmd w 0xc035 0xa00d 0x00000001 # cts_eventbuilder: + # cal_eb=0, mask=0000 0000 0000 0001, rr_interval=0 + # use_cal_eb=false +trbcmd w 0xc035 0xa101 0xffff0400 # trg_channel_mask: edge=1111 1111 1111 1111, mask=0000 0100 0000 0000 +trbcmd w 0xc035 0xa124 0x00000000 # trg_input_config0: delay=0, invert=false, override=off, spike_rej=0 +trbcmd w 0xc035 0xa125 0x00000000 # trg_input_config1: delay=0, invert=false, override=off, spike_rej=0 +trbcmd w 0xc035 0xa126 0x00000000 # trg_input_config2: delay=0, invert=false, override=off, spike_rej=0 +trbcmd w 0xc035 0xa127 0x00000000 # trg_input_config3: delay=0, invert=false, override=off, spike_rej=0 +trbcmd w 0xc035 0xa128 0x00000000 # trg_input_config4: delay=0, invert=false, override=off, spike_rej=0 +trbcmd w 0xc035 0xa129 0x00000000 # trg_input_config5: delay=0, invert=false, override=off, spike_rej=0 +trbcmd w 0xc035 0xa12a 0x00000000 # trg_input_config6: delay=0, invert=false, override=off, spike_rej=0 +trbcmd w 0xc035 0xa13b 0x000f0000 # trg_coin_config0: + # coin_mask=0000 0000, inhibit_mask=0000 0000 + # window=15 +trbcmd w 0xc035 0xa13c 0x000f0000 # trg_coin_config1: + # coin_mask=0000 0000, inhibit_mask=0000 0000 + # window=15 +trbcmd w 0xc035 0xa13e 0x00000000 # trg_input_mux0: input=extclk[0] +trbcmd w 0xc035 0xa13f 0x00000001 # trg_input_mux1: input=extclk[1] +trbcmd w 0xc035 0xa140 0x00000002 # trg_input_mux2: input=trgext[2] +trbcmd w 0xc035 0xa141 0x00000003 # trg_input_mux3: input=trgext[3] +trbcmd w 0xc035 0xa142 0x00000004 # trg_input_mux4: input=jeclin[0] +trbcmd w 0xc035 0xa143 0x00000005 # trg_input_mux5: input=jeclin[1] +trbcmd w 0xc035 0xa144 0x00000006 # trg_input_mux6: input=jeclin[2] +trbcmd w 0xc035 0xa146 0x00000000 # trg_addon_output_mux0: input=itc[0] +trbcmd w 0xc035 0xa147 0x00000001 # trg_addon_output_mux1: input=itc[1] +trbcmd w 0xc035 0xa148 0x00000002 # trg_addon_output_mux2: input=itc[2] +trbcmd w 0xc035 0xa149 0x00000003 # trg_addon_output_mux3: input=itc[3] +trbcmd w 0xc035 0xa14a 0x00000004 # trg_addon_output_mux4: input=itc[4] +trbcmd w 0xc035 0xa14b 0x00000005 # trg_addon_output_mux5: input=itc[5] +trbcmd w 0xc035 0xa14c 0x00000006 # trg_addon_output_mux6: input=itc[6] +trbcmd w 0xc035 0xa14d 0x00000007 # trg_addon_output_mux7: input=itc[7] +trbcmd w 0xc035 0xa14f 0x00010000 # trg_periph_config0: mask=0001 0000 0000 0000 0000 +trbcmd w 0xc035 0xa150 0x00000000 # trg_periph_config1: mask=0000 0000 0000 0000 0000 +trbcmd w 0xc035 0xa151 0x00000000 # trg_periph_config2: mask=0000 0000 0000 0000 0000 +trbcmd w 0xc035 0xa152 0x00000000 # trg_periph_config3: mask=0000 0000 0000 0000 0000 +trbcmd w 0xc035 0xa154 0x000061a7 # trg_pulser_config0: low_duration=24999 +trbcmd w 0xc035 0xa155 0x00000003 # trg_pulser_config1: low_duration=3 +trbcmd w 0xc035 0xa157 0x00000000 # trg_random_pulser_config0: threshold=0 +trbcmd w 0xc035 0xa159 0x1111111d # _trg_trigger_types0: + # type0=0xd_tdc_calibration_trigger, type1=0x1_physics_trigger + # type2=0x1_physics_trigger, type3=0x1_physics_trigger + # type4=0x1_physics_trigger, type5=0x1_physics_trigger + # type6=0x1_physics_trigger, type7=0x1_physics_trigger +trbcmd w 0xc035 0xa15a 0x11111111 # _trg_trigger_types1: + # type10=0x1_physics_trigger, type11=0x1_physics_trigger + # type12=0x1_physics_trigger, type13=0x1_physics_trigger + # type14=0x1_physics_trigger, type15=0x1_physics_trigger + # type8=0x1_physics_trigger, type9=0x1_physics_trigger +trbcmd clearbit 0xc035 0xa00c 0x80000000 # Enable all triggers + diff --git a/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/conf/conf_log.txt b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/conf/conf_log.txt new file mode 100644 index 0000000..d3ca223 --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/conf/conf_log.txt @@ -0,0 +1,25 @@ +... +DAQOPSERVER=localhost:35 + +... +dhcp server started +using config file /conf/dhcpd.conf + +... +started trbnetd +TRB3_SERVER=192.168.4.240 +port 35 + +... +started cts_gui with following parameters: +--endpoint 0xc035 +--port 1148 + +... +started vnc server (e.g. for Go4 window) +port=5902 +DISPLAY=:2 +password= + +connect with: vncviewer localhost:5902 + diff --git a/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/conf/conf_tdcs.sh b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/conf/conf_tdcs.sh new file mode 100755 index 0000000..a2cc702 --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/conf/conf_tdcs.sh @@ -0,0 +1,55 @@ +#!/bin/bash + + + +### all tdcs ### + +for TDC in 0x0350 0x0351 0x0352 0x0353; do + + # invert the first 32 channels + trbcmd w $TDC 0xc805 0xFFFFFFFF + + # enable trigger windows +-1000 ns + trbcmd w $TDC 0xc801 0x80c800c8 + + # set channel ringbuffer size + trbcmd w $TDC 0xc804 10 + +done + + +### tdcs with pasttrec attached ### + +for TDC in 0x0350 0x0351; do + + # enable the first 16 channels (CONN1) + trbcmd setbit $TDC 0xc802 0x0000FFFF + + # enable the second 16 channels (CONN2) + trbcmd setbit $TDC 0xc802 0xFFFF0000 + +done + + +### reference time TDC ### + +for TDC in 0x0353; do + + # non- invert the first channel + trbcmd clearbit $TDC 0xc805 0x1 + + # enable the first channel + trbcmd setbit $TDC 0xc802 0x1 + + # enable Florian's trigger Logic + trbcmd setbit $TDC 0xe000 0x1 + # enable edge detect + trbcmd setbit $TDC 0xe008 0x1 + # merge outputs + trbcmd setbit $TDC 0xe018 0x1 + # delay 0 cycles + trbcmd setbit $TDC 0xe100 0x0 + # stretcher on, five cycles + #trbcmd setbit $TDC 0xe200 0x10005 + +done diff --git a/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/conf/dhcpd.conf b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/conf/dhcpd.conf new file mode 100644 index 0000000..e361b85 --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/conf/dhcpd.conf @@ -0,0 +1,16 @@ + +shared-network em1 { + subnet 192.168.4.0 netmask 255.255.255.0 { + option subnet-mask 255.255.255.0; + option broadcast-address 192.168.4.255; + option routers 192.168.4.254; + #option domain-name-servers 141.2.242.36; + #option domain-name "x-matter.uni-frankfurt.de"; + default-lease-time 86400; + max-lease-time 172800; + } +} + host trb3_148 { hardware ethernet 02:00:f8:00:be:30; fixed-address 192.168.4.240;} + host trb3_148_new { hardware ethernet da:7a:37:0e:f4:30; fixed-address 192.168.4.240;} + host trb3_148_old { hardware ethernet 02:00:be:30:f4:0e; fixed-address 192.168.4.240;} + host trb3_35 { hardware ethernet da:7a:33:90:53:d9; fixed-address 192.168.4.240;} diff --git a/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/conf/register_configgbe.db b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/conf/register_configgbe.db new file mode 100755 index 0000000..b64cf58 --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/conf/register_configgbe.db @@ -0,0 +1,23 @@ + + + +!Register table +# Type # C0 # C1 # C2 # C3 # C4 # C5 # C6 # C7 # C8 # C9 # +################################################################################################### + 0 0x8300 0x8305 0x8307 0x8308 0x830b + 1 0x8301 0x8302 0x8304 0x8309 0x830c 0x830e 0x830f 0x8310 + + +!Value table +# SubEvtId UseGbE MultiQueue Trig. Num. InclTrgType +# Hub # Type # C0 # C1 # C2 # C3 # C4 # +################################################################################## + 0xc035 0 0xc035 1 0 0xffffff 1 + + + +#These values to not need to be written - for completeness only +# SubEvtDec QueDec FrameSize RX enable SubEvtSize Evt/Queue QueueClose MaxQueueSize +# Hub # Type # C0 # C1 # C2 # C3 # C4 # C5 # C6 # C7 # +########################################################################################################################## +# 0xff7f 1 0x00020001 0x00030062 0x578 1 59800 200 32000 60000 diff --git a/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/conf/register_configgbe_ip.db b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/conf/register_configgbe_ip.db new file mode 100755 index 0000000..c2da36f --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/conf/register_configgbe_ip.db @@ -0,0 +1,34 @@ +########################################################################################### +#Eventbuilders: +# EB 0: hadespc001 eth1 ports 50000 - 50099 + +!Register table +# Type # C0 # C1 # C2 # C3 # C4 # +####################################################### +#new memory locations + 0 0x8100 0x8101 0x8102 0x8103 0x8107 + 1 0x8110 0x8111 0x8112 0x8113 0x8117 + 2 0x8120 0x8121 0x8122 0x8123 0x8127 + 3 0x8130 0x8131 0x8132 0x8133 0x8137 + 4 0x8140 0x8141 0x8142 0x8143 0x8147 + 5 0x8150 0x8151 0x8152 0x8153 0x8157 + 6 0x8160 0x8161 0x8162 0x8163 0x8167 + 7 0x8170 0x8171 0x8172 0x8173 0x8177 + 8 0x8180 0x8181 0x8182 0x8183 0x8187 + 9 0x8190 0x8191 0x8192 0x8193 0x8197 + 10 0x81A0 0x81A1 0x81A2 0x81A3 0x81A7 + 11 0x81B0 0x81B1 0x81B2 0x81B3 0x81B7 + 12 0x81C0 0x81C1 0x81C2 0x81C3 0x81C7 + 13 0x81D0 0x81D1 0x81D2 0x81D3 0x81D7 + 14 0x81E0 0x81E1 0x81E2 0x81E3 0x81E7 + 15 0x81F0 0x81F1 0x81F2 0x81F3 0x81F7 + +!Value table +# Dest MAC Dest MAC Dest IP Dest Port Src Port +# Hub # Type # C0 # C1 # C2 # C3 # C4 # +#################################################################################### + + 0xc035 0 0xBB61482F 0xECF4 0xc0a804fe 50002 0xc350 + + + diff --git a/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/conf/reload_all.sh b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/conf/reload_all.sh new file mode 100755 index 0000000..a016ca9 --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/conf/reload_all.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +trbcmd reload 0x0350 +trbcmd reload 0x0351 +trbcmd reload 0x0352 +trbcmd reload 0x0353 +trbcmd reload 0xc035 + +sleep 4 + +./addresses.sh diff --git a/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/workdir/TdcEventBuilder.xml b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/workdir/TdcEventBuilder.xml new file mode 100644 index 0000000..536498d --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/workdir/TdcEventBuilder.xml @@ -0,0 +1,161 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/workdir/first.C b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/workdir/first.C new file mode 100644 index 0000000..728e429 --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/workdir/first.C @@ -0,0 +1,118 @@ +// this is example for + + +#include + +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(10, 510); + + // default channel numbers and edges mask + hadaq::TrbProcessor::SetDefaults(33, 0x2); +// hadaq::TdcProcessor::SetDefaults(1000); + //hadaq::TdcProcessor::DisableCalibrationFor(0,8); + // [min..max] range for TDC ids + //hadaq::TrbProcessor::SetTDCRange(0x610, 0x613); + hadaq::TrbProcessor::SetTDCRange(0x0350, 0x0353); + + // configure ToT calibration parameters + // first - minimal number of counts in ToT histogram + // second - maximal RMS value + hadaq::TdcProcessor::SetToTCalibr(100, 0.2); + + //hadaq::T + // [min..max] range for HUB ids + hadaq::TrbProcessor::SetHUBRange(0xc001, 0xcfff); + + // 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) : 0; + const char* caltrig = getenv("CALTRIG"); + unsigned trig = (caltrig && *caltrig) ? atoi(caltrig) : 0x0; + 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*/ 0x3fff); + hld->ConfigureCalibration("test_", -1, (1 << 0xD)); + + + // only accept trigger type 0x1 when storing file + //new hadaq::HldFilter(0x0); + + // create ROOT file store +// base::ProcMgr::instance()->CreateStore("td.root"); + + // 0 - disable store + // 1 - std::vector - includes original TDC message + // 2 - std::vector - compact form, without channel 0, stamp as float (relative to ch0) + // 3 - std::vector - compact form, with channel 0, absolute time stamp as double + base::ProcMgr::instance()->SetStoreKind(1); + +} + +// extern "C" required by DABC to find function from compiled code + +extern "C" void after_create(hadaq::HldProcessor* hld) +{ + printf("Called after all sub-components are created\n"); + + if (hld==0) return; + + for (unsigned k=0;kNumberOfTRB();k++) { + hadaq::TrbProcessor* trb = hld->GetTRB(k); + if (trb==0) continue; + printf("Configure %s!\n", trb->GetName()); + trb->SetPrintErrors(10); + } + + unsigned firsttdc = 0; + + for (unsigned k=0;kNumberOfTDC();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->DisableCalibrationFor(0); + + // if (tdc->GetID() == 0x1130); + + for (int n=1;n<49;++n) + tdc->SetRefChannel(n,0, 0xffff, 6000, -200, 200); // LED DIFF + } +} + + diff --git a/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/workdir/my_hotstart.hotstart b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/workdir/my_hotstart.hotstart new file mode 100644 index 0000000..ce6cf0a --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/workdir/my_hotstart.hotstart @@ -0,0 +1,42 @@ +// Automatically generated startup script +// Do not change it! + +go4->SetMainWindowState(4,"000000ff00000000fd000000020000000000000125000002e8fc0200000001fb0000001600420072006f00770073006500720044006f0063006b0100000073000002e80000007a00ffffff000000030000063c00000082fc0100000001fc000000000000063c0000003d00fffffffa000000000200000003fb00000016004c006f00670049006e0066006f0044006f0063006b0100000000ffffffff0000005300fffffffb0000001a004d006200730056006900650077006500720044006f0063006b0000000000ffffffff0000006500fffffffb0000001e0044004100420043004d006f006e00690074006f00720044006f0063006b0000000279000000ce000000000000000000000511000002e800000004000000040000000800000008fc0000000800000002000000040000001600460069006c00650054006f006f006c0042006100720100000000ffffffff0000000000000000000000160047006f00340054006f006f006c00730042006100720100000106ffffffff00000000000000000000001e0041006e0061006c00790073006900730054006f006f006c004200610072010000024a0000025800000000000000000000001a0044006900760069006400650050006100640044006f0063006b0000000395000000e40000000000000000000000020000000000000002000000020000002400420072006f0077007300650072004f007000740069006f006e00730044006f0063006b01000000000000010200000000000000000000001e0044007200610077004f007000740069006f006e00730044006f0063006b01000001020000037e00000000000000000000000200000002000000240048006900730044007200610077004f007000740069006f006e00730044006f0063006b0000000000000001290000000000000000000000180047006f0034005300740079006c00650044006f0063006b0000000000000004b10000000000000000000000020000000200000020005300630061006c0065004f007000740069006f006e00730044006f0063006b0000000000000004b100000000000000000000002c0041006e0061006c00790073006900730043006f006d006d0061006e00640054006f006f006c0042006100720100000000ffffffff0000000000000000000000030000000000000003000000010000001e0043006f006d006d0061006e0064004c0069006e00650044006f0063006b0000000000000004b1000000000000000000000003000000010000001c00540072006500650056006900650077006500720044006f0063006b0000000000000004b10000000000000000"); +go4->SetMainWindowGeometry(4,"01d9d0cb00010000000000140000000c000006570000042d00000018000000240000065300000429000000000000"); +go4->LoadLibrary("/usr/lib64/qt4/plugins/imageformats/libqgif.so"); +go4->LoadLibrary("/usr/lib64/qt4/plugins/imageformats/libqico.so"); +go4->LoadLibrary("/usr/lib64/qt4/plugins/imageformats/libqjpeg.so"); +go4->LoadLibrary("/usr/lib64/qt4/plugins/imageformats/libqmng.so"); +go4->LoadLibrary("/usr/lib64/libmng.so.1"); +go4->LoadLibrary("/usr/lib64/liblcms.so.1"); +go4->LoadLibrary("/usr/lib64/qt4/plugins/imageformats/libqsvg.so"); +go4->LoadLibrary("/usr/lib64/libQtSvg.so.4"); +go4->LoadLibrary("/usr/lib64/qt4/plugins/imageformats/libqtga.so"); +go4->LoadLibrary("/usr/lib64/qt4/plugins/imageformats/libqtiff.so"); +go4->LoadLibrary("/lib64/libnss_mdns_minimal.so.2"); +go4->LoadLibrary("/lib64/libnss_dns.so.2"); +go4->LoadLibrary("/lib64/libresolv.so.2"); + +go4->LaunchAnalysis("MyAnalysis", ".", "", "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(1); + +go4->StartAnalysis(); + +// in some analysis one requires to wait several seconds before new histograms appears +// go4->Wait(1); +go4->RefreshNamesList(); + diff --git a/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/workdir/second.C b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/workdir/second.C new file mode 100644 index 0000000..7a2a4f1 --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/workdir/second.C @@ -0,0 +1,454 @@ +#include +#include +#include +#include + +#include "TTree.h" +#include "TFile.h" +#include "TSystem.h" +#include "TString.h" +#include "TH1.h" +#include "TH2.h" +#include "TCanvas.h" +#include "TGo4AnalysisObjectManager.h" + + +#include "base/EventProc.h" +#include "base/Event.h" +#include "hadaq/TdcSubEvent.h" + +#define CHANNELS 33 +#define REFCHAN 0 +// #define REFCHAN_B 0 + +#define VERBOSE 0 +#define TAKE_FIRST_HIT 1 + + + +// Muentz-Torte +#define t1_L -400 // EE +#define t1_R 400 // EE +#define tot_L -10 // EE +#define tot_R 1000 // EE + +#define ref_channel_offset -75 //ns fine measured ref channel relative to coarse measured cts trigger channel +//#define ref_channel_offset 0 //ns fine measured ref channel relative to coarse measured cts trigger channel + +// in the first iteration, scanning through data in the coincidence window, rejecting hits (fuzzy edges) + +//#define spike_rejection 90 //ns for ASD8 0x72 (25000) with LASER +// #define spike_rejection 90 //ns for PASTTREC pt10 // for t1 calibration +//#define spike_rejection 60 //ns for PASTTREC pt10 +// #define spike_rejection 45 //ns for PASTTREC with all the nice filters +// #define spike_rejection 90 //ns for PASTTREC pt15 +//#define spike_rejection 100 //ns for PASTTREC pt20 +// #define spike_rejection 30 //ns for ASD8 0xA9 +// #define spike_rejection 60 //ns for ASD8 0x72 +// #define spike_rejection 75 //ns for ASD8 0x52 +//#define spike_rejection 47 //ns for ASD8 thr 37000 with LASER +// #define spike_rejection 90 //ns for PASTTREC pt20 with LASER +//#define spike_rejection 90 //ns for PASTTREC pt20 with Fe55 + +#define spike_rejection 30 +#define spike_rejection_refchan 10 + +#define individual_spike_rejection 0 + +//#define ref_spike_rejection 100 + + +//#define t1_accept_L (-250 + ref_channel_offset) //ns // GSI Dlab +//#define t1_accept_L (-1000000 + ref_channel_offset) //ns // HZDR fe55 +#define t1_accept_L (-2000 + ref_channel_offset) //ns // EE +//#define t1_accept_L (-150 + ref_channel_offset) //ns // Muentz-Torte +//#define t1_accept_R (100 + ref_channel_offset)//ns // GSI Dlab +//#define t1_accept_R (1000000 + ref_channel_offset)//ns // HZDR fe55 +#define t1_accept_R (2000 + ref_channel_offset)//ns // EE +// #define t1_accept_R (-130 + ref_channel_offset)//ns // Muentz-Torte +// #define t1_accept_R (-90 + ref_channel_offset)//ns // ASD8 with thr 0x52 + +#define fish_proj_cut 20 + + + +// real cuts on selected data + +#define max_tot 1000000 // Muentz-Torte +#define t1_cut_L -2000 +#define t1_cut_R 2000 + + +// #define coincidence_rejection 7 +#define accept_hits_per_layer 20 + +#define enable_coincidence_rejection 0 + +#define enable_single_hits 0 +#define enable_one_hit_per_layer 1 +#define enable_two_to_one_hits 0 + + + +// TFile* tree_out; +std::map trig_no; +std::map data_tree; +Bool_t write_tree = false; + + + +Bool_t file_exists(TString fname){ + + fstream src_file(fname.Data()); + return src_file.good(); +} + +TString from_env(TString env_var,TString default_val){ + if(gSystem->Getenv(env_var)){ + return gSystem->Getenv(env_var); + } + return default_val; +} + + + +class SecondProc : public base::EventProc { + protected: + + std::string fTdcId; //!< tdc id where channels will be selected + + double fHits[8]; //!< 8 channel, abstract hits + + base::H1handle hNumHits; //!< histogram with hits number +// base::H2handle h2D; + +// base::H1handle totCh1; //!< histogram with hits number +// base::H1handle totCh2; //!< histogram with hits number + + + base::H1handle tot_h[CHANNELS]; + base::H1handle tot_untrig_h[CHANNELS]; + base::H1handle t1_h[CHANNELS]; + base::H1handle potato_h[CHANNELS]; + base::H1handle meta_potato_h; + base::H1handle meta_t1_h; + base::H1handle meta_tot_h; + base::H1handle meta_tot_2d; + base::H1handle meta_t1_2d; + base::H1handle coinc_matrix; +// base::H1handle meta_fish; +// base::H1handle meta_fish_proj; +// base::H1handle fishes[FISHES]; +// base::H1handle fish_proj[FISHES]; + base::H1handle efficiency_h; + base::H1handle ref_counts_h; + base::H1handle dut_counts_h; + + + int entry_chan; + int entry_ref_chan; + double entry_t1; + double entry_tot; + + + + + +// int evt_no; + + public: + SecondProc(const char* procname, const char* _tdcid) : + base::EventProc(procname), + fTdcId(_tdcid), + hNumHits(0) + { + printf("Create %s for %s\n", GetName(), fTdcId.c_str()); + + hNumHits = MakeH1("FineAll","Fine all", 1020, 0, 1020, "fine"); +// h2D = MakeH2("h2d","title", 100, -20, 20, 100, -20,20,"x;y"); +// totCh1 = MakeH1("totCh1","totCh1", 20000, -200, 200, "ns"); +// totCh2 = MakeH1("totCh2","totCh2", 20000, -200, 200, "ns"); + + + if(from_env("tree_out","false") == "true"){ + write_tree = true; + } + + trig_no[fTdcId] = 0; + data_tree[fTdcId] = new TTree((TString) fTdcId,"data recorded"); + data_tree[fTdcId]->Branch("trig_no",&trig_no[fTdcId]); + data_tree[fTdcId]->Branch("t1",&entry_t1); + data_tree[fTdcId]->Branch("tot",&entry_tot); + data_tree[fTdcId]->Branch("chan",&entry_chan); + data_tree[fTdcId]->Branch("ref_chan",&entry_ref_chan); + + + for( unsigned i=0; iSetDrawOption("P0"); + ((TH1F*) efficiency_h)->SetMarkerStyle(22); + ((TH1F*) efficiency_h)->GetXaxis()->SetNdivisions(55); + + coinc_matrix = MakeH2("coinc_matrix","coinc_matrix",12,-2.5,9.5,10,15-0.5,24+0.5, "channels 0-7;channels 16-23"); + //meta_fish = MakeH2("meta_fish","meta_fish",250,-300,200,200,-100,100, "T_A+T_B;T_B-T_A"); + + //meta_fish_proj = MakeH1("meta_fish_proj","meta_fish_proj",250,-300,200, "T_A+T_B;counts"); + + + + // enable storing already in constructor + SetStoreEnabled(); + } + + virtual void UserPostLoop(void) { + + static Int_t was_called_before = 0; + + cout << "--- User Post Loop " << fTdcId << endl; +// TFile* tree_out = new TFile( Form("tree_out_%s.root",fTdcId.c_str()) ,"RECREATE"); + + if(from_env("tree_out","false") == "true"){ + + cout << "write tree_out.root" << endl; + TFile* tree_out; + + + if(was_called_before){ + tree_out = new TFile("tree_out.root","UPDATE"); + } else { + tree_out = new TFile("tree_out.root","RECREATE"); + } + tree_out->cd(); + data_tree[fTdcId]->Write(); + tree_out->Write(); + tree_out->Close(); + delete tree_out; + } + was_called_before ++; + } + + + 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) + { +// printf("### DEBUG ###\n"); + for (unsigned n=0;n<8;n++) fHits[n] = 0.; + + hadaq::TdcSubEvent* sub = + dynamic_cast (ev->GetSubEvent(fTdcId)); + + if(VERBOSE) cout<< "tdc: " << fTdcId << " evt no: " << trig_no[fTdcId] << endl; + if (sub==0) return false; + +// printf("%s process sub %d %s\n", GetName(), sub->Size(), fTdcId.c_str()); + + + static float effective_spike_rejection = from_env("spike_rejection", TString::Itoa(spike_rejection,10) ).Atof(); + + +// static int ref_counts[CHANNELS]; +// static int dut_counts[CHANNELS]; +// static bool is_dut[CHANNELS]; + + + // this is only run once -- + static bool is_initialized=false; + if(not(is_initialized)){ + for( int i = 0; i<31; i++){ +// ref_counts[i] = 0; +// dut_counts[i] = 0; +// is_dut[i] = false; +// if((overlaps[i][0] >= 0) && (overlaps[i][1] >= 0)){ +// is_dut[i] = true; +// } + } + + + + + is_initialized = true; + } + // ------ + + double num(0), ch0tm(0), ch1tm(0), ch2tm(0), ch3tm(0); + double t1_candidate[CHANNELS]; + double t2_candidate[CHANNELS]; + double t1[CHANNELS]; + double t2[CHANNELS]; + bool got_rising[CHANNELS]; + bool got_falling[CHANNELS]; + bool got_real_hit[CHANNELS]; + double tot[CHANNELS]; + for (unsigned i=0; iSize();cnt++) { + const hadaq::TdcMessageExt& ext = sub->msg(cnt); + + unsigned chid = ( ext.msg().getHitChannel() ); + bool rising = ext.msg().isHitRisingEdge(); // use this line for rising edge first/positive pulses + + if (chid==0) { + ch0tm = ext.GetGlobalTime(); + got_real_hit[chid] = true; + t1[chid] = 0; + tot[chid] = 100e-9; + continue; + + } + + + // full time + double tm = ext.GetGlobalTime(); + if((chid) >= CHANNELS) {continue;} // channel out of range of analysis + if(rising){ + + + if( !(TAKE_FIRST_HIT && got_real_hit[chid]) ){ // block subsequent hits if TAKE_FIRST_HIT setting is active + if((( ((tm)*1e9) > t1_accept_L) && (((tm)*1e9) < t1_accept_R )) ) { // this condition sets another coincidence window, except for REFCHAN_A + got_rising[chid] = true; + got_falling[chid] = false; + t1_candidate[chid] = tm; + } + } + }else{ // if falling edge +// printf("got falling edge, ch %d\n",(chid)); + if(got_rising[chid]){ + if(not(got_falling[chid])){ + got_falling[chid] = true; + t2_candidate[chid] = tm; + Double_t candidate_tot_ns = (t2_candidate[chid] - t1_candidate[chid])*1e9; + + if( candidate_tot_ns > effective_spike_rejection || (chid==REFCHAN || candidate_tot_ns > spike_rejection_refchan) ){ + // hit is long enough not to be rejected + t1[chid] = t1_candidate[chid]; + t2[chid] = t2_candidate[chid]; + tot[chid] = t2[chid] - t1[chid]; + got_real_hit[chid] = true; + + // fill untriggered tot histogram + FillH1(tot_untrig_h[chid],tot[chid]*1e9); + } +// printf("got hit, ch %d, tot = %f ns\n",(chid), tot[chid]*1e9); + } + } + } + + } + + + + for( unsigned i=0; i t1_cut_L) && (t1_vs_ref < t1_cut_R) && (tot[i]*1e9 < max_tot) ) { + + // fill histograms + FillH1(tot_h[i],tot[i]*1e9); + FillH2(potato_h[i],t1_vs_ref ,tot[i]*1e9); + FillH1(t1_h[i],t1_vs_ref ); // without cuts +// if(t1_vs_ref < -200 && tot[i]*1e9 > 0 ) FillH1(t1_h[i],t1_vs_ref ); // with noise rejecting cuts + // if( tot[i]*1e9 > 50 ) FillH1(t1_h[i],t1_vs_ref ); // with noise rejecting cuts + + + if( i != 0 ) { + FillH2(meta_potato_h,t1_vs_ref,tot[i]*1e9); + FillH1(meta_tot_h,tot[i]*1e9); + FillH1(meta_t1_h,t1_vs_ref ); + FillH2(meta_tot_2d,tot[i]*1e9,i); + FillH2(meta_t1_2d,t1_vs_ref,i); + entry_chan = i; + entry_t1 = t1_vs_ref; + entry_tot = tot[i]*1e9; + if(write_tree){ + data_tree[fTdcId]->Fill(); + } + } + + // efficiency estimation ... this cell, cell #i, is a reference detector +// ref_counts[i]++; // count up reference counts +// FillH1(counts_h,i-0.5); + } + } + } + + + + for (int i = 1 ; iSetBinContent(i,((float) (((TH1F*) t1_h[i])->GetEntries()) )/((float) (((TH1F*) t1_h[0])->GetEntries()))); + ((TH1F*) efficiency_h)->SetBinContent(i,((float) (((TH1F*) t1_h[i])->Integral()) )/ 600. ); // fixed numer of pulses sent for each channel + // ((TH1F*) efficiency_h)->SetBinContent(i,((float) (((TH1F*) t1_h[i])->Integral()) )/((float) (((TH1F*) tot_h[i])->Integral()))); ; // normalize by number of signals in same channel without couts, as for almost each trigger a noise signal is measured + } + + + + +// if(got_real_hit[0]){ +// FillH1(totCh1,tot[0]*1e9); +// } +// if(got_real_hit[1]){ +// FillH1(totCh2,tot[1]*1e9);ref_counts[i] +// } + +// FillH1(hNumHits, num); + + +// draw_and_save((TH2F*) meta_fish, "meta_fish","./","colz"); + +// tree_out->cd(); +// data_tree[fTdcId]->Write(); + trig_no[fTdcId]++; + + return true; + } + + +}; + + +void second() +{ + //hadaq::TdcProcessor::SetDefaults(700); +// tree_out = new TFile("./tree_out.root","RECREATE"); +// new SecondProc("Sec_1130", "TDC_1130"); +// new SecondProc("Sec_0352", "TDC_0353"); + new SecondProc("Sec_0350", "TDC_0350"); + new SecondProc("Sec_0353", "TDC_0353"); +// tree_out->Write(); +// tree_out->Close(); +} + diff --git a/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/workdir/start.sh b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/workdir/start.sh new file mode 100755 index 0000000..0914180 --- /dev/null +++ b/go4_trbnet/go4_trbnet_leap_42.3_stable_2018-03-01/workdir/start.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +echo "container started" + +echo "create main tmux session" + +echo "run /conf/conf.sh" +. /conf/conf.sh + +cd /workdir +tmux new -d -s main + + + +tmux link-window -s cts_gui:cts_gui -t main +tmux link-window -s vnc:vnc -t main + + +tmux new-window -t main -n "dabc" "dabc_exe TdcEventBuilder_noHLD.xml;/bin/bash" + + +#tmux new-window -t main -n "go4" "rm *.root; go4 0350_meta.hotstart;/bin/bash" +tmux new-window -t main -n "go4_ana" "rm *.root; tree_out=false go4analysis -stream localhost:6790 -http localhost:8080;/bin/bash" + +# tmux new-window -t main -n "htop" "htop;/bin/bash" +tmux new-window -t main -n "info" "cat /conf/conf_log.txt; cat info.txt; /bin/bash" +tmux new-window -t main -n "PT_ctrl" "cd /workdir/pasttrec_ctrl; /bin/bash" +tmux new-window -t main -n "new" "/bin/bash" +tmux new-window -t main -n "new" "/bin/bash" +tmux new-window -t main -n "new" "/bin/bash" +tmux new-window -t main -n "new" "/bin/bash" +tmux new-window -t main -n "new" "/bin/bash" +tmux new-window -t main -n "x11_apps" "lxpanel& sleep 10; firefox localhost:8080& /bin/bash" +tmux select-window -t main:info + + +tmux a -t main + + + + +echo "drop user to shell" +/bin/bash + +echo "terminate container"