Subversion Repositories f9daq

Compare Revisions

Regard whitespace Rev 35 → Rev 34

/sipmScan/src/analysisScan.cpp
31,7 → 31,7
#define TDC_BIN 1.0416 // 1 TDC bin in ns
#define MIKRO_BIN 0.49609/1000. //1 mikro step in mm; stage MM3MF
#define OFFSETX 5200 // Right edge of SiPM+Lightguide
#define OFFSETY 5300 // Lower edge of SiPM+Lightguide
#define OFFSETY 4800 // Lower edge of SiPM+Lightguide
 
#define RUNREC_ID 1
#define ENDREC_ID 2
372,11 → 372,11
h_correctedTDC->Fill((time - tdcOffset[channel]), channel);
hnhitsx[channel]->Fill((pos.xset - OFFSETX) * MIKRO_BIN);
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);
if (position(pos.xset-OFFSETX, pos.yset-OFFSETY, channel)) {
h2d[channel]->Fill((pos.xset - OFFSETX) * MIKRO_BIN, (pos.yset - OFFSETY) * MIKRO_BIN);
//if (position(pos.xset-OFFSETX, pos.yset-OFFSETY, channel)) {
//}
}
}
//gV673A->Fill(data,channel);
//gsumV673A[channel/16]->Fill(data);
}
/sipmScan/src/analysisThreshold.cpp
4,8 → 4,7
// Contributors: Rok Pestotnik, Rok Dolenec, Dino Tahirovic
//
// 3/1/2014 TDC cut relative to tdc offset
// 5/3/2014 TH3F h_correctedTDC; commented 'delete' commands
// 12/3/2014 declarations of all histos before while{}
//
 
#include "stdio.h"
#include "TROOT.h"
13,7 → 12,6
#include "TNtuple.h"
#include "TH1F.h"
#include "TH2F.h"
#include "TH3F.h"
#include "TF1.h"
#include "TMath.h"
#include "TStyle.h"
32,8 → 30,8
#define NCH 64
#define TDC_BIN 1.0416 // 1 TDC bin in ns
#define MIKRO_BIN 0.49609/1000. //1 mikro step in mm; stage MM3MF
#define OFFSETX 5200 // Right edge of SiPM+Lightguide
#define OFFSETY 5400 // Lower edge of SiPM+Lightguide
#define OFFSETX 5100 // Right edge of SiPM+Lightguide
#define OFFSETY 5200 // Lower edge of SiPM+Lightguide
 
#define RUNREC_ID 1
#define ENDREC_ID 2
93,8 → 91,9
 
