18 const float OneOverSqrt12 = 1. / std::sqrt(12);
35 return StatusCode::SUCCESS;
39 const MuonLayerPrepRawData& layerPrepRawData, std::vector<std::shared_ptr<const Muon::MuonSegment> >& segments)
const {
41 " Running segment finding in sector "
44 <<
intersection.trackParameters->position().perp() <<
" z " <<
intersection.trackParameters->position().z() <<
" locX "
46 <<
" phi " <<
intersection.trackParameters->position().phi());
58 std::vector<std::shared_ptr<const Muon::MuonSegment>>& segments)
const {
69 intersection.layerSurface.regionIndex == DetectorRegionIndex::Barrel ? TechnologyIndex::RPC : TechnologyIndex::TGC;
70 const std::vector<const MdtDriftCircleOnTrack*>& mdts = layerROTs.
getMdts();
71 const std::vector<const MuonClusterOnTrack*>& clusters = layerROTs.
getClusters(clusterTech);
77 const std::vector<const MdtDriftCircleOnTrack*>& mdts,
78 const std::vector<const MuonClusterOnTrack*>& clusters,
79 std::vector<std::shared_ptr<const Muon::MuonSegment>>& segments)
const {
81 if (mdts.size() <= 2)
return;
83 std::unique_ptr<Trk::SegmentCollection> segColl = std::make_unique<Trk::SegmentCollection>(
SG::VIEW_ELEMENTS);
85 !clusters.empty(), segColl.get(),
intersection.trackParameters->momentum().mag());
90 segments.emplace_back(mseg);
96 std::vector<std::shared_ptr<const Muon::MuonSegment>>& segments)
const {
101 if (layerPrepRawData.
mms.empty() && layerPrepRawData.
stgcs.empty())
return;
110 ATH_MSG_DEBUG(
" MM prds " << layerPrepRawData.
mms.size() <<
" STGC prds " << layerPrepRawData.
stgcs.size());
113 const std::vector<const MuonClusterOnTrack*>& clustersSTGC = layerROTs.
getClusters(TechnologyIndex::STGC);
114 const std::vector<const MuonClusterOnTrack*>& clustersMM = layerROTs.
getClusters(TechnologyIndex::MM);
117 NSWSegmentCache cache{};
120 if (!clustersSTGC.empty()) {
122 std::transform(clustersSTGC.begin(), clustersSTGC.end(), std::back_inserter(cache.inputClust),
126 if (!clustersMM.empty()) {
128 std::transform(clustersMM.begin(), clustersMM.end(), std::back_inserter(cache.inputClust),
131 if (cache.inputClust.empty())
return;
134 if (!m_patternSegs.empty()) {
135 std::set<Identifier> needed_rios{};
136 for (std::unique_ptr<const MuonClusterOnTrack>& clus : cache.inputClust) {
137 needed_rios.insert(clus->identify());
149 hasNSW |= (clus && needed_rios.count(clus->identify()));
152 if (!hasNSW)
continue;
154 if (m_segmentMatchingTool->match(ctx,
intersection, *seg)) segments.emplace_back(seg->
clone());
161 m_clusterSegMakerNSW->find(ctx, cache);
163 for (std::unique_ptr<MuonSegment>& seg : cache.constructedSegs) {
165 segments.emplace_back(std::move(seg));
170 std::vector<std::shared_ptr<const Muon::MuonSegment>>& segments)
const {
173 if (!combi2D)
return;
176 std::unique_ptr<MuonSegmentCombinationCollection> combi4D =
m_csc4dSegmentFinder->find(*combi2D, ctx);
177 if (!combi4D)
return;
180 for (
auto com : *combi4D) {
185 for (
unsigned int i = 0; i < nstations; ++i) {
190 if (!segs || segs->empty())
continue;
192 for (std::unique_ptr<MuonSegment>& seg_it : *segs) {
194 segments.emplace_back(std::move(seg_it));
201 std::vector<std::shared_ptr<const Muon::MuonSegment> >& segments)
const {
204 unsigned int nprevSegments = segments.size();
211 if (!houghDataPerSectorVec.
isValid()) {
217 if (
static_cast<int>(houghDataPerSectorVec->vec.size()) <= sector - 1) {
218 ATH_MSG_WARNING(
" MuonLayerHoughTool::HoughDataPerSectorVec smaller than sector "
219 << houghDataPerSectorVec->vec.size() <<
" sector " << sector);
229 << houghDataPerSectorVec->vec.size() <<
" " << houghDataPerSector.
maxVec.size());
233 ATH_MSG_WARNING(
" houghDataPerSector.maxVec.size() smaller than hash " << houghDataPerSector.
maxVec.size()
240 bool barrelLike =
intersection.layerSurface.regionIndex == DetectorRegionIndex::Barrel;
251 float x = barrelLike ?
r :
z;
252 float y = barrelLike ?
z :
r;
253 float theta = std::atan2(
x,
y);
255 ATH_MSG_DEBUG(
" Got Hough maxima " << maxVec.size() <<
" extrapolated position in Hough space (" <<
x <<
"," <<
y
256 <<
") error " << errx <<
" "
257 <<
" angle " <<
theta);
260 std::vector<std::unique_ptr<const Trk::MeasurementBase>> garbage;
261 auto handleMdt = [
this,
intersection, &garbage](
const MdtPrepData& prd, std::vector<const MdtDriftCircleOnTrack*>& mdts) {
265 garbage.emplace_back(mdt);
271 std::vector<const MuonClusterOnTrack*>& clusters) {
273 if (!cluster)
return;
274 clusters.push_back(cluster);
275 garbage.emplace_back(cluster);
280 MuonLayerHoughTool::MaximumVec::const_iterator mit = maxVec.begin();
281 MuonLayerHoughTool::MaximumVec::const_iterator mit_end = maxVec.end();
282 for (; mit != mit_end; ++mit) {
284 float residual = maximum.
pos -
y;
289 float pull = residual / std::hypot(errx , maxwidth * OneOverSqrt12);
292 ATH_MSG_DEBUG(
" Hough maximum " << maximum.
max <<
" position (" << refPos <<
"," << maximum.
pos
293 <<
") residual " << residual <<
" pull " << pull <<
" angle " << maximum.
theta
294 <<
" residual " << residualTheta);
297 if (std::abs(pull) > 5)
continue;
300 std::vector<const MdtDriftCircleOnTrack*> mdts;
301 std::vector<const MuonClusterOnTrack*> clusters;
302 for (
const auto& hit : maximum.
hits) {
306 for (
const auto& prd : hit->tgc->etaCluster) {
307 handleCluster(*prd, clusters);
309 }
else if (hit->prd) {
312 handleMdt(
static_cast<const MdtPrepData&
>(*hit->prd), mdts);
314 handleCluster(
static_cast<const MuonCluster&
>(*hit->prd), clusters);
321 ATH_MSG_DEBUG(
" Got Phi Hough maxima " << phiMaxVec.size() <<
" phi " <<
phi);
324 MuonLayerHoughTool::PhiMaximumVec::const_iterator pit = phiMaxVec.begin();
325 MuonLayerHoughTool::PhiMaximumVec::const_iterator pit_end = phiMaxVec.end();
326 for (; pit != pit_end; ++pit) {
331 << maximum.
pos <<
" residual " << residual);
333 for (
const auto& phi_hit : maximum.
hits) {
336 Identifier id = phi_hit->tgc->phiCluster.front()->identify();
338 for (
const auto& prd : phi_hit->tgc->phiCluster) handleCluster(*prd, clusters);
339 }
else if (phi_hit->prd) {
342 handleCluster(
static_cast<const MuonCluster&
>(*phi_hit->prd), clusters);
348 ATH_MSG_DEBUG(
" Got hits: mdts " << mdts.size() <<
" clusters " << clusters.size());
353 ATH_MSG_DEBUG(
" Done maximum: new segments " << segments.size() - nprevSegments);
355 ATH_MSG_DEBUG(
" Done with layer: new segments " << segments.size() - nprevSegments);
Scalar phi() const
phi method
Scalar theta() const
theta method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
Base class for Muon cluster RIO_OnTracks.
This is the common class for 3D segments used in the muon spectrometer.
const Trk::RIO_OnTrack * rioOnTrack(unsigned int) const
returns the RIO_OnTrack (also known as ROT) objects depending on the integer
virtual MuonSegment * clone() const override final
needed to avoid excessive RTTI
unsigned int numberOfContainedROTs() const
number of RIO_OnTracks
virtual const Amg::Vector3D & globalPosition() const override final
global position
This class represents the corrected MDT measurements, where the corrections include the effects of wi...
Class to represent measurements from the Monitored Drift Tubes.
Base class for Muon cluster RIO_OnTracks.
Class representing clusters in the muon system.
struct holding RIO_OnTracks for a given layer
const std::vector< const MuonClusterOnTrack * > & getClusters(MuonStationIndex::TechnologyIndex tech) const
access calibrated MuonClusters for a given technolgy
const std::vector< const MdtDriftCircleOnTrack * > & getMdts() const
access calibrated MDT's
Class to hold a set of MuonSegments belonging together.
std::vector< std::unique_ptr< MuonSegment > > SegmentVec
SegmentVec * stationSegments(unsigned int index) const
Access to segments in a given station.
unsigned int numberOfStations() const
Number of stations with segment.
This is the common class for 3D segments used in the muon spectrometer.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Base class for all TrackSegment implementations, extends the common MeasurementBase.
std::vector< std::string > intersection(std::vector< std::string > &v1, std::vector< std::string > &v2)
double error(const Amg::MatrixX &mat, int index)
return diagonal error of the matrix caller should ensure the matrix is symmetric and the index is in ...
const std::string & layerName(LayerIndex index)
convert LayerIndex into a string
TechnologyIndex
enum to classify the different layers in the muon spectrometer
DetectorRegionIndex
enum to classify the different layers in the muon spectrometer
constexpr int toInt(const EnumType enumVal)
unsigned int sectorLayerHash(DetectorRegionIndex detectorRegionIndex, LayerIndex layerIndex)
create a hash out of region and layer
const std::string & regionName(DetectorRegionIndex index)
convert DetectorRegionIndex into a string
LayerIndex
enum to classify the different layers in the muon spectrometer
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
struct representing the maximum in the hough space
const MuonLayerHough * hough
RegionDescriptor m_descriptor
RegionPhiMaximumVec phiMaxVec
Struct to hold all PrepRawData collections in a given layer.
std::vector< const CscPrepDataCollection * > cscs
std::vector< const MMPrepDataCollection * > mms
std::vector< const sTgcPrepDataCollection * > stgcs