Project

General

Profile

Simplified ROOT Histogramming using GRU

This page is a sandbox for ideas on how develop a generic histogrammer based on GRU

XML file examples

Example #1
<histograms>
  <histogram>
    <name>first</name>
    <title>First nice Histogram</title>
    <dimension>1</dimension>
    <parameter>
      <name>energy</name>
      <min>0.0</min>
      <max>32768.0</max>
      <binning>4096</binnig>
    </parameter>
  </histogram>
  <histogram>
    <name>second</name>
    <title>not so nice histogram</title>
    <dimension>2</dimension>
    <parameter>
      <name>energy</name>
      <min>0.0</min>
      <max>32768.0</max>
      <binning>4096</binnig>
    </parameter>
    <parameter>
      <name>tof</name>
      <min>0.0</min>
      <max>1000.0</max>
      <binning>2000.0</binnig>
    </parameter>
  </histogram>
</histograms>

Example #2
<narval_vigru_interface>
  <histograms_graphs>
    <nb_TGraph>1</nb_TGraph>
    <TGraph>
      <param>
        <TGraph_name>TGraph_name</TGraph_name>
        <TGraph_title>TGraph_title</TGraph_title>
        <binning>1000</binning>
        <x_title>x_title</x_title>
        <y_title>y_title</y_title>
      </param>
    </TGraph>
    <nb_TH1>2</nb_TH1>
    <TH1>
      <param>
        <TH>
          <name>TH1</name>
          <title>name</title>
          <type_CSIFD>F</type_CSIFD>
        </TH>
        <x>
          <name>name</name>
          <min>10</min>
          <max>20</max>
          <binning>200</binning>
        </x>
      </param>
      <param>
        <TH>
          <name>name</name>
          <title>name</title>
          <type_CSIFD>F</type_CSIFD>
        </TH>
        <x>
          <name>name</name>
          <min>50</min>
          <max>80</max>
          <binning>1024</binning>
        </x>
      </param>
    </TH1>
    <nb_TH2>1</nb_TH2>
    <TH2>
      <param>
        <TH>
          <name>TH2</name>
          <title>name</title>
          <type_CSIFD>D</type_CSIFD>
        </TH>
        <x>
          <name>name</name>
          <min>30</min>
          <max>40</max>
          <binning>200</binning>
        </x>
        <y>
          <name>name</name>
          <min>23</min>
          <max>693</max>
          <binning>1402</binning>
        </y>
      </param>
    </TH2>
    <nb_TH3>1</nb_TH3>
    <TH3>
      <param>
        <TH>
          <name>TH3</name>
          <title>name</title>
          <type_CSIFD>F</type_CSIFD>
        </TH>
        <x>
          <name>name</name>
          <min>32</min>
          <max>48</max>
          <binning>1024</binning>
        </x>
        <y>
          <name>name</name>
          <min>1</min>
          <max>2.6</max>
          <binning>1208</binning>
        </y>
        <z>
          <name>name</name>
          <min>3.2</min>
          <max>4.89</max>
          <binning>2048</binning>
        </z>
      </param>
    </TH3>
  </histograms_graphs>
</narval_vigru_interface>

Example #3, synthesis proposal between #1 and #2
<histograms>
  <TGraph>
    <name>graph</name>
    <param>
      <name>energy_channel_0</name>
    </param>
    <param>
      <name>energy_channel_1</name>
    </param>
    <param>
      <name>energy_channel_2</name>
    </param>
  </TGraph>
  <TH1>
    <name>first</name>
    <title>First nice Histogram</title>
    <x>
      <name>energy</name>
      <min>0.0</min>
      <max>32768.0</max>
      <binning>4096</binning>
    </x>
  </TH1>
  <TH2>
    <name>second</name>
    <title>not so nice histogram</title>
    <x>
      <name>energy</name>
      <min>0.0</min>
      <max>32768.0</max>
      <binning>4096</binning>
    </x>
    <y>
      <name>tof</name>
      <min>0.0</min>
      <max>1000.0</max>
      <binning>2000.0</binning>
    </y>
  </TH2>
</histograms>

