From 118ded9ac040c4d24879e0c5085e2bbca35b09c3 Mon Sep 17 00:00:00 2001 From: Stefan Ritt Date: Mon, 5 Dec 2016 14:03:06 +0100 Subject: [PATCH] Added optional histogram output in chip test --- software/drscl/drscl.cpp | 4 ++-- software/include/DRS.h | 2 +- software/src/DRS.cpp | 40 ++++++++++++++++++++++++++++++++++------ 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/software/drscl/drscl.cpp b/software/drscl/drscl.cpp index 9ad7da5..ad571c5 100644 --- a/software/drscl/drscl.cpp +++ b/software/drscl/drscl.cpp @@ -71,7 +71,7 @@ void print_help() puts("board | |all Address individual board/range/all boards"); puts("calib [dir] Response Calibration. Use dir=\"area\" for MEG"); puts("chn [n] Set number of channels: 8, 4, 2, 1"); - puts("ct Chip Test"); + puts("ct [histo] Chip Test [show histo]"); puts("del <0|1> Switch delayed start on/off"); puts("dir Show CF directory"); puts("dmode <0|1> Set Domino mode 0=single, 1=cont."); @@ -1333,7 +1333,7 @@ void cmd_loop() else { puts("Press 'q' to quit, any other key to repeat test.\n"); do { - b->ChipTest(); + b->ChipTest(param[1][0] > 0); b->SetStandbyMode(1); for (i=0 ; i<8 ; i++) b->SetDAC(i, 0); diff --git a/software/include/DRS.h b/software/include/DRS.h index 4e30503..62ac3d4 100644 --- a/software/include/DRS.h +++ b/software/include/DRS.h @@ -622,7 +622,7 @@ public: int GetTransport() const { return fTransport; } void RegisterTest(void); int RAMTest(int flag); - int ChipTest(); + int ChipTest(int flag); unsigned int GetCtrlReg(void); unsigned short GetConfigReg(void); unsigned int GetStatusReg(void); diff --git a/software/src/DRS.cpp b/software/src/DRS.cpp index 9186610..17ac3b6 100644 --- a/software/src/DRS.cpp +++ b/software/src/DRS.cpp @@ -3031,7 +3031,7 @@ int DRSBoard::RAMTest(int flag) /*------------------------------------------------------------------*/ -int DRSBoard::ChipTest() +int DRSBoard::ChipTest(int flag) { int i, j, tc, n_error, test_board, t; double freq, real_freq, max_freq; @@ -3206,12 +3206,20 @@ int DRSBoard::ChipTest() GetWave(0, i, wf1[i], false, tc, 0, true); // check if more than 500 mV lost - for (i=0 ; i<9 ; i++) - for (j=0 ; j<1024 ; j++) { - if (wf1[i][j] < 0 && lc[i][j] == 0) { - lc[i][j] = 0.15 * (wf0[i][j]-wf1[i][j])/t; // lc = C * delta_u / delta_t in [pA] + if (test_board) { + for (i=0 ; i<9 ; i++) + for (j=0 ; j<1024 ; j++) { + if (wf1[i][j] < 0 && lc[i][j] == 0) { + lc[i][j] = 0.15 * (wf0[i][j]-wf1[i][j])/t; // lc = C * delta_u / delta_t in [pA] + } } - } + } else { + for (i=0 ; i<8 ; i+=2) + for (j=0 ; j<1024 ; j++) + if (wf1[i][j] < 0 && lc[i][j] == 0) { + lc[i][j] = 0.15 * (wf0[i][j]-wf1[i][j])/t; // lc = C * delta_u / delta_t in [pA] + } + } // check if all cells drained if (test_board) { @@ -3236,10 +3244,19 @@ int DRSBoard::ChipTest() // calculate statistics over leakage current double sum = 0, lcmax = 0; int n = 0, imax, jmax; + int histo[100]; + memset(histo, 0, sizeof(histo)); for (i=0 ; i<9 ; i++) for (j=0 ; j<1024 ; j++) if (lc[i][j] > 0) { + int bin = (int)lc[i][j]; + if (bin == 0) + bin = 0; + if (bin > 99) + bin = 99; + histo[bin]++; + sum += lc[i][j]; n++; if (lc[i][j] > lcmax) { @@ -3249,6 +3266,17 @@ int DRSBoard::ChipTest() } } printf("Leakage current [pA]: %1.1lf average, %1.1lf max [%d/%d]\n", sum/n, lcmax, imax, jmax); + + if (flag) { + printf("Distrubtuion [pA-pA] N:\n"); + for (i=99 ; i>0 ; i--) + if (histo[i]) + break; + int hmax = i; + for (i=0 ; i<=hmax ; i++) { + printf("%d %d\n", i, histo[i]); + } + } } /* count errors */