Skip to content

Commit

Permalink
Merge pull request #196 from JeffersonLab/nsj_ttod_script
Browse files Browse the repository at this point in the history
Nsj ttod script
  • Loading branch information
zihlmann authored Jul 11, 2022
2 parents 5fd3f54 + 31fa928 commit 70ad01e
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 3 deletions.
28 changes: 25 additions & 3 deletions CDC_scripts/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This directory contains scripts useful for extracting the hit thresholds from configuration files and for calculating the correction to Garfield's drift time tables due to the magnetic field.
This directory contains scripts useful for extracting the hit thresholds from configuration files, calculating the correction to Garfield's drift time tables due to the magnetic field and estimating the time to distance calibration parameters from EPICS data.

# Finding the hit thresholds

Expand Down Expand Up @@ -30,7 +30,7 @@ ccdb add /CDC/hit_thresholds -r 71860-72435 cdc_h.txt

# Calculating the correction to Garfield's drift time tables for the magnetic field

The process is documented in GlueX-Docs 2512 and 2593.
The process is documented in [GlueX-doc-2592](https://halldweb.jlab.org/doc-private/DocDB/ShowDocument?docid=2592) and [2513](https://halldweb.jlab.org/doc-private/DocDB/ShowDocument?docid=2513).
The script is in the subdirectory Bfield\_drift\_correction.

**To find the correction function:**
Expand All @@ -51,4 +51,26 @@ Bfield->Scan("Bz:r:z","Bz>1.92&&z>=15&&z<=170&&r>=5&&r<=65")
root -q Bfield_dt2.C
```

5. Add the fit parameters obtained to the CCDB table /CDC/cdc_drift_parms.
5. Add the fit parameters obtained to the CCDB table /CDC/cdc\_drift\_parms.


# Estimating time to distance parameters from EPICS data

The script is located in the subdirectory calc_ttod. It uses the functions from [GlueX-doc-5394](https://halldweb.jlab.org/doc-private/DocDB/ShowDocument?docid=5394) to estimate the time to distance parameters (for CCDB /CDC/drift\_parameters) for 2125V runs using EPICS data for temperature and pressure.

**To find the time to distance parameters:**

1. Obtain the EPICS data for the time of interest. The names of the EPICS variables are:
```
RESET:i:GasPanelBarPress1
GAS:i::CDC_Temps-CDC_D1_Temp
GAS:i::CDC_Temps-CDC_D3_Temp
GAS:i::CDC_Temps-CDC_D4_Temp
GAS:i::CDC_Temps-CDC_D5_Temp
```

2. Run the script, providing as arguments the run number (used in the output filename), uncalibrated pressure and the downstream thermocouple temps D1 and D3 to D5. This should generate an output file in the correct format for the CCDB table. The example below created the file ttod_d10370.txt.

```
root -q "calc_ttod_from_epics.C(10370,99.8644,25.6996,25.8,25.9009,25.3)"
```
41 changes: 41 additions & 0 deletions CDC_scripts/calc_ttod/calc_ttod_from_epics.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Estimate CDC time to distance parameters for CCDB /CDC/drift_parameters for 2125V runs using functions from GlueX-doc-5394
// Arguments are run number (for output filename), uncalibrated pressure and downstream thermocouple temps excluding D2
// NSJ 14 June 2022

void calc_ttod_from_epics(int run, float p, float t1, float t3, float t4, float t5) {

float calp = 1.064*p - 5.098; // convert Hall D gas panel reading into kPa following https://logbooks.jlab.org/entry/3810976
float t = 273.15 + 0.25*(t1 + t3 + t4 + t5); // convert from C to K


float d = calp/t; // kPa/K
printf("density %.3f\n",d);


/* // fitted vs uncalibrated pressure from EPICS
float a1= 2.1053 + -0.0109 *p;
float b1 = -1.3129 + 0.0120 *p;
float c1 = 0.6935 + -0.0068 *p;
float a2 = -2.6136 + 0.0255 *p;
float b2 = 3.4686 + -0.0394 *p;
float c2 = -2.7263 + 0.0297 *p;
*/


// fitted vs calibrated pressure/temperature

float a1 = 2.0157 + -2.9468 *d;
float b1 = -1.1960 + 3.1979 *d;
float c1 = 0.6225 + -1.8051 *d;
float a2 = -2.3818 + 6.8484 *d;
float b2 = 3.1014 + -10.5439 *d;
float c2 = -2.4503 + 7.9724 *d;


FILE *pfile = fopen(Form("ttod_d%i.txt",run),"w");
fprintf(pfile,"%.6f %.6f 0 %.6f %.6f 0 %.6f %.6f 0 1.1 -0.08\n",a1,a2,b1,b2,c1,c2);
fprintf(pfile,"%.6f %.6f 0 %.6f %.6f 0 %.6f %.6f 0 1.1 -0.08\n",a1,-1*a2,b1,-1*b2,c1,-1*c2);
fclose(pfile);

}

0 comments on commit 70ad01e

Please sign in to comment.