Subversion Repositories f9daq

Compare Revisions

No changes between revisions

Ignore whitespace Rev 325 → Rev 326

/cvi/apps/sa02_daq/Makefile
0,0 → 1,105
CC = gcc
#CXX = g++ -std=c++11
ROOTINC=$(shell root-config --incdir )
ROOTLIB=$(shell root-config --libs )
 
 
INC=-I. -I$(ROOTINC)
 
LIBS=$(ROOTLIB) -L./ -lm
LIBS1=$(shell root-config --libs --glibs )
 
 
 
SRC = .
INC1 = -I. -I../lib -I/usr/include
DBG =
CFLAGS = $(DBG) $(INC) -fPIC -DLINUX -Wall
 
 
TARGET = daq
 
FILES = $(SRC)/daq.C
 
VMELIB = libf9vme.a
 
SHLIB = -lz
 
OBJ_FILES = VMEModule.o CAENV965.o CAEN_V1718.o VmUsbStack.o
 
 
all: sa02_ctrl sa02read
 
 
sa02_ctrl: sa02lib.c sa02_ctrl.cxx
$(CXX) $(CFLAGS) -I../cvi/instr/vme -Icvi -DBELLEPTS sa02_ctrl.cxx sa02lib.c cvi/H2D.c -L../cvi/instr/vme -lvme -ldl -lCAENVME $(SHLIB) -o sa02_ctrl
cp sa02_ctrl ../bin
 
 
wientest: wienvme_dll.c
$(CXX) $(CFLAGS) -Ivmeinterfaces -DMAIN wienvme_dll.c -lpcivme $(SHLIB) -o wientest
sa02read: sa02read.C
$(CXX) -DMAIN -Icvi $(CFLAGS) sa02read.C $(ROOTLIB) -lz -o sa02read
mikdir -p ../bin
cp sa02read ../bin
all1: vme daq
 
usbvme: usbvme.C CAEN_V1718.c
$(CXX) $(CFLAGS) usbvme.C CAEN_V1718.c $(SHLIB) -o usbvme
 
wusbxx_dll.o:vmeinterfaces/wusbxx_dll.c vmeinterfaces/wusbxx_dll.h
$(CXX) -Ivmeinterfaces -Ivmeinterfaces/VmUsbStack -c $(CFLAGS) vmeinterfaces/wusbxx_dll.c
 
libxxusb.o:vmeinterfaces/libxxusb.c vmeinterfaces/libxxusb.h
$(CXX) -Ivmeinterfaces -c $(CFLAGS) vmeinterfaces/libxxusb.cpp
 
VmUsbStack_cvi.o:vmeinterfaces/VmUsbStack/VmUsbStack_cvi.c vmeinterfaces/VmUsbStack/VmUsbStack_cvi.h
$(CXX) -Ivmeinterfaces -Ivmeinterfaces/VmUsbStack -c $(CFLAGS) vmeinterfaces/VmUsbStack/VmUsbStack_cvi.c
.cpp.o:
$(CXX) -c $(CFLAGS) $<
ar r $(VMELIB) $@
 
.C.o:
$(CXX) -c $(CFLAGS) $<
ar r $(VMELIB) $@
 
 
.cc.o:
$(CXX) -c $(CFLAGS) $<
ar r $(VMELIB) $@
 
.c.o:
$(CXX) -Ivmeinterfaces -c $(CFLAGS) $<
ar r $(VMELIB) $@
 
vme: $(OBJ_FILES)
 
CAEN_V1718.o: CAEN_V1718.c
 
VMEModule.o: VMEModule.hh VMEModule.cc
 
CAENV965.o: CAENV965.h CAENV965_DEF.h CAENV965.c
 
 
$(TARGET): $(FILES) $(OBJ_FILES)
$(CXX) -DMAIN $(CFLAGS) $(FILES) $(OBJ_FILES) $(SHLIB) -o $(TARGET)
 
 
 
libdaq.so: $(FILES)
@echo "Generating dictionary Dict.C..."
rootcint -f Dict.C -c $(INC) $(CPPFLAGS) daq.h LinkDef.h
$(CXX) -DG__DICTIONARY $(CFLAGS) $(INC) $(FILES) Dict.C -L. $(SHLIB) -shared -o libdaq.so
 
clean:
rm sa02_wienvme_ctrl sa02_caenusb_ctrl sa02_wvmusb_ctrl wientest Dict.C libdaq.so $(TARGET1) *.o
 
 
tgz:
tar czvf vme.tgz Makefile *.c *.h *.C *.cc *.hh
/cvi/apps/sa02_daq/Makefile.win32
0,0 → 1,182
#cmd.exe /k ""C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"" x86
#set INCLUDE=%INCLUDE%;"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include"
#set ROOTSYS=C:\root_v5.34.34
#
#nmake -f Makefile.win32
#
#set INCLUDE=%INCLUDE%;C:\Program Files\Microsoft SDKs\Windows\v7.1A\Include
!if "$(CFG)" == ""
!if ([findstr /c:"--build=debug" $(ROOTSYS)\bin\root-config > nul ] == 0)
CFG = Win32 Debug
!if ([findstr /c:"--disable-winrtdebug" $(ROOTSYS)\bin\root-config > nul ] == 0)
RUNTIME = Release
!else
RUNTIME = Debug
!endif
!message No configuration specified: Defaulting to Win32 Debug
!message With $(RUNTIME) Runtime DLL (Taken from ROOT config).
!message .
!else
CFG = Win32 Release
RUNTIME = Release
!message No configuration specified: Defaulting to Win32 Release
!message With $(RUNTIME) Runtime DLL (Taken from ROOT config).
!message .
!endif
!else
!if "$(CFG)" == "Win32 Release"
RUNTIME = Release
!elseif "$(CFG)" == "Win32 Debug"
RUNTIME = Debug
!endif
!endif
 
!if "$(CFG)" != "Win32 Release" && "$(CFG)" != "Win32 Debug"
!message Invalid configuration "$(CFG)" specified.
!message You can specify a configuration when running NMAKE
!message by defining the macro CFG on the command line. For example:
!message
!message NMAKE /f "Makefile.msc" CFG="Win32 Debug"
!message
!message Possible choices for configuration are:
!message
!message "Win32 Release" (based on "Win32 (x86) Dynamic Library")
!message "Win32 Debug" (based on "Win32 (x86) Dynamic Library")
!message
!error An invalid configuration is specified.
!endif
!message ROOTSYS = "$(ROOTSYS)/include"
 
ObjSuf = obj
SrcSuf = cpp
ExeSuf = .exe
DllSuf = dll
OutPutOpt = -out:
 
 
## VS2012 (VC11): configure subsystem version
## See: https://blogs.msdn.com/b/vcblog/archive/2012/10/08/10357555.aspx
## (APPVER used in win32.mak to set subsystem version)
!if ([nmake /? 2>&1 | findstr /c:"Version 14\." > nul ] == 0)
APPVER = 5.01
!endif
 
# Win32 system with Microsoft Visual C/C++
!include <win32.mak>
CC = $(cc)
CXX = $(cc)
CXXFLAGS = -nologo -EHsc -GR -DWIN32 -W3 -D_WINDOWS -DMAIN \
-DVISUAL_CPLUSPLUS -I$(ROOTSYS)/include -Icvi -Iinclude \
-wd4244
#-FIw32pragma.h
LD = $(link)
 
!if "$(CFG)" == "Win32 Release"
CXXOPT = -O2 -arch:SSE2 -MD
LDOPT = -opt:ref
!elseif "$(CFG)" == "Win32 Debug"
!if "$(RUNTIME)" == "Debug"
CXXOPT = -Z7 -MDd
!else
CXXOPT = -Z7 -O2 -arch:SSE2 -MD
!endif
LDOPT = -debug
!endif
 
# Check if nmake version is 8.xx or 9.xx
!if ([nmake /? 2>&1 | findstr /c:"Version 8\." > nul ] == 0) || \
([nmake /? 2>&1 | findstr /c:"Version 9\." > nul ] == 0)
MT_EXE = mt -nologo -manifest $@.manifest -outputresource:$@;1
MT_DLL = mt -nologo -manifest $@.manifest -outputresource:$@;2
EXTRAFLAGS = -D_CRT_SECURE_NO_DEPRECATE
!else if ([nmake /? 2>&1 | findstr /c:"Version 12\." > nul ] == 0)
MT_EXE =
MT_DLL =
EXTRAFLAGS =
!else if ([nmake /? 2>&1 | findstr /c:"Version 10\." > nul ] == 0)
EXTRAFLAGS = -D_CRT_SECURE_NO_DEPRECATE
!else if ([nmake /? 2>&1 | findstr /c:"Version 14\." > nul ] == 0)
EXTRAFLAGS = -D_CRT_SECURE_NO_DEPRECATE
!else
MT_EXE =
MT_DLL =
EXTRAFLAGS = -G5
!endif
 
LDFLAGS = $(LDOPT) $(conlflags) -nologo -include:_G__cpp_setupG__Hist \
-include:_G__cpp_setupG__Graf -include:_G__cpp_setupG__G3D \
-include:_G__cpp_setupG__GPad -include:_G__cpp_setupG__Tree \
-include:_G__cpp_setupG__Rint -include:_G__cpp_setupG__PostScript \
-include:_G__cpp_setupG__Matrix -include:_G__cpp_setupG__Physics
SOFLAGS = $(dlllflags:-pdb:none=)
ROOTLIBS = $(ROOTSYS)\lib\libCore.lib \
$(ROOTSYS)\lib\libCint.lib $(ROOTSYS)\lib\libHist.lib \
$(ROOTSYS)\lib\libGraf.lib $(ROOTSYS)\lib\libGraf3d.lib \
$(ROOTSYS)\lib\libGpad.lib $(ROOTSYS)\lib\libTree.lib \
$(ROOTSYS)\lib\libRint.lib $(ROOTSYS)\lib\libPostscript.lib \
$(ROOTSYS)\lib\libMatrix.lib $(ROOTSYS)\lib\libPhysics.lib \
$(ROOTSYS)\lib\libNet.lib $(ROOTSYS)\lib\libRIO.lib \
$(ROOTSYS)\lib\libMathCore.lib
LIBS = $(ROOTLIBS)
GLIBS = $(LIBS) $(ROOTSYS)\lib\libGui.lib $(ROOTSYS)\lib\libGraf.lib \
$(ROOTSYS)\lib\libGpad.lib
LIBSALL = $(ROOTLIBS)
 
EVENTLIB = libEvent.lib
 
 
#------------------------------------------------------------------------------
MYAPP = sa02read$(ExeSuf)
MYAPPS = sa02read.$(SrcSuf) XGetopt.$(ObjSuf) getopt_long.$(ObjSuf)
MYAPPO = sa02read.$(ObjSuf) XGetopt.$(ObjSuf) getopt_long.$(ObjSuf)
 
 
 
OBJS = $(MYAPPO)
PROGRAMS = $(MYAPP)
 
#------------------------------------------------------------------------------
 
!message LDFLAGS = "$(LDFLAGS)"
!message MYAPP = "$(MYAPP)"
!message MYAPPO = "$(MYAPPO)"
!message PROGRAMS = "$(PROGRAMS)"
 
 
all: $(PROGRAMS)
 
 
 
$(MYAPP): $(MYAPPO)
@echo "Compiling $@ "
$(LD) $(LDFLAGS) /SUBSYSTEM:CONSOLE \
$(MYAPPO) $(LIBSALL) $(OutPutOpt)$@
@echo "$@ done"
 
RootShowerDict.$(SrcSuf): MyParticle.h MyDetector.h MyEvent.h RSLinkDef.h
@echo "Generating dictionary $@..."
@rootcint -f $@ -c MyParticle.h MyDetector.h MyEvent.h RSLinkDef.h
 
#------------------------------------------------------------------------------
 
clean:
@del *.obj *Dict.* *.def *.exp *.d *.log .def *.pdb *.ilk *.manifest
 
distclean: clean
@del *.exe *.root *.ps *.lib *.dll
 
sa02read.$(ObjSuf): sa02read.$(SrcSuf)
@echo "Compiling sa02read $@ "
$(CXX) $(CXXFLAGS) $(EXTRAFLAGS) $(CXXOPT) -c sa02read.$(SrcSuf)
###
 
.$(SrcSuf).$(ObjSuf):
@echo "Compiling object $@ "
$(CXX) $(CXXFLAGS) $(EXTRAFLAGS) $(CXXOPT) -c $<
.c.$(ObjSuf):
@echo "Compiling object $@ "
$(CXX) $(CXXFLAGS) $(EXTRAFLAGS) $(CXXOPT) -c $<
 
/cvi/apps/sa02_daq/SA02_DEF.h
0,0 → 1,142
#ifndef _SA02_DEF_H
#define _SA02_DEF_H
 
#define FEB_SINGLE
#ifdef CAEN_V1495
// read data access
# define FEB_DATA_RDY 0x10c4
# define FEB_DATA_RST 0x101c
//# define FEB_TPENB 0x1020
// setup trigger SW or HW
# define FEB_SEUTRG 0x1028
# define FEB_SWTRG 0x1020
# ifdef FEB_SINGLE
# define FEB_DATA_START 0x1030
# define FEB_DATA_STOP 0x10c0
# else /* FEB_SINGLE */
# define FEB_DATA_START 0x1100
# define FEB_DATA_STOP 0x1340
# endif /* FEB_SINGLE */
# define FEB_DATA_INC 0x0004
# define FEB_BLTDATA_START 0x0030
# define FEB_BLTDATA_STOP 0x00c0
# define FEB_SREG 0x10c0
# ifdef FEB_SINGLE
# define FEB_SREG0 FEB_SREG
# define FEB_SREG1 FEB_SREG
# define FEB_SREG2 FEB_SREG
# define FEB_SREG3 FEB_SREG
# else /* FEB_SINGLE */ // parallel readout
# define FEB_SREG0 0x10d4
# define FEB_SREG1 0x10d8
# define FEB_SREG2 0x10dc
# define FEB_SREG3 0x10e0
# endif /* FEB_SINGLE */
// write accesss
# define FEB_REGH 0x1010
# define FEB_REGL 0x1014
# define FEB_EXEC 0x1018
#endif /* CAEN_V1495 */
 
#ifdef BELLEPTS
 
 
 
# define FEB_BLTDATA_START FEB_DATA_START
# define FEB_BLTDATA_STOP FEB_DATA_STOP
 
// data access
#define FEB_DATA 0x0100
#define FEB_DATA_INC 0x0100
 
#define FEB_CHADDR 0x0104
#define FEB_CNTR 0x0108
// write accesss
#define FEB_DATAOUT0 0x010C
#define FEB_DATAOUT1 0x0110
// read access
#define FEB_DATAIN0 0x0114
#define FEB_DATAIN1 0x0118
 
 
#define FEB_DATA_RST 0x0500
#define FEB_DATA_RDY 0x0504
#define FEB_DAQMODE 0x0508
#define FEB_SWTRG 0x050C // sw trigger
#define FEB_SELTRG 0x0510 // disable bits: 0-hw,1-sw
#define FEB_SETNEVE 0x0514
#define FEB_GETNEVE 0x0518
#define FEB_DEBUGMON 0x051C
#define FEB_SEUTRG 0x0520 // seu sw trigger
 
 
#define FEB_DEADBEEF 0x0FFC // register with a value 0xdeadbeef
#endif /* BELLEPTS */
 
// SA02 commands
 
#define FEB_INIT 0x00000000
#define FEB_CREG 0x01000000
#define FEB_SHFT_CLK 0x01000000
#define FEB_SEND_CLK 0x02000000
#define FEB_SEL_MON 0x03000000
#define FEB_MUX 0x03000000
#define FEB_SEL_DATA 0x04000000
 
#define FEB_TP 0x05000000
#define FEB_DLY0 0x06000000
#define FEB_SERIAL 0x08000000
#define FEB_DPM 0x09000000
#define FEB_VTH2 0x090000B0
#define FEB_VTH1 0x090000B1
#define FEB_TPLVL0 0x090100B0
#define FEB_TPLVL1 0x090100B1
 
#define DPM_WRITE 0x00B00000
#define DPM_CH1 0x00010000
 
#define FEB_SUBA_INC 0x00010000
#define FEB_RO 0x80000000
 
#define SA0x_ASIC0_CREG 0x0A000000
#define SA0x_ASIC0_GREG 0x0B000000
#define SA0x_ASIC0_CMON 0x0C000000
 
#define FEB_TMON0 0x0D000000
#define FEB_TMON1 0x0D010000
 
#define FEB_ADC_READ 0x0E000000
#define FEB_ADC_RESET 0x0E010000
 
#define ASIC_PHASECMPS 0x0000003
#define ASIC_GAIN 0x000000c
#define ASIC_SHAPINGTIME 0x0000030
#define ASIC_COMPARATOR 0x0000040
#define ASIC_VRDRIVE 0x0007F80
#define ASIC_MONITOR 0x0018000
#define ASIC_ID 0x3FE0000
 
#define ASIC_DECAYTIME 0x000007
#define ASIC_OFFSET 0x000078
#define ASIC_FINEADJ_UNIPOL 0x000780
#define ASIC_FINEADJ_DIFF 0x007800
#define ASIC_TPENDB 0x010000
#define ASIC_KILL 0x100000
 
#define ASIC_PHASECMPS_SHFT 0
#define ASIC_GAIN_SHFT 2
#define ASIC_SHAPINGTIME_SHFT 4
#define ASIC_COMPARATOR_SHFT 6
#define ASIC_VRDRIVE_SHFT 7
#define ASIC_MONITOR_SHFT 15
#define ASIC_ID_SHFT 17
 
#define ASIC_DECAYTIME_SHFT 0
#define ASIC_OFFSET_SHFT 3
#define ASIC_FINEADJ_UNIPOL_SHFT 7
#define ASIC_FINEADJ_DIFF_SHFT 11
#define ASIC_TPENDB_SHFT 16
#define ASIC_KILL_SHFT 17
 
#endif /* _SA02_DEF_H */
/cvi/apps/sa02_daq/XGetopt.cpp
0,0 → 1,225
// XGetopt.cpp Version 1.2
//
// Author: Hans Dietrich
// hdietrich2@hotmail.com
//
// Description:
// XGetopt.cpp implements getopt(), a function to parse command lines.
//
// History
// Version 1.2 - 2003 May 17
// - Added Unicode support
//
// Version 1.1 - 2002 March 10
// - Added example to XGetopt.cpp module header
//
// This software is released into the public domain.
// You are free to use it in any way you like.
//
// This software is provided "as is" with no expressed
// or implied warranty. I accept no liability for any
// damage or loss of business that this software may cause.
//
///////////////////////////////////////////////////////////////////////////////
 
 
///////////////////////////////////////////////////////////////////////////////
// if you are using precompiled headers then include this line:
//#include "stdafx.h"
///////////////////////////////////////////////////////////////////////////////
 
 
///////////////////////////////////////////////////////////////////////////////
// if you are not using precompiled headers then include these lines:
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
///////////////////////////////////////////////////////////////////////////////
 
 
#include "XGetopt.h"
 
 
///////////////////////////////////////////////////////////////////////////////
//
// X G e t o p t . c p p
//
//
// NAME
// getopt -- parse command line options
//
// SYNOPSIS
// int getopt(int argc, TCHAR *argv[], TCHAR *optstring)
//
// extern TCHAR *optarg;
// extern int optind;
//
// DESCRIPTION
// The getopt() function parses the command line arguments. Its
// arguments argc and argv are the argument count and array as
// passed into the application on program invocation. In the case
// of Visual C++ programs, argc and argv are available via the
// variables __argc and __argv (double underscores), respectively.
// getopt returns the next option letter in argv that matches a
// letter in optstring. (Note: Unicode programs should use
// __targv instead of __argv. Also, all character and string
// literals should be enclosed in _T( ) ).
//
// optstring is a string of recognized option letters; if a letter
// is followed by a colon, the option is expected to have an argument
// that may or may not be separated from it by white space. optarg
// is set to point to the start of the option argument on return from
// getopt.
//
// Option letters may be combined, e.g., "-ab" is equivalent to
// "-a -b". Option letters are case sensitive.
//
// getopt places in the external variable optind the argv index
// of the next argument to be processed. optind is initialized
// to 0 before the first call to getopt.
//
// When all options have been processed (i.e., up to the first
// non-option argument), getopt returns EOF, optarg will point
// to the argument, and optind will be set to the argv index of
// the argument. If there are no non-option arguments, optarg
// will be set to NULL.
//
// The special option "--" may be used to delimit the end of the
// options; EOF will be returned, and "--" (and everything after it)
// will be skipped.
//
// RETURN VALUE
// For option letters contained in the string optstring, getopt
// will return the option letter. getopt returns a question mark (?)
// when it encounters an option letter not included in optstring.
// EOF is returned when processing is finished.
//
// BUGS
// 1) Long options are not supported.
// 2) The GNU double-colon extension is not supported.
// 3) The environment variable POSIXLY_CORRECT is not supported.
// 4) The + syntax is not supported.
// 5) The automatic permutation of arguments is not supported.
// 6) This implementation of getopt() returns EOF if an error is
// encountered, instead of -1 as the latest standard requires.
//
// EXAMPLE
// BOOL CMyApp::ProcessCommandLine(int argc, TCHAR *argv[])
// {
// int c;
//
// while ((c = getopt(argc, argv, _T("aBn:"))) != EOF)
// {
// switch (c)
// {
// case _T('a'):
// TRACE(_T("option a\n"));
// //
// // set some flag here
// //
// break;
//
// case _T('B'):
// TRACE( _T("option B\n"));
// //
// // set some other flag here
// //
// break;
//
// case _T('n'):
// TRACE(_T("option n: value=%d\n"), atoi(optarg));
// //
// // do something with value here
// //
// break;
//
// case _T('?'):
// TRACE(_T("ERROR: illegal option %s\n"), argv[optind-1]);
// return FALSE;
// break;
//
// default:
// TRACE(_T("WARNING: no handler for option %c\n"), c);
// return FALSE;
// break;
// }
// }
// //
// // check for non-option args here
// //
// return TRUE;
// }
//
///////////////////////////////////////////////////////////////////////////////
 
//TCHAR *optarg; // global argument pointer
char *optarg; // global argument pointer
int optind = 0; // global argv index
 
//int getopt(int argc, TCHAR *argv[], TCHAR *optstring)
int getopt(int argc, char *argv[], char *optstring)
{
//static TCHAR *next = NULL;
static char *next = NULL;
if (optind == 0)
next = NULL;
 
optarg = NULL;
 
if (next == NULL || *next == _T('\0'))
{
if (optind == 0)
optind++;
 
if (optind >= argc || argv[optind][0] != _T('-') || argv[optind][1] == _T('\0'))
{
optarg = NULL;
if (optind < argc)
optarg = argv[optind];
return EOF;
}
 
if (strcmp( argv[optind], _T("--")) == 0)
{
optind++;
optarg = NULL;
if (optind < argc)
optarg = argv[optind];
return EOF;
}
 
next = argv[optind];
next++; // skip past -
optind++;
}
 
//TCHAR c = *next++;
//TCHAR *cp = _tcschr(optstring, c);
char c = *next++;
//char *cp = _tcschr(optstring, c);
char *cp =strchr(optstring, c);
 
if (cp == NULL || c == _T(':'))
return _T('?');
 
cp++;
if (*cp == _T(':'))
{
if (*next != _T('\0'))
{
optarg = next;
next = NULL;
}
else if (optind < argc)
{
optarg = argv[optind];
optind++;
}
else
{
return _T('?');
}
}
 
return c;
}
/cvi/apps/sa02_daq/addrecord.C
0,0 → 1,103
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <sys/time.h>
#include "dataio.h"
 
#define PEDESTAL 255
 
int main(int argc, char **argv) {
 
char fname[200]= {"tmp.out"};
int type;
time_t t;
 
if(argc<2) {
printf("Not enough arguments!\n");
return -1;
} else {
sprintf(fname,"%s",argv[1]);
type=atoi(argv[2]);
}
 
FILE *fp= fopen(fname,"ab");
 
switch(type) {
case RUNREC_ID:
if(argc<9) {
printf("Not enough arguments!\n");
} else {
RUNREC runrec; // start header: appears once at the start of the file
runrec.id = RUNREC_ID;
runrec.len = sizeof(runrec);
runrec.fver = 0x10000;
time(&t);
runrec.time=t;
runrec.nev = atoi(argv[3]);
runrec.ped = PEDESTAL;
runrec.nx = atoi(argv[4]);
runrec.x0 = atoi(argv[5]);
runrec.dx = atoi(argv[6]);
runrec.ny = atoi(argv[7]);
runrec.y0 = atoi(argv[8]);
runrec.dy = atoi(argv[9]);
printf("Writing header to file %s\n",fname);
printf("RECID = %u\n",runrec.id);
printf("Length = %u\n",runrec.len);
printf("File version = %u\n",runrec.fver);
printf("Time = %u\n",runrec.time);
printf("Number of events per step = %u\n",runrec.nev);
printf("Pedestal = %u\n",runrec.ped);
printf("Number of steps in X = %d\n",runrec.nx);
printf("Start position X = %d\n",runrec.x0);
printf("Step size direction X = %d\n",runrec.dx);
printf("Number of steps in Y = %d\n",runrec.ny);
printf("Start position Y = %d\n",runrec.y0);
printf("Step size direction Y = %d\n",runrec.dy);
if (fp) fwrite(&runrec, runrec.len,1,fp);
}
break;
case ENDREC_ID:
ENDREC endrec; // end header: appears once at the end of the file
endrec.id = ENDREC_ID;
endrec.len = sizeof(endrec);
time(&t);
endrec.time=t;
printf("Writing header to file %s\n",fname);
printf("RECID = %u\n",endrec.id);
printf("Length = %u\n",endrec.len);
printf("Time = %u\n",endrec.time);
if (fp) fwrite(&endrec, endrec.len,1,fp);
break;
case POSREC_ID:
if(argc<8) {
printf("Not enough arguments!\n");
} else {
POSREC posrec; // position header: appears at every change of position
posrec.id = POSREC_ID;
posrec.len = sizeof(posrec);
time(&t);
posrec.time=t;
posrec.ix = atoi(argv[3]);
posrec.x = atoi(argv[4]);
posrec.xset = atoi(argv[5]);
posrec.iy = atoi(argv[6]);
posrec.y = atoi(argv[7]);
posrec.yset = atoi(argv[8]);
printf("Writing header to file %s\n",fname);
printf("RECID = %u\n",posrec.id);
printf("Length = %u\n",posrec.len);
printf("Time = %u\n",posrec.time);
printf("Iteration X = %d\n",posrec.ix);
printf("MIKRO Position X = %d\n",posrec.x);
printf("Set position X = %d\n",posrec.xset);
printf("Iteration Y = %d\n",posrec.iy);
printf("MIKRO Position Y = %d\n",posrec.y);
printf("Set position Y = %d\n",posrec.yset);
if (fp) fwrite(&posrec, posrec.len,1,fp);
}
break;
}
fclose(fp);
return 0;
}
/cvi/apps/sa02_daq/analysis/FEBserial.txt
0,0 → 1,574
0001 ZJ5859 021 0x130ADFFC6E95A64
0001 ZJ5862 023 0x139E8C32AA177B9
0001 ZJ5858 022 0x13D3048229681BE
0001 ZJ5865 025 0x13DB9109CFED6A1
0002 ZJ5945 027 0x136BD54D4FFC3A3
0002 ZJ5887 028 0x136334095AB011E
0002 ZJ5894 029 0x13E96497A470D31
0002 ZJ5880 030 0x13A131038CD439B
0003 KA0409 031 0x13C27B4F55F1D06
0003 KA0453 032 0x1372E5FF040CC05
0003 KA0461 033 0x139EF8FD59DE21B
0003 KA0472 034 0x13F7BD334FDE8C2
0004 ZJ5614 035 0x13A8715018720BB
0004 ZJ5580 036 0x13600F17F2FA3D8
0004 ZJ5316 037 0x13DBE5C63C24303
0004 ZJ5573 038 0x13F86F952B2042B
0005 KA0441 039 0x13F740BFBA279D1
0005 KA0456 040 0x13094AD9E4FA901
0005 KA0464 042 0x132FC75A89C9285
0005 KA0469 043 0x13945944B4DE7FC
0006 KA0516 044 0x136B7B766DD9200
0006 KA0520 045 0x133D597D8CF68FA
0006 KA0573 046 0x13D3DE76F8845BF
0006 KA0580 047 0x1318351498635B9
0007 KA0632 048 0x13A8ABA4C99E4BA
0007 KA0646 049 0x136BA182BC35601
0007 KA0683 051 0x137A04BB1140EB8
0007 KA0685 052 0x13C1EE6ADF9EE63
0008 KA0302 053 0x1338F096D4E45F5
0008 KA0307 054 0x13B97A5297229A1
0008 KA0379 057 0x13DB4BFD1E012A0
0008 KA0344 058 0x137AAA803365F1B
0009 KA0680 059 0x13F020EA1C49735
0009 KA0764 060 0x134E63D08A85AE1
0009 KA0881 061 0x13C90F2ECAD2CDE
0009 KA0888 063 0x1356A1C2974346A
0010 ZJ5576 064 0x13560FF9B5665C9
0010 ZJ5583 065 0x13CA34306298E18
0010 ZJ5601 066 0x13AB90BA61D467C
0010 ZJ5605 067 0x13D3AAB90B4D01D
0011 KA0275 068 0x13F553F595B7E3B
0011 KA0276 069 0x13B9D469B507802
0011 KA0287 071 0x130105A6D393A1F
0011 KA0289 072 0x13684068C5930C6
0012 KA0614 074 0x13EEF94EF7E72C6
0012 KA0616 075 0x13F05425EF80297
0012 KA0679 076 0x131BA031120C6DC
0012 KA0692 077 0x1371DEE1AC46EC3
0013 KA0325 078 0x133FC374A556BA1
0013 KA0330 079 0x13462CAFBDEC9FF
0013 KA0348 080 0x13278825BEA019B
0013 KA0350 081 0x13107A6BAF0A6A7
0014 KA0504 082 0x138E881C8688E9D
0014 KA0563 084 0x13C14051FDBBFC0
0014 KA0571 086 0x1313EF4E25655C2
0014 KA0575 089 0x139FF7D1FA11225
0015 KA0395 024 0x131B0E0A302977F
0015 KA0396 050 0x13B2A0082A249DA
0015 KA0398 056 0x13E763E9B2AD5E7
0015 KA0399 062 0x13C9A115E8F7D7D
0016 KA0279 070 0x13A8059FEBBB519
0016 KA0280 073 0x13A04AE0DCD2607
0016 KA0281 088 0x13F7EE849802872
0016 KA0284 090 0x13A3AB0AA5740C0
0017 ZJ7133 104 0x131CF9758D0D927
0017 ZJ7134 110 0x13E83A6414D002E
0017 ZJ7135 119 0x139B9B121560046
0017 ZJ6748 124 0x1307D79C7D1A925
0017 ZJ7133 104 0x13E83A6414D002E
0017 ZJ7133 104 0x139B9B121560046
0018 KA0260 100 0x134829B96F82CB8
0018 KA0263 101 0x1373DC6B5CD045C
0018 KA0266 102 0x133936362FCAD89
0018 KA0268 103 0x13A3CF3593FDE31
0019 KA0228 105 0x137BC21BEA6E6C4
0019 KA0240 106 0x13937A56002C2FB
0019 KA0242 107 0x1316DC9EF24A03F
0019 KA0267 108 0x13ED7F13F485DE0
0020 KA0304 109 0x13E0DB20019C293
0020 KA0317 111 0x1355DA1361D8A5F
0020 KA0320 112 0x13676EDEEA903DD
0020 KA0357 113 0x1341E35D87A3859
0021 KA0152 115 0x1331381AF876C85
0021 KA0156 116 0x13EB9AA1BB5909B
0021 KA0201 117 0x139531DF6DD5E23
0021 KA0203 118 0x13F99CA9C312BE7
0022 KA0215 120 0x13F2DEDC0360A9F
0022 KA0232 121 0x137BC1EF90D95B4
0022 KA0238 122 0x13A9977332C6865
0022 KA0250 123 0x13D2932D5391844
0023 KA0245 125 0x136FF8A176A27B2
0023 KA0247 126 0x1327C5FB7406526
0023 KA0249 127 0x138494E6C0A069A
0023 KA0253 128 0x1360079557B13B7
0024 KA0259 129 0x130E6A431C45B16
0024 KA0273 130 0x136AC919653EFDE
0024 KA0274 131 0x13983823C05E383
0024 KA0299 132 0x13777814F10685B
0025 KA0295 133 0x1306253C2B2C808
0025 KA0309 134 0x13989618E27B220
0025 KA0316 135 0x13688E1F68FDD34
0025 KA0323 136 0x139F4A925139FC5
0026 KA0312 137 0x134B03B78A76FAC
0026 KA0335 138 0x131F9B4AA5992CF
0026 KA0342 139 0x13308BE94E95FBA
0026 KA0360 140 0x138271548F7CBE1
0027 KA0375 141 0x1398D74B02AE032
0027 KA0413 142 0x1343E107E58DE61
0027 ZJ5571 143 0x13EB349A997C138
0027 ZJ5579 144 0x135F94C24E28C09
0028 KA0401 145 0x137E2AA352A99D9
0028 KA0466 146 0x130A613789F0094
0028 KA0474 147 0x132D4DDF53D3EED
0028 KA0476 148 0x1376504076DCD77
0029 KA0414 149 0x13B6D4B9A55E085
0029 KA0420 150 0x13C7926B5332CFA
0029 KA0446 151 0x13E37BE5AE15226
0029 KA0447 152 0x1340FE951365AC5
0030 KA0423 153 0x13D0582BFBE6A99
0030 KA0430 154 0x13CB5CABBB937C7
0030 KA0438 155 0x1317F4CA7590513
0030 KA0467 156 0x13B782B4864F995
0031 ZJ5907 157 0x1343E2F39F3AD11
0031 ZJ5908 158 0x1341A20E6776A4B
0031 ZJ6734 159 0x1339980D0DEFC2A
0031 ZJ6739 160 0x13218710344A310
0032 KA0478 161 0x135F0F657F11A1A
0032 KA0510 162 0x13F02282D8FAAA4
0032 KA0514 163 0x13E8A2375F5E54D
0032 KA0522 164 0x13367F377A0D773
0033 KA0535 165 0x13C6F8984E8A8B4
0033 KA0536 166 0x131F201273C001E
0033 KA0537 167 0x134721EBDA90450
0033 KA0569 169 0x13899EEE179C84A
0034 KA0465 170 0x133E05D45E783DD
0034 KA0499 171 0x1359601C7AB04C0
0034 KA0555 172 0x13397765CF1FF9B
0034 KA0572 173 0x000008001809009
0035 KA0589 174 0x13B6BB8C7AD190B
0035 KA0591 175 0x131FBBB542F960D
0035 KA0597 176 0x133E30484D6446D
0035 KA0598 177 0x13B2CAAEC497875
0036 KA0593 178 0x138B9CB475B2E72
0036 KA0648 179 0x13089D69526A0AF
0036 KA0654 180 0x131663C9AB2B42E
0036 KA0704 181 0x130779A75F3F886
0037 KA0530 182 0x13A636E1507E49E
0037 KA0701 183 0x13BC6EFA641894E
0037 KA0722 184 0x13BFCDCBB126A8B
0037 KA0583 185 0x1320E9ECA6CA19E
0038 KA0501 186 0x13DA8D5DE52FADC
0038 KA0502 187 0x1390775CF73709D
0038 KA0503 188 0x1355AEDC9211FFD
0038 KA0521 189 0x135BDEE53B48599
0039 KA0508 190 0x13B14960F6C9F72
0039 KA0570 191 0x13EA3FC583713A6
0039 KA0604 192 0x13D71F06799D16F
0039 KA0617 193 0x136EF7F1E3973EC
0043 KA0665 207 0x13C0D546D14970C
0043 KA0727 208 0x131E2CB69C42730
0043 KA0765 209 0x13DF50794EF4271
0043 KA0785 210 0x13054D9554BAA7E
0040 KA0949 194 0x13D2B116D4009D0
0040 KA0984 195 0x138C993E6DAB4E6
0040 KA0985 196 0x131229EEDE4BDBE
0040 KA0997 197 0x000008001809009
0041 KA0903 198 0x13E0ED486837653
0041 KA0919 199 0x13AE799E6717780
0041 KA0935 200 0x13E6433F903C0A4
0041 KA0954 201 0x13FC00DE881C158
0042 KA0946 202 0x135045905061390
0042 KA0948 204 0x130E2B10FC90904
0042 KA0981 205 0x133025D26CB0E19
0042 KA0983 206 0x13944F7F9E57F39
0044 KA0700 211 0x1383093F933796D
0044 KA0719 212 0x13C4A06BE0370B2
0044 KA0760 213 0x13B66178AB3DD0A
0044 KA0763 214 0x137E1F3F41B5E69
0045 KA0610 215 0x1331D7723A86F34
0045 KA0696 216 0x13E2038EB25E0AA
0045 KA0774 217 0x1390983435C732C
0045 KA0778 219 0x13283D34A09A493
0046 KA0775 220 0x1378704644140B3
0046 KA0793 221 0x13BE413243DB79A
0046 KA0798 222 0x130B1AA8EF0C168
0046 KA0799 223 0x1387FC4FBF364EC
0047 KA0756 224 0x13386AAD5BD9D07
0047 KA0762 225 0x131FCF7AB1303AF
0047 KA0768 226 0x13B793D8FD0BC27
0047 KA0773 227 0x1317800586590B1
0048 KA0742 228 0x13D63752FE47443
0048 KA0747 229 0x13F72708C0E3030
0048 KA0787 230 0x1306FFC8FAC0C09
0048 KA0796 231 0x13768AB4A730976
0049 KA0613 232 0x13ECBBDBCB1880D
0049 KA0757 233 0x13212ED0E3E0703
0049 KA0767 234 0x1331A3BDC94FA96
0049 KA0794 235 0x13AF51CAE0CD2AC
0050 KA0615 236 0x13190E3896B4CD6
0050 KA0626 237 0x13B8417E99F50CE
0050 KA0631 238 0x13F4C45AEF4E7C1
0050 KA0656 239 0x13EE17BA8B13F96
0051 KA0611 240 0x13962DB9E18A9F7
0051 KA0651 241 0x137C1D65239B851
0051 KA0667 242 0x1320DC70B5D662E
0051 KA0684 243 0x13172E3EA47C112
0052 KA0686 244 0x13F78933E2C6193
0052 KA0687 245 0x13FA91A33409981
0052 KA0777 246 0x13AF073E949569A
0052 KA0784 247 0x13D56993E87A2F5
0053 KA0908 248 0x13310D86EB6AB35
0053 KA0917 249 0x1341D6C194BFFE9
0053 KA0952 250 0x13619A00DE08B14
0053 KA0988 251 0x1377E047BA88D38
0054 KA0915 252 0x137104C5EF12665
0054 KA0925 253 0x13DF8A8D9F18670
0054 KA0932 254 0x134178FAB69AE4A
0054 KA0973 255 0x13C68FA3C7F4E66
0055 KA0658 256 0x1363DAFD2644C4E
0055 KA0902 257 0x1328930F82BF530
0055 KA0968 258 0x135DC463D7668C7
0055 KA0987 259 0x13C07B7DF36C6AF
0056 KA0920 261 0x135E2731F8CBF36
0056 KA0976 262 0x13806196ECA1B1B
0056 KA0977 263 0x13FFC64CD5AF28D
0056 KA0982 264 0x13EA383E76FE616
0057 KA0941 265 0x13CFA9DB9792A46
0057 KA0972 266 0x13F14871C542EEA
0057 KA0986 267 0x13F9070EF22BDF4
0057 KA0993 268 0x13F060254298BC6
0058 KA0958 269 0x13FC8B25D8274DF
0058 KA0974 270 0x13A2C06506C8A6F
0058 ZJ6729 271 0x13A99088C749DD5
0058 ZJ7480 272 0x1308DFCEC8081CD
0059 ZJ5600 273 0x13EDA6135FDEA91
0059 ZJ5872 274 0x1395322B1762D53
0059 ZJ6726 275 0x130E852BDEB58A7
0059 ZJ6732 276 0x136A362DC6CCFFB
0060 ZJ5947 277 0x130EB0B7CDA9F17
0060 ZJ5949 278 0x133F2D80D9A26F1
0060 ZJ6721 279 0x13987970208B191
0060 ZJ6731 280 0x13899D1A6D2BB3A
0061 ZJ5876 281 0x13584848FD6A1EC
0061 ZJ5930 282 0x13240DF0F18F9AD
0061 ZJ5943 283 0x133E711BADB167F
0061 ZJ6722 284 0x13A6EC15819209F
0062 ZJ5594 285 0x1377A2E020EAC5A
0062 ZJ5606 286 0x139925EB549811F
0062 ZJ5607 287 0x1369D57FE96180A
0062 ZJ5902 288 0x138C47C5337F627
0063 ZJ5594 285 0x136673167E56141
0063 ZJ5606 286 0x1386A0D4CB25462
0063 ZJ5607 287 0x1349307E747C8E4
0063 ZJ5902 288 0x135F7BAA8CD8FB8
0063 ZJ5932 289 0x136673167E56141
0063 ZJ5933 290 0x1386A0D4CB25462
0063 ZJ5938 291 0x1349307E747C8E4
0063 ZJ6743 292 0x135F7BAA8CD8FB8
0064 ZJ5574 293 0x137B4E1B4FDA6F3
0064 ZJ5911 295 0x13E950970968460
0064 ZJ5912 296 0x1329BB5B056501C
0064 ZJ5919 298 0x1388F41D0A24C04
0065 ZJ5898 299 0x13703F39737D3AD
0065 ZJ5922 300 0x1347A8D4EA5A481
0065 ZJ5931 301 0x13481FD10629878
0065 ZJ5937 302 0x1367F579DBA95CE
0066 ZJ7465 303 0x13E43251F45468E
0066 ZJ7472 304 0x131E491514CF720
0066 ZJ7476 305 0x02027FFF7FFFFFD
0066 ZJ7697 306 0x13949340A0728AE
0067 ZJ7463 307 0x1321F424320C302
0067 ZJ7464 308 0x138537491741631
0067 ZJ7694 309 0x13D2B6ED218FC60
0067 ZJ7701 310 0x13897272AFDB88B
0068 ZJ7467 312 0x13F14F8A30CDB5A
0068 ZJ7482 313 0x13A72B29C4B8602
0068 ZJ7823 314 0x130E1E8CEF8CEB4
0068 ZJ7886 315 0x130768CB247BD34
0069 ZJ7824 316 0x13697B44CB449A9
0069 ZJ7825 317 0x136E2D05327B7ED
0069 ZJ7833 318 0x13B7492C2CE7826
0069 ZJ7893 319 0x135181586FFC67D
0070 ZJ7827 320 0x138D7836202852F
0070 ZJ7831 321 0x13260C5EE916CE5
0070 ZJ7884 322 0x000008001809009
0070 ZJ7891 323 0x1376248F85158D5
0071 ZJ7820 324 0x13F0CE1E60BDA65
0071 ZJ7822 325 0x136F21A1DDF90C3
0071 ZJ7826 326 0x13FE34EC83993A0
0071 ZJ7888 327 0x1356C675ED87D8B
0072 ZJ7889 329 0x1327F468E822456
0072 ZJ7829 330 0x13CFCC781F1FA56
0072 KA0838 331 0x136E833E105E64E
0072 KA0923 332 0x13F9AECE25819E7
0073 KA0820 333 0x1382B9385F63922
0073 KA0821 334 0x000008001809009
0073 KA0822 335 0x13A76A7A246D410
0073 KA0841 336 0x138217037D46881
0074 KA0851 337 0x1354D6B78E5AD71
0074 KA0893 338 0x13DCD688E9D4590
0074 KA0894 339 0x135000CC3F8C742
0074 KA0897 340 0x1359CE275895563
0075 KA0864 341 0x1320724B97F378D
0075 KA0865 342 0x13D69969DC625E0
0075 KA0868 343 0x13F1E1B112E8AF9
0075 KA0883 345 0x133D3D42BA7F60B
0076 KA0831 346 0x130871F5EA2D06E
0076 KA0836 347 0x136FBA06ECC06D0
0076 KA0839 348 0x13E8D6F8AC970EF
0076 KA0840 350 0x13916A9463F1201
0077 KA0808 351 0x135734D5BBB1CA6
0077 KA0801 353 0x13E6E792E51B899
0077 KA0810 354 0x000008001809009
0077 KA0848 355 0x132C428FC6E6AB3
0078 KA0870 356 0x13E1B1D31C246DD
0078 KA0873 357 0x13D93F004B55CAB
0078 KA0874 358 0x13F900F507A4844
0078 KA0878 359 0x13BCE6368F3F438
0079 KA0826 360 0x13E099879BFE3F1
0079 KA0859 361 0x13EB52CD6B46258
0079 KA0876 362 0x133067CD138B5DA
0079 KA0872 363 0x13323717AE37034
0080 KA0817 364 0x1358E1882AC05FF
0080 KA0825 365 0x1349AFD6CA7D837
0080 KA0827 367 0x000008001809009
0080 KA0843 368 0x132075B0627C23D
0081 KA0804 369 0x139B372E961FF32
0081 KA0862 370 0x13DD42BC8C73C5C
0081 KA0869 371 0x13E7800C5A2E0F9
0081 KA0896 372 0x13E492F30E4B873
0082 KA1007 373 0x13EB24C6F87E2AC
0082 KA1019 375 0x134A1D8B6407E40
0082 KA1047 376 0x13943D7B825790D
0082 KA1082 377 0x13417F014315BFA
0083 KA1043 378 0x13FA3D9FB7766F5
0083 KA1045 379 0x13500737CA032F2
0083 KA1093 380 0x135C99C8B933E6F
0083 KA1094 381 0x13D50DC3BB1AF42
0084 KA1011 382 0x13283ACF5515123
0084 KA1035 383 0x13F537CAA33E0CA
0084 KA1080 384 0x13BE803CBE71FB7
0084 KA1088 385 0x13CBA0A8A37DF13
0085 KA0959 386 0x133E47CB214381E
0085 KA1010 387 0x1320DB8B405939E
0085 KA1013 388 0x13FC32B96E8F358
0085 KA1034 389 0x1344A5DE1D416E7
0086 KA1037 390 0x1365E7BC192EBE3
0086 KA1041 391 0x137C0DFA8332044
0086 KA1049 392 0x132547FC0B57921
0086 KA1066 393 0x1331A4463CC0F26
0089 KA0597 176 0x133E30484D6446D
0089 KA0686 244 0x13F78933E2C6193
0089 KA0777 246 0x13AF073E949569A
0089 KA1093 380 0x135C99C8B933E6F
0087 KA1023 394 0x13AFFFF1C2E830F
0087 KA1025 395 0x1365C14BD02C736
0087 KA1027 396 0x132BDD51342BB93
0087 KA1029 397 0x13E878C38EB214C
0088 KA1054 398 0x1377E0FF5FD1799
0088 KA1067 399 0x13B70B3353DC3E5
0088 KA1085 400 0x136DA8C32E478FD
0088 KA1099 401 0x1315E60FB717B3E
0090 KA1006 402 0x13661C23A1D98CF
0090 KA1009 403 0x13959C103547CF0
0090 KA1024 405 0x1339EB390BA9C38
0090 KA1068 406 0x13DD36737FBA9FE
0091 KA1008 407 0x13C4A8FA166F7FB
0091 KA1022 408 0x13DA015D409BAEB
0091 KA1077 409 0x13756AD13381676
0091 KA1098 410 0x13D5790C48D3AE0
0092 KA1018 411 0x13F08C011F861A6
0092 KA1061 412 0x13579AEE9994D05
0092 KA1089 413 0x1320EAA0392484F
0092 KA1081 414 0x13937851A176C2C
0093 KA0937 415 0x1335EBE63987CF1
0093 KA0978 416 0x134CAC093F7225B
0093 KA0166 417 0x132D08833C3EA3F
0093 KA0235 418 0x13AD37C0D183923
0094 KA0929 419 0x13AD430F224AC81
0094 KA0930 420 0x139CDC3F971BBB0
0094 KA1106 421 0x131592C044DEE9C
0094 KA1107 422 0x130443361A62387
0095 KA0368 423 0x13CCE78521064E5
0095 KA0443 424 0x13E87F387B3D4FC
0095 KA0924 425 0x13584FB308E545C
0095 KA1105 426 0x138A92173B6A78B
0096 KA1075 427 0x13813AF66D3DE25
0096 KA1087 428 0x134234A3A154E3E
0096 KA1096 429 0x13E076EF590E040
0096 KA1097 430 0x133A7868995E32A
0097 KA0189 432 0x1344F32A69192D1
0097 KA0222 433 0x134D92CA3663775
0097 ZJ7830 434 0x132358457207499
0097 ZJ7885 435 0x138975895A54D3B
0098 KA1120 436 0x13F47DC659E6046
0098 KA1121 437 0x13750E8160E1BC1
0098 KA1125 438 0x1391288B1CCA9C2
0098 KA1126 439 0x13DEA2D918C235C
0099 KA0672 440 0x13D24E2277F29F5
0099 KA0975 441 0x13200684643A22F
0099 KA1108 442 0x130F98E34A73A3B
0099 ZJ7832 443 0x1366CC412737550
0099 KA1108 442 0x000008001809009
0100 KA1134 444 0x13F52552A2CD608
0100 KA1135 445 0x131DA970807E820
0100 KA1136 446 0x134E9C8C5E96CC2
0100 KA1137 447 0x13980A4426CD183
0101 KA0741 448 0x131D3A46471F97A
0101 KA1102 449 0x135D7DFF61CEF40
0101 KA1130 450 0x1398A47F04E8020
0101 KA1131 452 0x13310A7D1EE5E85
0102 KA0674 453 0x1354ACE1A5A978D
0102 KA0910 454 0x138A98816C68E15
0102 KA0953 455 0x13A7B775000E5A1
0102 KA0970 456 0x13E3D7D92D6AD52
0103 ZJ7464 308 0x138537491741631
0103 KA0203 118 0x13F99CA9C312BE7
0103 KA0654 180 0x131663C9AB2B42E
0103 KA1043 378 0x13FA3D9FB7766F5
0104 KA0785 210 0x13054D9554BAA7E
0104 ZJ7888 327 0x1356C675ED87D8B
0104 KA0309 134 0x13989618E27B220
0104 KA1025 395 0x1365C14BD02C736
0105 KA0667 242 0x1320DC70B5D662E
0105 KA0976 262 0x13806196ECA1B1B
0105 KA0504 082 0x138E881C8688E9D
0105 KA0888 063 0x1356A1C2974346A
0106 KA0520 045 0x133D597D8CF68FA
0106 KA0696 216 0x13E2038EB25E0AA
0106 KA1077 409 0x13756AD13381676
0106 ZJ6731 280 0x13899D1A6D2BB3A
0107 KA0447 152 0x1340FE951365AC5
0107 KA0840 350 0x13916A9463F1201
0107 KA0000 000 0x03012013FFFFFFF
0107 ZJ0000 000 0x1000C09009FFFFF
0108 KA0201 117 0x139531DF6DD5E23
0108 KA0765 209 0x13DF50794EF4271
0108 KA0920 261 0x135E2731F8CBF36
0108 KA1093 380 0x135C99C8B933E6F
0109 KA0398 056 0x13E763E9B2AD5E7
0109 ZJ7833 318 0x13B7492C2CE7826
0109 ZJ7893 319 0x135181586FFC67D
0109 KA0810 354 0x131672A5D06F19C
0110 ZJ7463 307 0x1321F424320C302
0110 KA1019 375 0x134A1D8B6407E40
0110 KA1135 445 0x131DA970807E820
0110 KA1136 446 0x134E9C8C5E96CC2
0111 ZJ7823 314 0x130E1E8CEF8CEB4
0111 KA0684 243 0x13172E3EA47C112
0111 KA0631 238 0x13F4C45AEF4E7C1
0111 KA0747 229 0x13F72708C0E3030
0112 KA1130 450 0x1398A47F04E8020
0112 KA1049 392 0x132547FC0B57921
0112 KA0798 222 0x130B1AA8EF0C168
0112 ZJ7830 434 0x132358457207499
0117 KA0838 331 0x136E833E105E64E
0117 KA0245 125 0x136FF8A176A27B2
0117 KA0287 071 0x130105A6D393A1F
0117 KA0266 102 0x133936362FCAD89
0118 KA0260 100 0x134829B96F82CB8
0118 KA0632 048 0x13A8ABA4C99E4BA
0118 KA0679 076 0x000008001809009
0118 KA1131 452 0x13310A7D1EE5E85
0118 KA0679 076 0x131BA031120C6DC
0119 KA0530 182 0x13A636E1507E49E
0119 KA0774 217 0x1390983435C732C
0119 KA0521 189 0x135BDEE53B48599
0119 KA1080 348 0x13BE803CBE71FB7
0120 KA1061 412 0x13579AEE9994D05
0120 KA0414 149 0x13B6D4B9A55E085
0120 KA1007 373 0x13EB24C6F87E2AC
0120 KA0796 231 0x13768AB4A730976
0121 KA1085 400 0x136DA8C32E478FD
0121 KA0774 217 0x1390983435C732C
0121 KA0722 184 0x13BFCDCBB126A8B
0121 KA1022 408 0x13DA015D409BAEB
0122 KA0897 340 0x1359CE275895563
0122 KA0799 223 0x1387FC4FBF364EC
0122 KA0929 419 0x13AD430F224AC81
0122 KA0570 191 0x13EA3FC583713A6
0113 KA0924 425 0x100000900000FFF
0113 KA1049 392 0x132547FC0B57921
0113 KA0798 222 0x130B1AA8EF0C168
0113 ZJ7830 434 0x132358457207499
0114 0x000001200001FFE
0114 KA0423 153 0x13D0582BFBE6A99
0114 KA1130 450 0x1398A47F04E8020
0114 KA0924 425 0x13584FB308E545C
0115 ZJ6748 124 0x000001200001FFE
0115 ZJ6732 276 0x1307D79C7D1A925
0115 ZJ5943 283 0x136A362DC6CCFFB
0116 KA0777 246 0x000002400003FFC
0116 KA0878 359 0x13AF073E949569A
0116 KA0368 423 0x13BCE6368F3F438
0123 ZJ7134 110 0x13E83A6414D002E
0123 ZJ5316 037 0x13DBE5C63C24303
0123 KA0247 126 0x1327C5FB7406526
0123 KA0510 162 0x13F02282D8FAAA4
0124 KA0881 061 0x13C90F2ECAD2CDE
0124 KA1087 428 0x134234A3A154E3E
0124 KA0981 205 0x133025D26CB0E19
0124 ZJ5908 158 0x1341A20E6776A4B
0125 KA0396 050 0x13B2A0082A249DA
0125 ZJ7820 324 0x13F0CE1E60BDA65
0125 KA0617 193 0x136EF7F1E3973EC
0125 KA0923 332 0x13F9AECE25819E7
0126 KA0808 351 0x135734D5BBB1CA6
0126 ZJ6743 292 0x135F7BAA8CD8FB8
0126 ZJ7697 306 0x13949340A0728AE
0126 KA0919 199 0x13AE799E6717780
0127 ZJ5932 289 0x136673167E56141
0127 ZJ7827 320 0x138D7836202852F
0127 KA0935 200 0x13E6433F903C0A4
0127 ZJ7831 321 0x13260C5EE916CE5
0128 KA0573 046 0x13D3DE76F8845BF
0128 KA0973 255 0x13C68FA3C7F4E66
0128 ZJ5938 291 0x1349307E747C8E4
0128 ZJ7891 323 0x1376248F85158D5
0129 KA0968 258 0x135DC463D7668C7
0129 KA0615 236 0x13190E3896B4CD6
0129 KA0727 208 0x131E2CB69C42730
0129 KA0683 051 0x137A04BB1140EB8
0130 ZJ5902 288 0x138C47C5337F627
0130 KA0563 084 0x13C14051FDBBFC0
0130 ZJ5912 296 0x1329BB5B056501C
0130 ZJ5600 273 0x13EDA6135FDEA91
0131 KA0535 165 0x13C6F8984E8A8B4
0131 KA0342 139 0x13308BE94E95FBA
0131 KA0453 032 0x1372E5FF040CC05
0131 KA0571 086 0x1313EF4E25655C2
0132 KA0295 133 0x1306253C2B2C808
0132 KA0250 123 0x13D2932D5391844
0132 ZJ5605 067 0x13D3AAB90B4D01D
0132 KA0317 111 0x1355DA1361D8A5F
0133 KA0259 129 0x130E6A431C45B16
0133 KA0222 433 0x134D92CA3663775
0133 KA0978 416 0x134CAC093F7225B
0133 KA1137 447 0x13980A4426CD183
0134 KA1097 430 0x133A7868995E32A
0134 ZJ5576 064 0x13560FF9B5665C9
0134 KA0166 417 0x132D08833C3EA3F
0134 KA1029 397 0x13E878C38EB214C
0135 KA0284 090 0x13A3AB0AA5740C0
0135 KA0474 147 0x132D4DDF53D3EED
0135 KA0330 079 0x13462CAFBDEC9FF
0135 KA0953 455 0x13A7B775000E5A1
0136 KA1066 393 0x1331A4463CC0F26
0136 KA0817 364 0x1358E1882AC05FF
0136 KA1041 391 0x137C0DFA8332044
0136 KA0320 112 0x13676EDEEA903DD
0137 ZJ6734 159 0x1339980D0DEFC2A
0137 ZJ6739 160 0x13218710344A310
0137 KA0335 138 0x131F9B4AA5992CF
0137 KA0503 188 0x1355AEDC9211FFD
0138 KA1037 390 0x1365E7BC192EBE3
0138 KA1011 382 0x13283ACF5515123
0138 KA0443 424 0x13E87F387B3D4FC
0138 KA0465 170 0x133E05D45E783DD
0139 ZJ5919 298 0x1388F41D0A24C04
0139 KA0775 220 0x1378704644140B3
0139 KA0441 039 0x13F740BFBA279D1
0139 KA0719 212 0x13C4A06BE0370B2
0140 KA0868 343 0x13F1E1B112E8AF9
0140 KA0763 214 0x137E1F3F41B5E69
0140 ZJ5594 285 0x1377A2E020EAC5A
0140 KA0974 270 0x13A2C06506C8A6F
0141 KA0626 237 0x13B8417E99F50CE
0141 KA0774 217 0x1390983435C732C
0141 KA0836 347 0x136FBA06ECC06D0
0141 KA0401 145 0x137E2AA352A99D9
0142 ZJ7467 312 0x13F14F8A30CDB5A
0142 ZJ7694 309 0x13D2B6ED218FC60
0142 KA0820 333 0x1382B9385F63922
0142 KA0756 224 0x13386AAD5BD9D07
/cvi/apps/sa02_daq/analysis/base.c
0,0 → 1,203
 
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <TROOT.h>
#include <TSystem.h>
#include <TFile.h>
#include <TDirectory.h>
#include <TCanvas.h>
#include <TH2D.h>
 
#include <algorithm>
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <vector>
#include <cctype>
 
 
 
#include "base.h"
 
std::string serialNumberOut;
 
const char * getSN(int runNumber){
char rNum[0xF];
sprintf(rNum,"%04d",runNumber);
std::string rNumber = rNum;
const char * serialNumberFromGraph;
std::string serialNumberTemp;
 
const char * serialNumberFromGraphHEX;
std::string serialNumberTempHEX;
 
std::string delimiter;
size_t pos = 0;
 
TH2D * sum_hxy = (TH2D *) gDirectory->Get("hxy0_sum_0");
// TH2D * sum_hxy = (TH2D *) gDirectory->Get("hxy1_sum_0"); // Za rune od 113 - 117, kjer je bil modul 0 izklopljen
TH2D * h2d = (TH2D *) gDirectory->Get("h2d_0");
 
if(!sum_hxy) {
printf("Ni naloženega dokumenta!\n");
return (char*) "NoFILE";
}
 
serialNumberFromGraph = sum_hxy->GetTitle(); // you get something like: HAPD=ZJ5859/021,ZJ5862/023,ZJ5858/022,ZJ5865/025
serialNumberTemp = serialNumberFromGraph;
delimiter = "=";
pos = serialNumberTemp.find(delimiter);
serialNumberTemp.erase(0, pos + delimiter.length()); // you get something like: ZJ5859/021,ZJ5862/023,ZJ5858/022,ZJ5865/025
//std::cout << "Vrstica 1 " << serialNumberTemp << std::endl;
serialNumberOut = serialNumberTemp;
if(h2d){
serialNumberFromGraphHEX = h2d->GetTitle()+1; // you get something like: FEB0=0x11354161 FEB1=0x11354161 FEB2=0x11354161 FEB3=0x11354161
// there is a whitespace at the beginning of title you want to remove, so you set pointer to +1.
serialNumberTempHEX = serialNumberFromGraphHEX; // you duplicate string
//std::cout << "Vrstica 2 " << serialNumberTempHEX << std::endl;
 
std::string SNtemp, FEBsnHEX, output;
 
delimiter = ",";
//int iteration=0;
while (serialNumberTemp.length()!=0) {
//std::cout << iteration << std::endl;
//iteration++;
if((pos = serialNumberTemp.find(delimiter))!=std::string::npos) SNtemp = serialNumberTemp.substr(0, pos);
else SNtemp = serialNumberTemp.substr(0, serialNumberTemp.length());
//std::cout << "Vrstica 3 " << SNtemp << std::endl;
//std::cout << "Vrstica 3a " << SNtemp.substr(0,SNtemp.find("/")) << " " << SNtemp.substr(SNtemp.find("/")+1) << std::endl;
if(pos!=std::string::npos) serialNumberTemp.erase(0, pos + delimiter.length());
else serialNumberTemp.erase(0, serialNumberTemp.length());
//std::cout << "Vrstica 4 " << serialNumberTemp << std::endl;
if(!SNtemp.compare("noserial")) continue;
FEBsnHEX = serialNumberTempHEX.substr(serialNumberTempHEX.find("=")+1,serialNumberTempHEX.find(" ")-serialNumberTempHEX.find("=")-1);
//std::cout << "Vrstica 5 " << FEBsnHEX << std::endl;
output = rNumber + " " + SNtemp.substr(0,SNtemp.find("/")) + " " + SNtemp.substr(SNtemp.find("/")+1) + " " + FEBsnHEX;
WriteSN(output);
//std::cout << output << std::endl;
serialNumberTempHEX.erase(0,serialNumberTempHEX.find(" ")+1);
}
}
printf("base.c output: %s\n", serialNumberOut.c_str());
return serialNumberOut.c_str();
}
 
int WriteSN(std::string compareLine){
const char * filename = "FEBserial.txt";
std::string line;
 
std::fstream file;
file.open(filename, std::fstream::in);
if (file.is_open()){
while (std::getline(file,line)){
//std::cout << line << std::endl;
if(!line.compare(compareLine)) return 0;
}
file.close();
}
 
file.open(filename, std::fstream::app);
if (file.is_open()){
file << compareLine << endl;
std::cout << "Add into " << filename << ": " << compareLine << std::endl;
 
file.close();
}
 
return 1;
}
 
int file_exists(char * fileName){
struct stat fbuf;
int i = stat (fileName, &fbuf);
if (i==0) return 1; //File found
else return 0;
}
 
GRID mapping(){
int f[6];
int ndim = 400;
char line[400];
GRID m;
FILE * fp = fopen("mapNEW.map","r");
 
/*
Stolpec 0: ASIC
Stolpec 1: Kanal na ASICU
Stolpec 2: x (iz sprednje strani)
Stolpec 3: y (iz sprednje strani)
...
*/
while (fgets(line,ndim,fp) != NULL) {
sscanf(line,"%d%d%d%d%d%d",&f[0],&f[1],&f[2],&f[3],&f[4],&f[5]);
//m.koordinatniSistem[f[2]][f[3]] = f[0]*36+f[1];
m.koordinatniSistem[11-f[2]][11-f[3]] = f[0]*36+f[1];
m.pozicijaPixla[f[0]*36+f[1]] = f[4];
m.pozicijaPixlaNaCipu[f[0]*36+f[1]] = f[5];
}
fclose(fp);
return m;
}
 
int CreateFEBsnFile(){
/*
you have to manualy save:
http://www-f9.ijs.si/~f9daq/aerorich/febtest/lvhvbit/xsltproc.php?xml=febps.xml&xsl=febsnmap.xsl
and then leave in this file only 1 line that contains info
(21 0x0130ADFFC6E95A64<br/>22 0x013D3048229681BE<br/> ..........)
*/
std::string line;
 
size_t pos = 0;
std::string token;
 
ifstream inputFile("xsltproc.html");
ofstream outpuFile;
outpuFile.open ("FEBserial.txt");
 
if (inputFile.is_open()){
while (std::getline(inputFile,line)){
std::cout << line << std::endl;
}
inputFile.close();
}
else std::cout << "Unable to open file" << std::endl;
 
std::string delimiter = "<br/>";
 
while ((pos = line.find(delimiter)) != std::string::npos) {
token = line.substr(0, pos);
if (token.length()>3) token = token.erase(token.find(" ")+3,1); // removes the first number after 0x... in
std::cout << token << std::endl;
outpuFile << token << std::endl;
line.erase(0, pos + delimiter.length());
}
 
std::cout << line << std::endl;
outpuFile << line;
 
outpuFile.close();
 
return 0;
 
}
 
int FEBsn(char * searchFEBserial){
FILE * fp = fopen("FEBserial.txt","r");
int FEBserialINT;
char FEBserialHEX[0xFF];
int ndim = 400;
char line[400];
while (fgets(line,ndim,fp) != NULL) {
sprintf(FEBserialHEX,"");
sscanf(line,"%d%s",&FEBserialINT,FEBserialHEX);
//printf("%d \t %s\n",FEBserialINT, FEBserialHEX);
if(!strcmp(FEBserialHEX,searchFEBserial)) return FEBserialINT;
}
return -1;
}
/cvi/apps/sa02_daq/analysis/base.h
0,0 → 1,17
#ifndef BASE_H_
#define BASE_H_
 
struct GRID{
int koordinatniSistem[12][12];
int pozicijaPixla[144];
int pozicijaPixlaNaCipu[144];
};
 
const char * getSN(int runNumber);
int WriteSN(std::string compareLine);
int file_exists(char *fileName);
GRID mapping();
int CreateFEBsnFile();
int FEBsn(char * searchFEBserial);
 
#endif
/cvi/apps/sa02_daq/analysis/fit.c
0,0 → 1,166
#include <stdio.h>
#include <stdlib.h>
 
#include <TROOT.h>
#include <TH1D.h>
#include <TH1F.h>
#include <TH2D.h>
#include <TH2F.h>
#include <TH2I.h>
#include <TCanvas.h>
#include <TStyle.h>
#include <TSystem.h>
#include <TFile.h>
#include <TDirectory.h>
#include <TPaveText.h>
#include <TSpectrum.h>
#include <TF1.h>
#include <algorithm>
 
#include "base.h"
#include "fit.h"
 
int fit(int kanal) {
GRID m = mapping();
char name[128];
sprintf(name,"hcharge0_0;%d",m.pozicijaPixla[kanal]+1);
 
TF1 * g0, * g1, * g2, * g3;
float gain;
float mean1, sigma1, mean2;
 
TH1D * h = (TH1D *) gDirectory->Get(name);
h->GetXaxis()->SetRangeUser(-50,300);
h->Draw();
TSpectrum * s = new TSpectrum(4);
int nfound = s->Search(h);
 
float * xpeaks = s->GetPositionX();
 
//SORTIRANJE
printf("Peaks found:\t");
for(int i=0; i<nfound;i++){
printf("%f\t",xpeaks[i]);
if(i==nfound-1) printf("\n");
}
float* first(&xpeaks[0]);
float* last(first + nfound);
std::sort(first, last);
printf("Sorted:\t\t");
for(int i=0; i<nfound;i++){
printf("%f\t",xpeaks[i]);
if(i==nfound-1) printf("\n");
}
 
for (int p=0;p<nfound;p++) {
float xp = xpeaks[p];
printf("Vrh številka %d je na poziciji %f\n",p,xp);
if(p==0) {
g0 = new TF1("0ph","gaus",xp-14,xp+14);
h->Fit(g0,"QR");
//g0->GetParameters(&par[0]);
} else if(p==1) {
g1 = new TF1("1ph","gaus",xp-14,xp+14);
h->Fit(g1,"QR+");
//g1->GetParameters(&par[3]);
} else if(p==2) {
g2 = new TF1("2ph","gaus",xp-14,xp+14);
h->Fit(g2,"QR+");
//g2->GetParameters(&par[6]);
} else {
g3 = new TF1("3ph","gaus",xp-14,xp+14);
h->Fit(g3,"QR+");
//g3->GetParameters(&par[9]);
}
}
 
if(nfound >= 1){
mean1 = g0->GetParameter(1);
sigma1 = g0->GetParameter(2);
if (sigma1<7) gain = 0;
else gain = 30;
} else {
gain = 0;
}
if(nfound > 1){
mean2 = g1->GetParameter(1);
printf("%f \t %f\n", mean1, mean2);
if (mean1<mean2) gain = mean2 - mean1;
else gain = mean1 - mean2;
printf("nfound: %d \t gain: %.1f \t mean1: %.1f \t sigma1: %.1f \t mean2: %.1f\n", nfound, gain, mean1, sigma1, mean2);
}
 
delete s;
return gain;
 
}
 
/*
for (int p=0;p<nfound;p++) {
float xp = xpeaks[p];
printf("Vrh številka %d je na poziciji %f\n",p,xp);
if(p==0) {
TF1 * g0 = new TF1("0ph","gaus",xp-14,xp+14);
h->Fit(g0,"QR");
g0->GetParameters(&par[0]);
delete g0;
} else if(p==1) {
TF1 * g1 = new TF1("1ph","gaus",xp-14,xp+14);
h->Fit(g1,"QR+");
g1->GetParameters(&par[3]);
delete g1;
} else if(p==2) {
TF1 * g2 = new TF1("2ph","gaus",xp-14,xp+14);
h->Fit(g2,"QR+");
g2->GetParameters(&par[6]);
delete g2;
} else {
TF1 * g3 = new TF1("3ph","gaus",xp-14,xp+14);
h->Fit(g3,"QR+");
g3->GetParameters(&par[9]);
delete g3;
}
}
if(nfound==1) total = new TF1("mstotal","gaus(0)",xpeaks[0]-14,xpeaks[0]+14);
else if(nfound==2) total = new TF1("mstotal","gaus(0)+gaus(3)",xpeaks[0]-14,xpeaks[1]+14);
else if(nfound==3) total = new TF1("mstotal","gaus(0)+gaus(3)+gaus(6)",xpeaks[0]-14,xpeaks[2]+14);
else total = new TF1("mstotal","gaus(0)+gaus(3)+gaus(6)+gaus(9)",xpeaks[0]-14,xpeaks[3]+14);
total->SetParameters(par);
h->Fit(total,"QR0+");
 
float mean1 = total->GetParameter(1);
//float error1 = total->GetParError(1);
float sigma1 = total->GetParameter(2);
 
float mean2 = total->GetParameter(4);
//float error2 = total->GetParError(4);
*/
 
 
/*
int test(int channel) {
char name[128];
sprintf(name,"hcharge2_0;%d",channel);
TH1D *h=(TH1D *) gDirectory->Get(name);
//h->Draw("");
double par[12];
TSpectrum *s = new TSpectrum(4);
int nfound = s->Search(h,10);
//printf("Found %d candidate peaks to fit\n",nfound);
float *xpeaks = s->GetPositionX();
 
TF1 *g0 = new TF1("0ph","gaus",xpeaks[0]-3,xpeaks[0]+3);
h->Fit(g0,"QR");
g0->GetParameters(&par[0]);
 
TF1 *g1 = new TF1("1ph","gaus",xpeaks[1]-3,xpeaks[1]+3);
h->Fit(g1,"QR+");
g1->GetParameters(&par[3]);
 
//Float_t gainErr = sRt((error1/mean1)*(error1/mean1)+(error2/mean2)*(error2/mean2))
delete s;
return nfound;
}*/
/cvi/apps/sa02_daq/analysis/fit.h
0,0 → 1,6
#ifndef FIT_H_
#define FIT_H_
 
int fit(int kanal);
 
#endif
/cvi/apps/sa02_daq/analysis/focus.c
0,0 → 1,650
#include <stdio.h>
#include <stdlib.h>
 
#include <TROOT.h>
#include <TH1D.h>
#include <TH2D.h>
#include <TH3D.h>
#include <TCanvas.h>
#include <TStyle.h>
#include <TSystem.h>
#include <TFile.h>
#include <TDirectory.h>
#include <TPaveText.h>
 
#include "base.h"
#include "focus.h"
 
int focus(int runNumber, int save) {
 
int HAPDnumber; //Number of HAPD: 0, 1, 2 or 3!
 
int direction, nx, ny;
char name[128];
char pdfname[128];
char buf[256];
float pNoise;
int color[6] = {1,2,4,6,8,9};
 
char hname[0xF];
 
int max = 20;
 
TFile * data[max];
 
 
for (int b=0;b<max;b++){
sprintf(buf,"./meritve/%04d_4_2DX_zOS_%05d.root",runNumber+b,(runNumber-10+b)*1000);
data[b] = new TFile(buf);
}
 
const char * serialNumber = getSN();
char * serialNumberTemp = strdup(serialNumber);
char * HAPDserialNumber;
 
GRID m = mapping();
int vrstaPisave = 82;
 
TCanvas * c;
TPad * pad1, * pad2, * pad3;
TPad * VirtualPad2[12];
TPaveText * info, * axisName;
TAxis * axis;
TH3D * h;
TH2D * slice[12]; //take the right slice from 3D histogram
TH1D * p[12];
 
/********** GLOBALNE **********/
gStyle->SetOptStat(0);
//gStyle->SetOptTitle(1);
gStyle->SetTitleFontSize(.15);
 
for(int HAPDnumber=0;HAPDnumber<4;HAPDnumber++){
HAPDserialNumber = strsep(&serialNumberTemp,",");
if(!strcmp(HAPDserialNumber,"noserial")) continue;
sprintf(hname,"hxy%d_0;1",HAPDnumber);
printf("%s \t %s \n",HAPDserialNumber,hname);
 
h = (TH3D *) data[0]->Get(hname);
 
/********** SMER MERITVE **********/
h->GetZaxis()->SetRange(1,1);
nx = h->GetNbinsX();
ny = h->GetNbinsY();
if (nx>=ny) direction = 0;
else direction = 1;
 
printf("Direction = %d\n", direction);
 
/********** CANVAS **********/
if (!direction) {
sprintf(buf,"%04d_%s_px",runNumber,HAPDserialNumber);
c = new TCanvas(buf,buf,0,0,2000,2000);
} else {
sprintf(buf,"%04d_%s_py",runNumber,HAPDserialNumber);
c = new TCanvas(buf,buf,0,0,2000,2000);
}
c->Divide(4,5,0,0);
 
for(int a=0;a<max;a++){
c->cd(a+1);
c->cd(a+1)->SetBorderSize(0);
c->cd(a+1)->SetBorderMode(0);
pad1 = new TPad("pad1","Title",0.05,0.94,0.95,1,0,0);
pad1->SetFillStyle(4000);
pad1->Draw();
 
pad2 = new TPad("pad2","Graphs",0,0,1,0.95,0,0);
pad2->SetFillStyle(4000);
pad2->Draw();
 
pad3 = new TPad("pad3","AxisTitle",0.57,0,0.92,0.05,0,0);
pad3->SetFillStyle(4000);
pad3->Draw();
/********** PAD 1 **********/
pad1->cd();
info = new TPaveText(0.2,0,0.8,1,"ndc");
info->SetBorderSize(0);
info->SetFillColor(4000);
info->SetTextSize(1);
info->SetTextAlign(22);
sprintf(name,"Z = %d stage steps", (runNumber-10+a)*1000);
info->AddText(name);
info->Draw();
 
/********** PAD3 **********/
pad3->cd();
axisName = new TPaveText(0.2,0,0.8,1,"ndc");
axisName->SetBorderSize(0);
axisName->SetFillColor(4000);
axisName->SetTextSize(.7);
axisName->SetTextFont(vrstaPisave);
axisName->SetTextAlign(22);
sprintf(name,"Incident light position (stage step)");
axisName->AddText(name);
//axisName->Draw();
/********** PAD2 **********/
pad2->cd();
pad2->Divide(1,4,0,0);
 
if(a) h = (TH3D *) data[a]->Get(hname);
 
for (int i=4;i<8;i++) {
if (!direction) {
pad2->cd(11 - i+1-4);
VirtualPad2[11 - i-4] = (TPad *)(pad2->cd(11 - i+1-4)); //Tole nastaviš zato, da lahko daš Log skalo
VirtualPad2[11 - i-4]->SetLogy(1);
//VirtualPad2[11 - i]->SetLeftMargin(.05);
//VirtualPad2[11 - i]->SetRightMargin(.05);
//VirtualPad2[11 - i]->SetGrid();
} else {
pad2->cd(i+1-4);
VirtualPad2[i-4] = (TPad *)(pad2->cd(11 - i+1 - 4)); //Tole nastaviš zato, da lahko daš Log skalo
VirtualPad2[i-4]->SetLogy(1);
//VirtualPad2[i]->SetLeftMargin(.05);
//VirtualPad2[i]->SetRightMargin(.05);
//VirtualPad2[i]->SetGrid();
}
for (int j=4;j<8;j++) {
if (!direction) h->GetZaxis()->SetRange(m.koordinatniSistem[j][i]+1,m.koordinatniSistem[j][i]+1);
else h->GetZaxis()->SetRange(m.koordinatniSistem[i][j]+1,m.koordinatniSistem[i][j]+1);
 
slice[j] = (TH2D *)h->Project3D("pyx");
 
if (!direction) {
sprintf(name,"PX: (%d,%d)",j,i);
p[j] = slice[j]->ProjectionX(name,i+1-4,i+1-4);
sprintf(name,"Projection X of row %d",i);
} else {
sprintf(name,"PY: (%d,%d)",i,j);
p[j] = slice[j]->ProjectionY(name,i+1-4,i+1-4);
sprintf(name,"Projection Y of column %d",i);
}
axis = p[j]->GetXaxis();
 
 
if(!direction) VirtualPad2[3]->SetBottomMargin(.17);
else VirtualPad2[0]->SetBottomMargin(.17);
 
p[j]->SetLineWidth(1);
 
p[j]->SetTitle(name);
p[j]->SetTitleOffset(1.5);
 
p[j]->GetYaxis()->SetRangeUser(1,10000);
p[j]->GetYaxis()->SetTickLength(0.01);
p[j]->GetYaxis()->SetTitleFont(vrstaPisave);
p[j]->GetYaxis()->SetLabelFont(vrstaPisave);
p[j]->GetYaxis()->SetLabelSize(0.05);
p[j]->GetYaxis()->SetLabelColor(kBlack);
p[j]->GetYaxis()->SetTitle("# events");
p[j]->GetYaxis()->SetNdivisions(0);
p[j]->GetYaxis()->CenterTitle();
p[j]->GetYaxis()->SetTitleSize(0.05);
p[j]->GetYaxis()->SetTitleOffset(.5);
p[j]->GetYaxis()->SetTitleColor(kWhite);
 
p[j]->GetXaxis()->SetTickLength(0.1);
p[j]->GetXaxis()->SetTitleFont(vrstaPisave);
p[j]->GetXaxis()->SetLabelFont(vrstaPisave);
p[j]->GetXaxis()->SetLabelSize(0.15);
p[j]->GetXaxis()->SetLabelColor(kBlack);
p[j]->GetXaxis()->SetLabelOffset(.05);
p[j]->GetXaxis()->SetTitle("Incident light position (stage step)");
//p[j]->GetXaxis()->SetNdivisions(0);
//p[j]->GetXaxis()->CenterTitle();
p[j]->GetXaxis()->SetTitleSize(0.01);
p[j]->GetXaxis()->SetTitleColor(kWhite); //zato ker ga ne moreš pozicionirat
p[j]->GetXaxis()->SetTitleOffset(.5);
 
pNoise = noise(p[j]);
for (int k=1;k<=p[j]->GetSize();k++) p[j]->SetBinContent(k,p[j]->GetBinContent(k)-pNoise);
 
if (j<6) p[j]->SetLineColor(kWhite+color[j]);
else p[j]->SetLineColor(kWhite+color[j-6]);
if (j==4) p[j]->DrawCopy();
else p[j]->DrawCopy("SAME");
}
}
}
c->Modified();
c->Update();
if (save==1){
switch (direction) {
case 0: sprintf(pdfname,"./meritve/%s_4_2DX_focus1_run%04d_to%04d.pdf",HAPDserialNumber,runNumber,runNumber+max-1);break;
case 1: sprintf(pdfname,"./meritve/%s_5_2DY_focus1_run%04d_to%04d.pdf",HAPDserialNumber,runNumber,runNumber+max-1);break;
}
c->SaveAs(pdfname,"pdf");
} else if (save==2){
switch (direction) {
case 0: sprintf(pdfname,"./meritve/%s_4_2DX_focus1.pdf(",HAPDserialNumber);break;
case 1: sprintf(pdfname,"./meritve/%s_5_2DY_focus1.pdf(",HAPDserialNumber);break;
}
c->SaveAs(pdfname,"pdf");
} else if (save==3){
switch (direction) {
case 0: sprintf(pdfname,"./meritve/%s_4_2DX_focus1.pdf",HAPDserialNumber);break;
case 1: sprintf(pdfname,"./meritve/%s_5_2DY_focus1.pdf",HAPDserialNumber);break;
}
c->SaveAs(pdfname,"pdf");
} else if (save==4){
switch (direction) {
case 0: sprintf(pdfname,"./meritve/%s_4_2DX_focus1.pdf)",HAPDserialNumber);break;
case 1: sprintf(pdfname,"./meritve/%s_5_2DY_focus1.pdf)",HAPDserialNumber);break;
}
c->SaveAs(pdfname,"pdf");
}
}
 
return 0;
}
 
int focus2(int runNumber, int save) {
 
int HAPDnumber; //Number of HAPD: 0, 1, 2 or 3!
 
int direction, nx, ny;
char name[128];
char pdfname[128];
char buf[256];
float pNoise;
int color[6] = {1,2,4,6,8,9};
 
char hname[0xF];
int max = 20;
 
TFile * data[max];
for (int b=0;b<max;b++){
sprintf(buf,"./meritve/%04d_4_2DX_zOS_%05d.root",runNumber+b,(runNumber-10+b)*1000);
data[b] = new TFile(buf);
}
 
const char * serialNumber = getSN();
char * serialNumberTemp = strdup(serialNumber);
char * HAPDserialNumber;
 
GRID m = mapping();
int vrstaPisave = 82;
 
TCanvas * c;
TPad * pad2;
TPad * VirtualPad2[max];
TH3D * h;
TH2D * slice[max]; //take the right slice from 3D histogram
TH1D * p[max];
 
/********** GLOBALNE **********/
gStyle->SetOptStat(0);
//gStyle->SetOptTitle(1);
gStyle->SetTitleFontSize(.15);
 
 
int line = 1;
for(int HAPDnumber=0;HAPDnumber<4;HAPDnumber++){
HAPDserialNumber = strsep(&serialNumberTemp,",");
if(!strcmp(HAPDserialNumber,"noserial")) continue;
sprintf(hname,"hxy%d_0;1",HAPDnumber);
printf("%s \t %s \n",HAPDserialNumber,hname);
 
h = (TH3D *) data[0]->Get(hname);
 
/********** SMER MERITVE **********/
h->GetZaxis()->SetRange(1,1);
nx = h->GetNbinsX();
ny = h->GetNbinsY();
if (nx>=ny) direction = 0;
else direction = 1;
 
printf("Direction = %d\n", direction);
 
/********** CANVAS **********/
if (!direction) {
sprintf(buf,"%04d_%s_px",runNumber,HAPDserialNumber);
c = new TCanvas(buf,buf,0,0,500,2000);
} else {
sprintf(buf,"%04d_%s_py",runNumber,HAPDserialNumber);
c = new TCanvas(buf,buf,0,0,2000,2000);
}
pad2 = new TPad("pad2","Graphs",0,0,1,1,0,0);
pad2->SetFillStyle(4000);
pad2->Draw();
/********** PAD2 **********/
pad2->cd();
pad2->Divide(1,max,0,0);
 
for (int i=0;i<max;i++) {
if(i) h = (TH3D *) data[i]->Get(hname);
 
pad2->cd(i+1);
VirtualPad2[i] = (TPad *)(pad2->cd(i+1)); //Tole nastaviš zato, da lahko daš Log skalo
VirtualPad2[i]->SetLogy(1);
//VirtualPad2[i]->SetLeftMargin(.05);
//VirtualPad2[i]->SetRightMargin(.05);
//VirtualPad2[i]->SetGrid();
for (int j=4;j<8;j++) {
if (!direction) h->GetZaxis()->SetRange(m.koordinatniSistem[j][line+4]+1,m.koordinatniSistem[j][line+4]+1);
else h->GetZaxis()->SetRange(m.koordinatniSistem[line+4][j]+1,m.koordinatniSistem[line+4][j]+1);
 
slice[j] = (TH2D *)h->Project3D("pyx");
 
if (!direction) {
sprintf(name,"PX: (%d,%d)",j,line+4);
p[j] = slice[j]->ProjectionX(name,line+1,line+1);
sprintf(name,"Z = %d Projection X of row %d",(runNumber-10+i)*1000,line+4);
} else {
sprintf(name,"PY: (%d,%d)",line+4,j);
p[j] = slice[j]->ProjectionY(name,line+1,line+1);
sprintf(name,"Z = %d Projection Y of column %d",(runNumber-10+i)*1000,line+4);
}
 
p[j]->SetLineWidth(1);
 
p[j]->SetTitle(name);
p[j]->SetTitleOffset(1.5);
 
p[j]->GetYaxis()->SetRangeUser(1,10000);
p[j]->GetYaxis()->SetTickLength(0.01);
p[j]->GetYaxis()->SetTitleFont(vrstaPisave);
p[j]->GetYaxis()->SetLabelFont(vrstaPisave);
p[j]->GetYaxis()->SetLabelSize(0.05);
p[j]->GetYaxis()->SetLabelColor(kBlack);
p[j]->GetYaxis()->SetTitle("# events");
p[j]->GetYaxis()->SetNdivisions(0);
p[j]->GetYaxis()->CenterTitle();
p[j]->GetYaxis()->SetTitleSize(0.05);
p[j]->GetYaxis()->SetTitleOffset(.5);
p[j]->GetYaxis()->SetTitleColor(kWhite);
 
p[j]->GetXaxis()->SetTickLength(0.1);
p[j]->GetXaxis()->SetTitleFont(vrstaPisave);
p[j]->GetXaxis()->SetLabelFont(vrstaPisave);
p[j]->GetXaxis()->SetLabelSize(0.15);
p[j]->GetXaxis()->SetLabelColor(kBlack);
p[j]->GetXaxis()->SetLabelOffset(.05);
p[j]->GetXaxis()->SetTitle("Incident light position (stage step)");
//p[j]->GetXaxis()->SetNdivisions(0);
//p[j]->GetXaxis()->CenterTitle();
p[j]->GetXaxis()->SetTitleSize(0.01);
p[j]->GetXaxis()->SetTitleColor(kWhite); //zato ker ga ne moreš pozicionirat
p[j]->GetXaxis()->SetTitleOffset(.5);
 
pNoise = noise(p[j]);
for (int k=1;k<=p[j]->GetSize();k++) p[j]->SetBinContent(k,p[j]->GetBinContent(k)-pNoise);
 
if (j<6) p[j]->SetLineColor(kWhite+color[j]);
else p[j]->SetLineColor(kWhite+color[j-6]);
if (j==4) p[j]->DrawCopy();
else p[j]->DrawCopy("SAME");
}
if(i==max-1) VirtualPad2[max-1]->SetBottomMargin(.17);
 
}
c->Modified();
c->Update();
if (save==1){
switch (direction) {
case 0: sprintf(pdfname,"./meritve/%s_4_2DX_focus2_run%04d_to%04d.pdf",HAPDserialNumber,runNumber,runNumber+max-1);break;
case 1: sprintf(pdfname,"./meritve/%s_5_2DY_focus2_run%04d_to%04d.pdf",HAPDserialNumber,runNumber,runNumber+max-1);break;
}
c->SaveAs(pdfname,"pdf");
} else if (save==2){
switch (direction) {
case 0: sprintf(pdfname,"./meritve/%s_4_2DX_focus2.pdf(",HAPDserialNumber);break;
case 1: sprintf(pdfname,"./meritve/%s_5_2DY_focus2.pdf(",HAPDserialNumber);break;
}
c->SaveAs(pdfname,"pdf");
} else if (save==3){
switch (direction) {
case 0: sprintf(pdfname,"./meritve/%s_4_2DX_focus2.pdf",HAPDserialNumber);break;
case 1: sprintf(pdfname,"./meritve/%s_5_2DY_focus2.pdf",HAPDserialNumber);break;
}
c->SaveAs(pdfname,"pdf");
} else if (save==4){
switch (direction) {
case 0: sprintf(pdfname,"./meritve/%s_4_2DX_focus2.pdf)",HAPDserialNumber);break;
case 1: sprintf(pdfname,"./meritve/%s_5_2DY_focus2.pdf)",HAPDserialNumber);break;
}
c->SaveAs(pdfname,"pdf");
}
}
 
return 0;
}
 
int focus3(int runNumber, int save) {
 
int HAPDnumber; //Number of HAPD: 0, 1, 2 or 3!
 
int direction, nx, ny;
char name[128];
char pdfname[128];
char buf[256];
float pNoise;
int color[6] = {1,2,4,6,8,9};
 
char hname[0xF];
 
const char * serialNumber = getSN();
char * serialNumberTemp = strdup(serialNumber);
char * HAPDserialNumber;
 
GRID m = mapping();
int vrstaPisave = 82;
 
TCanvas * c;
TPad * pad1, * pad2, * pad3;
TPad * VirtualPad2[12];
TPaveText * info, * axisName;
TAxis * axis;
TH3D * h;
TH2D * slice[12]; //take the right slice from 3D histogram
TH1D * p[12];
 
/********** GLOBALNE **********/
gStyle->SetOptStat(0);
//gStyle->SetOptTitle(1);
gStyle->SetTitleFontSize(.15);
 
for(int HAPDnumber=0;HAPDnumber<4;HAPDnumber++){
HAPDserialNumber = strsep(&serialNumberTemp,",");
if(!strcmp(HAPDserialNumber,"noserial")) continue;
sprintf(hname,"hxy%d_0;1",HAPDnumber);
printf("%s \t %s \n",HAPDserialNumber,hname);
 
h = (TH3D *) gDirectory->Get(hname);
 
/********** SMER MERITVE **********/
h->GetZaxis()->SetRange(1,1);
nx = h->GetNbinsX();
ny = h->GetNbinsY();
if (nx>=ny) direction = 0;
else direction = 1;
 
printf("Direction = %d\n", direction);
 
/********** CANVAS **********/
if (!direction) {
sprintf(buf,"%04d_%s_px",runNumber,HAPDserialNumber);
c = new TCanvas(buf,buf,0,0,700,700);
} else {
sprintf(buf,"%04d_%s_py",runNumber,HAPDserialNumber);
c = new TCanvas(buf,buf,0,0,700,700);
}
pad1 = new TPad("pad1","Title",0.05,0.94,0.95,1,0,0);
pad1->SetFillStyle(4000);
pad1->Draw();
 
pad2 = new TPad("pad2","Graphs",0,0,1,0.95,0,0);
pad2->SetFillStyle(4000);
pad2->Draw();
 
pad3 = new TPad("pad3","AxisTitle",0.57,0,0.92,0.05,0,0);
pad3->SetFillStyle(4000);
pad3->Draw();
/********** PAD 1 **********/
pad1->cd();
info = new TPaveText(0.2,0,0.8,1,"ndc");
info->SetBorderSize(0);
info->SetFillColor(4000);
info->SetTextSize(1);
info->SetTextAlign(22);
sprintf(name,"HAPD# %s (center)", HAPDserialNumber);
info->AddText(name);
info->Draw();
 
/********** PAD3 **********/
pad3->cd();
axisName = new TPaveText(0.2,0,0.8,1,"ndc");
axisName->SetBorderSize(0);
axisName->SetFillColor(4000);
axisName->SetTextSize(.7);
axisName->SetTextFont(vrstaPisave);
axisName->SetTextAlign(22);
sprintf(name,"Incident light position (stage step)");
axisName->AddText(name);
//axisName->Draw();
/********** PAD2 **********/
pad2->cd();
pad2->Divide(1,4,0,0);
 
h = (TH3D *) gDirectory->Get(hname);
 
for (int i=4;i<8;i++) {
if (!direction) {
pad2->cd(11 - i+1-4);
VirtualPad2[11 - i-4] = (TPad *)(pad2->cd(11 - i+1-4)); //Tole nastaviš zato, da lahko daš Log skalo
VirtualPad2[11 - i-4]->SetLogy(1);
//VirtualPad2[11 - i]->SetLeftMargin(.05);
//VirtualPad2[11 - i]->SetRightMargin(.05);
VirtualPad2[11 - i-4]->SetGrid();
} else {
pad2->cd(i+1-4);
VirtualPad2[i-4] = (TPad *)(pad2->cd(11 - i+1 - 4)); //Tole nastaviš zato, da lahko daš Log skalo
VirtualPad2[i-4]->SetLogy(1);
//VirtualPad2[i]->SetLeftMargin(.05);
//VirtualPad2[i]->SetRightMargin(.05);
VirtualPad2[i-4]->SetGrid();
}
for (int j=4;j<8;j++) {
if (!direction) h->GetZaxis()->SetRange(m.koordinatniSistem[j][i]+1,m.koordinatniSistem[j][i]+1);
else h->GetZaxis()->SetRange(m.koordinatniSistem[i][j]+1,m.koordinatniSistem[i][j]+1);
 
slice[j] = (TH2D *)h->Project3D("pyx");
 
if (!direction) {
sprintf(name,"PX: (%d,%d)",j,i);
p[j] = slice[j]->ProjectionX(name,i+1-4,i+1-4);
sprintf(name,"Projection X of row %d",i);
} else {
sprintf(name,"PY: (%d,%d)",i,j);
p[j] = slice[j]->ProjectionY(name,i+1-4,i+1-4);
sprintf(name,"Projection Y of column %d",i);
}
axis = p[j]->GetXaxis();
 
 
if(!direction) VirtualPad2[3]->SetBottomMargin(.17);
else VirtualPad2[0]->SetBottomMargin(.17);
 
p[j]->SetLineWidth(1);
 
p[j]->SetTitle(name);
p[j]->SetTitleOffset(1.5);
 
p[j]->GetYaxis()->SetRangeUser(1,10000);
p[j]->GetYaxis()->SetTickLength(0.01);
p[j]->GetYaxis()->SetTitleFont(vrstaPisave);
p[j]->GetYaxis()->SetLabelFont(vrstaPisave);
p[j]->GetYaxis()->SetLabelSize(0.05);
p[j]->GetYaxis()->SetLabelColor(kBlack);
p[j]->GetYaxis()->SetTitle("# events");
p[j]->GetYaxis()->SetNdivisions(0);
p[j]->GetYaxis()->CenterTitle();
p[j]->GetYaxis()->SetTitleSize(0.05);
p[j]->GetYaxis()->SetTitleOffset(.5);
p[j]->GetYaxis()->SetTitleColor(kWhite);
 
p[j]->GetXaxis()->SetTickLength(0.1);
p[j]->GetXaxis()->SetTitleFont(vrstaPisave);
p[j]->GetXaxis()->SetLabelFont(vrstaPisave);
p[j]->GetXaxis()->SetLabelSize(0.15);
p[j]->GetXaxis()->SetLabelColor(kBlack);
p[j]->GetXaxis()->SetLabelOffset(.05);
p[j]->GetXaxis()->SetTitle("Incident light position (stage step)");
//p[j]->GetXaxis()->SetNdivisions(0);
//p[j]->GetXaxis()->CenterTitle();
p[j]->GetXaxis()->SetTitleSize(0.01);
p[j]->GetXaxis()->SetTitleColor(kWhite); //zato ker ga ne moreš pozicionirat
p[j]->GetXaxis()->SetTitleOffset(.5);
 
pNoise = noise(p[j]);
for (int k=1;k<=p[j]->GetSize();k++) p[j]->SetBinContent(k,p[j]->GetBinContent(k)-pNoise);
 
if (j<6) p[j]->SetLineColor(kWhite+color[j]);
else p[j]->SetLineColor(kWhite+color[j-6]);
if (j==4) p[j]->DrawCopy();
else p[j]->DrawCopy("SAME");
}
}
c->Modified();
c->Update();
if (save==1){
switch (direction) {
case 0: sprintf(pdfname,"./meritve/%03d_%s_4_2DX_focus3.pdf",runNumber,HAPDserialNumber);break;
case 1: sprintf(pdfname,"./meritve/%03d_%s_5_2DY_focus3.pdf",runNumber,HAPDserialNumber);break;
}
c->SaveAs(pdfname,"pdf");
} else if (save==2){
switch (direction) {
case 0: sprintf(pdfname,"./meritve/%s_4_2DX_focus3.pdf(",HAPDserialNumber);break;
case 1: sprintf(pdfname,"./meritve/%s_5_2DY_focus3.pdf(",HAPDserialNumber);break;
}
c->SaveAs(pdfname,"pdf");
} else if (save==3){
switch (direction) {
case 0: sprintf(pdfname,"./meritve/%s_4_2DX_focus3.pdf",HAPDserialNumber);break;
case 1: sprintf(pdfname,"./meritve/%s_5_2DY_focus3.pdf",HAPDserialNumber);break;
}
c->SaveAs(pdfname,"pdf");
} else if (save==4){
switch (direction) {
case 0: sprintf(pdfname,"./meritve/%s_4_2DX_focus3.pdf)",HAPDserialNumber);break;
case 1: sprintf(pdfname,"./meritve/%s_5_2DY_focus3.pdf)",HAPDserialNumber);break;
}
c->SaveAs(pdfname,"pdf");
}
}
 
return 0;
}
 
float noise(TH1D * proj) {
float nBin=proj->GetSize(); //ugotovi koliko binov je v histogramu
float wholeAverage=0; //sem da povprečje celotnega kanala
float noise=0; //sem da povprečn šum
int j=0;
for (int i=1;i<=nBin;i++) wholeAverage+=proj->GetBinContent(i)/nBin;
for (int i=1;i<=nBin;i++) {
if (proj->GetBinContent(i)<1.1*wholeAverage) {
noise+=proj->GetBinContent(i);
j++;
}
}
if(j!=0) return noise/j;
else return 0;
}
/cvi/apps/sa02_daq/analysis/focus.h
0,0 → 1,9
#ifndef FOCUS_H_
#define FOCUS_H_
 
int focus(int runNumber, int save = 0);
int focus2(int runNumber, int save = 0);
int focus3(int runNumber, int save = 0);
float noise(TH1D * proj);
 
#endif
/cvi/apps/sa02_daq/analysis/gain.c
0,0 → 1,604
#include <stdio.h>
#include <stdlib.h>
 
#include <TROOT.h>
#include <TH1D.h>
#include <TH1F.h>
#include <TH2D.h>
#include <TH2F.h>
#include <TH2I.h>
#include <TNtuple.h>
#include <TTree.h>
#include <TGraph.h>
#include <TGraphErrors.h>
#include <TCanvas.h>
#include <TStyle.h>
#include <TSystem.h>
#include <TFile.h>
#include <TDirectory.h>
#include <TPaveText.h>
#include <TSpectrum.h>
#include <TF1.h>
#include <TColor.h>
#include <algorithm>
using namespace std;
 
#include <iostream>
#include <string>
 
#include "base.h"
#include "gain.h"
#include "savetoroot.h"
 
int charge(int runNumber, int save){
 
int HAPDnumber; //Number of HAPD: 0, 1, 2 or 3!
 
double xmin = -50;
double xmax = 300;
char name[64];
char pdfname[128];
char buf[256];
char hname[0xF];
 
sprintf(buf,"../modules/%04d/%04d_1_Treshold_Waveform.root",runNumber,runNumber);
TFile * data = new TFile(buf);
 
const char * serialNumber = getSN(runNumber);
printf("base.c return: %s\n", serialNumber);
/******* PREVERI ČE JE NALOŽEN FILE *******/
if (!strcmp(serialNumber, "NoFILE")){
printf("Ni naloženege datoteke\n");
return -1;
}
std::string serialNumberTemp = serialNumber;
std::cout << serialNumberTemp << std::endl;
std::string HAPDserialNumber,FEBserialNumber;
 
GRID m = mapping();
int vrstaPisave = 82;
 
TCanvas * c, * c4;
TH1D * h;
TH2D * h2 = NULL;
TPad * pad1, * pad2, * pad3;
TPaveText * sn, * gainTitle;
 
/********** GLOBALNE **********/
gStyle->SetOptStat(0);
//gStyle->SetOptTitle(1);
gStyle->SetTextFont(vrstaPisave);
gStyle->SetTitleFont(vrstaPisave);
gStyle->SetTitleFontSize(0.1);
gStyle->SetNumberContours(100);
 
gStyle->SetPalette(55);
 
//gROOT->SetBatch(kTRUE); //Does not show canvases
 
 
 
/******* ZRIHTA GRAFE *******/
for(HAPDnumber=0;HAPDnumber<4;HAPDnumber++){
if(save==2) {
SaveToRootInit();
}
//std::cout << serialNumberTemp << std::endl;
FEBserialNumber = serialNumberTemp.substr(0,serialNumberTemp.find(","));
serialNumberTemp.erase(0,FEBserialNumber.length()+1);
if(!FEBserialNumber.compare("noserial")) continue;
HAPDserialNumber = FEBserialNumber.substr(0,FEBserialNumber.find("/"));
FEBserialNumber.erase(0,FEBserialNumber.find("/")+1);
sprintf(hname,"hcharge%d_0",HAPDnumber);
printf("%s \t %s \t %s \n",FEBserialNumber.c_str(),HAPDserialNumber.c_str(),hname);
 
sprintf(name,"%04d_%s_Charge_c4",runNumber,HAPDserialNumber.c_str());
c4 = new TCanvas(name,name,0,0,1200,1200);
c4->Divide(2,2);
 
for (int chip=0;chip<4; chip++){
sprintf(name,"%04d_%s_c%d",runNumber,HAPDserialNumber.c_str(),chip);
c = new TCanvas(name,name,0,0,1200,1200);
c->cd();
pad1 = new TPad("pad11","SN",0,0.975,1,1,0,0);
pad1->SetFillStyle(4000);
pad1->Draw();
pad1->cd();
sn = new TPaveText(0.2,0,0.8,1,"ndc");
sn->SetBorderSize(0);
sn->SetFillColor(4000);
sn->SetTextSize(.8);
sn->SetTextAlign(22);
sprintf(buf,"Charge %s",HAPDserialNumber.c_str());
sn->AddText(buf);
//sn->Draw();
 
/******* DRUGI PAD *******/
c->cd();
pad2 = new TPad("pad2","Date",0.05,0.95,0.95,.99,0,0);
pad2->SetFillStyle(4000);
pad2->Draw();
pad2->cd();
gainTitle = new TPaveText(0,0,1,1,"ndc");
gainTitle->SetBorderSize(0);
gainTitle->SetFillColor(kSpring+1);
gainTitle->SetTextSize(.8);
gainTitle->SetTextAlign(22);
sprintf(buf,"Charge scan over center of channels:");
switch(chip){
case 0: sprintf(buf,"%s Chip A",buf);break;
case 1: sprintf(buf,"%s Chip B",buf);break;
case 2: sprintf(buf,"%s Chip D",buf);break;
case 3: sprintf(buf,"%s Chip C",buf);break;
}
gainTitle->AddText(buf);
gainTitle->Draw();
 
//----------- PAD 2 (FIGURES)
c->cd();
pad3 = new TPad("pad3","Figures",0,0,1,0.96,0,0);
pad3->SetFillStyle(4000);
pad3->Draw();
pad3->cd();
pad3->Divide(6,6,0,0,0);
for (int i=0;i<36;i++) {
int idx = i+chip*36;
sprintf(name,"%s;%d",hname,m.pozicijaPixla[idx]+1);
h = ((TH1D * ) data->Get(name));
 
TVirtualPad *pad = pad3->cd(m.pozicijaPixlaNaCipu[idx]+1);
pad->SetBorderSize(0);
pad->SetBorderMode(0);
 
if (idx==0 && h->InheritsFrom("TH1D") ) {
sprintf(name,"%s_2d",h->GetName());
TAxis *axis = h->GetXaxis();
h2 = new TH2D(name,h->GetTitle(),144,-0.5,143.5,axis->GetNbins(),
axis->GetXmin(),
axis->GetXmax());
h2->GetXaxis()->SetTitle("HAPD 2d channels");
h2->GetYaxis()->SetTitle(axis->GetTitle());
h2->GetYaxis()->SetTitleOffset(1.4);
}
 
if (h) {
//printf("TH2D %s\n",name);
sprintf(name,"ASIC %d ch %d",chip,idx);
h->SetTitle(name);
h->GetXaxis()->SetRangeUser(xmin,xmax);
h->SetMinimum(-0.1);
h->SetStats(kFALSE);
h->SetFillColor(kBlue);
h->DrawCopy("AH");
if(save==2) {
sprintf(text_for_STR, "Charge_1D_%s_ASIC_%d_CH_%d", HAPDserialNumber.c_str(),chip,idx);
SaveToRootAddTH1DCopy(h, text_for_STR);
}
 
if (h2){
for(int k=xmin;k<h->GetNbinsX(); k++){
//if (idx==133) printf("x = %d \t y = %d \t value = %d\n", idx+1, k,(int)h->GetBinContent(k+1));
if ((int)h->GetBinContent(k+1)==0) h2->SetBinContent(idx+1,k+1,1);
else h2->SetBinContent(idx+1,k+1,h->GetBinContent(k+1));
}
}
} else printf("TH2D %s does not exist !!!!\n",name);
}
c->Modified();
c->Update();
if(chip%2==0) c4->cd(chip+2);
else c4->cd(chip);
c->DrawClonePad();
if (save==1){
switch (chip) {
case 0: sprintf(pdfname,"../modules/%04d/%04d_%s_1_Charge.pdf(",runNumber,runNumber,HAPDserialNumber.c_str());break;
default: sprintf(pdfname,"../modules/%04d/%04d_%s_1_Charge.pdf",runNumber,runNumber,HAPDserialNumber.c_str());break;
}
c->SaveAs(pdfname,"pdf");
} else if (save==4){
sprintf(pdfname,"../modules/%04d/%04d_%s.pdf",runNumber,runNumber,HAPDserialNumber.c_str());
c->SaveAs(pdfname,"pdf");
}
}
if (h2) {
sprintf(name,"%04d_%s_c%d",runNumber,HAPDserialNumber.c_str(),5);
c = new TCanvas(name,name,600,500);
c->SetLeftMargin(0.15);
c->SetRightMargin(0.15);
c->SetLogz(1);
 
sprintf(buf,"Charge scan over the center of channels");
 
h2->SetTitle(buf);
gStyle->SetTitleFontSize(0.05);
h2->SetTitleFont(vrstaPisave);
h2->SetTitleOffset(0);
 
h2->GetZaxis()->SetRangeUser(1,10000);
h2->GetZaxis()->SetTickLength(.02);
h2->GetZaxis()->SetLabelFont(vrstaPisave);
h2->GetZaxis()->SetLabelSize(0.03);
 
h2->GetYaxis()->SetRangeUser(xmin,xmax);
h2->GetYaxis()->SetTitleFont(vrstaPisave);
h2->GetYaxis()->SetLabelFont(vrstaPisave);
//h2->GetYaxis()->SetLabelSize(0.04);
h2->GetYaxis()->SetLabelColor(kBlack);
//h2->GetYaxis()->SetNdivisions(12);
h2->GetYaxis()->CenterTitle();
h2->GetYaxis()->SetTitle("ADC channel (a.u.)");
//h2->GetYaxis()->SetTitleSize(0.05);
h2->GetYaxis()->SetTitleOffset(1.5);
h2->GetYaxis()->SetTitleColor(kBlack);
 
//h2->GetXaxis()->SetTickLength(0.05);
h2->GetXaxis()->SetTitleFont(vrstaPisave);
h2->GetXaxis()->SetLabelFont(vrstaPisave);
//h2->GetXaxis()->SetLabelSize(0.04);
h2->GetXaxis()->SetLabelColor(kBlack);
//h2->GetXaxis()->SetLabelOffset(.05);
//h2->GetXaxis()->SetNdivisions(0);
//h2->GetXaxis()->CenterTitle();
h2->GetXaxis()->SetTitle("Channel");
//h2->GetXaxis()->SetTitleSize(0.05);
h2->GetXaxis()->SetTitleColor(kBlack); //zato ker ga ne moreš pozicionirat
h2->GetXaxis()->SetTitleOffset(1.2);
 
 
h2->DrawCopy("COLZ");
if(save==2) {
sprintf(text_for_STR, "Charge_2D_%s", HAPDserialNumber.c_str());
SaveToRootAddTH2DCopy(h2, text_for_STR);
}
c->Modified();
c->Update();
if (save==1){
sprintf(pdfname,"../modules/%04d/%04d_%s_1_Charge.pdf",runNumber,runNumber,HAPDserialNumber.c_str());
c4->SaveAs(pdfname,"pdf");
sprintf(pdfname,"../modules/%04d/%04d_%s_1_Charge.pdf)",runNumber,runNumber,HAPDserialNumber.c_str());
c->SaveAs(pdfname,"pdf");
} else if (save==2){
sprintf(pdfname,"../modules/%04d/%04d_%s.pdf",runNumber,runNumber,HAPDserialNumber.c_str());
c4->SaveAs(pdfname,"pdf");
c->SaveAs(pdfname,"pdf");
}
if(save==2) {
sprintf(text_for_STR,"../modules/%04d/%04d_%s_out.root",runNumber,runNumber,HAPDserialNumber.c_str());
SaveToRootWrite(text_for_STR, HAPDserialNumber.c_str());
}
}
}
delete data;
return 0;
}
 
float getGain(TH1D * h, int deadChannelSigma) {
TF1 * g0, * g1, * g2, * g3;
float gain;
float mean1, sigma1, mean2;
//Double_t * xpeaks;
Float_t * xpeaks;
 
TSpectrum * s = new TSpectrum(3);
int nfound = s->Search(h); //TALE FUNKICJA LAHKO POVZROČA TEŽAVE, KER NI NUJNO DA VRNE VRHOVE V PRAVEM ZAPOREDJU
//printf("Found %d candidate peaks to fit\n",nfound);
xpeaks = s->GetPositionX();
 
Float_t * first(&xpeaks[0]);
Float_t * last(first + nfound);
std::sort(first, last);
 
 
 
float xp;
for (int p=0;p<nfound;p++) {
xp = xpeaks[p];
//printf("Vrh številka %d je na poziciji %f\n",p,xp);
if(p==0) {
g0 = new TF1("0ph","gaus",xp-14,xp+14);
h->Fit(g0,"QR");
} else if(p==1) {
g1 = new TF1("1ph","gaus",xp-14,xp+14);
h->Fit(g1,"QR+");
} else if(p==2) {
g2 = new TF1("2ph","gaus",xp-14,xp+14);
h->Fit(g2,"QR+");
} else {
g3 = new TF1("3ph","gaus",xp-14,xp+14);
h->Fit(g3,"QR+");
}
}
 
if(nfound >= 1){
mean1 = g0->GetParameter(1);
sigma1 = g0->GetParameter(2);
if (sigma1<deadChannelSigma) gain = 0;
else gain = 30;
} else {
gain = 0;
}
if(nfound > 1){
mean2 = g1->GetParameter(1);
printf("%f \t %f\n", mean1, mean2);
if (mean1<mean2) gain = mean2 - mean1;
else gain = mean1 - mean2;
//printf("nfound: %d \t gain: %.1f \t mean1: %.1f \t sigma1: %.1f \t mean2: %.1f\n", nfound, gain, mean1, sigma1, mean2);
}
delete s;
return gain;
}
 
int gain(int runNumber, int save){
 
int HAPDnumber = 0; //Number of HAPD: 0, 1, 2 or 3!
 
char name[128];
char pdfname[128];
char buf[0xFF];
float ojacanje;
 
char hname[0xF];
 
sprintf(buf,"../modules/%04d/%04d_1_Treshold_Waveform.root",runNumber,runNumber);
TFile * data = new TFile(buf);
 
const char * serialNumber = getSN(runNumber);
printf("base.c return: %s\n", serialNumber);
/******* PREVERI ČE JE NALOŽEN FILE *******/
if (!strcmp(serialNumber, "NoFILE")){
printf("Ni naloženege datoteke\n");
return -1;
}
std::string serialNumberTemp = serialNumber;
std::cout << serialNumberTemp << std::endl;
std::string HAPDserialNumber,FEBserialNumber;
 
GRID m = mapping();
int vrstaPisave = 82;
 
int blackWhite = 40;
int max = 140;
 
TCanvas * c1, * c2, * c3;
TPad * pad1, * pad2;
TPaveText * title;
TH1D * h;
TH1F * Gain1D;
TH2F * Gain2D;
TH2I * Gain2D_black, * Gain2D_white;
 
gStyle->SetOptStat(0);
gStyle->SetPalette(52);
gStyle->SetNumberContours(100);
 
 
for(HAPDnumber=0;HAPDnumber<4;HAPDnumber++){
SaveToRootInit();
 
//std::cout << serialNumberTemp << std::endl;
FEBserialNumber = serialNumberTemp.substr(0,serialNumberTemp.find(","));
serialNumberTemp.erase(0,FEBserialNumber.length()+1);
if(!FEBserialNumber.compare("noserial")) continue;
HAPDserialNumber = FEBserialNumber.substr(0,FEBserialNumber.find("/"));
FEBserialNumber.erase(0,FEBserialNumber.find("/")+1);
sprintf(hname,"hcharge%d_0",HAPDnumber);
printf("%s \t %s \t %s \n",FEBserialNumber.c_str(),HAPDserialNumber.c_str(),hname);
/******* 1D *******/
sprintf(buf,"%04d_%s_Gain1D",runNumber,HAPDserialNumber.c_str());
c1 = new TCanvas(buf,buf,0,0,600,300);
sprintf(name,"1D Gain of HAPD %s (%04d);Channel number;Gain",HAPDserialNumber.c_str(),runNumber);
Gain1D = new TH1F("Gain1D",name,144,0,144);
/******* 2D *******/
sprintf(buf,"%04d_%s_Gain2D",runNumber,HAPDserialNumber.c_str());
c2 = new TCanvas(buf,buf,0,0,600,600);
c2->SetRightMargin(0.15);
sprintf(name,"Backside view: Gain of HAPD %s (%04d)",HAPDserialNumber.c_str(),runNumber);
Gain2D = new TH2F("Gain2D",name,12,-0.5,11.5,12,-0.5,11.5);
Gain2D_black = new TH2I("Gain2D_black","Gain2D_black",12,-0.5,11.5,12,-0.5,11.5);
Gain2D_white = new TH2I("Gain2D_white","Gain2D_white",12,-0.5,11.5,12,-0.5,11.5);
Gain2D->SetMinimum(-0.1);
Gain2D->SetMaximum(max);
Gain2D_black->SetMinimum(blackWhite);
/******* NAREDI HISTOGRAME *******/
for (int i=0;i<12;i++) {
for (int j=0;j<12;j++) {
sprintf(name,"%s;%d",hname,m.pozicijaPixla[m.koordinatniSistem[i][j]]+1);
//printf("%s\n",name);
h = (TH1D *) data->Get(name);
h->GetXaxis()->SetRangeUser(-50,300);
ojacanje = getGain(h);
//printf("channel %d \t gain %f\n", m.koordinatniSistem[i][j], ojacanje);
Gain1D->Fill(m.koordinatniSistem[i][j],ojacanje);
Gain2D->Fill(i,j,ojacanje);
if(ojacanje<=blackWhite) Gain2D_white->Fill(i,j,ojacanje);
Gain2D_black->Fill(i,j,ojacanje);
}
}
c1->cd();
c1->SetGrid(1);
Gain1D->SetTitle("");
//Gain1D->SetLineWidth(2);
Gain1D->SetFillColor(kRed-10);
Gain1D->GetYaxis()->SetRangeUser(0,140);
Gain1D->GetYaxis()->SetTickLength(0.01);
Gain1D->GetYaxis()->SetTitleFont(vrstaPisave);
Gain1D->GetYaxis()->SetLabelFont(vrstaPisave);
Gain1D->GetYaxis()->SetLabelSize(0.04);
Gain1D->GetYaxis()->SetLabelColor(kBlack);
//Gain1D->GetYaxis()->SetNdivisions(0);
Gain1D->GetYaxis()->CenterTitle();
Gain1D->GetYaxis()->SetTitle("Gain");
Gain1D->GetYaxis()->SetTitleSize(0.05);
//Gain1D->GetYaxis()->SetTitleOffset(.5);
Gain1D->GetYaxis()->SetTitleColor(kBlack);
//Gain1D->GetXaxis()->SetRangeUser(0,80);
//Gain1D->GetXaxis()->SetTickLength(0.05);
Gain1D->GetXaxis()->SetTitleFont(vrstaPisave);
Gain1D->GetXaxis()->SetLabelFont(vrstaPisave);
Gain1D->GetXaxis()->SetLabelSize(0.04);
Gain1D->GetXaxis()->SetLabelColor(kBlack);
//Gain1D->GetXaxis()->SetLabelOffset(.05);
//Gain1D->GetXaxis()->SetNdivisions(0);
//Gain1D->GetXaxis()->CenterTitle();
Gain1D->GetXaxis()->SetTitle("Channel");
Gain1D->GetXaxis()->SetTitleSize(0.05);
Gain1D->GetXaxis()->SetTitleColor(kBlack); //zato ker ga ne moreš pozicionirat
Gain1D->GetXaxis()->SetTitleOffset(1);
Gain1D->DrawCopy();
c2->cd();
Gain2D->SetTitle("");
 
Gain2D->GetZaxis()->SetTickLength(.02);
Gain2D->GetZaxis()->SetTitleFont(vrstaPisave);
Gain2D->GetZaxis()->SetLabelFont(vrstaPisave);
Gain2D->GetZaxis()->SetLabelSize(0.03);
Gain2D->GetZaxis()->SetTitle("G_{a}");
Gain2D->GetZaxis()->CenterTitle();
//Gain2D->GetYaxis()->SetTickLength(0.03);
Gain2D->GetYaxis()->SetTitleFont(vrstaPisave);
Gain2D->GetYaxis()->SetLabelFont(vrstaPisave);
Gain2D->GetYaxis()->SetLabelSize(0.03);
Gain2D->GetYaxis()->SetLabelColor(kBlack);
Gain2D->GetYaxis()->SetLabelOffset(.01);
//Gain2D->GetYaxis()->SetNdivisions(12);
Gain2D->GetYaxis()->CenterTitle();
Gain2D->GetYaxis()->SetTitle("Rows");
Gain2D->GetYaxis()->SetTitleSize(0.035);
Gain2D->GetYaxis()->SetTitleOffset(1.2);
Gain2D->GetYaxis()->SetTitleColor(kBlack);
//Gain2D->GetXaxis()->SetTickLength(0.03);
Gain2D->GetXaxis()->SetTitleFont(vrstaPisave);
Gain2D->GetXaxis()->SetLabelFont(vrstaPisave);
Gain2D->GetXaxis()->SetLabelSize(0.03);
Gain2D->GetXaxis()->SetLabelColor(kBlack);
//Gain2D->GetXaxis()->SetLabelOffset(.05);
//Gain2D->GetXaxis()->SetNdivisions(0);
//Gain2D->GetXaxis()->CenterTitle();
Gain2D->GetXaxis()->SetTitle("Columns");
Gain2D->GetXaxis()->SetTitleSize(0.03);
Gain2D->GetXaxis()->SetTitleColor(kBlack); //zato ker ga ne moreš pozicionirat
Gain2D->GetXaxis()->SetTitleOffset(1.2);
Gain2D->DrawCopy("COLZ");
Gain2D_black->DrawCopy("TEXT,SAME");
Gain2D_white->SetMarkerColor(kWhite);
Gain2D_white->DrawCopy("TEXT,SAME");
c1->Modified();
c1->Update();
c2->Modified();
c2->Update();
 
sprintf(buf,"%04d_%s_Gain",runNumber,HAPDserialNumber.c_str());
c3 = new TCanvas(buf,buf,0,0,1000,1000);
c3->cd();
/******* 1D *******/
sprintf(buf,"%04d_%s_gain1d_pad1",runNumber,HAPDserialNumber.c_str());
pad1 = new TPad(buf,"SN",.15,0.7,.85,1,0,0);
pad1->SetFillStyle(4000);
pad1->Draw();
//pad1->SetRightMargin(0.15);
 
/******* 2D *******/
sprintf(buf,"%04d_%s_gain2d_pad2",runNumber,HAPDserialNumber.c_str());
pad2 = new TPad(buf,"Date",.15,0,.85,0.7,0,0);
pad2->SetFillStyle(4000);
pad2->Draw();
pad2->SetRightMargin(0.15);
 
pad1->cd();
pad1->SetGrid(1);
Gain1D->DrawCopy();
 
sprintf(text_for_STR, "Gain_1D_%s", HAPDserialNumber.c_str());
SaveToRootAddTH1F(Gain1D, text_for_STR);
 
title = new TPaveText(0.2,.93,0.8,.94,"ndc");
title->SetBorderSize(0);
title->SetFillColor(4000);
title->SetTextSize(.06);
title->SetTextAlign(22);
title->SetTextFont(vrstaPisave);
title->AddText("Gain");
title->Draw();
 
 
pad2->cd();
Gain2D->DrawCopy("COLZ");
Gain2D_black->DrawCopy("TEXT,SAME");
Gain2D_white->SetMarkerColor(kWhite);
Gain2D_white->DrawCopy("TEXT,SAME");
 
sprintf(text_for_STR, "Gain_2D_%s", HAPDserialNumber.c_str());
SaveToRootAddTH2F(Gain2D, text_for_STR);
title = new TPaveText(0.2,.91,0.8,.93,"ndc");
title->SetBorderSize(0);
title->SetFillColor(4000);
title->SetTextSize(.035);
title->SetTextAlign(22);
title->SetTextFont(vrstaPisave);
title->AddText("Backside view gain");
title->Draw();
 
delete c1;
delete c2;
if (save==1) {
sprintf(pdfname,"../modules/%04d/%04d_%s_Gain.pdf",runNumber,runNumber,HAPDserialNumber.c_str());
c3->SaveAs(pdfname,"pdf");
} else if (save==2){
sprintf(pdfname,"../modules/%04d/%04d_%s.pdf",runNumber,runNumber,HAPDserialNumber.c_str());
c3->SaveAs(pdfname,"pdf");
} else if (save==3){
sprintf(pdfname,"../modules/%04d/%04d_%s.pdf(",runNumber,runNumber,HAPDserialNumber.c_str());
c3->SaveAs(pdfname,"pdf");
} else if (save==5){
sprintf(pdfname,"../modules/%04d/%04d_%s.root",runNumber,runNumber,HAPDserialNumber.c_str());
c3->SaveAs(pdfname,"root");
}
sprintf(text_for_STR,"../modules/%04d/%04d_%s_out.root",runNumber,runNumber,HAPDserialNumber.c_str());
SaveToRootWrite(text_for_STR, HAPDserialNumber.c_str());
delete Gain1D;
delete Gain2D;
delete Gain2D_white;
delete Gain2D_black;
}
delete data;
return 0;
}
/cvi/apps/sa02_daq/analysis/gain.h
0,0 → 1,23
#ifndef GAIN_H_
#define GAIN_H_
 
struct FIT{
int success;
float pixPos;
float x;
float y;
float chi2;
float ndf;
float p0;
float p0e;
float p1;
float p1e;
float p2;
float p2e;
};
 
int charge(int runNumber, int save = 0);
float getGain(TH1D * h, int deadChannelSigm = 2);
int gain(int runNumber, int save = 0);
 
#endif
/cvi/apps/sa02_daq/analysis/getgain.sh
0,0 → 1,8
#!/bin/bash
 
for x in ../modules/[0-9][0-9][0-9][0-9]; do
run=`basename $x`
echo root -b -q process.c\($run\)
root -b -q process.c\($run\)
done
 
/cvi/apps/sa02_daq/analysis/getsn.cxx
0,0 → 1,55
#include "TString.h"
#include "TObjString.h"
#include "TObjArray.h"
#include "TDirectory.h"
#include "TFile.h"
#include "TSystem.h"
 
int ifebsn[8]={21,23,22,25, 27,28,29,30};
 
int getsn(const char *fname="test.xml"){
const char *f= gDirectory->GetFile()->GetName();
const char *t= gDirectory->Get("hxy0_sum_0")->GetTitle();
const char *d= gDirectory->Get("h2d_0")->GetTitle();
char h0[0xFF];
sscanf(t,"HAPD=%s",h0);
TDatime c = gDirectory->GetFile()->GetCreationDate();
const char *date= c.AsString();
 
 
FILE *fp=fopen(fname,"a");
 
TString sdna(d);
TObjArray *tdna = sdna.Tokenize(" ");
TString x(h0);
TObjArray *tx = x.Tokenize(",");
char run[0xf];
strncpy(run,gSystem->BaseName(f),4);
run[4]=0;
fprintf(fp,"<run id='%s' date='%s'>\n",run, date);
 
for (Int_t i = 0; i < tx->GetEntries(); i++) {
const char *sn = ((TObjString *)(tx->At(i)))->GetString();
const char *dna =(tdna->GetEntries()>=4)? ((TObjString *)(tdna->At(i)))->GetString() : " ";
char *mdna = (char *)&dna[5];
char sfeb[20];
if (strstr(sn,"/")!=NULL){
TString ssn(sn);
TObjArray *tsn = ssn.Tokenize("/");
const char *hapdsn = ((TObjString *)(tsn->At(0)))->GetString();
const char *febsnc = "000";
const char *febsn = ((TObjString *)(tsn->At(1)))->GetString();
sprintf(sfeb,"%s",febsn);
fprintf(fp, "<pos id='%d'><hapd>%s</hapd><feb>%s</feb><dna>%s</dna></pos>\n", i, hapdsn, sfeb,mdna );
} else {
sprintf(sfeb,"%03d", ifebsn[(4*(atoi(run)-1)+i)%8]);
fprintf(fp, "<pos id='%d'><hapd>%s</hapd><feb>%s</feb><dna>%s</dna></pos>\n", i, sn, sfeb,mdna );
}
 
}
//fprintf(fp,"</run>\n");
 
fprintf(stdout,"%s %s\n",gSystem->BaseName(f),t);
fclose(fp);
return 0;
}
/cvi/apps/sa02_daq/analysis/getsn.sh
0,0 → 1,26
FNAME=arichmoduletest.xml
rm $FNAME
echo "<moduletest>" >> $FNAME
for x in ../modules/[0-9][0-9][0-9][0-9]/*_1_Treshold_Waveform.root ; do
if [ -e $x ]
then
root -b -q $x getsn.cxx\(\"${FNAME}\"\)
RDIR=`dirname $x`
echo "<hapdgain>" >> $FNAME
echo $RDIR
for y in $RDIR/[0-9][0-9][0-9][0-9]_??????.root ; do
if [ -e "$y" ]
then
 
echo root -b -q $y printgain.c\(\"${FNAME}\"\)
root -b -q $y printgain.c\(\"${FNAME}\"\)
fi
 
done
echo "</hapdgain>" >> $FNAME
echo "</run>" >> $FNAME
fi
done
echo "</moduletest>" >> $FNAME
#cat $FNAME
 
/cvi/apps/sa02_daq/analysis/info.c
0,0 → 1,351
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
 
#include <TROOT.h>
#include <TLatex.h>
#include <TH1F.h>
#include <TH2D.h>
#include <TH3D.h>
#include <TGraph.h>
#include <TCanvas.h>
#include <TLegend.h>
#include <TStyle.h>
#include <TSystem.h>
#include <TFile.h>
#include <TTree.h>
#include <TDirectory.h>
#include <TPaveText.h>
 
#include "base.h"
#include "info.h"
#include "savetoroot.h"
 
int info(int runNumber, int save) {
 
int HAPDnumber; //Number of HAPD: 0, 1, 2 or 3!
 
char text[256];
char pdfname[256];
char buf[256];
char path[128];
int vrstaPisave = 82;
 
const char * serialNumber;
std::string serialNumberTemp;
std::string HAPDserialNumber,FEBserialNumber;
 
unsigned int id, len, cas;
int vmon[24], vset[24];
int imon[24];
//int status[6];
//int min_imon[6], max_imon[6], min_vmon[6], max_vmon[6], min_status[6], max_status[6];
int min_chipBias = 0, max_chipBias = 0;
int sizeOfTree;
time_t itime;
TDatime dh(1995,01,01,00,00,00); // to je za SetTimeOffset
 
char * viri[6] = {"Guard", "Chip A", "Chip B", "Chip C", "Chip D", "HV"};
 
TFile * data[3];
TCanvas * c;
TPad * pad1, * pad2, * pad3, * pad4, * pad5;
TPaveText * sn, * timeStamp, * imeMeritve, * zacetekMeritve;
TGraph * gr[10];
TLegend * leg[2];
TTree * tree;
 
/********** GLOBALNE **********/
gStyle->SetOptStat(0);
//gStyle->SetOptTitle(1);
gStyle->SetTextFont(vrstaPisave);
gStyle->SetTitleFont(vrstaPisave);
gStyle->SetTitleFontSize(0.08);
 
gStyle->SetPalette(55);
 
//gROOT->SetBatch(kTRUE); //Does not show canvases
 
sprintf(path,"../modules/%04d/%04d_1_Treshold_Waveform.root",runNumber,runNumber);
data[0] = new TFile(path);
if (!file_exists(path)){
printf("File '%s' does not exist.\n",path);
return -1;
}
serialNumber = getSN(runNumber);
printf("base.c return: %s\n", serialNumber);
serialNumberTemp = serialNumber;
sprintf(path,"../modules/%04d/%04d_2_2DX.root",runNumber,runNumber);
data[1] = new TFile(path);
if (!file_exists(path)){
printf("File '%s' does not exist.\n",path);
return -1;
}
sprintf(path,"../modules/%04d/%04d_3_2DY.root",runNumber,runNumber);
data[2] = new TFile(path);
if (!file_exists(path)){
printf("File '%s' does not exist.\n",path);
return -1;
}
 
for(HAPDnumber=0;HAPDnumber<4;HAPDnumber++){
SaveToRootInit();
 
//std::cout << serialNumberTemp << std::endl;
FEBserialNumber = serialNumberTemp.substr(0,serialNumberTemp.find(","));
serialNumberTemp.erase(0,FEBserialNumber.length()+1);
if(!FEBserialNumber.compare("noserial")) continue;
HAPDserialNumber = FEBserialNumber.substr(0,FEBserialNumber.find("/"));
FEBserialNumber.erase(0,FEBserialNumber.find("/")+1);
printf("%s \t %s \n",FEBserialNumber.c_str(),HAPDserialNumber.c_str());
 
sprintf(buf,"%04d_%s_Monitor",runNumber,HAPDserialNumber.c_str());
c = new TCanvas(buf,buf,0,0,1500,1200);
/******* PRVI PAD *******/
sprintf(buf,"%04d_%s_Monitor_pad1",runNumber,HAPDserialNumber.c_str());
pad1 = new TPad(buf,"SN",0,0.95,1,1,0,0);
pad1->SetFillStyle(4000);
pad1->Draw();
sn = new TPaveText(0.2,0,0.8,1,"ndc");
sn->SetBorderSize(0);
sn->SetFillColor(4000);
sn->SetTextSize(.8);
sn->SetTextAlign(22);
sn->SetTextFont(vrstaPisave);
 
/******* DRUGI PAD *******/
sprintf(buf,"%04d_%s_Monitor_pad2",runNumber,HAPDserialNumber.c_str());
pad2 = new TPad(buf,"Date",0.05,0.9,0.95,0.95,0,0);
pad2->SetFillStyle(4000);
pad2->Draw();
timeStamp = new TPaveText(0.2,0,0.8,1,"ndc");
timeStamp->SetBorderSize(0);
timeStamp->SetFillColor(4000);
timeStamp->SetTextSize(.4);
timeStamp->SetTextAlign(22);
timeStamp->SetTextFont(vrstaPisave);
 
/******* TRETJI PAD *******/
sprintf(buf,"%04d_%s_Monitor_pad3",runNumber,HAPDserialNumber.c_str());
pad3 = new TPad(buf,"Napetosti",0,0,1,0.9,0,0);
pad3->SetFillStyle(4000);
pad3->Draw();
pad3->cd();
pad3->Divide(0,3);
 
for (int k=0;k<3;k++){
pad3->cd(k+1);
 
sprintf(buf,"%04d_%s_Monitor_pad4",runNumber,HAPDserialNumber.c_str());
pad4 = new TPad(buf,"Naslov",0.05,0.9,0.95,1,0,0);
pad4->SetFillStyle(4000);
pad4->Draw();
imeMeritve = new TPaveText(0,0,1,1,"ndc");
imeMeritve->SetBorderSize(0);
imeMeritve->SetFillColor(kSpring+1);
imeMeritve->SetTextSize(.6);
imeMeritve->SetTextAlign(22);
imeMeritve->SetTextFont(vrstaPisave);
 
zacetekMeritve = new TPaveText(0.8,0,1,1,"ndc");
zacetekMeritve->SetBorderSize(0);
zacetekMeritve->SetFillColor(kSpring+1);
zacetekMeritve->SetTextSize(.4);
zacetekMeritve->SetTextAlign(22);
zacetekMeritve->SetTextFont(vrstaPisave);
 
switch (k){
case 0: sprintf(text, "Treshold and Waveform");break;
case 1: sprintf(text, "2D in X");break;
case 2: sprintf(text, "2D in Y");break;
}
pad4->cd();
imeMeritve->AddText(text);
imeMeritve->Draw();
 
pad3->cd(k+1);
 
sprintf(buf,"%04d_%s_Monitor_pad5",runNumber,HAPDserialNumber.c_str());
pad5 = new TPad(buf,"Grafi",0,0,1,.9,0,0);
pad5->SetFillStyle(4000);
pad5->Draw();
pad5->cd();
pad5->Divide(4,0);
 
tree = (TTree*) data[k]->Get("Monitor");
tree->SetBranchAddress("id",&id);
tree->SetBranchAddress("len",&len);
tree->SetBranchAddress("time",&cas);
tree->SetBranchAddress("imon",&imon);
tree->SetBranchAddress("vmon",&vmon);
tree->SetBranchAddress("vset",&vset);
//tree->SetBranchAddress("status",&status);
 
sizeOfTree = tree->GetEntries();
 
gr[0] = new TGraph(sizeOfTree);
gr[1] = new TGraph(sizeOfTree);
gr[2] = new TGraph(sizeOfTree);
gr[3] = new TGraph(sizeOfTree);
gr[4] = new TGraph(sizeOfTree);
gr[5] = new TGraph(sizeOfTree);
gr[6] = new TGraph(sizeOfTree);
gr[7] = new TGraph(sizeOfTree);
gr[8] = new TGraph(sizeOfTree);
gr[9] = new TGraph(sizeOfTree);
 
for (int i=0;i<sizeOfTree;i++){
tree->GetEntry(i);
 
cas = cas-2208988800; //(2208988800)CVI zapiše čas v sekundah od 00:00:00 1.1.1900 naprej, UNIX čas je od 00:00:00 1.1.1970
// cas-u morš še nekaj odštet, kr kasneje ko delaš TimeOffset, le ta vodi čas od 00:00:00 1.1.1995 naprej.
gr[0]->SetPoint(i,cas-788918400,vmon[HAPDnumber*6+0]);
gr[1]->SetPoint(i,cas-788918400,vmon[HAPDnumber*6+1]-vset[HAPDnumber*6+1]);
gr[2]->SetPoint(i,cas-788918400,vmon[HAPDnumber*6+2]-vset[HAPDnumber*6+2]);
gr[3]->SetPoint(i,cas-788918400,vmon[HAPDnumber*6+3]-vset[HAPDnumber*6+3]);
gr[4]->SetPoint(i,cas-788918400,vmon[HAPDnumber*6+4]-vset[HAPDnumber*6+4]);
gr[5]->SetPoint(i,cas-788918400,vmon[HAPDnumber*6+5]);
gr[6]->SetPoint(i,cas-788918400,imon[HAPDnumber*6+1]/1000.);
gr[7]->SetPoint(i,cas-788918400,imon[HAPDnumber*6+2]/1000.);
gr[8]->SetPoint(i,cas-788918400,imon[HAPDnumber*6+3]/1000.);
gr[9]->SetPoint(i,cas-788918400,imon[HAPDnumber*6+4]/1000.);
if (!i){
itime = cas;
zacetekMeritve->AddText(ctime(&itime));
} else if (k==2 && i==sizeOfTree-1){
itime = cas;
sprintf(buf,"End of measuring: %s",ctime(&itime));
timeStamp->AddText(buf);
}
for (int j=1;j<5;j++){
if (!i && j==1) {
min_chipBias = max_chipBias = vmon[HAPDnumber*6+j]-vset[HAPDnumber*6+j];
} else {
if (min_chipBias > vmon[HAPDnumber*6+j]-vset[HAPDnumber*6+j]) min_chipBias = vmon[HAPDnumber*6+j]-vset[HAPDnumber*6+j];
else if (max_chipBias < vmon[HAPDnumber*6+j]-vset[HAPDnumber*6+j]) max_chipBias = vmon[HAPDnumber*6+j]-vset[HAPDnumber*6+j];
}
}
}
 
leg[0] = new TLegend(0.55,0.1,.9,0.35);
leg[1] = new TLegend(0.70,0.70,.9,0.9);
leg[0]->SetFillColor(0);
leg[1]->SetFillColor(0);
for (int i=0;i<10;i++){
gr[i]->GetYaxis()->CenterTitle();
gr[i]->GetYaxis()->SetTitleFont(vrstaPisave);
gr[i]->GetYaxis()->SetLabelFont(vrstaPisave);
gr[i]->GetYaxis()->SetTitleOffset(1.6);
 
 
gr[i]->GetXaxis()->SetTitleFont(vrstaPisave);
gr[i]->GetXaxis()->SetLabelFont(vrstaPisave);
//gr[i]->GetXaxis()->CenterTitle();
gr[i]->GetXaxis()->SetTimeDisplay(1);
gr[i]->GetXaxis()->SetTimeOffset(dh.Convert());
gr[i]->GetXaxis()->SetTimeFormat("#splitline{%H:%M}{%d-%m}");
gr[i]->GetXaxis()->SetLabelOffset(0.02);
gr[i]->GetXaxis()->SetTitleOffset(1.5);
 
 
if(!i){
pad5->cd(1);
sprintf(text, "Guard bias (RMS = %.0f mV);Time;Bias [mV]", gr[i]->GetRMS(2));
gr[i]->SetTitle(text);
gr[i]->GetYaxis()->SetRangeUser(170000,180000);
 
gr[i]->Draw("AL");
sprintf(text, "Guard_%s_T_%d", HAPDserialNumber.c_str(), k);
SaveToRootAddGraph(gr[i], text);
} else if (i<5 && i!=0){
pad5->cd(2);
sprintf(text, "%s (RMS = %.0f mV)", viri[i], gr[i]->GetRMS(2));
leg[0]->AddEntry(gr[i],text,"L");
 
 
//gr[i]->GetYaxis()->SetRangeUser(min_chipBias-50,max_chipBias+50);
gr[i]->GetYaxis()->SetRangeUser(-1000,1000);
 
gr[i]->SetTitle("Chip (vmon - vset) difference;Time;Bias difference [mV]");
if (i==1) gr[i]->Draw("AL");
 
gr[i]->SetLineColor(i);
gr[i]->SetLineWidth(1);
 
gr[i]->Draw("LSAME");
sprintf(text, "BiasDifference_%s_CHIP_%d_T_%d", HAPDserialNumber.c_str(), i-1, k);
SaveToRootAddGraph(gr[i], text);
} else if (i>5){
pad5->cd(3);
sprintf(text, "%s", viri[i-5]);
leg[1]->AddEntry(gr[i],text,"L");
 
gr[i]->GetYaxis()->SetRangeUser(-1,11);
 
gr[i]->SetTitle("Chip leakage current;Time;Leakage current [mA]");
if (i==6) gr[i]->Draw("AL");
 
gr[i]->SetLineColor(i);
gr[i]->SetLineWidth(1);
 
gr[i]->Draw("LSAME");
sprintf(text, "LeakageCurrent_%s_CHIP_%d_T_%d", HAPDserialNumber.c_str(), i-6, k);
SaveToRootAddGraph(gr[i], text);
} else if (i==5){
pad5->cd(4);
sprintf(text, "HV (RMS = %.0f mV);Time;Bias [mV]", gr[i]->GetRMS(2));
gr[i]->GetYaxis()->SetRangeUser(6900000,7100000);
 
gr[i]->SetTitle(text);
 
gr[i]->Draw("AL");
sprintf(text, "HV_%s_T_%d", HAPDserialNumber.c_str(), k);
SaveToRootAddGraph(gr[i], text);
}
}
 
pad5->cd(2);
leg[0]->Draw();
pad5->cd(3);
leg[1]->Draw();
pad4->cd();
zacetekMeritve->Draw();
}
 
pad1->cd();
sprintf(buf,"RUN#: %04d (pos %d) FEB#: %s HAPD#: %s",runNumber, HAPDnumber, FEBserialNumber.c_str(),HAPDserialNumber.c_str());
sn->AddText(buf);
sn->Draw();
pad2->cd();
timeStamp->Draw();
 
c->Modified();
c->Update();
 
if (save) {
switch (save) {
case 1: sprintf(pdfname,"../modules/%04d/%04d_%s_0_Info.pdf",runNumber,runNumber,HAPDserialNumber.c_str());break;
case 2: sprintf(pdfname,"../modules/%04d/%04d_%s.pdf(",runNumber,runNumber,HAPDserialNumber.c_str());break;
}
c->SaveAs(pdfname,"pdf");
}
sprintf(pdfname,"../modules/%04d/%04d_%s_out.root",runNumber,runNumber,HAPDserialNumber.c_str());
SaveToRootWrite(pdfname, HAPDserialNumber.c_str());
}
for(int k=0;k<3;k++) delete data[k];
 
return 0;
}
/cvi/apps/sa02_daq/analysis/info.h
0,0 → 1,6
#ifndef INFO_H_
#define INFO_H_
 
int info(int runNumber, int save = 0);
 
#endif
/cvi/apps/sa02_daq/analysis/map.c
0,0 → 1,186
#include <stdio.h>
#include <stdlib.h>
 
#include <TROOT.h>
#include <TH1D.h>
#include <TH2D.h>
#include <TH3D.h>
#include <TCanvas.h>
#include <TStyle.h>
#include <TSystem.h>
#include <TFile.h>
#include <TDirectory.h>
#include <TPaveText.h>
 
#include "base.h"
#include "map.h"
 
int mapped(){
char pdfname[256];
 
GRID m = mapping();
 
TCanvas * c = new TCanvas("Koordinatni sistemi","Koordinatni sistemi",500,500);
c->Divide(2,2);
 
gStyle->SetOptStat(0);
TH2D *mapBack = new TH2D("mapBack", "Mapping - from back side", 12, -0.5, 11.5, 12, -0.5, 11.5);
TH2D *posBack = new TH2D("posBack", "Scan Position - from back side", 12, -0.5, 11.5, 12, -0.5, 11.5);
TH2D *posChipBack = new TH2D("posChipBack", "Position on chip - from back side", 12, -0.5, 11.5, 12, -0.5, 11.5);
TH2D *kvadratki = new TH2D("kvadratki", "", 12, -0.5, 11.5, 12, -0.5, 11.5);
 
for (int x=0;x<12;x++){
for (int y=0;y<12;y++){
mapBack->Fill(x,y,m.koordinatniSistem[x][y]);
posBack->Fill(x,y,m.pozicijaPixla[m.koordinatniSistem[x][y]]);
posChipBack->Fill(x,y,m.pozicijaPixlaNaCipu[m.koordinatniSistem[x][y]]);
kvadratki->Fill(x,y,144);
}
}
 
c->cd(1);
 
mapBack->GetYaxis()->SetTickLength(0.01);
mapBack->GetYaxis()->SetLabelOffset(0.03);
 
mapBack->GetXaxis()->SetTickLength(0.01);
mapBack->GetXaxis()->SetLabelOffset(0.03);
 
 
mapBack->DrawCopy("TEXT");
kvadratki->DrawCopy("BOX,SAME");
 
 
c->cd(3);
posBack->GetYaxis()->SetTickLength(0.01);
posBack->GetYaxis()->SetLabelOffset(0.03);
 
posBack->GetXaxis()->SetTickLength(0.01);
posBack->GetXaxis()->SetLabelOffset(0.03);
 
posBack->DrawCopy("TEXT");
kvadratki->DrawCopy("BOX,SAME");
 
c->cd(4);
posChipBack->GetYaxis()->SetTickLength(0.01);
posChipBack->GetYaxis()->SetLabelOffset(0.03);
 
posChipBack->GetXaxis()->SetTickLength(0.01);
posChipBack->GetXaxis()->SetLabelOffset(0.03);
 
posChipBack->DrawCopy("TEXT");
kvadratki->DrawCopy("BOX,SAME");
 
 
sprintf(pdfname,"map.pdf");
c->SaveAs(pdfname,"pdf");
 
return 0;
}
/*
int newFile(){
GRID m = mapping();
FILE *f = fopen("map.txt", "w");
if (f == NULL)
{
printf("Error opening file!\n");
exit(1);
}
for (int x=0;x<12;x++){
for (int y=0;y<12;y++){
fprintf(f, "%d\t%d\t%d\t%d\t%d\n", m.koordinatniSistemCHIP[y][x], m.koordinatniSistemPIXEL[y][x], x, 11-y,(11-x)+y*12);
}
}
 
fclose(f);
return 0;
}
 
GRID mapping2(){
int f[6];
int ndim = 400;
char line[400];
GRID m;
FILE * fp = fopen("mapNEW.map","r");
 
while (fgets(line,ndim,fp) != NULL) {
sscanf(line,"%d%d%d%d%d%d",&f[0],&f[1],&f[2],&f[3],&f[4],&f[5]);
//m.koordinatniSistem[f[2]][f[3]] = f[0]*36+f[1];
m.koordinatniSistemCHIP[11-f[2]][11-f[3]] = f[0];
m.koordinatniSistemPIXEL[11-f[2]][11-f[3]] = f[1];
m.koordinatniSistem[11-f[2]][11-f[3]] = f[0]*36+f[1];
m.pozicijaPixla[f[0]*36+f[1]] = f[4];
m.pozicijaPixlaNaCipu[f[0]*36+f[1]] = f[5];
}
fclose(fp);
 
TCanvas * c = new TCanvas("Koordinatni sistemi","Koordinatni sistemi",1000,1000);
c->Divide(2,2);
 
//gStyle->SetOptStat(0);
TH2D *mapBack = new TH2D("mapBack", "Mapping - from back side", 12, -0.5, 11.5, 12, -0.5, 11.5);
TH2D *zaporedje = new TH2D("zaporedje", "zaporedje meritve - from back side", 12, -0.5, 11.5, 12, -0.5, 11.5);
TH2D *chips = new TH2D("chips", "chips - from back side", 12, -0.5, 11.5, 12, -0.5, 11.5);
TH2D *pixelonchp = new TH2D("pixelonchp", "pixelonchp - from back side", 12, -0.5, 11.5, 12, -0.5, 11.5);
TH2D *kvadratki = new TH2D("kvadratki", "", 12, -0.5, 11.5, 12, -0.5, 11.5);
 
 
for (int x=0;x<12;x++){
for (int y=0;y<12;y++){
mapBack->Fill(x,y,m.koordinatniSistem[x][y]);
zaporedje->Fill(x,y,m.pozicijaPixla[m.koordinatniSistem[x][y]]);
chips->Fill(x,y,m.pozicijaPixlaNaCipu[m.koordinatniSistem[x][y]]);
pixelonchp->Fill(x,y,m.koordinatniSistemPIXEL[x][y]);
//mapBackNew->Fill(x,y,m.koordinatniSistem[y][11-x]);
//posBack->Fill(x,y,m.pozicijaPixla[m.koordinatniSistem[x][y]]);
//posChipBack->Fill(x,y,m.pozicijaPixlaNaCipu[m.koordinatniSistem[x][y]]);
kvadratki->Fill(x,y,144);
}
}
c->cd(1);
mapBack->GetYaxis()->SetTickLength(0.01);
mapBack->GetYaxis()->SetLabelOffset(0.03);
 
mapBack->GetXaxis()->SetTickLength(0.01);
mapBack->GetXaxis()->SetLabelOffset(0.03);
 
 
mapBack->DrawCopy("TEXT");
kvadratki->DrawCopy("BOX,SAME");
c->cd(2);
zaporedje->GetYaxis()->SetTickLength(0.01);
zaporedje->GetYaxis()->SetLabelOffset(0.03);
 
zaporedje->GetXaxis()->SetTickLength(0.01);
zaporedje->GetXaxis()->SetLabelOffset(0.03);
 
 
zaporedje->DrawCopy("TEXT");
kvadratki->DrawCopy("BOX,SAME");
c->cd(3);
chips->GetYaxis()->SetTickLength(0.01);
chips->GetYaxis()->SetLabelOffset(0.03);
 
chips->GetXaxis()->SetTickLength(0.01);
chips->GetXaxis()->SetLabelOffset(0.03);
 
 
chips->DrawCopy("TEXT");
kvadratki->DrawCopy("BOX,SAME");
c->cd(4);
pixelonchp->GetYaxis()->SetTickLength(0.01);
pixelonchp->GetYaxis()->SetLabelOffset(0.03);
 
pixelonchp->GetXaxis()->SetTickLength(0.01);
pixelonchp->GetXaxis()->SetLabelOffset(0.03);
 
 
pixelonchp->DrawCopy("TEXT");
kvadratki->DrawCopy("BOX,SAME");
 
 
return m;
}
*/
/cvi/apps/sa02_daq/analysis/map.h
0,0 → 1,8
#ifndef MAP_H_
#define MAP_H_
 
int mapped();
/*int newFile();
GRID mapping2();*/
 
#endif
/cvi/apps/sa02_daq/analysis/map.pdf
0,0 → 1,564
%PDF-1.4
%âãÏÓ
1 0 obj
<<
/Type /Catalog
/Pages 4 0 R
/Outlines 3 0 R
/PageMode /UseOutlines
>>
endobj
2 0 obj
<<
/Creator (ROOT Version 5.34/34)
/CreationDate (D:20160119005505)
/Title (map.pdf)
/Keywords (ROOT)
>>
endobj
5 0 obj
<<
/ProcSet [/PDF /Text]
/Font
<<
/F1 7 0 R /F2 8 0 R /F3 9 0 R /F4 10 0 R /F5 11 0 R /F6 12 0 R /F7 13 0 R /F8 14 0 R /F9 15 0 R /F10 16 0 R /F11 17 0 R /F12 18 0 R /F13 19 0 R /F14 20 0 R /F15 21 0 R
>>
/ExtGState 25 0 R
/ColorSpace << /Cs8 22 0 R >>
/Pattern 24 0 R
>>
endobj
7 0 obj
<<
/Type /Font
/Subtype /Type1
/Name /F1
/BaseFont /Times-Italic
/Encoding /WinAnsiEncoding
>>
endobj
8 0 obj
<<
/Type /Font
/Subtype /Type1
/Name /F2
/BaseFont /Times-Bold
/Encoding /WinAnsiEncoding
>>
endobj
9 0 obj
<<
/Type /Font
/Subtype /Type1
/Name /F3
/BaseFont /Times-BoldItalic
/Encoding /WinAnsiEncoding
>>
endobj
10 0 obj
<<
/Type /Font
/Subtype /Type1
/Name /F4
/BaseFont /Helvetica
/Encoding /WinAnsiEncoding
>>
endobj
11 0 obj
<<
/Type /Font
/Subtype /Type1
/Name /F5
/BaseFont /Helvetica-Oblique
/Encoding /WinAnsiEncoding
>>
endobj
12 0 obj
<<
/Type /Font
/Subtype /Type1
/Name /F6
/BaseFont /Helvetica-Bold
/Encoding /WinAnsiEncoding
>>
endobj
13 0 obj
<<
/Type /Font
/Subtype /Type1
/Name /F7
/BaseFont /Helvetica-BoldOblique
/Encoding /WinAnsiEncoding
>>
endobj
14 0 obj
<<
/Type /Font
/Subtype /Type1
/Name /F8
/BaseFont /Courier
/Encoding /WinAnsiEncoding
>>
endobj
15 0 obj
<<
/Type /Font
/Subtype /Type1
/Name /F9
/BaseFont /Courier-Oblique
/Encoding /WinAnsiEncoding
>>
endobj
16 0 obj
<<
/Type /Font
/Subtype /Type1
/Name /F10
/BaseFont /Courier-Bold
/Encoding /WinAnsiEncoding
>>
endobj
17 0 obj
<<
/Type /Font
/Subtype /Type1
/Name /F11
/BaseFont /Courier-BoldOblique
/Encoding /WinAnsiEncoding
>>
endobj
18 0 obj
<<
/Type /Font
/Subtype /Type1
/Name /F12
/BaseFont /Symbol
>>
endobj
19 0 obj
<<
/Type /Font
/Subtype /Type1
/Name /F13
/BaseFont /Times-Roman
/Encoding /WinAnsiEncoding
>>
endobj
20 0 obj
<<
/Type /Font
/Subtype /Type1
/Name /F14
/BaseFont /ZapfDingbats
>>
endobj
21 0 obj
<<
/Type /Font
/Subtype /Type1
/Name /F15
/BaseFont /Symbol
>>
endobj
22 0 obj
[/Pattern /DeviceRGB]
endobj
23 0 obj
<</ProcSet[/PDF]>>
endobj
24 0 obj
<<
/P01 26 0 R /P02 27 0 R /P03 28 0 R /P04 29 0 R /P05 30 0 R /P06 31 0 R /P07 32 0 R /P08 33 0 R /P09 34 0 R /P10 35 0 R /P11 36 0 R /P12 37 0 R /P13 38 0 R /P14 39 0 R /P15 40 0 R /P16 41 0 R /P17 42 0 R /P18 43 0 R /P19 44 0 R /P20 45 0 R /P21 46 0
R /P22 47 0 R /P23 48 0 R /P24 49 0 R /P25 50 0 R
>>
endobj
26 0 obj
<</Type/Pattern/Matrix[1 0 0 1 20 28]/PatternType 1/Resources 23 0 R/PaintType 2/TilingType 1/BBox[0 0 98 4]/XStep 98/YStep 4/Length 91/Filter/FlateDecode>>
stream
H‰*ä2TÈTà2P0P04€à¢T®p…< P0KÁP¡(¬à«m¨k Âe¤`¢Ëei ¤r€ºA •”1‚ȁe !2†@N0W @€|cï
endstream
endobj
27 0 obj
<</Type/Pattern/Matrix[0.75 0 0 0.75 20 28]/PatternType 1/Resources 23 0 R/PaintType 2/TilingType 1/BBox[0 0 96 4]/XStep 96/YStep 4/Length 92/Filter/FlateDecode>>
stream
H‰$Š1
€0C÷œ"Gø¿Ñ+âàPÜtPª ‹×7Ú!„¼— ΍0ÝJîO¡Np§ófÏ䌜 +hUÖ/~£Ve™PLøã#¼ ¢`:
endstream
endobj
28 0 obj
<</Type/Pattern/Matrix[0.5 0 0 0.5 20 28]/PatternType 1/Resources 23 0 R/PaintType 2/TilingType 1/BBox[0 0 96 16]/XStep 96/YStep 16/Length 93/Filter/FlateDecode>>
stream
H‰$Š1
€0C÷œ"Gø±(ö
‚ƒ88ˆ›JtñúþÚ!„¼—âN²’gÃÄËQçð ø:fÏY \Œ+**ðDls'Ƽ¯ä®.ªþŠ‘>Ï£¬
endstream
endobj
29 0 obj
<</Type/Pattern/Matrix[0.06 0 0 0.06 20 28]/PatternType 1/Resources 23 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 63/Filter/FlateDecode>>
stream
+endstream
+endobj
+30 0 obj
+<</Type/Pattern/Matrix[0.06 0 0 0.06 20 28]/PatternType 1/Resources 23 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 66/Filter/FlateDecode>>
+stream
+endstream
+endobj
+31 0 obj
+<</Type/Pattern/Matrix[0.03 0 0 0.03 20 28]/PatternType 1/Resources 23 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 66/Filter/FlateDecode>>
+stream
+H‰*ä2TÈTà2P0P04€à¢T®p…< P0KÁD¡(¬à«k Âe
+endstream
+endobj
+32 0 obj
+<</Type/Pattern/Matrix[0.03 0 0 0.03 20 28]/PatternType 1/Resources 23 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 68/Filter/FlateDecode>>
+stream
+endstream
+endobj
+33 0 obj
+<</Type/Pattern/Matrix[0.06 0 0 0.06 20 28]/PatternType 1/Resources 23 0 R/PaintType 2/TilingType 1/BBox[0 0 101 101]/XStep 100/YStep 100/Length 139/Filter/FlateDecode>>
+stream
+H‰D±Â0 DwÅÍL6Q•|CÅÀPuk+$ºðûصÓ¹Ø÷œä"xŒªš+%ëVZ.jd÷…x¡({]ÉÔ]Ó|âJ:Æ՘Jg–J±½D¯#ß=°ìk›é‰Z75ßüÔÆÃȘâx=Ãù½ÇoÚsٓ” GØõô`
+X1}
+endstream
+endobj
+34 0 obj
+<</Type/Pattern/Matrix[0.06 0 0 0.06 20 28]/PatternType 1/Resources 23 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 108/Filter/FlateDecode>>
+stream
+H‰*ä2TÈTà2P0P04€à¢T®p…< P0KÁD¡(¬à«k 65PÈRFFz&,d Ìen®g5,b˜‚$ šŒ@ò¦`Ž9HÞ¢6™ &€,
+ÖÌÈ` @—
+endstream
+endobj
+35 0 obj
+<</Type/Pattern/Matrix[0.06 0 0 0.06 20 28]/PatternType 1/Resources 23 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 93/Filter/FlateDecode>>
+stream
+¡\C dN.LÊ…«5…j6…X”ÃÌÈ`Š7
+endstream
+endobj
+36 0 obj
+<</Type/Pattern/Matrix[0.125 0 0 0.125 20 28]/PatternType 1/Resources 23 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 164/Filter/FlateDecode>>
+stream
+H‰\1Â0 EwŸâÁip“^‰u`@l0€(,\;v„Ú¡‰ÞûßVó¦„;ˆÁHìßçF'¼TíU>ðUÎƵ5=ƓÄImÚØî&ÕÛfZ½F߅µO¸ٌÞŸ—`ïi®“â;]ä­(!úî…jÿKݐäÿˆ¼ÆØßT{Œ,Š;Áè8æ†O=Ž|Š|¦#ýŽFF‡
+endstream
+endobj
+37 0 obj
+<</Type/Pattern/Matrix[0.125 0 0 0.125 20 28]/PatternType 1/Resources 23 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 226/Filter/FlateDecode>>
+stream
+H‰<P;nÃ0 Ýy
+NɪS\—{§w‡¤Ã­p+(…Ûðe/vîaÍÏðºÐb|w¾ƒoàk $b–,¢¬t(
+uÅVmËý׺¯—fuf–juî’x˱Sÿá¼,ƒ¬«Z\²A²…eDèˆÐ•ŠÐ¡íúJE,–6äöÈUäHFx>郞 d}eŽ
+endstream
+endobj
+38 0 obj
+<</Type/Pattern/Matrix[0.06 0 0 0.06 20 28]/PatternType 1/Resources 23 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 69/Filter/FlateDecode>>
+stream
+H‰*ä2TÈTà2P0P04€à¢T®p…< P0KÁD¡(¬à«k V™ËS›Ã¡!" ~0W @€ٗ«
+endstream
+endobj
+39 0 obj
+<</Type/Pattern/Matrix[0.15 0 0 0.15 20 28]/PatternType 1/Resources 23 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 80/YStep 80/Length 114/Filter/FlateDecode>>
+stream
+H‰4Œ=
+€0 …÷œâ!-¡ô ‚ƒ88ˆ›J+èâõMú3”×÷}Ir8A †ãúރ܊…ŸbŒX7Æ®Ø32Ù ~y[͆’úØ}´«Ýë %“¥o=X—æ¥íKáå@ñ3Mô 0‡o"±
+endstream
+endobj
+40 0 obj
+<</Type/Pattern/Matrix[0.102 0 0 0.102 20 28]/PatternType 1/Resources 23 0 R/PaintType 2/TilingType 1/BBox[0 0 60 60]/XStep 60/YStep 60/Length 218/Filter/FlateDecode>>
+stream
+щŽô`Š'_
+endstream
+endobj
+41 0 obj
+<</Type/Pattern/Matrix[0.1 0 0 0.05 20 28]/PatternType 1/Resources 23 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 123/Filter/FlateDecode>>
+stream
+VŒ¬ ˆr@´±P¡H5D«H·È4 ä°lB0W @€hU Å
+endstream
+endobj
+42 0 obj
+<</Type/Pattern/Matrix[0.06 0 0 0.06 20 28]/PatternType 1/Resources 23 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 66/Filter/FlateDecode>>
+stream
+éB
+endstream
+endobj
+43 0 obj
+<</Type/Pattern/Matrix[0.06 0 0 0.06 20 28]/PatternType 1/Resources 23 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 69/Filter/FlateDecode>>
+stream
+r¸‚¹¹ B
+endstream
+endobj
+44 0 obj
+<</Type/Pattern/Matrix[0.117 0 0 0.117 20 28]/PatternType 1/Resources 23 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 149/Filter/FlateDecode>>
+stream
+H‰LŽ;Â@ D{ŸbNÙ+6a¯€D((Pª@R áúø³Ž(Ö¶fÞØû&ÁÄ`ÇûÜ邗JŸ|UÆיq£Æ¨ŒÕúTÞ÷²Ö…Ê4´b£$"n.¤=̨!‹9×i=ÓÏ©8ÚT}ç.‚æWûúj͑䶋=Ÿ¡äñ´!žwä¹o8Ӊ~ öÂ6›
+endstream
+endobj
+45 0 obj
+<</Type/Pattern/Matrix[0.05 0 0 0.1 20 28]/PatternType 1/Resources 23 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 122/Filter/FlateDecode>>
+stream
+H‰<L;ƒ0 Ý}Šwä$Mš3 1 ĔvhU`áú<TÉö³Þo‡D¡pzíþ–+©–ä¤Ñaš/‰
+ÎrãORh²}ψäoÈ)“3¥ª[m¼ÚË¿!$Úùùˆ`N¢·$³¦ªW¯¥éå`oç Å
+endstream
+endobj
+46 0 obj
+<</Type/Pattern/Matrix[0.125 0 0 0.125 20 28]/PatternType 1/Resources 23 0 R/PaintType 2/TilingType 1/BBox[0 0 101 101]/XStep 100/YStep 100/Length 117/Filter/FlateDecode>>
+stream
+H‰D1
+€0 E÷œâ!)”ÞApqÓA©‚.^ß$-^ú^nì CX¼Ÿ&\u¼£Ç¼0V]œ¢"´2EnÔʔbc²\˜ÿÁÚWM”Š(U‘ýµÁ?èÏP‘‹o¤>I'f
+endstream
+endobj
+47 0 obj
+<</Type/Pattern/Matrix[0.125 0 0 0.125 20 28]/PatternType 1/Resources 23 0 R/PaintType 2/TilingType 1/BBox[0 0 101 101]/XStep 100/YStep 100/Length 118/Filter/FlateDecode>>
+stream
+H‰<=
+„P „ûœbŽ<ïÂba!vZ(» Úx}“¼Ÿ"|“a˜¹Hp€ a‰»wšñ7k0ó„à1,+c#Ï0~”4Ä×EV£r§ºoOcrßÓ]H –ªÜªr­ò¯‹( ĨÖÍT·½q¢‘^º÷(&
+endstream
+endobj
+48 0 obj
+<</Type/Pattern/Matrix[0.06 0 0 0.06 20 28]/PatternType 1/Resources 23 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 169/Filter/FlateDecode>>
+stream
+H‰<»
+1EûùŠ[[MÖÙìä ±°;”DÐÆßw¬pó˜“á$äMƒQ8ÇçF'¼ í >Qð5Œ=Î .Œkt˜;)Ôö¥Fa‹eÐvŠrX‰FiÔ2¨J”Â÷hŠ¬I\ÕR•o43æU@a [‚Za A‚E`é~O`é~S‚Æh.m«´)šKtÈqìë§ôÿCîú 0m:ý
+endstream
+endobj
+49 0 obj
+<</Type/Pattern/Matrix[0.125 0 0 0.125 20 28]/PatternType 1/Resources 23 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 280/Filter/FlateDecode>>
+stream
+H‰DQ9NA ÌûŽ‰Öãv_@"@ˆ @$|Ýåjvå©Ãã*Ê»½\dý?ñdMÎ2ÆߌßYÞn mÁyã\<,i¨8F)çlÒoÿë|[¬ã;ÍÏky”¯ nƒü•ß åNžTº<_ä¥Ä^Ó8 cžE›xOó„>©Ïԛ{êþÞSïFl©ú‡§>xoh&_öUdÙ«ÌDÚ¡‰…¦Öž*½Ç„z8!sÝÆ\ÆCÆ\•þÊ\•Çª¦îô»Qç¹:ùálÉeˆï1‰©#üÂH:âc¡Ó±7Ð ¨ÂÓa{%Âaû(ZxË‹@pÔ}=¼eE8sÖ}MÊ}¹
+0³‡
+endstream
+endobj
+50 0 obj
+<</Type/Pattern/Matrix[0.125 0 0 0.125 20 28]/PatternType 1/Resources 23 0 R/PaintType 2/TilingType 1/BBox[0 0 101 101]/XStep 100/YStep 100/Length 54/Filter/FlateDecode>>
+stream
+ @ÂÑiZPÅ`MæȊR†Ò€
+endstream
+endobj
+51 0 obj
+<<
+/Type /Page
+/Parent 4 0 R
+/MediaBox [ 0 0 595 842]
+/CropBox [ 20 255 561 822]
+/Rotate 90
+/Resources 5 0 R
+/Contents 52 0 R
+>>
+endobj
+52 0 obj
+<<
+/Length 53 0 R
+/Filter [/FlateDecode]
+>>
+stream
+Óã—?>~ÿ7ý›iÚÀn›y‘ÿtMê&9µµÇåùçú®Y–´>ú65s/Hs3·rMíÜL™à~Urûä*^øäW¢çŸØ¿?~|$½ýÔ ÝÚÉA—fLÛ]ü»¯¿ýÇé1ÝOããë?=þJ>ÿ׏¯ÿëñ_\Ñ{
+ã g×/žB÷yùÛe\G!ŸWX¥Ï̽'Ð~^ µkÓ-îMŠ(ts3¶žÑ©( “ø0:
+m
+(L£øÀÖ@GJ‹üµŒ$ç
+ÄU Iô
+Ï HD`꛵OÎ
+ÌÒҋ¼­,‘ã/‘i&Iìø‘XŠ8DŽ?îE¡I"ê<?³x\‚Å!.Ñ®Â"‘#Qaáæ(DÖU˜"q‰TcŠäHDV>ƒPiö$ÚȍBPr$"Ó0„%*±ž˜¨ÂRcýFæÈ4 Á‰+§Y”Æþé$£Æ4ɑˆ„'é¯ëäJ ‘ðä(D6&K\¢ÌÇž+"ëP„'ç*"º„£
+s(¹¤Á‰+D23N\!2¯Ap¢
+KìW¨œV1\>õlN˜^Zpr$j伉
+ë8G!ò¼FpâC´7—è"‹!¬æ¨ÄYjlâ‘ŽØDæ€Õ]Û5Sï^C$÷ƒØÄ}Éb¿KÀÑ/ÍÜÊá’PíøD 2á7¨ë<…HzIgMŽBdM×5]£…
+k:®0F&Ý"ˆä)T؍ã
+¡,Ö•¸@䇨Ä"«̘…È|F£’£Y’jTr"Ù&ݐú¶é»gã-²˜CT¢–rT 2㳘D"S„$*™‹!"1)2Ç@@b¡m>„ z‹*$¸@dy¥dT ²Ùj±‚
+TØ»†¹é×gp¡ý1Ä
+ªI™X°à
+žjт*Œ‘Á†pAæÐÂJãU˜BI鬫w—B)Ÿ©éZÏèЮ½F$*yõÍBWˆl•!&ñ›T#(q…À$Ì¢Ò44Ãüt‚Ù-CTâ
+‘÷‰Æ&õ£§0F’шJTaŠŒD%®Úº—éö¼z
+‘Í8D%ªJöÈ0fG rˆJ\ ’(ATâ
+5–UT!òÚ²E%ªÙ9¶¨´¤fž½&0,*q…€6W¢
+Sà gQ‰+DòˆJü.E0Wâ×™!*Q…È„R“=ôø¡·Çg]ïÝ£xÚ¹„
+ÏC`ÖmA‰+ÔÈöP…)²€ëå½z
+Ó͍\WiKAõ½‡âPÚRœÕ0l³âœÒ–âX£<c‡âܵ¥ ¦®ésæãÿ bn·à3ÚRœÓ¼6S[I[Šc-ò ǜҖ‚’¹Êd0£´%§‰‘ã¸fZòó¶™RNiKq¬NþrÊÏ-Õoñ(?{´ÔÐÊ#??{´ç5,Íöw9µ·Çe¾4g¯-5É3¥+Î^[
+f˜—ÐéyÍ­#Œ9G3Ž0æc`càc`càc`aÌ1ÆÀ0œ'EÜ0™c 2ËdžQ¦Q®Q¶Q¾QÆ1Ȝ£¬cÐyʽcyÇ óŽAæ…à…à…à…à…àƒÌ;
+Á;'þÜ;™w 2ïdÞQÞQÞQÞQÞQÞ1ȼ£¼cÐy¡Å½cyÇ óŽAæ…à…à…à…à…àƒÌ;
+Á;¶Ô;
+Á;
+Á;
+Á;©wRï8¤ÞqH½ãzG!xÇ!õŽBçD÷ŽAæƒÌ;™w‚w‚w‚w‚w‚w 2ï(ïtNÜpïdÞ1ȼcyG!xG!xG!xG!xG!xÇ óŽBðŽAçD÷ŽAæƒÌ;™w‚w‚w‚w‚w‚w 2ï(ïtNLrïdÞ1ȼcyG!xG!xG!xG!xG!xÇ óŽBðŽAç´,÷ŽAæƒÌ;™w‚w‚w‚w‚w‚w 2ï(ïô‘Î,
+ÿJïu|YïùÏç¢ËÝ"Ý£Èyñ"ÏÒ#Ú­ôË<’„M?õýgª<?ÿd¾-AάxéNúϸbcûWÊ_<>¶´©Àå¾Ä‹xãŽ
+Q\"–+×Å%jd˹Äu•º7ÓåŽD|yº¦oŸEÁëŸxwÅ%jäˉùrG¢F¾Ü‘¨‘/w$jäˉ
+WŽDh˜#\9±<º†+G#–H×påhÄ2鮍X.]Ã×½À†D•§˦k¸r4béô¹•'åâø<&‘»fîò2sù7¿úö›ÿòÓ_¾ÿßïúñ•ºÔú¿¬.µ¶õwûfè×9¯¿›QV“¥“+ù¨:y”";(«Bm”µäJ·”•,;(«Bmçe-e^ìXGi³ƒBjƒÐ1VÆ £ZFij;)4ä jÅG²2i…*Ô…–œBI™ƒ²rj…*ÔÇi¡¥ ´òÌq,´äªPZr
+jÊʳeªP煖œB›ãXVÆí ¬
+»¹(P–œ’)òÚM9…–œJ²@‹òÀhÉÏëc.ܧ‚Ú[Šc‰S˒ßv´T75cŸ—êFKA‰tZòÈh)Îk蛥ϯ-űdŠ2—¸7̔dv™÷´”Ô*óªâܵ¥8+y¼ CqîÚRk{¼¬Å¹kKA­2{Ïcµ6äL×ÊPlósGK~V]êåù¹£åýQñå+4¯)âì»ôÐ3J[
+jûµÞq)†ôÞò©‡ˆÕxÞ÷[ë?DT`–+IëzÇ3dØ&~Ë|Ë#Dä™-Ë»;ž * ÏÛ>7<@P¨ºKm3µÏ\~£Rµöq^ ’Açůɠó„ŸW‚¤Ði’Î+ARè4­æ• tžóJ :?µyu%Yu%Yu%Yu%
+¡º…P]‰Bê‡P]‰B¨®Ä «®D!TWbÐi¢D­c œc Œc |£ŒÚFu2jeÔ3ʨeŒc”QÃsžRÃ(Ç(Ë(Ï8¤¦qH]ãÚÆ!õCj…à‡Ô:
+gÿÔ;
+Á;
+Á;
+Á;©wRï8¤ÞqH½ãzG!xÇ!õŽBçÕ÷ŽAæƒÌ;™w‚w‚w‚w‚w‚w 2ï(ït^ÝrïdÞ1ȼcyG!xG!xG!xG!xG!xÇ óŽBðŽA§t·Ž0æaÌ8˜oŒmŒkŒiŒgŒe„1ÇÃsÎÙpÃdŽ1È,cyF!˜F!¸F!ØF!øF!Ç sŽB°ŽAç÷ŽAæƒÌ;™w‚w‚w‚w‚w‚w 2ï(ïtÎJRï(ï(ï(ï8¤ÞqH½ãzÇ!õŽCê…à‡Ô;
+s²Ü;™w 2ïdÞQÞQÞQÞQÞQÞ1ȼ£¼cÐG
+óIuê_å-7ªT“ó{Rm:m¿¡u$ߨ6írÛaxá̊mjq¦íjÐå;‰ï* Û/‡ŽŽBŠ(l¿90%G¡‹(ÌÒ!g§’où6â»
+nßÐUh`r$¦
+‘É‘˜+„&Gb©›‰5œnìPÛ|oï‡ÜØ¡žnìPˆO7v(¨;"ԍ
+!
+Q7v(„¨;Bԍ
+³¨;Bԍ
+ªÊ©lßëL^ëXRYÇômNۘ¾Í鱚>y½5–TÖ!}›ÓXñê­U6»‰»]ŽDí.G¢Æ~—#QcÃˑ¨°ãuc‡²Ç}
+Ë¡;–C7v(›tÜס°º±CYˆYñÖ*û^ŽD}/G¢Æ¾—#Qcßˑ¨±ïåHTØ÷º±C!csc‡²u_‡²u_‡²u_‡²u_‡²Å«¶ÖØ÷r$jì{q‰*û^ŽD}/G¢Æ¾—#QaßëÆe!ê¾e!ê¾e«¼û:”…¨û:”…¨û:”…(Z´µÆ¶W¨±ëÅjlzq…{^\¡Æ–W¨°ãu_W²Øt[W²Ðt[W²ÉÓm]ÉÓm]ÉâÒm] {]¼:k½.®ßëâǯ±×Åjìu95rkìu95öºîëKÈ<Ýח¿¯7aÆt_oB\º±7!1~coÂ^—S‰57èñkìuq…{]\¡Æ^W¨±×uŸÏ6¦osÚÆômNc¯ë>§mHß洍èQžvS^T,ÿFœ}Nþýö?¿ÿ™•>>}ý쇇LZ›v˜OÅ[åüR^—ÕZrJ>9,yáYkÉ©A&bcQ-E¿í‡%sHrfJ_•ËÎ
+-95·Í<ç…`­¥ Öf
+A´äÔ²4k*(´äÔ:7ë2ä煖¼lîöŽÃ˜—¶–¢¸îôÑ2
+-9%n¤5/ l-9%nl8³B½hÉ)qCÖÁù±Ð’S[¥ƒ¶ Ð’Sâǐw4䌸1Ž¹‹ÖRPëVŠ4?ZrJܘÖÜkÉ)qcžòòÎ֒ònåÑӏÙyYËû#£ìè7§q÷ºâ˜ÆfmËãڒS,Ýæ‚BKQþø³ïõ½^ÿøsoϼ^ýø³ï¶¼^ýø³ï«½^ýø³ož¼^ýøíge×´^ç¢øñÏ´äŏÓ"O¯>/óªPQæUTéôYñcPyñc¥ŽâÇ
+?©ºSN:¯oÓéÁMãÐîgÔ9©s‚sRç8¤ÎqhwŽ3ê‡Ô9§Þôî¿MåL‰G™Ý7Š¨m”Q×Ó(£žQF-£ÌîEÔ0ʨ_¼Æôn½=§É(µ‹C»_œQÃ8¤ŽQ–qH=㐚ơÝ5ΨmRߜZÓ»qü6¦þÔ9íÎqFã:G!8Ç!uŽCê‡vç8£ÎqHs*MïÎñÛtZhqç(¤ÎQÎQÎ1Ȝ£œ£œ£:G8G!8Ç sŽÞ¦Ó²–;G!uŽ2pŽBpŽAæ…à…à…Ô9ÊÀ9
+Á9^eZ£·©Ì"p㣾1¶1®ÆLc <c ,cŒ:ÆÆøE+K«]ìöœ5Ü.
+©_”a‚c 2Ë(Ï(Ó(¤®Q¶Q¾ñ
+Ój½M§´wŽBêeà…àƒÌ9
+Á9
+Á9
+IãÐîgÔ9©s‚sRç8¤ÎqhwŽ3ê‡Ô9§ºôî¿M§,wŽBêeà…àƒÌ9
+Á9
+Á9
+©s”s‚s¼¶´:÷n¥ã_ù½ŽÿWPJ
+endstream
+endobj
+53 0 obj
+6548
+endobj
+54 0 obj
+<<
+/Title (Page 1)
+/Dest [ 51 0 R /XYZ null null 0]
+/Parent 6 0 R
+>>
+3 0 obj
+<<
+/Type /Outlines
+/Count 2
+/First 6 0 R
+/Last 6 0 R
+>>
+endobj
+6 0 obj
+<<
+/Title (Contents)
+/Dest [ 51 0 R /XYZ null null 0]
+/Count 1
+/Parent 3 0 R
+/First 54 0 R
+/Last 54 0 R
+>>
+4 0 obj
+<<
+/Type /Pages
+/Count 1
+/Kids [ 51 0 R ]
+>>
+endobj
+25 0 obj
+<<
+/ca1.00 << /Type /ExtGState /ca 1.00 >> /CA1.00 << /Type /ExtGState /CA 1.00 >>
+>>
+endobj
+xref
+0 55
+0000000000 65535 f
+0000000015 00000 n
+0000000103 00000 n
+0000017381 00000 n
+0000017567 00000 n
+0000000223 00000 n
+0000017452 00000 n
+0000000512 00000 n
+0000000622 00000 n
+0000000730 00000 n
+0000000844 00000 n
+0000000952 00000 n
+0000001068 00000 n
+0000001181 00000 n
+0000001301 00000 n
+0000001407 00000 n
+0000001521 00000 n
+0000001633 00000 n
+0000001752 00000 n
+0000001831 00000 n
+0000001942 00000 n
+0000002027 00000 n
+0000002106 00000 n
+0000002144 00000 n
+0000002179 00000 n
+0000017627 00000 n
+0000002503 00000 n
+0000002785 00000 n
+0000003074 00000 n
+0000003364 00000 n
+0000003630 00000 n
+0000003899 00000 n
+0000004168 00000 n
+0000004439 00000 n
+0000004782 00000 n
+0000005094 00000 n
+0000005390 00000 n
+0000005760 00000 n
+0000006192 00000 n
+0000006464 00000 n
+0000006780 00000 n
+0000007200 00000 n
+0000007526 00000 n
+0000007795 00000 n
+0000008067 00000 n
+0000008422 00000 n
+0000008747 00000 n
+0000009070 00000 n
+0000009394 00000 n
+0000009767 00000 n
+0000010253 00000 n
+0000010512 00000 n
+0000010657 00000 n
+0000017282 00000 n
+0000017303 00000 n
+trailer
+<<
+/Size 55
+/Root 1 0 R
+/Info 2 0 R
+>>
+startxref
+17729
+%%EOF
/cvi/apps/sa02_daq/analysis/mapNEW.map
0,0 → 1,144
0 0 4 4 91 25
0 1 4 2 115 13
0 2 3 0 140 2
0 3 4 3 103 19
0 4 5 3 102 18
0 5 5 0 138 0
0 6 3 1 128 8
0 7 2 0 141 3
0 8 5 1 126 6
0 9 5 2 114 12
0 10 3 2 116 14
0 11 2 1 129 9
0 12 4 0 139 1
0 13 4 1 127 7
0 14 1 0 142 4
0 15 2 2 117 15
0 16 5 4 90 24
0 17 5 5 78 30
0 18 0 0 143 5
0 19 1 1 130 10
0 20 0 4 95 29
0 22 3 3 104 20
0 21 1 4 94 28
0 23 0 1 131 11
0 24 1 5 82 34
0 25 2 5 81 33
0 26 1 2 118 16
0 27 2 3 105 21
0 29 0 5 83 35
0 28 3 5 80 32
0 30 0 2 119 17
0 31 1 3 106 22
0 32 4 5 79 31
0 33 2 4 93 27
0 34 3 4 92 26
0 35 0 3 107 23
1 0 7 4 88 28
1 1 9 4 86 26
1 2 11 3 96 18
1 3 8 4 87 27
1 4 8 5 75 33
1 5 11 5 72 30
1 6 10 3 97 19
1 7 11 2 108 12
1 8 10 5 73 31
1 9 9 5 74 32
1 10 9 3 98 20
1 11 10 2 109 13
1 12 11 4 84 24
1 13 10 4 85 25
1 14 11 1 120 6
1 15 9 2 110 14
1 16 7 5 76 34
1 17 6 5 77 35
1 18 11 0 132 0
1 19 10 1 121 7
1 20 7 0 136 4
1 21 7 1 124 10
1 22 8 3 99 21
1 23 10 0 133 1
1 24 6 1 125 11
1 25 6 2 113 17
1 26 9 1 122 8
1 27 8 2 111 15
1 28 6 3 101 23
1 29 6 0 137 5
1 30 9 0 134 2
1 31 8 1 123 9
1 32 6 4 89 29
1 33 7 2 112 16
1 34 7 3 100 22
1 35 8 0 135 3
2 0 4 7 55 7
2 1 2 7 57 9
2 2 0 8 47 17
2 3 3 7 56 8
2 4 3 6 68 2
2 5 0 6 71 5
2 6 1 8 46 16
2 7 0 9 35 23
2 8 1 6 70 4
2 9 2 6 69 3
2 10 2 8 45 15
2 11 1 9 34 22
2 12 0 7 59 11
2 13 1 7 58 10
2 14 0 10 23 29
2 15 2 9 33 21
2 16 4 6 67 1
2 17 5 6 66 0
2 18 0 11 11 35
2 19 1 10 22 28
2 20 4 11 7 31
2 21 4 10 19 25
2 22 3 8 44 14
2 23 1 11 10 34
2 24 5 10 18 24
2 25 5 9 30 18
2 26 2 10 21 27
2 27 3 9 32 20
2 28 5 8 42 12
2 29 5 11 6 30
2 30 2 11 9 33
2 31 3 10 20 26
2 32 5 7 54 6
2 33 4 9 31 19
2 34 4 8 43 13
2 35 3 11 8 32
3 0 7 7 52 10
3 1 7 9 28 22
3 2 8 11 3 33
3 3 7 8 40 16
3 4 6 8 41 17
3 5 6 11 5 35
3 6 8 10 15 27
3 7 9 11 2 32
3 8 6 10 17 29
3 9 6 9 29 23
3 10 8 9 27 21
3 11 9 10 14 26
3 12 7 11 4 34
3 13 7 10 16 28
3 14 10 11 1 31
3 15 9 9 26 20
3 16 6 7 53 11
3 17 6 6 65 5
3 18 11 11 0 30
3 19 10 10 13 25
3 20 11 7 48 6
3 21 10 7 49 7
3 22 8 8 39 15
3 23 11 10 12 24
3 24 10 6 61 1
3 25 9 6 62 2
3 26 10 9 25 19
3 27 9 8 38 14
3 28 8 6 63 3
3 29 11 6 60 0
3 30 11 9 24 18
3 31 10 8 37 13
3 32 7 6 64 4
3 33 9 7 50 8
3 34 8 7 51 9
3 35 11 8 36 12
/cvi/apps/sa02_daq/analysis/printgain.c
0,0 → 1,43
void printgain(char * foutput=NULL){
char fname[0xff];
char run[0xff];
sprintf(fname,"%s",gSystem->BaseName(_file0->GetName()));
fname[11]=0;
strncpy(run,fname,4);
run[4]=0;
TIter nxt(gDirectory->GetListOfKeys());
TKey *key;
 
FILE *fo=stdout;
if (foutput!=NULL && strlen(foutput)>1) {
fo = fopen(foutput,"a");
printf("FILE=%s",foutput);
}
while ((key = (TKey*)nxt())) {
TClass *cl = gROOT->GetClass(key->GetClassName());
if (!cl->InheritsFrom("TCanvas")) continue;
TCanvas *c1 = (TCanvas*)key->ReadObj();
TPad *pad = (TPad *)c1->GetListOfPrimitives()->At(1);
 
TH2F *h2 = (TH2F*)pad->GetListOfPrimitives()->At(0);
TCanvas c2;
if (h2) {
h2->Print();
fprintf(fo,"<gain run='%s' sn='%s'>\n", run,&fname[5]);
for (int i=0;i < h2->GetNbinsX();i++){
for (int j=0;j < h2->GetNbinsY();j++){
fprintf(fo,"<v i='%d'>%g</v>\n",i* h2->GetNbinsY()+j, h2->GetBinContent(i+1,j+1));
}
}
fprintf(fo,"</gain>\n");
}
else printf("not found\n");
}
// TCanvas *c1 = gDirectory->Get("0063_ZJ6743_Gain")
// hFra40 = (TH1F*)c1->GetPrimitive("hFracEtcorr2Part");
 
}
/cvi/apps/sa02_daq/analysis/printgain.sh
0,0 → 1,14
#!/bin/bash
DIR=`dirname $0`
echo $DIR
FNAME=arichdeadchannels.xml
rm $FNAME
 
echo "<moduletest>" > $FNAME
for x in ../modules/[0-9][0-9][0-9][0-9]/[0-9][0-9][0-9][0-9]_??????.root ; do
echo root -b -q $x printgain.c\(\"${FNAME}\"\)
root -b -q $x printgain.c\(\"${FNAME}\"\)
done
echo "</moduletest>" >> $FNAME
#cat $FNAME
 
/cvi/apps/sa02_daq/analysis/projection.c
0,0 → 1,349
#include <stdio.h>
#include <stdlib.h>
 
#include <TROOT.h>
#include <TH1D.h>
#include <TH2D.h>
#include <TH3D.h>
#include <TCanvas.h>
#include <TStyle.h>
#include <TSystem.h>
#include <TFile.h>
#include <TDirectory.h>
#include <TPaveText.h>
 
#include <iostream>
#include <string>
 
#include "base.h"
#include "projection.h"
#include "savetoroot.h"
 
int projection(int runNumber, int save) {
 
int HAPDnumber; //Number of HAPD: 0, 1, 2 or 3!
 
int direction, nx, ny;
char name[128];
char pdfname[128];
char buf[256];
float pNoise;
int color[6] = {1,2,4,6,8,9};
 
char hname[0xF];
 
const char * serialNumber = getSN(runNumber);
std::string serialNumberTemp = serialNumber;
std::string HAPDserialNumber,FEBserialNumber;
 
GRID m = mapping();
int vrstaPisave = 82;
 
TCanvas * c, * c2;
TPad * pad1, * pad2, * pad3, * pad4, * c2pad1, * c2pad2;
TPad * VirtualPad2[12];
TLine * l;
TPaveText * info, * axisName;
TAxis * axis;
TH3D * h;
TH2D * slice[12], * sum; //take the right slice from 3D histogram
TH1D * p[12], * zamenjan[12];
 
/********** GLOBALNE **********/
gStyle->SetOptStat(0);
//gStyle->SetOptTitle(1);
gStyle->SetTitleFontSize(.15);
TDirectory *CurrentDirectory = gDirectory->CurrentDirectory();
 
for(HAPDnumber=0;HAPDnumber<4;HAPDnumber++){
 
// Change code here for runs where one or more modules were disabled during measurement
//if(HAPDnumber==0) continue;
//if(HAPDnumber==1) continue;
//if(HAPDnumber==2) continue;
//if(HAPDnumber==3) continue;
SaveToRootInit();
//std::cout << serialNumberTemp << std::endl;
FEBserialNumber = serialNumberTemp.substr(0,serialNumberTemp.find(","));
serialNumberTemp.erase(0,FEBserialNumber.length()+1);
if(!FEBserialNumber.compare("noserial")) continue;
HAPDserialNumber = FEBserialNumber.substr(0,FEBserialNumber.find("/"));
FEBserialNumber.erase(0,FEBserialNumber.find("/")+1);
sprintf(hname,"hxy%d_0;1",HAPDnumber);
printf("%s \t %s \t %s \n",FEBserialNumber.c_str(),HAPDserialNumber.c_str(),hname);
 
//~ h = (TH3D *) gDirectory->Get(hname);
h = (TH3D *) CurrentDirectory->Get(hname);
 
/********** SMER MERITVE **********/
h->GetZaxis()->SetRange(1,1);
nx = h->GetNbinsX();
ny = h->GetNbinsY();
if (nx>=ny) direction = 0;
else direction = 1;
 
printf("Direction = %d\n", direction);
 
/********** CANVAS **********/
if (!direction) {
sprintf(buf,"%04d_%s_px",runNumber,HAPDserialNumber.c_str());
c = new TCanvas(buf,buf,0,0,1200,1200);
} else {
sprintf(buf,"%04d_%s_py",runNumber,HAPDserialNumber.c_str());
c = new TCanvas(buf,buf,0,0,1200,1200);
}
 
pad1 = new TPad("pad1","Title",0.05,0.965,0.95,0.99,0,0);
pad1->SetFillStyle(4000);
pad1->Draw();
 
pad2 = new TPad("pad2","Graphs",0.05,.05,.95,0.97,0,0);
pad2->SetFillStyle(4000);
pad2->Draw();
 
pad3 = new TPad("pad3","AxisTitle",0.57,0.03,0.92,0.0470,0,0);
pad3->SetFillStyle(4000);
pad3->Draw();
 
pad4 = new TPad("pad4","Lines",0.07,0.05,1,0.97,0,0);
pad4->SetFillStyle(4000);
pad4->Draw();
pad4->cd();
 
l = new TLine();
l->SetLineColor(kBlue);
l->DrawLineNDC(0,.5003,.085,.5003);
l->DrawLineNDC(0.84,.5003,.9,.5003);
l->DrawLineNDC(0.452,0,.452,0.992);
/********** PAD 1 **********/
pad1->cd();
info = new TPaveText(0.2,0,0.8,1,"ndc");
info->SetBorderSize(0);
info->SetFillColor(4000);
info->SetTextSize(0.8);
info->SetTextAlign(22);
sprintf(name,"%s, Nx: %d, Ny: %d", serialNumber, nx, ny);
info->AddText(name);
//info->Draw();
 
/********** PAD3 **********/
pad3->cd();
axisName = new TPaveText(0.2,0,0.8,1,"ndc");
axisName->SetBorderSize(0);
axisName->SetFillColor(4000);
axisName->SetTextSize(.7);
axisName->SetTextFont(vrstaPisave);
axisName->SetTextAlign(22);
sprintf(name,"Incident light position (mm)");
axisName->AddText(name);
axisName->Draw();
/********** PAD2 **********/
pad2->cd();
pad2->Divide(1,12,0,0);
 
for (int i=0;i<12;i++) {
if (!direction) {
pad2->cd(11 - i+1);
VirtualPad2[11 - i] = (TPad *)(pad2->cd(11 - i+1)); //Tole nastaviš zato, da lahko daš Log skalo
VirtualPad2[11 - i]->SetLogy(1);
//VirtualPad2[11 - i]->SetLeftMargin(.05);
//VirtualPad2[11 - i]->SetRightMargin(.05);
//VirtualPad2[11 - i]->SetGrid();
} else {
pad2->cd(i+1);
VirtualPad2[i] = (TPad *)(pad2->cd(11 - i+1)); //Tole nastaviš zato, da lahko daš Log skalo
VirtualPad2[i]->SetLogy(1);
//VirtualPad2[i]->SetLeftMargin(.05);
//VirtualPad2[i]->SetRightMargin(.05);
//VirtualPad2[i]->SetGrid();
}
for (int j=0;j<12;j++) {
if (!direction) h->GetZaxis()->SetRange(m.koordinatniSistem[j][i]+1,m.koordinatniSistem[j][i]+1);
else h->GetZaxis()->SetRange(m.koordinatniSistem[i][j]+1,m.koordinatniSistem[i][j]+1);
 
slice[j] = (TH2D *)h->Project3D("pyx");
 
if (!direction) {
sprintf(name,"PX: (%d,%d)",j,i);
p[j] = slice[j]->ProjectionX(name,i+1,i+1);
sprintf(name,"Projection X of row %d",i);
} else {
sprintf(name,"PY: (%d,%d)",i,j);
p[j] = slice[j]->ProjectionY(name,i+1,i+1);
sprintf(name,"Projection Y of column %d",i);
}
axis = p[j]->GetXaxis();
 
if(!direction) zamenjan[j] = new TH1D(name,p[j]->GetTitle(),axis->GetNbins(),-32.9,33.6);
else zamenjan[j] = new TH1D(name,p[j]->GetTitle(),axis->GetNbins(),-33.97,32.55);
 
for (int k = 0; k < axis->GetNbins(); k++) zamenjan[j]->SetBinContent(k+1,p[j]->GetBinContent(k+1));
 
if(!direction) VirtualPad2[11]->SetBottomMargin(.17);
else VirtualPad2[0]->SetBottomMargin(.17);
 
zamenjan[j]->SetLineWidth(2);
 
zamenjan[j]->SetTitle(name);
zamenjan[j]->SetTitleOffset(1.5);
 
zamenjan[j]->GetYaxis()->SetRangeUser(1,10000);
zamenjan[j]->GetYaxis()->SetTickLength(0.01);
zamenjan[j]->GetYaxis()->SetTitleFont(vrstaPisave);
zamenjan[j]->GetYaxis()->SetLabelFont(vrstaPisave);
zamenjan[j]->GetYaxis()->SetLabelSize(0.05);
zamenjan[j]->GetYaxis()->SetLabelColor(kBlack);
zamenjan[j]->GetYaxis()->SetTitle("Number of Events");
zamenjan[j]->GetYaxis()->SetNdivisions(0);
zamenjan[j]->GetYaxis()->CenterTitle();
zamenjan[j]->GetYaxis()->SetTitleSize(0.05);
zamenjan[j]->GetYaxis()->SetTitleOffset(.5);
zamenjan[j]->GetYaxis()->SetTitleColor(kWhite);
 
zamenjan[j]->GetXaxis()->SetTickLength(0.1);
zamenjan[j]->GetXaxis()->SetTitleFont(vrstaPisave);
zamenjan[j]->GetXaxis()->SetLabelFont(vrstaPisave);
zamenjan[j]->GetXaxis()->SetLabelSize(0.15);
zamenjan[j]->GetXaxis()->SetLabelColor(kBlack);
zamenjan[j]->GetXaxis()->SetLabelOffset(.05);
zamenjan[j]->GetXaxis()->SetTitle("Incident light position (mm)");
//zamenjan[j]->GetXaxis()->SetNdivisions(0);
//zamenjan[j]->GetXaxis()->CenterTitle();
zamenjan[j]->GetXaxis()->SetTitleSize(0.01);
zamenjan[j]->GetXaxis()->SetTitleColor(kWhite); //zato ker ga ne moreš pozicionirat
zamenjan[j]->GetXaxis()->SetTitleOffset(.5);
 
pNoise = noise(zamenjan[j]);
for (int k=1;k<=zamenjan[j]->GetSize();k++) zamenjan[j]->SetBinContent(k,zamenjan[j]->GetBinContent(k)-pNoise);
 
if (j<6) zamenjan[j]->SetLineColor(kWhite+color[j]);
else zamenjan[j]->SetLineColor(kWhite+color[j-6]);
zamenjan[j]->SetLineWidth(1);
if (j==0) zamenjan[j]->DrawCopy();
else zamenjan[j]->DrawCopy("SAME");
if (!direction) sprintf(text_for_STR, "Scan_1D_X_%s_i_%d_j_%d", HAPDserialNumber.c_str(),i,j);
else sprintf(text_for_STR, "Scan_1D_Y_%s_i_%d_j_%d", HAPDserialNumber.c_str(),i,j);
SaveToRootAddTH1DCopy(zamenjan[j], text_for_STR);
 
/*
//Comment the "zamenjan[j]" if you want to se scale in position steps! 1000 steps = 0.3959mm
p[j]->SetLineWidth(2);
 
p[j]->SetTitle("");
p[j]->SetTitleOffset(1.5);
 
p[j]->GetYaxis()->SetRangeUser(1,10000);
p[j]->GetYaxis()->SetTickLength(0.01);
p[j]->GetYaxis()->SetTitleFont(vrstaPisave);
p[j]->GetYaxis()->SetLabelFont(vrstaPisave);
p[j]->GetYaxis()->SetLabelSize(0.05);
p[j]->GetYaxis()->SetLabelColor(kBlack);
p[j]->GetYaxis()->SetTitle("Stevilo dogodkov");
p[j]->GetYaxis()->SetNdivisions(0);
p[j]->GetYaxis()->CenterTitle();
p[j]->GetYaxis()->SetTitleSize(0.05);
p[j]->GetYaxis()->SetTitleOffset(.5);
p[j]->GetYaxis()->SetTitleColor(kWhite);
 
p[j]->GetXaxis()->SetTickLength(0.1);
p[j]->GetXaxis()->SetTitleFont(vrstaPisave);
p[j]->GetXaxis()->SetLabelFont(vrstaPisave);
p[j]->GetXaxis()->SetLabelSize(0.15);
p[j]->GetXaxis()->SetLabelColor(kBlack);
p[j]->GetXaxis()->SetLabelOffset(.05);
p[j]->GetXaxis()->SetTitle("Pozicija vpadne svetlobe (korak mizice)");
//p[j]->GetXaxis()->SetNdivisions(0);
//p[j]->GetXaxis()->CenterTitle();
p[j]->GetXaxis()->SetTitleSize(0.01);
p[j]->GetXaxis()->SetTitleColor(kWhite); //zato ker ga ne moreš pozicionirat
p[j]->GetXaxis()->SetTitleOffset(.5);
 
pNoise = noise(p[j]);
for (int k=1;k<=p[j]->GetSize();k++) p[j]->SetBinContent(k,p[j]->GetBinContent(k)-pNoise);
 
if (j<6) p[j]->SetLineColor(kWhite+color[j]);
else p[j]->SetLineColor(kWhite+color[j-6]);
p[j]->SetLineWidth(1);
if (j==0) p[j]->DrawCopy();
else p[j]->DrawCopy("SAME");
*/
}
}
c->Modified();
c->Update();
 
sprintf(buf,"%04d_%s_linearScan",runNumber,HAPDserialNumber.c_str());
c2 = new TCanvas(buf,buf,0,0,2000,2000);
c2->cd();
c2pad2 = new TPad("c2pad2","c2pad2",0.125,0,.875,0.75,0,0);
c2pad2->Draw();
c2pad2->cd();
c->DrawClonePad();
c2->cd();
c2pad1 = new TPad("c2pad1","c2pad1",0.2,0.74,.8,1,0,0);
c2pad1->Draw();
c2pad1->cd();
c2pad1->SetRightMargin(.15);
c2pad1->SetLogz();
gStyle->SetTitleFontSize(0.07);
sprintf(buf,"hxy%d_sum_0",HAPDnumber);
//~ sum = (TH2D *) gDirectory->Get(buf);
sum = (TH2D *) CurrentDirectory->Get(buf);
if(!direction) sprintf(buf,"Scan in X direction");
else sprintf(buf,"Scan in Y direction");
sum->SetTitle(buf);
sum->GetZaxis()->SetRangeUser(1,10000);
sum->Draw("COLZ");
 
if (!direction) sprintf(text_for_STR, "Scan_2D_X_%s", HAPDserialNumber.c_str());
else sprintf(text_for_STR, "Scan_2D_Y_%s", HAPDserialNumber.c_str());
SaveToRootAddTH2DCopy(sum, text_for_STR);
 
if (save==1){
switch (direction) {
case 0: sprintf(pdfname,"../modules/%04d/%04d_%s_2_2DX.pdf",runNumber,runNumber,HAPDserialNumber.c_str());break;
case 1: sprintf(pdfname,"../modules/%04d/%04d_%s_3_2DY.pdf",runNumber,runNumber,HAPDserialNumber.c_str());break;
}
c->SaveAs(pdfname,"pdf");
} else if (save==2){
sprintf(pdfname,"../modules/%04d/%04d_%s.pdf",runNumber,runNumber,HAPDserialNumber.c_str());
/*switch (direction) {
case 0: sprintf(pdfname,"../modules/%04d/%04d_%s.pdf",runNumber,runNumber,HAPDserialNumber.c_str());break;
case 1: sprintf(pdfname,"../modules/%04d/%04d_%s.pdf)",runNumber,runNumber,HAPDserialNumber.c_str());break;
}*/
c2->SaveAs(pdfname,"pdf");
}
sprintf(text_for_STR,"../modules/%04d/%04d_%s_out.root",runNumber,runNumber,HAPDserialNumber.c_str());
SaveToRootWrite(text_for_STR, HAPDserialNumber.c_str());
}
 
return 0;
}
 
float noise(TH1D * proj) {
float nBin=proj->GetSize(); //ugotovi koliko binov je v histogramu
float wholeAverage=0; //sem da povprečje celotnega kanala
float noise=0; //sem da povprečn šum
int j=0;
for (int i=1;i<=nBin;i++) wholeAverage+=proj->GetBinContent(i)/nBin;
for (int i=1;i<=nBin;i++) {
if (proj->GetBinContent(i)<1.1*wholeAverage) {
noise+=proj->GetBinContent(i);
j++;
}
}
if(j!=0) return noise/j;
else return 0;
}
/cvi/apps/sa02_daq/analysis/projection.h
0,0 → 1,7
#ifndef PROJECTION_H_
#define PROJECTION_H_
 
int projection(int runNumber, int save = 0);
float noise(TH1D * proj);
 
#endif
/cvi/apps/sa02_daq/analysis/script.c
0,0 → 1,43
void script(int runNumber){
char path[0xFF];
TFile * data;
 
gROOT->ProcessLine(".L ./base.c+");
gROOT->ProcessLine(".L ./savetoroot.c+");
gROOT->ProcessLine(".L ./info.c+");
gROOT->ProcessLine(".L ./gain.c+");
gROOT->ProcessLine(".L ./treshold.c+");
gROOT->ProcessLine(".L ./projection.c+");
 
//~ char c; printf("Compilation complete, PRESS ENTER to continue..."); scanf("%c",&c);
 
gROOT->SetBatch(kTRUE);
info(runNumber, 2);
 
gain(runNumber, 2);
 
charge(runNumber, 2);
treshold(runNumber, 2);
 
sprintf(path,"../modules/%04d/%04d_2_2DX.root",runNumber,runNumber);
if (file_exists(path)){
data = new TFile(path); //Zvezno po X
projection(runNumber, 2);
delete data;
} else printf("File '%s' with continous scan in direction x does not exist.\n",path);
 
sprintf(path,"../modules/%04d/%04d_3_2DY.root",runNumber,runNumber);
if (file_exists(path)){
data = new TFile(path); //Zvezno po Y
projection(runNumber, 2);
delete data;
} else printf("File '%s' with continous scan in direction y does not exist.\n",path);
 
charge(runNumber, 4);
treshold(runNumber, 4);
 
gROOT->ProcessLine(".q");
}
/cvi/apps/sa02_daq/analysis/treshold.c
0,0 → 1,299
#include <stdio.h>
#include <stdlib.h>
 
#include <TROOT.h>
#include <TH1D.h>
#include <TH2D.h>
#include <TCanvas.h>
#include <TStyle.h>
#include <TSystem.h>
#include <TFile.h>
#include <TColor.h>
#include <TDirectory.h>
#include <TPaveText.h>
 
#include <iostream>
#include <string>
 
#include "base.h"
#include "treshold.h"
#include "savetoroot.h"
 
int treshold(int runNumber, int save){
 
int HAPDnumber; //Number of HAPD: 0, 1, 2 or 3!
 
char name[128];
char pdfname[128];
char buf[256];
 
const char * hname = "h2d_0";
 
sprintf(buf,"../modules/%04d/%04d_1_Treshold_Waveform.root",runNumber,runNumber);
TFile * data = new TFile(buf);
 
const char * serialNumber = getSN(runNumber);
printf("base.c return: %s\n", serialNumber);
/******* PREVERI ČE JE NALOŽEN FILE *******/
if (!strcmp(serialNumber, "NoFILE")){
printf("Ni naloženege datoteke\n");
return -1;
}
std::string serialNumberTemp = serialNumber;
std::cout << serialNumberTemp << std::endl;
std::string HAPDserialNumber,FEBserialNumber;
 
GRID m = mapping();
int vrstaPisave = 82;
 
TCanvas * c, * c4;
TH2D * h;
TH1D * p = NULL;
TH2D * h2 = NULL;
TPad * pad1, * pad2, * pad3;
TPaveText * sn, * gainTitle;
 
/*
TFile * out;
//----------- CREATE OUTPUT FILE
sprintf(buf,"../modules/%04d/%04d.root",runNumber,runNumber);
if (file_exists(buf)){
//out = new TFile(path,"UPDATE");
printf("File %s already exists. To create new, delete old.\n",buf);
return 1;
} else {
out = new TFile(buf,"RECREATE");
printf("Creating file %s\n",buf);
}
*/
 
 
/********** GLOBALNE **********/
gStyle->SetOptStat(0);
//gStyle->SetOptTitle(1);
gStyle->SetTextFont(vrstaPisave);
gStyle->SetTitleFont(vrstaPisave);
gStyle->SetTitleFontSize(0.1);
gStyle->SetNumberContours(100);
 
gStyle->SetPalette(55);
 
//gROOT->SetBatch(kTRUE); //Does not show canvases
 
 
/******* PREVERI ČE JE NALOŽEN FILE *******/
if (!strcmp(serialNumber, "NoFILE")){
printf("Ni naloženege datoteke\n");
return 0;
}
 
/******* ZRIHTA GRAFE *******/
for(HAPDnumber=0;HAPDnumber<4;HAPDnumber++){
 
if(save==2) {
SaveToRootInit();
}
//std::cout << serialNumberTemp << std::endl;
FEBserialNumber = serialNumberTemp.substr(0,serialNumberTemp.find(","));
serialNumberTemp.erase(0,FEBserialNumber.length()+1);
if(!FEBserialNumber.compare("noserial")) continue;
HAPDserialNumber = FEBserialNumber.substr(0,FEBserialNumber.find("/"));
FEBserialNumber.erase(0,FEBserialNumber.find("/")+1);
printf("%s \t %s \t %s \n",FEBserialNumber.c_str(),HAPDserialNumber.c_str(),hname);
 
sprintf(name,"%04d_%s_Treshold_c4",runNumber,HAPDserialNumber.c_str());
c4 = new TCanvas(name,name,0,0,1200,1200);
c4->Divide(2,2);
 
for (int chip=0;chip<4; chip++){
sprintf(name,"%04d_%s_Treshold_c%d",runNumber,HAPDserialNumber.c_str(),chip);
c = new TCanvas(name,name,0,0,1200,1200);
c->cd();
pad1 = new TPad("pad11","SN",0,0.975,1,1,0,0);
pad1->SetFillStyle(4000);
pad1->Draw();
pad1->cd();
sn = new TPaveText(0.2,0,0.8,1,"ndc");
sn->SetBorderSize(0);
sn->SetFillColor(4000);
sn->SetTextSize(.8);
sn->SetTextAlign(22);
sprintf(buf,"%s (treshold scan)",HAPDserialNumber.c_str());
sn->AddText(buf);
//sn->Draw();
 
/******* DRUGI PAD *******/
c->cd();
pad2 = new TPad("pad2","Date",0.05,0.95,0.95,0.99,0,0);
pad2->SetFillStyle(4000);
pad2->Draw();
pad2->cd();
gainTitle = new TPaveText(0,0,1,1,"ndc");
gainTitle->SetBorderSize(0);
gainTitle->SetFillColor(kSpring+1);
gainTitle->SetTextSize(.6);
gainTitle->SetTextAlign(22);
sprintf(buf,"Treshold scan over center of channels:");
switch(chip){
case 0: sprintf(buf,"%s Chip A",buf);break;
case 1: sprintf(buf,"%s Chip B",buf);break;
case 2: sprintf(buf,"%s Chip D",buf);break;
case 3: sprintf(buf,"%s Chip C",buf);break;
}
gainTitle->AddText(buf);
gainTitle->Draw();
 
//----------- PAD 2 (FIGURES)
c->cd();
pad3 = new TPad("pad2","Figures",0,0,1,0.96,0,0);
pad3->SetFillStyle(4000);
pad3->Draw();
pad3->cd();
pad3->Divide(6,6,0,0,0);
for (int i=0;i<36;i++) {
int idx = i+chip*36;
sprintf(name,"%s;%d",hname,m.pozicijaPixla[idx]+1);
h = (TH2D *) data->Get(name);
 
TVirtualPad * pad = pad3->cd(m.pozicijaPixlaNaCipu[idx]+1);
pad->SetBorderSize(0);
pad->SetBorderMode(0);
 
if (h){
sprintf(name,"HAPD%d ASIC %d ch %d",HAPDnumber,chip,idx);
p = h->ProjectionY(name,idx+HAPDnumber*144+1,idx+HAPDnumber*144+1);
p->SetTitle(name);
p->SetStats(kFALSE);
p->SetFillColor(kBlue);
p->SetMinimum(-0.1);
p->DrawCopy("AH");
if(save==2) {
sprintf(text_for_STR, "Threshold_1D_%s_ASIC_%d_CH_%d", HAPDserialNumber.c_str(),chip,idx);
SaveToRootAddTH1DCopy(p, text_for_STR);
}
if (idx==0 && h->InheritsFrom("TH2D")) {
sprintf(name,"%s_2d",p->GetName());
TAxis * axis = p->GetXaxis();
h2 = new TH2D(name,p->GetTitle(),144,-0.5,143.5,axis->GetNbins(),
axis->GetXmin(),
axis->GetXmax() );
h2->SetTitle("HAPD Treshold scan");
h2->GetXaxis()->SetTitle("HAPD 2d channels");
h2->GetYaxis()->SetTitle("Treshold");
h2->GetYaxis()->SetTitleOffset(1.4);
}
if (h2){
for (int k=0;k<p->GetNbinsX();k++){
if ((int)p->GetBinContent(k+1)==0) h2->SetBinContent(idx+1,k+1,1);
else h2->SetBinContent(idx+1,k+1,p->GetBinContent(k+1));
}
}
} else printf("TH2D %s does not exist !!!!\n",name);
}
c->Modified();
c->Update();
if(chip%2==0) c4->cd(chip+2);
else c4->cd(chip);
c->DrawClonePad();
//c->Write();
if (save==1){
switch (chip) {
case 0: sprintf(pdfname,"../modules/%04d/%04d_%s_1_Treshold.pdf(",runNumber,runNumber,HAPDserialNumber.c_str());break;
default: sprintf(pdfname,"../modules/%04d/%04d_%s_1_Treshold.pdf",runNumber,runNumber,HAPDserialNumber.c_str());break;
}
c->SaveAs(pdfname,"pdf");
} else if (save==3){
sprintf(pdfname,"../modules/%04d/%04d_%s.pdf",runNumber,runNumber,HAPDserialNumber.c_str());
c->SaveAs(pdfname,"pdf");
} else if (save==4){
if(chip==3) sprintf(pdfname,"../modules/%04d/%04d_%s.pdf)",runNumber,runNumber,HAPDserialNumber.c_str());
else sprintf(pdfname,"../modules/%04d/%04d_%s.pdf",runNumber,runNumber,HAPDserialNumber.c_str());
c->SaveAs(pdfname,"pdf");
}
}
if (h2) {
sprintf(name,"%04d_%s_Treshold_c%d",runNumber,HAPDserialNumber.c_str(),5);
c = new TCanvas(name,name,600,500);
c->SetRightMargin(0.15);
c->SetLeftMargin(0.15);
c->SetLogz();
 
sprintf(buf,"Treshold scan over the center of channels");
 
h2->SetTitle(buf);
gStyle->SetTitleFontSize(0.05);
h2->SetTitleFont(vrstaPisave);
 
h2->GetZaxis()->SetRangeUser(1,10000);
h2->GetZaxis()->SetTickLength(.02);
h2->GetZaxis()->SetLabelFont(vrstaPisave);
h2->GetZaxis()->SetLabelSize(0.03);
 
h2->GetYaxis()->SetRangeUser(500,700);
h2->GetYaxis()->SetTitleFont(vrstaPisave);
h2->GetYaxis()->SetLabelFont(vrstaPisave);
//h2->GetYaxis()->SetLabelSize(0.04);
h2->GetYaxis()->SetLabelColor(kBlack);
//h2->GetYaxis()->SetNdivisions(12);
h2->GetYaxis()->CenterTitle();
h2->GetYaxis()->SetTitle("Treshold");
//h2->GetYaxis()->SetTitleSize(0.05);
h2->GetYaxis()->SetTitleOffset(1.5);
h2->GetYaxis()->SetTitleColor(kBlack);
 
//h2->GetXaxis()->SetTickLength(0.05);
h2->GetXaxis()->SetTitleFont(vrstaPisave);
h2->GetXaxis()->SetLabelFont(vrstaPisave);
//h2->GetXaxis()->SetLabelSize(0.04);
h2->GetXaxis()->SetLabelColor(kBlack);
//h2->GetXaxis()->SetLabelOffset(.05);
//h2->GetXaxis()->SetNdivisions(0);
//h2->GetXaxis()->CenterTitle();
h2->GetXaxis()->SetTitle("Channel");
//h2->GetXaxis()->SetTitleSize(0.05);
h2->GetXaxis()->SetTitleColor(kBlack); //zato ker ga ne moreš pozicionirat
h2->GetXaxis()->SetTitleOffset(1.2);
 
 
h2->SetStats(kFALSE);
h2->DrawCopy("COLZ");
if(save==2) {
sprintf(text_for_STR, "Threshold_2D_%s", HAPDserialNumber.c_str());
SaveToRootAddTH2DCopy(h2, text_for_STR);
}
c->Modified();
c->Update();
//c->Write();
if (save==1){
sprintf(pdfname,"../modules/%04d/%04d_%s_1_Treshold.pdf",runNumber,runNumber,HAPDserialNumber.c_str());
c4->SaveAs(pdfname,"pdf");
sprintf(pdfname,"../modules/%04d/%04d_%s_1_Treshold.pdf)",runNumber,runNumber,HAPDserialNumber.c_str());
c->SaveAs(pdfname,"pdf");
} else if (save==2){
sprintf(pdfname,"../modules/%04d/%04d_%s.pdf",runNumber,runNumber,HAPDserialNumber.c_str());
c4->SaveAs(pdfname,"pdf");
c->SaveAs(pdfname,"pdf");
} else if (save==3){
sprintf(pdfname,"../modules/%04d/%04d_%s.pdf",runNumber,runNumber,HAPDserialNumber.c_str());
c4->SaveAs(pdfname,"pdf");
sprintf(pdfname,"../modules/%04d/%04d_%s.pdf)",runNumber,runNumber,HAPDserialNumber.c_str());
c->SaveAs(pdfname,"pdf");
}
if(save==2) {
sprintf(text_for_STR,"../modules/%04d/%04d_%s_out.root",runNumber,runNumber,HAPDserialNumber.c_str());
SaveToRootWrite(text_for_STR, HAPDserialNumber.c_str());
}
}
}
delete data;
//out->Close();
return 0;
}
/cvi/apps/sa02_daq/analysis/treshold.h
0,0 → 1,6
#ifndef TRESHOLD_H_
#define TRESHOLD_H_
 
int treshold(int runNumber, int save = 0);
 
#endif
/cvi/apps/sa02_daq/cvi/CAEN_V729/CAEN_V729.c
0,0 → 1,1000
//
// test.c
//
// Description : test program for V729
//
// Author : S. Korpar
// Date : 2005/07/15
// adapted to CAEN V1719 by R. Pestotnik 2012/09/07
 
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
 
 
 
#ifdef _CVI_
# include <windows.h>
# include "CAEN_V729_CVI.h"
# include "asynctmr.h"
# include "H1D.h"
# include "H2D.h"
# include "HDraw.h"
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef short int16_t;
typedef unsigned short uint16_t;
typedef int int32_t;
typedef unsigned int uint32_t;
# include <utility.h>
# define usleep(x) Delay(x*1e-3)
#include "sa02lib.h"
#define printf sa02Printf
# else _CVI_
# include <unistd.h>
# include <ctype.h>
# include <vector>
# include <sys/time.h>
# include <sys/stat.h>
# include <signal.h>
# include <string>
#endif _CVI_
 
 
#include "vme.h"
#include "CAEN_V729_DEF.h"
#include "CAEN_V729.h"
#include "dataio.h"
 
//#include <utility.h>
CAEN_V729_PARAM CAEN_V729_param;
 
#define IREG_OFFSET 0x2000
#define V729_WAIT 100
 
 
#define TRUE 1
#define FALSE 0
 
uint32_t V729_module=0;
 
 
static int g_timerId = 0;
 
#ifdef V729_MAIN
int ctrl_c=0;
# else V729_MAIN
# ifdef V729_WINMAIN
int ctrl_c=0;
# else V729_WINMAIN
extern int ctrl_c;
# endif V729_WINMAIN
#endif V729_MAIN
 
#ifndef WIN32
struct sigaction oact;
#endif WIN32
//---------------------------------------------------------
 
 
//---------------------------------------------------------
DefineThreadSafeScalarVar (int, TimerOut,0);
 
 
void timerast (int signumber) {
 
}
 
//---------------------------------------------------------
 
int CVICALLBACK TimerOutCallback (int reserved, int theTimerId, int event,
void *callbackData, int eventData1,
int eventData2) {
double currentTime = 0.0;
double deltaTime = 0.0;
int id;
/* Like a regular UI timer, the async. timer's callback is passed the */
/* total elapsed time and the time since the last tick. */
if ((double*)eventData1)
currentTime = *((double*)eventData1);
if ((double*)eventData2)
deltaTime = *((double*)eventData2);
if (event == EVENT_TIMER_TICK) {
SetTimerOut(TRUE);
id= *((int *)callbackData);
fprintf(stdout,"TIMEOUT %d !!!\n", id );
 
}
/* We will get an EVENT_DISCARD when the timer is destroyed. */
if (event == EVENT_DISCARD)
g_timerId = 0;
return 0;
}
 
int g_tmlnk;
void tmlnk (int tout) {
 
//timer_out=0;
#ifdef _CVI_
g_tmlnk = tout;
SetTimerOut(FALSE);
g_timerId = NewAsyncTimer (((double)tout) *10./ 1000.0, 1, 1, TimerOutCallback, &g_tmlnk);
# else _CVI_
 
struct sigaction act;
struct itimerval tdelay;
 
act.sa_handler = timerast;
sigemptyset (&act.sa_mask);
act.sa_flags = 0;
 
tdelay.it_value.tv_sec = tout / 100;
tdelay.it_value.tv_usec = 10000 * (tout % 100);
tdelay.it_interval.tv_sec = 0;
tdelay.it_interval.tv_usec = 0;
 
if (sigaction (SIGALRM, &act, &oact) < 0) {
perror ("sigaction(tmlnk)");
exit (EXIT_FAILURE);
}
if (setitimer (ITIMER_REAL, &tdelay, NULL) < 0) {
perror ("setitimer(tmlnk)");
exit (EXIT_FAILURE);
}
 
#endif _CVI_
}
 
//---------------------------------------------------------
void tmulk ( void ){
#ifdef _CVI_
DiscardAsyncTimer( g_timerId );
# else _CVI_
struct itimerval tdelay;
 
tdelay.it_value.tv_sec = 0;
tdelay.it_value.tv_usec = 0;
tdelay.it_interval.tv_sec = 0;
tdelay.it_interval.tv_usec = 0;
 
if (setitimer (ITIMER_REAL, &tdelay, NULL) < 0) {
perror ("setitimer(tmulk)");
exit (EXIT_FAILURE);
}
if (sigaction (SIGALRM, &oact, NULL) < 0) {
perror ("sigaction(tmulk)");
exit (EXIT_FAILURE);
}
#endif _CVI_
}
 
//---------------------------------------------------------
int wait_while (int num) {
int i, tmp = 0;
 
for ( i =0; i <num; i++ ) tmp = 0;
return tmp;
}
 
//---------------------------------------------------------
 
 
void V729_map( uint32_t addr) {
V729_module = addr;
return;
}
//---------------------------------------------------------
int V729_status( void ){
uint32_t status;
VME_A24D16_R(V729_module+V729_CSR, &status);
return status;
}
//---------------------------------------------------------
void V729_info(FILE *kam) {
uint32_t code, mid, ver;
 
 
VME_A24D16_R(V729_module+0xFA,&code);
VME_A24D16_R(V729_module+0xFC,&mid);
VME_A24D16_R(V729_module+0xFE,&ver);
printf( "code/mid/ver = 0x%04X/0x%04X/0x%04X\n", code, mid, ver);
printf( "Fixed code (0xFAF5) = 0x%04X\n", code);
printf( "Manufacturer/Type = 0x%02X/0x%03X\n",
(mid & 0xFC00)>>10, mid & 0x3FF);
printf( "Version/Serial = %d/%d\n",
(ver & 0xF000)>>12, ver & 0xFFF);
return;
}
 
 
//---------------------------------------------------------
void V729_reg( uint32_t val) {
uint32_t push=0;
 
VME_A24D16_W(V729_module+V729_FSR, val);
VME_A24D16_W(V729_module+V729_UFSR, push); //push
usleep(V729_WAIT);
 
}
 
 
//---------------------------------------------------------
void V729_reset(int nall,int nbefore,int obae,int obaf) {
uint32_t cbl;
uint32_t val=0;
// cbl=4096+12-100;
cbl=4096+12-nbefore;
 
VME_A24D16_W(V729_module+V729_RR, val); // reset
printf("nbefore=%d\t", nbefore);
printf("nall=%d\t", nall);
printf("obae=%d\t", obae);
printf("obaf=%d\n", obaf);
 
// set AE
V729_reg( (obae & 0xFF)<<8 );//
V729_reg( (obae & 0xF00) ); //
 
printf("CSR = 0x%x\n", V729_status() );
// set AF and CBL
V729_reg( ((obaf & 0xFF)<<8) + (cbl & 0xFF) );
V729_reg( (obaf & 0xF00) + ((cbl & 0xF00)>>8) );
 
 
 
VME_A24D16_W(V729_module+V729_SR,nall); //total number of samples
 
return;
}
//---------------------------------------------------------
 
void V729_set_bias(int range, int bias1, int bias2) {
int i;
uint32_t bias;
 
switch (range) {
case 0: //User
for (i=0x18; i<0x27; i+=4) {
VME_A24D16_W(V729_module+i, bias1); //bias
usleep(V729_WAIT);
VME_A24D16_W(V729_module+i+2, bias2); //bias
usleep(V729_WAIT);
}
printf("Bias + %x - %x\n", bias1, bias2);
break;
case 1: //Single Ended +
for (i=0x18; i<0x27; i+=4) {
bias = 0xCC;
VME_A24D16_W(V729_module+i, bias); //bias
usleep(V729_WAIT);
bias =0x733;
VME_A24D16_W(V729_module+i+2, bias); //bias
usleep(V729_WAIT);
}
break;
case 2: //Single Ended -
for (i=0x18; i<0x27; i+=4) {
bias =0x733;
VME_A24D16_W(V729_module+i, bias); //bias
usleep(V729_WAIT);
bias= 0xD99 ;
VME_A24D16_W(V729_module+i+2, bias); //bias
usleep(V729_WAIT);
}
break;
case 4: //Differential Unipolar
for (i=0x18; i<0x27; i+=4) {
bias = 0x400;
VME_A24D16_W(V729_module+i,bias); //bias
usleep(V729_WAIT);
bias = 0xA66;
VME_A24D16_W(V729_module+i+2, bias); //bias
usleep(V729_WAIT);
}
break;
case 3: //Single Ended Bipolar
case 5: //Differential Bipolar
default:
for (i=0x18; i<0x27; i+=2) {
bias=0x733;
VME_A24D16_W(V729_module+i, bias); //bias
usleep(V729_WAIT);
}
break;
}
return;
}
 
//---------------------------------------------------------
void V729_aquisition_mode(uint32_t mode) { // mode 0 aqusition mode, 0x30 buffers programming
#ifdef V729_DEBUG
int status;
VME_A24D16_R(V729_module+V729_CSR, &status);
usleep(V729_WAIT);
fprintf(stderr, "V729_CSR 0x0E = 0x%04X\n", status);
#endif V729_DEBUG
 
VME_A24D16_W(V729_module+V729_CSR, mode); //aquisition mode
usleep(V729_WAIT);
#ifdef V729_DEBUG
fprintf(stderr, "V729_CSR 0x0E = 0x%04X\n", mode);
VME_A24D16_R(V729_module+V729_CSR, &status);
usleep(V729_WAIT);
fprintf(stderr, "V729_CSR 0x0E = 0x%04X\n", status);
#endif V729_DEBUG
return;
}
 
//---------------------------------------------------------
void V729_soft_stop( void ){
uint32_t sw=1;
VME_A24D16_W(V729_module+V729_SSR,sw);
// usleep(V729_WAIT);
sw =0;
VME_A24D16_W(V729_module+V729_OBR1,sw);
// usleep(V729_WAIT);
return;
}
 
//---------------------------------------------------------
void V729_clear_buffer( void ){
uint32_t data1,data2;
const int tout=100; /* 1/100 of a second */
int cnt=0;
tmlnk (tout);
 
do {
VME_A24D32_R(V729_module+V729_OBR1, &data1);
 
if (ctrl_c|| GetTimerOut()) break;
 
 
cnt++;
} while (data1 & (0x3<<29));
 
cnt=0;
do {
VME_A24D32_R(V729_module+V729_OBR2, &data2);
 
if (ctrl_c|| GetTimerOut()) break;
 
cnt++;
} while (data2 & (0x3<<29));
 
tmulk();
return;
}
 
void V729_get_buffer(uint32_t *data1, uint32_t *data2) {
VME_A24D32_R(V729_module+V729_OBR1, data1);
// usleep(V729_WAIT);
VME_A24D32_R(V729_module+V729_OBR2, data2);
// usleep(V729_WAIT);
return;
}
 
 
 
//---------------------------------------------------------
void V729_init(uint32_t addr, int nall, int cbl, uint32_t bias1, uint32_t bias2) {
V729_map(addr);
V729_info(stderr);
//V729_reset(nall,cbl,nall,0x1); // obaf = 1, disable start signals when there is at least one sample in the buffer
V729_reset(nall,cbl,nall,4000); // obaf = 1, disable start signals when there is at least one sample in the buffer
V729_set_bias(0,bias1,bias2);
V729_aquisition_mode(0);
#ifndef WIN32
CAENVME_SetFIFOMode(udev,1);
sleep(1);
#endif WIN32
}
 
 
//---------------------------------------------------------
int V729_blt=0;
int V729_SetBltMode(int mode) {
V729_blt = mode;
return mode;
}
 
int V729_event(int mask, int nall, uint32_t *data,uint32_t *data1,uint32_t *data2) {
uint32_t status;
const int tout=200; /* 1/100 of a second */
int nb=0;
int count=0;
int i;
tmlnk (tout);
 
 
//status= 0x80 ; VME_A16D16_W(IREG_OFFSET+0x8,&status); // pulse ch 8
//status = 0x1a ; VME_A16D16_W(IREG_OFFSET+0xC,&status); // clr1 enable1 .... clear busy1 flag // KEK magnet
//
do {
 
VME_A24D16_R(V729_module+V729_CSR, &status);
 
count++;
if (ctrl_c || GetTimerOut()) {
tmulk ();
printf("[%d] daq=%x status %x AE01=%d AE23=%d Waiting for DATA TRG bit... at line %d\n",count , (status>>4)&0x3,status, status&0x1,(status>>2)&0x1 , __LINE__);
 
V729_clear_buffer();
 
return -1;
}
 
} while ((status & 0x5) ^ 0x5);
tmulk ();
//count = (nall+5);
count = (nall+1);
if (V729_blt) {
 
//#ifdef CAEN_V1718
// VME_A24D32_FIFOBLTR(V729_module+V729_OBR1,data1,count*sizeof(uint32_t),&nb);
// VME_A24D32_FIFOBLTR(V729_module+V729_OBR2,data2,count *sizeof(uint32_t),&nb);
//#endif CAEN_V1718
for (i=0; i<count; i++) {
data[2*i] = data1[i];
data[2*i+1] = data2[i];
}
nb*=2;
} else {
int nc=0;
int j=0;
VME_MRRST(); // MultiReadReset
 
do {
VME_R(VME_A24,VME_D32,V729_module+V729_OBR1, &data[nc]);
} while ( !((data[nc]>>31)&0x1) );
nc++;
do {
VME_R(VME_A24,VME_D32,V729_module+V729_OBR2, &data[nc]);
} while ( !((data[nc]>>31)&0x1) );
nc++;
for (i=0; i<nall; i++) {
//if (mask & 0x3)
VME_MR(VME_A24,VME_D32,V729_module+V729_OBR1, &data[nc++]);
//if (mask & 0xc)
VME_MR(VME_A24,VME_D32,V729_module+V729_OBR2, &data[nc++]);
}
j = nc;
if ( VME_GetInterface()!= WIENER_VMEMM ) j = VME_MREXEC(data); // MultiReadExecute
 
nb=j*sizeof(uint32_t);
 
}
 
return nb;
}
int V729_plothandle;
//---------------------------------------------------------
int V729_plot(int first, uint16_t *buf ) {
#ifdef _CVI_
int start=23;
int end=35;
 
//const double maxy=2048;
const double maxy=512;
const double maxx=512;
//const double maxy=2048;
//const double maxy=128;
//const double maxy=512;
const int nx=500;
 
const int ny=100;
const int h0=10;
 
int i;
uint32_t *hdr = (uint32_t *)buf;
int nb= hdr[1]-2*sizeof(uint32_t);
int nitems = nb /sizeof(uint16_t);
unsigned int recid=hdr[0];
uint16_t *data = &buf[4];
double x,y;
double baseline=0;
double charge=0;
 
 
while (nitems>0) {
int id = data[0]-1;
int len= data[1]/sizeof(uint16_t)-2;
 
if (CAEN_V729_param.verbose) printf("\t->> recid=%d nb=%d nitems=%d id=%d len=%d\n", recid, hdr[1],nitems,id,len);
if (id>3) return 0;
 
data+=2;
 
if (first) {
for (i=0; i<4; i++) {
char hname[0xFF];
char htitle[0xFF];
sprintf (hname,"hwf%d",i);
sprintf (htitle,"CAEN V729 ch%d",i);
H2DInit(h0+i,hname, htitle ,len,-0.5,1,ny,-maxy,2*maxy/ny);
H2DSetTitleX(h0+i,"timebin");
H2DSetTitleY(h0+i,"pulse height");
 
sprintf (hname,"hcharge%d",i);
sprintf (htitle,"CAEN V729 ch%d",i);
H1DInit(h0+i,hname, htitle ,nx,-maxx,2*maxx/nx);
H1DSetTitleX(h0+i,"timebin");
H1DSetTitleY(h0+i,"charge");
}
first=0;
// h1d=new TH1F("h1d","Charge;signal charge(a.u.);N",500,-maxy,5*maxy);
 
}
 
baseline=0;
for (i=0; i<20; i++) baseline += data[i];
baseline /=20.;
// baseline=2000;
 
 
for (i=0; i<len; i++) {
if (CAEN_V729_param.verbose >2) printf("ADC %d %d\n", i, data[i]);
x=i;
y=data[i];
y-=baseline;
if (i>=start && i<end) charge += y;
 
H2DFill(h0+id,x,y,1);
}
charge /=(end-start);
H1DFill(h0+id,charge,1);
 
data+=len;
nitems=nitems - len-2;
//if (id==2) h1d->Fill(charge);
}
#else
#warning _CVI_ is not defined
#endif _CVI_
return 0;
}
 
//---------------------------------------------------------
int V729_decode(uint32_t mask, int nall, uint32_t *data, uint16_t *dadc, int debug) {
 
int hdrlen=6; // 4+2
uint16_t *adc[4]= {0};
int i,j;
 
int nc=0;
int narrays=0;
 
 
int indx[4] = {0,0,0,0};
int shft[4] = {0,0,0,0};
int ashft[4]= {0,0,0,0};
int nmask=0;
 
for (i=0; i<4; i++) {
adc[i] = &dadc[hdrlen+i*(nall+2)];
// printf("---->ID %d len %d ,%d\n",dadc[hdrlen+i*(nall-2)],dadc[hdrlen+i*(nall-1)],hdrlen+i*(nall+2)) ;
}
if (mask & 0x3) narrays++;
if (mask & 0xc) narrays++;
 
for (i=0; i<4; i++) if (mask & (1<<i) ) {
indx[nmask] = i;
shft[nmask] = (i%2)*12;
if (( (mask & 0x3) > 0 ) && (i>1)) ashft[nmask]=1;
else ashft[nmask]=0;
nmask++;
}
for (j=0; j<nmask; j++) {
nc=0;
for (i=0; i<nall+1; i++) {
int ii=narrays*i+ashft[j];
 
uint32_t data1 = data[ii];
 
if (data1 & (1<<31)) {
if (debug)
fprintf(stdout,"data1: empty flags: 0x%X, time tag: 0x%06X %d\n", (data1>>29) & 0x3, data1 & 0xFFFFFF, data1 & 0xFFFFFF);
} else if ((data1>>29) & 0x3) {
if (nc<nall) {
adc[j][nc] = (data1>>shft[j]) & 0xFFF;
if (debug >2) printf("[%d/%d] ADC%d adc0=%d\n", i,nc,indx[j], adc[j][nc]);
nc++;
}
 
} else {
if (debug) fprintf(stdout,"Data(%4d) %d indx=%d %d nc=%d(%d) %d 0x%08X\n", i, indx[j],narrays*i+ashft[j],j,nc,nmask,narrays, data1);
}
}
}
return nc;
}
 
//---------------------------------------------------------
void V729_Usage(void) {
 
printf ("*********************************************************************************:\n");
printf ("Usage: CAEN_V729 <arguments> ......... CAEN V729A data aquisition:\n\n");
printf ("Arguments: \n");
printf ("-d <debuglevel> \n");
printf ("-b <bias+> \n");
printf ("-e <bias-> \n");
printf ("-a <VME address> \n");
printf ("-c <n samples before stop> \n");
printf ("-n <number of events> \n");
printf ("-l <nall> number of samples \n");
printf ("-m <channel mask: 4bits (1 bit/ch)> \n");
printf ("-o <output file name> \n");
 
printf ("*********************************************************************************:\n");
}
//---------------------------------------------------------
// test program
 
int V729_GetParams(int argc,char **argv) {
#ifdef _CVI_
int p = CAEN_V729_param.panel;
GetCtrlVal(p,P4_MASK,&CAEN_V729_param.mask);
GetCtrlVal(p,P4_CBL ,&CAEN_V729_param.cbl);
GetCtrlVal(p,P4_NALL,&CAEN_V729_param.nall);
GetCtrlVal(p,P4_FILENAME,CAEN_V729_param.filename);
GetCtrlVal(p,P4_VERBOSE,&CAEN_V729_param.verbose);
GetCtrlVal(p,P4_NEVE,&CAEN_V729_param.neve);
GetCtrlVal(p,P4_ADDR,&CAEN_V729_param.addr);
GetCtrlVal(p,P4_BIAS1,&CAEN_V729_param.bias1);
GetCtrlVal(p,P4_BIAS2,&CAEN_V729_param.bias2);
GetCtrlVal(p,P4_FRACTION,&CAEN_V729_param.fraction);
 
# else _CVI_
CAEN_V729_param.mask=0xF;
CAEN_V729_param.cbl=13;
CAEN_V729_param.nall=1330;
CAEN_V729_param.filename= 0;
CAEN_V729_param.verbose = 0;
CAEN_V729_param.neve = 1;
CAEN_V729_param.addr = V729_OFFSET;
CAEN_V729_param.bias1 = 0x500; // vecje vrednosti povzrocajo tezave in zacno kanali oscilirat ....
CAEN_V729_param.bias2 = 0x500;
CAEN_V729_param.append = 0;
CAEN_V729_param.fp = NULL;
CAEN_V729_param.fraction = 0;
int c=0;
while ((c = getopt (argc, argv, "b:e:a:d:c:l:n:o:m:f:r:")) != -1)
switch (c) {
case 'd':
CAEN_V729_param.verbose=atoi(optarg);
break;
case 'c':
CAEN_V729_param.cbl=atoi(optarg);
break;
case 'l':
CAEN_V729_param.nall=atoi(optarg);
 
if (CAEN_V729_param.nall%16) {
printf ("buffer length should be multiple of 16 , modulo = %d\n",CAEN_V729_param.nall%16);
// exit(-1);
}
break;
case 'n':
CAEN_V729_param.neve=atoi(optarg);
break;
case 'r':
CAEN_V729_param.fraction=atof(optarg);
break;
case 'a':
CAEN_V729_param.addr=strtoul (optarg,NULL,0);
break; // address
case 'b':
CAEN_V729_param.bias1=strtoul (optarg,NULL,0);
break; // bias
case 'e':
CAEN_V729_param.bias2=strtoul (optarg,NULL,0);
break; // bias
 
case 'm':
CAEN_V729_param.mask=strtoul (optarg,NULL,0);
break; // mask
case 'o':
sprintf(CAEN_V729_param.filename,"%s", optarg );
CAEN_V729_param.append=0;
break; // output
case 'f':
sprintf(CAEN_V729_param.filename,"%s", optarg );
CAEN_V729_param.append=1;
break; // output
}
#endif _CVI_
return 0;
}
 
int V729_LoadPanel (int Parent_Panel_Handle, char Filename[], int Panel_Resource_ID) {
 
CAEN_V729_param.panel = LoadPanel(Parent_Panel_Handle, Filename, Panel_Resource_ID);
return CAEN_V729_param.panel;
}
 
 
 
#ifdef _CVI_
int CVICALLBACK HDrawCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
int ch=0,type=0;
switch (event) {
case EVENT_COMMIT:
GetCtrlVal(CAEN_V729_param.panel,P4_ADCCH, &ch);
GetCtrlVal(CAEN_V729_param.panel,P4_HDISPLAY, &type);
if (type) {
H2DDraw(10+ch,CAEN_V729_param.panel,P4_GRAPH, &V729_plothandle);
} else {
H1DDraw(10+ch,CAEN_V729_param.panel,P4_GRAPH, &V729_plothandle);
}
break;
}
return 0;
}
 
int CVICALLBACK V729_daq(void *functionData) {
return V729_main ( 0, NULL);
}
#endif _CVI_
 
void CatchSig (int i) {
ctrl_c = 1;
}
 
int p4h;
 
int V729_SetFilePointer (FILE *fp) {
CAEN_V729_param.fp = fp;
return 0;
}
 
int V729_main (int argc,char **argv) {
int hdrlen=4; // number of u16 words
FILE *fp=NULL;
int output=0;
int bsize;
int nmask,imask;
int i,ch, len,nb;
int adclen;
uint32_t *data , *data1 ,*data2 ;
uint16_t *adc ;
uint32_t *evhdr;
int ncount =0;
int nerrors=0;
int nball =0;
 
 
// reset timers
time_t t,told=0, tstart;
time(&t);
tstart=t;
InitializeTimerOut();
printf("V729_main \n");
V729_GetParams(argc,argv);
// open file
if (CAEN_V729_param.fp !=NULL) {
fp= CAEN_V729_param.fp;
output=2;
printf("V729_main Data file is already opened\n");
} else {
if (strlen(CAEN_V729_param.filename)>0) {
if (CAEN_V729_param.verbose) printf("Data in the file:%s\n", CAEN_V729_param.filename);
if (CAEN_V729_param.append) fp=fopen(CAEN_V729_param.filename,"a");
else fp=fopen(CAEN_V729_param.filename,"w");
output=1;
}
}
 
 
// allocate storage
 
bsize = sizeof(uint32_t)*2*(CAEN_V729_param.nall+1);
data = (uint32_t *)malloc(bsize);
data1 = (uint32_t *)malloc(bsize);
data2 = (uint32_t *)malloc(bsize);
nmask=0;
for (i=0; i<4; i++) if (CAEN_V729_param.mask & (1<<i)) nmask++;
adclen = CAEN_V729_param.nall+2;
len = nmask* adclen+hdrlen;
adc = (uint16_t *) malloc(len *sizeof(uint16_t)); // 4 channels + 4 ch header + 1 event hdr
 
// write headers
evhdr = (uint32_t *) &adc[0];
evhdr[0] = CAENV729REC_ID;
evhdr[1] = len *sizeof(uint16_t);
imask=0;
for (ch=0; ch<4; ch++) {
if ( CAEN_V729_param.mask & (1<<ch) ) {
uint16_t *chhdr= &adc[hdrlen+imask*adclen];
chhdr[0] = (uint16_t) ch+1;
chhdr[1] = (uint16_t) adclen * sizeof(uint16_t);
//printf("========>%d %d [%d,%d,%d]hdr=%d %d\n",ch, hdrlen+imask*adclen,hdrlen,imask,adclen,chhdr[0],chhdr[1]);
imask++;
 
}
}
 
// start
 
 
// open VME and initialize board
 
V729_init(CAEN_V729_param.addr, CAEN_V729_param.nall, CAEN_V729_param.cbl, CAEN_V729_param.bias1,CAEN_V729_param.bias2);
 
// event loop
for (i=0; i<CAEN_V729_param.neve; i++) {
GetCtrlVal(CAEN_V729_param.panel,P4_VERBOSE,&CAEN_V729_param.verbose);
if ( CAEN_V729_param.verbose) printf("neve=%d\n",i);
nb = V729_event(CAEN_V729_param.mask,CAEN_V729_param.nall,data, data1,data2);
 
if (ctrl_c) {
 
break;
}
if (nb<0) { // timeout
i--;
nerrors++;
} else {
 
V729_decode(CAEN_V729_param.mask,CAEN_V729_param.nall,data,adc, CAEN_V729_param.verbose);
 
#ifdef _CVI_
V729_plot(!i, adc );
#endif _CVI_
 
if (output) {
if (Random(0,1)<CAEN_V729_param.fraction) {
nball += fwrite(adc , 1, sizeof(uint16_t)*len, fp);
}
}
ncount++;
}
time(&t);
#ifdef _CVI_
if (t/4!=told ) {
double done=0;
if (CAEN_V729_param.neve) done= (double) (i)/CAEN_V729_param.neve;
HDrawCB ( 0, 0, EVENT_COMMIT ,NULL, 0,0);
 
EstimatedFinish(CAEN_V729_param.panel, P4_PROGRESS, P4_ETA, tstart, done);
}
#endif _CVI_
if (t/4!=told ) printf("%d events in %2.2f min (%d s) TIMEOUTS=%d %s",ncount, (double)(t-tstart)/60.,(int)(t-tstart), nerrors, ctime(&t));
told=t/4;
}
#ifdef _CVI_
HDrawCB ( 0, 0, EVENT_COMMIT ,NULL, 0,0);
#endif _CVI_
// end
if (output) {
for (ch=0; ch<4; ch++) {
if ( CAEN_V729_param.mask & (1<<ch) ) {
H2DWrite2File(10+ch,fp);
H1DWrite2File(10+ch,fp);
}
}
if (output==1) fclose(fp);
}
CAEN_V729_param.fp = NULL;
free(data);
free(data2);
free(data1);
free(adc);
time(&t);
printf("%d events in %2.2f min (%d s) TIMEOUTS=%d %s\n",ncount, (double)(t-tstart)/60.,(int)(t-tstart), nerrors, ctime(&t));
return 0;
}
 
 
 
#ifdef V729_MAIN
int main(int argc,char **argv) {
if (argc == 1) {
 
V729_Usage();
exit (-1);
}
// intercept routine
if (signal (SIGINT, CatchSig) == SIG_ERR) perror ("sigignore");
VME_START(NULL);
V729_main (argc,argv);
VME_STOP();
return ;
}
#endif V729_MAIN
 
#ifdef V729_WINMAIN
 
int CVICALLBACK HidePanelCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
switch (event) {
case EVENT_COMMIT:
HidePanel (panel);
break;
}
return 0;
}
 
 
void SetDimming(int state) {
SetCtrlAttribute (p4h, P4_DAQ, ATTR_DIMMED, state);
SetCtrlAttribute (p4h, P4_STOP, ATTR_DIMMED, !state);
}
 
void CVICALLBACK EndOfThread (int poolHandle, int functionID, unsigned int event, int value, void *callbackData) {
 
 
SetDimming(0);
printf("End of Thread \n");
return ;
 
}
 
static int poolHandle = 0;
static int p1h, pID, rID, tfID;
# define MAX_THREADS 10
int __stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpszCmdLine, int nCmdShow) {
char title[0xFF]="";
int i;
if (InitCVIRTE (hInstance, 0, 0) == 0)
return -1; /* out of memory */
 
SetSleepPolicy(VAL_SLEEP_MORE);
CmtNewThreadPool (MAX_THREADS, &poolHandle);
 
VME_START(WIENER_VMEMM);
SetStdioPort (CVI_STDIO_WINDOW );
if ((p4h = V729_LoadPanel (0, "CAEN_V729_CVI.uir", P4)) < 0)
return -1;
 
GetPanelAttribute (p4h, ATTR_TITLE, title );
 
SetPanelAttribute (p4h, ATTR_TITLE, title );
 
 
DisplayPanel (p4h);
 
InitColors();
 
do {
ThreadFunctionPtr mythread = NULL;
GetUserEvent (1, &pID, &rID);
 
 
if (pID ==p4h && rID == P4_DAQ ) mythread=V729_daq;
if (mythread!=NULL) {
printf("New Thread panel=%d button=%d\n", pID, rID);
ctrl_c=0;
 
 
CmtScheduleThreadPoolFunctionAdv (poolHandle, mythread, &rID,
DEFAULT_THREAD_PRIORITY,
EndOfThread,
EVENT_TP_THREAD_FUNCTION_END,
NULL, RUN_IN_SCHEDULED_THREAD,
&tfID);
SetDimming(1);
}
 
if ( pID==p4h && rID == P4_STOP ) {
printf("Stopping the Thread %d\n", tfID);
ctrl_c=1;
}
if ( pID==p4h && rID == P4_HIDE ) {
printf("Exit\n");
break;
}
} while (1);
 
CmtDiscardThreadPool (poolHandle);
DiscardPanel (p4h);
 
VME_STOP();
return 0;
}
#endif V729_WINMAIN
/cvi/apps/sa02_daq/cvi/CAEN_V729/CAEN_V729.h
0,0 → 1,41
#ifndef CAEN_V729_H
#define CAEN_V729_H
 
#define V729_OFFSET 0x880000
 
typedef struct {
uint32_t mask;
int cbl;
int nall;
char filename[0xFF];
int verbose ;
int neve ;
uint32_t addr;
uint32_t bias1 ;
uint32_t bias2;
int append;
int panel;
FILE *fp;
double fraction;
} CAEN_V729_PARAM;
 
void V729_map( uint32_t addr);
void V729_info(FILE *kam);
void V729_reg( uint32_t val);
void V729_reset(int nall,int nbefore,int obae,int obaf);
void V729_set_bias(int range, int bias1, int bias2);
void V729_aquisition_mode(uint32_t mode);
void V729_soft_stop( void);
void V729_clear_buffer(void) ;
void V729_get_buffer(uint32_t *data1, uint32_t *data2);
void V729_init(uint32_t addr, int nall, int cbl, uint32_t bias1, uint32_t bias2);
int V729_status( void );
int V729_event(int mask, int nall, uint32_t *data,uint32_t *data1,uint32_t *data2);
int V729_decode(uint32_t mask, int nall, uint32_t *data, uint16_t *dadc, int debug);
void V729_Usage(void);
int V729_GetParams(int argc,char **argv);
int V729_LoadPanel (int Parent_Panel_Handle, char Filename[], int Panel_Resource_ID);
int V729_SetFilePointer (FILE *fp);
int V729_main (int argc,char **argv);
int CVICALLBACK V729_daq(void *functionData);
#endif
/cvi/apps/sa02_daq/cvi/CAEN_V729/CAEN_V729.prj
0,0 → 1,321
[Project Header]
Version = 551
Platform Code = 4
Pathname = "/c/home/mitja/sa02_daq/cvi/CAEN_V729/CAEN_V729.prj"
CVI Dir = "/c/measurementstudio/cvi"
VXIplug&play Framework Dir = "/C/VXIpnp/winnt"
Number of Files = 11
Sort Type = "No Sort"
Target Type = "Executable"
Build Configuration = "Debug"
Warn User If Debugging Release = 1
Flags = 16
Drag Bar Left = 187
Window Top = 54
Window Left = 924
Window Bottom = 454
Window Right = 1672
 
[File 0001]
File Type = "CSource"
Path = "/c/home/mitja/sa02_daq/cvi/CAEN_V729/CAEN_V729.c"
Res Id = 1
Exclude = False
Disk Date = 3473761958
Project Flags = 0
Compile Into Object File = False
Object Format = "Win32-MSVC"
ForceCompile_Debug = False
ForceCompile_Release = True
Window Top = 361
Window Left = 715
Window Height = 0
Window Width = 0
Source Window State = "1,392,392,392,9,13,14,0,0,103,0,0,0,0,0,53,366,0,407,40,"
Header Dependencies Line0001 = "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30"
Header Dependencies Line0002 = ",31,32,33,34,35,36,37,38,39,40,41,42,43,44,46,49,50,52,53,55,67,70,71,"
 
[File 0002]
File Type = "Include"
Path = "/c/home/mitja/sa02_daq/dataio.h"
Res Id = 2
Exclude = False
Disk Date = 3473331202
Project Flags = 0
Window Top = 365
Window Left = 85
Window Height = 0
Window Width = 0
Source Window State = "1,10,10,10,8,21,8,0,0,89,0,0,0,0,0,25,0,0,9,11,"
 
[File 0003]
File Type = "Include"
Path = "/c/home/mitja/sa02_daq/cvi/HDraw.h"
Res Id = 3
Exclude = False
Disk Date = 3473251454
Project Flags = 0
Window Top = 515
Window Left = 52
Window Height = 0
Window Width = 0
Source Window State = "1,3,12,3,0,40,0,0,0,89,0,0,0,0,0,25,0,0,15,17,"
 
[File 0004]
File Type = "CSource"
Path = "/c/home/mitja/sa02_daq/cvi/HDraw.c"
Res Id = 4
Exclude = False
Disk Date = 3473325539
Project Flags = 0
Compile Into Object File = False
Object Format = "Win32-MSVC"
ForceCompile_Debug = False
ForceCompile_Release = True
Window Top = 463
Window Left = 450
Window Height = 0
Window Width = 0
Source Window State = "1,25,25,25,0,23,24,0,0,131,0,0,0,0,0,25,0,0,1,9,"
Header Dependencies = "1,2,3,4,5,6,7,9,12,13,14,15,16,18,19,20,21,22,23,50,52,53,55,"
 
[File 0005]
File Type = "CSource"
Path = "/c/home/mitja/sa02_daq/cvi/H2D.c"
Res Id = 5
Exclude = False
Disk Date = 3473748559
Project Flags = 0
Compile Into Object File = False
Object Format = "Win32-MSVC"
ForceCompile_Debug = False
ForceCompile_Release = True
Window Top = 432
Window Left = 45
Window Height = 0
Window Width = 0
Source Window State = "1,53,53,53,5,21,5,0,0,89,0,0,0,0,0,25,43,0,60,15,"
Header Dependencies = "1,2,3,4,5,6,9,12,13,14,15,16,18,19,20,21,22,23,50,"
 
[File 0006]
File Type = "Include"
Path = "/c/home/mitja/sa02_daq/cvi/H2D.h"
Res Id = 6
Exclude = False
Disk Date = 3473322655
Project Flags = 0
Window Top = 554
Window Left = 838
Window Height = 0
Window Width = 0
Source Window State = "1,51,51,51,6,23,6,0,0,89,0,0,0,0,0,25,33,0,42,33,"
 
[File 0007]
File Type = "Include"
Path = "/c/home/mitja/sa02_daq/cvi/CAEN_V729/CAEN_V729.h"
Res Id = 7
Exclude = False
Disk Date = 3473329824
Project Flags = 0
Window Top = 0
Window Left = 0
Window Height = 0
Window Width = 0
Source Window State = "1,0,0,0,0,0,0,0,0,89,0,0,0,0,0,25,14,0,35,36,"
 
[File 0008]
File Type = "User Interface Resource"
Path = "/c/home/mitja/sa02_daq/cvi/CAEN_V729/CAEN_V729_CVI.uir"
Res Id = 8
Exclude = False
Disk Date = 3473762889
Project Flags = 0
Window Top = 233
Window Left = 204
Window Height = 663
Window Width = 1184
 
[File 0009]
File Type = "Include"
Path = "/c/home/mitja/sa02_daq/cvi/CAEN_V729/CAEN_V729_DEF.h"
Res Id = 9
Exclude = False
Disk Date = 3473098417
Project Flags = 0
Window Top = 632
Window Left = 326
Window Height = 0
Window Width = 0
Source Window State = "1,0,0,0,0,0,0,0,0,89,0,0,0,0,0,25,0,0,11,33,"
 
[File 0010]
File Type = "Function Panel"
Path = "/c/MeasurementStudio/cvi/instr/WIENVME_DLL/wienvme_dll.fp"
Res Id = 10
Exclude = False
Disk Date = 3258260654
Project Flags = 0
Window Top = 0
Window Left = 0
Window Height = 0
Window Width = 0
 
[File 0011]
File Type = "Function Panel"
Path = "/c/MeasurementStudio/cvi/toolslib/toolbox/asynctmr.fp"
Res Id = 11
Exclude = False
Disk Date = 3051676800
Project Flags = 0
Window Top = 0
Window Left = 0
Window Height = 0
Window Width = 0
 
[SCC Options]
Use global settings = True
SCC Provider = ""
SCC Project = ""
Local Path = ""
Auxiliary Path = ""
Perform Same Action For .h File As For .uir File = "Ask"
Comment = ""
Username = ""
Use Default Comment = False
Use Default Username = False
Do Not Include PRJ File in Actions = True
Suppress CVI Error Messages = False
 
[Compiler Options]
Default Calling Convention = "cdecl"
Max Number Of Errors = 10
Require Prototypes = True
Require Return Values = True
Enable Pointer Mismatch Warning = False
Enable Unreachable Code Warning = False
Track Include File Dependencies = True
Prompt For Missing Includes = True
Stop On First Error File = False
Bring Up Err Win For Warnings = True
Show Build Dialog = False
O Option Compatible With 5.0 = False
 
[Run Options]
Stack Size = 250000
Debugging Level = "Standard"
Save Changes Before Running = "Ask"
Break On Library Errors = True
Break On First Chance Exceptions = False
Hide Windows = False
Break At First Statement = False
 
[Compiler Defines]
Compiler Defines = "/DV729_DEBUG /DWIN32_LEAN_AND_MEAN /DWIENVME /DCAEN_V1495 /DV729_WINMAIN"
 
[Command Line Args]
Command Line Args = ""
 
[Include Paths]
Include Path 1 = "/c/home/mitja/sa02_daq/vmeinterfaces"
Include Path 2 = "/c/home/mitja/sa02_daq/cvi/CAEN_V729"
 
[Included Headers]
Header 0010 = "/c/home/mitja/sa02_daq/vmeinterfaces/vme.h"
Header 0050 = "/c/home/mitja/sa02_daq/cvi/H2D.h"
Header 0053 = "/c/home/mitja/sa02_daq/cvi/HDraw.h"
Header 0065 = "/c/home/mitja/sa02_daq/SA02_DEF.h"
Header 0067 = "/c/home/mitja/sa02_daq/dataio.h"
Header 0062 = "/c/home/mitja/sa02_daq/sa02lib.h"
Header 0001 = "/c/MeasurementStudio/cvi/include/ansi/stdlib.h"
Header 0002 = "/c/MeasurementStudio/cvi/include/cvidef.h"
Header 0003 = "/c/MeasurementStudio/cvi/include/cvirte.h"
Header 0004 = "/c/MeasurementStudio/cvi/include/ansi/stdio.h"
Header 0005 = "/c/MeasurementStudio/cvi/include/ansi/string.h"
Header 0007 = "/c/MeasurementStudio/cvi/include/userint.h"
Header 0008 = "/c/MeasurementStudio/cvi/toolslib/toolbox/asynctmr.h"
Header 0009 = "/c/MeasurementStudio/cvi/include/ansi/stdarg.h"
Header 0011 = "/c/MeasurementStudio/cvi/instr/WIENVME_DLL/wienvme_dll.h"
Header 0012 = "/c/MeasurementStudio/cvi/include/ansi_c.h"
Header 0014 = "/c/MeasurementStudio/cvi/include/ansi/ctype.h"
Header 0015 = "/c/MeasurementStudio/cvi/include/ansi/errno.h"
Header 0016 = "/c/MeasurementStudio/cvi/include/ansi/float.h"
Header 0018 = "/c/MeasurementStudio/cvi/include/ansi/locale.h"
Header 0019 = "/c/MeasurementStudio/cvi/include/ansi/math.h"
Header 0020 = "/c/MeasurementStudio/cvi/include/ansi/setjmp.h"
Header 0021 = "/c/MeasurementStudio/cvi/include/ansi/signal.h"
Header 0022 = "/c/MeasurementStudio/cvi/include/ansi/stddef.h"
Header 0023 = "/c/MeasurementStudio/cvi/include/ansi/time.h"
Header 0024 = "/c/MeasurementStudio/cvi/sdk/include/windows.h"
Header 0025 = "/c/MeasurementStudio/cvi/sdk/include/windef.h"
Header 0026 = "/c/MeasurementStudio/cvi/sdk/include/winnt.h"
Header 0027 = "/c/MeasurementStudio/cvi/sdk/include/basetsd.h"
Header 0028 = "/c/MeasurementStudio/cvi/sdk/include/Guiddef.h"
Header 0033 = "/c/MeasurementStudio/cvi/sdk/include/winbase.h"
Header 0035 = "/c/MeasurementStudio/cvi/sdk/include/wingdi.h"
Header 0037 = "/c/MeasurementStudio/cvi/sdk/include/winuser.h"
Header 0039 = "/c/MeasurementStudio/cvi/sdk/include/winnls.h"
Header 0044 = "/c/MeasurementStudio/cvi/sdk/include/winsvc.h"
Header 0046 = "/c/MeasurementStudio/cvi/sdk/include/imm.h"
Header 0049 = "/c/MeasurementStudio/cvi/include/utility.h"
Header 0052 = "/c/MeasurementStudio/cvi/toolslib/toolbox/toolbox.h"
Header 0056 = "/c/MeasurementStudio/cvi/instr/MIKRO/MIKRO.h"
Header 0057 = "/c/MeasurementStudio/cvi/include/ivi.h"
Header 0058 = "/c/MeasurementStudio/cvi/include/visa.h"
Header 0059 = "/c/MeasurementStudio/cvi/include/visatype.h"
Header 0061 = "/c/MeasurementStudio/cvi/include/analysis.h"
Header 0066 = "/c/home/mitja/sa02_daq/cvi/sa02_CVI.h"
Header 0051 = "/c/MeasurementStudio/cvi/include/formatio.h"
Header 0054 = "/c/MeasurementStudio/cvi/include/rs232.h"
Header 0055 = "/c/home/mitja/sa02_daq/cvi/CAEN_V729/CAEN_V729_CVI.h"
Header 0071 = "/c/home/mitja/sa02_daq/cvi/CAEN_V729/CAEN_V729_DEF.h"
Header 0070 = "/c/home/mitja/sa02_daq/cvi/CAEN_V729/CAEN_V729.h"
Header 0006 = "/c/MeasurementStudio/cvi/include/ansi/assert.h"
Header 0013 = "/c/MeasurementStudio/cvi/include/ansi/limits.h"
Header 0017 = "/c/MeasurementStudio/cvi/sdk/include/pshpack4.h"
Header 0029 = "/c/MeasurementStudio/cvi/sdk/include/poppack.h"
Header 0030 = "/c/MeasurementStudio/cvi/sdk/include/pshpack2.h"
Header 0031 = "/c/MeasurementStudio/cvi/sdk/include/pshpack8.h"
Header 0032 = "/c/MeasurementStudio/cvi/sdk/include/winerror.h"
Header 0034 = "/c/MeasurementStudio/cvi/sdk/include/pshpack1.h"
Header 0036 = "/c/MeasurementStudio/cvi/sdk/include/tvout.h"
Header 0038 = "/c/MeasurementStudio/cvi/sdk/include/wincon.h"
Header 0040 = "/c/MeasurementStudio/cvi/sdk/include/winver.h"
Header 0041 = "/c/MeasurementStudio/cvi/sdk/include/winreg.h"
Header 0042 = "/c/MeasurementStudio/cvi/sdk/include/winnetwk.h"
Header 0043 = "/c/MeasurementStudio/cvi/sdk/include/mcx.h"
Max Header Number = 71
 
[Create Executable]
Executable File_Debug = "/c/home/mitja/sa02_daq/cvi/CAEN_V729_dbg.exe"
Target Creation Date_Debug = 3473761959
Force Creation of Target_Debug = False
Executable File_Release = ""
Target Creation Date_Release = 0
Force Creation of Target_Release = True
Icon File = ""
Application Title = ""
DLL Exports = "Include File Symbols"
DLL Import Library Choice = "Gen Lib For Current Mode"
Use VXIPNP Subdirectories for Import Libraries = False
Use Dflt Import Lib Base Name = True
Where to Copy DLL = "Do not copy"
Add Type Lib To DLL = False
Include Type Lib Help Links = False
Type Lib FP File = ""
Type Lib Guid = ""
Uses DataSocket = 0
Uses NIReports = 0
Uses DCom95 = 0
Instrument Driver Support Only = False
 
[External Compiler Support]
UIR Callbacks File Option = 0
Using LoadExternalModule = False
Create Project Symbols File = True
UIR Callbacks Obj File = ""
Project Symbols H File = ""
Project Symbols Obj File = ""
 
[DLL Debugging Support]
External Process Path = ""
 
/cvi/apps/sa02_daq/cvi/CAEN_V729/CAEN_V729_CVI.h
0,0 → 1,52
/**************************************************************************/
/* LabWindows/CVI User Interface Resource (UIR) Include File */
/* Copyright (c) National Instruments 2014. All Rights Reserved. */
/* */
/* WARNING: Do not add to, delete from, or otherwise modify the contents */
/* of this include file. */
/**************************************************************************/
 
#include <userint.h>
 
#ifdef __cplusplus
extern "C" {
#endif
 
/* Panels and Controls: */
 
#define P4 1
#define P4_CEVE 2
#define P4_NEVE 3
#define P4_VERBOSE 4
#define P4_NALL 5
#define P4_CBL 6
#define P4_HIDE 7 /* callback function: HidePanelCB */
#define P4_BIAS2 8
#define P4_BIAS1 9
#define P4_ADDR 10
#define P4_MASK 11
#define P4_FILENAME 12
#define P4_STOP 13
#define P4_DAQ 14
#define P4_GRAPH 15
#define P4_ADCCH 16 /* callback function: HDrawCB */
#define P4_FRACTION 17
#define P4_PROGRESS 18
#define P4_ETA 19
#define P4_HDISPLAY 20 /* callback function: HDrawCB */
 
 
/* Menu Bars, Menus, and Menu Items: */
 
/* (no menu bars in the resource file) */
 
 
/* Callback Prototypes: */
 
int CVICALLBACK HDrawCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
int CVICALLBACK HidePanelCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
 
 
#ifdef __cplusplus
}
#endif
/cvi/apps/sa02_daq/cvi/CAEN_V729/CAEN_V729_CVI.uir
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/cvi/apps/sa02_daq/cvi/CAEN_V729/CAEN_V729_DEF.h
0,0 → 1,23
#ifndef V729_DEF_H
#define V729_DEF_H
 
#define V729_OBR1 0x00
#define V729_OBR2 0x04
#define V729_SR 0x08
#define V729_AEC 0x0A
#define V729_REC 0x0C
#define V729_CSR 0x0E
#define V729_FSR 0x10
#define V729_UFSR 0x12
#define V729_RR 0x14
#define V729_SSR 0x16
#define V729_DO0P 0x18
#define V729_DO0M 0x1A
#define V729_DO1P 0x1C
#define V729_DO1M 0x1E
#define V729_DO2P 0x20
#define V729_DO2M 0x22
#define V729_DO3P 0x24
#define V729_DO3M 0x26
 
#endif V729_DEF_H
/cvi/apps/sa02_daq/cvi/H1D.c
0,0 → 1,254
#ifdef _CVI_
# include <ansi_c.h>
# else _CVI_
# include <stdlib.h>
# include <stdio.h>
# include <string.h>
#endif _CVI_
 
#include "H1D.h"
 
#define H1DMAX 500
H1D *h1[H1DMAX];
//int Printf(char *format, ...);
 
int H1DClear(int h1d) {
if (!h1[h1d]) return -1;
memset(h1[h1d]->data, 0,h1[h1d]->size );
h1[h1d]->min=0;
h1[h1d]->max=0;
h1[h1d]->nentries=0;
return 0;
 
}
 
int H1DPrint(int h1d) {
if (!h1[h1d]) return -1;
//Printf("PrintH1D nx=%d minx=%f stepx=%f ny=%d miny=%f stepy=%f size=%d\n", h1[h1d]->nx, h1[h1d]->minx, h1[h1d]->stepx, h1[h1d]->ny, h1[h1d]->miny, h1[h1d]->stepy, h1[h1d]->size ) ;
return 0;
 
}
 
int H1DExist(int h) {
if (h1[h]) return 1;
else return 0;
}
 
 
int H1DGetBin(int h, double value) {
int nx,xmin,dx;
int bin;
 
nx = H1DGetNbinsX(h);
xmin= H1DGetMinX(h);
dx = H1DGetStepX(h);
 
if (dx==0) return -1;
if (value<xmin) return -1;
bin = (int)((value-xmin)/dx);
if (bin>=nx) return -1;
else return bin;
}
 
int H1DFill(int h1d,double x, double val) {
 
int ix;
if (!h1[h1d]) return -1;
 
ix = H1DGetBin(h1d,x);
if (ix<0) return ix;
 
h1[h1d]->data[ix]+=val;
//Printf("%d %d data %f %f\n",x,y,val, h1[h1d]->data[idx]);
if (h1[h1d]->data[ix]>h1[h1d]->max) h1[h1d]->max= h1[h1d]->data[ix];
if (h1[h1d]->data[ix]<h1[h1d]->min) h1[h1d]->min= h1[h1d]->data[ix];
h1[h1d]->nentries++;
return 0;
}
 
 
int H1DFillBin(int h1d,int x, double val) {
 
if (!h1[h1d]) {
//Printf("FillH1D error h1d is not initialized\n");
return -1;
}
 
h1[h1d]->data[x]+=val;
//Printf("%d %d data %f %f\n",x,y,val, h1[h1d]->data[idx]);
if (h1[h1d]->data[x]>h1[h1d]->max) h1[h1d]->max= h1[h1d]->data[x];
if (h1[h1d]->data[x]<h1[h1d]->min) h1[h1d]->min= h1[h1d]->data[x];
h1[h1d]->nentries++;
return 0;
}
 
int H1DSetBinContent(int h1d,int x, double val) {
 
if (!h1[h1d]) {
//Printf("FillH1D error h1d is not initialized\n");
return -1;
}
 
h1[h1d]->data[x]=val;
//Printf("%d %d data %f %f\n",x,y,val, h1[h1d]->data[idx]);
if (h1[h1d]->data[x]>h1[h1d]->max) h1[h1d]->max= h1[h1d]->data[x];
if (h1[h1d]->data[x]<h1[h1d]->min) h1[h1d]->min= h1[h1d]->data[x];
h1[h1d]->nentries++;
return 0;
}
 
 
 
double H1DGetBinContent(int h1d,int atx) {
 
int idx;
if (!h1[h1d]) return 0;
if (h1[h1d]->nx <= atx) return 0;
if (atx<0) return 0;
if (atx*sizeof(double) < h1[h1d]->size ) return h1[h1d]->data[atx];
 
 
return 0;
}
 
 
int H1DInit(int h1d,char *name, char *title,int nx, double minx, double stepx) {
 
if (h1[h1d]) {
 
free(h1[h1d]->data);
free(h1[h1d]);
h1[h1d] = NULL;
}
// if (h1d!=H1DMAX-1) printf("InitH1D hID=%d\n",h1d);
h1[h1d] = (H1D *) malloc(sizeof(H1D));
//h2 =h1d;
 
H1DSetTitle(h1d,title);
H1DSetName(h1d,name);
H1DSetTitleX(h1d,"x");
;
h1[h1d]->id=H1D_ID;
h1[h1d]->nx = nx;
 
 
h1[h1d]->minx = minx;
 
h1[h1d]->stepx = stepx;
 
h1[h1d]->size = h1[h1d]->nx*sizeof(double);
h1[h1d]->data = (double *) malloc(h1[h1d]->size);
h1[h1d]->len=sizeof(H1D)-sizeof(double *)+h1[h1d]->size;
H1DClear(h1d);
H1DPrint(h1d);
//Printf("InitH1D 0x%x\n", h1d );
return 0;
 
}
 
 
double H1DGetXBinCenter(int h1d,int xbin) {
return h1[h1d]->minx+xbin*h1[h1d]->stepx;
}
 
 
int H1DWrite2File(int h1d,FILE *fp) {
 
if (!fp) return -1;
//printf("H1D sizeof(H1D)=%lu len-datasize=%d len=%lu datasize=%d\t",sizeof(H1D)-sizeof(double *),h1[h1d]->len-h1[h1d]->size,h1[h1d]->len,h1[h1d]->size);
//printf("H1D sz=%d %d\n",sizeof(double),sizeof(double *));
if (!H1DExist(h1d)){
printf("Histogram H1D=%d is not initialized\n",h1d);
return -1;
}
fwrite (h1[h1d], 1, sizeof(H1D)-sizeof(double *), fp);
fwrite (h1[h1d]->data, 1, h1[h1d]->size, fp);
return 0;
}
 
int H1DWrite(int h1d,const char *fname,const char *opt) {
FILE *fp=fopen(fname,opt);
H1DWrite2File(h1d,fp);
fclose(fp);
return 0;
}
 
 
 
 
int H1DSetTitle(int h1d,char *title) {
if (!h1[h1d]) {
printf("h1d %d does not exist %s\n",h1d, title);
return 0;
}
sprintf(h1[h1d]->title,"%s",title);
return 0;
}
 
 
int H1DSetTitleX(int h1d,char *title) {
sprintf(h1[h1d]->titlex,"%s",title);
return 0;
}
 
 
int H1DSetTitleY(int h1d,char *title) {
sprintf(h1[h1d]->titley,"%s",title);
return 0;
}
 
 
char * H1DGetTitleX(int h1d) {
return h1[h1d]->titlex;
}
 
char * H1DGetTitleY(int h1d) {
return h1[h1d]->titley;
}
 
char * H1DGetTitle(int h1d) {
return h1[h1d]->title;
}
 
 
 
int H1DSetName(int h1d,char *title) {
sprintf(h1[h1d]->name,"%s",title);
return 0;
}
 
int H1DGetNbinsX(int h) {
if (h1[h]) return h1[h]->nx;
else return 0;
}
 
 
 
double H1DGetMinX(int h) {
if (h1[h]) return h1[h]->minx;
else return 0;
}
 
 
 
double H1DGetStepX(int h) {
if (h1[h]) return h1[h]->stepx;
else return 0;
}
 
 
double H1DGetMin(int h) {
if (h1[h]) return h1[h]->min;
else return 0;
}
 
double H1DGetMax(int h) {
if (h1[h]) return h1[h]->max;
else return 0;
}
 
double * H1DGetData(int h) {
if (h1[h]) return h1[h]->data;
else return NULL;
}
 
/cvi/apps/sa02_daq/cvi/H1D.h
0,0 → 1,65
#ifndef _H1D_H_
#define _H1D_H_
 
/* 2d histogramming */
#define H1D_ID 0x11
#pragma pack(4)
typedef struct {
unsigned int id,len;
unsigned int nx;
int nentries;
unsigned int size;
double min;
double max;
double minx;
double stepx;
 
char name[20];
char title[100];
char titlex[40];
char titley[40];
 
double *data;
} H1D;
#pragma pack()
 
 
 
 
double H1DGetYBinCenter(int h2d,int ybin);
double H1DGetYBinCenter(int h2d,int xbin);
 
int H1DClear(int h2d);
int H1DPrint(int h2d);
int H1DExist(int h2d);
int H1DGetBin(int h2d, double value);
int H1DFill(int h2d,double x, double val);
int H1DFillBin(int h2d,int x, double val);
int H1DSetBinContent(int h2d,int x, double val);
double H1DGetBinContent(int h2d,int atx);
int H1DInit(int h2d,char *name, char *title,int nx, double minx, double stepx);
int H1DWrite(int h2d,const char *fname,const char*opt);
int H1DWrite2File(int h2d,FILE *fp);
int H1DSetTitle(int h2d,char *title);
int H1DSetTitleX(int h2d,char *title);
int H1DSetTitleY(int h2d,char *title);
int H1DSetName(int h2d,char *title);
 
char * H1DGetTitleX(int h1d);
 
char * H1DGetTitleY(int h1d);
 
char * H1DGetTitle(int h1d);
 
 
 
int H1DGetNbinsX(int h);
 
double H1DGetMinX(int h);
 
double H1DGetStepX(int h);
double H1DGetMin(int h);
double H1DGetMax(int h);
double * H1DGetData(int h);
 
#endif /* _H1D_H_ */
/cvi/apps/sa02_daq/cvi/H2D.c
0,0 → 1,224
#ifdef _CVI_
# include <ansi_c.h>
# else /* _CVI_ */
# include <stdlib.h>
# include <stdio.h>
# include <string.h>
#endif /* _CVI_ */
 
#include "H2D.h"
 
#define H2DMAX 500
H2D *h2[H2DMAX];
//int Printf(char *format, ...);
 
int H2DClear(int h2d) {
if (!h2[h2d]) return -1;
memset(h2[h2d]->data, 0,h2[h2d]->size );
h2[h2d]->min=0;
h2[h2d]->max=0;
h2[h2d]->nentries=0;
return 0;
}
 
int H2DPrint(int h2d) {
if (!h2[h2d]) return -1;
//Printf("PrintH2D nx=%d minx=%f stepx=%f ny=%d miny=%f stepy=%f size=%d\n", h2[h2d]->nx, h2[h2d]->minx, h2[h2d]->stepx, h2[h2d]->ny, h2[h2d]->miny, h2[h2d]->stepy, h2[h2d]->size ) ;
return 0;
}
 
int H2DExist(int h) {
if (h2[h]) return 1;
else return 0;
}
 
int H2DGetBin(int h2d,int x, int y) {
return x+h2[h2d]->nx * y;
}
 
int H2DCalculateBin(int h, int axis, double value) {
int nx=0;
double xmin=0,dx=0;
int bin;
switch (axis) {
case 0:
nx = H2DGetNbinsX(h);
xmin= H2DGetMinX(h);
dx = H2DGetStepX(h);
break;
case 1:
nx = H2DGetNbinsY(h);
xmin= H2DGetMinY(h);
dx = H2DGetStepY(h);
break;
default:
return -1;
}
if (dx<1e-10) return -1;
if (value<xmin) return -1;
bin = (int)((value-xmin)/dx);
if (bin>=nx) return -1;
else return bin;
}
 
int H2DFill(int h2d,double x, double y, double val) {
 
int ix,iy;
if (!h2[h2d]) return -1;
ix = H2DCalculateBin(h2d,0,x);
if (ix<0) return ix;
iy = H2DCalculateBin(h2d,1,y);
if (iy<0) return iy;
return H2DFillBin(h2d,ix, iy, val);
}
 
int H2DFillBin(int h2d,int x, int y, double val) {
 
int idx;
if (!h2[h2d]) {
//Printf("FillH2D error h2d is not initialized\n");
return -1;
}
 
idx = x+y*h2[h2d]->nx;
h2[h2d]->data[idx]+=val;
//Printf("%d %d data %f %f\n",x,y,val, h2[h2d]->data[idx]);
if (h2[h2d]->data[idx]>h2[h2d]->max) h2[h2d]->max= h2[h2d]->data[idx];
if (h2[h2d]->data[idx]<h2[h2d]->min) h2[h2d]->min= h2[h2d]->data[idx];
h2[h2d]->nentries++;
return 0;
}
 
double H2DGetBinContent(int h2d,int atx,int aty) {
 
int idx;
if (!h2[h2d]) return 0;
if (h2[h2d]->nx <= (unsigned int)atx) return 0;
if (h2[h2d]->ny <= (unsigned int)aty) return 0;
idx = atx+aty*h2[h2d]->nx;
if (idx*sizeof(double) < h2[h2d]->size ) return h2[h2d]->data[idx];
return 0;
}
 
int H2DInit(int h2d,const char *name,const char *title,int nx, double minx, double stepx, int ny, double miny, double stepy) {
 
if (h2[h2d]) {
free(h2[h2d]->data);
free(h2[h2d]);
h2[h2d] = NULL;
}
//printf("InitH2D hID=%d\n",h2d);
h2[h2d] = (H2D *) malloc(sizeof(H2D));
//h2 =h2d;
H2DSetTitle(h2d,title);
H2DSetName(h2d,name);
h2[h2d]->id=H2D_ID;
h2[h2d]->nx = nx;
h2[h2d]->ny = ny;
h2[h2d]->minx = minx;
h2[h2d]->miny = miny;
h2[h2d]->stepx = stepx;
h2[h2d]->stepy = stepy;
h2[h2d]->size = h2[h2d]->nx*h2[h2d]->ny*sizeof(double);
h2[h2d]->data = (double *) malloc(h2[h2d]->size);
h2[h2d]->len=sizeof(H2D)-sizeof(double *)+h2[h2d]->size;
H2DClear(h2d);
H2DPrint(h2d);
//Printf("InitH2D 0x%x\n", h2d );
return 0;
}
 
double H2DGetXBinCenter(int h2d,int xbin) {
return h2[h2d]->minx+xbin*h2[h2d]->stepx;
}
 
double H2DGetYBinCenter(int h2d,int ybin) {
return h2[h2d]->miny+ybin*h2[h2d]->stepy;
}
 
int H2DWrite2File(int h2d,FILE *fp) {
 
if (!fp) return -1;
//printf("H2D sizeof(H2D)=%lu len-datasize=%d len=%lu datasize=%d\t",sizeof(H2D)-sizeof(double *),h2[h2d]->len-h2[h2d]->size,h2[h2d]->len,h2[h2d]->size);
//printf("H2D sz=%d %d\n",sizeof(double),sizeof(double *));
if (!H2DExist(h2d)){
printf("Histogram H2D=%d is not initialized\n",h2d);
return -1;
}
fwrite (h2[h2d], 1, sizeof(H2D)-sizeof(double *), fp);
fwrite (h2[h2d]->data, 1, h2[h2d]->size, fp);
return 0;
}
 
int H2DWrite(int h2d,const char *fname,const char *opt) {
FILE *fp=fopen(fname,opt);
H2DWrite2File(h2d,fp);
fclose(fp);
return 0;
}
 
int H2DSetTitle(int h2d,const char *title) {
sprintf(h2[h2d]->title,"%s",title);
return 0;
}
 
int H2DSetTitleX(int h2d,const char *title) {
sprintf(h2[h2d]->titlex,"%s",title);
return 0;
}
 
int H2DSetTitleY(int h2d,const char *title) {
sprintf(h2[h2d]->titley,"%s",title);
return 0;
}
 
int H2DSetName(int h2d,const char *title) {
sprintf(h2[h2d]->name,"%s",title);
return 0;
}
 
int H2DGetNbinsY(int h) {
if (h2[h]) return h2[h]->ny;
else return 0;
}
 
int H2DGetNbinsX(int h) {
if (h2[h]) return h2[h]->nx;
else return 0;
}
 
double H2DGetMinY(int h) {
if (h2[h]) return h2[h]->miny;
else return 0;
}
 
double H2DGetMinX(int h) {
if (h2[h]) return h2[h]->minx;
else return 0;
}
 
double H2DGetStepY(int h) {
if (h2[h]) return h2[h]->stepy;
else return 0;
}
 
double H2DGetStepX(int h) {
if (h2[h]) return h2[h]->stepx;
else return 0;
}
 
double H2DGetMin(int h) {
if (h2[h]) return h2[h]->min;
else return 0;
}
 
double H2DGetMax(int h) {
if (h2[h]) return h2[h]->max;
else return 0;
}
 
double * H2DGetData(int h) {
if (h2[h]) return h2[h]->data;
else return NULL;
}
 
/cvi/apps/sa02_daq/cvi/H2D.h
0,0 → 1,63
#ifndef _H2D_H_
#define _H2D_H_
 
#ifdef __CINT__
#define HALIGN 41
#else
#define HALIGN 40
#endif
 
/* 2d histogramming */
#define H2D_ID 0x10
#pragma pack(4)
typedef struct {
unsigned int id,len;
unsigned int nx;
unsigned int ny;
int nentries;
unsigned int size; // 6*4
double min;
double max;
double minx;
double miny;
double stepx;
double stepy; // 6*8
char name[20];
char title[100];
char titlex[40];
char titley[HALIGN]; // 196
double *data;
} H2D;
#pragma pack()
 
double H2DGetYBinCenter(int h2d,int ybin);
double H2DGetYBinCenter(int h2d,int xbin);
 
int H2DClear(int h2d);
int H2DPrint(int h2d);
int H2DExist(int h2d);
int H2DCalculateBin(int h2d, int axis, double value);
int H2DGetBin(int h2d,int x, int y);
int H2DFill(int h2d,double x, double y, double val);
int H2DFillBin(int h2d,int x, int y, double val);
double H2DGetBinContent(int h2d,int atx, int aty);
int H2DInit(int h2d,const char *name,const char *title,int nx, double minx, double stepx, int ny, double miny, double stepy);
int H2DWrite(int h2d,const char *fname,const char*opt);
int H2DWrite2File(int h2d,FILE *fp);
int H2DSetTitle(int h2d,const char *title);
int H2DSetTitleX(int h2d,const char *title);
int H2DSetTitleY(int h2d,const char *title);
int H2DSetName(int h2d,const char *title);
 
int H2DGetNbinsY(int h);
int H2DGetNbinsX(int h);
double H2DGetMinY(int h);
double H2DGetMinX(int h);
double H2DGetStepY(int h);
double H2DGetStepX(int h);
double H2DGetMin(int h);
double H2DGetMax(int h);
double * H2DGetData(int h);
 
#endif /* _H2D_H_ */
/cvi/apps/sa02_daq/cvi/H3D.c
0,0 → 1,292
#ifdef _CVI_
# include <ansi_c.h>
# else _CVI_
# include <stdlib.h>
# include <stdio.h>
# include <string.h>
#endif _CVI_
 
#include "H3D.h"
 
#define H3DMAX 500
H3D *h3[H3DMAX];
//int Printf(char *format, ...);
 
int H3DClear(int h3d) {
if (!h3[h3d]) return -1;
memset(h3[h3d]->data, 0,h3[h3d]->size );
h3[h3d]->min=0;
h3[h3d]->max=0;
h3[h3d]->nentries=0;
return 0;
 
}
 
int H3DPrint(int h3d) {
if (!h3[h3d]) return -1;
//Printf("PrintH3D nx=%d minx=%f stepx=%f ny=%d miny=%f stepy=%f size=%d\n", h3[h3d]->nx, h3[h3d]->minx, h3[h3d]->stepx, h3[h3d]->ny, h3[h3d]->miny, h3[h3d]->stepy, h3[h3d]->size ) ;
return 0;
 
}
 
int H3DExist(int h) {
if (h3[h]) return 1;
else return 0;
}
 
 
int H3DCalculateBin(int h, int axis, double value) {
int nx=1,xmin=0,dx=0;
int bin;
switch (axis) {
case 0:
nx = H3DGetNbinsX(h);
xmin= H3DGetMinX(h);
dx = H3DGetStepX(h);
break;
case 1:
nx = H3DGetNbinsY(h);
xmin= H3DGetMinY(h);
dx = H3DGetStepY(h);
break;
case 2:
nx = H3DGetNbinsZ(h);
xmin= H3DGetMinZ(h);
dx = H3DGetStepZ(h);
break;
 
}
if (dx==0) return -1;
if (value<xmin) return -1;
bin = (int)((value-xmin)/dx);
if (bin>=nx) return -1;
else return bin;
}
 
int H3DFill(int h3d,double x, double y, double z, double val) {
 
int idx, ix,iy, iz;
if (!h3[h3d]) return -1;
 
ix = H3DCalculateBin(h3d,0,x);
if (ix<0) return ix;
 
iy = H3DCalculateBin(h3d,1,y);
if (iy<0) return iy;
 
iz = H3DCalculateBin(h3d,2,z);
if (iz<0) return iz;
 
 
H3DFillBin(h3d, ix, iy, iz, val);
return 0;
}
 
int H3DGetBin(int h3d,int x, int y, int z) {
return x+h3[h3d]->nx *(y+z*h3[h3d]->ny);
}
 
int H3DFillBin(int h3d,int x, int y, int z, double val) {
 
int idx;
if (!h3[h3d]) {
//Printf("FillH3D error h3d is not initialized\n");
return -1;
}
 
idx = H3DGetBin(h3d,x,y,z);
h3[h3d]->data[idx]+=val;
//Printf("%d %d data %f %f\n",x,y,val, h3[h3d]->data[idx]);
if (h3[h3d]->data[idx]>h3[h3d]->max) h3[h3d]->max= h3[h3d]->data[idx];
if (h3[h3d]->data[idx]<h3[h3d]->min) h3[h3d]->min= h3[h3d]->data[idx];
h3[h3d]->nentries++;
return 0;
}
 
double H3DGetBinContent(int h3d,int atx, int aty, int atz) {
 
int idx;
if (!h3[h3d]) return 0;
if (h3[h3d]->nx <= atx) return 0;
if (h3[h3d]->ny <= aty) return 0;
if (h3[h3d]->nz <= atz) return 0;
idx = H3DGetBin(h3d,atx,aty,atz);
if (idx*sizeof(double) < h3[h3d]->size ) return h3[h3d]->data[idx];
 
 
return 0;
}
 
 
int H3DInit(int h3d,char *name, char *title,int nx, double minx, double stepx, int ny, double miny, double stepy, int nz, double minz, double stepz) {
 
if (h3[h3d]) {
 
free(h3[h3d]->data);
free(h3[h3d]);
h3[h3d] = NULL;
}
//printf("InitH3D hID=%d\n",h3d);
h3[h3d] = (H3D *) malloc(sizeof(H3D));
//h2 =h3d;
 
H3DSetTitle(h3d,title);
H3DSetName(h3d,name);
h3[h3d]->id=H3D_ID;
h3[h3d]->nx = nx;
h3[h3d]->ny = ny;
h3[h3d]->nz = nz;
 
h3[h3d]->minx = minx;
h3[h3d]->miny = miny;
h3[h3d]->minz = minz;
 
h3[h3d]->stepx = stepx;
h3[h3d]->stepy = stepy;
h3[h3d]->stepz = stepz;
 
h3[h3d]->size = h3[h3d]->nx*h3[h3d]->ny*h3[h3d]->nz*sizeof(double);
h3[h3d]->data = (double *) malloc(h3[h3d]->size);
h3[h3d]->len=sizeof(H3D)-sizeof(double *)+h3[h3d]->size;
H3DClear(h3d);
H3DPrint(h3d);
//Printf("InitH3D 0x%x\n", h3d );
return 0;
 
}
 
 
double H3DGetXBinCenter(int h3d,int xbin) {
return h3[h3d]->minx+xbin*h3[h3d]->stepx;
}
 
double H3DGetYBinCenter(int h3d,int ybin) {
return h3[h3d]->miny+ybin*h3[h3d]->stepy;
}
 
double H3DGetZBinCenter(int h3d,int zbin) {
return h3[h3d]->minz+zbin*h3[h3d]->stepz;
}
 
 
int H3DWrite2File(int h3d,FILE *fp) {
 
if (!fp) return -1;
//printf("H3D sizeof(H3D)=%lu len-datasize=%d len=%lu datasize=%d\t",sizeof(H3D)-sizeof(double *),h3[h3d]->len-h3[h3d]->size,h3[h3d]->len,h3[h3d]->size);
//printf("H3D sz=%d %d\n",sizeof(double),sizeof(double *));
fwrite (h3[h3d], 1, sizeof(H3D)-sizeof(double *), fp);
fwrite (h3[h3d]->data, 1, h3[h3d]->size, fp);
return 0;
}
 
int H3DWrite(int h3d,const char *fname,const char *opt) {
FILE *fp=fopen(fname,opt);
H3DWrite2File(h3d,fp);
fclose(fp);
return 0;
}
 
 
 
 
int H3DSetTitle(int h3d,char *title) {
sprintf(h3[h3d]->title,"%s",title);
return 0;
}
 
 
int H3DSetTitleX(int h3d,char *title) {
sprintf(h3[h3d]->titlex,"%s",title);
return 0;
}
 
 
int H3DSetTitleY(int h3d,char *title) {
sprintf(h3[h3d]->titley,"%s",title);
return 0;
}
 
int H3DSetTitleZ(int h3d,char *title) {
sprintf(h3[h3d]->titlez,"%s",title);
return 0;
}
 
 
int H3DSetName(int h3d,char *title) {
sprintf(h3[h3d]->name,"%s",title);
return 0;
}
 
int H3DGetNbinsY(int h) {
if (h3[h]) return h3[h]->ny;
else return 0;
}
 
int H3DGetNbinsX(int h) {
if (h3[h]) return h3[h]->nx;
else return 0;
}
 
int H3DGetNbinsZ(int h) {
if (h3[h]) return h3[h]->nz;
else return 0;
}
 
 
 
double H3DGetMinX(int h) {
if (h3[h]) return h3[h]->minx;
else return 0;
}
 
double H3DGetMinY(int h) {
if (h3[h]) return h3[h]->miny;
else return 0;
}
 
double H3DGetMinZ(int h) {
if (h3[h]) return h3[h]->minz;
else return 0;
}
 
 
 
 
double H3DGetStepX(int h) {
if (h3[h]) return h3[h]->stepx;
else return 0;
}
 
double H3DGetStepY(int h) {
if (h3[h]) return h3[h]->stepy;
else return 0;
}
 
double H3DGetStepZ(int h) {
if (h3[h]) return h3[h]->stepz;
else return 0;
}
 
 
 
 
double H3DGetMin(int h) {
if (h3[h]) return h3[h]->min;
else return 0;
}
 
double H3DGetMax(int h) {
if (h3[h]) return h3[h]->max;
else return 0;
}
 
double * H3DGetSliceXYData(int h, int slice) {
if (h3[h]) return (h3[h]->data+slice*h3[h]->nx*h3[h]->ny);
else return NULL;
}
 
double * H3DGetData(int h) {
if (h3[h]) return h3[h]->data;
else return NULL;
}
 
/cvi/apps/sa02_daq/cvi/H3D.h
0,0 → 1,73
#ifndef _H3D_H_
#define _H3D_H_
 
/* 2d histogramming */
#define H3D_ID 0x12
#pragma pack(4)
typedef struct
{
unsigned int id,len;
unsigned int nx;
unsigned int ny;
unsigned int nz;
int nentries;
unsigned int size;
double min;
double max;
double minx;
double miny;
double minz;
double stepx;
double stepy;
double stepz;
char name[20];
char title[100];
char titlex[40];
char titley[40];
char titlez[40];
double *data;
}H3D;
#pragma pack()
 
 
double H3DGetYBinCenter(int h3d,int ybin);
double H3DGetYBinCenter(int h3d,int xbin);
 
int H3DClear(int h3d);
int H3DPrint(int h3d);
int H3DExist(int h3d);
int H3DCalculateBin(int h3d, int axis, double value);
int H3DGetBin(int h3d,int x, int y, int z);
int H3DFill(int h3d,double x, double y, double z, double val);
int H3DFillBin(int h3d,int x, int y, int z, double val);
double H3DGetBinContent(int h3d,int atx, int aty, int atz);
int H3DInit(int h3d,char *name, char *title,int nx, double minx, double stepx, int ny, double miny, double stepy,int nz, double minz, double stepz);
int H3DWrite(int h3d,const char *fname,const char*opt);
int H3DWrite2File(int h3d,FILE *fp);
int H3DSetTitle(int h3d,char *title);
int H3DSetTitleX(int h3d,char *title);
int H3DSetTitleY(int h3d,char *title);
int H3DSetTitleZ(int h3d,char *title);
int H3DSetName(int h3d,char *title);
 
int H3DGetNbinsY(int h);
int H3DGetNbinsX(int h);
int H3DGetNbinsZ(int h);
 
double H3DGetMinX(int h);
double H3DGetMinY(int h);
double H3DGetMinZ(int h);
 
 
double H3DGetStepX(int h);
double H3DGetStepY(int h);
double H3DGetStepZ(int h);
 
double H3DGetMin(int h);
double H3DGetMax(int h);
double * H3DGetSliceXYData(int h, int slice);
double * H3DGetData(int h);
 
#endif
/cvi/apps/sa02_daq/cvi/HDraw.c
0,0 → 1,169
#include <userint.h>
#include "CAEN_V729_CVI.h"
#include "HDraw.h"
#include "H3D.h"
#include "H2D.h"
#include "H1D.h"
 
HColorMap *colormap = NULL;
 
int hmapinit=0;
 
int InitColors(void) {
if (!hmapinit) {
colormap = malloc(sizeof(HColorMap));
 
colormap->numberofColors = 5;
colormap->array = malloc(colormap->numberofColors*sizeof(ColorMapEntry));
 
colormap->array[0].color = 0x0000ff; //BLUE
colormap->array[1].color = 0x00ff00; //GREEN
colormap->array[2].color = 0xffff00; //YELLOW
colormap->array[3].color = 0xff8000; //ORANGE
colormap->array[4].color = 0xff0000; //RED
 
colormap->HiColor =colormap->array[colormap->numberofColors-1].color ;
hmapinit=1;
 
return 0;
}
return -1;
}
 
 
 
HColorMap *GetColorMapPtr(void) {
return colormap;
}
 
 
int RangeColors( double min, double max) {
int i;
if (!hmapinit) InitColors();
 
//if (zerosuppress){
// if (min>0) min=0;
//}
if (colormap->numberofColors<2) return -1;
for (i=0; i<colormap->numberofColors; i++) {
 
colormap->array[i].dataValue.valDouble=i*(max-min)/(colormap->numberofColors-1)+min;
//sa02Printf("Colors %d ;%f %f %f\n",i, min,max,colormap->array[i].dataValue.valDouble );
 
}
return 0;
}
 
int H3DDrawSliceXY(int histogram,int slice,int panel, int control, int *plothandle) {
int i=0;
if (!H2DExist(histogram)) {
printf("2D Histogram %d does not exist!\n",histogram);
return 0;
}
 
 
if (H3DGetNbinsY(histogram)==1|| H3DGetNbinsX(histogram)==1) {
if (H3DGetNbinsY(histogram)==1) {
H1DInit(499,"projection","projection", H3DGetNbinsX(histogram), H3DGetMinX(histogram),H3DGetStepX(histogram));
for (i=0; i < H3DGetNbinsX(histogram); i++ ) H1DSetBinContent(499,i,H3DGetBinContent(histogram,i,0,slice));
} else {
H1DInit(499,"projection","projection", H3DGetNbinsY(histogram), H3DGetMinY(histogram),H3DGetStepY(histogram));
for (i=0; i < H3DGetNbinsY(histogram); i++ ) H1DSetBinContent(499,i,H3DGetBinContent(histogram,0,i,slice));
}
H1DDraw(499, panel, control, plothandle);
} else {
 
if (*plothandle> 0 ) DeleteGraphPlot (panel, control, *plothandle, VAL_IMMEDIATE_DRAW);
RangeColors(H3DGetMin(histogram),H3DGetMax(histogram));
*plothandle = PlotScaledIntensity (panel, control,
H3DGetSliceXYData(histogram, slice),
H3DGetNbinsX(histogram),
H3DGetNbinsY(histogram),
VAL_DOUBLE,
H3DGetStepY(histogram),
H3DGetMinY(histogram),
H3DGetStepX(histogram),
H3DGetMinX(histogram),
colormap->array,
colormap->HiColor,
colormap->numberofColors, 1, 0);
}
ProcessSystemEvents ();
return *plothandle;
 
}
 
 
 
 
 
int H2DDraw(int histogram,int panel, int control, int *plothandle) {
int i=0;
if (!H2DExist(histogram)) {
printf("2D Histogram %d does not exist!\n",histogram);
return 0;
}
 
 
if (H2DGetNbinsY(histogram)==1|| H2DGetNbinsX(histogram)==1) {
if (H2DGetNbinsY(histogram)==1) {
H1DInit(499,"projection","projection", H2DGetNbinsX(histogram), H2DGetMinX(histogram),H2DGetStepX(histogram));
for (i=0; i < H2DGetNbinsX(histogram); i++ ) H1DSetBinContent(499,i,H2DGetBinContent(histogram,i,0));
} else {
H1DInit(499,"projection","projection", H2DGetNbinsY(histogram), H2DGetMinY(histogram),H2DGetStepY(histogram));
for (i=0; i < H2DGetNbinsY(histogram); i++ ) H1DSetBinContent(499,i,H2DGetBinContent(histogram,0,i));
}
H1DDraw(499, panel, control, plothandle);
} else {
if (*plothandle> 0 ) DeleteGraphPlot (panel, control, *plothandle, VAL_IMMEDIATE_DRAW);
double min = H2DGetMin(histogram);
double max = H2DGetMax(histogram);
RangeColors(min,max);
*plothandle = PlotScaledIntensity (panel, control,
H2DGetData(histogram),
H2DGetNbinsX(histogram),
H2DGetNbinsY(histogram),
VAL_DOUBLE,
H2DGetStepY(histogram),
H2DGetMinY(histogram),
H2DGetStepX(histogram),
H2DGetMinX(histogram),
colormap->array,
colormap->HiColor,
colormap->numberofColors, 1, 0);
}
ProcessSystemEvents ();
return *plothandle;
 
}
 
 
unsigned int hcolors[8]={VAL_RED, VAL_GREEN, VAL_BLUE, VAL_CYAN, VAL_MAGENTA, VAL_YELLOW, VAL_GRAY, VAL_BLACK};
 
int H1DDraw(int histogram,int panel, int control, int *plothandle) {
if (!H1DExist(histogram)) {
printf("1D Histogram %d does not exist!\n",histogram);
return 0;
}
if (*plothandle> 0 ) DeleteGraphPlot (panel, control, *plothandle, VAL_IMMEDIATE_DRAW);
 
*plothandle = PlotWaveform (panel, control, H1DGetData(histogram), H1DGetNbinsX(histogram), VAL_DOUBLE, 1, 0, H1DGetMinX(histogram), H1DGetStepX(histogram), VAL_FAT_LINE, VAL_SMALL_SOLID_SQUARE, VAL_SOLID, 1,
hcolors[histogram%8]);
ProcessSystemEvents ();
return *plothandle;
 
}
 
int EstimatedFinish(int panel, int slider,int txt, time_t tstart, double fraction) {
 
time_t t, tend=tstart;
time(&t);
if (fraction>0) tend= ((double)(t-tstart))/fraction + tstart;
SetCtrlVal(panel, txt, ctime(&tend));
SetCtrlVal(panel, slider, 100*fraction);
 
return 0;
 
}
 
 
/cvi/apps/sa02_daq/cvi/HDraw.h
0,0 → 1,19
#ifndef _HDRAW_H_
#define _HDRAW_H_
#include "toolbox.h"
 
typedef struct {
ColorMapEntry *array;
int numberofColors;
int HiColor;
} HColorMap;
 
HColorMap *GetColorMapPtr(void);
int InitColors(void);
int RangeColors(double min, double max);
 
int H3DDrawSliceXY(int histogram,int slice,int panel, int control, int *plothandle);
int H2DDraw(int histogram,int panel, int control, int *plothandle);
int H1DDraw(int histogram,int panel, int control, int *plothandle);
int EstimatedFinish(int panel, int slider,int txt, time_t start, double fraction);
#endif _HDRAW_H_
/cvi/apps/sa02_daq/cvi/ICFA/icfa.c
0,0 → 1,273
#include "vme.h"
#include <userint.h>
#include "minirich.h"
#include "toolbox.h"
#include "icfa.h"
#include "H1D.h"
#include "H2D.h"
#include "H3D.h"
#include "HDraw.h"
 
 
 
int p6h;
int hxy=200;
int minirichplothandle=0;
 
int sa02Printf(const char *format, ...);
 
typedef struct {
int feb;
int chip;
int ch;
int chx;
int chy;
int pmtx;
int pmty;
int pmtid
} EID2MAPMT;
 
EID2MAPMT eid2mapmt[144*4];
 
 
int icfa_LoadElectronicMap(const char *fname) {
 
FILE *fp = fopen(fname,"r");
int febidx, feb,chip,ch,chx,chy,pmtx,pmty,pmt;
int nread=0;
int ndim=400;
char line[400];
int nr=0;
// file should be sorted feb [0..3], chip[0..3], ch [0.. 35]
while (fgets(line,ndim,fp)!=NULL) {
// FEBCH PMTCH X Y PMTX PMTY PMTID
 
nr = sscanf(line,"%d%d%d%d%d",&febidx,&ch,&chx,&chy,&pmt);
if (nr) {
chip = febidx / 36;
ch = febidx % 36;
pmtx = pmt / 3;
pmty = pmt % 3;
for (feb = 0; feb<4; feb++){
// 4 febs
// 0 2
// 1 3
int fx = feb %2;
int fy = feb /2;
eid2mapmt[nread+feb*144].feb = feb;
eid2mapmt[nread+feb*144].chip = chip;
eid2mapmt[nread+feb*144].ch = ch ;
eid2mapmt[nread+feb*144].chx = chx + fx * 18;
eid2mapmt[nread+feb*144].chy = chy + fy * 18;
eid2mapmt[nread+feb*144].pmtx = pmtx ;
eid2mapmt[nread+feb*144].pmty = pmty ;
}
}
nread++;
}
sa02Printf("eid2pmtxy %d records read.\n",nread);
fclose(fp);
return 0;
 
}
 
 
int icfa_GetPosition(unsigned int febchid, int *chx, int *chy) {
 
if (febchid>=144*4) return -1;
*chx = eid2mapmt[febchid].chx;
*chy = eid2mapmt[febchid].chy ;
return 0;
}
 
int icfa_Fill(int febchid, double weight){
int x;
int y;
icfa_GetPosition(febchid, &x, &y);
H2DFillBin(hxy, x,y,weight);
return 0;
}
 
 
 
int icfa_Init(){ // read mapmt mapping
 
icfa_LoadElectronicMap("eid2pmtxy.map");
//short VMUSB_VME_DGG(unsigned short channel, unsigned short trigger,unsigned short output,
// long delay, unsigned short gate, unsigned short invert, unsigned short latch);
// set DGG 1 to create ADC gate, I1 -> O1 delay:0, gate 0x400 = 12us
WIENER_VMUSB_VME_DGG(0,1,0,0x0,0x100,0,0);
/*
channel
[in] The DGG channel you wish to modify. Valid values are:
0 – For DGG channel A
1 – For DGG channel B
trigger
[in] Determines the start of the DGG. Valid Values are:
0 – Channel Disabled
1 – NIM input 1
2 – NIM input 2
3 – Event Trigger
4 - End of Event
5 - USB Trigger
6 - Pulser
output
[in] Determines the NIM ouput used for the DGG channel. Valid values are:
0 – NIM O1
1 – NIM O2
delay
[in] 32 bit word in steps of 12.5ns between trigger and start of gate consisting of
lower 16 bits: Delay_fine
upper 16 bits: Delay_coarse
gate
[in] Sets the length of the gate in units of 12.5ns
invert
[in] Determines whether or not the DGG is inverted. Valid values are:
0 – Not inverted
1 – Is inverted
latch
[in] Determines whether or not the DGG is latched. Valid values are:
0 – Not latched
1 – Is latched
*/
// User Devices Source Selector - Read/Write Offset = 16 0x10
// xxusb_register_write(udev, XXUSB_ACTION_REGISTER, 0x2); // USB Trigger
WIENER_VMUSB_VME_DGG(0,5,0,0xF,0xF,0,0);
//WIENER_VMUSB_VME_Output_settings(0,7,0,0); // nekaj od tega bi moralo delat
WIENER_VMUSB_register_write(10,0x2); // USB Trigger
 
 
return 0;
}
 
int icfa_Histo(){ // read mapmt mapping
 
H2DInit(hxy,"minirich","MiniRICH hit map",36,0, 1,36,0, 1);
H2DSetTitleX(hxy,"x (channels)");
H2DSetTitleY(hxy,"y (channels)");
return 0;
}
 
int icfa_Draw(){
if (minirichplothandle > 0 ) {
DeleteGraphPlot (p6h, MINIRICH_GRAPH, minirichplothandle, VAL_IMMEDIATE_DRAW);
minirichplothandle=0;
}
H2DDraw(hxy,p6h, MINIRICH_GRAPH, &minirichplothandle);
return 0;
}
 
int icfa_Event(uint32_t *d, int mode){
if (!mode) H2DClear(hxy);
for (int i=0;i<144*4;i++){
if (d[i]>0) icfa_Fill(i,d[i]);
}
return 0;
}
 
int CVICALLBACK daq_icfa(void *functionData) {
int neve;
int threshold;
icfa_Init();
GetCtrlVal(p6h,MINIRICH_NEVE, &neve);
GetCtrlVal(p6h,MINIRICH_THR, &threshold);
icfa_Histo();
for (int k=0;k<144*4;k++){
int i = Random(0,144*4);
icfa_Fill(k,1);
}
icfa_Draw(hxy);
return 0;
}
 
 
int CVICALLBACK rich_Draw_RingCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
static int oh1=0;
static int oh2=0;
switch (event) {
case EVENT_COMMIT: {
double min_r;
double max_r;
double x,y;
GetCtrlVal (p6h, MINIRICH_R_MIN, &min_r ) ;
GetCtrlVal (p6h, MINIRICH_R_MAX, &max_r ) ;
double r1=min_r*2.0 ;
double r2=max_r*2.0 ;
GetGraphCursor (p6h, MINIRICH_GRAPH, 1, &x, &y);
sa02Printf ( "x:%5.2f\ty:%5.2f OH1=%d OH2=%d\n", x, y, oh1, oh2 ) ;
 
if (oh1 > 0 ) {
DeleteGraphPlot (p6h, MINIRICH_GRAPH, oh1, VAL_IMMEDIATE_DRAW);
oh1=0;
}
if (oh2 > 0 ) {
DeleteGraphPlot (p6h, MINIRICH_GRAPH, oh2, VAL_IMMEDIATE_DRAW);
oh2=0;
}
oh1 = PlotOval (p6h, MINIRICH_GRAPH, x-r1, y-r1, x+r1, y+r1, VAL_RED, VAL_TRANSPARENT);
oh2 = PlotOval (p6h, MINIRICH_GRAPH, x-r2, y-r2, x+r2, y+r2, VAL_RED, VAL_TRANSPARENT);
break;
}
}
return 0;
}
 
int CVICALLBACK rich_Histo_ClearCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
switch (event) {
case EVENT_COMMIT:
H2DClear(hxy);
icfa_Draw();
break;
}
return 0;
}
 
int CVICALLBACK icfa_StartCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
switch (event) {
case EVENT_COMMIT:
daq_icfa(NULL);
break;
}
return 0;
}
 
extern HColorMap *colormap;
int CVICALLBACK SetMaximum (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
switch (event) {
case EVENT_COMMIT:
if (minirichplothandle> 0 ) DeleteGraphPlot (panel, MINIRICH_GRAPH, minirichplothandle, VAL_IMMEDIATE_DRAW);
int histogram=hxy;
double min = H2DGetMin(histogram);
double fx=0;
GetCtrlVal(p6h,MINIRICH_MAXZ, &fx);
double max = H2DGetMax(histogram)*fx/100.;
RangeColors(min,max);
minirichplothandle = PlotScaledIntensity (panel, MINIRICH_GRAPH,
H2DGetData(histogram),
H2DGetNbinsX(histogram),
H2DGetNbinsY(histogram),
VAL_DOUBLE,
H2DGetStepY(histogram),
H2DGetMinY(histogram),
H2DGetStepX(histogram),
H2DGetMinX(histogram),
colormap->array,
colormap->HiColor,
colormap->numberofColors, 1, 0);
break;
}
return 0;
}
/cvi/apps/sa02_daq/cvi/ICFA/icfa.h
0,0 → 1,22
//==============================================================================
//
// Title: icfa.h
// Purpose: A short description of the interface.
//
// Created on: 11/25/2017 at 11:40:55 AM by rok.
// Copyright: . All Rights Reserved.
//
//==============================================================================
 
#ifndef __icfa_H__
#define __icfa_H__
 
#include "minirich.h"
#include <stdint.h>
extern int p6h;
int CVICALLBACK daq_icfa(void *functionData);
int icfa_Init();
int icfa_Event(uint32_t *d, int mode);
int icfa_Draw();
int icfa_Histo();
#endif /* ndef __icfa_H__ */
/cvi/apps/sa02_daq/cvi/ICFA/minirich.h
0,0 → 1,59
/**************************************************************************/
/* LabWindows/CVI User Interface Resource (UIR) Include File */
/* */
/* WARNING: Do not add to, delete from, or otherwise modify the contents */
/* of this include file. */
/**************************************************************************/
 
#include <userint.h>
 
#ifdef __cplusplus
extern "C" {
#endif
 
/* Panels and Controls: */
 
#define MINIRICH 1
#define MINIRICH_GRAPH 2 /* control type: graph, callback function: (none) */
#define MINIRICH_CLEAR 3 /* control type: command, callback function: rich_Histo_ClearCB */
#define MINIRICH_DRAWRING 4 /* control type: command, callback function: rich_Draw_RingCB */
#define MINIRICH_CLOSE 5 /* control type: command, callback function: HidePanelCB */
#define MINIRICH_STOP 6 /* control type: command, callback function: (none) */
#define MINIRICH_START 7 /* control type: command, callback function: (none) */
#define MINIRICH_TEST 8 /* control type: command, callback function: icfa_StartCB */
#define MINIRICH_THR 9 /* control type: numeric, callback function: (none) */
#define MINIRICH_NEVE 10 /* control type: numeric, callback function: (none) */
#define MINIRICH_ADD 11 /* control type: radioButton, callback function: (none) */
#define MINIRICH_R_MAX 12 /* control type: numeric, callback function: (none) */
#define MINIRICH_R_MIN 13 /* control type: numeric, callback function: (none) */
#define MINIRICH_PROC 14 /* control type: scale, callback function: (none) */
#define MINIRICH_TRIG 15 /* control type: numeric, callback function: (none) */
#define MINIRICH_A0A1 16 /* control type: numeric, callback function: (none) */
#define MINIRICH_NEVNT 17 /* control type: numeric, callback function: (none) */
#define MINIRICH_REFIND 18 /* control type: numeric, callback function: (none) */
#define MINIRICH_MINHIT 19 /* control type: numeric, callback function: (none) */
#define MINIRICH_MAXZ 20 /* control type: scale, callback function: SetMaximum */
 
 
/* Control Arrays: */
 
/* (no control arrays in the resource file) */
 
 
/* Menu Bars, Menus, and Menu Items: */
 
/* (no menu bars in the resource file) */
 
 
/* Callback Prototypes: */
 
int CVICALLBACK HidePanelCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
int CVICALLBACK icfa_StartCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
int CVICALLBACK rich_Draw_RingCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
int CVICALLBACK rich_Histo_ClearCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
int CVICALLBACK SetMaximum(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
 
 
#ifdef __cplusplus
}
#endif
/cvi/apps/sa02_daq/cvi/ICFA/minirich.tui
0,0 → 1,1324
[TUI File Header]
Version = 102
Platform Code = 4
Screen Width = 1366
Screen Height = 768
 
[Panel001]
ATTR_DIMMED = False
ATTR_CONSTANT_NAME = "MINIRICH"
ATTR_CALLBACK_NAME = ""
ATTR_VISIBLE = True
ATTR_LEFT = 3
ATTR_TOP = 21
ATTR_WIDTH = 1085
ATTR_ZPLANE_POSITION = 0
ATTR_HEIGHT = 634
ATTR_FRAME_COLOR = 0XF0F0F0
ATTR_SCROLL_BARS = VAL_NO_SCROLL_BARS
ATTR_SCROLL_BAR_COLOR = 0XF0F0F0
ATTR_HSCROLL_OFFSET = 0
ATTR_BACKCOLOR = 0XF0F0F0
ATTR_TITLEBAR_VISIBLE = True
ATTR_TITLEBAR_THICKNESS = 18
ATTR_TITLEBAR_STYLE = VAL_WINDOWS_STYLE
ATTR_SCROLL_BAR_STYLE = VAL_LAB_STYLE
ATTR_TITLE = "MA Pmt RICH"
ATTR_TITLE_COLOR = VAL_BLACK
ATTR_TITLE_BACKCOLOR = 0XF0F0F0
ATTR_FRAME_STYLE = VAL_BEVELLED_FRAME
ATTR_SIZABLE = True
ATTR_MOVABLE = True
ATTR_TITLE_FONT = VAL_DIALOG_FONT
ATTR_TITLE_ITALIC = False
ATTR_TITLE_UNDERLINE = False
ATTR_TITLE_STRIKEOUT = False
ATTR_TITLE_POINT_SIZE = 10
ATTR_TITLE_BOLD = False
ATTR_TITLE_CHARACTER_SET = VAL_NATIVE_CHARSET
ATTR_PARENT_SHARES_SHORTCUT_KEYS = True
ATTR_ACTIVATE_WHEN_CLICKED_ON = True
ATTR_WINDOW_ZOOM = VAL_NO_ZOOM
ATTR_CAN_MINIMIZE = True
ATTR_CAN_MAXIMIZE = True
ATTR_SCALE_CONTENTS_ON_RESIZE = False
ATTR_MIN_HEIGHT_FOR_SCALING = 0
ATTR_MIN_WIDTH_FOR_SCALING = 0
ATTR_RESOLUTION_ADJUSTMENT = 50
ATTR_FLOATING = VAL_FLOAT_NEVER
ATTR_CONFORM_TO_SYSTEM = False
ATTR_CONFORM_TO_SYSTEM_THEME = True
ATTR_CLOSE_ITEM_VISIBLE = True
ATTR_SYSTEM_MENU_VISIBLE = True
ATTR_TITLE_SIZE_TO_FONT = True
ATTR_AUTO_CENTER_H_WHEN_LOADED = True
ATTR_AUTO_CENTER_V_WHEN_LOADED = True
ATTR_HAS_TASKBAR_BUTTON = False
ATTR_VSCROLL_OFFSET = 0
ATTR_FRAME_THICKNESS = 3
ATTR_MOUSE_CURSOR = VAL_DEFAULT_CURSOR
ATTR_PANEL_MENU_BAR_CONSTANT = ""
 
[Panel001_Control001]
ATTR_DIMMED = False
ATTR_CONSTANT_NAME = "GRAPH"
ATTR_CALLBACK_NAME = ""
ATTR_VISIBLE = True
ATTR_LEFT = 202
ATTR_TOP = 27
ATTR_WIDTH = 742
ATTR_ZPLANE_POSITION = 18
ATTR_HEIGHT = 593
ATTR_CTRL_STYLE = CTRL_GRAPH_LS
ATTR_INDUCE_CLOSE_CTRL = False
ATTR_TOOLTIP_TEXT = ""
ATTR_TOOLTIP_DELAY = 1000
ATTR_TOOLTIP_HIDE_DELAY = 0
ATTR_DISABLE_CTRL_TOOLTIP = False
ATTR_HIDDEN_WHEN_LOADED = False
ATTR_CTRL_MODE = VAL_HOT
ATTR_CTRL_TAB_POSITION = 0
ATTR_LABEL_COLOR = VAL_BLACK
ATTR_LABEL_TEXT = "Event Display"
ATTR_LABEL_FONT = VAL_DIALOG_FONT
ATTR_LABEL_ITALIC = False
ATTR_LABEL_UNDERLINE = False
ATTR_LABEL_STRIKEOUT = False
ATTR_LABEL_POINT_SIZE = 10
ATTR_LABEL_BOLD = False
ATTR_LABEL_CHARACTER_SET = VAL_NATIVE_CHARSET
ATTR_LABEL_VISIBLE = True
ATTR_LABEL_JUSTIFY = VAL_LEFT_JUSTIFIED
ATTR_LABEL_ANGLE = 0
ATTR_LABEL_LEFT = 272
ATTR_LABEL_TOP = 7
ATTR_LABEL_WIDTH = 73
ATTR_LABEL_HEIGHT = 15
ATTR_LABEL_RAISED = False
ATTR_LABEL_SIZE_TO_TEXT = True
ATTR_LABEL_BGCOLOR = 0XF0F0F0
ATTR_ADJUST_DATA_TYPE_WHEN_LOADED = False
ATTR_SHORTCUT_KEY = 0
ATTR_GRID_COLOR = VAL_BLACK
ATTR_GRID_STYLE = 0
ATTR_PLOT_BGCOLOR = VAL_BLACK
ATTR_XYNAME_FONT = VAL_DIALOG_FONT
ATTR_XYNAME_COLOR = VAL_BLACK
ATTR_XLABEL_FONT = VAL_DIALOG_FONT
ATTR_XLABEL_FONT (TOP) = VAL_DIALOG_FONT
ATTR_YLABEL_FONT = VAL_DIALOG_FONT
ATTR_YLABEL_FONT (RIGHT) = VAL_DIALOG_FONT
ATTR_XLABEL_COLOR = VAL_BLACK
ATTR_XLABEL_COLOR (TOP) = VAL_BLACK
ATTR_YLABEL_COLOR = VAL_BLACK
ATTR_YLABEL_COLOR (RIGHT) = VAL_BLACK
ATTR_XNAME = ""
ATTR_XNAME (TOP) = ""
ATTR_XGRID_VISIBLE = True
ATTR_XGRID_VISIBLE (TOP) = False
ATTR_XMINORGRID_VISIBLE = False
ATTR_XMINORGRID_VISIBLE (TOP) = False
ATTR_XLABEL_VISIBLE = True
ATTR_XLABEL_VISIBLE (TOP) = False
ATTR_XFORMAT = VAL_FLOATING_PT_FORMAT
ATTR_XFORMAT (TOP) = VAL_FLOATING_PT_FORMAT
ATTR_XDIVISIONS = VAL_AUTO
ATTR_XDIVISIONS (TOP) = VAL_AUTO
ATTR_XPRECISION = VAL_AUTO
ATTR_XPRECISION (TOP) = VAL_AUTO
ATTR_XPADDING = 0
ATTR_XPADDING (TOP) = 0
ATTR_XENG_UNITS = 0
ATTR_XENG_UNITS (TOP) = 0
ATTR_XUSE_LABEL_STRINGS = False
ATTR_XUSE_LABEL_STRINGS (TOP) = False
ATTR_XAXIS_GAIN = 1.00000000000000E+0
ATTR_XAXIS_GAIN (TOP) = 1.00000000000000E+0
ATTR_XAXIS_OFFSET = 0.00000000000000E+0
ATTR_XAXIS_OFFSET (TOP) = 0.00000000000000E+0
ATTR_YNAME = "Y"
ATTR_YNAME (RIGHT) = ""
ATTR_YGRID_VISIBLE = True
ATTR_YGRID_VISIBLE (RIGHT) = False
ATTR_YMINORGRID_VISIBLE = True
ATTR_YMINORGRID_VISIBLE (RIGHT) = False
ATTR_YLABEL_VISIBLE = True
ATTR_YLABEL_VISIBLE (RIGHT) = False
ATTR_YMAP_MODE = VAL_LINEAR
ATTR_YMAP_MODE (RIGHT) = VAL_LINEAR
ATTR_YFORMAT = VAL_FLOATING_PT_FORMAT
ATTR_YFORMAT (RIGHT) = VAL_FLOATING_PT_FORMAT
ATTR_YDIVISIONS = VAL_AUTO
ATTR_YDIVISIONS (RIGHT) = VAL_AUTO
ATTR_YPRECISION = VAL_AUTO
ATTR_YPRECISION (RIGHT) = VAL_AUTO
ATTR_YPADDING = 0
ATTR_YPADDING (RIGHT) = 0
ATTR_YENG_UNITS = 0
ATTR_YENG_UNITS (RIGHT) = 0
ATTR_YREVERSE = False
ATTR_YREVERSE (RIGHT) = False
ATTR_YUSE_LABEL_STRINGS = False
ATTR_YUSE_LABEL_STRINGS (RIGHT) = False
ATTR_YAXIS_GAIN = 1.00000000000000E+0
ATTR_YAXIS_GAIN (RIGHT) = 1.00000000000000E+0
ATTR_YAXIS_OFFSET = 0.00000000000000E+0
ATTR_YAXIS_OFFSET (RIGHT) = 0.00000000000000E+0
ATTR_EDGE_STYLE = VAL_RAISED_EDGE
ATTR_BORDER_VISIBLE = True
ATTR_FIXED_PLOT_AREA = False
ATTR_XYNAME_BOLD = False
ATTR_XYNAME_CHARACTER_SET = VAL_NATIVE_CHARSET
ATTR_XYNAME_ITALIC = False
ATTR_XYNAME_UNDERLINE = False
ATTR_XYNAME_STRIKEOUT = False
ATTR_XYNAME_POINT_SIZE = 10
ATTR_XLABEL_BOLD = False
ATTR_XLABEL_BOLD (TOP) = False
ATTR_XLABEL_CHARACTER_SET = VAL_NATIVE_CHARSET
ATTR_XLABEL_CHARACTER_SET (TOP) = VAL_NATIVE_CHARSET
ATTR_YLABEL_BOLD = False
ATTR_YLABEL_BOLD (RIGHT) = False
ATTR_YLABEL_CHARACTER_SET = VAL_NATIVE_CHARSET
ATTR_YLABEL_CHARACTER_SET (TOP) = VAL_NATIVE_CHARSET
ATTR_XLABEL_ANGLE = 0
ATTR_XLABEL_ANGLE (TOP) = 0
ATTR_YLABEL_ANGLE = 0
ATTR_YLABEL_ANGLE (RIGHT) = 0
ATTR_XLABEL_ITALIC = False
ATTR_XLABEL_ITALIC (TOP) = False
ATTR_YLABEL_ITALIC = False
ATTR_YLABEL_ITALIC (RIGHT) = False
ATTR_XLABEL_UNDERLINE = False
ATTR_XLABEL_UNDERLINE (TOP) = False
ATTR_YLABEL_UNDERLINE = False
ATTR_YLABEL_UNDERLINE (RIGHT) = False
ATTR_XLABEL_STRIKEOUT = False
ATTR_XLABEL_STRIKEOUT (TOP) = False
ATTR_YLABEL_STRIKEOUT = False
ATTR_YLABEL_STRIKEOUT (RIGHT) = False
ATTR_XLABEL_POINT_SIZE = 10
ATTR_XLABEL_POINT_SIZE (TOP) = 10
ATTR_YLABEL_POINT_SIZE = 10
ATTR_YLABEL_POINT_SIZE (RIGHT) = 10
ATTR_GRAPH_BGCOLOR = 0XF0F0F0
ATTR_ANTI_ALIASED_PLOTS = False
ATTR_LEGEND_VISIBLE = False
ATTR_LEGEND_TOP = 557
ATTR_LEGEND_LEFT = 949
ATTR_LEGEND_WIDTH = 70
ATTR_LEGEND_HEIGHT = 33
ATTR_LEGEND_FRAME_COLOR = 0XF0F0F0
ATTR_LEGEND_PLOT_BGCOLOR = VAL_BLACK
ATTR_LEGEND_AUTO_SIZE = True
ATTR_LEGEND_INTERACTIVE = False
ATTR_LEGEND_SHOW_SAMPLES = True
ATTR_INNER_MARKERS_VISIBLE = False
ATTR_PLOT_AREA_TOP = 8
ATTR_PLOT_AREA_LEFT = 58
ATTR_PLOT_AREA_WIDTH = 661
ATTR_PLOT_AREA_HEIGHT = 556
ATTR_NUM_CURSORS = 1
ATTR_NUM_ANNOTATIONS = 0
ATTR_XMAP_MODE = VAL_LINEAR
ATTR_XREVERSE = False
ATTR_XREVERSE (TOP) = False
ATTR_DATA_MODE = VAL_RETAIN
ATTR_COPY_ORIGINAL_DATA = True
ATTR_XMARK_ORIGIN = True
ATTR_XMARK_ORIGIN (TOP) = True
ATTR_YMARK_ORIGIN = True
ATTR_YMARK_ORIGIN (RIGHT) = True
ATTR_SMOOTH_UPDATE = True
ATTR_REFRESH_GRAPH = True
ATTR_SHIFT_TEXT_PLOTS = True
ATTR_ENABLE_ZOOM_AND_PAN = False
ATTR_ZOOM_STYLE = VAL_ZOOM_TO_RECT
ATTR_XLOOSE_FIT_AUTOSCALING = False
ATTR_XLOOSE_FIT_AUTOSCALING (TOP) = False
ATTR_YLOOSE_FIT_AUTOSCALING = False
ATTR_YLOOSE_FIT_AUTOSCALING (RIGHT) = False
ATTR_XLOOSE_FIT_AUTOSCALING_UNIT = 2
ATTR_XLOOSE_FIT_AUTOSCALING_UNIT (TOP) = 2
ATTR_YLOOSE_FIT_AUTOSCALING_UNIT = 2
ATTR_YLOOSE_FIT_AUTOSCALING_UNIT (RIGHT) = 2
ATTR_ENABLE_EDITABLE_AXES = True
ATTR_DS_BIND_PLOT_STYLE = VAL_THIN_LINE
ATTR_DS_BIND_POINT_STYLE = VAL_EMPTY_SQUARE
ATTR_DS_BIND_LINE_STYLE = VAL_SOLID
ATTR_DS_BIND_PLOT_COLOR = VAL_WHITE
ATTR_LEGEND_AUTO_DISPLAY = True
ATTR_DATASOCKET_ENABLED = False
ATTR_DATASOCKET_SOURCE = ""
ATTR_DATASOCKET_MODE = VAL_DS_READ
ATTR_ENABLE_ANTI_ALIASING = False
X_Axis_Scaling_Mode = VAL_MANUAL
X_Scale_Min = -5.00000000000000E-1
X_Scale_Max = 3.55000000000000E+1
X_Axis_Scaling_Mode (TOP) = VAL_AUTOSCALE
X_Scale_Min (TOP) = 0.00000000000000E+0
X_Scale_Max (TOP) = 1.00000000000000E+2
X_Scale_AbsDateTimeFormat_0 = "%X\n%x"
X_Scale_AbsDateTimeFormat_1 = "%X\n%x"
Y_Scale_AbsDateTimeFormat_0 = "%X\n%x"
Y_Scale_AbsDateTimeFormat_1 = "%X\n%x"
X_Scale_RelDateTimeFormat_0 = "%H:%M:%S"
X_Scale_RelDateTimeFormat_1 = "%H:%M:%S"
Y_Scale_RelDateTimeFormat_0 = "%H:%M:%S"
Y_Scale_RelDateTimeFormat_1 = "%H:%M:%S"
Y_Axis_Scaling_Mode = VAL_MANUAL
Y_Scale_Min = -5.00000000000000E-1
Y_Scale_Max = 3.55000000000000E+1
Y_Axis_Scaling_Mode (RIGHT) = VAL_MANUAL
Y_Scale_Min (RIGHT) = -5.00000000000000E-1
Y_Scale_Max (RIGHT) = 3.55000000000000E+1
 
[Panel001_Control001_Cursor001]
ATTR_CURSOR_MODE = VAL_FREE_FORM
ATTR_CURSOR_POINT_STYLE = VAL_EMPTY_CIRCLE
ATTR_CROSS_HAIR_STYLE = VAL_SHORT_CROSS
ATTR_CURSOR_COLOR = 0XFF3300
ATTR_CURSOR_YAXIS = VAL_LEFT_YAXIS
ATTR_CURSOR_XAXIS = VAL_BOTTOM_XAXIS
ATTR_CURSOR_ENABLED = True
X_Coordinate = 1.75000000000000E+1
Y_Coordinate = 1.74675675675676E+1
Active_Cursor = True
 
[Panel001_Control002]
ATTR_DIMMED = False
ATTR_CONSTANT_NAME = "CLEAR"
ATTR_CALLBACK_NAME = "rich_Histo_ClearCB"
ATTR_VISIBLE = True
ATTR_LEFT = 34
ATTR_TOP = 251
ATTR_WIDTH = 117
ATTR_ZPLANE_POSITION = 11
ATTR_HEIGHT = 24
ATTR_CTRL_STYLE = CTRL_SQUARE_COMMAND_BUTTON_LS
ATTR_INDUCE_CLOSE_CTRL = False
ATTR_TOOLTIP_TEXT = ""
ATTR_TOOLTIP_DELAY = 1000
ATTR_TOOLTIP_HIDE_DELAY = 0
ATTR_DISABLE_CTRL_TOOLTIP = False
ATTR_HIDDEN_WHEN_LOADED = False
ATTR_CTRL_MODE = VAL_HOT
ATTR_CTRL_TAB_POSITION = 1
ATTR_LABEL_COLOR = VAL_BLACK
ATTR_LABEL_TEXT = "Clear Histogram"
ATTR_LABEL_FONT = VAL_DIALOG_FONT
ATTR_LABEL_ITALIC = False
ATTR_LABEL_UNDERLINE = False
ATTR_LABEL_STRIKEOUT = False
ATTR_LABEL_POINT_SIZE = 10
ATTR_LABEL_BOLD = False
ATTR_LABEL_CHARACTER_SET = VAL_NATIVE_CHARSET
ATTR_LABEL_VISIBLE = True
ATTR_ADJUST_DATA_TYPE_WHEN_LOADED = False
ATTR_DFLT_VALUE = 0
ATTR_CMD_BUTTON_COLOR = 0XF0F0F0
ATTR_AUTO_SIZING = VAL_GROW_ONLY
ATTR_SHORTCUT_KEY = 0
 
[Panel001_Control003]
ATTR_DIMMED = False
ATTR_CONSTANT_NAME = "DRAWRING"
ATTR_CALLBACK_NAME = "rich_Draw_RingCB"
ATTR_VISIBLE = True
ATTR_LEFT = 34
ATTR_TOP = 220
ATTR_WIDTH = 117
ATTR_ZPLANE_POSITION = 2
ATTR_HEIGHT = 24
ATTR_CTRL_STYLE = CTRL_SQUARE_COMMAND_BUTTON_LS
ATTR_INDUCE_CLOSE_CTRL = False
ATTR_TOOLTIP_TEXT = ""
ATTR_TOOLTIP_DELAY = 1000
ATTR_TOOLTIP_HIDE_DELAY = 0
ATTR_DISABLE_CTRL_TOOLTIP = False
ATTR_HIDDEN_WHEN_LOADED = False
ATTR_CTRL_MODE = VAL_HOT
ATTR_CTRL_TAB_POSITION = 2
ATTR_LABEL_COLOR = VAL_BLACK
ATTR_LABEL_TEXT = "Draw Ring"
ATTR_LABEL_FONT = VAL_DIALOG_FONT
ATTR_LABEL_ITALIC = False
ATTR_LABEL_UNDERLINE = False
ATTR_LABEL_STRIKEOUT = False
ATTR_LABEL_POINT_SIZE = 10
ATTR_LABEL_BOLD = False
ATTR_LABEL_CHARACTER_SET = VAL_NATIVE_CHARSET
ATTR_LABEL_VISIBLE = True
ATTR_ADJUST_DATA_TYPE_WHEN_LOADED = False
ATTR_DFLT_VALUE = 0
ATTR_CMD_BUTTON_COLOR = 0XF0F0F0
ATTR_AUTO_SIZING = VAL_GROW_ONLY
ATTR_SHORTCUT_KEY = 0
 
[Panel001_Control004]
ATTR_DIMMED = False
ATTR_CONSTANT_NAME = "CLOSE"
ATTR_CALLBACK_NAME = "HidePanelCB"
ATTR_VISIBLE = True
ATTR_LEFT = 34
ATTR_TOP = 282
ATTR_WIDTH = 117
ATTR_ZPLANE_POSITION = 12
ATTR_HEIGHT = 24
ATTR_CTRL_STYLE = CTRL_SQUARE_COMMAND_BUTTON_LS
ATTR_INDUCE_CLOSE_CTRL = False
ATTR_TOOLTIP_TEXT = ""
ATTR_TOOLTIP_DELAY = 1000
ATTR_TOOLTIP_HIDE_DELAY = 0
ATTR_DISABLE_CTRL_TOOLTIP = False
ATTR_HIDDEN_WHEN_LOADED = False
ATTR_CTRL_MODE = VAL_HOT
ATTR_CTRL_TAB_POSITION = 3
ATTR_LABEL_COLOR = VAL_BLACK
ATTR_LABEL_TEXT = "Close Window"
ATTR_LABEL_FONT = VAL_DIALOG_FONT
ATTR_LABEL_ITALIC = False
ATTR_LABEL_UNDERLINE = False
ATTR_LABEL_STRIKEOUT = False
ATTR_LABEL_POINT_SIZE = 10
ATTR_LABEL_BOLD = False
ATTR_LABEL_CHARACTER_SET = VAL_NATIVE_CHARSET
ATTR_LABEL_VISIBLE = True
ATTR_ADJUST_DATA_TYPE_WHEN_LOADED = False
ATTR_DFLT_VALUE = 0
ATTR_CMD_BUTTON_COLOR = 0XF0F0F0
ATTR_AUTO_SIZING = VAL_GROW_ONLY
ATTR_SHORTCUT_KEY = 0
 
[Panel001_Control005]
ATTR_DIMMED = False
ATTR_CONSTANT_NAME = "STOP"
ATTR_CALLBACK_NAME = ""
ATTR_VISIBLE = True
ATTR_LEFT = 29
ATTR_TOP = 95
ATTR_WIDTH = 117
ATTR_ZPLANE_POSITION = 15
ATTR_HEIGHT = 24
ATTR_CTRL_STYLE = CTRL_SQUARE_COMMAND_BUTTON_LS
ATTR_INDUCE_CLOSE_CTRL = False
ATTR_TOOLTIP_TEXT = ""
ATTR_TOOLTIP_DELAY = 1000
ATTR_TOOLTIP_HIDE_DELAY = 0
ATTR_DISABLE_CTRL_TOOLTIP = False
ATTR_HIDDEN_WHEN_LOADED = False
ATTR_CTRL_MODE = VAL_HOT
ATTR_CTRL_TAB_POSITION = 4
ATTR_LABEL_COLOR = VAL_BLACK
ATTR_LABEL_TEXT = "Stop Acquisition"
ATTR_LABEL_FONT = VAL_DIALOG_FONT
ATTR_LABEL_ITALIC = False
ATTR_LABEL_UNDERLINE = False
ATTR_LABEL_STRIKEOUT = False
ATTR_LABEL_POINT_SIZE = 10
ATTR_LABEL_BOLD = False
ATTR_LABEL_CHARACTER_SET = VAL_NATIVE_CHARSET
ATTR_LABEL_VISIBLE = True
ATTR_ADJUST_DATA_TYPE_WHEN_LOADED = False
ATTR_DFLT_VALUE = 0
ATTR_CMD_BUTTON_COLOR = 0XF0F0F0
ATTR_AUTO_SIZING = VAL_GROW_ONLY
ATTR_SHORTCUT_KEY = 0
 
[Panel001_Control006]
ATTR_DIMMED = False
ATTR_CONSTANT_NAME = "START"
ATTR_CALLBACK_NAME = ""
ATTR_VISIBLE = True
ATTR_LEFT = 27
ATTR_TOP = 9
ATTR_WIDTH = 117
ATTR_ZPLANE_POSITION = 1
ATTR_HEIGHT = 24
ATTR_CTRL_STYLE = CTRL_SQUARE_COMMAND_BUTTON_LS
ATTR_INDUCE_CLOSE_CTRL = False
ATTR_TOOLTIP_TEXT = ""
ATTR_TOOLTIP_DELAY = 1000
ATTR_TOOLTIP_HIDE_DELAY = 0
ATTR_DISABLE_CTRL_TOOLTIP = False
ATTR_HIDDEN_WHEN_LOADED = False
ATTR_CTRL_MODE = VAL_HOT
ATTR_CTRL_TAB_POSITION = 5
ATTR_LABEL_COLOR = VAL_BLACK
ATTR_LABEL_TEXT = "Start Acquisition"
ATTR_LABEL_FONT = VAL_DIALOG_FONT
ATTR_LABEL_ITALIC = False
ATTR_LABEL_UNDERLINE = False
ATTR_LABEL_STRIKEOUT = False
ATTR_LABEL_POINT_SIZE = 10
ATTR_LABEL_BOLD = False
ATTR_LABEL_CHARACTER_SET = VAL_NATIVE_CHARSET
ATTR_LABEL_VISIBLE = True
ATTR_ADJUST_DATA_TYPE_WHEN_LOADED = False
ATTR_DFLT_VALUE = 0
ATTR_CMD_BUTTON_COLOR = 0XF0F0F0
ATTR_AUTO_SIZING = VAL_GROW_ONLY
ATTR_SHORTCUT_KEY = 0
 
[Panel001_Control007]
ATTR_DIMMED = False
ATTR_CONSTANT_NAME = "TEST"
ATTR_CALLBACK_NAME = "icfa_StartCB"
ATTR_VISIBLE = True
ATTR_LEFT = 27
ATTR_TOP = 36
ATTR_WIDTH = 117
ATTR_ZPLANE_POSITION = 17
ATTR_HEIGHT = 24
ATTR_CTRL_STYLE = CTRL_SQUARE_COMMAND_BUTTON_LS
ATTR_INDUCE_CLOSE_CTRL = False
ATTR_TOOLTIP_TEXT = ""
ATTR_TOOLTIP_DELAY = 1000
ATTR_TOOLTIP_HIDE_DELAY = 0
ATTR_DISABLE_CTRL_TOOLTIP = False
ATTR_HIDDEN_WHEN_LOADED = False
ATTR_CTRL_MODE = VAL_HOT
ATTR_CTRL_TAB_POSITION = 6
ATTR_LABEL_COLOR = VAL_BLACK
ATTR_LABEL_TEXT = "Test Acquisition"
ATTR_LABEL_FONT = VAL_DIALOG_FONT
ATTR_LABEL_ITALIC = False
ATTR_LABEL_UNDERLINE = False
ATTR_LABEL_STRIKEOUT = False
ATTR_LABEL_POINT_SIZE = 10
ATTR_LABEL_BOLD = False
ATTR_LABEL_CHARACTER_SET = VAL_NATIVE_CHARSET
ATTR_LABEL_VISIBLE = True
ATTR_ADJUST_DATA_TYPE_WHEN_LOADED = False
ATTR_DFLT_VALUE = 0
ATTR_CMD_BUTTON_COLOR = 0XF0F0F0
ATTR_AUTO_SIZING = VAL_GROW_ONLY
ATTR_SHORTCUT_KEY = 0
 
[Panel001_Control008]
ATTR_DIMMED = True
ATTR_CONSTANT_NAME = "THR"
ATTR_CALLBACK_NAME = ""
ATTR_VISIBLE = True
ATTR_LEFT = 81
ATTR_TOP = 133
ATTR_WIDTH = 69
ATTR_ZPLANE_POSITION = 14
ATTR_FRAME_COLOR = 0XF0F0F0
ATTR_CTRL_STYLE = CTRL_NUMERIC_LS
ATTR_INDUCE_CLOSE_CTRL = False
ATTR_TOOLTIP_TEXT = ""
ATTR_TOOLTIP_DELAY = 1000
ATTR_TOOLTIP_HIDE_DELAY = 0
ATTR_DISABLE_CTRL_TOOLTIP = False
ATTR_HIDDEN_WHEN_LOADED = False
ATTR_CTRL_MODE = VAL_HOT
ATTR_CTRL_TAB_POSITION = 7
ATTR_LABEL_COLOR = VAL_BLACK
ATTR_LABEL_TEXT = "Threshold"
ATTR_LABEL_FONT = VAL_DIALOG_FONT
ATTR_LABEL_ITALIC = False
ATTR_LABEL_UNDERLINE = False
ATTR_LABEL_STRIKEOUT = False
ATTR_LABEL_POINT_SIZE = 10
ATTR_LABEL_BOLD = False
ATTR_LABEL_CHARACTER_SET = VAL_NATIVE_CHARSET
ATTR_LABEL_VISIBLE = True
ATTR_LABEL_JUSTIFY = VAL_LEFT_JUSTIFIED
ATTR_LABEL_ANGLE = 0
ATTR_LABEL_LEFT = 31
ATTR_LABEL_TOP = 135
ATTR_LABEL_WIDTH = 53
ATTR_LABEL_HEIGHT = 15
ATTR_LABEL_RAISED = False
ATTR_LABEL_SIZE_TO_TEXT = True
ATTR_LABEL_BGCOLOR = 0XF0F0F0
ATTR_TEXT_COLOR = VAL_BLACK
ATTR_TEXT_FONT = VAL_DIALOG_FONT
ATTR_TEXT_ITALIC = False
ATTR_TEXT_UNDERLINE = False
ATTR_TEXT_STRIKEOUT = False
ATTR_TEXT_POINT_SIZE = 10
ATTR_TEXT_BOLD = False
ATTR_TEXT_CHARACTER_SET = VAL_NATIVE_CHARSET
ATTR_TEXT_BGCOLOR = VAL_WHITE
ATTR_TEXT_JUSTIFY = VAL_LEFT_JUSTIFIED
ATTR_DATA_TYPE = VAL_INTEGER
ATTR_ADJUST_DATA_TYPE_WHEN_LOADED = False
ATTR_MAX_VALUE = 2147483647
ATTR_MIN_VALUE = -1
ATTR_INCR_VALUE = 1
ATTR_FORMAT = VAL_DECIMAL_FORMAT
ATTR_PRECISION = 0
ATTR_CHECK_RANGE = VAL_NOTIFY
ATTR_PADDING = 0
ATTR_SHOW_RADIX = False
ATTR_DISABLE_RADIX = False
ATTR_INCDEC_WIDTH = 8
ATTR_DFLT_VALUE = 1
ATTR_SHOW_INCDEC_ARROWS = True
ATTR_NO_EDIT_TEXT = False
ATTR_SHORTCUT_KEY = 0
ATTR_DATASOCKET_ENABLED = False
ATTR_DATASOCKET_SOURCE = ""
ATTR_DATASOCKET_MODE = VAL_DS_READ
 
[Panel001_Control009]
ATTR_DIMMED = True
ATTR_CONSTANT_NAME = "NEVE"
ATTR_CALLBACK_NAME = ""
ATTR_VISIBLE = True
ATTR_LEFT = 81
ATTR_TOP = 70
ATTR_WIDTH = 69
ATTR_ZPLANE_POSITION = 16
ATTR_FRAME_COLOR = 0XF0F0F0
ATTR_CTRL_STYLE = CTRL_NUMERIC_LS
ATTR_INDUCE_CLOSE_CTRL = False
ATTR_TOOLTIP_TEXT = ""
ATTR_TOOLTIP_DELAY = 1000
ATTR_TOOLTIP_HIDE_DELAY = 0
ATTR_DISABLE_CTRL_TOOLTIP = False
ATTR_HIDDEN_WHEN_LOADED = False
ATTR_CTRL_MODE = VAL_HOT
ATTR_CTRL_TAB_POSITION = 8
ATTR_LABEL_COLOR = VAL_BLACK
ATTR_LABEL_TEXT = "N of events"
ATTR_LABEL_FONT = VAL_DIALOG_FONT
ATTR_LABEL_ITALIC = False
ATTR_LABEL_UNDERLINE = False
ATTR_LABEL_STRIKEOUT = False
ATTR_LABEL_POINT_SIZE = 10
ATTR_LABEL_BOLD = False
ATTR_LABEL_CHARACTER_SET = VAL_NATIVE_CHARSET
ATTR_LABEL_VISIBLE = True
ATTR_LABEL_JUSTIFY = VAL_LEFT_JUSTIFIED
ATTR_LABEL_ANGLE = 0
ATTR_LABEL_LEFT = 18
ATTR_LABEL_TOP = 70
ATTR_LABEL_WIDTH = 59
ATTR_LABEL_HEIGHT = 15
ATTR_LABEL_RAISED = False
ATTR_LABEL_SIZE_TO_TEXT = True
ATTR_LABEL_BGCOLOR = 0XF0F0F0
ATTR_TEXT_COLOR = VAL_BLACK
ATTR_TEXT_FONT = VAL_DIALOG_FONT
ATTR_TEXT_ITALIC = False
ATTR_TEXT_UNDERLINE = False
ATTR_TEXT_STRIKEOUT = False
ATTR_TEXT_POINT_SIZE = 10
ATTR_TEXT_BOLD = False
ATTR_TEXT_CHARACTER_SET = VAL_NATIVE_CHARSET
ATTR_TEXT_BGCOLOR = VAL_WHITE
ATTR_TEXT_JUSTIFY = VAL_LEFT_JUSTIFIED
ATTR_DATA_TYPE = VAL_INTEGER
ATTR_ADJUST_DATA_TYPE_WHEN_LOADED = False
ATTR_MAX_VALUE = 2147483647
ATTR_MIN_VALUE = -1
ATTR_INCR_VALUE = 1
ATTR_FORMAT = VAL_DECIMAL_FORMAT
ATTR_PRECISION = 0
ATTR_CHECK_RANGE = VAL_NOTIFY
ATTR_PADDING = 0
ATTR_SHOW_RADIX = False
ATTR_DISABLE_RADIX = False
ATTR_INCDEC_WIDTH = 8
ATTR_DFLT_VALUE = 1
ATTR_SHOW_INCDEC_ARROWS = True
ATTR_NO_EDIT_TEXT = False
ATTR_SHORTCUT_KEY = 0
ATTR_DATASOCKET_ENABLED = False
ATTR_DATASOCKET_SOURCE = ""
ATTR_DATASOCKET_MODE = VAL_DS_READ
 
[Panel001_Control010]
ATTR_DIMMED = False
ATTR_CONSTANT_NAME = "ADD"
ATTR_CALLBACK_NAME = ""
ATTR_VISIBLE = True
ATTR_LEFT = 34
ATTR_TOP = 173
ATTR_WIDTH = 12
ATTR_ZPLANE_POSITION = 13
ATTR_HEIGHT = 12
ATTR_CTRL_STYLE = CTRL_CHECK_BOX
ATTR_INDUCE_CLOSE_CTRL = False
ATTR_TOOLTIP_TEXT = ""
ATTR_TOOLTIP_DELAY = 1000
ATTR_TOOLTIP_HIDE_DELAY = 0
ATTR_DISABLE_CTRL_TOOLTIP = False
ATTR_HIDDEN_WHEN_LOADED = False
ATTR_CTRL_MODE = VAL_HOT
ATTR_CTRL_TAB_POSITION = 9
ATTR_LABEL_COLOR = VAL_BLACK
ATTR_LABEL_TEXT = "Accumulate hits On/Off"
ATTR_LABEL_FONT = VAL_DIALOG_FONT
ATTR_LABEL_ITALIC = False
ATTR_LABEL_UNDERLINE = False
ATTR_LABEL_STRIKEOUT = False
ATTR_LABEL_POINT_SIZE = 10
ATTR_LABEL_BOLD = False
ATTR_LABEL_CHARACTER_SET = VAL_NATIVE_CHARSET
ATTR_LABEL_VISIBLE = True
ATTR_LABEL_JUSTIFY = VAL_LEFT_JUSTIFIED
ATTR_LABEL_ANGLE = 0
ATTR_LABEL_LEFT = 57
ATTR_LABEL_TOP = 173
ATTR_LABEL_WIDTH = 119
ATTR_LABEL_HEIGHT = 15
ATTR_LABEL_RAISED = False
ATTR_LABEL_SIZE_TO_TEXT = True
ATTR_LABEL_BGCOLOR = 0XF0F0F0
ATTR_ADJUST_DATA_TYPE_WHEN_LOADED = False
ATTR_DFLT_VALUE = 1
ATTR_ON_COLOR = VAL_WHITE
ATTR_OFF_COLOR = VAL_WHITE
ATTR_SHORTCUT_KEY = 0
 
[Panel001_Control011]
ATTR_DIMMED = False
ATTR_CONSTANT_NAME = "R_MAX"
ATTR_CALLBACK_NAME = ""
ATTR_VISIBLE = True
ATTR_LEFT = 50
ATTR_TOP = 344
ATTR_WIDTH = 42
ATTR_ZPLANE_POSITION = 9
ATTR_FRAME_COLOR = VAL_LT_GRAY
ATTR_CTRL_STYLE = CTRL_NUMERIC
ATTR_INDUCE_CLOSE_CTRL = False
ATTR_TOOLTIP_TEXT = ""
ATTR_TOOLTIP_DELAY = 1000
ATTR_TOOLTIP_HIDE_DELAY = 0
ATTR_DISABLE_CTRL_TOOLTIP = False
ATTR_HIDDEN_WHEN_LOADED = False
ATTR_CTRL_MODE = VAL_HOT
ATTR_CTRL_TAB_POSITION = 10
ATTR_LABEL_COLOR = VAL_BLACK
ATTR_LABEL_TEXT = "R MAX"
ATTR_LABEL_FONT = VAL_DIALOG_FONT
ATTR_LABEL_ITALIC = False
ATTR_LABEL_UNDERLINE = False
ATTR_LABEL_STRIKEOUT = False
ATTR_LABEL_POINT_SIZE = 10
ATTR_LABEL_BOLD = False
ATTR_LABEL_CHARACTER_SET = VAL_NATIVE_CHARSET
ATTR_LABEL_VISIBLE = True
ATTR_LABEL_JUSTIFY = VAL_LEFT_JUSTIFIED
ATTR_LABEL_ANGLE = 0
ATTR_LABEL_LEFT = 14
ATTR_LABEL_TOP = 346
ATTR_LABEL_WIDTH = 39
ATTR_LABEL_HEIGHT = 15
ATTR_LABEL_RAISED = False
ATTR_LABEL_SIZE_TO_TEXT = True
ATTR_LABEL_BGCOLOR = VAL_RED
ATTR_TEXT_COLOR = VAL_BLACK
ATTR_TEXT_FONT = VAL_DIALOG_FONT
ATTR_TEXT_ITALIC = False
ATTR_TEXT_UNDERLINE = False
ATTR_TEXT_STRIKEOUT = False
ATTR_TEXT_POINT_SIZE = 10
ATTR_TEXT_BOLD = False
ATTR_TEXT_CHARACTER_SET = VAL_NATIVE_CHARSET
ATTR_TEXT_BGCOLOR = VAL_WHITE
ATTR_TEXT_JUSTIFY = VAL_LEFT_JUSTIFIED
ATTR_DATA_TYPE = VAL_DOUBLE
ATTR_ADJUST_DATA_TYPE_WHEN_LOADED = False
ATTR_MAX_VALUE = 1.00000000000000E+1
ATTR_MIN_VALUE = 0.00000000000000E+0
ATTR_INCR_VALUE = 1.00000000000000E+0
ATTR_FORMAT = VAL_FLOATING_PT_FORMAT
ATTR_PRECISION = 2
ATTR_CHECK_RANGE = VAL_NOTIFY
ATTR_PADDING = 0
ATTR_SHOW_RADIX = False
ATTR_DISABLE_RADIX = False
ATTR_INCDEC_WIDTH = 8
ATTR_DFLT_VALUE = 5.00000000000000E+0
ATTR_SHOW_INCDEC_ARROWS = True
ATTR_NO_EDIT_TEXT = False
ATTR_SHORTCUT_KEY = 0
ATTR_DATASOCKET_ENABLED = False
ATTR_DATASOCKET_SOURCE = ""
ATTR_DATASOCKET_MODE = VAL_DS_READ
 
[Panel001_Control012]
ATTR_DIMMED = False
ATTR_CONSTANT_NAME = "R_MIN"
ATTR_CALLBACK_NAME = ""
ATTR_VISIBLE = True
ATTR_LEFT = 49
ATTR_TOP = 323
ATTR_WIDTH = 43
ATTR_ZPLANE_POSITION = 10
ATTR_FRAME_COLOR = VAL_LT_GRAY
ATTR_CTRL_STYLE = CTRL_NUMERIC
ATTR_INDUCE_CLOSE_CTRL = False
ATTR_TOOLTIP_TEXT = ""
ATTR_TOOLTIP_DELAY = 1000
ATTR_TOOLTIP_HIDE_DELAY = 0
ATTR_DISABLE_CTRL_TOOLTIP = False
ATTR_HIDDEN_WHEN_LOADED = False
ATTR_CTRL_MODE = VAL_HOT
ATTR_CTRL_TAB_POSITION = 11
ATTR_LABEL_COLOR = VAL_BLACK
ATTR_LABEL_TEXT = "R MIN"
ATTR_LABEL_FONT = VAL_DIALOG_FONT
ATTR_LABEL_ITALIC = False
ATTR_LABEL_UNDERLINE = False
ATTR_LABEL_STRIKEOUT = False
ATTR_LABEL_POINT_SIZE = 10
ATTR_LABEL_BOLD = False
ATTR_LABEL_CHARACTER_SET = VAL_NATIVE_CHARSET
ATTR_LABEL_VISIBLE = True
ATTR_LABEL_JUSTIFY = VAL_LEFT_JUSTIFIED
ATTR_LABEL_ANGLE = 0
ATTR_LABEL_LEFT = 14
ATTR_LABEL_TOP = 324
ATTR_LABEL_WIDTH = 34
ATTR_LABEL_HEIGHT = 15
ATTR_LABEL_RAISED = False
ATTR_LABEL_SIZE_TO_TEXT = True
ATTR_LABEL_BGCOLOR = VAL_RED
ATTR_TEXT_COLOR = VAL_BLACK
ATTR_TEXT_FONT = VAL_DIALOG_FONT
ATTR_TEXT_ITALIC = False
ATTR_TEXT_UNDERLINE = False
ATTR_TEXT_STRIKEOUT = False
ATTR_TEXT_POINT_SIZE = 10
ATTR_TEXT_BOLD = False
ATTR_TEXT_CHARACTER_SET = VAL_NATIVE_CHARSET
ATTR_TEXT_BGCOLOR = VAL_WHITE
ATTR_TEXT_JUSTIFY = VAL_LEFT_JUSTIFIED
ATTR_DATA_TYPE = VAL_DOUBLE
ATTR_ADJUST_DATA_TYPE_WHEN_LOADED = False
ATTR_MAX_VALUE = 1.00000000000000E+1
ATTR_MIN_VALUE = 0.00000000000000E+0
ATTR_INCR_VALUE = 1.00000000000000E+0
ATTR_FORMAT = VAL_FLOATING_PT_FORMAT
ATTR_PRECISION = 2
ATTR_CHECK_RANGE = VAL_NOTIFY
ATTR_PADDING = 0
ATTR_SHOW_RADIX = False
ATTR_DISABLE_RADIX = False
ATTR_INCDEC_WIDTH = 8
ATTR_DFLT_VALUE = 4.00000000000000E+0
ATTR_SHOW_INCDEC_ARROWS = True
ATTR_NO_EDIT_TEXT = False
ATTR_SHORTCUT_KEY = 0
ATTR_DATASOCKET_ENABLED = False
ATTR_DATASOCKET_SOURCE = ""
ATTR_DATASOCKET_MODE = VAL_DS_READ
 
[Panel001_Control013]
ATTR_DIMMED = False
ATTR_CONSTANT_NAME = "PROC"
ATTR_CALLBACK_NAME = ""
ATTR_VISIBLE = True
ATTR_LEFT = 57
ATTR_TOP = 461
ATTR_WIDTH = 137
ATTR_ZPLANE_POSITION = 5
ATTR_HEIGHT = 7
ATTR_FRAME_COLOR = VAL_LT_GRAY
ATTR_CTRL_STYLE = CTRL_NUMERIC_FLAT_HSLIDE
ATTR_INDUCE_CLOSE_CTRL = False
ATTR_TOOLTIP_TEXT = ""
ATTR_TOOLTIP_DELAY = 1000
ATTR_TOOLTIP_HIDE_DELAY = 0
ATTR_DISABLE_CTRL_TOOLTIP = False
ATTR_HIDDEN_WHEN_LOADED = False
ATTR_CTRL_MODE = VAL_INDICATOR
ATTR_CTRL_TAB_POSITION = 12
ATTR_LABEL_COLOR = VAL_BLACK
ATTR_LABEL_TEXT = "Processed:"
ATTR_LABEL_FONT = VAL_DIALOG_FONT
ATTR_LABEL_ITALIC = False
ATTR_LABEL_UNDERLINE = False
ATTR_LABEL_STRIKEOUT = False
ATTR_LABEL_POINT_SIZE = 10
ATTR_LABEL_BOLD = False
ATTR_LABEL_CHARACTER_SET = VAL_NATIVE_CHARSET
ATTR_LABEL_VISIBLE = True
ATTR_LABEL_JUSTIFY = VAL_LEFT_JUSTIFIED
ATTR_LABEL_ANGLE = 0
ATTR_LABEL_LEFT = 2
ATTR_LABEL_TOP = 455
ATTR_LABEL_WIDTH = 60
ATTR_LABEL_HEIGHT = 15
ATTR_LABEL_RAISED = False
ATTR_LABEL_SIZE_TO_TEXT = True
ATTR_LABEL_BGCOLOR = VAL_LT_GRAY
ATTR_TEXT_COLOR = VAL_BLACK
ATTR_TEXT_FONT = VAL_DIALOG_FONT
ATTR_TEXT_ITALIC = False
ATTR_TEXT_UNDERLINE = False
ATTR_TEXT_STRIKEOUT = False
ATTR_TEXT_POINT_SIZE = 10
ATTR_TEXT_BOLD = False
ATTR_TEXT_CHARACTER_SET = VAL_NATIVE_CHARSET
ATTR_TEXT_BGCOLOR = VAL_WHITE
ATTR_TEXT_JUSTIFY = VAL_LEFT_JUSTIFIED
ATTR_DATA_TYPE = VAL_INTEGER
ATTR_ADJUST_DATA_TYPE_WHEN_LOADED = False
ATTR_MAX_VALUE = 100
ATTR_MIN_VALUE = 0
ATTR_INCR_VALUE = 1
ATTR_FORMAT = VAL_DECIMAL_FORMAT
ATTR_PRECISION = 0
ATTR_CHECK_RANGE = VAL_IGNORE
ATTR_PADDING = 0
ATTR_SHOW_RADIX = False
ATTR_DISABLE_RADIX = False
ATTR_INCDEC_WIDTH = 8
ATTR_DFLT_VALUE = 0
ATTR_SHOW_INCDEC_ARROWS = False
ATTR_DIG_DISP_TOP = 459
ATTR_DIG_DISP_LEFT = -32
ATTR_DIG_DISP_WIDTH = 69
ATTR_DIG_DISP_HEIGHT = 19
ATTR_SHOW_DIG_DISP = False
ATTR_NUM_DIVISIONS = -1
ATTR_NEEDLE_COLOR = VAL_BLACK
ATTR_FILL_HOUSING_COLOR = VAL_WHITE
ATTR_MARKER_STYLE = VAL_FULL_MARKERS
ATTR_TICK_STYLE = VAL_NO_MINOR_TICKS
ATTR_USE_PROGRESS_BAR_VISUAL_STYLES = False
ATTR_FILL_COLOR = VAL_RED
ATTR_FILL_OPTION = VAL_BOTTOM_FILL
ATTR_COLOR_RAMP_WIDTH = 5
ATTR_SHORTCUT_KEY = 0
ATTR_DATASOCKET_ENABLED = False
ATTR_DATASOCKET_SOURCE = ""
ATTR_DATASOCKET_MODE = VAL_DS_READ
Color_Ramp_Interpolate = False
Color_Ramp_Hi_Color = 0XFF0000
 
[Panel001_Control014]
ATTR_DIMMED = False
ATTR_CONSTANT_NAME = "TRIG"
ATTR_CALLBACK_NAME = ""
ATTR_VISIBLE = True
ATTR_LEFT = 73
ATTR_TOP = 416
ATTR_WIDTH = 69
ATTR_ZPLANE_POSITION = 6
ATTR_FRAME_COLOR = VAL_LT_GRAY
ATTR_CTRL_STYLE = CTRL_NUMERIC
ATTR_INDUCE_CLOSE_CTRL = False
ATTR_TOOLTIP_TEXT = ""
ATTR_TOOLTIP_DELAY = 1000
ATTR_TOOLTIP_HIDE_DELAY = 0
ATTR_DISABLE_CTRL_TOOLTIP = False
ATTR_HIDDEN_WHEN_LOADED = False
ATTR_CTRL_MODE = VAL_INDICATOR
ATTR_CTRL_TAB_POSITION = 13
ATTR_LABEL_COLOR = VAL_BLACK
ATTR_LABEL_TEXT = "TRIGGERS"
ATTR_LABEL_FONT = VAL_DIALOG_FONT
ATTR_LABEL_ITALIC = False
ATTR_LABEL_UNDERLINE = False
ATTR_LABEL_STRIKEOUT = False
ATTR_LABEL_POINT_SIZE = 10
ATTR_LABEL_BOLD = False
ATTR_LABEL_CHARACTER_SET = VAL_NATIVE_CHARSET
ATTR_LABEL_VISIBLE = True
ATTR_LABEL_JUSTIFY = VAL_LEFT_JUSTIFIED
ATTR_LABEL_ANGLE = 0
ATTR_LABEL_LEFT = 3
ATTR_LABEL_TOP = 418
ATTR_LABEL_WIDTH = 63
ATTR_LABEL_HEIGHT = 15
ATTR_LABEL_RAISED = False
ATTR_LABEL_SIZE_TO_TEXT = True
ATTR_LABEL_BGCOLOR = VAL_LT_GRAY
ATTR_TEXT_COLOR = VAL_BLACK
ATTR_TEXT_FONT = VAL_DIALOG_FONT
ATTR_TEXT_ITALIC = False
ATTR_TEXT_UNDERLINE = False
ATTR_TEXT_STRIKEOUT = False
ATTR_TEXT_POINT_SIZE = 10
ATTR_TEXT_BOLD = False
ATTR_TEXT_CHARACTER_SET = VAL_NATIVE_CHARSET
ATTR_TEXT_BGCOLOR = VAL_WHITE
ATTR_TEXT_JUSTIFY = VAL_LEFT_JUSTIFIED
ATTR_DATA_TYPE = VAL_INTEGER
ATTR_ADJUST_DATA_TYPE_WHEN_LOADED = False
ATTR_MAX_VALUE = 1000000
ATTR_MIN_VALUE = 0
ATTR_INCR_VALUE = 1
ATTR_FORMAT = VAL_DECIMAL_FORMAT
ATTR_PRECISION = 0
ATTR_CHECK_RANGE = VAL_NOTIFY
ATTR_PADDING = 0
ATTR_SHOW_RADIX = False
ATTR_DISABLE_RADIX = False
ATTR_INCDEC_WIDTH = 8
ATTR_DFLT_VALUE = 0
ATTR_SHOW_INCDEC_ARROWS = True
ATTR_NO_EDIT_TEXT = False
ATTR_SHORTCUT_KEY = 0
ATTR_DATASOCKET_ENABLED = False
ATTR_DATASOCKET_SOURCE = ""
ATTR_DATASOCKET_MODE = VAL_DS_READ
 
[Panel001_Control015]
ATTR_DIMMED = False
ATTR_CONSTANT_NAME = "A0A1"
ATTR_CALLBACK_NAME = ""
ATTR_VISIBLE = True
ATTR_LEFT = 114
ATTR_TOP = 593
ATTR_WIDTH = 42
ATTR_ZPLANE_POSITION = 3
ATTR_FRAME_COLOR = VAL_LT_GRAY
ATTR_CTRL_STYLE = CTRL_NUMERIC
ATTR_INDUCE_CLOSE_CTRL = False
ATTR_TOOLTIP_TEXT = ""
ATTR_TOOLTIP_DELAY = 1000
ATTR_TOOLTIP_HIDE_DELAY = 0
ATTR_DISABLE_CTRL_TOOLTIP = False
ATTR_HIDDEN_WHEN_LOADED = False
ATTR_CTRL_MODE = VAL_HOT
ATTR_CTRL_TAB_POSITION = 14
ATTR_LABEL_COLOR = VAL_BLACK
ATTR_LABEL_TEXT = "Aerogel thickness (mm)"
ATTR_LABEL_FONT = VAL_DIALOG_FONT
ATTR_LABEL_ITALIC = False
ATTR_LABEL_UNDERLINE = False
ATTR_LABEL_STRIKEOUT = False
ATTR_LABEL_POINT_SIZE = 10
ATTR_LABEL_BOLD = False
ATTR_LABEL_CHARACTER_SET = VAL_NATIVE_CHARSET
ATTR_LABEL_VISIBLE = True
ATTR_LABEL_JUSTIFY = VAL_LEFT_JUSTIFIED
ATTR_LABEL_ANGLE = 0
ATTR_LABEL_LEFT = 2
ATTR_LABEL_TOP = 596
ATTR_LABEL_WIDTH = 122
ATTR_LABEL_HEIGHT = 15
ATTR_LABEL_RAISED = False
ATTR_LABEL_SIZE_TO_TEXT = True
ATTR_LABEL_BGCOLOR = VAL_LT_GRAY
ATTR_TEXT_COLOR = VAL_BLACK
ATTR_TEXT_FONT = VAL_DIALOG_FONT
ATTR_TEXT_ITALIC = False
ATTR_TEXT_UNDERLINE = False
ATTR_TEXT_STRIKEOUT = False
ATTR_TEXT_POINT_SIZE = 10
ATTR_TEXT_BOLD = False
ATTR_TEXT_CHARACTER_SET = VAL_NATIVE_CHARSET
ATTR_TEXT_BGCOLOR = VAL_WHITE
ATTR_TEXT_JUSTIFY = VAL_LEFT_JUSTIFIED
ATTR_DATA_TYPE = VAL_FLOAT
ATTR_ADJUST_DATA_TYPE_WHEN_LOADED = False
ATTR_MAX_VALUE = +Inf
ATTR_MIN_VALUE = -Inf
ATTR_INCR_VALUE = 1.00000E+0
ATTR_FORMAT = VAL_FLOATING_PT_FORMAT
ATTR_PRECISION = 1
ATTR_CHECK_RANGE = VAL_NOTIFY
ATTR_PADDING = 0
ATTR_SHOW_RADIX = False
ATTR_DISABLE_RADIX = False
ATTR_INCDEC_WIDTH = 8
ATTR_DFLT_VALUE = 2.00000E+1
ATTR_SHOW_INCDEC_ARROWS = True
ATTR_NO_EDIT_TEXT = False
ATTR_SHORTCUT_KEY = 0
ATTR_DATASOCKET_ENABLED = False
ATTR_DATASOCKET_SOURCE = ""
ATTR_DATASOCKET_MODE = VAL_DS_READ
 
[Panel001_Control016]
ATTR_DIMMED = False
ATTR_CONSTANT_NAME = "NEVNT"
ATTR_CALLBACK_NAME = ""
ATTR_VISIBLE = True
ATTR_LEFT = 67
ATTR_TOP = 397
ATTR_WIDTH = 69
ATTR_ZPLANE_POSITION = 7
ATTR_FRAME_COLOR = VAL_LT_GRAY
ATTR_CTRL_STYLE = CTRL_NUMERIC
ATTR_INDUCE_CLOSE_CTRL = False
ATTR_TOOLTIP_TEXT = ""
ATTR_TOOLTIP_DELAY = 1000
ATTR_TOOLTIP_HIDE_DELAY = 0
ATTR_DISABLE_CTRL_TOOLTIP = False
ATTR_HIDDEN_WHEN_LOADED = False
ATTR_CTRL_MODE = VAL_HOT
ATTR_CTRL_TAB_POSITION = 15
ATTR_LABEL_COLOR = VAL_BLACK
ATTR_LABEL_TEXT = "MAX N. EV."
ATTR_LABEL_FONT = VAL_DIALOG_FONT
ATTR_LABEL_ITALIC = False
ATTR_LABEL_UNDERLINE = False
ATTR_LABEL_STRIKEOUT = False
ATTR_LABEL_POINT_SIZE = 10
ATTR_LABEL_BOLD = False
ATTR_LABEL_CHARACTER_SET = VAL_NATIVE_CHARSET
ATTR_LABEL_VISIBLE = True
ATTR_LABEL_JUSTIFY = VAL_LEFT_JUSTIFIED
ATTR_LABEL_ANGLE = 0
ATTR_LABEL_LEFT = 5
ATTR_LABEL_TOP = 399
ATTR_LABEL_WIDTH = 64
ATTR_LABEL_HEIGHT = 15
ATTR_LABEL_RAISED = False
ATTR_LABEL_SIZE_TO_TEXT = True
ATTR_LABEL_BGCOLOR = VAL_LT_GRAY
ATTR_TEXT_COLOR = VAL_BLACK
ATTR_TEXT_FONT = VAL_DIALOG_FONT
ATTR_TEXT_ITALIC = False
ATTR_TEXT_UNDERLINE = False
ATTR_TEXT_STRIKEOUT = False
ATTR_TEXT_POINT_SIZE = 10
ATTR_TEXT_BOLD = False
ATTR_TEXT_CHARACTER_SET = VAL_NATIVE_CHARSET
ATTR_TEXT_BGCOLOR = VAL_WHITE
ATTR_TEXT_JUSTIFY = VAL_LEFT_JUSTIFIED
ATTR_DATA_TYPE = VAL_INTEGER
ATTR_ADJUST_DATA_TYPE_WHEN_LOADED = False
ATTR_MAX_VALUE = 1000000
ATTR_MIN_VALUE = 0
ATTR_INCR_VALUE = 1
ATTR_FORMAT = VAL_DECIMAL_FORMAT
ATTR_PRECISION = 0
ATTR_CHECK_RANGE = VAL_NOTIFY
ATTR_PADDING = 0
ATTR_SHOW_RADIX = False
ATTR_DISABLE_RADIX = False
ATTR_INCDEC_WIDTH = 8
ATTR_DFLT_VALUE = 10000
ATTR_SHOW_INCDEC_ARROWS = True
ATTR_NO_EDIT_TEXT = False
ATTR_SHORTCUT_KEY = 0
ATTR_DATASOCKET_ENABLED = False
ATTR_DATASOCKET_SOURCE = ""
ATTR_DATASOCKET_MODE = VAL_DS_READ
 
[Panel001_Control017]
ATTR_DIMMED = False
ATTR_CONSTANT_NAME = "REFIND"
ATTR_CALLBACK_NAME = ""
ATTR_VISIBLE = True
ATTR_LEFT = 71
ATTR_TOP = 572
ATTR_WIDTH = 42
ATTR_ZPLANE_POSITION = 4
ATTR_FRAME_COLOR = VAL_LT_GRAY
ATTR_CTRL_STYLE = CTRL_NUMERIC
ATTR_INDUCE_CLOSE_CTRL = False
ATTR_TOOLTIP_TEXT = ""
ATTR_TOOLTIP_DELAY = 1000
ATTR_TOOLTIP_HIDE_DELAY = 0
ATTR_DISABLE_CTRL_TOOLTIP = False
ATTR_HIDDEN_WHEN_LOADED = False
ATTR_CTRL_MODE = VAL_HOT
ATTR_CTRL_TAB_POSITION = 16
ATTR_LABEL_COLOR = VAL_BLACK
ATTR_LABEL_TEXT = "Aerogel refind"
ATTR_LABEL_FONT = VAL_DIALOG_FONT
ATTR_LABEL_ITALIC = False
ATTR_LABEL_UNDERLINE = False
ATTR_LABEL_STRIKEOUT = False
ATTR_LABEL_POINT_SIZE = 10
ATTR_LABEL_BOLD = False
ATTR_LABEL_CHARACTER_SET = VAL_NATIVE_CHARSET
ATTR_LABEL_VISIBLE = True
ATTR_LABEL_JUSTIFY = VAL_LEFT_JUSTIFIED
ATTR_LABEL_ANGLE = 0
ATTR_LABEL_LEFT = 6
ATTR_LABEL_TOP = 573
ATTR_LABEL_WIDTH = 73
ATTR_LABEL_HEIGHT = 15
ATTR_LABEL_RAISED = False
ATTR_LABEL_SIZE_TO_TEXT = True
ATTR_LABEL_BGCOLOR = VAL_LT_GRAY
ATTR_TEXT_COLOR = VAL_BLACK
ATTR_TEXT_FONT = VAL_DIALOG_FONT
ATTR_TEXT_ITALIC = False
ATTR_TEXT_UNDERLINE = False
ATTR_TEXT_STRIKEOUT = False
ATTR_TEXT_POINT_SIZE = 10
ATTR_TEXT_BOLD = False
ATTR_TEXT_CHARACTER_SET = VAL_NATIVE_CHARSET
ATTR_TEXT_BGCOLOR = VAL_WHITE
ATTR_TEXT_JUSTIFY = VAL_LEFT_JUSTIFIED
ATTR_DATA_TYPE = VAL_FLOAT
ATTR_ADJUST_DATA_TYPE_WHEN_LOADED = False
ATTR_MAX_VALUE = +Inf
ATTR_MIN_VALUE = -Inf
ATTR_INCR_VALUE = 1.00000E-2
ATTR_FORMAT = VAL_FLOATING_PT_FORMAT
ATTR_PRECISION = 3
ATTR_CHECK_RANGE = VAL_NOTIFY
ATTR_PADDING = 0
ATTR_SHOW_RADIX = False
ATTR_DISABLE_RADIX = False
ATTR_INCDEC_WIDTH = 8
ATTR_DFLT_VALUE = 1.04900E+0
ATTR_SHOW_INCDEC_ARROWS = True
ATTR_NO_EDIT_TEXT = False
ATTR_SHORTCUT_KEY = 0
ATTR_DATASOCKET_ENABLED = False
ATTR_DATASOCKET_SOURCE = ""
ATTR_DATASOCKET_MODE = VAL_DS_READ
 
[Panel001_Control018]
ATTR_DIMMED = False
ATTR_CONSTANT_NAME = "MINHIT"
ATTR_CALLBACK_NAME = ""
ATTR_VISIBLE = True
ATTR_LEFT = 67
ATTR_TOP = 377
ATTR_WIDTH = 69
ATTR_ZPLANE_POSITION = 8
ATTR_FRAME_COLOR = VAL_LT_GRAY
ATTR_CTRL_STYLE = CTRL_NUMERIC
ATTR_INDUCE_CLOSE_CTRL = False
ATTR_TOOLTIP_TEXT = ""
ATTR_TOOLTIP_DELAY = 1000
ATTR_TOOLTIP_HIDE_DELAY = 0
ATTR_DISABLE_CTRL_TOOLTIP = False
ATTR_HIDDEN_WHEN_LOADED = False
ATTR_CTRL_MODE = VAL_HOT
ATTR_CTRL_TAB_POSITION = 17
ATTR_LABEL_COLOR = VAL_BLACK
ATTR_LABEL_TEXT = "MIN CH. HIT"
ATTR_LABEL_FONT = VAL_DIALOG_FONT
ATTR_LABEL_ITALIC = False
ATTR_LABEL_UNDERLINE = False
ATTR_LABEL_STRIKEOUT = False
ATTR_LABEL_POINT_SIZE = 10
ATTR_LABEL_BOLD = False
ATTR_LABEL_CHARACTER_SET = VAL_NATIVE_CHARSET
ATTR_LABEL_VISIBLE = True
ATTR_LABEL_JUSTIFY = VAL_LEFT_JUSTIFIED
ATTR_LABEL_ANGLE = 0
ATTR_LABEL_LEFT = 5
ATTR_LABEL_TOP = 379
ATTR_LABEL_WIDTH = 66
ATTR_LABEL_HEIGHT = 15
ATTR_LABEL_RAISED = False
ATTR_LABEL_SIZE_TO_TEXT = True
ATTR_LABEL_BGCOLOR = VAL_LT_GRAY
ATTR_TEXT_COLOR = VAL_BLACK
ATTR_TEXT_FONT = VAL_DIALOG_FONT
ATTR_TEXT_ITALIC = False
ATTR_TEXT_UNDERLINE = False
ATTR_TEXT_STRIKEOUT = False
ATTR_TEXT_POINT_SIZE = 10
ATTR_TEXT_BOLD = False
ATTR_TEXT_CHARACTER_SET = VAL_NATIVE_CHARSET
ATTR_TEXT_BGCOLOR = VAL_WHITE
ATTR_TEXT_JUSTIFY = VAL_LEFT_JUSTIFIED
ATTR_DATA_TYPE = VAL_INTEGER
ATTR_ADJUST_DATA_TYPE_WHEN_LOADED = False
ATTR_MAX_VALUE = 64
ATTR_MIN_VALUE = 0
ATTR_INCR_VALUE = 1
ATTR_FORMAT = VAL_DECIMAL_FORMAT
ATTR_PRECISION = 0
ATTR_CHECK_RANGE = VAL_NOTIFY
ATTR_PADDING = 0
ATTR_SHOW_RADIX = False
ATTR_DISABLE_RADIX = False
ATTR_INCDEC_WIDTH = 8
ATTR_DFLT_VALUE = 4
ATTR_SHOW_INCDEC_ARROWS = True
ATTR_NO_EDIT_TEXT = False
ATTR_SHORTCUT_KEY = 0
ATTR_DATASOCKET_ENABLED = False
ATTR_DATASOCKET_SOURCE = ""
ATTR_DATASOCKET_MODE = VAL_DS_READ
 
[Panel001_Control019]
ATTR_DIMMED = False
ATTR_CONSTANT_NAME = "MAXZ"
ATTR_CALLBACK_NAME = "SetMaximum"
ATTR_VISIBLE = True
ATTR_LEFT = 1012
ATTR_TOP = 37
ATTR_WIDTH = 9
ATTR_ZPLANE_POSITION = 0
ATTR_HEIGHT = 548
ATTR_FRAME_COLOR = 0XF0F0F0
ATTR_CTRL_STYLE = CTRL_NUMERIC_POINTER_VSLIDE_LS
ATTR_INDUCE_CLOSE_CTRL = False
ATTR_TOOLTIP_TEXT = ""
ATTR_TOOLTIP_DELAY = 1000
ATTR_TOOLTIP_HIDE_DELAY = 0
ATTR_DISABLE_CTRL_TOOLTIP = False
ATTR_HIDDEN_WHEN_LOADED = False
ATTR_CTRL_MODE = VAL_HOT
ATTR_CTRL_TAB_POSITION = 18
ATTR_LABEL_COLOR = VAL_BLACK
ATTR_LABEL_TEXT = "Zmax"
ATTR_LABEL_FONT = VAL_DIALOG_META_FONT
ATTR_LABEL_ITALIC = False
ATTR_LABEL_UNDERLINE = False
ATTR_LABEL_STRIKEOUT = False
ATTR_LABEL_POINT_SIZE = 11
ATTR_LABEL_BOLD = False
ATTR_LABEL_CHARACTER_SET = VAL_NATIVE_CHARSET
ATTR_LABEL_VISIBLE = True
ATTR_LABEL_JUSTIFY = VAL_LEFT_JUSTIFIED
ATTR_LABEL_ANGLE = 0
ATTR_LABEL_LEFT = 1046
ATTR_LABEL_TOP = 603
ATTR_LABEL_WIDTH = 29
ATTR_LABEL_HEIGHT = 15
ATTR_LABEL_RAISED = False
ATTR_LABEL_SIZE_TO_TEXT = True
ATTR_LABEL_BGCOLOR = 0XF0F0F0
ATTR_TEXT_COLOR = VAL_BLACK
ATTR_TEXT_FONT = VAL_DIALOG_META_FONT
ATTR_TEXT_ITALIC = False
ATTR_TEXT_UNDERLINE = False
ATTR_TEXT_STRIKEOUT = False
ATTR_TEXT_POINT_SIZE = 11
ATTR_TEXT_BOLD = False
ATTR_TEXT_CHARACTER_SET = VAL_NATIVE_CHARSET
ATTR_TEXT_BGCOLOR = VAL_WHITE
ATTR_TEXT_JUSTIFY = VAL_LEFT_JUSTIFIED
ATTR_DATA_TYPE = VAL_DOUBLE
ATTR_ADJUST_DATA_TYPE_WHEN_LOADED = False
ATTR_MAX_VALUE = 1.00000000000000E+2
ATTR_MIN_VALUE = 0.00000000000000E+0
ATTR_INCR_VALUE = 1.00000000000000E+0
ATTR_FORMAT = VAL_FLOATING_PT_FORMAT
ATTR_PRECISION = 2
ATTR_CHECK_RANGE = VAL_NOTIFY
ATTR_PADDING = 0
ATTR_SHOW_RADIX = False
ATTR_DISABLE_RADIX = False
ATTR_INCDEC_WIDTH = 9
ATTR_DFLT_VALUE = 1.00000000000000E+2
ATTR_SHOW_INCDEC_ARROWS = True
ATTR_DIG_DISP_TOP = 600
ATTR_DIG_DISP_LEFT = 962
ATTR_DIG_DISP_WIDTH = 75
ATTR_DIG_DISP_HEIGHT = 21
ATTR_SHOW_DIG_DISP = True
ATTR_NUM_DIVISIONS = -1
ATTR_NEEDLE_COLOR = 0XF0F0F0
ATTR_FILL_HOUSING_COLOR = 0X707088
ATTR_MARKER_STYLE = VAL_FULL_MARKERS
ATTR_TICK_STYLE = VAL_NO_MINOR_TICKS
ATTR_USE_PROGRESS_BAR_VISUAL_STYLES = False
ATTR_FILL_COLOR = 0X0040E0
ATTR_FILL_OPTION = VAL_BOTTOM_FILL
ATTR_COLOR_RAMP_WIDTH = 5
ATTR_SLIDER_WIDTH = 14
ATTR_SLIDER_HEIGHT = 10
ATTR_SLIDER_LEFT = 1010
ATTR_SHORTCUT_KEY = 0
ATTR_DATASOCKET_ENABLED = False
ATTR_DATASOCKET_SOURCE = ""
ATTR_DATASOCKET_MODE = VAL_DS_READ
Color_Ramp_Interpolate = False
Color_Ramp_Hi_Color = 0XFF0000
 
/cvi/apps/sa02_daq/cvi/ICFA/minirich.uir
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/cvi/apps/sa02_daq/cvi/PtsModule.h
0,0 → 1,40
#ifndef PtsModule__H_
#define PtsModule__H_
 
#define BYTE_PER_DOT 8192
#define ADR_CSR0 0x00 // D[1] LEDTEST; D[0] RESET
#define ADR_CLK 0x04 // D[15:12] CLKOUT1; D[11:8] CLKOUT0;
// D[7:4] SCLK; D[3:0] PCLK
#define ADR_VMECLK 0x08 // D[3] CLKOUT1; D[2] CLKOUT0;
// D[1] SCLK; D[0] PCLK
#define ADR_BUSA_REG 0x10
#define ADR_BUSA_IN 0x14
#define ADR_BUSA_DIR 0x18 // D[9:8] BUSA;
#define ADR_CFG 0x40
#define ADR_CSR1 0x44 // D[8] DONE; D[1] VCS_; D[0] PROGRAM_
#define ADR_MODE 0x48
#define ADR_SYSRESET 0xfc // write D=0 to sysreset
 
#define CSR1_PROGRAM_ 0x1
#define CSR1_VCS_ 0x2
#define CSR1_DONE 0x100
 
#define SELECTMAP_MODE 2
#define SLAVESERIAL_MODE 3
 
int Pts_erase(uint32_t addr ,int);
// int Pts_configure( const char *filename, int mode=SLAVESERIAL_MODE,
// int Pts_configure(const char *, int, int );
int Pts_configure_bit(uint32_t addr, const char *, int, int);
// int Pts_configure_rbt(const char *, int, int);
int Pts_check_configure(uint32_t addr,int);
int Pts_reset(int);
 
//#define PTSADDR 0x50000000
 
 
//#define Pts_write(VME,DATA) VME_write_32(udev,Ext_NoPriv_Data,PTSADDR+(VME),(DATA))
//#define Pts_read(VME,DATA) VME_read_32(udev,Ext_NoPriv_Data,PTSADDR+(VME),(DATA))
 
 
#endif
/cvi/apps/sa02_daq/cvi/_febdaq.ini
0,0 → 1,16
#VME_CONTROLLER WIENER_VMUSB
#VME_CONTROLLER WIENER_VMEMM
VME_CONTROLLER CAEN_V1718
CAEN_V288 0x100500
BELLEPTS 0x02505000
#CAEN_V1495
MIKRO_PORT 3
MIKRO_X 0x1
MIKRO_Y 0x2
MIKRO_Z 0x3
CAEN_V729 0x880000
FEBParam ..\parameters\feb1_0-default.param
#USER INTERFACE
# BIT 0 --> Test pulz = 0(Off)/1(On)
# BIT 1 --> Trigger = 0(Software)/1(Hardware)
UI 0x2
/cvi/apps/sa02_daq/cvi/eid2hapdxy.map
0,0 → 1,144
0 0 4 7
0 1 2 7
0 2 0 8
0 3 3 7
0 4 3 6
0 5 0 6
0 6 1 8
0 7 0 9
0 8 1 6
0 9 2 6
0 10 2 8
0 11 1 9
0 12 0 7
0 13 1 7
0 14 0 10
0 15 2 9
0 16 4 6
0 17 5 6
0 18 0 11
0 19 1 10
0 20 4 11
0 21 4 10
0 22 3 8
0 23 1 11
0 24 5 10
0 25 5 9
0 26 2 10
0 27 3 9
0 28 5 8
0 29 5 11
0 30 2 11
0 31 3 10
0 32 5 7
0 33 4 9
0 34 4 8
0 35 3 11
1 0 4 4
1 1 4 2
1 2 3 0
1 3 4 3
1 4 5 3
1 5 5 0
1 6 3 1
1 7 2 0
1 8 5 1
1 9 5 2
1 10 3 2
1 11 2 1
1 12 4 0
1 13 4 1
1 14 1 0
1 15 2 2
1 16 5 4
1 17 5 5
1 18 0 0
1 19 1 1
1 20 0 4
1 21 1 4
1 22 3 3
1 23 0 1
1 24 1 5
1 25 2 5
1 26 1 2
1 27 2 3
1 28 3 5
1 29 0 5
1 30 0 2
1 31 1 3
1 32 4 5
1 33 2 4
1 34 3 4
1 35 0 3
2 0 7 7
2 1 7 9
2 2 8 11
2 3 7 8
2 4 6 8
2 5 6 11
2 6 8 10
2 7 9 11
2 8 6 10
2 9 6 9
2 10 8 9
2 11 9 10
2 12 7 11
2 13 7 10
2 14 10 11
2 15 9 9
2 16 6 7
2 17 6 6
2 18 11 11
2 19 10 10
2 20 11 7
2 21 10 7
2 22 8 8
2 23 11 10
2 24 10 6
2 25 9 6
2 26 10 9
2 27 9 8
2 28 8 6
2 29 11 6
2 30 11 9
2 31 10 8
2 32 7 6
2 33 9 7
2 34 8 7
2 35 11 8
3 0 7 4
3 1 9 4
3 2 11 3
3 3 8 4
3 4 8 5
3 5 11 5
3 6 10 3
3 7 11 2
3 8 10 5
3 9 9 5
3 10 9 3
3 11 10 2
3 12 11 4
3 13 10 4
3 14 11 1
3 15 9 2
3 16 7 5
3 17 6 5
3 18 11 0
3 19 10 1
3 20 7 0
3 21 7 1
3 22 8 3
3 23 10 0
3 24 6 1
3 25 6 2
3 26 9 1
3 27 8 2
3 28 6 3
3 29 6 0
3 30 9 0
3 31 8 1
3 32 6 4
3 33 7 2
3 34 7 3
3 35 8 0
/cvi/apps/sa02_daq/cvi/eid2pmtxy.map
0,0 → 1,144
0 22 2 9
1 64 7 7
2 12 4 1
3 68 8 7
4 50 7 3
5 53 8 2
6 8 3 1
7 11 3 4
8 55 8 4
9 52 8 1
10 9 3 2
11 1 1 2
12 51 7 4
13 48 7 1
14 13 4 2
15 4 2 1
16 54 8 3
17 49 7 2
18 7 2 4
19 10 3 3
20 24 3 7
21 25 3 8
22 14 4 3
23 6 2 3
24 69 8 8
25 16 1 7
26 0 1 1
27 2 1 3
28 21 2 8
29 20 2 7
30 5 2 2
31 29 4 8
32 17 1 8
33 28 4 7
34 15 4 4
35 3 1 4
36 77 10 8
37 99 13 4
38 110 16 3
39 63 10 4
40 121 15 8
41 113 13 8
42 108 16 1
43 104 15 1
44 124 16 7
45 62 10 3
46 73 9 8
47 102 14 3
48 103 14 4
49 116 14 7
50 109 16 2
51 100 14 1
52 117 14 8
53 125 16 8
54 97 13 2
55 105 15 2
56 76 10 7
57 56 9 1
58 112 13 7
59 106 15 3
60 58 9 3
61 101 14 2
62 98 13 3
63 57 9 2
64 72 9 7
65 61 10 2
66 59 9 4
67 96 13 1
68 120 15 7
69 107 15 4
70 111 16 4
71 60 10 1
72 65 7 8
73 18 1 9
74 82 7 15
75 38 2 15
76 30 4 9
77 43 3 16
78 45 4 14
79 44 4 13
80 81 7 14
81 19 1 10
82 32 1 13
83 40 3 13
84 86 8 15
85 27 3 10
86 37 2 14
87 41 3 14
88 31 4 10
89 23 2 10
90 42 3 15
91 33 1 14
92 83 7 16
93 87 8 16
94 36 2 13
95 34 1 15
96 80 7 13
97 71 8 10
98 35 1 16
99 67 7 10
100 66 7 9
101 84 8 13
102 70 8 9
103 47 4 16
104 85 8 14
105 46 4 15
106 39 2 16
107 26 3 9
108 118 14 9
109 139 15 16
110 141 16 14
111 142 16 15
112 94 10 15
113 93 10 14
114 130 13 15
115 132 14 13
116 89 9 14
117 90 9 15
118 133 14 14
119 128 13 13
120 92 10 13
121 143 16 16
122 134 14 15
123 137 15 14
124 91 9 16
125 95 10 16
126 138 15 15
127 129 13 14
128 115 13 10
129 127 16 10
130 78 10 9
131 135 14 16
132 119 14 10
133 131 13 16
134 79 10 10
135 74 9 9
136 88 9 13
137 126 16 9
138 75 9 10
139 136 15 13
140 114 13 9
141 123 15 10
142 122 15 9
143 140 16 13
/cvi/apps/sa02_daq/cvi/eid2pmtxy_1.map
0,0 → 1,144
0 89 14 9
1 74 9 9
2 131 16 13
3 75 10 9
4 90 15 9
5 91 16 9
6 130 15 13
7 78 9 10
8 93 14 10
9 94 15 10
10 134 15 14
11 79 10 10
12 92 13 10
13 95 16 10
14 135 16 14
15 128 13 13
16 88 13 9
17 127 10 16
18 138 15 15
19 132 13 14
20 114 9 13
21 143 16 16
22 133 14 14
23 137 14 15
24 118 9 14
25 122 9 15
26 129 14 13
27 136 13 15
28 123 10 15
29 119 10 14
30 139 16 15
31 141 14 16
32 126 9 16
33 115 10 13
34 142 15 16
35 140 13 16
36 31 10 4
37 66 9 7
38 19 10 1
39 70 9 8
40 27 10 3
41 23 10 2
42 32 13 1
43 71 10 8
44 26 9 3
45 22 9 2
46 33 14 1
47 40 13 3
48 67 10 7
49 18 9 1
50 37 14 2
51 41 14 3
52 30 9 4
53 87 16 8
54 36 13 2
55 38 15 2
56 80 13 7
57 47 16 4
58 35 16 1
59 39 16 2
60 84 13 8
61 83 16 7
62 34 15 1
63 42 15 3
64 86 15 8
65 82 15 7
66 44 13 4
67 43 16 3
68 85 14 8
69 81 14 7
70 45 14 4
71 46 15 4
72 117 8 14
73 77 8 10
74 124 7 16
75 72 7 9
76 121 8 15
77 113 8 13
78 111 4 16
79 110 3 16
80 112 7 13
81 120 7 15
82 107 4 15
83 108 1 16
84 76 7 10
85 125 8 16
86 103 4 14
87 102 3 14
88 116 7 14
89 56 1 9
90 106 3 15
91 100 1 14
92 62 3 10
93 105 2 15
94 109 2 16
95 101 2 14
96 59 4 9
97 63 4 10
98 98 3 13
99 97 2 13
100 61 2 10
101 60 1 10
102 99 4 13
103 96 1 13
104 58 3 9
105 68 7 8
106 73 8 9
107 104 1 15
108 57 2 9
109 51 4 7
110 12 1 4
111 15 4 4
112 53 2 8
113 49 2 7
114 13 2 4
115 5 2 2
116 54 3 8
117 48 1 7
118 8 1 3
119 0 1 1
120 50 3 7
121 55 4 8
122 9 2 3
123 1 2 1
124 52 1 8
125 20 7 2
126 4 1 2
127 10 3 3
128 28 7 4
129 16 7 1
130 11 4 3
131 7 4 2
132 29 8 4
133 17 8 1
134 14 3 4
135 6 3 2
136 24 7 3
137 21 8 2
138 69 8 8
139 2 3 1
140 25 8 3
141 64 7 7
142 65 8 7
143 3 4 1
/cvi/apps/sa02_daq/cvi/febdaq.ini
0,0 → 1,23
VME_CONTROLLER WIENER_VMUSB
#VME_CONTROLLER WIENER_VMEMM
#VME_CONTROLLER CAEN_V1718
#CAEN_V288 0x100500
BELLEPTS 0x025F0000
#BELLEPTS 0x61000000
##BELLEPTS 0x51000000
#CAEN_V1495
#MIKRO_PORT 4
#MIKRO_X 0x1
#MIKRO_Y 0x2
#MIKRO_Z 0x3
#CAEN_V729 0x880000
#FEBParam ..\parameters\feb1_0-default.param
#FEBParam ..\parameters\icfa.param
FEBParam ..\parameters\pmtrich.param
#USER INTERFACE
# BIT 0 --> Test pulz = 0(Off)/1(On)
# BIT 1 -->
UI 0x0
FEBMask 0xF
# 1-soft, 2-ext., 3-int.
TriggerType 3
/cvi/apps/sa02_daq/cvi/pcivme_ni.dll
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/cvi/apps/sa02_daq/cvi/sa02_CVI.c
0,0 → 1,4957
//#include "tabela.h"
//#include "proba.h"
 
 
#include "vme.h"
 
//#define PTS_ADDR 0x025F0000
//#define PTS_ADDR 0x26000000
 
#include "PtsModule.h"
#define PTS_ADDR 0x61000000
#include <windows.h>
#include <formatio.h>
#include <analysis.h>
#include "toolbox.h"
#include <cvirte.h>
#include <stdlib.h>
#include <stdio.h>
 
#include <string.h>
#include <ctype.h>
#include <stdint.h>
 
#include <signal.h>
#include <utility.h>
#include <ansi_c.h>
#include <userint.h>
#include "toolbox.h"
 
#include "sa02lib.h"
#include "CAEN_V729.h"
#include "CAEN_V729_CVI.h"
#include "icfa.h"
 
#include "MIKRO.h"
const int dsize = 144*4;
 
#include "H1D.h"
#include "H2D.h"
#include "H3D.h"
#include "HDraw.h"
#include "dataio.h"
#include "sa02lib.h"
#include "sa02_CVI.h"
 
int ProcessUserEvent(int pID, int rID,int mode);
 
const char palaser[0xFF]="\"C:\\home\\software\\daq\\LaserDriver-Ver2.0\\Particulars LASER control.exe\"";
 
#define MAX_THREADS 10
const char slowcname[20][20]= {"TMON0","TMON1","VDD","V2P","V2N","VSS","VTH1","VTH2", "VCC12", "VCC15" ,"VCC25", "V38P" };
const int chart_control[4]= {P1_CHART_1,P1_CHART_2,P1_CHART_3,P1_CHART_4};
const int hapd_serials [4]= { P1_SERIAL_1, P1_SERIAL_2, P1_SERIAL_3, P1_SERIAL_4 };
const int fpga_serials [4]= { P1_SERIAL_FPGA_1, P1_SERIAL_FPGA_2, P1_SERIAL_FPGA_3, P1_SERIAL_FPGA_4 };
const int hapd_onoff [4]= { P1_ONOFF_1, P1_ONOFF_2, P1_ONOFF_3, P1_ONOFF_4 };
const int p2graph [4]= { P2_GRAPH_1, P2_GRAPH_2, P2_GRAPH_3, P2_GRAPH_4 };
 
#define PTS_ADDR 0x61000000
 
#define MIKRO_COM 4
#define MIKRO_X 1
#define MIKRO_Y 2
#define MIKRO_Z 3
 
#define TRUE 1
#define FALSE 0
#define TIMEOUT 3
 
#define CHECK_BIT(var,pos) ((var) & (1<<(pos)))
uint32_t gVME_CONTROLLER=WIENER_VMEMM;
uint32_t gCAEN_V288=0;
uint32_t gBELLEPTS=PTS_ADDR;
uint32_t gMIKRO_PORT=MIKRO_COM;
uint32_t gMIKRO_X=MIKRO_X, gMIKRO_Y=MIKRO_Y, gMIKRO_Z=MIKRO_Y;
uint32_t gCENTER_X=176000, gCENTER_Y=170000;
double gCENTER_KX=6./300, gCENTER_KY=3./300;
uint32_t gCAEN_V729=0;
uint32_t gCAEN_V1495=0;
uint32_t gFEBParamRead=0;
uint32_t gFEBMask=0xF;
uint32_t gTriggerType=2;
char gFEBParam[0xFF]="";
 
uint32_t uInterf = 0;
 
RUNINFO runinfo;
RUNREC runrec;
ENDREC endrec;
POSREC posrec;
EVTREC evtrec;
EVTREC evtrec1;
DATREC datrec;
MONREC monrec;
ITERATORREC iteratorrec;
 
 
typedef struct {
int chip;
int ch;
int chx;
int chy;
} EID2HAPDY;
 
EID2HAPDY eid2hapdxy[144];
 
// Variables
static int p1h, pID, rID, tfID;
static int p2h;
static int p3h;
static int p4h;
static int p5h;
static int pm1;
static int daq_on,loop_on;
static CmtThreadPoolHandle poolHandle = 0;
static CmtTSQHandle pTSQ = 0;
static int pTSQData[2];
 
double datay[10000];
double datax[10000];
double datayfit[10000];
 
//const int mux_map[4]={ 1,3,0,2};
 
int ctrl_c=0;
int integer_val=0;
FILE *gFp=NULL;
 
//***********************VARIABLE ZA BRANJE NAPETOSTI***********************//
 
#include "CAENV288.h"
 
#define ReadOperationalParam 0x02 //N470
#define TurnChanelOn 0x0a //N470
#define TurnChanelOff 0x0b //N470
#define ReadStatus 0x01 //SYS403
#define ReadParameters 0x02 //SYS403
 
int hvmon=0;
int hvmonFirst=0;
int32_t vset[24], iset[24];
 
 
// reads the run number from the first line in the file
int GetRunNumberFromFile(char *fname) {
char line[MAX_PATHNAME_LEN];
int ndim= MAX_PATHNAME_LEN;
int current_run = -1;
FILE *fp = NULL;
ssize_t size;
 
if ( GetFileInfo(fname,&size) ) fp = fopen(fname,"r");
 
if (fp) {
if (fgets(line,ndim,fp)!= NULL) current_run = atoi(line);
fclose(fp);
}
return current_run;
 
}
 
int IncreaseRunNumberInFile(char *fname) {
 
int current_run = GetRunNumberFromFile(fname);
FILE *fp = fopen(fname,"w");
 
if (fp) {
fprintf(fp,"%d", current_run+1 );
fclose(fp);
}
return current_run+1;
}
 
 
//**************************** get station parameters from ini file
int readIni(char *fname) {
 
FILE *fp = NULL;
char cmd[0xFF],val[0xFF];
int ndim=400;
char line[ndim];
ssize_t size;
 
if ( GetFileInfo(fname,&size) ) fp = fopen(fname,"r");
if (!fp) {
sprintf(line, "%s not found. Using default values.\n",fname);
MessagePopup ("Info", line);
return -1;
}
while (fgets(line,ndim,fp)!=NULL) {
sscanf(line,"%s%s",cmd, val);
if (cmd[0]=='#') continue;
if ( strstr(cmd,"VME_CONTROLLER")!= NULL ) {
if ( strstr(val,"WIENER_VMUSB")!= NULL ) gVME_CONTROLLER=WIENER_VMUSB;
if ( strstr(val,"WIENER_VMEMM")!= NULL ) gVME_CONTROLLER=WIENER_VMEMM;
if ( strstr(val,"CAEN_V1718") != NULL ) gVME_CONTROLLER=CAEN_V1718;
if ( strstr(val,"SIS3153_USB") != NULL ) gVME_CONTROLLER=SIS3153_USB;
}
if ( strstr(cmd,"CAEN_V288" )!= NULL ) gCAEN_V288 =strtoul(val,NULL,0);
if ( strstr(cmd,"BELLEPTS") != NULL ) gBELLEPTS =strtoul(val,NULL,0);
if ( strstr(cmd,"CAEN_V1495") != NULL ) gCAEN_V1495 =strtoul(val,NULL,0);
if ( strstr(cmd,"MIKRO_PORT")!= NULL ) gMIKRO_PORT=strtoul(val,NULL,0);
if ( strstr(cmd,"MIKRO_X") != NULL ) gMIKRO_X =strtoul(val,NULL,0);
if ( strstr(cmd,"MIKRO_Y") != NULL ) gMIKRO_Y =strtoul(val,NULL,0);
if ( strstr(cmd,"MIKRO_Z") != NULL ) gMIKRO_Z =strtoul(val,NULL,0);
if ( strstr(cmd,"CENTER_X") != NULL ) gCENTER_X =strtoul(val,NULL,0);
if ( strstr(cmd,"CENTER_Y") != NULL ) gCENTER_Y =strtoul(val,NULL,0);
if ( strstr(cmd,"CENTER_KX") != NULL ) gCENTER_KX =strtod(val,NULL);
if ( strstr(cmd,"CENTER_KY") != NULL ) gCENTER_KY =strtod(val,NULL);
if ( strstr(cmd,"CAEN_V729") != NULL ) gCAEN_V729 =strtoul(val,NULL,0);
if ( strstr(cmd,"FEBParam") != NULL ) sprintf(gFEBParam,"%s", val);
if ( strstr(cmd,"UI") != NULL ) uInterf =strtoul(val,NULL,0);
if ( strstr(cmd,"FEBMask") != NULL ) gFEBMask =strtoul(val,NULL,0);
if ( strstr(cmd,"TriggerType") != NULL ) gTriggerType =strtoul(val,NULL,0);
}
fclose(fp);
return 0;
}
//**************************** missing declarations in the library
char strbuf[0xFF];
 
int gLog=0;
int sa02Printf(const char *format, ...) {
va_list aptr;
int ret;
FILE *flog;
 
va_start(aptr, format);
ret = vsprintf(strbuf, format, aptr);
va_end(aptr);
SetCtrlVal(p1h,P1_STDIO,strbuf);
 
if (gLog) {
flog = fopen ("stdio.log", "a");
fprintf (flog, "%s", strbuf);
fclose (flog);
}
return(ret);
}
 
 
int CVICALLBACK sa02timeout (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
switch (event) {
case EVENT_TIMER_TICK:
sa02TimerOut = TRUE;
sa02Printf("sa02timeout\n");
//sa02Printf("TIMEOUT %s in line %d\n", __FILE__ , __LINE__);
break;
}
return 0;
}
void sa02Timerast (int signumber) {
sa02TimerOut = TRUE;
sa02Printf("TIMEOUT !!!\n");
SetCtrlAttribute (p1h, P1_DAQ_TIMEOUT, ATTR_ENABLED, 0);
}
 
void sa02Tmlnk (int tout) {
sa02TimerOut = FALSE;
SetCtrlAttribute (p1h, P1_DAQ_TIMEOUT, ATTR_INTERVAL,
(float)tout/100.);
SetCtrlAttribute (p1h, P1_DAQ_TIMEOUT, ATTR_ENABLED, 1);
// ResetTimer (p1h, P1_DAQ_TIMEOUT);
}
 
void sa02Tmulk ( void ) {
SetCtrlAttribute (p1h, P1_DAQ_TIMEOUT, ATTR_ENABLED, 0);
}
//****************************
 
 
int EscapeString(const char *i, char *o) {
unsigned int iptr=0, optr = 0;
// walk though the input string
for (iptr = 0; iptr < strlen(i); iptr++, optr++) {
// search for
if ( (i[iptr]=='\\') ) {
sa02Printf("Escape String %d %d \n",i[iptr] , i[iptr]==92 ) ;
//sa02Printf("Escape String %d %d \n",i[iptr] , ( (i[iptr] == 92) || (i[iptr] == 42) )) ;
o[optr] = i[iptr];
optr++;
}
 
o[optr] = i[iptr];
}
 
o[optr] = '\0';
 
 
return 0;
}
 
 
 
int p1plothandle=0;
int p2plothandle[4]= {0,0,0,0};
int p3plothandle=0;
 
int plothandle=0;
 
int phandle[4]= {0,0,0,0};
 
 
int plothandle2dfit=0;
int plothandleslix=0;
int plothandlesliy=0;
int plothandlefit=0;
 
void SigInt (int sig) {
ctrl_c = 1;
sa02TimerOut=1;
}
 
//int sa02Verbose=0;
int module_header(int recid,uint32_t *data,int len) {
data[0] = recid;
data[1] = (len >0)? len : 0 ;
return data[1]+2;
}
 
int PrintData(uint32_t *rdata, int count) {
int j;
uint32_t i;
for (j=0; j<count; j++) {
uint32_t recid = rdata[j++];
uint32_t len = rdata[j++];
sa02Printf(" recid=0x%0x len=%d pos=%d(maxpos %d) val=",recid, len, j, count);
if (len>2) {
sa02Printf("\n");
}
for (i=0; i<len; i++) {
if (j< count) {
sa02Printf("0x%0x\t", rdata[j]);
}
if (i%4==3) {
sa02Printf("\n");
}
j++;
}
sa02Printf("\n");
if (len) {
j--;
}
}
return 0;
}
 
//-------------------------------------------------------------------------
int CVICALLBACK PlotSliceY (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
int nslice,i;
int h2=(int) callbackData;
 
switch (event) {
case EVENT_COMMIT: {
int ny = H2DGetNbinsY(h2);
double miny = H2DGetMinY(h2);
double stepy = H2DGetStepY(h2);
GetCtrlVal(panel,P1_NSLIX,&nslice);
 
for (i=0; i < ny; i++ ) {
datax[i]=H2DGetBinContent(h2,nslice,i);
}
if (ny>0) {
if (plothandleslix) {
DeleteGraphPlot (p1h, P1_GRAPHY, plothandleslix, VAL_IMMEDIATE_DRAW);
}
 
plothandleslix = PlotWaveform (p1h, P1_GRAPHY, datax, ny,
VAL_DOUBLE, 1.0, 0.0, miny,
stepy, VAL_FAT_LINE,
VAL_EMPTY_SQUARE, VAL_SOLID, 1,
VAL_BLUE);
}
 
}
break;
}
return 0;
}
 
 
int CVICALLBACK PlotSliceX (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
int nslice,i;
int h2=(int) callbackData;
 
switch (event) {
case EVENT_COMMIT: {
int nx = H2DGetNbinsX(h2);
double minx = H2DGetMinX(h2);
double stepx = H2DGetStepX(h2);
GetCtrlVal(panel,P1_NSLIY,&nslice);
for (i=0; i < nx; i++ ) {
datax[i]=H2DGetBinContent(h2,i,nslice);
}
if (nx>0) {
if (plothandlesliy) {
DeleteGraphPlot (p1h, P1_GRAPHX, plothandlesliy, VAL_IMMEDIATE_DRAW);
}
 
plothandlesliy = PlotWaveform (p1h, P1_GRAPHX, datax, nx,
VAL_DOUBLE, 1.0, 0.0, minx,
stepx, VAL_FAT_LINE,
VAL_EMPTY_SQUARE, VAL_SOLID, 1,
VAL_BLUE);
}
 
}
break;
}
return 0;
}
 
 
 
void plot1d(int npoints, double x0, double dx) {
sa02Printf("TEST %d\n", npoints);
if (npoints>0) {
if (plothandle) {
DeleteGraphPlot (p1h, P1_GRAPH, plothandle, VAL_IMMEDIATE_DRAW);
}
plothandle = PlotWaveform (p1h, P1_GRAPH, datay, npoints, VAL_DOUBLE,
1.0, 0.0, x0, dx, VAL_CONNECTED_POINTS,
VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_BLUE);
}
}
 
/*
void plotxy(int h2d){
if (plothandlexy > 0 ) DeleteGraphPlot (p2h, P2_GRAPHXY, plothandlexy, VAL_IMMEDIATE_DRAW);
RangeColors(H2DGetMin(h2d),H2DGetMax(h2d));
plothandlexy = PlotScaledIntensity (p2h, P2_GRAPHXY, H2DGetData(h2d),
H2DGetNbinsX(h2d), H2DGetNbinsY(h2d), VAL_DOUBLE,
H2DGetStepY(h2d),H2DGetMinY(h2d),H2DGetStepX(h2d),H2DGetMinX(h2d),
colormap->array,
colormap->HiColor,
colormap->numberofColors, 1, 0);
ProcessSystemEvents ();
}
*/
 
int CVICALLBACK ZoomToFebCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
int feb=-1;
float xmin=0, xmax=0;
switch (event) {
case EVENT_COMMIT:
GetCtrlVal(panel,control,&feb);
switch (feb) {
case -1:
xmin=0;
xmax=144*4-1;
break;
default:
xmin = feb *144;
xmax =xmin+144 -1;
break;
}
SetAxisRange (p1h, P1_GRAPH2D, VAL_MANUAL, xmin, xmax, VAL_NO_CHANGE, 0.0, 1.0);
break;
}
return 0;
}
 
 
 
 
void plot2d(int h2d, int nslice) {
if (nslice < 0 ) {
nslice=0;
}
if (plothandle2dfit > 0 ) {
DeleteGraphPlot (p1h, P1_GRAPH2D, plothandle2dfit, VAL_IMMEDIATE_DRAW);
plothandle2dfit=0;
}
H2DDraw(h2d,p1h, P1_GRAPH2D, &p1plothandle);
 
if (sa02Verbose > 2) {
sa02Printf("min %f max %f x:min %f step%f y:min %f step%f\n",
H2DGetMin(h2d),H2DGetMax(h2d), H2DGetMinX(h2d),
H2DGetStepX(h2d),H2DGetMinY(h2d), H2DGetStepY(h2d));
}
SetCtrlVal(p1h, P1_NSLIY, nslice);
PlotSliceX(p1h,P1_GRAPHY,EVENT_COMMIT, NULL,0,0);
PlotSliceY(p1h,P1_GRAPHY,EVENT_COMMIT, NULL,0,0);
ProcessSystemEvents ();
}
 
void SetDimming(int state) {
SetCtrlAttribute (p1h, P1_MULTIFPGAWRITE, ATTR_DIMMED, state);
SetCtrlAttribute (p1h, P1_DAQ, ATTR_DIMMED, state);
SetCtrlAttribute (p1h, P1_READOUT, ATTR_DIMMED, state);
SetCtrlAttribute (p1h, P1_FPGAWRITE, ATTR_DIMMED, state);
SetCtrlVal (p1h, P1_LED, state);
SetCtrlAttribute (p2h, P2_DAQ, ATTR_DIMMED, state);
SetCtrlAttribute (p2h, P2_RUNSCRIPT, ATTR_DIMMED, state);
SetCtrlAttribute (p3h, P3_DAQ, ATTR_DIMMED, state);
SetCtrlAttribute (p4h, P4_DAQ, ATTR_DIMMED, state);
SetCtrlAttribute (p1h, P1_STOP, ATTR_DIMMED, !state);
SetCtrlAttribute (p2h, P2_STOP, ATTR_DIMMED, !state);
SetCtrlAttribute (p3h, P3_STOP, ATTR_DIMMED, !state);
SetCtrlAttribute (p4h, P4_STOP, ATTR_DIMMED, !state);
}
 
 
uint16_t GetConnectedFebMask(void) {
 
uint16_t mask=0;
int ison;
for (int i=0; i<4; i++) {
GetCtrlVal(p1h,hapd_onoff[i], &ison);
mask |= (ison << i);
}
sa02Printf("Connected FEBs mask, 0x%0x\n",mask);
return mask;
}
 
int CVICALLBACK daq(void *functionData) {
 
char title[256], serial[64];
int daqmode=1;
#define MAXSIZE 10000
int h2=0;
int maxsize = MAXSIZE;
uint32_t *rdata;
uint32_t response[2]= {0,0};
 
uint32_t fixeddata =0;
int testfixeddata =0;
uint32_t data =0;
uint32_t data0 =0;
uint32_t dataoff =0;
uint32_t dataon =0;
 
uint32_t cmd =0;
uint32_t chip =0;
uint32_t asicpar =0;
uint32_t asicshft=0;
uint32_t dstep =0;
uint32_t sendswtrg =0;
uint32_t tpenb =0;
 
uint32_t trglen;
uint16_t mask;
//uint32_t boardnumber_current=0;
// uint32_t hdr[10];
 
unsigned int aborttimeout =0;
int append =0;
int remap =0;
int neve =0;
int towrite =0;
int toread =0;
int ch =0;
int output =0;
int externalcmd =0;
int i=0,j=0, ir;
int ich;
//int ison;
 
char sfixeddata[0xFF]="";
char scmd[0xFF]="";
 
char filename[0xFF]="";
 
char externalcommand[0xFF]="";
 
FILE *fp=NULL;
int nbtotal=0;
time_t t,told, tstart;
int ncount=0;
int nerrors=0;
int readerror=0;
//int writeevents=0;
double fraction=0;
int board;
double t0;
 
rdata = malloc(sizeof(uint32_t)*maxsize);
 
// intercept routine
if (signal (SIGINT, SigInt) == SIG_ERR) {
perror ("sigignore");
}
 
 
mask=GetConnectedFebMask();
GetCtrlVal(p1h,P1_OUTPUTFILE, filename);
GetCtrlVal(p1h,P1_APPEND,&append); // append the data to the file filename
GetCtrlVal(p1h,P1_FRACTION, &fraction);
 
GetCtrlVal(p1h,P1_ABORTTOUT, &aborttimeout);
 
GetCtrlVal( p1h,P1_EXTERNALCMD, externalcommand);
GetCtrlVal( p1h,P1_EXTCMD, &externalcmd);
 
GetCtrlVal(p1h,P1_FIXEDDATA, sfixeddata);
fixeddata = strtoul (sfixeddata,NULL,0);
GetCtrlVal(p1h,P1_TESTFIXEDDATA, &testfixeddata);
 
 
GetCtrlVal(p1h,P1_TOREAD, &toread);
 
 
GetCtrlVal(p1h,P1_NEVE, &neve);
GetCtrlVal(p1h,P1_DSTEP, &dstep );
 
 
GetCtrlVal(p1h,P1_SENDSWTRIG,&sendswtrg);
GetCtrlVal(p1h,P1_INTTRGLEN, &trglen);
GetCtrlVal(p1h,P1_DAQMODE, &daqmode);
Sa02DaqMode (daqmode);
Sa02SelectTriggerWithMaskAndLength (sendswtrg, mask, trglen);
 
 
GetCtrlVal(p1h,P1_CHIP,&chip);
GetCtrlVal(p1h,P1_CHANNEL,&ch);
GetCtrlVal(p1h,P1_DATA,&data);
data0=data;
GetCtrlVal(p1h,P1_SCANTYPE,&towrite);
switch (towrite) {
case 1:
GetCtrlVal(p1h,P1_WRITECMD,scmd);
if (strcmp(scmd,"MUXASIC")==0) {
remap=1;
}
cmd =sa02GetCmdCode(scmd);
break;
case 3:
GetCtrlVal(p1h,P1_CHANNELOFF,scmd);
dataoff = strtoul (scmd,NULL,0);
GetCtrlVal(p1h,P1_CHANNELON,scmd);
dataon = strtoul (scmd,NULL,0);
chip =data/36;
ch =data%36;
sprintf(scmd,"channel");
case 2:
GetCtrlVal(p1h,P1_ASICPAR,scmd);
if (strlen(scmd)) cmd = sa02GetAsicCode(scmd,&asicpar, &asicshft);
 
break;
}
 
 
if (remap) {
data = sa02MuxMap(data);
sa02Printf("MUX %d\n",data);
}
 
GetCtrlVal(p1h,P1_TPENB,&tpenb);
//ReplaceAxisItem (p1h, P1_GRAPH2D, VAL_LEFT_YAXIS, 0, scmd, data0);
 
if (strlen(filename)>0) {
if (sa02Verbose) {
sa02Printf("Data in the file:%s\n", filename);
}
if (gFp) {
fp=gFp;
} else {
if (append) {
fp=fopen(filename,"ab");
} else {
fp=fopen(filename,"wb");
}
}
output=1;
// run header
runinfo.id= RUNINFO_ID; // run record ID
runinfo.len= sizeof(runinfo);
runinfo.cmd= cmd;
runinfo.x0 = data;
runinfo.dx = dstep;
runinfo.nx = neve;
runinfo.chip= chip;
runinfo.ch = ch;
runinfo.neve= toread;
runinfo.writemode= towrite;
sa02Printf("RUNINFO x0=%d nx=%d dx=%d\n", runinfo.x0,runinfo.dx,runinfo.nx);
nbtotal+=fwrite(&runinfo, 1,sizeof(runinfo),fp); //gzip
} else {
if (sa02Verbose) {
sa02Printf("Data are not written to the file!\n");
}
}
 
if (!neve & (towrite || toread) ) {
neve=1;
}
 
 
time(&t);
tstart=t;
told=t;
t0 = Timer();
 
 
title[0] = 0;
for (i=0; i<4; i++) {
int febon=0;
Sa02TestPulseEnable(i, tpenb); // Enable/disable test pulse
sa02GetSerial(i, serial);
GetCtrlVal(p1h,hapd_onoff[i], &febon);
if (strstr(serial,"0x00000000000000")!=NULL && febon) {
char txt[0xFF];
sprintf(txt, "FEB %d not connected or firmware not loaded? Serial number error! Switch Off FEB!",i);
MessagePopup ("Error", txt);
return -1;
}
sprintf(title,"%s FEB%d=%s", title, i, serial);
}
 
///////////////////////////////////////////////////////////////
int icfa_visible=0;
int icfa_add=0;
GetPanelAttribute (p6h, ATTR_VISIBLE, &icfa_visible);
GetCtrlVal (p6h, MINIRICH_ADD, &icfa_add);
if (icfa_visible) {
icfa_Init();
icfa_Histo();
}
///////////////////////////////////////////////////////////////
SetCtrlAttribute (p1h, P1_GRAPH2D, ATTR_LABEL_TEXT , title);
H2DInit(h2, "h2d",title, 144*4, 0,1,neve,data0, dstep);
H2DSetTitleY(h2,scmd);
 
sa02Printf("H2D nx=%d ny=%d i=%d neve=%d\n", H2DGetNbinsX(h2),H2DGetNbinsY(h2), i, neve);
 
 
plot2d(h2,1);
for (i=0; i<neve; i++) {
int nb = sizeof(uint32_t);
int count=0;
 
 
for (board=0; board<4; board++) {
 
switch (towrite) {
case 1: {
rdata[count+2]= data;
rdata[count+3]= sa02Cmd(board, cmd, data, chip, ch,1,response);
count+=module_header(cmd,&rdata[count],2 );
break;
}
case 2: {
uint32_t datal = asicpar & (data << asicshft);
rdata[count+2] = data;
rdata[count+3] = sa02AsicWrite(board, cmd, datal, chip, ch, asicpar,asicshft);
count+=module_header(cmd ,&rdata[count],2); // recid cmd
break;
}
case 3: {
rdata[count+2] = chip*36+ch;
rdata[count+3] = sa02AsicWrite(board, cmd, dataon, chip, ch, asicpar,asicshft); // switch on the channel
count+=module_header(cmd ,&rdata[count],2); // recid cmd
break;
}
}
if (towrite==3) {
SetCtrlVal(p1h,P1_SETVALUE, chip*36+ch );
} else {
SetCtrlVal(p1h,P1_SETVALUE, data);
}
 
 
 
}
 
Sa02SetNeve(toread);
sa02Reset();
 
// for ( j=0; j< toread; j++)
{
int eventerror = 0;
 
if ( (count +2 +dsize) >= maxsize) {
 
maxsize*=2;
sa02Printf("Increasing data buffer to %d elements\n", maxsize);
rdata=realloc(rdata ,sizeof(uint32_t)*maxsize);
}
 
do {
if (sendswtrg == 1) Sa02SoftwareTrigger();
nb = sa02Read(mask, &rdata[count+2] );
} while ( nb==0 && !ctrl_c);
if (nb==0) sa02Printf("nb==0 LINE=%d\n",__LINE__);
 
if (testfixeddata && nb>0) {
int len = nb / sizeof(uint32_t);
for (ir=0; ir<len; ir++) {
if ( rdata[count+2+ir]!=fixeddata ) {
time(&t);
sa02Printf("INSERT INTO fixederror VALUES ( '%d', '%d','%d','%d','0x%08x','0x%08x' ) \n", t, t-tstart, i*toread+j, ir, rdata[count+2+ir], fixeddata );
eventerror++;
}
}
}
if (eventerror) {
readerror++;
if (readerror==3) {
ctrl_c = 1;
system("date >> firmware.lock");
}
} else {
readerror= 0;
}
 
for (ich=0; ich<144*4; ich++) {
int xch = (143 - ich%144) + ich/144*144;
H2DFillBin(h2, xch,i,rdata[count+2+ich]);
}
if (icfa_visible) icfa_Event(&rdata[count+2], icfa_add );
/*
for (ich=0; ich<144; ich++) {
// id=(35-ich/4)+gBoardNumber*36;
// shft=(ich%4)*8;
id=(17-ich/8)+sa02BoardNumber*18;
shft=(ich%8)*4;
 
// if ( rdata[count+2+id] & (0xFF <<shft) ) {
if ( rdata[count+2+id] & (0xF <<shft) ) {
H2DFillBin(h2, ich,i,1);
}
if (sa02Verbose>2) {
sa02Printf("%02X ",(rdata[count+2+id]>> shft)& 0xF );
// sa02Printf("%02X ",(rdata[count+2+id]>> shft)& 0xFF );
}
}
*/
 
if (sa02Verbose>2) sa02Printf("\n" );
if (nb>=0) count+=module_header(0x3,&rdata[count],nb/sizeof(uint32_t)); // recid 0x3
 
if (ctrl_c) {
sa02Printf("ctrl_c detected ....\n");
break;
}
 
time(&t);
if (t!=told ) {
double done= (double) (i)/neve;
EstimatedFinish(p1h, P1_PROGRESS, P1_ETA, tstart, done);
plot2d(h2,i-1);
GetPanelAttribute (p6h, ATTR_VISIBLE, &icfa_visible);
if (icfa_visible) icfa_Draw();
SetCtrlVal(p1h,P1_CUREVE, j);
sa02Printf("%d events in %2.2f min (%d s) TIMEOUTS=%d %s",ncount, (double)(t-tstart)/60.,t-tstart, nerrors, ctime(&t));
}
if (aborttimeout && (t-tstart)>aborttimeout) {
sa02Printf("Abort timeout reached ....\n");
ctrl_c=1;
break;
}
told=t;
if (nb==0) {
nerrors++;
//j--; /// kako potem pride cez zeljeno stevil ozadetkov?
} else {
ncount++;
}
}
if (externalcmd) {
char ecmd[256];
sprintf(ecmd,"%s %u %u %u %u",externalcommand,(unsigned int) tstart,data, rdata[2], rdata[3]);
if (sa02Verbose) {
sa02Printf("Executing external command %s\n",ecmd);
}
system(ecmd);
}
 
if (output && Random(0,1)<fraction) {
evtrec.id = EVTREC_ID;
evtrec.len=count*sizeof(uint32_t)+ sizeof(evtrec);
evtrec.time= (uint32_t) time(NULL);
evtrec.nev=i;
nb = (int) fwrite( &evtrec, 1, sizeof(evtrec),fp); //gzip
if (count) {
nb+= (int) fwrite(&rdata[0],1,count*sizeof(uint32_t),fp); //gzip
}
if (nb!= (int) evtrec.len) {
sa02Printf("Error writing! %d!=%d\n",nb,evtrec.len);
}
nbtotal+= nb;
}
 
if (sa02Verbose==1) {
sa02Printf("[%d/%d] %u \t", i,count, (unsigned int) time(NULL));
PrintData(rdata,count);
}
if (towrite ==3) {
sa02AsicWrite(board, cmd, dataoff, chip, ch, asicpar, asicshft);
ch += dstep;
if (ch>35) {
ch-=36;
chip++;
}
} else {
data += dstep;
}
if (ctrl_c ) {
if (!testfixeddata) {
sa02Printf("Ctrl+C Program interrupted ....\n");
}
break;
}
}
plot2d(h2, i-1);
if (icfa_visible) icfa_Draw();
 
if (output) {
sprintf(scmd,"channel;daqtime=%f", Timer()-t0 );
H2DSetTitleX(h2,scmd);
H2DWrite2File(h2,fp);
if (!gFp) {
fclose(fp);
}
}
if (sa02Verbose>1) sa02Printf("%d bytes written to file %s\n", nbtotal, filename);
time(&t);
if (toread && !testfixeddata) sa02Printf("%d events in %2.2f min (%f s) TIMEOUTS=%d %s",ncount, (double)(Timer()-t0)/60.,Timer()-t0, nerrors, ctime(&t));
free(rdata);
 
return 0;
}
 
int CVICALLBACK quit (int panel, int event, void *callbackData,
int eventData1, int eventData2) {
switch (event) {
case EVENT_CLOSE:
// Stop timer callbacks
SuspendTimerCallbacks();
QuitUserInterface (0);
break;
}
return 0;
}
 
int CVICALLBACK Exit (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
switch (event) {
case EVENT_COMMIT:
quit(0,0,NULL,0,0);
exit(0);
}
return 0;
}
 
int SetParametersFromFile( const char *fname) {
uint32_t gdata;
uint32_t cdata;
 
sa02AsicGlobalRegister *greg = (sa02AsicGlobalRegister *) &gdata ;
sa02AsicChannelRegister *creg = (sa02AsicChannelRegister *) &cdata ;
unsigned short cregdata[8*144*4];
unsigned short gregdata[7*4*4];
#define NDIM 400
int ndim=NDIM;
char line[NDIM];
char cmd[NDIM];
char sasic[NDIM];
char v0[NDIM];
char v1[NDIM];
int asic=0, ch=0;
int gval=0, cval=0;
int board=0;
int row=0;
uint32_t sa02code;
int i;
ssize_t size;
FILE *fp = NULL;
if ( GetFileInfo(fname,&size) ) fp = fopen(fname,"r");
if (!fp) {
sa02Printf("Error! Cannot open file %s\n",fname);
return -1;
}
for (i=0; i<8*144*4; i++) {
cregdata[i]=0;
}
for (i=0; i<7*4*4; i++) {
gregdata[i]=0;
}
gdata=0;
cdata=0;
ResetTextBox(p3h,P3_FPGAPAR,"");
while (fgets(line,ndim,fp)!=NULL) {
int nb = sscanf(line,"%s%s%s%s",cmd,sasic,v0,v1);
if (nb<1 || cmd[0]=='#') {
continue;
}
asic = strtoul (sasic,NULL,0);
ch = strtoul (v0,NULL,0);
gval = strtoul (v0,NULL,0);
cval = strtoul (v1,NULL,0);
if (sa02Verbose>2) {
sa02Printf("%d %s",nb,line);
}
sa02code = sa02GetCmdCode(cmd);
if (strcmp(cmd,"MUXASIC")==0) {
asic = sa02MuxMap(asic);
}
switch (nb) {
case 1: {
if ( sa02code ) {
SetCtrlVal(p3h,P3_FPGAPAR,line);
 
break;
}
break;
}
case 2: {
if ( sa02code ) {
SetCtrlVal(p3h,P3_FPGAPAR,line);
 
break;
}
if (strcmp(cmd,"param_board")==0) {
board= asic;
}
if (strcmp(cmd,"load_global")==0) {
row= asic+1;
greg->id=13;
/*
SetTableCellVal (p3h, P3_GREG, MakePoint (1,row), greg->phasecmps);
SetTableCellVal (p3h, P3_GREG, MakePoint (2,row), greg->gain);
SetTableCellVal (p3h, P3_GREG, MakePoint (3,row), greg->shapingtime);
SetTableCellVal (p3h, P3_GREG, MakePoint (4,row), greg->comparator);
SetTableCellVal (p3h, P3_GREG, MakePoint (5,row), greg->vrdrive);
SetTableCellVal (p3h, P3_GREG, MakePoint (6,row), greg->monitor);
SetTableCellVal (p3h, P3_GREG, MakePoint (7,row), greg->id);
*/
gregdata[(board*4+asic)*7] = greg->phasecmps;
gregdata[(board*4+asic)*7+1] = greg->gain;
gregdata[(board*4+asic)*7+2] = greg->shapingtime;
gregdata[(board*4+asic)*7+3] = greg->comparator;
gregdata[(board*4+asic)*7+4] = greg->vrdrive;
gregdata[(board*4+asic)*7+5] = greg->monitor;
gregdata[(board*4+asic)*7+6] = greg->id;
 
break;
}
break;
}
case 3: {
if ( sa02code) {
SetCtrlVal(p3h,P3_FPGAPAR,line);
break;
}
if (strcmp(cmd,"param_global")==0) {
gdata = 0;
break;
}
if (strcmp(cmd,"phasecmps")==0) {
greg->phasecmps = gval;
break;
}
if (strcmp(cmd,"gain") ==0) {
greg->gain = gval;
break;
}
if (strcmp(cmd,"shapingtime")==0) {
greg->shapingtime = gval;
break;
}
if (strcmp(cmd,"comparator")==0) {
greg->comparator = gval;
break;
}
if (strcmp(cmd,"vrdrive")==0) {
greg->vrdrive = gval;
break;
}
if (strcmp(cmd,"monitor")==0) {
greg->monitor = gval;
break;
}
if (strcmp(cmd,"load_ch")==0) {
row = board*144+asic*36+ch+1;
/*
SetTableCellVal (p3h, P3_CREG, MakePoint (1,row), asic);
SetTableCellVal (p3h, P3_CREG, MakePoint (2,row), ch);
SetTableCellVal (p3h, P3_CREG, MakePoint (3,row), creg->decaytime);
SetTableCellVal (p3h, P3_CREG, MakePoint (4,row), creg->offset);
SetTableCellVal (p3h, P3_CREG, MakePoint (5,row), creg->fineadj_unipol);
SetTableCellVal (p3h, P3_CREG, MakePoint (6,row), creg->fineadj_diff);
SetTableCellVal (p3h, P3_CREG, MakePoint (7,row), creg->tpenb);
SetTableCellVal (p3h, P3_CREG, MakePoint (8,row), creg->kill);
*/
 
cregdata[(row -1)*8] = (unsigned short) asic;
cregdata[(row -1)*8+1] = (unsigned short) ch;
cregdata[(row -1)*8+2] = creg->decaytime;
cregdata[(row -1)*8+3] = creg->offset;
cregdata[(row -1)*8+4] = creg->fineadj_unipol;
cregdata[(row -1)*8+5] = creg->fineadj_diff;
cregdata[(row -1)*8+6] = creg->tpenb;
cregdata[(row -1)*8+7] = creg->kill;
cdata=0;
break;
}
if (strcmp(cmd,"select")==0) {
sa02Printf ("%s not implemeted yet\n", cmd);
break;
}
break;
}
case 4: {
if (strcmp(cmd,"param_ch")==0) {
cdata = 0;
break;
}
if (strcmp(cmd,"decaytime")==0) {
creg->decaytime = cval;
break;
}
if (strcmp(cmd,"offset")==0) {
creg->offset = cval;
break;
}
if (strcmp(cmd,"fineadj_unipol")==0) {
creg->fineadj_unipol = cval;
break;
}
if (strcmp(cmd,"fineadj_diff")==0) {
creg->fineadj_diff = cval;
break;
}
if (strcmp(cmd,"tpenb")==0) {
creg->tpenb = cval;
break;
}
if (strcmp(cmd,"kill")==0) {
creg->kill = cval;
break;
}
break;
}
}
 
}
fclose(fp);
SetTableCellRangeVals (p3h, P3_CREG, MakeRect (1, 1, 144*4, 8), cregdata, VAL_ROW_MAJOR);
SetTableCellRangeVals (p3h, P3_GREG, MakeRect (1, 1, 4*4, 7) , gregdata, VAL_ROW_MAJOR);
 
sa02Printf("Parameters loaded from file %s to Parameter Panel \n", fname);
return 0;
}
 
void CVICALLBACK MenuCB(int menubar, int menuItem, void *callbackData, int panel) {
switch (menuItem) {
case MENU_OPERATIO_CAEN_V729:
DisplayPanel(p4h);
break;
case MENU_OPERATIO_SA02CFG :
DisplayPanel(p3h);
break;
case MENU_OPERATIO_2DSCAN:
DisplayPanel(p2h);
break;
case MENU_OPERATIO_LASER:
DisplayPanel(p5h);
break;
case MENU_MINIRICH:
DisplayPanel(p6h);
break;
case MENU_OPERATIO_EXIT :
quit(0,0,NULL,0,0);
exit(0);
//loop_on=0;
break;
case MENU_HELP :
sa02Help();
break;
}
}
 
int CVICALLBACK daq_readonly(void *functionData) {
int h2=0;
uint32_t trglen;
uint32_t data[10000];
uint16_t mask;
//int ison;
//int *fdata= (int *) functionData;
int nbit,neve,nb,ch,i,j,sendswtrg;
 
time_t t,told, tstart;
//int gBoardNumber=0;
int ploteachevent =0;
 
GetCtrlVal(p1h,P1_PLOTEACHEVENT, &ploteachevent);
GetCtrlVal(p1h,P1_TOREAD , &neve);
GetCtrlVal(p1h,P1_NSLIX , &nbit);
if (nbit>7) {
nbit=7;
}
GetCtrlVal(p1h,P1_SENDSWTRIG,&sendswtrg);
GetCtrlVal(p1h,P1_INTTRGLEN, &trglen);
 
mask=GetConnectedFebMask();
Sa02SelectTriggerWithMaskAndLength (sendswtrg, mask, trglen);
Sa02SetNeve(2);
 
H2DInit(h2,"hbit","Bit Occupancy", 144*4, 0,1,8,0, 1);
H2DSetTitleX(h2,"channel");
H2DSetTitleY(h2,"Data bit");
time(&t);
tstart=t;
told=t;
for ( j=0; j< neve; j++) {
do {
if (sendswtrg==1) Sa02SoftwareTrigger();
nb = sa02Read(mask, data );
} while ( nb==0 && !ctrl_c);
if (nb==0) sa02Printf("nb==0 LINE=%d\n",__LINE__);
 
if (ctrl_c==1) break;
 
for (ch=0; ch<144*4; ch++) {
int board = ch/144;
int xch = (143 - ch%144) + board *144;
for (i=0; i<8; i++) if (data[ch] & (1<<i) ) H2DFillBin(h2,xch,i,1);
}
/*
for (ch=0; ch<144*4; ch++)
{
id=(35-ch/4)+gBoardNumber*36;
shft=(ch%4)*8;
for (i=0; i<8; i++)
{
if (data[id] & (1<<(i+shft)) )
{
H2DFillBin(h2,ch,i,1);
}
}
if (sa02Verbose>2)
{
sa02Printf("%02X ",(data[id]>> shft)& 0xFF );
}
}
*/
 
if (sa02Verbose>2) {
sa02Printf("\n" );
}
 
time(&t);
if (t!=told || ploteachevent) {
sa02Printf("%d events in %2.2f min (%d s) %s",j, (double)(t-tstart)/60.,t-tstart, ctime(&t));
GetCtrlVal(p1h,P1_NSLIY,&nbit);
plot2d(h2, nbit);
GetCtrlVal(p1h,P1_PLOTEACHEVENT, &ploteachevent);
SetCtrlVal(p1h,P1_CUREVE, j);
ProcessSystemEvents ();
ProcessSystemEvents ();
}
 
told=t;
 
}
 
plot2d(h2, nbit);
SetCtrlVal(p1h,P1_CUREVE, j);
 
return 0;
}
 
int CVICALLBACK LoadParameters (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
char fname[0xFF];
uint16_t mask;
switch (event) {
case EVENT_COMMIT:
mask=GetConnectedFebMask();
sa02Printf("LoadParameters 0x%0x\n", mask);
GetCtrlVal(p3h, P3_INPUTFILE, fname);
GetCtrlVal(p1h,P1_BOARDTYPE,&sa02BoardType);
SetCtrlAttribute (panel, control, ATTR_DIMMED, 1);
sa02LoadParametersFromFile(fname, mask);
SetCtrlAttribute (panel, control, ATTR_DIMMED, 0);
 
break;
}
return 0;
}
 
int SlowControl(uint32_t board, FILE *fp) {
uint32_t data;//,step,cmd;//,response[2]= {0,0};
int chip,channel,i;
//double doubleval;
char saddress[0xFF];
double sdata[20];
 
chip=0;
channel=0;
data=0;
 
GetCtrlVal(p1h,P1_BOARDTYPE,&sa02BoardType);
sa02Status(board,saddress,sdata);
SetCtrlVal(p1h,fpga_serials[board],saddress);
if (fp) {
fprintf(fp,"<slowc>\n<id>%d</id>\n", board );
fprintf(fp,"<dna>%s</dna>\n",saddress );
for (i=0; i<12; i++) fprintf(fp,"<%s>%f</%s>\n",slowcname[i],sdata[i],slowcname[i] );
fprintf(fp,"</slowc>\n" );
}
PlotStripChart (p1h, chart_control[board], sdata, 12, 0, 0, VAL_DOUBLE);
return 0;
}
 
 
int WriteChannelParameters ( int offset, int fine_offset, int tpenb) {
 
uint32_t response[2]= {0,0};
uint32_t cdata;
 
sa02AsicChannelRegister *creg = (sa02AsicChannelRegister *) &cdata ;
unsigned int i=0, j=0;
int row=0;
unsigned short val,asic,ch, board;
uint16_t mask=GetConnectedFebMask();
for (j=0; j<144*4; j++) {
i = j%144;
board = (unsigned short) j/144;
asic=(unsigned short )(i/36);
ch=(unsigned short )(i%36);
row=j+1;
GetTableCellVal (p3h, P3_CREG, MakePoint (1,row), &asic);
GetTableCellVal (p3h, P3_CREG, MakePoint (2,row), &ch);
GetTableCellVal (p3h, P3_CREG, MakePoint (3,row), &val);
creg->decaytime=val;
creg->offset = offset;
creg->fineadj_unipol = fine_offset;
GetTableCellVal (p3h, P3_CREG, MakePoint (6,row), &val);
creg->fineadj_diff = val;
creg->tpenb = tpenb;
//sa02Printf("===%d %d\n",i, tpenb);
GetTableCellVal (p3h, P3_CREG, MakePoint (8,row), &val);
creg->kill = val;
creg->unused=0;
if ( mask &(1<<board)) sa02Cmd(board,SA0x_ASIC0_CREG, cdata, asic, ch,1,response);
 
if (ctrl_c) {
break;
}
}
return 0;
}
 
int FebTestAna(void) {
int current_run;
char cmdCommand[0xFF];
current_run = GetRunNumberFromFile("current_run.txt");
sprintf(cmdCommand ,"C:/root/bin/root.exe \"../macros/febreport.cxx(\\\"data\\\", %d )\"", current_run);
sa02Printf("%s\n",cmdCommand);
LaunchExecutable(cmdCommand);
return 0;
}
 
int FebTest(void) {
int board=0, j=0, value, step;
 
FILE *fp;
int ndim=400;
char line[ndim];
int current_run=1;
time_t t;
int start;
int addheader=1;
char filename[0xFF];
char cmdCommand[0xFF];
 
uint32_t mask=GetConnectedFebMask();
 
LoadParameters(p3h, P3_LOADPAR,EVENT_COMMIT,NULL,0,0);
 
 
fp = fopen ("current_run.txt","r");
if (fp) {
if (fgets(line,ndim,fp)!=NULL) current_run=atoi(line)+1;
fclose(fp);
fp= NULL;
}
 
sprintf(line,"data\\febtest_%04d.dat",current_run );
SetCtrlVal(p1h,P1_OUTPUTFILE, line);
 
SetCtrlVal(p1h,P1_SENDSWTRIG,3 ); // set internal trigger
SendTriggerTypeCB(p1h,P1_TEST, EVENT_COMMIT,NULL, 0,0);
 
ThresholdLinearityCB (p1h, P1_THRVSADC, EVENT_COMMIT, NULL, 0, 0 );
 
GetCtrlVal(p1h,P1_OUTPUTFILE, filename);
fp = fopen(line, "ab");
if(fp) {
for (board=0; board<4; board++) if ( mask &(1<<board)) H1DWrite2File(board,fp);
fclose(fp);
}
 
 
sprintf(line,"data/febslowc_%04d.xml",current_run );
// SetCtrlVal(p1h, P1_RUNID, current_run);
fp = fopen (line,"w");
fprintf(fp,"<febtest>\n");
time(&t);
fprintf(fp,"<time>%s</time>\n", ctime(&t));
 
 
 
if (!ctrl_c) for (board=0; board<4; board++) {
if ( mask &(1<<board)) {
for (j=0; j<10; j++) {
SlowControl(board,fp);
ProcessSystemEvents ();
if (ctrl_c) break;
}
}
if (ctrl_c) break;
}
 
 
fprintf(fp,"</febtest>\n");
fclose(fp);
 
 
fp = fopen ("current_run.txt","w");
fprintf(fp,"%d\n", current_run);
fclose(fp);
 
 
 
 
 
WriteChannelParameters ( 0,0,0); // Test pulse on all channels
for (board=0; board<4; board++) if ( mask &(1<<board)) SlowControl(board,fp);
SetCtrlVal(p1h,P1_TPENB,1); // enable test pulse
 
SetCtrlVal(p1h,P1_DATA, 350);
SetCtrlVal(p1h,P1_NEVE, 150);
 
GetCtrlVal(p1h,P1_DATA, &start);
 
daq(NULL);
SetCtrlVal(p1h,P1_TPENB,0); // disable test pulse
 
 
// coarse offset
step=1;
if (!ctrl_c) for (value=0; value<16; value+=step) {
if (addheader) {
iteratorrec.id = ITERATORREC_ID;
iteratorrec.len = sizeof(iteratorrec);
iteratorrec.value = value;
iteratorrec.n = 16;
iteratorrec.step = step;
iteratorrec.level = 1;
GetCtrlVal(p1h,P1_OUTPUTFILE, filename);
fp = fopen(filename, "ab");
if(fp) {
fwrite (&iteratorrec, 1, iteratorrec.len, fp);
fclose(fp);
}
}
 
WriteChannelParameters ( value,0,1);
 
SetCtrlVal(p1h,P1_DATA,start - (value%8) * 13 + (value/8)*13*8 );
sa02Printf("offset=>%d\n", value);
daq(NULL);
if (ctrl_c) break;
}
 
// fine offset
if (!ctrl_c) for (value=0; value<16; value+=step) {
if (addheader) {
iteratorrec.id = ITERATORREC_ID;
iteratorrec.len = sizeof(iteratorrec);
iteratorrec.value = value;
iteratorrec.n = 16;
iteratorrec.step = step;
iteratorrec.level = 1;
GetCtrlVal(p1h,P1_OUTPUTFILE, filename);
fp = fopen(filename, "ab");
if(fp) {
fwrite (&iteratorrec, 1, iteratorrec.len, fp);
fclose(fp);
}
}
 
 
WriteChannelParameters (0, value,1);
 
SetCtrlVal(p1h,P1_DATA, start - (value%8) + (value/8)*8 );
sa02Printf("offset=>%d\n", value);
daq(NULL);
if (ctrl_c) break;
}
 
SetCtrlVal(p1h,P1_DATA, start);
 
GetCtrlVal(p1h,P1_OUTPUTFILE, filename);
 
sprintf(cmdCommand,"..\\sa02read -i %s -o data\\febtest_%04d.root", filename, current_run);
sa02Printf("%s\n",cmdCommand);
LaunchExecutable(cmdCommand);
 
//sprintf(cmdCommand ,"C:/root/bin/root.exe ../macros/febreport.cxx(\\\"data/febtest_%04d.root\\\")", current_run);
sprintf(cmdCommand ,"C:/root/bin/root.exe \"../macros/febreport.cxx(\\\"data\\\", %d )\"", current_run);
sa02Printf("%s\n",cmdCommand);
LaunchExecutable(cmdCommand);
 
sprintf(line,"%s", "test.dat");
SetCtrlVal(p1h,P1_OUTPUTFILE, line);
//daq(NULL);
return 0;
}
 
 
int CVICALLBACK ThresholdLinearityCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
const int kmax= 1024;
const int boardmax= 4;
 
switch (event) {
case EVENT_COMMIT: {
uint32_t val,retval, board,data,response[2]= {0,0};
int k;
int chip,channel;
double doubleval;
time_t t,told;
char title[0xFF];
char name[0xFF];
int h1=0;
uint16_t mask=GetConnectedFebMask();
chip=0;
channel=0;
GetCtrlVal(p1h,P1_BOARDTYPE,&sa02BoardType);
 
for (board=0; board<boardmax; board++) if ( mask &(1<<board)) {
char serial[0xFF];
GetCtrlVal(p1h,hapd_serials[board],serial );
sprintf(title,"VTH1 linearity, position %d sn=%s", board, serial);
sprintf(name,"vth1_%d", board);
H1DInit(h1+board, name,title, kmax, 0 ,1);
H1DSetTitleX(h1+board,"VTH1");
H1DSetTitleY(h1+board,"ADC(VTH1)");
SetCtrlAttribute (p1h, P1_GRAPH, ATTR_XNAME, H1DGetTitleX(h1+board) );
SetCtrlAttribute (p1h, P1_GRAPH, ATTR_YNAME, H1DGetTitleY(h1+board) );
//SetCtrlAttribute (p1h, P1_GRAPH, ATTR_LABEL_TEXT , H1DGetTitle(h1+board) );
if (phandle[board]> 0 ) DeleteGraphPlot (p1h, P1_GRAPH, phandle[board], VAL_IMMEDIATE_DRAW);
phandle[board] = 0;
}
for (board=0; board<boardmax; board++) if ( mask &(1<<board)) {
val=sa02Cmd(board, FEB_MUX, data=0x20, chip, channel ,1,response); // set mux to VTH1
time(&t);
told=t;
if (ctrl_c) break;
for (k=0; k<kmax; k++) {
if (ctrl_c) break;
SetCtrlVal(p1h,P1_SETSINGLEVALUE,k);
SetCtrlVal(p1h,P1_CUREVE,k);
retval=sa02Cmd(board, FEB_VTH1 , k , chip, channel ,1, response);
val=sa02Cmd(board, FEB_ADC_READ, data, chip, channel ,1,response);
if (sa02BoardType>2)
doubleval = (2*((val & 0xFFF) + 0.5)/0x1000 - 1.) * 3.3;
else
doubleval = ((val & 0xFFF) + 0.5)/0x1000 * 3.3;
 
 
H1DFillBin(h1+board, k, doubleval);
if (t!=told || k==kmax-1 ||k==0 ) {
H1DDraw(h1+board,p1h, P1_GRAPH, &phandle[board]);
sa02Printf("[%d] set VTH1=%d ADC(VTH1)= %6.3f V\n",board, k, doubleval);
SetCtrlVal(p1h,P1_CUREVE, k);
ProcessSystemEvents ();
}
told=t;
time(&t);
}
}
break;
}
}
return 0;
}
 
 
int CVICALLBACK MultiFpgaWrite (void *functionData) {
uint32_t val, board,data,step,cmd,response[2]= {0,0};
char scmd[0xFF],sdata[0xFF];
int chip, channel;
char filename[0xFF];
double delay, doubleval=0, x0, dx;
int neve,i,daqexe,addheader;
time_t t,told, tstart;
FILE *fp;
//int h2=0;
int *fdata= (int *) functionData;
 
datrec.id = DATREC_ID;
datrec.len = sizeof(datrec);
GetCtrlVal(p1h,P1_MULTINEVE , &neve);
GetCtrlVal(p1h,P1_WAIT , &delay);
GetCtrlVal(p1h, P1_SINGLEWRITECMD, scmd);
cmd=sa02GetCmdCode(scmd);
GetCtrlVal(p1h,P1_BOARDNUMBER, &board);
GetCtrlVal(p1h,P1_BOARDTYPE,&sa02BoardType);
GetCtrlVal(p1h, P1_SINGLEDATA, sdata);
data = strtoul (sdata,NULL,0);
// if (strcmp(scmd,"MUXASIC")==0) {
// data = sa02MuxMap(data);
// sa02Printf("MUX %d\n",data);
// }
GetCtrlVal(p1h, P1_SINGLEDATA, sdata);
data = strtoul (sdata,NULL,0);
x0=(double)data;
GetCtrlVal(p1h, P1_DSTEP0, &step);
dx=(double)step;
GetCtrlVal(p1h,P1_SINGLECHIP,&chip);
GetCtrlVal(p1h,P1_SINGLECHANNEL,&channel);
if (fdata[0]==P1_FPGAWRITE) {
neve=1;
}
GetCtrlVal(p1h,P1_DAQEXE,&daqexe);
GetCtrlVal(p1h,P1_ADDHEADER,&addheader);
time(&t);
tstart=t;
told=t;
if (addheader) {
iteratorrec.id = ITERATORREC_ID;
iteratorrec.len = sizeof(iteratorrec);
iteratorrec.value = data;
iteratorrec.n = neve;
iteratorrec.step = step;
iteratorrec.level = 2;
GetCtrlVal(p1h,P1_OUTPUTFILE, filename);
fp = fopen(filename, "ab");
if(fp) {
fwrite (&iteratorrec, 1, iteratorrec.len, fp);
fclose(fp);
}
}
for (i=0; i<neve; i++) {
SetCtrlVal(p1h,P1_SETSINGLEVALUE,data);
SetCtrlVal(p1h,P1_CUREVE,i);
val=sa02Cmd(board, cmd, data, chip, channel ,1, response);
if (addheader) {
datrec.cmd =cmd;
datrec.data =data;
datrec.chip =chip;
datrec.channel=channel;
datrec.retval =val;
GetCtrlVal(p1h,P1_OUTPUTFILE, filename);
fp = fopen(filename, "ab");
if(fp) {
fwrite (&datrec, 1, datrec.len, fp);
fclose(fp);
}
}
switch (cmd & (~ FEB_RO)) {
case FEB_ADC_READ:
case FEB_ADC_RESET:
doubleval = ((val & 0xFFF) + 0.5)/0x1000 * 3.3;
sa02Printf("ADC %f, 0x%08x\n", doubleval, val ) ;
break;
case FEB_TMON1:
case FEB_TMON0:
doubleval = ( (val >>2 ) & 0xFFF ) * 0.0625;
if (val&0x4000) {
doubleval=-doubleval;
}
sa02Printf("TMON %f 0x%x\n",doubleval, val ) ;
break;
case FEB_VTH1:
case FEB_VTH2:
doubleval = (val & 0xFFFF );
if (cmd & 1)
val=0x20;
else
val=0x30;
val=sa02Cmd(board, FEB_MUX, val, 0, 0 ,1,response);
val=sa02Cmd(board, FEB_ADC_READ, 0, 0, 0, 1,response);
if (sa02BoardType>2)
doubleval = (2*((val & 0xFFF) + 0.5)/0x1000 - 1.) * 3.3;
else
doubleval = ((val & 0xFFF) + 0.5)/0x1000 * 3.3;
sa02Printf("%5d %6.3f\n",data, doubleval);
break;
case SA0x_ASIC0_GREG:
if (cmd & FEB_RO) {
sa02PrintGREG(&val,"Returned GREG data->");
}
break;
case SA0x_ASIC0_CREG:
if (cmd & FEB_RO) {
sa02PrintCREG(&val,"Returned CREG data->");
}
break;
default:
sa02Printf("0x%08X\n",val);
// break;
}
datay[i]=doubleval;
if (delay>0 && fdata[0]==P1_MULTIFPGAWRITE) {
Delay(delay);
}
if (daqexe) {
daq(NULL);
}
if (ctrl_c) {
break;
}
if (t!=told ) {
plot1d(i,x0,dx);
SetCtrlVal(p1h,P1_CUREVE, i);
ProcessSystemEvents ();
}
data+=step;
told=t;
time(&t);
}
plot1d(i,x0,dx);
SetCtrlVal(p1h,P1_CUREVE, i);
return 0;
}
 
int CVICALLBACK SendSEUTRigger (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
 
switch (event) {
case EVENT_COMMIT:
Sa02SEUTrigger();
break;
}
return 0;
}
 
int CVICALLBACK FSelect (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
int status,fcontrol = 0;
char pathName[MAX_PATHNAME_LEN];
char defName[MAX_PATHNAME_LEN];
char fileMessage[100] = "";
switch (event) {
case EVENT_COMMIT:
switch (control) {
case P3_FSELECT:
fcontrol=P3_INPUTFILE;
strcpy(fileMessage,"Select Parameter file");
break;
case P3_PTSFSELECT:
fcontrol=P3_PTSFIRMWARE;
strcpy(fileMessage,"Select PTS Firmware file");
break;
}
sa02Printf("MAX_PATHNAME_LEN %d\n",MAX_PATHNAME_LEN);
GetCtrlVal(panel,fcontrol,defName);
status = FileSelectPopup ("",defName,"",
fileMessage, VAL_LOAD_BUTTON, 0,
0, 1, 0, pathName);
if (status>0)
SetCtrlVal(panel,fcontrol,pathName);
break;
}
return 0;
}
 
int CVICALLBACK Verbose (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
//int * data;
switch (event) {
case EVENT_COMMIT:
GetCtrlVal(panel,control,&sa02Verbose);
break;
}
return 0;
}
 
int CVICALLBACK Print (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
char dfile[MAX_PATHNAME_LEN];
char name[MAX_PATHNAME_LEN];
int h2=0;
switch (event) {
case EVENT_COMMIT: {
int hours, minutes, seconds;
int month, day, year;
int id=-1;
//int bitmap = 0;
if (panel == p1h) {
switch (control) {
case P1_PRINT:
id= P1_GRAPH;
sprintf(name,"G");
break;
case P1_PRINT2D:
id= P1_GRAPH2D;
sprintf(name,"2D");
break;
case P1_PRINTX:
id= P1_GRAPHX;
sprintf(name,"X");
break;
case P1_PRINTY:
id= P1_GRAPHY;
sprintf(name,"Y");
break;
}
h2=0;
} else {
switch (control) {
case P2_PRINTXY:
id= P2_GRAPH_1;
sprintf(name,"XY");
break;
}
h2=1;
}
GetSystemDate (&month,&day ,&year );
GetSystemTime(&hours, &minutes, &seconds);
if (id>=0) {
if( ( (panel == p1h)&&(control == P1_PRINT2D) ) || ((panel == p2h)&&(control == P2_GRAPH_1))) {
sprintf(dfile ,"data/%d_%d_%d_%d_%d_%s.th2d",year,month,day,hours,minutes, name );
H2DWrite(h2,dfile,"wb");
sa02Printf("sizeof H2D %d \n",sizeof(H2D));
sa02Printf("H2D image saved as %s\n", dfile);
sprintf(name ,"C:\\root\\bin\\root.exe ..\\macros\\H2Dload.cxx(\\\"%s\\\")", dfile);
LaunchExecutable(name);
} else {
sprintf(dfile ,"data/%d_%d_%d_%d_%d_%s.bmp",year,month,day,hours,minutes, name );
SaveCtrlDisplayToFile (panel,id, 0, -1, -1, dfile);
sa02Printf("bmp image saved as %s\n", dfile);
}
}
//PrintCtrl (p1h, P1_GRAPH2D, "sa02_CVI", 1, 1);
}
break;
}
return 0;
}
 
int CVICALLBACK CursorCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
double x=0,y=0;
int ix=0,iy=0;
int h2=(int) callbackData;
 
switch (event) {
case EVENT_COMMIT:
GetGraphCursor (p1h, P1_GRAPH2D, 1, &x, &y);
if(H2DGetStepX(h2)>0) {
ix=(int)((x-H2DGetMinX(h2))/H2DGetStepX(h2));
}
if(H2DGetStepY(h2)>0) {
iy=(int)((y-H2DGetMinY(h2))/H2DGetStepY(h2));
}
SetCtrlVal(panel,P1_NSLIX,ix);
SetCtrlVal(panel,P1_NSLIY,iy);
sa02Printf("Cursor %f %f h2=%d val=%f min=%f max=%f\n",
x,y,h2,H2DGetBinContent(h2,ix,iy),H2DGetMin(h2),
H2DGetMax(h2) );
break;
}
return 0;
}
 
 
int CVICALLBACK HistoInfoCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
double x=0,y=0;
int ix=0,iy=0;
int h2=(int) callbackData;
int b=0;
switch (event) {
case EVENT_COMMIT:
 
GetGraphCursor (panel, control, 1, &x, &y);
if (panel == p2h ) {
for (b=0; b<4; b++) {
if (control==p2graph[b]) break;
}
h2=100+b;
if(H2DGetStepX(h2)>0) {
ix=(int)((x-H2DGetMinX(h2))/H2DGetStepX(h2));
}
if(H2DGetStepY(h2)>0) {
iy=(int)((y-H2DGetMinY(h2))/H2DGetStepY(h2));
}
 
sa02Printf("Cursor %f %f h2=%d val=%f min=%f max=%f\n",
x,y,h2,H2DGetBinContent(h2,ix,iy),H2DGetMin(h2),
H2DGetMax(h2) );
}
break;
}
return 0;
}
 
 
int GetElectronicChannel(int x, int y, int *chip, int *ch) {
int i=0;
for (i=0; i<144; i++) {
if (eid2hapdxy[i].chx == x && eid2hapdxy[i].chy == y) {
*chip = eid2hapdxy[i].chip;
*ch = eid2hapdxy[i].ch ;
return 0;
}
}
return -1;
}
 
int SetCMon(int chx,int chy) {
int chip,ch,asic;
uint32_t response[2]= {0,0};
uint32_t board;
uint16_t mask=GetConnectedFebMask();
 
// GetCtrlVal(p1h,P1_BOARDNUMBER, &board);
GetCtrlVal(p1h,P1_BOARDTYPE,&sa02BoardType);
GetElectronicChannel(chx,chy,&chip,&ch);
asic = sa02MuxMap(chip);
sa02Printf("CHX %d CHY %d ",chx, chy);
sa02Printf("MUX %d ",asic);
sa02Printf("CMON ASIC: %d ch: %d\n",chip, ch);
for (board=0; board<4; board++) {
if (mask & (1<<board)) {
sa02Cmd(board,FEB_MUX , asic, 0, 0 ,2,response);
sa02Cmd(board,SA0x_ASIC0_CMON,0,chip,ch,2,response);
}
}
 
return 0;
}
 
int CVICALLBACK HDraw2DCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
int ch=0;
int ctrlID=0;
int *plot=0;
int graph=0;
int board=0;
switch (event) {
 
case EVENT_COMMIT:
for (board=0; board<4; board++) {
// if (panel == p1h){ rID = P1_CH; graph = P1_GRAPH; plot =&p1plothandle;}
if (panel == p2h) {
ctrlID = P2_CH;
graph = p2graph[board];
plot =&p2plothandle[board];
}
// if (panel == p3h){ rID = P3_CH; graph = P3_GRAPH; plot =&p3plothandle;}
// if (panel == p4h){ rID = P4_CH; graph = P4_GRAPH; plot =&p4plothandle;}
 
 
GetCtrlVal(panel,ctrlID, &ch);
if (ch) {
H3DDrawSliceXY(100+board,ch-1,panel,graph, plot);
} else {
H2DDraw(100+board,panel,graph, plot);
}
}
break;
}
return 0;
}
 
int GetHvMonitor( void ) {
int N470mid = 4;
int SYS403mid = 2;
unsigned short buf[256]= {0};
int retval;
int ii;
// G0,A0,B0,C0,D0,H0,G1,A1,B1,C1,D1,H1,G2,A2,B2,C2,D2,H2,G3,A3,B3,C3,D3,H3
int channels[]= {24, 0, 1, 2, 3, 0,25, 4, 5, 6, 7, 1,26, 8, 9,10,11, 2,27,12,13,14,15, 3}; //channel for SYS403 , then for N470
// int channels[]= {0,1,2,3,4,0,5,6,7,8,9,1,10,11,12,13,14,2,15,16,17,18,19,3}; //channel for SYS403 , then for N470
 
for (ii=0; ii<256; ii++) buf[ii]=0;
monrec.time = (uint32_t) time(NULL);
for (ii=0; ii<=23; ii++) {
if ((ii+1)%6==0 && ii!=0) {
buf[0]=(unsigned short) (channels[ii]<<8) | ReadOperationalParam;
if (gCAEN_V288) {
V288_Send(0,N470mid,1,buf);
retval=V288_Receive(0,255, buf);
}
monrec.status[ii] = buf[0]; //status
monrec.vmon[ii] = buf[1]*1000;//zapisano v mV
monrec.imon[ii] = buf[2]*1000;//zapisano v nA
monrec.vset[ii] = buf[3]*1000;//zapisano v mV
monrec.iset[ii] = buf[4]*1000;//zapisano v nA
} else {
buf[0]=(unsigned short) (channels[ii]<<8) | ReadStatus;
if (gCAEN_V288) {
V288_Send(0,SYS403mid,1,buf);
retval=V288_Receive(0,255,buf);
}
monrec.vmon[ii] = buf[1]*10;//zapisano v mV
monrec.imon[ii] = buf[2]*10;//zapisano v nA
monrec.status[ii] = buf[3]; //status
 
if (!hvmonFirst) {
buf[0]=(unsigned short) (channels[ii]<<8) | ReadParameters;
if (gCAEN_V288) {
V288_Send(0,SYS403mid,1,buf);
retval=V288_Receive(0,255,buf);
}
vset[ii] = monrec.vset[ii] = buf[7]*10;//zapisano v mV
iset[ii] = monrec.iset[ii] = buf[10]*10;//zapisano v nA
}
monrec.vset[ii] = vset[ii];//zapisano v mV
monrec.iset[ii] = iset[ii];//zapisano v nA
}
//sa02Printf("%04x \t %d \t %d \t %d \t %d *\n",monrec.status[ii],monrec.vmon[ii],monrec.vset[ii],monrec.imon[ii],monrec.iset[ii]);
}
hvmonFirst=1;
return 0;
}
 
int CVICALLBACK daq_scan(void *functionData) {
int ich,count=0, xyval[4]= {0,0,0,0};
//int c[4]= {0,0,0,0};
//int e[4]= {0,0,0,0};
uint32_t daqmode=1;
uint32_t trglen;
int nb,dsave,fcount=0,fmax=0,status,ch;
unsigned int i;
int hxy=100;
//int h2=0;
time_t t,told, tstart, t0;
 
uint32_t board;
uint32_t tpenb =0;
uint32_t response[2]= {0,0};
char title[0xFF];
char dfile[MAX_PATHNAME_LEN],dfile0[MAX_PATHNAME_LEN];
#define MAXSIZE 10000
int maxsize = MAXSIZE;
uint32_t sendswtrg=0;
int ncount=0;
uint32_t *rdata;
float dx,dy,gapx,gapy,addgap;
int ix,iy,nx,ny;
int scanunitsx=0,scanunitsy=0;
int x0,y0;
const float fx= (float)(1000 / 0.3595); // 4M scaling factor steps/mm
int daqexe;
int writeevents=0;
double fraction=0;
uint32_t *data;
char serial[4][0xFF];
char hname[0xFF];
time_t cas;
 
uint16_t mask=GetConnectedFebMask();
runrec.id = RUNREC_ID;
runrec.len = sizeof(runrec);
endrec.id = ENDREC_ID;
endrec.len = sizeof(endrec);
posrec.id = POSREC_ID;
posrec.len = sizeof(posrec);
evtrec.id = EVTREC_ID;
evtrec.len = sizeof(evtrec);
datrec.id = DATREC_ID;
datrec.len = sizeof(datrec);
monrec.id = MONREC_ID;
monrec.len = sizeof(monrec);
 
SetCtrlAttribute (p2h, P2_DAQ, ATTR_DIMMED, 1);
ctrl_c=0;
 
GetCtrlVal(p1h,P1_BOARDTYPE,&sa02BoardType);
 
GetCtrlVal (p1h, P1_SERIAL_1, serial[0]);
GetCtrlVal (p1h, P1_SERIAL_2, serial[1]);
GetCtrlVal (p1h, P1_SERIAL_3, serial[2]);
GetCtrlVal (p1h, P1_SERIAL_4, serial[3]);
 
sprintf(runrec.serial,"HAPD=%s,%s,%s,%s", serial[0],serial[1],serial[2],serial[3]);
 
GetCtrlVal (p2h, P2_NEVE, &runrec.nev);
GetCtrlVal (p2h, P2_PEDESTAL, &runrec.ped);
GetCtrlVal (p2h, P2_NX, &runrec.nx);
GetCtrlVal (p2h, P2_XSTEP, &runrec.dx);
GetCtrlVal (p2h, P2_XMIN, &runrec.x0);
GetCtrlVal (p2h, P2_NY, &runrec.ny);
GetCtrlVal (p2h, P2_YSTEP, &runrec.dy);
GetCtrlVal (p2h, P2_YMIN, &runrec.y0);
GetCtrlVal ( p1h, P2_TPENB,&tpenb);
GetCtrlVal ( p2h,P2_DAQEXE,&daqexe);
GetCtrlVal(p2h,P2_FRACTION, &fraction);
GetCtrlVal (p2h, P2_SCANUNITSX, &scanunitsx);
GetCtrlVal (p2h, P2_SCANUNITSY, &scanunitsy);
GetCtrlVal (p2h, P2_GAPX, &gapx);
GetCtrlVal (p2h, P2_GAPX, &gapy);
GetCtrlVal (p2h, P2_DX, &dx);
GetCtrlVal (p2h, P2_DX, &dy);
 
GetCtrlVal (p2h, P2_XC, &x0);
GetCtrlVal (p2h, P2_YC, &y0);
 
GetCtrlVal (p2h, P2_DIRECTION, &runrec.direction);
 
 
SetCtrlAttribute(p1h,P1_TRGHVMON,ATTR_ENABLED,1);
hvmonFirst = 0;
 
 
GetCtrlVal(p1h,P1_SENDSWTRIG,&sendswtrg);
GetCtrlVal(p1h,P1_INTTRGLEN, &trglen);
GetCtrlVal(p1h,P1_DAQMODE, &daqmode);
 
 
 
 
runrec.fver = scanunitsx + scanunitsy*2 ;
if (scanunitsx) {
x0 = (int)(x0 - 5.5 * fx * dx - gapx * fx * 0.5);
}
if (scanunitsy) {
y0 = (int)(y0 - 5.5 * fx * dy - gapy * fx * 0.5);
}
 
GetCtrlVal(p2h, P2_DSAVE, &dsave);
if (dsave) {
GetCtrlVal (p2h, P2_DFILE, dfile0);
fcount=1;
GetCtrlVal (p2h, P2_NEWF, &fmax);
fmax*=1000000;//fmax in Mega Bytes
}
time (&t0);
sa02Printf("---->daq_scan\n");
if (dsave) {
sprintf(dfile,"%s_file%02d.dat",dfile0,fcount);
//gFp = fopen (dfile, "ab");
gFp = fopen (dfile, "ab");
if (gFp==NULL) sa02Printf("----> !!! gFp==NULL !!!\n");
if (ferror (gFp)) sa02Printf("----> !!! ferror (gFp) after fopen !!!\n");
//time ((time_t *) &runrec.time);
time (&cas);
runrec.time = (uint32_t) cas;
status = (int) fwrite (&runrec, 1, runrec.len, gFp);
if(status != runrec.len) sa02Printf("----> !!! status != runrec.len (= %d) !!!\n", status);
if (ferror (gFp)) sa02Printf("----> !!! ferror (gFp) = %d !!!\n", ferror (gFp));
}
 
 
for (i=0; i<4; i++) {
sprintf(title,"HAPD%d Surface Scan single channels", i);
sprintf(hname,"hxy%d", i);
H3DInit(hxy+i,hname,title, runrec.nx,runrec.x0, runrec.dx,runrec.ny,runrec.y0, runrec.dy, 144, -0.5, 1);
H3DSetTitleZ(hxy+i,"channel");
sprintf(hname,"hxy%d_sum", i);
H2DInit(hxy+i,hname,runrec.serial, runrec.nx,runrec.x0, runrec.dx,runrec.ny,runrec.y0, runrec.dy);
if (scanunitsx) {
H2DSetTitleX(hxy+i,"x (channels)");
H3DSetTitleX(hxy+i,"x (channels)");
} else {
H2DSetTitleX(hxy+i,"x (stage steps)");
H3DSetTitleX(hxy+i,"x (stage steps)");
}
if (scanunitsy) {
H2DSetTitleY(hxy+i,"y (channels)");
H3DSetTitleY(hxy+i,"y (channels)");
} else {
H2DSetTitleY(hxy+i,"y (stage steps)");
H3DSetTitleY(hxy+i,"y (stage steps)");
}
 
}
if (runrec.direction) {
ny = runrec.ny;
nx = runrec.nx;
} else {
ny = runrec.nx;
nx = runrec.ny;
}
rdata = malloc(sizeof(uint32_t)*maxsize);
 
time(&t);
tstart=t;
told=t-1;
 
for (iy=0; iy<ny; iy++) {
 
if (ctrl_c) break;
 
if (runrec.direction) {
posrec.iy = iy;
posrec.yset=runrec.y0+posrec.iy*runrec.dy;
if (scanunitsy) {
if (posrec.yset>5) {
addgap=gapy * fx;
} else {
addgap=0;
}
posrec.yset = (int32_t)(y0+dy *fx * posrec.yset + addgap);
}
if (gMIKRO_Y) {
//sa02Printf("MIKRO_MoveTo (2, y);%d\n",y);
MIKRO_MoveTo (MIKRO_Y, posrec.yset);
sa02Printf("->MIKRO_MoveTo (2, y);%d\n",posrec.yset);
}
 
SetCtrlVal (p2h, P2_Y, posrec.yset);
SetCtrlVal (p2h, P2_IY, posrec.iy);
} else {
posrec.ix = iy;
posrec.xset=runrec.x0+posrec.ix*runrec.dx;
if (scanunitsx) {
if (posrec.xset>5) {
addgap=gapx * fx;
} else {
addgap=0;
}
posrec.xset = (int32_t)(x0+dx *fx * posrec.xset + addgap);
}
if (gMIKRO_Y) {
//sa02Printf("MIKRO_MoveTo (2, y);%d\n",y);
MIKRO_MoveTo (MIKRO_X, posrec.xset);
sa02Printf("->MIKRO_MoveTo (1, x);%d\n",posrec.xset);
}
SetCtrlVal (p2h, P2_X, posrec.xset);
SetCtrlVal (p2h, P2_IX, posrec.ix);
}
for (ix=0; ix<nx; ix++) {
if (ctrl_c) break;
 
if (runrec.direction) {
posrec.ix = ix;
posrec.xset=runrec.x0+posrec.ix*runrec.dx;
if (scanunitsx) {
if (posrec.xset>5) {
addgap=gapx * fx;
} else {
addgap=0;
}
posrec.xset = (int32_t)(x0+dx *fx * posrec.xset + addgap);
}
if (gMIKRO_X) {
//sa02Printf("MIKRO_MoveTo (1, x);%d\n",posrec.x);
MIKRO_MoveTo (MIKRO_X, posrec.xset);
sa02Printf("->MIKRO_MoveTo (1, x);%d\n",posrec.xset);
}
SetCtrlVal (p2h, P2_X, posrec.xset);
SetCtrlVal (p2h, P2_IX, posrec.ix);
} else {
posrec.iy = ix;
posrec.yset=runrec.y0+posrec.iy*runrec.dy;
if (scanunitsy) {
if (posrec.yset>5) {
addgap=gapy * fx;
} else {
addgap=0;
}
posrec.yset = (int32_t)(y0+dy *fx * posrec.yset + addgap);
}
if (gMIKRO_X) {
//sa02Printf("MIKRO_MoveTo (1, x);%d\n",posrec.y);
MIKRO_MoveTo (MIKRO_Y, posrec.yset);
sa02Printf("->MIKRO_MoveTo (2, y);%d\n",posrec.yset);
}
SetCtrlVal (p2h, P2_Y, posrec.yset);
SetCtrlVal (p2h, P2_IY, posrec.iy);
}
if (scanunitsx && scanunitsy) {
SetCMon(runrec.x0+posrec.ix*runrec.dx,runrec.y0+posrec.iy*runrec.dy);
}
if (dsave) {
if (fmax && (ftell(gFp) > fmax)) {
fcount+=1;
sprintf(dfile,"%s_file%02d.dat",dfile0,fcount);
fclose(gFp);
gFp = fopen (dfile, "ab");
}
time (&cas);
posrec.time = (uint32_t) cas;
status = (int) fwrite (&posrec, 1, posrec.len, gFp);
}
 
Sa02DaqMode (daqmode);
Sa02SelectTriggerWithMaskAndLength (sendswtrg, mask, trglen);
 
for (board=0; board<4; board++) {
if (mask & (1<<board)) {
sa02Cmd( board, FEB_VTH1, runrec.ped, 0,0,1,response);
Sa02TestPulseEnable(board,tpenb); // Enable/disable test pulse
}
}
 
Sa02SetNeve(runrec.nev);
 
evtrec.nev=1;
 
 
sa02Reset();
 
if (ctrl_c) break;
 
if ( (count+2+dsize) >= maxsize) {
maxsize*=2;
sa02Printf("Increasing data buffer to %d elements\n", maxsize);
rdata=realloc(rdata ,sizeof(uint32_t)*maxsize);
}
 
data = &rdata[count+2];
do {
//int k;
//uint32_t inputtriggers;
if (sendswtrg == 1) Sa02SoftwareTrigger();
nb = sa02Read(mask, &rdata[count+2] );
/*
for (k=0; k<4; k++) c[k] = Sa02GetCounter ( k ,&e[k]);
for (k=0; k<4; k++) sa02Printf(" CNTR%d=%d (ERR=%d)\t",k,c[k],e[k]);
sa02Printf("\nsa02Read bytes = %d mask=%d neve=%d (%d # %d)\n", nb, mask, runrec.nev, Sa02GetNeve( &inputtriggers ) , inputtriggers);
*/
} while ( nb==0 && !ctrl_c);
 
 
 
if (sa02TimerOut || nb==0) sa02Printf("sa02TimerOut || nb==0\n");
 
for (ich=0; ich<144*4; ich++) {
int brd = ich/144;
int xch = 143 - ich%144;
//sa02Printf("[%d] = %d \n", ich, data[ich]);
if (data[ich]> xyval[brd]) xyval[brd] = data[ich];
if (mask & (1<<brd)) {
H3DFillBin(hxy+ brd, posrec.ix,posrec.iy,xch,data[ich]);
H2DFillBin(hxy+ brd, posrec.ix,posrec.iy,data[ich]);
}
}
sa02Printf("max couts = %d %d %d %d\n", xyval[0],xyval[1],xyval[2],xyval[3]);
if (nb>=0) {
count+=module_header(0x3,&rdata[count],nb/sizeof(uint32_t));
}
 
 
/*
for (ich=0; ich<144; ich++) {
 
// uint32_t mask=0xFF;
// id=(35-ich/4);
// shft=(ich%4)*8;
uint32_t mask=0xF;
id=(17-ich/8)+board*18;
shft=(ich%8)*4;
if ( data[id] & (mask <<shft) ) {
H3DFillBin(hxy, posrec.ix,posrec.iy,ich,1);
H2DFillBin(hxy, posrec.ix,posrec.iy,1);
}
}
*/
if (dsave) {
if (Random(0,1)<fraction) {
writeevents=1;
} else {
writeevents=0;
}
if (writeevents) {
evtrec.id = EVTREC_ID;
evtrec.len=count*sizeof(uint32_t)+ sizeof(evtrec);
 
evtrec.time= (uint32_t) time(NULL);
evtrec.nev=i;
status = (int) fwrite( &evtrec, 1, sizeof(evtrec),gFp);
if (count) {
status = (int) fwrite(rdata,1,count*sizeof(uint32_t),gFp); //gzip
}
}
if (hvmon) {
time_t thv0,thv1;
time(&thv0);
GetHvMonitor();
time(&thv1);
status = (int) fwrite( &monrec, 1, sizeof(monrec),gFp);
sa02Printf("HvMonitor dt= %d s\n", thv1-thv0 );
hvmon =0;
}
 
ncount++;
}
 
time(&t);
if (t!=told ) {
double done= (double) (posrec.ix+posrec.iy*runrec.nx)/(runrec.nx*runrec.ny);
EstimatedFinish(p2h, P2_PROGRESS, P2_ETA, t0, done);
GetCtrlVal(p2h,P2_CH, &ch);
for (board=0; board<4; board++) {
if (ch) {
H3DDrawSliceXY(hxy+board,ch,p2h, p2graph[board], &p2plothandle[board]);
} else {
H2DDraw(hxy+board,p2h, p2graph[board], &p2plothandle[board]);
}
}
ProcessSystemEvents ();
SetCtrlVal(p2h,P2_CEVE, i);
sa02Printf("%d events in %2.2f min (%d s) %s",ncount, (double)(t-tstart)/60.,t-tstart, ctime(&t));
 
}
told=t;
 
 
 
if (ctrl_c) break;
 
if (daqexe &0x1) {
daq(NULL);
sa02Cmd( board, FEB_VTH1, runrec.ped, 0,0,1,response);
}
if (daqexe &0x2) {
V729_SetFilePointer(gFp);
V729_daq(NULL);
}
 
}
}
 
if (gFp) {
int ii=0, ison=0;
for (ii=0; ii<4; ii++) {
GetCtrlVal(p1h,hapd_onoff[ii], &ison);
if (ison ) {
H3DWrite2File(hxy+ii, gFp);
H2DWrite2File(hxy+ii, gFp);
}
}
fclose(gFp);
}
gFp=NULL;
free(rdata);
 
SetCtrlAttribute(p1h,P1_TRGHVMON,ATTR_ENABLED,0);
 
return 0;
}
 
int CVICALLBACK Testing(void *functionData) {
int i;
int N470mid = 4;
int SYS403mid = 2;
unsigned short buf[256]= {0};
int odg;
int channels[]= {0,1,2,3,4,0,5,6,7,8,9,1,10,11,12,13,14,2,15,16,17,18,19,3}; //channel for SYS403 , then for N470
time_t t0,t1;
time(&t0);
 
hvmonFirst=0;
 
for (i=0; i<256; i++) buf[i]=0;
for (i=0; i<=23; i++) {
if (((i+1)%6)==0&&i!=0) {
buf[0]=(unsigned short) (channels[i]<<8) | ReadOperationalParam;
if (gCAEN_V288) {
V288_Send(0,N470mid,1,buf);
odg=V288_Receive(0,255,buf);
}
monrec.status[i] = buf[0]; //status
monrec.vmon[i] = buf[1]*1000;//zapisano v mV
monrec.imon[i] = buf[2]*1000;//zapisano v nA
monrec.vset[i] = buf[3]*1000;//zapisano v mV
monrec.iset[i] = buf[4]*1000;//zapisano v nA
} else {
buf[0]=(unsigned short) (channels[i]<<8) | ReadStatus;
if (gCAEN_V288) {
V288_Send(0,SYS403mid,1,buf);
odg=V288_Receive(0,255,buf);
}
monrec.vmon[i] = buf[1]*10;//zapisano v mV
monrec.imon[i] = buf[2]*10;//zapisano v nA
monrec.status[i] = buf[3]; //status
if(!hvmonFirst) {
buf[0]=(unsigned short) (channels[i]<<8) | ReadParameters;
if (gCAEN_V288) {
V288_Send(0,SYS403mid,1,buf);
odg=V288_Receive(0,255,buf);
}
vset[i] = monrec.vset[i] = buf[7]*10;//zapisano v mV
iset[i] = monrec.iset[i] = buf[10]*10;//zapisano v nA
}
monrec.vset[i] = vset[i];//zapisano v mV
monrec.iset[i] = iset[i];//zapisano v nA
}
sa02Printf("%04x \t %.02f V \t %d V \t\t %.02f muA \t %d muA *\n",monrec.status[i],(float)monrec.vmon[i]/1000,monrec.vset[i]/1000,(float)monrec.imon[i]/1000,monrec.iset[i]/1000);
}
time (&t1);
sa02Printf("Cas izvedbe:%g s.\n",difftime(t1,t0));
 
return 0;
}
 
int CVICALLBACK set_dac(int OnOff) {
int val;
char name[MAX_PATHNAME_LEN];
if (OnOff) {
GetCtrlVal (p5h, P5_DAC_ON, &val);
sprintf(name ,"%s -p %d",palaser, val);
sa02Printf("%s\n", name);
system(name);
GetCtrlVal (p5h, P5_FREQUENCY_ON, &val);
sprintf(name ,"%s -f %d",palaser, val);
sa02Printf("%s\n", name);
system(name);
} else {
GetCtrlVal (p5h, P5_DAC_OFF, &val);
sprintf(name ,"%s -p %d",palaser, val);
sa02Printf("%s\n", name);
system(name);
GetCtrlVal (p5h, P5_FREQUENCY_OFF, &val);
sprintf(name ,"%s -f %d",palaser, val);
sa02Printf("%s\n", name);
system(name);
}
return 0;
}
 
int CVICALLBACK set_hv(int OnOff) {
int N470mid = 4;
int channel = 0;
int ret;
 
unsigned short buf[256];
 
buf[0]=(unsigned short) (channel<<8) | TurnChanelOff;
if (OnOff) buf[0]=(unsigned short) (channel<<8) | TurnChanelOn;
V288_Send(0,N470mid,1,buf);
ret=V288_Receive(0,255,buf);
 
buf[0]=(unsigned short) (channel<<8) | ReadOperationalParam;
V288_Send(0,N470mid,1,buf);
ret=V288_Receive(0,255,buf);
 
while (((buf[0]&0x20)&&(buf[0]&0x1))||(buf[0]&0x40)) {
if((buf[0]&0x20)&&(buf[0]&0x20)) sa02Printf("Channel is ramping up \t Vmon: %d V \t Vset: %d \t status: 0x%x\n",buf[1],buf[3],buf[0]);
else if(buf[0]&0x40) sa02Printf("Channel is ramping down \t Vmon: %d V \t Vset: %d \t status: 0x%x\n",buf[1],buf[3],buf[0]);
else if(buf[0]&0x1E) {
sa02Printf("status: 0x%x\n",buf[0]);
return -1;
} else sa02Printf("status: 0x%x\n",buf[0]);
Delay(2);
buf[0]=(unsigned short) (channel<<8) | ReadOperationalParam;
V288_Send(0,N470mid,1,buf);
ret=V288_Receive(0,255,buf);
}
 
buf[0]=(unsigned short) (channel<<8) | ReadOperationalParam;
V288_Send(0,N470mid,1,buf);
ret=V288_Receive(0,255,buf);
if(buf[0]&0x1) sa02Printf("HV is ON \t status: 0x%x\n",buf[0]);
else sa02Printf("HV is OFF \t status: 0x%x\n",buf[0]);
 
return 0;
}
 
int CVICALLBACK changeGlobalParam(int paramID, int paramValue) {
int state;
int cid = P3_GREG;
int scanpar = paramID; //ID of the parameter you are about to change
int nch = 4; //4 ASIC chips
int spar = scanpar-10;
Rect save_range,trange;
const int maxrange[20]= {0,0,8,16,16,16,2,2,2,0,4,4,4,2,256,4,512};
 
trange.top=0;
trange.left=0;
 
state = GetTableSelection (p3h, cid, &save_range);
trange = MakeRect (1, spar, nch, 1);
state = SetTableSelection (p3h, cid, trange);
if ((trange.top!=0)&&(trange.left!=0)) {
if (scanpar!=1) {
state = FillTableCellRange (p3h, cid, MakeRect (1, spar, nch, 1), paramValue%maxrange[scanpar-1]);
if (maxrange[scanpar-1] && paramValue/maxrange[scanpar-1]) {
state = FillTableCellRange (p3h, cid, MakeRect (1, spar-1, nch, 1), paramValue/maxrange[scanpar-1]);
}
}
UploadGlobalParameters (p3h,cid,EVENT_COMMIT,NULL,0,0);
}
state = SetTableSelection (p3h, cid, save_range);
 
return 0;
}
 
int CreateParamFile(char *filename) {
int n,i,row,asic,ch;
unsigned short val;
time_t t;
char buf[MAX_PATHNAME_LEN];
FILE *fp;
 
sprintf(buf,"..//parameters//%s",filename);
fp = fopen(buf, "w");
if (fp) {
//--------------------------------------------------- Parameters header
time(&t);
fprintf(fp, "#Parameter exported from CVI %s\n",ctime(&t) );
//--------------------------------------------------- FPGA parameters
GetNumTextBoxLines(p3h, P3_FPGAPAR,&n);
for (i=0; i<n; i++) {
GetTextBoxLine(p3h, P3_FPGAPAR, i, buf);
fprintf(fp, "%s\n",buf);
}
//--------------------------------------------------- Global parameters
for (row=1; row<1+16; row++) {
int irow = (row-1)%4;
int iboard = (row-1)/4;
fprintf(fp, "param_board %d\n",iboard);
fprintf(fp, "## global parameter for chip %d\n",(row-1)%4);
fprintf(fp, "param_global %d 0x1ffff\n",irow);
GetTableCellVal (p3h, P3_GREG, MakePoint (1,row), &val);
fprintf(fp, "phasecmps %d 0x%x\n",irow,val);
GetTableCellVal (p3h, P3_GREG, MakePoint (2,row), &val);
fprintf(fp, "gain %d 0x%x\n",irow,val);
GetTableCellVal (p3h, P3_GREG, MakePoint (3,row), &val);
fprintf(fp, "shapingtime %d 0x%x\n",irow,val);
GetTableCellVal (p3h, P3_GREG, MakePoint (4,row), &val);
fprintf(fp, "comparator %d 0x%x\n",irow,val);
GetTableCellVal (p3h, P3_GREG, MakePoint (5,row), &val);
fprintf(fp, "vrdrive %d 0x%x\n",irow,val);
GetTableCellVal (p3h, P3_GREG, MakePoint (6,row), &val);
fprintf(fp, "monitor %d 0x%x\n",irow,val);
GetTableCellVal (p3h, P3_GREG, MakePoint (7,row), &val);
fprintf(fp, "id %d 0x%x\n",irow,val);
 
fprintf(fp, "load_global %d\n\n\n",irow);
}
 
//--------------------------------------------------- Channel parameters
for (i=0; i<144*4; i++) {
int board = i/144;
int j= i%144;
asic=(j/36);
ch=j%36;
row=(i+1);
if (i%36==0) {
fprintf(fp, "# channel parameter for chip %d\n\n",asic);
}
 
fprintf(fp, "param_board %d\n",board);
fprintf(fp, "param_ch %d %d 0x0000\n",asic,ch);
 
GetTableCellVal (p3h, P3_CREG, MakePoint (3,row), &val);
fprintf(fp, "decaytime %d %d 0x%x\n",asic,ch,val);
GetTableCellVal (p3h, P3_CREG, MakePoint (4,row), &val);
fprintf(fp, "offset %d %d 0x%x\n",asic,ch,val);
GetTableCellVal (p3h, P3_CREG, MakePoint (5,row), &val);
fprintf(fp, "fineadj_unipol %d %d 0x%x\n",asic,ch,val);
GetTableCellVal (p3h, P3_CREG, MakePoint (6,row), &val);
fprintf(fp, "fineadj_diff %d %d 0x%x\n",asic,ch,val);
GetTableCellVal (p3h, P3_CREG, MakePoint (7,row), &val);
fprintf(fp, "tpenb %d %d 0x%x\n",asic,ch,val);
GetTableCellVal (p3h, P3_CREG, MakePoint (8,row), &val);
fprintf(fp, "kill %d %d 0x%x\n",asic,ch,val);
fprintf(fp, "load_ch %d %d\n\n\n",asic,ch);
}
fclose(fp);
}
sprintf(buf,"Created file '..//parameters//%s'\n",filename);
sa02Printf("%s",buf);
return 0;
}
 
 
int StepOne(void) {
char defaulParamFile[0xFF] = "..\\parameters\\default.param"; // path to default.param file
 
char HAPDnum[0xFF];
int HAPDnumberOnOff;
int ActiveHAPDNo=0;
int HAPDid[]= {P1_SERIAL_1,P1_SERIAL_2,P1_SERIAL_3,P1_SERIAL_4};
int HAPDstatus[]= {P1_ONOFF_1,P1_ONOFF_2,P1_ONOFF_3,P1_ONOFF_4};
char HAPDnumber[4][0xFF];
 
FILE *fp;
int ndim=400;
char line[ndim];
time_t t;
uint32_t mask = GetConnectedFebMask();
int current_run=1;
 
char cmdCommand[ndim];
 
int numberOfIterations = 1; //change this when everything will be working...
 
/****** Check if Serial numbers are filled in ******/
for (int i=0; i<4; i++) {
GetCtrlVal(p1h, HAPDid[i], HAPDnum);
GetCtrlVal(p1h, HAPDstatus[i], &HAPDnumberOnOff);
if(!strcmp(HAPDnum, "noserial") && HAPDnumberOnOff) {
printf("Fill in 'HAPD%d number' or disable 'HAPD%d'\n",i,i);
return -1;
}
strcpy(HAPDnumber[i],HAPDnum);
ActiveHAPDNo+=HAPDnumberOnOff;
}
if(!ActiveHAPDNo) {
sa02Printf("Turn on at least 1 HAPD.");
return -1;
}
sa02Printf("HAPD0 serial: %s \nHAPD1 serial: %s \nHAPD2 serial: %s \nHAPD3 serial: %s \n",HAPDnumber[0],HAPDnumber[1],HAPDnumber[2],HAPDnumber[3]);
 
/****** Loads param file and uploads it to FEB ******/
SetCtrlVal(p3h, P3_INPUTFILE, defaulParamFile); // write path to P3_INPUTFILE
SetParametersFromFile(defaulParamFile); // write default.param to P3_CREG table
 
LoadParameters(p3h, P3_LOADPAR, EVENT_COMMIT, NULL, 0, 0); // load parameters from defaul.param to FEB
ProcessSystemEvents ();
LoadParameters(p3h, P3_LOADPAR, EVENT_COMMIT, NULL, 0, 0); // load parameters from defaul.param to FEB
ProcessSystemEvents ();
LoadParameters(p3h, P3_LOADPAR, EVENT_COMMIT, NULL, 0, 0); // load parameters from defaul.param to FEB
ProcessSystemEvents ();
 
/****** MicroMini calibration ******/
sa02Printf("Calibration *\n\n");
SetHome(p2h, P2_HO,EVENT_COMMIT,NULL, 0, 0);
SetCtrlVal(p2h,P2_XC,gCENTER_X);
SetCtrlVal(p2h,P2_YC,gCENTER_Y);
 
/****** Reads run number ******/
fp = fopen ("CompleteScan_RunNumber.txt","r");
if (fp) {
if (fgets(line,ndim,fp)!= NULL) current_run = atoi(line)+1;
fclose(fp);
fp = NULL;
}
ProcessSystemEvents ();
 
/****** Slow Control ******/
sprintf(line,"%04d_SlowControl.xml",current_run);
fp = fopen (line,"w");
fprintf(fp,"<febtest>\n");
time(&t);
fprintf(fp,"<time>%s</time>\n", ctime(&t));
 
for (int board=0; board<4; board++) {
if (mask &(1<<board)) {
for (int k=0; k<10; k++) {
Delay(0.1);
SlowControl(board,fp);
ProcessSystemEvents ();
if (ctrl_c) break;
}
}
if (ctrl_c) break;
}
 
fprintf(fp,"</febtest>\n");
fclose(fp);
fp = NULL;
 
/****** Treshold scan, Calibration & Channel Param Upload (iterations) ******/
for(int j=0; j<=numberOfIterations; j++) {
if(!j) {
//Treshold settings
SetCtrlVal(p1h,P1_DATA, 400);
SetCtrlVal(p1h,P1_DSTEP, 1);
SetCtrlVal(p1h,P1_NEVE, 300);
SetCtrlVal(p1h,P1_TOREAD, 1000);
//Calibration settings
SetCtrlVal (p3h, P3_FITMODE, 2);
SetCtrlVal (p3h, P3_TARGETOFFSET, 550.);
SetCtrlVal (p3h, P3_TARGETRMS, 3.);
}
sprintf(line,"%04d_0_Treshold_%d.dat", current_run, j);
SetCtrlVal(p1h,P1_OUTPUTFILE, line);
if(j==numberOfIterations) continue; //when everything will be working remove this one and uncoment the next one
 
daq(NULL);
 
sprintf(cmdCommand,"cmd.exe /c ..\\sa02read -i .\\%s -o .\\%04d_0_Treshold_%d.root", line, current_run, j);
LaunchExecutable(cmdCommand);
 
 
ProcessSystemEvents ();
 
//if(j==numberOfIterations) continue;
 
sprintf(line,"Coarse fit parameters, iteration %d *\n\n", j);
sa02Printf(line);
 
FitH2DCoarse(p3h, P3_CALIBRATION_2,EVENT_COMMIT,NULL,0,0);
ProcessSystemEvents ();
 
sprintf(line,"%04d_Iteration_%d.param", current_run, j);
CreateParamFile(line);
 
sa02Printf("Loading channel parameters *\n\n");
 
sprintf(defaulParamFile,"..\\parameters\\%s",line);
SetCtrlVal(p3h, P3_INPUTFILE, defaulParamFile); // write path to P3_INPUTFILE
SetParametersFromFile(defaulParamFile); // write default.param to P3_CREG table
 
LoadParameters(p3h, P3_LOADPAR, EVENT_COMMIT, NULL, 0, 0); // load parameters to FEB
ProcessSystemEvents ();
LoadParameters(p3h, P3_LOADPAR, EVENT_COMMIT, NULL, 0, 0); // load parameters to FEB
ProcessSystemEvents ();
LoadParameters(p3h, P3_LOADPAR, EVENT_COMMIT, NULL, 0, 0); // load parameters to FEB
ProcessSystemEvents ();
 
 
}
 
/****** Increases run number in file for 1 ******/
/* fp = fopen ("CompleteScan_RunNumber.txt","w");
fprintf(fp,"%d\n", current_run);
fclose(fp);
*/
 
return 0;
}
 
int ModuleTest(void) {
int HAPDnumberOnOff;
int ActiveHAPDNo=0;
int HAPDid[]= {P1_SERIAL_1,P1_SERIAL_2,P1_SERIAL_3,P1_SERIAL_4};
int HAPDstatus[]= {P1_ONOFF_1,P1_ONOFF_2,P1_ONOFF_3,P1_ONOFF_4};
int ndim=400;
int current_run=1;
int ithr;
double targetoffset;
char line[ndim];
char buf[0xFF];
char cmdCommand[ndim];
char HAPDnumber[4][0xFF];
char HAPDnum[0xFF];
 
FILE *fp;
 
 
/****** Check if Serial numbers are filled in ******/
for (int i=0; i<4; i++) {
GetCtrlVal(p1h, HAPDid[i], HAPDnum);
GetCtrlVal(p1h, HAPDstatus[i], &HAPDnumberOnOff);
if(!strcmp(HAPDnum, "noserial") && HAPDnumberOnOff) {
printf("Fill in 'HAPD%d number' or disable 'HAPD%d'\n",i,i);
return -1;
}
strcpy(HAPDnumber[i],HAPDnum);
ActiveHAPDNo+=HAPDnumberOnOff;
}
if(!ActiveHAPDNo) {
sa02Printf("Turn on at least 1 HAPD.");
return -1;
}
sa02Printf("HAPD0 serial: %s \nHAPD1 serial: %s \nHAPD2 serial: %s \nHAPD3 serial: %s \n",HAPDnumber[0],HAPDnumber[1],HAPDnumber[2],HAPDnumber[3]);
 
/****** MicroMini calibration ******/
sa02Printf("Calibration *\n\n");
SetHome(p2h, P2_HO,EVENT_COMMIT,NULL, 0, 0);
SetCtrlVal(p2h,P2_XC,gCENTER_X);
SetCtrlVal(p2h,P2_YC,gCENTER_Y);
 
/****** Reads run number ******/
fp = fopen ("CompleteScan_RunNumber.txt","r");
if (fp) {
if (fgets(line,ndim,fp)!= NULL) current_run = atoi(line)+1;
fclose(fp);
fp = NULL;
}
ProcessSystemEvents ();
 
fp = fopen ("CompleteScan_RunNumber.txt","w");
fprintf(fp,"%d\n", current_run);
fclose(fp);
 
GetCtrlVal (p3h, P3_TARGETOFFSET, &targetoffset); // Treshold
ithr=(int)targetoffset+20;
/****** Treshold + Waveform scan over 144x center ******/
SetCtrlVal (p2h, P2_ZSET, 0);
SetCtrlVal (p2h, P2_XC, (uint32_t)(gCENTER_KX*0+gCENTER_X));
SetCtrlVal (p2h, P2_YC, (uint32_t)(gCENTER_KY*0+gCENTER_Y));
Zset(p2h,P2_ZSET,EVENT_COMMIT,NULL,0,0);
// Panel 1 setting
SetCtrlVal (p1h, P1_TPENB, 0); // disable test pulz
SetCtrlVal (p1h, P1_SENDSWTRIG, 2); // set external trigger
SendTriggerTypeCB (p1h, P1_SENDSWTRIG, EVENT_COMMIT,NULL,0,0); // commit external trigger
 
SetCtrlVal(p1h,P1_DATA, 500); // Inital value
SetCtrlVal(p1h,P1_DSTEP, 2); // Step size
SetCtrlVal(p1h,P1_NEVE, 101); // Number of steps
SetCtrlVal(p1h,P1_TOREAD, 1000); // Number of events
 
// Panel 4 setting
//SetCtrlVal(p4h,P4_FRACTION, 0.); // Fraction of waveforms to store (If you want to create charge accumulation graphs with sa02read set to 1.)
SetCtrlVal(p4h,P4_NEVE, 4000); // Number of events
 
// Panel 2 settings
SetCtrlVal (p2h, P2_SCANUNITSX, 1); // Only over the channel centers (1 Ch, 0 Step)
SetCtrlVal (p2h, P2_NX, 12); // Noumber of steps = 12
SetCtrlVal (p2h, P2_XSTEP, 1); // Step size = 1
SetCtrlVal (p2h, P2_XMIN, 0); // Start position = 0
SetCtrlVal (p2h, P2_SCANUNITSY, 1); // Only over the channel centers (1 Ch, 0 Step)
SetCtrlVal (p2h, P2_NY, 12); // Noumber of steps = 12
SetCtrlVal (p2h, P2_YSTEP, 1); // Step size = 1
SetCtrlVal (p2h, P2_YMIN, 0); // Start position = 0
SetCtrlVal (p2h, P2_DIRECTION, 1); // Set Y then scan X = 1 (0 = Set X then scan X)
 
SetCtrlVal (p2h, P2_NEVE, 100); // Number of events for position scan (keep low so the scan is faster ... this is not the point of interest for this scan)
SetCtrlVal (p2h, P2_PEDESTAL, ithr); // Treshold
 
SetCtrlVal (p2h, P2_DAQEXE, 3); // Execute at each position: SA02 scan and CAEN V729a
 
sprintf(buf,"%04d_1_Treshold_Waveform",current_run);
sprintf(line,"..\\modules\\%s",buf);
SetCtrlVal (p2h, P2_DFILE, line);
 
 
daq_scan(NULL);
 
sprintf(cmdCommand,"cmd.exe /c mkdir ..\\modules\\%04d & ..\\sa02read -i %s_file01.dat -o ..\\modules\\%04d\\%s.root",
current_run, line, current_run, buf);
LaunchExecutable(cmdCommand);
 
 
/****** 2D v X ******/
// Panel 2 settings
SetCtrlVal (p2h, P2_SCANUNITSX, 0); // Continuous scan over X (1 Ch, 0 Step)
SetCtrlVal (p2h, P2_NX, 380/2); // Noumber of steps = 380
SetCtrlVal (p2h, P2_XSTEP, 2*500); // Step size = 500
SetCtrlVal (p2h, P2_XMIN, 83000); // Start position = 8500
SetCtrlVal (p2h, P2_SCANUNITSY, 1); // Only over the channel centers (1 Ch, 0 Step)
SetCtrlVal (p2h, P2_NY, 12); // Noumber of steps = 12
SetCtrlVal (p2h, P2_YSTEP, 1); // Step size = 1
SetCtrlVal (p2h, P2_YMIN, 0); // Start position = 0
SetCtrlVal (p2h, P2_DIRECTION, 1); // Set Y then scan X = 1
 
SetCtrlVal (p2h, P2_NEVE, 1000); // Number of events for position scan
SetCtrlVal (p2h, P2_PEDESTAL, ithr); // Treshold
 
SetCtrlVal (p2h, P2_DAQEXE, 0); // Execute at each position: nothing
 
sprintf(buf,"%04d_2_2DX",current_run);
sprintf(line,"..\\modules\\%s", buf);
SetCtrlVal (p2h, P2_DFILE, line);
 
 
daq_scan(NULL);
 
sprintf(cmdCommand,"cmd.exe /c mkdir ..\\modules\\%04d & ..\\sa02read -i %s_file01.dat -o ..\\modules\\%04d\\%s.root ", current_run, line, current_run, buf);
LaunchExecutable(cmdCommand);
 
 
/****** 2D v Y ******/
// Panel 2 settings
SetCtrlVal (p2h, P2_SCANUNITSX, 1); // Only over the channel centers (1 Ch, 0 Step)
SetCtrlVal (p2h, P2_NX, 12); // Noumber of steps = 12
SetCtrlVal (p2h, P2_XSTEP, 1); // Step size = 1
SetCtrlVal (p2h, P2_XMIN, 0); // Start position = 0
SetCtrlVal (p2h, P2_SCANUNITSY, 0); // Continuous scan over Y (1 Ch, 0 Step)
SetCtrlVal (p2h, P2_NY, 380/2); // Noumber of steps = 380
SetCtrlVal (p2h, P2_YSTEP, 2*500); // Step size = 500
SetCtrlVal (p2h, P2_YMIN, 75000); // Start position = 7500
SetCtrlVal (p2h, P2_DIRECTION, 0); // Set X then scan Y = 0
 
SetCtrlVal (p2h, P2_NEVE, 1000); // Number of events for position scan
SetCtrlVal (p2h, P2_PEDESTAL, ithr); // Treshold
 
SetCtrlVal (p2h, P2_DAQEXE, 0); // Execute at each position: nothing
 
sprintf(buf,"%04d_3_2DY",current_run);
sprintf(line,"..\\modules\\%s", buf);
SetCtrlVal (p2h, P2_DFILE, line);
 
 
daq_scan(NULL);
 
sprintf(cmdCommand,"cmd.exe /c mkdir ..\\modules\\%04d & ..\\sa02read -i %s_file01.dat -o ..\\modules\\%04d\\%s.root ", current_run, line, current_run, buf);
system(cmdCommand); // wait here to finish to proceed to next step
sprintf(cmdCommand,"cmd.exe /c ..\\thisroot.bat & cd analysis & root script.c(%d)",current_run);
LaunchExecutable(cmdCommand);
 
SetCtrlVal (p2h, P2_ZSET, 300000);
SetCtrlVal (p2h, P2_XC, (uint32_t)(gCENTER_KX*0+gCENTER_X));
SetCtrlVal (p2h, P2_YC, (uint32_t)(gCENTER_KY*0+gCENTER_Y));
Zset(p2h,P2_ZSET,EVENT_COMMIT,NULL,0,0);
 
return 0;
}
 
int StepThree(void) {
//char cmdCommand[0xFF];
//char line[0xFF];
//char buf[0xFF];
//int current_run = 11;
 
return 0;
}
 
 
// map uir controls ....
#define MAX_UIRCTRLMAP_SIZE 1000
typedef struct {
char name[32];
int id;
int handle;
} UirCtrlMap;
UirCtrlMap gUirCtrlMap[MAX_UIRCTRLMAP_SIZE];
int gNUirCtrlMap=0;
 
int GetControlID(const char *ctrl) {
for (int i=0; i<gNUirCtrlMap; i++) {
if (strcmp(ctrl,gUirCtrlMap[i].name)==0) return ctrl,gUirCtrlMap[i].id;
}
return -1;
}
int GetPanelHandle(const char *ctrl) {
 
if ( strstr(ctrl, "P1_")!= NULL ) return p1h;
if ( strstr(ctrl, "P2_")!= NULL ) return p2h;
if ( strstr(ctrl, "P3_")!= NULL ) return p3h;
if ( strstr(ctrl, "P4_")!= NULL ) return p4h;
if ( strstr(ctrl, "P5_")!= NULL ) return p5h;
 
return -1;
}
 
int LoadUirHeader(const char *fname) {
int ndim=MAX_PATHNAME_LEN;
char line[MAX_PATHNAME_LEN];
char cmd[MAX_PATHNAME_LEN];
FILE *fp = NULL;
ssize_t size;
int n0= gNUirCtrlMap;
if ( GetFileInfo(fname,&size) ) fp = fopen(fname,"r");
if (!fp) {
sa02Printf("Error! Cannot open header file %s\n",fname);
return -1;
}
 
while (fgets(line,ndim,fp)!=NULL ) {
char ctrl[32];
int ctrlid;
int nb = sscanf(line,"%s%s%d",cmd, ctrl, &ctrlid);
if (strstr(cmd,"#define")!=NULL && nb==3) {
strcpy(gUirCtrlMap[gNUirCtrlMap].name, ctrl );
if (gNUirCtrlMap<MAX_UIRCTRLMAP_SIZE) {
gUirCtrlMap[gNUirCtrlMap].id = ctrlid;
gUirCtrlMap[gNUirCtrlMap].handle = GetPanelHandle(ctrl);
gNUirCtrlMap++;
} else {
sa02Printf("ERROR: Increase gNUirCtrlMap\n");
}
}
}
fclose(fp);
sa02Printf("Number of Controls loaded from File %s = %d \n", fname,gNUirCtrlMap-n0);
return 0;
}
 
 
char *str_replace(const char *str, const char *old, const char *new) {
 
/* Adjust each of the below values to suit your needs. */
 
/* Increment positions cache size initially by this number. */
size_t cache_sz_inc = 16;
/* Thereafter, each time capacity needs to be increased,
* multiply the increment by this factor. */
const size_t cache_sz_inc_factor = 3;
/* But never increment capacity by more than this number. */
const size_t cache_sz_inc_max = 1048576;
 
char *pret, *ret = NULL;
const char *pstr2, *pstr = str;
size_t i, count = 0;
ptrdiff_t *pos_cache = NULL;
size_t cache_sz = 0;
size_t cpylen, orglen, retlen, newlen =0, oldlen = strlen(old);
 
/* Find all matches and cache their positions. */
while ((pstr2 = strstr(pstr, old)) != NULL) {
count++;
 
/* Increase the cache size when necessary. */
if (cache_sz < count) {
cache_sz += cache_sz_inc;
pos_cache = realloc(pos_cache, sizeof(*pos_cache) * cache_sz);
if (pos_cache == NULL) {
goto end_repl_str;
}
cache_sz_inc *= cache_sz_inc_factor;
if (cache_sz_inc > cache_sz_inc_max) {
cache_sz_inc = cache_sz_inc_max;
}
}
 
pos_cache[count-1] = pstr2 - str;
pstr = pstr2 + oldlen;
}
 
orglen = pstr - str + strlen(pstr);
 
/* Allocate memory for the post-replacement string. */
if (count > 0) {
newlen = strlen(new);
retlen = orglen + (newlen - oldlen) * count;
} else retlen = orglen;
ret = malloc(retlen + 1);
if (ret == NULL) {
goto end_repl_str;
}
 
if (count == 0) {
/* If no matches, then just duplicate the string. */
strcpy(ret, str);
} else {
/* Otherwise, duplicate the string whilst performing
* the replacements using the position cache. */
pret = ret;
memcpy(pret, str, pos_cache[0]);
pret += pos_cache[0];
for (i = 0; i < count; i++) {
memcpy(pret, new, newlen);
pret += newlen;
pstr = str + pos_cache[i] + oldlen;
cpylen = (i == count-1 ? orglen : (size_t)pos_cache[i+1]) - pos_cache[i] - oldlen;
memcpy(pret, pstr, cpylen);
pret += cpylen;
}
ret[retlen] = '\0';
}
 
end_repl_str:
/* Free the cache and return the post-replacement string,
* which will be NULL in the event of an error. */
free(pos_cache);
return ret;
}
 
 
int CVICALLBACK run_script(void *functionData) {
FILE *fp = NULL;
FILE *fpout =NULL;
 
char *line;
char buf[MAX_PATHNAME_LEN];
int status;
char type[MAX_PATHNAME_LEN];
char param[MAX_PATHNAME_LEN];
char paramValue[MAX_PATHNAME_LEN];
int scx,nx,xstep,xmin,scy,ny,ystep,ymin,direction,nevents,tresh;
char test[256];
char outputFileSuffix[128];
char outputFile[MAX_PATHNAME_LEN];
char HAPDserialNumber[128];
ssize_t size;
int data[2];
int runno=0;
 
char scriptname[MAX_PATHNAME_LEN];
GetCtrlVal(p1h,P1_SCRIPTNAME, scriptname);
 
 
if ( GetFileInfo(scriptname,&size) ) fp = fopen(scriptname,"r");
if (!fp) {
sa02Printf("Error! Cannot open script file %s\n",scriptname);
return -1;
}
while (fgets(buf,MAX_PATHNAME_LEN,fp)!=NULL ) {
if (buf[0]!='#' && strlen(buf)>2) {
if (strstr(buf, "%RUN%")!=NULL) {
char srun[16];
sprintf(srun,"%04d",runno);
line = str_replace(buf,"%RUN%", srun);
} else {
line = buf;
}
sa02Printf("#[%d] %s",strlen(buf),buf);
sscanf(line,"%s",type);
if (strstr(type,"SetCtrlVal")!=NULL) {
int pID;
int rID;
int datatype;
sscanf(line,"%*s%s%s",param,paramValue);
pID= GetPanelHandle(param);
rID= GetControlID(param);
if (rID>0 && pID>0) {
GetCtrlAttribute (pID, rID, ATTR_DATA_TYPE, &datatype);
switch (datatype){
case VAL_INTEGER: SetCtrlVal (pID, rID, atoi(paramValue)); break;
case VAL_UNSIGNED_INTEGER: SetCtrlVal (pID, rID, strtoul(paramValue,NULL,0)); break;
case VAL_SHORT_INTEGER: SetCtrlVal (pID, rID, atoi(paramValue)); break;
case VAL_UNSIGNED_SHORT_INTEGER: SetCtrlVal (pID, rID, strtoul(paramValue,NULL,0)); break;
case VAL_DOUBLE : SetCtrlVal (pID, rID, atof(paramValue)); break;
case VAL_STRING : SetCtrlVal (pID, rID, paramValue ); break;
default: sa02Printf("[%s] ATTR_DATA_TYPE of the %s not supported datatype %d p4h=%d\n\n", type, param, datatype, p4h);
}
//sa02Printf("[%s] SetCtrlVal %s %s panel=%d control=%d\n",type,param, paramValue,pID,rID);
} else {
sa02Printf("[%s] Invalid Ctrl %s %s panel=%d control=%d\n",type,param, paramValue,pID,rID);
}
} else if (strstr(type,"2D")!=NULL) {
sscanf(line,"%*s%d%d%d%d%d%d%d%d%d%d%d%s",&scx,&nx,&xstep,&xmin,&scy,&ny,&ystep,&ymin,&direction,&nevents,&tresh,outputFileSuffix);
sprintf(test,"%d %d %d %d %d %d %d %d %d %d %d %s *\n",scx,nx,xstep,xmin,scy,ny,ystep,ymin,direction,nevents,tresh,outputFileSuffix);
sa02Printf("%s *\n\n",test);
SetCtrlVal (p2h, P2_SCANUNITSX, scx);
SetCtrlVal (p2h, P2_NX, nx);
SetCtrlVal (p2h, P2_XSTEP, xstep);
SetCtrlVal (p2h, P2_XMIN, xmin);
SetCtrlVal (p2h, P2_SCANUNITSY, scy);
SetCtrlVal (p2h, P2_NY, ny);
SetCtrlVal (p2h, P2_YSTEP, ystep);
SetCtrlVal (p2h, P2_YMIN, ymin);
SetCtrlVal (p2h, P2_DIRECTION, direction);
 
SetCtrlVal (p2h, P2_NEVE, nevents);
SetCtrlVal (p2h, P2_PEDESTAL, tresh);
 
GetCtrlVal (p1h, P1_SERIAL_1, HAPDserialNumber);
sprintf(outputFile,"%s_%s", HAPDserialNumber, outputFileSuffix);
SetCtrlVal (p2h, P2_DFILE, outputFile);
 
 
daq_scan(NULL);
 
} else if (strstr(type,"Delay")!=NULL) {
int idelay=0;
sscanf(line,"%*s%s",paramValue);
for (idelay=atoi(paramValue) ; idelay>0; idelay--) {
Delay(1);
SetCtrlVal(p1h, P1_DELAY, idelay);
ProcessSystemEvents();
if (ctrl_c) break;
}
} else if (strstr(type,"ThresholdLinearity")!=NULL) {
char *fname;
uint16_t mask = GetConnectedFebMask();
 
sscanf(line,"%*s%s",paramValue);
fname = paramValue;
 
ThresholdLinearityCB (p1h, P1_THRVSADC, EVENT_COMMIT, NULL, 0, 0 );
fpout = fopen(fname,"ab");
if(fpout) {
for (int board=0; board<4; board++) if ( mask &(1<<board)) H1DWrite2File(board,fpout);
fclose(fpout);
}
 
} else if (strstr(type,"LaunchExecutable")!=NULL) {
int index = FindPattern (line, 0, -1, "LaunchExecutable", 0, 0) + 17;
char *cmd = &line[index];
sa02Printf("cmd %d=%s\n",index, cmd);
if (strlen(cmd)>0) LaunchExecutable( cmd );
} else if (strstr(type,"CAEN_V729")!=NULL) {
char *fname;
//FILE *fpmon=NULL;
sscanf(line,"%*s%s",paramValue);
fname=paramValue;
fpout = fopen(fname,"ab");
if (fpout) {
V729_SetFilePointer(fpout);
V729_daq(NULL);
fclose(fpout);
}
} else if (strstr(type,"HvMonitor")!=NULL) {
int nrepetitions;
int delaytime;
int k=0;
FILE *fpmon=NULL;
sscanf(line,"%*s%s%d%d",paramValue, &delaytime, &nrepetitions );
fpmon = fopen(paramValue,"ab");
if ( fpmon ) {
hvmonFirst = 0;
for (k=0; k<nrepetitions; k++) {
double thv0,thv1;
thv0 = Timer();
GetHvMonitor();
for (int board=0;board<4;board++){
double sdata[12];
for (int k=0;k<6;k++){
sdata[k] = monrec.imon[k+4*board];
sdata[k+6] = 0;
}
SetAxisScalingMode (p1h, chart_control[board], VAL_LEFT_YAXIS, VAL_AUTOSCALE, 0, 1);
SetAxisScalingMode (p1h, chart_control[board], VAL_RIGHT_YAXIS, VAL_AUTOSCALE, 0, 1);
PlotStripChart (p1h, chart_control[board], sdata, 12, 0, 0, VAL_DOUBLE);
}
monrec.id = MONREC_ID;
monrec.len = sizeof(monrec);
thv1=Timer();
status = (int) fwrite( &monrec, 1, sizeof(monrec),fpmon);
sa02Printf("[%04d] HvMonitor dt= %f s status=%d\n", runno, thv1-thv0, status );
for (int idelay=delaytime ; idelay>0; idelay--) {
Delay(1);
SetCtrlVal(p1h, P1_DELAY, idelay);
ProcessSystemEvents();
if (ctrl_c) break;
}
if (ctrl_c) break;
}
fclose(fpmon);
} else {
sa02Printf("%s cannot open file %s\n",param, paramValue );
}
 
} else if (strstr(type,"GetRunNumberFromFile")!=NULL) {
sscanf(line,"%*s%s",paramValue);
runno = GetRunNumberFromFile(paramValue);
SetCtrlVal(p1h, P1_RUNNO, runno);
sa02Printf("%s %s run=>%d\n",type, paramValue, runno );
} else if (strstr(type,"IncreaseNumberInFile")!=NULL) {
sscanf(line,"%*s%s",paramValue);
runno = IncreaseRunNumberInFile(paramValue);
sa02Printf("%s %s run=>%d\n",type, paramValue, runno );
SetCtrlVal(p1h, P1_RUNNO, runno);
} else if (strstr(type,"LoadParameters")!=NULL) {
LoadParameters(p3h, P3_LOADPAR,EVENT_COMMIT,NULL,0,0);
sa02Printf("Loading parameters *\n\n");
} else if (strstr(type,"QueueUserEvent")!=NULL || strstr(type,"ProcessUserEvent")!=NULL) {
char scontrol[0xFF];
int panelHandle=0;
int controlID;
sscanf(line,"%*s%s",scontrol);
panelHandle = GetPanelHandle(scontrol);
controlID = GetControlID(scontrol);
sa02Printf("UserEvent %s panelHandle %d controlID %d\n",scontrol, panelHandle, controlID );
if (panelHandle>=0 && controlID >=0 ) {
if (strstr(type,"ProcessUserEvent")!=NULL) {
ProcessUserEvent(panelHandle, controlID,0);
} else {
data[1] = controlID;
data[0] = panelHandle;
status = CmtWriteTSQData (pTSQ, data, 1, TSQ_INFINITE_TIMEOUT, NULL);
}
}
 
} else if (strstr(type,"SetPositionAndMux")!=NULL) {
int ix,iy;
sscanf(line,"%*s%d%d",&ix,&iy);
sa02Printf("SetPositionAndMux %d %d \n", ix,iy);
 
SetCtrlVal (p2h, P2_CHX, ix);
SetCtrlVal (p2h, P2_CHY, iy);
SetPositionAndMux( p2h,0, EVENT_COMMIT , NULL,0,0);
 
} else if (strstr(type,"Treshold")!=NULL) {
sscanf(line,"%*s%s",outputFileSuffix);
 
GetCtrlVal (p1h, P1_SERIAL_1, HAPDserialNumber);
sprintf(outputFile,"%s_%s.dat", HAPDserialNumber, outputFileSuffix);
SetCtrlVal (p1h, P1_OUTPUTFILE, outputFile);
 
sprintf(test,"Treshold scan to file %s",outputFile);
sa02Printf("%s *\n\n", test);
 
daq(NULL);
} else if (strstr(type,"Fitanje")!=NULL) {
FitH2DCoarse(p3h, P3_CALIBRATION_2,EVENT_COMMIT,NULL,0,0);
sa02Printf("Coarse fit parameters *\n\n");
} else if (strstr(type,"UploadChannelParameters")!=NULL) {
UploadChannelParameters(p3h, P3_CPARLOAD,EVENT_COMMIT,NULL,0,0);
sa02Printf("Loading channel parameters *\n\n");
} else if (strstr(type,"KalibracijaMizice")!=NULL) {
SetHome(p2h, P2_HO,EVENT_COMMIT,NULL,0,0);
SetCtrlVal(p2h,P2_XC,gCENTER_X);
SetCtrlVal(p2h,P2_YC,gCENTER_Y);
sa02Printf("Calibration *\n\n");
} else if (strstr(type,"LaserHVOn")!=NULL) {
set_dac(1);
sa02Printf("Low intensity laser *\n\n");
} else if (strstr(type,"LaserHVOff")!=NULL) {
set_dac(0);
sa02Printf("High intensity laser *\n\n");
} else if (strstr(type,"Gain")!=NULL) {
sscanf(line,"%*s%d",paramValue);
sprintf(test," %d", atoi(paramValue));
sa02Printf("%s *\n\n", test);
changeGlobalParam(12, atoi(paramValue)); // Global parameter Gain has ID 12
} else if (strstr(type,"ShapingTime")!=NULL) {
sscanf(line,"%*s%s",paramValue);
sprintf(test," %d", atoi(paramValue));
sa02Printf("%s *\n\n", test);
changeGlobalParam(13, atoi(paramValue)); // Global parameter ShapingTime has ID 13
}
}
if (ctrl_c) {
break;
}
}
fclose(fp);
return 0;
}
 
/*
int CVICALLBACK StartPositionScan (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
daq_scan(NULL);
break;
}
return 0;
}
*/
 
int CVICALLBACK SetHome (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
switch (event) {
case EVENT_COMMIT:
SetWaitCursor (1);
if (gMIKRO_X) MIKRO_ReferenceMove (MIKRO_X);
if (gMIKRO_Y) MIKRO_ReferenceMove (MIKRO_Y);
if (gMIKRO_Z) MIKRO_ReferenceMove (MIKRO_Z);
SetWaitCursor (0);
break;
}
return 0;
}
 
int CVICALLBACK CBTimer (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
switch (event) {
case EVENT_TIMER_TICK:
// ProcessSystemEvents();
break;
}
return 0;
}
 
int CVICALLBACK GetPosition (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
int xpos=0,ypos=0,zpos=0;
switch (event) {
 
case EVENT_COMMIT:
 
if (gMIKRO_X) {
MIKRO_GetPosition(MIKRO_X,&xpos);
Delay(0.01);
SetCtrlVal (p2h, P2_X, xpos);
}
 
if (gMIKRO_Y) {
MIKRO_GetPosition(MIKRO_Y,&ypos);
Delay(0.01);
SetCtrlVal (p2h, P2_Y, ypos);
}
if (gMIKRO_X) {
MIKRO_GetPosition(MIKRO_Z,&zpos);
Delay(0.01);
SetCtrlVal (p2h, P2_Z, zpos);
sa02Printf("x=%d y=%d z=%d\n",xpos,ypos,zpos);
}
 
 
break;
}
return 0;
}
 
int CVICALLBACK ReRead (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
switch (event) {
case EVENT_COMMIT: {
int status;
char dfile[MAX_PATHNAME_LEN];
FILE *fp;
 
status = FileSelectPopup ("", "*.dat", ".dat",
"Izberi datoteko s podatki",
VAL_LOAD_BUTTON, 0, 0, 1, 0, dfile);
if (status==1) {
fp = fopen (dfile, "rb");
status = (int) fread (&runrec, 1, sizeof(runrec), fp);
fclose(fp);
if (runrec.id==RUNREC_ID) {
SetCtrlVal (p2h, P2_NX, runrec.nx);
SetCtrlVal (p2h, P2_XSTEP, runrec.dx);
SetCtrlVal (p2h, P2_XMIN, runrec.x0);
SetCtrlVal (p2h, P2_NY, runrec.ny);
SetCtrlVal (p2h, P2_YSTEP, runrec.dy);
SetCtrlVal (p2h, P2_YMIN, runrec.y0);
SetCtrlVal (p2h, P2_NEVE, runrec.nev);
SetCtrlVal (p2h, P2_SCANUNITSX, runrec.fver%2);
SetCtrlVal (p2h, P2_SCANUNITSY, runrec.fver/2);
SetCtrlVal (p2h, P2_DIRECTION, runrec.direction);
}
}
}
break;
}
return 0;
}
 
int CVICALLBACK Zset (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
switch (event) {
case EVENT_COMMIT: {
int zpos;
GetCtrlVal (p2h, P2_ZSET, &zpos);
if (gMIKRO_Z) MIKRO_MoveTo (MIKRO_Z, zpos);
 
}
break;
}
return 0;
}
 
int CVICALLBACK HidePanelCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
switch (event) {
case EVENT_COMMIT:
HidePanel (panel);
break;
}
return 0;
}
 
int GetChannelPosition(int chip, int ch, int *chx, int *chy) {
 
int i=0;
 
for (i=0; i<144; i++) {
 
if (eid2hapdxy[i].chip == chip && eid2hapdxy[i].ch == ch) {
*chx = eid2hapdxy[i].chx;
*chy = eid2hapdxy[i].chy ;
return 0;
}
}
return -1;
 
}
 
int LoadElectronicMap(const char *fname) {
 
FILE *fp = fopen(fname,"r");
int chip,ch,chx,chy,chxr,chyr;
int nread=0;
int ndim=400;
char line[400];
int nr=0;
 
while (fgets(line,ndim,fp)!=NULL) {
 
nr = sscanf(line,"%d%d%d%d",&chip,&ch,&chxr,&chyr);
if (nr) {
// Orientation of HAPD in xy system - position of APD A:LR,UR,UL,LL and view:B,F
//LRB
// chx=11-chxr;
// chy=11-chyr;
//URB
chx=chyr;
chy=11-chxr;
//ULB
// chx=chxr;
// chy=chyr;
//LLB
// chx=11-chyr;
// chy=chxr;
eid2hapdxy[nread].chip = chip;
eid2hapdxy[nread].ch = ch ;
eid2hapdxy[nread].chx = chx ;
eid2hapdxy[nread].chy = chy ;
}
nread++;
}
sa02Printf("eid2hapdxy %d records read.\n",nread);
fclose(fp);
return 0;
 
}
 
int CVICALLBACK SetParameters (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
//uint32_t address;
//char saddress[0xFF],
char fname[0xFF];
 
switch (event) {
case EVENT_COMMIT:
GetCtrlVal(p3h, P3_INPUTFILE, fname);
SetParametersFromFile(fname);
 
break;
}
return 0;
}
 
int CVICALLBACK UploadGlobalParameters (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
uint32_t response[2]= {0,0};
switch (event) {
case EVENT_COMMIT:
SetCtrlAttribute (panel, control, ATTR_DIMMED, 1);
{
uint32_t gdata;
 
int board,asic;
int i=0,imin=0,imax=0;
Rect trange;
Point cell;
int row=0;
unsigned short val;
sa02AsicGlobalRegister *greg = (sa02AsicGlobalRegister *) &gdata ;
uint16_t mask=GetConnectedFebMask();
// GetCtrlVal(p1h,P1_BOARDNUMBER,&board);
GetCtrlVal(p1h,P1_BOARDTYPE,&sa02BoardType);
 
if (control== P3_SELGPARLOAD) {
GetTableSelection (p3h, P3_GREG, &trange);
if ((trange.top!=0)&&(trange.left!=0)) {
imin= trange.top - 1;
imax= imin + trange.height;
 
} else {
if (!GetActiveTableCell(p3h, P3_GREG, &cell)) {
imin = cell.y-1;
imax = imin;
} else return 0;
}
} else {
imin=0;
imax=4*4;
}
 
for (i=imin; i<imax; i++) {
row=i+1;
GetTableCellVal (p3h, P3_GREG, MakePoint (1,row), &val);
greg->phasecmps = val;
GetTableCellVal (p3h, P3_GREG, MakePoint (2,row), &val);
greg->gain = val;
GetTableCellVal (p3h, P3_GREG, MakePoint (3,row), &val);
greg->shapingtime = val;
GetTableCellVal (p3h, P3_GREG, MakePoint (4,row), &val);
greg->comparator = val;
GetTableCellVal (p3h, P3_GREG, MakePoint (5,row), &val);
greg->vrdrive = val;
GetTableCellVal (p3h, P3_GREG, MakePoint (6,row), &val);
greg->monitor = val;
//GetTableCellVal (p3h, P3_GREG, MakePoint (7,row), &val); greg->id = val;
greg->id = 0;
greg->unused=0;
board=i/4;
asic=i%4;
 
if (mask & (1<<board) ) sa02Cmd(board,SA0x_ASIC0_GREG, gdata, asic, 0,1,response);
if (ctrl_c) {
break;
}
}
}
SetCtrlAttribute (panel, control, ATTR_DIMMED, 0);
sa02Printf("Global Parameters Uploaded to the ASICs\n");
break;
}
return 0;
}
 
int CVICALLBACK UploadChannelParameters (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
uint32_t response[2]= {0,0};
switch (event) {
case EVENT_COMMIT:
SetCtrlAttribute (panel, control, ATTR_DIMMED, 1);
{
uint32_t cdata;
int state;
Rect trange;
Point cell;
 
sa02AsicChannelRegister *creg = (sa02AsicChannelRegister *) &cdata ;
 
unsigned int i=0,imin=0,imax=0;
int row=0;
uint32_t board;
uint16_t mask=GetConnectedFebMask();
 
unsigned short val,asic,ch;
 
// GetCtrlVal(p1h,P1_BOARDNUMBER, &board);
GetCtrlVal(p1h,P1_BOARDTYPE,&sa02BoardType);
 
if ((panel==p3h)&&(control==P3_SELCPARLOAD)) {
state = GetTableSelection (p3h, P3_CREG, &trange);
if ((trange.top!=0)&&(trange.left!=0)) {
imin= trange.top-1;
imax= imin + trange.height;
 
} else {
if (!GetActiveTableCell(p3h, P3_CREG, &cell)) {
imin = cell.y-1;
imax = imin+1;
} else return 0;
}
} else if ((panel==p1h)&&(control==P1_CHPARLOAD)) {
GetCtrlVal(p1h,P1_NSLIX,&imin);
imax=imin+1;
} else {
imin=0;
imax=144*4;
}
 
for (i=imin; i<imax; i++) {
// asic=(unsigned short )(i/36);
// ch=(unsigned short )(i%36);
int err = 0;
row=i+1;
if (GetTableCellVal (p3h, P3_CREG, MakePoint (1,row), &asic)) err=1;
if (GetTableCellVal (p3h, P3_CREG, MakePoint (2,row), &ch)) err=1;
if (GetTableCellVal (p3h, P3_CREG, MakePoint (3,row), &val)) err=1;
creg->decaytime=val;
if (GetTableCellVal (p3h, P3_CREG, MakePoint (4,row), &val)) err=1;
creg->offset = val;
if (GetTableCellVal (p3h, P3_CREG, MakePoint (5,row), &val)) err=1;
creg->fineadj_unipol = val;
if (GetTableCellVal (p3h, P3_CREG, MakePoint (6,row), &val)) err=1;
creg->fineadj_diff = val;
if (GetTableCellVal (p3h, P3_CREG, MakePoint (7,row), &val)) err=1;
creg->tpenb = val;
//sa02Printf("===%d %d\n",i, val);
if (GetTableCellVal (p3h, P3_CREG, MakePoint (8,row), &val)) err=1;
creg->kill = val;
creg->unused=0;
board=i/144;
if (mask & (1<<board) ) sa02Cmd(board,SA0x_ASIC0_CREG, cdata, asic, ch,1,response);
if (sa02Verbose >0) {
sa02Printf("===%d\n",i);
}
if (err) sa02Printf("*** Table read error at row %d ***\n",row);
if (ctrl_c) {
break;
}
}
sa02Printf("Channel Parameters Uploaded to the ASICs\n");
 
}
SetCtrlAttribute (panel, control, ATTR_DIMMED, 0);
break;
}
return 0;
}
 
int CVICALLBACK UploadFPGAParameters (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
 
int n=0;
int i=0;
int nb=0;
#define NDIM 400
int asic=0;
char buf[NDIM];
char cmd[NDIM];
char sasic[NDIM];
uint32_t sa02code;
uint32_t board;
uint32_t response[2]= {0,0};
 
switch (event) {
case EVENT_COMMIT: {
uint16_t mask=GetConnectedFebMask();
SetCtrlAttribute (panel, control, ATTR_DIMMED, 1);
 
GetNumTextBoxLines(p3h, P3_FPGAPAR,&n);
for (i=0; i<n; i++) {
GetTextBoxLine(p3h, P3_FPGAPAR, i, buf);
nb = sscanf(buf,"%s%s",cmd,sasic);
asic = strtoul (sasic,NULL,0);
sa02code = sa02GetCmdCode(cmd);
if (strcmp(cmd,"MUXASIC")==0) {
asic = sa02MuxMap(asic);
}
for (board = 0; board < 4; board ++) if ( mask & (1 << board) ) sa02Cmd(board,sa02code, asic, 0, 0, 2,response);
sa02Printf("%s\n",buf);
}
sa02Printf("FPGA Parameters Uploaded to FEBS\n");
SetCtrlAttribute (panel, control, ATTR_DIMMED, 0);
break;
}
}
return 0;
}
 
int CVICALLBACK SetSelectionToVal (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
int state, input_cid=-1,output_cid=-1;
Rect trange;
unsigned short value;
switch (event) {
case EVENT_COMMIT:
switch (control) {
case P3_SETSELCPAR:
input_cid=P3_SETCPAR;
output_cid=P3_CREG;
break;
case P3_SETSELGPAR:
input_cid=P3_SETGPAR;
output_cid=P3_GREG;
break;
 
}
state = GetTableSelection (p3h, output_cid, &trange);
if ((trange.top!=0)&&(trange.left!=0)) {
GetCtrlVal(p3h,input_cid, &value);
state = FillTableCellRange (p3h, output_cid, trange, value);
}
break;
}
return 0;
}
 
int CVICALLBACK SelectMux (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
int cid[4]= {P3_MUX0,P3_MUX1,P3_MUX2,P3_MUX3};
int id=0,i;
uint32_t sa02code;
uint32_t board;
uint32_t response[2]= {0,0};
 
switch (event) {
case EVENT_COMMIT:
 
switch (control) {
case P3_MUX0:
id=0;
break;
case P3_MUX1:
id=1;
break;
case P3_MUX2:
id=2;
break;
case P3_MUX3:
id=3;
break;
default:
id=0;
}
SetCtrlVal(panel,control,1);
sa02code = sa02GetCmdCode("MUX");
GetCtrlVal(p1h,P1_BOARDNUMBER,&board);
sa02Cmd(board,sa02code, id, 0, 0, 2,response);
 
 
for (i=0; i<4; i++) {
if (id!= i) {
SetCtrlVal(panel,cid[i],0);
}
}
sa02Printf("MUX %d\n",id);
break;
}
return 0;
}
 
int CVICALLBACK UploadFromPanels (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
switch (event) {
case EVENT_COMMIT:
UploadFPGAParameters(panel,control,event,callbackData,eventData1,eventData2);
UploadChannelParameters(panel,control,event,callbackData,eventData1,eventData2);
UploadGlobalParameters(panel,control,event,callbackData,eventData1,eventData2);
break;
}
return 0;