# PID study proposal

### PID Studies

For each final state

• Determine p/theta range of each final state particle
• Compare PID variable distributions between data and MC
• First stage: 1D distributions integrated over all kinematics
• Optional: 2D distributions from different p/theta bins
• Do this for each run period under investigation
• Determine selection criteria which are 99% and 95% efficient

### Systematic Studies

How to determine systematic uncertainty in efficiency due to PID cuts (assumes you have a final state with some clean peak: rho, phi, pi0, eta, eta'...):

• make tight PID cuts on all particles except the one you are testing the efficiency of - call this particle P
• make two sets of invariant mass distributions for whatever peak you have
• masses for events in which P satisfies the standard PID requirements
• masses for events in which P fails the standard PID requirements
• Fit each mass distribution to get the yields: N(pass) and N(fail)
• efficiency of the cut is N(pass) / [N(pass) + N(fail)]
• compare this efficiency between data and MC to determine how well it is modeled
• Note: need to check for the presence of peaking backgrounds, good to look at bggen MC

Note this probably only works for the timing PID right now. Will need a separate set of files to test CDC dE/dx, but for now just look at the distributions. The biggest contributor here is probably the rate of events without enough hits to properly calculate dE/dx

### Example study of π0 → γγ

README for example DSelector and Python scripts to complete the studies above. Brief slides with some example plots.

The Python scripts produce summary PDFs for the PID plots comparing data/MC:

### Analyzing simulation files with launch v38 conditions

To analyze the simulation with the same software and loose PID cuts as the Analysis Launch ver38, you can set your environment and analyze your simulation REST files with the following commands on the ifarm:

```source /group/halld/Software/build_scripts/gluex_env_jlab.csh /group/halld/www/halldweb/html/halld_versions/version_4.20.0.xml
```
```setenv JANA_CALIB_CONTEXT variation=mc
hd_root --config=/group/halld/www/halldweb/html/data_monitoring/pid_syst/jana_pid.config /path/to/your/files/dana*.hddm
```

### Apply default cuts with DSelector

In order to apply the default cuts at the DSelector stage, copy the relevant lines into the Init function. All cuts should also be applied on the kinematically fit variables by changing `false` to `true`.

```dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 1.5, Gamma, SYS_BCAL));
dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 1.5, Gamma, SYS_FCAL));
```
```dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 1.0, Positron, SYS_BCAL));
dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 0.5, Positron, SYS_TOF));
dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 2.0, Positron, SYS_FCAL));
dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 2.5, Positron, SYS_START));
dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 1.0, Electron, SYS_BCAL));
dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 0.5, Electron, SYS_TOF));
dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 2.0, Electron, SYS_FCAL));
dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 2.5, Electron, SYS_START));
```
```dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 1.0, MuonPlus, SYS_BCAL));
dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 0.5, MuonPlus, SYS_TOF));
dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 2.0, MuonPlus, SYS_FCAL));
dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 2.5, MuonPlus, SYS_START));
dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 1.0, MuonMinus, SYS_BCAL));
dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 0.5, MuonMinus, SYS_TOF));
dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 2.0, MuonMinus, SYS_FCAL));
dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 2.5, MuonMinus, SYS_START));
```
```dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 1.0, PiPlus, SYS_BCAL));
dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 0.5, PiPlus, SYS_TOF));
dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 2.0, PiPlus, SYS_FCAL));
dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 2.5, PiPlus, SYS_START));
dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 1.0, PiMinus, SYS_BCAL));
dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 0.5, PiMinus, SYS_TOF));
dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 2.0, PiMinus, SYS_FCAL));
dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 2.5, PiMinus, SYS_START));
```
```dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 0.75, KPlus, SYS_BCAL));
dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 0.3, KPlus, SYS_TOF));
dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 2.5, KPlus, SYS_FCAL));
dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 2.5, KPlus, SYS_START));
dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 0.75, KMinus, SYS_BCAL));
dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 0.3, KMinus, SYS_TOF));
dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 2.5, KMinus, SYS_FCAL));
dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 2.5, KMinus, SYS_START));
```
```dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 1.0, Proton, SYS_BCAL));
dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 0.6, Proton, SYS_TOF));
dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 2.0, Proton, SYS_FCAL));
dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 2.5, Proton, SYS_START));
dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 1.0, AntiProton, SYS_BCAL));
dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 0.6, AntiProton, SYS_TOF));
dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 2.0, AntiProton, SYS_FCAL));
dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 2.5, AntiProton, SYS_START));
```
```dAnalysisActions.push_back(new DCutAction_MissingMassSquared(dComboWrapper, false, -0.1, 0.1));
```