Skip to content
This repository has been archived by the owner on Jan 31, 2022. It is now read-only.

Refactoring of anaUltraScurve.py and additional output distributions #75

Merged
merged 42 commits into from
Mar 28, 2018
Merged
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
6fc0c32
added getMapping function for creating chan-strip-panpin look up table
Mar 22, 2018
3f590af
removed unnecessary imports and made use of getMapping()
Mar 22, 2018
e34b1c7
added function for creating empty lists to be more pythonic
Mar 22, 2018
71b670c
cleaned up duplication in histogram initialization
Mar 22, 2018
af3af2f
getMapping() will now also include the vfat channel number as a ident…
Mar 22, 2018
5d948cd
removed unnecessary duplication of code when filling summary histograms
Mar 22, 2018
9338611
added additional method to ScanDataFitter to allow a histogram to be …
Mar 22, 2018
05bb749
Nev is now a nesteddict in ScanDataFitter and will be applied per vfa…
Mar 22, 2018
a3bdf37
functionality added to ScanDataFitter to provide output in either cha…
Mar 22, 2018
6d43ec9
cleaned up hot channel determination and made output table compatible…
Mar 22, 2018
b5e2cc9
ScanDataFitter.scanFits renamed to scanFitResults to distinguish it m…
Mar 22, 2018
1dc921d
removed unnecessary duplicate containers
Mar 22, 2018
66e9e39
ScanDataFitter.calDAC2Q_m and ScanDataFitter.calDAC2Q_b are now corre…
Mar 22, 2018
43b7f09
migrated dict_calSF to anaInfo since multiple objects require it
Mar 22, 2018
4724d92
moved fill2DScurveSummaryPlots() to anaUltraScurve.py and moved def o…
Mar 22, 2018
d3c6326
fixed a syntax error when checking for current pulse mode in ScanData…
Mar 22, 2018
74203b5
the saveSummary() has been moved from anaUltraScurve.py into anautili…
Mar 22, 2018
5d38901
cleaning up saving output plots
Mar 22, 2018
b470b2e
additional 1D histograms are made showing scurve mean and width posit…
Mar 22, 2018
7f3b1ff
added graphical 1D distributions of histograms and fits
Mar 22, 2018
77c5a6f
syntax and bug fixes, moved TTree declaration to block of code where …
Mar 22, 2018
c663b1a
changed drawing performed by plotAllSCurvesOnCanvas()
Mar 22, 2018
c603ba2
saveSummary will now take draw option as an argument
Mar 22, 2018
2f92ae4
tweaking thresh and enc distribution binning
Mar 22, 2018
50c53d9
adding vfatList argument which defaults to VFAT0..23 inclusive
Mar 23, 2018
3e3dd94
undoing vfatList option, more thought is required
Mar 23, 2018
3309d97
color coding TF1's in fitting based on fit results
Mar 23, 2018
594f741
fixed an issue where fitting scurves would use negative initial param…
Mar 23, 2018
c41ca6a
new utility function for list like object index finding
Mar 23, 2018
a83fcc9
added the possibility of debug printing to ScanDataFitter
Mar 23, 2018
e2c946c
filling histograms is now done via SetBinContent method so the error …
Mar 23, 2018
b3e478e
moved around where chargeBin list was determined to increase algorith…
Mar 23, 2018
5078e55
updated TObject and output names to be less ambigious, e.g. instead o…
Mar 23, 2018
93e86bf
added axis labels to thr and enc distributions
Mar 23, 2018
7c9215f
Added a threshold and enc distribution which summarizes the entire de…
Mar 26, 2018
def8374
typos fixed and added summary output directory
Mar 26, 2018
f558ada
merged with develop
Mar 26, 2018
b477934
mak3x8Canvas can now accept a TCanvas object to plot additional distr…
Mar 26, 2018
d053fb9
changing names of TObjects for scurve sigma to be consistent
Mar 26, 2018
f3a92c2
removing commented lines
Mar 26, 2018
174d8f9
decreasing bin size of scurve mean and sigma dist's for full detector
Mar 26, 2018
7f1a0e4
Merge branch 'develop' into feature_refactoringSCurve
Mar 26, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
adding vfatList argument which defaults to VFAT0..23 inclusive
  • Loading branch information
