Skip to content

Commit

Permalink
Extrapolation to calo for all ACTS processors
Browse files Browse the repository at this point in the history
  • Loading branch information
pandreetto committed Jul 12, 2024
1 parent c197992 commit ef7df42
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 110 deletions.
4 changes: 4 additions & 0 deletions ACTSTracking/ACTSTruthCKFTrackingProc.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ class ACTSTruthCKFTrackingProc : public ACTSProcBase {
uint32_t _eventNumber;
uint32_t _runNumber;

// Extrapolation to calo settings
float _caloFaceR = 1857; //mm
float _caloFaceZ = 2307; //mm

// Track fit parameters
double _initialTrackError_d0 = 20 * Acts::UnitConstants::um; // Marlin: 1.e3
double _initialTrackError_phi =
Expand Down
4 changes: 4 additions & 0 deletions ACTSTracking/ACTSTruthTrackingProc.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ class ACTSTruthTrackingProc : public ACTSProcBase {
uint32_t _eventNumber;
uint32_t _runNumber;

// Extrapolation to calo settings
float _caloFaceR = 1857; //mm
float _caloFaceZ = 2307; //mm

// Track fit parameters
double _initialTrackError_d0 = 20 * Acts::UnitConstants::um; // Marlin: 1.e3
double _initialTrackError_phi =
Expand Down
74 changes: 11 additions & 63 deletions src/ACTSTruthCKFTrackingProc.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ ACTSTruthCKFTrackingProc::ACTSTruthCKFTrackingProc()
registerOutputCollection(LCIO::TRACK, "TrackCollectionName",
"Name of track output collection.",
_outputTrackCollection, std::string("TruthTracks"));

// Extrapolation to calo surface
registerProcessorParameter("CaloFace_Radius",
"ECAL Inner Radius (mm).",
_caloFaceR, _caloFaceR);

registerProcessorParameter("CaloFace_Z",
"ECAL half length (mm).",
_caloFaceZ, _caloFaceZ);
}

void ACTSTruthCKFTrackingProc::init() {
Expand Down Expand Up @@ -317,7 +326,8 @@ void ACTSTruthCKFTrackingProc::processEvent(LCEvent* evt) {
{
std::cout << trackTip.chi2() << std::endl;
EVENT::Track* track = ACTSTracking::ACTS2Marlin_track(
trackTip, magneticField(), magCache);
trackTip, magneticField(), magCache,
_caloFaceR, _caloFaceZ, geometryContext(), magneticFieldContext(), trackingGeometry());
trackCollection->addElement(track);
}
} else {
Expand All @@ -326,68 +336,6 @@ void ACTSTruthCKFTrackingProc::processEvent(LCEvent* evt) {
}

}
/*
auto t1 = std::chrono::high_resolution_clock::now();
TrackFinderResultContainer results =
trackFinder.findTracks(sourceLinks, seeds, ckfOptions);
auto t2 = std::chrono::high_resolution_clock::now();
std::cout
<< "Tracking finding: "
<< std::chrono::duration_cast<std::chrono::milliseconds>(t2 - t1).count()
<< " ms" << std::endl;
for (TrackFinderResult& result : results) {
if (result.ok()) {
const Acts::CombinatorialKalmanFilterResult<ACTSTracking::SourceLink>&
fitOutput = result.value();
for (const size_t& trackTip : fitOutput.lastMeasurementIndices) {
if (fitOutput.fittedParameters.count(trackTip) == 0) {
streamlog_out(WARNING)
<< "No fitted track parameters for trajectory with entry index = "
<< trackTip << std::endl;
continue;
}
//
// Helpful debug output
Acts::MultiTrajectoryHelpers::TrajectoryState trajState =
Acts::MultiTrajectoryHelpers::trajectoryState(
fitOutput.fittedStates, trackTip);
streamlog_out(DEBUG) << "Trajectory Summary" << std::endl;
streamlog_out(DEBUG)
<< "\tchi2Sum " << trajState.chi2Sum << std::endl;
streamlog_out(DEBUG)
<< "\tNDF " << trajState.NDF << std::endl;
streamlog_out(DEBUG)
<< "\tnHoles " << trajState.nHoles << std::endl;
streamlog_out(DEBUG)
<< "\tnMeasurements " << trajState.nMeasurements << std::endl;
streamlog_out(DEBUG)
<< "\tnOutliers " << trajState.nOutliers << std::endl;
streamlog_out(DEBUG)
<< "\tnStates " << trajState.nStates << std::endl;
const Acts::BoundTrackParameters& params =
fitOutput.fittedParameters.at(trackTip);
streamlog_out(DEBUG) << "Fitted Paramemeters" << std::endl
<< params << std::endl;
//
// Make track object
EVENT::Track* track = ACTSTracking::ACTS2Marlin_track(
fitOutput, trackTip, magneticField(), magCache);
//
// Save results
trackCollection->addElement(track);
}
} else {
streamlog_out(WARNING)
<< "Track fit error: " << result.error() << std::endl;
_fitFails++;
}
}
*/

// Save the output track collection
evt->addCollection(trackCollection, _outputTrackCollection);
Expand Down
58 changes: 11 additions & 47 deletions src/ACTSTruthTrackingProc.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ ACTSTruthTrackingProc::ACTSTruthTrackingProc()
registerOutputCollection(LCIO::TRACK, "TrackCollectionName",
"Name of track output collection.",
_outputTrackCollection, std::string("TruthTracks"));

// Extrapolation to calo surface
registerProcessorParameter("CaloFace_Radius",
"ECAL Inner Radius (mm).",
_caloFaceR, _caloFaceR);

registerProcessorParameter("CaloFace_Z",
"ECAL half length (mm).",
_caloFaceZ, _caloFaceZ);
}

