Skip to content
Snippets Groups Projects
Commit 55308823 authored by Ryan Mackenzie White's avatar Ryan Mackenzie White Committed by Graeme Stewart
Browse files

no trigemcluster for rootcore (TrigEgammaMatchingTool-00-00-07)

parent 087479a8
No related branches found
No related tags found
No related merge requests found
Showing
with 993 additions and 0 deletions
This diff is collapsed.
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef ITRIGEGAMMAMATCHINGTOOL_H_
#define ITRIGEGAMMAMATCHINGTOOL_H_
#include "AsgTools/IAsgTool.h"
#include "TrigConfHLTData/HLTFrame.h"
#include "TrigConfHLTData/HLTTriggerElement.h"
#include "xAODEgamma/Egamma.h"
#include "xAODEgamma/ElectronContainer.h"
#include "xAODEgamma/PhotonContainer.h"
#include "xAODEgamma/ElectronAuxContainer.h"
#include "xAODEgamma/PhotonAuxContainer.h"
#include "xAODTrigEgamma/TrigElectronContainer.h"
#include "xAODTrigEgamma/TrigElectronAuxContainer.h"
#include "xAODTrigEgamma/TrigPhotonContainer.h"
#include "xAODTrigEgamma/TrigPhotonAuxContainer.h"
#include "xAODTracking/TrackParticleContainer.h"
#include "xAODTracking/TrackParticleAuxContainer.h"
#include "xAODTrigCalo/TrigEMCluster.h"
#include "xAODCaloEvent/CaloClusterContainer.h"
#include "xAODCaloEvent/CaloClusterAuxContainer.h"
#include "xAODTrigger/EmTauRoIContainer.h"
#include "TrigDecisionTool/TrigDecisionTool.h"
namespace Trig{
class ITrigEgammaMatchingTool : public virtual asg::IAsgTool {
ASG_TOOL_INTERFACE( Trig::ITrigEgammaMatchingTool )
public:
virtual StatusCode initialize(void) = 0;
virtual StatusCode execute()=0;
virtual StatusCode finalize()=0;
virtual bool match(const xAOD::Egamma *,const std::string,const HLT::TriggerElement*&)=0;
virtual bool match(const xAOD::Egamma *,const std::string)=0;
virtual bool matchHLT(const xAOD::Egamma *,const std::string)=0;
virtual const xAOD::Egamma* closestHLTObject(const xAOD::Egamma *,const std::string)=0;
protected:
private:
};
}
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef TRIGEGAMMAMATCHINGTOOL_H_
#define TRIGEGAMMAMATCHINGTOOL_H_
#include "TrigEgammaMatchingTool/ITrigEgammaMatchingTool.h"
#include "AsgTools/AsgToolsConf.h"
#include "AsgTools/AsgMetadataTool.h"
#include "AsgTools/AsgTool.h"
#include "AsgTools/ToolHandle.h"
#include <iostream>
#include "TrigDecisionTool/TrigDecisionTool.h"
namespace Trig{
class TrigEgammaMatchingTool :
public asg::AsgMetadataTool,
public virtual ITrigEgammaMatchingTool
{
ASG_TOOL_INTERFACE(Trig::TrigEgammaMatchingTool)
ASG_TOOL_CLASS2( TrigEgammaMatchingTool, Trig::ITrigEgammaMatchingTool,Trig::TrigEgammaMatchingTool)
public:
TrigEgammaMatchingTool( const std::string& name );
virtual ~TrigEgammaMatchingTool();
virtual StatusCode initialize(void);
virtual StatusCode execute();
virtual StatusCode finalize();
/*! Egamma trigger matching which returns TE */
bool match(const xAOD::Egamma *,const std::string,const HLT::TriggerElement*&);
/*! Egamma trigger matching to HLT Electron/Photon with DeactivatedTE*/
bool match(const xAOD::Egamma *,const std::string);
/*! Egamma trigger matching to HLT Electron/Photon Only */
bool matchHLT(const xAOD::Egamma *,const std::string);
/*! Egamma trigger matching to HLT Electron/Photon only -- returns nearest object */
const xAOD::Egamma* closestHLTObject(const xAOD::Egamma *,const std::string);
double dR(const double, const double, const double, const double);
double m_dR;
double m_dRL1;
protected:
private:
ToolHandle<Trig::TrigDecisionTool> m_trigDecTool;
template<class T> const T* getFeature(const HLT::TriggerElement* te);
template<class T> bool ancestorPassed(const HLT::TriggerElement* te);
bool matchHLTElectron(const xAOD::Electron *,const std::string,const HLT::TriggerElement*&);
bool matchHLTPhoton(const xAOD::Photon *,const std::string,const HLT::TriggerElement*&);
bool matchHLTCalo(const xAOD::Egamma *,const std::string,const HLT::TriggerElement*&);
bool matchL2Electron(const xAOD::Electron *,const std::string,const HLT::TriggerElement*&);
bool matchL2Photon(const xAOD::Photon *,const std::string,const HLT::TriggerElement*&);
bool matchL2Calo(const xAOD::Egamma *,const std::string,const HLT::TriggerElement*&);
bool matchL1(const xAOD::Egamma *,const std::string,const HLT::TriggerElement*&);
};
}
#endif
PACKAGE = TrigEgammaMatchingTool
PACKAGE_PRELOAD =
PACKAGE_CXXFLAGS =
PACKAGE_OBJFLAGS =
PACKAGE_LDFLAGS =
PACKAGE_BINFLAGS =
PACKAGE_LIBFLAGS =
PACKAGE_DEP = AsgTools xAODRootAccess xAODTrigger xAODEgamma xAODTrigEgamma xAODCaloEvent xAODTrigCalo xAODTracking TrigDecisionTool TrigSteeringEvent
PACKAGE_TRYDEP =
PACKAGE_CLEAN =
PACKAGE_NOGRID =
PACKAGE_PEDANTIC = 1
PACKAGE_NOOPT = 0
PACKAGE_NOCC = 0
PACKAGE_REFLEX = 0
include $(ROOTCOREDIR)/Makefile-common
package TrigEgammaMatchingTool
author Ryan Mackenzie White <ryan.white@cern.ch>
public
use AtlasPolicy AtlasPolicy-*
use AsgTools AsgTools-* Control/AthToolSupport
use AtlasROOT AtlasROOT-* External
use TrigDecisionTool TrigDecisionTool-* Trigger/TrigAnalysis
use TrigConfHLTData TrigConfHLTData-* Trigger/TrigConfiguration
use TrigSteeringEvent TrigSteeringEvent-* Trigger/TrigEvent
use xAODTrigger xAODTrigger-* Event/xAOD
use xAODEgamma xAODEgamma-* Event/xAOD
use xAODEgammaCnv xAODEgammaCnv-* Event/xAOD
use xAODTrigEgamma xAODTrigEgamma-* Event/xAOD
use xAODTracking xAODTracking-* Event/xAOD
use xAODTrigCalo xAODTrigCalo-* Event/xAOD
use xAODCaloEvent xAODCaloEvent-* Event/xAOD
private
use AtlasROOT AtlasROOT-* External
use TrigConfxAOD TrigConfxAOD-* Trigger/TrigConfiguration
use GaudiInterface GaudiInterface-* External
use AthenaBaseComps AthenaBaseComps-* Control
use xAODTrigger xAODTrigger-* Event/xAOD
end_private
apply_pattern dual_use_library files="*.cxx ../Root/*.cxx"
apply_pattern declare_joboptions files=../share/*.py
# Default job options for TrigEgammaMatchingTool
# Authors:
# Ryan Mackenzie White <ryan.white@cern.ch>
#
from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
from RecExConfig.RecFlags import rec
from RecExConfig.RecAlgsFlags import recAlgs
from InDetRecExample.InDetJobProperties import InDetFlags
InDetFlags.doSecVertexFinder.set_Value_and_Lock(False)
from AthenaCommon.AppMgr import ToolSvc
import os
if not 'DIR' in dir():
dirtouse='/afs/cern.ch/user/r/rwhite/workspace/public/validation/mc/DC14/valid1.147806.PowhegPythia8_AU2CT10_Zee.recon.AOD.e2658_s1967_s1964_r5787_tid01572823_00'
else :
dirtouse=DIR
outputName = 'Validation_asdf'
# To run
# athena -l DEBUG -c "DIR='/afs/cern.ch/user/r/rwhite/workspace/egamma/mc/DC14Val/mc14_13TeV.147406.PowhegPythia8_AZNLO_Zee.recon.AOD.e3059_s1982_s2008_r5787_tid01572494_00'" test_NavZeeTPAll.py
listfiles=os.listdir(dirtouse)
finallist=[]
for ll in listfiles:
finallist.append(dirtouse+'/'+ll)
#print finallist
athenaCommonFlags.FilesInput=finallist
athenaCommonFlags.EvtMax=100
#athenaCommonFlags.EvtMax=-1
rec.readAOD=True
# switch off detectors
rec.doForwardDet=False
rec.doInDet=False
rec.doCalo=False
rec.doMuon=False
rec.doEgamma=False
rec.doTrigger = True; recAlgs.doTrigger=False # disable trigger (maybe necessary if detectors switched off)
rec.doMuon=False
rec.doMuonCombined=False
rec.doWriteAOD=False
rec.doWriteESD=False
rec.doDPD=False
rec.doTruth=False
# autoconfiguration might trigger undesired feature
rec.doESD.set_Value_and_Lock(False) # uncomment if do not run ESD making algorithms
rec.doWriteESD.set_Value_and_Lock(False) # uncomment if do not write ESD
rec.doAOD.set_Value_and_Lock(False) # uncomment if do not run AOD making algorithms
rec.doWriteAOD.set_Value_and_Lock(False) # uncomment if do not write AOD
rec.doWriteTAG.set_Value_and_Lock(False) # uncomment if do not write TAG
# main jobOption
triggerList = [
#'e26_tight_iloose',
#'e26_lhtight_iloose',
#'e26_lhtight_cutd0dphideta_iloose',
#'e26_lhtight_iloose_HLTCalo',
#'e26_lhvloose_L1EM20VH',
#'e26_vloose_L1EM20VH',
#'e60_lhmedium',
#'e60_lhmedium_HLTCalo',
#'e60_lhmedium_cutd0dphideta',
#'e60_lhvloose',
'e17_lhloose',
'e17_loose',
#'e13_etcut_trkcut',
#"g20_loose",
#"g20_tight",
"g25_loose",
#"g25_medium",
#"g35_loose",
#"g35_medium",
]
include ("RecExCommon/RecExCommon_topOptions.py")
ToolSvc.TrigDecisionTool.TrigDecisionKey='xTrigDecision'
from AthenaCommon.AlgSequence import AlgSequence
theJob = AlgSequence()
from TrigEgammaMatchingTool.TrigEgammaMatchingToolConf import Trig__TrigEgammaMatchingTool
matchtool = Trig__TrigEgammaMatchingTool("MatchingTool");
from AthenaCommon.AppMgr import ToolSvc
ToolSvc += matchtool
from TrigEgammaMatchingTool.TrigEgammaMatchingToolConf import Trig__TrigEgammaMatchingToolTest
alg = Trig__TrigEgammaMatchingToolTest()
alg.TrigEgammaMatchingTool = matchtool
alg.TriggerList = triggerList
alg.OutputLevel = DEBUG
theJob += alg
include("TriggerTest/TriggerTestCommon.py")
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// TrigEgammaMatchingToolTest.cxx
#include "TrigEgammaMatchingToolTest.h"
#include "GaudiKernel/Property.h"
#include "xAODEgamma/ElectronContainer.h"
#include "xAODEgamma/PhotonContainer.h"
using std::string;
//**********************************************************************
namespace Trig{
TrigEgammaMatchingToolTest::
TrigEgammaMatchingToolTest(const std::string& name,
ISvcLocator* pSvcLocator )
: ::AthAlgorithm( name, pSvcLocator ),
m_trigdec("Trig::TrigDecisionTool/TrigDecisionTool"),
m_matchTool("Trig::TrigEgammaMatchingTool/TrigEgammaMatchingTool",this)
{
declareProperty("TrigEgammaMatchingTool",m_matchTool);
declareProperty("TriggerList",m_triggerList);
}
//**********************************************************************
TrigEgammaMatchingToolTest::~TrigEgammaMatchingToolTest() { }
//**********************************************************************
StatusCode TrigEgammaMatchingToolTest::initialize() {
ATH_MSG_INFO("Initializing " << name() << "...");
ATH_MSG_INFO("Retrieving tools...");
if ( (m_trigdec.retrieve()).isFailure() ){
ATH_MSG_ERROR("Could not retrieve Trigger Decision Tool! Can't work");
return StatusCode::FAILURE;
}
StatusCode sc = service("StoreGateSvc", m_storeGate);
if(sc.isFailure()) {
ATH_MSG_ERROR( "Unable to locate Service StoreGateSvc" );
return sc;
}
return StatusCode::SUCCESS;
}
//**********************************************************************
StatusCode TrigEgammaMatchingToolTest::finalize() {
ATH_MSG_INFO ("Finalizing " << name() << "...");
for (auto iter = m_counterBits.begin(); iter != m_counterBits.end(); iter++) {
ATH_MSG_INFO(iter->first << " == " << iter->second);
}
for (auto iter = m_counterMatch1Bits.begin(); iter != m_counterMatch1Bits.end(); iter++) {
ATH_MSG_INFO(iter->first << " " << iter->second << " " << m_counterMatch2Bits[iter->first] << " " << m_counterMatch3Bits[iter->first]);
}
return StatusCode::SUCCESS;
}
//**********************************************************************
StatusCode TrigEgammaMatchingToolTest::execute() {
ATH_MSG_INFO ("Executing " << name() << "...");
ATH_MSG_INFO( "L1: " << m_trigdec->isPassed( "L1_.*" )
<< ", L2: " << m_trigdec->isPassed( "L2_.*" )
<< ", EF: " << m_trigdec->isPassed( "EF_.*" )
<< ", HLT: " << m_trigdec->isPassed( "HLT_.*" ) );
auto chainGroups = m_trigdec->getChainGroup("HLT_e.*");
for(auto &trig : chainGroups->getListOfTriggers()) {
if(m_trigdec->isPassed(trig))
ATH_MSG_INFO("Passed: " << trig);
m_counterBits[trig]+=m_trigdec->isPassed(trig);
}
//Check Containers
const xAOD::ElectronContainer *offElectrons = 0;
const xAOD::ElectronContainer *onlElectrons = 0;
if ( (m_storeGate->retrieve(offElectrons,"Electrons")).isFailure() ){
ATH_MSG_ERROR("Failed to retrieve offline Electrons ");
}
ATH_MSG_INFO("Offline Electron container size " << offElectrons->size());
for(const auto& eg : *offElectrons){
if (eg) {
ATH_MSG_INFO(" REGTEST: egamma energy: " << eg->e());
ATH_MSG_INFO(" REGTEST: egamma eta: " << eg->eta() );
ATH_MSG_INFO(" REGTEST: egamma phi: " << eg->phi() );
for(unsigned int ilist = 0; ilist != m_triggerList.size(); ilist++) {
const HLT::TriggerElement *finalFC;
std::string trigger = m_triggerList.at(ilist);
ATH_MSG_DEBUG("Test Matching Method 1");
if(m_matchTool->match(eg,trigger)){
ATH_MSG_DEBUG("REGTEST:: Method 1 Matched Electron with tool for " << trigger);
m_counterMatch1Bits[trigger]++;
}
else ATH_MSG_DEBUG("REGTEST::Fails method 3 " << trigger);
ATH_MSG_DEBUG("Test mathcing method 2");
if(m_matchTool->match(eg,trigger,finalFC)){
ATH_MSG_DEBUG("REGTEST:: Method 2 Matched Electron with tool for " << trigger);
if ( finalFC != NULL ){
if ( (m_trigdec->ancestor<xAOD::ElectronContainer>(finalFC)).te() != NULL ){
if( (m_trigdec->ancestor<xAOD::ElectronContainer>(finalFC)).te()->getActiveState()){
ATH_MSG_DEBUG("REGTEST::Passed Matching " << trigger);
m_counterMatch2Bits[trigger]++;
}
else ATH_MSG_DEBUG("REGTEST::Fails method 2");
}
}
}
ATH_MSG_DEBUG("REGTEST::Test Matching method 3");
if(m_matchTool->matchHLT(eg,trigger)){
ATH_MSG_DEBUG("REGTEST:: Method 3 Matched Electron with tool for " << trigger);
m_counterMatch3Bits[trigger]++;
}
else ATH_MSG_DEBUG("REGTEST::Fails method 3");
}
} else{
ATH_MSG_INFO(" REGTEST: problems with egamma pointer");
}
if(eg->trackParticle()){
ATH_MSG_INFO(" REGTEST: pt= " << eg->trackParticle()->pt());
ATH_MSG_INFO(" REGTEST: charge= " << eg->trackParticle()->charge()) ;
ATH_MSG_INFO(" REGTEST: eta= " << eg->trackParticle()->eta());
ATH_MSG_INFO(" REGTEST: phi= " << eg->trackParticle()->phi()) ;
}
if(eg->caloCluster()){
ATH_MSG_INFO(" REGTEST: et= " << eg->caloCluster()->et());
ATH_MSG_INFO(" REGTEST: eta= " << eg->caloCluster()->eta());
ATH_MSG_INFO(" REGTEST: phi= " << eg->caloCluster()->phi()) ;
}
else ATH_MSG_INFO("No caloCluster");
}
if ( (m_storeGate->retrieve(onlElectrons,"HLT_xAOD__ElectronContainer_egamma_Electrons")).isFailure() ){
ATH_MSG_ERROR("Failed to retrieve offline Electrons ");
}
ATH_MSG_INFO("Online Electron container size " << onlElectrons->size());
for(const auto& eg : *onlElectrons){
if (eg) {
ATH_MSG_INFO(" REGTEST: egamma energy: " << eg->e());
ATH_MSG_INFO(" REGTEST: egamma eta: " << eg->eta() );
ATH_MSG_INFO(" REGTEST: egamma phi: " << eg->phi() );
} else{
ATH_MSG_INFO(" REGTEST: problems with egamma pointer");
}
if(eg->trackParticle()){
ATH_MSG_INFO(" REGTEST: pt= " << eg->trackParticle()->pt());
ATH_MSG_INFO(" REGTEST: charge= " << eg->trackParticle()->charge()) ;
ATH_MSG_INFO(" REGTEST: eta= " << eg->trackParticle()->eta());
ATH_MSG_INFO(" REGTEST: phi= " << eg->trackParticle()->phi() );
}
if(eg->caloCluster()){
ATH_MSG_INFO(" REGTEST: et= " << eg->caloCluster()->et());
ATH_MSG_INFO(" REGTEST: eta= " << eg->caloCluster()->eta());
ATH_MSG_INFO(" REGTEST: phi= " << eg->caloCluster()->phi()) ;
}
else ATH_MSG_INFO("No caloCluster");
}
return StatusCode::SUCCESS;
}
}
//**********************************************************************
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// TrigEgammaMatchingToolTest.h
#ifndef TrigEgammaMatchingToolTest_H
#define TrigEgammaMatchingToolTest_H
#include "AthenaBaseComps/AthAlgorithm.h"
#include "GaudiKernel/ToolHandle.h"
#include "TrigDecisionTool/TrigDecisionTool.h"
#include "TrigEgammaMatchingTool/ITrigEgammaMatchingTool.h"
class IExecuteTool;
namespace Trig{
class TrigEgammaMatchingToolTest : public AthAlgorithm {
public:
/// Constructor with parameters:
TrigEgammaMatchingToolTest(const std::string& name, ISvcLocator* pSvcLocator);
/// Destructor:
~TrigEgammaMatchingToolTest();
/// Athena algorithm's Hooks
StatusCode initialize();
StatusCode execute();
StatusCode finalize();
private:
/// Default constructor:
TrigEgammaMatchingToolTest();
private:
ToolHandle<Trig::TrigDecisionTool> m_trigdec;
ToolHandle<ITrigEgammaMatchingTool> m_matchTool;
std::vector<std::string> m_triggerList;
std::map<std::string,int> m_counterBits;
std::map<std::string,int> m_counterMatch1Bits;
std::map<std::string,int> m_counterMatch2Bits;
std::map<std::string,int> m_counterMatch3Bits;
StoreGateSvc * m_storeGate;
};
}
#endif
#include "GaudiKernel/DeclareFactoryEntries.h"
#include "TrigEgammaMatchingTool/TrigEgammaMatchingTool.h"
#include "../TrigEgammaMatchingToolTest.h"
DECLARE_NAMESPACE_TOOL_FACTORY(Trig,TrigEgammaMatchingTool)
DECLARE_NAMESPACE_ALGORITHM_FACTORY(Trig,TrigEgammaMatchingToolTest)
DECLARE_FACTORY_ENTRIES(TrigEgammaMatchingTool) {
DECLARE_NAMESPACE_TOOL(Trig,TrigEgammaMatchingTool)
DECLARE_NAMESPACE_ALGORITHM(Trig,TrigEgammaMatchingToolTest)
}
#include "GaudiKernel/LoadFactoryEntries.h"
LOAD_FACTORY_ENTRIES(TrigEgammaMatchingTool)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment