Skip to content

Commit

Permalink
2.25
Browse files Browse the repository at this point in the history
  • Loading branch information
W. Hennig authored and xia-stan committed Mar 7, 2023
1 parent 4d69dc0 commit 0434704
Show file tree
Hide file tree
Showing 24 changed files with 7,667 additions and 93 deletions.
8 changes: 8 additions & 0 deletions PixieNetConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -703,9 +703,17 @@ int init_PixieNetFippiConfig_from_file( const char * const filename,
if(ret==0)
for( int i = 0; i < NCHANNELS; ++i )
config->CHANNEL_CSRA[i] = SetOrClrBit(6, config->CHANNEL_CSRA[i], bits[i]);

ret = parse_multiple_bool_val( label_to_values, "CCSRA_NO_OVERLAP_08", bits, ignore_missing ) ;
if( (ignore_missing==0 && ret==1) || (ret<0) ) return -30;
if(ret==0)
for( int i = 0; i < NCHANNELS; ++i )
config->CHANNEL_CSRA[i] = SetOrClrBit(8, config->CHANNEL_CSRA[i], bits[i]);


ret = parse_multiple_bool_val( label_to_values, "CCSRA_NEGE_09", bits, ignore_missing) ;
if( (ignore_missing==0 && ret==1) || (ret<0) ) return -31;
if(ret==0)
for( int i = 0; i < NCHANNELS; ++i )
config->CHANNEL_CSRA[i] = SetOrClrBit(9, config->CHANNEL_CSRA[i], bits[i]);

Expand Down
2 changes: 1 addition & 1 deletion PixieNetConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ typedef struct PixieNetFippiConfig {
CCSRA_INVERT_05 1 if 1, ADC data is inverted before processing (for falling edge pulses)
CCSRA_VETO_REJLO_06 0 if 1, reject events when global Veto is low
CCSRA_U_07 0
CCSRA_U_08 0
CCSRA_NO_OVERLAP_08 1 if 1, do not capture overlapping waveforms (ignore closely following pulses)
CCSRA_NEGE_09 0 if 1, allow negative numbers as result of energy computation, NYI
CCSRA_U_10 0
CCSRA_U_11 0
Expand Down
4 changes: 2 additions & 2 deletions PixieNetDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*----------------------------------------------------------------------*/

// system constants
#define PS_CODE_VERSION 0x0224
#define PS_CODE_VERSION 0x0225
#define PN_BOARD_VERSION_12_250_A 0xA990
#define PN_BOARD_VERSION_12_250_B 0xA991
#define PN_BOARD_VERSION_12_250_B_PTP 0xA981
Expand All @@ -52,7 +52,7 @@
#define NTRACE_SAMPLES 8192
#define NAVG_TRACE_SAMPLES 4096
#define TWOTO32 4294967296
#define ICRSCALE 15 // factor between current iCR read and ICR in cps
#define ICRSCALE 15 // factor between current ICR read and ICR in cps

// Limits for settings
#define MIN_CW 5 // Coinc Window limits
Expand Down
104 changes: 81 additions & 23 deletions acquire.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*----------------------------------------------------------------------
/*----------------------------------------------------------------------
* Copyright (c) 2017 XIA LLC
* All rights reserved.
*
Expand Down Expand Up @@ -76,6 +76,7 @@ using namespace std;
#define PixieNetHit_RECORD_HIT_PSA 1 // optionally ignore PSA results
#define MAX_ACQ_TL 512 // set limit for waveforms length (abs max: 4092)
#define SUMMCA 1 //
#define MAX_QUEUED 100000


/* ********************************************************************************
Expand Down Expand Up @@ -148,10 +149,10 @@ typedef struct PixieNetHit402 {



/** A global variable that gets set to true if the ctrl-c interupt is detected.
/** A global variable that gets set to N>1 if the ctrl-c interupt is detected.
If this happens, the data collection loop is terminated, and everything else
exits as normal. */
boost::atomic<bool> g_datataking_stop_requested;
boost::atomic<size_t> g_datataking_stop_requested;


/** Writes listmode data in the queue to disk
Expand Down Expand Up @@ -198,7 +199,7 @@ void histogram_lm_data( uint32_t histogram[NCHANNELS+1][MAX_MCA_BINS],
unsigned int BINFACTOR[NCHANNELS] );


/** Sets g_datataking_stop_requested to true, which stops data taking so program
/** Sets g_datataking_stop_requested to N>0, which stops data taking so program
can exit. */
void handle_interupt( int s );

Expand Down Expand Up @@ -285,9 +286,11 @@ int main( int argc, char **argv )
int TL;
unsigned int BLbad[NCHANNELS];
unsigned int BLcut[NCHANNELS], BLavg[NCHANNELS];
long queued;
int pause_queue = 0;

//Set the handler for if the user hits ctrl-c
g_datataking_stop_requested = false;
g_datataking_stop_requested = 0;

struct sigaction sigIntHandler;
sigIntHandler.sa_handler = handle_interupt;
Expand Down Expand Up @@ -593,22 +596,47 @@ int main( int argc, char **argv )
// -----------poll for events -----------
// if data ready. read out, compute E, increment MCA *********
unsigned int nhits;
if( fippiconfig.RUN_TYPE == 0x402)
{
nhits = collect_PixieNet_lm_data402( mapped, hits, &runstats, &fippiconfig );
for( size_t i = 0; i < nhits; ++i ) // nhits = 0 to 4
if( !hit_queue.push( hits[i] ) )
cerr << "Failed to push onto queue" << endl;

// ensure we don't have too much of a backlog
size_t ntotalwrittennow = num_wrote;
queued = ((long)runstats.eventcount - (long)ntotalwrittennow);

} else {
nhits = collect_PixieNet_lm_data400( mapped, hits, &runstats, &fippiconfig );
for( size_t i = 0; i < nhits; ++i ) // nhits = 0 to 4
if( !hit_queue.push( hits[i] ) )
cerr << "Failed to push onto queue" << endl;
if (pause_queue==0 && queued > MAX_QUEUED )
{
cout << "queue paused " << queued << endl;
pause_queue = 1;
}

if( nhits )
notifier.notify_one();
if (pause_queue==1 && queued < MAX_QUEUED*0.8 )
{
cout << "queue un-paused " << queued << endl;
pause_queue = 0;
}




if(pause_queue==0)
{


if( fippiconfig.RUN_TYPE == 0x402)
{
nhits = collect_PixieNet_lm_data402( mapped, hits, &runstats, &fippiconfig );
for( size_t i = 0; i < nhits; ++i ) // nhits = 0 to 4
if( !hit_queue.push( hits[i] ) )
cerr << "Failed to push onto queue" << endl;

} else {
nhits = collect_PixieNet_lm_data400( mapped, hits, &runstats, &fippiconfig );
for( size_t i = 0; i < nhits; ++i ) // nhits = 0 to 4
if( !hit_queue.push( hits[i] ) )
cerr << "Failed to push onto queue" << endl;
}

if( nhits )
notifier.notify_one();

}


// ----------- Periodically save MCA and RS -----------
Expand Down Expand Up @@ -637,6 +665,13 @@ int main( int argc, char **argv )
}
}
fclose(filmca);

// 3) update console
const boost::posix_time::ptime currenttime1 = boost::posix_time::second_clock::local_time();
const boost::posix_time::time_duration dur1 = currenttime1 - starttime;
//cout << "Time: " << dur1 << " Events total " << runstats.eventcount << " written " << ntotalwrittennow << " queued " << ((long)runstats.eventcount - (long)ntotalwrittennow) << endl;
cout << "Time: " << dur1 << " Events total " << runstats.eventcount << " queued " << queued << endl;

}