void ACTSTruthTrackingProc::init() {
Expand Down Expand Up @@ -339,57 +348,12 @@ void ACTSTruthTrackingProc::processEvent(LCEvent* evt) {

if (result.ok()) {
const auto& fitOutput = result.value();
/*
if (fitOutput.fittedParameters) {
// Make the track object and relations object
IMPL::LCRelationImpl* relationTrack = new IMPL::LCRelationImpl;
//
// Helpful debug output
Acts::MultiTrajectoryHelpers::TrajectoryState trajState =
Acts::MultiTrajectoryHelpers::trajectoryState(
fitOutput.fittedStates, fitOutput.lastMeasurementIndex);
streamlog_out(DEBUG) << "Trajectory Summary" << std::endl;
streamlog_out(DEBUG)
<< "\tchi2Sum " << trajState.chi2Sum << std::endl;
streamlog_out(DEBUG)
<< "\tNDF " << trajState.NDF << std::endl;
streamlog_out(DEBUG)
<< "\tnHoles " << trajState.nHoles << std::endl;
streamlog_out(DEBUG)
<< "\tnMeasurements " << trajState.nMeasurements << std::endl;
streamlog_out(DEBUG)
<< "\tnOutliers " << trajState.nOutliers << std::endl;
streamlog_out(DEBUG)
<< "\tnStates " << trajState.nStates << std::endl;
const Acts::BoundTrackParameters& params =
fitOutput.fittedParameters.value();
streamlog_out(DEBUG) << "Fitted Paramemeters" << std::endl
<< params << std::endl;
// Make track object
EVENT::Track* track = ACTSTracking::ACTS2Marlin_track(
fitOutput, magneticField(), magCache);

// Save results
trackCollection->addElement(track);
// Make the particle to track link
relationTrack->setFrom(track);
relationTrack->setTo(mcParticle);
relationTrack->setWeight(1.0);
trackRelationCollection->addElement(relationTrack);
} else {
streamlog_out(WARNING)
<< "No fitted paramemeters for track" << std::endl;
_fitFails++;
}
*/
if (fitOutput.hasReferenceSurface())
{
EVENT::Track* track = ACTSTracking::ACTS2Marlin_track(
fitOutput, magneticField(), magCache);
fitOutput, magneticField(), magCache,
_caloFaceR, _caloFaceZ, geometryContext(), magneticFieldContext(), trackingGeometry());
trackCollection->addElement(track);

IMPL::LCRelationImpl* relationTrack = new IMPL::LCRelationImpl;
Expand Down

0 comments on commit ef7df42

Please sign in to comment.