Skip to content

Commit

Permalink
Add MC23e support for PRW
Browse files Browse the repository at this point in the history
  • Loading branch information
jdandoy committed Feb 7, 2025
1 parent 691338a commit 35463cf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
23 changes: 17 additions & 6 deletions Root/BasicEventSelection.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,7 @@ EL::StatusCode BasicEventSelection :: execute ()

// "Borrowed" from SUSYTools
// https://gitlab.cern.ch/atlas/athena/blob/3be30397de7c6cfdc15de38f532fdb4b9f338297/PhysicsAnalysis/SUSYPhys/SUSYTools/Root/SUSYObjDef_xAOD.cxx#L700
// Should track official https://gitlab.cern.ch/atlas/athena/-/blob/d09ebd5c011b654159e25ec3e205c09ac1bc64de/PhysicsAnalysis/AnalysisCommon/PileupReweighting/python/AutoconfigurePRW.py
StatusCode BasicEventSelection::autoconfigurePileupRWTool()
{

Expand Down Expand Up @@ -1194,13 +1195,16 @@ StatusCode BasicEventSelection::autoconfigurePileupRWTool()
case 450000 :
mcCampaignMD="mc23d";
break;
case 470000 :
mcCampaignMD="mc23e";
break;
default :
ANA_MSG_ERROR( "Could not determine mc campaign from run number! Impossible to autoconfigure PRW. Aborting." );
return StatusCode::FAILURE;
break;
}

