ATLAS Offline Software
Loading...
Searching...
No Matches
PadEmulatorTool.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4#ifndef PADEMULATORTOOL_H
5#define PADEMULATORTOOL_H
6
8#include "Gaudi/Property.h"
9#include "GaudiKernel/ConcurrencyFlags.h"
10#include "GaudiKernel/ITHistSvc.h"
11#include "GaudiKernel/ServiceHandle.h"
20#include "PadPattern.h"
22#include "PadEmulatorTrigger.h"
25#include "TrigT1NSWSimExtras.h"
26#include <fstream>
27
39
40namespace NSWL1 {
41
42 class PadEmulatorTool : public extends<AthAlgTool, IPadEmulatorTool> {
43
44 public:
45 PadEmulatorTool(const std::string& type, const std::string& name, const IInterface* parent);
46 virtual ~PadEmulatorTool() override = default;
47
48 virtual StatusCode initialize() override;
49 StatusCode loadPatterns(const std::string& pfile);
50 StatusCode maskPads();
51 StatusCode maskPatterns();
52 StatusCode createRobIDs();
53 virtual StatusCode attachBranches(MuonVal::MuonTesterTree &tree) override;
54 virtual StatusCode emulate(const EventContext& ctx, Muon::NSW_PadTriggerDataContainer* out) const override;
55
56 // Filter functions
57 std::vector<uint32_t> getForbiddenBandIDs(const std::vector<PadEmulatorTrigger>& triggers, const bool isLarge) const;
58 std::vector<PadEmulatorTrigger> filterPriorityEncoder(const std::vector<PadEmulatorTrigger>& input, const bool isLarge) const;
59 std::vector<PadEmulatorTrigger> filterLowBandIDs(const std::vector<PadEmulatorTrigger>& input) const;
60 std::vector<PadEmulatorTrigger> filterLastPhiOnly(const std::vector<PadEmulatorTrigger>& input) const;
61 std::vector<PadEmulatorTrigger> filterDuplicates(const std::vector<PadEmulatorTrigger>& input) const;
62
63 private:
64 Gaudi::Property<bool> m_isMC {this, "IsMC", true, "This is MC"};
65 Gaudi::Property<bool> m_doNtuple {this, "DoNtuple", false, "Save trigger information into the analysis flat ntuple"};
66 Gaudi::Property<unsigned short> m_stretch {this, "BCstretch", 2, "Number of BCIDs to stretch pad trigger hits"};
67 Gaudi::Property<bool> m_ignoreBCIDs {this, "IgnoreBCIDs", false, "Ignore hit BCIDs"};
68 Gaudi::Property<bool> m_lastPhiOnly {this, "LastPhiOnly", false, "Have phi bias in real data"};
69 Gaudi::Property<bool> m_bandIDPriorityEncode {this, "bandIDPriorityEncode", true, "Have band ID bias"};
70 Gaudi::Property<bool> m_noDuplicates {this, "noDuplicates", false, "Remove trigger candidate duplicates"};
71 Gaudi::Property<std::string> m_triggerLogic {this, "triggerLogic", "specific5over8", "Other options: 3and1, 2and2, 4over8, specific4over8, 5over8, superspecific5over8, 6over8, 2x3over4, 8over8"};
72
73 Gaudi::Property<std::string> m_pattername_L {this, "PadPatternameL",
74 PathResolver::find_calib_file("sTGCPadTriggerSim/patterns_corrected_large_19_12_2023_impr_07_03_2024_forFW.vhdl"), "Name of the vhdl file with pad patterns for LARGE sectors"};
75 Gaudi::Property<std::string> m_pattername_S {this, "PadPatternameS",
76 PathResolver::find_calib_file("sTGCPadTriggerSim/patterns_corrected_small_19_12_2023_impr_07_03_2024_forFW.vhdl"), "Name of the vhdl file with pad patterns for SMALL sectors"};
77
78 SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> m_detectorManagerKey {this, "DetectorManagerKey", "MuonDetectorManager", "Key of MuonDetectorManager condition data"};
79 ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};
80 SG::ReadHandleKey<sTgcDigitContainer> m_sTGCDigitContainerKey = {this, "sTGC_DigitContainerName", "sTGC_DIGITS_L1", "Name of the sTGC digit container"};
81 SG::ReadCondHandleKey<NswDcsDbData> m_dcsKey{this, "DCSDataKey", "NswDcsDbData", "Read key for the NSW DCS data"};
82
83 std::vector<uint32_t> m_robIDs;
84 std::vector<PadPattern> m_patterns_L, m_patterns_S;
85 std::map<std::string, std::vector<std::tuple<uint32_t, uint32_t>>> m_maskedPatterns;
86
87 /*
88 * Flat ntuple branches for debug purposes: wheel, sector, hitmask, bandid, phiid, relbcid and other TP quantities
89 */
90 std::shared_ptr<MuonVal::VectorBranch<int> > m_padTrigger_digits_sector ATLAS_THREAD_SAFE {};
91 std::shared_ptr<MuonVal::VectorBranch<int> > m_padTrigger_digits_eta ATLAS_THREAD_SAFE {};
92 std::shared_ptr<MuonVal::VectorBranch<int> > m_padTrigger_digits_phi ATLAS_THREAD_SAFE {};
93 std::shared_ptr<MuonVal::VectorBranch<int> > m_padTrigger_digits_multilayer ATLAS_THREAD_SAFE {};
94 std::shared_ptr<MuonVal::VectorBranch<int> > m_padTrigger_digits_gasgap ATLAS_THREAD_SAFE {};
95 std::shared_ptr<MuonVal::VectorBranch<uint32_t> > m_padTrigger_digits_source_id ATLAS_THREAD_SAFE {};
96 std::shared_ptr<MuonVal::VectorBranch<uint32_t> > m_padTrigger_digits_pfeb ATLAS_THREAD_SAFE {};
97 std::shared_ptr<MuonVal::VectorBranch<uint32_t> > m_padTrigger_digits_pad_channel ATLAS_THREAD_SAFE {};
98 std::shared_ptr<MuonVal::VectorBranch<uint32_t> > m_padTrigger_digits_relbcid ATLAS_THREAD_SAFE {};
99 std::shared_ptr<MuonVal::VectorBranch<uint8_t> > m_padTrigger_TP_R_id_init ATLAS_THREAD_SAFE {};
100 std::shared_ptr<MuonVal::VectorBranch<uint8_t> > m_padTrigger_TP_phi_id_init ATLAS_THREAD_SAFE {};
101 std::shared_ptr<MuonVal::VectorBranch<uint32_t> > m_padTrigger_TP_relbcid_init ATLAS_THREAD_SAFE {};
102 std::shared_ptr<MuonVal::VectorBranch<uint8_t> > m_padTrigger_TP_R_id ATLAS_THREAD_SAFE {};
103 std::shared_ptr<MuonVal::VectorBranch<uint8_t> > m_padTrigger_TP_phi_id ATLAS_THREAD_SAFE {};
104 std::shared_ptr<MuonVal::VectorBranch<uint32_t> > m_padTrigger_TP_relbcid ATLAS_THREAD_SAFE {};
105 std::shared_ptr<MuonVal::VectorBranch<char> > m_padTrigger_wheel ATLAS_THREAD_SAFE {};
106 std::shared_ptr<MuonVal::VectorBranch<uint32_t> > m_padTrigger_sector ATLAS_THREAD_SAFE {};
107 std::shared_ptr<MuonVal::VectorBranch<uint32_t> > m_padTrigger_hitmask ATLAS_THREAD_SAFE {};
108 std::shared_ptr<MuonVal::VectorBranch<uint32_t> > m_padTrigger_efficiency ATLAS_THREAD_SAFE {};
109 };
110}
111#endif
std::vector< uint32_t > getForbiddenBandIDs(const std::vector< PadEmulatorTrigger > &triggers, const bool isLarge) const
std::vector< PadEmulatorTrigger > filterPriorityEncoder(const std::vector< PadEmulatorTrigger > &input, const bool isLarge) const
Gaudi::Property< bool > m_isMC
Gaudi::Property< bool > m_doNtuple
virtual ~PadEmulatorTool() override=default
SG::ReadCondHandleKey< NswDcsDbData > m_dcsKey
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_detectorManagerKey
Gaudi::Property< bool > m_lastPhiOnly
Gaudi::Property< std::string > m_triggerLogic
StatusCode loadPatterns(const std::string &pfile)
std::vector< PadEmulatorTrigger > filterLowBandIDs(const std::vector< PadEmulatorTrigger > &input) const
SG::ReadHandleKey< sTgcDigitContainer > m_sTGCDigitContainerKey
std::map< std::string, std::vector< std::tuple< uint32_t, uint32_t > > > m_maskedPatterns
Gaudi::Property< bool > m_ignoreBCIDs
virtual StatusCode attachBranches(MuonVal::MuonTesterTree &tree) override
Gaudi::Property< std::string > m_pattername_S
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Gaudi::Property< bool > m_noDuplicates
std::shared_ptr< MuonVal::VectorBranch< int > > m_padTrigger_digits_sector ATLAS_THREAD_SAFE
std::vector< PadPattern > m_patterns_S
std::vector< PadEmulatorTrigger > filterLastPhiOnly(const std::vector< PadEmulatorTrigger > &input) const
Gaudi::Property< std::string > m_pattername_L
std::vector< uint32_t > m_robIDs
PadEmulatorTool(const std::string &type, const std::string &name, const IInterface *parent)
virtual StatusCode initialize() override
Gaudi::Property< bool > m_bandIDPriorityEncode
std::vector< PadEmulatorTrigger > filterDuplicates(const std::vector< PadEmulatorTrigger > &input) const
Gaudi::Property< unsigned short > m_stretch
std::vector< PadPattern > m_patterns_L
virtual StatusCode emulate(const EventContext &ctx, Muon::NSW_PadTriggerDataContainer *out) const override
static std::string find_calib_file(const std::string &logical_file_name)
Property holding a SG store/key/clid from which a ReadHandle is made.
PadEmulatorCoincidences.
TChain * tree