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

xAH updates for Trigger-Level Analyses #1676

Merged
merged 8 commits into from
Feb 16, 2024
67 changes: 42 additions & 25 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 logic
ANA_MSG_DEBUG("Applying trigger cut corresponding to chain group " << m_triggerSelection);
ANA_MSG_DEBUG("Is Trigger-Level Analysis (TLA) data = " << int(m_isTLAData));
ANA_MSG_DEBUG("Trigger chain group is passed = " << int(m_isTLAData ? triggerChainGroup->isPassed(TrigDefs::requireDecision) : triggerChainGroup->isPassed()));

// 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 @@ -999,33 +1011,34 @@ EL::StatusCode BasicEventSelection :: execute ()
}
isPassedBitsNames.push_back( trigName );
isPassedBits .push_back( m_trigDecTool_handle->isPassedBits(trigName) );
if(trigChain->getPrescale()<1) disabledTriggers.push_back( trigName );
if(trigChain->getPrescale()<1) disabledTriggers.push_back( trigName );
}

// Save info for extra triggers
//
if ( !m_extraTriggerSelection.empty() ) {

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

bool doLumiPrescale = true;
for ( const std::string &trigPart : trigChain->getListOfTriggers() ) {
if (std::find(m_triggerUnprescaleList.begin(), m_triggerUnprescaleList.end(), trigPart) == m_triggerUnprescaleList.end()) doLumiPrescale = false;
}
if ( doLumiPrescale ) {
triggerPrescalesLumi.push_back( m_pileup_tool_handle->getDataWeight( *eventInfo, trigName, true ) );
} else {
triggerPrescalesLumi.push_back( -1 );
}
}
isPassedBitsNames.push_back( trigName );
isPassedBits .push_back( m_trigDecTool_handle->isPassedBits(trigName) );
if(trigChain->getPrescale()<1) disabledTriggers.push_back( trigName );
}

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

bool doLumiPrescale = true;
for ( const std::string &trigPart : trigChain->getListOfTriggers() ) {
if (std::find(m_triggerUnprescaleList.begin(), m_triggerUnprescaleList.end(), trigPart) == m_triggerUnprescaleList.end()) doLumiPrescale = false;
}
if ( doLumiPrescale ) {
triggerPrescalesLumi.push_back( m_pileup_tool_handle->getDataWeight( *eventInfo, trigName, true ) );
} else {
triggerPrescalesLumi.push_back( -1 );
}
}

isPassedBitsNames.push_back( trigName );
isPassedBits .push_back( m_trigDecTool_handle->isPassedBits(trigName) );
if(trigChain->getPrescale()<1) disabledTriggers.push_back( trigName );
}
}

static SG::AuxElement::Decorator< std::vector< std::string > > dec_passedTriggers("passedTriggers");
Expand Down Expand Up @@ -1054,7 +1067,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
26 changes: 26 additions & 0 deletions Root/HistogramManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,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);
}
11 changes: 11 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
Loading
Loading