/* 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); }
/* initialization of data before data analysis */ int evt_start_np(){ chamber_p chamb; plane_p plane; int i, ipl; double d; /* for TGC */ chamb = &tgc_mwdc; #if DT2D_TAB chamb_get_dt2d_tab(chamb); #endif chamb_get_config(chamb); for(ipl=0; ipl<chamb->npl; ipl++){ plane = &chamb->plane[ipl]; plane->pres = 0.5; /* 0.5 mm resolution */ plane->fit = dr_is_true(dr_get(TGC_FIT_PLANE[ipl])); } if(dr_exists(d=dr_get(TGC_MAX_NCOMB))) chamb->max_ncomb = (int)d; chamb->allow_wireskip = dr_is_true(dr_get(TGC_ALLOW_WIRESKIP)); d = dr_get(TGC_N_VPLANE); chamb->nproj = dr_exists(d) ? min((int)d, MaxNIntPl) : 0; for(i=0; i<chamb->nproj; i++) dr_ref_n(spf("TGC_PLANE_%d",i), &chamb->h_proj[i]); dr_ref_n("TGC_X", &chamb->h_x); dr_ref_n("TGC_Y", &chamb->h_y); /* for FEC */ chamb = &fec_mwdc; #if DT2D_TAB chamb_get_dt2d_tab(chamb); #endif chamb_get_config(chamb); for(ipl=0; ipl<chamb->npl; ipl++){ plane = &chamb->plane[ipl]; plane->pres = 0.5; /* 0.5 mm resolution */ plane->fit = dr_is_true(dr_get(FEC_FIT_PLANE[ipl])); } if(dr_exists(d=dr_get(FEC_MAX_NCOMB))) chamb->max_ncomb = (int)d; chamb->allow_wireskip = dr_is_true(dr_get(FEC_ALLOW_WIRESKIP)); d = dr_get(FEC_N_VPLANE); chamb->nproj = dr_exists(d) ? min((int)d, MaxNIntPl) : 0; for(i=0; i<chamb->nproj; i++) dr_ref_n(spf("FEC_PLANE_%d",i), &chamb->h_proj[i]); dr_ref_n("FEC_X", &chamb->h_x); dr_ref_n("FEC_Y", &chamb->h_y); return(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); }
/* 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); }
/* initialization of data before data analysis */ int evt_start_rcnp(){ double d; int i, cmin, cmax, ipl; chamber_p chamb; plane_p plane; /* common */ #if !DT2D_TAB get_dt2d_prm(); #endif /* for GR */ if(dr_is_true(dr_get(ANALYZE_GR))){ cmax = dr_exists(d=dr_get(GR_VDC_MAX_CLUST_SIZE)) ? min(dr_int(d),Clst_MaxClstSize) : Clst_DefMaxClstSize; cmin = dr_exists(d=dr_get(GR_VDC_MIN_CLUST_SIZE)) ? dr_int(d) : Clst_DefMinClstSize; chamb = &gr_vdc; #if DT2D_TAB chamb_get_dt2d_tab(chamb); #endif chamb_get_config(chamb); d = dr_get(DEBUG_GR_N_OUTPUTRAY); gr_n_outputray = dr_exists(d) ? (int)d : 0; if(dr_is_true(dr_get(ANALYZE_GR_MATRIX))){ get_gr_matrix(); } for(ipl=0; ipl<chamb->npl; ipl++){ plane = &chamb->plane[ipl]; plane->min_clst_size = cmin; plane->max_clst_size = cmax; plane->ana_2hit_clst = dr_is_true(dr_get(GR_VDC_ANA_2HIT_CLUST)); /* angular resolution of a plane */ plane->ares = dr_get(GR_ARES[ipl])*d2r; if(dr_is_nothing(plane->ares)) plane->ares = 1.05*d2r; /* default */ } chamb->ana_mult_clst = dr_is_true(dr_get(GR_VDC_ANA_MULTI_CLUST)); chamb->max_chi2 = dr_get(GR_VDC_MAX_CHI2); if(dr_is_nothing(chamb->max_chi2)) chamb->max_chi2 = 0.; d = dr_get(GR_N_VPLANE); chamb->nproj = dr_exists(d) ? min((int)d, MaxNIntPl) : 0; for(i=0; i<chamb->nproj; i++) dr_ref_n(spf("GR_PLANE_%d",i), &chamb->h_proj[i]); dr_ref_n("GR_XP", &chamb->h_x); /* projection points */ dr_ref_n("GR_YP", &chamb->h_y); /* projection points */ fprintf(stderr, "GR VDC multi-cluster analysis = %s\n", chamb->ana_mult_clst ? "ON" : "OFF"); fprintf(stderr, "GR VDC 2-hit cluster analysis = %s\n", chamb->plane[0].ana_2hit_clst ? "ON" : "OFF"); fprintf(stderr, "GR VDC cluster size = %d <= nhit <= %d\n", cmin, cmax); } /* for LAS */ if(dr_is_true(dr_get(ANALYZE_LAS))){ cmax = dr_exists(d=dr_get(LAS_VDC_MAX_CLUST_SIZE)) ? min(dr_int(d),Clst_MaxClstSize) : Clst_DefMaxClstSize; cmin = dr_exists(d=dr_get(LAS_VDC_MIN_CLUST_SIZE)) ? dr_int(d) : Clst_DefMinClstSize; chamb = &las_vdc; #if DT2D_TAB chamb_get_dt2d_tab(chamb); #endif chamb_get_config(chamb); d = dr_get(DEBUG_LAS_N_OUTPUTRAY); las_n_outputray = dr_exists(d) ? (int)d : 0; get_las_matrix(); for(ipl=0; ipl<chamb->npl; ipl++){ plane = &chamb->plane[ipl]; plane->min_clst_size = cmin; plane->max_clst_size = cmax; plane->ana_2hit_clst = dr_is_true(dr_get(LAS_VDC_ANA_2HIT_CLUST)); /* angular resolution of a plane */ plane->ares = dr_get(LAS_ARES[ipl])*d2r; if(dr_is_nothing(plane->ares)) plane->ares = 1.05*d2r; /* default */ } d = dr_get(LAS_N_VPLANE); chamb->nproj = dr_exists(d) ? min((int)d, MaxNIntPl) : 0; for(i=0; i<chamb->nproj; i++) dr_ref_n(spf("LAS_PLANE_%d",i), &chamb->h_proj[i]); dr_ref_n("LAS_XP", &chamb->h_x); /* projection points */ dr_ref_n("LAS_YP", &chamb->h_y); /* projection points */ chamb->ana_mult_clst = dr_is_true(dr_get(LAS_VDC_ANA_MULTI_CLUST)); chamb->max_chi2 = dr_get(LAS_VDC_MAX_CHI2); if(dr_is_nothing(chamb->max_chi2)) chamb->max_chi2 = 0.; fprintf(stderr, "LAS VDC multi-cluster analysis = %s\n", chamb->ana_mult_clst ? "ON" : "OFF"); fprintf(stderr, "LAS VDC cluster size = %d <= nhit <= %d\n", cmin, cmax); } return(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); }
void dht_get_keyword (dht_t * du, const char *key, void (*cb) (const char *, const char *, void *), void *arg) { dr_get (du->router, key, cb, arg); }
static void print_param_node(ml_node_t *node, int row, FILE *fd, const param_t *p) { int j, k, len; int all; assert(node->type == ML_PARAM); all = (node->u.p.len == 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); fprintf(fd, "%d", di_get(p->xi,k)); if (j < len-1) fputc(' ',fd); if (p->info) printf("Wrote value %i for I%i\n", di_get(p->xi,k), k); } } 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); fprintf(fd, "%d", di_get(p->xi,k)); if (p->info) printf("Wrote value %i for I%i\n", di_get(p->xi,k), k); } 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); fprintf(fd, "%.8e", dr_get(p->xr,k)); if (j < len-1) fputc(' ',fd); if (p->info) printf("Wrote value %e for R%i\n", dr_get(p->xr,k), k); } } 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); fprintf(fd, "%.8e", dr_get(p->xr,k)); if (p->info) printf("Wrote value %e for R%i\n", dr_get(p->xr,k), k); } 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); fprintf(fd, "%.8e", dr_get(p->fun,k)); if (j < len-1) fputc(' ',fd); if (p->info) printf("Wrote value %e for O%i\n", dr_get(p->fun,k), k); } } 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); fprintf(fd, "%.8e", dr_get(p->fun,k)); if (p->info) printf("Wrote value %e for O%i\n", dr_get(p->fun,k), k); } break; case 'T': fputs(p->tag, fd); if (p->info) printf("Wrote value '%s' for tag\n", p->tag); break; default: assert(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; }