From 5be948e15edcd85d6a66ef25d44ebb35395644b9 Mon Sep 17 00:00:00 2001
From: Will Leight <wleight@cern.ch>
Date: Tue, 23 Jan 2018 23:59:39 +0100
Subject: [PATCH] Make muon truth algs barcode-independent

This fix ensures that barcode shifts for the MuonTruthDecorationAlg, MuonTruthAssociationAlg, and MuonSegmentTruthAssociationAlg are correctly set in the configuration.
This resolves some of the muon issues reported in the validation of the MC18 truth strategy (see ATLPHYSVAL-553 for more details), owing to that strategy using different barcode shifts.
It also helps to address longstanding problems with muon truth matching not being barcode-independent (see ATLASRECTS-2962 for more details).
This manual sweep resolves conflicts in the original sweep from 21.0 to master.


Former-commit-id: 8450ad170224300a72bb2e105f5791fc8bc3f321
---
 .../MuonRecExample/share/MuonRec_jobOptions.py  | 17 +++++++++++++++++
 .../share/MuonCombinedRec_postprocessing.py     |  9 +++++++++
 2 files changed, 26 insertions(+)

diff --git a/MuonSpectrometer/MuonReconstruction/MuonRecExample/share/MuonRec_jobOptions.py b/MuonSpectrometer/MuonReconstruction/MuonRecExample/share/MuonRec_jobOptions.py
index dec58fc72fb..02681c0d85b 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonRecExample/share/MuonRec_jobOptions.py
+++ b/MuonSpectrometer/MuonReconstruction/MuonRecExample/share/MuonRec_jobOptions.py
@@ -99,6 +99,14 @@ if rec.doTruth() and DetFlags.makeRIO.Muon_on():
    from MuonTruthAlgs.MuonTruthAlgsConf import Muon__MuonTruthDecorationAlg
    topSequence += Muon__MuonTruthDecorationAlg("MuonTruthDecorationAlg")
 
+   try:
+       from RecExConfig.InputFilePeeker import inputFileSummary
+       truthStrategy = inputFileSummary['metadata']['/Simulation/Parameters']['TruthStrategy']
+       if truthStrategy in ['MC15','MC18','MC18LLP']:
+           topSequence.MuonTruthDecorationAlg.BarcodeOffset=10000000
+   except:
+       print "Failed to read /Simulation/Parameters/ metadata"
+       pass
 
 #load default tools:
 if muonRecFlags.doStandalone() or muonRecFlags.doPseudoTracking():
@@ -131,6 +139,15 @@ if muonRecFlags.doStandalone():
 
         topSequence += Muon__MuonSegmentTruthAssociationAlg("MuonSegmentTruthAssociationAlg")
 
+        try:
+            from RecExConfig.InputFilePeeker import inputFileSummary
+            truthStrategy = inputFileSummary['metadata']['/Simulation/Parameters']['TruthStrategy']
+            if truthStrategy in ['MC15','MC18','MC18LLP']:
+                topSequence.MuonSegmentTruthAssociationAlg.BarcodeOffset=10000000
+        except:
+            print "Failed to read /Simulation/Parameters/ metadata"
+            pass
+
 #--------------------------------------------------------------------------
 # Apply alignment corrections to geometry
 #--------------------------------------------------------------------------
diff --git a/Reconstruction/MuonIdentification/MuonCombinedRecExample/share/MuonCombinedRec_postprocessing.py b/Reconstruction/MuonIdentification/MuonCombinedRecExample/share/MuonCombinedRec_postprocessing.py
index 521d770c554..98030248bb4 100644
--- a/Reconstruction/MuonIdentification/MuonCombinedRecExample/share/MuonCombinedRec_postprocessing.py
+++ b/Reconstruction/MuonIdentification/MuonCombinedRecExample/share/MuonCombinedRec_postprocessing.py
@@ -31,10 +31,19 @@ if rec.doTruth() and muonCombinedRecFlags.doxAOD() and rec.doMuonCombined():
         topSequence += TrackParticleTruthAlg(name = cols[i]+"TruthAlg",
                                              TrackTruthName=cols[i]+"Truth",
                                              TrackParticleName = colsTP[i] )
+    topSequence.CombinedMuonTracksTruthAlg.OutputLevel=VERBOSE
 
     from MuonTruthAlgs.MuonTruthAlgsConf import MuonTruthAssociationAlg
     topSequence += MuonTruthAssociationAlg("MuonTruthAssociationAlg")
 
+    try:
+        from RecExConfig.InputFilePeeker import inputFileSummary
+        truthStrategy = inputFileSummary['metadata']['/Simulation/Parameters']['TruthStrategy']
+        if truthStrategy in ['MC15','MC18','MC18LLP']:
+            topSequence.MuonTruthAssociationAlg.BarcodeOffset=10000000
+    except:
+        print "Failed to read /Simulation/Parameters/ metadata"
+        pass
 
 if muonCombinedRecFlags.doTrackPerformance:
     include("MuonCombinedRecExample/MuonCombinedTrackPerformance_jobOptions.py")
-- 
GitLab