Subversion Repositories f9daq

Compare Revisions

Ignore whitespace Rev 33 → Rev 34

/sipmScan/src/analysisBias.cpp
38,12 → 38,14
#define POSREC_ID 3
#define EVTREC_ID 4
#define THRREC_ID 5
#define BIASREC_ID 6
 
typedef struct {
unsigned int id,len;
unsigned int fver,time;
unsigned int thLow, thUp, thStep;
unsigned int biasLow, biasUp, biasStep;
unsigned int nev,nch,ped,xy;
unsigned int thLow, thUp, thStep;
int nx,x0,dx,ny,y0,dy;
} RUNREC;
RUNREC *runrec;
83,6 → 85,14
THRREC *thrrec;
THRREC thr;
 
typedef struct {
unsigned int id;
unsigned int len;
unsigned int bias;
} BIASREC;
BIASREC *biasrec;
BIASREC bias;
 
double padCenter[NCH][2];
 
int position(int, int, int);
89,7 → 99,7
 
// ------------------------------------------------------------------------------
 
int d2r(char* dfile0="test", int dbg=0, double tdcCut=5.0)
int analysisBias(char* dfile0="test", int dbg=0, double tdcCut=5.0)
{
 
const double c_tdcOffset = +2.5; // ns
162,6 → 172,7
TH2F *h2d[NCH];
TH2F *h_threshold;
TH2F *h_ch33;
TH2F *h_bias;
TNtuple *nt;
247,6 → 258,7
printf("nx = %d, x0 = %d, dx = %d\n", run.nx, run.x0, run.dx);
printf("ny = %d, y0 = %d, dy = %d\n", run.ny, run.y0, run.dy);
printf("thLow = %d, thUp = %d, thStep = %d\n", run.thLow, run.thUp, run.thStep);
printf("biasLow = %d, biasUp = %d, biasStep = %d\n", run.biasLow, run.biasUp, run.biasStep);
}
//create histograms
259,6 → 271,7
if (h_correctedTDC) delete h_correctedTDC;
h_correctedTDC = new TH2F("h_correctedTDC","Corrected TDC;t [ns];SiPM channel",33, -16.5*TDC_BIN,16.5*TDC_BIN,NCH,0,NCH);
//TH1F* gsumV673A[NCH/16] = new TH1F(hn,hname,256,-0.5,255.5);
h_bias = new TH2F("h_bias","",20, 71.0, 73.0, 33, -16.5*TDC_BIN, 16.5*TDC_BIN);
for(int i=0; i<NCH; i++) {
/*
sprintf(hname, "htdcpos%d", i);
393,6 → 406,7
hnhitsy[channel]->Fill((pos.yset - OFFSETY) * MIKRO_BIN);
h2d[channel]->Fill((pos.xset - OFFSETX) * MIKRO_BIN, (pos.yset - OFFSETY) * MIKRO_BIN);
//h_threshold->Fill(channel, thr.threshold);
h_bias->Fill(bias.bias/1000.0, (time-tdcOffset[channel]));
if (position(pos.xset-OFFSETX, pos.yset-OFFSETY, channel)) {
h_ch33->Fill(pos.xset-OFFSETX, pos.yset-OFFSETY);
h_threshold->Fill(channel, thr.threshold);
450,6 → 464,14
if (dbg) printf("THRREC id = %d len = %d threshold %d\n",
thrrec->id, thrrec->len, thrrec->threshold);
break;
case BIASREC_ID:
status = gzread(dfp, (voidp)&readbuf[2], (rec_len-2*ulsize));
biasrec = (BIASREC*) readbuf;
bias = *biasrec;
if (dbg) printf("BIASREC id = %d len = %d bias %d\n",
bias.id, bias.len, bias.bias);
break;
case ENDREC_ID:
gzread(dfp, (voidp)&readbuf[2], (rec_len-2*ulsize));
/sipmScan/src/sipmBias.c
13,7 → 13,8
# include "wienvme_dll.h"
# endif
# include "CAENV673A.h"
# include "CAENV462.h"
# include "CAENV462.h"
 
#endif
 
#ifdef USE_MIKRO
30,8 → 31,10
#ifdef USE_DAQ
# define USE_CAMAC
# include "camac.h"
# define NDAC 1
 
# define NDAC 1 // CAEN C221
# define ASD8 0 // channels
# define AMPDISSH 1
# define SIPM 2
# define CAEN_V673A 0x22220000 // IJS
//#define CAEN_V673A 0x10110000 // FMF
# define CAEN_V462 0x100300
53,6 → 56,7
#define IWAIT 200
 
#define NCH 64
#define POWERSUPPLY 66 // Power supply voltage for SiPM bias
 
static int p1h, pID, rID, tfID;
static int ph_tdc, ph_adc;
138,15 → 142,18
unsigned long *pdata;
 
FILE *fp;
#define RUNREC_ID 1
#define ENDREC_ID 2
#define POSREC_ID 3
#define EVTREC_ID 4
#define THRREC_ID 5
#define RUNREC_ID 1
#define ENDREC_ID 2
#define POSREC_ID 3
#define EVTREC_ID 4
#define THRREC_ID 5
#define BIASREC_ID 6
 
typedef struct {
unsigned long id,len;
unsigned long fver,time;
unsigned long thLow, thUp, thStep;
unsigned long biasLow, biasUp, biasStep;
unsigned long nev,nch,ped,xy;
long nx,x0,dx,ny,y0,dy;
} RUNREC;
175,14 → 182,23
typedef struct {
unsigned long id;
unsigned long len;
unsigned long thLow, thUp, thStep;
unsigned long threshold;
} THRREC;
THRREC thrrec;
typedef struct {
unsigned long id;
unsigned long len;
unsigned long bias;
} BIASREC;
BIASREC biasrec;
double thresholdLow;
double thresholdUp;
double thresholdStep;
double biasLow;
double biasUp;
double biasStep;
 
#define BSIZE 20000
205,6 → 221,8
evtrec.len = sizeof(evtrec);
thrrec.id = THRREC_ID;
thrrec.len = sizeof(thrrec);
biasrec.id = BIASREC_ID;
biasrec.len = sizeof(biasrec);
cres = 0;
241,7 → 259,7
GetCtrlVal (p1h, P1_FRAC, &frac);
}
GetCtrlVal (p1h, P1_STHRLOW, &thresholdLow);
GetCtrlVal (p1h, P1_SASD8THR, &thresholdLow);
runrec.thLow = thresholdLow*1000; // mV
GetCtrlVal (p1h, P1_STHRUP, &thresholdUp);
runrec.thUp = thresholdUp*1000; // mV
248,6 → 266,12
GetCtrlVal (p1h, P1_STEP, &thresholdStep);
runrec.thStep = thresholdStep*1000; // mV
GetCtrlVal (p1h, P1_SBIAS, &biasLow);
GetCtrlVal (p1h, P1_SBIASUP, &biasUp);
GetCtrlVal (p1h, P1_SBIASSTEP, &biasStep);
runrec.biasLow = biasLow*1000;
runrec.biasUp = biasUp*1000;
runrec.biasStep = biasStep*1000;
 
#ifdef USE_DAQ
V673A_map(0,CAEN_V673A,0);
268,12 → 292,21
fseed = runrec.time & 0x7fffffff;
Uniform (1, fseed, &fracg);
}
 
// Set SiPM bias voltage
//SetDac(SIPM, 1.0);
biasrec.bias = runrec.biasLow;
while (biasrec.bias <= runrec.biasUp) {
SetDac(SIPM, biasrec.bias/1000.0 - POWERSUPPLY);
SetCtrlVal(p1h, P1_SBIAS, biasrec.bias/1000.0);
status = fwrite(&biasrec, 1, biasrec.len, fp);
if (print) printf("BIASREC status %d len %d bias %d\n", status, biasrec.len, biasrec.bias);
// Set ASD threshold voltage
thrrec.threshold = (unsigned long) ceil(thresholdLow*1000); // threshold in mV
while (thrrec.threshold <= thresholdUp*1000) {
SetDac(0, thrrec.threshold/1000.0);
SetCtrlVal(p1h, P1_STHRLOW, thrrec.threshold/1000.0);
//wait_loop(100000);
SetDac(ASD8, thrrec.threshold/1000.0);
SetCtrlVal(p1h, P1_SASD8THR, thrrec.threshold/1000.0);
status = fwrite(&thrrec, 1, thrrec.len, fp);
if (print) printf("THRREC status %d len %d threshold %d\n", status, thrrec.len, thrrec.threshold);
459,7 → 492,12
if (!daq_on) break;
thrrec.threshold += thresholdStep*1000;
} // threhsold loop
if (!daq_on) break;
biasrec.bias += runrec.biasStep;
} // bias loop
SetDac(SIPM, 0); // safety
//if (dsave) {
time (&endrec.time);
status = fwrite (&endrec, 1, endrec.len, fp);
547,6 → 585,7
QueueUserEvent (1000, p1h, P1_RESET);
//QueueUserEvent (1000, p1h, P1_ASD8THR);
QueueUserEvent (1000, p1h, P1_AMPDISSHTHR);
QueueUserEvent (1000, p1h, P1_BIAS);
do {
GetUserEvent (1, &pID, &rID);
switch (rID) {
650,19 → 689,27
SetCtrlAttribute (p1h, P1_ADC, ATTR_YMAP_MODE, status);
update_plots();
break;
/*case P1_ASD8THR:
case P1_ASD8THR:
{
double value;
GetCtrlVal (p1h, P1_SASD8THR, &value);
SetDac(0, value);
SetDac(ASD8, value);
}
break;*/
break;
case P1_BIAS:
{
double value;
GetCtrlVal (p1h, P1_SBIAS, &value);
value -= POWERSUPPLY;
SetDac(SIPM, value);
}
break;
case P1_AMPDISSHTHR:
{
double value;
GetCtrlVal (p1h, P1_SAMPDISSHTHR, &value);
SetDac(1, value);
SetDac(AMPDISSH, value);
 
}
break;
/sipmScan/src/analysisScan.cpp
496,7 → 496,7
int position(int x, int y, int channel)
{
int flag = 0;
if ( (x > (padCenter[channel][0] - 5000)) && (x < (padCenter[channel][0] + 5000)) &&
(y > (padCenter[channel][1] - 5000)) && (y < (padCenter[channel][1] + 5000)) ) flag = 1;
if ( (x > (padCenter[channel][0] - 5040)) && (x < (padCenter[channel][0] + 5040)) &&
(y > (padCenter[channel][1] - 5040)) && (y < (padCenter[channel][1] + 5040)) ) flag = 1;
return flag;
}