8 from PlotHelpers 
import *
 
   10 from inspect 
import getmembers, isfunction
 
   12 print "Importing my new stuff" 
   14 import CorrelationMatrixHelpers
 
   18 print "Setting controls" 
   21 SetAxisRange.forceOneSided = 
True 
   24 SetAxisRange.invertAxisColour = 
False 
   25 DetermineStatValues.minInsteadOfMax = 
False 
   29     print "Too few arguments.  Expected the following:" 
   30     print "  1. Jet definition to study, such as AntiKt4LCTopo" 
   31     print "  2. Output plot file" 
   32     print "  3. Correlation uncertainties file, \"None\" is allowed" 
   33     print "  4. Whether to use relative differences instead of absolute, False is default" 
   34     print "  5. Input ROOT file in proper format" 
   35     print "     Typically should be the output file from util/MakeCorrelationMatrixPlots.cxx" 
   36     print "  6+ Additional input ROOT files in proper format (optional)" 
   37     print "     If additional files are specified, minimum correlation differences are plotted" 
   40 print "Getting arguments" 
   44 plotFileName = sys.argv[2]
 
   45 if plotFileName.endswith(
".root"):
 
   46     print "Output plot file appears to be a root file, blocking for safety to not overwrite inputs" 
   47     print "Check input file:",plotFileName
 
   49 corrUncFileName = sys.argv[3]
 
   50 corrUncFile = 
None if not corrUncFileName.endswith(
".root") 
else TFile.Open(corrUncFileName,
"READ")
 
   53 print "Setting up matrices" 
   54 useRelativeMetric = TString(sys.argv[4]).EqualTo(
"true",TString.kIgnoreCase)
 
   55 SetAxisRange.relativeAxis = useRelativeMetric
 
   57 print "Getting file names" 
   58 inFileNames = sys.argv[5:]
 
   59 inFiles = [TFile.Open(name,
"READ") 
for name 
in inFileNames]
 
   62 print "Checking and retrieving fixed pT/eta scan values from input files" 
   65 print fixedPtX,fixedPtY, fixedEtaX, fixedEtaY
 
   72 print "Building raw 4D difference histograms by file" 
   76 print "1) still defined as:",fixedPtX,fixedPtY,fixedEtaX,fixedEtaY
 
   82     if len(nominalPt) > 1:
 
   83         print "Unexpected length of the nominal pT set, expected 1 but got ",len(nominalPt)
 
   86         nominalPt = nominalPt[0]
 
   88     if len(nominalEta) > 1:
 
   89         print "Unexpected length of the nominal eta set, expected 1 but got ",len(nominalEta)
 
   92         nominalEta = nominalEta[0]
 
   94 print "2) still defined as:",fixedPtX,fixedPtY,fixedEtaX,fixedEtaY
 
  103 print "Building 4D correlation uncertainty histograms" 
  111 print "3) still defined as:",fixedPtX,fixedPtY,fixedEtaX,fixedEtaY
 
  116 print "Building 4D minimum difference histograms (with respect to nominal)" 
  122 print "Building 4D file-by-file difference histograms" 
  127 print "Building 4D maximum difference histograms (with respect to each other)" 
  132 if maxDiffPt:  maxDiffPt.applyAbsValue()
 
  133 if maxDiffEta: maxDiffEta.applyAbsValue()
 
  136 print "4) still defined as:",fixedPtX,fixedPtY,fixedEtaX,fixedEtaY
 
  141 print "Building 4D coverage histograms" 
  146 if coveragePt:  coveragePt.plotType  = 
"Metric2" 
  147 if coverageEta: coverageEta.plotType = 
"Metric2" 
  150 print "5) still defined as:",fixedPtX,fixedPtY,fixedEtaX,fixedEtaY
 
  152 saveFixedEtaY = fixedEtaY[:]
 
  153 saveFixedEtaX = fixedEtaX[:]
 
  154 saveFixedPtX = fixedPtX[:]
 
  155 saveFixedPtY = fixedPtY[:]
 
  158 print "Building 4D coverage histograms including correlation uncertainties" 
  165 if coverageWithUncPt:  coverageWithUncPt.plotType  = 
"Metric3" 
  167 if coverageWithUncEta: coverageWithUncEta.plotType = 
"Metric3" 
  169 fixedEtaX = saveFixedEtaX
 
  170 fixedEtaY = saveFixedEtaY
 
  171 fixedPtX = saveFixedPtX
 
  172 fixedPtY = saveFixedPtY
 
  174 print "6) still defined as:",fixedPtX,fixedPtY,fixedEtaX,fixedEtaY
 
  178 print "Writing results to file: ",(re.sub(
".eps",
"-*.eps",plotFileName) 
if plotFileName.endswith(
".eps") 
else (re.sub(
".png",
"-*.png",plotFileName) 
if plotFileName.endswith(
".png") 
else plotFileName))
 
  179 canvas = TCanvas(
"canvas",
"4D Correlation Matrix",0,0,2600,2200)
 
  180 canvas.SetLeftMargin(0.09 
if not useRelativeMetric 
else 0.08)
 
  181 canvas.SetRightMargin(0.19 
if not useRelativeMetric 
else 0.17)
 
  182 canvas.SetBottomMargin(0.04)
 
  183 canvas.SetTopMargin(0.12)
 
  184 canvas.SetLogz(useRelativeMetric)
 
  189 if not (plotFileName.endswith(
".eps") 
or plotFileName.endswith(
".png")):
 
  190     canvas.Print(plotFileName+
"[")
 
  203 print "here, it is",fixedEtaX
 
  206 CorrelationMatrixHelpers.saveHists4D(canvas,plotFileName,minDiffEta,
not useRelativeMetric,fixedEtaX,fixedEtaY,
"#eta=%.1f",scenarioLabel=
"",drawATLASLabel=drawATLASLabel,additionalString =5)
 
  207 CorrelationMatrixHelpers.saveHists4D(canvas,plotFileName,coverageEta,
not useRelativeMetric,fixedEtaX,fixedEtaY,
"#eta=%.1f",scenarioLabel=
"",drawATLASLabel=drawATLASLabel,additionalString=6)
 
  209 CorrelationMatrixHelpers.saveHists4D(canvas,plotFileName,coverageWithUncEta,
not useRelativeMetric,fixedEtaX,fixedEtaY,
"#eta=%.1f",scenarioLabel=
"",drawATLASLabel=drawATLASLabel,additionalString=7)
 
  212 if not (plotFileName.endswith(
".eps") 
or plotFileName.endswith(
".png")):
 
  213     canvas.Print(plotFileName+
"]")