17namespace ADD_CMODE(CP) {
30 using ColumnarTool::ColumnarTool;
33 MuonEfficiencyScaleFactors::MuonEfficiencyScaleFactors(
const std::string& name) :
39 m_custom_file_Combined(),
41 m_custom_file_HighEta(),
42 m_custom_file_LowPt(),
43 m_custom_file_LowPtCalo(),
44 m_custom_file_LRTCombined(),
45 m_custom_file_LRTLowPt(),
46 m_efficiency_decoration_name_data(),
47 m_efficiency_decoration_name_mc(),
48 m_sf_decoration_name(),
49 m_calibration_version(
"251211_Preliminary_r24run3"),
50 m_lowpt_threshold(-1.),
51 m_iso_jet_dR(
"dRJet"),
52 m_use2DIsoCorr(
false),
54 m_filtered_sys_sets(),
56 m_seperateSystBins(
false),
57 m_breakDownSyst(
false),
58 m_applyKineDepSys(
true),
60 m_Type(MuonEfficiencyType::Undefined) {
62 m_accessors = std::make_unique<Accessors>(
this);
64 declareProperty(
"WorkingPoint", m_wp);
67 declareProperty(
"CustomInputFolder", m_custom_dir);
68 declareProperty(
"CustomFileCaloTag", m_custom_file_Calo);
69 declareProperty(
"CustomFileCombined", m_custom_file_Combined);
70 declareProperty(
"CustomFileHighEta", m_custom_file_HighEta);
71 declareProperty(
"CustomFileLowPt", m_custom_file_LowPt);
72 declareProperty(
"CustomFileLowPtCalo", m_custom_file_LowPtCalo);
73 declareProperty(
"CustomFileLRTCombined", m_custom_file_LRTCombined);
74 declareProperty(
"CustomFileLRTLowPt", m_custom_file_LRTLowPt);
78 declareProperty(
"ApplyKinematicSystematic", m_applyKineDepSys);
81 declareProperty(
"DataEfficiencyDecorationName", m_efficiency_decoration_name_data);
82 declareProperty(
"MCEfficiencyDecorationName", m_efficiency_decoration_name_mc);
83 declareProperty(
"ScaleFactorDecorationName", m_sf_decoration_name);
85 declareProperty(
"CalibrationRelease", m_calibration_version);
88 declareProperty(
"LowPtThreshold", m_lowpt_threshold);
89 declareProperty(
"UncorrelateSystematics", m_seperateSystBins);
90 declareProperty(
"BreakDownSystematics", m_breakDownSyst);
93 declareProperty(
"CloseJetDRDecorator", m_iso_jet_dR);
94 declareProperty(
"Use2DIsoCorrections", m_use2DIsoCorr);
96 declareProperty(
"UseLRT", m_useLRT);
98 MuonEfficiencyScaleFactors::~MuonEfficiencyScaleFactors() =
default;
99 const std::string& MuonEfficiencyScaleFactors::close_by_jet_decoration()
const{
102 bool MuonEfficiencyScaleFactors::use_2D_iso_corrections()
const{
103 return m_use2DIsoCorr;
105 float MuonEfficiencyScaleFactors::lowPtTransition()
const{
106 return m_lowpt_threshold;
108 bool MuonEfficiencyScaleFactors::uncorrelate_sys()
const {
return m_seperateSystBins; }
109 MuonEfficiencyType MuonEfficiencyScaleFactors::measurement()
const{
112 std::string MuonEfficiencyScaleFactors::sf_decoration()
const {
113 return m_sf_decoration_name.empty() ? std::string(
"SF") + m_wp : m_sf_decoration_name;
115 std::string MuonEfficiencyScaleFactors::data_effi_decoration()
const{
116 return m_efficiency_decoration_name_data.empty() ? std::string(
"DataEffi") + m_wp : m_efficiency_decoration_name_data;
118 std::string MuonEfficiencyScaleFactors::mc_effi_decoration()
const{
119 return m_efficiency_decoration_name_mc.empty() ? std::string(
"MCEffi") + m_wp : m_efficiency_decoration_name_mc;
121 std::string MuonEfficiencyScaleFactors::sf_replica_decoration()
const {
122 return std::string(
"Replica") + sf_decoration();
124 std::string MuonEfficiencyScaleFactors::data_effi_replica_decoration()
const{
125 return std::string(
"Replica") + data_effi_decoration();
127 std::string MuonEfficiencyScaleFactors::mc_effi_replica_deocration()
const{
128 return std::string(
"Replica") + mc_effi_decoration();
130 size_t MuonEfficiencyScaleFactors::getPosition(
const EffiCollection* coll)
const {
132 for (
const auto& sf: m_sf_sets) {
133 if (sf.get() == coll)
return i;
138 size_t MuonEfficiencyScaleFactors::getNCollections()
const{
139 return m_sf_sets.size();
141 bool MuonEfficiencyScaleFactors::use_lrt()
const{
144 StatusCode MuonEfficiencyScaleFactors::initialize() {
146 ATH_MSG_INFO(
"The tool using working point " << m_wp <<
" is already initialized.");
147 return StatusCode::SUCCESS;
149 if (m_wp.find(
"Iso") != std::string::npos) {
150 m_Type = MuonEfficiencyType::Iso;
152 }
else if (m_wp.find(
"BadMuon") != std::string::npos) {
153 m_Type = MuonEfficiencyType::BadMuonVeto;
155 m_applyKineDepSys =
true;
156 }
else if (m_wp.find(
"TTVA") != std::string::npos) {
157 m_Type = MuonEfficiencyType::TTVA;
159 m_Type = MuonEfficiencyType::Reco;
160 if (m_useLRT && m_wp!=
"Medium") {
161 ATH_MSG_FATAL(Form(
"Only Medium identification WP is supported for LRT muons. You chose %s.", m_wp.c_str()));
162 return StatusCode::FAILURE;
165 ATH_MSG_INFO(
"Efficiency type is = " << EfficiencyTypeName(m_Type));
168 if (m_lowpt_threshold < 0) {
169 if (m_calibration_version.find(
"run3") != std::string::npos) {
170 m_lowpt_threshold = 1e4;
172 m_lowpt_threshold = 15e3;
178 if (m_Type == MuonEfficiencyType::Iso || m_Type == MuonEfficiencyType::TTVA || m_Type == MuonEfficiencyType::BadMuonVeto || (m_Type == MuonEfficiencyType::Reco && m_wp.find(
"HighPt") != std::string::npos)) {
179 ATH_MSG_DEBUG(
"We are running Isolation or TTVA or High Pt reco SF, so we use Zmumu based SF for the whole pt range!");
180 m_lowpt_threshold = -1;
181 }
else if (m_lowpt_threshold <= 0) {
182 ATH_MSG_INFO(
"Low pt SF turned off as crossover threshold is negative! Using Zmumu based SF for all pt values.");
184 ATH_MSG_INFO(
"JPsi based low pt SF will start to rock below " << m_lowpt_threshold / 1000. <<
" GeV!");
187 std::set<std::string> decorations{
189 data_effi_decoration(),
190 mc_effi_decoration() ,
191 sf_replica_decoration(),
192 data_effi_replica_decoration(),
193 mc_effi_replica_deocration()
195 if (decorations.size() != 6){
196 ATH_MSG_FATAL(
"At least one of the decoration names for scale-factor/ data-efficiency / mc-efficiency is not uniquely defined... Please check your properties");
197 return StatusCode::FAILURE;
202 if (!m_custom_dir.empty())
ATH_MSG_WARNING(
"Note: setting up with user specified input file location " << m_custom_dir <<
" - this is not encouraged!");
203 if (!m_custom_file_Calo.empty())
ATH_MSG_WARNING(
"Note: setting up with user specified CaloTag input file " << m_custom_file_Calo <<
" - this is not encouraged!");
204 if (!m_custom_file_Combined.empty())
ATH_MSG_WARNING(
"Note: setting up with user specified Central muon input file " << m_custom_file_Combined <<
" - this is not encouraged! ");
205 if (!m_custom_file_HighEta.empty())
ATH_MSG_WARNING(
"Note: setting up with user specified High Eta input file " << m_custom_file_HighEta <<
" - this is not encouraged! ");
206 if (!m_custom_file_LowPt.empty())
ATH_MSG_WARNING(
"Note: setting up with user specified Low Pt input file " << m_custom_file_LowPt <<
" - this is not encouraged! ");
207 if (!m_custom_file_LowPtCalo.empty())
ATH_MSG_WARNING(
"Note: setting up with user specified Low Pt CaloTag input file " << m_custom_file_LowPtCalo <<
" - this is not encouraged! ");
208 if (!m_custom_file_LRTCombined.empty())
ATH_MSG_WARNING(
"Note: setting up with user specified Central LRT muon input file " << m_custom_file_LRTCombined <<
" - this is not encouraged! ");
209 if (!m_custom_file_LRTLowPt.empty())
ATH_MSG_WARNING(
"Note: setting up with user specified Low Pt LRT muon input file " << m_custom_file_LowPt <<
" - this is not encouraged! ");
210 if (m_custom_dir.empty())
ATH_MSG_INFO(
"Trying to initialize, with working point " << m_wp <<
", using calibration release " << m_calibration_version);
216 m_affectingSys = affectingSystematics();
219 ATH_MSG_ERROR(
"loading the central value systematic set failed");
220 return StatusCode::FAILURE;
225 if (!registry.registerSystematics(*
this)) {
227 return StatusCode::FAILURE;
231 for (
auto& sf_set : m_sf_sets)
232 addSubtool (*sf_set);
234 return StatusCode::SUCCESS;
236 unsigned int MuonEfficiencyScaleFactors::getRandomRunNumber(
const xAOD::EventInfo* info)
const {
239 info = evtInfo.operator->();
241 ATH_MSG_ERROR(
"Could not retrieve the xAOD::EventInfo. Return 999999");
248 const auto& acc = *m_accessors;
250 ATH_MSG_DEBUG(
"The current event is a data event. Return runNumber instead.");
251 return acc.runNumberAcc (info);
253 if (!acc.acc_rnd.isAvailable(info)) {
254 ATH_MSG_WARNING(
"Failed to find the RandomRunNumber decoration. Please call the apply() method from the PileupReweightingTool before hand in order to get period dependent SFs. You'll receive SFs from the most recent period.");
256 }
else if (acc.acc_rnd(info) == 0) {
257 ATH_MSG_DEBUG(
"Pile up tool has given runNumber 0. Return SF from latest period.");
260 return acc.acc_rnd(info);
269 info = evtInfo.operator->();
271 ATH_MSG_ERROR(
"Could not retrieve the xAOD::EventInfo. Return 999999");
282 unsigned int RunNumber = getRandomRunNumber(info);
283 return m_current_sf->retrieveSF(mu, RunNumber)->ScaleFactor(mu, sf);
290 unsigned int RunNumber = getRandomRunNumber(info);
291 return m_current_sf->retrieveSF(mu, RunNumber)->ApplyScaleFactor(mu);
299 unsigned int RunNumber = getRandomRunNumber(info);
300 return m_current_sf->retrieveSF(mu, RunNumber)->ScaleFactorReplicas(mu, sfs);
307 unsigned int RunNumber = getRandomRunNumber(info);
308 return m_current_sf->retrieveSF(mu, RunNumber)->ApplyScaleFactorReplicas(mu, nreplicas);
315 unsigned int RunNumber = getRandomRunNumber(info);
316 return m_current_sf->retrieveSF(mu, RunNumber)->DataEfficiency(mu, eff);
323 unsigned int RunNumber = getRandomRunNumber(info);
324 return m_current_sf->retrieveSF(mu, RunNumber)->ApplyDataEfficiency(mu);
331 unsigned int RunNumber = getRandomRunNumber(info);
332 return m_current_sf->retrieveSF(mu, RunNumber)->DataEfficiencyReplicas(mu, sf_err);
339 unsigned int RunNumber = getRandomRunNumber(info);
340 return m_current_sf->retrieveSF(mu, RunNumber)->ApplyDataEfficiencyReplicas(mu, nreplicas);
347 unsigned int RunNumber = getRandomRunNumber(info);
348 return m_current_sf->retrieveSF(mu, RunNumber)->MCEfficiency(mu, eff);
355 unsigned int RunNumber = getRandomRunNumber(info);
356 return m_current_sf->retrieveSF(mu, RunNumber)->ApplyMCEfficiency(mu);
363 unsigned int RunNumber = getRandomRunNumber(info);
364 return m_current_sf->retrieveSF(mu, RunNumber)->MCEfficiencyReplicas(mu, sf_err);
371 unsigned int RunNumber = getRandomRunNumber(info);
372 return m_current_sf->retrieveSF(mu, RunNumber)->ApplyMCEfficiencyReplicas(mu, nreplicas);
375 std::string MuonEfficiencyScaleFactors::resolve_file_location(
const std::string &filename)
const{
376 if (!m_custom_dir.empty()) {
377 return m_custom_dir +
"/" + filename;
379 std::string fullPathToFile =
PathResolverFindCalibFile(Form(
"MuonEfficiencyCorrections/%s/%s", m_calibration_version.c_str(), filename.c_str()));
380 if (fullPathToFile.empty()) {
381 ATH_MSG_ERROR(
"Unable to resolve the input file " << m_calibration_version <<
"/" << filename <<
" via the PathResolver!");
383 return fullPathToFile;
385 std::string MuonEfficiencyScaleFactors::filename_Central()
const{
386 if (!m_custom_file_Combined.empty())
return (resolve_file_location(m_custom_file_Combined));
387 else if (m_Type == MuonEfficiencyType::Iso) {
388 return resolve_file_location(Form(
"Iso_%s_Z.root", m_wp.c_str()));
389 }
else if (m_Type == MuonEfficiencyType::TTVA) {
390 return resolve_file_location(
"TTVA_Z.root");
391 }
else if (m_Type == MuonEfficiencyType::BadMuonVeto) {
392 return resolve_file_location(
"BadMuonVeto_HighPt_Z.root");
393 }
else if (m_Type == MuonEfficiencyType::Reco) {
394 return resolve_file_location(Form(
"Reco_%s_Z.root", m_wp.c_str()));
399 std::string MuonEfficiencyScaleFactors::filename_LRTCentral()
const{
400 if (!m_custom_file_LRTCombined.empty())
return (resolve_file_location(m_custom_file_LRTCombined));
401 else if (m_Type == MuonEfficiencyType::Iso) {
403 return resolve_file_location(Form(
"Iso_%s_Z.root", m_wp.c_str()));
404 }
else if (m_Type == MuonEfficiencyType::TTVA) {
406 return resolve_file_location(
"TTVA_Z.root");
407 }
else if (m_Type == MuonEfficiencyType::BadMuonVeto) {
409 return resolve_file_location(
"BadMuonVeto_HighPt_Z.root");
410 }
else if (m_Type == MuonEfficiencyType::Reco) {
411 return resolve_file_location(Form(
"Reco_%sLRT_Z.root", m_wp.c_str()));
416 std::string MuonEfficiencyScaleFactors::filename_Calo()
const{
418 if (!m_custom_file_Calo.empty())
return resolve_file_location(m_custom_file_Calo);
419 else if (m_Type != MuonEfficiencyType::Reco) {
420 return filename_Central();
421 }
else return resolve_file_location(
"Reco_CaloTag_Z.root");
423 std::string MuonEfficiencyScaleFactors::filename_HighEta()
const {
425 if (!m_custom_file_HighEta.empty())
return resolve_file_location(m_custom_file_HighEta);
426 else if (m_Type != MuonEfficiencyType::Reco) {
427 return filename_Central();
428 }
else return resolve_file_location(
"Reco_HighEta_Z.root");
430 std::string MuonEfficiencyScaleFactors::filename_LowPt()
const {
432 if (!m_custom_file_LowPt.empty())
return resolve_file_location(m_custom_file_LowPt);
434 else if (m_Type != MuonEfficiencyType::Reco || m_lowpt_threshold < 0) {
435 return filename_Central();
436 }
else return resolve_file_location(Form(
"Reco_%s_JPsi.root", m_wp.c_str()));
438 std::string MuonEfficiencyScaleFactors::filename_LRTLowPt()
const {
440 if (!m_custom_file_LRTLowPt.empty())
return resolve_file_location(m_custom_file_LRTLowPt);
442 else if (m_Type != MuonEfficiencyType::Reco || m_lowpt_threshold < 0 || m_calibration_version.find(
"run3") != std::string::npos) {
443 return filename_LRTCentral();
444 }
else return resolve_file_location(Form(
"Reco_%sLRT_JPsi.root", m_wp.c_str()));
446 std::string MuonEfficiencyScaleFactors::filename_LowPtCalo()
const{
448 if (!m_custom_file_LowPtCalo.empty())
return resolve_file_location(m_custom_file_LowPtCalo);
450 else if (m_Type != MuonEfficiencyType::Reco || m_lowpt_threshold < 0) {
451 return filename_Central();
452 }
else return resolve_file_location(
"Reco_CaloTag_JPsi.root");
456 StatusCode MuonEfficiencyScaleFactors::LoadInputs() {
457 if (!m_sf_sets.empty()){
459 return StatusCode::SUCCESS;
461 std::map<std::string, unsigned int>
systematics = lookUpSystematics();
465 ATH_MSG_FATAL(
"No valid systematic could be loaded. Not even the statistical uncertainties");
466 return StatusCode::FAILURE;
470 m_sf_sets.push_back( std::make_unique<EffiCollection>(*
this));
471 EffiCollection* nominal = m_sf_sets.back().get();
473 std::function<
unsigned int(
unsigned int,
unsigned int)> not_inB = [](
unsigned int a ,
unsigned int b){
474 unsigned int b_flipped = ~b;
475 return a & b_flipped;
480 if ((syst.second & EffiCollection::ZAnalysis) && (syst.second & EffiCollection::JPsiAnalysis)) {
482 m_sf_sets.push_back(std::make_unique < EffiCollection > (nominal, *
this, syst.first, not_inB(syst.second, EffiCollection::ZAnalysis),
false));
483 m_sf_sets.push_back(std::make_unique < EffiCollection > (nominal, *
this, syst.first, not_inB(syst.second, EffiCollection::ZAnalysis),
true));
485 m_sf_sets.push_back(std::make_unique < EffiCollection > (nominal, *
this, syst.first, not_inB(syst.second, EffiCollection::JPsiAnalysis),
true));
486 m_sf_sets.push_back(std::make_unique < EffiCollection > (nominal, *
this, syst.first, not_inB(syst.second, EffiCollection::JPsiAnalysis),
false));
488 m_sf_sets.push_back(std::make_unique < EffiCollection > (nominal, *
this, syst.first, syst.second,
false));
489 m_sf_sets.push_back(std::make_unique < EffiCollection > (nominal, *
this, syst.first, syst.second,
true));
492 for(
auto& sf: m_sf_sets){
493 if (!sf->CheckConsistency()) {
494 ATH_MSG_FATAL(
"Inconsistent scalefactor maps have been found for "<<(sf->getSystSet() ?sf->getSystSet()->name() :
"UNKOWN"));
495 return StatusCode::FAILURE;
498 for (
auto& sf_set : m_sf_sets)
499 addSubtool (*sf_set);
500 return StatusCode::SUCCESS;
502 std::map<std::string, unsigned int> MuonEfficiencyScaleFactors::lookUpSystematics(){
503 std::map<std::string, unsigned int> syst_map;
506 std::set<std::string> files_to_look_up{
514 files_to_look_up.insert(filename_LRTCentral());
515 files_to_look_up.insert(filename_LRTLowPt());
517 std::function<int(
const std::string&)> get_bit = [
this](
const std::string& file_name){
518 if (file_name == filename_Central())
return EffiCollection::Central;
519 if (file_name == filename_LowPt())
return EffiCollection::CentralLowPt;
520 if (file_name == filename_Calo())
return EffiCollection::Calo;
521 if (file_name == filename_LowPtCalo())
return EffiCollection::CaloLowPt;
522 if (this->use_lrt()) {
523 if (file_name == filename_LRTCentral())
return EffiCollection::LRTCentral;
524 if (file_name == filename_LRTLowPt())
return EffiCollection::LRTCentralLowPt;
527 return EffiCollection::Forward;
530 std::function<void(
const std::string&,
int)> insert_bit =[&syst_map](
const std::string& key,
unsigned int bit){
531 if (syst_map.find(key) == syst_map.end()) syst_map.insert(std::pair<std::string, unsigned int>(key,bit));
532 else syst_map[key] = syst_map[key] | bit;
534 for (
const auto& look_up : files_to_look_up){
535 std::unique_ptr<TFile> root_file(TFile::Open(look_up.c_str(),
"READ"));
536 if (!root_file || !root_file->IsOpen()){
543 if (measurement() != MuonEfficiencyType::BadMuonVeto){
544 insert_bit(
"STAT", get_bit(look_up));
547 if (m_seperateSystBins) insert_bit(
"STAT", EffiCollection::UnCorrelated);
549 TTree* syst_tree =
nullptr;
550 root_file->GetObject(
"Systematics", syst_tree);
554 if (!m_breakDownSyst || syst_tree ==
nullptr){
555 ATH_MSG_DEBUG(
"The file "<<look_up<<
" does not contain any systematic tree. No break down for that one will be considered");
556 insert_bit(
"SYS",get_bit(look_up));
558 if (m_applyKineDepSys && (measurement() == MuonEfficiencyType::Reco || measurement() == MuonEfficiencyType::BadMuonVeto)){
559 insert_bit(
"SYS", EffiCollection::PtDependent);
564 std::string* syst_name =
nullptr;
565 bool is_symmetric(0), has_pt_sys(0), uncorrelated(0);
566 if (syst_tree->SetBranchAddress(
"Name", &syst_name) != 0 ||
567 syst_tree->SetBranchAddress(
"IsSymmetric", &is_symmetric) != 0 ||
568 syst_tree->SetBranchAddress(
"HasPtDependentSys", &has_pt_sys) !=0 ||
569 syst_tree->SetBranchAddress(
"CanBeUncorrelated", &uncorrelated) !=0){
572 ATH_MSG_FATAL(
"Although "<<look_up<<
" has a systematic tree. There is no proper connection to the branches");
576 for (
int i =0; syst_tree->GetEntry(i); ++i){
577 insert_bit( *syst_name, get_bit(look_up));
578 if (is_symmetric) insert_bit(*syst_name, EffiCollection::Symmetric);
580 if (m_applyKineDepSys && has_pt_sys) {
581 insert_bit(*syst_name, EffiCollection::PtDependent);
582 }
if (m_seperateSystBins && uncorrelated) insert_bit(*syst_name, EffiCollection::UnCorrelated);
588 return m_affectingSys.find(systematic) != m_affectingSys.end();
592 if (!m_affectingSys.empty())
return m_affectingSys;
594 for (
auto& collection : m_sf_sets){
595 if (!collection->getSystSet()){
596 ATH_MSG_FATAL(
"No systematic defined for scale-factor map. ");
599 result.insert(*collection->getSystSet());
610 return affectingSystematics();
612 StatusCode MuonEfficiencyScaleFactors::applySystematicVariation(
const CP::SystematicSet& systConfig) {
615 return StatusCode::FAILURE;
619 std::unordered_map<CP::SystematicSet, EffiCollection*>::const_iterator itr = m_filtered_sys_sets.find (systConfig);
623 if (itr == m_filtered_sys_sets.end()) {
625 ATH_MSG_ERROR(
"Unsupported combination of systematics passed to the tool! ");
626 return StatusCode::FAILURE;
628 itr = m_filtered_sys_sets.find(mySysConf);
632 if (itr == m_filtered_sys_sets.end()){
633 std::vector<std::unique_ptr<EffiCollection>>
::const_iterator coll_itr = std::find_if(m_sf_sets.begin(), m_sf_sets.end(),[&mySysConf](
const std::unique_ptr<EffiCollection>&
a){return a->isAffectedBySystematic(mySysConf);});
634 if (coll_itr == m_sf_sets.end()){
636 return StatusCode::FAILURE;
638 m_filtered_sys_sets.insert(std::pair<CP::SystematicSet, EffiCollection*>(systConfig, coll_itr->get()));
639 itr = m_filtered_sys_sets.find(systConfig);
641 m_current_sf = itr->second;
643 if (m_seperateSystBins && !itr->first.name().empty()){
644 for (std::set<CP::SystematicVariation>::const_iterator t = mySysConf.
begin(); t != mySysConf.
end(); ++t) {
645 if ((*t).isToyVariation()) {
649 std::pair<unsigned, float>
pair = (*t).getToyVariation();
650 if (
pair.first != 0 && !m_current_sf->SetSystematicBin(
pair.first)){
651 ATH_MSG_WARNING(
"Could not apply systematic " << (*t).name() <<
" for bin " <<
pair.first);
652 return StatusCode::FAILURE;
654 return StatusCode::SUCCESS;
658 return StatusCode::SUCCESS;
660 std::string MuonEfficiencyScaleFactors::getUncorrelatedSysBinName(
unsigned int Bin)
const {
662 throw std::runtime_error(
"No systematic has been loaded. Cannot return any syst-bin") ;
663 ATH_MSG_FATAL(
"No systematic has been loaded. Cannot return any syst-bin");
666 return m_current_sf->GetBinName(Bin);
668 int MuonEfficiencyScaleFactors::getUnCorrelatedSystBin(
const xAOD::Muon& mu)
const {
670 ATH_MSG_WARNING(
"No systematic has been loaded. Cannot return any syst-bin");
673 return m_current_sf->getUnCorrelatedSystBin(mu);
675 std::string MuonEfficiencyScaleFactors::getUncorrelatedSysBinName(
const CP::SystematicSet& systConfig)
const {
676 for (std::set<CP::SystematicVariation>::const_iterator t = systConfig.
begin(); t != systConfig.
end(); ++t) {
677 if ((*t).isToyVariation()) {
678 std::pair<unsigned, float>
pair = (*t).getToyVariation();
679 return getUncorrelatedSysBinName(
pair.first);
682 ATH_MSG_ERROR(
"The given systematic " << systConfig.
name() <<
" is not an unfolded one. Return unknown bin ");
683 return "unknown bin";
688 const auto& acc = *m_accessors;
692 switch (getEfficiencyScaleFactor(muon, sf, event).code())
695 acc.sfDec(muon) = sf;
696 acc.validDec(muon) =
true;
699 acc.sfDec(muon) = sf;
700 acc.validDec(muon) =
false;
703 throw std::runtime_error(
"Error in getEfficiencyScaleFactor");
709 const auto& acc = *m_accessors;
712 auto eventInfo = acc.eventInfoCol(event);
713 callSingleEvent (acc.muons(event), eventInfo);