Compare commits

...

12 Commits

29 changed files with 163 additions and 38 deletions

View File

@ -13,7 +13,7 @@ Compilation
* Using cmk.sh script,
.. code-block:: bash
./cmk.sh -b**s**j9 #option s is for simulator
./cmk.sh -bsj9 #option s is for simulator
Binaries

View File

@ -983,6 +983,7 @@ mount -t tmpfs none /mnt/ramdisk -o size=10G
\end{verbatim}
check how many GB memory you can allocate, to avoid swapping otherwise
\section{Offline processing and monitoring}
\subsection{Data out of the detector: UDP packets}\label{UDP}
@ -1064,13 +1065,22 @@ Checkout the {\tt{v3.1}} branch if in a 3.1.X release, the {\tt{v4.0.0}} branch
Four possible conversions are possible: into \textbf{cbf}, \textbf{hdf5}. \textbf{tiff} and \textbf{root} format. The detector writes 2 raw files per receiver. An offline image reconstruction executable has been written to collate the possible files together and produce output files. By default an interpolation between the values of the large pixels is performed. Gap pixels between modules are also inserted.
Note that the number of images per file in the 3.1.X release is hardcoded and needs to match whatever you are using in \\
\subsection{Releases}
Note for different releases:
\begin{itemize}
\item Note that the number of images per file in the 3.1.X release is hardcoded and needs to match whatever you are using in \\
{\tt{slsDetectorsPackage/slsReceiverSoftware/include/sls\_receiver\_defs.h}}:
\begin{verbatim}
#define EIGER_MAX_FRAMES_PER_FILE 2000
\end{verbatim}
The default is 2000 in the 3.1.X release. The default has been changed to 10000 frm realease 4.0.X and now this is picked up automatically without doing anything.
\item From release 4.1.x, it is not needed to change the options in the \tt{slsImageReconstruction/src/main\_csaxs.cpp} file, but it is enough to change the options in the compiler:
\end{itemize}
\subsubsection{cbf}
The cbf executable executable uses the CBFlib-0.9.5 library (downloaded from the web as it downloads architecture dependent packages at installation).Edit the Makefile to correclty point at it.\\
\underline{At cSAXS, the CBFlib-0.9.5 has been compiled -such that the required packages are}\\\underline{ downloaded in /sls/X12SA/data/x12saop/EigerPackage/CBFlib-0.9.5.}\\
@ -1128,7 +1138,7 @@ make cbfMaker; make cbfMakerOMNY;
\end{verbatim}
\subsubsection{hdf5}
In case of HDF5 output file, we rely on having the HDF5 1.10.1 library installed and {\tt{HDF5-External-Filter-Plugins}} installed. With HDF5 1.10.3, no need of the external plugings package is needed, but a small modification to the file is needed. Edit the Makefile to correclty point at it. Different compression methods are being tried so different external filters might be to be installed. This work is not finished yet.
In case of HDF5 output file, we rely on having the hdf5/1.10.3 (previously was 1.10.1 library installed and {\tt{HDF5-External-Filter-Plugins}} installed). Edit the Makefile to correclty point at Different compression methods (so far only the not efficien gzip is implemented) are being tried so different external filters might be to be installed. This work is not finished yet.
To choose HDF5, with ZLIB implementation, open {\tt{slsImageReconstruction/src/main\_csaxs.cpp}} and make sure that
\begin{verbatim}
@ -1201,6 +1211,28 @@ The HV can also be set and read through the software:
\end{verbatim}
Note that the get {\tt{vhighvoltage}}(\tt{\textcolor{red}{highvoltage}}) would return the measured HV from the master module only. If getting the highvoltage for individual halfmodules, only the master will have a value different from -999.
\section{Run the sum of counts in the receiver}
In the package {\tt{slsImageReconstruction}} there is also a very basic executable that allows to run receivers that sum all the counts in the UDP port and writes them as a text files in the {\tt{outdir}} directory in the same directory as the data files, with the same {\tt{fname}}. This is to use EIGER as a simple normalization detector.
The code is in {\tt{slsImageReconstruction/src/ReceiverSum.cpp}}.
For the compilation you need to be in {\tt{slsImageReconstruction}}
\begin{verbatim}
make -f Makefile.zmq receiverSum
\end{verbatim}
you might need to edit the path to the {\tt{slsDetectorPackage}} that you are using in the {\tt{Makefile.zmq}}.
Usage is:
\begin{verbatim}
export LD_LIBRARY_PATH=pathtoslsDetectorPackage/build/bin
./bin/receiverSum
./bin/receiverSum rx_tcppport 1955
\end{verbatim}
For now, to work peoperly there are some requirements that need to make more general if the code wants to be used more:
\begin{enumerate}
\item You can use the code only for a module (2 Receivers)
\item The first receiver has to run using tcp\_port 1954 (the second port is not fixed but we use 1955 normally)
\item Set the option {\tt{enablefwrite 0}} (\textcolor{red}{\tt{fwrite 0}}) as we do not write raw data but only the text files.
\item As a bit of time is required to make the sum compared to a normal receiver, use the option {\tt sls\_detector\_put rx\_fifodepth 50000}.
\end{enumerate}
File like fnamed0\_findex.txt, fnamed1\_findex.txt, fnamed2\_findex.txt and fnamed3\_findex.txt will be written, containing 2 columns: the frame number and the sum of counts for the port.
\appendix
\section{Kill the server, copy a new server, start the server}\label{server}

