diff --git a/PhysicsAnalysis/PrimaryDPDMaker/CMakeLists.txt b/PhysicsAnalysis/PrimaryDPDMaker/CMakeLists.txt index cc960c20431874852d743deaabea0a0463e2b030..82d53fa620c7d3c8ae9bedf157e465dc4316c38f 100644 --- a/PhysicsAnalysis/PrimaryDPDMaker/CMakeLists.txt +++ b/PhysicsAnalysis/PrimaryDPDMaker/CMakeLists.txt @@ -12,6 +12,7 @@ atlas_depends_on_subdirs( PUBLIC Control/AthenaKernel Control/DataModel Control/StoreGate + PhysicsAnalysis/DerivationFramework/DerivationFrameworkInterfaces DetectorDescription/IRegionSelector DetectorDescription/Identifier Event/EventKernel diff --git a/PhysicsAnalysis/PrimaryDPDMaker/PrimaryDPDMaker/BCIDFilterTool.h b/PhysicsAnalysis/PrimaryDPDMaker/PrimaryDPDMaker/BCIDFilterTool.h new file mode 100644 index 0000000000000000000000000000000000000000..ccb29f4962a98cdb8d5855f2f303bd5683297507 --- /dev/null +++ b/PhysicsAnalysis/PrimaryDPDMaker/PrimaryDPDMaker/BCIDFilterTool.h @@ -0,0 +1,50 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// BCIDFilterTool.h, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +#ifndef PRIMARYDPDMAKER_BCIDFILTERTOOL_H +#define PRIMARYDPDMAKER_BCIDFILTERTOOL_H + +#include<string> +#include <vector> + +// Gaudi & Athena basics +#include "AthenaBaseComps/AthAlgTool.h" + +// DerivationFramework includes +#include "DerivationFrameworkInterfaces/ISkimmingTool.h" + +/** @class BCIDFilterTool + + @author Christian Ohm -at- cern.ch + */ +class BCIDFilterTool : public AthAlgTool, public DerivationFramework::ISkimmingTool { + + public: + /** Constructor with parameters */ + BCIDFilterTool( const std::string& t, const std::string& n, const IInterface* p ); + + /** Destructor */ + ~BCIDFilterTool(); + + // Athena algtool's Hooks + StatusCode initialize(); + StatusCode finalize(); + + /** Check that the current event passes this filter */ + virtual bool eventPassesFilter() const; + + private: + mutable unsigned int m_ntot; + mutable unsigned int m_npass; + + std::vector<int> m_acceptBCIDs; + std::vector<int> m_rejectBCIDs; + +}; + +#endif diff --git a/PhysicsAnalysis/PrimaryDPDMaker/cmt/requirements b/PhysicsAnalysis/PrimaryDPDMaker/cmt/requirements index ed139753b1005891c73f7f626d68ba0ada207cc0..336f5201d83c082f7f328b00ea950574eb101c56 100644 --- a/PhysicsAnalysis/PrimaryDPDMaker/cmt/requirements +++ b/PhysicsAnalysis/PrimaryDPDMaker/cmt/requirements @@ -41,6 +41,8 @@ use TrkTrack TrkTrack-* Tracking/TrkEvent #Needed for RegSelSvc use IRegionSelector IRegionSelector-* DetectorDescription +use DerivationFrameworkInterfaces DerivationFrameworkInterfaces-* PhysicsAnalysis/DerivationFramework + private use NavFourMom NavFourMom-* Event use AtlasROOT AtlasROOT-* External diff --git a/PhysicsAnalysis/PrimaryDPDMaker/python/PrimaryDPDFlags.py b/PhysicsAnalysis/PrimaryDPDMaker/python/PrimaryDPDFlags.py index 142d34c3678a42f9139fe4e634fde3d072c98ba2..d93ef37b3ddcedbd6b5f9ecd7483b35c2c1e68b1 100644 --- a/PhysicsAnalysis/PrimaryDPDMaker/python/PrimaryDPDFlags.py +++ b/PhysicsAnalysis/PrimaryDPDMaker/python/PrimaryDPDFlags.py @@ -352,6 +352,50 @@ class WriteDRAW_EMU(JobProperty): jobproperties.PrimaryDPDFlags.add_JobProperty(WriteDRAW_EMU) listRAWtoDPD.append(WriteDRAW_EMU.StreamName) +class WriteDRAW_BCID1(JobProperty): + """ Produce the BCID-filtered DRAW, based on the AcceptBCIDs list (Byte Stream format).""" + statusOn = True + allowedTypes = ['bool'] + StoredValue = False + StreamName = "StreamDRAW_BCID1" + FileName = "" + Prescale = 1 + AcceptBCIDs = [11, 1247, 2430] + isVirtual = False + DPDMakerScript = "PrimaryDPDMaker/DRAW_BCID1.py" + pass +jobproperties.PrimaryDPDFlags.add_JobProperty(WriteDRAW_BCID1) +listRAWtoDPD.append(WriteDRAW_BCID1.StreamName) + +class WriteDRAW_BCID2(JobProperty): + """ Produce the BCID-filtered DRAW, based on the RejectBCIDs list (Byte Stream format).""" + statusOn = True + allowedTypes = ['bool'] + StoredValue = False + StreamName = "StreamDRAW_BCID2" + FileName = "" + Prescale = 1 + RejectBCIDs = [11, 1247, 2430] + isVirtual = False + DPDMakerScript = "PrimaryDPDMaker/DRAW_BCID2.py" + pass +jobproperties.PrimaryDPDFlags.add_JobProperty(WriteDRAW_BCID2) +listRAWtoDPD.append(WriteDRAW_BCID2.StreamName) + +class WriteDRAW_TOPSLMU(JobProperty): + """ Produce DRAW_TOPSLMU, a top-like single-muon selection for tau embedding used by H+ searches.""" + statusOn = True + allowedTypes = ['bool'] + StoredValue = False + StreamName = "StreamDRAW_TOPSLMU" + FileName = "" + Prescale = 1 + isVirtual = False + DPDMakerScript = "PrimaryDPDMaker/DRAW_TOPSLMU.py" + pass +jobproperties.PrimaryDPDFlags.add_JobProperty(WriteDRAW_TOPSLMU) +listRAWtoDPD.append(WriteDRAW_TOPSLMU.StreamName) + ##-------------------------------------------- ## Skimmed ESD ##-------------------------------------------- diff --git a/PhysicsAnalysis/PrimaryDPDMaker/share/DRAW_BCID1.py b/PhysicsAnalysis/PrimaryDPDMaker/share/DRAW_BCID1.py new file mode 100644 index 0000000000000000000000000000000000000000..b3f986e5d29063174fd8804811d21ec654a296b3 --- /dev/null +++ b/PhysicsAnalysis/PrimaryDPDMaker/share/DRAW_BCID1.py @@ -0,0 +1,53 @@ +#################################################### +### Setup: +### sequencer +### derivation framework / event selection +#################################################### + +# Sequence +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() +DRAW_BCID1_Seq = CfgMgr.AthSequencer("DRAW_BCID1_Seq") + +from PrimaryDPDMaker.PrimaryDPDMakerConf import BCIDFilterTool +bcidFilterTool = BCIDFilterTool( name = "BCID1Filter", + AcceptBCIDs = jobproperties.PrimaryDPDFlags.WriteDRAW_BCID1.AcceptBCIDs + ) + +bcidFilterTool.OutputLevel = 3 # INFO +ToolSvc += bcidFilterTool + +# Kernel algorithm +from DerivationFrameworkCore.DerivationFrameworkCoreConf import DerivationFramework__DerivationKernel +DRAW_BCID1_Seq += CfgMgr.DerivationFramework__DerivationKernel("DRAW_BCID1Kernel", + SkimmingTools = [bcidFilterTool] + ) +topSequence += DRAW_BCID1_Seq + +################## +### Output stream +################## +from OutputStreamAthenaPool.MultipleStreamManager import MSMgr +from D2PDMaker.D2PDHelpers import buildFileName +from PrimaryDPDMaker.PrimaryDPDFlags import primDPD +streamName = primDPD.WriteDRAW_BCID1.StreamName +fileName = buildFileName( primDPD.WriteDRAW_BCID1 ) +# Remove the .pool.root ending in the file name, this is a RAW file! +if fileName.endswith(".pool.root") : + fileName = fileName.rstrip(".pool.root") + pass +StreamDRAW_BCID1 = MSMgr.NewByteStream( streamName, fileName ) +StreamDRAW_BCID1.AddRequireAlgs(["DRAW_BCID1Kernel"]) + +# Don't write an output RAW file if it is empty +StreamDRAW_BCID1.bsOutputSvc.WriteEventlessFiles = primDPD.WriteEventlessFiles() + + +######################################### +# Add the containers to the output stream +######################################### +from PrimaryDPDMaker import PrimaryDPD_OutputDefinitions as dpdOutput + +# Take everything from the input +ExcludeList=[] +dpdOutput.addAllItemsFromInputExceptExcludeList(streamName,ExcludeList) diff --git a/PhysicsAnalysis/PrimaryDPDMaker/share/DRAW_BCID2.py b/PhysicsAnalysis/PrimaryDPDMaker/share/DRAW_BCID2.py new file mode 100644 index 0000000000000000000000000000000000000000..8343a0353b88e23b7a3b07c73de144eaa13ad2d4 --- /dev/null +++ b/PhysicsAnalysis/PrimaryDPDMaker/share/DRAW_BCID2.py @@ -0,0 +1,53 @@ +#################################################### +### Setup: +### sequencer +### derivation framework / event selection +#################################################### + +# Sequence +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() +DRAW_BCID2_Seq = CfgMgr.AthSequencer("DRAW_BCID2_Seq") + +from PrimaryDPDMaker.PrimaryDPDMakerConf import BCIDFilterTool +bcidFilterTool = BCIDFilterTool( name = "BCID2Filter", + RejectBCIDs = jobproperties.PrimaryDPDFlags.WriteDRAW_BCID2.RejectBCIDs + ) + +bcidFilterTool.OutputLevel = 3 # INFO +ToolSvc += bcidFilterTool + +# Kernel algorithm +from DerivationFrameworkCore.DerivationFrameworkCoreConf import DerivationFramework__DerivationKernel +DRAW_BCID2_Seq += CfgMgr.DerivationFramework__DerivationKernel("DRAW_BCID2Kernel", + SkimmingTools = [bcidFilterTool] + ) +topSequence += DRAW_BCID2_Seq + +################## +### Output stream +################## +from OutputStreamAthenaPool.MultipleStreamManager import MSMgr +from D2PDMaker.D2PDHelpers import buildFileName +from PrimaryDPDMaker.PrimaryDPDFlags import primDPD +streamName = primDPD.WriteDRAW_BCID2.StreamName +fileName = buildFileName( primDPD.WriteDRAW_BCID2 ) +# Remove the .pool.root ending in the file name, this is a RAW file! +if fileName.endswith(".pool.root") : + fileName = fileName.rstrip(".pool.root") + pass +StreamDRAW_BCID2 = MSMgr.NewByteStream( streamName, fileName ) +StreamDRAW_BCID2.AddRequireAlgs(["DRAW_BCID2Kernel"]) + +# Don't write an output RAW file if it is empty +StreamDRAW_BCID2.bsOutputSvc.WriteEventlessFiles = primDPD.WriteEventlessFiles() + + +######################################### +# Add the containers to the output stream +######################################### +from PrimaryDPDMaker import PrimaryDPD_OutputDefinitions as dpdOutput + +# Take everything from the input +ExcludeList=[] +dpdOutput.addAllItemsFromInputExceptExcludeList(streamName,ExcludeList) diff --git a/PhysicsAnalysis/PrimaryDPDMaker/share/DRAW_TOPSLMU.py b/PhysicsAnalysis/PrimaryDPDMaker/share/DRAW_TOPSLMU.py new file mode 100644 index 0000000000000000000000000000000000000000..0dffbd16a48519c326336cbac0446f7c36c2a4a6 --- /dev/null +++ b/PhysicsAnalysis/PrimaryDPDMaker/share/DRAW_TOPSLMU.py @@ -0,0 +1,84 @@ +#################################################### +## Name: DRAW_TOPSLMU.py +## +## Author: anna bozena kowalewska +## Email: anna.bozena.kowalewska@cern.ch +## +## Description: This defines the content of the +##ttbar single tight muon DRAW output stream. +#################################################### + +# Sequence +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() +DRAW_TOPSLMU_Seq = CfgMgr.AthSequencer("DRAW_TOPSLMU_Seq") + + +##============================================================================ +## Define the skimming (event selection) for the DRAW_TOPSLMU output stream +##============================================================================ +# Object selection strings +# FixedCutBEff_77 for btag +sel_muon = 'Muons.pt > 30.0*GeV && abs(Muons.eta) < 2.5 && (Muons.quality == 0)' +sel_jet = 'AntiKt4EMTopoJets.pt > 25*GeV && abs(AntiKt4EMTopoJets.eta) < 2.5' +sel_bjet = 'AntiKt4EMTopoJets.pt > 25*GeV && abs(AntiKt4EMTopoJets.eta) < 2.5 && BTagging_AntiKt4EMTopo.MV2c10_discriminant>0.645925' +sel_el = 'Electrons.pt > 20*GeV && ( Electrons.Loose || Electrons.LHLoose ) && abs( Electrons.eta) < 2.47' + +#met = 'MET_Reference_AntiKt4EMTopo["FinalClus"].met > 55*GeV' +met = 'MET_Reference_AntiKt4EMTopo["FinalTrk"].met > 45*GeV' + +#triggers for periodD3 Run=302872, events=474 +muTriggers = ['HLT_mu20_iloose_L1MU15','HLT_mu24_ivarmedium','HLT_mu24_imedium'] + +# Event selection string: +draw_ttbar = '( count('+sel_muon+')==1 && count('+sel_jet+')>=3 && count('+sel_bjet+')>=1 && count('+sel_el+') == 0 && count('+met+') >=1 ) && (' + " || ".join(muTriggers) + ')' + +print "This is the selection string that will be used for DRAW_TOPSLMU:" +print draw_ttbar + +# Event selection tool +from DerivationFrameworkTools.DerivationFrameworkToolsConf import DerivationFramework__xAODStringSkimmingTool +DRAW_TOPSLMU_SkimmingTool = DerivationFramework__xAODStringSkimmingTool(name = "DRAW_TOPSLMU_SkimmingTool", + expression = draw_ttbar) + +ToolSvc += DRAW_TOPSLMU_SkimmingTool + +print "Skimming tool:" +print DRAW_TOPSLMU_SkimmingTool + +# Kernel algorithm +from DerivationFrameworkCore.DerivationFrameworkCoreConf import DerivationFramework__DerivationKernel +DRAW_TOPSLMU_Seq += CfgMgr.DerivationFramework__DerivationKernel("DRAW_TOPSLMUKernel", + SkimmingTools = [DRAW_TOPSLMU_SkimmingTool] + ) + +topSequence += DRAW_TOPSLMU_Seq + + +################## +### Output stream +################## +from OutputStreamAthenaPool.MultipleStreamManager import MSMgr +from D2PDMaker.D2PDHelpers import buildFileName +from PrimaryDPDMaker.PrimaryDPDFlags import primDPD +streamName = primDPD.WriteDRAW_TOPSLMU.StreamName +fileName = buildFileName( primDPD.WriteDRAW_TOPSLMU ) +# Remove the .pool.root ending in the file name, this is a RAW file! +if fileName.endswith(".pool.root") : + fileName = fileName.rstrip(".pool.root") + pass + +StreamDRAW_TOPSLMU = MSMgr.NewByteStream( streamName, fileName ) +StreamDRAW_TOPSLMU.AddRequireAlgs(["DRAW_TOPSLMUKernel"]) + +# Don't write an output RAW file if it is empty +StreamDRAW_TOPSLMU.bsOutputSvc.WriteEventlessFiles = primDPD.WriteEventlessFiles() + +######################################### +# Add the containers to the output stream +######################################### +from PrimaryDPDMaker import PrimaryDPD_OutputDefinitions as dpdOutput + +# Take everything from the input +ExcludeList=[] +dpdOutput.addAllItemsFromInputExceptExcludeList(streamName,ExcludeList) diff --git a/PhysicsAnalysis/PrimaryDPDMaker/src/BCIDFilterTool.cxx b/PhysicsAnalysis/PrimaryDPDMaker/src/BCIDFilterTool.cxx new file mode 100644 index 0000000000000000000000000000000000000000..579b2166f9815c494d86093630c41b5decb6b268 --- /dev/null +++ b/PhysicsAnalysis/PrimaryDPDMaker/src/BCIDFilterTool.cxx @@ -0,0 +1,84 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +///////////////////////////////////////////////////////////////// +// BCIDFilterTool.cxx, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +#include "PrimaryDPDMaker/BCIDFilterTool.h" + +#include "xAODEventInfo/EventInfo.h" + +#include <string> + +// Constructor +BCIDFilterTool::BCIDFilterTool( const std::string& t, + const std::string& n, + const IInterface* p ) : + AthAlgTool(t,n,p), + m_ntot(0), + m_npass(0) + { + declareInterface<DerivationFramework::ISkimmingTool>(this); + declareProperty("AcceptBCIDs", m_acceptBCIDs); + declareProperty("RejectBCIDs", m_rejectBCIDs); + } + +// Destructor +BCIDFilterTool::~BCIDFilterTool() {} + +// Athena initialize and finalize +StatusCode BCIDFilterTool::initialize() +{ + ATH_MSG_VERBOSE("initialize() ..."); + if (m_acceptBCIDs.size() && m_rejectBCIDs.size()) { + ATH_MSG_ERROR("Failed to initialize - both accept and reject BCIDs specified, please only use one"); + return StatusCode::FAILURE; + } + if (!(m_acceptBCIDs.size() || m_rejectBCIDs.size())) { + ATH_MSG_ERROR("Neither AcceptBCIDs nor RejectBCIDs specified, can't use filter!"); + } + if (m_acceptBCIDs.size()) { + ATH_MSG_INFO("Events with the following " << m_acceptBCIDs.size() << " BCIDs will be accepted into the stream"); + for (int bcid : m_acceptBCIDs) ATH_MSG_INFO(" " << bcid); + } + if (m_rejectBCIDs.size()) { + ATH_MSG_INFO("Events with the following " << m_rejectBCIDs.size() << " BCIDs will be rejected from the stream"); + for (int bcid : m_rejectBCIDs) ATH_MSG_INFO(" " << bcid); + } + + return StatusCode::SUCCESS; +} +StatusCode BCIDFilterTool::finalize() +{ + ATH_MSG_VERBOSE("finalize() ..."); + ATH_MSG_INFO("Processed "<< m_ntot <<" events, "<< m_npass<<" events passed filter "); + return StatusCode::SUCCESS; +} + +// The filter itself +bool BCIDFilterTool::eventPassesFilter() const +{ + ++m_ntot; + + const xAOD::EventInfo* ei(0); + ATH_CHECK( evtStore()->retrieve(ei, "EventInfo") ); + + int bcid = ei->bcid(); + + if (m_acceptBCIDs.size()) { + for (auto acceptBCID : m_acceptBCIDs) { + if (bcid == acceptBCID) return true; + } + return false; + } + + else { + for (auto rejectBCID : m_rejectBCIDs) { + if (bcid == rejectBCID) return false; + } + return true; + } +} + diff --git a/PhysicsAnalysis/PrimaryDPDMaker/src/components/PrimaryDPDMaker_entries.cxx b/PhysicsAnalysis/PrimaryDPDMaker/src/components/PrimaryDPDMaker_entries.cxx index ce9cb1fe9e9ebaa915bd71c094c948b3ae8d8a5b..c2cd49de20b02aaffb902ab43feb7a574a1e68cc 100644 --- a/PhysicsAnalysis/PrimaryDPDMaker/src/components/PrimaryDPDMaker_entries.cxx +++ b/PhysicsAnalysis/PrimaryDPDMaker/src/components/PrimaryDPDMaker_entries.cxx @@ -4,6 +4,7 @@ #include "PrimaryDPDMaker/ThinContainers.h" #include "PrimaryDPDMaker/MBTSTimeFilterTool.h" #include "PrimaryDPDMaker/CaloTimeFilterTool.h" +#include "PrimaryDPDMaker/BCIDFilterTool.h" #include "PrimaryDPDMaker/CollisionFilterAlg.h" #include "PrimaryDPDMaker/muonTrkTrackThinTool.h" @@ -13,6 +14,7 @@ DECLARE_ALGORITHM_FACTORY( CollisionFilterAlg ) DECLARE_ALGORITHM_FACTORY( muonTrkTrackThinTool ) DECLARE_TOOL_FACTORY( MBTSTimeFilterTool ) DECLARE_TOOL_FACTORY( CaloTimeFilterTool ) +DECLARE_TOOL_FACTORY( BCIDFilterTool ) DECLARE_FACTORY_ENTRIES( PrimaryDPDMaker ) { @@ -22,4 +24,5 @@ DECLARE_FACTORY_ENTRIES( PrimaryDPDMaker ) DECLARE_ALGORITHM( muonTrkTrackThinTool ); DECLARE_TOOL( MBTSTimeFilterTool ); DECLARE_TOOL( CaloTimeFilterTool ); + DECLARE_TOOL( BCIDFilterTool ); }