// ----------- check if we've run long enough -------------------
Expand All @@ -645,7 +680,9 @@ int main( int argc, char **argv )

if( dur >= runtimelimit )
break;
} while ( !g_datataking_stop_requested );
if(g_datataking_stop_requested >1)
exit(-1); // multiple ctrl-c: exit altogether
} while ( g_datataking_stop_requested==0 );


// ********************** Run Stop **********************
Expand All @@ -666,9 +703,15 @@ int main( int argc, char **argv )
{
nhitsnow = collect_PixieNet_lm_data402( mapped, hits, &runstats, &fippiconfig );
for( size_t i = 0; i < nhitsnow; ++i )
{
hit_queue.push( hits[i] );

if(g_datataking_stop_requested >1)
exit(-1); // multiple ctrl-c: exit altogether
}

notifier.notify_one();



}while( nhitsnow );

Expand All @@ -681,9 +724,15 @@ int main( int argc, char **argv )
{
nhitsnow = collect_PixieNet_lm_data400( mapped, hits, &runstats, &fippiconfig );
for( size_t i = 0; i < nhitsnow; ++i )
{
hit_queue.push( hits[i] );
if(g_datataking_stop_requested >1)
exit(-1); // multiple ctrl-c: exit altogether
}

notifier.notify_one();



}while( nhitsnow );

Expand Down Expand Up @@ -790,8 +839,17 @@ int main( int argc, char **argv )

void handle_interupt( int s )
{
printf( "Caught signal %d\nWill stop taking data.", s );
g_datataking_stop_requested = true;
if(g_datataking_stop_requested==0)
{
printf( "Caught signal %d. Will stop taking data.\n", s ); // first time around, try safe exit
g_datataking_stop_requested = 1;
}
else
{
printf( "Caught signal %d again. Will exit DAQ.\n", s ); // 2nd time, give up
g_datataking_stop_requested ++;
}

}//void handle_interupt( int s );


