Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to xAH for Trigger-Level Analyses from GitLab-hosted fork #1675

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
env:
RELEASE_TYPE: ${{ matrix.release_type }}
RELEASE_VERSION: ${{ matrix.release_version }}
DOCKER_BASE_REPO: gitlab-registry.cern.ch/atlas/athena
DOCKER_BASE_REPO: atlas
DOCKER_TARGET_REPO: ucatlas
RELEASE: ${{ format('{0}@{1}', matrix.release_type, matrix.release_version) }}
strategy:
Expand Down
51 changes: 7 additions & 44 deletions Root/Algorithm.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
#include <xAODAnaHelpers/HelperFunctions.h>
#include "xAODEventInfo/EventInfo.h"

#include <boost/algorithm/string.hpp>

std::map<std::string, int> xAH::Algorithm::m_instanceRegistry = {};

// this is needed to distribute the algorithm to the workers
Expand Down Expand Up @@ -37,13 +35,14 @@ StatusCode xAH::Algorithm::algInitialize(){


//Backwards compatibility
m_forceFastSim = m_forceFastSim || m_setAFII || m_setAF3;
m_forceFastSim = m_forceFastSim || m_setAFII;

//Return a failure if there's contradictory flags (2 or more are true)
if( m_forceData ? (m_forceFastSim || m_forceFullSim) : (m_forceFastSim && m_forceFullSim) ){
ANA_MSG_ERROR("Multiple input-type flags are set, be sure only one of m_forceData(" << m_forceData << "), m_forceFastSim(" << m_forceFastSim << "), and m_forceFullSim(" << m_forceFullSim << ") are true.");
return StatusCode::FAILURE;
}

return StatusCode::SUCCESS;
}

Expand Down Expand Up @@ -115,49 +114,13 @@ bool xAH::Algorithm::isFastSim(){
ANA_CHECK( wk()->xaodEvent()->retrieveMetaInput(fmd, "FileMetaData") );
fmd->value(xAOD::FileMetaData::simFlavour, SimulationFlavour);

boost::to_upper(SimulationFlavour);
m_isFastSim = SimulationFlavour.find("ATLFAST") != std::string::npos;

return m_isFastSim;
}

