Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

m_histo_conv.c

Go to the documentation of this file.
00001 //-------------------------------------------------------------
00002 //        Go4 Release Package v3.04-01 (build 30401)
00003 //                      28-November-2008
00004 //---------------------------------------------------------------
00005 //   The GSI Online Offline Object Oriented (Go4) Project
00006 //   Experiment Data Processing at EE department, GSI
00007 //---------------------------------------------------------------
00008 //
00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI
00010 //                    Planckstr. 1, 64291 Darmstadt, Germany
00011 //Contact:            http://go4.gsi.de
00012 //----------------------------------------------------------------
00013 //This software can be used under the license agreements as stated
00014 //in Go4License.txt file which is part of the distribution.
00015 //----------------------------------------------------------------
00016 #include "typedefs.h"
00017 #include <stdlib.h>
00018 #include <stdio.h>
00019 #include <errno.h>
00020 #include <ctype.h>
00021 #include <string.h>
00022 #include "f_ut_wild.h"
00023 #include "f_his_hist.h"
00024 #include "f_radware.h"
00025 /**************************************************************************/
00026 main(argc,argv)
00027 int argc;
00028 char *argv[];
00029 {
00030 s_his_head *ps_his_head,*ps_his_head_dir;
00031 INTS4 i_j,ii,l_status,l_port,l_int;
00032 INTS4 l_size,l_histos=0;
00033 INTS4 *pl_all,*pl_dir,*pl_l;
00034 REAL4 *pr,*pr_l;
00035 CHARS *pc;
00036 CHARS c_server[32];
00037 CHARS c_histo[32];
00038 CHARS c_base[32];
00039 CHARS c_access[32];
00040 CHARS c_file[128];
00041 
00042 if(argc < 7)
00043 {
00044 printf("node port|6009 base password \"histogram\" [-print|-dir|-rad]\n");
00045 exit(0);
00046 }
00047 l_port=atol(argv[2]);
00048 strcpy(c_server,argv[1]);
00049 strcpy(c_access,argv[4]);
00050 strcpy(c_base,argv[3]);
00051 strcpy(c_histo,argv[5]);
00052 
00053 pl_all=NULL;
00054 /* get directory ******************************************************/
00055  if(strstr(argv[6],"-d") != NULL)
00056    {
00057      printf("Get directory %s from server %s [%d] pass=*** base=%s\n",
00058        c_histo,c_server,l_port,c_base);
00059      ps_his_head_dir=NULL;
00060      pl_dir=NULL;
00061      l_status = f_his_getdir(c_server,l_port,c_base,c_access,c_histo,(INTS4 **)&pl_dir,(INTS4 **)&l_histos);
00062      if(l_status == COMM__SUCCESS)
00063        {
00064     printf("Histograms: %d, slot size: %d b, Total: %d b\n",
00065       l_histos,sizeof(s_his_head),l_histos*sizeof(s_his_head));
00066     ps_his_head_dir = (s_his_head *)pl_dir;
00067     for(i_j=0;i_j<l_histos;i_j++)
00068       {
00069              if(f_ut_wild(ps_his_head_dir->c_name,c_histo)==0)
00070         printf("%-31s %s %8d %8d\n",
00071           ps_his_head_dir->c_name,ps_his_head_dir->c_dtype,ps_his_head_dir->l_bins_1,ps_his_head_dir->l_bins_2);
00072         ps_his_head_dir++;
00073       }
00074        } else printf("Error %d\n",l_status);
00075      exit(0);
00076    }
00077 /* get histograms ******************************************************/
00078  printf("Lookup histograms %s at server %s [%d] pass=*** base=%s\n",
00079    c_histo,c_server,l_port,c_base);
00080  ps_his_head_dir=NULL;
00081  pl_dir=NULL;
00082  l_status = f_his_getdir(c_server,l_port,c_base,c_access,c_histo,(INTS4 **)&pl_dir,(INTS4 **)&l_histos);
00083  if(l_status != COMM__SUCCESS)
00084    {
00085      printf("Error %d getting histograms %s\n",l_status,c_histo);
00086      exit(0);
00087    }
00088  ps_his_head_dir = (s_his_head *)pl_dir;
00089  for(i_j=0;i_j<l_histos;i_j++)
00090    {
00091      if(f_ut_wild(ps_his_head_dir->c_name,c_histo)==0)
00092        {
00093     ps_his_head=NULL;
00094     pl_all=NULL;
00095     l_status = f_his_gethis(c_server,l_port,c_base,c_access,ps_his_head_dir->c_name,
00096              (s_his_head **)&ps_his_head,(INTS4 **)&pl_all,(INTS4 **)&l_size);
00097     if(l_status != COMM__SUCCESS)
00098       {
00099         printf("Error %d getting histogram %s\n",l_status,ps_his_head_dir->c_name);
00100         exit(0);
00101       }
00102 
00103     /* process histogram ******************************************************/
00104     pl_l =         pl_all;
00105     pr_l =(REAL4 *)pl_all;
00106     if(ps_his_head->c_dtype == 'i') l_int=1; else l_int=0;
00107 
00108     /* print histogram ******************************************************/
00109     if(strstr(argv[6],"-p") != NULL)
00110       {
00111         printf("Histogram %s\n",ps_his_head_dir->c_name);
00112         printf("          channels: %10d, total: %10d [b], %s %8d %8d\n",
00113           ps_his_head->l_bins_1*ps_his_head->l_bins_2,l_size,
00114                     ps_his_head->c_dtype,ps_his_head->l_bins_1,ps_his_head->l_bins_2);
00115         /* print data channels */
00116         if(ps_his_head->l_bins_2 == 1)
00117           {
00118        for (i_j = 0; i_j < (ps_his_head->l_bins_1 - ps_his_head->l_bins_1 % 6); i_j += 6)
00119          {
00120            if(l_int) printf("%7d:%9d %9d %9d %9d %9d %9d\n",
00121                   i_j + 1,*pl_l,*(pl_l+1),*(pl_l+2),*(pl_l+3),*(pl_l+4),*(pl_l+5));
00122            else      printf("%7d:%11.4g %11.4g %11.4g %11.4g %11.4g %11.4g\n",
00123                   i_j + 1,*pr_l,*(pr_l+1),*(pr_l+2),*(pr_l+3),*(pr_l+4),*(pr_l+5));
00124            pl_l+=6;
00125            pr_l+=6;
00126          }
00127        if ((ps_his_head->l_bins_1 % 6))
00128          {
00129            printf("%7d:",i_j + 1);
00130            for (i_j = ps_his_head->l_bins_1 - ps_his_head->l_bins_1 % 6; i_j < ps_his_head->l_bins_1; i_j++)
00131              {
00132           if(l_int) printf("%9d ", *pl_l);
00133           else      printf("%11.4g ", *pr_l);
00134           pl_l++;
00135           pr_l++;
00136              }
00137            printf("\n");
00138          }}else printf("2d Histograms %s not supported\n",ps_his_head_dir->c_name);
00139       }
00140     /* dump radware histogram ******************************************************/
00141     if(strstr(argv[6],"-r") != NULL)
00142       {
00143         if(argc == 8)strcpy(c_file,argv[7]);
00144         else         strcpy(c_file,"rad_");
00145         strcat(c_file,ps_his_head_dir->c_name); // name from directory call includes path
00146         pc=c_file;
00147         for(ii=0;ii<strlen(c_file);ii++)
00148           {
00149        if(*pc == '/')*pc='-';
00150        if(*pc == '(')*pc='[';
00151        if(*pc == ')')*pc=']';
00152        if(*pc == ' ')*pc='_';
00153        pc++;
00154           }
00155         strcat(c_file,".spe");
00156         if(ps_his_head->l_bins_2 == 1)
00157           {
00158        if(l_int == 0)
00159          {
00160            pr=(REAL4 *) malloc(ps_his_head->l_bins_1*4);
00161            pr_l=pr;
00162            for(ii=0;ii<ps_his_head->l_bins_1;ii++)*pr++=(REAL4)*pl_l++;
00163          }
00164        l_status=f_radware_out1d(c_file,ps_his_head->c_name,pr_l,ps_his_head->l_bins_1,0);
00165        if(l_status == 0)printf("Radware histogram %s written to file %s.\n",ps_his_head_dir->c_name,c_file);
00166        else             printf("Radware histogram %s NOT written to file %s, ERROR!\n",ps_his_head_dir->c_name,c_file);
00167        if(l_int == 0)free(pr_l);
00168           } else printf("2d Histograms %s not supported\n",ps_his_head_dir->c_name);
00169       }
00170     free(pl_all);
00171        }
00172      ps_his_head_dir++;
00173    }
00174 }
00175 
00176 
00177 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Fri Nov 28 12:59:32 2008 for Go4-v3.04-1 by  doxygen 1.4.2