def getDirByAnaType(anaType, cName, ztrim=4): from anaInfo import ana_config import os # Check anaType is understood if anaType not in ana_config.keys(): print "getDirByAnaType() - Invalid analysis specificed, please select only from the list:" print ana_config.keys() exit(os.EX_USAGE) pass # Check Paths from gempython.utils.wrappers import envCheck envCheck('DATA_PATH') dataPath = os.getenv('DATA_PATH') dirPath = "" if anaType == "latency": dirPath = "%s/%s/%s/trk/" % (dataPath, cName, anaType) elif anaType == "scurve": dirPath = "%s/%s/%s/" % (dataPath, cName, anaType) elif anaType == "thresholdch": dirPath = "%s/%s/%s/channel/" % (dataPath, cName, "threshold") elif anaType == "thresholdvftrig": dirPath = "%s/%s/%s/vfat/trig/" % (dataPath, cName, "threshold") elif anaType == "thresholdvftrk": dirPath = "%s/%s/%s/vfat/trk/" % (dataPath, cName, "threshold") elif anaType == "trim": dirPath = "%s/%s/%s/z%f/" % (dataPath, cName, anaType, ztrim) return dirPath
dest="printData", help="Prints a comma separated table with the data to the terminal", metavar="printData") parser.add_option( "--vfatList", type="string", dest="vfatList", default=None, help="Comma separated list of VFATs to consider, e.g. '12,13'", metavar="vfatList") parser.set_defaults(filename="listOfScanDates.txt") (options, args) = parser.parse_args() # Check Paths envCheck('DATA_PATH') envCheck('ELOG_PATH') elogPath = os.getenv('ELOG_PATH') # Get VFAT List list_VFATs = [] if options.vfatList != None: list_VFATs = map(int, options.vfatList.split(',')) elif options.vfat != None: list_VFATs.append(options.vfat) else: print "You must specify at least one VFAT to be considered" exit(os.EX_USAGE) # Check that the user supplied a latency value if options.latSig is None and not options.bkgSub:
print("Please relaunch with the --calFileARM argument") exit(os.EX_USAGE) pass # Get the calibration for the CFG_THR_ARM_DAC register tuple_calInfo = parseCalFile(options.calFileARM) thrArmDac2Q_Slope = tuple_calInfo[0] thrArmDac2Q_Intercept = tuple_calInfo[1] ztrim = options.ztrim chMin = options.chMin chMax = options.chMax + 1 print('trimming at z = %f' % ztrim) if options.dirPath == None: envCheck('DATA_PATH') dataPath = os.getenv('DATA_PATH') startTime = datetime.datetime.now().strftime("%Y.%m.%d.%H.%M") print(startTime) dirPath = '%s/%s/trim/z%f' % (dataPath, chamber_config[options.gtx], ztrim) runCommand(["unlink", "%s/current" % dirPath]) runCommand(['mkdir', '-p', '%s/%s' % (dirPath, startTime)]) runCommand([ "ln", "-s", '%s/%s' % (dirPath, startTime), '%s/current' % dirPath ]) dirPath = '%s/%s' % (dirPath, startTime) else: dirPath = options.dirPath
default="ge11", help="Used to change gemType") args = parser.parse_args() import os if (args.slot < 1 or args.slot > 12): print("Please specify a valid AMC [1,12]") exit(os.EX_USAGE) if (args.ohMask < 0x0 or args.ohMask > 0xfff): print("Please specify a valid ohMask [0x0,0xfff]") exit(os.EX_USAGE) from gempython.utils.wrappers import envCheck envCheck("ELOG_PATH") elogPath = os.getenv("ELOG_PATH") import ROOT as r r.TH1.SetDefaultSumw2(False) r.gROOT.SetBatch(True) r.gStyle.SetOptStat(1111111) # Open input file print("Opening input file: {0}".format(args.infile)) infile = r.TFile(args.infile, "READ") if not infile: print("{0} does not exist".format(infilename)) exit(os.EX_IOERR) if infile.IsZombie(): print("{0} is a zombie".format(infilename))
print("queue '%s' not understood" % options.queue) print("list of supported queues is:", queueNames) exit(os.EX_USAGE) pass # Check anaType is understood supportedAnaTypes = ['scurve', 'trim'] if options.anaType not in supportedAnaTypes: print("Invalid analysis specificed, please select only from the list:") print(supportedAnaTypes) exit(os.EX_USAGE) pass # Prepare the commands for making the from gempython.utils.wrappers import envCheck, runCommand envCheck('BUILD_HOME') envCheck('DATA_PATH') envCheck('ELOG_PATH') buildHome = os.getenv('BUILD_HOME') dataPath = os.getenv('DATA_PATH') elogPath = os.getenv('ELOG_PATH') # Get info from input file from gempython.gemplotting.utils.anautilities import getDirByAnaType, filePathExists, makeListOfScanDatesFile, parseListOfScanDatesFile if (listOfScanDatesFile is None and options.chamberName is not None): makeListOfScanDatesFile(options.chamberName, options.anaType, options.startDate, options.endDate, ztrim=options.ztrim)
def compareSBitThreshResults(args): # Suppress all pop-ups from ROOT import ROOT as r r.gROOT.SetBatch(True) # Check Paths import os, sys from gempython.utils.wrappers import envCheck envCheck('DATA_PATH') envCheck('ELOG_PATH') elogPath = os.getenv('ELOG_PATH') # Get info from input file from gempython.gemplotting.utils.anautilities import getCyclicColor, getDirByAnaType, filePathExists, getSummaryCanvas, parseArmDacCalFile, parseListOfScanDatesFile parsedTuple = parseListOfScanDatesFile(args.filename, alphaLabels=args.alphaLabels) listChamberAndScanDate = parsedTuple[0] chamberName = listChamberAndScanDate[0][0] thrDacName = parsedTuple[1] gemType = "ge11" from gempython.tools.hw_constants import vfatsPerGemVariant # Parse calibration file if present arrayCalInfo = None if args.calFileARM is not None: arrayCalInfo = parseArmDacCalFile( args.calFileARM, gemType=gemType) # arrayCalInfo[i][vfatN] for coef of x^(4-i) legPlot = r.TLegend(0.5, 0.5, 0.9, 0.9) from gempython.utils.nesteddict import nesteddict as ndict dict_Histos = ndict() dict_Graphs = ndict() dict_MultiGraphs = {} for idx, infoTuple in enumerate(listChamberAndScanDate): # Setup the path dirPath = getDirByAnaType("sbitRateor", infoTuple[0]) if not filePathExists(dirPath, infoTuple[1]): print('Filepath {:s}/{:s} does not exist!'.format( dirPath, infoTuple[1])) print('Please cross-check, exiting!') sys.exit(os.EX_NOINPUT) filename = "{:s}/{:s}/SBitRatePlots.root".format(dirPath, infoTuple[1]) # Load the file r.TH1.AddDirectory(False) scanFile = r.TFile(filename, "READ") if scanFile.IsZombie(): print("{0} is a zombie!!!".format(filename)) print( "Please double check your input list of scandates: {0}".format( args.filename)) print("And then call this script again") raise IOError ################### # Get individual distributions ################### for vfat in range(vfatsPerGemVariant[gemType]): dict_Histos[infoTuple[2]][vfat] = scanFile.Get( "VFAT{0}/THR_ARM_DAC/g1D_rate_vs_THR-ARM-DAC_vfat{0}".format( vfat)) dict_Graphs[infoTuple[2]][vfat] = r.TGraph( dict_Histos[infoTuple[2]][vfat]) # Do we convert x-axis to charge units? if arrayCalInfo is not None: for pt in range(dict_Graphs[infoTuple[2]][vfat].GetN()): valX = r.Double() valY = r.Double() dict_Graphs[infoTuple[2]][vfat].GetPoint(pt, valX, valY) valX_Q = 0 for coef in range(0, 5): valX_Q += arrayCalInfo[coef][vfat] * pow( valX, 4 - coef) dict_Graphs[infoTuple[2]][vfat].SetPoint(pt, valX_Q, valY) pass pass # Make the TMultiGraph Objects suffix = "VFAT{0}".format(vfat) if idx == 0: dict_MultiGraphs[vfat] = r.TMultiGraph( "mGraph_RateVsThrDac_vfat{0}".format(suffix), suffix) # Set Style of TGraph dict_Graphs[infoTuple[2]][vfat].SetLineColor(getCyclicColor(idx)) dict_Graphs[infoTuple[2]][vfat].SetMarkerColor(getCyclicColor(idx)) dict_Graphs[infoTuple[2]][vfat].SetMarkerStyle(20 + idx) dict_Graphs[infoTuple[2]][vfat].SetMarkerSize(0.8) # Add to the MultiGraph dict_MultiGraphs[vfat].Add(dict_Graphs[infoTuple[2]][vfat]) ################### # Make an entry in the TLegend ################### if vfat == 0: legPlot.AddEntry(dict_Graphs[infoTuple[2]][vfat], "{0} = {1}".format(thrDacName, infoTuple[2]), "LPE") pass pass ################### # Make output ROOT file ################### outFileName = "{0}/compSbitThresh_{1}.root".format(elogPath, chamberName) outFile = r.TFile(outFileName, "RECREATE") # Plot Containers dict_canv = {} ################### # Now Make plots ################### for vfat in range(vfatsPerGemVariant[gemType]): # Make Output Canvas dict_canv[vfat] = r.TCanvas("canvSBitRate_VFAT{0}".format(vfat), "SBIT Rate by THR DAC", 700, 700) dict_canv[vfat].cd() dict_canv[vfat].cd().SetLogy() dict_MultiGraphs[vfat].Draw("APE1") dict_MultiGraphs[vfat].GetYaxis().SetTitle("Rate #left(Hz#right)") dict_MultiGraphs[vfat].GetYaxis().SetRangeUser(1e-1, 5e8) # max is 40 MHz if arrayCalInfo is not None: dict_MultiGraphs[vfat].GetXaxis().SetTitle( "Threshold #left(fC#right)") dict_MultiGraphs[vfat].GetXaxis().SetRangeUser(0, 20) else: dict_MultiGraphs[vfat].GetXaxis().SetTitle( "CFG_THR_ARM_DAC #left(DAC#right)") dict_MultiGraphs[vfat].GetXaxis().SetRangeUser(0, 125) pass dict_MultiGraphs[vfat].Draw("APE1") # Draw Legend? if not args.noLeg: legPlot.Draw("same") pass # Make output image? if args.savePlots: dict_canv[vfat].SaveAs("{0}/{1}.png".format( elogPath, dict_canv[vfat].GetName())) pass # Store Output thisDirectory = outFile.mkdir("VFAT{0}".format(vfat)) thisDirectory.cd() dict_MultiGraphs[vfat].Write() dict_canv[vfat].Write() pass # Make summary canvases, always save these canvSBitRate_Summary = getSummaryCanvas( dict_MultiGraphs.values()[0:vfatsPerGemVariant[gemType]], name="canvSBitRate_Summary", drawOpt="APE1", gemType=gemType) for vfatCanv in range(1, vfatsPerGemVariant[gemType] + 1): canvSBitRate_Summary.cd(vfatCanv).SetLogy() # Draw Legend? if not args.noLeg: canvSBitRate_Summary.cd(1) legPlot.Draw("same") pass # Save summary canvases (always) print("\nSaving Summary TCanvas Objects") canvSBitRate_Summary.SaveAs("{0}/{1}.png".format( elogPath, canvSBitRate_Summary.GetName())) # Close output files outFile.Close() print("You can find all ROOT objects in:") print("\n\t{0}/compSbitThresh_{1}.root\n".format(elogPath, chamberName)) print("You can find all plots in:") print("\n\t{0}\n".format(elogPath)) print("Done") return
pan_lookup = [] vfatCh_lookup = [] for vfat in range(0, 24): lookup_table.append([]) pan_lookup.append([]) vfatCh_lookup.append([]) for channel in range(0, 128): lookup_table[vfat].append(0) pan_lookup[vfat].append(0) vfatCh_lookup[vfat].append(0) pass pass from gempython.utils.wrappers import envCheck envCheck('GEM_PLOTTING_PROJECT') projectHome = os.environ.get('GEM_PLOTTING_PROJECT') if GEBtype == 'long': intext = open(projectHome + '/mapping/longChannelMap.txt', 'r') pass if GEBtype == 'short': intext = open(projectHome + '/mapping/shortChannelMap.txt', 'r') pass for i, line in enumerate(intext): if i == 0: continue mapping = line.rsplit('\t') lookup_table[int(mapping[0])][int(mapping[2]) - 1] = int(mapping[1]) pan_lookup[int(mapping[0])][int(mapping[2]) - 1] = int(mapping[3])
print("queue '%s' not understood" % options.queue) print("list of supported queues is:", queueNames) exit(os.EX_USAGE) pass # Check anaType is understood supportedAnaTypes = ['scurve', 'trim'] if options.anaType not in supportedAnaTypes: print("Invalid analysis specificed, please select only from the list:") print(supportedAnaTypes) exit(os.EX_USAGE) pass # Prepare the commands for making the from gempython.utils.wrappers import envCheck, runCommand envCheck('DATA_PATH') envCheck('ELOG_PATH') envCheck('VIRTUAL_ENV') # Get info from input file from gempython.gemplotting.utils.anautilities import getDirByAnaType, filePathExists, makeListOfScanDatesFile, parseListOfScanDatesFile if (listOfScanDatesFile is None and options.chamberName is not None): makeListOfScanDatesFile(options.chamberName, options.anaType, options.startDate, options.endDate, ztrim=options.ztrim) listOfScanDatesFile = '%s/listOfScanDates.txt' % (getDirByAnaType( options.anaType, options.chamberName, options.ztrim)) pass parsedTuple = parseListOfScanDatesFile(listOfScanDatesFile,
#!/bin/env python import os import threading from gempython.gemplotting.mapping.chamberInfo import chamber_config,GEBtype from gempython.vfatqc.utils.qcoptions import parser from gempython.utils.wrappers import envCheck (options, args) = parser.parse_args() envCheck('DATA_PATH') envCheck('CONFIG_PATH') envCheck('BUILD_HOME') def launchScurveScan(link,ztrim,cName,cType): import ROOT as r buildPath = os.getenv('BUILD_HOME') dataPath = os.getenv('DATA_PATH') configPath = os.getenv('CONFIG_PATH') trimFile = r.TFile( '%s/%s/trim/z%f/config/SCurveData_Trimmed.root'%(dataPath,cName,ztrim) ) trimRange = {} outTrimFile = open('%s/chConf%s.txt'%(configPath,cName),'w') outTrimFile.write('vfatN\I:vfatCH\I:trimDAC\I\n') for event in trimFile.scurveTree : if event.vcal == 10 : outTrimFile.write('%i\t%i\t%i\n'%(int(event.vfatN),int(event.vfatCH),int(event.trimDAC))) if event.vfatCH == 10 : trimRange[int(event.vfatN)] = int(event.trimRange) outTrimFile.close() trimFile.Close() os.system( 'cp %s/%s/threshold/config/ThresholdScanData/ThresholdByVFAT.txt %s/vthConf%s.txt'%(dataPath,cName,configPath,cName) ) ztrim = options.ztrim
help="Prints additional debugging information") parser.add_argument('-o', '--outfilename', type=str, default="SBitRatePlots.root", help="Filename to which analyzed data is written") parser.add_argument("-m", "--maxNoiseRate", type=float, dest="maxNoiseRate", default=0, help="Max Noise Rate allowed in Hz") args = parser.parse_args() from gempython.utils.wrappers import envCheck envCheck("DATA_PATH") from gempython.gemplotting.utils.anautilities import getElogPath elogPath = getElogPath() # load input file import ROOT as r sbitThreshFile = r.TFile(args.infilename, "READ") # determine scandate from gempython.gemplotting.utils.anautilities import getScandateFromFilename scandate = getScandateFromFilename(args.infilename) from gempython.gemplotting.mapping.chamberInfo import chamber_config from gempython.gemplotting.utils.threshAlgos import sbitRateAnalysis sbitRateAnalysis(chamber_config=chamber_config,
parser.add_option("--t3trig", action="store_true", dest="t3trig", help="Set up for using AMC13 T3 trigger input", metavar="t3trig") parser.add_option("--throttle", type="int", default=0, dest="throttle", help="factor by which to throttle the input L1A rate, e.g. new trig rate = L1A rate / throttle", metavar="throttle") parser.add_option("--tool", type="string", dest="tool",default="ultraScurve.py", help="Tool to run (scan or analyze", metavar="tool") parser.add_option("--trkdata", action="store_true", dest="trkdata", help="Run a per-VFAT VT1 scan using tracking data (default is to use trigger data)", metavar="trkdata") parser.add_option("--vt1", type="int", dest="vt1", default=100, help="Specify VT1 to use", metavar="vt1") parser.add_option("--vt2", type="int", dest="vt2", default=0, help="Specify VT2 to use", metavar="vt2") (options, args) = parser.parse_args() envCheck('DATA_PATH') envCheck('BUILD_HOME') if options.tool not in ["trimChamber.py","ultraThreshold.py","ultraLatency.py","fastLatency.py","ultraScurve.py"]: print "Invalid tool specified" exit(1) if options.debug: print list( itertools.izip([options.tool for x in range(len(chamber_config))], [options.shelf for x in range(len(chamber_config))], [options.slot for x in range(len(chamber_config))], chamber_config.keys(), chamber_config.values(), [hex(vfatmask) for vfatmask in chamber_vfatMask.values()], [options.scanmin for x in range(len(chamber_config))],
def getGEMDBView(view, vfatList=None, debug=False): """ Gets the GEM DB view defined by view for the list of vfats provided by vfatList, or if no vfatList is provided the full view stored in the DB. Returns a pandas dataframe object storing the data read from the DB view - Name of View to retrieve from GEM DB vfatList - list of VFAT Chip ID's, if None the full view is retrieved debug - Prints additional info if true """ # Check to make sure DB $ENV variables exist envCheck("GEM_ONLINE_DB_NAME") envCheck("GEM_ONLINE_DB_CONN") import os if view not in knownViews: from gempython.gemplotting.utils.exceptions import DBViewNotFound raise DBViewNotFound( "{}View {} not in knownViews: {}{}".format(colors.RED, view, knownViews, colors.ENDC), os.EX_USAGE) # Make base query query = ( 'SELECT data.* FROM CMS_GEM_MUON_VIEW.{0} data ' 'INNER JOIN (SELECT vfat3_barcode, MAX(run_number) AS run_number FROM CMS_GEM_MUON_VIEW.{0} GROUP BY vfat3_barcode) data_select ' 'ON data.vfat3_barcode = data_select.vfat3_barcode AND data.run_number = data_select.run_number' ).format(view) # Add a filter on VFAT serial number? if vfatList is not None: query += getVFATFilter(vfatList) pass if debug: print("query = {0}{1}{2}".format(colors.YELLOW, query, colors.ENDC)) pass # get a pandas data frame object containing the db query import cx_Oracle dbName = os.getenv("GEM_ONLINE_DB_NAME") dbConn = os.getenv("GEM_ONLINE_DB_CONN") gemdb = cx_Oracle.connect(dbConn + dbName) dfGEMView = pd.read_sql(query, gemdb) dfGEMView.columns = [str.lower(col) for col in dfGEMView.columns] if debug: print(dfGEMView.info()) print("Columns = {}".format(dfGEMView.columns)) print("Read {0} rows from view {1}".format(dfGEMView.shape[0], view)) pass if vfatList is not None: # First warn the user which VFATs are *not* found if len(vfatList) != dfGEMView.shape[0]: printYellow( "Length of returned view does not match length of input vfat List" ) vfatsNotFound = [ "0x{:x}".format(chipId) for chipId in vfatList if "0x{:x}".format(chipId) not in list(dfGEMView['vfat3_ser_num']) ] printYellow("VFATs not found: {0}".format(vfatsNotFound)) pass # Then add a 'vfatN' column to the output df; this increases row # to len(vfatList) dfGEMView = joinOnVFATSerNum(vfatList, dfGEMView) pass return dfGEMView
def makeListOfScanDatesFile(chamberName, anaType, startDate=None, endDate=None, delim='\t', ztrim=4): """ Given a starting scandate startDate and an ending scandate endDate this will make a text file for chamberName which is a two-column list of scandates for anaType compatible with parseListOfScanDatesFile() chamberName - Chamber name, expected to be in chamber_config.values() startDate - starting scandate in YYYY.MM.DD.hh.mm format, if None then the earliest possible date is used endDate - ending scandate in YYYY.MM.DD.hh.mm format, if None then today is used (latest possible date) delim - delimiter to use in output file name """ from gempython.utils.wrappers import envCheck, runCommand envCheck('DATA_PATH') import datetime startDay = datetime.date(datetime.MINYEAR,1,1) if startDate is not None: startDateInfo = [ int(info) for info in startDate.split(".") ] startDay = datetime.date(startDateInfo[0], startDateInfo[1], startDateInfo[2]) pass endDay = datetime.date.today() if endDate is not None: endDateInfo = [ int(info) for info in endDate.split(".") ] endDat = datetime.date(endDateInfo[0], endDateInfo[1], endDateInfo[2]) pass import os dirPath = getDirByAnaType(anaType, chamberName, ztrim) listOfScanDates = os.listdir(dirPath) try: listOfScanDatesFile = open('%s/listOfScanDates.txt'%dirPath,'w+') except IOError as e: print "Exception:", e print "Failed to open write output file" print "Is the below directory writeable?" print "" print "\t%s"%dirPath print "" exit(os.EX_IOERR) pass listOfScanDatesFile.write('ChamberName%sscandate\n'%delim) for scandate in listOfScanDates: if "current" == scandate: continue try: scandateInfo = [ int(info) for info in scandate.split('.') ] except ValueError as e: print "Skipping directory %s/%s"%(dirPath,scandate) continue thisDay = datetime.date(scandateInfo[0],scandateInfo[1],scandateInfo[2]) if (startDay < thisDay and thisDay <= endDay): listOfScanDatesFile.write('%s%s%s\n'%(chamberName,delim,scandate)) pass pass listOfScanDatesFile.close() runCommand( ['chmod','g+rw','%s/listOfScanDates.txt'%dirPath] ) return
def compareLatResults(args): # Suppress all pop-ups from ROOT import ROOT as r r.gROOT.SetBatch(True) # Check Paths import os, sys from gempython.utils.wrappers import envCheck envCheck('DATA_PATH') envCheck('ELOG_PATH') elogPath = os.getenv('ELOG_PATH') # Get info from input file from gempython.gemplotting.utils.anautilities import getCyclicColor, getDirByAnaType, filePathExists, make3x8Canvas, parseListOfScanDatesFile parsedTuple = parseListOfScanDatesFile(args.filename,alphaLabels=args.alphaLabels) listChamberAndScanDate = parsedTuple[0] chamberName = listChamberAndScanDate[0][0] legPlot = r.TLegend(0.5,0.5,0.9,0.9) from gempython.utils.nesteddict import nesteddict as ndict dict_Histos = ndict() dict_Graphs = ndict() dict_MultiGraphs = {} print("Loading data from input list of scandates file") from gempython.gemplotting.utils.anaInfo import tree_names for idx,infoTuple in enumerate(listChamberAndScanDate): # Setup the path dirPath = getDirByAnaType("latency", infoTuple[0]) if not filePathExists(dirPath, infoTuple[1]): print('Filepath {:s}/{:s} does not exist!'.format(dirPath, infoTuple[1])) print('Please cross-check, exiting!') sys.exit(os.EX_NOINPUT) filename = "{:s}/{:s}/{:s}".format(dirPath, infoTuple[1], tree_names["latencyAna"][0]) if not os.path.isfile(filename): print('File {:s} does not exist!'.format(filename)) print('Please cross-check, exiting!') sys.exit(os.EX_NOINPUT) # Load the file r.TH1.AddDirectory(False) scanFile = r.TFile(filename,"READ") if scanFile.IsZombie(): print("{:s} is a zombie!!!".format(filename)) print("Please double check your input list of scandates: {:s}".format(args.filename)) print("And then call this script again") raise IOError ################### # Get individual distributions ################### for vfat in range(24): baseDir = "VFAT_Plots/VFAT{0:d}".format(vfat) dict_Histos[infoTuple[2]][vfat] = scanFile.Get("{:s}/vfat{:d}HitsVsLat".format(baseDir,vfat)) dict_Graphs[infoTuple[2]][vfat] = scanFile.Get("{:s}/g_N_vs_Lat_VFAT{:d}".format(baseDir,vfat)) # Make the TMultiGraph Objects suffix = "VFAT{:d}".format(vfat) if idx == 0: dict_MultiGraphs[vfat] = r.TMultiGraph("mGraph_RateVsThrDac_vfat{:s}".format(suffix),suffix) # Set Style of TGraph dict_Graphs[infoTuple[2]][vfat].SetLineColor(getCyclicColor(idx)) dict_Graphs[infoTuple[2]][vfat].SetMarkerColor(getCyclicColor(idx)) dict_Graphs[infoTuple[2]][vfat].SetMarkerStyle(20+idx) dict_Graphs[infoTuple[2]][vfat].SetMarkerSize(0.8) # Add to the MultiGraph dict_MultiGraphs[vfat].Add(dict_Graphs[infoTuple[2]][vfat]) ################### # Make an entry in the TLegend ################### if vfat == 0: print("infoTuple[2] = ", infoTuple[2]) legPlot.AddEntry( dict_Graphs[infoTuple[2]][vfat], "{0}".format(infoTuple[2]), "LPE") pass pass ################### # Make output ROOT file ################### outFileName = "{0}/compLatResults_{1}.root".format(elogPath,chamberName) outFile = r.TFile(outFileName,"RECREATE") ################### # Now Make plots ################### print("Making output plots") dict_canv = {} for vfat in range(24): # Make Output Canvas dict_canv[vfat] = r.TCanvas("canvLatResults_VFAT{0}".format(vfat),"Hits vs. CFG_LATENCY Value",700,700) dict_canv[vfat].cd() dict_MultiGraphs[vfat].Draw("APE1") dict_MultiGraphs[vfat].GetYaxis().SetTitle("Hits #left(A.U.#right)") dict_MultiGraphs[vfat].GetYaxis().SetRangeUser(0,args.eventsPerLat) # max is 40 MHz dict_MultiGraphs[vfat].GetXaxis().SetTitle("CFG_LATENCY #left(BX#right)") dict_MultiGraphs[vfat].Draw("APE1") # Draw Legend? if not args.noLeg: legPlot.Draw("same") pass # Make output image? if args.savePlots: dict_canv[vfat].SaveAs("{0}/{1}.png".format(elogPath,dict_canv[vfat].GetName())) pass # Store Output thisDirectory = outFile.mkdir("VFAT{0}".format(vfat)) thisDirectory.cd() dict_MultiGraphs[vfat].Write() dict_canv[vfat].Write() pass # Make summary canvases, always save these canvLatResults_Summary = make3x8Canvas("canvLatResults_Summary",dict_MultiGraphs.values()[0:24],"APE1") # Draw Legend? if not args.noLeg: canvLatResults_Summary.cd(1) legPlot.Draw("same") pass # Save summary canvases (always) print("\nSaving Summary TCanvas Objects") #canvLatResults_Summary.SaveAs("{0}/{1}.png".format(elogPath,canvLatResults_Summary.GetName())) # Close output files outFile.Close() print("You can find all ROOT objects in:") print("\n\t{0}//compLatResults_{1}.root\n".format(elogPath,chamberName)) print("You can find all plots in:") print("\n\t{0}\n".format(elogPath)) print("Done") return