int d2r(char* dfile0="test", int dbg=0, double tdcCut=5.0)
{
const double c_tdcOffset = 1; // ns
const double c_tdcOffset = +2.5; // ns
printf(" Data to root conversion program\nUsage:\nd2r(input file name <without.dat>, debug on/off, TDC cut +-[ns])\n\n");
char fullname[256];
124,10 → 123,56
printf("%.2lf %.2lf %.2lf\n", padCenter[i][0], padCenter[i][1], tdcOffset[i]);
}
//TDC correction parameters
/*
double corpar[NCH][3]={ {-0.8, 25, 0},
{-0.8, 25, 0},
{-0.8, 25, 0},
{-0.8, 25, 0},
{-0.8, 25, 0},
{-0.8, 25, 0},
{-0.8, 25, 0},
{-0.8, 25, 0} };
sprintf(fullname, "data/%s_cor.txt", dfile0);
if( (fp=fopen(fullname, "rt")) == NULL )
printf("Cannot open parameter file %s !!!\n", fullname);
else {
printf("Opened parameter file %s\n", fullname);
for(int i=0; i<NCH; i++) {
fscanf(fp, "%lf %lf %lf\n", &corpar[i][0], &corpar[i][1], &corpar[i][2]);*/
/*// check if parameters make sense
if( (corpar[i][0] < (tdcmi-0.2*tdcmi)) || ((tdcma+0.2*tdcma) < corpar[i][0]) ||
(corpar[i][1] < 0) || (1e4*TDC_BIN < corpar[i][1]) ||
(1e4 < TMath::Abs(corpar[i][2])) ) {
printf("Warning: parameters for ch%d out of limits -> using default!\n", i);
corpar[i][0]=2200*TDC_BIN; corpar[i][1]=1000*TDC_BIN; corpar[i][2]=-100*TDC_BIN;
}*/
/* }
fclose(fp);
}*/
//for(int i=0; i<NCH; i++) printf("%.2lf %.2lf %.2lf\n", corpar[i][0], corpar[i][1], corpar[i][2]);
//histograms
char hname[256];
//double tdc;
TH2F *htdc;
TH2F* h_correctedTDC;
TH1F *hnhitsx[NCH], *hnhitsy[NCH];
TH2F *h2d[NCH];
TH2F *h_threshold;
TH2F *h_ch33;
TNtuple *nt;
//data buffer
unsigned int readbuf[READBUFFERLENGTH];
unsigned int buf[READBUFFERLENGTH];
//data file
gzFile dfp;
char dfile[256];
153,14 → 198,14
printf("Opened data file %s\n", dfile);
//opens ROOT file
//TFile *rootfile;
char fnameroot[256];
sprintf(fnameroot, "root/%s.root", dfile0);
TFile rootfile(fnameroot,"RECREATE",dfile0);
if (rootfile.IsZombie()) {
std::cout << "Error opening file" << std::endl;
exit(-1);
}
if (rootfile.IsOpen()) std::cout << "ROOT file opened for writing." << std::endl;
//rootfile = (TFile *) gROOT->FindObjectAny(dfile0);
//if (rootfile!=NULL) {printf("!!!\n");rootfile->Close();}
//rootfile = new TFile(fnameroot);
//if(rootfile) rootfile->Close();
TFile* rootfile = new TFile(fnameroot,"RECREATE",dfile0);
// -----------------------------------------------
// loop trough records
174,21 → 219,8
int ii;
int nint;
int nb;
int nSteps;
int status;
char hname[256];
TH2F* htdc = new TH2F("htdc",";TDC channel;SiPM channel",512,-0.5,511.5,NCH,-0.5,NCH-0.5);
TH3F* h_correctedTDC = new TH3F("h_correctedTDC",";SiPM channel; ASD threshold [V]; t [ns]",
NCH, -0.5, NCH-0.5,
101, 1.0, 2.0,
33, -16.5*TDC_BIN, 16.5*TDC_BIN);
TH1F* hnhitsx[NCH]; // move to 2d with (channel, position)
TH1F* hnhitsy[NCH]; //-||-
TH2F* h2d[NCH]; //-||-
TH2F* h_threshold = new TH2F("h_threshold",";SiPM ch;Threshold[V]",
64,-0.5,63.5,
101, 1.0, 2.0);
TH2F* h_ch33 = new TH2F("h_ch33","ch. 33;x;y",100,20000,30000,100,0,10000);
TNtuple* nt = new TNtuple("nt", "nt", "ch:x:y:tdc");
while(1) {
if(gzeof(dfp)) end_of_file = 1;
201,11 → 233,9
if(dbg) printf("-----------------------------------------------\n");
if(dbg) printf("[%d] rec_id = %d | rec_len = %u\n", ceve, rec_id, rec_len);
double nSteps = 0;
switch(rec_id)
{
case RUNREC_ID:
if (dbg) printf("RUNREC\n");
gzread(dfp, (voidp)&readbuf[2], (rec_len-2*ulsize));
runrec = (RUNREC *) readbuf;
run=*runrec;
220,27 → 250,14
}
//create histograms
//nt = (TNtuple*) gROOT->FindObject("nt");
//if (nt) delete nt;
//sprintf(hname, "htdc");
//htdc = (TH2F*) gROOT->FindObject(hname);
//if (htdc) delete htdc;
//htdc = new TH2F("htdc",";TDC channel;SiPM channel",512,0,512,NCH,0,NCH);
h_correctedTDC = (TH3F*) gROOT->FindObject("h_correctedTDC");
nt = new TNtuple("nt", "nt", "ch:x:y:tdc");
sprintf(hname, "htdc");
htdc = (TH2F*) gROOT->FindObject(hname);
if (htdc) delete htdc;
htdc = new TH2F("htdc","Raw TDC;TDC channel;SiPM channel",512,0,512,NCH,0,NCH);
h_correctedTDC = (TH2F*) gROOT->FindObject("h_correctedTDC");
if (h_correctedTDC) delete h_correctedTDC;
nSteps = (run.thUp - run.thLow)/double(run.thStep) + 1;
if (dbg) printf("nSteps %d\n", nSteps);
h_correctedTDC = new TH3F("h_correctedTDC",";SiPM channel; ASD threshold [V]; t [ns]",
NCH,
-0.5,
NCH-0.5,
nSteps,
(run.thLow - 0.5*run.thStep)/1000.0,
(run.thUp + 0.5*run.thStep)/1000.0,
2*tdcCut*TDC_BIN,
-tdcCut*TDC_BIN,
tdcCut*TDC_BIN);
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);
for(int i=0; i<NCH; i++) {
/*
255,6 → 272,7
htdc[i] = new TH1F(hname, hname, 512, 0*TDC_BIN, 512*TDC_BIN);
*/
sprintf(hname, "hnhitsx%d", i);
hnhitsx[i] = (TH1F*)gROOT->FindObject(hname);
if(hnhitsx[i]) delete hnhitsx[i];
283,10 → 301,12
}
if (h_threshold) delete h_threshold;
h_threshold = new TH2F("h_threshold",";SiPM ch;Threshold[V]",64,-0.5,63.5,
nSteps = (run.thUp - run.thLow)/double(run.thStep) + 1;
if (dbg) printf("nSteps %d\n", nSteps);
h_threshold = new TH2F("h_threshold","Threshold scan;SiPM ch;Threshold[mV]",64,-0.5,63.5,
nSteps,
(run.thLow - 0.5*run.thStep)/1000.0,
(run.thUp + 0.5*run.thStep)/1000.0);
run.thLow - 0.5*run.thStep,
run.thUp + 0.5*run.thStep);
//h_threshold = new TH2F("h_threshold","Threshold scan;SiPM ch;Threshold[mV]",64,-0.5,63.5,
// 101,995,2005);
294,11 → 314,9
if (h_ch33) delete h_ch33;
h_ch33 = new TH2F("h_ch33","ch. 33;x;y",100,20000,30000,100,0,10000);
 
