Exemplo n.º 1
0
/* Event Reduction */
int event(){
  int   i, j, gl_flag;
  double f;
  static int m=0;

  if(!m){
		evt_start();
		m=1;
	}
	message();
#if 0
  if(evt_blk())
		return(-1);
#endif

	dr_set(PROC_NUM[0], cflag ? childn:-1);  /* child process number */
	evt_time();
	evt_scaler();
	dr_set(BLOCK_ANA[0], ablk);
	if(dr_is_true(dr_get(EVENT_RCNP))){
    /* Analyzer RCNP Data */
		if(dr_is_true(dr_get(EVENT_BEND))){
			/* Block-end Event */
		}else{
			evt_init_rcnp();
			evt_ipr();
			gl_flag = 0;
			/* for GR */
      if(dr_is_true(dr_get(ANALYZE_GR))){
				evt_init_gr();
				evt_gr_adc();
				evt_gr_tdc();
				if(dr_is_true(dr_get(ANALYZE_GR_VDC))){
					evt_chamb_gr();
					evt_gr_kinema();
					gl_flag++;
				}
			}
			/* for LAS */
      if(dr_is_true(dr_get(ANALYZE_LAS))){
				evt_init_las();
				evt_las_adc();
				evt_las_tdc();
				if(dr_is_true(dr_get(ANALYZE_LAS_VDC))){
					evt_chamb_las();
					evt_las_kinema();
					gl_flag++;
				}
			}
			if(gl_flag==2){
				evt_gl_kinema();
			}
#if LAS_FPP_MWDC
			/* for LAS_FPP */
      if(dr_is_true(dr_get(ANALYZE_LAS_FPP))){
				evt_init_las_fpp();
				evt_chamb_las_fpp();
			}
#endif
#if NP_MWDC
			/* for NP */
      if(dr_is_true(dr_get(ANALYZE_NP))){
				evt_init_np();
				evt_chamb_np();
			}
#endif
			/* for GR FPP */
      if(dr_is_true(dr_get(ANALYZE_GR_FPP))){
				evt_init_gr_fpp();
				evt_gr_fpp_adc();
				evt_gr_fpp_tdc();
				evt_chamb_gr_fpp();
			}
		}
	}
#if F2_MWDC
	else if(dr_is_true(dr_get(EVENT_F2))){
    /* Analyzer SMART F2 Data */
		if(dr_is_true(dr_get(ANALYZE_F2))){
			evt_init_f2();
			evt_f2_adc();
			evt_f2_tdc();
			if(dr_is_true(dr_get(ANALYZE_F2_MWDC))){
				evt_chamb_f2();
				evt_f2_kinema();
			}
#if 0
			evt_f2_3377();
#endif
		}
	}
#endif
	show_debug();
	dst_write_data();

	if(rootflag == 1)
		root_write_data();

	dr_set(ANALYZED,1);
#if 0
sleep(1);
#endif
	return(0);
}
Exemplo n.º 2
0
/* GR-3377 data analysis */
int evt_chamb_gr(){
	int  i;
	chamber_p  chamb;
	plane_p    plane;
	ray_p    ray;
	ray_t    ray2;
	double   d;
	double   shift;

	chamb = &gr_vdc;
	ray   = &chamb->ray;
	if(!dr_exists(dr_get(GR_RAYID[0]))){
		for(i=0; i<chamb->npl; i++){
			plane = &chamb->plane[i];
			chamb_clust(plane);
			chamb_drift(plane);
			chamb_pos(plane);
		}
		chamb_ray(chamb);	
		dr_set(GR_RAYID,ray->rayid);
		dr_set(GR_CHI2[0],chamb->chi2);
		dr_set(GR_NCOMB[0],chamb->ncomb);
		if(ray->rayid==RAYID_NOERR){
			//			fprintf(stderr, "GRAD_X = %g\n", ray->dir.x);
			dr_set(GR_GRAD_X[0],ray->dir.x);
			dr_set(GR_GRAD_Y[0],ray->dir.y);
			/* rotation of axes as z=central-ray */
			ray_rotate_z(ray,dr_get(GR_VDC_TILT[2]));
			ray_rotate_y(ray,dr_get(GR_VDC_TILT[1]));
			ray_rotate_x(ray,dr_get(GR_VDC_TILT[0]));
			/* output of tracking information  */
			if(gr_n_outputray)
				chamb_outputray(chamb,&fd_gr_outputray,FNAMGRRAY,&gr_n_outputray);
			/* output of ray information */
			dr_set(GR_RAY_X[0], ray->org.x);
			dr_set(GR_RAY_Y[0], ray->org.y);
			dr_set(GR_RAY_TH[0],atan(ray->dir.x));
			dr_set(GR_RAY_PH[0],atan(ray->dir.y));
		}
	}else{
		ray->org.x = dr_get(GR_RAY_X[0]);
		ray->org.y = dr_get(GR_RAY_Y[0]);
		ray->org.z = 0.0;
		ray->dir.x = tan(dr_get(GR_RAY_TH[0]));
		ray->dir.y = tan(dr_get(GR_RAY_PH[0]));
		ray->dir.z = 1.0;
		ray->rayid = dr_int(dr_get(GR_RAYID[0]));
	}
	if(ray->rayid==RAYID_NOERR){
    /* projection to virtual planes */
		chamb_intersection(chamb);
		if(dr_is_true(dr_get(ANALYZE_GR_MATRIX))){
			/* trace-back by matrix
				 x  and  y are in mm  in the VDC cordinate system
				    (GR_X[0] and GR_Y[0])
				 th and ph are in rad in the central ray cordinate system
				    (GR_TH[0] and GR_PH[0])
			*/
			ray2.org.x = dr_get(GR_X[0]);
			ray2.org.y = dr_get(GR_Y[0]);
			ray2.dir.x = dr_get(GR_TH[0]);
			ray2.dir.y = dr_get(GR_PH[0]);
			dr_set(GR_XC[0], trace_back(&ray2, gr_xmat,  n_gr_xmat,  1));
			dr_set(GR_AI[0], trace_back(&ray2, gr_amat,  n_gr_amat,  1));
			dr_set(GR_BI[0], trace_back(&ray2, gr_bmat,  n_gr_bmat,  1));
			dr_set(GR_YC[0], trace_back(&ray2, gr_ymat,  n_gr_ymat,  1));
			dr_set(GR_PHC[0],trace_back(&ray2, gr_phmat, n_gr_phmat, 1));
		}
	}
	return(0);
}
Exemplo n.º 3
0
/* NP-3377 data analysis */
int evt_chamb_np(){
	chamber_p chamb;
	plane_p   plane;
	int       ipl;
	ray_p     ray;
	double      d;

	chamb = &tgc_mwdc;
	ray   = &chamb->ray;
	for(ipl=0; ipl<chamb->npl; ipl++){
		plane = &chamb->plane[ipl];
    chamb_clust(plane);
		chamb_drift(plane);
		chamb_pos(plane);
	}
	if(dr_exists(d=dr_get(LAS_RAYID)) && dr_int(d)==0){
		chamb_ray(chamb);
		dr_set(TGC_RAYID,ray->rayid);
		dr_set(TGC_CHI2[0],chamb->chi2);
		if(ray->rayid==RAYID_NOERR){
			/* rotation of axes as z=central-ray */
			ray_rotate_z(ray,dr_get(TGC_TILT[2]));
			ray_rotate_y(ray,dr_get(TGC_TILT[1]));
			ray_rotate_x(ray,dr_get(TGC_TILT[0]));
			/* output of ray information */
			dr_set(TGC_RAY_X[0], ray->org.x);
			dr_set(TGC_RAY_Y[0], ray->org.y);
			dr_set(TGC_TH[0],atan(ray->dir.x));
			dr_set(TGC_PH[0],atan(ray->dir.y));
			/* projection to virtual planes */
			chamb_intersection(chamb);
		}
	}

	chamb = &fec_mwdc;
	ray   = &chamb->ray;
	for(ipl=0; ipl<chamb->npl; ipl++){
		plane = &chamb->plane[ipl];
    chamb_clust(plane);
		chamb_drift(plane);
		chamb_pos(plane);
	}
	if(dr_exists(d=dr_get(LAS_RAYID)) && dr_int(d)==0){
		chamb_ray(chamb);
		dr_set(FEC_RAYID,ray->rayid);
		dr_set(FEC_CHI2[0],chamb->chi2);
		if(ray->rayid==RAYID_NOERR){
			/* rotation of axes as z=central-ray */
			ray_rotate_z(ray,dr_get(FEC_TILT[2]));
			ray_rotate_y(ray,dr_get(FEC_TILT[1]));
			ray_rotate_x(ray,dr_get(FEC_TILT[0]));
			/* output of ray information */
			dr_set(FEC_RAY_X[0], ray->org.x);
			dr_set(FEC_RAY_Y[0], ray->org.y);
			dr_set(FEC_TH[0],atan(ray->dir.x));
			dr_set(FEC_PH[0],atan(ray->dir.y));
			/* projection to virtual planes */
			chamb_intersection(chamb);
		}
	}
	
	return(0);
}
Exemplo n.º 4
0
/* LAS-3377 data analysis */
int evt_chamb_las(){
	double  f1, f2;
	int  i;
	chamber_p  chamb;
	plane_p    plane;
	ray_p      ray;

	chamb = &las_vdc;
	ray   = &chamb->ray;
	for(i=0; i<chamb->npl; i++){
		plane = &chamb->plane[i];
		chamb_clust(plane);
    chamb_drift(plane);
    chamb_pos(plane);
	}

	/* Temporary for E154 03-MAY-2006 */ 
	i = chamb->npl;
	chamb->npl = 4;
	chamb_ray(chamb);	
	chamb->npl = i;
	
	dr_set(LAS_RAYID,ray->rayid);
	dr_set(LAS_CHI2[0],chamb->chi2);
	dr_set(LAS_NCOMB[0],chamb->ncomb);
	if(ray->rayid==RAYID_NOERR){
    /* trace-back by matrix (with the VDC coordingate space) */
		dr_set(LAS_DP[0],trace_back(ray, las_xmat, n_las_xmat, 0));
		dr_set(LAS_AI[0],trace_back(ray, las_amat, n_las_amat, 0)/1000.);
		dr_set(LAS_GRAD_X[0], ray->dir.x/ray->dir.z);
		dr_set(LAS_GRAD_Y[0], ray->dir.y/ray->dir.z);
    /* rotation of axes as z=central-ray */
		ray_rotate_z(ray,dr_get(LAS_VDC_TILT[2]));
		ray_rotate_y(ray,dr_get(LAS_VDC_TILT[1]));
		ray_rotate_x(ray,dr_get(LAS_VDC_TILT[0]));
    /* output of tracking information  */
		if(las_n_outputray)
			chamb_outputray(chamb,&fd_las_outputray,FNAMLASRAY,&las_n_outputray);
    /* output of ray information */
		dr_set(LAS_RAY_X[0], ray->org.x);
		dr_set(LAS_RAY_Y[0], ray->org.y);
		dr_set(LAS_RAY_TH[0],atan(ray->dir.x));
		dr_set(LAS_RAY_PH[0],atan(ray->dir.y));
    /* projection to virtual planes */
		chamb_intersection(chamb);
	}
	return(0);
}
Exemplo n.º 5
0
static int read_param_node(ml_node_t *node, int row, const char *line,
                           param_t *p)
{
    int i, j, k, len, all;
    char *end;
    char command[MAXLINESIZE];

    assert(node->type == ML_PARAM);

    all = (node->u.p.len == 0);

    i = 0;
    switch (node->u.p.type) {
    case 'I':
        if (!node->u.p.column && (all || node->u.p.len > 1)) {

            /* Row vector. */
            len = all ? da_n(p->xi) : node->u.p.len;
            for (j = 0; j < len; j++) {
                k = all ? j : di_get(node->u.p.index, j);
                p->xi = di_set(p->xi, k, strtol(&line[i], &end, 10));

                i += end - &line[i];

                if (p->info)
                    printf("Read value %i for I%i\n", di_get(p->xi,k), k);

                if (p->usematc) {
                    sprintf(command, "I(%d) = %d", k, di_get(p->xi,k));
                    MTC_DOMATH(command);
                }
            }

        } else {

            /* Column vector or scalar.  */
            if (node->u.p.len == 1)
                k = di_get(node->u.p.index,0);
            else
                k = all ? row : di_get(node->u.p.index, row);

            p->xi = di_set(p->xi, k, strtol(&line[i], &end, 10));

            i += end - &line[i];

            if (p->info)
                printf("Read value %i for I%i\n", di_get(p->xi,k), k);

            if (p->usematc) {
                sprintf(command, "I(%d) = %d", k, di_get(p->xi,k));
                MTC_DOMATH(command);
            }
        }
        break;

    case 'R':
        if (!node->u.p.column && (all || node->u.p.len > 1)) {

            /* Row vector. */
            len = all ? da_n(p->xr) : node->u.p.len;
            for (j = 0; j < len; j++) {
                k = all ? j : di_get(node->u.p.index,j);
                p->xr = dr_set(p->xr, k, strtod(&line[i], &end));

                i += end - &line[i];

                if (p->info)
                    printf("Read value %e for R%i\n", dr_get(p->xr,k), k);

                if (p->usematc) {
                    sprintf(command, "R(%d) = %e", k, dr_get(p->xr,k));
                    MTC_DOMATH(command);
                }
            }

        } else {

            /* Column vector or scalar.  */
            if (node->u.p.len == 1)
                k = di_get(node->u.p.index,0);
            else
                k = all ? row : di_get(node->u.p.index, row);

            p->xr = dr_set(p->xr, k, strtod(&line[i], &end));

            i += end - &line[i];

            if (p->info)
                printf("Read value %e for R%i\n", dr_get(p->xr,k), k);

            if (p->usematc) {
                sprintf(command, "R(%d) = %e", k, dr_get(p->xr,k));
                MTC_DOMATH(command);
            }
        }
        break;

    case 'O':
        if (!node->u.p.column && (all || node->u.p.len > 1)) {

            /* Row vector. */
            len = all ? da_n(p->fun) : node->u.p.len;
            for (j = 0; j < len; j++) {
                k = all ? j : di_get(node->u.p.index,j);
                p->fun = dr_set(p->fun, k, strtod(&line[i], &end));

                i += end - &line[i];

                if (p->info)
                    printf("Read value %e for O%i\n", dr_get(p->fun,k), k);

                if (p->usematc) {
                    sprintf(command, "O(%d) = %e", k, dr_get(p->fun,k));
                    MTC_DOMATH(command);
                }
            }

        } else {

            /* Column vector or scalar.  */
            if (node->u.p.len == 1)
                k = di_get(node->u.p.index,0);
            else
                k = all ? row : di_get(node->u.p.index, row);

            p->fun = dr_set(p->fun, k, strtod(&line[i], &end));

            i += end - &line[i];

            if (p->info)
                printf("Read value %e for O%i\n", dr_get(p->fun,k), k);

            if (p->usematc) {
                sprintf(command, "O(%d) = %e", k, dr_get(p->fun,k));
                MTC_DOMATH(command);
            }
        }
        break;

    case 'T':
        fprintf(stderr, PKG_NAME "TAG parameters are input only\n");

    default:
        assert(0);
    }

    return i;
}