Commit b10b4b6b authored by Whitney Armstrong's avatar Whitney Armstrong
Browse files

modified: .clang-format

	modified:   JugDigi/src/components/UFSDTrackerDigi.cpp
	modified:   JugReco/JugReco/BField.h
	modified:   JugReco/src/components/ParticlesFromTrackFit.cpp
	modified:   JugReco/src/components/TrackFindingAlgorithm.cpp
	modified:   JugReco/src/components/TrackParamTruthInit.cpp
parent 1fa97315
......@@ -24,7 +24,7 @@ BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
......@@ -37,7 +37,7 @@ BraceWrapping:
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
......@@ -90,10 +90,6 @@ PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
RawStringFormats:
- Delimiter: pb
Language: TextProto
BasedOnStyle: google
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
......
......@@ -10,8 +10,11 @@
// Event Model related classes
//#include "GaudiExamples/MyTrack.h"
#include "eicd/RawTrackerHitCollection.h"
//
// dd4pod's tracker hit is the input collectiopn
#include "dd4pod/TrackerHitCollection.h"
// eicd's RawTrackerHit is the output
#include "eicd/RawTrackerHitCollection.h"
namespace Jug {
namespace Digi {
......@@ -21,6 +24,12 @@ namespace Jug {
*
*/
class UFSDTrackerDigi : public GaudiAlgorithm {
public:
Gaudi::Property<double> m_timeResolution{this, "timeResolution", 10};
Rndm::Numbers m_gaussDist;
DataHandle<dd4pod::TrackerHitCollection> m_inputHitCollection{"inputHitCollection", Gaudi::DataHandle::Reader, this};
DataHandle<eic::RawTrackerHitCollection> m_outputHitCollection{"outputHitCollection", Gaudi::DataHandle::Writer, this};
public:
// ill-formed: using GaudiAlgorithm::GaudiAlgorithm;
UFSDTrackerDigi(const std::string& name, ISvcLocator* svcLoc)
......@@ -43,7 +52,7 @@ namespace Jug {
const dd4pod::TrackerHitCollection* simhits = m_inputHitCollection.get();
// Create output collections
auto rawhits = m_outputHitCollection.createAndPut();
eic::RawTrackerHitCollection* rawHitCollection = new eic::RawTrackerHitCollection();
//eic::RawTrackerHitCollection* rawHitCollection = new eic::RawTrackerHitCollection();
std::map<long long,int> cell_hit_map;
for(const auto& ahit : *simhits) {
//std::cout << ahit << "\n";
......@@ -61,10 +70,6 @@ namespace Jug {
return StatusCode::SUCCESS;
}
Gaudi::Property<double> m_timeResolution{this, "timeResolution", 10};
Rndm::Numbers m_gaussDist;
DataHandle<dd4pod::TrackerHitCollection> m_inputHitCollection{"inputHitCollection", Gaudi::DataHandle::Reader, this};
DataHandle<eic::RawTrackerHitCollection> m_outputHitCollection{"outputHitCollection", Gaudi::DataHandle::Writer, this};
};
DECLARE_COMPONENT(UFSDTrackerDigi)
......
......@@ -10,6 +10,7 @@
#include "Acts/MagneticField/MagneticFieldContext.hpp"
#include "Acts/Utilities/Definitions.hpp"
// Forward declarations
namespace Acts {
template <typename G>
......
......@@ -60,13 +60,18 @@ namespace Jug {
debug() << "# fitted parameters : " << tsize << endmsg;
if(tsize == 0 ) continue;
traj.trajectory().second.visitBackwards(tsize-1, [&](auto&& trackstate) {
debug() << trackstate.hasPredicted() << endmsg;
debug() << trackstate.predicted() << endmsg;
//debug() << trackstate.hasPredicted() << endmsg;
//debug() << trackstate.predicted() << endmsg;
auto params = trackstate.predicted() ;//<< endmsg;
debug() << 1.0/params[Acts::eQOP] << " GeV" << endmsg;
if ( std::abs(1.0 / params[Acts::eQOP]) > 10) {
debug() << "skipping" << endmsg;
return;
}
eic::Particle p( {params[Acts::ePHI],params[Acts::eTHETA],1.0/params[Acts::eQOP],0.105}, {0.0,0.0,0.0,params[Acts::eT]},
(long long)13*params[Acts::eQOP]/std::abs(params[Acts::eQOP]), 0);
eic::Particle p({params[Acts::ePHI], params[Acts::eTHETA], 1.0 / params[Acts::eQOP], 0.105},
{0.0, 0.0, 0.0, params[Acts::eT]},
(long long)13 * params[Acts::eQOP] / std::abs(params[Acts::eQOP]), 0);
debug() << p << endmsg;
rec_parts->push_back(p);
});
......
//
#include "TrackFindingAlgorithm.h"
#include "JugReco/GeometryContainers.hpp"
// Gaudi
......@@ -53,124 +54,87 @@
#include <stdexcept>
namespace Jug::Reco {
using namespace Acts::UnitLiterals;
class TrackFindingAlgorithm : public GaudiAlgorithm {
public:
using TrackFinderResult = Acts::Result<Acts::CombinatorialKalmanFilterResult<SourceLink>>;
/// Track finding function that takes input measurements, initial trackstate
/// and track finder options and returns some track-finding-specific result.
using CKFOptions = Acts::CombinatorialKalmanFilterOptions<Acts::CKFSourceLinkSelector>;
using TrackFinderFunction =
std::function<TrackFinderResult(const SourceLinkContainer&, const TrackParameters&, const CKFOptions&)>;
public:
DataHandle<SourceLinkContainer> m_inputSourceLinks{"inputSourceLinks", Gaudi::DataHandle::Reader, this};
DataHandle<TrackParametersContainer> m_inputInitialTrackParameters{"inputInitialTrackParameters", Gaudi::DataHandle::Reader, this};
DataHandle<TrajectoryContainer> m_outputTrajectories{"outputTrajectories", Gaudi::DataHandle::Writer, this};
TrackFinderFunction m_trackFinderFunc;
SmartIF<IGeoSvc> m_geoSvc;
std::shared_ptr<Acts::ConstantBField> m_BField = nullptr;
Acts::GeometryContext m_geoctx;
Acts::CalibrationContext m_calibctx;
Acts::MagneticFieldContext m_fieldctx;
using namespace Acts::UnitLiterals;
Acts::CKFSourceLinkSelector::Config m_sourcelinkSelectorCfg;
TrackFindingAlgorithm::TrackFindingAlgorithm(const std::string& name, ISvcLocator* svcLoc) : GaudiAlgorithm(name, svcLoc) {
declareProperty("inputSourceLinks", m_inputSourceLinks, "");
declareProperty("inputInitialTrackParameters", m_inputInitialTrackParameters, "");
declareProperty("outputTrajectories", m_outputTrajectories, "");
}
TrackFindingAlgorithm(const std::string& name, ISvcLocator* svcLoc) : GaudiAlgorithm(name, svcLoc) {
declareProperty("inputSourceLinks", m_inputSourceLinks, "");
declareProperty("inputInitialTrackParameters", m_inputInitialTrackParameters, "");
declareProperty("outputTrajectories", m_outputTrajectories, "");
StatusCode TrackFindingAlgorithm::initialize() {
if (GaudiAlgorithm::initialize().isFailure())
return StatusCode::FAILURE;
m_geoSvc = service("GeoSvc");
if (!m_geoSvc) {
error() << "Unable to locate Geometry Service. "
<< "Make sure you have GeoSvc and SimSvc in the right order in the configuration." << endmsg;
return StatusCode::FAILURE;
}
m_BField = std::make_shared<Acts::ConstantBField>(Acts::Vector3D{0.0, 0.0, 1.0_T});
m_fieldctx = BFieldVariant(m_BField);
m_sourcelinkSelectorCfg = {
{Acts::GeometryID(), {15, 10}},
};
/** Create the track finder function implementation.
* The magnetic field is intentionally given by-value since the variant
* contains shared_ptr anyways.
*/
static TrackFinderFunction makeTrackFinderFunction(std::shared_ptr<const Acts::TrackingGeometry> trackingGeometry,
BFieldVariant magneticField);
/// Type erased track finder function.
TrackFinderFunction findTracks;
StatusCode initialize() override {
if (GaudiAlgorithm::initialize().isFailure())
return StatusCode::FAILURE;
m_geoSvc = service("GeoSvc");
if (!m_geoSvc) {
error() << "Unable to locate Geometry Service. "
<< "Make sure you have GeoSvc and SimSvc in the right order in the configuration." << endmsg;
return StatusCode::FAILURE;
}
m_BField = std::make_shared<Acts::ConstantBField>(Acts::Vector3D{0.0, 0.0, 1.0_T});
m_fieldctx = BFieldVariant(m_BField);
m_sourcelinkSelectorCfg = {{Acts::GeometryID(), {15, 10}},};
findTracks = TrackFindingAlgorithm::makeTrackFinderFunction(m_geoSvc->trackingGeometry(), m_BField);
// IRndmGenSvc* randSvc = svc<IRndmGenSvc>("RndmGenSvc", true);
// StatusCode sc = m_gaussDist.initialize(randSvc, Rndm::Gauss(0.0, m_timeResolution.value()));
// if (!sc.isSuccess()) {
// return StatusCode::FAILURE;
//}
return StatusCode::SUCCESS;
}
findTracks = TrackFindingAlgorithm::makeTrackFinderFunction(m_geoSvc->trackingGeometry(), m_BField);
// IRndmGenSvc* randSvc = svc<IRndmGenSvc>("RndmGenSvc", true);
// StatusCode sc = m_gaussDist.initialize(randSvc, Rndm::Gauss(0.0, m_timeResolution.value()));
// if (!sc.isSuccess()) {
// return StatusCode::FAILURE;
//}
return StatusCode::SUCCESS;
}
StatusCode execute() override {
// Read input data
const SourceLinkContainer* src_links = m_inputSourceLinks.get();
const TrackParametersContainer* init_trk_params = m_inputInitialTrackParameters.get();
//const auto sourceLinks = ctx.eventStore.get<SourceLinkContainer>(m_cfg.inputSourceLinks);
//const auto initialParameters = ctx.eventStore.get<TrackParametersContainer>(m_cfg.inputInitialTrackParameters);
//// Prepare the output data with MultiTrajectory
//TrajectoryContainer trajectories;
auto trajectories = m_outputTrajectories.createAndPut();
trajectories->reserve(init_trk_params->size());
//// Construct a perigee surface as the target surface
auto pSurface = Acts::Surface::makeShared<Acts::PerigeeSurface>(Acts::Vector3D{0., 0., 0.});
ACTS_LOCAL_LOGGER(Acts::getDefaultLogger("TrackFindingAlgorithm Logger", Acts::Logging::INFO));
// Perform the track finding for each starting parameter
// @TODO: use seeds from track seeding algorithm as starting parameter
for (std::size_t iseed = 0; iseed < init_trk_params->size(); ++iseed) {
const auto& initialParams = (*init_trk_params)[iseed];
// Set the CombinatorialKalmanFilter options
TrackFindingAlgorithm::CKFOptions ckfOptions( m_geoctx, m_fieldctx, m_calibctx,
m_sourcelinkSelectorCfg, Acts::LoggerWrapper{logger()},
&(*pSurface));
//TrackFindingAlgorithm::CKFOptions ckfOptions(ctx.geoContext, ctx.magFieldContext, ctx.calibContext,
// m_cfg.sourcelinkSelectorCfg, Acts::LoggerWrapper{logger()},
// &(*pSurface));
debug() << "Invoke track finding seeded by truth particle " << iseed << endmsg;
auto result = findTracks(*src_links, initialParams, ckfOptions);
if (result.ok()) {
// Get the track finding output object
const auto& trackFindingOutput = result.value();
// Create a SimMultiTrajectory
trajectories->emplace_back(std::move(trackFindingOutput.fittedStates),
std::move(trackFindingOutput.trackTips),
std::move(trackFindingOutput.fittedParameters));
} else {
ACTS_WARNING("Track finding failed for truth seed " << iseed << " with error" << result.error());
// Track finding failed, but still create an empty SimMultiTrajectory
trajectories->push_back(SimMultiTrajectory());
}
StatusCode TrackFindingAlgorithm::execute() {
// Read input data
const SourceLinkContainer* src_links = m_inputSourceLinks.get();
const TrackParametersContainer* init_trk_params = m_inputInitialTrackParameters.get();
// const auto sourceLinks = ctx.eventStore.get<SourceLinkContainer>(m_cfg.inputSourceLinks);
// const auto initialParameters = ctx.eventStore.get<TrackParametersContainer>(m_cfg.inputInitialTrackParameters);
//// Prepare the output data with MultiTrajectory
// TrajectoryContainer trajectories;
auto trajectories = m_outputTrajectories.createAndPut();
trajectories->reserve(init_trk_params->size());
//// Construct a perigee surface as the target surface
auto pSurface = Acts::Surface::makeShared<Acts::PerigeeSurface>(Acts::Vector3D{0., 0., 0.});
ACTS_LOCAL_LOGGER(Acts::getDefaultLogger("TrackFindingAlgorithm Logger", Acts::Logging::INFO));
// Perform the track finding for each starting parameter
// @TODO: use seeds from track seeding algorithm as starting parameter
for (std::size_t iseed = 0; iseed < init_trk_params->size(); ++iseed) {
const auto& initialParams = (*init_trk_params)[iseed];
// Set the CombinatorialKalmanFilter options
TrackFindingAlgorithm::CKFOptions ckfOptions(m_geoctx, m_fieldctx, m_calibctx, m_sourcelinkSelectorCfg,
Acts::LoggerWrapper{logger()}, &(*pSurface));
// TrackFindingAlgorithm::CKFOptions ckfOptions(ctx.geoContext, ctx.magFieldContext, ctx.calibContext,
// m_cfg.sourcelinkSelectorCfg, Acts::LoggerWrapper{logger()},
// &(*pSurface));
debug() << "Invoke track finding seeded by truth particle " << iseed << endmsg;
auto result = findTracks(*src_links, initialParams, ckfOptions);
if (result.ok()) {
// Get the track finding output object
const auto& trackFindingOutput = result.value();
// Create a SimMultiTrajectory
trajectories->emplace_back(std::move(trackFindingOutput.fittedStates), std::move(trackFindingOutput.trackTips),
std::move(trackFindingOutput.fittedParameters));
} else {
ACTS_WARNING("Track finding failed for truth seed " << iseed << " with error" << result.error());
// Track finding failed, but still create an empty SimMultiTrajectory
trajectories->push_back(SimMultiTrajectory());
}
//ctx.eventStore.add(m_cfg.outputTrajectories, std::move(trajectories));
return StatusCode::SUCCESS;
}
};
// ctx.eventStore.add(m_cfg.outputTrajectories, std::move(trajectories));
return StatusCode::SUCCESS;
}
DECLARE_COMPONENT(TrackFindingAlgorithm)
} // namespace Jug::Reco
......@@ -194,7 +158,8 @@ namespace Jug::Reco {
TrackFindingAlgorithm::TrackFinderFunction
TrackFindingAlgorithm::makeTrackFinderFunction(std::shared_ptr<const Acts::TrackingGeometry> trackingGeometry,
BFieldVariant magneticField) {
BFieldVariant magneticField)
{
using Updater = Acts::GainMatrixUpdater;
using Smoother = Acts::GainMatrixSmoother;
......
......@@ -61,13 +61,13 @@ namespace Jug::Reco {
cov(Acts::eLOC_1, Acts::eLOC_1) = 0.1 * mm*0.1 * mm;
cov(Acts::ePHI, Acts::ePHI) = M_PI / 180.0;
cov(Acts::eTHETA, Acts::eTHETA) = M_PI / 180.0;
cov(Acts::eQOP, Acts::eQOP) = 1.0 / (0.2 * GeV* 0.2 * GeV);
cov(Acts::eQOP, Acts::eQOP) = 1.0 / (0.3 * GeV* 0.3 * GeV);
cov(Acts::eT, Acts::eT) = Acts::UnitConstants::ns;
init_trk_params->emplace_back(std::make_optional(std::move(cov)),
Acts::Vector3D(part.vsx() * mm, part.vsy() * mm, part.vsz() * mm),
Acts::Vector3D(part.psx() * GeV, part.psy() * GeV, part.psz() * GeV),
((part.pdgID() > 0) ? 1 : -1), part.time() * Acts::UnitConstants::ns);
((part.pdgID() > 0) ? -1 : 1), part.time() * Acts::UnitConstants::ns);
//part .charge()
debug() << "Invoke track finding seeded by truth particle " << part << endmsg;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment