23#include "Acts/Definitions/Units.hpp"
24#include "Acts/EventData/ParticleHypothesis.hpp"
25#include "Acts/Surfaces/PlaneSurface.hpp"
26#include "Acts/Utilities/Helpers.hpp"
34using namespace Acts::UnitLiterals;
38 constexpr double toDeg(
const double rad) {
39 return rad / 1._degree;
45 const EventContext& ctx) {
47 if(!
SG::get(muTagCont, key, ctx).isSuccess()){
54 if (muTag->idTrack() == &idTrack){
61 bool isOnCaloExit(
const Acts::Surface& surf) {
65 bool isOnCaloExit(
const Acts::BoundTrackParameters& pars) {
66 return isOnCaloExit(pars.referenceSurface());
75 if (matchedSegs.empty() ||
toLayerIndex(matchedSegs.front()->chamberIndex()) ==
toLayerIndex(matchedSegs.back()->chamberIndex())) {
88 const auto [barrelLength, barrelTheta] =
calcSeedLength(tgContext, barrelSeed);
89 const auto [endcapLength, endcapTheta] =
calcSeedLength(tgContext, endcapSeed);
90 ATH_MSG_VERBOSE(__func__<<
"() "<<__LINE__<<
" - Constructed new seed from truth muon wih pT:"
91 <<(truthMuon.pt()/ Gaudi::Units::GeV)<<
" [GeV], eta: "<<truthMuon.eta()
92 <<
", phi: "<<toDeg(truthMuon.phi())<<
", q: "<<truthMuon.charge()
93 <<
", matchedSeg: "<<matchedSegs.size()<<
" barrel (L/theta): "<<barrelLength
94 <<
"/"<<barrelTheta<<
" - endcap (L/theta): "
95 <<endcapLength<<
"/"<<endcapTheta<<
"\n"<<barrelSeed);
96 if (barrelLength < 0 && endcapLength < 0) {
100 return barrelLength < 0 || std::abs(endcapLength) < barrelLength
101 ? endcapSeed : barrelSeed;
106 double maxL{-1.*Gaudi::Units::km}, minL{1.*Gaudi::Units::km},
107 maxTheta{-181.}, minTheta{181};
110 if (!
m_seedingTool->withinBounds(projPos, seed.location())) {
113 const double projected = projPos[seed.location()==Location::Barrel];
114 const double theta = seg->direction().theta();
115 minL = std::min(minL, projected);
116 maxL = std::max(maxL, projected);
117 minTheta = std::min(minTheta, toDeg(
theta));
118 maxTheta = std::max(maxTheta, toDeg(
theta));
120 return std::make_pair(maxL - minL, maxTheta - minTheta);
151 return m_segSelector->passSeedingQuality(Gaudi::Hive::currentContext(),
156 return m_segSelector->passTrackQuality(Gaudi::Hive::currentContext(),
167 const unsigned linkIdx = truthS ?
m_truthSegs->push_back(*truthS) : -1;
187 unsigned short linkIdx =
m_truthTrks->find(truthP);
190 for (
auto loc : {Location::Barrel, Location::Endcap}) {
192 std::format(
"TruthSegments_has{}Proj", loc), [loc,
this](
const SG::AuxElement* aux) ->
unsigned short {
195 const Acts::GeometryContext tgContext =
m_ctxProvider.getGeometryContext(Gaudi::Hive::currentContext());
210 std::vector<unsigned short>>>(
m_tree,
212 std::vector<unsigned short> idx{};
222 return getTruthSegments(p).size();
228 std::vector<const xAOD::MuonSimHit*> allHits{};
233 if (allHits.empty()) {
237 return a->kineticEnergy() < b->kineticEnergy();
239 return (
min->kineticEnergy() -
max->kineticEnergy()) / Gaudi::Units::GeV;
242 auto cone = std::make_shared<VectorBranch<float>>(m_tree,
243 std::format(
"{}_seedThetaCone", m_truthTrks->name()));
244 auto qTimesP = std::make_shared<VectorBranch<float>>(m_tree,
245 std::format(
"{}_qTimesP", m_truthTrks->name()));
247 m_tree.addBranch(cone);
248 m_tree.addBranch(qTimesP);
251 std::format(
"{:}_seedLength", m_truthTrks->name()), [cone, qTimesP,
this] (
const xAOD::TruthParticle& p) ->
float {
253 const EventContext& ctx{Gaudi::Hive::currentContext()};
254 const Acts::GeometryContext tgContext = m_ctxProvider.getGeometryContext(ctx);
255 const Acts::MagneticFieldContext mfContext = m_ctxProvider.getMagneticFieldContext(ctx);
257 mfContext.get<
const AtlasFieldCacheCondObj*>()->getInitializedCache(magField);
258 auto truthSeed = makeSeedFromTruth(tgContext, p);
261 qTimesP->push_back(0);
264 auto [
length,
theta] = calcSeedLength(tgContext, *truthSeed);
265 cone->push_back(
theta);
266 qTimesP->push_back(m_seedingTool->estimateQtimesP(tgContext, *truthSeed, magField) / Gaudi::Units::GeV);
271 for (
const auto var :{
"d0",
"z0",
"prodZ",
"prodR"}) {
272 m_trkTruthLinks.emplace_back(m_truthKey, var);
273 m_truthTrks->addVariable<
float>(-99999.f,
var);
276 m_tree.addBranch(m_truthTrks);
277 m_trkTruthLinks.emplace_back(m_truthSegmentKey,
"truthParticleLink");
278 m_trkTruthLinks.emplace_back(m_truthKey,
"truthSegmentLinks");
279 m_trkTruthLinks.emplace_back(m_recoSegmentKey,
"truthSegmentLink");
280 m_trkTruthLinks.emplace_back(m_muonKey,
"truthParticleLink");
283 m_tree.addBranch(m_recoSegs);
284 m_tree.addBranch(std::make_unique<EventInfoBranch>(m_tree, evOpts));
286 static const std::vector<std::string> trackSummaries{
288 "innerSmallHits",
"innerLargeHits",
"innerSmallHoles",
"innerLargeHoles",
289 "innerClosePrecisionHits",
291 "middleSmallHits",
"middleLargeHits",
"middleSmallHoles",
292 "middleLargeHoles",
"middleClosePrecisionHits",
294 "outerSmallHits",
"outerLargeHits",
"outerSmallHoles",
"outerLargeHoles",
295 "outerClosePrecisionHits",
297 "extendedSmallHits",
"extendedLargeHits",
"extendedSmallHoles",
298 "extendedLargeHoles",
"extendedClosePrecisionHits",
299 "innerTriggerEtaHits",
"innerTriggerPhiHits",
300 "middleTriggerEtaHits",
"middleTriggerPhiHits",
301 "outerTriggerEtaHits",
"outerTriggerPhiHits",
303 "innerTriggerEtaHoles",
"innerTriggerPhiHoles",
304 "middleTriggerEtaHoles",
"middleTriggerPhiHoles",
305 "outerTriggerEtaHoles",
"outerTriggerPhiHoles",
307 if(!m_legacyTrackKey.empty()) {
308 m_legacyTrks = std::make_unique<IParticleFourMomBranch>(m_tree,
"LegacyMSTrks");
309 m_legacyTrks->addVariable(std::make_unique<TrackChi2Branch>(*m_legacyTrks));
314 },
"truth",
"LegacyMS");
316 for (
const auto& summary : trackSummaries) {
319 m_tree.addBranch(m_legacyTrks);
320 m_legacyRecoSegs = std::make_unique<SegmentVariables>(m_tree, m_legacySegmentKey.key(),
"LegacyRecoSegments", msgLevel());
321 m_tree.addBranch(m_legacyRecoSegs);
324 m_seedSummary = std::make_shared<TrackSummaryModule>(m_tree,
"TrkSeed", m_summaryTool.get());
325 m_muonTrks = std::make_shared<IParticleFourMomBranch>(m_tree,
"ActsMuons");
326 m_muonTrks->addVariable(std::make_unique<TrackChi2Branch>(*m_muonTrks));
327 m_muonTrks->addVariable<
float>(4.5,
"segmentDeltaEta");
328 m_muonTrks->addVariable<
float>(std::numbers::pi,
"segmentDeltaPhi");
329 m_muonTrks->addVariable<
float>(-1.,
"segmentChi2OverDoF");
331 using TrkType = xAOD::Muon::TrackParticleType;
332 auto dumpTrack = [&](
const std::string& trkName, TrkType
type) {
333 auto trkColl = std::make_shared<IParticleFourMomBranch>(m_tree, trkName);
334 trkColl->addVariable(std::make_unique<TrackChi2Branch>(*trkColl));
335 if (
type != TrkType::InnerDetectorTrackParticle) {
336 trkColl->addVariable(std::make_unique<TrackFitIterBranch>(*trkColl));
338 trkColl->addVariable(std::make_unique<MaterialRecorderBranch>(*trkColl));
339 trkColl->addVariable(std::make_unique<EnergyLossBranch>(*trkColl));
341 trkColl->addVariable<
float>(
"d0");
342 trkColl->addVariable<
float>(
"z0");
343 if (
type != TrkType::InnerDetectorTrackParticle) {
344 for (
const auto& summary : trackSummaries) {
360 auto msTracks = dumpTrack(
"MsTrk", TrkType::MuonSpectrometerTrackParticle);
361 dumpTrack(
"MeTrk", TrkType::ExtrapolatedMuonSpectrometerTrackParticle);
362 m_idTracks = dumpTrack(
"IdTrk", TrkType::InnerDetectorTrackParticle);
366 auto&
l0{
m_tree.newVector<
float>(std::format(
"{:}_caloExitLoc0", m_idTracks->name()))};
367 auto&
l1{
m_tree.newVector<
float>(std::format(
"{:}_caloExitLoc1", m_idTracks->name()))};
368 auto&
theta{
m_tree.newVector<
float>(std::format(
"{:}_caloExitTheta", m_idTracks->name()))};
369 auto&
phi{
m_tree.newVector<
float>(std::format(
"{:}_caloExitPhi", m_idTracks->name()))};
370 auto&
mom{
m_tree.newVector<
float>(std::format(
"{:}_caloExitMom", m_idTracks->name()))};
373 std::format(
"{:}_isCandidate", m_idTracks->name()),
375 const MuonR4::MuonTag* tag = findBaseIdTag(idTrack, Gaudi::Hive::currentContext());
376 std::optional<Acts::BoundTrackParameters> trkPars = tag ? tag->extrapolatedParsID(Acts::hashString(
"@CaloExit"))
378 const std::size_t idx = l0.size();
379 using namespace MuonCombinedR4;
380 l0[idx] = trkPars ? longitudinalParam(*trkPars, logger()) : 1._km;
381 l1[idx] = trkPars ? toDeg(localPolarAngle(*trkPars, logger())) : 360.;
383 theta[idx] = trkPars ? toDeg(trkPars->get<Acts::eBoundTheta>()) : 360.;
384 phi[idx] = trkPars ? toDeg(trkPars->get<Acts::eBoundPhi>()) : 360.;
385 mom[idx] = trkPars ? trkPars->absoluteMomentum() : -1._GeV;
386 return trkPars != std::nullopt;
390 auto& dX0{
m_tree.newMatrix<
float>(std::format(
"{:}_segTagDx0", m_idTracks->name()))};
391 auto& dY0{
m_tree.newMatrix<
float>(std::format(
"{:}_segTagDy0", m_idTracks->name()))};
392 auto&
dTheta{
m_tree.newMatrix<
float>(std::format(
"{:}_segTagDtheta", m_idTracks->name()))};
393 auto&
dPhi{
m_tree.newMatrix<
float>(std::format(
"{:}_segTagDphi", m_idTracks->name()))};
394 auto& segments{
m_tree.newMatrix<std::uint8_t>(std::format(
"{:}_segTagSegments", m_idTracks->name()))};
395 auto& goodExtp{
m_tree.newMatrix<std::uint8_t>(std::format(
"{:}_segTagExtpGood",m_idTracks->name()))};
396 auto& taggedSeg{
m_tree.newMatrix<std::uint8_t>(std::format(
"{:}_segTagOnTag", m_idTracks->name()))};
397 m_idTracks->addVariable(
399 std::format(
"{:}_segTagScore", m_idTracks->name()),
400 [&dX0, &dY0, &dTheta, &dPhi, &segments,
402 auto result = calcSegTagVariables(idTrack, Gaudi::Hive::currentContext());
404 segments.push_back(std::move(result.recoSegs));
405 dX0.push_back(std::move(result.deltaX0));
406 dY0.push_back(std::move(result.deltaY0));
407 dTheta.push_back(std::move(result.deltaTheta));
408 dPhi.push_back(std::move(result.deltaPhi));
409 goodExtp.push_back(std::move(result.goodExtp));
410 taggedSeg.push_back(std::move(result.taggedSeg));
411 return std::move(result.matchScores);
417 return truthTreeParticle(*trk, Gaudi::Hive::currentContext());
418 },
"truth",
"IdTrack");
422 m_muonTrks->addVariable<
uint16_t>(
"allAuthors");
423 m_muonTrks->addVariable<
uint16_t>(
"author");
426 std::vector<unsigned short>>>(m_tree,
427 std::format(
"{:}_segmentLinks", m_muonTrks->name()), [&] (
const xAOD::Muon& p){
428 std::vector<unsigned short> idx{};
429 for (
unsigned seg = 0 ; seg <
p.nMuonSegments(); ++seg) {
430 idx.push_back(m_recoSegs->push_back(*
p.muonSegment(seg)));
436 std::format(
"{:}_seedLink", msTracks->name()), [&] (
const xAOD::TrackParticle& p) ->
unsigned short {
437 auto actsTrk = ActsTrk::getActsTrack(p);
439 THROW_EXCEPTION(
"Cannot find the associated ms track from the primary track");
441 return actsTrk->component<std::size_t>(
"parentSeed");
448 THROW_EXCEPTION(
"Cannot find the associated ms track from the primary track");
450 auto refPars = actsTrk->createParametersAtReference();
452 : refPars.
get<
Acts::eBoundLoc0>();
458 THROW_EXCEPTION(
"Cannot find the associated ms track from the primary track");
460 auto refPars = actsTrk->createParametersAtReference();
462 : refPars.
get<
Acts::eBoundLoc0>();
468 THROW_EXCEPTION(
"Cannot find the associated ms track from the primary track");
470 return isOnCaloExit(actsTrk->referenceSurface());
476 },
"truth",
"ActsMuon");
479 for (
const auto& summary : trackSummaries) {
482 m_tree.addBranch(m_muonTrks);
484 m_tree.addBranch(m_seedSummary);
488 return StatusCode::SUCCESS;
492 const EventContext& ctx)
const {
506 const EventContext& ctx)
const {
507 return findTagMatchingToId(idTrack,
m_idTagKey, ctx);
510 const EventContext& ctx)
const {
511 return findTagMatchingToId(idTrack,
m_segTagKey, ctx);
514 std::vector<const xAOD::MuonSegment*>
516 const EventContext& ctx)
const {
517 std::vector<const xAOD::MuonSegment*> compatibleSegs{};
519 std::vector<const xAOD::MuonSegment*> truthSegs =
getTruthSegments(*truthPart);
522 std::copy_if(recoSegs->
begin(), recoSegs->
end(), std::back_inserter(compatibleSegs),
524 return Acts::rangeContainsValue(truthSegs, getMatchedTruthSegment(*recoSeg));
526 if (!compatibleSegs.empty()) {
527 return compatibleSegs;
534 if (muon->trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle) == &idTrack) {
535 for (std::size_t s = 0; s < muon->nMuonSegments() ; ++s) {
536 compatibleSegs.push_back(muon->muonSegment(s));
541 return compatibleSegs;
550 const EventContext& ctx) {
555 if (compatibleSegs.empty()) {
563 std::optional<Acts::BoundTrackParameters> startPars = caloExt->
lastParameters();
570 const Acts::GeometryContext tgContext =
m_ctxProvider.getGeometryContext(ctx);
575 const Acts::Surface& target{msSector->
surface()};
576 if (target.geometryId() == startPars->referenceSurface().geometryId()) {
580 auto surfPars = muTag->
extrapolatedParsID(Acts::toUnderlying(segment.chamberIndex()));
582 startPars = surfPars;
583 ATH_MSG_VERBOSE(__func__<<
"() "<<__LINE__<<
" - Recycle cached parameters from muTag\n"
587 ATH_MSG_DEBUG(__func__<<
"() "<<__LINE__<<
" - Extrapolation to "<<
printID(segment)<<
" failed somehow");
591 if (!extpPars.ok()) {
592 ATH_MSG_DEBUG(__func__<<
"() "<<__LINE__<<
" - Extrapolation keeps failing");
595 ATH_MSG_DEBUG(__func__<<
"() "<<__LINE__<<
" - Updated parameters to \n"<<(*extpPars));
596 startPars = *extpPars;
601 float bestMatchScore{std::numeric_limits<float>::max()};
602 Acts::BoundVector bestPars{Acts::BoundVector::Zero()};
604 auto dumpBestSeg = [&]() {
608 result.recoSegs.push_back(
m_recoSegs->push_back(*bestSeg));
609 result.matchScores.push_back(bestMatchScore);
610 result.deltaPhi.push_back(toDeg(bestPars[Acts::eBoundPhi]));
611 result.deltaTheta.push_back(toDeg(bestPars[Acts::eBoundTheta]));
612 result.deltaY0.push_back(bestPars[Acts::eBoundLoc1]);
613 result.deltaX0.push_back(bestPars[Acts::eBoundLoc0]);
614 result.goodExtp.push_back(1);
615 result.taggedSeg.push_back(muTag && Acts::rangeContainsValue(muTag->
segments(), bestSeg));
617 bestMatchScore = std::numeric_limits<float>::max();
618 bestPars = Acts::BoundVector::Zero();
621 for (
auto segItr = compatibleSegs.begin(); segItr != compatibleSegs.end(); ) {
624 if (!nextParameters(*testMe)) {
625 result.recoSegs.push_back(
m_recoSegs->push_back(*testMe));
626 result.matchScores.push_back(-1.f);
627 result.deltaX0.push_back(1._m);
628 result.deltaY0.push_back(1._m);
629 result.deltaTheta.push_back(180.);
630 result.deltaPhi.push_back(180.);
631 result.goodExtp.push_back(0);
632 result.taggedSeg.push_back(0);
633 segItr = std::find_if(std::next(segItr),compatibleSegs.end(), [&](
const xAOD::MuonSegment* assocSeg){
634 return getEnvelope(*testMe) != getEnvelope(*assocSeg);
644 Acts::BoundVector dPars = segmentPars.parameters() - startPars->parameters();
647 dPars[Acts::eBoundPhi] = dPars[Acts::eBoundLoc0] = 0.;
652 dPars[Acts::eBoundQOverP] = dPars[Acts::eBoundTime] = 0.;
653 Acts::BoundMatrix covariance{Acts::BoundMatrix::Identity()};
654 covariance(Acts::eBoundLoc0, Acts::eBoundLoc0) = Acts::square(
m_toleranceX0.value());
655 covariance(Acts::eBoundLoc1, Acts::eBoundLoc1) = Acts::square(
m_toleranceY0.value());
656 covariance(Acts::eBoundTheta, Acts::eBoundTheta) = Acts::square(
m_toleranceTheta.value());
657 covariance(Acts::eBoundPhi, Acts::eBoundPhi) = Acts::square(
m_tolerancePhi.value());
658 if (startPars->covariance()) {
659 covariance += (*startPars->covariance());
661 if (segmentPars.covariance()) {
662 covariance += (*segmentPars.covariance());
664 const float chi2 = dPars.dot(covariance.inverse()*dPars);
665 ATH_MSG_VERBOSE(__func__<<
"() "<<__LINE__<<
" - Difference: "<<Acts::toString(dPars)
666 <<
", covariance: \n"<<Acts::toString(covariance)<<
",\nchi2: "<<
chi2);
667 if (
chi2 < bestMatchScore) {
668 ATH_MSG_DEBUG(__func__<<
"() "<<__LINE__<<
" - Best parameters on surface thus far");
669 bestMatchScore =
chi2;
671 bestPars = std::move(dPars);
686 return StatusCode::SUCCESS;
690 ATH_MSG_VERBOSE(
"iMuon " << muon->index() <<
" pT: "<<(muon->pt() *MeVtoGeV)<<
" [GeV], eta: "
691 <<muon->eta() <<
", phi: "<<toDeg(muon->phi())<<
", q: "<<muon->charge()
692 <<
", nSegments: "<<muon->nMuonSegments());
693 const xAOD::TrackParticle* track = muon->trackParticle(xAOD::Muon::TrackParticleType::MuonSpectrometerTrackParticle);
700 for (
size_t s = 0; s < muon->nMuonSegments(); ++s) {
703 ATH_MSG_VERBOSE(std::format(
"Legacy muon-segment link: segment {:} @{:}, eta: {:.2f}, phi {:.2f}",
714 if (legacyRecoSegs->
size()) {
730 return StatusCode::SUCCESS;
734 return StatusCode::SUCCESS;
742 Amg::toString(seg->position())<<
", eta: "<<seg->direction().eta()
743 <<
", phi: "<<toDeg(seg->direction().phi()));
746 if (truthSegs->
size()) {
753 const std::size_t nT = truthMuons->
size() - 1;
754 if (!truthMuons->
empty()) {
762 <<
", eta: "<<truth->eta()<<
", phi: "<<toDeg(truth->phi())<<
", q: "<<truth->charge()
767 return StatusCode::SUCCESS;
785 const Acts::GeometryContext tgContext =
m_ctxProvider.getGeometryContext(ctx);
786 const Acts::MagneticFieldContext mfContext =
m_ctxProvider.getMagneticFieldContext(ctx);
792 std::vector<unsigned>> truthToSeedMatchCounter{};
794 if (!trkSeeds->empty()) {
801 m_seedType+= Acts::toUnderlying(seed.location());
805 auto startPars =
m_seedingTool->estimateStartParameters(ctx, seed);
806 if (startPars.ok()) {
816 truthSeg !=
nullptr) {
818 if (seedIdx >= matchCounter.size()) {
819 matchCounter.resize(seedIdx +1);
821 ++matchCounter[seedIdx];
831 for (
auto& [truthMuon, matches] : truthToSeedMatchCounter) {
832 const unsigned tIndex =
m_truthTrks->find(truthMuon);
837 while (std::count_if(matches.begin(), matches.end(),
838 [](
const unsigned nMatched){
841 auto bestMatch = std::ranges::max_element(matches);
842 const std::size_t seedIdx = std::distance(matches.begin(), bestMatch);
864 return xAOD::TruthHelpers::getTruthParticle(*idTrk) ==
865 xAOD::TruthHelpers::getTruthParticle(*p);
875 if (idTag->extrapolatedParsID(Acts::hashString(
"@CaloExit"))){
880 return StatusCode::SUCCESS;
888 return StatusCode::SUCCESS;
892 return StatusCode::SUCCESS;
Scalar phi() const
phi method
Scalar theta() const
theta method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_VERBOSE(x,...)
Handle class for reading from StoreGate.
std::unique_ptr< const Acts::Logger > makeActsAthenaLogger(IMessageSvc *svc, const std::string &name, int level, std::optional< std::string > parent_name)
The CaloExtension holds the ID extrapolation states through the calorimeter and the associated CaloCl...
std::optional< Acts::BoundTrackParameters > lastParameters() const
Returns the outermost parameters known to the extension.
const ServiceHandle< StoreGateSvc > & detStore() const
StatusCode addVariable(const std::string &name, T *&ptr, std::string_view docstring="")
Add a variable to the tuple.
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
bool empty() const noexcept
Returns true if the collection is empty.
Local cache for magnetic field (based on MagFieldServices/AtlasFieldSvcTLS.h).
A spectrometer sector forms the envelope of all chambers that are placed in the same MS sector & laye...
const Acts::PlaneSurface & surface() const
Returns the associated surface.
void addSegment(const xAOD::MuonSegment *seg)
Append a segment to the seed.
Location
Enum defining whether the seed is made in the endcap / barrel.
void setPosition(Amg::Vector3D &&pos)
set the seed's position
Baseline EDM object to gather all relevant information about a reconstructed muon candidate which can...
std::optional< Acts::BoundTrackParameters > extrapolatedParsID(const Acts::HashedString &parName) const
Returns the cached extrapolated ID track parameters.
const std::vector< const xAOD::MuonSegment * > & segments() const
Returns the segments associated with the tag.
ToolHandle< MuonR4::ITrackSeedingDiagnosticsTool > m_seedingTool
The track seeding tool to construct the seed candidates and to estimate the initial parameters.
const MuonGMR4::MuonDetectorManager * m_detMgr
The detector manager to fetch the segment surfaces.
MuonVal::ScalarBranch< std::uint16_t > & m_nIdTags
The number of selected ID tracks in the event.
ToolHandle< MuonR4::ITrackSummaryTool > m_summaryTool
Hit summary tool.
StatusCode dumpLegacyTracks(const EventContext &ctx)
Dumps the legacy containers to the TTree.
SegmentKey_t m_legacySegmentKey
Legacy segment container.
const MuonR4::MuonTag * findBaseIdTag(const xAOD::TrackParticle &idTrack, const EventContext &ctx) const
Searches the Id track in the basline collection of all ID tracks selected for the combined muon recon...
const MuonGMR4::SpectrometerSector * getEnvelope(const xAOD::MuonSegment &segment) const
MuonTagKey_t m_idTagKey
The collection of all ID tracks that are selected for combined reconstruction.
TrackKey_t m_idTrackKey
The collection of ID tracks associated with the truth particle.
MuonVal::VectorBranch< unsigned short > & m_legacySegToTrkLinks
Link of the legacy track to the legacy segment.
ParticleBranchPtr_t m_truthTrks
MuonVal::VectorBranch< int > & m_seedSector
Sector of the seed, even center, odd overlap regions, for details see:
MuonVal::VectorBranch< float > & m_seedThetaCone
Maximum angular difference between the segments part of the seed.
ParticleBranchPtr_t m_legacyTrks
Output branches of the legacy MS tracks.
SegmentBranchPtr_t m_truthSegs
SegmentBranchPtr_t m_legacyRecoSegs
MuonVal::ScalarBranch< std::uint16_t > & m_nIdTracks
The number of ID tracks in the event.
MuonVal::MatrixBranch< unsigned short > & m_truthMuRecoSegLinks
Links from the truth muon to the segments.
std::unique_ptr< const Acts::Logger > m_logger
Instance to the Acts logger.
MuonVal::MatrixBranch< unsigned short > & m_truthMuToSeedIdx
Links to all MsTrkSeeds that could be matched to the truthMuon, i.e.
TrackKey_t m_legacyTrackKey
Legacy track reconstruction chain.
std::pair< double, double > calcSeedLength(const Acts::GeometryContext &tgContext, const MuonR4::MsTrackSeed &seed) const
Calculate the length of the seed and the theta deflection angle The length is defined as the spread o...
StatusCode execute(const EventContext &ctx) override final
Execute method.
SegmentTagVariables calcSegTagVariables(const xAOD::TrackParticle &idTrack, const EventContext &ctx)
MuonTagKey_t m_segTagKey
The collection of the original segment tags.
MuonVal::VectorBranch< char > & m_seedType
Is the seed in the encap or in the barrel chambers.
StatusCode dumpRecoContent(const EventContext &ctx)
Dump the reconstructed information.
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthKey
Key to the truth particle collection.
Gaudi::Property< double > m_toleranceTheta
Extra tolerance applied on the bending direction when calculating the matching score.
Gaudi::Property< bool > m_isMC
Toggle whether the job runs on MC or not.
ParticleBranchPtr_t m_muonTrks
Stored muon information from the Acts muon reco chain.
MuonVal::MatrixBranch< unsigned short > & m_truthSegToRecoLink
Link of the truth segments to the matchin reco segments.
Gaudi::Property< double > m_toleranceX0
Extra tolerance applied on the non-bending intercept when calculating the matching score.
SegmentBranchPtr_t m_recoSegs
StatusCode dumpTruthContent(const EventContext &ctx)
Dump truth information.
SG::ReadHandleKey< MuonR4::MsTrackSeedContainer > m_msTrkSeedKey
Temporary container write handle to push the seeds to store gate for later efficiency analysis.
Gaudi::Property< bool > m_storeID
Toggle whether to process ID tracks or not.
ToolHandle< ActsTrk::IExtrapolationTool > m_extrapolationTool
Track extrapolation tool.
const xAOD::TruthParticle * truthTreeParticle(const xAOD::IParticle &part, const EventContext &ctx) const
Returns the matched truth particle that is dumped in the tree.
const MuonR4::MuonTag * findMuTagIMO(const xAOD::TrackParticle &idTrack, const EventContext &ctx) const
ParticleBranchPtr_t m_idTracks
Stored ID track information.
StatusCode initialize() override final
MuonVal::MatrixBranch< unsigned short > & m_seedRecoSegMatch
Link of the track seed to the building segment.
MuonVal::VectorBranch< float > & m_seedQP
Estimated momentum times charge from the track seed.
MuonVal::MatrixBranch< unsigned short > & m_truthMuToSeedCounter
Number of matched segments in the seed.
MuonVal::ThreeVectorBranch m_seedPos
Simple seed information.
Gaudi::Property< double > m_tolerancePhi
Extra tolerance applied on the bending direction when calculating the matching score.
MuonKey_t m_legacyMuonKey
Legacy muons.
MuonVal::VectorBranch< float > & m_seedLength
Maximum separation between the segments on the reference plane.
MuonVal::UnitThreeVectorBranch m_seedDir
Seed direction vector.
ToolHandle< MuonR4::ISegmentSelectionTool > m_segSelector
Selection tool to quantify the segment candidate quality.
SegmentKey_t m_recoSegmentKey
Primary segment container.
MuonVal::MuonTesterTree m_tree
The output tree object.
std::vector< const xAOD::MuonSegment * > getAssociatedSegments(const xAOD::TrackParticle &idTrack, const EventContext &ctx) const
Returns the collection of reconstructed segments that can be associated to the id track If the track ...
ActsTrk::ContextUtility m_ctxProvider
Context provider for geometry, magnetic field and calibration contexts.
SegmentKey_t m_truthSegmentKey
Segment from the truth hits.
MuonVal::VectorBranch< char > & m_seedGood
Does the seeding tool construct valid parameters from the seed.
std::optional< MuonR4::MsTrackSeed > makeSeedFromTruth(const Acts::GeometryContext &tgContext, const xAOD::TruthParticle &truthMuon) const
Construct MS track seed from the truth associated segments.
StatusCode finalize() override final
std::shared_ptr< TrackSummaryModule > m_seedSummary
Hit summary on the track seed.
Gaudi::Property< double > m_toleranceY0
Extra tolerance applied on the bending intercept when calculating the matching score.
MuonVal::VectorBranch< unsigned short > & m_seedTruthLink
Link to the truth muon.
MuonKey_t m_muonKey
Dependency on the R4 muon container.
static bool connectCollections(ParticleBranch_ptr primColl, ParticleBranch_ptr secondColl, Linker_t fromPrimToSec, const std::string &altPrimName="", const std::string &altSecName="")
@ isMC
Flag determining whether the branch is simulation.
Generic branch object where the information is evaluated by a std::function instead reading it from t...
Property holding a SG store/key/clid from which a ReadHandle is made.
Class providing the definition of the 4-vector interface.
Amg::Vector3D direction() const
Returns the direction as Amg::Vector.
::Muon::MuonStationIndex::ChIndex chamberIndex() const
Returns the chamber index.
Amg::Vector3D position() const
Returns the position as Amg::Vector.
int etaIndex() const
Returns the eta index, which corresponds to stationEta in the offline identifiers (and the ).
std::uint8_t nPhiLayers() const
Returns the number of trigger phi hits.
double chi2(TH1 *h0, TH1 *h1)
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
static Root::TMsgLogger logger("iLumiCalc")
constexpr std::size_t s_caloEnvelopeID
Volume Ids ofthe Calorimeter.
const CaloExtension * getCaloExtension(const xAOD::TrackParticle &track)
Retrieve a pointer to the CaloExtension linked with the passed TrackParticle.
std::optional< ActsTrk::TrackContainer::ConstTrackProxy > getActsTrack(const xAOD::TrackParticle &trkPart)
Return the proxy to the Acts track from which the track particle was made frome.
This class is not to needed in AthSimulation.
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Eigen::Matrix< double, 2, 1 > Vector2D
ID3PD * m_tree
Pointer to the ID3PD object used.
for(size_t i=0;i< m_blockFillers.size();i++)
Fill one block.
double localPolarAngle(const Acts::BoundTrackParameters &pars, const Acts::Logger &logger)
Returns the local angular polar angle of the track parameter.
double longitudinalParam(const Acts::BoundTrackParameters &pars, const Acts::Logger &logger)
Returns the longitudinal local track parameter which is defined as.
Acts::BoundTrackParameters boundSegmentPars(const ActsTrk::GeometryContext &gctx, const MuonGMR4::MuonDetectorManager &detMgr, const xAOD::MuonSegment &segment, const Acts::ParticleHypothesis hypot=Acts::ParticleHypothesis::muon())
Returns the segment parameters as boundTrackParameters.
This header ties the generic definitions in this package.
const xAOD::TruthParticle * getTruthMatchedParticle(const xAOD::MuonSegment &segment)
Returns the particle truth-matched to the segment.
std::vector< MsTrackSeed > MsTrackSeedContainer
std::string printID(const xAOD::MuonSegment &seg)
Print the chamber ID of a segment, e.g.
std::vector< const xAOD::MuonSimHit * > getMatchingSimHits(const xAOD::MuonSegment &segment)
: Returns all sim hits matched to a xAOD::MuonSegment
std::vector< const xAOD::MuonSegment * > getTruthSegments(const xAOD::TruthParticle &truthMuon)
Returns the segments associated to the truth muon.
DataVector< MuonTag > MuonTagContainer
const xAOD::MuonSegment * getMatchedTruthSegment(const xAOD::MuonSegment &segment)
Returns the truth-matched segment.
Lightweight algorithm to read xAOD MDT sim hits and (fast-digitised) drift circles from SG and fill a...
Class to store array like branches into the n-tuples.
LayerIndex toLayerIndex(ChIndex index)
convert ChIndex into LayerIndex
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
AuxElement(SG::AuxVectorData *container, size_t index)
Base class for elements of a container that can have aux data.
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
bool dPhi(const xAOD::TauJet &tau, const xAOD::CaloVertexedTopoCluster &cluster, float &out)
const xAOD::TruthParticle * getTruthParticle(const xAOD::IParticle &p)
Return the truthParticle associated to the given IParticle (if any).
MuonSegmentContainer_v1 MuonSegmentContainer
Definition of the current "MuonSegment container version".
TrackParticle_v1 TrackParticle
Reference the current persistent version:
MuonSimHit_v1 MuonSimHit
Defined the version of the MuonSimHit.
TruthParticle_v1 TruthParticle
Typedef to implementation.
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
Muon_v1 Muon
Reference the current persistent version:
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".
MuonSegment_v1 MuonSegment
Reference the current persistent version:
TruthParticleContainer_v1 TruthParticleContainer
Declare the latest version of the truth particle container.
Searched the MuTagIMO tag.
#define THROW_EXCEPTION(MESSAGE)