std::string mcCampaignMD_v2 = "";
std::string mcCampaignMD_v2 = "";
const xAOD::FileMetaData* fmd(nullptr);
if ( !m_event->retrieveMetaInput(fmd, "FileMetaData").isSuccess() || !fmd->value(xAOD::FileMetaData::mcCampaign, mcCampaignMD_v2) ) {
ANA_MSG_WARNING("Failed to retrieve FileMetaData from MetaData! Using MC campaign from run number. PLEASE DOUBLE-CHECK this is the correct campaign for your samples!");
Expand Down Expand Up @@ -1237,14 +1241,14 @@ StatusCode BasicEventSelection::autoconfigurePileupRWTool()
// Sanity checks
bool mc2XX_GoodFromProperty = !mcCampaignList.empty();
bool mc2XX_GoodFromMetadata = false;
for(const auto& mcCampaignP : mcCampaignList) mc2XX_GoodFromProperty &= ( mcCampaignP == "mc20a" || mcCampaignP == "mc20d" || mcCampaignP == "mc20e" || mcCampaignP == "mc23a" || mcCampaignP == "mc23c" || mcCampaignP == "mc23d");
if( mcCampaignMD == "mc20a" || mcCampaignMD == "mc20d" || mcCampaignMD == "mc20e" || mcCampaignMD == "mc23a" || mcCampaignMD == "mc23c" || mcCampaignMD == "mc23d") mc2XX_GoodFromMetadata = true;
for(const auto& mcCampaignP : mcCampaignList) mc2XX_GoodFromProperty &= ( mcCampaignP == "mc20a" || mcCampaignP == "mc20d" || mcCampaignP == "mc20e" || mcCampaignP == "mc23a" || mcCampaignP == "mc23c" || mcCampaignP == "mc23d" || mcCampaignP == "mc23e");
if( mcCampaignMD == "mc20a" || mcCampaignMD == "mc20d" || mcCampaignMD == "mc20e" || mcCampaignMD == "mc23a" || mcCampaignMD == "mc23c" || mcCampaignMD == "mc23d" || mcCampaignMD == "mc23e") mc2XX_GoodFromMetadata = true;

if( !mc2XX_GoodFromMetadata && !mc2XX_GoodFromProperty ) {
// ::
std::string MetadataAndPropertyBAD("");
MetadataAndPropertyBAD += "autoconfigurePileupRWTool(): access to FileMetaData failed, but don't panic. You can try to manually set the 'mcCampaign' BasicEventSelection property to ";
MetadataAndPropertyBAD += "'mc20a', 'mc20c', 'mc20d', 'mc20e', 'mc20f', 'mc23a', 'mc23c', or 'mc23d' and restart your job. If you set it to any other string, you will still incur in this error.";
MetadataAndPropertyBAD += "'mc20a', 'mc20c', 'mc20d', 'mc20e', 'mc20f', 'mc23a', 'mc23c', 'mc23d', or 'mc23e' and restart your job. If you set it to any other string, you will still incur in this error.";
ANA_MSG_ERROR( MetadataAndPropertyBAD );
return StatusCode::FAILURE;
// ::
Expand Down Expand Up @@ -1300,6 +1304,7 @@ StatusCode BasicEventSelection::autoconfigurePileupRWTool()
else if (mcCampaign == "mc23a") {prwConfigFile = PathResolverFindCalibFile(m_commonPRWFileMC23a);}
else if (mcCampaign == "mc23c") {prwConfigFile = PathResolverFindCalibFile(m_commonPRWFileMC23c);}
else if (mcCampaign == "mc23d") {prwConfigFile = PathResolverFindCalibFile(m_commonPRWFileMC23d);}
else if (mcCampaign == "mc23e") {prwConfigFile = PathResolverFindCalibFile(m_commonPRWFileMC23e);}
else {
ANA_MSG_ERROR("autoconfigurePileupRWTool(): no common PRW file known for MC campaign: " << mcCampaign);
return StatusCode::FAILURE;
Expand Down Expand Up @@ -1329,7 +1334,9 @@ StatusCode BasicEventSelection::autoconfigurePileupRWTool()
if( !m_prwActualMu2022File.empty() && mcCampaign == "mc23a" )
prwConfigFiles.push_back(PathResolverFindCalibFile(m_prwActualMu2022File));
if( !m_prwActualMu2023File.empty() && (mcCampaign == "mc23c" || mcCampaign=="mc23d") )
prwConfigFiles.push_back(PathResolverFindCalibFile(m_prwActualMu2023File));
prwConfigFiles.push_back(PathResolverFindCalibFile(m_prwActualMu2023File));
if( !m_prwActualMu2024File.empty() && (mcCampaign == "mc23e") )
prwConfigFiles.push_back(PathResolverFindCalibFile(m_prwActualMu2024File));
}

// also need to handle lumicalc files: only use 2015+2016 with mc20a
Expand Down Expand Up @@ -1380,6 +1387,10 @@ StatusCode BasicEventSelection::autoconfigurePileupRWTool()
if (year == "23") {
lumiCalcFiles.push_back(filename);
}
} else if (mcCampaign == "mc23e") {
if (year == "24") {
lumiCalcFiles.push_back(filename);
}
} else {
ANA_MSG_ERROR( "No lumicalc file is suitable for your mc campaign!" );
}
Expand Down
4 changes: 4 additions & 0 deletions xAODAnaHelpers/BasicEventSelection.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ class BasicEventSelection : public xAH::Algorithm
std::string m_prwActualMu2022File = "";
/// @brief actualMu configuration file for the MC23d campaign (2023). Added to the PRW tool when using PRW autoconfiguration.
std::string m_prwActualMu2023File = "";
/// @brief actualMu configuration file for the MC23e campaign (2024). Added to the PRW tool when using PRW autoconfiguration.
std::string m_prwActualMu2024File = "";
/// @brief Common PRW file for the MC20a campaign (2015/16). Added to the PRW tool when using PRW autoconfiguration with common PRW files option.
std::string m_commonPRWFileMC20a = "PileupReweighting/mc20_common/mc20a.284500.physlite.prw.v1.root";
/// @brief Common PRW file for the MC20d campaign (2017). Added to the PRW tool when using PRW autoconfiguration with common PRW files option.
Expand All @@ -117,6 +119,8 @@ class BasicEventSelection : public xAH::Algorithm
std::string m_commonPRWFileMC23c = "PileupReweighting/mc23_common/mc23c.450000.physlite.prw.v1.root";
/// @brief Common PRW file for the MC23d campaign (2023). Added to the PRW tool when using PRW autoconfiguration with common PRW files option.
std::string m_commonPRWFileMC23d = "PileupReweighting/mc23_common/mc23d.450000.physlite.prw.v1.root";
/// @brief Common PRW file for the MC23e campaign (2024). Added to the PRW tool when using PRW autoconfiguration with common PRW files option.
std::string m_commonPRWFileMC23e = "PileupReweighting/mc23_common/mc23e.470000.physlite.prw.v1.root";
/**
@rst
mc16(acd) to bypass the automatic campaign determination from AMI, several campaigns can be separated by a comma. Only used
Expand Down

0 comments on commit 35463cf

Please sign in to comment.