bool xAH::Algorithm::isAF3(){

// If already set return
if (m_isAF3==0 || m_isAF3==1){
return m_isAF3;
}
// If full sim, return empty string (call function first to make sure Force options are considered)
bool isFaS = isFastSim();
if (!isFaS){
m_isAF3 = 0;
return m_isAF3;
}

if (m_setAF3){
m_isAF3 = 1;
return m_isAF3;
}

std::string SimulationFlavour;
const xAOD::FileMetaData* fmd = nullptr;
if( wk()->xaodEvent()->retrieveMetaInput(fmd, "FileMetaData") != StatusCode::SUCCESS){
ANA_MSG_ERROR("Cannot retreve File Metadata to find simulation flavour");
return false;
}
fmd->value(xAOD::FileMetaData::simFlavour, SimulationFlavour);

boost::to_upper(SimulationFlavour);
if(SimulationFlavour.find("ATLFASTII") != std::string::npos){
m_isAF3 = 0;
} else if (SimulationFlavour.find("ATLFAST3") != std::string::npos){
m_isAF3 = 1;
} else {
ANA_MSG_ERROR("Unexpected Simulation type: "<< SimulationFlavour);
return false;
if( SimulationFlavour == "AtlfastII" ){
m_isFastSim = 1;
}else{
m_isFastSim = 0;
}

return m_isAF3;
return m_isFastSim;
}

bool xAH::Algorithm::isPHYS(){
Expand Down
50 changes: 40 additions & 10 deletions Root/BasicEventSelection.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,19 @@ EL::StatusCode BasicEventSelection :: execute ()

if ( m_applyTriggerCut ) {

if ( !triggerChainGroup->isPassed() ) {
// additional DEBUG logging to validate conditional logicss
ANA_MSG_DEBUG("Applying trigger cut corresponding to chain group " << m_triggerSelection);
ANA_MSG_DEBUG("Trigger chain group is NOT passed && is TLA data = " << int(!triggerChainGroup->isPassed(TrigDefs::requireDecision) && m_isTLAData));
ANA_MSG_DEBUG("Trigger chain group is NOT passed (no requireDecision) && is NOT TLA data = " << int(!triggerChainGroup->isPassed() && !m_isTLAData));

// different behaviour for isPassed depending on whether you are running on TLA data or not
// if running on TLA data, we only store the HLT part of the trigger decision i.e. the L1 part
// will always be "false", so we need to use TrigDefs::requireDecision to limit the decision
// to being satisfied by the HLT leg(s) of the trigger chain
// TODO: check performance of this method when using trigger chains with the SAME HLT leg but different L1 seed
// e.g. HLT_j20_pf_ftf_L1J100 vs. HLT_j20_pf_ftf_L1HT190-J15s5pETA21
if ( (m_isTLAData && !triggerChainGroup->isPassed(TrigDefs::requireDecision)) || (!m_isTLAData && !triggerChainGroup->isPassed()) ) {
// if (!triggerChainGroup->isPassed(TrigDefs::requireDecision)) {
wk()->skipEvent();
return EL::StatusCode::SUCCESS;
}
Expand All @@ -986,7 +998,7 @@ EL::StatusCode BasicEventSelection :: execute ()
//
for ( auto &trigName : triggerChainGroup->getListOfTriggers() ) {
auto trigChain = m_trigDecTool_handle->getChainGroup( trigName );
if ( trigChain->isPassed() ) {
if ( (m_isTLAData && trigChain->isPassed(TrigDefs::requireDecision)) || (!m_isTLAData && trigChain->isPassed()) ) {
passedTriggers.push_back( trigName );
triggerPrescales.push_back( trigChain->getPrescale() );

Expand All @@ -1008,7 +1020,7 @@ EL::StatusCode BasicEventSelection :: execute ()

for ( const std::string &trigName : m_extraTriggerSelectionList ) {
auto trigChain = m_trigDecTool_handle->getChainGroup( trigName );
if ( trigChain->isPassed() ) {
if ( (m_isTLAData && trigChain->isPassed(TrigDefs::requireDecision)) || (!m_isTLAData && trigChain->isPassed()) ) {
passedTriggers.push_back( trigName );
triggerPrescales.push_back( trigChain->getPrescale() );

Expand Down Expand Up @@ -1054,7 +1066,11 @@ EL::StatusCode BasicEventSelection :: execute ()
}
if ( m_storePassHLT ) {
static SG::AuxElement::Decorator< int > passHLT("passHLT");
passHLT(*eventInfo) = ( m_triggerSelection.find("HLT_") != std::string::npos ) ? (int)m_trigDecTool_handle->isPassed(m_triggerSelection.c_str()) : -1;
if (!m_isTLAData) {
passHLT(*eventInfo) = ( m_triggerSelection.find("HLT_") != std::string::npos ) ? (int)m_trigDecTool_handle->isPassed(m_triggerSelection.c_str()) : -1;
} else {
passHLT(*eventInfo) = ( m_triggerSelection.find("HLT_") != std::string::npos ) ? (int)m_trigDecTool_handle->isPassed(m_triggerSelection.c_str(), TrigDefs::requireDecision) : -1;
}
}

} // if giving a specific list of triggers to look at
Expand Down Expand Up @@ -1122,7 +1138,7 @@ StatusCode BasicEventSelection::autoconfigurePileupRWTool()
ANA_CHECK( m_event->retrieve( eventInfo, "EventInfo" ) );

// Determine simulation flavour
std::string SimulationFlavour = isFastSim() ? ( isAF3() ? "AF3" : "AFII" ) : "FS";
std::string SimulationFlavour = isFastSim() ? "AFII" : "FS";

// Extract campaign automatically from Run Number
std::string mcCampaignMD = "";
Expand All @@ -1140,6 +1156,9 @@ StatusCode BasicEventSelection::autoconfigurePileupRWTool()
case 310000 :
mcCampaignMD="mc20e";
break;
case 410000 :
mcCampaignMD="mc23";
break;
default :
ANA_MSG_ERROR( "Could not determine mc campaign from run number! Impossible to autoconfigure PRW. Aborting." );
return StatusCode::FAILURE;
Expand Down Expand Up @@ -1170,14 +1189,14 @@ StatusCode BasicEventSelection::autoconfigurePileupRWTool()
bool mc20X_GoodFromProperty = !mcCampaignList.empty();
bool mc20X_GoodFromMetadata = false;
for(const auto& mcCampaignP : mcCampaignList) mc20X_GoodFromProperty &= ( mcCampaignP == "mc20a" || mcCampaignP == "mc20d" || mcCampaignP == "mc20e");
if( mcCampaignMD == "mc20a" || mcCampaignMD == "mc20d" || mcCampaignMD == "mc20e") mc20X_GoodFromMetadata = true;
if( mcCampaignMD == "mc20a" || mcCampaignMD == "mc20d" || mcCampaignMD == "mc20e"|| mcCampaignMD == "mc23") mc20X_GoodFromMetadata = true;

if( !mc20X_GoodFromMetadata && !mc20X_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', or 'mc20f' 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', or 'mc23' 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 @@ -1248,6 +1267,8 @@ StatusCode BasicEventSelection::autoconfigurePileupRWTool()
prwConfigFiles.push_back(PathResolverFindCalibFile(m_prwActualMu2017File));
if( !m_prwActualMu2018File.empty() && (mcCampaign == "mc20e" || mcCampaign=="mc20f") )
prwConfigFiles.push_back(PathResolverFindCalibFile(m_prwActualMu2018File));
if( !m_prwActualMu2022File.empty() && (mcCampaign == "mc23") )
prwConfigFiles.push_back(PathResolverFindCalibFile(m_prwActualMu2022File));
}

// also need to handle lumicalc files: only use 2015+2016 with mc20a
Expand Down Expand Up @@ -1275,8 +1296,12 @@ StatusCode BasicEventSelection::autoconfigurePileupRWTool()
for(const auto& filename : allLumiCalcFiles)
{
// looking for things of format "stuff/data15_13TeV/stuff" etc
size_t pos = filename.find("data");
std::string year = filename.substr(pos+4, 2);
// If keyword 'data' appears multiple times in the path we need to modify the substring we search for
// /cvmfs/atlas.cern.ch/repo/sw/database/GroupData/GoodRunsLists/data22_13p6TeV/*/ilumi*
// size_t pos = filename.find("data");
// std::string year = filename.substr(pos+4, 2);
size_t pos = filename.find("GoodRunsLists/data");
std::string year = filename.substr(pos+18, 2);

if (mcCampaign == "mc20a") {
if (year == "15" || year == "16") {
Expand All @@ -1290,7 +1315,12 @@ StatusCode BasicEventSelection::autoconfigurePileupRWTool()
if (year == "18") {
lumiCalcFiles.push_back(filename);
}
} else {
} else if (mcCampaign == "mc23") {
if (year == "22") {
lumiCalcFiles.push_back(filename);
}
}
else {
ANA_MSG_ERROR( "No lumicalc file is suitable for your mc campaign!" );
}
}
Expand Down
13 changes: 11 additions & 2 deletions Root/ElectronContainer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -825,8 +825,17 @@ void ElectronContainer::FillElectron( const xAOD::IParticle* particle, const xAO

for (auto& PID : m_infoSwitch.m_PIDWPs) {
if (!PID.empty()) {
accPID.insert( std::pair<std::string, SG::AuxElement::Accessor<char> > ( PID , SG::AuxElement::Accessor<char>( PID ) ) );
safeFill<char, int, xAOD::Electron>( elec, accPID.at( PID ), m_PID->at( PID ), -1 );
if (PID == "LHLooseBL") {
accPID.insert( std::pair<std::string, SG::AuxElement::Accessor<char> > ( PID , SG::AuxElement::Accessor<char>( "LHLoose" ) ) );
if ( accPID.at( PID ).isAvailable( *elec ) && accBLayer.isAvailable( *elec ) ) {
m_PID->at( PID )->push_back( accBLayer( *elec ) == 1 && (accPID.at( PID ))( *elec ) == 1 );
} else {
m_PID->at( PID )->push_back( -1 );
}
} else {
accPID.insert( std::pair<std::string, SG::AuxElement::Accessor<char> > ( PID , SG::AuxElement::Accessor<char>( PID ) ) );
safeFill<char, int, xAOD::Electron>( elec, accPID.at( PID ), m_PID->at( PID ), -1 );
}
}
}
}
Expand Down
60 changes: 27 additions & 33 deletions Root/ElectronSelector.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,12 @@ EL::StatusCode ElectronSelector :: initialize ()
}

if ( m_readIDFlagsFromDerivation ) {
// LooseBL is not in Derivations, so choose Loose and do BLayer cut locally
if( m_LHOperatingPoint == "LooseBL" ){
m_LHOperatingPoint = "Loose";
m_doBLTrackQualityCut = true;
}

ANA_MSG_INFO( "Reading Electron LH ID from DAODs ..." );
ANA_CHECK( m_el_LH_PIDManager->setupWPs( false ));
} else {
Expand Down Expand Up @@ -345,47 +351,35 @@ EL::StatusCode ElectronSelector :: initialize ()
// do not initialise if there are no input trigger chains
if( !( m_singleElTrigChains.empty() && m_diElTrigChains.empty() ) ) {

// grab the TrigDecTool from the ToolStore
if(!m_trigDecTool_handle.isUserConfigured()){
ANA_MSG_FATAL("A configured " << m_trigDecTool_handle.typeAndName() << " must have been previously created! Are you creating one in xAH::BasicEventSelection?" );
return EL::StatusCode::FAILURE;
}
ANA_CHECK( m_trigDecTool_handle.retrieve());
ANA_MSG_DEBUG("Retrieved tool: " << m_trigDecTool_handle);
if( !isPHYS() ) {
// Grab the TrigDecTool from the ToolStore
if(!m_trigDecTool_handle.isUserConfigured()){
ANA_MSG_FATAL("A configured " << m_trigDecTool_handle.typeAndName() << " must have been previously created! Are you creating one in xAH::BasicEventSelection?" );
return EL::StatusCode::FAILURE;
}
ANA_CHECK( m_trigDecTool_handle.retrieve());
ANA_MSG_DEBUG("Retrieved tool: " << m_trigDecTool_handle);

// in AB we need to explicitly retrieve this tool, see https://twiki.cern.ch/twiki/bin/viewauth/Atlas/R22TriggerAnalysis
ANA_CHECK( m_scoreTool.retrieve());
ANA_CHECK( m_scoreTool.retrieve());

// Run3 got a new trigger navigation
if (m_useRun3navigation) {
m_trigElectronMatchTool_handle = asg::AnaToolHandle<Trig::IMatchingTool>("Trig::R3MatchingTool/TrigR3MatchingTool");
// everything went fine, let's initialise the tool!
m_trigElectronMatchTool_handle = asg::AnaToolHandle<Trig::IMatchingTool>("Trig::MatchingTool/MatchingTool");;
ANA_CHECK( m_trigElectronMatchTool_handle.setProperty( "TrigDecisionTool", m_trigDecTool_handle ));
ANA_CHECK( m_trigElectronMatchTool_handle.setProperty( "ScoringTool", m_scoreTool ));
ANA_CHECK( m_trigElectronMatchTool_handle.setProperty("OutputLevel", msg().level() ));
ANA_CHECK( m_trigElectronMatchTool_handle.setProperty( "OutputLevel", msg().level() ));
ANA_CHECK( m_trigElectronMatchTool_handle.retrieve());
ANA_MSG_DEBUG("Retrieved tool: " << m_trigElectronMatchTool_handle);
}
// otherwise we have to configure the Run2-style navigation
else {
if( !isPHYS() ) {
m_trigElectronMatchTool_handle = asg::AnaToolHandle<Trig::IMatchingTool>("Trig::MatchingTool/MatchingTool");;
ANA_CHECK( m_trigElectronMatchTool_handle.setProperty( "TrigDecisionTool", m_trigDecTool_handle ));
ANA_CHECK( m_trigElectronMatchTool_handle.setProperty( "ScoringTool", m_scoreTool ));
ANA_CHECK( m_trigElectronMatchTool_handle.setProperty( "OutputLevel", msg().level() ));
ANA_CHECK( m_trigElectronMatchTool_handle.retrieve());
ANA_MSG_DEBUG("Retrieved tool: " << m_trigElectronMatchTool_handle);
}
else { // For DAOD_PHYS samples
m_trigElectronMatchTool_handle = asg::AnaToolHandle<Trig::IMatchingTool>("Trig::MatchFromCompositeTool/MatchFromCompositeTool");;
ANA_CHECK( m_trigElectronMatchTool_handle.setProperty( "OutputLevel", msg().level() ));
if (!m_trigInputPrefix.empty()){
ANA_CHECK( m_trigElectronMatchTool_handle.setProperty( "InputPrefix", m_trigInputPrefix ));
ANA_CHECK( m_trigElectronMatchTool_handle.setProperty( "RemapBrokenLinks", true) );
}
ANA_CHECK( m_trigElectronMatchTool_handle.retrieve());
ANA_MSG_DEBUG("Retrieved tool: " << m_trigElectronMatchTool_handle);
} else { // For DAOD_PHYS samples
m_trigElectronMatchTool_handle = asg::AnaToolHandle<Trig::IMatchingTool>("Trig::MatchFromCompositeTool/MatchFromCompositeTool");;
ANA_CHECK( m_trigElectronMatchTool_handle.setProperty( "OutputLevel", msg().level() ));
if (!m_trigInputPrefix.empty()){
ANA_CHECK( m_trigElectronMatchTool_handle.setProperty( "InputPrefix", m_trigInputPrefix ));
ANA_CHECK( m_trigElectronMatchTool_handle.setProperty( "RemapBrokenLinks", true) );
}
ANA_CHECK( m_trigElectronMatchTool_handle.retrieve());
ANA_MSG_DEBUG("Retrieved tool: " << m_trigElectronMatchTool_handle);
}

} else {

m_doTrigMatch = false;
Expand Down
1 change: 1 addition & 0 deletions Root/HelperClasses.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ namespace HelperClasses{
m_clean = has_exact("clean");
m_cleanLight = has_exact("cleanLight");
m_cleanTrig = has_exact("cleanTrig");
m_timing = has_exact("timing");
m_cleanLLP = has_exact("cleanLLP");
m_timing = has_exact("timing");
m_energy = has_exact("energy");
Expand Down
27 changes: 27 additions & 0 deletions Root/HistogramManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ TProfile* HistogramManager::book(std::string name, std::string title,
return tmp;
}


MsgStream& HistogramManager :: msg () const { return m_msg; }
MsgStream& HistogramManager :: msg (int level) const {
MsgStream& result = msg();
Expand Down Expand Up @@ -242,3 +243,29 @@ void HistogramManager::fillHist(const std::string& histName, double valueX, doub
}
histPointer->Fill(valueX, valueY, weight);
}

void HistogramManager::fillHist(const std::string& histName, double valueX, double valueY, double valueZ, double weight) {
TH3* histPointer(NULL);
HistMap_t::const_iterator it = m_histMap.find( histName );
if ( it == m_histMap.end() ) {
ANA_MSG_ERROR("Histogram name " << histName << " not found");
return;
}
else {
histPointer = (TH3*)it->second;
}
histPointer->Fill(valueX, valueY, valueZ, weight);
}

void HistogramManager::fillProfile(const std::string& histName, double valueX, double valueY, double weight) {
TProfile* histPointer(NULL);
HistMap_t::const_iterator it = m_histMap.find( histName );
if ( it == m_histMap.end() ) {
ANA_MSG_ERROR("Histogram name " << histName << " not found");
return;
}
else {
histPointer = (TProfile*)it->second;
}
histPointer->Fill(valueX, valueY, weight);
}
2 changes: 1 addition & 1 deletion Root/IsoCloseByCorr.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,4 @@ EL::StatusCode IsoCloseByCorr :: histFinalize ()
ANA_MSG_INFO( "Calling histFinalize");
ANA_CHECK( xAH::Algorithm::algFinalize());
return EL::StatusCode::SUCCESS;
}
}
16 changes: 16 additions & 0 deletions Root/JetCalibrator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,17 @@ EL::StatusCode JetCalibrator :: initialize ()
if ( m_jetCalibToolsDEV ) {
ANA_CHECK( m_JetCalibrationTool_handle.setProperty("DEVmode", m_jetCalibToolsDEV));
}
// HLT jet re-calibration configuration
if (m_recalibrateHLTJets) {
ANA_CHECK( m_JetCalibrationTool_handle.setProperty("UseHLTEventShape", true) );
// Note: PrimaryVerticesContainerName is actually a private ReadHandleKey, but we can set its value via the setProperty method
ANA_CHECK( m_JetCalibrationTool_handle.setProperty("PrimaryVerticesContainerName", m_HLTVertexContainerName) );
ANA_CHECK( m_JetCalibrationTool_handle.setProperty("averageInteractionsPerCrossingKey", m_HLTAvgMuDecor) );
if (m_EvtInfoHLTNPVDecor != "") {
ANA_CHECK( m_JetCalibrationTool_handle.setProperty("UseNPVFromEventInfo", true) );
ANA_CHECK( m_JetCalibrationTool_handle.setProperty("NPVKey", m_EvtInfoHLTNPVDecor) );
}
}
ANA_CHECK( m_JetCalibrationTool_handle.retrieve());
ANA_MSG_DEBUG("Retrieved tool: " << m_JetCalibrationTool_handle);

Expand Down Expand Up @@ -461,6 +472,11 @@ EL::StatusCode JetCalibrator :: execute ()
// }
// }

if(isMC() && m_useLargeRTruthLabelingTool && m_JetTruthLabelingTool_handle.isInitialized()){
// largeR jet truth labelling
m_JetTruthLabelingTool_handle->modify(*(calibJetsSC.first));
}

// loop over available systematics - remember syst == "Nominal" --> baseline
auto vecOutContainerNames = std::make_unique< std::vector< std::string > >();

Expand Down
Loading
Loading