diff --git a/Trigger/TrigT1/Global/GlobalSimulation/python/GlobalSimAlgCfg_invMassDPhiInc2.py b/Trigger/TrigT1/Global/GlobalSimulation/python/GlobalSimAlgCfg_invMassDPhiInc2.py index 58c569c32abd2a3fd5b64c75c84b597a92b96d01..5b160ab518aa9e487a4212624d39b265c4d39079 100644 --- a/Trigger/TrigT1/Global/GlobalSimulation/python/GlobalSimAlgCfg_invMassDPhiInc2.py +++ b/Trigger/TrigT1/Global/GlobalSimulation/python/GlobalSimAlgCfg_invMassDPhiInc2.py @@ -9,6 +9,16 @@ from AthenaCommon.Constants import DEBUG def GlobalSimulationAlgCfg(flags, name="GlobalSimHypoContainer", + minEt1Cuts = [0,0,0,0], + minEt2Cuts = [0,0,0,0], + minEta1Cuts = [0,0,0,0], + maxEta1Cuts = [0,0,0,0], + minEta2Cuts = [0,0,0,0], + maxEta2Cuts = [0,0,0,0], + minInvMassSqrCuts = [0,0,0,0], + maxInvMassSqrCuts = [0,0,0,0], + minDeltaPhiCuts = [0,0,0,0], + maxDeltaPhiCuts = [0,0,0,0], OutputLevel=DEBUG, dump=False): @@ -19,6 +29,23 @@ def GlobalSimulationAlgCfg(flags, hypoTool = CompFactory.GlobalSim.InvariantMassDeltaPhiInclusive2AlgTool( 'InvMassDPhiInc2AlgTool') hypoTool.enableDump = dump + + hypoTool.minEt1Cuts = minEt1Cuts + hypoTool.minEt2Cuts = minEt2Cuts + + hypoTool.minEta1Cuts = minEta1Cuts + hypoTool.maxEta1Cuts = maxEta1Cuts + + hypoTool.minEta2Cuts = minEta2Cuts + hypoTool.maxEta2Cuts = maxEta2Cuts + + hypoTool.minInvMassSqrCuts = minInvMassSqrCuts + hypoTool.maxInvMassSqrCuts = maxInvMassSqrCuts + + + hypoTool.minDeltaPhiCuts = minDeltaPhiCuts + hypoTool.maxDeltaPhiCuts = maxDeltaPhiCuts + hypoTool.OutputLevel = OutputLevel alg = CompFactory.GlobalSim.GlobalSimulationAlg(name + 'Alg') diff --git a/Trigger/TrigT1/Global/GlobalSimulation/src/GlobalAlgs/Hypothesis/UCL/GenericTob.h b/Trigger/TrigT1/Global/GlobalSimulation/src/GlobalAlgs/Hypothesis/UCL/GenericTob.h index 976713580adedd3e9ca501ccfe96dd4317d5e8db..21861e1ea02f0d7bf2b1bd2db3ce6d6a823b0d9c 100644 --- a/Trigger/TrigT1/Global/GlobalSimulation/src/GlobalAlgs/Hypothesis/UCL/GenericTob.h +++ b/Trigger/TrigT1/Global/GlobalSimulation/src/GlobalAlgs/Hypothesis/UCL/GenericTob.h @@ -47,7 +47,7 @@ namespace GlobalSim { const std::bitset<1>& overflow_bits() const {return m_Overflow_bits;} std::bitset<32> as_bits() const; - ulong Et () const {return m_Et_bits.to_ulong();} + int Et () const {return bitSetToInt(m_Et_bits);} int Eta () const {return bitSetToInt(m_Eta_bits);} int Phi () const {return bitSetToInt(m_Phi_bits);} int Charge () const{return bitSetToInt(m_Charge_bits);} diff --git a/Trigger/TrigT1/Global/GlobalSimulation/src/GlobalAlgs/Hypothesis/UCL/InvariantMassDeltaPhiInclusive2AlgTool.cxx b/Trigger/TrigT1/Global/GlobalSimulation/src/GlobalAlgs/Hypothesis/UCL/InvariantMassDeltaPhiInclusive2AlgTool.cxx index a5503a39749d6beab2c964480a93c947335c424a..64ea049f19a19ba7befc3107c51f6ce0e45ddda5 100644 --- a/Trigger/TrigT1/Global/GlobalSimulation/src/GlobalAlgs/Hypothesis/UCL/InvariantMassDeltaPhiInclusive2AlgTool.cxx +++ b/Trigger/TrigT1/Global/GlobalSimulation/src/GlobalAlgs/Hypothesis/UCL/InvariantMassDeltaPhiInclusive2AlgTool.cxx @@ -22,12 +22,73 @@ namespace GlobalSim { const IInterface* parent) : base_class(type, name, parent){ } - + + bool cutChecker(const std::vector<int>& vals, std::size_t sz) { + if (vals.size() != sz) {return false;} + return std::all_of(std::cbegin(vals), + std::cend(vals), + [](const auto& v){return v >= 0;}); + } + StatusCode InvariantMassDeltaPhiInclusive2AlgTool::initialize() { CHECK(m_tobsInReadKey1.initialize()); CHECK(m_tobsInReadKey2.initialize()); + CHECK(m_resultsWriteKey.initialize()); + + if(!cutChecker(m_minEt1Cuts, s_NumResultBits)){ + ATH_MSG_ERROR("minimum Et1 cuts error"); + return StatusCode::FAILURE; + } + + if(!cutChecker(m_minEt2Cuts, s_NumResultBits)){ + ATH_MSG_ERROR("minimum Et2 cuts error"); + return StatusCode::FAILURE; + } + + if (m_applyEtaCuts) { + + if(!cutChecker(m_minEta1Cuts, s_NumResultBits)){ + ATH_MSG_ERROR("minimum Eta1 cuts error"); + return StatusCode::FAILURE; + } + + if(!cutChecker(m_maxEta1Cuts, s_NumResultBits)){ + ATH_MSG_ERROR("maximum Eta1 cuts error"); + return StatusCode::FAILURE; + } + + if(!cutChecker(m_minEta2Cuts, s_NumResultBits)){ + ATH_MSG_ERROR("minimum Eta2 cuts error"); + return StatusCode::FAILURE; + } + + if(!cutChecker(m_maxEta2Cuts, s_NumResultBits)){ + ATH_MSG_ERROR("maximum Eta2 cuts error"); + return StatusCode::FAILURE; + } + } + + if(!cutChecker(m_minInvMassSqrCuts, s_NumResultBits)){ + ATH_MSG_ERROR("minimum invariant mass cuts error"); + return StatusCode::FAILURE; + } + + if(!cutChecker(m_maxInvMassSqrCuts, s_NumResultBits)){ + ATH_MSG_ERROR("maximum invariant mass cuts error"); + return StatusCode::FAILURE; + } + + if(!cutChecker(m_minDeltaPhiCuts, s_NumResultBits)){ + ATH_MSG_ERROR("minimum Delta phi cuts error"); + return StatusCode::FAILURE; + } + + if(!cutChecker(m_maxDeltaPhiCuts, s_NumResultBits)){ + ATH_MSG_ERROR("maximum Delta phi cuts error"); + return StatusCode::FAILURE; + } return StatusCode::SUCCESS; } @@ -56,6 +117,22 @@ namespace GlobalSim { } ATH_MSG_DEBUG(ss.str()); + auto tobSelections1 = + std::vector<GenericTobContainer>(s_NumResultBits, + GenericTobContainer()); + CHECK(selectTobs1(*tobs1, tobSelections1)); + + auto tobSelections2 = + std::vector<GenericTobContainer>(s_NumResultBits, + GenericTobContainer()); + CHECK(selectTobs2(*tobs2, tobSelections2)); + + + auto result = std::make_unique<InvariantMassResult>(); + auto h_write = + SG::WriteHandle<InvariantMassResult>(m_resultsWriteKey, ctx); + CHECK(h_write.record(std::move(result))); + return StatusCode::SUCCESS; } @@ -70,5 +147,91 @@ namespace GlobalSim { return ss.str(); } + + StatusCode + InvariantMassDeltaPhiInclusive2AlgTool::selectTobs1(const GenericTobContainer& tobs, + std::vector<GenericTobContainer>& tobSelections) const { + + + + for (std::size_t isel{0}; isel != s_NumResultBits; ++isel) { + if (m_applyEtaCuts) { + CHECK (selectTobs(tobs, + tobSelections[isel], + m_minEt1Cuts[isel], + m_minEta1Cuts[isel], + m_maxEta1Cuts[isel])); + } else { + CHECK (selectTobs(tobs, + tobSelections[isel], + m_minEt1Cuts[isel])); + } + } + + return StatusCode::SUCCESS; + } + + StatusCode + InvariantMassDeltaPhiInclusive2AlgTool::selectTobs2(const GenericTobContainer& tobs, + std::vector<GenericTobContainer>& tobSelections) const { + + + for (std::size_t isel{0}; isel != s_NumResultBits; ++isel) { + if (m_applyEtaCuts) { + CHECK (selectTobs(tobs, + tobSelections[isel], + m_minEt2Cuts[isel], + m_minEta2Cuts[isel], + m_maxEta2Cuts[isel])); + } else { + CHECK (selectTobs(tobs, + tobSelections[isel], + m_minEt2Cuts[isel])); + } + } + return StatusCode::SUCCESS; + } + + + StatusCode + InvariantMassDeltaPhiInclusive2AlgTool::selectTobs(const GenericTobContainer& tobs, + GenericTobContainer& selectedTobs, + int minEt, + int minEta, + int maxEta) const { + + auto tobSelector = [minEt, + minEta, + maxEta] (const auto& t) { + return t->Et() > minEt and t->Eta() >= minEta and t->Eta() <= maxEta; + }; + + std::copy_if(std::cbegin(tobs), + std::cend(tobs), + std::back_inserter(selectedTobs), + tobSelector); + + + return StatusCode::SUCCESS; + } + + StatusCode + InvariantMassDeltaPhiInclusive2AlgTool::selectTobs(const GenericTobContainer& tobs, + GenericTobContainer& selectedTobs, + int minEt) const { + + auto tobSelector = [minEt] (const auto& t) { + return t->Et() > minEt; + }; + + std::copy_if(std::cbegin(tobs), + std::cend(tobs), + std::back_inserter(selectedTobs), + tobSelector); + + + return StatusCode::SUCCESS; + } + } diff --git a/Trigger/TrigT1/Global/GlobalSimulation/src/GlobalAlgs/Hypothesis/UCL/InvariantMassDeltaPhiInclusive2AlgTool.h b/Trigger/TrigT1/Global/GlobalSimulation/src/GlobalAlgs/Hypothesis/UCL/InvariantMassDeltaPhiInclusive2AlgTool.h index 15c2f5b4b4d87c5604afce43f77205ce0746aeb2..a5d2c27f62f483c927197c0320f2683e4ac205ab 100644 --- a/Trigger/TrigT1/Global/GlobalSimulation/src/GlobalAlgs/Hypothesis/UCL/InvariantMassDeltaPhiInclusive2AlgTool.h +++ b/Trigger/TrigT1/Global/GlobalSimulation/src/GlobalAlgs/Hypothesis/UCL/InvariantMassDeltaPhiInclusive2AlgTool.h @@ -10,10 +10,12 @@ */ #include "GenericTob.h" - +#include "InvariantMassResult.h" #include "../../../IGlobalSimAlgTool.h" #include "AthenaBaseComps/AthAlgTool.h" +#include <bitset> + namespace GlobalSim { class InvariantMassDeltaPhiInclusive2AlgTool: public extends<AthAlgTool, IGlobalSimAlgTool> { @@ -42,8 +44,86 @@ namespace GlobalSim { "enableDump", {false}, "flag to enable dumps"}; + + Gaudi::Property<std::vector<int>> m_minEt1Cuts + {this, + "minEt1Cuts", + {}, + "Min Et for Tobs 1" + }; + + Gaudi::Property<std::vector<int>> m_minEt2Cuts + {this, + "minEt2Cuts", + {}, + "Min Et for Tobs 2" + }; + + Gaudi::Property<bool> m_applyEtaCuts + {this, + "applyEtaCuts", + {true}, + "Apply eta cuts if set true" + }; + + Gaudi::Property<std::vector<int>> m_minEta1Cuts + {this, + "minEta1Cuts", + {}, + "Min Eta for Tobs 1" + }; + + Gaudi::Property<std::vector<int>> m_maxEta1Cuts + {this, + "maxEta1Cuts", + {}, + "Max Eta for Tobs 1" + }; + + Gaudi::Property<std::vector<int>> m_minEta2Cuts + {this, + "minEta2Cuts", + {}, + "Min Eta for Tobs 2" + }; + + Gaudi::Property<std::vector<int>> m_maxEta2Cuts + {this, + "maxEta2Cuts", + {}, + "Max Eta for Tobs 2" + }; + Gaudi::Property<std::vector<int>> m_minInvMassSqrCuts + {this, + "minInvMassSqrCuts", + {}, + "minimum invariant mass squared" + }; + + Gaudi::Property<std::vector<int>> m_maxInvMassSqrCuts + {this, + "maxInvMassSqrCuts", + {}, + "maximum invariant mass squared" + }; + + Gaudi::Property<std::vector<int>> m_minDeltaPhiCuts + {this, + "minDeltaPhiCuts", + {}, + "minimum DeltaPhi" + }; + + Gaudi::Property<std::vector<int>> m_maxDeltaPhiCuts + {this, + "maxDeltaPhiCuts", + {}, + "maximum DeltaPhi" + }; + + SG::ReadHandleKey<GenericTobContainer> m_tobsInReadKey1 { this, @@ -51,8 +131,6 @@ namespace GlobalSim { "genericTobContainer1", "key to read a container of Generic TOBS"}; - - SG::ReadHandleKey<GenericTobContainer> m_tobsInReadKey2 { this, @@ -60,7 +138,39 @@ namespace GlobalSim { "genericTobContainer2", "key to read a container of Generic TOBS"}; + + SG::WriteHandleKey<InvariantMassResult> + m_resultsWriteKey { + this, + "ResultsKey", + "yesultsKey", + "key to write a bitset of results"}; + + + StatusCode + selectTobs1(const GenericTobContainer&, + std::vector<GenericTobContainer>&) const; + + StatusCode + selectTobs2(const GenericTobContainer&, + std::vector<GenericTobContainer>&) const; + + StatusCode + selectTobs(const GenericTobContainer&, + GenericTobContainer&, + int minEt, + int minEta, + int maxEta) const; + + + StatusCode + selectTobs(const GenericTobContainer&, + GenericTobContainer&, + int minEt) const; + }; + + } #endif diff --git a/Trigger/TrigT1/Global/GlobalSimulation/src/GlobalAlgs/Hypothesis/UCL/InvariantMassResult.h b/Trigger/TrigT1/Global/GlobalSimulation/src/GlobalAlgs/Hypothesis/UCL/InvariantMassResult.h new file mode 100644 index 0000000000000000000000000000000000000000..ebb87a1b32074c4dab5d605c59367b136cbb5cd2 --- /dev/null +++ b/Trigger/TrigT1/Global/GlobalSimulation/src/GlobalAlgs/Hypothesis/UCL/InvariantMassResult.h @@ -0,0 +1,19 @@ +/* + Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef GLOBALSIM_INVARIANTMASSRESULT_H +#define GLOBALSIM_INVARIANTMASSRESULT_H + +#include <bitset> + +#include <ostream> + +namespace GlobalSim { + constexpr static std::size_t s_NumResultBits{4}; + using InvariantMassResult = std::bitset<s_NumResultBits>; +} + +CLASS_DEF( GlobalSim::InvariantMassResult , 227725379 , 1 ) + +#endif diff --git a/Trigger/TrigT1/Global/GlobalSimulation/src/GlobalAlgs/Hypothesis/UCL/eEmSortSelectCountContainerAlgTool.cxx b/Trigger/TrigT1/Global/GlobalSimulation/src/GlobalAlgs/Hypothesis/UCL/eEmSortSelectCountContainerAlgTool.cxx index 29269b2d6ef53cfb7458d9b16078250a388ac66c..6473a4a7130be9d70eb0ef691ba4d964dde97bd2 100644 --- a/Trigger/TrigT1/Global/GlobalSimulation/src/GlobalAlgs/Hypothesis/UCL/eEmSortSelectCountContainerAlgTool.cxx +++ b/Trigger/TrigT1/Global/GlobalSimulation/src/GlobalAlgs/Hypothesis/UCL/eEmSortSelectCountContainerAlgTool.cxx @@ -47,9 +47,9 @@ namespace GlobalSim { // All values set to EM5 for now m_count_EtMin = - std::vector<std::vector<unsigned int>> (s_NumCnt, - std::vector<unsigned int>(s_NumEtaRanges, - 0x019)); + std::vector<std::vector<int>> (s_NumCnt, + std::vector<int>(s_NumEtaRanges, + 0x019)); // Eta min is tricky: diff --git a/Trigger/TrigT1/Global/GlobalSimulation/src/GlobalAlgs/Hypothesis/UCL/eEmSortSelectCountContainerAlgTool.h b/Trigger/TrigT1/Global/GlobalSimulation/src/GlobalAlgs/Hypothesis/UCL/eEmSortSelectCountContainerAlgTool.h index bf348212bf210a6aae1f73b4e6fd530f7c09c889..ca53cfa5f65c5ced72351b49bfae9d398e0c0740 100644 --- a/Trigger/TrigT1/Global/GlobalSimulation/src/GlobalAlgs/Hypothesis/UCL/eEmSortSelectCountContainerAlgTool.h +++ b/Trigger/TrigT1/Global/GlobalSimulation/src/GlobalAlgs/Hypothesis/UCL/eEmSortSelectCountContainerAlgTool.h @@ -76,7 +76,7 @@ namespace GlobalSim { // s_NumCnt: one entry per set of count cuts. The inner vector // will be initialised to have length 3, one cut for eacn of the // three eta regions. - std::vector<std::vector<unsigned int>> m_count_EtMin; + std::vector<std::vector<int>> m_count_EtMin; std::vector<std::vector<int>> m_count_EtaMin; std::vector<std::vector<int>> m_count_EtaMax;