test_indep.cpp is done compare speed for 2 readout method
This commit is contained in:
parent
eef989aa54
commit
27576d301d
232
test_indep.cpp
232
test_indep.cpp
|
@ -4,10 +4,129 @@
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <time.h> // time in nano-sec
|
||||||
|
|
||||||
|
void RawDecorder(uint8_t * data, size_t size, int verbose = 0){
|
||||||
|
uint64_t haha ;
|
||||||
|
unsigned short dataType;
|
||||||
|
|
||||||
|
int word = 0;
|
||||||
|
int traceWord = -2;
|
||||||
|
for( int i =0 ; i < ((int)size / 8) ; i++){
|
||||||
|
|
||||||
|
///the data is array of 1 byte.
|
||||||
|
/// by get the point of the data[8*i]
|
||||||
|
/// cast it into uint64_t pointer, that will get 8 bytes all togteher
|
||||||
|
/// get this point value, and bit swap it.
|
||||||
|
haha = __builtin_bswap64(*(uint64_t *)&(data[8*i]));
|
||||||
|
if (verbose > 0 ) printf("%7d | %3d | %3d | 0x%016lX \n", i, word, traceWord, haha);
|
||||||
|
|
||||||
|
if ( word == 0 ){ /// aggregation header, or start header, or end header
|
||||||
|
dataType = ( haha >> 56 ) & 0xFF ;
|
||||||
|
if ( verbose> 0 & dataType == 0x30 ) printf("====== start Run data\n");
|
||||||
|
if ( verbose> 0 & dataType == 0x32 ) printf("====== Stop Run data\n");
|
||||||
|
if ( verbose> 0 & (dataType >> 4) == 0x2 ) printf("====== data aggregation start\n");
|
||||||
|
}else{
|
||||||
|
|
||||||
|
|
||||||
|
if( dataType == 0x30 ){
|
||||||
|
if( word == 1){
|
||||||
|
if( (haha & 0xFFFFFFFF) != 0x2000000) printf("*** something wrong.\n");
|
||||||
|
}
|
||||||
|
uint64_t channelMask;
|
||||||
|
if( word == 2){
|
||||||
|
channelMask = ( haha & 0xFFFFFFFF );
|
||||||
|
}
|
||||||
|
if( word == 3){
|
||||||
|
channelMask += (( haha & 0xFFFFFFFF ) << 32);
|
||||||
|
if (verbose > 0 ) printf("Channel mask : 0x%016lX\n", channelMask);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if( (dataType >> 4 ) == 0x2 ) {
|
||||||
|
unsigned short chID ;
|
||||||
|
uint64_t timestamp ;
|
||||||
|
bool hasTrace;
|
||||||
|
unsigned short fl ; // flag low
|
||||||
|
unsigned short fh ; // flog hight
|
||||||
|
unsigned short energy ;
|
||||||
|
unsigned short fTime ;
|
||||||
|
|
||||||
|
unsigned short traceLength;
|
||||||
|
|
||||||
|
unsigned short anaProb0[512];
|
||||||
|
unsigned short anaProb1[512];
|
||||||
|
bool digProb0[512];
|
||||||
|
bool digProb1[512];
|
||||||
|
bool digProb2[512];
|
||||||
|
bool digProb3[512];
|
||||||
|
|
||||||
|
if( word == 1){
|
||||||
|
chID = ((haha >> 56) & 0x7F);
|
||||||
|
timestamp = (haha & 0xFFFFFFFFFFFF);
|
||||||
|
}else if( word == 2){
|
||||||
|
hasTrace = ((haha >> 62) & 0x1);
|
||||||
|
fl = (( haha >> 50) & 0x1FFF);
|
||||||
|
fh = (( haha >> 41) & 0xFF);
|
||||||
|
energy = (haha & 0xFFFF);
|
||||||
|
fTime = ((haha >> 15) & 0x7FF);
|
||||||
|
}else{
|
||||||
|
if( ((haha >> 63) & 0x1 ) == 1 && traceWord == -2) {
|
||||||
|
//printf("=====last word of header\n");
|
||||||
|
traceWord = 0;
|
||||||
|
|
||||||
|
if (verbose > 0 ) printf("ch %2d, energy %5u, time %10lu, fTime %5u %10.2f ms 0x%X, 0x%X, %u\n",
|
||||||
|
chID, energy, timestamp, fTime, (timestamp*8 + fTime*0.0078125) / 1e+6 , fl, fh, hasTrace);
|
||||||
|
|
||||||
|
word ++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( hasTrace) {
|
||||||
|
if( traceWord == 0) {
|
||||||
|
traceLength = (haha & 0xFFF );
|
||||||
|
word ++;
|
||||||
|
traceWord ++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( traceWord > 0 ){
|
||||||
|
anaProb0[traceWord-1] = (haha & 0x3FFF);
|
||||||
|
anaProb1[traceWord-1] = ((haha >> 16) & 0x3FFF);
|
||||||
|
digProb0[traceWord-1] = ((haha >> 14) & 0x1);
|
||||||
|
digProb1[traceWord-1] = ((haha >> 15) & 0x1);
|
||||||
|
digProb2[traceWord-1] = ((haha >> 30) & 0x1);
|
||||||
|
digProb3[traceWord-1] = ((haha >> 31) & 0x1);
|
||||||
|
|
||||||
|
traceWord ++;
|
||||||
|
|
||||||
|
if( traceWord - 1 == traceLength ){
|
||||||
|
//printf("============= end of one data, traceLength = %d\n", traceLength);
|
||||||
|
word = 0;
|
||||||
|
traceWord = -2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
word++;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
|
timespec t0, t1, t2;
|
||||||
|
|
||||||
//#################################### Open digitizer
|
//#################################### Open digitizer
|
||||||
uint64_t dev_handle;
|
uint64_t dev_handle;
|
||||||
|
@ -31,20 +150,20 @@ int main(){
|
||||||
|
|
||||||
/// Global trigger configuration
|
/// Global trigger configuration
|
||||||
ret = CAEN_FELib_SetValue(dev_handle, "/par/GlobalTriggerSource", "SwTrg | TestPulse"); // use test Pulse
|
ret = CAEN_FELib_SetValue(dev_handle, "/par/GlobalTriggerSource", "SwTrg | TestPulse"); // use test Pulse
|
||||||
ret = CAEN_FELib_SetValue(dev_handle, "/par/TestPulsePeriod", "100000000"); /// ns
|
ret = CAEN_FELib_SetValue(dev_handle, "/par/TestPulsePeriod", "1000000"); /// ns, 1 msec
|
||||||
ret = CAEN_FELib_SetValue(dev_handle, "/par/TestPulseWidth", "16"); ///ns
|
ret = CAEN_FELib_SetValue(dev_handle, "/par/TestPulseWidth", "16"); ///ns
|
||||||
|
|
||||||
/// Wave configuration
|
/// Wave configuration
|
||||||
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/ChRecordLengthS", "512");
|
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/ChRecordLengthS", "512"); // when setting sample, the ChRecordLengthT will not set. vice versa
|
||||||
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/WaveTriggerSource", "GlobalTriggerSource");
|
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/WaveTriggerSource", "GlobalTriggerSource");
|
||||||
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/WaveResolution", "RES8");
|
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/WaveResolution", "RES8"); // 8 ns
|
||||||
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/WaveAnalogProbe0", "ADCInput");
|
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/WaveAnalogProbe0", "ADCInput");
|
||||||
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/WaveAnalogProbe1", "TimeFilter");
|
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/WaveAnalogProbe1", "TimeFilter");
|
||||||
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/WaveDigitalProbe0", "Trigger");
|
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/WaveDigitalProbe0", "Trigger");
|
||||||
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/WaveDigitalProbe1", "TimeFilterArmed");
|
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/WaveDigitalProbe1", "TimeFilterArmed");
|
||||||
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/WaveDigitalProbe2", "EnergyFilterBaselineFreeze");
|
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/WaveDigitalProbe2", "EnergyFilterBaselineFreeze");
|
||||||
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/WaveDigitalProbe3", "EnergyFilterPeakReady");
|
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/WaveDigitalProbe3", "EnergyFilterPeakReady");
|
||||||
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/ChPreTriggerS", "200");
|
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/ChPreTriggerS", "100");
|
||||||
|
|
||||||
/// Event configuration
|
/// Event configuration
|
||||||
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/EventTriggerSource", "GlobalTriggerSource");
|
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/EventTriggerSource", "GlobalTriggerSource");
|
||||||
|
@ -65,8 +184,17 @@ int main(){
|
||||||
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/EnergyFilterFineGain", "1.0");
|
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/EnergyFilterFineGain", "1.0");
|
||||||
|
|
||||||
|
|
||||||
//#################################### Set the end point for data
|
if( ret != CAEN_FELib_Success) printf("errro in set value\n");
|
||||||
|
|
||||||
|
//#################################### setting readout
|
||||||
|
ret = CAEN_FELib_GetValue(dev_handle, "/ch/10/par/ChRecordLengthS", value);
|
||||||
|
if( ret != CAEN_FELib_Success) printf("errro in get value\n");
|
||||||
|
|
||||||
|
|
||||||
|
printf("trace length : %s sample\n", value);
|
||||||
|
|
||||||
|
//#################################### Set the end point for data
|
||||||
|
/*
|
||||||
{//----------------------- RAW
|
{//----------------------- RAW
|
||||||
uint64_t ep_handle;
|
uint64_t ep_handle;
|
||||||
ret = CAEN_FELib_GetHandle(dev_handle, "/endpoint/raw", &ep_handle);
|
ret = CAEN_FELib_GetHandle(dev_handle, "/endpoint/raw", &ep_handle);
|
||||||
|
@ -85,7 +213,7 @@ int main(){
|
||||||
);
|
);
|
||||||
|
|
||||||
uint8_t* data = new uint8_t[200000];
|
uint8_t* data = new uint8_t[200000];
|
||||||
size_t size; /// number of byte of the data
|
size_t size; /// number of byte of the data, size/8 = word [64 bits]
|
||||||
uint32_t n_events;
|
uint32_t n_events;
|
||||||
|
|
||||||
printf("Starting ACQ\n");
|
printf("Starting ACQ\n");
|
||||||
|
@ -93,70 +221,25 @@ int main(){
|
||||||
ret = CAEN_FELib_SendCommand(dev_handle, "/cmd/swstartacquisition");
|
ret = CAEN_FELib_SendCommand(dev_handle, "/cmd/swstartacquisition");
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for( int i = 0; i < 2; i++){
|
|
||||||
|
for( int i = 0; i < 10; i++){
|
||||||
|
|
||||||
usleep(10000);
|
//usleep(1000000);
|
||||||
|
clock_gettime(CLOCK_REALTIME, &t0);
|
||||||
|
|
||||||
ret = CAEN_FELib_ReadData(ep_handle, 100, data, &size, &n_events );
|
ret = CAEN_FELib_ReadData(ep_handle, 100, data, &size, &n_events );
|
||||||
count ++;
|
count ++;
|
||||||
|
clock_gettime(CLOCK_REALTIME, &t1);
|
||||||
|
|
||||||
if( ret == CAEN_FELib_Success ) {
|
if( ret == CAEN_FELib_Success ) {
|
||||||
printf("================= %u, %ld, %d \n", n_events, size, count);
|
printf("================= %u, %ld byte, %d \n", n_events, size, count);
|
||||||
|
|
||||||
uint64_t haha ;
|
RawDecorder(data, size);
|
||||||
unsigned short dataType;
|
clock_gettime(CLOCK_REALTIME, &t2);
|
||||||
|
printf("t2-t1 : %ld\n", t2.tv_nsec-t1.tv_nsec);
|
||||||
int word = 0;
|
|
||||||
for( int i =0 ; i < std::min((int)size / 8, 100) ; i++){
|
|
||||||
|
|
||||||
///the data is array of 1 byte.
|
|
||||||
/// by get the point of the data[8*i]
|
|
||||||
/// cast it into uint64_t pointer, that will get 8 bytes all togteher
|
|
||||||
/// get this point value, and bit swap it.
|
|
||||||
haha = __builtin_bswap64(*(uint64_t *)&(data[8*i]));
|
|
||||||
printf("%7d | 0x%016lX \n", i, haha);
|
|
||||||
|
|
||||||
|
|
||||||
if ( word == 0 ){ /// aggregation header, or start header, or end header
|
|
||||||
dataType = ( haha >> 55 ) & 0xFF ;
|
|
||||||
if ( dataType == 0x30 ){ /// start Run data
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( dataType == 0x32 ){ /// stop Run data
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( (dataType >> 4) == 0x2 ){ /// data aggregation
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( word == 1 ){
|
|
||||||
unsigned short channel = ((haha >> 56) & 0x7F);
|
|
||||||
unsigned short SE = ((haha >> 55) & 0x1);
|
|
||||||
uint64_t timestamp = (haha & 0xFFFFFFFFFFFF);
|
|
||||||
printf("ch %u, SE %u, %llu \n", channel, SE, timestamp);
|
|
||||||
}
|
|
||||||
if ( word == 2 ){
|
|
||||||
unsigned short W = ((haha >> 62) & 0x1);
|
|
||||||
unsigned short fl = (( haha >> 50) & 0x1FFF);
|
|
||||||
unsigned short fh = (( haha >> 41) & 0xFF);
|
|
||||||
unsigned short energy = (haha & 0xFFFF);
|
|
||||||
unsigned short fTime = ((haha >> 15) & 7FF);
|
|
||||||
|
|
||||||
printf("energy %u, fTiem %u, fl %u, fh %u, W %u\n", energy, fTime, fl, fh, W);
|
|
||||||
|
|
||||||
}*/
|
|
||||||
|
|
||||||
word++;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
printf("t1-t0 : %ld\n", t1.tv_nsec-t0.tv_nsec);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,8 +247,8 @@ int main(){
|
||||||
ret = CAEN_FELib_SendCommand(dev_handle, "/cmd/disarmacquisition");
|
ret = CAEN_FELib_SendCommand(dev_handle, "/cmd/disarmacquisition");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/**/
|
||||||
|
|
||||||
/**
|
|
||||||
{//------------------------ DPPPHA
|
{//------------------------ DPPPHA
|
||||||
uint64_t ep_handle;
|
uint64_t ep_handle;
|
||||||
ret = CAEN_FELib_GetHandle(dev_handle, "/endpoint/dpppha", &ep_handle);
|
ret = CAEN_FELib_GetHandle(dev_handle, "/endpoint/dpppha", &ep_handle);
|
||||||
|
@ -231,11 +314,14 @@ int main(){
|
||||||
ret = CAEN_FELib_SendCommand(dev_handle, "/cmd/armacquisition");
|
ret = CAEN_FELib_SendCommand(dev_handle, "/cmd/armacquisition");
|
||||||
ret = CAEN_FELib_SendCommand(dev_handle, "/cmd/swstartacquisition");
|
ret = CAEN_FELib_SendCommand(dev_handle, "/cmd/swstartacquisition");
|
||||||
|
|
||||||
|
timespec tsum;
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for( int i = 0; i < 10; i++){
|
for( int i = 0; i < 64*5; i++){
|
||||||
|
|
||||||
usleep(10000);
|
//usleep(10000);
|
||||||
|
|
||||||
|
clock_gettime(CLOCK_REALTIME, &t0);
|
||||||
ret = CAEN_FELib_ReadData(ep_handle, 100,
|
ret = CAEN_FELib_ReadData(ep_handle, 100,
|
||||||
&channel,
|
&channel,
|
||||||
×tamp,
|
×tamp,
|
||||||
|
@ -259,6 +345,18 @@ int main(){
|
||||||
&event_size
|
&event_size
|
||||||
);
|
);
|
||||||
count ++;
|
count ++;
|
||||||
|
|
||||||
|
clock_gettime(CLOCK_REALTIME, &t1);
|
||||||
|
printf("%3d | t1-t0 : %ld\n", i, t1.tv_nsec-t0.tv_nsec);
|
||||||
|
|
||||||
|
tsum.tv_nsec += t1.tv_nsec-t0.tv_nsec;
|
||||||
|
|
||||||
|
if( channel == 63) {
|
||||||
|
printf("================###################=== tsum : %ld\n", tsum.tv_nsec);
|
||||||
|
tsum.tv_nsec = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
if( ret == CAEN_FELib_Success ) {
|
if( ret == CAEN_FELib_Success ) {
|
||||||
printf("================= %ld, %d \n", event_size, count);
|
printf("================= %ld, %d \n", event_size, count);
|
||||||
printf("ch : %u, energy : %u, time : %lu, fTime : %u \n", channel, energy, timestamp, fine_timestamp);
|
printf("ch : %u, energy : %u, time : %lu, fTime : %u \n", channel, energy, timestamp, fine_timestamp);
|
||||||
|
@ -280,7 +378,7 @@ int main(){
|
||||||
digital_probes[3][i]);
|
digital_probes[3][i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user