if (dbg) printf("RUNREC: all histos created.\n");
break;
case POSREC_ID:
if (dbg) printf("POSREC\n");
gzread(dfp, (voidp)&readbuf[2], (rec_len-2*ulsize));
posrec = (POSREC *) readbuf;
pos=*posrec;
319,7 → 337,7
//if (rec_len < 0 || rec_len > 10000) {
if (rec_len > READBUFFERLENGTH) {
printf("Len %u\n", rec_len);
return(1);
return(0);
}
nb = rec_len - 3*ulsize; // no. of bytes to read
gzread(dfp, (voidp)&buf, nb);
368,16 → 386,16
if (dbg) nt->Fill(channel, pos.ix, pos.iy, data);
double tdcmin = tdcOffset[channel] - tdcCut;
double tdcmax = tdcOffset[channel] + tdcCut;
double time = data*TDC_BIN - tdcOffset[channel];
if(time >= -tdcCut and time <= tdcCut) {
h_correctedTDC->Fill(channel, thr.threshold/1000.0, time);
double time = data*TDC_BIN;
if(time >= tdcmin && time <= tdcmax) {
h_correctedTDC->Fill((time - tdcOffset[channel]), channel);
hnhitsx[channel]->Fill((pos.xset - OFFSETX) * MIKRO_BIN);
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);
if (position(pos.xset-OFFSETX, pos.yset-OFFSETY, channel)) {
h_ch33->Fill(pos.xset-OFFSETX, pos.yset-OFFSETY);
h_threshold->Fill(channel, thr.threshold/1000.0);
h_threshold->Fill(channel, thr.threshold);
}
}
//gV673A->Fill(data,channel);
390,6 → 408,39
ii += len;
} //while
 
