ATLAS Offline Software
PadTriggerLookupTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /*
6 This tool utilizes the same LUT as in the pad trigger hardware. Trigger band-id and phi-d are looked up where pad coincidence patterns are keys
7 */
8 #ifndef NSWL1_PadTriggerLookupTool_H
9 #define NSWL1_PadTriggerLookupTool_H
10 
12 #include "GaudiKernel/IIncidentListener.h"
14 #include "GaudiKernel/ServiceHandle.h"
15 
18 
19 #include <unordered_map>
20 #include <string>
21 #include <vector>
22 
23 namespace MuonGM {
24  class MuonDetectorManager;
25 }
26 
27 namespace NSWL1 {
28  //functor to be used to hash pad coincidence patterns for fast lookup
29  struct hashPattern {
30  size_t operator()(const std::vector<int> &vec ) const {
31  std::size_t seed = vec.size();
32  for(auto& i : vec) {
33  seed ^= i + 0x9e3779b9 + (seed << 6) + (seed >> 2);
34  }
35  return seed;
36  }
37  };
39  virtual public IPadTriggerLookupTool, public AthAlgTool, public IIncidentListener {
40  public:
41  PadTriggerLookupTool(const std::string& type,
42  const std::string& name,
43  const IInterface* parent);
44  virtual ~PadTriggerLookupTool()=default;
45  virtual StatusCode initialize() override;
46  virtual void handle (const Incident& inc) override;
47  virtual
48  StatusCode lookup_pad_triggers(const std::vector<std::shared_ptr<PadData>>& pads,
49  std::vector<std::unique_ptr<PadTrigger>> &triggers) override;
50  private:
51  ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};
52  Gaudi::Property<bool> m_dumpSectorGeometry {this, "DumpSectorGeometry", false, "Record sector pad geometry into an ASCII file (1L/1S by default). Use it for debugging"};
53 
55  StatusCode loadCoincidenceTable(const std::string&);
56  // inflates the table by appending 3o4s //empty hits/missing layers are -9999 (const value of the 'nullPadNumber' variable. Never use any nonsense number for non existing values it will break some rules )
58  const std::vector<float> m_etaBandsLargeSector;
59  const std::vector<float> m_etaBandsSmallSector;
60  StatusCode LookupSectorTriggers(const std::vector<std::shared_ptr<PadData>>& pads,int side, int sector, std::vector<std::unique_ptr<PadTrigger>> &triggers);
61  std::vector<std::vector<std::shared_ptr<PadData>>> selectWedgePatterns(const std::vector<std::shared_ptr<PadData>> &pads,int side, int sector,int multiplet) const;
62 
64 
65  std::vector<std::shared_ptr<PadOfflineData>> fetchSectorPads(bool isSmall,int side=1,int sector=1);//use sector number as coming ids
66  std::vector<std::shared_ptr<PadOfflineData>> fetchSmallSectorPads(int side=1,int sector=1);
67  std::vector<std::shared_ptr<PadOfflineData>> fetchLargeSectorPads(int side=1,int sector=1);
68  //void fillGeometricInformation(const std::shared_ptr<PadOfflineData>& );
69  std::pair<int,int> Lookup( std::vector<int> );//fast lookup for phi and bandIds given a set of pads. returns (-1,-1) if nothing is found
70  std::unordered_map<std::vector<int>,std::pair<int,int> ,hashPattern> m_pats;
71  //use sector numbering scheme as in idHelper (i.e sector numbers from {1....8} + S/L)
72  //note that numbering for the sector logic is different ....
73  StatusCode printGeometry( const std::vector<std::shared_ptr<PadOfflineData>>&, std::ofstream&) const;//used for debugging purposes only, has no functionality in the actual trigger
74 
75 
76  };
77 
78 } // namespace NSWL1
79 
80 #endif
NSWL1::PadTriggerLookupTool::m_dumpSectorGeometry
Gaudi::Property< bool > m_dumpSectorGeometry
Definition: PadTriggerLookupTool.h:52
NSWL1::hashPattern::operator()
size_t operator()(const std::vector< int > &vec) const
Definition: PadTriggerLookupTool.h:30
MuonGM
Ensure that the Athena extensions are properly loaded.
Definition: GeoMuonHits.h:27
NSWL1::PadTriggerLookupTool::selectWedgePatterns
std::vector< std::vector< std::shared_ptr< PadData > > > selectWedgePatterns(const std::vector< std::shared_ptr< PadData >> &pads, int side, int sector, int multiplet) const
Definition: PadTriggerLookupTool.cxx:182
TriggerTypes.h
NSWL1::PadTriggerLookupTool::m_etaBandsSmallSector
const std::vector< float > m_etaBandsSmallSector
Definition: PadTriggerLookupTool.h:59
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
NSWL1::PadTriggerLookupTool::expandCoincidenceTable
StatusCode expandCoincidenceTable()
Definition: PadTriggerLookupTool.cxx:126
NSWL1::PadTriggerLookupTool::m_detManager
const MuonGM::MuonDetectorManager * m_detManager
Definition: PadTriggerLookupTool.h:63
python.TrigTLAMonitorAlgorithm.triggers
triggers
Definition: TrigTLAMonitorAlgorithm.py:196
NSWL1::PadTriggerLookupTool::fetchSectorPads
std::vector< std::shared_ptr< PadOfflineData > > fetchSectorPads(bool isSmall, int side=1, int sector=1)
Definition: PadTriggerLookupTool.cxx:401
NSWL1::PadTriggerLookupTool::handle
virtual void handle(const Incident &inc) override
Definition: PadTriggerLookupTool.cxx:57
TRT::Hit::side
@ side
Definition: HitInfo.h:83
NSWL1::hashPattern
Definition: PadTriggerLookupTool.h:29
lumiFormat.i
int i
Definition: lumiFormat.py:85
NSWL1::PadTriggerLookupTool::printGeometry
StatusCode printGeometry(const std::vector< std::shared_ptr< PadOfflineData >> &, std::ofstream &) const
Definition: PadTriggerLookupTool.cxx:461
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::PadTriggerLookupTool::loadCoincidenceTable
StatusCode loadCoincidenceTable(const std::string &)
load the 4o4 coincidence table
Definition: PadTriggerLookupTool.cxx:94
NSWL1::PadTriggerLookupTool::m_pats
std::unordered_map< std::vector< int >, std::pair< int, int >,hashPattern > m_pats
Definition: PadTriggerLookupTool.h:70
NSWL1::PadTriggerLookupTool::~PadTriggerLookupTool
virtual ~PadTriggerLookupTool()=default
IPadTriggerLookupTool.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
NSWL1::PadTriggerLookupTool::Lookup
std::pair< int, int > Lookup(std::vector< int >)
Definition: PadTriggerLookupTool.cxx:487
NSWL1::PadTriggerLookupTool::m_etaBandsLargeSector
const std::vector< float > m_etaBandsLargeSector
Definition: PadTriggerLookupTool.h:58
NSWL1::PadTriggerLookupTool::PadTriggerLookupTool
PadTriggerLookupTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: PadTriggerLookupTool.cxx:28
NSWL1::PadTriggerLookupTool::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: PadTriggerLookupTool.h:51
MuonGM::MuonDetectorManager
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h:50
NSWL1::PadTriggerLookupTool
Definition: PadTriggerLookupTool.h:39
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
NSWL1::PadTriggerLookupTool::initialize
virtual StatusCode initialize() override
Definition: PadTriggerLookupTool.cxx:36
NSWL1::PadTriggerLookupTool::fetchSmallSectorPads
std::vector< std::shared_ptr< PadOfflineData > > fetchSmallSectorPads(int side=1, int sector=1)
Definition: PadTriggerLookupTool.cxx:454
AthAlgTool
Definition: AthAlgTool.h:26
NSWL1::PadTriggerLookupTool::fetchLargeSectorPads
std::vector< std::shared_ptr< PadOfflineData > > fetchLargeSectorPads(int side=1, int sector=1)
Definition: PadTriggerLookupTool.cxx:457
NSWL1::PadTriggerLookupTool::lookup_pad_triggers
virtual StatusCode lookup_pad_triggers(const std::vector< std::shared_ptr< PadData >> &pads, std::vector< std::unique_ptr< PadTrigger >> &triggers) override
Definition: PadTriggerLookupTool.cxx:67
NSWL1
A trigger trigger candidate for a stgc sector.
Definition: NSWL1Simulation.cxx:9
NSWL1::IPadTriggerLookupTool
Definition: IPadTriggerLookupTool.h:19
IMuonIdHelperSvc.h
ServiceHandle< Muon::IMuonIdHelperSvc >
NSWL1::PadTriggerLookupTool::LookupSectorTriggers
StatusCode LookupSectorTriggers(const std::vector< std::shared_ptr< PadData >> &pads, int side, int sector, std::vector< std::unique_ptr< PadTrigger >> &triggers)
Definition: PadTriggerLookupTool.cxx:309