THaRasteredBeam::THaRasteredBeam( const char* name, const char* description ) : THaBeam( name, description ) { AddDetector( new THaRaster("Raster","raster",this) ); }
Q330_CFG *q330ReadCfg(char *name) { int i, status, ntoken; FILE *fp = NULL; Q330_CFG *cfg = NULL; QDP_TYPE_C1_QCAL DefaultCalib = Q330_DEFAULT_CALIB; char *token[MAX_TOKEN]; char input[MAXLINELEN]; LNKLST *addr = NULL, *detector = NULL; static char *DefaultName = Q330_DEFAULT_CFG_PATH; /* Locate and open the file */ if (name == NULL) name = getenv(Q330_CFG_ENV_STRING); if (name == NULL) name = DefaultName; if (!utilFileExists(name)) return NULL; if ((fp = fopen(name, "r")) == NULL) return ReadCfgCleanReturn(fp, cfg, addr, NULL); /* Create the config structure and save the name */ if ((cfg = CreateCfg(name)) == NULL) return ReadCfgCleanReturn(fp, cfg, addr, NULL); cfg->calib = DefaultCalib; /* Initialize the temp lists */ if ((addr = listCreate()) == NULL) return ReadCfgCleanReturn(fp, cfg, addr, NULL); if ((detector = listCreate()) == NULL) return ReadCfgCleanReturn(fp, cfg, addr, NULL); /* Read the contents of the file into the list */ while ((status = utilGetLine(fp, input, MAXLINELEN, COMMENT, NULL)) == 0) { ntoken = utilParse(input, token, " \t", MAX_TOKEN, QUOTE); /* "q330" entries define Q330_ADDR structures */ if (strcasecmp(token[0], "q330") == 0) { if (!AddAddr(addr, token, ntoken)) return ReadCfgCleanReturn(fp, cfg, addr, NULL); /* "detector" entries define Q330_ADDR structures */ } else if (strcasecmp(token[0], "detector") == 0) { if (!AddDetector(detector, token, ntoken)) return ReadCfgCleanReturn(fp, cfg, addr, NULL); /* "calib" entries define QDP_TYPE_C1_QCAL structures */ } else if (strcasecmp(token[0], "calib") == 0) { if (!AddCalib(&cfg->calib, token, ntoken)) return ReadCfgCleanReturn(fp, cfg, addr, NULL); /* anything else is not supported */ } else { errno = EINVAL; return ReadCfgCleanReturn(fp, cfg, addr, NULL); } } if (status != 1) return ReadCfgCleanReturn(fp, cfg, addr, NULL); /* Copy the addresses into the output structure */ if (!listSetArrayView(addr)) return ReadCfgCleanReturn(fp, cfg, addr, NULL); cfg->naddr = addr->count; if ((cfg->addr = (Q330_ADDR *) malloc(sizeof(Q330_ADDR) * cfg->naddr)) == NULL) return ReadCfgCleanReturn(fp, cfg, addr, NULL); for (i = 0; i < addr->count; i++) cfg->addr[i] = *((Q330_ADDR *) addr->array[i]); /* Copy the detectors into the output structure */ if (!listSetArrayView(detector)) return ReadCfgCleanReturn(fp, cfg, addr, NULL); cfg->ndetector = detector->count; if ((cfg->detector = (Q330_DETECTOR *) malloc(sizeof(Q330_DETECTOR) * cfg->ndetector)) == NULL) return ReadCfgCleanReturn(fp, cfg, detector, NULL); for (i = 0; i < detector->count; i++) cfg->detector[i] = *((Q330_DETECTOR *) detector->array[i]); /* All done, return the newly created structure */ return ReadCfgCleanReturn(fp, NULL, addr, cfg); }