Example #4 last modification
<narval_vigru_interface>
  <histograms_graphs>
    <nb_TH1>2</nb_TH1>
    <TH1>
      <histogram>
        <header>
          <name>V550-CH0#0</name>
          <title>Histo-1D_V550-CH0#0</title>
          <type_CSIFD>D</type_CSIFD>
        </header>
        <x>
          <name>V550-CH0_channel_0</name>
          <kind>UNSIGNED_INT_32</kind>
          <min>0</min>
          <max>1024</max>
          <binning>1024</binning>
        </x>
      </histogram>
      <histogram>
        <header>
          <name>V550-CH0#1</name>
          <title>Histo-1D_V550-CH0#1</title>
          <type_CSIFD>D</type_CSIFD>
        </header>
        <x>
          <name>V550-CH0_channel_1</name>
          <kind>UNSIGNED_INT_32</kind>
          <min>0</min>
          <max>1024</max>
          <binning>1024</binning>
        </x>
      </histogram>
    </TH1>
    <nb_TH2>1</nb_TH2>
    <TH2>
      <histogram>
        <header>
          <name>V550-CH0#0_V550-CH0#1</name>
          <title>Histo-2D_V550-CH0#0_V550-CH0#1</title>
          <type_CSIFD>D</type_CSIFD>
        </header>
        <x>
          <name>V550-CH0_channel_0</name>
          <kind>UNSIGNED_INT_32</kind>
          <min>0</min>
          <max>1024</max>
          <binning>1024</binning>
        </x>
        <y>
          <name>V550-CH0_channel_1</name>
          <kind>UNSIGNED_INT_32</kind>
          <min>0</min>
          <max>1024</max>
          <binning>1024</binning>
        </y>
      </histogram>
    </TH2>
  </histograms_graphs>
</narval_vigru_interface>

API proposition

Common Specifications
#ifndef _API_DATA_FLOW_DECODER_
#define _API_DATA_FLOW_DECODER_

void initialise_decode_library (char *configuration_file_name, unsigned int *error_code); /* error_code to 0 => success */

void *get_first_event (void *buffer); /* NULL Value => ERROR */
void *get_next_event (void *buffer, unsigned int buffer_length, void *event); /* NULL Value => end of buffer */

unsigned int parameter_correspondance (char *param);

int get_integer (void *event, unsigned int parameter, unsigned int *error_code); /* error_code to 0 => success */
unsigned int get_unsigned_integer  (void *event, unsigned int parameter, unsigned int *error_code); /* error_code to 0 => success */
unsigned long long get_unsigned_long_long   (void *event, unsigned int parameter, unsigned int *error_code); /* error_code to 0 => success */
/* error_code to 1 => unknown parameter */

/* and so on */

#endif

Common Specifications correspopndant à #exemple4

extern "C" {
void *get_first_event (void *buffer);
void *get_next_event (void *buffer, 
               unsigned int buffer_length, 
               void *event);

unsigned int parameter_correspondance (char *param_string);

unsigned char get_U8 (void *event, 
               unsigned int param, unsigned int *error_code);
unsigned short get_U16 (void *event, 
               unsigned int param, unsigned int *error_code);               
unsigned int get_U32 (void *event, 
               unsigned int param, unsigned int *error_code);
unsigned long long get_U64 (void *event, 
               unsigned int param, unsigned int *error_code);

signed char get_I8 (void *event, 
               unsigned int param, unsigned int *error_code);
short get_I16 (void *event, 
               unsigned int param, unsigned int *error_code);               
int get_I32 (void *event, 
               unsigned int param, unsigned int *error_code);
long long get_I64 (void *event, 
               unsigned int param, unsigned int *error_code);

float get_float (void *event, 
               unsigned int param, unsigned int *error_code);
double get_double (void *event, 
               unsigned int param, unsigned int *error_code);
};

ADF example
#include "api_data_flow_decoder.h" 

struct adf_header
{
  unsigned int length;
  unsigned int message_type;
  unsigned int event_number;
  unsigned long long time_stap;
}

void *get_first_event (void *buffer)
{
   /* first event starts at the beginning of the buffer */
   return buffer;
}

unsigned int parameter_correspondance (char *param)
{
   if (strcmp(param, "length") == 0)
  {
     return 1;
  }
   if (strcmp(param, "event_number") == 0)
  {
     return 2;
  }
   if (strcmp(param, "message_type") == 0)
  {
     return 3;
  }
  if (strcmp(param, "time_stamp") == 0)
  {
     return 4;
  }
   return 0;
}

void *get_next_event (void *buffer, unsigned int buffer_length, void *event)
{
   struct adf_header *data;
   void *next_address;

   data = (struct adf_header *) event;
   next_address = event + data->length;
   if (next_address >= buffer + buffer_length)
   {
      return NULL:
   }
   return next_address;
}

int get_integer (void *event, unsigned int parameter, unsigned int *error_code)
{
   *error_code = 1;
   return 0;
}
unsigned int get_unsigned_integer  (void *event, unsigned int parameter, unsigned int *error_code)
{
   struct adf_header *data;

   data = (struct adf_header *) event;
   *error_code = 0;
   if (parameter == 1)
   {
      return data->length;
   }
   if (parameter == 2)
   {
      return data->event_number;
   }
   if (parameter == 3)
   {
      return data->message_type;
   }
   *error_code = 1;
   return 0;
}
unsigned long long get_unsigned_long_long   (void *event, unsigned int parameter, unsigned int *error_code)
{
   struct adf_header *data;

   data = (struct adf_header *) event;
   *error_code = 0;
   if (parameter == 4)
   {
      return data->time_stamp;
   }
   *error_code = 1;
   return 0;
}