ATLAS Offline Software
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 
6 namespace{
8  static const HitList dummy{};
9 }
10 
11 namespace 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  }
65  bool TgcHitClusteringObj::buildClusters3D() {
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 }
TgcHitClustering.h
Muon::TgcHitClusteringObj::cluster
bool cluster(const HitList &col)
MuonGM::TgcReadoutElement::spacePointPosition
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...
Definition: MuonDetDescr/MuonReadoutGeometry/src/TgcReadoutElement.cxx:332
Muon::TgcPrepData::detectorElement
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 ...
Definition: TgcPrepData.h:120
Muon
This class provides conversion from CSC RDO data to CSC Digits.
Definition: TrackSystemController.h:49
read_hist_ntuple.h1
h1
Definition: read_hist_ntuple.py:21
std::stable_sort
void stable_sort(std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, std::reverse_iterator< DataModel_detail::iterator< DVL > > end, Compare comp)
Specialization of stable_sort for DataVector/List.
Definition: DVL_algorithms.h:711
Muon::TgcHitClusteringObj::HitList
TgcClusterObj3D::HitList HitList
Definition: TgcHitClustering.h:49
Muon::TgcHitClusteringObj::clustersEta
std::vector< HitList > clustersEta
Definition: TgcHitClustering.h:67
TgcIdHelper::channel
int channel(const Identifier &id) const override
Definition: TgcIdHelper.cxx:649
Muon::TgcHitClusteringObj::bestEtaCluster
const HitList & bestEtaCluster() const
Definition: TgcHitClustering.cxx:12
Muon::TgcClusterObj3D::Edge
Edge
Representation of the four edge points.
Definition: TgcHitClustering.h:30
MuonGM::TgcReadoutElement
A TgcReadoutElement corresponds to a single TGC chamber; therefore typically a TGC station contains s...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/TgcReadoutElement.h:42
AnalysisUtils::copy_if
Out copy_if(In first, const In &last, Out res, const Pred &p)
Definition: IFilterUtils.h:30
python.xAODType.dummy
dummy
Definition: xAODType.py:4
Muon::TgcHitClusteringObj::m_tgcIdHelper
const TgcIdHelper * m_tgcIdHelper
Definition: TgcHitClustering.h:66
Trk::PrepRawData::identify
Identifier identify() const
return the identifier
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
Muon::TgcClusterObj3D
Definition: TgcHitClustering.h:19
query_example.col
col
Definition: query_example.py:7
a
TList * a
Definition: liststreamerinfos.cxx:10
Muon::TgcPrepData
Class to represent TGC measurements.
Definition: TgcPrepData.h:32
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:569
Muon::TgcHitClusteringObj::bestPhiCluster
const HitList & bestPhiCluster() const
Definition: TgcHitClustering.cxx:15
Muon::TgcHitClusteringObj::clustersPhi
std::vector< HitList > clustersPhi
Definition: TgcHitClustering.h:68