Ejemplo n.º 1
0
thStatus thRemoveHists(char *block_name){
  thHistSpecList *thishist,*nexthist;
  thHBlockList *thisblock,*nextblock,**lastblockp;

  if(block_name)
    if(*block_name=='\0')
      block_name = 0;
    else
      lastblockp = &thHBlockListP;

  if(thHBlockListP == 0){
    return(S_FAILURE);		/* No histograms defined */
  } else {
    thisblock = thHBlockListP;
    if(!block_name)
      HDELET(0);		/* Free all space */
    while(thisblock) {
      if(block_name)
	if(strcasecmp(block_name,thisblock->blockname)!=0){
	  lastblockp = &thisblock->next;
	  thisblock = thisblock->next;
	  continue;
	}
      thishist = thisblock->var->opaque;
      while(thishist){
	nexthist = thishist->next;
	if(block_name) {
	  HDELET(*(DAINT *) thishist->varname->varptr);
	}
	free(thishist);
	thishist = nexthist;
      }
      nextblock = thisblock->next;
      if(block_name){
	if(strcasecmp(block_name,thisblock->blockname)==0) {
	  *lastblockp = nextblock;
	  free(thisblock);
	}
	return(S_SUCCESS);
      } else {
	free(thisblock);
      }
      thisblock = nextblock;
    }
    if(block_name) {
      fprintf(stderr,"Hist block %s not found\n",block_name);
      return(S_FAILURE);
    }
    thHBlockListP = (thHBlockList *) NULL;
  }
  return(S_SUCCESS);
}
Ejemplo n.º 2
0
//----
// function to display PMT pulse (flash-ADC array arr[]) :
//
void ANTI2DBc::displ_a(char comm[], int id, int mf, const geant arr[]){
  integer i;
  geant tm,a(0.);
  geant tb,tbi;
  char name[80], buf[10];
  sprintf(buf, "%4d\n",id);
  strcpy(name,comm);
  strcat(name,buf);
  tb=geant(mf)*ANTI2DBc::fadcbw();
  tbi=ANTI2DBc::fadcbw();
  HBOOK1(2638,name,100,0.,100*tb,0.);
  for(i=1;i<=ANTI2C::ANFADC;i++){
    if(i%mf==0){
      a+=arr[i-1];
      tm=i*tbi-0.5*tb;
      HF1(2638,tm,a/geant(mf));
      a=0.;
    }
    else{
      a+=arr[i-1];
    }
  }
  HPRINT(2638);
  HDELET(2638);
  return ;
}
Ejemplo n.º 3
0
/*----------------------------- get_next_scan -------------------------------*/
int get_next_scan( int nscan)
  {

  if ( nscan != 1)
    {              // we don't need to fit and save at the begining 
    fit_thresh(nscan-1);
    save_hist(nscan-1);
    print_scan_result(nscan-1);
    HDELET(0);
    }
  init_hist (nscan);
  return 0;
  }
Ejemplo n.º 4
0
/*----------------------------- 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;
}
Ejemplo n.º 5
0
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;
  }