Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
athena
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
atlas
athena
Merge requests
!71349
Something went wrong on our end
Revive the Muon effi SF tester macro
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Revive the Muon effi SF tester macro
jojungge/athena:SagarNeedsToBeHappy
into
main
Overview
13
Commits
7
Pipelines
0
Changes
2
All threads resolved!
Hide all comments
Merged
Johannes Junggeburth
requested to merge
jojungge/athena:SagarNeedsToBeHappy
into
main
10 months ago
Overview
13
Commits
7
Pipelines
0
Changes
2
All threads resolved!
Hide all comments
Expand
Revive the tester macro to compare the scale-factors per muon in different recommendation releases. Macro is now based on the MuonTesterTree package.
Delete obsolete tester algorithms
Introduce a CA config
Tagging
@sagara17
,
@goblirsc
,
@sagar
,
@vaustrup
,
@gproto
Edited
10 months ago
by
Johannes Junggeburth
1
0
Merge request reports
Viewing commit
1f0c1eaa
Prev
Next
Show latest version
2 files
+
0
−
235
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
1f0c1eaa
Tschuuuuuuuss
· 1f0c1eaa
Johannes Junggeburth
authored
10 months ago
PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/util/MuonEfficiencyScaleFactorsSFFileTester.cxx deleted
100644 → 0
+
0
−
234
Options
/*
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/
/*
* This macro is meant for testing purposes of the MCP efficiency teams, it is not a minimal working example for analyzers,
* please use MuonEfficiencyScaleFactorsTest or MuonTriggerSFRootCoreTest instead
*/
#include
<memory>
#include
<cstdlib>
#include
<string>
#include
<map>
// ROOT include(s):
#include
<TFile.h>
#include
<TError.h>
#include
<TStopwatch.h>
#include
<TString.h>
// Infrastructure include(s):
#ifdef ROOTCORE
# include "xAODRootAccess/Init.h"
# include "xAODRootAccess/TEvent.h"
# include "xAODRootAccess/tools/ReturnCheck.h"
# include "AsgMessaging/Check.h"
#endif // ROOTCORE
// EDM include(s):
#include
"xAODEventInfo/EventInfo.h"
#include
"xAODMuon/MuonContainer.h"
#include
"xAODMuon/MuonAuxContainer.h"
// Local include(s):
#include
"MuonEfficiencyCorrections/MuonEfficiencyScaleFactors.h"
#include
"PATInterfaces/ISystematicsTool.h"
#include
"xAODCore/tools/IOStats.h"
#include
"xAODCore/tools/ReadStats.h"
#include
"AsgTools/ToolHandle.h"
#include
"AsgTools/StandaloneToolHandle.h"
#include
"AsgAnalysisInterfaces/IPileupReweightingTool.h"
#include
"MuonEfficiencyCorrections/MuonSFTestHelper.h"
#define CHECK_CPCorr(Arg) \
if (Arg.code() == CP::CorrectionCode::Error){ \
Error(#Arg,"Correction Code 'Error' (returned in line %i) ",__LINE__); \
return 1; \
}
typedef
asg
::
StandaloneToolHandle
<
CP
::
IMuonEfficiencyScaleFactors
>
EffiToolInstance
;
EffiToolInstance
createSFTool
(
const
std
::
string
&
WP
,
const
std
::
string
&
CustomInput
,
bool
uncorrelate_Syst
,
bool
doJPsi
,
bool
isComparison
=
false
)
{
EffiToolInstance
tool
(
std
::
string
(
"CP::MuonEfficiencyScaleFactors/EffiTool_"
)
+
WP
+
(
isComparison
?
"_comp"
:
""
)
);
tool
.
setProperty
(
"WorkingPoint"
,
WP
).
isSuccess
();
tool
.
setProperty
(
"UncorrelateSystematics"
,
uncorrelate_Syst
).
isSuccess
();
if
(
doJPsi
)
tool
.
setProperty
(
"LowPtThreshold"
,
1.e14
).
isSuccess
();
else
tool
.
setProperty
(
"LowPtThreshold"
,
-
1.
).
isSuccess
();
if
(
!
CustomInput
.
empty
())
tool
.
setProperty
(
"CustomInputFolder"
,
CustomInput
).
isSuccess
();
tool
.
retrieve
().
isSuccess
();
return
tool
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
// force strict checking of return codes
StatusCode
::
enableFailure
();
StatusCode
::
enableFailure
();
// The application's name:
const
char
*
APP_NAME
=
argv
[
0
];
// this default is for MC16a -> data2016
std
::
string
prwFilename
=
"dev/PileupReweighting/share/DSID361xxx/pileup_mc20a_dsid361107_FS.root"
;
std
::
string
ilumiFilename
=
"GoodRunsLists/data16_13TeV/20180129/PHYS_StandardGRL_All_Good_25ns_297730-311481_OflLumi-13TeV-009.root"
;
std
::
string
OutputFilename
=
"Applied_SFs.root"
;
std
::
string
InDir
=
""
;
std
::
string
DefaultCalibRelease
=
""
;
std
::
string
SFComparisonFolder
=
""
;
bool
doJPsi
=
false
;
long
long
int
nmax
=
-
1
;
// read the config provided by the user
for
(
int
k
=
1
;
k
<
argc
-
1
;
++
k
)
{
if
(
std
::
string
(
argv
[
k
]).
find
(
"-i"
)
==
0
)
{
InDir
=
argv
[
k
+
1
];
}
if
(
std
::
string
(
argv
[
k
]).
find
(
"--c1"
)
==
0
)
{
DefaultCalibRelease
=
argv
[
k
+
1
];
}
if
(
std
::
string
(
argv
[
k
]).
find
(
"--c2"
)
==
0
)
{
SFComparisonFolder
=
argv
[
k
+
1
];
}
if
(
std
::
string
(
argv
[
k
]).
find
(
"-n"
)
==
0
)
{
nmax
=
atoi
(
argv
[
k
+
1
]);
}
if
(
std
::
string
(
argv
[
k
]).
find
(
"-o"
)
==
0
)
{
OutputFilename
=
argv
[
k
+
1
];
}
if
(
std
::
string
(
argv
[
k
]).
find
(
"--JPsi"
)
==
0
)
{
doJPsi
=
true
;
if
(
OutputFilename
==
"Applied_SFs.root"
)
OutputFilename
=
"Applied_SFs_JPsi.root"
;
}
if
(
std
::
string
(
argv
[
k
]).
find
(
"--ilumi"
)
==
0
)
{
ilumiFilename
=
argv
[
k
+
1
];
}
if
(
std
::
string
(
argv
[
k
]).
find
(
"--prw"
)
==
0
)
{
prwFilename
=
argv
[
k
+
1
];
}
}
bool
doComparison
=
!
SFComparisonFolder
.
empty
();
// check( if we received a file name:
if
(
argc
<
3
)
{
Error
(
APP_NAME
,
"No file name received!"
);
Error
(
APP_NAME
,
" Usage: %s -i [xAOD file name]"
,
APP_NAME
);
return
EXIT_FAILURE
;
}
RETURN_CHECK
(
APP_NAME
,
xAOD
::
Init
(
APP_NAME
));
// Open the input file:
const
TString
fileName
=
InDir
;
Info
(
APP_NAME
,
"Opening file: %s"
,
fileName
.
Data
());
std
::
unique_ptr
<
TFile
>
ifile
(
TFile
::
Open
(
fileName
,
"READ"
));
if
(
!
ifile
.
get
())
{
Error
(
APP_NAME
,
" Unable to load xAOD input file"
);
return
EXIT_FAILURE
;
}
// Create a TEvent object:
xAOD
::
TEvent
event
;
RETURN_CHECK
(
APP_NAME
,
event
.
readFrom
(
ifile
.
get
(),
xAOD
::
TEvent
::
kClassAccess
));
Info
(
APP_NAME
,
"Number of events in the file: %i"
,
static_cast
<
int
>
(
event
.
getEntries
()));
// Decide how many events to run over:
Long64_t
entries
=
event
.
getEntries
();
if
((
nmax
!=
-
1
)
&&
(
nmax
<
entries
))
entries
=
nmax
;
TStopwatch
tsw
;
tsw
.
Start
();
const
std
::
vector
<
std
::
string
>
WPs
{
// reconstruction WPs
"Loose"
,
"Medium"
,
"Tight"
,
"HighPt"
,
"LowPt"
,
// track-to-vertex-association WPs
"TTVA"
,
// BadMuon veto SFs
//"BadMuonVeto_HighPt",
// isolation WPs
"Loose_VarRadIso"
,
"Tight_VarRadIso"
,
"PflowLoose_VarRadIso"
,
"PflowTight_VarRadIso"
};
std
::
vector
<
EffiToolInstance
>
EffiTools
;
std
::
vector
<
EffiToolInstance
>
ComparisonTools
;
for
(
auto
&
WP
:
WPs
)
{
EffiTools
.
push_back
(
createSFTool
(
WP
,
DefaultCalibRelease
,
false
,
doJPsi
));
if
(
doComparison
)
ComparisonTools
.
push_back
(
createSFTool
(
WP
,
SFComparisonFolder
,
false
,
doJPsi
,
true
));
}
TestMuonSF
::
MuonSFTestHelper
PrimaryHelper
(
DefaultCalibRelease
,
true
);
TestMuonSF
::
MuonSFTestHelper
ComparisonHelper
(
PrimaryHelper
.
tree_shared
(),
SFComparisonFolder
);
for
(
auto
Effi
:
EffiTools
)
{
PrimaryHelper
.
addTool
(
Effi
.
getHandle
());
PrimaryHelper
.
addReplicaTool
(
Effi
.
getHandle
());
}
for
(
auto
Effi
:
ComparisonTools
)
{
ComparisonHelper
.
addTool
(
Effi
.
getHandle
());
ComparisonHelper
.
addReplicaTool
(
Effi
.
getHandle
());
}
if
(
!
PrimaryHelper
.
init
())
return
EXIT_FAILURE
;
if
(
doComparison
&&
!
ComparisonHelper
.
init
())
return
EXIT_FAILURE
;
double
t_init
=
tsw
.
CpuTime
();
tsw
.
Reset
();
tsw
.
Start
();
unsigned
int
nMuons
=
0
;
asg
::
StandaloneToolHandle
<
CP
::
IPileupReweightingTool
>
m_prw_tool
(
"CP::PileupReweightingTool/myTool"
);
// This is just a placeholder configuration for testing. Do not use these config files for your analysis!
std
::
vector
<
std
::
string
>
m_ConfigFiles
{
prwFilename
};
std
::
vector
<
std
::
string
>
m_LumiCalcFiles
{
ilumiFilename
};
ASG_CHECK_SA
(
APP_NAME
,
m_prw_tool
.
setProperty
(
"ConfigFiles"
,
m_ConfigFiles
));
ASG_CHECK_SA
(
APP_NAME
,
m_prw_tool
.
setProperty
(
"LumiCalcFiles"
,
m_LumiCalcFiles
));
ASG_CHECK_SA
(
APP_NAME
,
m_prw_tool
.
setProperty
(
"DataScaleFactor"
,
1.0
/
1.09
));
ASG_CHECK_SA
(
APP_NAME
,
m_prw_tool
.
setProperty
(
"DataScaleFactorUP"
,
1.
));
ASG_CHECK_SA
(
APP_NAME
,
m_prw_tool
.
setProperty
(
"DataScaleFactorDOWN"
,
1.0
/
1.18
));
ASG_CHECK_SA
(
APP_NAME
,
m_prw_tool
.
initialize
());
// write a root file containing the SFs, stat and sys errors
TFile
*
f
=
new
TFile
(
OutputFilename
.
c_str
(),
"RECREATE"
);
for
(
Long64_t
entry
=
0
;
entry
<
entries
;
++
entry
)
{
// Tell the object which entry to look at:
event
.
getEntry
(
entry
);
// Print some event information for fun:
const
xAOD
::
EventInfo
*
ei
=
0
;
RETURN_CHECK
(
APP_NAME
,
event
.
retrieve
(
ei
,
"EventInfo"
));
RETURN_CHECK
(
APP_NAME
,
m_prw_tool
->
apply
(
*
ei
));
if
(
entry
%
5000
==
0
)
Info
(
APP_NAME
,
"===>>> start processing event #%i, run #%i (%i events processed so far) <<<==="
,
static_cast
<
int
>
(
ei
->
eventNumber
()),
static_cast
<
int
>
(
ei
->
runNumber
()),
static_cast
<
int
>
(
entry
));
// Get the Muons from the event:
const
xAOD
::
MuonContainer
*
muons
=
0
;
RETURN_CHECK
(
APP_NAME
,
event
.
retrieve
(
muons
,
"Muons"
));
for
(
const
auto
*
mu
:
*
muons
)
{
if
(
PrimaryHelper
.
fill
(
mu
)
!=
CP
::
CorrectionCode
::
Ok
)
return
EXIT_FAILURE
;
if
(
doComparison
&&
ComparisonHelper
.
fill
(
mu
)
!=
CP
::
CorrectionCode
::
Ok
)
return
EXIT_FAILURE
;
PrimaryHelper
.
fillTree
();
}
nMuons
=
nMuons
+
muons
->
size
();
}
double
t_run
=
tsw
.
CpuTime
()
/
entries
;
Info
(
APP_NAME
,
" MCP init took %g s"
,
t_init
);
Info
(
APP_NAME
,
" time per event: %g s"
,
t_run
);
std
::
cout
<<
"Number of muons in file: "
<<
nMuons
<<
std
::
endl
;
f
->
cd
();
f
->
WriteObject
(
PrimaryHelper
.
tree
(),
PrimaryHelper
.
tree
()
->
GetName
());
f
->
Close
();
//get smart slimming list
xAOD
::
IOStats
::
instance
().
stats
().
printSmartSlimmingBranchList
();
// Return gracefully:
return
0
;
}
Loading