// events ------------------------------------------------------------------------------------------
// fill histograms
/*
for(int i=0; i<NCH; i++) {
//tdc=((double)evtrec->data[i])*TDC_BIN - tdcoffset[i];
//adc=(double)evtrec->data[i+NCH]-adcoffset[i];
if (gNtWrite) nt->Fill(i,pos.ix,pos.iy,tdc);
//if( (qdcmi < adc) && (adc < qdcma) ) {
htdc[i]->Fill(tdc);
//}
//hadc[i]->Fill(adc);
//hcor[i]->Fill(adc,tdc);
//if(adc > corpar[i][2])
//hctdc[i]->Fill( tdc - (corpar[i][0] + corpar[i][1]/TMath::Sqrt(adc - corpar[i][2])) );
 
if( (abs(padcenter[i][0] - pos.xset) < POSMARG) && (abs(padcenter[i][1] - pos.yset) < POSMARG) ) {
htdcpos[i]->Fill(tdc);
//hadcpos[i]->Fill(adc);
//hcorpos[i]->Fill(adc,tdc);
//if(adc > corpar[i][2])
//hctdcpos[i]->Fill( tdc - (corpar[i][0] + corpar[i][1]/TMath::Sqrt(adc - corpar[i][2])) );
}
if((tdcmi < tdc) && (tdc < tdcma)) {
//hadc_cut[i]->Fill(adc);
hnhitsx[i]->Fill((pos.xset - OFFSETX) * MIKRO_BIN);
hnhitsy[i]->Fill((pos.yset - OFFSETY) * MIKRO_BIN);
h2d[i]->Fill((pos.xset - OFFSETX) * MIKRO_BIN, (pos.yset - OFFSETY) * MIKRO_BIN);
//if(i==4) adc1=adc;
//if(i==5) adc2=adc;
}
} */
break;
case THRREC_ID:
449,24 → 500,24
 
if(dfp) {
gzclose(dfp);
//delete dfp;
delete dfp;
}
//if(dbg) return 0;
if(rootfile.IsOpen()) {
if(dbg) return 1;
if(rootfile) {
nt->Write();
rootfile.Write();
rootfile->Write();
printf("Saved to %s\n", fnameroot);
rootfile.Close();
//delete rootfile;
rootfile->Close();
delete rootfile;
}
return 0;
return 1;
}
 
int position(int x, int y, int channel)
{
int flag = 0;
if ( (x > (padCenter[channel][0] - 5000)) and (x < (padCenter[channel][0] + 5000)) and
(y > (padCenter[channel][1] - 5000)) and (y < (padCenter[channel][1] + 5000)) ) flag = 1;
if ( (x > (padCenter[channel][0] - 5000)) && (x < (padCenter[channel][0] + 5000)) &&
(y > (padCenter[channel][1] - 5000)) && (y < (padCenter[channel][1] + 5000)) ) flag = 1;
return flag;
}
/sipmScan/examples/tdc.C
File deleted
/sipmScan/examples/thresholdScan.C
File deleted
/sipmScan/examples/threshold64.C
File deleted
/sipmScan/examples/sipm.C
File deleted
/sipmScan/d2r.ini
1,72 → 1,72
# ch pad_center_x pad_center_y tdc_offset # sipm2, tdc modified 27/3/14 pos added 20/2/14 threshold scan
0 75600 5040 143.5
1 55440 5040 143.5
2 75600 15120 143.5
3 55440 15120 143.5
4 45360 25200 143.5
5 65520 25200 143.5
6 45360 35280 143.5
7 65520 35280 143.5
# ch pad_center_x pad_center_y tdc_offset # sipm2, tdc modified 20/3/14 pos added 20/2/14
0 75600 5040 142.5
1 55440 5040 142.1
2 75600 15120 142.1
3 55440 15120 141.6
4 45360 25200 142.2
5 65520 25200 141.9
6 45360 35280 143
7 65520 35280 141.3
 
