Skip to content
Snippets Groups Projects
Commit 23d214bf authored by Vakhtang Tsulaia's avatar Vakhtang Tsulaia
Browse files

Merge branch 'btag-cleanup-boilerplate' into 'master'

Remove boilerplate code from BTagging and FlavorTagDiscriminants

See merge request atlas/athena!35084
parents 5d8f36a8 a435b2ff
No related branches found
No related tags found
No related merge requests found
......@@ -3,11 +3,12 @@
from AthenaCommon.CFElements import findAllAlgorithms
from AthenaCommon.AthenaCommonFlags import jobproperties as jps
from GaudiKernel.Configurable import WARNING
def FtagJetCollection(jetcol, seq):
def FtagJetCollection(jetcol, seq, OutputLevel=WARNING):
jetcol_name_without_Jets = jetcol.replace('Jets','')
......@@ -99,6 +100,7 @@ def FtagJetCollection(jetcol, seq):
options['JetLinkName'] = options['BTaggingCollectionName'] + '.jetLink'
options['BTagTrackToJetAssociatorName'] = 'BTagTrackToJetAssociator'
options['name'] = ( 'BTagging_'+jetcol_name_without_Jets+ '_Augment').lower()
options['OutputLevel'] = OutputLevel
acc.addEventAlgo(Analysis__BTagHighLevelAugmenterAlg(**options))
......
......@@ -25,44 +25,7 @@ public:
void augment(const xAOD::Jet &jet);
void augment(const xAOD::Jet &jet, const xAOD::Jet &uncalibrated_jet);
std::string get_pt_uncalib_key();
std::string get_eta_uncalib_key();
std::string get_abs_eta_uncalib_key();
std::string get_ip2d_nTrks_key();
std::string get_ip2d_isDefaults_key();
std::string get_ip2d_cu_key();
std::string get_ip2d_bu_key();
std::string get_ip2d_bc_key();
std::string get_ip3d_nTrks_key();
std::string get_ip3d_isDefaults_key();
std::string get_ip3d_cu_key();
std::string get_ip3d_bu_key();
std::string get_ip3d_bc_key();
std::string get_jf_isDefaults_key();
std::string get_jf_deltaR_key();
std::string get_sv1_isDefaults_key();
std::string get_secondaryVtx_isDefaults_key();
std::string get_secondaryVtx_nTrks_key();
std::string get_secondaryVtx_m_key();
std::string get_secondaryVtx_E_key();
std::string get_secondaryVtx_EFrac_key();
std::string get_secondaryVtx_L3d_key();
std::string get_secondaryVtx_Lxy_key();
std::string get_secondaryVtx_min_trk_flightDirRelEta_key();
std::string get_secondaryVtx_max_trk_flightDirRelEta_key();
std::string get_secondaryVtx_avg_trk_flightDirRelEta_key();
std::string get_min_trk_flightDirRelEta_key();
std::string get_max_trk_flightDirRelEta_key();
std::string get_avg_trk_flightDirRelEta_key();
std::string get_smt_isDefaults_key();
std::string get_rnnip_isDefaults_key();
std::vector<std::string> getDecoratorKeys() const;
private:
bool jfIsDefaults(const xAOD::BTagging &btag);
......
......@@ -117,128 +117,44 @@ BTagJetAugmenter::BTagJetAugmenter(std::string associator, FlavorTagDiscriminant
BTagJetAugmenter::~BTagJetAugmenter() = default;
BTagJetAugmenter::BTagJetAugmenter(BTagJetAugmenter&&) = default;
std::string BTagJetAugmenter::get_pt_uncalib_key() {
return SG::AuxTypeRegistry::instance().getName( m_pt_uncalib.auxid() );
}
std::string BTagJetAugmenter::get_eta_uncalib_key() {
return SG::AuxTypeRegistry::instance().getName( m_eta_uncalib.auxid() );
}
std::string BTagJetAugmenter:: get_abs_eta_uncalib_key() {
return SG::AuxTypeRegistry::instance().getName( m_abs_eta_uncalib.auxid() );
}
std::string BTagJetAugmenter::get_ip2d_nTrks_key() {
return SG::AuxTypeRegistry::instance().getName( m_ip2d_nTrks.auxid() );
}
std::string BTagJetAugmenter::get_ip2d_isDefaults_key() {
return SG::AuxTypeRegistry::instance().getName( m_ip2d_isDefaults.auxid() );
}
std::string BTagJetAugmenter::get_ip2d_cu_key() {
return SG::AuxTypeRegistry::instance().getName( m_ip2d_cu.auxid() );
}
std::string BTagJetAugmenter::get_ip2d_bu_key() {
return SG::AuxTypeRegistry::instance().getName( m_ip2d_bu.auxid() );
}
std::string BTagJetAugmenter::get_ip2d_bc_key() {
return SG::AuxTypeRegistry::instance().getName( m_ip2d_bc.auxid() );
}
std::string BTagJetAugmenter::get_ip3d_nTrks_key() {
return SG::AuxTypeRegistry::instance().getName( m_ip3d_nTrks.auxid() );
}
std::string BTagJetAugmenter::get_ip3d_isDefaults_key() {
return SG::AuxTypeRegistry::instance().getName( m_ip3d_isDefaults.auxid() );
}
std::string BTagJetAugmenter::get_ip3d_cu_key() {
return SG::AuxTypeRegistry::instance().getName( m_ip3d_cu.auxid() );
}
std::string BTagJetAugmenter::get_ip3d_bu_key() {
return SG::AuxTypeRegistry::instance().getName( m_ip3d_bu.auxid() );
}
std::string BTagJetAugmenter::get_ip3d_bc_key() {
return SG::AuxTypeRegistry::instance().getName( m_ip3d_bc.auxid() );
}
std::string BTagJetAugmenter::get_jf_isDefaults_key() {
return SG::AuxTypeRegistry::instance().getName( m_jf_isDefaults.auxid() );
}
std::string BTagJetAugmenter::get_jf_deltaR_key() {
return SG::AuxTypeRegistry::instance().getName( m_jf_deltaR.auxid() );
}
std::string BTagJetAugmenter::get_sv1_isDefaults_key() {
return SG::AuxTypeRegistry::instance().getName( m_sv1_isDefaults.auxid() );
}
std::string BTagJetAugmenter::get_secondaryVtx_isDefaults_key() {
return SG::AuxTypeRegistry::instance().getName( m_secondaryVtx_isDefaults.auxid() );
}
std::string BTagJetAugmenter::get_secondaryVtx_nTrks_key() {
return SG::AuxTypeRegistry::instance().getName( m_secondaryVtx_nTrks.auxid() );
}
std::string BTagJetAugmenter::get_secondaryVtx_m_key() {
return SG::AuxTypeRegistry::instance().getName( m_secondaryVtx_m.auxid() );
}
std::string BTagJetAugmenter::get_secondaryVtx_E_key() {
return SG::AuxTypeRegistry::instance().getName( m_secondaryVtx_E.auxid() );
}
std::string BTagJetAugmenter::get_secondaryVtx_EFrac_key() {
return SG::AuxTypeRegistry::instance().getName( m_secondaryVtx_EFrac.auxid() );
}
std::string BTagJetAugmenter::get_secondaryVtx_L3d_key() {
return SG::AuxTypeRegistry::instance().getName( m_secondaryVtx_L3d.auxid() );
}
std::string BTagJetAugmenter::get_secondaryVtx_Lxy_key() {
return SG::AuxTypeRegistry::instance().getName( m_secondaryVtx_Lxy.auxid() );
}
std::string BTagJetAugmenter::get_secondaryVtx_min_trk_flightDirRelEta_key() {
return SG::AuxTypeRegistry::instance().getName( m_secondaryVtx_min_trk_flightDirRelEta.auxid() );
}
std::string BTagJetAugmenter::get_secondaryVtx_max_trk_flightDirRelEta_key() {
return SG::AuxTypeRegistry::instance().getName( m_secondaryVtx_max_trk_flightDirRelEta.auxid() );
}
std::string BTagJetAugmenter::get_secondaryVtx_avg_trk_flightDirRelEta_key() {
return SG::AuxTypeRegistry::instance().getName( m_secondaryVtx_avg_trk_flightDirRelEta.auxid() );
}
std::string BTagJetAugmenter::get_min_trk_flightDirRelEta_key() {
return SG::AuxTypeRegistry::instance().getName( m_min_trk_flightDirRelEta.auxid() );
}
std::string BTagJetAugmenter::get_max_trk_flightDirRelEta_key() {
return SG::AuxTypeRegistry::instance().getName( m_max_trk_flightDirRelEta.auxid() );
}
std::string BTagJetAugmenter::get_avg_trk_flightDirRelEta_key() {
return SG::AuxTypeRegistry::instance().getName( m_avg_trk_flightDirRelEta.auxid() );
}
std::string BTagJetAugmenter::get_smt_isDefaults_key() {
return SG::AuxTypeRegistry::instance().getName( m_smt_isDefaults.auxid() );
}
std::string BTagJetAugmenter::get_rnnip_isDefaults_key() {
return SG::AuxTypeRegistry::instance().getName( m_rnnip_isDefaults.auxid() );
std::vector<std::string> BTagJetAugmenter::getDecoratorKeys() const {
const auto& type_registry = SG::AuxTypeRegistry::instance();
std::vector<std::string> keys;
for (const auto& auxid: {
m_pt_uncalib.auxid(),
m_eta_uncalib.auxid(),
m_abs_eta_uncalib.auxid(),
m_ip2d_nTrks.auxid(),
m_ip2d_isDefaults.auxid(),
m_ip2d_cu.auxid(),
m_ip2d_bu.auxid(),
m_ip2d_bc.auxid(),
m_ip3d_nTrks.auxid(),
m_ip3d_isDefaults.auxid(),
m_ip3d_cu.auxid(),
m_ip3d_bu.auxid(),
m_ip3d_bc.auxid(),
m_jf_isDefaults.auxid(),
m_jf_deltaR.auxid(),
m_sv1_isDefaults.auxid(),
m_secondaryVtx_isDefaults.auxid(),
m_secondaryVtx_nTrks.auxid(),
m_secondaryVtx_m.auxid(),
m_secondaryVtx_E.auxid(),
m_secondaryVtx_EFrac.auxid(),
m_secondaryVtx_L3d.auxid(),
m_secondaryVtx_Lxy.auxid(),
m_secondaryVtx_min_trk_flightDirRelEta.auxid(),
m_secondaryVtx_max_trk_flightDirRelEta.auxid(),
m_secondaryVtx_avg_trk_flightDirRelEta.auxid(),
m_min_trk_flightDirRelEta.auxid(),
m_max_trk_flightDirRelEta.auxid(),
m_avg_trk_flightDirRelEta.auxid(),
m_smt_isDefaults.auxid(),
m_rnnip_isDefaults.auxid()}) {
keys.push_back(type_registry.getName(auxid));
}
return keys;
}
void BTagJetAugmenter::augment(const xAOD::Jet &jet, const xAOD::Jet &uncalibrated_jet) {
......
......@@ -38,49 +38,14 @@ namespace Analysis {
typedef SG::AuxElement AE;
// Decorator keys will be modified at run-time to conform to the correct container name
// For the run-time update to work, the decoration key name properties must start with a period (".")
SG::WriteDecorHandleKey< xAOD::BTaggingContainer > m_dec_pt_uncalib {this, "pt_uncalib", "", ""};
SG::WriteDecorHandleKey< xAOD::BTaggingContainer > m_dec_eta_uncalib {this, "eta_uncalib", "", ""};
SG::WriteDecorHandleKey< xAOD::BTaggingContainer > m_dec_abs_eta_uncalib {this, "abs_eta_uncalib", "", ""};
SG::WriteDecorHandleKey< xAOD::BTaggingContainer > m_dec_ip2d_nTrks {this, "ip2d_nTrks", "", ""};
SG::WriteDecorHandleKey< xAOD::BTaggingContainer > m_dec_ip2d_isDefaults {this, "ip2d_isDefaults", "", ""};
SG::WriteDecorHandleKey< xAOD::BTaggingContainer > m_dec_ip2d_cu {this, "ip2d_cu", "", ""};
SG::WriteDecorHandleKey< xAOD::BTaggingContainer > m_dec_ip2d_bu {this, "ip2d_bu", "", "" };
SG::WriteDecorHandleKey< xAOD::BTaggingContainer > m_dec_ip2d_bc {this, "ip2d_bc", "", ""};
SG::WriteDecorHandleKey< xAOD::BTaggingContainer > m_dec_ip3d_nTrks {this, "ip3d_nTrks", "", ""};
SG::WriteDecorHandleKey< xAOD::BTaggingContainer > m_dec_ip3d_isDefaults {this, "ip3d_isDefaults", "", ""};
SG::WriteDecorHandleKey< xAOD::BTaggingContainer > m_dec_ip3d_cu {this, "ip3d_cu", "", ""};
SG::WriteDecorHandleKey< xAOD::BTaggingContainer > m_dec_ip3d_bu {this, "ip3d_bu", "", "" };
SG::WriteDecorHandleKey< xAOD::BTaggingContainer > m_dec_ip3d_bc {this, "ip3d_bc", "", ""};
SG::WriteDecorHandleKey< xAOD::BTaggingContainer > m_dec_jf_isDefaults {this, "jf_isDefaults", "", ""};
SG::WriteDecorHandleKey< xAOD::BTaggingContainer > m_dec_jf_deltaR {this, "jf_deltaR", "", ""};
SG::WriteDecorHandleKey< xAOD::BTaggingContainer > m_dec_sv1_isDefaults {this, "sv1_isDefaults", "", ""};
SG::WriteDecorHandleKey< xAOD::BTaggingContainer > m_dec_secondaryVtx_isDefaults {this, "secondaryVtx_isDefaults", "", ""};
SG::WriteDecorHandleKey< xAOD::BTaggingContainer > m_dec_secondaryVtx_nTrks {this, "secondaryVtx_nTrks", "", ""};
SG::WriteDecorHandleKey< xAOD::BTaggingContainer > m_dec_secondaryVtx_m {this, "secondaryVtx_m", "", ""};
SG::WriteDecorHandleKey< xAOD::BTaggingContainer > m_dec_secondaryVtx_E {this, "secondaryVtx_E", "", ""};
SG::WriteDecorHandleKey< xAOD::BTaggingContainer > m_dec_secondaryVtx_EFrac {this, "secondaryVtx_EFrac", "", ""};
SG::WriteDecorHandleKey< xAOD::BTaggingContainer > m_dec_secondaryVtx_L3d {this, "secondaryVtx_L3d", "", ""};
SG::WriteDecorHandleKey< xAOD::BTaggingContainer > m_dec_secondaryVtx_Lxy {this, "secondaryVtx_Lxy", "", ""};
SG::WriteDecorHandleKey< xAOD::BTaggingContainer > m_dec_secondaryVtx_min_trk_flightDirRelEta {this, "secondaryVtx_min_trk_flightDirRelEta", "", ""};
SG::WriteDecorHandleKey< xAOD::BTaggingContainer > m_dec_secondaryVtx_max_trk_flightDirRelEta {this, "secondaryVtx_max_trk_flightDirRelEta", "", ""};
SG::WriteDecorHandleKey< xAOD::BTaggingContainer > m_dec_secondaryVtx_avg_trk_flightDirRelEta {this, "secondaryVtx_avg_trk_flightDirRelEta", "", ""};
SG::WriteDecorHandleKey< xAOD::BTaggingContainer > m_dec_min_trk_flightDirRelEta {this, "min_trk_flightDirRelEta", "", ""};
SG::WriteDecorHandleKey< xAOD::BTaggingContainer > m_dec_max_trk_flightDirRelEta {this, "max_trk_flightDirRelEta", "", ""};
SG::WriteDecorHandleKey< xAOD::BTaggingContainer > m_dec_avg_trk_flightDirRelEta {this, "avg_trk_flightDirRelEta", "", ""};
SG::WriteDecorHandleKey< xAOD::BTaggingContainer > m_dec_smt_isDefaults {this, "smt_isDefaults", "", ""};
SG::WriteDecorHandleKey< xAOD::BTaggingContainer > m_dec_rnnip_isDefaults {this, "rnnip_isDefaults", "", ""};
// Decorator keys will be created at run-time to conform to the
// correct container name.
std::vector<
std::unique_ptr<
SG::WriteDecorHandleKey<xAOD::BTaggingContainer>
>
> m_write_handles;
};
}
#endif
......@@ -36,84 +36,16 @@ namespace Analysis {
FlipTagConfig flipTagConf = FlavorTagDiscriminants::flipTagConfigFromString(m_flipTagConfig);
m_aug = std::make_unique<BTagJetAugmenter>(m_acc_jet_track_links, flipTagConf);
m_dec_pt_uncalib = m_BTagCollectionName.key() + "." + m_aug->get_pt_uncalib_key();
m_dec_eta_uncalib = m_BTagCollectionName.key() + "." + m_aug->get_eta_uncalib_key();
m_dec_abs_eta_uncalib = m_BTagCollectionName.key() + "." + m_aug->get_abs_eta_uncalib_key();
m_dec_ip2d_nTrks = m_BTagCollectionName.key() + "." + m_aug->get_ip2d_nTrks_key();
m_dec_ip2d_isDefaults = m_BTagCollectionName.key() + "." + m_aug->get_ip2d_isDefaults_key();
m_dec_ip2d_cu = m_BTagCollectionName.key() + "." + m_aug->get_ip2d_cu_key();
m_dec_ip2d_bu = m_BTagCollectionName.key() + "." + m_aug->get_ip2d_bu_key();
m_dec_ip2d_bc = m_BTagCollectionName.key() + "." + m_aug->get_ip2d_bc_key();
m_dec_ip3d_nTrks = m_BTagCollectionName.key() + "." + m_aug->get_ip3d_nTrks_key();
m_dec_ip3d_isDefaults = m_BTagCollectionName.key() + "." + m_aug->get_ip3d_isDefaults_key();
m_dec_ip3d_cu = m_BTagCollectionName.key() + "." + m_aug->get_ip3d_cu_key();
m_dec_ip3d_bu = m_BTagCollectionName.key() + "." + m_aug->get_ip2d_bu_key();
m_dec_ip3d_bc = m_BTagCollectionName.key() + "." + m_aug->get_ip2d_bc_key();
m_dec_jf_isDefaults = m_BTagCollectionName.key() + "." + m_aug->get_jf_isDefaults_key();
m_dec_jf_deltaR = m_BTagCollectionName.key() + "." + m_aug->get_jf_deltaR_key();
m_dec_sv1_isDefaults = m_BTagCollectionName.key() + "." + m_aug->get_sv1_isDefaults_key();
m_dec_secondaryVtx_isDefaults = m_BTagCollectionName.key() + "." + m_aug->get_secondaryVtx_isDefaults_key();
m_dec_secondaryVtx_nTrks = m_BTagCollectionName.key() + "." + m_aug->get_secondaryVtx_nTrks_key();
m_dec_secondaryVtx_m = m_BTagCollectionName.key() + "." + m_aug->get_secondaryVtx_m_key();
m_dec_secondaryVtx_E = m_BTagCollectionName.key() + "." + m_aug->get_secondaryVtx_E_key();
m_dec_secondaryVtx_EFrac = m_BTagCollectionName.key() + "." + m_aug->get_secondaryVtx_EFrac_key();
m_dec_secondaryVtx_L3d = m_BTagCollectionName.key() + "." + m_aug->get_secondaryVtx_L3d_key();
m_dec_secondaryVtx_Lxy = m_BTagCollectionName.key() + "." + m_aug->get_secondaryVtx_Lxy_key();
m_dec_secondaryVtx_min_trk_flightDirRelEta = m_BTagCollectionName.key() + "." + m_aug->get_secondaryVtx_min_trk_flightDirRelEta_key();
m_dec_secondaryVtx_max_trk_flightDirRelEta = m_BTagCollectionName.key() + "." + m_aug->get_secondaryVtx_max_trk_flightDirRelEta_key();
m_dec_secondaryVtx_avg_trk_flightDirRelEta = m_BTagCollectionName.key() + "." + m_aug->get_secondaryVtx_avg_trk_flightDirRelEta_key();
m_dec_min_trk_flightDirRelEta = m_BTagCollectionName.key() + "." + m_aug->get_min_trk_flightDirRelEta_key();
m_dec_max_trk_flightDirRelEta = m_BTagCollectionName.key() + "." + m_aug->get_max_trk_flightDirRelEta_key();
m_dec_avg_trk_flightDirRelEta = m_BTagCollectionName.key() + "." + m_aug->get_avg_trk_flightDirRelEta_key();
m_dec_smt_isDefaults = m_BTagCollectionName.key() + "." + m_aug->get_smt_isDefaults_key();
m_dec_rnnip_isDefaults = m_BTagCollectionName.key() + "." + m_aug->get_rnnip_isDefaults_key();
CHECK( m_dec_pt_uncalib.initialize() );
CHECK( m_dec_eta_uncalib.initialize() );
CHECK( m_dec_abs_eta_uncalib.initialize() );
CHECK( m_dec_ip2d_nTrks.initialize() );
CHECK( m_dec_ip2d_isDefaults.initialize() );
CHECK( m_dec_ip2d_cu.initialize() );
CHECK( m_dec_ip2d_bu.initialize() );
CHECK( m_dec_ip2d_bc.initialize() );
CHECK( m_dec_ip3d_nTrks.initialize() );
CHECK( m_dec_ip3d_isDefaults.initialize() );
CHECK( m_dec_ip3d_cu.initialize() );
CHECK( m_dec_ip3d_bu.initialize() );
CHECK( m_dec_ip3d_bc.initialize() );
CHECK( m_dec_jf_isDefaults.initialize() );
CHECK( m_dec_jf_deltaR.initialize() );
CHECK( m_dec_sv1_isDefaults.initialize() );
CHECK( m_dec_secondaryVtx_isDefaults.initialize() );
CHECK( m_dec_secondaryVtx_nTrks.initialize() );
CHECK( m_dec_secondaryVtx_m.initialize() );
CHECK( m_dec_secondaryVtx_E.initialize() );
CHECK( m_dec_secondaryVtx_EFrac.initialize() );
CHECK( m_dec_secondaryVtx_L3d.initialize() );
CHECK( m_dec_secondaryVtx_Lxy.initialize() );
CHECK( m_dec_secondaryVtx_min_trk_flightDirRelEta.initialize() );
CHECK( m_dec_secondaryVtx_max_trk_flightDirRelEta.initialize() );
CHECK( m_dec_secondaryVtx_avg_trk_flightDirRelEta.initialize() );
CHECK( m_dec_min_trk_flightDirRelEta.initialize() );
CHECK( m_dec_max_trk_flightDirRelEta.initialize() );
CHECK( m_dec_avg_trk_flightDirRelEta.initialize() );
CHECK( m_dec_smt_isDefaults.initialize() );
CHECK( m_dec_rnnip_isDefaults.initialize() );
// create and initialize write handles
for (const std::string& key: m_aug->getDecoratorKeys()) {
std::string full_key = m_BTagCollectionName.key() + "." + key;
ATH_MSG_DEBUG("Adding " << full_key);
m_write_handles.emplace_back(
std::make_unique<SG::WriteDecorHandleKey<xAOD::BTaggingContainer>>(
this, key, full_key, ""));
ATH_MSG_DEBUG("Initializing " << full_key);
ATH_CHECK(m_write_handles.back()->initialize());
}
return StatusCode::SUCCESS;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment