Skip to content

Commit

Permalink
Updates for GN2 and fix to InDetTrackSelectionTool
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Hank committed Nov 8, 2024
1 parent 1f23e8b commit 4b8ac58
Show file tree
Hide file tree
Showing 7 changed files with 179 additions and 91 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
release_type:
- analysisbase
release_version:
- 25.2.24
- 25.2.31

steps:
- uses: actions/checkout@master
Expand Down
215 changes: 142 additions & 73 deletions Root/BJetEfficiencyCorrector.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ EL::StatusCode BJetEfficiencyCorrector :: initialize ()
m_decorSF = m_decor + "_SF";
m_decorWeight = m_decor + "_Weight";
m_decorQuantile = m_decor + "_Quantile";
m_decorInefficiencySF = m_decor + "_InefficiencySF";

bool opOK(false),taggerOK(false);
m_getScaleFactors = false;
Expand Down Expand Up @@ -148,7 +147,6 @@ EL::StatusCode BJetEfficiencyCorrector :: initialize ()
m_outputSystName += "_" + m_taggerName + "_" + m_operatingPt;
m_decorWeight += "_" + m_taggerName + "_" + m_operatingPt;
m_decorQuantile += "_" + m_taggerName + "_" + m_operatingPt;
m_decorInefficiencySF += "_" + m_taggerName + "_" + m_operatingPt;

if(!m_useContinuous){
ANA_MSG_INFO( "Decision Decoration Name : " << m_decor);
Expand All @@ -157,7 +155,6 @@ EL::StatusCode BJetEfficiencyCorrector :: initialize ()
ANA_MSG_INFO( "Weight Decoration Name: " << m_decorWeight);
ANA_MSG_INFO( "Quantile Decoration Name: " << m_decorQuantile);
ANA_MSG_INFO( "Scale Factor Decoration Name : " << m_decorSF);
ANA_MSG_INFO( "Inefficiency Scale Factor Decoration Name : " << m_decorInefficiencySF);
}