Brian Dorney committed Mar 23, 2018
commit 50c53d9609ec572d4643345d69db07630c13963d
36 changes: 22 additions & 14 deletions anaUltraScurve.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ def plotAllSCurvesOnCanvas(vfatHistos, vfatHistosPanPin2=None, obsName="canvScur

g_scurve = r.TGraph(h_scurve)
if binX == 1:
g_scurve.Draw("AP")
g_scurve.Clone().Draw("AP")
else:
g_scurve.Draw("sameP")
g_scurve.Clone().Draw("sameP")
#canv_dict[vfat].Update()
if vfatHistosPanPin2 is not None:
for vfat,histo in vfatHistosPanPin2.iteritems():
Expand All @@ -103,7 +103,7 @@ def plotAllSCurvesOnCanvas(vfatHistos, vfatHistosPanPin2=None, obsName="canvScur
h_scurve.SetLineWidth(2)

g_scurve = r.TGraph(h_scurve)
g_scurve.Draw("sameP")
g_scurve.Clone().Draw("sameP")
#canv_dict[vfat].Update()

return canv_dict
Expand All @@ -120,7 +120,11 @@ def plotAllSCurvesOnCanvas(vfatHistos, vfatHistosPanPin2=None, obsName="canvScur
from fitting.fitScanData import ScanDataFitter
from gempython.utils.nesteddict import nesteddict as ndict
from gempython.utils.wrappers import envCheck


defaultVFATList='0'
for vfat in range(1,24):
defaultVFATList+=(',%i'%vfat)

from anaoptions import parser
parser.add_option("-b", "--drawbad", action="store_true", dest="drawbad",
help="Draw fit overlays for Chi2 > 10000", metavar="drawbad")
Expand All @@ -133,6 +137,8 @@ def plotAllSCurvesOnCanvas(vfatHistos, vfatHistosPanPin2=None, obsName="canvScur
help="Fit scurves and save fit information to output TFile", metavar="performFit")
parser.add_option("--IsTrimmed", action="store_true", dest="IsTrimmed",
help="If the data is from a trimmed scan, plot the value it tried aligning to", metavar="IsTrimmed")
parser.add_option("--vfatList", type="string", dest="vfatList", default=defaultVFATList,
help="Comma separated list of vfats positions to analyze", metavar="vfatList")
parser.add_option("--zscore", type="float", dest="zscore", default=3.5,
help="Z-Score for Outlier Identification in MAD Algo", metavar="zscore")
parser.set_defaults(outfilename="SCurveFitData.root")
Expand All @@ -142,6 +148,8 @@ def plotAllSCurvesOnCanvas(vfatHistos, vfatHistosPanPin2=None, obsName="canvScur
filename = options.filename[:-5]
os.system("mkdir " + filename)

listOfVFATs = options.vfatList.split(',')
listOfVFATs = [int(vfat) for vfat in listOfVFATs]
outfilename = options.outfilename
GEBtype = options.GEBtype

Expand Down Expand Up @@ -181,7 +189,7 @@ def plotAllSCurvesOnCanvas(vfatHistos, vfatHistosPanPin2=None, obsName="canvScur
r.gStyle.SetOptStat(1111111)

# Initialize distributions
for vfat in range(0,24):
for vfat in listOfVFATs:
vSummaryPlots[vfat] = r.TH2D('vSummaryPlots%i'%vfat,
'VFAT %i;Channels;VCal [fC]'%vfat,
128,-0.5,127.5,256,
Expand Down Expand Up @@ -264,7 +272,7 @@ def plotAllSCurvesOnCanvas(vfatHistos, vfatHistosPanPin2=None, obsName="canvScur

# Get some of the operational settings of the ASIC
# Refactor this using root_numpy???
dict_vfatID = dict((vfat, 0) for vfat in range(0,24))
dict_vfatID = dict((vfat, 0) for vfat in listOfVFATs)
listOfBranches = inF.scurveTree.GetListOfBranches()
for event in inF.scurveTree:
vthr_list[event.vfatN][event.vfatCH] = event.vthr
Expand Down Expand Up @@ -300,7 +308,7 @@ def plotAllSCurvesOnCanvas(vfatHistos, vfatHistosPanPin2=None, obsName="canvScur
fitSummary = open(filename+'/fitSummary.txt','w')
fitSummary.write('vfatN/I:vfatID/I:vfatCH/I:fitP0/F:fitP1/F:fitP2/F:fitP3/F\n')
scanFitResults = fitter.fit()
for vfat in range(0,24):
for vfat in listOfVFATs:
for chan in range(0,128):
fitSummary.write(
'%i\t%i\t%i\t%f\t%f\t%f\t%f\n'%(
Expand All @@ -319,10 +327,10 @@ def plotAllSCurvesOnCanvas(vfatHistos, vfatHistosPanPin2=None, obsName="canvScur
print("Determining hot channels")
masks = []
maskReasons = []
effectivePedestals = [ np.zeros(128) for vfat in range(24) ]
effectivePedestals = [ np.zeros(128) for vfat in listOfVFATs ]
print "| vfatN | Dead Chan | Hot Chan | Failed Fits | High Noise | High Eff Ped |"
print "| :---: | :-------: | :------: | :---------: | :--------: | :----------: |"
for vfat in range(0, 24):
for vfat in listOfVFATs:
trimValue = np.zeros(128)
channelNoise = np.zeros(128)
fitFailed = np.zeros(128, dtype=bool)
Expand Down Expand Up @@ -421,7 +429,7 @@ def plotAllSCurvesOnCanvas(vfatHistos, vfatHistosPanPin2=None, obsName="canvScur
fitSummaryPlots = {}
threshSummaryPlots = {}
encSummaryPlots = {}
for vfat in range (0,24):
for vfat in listOfVFATs:
fitThr = np.zeros(128)
fitENC = np.zeros(128)
stripPinOrChanArray = np.zeros(128)
Expand Down Expand Up @@ -521,7 +529,7 @@ def plotAllSCurvesOnCanvas(vfatHistos, vfatHistosPanPin2=None, obsName="canvScur
if options.IsTrimmed:
trimmed_text = open('scanInfo.txt', 'r')
trimVcal = []
for vfat in range(0,24):
for vfat in listOfVFATs:
trimVcal.append(0)
pass
for n, line in enumerate(trimmed_text):
Expand Down Expand Up @@ -549,7 +557,7 @@ def plotAllSCurvesOnCanvas(vfatHistos, vfatHistosPanPin2=None, obsName="canvScur

confF = open(filename+'/chConfig.txt','w')
confF.write('vfatN/I:vfatID/I:vfatCH/I:trimDAC/I:mask/I\n')
for vfat in range (0,24):
for vfat in listOfVFATs:
for chan in range (0, 128):
confF.write('%i\t%i\t%i\t%i\t%i\n'%(
vfat,
Expand All @@ -576,7 +584,7 @@ def plotAllSCurvesOnCanvas(vfatHistos, vfatHistosPanPin2=None, obsName="canvScur
canvOfScurveHistosNoHotChan = plotAllSCurvesOnCanvas(vSummaryPlotsNoHotChan,None,"canvScurvesNoHotChan")

canvOfScurveFits = {}
for vfat in range(0,24):
for vfat in listOfVFATs:
canvOfScurveFits[vfat] = r.TCanvas("canvScurveFits_vfat%i"%vfat,"Scurve Fits from VFAT%i"%vfat,600,600)
canvOfScurveFits[vfat].cd()
for chan in range (0,128):
Expand All @@ -590,7 +598,7 @@ def plotAllSCurvesOnCanvas(vfatHistos, vfatHistosPanPin2=None, obsName="canvScur
outF.cd()
if options.performFit:
myT.Write()
for vfat in range(0,23):
for vfat in listOfVFATs:
dirVFAT = outF.mkdir("VFAT%i"%vfat)
dirVFAT.cd()
vSummaryPlots[vfat].Write()
Expand Down