Gnuscope: Difference between revisions

From FSU Fox's Lab Wiki
Jump to navigation Jump to search
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 26: Line 26:


== Simple C++ code ==
== Simple C++ code ==
=== writing ===


<syntaxhighlight lang="C++" line>
<syntaxhighlight lang="C++" line>
Line 46: Line 48:


// write file
// write file
fwrite(multi, 1, 1, outFile);
for( int ev = 0; ev < numEvent; ev++){
for( int i = 0; i < multi; i++){
  fwrite(multi[ev], 1, 1, outFile); // write multi[ev] to outFile for 1 byte and 1 time.
  fwrite(id[i], 1, 1, outFile);  
  for( int i = 0; i < multi; i++){
  fwrite(energy[i], 2, 1, outFile);  
    fwrite(id[ev][i], 1, 1, outFile);  
    fwrite(energy[ev][i], 2, 1, outFile); // write energy[ev][i] to outFile for 2 byte and 1 time.
  }
  fwrite(multi[ev], 1, 1, outFile);  
}
}
fwrite(multi, 1, 1, outFile);
fclose(outFile);
fclose(outFile);


</syntaxhighlight>
</syntaxhighlight>
=== Reading ===


= Using docker =
= Using docker =

Latest revision as of 14:50, 3 May 2022

introduction

The code is for the analysis of gamma-ray spectroscopy. It can date back to July 2002. The last update of the code was June 28, 2017.

The code use GTK2 for a graphical interface.

To download https://fsunuc.physics.fsu.edu/~caussyn/gnuscope_ddc_gtk2.tar.gz

data structure

The data is a binary format. A event should be like this:

<multi><ID><Energy><ID><Energy>.... <multi>

where <multi> is a multiplicity of the event, <ID> is the ID of the detector, and <Energy> is the energy of that detector.

items data type length max
mulit unsigned char 1 byte 256
ID unsigned char 1 byte 256
Energy unsigned short 2 byte 65535

Simple C++ code

writing

FILE * outFile = fopen("saveFileName.gnc", "w+");

int numEvent = 1000;
int maxMulti = 100;

char * multi = new char[numEvent];
char ** ID = new * char[numEvent];
unsigned short ** energy = new * char[numEvent];
for( int i = 0; i < numEvent; i++){
  ID[i] = new char[maxMulti];
  energy[i] = new char[maxMulti];
}

// fill data here


// write file
for( int ev = 0; ev < numEvent; ev++){
  fwrite(multi[ev], 1, 1, outFile);  // write multi[ev] to outFile for 1 byte and 1 time.
  for( int i = 0; i < multi; i++){
    fwrite(id[ev][i], 1, 1, outFile); 
    fwrite(energy[ev][i], 2, 1, outFile); // write energy[ev][i] to outFile for 2 byte and 1 time.
  }
  fwrite(multi[ev], 1, 1, outFile); 
}
fclose(outFile);

Reading

Using docker

Compiling the code usually results in failure in Debian 10 or Ubuntu 20.04. To bypass this, we can use docker to run the code in Ubuntu 14.04.

For detail on setup the docker image, please check https://fsunuc.physics.fsu.edu/elog/dataServer/3.

One of the inconveniences is that the program can only run locally, not remotely.