16#include "Gaudi/Property.h"
32 ISvcLocator* pSvcLocator ) :
63 m_h_density =
new TH1F(
"Density",
"Density", 800, -200.0, 200.0);
65 m_h_truthVertices =
new TH1F(
"TruthVertices",
"TruthVertices", 800, -200.0, 200.0);
66 m_h_modeCheck =
new TH1F(
"ModeOffset",
"ModeOffset", 100, -2.0, 2.0);
73 return StatusCode::SUCCESS;
79 return StatusCode::SUCCESS;
89 std::vector<Trk::ITrackLink*> trackVector;
92 std::vector<const Trk::TrackParameters*> perigeeList;
96 std::unique_ptr<Trk::IVertexTrackDensityEstimator::ITrackDensity> dens;
97 double mode =
m_estimator->globalMaximum (perigeeList, dens);
101 for (
int i = 0; i < 800; i++)
103 double z = -200.0 + 0.25 + i*0.5;
104 double density = dens->trackDensity(
z);
109 std::vector<Amg::Vector3D> truth;
117 return StatusCode::SUCCESS;
125 std::vector<const Trk::TrackParameters*>& perigeeList)
127 for (
auto *seedtrkAtVtxIter : trackVector)
129 perigeeList.push_back( seedtrkAtVtxIter->parameters() );
134 std::vector<Trk::ITrackLink*>& trackVector)
136 bool selectionPassed{
false};
142 for (
auto itr = trackParticles->
begin(); itr != trackParticles->
end(); ++itr) {
148 selectionPassed=
static_cast<bool>(
m_trackFilter->accept(**itr,&beamposition));
156 vertexError.setZero();
158 selectionPassed=
static_cast<bool>(
m_trackFilter->accept(**itr,&null));
166 trackVector.push_back(linkTT);
176 const std::vector<Trk::ITrackLink*>& trackVector,
177 std::vector<Amg::Vector3D>& truth,
179 TH1* h_modeCheck)
const
181 double modeClosestDistance = std::numeric_limits<double>::max();
192 if (vLink ==
nullptr){
193 ATH_MSG_ERROR(
"Invalid truthVertexLink from signalEvents in GaussianDensityTestAlg::findTruth");
194 return StatusCode::FAILURE;
198 for (
auto *trk : trackVector)
203 bool isAssoc = truthParticleAssoc(**(*lxtp)).isValid();
206 const auto& assocParticle = truthParticleAssoc(**(*lxtp));
208 for (
const auto& truthParticle : evt->truthParticleLinks())
210 if (!truthParticle.isValid())
continue;
211 if (assocParticle == truthParticle)
224 h_truthDensity->Fill(vLink->
z());
240 truth.push_back(vTruth);
241 if (abs(modeClosestDistance) > abs(mode - vTruth[2]))
242 modeClosestDistance = mode - vTruth[2];
258 if (vLink ==
nullptr) {
260 return StatusCode::FAILURE;
264 for (
auto *trk : trackVector)
269 bool isAssoc = truthParticleAssoc(**(*lxtp)).isValid();
272 const auto& assocParticle = truthParticleAssoc(**(*lxtp));
274 for (
const auto& truthParticle : evt->truthParticleLinks())
276 if (!truthParticle.isValid())
continue;
277 if (assocParticle == truthParticle)
290 h_truthDensity->Fill(vLink->
z());
306 truth.push_back(vTruth);
307 if (abs(modeClosestDistance) > abs(mode - vTruth[2]))
308 modeClosestDistance = mode - vTruth[2];
317 h_modeCheck->Fill( modeClosestDistance );
318 return StatusCode::SUCCESS;
325 v.makePrivateStore();
328 v.setFitQuality(0., 0.);
330 double significance = 0.0;
331 std::unique_ptr<ImpactParametersAndSigma> ipas =
m_ipEstimator->estimate( params, &
v );
332 if ( ipas !=
nullptr )
334 if ( ipas->sigmad0 > 0 && ipas->sigmaz0 > 0)
336 significance = sqrt(
pow(ipas->IPd0/ipas->sigmad0,2) +
pow(ipas->IPz0/ipas->sigmaz0,2) );
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define CHECK(...)
Evaluate an expression and check for errors.
#define AmgSymMatrix(dim)
constexpr int pow(int base, int exp) noexcept
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
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.
ElementLink implementation for ROOT usage.
bool setElement(ElementType element)
Set to point to an element.
bool setStorableObject(BaseConstReference data, bool replace=false, IProxyDict *sg=0)
Set link to point to a new container (storable).
const Trk::RecVertex & beamVtx() const noexcept
void makePrivateStore()
Create a new (empty) private store for this object.
SG::ConstAccessor< T, ALLOC > ConstAccessor
Helper class to provide type-safe access to aux data.
const_pointer_type retrieve()
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
virtual StatusCode finalize()
TH1 * m_h_density
Histograms and trees.
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trackParticlesKey
Data handle keys.
ToolHandle< Trk::IVertexTrackDensityEstimator > m_estimator
virtual ~GaussianDensityTestAlg()
Destructor:
StatusCode findTruth(double mode, const std::vector< Trk::ITrackLink * > &trackVector, std::vector< Amg::Vector3D > &truth, TH1 *h_truthDensity, TH1 *h_modeCheck) const
ToolHandle< InDet::IInDetTrackSelectionTool > m_trackFilter
virtual StatusCode execute()
SG::ReadHandleKey< xAOD::TruthPileupEventContainer > m_pileupEventsKey
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamSpotKey
ToolHandle< Trk::ITrackToVertexIPEstimator > m_ipEstimator
Gaudi::Property< int > m_truthVertexTracks
void selectTracks(const xAOD::TrackParticleContainer *trackParticles, std::vector< Trk::ITrackLink * > &trackVector)
SG::ReadHandleKey< xAOD::TruthEventContainer > m_truthEventsKey
virtual StatusCode initialize()
static void analyzeTracks(const std::vector< Trk::ITrackLink * > &trackVector, std::vector< const Trk::TrackParameters * > &perigeeList)
ServiceHandle< ITHistSvc > m_iTHistSvc
Gaudi::Property< double > m_significanceTruthCut
double ipSignificance(const Trk::TrackParameters *params, const Amg::Vector3D *vertex) const
Element link to XAOD TrackParticle.
const Amg::Vector3D & position() const
return position of vertex
float z() const
Vertex longitudinal distance along the beam line form the origin.
float y() const
Vertex y displacement.
float x() const
Vertex x displacement.
void setCovariancePosition(const AmgSymMatrix(3)&covariancePosition)
Sets the vertex covariance matrix.
void setPosition(const Amg::Vector3D &position)
Sets the 3-position.
Eigen::Matrix< double, 3, 1 > Vector3D
Ensure that the ATLAS eigen extensions are properly loaded.
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
@ z
global position (cartesian)
ParametersBase< TrackParametersDim, Charged > TrackParameters
TruthEventBase_v1 TruthEventBase
Typedef to implementation.
TruthVertex_v1 TruthVertex
Typedef to implementation.
Vertex_v1 Vertex
Define the latest version of the vertex class.
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".