/************************************************************************* * * vme_list.c - Library of routines for readout and buffering of * events using a JLAB Trigger Interface V3 (TI) with * a Linux VME controller in CODA 3.0. * * This is for a CDC ADC125 crates controlled by a * trigger superviser * * Modified: Tue Apr 29 09:57:23 EDT 2014 B. Zihlmann * adaped for CDC readout using TS * */ /* Event Buffer definitions */ #define MAX_EVENT_POOL 10 #define MAX_EVENT_LENGTH 4096*1000 /* Size in Bytes: can not be more than 4MB*/ /* Define TI Type (TI_MASTER or TI_SLAVE) */ #define TI_SLAVE /* TS Fiber Link trigger source (from TI Master, TD, or TS), POLL for available data */ #define TI_READOUT TI_READOUT_TS_POLL /* TI VME address, or 0 for Auto Initialize (search for TI by slot) */ #define TI_ADDR (21<<19) /* Measured longest fiber length in system */ /*#define FIBER_LATENCY_OFFSET 0x3A */ #define FIBER_LATENCY_OFFSET 0xCA /* Define buffering level and block level */ /* should be done by setup procedure not hardcoded!*/ #define BUFFERLEVEL 1 #define BLOCKLEVEL 1 /*int blockLevel = BLOCKLEVEL;*/ /*int tsCrate=0;*/ #include "dmaBankTools.h" /* Macros for handling CODA banks */ #include "tiprimary_list.c" /* Source required for CODA readout lists using the TI */ #include "fa125Lib.h" extern unsigned int fa125AddrList[FA125_MAX_BOARDS]; extern int fa125A32Base; #include "ccdb_inc.h" /* include file for C++ API wrapper*/ /* private variables for the time being needed for hard coded stuff*/ int HOSTROC = 0; char hnam[128]; char str1[128]; char DETECTOR[128]; int NADCS = 0; int SLOT = 3; int SETDACVALUESCONST = 0; /* if set to 1 set all DAC valvues to 0x8000 */ /* CCDB DATABASE VARIABLES*/ int DAC_Values[20][72]; int Thresholds[20][72]; int FA125ReadOutMode; int FA125Latency; int FA125WindowSize; int FA125NSB; int FA125NSA; int FA125NP; int ERRORCounter = 0; int ERRORLOG = 100; int EventCounter = 0; /* NOTE THE FOLLOWING IS NEED TO DO SPARSIFICATION ON THE FLY ON THE ROC */ unsigned int new_array[325000]; /**************************************** * DOWNLOAD ****************************************/ void rocDownload() { int stat; int iFlag; int i,k,j; /* hard code numbers here for the time being*/ /* and code that I understand */ /* CONFIGURATION PARAMETERS FOR THE CRATE AND THE ADCS ARE CURRENTLY TAKEN FROM */ /* ONLINE_CCDB AS DAQ CONFIGURATiON SCHEEME IS STILL UNDER CONTRUCTION */ gethostname(hnam,128); strncpy(str1, &hnam[6], 128); HOSTROC = atoi(str1); strncpy(DETECTOR,&hnam[3],3); DETECTOR[3] = '\0'; /*GET DAC values from DATA base and number of ADCS in crate*/ NADCS = GetDACfromdatabase(HOSTROC, DETECTOR); /*if (HOSTROC==9){ //do not use the last 2 ADCs from rocfdc9 NADCS -= 2; } */ /* set DAC values to default constant value if requested*/ if (SETDACVALUESCONST){ set_DAC_Defaults(DETECTOR); } printf("NUMBER OF ADCS: %d\n",NADCS); /* printf("DAC Values:(ADC# CHAN# DAC)\n"); for (k=0;k