View File

@ -0,0 +1 @@
../slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer

View File

@ -1 +0,0 @@
../slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServerv5.0.0-rc2

View File

@ -0,0 +1 @@
../slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer

View File

@ -1 +0,0 @@
../slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServerv5.0.0-rc2

View File

@ -0,0 +1 @@
../slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer

View File

@ -1 +0,0 @@
../slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServerv5.0.0-rc2

View File

@ -0,0 +1 @@
../slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer

View File

@ -1 +0,0 @@
../slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServerv5.0.0-rc2

View File

@ -0,0 +1 @@
../slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer

View File

@ -1 +0,0 @@
../slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServerv5.0.0-rc2

View File

@ -0,0 +1 @@
../slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer

View File

@ -1 +0,0 @@
../slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServerv5.0.0-rc2

View File

@ -0,0 +1 @@
../slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer

View File

@ -1 +0,0 @@
../slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServerv5.0.0-rc2

View File

@ -148,6 +148,16 @@
#define DTA_OFFSET_REG (0x24 * REG_OFFSET + BASE_CONTROL)
/* Formatting for adif core -----------------------------------------------*/
#define ADIF_CONFIG_REG (0x00 * REG_OFFSET + BASE_ADIF)
#define ADIF_ADDTNL_OFST_OFST (0)
#define ADIF_ADDTNL_OFST_MSK (0x00000003 << ADIF_ADDTNL_OFST_OFST)
#define ADIF_PIPELINE_OFST (4)
#define ADIF_PIPELINE_MSK (0x0000000F << ADIF_PIPELINE_OFST)
/* Formatting for data core -----------------------------------------------*/
#define FMT_CONFIG_REG (0x00 * REG_OFFSET + BASE_FMT)

View File

