ATLAS Offline Software
MdtSegmentSeedGenerator.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
10 
11 #include <Acts/Utilities/Enumerate.hpp>
12 
13 #include <Acts/Utilities/Enumerate.hpp>
14 #include <CxxUtils/sincos.h>
15 #include <format>
16 
17 namespace MuonR4{
18  using namespace SegmentFit;
19  using namespace SegmentFitHelpers;
21 
22  double driftCov(const CalibratedSpacePoint& dcHit){
23  return std::visit([](const auto& cov) ->double{
25  }, dcHit.covariance());
26  }
27  constexpr bool passRangeCut(const std::array<double, 2>& cutRange, const double value) {
28  return cutRange[0] <= value && value <= cutRange[1];
29  }
30 
31  std::ostream& MdtSegmentSeedGenerator::SeedSolution::print(std::ostream& ostr) const{
32  ostr<<"two circle solution with ";
33  ostr<<"theta: "<<theta / Gaudi::Units::deg<<" pm "<<dTheta / Gaudi::Units::deg<<", ";
34  ostr<<"y0: "<<Y0<<" pm "<<dY0;
35  return ostr;
36  }
38  return m_cfg;
39  }
42  const SegmentSeed* segmentSeed,
43  const Config& configuration):
45  m_cfg{configuration},
46  m_segmentSeed{segmentSeed} {
47 
48  if (m_hitLayers.mdtHits().empty()) return;
49 
50  if (std::ranges::find_if(m_hitLayers.mdtHits(), [this](const HitVec& vec){
51  return vec.size() > m_cfg.busyLayerLimit;
52  }) != m_hitLayers.mdtHits().end()) {
53  m_cfg.startWithPattern = false;
54  }
55  // Set the start for the upper layer
56  m_upperLayer = m_hitLayers.mdtHits().size()-1;
57 
59  while (m_lowerLayer < m_upperLayer && m_hitLayers.mdtHits()[m_lowerLayer].size() >m_cfg.busyLayerLimit){
60  ++m_lowerLayer;
61  }
63  while (m_lowerLayer < m_upperLayer && m_hitLayers.mdtHits()[m_upperLayer].size() > m_cfg.busyLayerLimit) {
64  --m_upperLayer;
65  }
66 
67  if (msgLvl(MSG::VERBOSE)) {
68  std::stringstream sstr{};
69  for (const auto& [layCount, layer] : Acts::enumerate(m_hitLayers.mdtHits())) {
70  sstr<<"Mdt-hits in layer "<<layCount<<": "<<layer.size()<<std::endl;
71  for (const HoughHitType& hit : layer) {
72  sstr<<" **** "<<hit->msSector()->idHelperSvc()->toString(hit->identify())<<" "
73  <<Amg::toString(hit->positionInChamber())<<", driftRadius: "<<hit->driftRadius()<<std::endl;
74  }
75  }
76  for (const auto& [layCount, layer] : Acts::enumerate(m_hitLayers.stripHits())) {
77  sstr<<"Hits in layer "<<layCount<<": "<<layer.size()<<std::endl;
78  for (const HoughHitType& hit : layer) {
79  sstr<<" **** "<<hit->msSector()->idHelperSvc()->toString(hit->identify())<<" "
80  <<Amg::toString(hit->positionInChamber())<<", driftRadius: "<<hit->driftRadius()<<std::endl;
81  }
82  }
83  ATH_MSG_VERBOSE("SeedGenerator - sorting of hits done. Mdt layers: "<<m_hitLayers.mdtHits().size()
84  <<", strip layers: "<<m_hitLayers.stripHits().size()<<std::endl<<sstr.str());
85  }
86  }
87 
89  return m_nGenSeeds;
90  }
92  const HitVec& lower = m_hitLayers.mdtHits()[m_lowerLayer];
95  if (++m_signComboIndex >= s_signCombos.size()){
96  m_signComboIndex = 0;
98  if (++m_lowerHitIndex >= lower.size()){
101  if (++m_upperHitIndex >= upper.size()) {
102  m_upperHitIndex = 0;
106  }
107  if (m_lowerLayer >= m_upperLayer){
108  m_lowerLayer = 0;
110  }
111  }
112  }
113  }
114  }
115  }
116  std::optional<MdtSegmentSeedGenerator::DriftCircleSeed>
117  MdtSegmentSeedGenerator::nextSeed(const EventContext& ctx) {
118  std::optional<DriftCircleSeed> found = std::nullopt;
120  ++m_nGenSeeds;
121  found = std::make_optional<DriftCircleSeed>();
122  found->parameters = m_segmentSeed->parameters();
123  found->measurements = m_cfg.calibrator->calibrate(ctx,
127  found->parentBucket = m_segmentSeed->parentBucket();
128 
129  SeedSolution patternSeed{};
130  patternSeed.seedHits.resize(2*m_hitLayers.mdtHits().size());
131  patternSeed.solutionSigns.resize(2*m_hitLayers.mdtHits().size());
132  patternSeed.Y0 = m_segmentSeed->interceptY();
133  patternSeed.theta = m_segmentSeed->tanTheta();
134  m_seenSolutions.push_back(std::move(patternSeed));
135  return found;
136  }
137 
138  while (m_lowerLayer < m_upperLayer) {
139  const HitVec& lower = m_hitLayers.mdtHits().at(m_lowerLayer);
141  ATH_MSG_VERBOSE("Layers with hits: "<<m_hitLayers.mdtHits().size()
142  <<" -- next bottom hit: "<<m_lowerLayer<<", hit: "<<m_lowerHitIndex
143  <<" ("<<lower.size()<<"), topHit " <<m_upperLayer<<", "<<m_upperHitIndex
144  <<" ("<<upper.size()<<") - ambiguity "<<s_signCombos[m_signComboIndex]);
145 
150  if (found) {
151  return found;
152  }
153  }
154  return std::nullopt;
155  }
156  std::optional<MdtSegmentSeedGenerator::DriftCircleSeed>
157  MdtSegmentSeedGenerator::buildSeed(const EventContext& ctx,
158  const HoughHitType & topHit,
159  const HoughHitType & bottomHit,
160  const SignComboType& signs) {
161 
162  const auto* bottomPrd = static_cast<const xAOD::MdtDriftCircle*>(bottomHit->primaryMeasurement());
163  const auto* topPrd = static_cast<const xAOD::MdtDriftCircle*>(topHit->primaryMeasurement());
164  if (bottomPrd->status() != Muon::MdtDriftCircleStatus::MdtStatusDriftTime ||
166  return std::nullopt;
167  }
168  const int signTop = signs[0];
169  const int signBot = signs[1];
170  double R = signBot *bottomHit->driftRadius() - signTop * topHit->driftRadius();
171  const Amg::Vector3D& bottomPos{bottomHit->positionInChamber()};
172  const Amg::Vector3D& topPos{topHit->positionInChamber()};
173  const Muon::IMuonIdHelperSvc* idHelperSvc{topHit->msSector()->idHelperSvc()};
174  const Amg::Vector3D D = topPos - bottomPos;
175  const double thetaTubes = std::atan2(D.y(), D.z());
176  const double distTubes = std::hypot(D.y(), D.z());
177  ATH_MSG_VERBOSE(__func__<<"() "<<__LINE__<<": Bottom tube "<<idHelperSvc->toString(bottomHit->identify())<<" "<<Amg::toString(bottomPos)
178  <<", driftRadius: "<<bottomHit->driftRadius()<<" - top tube "<<idHelperSvc->toString(topHit->identify())
179  <<" "<<Amg::toString(topPos)<<", driftRadius: "<<topHit->driftRadius()
180  <<", tube distance: "<<Amg::toString(D));
181 
182  DriftCircleSeed candidateSeed{};
183  candidateSeed.parameters = m_segmentSeed->parameters();
184  candidateSeed.parentBucket = m_segmentSeed->parentBucket();
185  double theta{thetaTubes - std::asin(std::clamp(R / distTubes, -1., 1.))};
186  Amg::Vector3D seedDir = dirFromAngles(90.*Gaudi::Units::deg, theta);
187  double Y0 = bottomPos.y()*seedDir.z() - bottomPos.z()*seedDir.y() + signBot*bottomHit->driftRadius();
188  double combDriftUncert{std::sqrt(bottomPrd->driftRadiusCov() + topPrd->driftRadiusCov())};
190  candidateSeed.parameters[toInt(ParamDefs::theta)] = theta;
191  candidateSeed.parameters[toInt(ParamDefs::y0)] = Y0 / seedDir.z();
194  const auto [linePos, lineDir] = makeLine(candidateSeed.parameters);
195  auto calibBottom = m_cfg.calibrator->calibrate(ctx, bottomHit, linePos, lineDir,
196  candidateSeed.parameters[toInt(ParamDefs::time)]);
197  auto calibTop = m_cfg.calibrator->calibrate(ctx, topHit, linePos, lineDir,
198  candidateSeed.parameters[toInt(ParamDefs::time)]);
199  R = signBot * calibBottom->driftRadius() - signTop * calibTop->driftRadius();
201  theta = thetaTubes - std::asin(std::clamp(R / distTubes, -1., 1.));
202  seedDir = dirFromAngles(90.*Gaudi::Units::deg, theta);
203  Y0 = bottomPos.y()*seedDir.z() - bottomPos.z()*seedDir.y() + signBot*bottomHit->driftRadius();
204  combDriftUncert = std::sqrt(driftCov(*calibBottom) + driftCov(*calibTop));
205  }
206 
207  candidateSeed.parameters[toInt(ParamDefs::theta)] = theta;
208  candidateSeed.parameters[toInt(ParamDefs::y0)] = Y0 / seedDir.z();
210  if (!passRangeCut(m_cfg.thetaRange, theta) ||
211  !passRangeCut(m_cfg.interceptRange, candidateSeed.parameters[toInt(ParamDefs::y0)])) {
212  return std::nullopt;
213  }
214 
215  const Amg::Vector3D seedPos = Y0 / seedDir.z() * Amg::Vector3D::UnitY();
216 
217  assert(std::abs(topPos.y()*seedDir.z() - topPos.z() * seedDir.y() + signTop*topHit->driftRadius() - Y0) < std::numeric_limits<float>::epsilon() );
218  ATH_MSG_VERBOSE("Candidate seed theta: "<<theta<<", tanTheta: "<<(seedDir.y() / seedDir.z())<<", y0: "<<Y0/seedDir.z());
219 
220  SeedSolution solCandidate{};
221  solCandidate.Y0 = seedPos[toInt(ParamDefs::y0)];
222  solCandidate.theta = theta;
224  solCandidate.dTheta = combDriftUncert / std::sqrt(1. - std::pow(std::clamp(R / distTubes, -1., 1.), 2)) / distTubes;
225  solCandidate.dY0 = std::hypot(-bottomPos.y()*seedDir.y() + bottomPos.z()*seedDir.z(), 1.) * solCandidate.dTheta;
226  ATH_MSG_VERBOSE("Test new "<<solCandidate<<".");
227 
229  unsigned int nMdt{0};
231  for (const auto& [layerNr, hitsInLayer] : Acts::enumerate(m_hitLayers.mdtHits())) {
232  ATH_MSG_VERBOSE( hitsInLayer.size()<<" hits in layer "<<(layerNr +1));
233  for (const HoughHitType testMe : hitsInLayer){
234  CalibSpacePointPtr calibHit = m_cfg.calibrator->calibrate(ctx,testMe, seedPos, seedDir, 0.);
235  if (!calibHit || calibHit->fitState() != CalibratedSpacePoint::State::Valid) {
236  continue;
237  }
238  const double pull = std::sqrt(SegmentFitHelpers::chiSqTermMdt(seedPos, seedDir, *calibHit, msg()));
239  ATH_MSG_VERBOSE("Test hit "<<idHelperSvc->toString(testMe->identify())
240  <<" "<<Amg::toString(testMe->positionInChamber())<<", pull: "<<pull);
241  if (pull < m_cfg.hitPullCut) {
242  solCandidate.seedHits.emplace_back(calibHit->spacePoint());
243  candidateSeed.measurements.push_back(std::move(calibHit));
244  ++nMdt;
245  }
246  }
247  }
249  if (1.*nMdt < std::max(1.*m_cfg.nMdtHitCut, m_cfg.nMdtLayHitCut * m_hitLayers.mdtHits().size())) {
250  return std::nullopt;
251  }
252  /* Calculate the left-right signs of the used hits */
253  if (m_cfg.overlapCorridor) {
254  solCandidate.solutionSigns = driftSigns(seedPos, seedDir, solCandidate.seedHits, msg());
255  ATH_MSG_VERBOSE("Circle solutions for seed "<<idHelperSvc->toStringChamber(bottomHit->identify())<<" - "
256  <<solCandidate);
258  for (unsigned int a = m_cfg.startWithPattern; a< m_seenSolutions.size() ;++a) {
259  const SeedSolution& accepted = m_seenSolutions[a];
260  unsigned int nOverlap{0};
261  std::vector<int> corridor = driftSigns(seedPos, seedDir, accepted.seedHits, msg());
262  ATH_MSG_VERBOSE("Test seed against accepted "<<accepted<<", updated signs: "<<corridor);
264  for (unsigned int l = 0; l < accepted.seedHits.size(); ++l){
265  nOverlap += corridor[l] == accepted.solutionSigns[l];
266  }
269  if (nOverlap == corridor.size() && accepted.seedHits.size() >= solCandidate.seedHits.size()) {
270  ATH_MSG_VERBOSE("Same set of hits collected within the same corridor");
271  return std::nullopt;
272  }
273  }
274  } else if (std::ranges::find_if(m_seenSolutions,
275  [&solCandidate] (const SeedSolution& seen) {
276  return std::abs(seen.Y0 - solCandidate.Y0) < std::hypot(seen.dY0, solCandidate.dY0) &&
277  std::abs(seen.theta - solCandidate.theta) < std::hypot(seen.dTheta, solCandidate.dTheta);
278  }) != m_seenSolutions.end()){
279  return std::nullopt;
280  }
281 
283  m_seenSolutions.emplace_back(std::move(solCandidate));
286  if (m_cfg.tightenHitCut) {
288  }
293  ++m_nGenSeeds;
294 
295  ATH_MSG_VERBOSE("In event "<<ctx.eventID().event_number()<<" found new seed solution "<<toString(candidateSeed.parameters));
296  if (m_cfg.fastSeedFit) {
297  fitDriftCircles(candidateSeed);
298  }
299 
300  // Combine the seed with the phi estimate
301  {
302  const Amg::Vector3D parDir = dirFromTangents(m_segmentSeed->tanPhi(), std::tan(theta));
303  candidateSeed.parameters[toInt(ParamDefs::theta)] = parDir.theta();
304  candidateSeed.parameters[toInt(ParamDefs::phi)] = parDir.phi();
305  }
306 
308  {
309  const auto [seedPos, seedDir] = makeLine(candidateSeed.parameters);
310  for (const std::vector<HoughHitType>& hitsInLayer : m_hitLayers.stripHits()) {
311  HoughHitType bestHit{nullptr};
312  double bestPull{m_cfg.hitPullCut};
313  for (const HoughHitType testMe : hitsInLayer){
314  const double pull = std::sqrt(SegmentFitHelpers::chiSqTermStrip(seedPos, seedDir, *testMe, msg()))
315  / testMe->dimension();
316  ATH_MSG_VERBOSE("Test hit "<<idHelperSvc->toString(testMe->identify())
317  <<" "<<Amg::toString(testMe->positionInChamber())<<", pull: "<<pull);
319  if (pull <= bestPull) {
320  bestHit = testMe;
321  bestPull = pull;
322  }
323  }
324  if (!bestHit) {
325  continue;
326  }
327  candidateSeed.measurements.push_back(m_cfg.calibrator->calibrate(ctx,bestHit, seedPos, seedDir, 0));
328  }
329  }
330  return candidateSeed;
331  }
333 
334  double theta = inSeed.parameters[toInt(ParamDefs::theta)];
335 
336  Amg::Vector3D seedDir = dirFromAngles(90.* Gaudi::Units::deg, theta);
337 
338  const double y0 = inSeed.parameters[toInt(ParamDefs::y0)] * seedDir.z();
339 
340  double norm{0.}, fitY0{0.};
341  Amg::Vector3D centerOfGravity{Amg::Vector3D::Zero()};
342  std::vector<int> driftSigns{};
343  std::vector<double> invCovs{};
344  driftSigns.reserve(inSeed.measurements.size());
345  invCovs.reserve(inSeed.measurements.size());
346  for (const std::unique_ptr<CalibratedSpacePoint>& hit : inSeed.measurements) {
347  const double invCov = 1./ driftCov(*hit);
348  norm += invCov;
349  const Amg::Vector3D& pos{hit->positionInChamber()};
350  centerOfGravity+= invCov * pos;
351  invCovs.push_back(invCov);
352  const int sign = y0 - pos.y() * seedDir.z() + pos.z()* seedDir.y() > 0 ? 1 : -1;
353  fitY0 += invCov * sign * hit->driftRadius();
354  driftSigns.push_back(sign);
355  }
357  const double invNorm = 1./ norm;
358  fitY0*= invNorm;
359  centerOfGravity *= invNorm;
360 
361  double Tzzyy{0.}, Tyz{0.}, Trz{0.}, Try{0.};
362  for (const auto&[covIdx, hit] : Acts::enumerate(inSeed.measurements)) {
363  const double invCov = invCovs[covIdx]*invNorm;
364  const int sign = driftSigns[covIdx];
365  const Amg::Vector3D pos = hit->positionInChamber() - centerOfGravity;
366  Tzzyy += invCov * (std::pow(pos.z(), 2) - std::pow(pos.y(), 2));
367  Tyz += invCov * pos.y()*pos.z();
368  Trz += invCov * sign*pos.z() * hit->driftRadius();
369  Try += invCov * sign*pos.y() * hit->driftRadius();
370  }
372  const double thetaMin = - (Tzzyy - Try) / (4* Tyz + Trz);
373  const double thetaDet = std::pow(Tzzyy -Try,2) + 4*(Tyz + Trz)*(2*Tyz + 0.5*Trz);
374  const double thetaGuess = thetaMin + (theta > thetaMin ? 1. : -1.)*std::sqrt(thetaDet) / (4*Tyz + Trz);
375  // const double thetaGuess = std::atan2( 2.*(Tyz - Trz), Tzzyy) / 2.;
376 
377  ATH_MSG_VERBOSE("Start fast fit seed: "<<theta<<", guess: "<<thetaGuess
378  <<", y0: "<<y0<<", fitY0: "<<fitY0<<", centre: "<<Amg::toString(centerOfGravity));
380  theta = thetaGuess;
381  bool converged{false};
382  while (!converged && inSeed.nIter++ <= m_cfg.nMaxIter) {
383  const CxxUtils::sincos twoTheta{2.*theta};
384  const double thetaPrime = 0.5*Tzzyy *twoTheta.sn - Tyz * twoTheta.cs - Trz * seedDir.z() - Try * seedDir.y();
385  if (std::abs(thetaPrime) < m_cfg.precCutOff){
386  converged = true;
387  break;
388  }
389 
390  const double thetaTwoPrime = Tzzyy * twoTheta.cs + 2* Tyz * twoTheta.sn + Trz * seedDir.y() - Try * seedDir.z();
391  const double update = thetaPrime / thetaTwoPrime;
392  ATH_MSG_VERBOSE("Fit iteration #"<<inSeed.nIter<<" -- theta: "<<theta<<", thetaPrime: "<<thetaPrime
393  <<", thetaTwoPrime: "<<thetaTwoPrime<<" -- "<<std::format("{:.8f}", update)
394  <<" --> next theta "<<(theta - thetaPrime / thetaTwoPrime));
395 
396  if (std::abs(update) < m_cfg.precCutOff) {
397  converged = true;
398  break;
399  }
400  theta -= update;
401  const CxxUtils::sincos thetaUpdate{theta};
402  seedDir.y() = thetaUpdate.sn;
403  seedDir.z() = thetaUpdate.cs;
404  }
405  if (!converged) {
406  return;
407  }
408  inSeed.parameters[toInt(ParamDefs::theta)] = theta;
409  inSeed.parameters[toInt(ParamDefs::y0)] = (centerOfGravity.y() *seedDir.z() - centerOfGravity.z() * seedDir.y() + fitY0) / std::cos(theta);
410  ATH_MSG_VERBOSE("Drift circle fit converged within "<<inSeed.nIter<<" iterations giving "<<toString(inSeed.parameters)<<", chi2: "<<inSeed.chi2);
411  }
412 
413 }
MuonR4::MdtSegmentSeedGenerator::m_upperHitIndex
std::size_t m_upperHitIndex
Explicit hit to pick in the selected top layer.
Definition: MdtSegmentSeedGenerator.h:155
MuonR4::SegmentFitHelpers::driftSigns
std::vector< int > driftSigns(const Amg::Vector3D &posInChamber, const Amg::Vector3D &dirInChamber, const std::vector< const SpacePoint * > &uncalibHits, MsgStream &msg)
Calculates whether a segement line travereses the tube measurements on the left (-1) or right (1) sid...
Definition: SegmentFitHelperFunctions.cxx:209
MuonR4::MdtSegmentSeedGenerator::SeedSolution::dTheta
double dTheta
: Uncertainty on the slope
Definition: MdtSegmentSeedGenerator.h:109
MuonR4::SegmentSeed::parentBucket
const SpacePointBucket * parentBucket() const
Returns the bucket out of which the seed was formed.
Definition: SegmentSeed.cxx:38
MuonR4::SpacePoint::msSector
const MuonGMR4::SpectrometerSector * msSector() const
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/src/SpacePoint.cxx:116
MuonR4::MdtSegmentSeedGenerator::Config::overlapCorridor
bool overlapCorridor
Check whether a new seed candidate shares the same left-right solution with already accepted ones Rej...
Definition: MdtSegmentSeedGenerator.h:50
PlotCalibFromCool.norm
norm
Definition: PlotCalibFromCool.py:100
MuonR4::MdtSegmentSeedGenerator::numGenerated
unsigned int numGenerated() const
Returns how many seeds have been generated.
Definition: MdtSegmentSeedGenerator.cxx:88
max
#define max(a, b)
Definition: cfImp.cxx:41
MuonR4::MdtSegmentSeedGenerator::DriftCircleSeed::parameters
SegmentFit::Parameters parameters
Seed parameters.
Definition: MdtSegmentSeedGenerator.h:65
MuonR4::MdtSegmentSeedGenerator::Config::nMdtHitCut
unsigned int nMdtHitCut
How many drift circle hits needs the seed to contain in order to be valid.
Definition: MdtSegmentSeedGenerator.h:41
MuonR4::MdtSegmentSeedGenerator::SignComboType
std::array< int, 2 > SignComboType
Sign combinations to draw the 4 lines tangent to 2 drift circles The first two are indicating whether...
Definition: MdtSegmentSeedGenerator.h:97
vtune_athena.format
format
Definition: vtune_athena.py:14
MuonR4::MdtSegmentSeedGenerator::Config::busyLayerLimit
unsigned int busyLayerLimit
How many drift circles may be on a layer to be used for seeding.
Definition: MdtSegmentSeedGenerator.h:39
MuonR4::SegmentSeed::tanPhi
double tanPhi() const
Returns the angle from the phi extension.
Definition: SegmentSeed.cxx:31
EventPrimitivesHelpers.h
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
MuonR4::MdtSegmentSeedGenerator::SeedSolution::solutionSigns
std::vector< int > solutionSigns
Vector of radial signs of the valid hits.
Definition: MdtSegmentSeedGenerator.h:115
MuonR4::driftCov
double driftCov(const CalibratedSpacePoint &dcHit)
Definition: MdtSegmentSeedGenerator.cxx:22
plotBeamSpotVxVal.cov
cov
Definition: plotBeamSpotVxVal.py:201
MuonR4::MdtSegmentSeedGenerator::config
const Config & config() const
Returns the current seed configuration.
Definition: MdtSegmentSeedGenerator.cxx:37
sincos.h
Helper to simultaneously calculate sin and cos of the same angle.
MuonR4::MdtSegmentSeedGenerator::MdtSegmentSeedGenerator
MdtSegmentSeedGenerator(const std::string &name, const SegmentSeed *segmentSeed, const Config &configuration)
Standard constructor taking the segmentSeed to start with and then few configuration tunes.
Definition: MdtSegmentSeedGenerator.cxx:41
MuonR4::SegmentSeed::positionInChamber
Amg::Vector3D positionInChamber() const
Returns the position of the seed in the sector frame.
Definition: SegmentSeed.cxx:41
deg
#define deg
Definition: SbPolyhedron.cxx:17
MuonR4::HitVec
SpacePointPerLayerSorter::HitVec HitVec
Definition: SpacePointPerLayerSorter.cxx:9
athena.value
value
Definition: athena.py:124
MuonR4::MdtSegmentSeedGenerator::SeedSolution
Cache of all solutions seen thus far.
Definition: MdtSegmentSeedGenerator.h:103
ISpacePointCalibrator.h
MuonR4::MdtSegmentSeedGenerator::Config::fastSeedFit
bool fastSeedFit
Toggle whether the seed is rapidly refitted.
Definition: MdtSegmentSeedGenerator.h:56
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
upper
int upper(int c)
Definition: LArBadChannelParser.cxx:49
MuonR4::MdtSegmentSeedGenerator::m_nGenSeeds
unsigned int m_nGenSeeds
Counter on how many seeds have been generated.
Definition: MdtSegmentSeedGenerator.h:161
MuonR4::MdtSegmentSeedGenerator::Config::nMdtLayHitCut
double nMdtLayHitCut
Hit cut based on the fraction of collected tube layers.
Definition: MdtSegmentSeedGenerator.h:44
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
MuonR4::ISpacePointCalibrator::calibrate
virtual CalibSpacePointPtr calibrate(const EventContext &ctx, const SpacePoint *spacePoint, const Amg::Vector3D &seedPosInChamb, const Amg::Vector3D &seedDirInChamb, const double timeDelay) const =0
Calibrates a single space point.
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
MuonR4::MdtSegmentSeedGenerator::Config::recalibSeedCircles
bool recalibSeedCircles
Recalibrate the seed drift circles from the initial estimate
Definition: MdtSegmentSeedGenerator.h:52
MuonR4::SegmentFit::makeLine
std::pair< Amg::Vector3D, Amg::Vector3D > makeLine(const Parameters &pars)
Returns the parsed parameters into an Eigen line parametrization.
Definition: SegmentFitterEventData.cxx:30
MuonR4::HoughHitType
HoughMaximum::HitType HoughHitType
Definition: MuonHoughDefs.h:18
MuonR4::toString
std::string toString(const CalibratedSpacePoint::Covariance_t &mat)
Returns the matrix in string.
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/src/UtilFunctions.cxx:75
Muon::MdtStatusDriftTime
@ MdtStatusDriftTime
The tube produced a vaild measurement.
Definition: MdtDriftCircleStatus.h:34
MuonR4::SegmentFit::ParamDefs::phi
@ phi
MuonR4::MdtSegmentSeedGenerator::Config::startWithPattern
bool startWithPattern
Try at the first time the pattern seed as candidate.
Definition: MdtSegmentSeedGenerator.h:37
MuonR4::MdtSegmentSeedGenerator::m_lowerHitIndex
std::size_t m_lowerHitIndex
Explicit hit to pick in the selected bottom layer.
Definition: MdtSegmentSeedGenerator.h:153
MuonR4::SpacePoint::primaryMeasurement
const xAOD::UncalibratedMeasurement * primaryMeasurement() const
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/src/SpacePoint.cxx:107
CalibratedSpacePoint.h
MuonR4::SegmentFit::dirFromTangents
Amg::Vector3D dirFromTangents(const double tanPhi, const double tanTheta)
Constructs a direction vector from tanPhi & tanTheta.
Definition: SegmentFitterEventData.cxx:23
MuonR4::MdtSegmentSeedGenerator::Config
Configuration switches of the module
Definition: MdtSegmentSeedGenerator.h:29
MuonR4::MdtSegmentSeedGenerator::s_signCombos
constexpr static std::array< SignComboType, 4 > s_signCombos
Definition: MdtSegmentSeedGenerator.h:98
MdtSegmentSeedGenerator.h
MuonR4::SegmentFitHelpers::chiSqTermStrip
double chiSqTermStrip(const Amg::Vector3D &posInChamber, const Amg::Vector3D &dirInChamber, const SpacePoint &measurement, MsgStream &msg)
Calculates the chi2 contribuation to a linear segment line from an uncalibrated strip measurement.
Definition: SegmentFitHelperFunctions.cxx:74
MuonR4::MdtSegmentSeedGenerator::SeedSolution::theta
double theta
: Theta of the line
Definition: MdtSegmentSeedGenerator.h:105
Amg::toString
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Definition: GeoPrimitivesToStringConverter.h:40
MuonR4::SegmentSeed::tanTheta
double tanTheta() const
Returns the angular coordinate of the eta transform.
Definition: SegmentSeed.cxx:32
MuonR4::MdtSegmentSeedGenerator::m_cfg
Config m_cfg
Definition: MdtSegmentSeedGenerator.h:142
MuonR4::SegmentFitHelpers::chiSqTermMdt
double chiSqTermMdt(const Amg::Vector3D &posInChamber, const Amg::Vector3D &dirInChamber, const SpacePoint &measurement, MsgStream &msg)
Calculates the chi2 contribuation to a linear segment line from an uncalibrated Mdt measurement.
Definition: SegmentFitHelperFunctions.cxx:49
MuonR4::MdtSegmentSeedGenerator::SeedSolution::print
std::ostream & print(std::ostream &ostr) const
Definition: MdtSegmentSeedGenerator.cxx:31
MuonR4::SpacePointPerLayerSorter::HitVec
std::vector< const SpacePoint * > HitVec
Definition: SpacePointPerLayerSorter.h:16
MuonR4::MdtSegmentSeedGenerator::Config::thetaRange
std::array< double, 2 > thetaRange
Cut on the theta angle.
Definition: MdtSegmentSeedGenerator.h:31
SegmentFitHelperFunctions.h
MuonR4::MdtSegmentSeedGenerator::buildSeed
std::optional< DriftCircleSeed > buildSeed(const EventContext &ctx, const HoughHitType &topHit, const HoughHitType &bottomHit, const SignComboType &signs)
Tries to build the seed from the two hits.
Definition: MdtSegmentSeedGenerator.cxx:157
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
MuonR4::MdtSegmentSeedGenerator::m_upperLayer
std::size_t m_upperLayer
Considered layer to pick the top drift circle from.
Definition: MdtSegmentSeedGenerator.h:149
MuonR4::SegmentSeed::interceptY
double interceptY() const
Returns the intercept coordinate of the eta transform.
Definition: SegmentSeed.cxx:34
MuonR4::SegmentSeed::getHitsInMax
const std::vector< HitType > & getHitsInMax() const
Returns the list of assigned hits.
Definition: SegmentSeed.cxx:37
sign
int sign(int a)
Definition: TRT_StrawNeighbourSvc.h:107
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
python.StandardJetMods.pull
pull
Definition: StandardJetMods.py:282
MuonR4::MdtSegmentSeedGenerator::SeedSolution::seedHits
HitVec seedHits
Used hits in the seed.
Definition: MdtSegmentSeedGenerator.h:113
drawFromPickle.tan
tan
Definition: drawFromPickle.py:36
MuonR4::MdtSegmentSeedGenerator::SeedSolution::dY0
double dY0
: Uncertainty on the intercept
Definition: MdtSegmentSeedGenerator.h:111
MuonR4::MdtSegmentSeedGenerator::Config::hitPullCut
double hitPullCut
Upper cut on the hit chi2 w.r.t.
Definition: MdtSegmentSeedGenerator.h:35
MuonR4::SegmentFit::AxisDefs::eta
@ eta
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
MdtDriftCircle.h
MuonR4::MdtSegmentSeedGenerator::DriftCircleSeed::measurements
std::vector< std::unique_ptr< CalibratedSpacePoint > > measurements
List of calibrated measurements.
Definition: MdtSegmentSeedGenerator.h:67
MuonR4::SegmentFit::ParamDefs::time
@ time
MuonR4::CalibratedSpacePoint::State::Valid
@ Valid
MuonR4::SpacePoint
The muon space point is the combination of two uncalibrated measurements one of them measures the eta...
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/MuonSpacePoint/SpacePoint.h:18
MuonR4::MdtSegmentSeedGenerator::~MdtSegmentSeedGenerator
~MdtSegmentSeedGenerator()
MuonR4::ISpacePointCalibrator::CalibSpacePointPtr
std::unique_ptr< CalibratedSpacePoint > CalibSpacePointPtr
Definition: ISpacePointCalibrator.h:25
MuonR4::SpacePointPerLayerSorter::stripHits
const HitLayVec & stripHits() const
Returns the sorted strip hits.
Definition: SpacePointPerLayerSorter.h:31
MuonR4::SegmentFit::ParamDefs::y0
@ y0
MuonR4::passRangeCut
constexpr bool passRangeCut(const std::array< double, 2 > &cutRange, const double value)
Definition: MdtSegmentSeedGenerator.cxx:27
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
MuonGMR4::SpectrometerSector::idHelperSvc
const Muon::IMuonIdHelperSvc * idHelperSvc() const
Returns the IdHelpeSvc.
Definition: SpectrometerSector.cxx:40
Amg::error
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 ...
Definition: EventPrimitivesHelpers.h:40
MuonR4::SegmentFit::toInt
constexpr int toInt(const ParamDefs p)
Definition: MuonHoughDefs.h:42
MuonR4::MdtSegmentSeedGenerator::DriftCircleSeed::chi2
double chi2
Seed chi2.
Definition: MdtSegmentSeedGenerator.h:71
MuonR4::MdtSegmentSeedGenerator::moveToNextCandidate
void moveToNextCandidate()
Prepares the generator to generate the seed from the next pair of drift circles.
Definition: MdtSegmentSeedGenerator.cxx:91
MuonR4::MdtSegmentSeedGenerator::DriftCircleSeed::nIter
unsigned int nIter
Iterations to obtain the seed.
Definition: MdtSegmentSeedGenerator.h:69
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
MuonR4
This header ties the generic definitions in this package.
Definition: HoughEventData.h:16
MuonR4::MdtSegmentSeedGenerator::Config::nMaxIter
unsigned int nMaxIter
Maximum number of iterations in the fast segment fit.
Definition: MdtSegmentSeedGenerator.h:58
MuonR4::SpacePoint::positionInChamber
const Amg::Vector3D & positionInChamber() const
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/src/SpacePoint.cxx:119
a
TList * a
Definition: liststreamerinfos.cxx:10
MuonR4::MdtSegmentSeedGenerator::m_segmentSeed
const SegmentSeed * m_segmentSeed
Definition: MdtSegmentSeedGenerator.h:145
CondAlgsOpts.found
int found
Definition: CondAlgsOpts.py:101
MuonR4::CalibSpacePointPtr
ISpacePointCalibrator::CalibSpacePointPtr CalibSpacePointPtr
Definition: SpacePointCalibrator.cxx:23
MuonR4::SpacePointPerLayerSorter::mdtHits
const HitLayVec & mdtHits() const
Returns the sorted Mdt hits.
Definition: SpacePointPerLayerSorter.h:23
MuonR4::MdtSegmentSeedGenerator::Config::tightenHitCut
bool tightenHitCut
Once a seed with even more than initially required hits is found, reject all following seeds with les...
Definition: MdtSegmentSeedGenerator.h:47
MuonR4::CalibratedSpacePoint
The calibrated Space point is created during the calibration process.
Definition: CalibratedSpacePoint.h:15
MuonR4::SegmentSeed
Representation of a segment seed (a fully processed hough maximum) produced by the hough transform.
Definition: SegmentSeed.h:14
MuonR4::MdtSegmentSeedGenerator::m_seenSolutions
std::vector< SeedSolution > m_seenSolutions
Definition: MdtSegmentSeedGenerator.h:159
MuonR4::MdtSegmentSeedGenerator::Config::interceptRange
std::array< double, 2 > interceptRange
Cut on the intercept range.
Definition: MdtSegmentSeedGenerator.h:33
MuonR4::SegmentSeed::parameters
const Parameters & parameters() const
Returns the parameter array.
Definition: SegmentSeed.cxx:35
CxxUtils::sincos
Helper to simultaneously calculate sin and cos of the same angle.
Definition: sincos.h:76
Muon::IMuonIdHelperSvc
Interface for Helper service that creates muon Identifiers and can be used to print Identifiers.
Definition: IMuonIdHelperSvc.h:26
MuonR4::MdtSegmentSeedGenerator::DriftCircleSeed
Helper struct from a generated Mdt seed.
Definition: MdtSegmentSeedGenerator.h:63
MuonR4::MdtSegmentSeedGenerator::fitDriftCircles
void fitDriftCircles(DriftCircleSeed &seed) const
Refine the seed by performing a fast Mdt segment fit.
Definition: MdtSegmentSeedGenerator.cxx:332
MuonR4::MdtSegmentSeedGenerator::m_signComboIndex
std::size_t m_signComboIndex
Explicit hit to pick in the selected top layer.
Definition: MdtSegmentSeedGenerator.h:157
MuonR4::MdtSegmentSeedGenerator::Config::precCutOff
double precCutOff
Precision cut off in the fast segment fit.
Definition: MdtSegmentSeedGenerator.h:60
MuonR4::SpacePoint::driftRadius
double driftRadius() const
: Returns the size of the drift radius
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/src/SpacePoint.cxx:143
MuonR4::CalibratedSpacePoint::covariance
const Covariance_t & covariance() const
Definition: CalibratedSpacePoint.cxx:33
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
MuonR4::SegmentFit::dirFromAngles
Amg::Vector3D dirFromAngles(const double phi, const double theta)
Constructs a direction vector from the polar theta & phi angles.
Definition: SegmentFitterEventData.cxx:26
MuonR4::SegmentSeed::directionInChamber
Amg::Vector3D directionInChamber() const
Returns the direction of the seed in the sector frame.
Definition: SegmentSeed.cxx:42
xAOD::MdtDriftCircle_v1
https://gitlab.cern.ch/atlas/athena/-/blob/master/MuonSpectrometer/MuonReconstruction/MuonRecEvent/Mu...
Definition: MdtDriftCircle_v1.h:21
MuonR4::MdtSegmentSeedGenerator::Config::calibrator
const ISpacePointCalibrator * calibrator
Pointer to the space point calibrator.
Definition: MdtSegmentSeedGenerator.h:54
MuonR4::MdtSegmentSeedGenerator::m_hitLayers
SpacePointPerLayerSorter m_hitLayers
Definition: MdtSegmentSeedGenerator.h:146
MuonR4::MdtSegmentSeedGenerator::HitVec
SpacePointPerLayerSorter::HitVec HitVec
Definition: MdtSegmentSeedGenerator.h:26
WriteBchToCool.update
update
Definition: WriteBchToCool.py:67
MuonR4::MdtSegmentSeedGenerator::m_lowerLayer
std::size_t m_lowerLayer
Considered layer to pick the bottom drift circle from.
Definition: MdtSegmentSeedGenerator.h:151
MuonR4::SpacePoint::identify
const Identifier & identify() const
: Identifier of the primary measurement
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/src/SpacePoint.cxx:140
MuonR4::SegmentFit::ParamDefs::theta
@ theta
generate::Zero
void Zero(TH1D *hin)
Definition: generate.cxx:32
MuonR4::MdtSegmentSeedGenerator::nextSeed
std::optional< DriftCircleSeed > nextSeed(const EventContext &ctx)
returns the next seed in the row
Definition: MdtSegmentSeedGenerator.cxx:117
MuonR4::MdtSegmentSeedGenerator::SeedSolution::Y0
double Y0
Intersecpt of the line.
Definition: MdtSegmentSeedGenerator.h:107