Subversion Repositories f9daq

Compare Revisions

Ignore whitespace Rev 290 → Rev 291

/cvi/apps/l2d2_easyroc/Analysis/Analysis/data/rok0
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/Analysis/Analysis/data/rok1
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/l2d2_easyroc/Analysis/Analysis/data/rok1
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/Analysis/Analysis/data/rok2
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/l2d2_easyroc/Analysis/Analysis/data/rok2
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/Analysis/Analysis/data/rok3
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/l2d2_easyroc/Analysis/Analysis/data/rok3
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/Analysis/Analysis/e2r.cpp
===================================================================
--- l2d2_easyroc/Analysis/Analysis/e2r.cpp (nonexistent)
+++ l2d2_easyroc/Analysis/Analysis/e2r.cpp (revision 291)
@@ -0,0 +1,144 @@
+#include "stdio.h"
+#include "TROOT.h"
+#include "TSystem.h"
+#include "TFile.h"
+#include "TH1F.h"
+#include "TH2F.h"
+#include "TF1.h"
+#include "TMath.h"
+
+#define NCH 32
+
+#define HEADER_WORD_1 0xFFFF
+#define HEADER_WORD_2 0xEA0C
+#define ID_ADC_HG 0x81
+#define ID_ADC_LG 0x60
+#define ID_TDC 0xCC
+#define PRINT_FREQUENCY 10000
+
+void e2r(char* dfile0="test", int dbg=0)
+{
+ char fullname[256], sbuff[256];
+
+ FILE *dfp;
+ char dfile[256];
+ sprintf(dfile, "data/%s", dfile0);
+
+ if((dfp=fopen(dfile,"rb")) == NULL) {
+ printf("Cannot open data file %s !!!\n", dfile);
+ return;
+ } else {
+ printf("Opened data file %s.\n", dfile);
+ }
+
+ if(sizeof(int) != 4) {
+ printf("sizeof(int) != 4, sizeof(int) = %d !!!\n", sizeof(int));
+ return;
+ }
+ int dum32;
+
+
+
+ char hname[256], htitle[256];
+ TH1F *htdc[2][NCH], *hadc_hg[NCH], *hadc_lg[NCH];
+
+ //opens ROOT file
+ TFile *rootfile; char fnameroot[256];
+ sprintf(fnameroot, "root/%s.root", dfile0);
+ //rootfile = (TFile *) gROOT->FindObjectAny(dfile0);
+ //if (rootfile!=NULL) {printf("!!!\n");rootfile->Close();}
+ //rootfile = new TFile(fnameroot);
+ //if(rootfile) rootfile->Close();
+ rootfile = new TFile(fnameroot,"RECREATE",dfile0);
+
+ for(int i=0; i<NCH; i++) {
+ sprintf(hname, "htdc_le_%d", i);
+ htdc[0][i] = (TH1F*)gROOT->FindObject(hname);
+ if(htdc[0][i]) delete htdc[0][i];
+ htdc[0][i] = new TH1F(hname, hname, 256, -0.5, 255.5);
+
+ sprintf(hname, "htdc_te_%d", i);
+ htdc[1][i] = (TH1F*)gROOT->FindObject(hname);
+ if(htdc[1][i]) delete htdc[1][i];
+ htdc[1][i] = new TH1F(hname, hname, 256, -0.5, 255.5);
+
+ sprintf(hname, "hadc_hg%d", i);
+ hadc_hg[i] = (TH1F*)gROOT->FindObject(hname);
+ if(hadc_hg[i]) delete hadc_hg[i];
+ hadc_hg[i] = new TH1F(hname, hname, 4096, -0.5, 4095.5);
+
+ sprintf(hname, "hadc_lg%d", i);
+ hadc_lg[i] = (TH1F*)gROOT->FindObject(hname);
+ if(hadc_lg[i]) delete hadc_lg[i];
+ hadc_lg[i] = new TH1F(hname, hname, 4096, -0.5, 4095.5);
+ }
+
+ // ------------- data ----------------------------------------------------
+
+ int ceve = 0;
+ while(!feof(dfp)) {
+ fread( &dum32, sizeof(int), 1, dfp);
+
+ int hw1 = (dum32 >> 16) & 0xFFFF;
+ int hw2 = dum32 & 0xFFFF;
+ if( (hw1 == HEADER_WORD_1) && (hw2 == HEADER_WORD_2) ) {
+ fread( &dum32, sizeof(int), 1, dfp);
+ int Number_of_word = dum32 & 0xFFFF;
+ fread( &dum32, sizeof(int), 1, dfp);
+ int EventCounter = (dum32 >> 16) & 0xFFFF;
+ if(dbg) printf("\n>>>>>> Number_of_word = %d | EventCounter = %d\n", Number_of_word, EventCounter);
+ //~ else if( !(EventCounter%PRINT_FREQUENCY) ) printf(" EventConter = %d\n", EventCounter);
+ else if( !(EventCounter%PRINT_FREQUENCY) ) printf(".");
+ ceve++;
+ continue;
+ }
+
+ int id = (dum32 >> 24) & 0xFF;
+ int ch, overflow, edge, data;
+ switch(id) {
+ case ID_ADC_HG:
+ ch = (dum32 >> 16) & 0x1F;
+ overflow = (dum32 >> 13) & 0x1;
+ data = (dum32) & 0xFFF;
+ //~ printf("ID_ADC_HG: ch = %d | X = %d | data = %d\n", ch, overflow, data);
+ if(dbg) printf("HG[%2d]=%4d ", ch, data);
+ hadc_hg[ch]->Fill(data);
+ break;
+ case ID_ADC_LG:
+ ch = (dum32 >> 16) & 0x1F;
+ overflow = (dum32 >> 13) & 0x1;
+ data = (dum32) & 0xFFF;
+ //~ printf("ID_ADC_LG: ch = %d | X = %d | data = %d\n", ch, overflow, data);
+ if(dbg) printf("LG[%2d]=%4d ", ch, data);
+ hadc_lg[ch]->Fill(data);
+ break;
+ case ID_TDC:
+ ch = (dum32 >> 16) & 0x1F;
+ edge = (dum32 >> 15) & 0x1;
+ data = (dum32) & 0x3FFF;
+ printf("ID_TDC: ch = %d | X = %d | data = %d\n", ch, overflow, data);
+ if(edge < 2) htdc[edge][ch]->Fill(data);
+ break;
+ default:
+ printf("default: dum32 = 0x%X!!!\n", dum32);
+ break;
+ }
+ //~ ceve++;
+ //~ if( !(ceve%PRINT_FREQUENCY) ) printf(".");
+ if(dbg && (ceve > dbg) ) break;
+ }
+ printf("\nProcessed events = %d\n", ceve);
+
+ // ------------------------------------------------------------------------
+
+ if(dfp) fclose(dfp);
+
+ if(dbg) return;
+ if(rootfile) {
+ rootfile->Write();
+ printf("Saved to %s\n", fnameroot);
+ rootfile->Close();
+ }
+
+ gSystem->Exit(1);
+}
Index: l2d2_easyroc/Analysis/Analysis/e2r_cpp.d
===================================================================
--- l2d2_easyroc/Analysis/Analysis/e2r_cpp.d (nonexistent)
+++ l2d2_easyroc/Analysis/Analysis/e2r_cpp.d (revision 291)
@@ -0,0 +1,69 @@
+
+# DO NOT DELETE
+
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TROOT.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TDirectory.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TNamed.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TObject.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/Rtypes.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/RConfig.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/RVersion.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/DllImport.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/Rtypeinfo.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/snprintf.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/strlcpy.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TGenericClassInfo.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TSchemaHelper.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TStorage.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TVersionCheck.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/Riosfwd.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TBuffer.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TString.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TMathBase.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TList.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TSeqCollection.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TCollection.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TIterator.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TDatime.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TUUID.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TSystem.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TInetAddress.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TTimer.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TSysEvtHandler.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TQObject.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TTime.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TFile.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TDirectoryFile.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TMap.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/THashTable.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TUrl.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TH1F.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TH1.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TAxis.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TAttAxis.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TArrayD.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TArray.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TAttLine.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TAttFill.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TAttMarker.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TArrayC.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TArrayS.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TArrayI.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TArrayF.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/Foption.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TVectorFfwd.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TVectorDfwd.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TFitResultPtr.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TH2F.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TH2.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TMatrixFBasefwd.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TMatrixDBasefwd.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TF1.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TFormula.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TBits.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TObjArray.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/Math/ParamFunctor.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TMath.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/TError.h
+./e2r_cpp.so: /home/rok/root-v5-34-00-patches/include/cintdictversion.h /home/rok/root-v5-34-00-patches/include/RVersion.h
+e2r_cpp__ROOTBUILDVERSION= 5.34/08
Index: l2d2_easyroc/Analysis/Analysis/gif/Canvas_1.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/l2d2_easyroc/Analysis/Analysis/gif/Canvas_1.gif
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/Analysis/Analysis/root/rok1.root
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/l2d2_easyroc/Analysis/Analysis/root/rok1.root
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/Analysis/Analysis/root/rok2.root
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/l2d2_easyroc/Analysis/Analysis/root/rok2.root
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/Analysis/Analysis/root/rok3.root
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/l2d2_easyroc/Analysis/Analysis/root/rok3.root
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/Analysis/Canvas_1.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/l2d2_easyroc/Analysis/Canvas_1.gif
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/Analysis/e2r.cpp
===================================================================
--- l2d2_easyroc/Analysis/e2r.cpp (nonexistent)
+++ l2d2_easyroc/Analysis/e2r.cpp (revision 291)
@@ -0,0 +1,144 @@
+#include "stdio.h"
+#include "TROOT.h"
+#include "TSystem.h"
+#include "TFile.h"
+#include "TH1F.h"
+#include "TH2F.h"
+#include "TF1.h"
+#include "TMath.h"
+
+#define NCH 32
+
+#define HEADER_WORD_1 0xFFFF
+#define HEADER_WORD_2 0xEA0C
+#define ID_ADC_HG 0x81
+#define ID_ADC_LG 0x60
+#define ID_TDC 0xCC
+#define PRINT_FREQUENCY 10000
+
+void e2r(char* dfile0="test", int dbg=0)
+{
+ char fullname[256], sbuff[256];
+
+ FILE *dfp;
+ char dfile[256];
+ sprintf(dfile, "data/%s", dfile0);
+
+ if((dfp=fopen(dfile,"rb")) == NULL) {
+ printf("Cannot open data file %s !!!\n", dfile);
+ return;
+ } else {
+ printf("Opened data file %s.\n", dfile);
+ }
+
+ if(sizeof(int) != 4) {
+ printf("sizeof(int) != 4, sizeof(int) = %d !!!\n", sizeof(int));
+ return;
+ }
+ int dum32;
+
+
+
+ char hname[256], htitle[256];
+ TH1F *htdc[2][NCH], *hadc_hg[NCH], *hadc_lg[NCH];
+
+ //opens ROOT file
+ TFile *rootfile; char fnameroot[256];
+ sprintf(fnameroot, "root/%s.root", dfile0);
+ //rootfile = (TFile *) gROOT->FindObjectAny(dfile0);
+ //if (rootfile!=NULL) {printf("!!!\n");rootfile->Close();}
+ //rootfile = new TFile(fnameroot);
+ //if(rootfile) rootfile->Close();
+ rootfile = new TFile(fnameroot,"RECREATE",dfile0);
+
+ for(int i=0; i<NCH; i++) {
+ sprintf(hname, "htdc_le_%d", i);
+ htdc[0][i] = (TH1F*)gROOT->FindObject(hname);
+ if(htdc[0][i]) delete htdc[0][i];
+ htdc[0][i] = new TH1F(hname, hname, 256, -0.5, 255.5);
+
+ sprintf(hname, "htdc_te_%d", i);
+ htdc[1][i] = (TH1F*)gROOT->FindObject(hname);
+ if(htdc[1][i]) delete htdc[1][i];
+ htdc[1][i] = new TH1F(hname, hname, 256, -0.5, 255.5);
+
+ sprintf(hname, "hadc_hg%d", i);
+ hadc_hg[i] = (TH1F*)gROOT->FindObject(hname);
+ if(hadc_hg[i]) delete hadc_hg[i];
+ hadc_hg[i] = new TH1F(hname, hname, 4096, -0.5, 4095.5);
+
+ sprintf(hname, "hadc_lg%d", i);
+ hadc_lg[i] = (TH1F*)gROOT->FindObject(hname);
+ if(hadc_lg[i]) delete hadc_lg[i];
+ hadc_lg[i] = new TH1F(hname, hname, 4096, -0.5, 4095.5);
+ }
+
+ // ------------- data ----------------------------------------------------
+
+ int ceve = 0;
+ while(!feof(dfp)) {
+ fread( &dum32, sizeof(int), 1, dfp);
+
+ int hw1 = (dum32 >> 16) & 0xFFFF;
+ int hw2 = dum32 & 0xFFFF;
+ if( (hw1 == HEADER_WORD_1) && (hw2 == HEADER_WORD_2) ) {
+ fread( &dum32, sizeof(int), 1, dfp);
+ int Number_of_word = dum32 & 0xFFFF;
+ fread( &dum32, sizeof(int), 1, dfp);
+ int EventCounter = (dum32 >> 16) & 0xFFFF;
+ if(dbg) printf("\n>>>>>> Number_of_word = %d | EventCounter = %d\n", Number_of_word, EventCounter);
+ //~ else if( !(EventCounter%PRINT_FREQUENCY) ) printf(" EventConter = %d\n", EventCounter);
+ else if( !(EventCounter%PRINT_FREQUENCY) ) printf(".");
+ ceve++;
+ continue;
+ }
+
+ int id = (dum32 >> 24) & 0xFF;
+ int ch, overflow, edge, data;
+ switch(id) {
+ case ID_ADC_HG:
+ ch = (dum32 >> 16) & 0x1F;
+ overflow = (dum32 >> 13) & 0x1;
+ data = (dum32) & 0xFFF;
+ //~ printf("ID_ADC_HG: ch = %d | X = %d | data = %d\n", ch, overflow, data);
+ if(dbg) printf("HG[%2d]=%4d ", ch, data);
+ hadc_hg[ch]->Fill(data);
+ break;
+ case ID_ADC_LG:
+ ch = (dum32 >> 16) & 0x1F;
+ overflow = (dum32 >> 13) & 0x1;
+ data = (dum32) & 0xFFF;
+ //~ printf("ID_ADC_LG: ch = %d | X = %d | data = %d\n", ch, overflow, data);
+ if(dbg) printf("LG[%2d]=%4d ", ch, data);
+ hadc_lg[ch]->Fill(data);
+ break;
+ case ID_TDC:
+ ch = (dum32 >> 16) & 0x1F;
+ edge = (dum32 >> 15) & 0x1;
+ data = (dum32) & 0x3FFF;
+ printf("ID_TDC: ch = %d | X = %d | data = %d\n", ch, overflow, data);
+ if(edge < 2) htdc[edge][ch]->Fill(data);
+ break;
+ default:
+ printf("default: dum32 = 0x%X!!!\n", dum32);
+ break;
+ }
+ //~ ceve++;
+ //~ if( !(ceve%PRINT_FREQUENCY) ) printf(".");
+ if(dbg && (ceve > dbg) ) break;
+ }
+ printf("\nProcessed events = %d\n", ceve);
+
+ // ------------------------------------------------------------------------
+
+ if(dfp) fclose(dfp);
+
+ if(dbg) return;
+ if(rootfile) {
+ rootfile->Write();
+ printf("Saved to %s\n", fnameroot);
+ rootfile->Close();
+ }
+
+ gSystem->Exit(1);
+}
Index: l2d2_easyroc/Developer Command Prompt for VS2013.lnk
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/l2d2_easyroc/Developer Command Prompt for VS2013.lnk
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/DrootHelper.cpp
===================================================================
--- l2d2_easyroc/DrootHelper.cpp (nonexistent)
+++ l2d2_easyroc/DrootHelper.cpp (revision 291)
@@ -0,0 +1,92 @@
+//#include "DrootHelper.cpp"
+
+#include "TROOT.h"
+#include "TStyle.h"
+#include "TDirectory.h"
+#include "TH1F.h"
+#include "TH2F.h"
+
+double fontsiz = 0.04;
+
+int legmark[] = {kFullTriangleDown,kFullTriangleUp,kFullSquare,kFullTriangleDown,kFullTriangleUp,kFullSquare,kFullCircle,kOpenCircle,kPlus};
+int legcol[] = {kBlack,kGray+1,kGray+2,kBlack,kGray+1,kGray+2,kBlack,40,6};
+int legsty[] = {1,7,2,1,7,2,9,5,6};
+
+void DrSetDrawStyle(double fntsz = 0.04) {
+ // set draw style
+ gStyle->SetOptStat("ne");
+ gStyle->SetPalette(1, 0);
+
+ gStyle->SetPaperSize(TStyle::kA4);
+ gStyle->SetStatBorderSize(1);
+ gStyle->SetFrameBorderMode(0);
+ gStyle->SetFrameFillColor(0);
+ gStyle->SetTitleFillColor(0);
+ gStyle->SetCanvasBorderMode(0);
+ gStyle->SetPadBorderMode(0);
+ gStyle->SetPadColor(0);
+ gStyle->SetCanvasColor(0);
+ gStyle->SetStatColor(0);
+ gStyle->SetOptFit(11);
+ gStyle->SetPadRightMargin(0.1);
+ gStyle->SetPadLeftMargin(0.08);
+ gStyle->SetPadRightMargin(0.1);
+ gStyle->SetPadLeftMargin(0.12);
+
+ gStyle->SetPadTopMargin(0.11);
+ gStyle->SetPadBottomMargin(0.16);
+ gStyle->SetTitleOffset(1.2, "x");
+ gStyle->SetLabelOffset(0.02, "x");
+ //~ gStyle->SetPadLeftMargin(0.12);
+ gStyle->SetPadLeftMargin(0.10);
+ gStyle->SetTitleOffset(0.9, "y");
+ gStyle->SetPadRightMargin(0.10);
+
+ gStyle->SetTitleFontSize(0.07);
+ gStyle->SetTitleBorderSize(0);
+ gStyle->SetTitleX(0.4);
+
+ fontsiz = fntsz;
+ gStyle->SetStatFontSize(fontsiz+0.015);
+ //hp1d->SetLabelSize(fontsiz, "xy");
+ //hp1d->SetTitleSize(fontsiz, "xy");
+}
+
+TH1F *DrTH1F(TDirectory *drdir, char *drhname, char *drhtitle="")
+{
+ TH1F *drhp1d = NULL;
+
+ drhp1d = (TH1F *)drdir->Get(drhname);
+ drhp1d->SetTitle(drhtitle);
+ drhp1d->SetLabelSize(fontsiz*0.8, "xy");
+ drhp1d->SetTitleSize(fontsiz, "xy");
+
+ return drhp1d;
+}
+
+TH2F *DrTH2F(TDirectory *drdir, char *drhname, char *drhtitle="")
+{
+ TH2F *drhp2d = NULL;
+
+ drhp2d = (TH2F *)drdir->Get(drhname);
+ drhp2d->SetTitle(drhtitle);
+ drhp2d->SetLabelSize(fontsiz*0.8, "xyz");
+ drhp2d->SetTitleSize(fontsiz, "xyz");
+
+ return drhp2d;
+}
+
+void DrNull(double x0, double y0, double x1, double y1, char *drhtitle="", int ndiv=-1, double fontfrac=1.0)
+{
+ TH1F *drhp1d = new TH1F("",drhtitle,100, x0, x1);
+
+ drhp1d->GetXaxis()->SetRangeUser(x0, x1);
+ drhp1d->GetYaxis()->SetRangeUser(y0, y1);
+ drhp1d->SetLabelSize(fontsiz*fontfrac*0.9, "xyz");
+ drhp1d->SetTitleSize(fontsiz*fontfrac, "xyz");
+ if(ndiv>0) (drhp1d->GetYaxis())->SetNdivisions(ndiv);
+ drhp1d->DrawClone();
+
+ delete drhp1d;
+}
+
Index: l2d2_easyroc/README.txt
===================================================================
--- l2d2_easyroc/README.txt (nonexistent)
+++ l2d2_easyroc/README.txt (revision 291)
@@ -0,0 +1,28 @@
+Uporaba analize:
+
+1) Datoteko s podatki (npr. test_file01.dat) mora biti v ...analiza\data direktoriju
+2) V ukazni vrstici, v kateri bo deloval ROOT zaženeš ukaze:
+
+root -l "d2r.cpp+(\"test\")"
+oz .x d2r.cpp+("test")
+
+kjer je "test" del imena datoteke pred _file01.dat. Program ustvari .root file v ...analiza\root direktoriju.
+
+
+root -l "plots2.cpp(\"test\",\"a\")"
+
+kjer je drugi parameter (a) lahko:
+a: slika porazdelitve naboja in èasa
+d: razlika v izmerjenih èasih (koincidenèni timing)
+t: èasovna loèljivost na kanalu 0 (za meritve z laserjem)
+e: analiza za meritev uèinkovitosti zaznavanja (za meritve z referenènim BGO detektorjem)
+
+3) Za nataène meritve èasa je potrebna še time-walk korekcija:
+
+root -l "d2r.cpp+(\"test\")"
+root -l "cor.cpp(\"test\", 1,64,10,10)"
+root -l "d2r.cpp+(\"test\")"
+root -l "plots2.cpp(\"test\",\"d\")"
+
+Najprej je potrebno zagnati d2r.cpp, da naredi root file. Potem cor.cpp izraèuna popravke in jih shrani v txt file v ...analiza\data direktorij. Te popravke nato uporabiš ko znova zaženeš d2r.cpp.
+
Index: l2d2_easyroc/SiTCP.c
===================================================================
--- l2d2_easyroc/SiTCP.c (nonexistent)
+++ l2d2_easyroc/SiTCP.c (revision 291)
@@ -0,0 +1,207 @@
+#include "SiTCP.h"
+//------------------------------------------------------------------------------------------------------
+void SiTCPinit(){
+ printf("SiTCP control --> Start.\n");
+ WORD wVersionRequested;
+ WSADATA wsaData;
+ int err;
+
+/* Use the MAKEWORD(lowbyte, highbyte) macro declared in Windef.h */
+ wVersionRequested = MAKEWORD(2, 2);
+
+ err = WSAStartup(wVersionRequested, &wsaData);
+ if (err != 0) {
+ /* Tell the user that we could not find a usable */
+ /* Winsock DLL. */
+ printf("WSAStartup failed with error: %d\n", err);
+ }
+};
+//------------------------------------------------------------------------------------------------------
+void SiTCPclose(){
+ WSACleanup();
+ printf("SiTCPclose -> Done.\n");
+};
+//------------------------------------------------------------------------------------------------------
+int SiTCPSetIPPort(char* IpAddr, unsigned int tcp, unsigned int udp){
+ sitcpIpAddr = IpAddr;
+ if(tcp<=0 || 65535<=tcp || udp<=0 || 65535<=udp){
+ if(tcp<=0 || 65535<=tcp){
+ printf("error : invalid port : tcp = %u\n", tcp);
+ }
+ if(udp<=0 || 65535<=udp){
+ printf("error : invalid port : udp = %u\n", udp);
+ }
+ printf("exit(1);!!!\n");
+ }
+ tcpPort = tcp;
+ udpPort = udp;
+ puts("");
+ printf("SiTCP:IP Address = %s\n", sitcpIpAddr);
+ printf(" TCP Port = %u\n", tcpPort);
+ printf(" UDP Port = %u\n", udpPort);
+ puts("");
+ return 1;
+}
+//------------------------------------------------------------------------------------------------------
+int SiTCPCreateTCPSock(){
+ printf("Create socket for TCP...");
+ tcpsock = socket(AF_INET, SOCK_STREAM, 0);
+ if(tcpsock < 0){
+ perror("TCP socket");
+ printf("errno = %d\n", errno);
+ printf("exit(1);!!!\n");
+ }
+ memset(&tcpAddr, 0, sizeof(tcpAddr));
+ tcpAddr.sin_family = AF_INET;
+ tcpAddr.sin_port = htons(tcpPort);
+ tcpAddr.sin_addr.s_addr = inet_addr(sitcpIpAddr);
+ printf(" Done\n");
+
+ printf(" ->Trying to connect to %s ...\n", sitcpIpAddr);
+ if(connect(tcpsock, (struct sockaddr *)&tcpAddr, sizeof(tcpAddr)) < 0){
+ if(errno != EINPROGRESS) perror("TCP connection");
+ FD_ZERO(&rmask);
+ FD_SET(tcpsock, &rmask);
+ wmask = rmask;
+ timeout.tv_sec = 3;
+ timeout.tv_usec = 0;
+
+ int rc = select(tcpsock+1, &rmask, NULL, NULL, &timeout);
+ if(rc<0) perror("connect-select error");
+ if(rc==0){
+ puts("\n =====time out !=====\n ");
+ printf("exit(1);!!!\n");
+ }
+ else{
+ puts("\n ===connection error===\n ");
+ printf("exit(1);!!!\n");
+ }
+ }
+ FD_ZERO(&readfds);
+ FD_SET(tcpsock, &readfds);
+ FD_SET(0, &readfds);
+
+ puts(" ->Connect success!");
+
+ return 1;
+ }
+ //------------------------------------------------------------------------------------------------------
+ int SiTCPCreateUDPSock(){
+ printf("Create socket for RBCP...");
+ udpsock = socket(AF_INET, SOCK_DGRAM, 0);
+ //if(udpsock < 0){
+ if(udpsock == INVALID_SOCKET){
+ //perror("UDP socket");
+ //printf("errno = %d | udpsock = %d\n", errno, udpsock);
+ printf("errno = %d | udpsock = %d\n", WSAGetLastError(), udpsock);
+ printf("exit(1);!!!\n");
+ }
+ memset(& SiTCPudpAddr, 0, sizeof( SiTCPudpAddr));
+ SiTCPudpAddr.sin_family = AF_INET;
+ SiTCPudpAddr.sin_port = htons(udpPort);
+ SiTCPudpAddr.sin_addr.s_addr = inet_addr(sitcpIpAddr);
+ printf(" Done\n");
+ return 1;
+ }
+ //------------------------------------------------------------------------------------------------------
+ int SiTCPCloseUDPSock(){
+ printf("Close UDP Socket...");
+ closesocket(udpsock);
+ printf(" Done\n");
+ return 1;
+ }
+ //------------------------------------------------------------------------------------------------------
+ int SiTCPCloseTCPSock(){
+ printf("Close TCP Socket...");
+ closesocket(tcpsock);
+ printf(" Done\n");
+ return 1;
+ }
+ //------------------------------------------------------------------------------------------------------
+ void SiTCPRBCPskeleton(unsigned char type, unsigned char command, unsigned char id,
+ unsigned char length, unsigned int address){
+ SiTCPsndHeader.type=type;
+ SiTCPsndHeader.command=command;
+ SiTCPsndHeader.id=id;
+ SiTCPsndHeader.length=length;
+ SiTCPsndHeader.address=htonl(address);
+ memcpy(SiTCPsndBuf, &SiTCPsndHeader, sizeof(SiTCPsndHeader));
+}
+//------------------------------------------------------------------------------------------------------
+int SiTCPrcvRBCP_ACK(int output){
+//printf("hogeeeee0");
+ fd_set setSelect;
+ int rcvdBytes;
+ unsigned char rcvdBuf[1024];
+ int rd_data;
+
+ // puts("\nWait to receive the ACK packet...");
+
+ int recvVal = 1;
+
+ while(recvVal){
+//printf("hogeeeee1");
+ FD_ZERO(&setSelect);
+//printf("hogeeeee2");
+ FD_SET(udpsock, &setSelect);
+//printf("hogeeeee3");
+ timeout.tv_sec = 3;
+ timeout.tv_usec = 0;
+//printf("hogeeeee4");
+ if(select(udpsock+1, &setSelect, NULL, NULL,&timeout)==0){
+ // time out
+//printf("hogeeeee5");
+ recvVal = 0;
+ puts("\n***** Timeout ! *****");
+//printf("hogeeeee6");
+ return -1;
+ }
+ else {
+ // receive packet
+//printf("hogeeeee7");
+ if(FD_ISSET(udpsock,&setSelect)){
+//printf("hogeeeee8");
+ //rcvdBytes=recvfrom(udpsock, rcvdBuf, 2048, 0, NULL, NULL);
+ rcvdBytes=recvfrom(udpsock, rcvdBuf, 1024, 0, NULL, NULL);
+ if(rcvdBytes < 0) {
+ Sleep(1000);
+ rcvdBytes=recvfrom(udpsock, rcvdBuf, 1024, 0, NULL, NULL);
+ }
+//printf("hogeeee88");
+ rcvdBuf[rcvdBytes]=0;
+ if(output == 1){
+ //puts("\n***** A pacekt is received ! *****.");
+ //puts("Received data:");
+//printf("hogeeeee9");
+ int j=0;
+ for(int i=0; i<rcvdBytes; i++){
+ if(j==0) {
+//printf("hogeeeee10");
+ //printf("\t[%.3x]:%.2x ",i,rcvdBuf[i]);
+ j++;
+ }else if(j==3){
+//printf("hogeeeee11");
+ //printf("%.2x \n",rcvdBuf[i]);
+ j=0;
+ }else{
+//printf("hogeeeee12");
+ //printf("%.2x ",rcvdBuf[i]);
+ j++;
+ }
+ }
+ //puts("\n");
+ rd_data = rcvdBuf[8];
+ }
+ recvVal = 0;
+ }
+ }
+ }
+ // printf("%.2x",rd_data);
+ return rd_data;
+ //usleep(50);
+}
+//------------------------------------------------------------------------------------------------------
+int SiTCPGetTCPSock(){return tcpsock;}
+int SiTCPGetUDPSock(){return udpsock;}
+struct bcp_header SiTCPGetSiTCPsndHeader() {return SiTCPsndHeader;}
+
Index: l2d2_easyroc/SiTCP.h
===================================================================
--- l2d2_easyroc/SiTCP.h (nonexistent)
+++ l2d2_easyroc/SiTCP.h (revision 291)
@@ -0,0 +1,66 @@
+#ifndef SiTCP_H
+#define SiTCP_H
+
+//#include<iostream>
+#include<stdio.h>
+#include<stdlib.h>
+#include<errno.h>
+//#include<string>
+//#include<cstring>
+//#include<arpa/inet.h>
+#include <Winsock2.h>
+//#include<fstream>
+
+//#include<unistd.h>
+
+#define EINPROGRESS 115 /* Operation now in progress */
+
+struct bcp_header{
+ unsigned char type;
+ unsigned char command;
+ unsigned char id;
+ unsigned char length;
+ unsigned int address;
+};
+
+
+char* sitcpIpAddr;
+unsigned int tcpPort;
+unsigned int udpPort;
+int udpsock;
+int tcpsock;
+struct sockaddr_in tcpAddr;
+// struct sockaddr_in udpAddr;
+
+fd_set rmask, wmask, readfds;
+struct timeval timeout;
+//struct bcp_header sndHeader;
+//unsigned char sndBuf[2048];
+
+struct bcp_header SiTCPsndHeader;
+unsigned char SiTCPsndBuf[2048];
+unsigned char SiTCPsndData[256];
+struct sockaddr_in SiTCPudpAddr;
+
+void SiTCPinit();
+void SiTCPclose();
+int SiTCPSetIPPort(char* IpAddr, unsigned int tcp, unsigned int udp);
+int SiTCPCreateUDPSock();
+int SiTCPCloseUDPSock();
+int SiTCPCreateTCPSock();
+int SiTCPCloseTCPSock();
+
+//int GetTCPSock(){return tcpsock;}
+//int GetUDPSock(){return udpsock;}
+int SiTCPGetTCPSock();
+int SiTCPGetUDPSock();
+
+void SiTCPRBCPskeleton(unsigned char type, unsigned char command, unsigned char id,
+ unsigned char length, unsigned int address);
+
+int SiTCPrcvRBCP_ACK(int output);
+
+struct bcp_header SiTCPGetsndHeader();
+ //bcp_header GetsndHeader() const {return sndHeader;}
+
+#endif
Index: l2d2_easyroc/cor.cpp
===================================================================
--- l2d2_easyroc/cor.cpp (nonexistent)
+++ l2d2_easyroc/cor.cpp (revision 291)
@@ -0,0 +1,337 @@
+#include "TROOT.h"
+#include "TFile.h"
+#include "TBenchmark.h"
+#include "TH1F.h"
+#include "TH2F.h"
+#include "TCanvas.h"
+#include "TStyle.h"
+#include "TPad.h"
+#include "TF1.h"
+#include "TGraph.h"
+#include "TSpectrum.h"
+#include "TGraphErrors.h"
+#include "TSystem.h"
+#include "TMath.h"
+
+#define COROUT
+#define SHOW_SLICES
+#define NCH 20
+#define USED_CH 2
+#define TDC_BIN (25./1000.) //1 TDC bin in ns
+//~ #define FIRST_CH 0
+
+double g_corpars[NCH][3];
+
+int mapii[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,11,12,13,14,15,16,17,18,19 };
+int mapij[] = { 1, 0,16,16,16,16,16,16,16,16, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 };
+
+// root -l "cor.cpp(\"run045\",64,1,20,\"s\")"
+void cor(char *fname="cscan3", int range=1, const int nslicex=64, int slmin=1, const int projmin=5, char *fite="s")
+{
+ double fitw=1.0;
+ char skip='n';
+ char fullname[256];
+
+ //get ROOT file with histograms
+ char fnameroot[1024];
+ TFile * rootfile;
+ TDirectory *dir;
+
+ sprintf(fnameroot, "root/%s.root", fname);
+ rootfile = (TFile *) gROOT->FindObject(fname);
+ if(rootfile==NULL) rootfile = new TFile(fnameroot);
+ if(rootfile==NULL) {
+ printf("Cannot open root file %s!!!\n",fnameroot);
+ return;
+ }
+ dir = (TDirectory*) rootfile;
+
+
+ // set draw style
+ gStyle->SetOptStat("ne");
+ gStyle->SetPalette(1, 0);
+
+ gStyle->SetPaperSize(TStyle::kA4);
+ gStyle->SetStatBorderSize(1);
+ gStyle->SetFrameBorderMode(0);
+ gStyle->SetFrameFillColor(0);
+ gStyle->SetCanvasBorderMode(0);
+ gStyle->SetPadBorderMode(0);
+ gStyle->SetPadColor(0);
+ gStyle->SetCanvasColor(0);
+ gStyle->SetStatColor(0);
+ gStyle->SetOptFit(11);
+
+ gStyle->SetPadRightMargin(0.1);
+
+ char hname[256];
+ TH1F *hp1d; TH2F *hp2d;
+
+ int ch=0;
+ int nbinsx, deltax, bin0, bin1;
+ double binc;
+ TH1F *hprojx[nslicex];
+
+ TF1 *f_fit = 0;
+ TF1 *fg = new TF1("fg", "gaus(0)");
+ fg->SetParNames("Constant","Mean","Sigma");
+ TF1 *fgg = new TF1("fgg", "gaus(0)+gaus(3)");
+ fgg->SetParNames("Constant","Mean","Sigma","Constant2","Mean2","Sigma2");
+ TF1 *fggg = new TF1("fgg", "gaus(0)+gaus(3)+gaus(6)");
+ fggg->SetParNames("Constant","Mean","Sigma","Constant2","Mean2","Sigma2","Constant3","Mean3","Sigma3");
+ TF1 *fitsqrt = new TF1("fitsqrt","[0]+[1]/TMath::Sqrt(x-[2])");
+
+ TF1 *fcg = new TF1("fcg", "pol0(0)+gaus(1)");
+ fcg->SetParNames("C", "Constant","Mean","Sigma");
+
+ TF1 *fcgg = new TF1("fcgg", "pol0(0)+gaus(1)+gaus(4)");
+ fcgg->SetParName(0,"Const");
+ fcgg->SetParName(1,"G1_Const"); fcgg->SetParName(2,"G1_Mean" ); fcgg->SetParName(3,"G1_Sigma" );
+ fcgg->SetParName(4,"G2_Const"); fcgg->SetParName(5,"G2_Mean" ); fcgg->SetParName(6,"G2_Sigma" );
+
+ TGraphErrors *gcor[NCH];
+ double fitcenter, fitampl;
+
+ double fitsigmas[2];
+ int fitminsigmai;
+ double fiterror, fitmean;
+
+#ifdef COROUT
+ FILE *fp;
+ //open file to save parameters
+ sprintf(fullname, "data/%s_cor.txt", fname);
+ if( (fp=fopen(fullname, "wt")) == NULL )
+ printf("Cannot create parameter file %s !!!\n", fullname);
+ else
+ printf("Created parameter file %s\n", fullname);
+#endif
+
+
+ TCanvas *c1 = new TCanvas("Cor.Fits", "Cor.Fits", 0, 0, 1300, 450);
+ c1->Divide(2,1);
+
+
+#ifdef SHOW_SLICES
+ TCanvas *c0 = new TCanvas("Slices", "Slices", 0, 520, 1300, 470);
+ c0->Divide(5,5);
+#endif
+ const int c0pads = 25;
+
+
+ if(nslicex==0) {
+#ifdef COROUT
+ for(int j=0;j<NCH; j++) fprintf(fp,"%lf %lf %lf\n", 0.0,0.005,0.0);
+ gSystem->Exit(1);
+ return;
+#endif
+ } else {
+#ifdef FIRST_CH
+ ch=FIRST_CH;
+#else
+ for(ch=0;ch<USED_CH; ch++)
+#endif
+ {
+
+ gcor[ch] = new TGraphErrors(nslicex);
+ sprintf(hname,"TDC Corection ch%d;QDC;TDC [ps]",ch);
+ gcor[ch]->SetTitle(hname);
+ if(range == 0) {
+ sprintf(hname, "hdiffcor_low_%d_%d",mapii[ch],mapij[ch]); hp2d = (TH2F *) dir->Get(hname);
+ } else if(range == 2) {
+ sprintf(hname, "hdiffcor_hi_%d_%d",mapii[ch],mapij[ch]); hp2d = (TH2F *) dir->Get(hname);
+ } else {
+ sprintf(hname, "hdiffcor_%d_%d",mapii[ch],mapij[ch]); hp2d = (TH2F *) dir->Get(hname);
+ }
+ //~ sprintf(hname, "hcor%d",ch); hp2d = (TH2F *) dir->Get(hname);
+ nbinsx=hp2d->GetNbinsX();
+ deltax=nbinsx/nslicex;
+
+ c0->Clear();c0->Divide(8,4);
+ for(int i=slmin; i<nslicex; i++) {
+ bin0=i*deltax+1;
+ bin1=(i+1)*deltax+1;
+ binc=(hp2d->GetXaxis()->GetBinCenter(bin0)+hp2d->GetXaxis()->GetBinCenter(bin1))/2.0;
+
+ sprintf(hname, "hprojx%d",i);
+ hprojx[i]=(TH1F*)hp2d->ProjectionY(hname, bin0, bin1);
+
+ //~ (hprojx[i]->GetXaxis())->SetRangeUser(-1, 2);
+ if( hprojx[i]->GetMaximum() > projmin ) {
+
+ fitcenter = hprojx[i]->GetBinCenter(hprojx[i]->GetMaximumBin());
+ fitampl = hprojx[i]->GetMaximum();
+
+//------/
+ if(i<1024) {
+
+ //~ if( (ch<8) && (i<3) && (fitcenter < 0.4) ) fitcenter = 0.7;
+
+ f_fit = fcg;
+ f_fit->SetParameters(fitampl*0.1, fitampl*0.9, fitcenter, 0.1);
+ //~
+ //~ f_fit = fcgg;
+ //~ f_fit->SetParameters(fitampl*0.01,
+ //~ fitampl*0.4, 0, 0.4,
+ //~ fitampl*0.4, 0, 0.2);
+
+ //~ f_fit = fgg;
+ //~ f_fit->SetParameters(fitampl*0.9, fitcenter, 0.1, fitampl*0.1, fitcenter, 0.5);
+ //~
+ //~ f_fit = fg;
+ //~ f_fit->SetParameters(fitampl*0.9, fitcenter, 0.1);
+
+ //~ f_fit->SetParLimits(0, 0, fitampl*3);
+
+ #ifdef SHOW_SLICES
+ c0->cd(i%c0pads + 1); //c0->cd(i%4 + 1)->SetLogy();
+ //~ hprojx[i]->Fit(f_fit,"QL", "", fitcenter-1.0*fitw, fitcenter+0.5*fitw);
+ hprojx[i]->Fit(f_fit,"QL", "");
+ //c0->Update();
+ //if( !((i+1)%9) && (skip!='y') ) {c0->Update(); printf("Skip?: "); scanf("%c",&skip);}
+ //if( (skip=='q') || (skip=='Q') ) return;
+ //hprojx[i]->DrawClone();
+ //fgg->SetRange(-1,2);
+ //fgg->DrawClone("LSAME");
+ #else
+ //~ hprojx[i]>Fit(fgg,"0QL", "", fitcenter-1.0*fitw, fitcenter+2.0*fitw);
+ hprojx[i]->Fit(f_fit,"0QL", "");
+ #endif
+
+ //~ fitsigmas[0] = TMath::Abs(f_fit->GetParameter(2));
+ //~ fitsigmas[1] = TMath::Abs(f_fit->GetParameter(5));
+ //~ fitminsigmai = TMath::LocMin(2,fitsigmas);
+ //~ fitmean = f_fit->GetParameter(1 + fitminsigmai*3);
+ //~ fiterror = TMath::Abs(f_fit->GetParameter(2 + fitminsigmai*3));
+ //~ printf("fitminsigmai = %d {%lf, %lf}\n", fitminsigmai, fitsigmas[0], fitsigmas[1]);
+ //~
+ //~ fitmean = f_fit->GetParameter(1);
+ //~ fiterror = TMath::Abs(f_fit->GetParameter(2));
+ //~
+
+ // fcg
+ fitmean = f_fit->GetMaximumX(fitcenter-1.0*fitw, fitcenter+0.5*fitw);
+ fiterror = TMath::Abs(f_fit->GetParameter(3));
+
+ //~ // fcgg
+ //~ fitmean = f_fit->GetMaximumX(fitcenter-1.0*fitw, fitcenter+1.0*fitw);
+ //~ double HalfMax = (f_fit->GetMaximum(fitcenter-1.0*fitw, fitcenter+1.0*fitw) + f_fit->GetParameter(0))/2.0;
+ //~ double MinHalfMax = f_fit->GetX(HalfMax, fitcenter-1.0*fitw, fitcenter);
+ //~ double MaxHalfMax = f_fit->GetX(HalfMax, fitcenter, fitcenter+1.0*fitw);
+ //~ double FWHMc = MaxHalfMax - MinHalfMax;
+ //~ fiterror = TMath::Abs(FWHMc);
+//~ //------/
+ } else {
+ fgg->SetParameters(fitampl, fitcenter, 0.05,
+ fitampl/15, fitcenter, 0.5);
+
+ fgg->SetParLimits(0, fitampl*0.3, fitampl*1.1);
+ fgg->SetParLimits(3, fitampl*0.01, fitampl*0.7);
+
+ fgg->SetParLimits(1, -1, 1);
+ fgg->SetParLimits(4, -1, 1);
+
+ fgg->SetParLimits(2, 0, 0.300);
+ fgg->SetParLimits(5, 0.3, 4.0);
+
+ #ifdef SHOW_SLICES
+ c0->cd(i%c0pads + 1); //c0->cd(i%4 + 1)->SetLogy();
+ hprojx[i]->Fit(fgg,"QL", "", fitcenter-1.0*fitw, fitcenter+2.0*fitw);
+ //c0->Update();
+ //if( !((i+1)%9) && (skip!='y') ) {c0->Update(); printf("Skip?: "); scanf("%c",&skip);}
+ //if( (skip=='q') || (skip=='Q') ) return;
+ //hprojx[i]->DrawClone();
+ //fgg->SetRange(-1,2);
+ //fgg->DrawClone("LSAME");
+ #else
+ hprojx[i]>Fit(fgg,"0QL", "", fitcenter-1.0*fitw, fitcenter+2.0*fitw);
+ #endif
+
+ fitsigmas[0] = TMath::Abs(fgg->GetParameter(2));
+ fitsigmas[1] = TMath::Abs(fgg->GetParameter(5));
+ fitminsigmai = TMath::LocMin(2,fitsigmas);
+ //printf("fitminsigmai = %d {%.1lf, %.1lf}\n", fitminsigmai, fitsigmas[0]*1000, fitsigmas[1]*1000);
+ fitmean = fgg->GetParameter(1 + fitminsigmai*3);
+ fiterror = TMath::Abs(fgg->GetParameter(2 + fitminsigmai*3));
+//------/
+ } //if(i<4)
+
+ printf(">>> ADC %3d - %3d -> %5.1lf ps\n", bin0, bin1, fiterror*1000.);
+
+ gcor[ch]->SetPoint(i, binc, fitmean);
+ // weight = slice fit sigma (default)
+ if( strcmp(fite, "s")==0 )
+ gcor[ch]->SetPointError(i, 0.0, fiterror);
+ // weight = slice maximum bin content ~ n of events
+ else if( strcmp(fite, "h")==0 )
+ gcor[ch]->SetPointError(i, 0.0, 2./sqrt(hprojx[i]->GetMaximum()));
+ // weight = both
+ else if( strcmp(fite, "b")==0 )
+ gcor[ch]->SetPointError(i, 0, 100.*fiterror/hprojx[i]->GetMaximum());
+ else if( strcmp(fite, "k")==0 )
+ gcor[ch]->SetPointError(i, 0, 1./sqrt(hprojx[i]->GetMaximum()));
+
+ } //if( hprojx[i]->GetMaximum() > projmin )
+ }// for(int i=slmin; i<nslicex; i++)
+#ifdef SHOW_SLICES
+ c0->Update();
+ sprintf(fullname, "gif/%s_ch_%d.gif", fname, ch); c0->SaveAs(fullname);
+#endif
+
+
+ c1->cd(ch+1); gPad->SetLogz();
+
+ fitsqrt->SetLineWidth(2);
+ gStyle->SetOptStat("e");
+ gStyle->SetOptFit(11);
+ (gcor[ch]->GetYaxis())->SetRangeUser((hp2d->GetYaxis())->GetXmin(), (hp2d->GetYaxis())->GetXmax());
+ //~ (gcor[ch]->GetYaxis())->SetRangeUser(-2,3);
+ //gcor[ch]->Draw("AP");
+
+ fitsqrt->SetParameters(0, 10, 50);
+
+ fitsqrt->SetRange(TMath::Ceil(fitsqrt->GetParameter(2)),(gcor[ch]->GetXaxis())->GetXmax());
+ //~ fitsqrt->SetRange(TMath::Ceil(fitsqrt->GetParameter(2)),3*256.);
+ //fitsqrt->SetParameters(-0.25, 3, 55);
+ //fitsqrt->SetParLimits(0,-4,8);
+ //~ fitsqrt->SetParLimits(1,0,20);
+ //~ fitsqrt->SetParLimits(2,-100,2000);
+ fitsqrt->SetParLimits(2,0,2000);
+//~ #ifdef FIRST_CH
+ //~ if(ch==FIRST_CH) gcor[ch]->Fit(fitsqrt, "0Q","");
+//~ #else
+ //~ if(ch==0) gcor[ch]->Fit(fitsqrt, "0Q","");
+//~ #endif
+ gcor[ch]->Fit(fitsqrt, "0QR","");
+ //(gcor[ch]->GetYaxis())->UnZoom();
+ sprintf(fullname, "SiPM_%d; Charge [200 fC/bin]; TDC [ns]", ch+1);
+ hp2d->SetTitle(fullname);
+ //~ (hp2d->GetXaxis())->SetRangeUser(0.,4*256.);
+ //~ (hp2d->GetXaxis())->SetRangeUser(0.,3*256.);
+ //(hp2d->GetYaxis())->SetRangeUser(-1.,3.);
+ //~ (hp2d->GetYaxis())->SetRangeUser(-2.5,2.5);
+ hp2d->DrawCopy("COLZ");
+ fitsqrt->SetRange(TMath::Ceil(fitsqrt->GetParameter(2)),8*256.);
+ //~ fitsqrt->SetRange(TMath::Ceil(fitsqrt->GetParameter(2)),(gcor[ch]->GetXaxis())->GetXmax());
+ fitsqrt->DrawCopy("LSAME");
+ gcor[ch]->Draw("PSAME");
+
+ sprintf(fullname, "gif/%s_cor.gif", fname); c1->SaveAs(fullname);
+
+ printf("[ch.%d - ch.%d] %lf %lf\n", mapii[ch], mapij[ch], fitsqrt->GetParameter(1), fitsqrt->GetParameter(2));
+ #ifdef COROUT
+ fprintf(fp,"%lf %lf %lf\n", fitsqrt->GetParameter(0), fitsqrt->GetParameter(1), fitsqrt->GetParameter(2));
+ #endif
+ g_corpars[ch][0]=fitsqrt->GetParameter(0);
+ g_corpars[ch][1]=fitsqrt->GetParameter(1);
+ g_corpars[ch][2]=fitsqrt->GetParameter(2);
+
+ }
+ }
+
+#ifdef COROUT
+ for(int i=USED_CH;i<NCH; i++) fprintf(fp,"%lf %lf %lf\n", 0.0,0.005,0.0);
+ if(fp) fclose(fp);
+#endif
+
+ //rootfile->Close();
+}
Index: l2d2_easyroc/cor_laser.cpp
===================================================================
--- l2d2_easyroc/cor_laser.cpp (nonexistent)
+++ l2d2_easyroc/cor_laser.cpp (revision 291)
@@ -0,0 +1,300 @@
+#include "TROOT.h"
+#include "TFile.h"
+#include "TBenchmark.h"
+#include "TH1F.h"
+#include "TH2F.h"
+#include "TCanvas.h"
+#include "TStyle.h"
+#include "TPad.h"
+#include "TF1.h"
+#include "TGraph.h"
+#include "TSpectrum.h"
+#include "TGraphErrors.h"
+
+#define COROUT
+#define SHOW_SLICES
+#define NCH 20
+#define USED_CH 1
+#define TDC_BIN (25./1000.) //1 TDC bin in ns
+//~ #define FIRST_CH 1
+
+double g_corpars[NCH][3];
+
+int mapii[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,11,12,13,14,15,16,17,18,19 };
+int mapij[] = { 1, 0,16,16,16,16,16,16,16,16, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 };
+
+// root -l "cor.cpp(\"run045\",64,1,20,\"s\")"
+void cor_laser(char *fname="cscan3", const int nslicex=64, int slmin=1, const int projmin=5, char *fite="s")
+{
+ double fitw=1.0;
+ char skip='n';
+
+ char fullname[256];
+
+ //get ROOT file with histograms
+ char fnameroot[1024];
+ TFile * rootfile;
+ TDirectory *dir;
+
+ sprintf(fnameroot, "root/%s.root", fname);
+ rootfile = (TFile *) gROOT->FindObject(fname);
+ if(rootfile==NULL) rootfile = new TFile(fnameroot);
+ if(rootfile==NULL) {
+ printf("Cannot open root file %s!!!\n",fnameroot);
+ return;
+ }
+ dir = (TDirectory*) rootfile;
+
+
+ // set draw style
+ gStyle->SetOptStat("ne");
+ gStyle->SetPalette(1, 0);
+
+ gStyle->SetPaperSize(TStyle::kA4);
+ gStyle->SetStatBorderSize(1);
+ gStyle->SetFrameBorderMode(0);
+ gStyle->SetFrameFillColor(0);
+ gStyle->SetCanvasBorderMode(0);
+ gStyle->SetPadBorderMode(0);
+ gStyle->SetPadColor(0);
+ gStyle->SetCanvasColor(0);
+ gStyle->SetStatColor(0);
+ gStyle->SetOptFit(11);
+
+ gStyle->SetPadRightMargin(0.1);
+
+ char hname[256];
+ TH1F *hp1d; TH2F *hp2d;
+
+ int ch=0;
+ int nbinsx, deltax, bin0, bin1;
+ double binc;
+ TH1F *hprojx[nslicex];
+
+ TF1 *f_fit = 0;
+ TF1 *fg = new TF1("fg", "gaus(0)");
+ fg->SetParNames("Constant","Mean","Sigma");
+ TF1 *fgg = new TF1("fgg", "gaus(0)+gaus(3)");
+ fgg->SetParNames("Constant","Mean","Sigma","Constant2","Mean2","Sigma2");
+ TF1 *fggg = new TF1("fgg", "gaus(0)+gaus(3)+gaus(6)");
+ fggg->SetParNames("Constant","Mean","Sigma","Constant2","Mean2","Sigma2","Constant3","Mean3","Sigma3");
+ TF1 *fitsqrt = new TF1("fitsqrt","[0]+[1]/TMath::Sqrt(x-[2])");
+
+ TF1 *fcg = new TF1("fcg", "pol0(0)+gaus(1)");
+ fcg->SetParNames("C", "Constant","Mean","Sigma");
+
+ TGraphErrors *gcor[NCH];
+ double fitcenter, fitampl;
+
+ double fitsigmas[2];
+ int fitminsigmai;
+ double fiterror, fitmean;
+
+#ifdef COROUT
+ FILE *fp;
+ //open file to save parameters
+ sprintf(fullname, "data/%s_cor.txt", fname);
+ if( (fp=fopen(fullname, "wt")) == NULL )
+ printf("Cannot create parameter file %s !!!\n", fullname);
+ else
+ printf("Created parameter file %s\n", fullname);
+#endif
+
+
+ TCanvas *c1 = new TCanvas("Cor.Fits", "Cor.Fits", 0, 0, 1300, 700);
+ c1->Divide(2,1);
+
+
+#ifdef SHOW_SLICES
+ TCanvas *c0 = new TCanvas("Slices", "Slices", 0, 0, 1300, 700);
+ c0->Divide(5,5);
+#endif
+ const int c0pads = 25;
+
+
+ if(nslicex==0) {
+#ifdef COROUT
+ for(int j=0;j<NCH; j++) fprintf(fp,"%lf %lf %lf\n", 0.0,0.005,0.0);
+ gSystem->Exit(1);
+#endif
+ } else {
+#ifdef FIRST_CH
+ ch=FIRST_CH;
+#else
+ for(ch=0;ch<USED_CH; ch++)
+#endif
+ {
+
+ gcor[ch] = new TGraphErrors(nslicex);
+ sprintf(hname,"TDC Corection ch%d;QDC;TDC [ps]",ch);
+ gcor[ch]->SetTitle(hname);
+ //~ sprintf(hname, "hdiffcor_%d_%d",mapii[ch],mapij[ch]); hp2d = (TH2F *) dir->Get(hname);
+ sprintf(hname, "hcor%d",ch); hp2d = (TH2F *) dir->Get(hname);
+ nbinsx=hp2d->GetNbinsX();
+ deltax=nbinsx/nslicex;
+
+ c0->Clear();c0->Divide(8,4);
+ for(int i=slmin; i<nslicex-1; i++) {
+ bin0=i*deltax+1;
+ bin1=(i+1)*deltax+1;
+ binc=(hp2d->GetXaxis()->GetBinCenter(bin0)+hp2d->GetXaxis()->GetBinCenter(bin1))/2.0;
+
+ sprintf(hname, "hprojx%d",i);
+ hprojx[i]=(TH1F*)hp2d->ProjectionY(hname, bin0, bin1);
+
+ //~ (hprojx[i]->GetXaxis())->SetRangeUser(-1, 2);
+ if( hprojx[i]->GetMaximum() > projmin ) {
+
+ fitcenter = hprojx[i]->GetBinCenter(hprojx[i]->GetMaximumBin());
+ fitampl = hprojx[i]->GetMaximum();
+
+//------/
+ if(i<1024) {
+
+ //~ if( (ch<8) && (i<3) && (fitcenter < 0.4) ) fitcenter = 0.7;
+
+ //~ f_fit = fcg;
+ //~ f_fit->SetParameters(fitampl*0.1, fitampl*0.9, fitcenter, 0.1);
+
+ f_fit = fgg;
+ f_fit->SetParameters(fitampl*0.9, fitcenter, 0.1, fitampl*0.1, fitcenter, 0.5);
+ //~
+ //~ f_fit = fg;
+ //~ f_fit->SetParameters(fitampl*0.9, fitcenter, 0.1);
+
+ //~ f_fit->SetParLimits(0, 0, fitampl*3);
+
+ #ifdef SHOW_SLICES
+ c0->cd(i%c0pads + 1); //c0->cd(i%4 + 1)->SetLogy();
+ hprojx[i]->Fit(f_fit,"QL", "", fitcenter-1.0*fitw, fitcenter+0.5*fitw);
+ //~ hprojx[i]->Fit(f_fit,"QL", "");
+ //c0->Update();
+ //if( !((i+1)%9) && (skip!='y') ) {c0->Update(); printf("Skip?: "); scanf("%c",&skip);}
+ //if( (skip=='q') || (skip=='Q') ) return;
+ //hprojx[i]->DrawClone();
+ //fgg->SetRange(-1,2);
+ //fgg->DrawClone("LSAME");
+ #else
+ //~ hprojx[i]>Fit(fgg,"0QL", "", fitcenter-1.0*fitw, fitcenter+2.0*fitw);
+ hprojx[i]->Fit(f_fit,"0QL", "");
+ #endif
+
+ //~ fitsigmas[0] = TMath::Abs(f_fit->GetParameter(2));
+ //~ fitsigmas[1] = TMath::Abs(f_fit->GetParameter(5));
+ //~ fitminsigmai = TMath::LocMin(2,fitsigmas);
+ //~ fitmean = f_fit->GetParameter(1 + fitminsigmai*3);
+ //~ fiterror = TMath::Abs(f_fit->GetParameter(2 + fitminsigmai*3));
+ //~ printf("fitminsigmai = %d {%lf, %lf}\n", fitminsigmai, fitsigmas[0], fitsigmas[1]);
+ //~
+ //~ fitmean = f_fit->GetParameter(1);
+ //~ fiterror = TMath::Abs(f_fit->GetParameter(2));
+ //~
+ fitmean = f_fit->GetMaximumX(fitcenter-1.0*fitw, fitcenter+0.5*fitw);
+ fiterror = TMath::Abs(f_fit->GetParameter(2));
+//------/
+ } else {
+ fgg->SetParameters(fitampl, fitcenter, 0.05,
+ fitampl/15, fitcenter, 0.5);
+
+ fgg->SetParLimits(0, fitampl*0.3, fitampl*1.1);
+ fgg->SetParLimits(3, fitampl*0.01, fitampl*0.7);
+
+ fgg->SetParLimits(1, -1, 1);
+ fgg->SetParLimits(4, -1, 1);
+
+ fgg->SetParLimits(2, 0, 0.300);
+ fgg->SetParLimits(5, 0.3, 4.0);
+
+ #ifdef SHOW_SLICES
+ c0->cd(i%c0pads + 1); //c0->cd(i%4 + 1)->SetLogy();
+ hprojx[i]->Fit(fgg,"QL", "", fitcenter-1.0*fitw, fitcenter+2.0*fitw);
+ //c0->Update();
+ //if( !((i+1)%9) && (skip!='y') ) {c0->Update(); printf("Skip?: "); scanf("%c",&skip);}
+ //if( (skip=='q') || (skip=='Q') ) return;
+ //hprojx[i]->DrawClone();
+ //fgg->SetRange(-1,2);
+ //fgg->DrawClone("LSAME");
+ #else
+ hprojx[i]>Fit(fgg,"0QL", "", fitcenter-1.0*fitw, fitcenter+2.0*fitw);
+ #endif
+
+ fitsigmas[0] = TMath::Abs(fgg->GetParameter(2));
+ fitsigmas[1] = TMath::Abs(fgg->GetParameter(5));
+ fitminsigmai = TMath::LocMin(2,fitsigmas);
+ //printf("fitminsigmai = %d {%.1lf, %.1lf}\n", fitminsigmai, fitsigmas[0]*1000, fitsigmas[1]*1000);
+ fitmean = fgg->GetParameter(1 + fitminsigmai*3);
+ fiterror = TMath::Abs(fgg->GetParameter(2 + fitminsigmai*3));
+//------/
+ } //if(i<4)
+
+ printf(">>> ADC %3d - %3d -> %5.1lf ps\n", bin0, bin1, fiterror*1000.);
+
+ gcor[ch]->SetPoint(i, binc, fitmean);
+ // weight = slice fit sigma (default)
+ if( strcmp(fite, "s")==0 )
+ gcor[ch]->SetPointError(i, 0.0, fiterror);
+ // weight = slice maximum bin content ~ n of events
+ else if( strcmp(fite, "h")==0 )
+ gcor[ch]->SetPointError(i, 0.0, 10./sqrt(hprojx[i]->GetMaximum()));
+ // weight = both
+ else if( strcmp(fite, "b")==0 )
+ gcor[ch]->SetPointError(i, 0, 100.*fiterror/hprojx[i]->GetMaximum());
+ } //if( hprojx[i]->GetMaximum() > projmin )
+ }// for(int i=slmin; i<nslicex; i++)
+#ifdef SHOW_SLICES
+ c0->Update();
+ sprintf(fullname, "gif/%s_ch_%d.gif", fname, ch); c0->SaveAs(fullname);
+#endif
+
+
+ c1->cd(ch+1); gPad->SetLogz();
+
+ fitsqrt->SetLineWidth(2);
+ gStyle->SetOptFit();
+ (gcor[ch]->GetYaxis())->SetRangeUser((hp2d->GetYaxis())->GetXmin(), (hp2d->GetYaxis())->GetXmax());
+ //gcor[ch]->Draw("AP");
+
+ fitsqrt->SetParameters(0, 10, 50);
+
+ //fitsqrt->SetRange(TMath::Ceil(fitsqrt->GetParameter(2)),(gcor[ch]->GetXaxis())->GetXmax());
+ fitsqrt->SetRange(TMath::Ceil(fitsqrt->GetParameter(2)),3*256.);
+ //fitsqrt->SetParameters(-0.25, 3, 55);
+ //fitsqrt->SetParLimits(0,-4,8);
+ //~ fitsqrt->SetParLimits(1,0,20);
+ //~ fitsqrt->SetParLimits(2,0,200);
+//~ #ifdef FIRST_CH
+ //~ if(ch==FIRST_CH) gcor[ch]->Fit(fitsqrt, "0Q","");
+//~ #else
+ //~ if(ch==0) gcor[ch]->Fit(fitsqrt, "0Q","");
+//~ #endif
+ gcor[ch]->Fit(fitsqrt, "0QR","");
+ //(gcor[ch]->GetYaxis())->UnZoom();
+ hp2d->SetTitle("TDCvsQDC; QDC; TDC [ns]");
+ //~ (hp2d->GetXaxis())->SetRangeUser(0.,4*256.);
+ //(hp2d->GetYaxis())->SetRangeUser(-1.,3.);
+ //~ (hp2d->GetYaxis())->SetRangeUser(-3.,3.);
+ hp2d->DrawCopy("COLZ");
+ fitsqrt->SetRange(TMath::Ceil(fitsqrt->GetParameter(2)),4*256.);
+ fitsqrt->DrawCopy("LSAME");
+ gcor[ch]->Draw("PSAME");
+
+ sprintf(fullname, "gif/%s_cor.gif", fname); c1->SaveAs(fullname);
+
+ printf("[ch.%d - ch.%d] %lf %lf\n", mapii[ch], mapij[ch], fitsqrt->GetParameter(1), fitsqrt->GetParameter(2));
+ #ifdef COROUT
+ fprintf(fp,"%lf %lf %lf\n", fitsqrt->GetParameter(0), fitsqrt->GetParameter(1), fitsqrt->GetParameter(2));
+ #endif
+ g_corpars[ch][0]=fitsqrt->GetParameter(0);
+ g_corpars[ch][1]=fitsqrt->GetParameter(1);
+ g_corpars[ch][2]=fitsqrt->GetParameter(2);
+
+ }
+ }
+
+#ifdef COROUT
+ for(int i=USED_CH;i<NCH; i++) fprintf(fp,"%lf %lf %lf\n", 0.0,0.005,0.0);
+ if(fp) fclose(fp);
+#endif
+
+ //rootfile->Close();
+}
Index: l2d2_easyroc/cvibuild.l2d/Debug/BuildStep.bat
===================================================================
--- l2d2_easyroc/cvibuild.l2d/Debug/BuildStep.bat (nonexistent)
+++ l2d2_easyroc/cvibuild.l2d/Debug/BuildStep.bat (revision 291)
@@ -0,0 +1,2 @@
+@call %1.bat > %1.out
+@echo Build Step complete for %1
Index: l2d2_easyroc/cvibuild.l2d/Debug/CAENV965.nidobj
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/l2d2_easyroc/cvibuild.l2d/Debug/CAENV965.nidobj
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/cvibuild.l2d/Debug/CAENV965.obj
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/l2d2_easyroc/cvibuild.l2d/Debug/CAENV965.obj
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/cvibuild.l2d/Debug/CAENV965.obj.cvidefprots
===================================================================
--- l2d2_easyroc/cvibuild.l2d/Debug/CAENV965.obj.cvidefprots (nonexistent)
+++ l2d2_easyroc/cvibuild.l2d/Debug/CAENV965.obj.cvidefprots (revision 291)
@@ -0,0 +1,24 @@
+[V965_map]
+Class="Function"
+Prototype="int V965_map(int ModuleNumber, unsigned long ModuleOffset, int print);"
+
+[V965_init]
+Class="Function"
+Prototype="int V965_init(int ModuleNumber, unsigned short ped);"
+
+[V965_clear]
+Class="Function"
+Prototype="int V965_clear(int ModuleNumber);"
+
+[V965_status]
+Class="Function"
+Prototype="int V965_status(int ModuleNumber);"
+
+[V965_status2]
+Class="Function"
+Prototype="int V965_status2(int ModuleNumber);"
+
+[V965_read]
+Class="Function"
+Prototype="int V965_read(int ModuleNumber, unsigned long *whereto);"
+
Index: l2d2_easyroc/cvibuild.l2d/Debug/CC_no_dep_options.txt
===================================================================
--- l2d2_easyroc/cvibuild.l2d/Debug/CC_no_dep_options.txt (nonexistent)
+++ l2d2_easyroc/cvibuild.l2d/Debug/CC_no_dep_options.txt (revision 291)
@@ -0,0 +1 @@
+-force-include-file "easiroc.c";"c:\home\rokd\l2d2_easyroc\easiroc.c" -force-include-file "easiroc.h";"c:\home\rokd\l2d2_easyroc\easiroc.h" -force-include-file "l2d.c";"c:\home\rokd\l2d2_easyroc\l2d.c" -force-include-file "l2d_ui.h";"c:\home\rokd\l2d2_easyroc\l2d_ui.h" -force-include-file "sender.c";"c:\home\rokd\l2d2_easyroc\sender.c" -force-include-file "sender.h";"c:\home\rokd\l2d2_easyroc\sender.h" -force-include-file "SiTCP.c";"c:\home\rokd\l2d2_easyroc\SiTCP.c" -force-include-file "SiTCP.h";"c:\home\rokd\l2d2_easyroc\SiTCP.h"
\ No newline at end of file
Index: l2d2_easyroc/cvibuild.l2d/Debug/CC_options.txt
===================================================================
--- l2d2_easyroc/cvibuild.l2d/Debug/CC_options.txt (nonexistent)
+++ l2d2_easyroc/cvibuild.l2d/Debug/CC_options.txt (revision 291)
@@ -0,0 +1 @@
+-triple i386-pc-win32 -fno-caret-diagnostics -fno-gnu-keywords -fms-extensions -mms-bitfields -fmath-errno -mdisable-fp-elim -Wno-microsoft -Wno-error=invalid-token-paste -Werror=gnu -Werror=pointer-arith -Wno-pointer-sign -Wno-unreachable-code -Wno-parentheses -Wno-unused-variable -Wuninitialized -Wno-div-by-zero -Wno-array-bounds -Wno-null-dereference -Wno-ignored-qualifiers -Wreturn-type -Wno-panel-handle -Wno-tautological-compare -Wno-empty-body -Wno-missing-braces -Wno-overlength-strings -Wno-cast-align -Wno-missing-noreturn -Wno-invalid-noreturn -Wno-shadow -Wno-switch -Wno-switch-enum -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-value -Wno-used-but-marked-unused -Wno-conversion -Wno-sign-compare -Wno-char-subscripts -Wno-declaration-after-statement -Wno-typecheck-convert -Wno-float-equal -Wno-vla -Wno-attributes -Wno-unknown-attributes -Wno-deprecated-declarations -Wno-packed -Wno-padded -Wno-comment -Wno-format -Wno-implicit-int -Wno-implicit-function-declaration -Wno-builtin-implicit-decl -Wno-missing-declarations -Wno-missing-field-initializers -Wno-trigraphs -Wno-multichar -Wno-long-long -Wno-unknown-pragmas -Wno-ignored-pragmas -Wno-pragma-reset -Wno-pragma-on-off-switch -Wno-pragma-unused -Wno-end-of-directive -Wno-pragma-not-supported -Wno-unexpected-token -Wno-four-char-constants -Wno-discard-qual -Wno-sign-conversion -Wno-variadic-macros -Wno-macro-name -Wno-macro-poisoning -Wno-macro-redefined -Wno-builtin-macro-redefined -Wno-builtin-macro-undefined -Wno-unused-macros -Wno-gnu-designator -Wno-nonnull -Wno-constant-conversion -Wno-out-of-scope-declarations -Wno-static-non-static -Wno-constant-too-large -Wno-#warnings -Wno-undef -Wno-include-next -Wno-extra-tokens -Wno-line-number -Wno-weak -Wno-member-redeclare -Wno-expected-semi -Wno-too-many-args -Wno-literal-range -Wno-unknown-escape -Wno-shift -Wchar-init -Wno-braces-init -Wno-incomplete-field -Wno-tentative -Wno-ordered-comparison -Wno-pointer-compare -Wno-stack-memory -Wno-excess-elements -Wno-missing-terminating -Wno-illegal-storage -Wno-clang -Wno-backslash -Wno-decl-param -Wno-negative-to-unsigned -Wno-extern -Wno-constant-logical-operand -Wno-initializer-overrides -Wno-variadic-call-conv -Wno-main -Wno-omp-nested-parallel -Wno-omp-repeated-ordered -Wpointer-int-conv -Wint-conversion -Wpointer-conv -Wmissing-return-value -Winvalid-return -Wduplicate-decl-spec -Wpromoted-param -Wno-strict-prototypes -Wno-va-named-param -Wno-invalid-token-paste -fdiagnostics-show-option -cvi-debugging=standard -Wuninitialized-runtime -I "c:\Program Files\National Instruments\CVI2013\instr\CAMAC_2000" -I "c:\Program Files\National Instruments\CVI2013\instr\WIENVME_DLL" -I "c:\Program Files\National Instruments\CVI2013\instr\CAENV965" -I "c:\program files\national instruments\cvi2013\toolslib\activex\word" -I "c:\program files\national instruments\cvi2013\toolslib\activex\excel" -I "c:\program files\national instruments\cvi2013\toolslib\custctrl" -I "c:\program files\national instruments\cvi2013\toolslib\custctrl\custsupp" -I "c:\program files\national instruments\cvi2013\toolslib\cvirtsup" -I "c:\program files\national instruments\cvi2013\toolslib\datasock" -I "c:\program files\national instruments\cvi2013\toolslib\daqUtil" -I "c:\program files\national instruments\cvi2013\toolslib\printing" -I "c:\program files\national instruments\cvi2013\toolslib\toolbox" -I "c:\program files\national instruments\cvi2013\toolslib\reportgen" -I "c:\program files\national instruments\cvi2013\toolslib\localui" -I "c:\program files\national instruments\cvi2013\instr" -I "C:\Program Files\National Instruments\Shared\CVI\toolslib\custctrl" -I "C:\Program Files\National Instruments\Shared\CVI\toolslib\custctrl\custsupp" -I "C:\Program Files\National Instruments\Shared\CVI\instr" -I "C:\ProgramData\National Instruments\CVI2013\instr" -I "c:\program files\national instruments\cvi2013\include" -I "C:\Program Files\National Instruments\Shared\CVI\include" -I "C:\ProgramData\National Instruments\CVI2013\include" -I "C:\ProgramData\National Instruments\CVI\include" -I "c:\program files\national instruments\cvi2013\include\ansi" -I "c:\program files\national instruments\cvi2013\include\clang\2.9" -I "C:\Program Files\IVI Foundation\IVI\Include" -I "C:\Program Files\IVI Foundation\VISA\winnt\include" -I "c:\program files\national instruments\cvi2013\sdk\include" -I c:\home\cvi\instr\CAENV965 -I c:\home\cvi\instr\CAMAC_2000 -I c:\home\cvi\instr\WIENVME_DLL -I "c:\Program Files\National Instruments\CVI2013\bin" -I "c:\ProgramData\National Instruments\CVI2013\bin" -I "c:\Program Files\National Instruments\Shared\CVI\Bin"
\ No newline at end of file
Index: l2d2_easyroc/cvibuild.l2d/Debug/CallCC.bat
===================================================================
--- l2d2_easyroc/cvibuild.l2d/Debug/CallCC.bat (nonexistent)
+++ l2d2_easyroc/cvibuild.l2d/Debug/CallCC.bat (revision 291)
@@ -0,0 +1,22 @@
+@set INCLUDE=
+@set LIB=
+@set FileNum=%1
+@shift
+@set SrcFileName=%1
+@shift
+@set ObjFileName=%1
+@shift
+@set DefProts=%1
+@shift
+@set OutFileName=%1
+@shift
+@set REST=%1 %2 %3 %4 %5 %6 %7 %8 %9
+@rem c:\home\rokd\l2d2_easyroc
+@echo Compiling %FileNum% %SrcFileName%
+@"c:\program files\national instruments\cvi2013\bin\clang\2.9\clang.exe" -cc1 -nostdinc -emit-obj -add-plugin cvi-emit-defprots -plugin-arg-cvi-emit-defprots %DefProts% %REST% -std=c99 @"CC_no_dep_options.txt" @"CC_options.txt" -D_CVI_="1302" -D_NI_i386_="1" -D_NI_mswin_="1" -D_NI_mswin32_="1" -D_CVI_DEBUG_="1" -D_CVI_EXE_="1" -D_LINK_CVIRTE_="1" -D_CVI_FDS_="1" -D_CVI_USE_FUNCS_FOR_VARS_="1" -D__DEFALIGN="8" -D_NI_VC_="220" -D_WIN32="1" -DWIN32="1" -D__WIN32__="1" -D_WINDOWS="1" -D__NT__="1" -D_M_IX86="400" -D__FLAT__="1" -D_PUSHPOP_SUPPORTED="1" -D_CVI_C99_EXTENSIONS_="1" -D_CVI_PROFILE_LEVEL_="0" -D_TARGET_FILE_VERSION_="\"1.0.0.0\"" -D_TARGET_PRODUCT_VERSION_="\"1.0.0.0\"" -D_OPENMP="200505" -D_CVI_CONFIGURATION_NAME_="\"Debug\"" -D_CVI_RTE_SHARED_="1" -DWIN32_LEAN_AND_MEAN -DWIENVME -o %ObjFileName% %SrcFileName% > %OutFileName% 2>&1
+@if errorlevel 1 goto err
+@echo Compile succeeded for %FileNum% %SrcFileName%
+@exit 0
+:err
+@echo Compile failed for %FileNum% %SrcFileName%
+@exit 1
Index: l2d2_easyroc/cvibuild.l2d/Debug/CallLink.bat
===================================================================
--- l2d2_easyroc/cvibuild.l2d/Debug/CallLink.bat (nonexistent)
+++ l2d2_easyroc/cvibuild.l2d/Debug/CallLink.bat (revision 291)
@@ -0,0 +1,9 @@
+@"c:\program files\national instruments\cvi2013\bin\cvilink.exe" -cmd:link_options.txt -flags:0 -expiry:0 > Link.out 2>&1
+@if errorlevel 1 goto err
+@echo Link success
+@echo Link complete
+@exit 0
+:err
+@echo Link complete
+@echo Link failed
+@exit 1
Index: l2d2_easyroc/cvibuild.l2d/Debug/CallRC.bat
===================================================================
--- l2d2_easyroc/cvibuild.l2d/Debug/CallRC.bat (nonexistent)
+++ l2d2_easyroc/cvibuild.l2d/Debug/CallRC.bat (revision 291)
@@ -0,0 +1,8 @@
+@echo "c:\program files\national instruments\cvi2013\sdk\bin\rc.exe" /d _CVI_ /i "c:\program files\national instruments\cvi2013\sdk\include" /fo %2 %1
+@"c:\program files\national instruments\cvi2013\sdk\bin\rc.exe" /d _CVI_ /i "c:\program files\national instruments\cvi2013\sdk\include" /fo %2 %1 > Rc.out 2>&1
+@if errorlevel 1 goto err
+@echo RC complete
+@exit 0
+:err
+@echo RC failed
+@exit 1
Index: l2d2_easyroc/cvibuild.l2d/Debug/Jamfile
===================================================================
--- l2d2_easyroc/cvibuild.l2d/Debug/Jamfile (nonexistent)
+++ l2d2_easyroc/cvibuild.l2d/Debug/Jamfile (revision 291)
@@ -0,0 +1,85 @@
+CCFLAGS = -g ;
+HDRS = "c:\\Program Files\\National Instruments\\CVI2013\\instr\\CAMAC_2000"
+ "c:\\Program Files\\National Instruments\\CVI2013\\instr\\WIENVME_DLL"
+ "c:\\Program Files\\National Instruments\\CVI2013\\instr\\CAENV965"
+ "c:\\program files\\national instruments\\cvi2013\\toolslib\\activex\\word"
+ "c:\\program files\\national instruments\\cvi2013\\toolslib\\activex\\excel"
+ "c:\\program files\\national instruments\\cvi2013\\toolslib\\custctrl"
+ "c:\\program files\\national instruments\\cvi2013\\toolslib\\custctrl\\custsupp"
+ "c:\\program files\\national instruments\\cvi2013\\toolslib\\cvirtsup"
+ "c:\\program files\\national instruments\\cvi2013\\toolslib\\datasock"
+ "c:\\program files\\national instruments\\cvi2013\\toolslib\\daqUtil"
+ "c:\\program files\\national instruments\\cvi2013\\toolslib\\printing"
+ "c:\\program files\\national instruments\\cvi2013\\toolslib\\toolbox"
+ "c:\\program files\\national instruments\\cvi2013\\toolslib\\reportgen"
+ "c:\\program files\\national instruments\\cvi2013\\toolslib\\localui"
+ "c:\\program files\\national instruments\\cvi2013\\instr"
+ "C:\\Program Files\\National Instruments\\Shared\\CVI\\toolslib\\custctrl"
+ "C:\\Program Files\\National Instruments\\Shared\\CVI\\toolslib\\custctrl\\custsupp"
+ "C:\\Program Files\\National Instruments\\Shared\\CVI\\instr"
+ "C:\\ProgramData\\National Instruments\\CVI2013\\instr"
+ "c:\\program files\\national instruments\\cvi2013\\include"
+ "C:\\Program Files\\National Instruments\\Shared\\CVI\\include"
+ "C:\\ProgramData\\National Instruments\\CVI2013\\include"
+ "C:\\ProgramData\\National Instruments\\CVI\\include"
+ "c:\\program files\\national instruments\\cvi2013\\include\\ansi"
+ "c:\\program files\\national instruments\\cvi2013\\include\\clang\\2.9"
+ "C:\\Program Files\\IVI Foundation\\IVI\\Include"
+ "C:\\Program Files\\IVI Foundation\\VISA\\winnt\\include"
+ "c:\\program files\\national instruments\\cvi2013\\sdk\\include"
+ "c:\\home\\cvi\\instr\\CAENV965"
+ "c:\\home\\cvi\\instr\\CAMAC_2000"
+ "c:\\home\\cvi\\instr\\WIENVME_DLL"
+ "c:\\Program Files\\National Instruments\\CVI2013\\bin"
+ "c:\\ProgramData\\National Instruments\\CVI2013\\bin"
+ "c:\\Program Files\\National Instruments\\Shared\\CVI\\Bin"
+ ;
+include Jamfile_instr ;
+LOCATE on "easiroc.c" = "c:\\home\\rokd\\l2d2_easyroc" ;
+LOCATE on "easiroc.h" = "c:\\home\\rokd\\l2d2_easyroc" ;
+LOCATE on "l2d.c" = "c:\\home\\rokd\\l2d2_easyroc" ;
+LOCATE on "l2d_ui.h" = "c:\\home\\rokd\\l2d2_easyroc" ;
+LOCATE on "sender.c" = "c:\\home\\rokd\\l2d2_easyroc" ;
+LOCATE on "sender.h" = "c:\\home\\rokd\\l2d2_easyroc" ;
+LOCATE on "SiTCP.c" = "c:\\home\\rokd\\l2d2_easyroc" ;
+LOCATE on "SiTCP.h" = "c:\\home\\rokd\\l2d2_easyroc" ;
+Object "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\easiroc.obj" : "c:\\home\\rokd\\l2d2_easyroc\\easiroc.c" ;
+FILENUM on "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\easiroc.obj" = 1 ;
+DEFPROTS on "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\easiroc.obj" = "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\easiroc.obj.cvidefprots" ;
+OUTFILE on "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\easiroc.obj" = "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\easiroc.obj.out" ;
+PrjObjects += "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\easiroc.obj" ;
+Object "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.obj" : "c:\\home\\rokd\\l2d2_easyroc\\l2d.c" ;
+FILENUM on "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.obj" = 2 ;
+DEFPROTS on "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.obj" = "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.obj.cvidefprots" ;
+OUTFILE on "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.obj" = "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.obj.out" ;
+PrjObjects += "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.obj" ;
+Object "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\sender.obj" : "c:\\home\\rokd\\l2d2_easyroc\\sender.c" ;
+FILENUM on "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\sender.obj" = 3 ;
+DEFPROTS on "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\sender.obj" = "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\sender.obj.cvidefprots" ;
+OUTFILE on "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\sender.obj" = "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\sender.obj.out" ;
+PrjObjects += "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\sender.obj" ;
+Object "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\SiTCP.obj" : "c:\\home\\rokd\\l2d2_easyroc\\SiTCP.c" ;
+FILENUM on "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\SiTCP.obj" = 4 ;
+DEFPROTS on "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\SiTCP.obj" = "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\SiTCP.obj.cvidefprots" ;
+OUTFILE on "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\SiTCP.obj" = "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\SiTCP.obj.out" ;
+PrjObjects += "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\SiTCP.obj" ;
+Object "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\camac.obj" : "c:\\home\\cvi\\instr\\CAMAC_2000\\camac.c" ;
+FILENUM on "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\camac.obj" = 5 ;
+DEFPROTS on "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\camac.obj" = "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\camac.obj.cvidefprots" ;
+OUTFILE on "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\camac.obj" = "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\camac.obj.out" ;
+InstrObjects += "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\camac.obj" ;
+Object "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\CAENV965.obj" : "c:\\home\\cvi\\instr\\CAENV965\\CAENV965.c" ;
+FILENUM on "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\CAENV965.obj" = 6 ;
+DEFPROTS on "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\CAENV965.obj" = "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\CAENV965.obj.cvidefprots" ;
+OUTFILE on "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\CAENV965.obj" = "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\CAENV965.obj.out" ;
+InstrObjects += "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\CAENV965.obj" ;
+Object "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\wienvme_dll.obj" : "c:\\home\\cvi\\instr\\WIENVME_DLL\\wienvme_dll.c" ;
+FILENUM on "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\wienvme_dll.obj" = 7 ;
+DEFPROTS on "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\wienvme_dll.obj" = "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\wienvme_dll.obj.cvidefprots" ;
+OUTFILE on "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\wienvme_dll.obj" = "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\wienvme_dll.obj.out" ;
+InstrObjects += "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\wienvme_dll.obj" ;
+Object "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\resources.res" : "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\resources.in.rc" ;
+MainFromObjects "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.exe" : $(PrjObjects) $(InstrObjects) ;
+Depends "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.exe" : "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\link_options.txt" ;
+Depends "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.exe" : "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\resources.res" ;
+Depends all : "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.exe" ;
Index: l2d2_easyroc/cvibuild.l2d/Debug/Jamfile_instr
===================================================================
--- l2d2_easyroc/cvibuild.l2d/Debug/Jamfile_instr (nonexistent)
+++ l2d2_easyroc/cvibuild.l2d/Debug/Jamfile_instr (revision 291)
@@ -0,0 +1,49 @@
+Depends "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.exe" : "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\easiroc.obj" ;
+Depends "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.exe" : "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.obj" ;
+Depends "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.exe" : "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\sender.obj" ;
+Depends "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.exe" : "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\SiTCP.obj" ;
+Depends "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.exe" : "c:\\program files\\national instruments\\cvi2013\\sdk\\lib\\msvc\\advapi32.lib" ;
+NoCare "c:\\program files\\national instruments\\cvi2013\\sdk\\lib\\msvc\\advapi32.lib" ;
+Depends "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.exe" : "c:\\ProgramData\\National Instruments\\CVI2013\\bin\\msvc\\analysis.lib" ;
+NoCare "c:\\ProgramData\\National Instruments\\CVI2013\\bin\\msvc\\analysis.lib" ;
+Depends "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.exe" : "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\CAENV965.obj" ;
+Depends "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.exe" : "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\camac.obj" ;
+Depends "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.exe" : "c:\\Program Files\\National Instruments\\CVI2013\\bin\\msvc\\cviauto.lib" ;
+NoCare "c:\\Program Files\\National Instruments\\CVI2013\\bin\\msvc\\cviauto.lib" ;
+Depends "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.exe" : "c:\\Program Files\\National Instruments\\CVI2013\\bin\\msvc\\cviddc.lib" ;
+NoCare "c:\\Program Files\\National Instruments\\CVI2013\\bin\\msvc\\cviddc.lib" ;
+Depends "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.exe" : "c:\\Program Files\\National Instruments\\CVI2013\\bin\\msvc\\cvidotnet.lib" ;
+NoCare "c:\\Program Files\\National Instruments\\CVI2013\\bin\\msvc\\cvidotnet.lib" ;
+Depends "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.exe" : "c:\\Program Files\\National Instruments\\CVI2013\\bin\\msvc\\cvinetstreams.lib" ;
+NoCare "c:\\Program Files\\National Instruments\\CVI2013\\bin\\msvc\\cvinetstreams.lib" ;
+Depends "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.exe" : "c:\\Program Files\\National Instruments\\CVI2013\\bin\\msvc\\cvinetv.lib" ;
+NoCare "c:\\Program Files\\National Instruments\\CVI2013\\bin\\msvc\\cvinetv.lib" ;
+Depends "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.exe" : "c:\\Program Files\\National Instruments\\CVI2013\\bin\\msvc\\cvintwrk.lib" ;
+NoCare "c:\\Program Files\\National Instruments\\CVI2013\\bin\\msvc\\cvintwrk.lib" ;
+Depends "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.exe" : "c:\\Program Files\\National Instruments\\CVI2013\\bin\\msvc\\cvitdms.lib" ;
+NoCare "c:\\Program Files\\National Instruments\\CVI2013\\bin\\msvc\\cvitdms.lib" ;
+Depends "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.exe" : "c:\\program files\\national instruments\\cvi2013\\sdk\\lib\\msvc\\gdi32.lib" ;
+NoCare "c:\\program files\\national instruments\\cvi2013\\sdk\\lib\\msvc\\gdi32.lib" ;
+Depends "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.exe" : "c:\\Program Files\\National Instruments\\CVI2013\\bin\\msvc\\gpib.lib" ;
+NoCare "c:\\Program Files\\National Instruments\\CVI2013\\bin\\msvc\\gpib.lib" ;
+Depends "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.exe" : "c:\\Program Files\\National Instruments\\Shared\\CVI\\Bin\\msvc\\ivi.lib" ;
+NoCare "c:\\Program Files\\National Instruments\\Shared\\CVI\\Bin\\msvc\\ivi.lib" ;
+Depends "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.exe" : "c:\\program files\\national instruments\\cvi2013\\sdk\\lib\\msvc\\kernel32.lib" ;
+NoCare "c:\\program files\\national instruments\\cvi2013\\sdk\\lib\\msvc\\kernel32.lib" ;
+Depends "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.exe" : "c:\\Program Files\\National Instruments\\CVI2013\\bin\\msvc\\nivxi.lib" ;
+NoCare "c:\\Program Files\\National Instruments\\CVI2013\\bin\\msvc\\nivxi.lib" ;
+Depends "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.exe" : "c:\\Program Files\\National Instruments\\CVI2013\\bin\\msvc\\omp.lib" ;
+NoCare "c:\\Program Files\\National Instruments\\CVI2013\\bin\\msvc\\omp.lib" ;
+Depends "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.exe" : "c:\\Program Files\\National Instruments\\CVI2013\\toolslib\\toolbox\\msvc\\toolbox.obj" ;
+NoCare "c:\\Program Files\\National Instruments\\CVI2013\\toolslib\\toolbox\\msvc\\toolbox.obj" ;
+Depends "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.exe" : "c:\\program files\\national instruments\\cvi2013\\sdk\\lib\\msvc\\user32.lib" ;
+NoCare "c:\\program files\\national instruments\\cvi2013\\sdk\\lib\\msvc\\user32.lib" ;
+Depends "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.exe" : "c:\\program files\\national instruments\\cvi2013\\sdk\\lib\\msvc\\uuid.lib" ;
+NoCare "c:\\program files\\national instruments\\cvi2013\\sdk\\lib\\msvc\\uuid.lib" ;
+Depends "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.exe" : "c:\\Program Files\\National Instruments\\Shared\\CVI\\Bin\\msvc\\visa.lib" ;
+NoCare "c:\\Program Files\\National Instruments\\Shared\\CVI\\Bin\\msvc\\visa.lib" ;
+Depends "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.exe" : "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\wienvme_dll.obj" ;
+Depends "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.exe" : "c:\\program files\\national instruments\\cvi2013\\sdk\\lib\\msvc\\winmm.lib" ;
+NoCare "c:\\program files\\national instruments\\cvi2013\\sdk\\lib\\msvc\\winmm.lib" ;
+Depends "c:\\home\\rokd\\l2d2_easyroc\\cvibuild.l2d\\Debug\\l2d.exe" : "c:\\Program Files\\Microsoft SDKs\\Windows\\v7.1A\\Lib\\WS2_32.Lib" ;
+NoCare "c:\\Program Files\\Microsoft SDKs\\Windows\\v7.1A\\Lib\\WS2_32.Lib" ;
Index: l2d2_easyroc/cvibuild.l2d/Debug/SiTCP.nidobj
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/l2d2_easyroc/cvibuild.l2d/Debug/SiTCP.nidobj
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/cvibuild.l2d/Debug/SiTCP.obj
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/l2d2_easyroc/cvibuild.l2d/Debug/SiTCP.obj
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/cvibuild.l2d/Debug/SiTCP.obj.cvidefprots
===================================================================
--- l2d2_easyroc/cvibuild.l2d/Debug/SiTCP.obj.cvidefprots (nonexistent)
+++ l2d2_easyroc/cvibuild.l2d/Debug/SiTCP.obj.cvidefprots (revision 291)
@@ -0,0 +1,48 @@
+[SiTCPinit]
+Class="Function"
+Prototype="void SiTCPinit();"
+
+[SiTCPclose]
+Class="Function"
+Prototype="void SiTCPclose();"
+
+[SiTCPSetIPPort]
+Class="Function"
+Prototype="int SiTCPSetIPPort(char *IpAddr, unsigned int tcp, unsigned int udp);"
+
+[SiTCPCreateTCPSock]
+Class="Function"
+Prototype="int SiTCPCreateTCPSock();"
+
+[SiTCPCreateUDPSock]
+Class="Function"
+Prototype="int SiTCPCreateUDPSock();"
+
+[SiTCPCloseUDPSock]
+Class="Function"
+Prototype="int SiTCPCloseUDPSock();"
+
+[SiTCPCloseTCPSock]
+Class="Function"
+Prototype="int SiTCPCloseTCPSock();"
+
+[SiTCPRBCPskeleton]
+Class="Function"
+Prototype="void SiTCPRBCPskeleton(unsigned char type, unsigned char command, unsigned char id, unsigned char length, unsigned int address);"
+
+[SiTCPrcvRBCP_ACK]
+Class="Function"
+Prototype="int SiTCPrcvRBCP_ACK(int output);"
+
+[SiTCPGetTCPSock]
+Class="Function"
+Prototype="int SiTCPGetTCPSock();"
+
+[SiTCPGetUDPSock]
+Class="Function"
+Prototype="int SiTCPGetUDPSock();"
+
+[SiTCPGetSiTCPsndHeader]
+Class="Function"
+Prototype="struct bcp_header SiTCPGetSiTCPsndHeader();"
+
Index: l2d2_easyroc/cvibuild.l2d/Debug/camac.nidobj
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/l2d2_easyroc/cvibuild.l2d/Debug/camac.nidobj
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/cvibuild.l2d/Debug/camac.obj
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/l2d2_easyroc/cvibuild.l2d/Debug/camac.obj
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/cvibuild.l2d/Debug/camac.obj.cvidefprots
===================================================================
--- l2d2_easyroc/cvibuild.l2d/Debug/camac.obj.cvidefprots (nonexistent)
+++ l2d2_easyroc/cvibuild.l2d/Debug/camac.obj.cvidefprots (revision 291)
@@ -0,0 +1,20 @@
+[CAMAC_map]
+Class="Function"
+Prototype="void CAMAC_map();"
+
+[CAMAC_cccc]
+Class="Function"
+Prototype="void CAMAC_cccc(unsigned long *c_ext);"
+
+[CAMAC_cccd]
+Class="Function"
+Prototype="void CAMAC_cccd(unsigned long *c_ext, unsigned long *c_sw);"
+
+[CAMAC_ccci]
+Class="Function"
+Prototype="void CAMAC_ccci(unsigned long *c_ext, unsigned long *c_sw);"
+
+[CAMAC_cccz]
+Class="Function"
+Prototype="void CAMAC_cccz(unsigned long *c_ext);"
+
Index: l2d2_easyroc/cvibuild.l2d/Debug/dlldependencies.txt
===================================================================
--- l2d2_easyroc/cvibuild.l2d/Debug/dlldependencies.txt (nonexistent)
+++ l2d2_easyroc/cvibuild.l2d/Debug/dlldependencies.txt (revision 291)
@@ -0,0 +1,8 @@
+cvi.lib
+cvirte.dll
+kernel32.lib
+KERNEL32.dll
+WS2_32.Lib
+WS2_32.dll
+user32.lib
+USER32.dll
Index: l2d2_easyroc/cvibuild.l2d/Debug/easiroc.nidobj
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/l2d2_easyroc/cvibuild.l2d/Debug/easiroc.nidobj
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/cvibuild.l2d/Debug/easiroc.obj
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/l2d2_easyroc/cvibuild.l2d/Debug/easiroc.obj
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/cvibuild.l2d/Debug/easiroc.obj.cvidefprots
===================================================================
--- l2d2_easyroc/cvibuild.l2d/Debug/easiroc.obj.cvidefprots (nonexistent)
+++ l2d2_easyroc/cvibuild.l2d/Debug/easiroc.obj.cvidefprots (revision 291)
@@ -0,0 +1,80 @@
+[usleep]
+Class="Function"
+Prototype="void usleep(long long usec);"
+
+[easiroc_Init]
+Class="Function"
+Prototype="int easiroc_Init(const char *SiTCP_MASTER_IP, unsigned int daq_mode);"
+
+[easiroc_Close]
+Class="Function"
+Prototype="void easiroc_Close();"
+
+[WriteData]
+Class="Function"
+Prototype="int WriteData(unsigned int sock, unsigned int data);"
+
+[PrepareFPGA]
+Class="Function"
+Prototype="void PrepareFPGA();"
+
+[PrepareSC]
+Class="Function"
+Prototype="void PrepareSC(int chipNo);"
+
+[PrepareReadSC]
+Class="Function"
+Prototype="void PrepareReadSC(int chipNo);"
+
+[DebugFPGA]
+Class="Function"
+Prototype="int DebugFPGA(unsigned int socket);"
+
+[TransmitSC]
+Class="Function"
+Prototype="int TransmitSC(unsigned int socket);"
+
+[TransmitReadSC]
+Class="Function"
+Prototype="int TransmitReadSC(unsigned int socket);"
+
+[PreparePSC]
+Class="Function"
+Prototype="int PreparePSC(int CurrentCh, int CurrentProbeType);"
+
+[TransmitProbe]
+Class="Function"
+Prototype="int TransmitProbe(unsigned int socket);"
+
+[easiroc_fTransmitSC]
+Class="Function"
+Prototype="int easiroc_fTransmitSC();"
+
+[easiroc_fTransmitReadSC]
+Class="Function"
+Prototype="int easiroc_fTransmitReadSC();"
+
+[easiroc_fAsicInitialize]
+Class="Function"
+Prototype="int easiroc_fAsicInitialize();"
+
+[easiroc_fTransmitProbe]
+Class="Function"
+Prototype="int easiroc_fTransmitProbe(int CurrentCh, int CurrentProbe);"
+
+[ADCOneCycle_wHeader_ver2]
+Class="Function"
+Prototype="int ADCOneCycle_wHeader_ver2(unsigned int socket, FILE *file);"
+
+[ADCStop]
+Class="Function"
+Prototype="void ADCStop(unsigned int socket);"
+
+[ContinuousADC_ver2]
+Class="Function"
+Prototype="int ContinuousADC_ver2(unsigned int socket, char *file_name, int MaxCycleNum);"
+
+[easiroc_fDAQ]
+Class="Function"
+Prototype="int easiroc_fDAQ(char *file_name, int MaxCycleNum);"
+
Index: l2d2_easyroc/cvibuild.l2d/Debug/l2d.exe
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/l2d2_easyroc/cvibuild.l2d/Debug/l2d.exe
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/cvibuild.l2d/Debug/l2d.nidobj
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/l2d2_easyroc/cvibuild.l2d/Debug/l2d.nidobj
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/cvibuild.l2d/Debug/l2d.obj
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/l2d2_easyroc/cvibuild.l2d/Debug/l2d.obj
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/cvibuild.l2d/Debug/l2d.obj.cvidefprots
===================================================================
--- l2d2_easyroc/cvibuild.l2d/Debug/l2d.obj.cvidefprots (nonexistent)
+++ l2d2_easyroc/cvibuild.l2d/Debug/l2d.obj.cvidefprots (revision 291)
@@ -0,0 +1,24 @@
+[wait_loop]
+Class="Function"
+Prototype="void wait_loop(unsigned long iloop);"
+
+[cb_timer]
+Class="Function"
+Prototype="int cb_timer(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);"
+
+[update_plots]
+Class="Function"
+Prototype="int update_plots();"
+
+[daq_run]
+Class="Function"
+Prototype="int daq_run(void *functionData);"
+
+[WinMain]
+Class="Function"
+Prototype="int WinMain(struct HINSTANCE__ *hInstance, struct HINSTANCE__ *hPrevInstance, char *lpszCmdLine, int nCmdShow);"
+
+[max_from]
+Class="Function"
+Prototype="int max_from(int *array, int ifrom, int ito);"
+
Index: l2d2_easyroc/cvibuild.l2d/Debug/link_options.txt
===================================================================
--- l2d2_easyroc/cvibuild.l2d/Debug/link_options.txt (nonexistent)
+++ l2d2_easyroc/cvibuild.l2d/Debug/link_options.txt (revision 291)
@@ -0,0 +1,44 @@
+-nologo
+-out:c:\home\rokd\l2d2_easyroc\cvibuild.l2d\Debug\l2d.exe
+-arch:x86
+-timestamp
+-debug:2
+-res:c:\home\rokd\l2d2_easyroc\cvibuild.l2d\Debug\resources.res
+-entry:_CVIWinMainStartupCodeForDebugging@0
+-base:0x400000
+-linked:c:\home\rokd\l2d2_easyroc\cvibuild.l2d\Debug\linkersummary.txt
+-dlldeps:c:\home\rokd\l2d2_easyroc\cvibuild.l2d\Debug\dlldependencies.txt
+-licensing:c:\home\rokd\l2d2_easyroc\cvibuild.l2d\Debug\linkerlicensing.txt
+-browsedeps:c:\home\rokd\l2d2_easyroc\cvibuild.l2d\Debug\moduledependencies.txt
+-stackreserve:1048576
+-stackcommit:4096
+-in:c:\home\rokd\l2d2_easyroc\cvibuild.l2d\Debug\easiroc.obj
+-in:c:\home\rokd\l2d2_easyroc\cvibuild.l2d\Debug\l2d.obj
+-in:c:\home\rokd\l2d2_easyroc\cvibuild.l2d\Debug\sender.obj
+-in:c:\home\rokd\l2d2_easyroc\cvibuild.l2d\Debug\SiTCP.obj
+-more:c:\program files\national instruments\cvi2013\bin\msvc\cvistart.lib
+-more:c:\program files\national instruments\cvi2013\bin\msvc\cvi.lib
+-more:c:\program files\national instruments\cvi2013\sdk\lib\msvc\advapi32.lib
+-more:c:\ProgramData\National Instruments\CVI2013\bin\msvc\analysis.lib
+-more:c:\home\rokd\l2d2_easyroc\cvibuild.l2d\Debug\CAENV965.obj
+-more:c:\home\rokd\l2d2_easyroc\cvibuild.l2d\Debug\camac.obj
+-more:c:\Program Files\National Instruments\CVI2013\bin\msvc\cviauto.lib
+-more:c:\Program Files\National Instruments\CVI2013\bin\msvc\cviddc.lib
+-more:c:\Program Files\National Instruments\CVI2013\bin\msvc\cvidotnet.lib
+-more:c:\Program Files\National Instruments\CVI2013\bin\msvc\cvinetstreams.lib
+-more:c:\Program Files\National Instruments\CVI2013\bin\msvc\cvinetv.lib
+-more:c:\Program Files\National Instruments\CVI2013\bin\msvc\cvintwrk.lib
+-more:c:\Program Files\National Instruments\CVI2013\bin\msvc\cvitdms.lib
+-more:c:\program files\national instruments\cvi2013\sdk\lib\msvc\gdi32.lib
+-more:c:\Program Files\National Instruments\CVI2013\bin\msvc\gpib.lib
+-more:c:\Program Files\National Instruments\Shared\CVI\Bin\msvc\ivi.lib
+-more:c:\program files\national instruments\cvi2013\sdk\lib\msvc\kernel32.lib
+-more:c:\Program Files\National Instruments\CVI2013\bin\msvc\nivxi.lib
+-more:c:\Program Files\National Instruments\CVI2013\bin\msvc\omp.lib
+-more:c:\Program Files\National Instruments\CVI2013\toolslib\toolbox\msvc\toolbox.obj
+-more:c:\program files\national instruments\cvi2013\sdk\lib\msvc\user32.lib
+-more:c:\program files\national instruments\cvi2013\sdk\lib\msvc\uuid.lib
+-more:c:\Program Files\National Instruments\Shared\CVI\Bin\msvc\visa.lib
+-more:c:\home\rokd\l2d2_easyroc\cvibuild.l2d\Debug\wienvme_dll.obj
+-more:c:\program files\national instruments\cvi2013\sdk\lib\msvc\winmm.lib
+-more:c:\Program Files\Microsoft SDKs\Windows\v7.1A\Lib\WS2_32.Lib
\ No newline at end of file
Index: l2d2_easyroc/cvibuild.l2d/Debug/linkersummary.txt
===================================================================
--- l2d2_easyroc/cvibuild.l2d/Debug/linkersummary.txt (nonexistent)
+++ l2d2_easyroc/cvibuild.l2d/Debug/linkersummary.txt (revision 291)
@@ -0,0 +1,12 @@
+easiroc.obj
+l2d.obj
+sender.obj
+SiTCP.obj
+cvi.lib
+analysis.lib
+cvistart.lib
+kernel32.lib
+WS2_32.Lib
+user32.lib
+EXE Symbol Module
+Resource Module
Index: l2d2_easyroc/cvibuild.l2d/Debug/moduledependencies.txt
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/l2d2_easyroc/cvibuild.l2d/Debug/moduledependencies.txt
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/cvibuild.l2d/Debug/resources.in.rc
===================================================================
--- l2d2_easyroc/cvibuild.l2d/Debug/resources.in.rc (nonexistent)
+++ l2d2_easyroc/cvibuild.l2d/Debug/resources.in.rc (revision 291)
@@ -0,0 +1,37 @@
+#include "c:\program files\national instruments\cvi2013\sdk\include\winver.h"
+
+2 ICON "c:\\program files\\national instruments\\cvi2013\\bin\\default.ico"
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ 65535 "l2d"
+END
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 1,0,0,0
+ PRODUCTVERSION 1,0,0,0
+ FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
+ FILEFLAGS 0x1L
+ FILEOS VOS__WINDOWS32
+ FILETYPE VFT_APP
+ FILESUBTYPE VFT_UNKNOWN
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "CompanyName", "\0"
+ VALUE "FileDescription", "l2d (Debug x86)\0"
+ VALUE "FileVersion", "1.0\0"
+ VALUE "InternalName", "l2d\0"
+ VALUE "LegalCopyright", "Copyright © 2018\0"
+ VALUE "OriginalFilename", "l2d.exe\0"
+ VALUE "ProductName", " l2d\0"
+ VALUE "ProductVersion", "1.0\0"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 0x4b0
+ END
+END
Index: l2d2_easyroc/cvibuild.l2d/Debug/resources.res
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/l2d2_easyroc/cvibuild.l2d/Debug/resources.res
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/cvibuild.l2d/Debug/sender.nidobj
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/l2d2_easyroc/cvibuild.l2d/Debug/sender.nidobj
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/cvibuild.l2d/Debug/sender.obj
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/l2d2_easyroc/cvibuild.l2d/Debug/sender.obj
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/cvibuild.l2d/Debug/sender.obj.cvidefprots
===================================================================
--- l2d2_easyroc/cvibuild.l2d/Debug/sender.obj.cvidefprots (nonexistent)
+++ l2d2_easyroc/cvibuild.l2d/Debug/sender.obj.cvidefprots (revision 291)
@@ -0,0 +1,36 @@
+[SenderInit]
+Class="Function"
+Prototype="void SenderInit();"
+
+[SenderClose]
+Class="Function"
+Prototype="void SenderClose();"
+
+[Senderudp_send]
+Class="Function"
+Prototype="void Senderudp_send(unsigned int address, int data);"
+
+[Senderudp_recv]
+Class="Function"
+Prototype="int Senderudp_recv(unsigned int address, int data);"
+
+[SenderRBCPpacket_send]
+Class="Function"
+Prototype="void SenderRBCPpacket_send(unsigned int address, unsigned char length, int *data);"
+
+[SenderRBCPpacket_recv]
+Class="Function"
+Prototype="void SenderRBCPpacket_recv(unsigned int address, unsigned char length, int *data);"
+
+[SenderRBCP_multi_packet_send]
+Class="Function"
+Prototype="void SenderRBCP_multi_packet_send(unsigned int address, unsigned int total_length, int *data);"
+
+[Senderread_madc]
+Class="Function"
+Prototype="int Senderread_madc(int data);"
+
+[Senderclear_all]
+Class="Function"
+Prototype="void Senderclear_all();"
+
Index: l2d2_easyroc/cvibuild.l2d/Debug/wienvme_dll.nidobj
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/l2d2_easyroc/cvibuild.l2d/Debug/wienvme_dll.nidobj
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/cvibuild.l2d/Debug/wienvme_dll.obj
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/l2d2_easyroc/cvibuild.l2d/Debug/wienvme_dll.obj
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/cvibuild.l2d/Debug/wienvme_dll.obj.cvidefprots
===================================================================
--- l2d2_easyroc/cvibuild.l2d/Debug/wienvme_dll.obj.cvidefprots (nonexistent)
+++ l2d2_easyroc/cvibuild.l2d/Debug/wienvme_dll.obj.cvidefprots (revision 291)
@@ -0,0 +1,100 @@
+[WIENVME_load]
+Class="Function"
+Prototype="void WIENVME_load(char *module_path);"
+
+[WIENVME_open]
+Class="Function"
+Prototype="int WIENVME_open(int *hHandle, unsigned char AddMod, char *device_name, unsigned short module_number);"
+
+[WIENVME_open24]
+Class="Function"
+Prototype="int WIENVME_open24();"
+
+[WIENVME_open32]
+Class="Function"
+Prototype="int WIENVME_open32();"
+
+[WIENVME_start]
+Class="Function"
+Prototype="int WIENVME_start(char *module_path);"
+
+[WIENVME_unload]
+Class="Function"
+Prototype="void WIENVME_unload();"
+
+[WIENVME_close]
+Class="Function"
+Prototype="int WIENVME_close(int hHandle);"
+
+[WIENVME_close24]
+Class="Function"
+Prototype="int WIENVME_close24();"
+
+[WIENVME_close32]
+Class="Function"
+Prototype="int WIENVME_close32();"
+
+[WIENVME_stop]
+Class="Function"
+Prototype="int WIENVME_stop();"
+
+[WIENVME_reset]
+Class="Function"
+Prototype="int WIENVME_reset();"
+
+[WIENVME_read8]
+Class="Function"
+Prototype="int WIENVME_read8(int hHandle, unsigned long n, unsigned long at, void *buff);"
+
+[WIENVME_read16]
+Class="Function"
+Prototype="int WIENVME_read16(int hHandle, unsigned long n, unsigned long at, void *buff);"
+
+[WIENVME_read32]
+Class="Function"
+Prototype="int WIENVME_read32(int hHandle, unsigned long n, unsigned long at, void *buff);"
+
+[WIENVME_write8]
+Class="Function"
+Prototype="int WIENVME_write8(int hHandle, unsigned long n, unsigned long at, void *buff);"
+
+[WIENVME_write16]
+Class="Function"
+Prototype="int WIENVME_write16(int hHandle, unsigned long n, unsigned long at, void *buff);"
+
+[WIENVME_write32]
+Class="Function"
+Prototype="int WIENVME_write32(int hHandle, unsigned long n, unsigned long at, void *buff);"
+
+[WIENVME_VME_R]
+Class="Function"
+Prototype="short WIENVME_VME_R(unsigned short AM, unsigned short DW, unsigned int VME_Address, unsigned int *Data);"
+
+[WIENVME_VME_W]
+Class="Function"
+Prototype="short WIENVME_VME_W(unsigned short AM, unsigned short DW, unsigned int VME_Address, unsigned int Data);"
+
+[WIENVME_VME_MW]
+Class="Function"
+Prototype="short WIENVME_VME_MW(unsigned short AM, unsigned short DW, unsigned int VME_Address, unsigned int Data);"
+
+[WIENVME_VME_MWRST]
+Class="Function"
+Prototype="short WIENVME_VME_MWRST();"
+
+[WIENVME_VME_MWEXEC]
+Class="Function"
+Prototype="short WIENVME_VME_MWEXEC();"
+
+[WIENVME_VME_MR]
+Class="Function"
+Prototype="short WIENVME_VME_MR(unsigned short AM, unsigned short DW, unsigned int VME_Address, unsigned int *Data);"
+
+[WIENVME_VME_MRRST]
+Class="Function"
+Prototype="short WIENVME_VME_MRRST();"
+
+[WIENVME_VME_MREXEC]
+Class="Function"
+Prototype="short WIENVME_VME_MREXEC(unsigned int *Data);"
+
Index: l2d2_easyroc/cvibuild.l2d/build.ini
===================================================================
--- l2d2_easyroc/cvibuild.l2d/build.ini (nonexistent)
+++ l2d2_easyroc/cvibuild.l2d/build.ini (revision 291)
@@ -0,0 +1,226 @@
+[File 0001]
+Path = "/c/Program Files/National Instruments/CVI2012/instr/CAENV965/CAENV965.c"
+Object Format_Debug = "Win32-MSVC"
+Object Format_Release = "Unknown"
+Object Format_Debug64 = "Unknown"
+Object Format_Release64 = "Unknown"
+ForceCompile_Debug = False
+ForceCompile_Release = False
+ForceCompile_Debug64 = False
+ForceCompile_Release64 = False
+Object Format Version = 1
+Header Dependencies Line0001 = "2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,"
+Header Dependencies Line0002 = "32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58"
+Header Dependencies Line0003 = ",59,60,61,62,64,65,66,67,68,71,"
+
+[File 0002]
+Path = "/c/Program Files/National Instruments/CVI2012/instr/CAMAC_2000/camac.c"
+Object Format_Debug = "Win32-MSVC"
+Object Format_Release = "Unknown"
+Object Format_Debug64 = "Unknown"
+Object Format_Release64 = "Unknown"
+ForceCompile_Debug = False
+ForceCompile_Release = False
+ForceCompile_Debug64 = False
+ForceCompile_Release64 = False
+Object Format Version = 1
+Header Dependencies Line0001 = "2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,"
+Header Dependencies Line0002 = "32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58"
+Header Dependencies Line0003 = ",59,60,61,62,63,"
+
+[File 0003]
+Path = "/c/home/rokd/temp/l2d2_easyroc/easiroc.c"
+Object Format_Debug = "Win32-MSVC"
+Object Format_Release = "Unknown"
+Object Format_Debug64 = "Unknown"
+Object Format_Release64 = "Unknown"
+ForceCompile_Debug = True
+ForceCompile_Release = True
+ForceCompile_Debug64 = True
+ForceCompile_Release64 = True
+Object Format Version = 1
+Header Dependencies Line0001 = "2,3,5,8,9,17,20,22,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,4"
+Header Dependencies Line0002 = "5,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,74,75,76,77,80,"
+
+[File 0004]
+Path = "/c/home/rokd/temp/l2d2_easyroc/l2d.c"
+Object Format_Debug = "Win32-MSVC"
+Object Format_Release = "Unknown"
+Object Format_Debug64 = "Unknown"
+Object Format_Release64 = "Unknown"
+ForceCompile_Debug = True
+ForceCompile_Release = False
+ForceCompile_Debug64 = False
+ForceCompile_Release64 = False
+Object Format Version = 1
+Header Dependencies Line0001 = "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,25,26,27,28,29,30,31"
+Header Dependencies Line0002 = ",32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,5"
+Header Dependencies Line0003 = "8,59,60,61,62,69,70,72,73,74,75,76,77,78,80,"
+
+[File 0005]
+Path = "/c/home/rokd/temp/l2d2_easyroc/sender.c"
+Object Format_Debug = "Win32-MSVC"
+Object Format_Release = "Unknown"
+Object Format_Debug64 = "Unknown"
+Object Format_Release64 = "Unknown"
+ForceCompile_Debug = False
+ForceCompile_Release = True
+ForceCompile_Debug64 = True
+ForceCompile_Release64 = True
+Object Format Version = 1
+Header Dependencies Line0001 = "2,3,5,8,9,17,20,22,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,4"
+Header Dependencies Line0002 = "5,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,73,74,75,76,77,78,"
+
+[File 0006]
+Path = "/c/home/rokd/temp/l2d2_easyroc/SiTCP.c"
+Object Format_Debug = "Win32-MSVC"
+Object Format_Release = "Unknown"
+Object Format_Debug64 = "Unknown"
+Object Format_Release64 = "Unknown"
+ForceCompile_Debug = False
+ForceCompile_Release = True
+ForceCompile_Debug64 = True
+ForceCompile_Release64 = True
+Object Format Version = 1
+Header Dependencies Line0001 = "2,3,5,8,9,17,20,22,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,4"
+Header Dependencies Line0002 = "5,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,73,74,75,76,77,"
+
+[File 0007]
+Path = "/c/Program Files/National Instruments/CVI2012/instr/WIENVME_DLL/wienvme_dll.c"
+Object Format_Debug = "Win32-MSVC"
+Object Format_Release = "Unknown"
+Object Format_Debug64 = "Unknown"
+Object Format_Release64 = "Unknown"
+ForceCompile_Debug = False
+ForceCompile_Release = False
+ForceCompile_Debug64 = False
+ForceCompile_Release64 = False
+Object Format Version = 1
+Header Dependencies Line0001 = "2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,3"
+Header Dependencies Line0002 = "1,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,"
+Header Dependencies Line0003 = "58,59,60,61,62,"
+
+[Create Executable]
+Target Creation Date_Debug = 3602830855
+Force Creation of Target_Debug = False
+Needs To Rebuild Resource File_Debug = False
+File Version Incremented_Debug = False
+Target Creation Date_Release = 0
+Force Creation of Target_Release = False
+Needs To Rebuild Resource File_Release = True
+File Version Incremented_Release = False
+Target Creation Date_Debug64 = 0
+Force Creation of Target_Debug64 = False
+Needs To Rebuild Resource File_Debug64 = True
+File Version Incremented_Debug64 = False
+Target Creation Date_Release64 = 0
+Force Creation of Target_Release64 = False
+Needs To Rebuild Resource File_Release64 = True
+File Version Incremented_Release64 = False
+Uses NIReports = 0
+Uses USI = 0
+Uses TDM Streaming = 0
+Uses Analysis = 1
+Uses Network Variable = 0
+Uses DAQmx = 0
+Uses CAN = 0
+Uses VISA = 0
+Uses GPIB = 0
+Uses IVI = 0
+Uses IMAQ = 0
+Uses FlexMotion = 0
+Uses Motion = 0
+Uses DMM = 0
+Uses FGen = 0
+Uses Scope = 0
+Uses HSDIO = 0
+
+[Included Headers]
+Header 0079 = "/c/home/rokd/temp/l2d2_easyroc/easiroc.c"
+Header 0072 = "/c/home/rokd/temp/l2d2_easyroc/l2d_ui.h"
+Header 0073 = "/c/home/rokd/temp/l2d2_easyroc/SiTCP.h"
+Header 0078 = "/c/home/rokd/temp/l2d2_easyroc/sender.h"
+Header 0080 = "/c/home/rokd/temp/l2d2_easyroc/easiroc.h"
+Header 0001 = "/c/Program Files/National Instruments/CVI2012/include/userint.h"
+Header 0002 = "/c/Program Files/National Instruments/CVI2012/include/cvidef.h"
+Header 0003 = "/c/Program Files/National Instruments/CVI2012/include/cvirte.h"
+Header 0004 = "/c/Program Files/National Instruments/CVI2012/include/utility.h"
+Header 0005 = "/c/Program Files/National Instruments/CVI2012/include/ansi/stdlib.h"
+Header 0006 = "/c/Program Files/National Instruments/CVI2012/include/ansi_c.h"
+Header 0007 = "/c/Program Files/National Instruments/CVI2012/include/ansi/assert.h"
+Header 0008 = "/c/Program Files/National Instruments/CVI2012/include/ansi/ctype.h"
+Header 0009 = "/c/Program Files/National Instruments/CVI2012/include/ansi/errno.h"
+Header 0010 = "/c/Program Files/National Instruments/CVI2012/include/ansi/float.h"
+Header 0011 = "/c/Program Files/National Instruments/CVI2012/include/ansi/limits.h"
+Header 0012 = "/c/Program Files/National Instruments/CVI2012/include/ansi/locale.h"
+Header 0013 = "/c/Program Files/National Instruments/CVI2012/include/ansi/math.h"
+Header 0014 = "/c/Program Files/National Instruments/CVI2012/include/mbsupp.h"
+Header 0015 = "/c/Program Files/National Instruments/CVI2012/include/ansi/setjmp.h"
+Header 0016 = "/c/Program Files/National Instruments/CVI2012/include/ansi/signal.h"
+Header 0017 = "/c/Program Files/National Instruments/CVI2012/include/ansi/stdarg.h"
+Header 0018 = "/c/Program Files/National Instruments/CVI2012/include/ansi/stddef.h"
+Header 0019 = "/c/Program Files/National Instruments/CVI2012/include/ansi/stdint.h"
+Header 0020 = "/c/Program Files/National Instruments/CVI2012/include/ansi/stdio.h"
+Header 0021 = "/c/Program Files/National Instruments/CVI2012/include/stdlibex.h"
+Header 0022 = "/c/Program Files/National Instruments/CVI2012/include/ansi/string.h"
+Header 0023 = "/c/Program Files/National Instruments/CVI2012/include/ansi/time.h"
+Header 0024 = "/c/Program Files/National Instruments/CVI2012/instr/WIENVME_DLL/wienvme_dll.h"
+Header 0025 = "/c/Program Files/National Instruments/CVI2012/sdk/include/Windows.h"
+Header 0026 = "/c/Program Files/National Instruments/CVI2012/sdk/include/sdkddkver.h"
+Header 0027 = "/c/Program Files/National Instruments/CVI2012/sdk/include/driverspecs.h"
+Header 0028 = "/c/Program Files/National Instruments/CVI2012/sdk/include/specstrings.h"
+Header 0029 = "/c/Program Files/National Instruments/CVI2012/sdk/include/sal_supp.h"
+Header 0030 = "/c/Program Files/National Instruments/CVI2012/sdk/include/specstrings_supp.h"
+Header 0031 = "/c/Program Files/National Instruments/CVI2012/sdk/include/specstrings_strict.h"
+Header 0032 = "/c/Program Files/National Instruments/CVI2012/sdk/include/specstrings_undef.h"
+Header 0033 = "/c/Program Files/National Instruments/CVI2012/sdk/include/sdv_driverspecs.h"
+Header 0034 = "/c/Program Files/National Instruments/CVI2012/sdk/include/WinDef.h"
+Header 0035 = "/c/Program Files/National Instruments/CVI2012/sdk/include/WinNT.h"
+Header 0036 = "/c/Program Files/National Instruments/CVI2012/sdk/include/kernelspecs.h"
+Header 0037 = "/c/Program Files/National Instruments/CVI2012/sdk/include/BaseTsd.h"
+Header 0038 = "/c/Program Files/National Instruments/CVI2012/sdk/include/Guiddef.h"
+Header 0039 = "/c/Program Files/National Instruments/CVI2012/sdk/include/PshPack4.h"
+Header 0040 = "/c/Program Files/National Instruments/CVI2012/sdk/include/PopPack.h"
+Header 0041 = "/c/Program Files/National Instruments/CVI2012/sdk/include/PshPack2.h"
+Header 0042 = "/c/Program Files/National Instruments/CVI2012/sdk/include/PshPack8.h"
+Header 0043 = "/c/Program Files/National Instruments/CVI2012/sdk/include/ktmtypes.h"
+Header 0044 = "/c/Program Files/National Instruments/CVI2012/sdk/include/WinBase.h"
+Header 0045 = "/c/Program Files/National Instruments/CVI2012/sdk/include/WinError.h"
+Header 0046 = "/c/Program Files/National Instruments/CVI2012/sdk/include/WinGDI.h"
+Header 0047 = "/c/Program Files/National Instruments/CVI2012/sdk/include/PshPack1.h"
+Header 0048 = "/c/Program Files/National Instruments/CVI2012/sdk/include/WinUser.h"
+Header 0049 = "/c/Program Files/National Instruments/CVI2012/sdk/include/Tvout.h"
+Header 0050 = "/c/Program Files/National Instruments/CVI2012/sdk/include/WinNls.h"
+Header 0051 = "/c/Program Files/National Instruments/CVI2012/sdk/include/WinCon.h"
+Header 0052 = "/c/Program Files/National Instruments/CVI2012/sdk/include/WinVer.h"
+Header 0053 = "/c/Program Files/National Instruments/CVI2012/sdk/include/VerRsrc.h"
+Header 0054 = "/c/Program Files/National Instruments/CVI2012/sdk/include/WinReg.h"
+Header 0055 = "/c/Program Files/National Instruments/CVI2012/sdk/include/Reason.h"
+Header 0056 = "/c/Program Files/National Instruments/CVI2012/sdk/include/WinNetWk.h"
+Header 0057 = "/c/Program Files/National Instruments/CVI2012/sdk/include/wnnc.h"
+Header 0058 = "/c/Program Files/National Instruments/CVI2012/sdk/include/StrAlign.h"
+Header 0059 = "/c/Program Files/National Instruments/CVI2012/sdk/include/WinSvc.h"
+Header 0060 = "/c/Program Files/National Instruments/CVI2012/sdk/include/Mcx.h"
+Header 0061 = "/c/Program Files/National Instruments/CVI2012/sdk/include/Imm.h"
+Header 0062 = "/c/Program Files/National Instruments/CVI2012/sdk/include/Ime_cmodes.h"
+Header 0063 = "/c/Program Files/National Instruments/CVI2012/instr/CAMAC_2000/camac.h"
+Header 0064 = "/c/Program Files/National Instruments/CVI2012/instr/CAENV965/CAENV965.h"
+Header 0065 = "/c/Program Files/National Instruments/Shared/CVI/include/ivi.h"
+Header 0066 = "/c/Program Files/National Instruments/Shared/CVI/include/visa.h"
+Header 0067 = "/c/Program Files/National Instruments/Shared/CVI/include/visatype.h"
+Header 0068 = "/c/Program Files/National Instruments/Shared/CVI/include/vpptype.h"
+Header 0069 = "/c/ProgramData/National Instruments/CVI2012/include/analysis.h"
+Header 0070 = "/c/ProgramData/National Instruments/CVI2012/include/advanlys.h"
+Header 0071 = "/c/Program Files/National Instruments/CVI2012/instr/CAENV965/CAENV965_DEF.h"
+Header 0074 = "/c/Program Files/National Instruments/CVI2012/sdk/include/WinSock2.h"
+Header 0075 = "/c/Program Files/National Instruments/CVI2012/sdk/include/ws2def.h"
+Header 0076 = "/c/Program Files/National Instruments/CVI2012/sdk/include/inaddr.h"
+Header 0077 = "/c/Program Files/National Instruments/CVI2012/sdk/include/Qos.h"
+Max32 Header Number = 80
+
+[TPC Settings]
+TPCPath = ""
+TPCDate = 0
+TPCPath x64 = ""
+TPCDate x64 = 0
+
Index: l2d2_easyroc/cvibuild.l2d/dependencies.bri
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/l2d2_easyroc/cvibuild.l2d/dependencies.bri
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/d2r.cpp
===================================================================
--- l2d2_easyroc/d2r.cpp (nonexistent)
+++ l2d2_easyroc/d2r.cpp (revision 291)
@@ -0,0 +1,690 @@
+#include "stdio.h"
+#include "TROOT.h"
+#include "TSystem.h"
+#include "TFile.h"
+#include "TH1F.h"
+#include "TH2F.h"
+#include "TF1.h"
+#include "TMath.h"
+#include "TStyle.h"
+#include "TCanvas.h"
+#include "TLine.h"
+
+//kobayashi
+#include "TTree.h"
+
+//~ #define USE_ZLIB
+#ifdef USE_ZLIB
+# include "zlib.h"
+#endif
+// ------------------------------------------------------------------------------
+
+#define POSMARG 1000
+
+#define READBUFFERLENGTH 500000
+
+// data format
+#define MAXDATA 64
+#define NCH 32
+#define ANALYSE_CH 32
+#define MPPC_1_CH 0
+#define MPPC_2_CH 1
+#define TRIGGER_CH 31
+//~ #define ANALYSE_CH 8
+//~ #define MPPC_1_CH 2
+//~ #define MPPC_2_CH 5
+#define REF_CH 0
+#define TDC_BIN (25./1000.) //1 TDC bin in ns
+#define MIKRO_BIN 0.3595/1000. //1 mikro step in mm
+
+#define RUNREC_ID 1
+#define ENDREC_ID 2
+#define POSREC_ID 3
+#define EVTREC_ID 4
+
+//define testpulse
+typedef struct {
+ unsigned long id,len;
+ unsigned long fver,time;
+ unsigned long nev,nch,ped,xy;
+ long nx,x0,dx,ny,y0,dy;
+} RUNREC;
+RUNREC *runrec;
+RUNREC run;
+
+typedef struct {
+ unsigned long id,len;
+ unsigned long time;
+} ENDREC;
+ENDREC *endrec;
+
+typedef struct {
+ unsigned long id,len;
+ unsigned long time;
+ long ix,x,xset,iy,y,yset;
+} POSREC;
+POSREC *posrec;
+POSREC pos;
+
+typedef struct {
+ unsigned long id,len;
+ unsigned long nev;
+ unsigned short data[MAXDATA];
+} EVTREC;
+EVTREC *evtrec;
+
+// ------------------------------------------------------------------------------
+
+int d2r(char* dfile0="test", double qdcmi=0, double qdcma=4096, double tdcmi=-1.5, double tdcma=3, double adc_cor_min=200.0, double deltaT_ctdcdiff=0)
+{
+ int dbg=0;
+ printf(" dat 2 root conversion program\nUsage:\nd2r(input file -.dat, TDC min [ps], TDC max [ps], QDC min, QDC max)\n\n");
+
+ char fullname[256], sbuff[256];
+ FILE *fp;
+
+ //Chanel information
+ //~ int chmapx[NCH]={7,6,5,4,3,2,1,0};
+ //~ int chmapx[NCH]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19};
+ int chmapx[NCH]; for(int i=0; i<NCH; i++) {chmapx[i]=i;};
+
+ //~ double padcenter[NCH][2]={ {201000, 210000},
+ //~ {183000, 210000},
+ //~ {165000, 210000},
+ //~ {147000, 210000},
+ //~ {129000, 210000},
+ //~ {111000, 210000},
+ //~ { 93000, 210000},
+ //~ { 75000, 210000} };
+//~ // double tdcoffset[NCH]={57.78, 57.28, 57.86, 57.64, 56.06, 56.46, 57.5, 57.41};
+ //~ double tdcoffset[NCH]={2311*TDC_BIN, 2291*TDC_BIN, 2314*TDC_BIN, 2306*TDC_BIN,
+ //~ 2242*TDC_BIN, 2258*TDC_BIN, 2300*TDC_BIN, 2296*TDC_BIN};
+ double padcenter[NCH][2]; for(int i=0; i<NCH; i++) {padcenter[i][0]=0; padcenter[i][1]=0;};
+ double tdcoffset[NCH]; for(int i=0; i<NCH; i++) {tdcoffset[i]=0;};
+ sprintf(fullname, "d2r.ini");
+ if( (fp=fopen(fullname, "rt")) == NULL )
+ printf("Cannot open pad centers file %s !!!\n", fullname);
+ else {
+ printf("Opened pad centers file %s\n", fullname);
+ fgets(sbuff,256, fp);printf("%s", sbuff);
+ for(int i=0; i<NCH; i++)
+ fscanf(fp, "%lf %lf %lf\n", &padcenter[i][0], &padcenter[i][1], &tdcoffset[i]);
+ fclose(fp);
+ }
+ for(int i=0; i<NCH; i++) 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} };
+ double corpar[NCH][3]; for(int i=0; i<NCH; i++) {corpar[i][0]=0.0; corpar[i][1]=0.005; corpar[i][2]=0.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], htitle[256];
+ double adc,tdc;
+ TH1F *hadc[NCH], *hadc_cut[NCH], *hadc_cut_2[NCH];
+ TH1F *htdc[NCH], *htdc_cut[NCH], *htdc_cut_2[NCH], *hctdc[NCH];
+ TH2F *h2d[NCH], *hcor[NCH];
+ TH2F *hdiffcor[NCH][NCH];
+ TH2F *hdiffcor_low[NCH][NCH];
+ TH2F *hdiffcor_hi[NCH][NCH];
+ TH2F *hadccor;
+ TH2F *htdccor;
+ TH2F *hcoradctdc0, *hcoradctdc1, hcoradctdc01, hcoradctdc11;
+ TH1F *htesttdc1, *htesttdc2;
+ TTree *ftt;
+
+ TH1F *htdcdiff, *htdcdiff_cut, *htdcdiff_cut_2;
+
+ double ref_cut_1_lo = qdcmi;
+ double ref_cut_1_hi = qdcma;
+ double ref_cut_2_lo = tdcmi;
+ double ref_cut_2_hi = tdcma;
+
+ //kobayashi
+ double t_adc0, t_tdc0, t_adc1, t_tdc1, t_ctdc;
+
+ //data buffer
+ char readbuf[READBUFFERLENGTH];
+ runrec = (RUNREC *) readbuf;
+ endrec = (ENDREC *) readbuf;
+ posrec = (POSREC *) readbuf;
+ evtrec = (EVTREC *) readbuf;
+
+ //data file
+#ifdef USE_ZLIB
+ gzFile dfp;
+#else
+ FILE *dfp;
+#endif
+ char dfile[256];
+ int ftype=0, fcount=1;
+ do {
+ switch(ftype++) {
+ case 0:
+ sprintf(dfile, "data/%s_file%02d.dat", dfile0, fcount);
+ break;
+ case 1:
+ sprintf(dfile, "data/%s_file%02d.dat.gz", dfile0, fcount);
+ break;
+ case 2:
+ sprintf(dfile, "data/%s_file%02d.gz", dfile0, fcount);
+ break;
+ default:
+ printf(" Cannot find data file for %s !!!\n", dfile0);
+ return -1;
+ }
+#ifdef USE_ZLIB
+ dfp=gzopen(dfile,"rb");
+#else
+ dfp=fopen(dfile,"rb");
+#endif
+
+ } while(!dfp);
+ printf("Opened data file %s\n", dfile);
+
+ //opens ROOT file
+ TFile *rootfile; char fnameroot[256];
+ sprintf(fnameroot, "root/%s.root", dfile0);
+ //rootfile = (TFile *) gROOT->FindObjectAny(dfile0);
+ //if (rootfile!=NULL) {printf("!!!\n");rootfile->Close();}
+ //rootfile = new TFile(fnameroot);
+ //if(rootfile) rootfile->Close();
+ rootfile = new TFile(fnameroot,"RECREATE",dfile0);
+
+// -----------------------------------------------
+ // loop trough records
+ UInt_t rec_id, rec_len;
+ unsigned ulsize = 4;
+ int ceve=0;
+ int end_of_file = 0;
+
+ while(1) {
+#ifdef USE_ZLIB
+ if(gzeof(dfp)) end_of_file = 1;
+#else
+ if(feof(dfp)) end_of_file = 1;
+#endif
+
+#ifdef USE_ZLIB
+ gzread(dfp, (voidp)&readbuf, 2*ulsize);
+#else
+ fread( (void*)&readbuf, 2*ulsize, 1, dfp);
+
+#endif
+ rec_id=readbuf[0];
+ rec_len=readbuf[ulsize];
+ //kobayashi
+ if(rec_id == 4) rec_len = 140;
+
+ //~ if(dbg) printf("-----------------------------------------------\n");
+ //~ if(dbg) printf("[%d] rec_id = %d | rec_len = %d\n", ceve, rec_id, rec_len);
+
+ //printf("[%d] rec_id = %d | rec_len = %u\n", ceve, readbuf[0], readbuf[ulsize]);
+ switch(rec_id)
+ {
+
+ case RUNREC_ID:
+#ifdef USE_ZLIB
+ gzread(dfp, (voidp)&readbuf[2*ulsize], (rec_len-2*ulsize));
+#else
+ fread( (void*)&readbuf[2*ulsize], (rec_len-2*ulsize), 1, dfp);
+#endif
+ run=*runrec;
+
+ if(dbg) {
+ printf("RUNREC_ID\n");
+ printf("id = %d, len = %d, time = %d\n", run.id, run.len, run.time);
+ printf("nev = %d, nch = %d\n", run.nev, run.nch);
+ 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);
+
+ //~ break;
+ }
+
+ //create histograms
+
+ sprintf(hname, "htdcdiff");
+ htdcdiff = (TH1F*)gROOT->FindObject(hname);
+ if(htdcdiff) delete htdcdiff;
+ htdcdiff = new TH1F(hname, hname, 4096, -2048.5*TDC_BIN, 2047.5*TDC_BIN);
+ //~ htdcdiff = new TH1F(hname, hname, 4096, -0.5*TDC_BIN, 4095.5*TDC_BIN);
+
+ sprintf(hname, "htdcdiff_cut");
+ htdcdiff_cut = (TH1F*)gROOT->FindObject(hname);
+ if(htdcdiff_cut) delete htdcdiff_cut;
+ //~ htdcdiff_cut = new TH1F(hname, hname, 4096, -2048.5*TDC_BIN, 2047.5*TDC_BIN);
+ htdcdiff_cut = new TH1F(hname, hname, 4096, -2048.5*TDC_BIN, 2047.5*TDC_BIN);
+ //kobayashi
+ //~ htdcdiff_cut = new TH1F(hname, hname, 4096, -0.5*TDC_BIN, 4095.5*TDC_BIN);
+
+ sprintf(hname, "htdcdiff_cut_2");
+ htdcdiff_cut_2 = (TH1F*)gROOT->FindObject(hname);
+ if(htdcdiff_cut_2) delete htdcdiff_cut_2;
+ htdcdiff_cut_2 = new TH1F(hname, hname, 4096, -2048.5*TDC_BIN, 2047.5*TDC_BIN);
+ //~ htdcdiff_cut_2 = new TH1F(hname, hname, 4096, -0.5*TDC_BIN, 4095.5*TDC_BIN);
+
+ sprintf(hname, "hadccor");
+ hadccor = (TH2F*)gROOT->FindObject(hname);
+ if(hadccor) delete hadccor;
+ //~ hadccor = new TH2F(hname, hname, 256, 0, 4096, 256, 0, 4096);
+ hadccor = new TH2F(hname, hname, 256, 0, 4096, 256, -32768.5*TDC_BIN, 32767.5*TDC_BIN);
+
+ sprintf(hname, "htdccor");
+ htdccor = (TH2F*)gROOT->FindObject(hname);
+ if(htdccor) delete hadccor;
+ //~ htdccor = new TH2F(hname, hname, 512, 0, 1024*TDC_BIN, 512, 0, 1024*TDC_BIN);
+ htdccor = new TH2F(hname, hname, 512, 1024*TDC_BIN, 2048*TDC_BIN, 512, 1024*TDC_BIN, 2048*TDC_BIN);
+ //~ htdccor = new TH2F(hname, hname, 512, 0, 2048*TDC_BIN, 512, 0, 2048*TDC_BIN);
+ //~ htdccor = new TH2F(hname, hname, 11*20+1, 15.985, 27.035, 3*40+1, 15.990,19.015);
+ //~ htdccor = new TH2F(hname, hname, 512, 0, 2047.5*TDC_BIN, 3*40+1, 15.990,19.015);
+
+ //kobayashi
+ sprintf(hname, "hcoradctdc0");
+ hcoradctdc0 = (TH2F*)gROOT->FindObject(hname);
+ hcoradctdc0 = new TH2F(hname,hname,2000,0,2000,800,-10,10);
+ sprintf(hname, "hcoradctdc1");
+ hcoradctdc1 = (TH2F*)gROOT->FindObject(hname);
+ hcoradctdc1 = new TH2F(hname,hname,2000,0,2000,800,-10,10);
+ ftt = (TTree*)gROOT->FindObject("ftt");
+ if(ftt) delete ftt;
+ ftt = new TTree("ftt","ftt");
+ ftt->Branch("t_adc0",&t_adc0,"t_adc0/D");
+ ftt->Branch("t_adc1",&t_adc1,"t_adc1/D");
+ ftt->Branch("t_tdc0",&t_tdc0,"t_tdc0/D");
+ ftt->Branch("t_tdc1",&t_tdc1,"t_tdc1/D");
+ ftt->Branch("t_ctdc",&t_ctdc,"t_ctdc/D");
+ #ifdef testpulse
+ sprintf(hname, "htesttdc1");
+ htesttdc1 = (TH1F*)gROOT->FindObject(hname);
+ if(htesttdc1) delete htesttdc1;
+ htesttdc1 = new TH1F(hname, hname, 65536, -0.5*TDC_BIN, 65535.5*TDC_BIN);
+ sprintf(hname, "htesttdc2");
+ htesttdc2 = (TH1F*)gROOT->FindObject(hname);
+ if(htesttdc2) delete htesttdc2;
+ htesttdc2 = new TH1F(hname, hname, 65536, -0.5*TDC_BIN, 65535.5*TDC_BIN);
+ #endif
+
+ for(int i=0; i<ANALYSE_CH; i++) {
+ sprintf(hname, "hadc%d", i);
+ hadc[i] = (TH1F*)gROOT->FindObject(hname);
+ if(hadc[i]) delete hadc[i];
+ hadc[i] = new TH1F(hname, hname, 4096, -0.5, 4095.5);
+
+ sprintf(hname, "hadc_cut%d", i);
+ hadc_cut[i] = (TH1F*)gROOT->FindObject(hname);
+ if(hadc_cut[i]) delete hadc_cut[i];
+ hadc_cut[i] = new TH1F(hname, hname, 4096, -0.5, 4095.5);
+
+ sprintf(hname, "hadc_cut_2%d", i);
+ hadc_cut_2[i] = (TH1F*)gROOT->FindObject(hname);
+ if(hadc_cut_2[i]) delete hadc_cut_2[i];
+ hadc_cut_2[i] = new TH1F(hname, hname, 4096, -0.5, 4095.5);
+
+ sprintf(hname, "htdc%d", i);
+ htdc[i] = (TH1F*)gROOT->FindObject(hname);
+ if(htdc[i]) delete htdc[i];
+ //~ htdc[i] = new TH1F(hname, hname, 4096, -2048.5*TDC_BIN, 2047.5*TDC_BIN);
+ //~ htdc[i] = new TH1F(hname, hname, 4096, -0.5*TDC_BIN, 4095.5*TDC_BIN); //original
+ //~ htdc[i] = new TH1F(hname, hname, 65536/2, -0.5*TDC_BIN, 65535.5*TDC_BIN); //koba
+ //~ htdc[i] = new TH1F(hname, hname, 65536/2, -32768.5*TDC_BIN, 32767.5*TDC_BIN); //koba
+ htdc[i] = new TH1F(hname, hname, 65536, -32768.5*TDC_BIN, 32767.5*TDC_BIN);
+ //~ htdc[i] = new TH1F(hname, hname, 65536, -0.5*TDC_BIN, 65535.5*TDC_BIN);
+
+ sprintf(hname, "htdc_cut%d", i);
+ htdc_cut[i] = (TH1F*)gROOT->FindObject(hname);
+ if(htdc_cut[i]) delete htdc_cut[i];
+ //~ htdc_cut[i] = new TH1F(hname, hname, 4096, -2048.5*TDC_BIN, 2047.5*TDC_BIN);
+ //~ htdc_cut[i] = new TH1F(hname, hname, 4096, -0.5*TDC_BIN, 4095.5*TDC_BIN);//original
+ //~ htdc_cut[i] = new TH1F(hname, hname, 65536/2, -0.5*TDC_BIN, 65535.5*TDC_BIN); //koba
+ htdc_cut[i] = new TH1F(hname, hname, 65536/2, -32768.5*TDC_BIN, 32767.5*TDC_BIN); //koba
+ //~ htdc_cut[i] = new TH1F(hname, hname, 65536, -32768.5*TDC_BIN, 32767.5*TDC_BIN);
+
+ sprintf(hname, "htdc_cut_2%d", i);
+ htdc_cut_2[i] = (TH1F*)gROOT->FindObject(hname);
+ if(htdc_cut_2[i]) delete htdc_cut_2[i];
+ //~ htdc_cut_2[i] = new TH1F(hname, hname, 4096, -2048.5*TDC_BIN, 2047.5*TDC_BIN);
+ //~ htdc_cut_2[i] = new TH1F(hname, hname, 4096, -0.5*TDC_BIN, 4095.5*TDC_BIN);//original
+ htdc_cut_2[i] = new TH1F(hname, hname, 65536, -0.5*TDC_BIN, 65535.5*TDC_BIN); //koba
+
+ sprintf(hname, "hctdc%d", i);
+ hctdc[i] = (TH1F*)gROOT->FindObject(hname);
+ if(hctdc[i]) delete hctdc[i];
+ //~ hctdc[i] = new TH1F(hname, hname, 4096, -2048.5*TDC_BIN, 2047.5*TDC_BIN);
+ //~ hctdc[i] = new TH1F(hname, hname, 65536/2, -32768.5*TDC_BIN, 32767.5*TDC_BIN);
+ hctdc[i] = new TH1F(hname, hname, 65536, -32768.5*TDC_BIN, 32767.5*TDC_BIN);
+
+ sprintf(hname, "h2d%d", i);
+ h2d[i] = (TH2F*)gROOT->FindObject(hname);
+ if(h2d[i]) delete h2d[i];
+ h2d[i] = new TH2F(hname, hname, run.nx, (run.x0-0.5*run.dx)*MIKRO_BIN, (run.x0+(run.nx-0.5)*run.dx)*MIKRO_BIN,
+ run.ny, (run.y0-0.5*run.dy)*MIKRO_BIN, (run.y0+(run.ny-0.5)*run.dy)*MIKRO_BIN);
+
+ sprintf(hname, "hcor%d", i);
+ hcor[i] = (TH2F*)gROOT->FindObject(hname);
+ if(hcor[i]) delete hcor[i];
+ //~ hcor[i] = new TH2F(hname, hname, 256, 0-0.5, 1024-0.5, 200, 10-(TDC_BIN/2), 20-(TDC_BIN/2));
+ //~ hcor[i] = new TH2F(hname, hname, 512, 0-0.5, 1024-0.5, 4096, -32768.5*TDC_BIN, 32767.5*TDC_BIN);
+ //~ hcor[i] = new TH2F(hname, hname, 256, 0-0.5, 512-0.5, 160, -2-(TDC_BIN/2), 2-(TDC_BIN/2));
+ hcor[i] = new TH2F(hname, hname, 512, 0-0.5, 1024-0.5, 160, -1.5-(TDC_BIN/2), 2.5-(TDC_BIN/2));
+
+
+ for(int j=0; j<ANALYSE_CH; j++) {
+ sprintf(hname, "hdiffcor_%d_%d",i,j);
+ sprintf(htitle, "ch.%d - ch.%d",i,j);
+ hdiffcor[i][j] = (TH2F*)gROOT->FindObject(hname);
+ if(hdiffcor[i][j]) delete hdiffcor[i][j];
+ hdiffcor[i][j] = new TH2F(hname, htitle, 256, 0-0.5, 1024-0.5, 128, -6.4-(TDC_BIN/2), 6.4-(TDC_BIN/2));
+
+ sprintf(hname, "hdiffcor_low_%d_%d",i,j);
+ sprintf(htitle, "ch.%d - ch.%d",i,j);
+ hdiffcor_low[i][j] = (TH2F*)gROOT->FindObject(hname);
+ if(hdiffcor_low[i][j]) delete hdiffcor_low[i][j];
+ hdiffcor_low[i][j] = new TH2F(hname, htitle, 256, 0-0.5, 512-0.5, 128, -6.4-(TDC_BIN/2), 6.4-(TDC_BIN/2));
+
+ sprintf(hname, "hdiffcor_hi_%d_%d",i,j);
+ sprintf(htitle, "ch.%d - ch.%d",i,j);
+ hdiffcor_hi[i][j] = (TH2F*)gROOT->FindObject(hname);
+ if(hdiffcor_hi[i][j]) delete hdiffcor_hi[i][j];
+ hdiffcor_hi[i][j] = new TH2F(hname, htitle, 256, 0-0.5, 2048-0.5, 128, -6.4-(TDC_BIN/2), 6.4-(TDC_BIN/2));
+ }
+ }
+
+ break;
+
+ case POSREC_ID:
+#ifdef USE_ZLIB
+ gzread(dfp, (voidp)&readbuf[2*ulsize], (rec_len-2*ulsize));
+#else
+ fread( (void*)&readbuf[2*ulsize], (rec_len-2*ulsize), 1, dfp);
+#endif
+
+ pos=*posrec;
+
+ if(dbg) {
+ printf("POSREC_ID\n");
+ printf("id = %d, len = %d, time = %d\n", posrec->id, posrec->len, posrec->time);
+ printf("ix = %d, x = %d, xset = %d\n", posrec->ix, posrec->x, posrec->xset);
+ printf("iy = %d, y = %d, yset = %d\n", posrec->iy, posrec->y, posrec->yset);
+ } else printf(" [%d,%d] %d, %d\n", pos.ix, pos.iy, pos.xset, pos.yset);
+
+ break;
+
+ case EVTREC_ID:
+#ifdef USE_ZLIB
+ gzread(dfp, (voidp)&readbuf[2*ulsize], (rec_len-2*ulsize));
+#else
+ fread( (void*)&readbuf[2*ulsize], (rec_len-2*ulsize), 1, dfp);
+#endif
+
+
+ if(dbg) {
+ //~ printf("EVTREC_ID\n");
+ //~ printf("id = %d, len = %d, nev = %d\n", evtrec->id, evtrec->len, evtrec->nev);
+ //for(int datai = 0; datai < NCH; datai++) printf("%u ", evtrec->data[datai]);
+ //printf("\n");
+ //for(int datai = NCH; datai < NCH+NCH; datai++) printf("%u ", evtrec->data[datai]);
+ //printf("\n");
+ //break;
+ }
+// events ------------------------------------------------------------------------------------------
+// fill histograms
+
+ double tdc_noise_cut;
+ //~ double adc_cor_min;
+ double tdca[ANALYSE_CH];
+ double ctdca[ANALYSE_CH];
+ double adca[ANALYSE_CH];
+ double ctdcdiff, tdcdiff;
+
+
+ tdc_noise_cut = 5.0;
+ //~ adc_cor_min = 200.0;
+
+ for(int i=0; i<ANALYSE_CH; i++) {
+ tdc=((double)evtrec->data[i])*TDC_BIN + tdcoffset[i];
+ //~ tdc=((double)evtrec->data[i])*TDC_BIN;
+
+ adc=(double)evtrec->data[i+NCH];
+ //~ if(i==15) printf("aaaaaaaaaaa15 norma %f\n",tdc);
+ tdca[i]=tdc;
+ adca[i]=adc;
+
+ //~ if(ceve < 100) {
+ //~ printf("[%3d] tdc[%2d] = %lf | adc[%2d] = %lf\n", ceve, i, tdc, i, adc);
+ //~ }
+ }
+ for(int i=0; i<ANALYSE_CH; i++) {
+ if(0 < adca[i]) hadc[i]->Fill(adca[i]);
+ //~ if( (qdcmi < adca[i]) && (adca[i] < qdcma) )
+ if(0 < tdca[i]) htdc[i]->Fill(tdca[i]-tdca[TRIGGER_CH]);
+ //~ if(0 < tdca[i]) htdc[i]->Fill(tdca[i]);
+ hcor[i]->Fill(adca[i],tdca[i]-tdca[TRIGGER_CH]);
+
+ if(adca[i] > corpar[i][2]) {
+ ctdca[i] = tdca[i]-tdca[TRIGGER_CH] - (corpar[i][0] + corpar[i][1]/TMath::Sqrt(adca[i] - corpar[i][2]));
+ } else {
+ ctdca[i] = -999.9*(i+1);
+ }
+ //~ if(tdc_noise_cut < tdca[i])
+ double adc_max_cut = 1000;
+ if(adca[i] < adc_max_cut)
+ hctdc[i]->Fill( ctdca[i] );
+
+ //~ if(dbg && (i<4) && (1 < tdca[0] && (1 < tdca[1]))) printf("tdca[%d] = %lf | tdca[TRG] = %lf | ctdca[i] = %lf | adca[i] = %lf\n", i, tdca[i],tdca[TRIGGER_CH],ctdca[i],adca[i]);
+ if(dbg && (i<4) ) printf("[%4d] tdca[%d] = %lf | tdca[TRG] = %lf | ctdca[i] = %lf | adca[i] = %lf\n", ceve, i, tdca[i],tdca[TRIGGER_CH],ctdca[i],adca[i]);
+
+ if( (qdcmi < adca[i]) && (adca[i] < qdcma) && (tdcmi < tdca[i]) && (tdca[i] < tdcma)) {
+ h2d[i]->Fill(pos.xset*MIKRO_BIN, pos.yset*MIKRO_BIN);
+ }
+ }
+
+ //~ printf("aaaaaaaaaaa15 %f\n",((double)evtrec->data[15])); printf("aaaaaaaaaaa15 %f\n",((double)evtrec->data[15])*TDC_BIN);
+ //~ printf("aaaaaaaaaaa30 %d\n",evtrec->data[30]);
+ //~ printf("aaaaaaaaaaa31 %d\n",evtrec->data[31]);
+ //~ printf("aaaaaaaaaaa15 %f\n",tdca[15]);
+ //~ printf("aaaaaaaaaaa30 %d\n",tdca[30]);
+ //~ printf("aaaaaaaaaaa31 %d\n",tdca[31]);
+ //~
+ //kobayashi
+ ctdcdiff = ctdca[MPPC_2_CH] - ctdca[MPPC_1_CH] +deltaT_ctdcdiff;
+ tdcdiff = tdca[MPPC_2_CH] - tdca[MPPC_1_CH];
+ t_ctdc = ctdcdiff;
+ t_tdc0=tdca[0];
+ t_tdc1=tdca[1];
+ t_adc0=adca[15];
+ t_adc1=adca[1];
+
+ hcoradctdc0->Fill(adca[0],ctdcdiff);
+ hcoradctdc1->Fill(adca[1],ctdcdiff);
+ ftt->Fill();
+ #ifdef testpulse
+ htesttdc1->Fill(tdca[16]-tdca[14]);
+ htesttdc2->Fill(tdca[14]-tdca[15]);
+ #endif
+
+//cut za timing:
+#define CUT_1_CONDITION ( (qdcmi < adca[MPPC_1_CH]) && (adca[MPPC_1_CH] < qdcma) && (tdcmi < adca[MPPC_2_CH]) && (adca[MPPC_2_CH] < tdcma) )
+//~ // cut za meritev efficiency:
+//~ #define CUT_1_CONDITION ( (qdcmi < adca[MPPC_1_CH]) && (adca[MPPC_1_CH] < qdcma) )
+
+//~ #define CUT_1_CONDITION ( (tdcmi < ctdcdiff) && (ctdcdiff < tdcma) )
+//~ #define CUT_1_CONDITION ( (ref_cut_1_lo < adca[MPPC_1_CH]) && (adca[MPPC_1_CH] < ref_cut_1_hi) )
+//~ #define CUT_1_CONDITION ( (qdcmi < tdca[MPPC_1_CH]) && (tdca[MPPC_1_CH] < qdcma) )
+//~ #define CUT_1_CONDITION ( (ref_cut_1_lo < adca[REF_CH]) && (adca[REF_CH] < ref_cut_1_hi) && (ref_cut_1_lo < adca[MPPC_1_CH]) && (adca[MPPC_1_CH] < ref_cut_1_hi) )
+
+
+// cut za meritev efficiency:
+#define CUT_2_CONDITION ( (tdcmi < adca[REF_CH]) && (adca[REF_CH] < tdcma) )
+//~ #define CUT_2_CONDITION ( (qdcmi < adca[MPPC_1_CH]) && (adca[MPPC_1_CH] < qdcma) && (tdcmi < adca[REF_CH]) && (adca[REF_CH] < tdcma) )
+//~ #define CUT_2_CONDITION ( (ref_cut_1_lo < tdca[MPPC_1_CH]) && (tdca[MPPC_1_CH] < ref_cut_1_hi) )
+//~ #define CUT_2_CONDITION ( (qdcmi < adca[REF_CH]) && (adca[REF_CH] < qdcma) && (tdcmi < tdca[REF_CH]) && (tdca[REF_CH] < tdcma) )
+//~ #define CUT_2_CONDITION ( (ref_cut_1_lo < adca[MPPC_1_CH]) && (adca[MPPC_1_CH] < ref_cut_1_hi) && (ref_cut_2_lo < adca[MPPC_2_CH]) && (adca[MPPC_2_CH] < ref_cut_2_hi) )
+//~ #define CUT_2_CONDITION ( (ref_cut_2_lo < adca[REF_CH]) && (adca[REF_CH] < ref_cut_2_hi) )
+//~ #define CUT_2_CONDITION ( (ref_cut_1_lo < tdca[MPPC_1_CH]) && (tdca[MPPC_1_CH] < ref_cut_1_hi) && (ref_cut_2_lo < tdca[MPPC_2_CH]) && (tdca[MPPC_2_CH] < ref_cut_2_hi) )
+//~ #define CUT_2_CONDITION ( (ref_cut_2_lo < tdca[REF_CH]) && (tdca[REF_CH] < ref_cut_2_hi) && (ref_cut_2_lo < tdca[MPPC_1_CH]) && (tdca[MPPC_1_CH] < ref_cut_2_hi) )
+
+
+ if( (tdc_noise_cut < tdca[MPPC_1_CH]) && (tdc_noise_cut < tdca[MPPC_2_CH])) {
+ //~ if( (qdcmi < adca[MPPC_1_CH]) && (tdcmi < adca[MPPC_2_CH]) )
+ htdcdiff->Fill(ctdcdiff);
+
+ if( CUT_1_CONDITION ) {
+ htdcdiff_cut->Fill(ctdcdiff);
+ //~ htdcdiff_cut->Fill(tdcdiff);
+ }
+ if( CUT_2_CONDITION ) {
+ htdcdiff_cut_2->Fill(ctdcdiff);
+ }
+ }
+
+ for(int i=0; i<ANALYSE_CH; i++) {
+
+ //~ if( CUT_1_CONDITION ) {
+ //~ if( ( (qdcmi < adca[REF_CH]) && (adca[REF_CH] < qdcma) ) ) {
+ //~ if( ( (-2 < ctdca[0]) && (ctdca[0] < 2) ) ) {
+ //~ htdc_cut[i]->Fill(tdca[i]-tdca[31]);
+ //~ htdc_cut[i]->Fill(ctdca[i]);
+ //~ hadc_cut[i]->Fill(adca[i]);
+ //~ }
+ if( (qdcmi < adca[i]) && (adca[i] < qdcma) && (adca[i] > corpar[i][2]) )
+ htdc_cut[i]->Fill(ctdca[i]);
+ if( (tdcmi < ctdca[i]) && (ctdca[i] < tdcma) )
+ hadc_cut[i]->Fill(adca[i]);
+
+ if( CUT_2_CONDITION ) {
+ htdc_cut_2[i]->Fill(tdca[i]);
+ hadc_cut_2[i]->Fill(adca[i]);
+ hadc_cut_2[i]->Fill(adca[i]);
+ }
+ }
+
+ //~ hadccor->Fill(adca[REF_CH], adca[MPPC_1_CH]);
+ hadccor->Fill(adca[REF_CH], tdca[8]-tdca[31]);
+
+ htdccor->Fill(tdca[MPPC_1_CH], tdca[MPPC_2_CH]);
+
+
+// --------------- corelation plots for time-walk correction ---------------
+
+ if( (tdc_noise_cut<tdca[MPPC_1_CH]) && (tdc_noise_cut<tdca[MPPC_2_CH]) && (adc_cor_min<adca[MPPC_2_CH]) ) {
+ hdiffcor[MPPC_1_CH][MPPC_2_CH]->Fill(adca[MPPC_1_CH],tdca[MPPC_1_CH]-ctdca[MPPC_2_CH]);
+
+ hdiffcor_low[MPPC_1_CH][MPPC_2_CH]->Fill(adca[MPPC_1_CH],tdca[MPPC_1_CH]-ctdca[MPPC_2_CH]);
+ hdiffcor_hi[MPPC_1_CH][MPPC_2_CH]->Fill(adca[MPPC_1_CH],tdca[MPPC_1_CH]-ctdca[MPPC_2_CH]);
+ }
+
+ if( (tdc_noise_cut<tdca[MPPC_2_CH]) && (tdc_noise_cut<tdca[MPPC_1_CH]) && (adc_cor_min<adca[MPPC_1_CH]) ) {
+ hdiffcor[MPPC_2_CH][MPPC_1_CH]->Fill(adca[MPPC_2_CH],tdca[MPPC_2_CH]-ctdca[MPPC_1_CH]);
+
+ hdiffcor_low[MPPC_2_CH][MPPC_1_CH]->Fill(adca[MPPC_2_CH],tdca[MPPC_2_CH]-ctdca[MPPC_1_CH]);
+ hdiffcor_hi[MPPC_2_CH][MPPC_1_CH]->Fill(adca[MPPC_2_CH],tdca[MPPC_2_CH]-ctdca[MPPC_1_CH]);
+ }
+
+// events ------------------------------------------------------------------------------------------
+
+ break;
+
+ case ENDREC_ID:
+#ifdef USE_ZLIB
+ gzread(dfp, (voidp)&readbuf[2*ulsize], (rec_len-2*ulsize));
+#else
+ fread( (void*)&readbuf[2*ulsize], (rec_len-2*ulsize), 1, dfp);
+#endif
+
+ if(dbg) {
+ printf("ENDREC_ID\n");
+ printf("id = %d, len = %d, time = %d\n", endrec->id, endrec->len, endrec->time);
+ } else printf(" ENDREC\n");
+
+ fcount++;
+ switch(ftype-1) {
+ case 0:
+ sprintf(dfile, "data/%s_file%02d.dat", dfile0, fcount);
+ break;
+ case 1:
+ sprintf(dfile, "data/%s_file%02d.dat.gz", dfile0, fcount);
+ break;
+ case 2:
+ sprintf(dfile, "data/%s_file%02d.gz", dfile0, fcount);
+ break;
+ }
+
+#ifdef USE_ZLIB
+ if(dfp) gzclose(dfp);
+ dfp=gzopen(dfile,"rb");
+#else
+ if(dfp) fclose(dfp);
+ dfp=fopen(dfile,"rb");
+#endif
+
+ if(!dfp) {
+ printf(" Cannot open data file: %s ---> Exiting\n", dfile);
+ end_of_file = 1;
+ } else {
+ printf(" Opened data file: %s\n", dfile);
+ end_of_file = 0;
+ }
+
+ break;
+
+ default:
+ printf("switch(rec_id): default !!!\n");
+ end_of_file = 1;
+ break;
+ }
+
+ ceve++;
+ if( (ceve%50000) == 0) printf(" Current event = %d\n", ceve);
+ if(dbg) if( ceve>dbg ) break;
+ if(end_of_file) break;
+ }
+
+
+#ifdef USE_ZLIB
+ if(dfp) gzclose(dfp);
+#else
+ if(dfp) fclose(dfp);
+#endif
+
+ if(dbg) return 1;
+ if(rootfile) {
+ #ifdef testpulse
+ printf("<<< EASIROC Disc : %f [ps]\n", htesttdc1->GetRMS()*1000);
+ printf("<<< TEST Disc : %f [ps]\n", htesttdc2->GetRMS()*1000);
+ #endif
+ ftt->Write();
+ rootfile->Write();
+ //cout<<"maximum x value = " << htdcdiff->GetXaxis()->GetBinCenter( htdcdiff->GetMaximumBin()) <<endl;
+ printf("Saved to %s\n", fnameroot);
+ rootfile->Close();
+ }
+
+ gSystem->Exit(1);
+
+ return 1;
+}
Index: l2d2_easyroc/d2r.ini
===================================================================
--- l2d2_easyroc/d2r.ini (nonexistent)
+++ l2d2_easyroc/d2r.ini (revision 291)
@@ -0,0 +1,33 @@
+# pad_center_x pad_center_y tdc_offset
+0.0 0.0 -3.50000
+1.0 0.0 0.000000
+2.0 0.0 0.000000
+3.0 0.0 0.000000
+4.0 0.0 0.000000
+5.0 0.0 0.000000
+6.0 0.0 0.000000
+7.0 0.0 0.000000
+8.0 0.0 0.000000
+9.0 0.0 0.000000
+10. 0.0 0.000000
+11. 0.0 0.000000
+12. 0.0 0.000000
+13. 0.0 0.000000
+14. 0.0 0.000000
+15. 0.0 -3.70000
+16. 0.0 -3.20000
+17. 0.0 0.000000
+18. 0.0 0.000000
+19. 0.0 0.000000
+20. 0.0 0.000000
+21. 0.0 0.000000
+22. 0.0 0.000000
+23. 0.0 0.000000
+24. 0.0 0.000000
+25. 0.0 0.000000
+26. 0.0 0.000000
+27. 0.0 0.000000
+28. 0.0 0.000000
+29. 0.0 0.000000
+30. 0.0 0.000000
+31. 0.0 0.000000
Index: l2d2_easyroc/d2time.cpp
===================================================================
--- l2d2_easyroc/d2time.cpp (nonexistent)
+++ l2d2_easyroc/d2time.cpp (revision 291)
@@ -0,0 +1,278 @@
+#include "stdio.h"
+#include "TROOT.h"
+#include "TSystem.h"
+#include "TFile.h"
+#include "TH1F.h"
+#include "TH2F.h"
+#include "TF1.h"
+#include "TMath.h"
+#include "TStyle.h"
+#include "TCanvas.h"
+#include "TLine.h"
+
+//~ #define USE_ZLIB
+#ifdef USE_ZLIB
+# include "zlib.h"
+#endif
+// ------------------------------------------------------------------------------
+
+#define POSMARG 1000
+
+#define READBUFFERLENGTH 50000
+
+// data format
+#define MAXDATA 40
+
+#define RUNREC_ID 1
+#define ENDREC_ID 2
+#define POSREC_ID 3
+#define EVTREC_ID 4
+
+typedef struct {
+ unsigned long id,len;
+ unsigned long fver,time;
+ unsigned long nev,nch,ped,xy;
+ long nx,x0,dx,ny,y0,dy;
+} RUNREC;
+RUNREC *runrec;
+RUNREC run;
+
+typedef struct {
+ unsigned long id,len;
+ unsigned long time;
+} ENDREC;
+ENDREC *endrec;
+
+typedef struct {
+ unsigned long id,len;
+ unsigned long time;
+ long ix,x,xset,iy,y,yset;
+} POSREC;
+POSREC *posrec;
+POSREC pos;
+
+typedef struct {
+ unsigned long id,len;
+ unsigned long nev;
+ unsigned short data[MAXDATA];
+} EVTREC;
+EVTREC *evtrec;
+
+// ------------------------------------------------------------------------------
+
+int d2time(char* dfile0="test")
+{
+ unsigned long startTime = 0;
+ unsigned long endTime = 0;
+
+
+
+ int dbg=0;
+ printf(" dat 2 root conversion program\nUsage:\nd2r(input file -.dat, TDC min [ps], TDC max [ps], QDC min, QDC max)\n\n");
+
+ char fullname[256], sbuff[256];
+ FILE *fp;
+
+
+ //data buffer
+ char readbuf[READBUFFERLENGTH];
+ runrec = (RUNREC *) readbuf;
+ endrec = (ENDREC *) readbuf;
+ posrec = (POSREC *) readbuf;
+ evtrec = (EVTREC *) readbuf;
+
+ //data file
+#ifdef USE_ZLIB
+ gzFile dfp;
+#else
+ FILE *dfp;
+#endif
+ char dfile[256];
+ int ftype=0, fcount=1;
+ do {
+ switch(ftype++) {
+ case 0:
+ sprintf(dfile, "data/%s_file%02d.dat", dfile0, fcount);
+ break;
+ case 1:
+ sprintf(dfile, "data/%s_file%02d.dat.gz", dfile0, fcount);
+ break;
+ case 2:
+ sprintf(dfile, "data/%s_file%02d.gz", dfile0, fcount);
+ break;
+ default:
+ printf(" Cannot find data file for %s !!!\n", dfile0);
+ return -1;
+ }
+#ifdef USE_ZLIB
+ dfp=gzopen(dfile,"rb");
+#else
+ dfp=fopen(dfile,"rb");
+#endif
+
+ } while(!dfp);
+ printf("Opened data file %s\n", dfile);
+
+// -----------------------------------------------
+ // loop trough records
+ UInt_t rec_id, rec_len;
+ unsigned ulsize = 4;
+ int ceve=0;
+ int end_of_file = 0;
+
+ while(1) {
+#ifdef USE_ZLIB
+ if(gzeof(dfp)) end_of_file = 1;
+#else
+ if(feof(dfp)) end_of_file = 1;
+#endif
+
+#ifdef USE_ZLIB
+ gzread(dfp, (voidp)&readbuf, 2*ulsize);
+#else
+ fread( (void*)&readbuf, 2*ulsize, 1, dfp);
+#endif
+ rec_id=readbuf[0];
+ rec_len=readbuf[ulsize];
+
+ if(dbg) printf("-----------------------------------------------\n");
+ if(dbg) printf("[%d] rec_id = %d | rec_len = %d\n", ceve, rec_id, rec_len);
+
+ switch(rec_id)
+ {
+ case RUNREC_ID:
+#ifdef USE_ZLIB
+ gzread(dfp, (voidp)&readbuf[2*ulsize], (rec_len-2*ulsize));
+#else
+ fread( (void*)&readbuf[2*ulsize], (rec_len-2*ulsize), 1, dfp);
+#endif
+ run=*runrec;
+
+ if(dbg) {
+ printf("RUNREC_ID\n");
+ printf("id = %d, len = %d, time = %d\n", run.id, run.len, run.time);
+ printf("nev = %d, nch = %d\n", run.nev, run.nch);
+ 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);
+
+ break;
+ }
+
+ printf(">>>>>>>>>>>> RUNREC time = %u\n", run.time);
+ startTime = run.time;
+
+ break;
+
+ case POSREC_ID:
+#ifdef USE_ZLIB
+ gzread(dfp, (voidp)&readbuf[2*ulsize], (rec_len-2*ulsize));
+#else
+ fread( (void*)&readbuf[2*ulsize], (rec_len-2*ulsize), 1, dfp);
+#endif
+
+ pos=*posrec;
+
+ if(dbg) {
+ printf("POSREC_ID\n");
+ printf("id = %d, len = %d, time = %d\n", posrec->id, posrec->len, posrec->time);
+ printf("ix = %d, x = %d, xset = %d\n", posrec->ix, posrec->x, posrec->xset);
+ printf("iy = %d, y = %d, yset = %d\n", posrec->iy, posrec->y, posrec->yset);
+ } else printf(" [%d,%d] %d, %d\n", pos.ix, pos.iy, pos.xset, pos.yset);
+
+ break;
+
+ case EVTREC_ID:
+#ifdef USE_ZLIB
+ gzread(dfp, (voidp)&readbuf[2*ulsize], (rec_len-2*ulsize));
+#else
+ fread( (void*)&readbuf[2*ulsize], (rec_len-2*ulsize), 1, dfp);
+#endif
+
+
+ if(dbg) {
+ printf("EVTREC_ID\n");
+ printf("id = %d, len = %d, nev = %d\n", evtrec->id, evtrec->len, evtrec->nev);
+ //for(int datai = 0; datai < NCH; datai++) printf("%u ", evtrec->data[datai]);
+ //printf("\n");
+ //for(int datai = NCH; datai < NCH+NCH; datai++) printf("%u ", evtrec->data[datai]);
+ //printf("\n");
+ //break;
+ }
+
+ break;
+
+ case ENDREC_ID:
+#ifdef USE_ZLIB
+ gzread(dfp, (voidp)&readbuf[2*ulsize], (rec_len-2*ulsize));
+#else
+ fread( (void*)&readbuf[2*ulsize], (rec_len-2*ulsize), 1, dfp);
+#endif
+
+ if(dbg) {
+ printf("ENDREC_ID\n");
+ printf("id = %d, len = %d, time = %d\n", endrec->id, endrec->len, endrec->time);
+ } else printf(" ENDREC\n");
+
+
+ printf(">>>>>>>>>>>> ENDREC time = %u\n", endrec->time);
+ endTime = endrec->time;
+
+ fcount++;
+ switch(ftype-1) {
+ case 0:
+ sprintf(dfile, "data/%s_file%02d.dat", dfile0, fcount);
+ break;
+ case 1:
+ sprintf(dfile, "data/%s_file%02d.dat.gz", dfile0, fcount);
+ break;
+ case 2:
+ sprintf(dfile, "data/%s_file%02d.gz", dfile0, fcount);
+ break;
+ }
+
+#ifdef USE_ZLIB
+ if(dfp) gzclose(dfp);
+ dfp=gzopen(dfile,"rb");
+#else
+ if(dfp) fclose(dfp);
+ dfp=fopen(dfile,"rb");
+#endif
+
+ if(!dfp) {
+ printf(" Cannot open data file: %s ---> Exiting\n", dfile);
+ end_of_file = 1;
+ } else {
+ printf(" Opened data file: %s\n", dfile);
+ end_of_file = 0;
+ }
+
+ break;
+
+ default:
+ printf("switch(rec_id): default !!!\n");
+ end_of_file = 1;
+ break;
+ }
+
+ ceve++;
+ if( (ceve%50000) == 0) printf(" Current event = %d\n", ceve);
+ if(dbg) if( ceve>dbg ) break;
+ if(end_of_file) break;
+ }
+
+
+#ifdef USE_ZLIB
+ if(dfp) gzclose(dfp);
+#else
+ if(dfp) fclose(dfp);
+#endif
+
+
+ printf(">>>>>>>>>>>> TIME = ENDREC.time - RUNREC.time = %u (s) = %.2lf (min)\n", endTime - startTime, (endTime - startTime)/60.);
+
+ if(dbg) return 1;
+
+ gSystem->Exit(1);
+
+ return 1;
+}
\ No newline at end of file
Index: l2d2_easyroc/data/EASIROCtestLinux.dat
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/l2d2_easyroc/data/EASIROCtestLinux.dat
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/data/EASIROCtestWin
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/l2d2_easyroc/data/EASIROCtestWin
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/data/test
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/l2d2_easyroc/data/test
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/e2r.cpp
===================================================================
--- l2d2_easyroc/e2r.cpp (nonexistent)
+++ l2d2_easyroc/e2r.cpp (revision 291)
@@ -0,0 +1,144 @@
+#include "stdio.h"
+#include "TROOT.h"
+#include "TSystem.h"
+#include "TFile.h"
+#include "TH1F.h"
+#include "TH2F.h"
+#include "TF1.h"
+#include "TMath.h"
+
+#define NCH 32
+
+#define HEADER_WORD_1 0xFFFF
+#define HEADER_WORD_2 0xEA0C
+#define ID_ADC_HG 0x81
+#define ID_ADC_LG 0x60
+#define ID_TDC 0xCC
+#define PRINT_FREQUENCY 10000
+
+void e2r(char* dfile0="test", int dbg=0)
+{
+ char fullname[256], sbuff[256];
+
+ FILE *dfp;
+ char dfile[256];
+ sprintf(dfile, "data/%s", dfile0);
+
+ if((dfp=fopen(dfile,"rb")) == NULL) {
+ printf("Cannot open data file %s !!!\n", dfile);
+ return;
+ } else {
+ printf("Opened data file %s.\n", dfile);
+ }
+
+ if(sizeof(int) != 4) {
+ printf("sizeof(int) != 4, sizeof(int) = %d !!!\n", sizeof(int));
+ return;
+ }
+ int dum32;
+
+
+
+ char hname[256], htitle[256];
+ TH1F *htdc[2][NCH], *hadc_hg[NCH], *hadc_lg[NCH];
+
+ //opens ROOT file
+ TFile *rootfile; char fnameroot[256];
+ sprintf(fnameroot, "root/%s.root", dfile0);
+ //rootfile = (TFile *) gROOT->FindObjectAny(dfile0);
+ //if (rootfile!=NULL) {printf("!!!\n");rootfile->Close();}
+ //rootfile = new TFile(fnameroot);
+ //if(rootfile) rootfile->Close();
+ rootfile = new TFile(fnameroot,"RECREATE",dfile0);
+
+ for(int i=0; i<NCH; i++) {
+ sprintf(hname, "htdc_le_%d", i);
+ htdc[0][i] = (TH1F*)gROOT->FindObject(hname);
+ if(htdc[0][i]) delete htdc[0][i];
+ htdc[0][i] = new TH1F(hname, hname, 256, -0.5, 255.5);
+
+ sprintf(hname, "htdc_te_%d", i);
+ htdc[1][i] = (TH1F*)gROOT->FindObject(hname);
+ if(htdc[1][i]) delete htdc[1][i];
+ htdc[1][i] = new TH1F(hname, hname, 256, -0.5, 255.5);
+
+ sprintf(hname, "hadc_hg%d", i);
+ hadc_hg[i] = (TH1F*)gROOT->FindObject(hname);
+ if(hadc_hg[i]) delete hadc_hg[i];
+ hadc_hg[i] = new TH1F(hname, hname, 4096, -0.5, 4095.5);
+
+ sprintf(hname, "hadc_lg%d", i);
+ hadc_lg[i] = (TH1F*)gROOT->FindObject(hname);
+ if(hadc_lg[i]) delete hadc_lg[i];
+ hadc_lg[i] = new TH1F(hname, hname, 4096, -0.5, 4095.5);
+ }
+
+ // ------------- data ----------------------------------------------------
+
+ int ceve = 0;
+ while(!feof(dfp)) {
+ fread( &dum32, sizeof(int), 1, dfp);
+
+ int hw1 = (dum32 >> 16) & 0xFFFF;
+ int hw2 = dum32 & 0xFFFF;
+ if( (hw1 == HEADER_WORD_1) && (hw2 == HEADER_WORD_2) ) {
+ fread( &dum32, sizeof(int), 1, dfp);
+ int Number_of_word = dum32 & 0xFFFF;
+ fread( &dum32, sizeof(int), 1, dfp);
+ int EventCounter = (dum32 >> 16) & 0xFFFF;
+ if(dbg) printf("\n>>>>>> Number_of_word = %d | EventCounter = %d\n", Number_of_word, EventCounter);
+ //~ else if( !(EventCounter%PRINT_FREQUENCY) ) printf(" EventConter = %d\n", EventCounter);
+ else if( !(EventCounter%PRINT_FREQUENCY) ) printf(".");
+ ceve++;
+ continue;
+ }
+
+ int id = (dum32 >> 24) & 0xFF;
+ int ch, overflow, edge, data;
+ switch(id) {
+ case ID_ADC_HG:
+ ch = (dum32 >> 16) & 0x1F;
+ overflow = (dum32 >> 13) & 0x1;
+ data = (dum32) & 0xFFF;
+ //~ printf("ID_ADC_HG: ch = %d | X = %d | data = %d\n", ch, overflow, data);
+ if(dbg) printf("HG[%2d]=%4d ", ch, data);
+ hadc_hg[ch]->Fill(data);
+ break;
+ case ID_ADC_LG:
+ ch = (dum32 >> 16) & 0x1F;
+ overflow = (dum32 >> 13) & 0x1;
+ data = (dum32) & 0xFFF;
+ //~ printf("ID_ADC_LG: ch = %d | X = %d | data = %d\n", ch, overflow, data);
+ if(dbg) printf("LG[%2d]=%4d ", ch, data);
+ hadc_lg[ch]->Fill(data);
+ break;
+ case ID_TDC:
+ ch = (dum32 >> 16) & 0x1F;
+ edge = (dum32 >> 15) & 0x1;
+ data = (dum32) & 0x3FFF;
+ printf("ID_TDC: ch = %d | X = %d | data = %d\n", ch, overflow, data);
+ if(edge < 2) htdc[edge][ch]->Fill(data);
+ break;
+ default:
+ printf("default: dum32 = 0x%X!!!\n", dum32);
+ break;
+ }
+ //~ ceve++;
+ //~ if( !(ceve%PRINT_FREQUENCY) ) printf(".");
+ if(dbg && (ceve > dbg) ) break;
+ }
+ printf("\nProcessed events = %d\n", ceve);
+
+ // ------------------------------------------------------------------------
+
+ if(dfp) fclose(dfp);
+
+ if(dbg) return;
+ if(rootfile) {
+ rootfile->Write();
+ printf("Saved to %s\n", fnameroot);
+ rootfile->Close();
+ }
+
+ gSystem->Exit(1);
+}
Index: l2d2_easyroc/easiroc.c
===================================================================
--- l2d2_easyroc/easiroc.c (nonexistent)
+++ l2d2_easyroc/easiroc.c (revision 291)
@@ -0,0 +1,705 @@
+#include "easiroc.h"
+
+static const int SiTCP_PORT = 24;
+SOCKET sock;
+
+unsigned int slowdata[sizeByte_SC];
+unsigned int ReadSCdata[sizeByte_RSC];
+unsigned int Probedata[sizeByte_PSC];
+unsigned int Pindata[sizeByte_PIN];
+
+unsigned int Probedata[sizeByte_PSC];
+
+int ForceStop = 0;
+int EndADC = 0;
+
+#include <windows.h>
+
+void usleep(__int64 usec)
+{
+ HANDLE timer;
+ LARGE_INTEGER ft;
+
+ ft.QuadPart = -(10*usec); // Convert to 100 nanosecond interval, negative value indicates relative time
+
+ timer = CreateWaitableTimer(NULL, TRUE, NULL);
+ SetWaitableTimer(timer, &ft, 0, NULL, NULL, 0);
+ WaitForSingleObject(timer, INFINITE);
+ CloseHandle(timer);
+}
+
+//------------------------------------------------------------------------------------------------------
+int easiroc_Init(const char* SiTCP_MASTER_IP, unsigned int daq_mode)
+{
+ // Start WinSock
+ printf("easiroc_Init --> Start.\n");
+ WORD wVersionRequested;
+ WSADATA wsaData;
+ if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) {
+ printf("WSAStartup failed with error!\n");
+ }
+
+ //Initialize -------------------------------------------------------------
+
+ sock = INVALID_SOCKET;
+ struct sockaddr_in SiTCP_ADDR;
+ const char* IP;
+ unsigned int port;
+
+ sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ if(sock == INVALID_SOCKET) {
+ printf("Error: easiroc_Init::sock = %d\n", sock);
+ return -1;
+ }
+ IP = SiTCP_MASTER_IP;
+ port = SiTCP_PORT;
+ SiTCP_ADDR.sin_family = AF_INET;
+ SiTCP_ADDR.sin_port = htons(port);
+ SiTCP_ADDR.sin_addr.s_addr = inet_addr(IP);
+
+ struct timeval tv;
+ tv.tv_sec = 3;
+ tv.tv_usec = 0;
+ setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char*)&tv, sizeof(tv));
+
+ int flag = 1;
+ setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char*)&flag, sizeof(flag));
+
+ //Connection -------------------------------------------------------------
+ int con = connect(sock, (struct sockaddr*)&SiTCP_ADDR, sizeof(SiTCP_ADDR));
+ printf("easiroc_Init::connect = %d\n", con);
+ if(0 > con){
+ printf("SiTCP Master :: Connection fail\n");
+ closesocket(sock);
+ return -1;
+ }
+
+ printf("SiTCP Master :: Connection Done\n\n");
+
+ // Auto Initialize -------------------------------------------------------
+ PrepareFPGA();
+ DebugFPGA(sock);
+ printf("\nASIS Initialize : Done\n\n");
+ //Sleep(1000);
+
+ WriteData(sock, 37888);
+ PrepareSC(1);
+ TransmitSC(sock);
+ printf("\nSlow Control chip1 : Done\n\n");
+ PrepareReadSC(1);
+ TransmitReadSC(sock);
+ printf("\nRead Slow Control chip1 : Done\n\n");
+
+ WriteData(sock, 21504);
+ PrepareSC(2);
+ TransmitSC(sock);
+ printf("\nSlow Control chip2 : Done\n\n");
+ PrepareReadSC(2);
+ TransmitReadSC(sock);
+ printf("\nRead Slow Control chip2: Done\n\n");
+
+ WriteData(sock, 5120);
+ {
+ unsigned int signal = 31;
+ signal = signal << 16;
+ unsigned int data = daq_mode;
+ data = data << 8;
+ signal += data;
+ if(-1 == WriteData(sock, signal)){
+ return -1;
+ }
+ printf("\n#D : DAQ mode is %d \n", daq_mode);
+ }
+
+
+ return 0;
+}
+//------------------------------------------------------------------------------------------------------
+void easiroc_Close()
+{
+ closesocket(sock);
+ WSACleanup();
+ printf("easiroc_Close -> Done.\n");
+}
+//------------------------------------------------------------------------------------------------------
+int WriteData(SOCKET sock, unsigned int data)
+{
+ int esrcdbg = 0;
+
+ data += 128 << 24;;
+
+ if(esrcdbg) printf("0x%X\n", data);
+ send(sock, (char*)&data, sizeof(int), 0);
+ // this sleep is needed!
+ Sleep(WRITEDATA_DELAY);
+
+ unsigned int buf = 0;
+ unsigned int length = 4;
+ int ret = recv(sock, (char*)&buf, length, 0);
+
+ if ( ret > 0 ) {
+ if(esrcdbg) printf("Bytes received: %d\n", ret);
+ else printf(".");
+ } else if ( ret == 0 ) {
+ printf("Connection closed\n");
+ return -1;
+ } else {
+ printf("recv failed: %d\n", WSAGetLastError());
+ return -1;
+ }
+
+ return 0;
+}
+//------------------------------------------------------------------------------------------------------
+void PrepareFPGA()
+{
+ Pindata[0] = 20;
+ Pindata[1] = 65776;
+}
+//------------------------------------------------------------------------------------------------------
+void PrepareSC(int chipNo)
+{
+ if(chipNo == 1) {
+ slowdata[0] = 192;
+ slowdata[1] = 1720319;
+ slowdata[2] = 4253040640;
+ slowdata[3] = 413;
+ slowdata[4] = 0;
+ slowdata[5] = 3739423232;
+ slowdata[6] = 4294967295;
+ slowdata[7] = 4294967295;
+ slowdata[8] = 4294967295;
+ slowdata[9] = 4294967295;
+ slowdata[10] = 4294967295;
+ slowdata[11] = 4294967295;
+ slowdata[12] = 4294967295;
+ slowdata[13] = 4294967295;
+ slowdata[14] = 4294967295;
+ } else {
+ slowdata[0] = 192;
+ slowdata[1] = 4292874239;
+ slowdata[2] = 4257218559;
+ slowdata[3] = 478;
+ slowdata[4] = 0;
+ slowdata[5] = 3740340736;
+ slowdata[6] = 1175693740;
+ slowdata[7] = 2815957775;
+ slowdata[8] = 766945147;
+ slowdata[9] = 1504433946;
+ slowdata[10] = 2729016485;
+ slowdata[11] = 3412554245;
+ slowdata[12] = 2725848728;
+ slowdata[13] = 2267165112;
+ slowdata[14] = 4291041547;
+ }
+}
+//------------------------------------------------------------------------------------------------------
+void PrepareReadSC(int chipNo)
+{
+ if(chipNo == 1) {
+ ReadSCdata[0] = 0;
+ } else {
+ ReadSCdata[0] = 1;
+ }
+}
+//------------------------------------------------------------------------------------------------------
+int DebugFPGA(SOCKET socket)
+{
+ unsigned int buffer = 0;
+ buffer += 0 << 16;
+ buffer += (Pindata[0] & 255) << 8;
+ if(-1 == WriteData(socket, buffer)){
+ return -1;
+ }
+
+ for(int i = 1 ; i<5; ++i){
+ buffer = 0;
+ if(i == 4){
+ buffer += 5 << 16;
+ }else{
+ buffer += i << 16;
+ }
+ buffer += ((Pindata[1] >> (i-1)*8) & 255) << 8;
+
+ if(-1 == WriteData(socket, buffer)){
+ return -1;
+ }
+ Sleep(1);
+ }
+
+ return 0;
+}
+//------------------------------------------------------------------------------------------------------
+int TransmitSC(SOCKET socket)
+{
+ unsigned int data = 0;
+ //Set SC mode -----------------------------------------------------------
+ data = 0;
+ data += 1 << 16;
+ data += 240 << 8;
+ if(-1 == WriteData(socket, data)){
+ return -1;
+ }
+
+ //SC start -------------------------------------------------------------
+ data = 0;
+ data += 10 << 16;
+ data += (slowdata[0] & 255) << 8;
+ if(-1 == WriteData(socket, data)){
+ return -1;
+ }
+
+ for(int i = 1; i<15; ++i){
+ for(int shift = 0; shift<4; ++shift){
+ data = 0;
+ data += 10 << 16;
+ data += ((slowdata[i] >> 8*shift) & 255) << 8;
+ if(-1 == WriteData(socket, data)){
+ return -1;
+ }
+ //std::cout<<"test"<<std::endl;
+ Sleep(1);
+ }
+ }
+
+ // Sleep(50000);
+
+ //StartCycle -----------------------------------------------------------
+ data = 0;
+ data += 1 << 16;
+ data += 242 << 8;
+ if(-1 == WriteData(socket, data)){
+ return -1;
+ }
+
+ data = 0;
+ data += 1 << 16;
+ data += 240 << 8;
+ if(-1 == WriteData(socket, data)){
+ return -1;
+ }
+
+ // Sleep(50000);
+
+ //Load SC --------------------------------------------------------------
+ data = 0;
+ data += 1 << 16;
+ data += 241 << 8;
+ if(-1 == WriteData(socket, data)){
+ return -1;
+ }
+
+ data = 0;
+ data += 1 << 16;
+ data += 240 << 8;
+ if(-1 == WriteData(socket, data)){
+ return -1;
+ }
+
+ return 0;
+}
+//------------------------------------------------------------------------------------------------------
+int TransmitReadSC(SOCKET socket)
+{
+ //SCA read ---------------------------------------------------------------
+ unsigned int data = 0;
+
+ for(int i = 0; i<4; ++i){
+ data = 0;
+ data += 12 << 16;
+ data += ((ReadSCdata[0] >> i*8) & 255) << 8;
+ if(-1 == WriteData(socket, data)){
+ return -1;
+ }
+ Sleep(1);
+ }
+
+ //StartCycle ------------------------------------------------------------
+ data = 0;
+ data += 1 << 16;
+ data += 242 << 8;
+ if(-1 == WriteData(socket, data)){
+ return -1;
+ }
+
+ data = 0;
+ data += 1 << 16;
+ data += 240 << 8;
+ if(-1 == WriteData(socket, data)){
+ return -1;
+ }
+
+ return 0;
+}
+//------------------------------------------------------------------------------------------------------
+int PreparePSC(int CurrentCh, int CurrentProbeType)
+{
+ enum Asign{fs_all, ssh_16, ssh_0, pa_16, pa_0, sizeAsign};
+ enum DataName{fs, ssh_hg, ssh_lg, pa_hg, pa_lg, sizeDataName};
+ enum DataName CurrentProbe;
+ CurrentProbe = fs;
+
+ static unsigned int ProbeBuffer = 0;
+ int flag_rst = 0;
+ int flag_input = 1;
+ for(int i = 0; i<sizeByte_PSC; ++i){
+ Probedata[i] = 0;
+ }
+
+ switch(CurrentProbeType){
+ case '1':
+ CurrentProbe = pa_hg;
+ break;
+
+ case '2':
+ CurrentProbe = pa_lg;
+ break;
+
+ case '3':
+ CurrentProbe = ssh_hg;
+ break;
+
+ case '4':
+ CurrentProbe = ssh_lg;
+ break;
+
+ case '5':
+ CurrentProbe = fs;
+ break;
+
+ case '6':
+
+ break;
+
+ case '7':
+
+ break;
+
+ case '8':
+ flag_rst = 1;
+ CurrentCh = 0;
+ ProbeBuffer = 0;
+ CurrentProbe = fs;
+ break;
+
+ default:
+ break;
+ };
+
+ if(flag_rst) {
+ return 0;
+ }
+
+ if(flag_input) {
+ ProbeBuffer = 1 << (31 - CurrentCh);
+ }
+
+ unsigned int buffer_16 = ProbeBuffer*ProbeBuffer;
+ unsigned int buffer_0 = (ProbeBuffer >> 16)*(ProbeBuffer >> 16);
+ if(CurrentProbe == ssh_hg || CurrentProbe == pa_hg) {
+ buffer_16 = buffer_16 << 1;
+ buffer_0 = buffer_0 << 1;
+ }
+ if(CurrentProbe == fs) {
+ Probedata[fs_all] = ProbeBuffer;
+ } else if(CurrentProbe == ssh_hg || CurrentProbe == ssh_lg) {
+ if(CurrentCh > 15) {
+ Probedata[ssh_16] = buffer_16;
+ } else {
+ Probedata[ssh_0] = buffer_0;
+ }
+ } else if(CurrentProbe == pa_hg || CurrentProbe == pa_lg) {
+ if(CurrentCh > 15){
+ Probedata[pa_16] = buffer_16;
+ }else{
+ Probedata[pa_0] = buffer_0;
+ }
+ } else {
+ printf("bug desu\n");
+ }
+
+ for(int shift = 0; shift<32; ++shift) {
+ if(((Probedata[fs_all]) >> shift) & 1) {
+ printf("!");
+ }else{
+ printf(".");
+ }
+ }
+ printf("\n");
+
+ for(int index = ssh_16; index <= ssh_0; ++index) {
+ for(int shift = 0; shift<32; ++shift) {
+ if(((Probedata[index]) >> shift) & 1) {
+ printf("!");
+ } else {
+ printf(".");
+ }
+ }
+ }
+ printf("\n");
+
+ for(int index = pa_16; index <= pa_0; ++index) {
+ for(int shift = 0; shift<32; ++shift) {
+ if(((Probedata[index]) >> shift) & 1) {
+ printf("!");
+ }else{
+ printf(".");
+ }
+ }
+ }
+ printf("\n");
+
+ return 0;
+}
+//------------------------------------------------------------------------------------------------------
+int TransmitProbe(SOCKET socket)
+{
+ unsigned int data = 0;
+ //Set Probe mode --------------------------------------------------------
+ data += 1 << 16;
+ data += 208 << 8;
+ if(-1 == WriteData(socket, data)) {
+ return -1;
+ }
+
+ //Probe start ----------------------------------------------------------
+ for(int i = 0; i<sizeByte_PSC; ++i) {
+ for(int shift = 0; shift<4; ++shift) {
+ data = 0;
+ data += 10 << 16;
+ data += ((Probedata[i] >> 8*shift) & 255) << 8;
+ if(-1 == WriteData(socket, data)) {
+ return -1;
+ }
+ }
+ }
+
+ //StartCycle ------------------------------------------------------------
+ data = 0;
+ data += 1 << 16;
+ data += 210 << 8;
+ if(-1 == WriteData(socket, data)) {
+ return -1;
+ }
+
+ data = 0;
+ data += 1 << 16;
+ data += 208 << 8;
+ if(-1 == WriteData(socket, data)) {
+ return -1;
+ }
+
+ return 0;
+}
+//------------------------------------------------------------------------------------------------------
+int easiroc_fTransmitSC()
+{
+ if(WriteData(sock, 37888) != 0) return -1;
+ PrepareSC(1);
+ if(TransmitSC(sock) != 0) return -1;
+ printf("\nSlow Control chip1 : Done\n\n");
+
+ if(WriteData(sock, 21504) != 0) return -1;
+ PrepareSC(2);
+ if(TransmitSC(sock) != 0) return -1;
+ printf("\nSlow Control chip2 : Done\n\n");
+
+ if(WriteData(sock, 5120) != 0) return -1;
+
+ return 0;
+}
+//------------------------------------------------------------------------------------------------------
+int easiroc_fTransmitReadSC()
+{
+ if(WriteData(sock, 37888) != 0) return -1;
+ PrepareReadSC(1);
+ if(TransmitReadSC(sock) != 0) return -1;
+ printf("\nRead Slow Control chip1 : Done\n\n");
+
+ if(WriteData(sock, 21504) != 0) return -1;
+ PrepareReadSC(2);
+ if(TransmitReadSC(sock) != 0) return -1;
+ printf("\nRead Slow Control chip2 : Done\n\n");
+
+ if(WriteData(sock, 5120) != 0) return -1;
+
+ return 0;
+}
+//------------------------------------------------------------------------------------------------------
+int easiroc_fAsicInitialize()
+{
+ PrepareFPGA();
+ DebugFPGA(sock);
+ printf("\nASIS Initialize : Done\n\n");
+
+ return 0;
+}
+//------------------------------------------------------------------------------------------------------
+int easiroc_fTransmitProbe(int CurrentCh, int CurrentProbe)
+{
+ //printf("\neasiroc_fTransmitProbe: CurrentCh : %d | CurrentProbe: %d\n\n", CurrentCh, CurrentProbe);
+
+ if(CurrentCh < 32) {
+ if(WriteData(sock, 37888)!= 0) return -1;
+ } else if(CurrentCh > 31) {
+ if(WriteData(sock, 21504)!= 0) return -1;
+ CurrentCh = CurrentCh - 32;
+ }
+
+ //printf("\neasiroc_fTransmitProbe: Preparing PSC\n\n");
+ if(PreparePSC(CurrentCh, CurrentProbe)!= 0) {
+ printf("\neasiroc_fTransmitProbe: PreparingPSC ERROR !!!!!!!!!!!!!!!!!!!\n\n");
+ return -1;
+ }
+ //printf("\neasiroc_fTransmitProbe: TransmitProbe\n\n");
+ if(TransmitProbe(sock)!= 0) {
+ printf("\neasiroc_fTransmitProbe: TransmitProbe ERROR !!!!!!!!!!!!!!!!!!!\n\n");
+ return -1;
+ }
+ //WriteData(3, 5120);
+ //printf("\nTransmitProbe: Success!\n\n");
+
+ return 0;
+}
+//------------------------------------------------------------------------------------------------------
+int ADCOneCycle_wHeader_ver2(SOCKET socket, FILE* file)
+{
+ static const int NofHeader = 3;
+
+ unsigned int DataBuffer[1000];
+ memset(DataBuffer, 0, sizeof(DataBuffer));
+ unsigned int *ptr_DataBuf = DataBuffer;
+ unsigned int TotalRecvByte = 0;
+ unsigned int TotalRecvEvent = 0;
+
+ unsigned int sizeHeader = NofHeader*sizeof(int);
+
+ unsigned int Header[] = {1, 1, 1};
+ int ret = 0;
+
+ ret = recv(sock, (char*)Header, sizeHeader, 0);
+ if(ret <= 0 && EndADC == 1) {
+ if(EndADC != 0) printf("Fatal ADC ERROR : recv\n");
+ return -1;
+ }
+
+ // sleep necessary! ERRORS happen if trigger rate lower than ~ sleep frequency!
+ usleep(200);
+ //Sleep(1);
+
+ //printf("Header1 (0xFFFFEA0C) : 0x%x | Header2 (0x00000100) : 0x%x\n", Header[0], Header[1]);
+ if(Header[0] != 0xFFFFEA0C) {
+ printf("Fatal ADC ERROR : HEADER\n");
+ printf("Header1 : 0x%x | Header2 : 0x%x | Header3 : 0x%x\n", Header[0], Header[1], Header[2]);
+ return -1;
+ } else {
+ unsigned int sizeData = (sizeof(int)*Header[1] & 0xffff);
+ unsigned int NofWord = (Header[1] & 0xffff);
+ unsigned int OneData[NofWord];
+
+ recv(socket, (char*)OneData, sizeData, 0);
+
+ // for(int i = 0; i<NofWord; ++i){ std::cout << std::hex << OneData[i] << std::endl; }
+
+ memcpy(ptr_DataBuf, Header, sizeHeader);
+ ptr_DataBuf += NofHeader;
+
+ memcpy(ptr_DataBuf, OneData, sizeData);
+ ptr_DataBuf += sizeData/sizeof(int);
+
+ TotalRecvByte += sizeHeader + sizeData;
+ ++TotalRecvEvent;
+ }
+
+ if(EndADC != 1){
+ for(unsigned int i = 0; i<TotalRecvByte/sizeof(int); ++i) {
+ unsigned int buffer = DataBuffer[i];
+ fwrite((char*)&buffer, sizeof(int), 1, file);
+ }
+ }
+
+ return 0;
+}
+//------------------------------------------------------------------------------------------------------
+void ADCStop(SOCKET socket)
+{
+ unsigned int signal = 0;
+ printf("ADC exit process\n");
+ signal += 16 << 24;
+ signal += 100 << 16;
+ send(socket, (char*)&signal, sizeof(int), 0);
+ Sleep(1);
+
+ signal = 0;
+ signal += 100 << 16;
+ send(socket, (char*)&signal, sizeof(int), 0);
+
+ Sleep(10);
+
+ return;
+}
+//------------------------------------------------------------------------------------------------------
+int ContinuousADC_ver2(SOCKET socket, char *file_name, int MaxCycleNum)
+{
+
+ unsigned int signal = 0;
+ int EventNum = 0;
+
+ FILE *file = NULL;
+ file = fopen(file_name, "wb");
+ if(file==NULL) {
+ printf("ContinuousADC_ver2: ERROR opneing file %s\n", file_name);
+ return -1;
+ }
+
+ signal += 32 << 24;
+ signal += 100 << 16;
+ send(socket, (char*)&signal, sizeof(int), 0);
+ Sleep(100);
+
+ while(EventNum < MaxCycleNum){
+ //Sleep(10);
+ ADCOneCycle_wHeader_ver2(socket, file);
+ ++EventNum;
+ if(0 == EventNum%1000){
+ printf("Event # %d\n", EventNum);
+ }
+
+ if(0 || EventNum == MaxCycleNum|| ForceStop == 1) {
+ ADCStop(socket);
+
+ EndADC = 1;
+ int abort = 0;
+ while(0 == ADCOneCycle_wHeader_ver2(socket, file)) {
+ Sleep(1);
+ if(abort == 50) {
+ ADCStop(socket);
+ abort = 0;
+ }
+ //printf("dummy data\n");
+ printf(".");
+ ++abort;
+ }
+
+ EndADC = 0;
+ ForceStop = 0;
+ break;
+ }
+ }
+
+ printf("\nEnd ADC\n");
+ fclose(file);
+
+ return 0;
+}
+//------------------------------------------------------------------------------------------------------
+int easiroc_fDAQ(char *file_name, int MaxCycleNum)
+{
+ printf("easiroc_fDAQ: Starting DAQ with file_name = %s | MaxCycleNum = %d\n", file_name, MaxCycleNum);
+ if(ContinuousADC_ver2(sock, file_name, MaxCycleNum) != 0) return -1;
+
+ return 0;
+}
+
+
+
Index: l2d2_easyroc/easiroc.h
===================================================================
--- l2d2_easyroc/easiroc.h (nonexistent)
+++ l2d2_easyroc/easiroc.h (revision 291)
@@ -0,0 +1,44 @@
+#ifndef easiroc_H
+#define easiroc_H
+
+#include<stdio.h>
+#include<stdlib.h>
+#include<errno.h>
+#include <Winsock2.h>
+
+#define sizeByte_SC 15
+#define sizeByte_PSC 5
+#define sizeByte_RSC 1
+#define sizeByte_PIN 2
+
+#define WRITEDATA_DELAY 40
+
+
+//------------------------------------------------------------------------------------------------------
+
+int easiroc_Init(const char* SiTCP_MASTER_IP, unsigned int daq_mode) ;
+void easiroc_Close();
+
+int WriteData(SOCKET sock, unsigned int data);
+
+void PrepareFPGA();
+int DebugFPGA(SOCKET socket);
+
+void PrepareSC(int chipNo);
+int TransmitSC(SOCKET socket);
+
+void PrepareReadSC(int chipNo);
+int TransmitReadSC(SOCKET socket);
+
+int PreparePSC(int CurrentCh, int CurrentProbeType);
+
+int ADCOneCycle_wHeader_ver2(SOCKET socket, FILE* file);
+void ADCStop(SOCKET socket);
+int ContinuousADC_ver2(SOCKET socket, char *file_name, int MaxCycleNum);
+
+int easiroc_fTransmitSC();
+int easiroc_fTransmitReadSC();
+int easiroc_fAsicInitialize();
+int easiroc_fTransmitProbe(int CurrentCh, int CurrentProbe);
+int easiroc_fDAQ(char *file_name, int MaxCycleNum);
+#endif
Index: l2d2_easyroc/easiroc~cvi151553.c
===================================================================
--- l2d2_easyroc/easiroc~cvi151553.c (nonexistent)
+++ l2d2_easyroc/easiroc~cvi151553.c (revision 291)
@@ -0,0 +1,1266 @@
+#include "easiroc.h"
+
+static const int SiTCP_PORT = 24;
+
+
+unsigned int slowdata[sizeByte_SC];
+unsigned int ReadSCdata[sizeByte_RSC];
+unsigned int Probedata[sizeByte_PSC];
+unsigned int Pindata[sizeByte_PIN];
+
+
+
+
+//------------------------------------------------------------------------------------------------------
+int easiroc_Init(const char* SiTCP_MASTER_IP, unsigned int daq_mode)
+{
+ // Start WinSock
+ printf("easiroc_Init --> Start.\n");
+ WORD wVersionRequested;
+ WSADATA wsaData;
+ if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) {
+ printf("WSAStartup failed with error!\n");
+ }
+
+ //Initialize -------------------------------------------------------------
+
+ SOCKET sock = INVALID_SOCKET;
+ struct sockaddr_in SiTCP_ADDR;
+ const char* IP;
+ unsigned int port;
+
+ sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ if(sock == INVALID_SOCKET) {
+ printf("easiroc_Init::sock = %d\n", sock);
+ return -1;
+ }
+ IP = SiTCP_MASTER_IP;
+ port = SiTCP_PORT;
+ SiTCP_ADDR.sin_family = AF_INET;
+ SiTCP_ADDR.sin_port = htons(port);
+ SiTCP_ADDR.sin_addr.s_addr = inet_addr(IP);
+
+ struct timeval tv;
+ tv.tv_sec = 3;
+ tv.tv_usec = 0;
+ setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char*)&tv, sizeof(tv));
+
+ int flag = 1;
+ setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char*)&flag, sizeof(flag));
+
+ //Connection -------------------------------------------------------------
+ int con = connect(sock, (struct sockaddr*)&SiTCP_ADDR, sizeof(SiTCP_ADDR));
+ printf("easiroc_Init::connect = %d\n", con);
+ if(0 > con){
+ printf("SiTCP Master :: Connection fail\n");
+ closesocket(sock);
+ return -1;
+ }
+
+ printf("SiTCP Master :: Connection Done\n\n");
+
+ // Auto Initialize -------------------------------------------------------
+ PrepareFPGA();
+ DebugFPGA(sock);
+ printf("\nASIS Initialize : Done\n\n");
+// Sleep(10000);
+
+ WriteData(sock, 37888);
+ PrepareSC(1);
+ TransmitSC(sock);
+ printf("\nSlow Control chip1 : Done\n\n");
+ PrepareReadSC(1);
+ TransmitReadSC(sock);
+ printf("\nRead Slow Control chip1 : Done\n\n");
+
+ WriteData(sock, 21504);
+ PrepareSC(2);
+ TransmitSC(sock);
+ printf("\nSlow Control chip2 : Done\n\n");
+ PrepareReadSC(2);
+ TransmitReadSC(sock);
+ printf("\nRead Slow Control chip2: Done\n\n");
+
+ WriteData(sock, 5120);
+ {
+ unsigned int signal = 31;
+ signal = signal << 16;
+ unsigned int data = daq_mode;
+ data = data << 8;
+ signal += data;
+ if(-1 == WriteData(sock, signal)){
+ return -1;
+ }
+ printf("\n#D : DAQ mode is %d \n", daq_mode);
+ }
+
+
+ return 0;
+}
+//------------------------------------------------------------------------------------------------------
+void easiroc_Close()
+{
+ WSACleanup();
+ printf("easiroc_Close -> Done.\n");
+}
+//------------------------------------------------------------------------------------------------------
+int WriteData(SOCKET sock, unsigned int data)
+{
+ int esrcdbg = 0;
+
+ Sleep(SOCK_DELAY);
+
+ data += 128 << 24;;
+
+ if(esrcdbg) printf("0x%X\n", data);
+ send(sock, (char*)&data, sizeof(int), 0);
+
+ Sleep(SOCK_DELAY);
+
+ unsigned int buf = 0;
+ unsigned int length = 4;
+ int ret = recv(sock, (char*)&buf, length, 0);
+
+ if ( ret > 0 ) {
+ if(esrcdbg) printf("Bytes received: %d\n", ret);
+ else printf(".");
+ } else if ( ret == 0 ) {
+ printf("Connection closed\n");
+ return -1;
+ } else {
+ printf("recv failed: %d\n", WSAGetLastError());
+ return -1;
+ }
+
+ return 0;
+}
+//------------------------------------------------------------------------------------------------------
+void PrepareFPGA()
+{
+ Pindata[0] = 20;
+ Pindata[1] = 65776;
+}
+//------------------------------------------------------------------------------------------------------
+void PrepareSC(int chipNo)
+{
+ if(chipNo == 1) {
+ slowdata[0] = 192;
+ slowdata[1] = 1720319;
+ slowdata[2] = 4253040640;
+ slowdata[3] = 413;
+ slowdata[4] = 0;
+ slowdata[5] = 3739423232;
+ slowdata[6] = 4294967295;
+ slowdata[7] = 4294967295;
+ slowdata[8] = 4294967295;
+ slowdata[9] = 4294967295;
+ slowdata[10] = 4294967295;
+ slowdata[11] = 4294967295;
+ slowdata[12] = 4294967295;
+ slowdata[13] = 4294967295;
+ slowdata[14] = 4294967295;
+ } else {
+ slowdata[0] = 192;
+ slowdata[1] = 4292874239;
+ slowdata[2] = 4257218559;
+ slowdata[3] = 478;
+ slowdata[4] = 0;
+ slowdata[5] = 3740340736;
+ slowdata[6] = 1175693740;
+ slowdata[7] = 2815957775;
+ slowdata[8] = 766945147;
+ slowdata[9] = 1504433946;
+ slowdata[10] = 2729016485;
+ slowdata[11] = 3412554245;
+ slowdata[12] = 2725848728;
+ slowdata[13] = 2267165112;
+ slowdata[14] = 4291041547;
+ }
+}
+//------------------------------------------------------------------------------------------------------
+void PrepareReadSC(int chipNo)
+{
+ if(chipNo == 1) {
+ ReadSCdata[0] = 0;
+ } else {
+ ReadSCdata[0] = 1;
+ }
+}
+//------------------------------------------------------------------------------------------------------
+int DebugFPGA(SOCKET socket)
+{
+ unsigned int buffer = 0;
+ buffer += 0 << 16;
+ buffer += (Pindata[0] & 255) << 8;
+ if(-1 == WriteData(socket, buffer)){
+ return -1;
+ }
+
+ for(int i = 1 ; i<5; ++i){
+ buffer = 0;
+ if(i == 4){
+ buffer += 5 << 16;
+ }else{
+ buffer += i << 16;
+ }
+ buffer += ((Pindata[1] >> (i-1)*8) & 255) << 8;
+
+ if(-1 == WriteData(socket, buffer)){
+ return -1;
+ }
+ Sleep(1);
+ }
+
+ return 0;
+}
+//------------------------------------------------------------------------------------------------------
+int TransmitSC(SOCKET socket){
+ unsigned int data = 0;
+ //Set SC mode -----------------------------------------------------------
+ data = 0;
+ data += 1 << 16;
+ data += 240 << 8;
+ if(-1 == WriteData(socket, data)){
+ return -1;
+ }
+
+ //SC start -------------------------------------------------------------
+ data = 0;
+ data += 10 << 16;
+ data += (slowdata[0] & 255) << 8;
+ if(-1 == WriteData(socket, data)){
+ return -1;
+ }
+
+ for(int i = 1; i<15; ++i){
+ for(int shift = 0; shift<4; ++shift){
+ data = 0;
+ data += 10 << 16;
+ data += ((slowdata[i] >> 8*shift) & 255) << 8;
+ if(-1 == WriteData(socket, data)){
+ return -1;
+ }
+ //std::cout<<"test"<<std::endl;
+ Sleep(1);
+ }
+ }
+
+ // Sleep(50000);
+
+ //StartCycle -----------------------------------------------------------
+ data = 0;
+ data += 1 << 16;
+ data += 242 << 8;
+ if(-1 == WriteData(socket, data)){
+ return -1;
+ }
+
+ data = 0;
+ data += 1 << 16;
+ data += 240 << 8;
+ if(-1 == WriteData(socket, data)){
+ return -1;
+ }
+
+ // Sleep(50000);
+
+ //Load SC --------------------------------------------------------------
+ data = 0;
+ data += 1 << 16;
+ data += 241 << 8;
+ if(-1 == WriteData(socket, data)){
+ return -1;
+ }
+
+ data = 0;
+ data += 1 << 16;
+ data += 240 << 8;
+ if(-1 == WriteData(socket, data)){
+ return -1;
+ }
+
+ return 0;
+}
+//------------------------------------------------------------------------------------------------------
+int TransmitReadSC(SOCKET socket)
+{
+ //SCA read ---------------------------------------------------------------
+ unsigned int data = 0;
+
+ for(int i = 0; i<4; ++i){
+ data = 0;
+ data += 12 << 16;
+ data += ((ReadSCdata[0] >> i*8) & 255) << 8;
+ if(-1 == WriteData(socket, data)){
+ return -1;
+ }
+ Sleep(1);
+ }
+
+ //StartCycle ------------------------------------------------------------
+ data = 0;
+ data += 1 << 16;
+ data += 242 << 8;
+ if(-1 == WriteData(socket, data)){
+ return -1;
+ }
+
+ data = 0;
+ data += 1 << 16;
+ data += 240 << 8;
+ if(-1 == WriteData(socket, data)){
+ return -1;
+ }
+
+ return 0;
+}
+
+//------------------------------------------------------------------------------------------------------
+
+/*
+
+#include"src/easiroc.h"
+#include"src/SC.hh"
+
+#include<fstream>
+#include<ios>
+
+static const int SiTCP_PORT = 24;
+
+extern unsigned int slowdata[sizeByte_SC];
+extern unsigned int ReadSCdata[sizeByte_RSC];
+extern unsigned int Probedata[sizeByte_PSC];
+extern unsigned int Pindata[sizeByte_PIN];
+
+int ForceStop = 0;
+int EndADC = 0;
+
+void ForceStop_FromCtrl_C(int signal);
+int receive(int sock, char* data_buf, unsigned int *ReadLength);
+int WriteData(int socket, unsigned int data);
+int ReadData(int socket, unsigned int signal, unsigned int data);
+void ADCStop(int socket);
+
+int DebugFPGA(int socket);
+int TransmitSC(int socket);
+int TransmitReadSC(int socket);
+int TransmitProbe(int socket);
+int ContinuousADC(int socket);
+int ContinuousADC_ver2(int socket);
+void ADCOneCycle(int socket, std::ofstream& file);
+void ADCOneCycle_wHeader(int socket, std::ofstream& file);
+int ADCOneCycle_wHeader_ver2(int socket, std::ofstream& file);
+void MHTDC_debug(int socket);
+int Debugging(int socket);
+int chipselect();
+
+int main(int argc, char* argv[]){
+ if(1 == argc){
+ std::cout << "Usage\n";
+ std::cout << "./easiroc [IP Address of SOY] [DAQ mode]" << std::e\
+ndl;
+ std::cout << " DAQ mode : 1 MHTDC\n";
+ std::cout << " : 2 ADC\n";
+ std::cout << " : 3 ADC & MHTDC" << std::endl;
+ exit(-1);
+ }
+
+ unsigned int daq_mode = (unsigned int)atoi(argv[2]);
+
+ const char* SiTCP_MASTER_IP = argv[1];
+
+ int sock = 0;
+ struct sockaddr_in SiTCP_ADDR;
+ const char* IP;
+ unsigned int port;
+
+ //Initialize -------------------------------------------------------------
+ ForceStop = 0;
+ (void) signal(SIGINT, ForceStop_FromCtrl_C);
+
+ sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ IP = SiTCP_MASTER_IP;
+ port = SiTCP_PORT;
+ SiTCP_ADDR.sin_family = AF_INET;
+ SiTCP_ADDR.sin_port = htons(port);
+ SiTCP_ADDR.sin_addr.s_addr = inet_addr(IP);
+
+ struct timeval tv;
+ tv.tv_sec = 3;
+ tv.tv_usec = 0;
+ setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char*)&tv, sizeof(tv));
+
+ int flag = 1;
+ setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char*)&flag, sizeof(flag));
+
+ //Connection -------------------------------------------------------------
+ if(0 > connect(sock, (struct sockaddr*)&SiTCP_ADDR, sizeof(SiTCP_ADDR))){
+ std::cerr << "SiTCP Master :: Connection fail" << std::endl;
+ close(sock);
+ return -1;
+ }
+
+ std::cout << "SiTCP Master :: Connection Done" << std::endl;
+ std::cout << std::endl;
+
+ // Auto Initialize -------------------------------------------------------
+ PrepareFPGA();
+ DebugFPGA(sock);
+ std::cout << "ASIS Initialize : Done" << std::endl;
+ std::cout << std::endl;
+ usleep(10000);
+
+ WriteData(3, 37888);
+ PrepareSC(1);
+ TransmitSC(sock);
+ std::cout << "Slow Control chip1 : Done" << std::endl;
+ std::cout << std::endl;
+ PrepareReadSC(1);
+ TransmitReadSC(sock);
+ std::cout << "Read Slow Control chip1 : Done" << std::endl;
+ std::cout << std::endl;
+
+ WriteData(3, 21504);
+ PrepareSC(2);
+ TransmitSC(sock);
+ std::cout << "Slow Control chip2 : Done" << std::endl;
+ std::cout << std::endl;
+ PrepareReadSC(2);
+ TransmitReadSC(sock);
+ std::cout << "Read Slow Control chip2: Done" << std::endl;
+ std::cout << std::endl;
+
+ WriteData(3, 5120);
+ {
+ unsigned int signal = 31;
+ signal = signal << 16;
+ unsigned int data = daq_mode;
+ data = data << 8;
+ signal += data;
+ if(-1 == WriteData(sock, signal)){
+ exit(-1);
+ }
+ std::cout << "#D : DAQ mode is " << daq_mode << std::endl;
+ }
+
+
+ // User area -----------------------------------------------------------
+ bool DispMenu = true;
+ int CurrentCh = 0;
+ while(DispMenu){
+ for(int i = 0; i<3; ++i){
+ std::cout << std::endl;
+ }
+
+ std::cout << "I'm : " << SiTCP_MASTER_IP << std::endl;
+ std::cout << "Please select" << std::endl;
+ std::cout << " 1. Transmit SC" << std::endl;
+ std::cout << " 2. Transmit Read SC" << std::endl;
+ std::cout << " 3. ASIC Initialize" << std::endl;
+ std::cout << " 4. Transmit Probe " << std::endl;
+ std::cout << " 5. Connection Close" << std::endl;
+ std::cout << " 6. Start DAQ" << std::endl;
+ std::cout << " 7. Debug" << std::endl;
+ std::cout << "input # ====> " << std::flush;
+ char buf[10];
+ fgets(buf, sizeof(buf),stdin);
+ char num;
+ sscanf(buf,"%c",&num);
+
+ switch(num){
+ case '1':
+ WriteData(3, 37888);
+ PrepareSC(1);
+ TransmitSC(sock);
+ WriteData(3, 21504);
+ PrepareSC(2);
+ TransmitSC(sock);
+ WriteData(3, 5120);
+ break;
+
+ case '2':
+ WriteData(3, 37888);
+ PrepareReadSC(1);
+ TransmitReadSC(sock);
+ WriteData(3, 21504);
+ PrepareReadSC(2);
+ TransmitReadSC(sock);
+ WriteData(3, 5120);
+ break;
+
+ case '3':
+ PrepareFPGA();
+ DebugFPGA(sock);
+ break;
+
+ case '4':
+ std::cout << "Input channel number ====> " << std::endl;
+ std::cin >> CurrentCh;
+ fgets(&buf[0],sizeof(buf),stdin); //Enter buffer clear
+ if(CurrentCh < 32){
+ WriteData(3, 37888);
+ }
+ else if(CurrentCh > 31){
+ WriteData(3, 21504);
+ CurrentCh = CurrentCh - 32;
+ }
+ std::cout<<CurrentCh<<std::endl;
+ PreparePSC(CurrentCh);
+ TransmitProbe(sock);
+ //WriteData(3, 5120);
+ break;
+
+ case '5':
+ DispMenu = false;
+ break;
+
+ case '6':
+ ContinuousADC_ver2(sock);
+ break;
+
+ case '7':
+ Debugging(sock);
+ break;
+
+ case '8':
+ MHTDC_debug(sock);
+ break;
+
+ case '9':
+ chipselect();
+ break;
+
+ default:
+ break;
+ };
+ }
+
+ //End Connection ---------------------------------------------------------
+ close(sock);
+ std::cout << "All :: Connection Close" << std::endl;
+
+ return 0;
+}
+
+void ForceStop_FromCtrl_C(int signal){
+ std::cout << "Stop request from user" << std::endl;
+ ForceStop = 1;
+ EndADC = 1;
+}
+
+int receive(int sock, char* data_buf, unsigned int *ReadLength){
+ unsigned int revd_size = 0;
+ int tmp_returnVal = 0;
+
+ while(revd_size < *ReadLength){
+ tmp_returnVal = recv(sock, data_buf +revd_size, *ReadLength -revd_size, 0);
+ if(tmp_returnVal < 0){
+ int errbuf = errno;
+ perror("TCP receive");
+ if(errbuf == EAGAIN){
+ if(EndADC == 1){
+ std::cout << "No data" << std::endl;
+ break;
+ }
+ continue;
+ }else if(errbuf == EINTR){
+ continue;
+ }else{
+ exit(-1);
+ }
+ }
+ revd_size += tmp_returnVal;
+ }
+
+ // std::cout << "ret is " << std::dec << revd_size << std::endl;
+ return revd_size;
+}
+
+int WriteData(int sock, unsigned int data){
+ data += 128 << 24;
+// for(int i = 31; i>-1; --i){
+// unsigned int hoge = (data >> i) & 1;
+// if(hoge){
+// fprintf(stdout, "!");
+// }else{
+// fprintf(stdout, ".");
+// }
+// if(i%8 == 0){
+// fprintf(stdout, "\n");
+// }
+// }
+// fprintf(stdout, "\n");
+
+// std::cout << std::hex << data << std::endl;
+ send(sock, (char*)&data, sizeof(int), 0);
+ unsigned int buf = 0;
+ unsigned int length = 4;
+ receive(sock, (char*)&buf, &length);
+ if(data - buf){
+ std::cerr << "### Data Transmit Error ###" << std::endl;
+ std::cerr << "Transmited data is " << std::hex << data << std::endl;
+ std::cout << "Returned data is " << std::hex << buf << std::endl;
+ return -1;
+ }
+
+ return 0;
+}
+
+int ReadData(int sock, unsigned int signal, unsigned int *data){
+ signal += 64 << 24;
+ send(sock, (char*)&signal, sizeof(int), 0);
+ unsigned int length = 4;
+ receive(sock, (char*)data, &length);
+
+// for(int i = 31; i>-1; --i){
+// unsigned int hoge = (*data >> i) & 1;
+// if(hoge){
+// fprintf(stdout, "!");
+// }else{
+// fprintf(stdout, ".");
+// }
+// if(i%8 == 0){
+// fprintf(stdout, "\n");
+// }
+// }
+// fprintf(stdout, "\n");
+
+ return 0;
+}
+
+int DebugFPGA(int socket){
+ unsigned int buffer = 0;
+ buffer += 0 << 16;
+ buffer += (Pindata[0] & 255) << 8;
+ if(-1 == WriteData(socket, buffer)){
+ exit(-1);
+ }
+
+ for(int i = 1 ; i<5; ++i){
+ buffer = 0;
+ if(i == 4){
+ buffer += 5 << 16;
+ }else{
+ buffer += i << 16;
+ }
+ buffer += ((Pindata[1] >> (i-1)*8) & 255) << 8;
+
+ if(-1 == WriteData(socket, buffer)){
+ exit(-1);
+ }
+ usleep(1);
+ }
+
+ return 0;
+}
+
+int TransmitSC(int socket){
+ unsigned int data = 0;
+ //Set SC mode -----------------------------------------------------------
+ data = 0;
+ data += 1 << 16;
+ data += 240 << 8;
+ if(-1 == WriteData(socket, data)){
+ exit(-1);
+ }
+
+ //SC start -------------------------------------------------------------
+ data = 0;
+ data += 10 << 16;
+ data += (slowdata[0] & 255) << 8;
+ if(-1 == WriteData(socket, data)){
+ exit(-1);
+ }
+
+ for(int i = 1; i<15; ++i){
+ for(int shift = 0; shift<4; ++shift){
+ data = 0;
+ data += 10 << 16;
+ data += ((slowdata[i] >> 8*shift) & 255) << 8;
+ if(-1 == WriteData(socket, data)){
+ exit(-1);
+ }
+ //std::cout<<"test"<<std::endl;
+ usleep(1);
+ }
+ }
+
+ // usleep(50000);
+
+ //StartCycle -----------------------------------------------------------
+ data = 0;
+ data += 1 << 16;
+ data += 242 << 8;
+ if(-1 == WriteData(socket, data)){
+ exit(-1);
+ }
+
+ data = 0;
+ data += 1 << 16;
+ data += 240 << 8;
+ if(-1 == WriteData(socket, data)){
+ exit(-1);
+ }
+
+ // usleep(50000);
+
+ //Load SC --------------------------------------------------------------
+ data = 0;
+ data += 1 << 16;
+ data += 241 << 8;
+ if(-1 == WriteData(socket, data)){
+ exit(-1);
+ }
+
+ data = 0;
+ data += 1 << 16;
+ data += 240 << 8;
+ if(-1 == WriteData(socket, data)){
+ exit(-1);
+ }
+
+ return 0;
+}
+
+int TransmitReadSC(int socket){
+ //SCA read ---------------------------------------------------------------
+ unsigned int data = 0;
+
+ for(int i = 0; i<4; ++i){
+ data = 0;
+ data += 12 << 16;
+ data += ((ReadSCdata[0] >> i*8) & 255) << 8;
+ if(-1 == WriteData(socket, data)){
+ exit(-1);
+ }
+ usleep(1);
+ }
+
+ //StartCycle ------------------------------------------------------------
+ data = 0;
+ data += 1 << 16;
+ data += 242 << 8;
+ if(-1 == WriteData(socket, data)){
+ exit(-1);
+ }
+
+ data = 0;
+ data += 1 << 16;
+ data += 240 << 8;
+ if(-1 == WriteData(socket, data)){
+ exit(-1);
+ }
+
+ return 0;
+}
+
+int TransmitProbe(int socket){
+ unsigned int data = 0;
+ //Set Probe mode --------------------------------------------------------
+ data += 1 << 16;
+ data += 208 << 8;
+ if(-1 == WriteData(socket, data)){
+ exit(-1);
+ }
+
+ //Probe start ----------------------------------------------------------
+ for(int i = 0; i<sizeByte_PSC; ++i){
+ for(int shift = 0; shift<4; ++shift){
+ data = 0;
+ data += 10 << 16;
+ data += ((Probedata[i] >> 8*shift) & 255) << 8;
+ if(-1 == WriteData(socket, data)){
+ exit(-1);
+ }
+ usleep(1);
+ }
+ }
+
+ usleep(50000);
+
+ //StartCycle ------------------------------------------------------------
+ data = 0;
+ data += 1 << 16;
+ data += 210 << 8;
+ if(-1 == WriteData(socket, data)){
+ exit(-1);
+ }
+
+ data = 0;
+ data += 1 << 16;
+ data += 208 << 8;
+ if(-1 == WriteData(socket, data)){
+ exit(-1);
+ }
+
+ return 0;
+}
+
+int ContinuousADC(int socket){
+ std::string file_num;
+ std::cout << "Input output data file name : " << std::flush;
+ std::cin >> file_num;
+ std::string basename = "after_break_ext_";
+ std::string file_name = basename + file_num + ".dat";
+ std::ofstream file(file_name.c_str(),std::ios::binary);
+
+ int MaxCycleNum = 0;
+ std::cout << "Input total # of events" << std::endl;
+ // std::cout << "If you type 'N', preset # of events will be N*1000" << std::endl;
+ std::cout << "======>" << std::flush;
+ std::cin >> MaxCycleNum;
+ MaxCycleNum = MaxCycleNum/1000;
+ std::cout << "Preset value : " << MaxCycleNum*1000 << std::endl;
+
+ for(int i = 0; i<MaxCycleNum; ++i){
+ // ADCOneCycle(socket, file);
+ ADCOneCycle_wHeader(socket, file);
+ std::cout << "Event # " << 1000*(i+1) << std::endl;
+ }
+
+ std::cout << "End ADC" << std::endl;
+ file.close();
+
+ return 0;
+}
+
+int ContinuousADC_ver2(int socket){
+ std::string file_name;
+ std::cout << "Input output data file name : " << std::flush;
+ std::cin >> file_name;
+ std::ofstream file(file_name.c_str(),std::ios::binary);
+
+ int MaxCycleNum = 0;
+ std::cout << "Input total # of events" << std::endl;
+ std::cout << "======>" << std::flush;
+ std::cin >> MaxCycleNum;
+ std::cout << "Preset value : " << std::dec << MaxCycleNum << std::endl;
+
+ unsigned int signal = 0;
+ int EventNum = 0;
+
+ signal += 32 << 24;
+ signal += 100 << 16;
+ send(socket, (char*)&signal, sizeof(int), 0);
+
+ while(EventNum < MaxCycleNum){
+ ADCOneCycle_wHeader_ver2(socket, file);
+ ++EventNum;
+ if(0 == EventNum%1000){
+ std::cout << "Event # " << std::dec << EventNum << std::endl;
+ }
+
+ if(false
+ || EventNum == MaxCycleNum
+ || ForceStop == 1
+ ){
+ ADCStop(socket);
+
+ EndADC = 1;
+ int abort = 0;
+ while(0 == ADCOneCycle_wHeader_ver2(socket, file)){
+ usleep(10000);
+ if(abort == 50){
+ ADCStop(socket);
+ abort = 0;
+ }
+ std::cout << "dummy data" << std::endl;
+ ++abort;
+ }
+
+ EndADC = 0;
+ ForceStop = 0;
+ break;
+ }
+ }
+
+ std::cout << "End ADC" << std::endl;
+ file.close();
+
+ return 0;
+}
+
+void ADCOneCycle(int socket, std::ofstream& file){
+ static const int TotalEvent = 1000;
+ unsigned int signal = 0;
+
+ signal += 16 << 24;
+ signal += 100 << 16;
+ send(socket, (char*)&signal, sizeof(int), 0);
+
+ unsigned int ADCData[16*TotalEvent];
+ for(int i = 0; i<16*TotalEvent; ++i){
+ ADCData[i] = 0;
+ }
+ static unsigned int ADCLength = sizeof(ADCData);
+ receive(socket, (char*)ADCData, &ADCLength);
+
+
+ for(int Event = 0; Event<TotalEvent; ++Event ){
+ int event = 0xffff;
+ file.write((char*)&event, sizeof(short));
+ // fprintf(stdout, "Event # %d\n",Event);
+
+ for(int i = 0; i<16; ++i){
+ unsigned int buffer = ADCData[i+16*Event] & 4095;
+ // fprintf(stdout, "%d\n",buffer & 15);
+ file.write((char*)&buffer, sizeof(short));
+ buffer = (ADCData[i+16*Event] >> 16) & 4095;
+ // fprintf(stdout, "%d\n",buffer & 15);
+ file.write((char*)&buffer, sizeof(short));
+ }
+ // std::cout << std::endl;
+ // std::cout << std::endl;
+ }
+
+ signal = 0;
+ signal += 100 << 16;
+ if(-1 == WriteData(socket, signal)){
+ exit(-1);
+ }
+
+}
+
+void ADCOneCycle_wHeader(int socket, std::ofstream& file){
+ static const int TotalEvent = 1000;
+ unsigned int signal = 0;
+
+ unsigned int DataBuffer[100*TotalEvent];
+ memset(DataBuffer, 0, sizeof(DataBuffer));
+ unsigned int *ptr_DataBuf = DataBuffer;
+ unsigned int TotalRecvByte = 0;
+ unsigned int TotalRecvEvent = 0;
+
+ static unsigned int sizeHeader = 2*sizeof(int);
+
+ signal += 16 << 24;
+ signal += 100 << 16;
+ send(socket, (char*)&signal, sizeof(int), 0);
+
+ for(int i = 0; i<TotalEvent; ++i){
+ unsigned int Header[2] = {1, 1};
+ receive(socket, (char*)Header, &sizeHeader);
+ // Header[0] = 0xFFFFEA0C;
+ // Header[1] = 0x00000100;
+ if(Header[0] != 0xFFFFEA0C){
+ std::cerr << "Fatal ADC ERROR : HEADER" << std::endl;
+ std::cerr << "Header1 : " << std::hex << Header[0] << " Header2 : " << std::hex << Header[1] << std::endl;
+ exit(-1);
+ }else{
+ // std::cerr << "Header1 : " << std::hex << Header[0] << " Header2 : " << std::hex << Header[1] << std::endl;
+ // std::cout << "Num " << i << std::endl;
+ // std::cerr << "Header1 : " << std::hex << Header[0] << " Header2 : " << std::hex << Header[1] << std::endl;
+ unsigned int sizeData = Header[1] & 0xffff;
+ unsigned int OneData[sizeData/sizeof(int)];
+// for(unsigned int i = 0; i<sizeData/sizeof(int); ++i){
+// OneData[i] = (900 +2*i) << 16;
+// OneData[i] += 900 +2*i +1;
+// }
+ receive(socket, (char*)OneData, &sizeData);
+ // std::cout << OneData[0] << std::endl;
+
+ memcpy(ptr_DataBuf, Header, sizeHeader);
+ ptr_DataBuf += 2;
+
+ memcpy(ptr_DataBuf, OneData, sizeData);
+ ptr_DataBuf += sizeData/sizeof(int);
+
+ TotalRecvByte += sizeHeader + sizeData;
+ ++TotalRecvEvent;
+ }
+ }
+
+
+ for(unsigned int i = 0; i<TotalRecvByte/sizeof(int); ++i){
+// unsigned int buffer = (DataBuffer[i] >> 16) & 0xffff;
+// // fprintf(stdout, "%d\n",buffer & 15);
+// file.write((char*)&buffer, sizeof(short));
+// buffer = DataBuffer[i] & 0xffff;
+// // fprintf(stdout, "%d\n",buffer & 15);
+// file.write((char*)&buffer, sizeof(short));
+ unsigned int buffer = DataBuffer[i];
+ file.write((char*)&buffer, sizeof(int));
+ }
+
+ signal = 0;
+ signal += 100 << 16;
+ if(-1 == WriteData(socket, signal)){
+ exit(-1);
+ }
+
+ return;
+}
+
+int ADCOneCycle_wHeader_ver2(int socket, std::ofstream& file){
+ static const int NofHeader = 3;
+
+ unsigned int DataBuffer[1000];
+ memset(DataBuffer, 0, sizeof(DataBuffer));
+ unsigned int *ptr_DataBuf = DataBuffer;
+ unsigned int TotalRecvByte = 0;
+ unsigned int TotalRecvEvent = 0;
+
+ static unsigned int sizeHeader = NofHeader*sizeof(int);
+
+ unsigned int Header[NofHeader] = {1, 1, 1};
+ int ret = 0;
+ ret = receive(socket, (char*)Header, &sizeHeader);
+ if(ret <= 0 && EndADC == 1){
+ return -1;
+ }
+
+ // std::cout << "Header1 : " << std::hex << Header[0] << " Header2 : " << std::hex << Header[1] << std::endl;
+ // Header[0] = 0xFFFFEA0C;
+ // Header[1] = 0x00000100;
+ if(Header[0] != 0xFFFFEA0C){
+ std::cerr << "Fatal ADC ERROR : HEADER" << std::endl;
+ std::cerr << "Header1 : " << std::hex << Header[0]
+ << " Header2 : " << std::hex << Header[1]
+ << " Header3 : " << std::hex << Header[2] << std::endl;
+ exit(-1);
+ }else{
+ unsigned int sizeData = (sizeof(int)*Header[1] & 0xffff);
+ unsigned int NofWord = (Header[1] & 0xffff);
+ unsigned int OneData[NofWord];
+ receive(socket, (char*)OneData, &sizeData);
+
+// for(int i = 0; i<NofWord; ++i){
+// std::cout << std::hex << OneData[i] << std::endl;
+// }
+
+ memcpy(ptr_DataBuf, Header, sizeHeader);
+ ptr_DataBuf += NofHeader;
+
+ memcpy(ptr_DataBuf, OneData, sizeData);
+ ptr_DataBuf += sizeData/sizeof(int);
+
+ TotalRecvByte += sizeHeader + sizeData;
+ ++TotalRecvEvent;
+ }
+
+ if(EndADC != 1){
+ for(unsigned int i = 0; i<TotalRecvByte/sizeof(int); ++i){
+ unsigned int buffer = DataBuffer[i];
+ file.write((char*)&buffer, sizeof(int));
+ }
+ }
+
+ return 0;
+}
+
+// Debug ---------------------------------------------------------------------
+int Debugging(int socket){
+ enum debug{read, write, quit, sizedebug};
+ bool flag_[sizedebug];
+ for(int i = 0; i<sizedebug; ++i){
+ flag_[i] = false;
+ }
+
+ std::cout << "Read/Write" << std::endl;
+ std::cout << "1. Read" << std::endl;
+ std::cout << "2. Write" << std::endl;
+ std::cout << "3. Return" << std::endl;
+ std::cout << "input # =====> " << std::flush;
+ char buf[10];
+ fgets(buf, sizeof(buf), stdin);
+ char num;
+ sscanf(buf, "%c", &num);
+
+ switch(num){
+ case '1':
+ flag_[read] = true;
+ break;
+
+ case '2':
+ flag_[write] = true;
+ break;
+
+ default:
+
+ break;
+ };
+
+ if(flag_[read]){
+ std::cout << "Debug Read" << std::endl;
+ std::cout << "Input subaddress : " << std::flush;
+ std::string strbuf;
+ std::cin >> strbuf;
+ std::istringstream valbuf(strbuf);
+ unsigned int saddr = 0;
+ valbuf >> saddr;
+ saddr = saddr << 16;
+
+ unsigned int data = 0;
+ if(0 == ReadData(socket, saddr, &data)){
+ std::cout << std::hex << data << std::endl;
+ std::cout << "bit31 << >> bit0" << std::endl;
+ for(int i = 1; i<33; ++i){
+ if(data >> (32 -i) & 1){
+ std::cout << "!" << std::flush;
+ }else{
+ std::cout << "." << std::flush;
+ }
+
+ if(0 == i%8){
+ std::cout << " " << std::endl;
+ }
+ }
+ std::cout << std::endl;
+ }else{
+ std::cerr << "Read error" << std::endl;
+ exit(-1);
+ }
+ }
+
+ if(flag_[write]){
+ std::cout << "Debug Write" << std::endl;
+ std::cout << "Input subaddress : " << std::flush;
+ std::string strbuf;
+ std::cin >> strbuf;
+ std::istringstream valbuf(strbuf);
+ unsigned int signal = 0;
+ valbuf >> signal;
+ signal = signal << 16;
+
+ std::cout << "Input signal : " << std::flush;
+ std::string strbuf2;
+ std::cin >> strbuf2;
+ std::istringstream databuf(strbuf2);
+ unsigned int data = 0;
+ databuf >> data;
+ data = data << 8;
+ signal += data;
+
+ std::cout << std::hex << signal << std::flush;
+ std::cout << std::dec << std::endl;
+ std::cout << signal << std::endl;
+ if(-1 == WriteData(socket, signal)){
+ exit(-1);
+ }
+ }
+
+ return 0;
+}
+
+void ADCStop(int socket){
+ unsigned int signal = 0;
+ std::cout << "ADC exit process" << std::endl;
+ signal += 16 << 24;
+ signal += 100 << 16;
+ send(socket, (char*)&signal, sizeof(int), 0);
+ sleep(1);
+
+ signal = 0;
+ signal += 100 << 16;
+ send(socket, (char*)&signal, sizeof(int), 0);
+
+ usleep(10000);
+
+ return;
+}
+
+void MHTDC_debug(int sock){
+
+ std::ofstream m_file("mhtdc.dat",std::ios::binary);
+
+ unsigned int saddr = 50;
+ unsigned int data = 0;
+ saddr = saddr << 16;
+ unsigned int signal = 4;
+ signal = signal << 8;
+ saddr += signal;
+ WriteData(sock, saddr);
+
+ saddr = 50;
+ saddr = saddr << 16;
+ WriteData(sock, saddr);
+ usleep(100000);
+
+ while(ForceStop == 0){
+ // for(int k = 0; k<3; ++k){
+ saddr = 41;
+ data = 0;
+ saddr = saddr << 16;
+
+ usleep(100000);
+ if(0 == ReadData(sock, saddr, &data)){
+ int size = (data >> 8) & 0xff;
+ // std::cout << "size : " << size << std::endl;
+ std::cout << std::hex << "status : " << data << std::endl;
+
+ int valid = data & 0x1;
+
+ if(valid == 1){
+ unsigned int f_size = 0xffff;
+ f_size = (f_size << 16) + size;
+ m_file.write((char*)&f_size, sizeof(unsigned int));
+ for(int i = 0; i<size; ++i){
+ // usleep(100);
+ saddr = 42;
+ saddr = saddr << 16;
+ unsigned int head =0;
+ if(0 == ReadData(sock, saddr, &data)){
+ std::cout << std::hex << "header" << i << " : " << data << std::endl;
+ head = data & 0xffff;
+ }else{
+ std::cerr << "Read error" << std::endl;
+ exit(-1);
+ }
+
+ // Leading
+ saddr = 40;
+ saddr = saddr << 16;
+ if(0 == ReadData(sock, saddr, &data)){
+ unsigned int time = (data & 0xffff);
+ unsigned int one_data = (head << 16) + time;
+ m_file.write((char*)&one_data, sizeof(unsigned int));
+ std::cout << std::dec << "time L" << i << " : " << time << " ns" << std::endl;
+ }else{
+ std::cerr << "Read error" << std::endl;
+ exit(-1);
+ }
+
+ // Trailing
+ saddr = 43;
+ saddr = saddr << 16;
+ if(0 == ReadData(sock, saddr, &data)){
+ unsigned int time = (data & 0xffff);
+ time = (1 << 15) + time;
+ unsigned int one_data = (head << 16) + time;
+ m_file.write((char*)&one_data, sizeof(unsigned int));
+ std::cout << std::dec << "time T" << i << " : " << (time & 0xfff) << " ns" << std::endl;
+ }else{
+ std::cerr << "Read error" << std::endl;
+ exit(-1);
+ }
+ }
+ saddr = 50;
+ saddr = saddr << 16;
+ signal = 4;
+ signal = signal << 8;
+ saddr += signal;
+ WriteData(sock, saddr);
+
+ saddr = 50;
+ saddr = saddr << 16;
+ WriteData(sock, saddr);
+
+ }
+ }else{
+ std::cerr << "Read error" << std::endl;
+ exit(-1);
+ }
+ }
+
+ return;
+}
+
+int chipselect(){
+
+ WriteData(3, 37888);
+ // if(-1 == WriteData(3, 5120)){
+ // exit(-1);
+ // }
+ return 0;
+}
+ */
Index: l2d2_easyroc/l2d.c
===================================================================
--- l2d2_easyroc/l2d.c (nonexistent)
+++ l2d2_easyroc/l2d.c (revision 291)
@@ -0,0 +1,1387 @@
+//#define USE_DAQ
+//#define USE_MIKRO
+#define USE_EASIROC
+#define USE_UDPCONTROL
+
+#ifdef USE_EASIROC
+ #include "easiroc.h"
+
+ #define erIpAddr "192.168.10.16"
+ #define erDAQmode 3
+#endif
+
+#ifdef USE_UDPCONTROL
+ #include "SiTCP.h"
+ #include "sender.h"
+
+ #define IpAddr "192.168.10.16"
+ #define tcpport 24
+ #define udpport 4660
+
+ int HVDAC = 0;
+ int MADC = 0;
+ int MUX = 0;
+ double HV = 0;
+ double rd_data = 0;
+ float DACdata[63];
+
+ float HVC_1 = 483.183;
+ float HVC_2 = 780;
+ // HVDAC =HVC_1 * HV + HVC_2; convert HV to DAC bit
+
+ float ADC2HV = 0.00208;
+ // rd_data = ADC2HV * rd_data; convert ADC bit to HV
+
+ float ADC2uA = 0.034;
+ // rd_data = ADC2uA * rd_data; convert ADC bit to HVcurrent
+
+ float ADC2V = 0.0000685;
+ //rd_data = ADC2V * rd_data; convert ADC bit to inputDAC Voltage
+
+ float ADC2K = 4500;
+ // rd_data = ADC2K * rd_data/65535/2.4; convert ADC bit to TEMP(K)
+#endif
+
+
+// Izberi ustrezni interface v meniju projektnega okna
+// Options->CompilerDefines (dodaj /DSISVME ali /DWIENVME)
+#ifdef USE_DAQ
+# define USE_CAMAC
+# include "camac.h"
+# ifdef SISVME
+# include "sisWIENVME_VME_dll.h"
+# endif
+# ifdef WIENVME
+//# include "wienWIENVME_VME_dll.h"
+# include "wienvme_dll.h"
+# endif
+# include "CAENV965.h"
+#endif
+
+#ifdef USE_MIKRO
+# include "MIKRO.h"
+#endif
+
+#include <userint.h>
+#include <ansi_c.h>
+#include <utility.h>
+#include <analysis.h>
+
+#include "l2d_ui.h"
+
+#ifdef USE_DAQ
+# define VADC_ADDR1 0x55550000
+# define VADC1 1
+//# define VADC_ADDR2 0x550000
+# define VADC2 2
+//# define NTDCJ1 17
+//# define NTDCJ2 18
+//# define NGL 23
+# define NPIO 23
+#define USE_CAEN_TDC
+//CAEN V1290A TDC
+#define TDC_ADDR 0x44440000
+#define NCH_TDC 32
+#define EVMAX 4 //how many of the multihit to save
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+static int tdcmap[32]={ 0, 1,2, 3,4, 5,6, 7,8,9,10,11,12,13,14,15,
+// 16 19 18 19 20 21 22 23 24 25 26 27 28 29 30 31
+ 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31};
+#endif
+
+#ifdef USE_CAEN_TDC
+// CAEN V1290 TDC
+int V1290_writeOC(int *write_buffer);
+int V1290_readOC(int *write_buffer);
+void V1290_init();
+#endif
+// Pomozne funkcije
+int max_from(int* array, int ifrom, int ito);
+
+#ifdef USE_MIKRO
+# define MIKRO_COM 5
+# define MIKRO_X 1
+#define USE_MIKRO_Y
+# define MIKRO_Y 2
+#define USE_MIKRO_Z
+# define MIKRO_Z 3
+#endif
+
+#define MAXCH_TDC 65536
+#define MAXCH_QDC 0x1000
+#define MAX_THREADS 10
+
+#define IWAIT 200
+
+# define NCH 32
+static int p1h, pID, rID, tfID;
+static int ph_tdc, ph_adc;
+static int dtdc[NCH][2][MAXCH_TDC];
+static int dadc[NCH][2][MAXCH_QDC];
+static int daq_on;
+static int poolHandle = 0;
+static int ntics,dummy;
+// <- NTDCJ1 ->|<- NTDCJ2 ->
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+//static int tdcmap[NCH]= { 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7 ,99,99,99,99};
+//static int adcmap[NCH*2]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15, 99,99,99,99,
+ //99,99,99,9999,99,99,9999,99,99,9999,99,99,99,99, 99,99,99,99};
+static int adcmap[32]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,
+ 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31};
+
+
+//static int adcmap[16]={99,99,99,99,99,99,99,99, 0, 1, 2, 3, 4, 5, 6, 7};
+//static int adcmap[16]={ 0, 1, 2, 3, 4, 5,99, 7, 6,99,99,99,99,99,99,99};
+//static int adcmap[16]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15};
+/************************************************************/
+void wait_loop(unsigned long iloop)
+
+{
+ int i;
+
+ for (i=0;i<iloop;i++);
+ return;
+}
+
+int CVICALLBACK cb_timer (int panel, int control, int event, void *callbackData,
+ int eventData1, int eventData2)
+{
+ QueueUserEvent (9000, p1h, P1_TIMER);
+ return (0);
+}
+
+int update_plots (void)
+{
+ int irange, ch;
+
+ GetCtrlVal (p1h, P1_PLCH, &ch);
+
+ if (ph_tdc>0) DeleteGraphPlot (p1h, P1_TDC, ph_tdc, VAL_DELAYED_DRAW);
+ GetCtrlVal (p1h, P1_TDCHL, &irange);
+ ph_tdc = PlotY (p1h, P1_TDC, &dtdc[ch][irange], MAXCH_TDC, VAL_INTEGER,
+ VAL_VERTICAL_BAR, VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED);
+
+ if (ph_adc>0) DeleteGraphPlot (p1h, P1_ADC, ph_adc, VAL_DELAYED_DRAW);
+ GetCtrlVal (p1h, P1_ADCHL, &irange);
+ ph_adc = PlotY (p1h, P1_ADC, &dadc[ch][irange], MAXCH_QDC, VAL_INTEGER,
+ VAL_VERTICAL_BAR, VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_BLUE);
+ return (0);
+}
+
+int CVICALLBACK daq_run(void *functionData)
+{
+ int i,j;
+ int ndat,dtype,ch,rg,adc,cres;
+ unsigned long a,b,ec1,ec2;
+ unsigned long data[100], data2[100];
+ unsigned long aa[NCH][4];
+ unsigned long step_minutes, end_time_s, cur_time_s;
+ int start_hours, start_minutes, start_seconds;
+
+ unsigned short tdcneve;
+#ifdef USE_DAQ
+ unsigned long tdc_ev_c[NCH_TDC];
+#endif
+ int abstime, num_hits, tdcch;
+ int tdcbuff;
+
+ int dsave,status,fmax,fcount,fev;
+ int popupret;
+ char dfile[MAX_PATHNAME_LEN],dfile0[MAX_PATHNAME_LEN];
+ int supr0,tdcmin,fseed,esave;
+ float frac;
+ double fracg;
+ int dum;
+ unsigned short dum16;
+ unsigned long dum32;
+
+ FILE *fp;
+ #define RUNREC_ID 1
+ #define ENDREC_ID 2
+ #define POSREC_ID 3
+ #define EVTREC_ID 4
+
+ typedef struct {
+ unsigned long id,len;
+ unsigned long fver,time;
+ unsigned long nev,nch,ped,xy;
+ long nx,x0,dx,ny,y0,dy;
+ } RUNREC;
+ RUNREC runrec;
+
+ typedef struct {
+ unsigned long id,len;
+ unsigned long time;
+ } ENDREC;
+ ENDREC endrec;
+
+ typedef struct {
+ unsigned long id,len;
+ unsigned long time;
+ long ix,x,xset,iy,y,yset;
+ } POSREC;
+ POSREC posrec;
+
+ typedef struct {
+ unsigned long id,len;
+ unsigned long nev;
+ unsigned short data[NCH*2];
+ } EVTREC;
+ EVTREC evtrec;
+
+ runrec.id = RUNREC_ID;
+ runrec.len = sizeof(runrec);
+ runrec.fver = 0x10000;
+ runrec.nch = NCH;
+ GetCtrlVal(p1h, P1_ADCHLSAVE, &runrec.xy);//runrec.xy = 1;
+ endrec.id = ENDREC_ID;
+ endrec.len = sizeof(endrec);
+ posrec.id = POSREC_ID;
+ posrec.len = sizeof(posrec);
+ evtrec.id = EVTREC_ID;
+ evtrec.len = sizeof(evtrec);
+ /*
+ printf("<<<<<<<<<<<runrec.len %d\n",runrec.len);
+ printf("<<<<<<<<<<<endrec.len %d\n",endrec.len);
+ printf("<<<<<<<<<<<posrec.len %d\n",posrec.len);
+ printf("<<<<<<<<<<<evtrec.len %d\n",evtrec.len);
+ printf("<<<<<<<<<<<siye evtrec.len %d\n",sizeof(evtrec.len));
+ printf("<<<<<<<<<<<siye evtrec.id %d\n",sizeof(evtrec.id));
+ printf("<<<<<<<<<<<siye evtrec.nev %d\n",sizeof(evtrec.nev));
+ printf("<<<<<<<<<<<siye evtrec.data %d\n",sizeof(evtrec.data)); */
+ cres = 0;
+
+ GetCtrlVal (p1h, P1_NEVE, &runrec.nev);
+ GetCtrlVal (p1h, P1_PEDESTAL, &runrec.ped);
+
+ GetCtrlVal (p1h, P1_NX, &runrec.nx);
+ GetCtrlVal (p1h, P1_XSTEP, &runrec.dx);
+ GetCtrlVal (p1h, P1_XMIN, &runrec.x0);
+ GetCtrlVal (p1h, P1_NY, &runrec.ny);
+ GetCtrlVal (p1h, P1_YSTEP, &runrec.dy);
+ GetCtrlVal (p1h, P1_YMIN, &runrec.y0);
+
+ GetCtrlVal (p1h, P1_NMIN, &step_minutes);
+ GetSystemTime(&start_hours, &start_minutes, &start_seconds);
+ //cur_time_s = start_hours*3600 + start_minutes*60 + start_seconds;
+ time(&cur_time_s);
+ end_time_s = cur_time_s + step_minutes*60;
+ printf("START:%2d-%2d-%2d (cur_time = %u s, end_time = %u s)\n", start_hours, start_minutes, start_seconds, cur_time_s, end_time_s);
+
+ GetCtrlVal (p1h, P1_DSAVE, &dsave);
+ if (dsave) {
+ GetCtrlVal (p1h, P1_DFILE, dfile0);
+
+ fev=0;
+ fcount=1;
+ GetCtrlVal (p1h, P1_NEWF, &fmax);
+ fmax*=1000000;//fmax in Mega Bytes
+ }
+ GetCtrlVal (p1h, P1_SUPR, &supr0);
+ if (supr0) {
+ GetCtrlVal (p1h, P1_TDCMIN, &tdcmin);
+ GetCtrlVal (p1h, P1_FRAC, &frac);
+ }
+
+#ifdef USE_DAQ
+ #ifdef VADC_ADDR1
+ V965_map (VADC1, VADC_ADDR1, 1);
+ V965_init (VADC1, runrec.ped);
+ for(i=0;i<2*16;i++) {
+ dum16=0;
+ WIENVME_VME_A24D16_W(VADC_ADDR1 + 0x1080 + i*2, &dum16);
+ //printf("writing threshold to addr = 0x%X\n", 0x1080 + i*2);
+ }
+ #endif
+ #ifdef VADC_ADDR2
+ V965_map (VADC2, VADC_ADDR2, 1);
+ V965_init (VADC2, runrec.ped);
+ for(i=0;i<2*16;i++) {
+ dum16=0;
+ WIENVME_VME_A24D16_W(VADC_ADDR2 + 0x1080 + i*2, &dum16);
+ //printf("writing threshold to addr = 0x%X\n", 0x1080 + i*2);
+ }
+ #endif
+ #ifdef USE_CAEN_TDC
+ dum=0; WIENVME_VME_A24D16_W(TDC_ADDR+0x1016, &dum); Delay(0.01);
+
+
+ //pair(00)/trailing(01)/leading(10)/both(11) edge
+ dum=0x2200; V1290_writeOC(&dum);
+ GetCtrlVal (p1h, P1_TDC_EDGE, &dum);
+ V1290_writeOC(&dum);
+ #endif
+
+ #ifdef USE_CAMAC
+ BZ(&cres);
+ CAMAC_cccz(&cres);
+ CAMAC_cccc(&cres);
+ CREM_I(&cres);
+ //CSSA_R(NGL,0,25,&cres);
+#ifdef NPIO
+ //CAEN C 219 Progammable I/O
+ CSSA_R(NPIO, 0, 9, &dum);//init
+ //dum=6; //(OUTPUT, POSITIVE, NORMAL, TRANSPARENT)
+ dum=2; //(OUTPUT, NEGATIVE, NORMAL, TRANSPARENT)
+ CSSA_W(NPIO, 0, 17, &dum);
+ Delay(0.01);
+#endif
+ Delay(0.01);
+ #ifdef NTDCJ1
+ CSSA_R(NTDCJ1,0,9,&cres);
+ printf("CSSA_R(NTDCJ1,0,9,&cres)=0x%0x\n", cres);
+ CSSA_R(NTDCJ1,0,26,&cres);
+ CSSA_R(NTDCJ1,1,26,&cres);
+ printf("CSSA_R(NTDCJ1,0,26,&cres)=0x%0x\n", cres);
+ #endif
+ #ifdef NTDCJ2
+ CSSA_R(NTDCJ2,0,9,&cres);
+ printf("CSSA_R(NTDCJ2,0,9,&cres)=0x%0x\n", cres);
+ CSSA_R(NTDCJ2,0,26,&cres);
+ printf("CSSA_R(NTDCJ2,0,26,&cres)=0x%0x\n", cres);
+ #endif
+ #endif
+#endif
+
+ if (dsave) {
+ sprintf(dfile,"%s_file%02d.dat",dfile0,fcount);
+/*
+ // checks if file already exists and prompts user for action
+ if( fopen(dfile, "r") != NULL ) {
+ popupret = GenericMessagePopup("Warrning!", "File already exists!",
+ "New file", "Overwrite", "Cancel", 0, 1, 0,
+ VAL_GENERIC_POPUP_BTN1, VAL_GENERIC_POPUP_BTN1, VAL_GENERIC_POPUP_BTN3);
+
+ //printf("GenericMessagePopup return val = %d\n", popupret);
+ switch( popupret ) {
+ case 1: // "New file"
+ printf("last char = %c\n", dfile[strlen(dfile0)-1]);
+ break;
+ case 2: // "Overwrite"
+ break;
+ default: // "Cancel"
+ daq_on=0;
+ SetCtrlVal (p1h, P1_DAQ, daq_on);
+ return 0;
+
+
+ }
+ }
+*/
+ fp = fopen (dfile, "wb");
+ time (&runrec.time);
+ status = fwrite (&runrec, 1, runrec.len, fp);
+ }
+ if (supr0) {
+ fseed = runrec.time & 0x7fffffff;
+ Uniform (1, fseed, &fracg);
+ }
+
+
+ for (posrec.iy=0;posrec.iy<runrec.ny;posrec.iy++) {
+ posrec.yset=runrec.y0+posrec.iy*runrec.dy;
+#ifdef USE_MIKRO_Y
+// printf("MIKRO_MoveTo (2, y);%d\n",y);
+ MIKRO_MoveTo (MIKRO_Y, posrec.yset);
+// printf("->MIKRO_MoveTo (2, y);%d\n",y);
+#endif
+
+ SetCtrlVal (p1h, P1_Y, posrec.yset);
+ SetCtrlVal (p1h, P1_IY, posrec.iy);
+
+
+ for (posrec.ix=0;posrec.ix<runrec.nx;posrec.ix++) {
+ posrec.xset=runrec.x0+posrec.ix*runrec.dx;
+#ifdef USE_MIKRO
+ // printf("MIKRO_MoveTo (1, x);%d\n",x);
+ MIKRO_MoveTo (MIKRO_X, posrec.xset);
+ // printf("->MIKRO_MoveTo (1, x);%d\n",x);
+#endif
+
+ SetCtrlVal (p1h, P1_X, posrec.xset);
+ SetCtrlVal (p1h, P1_IX, posrec.ix);
+
+
+ if (dsave) {
+ /*if (fmax && (ftell(fp) > fmax)) {
+ fcount+=1;
+ sprintf(dfile,"%s_file%02d.dat",dfile0,fcount);
+ fclose(fp);
+ fp = fopen (dfile, "wb");
+ } */
+
+ time (&posrec.time);
+ status = fwrite (&posrec, 1, posrec.len, fp);
+ }
+
+// clear the plots
+ for (j=0;j<NCH;j++) {
+ for (i=0;i<MAXCH_TDC;i++){
+ dtdc[j][0][i]=0;
+ dtdc[j][1][i]=0;
+ }
+ for (i=0;i<MAXCH_QDC;i++){
+ dadc[j][0][i]=0;
+ dadc[j][1][i]=0;
+ }
+ }
+
+ evtrec.nev=1;
+ do {
+ for (j=0;j<NCH;j++)
+ for (i=0;i<4;i++)
+ aa[j][i]=0;
+// if((neve%1000)==0) printf("Events %ld\n",neve);
+
+#ifdef USE_DAQ
+ ndat = 0;
+# ifdef VADC_ADDR1
+ ndat=V965_clear(VADC1);
+# endif
+# ifdef VADC_ADDR2
+ ndat=V965_clear(VADC2);
+# endif
+# ifdef USE_CAMAC
+ wait_loop(IWAIT);
+# ifdef NTDCJ1
+ CSSA_R(NTDCJ1,0,9,&cres);
+# endif
+# ifdef NTDCJ2
+ CSSA_R(NTDCJ2,0,9,&cres);
+# endif
+ #ifdef USE_CAEN_TDC
+ dum=0; WIENVME_VME_A24D16_W(TDC_ADDR+0x1016, &dum); //Delay(0.01);
+ #endif
+
+// Delay(0.001);
+ wait_loop(IWAIT);
+ //CSSA_R(NGL,0,10,&cres);
+
+
+
+# ifdef NPIO
+ dum=0x0;
+ CSSA_W(NPIO, 0, 16, &dum);
+ //printf("PIO VETO OFF\n");
+# endif
+# endif
+
+ // Waiting for LAM
+
+ ntics=0;
+
+
+ //while( (!(V965_status(VADC1)&0x1)) && (ntics<2) && daq_on );
+
+ /*
+ //tdcbuff=1;
+ #ifdef USE_CAEN_TDC
+ //dum=0x0; PCIWIENVME_VME_read16(hHandle24, 1, TDC_ADDR+0x1002, &dum);//Status Word
+ do {
+ dum16=0x0; WIENVME_VME_A24D16_R(TDC_ADDR+0x1002, &dum16); Delay(0.01);
+ //printf("tdc [%d] dum16 = %d | dum & 0x1 = %d | daq_on = %d\n", evtrec.nev, dum16, dum16 & 0x1, daq_on);
+ //tdcbuff=dum16 & 0x1;//LAM = last bit
+ } while( (!(dum16 & 0x1)) && daq_on );
+
+
+ #endif
+ do {
+ //dum16=0x0; WIENVME_VME_A24D16_R(VADC_ADDR1+0x100E, &dum16); Delay(0.01);
+ //printf("adc [%d] dum16 = %d | dum & 0x1 = %d | VADC_ADDR1 = %x\n", evtrec.nev, dum16, dum16 & 0x1, VADC_ADDR1);
+ }while( (!(V965_status(VADC1)&0x1)) && daq_on );
+ */
+ //kobayashi
+
+ int tdc_lam, adc_lam;
+#ifdef USE_CAEN_TDC
+ tdc_lam = 0;
+#else
+ tdc_lam = 1;
+#endif
+#ifdef VADC_ADDR1
+ adc_lam = 0;
+#else
+ adc_lam = 1;
+#endif
+
+ //printf(">>>> LAM: ");
+#ifdef USE_CAEN_TDC
+ do {
+ dum16=0x0; WIENVME_VME_A24D16_R(TDC_ADDR+0x1002, &dum16); //Delay(0.01);
+ tdc_lam = dum16 & 0x1;
+ } while( (!tdc_lam) && daq_on );
+ //printf("tdc_lam = %d | ", tdc_lam);
+#endif
+#ifdef VADC_ADDR1
+ do {
+ adc_lam = V965_status(VADC1)&0x1;
+ } while( (!adc_lam) && daq_on );
+ //printf("adc_lam = %d", adc_lam);
+#endif
+ //printf("\n");
+
+
+# ifdef NPIO
+ dum=0x1;
+ CSSA_W(NPIO, 0, 16, &dum);
+ //printf("PIO VETO ON\n");
+# endif
+
+ wait_loop(2000);
+ if (!daq_on) break;
+
+ if (ntics>=2) {
+# ifdef VADC_ADDR1
+ ndat=V965_read (VADC1, &data[0]);
+# endif
+# ifdef VADC_ADDR2
+ ndat=V965_read (VADC2, &data2[0]);
+# endif
+
+ if(step_minutes > 0) {
+ GetSystemTime(&start_hours, &start_minutes, &start_seconds);
+ //cur_time_s = start_hours*3600 + start_minutes*60 + start_seconds;
+ time(&cur_time_s);
+ if(cur_time_s >= end_time_s) {
+ end_time_s = cur_time_s + step_minutes*60;
+ printf("STEP (lam):%2d-%2d-%2d @ %d\n", start_hours, start_minutes, start_seconds, posrec.xset);
+ break;
+ }
+ }
+
+ continue;
+ }
+
+ for (i=0; i<NCH; i++) {
+ adc=0;
+ wait_loop(IWAIT);
+# ifdef USE_CAMAC
+# ifdef NTDCJ1
+ if(i<8) {
+ CSSA_R(NTDCJ1,tdcmap[i],0,&adc);
+ //printf("TDC=0x%04X\n",adc);
+ adc=adc&0xfff;
+ aa[i][0]=adc;
+ dtdc[i][0][adc]+=1;
+ }
+# endif
+# ifdef NTDCJ2
+ if(8<=i && i<16) {
+ CSSA_R(NTDCJ2,tdcmap[i],0,&adc);
+ //printf("TDC=0x%04X\n",adc);
+ adc=adc&0xfff;
+ //offset for channel mapping (0-9 = MCPPMT5, 0-7 = tdc, 8,9=adc only)
+ aa[i+2][0]=adc;
+ dtdc[i+2][0][adc]+=1;
+ }
+# endif
+# endif
+ }
+
+
+ // TDC
+ #ifdef USE_CAEN_TDC
+
+ int dbg_tdc_t = 0;
+ int dbg_tdc_f = 0;
+ FILE *fpout=NULL;
+ if(dbg_tdc_f) fpout=fopen("TDCout.txt", "at");
+
+
+
+ //number of events
+ //tdcneve=0; PCIWIENVME_VME_read16(hHandle24, 1, TDC_ADDR+0x1020, &tdcneve);
+ tdcneve=0; WIENVME_VME_A24D16_R(TDC_ADDR+0x1020, &tdcneve);
+ unsigned long triggneve=0; WIENVME_VME_A24D32_R(TDC_ADDR+0x101C, &triggneve);
+ if(dbg_tdc_t) printf("\n [%d] tdcneve = %u | triggneve = %u\n", evtrec.nev, tdcneve, triggneve);
+ if(dbg_tdc_f) fprintf(fpout, "\n [%d] tdcneve = %u | triggneve = %u\n", evtrec.nev, tdcneve, triggneve);
+
+ int tdcchhit[32];
+
+ unsigned short l=0;
+ for (i=0;i<NCH_TDC;i++)
+ tdc_ev_c[i]=0;
+ while(l < tdcneve)
+ {
+ //dum=0x0; PCIWIENVME_VME_read32(hHandle24, 1, TDC_ADDR+0x0, &dum);//read
+ dum32=0x0; WIENVME_VME_A24D32_R(TDC_ADDR+0x0, &dum32);
+
+ if(dbg_tdc_t) printf(">>>>>>>>>>>>> l = %d | %x\n", l, dum32);
+ if(dbg_tdc_f) fprintf(fpout, ">>>>>>>>>>>>> l = %d | %x\n", l, dum32);
+
+ switch(dum32 & 0xf8000000)
+ {
+ case 0x40000000://01000 = Global Header
+ for (int k=0;k<32;k++) tdcchhit[k]=0;
+ if(dbg_tdc_t) printf(">>> GLOBAL HEADER | event count = %d\n", (dum32 & 0x7FFFFFF) >> 5);
+ if(dbg_tdc_f) fprintf(fpout, ">>> GLOBAL HEADER | event count = %d\n", (dum32 & 0x7FFFFFF) >> 5);
+ break;
+ case 0x8000000://00001 = TDC Header
+ if(dbg_tdc_t) printf(">>> TDC HEADER | Event ID =%d | Bunch ID = %d\n", (dum32 & 0xFFFFFF) >> 12, (dum32 & 0xFFF));
+ if(dbg_tdc_f) fprintf(fpout, ">>> TDC HEADER | Event ID =%d | Bunch ID = %d\n", (dum32 & 0xFFFFFF) >> 12, (dum32 & 0xFFF));
+ break;
+ case 0x00000000://00000 = TDC Measurement
+ if(dbg_tdc_t) printf(">>> TDC Measurement !!!!!!!! >>> CH = %d | edge = %d | ev = %d\n", (dum32 & 0x3FFFFFF) >> 21, (dum32 & 0x7FFFFFF) >> 26, dum32 & 0x1FFFFF);
+ if(dbg_tdc_f) fprintf(fpout, ">>> TDC Measurement !!!!!!!! >>> CH = %d | edge = %d | ev = %d\n", (dum32 & 0x3FFFFFF) >> 21, (dum32 & 0x7FFFFFF) >> 26, dum32 & 0x1FFFFF);
+
+ //TDC Channel = 0000 0x<...Channel...>x 20*x
+ tdcch = tdcmap[(dum32 & 0x3FFFFFF) >> 21];
+
+
+ //TDC Measurement = 0000 0xxx xxx<...TDC...>
+ unsigned long tdc_ev = dum32 & 0x1FFFFF;
+
+ int tdc_edge = (dum32 & 0x1) >> 26;
+
+ /*
+ adc = (int)(tdc_ev/4.0); // 21 bit -> 16 bit ???
+ int adcs = (int)(adc/16.0);
+ */
+ /*
+ int tdc_ev_offset = 31000;
+ adc = tdc_ev - tdc_ev_offset;
+ int adcs = 0;
+ if(0 < adc) adcs = adc;
+ if(4095 < adc) adcs = 4095;
+ */
+
+ if(dbg_tdc_t) printf(">>> tdcch = %d | tdc_ev = %d | raw = %d\n", tdcch, tdc_ev, dum32);
+ if(dbg_tdc_f) fprintf(fpout, ">>> tdcch = %d | tdc_ev = %d | raw = %d\n", tdcch, tdc_ev, dum32);
+
+ if(l==0)
+ if(tdcchhit[tdcch]==0)
+ if(tdc_edge==0) {
+ if(tdcch < NCH_TDC) {
+ aa[tdcch][0]=tdc_ev;
+ if(tdcch < MAXCH_TDC) {
+ dtdc[tdcch][0][tdc_ev]+=1;
+ }
+ }
+ }
+ tdcchhit[tdcch]=1;
+
+ break;
+ case 0x18000000://00011 = TDC Trailer
+ if(dbg_tdc_t) printf(">>> TDC Trailer | Event ID =%d\n", (dum32 & 0xFFFFFF) >> 12);
+ if(dbg_tdc_f) fprintf(fpout, ">>> TDC Trailer | Event ID =%d\n", (dum32 & 0xFFFFFF) >> 12);
+ break;
+ case 0x20000000://00100 = TDC Error
+ if(dbg_tdc_t) printf(">>> TDC Error = %d\n", dum32 & 0x7FFF);
+ if(dbg_tdc_f) fprintf(fpout, ">>> TDC Error = %d\n", dum32 & 0x7FFF);
+ break;
+ case 0x88000000://10001 = Extended Trigger Time Tag
+ if(dbg_tdc_t) printf(">>> Extended Trigger Time Tag \n");
+ if(dbg_tdc_f) fprintf(fpout, ">>> Extended Trigger Time Tag \n");
+ break;
+ case 0xC0000000://11000 = Filler
+ if(dbg_tdc_t) printf(">>> Filler \n");
+ if(dbg_tdc_f) fprintf(fpout, ">>> Filler \n");
+ break;
+ case 0x80000000://10000 = The Trailer
+ num_hits=((dum32 & 0x1FFFFF) >> 5) - 2;
+ l++;
+ if(dbg_tdc_t) printf(">>> The Trailer | status bits: %d%d%d | num_hits = %d\n", (dum32 >> 26) % 0x1, (dum32 >> 25) % 0x1, (dum32 >> 24) % 0x1, num_hits);
+ if(dbg_tdc_f) fprintf(fpout, ">>> The Trailer | num_hits = %d\n", num_hits);
+ break;
+ /*
+ case 0x00000000://00000 = TDC Measurement
+ //TDC Channel = 0000 0x<...Channel...>x 20*x
+ tdcch = tdcmap[(dum32 & 0x3FFFFFF) >> 21];
+ //TDC Measurement = 0000 0xxx xxx<...TDC...>
+ tdc_ev = dum32 & 0x1FFFFF;
+ if((tdcch < NCH_TDC)&&(tdc_ev < MAXCH_TDC)&&(tdc_ev_c[tdcch] < EVMAX))
+ {
+ dtdc[tdcch][tdc_ev_c[tdcch]][tdc_ev]++;
+ //atdc[tdcch][tdc_ev_c[tdcch]++] = tdc_ev;
+ }
+
+ //#define CH_TRG 0
+ //#define CH_SIPM 1
+ //#define CH_PMT 2
+
+ //for(i=1;i<NCH_TDC;i++)
+ // if(tdc_ev_c[CH_TRG] && tdc_ev_c[i])
+ // {
+ // abstime=atdc[i][tdc_ev_c[i]-1] - atdc[CH_TRG][tdc_ev_c[CH_TRG]-1] + 30000;
+ // if((0 <= abstime) && (abstime < MAXCH_TDC))
+ // dtdc2[i][tdc_ev_c[i]-1][abstime]++;
+ // }
+
+ break;
+ case 0x80000000://10000 = Global Trailer
+ //Word Count = bit 31...21< Word Count: 20 ... 5 > 4...0
+ num_hits=((dum32 & 0x1FFFFF) >> 5) - 2;
+ l++;
+ break;
+ case 0xC0000000://11000 = Filler
+ l=tdcneve;//exit while loop
+ break; */
+ default:
+ break;
+ }
+ }
+
+ if(dbg_tdc_f) fclose(fpout);
+ #endif
+
+# ifdef VADC_ADDR1
+ ndat=V965_read (VADC1, &data[0]);
+ //printf("<<<<<ndat %d\n",ndat);
+ for (i=0; i<ndat; i++) {
+ dtype=(data[i]>>25)&0x3;
+ if (dtype==0) {
+ ch=adcmap[(data[i]>>17)&0xf];
+ if (ch<NCH) {
+ rg=(data[i]>>16)&0x1;
+ adc=data[i]&0xfff;
+ aa[ch][rg+2]=adc;
+ dadc[ch][rg][adc]+=1;
+ //printf("<<<<<ch %d rg %d adc %d map %d\n",ch,rg,adc, (data[i]>>17)&0xf);
+ }
+ }
+ }
+ //printf("VADC_ADDR1 READ\n");
+# endif
+ // printf("======================================\n");
+# ifdef VADC_ADDR2
+ ndat=V965_read (VADC2, &data2[0]);
+ for (i=0; i<ndat; i++) {
+ dtype=(data2[i]>>25)&0x3;
+ if (dtype==0) {
+ ch=adcmap[NCH + ((data2[i]>>17)&0xf)];
+
+ //printf("ADCCH = %2d , adcmap[ADCCH] = %2d , ADC = %d\n", NCH + ((data2[i]>>17)&0xf), ch, data2[i]&0xfff);
+
+ if (ch<NCH) {
+ rg=(data2[i]>>16)&0x1;
+ adc=data2[i]&0xfff;
+ aa[ch][rg+2]=adc;
+ dadc[ch][rg][adc]+=1;
+ }
+ }
+ }
+# endif
+
+#else /* generate test data */
+ if (!daq_on) break;
+ for (i=0;i<NCH;i++) {
+ adc=100+evtrec.nev%200;
+ dtdc[i][1][adc]+=1;
+ dadc[i][1][adc]+=1;
+ aa[i][0]=adc;
+ aa[i][2]=adc;
+ adc=200+evtrec.nev%400;
+ dtdc[i][0][adc]+=1;
+ dadc[i][0][adc]+=1;
+ aa[i][1]=adc;
+ aa[i][3]=adc;
+ }
+#endif
+ esave=dsave;
+ if (supr0 && esave) {
+ Uniform (1, -1, &fracg);
+ if (fracg > frac) {
+ esave=0;
+ for (i=0;i<NCH;i++) {
+ if (aa[i][0] >= tdcmin) esave=1;
+ }
+ }
+ }
+ if (esave) {
+// time (&evtrec.time);
+ //GetCtrlVal(p1h, P1_ADCHLSAVE, &runrec.xy);
+ for (i=0;i<NCH;i++) {
+ evtrec.data[i] = aa[i][0]; //TDC
+ //printf(">>> TDC Measurement !!!!!!!! >>> CH = %d | ev = %d\n", i, evtrec.data[i]);
+ //if(i==0)
+ // evtrec.data[i+NCH] = aa[i][2]; //ADC High Range = 2 , low = 3
+ //else
+ evtrec.data[i+NCH] = aa[i][2]; //ADC High Range = 2 , low = 3
+// printf(">>> ADC Measurement !!!!!!!! >>> CH = %d | ev = %d \n", i, evtrec.data[i+NCH]);
+ //printf("<<<<<<<<<<<evtrec.len %d\n",evtrec.len);
+ }
+ status = fwrite (&evtrec, 1, evtrec.len, fp);
+ }
+
+ //if (!(evtrec.nev%1000))
+ SetCtrlVal (p1h, P1_CEVE, evtrec.nev);
+
+ if (dsave&&(!(evtrec.nev%1000))) {
+ if (fmax && (ftell(fp) > fmax)) {
+ time (&endrec.time);
+ status = fwrite (&endrec, 1, endrec.len, fp);
+ fcount+=1;
+ sprintf(dfile,"%s_file%02d.dat",dfile0,fcount);
+ fclose(fp);
+ fp = fopen (dfile, "wb");
+ printf(" Opened file %s\n", dfile);
+ }
+ }
+
+ if(step_minutes > 0) {
+ GetSystemTime(&start_hours, &start_minutes, &start_seconds);
+ //cur_time_s = start_hours*3600 + start_minutes*60 + start_seconds;
+ time(&cur_time_s);
+ if(cur_time_s >= end_time_s) {
+ end_time_s = cur_time_s + step_minutes*60;
+ printf("STEP (nev):%2d-%2d-%2d @ %d\n", start_hours, start_minutes, start_seconds, posrec.xset);
+ break;
+ }
+ }
+
+
+ } while (evtrec.nev++<runrec.nev);
+ if (!daq_on) break;
+ }
+ if (!daq_on) break;
+ }
+
+ if (dsave) {
+ time (&endrec.time);
+ status = fwrite (&endrec, 1, endrec.len, fp);
+ fclose(fp);
+ }
+
+ daq_on=0;
+ SetCtrlVal (p1h, P1_DAQ, daq_on);
+ SetCtrlVal (p1h, P1_CEVE, evtrec.nev);
+
+ return 0;
+}
+
+//=================================================================================
+//=================================================================================
+//=================================================================================
+
+int __stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
+ LPSTR lpszCmdLine, int nCmdShow)
+{
+ int i,j,status,refon;
+ long int xpos, ypos, zpos;
+ char dfile[300];
+ FILE *fp;
+ int dum;
+ unsigned short dum16;
+
+ typedef struct {
+ unsigned long id,len;
+ unsigned long fver,time;
+ unsigned long nev,nch,ped,xy;
+ long nx,x0,dx,ny,y0,dy;
+ } RUNREC;
+ RUNREC runrec;
+
+ if (InitCVIRTE (hInstance, 0, 0) == 0)
+ return -1; /* out of memory */
+
+ SetSleepPolicy(VAL_SLEEP_MORE);
+ CmtNewThreadPool (MAX_THREADS, &poolHandle);
+
+ SetStdioWindowOptions (1000, 0, 0);
+ //SetStdioWindowSize (150, 600);
+ //SetStdioWindowPosition (825, 250);
+ SetStdioWindowSize (900, 600);
+ //SetStdioWindowPosition (20, 800);
+ SetStdioWindowPosition (20, 1100);
+
+#ifdef USE_DAQ
+ WIENVME_VME_START(NULL);
+#endif
+
+#ifdef USE_CAEN_TDC
+ V1290_init();
+#endif
+
+#ifdef USE_MIKRO
+ MIKRO_Open (MIKRO_COM);
+ MIKRO_Init (MIKRO_X,0);
+#ifdef USE_MIKRO_Y
+ MIKRO_Init (MIKRO_Y,0);
+#endif
+#ifdef USE_MIKRO_Z
+ MIKRO_Init (MIKRO_Z,0);
+#endif
+#endif
+
+ if ((p1h = LoadPanel (0, "l2d_ui.uir", P1)) < 0) return -1;
+ DisplayPanel (p1h);
+ SetCtrlAttribute (p1h, P1_PLCH, ATTR_MAX_VALUE, NCH-1);
+
+ GetCtrlVal(p1h, P1_ADCHLSAVE, &runrec.xy);
+ SetCtrlVal(p1h, P1_ADCHL, runrec.xy-2);
+
+ QueueUserEvent (1000, p1h, P1_RESET);
+
+ do {
+ GetUserEvent (1, &pID, &rID);
+ switch (rID) {
+ case P1_TIMER:
+ ntics+=1;
+ GetCtrlVal (p1h, P1_REFON, &refon);
+ if (refon) update_plots();
+ break;
+ case P1_REFRESH:
+ update_plots();
+ break;
+ case P1_DAQ:
+ GetCtrlVal (p1h, P1_DAQ, &daq_on);
+ if (daq_on) {
+ CmtScheduleThreadPoolFunction (poolHandle, daq_run, (void *)&dummy, &tfID);
+ } else {
+ CmtWaitForThreadPoolFunctionCompletion (poolHandle, tfID,
+ OPT_TP_PROCESS_EVENTS_WHILE_WAITING);
+ CmtReleaseThreadPoolFunctionID (poolHandle, tfID);
+# ifdef NPIO
+ dum=0x0;
+ CSSA_W(NPIO, 0, 16, &dum);
+ //printf("PIO VETO OFF\n");
+# endif
+ }
+ break;
+ case P1_ZSET:
+ if (!daq_on) {
+ GetCtrlVal (p1h, P1_ZSET, &zpos);
+#ifdef USE_MIKRO_Z
+ MIKRO_MoveTo (MIKRO_Z, zpos);
+#endif
+ }
+ break;
+ case P1_REREAD:
+ if (!daq_on) {
+ status = FileSelectPopup ("", "*.dat", ".dat",
+ "Izberi datoteko s podatki",
+ VAL_LOAD_BUTTON, 0, 0, 1, 0, dfile);
+ if (status==1) {
+ fp = fopen (dfile, "rb");
+ status = fread (&runrec, 1, sizeof(runrec), fp);
+ fclose(fp);
+ if (runrec.id==1) {
+ SetCtrlVal (p1h, P1_NX, runrec.nx);
+ SetCtrlVal (p1h, P1_XSTEP, runrec.dx);
+ SetCtrlVal (p1h, P1_XMIN, runrec.x0);
+ SetCtrlVal (p1h, P1_NY, runrec.ny);
+ SetCtrlVal (p1h, P1_YSTEP, runrec.dy);
+ SetCtrlVal (p1h, P1_YMIN, runrec.y0);
+ SetCtrlVal (p1h, P1_NEVE, runrec.nev);
+ }
+ }
+ }
+ break;
+ case P1_MGET:
+ #ifdef USE_MIKRO
+ MIKRO_GetPosition(MIKRO_X,&xpos);
+ Delay(0.01);
+ SetCtrlVal (p1h, P1_X, xpos);
+ #ifdef USE_MIKRO_Y
+ MIKRO_GetPosition(MIKRO_Y,&ypos);
+ Delay(0.01);
+ SetCtrlVal (p1h, P1_Y, ypos);
+ #endif
+ #ifdef USE_MIKRO_Z
+ MIKRO_GetPosition(MIKRO_Z,&zpos);
+ Delay(0.01);
+ SetCtrlVal (p1h, P1_Z, zpos);
+ #endif
+ #endif
+ break;
+ case P1_HO:
+ if (!daq_on) {
+ SetWaitCursor (1);
+#ifdef USE_MIKRO
+ MIKRO_ReferenceMove (MIKRO_X);
+ #ifdef USE_MIKRO_Y
+ MIKRO_ReferenceMove (MIKRO_Y);
+ #endif
+ #ifdef USE_MIKRO_Z
+ MIKRO_ReferenceMove (MIKRO_Z);
+ #endif
+#endif
+ SetWaitCursor (0);
+ }
+ break;
+ case P1_RESET:
+ for (j=0;j<NCH;j++) {
+ for (i=0;i<MAXCH_TDC;i++){
+ dtdc[j][0][i]=0;
+ dtdc[j][1][i]=0;
+ }
+ for (i=0;i<MAXCH_QDC;i++){
+ dadc[j][0][i]=0;
+ dadc[j][1][i]=0;
+ }
+ }
+ update_plots();
+ break;
+ case P1_TDCLOG:
+ GetCtrlVal (p1h, P1_TDCLOG, &status);
+ SetCtrlAttribute (p1h, P1_TDC, ATTR_YMAP_MODE, status);
+ update_plots();
+ break;
+ case P1_ADCLOG:
+ GetCtrlVal (p1h, P1_ADCLOG, &status);
+ SetCtrlAttribute (p1h, P1_ADC, ATTR_YMAP_MODE, status);
+ update_plots();
+ break;
+ case P1_PIO_ON:
+# ifdef NPIO
+ dum=0x1;
+ CSSA_W(NPIO, 0, 16, &dum);
+ printf("PIO VETO ON\n");
+# endif
+ break;
+ case P1_PIO_OFF:
+# ifdef NPIO
+ dum=0x0;
+ CSSA_W(NPIO, 0, 16, &dum);
+ printf("PIO VETO OFF\n");
+# endif
+ break;
+ case P1_TDCCLEAR:
+ #ifdef USE_CAEN_TDC
+ dum16=0x0; WIENVME_VME_A24D16_W(TDC_ADDR+0x1014, &dum16); Delay(0.1);
+ dum16=0x0; WIENVME_VME_A24D16_W(TDC_ADDR+0x1016, &dum16); Delay(0.1);
+ dum16=0x0; WIENVME_VME_A24D16_W(TDC_ADDR+0x1018, &dum16); Delay(0.1);
+ #endif
+ break;
+ case P1_TDCMIKRO:
+ #ifdef USE_CAEN_TDC
+ dum=0x0000; WIENVME_VME_A24D16_R(TDC_ADDR + 0x1030, &dum); Delay(0.01); printf("Micro handshake = %x\n", dum);
+ #endif
+ break;
+ case P1_TDCINIT:
+
+ #ifdef USE_CAEN_TDC
+ //V1290_init() ;
+
+ ////Maximum number of hits per event
+ printf("V1290_writeOC(0x3300)\n");
+ dum=0x3300; V1290_writeOC(&dum); Delay(0.1);
+ //dum=0x0001; V1290_writeOC(&dum); Delay(0.1);
+ printf("V1290_writeOC(0x1000)\n");
+ dum=0x1000; V1290_writeOC(&dum); Delay(0.1);
+ printf("V1290_writeOC(0x3400)\n");
+ dum=0x3400; V1290_writeOC(&dum); Delay(0.1);
+ dum=0x0;
+ printf("V1290_readOC()\n");
+ if(V1290_readOC(&dum) == -1)
+ printf("V1290_readOC timeout!!!\n");
+ else {
+ Delay(0.1);
+ printf("TDC Maximum number of hits per event = %d\n", dum);
+ }
+
+ #endif
+ break;
+ case P1_TDCTEST:
+
+ #ifdef USE_CAEN_TDC
+ /*
+ for (i=0x4000;i<0x4050;i+=4) {
+ dum=0;
+ WIENVME_VME_A24D16_R(TDC_ADDR+i, &dum);
+ printf("0x%04X -> 0x%04X\n",i,dum);
+ }
+ for (i=0x4080;i<0x4088;i+=4) {
+ dum=0;
+ WIENVME_VME_A24D16_R(TDC_ADDR+i, &dum);
+ printf("0x%04X -> 0x%04X\n",i,dum);
+ }
+ dum=0;i=0x1026;
+ WIENVME_VME_A24D16_R(TDC_ADDR+i, &dum);
+ printf("0x%04X -> 0x%04X\n",i,dum);
+
+
+ dum=0x0200; V1290_writeOC(&dum);
+ dum=0x0; V1290_readOC(&dum); printf("dum = %04X\n", dum&0xFFFF);
+ */
+
+ dum=0x4500; V1290_writeOC(&dum);
+ dum=0x0; V1290_readOC(&dum); printf("Ch Enable 1 = %04X\n", dum&0xFFFF);
+ dum=0x0; V1290_readOC(&dum); printf("Ch Enable 2 = %04X\n", dum&0xFFFF);
+
+
+ dum=0x1600; V1290_writeOC(&dum);
+ dum=0x0000; V1290_readOC(&dum); printf("Match window Width = %d\n", dum&0xFFFF);
+ dum=0x0000; V1290_readOC(&dum); printf("Window Offset = %d\n", dum&0xFFFF);
+ dum=0x0000; V1290_readOC(&dum); printf("Extra Search Window = %d\n", dum&0xFFFF);
+ dum=0x0000; V1290_readOC(&dum); printf("Reject Margin = %d\n", dum&0xFFFF);
+ dum=0x0000; V1290_readOC(&dum); printf("Trigger Subtraction = %d\n", dum&0xFFFF);
+
+
+ dum=0x3400; V1290_writeOC(&dum);
+ dum=0x0000; V1290_readOC(&dum); printf("TDC Maximum number of hits per event = %d\n", dum);
+
+
+ /*
+ // test
+
+ dum16=0x0; WIENVME_VME_A24D16_R(TDC_ADDR+0x1026, &dum16); Delay(0.1);
+ printf("WIENVME_VME_A24D16_R(TDC_ADDR+0x1026, dum16) -> %d\n", dum16);
+
+ //dum=0x20; WIENVME_VME_A24D16_W(TDC_ADDR+0x1000, &dum); Delay(0.1);
+
+ dum=0x0; WIENVME_VME_A24D16_R(TDC_ADDR+0x1000, &dum); Delay(0.1);
+ printf("WIENVME_VME_A24D16_R(TDC_ADDR+0x1000, dum) -> %d\n", dum);
+
+ dum=0x0; WIENVME_VME_A24D16_R(TDC_ADDR+0x1002, &dum); Delay(0.1);
+ printf("WIENVME_VME_A24D16_R(TDC_ADDR+0x1002, dum) -> %d\n", dum);
+
+ int tdcneve=0; WIENVME_VME_A24D16_R(TDC_ADDR+0x1020, &tdcneve);
+ unsigned long triggneve=0; WIENVME_VME_A24D32_R(TDC_ADDR+0x101C, &triggneve);
+ printf("tdcneve = %d | triggneve = %u\n", tdcneve, triggneve);
+
+ dum=0x4500; V1290_writeOC(&dum);
+ dum=0x0; V1290_readOC(&dum); printf("Channel enable mask word 1 = %x\n", dum);
+ dum=0x0; V1290_readOC(&dum); printf("Channel enable mask word 2 = %x\n", dum);
+
+ //dum=0x4500; WIENVME_VME_A24D16_W(TDC_ADDR+0x102E, &dum); Delay(0.1);
+ //dum=0x0000; WIENVME_VME_A24D16_R(TDC_ADDR+0x102E, &dum); Delay(0.1); printf("Channel enable mask word 1 = %x\n", dum);
+ //dum=0x0000; WIENVME_VME_A24D16_R(TDC_ADDR+0x102E, &dum); Delay(0.1); printf("Channel enable mask word 2 = %x\n", dum);
+
+ */
+
+ //dum16=0x0; WIENVME_VME_A24D16_R(VADC_ADDR1+0x1000, &dum16); Delay(0.1);
+ //printf("WIENVME_VME_A24D16_R(VADC_ADDR1+0x1000, dum16) -> %x\n", dum16);
+ /*
+ dum=0xC200; V1290_writeOC(&dum); printf("V1290_writeOC(&dum) -> %d\n", dum);
+ dum=0x0; V1290_readOC(&dum); printf("1. V1290_readOC(&dum) -> %d\n", dum);
+ dum=0x0; V1290_readOC(&dum); printf("2. V1290_readOC(&dum) -> %d\n", dum);
+ dum=0x0; V1290_readOC(&dum); printf("3. V1290_readOC(&dum) -> %d\n", dum);
+ dum=0x0; V1290_readOC(&dum); printf("4. V1290_readOC(&dum) -> %d\n", dum);
+
+ dum16=0xC200; WIENVME_VME_A24D16_W(TDC_ADDR+0xC200, &dum16); Delay(0.1);
+ printf("WIENVME_VME_A24D16_W(TDC_ADDR+0xC200, dum) -> %x\n", dum16);
+ dum16=0x0; WIENVME_VME_A24D16_R(TDC_ADDR+0xC200, &dum16); Delay(0.1);
+ printf("1. WIENVME_VME_A24D16_R(TDC_ADDR+0xC200, dum) -> %x\n", dum16);
+ dum16=0x0; WIENVME_VME_A24D16_R(TDC_ADDR+0xC200, &dum16); Delay(0.1);
+ printf("2. WIENVME_VME_A24D16_R(TDC_ADDR+0xC200, dum16) -> %x\n", dum16);
+ dum16=0x0; WIENVME_VME_A24D16_R(TDC_ADDR+0xC200, &dum16); Delay(0.1);
+ printf("3. WIENVME_VME_A24D16_R(TDC_ADDR+0xC200, dum16) -> %x\n", dum16);
+ dum16=0x0; WIENVME_VME_A24D16_R(TDC_ADDR+0xC200, &dum16); Delay(0.1);
+ printf("4. WIENVME_VME_A24D16_R(TDC_ADDR+0xC200, dum16) -> %x\n", dum16); */
+
+ #endif
+ break;
+#ifdef USE_EASIROC
+ case P1_ESRC_INIT:
+ easiroc_Init(erIpAddr, erDAQmode);
+ break;
+
+ case P1_ESRC_F1:
+ easiroc_fTransmitSC();
+ break;
+
+ case P1_ESRC_F2:
+ easiroc_fTransmitReadSC();
+ break;
+
+ case P1_ESRC_F3:
+ easiroc_fAsicInitialize();
+ break;
+
+ case P1_ESRC_F4:
+ int transmitProbeCh = 0;
+ GetCtrlVal (p1h, P1_ESRC_PROBE_CH, &transmitProbeCh);
+ int transmitProbeType = 0;
+ GetCtrlVal (p1h, P1_ESRC_PROBE_TYPE, &transmitProbeType);
+
+ printf("transmitProbeCh = %d | transmitProbeType = %d\n", transmitProbeCh, transmitProbeType);
+ if(easiroc_fTransmitProbe(transmitProbeCh, transmitProbeType) == 0)
+ printf("\nTransmit Probe SUCESS\n");
+ break;
+
+ case P1_ESRC_DAQ:
+ char esrcDaqFile[256];
+ GetCtrlVal (p1h, P1_DFILE, esrcDaqFile);
+ int esrcDaqNeve = 0;
+ GetCtrlVal (p1h, P1_NEVE, &esrcDaqNeve);
+
+ if(easiroc_fDAQ(esrcDaqFile, esrcDaqNeve) == 0)
+ printf("\nEASIROC DAQ SUCESS\n");
+ break;
+
+ case P1_ESRC_CLOSE:
+ easiroc_Close();
+ break;
+#endif
+#ifdef USE_UDPCONTROL
+ case P1_ER_INIT:
+ SiTCPinit();
+ SiTCPSetIPPort(IpAddr, tcpport, udpport);
+ // SiTCPCreateTCPSock();
+ SiTCPCreateUDPSock();
+
+ SenderInit();
+ Senderudp_send(0x00000012,248); //Set ADC rate to 50Hz
+ Senderudp_send(0x0000001f,0);
+ break;
+ case P1_ER_CLOSE:
+ SiTCPclose();
+ SenderClose();
+ break;
+ case P1_ER_HV_CONTROL:
+ GetCtrlVal (p1h, P1_ER_HV_CONTROL_IN, &HV);
+
+ HVDAC = HVC_1 * HV + HVC_2; //change HV to DAC bit
+
+ printf("P1_ER_HV_CONTROL: HV = %lf | HVDAC = %d\n", HV, HVDAC);
+
+ Senderudp_send(0x00000010,HVDAC/256);//Set higher 8bit to FPGA reg
+ Senderudp_send(0x00000011,HVDAC%256);//lower 8bit
+ Senderudp_send(0x0000001e,1); //Start DAC control
+ break;
+ case P1_ER_HV_STATUS:
+ rd_data = Senderread_madc(3);//Read ADC data
+ // std::cout <<"MADC_data = "<< rd_data;
+ rd_data = ADC2HV * rd_data; //convert ADC bit to HV
+ printf("Bias voltage : %.2lfV\n",rd_data);
+
+ rd_data = Senderread_madc(4);//Read ADC data
+ //std::cout <<"MADC_data = "<< rd_data;
+ rd_data = ADC2uA * rd_data; //convert ADC bit to HVcurrent
+ printf("Bias current : %.2lfuA\n",rd_data);
+ break;
+#endif
+
+ }
+
+ } while ((rID != P1_EXIT)||daq_on);
+
+ CmtDiscardThreadPool (poolHandle);
+ DiscardPanel (p1h);
+
+#ifdef USE_MIKRO
+ MIKRO_Close ();
+#endif
+
+#ifdef USE_DAQ
+ WIENVME_VME_STOP();
+#endif
+ return 0;
+
+}
+
+#ifdef USE_CAEN_TDC
+/* ****************** CAEN V1290 TDC Write OPCODE****************** */
+int V1290_writeOC(int *write_buffer)
+{
+ //printf(">>> Writing %d\n", *write_buffer);
+ int wait_count = 0;
+ int read_buffer = 0;
+ do
+ {
+ // Micro Handshake Register
+ WIENVME_VME_A24D16_R(TDC_ADDR + 0x1030, &read_buffer); Delay(0.01);
+ //printf("V1290_writeOC wait_count = %d | read_buffer = %x\n", wait_count, read_buffer);
+ if(100 < wait_count++)
+ return -1;
+
+ } while (!(read_buffer & 0x1));
+
+ // Micro Register
+ WIENVME_VME_A24D16_W(TDC_ADDR + 0x102E, write_buffer);
+
+ return 0;
+}
+/* ****************** CAEN V1290 TDC Read OPCODE ****************** */
+int V1290_readOC(int *return_buffer)
+{
+ int wait_count = 0;
+ int read_buffer = 0;
+ do
+ {
+ // Micro Handshake Register
+ WIENVME_VME_A24D16_R(TDC_ADDR + 0x1030, &read_buffer); Delay(0.01);
+ //printf("V1290_readOC wait_count = %d | read_buffer = %x\n", wait_count, read_buffer);
+ if(100 < wait_count++)
+ return -1;
+
+ } while (!(read_buffer&0x2));
+
+ // Micro Register
+ WIENVME_VME_A24D16_R(TDC_ADDR + 0x102E, return_buffer);
+
+ //printf(">>> Returning %d\n", *return_buffer);
+ return 0;
+}
+/* ****************** ******************************************* */
+void V1290_init()
+{
+ int dum;
+ // intialization
+
+ dum=0x0; WIENVME_VME_A24D16_W(TDC_ADDR+0x1014, &dum); Delay(0.1);
+ dum=0x0; WIENVME_VME_A24D16_W(TDC_ADDR+0x1016, &dum); Delay(0.1);
+ dum=0x0; WIENVME_VME_A24D16_W(TDC_ADDR+0x1018, &dum); Delay(0.1);
+
+ //Trigger matching
+ dum=0x0000; V1290_writeOC(&dum);
+
+ // Constraints: tdc_window < tdc_offset <= 4095
+ // Largest window: 4095-margin;
+ // units: clock cycles = 25 ns
+ int tdc_margin = 0;
+ int tdc_offset = 40;
+ int tdc_window = tdc_offset - tdc_margin;
+
+ //set window width
+ dum=0x1000; V1290_writeOC(&dum);
+ dum=tdc_window; V1290_writeOC(&dum);
+ //set window offset
+ dum=0x1100; V1290_writeOC(&dum);
+ dum=-tdc_offset; V1290_writeOC(&dum);
+ //set extra search margin
+ dum=0x1200; V1290_writeOC(&dum);
+ dum=tdc_margin; V1290_writeOC(&dum);
+
+ //enable all channels
+ dum=0x4200; V1290_writeOC(&dum);
+ //disable all channels
+ //dum=0x4300; V1290_writeOC(&dum);
+ //enable first NCH_TDC channels
+ //for(i=0;i<NCH_TDC;i++)
+ //{
+ // dum=0x4000 + i;
+ // V1290_writeOC(&dum);
+ //}
+ //enable used channels
+ //for(i=0;i<32;i++)
+ // if(tdcmap[i]<32)
+ // {
+ // dum=0x4000 + i;
+ // V1290_writeOC(&dum);
+ // }
+
+ //enable(0x30xx)/disable(0x31xx) TDC Header and Trailer
+ dum=0x3100; V1290_writeOC(&dum);
+ /*
+ ////Maximum number of hits per event (does not work for unknown reason, sets to 0!)
+ dum=0x3300; V1290_writeOC(&dum);
+ //dum=0x0001; V1290_writeOC(&dum);
+ dum=0x1000; V1290_writeOC(&dum);
+ */
+ dum=0x3400; V1290_writeOC(&dum);
+ dum=0x0000; V1290_readOC(&dum);
+ printf("TDC Maximum number of hits per event = %d\n", dum);
+
+ //pair(00)/trailing(01)/leading(10)/both(11) edge
+ dum=0x2200; V1290_writeOC(&dum);
+ dum=0x1; V1290_writeOC(&dum);
+
+ //enable(0x14xx)/disable(0x15xx) substraction of trigger time
+ dum=0x1400; V1290_writeOC(&dum);
+}
+#endif
+/* ****** vrne (INT!) max vrednost iz arraya od elementa do elementa ****** */
+int max_from(int* array, int ifrom, int ito)
+{
+ int i;
+ int vmax;
+
+ vmax = array[ifrom];
+ for(i=ifrom+1; i<=ito; i++)
+ if(vmax < array[i])
+ vmax = array[i];
+
+ return vmax;
+}
Index: l2d2_easyroc/l2d.cdb
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/l2d2_easyroc/l2d.cdb
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/l2d.cws
===================================================================
--- l2d2_easyroc/l2d.cws (nonexistent)
+++ l2d2_easyroc/l2d.cws (revision 291)
@@ -0,0 +1,261 @@
+[Workspace Header]
+Version = 1302
+Pathname = "/c/home/rokd/l2d2_easyroc/l2d.cws"
+CVI Dir = "/c/program files/national instruments/cvi2013"
+CVI Shared Dir = "/C/Program Files/National Instruments/Shared/CVI"
+CVI Pub Local Dir = "/C/ProgramData/National Instruments/CVI2013"
+CVI Pub Global Dir = "/C/ProgramData/National Instruments/CVI"
+IVI Standard Root Dir = "/C/Program Files/IVI Foundation/IVI"
+IVI Standard Root 64-bit Dir = "/C/Program Files/IVI Foundation/IVI"
+VXIplug&play Framework Dir = "/C/Program Files/IVI Foundation/VISA/winnt"
+VXIplug&play Framework 64-bit Dir = "/C/Program Files/IVI Foundation/VISA/win64"
+Number of Projects = 1
+Active Project = 1
+Project 0001 = "l2d.prj"
+Drag Bar Left = 174
+Window Top = 31
+Window Left = 1
+Window Bottom = 1009
+Window Right = 839
+Maximized = True
+Maximized Children = True
+Max32 Number Of Errors = 20
+Track Include File Dependencies = True
+Prompt For Missing Includes = True
+Stop On First Error File = False
+Bring Up Err Win At Start = True
+Bring Up Err Win For Errors = False
+Save Changes Before Running = "Always"
+Save Changes Before Compiling = "Always"
+Hide Windows = False
+Break At First Statement = False
+Sort Type = "File Name"
+Number of Opened Files = 9
+Window Confinement Region Enabled = True
+MainColumnWidth = 157
+FileDateColumnWidth = 70
+FileSizeColumnWidth = 70
+
+[Project Header 0001]
+Version = 1302
+Don't Update DistKit = False
+Platform Code = 4
+Build Configuration = "Debug"
+Warn User If Debugging Release = 1
+Batch Build Release = False
+Batch Build Debug = False
+
+[File 0001]
+Path = "/c/home/cvi/instr/CAMAC_2000/CAMAC.fp"
+File Type = "Function Panel"
+Disk Date = 3368785720
+In Projects = "1,"
+
+[File 0002]
+Path = "/c/home/cvi/instr/CAENV965/CAENV965.fp"
+File Type = "Function Panel"
+Disk Date = 3565067385
+In Projects = "1,"
+
+[File 0003]
+Path = "/c/home/cvi/instr/WIENVME_DLL/wienvme_dll.fp"
+File Type = "Function Panel"
+Disk Date = 3555477334
+In Projects = "1,"
+
+[File 0004]
+Path = "/c/home/rokd/l2d2_easyroc/easiroc.c"
+File Type = "CSource"
+Disk Date = 3603793368
+In Projects = "1,"
+Window Top = 33
+Window Left = 10
+Window Z-Order = 1
+Source Window State = "1,584,585,585,13,13,13,0,0,183,0,0,0,0,0,48,528,0,588,42,349,523,1,0,"
+
+[File 0005]
+Path = "/c/home/rokd/l2d2_easyroc/l2d.c"
+File Type = "CSource"
+Disk Date = 3603776262
+In Projects = "1,"
+Window Top = 436
+Window Left = 4
+Window Z-Order = 3
+Source Window State = "1,8,8,8,20,33,20,0,0,80,0,0,0,0,0,25,39,0,915,4,349,683,1,15,"
+
+[File 0006]
+Path = "/c/home/rokd/l2d2_easyroc/l2d_ui.uir"
+File Type = "User Interface Resource"
+Disk Date = 3603787634
+In Projects = "1,"
+Window Top = 33
+Window Left = 10
+Window Height = 349
+Window Width = 683
+Window Z-Order = 5
+
+[File 0007]
+Path = "/c/home/rokd/l2d2_easyroc/l2d_ui.h"
+File Type = "Include"
+Disk Date = 3603786987
+In Projects = "1,"
+Window Top = 33
+Window Left = -204
+Window Z-Order = 9
+Source Window State = "1,0,0,0,0,0,0,0,0,80,0,0,0,0,0,25,0,0,0,0,349,683,1,0,"
+
+[File 0008]
+Path = "/c/home/rokd/l2d2_easyroc/SiTCP.c"
+File Type = "CSource"
+Disk Date = 3594638249
+In Projects = "1,"
+Window Top = 219
+Window Left = -108
+Window Z-Order = 4
+Source Window State = "1,137,137,137,22,29,29,0,0,80,0,0,0,0,0,25,0,0,170,8,349,683,1,0,"
+
+[File 0009]
+Path = "/c/home/rokd/l2d2_easyroc/SiTCP.h"
+File Type = "Include"
+Disk Date = 3579505677
+In Projects = "1,"
+Window Top = 188
+Window Left = -124
+Window Z-Order = 7
+Source Window State = "1,0,1,1,0,17,17,0,3,80,0,0,0,0,0,25,0,0,0,0,349,683,1,0,"
+
+[File 0010]
+Path = "/c/home/rokd/l2d2_easyroc/sender.c"
+File Type = "CSource"
+Disk Date = 3594633824
+In Projects = "1,"
+Window Top = 281
+Window Left = -76
+Window Z-Order = 8
+Source Window State = "1,171,171,171,2,7,7,0,0,80,0,0,0,0,0,25,0,0,112,182,349,683,1,0,"
+
+[File 0011]
+Path = "/c/home/rokd/l2d2_easyroc/sender.h"
+File Type = "Include"
+Disk Date = 3579505274
+In Projects = "1,"
+Window Top = 250
+Window Left = -92
+Window Z-Order = 6
+Source Window State = "1,1,1,1,0,18,18,0,0,80,0,0,0,0,0,25,0,0,5,36,349,683,1,14,"
+
+[File 0012]
+Path = "/c/home/rokd/l2d2_easyroc/easiroc.h"
+File Type = "Include"
+Disk Date = 3603793222
+In Projects = "1,"
+Window Top = 188
+Window Left = 90
+Window Z-Order = 2
+Source Window State = "1,13,14,14,29,29,29,0,0,80,0,44,0,44,0,25,0,0,13,29,349,683,1,0,"
+
+[File 0013]
+Path = "/c/Program Files/Microsoft SDKs/Windows/v7.1A/Lib/WS2_32.Lib"
+File Type = "Library"
+Disk Date = 3431916852
+In Projects = "1,"
+
+[Tab Order]
+Tab 0001 = "/c/home/rokd/l2d2_easyroc/SiTCP.h"
+Tab 0002 = "/c/home/rokd/l2d2_easyroc/sender.h"
+Tab 0003 = "/c/home/rokd/l2d2_easyroc/SiTCP.c"
+Tab 0004 = "/c/home/rokd/l2d2_easyroc/sender.c"
+Tab 0005 = "/c/home/rokd/l2d2_easyroc/l2d_ui.uir"
+Tab 0006 = "/c/home/rokd/l2d2_easyroc/easiroc.h"
+Tab 0007 = "/c/home/rokd/l2d2_easyroc/l2d.c"
+Tab 0008 = "/c/home/rokd/l2d2_easyroc/easiroc.c"
+Tab 0009 = "/c/home/rokd/l2d2_easyroc/l2d_ui.h"
+
+[Default Build Config 0001 Debug]
+Generate Browse Info = True
+Enable Uninitialized Locals Runtime Warning = True
+Batch Build = False
+Profile = "Disabled"
+Debugging Level = "Standard"
+Execution Trace = "Disabled"
+Command Line Args = ""
+Working Directory = ""
+Environment Options = ""
+External Process Path = ""
+
+[Default Build Config 0001 Release]
+Generate Browse Info = True
+Enable Uninitialized Locals Runtime Warning = True
+Batch Build = False
+Profile = "Disabled"
+Debugging Level = "Standard"
+Execution Trace = "Disabled"
+Command Line Args = ""
+Working Directory = ""
+Environment Options = ""
+External Process Path = ""
+
+[Default Build Config 0001 Debug64]
+Generate Browse Info = True
+Enable Uninitialized Locals Runtime Warning = True
+Batch Build = False
+Profile = "Disabled"
+Debugging Level = "Standard"
+Execution Trace = "Disabled"
+Command Line Args = ""
+Working Directory = ""
+Environment Options = ""
+External Process Path = ""
+
+[Default Build Config 0001 Release64]
+Generate Browse Info = True
+Enable Uninitialized Locals Runtime Warning = True
+Batch Build = False
+Profile = "Disabled"
+Debugging Level = "Standard"
+Execution Trace = "Disabled"
+Command Line Args = ""
+Working Directory = ""
+Environment Options = ""
+External Process Path = ""
+
+[Build Dependencies 0001]
+Number of Dependencies = 0
+
+[Build Options 0001]
+Generate Browse Info = True
+Enable Uninitialized Locals Runtime Warning = True
+Execution Trace = "Disabled"
+Profile = "Disabled"
+Debugging Level = "Standard"
+Break On Library Errors = True
+Break On First Chance Exceptions = False
+
+[Execution Target 0001]
+Execution Target Address = "Local desktop computer"
+Execution Target Port = 0
+Execution Target Type = 0
+
+[SCC Options 0001]
+Use global settings = True
+SCC Provider = ""
+SCC Project = ""
+Local Path = ""
+Auxiliary Path = ""
+Perform Same Action For .h File As For .uir File = "Ask"
+Perform Same Action For .cds File As For .prj File = "Ask"
+Username = ""
+Comment = ""
+Use Default Username = False
+Use Default Comment = False
+Suppress CVI Error Messages = False
+Always show confirmation dialog = True
+
+[DLL Debugging Support 0001]
+External Process Path = ""
+
+[Command Line Args 0001]
+Command Line Args = ""
+Working Directory = ""
+Environment Options = ""
+
Index: l2d2_easyroc/l2d.exe
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/l2d2_easyroc/l2d.exe
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/l2d.prj
===================================================================
--- l2d2_easyroc/l2d.prj (nonexistent)
+++ l2d2_easyroc/l2d.prj (revision 291)
@@ -0,0 +1,574 @@
+[Project Header]
+Version = 1302
+Pathname = "/c/home/rokd/l2d2_easyroc/l2d.prj"
+CVI Dir = "/c/program files/national instruments/cvi2013"
+CVI Shared Dir = "/C/Program Files/National Instruments/Shared/CVI"
+CVI Pub Local Dir = "/C/ProgramData/National Instruments/CVI2013"
+CVI Pub Global Dir = "/C/ProgramData/National Instruments/CVI"
+IVI Standard Root Dir = "/C/Program Files/IVI Foundation/IVI"
+VXIplug&play Framework Dir = "/C/Program Files/IVI Foundation/VISA/winnt"
+IVI Standard Root 64-bit Dir = "/C/Program Files/IVI Foundation/IVI"
+VXIplug&play Framework 64-bit Dir = "/C/Program Files/IVI Foundation/VISA/win64"
+Number of Files = 13
+Target Type = "Executable"
+Flags = 2064
+Copied From Locked InstrDrv Directory = False
+Copied from VXIPNP Directory = False
+Locked InstrDrv Name = ""
+Don't Display Deploy InstrDrv Dialog = False
+
+[Folders]
+Folder 0 = "Source Files"
+FolderEx 0 = "Source Files"
+Folder 1 = "User Interface Files"
+FolderEx 1 = "User Interface Files"
+Folder 2 = "Include Files"
+FolderEx 2 = "Include Files"
+Folder 3 = "Instrument Files"
+FolderEx 3 = "Instrument Files"
+Folder 4 = "Library Files"
+FolderEx 4 = "Library Files"
+
+[File 0001]
+File Type = "CSource"
+Res Id = 1
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "easiroc.c"
+Path = "/c/home/rokd/l2d2_easyroc/easiroc.c"
+Exclude = False
+Compile Into Object File = False
+Project Flags = 0
+Folder = "Source Files"
+Folder Id = 0
+
+[File 0002]
+File Type = "CSource"
+Res Id = 2
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "l2d.c"
+Path = "/c/home/rokd/l2d2_easyroc/l2d.c"
+Exclude = False
+Compile Into Object File = False
+Project Flags = 0
+Folder = "Source Files"
+Folder Id = 0
+
+[File 0003]
+File Type = "CSource"
+Res Id = 3
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "sender.c"
+Path = "/c/home/rokd/l2d2_easyroc/sender.c"
+Exclude = False
+Compile Into Object File = False
+Project Flags = 0
+Folder = "Source Files"
+Folder Id = 0
+
+[File 0004]
+File Type = "CSource"
+Res Id = 4
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "SiTCP.c"
+Path = "/c/home/rokd/l2d2_easyroc/SiTCP.c"
+Exclude = False
+Compile Into Object File = False
+Project Flags = 0
+Folder = "Source Files"
+Folder Id = 0
+
+[File 0005]
+File Type = "User Interface Resource"
+Res Id = 5
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "l2d_ui.uir"
+Path = "/c/home/rokd/l2d2_easyroc/l2d_ui.uir"
+Exclude = False
+Project Flags = 0
+Folder = "User Interface Files"
+Folder Id = 1
+
+[File 0006]
+File Type = "Include"
+Res Id = 6
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "easiroc.h"
+Path = "/c/home/rokd/l2d2_easyroc/easiroc.h"
+Exclude = False
+Project Flags = 0
+Folder = "Include Files"
+Folder Id = 2
+
+[File 0007]
+File Type = "Include"
+Res Id = 7
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "l2d_ui.h"
+Path = "/c/home/rokd/l2d2_easyroc/l2d_ui.h"
+Exclude = False
+Project Flags = 0
+Folder = "Include Files"
+Folder Id = 2
+
+[File 0008]
+File Type = "Include"
+Res Id = 8
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "sender.h"
+Path = "/c/home/rokd/l2d2_easyroc/sender.h"
+Exclude = False
+Project Flags = 0
+Folder = "Include Files"
+Folder Id = 2
+
+[File 0009]
+File Type = "Include"
+Res Id = 9
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "SiTCP.h"
+Path = "/c/home/rokd/l2d2_easyroc/SiTCP.h"
+Exclude = False
+Project Flags = 0
+Folder = "Include Files"
+Folder Id = 2
+
+[File 0010]
+File Type = "Function Panel"
+Res Id = 10
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "../../cvi/instr/CAENV965/CAENV965.fp"
+Path = "/c/home/cvi/instr/CAENV965/CAENV965.fp"
+Exclude = False
+Project Flags = 0
+Folder = "Instrument Files"
+Folder Id = 3
+
+[File 0011]
+File Type = "Function Panel"
+Res Id = 11
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "../../cvi/instr/CAMAC_2000/CAMAC.fp"
+Path = "/c/home/cvi/instr/CAMAC_2000/CAMAC.fp"
+Exclude = False
+Project Flags = 0
+Folder = "Instrument Files"
+Folder Id = 3
+
+[File 0012]
+File Type = "Function Panel"
+Res Id = 12
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "../../cvi/instr/WIENVME_DLL/wienvme_dll.fp"
+Path = "/c/home/cvi/instr/WIENVME_DLL/wienvme_dll.fp"
+Exclude = False
+Project Flags = 0
+Folder = "Instrument Files"
+Folder Id = 3
+
+[File 0013]
+File Type = "Library"
+Res Id = 13
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "../../../Program Files/Microsoft SDKs/Windows/v7.1A/Lib/WS2_32.Lib"
+Path = "/c/Program Files/Microsoft SDKs/Windows/v7.1A/Lib/WS2_32.Lib"
+Exclude = False
+Project Flags = 0
+Folder = "Library Files"
+Folder Id = 4
+
+[Custom Build Configs]
+Num Custom Build Configs = 0
+
+[Default Build Config Debug]
+Config Name = "Debug"
+Is 64-Bit = False
+Is Release = False
+Default Calling Convention = "cdecl"
+Optimization Level = "No optimizations"
+Require Prototypes = False
+Show Warning IDs in Build Output = False
+Selected Warning Level = "None"
+Warning List None = "4,9,84,105,106,107,108,109,110,111"
+Warning List Common = ""
+Warning List Extended = ""
+Warning List All = ""
+Warning Mode = 0
+Enable Unreferenced Identifiers Warning = False
+Enable Pointer Mismatch Warning = False
+Enable Unreachable Code Warning = False
+Enable Assignment In Conditional Warning = False
+Uninitialized Locals Compile Warning = "Aggressive"
+Require Return Values = True
+Enable C99 Extensions = True
+Enable OpenMP Extensions = False
+Stack Size = 250000
+Stack Reserve = 1048576
+Stack Commit = 4096
+Image Base Address = 4194304
+Image Base Address x64 = 4194304
+Compiler Defines = "/DWIN32_LEAN_AND_MEAN /DWIENVME"
+Sign = False
+Sign Store = ""
+Sign Certificate = ""
+Sign Timestamp URL = ""
+Sign URL = ""
+Manifest Embed = False
+Icon File Is Rel = False
+Icon File = ""
+Application Title = ""
+Use IVI Subdirectories for Import Libraries = False
+Use VXIPNP Subdirectories for Import Libraries = False
+Use Dflt Import Lib Base Name = True
+Where to Copy DLL = "Do not copy"
+Custom Directory to Copy DLL Is Rel = False
+Custom Directory to Copy DLL = ""
+Generate Source Documentation = "None"
+Runtime Support = "Full Runtime Support"
+Runtime Binding = "Shared"
+Embed Project .UIRs = False
+Generate Map File = False
+Embed Timestamp = True
+Create Console Application = False
+Using LoadExternalModule = False
+DLL Exports = "Include File Symbols"
+Register ActiveX Server = False
+Numeric File Version = "1,0,0,0"
+Numeric Prod Version = "1,0,0,0"
+Comments = ""
+Comments Ex = ""
+Company Name = ""
+Company Name Ex = "%company"
+File Description = "l2d (Debug x86)"
+File Description Ex = "%application (%rel_dbg %arch)"
+File Version = "1.0"
+File Version Ex = "%f1.%f2"
+Internal Name = "l2d"
+Internal Name Ex = "%basename"
+Legal Copyright = "Copyright © 2018"
+Legal Copyright Ex = "Copyright © %company %Y"
+Legal Trademarks = ""
+Legal Trademarks Ex = ""
+Original Filename = "l2d.exe"
+Original Filename Ex = "%filename"
+Private Build = ""
+Private Build Ex = ""
+Product Name = " l2d"
+Product Name Ex = "%company %application"
+Product Version = "1.0"
+Product Version Ex = "%p1.%p2"
+Special Build = ""
+Special Build Ex = ""
+Add Type Lib To DLL = False
+Include Type Lib Help Links = False
+TLB Help Style = "HLP"
+Type Lib FP File Is Rel = False
+Type Lib FP File = ""
+
+[Default Build Config Release]
+Config Name = "Release"
+Is 64-Bit = False
+Is Release = True
+Default Calling Convention = "cdecl"
+Optimization Level = "No optimizations"
+Require Prototypes = True
+Show Warning IDs in Build Output = False
+Selected Warning Level = "None"
+Warning List None = "4,9,84,105,106,107,108,109,110,111"
+Warning List Common = ""
+Warning List Extended = ""
+Warning List All = ""
+Warning Mode = 0
+Enable Unreferenced Identifiers Warning = False
+Enable Pointer Mismatch Warning = False
+Enable Unreachable Code Warning = False
+Enable Assignment In Conditional Warning = False
+Uninitialized Locals Compile Warning = "Aggressive"
+Require Return Values = True
+Enable C99 Extensions = True
+Enable OpenMP Extensions = False
+Stack Size = 250000
+Stack Reserve = 1048576
+Stack Commit = 4096
+Image Base Address = 4194304
+Image Base Address x64 = 4194304
+Compiler Defines = "/DWIN32_LEAN_AND_MEAN"
+Sign = False
+Sign Store = ""
+Sign Certificate = ""
+Sign Timestamp URL = ""
+Sign URL = ""
+Manifest Embed = False
+Icon File Is Rel = False
+Icon File = ""
+Application Title = ""
+Use IVI Subdirectories for Import Libraries = False
+Use VXIPNP Subdirectories for Import Libraries = False
+Use Dflt Import Lib Base Name = True
+Where to Copy DLL = "Do not copy"
+Custom Directory to Copy DLL Is Rel = False
+Custom Directory to Copy DLL = ""
+Generate Source Documentation = "None"
+Runtime Support = "Full Runtime Support"
+Runtime Binding = "Shared"
+Embed Project .UIRs = False
+Generate Map File = False
+Embed Timestamp = True
+Create Console Application = False
+Using LoadExternalModule = False
+DLL Exports = "Include File Symbols"
+Register ActiveX Server = False
+Add Type Lib To DLL = False
+Include Type Lib Help Links = False
+TLB Help Style = "HLP"
+Type Lib FP File Is Rel = False
+Type Lib FP File = ""
+
+[Default Build Config Debug64]
+Config Name = "Debug64"
+Is 64-Bit = True
+Is Release = False
+Default Calling Convention = "cdecl"
+Optimization Level = "No optimizations"
+Require Prototypes = True
+Show Warning IDs in Build Output = False
+Selected Warning Level = "None"
+Warning List None = "4,9,84,105,106,107,108,109,110,111"
+Warning List Common = ""
+Warning List Extended = ""
+Warning List All = ""
+Warning Mode = 0
+Enable Unreferenced Identifiers Warning = False
+Enable Pointer Mismatch Warning = False
+Enable Unreachable Code Warning = False
+Enable Assignment In Conditional Warning = False
+Uninitialized Locals Compile Warning = "Aggressive"
+Require Return Values = True
+Enable C99 Extensions = True
+Enable OpenMP Extensions = False
+Stack Size = 250000
+Stack Reserve = 1048576
+Stack Commit = 4096
+Image Base Address = 4194304
+Image Base Address x64 = 4194304
+Compiler Defines = "/DWIN32_LEAN_AND_MEAN"
+Sign = False
+Sign Store = ""
+Sign Certificate = ""
+Sign Timestamp URL = ""
+Sign URL = ""
+Manifest Embed = False
+Icon File Is Rel = False
+Icon File = ""
+Application Title = ""
+Use IVI Subdirectories for Import Libraries = False
+Use VXIPNP Subdirectories for Import Libraries = False
+Use Dflt Import Lib Base Name = True
+Where to Copy DLL = "Do not copy"
+Custom Directory to Copy DLL Is Rel = False
+Custom Directory to Copy DLL = ""
+Generate Source Documentation = "None"
+Runtime Support = "Full Runtime Support"
+Runtime Binding = "Shared"
+Embed Project .UIRs = False
+Generate Map File = False
+Embed Timestamp = True
+Create Console Application = False
+Using LoadExternalModule = False
+DLL Exports = "Include File Symbols"
+Register ActiveX Server = False
+Add Type Lib To DLL = False
+Include Type Lib Help Links = False
+TLB Help Style = "HLP"
+Type Lib FP File Is Rel = False
+Type Lib FP File = ""
+
+[Default Build Config Release64]
+Config Name = "Release64"
+Is 64-Bit = True
+Is Release = True
+Default Calling Convention = "cdecl"
+Optimization Level = "No optimizations"
+Require Prototypes = True
+Show Warning IDs in Build Output = False
+Selected Warning Level = "None"
+Warning List None = "4,9,84,105,106,107,108,109,110,111"
+Warning List Common = ""
+Warning List Extended = ""
+Warning List All = ""
+Warning Mode = 0
+Enable Unreferenced Identifiers Warning = False
+Enable Pointer Mismatch Warning = False
+Enable Unreachable Code Warning = False
+Enable Assignment In Conditional Warning = False
+Uninitialized Locals Compile Warning = "Aggressive"
+Require Return Values = True
+Enable C99 Extensions = True
+Enable OpenMP Extensions = False
+Stack Size = 250000
+Stack Reserve = 1048576
+Stack Commit = 4096
+Image Base Address = 4194304
+Image Base Address x64 = 4194304
+Compiler Defines = "/DWIN32_LEAN_AND_MEAN"
+Sign = False
+Sign Store = ""
+Sign Certificate = ""
+Sign Timestamp URL = ""
+Sign URL = ""
+Manifest Embed = False
+Icon File Is Rel = False
+Icon File = ""
+Application Title = ""
+Use IVI Subdirectories for Import Libraries = False
+Use VXIPNP Subdirectories for Import Libraries = False
+Use Dflt Import Lib Base Name = True
+Where to Copy DLL = "Do not copy"
+Custom Directory to Copy DLL Is Rel = False
+Custom Directory to Copy DLL = ""
+Generate Source Documentation = "None"
+Runtime Support = "Full Runtime Support"
+Runtime Binding = "Shared"
+Embed Project .UIRs = False
+Generate Map File = False
+Embed Timestamp = True
+Create Console Application = False
+Using LoadExternalModule = False
+DLL Exports = "Include File Symbols"
+Register ActiveX Server = False
+Add Type Lib To DLL = False
+Include Type Lib Help Links = False
+TLB Help Style = "HLP"
+Type Lib FP File Is Rel = False
+Type Lib FP File = ""
+
+[Compiler Options]
+Default Calling Convention = "cdecl"
+Require Prototypes = True
+Require Return Values = True
+Enable Pointer Mismatch Warning = False
+Enable Unreachable Code Warning = False
+Enable Unreferenced Identifiers Warning = False
+Enable Assignment In Conditional Warning = False
+O Option Compatible With 5.0 = False
+Enable C99 Extensions = True
+Uninitialized Locals Compile Warning = "Conservative"
+Precompile Prefix Header = False
+Prefix Header File = ""
+
+[Run Options]
+Stack Size = 250000
+Stack Commit = 4096
+Image Base Address = 4194304
+Image Base Address x64 = 4194304
+
+[Compiler Defines]
+Compiler Defines = "/DWIN32_LEAN_AND_MEAN"
+
+[Include Paths]
+Include Path 1 Is Rel = True
+Include Path 1 Rel To = "CVI"
+Include Path 1 Rel To Override = "CVI"
+Include Path 1 Rel Path = "instr/CAMAC_2000"
+Include Path 1 = "/c/Program Files/National Instruments/CVI2013/instr/CAMAC_2000"
+Include Path 2 Is Rel = True
+Include Path 2 Rel To = "CVI"
+Include Path 2 Rel To Override = "CVI"
+Include Path 2 Rel Path = "instr/WIENVME_DLL"
+Include Path 2 = "/c/Program Files/National Instruments/CVI2013/instr/WIENVME_DLL"
+Include Path 3 Is Rel = True
+Include Path 3 Rel To = "CVI"
+Include Path 3 Rel To Override = "CVI"
+Include Path 3 Rel Path = "instr/CAENV965"
+Include Path 3 = "/c/Program Files/National Instruments/CVI2013/instr/CAENV965"
+
+[Create Executable]
+Executable File_Debug Is Rel = True
+Executable File_Debug Rel To = "Project"
+Executable File_Debug Rel Path = "l2d.exe"
+Executable File_Debug = "/c/home/rokd/l2d2_easyroc/l2d.exe"
+Executable File_Release Is Rel = True
+Executable File_Release Rel To = "Project"
+Executable File_Release Rel Path = "l2d.exe"
+Executable File_Release = "/c/home/rokd/l2d2_easyroc/l2d.exe"
+Executable File_Debug64 Is Rel = True
+Executable File_Debug64 Rel To = "Project"
+Executable File_Debug64 Rel Path = "l2d.exe"
+Executable File_Debug64 = "/c/home/rokd/l2d2_easyroc/l2d.exe"
+Executable File_Release64 Is Rel = True
+Executable File_Release64 Rel To = "Project"
+Executable File_Release64 Rel Path = "l2d.exe"
+Executable File_Release64 = "/c/home/rokd/l2d2_easyroc/l2d.exe"
+Icon File Is Rel = False
+Icon File = ""
+Application Title = ""
+DLL Exports = "Include File Symbols"
+Use IVI Subdirectories for Import Libraries = False
+Use VXIPNP Subdirectories for Import Libraries = False
+Use Dflt Import Lib Base Name = True
+Where to Copy DLL = "Do not copy"
+Custom Directory to Copy DLL Is Rel = False
+Custom Directory to Copy DLL = ""
+Generate Source Documentation = "None"
+Add Type Lib To DLL = False
+Include Type Lib Help Links = False
+TLB Help Style = "HLP"
+Type Lib FP File Is Rel = False
+Type Lib FP File = ""
+Type Lib Guid = ""
+Runtime Support = "Full Runtime Support"
+Instrument Driver Support Only = False
+Embed Project .UIRs = False
+Generate Map File = False
+
+[External Compiler Support]
+UIR Callbacks File Option = 0
+Using LoadExternalModule = False
+Create Project Symbols File = True
+UIR Callbacks Obj File Is Rel = False
+UIR Callbacks Obj File = ""
+Project Symbols H File Is Rel = False
+Project Symbols H File = ""
+Project Symbols Obj File Is Rel = False
+Project Symbols Obj File = ""
+
+[ActiveX Server Options]
+Specification File Is Rel = False
+Specification File = ""
+Source File Is Rel = False
+Source File = ""
+Include File Is Rel = False
+Include File = ""
+IDL File Is Rel = False
+IDL File = ""
+Register ActiveX Server = False
+
+[Signing Info]
+Sign = False
+Sign Debug Build = False
+Store = ""
+Certificate = ""
+Timestamp URL = ""
+URL = ""
+
+[Manifest Info]
+Embed = False
+
+[tpcSection]
+tpcEnabled = 0
+tpcOverrideEnvironment = 0
+tpcEnabled x64 = 0
+tpcOverrideEnvironment x64 = 0
+
Index: l2d2_easyroc/l2d_ui.h
===================================================================
--- l2d2_easyroc/l2d_ui.h (nonexistent)
+++ l2d2_easyroc/l2d_ui.h (revision 291)
@@ -0,0 +1,104 @@
+/**************************************************************************/
+/* LabWindows/CVI User Interface Resource (UIR) Include File */
+/* */
+/* WARNING: Do not add to, delete from, or otherwise modify the contents */
+/* of this include file. */
+/**************************************************************************/
+
+#include <userint.h>
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+ /* Panels and Controls: */
+
+#define P1 1
+#define P1_EXIT 2 /* control type: command, callback function: (none) */
+#define P1_ADC 3 /* control type: graph, callback function: (none) */
+#define P1_TDC 4 /* control type: graph, callback function: (none) */
+#define P1_RESET 5 /* control type: command, callback function: (none) */
+#define P1_CEVE 6 /* control type: numeric, callback function: (none) */
+#define P1_NMIN 7 /* control type: numeric, callback function: (none) */
+#define P1_NEVE 8 /* control type: numeric, callback function: (none) */
+#define P1_FRAC 9 /* control type: numeric, callback function: (none) */
+#define P1_TDCMIN 10 /* control type: numeric, callback function: (none) */
+#define P1_PEDESTAL 11 /* control type: numeric, callback function: (none) */
+#define P1_ADCHLSAVE 12 /* control type: binary, callback function: (none) */
+#define P1_TDC_EDGE 13 /* control type: binary, callback function: (none) */
+#define P1_ADCHL 14 /* control type: binary, callback function: (none) */
+#define P1_ADCLOG 15 /* control type: binary, callback function: (none) */
+#define P1_TDCLOG 16 /* control type: binary, callback function: (none) */
+#define P1_TDCHL 17 /* control type: binary, callback function: (none) */
+#define P1_DAQ 18 /* control type: textButton, callback function: (none) */
+#define P1_SUPR 19 /* control type: radioButton, callback function: (none) */
+#define P1_DSAVE 20 /* control type: radioButton, callback function: (none) */
+#define P1_DFILE 21 /* control type: string, callback function: (none) */
+#define P1_IY 22 /* control type: numeric, callback function: (none) */
+#define P1_Z 23 /* control type: numeric, callback function: (none) */
+#define P1_Y 24 /* control type: numeric, callback function: (none) */
+#define P1_YMIN 25 /* control type: numeric, callback function: (none) */
+#define P1_IX 26 /* control type: numeric, callback function: (none) */
+#define P1_YSTEP 27 /* control type: numeric, callback function: (none) */
+#define P1_X 28 /* control type: numeric, callback function: (none) */
+#define P1_NY 29 /* control type: numeric, callback function: (none) */
+#define P1_ZSET 30 /* control type: numeric, callback function: (none) */
+#define P1_XMIN 31 /* control type: numeric, callback function: (none) */
+#define P1_XSTEP 32 /* control type: numeric, callback function: (none) */
+#define P1_NX 33 /* control type: numeric, callback function: (none) */
+#define P1_MGET 34 /* control type: command, callback function: (none) */
+#define P1_REREAD 35 /* control type: command, callback function: (none) */
+#define P1_HO 36 /* control type: command, callback function: (none) */
+#define P1_PLCH 37 /* control type: numeric, callback function: (none) */
+#define P1_NEWF 38 /* control type: numeric, callback function: (none) */
+#define P1_REFON 39 /* control type: radioButton, callback function: (none) */
+#define P1_REFRESH 40 /* control type: command, callback function: (none) */
+#define P1_PIO_OFF 41 /* control type: command, callback function: (none) */
+#define P1_PIO_ON 42 /* control type: command, callback function: (none) */
+#define P1_TDCTEST 43 /* control type: command, callback function: (none) */
+#define P1_TDCCLEAR 44 /* control type: command, callback function: (none) */
+#define P1_TDCINIT 45 /* control type: command, callback function: (none) */
+#define P1_TDCMIKRO 46 /* control type: command, callback function: (none) */
+#define P1_ER_HV_STATUS 47 /* control type: command, callback function: (none) */
+#define P1_ESRC_DAQ 48 /* control type: command, callback function: (none) */
+#define P1_ESRC_F4 49 /* control type: command, callback function: (none) */
+#define P1_ESRC_F3 50 /* control type: command, callback function: (none) */
+#define P1_ESRC_F2 51 /* control type: command, callback function: (none) */
+#define P1_ESRC_F1 52 /* control type: command, callback function: (none) */
+#define P1_ER_HV_CONTROL 53 /* control type: command, callback function: (none) */
+#define P1_ESRC_CLOSE 54 /* control type: command, callback function: (none) */
+#define P1_ER_CLOSE 55 /* control type: command, callback function: (none) */
+#define P1_ESRC_INIT 56 /* control type: command, callback function: (none) */
+#define P1_ER_INIT 57 /* control type: command, callback function: (none) */
+#define P1_TIMER 58 /* control type: timer, callback function: cb_timer */
+#define P1_DECORATION 59 /* control type: deco, callback function: (none) */
+#define P1_ESRC_PROBE_CH 60 /* control type: numeric, callback function: (none) */
+#define P1_ER_HV_CONTROL_IN 61 /* control type: numeric, callback function: (none) */
+#define P1_TEXTMSG 62 /* control type: textMsg, callback function: (none) */
+#define P1_TEXTMSG_2 63 /* control type: textMsg, callback function: (none) */
+#define P1_TEXTMSG_3 64 /* control type: textMsg, callback function: (none) */
+#define P1_TEXTMSG_4 65 /* control type: textMsg, callback function: (none) */
+#define P1_ESRC_PROBE_TYPE 66 /* control type: ring, callback function: (none) */
+#define P1_TEXTMSG_6 67 /* control type: textMsg, callback function: (none) */
+#define P1_TEXTMSG_5 68 /* control type: textMsg, callback function: (none) */
+#define P1_DECORATION_2 69 /* control type: deco, callback function: (none) */
+
+
+ /* Control Arrays: */
+
+ /* (no control arrays in the resource file) */
+
+
+ /* Menu Bars, Menus, and Menu Items: */
+
+ /* (no menu bars in the resource file) */
+
+
+ /* Callback Prototypes: */
+
+int CVICALLBACK cb_timer(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+
+
+#ifdef __cplusplus
+ }
+#endif
Index: l2d2_easyroc/l2d_ui.uir
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/l2d2_easyroc/l2d_ui.uir
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/pcivme_ni.log
===================================================================
--- l2d2_easyroc/pcivme_ni.log (nonexistent)
+++ l2d2_easyroc/pcivme_ni.log (revision 291)
@@ -0,0 +1 @@
+VMEinitNT
Index: l2d2_easyroc/plots2.cpp
===================================================================
--- l2d2_easyroc/plots2.cpp (nonexistent)
+++ l2d2_easyroc/plots2.cpp (revision 291)
@@ -0,0 +1,2186 @@
+#include "TROOT.h"
+#include "TFile.h"
+#include "TBenchmark.h"
+#include "TH1F.h"
+#include "TH2F.h"
+gROOT->Reset();
+
+#include "TCanvas.h"
+#include "TStyle.h"
+#include "TPad.h"
+#include "TF1.h"
+#include "TGraph.h"
+#include "TSpectrum.h"
+
+#include "DrootHelper.cpp"
+
+
+#define NCH 2
+
+//-------------------------------------------------------------------------------------
+
+void SetGS() {
+ const UInt_t Number = 2;
+ Double_t Red[Number] = {0.00, 1.00};
+ Double_t Green[Number] = {0.00, 1.00};
+ Double_t Blue[Number] = {0.00, 1.00};
+ Double_t Stops[Number] = {0.00, 1.00};
+
+ Int_t nb=50;
+ TColor::CreateGradientColorTable(Number, Stops, Red, Green, Blue, nb);
+}
+
+
+//-------------------------------------------------------------------------------------
+Double_t ConstantStep(Double_t x)
+{
+ if(x<=0) return 0.;
+ else return 1.;
+}
+
+// =======================================================================================================
+
+void plotCorTDC(TH1F *hp1d, char *hTitle, double fitmin, double fitmax, double drawmin, double drawmax)
+{
+ char sbuff[256];
+
+ TLegend *leg1 = new TLegend(0.57,0.76,0.88,0.88);
+ leg1->SetFillColor(0);
+ leg1->SetBorderSize(1);
+ leg1->SetTextSize(0.05);
+ leg1->SetTextAlign(22);
+
+ //gStyle->SetOptFit(111);
+ sprintf(sbuff, "%s;Time[ns];", hTitle);
+ hp1d->SetTitle(sbuff);
+ //~ hp1d->GetXaxis()->SetRangeUser(2*fitmin, 2*fitmax);
+ hp1d->GetXaxis()->SetRangeUser(drawmin, drawmax);
+ //~ hcTDC->DrawClone();
+
+ //~ TF1 *fs = new TF1("fs","pol0(0) + gaus(1)");
+
+ TF1 *fs = new TF1("fs","gaus(0) + ([3]*exp((x)/[4]) + [5]) * (0.5+0.5*TMath::Erf((x-[6])/[7]))");
+ fs->SetParName(0, "G_Const"); fs->SetParName(1, "G_Mean"); fs->SetParName(2, "G_Sigma");
+ fs->SetParName(3, "Exp_p0"); fs->SetParName(4, "Exp_p1"); fs->SetParName(5, "Exp_p2");
+ fs->SetParName(6, "Erf_p0"); fs->SetParName(7, "Erf_p1");
+//~
+ TF1 *fg1 = new TF1("fg1", "gaus(0)"); fg1->SetNpx(400);
+ TF1 *fe1 = new TF1("fe1", "[0]*exp((x)/[1]) + [2]");
+ TF1 *ferf1 = new TF1("ferf1", "[0]*(0.5+0.5*TMath::Erf((x-[1])/[2]))");
+ TF1 *fe1erf = new TF1("fe1erf", "([0]*exp((x)/[1]) + [2]) * (0.5+0.5*TMath::Erf((x-[3])/[4]))"); fe1erf->SetNpx(400);
+
+ double fitampl = hp1d->GetMaximum();
+ double fitcenter = hp1d->GetBinCenter(hp1d->GetMaximumBin());
+
+ fs->SetNpx(400);
+ fs->SetParameters(fitampl, fitcenter, 0.01, 1e2, -0.1, 1e1, 0, 0.05);
+
+ // G + Er + Ex
+ //fs->SetParLimits( 1, -0.1, 0.1);
+ //fs->SetParLimits( 2, 0.018, 0.5);
+ fs->SetParLimits( 4, -0.3, 0);
+ //fs->SetParLimits( 6, -1e-1, 1e-1);
+ fs->SetParLimits( 7, 0.04, 0.6);
+
+ //~ // G
+ //~ fs->SetParameters(fitampl/100., fitampl, fitcenter, 0.01);
+
+ hp1d->Fit(fs,"Q","",fitmin, fitmax);
+
+ //~ printf("Chi / NDF = %lf/%lf\n", fs->GetChisquare(), fs->GetNDF());
+
+ fg1->SetParameters(fs->GetParameter(0), fs->GetParameter(1), fs->GetParameter(2));
+ //~ fe1->SetParameters(fs->GetParameter(3), fs->GetParameter(4), fs->GetParameter(5));
+ //~ ferf1->SetParameters(1e4, fs->GetParameter(6), fs->GetParameter(7));
+ fe1erf->SetParameters(fs->GetParameter(3), fs->GetParameter(4), fs->GetParameter(5), fs->GetParameter(6), fs->GetParameter(7));
+
+ fg1->SetLineColor(kRed); fg1->SetLineWidth(1); fg1->SetLineStyle(1); fg1->SetRange(fitmin, fitmax); fg1->DrawCopy("SAME");
+ //~ fe1->SetLineColor(kBlue); fe1->SetLineWidth(1); fe1->SetLineStyle(1); fe1->SetRange(fitmin, fitmax); fe1->DrawCopy("SAME");
+ //~ ferf1->SetLineColor(kYellow); ferf1->SetLineWidth(1);ferf1->SetLineStyle(1);ferf1->SetRange(fitmin, fitmax);ferf1->DrawCopy("SAME");
+ fe1erf->SetLineColor(kBlue); fe1erf->SetLineWidth(1);fe1erf->SetLineStyle(1);fe1erf->SetRange(fitmin, fitmax);fe1erf->DrawCopy("SAME");
+
+ double HalfMax = fitampl/2.0;
+ double MinHalfMax = fs->GetX(HalfMax, -0.5, fitcenter);
+ double MaxHalfMax = fs->GetX(HalfMax, fitcenter, 1.5);
+ double FWHM = MaxHalfMax - MinHalfMax;
+ double sigmaFWHM = fs->GetParameter(2);
+ printf("Corrected %s resolution FWHM = %.1lf [ps]\n", hTitle, FWHM*1000);
+ //~ fprintf(fp,"%lf ", FWHM*1000);
+
+ sprintf(sbuff, "FWHM = %.0lf ps", FWHM*1000);
+ leg1->AddEntry((TF1*)fs->Clone(),sbuff, "L");
+ leg1->Draw();
+}
+
+// =======================================================================================================
+
+void plots2(char *fname="480", char *plopt="d", double fitcenter = 1190., double fitw = 70., double comhi_range_hi = 2100., int batch_q=0)
+{
+ char sbuff[256];
+
+ char *fitopt="crystal1";
+ double inmin=-10;
+ double inmax=10;
+ double Ecut_lo = 450.;
+ double Ecut_hi = 625.;
+
+
+ int printeps = 0;
+ int printgif=-1, double fitlo=1.0, double fithi=1.0;
+ int ch=0;
+ char fullname[256];
+
+ //get ROOT file with histograms
+ char fnameroot[1024];
+ TFile * rootfile;
+ TDirectory *dir;
+
+ sprintf(fnameroot, "root/%s.root", fname);
+ rootfile = (TFile *) gROOT->FindObject(fname);
+ if(rootfile==NULL) rootfile = new TFile(fnameroot);
+ if(rootfile==NULL) {
+ printf("Cannot open root file %s!!!\n",fnameroot);
+ return;
+ }
+ dir = (TDirectory*) rootfile;
+
+ DrSetDrawStyle();
+
+ TCanvas *c[64];
+ int cc=-1;
+ char hname[256], htitle[256];
+ TH1F *hp1d, *hp1dcut; TH2F *hp2d;
+
+ TLegend *leg[64];
+ int legi = -1;
+ TH1F *legentry[64];
+ int legentryi = -1;
+
+ TGraph *graph[16];
+ int igraph=-1;
+
+ int colarr[20] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, kOrange, 10,11,12,13,14,15,16,17,18,19};
+ int legsty[] = {1,7,2,3,9,6,9,5,6};
+
+ TF1 *fg = new TF1("fg", "gaus"); fg->SetNpx(300);
+
+ TF1 *fgg = new TF1("fgg", "gaus(0)+gaus(3)"); fg->SetNpx(300);
+ fgg->SetParName(0,"G1_Const"); fgg->SetParName(3,"G2_Const");
+ fgg->SetParName(1,"G1_Mean" ); fgg->SetParName(4,"G2_Mean" );
+ fgg->SetParName(2,"G1_Sigma"); fgg->SetParName(5,"G2_Sigma");
+
+ TF1 *fg3 = new TF1("fg3", "gaus(0)+gaus(3)+gaus(6)"); fg3->SetNpx(300);
+ fg3->SetParName(0,"G1_Const"); fg3->SetParName(3,"G2_Const"); fg3->SetParName(6,"G3_Const");
+ fg3->SetParName(1,"G1_Mean" ); fg3->SetParName(4,"G2_Mean" ); fg3->SetParName(7,"G3_Mean" );
+ fg3->SetParName(2,"G1_Sigma"); fg3->SetParName(5,"G2_Sigma"); fg3->SetParName(8,"G3_Sigma");
+
+ TF1 *fg4 = new TF1("fg4", "gaus(0)+gaus(3)+gaus(6)+gaus(9)"); fg4->SetNpx(300);
+ fg4->SetParName(0,"G1_Const"); fg4->SetParName(3,"G2_Const"); fg4->SetParName(6,"G3_Const"); fg4->SetParName(9,"G4_Const");
+ fg4->SetParName(1,"G1_Mean" ); fg4->SetParName(4,"G2_Mean" ); fg4->SetParName(7,"G3_Mean" ); fg4->SetParName(10,"G4_Mean" );
+ fg4->SetParName(2,"G1_Sigma"); fg4->SetParName(5,"G2_Sigma"); fg4->SetParName(8,"G3_Sigma"); fg4->SetParName(11,"G4_Sigma");
+
+ TF1 *fg5 = new TF1("fg5", "gaus(0)+gaus(3)+gaus(6)+gaus(9)+gaus(12)"); fg5->SetNpx(300);
+ fg5->SetParName(0,"G1_Const"); fg5->SetParName(3,"G2_Const"); fg5->SetParName(6,"G3_Const"); fg5->SetParName(9,"G4_Const"); fg5->SetParName(12,"G5_Const");
+ fg5->SetParName(1,"G1_Mean" ); fg5->SetParName(4,"G2_Mean" ); fg5->SetParName(7,"G3_Mean" ); fg5->SetParName(10,"G4_Mean" ); fg5->SetParName(13,"G5_Mean" );
+ fg5->SetParName(2,"G1_Sigma"); fg5->SetParName(5,"G2_Sigma"); fg5->SetParName(8,"G3_Sigma"); fg5->SetParName(11,"G4_Sigma"); fg5->SetParName(14,"G5_Sigma");
+
+// -------------------------------------------------------------------
+
+ if( strchr(plopt, 'a') != NULL ) {
+
+ //~ gStyle->SetOptStat(1111);
+ gStyle->SetOptStat(0);
+ gStyle->SetOptFit(0);
+
+ c[++cc] = new TCanvas("a", "a", 0, 0, 1200, 700);
+ c[cc]->Divide(2,2);
+
+ int draw_cuts = 1;
+ int rebin_tdcs = 0;
+
+ int ccccdi = 0;
+ int ich;
+
+// -------------------------- qdc 0 ----------------------------------
+ ich = 0;
+ (c[cc]->cd(++ccccdi))->SetLogy(1);
+ sprintf(hname, "hadc%d", ich);
+ hp1d = DrTH1F(dir, hname, "");
+ hp1d->SetTitle("MPPC 1;Charge [200 fC/bin]");
+ hp1d->GetXaxis()->SetRangeUser(0,2000);
+ //~ hp1d->GetYaxis()->SetRangeUser(0.9,hp1d->GetMaximum()*1.1);
+ hp1d->SetLineColor(kBlack);
+ hp1d->DrawClone();
+
+ if(draw_cuts) {
+ sprintf(hname, "hadc_cut%d", ich);
+ hp1dcut = DrTH1F(dir, hname, "");
+ hp1dcut->SetLineColor(kRed);
+ hp1dcut->DrawClone("SAME");
+
+ //~ sprintf(hname, "hadc_cut_2%d", ich);
+ //~ hp1dcut = DrTH1F(dir, hname, "");
+ //~ hp1dcut->SetLineColor(kGreen);
+ //~ hp1dcut->DrawClone("SAME");
+ }
+
+// -------------------------- TDC 0 ----------------------------------
+ (c[cc]->cd(++ccccdi))->SetLogy(1);
+ sprintf(hname, "htdc%d", ich);
+ hp1d = DrTH1F(dir, hname, "");
+ hp1d->SetTitle("MPPC 1;Time [ns]");
+ if(rebin_tdcs) hp1d->Rebin(rebin_tdcs);
+ //~ hp1d->GetXaxis()->SetRangeUser(0,22);
+ hp1d->GetXaxis()->SetRangeUser(20,34);
+ //~ hp1d->GetYaxis()->SetRangeUser(0.9,hp1d->GetMaximum()*1.1);
+ hp1d->SetLineColor(kBlack);
+ hp1d->DrawClone();
+
+ if(draw_cuts) {
+ sprintf(hname, "htdc_cut%d", ich);
+ hp1dcut = DrTH1F(dir, hname, "");
+ if(rebin_tdcs) hp1dcut->Rebin(rebin_tdcs);
+ hp1dcut->SetLineColor(kRed);
+ hp1dcut->DrawClone("SAME");
+
+ //~ sprintf(hname, "htdc_cut_2%d", ich);
+ //~ hp1dcut = DrTH1F(dir, hname, "");
+ //~ if(rebin_tdcs) hp1dcut->Rebin(rebin_tdcs);
+ //~ hp1dcut->SetLineColor(kGreen);
+ //~ hp1dcut->DrawClone("SAME");
+ }
+
+ // -------------------------- qdc 1 ----------------------------------
+ ich = 1;
+ (c[cc]->cd(++ccccdi))->SetLogy(1);
+ sprintf(hname, "hadc%d", ich);
+ hp1d = DrTH1F(dir, hname, "");
+ hp1d->SetTitle("MPPC 2;Charge [200 fC/bin]");
+ hp1d->GetXaxis()->SetRangeUser(0,2000);
+ //~ hp1d->GetYaxis()->SetRangeUser(0.9,hp1d->GetMaximum()*1.1);
+ hp1d->SetLineColor(kBlack);
+ hp1d->DrawClone();
+
+ if(draw_cuts) {
+ sprintf(hname, "hadc_cut%d", ich);
+ hp1dcut = DrTH1F(dir, hname, "");
+ hp1dcut->SetLineColor(kRed);
+ hp1dcut->DrawClone("SAME");
+
+ //~ sprintf(hname, "hadc_cut_2%d", ich);
+ //~ hp1dcut = DrTH1F(dir, hname, "");
+ //~ hp1dcut->SetLineColor(kGreen);
+ //~ hp1dcut->DrawClone("SAME");
+ }
+
+// -------------------------- TDC 1 ----------------------------------
+ (c[cc]->cd(++ccccdi))->SetLogy(1);
+ sprintf(hname, "htdc%d", ich);
+ hp1d = DrTH1F(dir, hname, "");
+ hp1d->SetTitle("MPPC 2;Time [ns]");
+ if(rebin_tdcs) hp1d->Rebin(rebin_tdcs);
+ //~ hp1d->GetXaxis()->SetRangeUser(0,22);
+ hp1d->GetXaxis()->SetRangeUser(20,34);
+ //~ hp1d->GetYaxis()->SetRangeUser(0.9,hp1d->GetMaximum()*1.1);
+ hp1d->SetLineColor(kBlack);
+ hp1d->DrawClone();
+
+ if(draw_cuts) {
+ sprintf(hname, "htdc_cut%d", ich);
+ hp1dcut = DrTH1F(dir, hname, "");
+ if(rebin_tdcs) hp1dcut->Rebin(rebin_tdcs);
+ hp1dcut->SetLineColor(kRed);
+ hp1dcut->DrawClone("SAME");
+
+ //~ sprintf(hname, "htdc_cut_2%d", ich);
+ //~ hp1dcut = DrTH1F(dir, hname, "");
+ //~ if(rebin_tdcs) hp1dcut->Rebin(rebin_tdcs);
+ //~ hp1dcut->SetLineColor(kGreen);
+ //~ hp1dcut->DrawClone("SAME");
+ }
+
+ sprintf(fullname, "gif/a_%s.gif", fname); c[cc]->SaveAs(fullname);
+ }
+
+// -------------------------------------------------------------------
+
+ if( strchr(plopt, 'q') != NULL ) {
+
+ gStyle->SetOptStat(1111);
+ gStyle->SetOptFit(0);
+
+ c[++cc] = new TCanvas("q", "q", 0, 0, 1200, 700);
+ c[cc]->Divide(3,2);
+
+ int draw_cuts = 1;
+ int rebin_tdcs = 1;
+
+ int ccccdi = 0;
+ int ich;
+/*
+ ich = 2;
+// -------------------------- qdc ref ----------------------------------
+ (c[cc]->cd(++ccccdi))->SetLogy(1);
+ sprintf(hname, "hadc%d", ich);
+ hp1d = DrTH1F(dir, hname, "");
+ //~ hp1d->GetXaxis()->SetRangeUser(0,100);
+ hp1d->GetYaxis()->SetRangeUser(0.9,hp1d->GetMaximum()*1.1);
+ hp1d->DrawClone();
+
+ sprintf(hname, "hadc_cut%d", ich);
+ hp1dcut = DrTH1F(dir, hname, "");
+ hp1dcut->SetLineColor(kRed);
+ hp1dcut->DrawClone("SAME");
+
+ sprintf(hname, "hadc_cut_2%d", ich);
+ hp1dcut = DrTH1F(dir, hname, "");
+ hp1dcut->SetLineColor(kGreen);
+ hp1dcut->DrawClone("SAME");
+
+// -------------------------- TDC ref ----------------------------------
+ (c[cc]->cd(++ccccdi))->SetLogy(1);
+ sprintf(hname, "htdc%d", ich);
+ hp1d = DrTH1F(dir, hname, "");
+ hp1d->Rebin(8);
+ hp1d->GetXaxis()->SetRangeUser(5,105);
+ hp1d->GetYaxis()->SetRangeUser(0.9,hp1d->GetMaximum()*1.1);
+ hp1d->DrawClone();
+
+ sprintf(hname, "htdc_cut%d", ich);
+ hp1dcut = DrTH1F(dir, hname, "");
+ hp1dcut->Rebin(8);
+ hp1dcut->SetLineColor(kRed);
+ hp1dcut->DrawClone("SAME");
+
+ sprintf(hname, "htdc_cut_2%d", ich);
+ hp1dcut = DrTH1F(dir, hname, "");
+ hp1dcut->Rebin(8);
+ hp1dcut->SetLineColor(kGreen);
+ hp1dcut->DrawClone("SAME");
+*/
+
+// -------------------------- TDC DIFF ----------------------------------
+ (c[cc]->cd(++ccccdi))->SetLogy(0);
+ sprintf(hname, "htdcdiff");
+ hp1d = DrTH1F(dir, hname, "");
+ hp1d->Rebin(rebin_tdcs);
+ hp1d->GetXaxis()->SetRangeUser(-15,15);
+ //~ hp1d->GetYaxis()->SetRangeUser(0.9,hp1d->GetMaximum()*2);
+ hp1d->GetYaxis()->SetRangeUser(0.,hp1d->GetMaximum()*1.1);
+ hp1d->DrawClone();
+
+ if(draw_cuts) {
+ sprintf(hname, "htdcdiff_cut");
+ hp1dcut = DrTH1F(dir, hname, "");
+ hp1dcut->Rebin(rebin_tdcs);
+ hp1dcut->SetLineColor(kRed);
+ hp1dcut->DrawClone("SAME");
+
+ sprintf(hname, "htdcdiff_cut_2");
+ hp1dcut = DrTH1F(dir, hname, "");
+ hp1dcut->Rebin(rebin_tdcs);
+ hp1dcut->SetLineColor(kGreen);
+ hp1dcut->DrawClone("SAME");
+ }
+
+// -------------------------- qdc MPPC ----------------------------------
+ ich = 0;
+ (c[cc]->cd(++ccccdi))->SetLogy(1);
+ sprintf(hname, "hadc%d", ich);
+ hp1d = DrTH1F(dir, hname, "");
+ hp1d->GetXaxis()->SetRangeUser(0,1500);
+ //~ hp1d->GetYaxis()->SetRangeUser(0.9,hp1d->GetMaximum()*1.1);
+ hp1d->DrawClone();
+
+ if(draw_cuts) {
+ sprintf(hname, "hadc_cut%d", ich);
+ hp1dcut = DrTH1F(dir, hname, "");
+ hp1dcut->SetLineColor(kRed);
+ hp1dcut->DrawClone("SAME");
+
+ sprintf(hname, "hadc_cut_2%d", ich);
+ hp1dcut = DrTH1F(dir, hname, "");
+ hp1dcut->SetLineColor(kGreen);
+ hp1dcut->DrawClone("SAME");
+ }
+
+// -------------------------- TDC MPPC ----------------------------------
+ (c[cc]->cd(++ccccdi))->SetLogy(1);
+ sprintf(hname, "htdc%d", ich);
+ hp1d = DrTH1F(dir, hname, "");
+ hp1d->Rebin(rebin_tdcs);
+ hp1d->GetXaxis()->SetRangeUser(0,20);
+ hp1d->GetYaxis()->SetRangeUser(0.9,hp1d->GetMaximum()*1.1);
+ hp1d->DrawClone();
+
+ if(draw_cuts) {
+ sprintf(hname, "htdc_cut%d", ich);
+ hp1dcut = DrTH1F(dir, hname, "");
+ hp1dcut->Rebin(rebin_tdcs);
+ hp1dcut->SetLineColor(kRed);
+ hp1dcut->DrawClone("SAME");
+
+ sprintf(hname, "htdc_cut_2%d", ich);
+ hp1dcut = DrTH1F(dir, hname, "");
+ hp1dcut->Rebin(rebin_tdcs);
+ hp1dcut->SetLineColor(kGreen);
+ hp1dcut->DrawClone("SAME");
+ }
+
+ // -------------------------- qdc MPPC ----------------------------------
+ ich = 1;
+ ccccdi++;
+ (c[cc]->cd(++ccccdi))->SetLogy(1);
+ sprintf(hname, "hadc%d", ich);
+ hp1d = DrTH1F(dir, hname, "");
+ hp1d->GetXaxis()->SetRangeUser(0,1500);
+ //~ hp1d->GetYaxis()->SetRangeUser(0.9,hp1d->GetMaximum()*1.1);
+ hp1d->DrawClone();
+
+ if(draw_cuts) {
+ sprintf(hname, "hadc_cut%d", ich);
+ hp1dcut = DrTH1F(dir, hname, "");
+ hp1dcut->SetLineColor(kRed);
+ hp1dcut->DrawClone("SAME");
+
+ sprintf(hname, "hadc_cut_2%d", ich);
+ hp1dcut = DrTH1F(dir, hname, "");
+ hp1dcut->SetLineColor(kGreen);
+ hp1dcut->DrawClone("SAME");
+ }
+
+// -------------------------- TDC MPPC ----------------------------------
+ (c[cc]->cd(++ccccdi))->SetLogy(1);
+ sprintf(hname, "htdc%d", ich);
+ hp1d = DrTH1F(dir, hname, "");
+ hp1d->Rebin(rebin_tdcs);
+ hp1d->GetXaxis()->SetRangeUser(0,20);
+ hp1d->GetYaxis()->SetRangeUser(0.9,hp1d->GetMaximum()*1.1);
+ hp1d->DrawClone();
+
+ if(draw_cuts) {
+ sprintf(hname, "htdc_cut%d", ich);
+ hp1dcut = DrTH1F(dir, hname, "");
+ hp1dcut->Rebin(rebin_tdcs);
+ hp1dcut->SetLineColor(kRed);
+ hp1dcut->DrawClone("SAME");
+
+ sprintf(hname, "htdc_cut_2%d", ich);
+ hp1dcut = DrTH1F(dir, hname, "");
+ hp1dcut->Rebin(rebin_tdcs);
+ hp1dcut->SetLineColor(kGreen);
+ hp1dcut->DrawClone("SAME");
+ }
+
+ sprintf(fullname, "gif/q_%s.gif", fname); c[cc]->SaveAs(fullname);
+ //~ sprintf(fullname, "%s_j2.eps", fname); c[cc]->SaveAs(fullname);
+
+ if(batch_q) gSystem->Exit(1);
+ }
+// -------------------------------------------------------------------
+
+ if( strchr(plopt, 'n') != NULL ) {
+
+ gStyle->SetOptStat("e");
+ //~ gStyle->SetOptFit(1);
+
+ c[++cc] = new TCanvas("d", "d", 0, 0, 900, 600);
+ //~ c[cc]->Divide(2,2);
+
+ int draw_cuts = 0;
+ int rebin_tdcs = 1;
+
+ double drawmin = -17;
+ double drawmax = +17;
+ double fitmin = -10;
+ double fitmax = 10;
+ double fitcenter = 0.0;
+ double HalfMax, MinHalfMax, MaxHalfMax, FWHM, FWHMc;
+
+ int ccccdi = 0;
+ int ich = 0;
+
+ TF1 *f_fit;
+
+ TF1 *fcg = new TF1("fcg", "pol0(0)+gaus(1)"); fcg->SetNpx(300);
+ fcg->SetParName(0,"Const"); fcg->SetParName(1,"G_Const");
+ fcg->SetParName(2,"G_Mean" ); fcg->SetParName(3,"G_Sigma" );
+
+ TF1 *fcgg = new TF1("fcgg", "pol0(0)+gaus(1)+gaus(4)"); fcgg->SetNpx(300);
+ fcgg->SetParName(0,"Const");
+ fcgg->SetParName(1,"G1_Const"); fcgg->SetParName(2,"G1_Mean" ); fcgg->SetParName(3,"G1_Sigma" );
+ fcgg->SetParName(4,"G2_Const"); fcgg->SetParName(5,"G2_Mean" ); fcgg->SetParName(6,"G2_Sigma" );
+
+ (c[cc]->cd(++ccccdi))->SetLogy(0);
+ sprintf(hname, "htdcdiff");
+ hp1d = DrTH1F(dir, hname, "");
+ //~ hp1d->Rebin(rebin_tdcs);
+ hp1d->SetLineColor(kBlack);
+ hp1d->GetXaxis()->SetRangeUser(drawmin,drawmax);
+ hp1d->GetYaxis()->SetRangeUser(0.0,hp1d->GetMaximum()*1.1);
+ hp1d->SetTitle(";Coincidence Time [ns];Counts");
+
+
+ f_fit = fcgg;
+ f_fit->SetParameters(hp1d->GetMaximum()*0.25,
+ hp1d->GetMaximum()*0.7, 0, 0.4,
+ hp1d->GetMaximum()*0.05, 0, 0.05);
+ f_fit->SetParLimits(0, 0, hp1d->GetMaximum());
+ f_fit->SetParLimits(1, 0, hp1d->GetMaximum());
+ f_fit->SetParLimits(2, fitmin,fitmax);
+ f_fit->SetParLimits(3, 0.2, 1);
+ f_fit->SetParLimits(4, 0, hp1d->GetMaximum());
+ f_fit->SetParLimits(5, fitmin,fitmax);
+ f_fit->SetParLimits(6, 0.02, 0.3);
+
+ //~ f_fit = fcgg;
+ //~ f_fit->SetParameters(hp1d->GetMaximum()*0.1,
+ //~ hp1d->GetMaximum()*0.5, 0, 0.05,
+ //~ hp1d->GetMaximum()*0.4, 0, 0.5);
+
+ //~ f_fit = fcg;
+ //~ f_fit->SetParameters(hp1d->GetMaximum()*0.1,
+ //~ hp1d->GetMaximum()*0.9, 0, 0.05);
+
+ f_fit->SetRange(fitmin,fitmax);
+ f_fit->SetLineWidth(1);
+ hp1d->Fit(f_fit, "Q", "", fitmin,fitmax);
+
+
+ HalfMax = f_fit->GetMaximum(fitmin, fitmax)/2.0;
+ MinHalfMax = f_fit->GetX(HalfMax, fitmin, fitcenter);
+ MaxHalfMax = f_fit->GetX(HalfMax, fitcenter, fitmax);
+ FWHM = MaxHalfMax - MinHalfMax;
+
+ HalfMax = (f_fit->GetMaximum(fitmin, fitmax) + f_fit->GetParameter(0))/2.0;
+ MinHalfMax = f_fit->GetX(HalfMax, fitmin, fitcenter);
+ MaxHalfMax = f_fit->GetX(HalfMax, fitcenter, fitmax);
+ FWHMc = MaxHalfMax - MinHalfMax;
+
+ //~ printf("FWHM = %lf ns | FWHMc = %lf ns\n", FWHM, FWHMc);
+ printf("FWHM (peak only) = %.3lf ns\n", FWHMc);
+
+
+ leg[++legi] = new TLegend(0.122768, 0.740418, 0.420759, 0.878049);
+ leg[legi]->SetFillColor(0); leg[legi]->SetBorderSize(1); leg[legi]->SetTextSize(0.03); leg[legi]->SetTextAlign(22);
+
+
+ for(int i=0; i<6; i++) fgg->SetParameter(i, f_fit->GetParameter(i+1));
+ //~ fgg->SetRange(drawmin, drawmax); fgg->SetNpx(300); fgg->SetLineColor(kBlue); fgg->SetLineWidth(1); fgg->DrawClone("LSAME");
+ double Icherenkovs = fgg->Integral(drawmin, drawmax);
+
+ double Iall = f_fit->Integral(fitmin, fitmax);
+ double Rsn = Icherenkovs/(Iall-Icherenkovs);
+
+ double Ientr = hp1d->GetEntries()*hp1d->GetBinWidth(1);
+ double Rsne = Icherenkovs/(Ientr-Icherenkovs);
+
+ double Ihist = hp1d->Integral(1, hp1d->GetNbinsX()-1)*hp1d->GetBinWidth(1);
+ double Rsnh = Icherenkovs/(Ihist-Icherenkovs);
+
+ //~ printf("ICherenkov = %lf | IAll = %lf | Ientr = %lf | Ihist = %lf\n", Icherenkovs, Iall, Ientr, Ihist);
+ //~ printf("TF1 -> S/N = %lf || TH1F(e) -> S/N = %lf || TH1F(i) -> S/N = %lf\n", Rsn, Rsne, Rsnh);
+ printf("S/N (vs. All) = %lf\n", Rsnh);
+
+ if(draw_cuts) {
+ sprintf(hname, "htdcdiff_cut");
+ hp1dcut = DrTH1F(dir, hname, "");
+ hp1dcut->Rebin(rebin_tdcs);
+ hp1dcut->SetLineColor(kRed);
+ hp1dcut->DrawClone("SAME");
+
+ sprintf(hname, "htdcdiff_cut_2");
+ hp1dcut = DrTH1F(dir, hname, "");
+ hp1dcut->Rebin(rebin_tdcs);
+ hp1dcut->SetLineColor(kGreen);
+ hp1dcut->DrawClone("SAME");
+ }
+
+//~ #define USE_NOISE_FILE
+
+#ifdef USE_NOISE_FILE
+ //get ROOT file with histograms
+ char fnameroot[1024];
+ TFile * rootfile2;
+ TDirectory *dir2;
+
+ sprintf(fname, "run054");
+ sprintf(fnameroot, "root/%s.root", fname);
+ rootfile2 = (TFile *) gROOT->FindObject(fname);
+ if(rootfile2==NULL) rootfile2 = new TFile(fnameroot);
+ if(rootfile2==NULL) {
+ printf("Cannot open root file 2 %s!!!\n",fnameroot);
+ return;
+ }
+ dir2 = (TDirectory*) rootfile2;
+
+ sprintf(hname, "htdcdiff");
+ hp1dcut = DrTH1F(dir2, hname, "");
+ hp1dcut->SetLineColor(kMagenta);
+ hp1dcut->DrawClone("SAME");
+
+ leg[legi]->AddEntry((TH1F*)hp1d->Clone(), "With source (30 min)", "L");
+ leg[legi]->AddEntry((TH1F*)hp1dcut->Clone(), "W/o source (30 min)", "L");
+ sprintf(fullname, "Fit FWHM = %.3lf ns", FWHMc);
+ leg[legi]->AddEntry((TF1*)f_fit->Clone(), fullname, "L");
+ leg[legi]->Draw();
+#endif
+
+ sprintf(fullname, "gif/n_%s.gif", fname); c[cc]->SaveAs(fullname);
+
+ if(batch_q) gSystem->Exit(1);
+ }
+// -------------------------------------------------------------------
+
+ if( strchr(plopt, 'f') != NULL ) {
+
+ DrSetDrawStyle(0.05);
+
+ gStyle->SetOptStat("e");
+ //~ gStyle->SetOptFit(1);
+
+ gStyle->SetPadRightMargin(0.03);
+ gStyle->SetPadTopMargin(0.05);
+ gStyle->SetPadBottomMargin(0.12);
+ gStyle->SetStatFontSize(0.05);
+ gStyle->SetStatX(0.97);
+ gStyle->SetStatY(0.95);
+
+ c[++cc] = new TCanvas("f", "f", 0, 460, 720, 400);
+ //~ c[cc]->Divide(2,2);
+
+ int draw_cuts = 0;
+ int rebin_tdcs = 1;
+
+ double drawmin = -10;
+ double drawmax = +10;
+ //~ double fitmin = inmin;
+ //~ double fitmax = inmax;
+ double fitmin = -10;
+ double fitmax = 10;
+ double fitcenter = 0.0;
+ double HalfMax, MinHalfMax, MaxHalfMax, FWHM, FWHMc;
+
+ int ccccdi = 0;
+ int ich = 0;
+
+ TF1 *f_fit;
+ TF1 *f_integrate;
+
+ TF1 *fc = new TF1("fc", "pol0(0)");
+
+ TF1 *fcg = new TF1("fcg", "pol0(0)+gaus(1)"); fcg->SetNpx(300);
+ fcg->SetParName(0,"Const"); fcg->SetParName(1,"G_Const");
+ fcg->SetParName(2,"G_Mean" ); fcg->SetParName(3,"G_Sigma" );
+
+ TF1 *fcgg = new TF1("fcgg", "pol0(0)+gaus(1)+gaus(4)"); fcgg->SetNpx(300);
+ fcgg->SetParName(0,"Const");
+ fcgg->SetParName(1,"G1_Const"); fcgg->SetParName(2,"G1_Mean" ); fcgg->SetParName(3,"G1_Sigma" );
+ fcgg->SetParName(4,"G2_Const"); fcgg->SetParName(5,"G2_Mean" ); fcgg->SetParName(6,"G2_Sigma" );
+
+ TF1 *fcggg = new TF1("fcggg", "pol0(0)+gaus(1)+gaus(4)+gaus(7)"); fcggg->SetNpx(300);
+ fcggg->SetParName(0,"Const");
+ fcggg->SetParName(1,"G1_Const"); fcggg->SetParName(2,"G1_Mean" ); fcggg->SetParName(3,"G1_Sigma" );
+ fcggg->SetParName(4,"G2_Const"); fcggg->SetParName(5,"G2_Mean" ); fcggg->SetParName(6,"G2_Sigma" );
+ fcggg->SetParName(7,"G3_Const"); fcggg->SetParName(8,"G3_Mean" ); fcggg->SetParName(9,"G3_Sigma" );
+
+ //~ TF1 *f_nocrystal = new TF1("f_nocrystal", "[0]*exp(-0.5*((x-[1])/(sqrt(2)*[2]))**2)+[3]*exp(-0.5*((x-[4])/(sqrt(2)*[5]))**2)+[6]*exp(-1*((x-[7])**2)/(2*(([2])**2+([5])**2)))+[8]*exp(-1*(((x-[9])**2)/(2*(([2])**2+([5])**2))))+[10]");
+ TF1 *f_nocrystal = new TF1("f_nocrystal", "[0]*([1]**2*TMath::Gaus(x,[2],sqrt(2)*[3],1)+(1-[1])**2*TMath::Gaus(x,[4],sqrt(2)*[5],1)+[1]*(1-[1])*TMath::Gaus(x,[6],sqrt([3]**2+[5]**2),1)+[1]*(1-[1])*TMath::Gaus(x,[7],sqrt([3]**2+[5]**2),1))+[8]");
+ f_nocrystal->SetParName(0, "const");
+ f_nocrystal->SetParName(1, "ratio");
+ f_nocrystal->SetParName(2, "WW_mean");
+ f_nocrystal->SetParName(3, "Window_sigma");
+ f_nocrystal->SetParName(4, "MM_mean");
+ f_nocrystal->SetParName(5, "MCP_sigma");
+ f_nocrystal->SetParName(6, "WM1_mean");
+ f_nocrystal->SetParName(7, "WM2_mean");
+ f_nocrystal->SetParName(8, "Constant");
+
+ //~ TF1 *f_crystal = new TF1("f_crystal", "[0]+[1]*([2]**2*(TMath::Gaus(x,[3],sqrt(2)*[4],1))+([5])**2*(TMath::Gaus(x,[6],sqrt(2)*[7],1))+(4*[5]/6)**2*(TMath::Gaus(x,[8],sqrt(2)*[9],1))+[2]*[5]*(TMath::Gaus(x,[10],sqrt([2]**2+[5]**2),1))+[5]*[2]*(TMath::Gaus(x,[11],sqrt([2]**2+[5]**2),1))+[2]*(4/6*[5])*(TMath::Gaus(x,[12],sqrt([2]**2+(4/6*[5])**2),1))+[2]*(4/6*[5])*(TMath::Gaus(x,[13],sqrt([2]**2+(4/6*[5])**2),1))+[5]*(4/6*[5])*(TMath::Gaus(x,[14],sqrt([5]**2+(4/6*[5])**2),1))+[5]*(4/6*[5])*(TMath::Gaus(x,[15],sqrt([5]**2+(4/6*[5])**2),1)))");
+ TF1 *f_crystal = new TF1("f_crystal", "[0]+[1]*([2]**2*(TMath::Gaus(x,[3],sqrt(2)*[4],1))+([5])**2*(TMath::Gaus(x,[6],sqrt(2)*[7],1))+(4*[5]/6)**2*(TMath::Gaus(x,[8],sqrt(2)*[9],1))+[2]*[5]*(TMath::Gaus(x,[10],sqrt([4]**2+[7]**2),1))+[5]*[2]*(TMath::Gaus(x,[11],sqrt([4]**2+[7]**2),1))+[2]*(4/6*[5])*(TMath::Gaus(x,[12],sqrt([4]**2+[9]**2),1))+[2]*(4/6*[5])*(TMath::Gaus(x,[13],sqrt([4]**2+[9]**2),1))+[5]*(4/6*[5])*(TMath::Gaus(x,[14],sqrt([7]**2+[9]**2),1))+[5]*(4/6*[5])*(TMath::Gaus(x,[15],sqrt([7]**2+[9]**2),1)))");
+ f_crystal->SetParName(0, "dark");
+ f_crystal->SetParName(1, "const");
+ f_crystal->SetParName(2, "Prob_Crystal");
+ f_crystal->SetParName(3, "CC_mean");
+ f_crystal->SetParName(4, "Crystal_sigma");
+ f_crystal->SetParName(5, "Prob_window");
+ f_crystal->SetParName(6, "WW_mean");
+ f_crystal->SetParName(7, "WW_sigma");
+ f_crystal->SetParName(8, "MM_mean");
+ f_crystal->SetParName(9, "MM_sigma");
+ f_crystal->SetParName(10, "CW1_mean");
+ f_crystal->SetParName(11, "CW2_mean");
+ f_crystal->SetParName(12, "CM1_mean");
+ f_crystal->SetParName(13, "CM2_mean");
+ f_crystal->SetParName(14, "WM1_mean");
+ f_crystal->SetParName(15, "WM2_mean");
+
+ //~ TF1 *f_crystal1 = new TF1("f_crystal1", "[0]+[1]*([2]**2*TMath::Gaus(x,[3],sqrt(2)*[4],1)+(1.-5./3*[2])**2*TMath::Gaus(x,[5],sqrt(2)*[6],1)+(4.*[2]/6.)**2*TMath::Gaus(x,[7],sqrt(2)*[8],1)+[2]*(1.-(5./3)*[2])*TMath::Gaus(x,[9],sqrt([4]**2+[6]**2),1)+(1.-(5./3)*[2])*[2]*TMath::Gaus(x,[10],sqrt([4]**2+[6]**2),1)+[2]*4./6.*[2]*TMath::Gaus(x,[11],sqrt([4]**2+[8]**2),1)+[2]*4/6.*[2]*TMath::Gaus(x,[12],sqrt([4]**2+[8]**2),1)+4./6*[2]*(1.-5./3*[2])*TMath::Gaus(x,[13],sqrt([6]**2+[8]**2),1)+(1.-5./3*[2])*4./6*[2]*TMath::Gaus(x,[14],sqrt([8]**2+[6]**2),1))");
+ TF1 *f_crystal1 = new TF1("f_crystal1", "[0]+[1]*([2]**2*TMath::Gaus(x,[3],sqrt(2)*[4],1)+(1.-(1.+[15])*[2])**2*TMath::Gaus(x,[5],sqrt(2)*[6],1)+([15]*[2])**2*TMath::Gaus(x,[7],sqrt(2)*[8],1)+[16]**2*[2]*(1.-(1+[15])*[2])*TMath::Gaus(x,[9],sqrt([4]**2+[6]**2),1)+[16]**2*(1.-(1+[15])*[2])*[2]*TMath::Gaus(x,[10],sqrt([4]**2+[6]**2),1)+[2]*[15]*[2]*TMath::Gaus(x,[11],sqrt([4]**2+[8]**2),1)+[2]*[15]*[2]*TMath::Gaus(x,[12],sqrt([4]**2+[8]**2),1)+[15]*[2]*(1.-(1+[15])*[2])*TMath::Gaus(x,[13],sqrt([6]**2+[8]**2),1)+(1.-(1.+[15])*[2])*[15]*[2]*TMath::Gaus(x,[14],sqrt([8]**2+[6]**2),1))");
+ f_crystal1->SetParName(0, "dark");
+ f_crystal1->SetParName(1, "const");
+ f_crystal1->SetParName(2, "Prob_Window");
+ f_crystal1->SetParName(3, "WW_mean");
+ f_crystal1->SetParName(4, "Window_sigma");
+ f_crystal1->SetParName(5, "CC_mean");
+ f_crystal1->SetParName(6, "Crystal_sigma");
+ f_crystal1->SetParName(7, "MM_mean");
+ f_crystal1->SetParName(8, "MCP_sigma");
+ f_crystal1->SetParName(9, "CW1_mean");
+ f_crystal1->SetParName(10, "CW2_mean");
+ f_crystal1->SetParName(11, "WM1_mean");
+ f_crystal1->SetParName(12, "WM2_mean");
+ f_crystal1->SetParName(13, "CM1_mean");
+ f_crystal1->SetParName(14, "CM2_mean");
+ f_crystal1->SetParName(15, "ratio_mcp/window");
+ f_crystal1->SetParName(16, "Sup._CW");
+
+ double ratio_r=0;
+
+ (c[cc]->cd(++ccccdi))->SetLogy(0);
+ sprintf(hname, "htdcdiff_cut");
+ hp1d = DrTH1F(dir, hname, "");
+ //~ hp1d->Rebin(rebin_tdcs);
+ hp1d->SetLineColor(kBlack);
+ hp1d->GetXaxis()->SetRangeUser(drawmin,drawmax);
+ hp1d->GetYaxis()->SetRangeUser(0.0,hp1d->GetMaximum()*1.1);
+ sprintf(fullname, ";Coincidence Time [ns];Counts");
+ hp1d->SetTitle(fullname);
+
+ if( strcmp(fitopt, "cgg")==0 ) {
+ f_fit = fcgg;
+ f_fit->SetParameters(hp1d->GetMaximum()*0.1,
+ hp1d->GetMaximum()*0.4, 0, 0.8,
+ hp1d->GetMaximum()*0.5, 0, 0.05);
+ f_fit->SetParLimits(0, 0, hp1d->GetMaximum());
+ f_fit->SetParLimits(1, 0, hp1d->GetMaximum());
+ f_fit->SetParLimits(2, fitmin,fitmax);
+ f_fit->SetParLimits(3, 0.05, 1);
+ f_fit->SetParLimits(4, 0, hp1d->GetMaximum());
+ f_fit->SetParLimits(5, fitmin,fitmax);
+ f_fit->SetParLimits(6, 0.01, 1);
+ } else if(strcmp(fitopt, "cggg")==0) {
+ f_fit = fcggg;
+ f_fit->SetParameters(hp1d->GetMaximum()*0.1,
+ hp1d->GetMaximum()*0.4, 0, 0.4,
+ hp1d->GetMaximum()*0.4, 0, 0.2,
+ hp1d->GetMaximum()*0.1, 0, 0.05);
+ f_fit->SetParLimits(0, 0, hp1d->GetMaximum());
+ f_fit->SetParLimits(1, 0, hp1d->GetMaximum());
+ f_fit->SetParLimits(2, fitmin,fitmax);
+ f_fit->SetParLimits(3, 0.01, 1);
+ f_fit->SetParLimits(4, 0, hp1d->GetMaximum());
+ f_fit->SetParLimits(5, fitmin,fitmax);
+ f_fit->SetParLimits(6, 0.05, 1);
+ f_fit->SetParLimits(7, 0, hp1d->GetMaximum());
+ f_fit->SetParLimits(8, fitmin,fitmax);
+ f_fit->SetParLimits(9, 0.2, 1);
+ } else if(strcmp(fitopt, "nocrystal")==0)
+ { f_fit = f_nocrystal;
+
+ //~ f_fit->SetParameters(4000,0.87,0.03,0.03,0.28,0.1,200,200,0.01);
+ f_fit->SetParameters(200,0.8,0.0,0.03,0.0,0.1,-0.13,0.13,10.16);
+ f_fit->SetParLimits(0,0,10000);
+ f_fit->SetParLimits(1,0,1);
+ f_fit->SetParLimits(2,-0.02,0.02);
+ f_fit->SetParLimits(3,0.01,0.3);
+ f_fit->SetParLimits(4,-0.02,0.02);
+ f_fit->SetParLimits(5,0,0.8);
+ f_fit->SetParLimits(6,-0.5,0.0);
+ f_fit->SetParLimits(7,0.0,0.5);
+ f_fit->SetParLimits(8,0.00,9000.5);
+ //~ f_fit->FixParameter(6, 100);
+ //~ f_fit->FixParameter(7, 100);
+ //~
+
+ } else if(strcmp(fitopt, "crystal")==0)
+ {
+ f_fit = f_crystal;
+ //~ f_fit->SetParameters(0.1,300,0.8,0,0.07,0.01,0,0.028,0,0.15,0,0,-0.2,0.2,-0.2,0.2);
+ f_fit->SetParameter(0, 0.1);
+ f_fit->SetParameter(1, 300);
+ f_fit->SetParameter(2, 0.8);
+ f_fit->SetParameter(3, 0.);
+ f_fit->SetParameter(4, 0.07);
+ f_fit->SetParameter(5, 0.01);
+ f_fit->SetParameter(6, 0.0);
+ f_fit->SetParameter(7, 0.028);
+ f_fit->SetParameter(8, 0.0);
+ f_fit->SetParameter(9, 0.15);
+ f_fit->SetParameter(10, 0.0);
+ f_fit->SetParameter(11, 0.0);
+ f_fit->SetParameter(12, -0.2);
+ f_fit->SetParameter(13, 0.2);
+ f_fit->SetParameter(14, -0.2);
+ f_fit->SetParameter(15, 0.2);
+ f_fit->SetParameter(15, 0.2);
+
+ f_fit->SetParLimits(0, 0, 10);
+ f_fit->SetParLimits(1, 0, 1000);
+ f_fit->SetParLimits(2, 0, 1);
+ f_fit->SetParLimits(3, -0.02, 0.02); f_fit->SetParLimits(4, 0, 0.3);
+ f_fit->SetParLimits(5, 0, 1); f_fit->SetParLimits(6, -0.02, 0.02);
+ f_fit->SetParLimits(7, 0, 0.035);
+ f_fit->SetParLimits(8, -0.02, 0.02);
+ f_fit->SetParLimits(9, 0, 0.2);
+ f_fit->SetParLimits(10, -0.02, 0.02);
+ f_fit->SetParLimits(11, -0.02, 0.02);
+ f_fit->SetParLimits(12, -0.04, 0);
+ f_fit->SetParLimits(13, 0, 0.04);
+ f_fit->SetParLimits(14, -0.04, 0);
+ f_fit->SetParLimits(15, 0, 0.04);
+
+ } else if(strcmp(fitopt, "crystal1")==0)
+ {
+ f_fit = f_crystal1;
+ //~ f_fit->SetParameters(0.1,300,0.8,0,0.07,0.01,0,0.028,0,0.15,0,0,-0.2,0.2,-0.2,0.2);
+ f_fit->SetParameter(0, 100.1);
+ f_fit->SetParameter(1, 1);
+ f_fit->SetParameter(2, 0.2); //prob. window
+ f_fit->SetParameter(3, 0.0);
+ f_fit->SetParameter(4, 0.02); // window sigma
+ f_fit->SetParameter(5, 0.0);
+ f_fit->SetParameter(6, 120/3.3/1000); //crystal sigma
+ f_fit->SetParameter(7, 0.0);
+ f_fit->SetParameter(8, 0.15); // mcp sigma
+ f_fit->SetParameter(9, -0.1825); //cw
+ f_fit->SetParameter(10, 0.1825);
+ f_fit->SetParameter(11, -0.2); //wm
+ f_fit->SetParameter(12, 0.2);
+ f_fit->SetParameter(13, -0.3); //cm
+ f_fit->SetParameter(14, 0.3);
+ f_fit->SetParameter(15, 1/0.6795 -1.);
+ f_fit->SetParameter(16, 0.1);
+ f_fit->SetParameter(1, hp1d->GetMaximum()/(f_fit->Eval(0)-f_fit->GetParameter(0)));
+
+
+ f_fit->SetParLimits(0, 0, 400);
+ f_fit->SetParLimits(1, 0, 100000);
+ f_fit->SetParLimits(2, 0, 1.);
+ f_fit->SetParLimits(3, -0.025, 0.025);
+ f_fit->SetParLimits(4, 0.02, 0.08);
+ f_fit->SetParLimits(5, -0.025, 0.025);
+ f_fit->SetParLimits(6, 0.01, 0.2);
+ f_fit->SetParLimits(7, -0.025, 0.025);
+ f_fit->SetParLimits(8, 0, 0.5);
+ f_fit->SetParLimits(9, -0.6, 0.02);
+ f_fit->SetParLimits(10, -0.02, 0.6);
+ f_fit->SetParLimits(11, -0.3, -0.1);
+ f_fit->SetParLimits(12, 0.1, 0.3);
+ f_fit->SetParLimits(13, -0.7, -0.1);
+ f_fit->SetParLimits(14, 0.1, 0.7);
+ f_fit->SetParLimits(15, 0, 0.999);
+ f_fit->SetParLimits(16, 0, 1);
+ f_fit->FixParameter(4,0.02668);
+ //~ f_fit->FixParameter(6,0.048);
+ f_fit->FixParameter(8,0.0877);
+ f_fit->FixParameter(11,-0.19);
+ f_fit->FixParameter(12,0.19);
+ //~
+ ratio_r = 1/0.6795 -1.;
+ //~ ratio_r = 1/0.8089 -1.;
+ f_fit->FixParameter(15,ratio_r);
+ //~ f_fit->FixParameter(16,1);
+ //~ f_fit->FixParameter(2,0.52);
+ //~ f_fit->FixParameter(6,170/3.3/1000);
+ //~ f_fit->FixParameter(3,0);
+ //~ f_fit->FixParameter(5,0);
+ //~ f_fit->FixParameter(7,0);
+
+ //~ cout<<"hogeeeeeeeeeeee "<<f_fit->GetParameter(1)*((1.-5./3.*(f_fit->GetParameter(2)))*(4./6.*(f_fit->GetParameter(2))))<<endl;
+ }
+ //~ f_fit->SetRange(fitmin,fitmax);
+ f_fit->SetRange(-10,10);
+ f_fit->SetLineWidth(1); f_fit->SetLineStyle(2);
+ f_fit->SetNpx(300);
+ //~ hp1d->Fit(f_fit, "QWW", "", fitmin,fitmax);
+ //~ hp1d->Fit(f_fit, "ILM+", "", -0.4,0.4);
+ //~
+ hp1d->Fit(f_fit, "LM+", "", -.5,.5);
+ //~ hp1d->Draw();
+ //~ f_fit->Draw("same"); //f_fit->SetLineColor(6);
+
+ f_fit->SetLineColor(1);
+ hp1d->GetXaxis()->SetRangeUser(-1.5,2);
+
+ gStyle->SetOptFit(1111);
+ double wmsigma = sqrt(f_fit->GetParameter(3)**2 + f_fit->GetParameter(5)**2);
+
+ double cm1sigma = sqrt(f_fit->GetParameter(6)**2 + f_fit->GetParameter(8)**2);
+ double wm1sigma = sqrt(f_fit->GetParameter(4)**2 + f_fit->GetParameter(8)**2);
+ double cw1sigma = sqrt(f_fit->GetParameter(6)**2 + f_fit->GetParameter(4)**2);
+
+
+ //kobayashi
+ TPaveStats* st1 = (TPaveStats*) hp1d->FindObject("stats");
+ st1->SetX1NDC(0.63); st1->SetX2NDC(0.99);
+ st1->SetY1NDC(0.24); st1->SetY2NDC(0.99);
+
+ double pw = f_fit->GetParameter(2);
+ double pm = f_fit->GetParameter(15)*f_fit->GetParameter(2);
+ double pc = 1-pw - pm;
+
+ double rate = pw**2 + pm**2 + 2*pw*pm;
+ double sumrate = pw**2+pm**2+pc**2+2*pw*pm+2*pm*pc+2*pc*pw*f_fit->GetParameter(16)**2;
+
+ cout<<"pw = "<<pw<<" pm = "<<pm<<" pc = "<<pc<<endl;
+ cout<<"rate = "<<rate<<" sumrate = "<<sumrate<<" rate/sumrate = "<<rate/sumrate<<endl;
+ cout<<" FWHM_sim = "<<f_fit->GetParameter(6)*sqrt(2)*2.35<<endl;
+
+ if(strcmp(fitopt, "nocrystal")==0)
+ {
+ //~ TF1 *fg_WW = new TF1("fg_WW","[0]*exp(-(x-[1])**2/2/([3]**2))/sqrt(2*3.141592*[2]*[2])");
+ //~ TF1 *fg_MM = new TF1("fg_MM","[0]*exp(-(x-[1])**2/2/([3]**2))/sqrt(2*3.141592*[2]*[2])");
+ //~ TF1 *fg_WM1 = new TF1("fg_WM1","[0]*exp(-(x-[1])**2/2/([3]**2))/sqrt(2*3.141592*[2]*[2])");
+ //~ TF1 *fg_WM2 = new TF1("fg_WM2","[0]*exp(-(x-[1])**2/2/([3]**2))/sqrt(2*3.141592*[2]*[2])");
+ TF1 *fg_WW = new TF1("fg_WW","[0]*TMath::Gaus(x,[1],[2],1)");fg_WW->SetNpx(300);
+ TF1 *fg_MM = new TF1("fg_MM","[0]*TMath::Gaus(x,[1],[2],1)");fg_MM->SetNpx(300);
+ TF1 *fg_WM1 = new TF1("fg_WM1","[0]*TMath::Gaus(x,[1],[2],1)"); fg_WM1->SetNpx(300);
+ TF1 *fg_WM2 = new TF1("fg_WM2","[0]*TMath::Gaus(x,[1],[2],1)"); fg_WM2->SetNpx(300);
+ fg_WW -> SetParameters(f_fit->GetParameter(1)**2*f_fit->GetParameter(0),f_fit->GetParameter(2),sqrt(2)*f_fit->GetParameter(3));
+ fg_MM -> SetParameters((1-f_fit->GetParameter(1))**2*f_fit->GetParameter(0),f_fit->GetParameter(4),sqrt(2)*f_fit->GetParameter(5));
+ fg_WM1 -> SetParameters(f_fit->GetParameter(0)*(1-f_fit->GetParameter(1))*f_fit->GetParameter(1),f_fit->GetParameter(6),wmsigma);
+ fg_WM2 -> SetParameters(f_fit->GetParameter(0)*(1-f_fit->GetParameter(1))*f_fit->GetParameter(1),f_fit->GetParameter(7),wmsigma);
+
+ fg_WW->Draw("sames"); fg_WW->SetLineColor(kYellow+1); fg_WW->SetRange(-10,10);
+ fg_MM->Draw("sames"); fg_MM->SetLineColor(kMagenta-7); fg_MM->SetRange(-10,10);
+ fg_WM1->Draw("sames"); fg_WM1->SetLineColor(kRed-4); fg_WM1->SetRange(-10,10);
+ fg_WM2->Draw("sames"); fg_WM2->SetLineColor(kRed-4); fg_WM2->SetRange(-10,10);
+
+ double integ_WW, integ_MM, integ_WM1, integ_WM2;
+ integ_WW = fg_WW->Integral(-4,4);
+ }
+ if(strcmp(fitopt, "crystal1")==0)
+ {
+ TF1 *fg_CC = new TF1("fg_CC","[0]*TMath::Gaus(x,[1],[2],1)"); fg_CC->SetNpx(300);
+ TF1 *fg_WW = new TF1("fg_WW","[0]*TMath::Gaus(x,[1],[2],1)"); fg_WW->SetNpx(300);
+ TF1 *fg_MM = new TF1("fg_MM","[0]*TMath::Gaus(x,[1],[2],1)"); fg_MM->SetNpx(300);
+ TF1 *fg_WM1 = new TF1("fg_WM1","[0]*TMath::Gaus(x,[1],[2],1)"); fg_WM1->SetNpx(300);
+ TF1 *fg_WM2 = new TF1("fg_WM2","[0]*TMath::Gaus(x,[1],[2],1)"); fg_WM2->SetNpx(300);
+ TF1 *fg_CW1 = new TF1("fg_CW1","[0]*TMath::Gaus(x,[1],[2],1)"); fg_CW1->SetNpx(300);
+ TF1 *fg_CW2 = new TF1("fg_CW2","[0]*TMath::Gaus(x,[1],[2],1)"); fg_CW2->SetNpx(300);
+ TF1 *fg_CM1 = new TF1("fg_CM1","[0]*TMath::Gaus(x,[1],[2],1)"); fg_CM1->SetNpx(300);
+ TF1 *fg_CM2 = new TF1("fg_CM2","[0]*TMath::Gaus(x,[1],[2],1)"); fg_CM2->SetNpx(300);
+
+
+ // normalize
+ fg_CC -> SetParameters((1.-(1+f_fit->GetParameter(15))*f_fit->GetParameter(2))**2*f_fit->GetParameter(1),f_fit->GetParameter(5),sqrt(2)*f_fit->GetParameter(6));
+ fg_WW -> SetParameters(f_fit->GetParameter(2)**2*f_fit->GetParameter(1),f_fit->GetParameter(3),sqrt(2)*f_fit->GetParameter(4));
+ fg_MM -> SetParameters((f_fit->GetParameter(15)*f_fit->GetParameter(2))**2*f_fit->GetParameter(1),f_fit->GetParameter(7),sqrt(2)*f_fit->GetParameter(8));
+ fg_WM1 -> SetParameters(f_fit->GetParameter(1)*(f_fit->GetParameter(15)*f_fit->GetParameter(2))*f_fit->GetParameter(2),f_fit->GetParameter(11),wm1sigma);
+ fg_WM2 -> SetParameters(f_fit->GetParameter(1)*(f_fit->GetParameter(15)*f_fit->GetParameter(2))*f_fit->GetParameter(2),f_fit->GetParameter(12),wm1sigma);
+ fg_CW1 -> SetParameters(f_fit->GetParameter(1)*f_fit->GetParameter(16)*(1.-(1+f_fit->GetParameter(15))*f_fit->GetParameter(2))*f_fit->GetParameter(2),f_fit->GetParameter(9),cw1sigma);
+ fg_CW2 -> SetParameters(f_fit->GetParameter(1)*f_fit->GetParameter(16)*(1.-(1+f_fit->GetParameter(15))*f_fit->GetParameter(2))*f_fit->GetParameter(2),f_fit->GetParameter(10),cw1sigma);
+ fg_CM1 -> SetParameters(f_fit->GetParameter(1)*(ratio_r*f_fit->GetParameter(2))*(1.-(1+f_fit->GetParameter(15))*f_fit->GetParameter(2)),f_fit->GetParameter(13),cm1sigma);
+ fg_CM2 -> SetParameters(f_fit->GetParameter(1)*(ratio_r*f_fit->GetParameter(2))*(1.-(1+f_fit->GetParameter(15))*f_fit->GetParameter(2)),f_fit->GetParameter(14),cm1sigma);
+
+ //non normalize
+ //~ fg_CC -> SetParameters((1.-5./3.*f_fit->GetParameter(2))**2*f_fit->GetParameter(1),f_fit->GetParameter(5),sqrt(2)*f_fit->GetParameter(6));
+ //~ fg_WW -> SetParameters(f_fit->GetParameter(2)**2*f_fit->GetParameter(1),f_fit->GetParameter(3),sqrt(2)*f_fit->GetParameter(4));
+ //~ fg_MM -> SetParameters((4./6.*f_fit->GetParameter(2))**2*f_fit->GetParameter(1),f_fit->GetParameter(7),sqrt(2)*f_fit->GetParameter(8));
+ //~ fg_WM1 -> SetParameters(f_fit->GetParameter(1)*(4./6.*f_fit->GetParameter(2))*f_fit->GetParameter(2),f_fit->GetParameter(11),wm1sigma);
+ //~ fg_WM2 -> SetParameters(f_fit->GetParameter(1)*(4./6.*f_fit->GetParameter(2))*f_fit->GetParameter(2),f_fit->GetParameter(12),wm1sigma);
+ //~ fg_CW1 -> SetParameters(f_fit->GetParameter(1)*(1.-5./3*f_fit->GetParameter(2))*f_fit->GetParameter(2),f_fit->GetParameter(9),cw1sigma);
+ //~ fg_CW2 -> SetParameters(f_fit->GetParameter(1)*(1.-5./3*f_fit->GetParameter(2))*f_fit->GetParameter(2),f_fit->GetParameter(10),cw1sigma);
+ //~ fg_CM1 -> SetParameters(f_fit->GetParameter(1)*(4./6.*f_fit->GetParameter(2))*(1.-5./3*f_fit->GetParameter(2)),f_fit->GetParameter(13),cm1sigma);
+ //~ fg_CM2 -> SetParameters(f_fit->GetParameter(1)*(4./6.*f_fit->GetParameter(2))*(1.-5./3*f_fit->GetParameter(2)),f_fit->GetParameter(14),cm1sigma);
+
+
+ fg_CC->Draw("sames"); fg_CC->SetLineColor(kCyan-5); fg_CC->SetRange(-10,10);
+ fg_WW->Draw("sames"); fg_WW->SetLineColor(kYellow+1); fg_WW->SetRange(-10,10);
+ fg_MM->Draw("sames"); fg_MM->SetLineColor(kMagenta-7); fg_MM->SetRange(-10,10);
+ fg_CW1->Draw("sames"); fg_CW1->SetLineColor(kGreen+2); fg_CW1->SetRange(-10,10);
+ fg_CW2->Draw("sames"); fg_CW2->SetLineColor(kGreen+2); fg_CW2->SetRange(-10,10);
+ fg_WM1->Draw("sames"); fg_WM1->SetLineColor(kRed-4); fg_WM1->SetRange(-10,10);
+ fg_WM2->Draw("sames"); fg_WM2->SetLineColor(kRed-4); fg_WM2->SetRange(-10,10);
+ fg_CM1->Draw("sames"); fg_CM1->SetLineColor(kBlue+2); fg_CM1->SetRange(-10,10);
+ fg_CM2->Draw("sames"); fg_CM2->SetLineColor(kBlue+2); fg_CM2->SetRange(-10,10);
+ }
+
+ HalfMax = f_fit->GetMaximum(fitmin, fitmax)/2.0;
+ MinHalfMax = f_fit->GetX(HalfMax, fitmin, fitcenter);
+ MaxHalfMax = f_fit->GetX(HalfMax, fitcenter, fitmax);
+ FWHM = MaxHalfMax - MinHalfMax;
+
+ HalfMax = (f_fit->GetMaximum(fitmin, fitmax) + f_fit->GetParameter(0))/2.0;
+ MinHalfMax = f_fit->GetX(HalfMax, fitmin, f_fit->GetMaximumX(fitmin, fitmax));
+ MaxHalfMax = f_fit->GetX(HalfMax, f_fit->GetMaximumX(fitmin, fitmax), fitmax);
+ FWHMc = MaxHalfMax - MinHalfMax;
+
+ printf("(f) HalfMax = %.3lf ns | MinHalfMax = %.3lf ns | MaxHalfMax = %.3lf ns\n", HalfMax, MinHalfMax, MaxHalfMax);
+ printf("(f) FWHM (peak only) = %.3lf ns\n", FWHMc);
+
+ f_integrate = fgg;
+ for(int i=0; i<6; i++) f_integrate->SetParameter(i, f_fit->GetParameter(i+1));
+ //~ for(int i=0; i<9; i++) f_integrate->SetParameter(i, f_fit->GetParameter(i+1));
+ //~ fgg->SetRange(drawmin, drawmax); fgg->SetNpx(300); fgg->SetLineColor(kBlue); fgg->SetLineWidth(1); fgg->DrawClone("LSAME");
+ double Icherenkovs = f_integrate->Integral(drawmin, drawmax)/hp1d->GetBinWidth(1);
+
+ double Iall = f_fit->Integral(fitmin, fitmax)/hp1d->GetBinWidth(1);
+ double Rsn = Icherenkovs/(Iall-Icherenkovs);
+
+ //~ double Ientr = hp1d->GetEntries()*hp1d->GetBinWidth(1);
+ double Ientr = hp1d->GetEntries();
+ double Rsne = Icherenkovs/(Ientr-Icherenkovs);
+
+ //~ double Ihist = hp1d->Integral(1, hp1d->GetNbinsX()-1)*hp1d->GetBinWidth(1);
+ double Ihist = hp1d->Integral(1, hp1d->GetNbinsX()-1);
+ double Rsnh = Icherenkovs/(Ihist-Icherenkovs);
+
+ double Icherenkovs_10ns = f_integrate->Integral(-10, 10)/hp1d->GetBinWidth(1);
+ fc->SetParameter(0, f_fit->GetParameter(0));
+ double Inoise_10ns = fc->Integral(-10, 10)/hp1d->GetBinWidth(1);
+ double R10ns = Icherenkovs_10ns/Inoise_10ns;
+
+ double Icherenkovs_4ns = f_integrate->Integral(-4, 4)/hp1d->GetBinWidth(1);
+ fc->SetParameter(0, f_fit->GetParameter(0));
+ double Inoise_4ns = fc->Integral(-4, 4)/hp1d->GetBinWidth(1);
+ double R4ns = Icherenkovs_4ns/Inoise_4ns;
+
+ double Icherenkovs_2ns = f_integrate->Integral(-2, 2)/hp1d->GetBinWidth(1);
+ fc->SetParameter(0, f_fit->GetParameter(0));
+ double Inoise_2ns = fc->Integral(-2, 2)/hp1d->GetBinWidth(1);
+ double R2ns = Icherenkovs_2ns/Inoise_2ns;
+
+ //~ printf("ICherenkov = %lf | IAll = %lf | Ientr = %lf | Ihist = %lf\n", Icherenkovs, Iall, Ientr, Ihist);
+ printf("Icherenkovs_4ns = %.0lf\n", Icherenkovs_4ns);
+ //~ printf("TF1 -> S/N = %lf || TH1F(e) -> S/N = %lf || TH1F(i) -> S/N = %lf\n", Rsn, Rsne, Rsnh);
+ //~ printf("S/N (All) = %lf\n", Rsnh);
+ printf("S/N (10ns) = %.2lf\n", R10ns);
+ printf("S/N (4 ns) = %.2lf\n", R4ns);
+ printf("S/N (2 ns) = %.2lf\n", R2ns);
+
+ leg[++legi] = new TLegend(0.12,0.4,0.43,0.925);
+ leg[legi]->SetFillColor(0); leg[legi]->SetBorderSize(1); leg[legi]->SetTextSize(0.05); leg[legi]->SetTextAlign(12);
+
+ sprintf(fullname, "FWHM_fit = %.0lf ps", 1000*FWHMc);
+ //~ leg[legi]->AddEntry((TF1*)f_fit->Clone(), fullname, "L");
+ leg[legi]->AddEntry((TF1*)f_fit->Clone(), fullname, "");
+
+ sprintf(fullname, "FWHM_c = %.0lf ps", 1000*f_fit->GetParameter(6)*2.35*sqrt(2));
+ leg[legi]->AddEntry((TF1*)f_fit->Clone(), fullname, "");
+
+ //~ sprintf(fullname, "S/N (#pm10ns) = %.1lf", R10ns);
+ //~ leg[legi]->AddEntry((TF1*)f_fit->Clone(), fullname, "");
+ //~ sprintf(fullname, "S/N (#pm 4ns) = %.1lf", R4ns);
+ //~ leg[legi]->AddEntry((TF1*)f_fit->Clone(), fullname, "");
+ //~ sprintf(fullname, "S/N (#pm 2ns) = %.1lf", R2ns);
+ //~ leg[legi]->AddEntry((TF1*)f_fit->Clone(), fullname, "");
+
+ //kobayashi
+ sprintf(fullname, "R_w = %.2f" , pw);
+ leg[legi]->AddEntry((TF1*)f_fit->Clone(), fullname, "");
+ sprintf(fullname, "R_m = %.2f" , pm);
+ leg[legi]->AddEntry((TF1*)f_fit->Clone(), fullname, "");
+ sprintf(fullname, "R_c = %.2f" , pc);
+ leg[legi]->AddEntry((TF1*)f_fit->Clone(), fullname, "");
+ sprintf(fullname, "R_w&m = %.2f" , rate);
+ leg[legi]->AddEntry((TF1*)f_fit->Clone(), fullname, "");
+ sprintf(fullname, "R_sum = %.2f" , sumrate);
+ leg[legi]->AddEntry((TF1*)f_fit->Clone(), fullname, "");
+ sprintf(fullname, "R_w&m/sum = %.2f" , rate/sumrate);
+ leg[legi]->AddEntry((TF1*)f_fit->Clone(), fullname, "");
+
+
+ leg[legi]->Draw();
+
+ if(draw_cuts) {
+ sprintf(hname, "htdcdiff_cut");
+ hp1dcut = DrTH1F(dir, hname, "");
+ hp1dcut->Rebin(rebin_tdcs);
+ hp1dcut->SetLineColor(kRed);
+ hp1dcut->DrawClone("SAME");
+
+ sprintf(hname, "htdcdiff_cut_2");
+ hp1dcut = DrTH1F(dir, hname, "");
+ hp1dcut->Rebin(rebin_tdcs);
+ hp1dcut->SetLineColor(kGreen);
+ hp1dcut->DrawClone("SAME");
+ }
+
+ sprintf(fullname, "gif/f_%s.gif", fname); c[cc]->SaveAs(fullname);
+ sprintf(fullname, "eps/f_%s.eps", fname); c[cc]->SaveAs(fullname);
+ cout<< "maximum x value = " << hp1d->GetXaxis()->GetBinCenter( hp1d->GetMaximumBin())<<endl;
+ if(batch_q) gSystem->Exit(1);
+ }
+
+// -------------------------------------------------------------------
+
+ if( strchr(plopt, 'd') != NULL ) {
+
+ DrSetDrawStyle(0.05);
+
+ gStyle->SetOptStat("e");
+ //~ gStyle->SetOptStat(0);
+ gStyle->SetOptFit(1);
+ //~ gStyle->SetOptFit(0);
+
+ gStyle->SetPadRightMargin(0.03);
+ gStyle->SetPadTopMargin(0.05);
+ gStyle->SetPadBottomMargin(0.12);
+ gStyle->SetStatFontSize(0.05);
+ gStyle->SetStatX(0.97);
+ gStyle->SetStatY(0.95);
+
+ c[++cc] = new TCanvas("d", "d", 0, 0, 720, 400);
+ //~ c[cc]->Divide(2,2);
+
+ int draw_cuts = 0;
+ int rebin_tdcs = 1;
+
+ double drawmin = -10;
+ double drawmax = +10;
+ //~ double fitmin = inmin;
+ //~ double fitmax = inmax;
+ double fitmin = -10;
+ double fitmax = 10;
+ double fitcenter = 0.0;
+ double HalfMax, MinHalfMax, MaxHalfMax, FWHM, FWHMc;
+
+ int ccccdi = 0;
+ int ich = 0;
+
+ TF1 *f_fit;
+ TF1 *f_integrate;
+
+ TF1 *fc = new TF1("fc", "pol0(0)");
+
+ TF1 *fcg = new TF1("fcg", "pol0(0)+gaus(1)"); fcg->SetNpx(300);
+ fcg->SetParName(0,"Const"); fcg->SetParName(1,"G_Const");
+ fcg->SetParName(2,"G_Mean" ); fcg->SetParName(3,"G_Sigma" );
+
+ TF1 *fcgg = new TF1("fcgg", "pol0(0)+gaus(1)+gaus(4)"); fcgg->SetNpx(300);
+ fcgg->SetParName(0,"Const");
+ fcgg->SetParName(1,"G1_Const"); fcgg->SetParName(2,"G1_Mean" ); fcgg->SetParName(3,"G1_Sigma" );
+ fcgg->SetParName(4,"G2_Const"); fcgg->SetParName(5,"G2_Mean" ); fcgg->SetParName(6,"G2_Sigma" );
+
+ TF1 *fcggg = new TF1("fcggg", "pol0(0)+gaus(1)+gaus(4)+gaus(7)"); fcggg->SetNpx(300);
+ fcggg->SetParName(0,"Const");
+ fcggg->SetParName(1,"G1_Const"); fcggg->SetParName(2,"G1_Mean" ); fcggg->SetParName(3,"G1_Sigma" );
+ fcggg->SetParName(4,"G2_Const"); fcggg->SetParName(5,"G2_Mean" ); fcggg->SetParName(6,"G2_Sigma" );
+ fcggg->SetParName(7,"G3_Const"); fcggg->SetParName(8,"G3_Mean" ); fcggg->SetParName(9,"G3_Sigma" );
+
+ (c[cc]->cd(++ccccdi))->SetLogy(0);
+ //~ sprintf(hname, "htdcdiff");
+ sprintf(hname, "htdcdiff_cut");
+ hp1d = DrTH1F(dir, hname, "");
+ //~ hp1d->Rebin(rebin_tdcs);
+ hp1d->SetLineColor(kBlack);
+ hp1d->GetXaxis()->SetRangeUser(drawmin,drawmax);
+ hp1d->GetYaxis()->SetRangeUser(0.0,hp1d->GetMaximum()*1.1);
+ //~ hp1d->GetYaxis()->SetRangeUser(0.0,hp1d->GetMaximum()*2);
+ sprintf(fullname, ";Coincidence Time [ns];Counts");
+ hp1d->SetTitle(fullname);
+
+ //kobayashi
+ //~ fitmin = hp1d->GetXaxis()->GetBinCenter(hp1d->GetMaximumBin()) - hp1d->GetRMS()/15;
+ //~ fitmax = hp1d->GetXaxis()->GetBinCenter(hp1d->GetMaximumBin()) + hp1d->GetRMS()/15;
+
+ //~ if( strcmp(fname, "run000")==0 ) {
+ //~ f_fit = fcg;
+ //~ f_fit->SetParameters(hp1d->GetMaximum()*0.1,
+ //~ hp1d->GetMaximum()*0.9, 0, 0.05);
+ //~ } else if( strcmp(fname, "run061")==0 ||
+ //~ strcmp(fname, "run062")==0 ||
+ //~ strcmp(fname, "run063")==0 ||
+ //~ strcmp(fname, "run064")==0 ||
+ //~ strcmp(fname, "run065")==0) {
+ //~ f_fit = fcgg;
+ //~ f_fit->SetParameters(hp1d->GetMaximum()*0.1,
+ //~ hp1d->GetMaximum()*0.5, 0, 0.05,
+ //~ hp1d->GetMaximum()*0.4, 0, 0.5);
+ //~ } else {
+ //~ f_fit = fcgg;
+ //~ f_fit->SetParameters(hp1d->GetMaximum()*0.25,
+ //~ hp1d->GetMaximum()*0.7, 0, 0.4,
+ //~ hp1d->GetMaximum()*0.05, 0, 0.05);
+ //~ f_fit->SetParLimits(0, 0, hp1d->GetMaximum());
+ //~ f_fit->SetParLimits(1, 0, hp1d->GetMaximum());
+ //~ f_fit->SetParLimits(2, fitmin,fitmax);
+ //~ f_fit->SetParLimits(3, 0.2, 1);
+ //~ f_fit->SetParLimits(4, 0, hp1d->GetMaximum());
+ //~ f_fit->SetParLimits(5, fitmin,fitmax);
+ //~ if( strcmp(fname, "run059")==0 ||
+ //~ strcmp(fname, "run060")==0)
+ //~ f_fit->SetParLimits(6, 0.02, 0.3);
+ //~ else
+ //~ f_fit->SetParLimits(6, 0.02, 0.2);
+ //~
+ //~ }
+
+ if( strcmp(fitopt, "cgg")==0 ) {
+ f_fit = fcgg;
+ f_fit->SetParameters(hp1d->GetMaximum()*0.1,
+ hp1d->GetMaximum()*0.4, 0, 0.9,
+ hp1d->GetMaximum()*0.5, 0, 0.05);
+ f_fit->SetParLimits(0, 0, hp1d->GetMaximum());
+ f_fit->SetParLimits(1, hp1d->GetMaximum()*0.01, hp1d->GetMaximum());
+ f_fit->SetParLimits(2, fitmin,fitmax);
+ f_fit->SetParLimits(3, 0.05, 1);
+ f_fit->SetParLimits(4, hp1d->GetMaximum()*0.01, hp1d->GetMaximum());
+ f_fit->SetParLimits(5, fitmin,fitmax);
+ f_fit->SetParLimits(6, 0.01, 1);
+ } else if(strcmp(fitopt, "cggg")==0) {
+ f_fit = fcggg;
+ //original
+ //~ f_fit->SetParameters(hp1d->GetMaximum()*0.01,
+ //~ hp1d->GetMaximum()*0.4, 0, 0.4,
+ //~ hp1d->GetMaximum()*0.4, 0, 0.2,
+ //~ hp1d->GetMaximum()*0.1, 0, 0.05);
+ //kobayashi
+ double init_mean = hp1d->GetXaxis()->GetBinCenter(hp1d->GetMaximumBin());
+ f_fit->SetParameters(hp1d->GetMaximum()*0.0001,
+ hp1d->GetMaximum()*0.01, init_mean , 0.04,
+ hp1d->GetMaximum()*0.01, init_mean + 0.2, 0.03,
+ hp1d->GetMaximum()*0.01, init_mean - 0.2, 0.03);
+ f_fit->SetParLimits(0, 0, hp1d->GetMaximum());
+ f_fit->SetParLimits(1, 0, hp1d->GetMaximum());
+ f_fit->SetParLimits(2, fitmin,fitmax);
+ f_fit->SetParLimits(3, 0.001, 1);
+ f_fit->SetParLimits(4, hp1d->GetMaximum()*0.1, hp1d->GetMaximum());
+ f_fit->SetParLimits(5, fitmin,fitmax);
+ f_fit->SetParLimits(6, 0.005, 3);
+ f_fit->SetParLimits(7, hp1d->GetMaximum()*0.1, hp1d->GetMaximum());
+ f_fit->SetParLimits(8, fitmin,fitmax);
+ f_fit->SetParLimits(9, 0.02, 5);
+ } else if(strcmp(fitopt, "gg")==0) {
+ f_fit = fgg;
+ f_fit->SetParameters(hp1d->GetMaximum()*0.4, 0, 0.9,
+ hp1d->GetMaximum()*0.5, 0, 0.05);
+ f_fit->SetParLimits(0, hp1d->GetMaximum()*0.01, hp1d->GetMaximum());
+ f_fit->SetParLimits(1, fitmin,fitmax);
+ f_fit->SetParLimits(2, 0.05, 1);
+ f_fit->SetParLimits(3, hp1d->GetMaximum()*0.01, hp1d->GetMaximum());
+ f_fit->SetParLimits(4, fitmin,fitmax);
+ f_fit->SetParLimits(5, 0.01, 1);
+ }
+
+ f_fit->SetRange(fitmin,fitmax);
+ f_fit->SetLineWidth(1); f_fit->SetLineStyle(9);
+ hp1d->Fit(f_fit, "QWW", "", fitmin,fitmax);
+ //~ hp1d->Fit(f_fit, "QWW", "", -0.5,+0.5);
+
+ //~ fg->SetRange(fitmin,fitmax); fg->SetLineWidth(1.0);
+ //~ fg->SetParameters(f_fit->GetParameter(0+1), f_fit->GetParameter(1+1), f_fit->GetParameter(2+1)); fg->SetLineColor(kMagenta); fg->DrawCopy("LSAME");
+ //~ fg->SetParameters(f_fit->GetParameter(0+4), f_fit->GetParameter(1+4), f_fit->GetParameter(2+4)); fg->SetLineColor(kGreen); fg->DrawCopy("LSAME");
+ //~ fg->SetParameters(f_fit->GetParameter(0+7), f_fit->GetParameter(1+7), f_fit->GetParameter(2+7)); fg->SetLineColor(kYellow); fg->DrawCopy("LSAME");
+
+
+ HalfMax = f_fit->GetMaximum(fitmin, fitmax)/2.0;
+ MinHalfMax = f_fit->GetX(HalfMax, fitmin, fitcenter);
+ MaxHalfMax = f_fit->GetX(HalfMax, fitcenter, fitmax);
+ FWHM = MaxHalfMax - MinHalfMax;
+
+ HalfMax = (f_fit->GetMaximum(fitmin, fitmax) + f_fit->GetParameter(0))/2.0;
+ MinHalfMax = f_fit->GetX(HalfMax, fitmin, f_fit->GetMaximumX(fitmin, fitmax));
+ MaxHalfMax = f_fit->GetX(HalfMax, f_fit->GetMaximumX(fitmin, fitmax), fitmax);
+ FWHMc = MaxHalfMax - MinHalfMax;
+
+ //~ printf("FWHM = %lf ns | FWHMc = %lf ns\n", FWHM, FWHMc);
+ printf("(d) FWHM (peak only) = %.3lf ns\n", FWHMc);
+
+ f_integrate = fgg;
+ for(int i=0; i<6; i++) f_integrate->SetParameter(i, f_fit->GetParameter(i+1));
+ //~ for(int i=0; i<9; i++) f_integrate->SetParameter(i, f_fit->GetParameter(i+1));
+ //~ fgg->SetRange(drawmin, drawmax); fgg->SetNpx(300); fgg->SetLineColor(kBlue); fgg->SetLineWidth(1); fgg->DrawClone("LSAME");
+ double Icherenkovs = f_integrate->Integral(drawmin, drawmax)/hp1d->GetBinWidth(1);
+
+ double Iall = f_fit->Integral(fitmin, fitmax)/hp1d->GetBinWidth(1);
+ double Rsn = Icherenkovs/(Iall-Icherenkovs);
+
+ //~ double Ientr = hp1d->GetEntries()*hp1d->GetBinWidth(1);
+ double Ientr = hp1d->GetEntries();
+ double Rsne = Icherenkovs/(Ientr-Icherenkovs);
+
+ //~ double Ihist = hp1d->Integral(1, hp1d->GetNbinsX()-1)*hp1d->GetBinWidth(1);
+ double Ihist = hp1d->Integral(1, hp1d->GetNbinsX()-1);
+ double Rsnh = Icherenkovs/(Ihist-Icherenkovs);
+
+ double Icherenkovs_10ns = f_integrate->Integral(-10, 10)/hp1d->GetBinWidth(1);
+ fc->SetParameter(0, f_fit->GetParameter(0));
+ double Inoise_10ns = fc->Integral(-10, 10)/hp1d->GetBinWidth(1);
+ double R10ns = Icherenkovs_10ns/Inoise_10ns;
+
+ double Icherenkovs_4ns = f_integrate->Integral(-4, 4)/hp1d->GetBinWidth(1);
+ fc->SetParameter(0, f_fit->GetParameter(0));
+ double Inoise_4ns = fc->Integral(-4, 4)/hp1d->GetBinWidth(1);
+ double R4ns = Icherenkovs_4ns/Inoise_4ns;
+
+ double Icherenkovs_2ns = f_integrate->Integral(-2, 2)/hp1d->GetBinWidth(1);
+ fc->SetParameter(0, f_fit->GetParameter(0));
+ double Inoise_2ns = fc->Integral(-2, 2)/hp1d->GetBinWidth(1);
+ double R2ns = Icherenkovs_2ns/Inoise_2ns;
+
+ //~ printf("ICherenkov = %lf | IAll = %lf | Ientr = %lf | Ihist = %lf\n", Icherenkovs, Iall, Ientr, Ihist);
+ printf("Icherenkovs_4ns = %.0lf\n", Icherenkovs_4ns);
+ //~ printf("TF1 -> S/N = %lf || TH1F(e) -> S/N = %lf || TH1F(i) -> S/N = %lf\n", Rsn, Rsne, Rsnh);
+ //~ printf("S/N (All) = %lf\n", Rsnh);
+ printf("S/N (10ns) = %.2lf\n", R10ns);
+ printf("S/N (4 ns) = %.2lf\n", R4ns);
+ printf("S/N (2 ns) = %.2lf\n", R2ns);
+
+//~ #define USE_NOISE_FILE
+
+#ifdef USE_NOISE_FILE
+ //get ROOT file with histograms
+ char fnameroot[1024];
+ TFile * rootfile2;
+ TDirectory *dir2;
+
+ //~ sprintf(fname, "run054");
+ sprintf(fname, "run_309");
+ sprintf(fnameroot, "root/%s.root", fname);
+ rootfile2 = (TFile *) gROOT->FindObject(fname);
+ if(rootfile2==NULL) rootfile2 = new TFile(fnameroot);
+ if(rootfile2==NULL) {
+ printf("Cannot open root file 2 %s!!!\n",fnameroot);
+ return;
+ }
+ dir2 = (TDirectory*) rootfile2;
+
+ sprintf(hname, "htdcdiff");
+ hp1dcut = DrTH1F(dir2, hname, "");
+ hp1dcut->SetLineColor(40);
+ hp1dcut->SetLineStyle(2);
+ hp1dcut->DrawClone("SAME");
+
+ leg[++legi] = new TLegend(0.125,0.5,0.425,0.925);
+ leg[legi]->SetFillColor(0); leg[legi]->SetBorderSize(1); leg[legi]->SetTextSize(0.05); leg[legi]->SetTextAlign(12);
+
+ leg[legi]->AddEntry((TH1F*)hp1d->Clone(), "With source", "L");
+ leg[legi]->AddEntry((TH1F*)hp1dcut->Clone(), "W/o source", "L");
+#else
+ leg[++legi] = new TLegend(0.125,0.625,0.425,0.925);
+ leg[legi]->SetFillColor(0); leg[legi]->SetBorderSize(1); leg[legi]->SetTextSize(0.05); leg[legi]->SetTextAlign(12);
+#endif
+
+ sprintf(fullname, "FWHM = %.0lf ps", 1000*FWHMc);
+ leg[legi]->AddEntry((TF1*)f_fit->Clone(), fullname, "L");
+ sprintf(fullname, "S/N (#pm10ns) = %.1lf", R10ns);
+ leg[legi]->AddEntry((TF1*)f_fit->Clone(), fullname, "");
+ sprintf(fullname, "S/N (#pm 4ns) = %.1lf", R4ns);
+ leg[legi]->AddEntry((TF1*)f_fit->Clone(), fullname, "");
+ sprintf(fullname, "S/N (#pm 2ns) = %.1lf", R2ns);
+ leg[legi]->AddEntry((TF1*)f_fit->Clone(), fullname, "");
+ leg[legi]->Draw();
+
+ if(draw_cuts) {
+ sprintf(hname, "htdcdiff_cut");
+ hp1dcut = DrTH1F(dir, hname, "");
+ hp1dcut->Rebin(rebin_tdcs);
+ hp1dcut->SetLineColor(kRed);
+ hp1dcut->DrawClone("SAME");
+
+ sprintf(hname, "htdcdiff_cut_2");
+ hp1dcut = DrTH1F(dir, hname, "");
+ hp1dcut->Rebin(rebin_tdcs);
+ hp1dcut->SetLineColor(kGreen);
+ hp1dcut->DrawClone("SAME");
+ }
+
+ sprintf(fullname, "gif/d_%s.gif", fname); c[cc]->SaveAs(fullname);
+ sprintf(fullname, "eps/d_%s.eps", fname); c[cc]->SaveAs(fullname);
+
+ if(batch_q) gSystem->Exit(1);
+ }
+
+// -------------------------------------------------------------------
+
+ if( strchr(plopt, 'c') != NULL ) {
+
+ //~ gStyle->SetOptStat(1111);
+ //~ gStyle->SetOptFit(0);
+
+ c[++cc] = new TCanvas("c", "c", 0, 0, 900, 700);
+ //~ c[cc]->Divide(2,2);
+
+ int ccccdi = 0;
+
+ (c[cc]->cd(++ccccdi))->SetLogz(1);
+ sprintf(hname, "htdccor");
+ hp2d = DrTH2F(dir, hname, "");
+ //~ hp2d->GetYaxis()->SetRangeUser(0,1500);
+ //~ sprintf(fullname, "%s;QDC Reference 1275 keV; QDC Reference Coincidence", fname);
+ //~ hp2d->SetTitle(fullname);
+ hp2d->DrawClone("COLZ");
+
+ //~ (c[cc]->cd(++ccccdi))->SetLogz(1);
+ //~ sprintf(hname, "hcor%d",0);
+ //~ hp2d = DrTH2F(dir, hname, "");
+ //~ hp2d->DrawClone("COLZ");
+ //~
+ //~ (c[cc]->cd(++ccccdi))->SetLogz(1);
+ //~ sprintf(hname, "hcor%d",1);
+ //~ hp2d = DrTH2F(dir, hname, "");
+ //~ hp2d->DrawClone("COLZ");
+ //~
+ //~
+ //~ (c[cc]->cd(++ccccdi))->SetLogz(1);
+ //~ sprintf(hname, "hdiffcor_%d_%d",0,1);
+ //~ hp2d = DrTH2F(dir, hname, "");
+ //~ hp2d->DrawClone("COLZ");
+ //~
+ //~ (c[cc]->cd(++ccccdi))->SetLogz(1);
+ //~ sprintf(hname, "hdiffcor_%d_%d",1,0);
+ //~ hp2d = DrTH2F(dir, hname, "");
+ //~ hp2d->DrawClone("COLZ");
+
+ sprintf(fullname, "gif/c_%s.gif", fname); c[cc]->SaveAs(fullname);
+ }
+
+// -------------------------------------------------------------------------------
+// -------------------------------------------------------------------
+
+ if( strchr(plopt, 't') != NULL ) {
+
+ gStyle->SetOptStat(1111);
+ //~ gStyle->SetOptFit(0);
+
+ c[++cc] = new TCanvas("c", "c", 0, 0, 700, 400);
+ //~ c[cc]->Divide(2,2);
+
+ double drawmin = -1;
+ double drawmax = 2;
+ double fitmin = -1;
+ double fitmax = 0.75;
+ double fitcenter = 0.0;
+ double HalfMax, MinHalfMax, MaxHalfMax, FWHM;
+
+ int ccccdi = 0;
+
+ //~ (c[cc]->cd(++ccccdi))->SetLogy(1);
+ sprintf(hname, "hctdc%d", 0);
+ hp1d = DrTH1F(dir, hname, "");
+ hp1d->SetTitle("Vov = 1.5V; Time [ns];");
+ hp1d->GetXaxis()->SetRangeUser(drawmin,drawmax);
+
+ f_fit = fgg;
+ f_fit->SetParameters(hp1d->GetMaximum()*0.9, 0, 0.1,
+ hp1d->GetMaximum()*0.1, 0, 0.5);
+ //~ f_fit->SetParLimits(1, 0, hp1d->GetMaximum());
+ //~ f_fit->SetParLimits(2, fitmin,fitmax);
+ //~ f_fit->SetParLimits(3, 0.2, 1);
+ //~ f_fit->SetParLimits(4, 0, hp1d->GetMaximum());
+ //~ f_fit->SetParLimits(5, fitmin,fitmax);
+
+ f_fit->SetRange(fitmin,fitmax);
+ f_fit->SetLineWidth(1);
+ hp1d->Fit(f_fit, "Q", "", fitmin,fitmax);
+
+
+ HalfMax = f_fit->GetMaximum(fitmin, fitmax)/2.0;
+ MinHalfMax = f_fit->GetX(HalfMax, fitmin, fitcenter);
+ MaxHalfMax = f_fit->GetX(HalfMax, fitcenter, fitmax);
+ FWHM = MaxHalfMax - MinHalfMax;
+ printf("FWHM = %.3lf ns\n", FWHM);
+
+ fg->SetRange(-2,5); fg->SetLineWidth(1.0);
+ fg->SetParameters(f_fit->GetParameter(0), f_fit->GetParameter(1), f_fit->GetParameter(2));
+ fg->SetLineColor(kGreen); fg->DrawClone("LSAME");
+ fg->SetParameters(f_fit->GetParameter(0+3), f_fit->GetParameter(1+3), f_fit->GetParameter(2+3));
+ fg->SetLineColor(kMagenta); fg->DrawClone("LSAME");
+
+ sprintf(fullname, "gif/t_%s.gif", fname); c[cc]->SaveAs(fullname);
+ sprintf(fullname, "eps/t_%s.eps", fname); c[cc]->SaveAs(fullname);
+ }
+
+// -------------------------------------------------------------------------------
+// -------------------------------------------------------------------
+
+ if( strchr(plopt, 'e') != NULL ) {
+
+
+ DrSetDrawStyle(0.05);
+
+ gStyle->SetOptStat("e");
+ gStyle->SetOptFit(0);
+
+ gStyle->SetPadRightMargin(0.03);
+ gStyle->SetPadTopMargin(0.05);
+ gStyle->SetPadBottomMargin(0.12);
+ gStyle->SetStatFontSize(0.05);
+ gStyle->SetStatX(0.97);
+ gStyle->SetStatY(0.95);
+
+ c[++cc] = new TCanvas("e_ref", "e_ref", 0, 0, 720, 400);
+
+
+ int spectra_rebin = 0;
+ int yaxis_max = 0;
+ //~ int yaxis_max = 1200;
+ //~ int xaxis_max = 2500;
+ int xaxis_max = 3000;
+
+ //~ double fitcenter = 1190.;
+ //~ double fitw = 70.;
+ //~ double Cher_min = 10;
+ //~ double Cher_max = 16;
+ double Cher_min = -120;
+ double Cher_max = -110;
+ //~ double const_min = 20;
+ //~ double const_max = 80;
+ double const_min = -250;
+ double const_max = -200;
+ int ccccdi = 0;
+
+ if( strcmp(fname, "eff003")==0) {fitcenter=760.; fitw=100.;}
+ if( strcmp(fname, "eff004")==0) {fitcenter=1220.; fitw=150.; spectra_rebin=8; yaxis_max=3300;}
+ if( strcmp(fname, "eff005")==0) {fitcenter=1140.; fitw=60.;}
+ if( strcmp(fname, "eff006")==0) {fitcenter=2050.; fitw=60.; xaxis_max=4000;}
+
+ if( strcmp(fname, "eff012")==0) {Cher_min=13; Cher_max=15;}
+ if( strcmp(fname, "eff013")==0) {Cher_min=12; Cher_max=14;}
+ if( strcmp(fname, "eff014")==0) {Cher_min=12; Cher_max=14;}
+ if( strcmp(fname, "eff015")==0) {Cher_min=12; Cher_max=14;}
+ if( strcmp(fname, "eff016")==0) {Cher_min=12; Cher_max=14;}
+ if( strcmp(fname, "eff017")==0) {Cher_min=12; Cher_max=14;}
+ if( strcmp(fname, "eff018")==0) {Cher_min=12; Cher_max=14;}
+
+ sprintf(hname, "hadc%d", 0);
+ hp1d = DrTH1F(dir, hname, "");
+ hp1d->SetTitle("; Charge [200 fC/bin];Counts");
+ if(spectra_rebin) hp1d->Rebin(spectra_rebin);
+ hp1d->SetLineColor(kBlack);
+ hp1d->GetXaxis()->SetRangeUser(0,xaxis_max);
+ if(yaxis_max) hp1d->GetYaxis()->SetRangeUser(0,yaxis_max);
+ hp1d->Draw();
+
+ //~ printf("Photofraction ~ %lf\n", hp1d->Integral(1300,1700)/hp1d->Integral(0,1300));
+
+ f_fit = fg;
+ f_fit->SetParameters(hp1d->GetMaximum()*0.1, fitcenter, fitw);
+
+ f_fit->SetRange(fitcenter-fitw, fitcenter+fitw);
+ f_fit->SetLineWidth(3);
+ hp1d->Fit(f_fit, "0Q", "", fitcenter-fitw, fitcenter+fitw);
+ f_fit->DrawClone("LSAME");
+
+ double PP_1sigma_min = f_fit->GetParameter(1)-f_fit->GetParameter(2);
+ double PP_1sigma_max = f_fit->GetParameter(1)+f_fit->GetParameter(2);
+ printf("PPcenter, PPwidth = %.0lf, %.0lf\n", f_fit->GetParameter(1), f_fit->GetParameter(2));
+ printf("PP+/-1sigma = [%.0lf, %.0lf]\n", PP_1sigma_min, PP_1sigma_max);
+ printf("PP resolution = %.1lf\%% (FWHM = %.1lf\%%)\n", 100*f_fit->GetParameter(2)/f_fit->GetParameter(1), 235*f_fit->GetParameter(2)/f_fit->GetParameter(1));
+
+// -------- 1275keV Compton estimation --------
+
+// COMPTON EDGE
+ //~ TF1 *fcompt = new TF1("fcompt", "[2]*(1 - ConstantStep(((x-[0])/[1]) - (1275.*(2*1275./511./(1+2*1275./511.)))))*(2 + (((x-[0])/[1])/1275.)^2/((1275./511.)^2*(1 - (((x-[0])/[1])/1275.))^2) + (((x-[0])/[1])/1275.)*((((x-[0])/[1])/1275.) - 2/(1275./511.))/(1 - (((x-[0])/[1])/1275.)))/(1275./511.)^2");
+ //~ TF1 *fcomhi = new TF1("fcomhi", "gaus(0)+fcompt");
+ //~ fcomhi->SetNpx(500); fcomhi->SetLineWidth(1); fcomhi->SetLineColor(6);
+ //~ double comhi_range_low = 1670.;
+ //~ //double comhi_range_hi = 2130.;
+ //~ double comhi_range_hi = 2070.;
+ //~ fcomhi->SetParameters(2000., 1710., 50., 100, 2, 200);
+ //~ fcomhi->SetRange(comhi_range_low, comhi_range_hi);
+ //~ hp1d->Fit(fcomhi, "0QR");
+ //~ //fcomhi->DrawClone("LSAME");
+ //~
+ //~ fcompt->SetNpx(300); fcompt->SetLineWidth(1); fcompt->SetLineColor(kBlue); fcompt->SetLineStyle(9);
+ //~ fcompt->SetParameter(0, fcomhi->GetParameter(3));
+ //~ fcompt->SetParameter(1, fcomhi->GetParameter(4));
+ //~ fcompt->SetParameter(2, fcomhi->GetParameter(5));
+ //~ fcompt->SetRange(0, comhi_range_hi);
+ //~ fcompt->DrawClone("LSAME");
+ //~
+ //~ double IComHi = fcompt->Integral(PP_1sigma_min, PP_1sigma_max)/hp1d->GetBinWidth(1);
+ //~ printf("IComHi = %.0lf\n", IComHi);
+
+// G LINEAR G
+ //~ TF1 *fcomhi = new TF1("fcomhi", "gaus(0)+pol0(3)+gaus(4)");
+ //~ fcomhi->SetNpx(500); fcomhi->SetLineWidth(1); fcomhi->SetLineColor(kBlue);
+ //~ double comhi_range_low = 1700.;
+ //~ double comhi_range_hi = 2150.;
+ //~ fcomhi->SetParameters(2000., 1710., 50.,
+ //~ 150.,
+ //~ 200., 2150., 100.);
+ //~ fcomhi->SetRange(comhi_range_low, comhi_range_hi);
+ //~ hp1d->Fit(fcomhi, "0QR");
+ //~ fcomhi->DrawClone("LSAME");
+ //~
+ //~ TF1 *fcom_lin = new TF1("fcom_lin", "pol0(0)");
+ //~ fcom_lin->SetNpx(300); fcom_lin->SetLineWidth(1); fcom_lin->SetLineColor(6);
+ //~ fcom_lin->SetParameter(0, fcomhi->GetParameter(3));
+ //~ fcom_lin->SetRange(0, 4000);
+ //~ fcom_lin->DrawClone("LSAME");
+ //~
+ //~ double IComHi = fcom_lin->Integral(PP_1sigma_min, PP_1sigma_max)/hp1d->GetBinWidth(1);
+// G LINEAR EXP
+ TF1 *fcomhi = new TF1("fcomhi", "gaus(0) + [3] + [4]*TMath::Exp((x-[5])/[6])");
+ fcomhi->SetNpx(500); fcomhi->SetLineWidth(1); fcomhi->SetLineColor(6);
+ //double comhi_range_low = 1250.;
+ double comhi_range_low = fitcenter - 1.5*fitw;
+ //double comhi_range_hi = 2100.;
+ //~ fcomhi->SetParameters(2000., fitcenter, fitw,
+ //~ 170.,
+ //~ 85., 2000., 100.);
+ fcomhi->SetParameters(800., fitcenter, fitw,
+ 40.,
+ 5., comhi_range_hi, 100.);
+
+ //~ fcomhi->SetParLimits(2, 50., 2000.);
+ fcomhi->SetRange(comhi_range_low, comhi_range_hi);
+ hp1d->Fit(fcomhi, "0QR");
+ //~ fcomhi->SetRange(0, 4000);
+ fcomhi->DrawClone("LSAME");
+
+ TF1 *fcompt = new TF1("fcompt", "[0] + [1]*TMath::Exp((x-[2])/[3])");
+ fcompt->SetNpx(300); fcompt->SetLineWidth(1); fcompt->SetLineColor(kBlue); fcompt->SetLineStyle(9);
+ fcompt->SetParameter(0, fcomhi->GetParameter(3));
+ fcompt->SetParameter(1, fcomhi->GetParameter(4));
+ fcompt->SetParameter(2, fcomhi->GetParameter(5));
+ fcompt->SetParameter(3, fcomhi->GetParameter(6));
+ //~ fcompt->SetRange(1000, comhi_range_hi);
+ fcompt->SetRange(400, comhi_range_hi);
+ fcompt->DrawClone("LSAME");
+ //~
+ double IComHi = fcompt->Integral(PP_1sigma_min, PP_1sigma_max)/hp1d->GetBinWidth(1);
+ printf("IComHi = %.0lf\n", IComHi);
+ //~
+//~ // EXP
+ //~ TF1 *fcomhi = new TF1("fcomhi", "[0] + [1]*TMath::Exp((x-[2])/[3])");
+ //~ fcomhi->SetNpx(500); fcomhi->SetLineWidth(1); fcomhi->SetLineColor(6);
+ //~ double comhi_range_low = 1800.;
+ //~ double comhi_range_hi = 2000.;
+ //~ fcomhi->SetParameters(150., 1., 2000.,1.);
+ //~ fcomhi->SetRange(comhi_range_low, comhi_range_hi);
+ //~ hp1d->Fit(fcomhi, "R");
+ //~ fcomhi->SetRange(0, 4000);
+ //~ fcomhi->DrawClone("LSAME");
+ //~
+ //~ double IComHi = fcomhi->Integral(PP_1sigma_min, PP_1sigma_max)/hp1d->GetBinWidth(1);
+ //~ printf("IComHi = %.0lf\n", IComHi);
+// LIN
+ //~ TF1 *fcomhi = new TF1("fcomhi", "pol0");
+ //~ fcomhi->SetNpx(500); fcomhi->SetLineWidth(1); fcomhi->SetLineColor(6);
+ //~ double comhi_range_low = 1800.;
+ //~ double comhi_range_hi = 1900.;
+ //~ fcomhi->SetParameter(0,150);
+ //~ fcomhi->SetRange(comhi_range_low, comhi_range_hi);
+ //~ hp1d->Fit(fcomhi, "QR");
+ //~ fcomhi->SetRange(0, 4000);
+ //~ fcomhi->DrawClone("LSAME");
+ //~
+ //~ double IComHi = fcomhi->Integral(PP_1sigma_min, PP_1sigma_max)/hp1d->GetBinWidth(1);
+ //~ printf("IComHi = %.0lf\n", IComHi);
+
+// -------- 1275keV Compton estimation --------
+
+ sprintf(hname, "hadc_cut%d", 0);
+ hp1dcut = DrTH1F(dir, hname, "");
+ if(spectra_rebin) hp1dcut->Rebin(spectra_rebin);
+ hp1dcut->SetLineColor(kRed);
+
+ hp1dcut->SetLineColor(40);
+ hp1dcut->SetLineStyle(2);
+ hp1dcut->DrawClone("SAME");
+ double N511 = hp1dcut->GetEntries();
+ //~ double N511 = hp1dcut->Integral(PP_1sigma_min-10, PP_1sigma_max+10);
+
+ leg[++legi] = new TLegend(0.124302, 0.65, 0.6, 0.925134);
+ leg[legi]->SetFillColor(0); leg[legi]->SetBorderSize(1); leg[legi]->SetTextSize(0.05); leg[legi]->SetTextAlign(22);
+ leg[legi]->AddEntry((TH1F*)hp1d->Clone(), "Measurement", "L");
+ leg[legi]->AddEntry((TH1F*)hp1dcut->Clone(), "#pm1 #sigma Photopeak Cut", "L");
+ leg[legi]->AddEntry((TF1*)fcompt->Clone(), "1275 keV Compton Estimate", "L");
+
+ //~ leg[legi]->Draw();
+
+ //~ sprintf(hname, "hadc_cut_2%d", 0);
+ //~ hp1d = DrTH1F(dir, hname, "");
+ //~ hp1d->SetLineColor(kGreen);
+ //~ hp1d->DrawClone("SAME");
+
+
+ sprintf(fullname, "gif/e_%s.gif", fname); c[cc]->SaveAs(fullname);
+ sprintf(fullname, "eps/e_%s.eps", fname); c[cc]->SaveAs(fullname);
+
+
+
+ c[++cc] = new TCanvas("e_sipm", "e_sipm", 0, 470, 720, 300);
+ int ch_Sprttype = 8;
+
+ (c[cc]->cd(1))->SetLogy(1);
+ sprintf(hname, "htdc%d", ch_Sprttype);
+ hp1d = DrTH1F(dir, hname, "");
+ hp1d->SetTitle("; Time [ns];Counts");
+ //~ hp1d->Rebin(4);
+ hp1d->SetLineColor(kBlack);
+ //~ hp1d->GetXaxis()->SetRangeUser(0,80);//original
+ hp1d->GetXaxis()->SetRangeUser(-400,50);
+ hp1d->GetYaxis()->SetRangeUser(0.1,hp1d->GetMaximum()*2);
+ hp1d->DrawClone();
+
+ sprintf(hname, "htdc_cut%d", ch_Sprttype);
+ hp1d = DrTH1F(dir, hname, "");
+ //~ hp1d->Rebin(4);
+ hp1d->SetLineColor(kRed);
+
+ TF1 *fc = new TF1("fc", "pol0"); fc->SetNpx(300);
+ fc->SetParameter(0,1);
+ //~ fc->SetParameter(1,-0.1);
+ fc->SetRange(const_min,const_max);
+ hp1d->Fit(fc, "0QWWR");
+
+ hp1d->DrawClone("SAME");
+ fc->SetLineColor(kBlue);
+ fc->DrawClone("LSAME");
+
+ double Ntdc = hp1d->Integral(hp1d->FindBin(Cher_min), hp1d->FindBin(Cher_max));
+ double Nbckg = fc->Integral(Cher_min,Cher_max)/hp1d->GetBinWidth(1);
+ printf("fc par(0) = %lf | Nbckg = %.0lf\n", fc->GetParameter(0), Nbckg);
+
+
+ //~ sprintf(hname, "htdc_cut_2%d", 1);
+ //~ hp1d = DrTH1F(dir, hname, "");
+ //~ hp1d->SetLineColor(kGreen);
+ //~ hp1d->DrawClone("SAME");
+
+ printf("N511 = %.0lf | Ntdc = %.0lf | R = %.2lf \%% | R_1 = %.2lf \%% | R_2 = %.2lf \%%\n", N511, Ntdc, 100*Ntdc/N511, 100*(Ntdc-Nbckg)/N511, 100*(Ntdc-Nbckg)/(N511-IComHi));
+
+ sprintf(fullname, "gif/e2_%s.gif", fname); c[cc]->SaveAs(fullname);
+ sprintf(fullname, "eps/e2_%s.eps", fname); c[cc]->SaveAs(fullname);
+
+ int kobayashi =1;
+ if(kobayashi){
+ double Nnohit = hp1d->Integral(hp1d->FindBin(-715), hp1d->FindBin(-685));
+
+ printf("N511 = %.0lf | Nnohit = %.0lf | R = %.2lf \%% | R_1 = %.2lf \%% | R_2 = %.2lf \%%\n", N511, Nnohit, 100*(N511-Nnohit)/N511, 100*((N511-Nnohit)-Nbckg)/N511, 100*((N511-Nnohit)-Nbckg)/(N511-IComHi));
+
+ }
+
+ //~ (c[cc]->cd(++ccccdi))->SetLogy(1);
+ //~ sprintf(hname, "hadc%d", 1);
+ //~ hp1d = DrTH1F(dir, hname, "");
+ //~ hp1d->SetLineColor(kBlack);
+ //~ hp1d->GetXaxis()->SetRangeUser(0,2000);
+ //~ hp1d->DrawClone();
+ //~
+ //~ sprintf(hname, "hadc_cut%d", 1);
+ //~ hp1d = DrTH1F(dir, hname, "");
+ //~ hp1d->SetLineColor(kRed);
+ //~ hp1d->DrawClone("SAME");
+ //~
+ //~ sprintf(hname, "hadc_cut_2%d", 1);
+ //~ hp1d = DrTH1F(dir, hname, "");
+ //~ hp1d->SetLineColor(kGreen);
+ //~ hp1d->DrawClone("SAME");
+
+ //~ sprintf(fullname, "gif/e_%s.gif", fname); c[cc]->SaveAs(fullname);
+ //~ sprintf(fullname, "eps/e_%s.eps", fname); c[cc]->SaveAs(fullname);
+ }
+// -------------------------------------------------------------------
+
+ if( strchr(plopt, 'r') != NULL ) {
+
+ //~ gStyle->SetOptStat(1111);
+ gStyle->SetOptStat(0);
+ gStyle->SetOptFit(0);
+
+ c[++cc] = new TCanvas("e", "e", 0, 0, 1200, 450);
+ c[cc]->Divide(3,1);
+
+ int spectra_rebin = 0;
+ int yaxis_max = 0;
+ int xaxis_max = 3000;
+
+ double fitcenter = 700.;
+ double fitw = 60.;
+ double Cher_min = 4;
+ double Cher_max = 16;
+ double const_min = Cher_max;
+ double const_max = 80;
+ int ccccdi = 0;
+
+ if( strcmp(fname, "eff003")==0) {fitcenter=760.; fitw=100.;}
+ if( strcmp(fname, "eff004")==0) {fitcenter=1220.; fitw=150.; spectra_rebin=8; yaxis_max=3300;}
+ if( strcmp(fname, "eff005")==0) {fitcenter=1140.; fitw=60.;}
+ if( strcmp(fname, "eff006")==0) {fitcenter=2050.; fitw=60.; xaxis_max=4000;}
+ if( strcmp(fname, "eff007")==0) {fitcenter=710.; fitw=50.;}
+ if( strcmp(fname, "eff009")==0) {fitcenter=900.; fitw=60.; xaxis_max=2000;}
+
+ (c[cc]->cd(++ccccdi))->SetLogy(1);
+ sprintf(hname, "hadc%d", 0);
+ hp1d = DrTH1F(dir, hname, "");
+ hp1d->SetTitle("Reference Coincidence; Charge [200 fC/bin];");
+ if(spectra_rebin) hp1d->Rebin(spectra_rebin);
+ hp1d->SetLineColor(kBlack);
+ hp1d->GetXaxis()->SetRangeUser(0,xaxis_max);
+ if(yaxis_max) hp1d->GetYaxis()->SetRangeUser(0.5,yaxis_max);
+
+ f_fit = fg;
+ f_fit->SetParameters(hp1d->GetMaximum()*0.1, fitcenter, fitw);
+
+ f_fit->SetRange(fitcenter-fitw, fitcenter+fitw);
+ f_fit->SetLineWidth(1);
+ hp1d->Fit(f_fit, "Q", "", fitcenter-fitw, fitcenter+fitw);
+
+ printf("PP+/-1sigma = [%.0lf, %.0lf]\n", f_fit->GetParameter(1)-f_fit->GetParameter(2), f_fit->GetParameter(1)+f_fit->GetParameter(2));
+ printf("PP resolution = %.1lf\%% (FWHM = %.1lf\%%)\n", 100*f_fit->GetParameter(2)/f_fit->GetParameter(1), 235*f_fit->GetParameter(2)/f_fit->GetParameter(1));
+
+ sprintf(hname, "hadc_cut%d", 0);
+ hp1d = DrTH1F(dir, hname, "");
+ if(spectra_rebin) hp1d->Rebin(spectra_rebin);
+ hp1d->SetLineColor(kRed);
+ hp1d->DrawClone("SAME");
+ double N511 = hp1d->GetEntries();
+
+ sprintf(hname, "hadc_cut_2%d", 0);
+ hp1d = DrTH1F(dir, hname, "");
+ hp1d->SetLineColor(kGreen);
+ hp1d->DrawClone("SAME");
+
+//-----------------------------------------------------------------------
+
+ (c[cc]->cd(++ccccdi))->SetLogy(1);
+ sprintf(hname, "hadc%d", 2);
+ hp1d = DrTH1F(dir, hname, "");
+ hp1d->SetTitle("Reference 1275 keV; Charge [200 fC/bin];");
+ //~ if(spectra_rebin) hp1d->Rebin(spectra_rebin);
+ hp1d->SetLineColor(kBlack);
+ //~ hp1d->GetXaxis()->SetRangeUser(0,xaxis_max);
+ //~ if(yaxis_max) hp1d->GetYaxis()->SetRangeUser(0,yaxis_max);
+ hp1d->DrawClone();
+
+ sprintf(hname, "hadc_cut%d", 2);
+ hp1d = DrTH1F(dir, hname, "");
+ if(spectra_rebin) hp1d->Rebin(spectra_rebin);
+ hp1d->SetLineColor(kRed);
+ hp1d->DrawClone("SAME");
+
+ sprintf(hname, "hadc_cut_2%d", 2);
+ hp1d = DrTH1F(dir, hname, "");
+ hp1d->SetLineColor(kGreen);
+ hp1d->DrawClone("SAME");
+
+//-----------------------------------------------------------------------
+
+ (c[cc]->cd(++ccccdi))->SetLogy(1);
+ sprintf(hname, "htdc%d", 1);
+ hp1d = DrTH1F(dir, hname, "");
+ hp1d->SetTitle("MPPC Cherenkov; Time [ns];");
+ //~ hp1d->Rebin(4);
+ hp1d->SetLineColor(kBlack);
+ hp1d->GetXaxis()->SetRangeUser(0,80);
+ hp1d->GetYaxis()->SetRangeUser(0.1,hp1d->GetMaximum()*2);
+ hp1d->DrawClone();
+
+ sprintf(hname, "htdc_cut%d", 1);
+ hp1d = DrTH1F(dir, hname, "");
+ //~ hp1d->Rebin(4);
+ hp1d->SetLineColor(kRed);
+
+ TF1 *fc = new TF1("fc", "pol0"); fc->SetNpx(300);
+ fc->SetParameter(0,1);
+ fc->SetRange(const_min,const_max);
+ hp1d->Fit(fc, "0QWWR");
+
+ hp1d->DrawClone("SAME");
+ fc->SetLineColor(kBlue);
+ fc->DrawClone("LSAME");
+
+ double Ntdc = hp1d->Integral(hp1d->FindBin(Cher_min), hp1d->FindBin(Cher_max));
+ double Nbckg = fc->Integral(Cher_min,Cher_max)/hp1d->GetBinWidth(1);
+ printf("fc par(0) = %lf | Nbckg = %.0lf\n", fc->GetParameter(0), Nbckg);
+
+
+ sprintf(hname, "htdc_cut_2%d", 1);
+ hp1d = DrTH1F(dir, hname, "");
+ hp1d->SetLineColor(kGreen);
+ hp1d->DrawClone("SAME");
+
+ printf("N511 = %.0lf | Ntdc = %.0lf | R = %lf\n", N511, Ntdc, Ntdc/N511);
+
+ printf("R_1 = %lf\n", (Ntdc-Nbckg)/N511);
+
+ //~ (c[cc]->cd(++ccccdi))->SetLogy(1);
+ //~ sprintf(hname, "hadc%d", 1);
+ //~ hp1d = DrTH1F(dir, hname, "");
+ //~ hp1d->SetLineColor(kBlack);
+ //~ hp1d->GetXaxis()->SetRangeUser(0,2000);
+ //~ hp1d->DrawClone();
+ //~
+ //~ sprintf(hname, "hadc_cut%d", 1);
+ //~ hp1d = DrTH1F(dir, hname, "");
+ //~ hp1d->SetLineColor(kRed);
+ //~ hp1d->DrawClone("SAME");
+ //~
+ //~ sprintf(hname, "hadc_cut_2%d", 1);
+ //~ hp1d = DrTH1F(dir, hname, "");
+ //~ hp1d->SetLineColor(kGreen);
+ //~ hp1d->DrawClone("SAME");
+
+ sprintf(fullname, "gif/e_%s.gif", fname); c[cc]->SaveAs(fullname);
+ sprintf(fullname, "eps/e_%s.eps", fname); c[cc]->SaveAs(fullname);
+ }
+
+// -------------------------------------------------------------------------------
+ // -------------------------------------------------------------------
+
+ if( strchr(plopt, 'p') != NULL ) {
+
+
+ DrSetDrawStyle(0.05);
+
+ gStyle->SetOptStat("e");
+ gStyle->SetOptFit(0);
+
+ gStyle->SetPadRightMargin(0.03);
+ gStyle->SetPadTopMargin(0.05);
+ gStyle->SetPadBottomMargin(0.12);
+ gStyle->SetStatFontSize(0.05);
+ gStyle->SetStatX(0.97);
+ gStyle->SetStatY(0.95);
+
+ c[++cc] = new TCanvas("Print", "Print", 0, 0, 720, 400);
+
+
+ int spectra_rebin = 0;
+ int yaxis_max = 1000;
+ int xaxis_max = 1200;
+
+
+ double Cher_min = 10;
+ double Cher_max = 16;
+ double const_min = 20;
+ double const_max = 80;
+ int ccccdi = 0;
+
+ sprintf(hname, "hadc%d", 0);
+ hp1d = DrTH1F(dir, hname, "");
+ hp1d->SetTitle("; Charge [200 fC/bin];Counts");
+ if(spectra_rebin) hp1d->Rebin(spectra_rebin);
+ hp1d->SetLineColor(kBlack);
+ hp1d->GetXaxis()->SetRangeUser(0,xaxis_max);
+ if(yaxis_max) hp1d->GetYaxis()->SetRangeUser(0,yaxis_max);
+ hp1d->Draw();
+
+ sprintf(hname, "hadc_cut%d", 0);
+ hp1dcut = DrTH1F(dir, hname, "");
+ if(spectra_rebin) hp1dcut->Rebin(spectra_rebin);
+ hp1dcut->SetLineColor(kRed);
+ hp1dcut->Draw("SAME");
+
+ sprintf(fullname, "gif/p_%s.gif", fname); c[cc]->SaveAs(fullname);
+ sprintf(fullname, "eps/p_%s.eps", fname); c[cc]->SaveAs(fullname);
+ }
+
+// -------------------------------------------------------------------
+
+ if( strchr(plopt, 'b') != NULL ) {
+ gStyle->SetOptStat(0);
+ gStyle->SetOptFit(0);
+
+ c[++cc] = new TCanvas("b", "b", 0, 0, 1200, 700);
+ c[cc]->Divide(2,2);
+
+ int ccccdi = 0;
+ int ich;
+/*
+// ------------------------------------------------------------
+ ich = 0;
+ (c[cc]->cd(++ccccdi))->SetLogy(1);
+ sprintf(hname, "htdc%d", ich);
+ hp1d = DrTH1F(dir, hname, "");
+ hp1d->SetTitle(hname);
+ //~ hp1d->GetXaxis()->SetRangeUser(0,2000);
+ //~ hp1d->GetYaxis()->SetRangeUser(0.9,hp1d->GetMaximum()*1.1);
+ hp1d->SetLineColor(kBlack);
+ hp1d->DrawClone();
+
+// ------------------------------------------------------------
+ ich = 1;
+ (c[cc]->cd(++ccccdi))->SetLogy(1);
+ sprintf(hname, "htdc%d", ich);
+ hp1d = DrTH1F(dir, hname, "");
+ hp1d->SetTitle(hname);
+ //~ hp1d->GetXaxis()->SetRangeUser(0,2000);
+ //~ hp1d->GetYaxis()->SetRangeUser(0.9,hp1d->GetMaximum()*1.1);
+ hp1d->SetLineColor(kBlack);
+ hp1d->DrawClone();
+*/
+// -------------------------- qdc 0 ----------------------------------
+ ich = 0;
+ (c[cc]->cd(++ccccdi))->SetLogy(1);
+ /*
+ sprintf(hname, "hadc%d", ich);
+ hp1d = DrTH1F(dir, hname, "");
+ hp1d->SetTitle("SiPM;Charge [200 fC/bin]");
+ hp1d->GetXaxis()->SetRangeUser(0,1000);
+ //~ hp1d->GetYaxis()->SetRangeUser(0.9,hp1d->GetMaximum()*1.1);
+ hp1d->SetLineColor(kBlack);
+ hp1d->DrawClone();
+ */
+
+TLegend *leg0 = new TLegend(0.57,0.66,0.88,0.88);
+ leg0->SetFillColor(0);
+ leg0->SetBorderSize(1);
+ leg0->SetTextSize(0.05);
+ leg0->SetTextAlign(22);
+
+ sprintf(hname, "hadc%d", ich);
+ TH1F* hADC = DrTH1F(dir, hname, "");
+
+ hADC->SetTitle("SiPM;Charge [200 fC/bin]");
+ hADC->GetXaxis()->SetRangeUser(0,1000);
+ hADC->SetLineColor(kBlack);
+ hADC->DrawClone();
+
+ int dbgprint=1;
+ const int nPeaks=3;
+ double pSigma=10;
+ double pThr=0.005;
+
+ TSpectrum *sADC = new TSpectrum(nPeaks,0.3);
+ sADC->Search(hADC, pSigma,"",pThr);
+ int foundNPeaks = sADC->GetNPeaks();
+ float *foundPeakX = sADC->GetPositionX();
+ float *foundPeakY = sADC->GetPositionY();
+
+ if(1 < foundNPeaks) {
+ //void Sort(Int_t n1, const Float_t *a, Int_t *index, Bool_t down)
+ int sortedPeakIndex[nPeaks];
+ TMath::Sort(foundNPeaks, foundPeakX, sortedPeakIndex, 0);
+ if(dbgprint) {
+ printf("foundNPeaks = %d\n",foundNPeaks);
+ for(int i=0; i<foundNPeaks; i++) printf("Peak[%d] = %f\n",i, foundPeakX[sortedPeakIndex[i]]);
+ }
+ float peakMidpointX[nPeaks+1];
+ float peakMidpointY[nPeaks+1];
+
+ peakMidpointX[0] = 0; peakMidpointY[0] = 1;
+ for(int i=1; i<foundNPeaks; i++) {
+ peakMidpointX[i] = (foundPeakX[sortedPeakIndex[i]] + foundPeakX[sortedPeakIndex[i-1]])/2.0;
+ peakMidpointY[i] = 1;
+
+ if(dbgprint) printf("peakMidpointX[%d] = %f\n",i, peakMidpointX[i]);
+
+ }
+ peakMidpointX[foundNPeaks] = 1120; peakMidpointY[foundNPeaks] = 1;
+
+ if(dbgprint) printf("peakMidpointX[%d] = %f\n",foundNPeaks, peakMidpointX[foundNPeaks]);
+
+ TPolyMarker *pmMidpoints = new TPolyMarker(nPeaks+1, peakMidpointX, peakMidpointY);
+ pmMidpoints->SetMarkerStyle(33); pmMidpoints->SetMarkerColor(9); pmMidpoints->SetMarkerSize(2);
+ pmMidpoints->Draw("SAME");
+
+ //~ fprintf(fp,"peakEvents:\n");
+
+ double peakEvents[nPeaks];
+ for(int i=0; i<foundNPeaks-1; i++) {
+ peakEvents[i] = hADC->Integral(hADC->FindBin(peakMidpointX[i]), hADC->FindBin(peakMidpointX[i+1]));
+
+ if(dbgprint) printf("I(%.1f, %.1f) = %.1lf\n", peakMidpointX[i], peakMidpointX[i+1], peakEvents[i]);
+ //~ fprintf(fp,"%lf\n", peakEvents[i]);
+
+ }
+ peakEvents[foundNPeaks-1] = hADC->Integral(hADC->FindBin(peakMidpointX[foundNPeaks-1]), hADC->FindBin(1130.));
+
+ if(dbgprint) printf("I(%.1f, %.1f) = %.1lf\n", peakMidpointX[foundNPeaks-1], 1130., peakEvents[foundNPeaks-1]);
+ //~ fprintf(fp,"%lf\n", peakEvents[foundNPeaks-1]);
+
+ double N0all = -TMath::Log(peakEvents[0]/hADC->GetEntries());
+ double N01 = peakEvents[1]/peakEvents[0];
+ double N02 = 2*peakEvents[2]/peakEvents[1];
+
+ if(dbgprint) printf("Poisson <N>: N0all -> %.3lf | N01 -> %.3lf | N12 -> %.3lf\n", N0all, N01, N02);
+
+
+
+ sprintf(sbuff, "<N> = %.3lf", N0all);
+ leg0->AddEntry((TH1F*)hADC->Clone(),sbuff, "");
+ sprintf(sbuff, "1 CPH = %.0lf", foundPeakX[sortedPeakIndex[1]]);
+ leg0->AddEntry((TH1F*)hADC->Clone(),sbuff, "");
+ leg0->Draw();
+ }
+
+ double N_adc_integral = hADC->Integral(hADC->FindBin(peakMidpointX[1]), hADC->FindBin(1000.));
+ double N_poisson = (1 - TMath::Exp(-N0all))*hADC->GetEntries();
+ printf("hADC->GetEntries() = %.0lf\n", hADC->GetEntries());
+ printf("N_adc_integral = %.0lf | N_poisson = %.0lf\n", N_adc_integral, N_poisson);
+
+ sprintf(hname, "hadc_cut%d", ich);
+ hp1d = DrTH1F(dir, hname, "");
+ hp1d->SetLineColor(kRed);
+ hp1d->DrawClone("SAME");
+
+// -------------------------- TDC 0 ----------------------------------
+ (c[cc]->cd(++ccccdi))->SetLogy(1);
+ sprintf(hname, "htdc%d", ich);
+ hp1d = DrTH1F(dir, hname, "");
+ hp1d->SetTitle("SiPM;Time [ns]");
+ hp1d->GetXaxis()->SetRangeUser(-5,5);
+ //~ hp1d->GetYaxis()->SetRangeUser(0.9,hp1d->GetMaximum()*1.1);
+ hp1d->SetLineColor(kBlack);
+ hp1d->DrawClone();
+
+ printf("hTDC->GetEntries() = %.0lf\n", hp1d->GetEntries());
+ double N_tdc_integral = hp1d->Integral(hp1d->FindBin(-10), hp1d->FindBin(10));
+ printf("N_tdc_integral = %.0lf\n", N_tdc_integral);
+
+ // -----------------------------------------------------------
+
+ (c[cc]->cd(++ccccdi))->SetLogy(0);
+ sprintf(hname, "hcor%d", ich);
+ hp2d = DrTH2F(dir, hname, "");
+ hp2d->SetTitle(";Charge [200 fC/bin];cTime [ns]");
+ //~ hp1d->GetXaxis()->SetRangeUser(0,2000);
+ //~ hp1d->GetYaxis()->SetRangeUser(0.9,hp1d->GetMaximum()*1.1);
+ //~ hp1d->SetLineColor(kBlack);
+ hp2d->DrawClone("COLZ");
+
+// -------------------------- cTDC 0 ----------------------------------
+ (c[cc]->cd(++ccccdi))->SetLogy(0);
+ sprintf(hname, "hctdc%d", ich);
+ hp1d = DrTH1F(dir, hname, "");
+ //~ hp1d->SetTitle("SiPM;cTime [ns]");
+ //~ hp1d->GetXaxis()->SetRangeUser(-5,5);
+ //~ //hp1d->GetYaxis()->SetRangeUser(0.9,hp1d->GetMaximum()*1.1);
+ hp1d->SetLineColor(kBlack);
+ //~ hp1d->DrawClone();
+
+ plotCorTDC(hp1d, "SiPM;cTime [ns]", -0.5, 0.45, -1., 2);
+
+ printf("hcTDC->GetEntries() = %.0lf\n", hp1d->GetEntries());
+ double N_ctdc_integral = hp1d->Integral(hp1d->FindBin(-2), hp1d->FindBin(2));
+ printf("N_ctdc_integral = %.0lf\n", N_ctdc_integral);
+
+ printf("N_ctdc_integral/N_poisson = %.3lf\n", N_ctdc_integral/N_poisson);
+ printf("N_adc_integral/N_poisson = %.3lf\n", N_adc_integral/N_poisson);
+ printf("N_ctdc_integral/N_adc_integral = %.3lf\n", N_ctdc_integral/N_adc_integral);
+
+ //~ sprintf(hname, "htdc_cut%d", ich);
+ //~ hp1d = DrTH1F(dir, hname, "");
+ //~ hp1d->SetLineColor(kRed);
+ //~ hp1d->DrawClone("SAME");
+
+ sprintf(fullname, "gif/b_%s.gif", fname); c[cc]->SaveAs(fullname);
+ }
+
+
+// -------------------------------------------------------------------
+
+ if( strchr(plopt, 'g') != NULL ) {
+ gStyle->SetOptStat(0);
+ gStyle->SetOptFit(0);
+
+ c[++cc] = new TCanvas("g", "g", 640, 0, 640, 360);
+
+ int ccccdi = 0;
+ int ich = 15;
+
+ (c[cc]->cd(++ccccdi))->SetLogy(0);
+ sprintf(hname, "htdc%d", ich);
+ hp1d = DrTH1F(dir, hname, "");
+ //~ hp1d->SetTitle("SiPM;cTime [ns]");
+ //~ hp1d->GetXaxis()->SetRangeUser(-5,5);
+ //~ //hp1d->GetYaxis()->SetRangeUser(0.9,hp1d->GetMaximum()*1.1);
+ hp1d->SetLineColor(kBlack);
+
+ //~ hp1d->DrawClone();
+
+ sprintf(hname, "Trigger(ch.%d)-Trigger(ch.31);Time [ns]", ich);
+ plotCorTDC(hp1d, hname, -0.25, 0.25, -0.5, 0.5);
+
+ sprintf(fullname, "gif/g_%s.gif", fname); c[cc]->SaveAs(fullname);
+ }
+// -------------------------------------------------------------------------------
+}
Index: l2d2_easyroc/root/EASIROCtestLinux.dat.root
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/l2d2_easyroc/root/EASIROCtestLinux.dat.root
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/root/EASIROCtestLinux.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/l2d2_easyroc/root/EASIROCtestLinux.gif
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/root/EASIROCtestWin.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/l2d2_easyroc/root/EASIROCtestWin.gif
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/root/EASIROCtestWin.root
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/l2d2_easyroc/root/EASIROCtestWin.root
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: l2d2_easyroc/sender.c
===================================================================
--- l2d2_easyroc/sender.c (nonexistent)
+++ l2d2_easyroc/sender.c (revision 291)
@@ -0,0 +1,247 @@
+#include "sender.h"
+#define binary(bit) strtol(bit,NULL,2)
+
+void SenderInit(){};
+
+void SenderClose(){};
+
+//------------------------------------------------------------------------------------------------------
+// Send 1 data & address by UDP
+void Senderudp_send( unsigned int address, int data){// data: send only 1 data length
+ SiTCPRBCPskeleton(0xff, 0x80, address, 0x1, address);
+ SiTCPsndData[0] = data;
+
+ memcpy(SiTCPsndBuf+sizeof(struct bcp_header), SiTCPsndData, sizeof SiTCPsndData);
+ int len = 0;
+ len = sendto(SiTCPGetUDPSock(), SiTCPsndBuf, 1 + sizeof(struct bcp_header), 0,
+ (struct sockaddr *)&SiTCPudpAddr, sizeof(SiTCPudpAddr));//important!
+ if(len < 0){
+ perror("UDP send error");
+ printf("exit(1);!!!\n");
+}
+ SiTCPrcvRBCP_ACK(1);
+}
+
+//------------------------------------------------------------------------------------------------------
+// Recv 1 data & address by UDP
+
+int Senderudp_recv( unsigned int address, int data){// data: send only 1 data length
+
+ SiTCPRBCPskeleton(0xff, 0xc0, address, 0x1, address);
+
+ int len = 0;
+ len = sendto(SiTCPGetUDPSock(), SiTCPsndBuf, 1 + sizeof(struct bcp_header), 0,
+ (struct sockaddr *)&SiTCPudpAddr, sizeof(SiTCPudpAddr));//important!
+ if(len < 0){
+ perror("UDP recv error");
+ printf("exit(1);!!!\n");
+ }
+
+ int rd_data = 0;
+ rd_data = SiTCPrcvRBCP_ACK(1);
+ // std::cout << rd_data << std::endl;
+
+ return rd_data;
+}
+
+//------------------------------------------------------------------------------------------------------
+// Send 1 packet data & address by UDP
+
+void SenderRBCPpacket_send( unsigned int address,
+ unsigned char length, int* data){
+
+ printf("enter packet function\n");
+
+ SiTCPRBCPskeleton(0xff, 0x80, address, length, address);
+
+ for(int i=0; i<256; ++i){
+ SiTCPsndData[i] = data[i];// <- sndData: 0~255
+ }
+
+ memcpy(SiTCPsndBuf+sizeof(struct bcp_header), SiTCPsndData, sizeof SiTCPsndData);
+
+ int len = 0;
+ len = sendto(SiTCPGetUDPSock(), SiTCPsndBuf, sizeof SiTCPsndData + sizeof(struct bcp_header), 0,
+ (struct sockaddr *)&SiTCPudpAddr, sizeof(SiTCPudpAddr));//important!
+
+ if(len < 0){
+ perror("UDP send error");
+ printf("exit(1);!!!\n");
+ }
+ SiTCPrcvRBCP_ACK(0);
+}
+
+//------------------------------------------------------------------------------------------------------
+// Recv 1 packet data & address by UDP
+
+void SenderRBCPpacket_recv( unsigned int address,
+ unsigned char length, int* data){
+
+ printf("enter packet function\n");
+
+ SiTCPRBCPskeleton(0xff, 0xc0, address, length, address);
+
+
+ int len = 0;
+ len = sendto(SiTCPGetUDPSock(), SiTCPsndBuf, sizeof SiTCPsndData + sizeof(struct bcp_header), 0,
+ (struct sockaddr *)&SiTCPudpAddr, sizeof(SiTCPudpAddr));//important!
+
+ if(len < 0){
+ perror("UDP recv error");
+ printf("exit(1);!!!\n");
+ }
+ SiTCPrcvRBCP_ACK(1);
+}
+//------------------------------------------------------------------------------------------------------
+//=============== multi packet sending method ===============
+
+void SenderRBCP_multi_packet_send( unsigned int address,
+ unsigned int total_length, int* data){
+
+ unsigned int total_packet = ((total_length/255)+1)*2;
+ unsigned int packetNo = 0;
+
+ printf("------------------ RBCP : register access ------------------\n");
+ printf("\n");
+ printf("Start sending packet data");
+
+ for(packetNo=0; packetNo<total_packet; ++packetNo){
+
+ // SiTCPrcvRBCP_ACK(0);
+ SiTCPRBCPskeleton(0xff, 0x80, address+(packetNo*255), 0xff, address+(packetNo*255));
+
+ for(int i=0; i<255; ++i){
+ SiTCPsndData[i] = data[i+(packetNo*255)];// <- sndData: 0~255
+ }
+
+ memcpy(SiTCPsndBuf+sizeof(struct bcp_header), SiTCPsndData, sizeof SiTCPsndData);
+
+ int len = 0;
+ len = sendto(SiTCPGetUDPSock(), SiTCPsndBuf, sizeof SiTCPsndData + sizeof(struct bcp_header), 0,
+ (struct sockaddr *)&SiTCPudpAddr, sizeof(SiTCPudpAddr));//important!
+
+ if(len < 0){
+ perror("Send DAQ Start Signal");
+ printf("exit(1);!!!\n");
+ }
+
+ SiTCPrcvRBCP_ACK(0);
+ // std::cout << SiTCPrcvRBCP_ACK(1) << std::endl;
+
+ printf(".");
+ }
+ printf("Done!!!\n");
+ printf("\n");
+
+ printf("Number of sent packets = %d\n", packetNo);
+ printf("\n");
+
+}
+//------------------------------------------------------------------------------------------------------
+//--------------------EASIROC MADC sender---------------------------
+int Senderread_madc( int data){// data: send only 1 data length
+
+ //Set ADC ch to FPGA reg
+ SiTCPRBCPskeleton(0xff, 0x80, 0x00000012, 0x1, 0x00000012);
+ SiTCPsndData[0] = data;
+
+ memcpy(SiTCPsndBuf+sizeof(struct bcp_header), SiTCPsndData, sizeof SiTCPsndData);
+ int len = 0;
+ len = sendto(SiTCPGetUDPSock(), SiTCPsndBuf, 1 + sizeof(struct bcp_header), 0,
+ (struct sockaddr *)&SiTCPudpAddr, sizeof(SiTCPudpAddr));//important!
+ if(len < 0){
+ perror("UDP Send error");
+ printf("exit(1);!!!\n");
+ }
+ SiTCPrcvRBCP_ACK(1);
+
+ SiTCPRBCPskeleton(0xff, 0x80, 0x0000001f, 0x1, 0x0000001f);
+ SiTCPsndData[0] = 1;
+
+ memcpy(SiTCPsndBuf+sizeof(struct bcp_header), SiTCPsndData, sizeof SiTCPsndData);
+ len = 0;
+ len = sendto(SiTCPGetUDPSock(), SiTCPsndBuf, 1 + sizeof(struct bcp_header), 0,
+ (struct sockaddr *)&SiTCPudpAddr, sizeof(SiTCPudpAddr));//important!
+ if(len < 0){
+ perror("UDP Send error");
+ printf("exit(1);!!!\n");
+ }
+ SiTCPrcvRBCP_ACK(1);
+
+ //Sleep(20000);//wait ADC ch change
+ Sleep(2000);//wait ADC ch change
+
+ //start Read ADC
+ SiTCPRBCPskeleton(0xff, 0x80, 0x00000012, 0x1, 0x00000012);
+ SiTCPsndData[0] = 240;
+
+ memcpy(SiTCPsndBuf+sizeof(struct bcp_header), SiTCPsndData, sizeof SiTCPsndData);
+ len = 0;
+ len = sendto(SiTCPGetUDPSock(), SiTCPsndBuf, 1 + sizeof(struct bcp_header), 0,
+ (struct sockaddr *)&SiTCPudpAddr, sizeof(SiTCPudpAddr));//important!
+ if(len < 0){
+ perror("UDP Send error");
+ printf("exit(1);!!!\n");
+ }
+ SiTCPrcvRBCP_ACK(1);
+
+ SiTCPRBCPskeleton(0xff, 0x80, 0x0000001f, 0x1, 0x0000001f);
+ SiTCPsndData[0] = 0;
+
+ memcpy(SiTCPsndBuf+sizeof(struct bcp_header), SiTCPsndData, sizeof SiTCPsndData);
+ len = 0;
+ len = sendto(SiTCPGetUDPSock(), SiTCPsndBuf, 1 + sizeof(struct bcp_header), 0,
+ (struct sockaddr *)&SiTCPudpAddr, sizeof(SiTCPudpAddr));//important!
+ if(len < 0){
+ perror("UDP Send error");
+ printf("exit(1);!!!\n");
+ }
+ SiTCPrcvRBCP_ACK(1);
+
+ //read data
+ int rd_data = 0;
+ int rd_data1 = 0;
+ int rd_data2 = 0;
+ SiTCPRBCPskeleton(0xff, 0xc0, 0x00000004, 0x1, 0x00000004);
+ len = 0;
+ len = sendto(SiTCPGetUDPSock(), SiTCPsndBuf, 1 + sizeof(struct bcp_header), 0,
+ (struct sockaddr *)&SiTCPudpAddr, sizeof(SiTCPudpAddr));//important!
+ if(len < 0){
+ perror("UDP recv error");
+ printf("exit(1);!!!\n");
+ }
+ rd_data1 = SiTCPrcvRBCP_ACK(1);
+ // std::cout << rd_data << std::endl;
+ SiTCPRBCPskeleton(0xff, 0xc0, 0x00000005, 0x1, 0x00000005);
+ len = 0;
+ len = sendto(SiTCPGetUDPSock(), SiTCPsndBuf, 1 + sizeof(struct bcp_header), 0,
+ (struct sockaddr *)&SiTCPudpAddr, sizeof(SiTCPudpAddr));//important!
+ if(len < 0){
+ perror("UDP recv error");
+ printf("exit(1);!!!\n");
+ }
+ rd_data2 = SiTCPrcvRBCP_ACK(1);
+ // std::cout << rd_data << std::endl;
+ rd_data = rd_data1*256 + rd_data2;
+
+ return rd_data;
+
+}
+
+
+
+//------------------------------------------------------------------------------------------------------
+void Senderclear_all(){
+ unsigned char address;
+ int data;
+ //int nbyte;
+
+ // Send register clear
+ address = 0x00;
+ data = 0x0;
+ Senderudp_send(address, data);
+
+ printf("Clear all registers in FPGA.\n");
+}
+
+
Index: l2d2_easyroc/sender.h
===================================================================
--- l2d2_easyroc/sender.h (nonexistent)
+++ l2d2_easyroc/sender.h (revision 291)
@@ -0,0 +1,15 @@
+#pragma once
+#include "SiTCP.h"
+//#include <unistd.h>
+
+ void SenderInit();
+ void SenderClose();
+
+ void Senderudp_send( unsigned int address, int data);
+ int Senderudp_recv( unsigned int address, int data);
+ void SenderRBCPpacket_send( unsigned int address, unsigned char length, int* data);
+ void SenderRBCPpacket_recv( unsigned int address, unsigned char length, int* data);
+ void SenderRBCP_multi_packet_send( unsigned int address, unsigned int total_length, int* data);
+ int Senderread_madc( int data);
+ void Senderclear_all();
+ void Sendertcp_send( char* data);
Index: l2d2_easyroc/test
===================================================================