Skip to content

Commit

Permalink
Fix conflicts with GN2 additions
Browse files Browse the repository at this point in the history
add flavorTagTLA option for jets

Conflicts:
	Root/JetContainer.cxx
  • Loading branch information
sfranchel authored and mamerl committed Apr 24, 2024
1 parent 9e326b6 commit df8b715
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 22 deletions.
1 change: 1 addition & 0 deletions Root/HelperClasses.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ namespace HelperClasses{
m_constituentAll = has_exact("constituentAll");
m_flavorTag = has_exact("flavorTag");
m_flavorTagHLT = has_exact("flavorTagHLT");
m_flavorTagTLA = has_exact("flavorTagTLA");
m_btag_jettrk = has_exact("btag_jettrk");
m_jetFitterDetails = has_exact("jetFitterDetails");
m_svDetails = has_exact("svDetails");
Expand Down
126 changes: 104 additions & 22 deletions Root/JetContainer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,11 @@ JetContainer::JetContainer(const std::string& name, const std::string& detailStr
}

// flavorTag
if( m_infoSwitch.m_flavorTag || m_infoSwitch.m_flavorTagHLT || m_infoSwitch.m_flavorTagTLA ) {
m_HadronConeExclTruthLabelID =new std::vector<int>();
m_HadronConeExclExtendedTruthLabelID=new std::vector<int>();
}

if( m_infoSwitch.m_flavorTag || m_infoSwitch.m_flavorTagHLT ) {

m_DL1r =new std::vector<float>();
Expand All @@ -280,8 +285,6 @@ JetContainer::JetContainer(const std::string& name, const std::string& detailStr
m_GN2v00NewAliasWP_pu =new std::vector<float>();
m_GN2v00NewAliasWP_pc =new std::vector<float>();
m_GN2v00NewAliasWP_pb =new std::vector<float>();
m_HadronConeExclTruthLabelID =new std::vector<int>();
m_HadronConeExclExtendedTruthLabelID=new std::vector<int>();

// Jet Fitter
if( m_infoSwitch.m_jetFitterDetails){
Expand Down Expand Up @@ -392,6 +395,13 @@ JetContainer::JetContainer(const std::string& name, const std::string& detailStr
m_vtx_online_bkg_z0 = new std::vector<float>();
}

if( m_infoSwitch.m_flavorTagTLA ) {
m_fastDIPS =new std::vector<float>();
m_fastDIPS_pu =new std::vector<float>();
m_fastDIPS_pc =new std::vector<float>();
m_fastDIPS_pb =new std::vector<float>();
}

if( !m_infoSwitch.m_jetBTag.empty() ) {
std::stringstream ss_wpName;
for(const auto& btaginfo : m_infoSwitch.m_jetBTag)
Expand Down Expand Up @@ -723,7 +733,12 @@ JetContainer::~JetContainer()


// flavorTag
if( m_infoSwitch.m_flavorTag || m_infoSwitch.m_flavorTagHLT ) {
if( m_infoSwitch.m_flavorTag || m_infoSwitch.m_flavorTagHLT || m_infoSwitch.m_flavorTagTLA ) {
delete m_HadronConeExclTruthLabelID;
delete m_HadronConeExclExtendedTruthLabelID;
}

if( m_infoSwitch.m_flavorTag || m_infoSwitch.m_flavorTagHLT ) {
// flavorTag

delete m_DL1r;
Expand Down Expand Up @@ -751,9 +766,6 @@ JetContainer::~JetContainer()
delete m_GN2v00NewAliasWP_pc;
delete m_GN2v00NewAliasWP_pb;

delete m_HadronConeExclTruthLabelID;
delete m_HadronConeExclExtendedTruthLabelID;

// Jet Fitter
if( m_infoSwitch.m_jetFitterDetails){
delete m_JetFitter_nVTX ;
Expand Down Expand Up @@ -861,6 +873,13 @@ JetContainer::~JetContainer()
delete m_vtx_online_bkg_z0 ;
}

if( m_infoSwitch.m_flavorTagTLA ) {
delete m_fastDIPS;
delete m_fastDIPS_pu;
delete m_fastDIPS_pc;
delete m_fastDIPS_pb;
}

for(auto btag : m_btags)
delete btag;

Expand Down Expand Up @@ -1038,6 +1057,12 @@ void JetContainer::setTree(TTree *tree)
connectBranch<double>(tree,"JetVertexCharge_discriminant", &m_JetVertexCharge_discriminant);
}

if(m_infoSwitch.m_flavorTag || m_infoSwitch.m_flavorTagHLT || m_infoSwitch.m_flavorTagTLA)
{
connectBranch<int> (tree,"HadronConeExclTruthLabelID" ,&m_HadronConeExclTruthLabelID);
connectBranch<int> (tree,"HadronConeExclExtendedTruthLabelID",&m_HadronConeExclExtendedTruthLabelID);
}

if(m_infoSwitch.m_flavorTag || m_infoSwitch.m_flavorTagHLT)
{
connectBranch<float>(tree,"DL1r" ,&m_DL1r );
Expand All @@ -1064,8 +1089,6 @@ void JetContainer::setTree(TTree *tree)
connectBranch<float>(tree,"GN2v00NewAliasWP_pu" ,&m_GN2v00NewAliasWP_pu );
connectBranch<float>(tree,"GN2v00NewAliasWP_pc" ,&m_GN2v00NewAliasWP_pc );
connectBranch<float>(tree,"GN2v00NewAliasWP_pb" ,&m_GN2v00NewAliasWP_pb );
connectBranch<int> (tree,"HadronConeExclTruthLabelID" ,&m_HadronConeExclTruthLabelID);
connectBranch<int> (tree,"HadronConeExclExtendedTruthLabelID",&m_HadronConeExclExtendedTruthLabelID);
}

if(m_infoSwitch.m_flavorTagHLT)
Expand All @@ -1087,6 +1110,13 @@ void JetContainer::setTree(TTree *tree)
connectBranch<float>(tree,"vtx_online_bkg_y0", &m_vtx_online_bkg_y0);
connectBranch<float>(tree,"vtx_online_bkg_z0", &m_vtx_online_bkg_z0);
}
if(m_infoSwitch.m_flavorTagTLA)
{
connectBranch<float>(tree,"fastDIPS", &m_fastDIPS);
connectBranch<float>(tree,"fastDIPS_pu", &m_fastDIPS_pu);
connectBranch<float>(tree,"fastDIPS_pc", &m_fastDIPS_pc);
connectBranch<float>(tree,"fastDIPS_pb", &m_fastDIPS_pb);
}

if(m_infoSwitch.m_jetFitterDetails)
{
Expand Down Expand Up @@ -1305,6 +1335,12 @@ void JetContainer::updateParticle(uint idx, Jet& jet)
jet.JVC = m_JetVertexCharge_discriminant->at(idx);
}

if(m_infoSwitch.m_flavorTag || m_infoSwitch.m_flavorTagHLT || m_infoSwitch.m_flavorTagTLA)
{
if(m_HadronConeExclTruthLabelID) jet.HadronConeExclTruthLabelID =m_HadronConeExclTruthLabelID ->at(idx);
if(m_HadronConeExclExtendedTruthLabelID) jet.HadronConeExclExtendedTruthLabelID=m_HadronConeExclExtendedTruthLabelID->at(idx);
}

if(m_infoSwitch.m_flavorTag || m_infoSwitch.m_flavorTagHLT)
{
if(m_debug) std::cout << "updating flavorTag " << std::endl;
Expand Down Expand Up @@ -1334,8 +1370,6 @@ void JetContainer::updateParticle(uint idx, Jet& jet)
if(m_GN2v00NewAliasWP_pb) jet.GN2v00NewAliasWP_pb =m_GN2v00NewAliasWP_pb ->at(idx);

//std::cout << m_HadronConeExclTruthLabelID->size() << std::endl;
if(m_HadronConeExclTruthLabelID) jet.HadronConeExclTruthLabelID =m_HadronConeExclTruthLabelID ->at(idx);
if(m_HadronConeExclExtendedTruthLabelID) jet.HadronConeExclExtendedTruthLabelID=m_HadronConeExclExtendedTruthLabelID->at(idx);
if(m_debug) std::cout << "leave flavorTag " << std::endl;
}

Expand Down Expand Up @@ -1374,6 +1408,16 @@ void JetContainer::updateParticle(uint idx, Jet& jet)
jet.JetFitter_N2Tpar =m_JetFitter_N2Tpar ->at(idx);

}

if(m_infoSwitch.m_flavorTagTLA)
{
if(m_debug) std::cout << "updating flavorTagTLA " << std::endl;
if(m_fastDIPS) jet.fastDIPS =m_fastDIPS ->at(idx);
if(m_fastDIPS_pu) jet.fastDIPS_pu =m_fastDIPS_pu ->at(idx);
if(m_fastDIPS_pc) jet.fastDIPS_pc =m_fastDIPS_pc ->at(idx);
if(m_fastDIPS_pb) jet.fastDIPS_pb =m_fastDIPS_pb ->at(idx);
if(m_debug) std::cout << "leave flavorTagTLA " << std::endl;
}

if(m_infoSwitch.m_svDetails){

Expand Down Expand Up @@ -1842,6 +1886,11 @@ void JetContainer::setBranches(TTree *tree)
setBranch<std::vector<float> >(tree,"constituent_e", m_constituent_e );
}

if( m_infoSwitch.m_flavorTag || m_infoSwitch.m_flavorTagHLT || m_infoSwitch.m_flavorTagTLA ) {
setBranch<int>(tree,"HadronConeExclTruthLabelID", m_HadronConeExclTruthLabelID);
setBranch<int>(tree,"HadronConeExclExtendedTruthLabelID", m_HadronConeExclExtendedTruthLabelID);
}

if( m_infoSwitch.m_flavorTag || m_infoSwitch.m_flavorTagHLT ) {

setBranch<float>(tree,"DL1r", m_DL1r);
Expand All @@ -1868,8 +1917,6 @@ void JetContainer::setBranches(TTree *tree)
setBranch<float>(tree,"GN2v00NewAliasWP_pu", m_GN2v00NewAliasWP_pu);
setBranch<float>(tree,"GN2v00NewAliasWP_pc", m_GN2v00NewAliasWP_pc);
setBranch<float>(tree,"GN2v00NewAliasWP_pb", m_GN2v00NewAliasWP_pb);
setBranch<int >(tree,"HadronConeExclTruthLabelID", m_HadronConeExclTruthLabelID);
setBranch<int >(tree,"HadronConeExclExtendedTruthLabelID", m_HadronConeExclExtendedTruthLabelID);

if( m_infoSwitch.m_jetFitterDetails){

Expand Down Expand Up @@ -1980,6 +2027,13 @@ void JetContainer::setBranches(TTree *tree)

}

if( m_infoSwitch.m_flavorTagTLA ) {
setBranch<float>(tree,"fastDIPS", m_fastDIPS);
setBranch<float>(tree,"fastDIPS_pu", m_fastDIPS_pu);
setBranch<float>(tree,"fastDIPS_pc", m_fastDIPS_pc);
setBranch<float>(tree,"fastDIPS_pb", m_fastDIPS_pb);
}

if( !m_infoSwitch.m_jetBTag.empty() || !m_infoSwitch.m_jetBTagCts.empty() ) {
for(auto btag : m_btags)
btag->setBranch(tree, m_name);
Expand Down Expand Up @@ -2289,6 +2343,11 @@ void JetContainer::clear()
m_constituent_e ->clear();
}

if ( m_infoSwitch.m_flavorTag || m_infoSwitch.m_flavorTagHLT || m_infoSwitch.m_flavorTagTLA ) {
m_HadronConeExclTruthLabelID ->clear();
m_HadronConeExclExtendedTruthLabelID->clear();
}

// flavor tag
if ( m_infoSwitch.m_flavorTag || m_infoSwitch.m_flavorTagHLT ) {

Expand Down Expand Up @@ -2316,9 +2375,6 @@ void JetContainer::clear()
m_GN2v00NewAliasWP_pu ->clear();
m_GN2v00NewAliasWP_pc ->clear();
m_GN2v00NewAliasWP_pb ->clear();
m_HadronConeExclTruthLabelID ->clear();
m_HadronConeExclExtendedTruthLabelID->clear();


if( m_infoSwitch.m_jetFitterDetails){
m_JetFitter_nVTX ->clear();
Expand Down Expand Up @@ -2422,6 +2478,12 @@ void JetContainer::clear()

}

if ( m_infoSwitch.m_flavorTagTLA ) {
m_fastDIPS ->clear();
m_fastDIPS_pu ->clear();
m_fastDIPS_pc ->clear();
m_fastDIPS_pb ->clear();
}

if( !m_infoSwitch.m_jetBTag.empty() || !m_infoSwitch.m_jetBTagCts.empty()) { // just clear them all....
for(auto btag : m_btags)
Expand Down Expand Up @@ -3175,6 +3237,16 @@ void JetContainer::FillJet( const xAOD::IParticle* particle, const xAOD::Vertex*
m_constituent_e-> push_back( e );
}


if ( m_infoSwitch.m_flavorTag || m_infoSwitch.m_flavorTagHLT || m_infoSwitch.m_flavorTagTLA ) {
// flavor groups truth definition
static SG::AuxElement::ConstAccessor<int> hadConeExclTruthLabel("HadronConeExclTruthLabelID");
safeFill<int, int, xAOD::Jet>(jet, hadConeExclTruthLabel, m_HadronConeExclTruthLabelID, -999);

static SG::AuxElement::ConstAccessor<int> hadConeExclExtendedTruthLabel("HadronConeExclExtendedTruthLabelID");
safeFill<int, int, xAOD::Jet>(jet, hadConeExclExtendedTruthLabel, m_HadronConeExclExtendedTruthLabelID, -999);
}

if ( m_infoSwitch.m_flavorTag || m_infoSwitch.m_flavorTagHLT ) {
const xAOD::BTagging * myBTag(0);

Expand Down Expand Up @@ -3256,13 +3328,6 @@ void JetContainer::FillJet( const xAOD::IParticle* particle, const xAOD::Vertex*
m_GN2v00NewAliasWP_pb->push_back(pb);
m_GN2v00NewAliasWP->push_back( score );

// flavor groups truth definition
static SG::AuxElement::ConstAccessor<int> hadConeExclTruthLabel("HadronConeExclTruthLabelID");
safeFill<int, int, xAOD::Jet>(jet, hadConeExclTruthLabel, m_HadronConeExclTruthLabelID, -999);

static SG::AuxElement::ConstAccessor<int> hadConeExclExtendedTruthLabel("HadronConeExclExtendedTruthLabelID");
safeFill<int, int, xAOD::Jet>(jet, hadConeExclExtendedTruthLabel, m_HadronConeExclExtendedTruthLabelID, -999);

if(m_infoSwitch.m_jetFitterDetails ) {

static SG::AuxElement::ConstAccessor< int > jf_nVTXAcc ("JetFitter_nVTX");
Expand Down Expand Up @@ -3562,6 +3627,23 @@ void JetContainer::FillJet( const xAOD::IParticle* particle, const xAOD::Vertex*
if(m_debug) std::cout << "Done m_flavorTagHLT " << std::endl;
}

if (m_infoSwitch.m_flavorTagTLA){
if(m_debug) std::cout << "Filling m_flavorTagHLT " << std::endl;

float pu=0, pb=0, pc=0, score=0;
pu = jet->auxdata<float>( "fastDIPS20211215_pu" );
pc = jet->auxdata<float>( "fastDIPS20211215_pc" );
pb = jet->auxdata<float>( "fastDIPS20211215_pb" );
//FixMe: Retrieve the correct f_c value from the CDI file would be the best approach
score=log( pb / (0.018*pc+0.982*pu) );

m_fastDIPS_pu->push_back( pu );
m_fastDIPS_pc->push_back( pc );
m_fastDIPS_pb->push_back( pb );
m_fastDIPS->push_back( score );

if(m_debug) std::cout << "Done m_flavorTagTLA " << std::endl;
}

if( !m_infoSwitch.m_jetBTag.empty() || !m_infoSwitch.m_jetBTagCts.empty() ) {
for(auto btag : m_btags)
Expand Down
2 changes: 2 additions & 0 deletions xAODAnaHelpers/HelperClasses.h
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ namespace HelperClasses {
m_constituentAll constituentAll exact
m_flavorTag flavorTag exact
m_flavorTagHLT flavorTagHLT exact
m_flavorTagTLA flavorTagTLA exact
m_sfFTagFix sfFTagFix partial
m_sfFTagFlt sfFTagFlt partial
m_sfFTagHyb sfFTagHyb partial
Expand Down Expand Up @@ -543,6 +544,7 @@ namespace HelperClasses {
bool m_constituentAll;
bool m_flavorTag;
bool m_flavorTagHLT;
bool m_flavorTagTLA;
bool m_btag_jettrk;
bool m_jetFitterDetails;
bool m_svDetails;
Expand Down
4 changes: 4 additions & 0 deletions xAODAnaHelpers/Jet.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ namespace xAH {
float DL1dv01_pu;
float DL1dv01_pc;
float DL1dv01_pb;
float fastDIPS;
float fastDIPS_pu;
float fastDIPS_pc;
float fastDIPS_pb;
float GN1;
float GN1_pu;
float GN1_pc;
Expand Down

0 comments on commit df8b715

Please sign in to comment.