ATLAS Offline Software
MuonCombinePatternTool.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 #ifndef MUONCOMBINEPATTERNTOOLS_MUONCOMBINEPATTERNTOOL_H
6 #define MUONCOMBINEPATTERNTOOLS_MUONCOMBINEPATTERNTOOL_H
7 
8 
9 #include "AthenaBaseComps/AthAlgTool.h" //base class
10 #include "GaudiKernel/ServiceHandle.h" //member
12 #include "MuonIdHelpers/IMuonIdHelperSvc.h" //template parameter
15 
16 
18 private:
19  struct ChamberInfo {
20  ChamberInfo() = default;
21  int neta{0};
22  int nphi{0};
23  int ninside{0};
24  int noutside{0};
25  int ninsidePat{0};
26  int noutsidePat{0};
27  double phiMin{FLT_MAX};
28  double phiMax{-FLT_MAX};
29  };
30  using IdChMap = std::map<Identifier, ChamberInfo>;
31 
32 public:
33  using PrdPatternPair = std::pair<std::unique_ptr<Muon::MuonPrdPattern>, std::unique_ptr<Muon::MuonPrdPattern>>;
34 
35  using CandPrdPatPtr = std::shared_ptr<const Muon::MuonPrdPattern>;
36  using CandidatePatPair = std::pair<CandPrdPatPtr, CandPrdPatPtr>;
37 
38  MuonCombinePatternTool(const std::string& type, const std::string& name, const IInterface* parent);
39  virtual ~MuonCombinePatternTool() = default;
40 
41  StatusCode initialize() override;
42 
45  std::unique_ptr<MuonPrdPatternCollection> combineEtaPhiPatterns(
46  const MuonPrdPatternCollection& phiPatternCollection, const MuonPrdPatternCollection& etaPatternCollection,
47  const EtaPhiHitAssocMap& phiEtaHitAssMap) const override;
48 
50  std::unique_ptr<Muon::MuonPrdPattern> makeCombinedPattern(const Muon::MuonPrdPattern& phipattern,
51  const Muon::MuonPrdPattern& etapattern) const override;
52 
55  virtual std::unique_ptr<MuonPatternCombinationCollection> makePatternCombinations(const MuonPrdPatternCollection& muonpatterns) const override;
56 
57 private:
60  std::unique_ptr<MuonPrdPatternCollection> makeCombinedPatterns(std::vector<CandidatePatPair>& candidates) const;
61 
63  static bool subset(const Muon::MuonPrdPattern* pattern1, const Muon::MuonPrdPattern* pattern2);
64 
66  static bool subset(std::pair<PrepDataSet, PrepDataSet>& candidate1,
67  std::pair<PrepDataSet, PrepDataSet>& candidate2);
68 
69 
72  std::unique_ptr<Muon::MuonPrdPattern> cleanPhiPattern(std::unique_ptr<Muon::MuonPrdPattern> phipattern) const;
73 
75  std::unique_ptr<Muon::MuonPrdPattern> cleanupCombinedPattern(const Muon::MuonPrdPattern& combinedpattern) const;
76 
78  std::vector<PrdPatternPair> splitPatterns2D(const Muon::MuonPrdPattern* phipattern,
79  const Muon::MuonPrdPattern* etapattern) const;
80 
82  std::vector<PrdPatternPair> splitPatterns3D(const Muon::MuonPrdPattern* phipattern,
83  const Muon::MuonPrdPattern* etapattern) const;
84 
88  std::vector<PrdPatternPair> splitPatternsCylinder(const Muon::MuonPrdPattern* phipattern,
89  const Muon::MuonPrdPattern* etapattern) const;
90 
95  std::unique_ptr<Muon::MuonPrdPattern> makeAssPhiPattern(
97  const EtaPhiHitAssocMap& phiEtaHitAssMap,
98  bool check = false) const;
99 
102  std::array<double,4> updateParametersForCosmics(const Muon::MuonPrdPattern& phipattern,
103  const Muon::MuonPrdPattern& etapattern) const;
104 
107  std::pair<double, double> calculateR0Phi(const Muon::MuonPrdPattern& phipattern, const Muon::MuonPrdPattern& etapattern,
108  double phi_estimate = -M_PI_2) const;
109 
111  static double calculateRz0(const Muon::MuonPrdPattern& pattern, double phi, double theta);
112 
116  const Muon::MuonPrdPattern& etapattern,
117  const std::array<double,4>& new_pars) const;
118 
121  void addCandidate(const CandPrdPatPtr& etapattern, const CandPrdPatPtr& phipattern,
122  std::vector<CandidatePatPair>& candidates, bool add_asspattern,
123  const EtaPhiHitAssocMap& phiEtaHitAssMap) const;
124 
126  static void cleanCandidates(std::vector<CandidatePatPair>& candidates);
127 
129  void printPattern(const Muon::MuonPrdPattern* muonpattern) const;
130 
133 
135  const double m_maximum_xydistance;
137  const double m_maximum_rzdistance;
138 
141 
144 
148 
152 
156 
160 
161  ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc{this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};
162 
163  PublicToolHandle<Muon::MuonEDMPrinterTool> m_printer{this, "printerTool", "Muon::MuonEDMPrinterTool/MuonEDMPrinterTool",
164  "ToolHandle for EDM printing of segments"};
165 };
166 
167 #endif // MUONCOMBINEPATTERNTOOLS_MUONCOMBINEPATTERNTOOL_H
MuonCombinePatternTool::ChamberInfo::neta
int neta
Definition: MuonCombinePatternTool.h:21
mergePhysValFiles.pattern
pattern
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:26
MuonCombinePatternTool::CandidatePatPair
std::pair< CandPrdPatPtr, CandPrdPatPtr > CandidatePatPair
Definition: MuonCombinePatternTool.h:36
MuonCombinePatternTool::ChamberInfo::phiMax
double phiMax
Definition: MuonCombinePatternTool.h:28
MuonCombinePatternTool::m_maxSizePhiPatternLoose
unsigned int m_maxSizePhiPatternLoose
Definition: MuonCombinePatternTool.h:158
MuonCombinePatternTool::CandPrdPatPtr
std::shared_ptr< const Muon::MuonPrdPattern > CandPrdPatPtr
Definition: MuonCombinePatternTool.h:35
MuonCombinePatternTool::m_maximum_xydistance
const double m_maximum_xydistance
distance cut in xy for hits
Definition: MuonCombinePatternTool.h:135
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
MuonEDMPrinterTool.h
drawFromPickle.candidates
candidates
Definition: drawFromPickle.py:271
theta
Scalar theta() const
theta method
Definition: AmgMatrixBasePlugin.h:75
MuonCombinePatternTool::m_muonHoughMathUtils
MuonHoughMathUtils m_muonHoughMathUtils
object for use of mathematical formulas for trackmodels
Definition: MuonCombinePatternTool.h:132
MuonHoughMathUtils
Definition: MuonHoughMathUtils.h:35
MuonCombinePatternTool::m_maximum_rzdistance
const double m_maximum_rzdistance
distance cut in rz for hits
Definition: MuonCombinePatternTool.h:137
MuonCombinePatternTool::initialize
StatusCode initialize() override
Definition: MuonCombinePatternTool.cxx:58
MuonCombinePatternTool::makeCombinedPattern
std::unique_ptr< Muon::MuonPrdPattern > makeCombinedPattern(const Muon::MuonPrdPattern &phipattern, const Muon::MuonPrdPattern &etapattern) const override
Combines phi and eta pattern into a new combined pattern.
Definition: MuonCombinePatternTool.cxx:648
MuonCombinePatternTool::updateParametersForCosmics
std::array< double, 4 > updateParametersForCosmics(const Muon::MuonPrdPattern &phipattern, const Muon::MuonPrdPattern &etapattern) const
calculate new track parameters of match (only for cosmics!) returns [r0, phi, rz0,...
Definition: MuonCombinePatternTool.cxx:1051
MuonCombinePatternTool::addCandidate
void addCandidate(const CandPrdPatPtr &etapattern, const CandPrdPatPtr &phipattern, std::vector< CandidatePatPair > &candidates, bool add_asspattern, const EtaPhiHitAssocMap &phiEtaHitAssMap) const
adds eta,phi pair to candidate vector, also performs splitting and associated pattern (only for cosmi...
Definition: MuonCombinePatternTool.cxx:1590
Muon::MuonPrdPattern
Class to store a pattern in the muon system containing PrepRawData pointers.
Definition: MuonPrdPattern.h:27
MuonCombinePatternTool::cleanCandidates
static void cleanCandidates(std::vector< CandidatePatPair > &candidates)
clean candidates from subsets or duplicates
Definition: MuonCombinePatternTool.cxx:1651
MuonCombinePatternTool::subset
static bool subset(const Muon::MuonPrdPattern *pattern1, const Muon::MuonPrdPattern *pattern2)
is pattern1 a complete subset of other pattern2?
Definition: MuonCombinePatternTool.cxx:1432
MuonCombinePatternTool::ChamberInfo::ChamberInfo
ChamberInfo()=default
Muon::IMuonCombinePatternTool::EtaPhiHitAssocMap
std::map< const Trk::PrepRawData *, PrepDataSet > EtaPhiHitAssocMap
Definition: IMuonCombinePatternTool.h:25
MuonCombinePatternTool::updatePatternsForCosmics
PrdPatternPair updatePatternsForCosmics(const Muon::MuonPrdPattern &phipattern, const Muon::MuonPrdPattern &etapattern, const std::array< double, 4 > &new_pars) const
update patterns based on new track parameters (used only for cosmics) builds 2 new prd patterns
Definition: MuonCombinePatternTool.cxx:1349
MuonCombinePatternTool::makeCombinedPatterns
std::unique_ptr< MuonPrdPatternCollection > makeCombinedPatterns(std::vector< CandidatePatPair > &candidates) const
make combined pattern from all candidates, removes duplicates with phi when no overlap with eta patte...
Definition: MuonCombinePatternTool.cxx:600
MuonCombinePatternTool::m_use_cosmics
bool m_use_cosmics
use cosmic settings
Definition: MuonCombinePatternTool.h:140
MuonCombinePatternTool::combineEtaPhiPatterns
std::unique_ptr< MuonPrdPatternCollection > combineEtaPhiPatterns(const MuonPrdPatternCollection &phiPatternCollection, const MuonPrdPatternCollection &etaPatternCollection, const EtaPhiHitAssocMap &phiEtaHitAssMap) const override
Combines phi and eta pattern collection into a new combined pattern collection.
Definition: MuonCombinePatternTool.cxx:69
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
MuonCombinePatternTool::PrdPatternPair
std::pair< std::unique_ptr< Muon::MuonPrdPattern >, std::unique_ptr< Muon::MuonPrdPattern > > PrdPatternPair
Definition: MuonCombinePatternTool.h:33
MuonCombinePatternTool::m_flipdirectionforcosmics
bool m_flipdirectionforcosmics
flip direction for cosmics after splitting as if coming from IP (false by default)
Definition: MuonCombinePatternTool.h:155
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
MuonCombinePatternTool::splitPatterns3D
std::vector< PrdPatternPair > splitPatterns3D(const Muon::MuonPrdPattern *phipattern, const Muon::MuonPrdPattern *etapattern) const
split patterns in two at point closest to IP in 3D
Definition: MuonCombinePatternTool.cxx:778
MuonCombinePatternTool::printPattern
void printPattern(const Muon::MuonPrdPattern *muonpattern) const
print out pattern hits
Definition: MuonCombinePatternTool.cxx:1468
MuonCombinePatternTool::~MuonCombinePatternTool
virtual ~MuonCombinePatternTool()=default
MuonCombinePatternTool::cleanupCombinedPattern
std::unique_ptr< Muon::MuonPrdPattern > cleanupCombinedPattern(const Muon::MuonPrdPattern &combinedpattern) const
clean combined pattern, remove outliers
Definition: MuonCombinePatternTool.cxx:920
MuonCombinePatternTool::ChamberInfo::phiMin
double phiMin
Definition: MuonCombinePatternTool.h:27
MuonCombinePatternTool::ChamberInfo::ninsidePat
int ninsidePat
Definition: MuonCombinePatternTool.h:25
MuonCombinePatternTool::ChamberInfo::nphi
int nphi
Definition: MuonCombinePatternTool.h:22
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
MuonCombinePatternTool::m_splitpatterns
bool m_splitpatterns
split patterns (only for cosmics)
Definition: MuonCombinePatternTool.h:143
MuonCombinePatternTool::cleanPhiPattern
std::unique_ptr< Muon::MuonPrdPattern > cleanPhiPattern(std::unique_ptr< Muon::MuonPrdPattern > phipattern) const
clean phi pattern, similar as in MuonHoughPatternTool, used for newly created phi patterns based on h...
Definition: MuonCombinePatternTool.cxx:1498
MuonCombinePatternTool
Definition: MuonCombinePatternTool.h:17
LArNewCalib_Delay_OFC_Cali.check
check
Definition: LArNewCalib_Delay_OFC_Cali.py:258
MuonCombinePatternTool::MuonCombinePatternTool
MuonCombinePatternTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: MuonCombinePatternTool.cxx:38
MuonCombinePatternTool::m_printer
PublicToolHandle< Muon::MuonEDMPrinterTool > m_printer
Definition: MuonCombinePatternTool.h:163
MuonCombinePatternTool::ChamberInfo::ninside
int ninside
Definition: MuonCombinePatternTool.h:23
MuonCombinePatternTool::m_useTightAssociation
bool m_useTightAssociation
Definition: MuonCombinePatternTool.h:157
MuonCombinePatternTool::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: MuonCombinePatternTool.h:161
MuonCombinePatternTool::ChamberInfo::noutsidePat
int noutsidePat
Definition: MuonCombinePatternTool.h:26
MuonCombinePatternTool::calculateRz0
static double calculateRz0(const Muon::MuonPrdPattern &pattern, double phi, double theta)
calculate rz0 for cosmic pattern
Definition: MuonCombinePatternTool.cxx:1310
MuonCombinePatternTool::splitPatterns2D
std::vector< PrdPatternPair > splitPatterns2D(const Muon::MuonPrdPattern *phipattern, const Muon::MuonPrdPattern *etapattern) const
split patterns in two at point closest to IP in rphi
Definition: MuonCombinePatternTool.cxx:719
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
MuonCombinePatternTool::calculateR0Phi
std::pair< double, double > calculateR0Phi(const Muon::MuonPrdPattern &phipattern, const Muon::MuonPrdPattern &etapattern, double phi_estimate=-M_PI_2) const
calculate phi and r0 for cosmic patterns, phi estimate needs to be given
Definition: MuonCombinePatternTool.cxx:1177
MuonCombinePatternTool::m_nodiscarding
bool m_nodiscarding
don't discard any candidates based on gasgap assocation (true by default)
Definition: MuonCombinePatternTool.h:147
IMuonCombinePatternTool.h
MuonCombinePatternTool::splitPatternsCylinder
std::vector< PrdPatternPair > splitPatternsCylinder(const Muon::MuonPrdPattern *phipattern, const Muon::MuonPrdPattern *etapattern) const
split patterns in two when crossing calorimeter at point closest to IP in 3D (should be same as split...
Definition: MuonCombinePatternTool.cxx:889
MuonCombinePatternTool::makePatternCombinations
virtual std::unique_ptr< MuonPatternCombinationCollection > makePatternCombinations(const MuonPrdPatternCollection &muonpatterns) const override
converts MuonPrdPatterns into MuonPatternCombinationCollection MuonPatternCombinationCollection are d...
Definition: MuonCombinePatternTool.cxx:1382
AthAlgTool
Definition: AthAlgTool.h:26
MuonHoughMathUtils.h
MuonCombinePatternTool::makeAssPhiPattern
std::unique_ptr< Muon::MuonPrdPattern > makeAssPhiPattern(const Muon::MuonPrdPattern &pattern, const EtaPhiHitAssocMap &phiEtaHitAssMap, bool check=false) const
make combined phi pattern by associating phi hits to noncombined eta pattern, return 0 if no phi meas...
Definition: MuonCombinePatternTool.cxx:980
MuonCombinePatternTool::IdChMap
std::map< Identifier, ChamberInfo > IdChMap
Definition: MuonCombinePatternTool.h:30
IMuonIdHelperSvc.h
MuonCombinePatternTool::ChamberInfo::noutside
int noutside
Definition: MuonCombinePatternTool.h:24
Muon::IMuonCombinePatternTool
Interface for tools combining Muon::MuonPattern objects.
Definition: IMuonCombinePatternTool.h:14
MuonCombinePatternTool::m_maxSizeEtaPatternLoose
unsigned int m_maxSizeEtaPatternLoose
Definition: MuonCombinePatternTool.h:159
MuonCombinePatternTool::m_bestphimatch
bool m_bestphimatch
take only best phi match as candidate or take all phi matches (false by default, but true for cosmics...
Definition: MuonCombinePatternTool.h:151
MuonCombinePatternTool::ChamberInfo
Definition: MuonCombinePatternTool.h:19
ServiceHandle< Muon::IMuonIdHelperSvc >