-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from nstelter-slac/bringover_all_scripts
Bringover all scritps from the /rix directory, revert exists scripts to orignal versions for now
- Loading branch information
Showing
98 changed files
with
29,521 additions
and
987 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
0
scripts/OffXavierV4_2.npy → calibrationSuite/OffXavierV4_2.npy
100755 → 100644
File renamed without changes.
File renamed without changes.
40 changes: 21 additions & 19 deletions
40
scripts/ancillaryMethods.py → calibrationSuite/ancillaryMethods.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,51 @@ | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
from scipy.stats import binned_statistic | ||
|
||
|
||
def makeProfile(x, y, bins, range=None, spread=False): | ||
## NaN for empty bins are suppressed | ||
## using mean root(N) for non-empty bins to calculate 0 var weights | ||
## | ||
## spread=True to return standard deviation instead of standard error | ||
|
||
meansObj = binned_statistic(x, [y, y**2], bins=bins, range=range, statistic="mean") | ||
meansObj = binned_statistic(x, [y, y**2], bins=bins, range=range, statistic='mean') | ||
means, means2 = meansObj.statistic | ||
countsObj = binned_statistic(x, [y, y**2], bins=bins, range=(0, 1), statistic="count") | ||
countsObj = binned_statistic(x, y, bins=bins, range=range, statistic='count') | ||
stdObj = binned_statistic(x, y, bins=bins, range=range, statistic='std') | ||
bin_N = countsObj.statistic | ||
yErr = np.sqrt(means2 - means**2) | ||
usefulBins = np.bitwise_and(bin_N>0, ~np.isnan(means)) | ||
if bin_N.sum()==0: | ||
##no data | ||
print("no data in profile") | ||
return None, None, None | ||
|
||
##yErr = np.sqrt(means2 - means**2) | ||
yErr = stdObj.statistic | ||
if not spread: | ||
root_N = np.sqrt(bin_N) | ||
root_N[root_N == 0] = root_N[root_N > 0].mean() | ||
yErr = yErr / root_N | ||
root_N[root_N==0] = root_N[usefulBins].mean() | ||
yErr = yErr/root_N | ||
##yErr = yErr.clip(0, 6666666.) | ||
# where is means_result defined?? (ignore from ruff for now) | ||
bin_edges = means_result.bin_edges # noqa: F821 | ||
bin_centers = (bin_edges[:-1] + bin_edges[1:]) / 2.0 | ||
usefulBins = bin_N > 0 | ||
return bin_centers[usefulBins], means[usefulBins], yErr[usefulBins] | ||
|
||
bin_edges = meansObj.bin_edges | ||
bin_centers = (bin_edges[:-1] + bin_edges[1:])/2. | ||
return bin_centers[usefulBins], means[usefulBins], yErr[usefulBins] | ||
|
||
def plotProfile(x, y, yErr): | ||
plt.errorbar(x=x, y=y, yerr=yErr, linestyle="none", marker=".") | ||
|
||
plt.errorbar(x=x, y=y, yerr=yErr, linestyle='none', marker='.') | ||
|
||
def selectedClusters(clusters, row, col, lowEnerygCut, highEnergyCut, nPixelCut=4, isSquare=1): | ||
pass | ||
|
||
|
||
def goodClusters(clusters, row, col, nPixelCut=4, isSquare=None): | ||
##print(clusters) | ||
pixelRowCol = np.bitwise_and((clusters[:, :, 1] == row), (clusters[:, :, 2] == col)) | ||
pixelRowCol = np.bitwise_and((clusters[:,:,1] == row), | ||
(clusters[:,:,2] == col)) | ||
if isSquare is None: | ||
small = clusters[:, :, 3] < nPixelCut | ||
small = clusters[:,:,3]<nPixelCut | ||
else: | ||
small = np.bitwise_and((clusters[:, :, 3] < nPixelCut), (clusters[:, :, 4] == isSquare)) | ||
small = np.bitwise_and((clusters[:,:,3]<nPixelCut), (clusters[:,:,4]==isSquare)) | ||
return clusters[np.bitwise_and(small, pixelRowCol)] | ||
|
||
|
||
def getClusterEnergies(clusters): | ||
##print(clusters) | ||
return clusters[:, 0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.