diff --git a/convertDRS4/README.txt b/convertDRS4/README.txt index d10cfb685bb0ca7841c3abb6e54951e211d0a972..1467860ef1dda7293c007f1fc61c94b6367f29fa 100644 --- a/convertDRS4/README.txt +++ b/convertDRS4/README.txt @@ -1,8 +1,8 @@ Application for convertation of binary files acquired by DRS4 to ROOT file. -1. g++ -o read_binary read_binary.cpp -lm `root-config --cflags --libs` -This compiles read_binary.cpp file and makes object file read_binary. -2. ./read_binary_DRS4 ./data/rawDataDSR4/file_name.dat -With the help of the object file it is possible to convert binary file .dat to file .root (which we call raw /home/dariak/NeuRad_tests/data/rawDataDSR4) -3. read_root.C -This script reads raw file and make another file .root with simple analysis /home/dariak/NeuRad_tests/data/dataDSR4 +1. read_binary.cpp complies within makefile (commaned make clean, then make in Neurad_test) and makes object file read_binary in current directory +2. To convert binary file to root file do: +./read_binary_DRS4 ./data/rawDataDSR4/input_file_name.dat ../data/rawDataDSR4/output_file_name.root +!both input and output files should be specified! + + diff --git a/convertDRS4/read_binary.cpp b/convertDRS4/read_binary.cpp index 466aa5b1e481b37a21d8fe2b851005e776829ca6..1b66e0907e593fa67b53ad5abeaabad2ee5ccd48 100644 --- a/convertDRS4/read_binary.cpp +++ b/convertDRS4/read_binary.cpp @@ -85,15 +85,28 @@ int main(int argc, const char * argv[]) float bin_width[16][4][1024]; int i, j, b, chn, n, chn_index, n_boards; double t1, t2, t3, t4, dt, dt34; - char filename[256]; + char filename[256]; //for input binary file + char outroot[256]; //for output root file int ndt; double threshold, sumdt, sumdt2; + if (argc == 3) { + strcpy(filename, argv[1]); + strcpy(outroot, argv[2]); + } + else if (argc == 2) { + printf("Error: both input binary file and output root file should be specified!\n"); + return -1; + } + else { + printf("Error: input binary file and output root file should be specified!\n"); + return -1; + } -//for ROOT +// ---------------for ROOT - TFile* rfile = new TFile("../data/rawDataDSR4/NeuRad_test_07_1.root", "RECREATE"); + TFile* rfile = new TFile(outroot, "RECREATE"); TTree* rtree = new TTree("rtree", "tree for drs4 analysis"); //rtree->Branch("t1", &t1, "t1/D"); //br for time of threshold crossing signal in 1 ch // rtree->Branch("t2", &t2, "t2/D"); //br for time of threshold crossing signal in 2 ch @@ -111,13 +124,8 @@ int main(int argc, const char * argv[]) // rtree->Branch("amp_ch2", amp_ch2, "amp_ch2[ncell]/D"); // rtree->Branch("time_ch2", time_ch2, "time_ch2[ncell]/D"); - if (argc > 1) - strcpy(filename, argv[1]); - else { - printf("Usage: read_binary \n"); - return 0; - } - +//---------------- + // open the binary waveform file FILE *f = fopen(filename, "r"); if (f == NULL) { diff --git a/data/rawDataDSR4/NeuRad_test_07_1.root b/data/rawDataDSR4/NeuRad_test_07_1.root index 4db35226a0dab300ab36bd3d7a62f73ec3c7f304..90a88499c4f2ab689bb01700927b9ef67a1c87b7 100644 Binary files a/data/rawDataDSR4/NeuRad_test_07_1.root and b/data/rawDataDSR4/NeuRad_test_07_1.root differ