diff --git a/ACTSTracking/Helpers.hxx b/ACTSTracking/Helpers.hxx index c84943a..83da45b 100644 --- a/ACTSTracking/Helpers.hxx +++ b/ACTSTracking/Helpers.hxx @@ -78,15 +78,14 @@ EVENT::Track* ACTS2Marlin_track( std::shared_ptr magneticField, Acts::MagneticFieldProvider::Cache& magCache); */ -EVENT::Track* ACTS2Marlin_track( - const TrackResult& fitter_res, - std::shared_ptr magneticField, - Acts::MagneticFieldProvider::Cache& magCache); EVENT::Track* ACTS2Marlin_track( const TrackResult& fitter_res, std::shared_ptr magneticField, - Acts::MagneticFieldProvider::Cache& magCache, double caloFaceR, double caloFaceZ, Acts::GeometryContext geoContext, Acts::MagneticFieldContext magFieldContext, std::shared_ptr trackingGeo); + Acts::MagneticFieldProvider::Cache& magCache, + double caloFaceR, double caloFaceZ, Acts::GeometryContext geoContext, + Acts::MagneticFieldContext magFieldContext, + std::shared_ptr trackingGeo); //! Convert ACTS track state class to Marlin class /** diff --git a/src/Helpers.cxx b/src/Helpers.cxx index 67b4dd8..cf67272 100644 --- a/src/Helpers.cxx +++ b/src/Helpers.cxx @@ -241,81 +241,6 @@ EVENT::Track* ACTS2Marlin_track( */ -EVENT::Track* ACTS2Marlin_track( - const TrackResult& fitter_res, - std::shared_ptr magneticField, - Acts::MagneticFieldProvider::Cache& magCache) -{ - IMPL::TrackImpl* track = new IMPL::TrackImpl; - - track->setChi2(fitter_res.chi2()); - track->setNdf(fitter_res.nDoF()); - track->setNholes(fitter_res.nHoles()); - - const Acts::Vector3 zeroPos(0, 0, 0); - Acts::Result fieldRes = magneticField->getField(zeroPos, magCache); - if (!fieldRes.ok()) { - throw std::runtime_error("Field lookup error: " + fieldRes.error().value()); - } - Acts::Vector3 field = *fieldRes; - - const Acts::BoundVector& params = fitter_res.parameters(); - const Acts::BoundMatrix& covariance = fitter_res.covariance(); - EVENT::TrackState* trackStateAtIP = ACTSTracking::ACTS2Marlin_trackState( - EVENT::TrackState::AtIP, params, covariance, field[2] / Acts::UnitConstants::T); - track->trackStates().push_back(trackStateAtIP); - - EVENT::TrackerHitVec hitsOnTrack; - EVENT::TrackStateVec statesOnTrack; - - for (const auto& trk_state : fitter_res.trackStatesReversed()) - { - if (!trk_state.hasUncalibratedSourceLink()) continue; - - auto sl = trk_state.getUncalibratedSourceLink() - .get(); - EVENT::TrackerHit* curr_hit = sl.lciohit(); - hitsOnTrack.push_back(curr_hit); - - const Acts::Vector3 hitPos(curr_hit->getPosition()[0], - curr_hit->getPosition()[1], - curr_hit->getPosition()[2]); - - Acts::Result fieldRes = - magneticField->getField(hitPos, magCache); - if (!fieldRes.ok()) { - throw std::runtime_error("Field lookup error: " + - fieldRes.error().value()); - } - Acts::Vector3 field = *fieldRes; - - EVENT::TrackState* trackState = ACTSTracking::ACTS2Marlin_trackState( - EVENT::TrackState::AtOther, trk_state.smoothed(), - trk_state.smoothedCovariance(), field[2] / Acts::UnitConstants::T); - statesOnTrack.push_back(trackState); - } - - std::reverse(hitsOnTrack.begin(), hitsOnTrack.end()); - std::reverse(statesOnTrack.begin(), statesOnTrack.end()); - - for (EVENT::TrackerHit* hit : hitsOnTrack) { - track->addHit(hit); - } - - if (statesOnTrack.size() > 0) { - dynamic_cast(statesOnTrack.back()) - ->setLocation(EVENT::TrackState::AtLastHit); - dynamic_cast(statesOnTrack.front()) - ->setLocation(EVENT::TrackState::AtFirstHit); - } - - EVENT::TrackStateVec& myTrackStates = track->trackStates(); - myTrackStates.insert(myTrackStates.end(), statesOnTrack.begin(), - statesOnTrack.end()); - - return track; -} - // Conversion with extrapolation to calorimeter face EVENT::Track* ACTS2Marlin_track( const TrackResult& fitter_res, @@ -328,6 +253,7 @@ EVENT::Track* ACTS2Marlin_track( track->setChi2(fitter_res.chi2()); track->setNdf(fitter_res.nDoF()); + track->setNholes(fitter_res.nHoles()); const Acts::Vector3 zeroPos(0, 0, 0); Acts::Result fieldRes = magneticField->getField(zeroPos, magCache); @@ -393,7 +319,8 @@ EVENT::Track* ACTS2Marlin_track( double time = params[Acts::eBoundTime]; Acts::Vector3 pos(d0 * cos(phi), d0 * sin(phi), z0); - Acts::CurvilinearTrackParameters start(Acts::VectorHelpers::makeVector4(pos, time), phi, theta, qoverp, covariance, Acts::ParticleHypothesis::pion()); + Acts::CurvilinearTrackParameters start(Acts::VectorHelpers::makeVector4(pos, time), phi, theta, + qoverp, covariance, Acts::ParticleHypothesis::pion()); // Set propagator options Acts::PropagatorOptions myCaloPropOptions(geoContext, magFieldContext); @@ -416,7 +343,8 @@ EVENT::Track* ACTS2Marlin_track( const Acts::BoundMatrix& atCaloCovariance = *(end_parameters->covariance()); EVENT::TrackState* trackStateAtCalo = ACTSTracking::ACTS2Marlin_trackState( - EVENT::TrackState::AtCalorimeter, end_parameters->parameters(), atCaloCovariance, field[2] / Acts::UnitConstants::T); + EVENT::TrackState::AtCalorimeter, end_parameters->parameters(), + atCaloCovariance, field[2] / Acts::UnitConstants::T); track->trackStates().push_back(trackStateAtCalo); } else { @@ -427,7 +355,8 @@ EVENT::Track* ACTS2Marlin_track( const Acts::BoundMatrix& atCaloCovariance = *(end_parametersP->covariance()); EVENT::TrackState* trackStateAtCalo = ACTSTracking::ACTS2Marlin_trackState( - EVENT::TrackState::AtCalorimeter, end_parametersP->parameters(), atCaloCovariance, field[2] / Acts::UnitConstants::T); + EVENT::TrackState::AtCalorimeter, end_parametersP->parameters(), + atCaloCovariance, field[2] / Acts::UnitConstants::T); track->trackStates().push_back(trackStateAtCalo); } else{ @@ -441,7 +370,8 @@ EVENT::Track* ACTS2Marlin_track( const Acts::BoundMatrix& atCaloCovariance = *(end_parametersM->covariance()); EVENT::TrackState* trackStateAtCalo = ACTSTracking::ACTS2Marlin_trackState( - EVENT::TrackState::AtCalorimeter, end_parametersM->parameters(), atCaloCovariance, field[2] / Acts::UnitConstants::T); + EVENT::TrackState::AtCalorimeter, end_parametersM->parameters(), + atCaloCovariance, field[2] / Acts::UnitConstants::T); track->trackStates().push_back(trackStateAtCalo); } else{ @@ -453,8 +383,18 @@ EVENT::Track* ACTS2Marlin_track( std::reverse(hitsOnTrack.begin(), hitsOnTrack.end()); std::reverse(statesOnTrack.begin(), statesOnTrack.end()); + UTIL::CellIDDecoder decoder( + lcio::LCTrackerCellID::encoding_string()); + EVENT::IntVec& subdetectorHitNumbers = track->subdetectorHitNumbers(); + subdetectorHitNumbers.resize(7, 0); for (EVENT::TrackerHit* hit : hitsOnTrack) { track->addHit(hit); + + uint32_t sysid = decoder(hit)["system"]; + if (subdetectorHitNumbers.size() <= sysid) { + subdetectorHitNumbers.resize(sysid + 1, 0); + } + subdetectorHitNumbers[sysid]++; } if (statesOnTrack.size() > 0) {