// now take this name and convert it to the cut value for the CDI file
Expand Down Expand Up @@ -222,7 +219,7 @@ EL::StatusCode BJetEfficiencyCorrector :: initialize ()
std::string sampleName;
while(std::getline(ss,sampleName,','))
{
HelperFunctions::ShowerType mySampleShowerType=HelperFunctions::getMCShowerType(sampleName);
HelperFunctions::ShowerType mySampleShowerType=HelperFunctions::getMCShowerType(sampleName,m_taggerName);
if(mySampleShowerType!=sampleShowerType && sampleShowerType!=HelperFunctions::Unknown)
ANA_MSG_ERROR("Cannot have different shower types per grid task.");
sampleShowerType=mySampleShowerType;
Expand All @@ -231,75 +228,158 @@ EL::StatusCode BJetEfficiencyCorrector :: initialize ()
else // Use sample name when running locally
{
gridName=wk()->metaData()->castString(SH::MetaFields::sampleName);
sampleShowerType=HelperFunctions::getMCShowerType(gridName);
sampleShowerType=HelperFunctions::getMCShowerType(gridName,m_taggerName);
}

if(m_isRun3){
switch(sampleShowerType)
{
case HelperFunctions::Pythia8:
calibration="601229";
break;
case HelperFunctions::Herwig7p2:
calibration="601414";
break;
case HelperFunctions::Sherpa2212:
calibration="700660";
break;
default:
if(m_taggerName=="DL1dv01"){
if(m_isRun3){
switch(sampleShowerType)
{
case HelperFunctions::Pythia8:
calibration="601229";
break;
case HelperFunctions::Herwig7p2:
calibration="601414";
break;
case HelperFunctions::Sherpa2212:
calibration="700660";
break;
default:
if (m_allowCalibrationFallback) {
ANA_MSG_WARNING("Cannot determine MC shower type for sample " << gridName << ", falling back to 'default'.");
ANA_MSG_WARNING("Please double-check if this is appropriate for your sample, otherwise you have specify the MC-to-MC calibration manually!");
calibration="default";
break;
}
else {
ANA_MSG_ERROR("Cannot determine MC shower type for sample " << gridName << ".");
return EL::StatusCode::FAILURE;
break;
}
}
} else {

switch(sampleShowerType)
{
case HelperFunctions::Pythia8:
calibration="410470";
break;
case HelperFunctions::Herwig7p1:
calibration="411233";
break;
case HelperFunctions::Herwig7p2:
calibration="600666";
break;
case HelperFunctions::Sherpa221:
calibration="410250";
break;
case HelperFunctions::Sherpa2210:
calibration="700122";
break;
case HelperFunctions::Sherpa2212:
calibration="700660";
break;
case HelperFunctions::AmcPy8:
calibration="410464";
break;
case HelperFunctions::AmcH7:
calibration="412116";
break;
case HelperFunctions::Unknown:
if (m_allowCalibrationFallback) {
ANA_MSG_WARNING("Cannot determine MC shower type for sample " << gridName << ", falling back to 'default'.");
ANA_MSG_WARNING("Please double-check if this is appropriate for your sample, otherwise you have specify the MC-to-MC calibration manually!");
calibration="default";
break;
}
else {
ANA_MSG_ERROR("Cannot determine MC shower type for sample " << gridName << ".");
return EL::StatusCode::FAILURE;
break;
ANA_MSG_ERROR("Cannot determine MC shower type for sample " << gridName << ".");
return EL::StatusCode::FAILURE;
break;
}
}
}
} else {

switch(sampleShowerType)
{
case HelperFunctions::Pythia8:
calibration="410470";
break;
case HelperFunctions::Herwig7p1:
calibration="411233";
break;
case HelperFunctions::Herwig7p2:
calibration="600666";
break;
case HelperFunctions::Sherpa221:
calibration="410250";
break;
case HelperFunctions::Sherpa2210:
calibration="700122";
break;
case HelperFunctions::Sherpa2212:
calibration="700660";
break;
case HelperFunctions::AmcPy8:
calibration="410464";
break;
case HelperFunctions::AmcH7:
calibration="412116";
break;
case HelperFunctions::Unknown:
if (m_allowCalibrationFallback) {
ANA_MSG_WARNING("Cannot determine MC shower type for sample " << gridName << ", falling back to 'default'.");
ANA_MSG_WARNING("Please double-check if this is appropriate for your sample, otherwise you have specify the MC-to-MC calibration manually!");
calibration="default";
break;
} else if(m_taggerName=="GN2v01"){
if(m_isRun3){
switch(sampleShowerType)
{
case HelperFunctions::Pythia8_517:
calibration="601398";
break;
case HelperFunctions::Pythia8:
calibration="601229";
break;
case HelperFunctions::Herwig7p2:
calibration="601414";
break;
case HelperFunctions::Sherpa2214:
calibration="700808";
break;
case HelperFunctions::Sherpa_Unknown:
ANA_MSG_WARNING("Unknown Sherpa version MC shower type for sample " << gridName << ", falling back to MC-MC SFs for Sherpa 2.2.11-2.2.16.");
ANA_MSG_WARNING("Please double-check if this is appropriate for your sample, otherwise you have specify the MC-to-MC calibration manually!");
calibration="700808";
break;
default:
if (m_allowCalibrationFallback) {
ANA_MSG_WARNING("Cannot determine MC shower type for sample " << gridName << ", falling back to 'default'.");
ANA_MSG_WARNING("Please double-check if this is appropriate for your sample, otherwise you have specify the MC-to-MC calibration manually!");
calibration="default";
break;
}
else {
ANA_MSG_ERROR("Cannot determine MC shower type for sample " << gridName << ".");
return EL::StatusCode::FAILURE;
break;
}
}
else {
ANA_MSG_ERROR("Cannot determine MC shower type for sample " << gridName << ".");
return EL::StatusCode::FAILURE;
break;
} else {

switch(sampleShowerType)
{
case HelperFunctions::Pythia8_517:
calibration="410480";
break;
case HelperFunctions::Pythia8:
calibration="410470";
break;
case HelperFunctions::Herwig7p1:
calibration="411233";
break;
case HelperFunctions::Herwig7p2:
calibration="600666";
break;
case HelperFunctions::Sherpa2214:
calibration="700660";
break;
case HelperFunctions::Sherpa_Unknown:
ANA_MSG_WARNING("Unknown Sherpa version MC shower type for sample " << gridName << ", falling back to MC-MC SFs for Sherpa 2.2.11-2.2.16.");
ANA_MSG_WARNING("Please double-check if this is appropriate for your sample, otherwise you have specify the MC-to-MC calibration manually!");
calibration="700660";
break;
case HelperFunctions::Unknown:
if (m_allowCalibrationFallback) {
ANA_MSG_WARNING("Cannot determine MC shower type for sample " << gridName << ", falling back to 'default'.");
ANA_MSG_WARNING("Please double-check if this is appropriate for your sample, otherwise you have specify the MC-to-MC calibration manually!");
calibration="default";
break;
}
else {
ANA_MSG_ERROR("Cannot determine MC shower type for sample " << gridName << ".");
return EL::StatusCode::FAILURE;
break;
}
}
}
}
} else {
if (m_allowCalibrationFallback) {
ANA_MSG_WARNING("Cannot determine MC shower type for tagger " << m_taggerName << ", only GN2v01 and DL1dv01 are supported. Falling back to 'default'.");
ANA_MSG_WARNING("Please double-check if this is appropriate for your sample and tagger, otherwise you have specify the MC-to-MC calibration manually!");
calibration="default";
} else {
ANA_MSG_ERROR("Cannot determine MC shower type for tagger " << m_taggerName << ".");
return EL::StatusCode::FAILURE;
}
}
} else { makeMCIndexMap(m_EfficiencyCalibration); }
ANA_CHECK( m_BJetEffSFTool_handle.setProperty("EfficiencyBCalibrations" , calibration));
Expand Down Expand Up @@ -459,7 +539,6 @@ EL::StatusCode BJetEfficiencyCorrector :: executeEfficiencyCorrection(const xAOD
// for continuous b-tagging only
SG::AuxElement::Decorator< float > dec_Weight( m_decorWeight );
SG::AuxElement::Decorator< int > dec_Quantile( m_decorQuantile );
SG::AuxElement::Decorator< std::vector<float> > dec_ineffsfBTag( m_decorInefficiencySF );

//
// run the btagging decision or get weight and quantile if running continuous
Expand Down Expand Up @@ -543,8 +622,6 @@ EL::StatusCode BJetEfficiencyCorrector :: executeEfficiencyCorrection(const xAOD
if(abs(jet_itr->eta()) > 2.5){
if(!dec_sfBTag.isAvailable( *jet_itr ))
dec_sfBTag ( *jet_itr ) = std::vector<float>({1.});
if(m_useContinuous && !dec_ineffsfBTag.isAvailable( *jet_itr ))
dec_ineffsfBTag( *jet_itr ) = std::vector<float>({1.});
continue;
}
if(m_setMapIndex){ // select an efficiency map for use in MC/MC and inefficiency scale factors, based on user specified selection of efficiency maps
Expand All @@ -555,16 +632,13 @@ EL::StatusCode BJetEfficiencyCorrector :: executeEfficiencyCorrection(const xAOD
}
// get the scale factor
float SF(-1.0);
float inefficiencySF(-1.0); // only for continuous b-tagging
CP::CorrectionCode BJetEffCode;
CP::CorrectionCode BJetIneEffCode = CP::CorrectionCode::Ok;
// if passes cut take the efficiency scale factor
// if failed cut take the inefficiency scale factor
// for continuous b-tagging save both
// for continuous take efficiency, as inefficiency should not be used
if(m_useContinuous)
{
BJetEffCode = m_BJetEffSFTool_handle->getScaleFactor( *jet_itr, SF );
BJetIneEffCode = m_BJetEffSFTool_handle->getInefficiencyScaleFactor( *jet_itr, inefficiencySF );
}
else
{
Expand All @@ -574,7 +648,7 @@ EL::StatusCode BJetEfficiencyCorrector :: executeEfficiencyCorrection(const xAOD
BJetEffCode = m_BJetEffSFTool_handle->getInefficiencyScaleFactor( *jet_itr, SF );
}

if (BJetEffCode == CP::CorrectionCode::Error || BJetIneEffCode == CP::CorrectionCode::Error)
if (BJetEffCode == CP::CorrectionCode::Error)
{
ANA_MSG_ERROR( "Error in getEfficiencyScaleFactor");
return EL::StatusCode::FAILURE;
Expand All @@ -587,12 +661,9 @@ EL::StatusCode BJetEfficiencyCorrector :: executeEfficiencyCorrection(const xAOD
// Save it to the vector
if( !dec_sfBTag .isAvailable( *jet_itr ))
dec_sfBTag ( *jet_itr ) = std::vector<float>();
if(m_useContinuous && !dec_ineffsfBTag.isAvailable( *jet_itr ))
dec_ineffsfBTag( *jet_itr ) = std::vector<float>();


dec_sfBTag( *jet_itr ).push_back(SF);
if(m_useContinuous) dec_ineffsfBTag( *jet_itr ).push_back(inefficiencySF);
}
}
}
Expand All @@ -602,8 +673,6 @@ EL::StatusCode BJetEfficiencyCorrector :: executeEfficiencyCorrection(const xAOD
{
if( !dec_sfBTag .isAvailable( *jet_itr ))
dec_sfBTag ( *jet_itr ) = std::vector<float>({1.});
if(m_useContinuous && !dec_ineffsfBTag.isAvailable( *jet_itr ))
dec_ineffsfBTag( *jet_itr ) = std::vector<float>({1.});
}
}

Expand Down
42 changes: 30 additions & 12 deletions Root/HelperFunctions.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ bool HelperFunctions::has_exact(const std::string input, const std::string flag)
return inputSet.find(flag) != inputSet.end();
}

HelperFunctions::ShowerType HelperFunctions::getMCShowerType(const std::string& sample_name)
HelperFunctions::ShowerType HelperFunctions::getMCShowerType(const std::string& sample_name, const std::string& m_taggerName)
{
//
//pre-process sample name
Expand All @@ -534,15 +534,33 @@ HelperFunctions::ShowerType HelperFunctions::getMCShowerType(const std::string&

//
// Determine shower type by looking for keywords in name
if(tmp_name.Contains("AMCATNLOPY")) return AmcPy8;
else if(tmp_name.Contains("AMCATNLOH")) return AmcH7;
else if(tmp_name.Contains("PYTHIA8EVTGEN")) return Pythia8;
else if(tmp_name.Contains("HERWIG")) return Herwig7p1;
else if(tmp_name.Contains("PHH7EG")) return Herwig7p2;
else if(tmp_name.Contains("SHERPA_221_")) return Sherpa221;
else if(tmp_name.Contains("SH_221_")) return Sherpa221;
else if(tmp_name.Contains("SH_2210")) return Sherpa2210;
else if(tmp_name.Contains("SH_2211")) return Sherpa2210;
else if(tmp_name.Contains("SH_2212")) return Sherpa2212;
else return Unknown;
if(m_taggerName=="DL1dv01"){
if(tmp_name.Contains("AMCATNLOPY")) return AmcPy8;
else if(tmp_name.Contains("AMCATNLOH")) return AmcH7;
else if(tmp_name.Contains("PYTHIA8EVTGEN")) return Pythia8;
else if(tmp_name.Contains("HERWIG")) return Herwig7p1;
else if(tmp_name.Contains("PHH7EG")) return Herwig7p2;
else if(tmp_name.Contains("SHERPA_221_")) return Sherpa221;
else if(tmp_name.Contains("SH_221_")) return Sherpa221;
else if(tmp_name.Contains("SH_2210")) return Sherpa2210;
else if(tmp_name.Contains("SH_2211")) return Sherpa2210;
else if(tmp_name.Contains("SH_2212")) return Sherpa2212;
else return Unknown;
} else if(m_taggerName=="GN2v01"){
if(tmp_name.Contains("PYTHIA8EVTGEN517")) return Pythia8_517;
else if(tmp_name.Contains("PYTHIA8EVTGEN") and !tmp_name.Contains("AMCATNLO")) return Pythia8; //aMcAtNlo not supported for GN2, so don't let it count as Pythia8
else if(tmp_name.Contains("HERWIG") and !tmp_name.Contains("AMCATNLO")) return Herwig7p1;
else if(tmp_name.Contains("PHH7EG")) return Herwig7p2;
else if(tmp_name.Contains("SH_2210")) return Sherpa2214;//FTAG uses 2.2.14 SFs for 2.2.10
else if(tmp_name.Contains("SH_2211")) return Sherpa2214;//MC-to-MC maps for versions of Sherpa between 2.2.11 and 2.2.16 are equivalent.
else if(tmp_name.Contains("SH_2212")) return Sherpa2214;
else if(tmp_name.Contains("SH_2213")) return Sherpa2214;
else if(tmp_name.Contains("SH_2214")) return Sherpa2214;
else if(tmp_name.Contains("SH_2215")) return Sherpa2214;
else if(tmp_name.Contains("SH_2216")) return Sherpa2214;
else if(tmp_name.Contains("SH_") and !tmp_name.Contains("SH_2")) return Sherpa_Unknown;//Unknown Sherpa Version. This is to handle Sh_blank (e.g. DSID 701050). The examples I've found are all 2.2.16, but that's not guaranteed.
else return Unknown;
} else {
return Unknown;
}
}
3 changes: 2 additions & 1 deletion Root/JetContainer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1889,7 +1889,8 @@ void JetContainer::setBranches(TTree *tree)
// this applies the JVF/JVT selection cuts
// https://twiki.cern.ch/twiki/bin/view/AtlasProtected/JvtManualRecalculation
if( m_infoSwitch.m_allTrackPVSel ) {
m_trkSelTool = new InDet::InDetTrackSelectionTool( "JetTrackSelection", "Loose" );
m_trkSelTool = new InDet::InDetTrackSelectionTool( "JetTrackSelection");
m_trkSelTool->setProperty( "CutLevel", "Loose");
m_trkSelTool->initialize();
// to do this need to have AddJets return a status code
//ANA_CHECK( m_trkSelTool->initialize());
Expand Down
1 change: 1 addition & 0 deletions Root/MuonCalibrator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ EL::StatusCode MuonCalibrator :: initialize ()
ANA_CHECK(m_muonCalibrationTool_handle.setProperty("do2StationsHighPt", m_do2StationsHighPt));
}
ANA_CHECK(m_muonCalibrationTool_handle.setProperty( "IsRun3Geo", m_isRun3Geo ));
ANA_CHECK(m_muonCalibrationTool_handle.setProperty( "OutputLevel", msg().level()));
ANA_CHECK(m_muonCalibrationTool_handle.retrieve());
ANA_MSG_DEBUG("Retrieved tool: " << m_muonCalibrationTool_handle);

Expand Down
Loading

0 comments on commit 4b8ac58

Please sign in to comment.