8 75600 45360 143.5
9 55440 45360 142.5
10 75600 55440 142.5
11 55440 55440 142.5
12 45360 65520 142.5
13 65520 65520 142.5
14 45360 75600 142.5
15 65520 75600 142.5
8 75600 45360 141
9 55440 45360 140
10 75600 55440 140
11 55440 55440 140
12 45360 65520 140
13 65520 65520 140
14 45360 75600 140
15 65520 75600 140
 
16 65520 5040 144.5
17 45360 5040 144.5
18 65520 15120 144.5
19 45360 15120 144.5
20 55440 25200 144.5
21 75600 25200 144.5
22 55440 35280 144.5
23 75600 35280 143.5
16 65520 5040 142.7
17 45360 5040 142
18 65520 15120 142
19 45360 15120 142.1
20 55440 25200 142.1
21 75600 25200 141
22 55440 35280 142
23 75600 35280 142
 
24 65520 45360 143.5
25 45360 45360 143.5
26 65520 55440 143.5
27 45360 55440 143.5
28 55440 65520 143.5
29 75600 65520 143.5
30 55440 75600 143.5
31 75600 75600 146.5
24 65520 45360 142
25 45360 45360 141.5
26 65520 55440 141.8
27 45360 55440 141.9
28 55440 65520 141.3
29 75600 65520 141
30 55440 75600 141.7
31 75600 75600 145
 
32 5040 5040 143.5
33 25200 5040 143.5
34 5040 15120 143.5
35 25200 15120 143.5
36 35280 25200 143.5
37 15120 25200 143.5
38 35280 35280 144.5
39 15120 35280 144.5
32 5040 5040 141
33 25200 5040 141
34 5040 15120 141
35 25200 15120 141
36 35280 25200 141
37 15120 25200 141
38 35280 35280 141
39 15120 35280 140.1
 
40 5040 45360 144.5
41 25200 45360 144.5
42 5040 55440 144.5
43 25200 55440 144.5
44 35280 65520 144.5
45 15120 65520 144.5
46 35280 75600 144.5
47 15120 75600 144.5
40 5040 45360 142.8
41 25200 45360 142.7
42 5040 55440 143.7
43 25200 55440 142.7
44 35280 65520 142.7
45 15120 65520 142.4
46 35280 75600 142.1
47 15120 75600 141.9
 
48 15120 5040 144.5
49 35280 5040 144.5
50 15120 15120 144.5
51 35280 15120 144.5
52 25200 25200 143.5
53 5040 25200 142.5
54 25200 35280 142.5
55 5040 35280 142.5
48 15120 5040 143
49 35280 5040 140.9
50 15120 15120 142
51 35280 15120 141.5
52 25200 25200 140
53 5040 25200 141.3
54 25200 35280 142
55 5040 35280 141
 
56 15120 45360 142.5
57 35280 45360 142.5
58 15120 55440 142.5
59 35280 55440 142.5
60 25200 65520 142.5
61 5040 65520 142.5
62 25200 75600 142.5
63 5040 75600 142.5
56 15120 45360 140
57 35280 45360 140
58 15120 55440 140
59 35280 55440 140
60 25200 65520 140
61 5040 65520 140
62 25200 75600 140
63 5040 75600 140