diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/CMakeLists.txt b/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/CMakeLists.txt index 64d20b50fdaf2349b907fde7fe670e181902675a..830e41a9ddef7d2e75c51698095a3e45185d1008 100644 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/CMakeLists.txt +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/CMakeLists.txt @@ -37,5 +37,5 @@ atlas_add_component( MuonPhysValMonitoring LINK_LIBRARIES ${ROOT_LIBRARIES} GaudiKernel AthenaMonitoringLib xAODBase xAODCore xAODEventInfo xAODMuon xAODTracking xAODTrigMuon xAODTrigger xAODTruth MuonHistUtils IsolationSelectionLib MuonSelectorToolsLib MuonCombinedToolInterfaces TrkToolInterfaces TrkValHistUtils TrigDecisionToolLib ) # Install files from the package: -atlas_install_scripts( macros/*.py macros/*.sh macros/*.C ) +atlas_install_scripts( macros/MuonValidation_*.py macros/MuonValidation_*.sh ) diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/cmt/requirements b/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/cmt/requirements index 0e54b3a05843598ef0974422cecd1f1b0a03ab9e..cdbb72d2bd409ad0b8694bffe7ac703ca2d40a8f 100644 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/cmt/requirements +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/cmt/requirements @@ -44,7 +44,7 @@ private ## default is to make component library library MuonPhysValMonitoring *.cxx components/*.cxx -apply_pattern declare_scripts files="-s=$(MuonPhysValMonitoring_root)/macros *.py *.sh *.C" +apply_pattern declare_scripts files="-s=$(MuonPhysValMonitoring_root)/macros MuonValidation_*.py MuonValidation_*.sh" #macro_append cppflags ' -std=c++11 ' #macro_append use_linkopts ' -std=c++11 ' diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/AddGaussianFitToPulls.py b/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/MuonValidation_AddGaussianFitToPulls.py similarity index 98% rename from MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/AddGaussianFitToPulls.py rename to MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/MuonValidation_AddGaussianFitToPulls.py index cd71d49bdc535953a1395bc2e80a033ab5617a20..8494d418814bbaba055c3e9eaae0d98ccfa88830 100644 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/AddGaussianFitToPulls.py +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/MuonValidation_AddGaussianFitToPulls.py @@ -71,6 +71,5 @@ def main( args ): #--------------------------------------------------------------------------- if __name__ == "__main__": - ROOT.gROOT.Macro("rootlogon.C") ROOT.gROOT.SetBatch() main( sys.argv ) diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/CreateEffAndRecoFracPlots.py b/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/MuonValidation_CreateEffAndRecoFracPlots.py similarity index 100% rename from MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/CreateEffAndRecoFracPlots.py rename to MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/MuonValidation_CreateEffAndRecoFracPlots.py diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/CreatePullProfiles.py b/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/MuonValidation_CreatePullProfiles.py similarity index 97% rename from MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/CreatePullProfiles.py rename to MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/MuonValidation_CreatePullProfiles.py index 53564b16cdbc90266fdc43b654dd4089ed727d1a..861d81378f37cac5a4c5e3c167b40de7f9ce3886 100644 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/CreatePullProfiles.py +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/MuonValidation_CreatePullProfiles.py @@ -5,7 +5,7 @@ import os from array import array import itertools import ROOT -from CreateResolutionProfiles import * +from MuonValidation_CreateResolutionProfiles import * #--------------------------------------------------------------------------- @@ -76,6 +76,5 @@ def main( args ): #--------------------------------------------------------------------------- if __name__ == "__main__": - ROOT.gROOT.Macro("rootlogon.C") ROOT.gROOT.SetBatch() main( sys.argv ) diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/CreateResolutionProfiles.py b/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/MuonValidation_CreateResolutionProfiles.py similarity index 99% rename from MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/CreateResolutionProfiles.py rename to MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/MuonValidation_CreateResolutionProfiles.py index 7ff7699cb16d484bf875e63c664f99631891fd55..49b81976d90faec78e2288c782ffd63e5df4af62 100755 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/CreateResolutionProfiles.py +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/MuonValidation_CreateResolutionProfiles.py @@ -223,6 +223,5 @@ def main( args ): #--------------------------------------------------------------------------- if __name__ == "__main__": - ROOT.gROOT.Macro("rootlogon.C") ROOT.gROOT.SetBatch() main( sys.argv ) diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/CreateMuonValidationSlides.py b/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/MuonValidation_CreateSlides.py similarity index 99% rename from MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/CreateMuonValidationSlides.py rename to MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/MuonValidation_CreateSlides.py index f295eb306b0e4268d7ae4b34137bc582f1d63310..333b0c6ce3b366357348c232d33d326a52a94610 100644 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/CreateMuonValidationSlides.py +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/MuonValidation_CreateSlides.py @@ -8,7 +8,7 @@ import sys import os import argparse from commands import getstatusoutput -from config import * +from MuonValidation_CreateSlides_config import * ############################################################################# @@ -305,6 +305,6 @@ if __name__ == "__main__": print( 'INFO This program requires Python version 2.7 or greater' ) exit(1) - ROOT.gROOT.Macro("rootlogon.C") + #ROOT.gROOT.Macro("rootlogon.C") ROOT.gROOT.SetBatch() main() diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/config.py b/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/MuonValidation_CreateSlides_config.py similarity index 100% rename from MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/config.py rename to MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/MuonValidation_CreateSlides_config.py diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/runPostProcessMacros.sh b/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/MuonValidation_runPostProcessMacrosRtt.sh similarity index 77% rename from MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/runPostProcessMacros.sh rename to MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/MuonValidation_runPostProcessMacrosRtt.sh index e768f6309d2f7f02e4e44d985850d3b42f01f727..565a85d1ffcbf7fdda280b6a031068fab8206784 100755 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/runPostProcessMacros.sh +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/MuonValidation_runPostProcessMacrosRtt.sh @@ -14,13 +14,13 @@ tmpfile=$inputfile.temp.root # showing overall efficiency, resolution, scale, etc. ## Creates efficiency and other ratio plots -#CreateEffAndRecoFracPlots.py $tmpfile #doAverage +#MuonValidation_CreateEffAndRecoFracPlots.py $tmpfile #doAverage ## Creates pt resolution and pt scale plots. doBinned option makes res plots for each bin in 2D hists -CreateResolutionProfiles.py $tmpfile #doAverage doBinned +MuonValidation_CreateResolutionProfiles.py $tmpfile #doAverage doBinned ## Creates profiles of pull plots over pt -#CreatePullProfiles.py $tmpfile #doAverage +#MuonValidation_CreatePullProfiles.py $tmpfile #doAverage ## Normalizes all plots to unity (for comparisons). MUST RUN AFTER EFFICIENCY MACROS!!! OTHERWISE EFFICIENCY WILL BE WRONG!!!! # normalizator.py $tmpfile diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/validator.py b/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/validator.py index 358db00c26d4d818ece33911424be5277a971085..4711974b35f277c5874e7547a908965af9006e99 100644 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/validator.py +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/macros/validator.py @@ -14,6 +14,8 @@ import re import os import math +LABELS = [] + def GoToDirectory(directory): cwd = os.getcwd() print os.getcwd() @@ -52,20 +54,21 @@ class Validator(object): self.CompareFunc = compareFunc self.DoNormalization = normalization - def CompareFiles(self,reference, test, dirName): - refFile = TFile.Open(reference) - testFile = TFile.Open(test) - self.CompareDirectories(refFile, testFile, dirName) + def CompareFiles(self, fileNames, dirName): + openedFiles = [ TFile.Open(f) for f in fileNames ] + self.CompareDirectories(openedFiles, dirName) - def CompareDirectories(self, refDir, testDir, dirName): + def CompareDirectories(self, dirs, dirName): if (self.structDirs): GoToDirectory(dirName) + refDir = dirs[0] newRefDir = refDir.GetDirectory(dirName) - if not testDir: - print 'ERROR --------- test dir not found: ', dirName - newTestDir=0 - return - else: - newTestDir = testDir.GetDirectory(dirName) + for testDir in dirs: + if testDir == refDir: continue + if not testDir: + print 'ERROR --------- test dir not found: ', dirName, testDir + return + + newTestDirs = [ testDir.GetDirectory(dirName) for testDir in dirs ] theDir = newRefDir # if not newRefDir: @@ -73,7 +76,7 @@ class Validator(object): # theDir = newTestDir for key in theDir.GetListOfKeys(): - + obj = key.ReadObj() #2D histograms cannot be compared; skip @@ -82,28 +85,29 @@ class Validator(object): if obj.IsA().InheritsFrom(ROOT.TH1.Class()): print key.GetName() - testHist = newTestDir.Get(key.GetName()) - if testHist: - self.CompareHistograms(obj, testHist, newRefDir.GetPath()) + #testHist = newTestDir.Get(key.GetName()) + testHists = [ newTestDir.Get(key.GetName()) for newTestDir in newTestDirs ] + self.CompareHistograms( testHists, newRefDir.GetPath()) elif obj.IsA().InheritsFrom(ROOT.TDirectory.Class()): - self.CompareDirectories(newRefDir, newTestDir, obj.GetName()) + self.CompareDirectories( newTestDirs, obj.GetName()) if (self.structDirs): os.chdir("..") - def CompareHistograms(self, refHist, testHist, path): + def CompareHistograms(self, hists, path): # print self.excludedStrings, refHist.GetName() # if any(exString in refHist.GetName() for exString in self.excludedStrings): # print "Skipped " + path + "/" + refHist.GetName() # return - #@@@if self.CompareFunc(refHist, testHist): print path + refHist.GetName() + " looks ok" #else: - self.MakeComparisonPlot(refHist, testHist, path) + #self.MakeComparisonPlot(refHist, testHist, path) + self.MakeComparisonPlot(hists, path) - def MakeComparisonPlot(self,refHist, testHist, path): - def SetBounds(refHist, testHist, ymin=0, ymax=0): + #def MakeComparisonPlot(self,refHist, testHist, path): + def MakeComparisonPlot(self, hists, path): + def SetBounds(hists, ymin=0, ymax=0): if (ymin==0 and ymax==0): - ymin = min(refHist.GetMinimum(), testHist.GetMinimum()) - ymax = max(refHist.GetMaximum(), testHist.GetMaximum()) + ymin = min( [ h.GetMinimum() for h in hists ] ) + ymax = min( [ h.GetMaximum() for h in hists ] ) if ymin>0 and ymax>0: ymin = 0 else: @@ -112,11 +116,11 @@ class Validator(object): # if ymin<0 and ymax>0: # if ymax>0 and abs(minimum)>ymax: # ymax = -minimum - refHist.SetMinimum(ymin) - refHist.SetMaximum(ymax) - return refHist + hists[0].SetMinimum(ymin) + hists[0].SetMaximum(ymax) + return hists[0] ################################## end SetBounds - + # try: # refHist.Scale(1.0/refHist.Integral()) # testHist.Scale(1.0/testHist.Integral()) @@ -133,29 +137,37 @@ class Validator(object): padRatio.Draw() ROOT.TLine() padMain.cd() - - #leg = ROOT.TLegend(0.82,0.78,0.96,0.94) - leg = ROOT.TLegend(0.8,0.76,0.96,0.94) + + leg = ROOT.TLegend(0.82,0.78,0.96,0.94) + #leg = ROOT.TLegend(0.52,0.76,0.96,0.94) #leg.SetFillColor(ROOT.kWhite) leg.SetFillStyle(0) leg.SetBorderSize(0) leg.SetTextFont(43) - leg.SetTextSizePixels(32) - leg.AddEntry(refHist, "ref", 'lp') - leg.AddEntry(testHist, "test",'lp') - + leg.SetTextSizePixels(32) + + refHist = hists[0] refHist.SetLineColor(17) #refHist.SetFillColor(30) - if self.DoNormalization and not "_Eff_" in refHist.GetName() and not "_eff" in refHist.GetName(): - i1 = 1.*refHist.Integral() - i2 = 1.*testHist.Integral() - if i1>i2: - refHist.Scale(i2/i1) - elif i2>0: - testHist.Scale(i1/i2) - - refHist = SetBounds(refHist, testHist) + ## @@@ Legend!!! + #leg.AddEntry(hists[0], 'ref', 'lp') + #leg.AddEntry(hists[1], 'test', 'lp') + #if len(hists)>2: + # for i in range(2,len(hists)): + # leg.AddEntry(hists[i], 'test{0}'.format(i), 'lp') + for i in range(0,len(hists)): + leg.AddEntry(hists[i], LABELS[i], 'lp') + + if self.DoNormalization and not "_Eff_" in refHist.GetName() and not "_eff" in refHist.GetName() and not "_Eff" in refHist.GetName(): + for h in hists: + n = h.Integral() + if n>0: + h.Scale(1./n) + for i in range (1,h.GetXaxis().GetNbins()+1): + h.SetBinError(i,h.GetBinError(i)/n); + + refHist = SetBounds(hists) ref_textsize = 32./(padMain.GetWh()*padMain.GetAbsHNDC()) refHist.GetYaxis().SetLabelSize( ref_textsize ) @@ -173,52 +185,80 @@ class Validator(object): #testHist.Rebin(2) #refHist.Rebin(2); - - if refHist.GetMaximum()>testHist.GetMaximum(): - refHist.DrawCopy("e") - testHist.DrawCopy("ehistsame") - refHist.DrawCopy("ehistsame") - else: - testHist.DrawCopy("ehist") - refHist.DrawCopy("ehistsame") + histmax = refHist + histmax.DrawCopy('e') + # for h in hists: + # if h.GetMaximum() > refHist.GetMaximum(): + # histmax = h + # if histmax == refHist: + # histmax.DrawCopy("e") + # else: + # histmax.DrawCopy("ehist") + nh=0 + for h in hists: + if h is not histmax: + if h==refHist: + h.DrawCopy('histsame') + else: + nh=nh+1 + if nh>1: + h.SetMarkerStyle(0) + h.SetMarkerColor(0) + h.SetLineColor(8) # green + h.SetLineStyle(ROOT.kDashed) + h.DrawCopy('ehistsame') + # if refHist.GetMaximum()>histmax.GetMaximum(): + # refHist.DrawCopy("e") + # testHist.DrawCopy("ehistsame") + # refHist.DrawCopy("ehistsame") + # else: + # testHist.DrawCopy("ehist") + # refHist.DrawCopy("ehistsame") leg.Draw() padRatio.cd() - ratioHist = testHist.Clone() - ratioHist.Divide(refHist) - #ratioHist = SetBounds(ratioHist, ratioHist, 0.84,1.16) - ratioHist = SetBounds(ratioHist, ratioHist, 0.941,1.059) - for i in range(ratioHist.GetNbinsX()): - nref = refHist.GetBinContent(i) - ntest = testHist.GetBinContent(i) - if nref == 0 or ntest == 0: - ratioHist.SetBinError(i, 0) - else: - #error = nref/ntest*math.sqrt((refHist.GetBinError(i)/nref)**2 + (testHist.GetBinError(i)/ntest)**2) - error = nref/ntest* max(refHist.GetBinError(i)/nref, testHist.GetBinError(i)/ntest) - ratioHist.SetBinError(i, error) - ratioHist_textsize = 32./(padRatio.GetWh()*padRatio.GetAbsHNDC()) - ratioHist.GetYaxis().SetLabelSize( ratioHist_textsize ) - ratioHist.GetXaxis().SetLabelSize( ratioHist_textsize ) - ratioHist.GetXaxis().SetTitleSize( 1.2*ratioHist_textsize ) - ratioHist.GetXaxis().SetTitleOffset(0.75) - ratioHist.GetXaxis().SetTitleColor(kAzure) - ratioHist.GetYaxis().SetTitleSize( ratioHist_textsize ) - ratioHist.GetYaxis().SetTitleOffset(0.6) + for h in hists: + if h is refHist: continue + ratioHist = h.Clone() + ratioHist.Divide(refHist) + ratioHist = SetBounds( [ratioHist, ratioHist], 0.84,1.16) # 0.941,1.059 + for i in range(ratioHist.GetNbinsX()): + nref = refHist.GetBinContent(i) + ntest = h.GetBinContent(i) + if nref == 0 or ntest == 0: + ratioHist.SetBinError(i, 0) + else: + #error = nref/ntest*math.sqrt((refHist.GetBinError(i)/nref)**2 + (testHist.GetBinError(i)/ntest)**2) + error = nref/ntest* max(refHist.GetBinError(i)/nref, h.GetBinError(i)/ntest) + ratioHist.SetBinError(i, error) + + ratioHist_textsize = 32./(padRatio.GetWh()*padRatio.GetAbsHNDC()) + ratioHist.GetYaxis().SetLabelSize( ratioHist_textsize ) + ratioHist.GetXaxis().SetLabelSize( ratioHist_textsize ) + ratioHist.GetXaxis().SetTitleSize( 1.2*ratioHist_textsize ) + ratioHist.GetXaxis().SetTitleOffset(0.75) + ratioHist.GetXaxis().SetTitleColor(kAzure) + ratioHist.GetYaxis().SetTitleSize( ratioHist_textsize ) + ratioHist.GetYaxis().SetTitleOffset(0.6) - ratioHist.SetLineColor(ROOT.kBlack) - ratioHist.SetMarkerStyle(24) - ratioHist.SetYTitle("test / ref") - ratioHist.Draw("p") - - lineRatio = ROOT.TLine( ratioHist.GetXaxis().GetXmin(), 1, - ratioHist.GetXaxis().GetXmax(), 1 ) - lineRatio.SetLineColor( ROOT.kRed ) - lineRatio.SetLineWidth( 2 ) - lineRatio.Draw("same") - + ratioHist.SetLineColor(ROOT.kBlack) + ratioHist.SetMarkerStyle(24) + ratioHist.SetYTitle("test / ref") + if h == hists[1]: + ratioHist.DrawCopy("p") + lineRatio = ROOT.TLine( ratioHist.GetXaxis().GetXmin(), 1, + ratioHist.GetXaxis().GetXmax(), 1 ) + lineRatio.SetLineColor( ROOT.kRed ) + lineRatio.SetLineWidth( 2 ) + lineRatio.Draw("same") + else: + ratioHist.SetMarkerStyle(25) + ratioHist.SetMarkerColor(8) + ratioHist.SetLineColor(8) + ratioHist.DrawCopy("psame") + npath = "" if not self.structDirs: npath = path[path.find(":/")+2:] + "/" @@ -242,23 +282,43 @@ def main( argv ): parser = argparse.ArgumentParser( description = 'Distribution Plotter' ) parser.add_argument( '-s', '--structDirs', default = True, action = "store_true", help = ' if true, it creates directories following the same structure as in the root file to store the pdf plots') - parser.add_argument( '-r', '--reference', help = 'bla' ) - parser.add_argument( '-t', '--test', help = 'Print cutflow' ) + parser.add_argument( '-r', '--reference', help = 'The reference' ) + parser.add_argument( '-t', '--test', help = 'The test' ) + parser.add_argument( '-t2', '--test2', default ='', help = 'The additional test' ) parser.add_argument( '-d', '--directory', default = "/", help = 'Print cutflow fror systematic variations' ) parser.add_argument( '-e', '--exclude', default = "_bin_", help = 'histograms whose names contain the provided strings are not examined') parser.add_argument( '-n', '--normalize', default = False, action = "store_true", help = 'normalize histograms with larger stats for better comparison') + parser.add_argument( '-l', '--labels', default ='', help = 'Add text to legend for ref/test/test2, split with commas' ) + args = parser.parse_args() + #ROOT.gROOT.Macro("rootlogon.C") ROOT.gROOT.SetBatch() #ROOT.gROOT.LoadMacro("./AtlasUtils.C") ROOT.gROOT.LoadMacro("./AtlasStyle.C") - - SetAtlasStyle() + ROOT.TH1.SetDefaultSumw2(ROOT.kTRUE) + SetAtlasStyle() + + LABELS = [] + if args.labels is '': + LABELS = [ 'Ref','Test' ] + if args.test2 is not '': + LABELS.append( 'Test2' ) + else: + LABELS = args.labels.split(",") + #print LABELS + + # if you want to pass labels to legend directly from the file name...: + #LABELS.append( args.test.split('.')[2]+' '+args.test.split('.')[3] ) + # + validator = Validator( args.structDirs, args.exclude, SameHist, args.normalize ) - validator.CompareFiles(os.path.abspath(args.reference), os.path.abspath(args.test), args.directory) - #validator.CompareFiles(os.path.abspath(args.test), os.path.abspath(args.reference), args.directory) + if args.test2 == '': + allFiles = [ os.path.abspath(args.reference), os.path.abspath(args.test) ] + else: + allFiles = [ os.path.abspath(args.reference), os.path.abspath(args.test), os.path.abspath(args.test2) ] #====================================================================== if __name__ == "__main__": diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/src/MuonPhysValMonitoringTool.cxx b/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/src/MuonPhysValMonitoringTool.cxx index e72c95acc9631f15360c315073f53e248ba9a9d1..e8facb7a922769bfef53d6b3d58d5593f64cd605 100644 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/src/MuonPhysValMonitoringTool.cxx +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/src/MuonPhysValMonitoringTool.cxx @@ -17,6 +17,10 @@ #include "xAODMuon/MuonContainer.h" #include "xAODMuon/MuonAuxContainer.h" #include "xAODMuon/Muon.h" +#include "xAODMuon/SlowMuonContainer.h" +#include "xAODMuon/SlowMuonAuxContainer.h" +#include "xAODMuon/SlowMuon.h" + #include "xAODTrigger/MuonRoI.h" #include "xAODTrigger/MuonRoIContainer.h" #include "xAODTrigMuon/L2StandAloneMuonContainer.h" @@ -35,7 +39,9 @@ #include "xAODBase/IParticleHelpers.h" #include "TString.h" -#include <math.h> +#include <math.h> + +typedef ElementLink< xAOD::TrackParticleContainer > TrackLink; typedef ElementLink< xAOD::MuonContainer > MuonLink; typedef ElementLink< xAOD::MuonSegmentContainer > MuonSegmentLink; typedef ElementLink< xAOD::TruthParticleContainer > TruthLink; @@ -83,6 +89,7 @@ MuonPhysValMonitoringTool::MuonPhysValMonitoringTool( const std::string& type, declareProperty( "IsData", m_isData = false ); declareProperty( "MuonContainerName", m_muonsName = "Muons" ); + declareProperty( "SlowMuonContainerName", m_slowMuonsName = "SlowMuons" ); declareProperty( "MuonTruthParticleContainerName", m_muonsTruthName = "MuonTruthParticles" ); declareProperty( "TrackContainerName", m_tracksName); @@ -127,6 +134,8 @@ StatusCode MuonPhysValMonitoringTool::initialize() { ATH_MSG_INFO ("Initializing " << name() << "..."); ATH_CHECK(ManagedMonitorToolBase::initialize()); + + if (m_slowMuonsName!="") m_muonsName = m_slowMuonsName; for (unsigned int i=0; i<m_selectHLTMuonItems.size(); i++){ if(m_selectHLTMuonItems[i][0]=="" || m_selectHLTMuonItems[i][1]=="") continue; @@ -213,6 +222,7 @@ StatusCode MuonPhysValMonitoringTool::bookHistograms() unsigned int defaultAuthorList[]={xAOD::Muon::MuidCo,xAOD::Muon::MuTagIMO,xAOD::Muon::MuidSA,xAOD::Muon::MuGirl,xAOD::Muon::CaloTag,xAOD::Muon::CaloLikelihood}; for (const auto author : defaultAuthorList) m_selectMuonAuthors.push_back(author); } + else if (m_selectMuonAuthors.size()==1 && m_selectMuonAuthors[0]==0) m_selectMuonAuthors.clear(); if (m_selectMuonCategories.size()==0) { unsigned int defaultMuonCategories[]={ ALL, PROMPT, INFLIGHT, NONISO, REST }; @@ -228,12 +238,17 @@ StatusCode MuonPhysValMonitoringTool::bookHistograms() for (const auto category: m_selectMuonCategories) m_selectMuonCategoriesStr.push_back(theMuonCategories[category]); + bool separateSAFMuons = true; + if (m_slowMuonsName!="") separateSAFMuons = false; // no such muons in case of SlowMuon reco + for (const auto category : m_selectMuonCategoriesStr) { - std::string categoryPath = "Muons/"+category+"/"; + std::string categoryPath = m_muonsName+"/"+category+"/"; m_muonValidationPlots.push_back( new MuonValidationPlots(0, categoryPath, m_selectMuonWPs, m_selectMuonAuthors, m_isData, (category==theMuonCategories[ALL]? false : m_doBinnedResolutionPlots), + separateSAFMuons, m_doMuonTree)); + m_slowMuonValidationPlots.push_back( new SlowMuonValidationPlots( 0, categoryPath, m_isData ) ); if (m_doTrigMuonValidation) { if (category=="All"){ m_TriggerMuonValidationPlots.push_back( new TriggerMuonValidationPlots(0, categoryPath, @@ -242,7 +257,7 @@ StatusCode MuonPhysValMonitoringTool::bookHistograms() } if (m_muonTracksName!="") { m_muonMSTrackValidationPlots.push_back(new MuonTrackValidationPlots(0, categoryPath, "MSTrackParticles", m_isData)); - if (!m_isData) m_oUnmatchedRecoMuonTrackPlots = new Muon::RecoMuonTrackPlotOrganizer(0, "Muons/UnmatchedRecoMuonTracks/"); + if (!m_isData) m_oUnmatchedRecoMuonTrackPlots = new Muon::RecoMuonTrackPlotOrganizer(0, Form("%s/UnmatchedRecoMuonTracks/",m_muonsName.c_str())); } if (m_muonExtrapolatedTracksName!="") m_muonMETrackValidationPlots.push_back(new MuonTrackValidationPlots(0, categoryPath, "METrackParticles", m_isData)); if (m_muonMSOnlyExtrapolatedTracksName!="") m_muonMSOnlyMETrackValidationPlots.push_back(new MuonTrackValidationPlots(0, categoryPath, "MSOnlyMETrackParticles", m_isData)); @@ -256,16 +271,17 @@ StatusCode MuonPhysValMonitoringTool::bookHistograms() if (m_muonSegmentsName!="") { if (category!=theMuonCategories[ALL]) continue; //cannot identify the truth origin of segments... m_muonSegmentValidationPlots.push_back(new MuonSegmentValidationPlots(0, categoryPath, m_isData)); - if (!m_isData) m_oUnmatchedRecoMuonSegmentPlots = new Muon::MuonSegmentPlots(0, "Muons/UnmatchedRecoMuonSegments/"); + if (!m_isData) m_oUnmatchedRecoMuonSegmentPlots = new Muon::MuonSegmentPlots(0, Form("%s/UnmatchedRecoMuonSegments/",m_muonsName.c_str())); } } if (!m_isData) { - m_oUnmatchedRecoMuonPlots = new Muon::RecoMuonPlotOrganizer(0, "Muons/UnmatchedRecoMuons/"); - m_oUnmatchedTruthMuonPlots = new Muon::TruthMuonPlotOrganizer(0, "Muons/UnmatchedTruthMuons/"); + m_oUnmatchedRecoMuonPlots = new Muon::RecoMuonPlotOrganizer(0, Form("%s/UnmatchedRecoMuons/",m_muonsName.c_str())); + m_oUnmatchedTruthMuonPlots = new Muon::TruthMuonPlotOrganizer(0, Form("%s/UnmatchedTruthMuons/",m_muonsName.c_str())); } for (const auto plots : m_muonValidationPlots) bookValidationPlots(*plots).ignore(); + for (const auto plots : m_slowMuonValidationPlots) bookValidationPlots(*plots).ignore(); for (const auto plots : m_TriggerMuonValidationPlots) bookValidationPlots(*plots).ignore(); for (const auto plots : m_muonIDTrackValidationPlots) bookValidationPlots(*plots).ignore(); for (const auto plots : m_muonIDSelectedTrackValidationPlots) bookValidationPlots(*plots).ignore(); @@ -282,37 +298,37 @@ StatusCode MuonPhysValMonitoringTool::bookHistograms() } //book overview hists - h_overview_Z_mass = new TH1F("Muons_Overview_Z_mass","",20,76,106); - ATH_CHECK(regHist(h_overview_Z_mass,"Muons/Overview",all)); - h_overview_Z_mass_ME = new TH1F("Muons_Overview_Z_mass_ME","",20,76,106); - ATH_CHECK(regHist(h_overview_Z_mass_ME,"Muons/Overview",all)); - h_overview_Z_mass_ID = new TH1F("Muons_Overview_Z_mass_ID","",20,76,106); - ATH_CHECK(regHist(h_overview_Z_mass_ID,"Muons/Overview",all)); + h_overview_Z_mass = new TH1F(Form("%s_Overview_Z_mass",m_muonsName.c_str()),"",20,76,106); + ATH_CHECK(regHist(h_overview_Z_mass,Form("%s/Overview",m_muonsName.c_str()),all)); + h_overview_Z_mass_ME = new TH1F(Form("%s_Overview_Z_mass_ME",m_muonsName.c_str()),"",20,76,106); + ATH_CHECK(regHist(h_overview_Z_mass_ME,Form("%s/Overview",m_muonsName.c_str()),all)); + h_overview_Z_mass_ID = new TH1F(Form("%s_Overview_Z_mass_ID",m_muonsName.c_str()),"",20,76,106); + ATH_CHECK(regHist(h_overview_Z_mass_ID,Form("%s/Overview",m_muonsName.c_str()),all)); h_overview_nObjects.clear(); - h_overview_nObjects.push_back(new TH1F("Muons_Overview_N_perevent_truth_muons", "Number of truth Muons per event", 20, -0.5, 19.5)); - h_overview_nObjects.push_back(new TH1F("Muons_Overview_N_perevent_muons", "Number of Muons per event", 20, -0.5, 19.5)); - h_overview_nObjects.push_back(new TH1F("Muons_Overview_N_perevent_tracks", "Number of Tracks per event", 50, -0.5, 49.5)); - h_overview_nObjects.push_back(new TH1F("Muons_Overview_N_perevent_truth_segments", "Number of truth Segments per event", 200, -0.5, 199.5)); - h_overview_nObjects.push_back(new TH1F("Muons_Overview_N_perevent_segments", "Number of Segments per event", 200, -0.5, 199.5)); + h_overview_nObjects.push_back(new TH1F(Form("%s_Overview_N_perevent_truth_muons",m_muonsName.c_str()), "Number of truth Muons per event", 20, -0.5, 19.5)); + h_overview_nObjects.push_back(new TH1F(Form("%s_Overview_N_perevent_muons",m_muonsName.c_str()), "Number of Muons per event", 20, -0.5, 19.5)); + h_overview_nObjects.push_back(new TH1F(Form("%s_Overview_N_perevent_tracks",m_muonsName.c_str()), "Number of Tracks per event", 50, -0.5, 49.5)); + h_overview_nObjects.push_back(new TH1F(Form("%s_Overview_N_perevent_truth_segments",m_muonsName.c_str()), "Number of truth Segments per event", 200, -0.5, 199.5)); + h_overview_nObjects.push_back(new TH1F(Form("%s_Overview_N_perevent_segments",m_muonsName.c_str()), "Number of Segments per event", 200, -0.5, 199.5)); for (const auto hist : h_overview_nObjects) { - if (hist) ATH_CHECK(regHist(hist,"Muons/Overview",all)); + if (hist) ATH_CHECK(regHist(hist,Form("%s/Overview",m_muonsName.c_str()),all)); } - h_overview_reco_category = new TH1F("Muons_Overview_reco_category","",4,0,4); //prompt/in-flight/non-isolated/other + h_overview_reco_category = new TH1F(Form("%s_Overview_reco_category",m_muonsName.c_str()),"",4,0,4); //prompt/in-flight/non-isolated/other for (int i=1; i<4; i++) { //skip 'All' h_overview_reco_category->GetXaxis()->SetBinLabel(i,theMuonCategories[i].c_str()); } h_overview_reco_category->GetXaxis()->SetBinLabel(4,"Other"); //of some other origin or fakes - ATH_CHECK(regHist(h_overview_reco_category,"Muons/Overview",all)); + ATH_CHECK(regHist(h_overview_reco_category,Form("%s/Overview",m_muonsName.c_str()),all)); int nAuth = xAOD::Muon::NumberOfMuonAuthors; for (int i=1; i<4; i++) { - h_overview_reco_authors.push_back(new TH1F(("Muons_"+theMuonCategories[i]+"_reco_authors").c_str(),("Muons_"+theMuonCategories[i]+"_reco_authors").c_str(),nAuth+1,-0.5,nAuth+0.5)); + h_overview_reco_authors.push_back(new TH1F((m_muonsName+"_"+theMuonCategories[i]+"_reco_authors").c_str(),(m_muonsName+"_"+theMuonCategories[i]+"_reco_authors").c_str(),nAuth+1,-0.5,nAuth+0.5)); } - h_overview_reco_authors.push_back(new TH1F("Muons_Overview_Other_reco_authors","Muons_Other_reco_authors",nAuth+1,-0.5,nAuth+0.5)); + h_overview_reco_authors.push_back(new TH1F((m_muonsName+"_Overview_Other_reco_authors").c_str(),(m_muonsName+"_Other_reco_authors").c_str(),nAuth+1,-0.5,nAuth+0.5)); for (const auto hist : h_overview_reco_authors) { - if (hist) ATH_CHECK(regHist(hist,"Muons/Overview",all)); + if (hist) ATH_CHECK(regHist(hist,Form("%s/Overview",m_muonsName.c_str()),all)); } return StatusCode::SUCCESS; @@ -354,6 +370,7 @@ StatusCode MuonPhysValMonitoringTool::fillHistograms() ATH_MSG_DEBUG ("Filling hists " << name() << "..."); m_vMatchedTruthMuons.clear(); m_vMatchedMuons.clear(); + m_vMatchedSlowMuons.clear(); m_vMatchedMuonTracks.clear(); m_vMatchedMuonSegments.clear(); m_vZmumuIDTracks.clear(); @@ -390,13 +407,25 @@ StatusCode MuonPhysValMonitoringTool::fillHistograms() h_overview_nObjects[0]->Fill(TruthMuons->size()); } - const xAOD::MuonContainer* Muons = evtStore()->retrieve< const xAOD::MuonContainer >( m_muonsName ); - if (!Muons) { - ATH_MSG_WARNING ("Couldn't retrieve Muons container with key: " << m_muonsName); - return StatusCode::SUCCESS; - } - ATH_MSG_DEBUG("Retrieved muons " << Muons->size()); - h_overview_nObjects[1]->Fill(Muons->size()); + const xAOD::MuonContainer* Muons = 0; + const xAOD::SlowMuonContainer* SlowMuons = 0; + if (m_slowMuonsName!="") { + SlowMuons = evtStore()->retrieve< const xAOD::SlowMuonContainer >( m_slowMuonsName ); + if (!SlowMuons) { + ATH_MSG_WARNING ("Couldn't retrieve SlowMuons container with key: " << m_slowMuonsName); + return StatusCode::SUCCESS; + } + ATH_MSG_DEBUG("Retrieved slow muons " << SlowMuons->size()); + h_overview_nObjects[1]->Fill(SlowMuons->size()); + } else { + Muons = evtStore()->retrieve< const xAOD::MuonContainer >( m_muonsName ); + if (!Muons) { + ATH_MSG_WARNING ("Couldn't retrieve Muons container with key: " << m_muonsName); + return StatusCode::SUCCESS; + } + ATH_MSG_DEBUG("Retrieved muons " << Muons->size()); + h_overview_nObjects[1]->Fill(Muons->size()); + } /////////////////////////////////////////////////////////////////////// @@@ // @@@ Temp hack to get the MuonSpectrometerTrackParticle (@MS Entry, not extrapolated), needed for eloss plots @@ -416,14 +445,15 @@ StatusCode MuonPhysValMonitoringTool::fillHistograms() //Do resonance selection std::vector<std::pair<const xAOD::Muon*,const xAOD::Muon*> > pairs; - for (const auto mu1: *Muons) { - for (const auto mu2: *Muons) { - if (mu1==mu2) continue; - if (mu1->charge()*mu2->charge()>=0) continue; - pairs.push_back(std::make_pair(mu1,mu2)); + if (Muons) { + for (const auto mu1: *Muons) { + for (const auto mu2: *Muons) { + if (mu1==mu2) continue; + if (mu1->charge()*mu2->charge()>=0) continue; + pairs.push_back(std::make_pair(mu1,mu2)); + } } } - float dMmin=1e10; float mZ=0; @@ -488,8 +518,17 @@ StatusCode MuonPhysValMonitoringTool::fillHistograms() for (const auto truthMu: *TruthMuons) handleTruthMuon(truthMu); } - for (const auto mu: *Muons) handleMuon(mu); - + if (SlowMuons) { + for (const auto smu: *SlowMuons) { + if (!smu) continue; + const MuonLink link = smu->muonLink(); + if (!link.isValid()) continue; + //handleSlowMuon( smu ); + handleMuon( *link, smu); + } + } + else if (Muons) + for (const auto mu: *Muons) handleMuon(mu); if (m_tracksName!="") { auto IDTracks = getContainer<xAOD::TrackParticleContainer>( m_tracksName ); @@ -517,7 +556,7 @@ StatusCode MuonPhysValMonitoringTool::fillHistograms() for(const auto tp : *MuonExtrapolatedTracks) handleMuonTrack(tp,xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle); } - if (m_muonMSOnlyExtrapolatedTracksName!="") { + if (m_muonMSOnlyExtrapolatedTracksName!="" && evtStore()->contains<xAOD::TrackParticleContainer>(m_muonMSOnlyExtrapolatedTracksName)) { auto MSOnlyMuonExtrapolatedTracks = getContainer<xAOD::TrackParticleContainer>( m_muonMSOnlyExtrapolatedTracksName ); if (!MSOnlyMuonExtrapolatedTracks) return StatusCode::FAILURE; ATH_MSG_DEBUG("handling " << MSOnlyMuonExtrapolatedTracks->size() << " " << m_muonMSOnlyExtrapolatedTracksName); @@ -951,11 +990,22 @@ void MuonPhysValMonitoringTool::handleMuonSegment(const xAOD::MuonSegment* muSeg } -void MuonPhysValMonitoringTool::handleMuon(const xAOD::Muon* mu) +void MuonPhysValMonitoringTool::handleMuon(const xAOD::Muon* mu, const xAOD::SlowMuon *smu) { if (!mu) return; if (msgLvl(MSG::DEBUG)) printMuonDebug(mu); + //make deep copy of muon and decorate with quality + xAOD::Muon* mu_c = 0; + try{ + mu_c = getCorrectedMuon(*mu); + } + catch(SG::ExcBadAuxVar&){ + ATH_MSG_ERROR( "Cannot retrieve aux-item - rejecting muon" ); + if (mu_c) delete mu_c; + return; + } + if (m_isData) { MUCATEGORY thisMuonCategory = ALL; // for events with a Zmumu candidate, separate Z muons from the rest: @@ -971,32 +1021,30 @@ void MuonPhysValMonitoringTool::handleMuon(const xAOD::Muon* mu) //fill plots for (unsigned int i=0; i<m_selectMuonCategories.size(); i++) { if (m_selectMuonCategories[i]==ALL || m_selectMuonCategories[i]==thisMuonCategory) { - m_muonValidationPlots[i]->fill(*mu); + m_muonValidationPlots[i]->fill(*mu_c); + if (smu && mu_c) m_slowMuonValidationPlots[i]->fill(*smu,*mu_c); } } return; } - //make deep copy of muon and decorate with quality - xAOD::Muon* mu_c = 0; - try{ - mu_c = getCorrectedMuon(*mu); - } - catch(SG::ExcBadAuxVar&){ - ATH_MSG_ERROR( "Cannot retrieve aux-item - rejecting muon" ); - if (mu_c) delete mu_c; - return; - } /////////////////////////////////////////////////////// //SELECT MUON MEDIUM QUALITY FOR TRIGGER VALIDATION xAOD::Muon::Quality my_quality=m_muonSelectionTool->getQuality(*mu_c); if (my_quality<=xAOD::Muon::Medium && m_isoTool->accept( *mu_c )) m_vRecoMuons.push_back(mu); /////////////////////////////////////////////////////// - - if (std::find(std::begin(m_vMatchedMuons), std::end(m_vMatchedMuons), mu) != std::end(m_vMatchedMuons)) { - if (mu_c) delete mu_c; - return; + + if (smu) { + if (std::find(std::begin(m_vMatchedSlowMuons), std::end(m_vMatchedSlowMuons), smu) != std::end(m_vMatchedSlowMuons)) { + if (mu_c) delete mu_c; + return; + } + } else { + if (std::find(std::begin(m_vMatchedMuons), std::end(m_vMatchedMuons), mu) != std::end(m_vMatchedMuons)) { + if (mu_c) delete mu_c; + return; + } } //unmatched reco muons (not matched with any kind of truth particle, fakes) @@ -1009,16 +1057,72 @@ void MuonPhysValMonitoringTool::handleMuon(const xAOD::Muon* mu) for (unsigned int i=0; i<m_selectMuonCategories.size(); i++) { if (m_selectMuonCategories[i]==ALL) { m_muonValidationPlots[i]->fill(*mu_c); + if (smu && mu_c) m_slowMuonValidationPlots[i]->fill(*smu,*mu_c); break; } } if (mu_c) delete mu_c; } +void MuonPhysValMonitoringTool::handleSlowMuon(const xAOD::SlowMuon */*smu*/) +{ + // if (!smu) return; + // const MuonLink muLink = smu->muonLink(); + // if (!muLink.isValid()) return; + + // //make deep copy of muon and decorate with quality + // xAOD::Muon* mu_c = 0; + // try{ + // mu_c = getCorrectedMuon( *(*muLink) ); + // } + // catch(SG::ExcBadAuxVar&){ + // ATH_MSG_ERROR( "Cannot retrieve aux-item - rejecting muon" ); + // if (mu_c) delete mu_c; + // return; + // } + + // const TrackLink trackLink = mu_c->inDetTrackParticleLink(); + + // // const TruthLink truthMuLink = mu_c->auxdata<TruthLink>("truthParticleLink"); + // const xAOD::TruthParticle* truthMu = 0; + // unsigned int thisMuonCategory = 999; + // if (trackLink.isValid()) { + // thisMuonCategory = getMuonTruthCategory( *trackLink ); + // } + // // if (truthMuLink.isValid()) { + // // truthMu = *truthMuLink; + // // thisMuonCategory = getMuonTruthCategory(truthMu); + // // } + // ATH_MSG_INFO(" --- " << truthMu << " " << thisMuonCategory); + // for (unsigned int i=0; i<m_selectMuonCategories.size(); i++) { + // if (m_selectMuonCategories[i]==ALL || m_selectMuonCategories[i]==thisMuonCategory) { + // m_slowMuonValidationPlots[i]->fill(truthMu, smu, mu_c); + // break; + // } + // } + // if (mu_c) delete mu_c; +} void MuonPhysValMonitoringTool::handleTruthMuon(const xAOD::TruthParticle* truthMu) { - const xAOD::Muon* mu = findRecoMuon(truthMu); + const xAOD::SlowMuon* smu = 0; + const xAOD::Muon* mu = 0; + if (m_slowMuonsName!="") { + smu = findRecoSlowMuon(truthMu); + if (smu) { + const MuonLink muLink = smu->muonLink(); + if (muLink.isValid()) + mu = *muLink; + + if (!mu) { + ATH_MSG_WARNING("Found SlowMuon without valid muon link"); + smu = 0; + } + } + } + else { + mu = findRecoMuon(truthMu); + } if (msgLvl(MSG::DEBUG)) printTruthMuonDebug(truthMu, mu); if ( !passesAcceptanceCuts(truthMu) ) return; @@ -1039,6 +1143,7 @@ void MuonPhysValMonitoringTool::handleTruthMuon(const xAOD::TruthParticle* truth for (unsigned int i=0; i<m_selectMuonCategories.size(); i++) { if (m_selectMuonCategories[i]==ALL || m_selectMuonCategories[i]==thisMuonCategory) { m_muonValidationPlots[i]->fill(truthMu, mu_c, MSTracks); //if no muon is found a protection inside MuonValidationPlots will ensure, its plots won't be filled + m_slowMuonValidationPlots[i]->fill(truthMu, smu, mu_c); } } if (mu_c) { @@ -1101,7 +1206,7 @@ void MuonPhysValMonitoringTool::handleMuonTrack(const xAOD::TrackParticle* tp, x if (!truthLink.isValid()) { - ATH_MSG_VERBOSE("No truth link available"); + ATH_MSG_DEBUG("No truth link available"); if (type==xAOD::Muon::InnerDetectorTrackParticle) return; if (!passesAcceptanceCuts(tp)) return; @@ -1338,6 +1443,29 @@ const xAOD::Muon* MuonPhysValMonitoringTool::findRecoMuon(const xAOD::TruthParti return (*link); } +const xAOD::SlowMuon* MuonPhysValMonitoringTool::findRecoSlowMuon(const xAOD::TruthParticle* truthMu) +{ + if (m_slowMuonsName=="") return nullptr; + + // if(!truthMu->isAvailable< MuonLink >("recoMuonLink") ) return nullptr; + // const MuonLink link = truthMu->auxdata< MuonLink >("recoMuonLink"); + // if(!link.isValid() ) return nullptr; + + const xAOD::SlowMuonContainer* SlowMuons = 0; + SlowMuons = evtStore()->retrieve< const xAOD::SlowMuonContainer >( m_slowMuonsName ); + for (const auto smu: *SlowMuons) { + const MuonLink muLink = smu->muonLink(); + if (!muLink.isValid()) continue; + float DR = (*muLink)->p4().DeltaR(truthMu->p4()); + if ( DR<0.005 ) { + m_vMatchedSlowMuons.push_back(smu); + return smu; + } + } + + return nullptr; +} + void MuonPhysValMonitoringTool::printTruthMuonDebug(const xAOD::TruthParticle* truthMu, const xAOD::Muon* mu) { @@ -1425,6 +1553,15 @@ MuonPhysValMonitoringTool::MUCATEGORY MuonPhysValMonitoringTool::getMuonSegmentT return REST; } +MuonPhysValMonitoringTool::MUCATEGORY MuonPhysValMonitoringTool::getMuonTruthCategory(const xAOD::Muon* mu) +{ + int truthType = mu->auxdata< int >("truthType"); + if (truthType == 6) return PROMPT; + else if (truthType == 8 && (mu->auxdata< int >("truthOrigin") == 34 || mu->auxdata< int >("truthOrigin") == 35)) return INFLIGHT; + else if (truthType == 7 ) return NONISO; + return REST; +} + MuonPhysValMonitoringTool::MUCATEGORY MuonPhysValMonitoringTool::getMuonTruthCategory(const xAOD::IParticle* mu) { int truthType = mu->auxdata< int >("truthType"); diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/src/MuonPhysValMonitoringTool.h b/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/src/MuonPhysValMonitoringTool.h index 56f3b7dcc56eb0ce54ca2c39cb791576f7d0a4fb..7222adba4fbb7cd829f216fd8ac09ac40a3b4463 100644 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/src/MuonPhysValMonitoringTool.h +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/src/MuonPhysValMonitoringTool.h @@ -25,6 +25,8 @@ #include "xAODTrigMuon/L2CombinedMuonContainer.h" #include "xAODTrigMuon/L2CombinedMuon.h" +#include "xAODMuon/SlowMuon.h" + // Tools #include "MuonSelectorTools/IMuonSelectionTool.h" #include "TrigDecisionTool/TrigDecisionTool.h" @@ -41,11 +43,12 @@ #include "TriggerMuonValidationPlots.h" #include "MuonTrackValidationPlots.h" #include "MuonSegmentValidationPlots.h" +#include "SlowMuonValidationPlots.h" // Forward declaration namespace Rec { - class IMuonPrintingTool; - } + class IMuonPrintingTool; +} namespace MuonPhysValMonitoring { class MuonPhysValMonitoringTool @@ -90,7 +93,8 @@ class MuonPhysValMonitoringTool /// Default constructor: MuonPhysValMonitoringTool(); - void handleMuon(const xAOD::Muon* mu); + void handleMuon(const xAOD::Muon* mu,const xAOD::SlowMuon *smu=0); + void handleSlowMuon(const xAOD::SlowMuon *smu); void handleTruthMuon(const xAOD::TruthParticle* truthMu); void handleMuonTrack(const xAOD::TrackParticle* tp, xAOD::Muon::TrackParticleType type); void handleMuonSegment(const xAOD::MuonSegment* muSeg); @@ -109,6 +113,7 @@ class MuonPhysValMonitoringTool StatusCode bookValidationPlots(PlotBase& valPlots); const xAOD::Muon* findRecoMuon(const xAOD::TruthParticle* truthMu); + const xAOD::SlowMuon* findRecoSlowMuon(const xAOD::TruthParticle* truthMu); const xAOD::MuonSegment* findRecoMuonSegment(const xAOD::MuonSegment* truthMuSeg); xAOD::Muon* getCorrectedMuon(const xAOD::Muon &mu); @@ -126,6 +131,7 @@ class MuonPhysValMonitoringTool std::string m_tracksName; std::string m_fwdtracksName; std::string m_muonsName; + std::string m_slowMuonsName; std::string m_muonsTruthName; std::string m_muonTracksName; std::string m_muonExtrapolatedTracksName; @@ -170,6 +176,7 @@ class MuonPhysValMonitoringTool std::vector<std::string> m_selectMuonCategoriesStr; MuonPhysValMonitoringTool::MUCATEGORY getMuonSegmentTruthCategory(const xAOD::MuonSegment* truthMuSeg, const xAOD::TruthParticleContainer* muonTruthContainer); MuonPhysValMonitoringTool::MUCATEGORY getMuonTruthCategory(const xAOD::IParticle* prt); + MuonPhysValMonitoringTool::MUCATEGORY getMuonTruthCategory(const xAOD::Muon* prt); bool passesAcceptanceCuts(const xAOD::IParticle* prt); float deltaR(const xAOD::IParticle* prt1, const xAOD::IParticle* prt2); void SplitString(TString x, TString delim, std::vector<TString> &v); @@ -189,6 +196,8 @@ class MuonPhysValMonitoringTool Muon::RecoMuonTrackPlotOrganizer* m_oUnmatchedRecoMuonTrackPlots; Muon::MuonSegmentPlots* m_oUnmatchedRecoMuonSegmentPlots; + std::vector<SlowMuonValidationPlots*> m_slowMuonValidationPlots; + //overview hists std::vector<TH1F*> h_overview_nObjects; TH1F* h_overview_reco_category; @@ -200,10 +209,10 @@ class MuonPhysValMonitoringTool std::vector<const xAOD::TruthParticle*> m_vMatchedTruthMuons; std::vector<const xAOD::Muon*> m_vMatchedMuons; + std::vector<const xAOD::SlowMuon*> m_vMatchedSlowMuons; std::vector<const xAOD::TrackParticle*> m_vMatchedMuonTracks; std::vector<const xAOD::MuonSegment*> m_vMatchedMuonSegments; std::vector<const xAOD::TrackParticle*> m_vZmumuIDTracks; - std::vector<const xAOD::TrackParticle*> m_vZmumuMSTracks; std::vector<const xAOD::TrackParticle*> m_vZmumuMETracks; std::vector<const xAOD::Muon*> m_vZmumuMuons; std::vector<const xAOD::Muon*> m_vEFMuons; diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/src/MuonValidationPlots.cxx b/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/src/MuonValidationPlots.cxx index 8bbe855b0e58c3533bb3ee37fc3a67e32e22a34d..aade7cd845c63d7e9d2fcb94d7e2e4269ec2e37d 100644 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/src/MuonValidationPlots.cxx +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/src/MuonValidationPlots.cxx @@ -8,9 +8,8 @@ typedef ElementLink< xAOD::TrackParticleContainer > TrackLink; typedef ElementLink< xAOD::MuonContainer > MuonLink; -MuonValidationPlots::MuonValidationPlots(PlotBase* pParent, std::string sDir,std::vector<int> wps,std::vector<unsigned int> authors, bool isData, bool doBinnedResolutionPlots, bool /*doMuonTree*/): - PlotBase(pParent, sDir), m_selectedWPs(wps), m_selectedAuthors(authors), m_truthSelections(2,""), m_oTruthRelatedMuonPlots(NULL), m_isData(isData) - +MuonValidationPlots::MuonValidationPlots(PlotBase* pParent, std::string sDir,std::vector<int> wps,std::vector<unsigned int> authors, bool isData, bool doBinnedResolutionPlots, bool doSeparateSAFMuons, bool /*doMuonTree*/): + PlotBase(pParent, sDir), m_selectedWPs(wps), m_selectedAuthors(authors), m_truthSelections(2,""), m_oTruthRelatedMuonPlots(NULL), m_isData(isData), m_doSeparateSAFMuons(doSeparateSAFMuons) { if (!m_isData) { m_truthSelections[0] = "all"; //no selection on truth muons (minimum selection is |eta|<2.5, pt>5 GeV, defined in MuonPhysValMonitoringTool::handleTruthMuon() @@ -48,13 +47,24 @@ MuonValidationPlots::MuonValidationPlots(PlotBase* pParent, std::string sDir,std //define a histogram class for each of the selected muon authors (+one inclusive for all authors) for (unsigned int i=0; i<m_selectedAuthors.size(); i++) { std::string sAuthor = Muon::EnumDefs::toString( (xAOD::Muon::Author) m_selectedAuthors[i] ); + if (sAuthor=="CaloTag") sAuthor="CaloTagTight"; m_oRecoMuonPlots_perAuthor.push_back(new Muon::RecoMuonPlotOrganizer(this, "reco/"+sAuthor, (sAuthor=="MuidCo")? &allPlotCategories: &selectedPlotCategories)); if (!m_isData) m_oTruthRelatedMuonPlots_perAuthor.push_back(new Muon::TruthRelatedMuonPlotOrganizer(this, "matched/"+sAuthor, doBinnedResolutionPlots)); } - //define histogram class for SiliconAssociatedForwardMuons - m_oRecoMuonPlots_SiAssocFwrdMu.push_back(new Muon::RecoMuonPlotOrganizer(this, "reco/SiAssocForward", &selectedPlotCategories)); - if (!m_isData) m_oTruthRelatedMuonPlots_SiAssocFwrdMu.push_back(new Muon::TruthRelatedMuonPlotOrganizer(this, "matched/SiAssocForward", doBinnedResolutionPlots)); + //define histogram class for loose CaloTag and append to author plots, not very nice workaround though + for (unsigned int i=0; i<m_selectedAuthors.size(); i++) { + if ((xAOD::Muon::Author) m_selectedAuthors[i]==xAOD::Muon::CaloTag){ //found CaloTag in list, also do CaloTagLoose + m_oRecoMuonPlots_perAuthor.push_back(new Muon::RecoMuonPlotOrganizer(this, "reco/CaloTagLoose", &selectedPlotCategories)); + if (!m_isData) m_oTruthRelatedMuonPlots_perAuthor.push_back(new Muon::TruthRelatedMuonPlotOrganizer(this, "matched/CaloTagLoose", doBinnedResolutionPlots)); + } + } + + //define histogram class for SiliconAssociatedForwardMuons + if (m_doSeparateSAFMuons) { + m_oRecoMuonPlots_SiAssocFwrdMu.push_back(new Muon::RecoMuonPlotOrganizer(this, "reco/SiAssocForward", &selectedPlotCategories)); + if (!m_isData) m_oTruthRelatedMuonPlots_SiAssocFwrdMu.push_back(new Muon::TruthRelatedMuonPlotOrganizer(this, "matched/SiAssocForward", doBinnedResolutionPlots)); + } } @@ -122,14 +132,19 @@ void MuonValidationPlots::fillRecoMuonPlots(const xAOD::Muon& mu) if (ipar<11) continue; } - //filter SiliconAssociatedForwardMuons - if (mu.muonType()!=(xAOD::Muon::MuonType) xAOD::Muon::SiliconAssociatedForwardMuon) m_oRecoMuonPlots_perAuthor[i]->fill(mu); + //filter SiliconAssociatedForwardMuons + if (mu.muonType()!=(xAOD::Muon::MuonType)xAOD::Muon::SiliconAssociatedForwardMuon || !m_doSeparateSAFMuons) m_oRecoMuonPlots_perAuthor[i]->fill(mu); } } //fill SiliconAssociatedForwardMuons for (unsigned int i=0; i<m_oTruthRelatedMuonPlots_SiAssocFwrdMu.size();i++){ if (mu.muonType()==(xAOD::Muon::MuonType) xAOD::Muon::SiliconAssociatedForwardMuon) m_oRecoMuonPlots_SiAssocFwrdMu[i]->fill(mu); } + //fill CaloTagLoose (one additional plot in plot list) + unsigned int counter= m_selectedAuthors.size(); + if ( counter+1==m_oRecoMuonPlots_perAuthor.size()){ + if (mu.isAuthor(xAOD::Muon::CaloTag)) m_oRecoMuonPlots_perAuthor[counter]->fill(mu); + } } void MuonValidationPlots::fillTruthMuonPlots(const xAOD::TruthParticle &truthMu) @@ -160,7 +175,7 @@ void MuonValidationPlots::fill(const xAOD::TruthParticle* truthMu, const xAOD::M m_oTruthRelatedMuonPlots->fill(*truthMu, *mu, MSTracks); //fill SiliconAssociatedForwardMuons for (unsigned int i=0; i<m_oTruthRelatedMuonPlots_SiAssocFwrdMu.size();i++){ - if (mu->muonType()==xAOD::Muon::SiliconAssociatedForwardMuon) m_oTruthRelatedMuonPlots_SiAssocFwrdMu[i]->fill(*truthMu, *mu, MSTracks); + if (mu->muonType()==xAOD::Muon::SiliconAssociatedForwardMuon || !m_doSeparateSAFMuons) m_oTruthRelatedMuonPlots_SiAssocFwrdMu[i]->fill(*truthMu, *mu, MSTracks); } //plots per quality @@ -179,9 +194,14 @@ void MuonValidationPlots::fill(const xAOD::TruthParticle* truthMu, const xAOD::M if (ipar<11) continue; } //filter SilicionAssociatedForwardMuons - if (mu->muonType()!=xAOD::Muon::SiliconAssociatedForwardMuon) m_oTruthRelatedMuonPlots_perAuthor[i]->fill(*truthMu, *mu, MSTracks); + if (mu->muonType()!=xAOD::Muon::SiliconAssociatedForwardMuon || !m_doSeparateSAFMuons) m_oTruthRelatedMuonPlots_perAuthor[i]->fill(*truthMu, *mu, MSTracks); } - } + } + //fill CaloTagLoose (one additional plot in plot list) + unsigned int counter= m_selectedAuthors.size(); + if ( counter+1==m_oRecoMuonPlots_perAuthor.size()){ + if (mu->isAuthor(xAOD::Muon::CaloTag)) m_oTruthRelatedMuonPlots_perAuthor[counter]->fill(*truthMu, *mu, MSTracks); + } } } diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/src/MuonValidationPlots.h b/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/src/MuonValidationPlots.h index fd0f2af127b4a41e6a0e3111d8e5f423e3d1a5b8..b35c2ecc86048911a5dcdcaa9d9dfdfd0803df82 100644 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/src/MuonValidationPlots.h +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/src/MuonValidationPlots.h @@ -15,7 +15,7 @@ class MuonValidationPlots:public PlotBase { public: - MuonValidationPlots(PlotBase* pParent, std::string sDir, std::vector<int> wps, std::vector<unsigned int> authors, bool isData, bool doBinnedResolutionPlots, bool doMuonTree=false ); + MuonValidationPlots(PlotBase* pParent, std::string sDir, std::vector<int> wps, std::vector<unsigned int> authors, bool isData, bool doBinnedResolutionPlots, bool doSplitSAFMuons, bool doMuonTree=false ); virtual ~MuonValidationPlots(); void fill(const xAOD::Muon& mu); @@ -43,7 +43,7 @@ class MuonValidationPlots:public PlotBase { void fillTruthMuonPlots(const xAOD::TruthParticle &truthMu); bool m_isData; - + bool m_doSeparateSAFMuons; }; #endif diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/src/SlowMuonValidationPlots.cxx b/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/src/SlowMuonValidationPlots.cxx new file mode 100644 index 0000000000000000000000000000000000000000..7fd4222a66196a21df4fb04c93436bff0d8ce550 --- /dev/null +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/src/SlowMuonValidationPlots.cxx @@ -0,0 +1,48 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "SlowMuonValidationPlots.h" +#include "MuonHistUtils/MuonEnumDefs.h" + +#include <iostream> + +typedef ElementLink< xAOD::MuonContainer > MuonLink; + +SlowMuonValidationPlots::SlowMuonValidationPlots(PlotBase* pParent, std::string sDir, bool isData): + PlotBase(pParent, sDir), m_isData(isData) +{ + //histogram classes for all muons + m_oSlowMuonRecoPlots = new Muon::SlowMuonParamPlots(this, "reco/AllMuons/parameters/"); + if (!m_isData) m_oSlowMuonMatchedPlots = new Muon::SlowMuonParamPlots(this, "matched/AllMuons/parameters/"); +} + +SlowMuonValidationPlots::~SlowMuonValidationPlots() +{ + delete m_oSlowMuonRecoPlots; + m_oSlowMuonRecoPlots = 0; + + if (!m_isData) { + delete m_oSlowMuonMatchedPlots; + m_oSlowMuonMatchedPlots = 0; + } +} + +void SlowMuonValidationPlots::fill(const xAOD::SlowMuon& smu, const xAOD::Muon& mu) +{ + fillRecoMuonPlots(smu,mu); +} +void SlowMuonValidationPlots::fill( const xAOD::TruthParticle* truthMu, const xAOD::SlowMuon* smu, const xAOD::Muon* mu ) +{ + if (smu) fillRecoMuonPlots(*smu,*mu); + if ( (smu) && (truthMu) ) { + m_oSlowMuonMatchedPlots->fill(*smu); + } +} + +void SlowMuonValidationPlots::fillRecoMuonPlots(const xAOD::SlowMuon& smu, const xAOD::Muon& /*mu*/) +{ + //fill hists for all muons + m_oSlowMuonRecoPlots->fill(smu); +} + diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/src/SlowMuonValidationPlots.h b/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/src/SlowMuonValidationPlots.h new file mode 100644 index 0000000000000000000000000000000000000000..79680b26a210705baf9b05a47950d3825f0c7836 --- /dev/null +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonPhysValMonitoring/src/SlowMuonValidationPlots.h @@ -0,0 +1,32 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef MUONPHYSVALMONITORING_SLOWMUONVALIDATIONPLOTS_H +#define MUONPHYSVALMONITORING_SLOWMUONVALIDATIONPLOTS_H + +#include "xAODTruth/TruthParticle.h" +#include "xAODMuon/SlowMuon.h" +#include "MuonHistUtils/SlowMuonParamPlots.h" + +class SlowMuonValidationPlots:public PlotBase +{ + public: + SlowMuonValidationPlots(PlotBase* pParent, std::string sDir, bool isData); + + virtual ~SlowMuonValidationPlots(); + void fill(const xAOD::SlowMuon& smu, const xAOD::Muon& mu); + void fill(const xAOD::TruthParticle *truthMu, const xAOD::SlowMuon *smu, const xAOD::Muon* mu); + + Muon::SlowMuonParamPlots* m_oSlowMuonRecoPlots; + Muon::SlowMuonParamPlots* m_oSlowMuonMatchedPlots; + + private: + void fillRecoMuonPlots(const xAOD::SlowMuon& smu, const xAOD::Muon& mu); + void fillMatchedMuonPlots(const xAOD::SlowMuon& smu, const xAOD::Muon& mu); + + bool m_isData; + +}; + +#endif diff --git a/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/MuonHistUtils/MuonParamElossPlots.h b/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/MuonHistUtils/MuonParamElossPlots.h new file mode 100644 index 0000000000000000000000000000000000000000..6d9ebd0951f036e4edd2a63468722652515c89f4 --- /dev/null +++ b/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/MuonHistUtils/MuonParamElossPlots.h @@ -0,0 +1,58 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef MUONHISTUTILS_MUONPARAMELOSSPLOTS_H +#define MUONHISTUTILS_MUONPARAMELOSSPLOTS_H + +#include "TrkValHistUtils/PlotBase.h" +#include "xAODMuon/Muon.h" +#include "xAODTruth/TruthParticle.h" +#include <string> + +namespace Muon{ + +class MuonParamElossPlots: public PlotBase +{ + public: + MuonParamElossPlots(PlotBase *pParent, std::string sDir); + void fill(const xAOD::TruthParticle& truthMu, const xAOD::Muon& mu); + + TH1* msInnerMatchChi2; + TH1* msOuterMatchChi2; + + TH1* ELoss; + TH1* ELossDiffTruth; + TH1* ELossDiffTruthEta0_1p35; + TH1* ELossDiffTruthEta1p35_1p55; + TH1* ELossDiffTruthEta1p55_end; + TH1* ELossSigma; + TH1* paramELoss; + TH1* paramELossDiff; + TH1* paramELossDiffTruth; + TH1* paramELossDiffTruthEta0_1p35; + TH1* paramELossDiffTruthEta1p35_1p55; + TH1* paramELossDiffTruthEta1p55_end; + TH1* measELoss; + TH1* measELossDiff; + TH1* measELossDiffTruth; + TH1* measELossDiffTruthEta0_1p35; + TH1* measELossDiffTruthEta1p35_1p55; + TH1* measELossDiffTruthEta1p55_end; + TH1* ELossType; + TH1* ELossTypeParametrPt; + TH1* ELossTypeNotIsoPt; + TH1* ELossTypeTailPt; + TH1* ELossTypeAllPt; + + private: + void initializePlots(); + void FillPlot(TH1* hist, const xAOD::Muon& mu,const xAOD::Muon::ParamDef paramDef,float scale=1); + void FillPlot(TH1* hist, TH1* hist_DiffTruth, TH1* hist_DiffTruthEta0_1p35, TH1* hist_DiffTruthEta1p35_1p55, TH1* hist_DiffTruthEta1p55_endd, const xAOD::TruthParticle& truthMu, const xAOD::Muon& mu, const xAOD::Muon::ParamDef paramDef,float scale=1); + void FillPlotELossType(TH1* hist, const xAOD::Muon& mu,float scale=1); + void FillPlotELossType(TH1* hist, const xAOD::Muon& mu, xAOD::Muon::EnergyLossType type, float scale=1); +}; + +} + +#endif diff --git a/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/MuonHistUtils/MuonTruthHitPlots.h b/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/MuonHistUtils/MuonTruthHitPlots.h new file mode 100644 index 0000000000000000000000000000000000000000..5e33592b8374b98e4587a3ed3b2783f445f4f553 --- /dev/null +++ b/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/MuonHistUtils/MuonTruthHitPlots.h @@ -0,0 +1,66 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef MUONHISTUTILS_MUONTRUTHHITPLOTS_H +#define MUONHISTUTILS_MUONTRUTHHITPLOTS_H + +#include "TrkValHistUtils/PlotBase.h" +#include "xAODMuon/Muon.h" + +namespace Muon{ + +class MuonTruthHitPlots:public PlotBase { + public: + MuonTruthHitPlots(PlotBase* pParent, std::string sDir); + void fill(const xAOD::Muon& muon); + void fillPlot(TH1* hitPlots, const std::string& sInfo, const Muon::MuonStationIndex::ChIndex& index, const xAOD::Muon& muon); + void fillPlot(TH1* hitPlots, const std::string& sInfo, const Muon::MuonStationIndex::PhiIndex& index, const xAOD::Muon& muon); + void fillPlot(TH1* hitPlots, const std::string& sInfo, const xAOD::Muon& muon); + + TH1* precMatchedHitsSummed; + TH1* precMatchedHitsBIS; + TH1* precMatchedHitsBIL; + TH1* precMatchedHitsBMS; + TH1* precMatchedHitsBML; + TH1* precMatchedHitsBOS; + TH1* precMatchedHitsBOL; + TH1* precMatchedHitsBEE; + TH1* precMatchedHitsEIS; + TH1* precMatchedHitsEIL; + TH1* precMatchedHitsEMS; + TH1* precMatchedHitsEML; + TH1* precMatchedHitsEOS; + TH1* precMatchedHitsEOL; + TH1* precMatchedHitsEES; + TH1* precMatchedHitsEEL; + TH1* precMatchedHitsCSS; + TH1* precMatchedHitsCSL; + + TH1* phiMatchedHitsSummed; + TH1* phiMatchedHitsBM1; + TH1* phiMatchedHitsBM2; + TH1* phiMatchedHitsBO1; + TH1* phiMatchedHitsBO2; + TH1* phiMatchedHitsT1; + TH1* phiMatchedHitsT2; + TH1* phiMatchedHitsT3; + TH1* phiMatchedHitsT4; + TH1* phiMatchedHitsCSC; + + TH1* trigEtaMatchedHitsSummed; + TH1* trigEtaMatchedHitsBM1; + TH1* trigEtaMatchedHitsBM2; + TH1* trigEtaMatchedHitsBO1; + TH1* trigEtaMatchedHitsBO2; + TH1* trigEtaMatchedHitsT1; + TH1* trigEtaMatchedHitsT2; + TH1* trigEtaMatchedHitsT3; + TH1* trigEtaMatchedHitsT4; + // TH1* trigEtaMatchedHitsCSC; + + +}; +} + +#endif diff --git a/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/MuonHistUtils/SlowMuonParamPlots.h b/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/MuonHistUtils/SlowMuonParamPlots.h new file mode 100644 index 0000000000000000000000000000000000000000..978d9ed8585c78635f59f590478f200871ba1be8 --- /dev/null +++ b/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/MuonHistUtils/SlowMuonParamPlots.h @@ -0,0 +1,29 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef MUONHISTUTILS_SLOWMUONPARAMPLOTS_H +#define MUONHISTUTILS_SLOWMUONPARAMPLOTS_H + +#include "TrkValHistUtils/PlotBase.h" + +#include "xAODMuon/SlowMuon.h" + +namespace Muon{ + +class SlowMuonParamPlots: public PlotBase { + public: + SlowMuonParamPlots(PlotBase *pParent, std::string sDir); + + void fill(const xAOD::SlowMuon& smu); + + TH1* beta; + + private: + void initializePlots(); + +}; + +} + +#endif diff --git a/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/MuonHistUtils/TruthRelatedMuonPlotOrganizer.h b/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/MuonHistUtils/TruthRelatedMuonPlotOrganizer.h index 36a806310365c80ed2c364c6ae752c1b59f4e70c..132b7f678fb4df91b2ea9dfdffddfe9e73ea1d12 100644 --- a/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/MuonHistUtils/TruthRelatedMuonPlotOrganizer.h +++ b/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/MuonHistUtils/TruthRelatedMuonPlotOrganizer.h @@ -11,7 +11,9 @@ #include "MuonHistUtils/MuonHitDiffSummaryPlots.h" #include "MuonHistUtils/MuonResolutionPlots.h" #include "MuonHistUtils/MomentumTruthPullPlots.h" +#include "MuonHistUtils/MuonParamElossPlots.h" #include "MuonHistUtils/MuonTree.h" +#include "MuonHistUtils/MuonTruthHitPlots.h" #include "TrkValHistUtils/DefParamPullPlots.h" #include "xAODMuon/Muon.h" @@ -20,7 +22,7 @@ namespace Muon { - enum TRUTHRELATEDPLOTCLASS {TRK_MATCHEDTRUE,TRK_MATCHEDRECO,TRK_MSHITDIFF,MUON_HITDIFF,MUON_RESOL,TRK_DEFPARAMPULLS,MUON_PULLSTAIL,MUON_PULLSNOTAIL,MAX_TRUTHRELATEDPLOTCLASS}; + enum TRUTHRELATEDPLOTCLASS {TRK_MATCHEDTRUE,TRK_MATCHEDRECO,TRK_MSHITDIFF,MUON_HITDIFF,MUON_TRUTHHIT,MUON_RESOL,TRK_DEFPARAMPULLS,MUON_PULLSTAIL,MUON_PULLSNOTAIL,MUON_PARAMELOSS,MAX_TRUTHRELATEDPLOTCLASS}; class TruthRelatedMuonPlotOrganizer:public PlotBase { public: @@ -39,10 +41,12 @@ namespace Muon Trk::ParamPlots *m_oMatchedRecoPlots; Trk::MSHitDiffPlots *m_oMSHitDiffPlots; Muon::MuonHitDiffSummaryPlots *m_oMuonHitDiffSummaryPlots; + Muon::MuonTruthHitPlots *m_oMuonTruthHitPlots; Muon::MuonResolutionPlots *m_oMuonResolutionPlots; Trk::DefParamPullPlots *m_oDefParamPullPlots; Muon::MomentumTruthPullPlots *m_oMomentumTruthPullPlots_Tail; Muon::MomentumTruthPullPlots *m_oMomentumTruthPullPlots_NoTail; + Muon::MuonParamElossPlots *m_oMatchedRecoElossPlots; }; diff --git a/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/Root/MuonHitSummaryPlots.cxx b/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/Root/MuonHitSummaryPlots.cxx index c97b0b9cde562461bb5729b1f992c375679cd215..2a741586328f53b961cfaca0abb9ff61c3602620 100644 --- a/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/Root/MuonHitSummaryPlots.cxx +++ b/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/Root/MuonHitSummaryPlots.cxx @@ -88,21 +88,21 @@ void MuonHitSummaryPlots::fill(const xAOD::Muon& muon){ fillPlot(extendedSmallHoles, xAOD::extendedSmallHoles, muon); fillPlot(extendedLargeHoles, xAOD::extendedLargeHoles, muon); - // int netaholes=0, nphiholes=0; - // uint8_t hitval = 0; - // if (muon.summaryValue(hitval,xAOD::etaLayer1Holes)) netaholes+=(int)hitval; - // if (muon.summaryValue(hitval,xAOD::etaLayer2Holes)) netaholes+=(int)hitval; - // if (muon.summaryValue(hitval,xAOD::etaLayer3Holes)) netaholes+=(int)hitval; - // if (muon.summaryValue(hitval,xAOD::etaLayer4Holes)) netaholes+=(int)hitval; - - // if (muon.summaryValue(hitval,xAOD::phiLayer1Holes)) nphiholes+=(int)hitval; - // if (muon.summaryValue(hitval,xAOD::phiLayer2Holes)) nphiholes+=(int)hitval; - // if (muon.summaryValue(hitval,xAOD::phiLayer3Holes)) nphiholes+=(int)hitval; - // if (muon.summaryValue(hitval,xAOD::phiLayer4Holes)) nphiholes+=(int)hitval; - - // etaHoles.fill(netaholes, muon.eta(), muon.phi()); - // phiHoles.fill(nphiholes, muon.eta(), muon.phi()); - // etaphiHoles.fill(netaholes+nphiholes, muon.eta(), muon.phi()); + int netaholes=0, nphiholes=0; + uint8_t hitval = 0; + if (muon.summaryValue(hitval,xAOD::etaLayer1Holes)) netaholes+=(int)hitval; + if (muon.summaryValue(hitval,xAOD::etaLayer2Holes)) netaholes+=(int)hitval; + if (muon.summaryValue(hitval,xAOD::etaLayer3Holes)) netaholes+=(int)hitval; + if (muon.summaryValue(hitval,xAOD::etaLayer4Holes)) netaholes+=(int)hitval; + + if (muon.summaryValue(hitval,xAOD::phiLayer1Holes)) nphiholes+=(int)hitval; + if (muon.summaryValue(hitval,xAOD::phiLayer2Holes)) nphiholes+=(int)hitval; + if (muon.summaryValue(hitval,xAOD::phiLayer3Holes)) nphiholes+=(int)hitval; + if (muon.summaryValue(hitval,xAOD::phiLayer4Holes)) nphiholes+=(int)hitval; + + etaHoles.fill(netaholes, muon.eta(), muon.phi()); + phiHoles.fill(nphiholes, muon.eta(), muon.phi()); + etaphiHoles.fill(netaholes+nphiholes, muon.eta(), muon.phi()); // fillPlot(phiLayer1Holes, xAOD::phiLayer1Holes, muon); // fillPlot(phiLayer2Holes, xAOD::phiLayer2Holes, muon); diff --git a/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/Root/MuonParamElossPlots.cxx b/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/Root/MuonParamElossPlots.cxx new file mode 100644 index 0000000000000000000000000000000000000000..58c95964d33f56998d7eb4421be32aa9d2354315 --- /dev/null +++ b/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/Root/MuonParamElossPlots.cxx @@ -0,0 +1,163 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "MuonHistUtils/MuonParamElossPlots.h" +#include "xAODTracking/TrackingPrimitives.h" + +namespace Muon{ + +MuonParamElossPlots::MuonParamElossPlots(PlotBase *pParent, std::string sDir):PlotBase(pParent, sDir) + ,msInnerMatchChi2(NULL) + ,msOuterMatchChi2(NULL) + ,ELoss(NULL) + ,ELossDiffTruth(NULL) + ,ELossDiffTruthEta0_1p35(NULL) + ,ELossDiffTruthEta1p35_1p55(NULL) + ,ELossDiffTruthEta1p55_end(NULL) + ,ELossSigma(NULL) + ,paramELoss(NULL) + ,paramELossDiff(NULL) + ,paramELossDiffTruth(NULL) + ,paramELossDiffTruthEta0_1p35(NULL) + ,paramELossDiffTruthEta1p35_1p55(NULL) + ,paramELossDiffTruthEta1p55_end(NULL) + ,measELoss(NULL) + ,measELossDiff(NULL) + ,measELossDiffTruth(NULL) + ,measELossDiffTruthEta0_1p35(NULL) + ,measELossDiffTruthEta1p35_1p55(NULL) + ,measELossDiffTruthEta1p55_end(NULL) + ,ELossType(NULL) + ,ELossTypeParametrPt(NULL) + ,ELossTypeNotIsoPt(NULL) + ,ELossTypeTailPt(NULL) + ,ELossTypeAllPt(NULL) +{} + +void MuonParamElossPlots::initializePlots() +{ + msInnerMatchChi2 = Book1D("msInnerMatchChi2","inner match #chi^{2};inner match #chi^{2};;Entries",100,0.,100.); + msOuterMatchChi2 = Book1D("msOuterMatchChi2","outer match #chi^{2};outer match #chi^{2};;Entries",100,0.,100.); + + ELoss = Book1D("ELoss","ELoss;ELoss [GeV];Entries",50,0,10); + ELossDiffTruth = Book1D("ELossDiffTruth","Difference ELoss to truth ELoss);#Delta(fitted - truth) [GeV];Entries",100,-10.,10.); + ELossDiffTruthEta0_1p35 = Book1D("ELossDiffTruthEta0_1p35","Difference ELoss to truth ELoss for 0<|#eta|<1.35;#Delta(fitted - truth) [GeV];Entries",100,-10.,10.); + ELossDiffTruthEta1p35_1p55 = Book1D("ELossDiffTruthEta1p35_1p55","Difference ELoss to truth ELoss for 1.35<|#eta|<1.55;#Delta(fitted - truth) [GeV];Entries",100,-10.,10.); + ELossDiffTruthEta1p55_end = Book1D("ELossDiffTruthEta1p55_end","Difference ELoss to truth ELoss for 1.55<|#eta|;#Delta(fitted - truth) [GeV];Entries",100,-10.,10.); + ELossSigma = Book1D("ELossSigma","ELossSigma;ELossSgima [GeV];Entries",50,0,5); + + paramELoss = Book1D("paramELoss","paramELoss;paramELoss [GeV];Entries",50,0,10); + paramELossDiff = Book1D("paramELossDiff","Difference paramELoss to fitted ELoss;#Delta(param-fitted) [GeV];Entries",100,-3.,1.); + paramELossDiffTruth = Book1D("paramELossDiffTruth","Difference paramELoss to truth ELoss;#Delta(param-truth) [GeV];Entries",100,-10.,10.); + paramELossDiffTruthEta0_1p35 = Book1D("paramELossDiffTruthEta0_1p35","Difference paramELoss to truth ELoss for 0<|#eta|<1.35;#Delta(param-truth) [GeV];Entries",100,-10.,10.); + paramELossDiffTruthEta1p35_1p55 = Book1D("paramELossDiffTruthEta1p35_1p55","Difference paramELoss to truth ELoss for 1.35<|#eta|<1.55;#Delta(param-truth) [GeV];Entries",100,-10.,10.); + paramELossDiffTruthEta1p55_end = Book1D("paramELossDiffTruthhEta1p55_end","Difference paramELoss to truth ELoss for 1.55<|#eta|;#Delta(param-truth) [GeV];Entries",100,-10.,10.); + + measELoss = Book1D("measELoss","measELoss;measELoss [GeV];Entries",50,0,10); + measELossDiff = Book1D("measELossDiff","Difference measELoss to fitted ELoss);#Delta(meas- fitted) [GeV];Entries",100,-3.,1.); + measELossDiffTruth = Book1D("measELossDiffTruth","Difference measELoss to truth ELoss);#Delta(meas- truth) [GeV];Entries",100,-10.,10.); + measELossDiffTruthEta0_1p35 = Book1D("measELossDiffTruthEta0_1p35","Difference measELoss to truth ELoss for 0<|#eta|<1.35;#Delta(meas- truth) [GeV];Entries",100,-10.,10.); + measELossDiffTruthEta1p35_1p55 = Book1D("measELossDiffTruthEta1p35_1p55","Difference measELoss to truth ELoss for 1.35<|#eta|<1.55;#Delta(meas- truth) [GeV];Entries",100,-10.,10.); + measELossDiffTruthEta1p55_end = Book1D("measELossDiffTruthEta1p55_end","Difference measELoss to truth ELoss for 1.55<|#eta|;#Delta(meas- truth) [GeV];Entries",100,-10.,10.); + + ELossType = Book1D("ELossType","ELossType;Type;Entries",5,-0.5,4.5); + ELossTypeParametrPt = Book1D("ELossTypeParametrPt","ELossType:Parametrized Pt;Pt [GeV];Entries",50,0,500); + ELossTypeNotIsoPt = Book1D("ELossTypeNotIsoPt","ELossType:NotIsolated Pt;Pt [GeV];Entries",50,0,500); + ELossTypeTailPt = Book1D("ELossTypeTailPt","ELossType:Tail Pt;Pt [GeV];Entries",50,0,500); + ELossTypeAllPt = Book1D("ELossTypeAllPt","All ELossTypes Pt;Pt [GeV];Entries",50,0,500); +} + + void MuonParamElossPlots::fill(const xAOD::TruthParticle& truthmu, const xAOD::Muon& mu) +{ + FillPlot(msInnerMatchChi2,mu,xAOD::Muon::msInnerMatchChi2); + FillPlot(msOuterMatchChi2,mu,xAOD::Muon::msOuterMatchChi2); +#ifndef XAOD_ANALYSIS + FillPlot(ELoss,ELossDiffTruth,ELossDiffTruthEta0_1p35,ELossDiffTruthEta1p35_1p55,ELossDiffTruthEta1p55_end,truthmu,mu,xAOD::Muon::EnergyLoss,0.001); + FillPlot(measELoss,measELossDiffTruth,measELossDiffTruthEta0_1p35,measELossDiffTruthEta1p35_1p55,measELossDiffTruthEta1p55_end,truthmu,mu,xAOD::Muon::MeasEnergyLoss,0.001); + FillPlot(ELossSigma,mu,xAOD::Muon::EnergyLossSigma,0.001); + FillPlot(paramELoss,paramELossDiffTruth,paramELossDiffTruthEta0_1p35,paramELossDiffTruthEta1p35_1p55,paramELossDiffTruthEta1p55_end,truthmu,mu,xAOD::Muon::ParamEnergyLoss,0.001); + FillPlotELossType(ELossType,mu,0.001); + FillPlotELossType(ELossTypeNotIsoPt,mu,xAOD::Muon::NotIsolated,0.001); + FillPlotELossType(ELossTypeParametrPt,mu,xAOD::Muon::Parametrized,0.001); + FillPlotELossType(ELossTypeTailPt,mu,xAOD::Muon::Tail,0.001); +#endif // not XAOD_ANALYSIS +} + void MuonParamElossPlots::FillPlot(TH1* hist, const xAOD::Muon& mu,const xAOD::Muon::ParamDef paramDef,float scale) { + if (mu.author()==xAOD::Muon::CaloTag || mu.author()==xAOD::Muon::CaloLikelihood || mu.author()==xAOD::Muon::ExtrapolateMuonToIP) return; //protection + float fpar = 0; + if (mu.isAvailable<float>("EnergyLoss")) { + if (mu.parameter(fpar, paramDef)) + hist->Fill(scale*fpar); //scale to GeV, if needed + } + return; +} + void MuonParamElossPlots::FillPlot(TH1* hist, TH1* hist_DiffTruth, TH1* hist_DiffTruthEta0_1p35, TH1* hist_DiffTruthEta1p35_1p55, TH1* hist_DiffTruthEta1p55_end, const xAOD::TruthParticle& truthprt, const xAOD::Muon& mu,const xAOD::Muon::ParamDef paramDef,float scale) { + if (mu.author()==xAOD::Muon::CaloTag || mu.author()==xAOD::Muon::CaloLikelihood || mu.author()==xAOD::Muon::ExtrapolateMuonToIP) return; //protection + float fpar = 0; + if (mu.isAvailable<float>("EnergyLoss")) { + if (mu.parameter(fpar, paramDef)) + hist->Fill(scale*fpar); //scale to GeV, if needed + + //get true energy loss + if (/*!truthprt.isAvailable<float>("CaloEntryLayer_px") || + !truthprt.isAvailable<float>("CaloEntryLayer_py") || + !truthprt.isAvailable<float>("CaloEntryLayer_pz") ||*/ + !truthprt.isAvailable<float>("px") || + !truthprt.isAvailable<float>("py") || + !truthprt.isAvailable<float>("pz") || + !truthprt.isAvailable<float>("MuonEntryLayer_px") || + !truthprt.isAvailable<float>("MuonEntryLayer_py") || + !truthprt.isAvailable<float>("MuonEntryLayer_pz")) return; + + //workaround for missing caloentry + TVector3 vecCaloEntry(truthprt.auxdata<float>("px"), + truthprt.auxdata<float>("py"), + truthprt.auxdata<float>("pz")); + + /* TVector3 vecCaloEntry(truthprt.auxdata<float>("CaloEntryLayer_px"), + truthprt.auxdata<float>("CaloEntryLayer_py"), + truthprt.auxdata<float>("CaloEntryLayer_pz"));*/ + + TVector3 vecMuonExit(truthprt.auxdata<float>("MuonEntryLayer_px"), + truthprt.auxdata<float>("MuonEntryLayer_py"), + truthprt.auxdata<float>("MuonEntryLayer_pz")); + float dpTruth=vecCaloEntry.Mag()-vecMuonExit.Mag(); + hist_DiffTruth->Fill(scale*(fpar-dpTruth)); //scale to GeV, if needed + //again in eta ranges + if (fabs(mu.eta())<1.35) hist_DiffTruthEta0_1p35->Fill(scale*(fpar-dpTruth)); + else { + if (fabs(mu.eta())<1.55) hist_DiffTruthEta1p35_1p55->Fill(scale*(fpar-dpTruth)); + else hist_DiffTruthEta1p55_end->Fill(scale*(fpar-dpTruth)); + } + } + return; +} + void MuonParamElossPlots::FillPlotELossType(TH1* hist, const xAOD::Muon& mu, float scale) { + if (mu.author()==xAOD::Muon::CaloTag || mu.author()==xAOD::Muon::CaloLikelihood || mu.author()==xAOD::Muon::ExtrapolateMuonToIP) return; //protection + if (mu.isAvailable<float>("EnergyLoss")) { + hist->Fill(mu.energyLossType()); + ELossTypeAllPt->Fill(mu.pt()*scale); + float used=0; + float meas=-100000; + float param=-100000; + if (mu.parameter(used, xAOD::Muon::EnergyLoss) && mu.parameter(param, xAOD::Muon::ParamEnergyLoss) && mu.parameter(meas, xAOD::Muon::MeasEnergyLoss ) ){ + //fill diff plots + if (mu.energyLossType()==xAOD::Muon::Parametrized){ + paramELossDiff->Fill((param-used)*scale); + } + if (mu.energyLossType()==xAOD::Muon::Tail){ + measELossDiff->Fill((meas-used)*scale); + } + } + } + return; +} +void MuonParamElossPlots::FillPlotELossType(TH1* hist, const xAOD::Muon& mu, const xAOD::Muon::EnergyLossType type, float scale) { + if (mu.author()==xAOD::Muon::CaloTag || mu.author()==xAOD::Muon::CaloLikelihood || mu.author()==xAOD::Muon::ExtrapolateMuonToIP) return; //protection + if (mu.isAvailable<float>("EnergyLoss")) { + if (mu.energyLossType()==type) hist->Fill(mu.pt()*scale); //scale to GeV, if needed + } + return; +} +}//namespace Muon diff --git a/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/Root/MuonParamPlots.cxx b/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/Root/MuonParamPlots.cxx index 1aea0c8f3ffc03fb868f32bc8593458cc31729ec..230211a0031aed06ae6b2b45298b2b11fac08def 100644 --- a/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/Root/MuonParamPlots.cxx +++ b/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/Root/MuonParamPlots.cxx @@ -21,11 +21,11 @@ void MuonParamPlots::initializePlots() msInnerMatchChi2 = Book1D("msInnerMatchChi2","inner match #chi^{2};inner match #chi^{2};;Entries",100,0.,100.); msOuterMatchChi2 = Book1D("msOuterMatchChi2","outer match #chi^{2};outer match #chi^{2};;Entries",100,0.,100.); - ELoss = Book1D("ELoss","ELoss;ELoss [GeV];Entries",50,0,10); + ELoss = Book1D("ELoss","ELoss;ELoss [GeV];Entries",100,0,20); ELossSigma = Book1D("ELossSigma","ELossSigma;ELossSgima [GeV];Entries",50,0,5); paramELoss = Book1D("paramELoss","paramELoss;paramELoss [GeV];Entries",50,0,10); - measELoss = Book1D("measELoss","measELoss;measELoss [GeV];Entries",50,0,10); + measELoss = Book1D("measELoss","measELoss;measELoss [GeV];Entries",100,0,20); } diff --git a/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/Root/MuonTruthHitPlots.cxx b/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/Root/MuonTruthHitPlots.cxx new file mode 100644 index 0000000000000000000000000000000000000000..7aa3ed6d3c01773a294c47dc294dd96dd624d9d7 --- /dev/null +++ b/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/Root/MuonTruthHitPlots.cxx @@ -0,0 +1,132 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "MuonHistUtils/MuonTruthHitPlots.h" + +namespace Muon{ + +MuonTruthHitPlots::MuonTruthHitPlots(PlotBase* pParent, std::string sDir): +PlotBase(pParent, sDir) + +{ + precMatchedHitsSummed=Book1D("precMatchedHitsSummed","summed precision hits matched to truth (all chambers)",21,-0.5,20.5); + precMatchedHitsBIS=Book1D("precMatchedHitsBIS","BIS precision hits matched to truth;matched hits;entries",21,-0.5,20.5); + precMatchedHitsBIL=Book1D("precMatchedHitsBIL","BIL precision hits matched to truth;matched hits;entries",21,-0.5,20.5); + precMatchedHitsBMS=Book1D("precMatchedHitsBMS","BMS precision hits matched to truth;matched hits;entries",21,-0.5,20.5); + precMatchedHitsBML=Book1D("precMatchedHitsBML","BML precision hits matched to truth;matched hits;entries",21,-0.5,20.5); + precMatchedHitsBOS=Book1D("precMatchedHitsBOS","BOS precision hits matched to truth;matched hits;entries",21,-0.5,20.5); + precMatchedHitsBOL=Book1D("precMatchedHitsBOL","BOL precision hits matched to truth;matched hits;entries",21,-0.5,20.5); + precMatchedHitsBEE=Book1D("precMatchedHitsBEE","BEE precision hits matched to truth;matched hits;entries",21,-0.5,20.5); + precMatchedHitsEIS=Book1D("precMatchedHitsEIS","EIS precision hits matched to truth;matched hits;entries",21,-0.5,20.5); + precMatchedHitsEIL=Book1D("precMatchedHitsEIL","EIL precision hits matched to truth;matched hits;entries",21,-0.5,20.5); + precMatchedHitsEMS=Book1D("precMatchedHitsEMS","EMS precision hits matched to truth;matched hits;entries",21,-0.5,20.5); + precMatchedHitsEML=Book1D("precMatchedHitsEML","EML precision hits matched to truth;matched hits;entries",21,-0.5,20.5); + precMatchedHitsEOS=Book1D("precMatchedHitsEOS","EOS precision hits matched to truth;matched hits;entries",21,-0.5,20.5); + precMatchedHitsEOL=Book1D("precMatchedHitsEOL","EOL precision hits matched to truth;matched hits;entries",21,-0.5,20.5); + precMatchedHitsEES=Book1D("precMatchedHitsEES","EES precision hits matched to truth;matched hits;entries",21,-0.5,20.5); + precMatchedHitsEEL=Book1D("precMatchedHitsEEL","EEL precision hits matched to truth;matched hits;entries",21,-0.5,20.5); + precMatchedHitsCSS=Book1D("precMatchedHitsCSS","CSS precision hits matched to truth;matched hits;entries",21,-0.5,20.5); + precMatchedHitsCSL=Book1D("precMatchedHitsCSL","CSL precision hits matched to truth;matched hits;entries",21,-0.5,20.5); + + phiMatchedHitsSummed=Book1D("phiMatchedHitsSummed","summed phi hits matched to truth (all chambers)",21,-0.5,20.5 ); + phiMatchedHitsBM1=Book1D("phiMatchedHitsBM1","BM1 phi hits matched to truth;matched hits;entries",21,-0.5,20.5 ); + phiMatchedHitsBM2=Book1D("phiMatchedHitsBM2","BM2 phi hits matched to truth;matched hits;entries",21,-0.5,20.5 ); + phiMatchedHitsBO1=Book1D("phiMatchedHitsBO1","BO1 phi hits matched to truth;matched hits;entries",21,-0.5,20.5 ); + phiMatchedHitsBO2=Book1D("phiMatchedHitsBO2","BO2 phi hits matched to truth;matched hits;entries",21,-0.5,20.5 ); + phiMatchedHitsT1=Book1D("phiMatchedHitsT1","T1 phi hits matched to truth;matched hits;entries",21,-0.5,20.5 ); + phiMatchedHitsT2=Book1D("phiMatchedHitsT2","T2 phi hits matched to truth;matched hits;entries",21,-0.5,20.5 ); + phiMatchedHitsT3=Book1D("phiMatchedHitsT3","T3 phi hits matched to truth;matched hits;entries",21,-0.5,20.5 ); + phiMatchedHitsT4=Book1D("phiMatchedHitsT4","T4 phi hits matched to truth;matched hits;entries",21,-0.5,20.5 ); + phiMatchedHitsCSC=Book1D("phiMatchedHitsCSC","CSC phi hits matched to truth;matched hits;entries",21,-0.5,20.5 ); + + trigEtaMatchedHitsSummed=Book1D("trigEtaMatchedHitsSummed","summed trigEta hits matched to truth (all chambers)",21,-0.5,20.5 ); + trigEtaMatchedHitsBM1=Book1D("trigEtaMatchedHitsBM1","BM1 trigEta hits matched to truth;matched hits;entries",21,-0.5,20.5 ); + trigEtaMatchedHitsBM2=Book1D("trigEtaMatchedHitsBM2","BM2 trigEta hits matched to truth;matched hits;entries",21,-0.5,20.5 ); + trigEtaMatchedHitsBO1=Book1D("trigEtaMatchedHitsBO1","BO1 trigEta hits matched to truth;matched hits;entries",21,-0.5,20.5 ); + trigEtaMatchedHitsBO2=Book1D("trigEtaMatchedHitsBO2","BO2 trigEta hits matched to truth;matched hits;entries",21,-0.5,20.5 ); + trigEtaMatchedHitsT1=Book1D("trigEtaMatchedHitsT1","T1 trigEta hits matched to truth;matched hits;entries",21,-0.5,20.5 ); + trigEtaMatchedHitsT2=Book1D("trigEtaMatchedHitsT2","T2 trigEta hits matched to truth;matched hits;entries",21,-0.5,20.5 ); + trigEtaMatchedHitsT3=Book1D("trigEtaMatchedHitsT3","T3 trigEta hits matched to truth;matched hits;entries",21,-0.5,20.5 ); + trigEtaMatchedHitsT4=Book1D("trigEtaMatchedHitsT4","T4 trigEta hits matched to truth;matched hits;entries",21,-0.5,20.5 ); + // trigEtaMatchedHitsCSC=Book1D("trigEtaMatchedHitsCSC","CSC trigEta hits matched to truth;matched hits;entries",21,-0.5,20.5 ); + + } + +void MuonTruthHitPlots::fill(const xAOD::Muon& muon){ + + fillPlot(precMatchedHitsSummed,"nprecMatchedHitsPerChamberLayer", muon); + fillPlot(precMatchedHitsBIS,"nprecMatchedHitsPerChamberLayer", Muon::MuonStationIndex::BIS, muon); + fillPlot(precMatchedHitsBIL,"nprecMatchedHitsPerChamberLayer", Muon::MuonStationIndex::BIL, muon); + fillPlot(precMatchedHitsBMS,"nprecMatchedHitsPerChamberLayer", Muon::MuonStationIndex::BMS, muon); + fillPlot(precMatchedHitsBML,"nprecMatchedHitsPerChamberLayer", Muon::MuonStationIndex::BML, muon); + fillPlot(precMatchedHitsBOS,"nprecMatchedHitsPerChamberLayer", Muon::MuonStationIndex::BOS, muon); + fillPlot(precMatchedHitsBOL,"nprecMatchedHitsPerChamberLayer", Muon::MuonStationIndex::BOL, muon); + fillPlot(precMatchedHitsBEE,"nprecMatchedHitsPerChamberLayer", Muon::MuonStationIndex::BEE, muon); + fillPlot(precMatchedHitsEIS,"nprecMatchedHitsPerChamberLayer", Muon::MuonStationIndex::EIS, muon); + fillPlot(precMatchedHitsEIL,"nprecMatchedHitsPerChamberLayer", Muon::MuonStationIndex::EIL, muon); + fillPlot(precMatchedHitsEMS,"nprecMatchedHitsPerChamberLayer", Muon::MuonStationIndex::EMS, muon); + fillPlot(precMatchedHitsEML,"nprecMatchedHitsPerChamberLayer", Muon::MuonStationIndex::EML, muon); + fillPlot(precMatchedHitsEOS,"nprecMatchedHitsPerChamberLayer", Muon::MuonStationIndex::EOS, muon); + fillPlot(precMatchedHitsEOL,"nprecMatchedHitsPerChamberLayer", Muon::MuonStationIndex::EOL, muon); + fillPlot(precMatchedHitsEES,"nprecMatchedHitsPerChamberLayer", Muon::MuonStationIndex::EES, muon); + fillPlot(precMatchedHitsEEL,"nprecMatchedHitsPerChamberLayer", Muon::MuonStationIndex::EEL, muon); + fillPlot(precMatchedHitsCSS,"nprecMatchedHitsPerChamberLayer", Muon::MuonStationIndex::CSS, muon); + fillPlot(precMatchedHitsCSL,"nprecMatchedHitsPerChamberLayer", Muon::MuonStationIndex::CSL, muon); + + fillPlot(phiMatchedHitsSummed,"nphiMatchedHitsPerChamberLayer", muon); + fillPlot(phiMatchedHitsBM1, "nphiMatchedHitsPerChamberLayer", Muon::MuonStationIndex::BM1, muon); + fillPlot(phiMatchedHitsBM2, "nphiMatchedHitsPerChamberLayer", Muon::MuonStationIndex::BM2, muon); + fillPlot(phiMatchedHitsBO1, "nphiMatchedHitsPerChamberLayer", Muon::MuonStationIndex::BO1, muon); + fillPlot(phiMatchedHitsBO2, "nphiMatchedHitsPerChamberLayer", Muon::MuonStationIndex::BO2, muon); + fillPlot(phiMatchedHitsT1, "nphiMatchedHitsPerChamberLayer", Muon::MuonStationIndex::T1, muon); + fillPlot(phiMatchedHitsT2, "nphiMatchedHitsPerChamberLayer", Muon::MuonStationIndex::T2, muon); + fillPlot(phiMatchedHitsT3, "nphiMatchedHitsPerChamberLayer", Muon::MuonStationIndex::T3, muon); + fillPlot(phiMatchedHitsT4, "nphiMatchedHitsPerChamberLayer", Muon::MuonStationIndex::T4, muon); + fillPlot(phiMatchedHitsCSC, "nphiMatchedHitsPerChamberLayer", Muon::MuonStationIndex::CSC, muon); + + fillPlot(trigEtaMatchedHitsSummed,"ntrigEtaMatchedHitsPerChamberLayer", muon); + fillPlot(trigEtaMatchedHitsBM1, "ntrigEtaMatchedHitsPerChamberLayer", Muon::MuonStationIndex::BM1, muon); + fillPlot(trigEtaMatchedHitsBM2, "ntrigEtaMatchedHitsPerChamberLayer", Muon::MuonStationIndex::BM2, muon); + fillPlot(trigEtaMatchedHitsBO1, "ntrigEtaMatchedHitsPerChamberLayer", Muon::MuonStationIndex::BO1, muon); + fillPlot(trigEtaMatchedHitsBO2, "ntrigEtaMatchedHitsPerChamberLayer", Muon::MuonStationIndex::BO2, muon); + fillPlot(trigEtaMatchedHitsT1, "ntrigEtaMatchedHitsPerChamberLayer", Muon::MuonStationIndex::T1, muon); + fillPlot(trigEtaMatchedHitsT2, "ntrigEtaMatchedHitsPerChamberLayer", Muon::MuonStationIndex::T2, muon); + fillPlot(trigEtaMatchedHitsT3, "ntrigEtaMatchedHitsPerChamberLayer", Muon::MuonStationIndex::T3, muon); + fillPlot(trigEtaMatchedHitsT4, "ntrigEtaMatchedHitsPerChamberLayer", Muon::MuonStationIndex::T4, muon); + // fillPlot(trigEtaMatchedHitsCSC, "ntrigEtaMatchedHitsPerChamberLayer", Muon::MuonStationIndex::CSC, muon); + +} + +void MuonTruthHitPlots::fillPlot(TH1* hitPlots, const std::string& sInfo,const xAOD::Muon& muon){ + //protection + if (muon.author()!=xAOD::Muon::MuidCo && muon.author()!=xAOD::Muon::MuidSA && muon.author()!=xAOD::Muon::MuGirl) return; + + if (!muon.isAvailable<std::vector<unsigned int >>(sInfo)) return; + std::vector<unsigned int> vec=muon.auxdata<std::vector<unsigned int>>(sInfo); + for (unsigned int i=0;i<vec.size();i++) { + hitPlots->Fill(vec[i]); + } +} + + void MuonTruthHitPlots::fillPlot(TH1* hitPlots, const std::string& sInfo, const Muon::MuonStationIndex::ChIndex& index, const xAOD::Muon& muon){ + //protection + if (muon.author()!=xAOD::Muon::MuidCo && muon.author()!=xAOD::Muon::MuidSA && muon.author()!=xAOD::Muon::MuGirl) return; + + if (!muon.isAvailable<std::vector<unsigned int >>(sInfo)) return; + std::vector<unsigned int> vec=muon.auxdata<std::vector<unsigned int>>(sInfo); + hitPlots->Fill(vec[index]); + +} + void MuonTruthHitPlots::fillPlot(TH1* hitPlots, const std::string& sInfo, const Muon::MuonStationIndex::PhiIndex& index, const xAOD::Muon& muon){ + //protection + if (muon.author()!=xAOD::Muon::MuidCo && muon.author()!=xAOD::Muon::MuidSA && muon.author()!=xAOD::Muon::MuGirl) return; + + if (!muon.isAvailable<std::vector<unsigned int >>(sInfo)) return; + std::vector<unsigned int> vec=muon.auxdata<std::vector<unsigned int>>(sInfo); + hitPlots->Fill(vec[index]); + +} + + +} diff --git a/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/Root/RecoMuonPlotOrganizer.cxx b/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/Root/RecoMuonPlotOrganizer.cxx index 3db1e34f18ec531ff0f6b432261049caf98fd390..fb825ffccbd85d57bab4752b55f19982f6f99dea 100644 --- a/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/Root/RecoMuonPlotOrganizer.cxx +++ b/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/Root/RecoMuonPlotOrganizer.cxx @@ -77,15 +77,9 @@ RecoMuonPlotOrganizer::~RecoMuonPlotOrganizer() m_allPlots.clear(); } -void RecoMuonPlotOrganizer::fill(const xAOD::Muon& mu) { + void RecoMuonPlotOrganizer::fill(const xAOD::Muon& mu) { if (m_oIDHitPlots && (mu.inDetTrackParticleLink().isValid())) m_oIDHitPlots->fill(*mu.trackParticle(xAOD::Muon::InnerDetectorTrackParticle)); - if (m_oTrkParamPlots) { - if (mu.muonType()==xAOD::Muon::SiliconAssociatedForwardMuon) { - if (mu.combinedTrackParticleLink().isValid()) { - m_oTrkParamPlots->fill(*mu.trackParticle(xAOD::Muon::CombinedTrackParticle)); - } - } else m_oTrkParamPlots->fill(mu); - } + if (m_oTrkParamPlots) m_oTrkParamPlots->fill(mu); if (m_oMuonParamPlots) m_oMuonParamPlots->fill(mu); if (m_oMuRecoInfoPlots) m_oMuRecoInfoPlots->fill(mu); if (m_oMomentumPullPlots) m_oMomentumPullPlots->fill(mu); diff --git a/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/Root/SlowMuonParamPlots.cxx b/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/Root/SlowMuonParamPlots.cxx new file mode 100644 index 0000000000000000000000000000000000000000..98446f1025ce6efa573d14006d2bb6fe19609029 --- /dev/null +++ b/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/Root/SlowMuonParamPlots.cxx @@ -0,0 +1,24 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "MuonHistUtils/SlowMuonParamPlots.h" + +namespace Muon{ + +SlowMuonParamPlots::SlowMuonParamPlots(PlotBase *pParent, std::string sDir) + :PlotBase(pParent, sDir) + , beta(NULL) +{} + +void SlowMuonParamPlots::initializePlots() +{ + beta = Book1D("beta", "beta;beta;Entries",150,0,1.5); +} + +void SlowMuonParamPlots::fill(const xAOD::SlowMuon& smu) +{ + beta->Fill( smu.beta() ); +} + +} //close namespace Muon diff --git a/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/Root/TruthRelatedMuonPlotOrganizer.cxx b/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/Root/TruthRelatedMuonPlotOrganizer.cxx index 7edc09c83596e0a6ee03b3554da1ef7e647a70fa..fe59021ec60055e8d47423697b540aada8346147 100644 --- a/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/Root/TruthRelatedMuonPlotOrganizer.cxx +++ b/MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils/Root/TruthRelatedMuonPlotOrganizer.cxx @@ -19,10 +19,12 @@ TruthRelatedMuonPlotOrganizer::TruthRelatedMuonPlotOrganizer(PlotBase* pParent, , m_oMatchedRecoPlots(NULL) , m_oMSHitDiffPlots(NULL) , m_oMuonHitDiffSummaryPlots(NULL) +, m_oMuonTruthHitPlots(NULL) , m_oMuonResolutionPlots(NULL) , m_oDefParamPullPlots(NULL) , m_oMomentumTruthPullPlots_Tail(NULL) , m_oMomentumTruthPullPlots_NoTail(NULL) +, m_oMatchedRecoElossPlots(NULL) { @@ -50,6 +52,10 @@ TruthRelatedMuonPlotOrganizer::TruthRelatedMuonPlotOrganizer(PlotBase* pParent, m_oMuonHitDiffSummaryPlots = new Muon::MuonHitDiffSummaryPlots(this,"/hits/"); m_allPlots.push_back(m_oMuonHitDiffSummaryPlots); break; + case MUON_TRUTHHIT: + m_oMuonTruthHitPlots = new Muon::MuonTruthHitPlots(this,"/truthHits/"); + m_allPlots.push_back(m_oMuonTruthHitPlots); + break; case MUON_RESOL: m_oMuonResolutionPlots = new Muon::MuonResolutionPlots(this, "/resolution/","",doBinnedResolutionPlots); m_allPlots.push_back(m_oMuonResolutionPlots); @@ -66,6 +72,10 @@ TruthRelatedMuonPlotOrganizer::TruthRelatedMuonPlotOrganizer(PlotBase* pParent, m_oMomentumTruthPullPlots_NoTail = new Muon::MomentumTruthPullPlots(this,"/momentumPulls/","NoTail"); m_allPlots.push_back(m_oMomentumTruthPullPlots_NoTail); break; + case MUON_PARAMELOSS: + m_oMatchedRecoElossPlots = new Muon::MuonParamElossPlots(this,"/Eloss/"); + m_allPlots.push_back(m_oMatchedRecoElossPlots); + break; } } @@ -80,9 +90,13 @@ TruthRelatedMuonPlotOrganizer::~TruthRelatedMuonPlotOrganizer() void TruthRelatedMuonPlotOrganizer::fill(const xAOD::TruthParticle& truthMu, const xAOD::Muon& mu, const xAOD::TrackParticleContainer* MSTracks){ if (m_oMatchedPlots) m_oMatchedPlots->fill( truthMu ); if (m_oMuonHitDiffSummaryPlots) m_oMuonHitDiffSummaryPlots->fill(mu, truthMu); - + if (m_oMuonTruthHitPlots) m_oMuonTruthHitPlots->fill(mu); + + //new for eloss + if (m_oMatchedRecoElossPlots) m_oMatchedRecoElossPlots->fill(truthMu, mu ); + // Tracking related plots - const xAOD::TrackParticle* primaryTrk = (mu.muonType()==xAOD::Muon::SiliconAssociatedForwardMuon)? mu.trackParticle(xAOD::Muon::CombinedTrackParticle) : mu.trackParticle(xAOD::Muon::Primary); //fix for SiliconAssociatedForwardMuon + const xAOD::TrackParticle* primaryTrk = mu.trackParticle(xAOD::Muon::Primary); //const xAOD::TrackParticle* meTrk = mu.trackParticle(xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle); if (!primaryTrk) return; diff --git a/MuonSpectrometer/MuonValidation/MuonRecValidation/MuonRecRTT/test/MuonRecRTT_TestConfiguration.xml b/MuonSpectrometer/MuonValidation/MuonRecValidation/MuonRecRTT/test/MuonRecRTT_TestConfiguration.xml index e34e2266405eda23a3b41c7aa4c2d2c3e0f572f0..9132679058391e6f2e51114efac0587370cf39dd 100644 --- a/MuonSpectrometer/MuonValidation/MuonRecValidation/MuonRecRTT/test/MuonRecRTT_TestConfiguration.xml +++ b/MuonSpectrometer/MuonValidation/MuonRecValidation/MuonRecRTT/test/MuonRecRTT_TestConfiguration.xml @@ -110,7 +110,7 @@ <testname>ExeRunner</testname> <arg> <argname>exeName</argname> - <argvalue>runPostProcessMacros.sh</argvalue> + <argvalue>MuonValidation_runPostProcessMacrosRtt.sh</argvalue> </arg> <arg> <argname>exeParamString</argname>