ATLAS Offline Software
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 
40 namespace 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);
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
NSWL1::PadEmulatorTool
Definition: PadEmulatorTool.h:42
PathResolver::find_calib_file
static std::string find_calib_file(const std::string &logical_file_name)
Definition: PathResolver.cxx:273
TrigT1NSWSimExtras.h
NSWL1::PadEmulatorTool::attachBranches
virtual StatusCode attachBranches(MuonVal::MuonTesterTree &tree) override
Definition: PadEmulatorTool.cxx:48
sTgcIdHelper.h
NSWL1::PadEmulatorTool::m_triggerLogic
Gaudi::Property< std::string > m_triggerLogic
Definition: PadEmulatorTool.h:71
NSW_PadTriggerDataContainer.h
NSWL1::PadEmulatorTool::m_isMC
Gaudi::Property< bool > m_isMC
Definition: PadEmulatorTool.h:64
NSWL1::PadEmulatorTool::m_pattername_S
Gaudi::Property< std::string > m_pattername_S
Definition: PadEmulatorTool.h:75
NSWL1::PadEmulatorTool::m_lastPhiOnly
Gaudi::Property< bool > m_lastPhiOnly
Definition: PadEmulatorTool.h:68
LArNewCalib_Delay_OFC_Cali.pfile
string pfile
Definition: LArNewCalib_Delay_OFC_Cali.py:183
NSWL1::PadEmulatorTool::m_patterns_S
std::vector< PadPattern > m_patterns_S
Definition: PadEmulatorTool.h:84
NSWL1::PadEmulatorTool::m_maskedPatterns
std::map< std::string, std::vector< std::tuple< uint32_t, uint32_t > > > m_maskedPatterns
Definition: PadEmulatorTool.h:85
NSWL1::PadEmulatorTool::m_doNtuple
Gaudi::Property< bool > m_doNtuple
Definition: PadEmulatorTool.h:65
NSWL1::PadEmulatorTool::m_patterns_L
std::vector< PadPattern > m_patterns_L
Definition: PadEmulatorTool.h:84
NSWL1::PadEmulatorTool::maskPatterns
StatusCode maskPatterns()
Definition: PadEmulatorTool.cxx:513
tree
TChain * tree
Definition: tile_monitor.h:30
Muon::NSW_PadTriggerDataContainer
Definition: NSW_PadTriggerDataContainer.h:15
NSWL1::PadEmulatorTool::~PadEmulatorTool
virtual ~PadEmulatorTool() override=default
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:70
NSWL1::PadEmulatorTool::ATLAS_THREAD_SAFE
std::shared_ptr< MuonVal::VectorBranch< int > > m_padTrigger_digits_sector ATLAS_THREAD_SAFE
Definition: PadEmulatorTool.h:90
NSWL1::PadEmulatorTool::m_dcsKey
SG::ReadCondHandleKey< NswDcsDbData > m_dcsKey
Definition: PadEmulatorTool.h:81
PadEmulatorCoincidences.h
NSW_PadTriggerSegment.h
NSWL1::PadEmulatorTool::m_sTGCDigitContainerKey
SG::ReadHandleKey< sTgcDigitContainer > m_sTGCDigitContainerKey
Definition: PadEmulatorTool.h:80
NSWL1::PadEmulatorTool::initialize
virtual StatusCode initialize() override
Definition: PadEmulatorTool.cxx:11
python.TrigTLAMonitorAlgorithm.triggers
triggers
Definition: TrigTLAMonitorAlgorithm.py:196
NSWL1::PadEmulatorTool::getForbiddenBandIDs
std::vector< uint32_t > getForbiddenBandIDs(const std::vector< PadEmulatorTrigger > &triggers, const bool isLarge) const
Definition: PadEmulatorTool.cxx:343
SG::ReadHandleKey< sTgcDigitContainer >
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
NSWL1::PadEmulatorTool::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: PadEmulatorTool.h:79
MuonVal::MuonTesterTree
Definition: MuonTesterTree.h:30
NSW_PadTriggerData.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AthAlgTool.h
test_pyathena.parent
parent
Definition: test_pyathena.py:15
NSWL1::PadEmulatorTool::m_pattername_L
Gaudi::Property< std::string > m_pattername_L
Definition: PadEmulatorTool.h:73
PadPattern.h
NSWL1::PadEmulatorTool::filterPriorityEncoder
std::vector< PadEmulatorTrigger > filterPriorityEncoder(const std::vector< PadEmulatorTrigger > &input, const bool isLarge) const
Definition: PadEmulatorTool.cxx:365
NSWL1::PadEmulatorTool::createRobIDs
StatusCode createRobIDs()
Definition: PadEmulatorTool.cxx:558
NSWL1::PadEmulatorTool::emulate
virtual StatusCode emulate(const EventContext &ctx, Muon::NSW_PadTriggerDataContainer *out) const override
Definition: PadEmulatorTool.cxx:95
PadEmulatorTrigger.h
PathResolver.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
NSWL1::PadEmulatorTool::maskPads
StatusCode maskPads()
NSWL1::PadEmulatorTool::filterLowBandIDs
std::vector< PadEmulatorTrigger > filterLowBandIDs(const std::vector< PadEmulatorTrigger > &input) const
Definition: PadEmulatorTool.cxx:378
NSWL1::PadEmulatorTool::loadPatterns
StatusCode loadPatterns(const std::string &pfile)
Definition: PadEmulatorTool.cxx:423
MuonDetectorManager.h
NSWL1::PadEmulatorTool::m_ignoreBCIDs
Gaudi::Property< bool > m_ignoreBCIDs
Definition: PadEmulatorTool.h:67
NSWL1::PadEmulatorTool::filterLastPhiOnly
std::vector< PadEmulatorTrigger > filterLastPhiOnly(const std::vector< PadEmulatorTrigger > &input) const
Definition: PadEmulatorTool.cxx:390
NSWL1::PadEmulatorTool::m_bandIDPriorityEncode
Gaudi::Property< bool > m_bandIDPriorityEncode
Definition: PadEmulatorTool.h:69
NSWL1::PadEmulatorTool::filterDuplicates
std::vector< PadEmulatorTrigger > filterDuplicates(const std::vector< PadEmulatorTrigger > &input) const
Definition: PadEmulatorTool.cxx:407
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager >
sTgcDigit.h
NSWL1::PadEmulatorTool::m_noDuplicates
Gaudi::Property< bool > m_noDuplicates
Definition: PadEmulatorTool.h:70
sTgcDigitContainer.h
NSWL1::PadEmulatorTool::m_detectorManagerKey
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_detectorManagerKey
Definition: PadEmulatorTool.h:78
NswDcsDbData.h
IPadEmulatorTool.h
NSWL1
PadEmulatorCoincidences.
Definition: NSWL1Simulation.cxx:7
NSWL1::PadEmulatorTool::m_stretch
Gaudi::Property< unsigned short > m_stretch
Definition: PadEmulatorTool.h:66
NSWL1::PadEmulatorTool::PadEmulatorTool
PadEmulatorTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: PadEmulatorTool.cxx:8
NSWL1::PadEmulatorTool::m_robIDs
std::vector< uint32_t > m_robIDs
Definition: PadEmulatorTool.h:83
ServiceHandle< Muon::IMuonIdHelperSvc >