Commit 755da505 authored by Ryan Mackenzie White's avatar Ryan Mackenzie White Committed by Graeme Stewart
Browse files

fix for athana (TrigAnalysisExamples-00-01-09)

	* Remove TrigEDM for AthAnalysisBase
	* TrigAnalysisExamples-00-01-09

2016-09-13 Ryan White <ryan.white@cern.ch>
	* Compile for AthAnalysisBase
	* TrigAnalysisExamples-00-01-08

2016-09-13 Ryan White <ryan.white@cern.ch>
	* AthAnalysis JO (no RecExCommon, good for athena too)
	* TrigAnalysisExamples-00-01-07

2016-09-12 Ryan White <ryan.white@cern.ch>
	* Remove athena-only dependencies
	* TrigAnalysisExamples-00-01-06


Former-commit-id: d248f660
parent eb87f91e
......@@ -13,6 +13,9 @@ atlas_depends_on_subdirs( PUBLIC
Event/xAOD/xAODTrigger
Event/xAOD/xAODEgamma
Event/xAOD/xAODTau
Event/xAOD/xAODTrigEgamma
Event/xAOD/xAODTrigCalo
Event/xAOD/xAODJet
Trigger/TrigConfiguration/TrigConfHLTData
PRIVATE
Control/AthenaBaseComps
......@@ -25,7 +28,6 @@ atlas_depends_on_subdirs( PUBLIC
Trigger/TrigAnalysis/TrigAnalysisInterfaces
Trigger/TrigAnalysis/TrigDecisionTool
Trigger/TrigAnalysis/TriggerMatchingTool
Trigger/TrigAnalysis/TrigEgammaEmulationTool
Trigger/TrigEvent/TrigSteeringEvent
Event/FourMomUtils)
......@@ -38,7 +40,7 @@ atlas_add_component( TrigAnalysisExamples
src/*.cxx
src/components/*.cxx
INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS}
LINK_LIBRARIES ${ROOT_LIBRARIES} ${Boost_LIBRARIES} AthenaBaseComps AthenaKernel StoreGateLib AthAnalysisBaseCompsLib AsgTools SGtests EventInfo GaudiKernel xAODEventInfo xAODTrigger xAODEgamma xAODTau TrigConfHLTData TrigDecisionToolLib TriggerMatchingTool TrigEgammaEmulationTool TrigSteeringEvent FourMomUtils)
LINK_LIBRARIES ${ROOT_LIBRARIES} ${Boost_LIBRARIES} AthenaBaseComps AthenaKernel StoreGateLib AthAnalysisBaseCompsLib AsgTools SGtests EventInfo GaudiKernel xAODEventInfo xAODTrigger xAODEgamma xAODTau xAODTrigEgamma xAODTrigCalo xAODJet TrigConfHLTData TrigDecisionToolLib TriggerMatchingTool TrigSteeringEvent FourMomUtils)
# Install files from the package:
atlas_install_python_modules( python/*.py )
......
......@@ -13,33 +13,39 @@ use TestPolicy TestPolicy-*
use AthenaPython AthenaPython-* Control -no_auto_imports
# for example EDM access test
use TrigParticle TrigParticle-* Trigger/TrigEvent
# use TrigParticle TrigParticle-* Trigger/TrigEvent
private
# xAOD
use xAODTrigger xAODTrigger-* Event/xAOD
use xAODEgamma xAODEgamma-* Event/xAOD
use xAODTrigEgamma xAODTrigEgamma-* Event/xAOD
use xAODTau xAODTau-* Event/xAOD
use xAODCaloEvent xAODCaloEvent-* Event/xAOD
use xAODMuon xAODMuon-* Event/xAOD
use xAODBase xAODBase-* Event/xAOD
use xAODTrigEgamma xAODTrigEgamma-* Event/xAOD
use xAODEventInfo xAODEventInfo-* Event/xAOD
use FourMomUtils FourMomUtils-* Control/FourMomUtils
use xAODJet xAODJet-* Event/xAOD
use xAODTrigCalo xAODTrigCalo-* Event/xAOD
private
# tools for analysis
use FourMomUtils FourMomUtils-* Event
use AthenaBaseComps AthenaBaseComps-* Control
use AthenaKernel AthenaKernel-* Control
use AtlasBoost AtlasBoost-* External
use GaudiInterface GaudiInterface-* External
use AtlasTriggerRunTime AtlasTriggerRunTime-*
use StoreGate StoreGate-* Control
# For the TrigBunchCrossingTool example:
use TrigAnalysisInterfaces TrigAnalysisInterfaces-* Trigger/TrigAnalysis
use EventInfo EventInfo-* Event
# for TrigDecisionTool test
use TrigDecisionTool TrigDecisionTool-* Trigger/TrigAnalysis
use TriggerMatchingTool TriggerMatchingTool-* Trigger/TrigAnalysis
use TrigConfHLTData TrigConfHLTData-* Trigger/TrigConfiguration
# for TrigMatchExamples
public
......@@ -55,6 +61,5 @@ apply_pattern declare_python_modules files="*.py"
apply_pattern declare_joboptions files="*.py"
private
use AnalysisTriggerEvent AnalysisTriggerEvent-* PhysicsAnalysis/AnalysisTrigger
use AtlasROOT AtlasROOT-* External
use TrigSteeringEvent TrigSteeringEvent-* Trigger/TrigEvent
......@@ -100,9 +100,9 @@ tp_electron=TagAndProbeExAlg( "TagAndProbeExAlg", Flavor="Electron",
HLTTriggerList=electronHLTList,
L1TriggerList=["L1_EM15VH","L1_EM22VHI"])
jetmet = JetMetExAlg("JetMetExAlg",HLTTriggerList=['HLT_j300'])
emulator = TrigEmulatorExAlg(HLTTriggerList=electronHLTList,EgammaEmulation=False)
emulator = TrigEmulatorExAlg(HLTTriggerList=electronHLTList)
express=TrigExpressStreamAlg()
tat = TriggerAnalysisTutorial(StatTriggerChains=mergedList,ElectronTriggerList=electronHLTList)
tat = TriggerAnalysisTutorial()
# Histogram routing
ServiceMgr += CfgMgr.THistSvc()
......
from AthenaCommon.AppMgr import theApp
from AthenaCommon.AppMgr import ToolSvc
## get a handle on the ServiceManager
from AthenaCommon.AppMgr import ServiceMgr
#--------------------------------------------------------------
# Load POOL support
#--------------------------------------------------------------
import AthenaPoolCnvSvc.ReadAthenaPool
from glob import glob
if not "InputFiles" in dir():
#InputFiles = [ "/afs/cern.ch/atlas/project/trigger/pesa-sw/validation/validation-data/attila.AOD.pool.root" ]
ServiceMgr.EventSelector.InputCollections = ["/afs/cern.ch/user/r/rwhite/workspace/public/tutorial/data16_13TeV.00307195.physics_Main.merge.DAOD_EGZ.f731_m1616_f731_m1662._0001.1"]
if not "OutputFile" in dir():
OutputFile = "TDTExample.root"
if not "AthenaCommon.AppMgr.EvtMax" in dir():
theApp.EvtMax=20
cfgtool = CfgMgr.TrigConf__xAODConfigTool("xAODConfigTool")
ToolSvc += cfgtool
from TrigDecisionTool.TrigDecisionToolConf import Trig__TrigDecisionTool
ToolSvc += Trig__TrigDecisionTool( "TrigDecisionTool" )
#########################################################################
# #
# Now set up the example job #
# #
#########################################################################
# Define sets of triggers to use
electronHLTList=["HLT_e26_lhtight_nod0_ivarloose","HLT_e26_lhtight_nod0_iloose","HLT_e17_lhloose_nod0"]
tauHLTList=[]
muonHLTList=[]
jetHLTList=["HLT_j300","HLT_3j20"]
combinedList=[]
mergedList=electronHLTList + tauHLTList + muonHLTList + jetHLTList
# Add the additional tools required for running the example algorithms
# Helper tool, provides some simple template methods to dump Navigation of chains
ToolSvc += CfgMgr.Trig__TriggerAnalysisHelper("TriggerAnalysisHelper")
# Matching Tool
ToolSvc += CfgMgr.Trig__MatchingTool("MatchingTool",OutputLevel=DEBUG)
# Emulators
#
# Egamma emulator -- disabled for now
# from TrigEgammaEmulationTool.TrigEgammaEmulationToolConfig import TrigEgammaEmulationToolFactory
# egEmulator = TrigEgammaEmulationToolFactory(elHLTList, name = "TrigEgammaEmulationTool", OutputLevel = INFO)
# Bunch crossing tool
#from TrigBunchCrossingTool.BunchCrossingTool import BunchCrossingTool
#if isMC: bcTool = BunchCrossingTool( "MC" )
#else: bcTool = BunchCrossingTool( "LHC" )
#ToolSvc += bcTool
#
# Trigger Analysis Examples
#
from TrigAnalysisExamples.TrigAnalysisExamplesConf import Trig__TDTExample
from TrigAnalysisExamples.TrigAnalysisExamplesConf import TagAndProbeExAlg
from TrigAnalysisExamples.TrigAnalysisExamplesConf import JetMetExAlg
from TrigAnalysisExamples.TrigAnalysisExamplesConf import TrigEmulatorExAlg
from TrigAnalysisExamples.TrigAnalysisExamplesConf import TrigExpressStreamAlg
from TrigAnalysisExamples.TrigAnalysisExamplesConf import TriggerAnalysisTutorial
from TrigAnalysisExamples.TrigAnalysisExamplesConf import TrigMatchExAlg
tdtexample = Trig__TDTExample( "TDTExample", TriggerList=["HLT_e26_lhtight_nod0_ivarloose","HLT_e26_lhtight_nod0_iloose","HLT_e17_lhloose_nod0"] )
match = TrigMatchExAlg()
tp_electron=TagAndProbeExAlg( "TagAndProbeExAlg", Flavor="Electron",
HLTTriggerList=electronHLTList,
L1TriggerList=["L1_EM15VH","L1_EM22VHI"])
jetmet = JetMetExAlg("JetMetExAlg",HLTTriggerList=['HLT_j300'])
emulator = TrigEmulatorExAlg(HLTTriggerList=electronHLTList)
express=TrigExpressStreamAlg()
tat = TriggerAnalysisTutorial()
# Histogram routing
ServiceMgr += CfgMgr.THistSvc()
ServiceMgr.THistSvc.Output += ["Trigger DATAFILE='TriggerAnalysisTutorial.root' TYP='ROOT' OPT='RECREATE'"]
ServiceMgr.THistSvc.OutputLevel = ERROR
# Add the examples to the top algorithm sequence
from AthenaCommon.AlgSequence import AlgSequence
topSequence = AlgSequence()
topSequence += tdtexample
topSequence += match
topSequence += tp_electron
topSequence += jetmet
#topSequence += emulator
topSequence += express
#topSequence += tat
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: ElectronClusterMetric.cxx 770492 2016-08-28 16:52:40Z rwhite $
// Local include(s):
#include "ElectronClusterMetric.h"
// The only function that a metric need implement
// is calculateDistance(const T *t, const R *r)
// where T is the trigger type you are matching
// and r is the reco type you are matching.
// There are a few rules you must follow when you
// implement the distance function:
//
// (1) The distance must be greater than or equal to
// zero. Anything less than 0 will be treated as
// infinitely far away.
// (2) Smaller distances mean closer. So, for example,
// if you measure the distance between two things
// as the number of hits they share, you should
// return one over that number.
// (3) The actual scale you set with the distance does
// not matter, as long as you set the cutoff
// appropriately. Numbers between 0 and 100
// work just as well numbers between 0 and 1
float ElectronClusterMetric::calculateDistance(
const xAOD::TrigElectron *trig,
const xAOD::Electron *reco) const {
// test for valid parameters
if(!trig || !reco)
return -1.;
// We can instantiate the default deltaR distance functor to
// calculate deltaR for us
//DeltaRDistanceFunctor<xAOD::CaloCluster,xAOD::TrigEMCluster> deltaRMetric;
//float dist = deltaRMetric(reco->cluster(), trig->cluster());
float dist=0.;
return dist;
}
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef ELECTRON_CLUSTER_METRIC
#define ELECTRON_CLUSTER_METRIC
// EDM include(s):
#include "xAODTrigEgamma/TrigElectron.h"
#include "xAODEgamma/Electron.h"
//#include "TrigObjectMatching/DistanceFunctor.h"
/**
* @brief The ElectronClusterMetric is a brief example how to
* define a custom metric for performing trigger object
* matching.
*
* In this case, we determine the distance between a
* TrigElectronContainer and a reconstructed electron
* as the smallest DeltaR between the cluster associated
* with the electron and the clusters associated
* with the trigger electrons. Please see
* ElectronClusterMetric.cxx for more information
*
* @author Ben Smith <bcsmith@fas.harvard.edu> - Harvard University
*
*/
class ElectronClusterMetric {
public:
ElectronClusterMetric() {};
virtual ~ElectronClusterMetric() {};
private:
virtual float calculateDistance(const xAOD::TrigElectron *t, const xAOD::Electron *u) const;
};
/*class ElectronClusterMetric :
public DistanceFunctor<xAOD::TrigElectron, xAOD::Electron> {
public:
// note that if the metric needed access to private data
// (like the trig decision tool, or an eta cut, etc.) it
// can be passed via the constructor like any other object
ElectronClusterMetric() {};
virtual ~ElectronClusterMetric() {};
private:
// this is the only function that you need to implement. The base
// class takes care of everything else, including reflexivity.
virtual float calculateDistance(const xAOD::TrigElectron *t, const xAOD::Electron *u) const;
};*/
#endif
......@@ -2,7 +2,7 @@
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: TagAndProbeExAlg.cxx 771843 2016-09-05 16:56:27Z rwhite $
// $Id: TagAndProbeExAlg.cxx 771815 2016-09-05 15:04:05Z rwhite $
// Updated to xAOD for Trigger Tutorial
//
// Gaudi/Athena include(s):
......
......@@ -4,7 +4,7 @@
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: TagAndProbeExAlg.h 771843 2016-09-05 16:56:27Z rwhite $
// $Id: TagAndProbeExAlg.h 773008 2016-09-13 14:08:35Z rwhite $
#ifndef TRIGANALYSISEXAMPLES_TAG_AND_PROBE_EX_ALG_H
#define TRIGANALYSISEXAMPLES_TAG_AND_PROBE_EX_ALG_H
......@@ -24,6 +24,10 @@
#include "TrigDecisionTool/TrigDecisionTool.h"
#include "TriggerMatchingTool/IMatchingTool.h"
#include "TriggerAnalysisHelper.h"
// xAOD include
#include "xAODMuon/MuonContainer.h"
#include "xAODEgamma/ElectronContainer.h"
/**
* @brief The TagAndProbeExAlg is an example of how to use
* the TrigMatchTool to do a tag and probe measurement with
......
......@@ -21,13 +21,11 @@ TrigEmulatorExAlg::TrigEmulatorExAlg( const std::string& name, ISvcLocator *pSvc
m_trigDec( "Trig::TrigDecisionTool/TrigDecisionTool" ),
m_matchTool( "Trig::MatchingTool/MatchingTool",this),
m_tah( "Trig::TriggerAnalysisHelper/TriggerAnalysisHelper",this ),
m_egEmulationTool("Trig::TrigEgammaEmulationTool/TrigEgammaEmulationTool",this),
m_histSvc( "THistSvc", name ) {
// job option configurable properties
declareProperty( "L1TriggerList", m_l1chainList);
declareProperty( "HLTTriggerList", m_hltchainList);
declareProperty( "EgammaEmulation", m_doEg=false);
}
StatusCode TrigEmulatorExAlg::initialize() {
......@@ -35,10 +33,8 @@ StatusCode TrigEmulatorExAlg::initialize() {
CHECK( m_trigDec.retrieve() );
CHECK( m_matchTool.retrieve() );
CHECK( m_tah.retrieve() );
CHECK(m_egEmulationTool.retrieve());
CHECK( m_histSvc.retrieve() );
CHECK(m_egEmulationTool->initialize());
m_trigDec->ExperimentalAndExpertMethods()->enable();
//Setup histograms for trigger decision and prescale
......@@ -122,15 +118,6 @@ StatusCode TrigEmulatorExAlg::collectTriggerStatistics() {
* TriggerAnalysis for TrigEmulator
* *******************************************************************************************/
StatusCode TrigEmulatorExAlg::EmulationAnalysis (){
if(m_doEg){
m_egEmulationTool->EventWiseContainer(); // Need to retrieve all trigger containers
for(const auto chain : m_hltchainList){
if(m_egEmulationTool->isPassed(chain)){
m_numHLTEmulatedEvents[chain]+=1;
h_emulationAccepts->Fill( chain.c_str(), 1 );
}
} //
}
return StatusCode::SUCCESS;
}
......
......@@ -24,14 +24,14 @@
#include "TrigDecisionTool/TrigDecisionTool.h"
#include "TriggerMatchingTool/IMatchingTool.h"
#include "TriggerAnalysisHelper.h"
#include "TrigEgammaEmulationTool/ITrigEgammaEmulationTool.h"
/**
* @brief
*
* Example code for emulating the trigger decision
* from reconstructed objects, e.g. L1 Objects
*
*
* @author
* @author Ryan White <ryan.white@cern.ch>
*
* Please see the .cxx file for detailed comments
*
......@@ -66,9 +66,6 @@ private:
ToolHandle<Trig::IMatchingTool> m_matchTool;
//! Helper class for tutorial, provides an additional layer to illustrate TDT functionality
ToolHandle< Trig::TriggerAnalysisHelper > m_tah;
//! Egamma TrigEmulator tool
ToolHandle<Trig::ITrigEgammaEmulationTool> m_egEmulationTool;
// The THistSvc
ServiceHandle< ITHistSvc > m_histSvc;
......
......@@ -2,7 +2,7 @@
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: TrigMatchExAlg.cxx 770909 2016-08-30 19:59:36Z rwhite $
// $Id: TrigMatchExAlg.cxx 772674 2016-09-12 09:12:29Z rwhite $
// Athena/Gaudi include(s):
#include "AthenaKernel/errorcheck.h"
......@@ -15,7 +15,6 @@
// Local include(s):
#include "TrigMatchExAlg.h"
#include "ElectronClusterMetric.h"
TrigMatchExAlg::TrigMatchExAlg( const std::string& name, ISvcLocator *pSvcLocator )
: AthAlgorithm( name, pSvcLocator ),
......
......@@ -12,6 +12,9 @@
#include "TrigDecisionTool/TrigDecisionTool.h"
#include "TriggerMatchingTool/IMatchingTool.h"
#include "xAODTrigger/TrigPassBits.h"
#include "xAODTrigCalo/TrigEMCluster.h"
#include "xAODTrigEgamma/TrigElectronContainer.h"
//TrigConf include(s)
#include "TrigConfHLTData/HLTTriggerElement.h"
......
......@@ -2,7 +2,7 @@
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: TriggerAnalysisTutorial.cxx 771843 2016-09-05 16:56:27Z rwhite $
// $Id: TriggerAnalysisTutorial.cxx 772674 2016-09-12 09:12:29Z rwhite $
// System include(s):
#include <iomanip>
......@@ -41,7 +41,8 @@ TriggerAnalysisTutorial::TriggerAnalysisTutorial( const std::string &name,
m_tah( "Trig::TriggerAnalysisHelper/TriggerAnalysisHelper",this ),
m_bcTool( "Trig::TrigConfBunchCrossingTool/BunchCrossingTool" ),
m_histSvc( "THistSvc", name ) {
declareProperty( "TriggerList", m_chain_names, "List of triggers to analyze");
}
TriggerAnalysisTutorial::~TriggerAnalysisTutorial()
......@@ -75,6 +76,18 @@ StatusCode TriggerAnalysisTutorial::execute() {
++m_eventNr;
ATH_MSG_INFO( "Event Number " << m_eventNr );
// Get list of configured chains on first event
// Check HLT chains are configured and push_back on cfg_chains
if(m_eventNr==1){
std::vector<std::string> allHLT = m_trigDec->getChainGroup("HLT_.*")->getListOfTriggers();
// Create list of configured chains from input list
for(const std::string chain:allHLT){
if(std::find(m_chain_names.begin(), m_chain_names.end(), chain) != m_chain_names.end()){
ATH_MSG_INFO("Found corresponding chain in list " << chain);
m_cfg_chains.push_back(chain);
}
}
}
return StatusCode::SUCCESS;
}
......
......@@ -4,7 +4,7 @@
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: TriggerAnalysisTutorial.h 771843 2016-09-05 16:56:27Z rwhite $
// $Id: TriggerAnalysisTutorial.h 772674 2016-09-12 09:12:29Z rwhite $
#ifndef TRIGANALYSISEXAMPLES_TRIGGERANALYSISTUTORIAL_H
#define TRIGANALYSISEXAMPLES_TRIGGERANALYSISTUTORIAL_H
......@@ -37,7 +37,7 @@ class TH1;
* @author Ricardo Goncalo <goncalo@cern.ch> - University
*
* Updated August 2016 for ATLAS Trigger for Physics Workshop
* Empty algorithm -- see other examples
* Some basic trigger analysis code -- see other examples
* Can we make one common algorithm to put everything together?
* @author Ryan White <rwhite@cern.ch> - UTFSM
*/
......@@ -59,6 +59,10 @@ public:
private:
int m_eventNr;
int m_eventsPrinted;
std::vector< std::string > m_chain_names;
std::vector< std::string > m_cfg_chains;
// TrigDecisionTool
ToolHandle< Trig::TrigDecisionTool > m_trigDec;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment