ATLAS Offline Software
Loading...
Searching...
No Matches
TgcHitClustering.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6namespace{
8 static const HitList dummy{};
9}
10
11namespace Muon {
13 return clustersEta.size() ? clustersEta.front() : dummy;
14 }
16 return clustersPhi.size() ? clustersPhi.front() : dummy;
17 }
19 std::vector<HitList>& finalClusts) {
20 if (filteredHits.empty()) return false;
21 finalClusts.reserve(filteredHits.size());
22 std::sort(filteredHits.begin(), filteredHits.end(),
23 [this](const TgcPrepData* h1,const TgcPrepData* h2) {
24 const int gap1{m_tgcIdHelper->gasGap(h1->identify())}, gap2{m_tgcIdHelper->gasGap(h2->identify())};
25 if (gap1 != gap2) return gap1 < gap2;
26 return m_tgcIdHelper->channel(h1->identify()) < m_tgcIdHelper->channel(h2->identify());
27 });
28
29 for (const TgcPrepData* prd : filteredHits) {
31 if (finalClusts.empty() ||
32 m_tgcIdHelper->channel(finalClusts.back().back()->identify()) +1 != m_tgcIdHelper->channel(prd->identify()) ||
33 m_tgcIdHelper->gasGap(finalClusts.back().back()->identify()) != m_tgcIdHelper->gasGap(prd->identify())) {
34 finalClusts.emplace_back();
35 }
36 finalClusts.back().push_back(prd);
37 }
38 std::stable_sort(finalClusts.begin(),finalClusts.end(),
39 []( const HitList& a, const HitList& b){
40 return a.size() < b.size();
41 });
42 return true;
43 }
44
45 bool TgcHitClusteringObj::cluster( const std::vector<const TgcPrepData*>& col ){
46
47
48 std::vector<const TgcPrepData*> etaHits{}, phiHits{};
49 etaHits.reserve(col.size());
50 phiHits.reserve(col.size());
51
53 std::copy_if(col.begin(),col.end(), std::back_inserter(etaHits), [this](const TgcPrepData* prd) {
54 return !m_tgcIdHelper->measuresPhi(prd->identify());
55 });
56 std::copy_if(col.begin(),col.end(), std::back_inserter(phiHits), [this](const TgcPrepData* prd){
57 return m_tgcIdHelper->measuresPhi(prd->identify());
58 });
59
60 if (!cluster(etaHits, clustersEta)) return false;
61 if (!cluster(phiHits, clustersPhi)) return false;
62
63 return true;
64 }
66
67 if( clustersPhi.empty() || clustersEta.empty() ) return false;
68
69 const TgcPrepData* etaHit = bestEtaCluster().front();
70
71 const MuonGM::TgcReadoutElement* detEl = etaHit->detectorElement();
72
73 // now loop over eta and phi clusters and form space points
74 for(HitList& eit : clustersEta) {
75
76 const TgcPrepData* firstEta = eit.front();
77 const TgcPrepData* lastEta = eit.back();
78
79 for(HitList& pit : clustersPhi) {
80
81 const TgcPrepData* firstPhi = pit.front();
82 const TgcPrepData* lastPhi = pit.back();
83
84 TgcClusterObj3D cl3D{eit, pit};
85 using Edge = TgcClusterObj3D::Edge;
86
87 detEl->spacePointPosition( firstPhi->identify(), firstEta->identify(), cl3D.getEdge(Edge::LowEtaLowPhi) );
88 if( lastPhi != firstPhi ) {
89 detEl->spacePointPosition( lastPhi->identify(), firstEta->identify(), cl3D.getEdge(Edge::LowEtaHighPhi));
90 } else {
91 cl3D.getEdge(Edge::LowEtaHighPhi) = cl3D.getEdge(Edge::LowEtaLowPhi);
92 }
93 if( lastEta != firstEta ) {
94 detEl->spacePointPosition( firstPhi->identify(),lastEta->identify(), cl3D.getEdge(Edge::HighEtaLowPhi) );
95 if( lastPhi != firstPhi ) {
96 detEl->spacePointPosition( lastPhi->identify(),lastEta->identify(), cl3D.getEdge(Edge::HighEtaHighPhi) );
97 } else {
98 cl3D.getEdge(Edge::HighEtaHighPhi) = cl3D.getEdge(Edge::HighEtaLowPhi);
99 }
100 }else{
101 cl3D.getEdge(Edge::HighEtaLowPhi) = cl3D.getEdge(Edge::LowEtaLowPhi);
102 cl3D.getEdge(Edge::HighEtaHighPhi) = cl3D.getEdge(Edge::LowEtaHighPhi);
103 }
104 clusters3D.push_back(std::move(cl3D));
105 }
106 }
107 return true;
108 }
109
110
111
112}
static Double_t a
if(febId1==febId2)
A TgcReadoutElement corresponds to a single TGC chamber; therefore typically a TGC station contains s...
virtual bool spacePointPosition(const Identifier &phiId, const Identifier &etaId, Amg::Vector2D &pos) const override
space point position for a given pair of phi and eta identifiers The LocalPosition is expressed in th...
Edge
Representation of the four edge points.
Amg::Vector3D & getEdge(const Edge e)
Class to represent TGC measurements.
Definition TgcPrepData.h:32
virtual const MuonGM::TgcReadoutElement * detectorElement() const override final
Returns the detector element corresponding to this PRD The pointer will be zero if the det el is not ...
Identifier identify() const
return the identifier
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
void stable_sort(DataModel_detail::iterator< DVL > beg, DataModel_detail::iterator< DVL > end)
Specialization of stable_sort for DataVector/List.
std::vector< TgcClusterObj3D > clusters3D
const HitList & bestEtaCluster() const
const HitList & bestPhiCluster() const
bool cluster(const HitList &col)
std::vector< HitList > clustersEta
std::vector< HitList > clustersPhi
const TgcIdHelper * m_tgcIdHelper
TgcClusterObj3D::HitList HitList