@ -50,6 +50,8 @@ uint32_t clkDivider[NUM_CLOCKS] = {};
int highvoltage = 0;
int detPos[2] = {};
int64_t exptimeReg[3] = {0, 0, 0};
int64_t gateDelayReg[3] = {0, 0, 0};
int isInitCheckDone() { return initCheckDone; }
@ -418,6 +420,7 @@ void setupDetector() {
setHighVoltage(DEFAULT_HIGH_VOLTAGE);
setDefaultDacs();
setASICDefaults();
setADIFDefaults();
// dynamic range
setDynamicRange(DEFAULT_DYNAMIC_RANGE);
@ -514,6 +517,17 @@ void setASICDefaults() {
bus_w(ASIC_RDO_CONFIG_REG, val);
}
void setADIFDefaults() {
uint32_t addr = ADIF_CONFIG_REG;
bus_w(addr, ((bus_r(addr) & ~ADIF_ADDTNL_OFST_MSK) & ~ADIF_PIPELINE_MSK));
bus_w(addr,
(bus_r(addr) | ((DEFAULT_ADIF_PIPELINE_VAL << ADIF_PIPELINE_OFST) &
ADIF_PIPELINE_MSK)));
bus_w(addr,
(bus_r(addr) | ((DEFAULT_ADIF_ADD_OFST_VAL << ADIF_ADDTNL_OFST_OFST) &
ADIF_ADDTNL_OFST_MSK)));
}
/* firmware functions (resets) */
void cleanFifos() {
@ -681,7 +695,7 @@ void updateGatePeriod() {
}
}
}
LOG(logINFO, ("\tSetting Gate Period to %lld ns\n", (long long int)max));
LOG(logINFO, ("\tUpdating Gate Period to %lld ns\n", (long long int)max));
max *= (1E-9 * getFrequency(SYSTEM_C0));
set64BitReg(max, ASIC_EXP_GATE_PERIOD_LSB_REG,
ASIC_EXP_GATE_PERIOD_MSB_REG);
@ -714,14 +728,22 @@ int setExpTime(int gateIndex, int64_t val) {
return FAIL;
}
if (val < 0) {
LOG(logERROR, ("Invalid exptime (index:%d): %lld ns\n", gateIndex,
(long long int)val));
LOG(logERROR,
("Invalid exptime%d : %lld ns\n", gateIndex, (long long int)val));
return FAIL;
}
LOG(logINFO, ("Setting exptime %lld ns (index:%d)\n", (long long int)val,
gateIndex));
LOG(logINFO,
("Setting exptime%d to %lld ns\n", gateIndex, (long long int)val));
val *= (1E-9 * getFrequency(SYSTEM_C0));
set64BitReg(val, alsb, amsb);
// set in register only if counter enabled
exptimeReg[gateIndex] = val;
if (getCounterMask() & (1 << gateIndex)) {
set64BitReg(val, alsb, amsb);
} else {
LOG(logWARNING, ("Writing 0 to reg (counter disabled)\n"));
set64BitReg(0, alsb, amsb);
}
// validate for tolerance
int64_t retval = getExpTime(gateIndex);
@ -755,7 +777,15 @@ int64_t getExpTime(int gateIndex) {
LOG(logERROR, ("Invalid gate index: %d\n", gateIndex));
return -1;
}
return get64BitReg(alsb, amsb) / (1E-9 * getFrequency(SYSTEM_C0));
uint64_t retval = 0;
// read from register if counter enabled
if (getCounterMask() & (1 << gateIndex)) {
retval = get64BitReg(alsb, amsb);
} else {
retval = exptimeReg[gateIndex];
}
return retval / (1E-9 * getFrequency(SYSTEM_C0));
}
int setGateDelay(int gateIndex, int64_t val) {
@ -779,14 +809,22 @@ int setGateDelay(int gateIndex, int64_t val) {
return FAIL;
}
if (val < 0) {
LOG(logERROR, ("Invalid gate delay (index:%d): %lld ns\n", gateIndex,
LOG(logERROR, ("Invalid gate delay%d : %lld ns\n", gateIndex,
(long long int)val));
return FAIL;
}
LOG(logINFO, ("Setting gate delay %lld ns (index:%d)\n", (long long int)val,
gateIndex));
LOG(logINFO,
("Setting gate delay%d to %lld ns\n", gateIndex, (long long int)val));
val *= (1E-9 * getFrequency(SYSTEM_C0));
set64BitReg(val, alsb, amsb);
// set in register only if counter enabled
gateDelayReg[gateIndex] = val;
if (getCounterMask() & (1 << gateIndex)) {
set64BitReg(val, alsb, amsb);
} else {
LOG(logWARNING, ("Writing 0 to reg (counter disabled)\n"));
set64BitReg(0, alsb, amsb);
}
// validate for tolerance
int64_t retval = getGateDelay(gateIndex);
@ -820,7 +858,15 @@ int64_t getGateDelay(int gateIndex) {
LOG(logERROR, ("Invalid gate index: %d\n", gateIndex));
return -1;
}
return get64BitReg(alsb, amsb) / (1E-9 * getFrequency(SYSTEM_C0));
uint64_t retval = 0;
// read from register if counter enabled
if (getCounterMask() & (1 << gateIndex)) {
retval = get64BitReg(alsb, amsb);
} else {
retval = gateDelayReg[gateIndex];
}
return retval / (1E-9 * getFrequency(SYSTEM_C0));
}
void setCounterMask(uint32_t arg) {
@ -835,7 +881,11 @@ void setCounterMask(uint32_t arg) {
LOG(logDEBUG, ("Config Reg: 0x%x\n", bus_r(addr)));
updatePacketizing();
updateGatePeriod();
LOG(logINFO, ("\tUpdating Exptime and Gate Delay\n"));
for (int i = 0; i < 3; ++i) {
setExpTime(i, exptimeReg[i]);
setGateDelay(i, gateDelayReg[i]);
}
}
uint32_t getCounterMask() {
@ -844,6 +894,7 @@ uint32_t getCounterMask() {
}
void updatePacketizing() {
LOG(logINFO, ("\tUpdating Packetizing\n"));
const int ncounters = __builtin_popcount(getCounterMask());
const int tgEnable = enableTenGigabitEthernet(-1);
int packetsPerFrame = 0;
@ -1025,9 +1076,24 @@ int setTrimbits(int *trimbits) {
LOG(logINFO, ("Trimbits validated\n"));
trimmingPrint = logDEBUG5;
// remember previous run clock
uint32_t prevRunClk = clkDivider[SYSTEM_C0];
// set to trimming clock
if (setClockDivider(SYSTEM_C0, DEFAULT_TRIMMING_RUN_CLKDIV) == FAIL) {
LOG(logERROR,
("Could not start trimming. Could not set to trimming clock\n"));
return FAIL;
}
// trimming
int error = 0;
uint64_t patword = 0;
int iaddr = 0;
for (int ichip = 0; ichip < NCHIP; ichip++) {
if (error != 0) {
break;
}
LOG(logDEBUG1, (" Chip %d\n", ichip));
iaddr = 0;
patword = 0;
@ -1118,8 +1184,8 @@ int setTrimbits(int *trimbits) {
if (iaddr >= MAX_PATTERN_LENGTH) {
LOG(logERROR, ("Addr 0x%x is past max_address_length 0x%x!\n",
iaddr, MAX_PATTERN_LENGTH));
trimmingPrint = logINFO;
return FAIL;
error = 1;
break;
}
// set pattern wait address
@ -1141,12 +1207,25 @@ int setTrimbits(int *trimbits) {
startPattern();
}
// copy trimbits locally
for (int ichan = 0; ichan < ((detectorModules)->nchan); ++ichan) {
detectorChans[ichan] = trimbits[ichan];
if (error == 0) {
// copy trimbits locally
for (int ichan = 0; ichan < ((detectorModules)->nchan); ++ichan) {
detectorChans[ichan] = trimbits[ichan];
}
LOG(logINFO, ("All trimbits have been loaded\n"));
}
trimmingPrint = logINFO;
LOG(logINFO, ("All trimbits have been loaded\n"));
// set back to previous clock
if (setClockDivider(SYSTEM_C0, prevRunClk) == FAIL) {
LOG(logERROR, ("Could not set to previous run clock after trimming\n"));
return FAIL;
}
if (error != 0) {
return FAIL;
}
return OK;
}

View File

@ -39,14 +39,17 @@
#define DEFAULT_TIMING_MODE (AUTO_TIMING)
#define DEFAULT_READOUT_C0 (10) //(100000000) // rdo_clk, 100 MHz
#define DEFAULT_READOUT_C1 (10) //(100000000) // smp sample clk (x2), 100 MHz
#define DEFAULT_SYSTEM_C0 (20) // (50000000) // run_clk, 50 MHz
#define DEFAULT_SYSTEM_C0 (10) //(100000000) // run_clk, 100 MHz
#define DEFAULT_SYSTEM_C1 (10) //(100000000) // sync_clk, 100 MHz
#define DEFAULT_SYSTEM_C2 (10) //(100000000) // str_clk, 100 MHz
#define DEFAULT_SYSTEM_C3 (5) //(200000000) // smp_clk, 200 MHz
// (DEFAULT_SYSTEM_C3 only for timing receiver) should not be changed
#define DEFAULT_TRIMMING_RUN_CLKDIV (40) // (25000000) // 25 MHz
#define DEFAULT_ASIC_LATCHING_NUM_PULSES (10)
#define DEFAULT_MSTR_OTPT_P1_NUM_PULSES (20)
#define DEFAULT_ADIF_PIPELINE_VAL (8)
#define DEFAULT_ADIF_ADD_OFST_VAL (0)
/* Firmware Definitions */
#define MAX_TIMESLOT_VAL (0xFFFFFF)

View File

@ -120,6 +120,7 @@ int setDefaultDacs();
#endif
#ifdef MYTHEN3D
void setASICDefaults();
void setADIFDefaults();
#endif
#if defined(GOTTHARD2D) || defined(EIGERD)
int readConfigFile();

View File

@ -1,12 +1,12 @@
/** API versions */
#define GITBRANCH "5.0.0-rc2"
#define APICTB 0x201008
#define APIGOTTHARD 0x201008
#define APIGOTTHARD2 0x201008
#define APIJUNGFRAU 0x201008
#define APIMYTHEN3 0x201008
#define APIMOENCH 0x201008
#define APIEIGER 0x201008
#define GITBRANCH "developer"
#define APILIB 0x201008
#define APIRECEIVER 0x201008
#define APIGUI 0x201009
#define APICTB 0x201009
#define APIGOTTHARD 0x201009
#define APIGOTTHARD2 0x201009
#define APIJUNGFRAU 0x201009
#define APIMOENCH 0x201009
#define APIEIGER 0x201009
#define APIMYTHEN3 0x201009