Expand Down
2 changes: 1 addition & 1 deletion defaults.ini
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ CCSRA_TRIGENA_04 1 1 1 1
CCSRA_INVERT_05 0 0 0 0
CCSRA_VETO_REJLO_06 0 0 0 0
CCSRA_U_07 0 0 0 0
CCSRA_U_08 0 0 0 0
CCSRA_NO_OVERLAP_08 1 1 1 1
CCSRA_NEGE_09 0 0 0 0
CCSRA_U_10 0 0 0 0
CCSRA_U_11 0 0 0 0
Expand Down
Binary file modified docs/Pixie_Net_Manual.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ <h2>Help</h2>
<i style="font-size: 11px"><p>If you're seeing this page, it means you have successfully set up your Pixie-Net.
For more help, see </i> </p>
<a href="Pixie_Net_Manual.pdf"> Pixie-Net manual </a>
<a href="https://xiallc.atlassian.net/wiki/spaces/SUPPORT/pages/186548225/Pixie-Net"> XIA Pixie-Net website</a>
<a href="https://github.com/xia-whennig/PN-Releases"> XIA Pixie-Net releases</a>
<div class="tooltip"> <b style="font-size: 11px"> or try the tooltips</b>
<span class="tooltiptext">Hoover over bold underlined text for more information </span>
</div>
Expand Down
23 changes: 15 additions & 8 deletions startdaq.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ int main(void) {
double elm, q;
double cfdlev;
time_t starttime, currenttime;
unsigned int startTS, m, c0, c1, c2, c3, w0, w1, tmpI, revsn;
unsigned int startTS, w0, w1, tmpI, revsn;
//double m, c0, c1, c2, c3;
unsigned int evstats, R1, hit, timeL, timeH, psa0, psa1, cfd0;
unsigned int psa_base, psa_Q0, psa_Q1, psa_ampl, psa_R;
unsigned int cfdout, cfdlow, cfdhigh, cfdticks, cfdfrac, ts_max;
Expand Down Expand Up @@ -194,6 +195,7 @@ int main(void) {
loopcount = 0;
eventcount = 0;
starttime = time(NULL); // capture OS start time
currenttime = starttime;
if( (RunType==0x500) || (RunType==0x501) || (RunType==0x502) || (RunType==0x400) ) { // list mode runtypes
if(SyncT) mapped[ARTC_CLR] = 1; // write to reset time counter
mapped[AOUTBLOCK] = 2;
Expand Down Expand Up @@ -485,16 +487,19 @@ int main(void) {
// 1) Run Statistics
mapped[AOUTBLOCK] = OB_RSREG;

/*
// for debug purposes, print to std out so we see what's going on
k = 3; // no loop for now
{
m = mapped[ARS0_MOD+k];
c0 = mapped[ARS0_CH0+k];
c1 = mapped[ARS0_CH1+k];
c2 = mapped[ARS0_CH2+k];
c3 = mapped[ARS0_CH3+k];
printf("%s,%u,%s,%u,%u,%u,%u\n ","RunTime",m,"COUNTTIME",c0,c1,c2,c3);
m = (mapped[ARS0_MOD+k] + (mapped[ARS0_MOD+k+1]*TWOTO32))/1E9;
c0 = (mapped[ARS0_CH0+k] + (mapped[ARS0_CH0+k+1]*TWOTO32))/1E9;
c1 = (mapped[ARS0_CH1+k] + (mapped[ARS0_CH1+k+1]*TWOTO32))/1E9;
c2 = (mapped[ARS0_CH2+k] + (mapped[ARS0_CH2+k+1]*TWOTO32))/1E9;
c3 = (mapped[ARS0_CH3+k] + (mapped[ARS0_CH3+k+1]*TWOTO32))/1E9;
printf(" %s %9.3f, %s %9.3f,%9.3f,%9.3f,%9.3f\n","RUN_TIME",m,"COUNT_TIME",c0,c1,c2,c3);
}
*/
printf(" Time %u s, Events total %u\n",(unsigned int)(currenttime - starttime),eventcount);

// print (small) set of RS to file, visible to web
read_print_runstats(1, 0, mapped);
Expand Down Expand Up @@ -556,7 +561,8 @@ int main(void) {
// clear RunEnable bit to stop run
mapped[ACSRIN] = 0;
// todo: there may be events left in the buffers. need to stop, then keep reading until nothing left

printf(" Run ended, events total %u. Finishing up ...\n",eventcount);

// final save MCA and RS
filmca = fopen("MCA.csv","w");
fprintf(filmca,"bin,MCAch0,MCAch1,MCAch2,MCAch3\n");
Expand Down Expand Up @@ -623,6 +629,7 @@ int main(void) {


if( (RunType==0x500) || (RunType==0x501) || (RunType==0x502) || (RunType==0x400) ) {
if(eventcount>100000) printf(" Closing files, this may take a long time for high rates\n");
fclose(fil);
}
flock( fd, LOCK_UN );
Expand Down
Loading

0 comments on commit 0434704

Please sign in to comment.