25 #include <TGraphErrors.h>
34 #include "TMultiGraph.h"
51 const double TwoPi = 2. * 3.14159265358979323846 ;
52 const unsigned int T1995 = 788936400;
54 "CTIME",
"USEC",
"EXPOSURE",
"EXPTIME",
"MONOWL",
55 "AMP2.VOLTAGE",
"AMP2.CURRENT",
56 "CRYO.A.TEMP",
"CRYO.B.TEMP",
"CRYO.C.TEMP",
"CRYO.D.TEMP",
"CRYO.1.SETPT",
57 "MONOCH-WAVELENG",
"MONOCH.WAVELENG",
268 int IsOver(
int x,
int y);
277 if ( pInstance == 0 ) {
278 pInstance =
new DataStr (nx,ny);
289 if ( (nx == 3302) && (ny == 1612) ){
296 printf(
" DataStr::DataStr device = XCAM \n");
297 printf(
" PixSz= %f device_id=%i \n", pixsz, device);
308 if ( (nx == 1652) && (ny == 1612) ){
315 printf(
" DataStr::DataStr device = XCAM active area \n");
316 printf(
" PixSz= %f device_id=%i \n", pixsz, device);
328 if ( (nx == 817) && (ny == 1606) ){
335 printf(
" DataStr::DataStr device = Swiss \n");
336 printf(
" PixSz= %f device_id=%i \n", pixsz, device);
373 printf(
" DataStr::DataStr - not recognized device, use default \n");
376 NXover = nx-NXpres-512;
377 if (NXover < 0) NXover=0;
379 if (NYover < 0) NYover=0;
380 printf(
" DataStr::DataStr default as e2v CCD250 %i (%i,%i) %i (%i,%i) \n",
381 nx,NXpres,NXover, ny,NYpres,NYover);
382 printf(
" PixSz= %f device_id=%i \n", pixsz, device);
400 x <= oxmax ) {
return 1;}
402 y <= oymax ) {
return 1;}
409 x <= oxmax ) {
return 1;}
452 enum { Lcard = FLEN_CARD };
454 char value_str[Lcard];
467 std::pair<map <string, double>::iterator,
bool>
pptr;
472 char TableName[FLEN_VALUE];
476 char * ColName[NbCol];
477 static vector<double> TabData[NbCol];
478 static const char * FieldName[NbCol];
483 int Open(
const char * file_name );
485 int Read(
int copy =0);
486 void PrimeOut (
long Nx,
long Ny );
488 int OpenOutF (
const char * fOutName =
"Out_bufzs" );
489 int OutFitsF(
unsigned short * buf);
490 int getValue(
const char *
name,
double *
value );
493 void PrintKeys(
void );
507 for (
int i = 0;
i < NbCol;
i++) {
508 delete [] ColName[
i]; ColName[
i]=0;
538 strcpy (foutname, fOutName);
539 strcat (foutname,
".fits");
540 printf(
" OpenOutF name = %s \n", foutname);
545 printf(
" OpenOutF:: hdu=%i \n",
fout->HDUposition);
572 fits_report_error(stderr,
status );
574 fits_report_error(stderr,
status );
576 fits_report_error(stderr,
status );
577 if ( fits_update_key(
fout, TINT,
"NEXTEND", &channels,
"", &
status) )
578 fits_report_error(stderr,
status );
582 fits_report_error(stderr,
status );
583 printf(
" primary header done \n");
591 char cname[10] =
"Ch";
595 if ( fits_update_key(
fout, TSTRING,
"EXTNAME", cname,
"Channel number", &
status) )
596 fits_report_error(stderr,
status );
598 fits_report_error(stderr,
status );
599 if ( fits_update_key(
fout, TINT,
"BITPIX", &
bitpix,
"BITS PER PIXEL", &
status) )
600 fits_report_error(stderr,
status );
602 fits_report_error(stderr,
status );
603 if ( fits_update_key(
fout, TSTRING,
"DETECTOR", detector,
"DETECTOR ID", &
status) )
604 fits_report_error(stderr,
status );
632 fits_open_file (&
fptr, file_name, READONLY, &
status);
660 if (
Ncards < 1)
return -3;
666 for (
int ik=0; ik<
Ncards; ik++){
678 cr =
card + lngth + 1;
681 int cond = strcmp(
keyword,
"COMMENT") &&
685 if ( !cond )
continue;
686 if ( !strcmp(
keyword,
"HIERARCH") ){
688 lngth = (int)( pdest - cr );
699 lngth = (int)( pdest - cr );
712 while (L <lngth &&
value_str[L]==
' ') {cr++; L++;}
728 if ( copy && (
hdutype == IMAGE_HDU) ) {
729 printf(
" OutFitsF:: fptr.hdu=%i fout.hdu=%i \n",
730 fptr->HDUposition,
fout->HDUposition);
733 printf(
" OutFitsF:: fout.hdu=%i \n",
fout->HDUposition);
791 int colnum[
NbCol] = {0};
797 if ( nfound !=
NbCol )
goto BadTable;
809 fits_get_coltype(
fptr, colnum[
i], &typecode, &repeat, &width, &
status);
814 printf(
" FileF::Read BINARY_TBL problem: status=%i \n",
status);
832 else {*Value=
H_Iter->second;
return 0; }
840 printf(
" FileF::PrintKeys Ncards= %i MapSize= %i \n",
Ncards, msize);
844 double val =
H_Iter->second;
845 printf(
" %2i. %s:: %f \n", i, name.c_str(), val );
869 printf(
" FileList::dir_nm: %s \n", dir_nm.c_str());
871 const char fstr[] =
".fits";
872 const char * pdest = strstr( dir_nm.c_str(), fstr );
875 FName.insert( dir_nm );
877 printf(
" FileList:: Single file %i: %s \n",
Nfile, dir_nm.c_str());
880 void *dirp = gSystem->OpenDirectory(dir_nm.c_str());
881 while( (afile = gSystem->GetDirEntry(dirp)) ) {
882 pdest = strstr( afile, fstr );
883 if ( pdest == 0 )
continue;
886 FName.insert( fname );
937 FFT(
const char * Name,
938 const int minD,
const int maxD,
939 const int minL,
const int maxL,
941 const int FrInd=0,
const double Afk=2. );
942 void DTrans(
double * buf,
const int idu,
int sub);
951 fftw_destroy_plan(
p1d);
p1d=0;
958 const float left_margin = (float)0.04;
959 const float right_margin = (float)0.001;
960 const float top_margin = (float)0.01;
961 const float bot_margin = (float)0.04;
966 for (
int u=0;
u<Ncha;
u++){
970 sprintf(tiname,
"%s %i",
FFTName, ich);
971 sprintf(PDFname,
"%s_%i.pdf",
FFTName, ich);
972 Tr[
u] =
new TCanvas( tiname, tiname, 200+4*
u, 10+2*
u, 800, 600);
973 Tr[
u]->SetBorderMode (1);
974 Tr[
u]->SetLeftMargin (left_margin);
975 Tr[
u]->SetRightMargin (right_margin);
976 Tr[
u]->SetTopMargin (top_margin);
977 Tr[
u]->SetBottomMargin(bot_margin);
978 Tr[
u]->SetFrameFillColor(0);
988 int Npsd =
PSDav[ich].size();
989 int Nfrq =
Freq.size();
990 printf(
" RowPSD points =%i RowFreq size=%i *** \n", Npsd, Nfrq);
991 if ( Npsd <= 3 )
continue;
993 if ( Nfrq < nn )
continue;
994 TGraph * std6 =
new TGraph( nn, &
Freq[0], &
PSDav[ich][0]);
996 std6->GetYaxis()->SetTitle(
"PSD ");
997 std6->GetXaxis()->SetTitle(
"k/N, 1/pixel");
998 std6->SetMarkerColor(4);
999 std6->SetMarkerStyle(21);
1008 Tr[
u]->Print(PDFname);
1013 TCanvas * Tb =
new TCanvas(
"subtract",
"subtract", 250, 20, 800, 600);
1014 Tb->SetBorderMode (1);
1015 Tb->SetLeftMargin (left_margin);
1016 Tb->SetRightMargin (right_margin);
1017 Tb->SetTopMargin (top_margin);
1018 Tb->SetBottomMargin(bot_margin);
1019 Tb->SetFrameFillColor(0);
1022 int Entry = (int)
hbuf[0]->GetEntries();
1026 gStyle->SetOptFit(1);
1028 hbuf[0]->Fit(
"gaus");
1031 Entry = (int)
hbuf[1]->GetEntries();
1035 gStyle->SetOptFit(1);
1037 hbuf[1]->Fit(
"gaus");
1040 Entry = (int)
hbuf[2]->GetEntries();
1047 Entry = (int)
hbuf[3]->GetEntries();
1073 Nline(maxLine-minLine),
1074 Ndata(maxData-minData),
1084 int size2 =
sizeof(fftw_complex) *
Nfreq;
1085 inA = (
double*) fftw_malloc(size);
1086 outF = (fftw_complex *)fftw_malloc(size2);
1093 PSDs.resize(Nfreq,0.);
1100 sprintf(title,
"buf in %i",
Ndata);
1101 hbuf[0] =
new TH1D(title,title, 400,-100.,300.);
1102 hbuf[0]->SetStats(1);
1103 sprintf(title,
"buf out %i",
Ndata);
1104 hbuf[1] =
new TH1D(title,title, 400,-100.,300.);
1105 hbuf[1]->SetStats(1);
1106 sprintf(title,
"Asub %i",
Ndata);
1107 sprintf(titl2,
"kf %i",
kf);
1108 hbuf[2] =
new TH1D(title,titl2, 80,-16.,16.);
1109 hbuf[2]->SetStats(1);
1110 sprintf(title,
"WA %i",
Ndata);
1111 hbuf[3] =
new TH1D(title,titl2, 80,0.,20.);
1112 hbuf[3]->SetStats(1);
1148 double WA = sqrt(ReA*ReA + ImA*ImA);
1149 hbuf[3]->Fill( WA );
1153 double arg =
Farg *
j;
1154 double A_subtr = (ReA*cos(arg) - ImA*sin(arg));
1155 hbuf[0]->Fill( buf[
jb] );
1157 hbuf[1]->Fill( buf[jb] );
1158 hbuf[2]->Fill( A_subtr );
1166 if (ind >=
MaxP ) {ind=0;}
1175 const double eQ = 1.60217657;
1202 { 200., 0.125, 0.775},
1203 { 210., 0.132, 0.779428571},
1204 { 220., 0.133, 0.749636364},
1205 { 230., 0.139, 0.749391304},
1206 { 240., 0.141, 0.7285},
1207 { 250., 0.133, 0.65968},
1208 { 260., 0.12, 0.572307692},
1209 { 270., 0.103, 0.473037037},
1210 { 280., 0.103, 0.456142857},
1211 { 290., 0.117, 0.500275862},
1212 { 300., 0.131, 0.541466667},
1213 { 310., 0.139, 0.556},
1214 { 320., 0.142, 0.55025},
1215 { 330., 0.149, 0.559878788},
1216 { 340., 0.154, 0.561647059},
1217 { 350., 0.153, 0.542057143},
1218 { 360., 0.154, 0.530444444},
1219 { 370., 0.154, 0.516108108},
1220 { 380., 0.164, 0.535157895},
1221 { 390., 0.179, 0.569128205},
1222 { 400., 0.189, 0.5859},
1223 { 420., 0.206, 0.608190476},
1224 { 440., 0.222, 0.625636364},
1225 { 460., 0.235, 0.633478261},
1226 { 480., 0.247, 0.638083333},
1227 { 500., 0.262, 0.64976},
1228 { 520., 0.275, 0.655769231},
1229 { 540., 0.286, 0.656740741},
1230 { 560., 0.297, 0.657642857},
1231 { 580., 0.311, 0.664896552},
1232 { 600., 0.321, 0.6634},
1233 { 620., 0.334, 0.668},
1234 { 640., 0.347, 0.6723125},
1235 { 660., 0.359, 0.674484848},
1236 { 680., 0.368, 0.671058824},
1237 { 700., 0.379, 0.671371429},
1238 { 720., 0.391, 0.673388889},
1239 { 740., 0.403, 0.675297297},
1240 { 760., 0.413, 0.673842105},
1241 { 780., 0.425, 0.675641026},
1242 { 800., 0.434, 0.6727},
1243 { 820., 0.445, 0.672926829},
1244 { 840., 0.459, 0.677571429},
1245 { 860., 0.469, 0.676232558},
1246 { 880., 0.48, 0.676363636},
1247 { 900., 0.491, 0.676488889},
1248 { 920., 0.5, 0.673913043},
1249 { 940., 0.512, 0.675404255},
1250 { 960., 0.522, 0.67425},
1251 { 980., 0.513, 0.649102041},
1252 {1000., 0.492, 0.61008},
1253 {1020., 0.439, 0.533686275},
1254 {1040., 0.354, 0.422076923},
1255 {1060., 0.244, 0.285433962},
1256 {1080., 0.168, 0.192888889}
1356 for (; i<
Ncal; i++){
1357 if (waw >
PDresp[i].wave)
continue;
1364 QE = q1 + (q2-q1)*(waw-w1)/(w2-w1);
1377 if (waw >
PDratio[i].wave)
continue;
1382 double q1=
PDratio[i-1]. ratio;
1384 Ra = q1 + (q2-q1)*(waw-w1)/(w2-w1);
1391 int PeakRange(TH1D *
hist,
double * maxpos,
double * Rmin,
double * Rmax,
double * maxV)
1393 const double Fract = 0.04;
1394 int maxbin = hist->GetMaximumBin();
1395 *maxpos = hist->GetBinCenter(maxbin);
1396 double maxval = hist->GetBinContent(maxbin);
1399 cout <<
" maxbin=" << maxbin <<
" maxval=" <<maxval <<endl;
1400 cout <<
" max/maxpos=" << *maxpos << endl;
1403 while (bin>0 && hist->GetBinContent(bin) > Fract*maxval) bin--;
1404 *Rmin = hist->GetBinCenter(bin);
1405 cout <<
" Rmin=" << *Rmin <<
" A(Rmin)=" << hist->GetBinContent(bin) << endl;
1407 int xlast = hist->GetXaxis()->GetLast();
1409 while (bin<xlast && hist->GetBinContent(bin) > Fract*maxval) bin++;
1411 *Rmax = hist->GetBinCenter(bin);
1412 cout <<
" Rmax=" << *Rmax <<
" A(Rmax)=" << hist->GetBinContent(bin) << endl;
1467 PhDi (
int Nfiles,
const char * PDn );
1469 static double Gauss (
double *
v,
double *par );
1470 double Integral( vector<double>::iterator first,
1471 vector<double>::iterator last,
1472 vector<double>::iterator
point,
1476 vector<double> & Time,
1498 PDh->SetBorderMode (0);
1503 PDh->SetFrameFillColor(0);
1505 PDh->SetFillStyle(4100);
1506 PDh->SetFillColor(0);
1517 sprintf(hname,
"%s time",
PDname);
1518 PDdtm =
new TH1D (hname, hname, 100, 0., 25.);
1520 sprintf(hname,
"%s integral",
PDname);
1521 PD_Int =
new TH1D (hname, hname, 1000, 0., 100.);
1536 printf(
"Number of PD calibration points %i *** \n",
Ncal);
1546 if (s1 < 0.000001) s1=0.000001;
1548 double argG1 = (x - par[1])/s1;
1549 double fitval = par[0]*TMath::Exp(-0.5*argG1*argG1);
1554 vector<double>::iterator last,
1555 vector<double>::iterator
point,
1559 vector<double> & Time,
1565 double Val = base - *
point;
1567 double limit = 4.*abs(b_rms);
1568 if (abs(b_rms) < 0.0001 ) limit = 0.1*(base - *
point);
1573 if (first == last) {
PDbad++;
return InT;}
1576 if (point==first) {ti = Time[indx+1] - Time[indx] ; }
1577 else if (point==last) {ti = Time[indx] - Time[indx-1] ; }
1578 else {ti =(Time[indx+1] - Time[indx-1])/2.;}
1579 if (Val < limit) {
PDbad++;
return InT;}
1582 vector<double>::iterator stop,
start;
1583 start = stop =
point;
1585 for (; stop <= last; stop++) {
1587 if ( Val < limit) {stop--;
break;}
1589 if (stop==last) {ti = Time[indx] - Time[indx-1] ;}
1590 else {ti =(Time[indx+1] - Time[indx-1])/2.;}
1594 for (; start >= first; start--) {
1595 Val = base - *
start;
1596 if (Val < limit) {start++;
break;}
1598 if (start==first) {ti = Time[indx+1] - Time[indx] ;}
1599 else {ti =(Time[indx+1] - Time[indx-1])/2.;}
1606 if (before < 1) {istate=-1;
PDbad++;}
1607 if (after < 1) {istate=-2;
PDbad++;}
1611 iTime = Time[ind_stop] - Time[ind_strt];
1612 printf(
" Integral: strt=%i pnt=%li stop=%i \n ",ind_strt,
std::distance(first,point), ind_stop);
1613 printf(
" Integral: base=%f rms=%f limit=%f \n",base,b_rms,limit);
1635 const char fitname[] =
"fitGauss";
1639 double peak_tot = 0.;
1642 WaveL.push_back(wave);
1653 printf(
"GetValue: nfile=%i nrows=%li min=%f max=%f \n", Nf, FileF::nrows, min, max);
1656 double middle = (max +
min) / 2.;
1657 double numB = 0., AvB =0.;
1658 double numS = 0., AvS =0.;
1664 if (numB > 0) {AvB /= numB;}
1666 if (numS > 0) {AvS /= numS;}
1668 printf(
"GetValue: numB=%f AvB=%f numS=%f AvS=%f \n", numB, AvB, numS, AvS);
1670 double dB = max - AvB;
1671 double dS = AvS -
min;
1672 double rangeB = AvB - 2.*dB;
1673 double rangeS = AvS + 2.*dS;
1674 cout <<
"RANGEB= " << rangeB <<
"RANGES= " << rangeS << endl;
1676 sprintf(title,
"PD_S %i", Nf);
1677 PDhisS[
Nf] =
new TH1D (title, title, 16, min-dS, rangeS);
1679 sprintf(title,
"PD_B %i", Nf);
1680 PDhisB[
Nf] =
new TH1D (title, title, 20, rangeB, max);
1683 double time_read= 0.;
1690 if (i<10)
printf(
" %7.4f", dt);
1692 PDdtm->Fill(dt*1000.);
1706 cout <<
" maxpos=" << maxpos <<
" Rmin=" << Rmin <<
" Rmax" << Rmax <<endl;
1712 gPad->SetFillStyle(4100);
1713 gPad->SetFillColor(0);
1721 fitB[
Nf]->SetParameter(0, maxVa);
1722 fitB[
Nf]->SetParameter(1, maxpos);
1723 fitB[
Nf]->SetParameter(2, (Rmax - Rmin)/4.);
1724 cout <<
" par0=" << maxVa << endl;
1725 cout <<
" par1=" << maxpos <<
" par2=" << (Rmax - Rmin)/4. << endl;
1726 cout <<
"fitname=" << fitname << endl;
1728 base_flag =
PDhisB[
Nf]->Fit(fitname,
"LR");
1729 peak_tot =
fitB[
Nf]->GetParameter(0);
1730 position =
fitB[
Nf]->GetParameter(1);
1731 width =
fitB[
Nf]->GetParameter(2);
1732 printf (
" PD base: peak_events=%f position=%f rms=%f fit_flag=%i \n",
1733 peak_tot, position, width, base_flag);
1737 PDbase.push_back(position);
1738 PDbw.push_back(width);
1747 SinT.push_back(inTime);
1750 printf(
" SiIn=%f readings=%i inTime=%f istat=%i \n",
SiI[Nf],
PDreads, inTime, istat);
1755 cout <<
" maxpos=" << maxpos <<
" Rmin=" << Rmin <<
" Rmax" << Rmax <<endl;
1761 gPad->SetFillStyle(4100);
1762 gPad->SetFillColor(0);
1770 fitS[
Nf]->SetParameter(0, maxVa);
1771 fitS[
Nf]->SetParameter(1, maxpos);
1772 fitS[
Nf]->SetParameter(2, (Rmax - Rmin)/4.);
1773 cout <<
" par0=" << maxVa << endl;
1774 cout <<
" par1=" << maxpos <<
" par2=" << (Rmax - Rmin)/4. << endl;
1775 cout <<
"fitname=" << fitname << endl;
1777 base_flag =
PDhisS[
Nf]->Fit(fitname,
"LR");
1778 peak_tot =
fitS[
Nf]->GetParameter(0);
1779 position =
fitS[
Nf]->GetParameter(1);
1780 width =
fitS[
Nf]->GetParameter(2);
1781 printf (
" PD sgnl: peak_events=%f position=%f rms=%f fit_flag=%i \n",
1782 peak_tot, position, width, base_flag);
1805 sprintf(title,
"%s_0",
PDname);
1806 TCanvas * PD =
new TCanvas( title,title, 60, 40, 900, 800);
1807 PD->SetBorderMode (0);
1812 PD->SetFrameFillColor(0);
1813 PD->Divide(
NXpad,NYpad);
1815 gPad->SetFillStyle(4100);
1816 gPad->SetFillColor(0);
1818 for (
int i=0;
i<NH;
i++){
1823 PDplot[
i]->SetTitle(
"exposure");
1824 PDplot[
i]->GetXaxis()->SetTimeDisplay(1);
1825 PDplot[
i]->GetXaxis()->SetLabelOffset((
float)0.02);
1826 PDplot[
i]->SetMarkerColor (4);
1827 PDplot[
i]->SetMarkerStyle (8);
1838 sprintf(title,
"%s_s",
PDname);
1839 TCanvas * PDs =
new TCanvas( title, title, 65, 45, 900, 800);
1840 PDs->SetBorderMode (0);
1845 PDs->SetFrameFillColor(0);
1848 gPad->SetFillStyle(4100);
1849 gPad->SetFillColor(0);
1855 sprintf(title,
"%s current",
PDname);
1856 PDsp->SetTitle(title);
1857 PDsp->GetXaxis()->SetTitle(
"Wavelength, nm");
1858 PDsp->GetXaxis()->SetLabelOffset((
float)0.02);
1859 PDsp->GetYaxis()->SetTitle(
"Charge, pC");
1860 PDsp->SetMarkerColor (4);
1861 PDsp->SetMarkerStyle (8);
1862 PDsp->SetMarkerSize (1);
1863 PDsp->SetLineColor (4);
1864 PDsp->SetLineWidth (2);
1873 sprintf(title,
"%s integral",
PDname);
1874 PDip->SetTitle(title);
1875 PDip->GetXaxis()->SetTitle(
"Wavelength, nm");
1876 PDip->GetXaxis()->SetLabelOffset((
float)0.02);
1877 PDip->GetYaxis()->SetTitle(
"Charge, Ge-");
1878 PDip->SetMarkerColor (4);
1879 PDip->SetMarkerStyle (8);
1880 PDip->SetMarkerSize (1);
1881 PDip->SetLineColor (4);
1882 PDip->SetLineWidth (2);
1891 sprintf(title,
"%s signal readings",
PDname);
1892 PDep->SetTitle(title);
1893 PDep->GetXaxis()->SetTitle(
"Wavelength, nm");
1894 PDep->GetXaxis()->SetLabelOffset((
float)0.02);
1895 PDep->SetMarkerColor (4);
1896 PDep->SetMarkerStyle (8);
1897 PDep->SetMarkerSize (1);
1898 PDep->SetLineColor (4);
1899 PDep->SetLineWidth (2);
1909 sprintf(title,
"%s exposure",
PDname);
1910 PDit->SetTitle(title);
1911 PDit->GetXaxis()->SetTitle(
"Wavelength, nm");
1912 PDit->GetXaxis()->SetLabelOffset((
float)0.02);
1913 PDit->SetMarkerColor (4);
1914 PDit->SetMarkerStyle (8);
1915 PDit->SetMarkerSize (1);
1916 PDit->SetLineColor (4);
1917 PDit->SetLineWidth (2);
1922 TGraph * PDsip =
new TGraph(
Nsets, &
SiL[0], &
SiI[0]);
1926 sprintf(title,
"%s Current vs Int",
PDname);
1927 PDsip->SetTitle(title);
1928 PDsip->GetXaxis()->SetTitle(
"Charge L, pC");
1929 PDsip->GetXaxis()->SetLabelOffset((
float)0.02);
1930 PDsip->GetYaxis()->SetTitle(
"Charge, Ge-");
1931 PDsip->SetMarkerColor (4);
1932 PDsip->SetMarkerStyle (8);
1933 PDsip->SetMarkerSize (1);
1934 PDsip->SetLineColor (4);
1935 PDsip->SetLineWidth (2);
1944 sprintf(title,
"%s base line",
PDname);
1945 PDba->SetTitle(title);
1946 PDba->GetXaxis()->SetTitle(
"File Nb");
1947 PDba->GetXaxis()->SetLabelOffset((
float)0.02);
1948 PDba->GetYaxis()->SetTitle(
"Current, pA");
1949 PDba->SetMarkerColor (4);
1950 PDba->SetMarkerStyle (8);
1951 PDba->SetMarkerSize (1);
1952 PDba->SetLineColor (4);
1953 PDba->SetLineWidth (2);
1962 sprintf(title,
"%s base line width",
PDname);
1963 PDbawi->SetTitle(title);
1964 PDbawi->GetXaxis()->SetTitle(
"File Nb");
1965 PDbawi->GetXaxis()->SetLabelOffset((
float)0.02);
1966 PDbawi->GetYaxis()->SetTitle(
"Current, pA");
1967 PDbawi->SetMarkerColor (4);
1968 PDbawi->SetMarkerStyle (8);
1969 PDbawi->SetMarkerSize (1);
1970 PDbawi->SetLineColor (4);
1971 PDbawi->SetLineWidth (2);
1972 PDbawi->Draw(
"ALP");
1980 sprintf(title,
"%s wavelength",
PDname);
1981 PDw->SetTitle(title);
1982 PDw->GetXaxis()->SetTitle(
"File Nb");
1983 PDw->GetXaxis()->SetLabelOffset((
float)0.02);
1984 PDw->GetYaxis()->SetTitle(
"Wavelength, nm");
1985 PDw->SetMarkerColor (4);
1986 PDw->SetMarkerStyle (8);
1987 PDw->SetMarkerSize (1);
1988 PDw->SetLineColor (4);
1989 PDw->SetLineWidth (2);
1997 sprintf(title,
"%s time interval, ms",
PDname);
1998 PDdtm->GetXaxis()->SetTitle(title);
1999 PDdtm->GetXaxis()->SetLabelOffset((
float)0.02);
2000 PDdtm->GetYaxis()->SetTitle(
"Counts");
2001 PDdtm->SetMarkerColor (4);
2002 PDdtm->SetMarkerStyle (8);
2003 PDdtm->SetMarkerSize (1);
2004 PDdtm->SetLineColor (4);
2005 PDdtm->SetLineWidth (2);
2010 PDs->Print(
"PD0s.pdf");
2013 sprintf(title,
"%s_QA",
PDname);
2014 TCanvas * PDQA =
new TCanvas( title, title, 65, 45, 900, 800);
2015 PDQA->SetBorderMode (0);
2020 PDQA->SetFrameFillColor(0);
2023 gPad->SetFillStyle(4100);
2024 gPad->SetFillColor(0);
2030 sprintf(title,
"%s charge",
PDname);
2031 PDqa1->SetTitle(title);
2032 PDqa1->GetXaxis()->SetTitle(
"File Nb");
2033 PDqa1->GetXaxis()->SetLabelOffset((
float)0.02);
2034 PDqa1->GetYaxis()->SetTitle(
"Charge, Me-");
2035 PDqa1->SetMarkerColor (4);
2036 PDqa1->SetMarkerStyle (8);
2037 PDqa1->SetMarkerSize (1);
2038 PDqa1->SetLineColor (4);
2039 PDqa1->SetLineWidth (2);
2048 sprintf(title,
"%s signal readings",
PDname);
2049 PDqa2->SetTitle(title);
2050 PDqa2->GetXaxis()->SetTitle(
"File Nb");
2051 PDqa2->GetXaxis()->SetLabelOffset((
float)0.02);
2052 PDqa2->SetMarkerColor (4);
2053 PDqa2->SetMarkerStyle (8);
2054 PDqa2->SetMarkerSize (1);
2055 PDqa2->SetLineColor (4);
2056 PDqa2->SetLineWidth (2);
2066 sprintf(title,
"%s exposure",
PDname);
2067 PDqa3->SetTitle(title);
2068 PDqa3->GetXaxis()->SetTitle(
"File Nb");
2069 PDqa3->GetXaxis()->SetLabelOffset((
float)0.02);
2070 PDqa3->SetMarkerColor (4);
2071 PDqa3->SetMarkerStyle (8);
2072 PDqa3->SetMarkerSize (1);
2073 PDqa3->SetLineColor (4);
2074 PDqa3->SetLineWidth (2);
2083 sprintf(title,
"%s base line",
PDname);
2084 PDqa4->SetTitle(title);
2085 PDqa4->GetXaxis()->SetTitle(
"File Nb");
2086 PDqa4->GetXaxis()->SetLabelOffset((
float)0.02);
2087 PDqa4->GetYaxis()->SetTitle(
"Current, pA");
2088 PDqa4->SetMarkerColor (4);
2089 PDqa4->SetMarkerStyle (8);
2090 PDqa4->SetMarkerSize (1);
2091 PDqa4->SetLineColor (4);
2092 PDqa4->SetLineWidth (2);
2102 PDqa5->SetTitle(
"Wavelength");
2103 PDqa5->GetXaxis()->SetTitle(
"File Nb");
2104 PDqa5->GetXaxis()->SetLabelOffset((
float)0.02);
2105 PDqa5->GetYaxis()->SetTitle(
"Wavelength, nm");
2106 PDqa5->SetMarkerColor (4);
2107 PDqa5->SetMarkerStyle (8);
2108 PDqa5->SetMarkerSize (1);
2109 PDqa5->SetLineColor (4);
2110 PDqa5->SetLineWidth (2);
2116 if (
PD_Int->GetEntries() > 0 ){
2121 PDQA->Print(
"PD0qa.pdf");
2180 Bias (
const string & dir_name,
2181 const string & outFnm,
2185 int OutFitsF (
double * outbuf,
const char * fOutName =
"bias_outf" );
2202 const string & outFnm,
2233 cout <<
"Set starts:" << *FL.
FName_Iter << endl;
2243 if (
hdu > MaxP )
break;
2244 if (
Read() )
continue;
2250 if (!ir)
Vval[
i].push_back( v );
2254 if (
naxis != 2)
continue;
2280 printf(
" Average over %i zero exposures Nhdu=%i \n", Nf,
Nhdu);
2281 if ( Nf < 1 ) {
printf(
" No bias files \n");
Flag = -2;
return;}
2282 if (
Nchan < 1 ) {
printf(
" No channels detected \n");
Flag = -2;
return;}
2285 printf(
" Bias::Bias ch_idx=%i Nchan=%i avbuf_size=%lu npixels=%lu \n",
u, Nchan, (
long unsigned)
avbuf[
u].
size(),
npixels);
2305 if ( Nf < 2 ) {
printf(
" ** Only one bias file :( \n");
Flag = 0;
return;}
2311 if (
u > MaxP )
break;
2312 sprintf(title,
"hb0%i",
u);
2313 sprintf(hname,
"pixel average amplitude");
2314 hb[
u][0] =
new TH1D( title, hname, 2000, 1900., 41900.);
2315 hb[
u][0]->GetXaxis()->SetNdivisions(505);
2316 hb[
u][0]->SetStats(0);
2318 sprintf(title,
"hb1%i",
u);
2319 sprintf(hname,
"pixel simple average subtracted");
2320 hb[
u][1] =
new TH1D( title, hname, 1000, -100., 100.);
2321 hb[
u][1]->GetXaxis()->SetNdivisions(505);
2322 hb[
u][1]->SetStats(0);
2324 sprintf(title,
"hb2%i",
u);
2325 sprintf(hname,
"pixel rms");
2326 hb[
u][2] =
new TH1D( title, hname, 400, 0., 40.);
2327 hb[
u][2]->GetXaxis()->SetNdivisions(505);
2328 hb[
u][2]->SetStats(0);
2330 sprintf(title,
"hb3%i",
u);
2331 sprintf(hname,
"over_scan subtracted amplitude");
2332 hb[
u][3] =
new TH1D( title, hname, 600, -100., 500.);
2333 hb[
u][3]->SetDirectory(0);
2334 hb[
u][3]->GetXaxis()->SetNdivisions(505);
2335 hb[
u][3]->SetStats(0);
2337 sprintf(title,
"hb4%i",
u);
2338 sprintf(hname,
"X_overscan average amplitude");
2339 hb[
u][4] =
new TH1D( title, hname, 2000, 1900., 41900.);
2340 hb[
u][4]->GetXaxis()->SetNdivisions(505);
2341 hb[
u][4]->SetStats(0);
2344 sprintf(title,
"htrA%i",
u);
2345 sprintf(hname,
"Traverage amplitudes");
2346 htrA[
u] =
new TH1D( title, hname, 2000, 1900., 41900.);
2347 htrA[
u]->GetXaxis()->SetNdivisions(505);
2348 htrA[
u]->SetStats(0);
2349 sprintf(title,
"hmi%i",
u);
2350 sprintf(hname,
"pixel truncated average subtracted");
2351 htrS[
u] =
new TH1D( title, hname, 1000, -100., 100.);
2352 htrS[
u]->GetXaxis()->SetNdivisions(505);
2353 htrS[
u]->SetStats(0);
2354 sprintf(title,
"hma%i",
u);
2355 sprintf(hname,
"Tr rms");
2356 htrD[
u] =
new TH1D( title, hname, 400, 0., 40.);
2357 htrD[
u]->GetXaxis()->SetNdivisions(505);
2358 htrD[
u]->SetStats(0);
2367 if (
u > MaxP )
break;
2369 for (
int iy=Dev->
minY(); iy<Dev->
maxY(); iy++) {
2370 for (
int ix=0; ix<
nx; ix++) {
2387 sprintf(htitle,
"File %i",
i);
2391 hfz[
i] =
new TH1F( htitle,
filename.c_str(), 1000, -250., 750.);
2392 hfz[
i]->SetStats(1);
2398 if (
doFFT && (!FFTinit)) {
2399 Col =
new FFT(
"Bias Col",
2403 Row =
new FFT(
"Bias Row",
2419 cout <<
"Distribution, File: " << *FL.
FName_Iter << endl;
2423 if (
hdu > MaxP )
break;
2424 if (
Read() )
continue;
2429 if (
naxis != 2)
continue;
2434 for (
int iy=Dev->
minY(); iy<Dev->
maxY(); iy++) {
2435 for (
int ix=Dev->
minX(); ix<Dev->
maxX(); ix++) {
2439 if (TMath::Abs(amp) < 100. ) {b_shift += amp; act+=1.;}
2442 if (act > 100000.) b_shift /= act;
2450 for (
int iy=Dev->
minY(); iy<Dev->
maxY(); iy++) {
2452 for (
int ix=
nx-1; ix>=Dev->
minX(); ix--) {
2455 if ( Dev->
IsOverX(ix) )
continue;
2457 double Atr =
tmpbuf[
j] - b_shift;
2462 if (Nf < Nfhst)
hfz[Nf]->Fill( Atr );
2485 if ( Nf < 2 ) {
printf(
" Not enough bias files for RMS: %i \n", Nf);
Flag = 0;
return;}
2488 string foName =
"BiasNoise_";
2491 printf(
" Output File: %s \n", foName.c_str());
2492 FILE * pFile = fopen (foName.c_str(),
"wt");
2493 if (pFile == 0) {
printf(
" File %s cann't be open \n", foName.c_str());
Flag=-1;
return;}
2494 fprintf (pFile,
"// %s input files from: %s \n", foName.c_str(),
dname.c_str());
2495 fprintf (pFile,
"// Channel Noise rms \n");
2501 for (
int iy=Dev->
minY(); iy<Dev->
maxY(); iy++) {
2502 for (
int ix=Dev->
minX(); ix<Dev->
maxX(); ix++) {
2505 hb[
u][2]->Fill( rms );
2506 if ( Nf < 4 )
continue;
2510 double Trms = TMath::Sqrt( S2/(Nf-3.) );
2511 htrD[
u]->Fill( Trms );
2525 const float left_margin = (float)0.04;
2526 const float right_margin = (float)0.001;
2527 const float top_margin = (float)0.01;
2528 const float bot_margin = (float)0.04;
2535 sprintf(tiname,
"Bias FFT %i",
u);
2536 sprintf(PDFname,
"BiasFFT_%i.pdf",
u);
2537 if (
u >
MaxP )
break;
2538 Tr[
u] =
new TCanvas( tiname,tiname, 200+4*
u, 10+2*
u, 800, 600);
2539 Tr[
u]->SetBorderMode (1);
2540 Tr[
u]->SetLeftMargin (left_margin);
2541 Tr[
u]->SetRightMargin (right_margin);
2542 Tr[
u]->SetTopMargin (top_margin);
2543 Tr[
u]->SetBottomMargin(bot_margin);
2544 Tr[
u]->SetFrameFillColor(0);
2548 printf(
" Start draw Power Spectrum for Rows\n\n");
2556 printf(
" RowPSD points =%i RowFreq size=%i *** \n", Npsd, Nfrq);
2557 if ( Npsd <= 3 )
continue;
2559 if ( Nfrq < nn )
continue;
2561 std6->SetTitle(
"Rows");
2562 std6->GetYaxis()->SetTitle(
"PSD ");
2563 std6->GetXaxis()->SetTitle(
"k/N, 1/pixel");
2564 std6->SetMarkerColor(4);
2565 std6->SetMarkerStyle(21);
2576 printf(
" ColPSD points =%i ColFreq size=%i *** \n", Npsd, Nfrq);
2577 if ( Npsd <= 3 )
continue;
2579 if ( Nfrq < nn )
continue;
2581 std7->SetTitle(
"Columns");
2582 std7->GetYaxis()->SetTitle(
"PSD ");
2583 std7->GetXaxis()->SetTitle(
"k/N, 1/pixel");
2584 std7->SetMarkerColor(6);
2585 std7->SetMarkerStyle(21);
2590 Tr[
u]->Print(PDFname);
2597 const float left_margin = (float)0.04;
2598 const float right_margin = (float)0.001;
2599 const float top_margin = (float)0.01;
2600 const float bot_margin = (float)0.04;
2606 mean[NH] =
hfz[NH]->GetMean();
2615 sprintf(tiname,
"Bias BL %i",
u);
2616 sprintf(PDFname,
"BiasBL_%i.pdf",
u);
2617 if (
u >
MaxP )
break;
2620 Bi[
u] =
new TCanvas( tiname, tiname, 10+5*
u, 10+5*
u, 900, 800);
2621 Bi[
u]->SetBorderMode (0);
2622 Bi[
u]->SetLeftMargin (left_margin);
2623 Bi[
u]->SetRightMargin (right_margin);
2624 Bi[
u]->SetTopMargin (top_margin);
2625 Bi[
u]->SetBottomMargin(bot_margin);
2626 Bi[
u]->SetFrameFillColor(0);
2629 gPad->SetFillStyle(4100);
2630 gPad->SetFillColor(0);
2633 int Entry = (int)
hb[
u][
i]->GetEntries();
2635 if ( Entry < 1 )
continue;
2653 if ( (NH > 0) & (
Vval[0].
size() > 0) ){
2655 TGraph * pGmean =
new TGraph( NH, &
Vval[0][0], mean);
2656 pGmean->GetXaxis()->SetTimeDisplay(1);
2657 pGmean->GetXaxis()->SetLabelOffset((
float)0.02);
2658 pGmean->GetXaxis()->SetTimeFormat(
"#splitline{%Y-%m-%d}{%H:%M:%S}");
2659 pGmean->SetTitle(
"Mean level");
2660 pGmean->SetMarkerColor (4);
2661 pGmean->SetMarkerStyle (8);
2662 pGmean->SetMarkerSize (1);
2663 pGmean->SetLineColor (4);
2664 pGmean->SetLineWidth (2);
2665 pGmean->GetYaxis()->SetNdivisions (505);
2666 pGmean->GetYaxis()->SetTitle (
"File mean bias level, adu");
2667 pGmean->GetYaxis()->CenterTitle();
2668 pGmean->GetYaxis()->SetTitleOffset ((
float)1.06);
2669 pGmean->GetYaxis()->SetLabelSize ((
float)0.037);
2670 pGmean->Draw(
"ALP");
2678 if ( NH < 1 )
return;
2680 TCanvas * Zi =
new TCanvas(
"BiasVar",
"BiasVar", 50, 30, 900, 800);
2681 Zi->SetBorderMode (0);
2682 Zi->SetLeftMargin (left_margin);
2683 Zi->SetRightMargin (right_margin);
2684 Zi->SetTopMargin (top_margin);
2685 Zi->SetBottomMargin(bot_margin);
2686 Zi->SetFrameFillColor(0);
2689 gPad->SetFillStyle(4100);
2690 gPad->SetFillColor(0);
2692 for (
int i=0;
i<NH;
i++){
2693 if (
hfz[
i]->GetEntries() < 1 )
continue;
2705 TCanvas * PD =
new TCanvas(
"PDmonBias",
"PDmonBias", 60, 40, 900, 800);
2706 PD->SetBorderMode (0);
2707 PD->SetLeftMargin (left_margin);
2708 PD->SetRightMargin (right_margin);
2709 PD->SetTopMargin (top_margin);
2710 PD->SetBottomMargin(bot_margin);
2711 PD->SetFrameFillColor(0);
2714 gPad->SetFillStyle(4100);
2715 gPad->SetFillColor(0);
2717 for (
int i=0;
i<NH;
i++){
2718 if ( !
gPDc[
i] )
continue;
2722 gPDc[
i]->SetTitle(
"exposure");
2723 gPDc[
i]->GetXaxis()->SetTimeDisplay(1);
2724 gPDc[
i]->GetXaxis()->SetLabelOffset((
float)0.02);
2725 gPDc[
i]->SetMarkerColor (4);
2726 gPDc[
i]->SetMarkerStyle (8);
2727 gPDc[
i]->SetMarkerSize (1);
2728 gPDc[
i]->SetLineColor (4);
2729 gPDc[
i]->SetLineWidth (2);
2730 gPDc[
i]->Draw(
"ALP");
2735 for (
int i=0;
i<NH;
i++){ xnf[
i]=
i;}
2736 TGraph * pPDa =
new TGraph( NH, xnf,
PDbl);
2737 pPDa->SetTitle(
"PD average");
2738 pPDa->GetXaxis()->SetLabelOffset((
float)0.02);
2739 pPDa->SetMarkerColor (14);
2740 pPDa->SetMarkerStyle (8);
2741 pPDa->SetMarkerSize (1);
2742 pPDa->SetLineColor (14);
2743 pPDa->SetLineWidth (2);