Jf: Electron collection mode (#983)

* electron collection mode for jungfrau. also removing the config chip when using register command
* collectionMode: HOLE/ELECTRON (enum)
This commit is contained in:
2024-09-30 17:15:22 +02:00
committed by GitHub
parent 7fa5b5d70a
commit 5b832cb6aa
30 changed files with 32158 additions and 21441 deletions

View File

@ -572,6 +572,7 @@ void setupDetector() {
#endif
setPedestalMode(DEFAULT_PEDESTAL_MODE, DEFAULT_PEDESTAL_FRAMES,
DEFAULT_PEDESTAL_LOOPS);
setElectronCollectionMode(DEFAULT_ELECTRON_COLLECTION_MODE);
}
int resetToDefaultDacs(int hardReset) {
@ -2615,6 +2616,22 @@ void setPedestalMode(int enable, uint8_t frames, uint16_t loops) {
}
}
int getElectronCollectionMode() {
return ((bus_r(DAQ_REG) & DAQ_ELCTRN_CLLCTN_MDE_MSK) >>
DAQ_ELCTRN_CLLCTN_MDE_OFST);
}
void setElectronCollectionMode(int enable) {
LOG(logINFO,
("Setting Collection Mode to %s\n", enable == 0 ? "Hole" : "Electron"));
if (enable) {
bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_ELCTRN_CLLCTN_MDE_MSK);
} else {
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_ELCTRN_CLLCTN_MDE_MSK);
}
configureChip();
}
int getTenGigaFlowControl() {
return ((bus_r(CONFIG_REG) & CONFIG_ETHRNT_FLW_CNTRL_MSK) >>
CONFIG_ETHRNT_FLW_CNTRL_OFST);

View File

@ -37,28 +37,29 @@
#define CONFIG_FILE ("config_jungfrau.txt")
/** Default Parameters */
#define DEFAULT_NUM_FRAMES (100 * 1000 * 1000)
#define DEFAULT_STARTING_FRAME_NUMBER (1)
#define DEFAULT_NUM_CYCLES (1)
#define DEFAULT_EXPTIME (10 * 1000) // ns
#define DEFAULT_PERIOD (2 * 1000 * 1000) // ns
#define DEFAULT_DELAY (0)
#define DEFAULT_HIGH_VOLTAGE (0)
#define DEFAULT_TIMING_MODE (AUTO_TIMING)
#define DEFAULT_SETTINGS (GAIN0)
#define DEFAULT_GAINMODE (DYNAMIC)
#define DEFAULT_TX_UDP_PORT (0x7e9a)
#define DEFAULT_TMP_THRSHLD (65 * 1000) // milli degree Celsius
#define DEFAULT_NUM_STRG_CLLS (0)
#define DEFAULT_STRG_CLL_STRT (0xf)
#define DEFAULT_STRG_CLL_STRT_CHIP11 (0x3)
#define DEFAULT_STRG_CLL_DLY (0)
#define DEFAULT_FLIP_ROWS (0)
#define DEFAULT_FILTER_RESISTOR (1) // higher resistor
#define DEFAULT_FILTER_CELL (0)
#define DEFAULT_PEDESTAL_MODE (0)
#define DEFAULT_PEDESTAL_FRAMES (1)
#define DEFAULT_PEDESTAL_LOOPS (1)
#define DEFAULT_NUM_FRAMES (100 * 1000 * 1000)
#define DEFAULT_STARTING_FRAME_NUMBER (1)
#define DEFAULT_NUM_CYCLES (1)
#define DEFAULT_EXPTIME (10 * 1000) // ns
#define DEFAULT_PERIOD (2 * 1000 * 1000) // ns
#define DEFAULT_DELAY (0)
#define DEFAULT_HIGH_VOLTAGE (0)
#define DEFAULT_TIMING_MODE (AUTO_TIMING)
#define DEFAULT_SETTINGS (GAIN0)
#define DEFAULT_GAINMODE (DYNAMIC)
#define DEFAULT_TX_UDP_PORT (0x7e9a)
#define DEFAULT_TMP_THRSHLD (65 * 1000) // milli degree Celsius
#define DEFAULT_NUM_STRG_CLLS (0)
#define DEFAULT_STRG_CLL_STRT (0xf)
#define DEFAULT_STRG_CLL_STRT_CHIP11 (0x3)
#define DEFAULT_STRG_CLL_DLY (0)
#define DEFAULT_FLIP_ROWS (0)
#define DEFAULT_FILTER_RESISTOR (1) // higher resistor
#define DEFAULT_FILTER_CELL (0)
#define DEFAULT_PEDESTAL_MODE (0)
#define DEFAULT_PEDESTAL_FRAMES (1)
#define DEFAULT_PEDESTAL_LOOPS (1)
#define DEFAULT_ELECTRON_COLLECTION_MODE (0)
#define HIGHVOLTAGE_MIN (60)
#define HIGHVOLTAGE_MAX (200)

View File

@ -607,6 +607,8 @@ uint64_t getSelectCurrentSource();
int getPedestalMode();
void getPedestalParameters(uint8_t *frames, uint16_t *loops);
void setPedestalMode(int enable, uint8_t frames, uint16_t loops);
int getElectronCollectionMode();
void setElectronCollectionMode(int enable);
#endif
// eiger specific - iodelay, pulse, rate, temp, activate, delay nw parameter

View File

@ -330,3 +330,5 @@ int setColumn(int);
int get_pedestal_mode(int);
int set_pedestal_mode(int);
int config_transceiver(int);
int get_collection_mode(int);
int set_collection_mode(int);

View File

@ -85,21 +85,7 @@ u_int32_t readRegister(u_int32_t offset) {
}
void writeRegister(u_int32_t offset, u_int32_t data) {
// if electron mode bit touched
#ifdef JUNGFRAUD
int electronCollectionModeChange = 0;
if ((offset << MEM_MAP_SHIFT) == DAQ_REG) {
if ((readRegister(offset) ^ data) & DAQ_ELCTRN_CLLCTN_MDE_MSK) {
electronCollectionModeChange = 1;
}
}
#endif
bus_w(offset << MEM_MAP_SHIFT, data);
#ifdef JUNGFRAUD
if (electronCollectionModeChange) {
configureChip();
}
#endif
}
u_int32_t readRegister16(u_int32_t offset) {

View File

@ -492,6 +492,8 @@ void function_table() {
flist[F_GET_PEDESTAL_MODE] = &get_pedestal_mode;
flist[F_SET_PEDESTAL_MODE] = &set_pedestal_mode;
flist[F_CONFIG_TRANSCEIVER] = &config_transceiver;
flist[F_GET_COLLECTION_MODE] = &get_collection_mode;
flist[F_SET_COLLECTION_MODE] = &set_collection_mode;
// check
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
@ -11086,3 +11088,62 @@ int config_transceiver(int file_des) {
#endif
return Server_SendResult(file_des, INT32, NULL, 0);
}
int get_collection_mode(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
enum collectionMode retval = HOLE;
LOG(logDEBUG1, ("Getting collection mode\n"));
#ifndef JUNGFRAUD
functionNotImplemented();
#else
// get only
retval = getElectronCollectionMode() ? ELECTRON : HOLE;
LOG(logDEBUG1, ("collection mode retval: %u\n", retval));
#endif
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
}
int set_collection_mode(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
enum collectionMode arg = HOLE;
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
return printSocketReadError();
LOG(logDEBUG1, ("Setting collection mode: %u\n", (int)arg));
#ifndef JUNGFRAUD
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
if (getChipVersion() == 11) {
ret = FAIL;
sprintf(mess,
"Cannot set addl. number of storage cells for chip v1.1\n");
LOG(logERROR, (mess));
} else {
switch (arg) {
case HOLE:
setElectronCollectionMode(0);
break;
case ELECTRON:
setElectronCollectionMode(1);
break;
default:
modeNotImplemented("Collection mode index", (int)arg);
break;
}
enum collectionMode retval =
getElectronCollectionMode() ? ELECTRON : HOLE;
validate(&ret, mess, (int)arg, (int)retval, "set collection mode",
DEC);
LOG(logDEBUG1, ("collection mode retval: %u\n", retval));
}
}
#endif
return Server_SendResult(file_des, INT32, NULL, 0);
}