예제 #1
0
int main(int argc, char *argv[])
{
  HLIMIT(PAWC_SIZE);

  if (argc !=  3) {
    printf("usage: %s <module> <channel>\n", argv[0]);
    exit(EXIT_FAILURE);
  }
   
  int mod = atoi(argv[1]);
  int ch  = atoi(argv[2]);
  
  PixieInterface pif("pixie.cfg");
  pif.GetSlots();
  pif.Init();
           
  usleep(200);
  pif.Boot(PixieInterface::DownloadParameters |
	   PixieInterface::ProgramFPGA |
	   PixieInterface::SetDAC, true);
  

  TraceGrabber grabber;
  forChannel(pif, mod, ch, grabber);

  char traceFile[] = "trace.dat";
  char fileOptions[] = "N";

  HRPUT (0, traceFile, fileOptions);
  
  return EXIT_SUCCESS;
}
예제 #2
0
파일: test_19.c 프로젝트: slava77/emulibSVN
/*----------------------------- save_hist_19 ----------------------------------*/
int save_hist_19()
{

  char file_name_element[] = "/test_results/temp/test_19_";
  char *file_name;
  file_name = malloc(strlen(datadir_translation) +
                     strlen(file_name_element) + 10);
  if (file_name == NULL)
    {
      printf("malloc() failed for file_name.\n");
      return -1;
    }
  sprintf(file_name,"%s%s%02d.his",datadir_translation,
          file_name_element,1);
  /* Save histograms */
  printf("Saving histograms in file %s\n", file_name);
  HRPUT(0, file_name, "N");
  HDELET(0);
  free(file_name);
  return 0;
}
예제 #3
0
파일: test_24.c 프로젝트: slava77/emulibSVN
int test_24_finish(void)
  {
  int      j, ilayer, isegment, icfeb, n, nfail;
  logical  channel_ok;
  float    limits[7];
  char     timestring[40];
  time_t   t;
  char *file_his_name;

  /* Save histograms */
  file_his_name = malloc(strlen(datadir_translation) + 
			 strlen(test_24_file_his_el) + 1);
  if (file_his_name == NULL)
    {
    printf("malloc() failed for file_his_name.  Could not save histograms.\n");
    }
  else
    {
    sprintf(file_his_name,"%s%s",
	    datadir_translation, test_24_file_his_el);
    printf("Saving histograms\n");
    HRPUT(0, file_his_name, "N");
    free(file_his_name);    
    }

/* Look for values outside limits */
  fprintf(fp, "\nList of sections with peak outside limits %d-%d, or with "
	  "chisq/ndf > 10:\n", LOWER_LIMIT, UPPER_LIMIT);
  nfail = 0;

  for (ilayer = 0; ilayer < NLAYER; ilayer++)
    {
    for (isegment = 0; isegment < nsegments; isegment++)
      {
      for (icfeb = 0; icfeb < ncfebs; icfeb++)
	{
        channel_ok = _TRUE;
        j = ncfebs * isegment + icfeb;

        if (peak[ilayer][j] < LOWER_LIMIT || peak[ilayer][j] > UPPER_LIMIT)
	  {
          channel_ok = _FALSE;
          fprintf(fp, "Layer %d segment %d cfeb %d has peak= %4.0f\n", 
		  ilayer+1, isegment+1, icfeb+1, peak[ilayer][j]);
	  }

        if (chisq[ilayer][j] > 10)
	  {
          channel_ok = _FALSE;
          fprintf(fp, "Layer %d segment %d cfeb %d has chisq=%8.2f\n", 
		  ilayer+1, isegment+1, icfeb+1, chisq[ilayer][j]);
	  }

        if (!channel_ok) nfail++;
	}
      }
    }
  fprintf(fp, "\n");
  fprintf(fp, "Total bad channels = %d\n", nfail);

/* Print voltage Equalization table */
  fprintf(fp, "\nEqualization table rounded to nearest 10 volts:\n");
  if (nsegments == 5) fprintf(fp, "HV segment:     1     2     3     4     5    all\n");
  else                fprintf(fp, "HV segment:     1     2     3    all\n");
  fprintf(fp, "------------------------------------------------\n");
  for (ilayer = 0; ilayer < NLAYER; ilayer++)
    {
    fprintf(fp, "Layer %d:   ", ilayer+1);
    for (isegment = 0; isegment < nsegments; isegment++)
      {
      if (dv[ilayer][isegment]  >= 0) 
	n = 10 * (int)((dv[ilayer][isegment] / 10) + 0.5);
      else n = 10 * (int)((dv[ilayer][isegment] / 10) - 0.5);
      fprintf(fp, "  %4d", n);
      }
    if (dv_all[ilayer] >= 0) 
      n = 10 * (int)((dv_all[ilayer] / 10) + 0.5);
    else n = 10 * (int)((dv_all[ilayer] / 10) - 0.5);
    fprintf(fp, "  %4d\n", n);
    }
  fprintf(fp, "\n");


/* Plot results */
  limits[0] = 0;                   /* layer histo ymin */
  limits[1] = 1400;                /* layer histo ymax */
  limits[2] = 0;                   /* summary histo ymin */
  limits[3] = 1400;                /* summary histo ymax */
  limits[4] = LOWER_LIMIT;         /* lower limit line */
  limits[5] = UPPER_LIMIT;         /* upper limit line */
  limits[6] = nsegments * ncfebs;
  
  one_page_plot_v3(24, 1, GAIN_PLOT, (float *)ppeak, (float *)ppeak, limits, 
		   csc_name, "Landau peaks", "Landau peak, ADC "
		   "counts (5x5 sum)", 0);

/* Print mandatory summary statement */
  if (nfail > 0) fprintf(fp, "Test result = Failed\n\n");
  else fprintf(fp, "Test result = OK\n\n");

/* Add the date and time */
  time(&t);
  sprintf(timestring, "%s", ctime(&t));
  fprintf(fp, "%s\n\n", timestring);

  fclose(fp);

  HDELET(0);

  return 0;
  }