diff options
Diffstat (limited to 'utils/sddm')
| -rwxr-xr-x | utils/sddm/dc.py | 19 | ||||
| -rwxr-xr-x | utils/sddm/plot_energy.py | 6 |
2 files changed, 21 insertions, 4 deletions
diff --git a/utils/sddm/dc.py b/utils/sddm/dc.py index a1d87b5..d681831 100755 --- a/utils/sddm/dc.py +++ b/utils/sddm/dc.py @@ -343,12 +343,29 @@ class Constraint(object): def renormalize(self, x, fix): if fix not in self.range: return x + + if 1 - x[fix] < EPSILON: + return x + + if self(x) < 0: + return x + + # Scale all the other entries except for the fixed one by a constant to + # ensure that sum(x) = 1 - EPSILON + c = ((1-x[fix])-EPSILON)/sum(x[i] for i in self.range if i != fix) + x = x.copy() + + for i in self.range: + if i != fix: + x[i] *= c + while self(x) >= 0: for i in self.range: if i == fix: continue - x[i] -= self(x) + x[i] /= 2 + return x def renormalize_no_fix(self, x): diff --git a/utils/sddm/plot_energy.py b/utils/sddm/plot_energy.py index c9f5142..88950f7 100755 --- a/utils/sddm/plot_energy.py +++ b/utils/sddm/plot_energy.py @@ -471,13 +471,13 @@ def get_events(filenames, merge_fits=False): ev = ev.groupby('run',group_keys=False).apply(retrigger_cut) if merge_fits: - ev.set_index(['run','gtid']) - ev = pd.merge(fits,ev,how='inner',on=['run','gtid']) + # Set the index to (run, gtid) so we can set columns from the single particle results + ev = ev.set_index(['run','gtid']) ev_single_particle = ev[(ev.id2 == 0) & (ev.id3 == 0)] ev_single_particle = ev_single_particle.sort_values('fmin').groupby(['run','gtid']).nth(0) ev = ev.sort_values('fmin').groupby(['run','gtid']).nth(0) - ev['psi'] /= ev.nhit_cal + #ev['psi'] /= ev.nhit_cal ev['cos_theta'] = np.cos(ev_single_particle['theta1']) ev['r'] = np.sqrt(ev.x**2 + ev.y**2 + ev.z**2) |
