#!/usr/bin/gawk -f # meaning of fields # 1) digital filter settings # 2) data mode: ZS (+parameters), noZS, test patterns # 3) number of timebins # 4) tracklet parameters # 5) trigger setup # ----------------------------------------------------------------------- # Preparation for parsing of one config # ----------------------------------------------------------------------- # Default settings { TRK = "off"; ZS = "off" } # Ignore comments and empty lines /^#/ { next; } /^$/ { next; } # Sanity checks length($0) >= 200 { print "Name of configuration is too long" > "/dev/stderr"; exit 1; } NF<5 || NF>6{ print "Wrong number of fields in record, must be 5 or 6" > "/dev/stderr"; print "Record: " $0 > "/dev/stderr"; exit 1; } # ----------------------------------------------------------------------- # Main readout mode # ----------------------------------------------------------------------- # Zero suppression mode settings $2 ~ /^zs/ { HCID="zs" } # Full readout mode (non-ZS) $2 ~ /^nozs/ { HCID="nozs" } # Testpattern modes $2 ~ /^tp1/ { HCID="testpattern1" } $2 ~ /^tp2/ { HCID="testpattern2" } $2 ~ /^tp3/ { HCID="testpattern3" } $2 ~ /^tp4/ { HCID="testpattern4" } $2 ~ /^tp5/ { HCID="testpattern5" } $2 ~ /^tp6/ { HCID="testpattern6" } # ----------------------------------------------------------------------- # Options for ZS mode # ----------------------------------------------------------------------- # Suppress empty headers $2 ~ /^zs.*-deh/ { HCID = HCID "-deh"; } # Write every 128th / 256th / 1024th event? $2 ~ /^zs.*-(e[[:digit:]]*)/ { match($2, /^zs.*-(e[[:digit:]]*)/, arr) ; HCID = HCID "-" arr[1]; } # Specify single pad and 3-pad cluster thresholds for ZS $2 ~ /^zs.*-[sc]/ { match($2, /^zs.*-([sc][scmn.0-9]*)/, arr); ZS = arr[1]; } # ----------------------------------------------------------------------- # Options for non-ZS mode # ----------------------------------------------------------------------- # Statistics mode to collect noise stats $2 ~ /^nozs.*-stat/ { HCID = HCID "-stat"; } # ----------------------------------------------------------------------- # Filter configuration # ----------------------------------------------------------------------- { FILTER = $1; } # ----------------------------------------------------------------------- # Trigger configuration # ----------------------------------------------------------------------- { TRG = $5; } # ----------------------------------------------------------------------- # Options # ----------------------------------------------------------------------- NF>5 { OPT = $6; } NF==5 { OPT = ""; } # ----------------------------------------------------------------------- # Special tracklet modes # ----------------------------------------------------------------------- # Disable tracklet calculation $4 ~ /^notrk/ { HCID = HCID "-notrk"; TRK = "off"; } # Tracklets for cosmic trigger at CERN $4 ~ /^csmtrk/ { HCID = HCID "-csmtrk"; TRK = "csmtrk"; } # Standard tracklets $4 ~ /^trk-/ { match($4, /^trk-(.*)/, arr); TRK = arr[1]; } # Auto-generated tracklet config $4 ~ /^trkl-/ { match($4, /(^trkl-.*)/, arr); TRK = arr[1]; } # ----------------------------------------------------------------------- # Number of timebins # ----------------------------------------------------------------------- $3 ~ /^tb/ { match($3, /^tb([[:digit:]]*)/, arr); TB = arr[1]; } # ----------------------------------------------------------------------- # In the end, write the configuration file to stdout # ----------------------------------------------------------------------- { if (NF == 5) cfgname = $1 "_" $2 "_" $3 "_" $4 "_" $5; if ( NF == 6) cfgname = $1 "_" $2 "_" $3 "_" $4 "_" $5 "_" $6; if ( length(cfgname)>=99 ) { print "Name of configuration is too long" > "/dev/stderr"; exit 1; } filename = "configurations/cf_" cfgname ".cfg" if ( outfile == "" ) { of = filename; } else { of = outfile; } if ( report == "name" ) { print cfgname; } else if (report == "file" ) { print filename; } else if (report == "depend" ) { print "configurations/cf_" cfgname ".ldr: src/filter/" $1 ".dat" ; } else if (report == "input" ) { print $0; } # generic first part of configuration print "mcm_temp/autoread_off" > of; print "common/ttcrx_regs_s" >> of; print "common/reset" >> of; print "common/fitred" >> of; # configuration dependent settings print "filter/" FILTER ".auto" >> of; print "zs/zs-" ZS ".auto" >> of; print "trg/" TRG >> of; if ( ! match(TRK,/off/) ) { if (match(TRK,/^trkl/)) print "trk/" TRK ".auto" >> of; else print "trk/" TRK >> of; print "trk/trk-patch" >> of; } print "hcid/" HCID >> of; print "timebins/tb" TB ".auto" >> of; if ( ! match(OPT,/nopm/) ) { if ( match(OPT,/pm-edge/) ) { print "patchmaker/pm_set_adcmask_all_off" >> of; print "patchmaker/pm_apply" >> of; } else { print "patchmaker/pm_set_adcmask_default" >> of; print "patchmaker/pm_apply" >> of; } } if ( match(OPT,/nion/) ) print "common/ni_powersave_off_hcm" >> of; if ( match(FILTER,/g/) ) { print "gaintbl/apply" >> of; } # generic final part print "common/pretrigger_acq" >> of; print "common/ttcrx_regs_t" >> of; print "ori/pwr_on" >> of; close(of); }