diff --git a/Tracking/Acts/FaserActsKalmanFilter/src/CKF2.cxx b/Tracking/Acts/FaserActsKalmanFilter/src/CKF2.cxx index 380f0e47ecf8186158625fa28df2146cf1604c7e..50ed0ad27d3f71cac6429344cd897d737b4e17b7 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/src/CKF2.cxx +++ b/Tracking/Acts/FaserActsKalmanFilter/src/CKF2.cxx @@ -105,13 +105,13 @@ StatusCode CKF2::execute() { Acts::CalibrationContext calibContext; CHECK(m_trackSeedTool->run(m_maskedLayers, m_backwardPropagation)); - std::shared_ptr<const Acts::Surface> initialSurface = + std::shared_ptr<const Acts::Surface> targetSurface = m_trackSeedTool->initialSurface(); std::shared_ptr<std::vector<Acts::BoundTrackParameters>> initialParameters = m_trackSeedTool->initialTrackParameters(); std::shared_ptr<std::vector<IndexSourceLink>> sourceLinks = m_trackSeedTool->sourceLinks(); - double origin = m_trackSeedTool->targetZPosition(); + double targetZposition = m_trackSeedTool->targetZPosition(); std::shared_ptr<std::vector<Measurement>> measurements = m_trackSeedTool->measurements(); std::shared_ptr<std::vector<const Tracker::FaserSCT_Cluster*>> clusters = m_trackSeedTool->clusters(); @@ -156,14 +156,15 @@ StatusCode CKF2::execute() { {Acts::GeometryIdentifier(), {{}, {m_chi2Max}, {m_nMax}}}, }; - // configuration of the GeneralFitterOptions + // configuration of the targetSurface of CKF in GeneralFitterOptions Acts::RotationMatrix3 rotation = Acts::RotationMatrix3::Identity(); - rotation.col(0) = Acts::Vector3(0, 0, -1); - rotation.col(1) = Acts::Vector3(0, 1, 0); - rotation.col(2) = Acts::Vector3(1, 0, 0); - Acts::Translation3 trans(0., 0., origin); - Acts::Transform3 trafo(rotation * trans); - initialSurface = Acts::Surface::makeShared<Acts::PerigeeSurface>(trafo); + rotation.col(0) = Acts::Vector3(0, 1, 0); + rotation.col(1) = Acts::Vector3(1, 0, 0); + rotation.col(2) = Acts::Vector3(0, 0, -1); + Acts::Translation3 trans(0., 0., targetZposition); + Acts::Transform3 trafo(trans*rotation); + ATH_MSG_DEBUG("ACTS CKF target surface has center at " << trafo.translation().transpose()); + targetSurface = Acts::Surface::makeShared<Acts::PlaneSurface>(trafo); Acts::PropagatorPlainOptions pOptions; pOptions.maxSteps = m_maxSteps; @@ -174,7 +175,7 @@ StatusCode CKF2::execute() { } GeneralFitterOptions options{ - gctx, magFieldContext, calibContext, &(*initialSurface), pOptions}; + gctx, magFieldContext, calibContext, &(*targetSurface), pOptions}; // Perform the track finding for all initial parameters @@ -182,7 +183,6 @@ StatusCode CKF2::execute() { ATH_MSG_DEBUG("Invoke track finding with " << initialParameters->size() << " seeds."); unsigned int nSeed = 0; - std::list<TrackInfo> allTracks; for (std::size_t iseed = 0; iseed < (*initialParameters).size(); ++iseed) { ATH_MSG_DEBUG(" position: " << (*initialParameters)[iseed].position(gctx).transpose()); @@ -200,15 +200,20 @@ StatusCode CKF2::execute() { auto& tracksForSeed = result.value(); m_numberOfFittedTracks += tracksForSeed.size(); + ATH_MSG_DEBUG("Find " << tracksForSeed.size() << " tracks for this seed"); for (auto& track : tracksForSeed) { // Set the seed number, this number decrease by 1 since the seed number // has already been updated seedNumber(track) = nSeed - 1; auto destProxy = tracks.getTrack(tracks.addTrack()); destProxy.copyFrom(track, true); // make sure we copy track states! - allTracks.push_back(track); } } + + std::list<TrackInfo> allTracks; + for(const auto& track: tracks){ + allTracks.push_back(track); + } // the list of tracks is sorted by the number of measurements using the chi2 value as a tie-breaker allTracks.sort([](const TrackInfo &left, const TrackInfo &right) { @@ -222,23 +227,22 @@ StatusCode CKF2::execute() { TrackInfo selected = allTracks.front(); auto destProxy = selectedTracks.getTrack(selectedTracks.addTrack()); - destProxy.copyFrom(selected.track, true); // make sure we copy track states! + destProxy.copyFrom(tracks.getTrack(selected.index), true); // make sure we copy track states! allTracks.remove_if([&](const TrackInfo &p) { return (p.nMeasurements <= 12) || ((p.clusterSet & selected.clusterSet).count() > 6); }); } - + ATH_MSG_DEBUG("There are " << selectedTracks.size() << " selected tracks for this event."); for (const auto & track : selectedTracks) { - //if(track.hasReferenceSurface){ - // const auto& parameter = track.parameters(); - // ATH_MSG_DEBUG("Fitted parameters"); - // ATH_MSG_DEBUG(" params: " << params.parameters().transpose()); - // ATH_MSG_DEBUG(" position: " << params.position(gctx).transpose()); - // ATH_MSG_DEBUG(" momentum: " << params.momentum().transpose()); - // ATH_MSG_DEBUG(" charge: " << params.charge()); - //} + if(track.hasReferenceSurface()){ + const auto& params = track.parameters(); + //const auto& qOp = track.qOverP(); + //const auto& charge = track.charge(); + ATH_MSG_DEBUG("Fitted parameters"); + ATH_MSG_DEBUG(" params: " << params.transpose()); + } std::unique_ptr<Trk::Track> trk = m_createTrkTrackTool->createTrack(gctx, track, m_backwardPropagation); m_numberOfSelectedTracks++; std::unique_ptr<Trk::Track> trk2 = m_kalmanFitterTool1->fit( @@ -251,9 +255,10 @@ StatusCode CKF2::execute() { } } + //write out all acts found tracks for debugging // // @todo run the performance writer // if (m_performanceWriter && !m_noDiagnostics) { -// ATH_CHECK(m_performanceWriterTool->write(gctx, selectedTrajectories)); +// ATH_CHECK(m_performanceWriterTool->write(gctx, tracks)); // } if (m_statesWriter && !m_noDiagnostics) { diff --git a/Tracking/Acts/FaserActsKalmanFilter/src/CKF2.h b/Tracking/Acts/FaserActsKalmanFilter/src/CKF2.h index a7d46feaf426d8f8edef703ea9b1291f59d768e4..7e6810e8d3f316eac3c1c1e493b9f25b34156c3f 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/src/CKF2.h +++ b/Tracking/Acts/FaserActsKalmanFilter/src/CKF2.h @@ -47,12 +47,13 @@ public: struct TrackInfo { TrackInfo(const FaserActsTrackContainer::TrackProxy& trk) : - track{trk}, clusterSet{nClusters} { + clusterSet{nClusters} { + nMeasurements = trk.nMeasurements(); chi2 = trk.chi2(); //@todo: Is this unique? index = trk.index(); - for (const auto& state : track.trackStatesReversed()) { + for (const auto& state : trk.trackStatesReversed()) { auto typeFlags = state.typeFlags(); if (not typeFlags.test(Acts::TrackStateFlag::MeasurementFlag)) { continue; @@ -63,7 +64,6 @@ public: } static size_t nClusters; - FaserActsTrackContainer::TrackProxy track; ClusterSet clusterSet; size_t nMeasurements; double chi2; diff --git a/Tracking/Acts/FaserActsKalmanFilter/src/TrackClassification.cxx b/Tracking/Acts/FaserActsKalmanFilter/src/TrackClassification.cxx index 6e8dfbac32f6c24e1c0823bda3bfe3c994b00978..a3cd8c500c543220b708842100aad9d9e10cd788 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/src/TrackClassification.cxx +++ b/Tracking/Acts/FaserActsKalmanFilter/src/TrackClassification.cxx @@ -39,21 +39,17 @@ void identifyContributingParticles( particleHitCounts.clear(); for (const auto& state : track.trackStatesReversed()) { - // no truth info with non-measurement state + // no truth info with non-measurement state if (not state.typeFlags().test(Acts::TrackStateFlag::MeasurementFlag)) { continue; } + std::vector<int> barcodes {}; // register all particles that generated this hit - //@todo: this can break. Need to understand the reason!!! if(not state.hasUncalibratedSourceLink()){ - //throw std::runtime_error("The measurement state does not have a source link?"); - continue; + throw std::runtime_error("The measurement state does not have a source link?"); } - Acts::SourceLink sl_acts = state.getUncalibratedSourceLink(); - IndexSourceLink sl = sl_acts.template get<IndexSourceLink>(); - // IndexSourceLink sl = - // state.getUncalibratedSourceLink().template get<IndexSourceLink>(); + IndexSourceLink sl = state.getUncalibratedSourceLink().template get<IndexSourceLink>(); if(sl.hit()==nullptr){ throw std::runtime_error("The source hit is empty"); }