Low-Energy Muon (LEM) Experiment
0.5.1
|
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <math.h>
#include <include/linux/version.h>
#include "midas.h"
#include "mcstd.h"
#include "sis3820.h"
#include "v1190.h"
#include "experim.h"
#include "nemu_experim.h"
Go to the source code of this file.
Data Structures | |
struct | TDC_EVAL_EVENT |
struct | TDC_PILEUP |
Macros | |
#define | SIS3820_ADDRESS_0 0x38000000 |
Local definitions to connect to VME module. More... | |
#define | SIS3820_ADDRESS_1 0x39000000 |
VME address of 2nd scaler module. More... | |
#define | V1190_ADDRESS 0xEE000000 |
the VME address of the CAEN V1190 TDC More... | |
#define | MAX_NUMBER_LWORDS 1024 |
max number of block data transfer */ More... | |
#define | ALMOST_FULL_LEVEL 1024 |
#define | DATABUFFER_SIZE 131072 |
set size of FiFo (ring) buffer, 2^17 More... | |
#define | DIFF_TOLERANCE -12200 |
#define | TD_EVENT (1<<0) |
Event flags. More... | |
#define | LE_POSITRON_EVENT (1<<1) |
#define | M2_EVENT (1<<2) |
#define | BC_EVENT (1<<3) |
#define | M1_EVENT (1<<4) |
#define | M1_POSITRON_EVENT (1<<5) |
#define | MASTERLAST 1 |
timing flags More... | |
#define | MASTERFIRST 2 |
#define | BINNING 0.1953125 |
Functions | |
INT | frontend_init () |
INT | frontend_exit () |
INT | begin_of_run (INT run_number, char *error) |
INT | end_of_run (INT run_number, char *error) |
INT | pause_run (INT run_number, char *error) |
INT | resume_run (INT run_number, char *error) |
INT | frontend_loop () |
INT | read_trigger_event (char *pevent, INT off) |
INT | poll_event (INT source, INT count, BOOL test) |
INT | read_scaler_event (char *pevent, INT off) |
INT | read_slowcontrol_event (char *pevent, INT off) |
INT | do_channel (INT ch, INT time) |
INT | do_master_channel (INT ch, INT event_type) |
U_LONG | pileup_end (INT pileupWindow) |
INT | evaluate_slow_muon_event () |
INT | evaluate_fast_muon_event () |
BOOL | check_tof_and_pileup (INT timing, INT tofWindow, INT firstCh, INT lastCh, INT masterChannel, INT masterIndex, INT *channel, INT *ind) |
BOOL | check_positron (INT decWindow, INT coincWindow, INT firstCh, INT lastCh, INT masterChannel, INT masterIndex, INT *channel, INT *ind) |
void | scaler_mode (u_int32_t module_address) |
int | init_sis3820 (u_int32_t module_address) |
int | init_v1190 (u_int32_t module_address) |
void | OnOff_mode () |
INT | interrupt_configure (INT cmd, INT source, PTYPE adr) |
Variables | |
char * | frontend_name = "VME_FE" |
experiment specific ODB structures More... | |
char * | frontend_file_name = __FILE__ |
The frontend file name, don't change it. More... | |
BOOL | frontend_call_loop = TRUE |
frontend_loop is called periodically if this variable is TRUE More... | |
INT | display_period = 3000 |
a frontend status page is displayed with this frequency in ms More... | |
INT | max_event_size = 128000 |
maximum event size produced by this frontend More... | |
INT | max_event_size_frag = 5*1024*1024 |
maximum event size for fragmented events (EQ_FRAGMENTED) More... | |
INT | event_buffer_size = 60*10000 |
buffer size to hold events More... | |
TRIGGER_SETTINGS | trigger_settings |
/Equipment/Trigger/Settings More... | |
SCALER_SETTINGS | scaler_settings |
RUNINFO | runinfo |
/Runinfo ODB key, defined in from midas.h More... | |
BEAMLINE_EVENT | beamline_event |
for slow control parameters More... | |
LEMVAC_EVENT | lemvac_event |
MODCRYO_EVENT | moddy_event |
SAMPLECRYO_EVENT | sample_event |
SCS2001M_EVENT | scs2001m_event |
HV_EVENT | hv_event |
HV_DETECTORS_EVENT | hvdet_event |
HV_SETTINGS | hv_settings |
OMEGA_EVENT | omega_event |
INFO | info |
static VME_STATS | vme_stats |
static TDC_EVAL_EVENT | tdc_eval_event |
static TDC_PILEUP | tdc_pileup |
static INT | hdev |
handle for VME-PCI device More... | |
static DWORD * | databuffer |
ring buffer for TDC data More... | |
static DWORD * | p_read |
static DWORD * | p_write |
read and write pointers for data ring buffer More... | |
static DWORD | masterFlagSlowMuon |
use either TD_EVENT or M2_EVENT as slow muon master More... | |
static DWORD | eventDefinedSlowMuon |
bit pattern containing trigger mode for slow muons (BC-TD-M2) More... | |
static DWORD | eventDefinedFastMuon |
bit pattern containing trigger mode for fast muons (BC-M1) More... | |
static DWORD | masterChannelSlowMuon |
"master" TDC channel for slow muons (TD or M2) More... | |
static DWORD | masterChannelFastMuon |
"master" TDC channel for BC-M1 (usually M1) More... | |
static U_LONG | runTime |
absolute run time in TDC LSB units More... | |
static U_LONG | nextGoodTime |
absolute run time when new events are accepted (for on/off mode) More... | |
static DWORD | dataWindowFastMuon |
static DWORD | dataWindowSlowMuon |
static INT | t0_offset |
static BOOL | flag_external_on |
flag to indicate "on/off", "red/green" mode More... | |
static BOOL | flag_scaler_address_0 |
static BOOL | flag_scaler_address_1 |
flags to indicate status of VME scalers More... | |
INT | mode |
scaler mode, see scaler_mode() More... | |
static struct timeval | tvLastTime |
static BOOL | flag_on_puls |
flag to indicate that "puls" was turned on, "on/off" or "red/green" mode More... | |
EQUIPMENT | equipment [] |
#define ALMOST_FULL_LEVEL 1024 |
Definition at line 214 of file vme_fe.c.
Referenced by init_v1190().
#define BC_EVENT (1<<3) |
Definition at line 222 of file vme_fe.c.
Referenced by begin_of_run(), evaluate_fast_muon_event(), evaluate_slow_muon_event(), and frontend_loop().
#define BINNING 0.1953125 |
Referenced by frontend_loop().
#define DATABUFFER_SIZE 131072 |
set size of FiFo (ring) buffer, 2^17
Definition at line 215 of file vme_fe.c.
Referenced by evaluate_fast_muon_event(), evaluate_slow_muon_event(), frontend_init(), and read_trigger_event().
#define DIFF_TOLERANCE -12200 |
this is the allowed TDC time difference to the preceding event 12200 ~ 524288 - 512000 (2^19-1/10kHz)
Definition at line 216 of file vme_fe.c.
Referenced by do_channel().
#define LE_POSITRON_EVENT (1<<1) |
Definition at line 220 of file vme_fe.c.
Referenced by begin_of_run(), evaluate_slow_muon_event(), and frontend_loop().
#define M1_EVENT (1<<4) |
Definition at line 223 of file vme_fe.c.
Referenced by begin_of_run(), evaluate_fast_muon_event(), and frontend_loop().
#define M1_POSITRON_EVENT (1<<5) |
Definition at line 224 of file vme_fe.c.
Referenced by begin_of_run(), evaluate_fast_muon_event(), and frontend_loop().
#define M2_EVENT (1<<2) |
Definition at line 221 of file vme_fe.c.
Referenced by begin_of_run(), evaluate_slow_muon_event(), and frontend_loop().
#define MASTERFIRST 2 |
Definition at line 228 of file vme_fe.c.
Referenced by evaluate_fast_muon_event(), and evaluate_slow_muon_event().
#define MASTERLAST 1 |
timing flags
Definition at line 227 of file vme_fe.c.
Referenced by check_tof_and_pileup(), and evaluate_slow_muon_event().
#define MAX_NUMBER_LWORDS 1024 |
max number of block data transfer */
Definition at line 213 of file vme_fe.c.
Referenced by frontend_loop().
#define SIS3820_ADDRESS_0 0x38000000 |
Local definitions to connect to VME module.
VME address of 1st scaler module
Definition at line 210 of file vme_fe.c.
Referenced by begin_of_run(), frontend_exit(), frontend_init(), read_scaler_event(), and resume_run().
#define SIS3820_ADDRESS_1 0x39000000 |
VME address of 2nd scaler module.
Definition at line 211 of file vme_fe.c.
Referenced by begin_of_run(), frontend_exit(), frontend_init(), read_scaler_event(), and resume_run().
#define TD_EVENT (1<<0) |
Event flags.
Definition at line 219 of file vme_fe.c.
Referenced by begin_of_run(), evaluate_slow_muon_event(), and frontend_loop().
#define V1190_ADDRESS 0xEE000000 |
the VME address of the CAEN V1190 TDC
Definition at line 212 of file vme_fe.c.
Referenced by begin_of_run(), end_of_run(), frontend_init(), frontend_loop(), and resume_run().
INT begin_of_run | ( | INT | run_number, |
char * | error | ||
) |
Definition at line 589 of file vme_fe.c.
References BC_EVENT, BCL1, BCL2, BCL3, BCL4, BCR1, BCR2, BCR3, BCR4, TRIGGER_SETTINGS::beamcounter_active, CLOCK, TRIGGER_SETTINGS::data_window, databuffer, dataWindowFastMuon, dataWindowSlowMuon, TRIGGER_SETTINGS::enable_onoff_mode, TRIGGER_SETTINGS::event_0_active, TRIGGER_SETTINGS::event_0_settings, TRIGGER_SETTINGS::event_1_active, TRIGGER_SETTINGS::event_1_settings, TRIGGER_SETTINGS::event_2_active, TRIGGER_SETTINGS::event_2_settings, eventDefinedFastMuon, eventDefinedSlowMuon, TRIGGER_SETTINGS::events, EXTOFF1, EXTON1, flag_external_on, flag_on_puls, flag_scaler_address_0, flag_scaler_address_1, hdev, VME_STATS::last_TDCtime, LE_POSITRON_EVENT, M1_EVENT, M1_POSITRON_EVENT, M2_EVENT, masterChannelFastMuon, masterChannelSlowMuon, masterFlagSlowMuon, MCP1, TRIGGER_SETTINGS::mcp2_active, MCP2F, MCP2R, MCP2X1, MCP2X2, MCP2Y1, MCP2Y2, N_TDC_CHANNELS, nextGoodTime, p_read, p_write, POSBDI, POSBDO, POSBUI, POSBUO, TRIGGER_SETTINGS::positrons_active, POSLDI, POSLDO, POSLUI, POSLUO, POSMCP1I, POSMCP1O, POSRDI, POSRDO, POSRUI, POSRUO, POSTDI, POSTDO, POSTUI, POSTUO, runTime, scaler_mode(), SIS3820_ADDRESS_0, SIS3820_ADDRESS_1, sis3820_key_disable(), sis3820_key_enable(), sis3820_key_reset(), t0_offset, TRIGGER_SETTINGS::t0_offset, TD, TRIGGER_SETTINGS::td_active, TD_EVENT, TRIGGER_SETTINGS::td_master, tdc_eval_event, tdc_pileup, trigger_settings, V1190_ADDRESS, V1190_OPCODE_ADDRESS, V1190_SOFTWARE_CLEAR, and vme_stats.
BOOL check_positron | ( | INT | decWindow, |
INT | coincWindow, | ||
INT | firstCh, | ||
INT | lastCh, | ||
INT | masterChannel, | ||
INT | masterIndex, | ||
INT * | channel, | ||
INT * | ind | ||
) |
check_positron(decWindow, coincWindow, firstCh, lastCh, masterchannel, channel, ind):
check events: is there a e+ (coincidence) signal in the decWindow relative to masterChannel? find the nearest e+ event with respect to the masterChannel[0] event. if coincWindow < 0: single e+ counters are considered if coincWindow >=0: look for coincidences between the two channels firstCh and lastCh N O T E: post- pileup checking for positrons; this data will be written to the Midas event
Definition at line 2038 of file vme_fe.c.
References TDC_EVAL_EVENT::foundChannel, masterChannel, tdc_eval_event, and TDC_EVAL_EVENT::tdc_event.
Referenced by evaluate_fast_muon_event(), and evaluate_slow_muon_event().
BOOL check_tof_and_pileup | ( | INT | timing, |
INT | tofWindow, | ||
INT | firstCh, | ||
INT | lastCh, | ||
INT | masterChannel, | ||
INT | masterIndex, | ||
INT * | channel, | ||
INT * | ind | ||
) |
check_tof_and_pileup():
check events: is there a signal in the tofWIndow relative to masteChannel? if yes: check if hit is "clean", i.e. there was no other signal within pileupWindow
N O T E: this function only checks the pre-pileup for "TOF" and "Decay" hits, i.e. BC and e+ hits. The pre-pileup for the master channels is implicitly done in the loop over the TDC output buffer (currently done in frontend_loop()) where it is required that two starts of master channel events are separated by at least diffTimeSlowMuon or diffTimeFastMuon (which is 10musec at the moment).
Definition at line 1969 of file vme_fe.c.
References TDC_EVAL_EVENT::foundChannel, masterChannel, MASTERLAST, TDC_EVAL_EVENT::pileup, tdc_eval_event, and TDC_EVAL_EVENT::tdc_event.
Referenced by evaluate_fast_muon_event(), and evaluate_slow_muon_event().
INT do_channel | ( | INT | ch, |
INT | TDCtime | ||
) |
update channel statistics, copy TDC times in temporary buffer tdc_event[ch][index] to be used in evaluate_event():
Definition at line 1334 of file vme_fe.c.
References DIFF_TOLERANCE, TDC_EVAL_EVENT::event_time, TDC_EVAL_EVENT::foundChannel, VME_STATS::last_TDCtime, VME_STATS::run_time, runTime, TDC_EVAL_EVENT::set_t0, t0_offset, TDC_BIT_RANGE, tdc_eval_event, TDC_EVAL_EVENT::tdc_event, TDC_EVAL_EVENT::thisTimeFastMuon, TDC_EVAL_EVENT::thisTimeSlowMuon, and vme_stats.
Referenced by frontend_loop().
INT do_master_channel | ( | INT | ch, |
INT | event_type | ||
) |
Definition at line 1369 of file vme_fe.c.
References dataWindowFastMuon, dataWindowSlowMuon, TDC_EVAL_EVENT::doEvaluateFastMuonEvent, TDC_EVAL_EVENT::doEvaluateSlowMuonEvent, TDC_PILEUP::endMasterEvent0, TDC_PILEUP::endMasterEvent1or2, EVENT_0_TYPE, EVENT_1_TYPE, EVENT_2_TYPE, eventDefinedFastMuon, eventDefinedSlowMuon, TDC_EVAL_EVENT::foundChannel, TDC_EVAL_EVENT::indexFastMuon, TDC_EVAL_EVENT::indexFastMuonSet, TDC_EVAL_EVENT::indexSlowMuon, TDC_EVAL_EVENT::indexSlowMuonSet, TDC_PILEUP::lastMasterEvent0Pileup, TDC_PILEUP::lastMasterEvent1or2Pileup, TDC_EVAL_EVENT::lastTimeFastMuon, TDC_EVAL_EVENT::lastTimeSlowMuon, VME_STATS::mcp1_clean, VME_STATS::mcp1_good, VME_STATS::mcp2_clean, VME_STATS::mcp2_good, MCP2F, TDC_EVAL_EVENT::pileup, pileup_end(), runTime, TD, VME_STATS::td_clean, VME_STATS::td_good, tdc_eval_event, tdc_pileup, TDC_EVAL_EVENT::thisTimeFastMuon, TDC_EVAL_EVENT::thisTimeSlowMuon, and vme_stats.
Referenced by frontend_loop().
INT end_of_run | ( | INT | run_number, |
char * | error | ||
) |
Definition at line 858 of file vme_fe.c.
References VME_STATS::channelCounts, VME_STATS::fastMuonEvents, hdev, p_read, p_write, VME_STATS::readcounts, VME_STATS::run_time, VME_STATS::slowMuonEvents, TRIGGER_SETTINGS::tdc_disable_atstartup, VME_STATS::tdc_error_counts, trigger_settings, V1190_ADDRESS, V1190_DISABLE_ALL_CHANNEL, V1190_OPCODE_ADDRESS, and vme_stats.
INT evaluate_fast_muon_event | ( | ) |
check events, if trigger condition is met, build events, move them to ring buffer which is read in the read_trigger_event() function
Definition at line 1815 of file vme_fe.c.
References BC_EVENT, BCL1, BCL2, BCL3, BCL4, BCR1, BCR2, BCR3, BCR4, LEM_DATA::channel, VME_STATS::channelCounts, check_positron(), check_tof_and_pileup(), LEM_DATA::data, DATA_N_HITS, TRIGGER_SETTINGS::data_window, databuffer, DATABUFFER_SIZE, TRIGGER_SETTINGS::event_0_settings, EVENT_0_TYPE, eventDefinedFastMuon, TDC_EVAL_EVENT::eventSize, VME_STATS::fastMuonEvents, TDC_EVAL_EVENT::foundChannel, TDC_EVAL_EVENT::indexFastMuon, M1_EVENT, M1_POSITRON_EVENT, masterChannelFastMuon, MASTERFIRST, MCP1, VME_STATS::mcp1_clean, N_TDC_CHANNELS, NEW_EVENT_MASK, p_write, POSMCP1I, POSMCP1O, TDC_EVAL_EVENT::tdc_data, tdc_eval_event, TDC_EVAL_EVENT::tdc_event, TRIGGER_SETTINGS::tof_bc_pileup_window, TRIGGER_SETTINGS::tof_bc_window, trigger_settings, and vme_stats.
Referenced by frontend_loop().
INT evaluate_slow_muon_event | ( | ) |
check events, if trigger condition is met, build events, move them to ring buffer which is read in the read_trigger_event() function
Definition at line 1489 of file vme_fe.c.
References BC_EVENT, BCL1, BCL2, BCL3, BCL4, BCR1, BCR2, BCR3, BCR4, LEM_DATA::channel, check_positron(), check_tof_and_pileup(), LEM_DATA::data, DATA_N_HITS, TRIGGER_SETTINGS::data_window, databuffer, DATABUFFER_SIZE, TRIGGER_SETTINGS::enable_onoff_mode, TRIGGER_SETTINGS::event_1_active, TRIGGER_SETTINGS::event_1_settings, EVENT_1_TYPE, TRIGGER_SETTINGS::event_2_settings, EVENT_2_TYPE, TDC_EVAL_EVENT::event_time, eventDefinedSlowMuon, TRIGGER_SETTINGS::events, TDC_EVAL_EVENT::eventSize, TDC_EVAL_EVENT::eventType, EXTOFF1_FLAG, EXTON1_FLAG, flag_external_on, TDC_EVAL_EVENT::foundChannel, TDC_EVAL_EVENT::indexSlowMuon, LE_POSITRON_EVENT, M2_EVENT, masterChannelSlowMuon, MASTERFIRST, MASTERLAST, VME_STATS::mcp2_clean, MCP2F, MCP2R, MCP2X1, MCP2X2, MCP2Y1, MCP2Y2, N_TDC_CHANNELS, NEW_EVENT_MASK, nextGoodTime, p_write, POSBDI, POSBDO, POSBUI, POSBUO, POSLDI, POSLDO, POSLUI, POSLUO, POSRDI, POSRDO, POSRUI, POSRUO, POSTDI, POSTDO, POSTUI, POSTUO, runTime, VME_STATS::slowMuonEvents, TD, VME_STATS::td_clean, TD_EVENT, TDC_EVAL_EVENT::tdc_data, tdc_eval_event, TDC_EVAL_EVENT::tdc_event, TRIGGER_SETTINGS::tof_bc_pileup_window, TRIGGER_SETTINGS::tof_bc_window, TRIGGER_SETTINGS::tof_m2_window, trigger_settings, and vme_stats.
Referenced by frontend_loop().
INT frontend_exit | ( | ) |
Definition at line 557 of file vme_fe.c.
References databuffer, flag_scaler_address_0, flag_scaler_address_1, hdev, SIS3820_ADDRESS_0, SIS3820_ADDRESS_1, and sis3820_key_reset().
INT frontend_init | ( | ) |
create hot links to ODB structures
to save selected slow control parameter
Definition at line 416 of file vme_fe.c.
References beamline_event, BEAMLINE_EVENT_STR, BEAMLINE_SETTINGS_STR, databuffer, DATABUFFER_SIZE, eventDefinedFastMuon, eventDefinedSlowMuon, EXP_PARAM_STR, flag_external_on, flag_on_puls, flag_scaler_address_0, flag_scaler_address_1, hDB, hdev, HV_DETECTORS_EVENT_STR, HV_DETECTORS_SETTINGS_STR, hv_event, HV_EVENT_STR, HV_SETTINGS_STR, hvdet_event, info, init_sis3820(), init_v1190(), lemvac_event, LEMVAC_EVENT_STR, LEMVAC_SETTINGS_STR, MODCRYO_EVENT_STR, MODCRYO_SETTINGS_STR, moddy_event, omega_event, p_read, p_write, runinfo, sample_event, SAMPLECRYO_EVENT_STR, SAMPLECRYO_SETTINGS_STR, SCALER_SETTINGS_STR, scs2001m_event, SCS2001M_EVENT_STR, SCS2001M_SETTINGS_STR, SIS3820_ADDRESS_0, SIS3820_ADDRESS_1, tdc_eval_event, tdc_pileup, trigger_settings, TRIGGER_SETTINGS_STR, tvLastTime, V1190_ADDRESS, vme_stats, and VME_STATS_STR.
INT frontend_loop | ( | ) |
frontend_loop() is called whenever the frontend is idle or once between every event if the variable frontend_call_loop = true in the frontend code. This means that the frontend has to be re-compiled if one wants to use frontend_loop().
It performs the readout of the V1190 TDC and builds the events to be sent in read_trigger_event();
A 10kHz clock is used to check if hits belong to one TDC cycle of 100musec. Events may look like
1-1-1-4-1-1 = clock-clock-clock-TD-clock-clock –> no valid events 1-4-4-1-1 = clock-TD-TD-clock-clock –> no valid event 1-26-27-30-29-28-31-1 = clock-M2F-M2R-Y1-X2-X1-Y2 –> no valid event, TD missing 4-26-27-28-29-30-31-1 –> valid event 4-4-26-27-28-29-30-31-1 –> valid event 4-26-27-28-29-30-31-26-27-28-29-30-31-4 –> valid event, pileup times are sent with data buffer
Read complete TDC output buffer of 32k events. At low rates a VME bus error (return code = 0x211) indicates the end of data. This stops reading data from the TDC. At high rates (MHz) this does not work anymore since there are always data present in the output buffer. In this case a TDC TDC error may occur (bit 29 is set) that can be used to tag the start of new data.
Definition at line 949 of file vme_fe.c.
References VME_STATS::bc_clean, BC_EVENT, TRIGGER_SETTINGS::bc_rate, BCL1, BCL2, BCL3, BCL4, BCR1, BCR2, BCR3, BCR4, BINNING, V1190_DATA::buffer, V1190_DATA::channel, VME_STATS::channelCounts, CLOCK, TDC_EVAL_EVENT::clockIndex, V1190_DATA::data, dataWindowFastMuon, dataWindowSlowMuon, TRIGGER_SETTINGS::delay_daq_usec_, do_channel(), do_master_channel(), TDC_EVAL_EVENT::doEvaluateFastMuonEvent, TDC_EVAL_EVENT::doEvaluateSlowMuonEvent, TRIGGER_SETTINGS::enable_onoff_mode, TDC_PILEUP::endBeamCounterEvent, evaluate_fast_muon_event(), evaluate_slow_muon_event(), TRIGGER_SETTINGS::event_0_settings, EVENT_0_TYPE, TRIGGER_SETTINGS::event_1_active, TRIGGER_SETTINGS::event_1_settings, EVENT_1_TYPE, TRIGGER_SETTINGS::event_2_active, TRIGGER_SETTINGS::event_2_settings, EVENT_2_TYPE, TDC_EVAL_EVENT::event_time, eventDefinedFastMuon, eventDefinedSlowMuon, TRIGGER_SETTINGS::events, EXTOFF1, EXTON1, flag_external_on, TDC_EVAL_EVENT::foundChannel, VME_STATS::frontend_loop_counts, VME_STATS::frontend_loop_readtdc, hdev, VME_STATS::last_TDCtime, TDC_PILEUP::lastBeamCounterEventPileup, TDC_EVAL_EVENT::lastTimeFastMuon, TDC_EVAL_EVENT::lastTimeSlowMuon, LE_POSITRON_EVENT, M1_EVENT, M1_POSITRON_EVENT, M2_EVENT, TRIGGER_SETTINGS::master_delay, masterChannelFastMuon, masterChannelSlowMuon, MAX_NUMBER_LWORDS, MCP1, TRIGGER_SETTINGS::mcp1_delay, TRIGGER_SETTINGS::mcp1_rate, MCP2F, MCP2R, MCP2X1, MCP2X2, MCP2Y1, MCP2Y2, N_HITS, nextGoodTime, OnOff_mode(), TDC_EVAL_EVENT::pileup, pileup_end(), POSBDI, POSBDO, POSBUI, POSBUO, TRIGGER_SETTINGS::positron_delay, POSLDI, POSLDO, POSLUI, POSLUO, POSMCP1I, POSMCP1O, POSRDI, POSRDO, POSRUI, POSRUO, POSTDI, POSTDO, POSTUI, POSTUO, rate, VME_STATS::run_time, runinfo, runTime, TRIGGER_SETTINGS::simulation_flag, t0_offset, TD, TRIGGER_SETTINGS::td_delay, TD_EVENT, TDC_BIT_RANGE, VME_STATS::tdc_error_counts, tdc_eval_event, TDC_EVAL_EVENT::tdc_event, tdc_pileup, TDC_EVAL_EVENT::thisTimeFastMuon, TDC_EVAL_EVENT::thisTimeSlowMuon, TRIGGER_SETTINGS::tof_bc_pileup_window, trigger_settings, V1190_ADDRESS, V1190_ALMFULL_BIT, V1190_OUTPUT_BUFFER_SIZE, V1190_STATUS_REGISTER, and vme_stats.
int init_sis3820 | ( | u_int32_t | module_address | ) |
init_sis3820 is called during frontend_init for hardware initialization.
Return:
Definition at line 2452 of file vme_fe.c.
References hdev, mode, sis3820_control_read(), sis3820_key_enable(), sis3820_key_reset(), sis3820_modid_read(), and sis3820_operation_mode_read().
Referenced by frontend_init().
int init_v1190 | ( | u_int32_t | module_address | ) |
Definition at line 2503 of file vme_fe.c.
References ALMOST_FULL_LEVEL, hdev, TRIGGER_SETTINGS::tdc_disable_atstartup, trigger_settings, V1190_ALMOST_FULL_LEVEL, V1190_CONT_STOR, V1190_CONTROL_REGISTER, V1190_DISABLE_ALL_CHANNEL, V1190_EDGE_LEADING_MODE, V1190_LSB_200PS, V1190_MODULE_RESET, V1190_OPCODE_ADDRESS, V1190_SET_DETECTION, V1190_SET_TR_LEAD_LSB, and V1190_STATUS_REGISTER.
Referenced by frontend_init().
INT interrupt_configure | ( | INT | cmd, |
INT | source, | ||
PTYPE | adr | ||
) |
void OnOff_mode | ( | ) |
Definition at line 2593 of file vme_fe.c.
References TRIGGER_SETTINGS::delay_offpuls_usec_, flag_on_puls, hdev, TRIGGER_SETTINGS::period_onpuls_usec_, trigger_settings, and tvLastTime.
Referenced by frontend_loop().
U_LONG pileup_end | ( | INT | pileupWindow | ) |
calculate the end of pileup gate in absolute run time (in TDC LSB units)
Definition at line 1474 of file vme_fe.c.
References runTime.
Referenced by do_master_channel(), and frontend_loop().
INT poll_event | ( | INT | source, |
INT | count, | ||
BOOL | test | ||
) |
INT read_scaler_event | ( | char * | pevent, |
INT | off | ||
) |
Read out of scaler modules.
If HAVE_TEST_RUN is defined scaler entries of about 100 are thrown. If not defined use the function sis3820_read_scaler to read out the VME scaler module.
Return:
Definition at line 2220 of file vme_fe.c.
References A32BLT32, flag_scaler_address_0, flag_scaler_address_1, hdev, SCALER_SETTINGS::input_mode_3, N_SCALER, N_SCALER_MODULE, scaler_settings, SIS3820_ADDRESS_0, SIS3820_ADDRESS_1, and sis3820_scaler_read().
INT read_slowcontrol_event | ( | char * | pevent, |
INT | off | ||
) |
Read slow control parameters from ODB.
Definition at line 2292 of file vme_fe.c.
References beamline_event, BEAMLINE_EVENT::demand, hv_event, hvdet_event, info, MODCRYO_EVENT::input, SAMPLECRYO_EVENT::input, LEMVAC_EVENT::input, SCS2001M_EVENT::input, OMEGA_EVENT::input, lemvac_event, BEAMLINE_EVENT::measured, HV_EVENT::measured, HV_DETECTORS_EVENT::measured, moddy_event, omega_event, INFO::sample_cryo, sample_event, and scs2001m_event.
INT read_trigger_event | ( | char * | pevent, |
INT | off | ||
) |
read_trigger_event() is the event read out function to get the V1190 TDC data.
Definition at line 2141 of file vme_fe.c.
References databuffer, DATABUFFER_SIZE, NEW_EVENT_MASK, p_read, VME_STATS::readcounts, and vme_stats.
INT resume_run | ( | INT | run_number, |
char * | error | ||
) |
Definition at line 893 of file vme_fe.c.
References flag_scaler_address_0, flag_scaler_address_1, hdev, SIS3820_ADDRESS_0, SIS3820_ADDRESS_1, sis3820_key_disable(), sis3820_key_enable(), sis3820_key_reset(), V1190_ADDRESS, and V1190_SOFTWARE_CLEAR.
void scaler_mode | ( | u_int32_t | module_address | ) |
scaler_mode is called at begin_of_run. It reads the ODB record /Equipment/Scaler/Settings and checks if the variable scaler_settings.input_mode_3 is set. If yes the SIS3820 will be set to
SIS3820_CONTROL_INPUT_MODE3 + SIS3820_SCALER_DATA_FORMAT_24BIT
otherwise it will be set to
SIS3820_CONTROL_INPUT_MODE0 + SIS3820_SCALER_DATA_FORMAT_32BIT
No interrupt handling at the moment.
Definition at line 2383 of file vme_fe.c.
References CTRL_REFERENCE_CH1_DISABLE, CTRL_REFERENCE_CH1_ENABLE, hDB, hdev, SCALER_SETTINGS::input_mode_3, SCALER_SETTINGS::reference_ch1, scaler_settings, SIS3820_CONTROL_INPUT_MODE0, SIS3820_CONTROL_INPUT_MODE3, sis3820_control_read(), sis3820_control_write(), sis3820_operation_mode_read(), sis3820_operation_mode_write(), SIS3820_SCALER_DATA_FORMAT_24BIT, and SIS3820_SCALER_DATA_FORMAT_32BIT.
Referenced by begin_of_run().
BEAMLINE_EVENT beamline_event |
for slow control parameters
Definition at line 196 of file vme_fe.c.
Referenced by frontend_init(), and read_slowcontrol_event().
|
static |
ring buffer for TDC data
Definition at line 270 of file vme_fe.c.
Referenced by begin_of_run(), evaluate_fast_muon_event(), evaluate_slow_muon_event(), frontend_exit(), frontend_init(), and read_trigger_event().
|
static |
Definition at line 279 of file vme_fe.c.
Referenced by begin_of_run(), do_master_channel(), and frontend_loop().
|
static |
Definition at line 279 of file vme_fe.c.
Referenced by begin_of_run(), do_master_channel(), and frontend_loop().
INT display_period = 3000 |
INT event_buffer_size = 60*10000 |
|
static |
bit pattern containing trigger mode for fast muons (BC-M1)
Definition at line 274 of file vme_fe.c.
Referenced by begin_of_run(), do_master_channel(), evaluate_fast_muon_event(), frontend_init(), and frontend_loop().
|
static |
bit pattern containing trigger mode for slow muons (BC-TD-M2)
Definition at line 273 of file vme_fe.c.
Referenced by begin_of_run(), do_master_channel(), evaluate_slow_muon_event(), frontend_init(), and frontend_loop().
|
static |
flag to indicate "on/off", "red/green" mode
Definition at line 281 of file vme_fe.c.
Referenced by begin_of_run(), evaluate_slow_muon_event(), frontend_init(), and frontend_loop().
|
static |
flag to indicate that "puls" was turned on, "on/off" or "red/green" mode
Definition at line 285 of file vme_fe.c.
Referenced by begin_of_run(), frontend_init(), and OnOff_mode().
|
static |
Definition at line 282 of file vme_fe.c.
Referenced by begin_of_run(), frontend_exit(), frontend_init(), read_scaler_event(), and resume_run().
|
static |
flags to indicate status of VME scalers
Definition at line 282 of file vme_fe.c.
Referenced by begin_of_run(), frontend_exit(), frontend_init(), read_scaler_event(), and resume_run().
BOOL frontend_call_loop = TRUE |
char* frontend_file_name = __FILE__ |
char* frontend_name = "VME_FE" |
|
static |
handle for VME-PCI device
Definition at line 269 of file vme_fe.c.
Referenced by begin_of_run(), end_of_run(), frontend_exit(), frontend_init(), frontend_loop(), init_sis3820(), init_v1190(), OnOff_mode(), read_scaler_event(), resume_run(), and scaler_mode().
HV_EVENT hv_event |
Definition at line 201 of file vme_fe.c.
Referenced by analyzer_init(), frontend_init(), get_t0(), get_t0L3RA(), read_slowcontrol_event(), set_spin_rot_angle(), and update_info().
HV_SETTINGS hv_settings |
HV_DETECTORS_EVENT hvdet_event |
Definition at line 202 of file vme_fe.c.
Referenced by frontend_init(), and read_slowcontrol_event().
INFO info |
Definition at line 206 of file vme_fe.c.
Referenced by ana_end_of_run(), analyzer_init(), bh_flow_in(), bh_flow_out(), bh_in_init(), bh_out_init(), bruker_in(), bruker_in_init(), bruker_out(), bruker_out_init(), danfysik_in(), danfysik_in_init(), danfysik_out(), danfysik_out_init(), energy_loss(), frontend_init(), get_magnetic_field(), get_t0(), get_t0L3RA(), hv_fug(), hv_fug_init(), hv_nhq_20xm_mscb(), hv_nhq_20xm_mscb_init(), hvr400(), hvr400_init(), lem_epics(), lemplug(), lemplug_init(), lemvac_in(), lemvac_out(), ls340_cryo_name_changed(), ls340_in(), ls340_in_init(), ls340_out(), ls340_out_init(), mirror(), mirror_init(), open_odb_records(), ps64_in(), ps64_out(), psi_epics_init(), read_slowcontrol_event(), scs400_in(), scs400_in_init(), scs400_out(), scs400_out_init(), scs900_in(), scs900_in_init(), scs900_out(), scs900_out_init(), sep61vac(), set_spin_rot_angle(), SM_in(), sm_in_init(), SM_out(), sm_out_init(), twickenham(), twickenham_init(), update_info(), update_run_header(), update_t0shift(), w6100_in(), w6100_in_init(), w6100_out(), w6100_out_init(), xtc(), and xtc_init().
LEMVAC_EVENT lemvac_event |
Definition at line 197 of file vme_fe.c.
Referenced by frontend_init(), and read_slowcontrol_event().
|
static |
"master" TDC channel for BC-M1 (usually M1)
Definition at line 276 of file vme_fe.c.
Referenced by begin_of_run(), evaluate_fast_muon_event(), and frontend_loop().
|
static |
"master" TDC channel for slow muons (TD or M2)
Definition at line 275 of file vme_fe.c.
Referenced by begin_of_run(), evaluate_slow_muon_event(), and frontend_loop().
|
static |
use either TD_EVENT or M2_EVENT as slow muon master
Definition at line 272 of file vme_fe.c.
Referenced by begin_of_run().
INT max_event_size = 128000 |
INT max_event_size_frag = 5*1024*1024 |
MODCRYO_EVENT moddy_event |
Definition at line 198 of file vme_fe.c.
Referenced by frontend_init(), and read_slowcontrol_event().
INT mode |
scaler mode, see scaler_mode()
Definition at line 283 of file vme_fe.c.
Referenced by init_sis3820().
|
static |
absolute run time when new events are accepted (for on/off mode)
Definition at line 278 of file vme_fe.c.
Referenced by begin_of_run(), evaluate_slow_muon_event(), and frontend_loop().
OMEGA_EVENT omega_event |
Definition at line 205 of file vme_fe.c.
Referenced by frontend_init(), and read_slowcontrol_event().
|
static |
Definition at line 271 of file vme_fe.c.
Referenced by begin_of_run(), end_of_run(), frontend_init(), poll_event(), and read_trigger_event().
|
static |
read and write pointers for data ring buffer
Definition at line 271 of file vme_fe.c.
Referenced by begin_of_run(), end_of_run(), evaluate_fast_muon_event(), evaluate_slow_muon_event(), frontend_init(), and poll_event().
RUNINFO runinfo |
/Runinfo ODB key, defined in from midas.h
Not defined in experim.h:
Definition at line 193 of file vme_fe.c.
Referenced by ana_begin_of_run(), ana_end_of_run(), ana_pause_run(), ana_resume_run(), analyzer_init(), analyzer_loop(), decay_bor(), decay_init(), disp_scaler(), frontend_init(), frontend_loop(), get_sum_filename(), mcp1_init(), pileup_init(), sc_eor(), scaler_sum(), tof_bor(), tof_init(), update_run_header(), and write_histogram_file().
|
static |
absolute run time in TDC LSB units
Definition at line 277 of file vme_fe.c.
Referenced by begin_of_run(), do_channel(), do_master_channel(), evaluate_slow_muon_event(), frontend_loop(), and pileup_end().
SAMPLECRYO_EVENT sample_event |
Definition at line 199 of file vme_fe.c.
Referenced by frontend_init(), and read_slowcontrol_event().
SCALER_SETTINGS scaler_settings |
/Equipment/Scaler/Settings/
Definition at line 189 of file vme_fe.c.
Referenced by analyzer_init(), read_scaler_event(), and scaler_mode().
SCS2001M_EVENT scs2001m_event |
Definition at line 200 of file vme_fe.c.
Referenced by analyzer_init(), frontend_init(), read_slowcontrol_event(), and update_info().
|
static |
Definition at line 280 of file vme_fe.c.
Referenced by begin_of_run(), do_channel(), and frontend_loop().
|
static |
Definition at line 267 of file vme_fe.c.
Referenced by begin_of_run(), check_positron(), check_tof_and_pileup(), do_channel(), do_master_channel(), evaluate_fast_muon_event(), evaluate_slow_muon_event(), frontend_init(), and frontend_loop().
|
static |
Definition at line 268 of file vme_fe.c.
Referenced by begin_of_run(), do_master_channel(), frontend_init(), and frontend_loop().
TRIGGER_SETTINGS trigger_settings |
/Equipment/Trigger/Settings
The following structures are defined in experim.h that is created by entering 'make' in ODBedit.
ODB record values can be easily accessed by db_open_record which creates a hot-link to the structure; structure_name.keyvalue
Definition at line 188 of file vme_fe.c.
Referenced by analyzer_init(), begin_of_run(), end_of_run(), evaluate_fast_muon_event(), evaluate_slow_muon_event(), frontend_init(), frontend_loop(), init_v1190(), and OnOff_mode().
|
static |
Definition at line 284 of file vme_fe.c.
Referenced by frontend_init(), and OnOff_mode().
|
static |
Definition at line 266 of file vme_fe.c.
Referenced by begin_of_run(), do_channel(), do_master_channel(), end_of_run(), evaluate_fast_muon_event(), evaluate_slow_muon_event(), frontend_init(), frontend_loop(), poll_event(), and read_trigger_event().