40 DisableTool{ !m_convertAODTrackParticles }));
67 return StatusCode::SUCCESS;
90 return StatusCode::FAILURE;
102 return StatusCode::SUCCESS;
104 tracks = rh_tracks.
cptr();
115 <<
m_aodTruth.key() <<
" found. Do nothing.");
116 return StatusCode::SUCCESS;
118 aodTruth = rh_aodTruth.
cptr();
122 if (!rh_trackTruth.
isValid()) {
125 return StatusCode::SUCCESS;
127 trackTruth = rh_trackTruth.
cptr();
132 if (!rh_truthParticleLinkVec.
isValid()) {
135 return StatusCode::SUCCESS;
137 truthLinks = rh_truthParticleLinkVec.
cptr();
143 if (!vtx_container.
isValid()) {
145 return StatusCode::SUCCESS;
148 for(
auto vtx : *vtx_container) {
162 ATH_MSG_INFO(
"No primary vertex found, will use dummy vertex at "
163 << dummyVertex->
x() <<
"," << dummyVertex->
y() <<
","
164 << dummyVertex->
z());
165 primaryVertex = dummyVertex;
169 ATH_MSG_WARNING(
"Neither primary nor dummy vertex found. Do Nothing.");
170 return StatusCode::SUCCESS;
178 wh_xaodout.
record(std::make_unique<xAOD::TrackParticleContainer>(),
179 std::make_unique<xAOD::TrackParticleAuxContainer>()));
186 return StatusCode::FAILURE;
189 tracksMap = rh_tracksMap.
cptr();
194 truthLinks, primaryVertex, tracksMap);
197 truthLinks, primaryVertex);
207 std::make_unique<xAOD::TrackParticleContainer>(),
208 std::make_unique<xAOD::TrackParticleAuxContainer>()));
210 wh_xaodTrackParticlesout, truthLinks);
216 return StatusCode::SUCCESS;
219template<
typename CONT>
230 return track_particle->
track();
242 if (cont_src.
size() != cont_dest->
size()) {
243 std::stringstream message;
244 message << __FILE__ <<
":" << __LINE__
245 <<
" Expected one-to-one conversion from AOD to xAOD "
246 "TrackParticles but sizes differ: "
247 << cont_src.size() <<
" != " << cont_dest->size();
248 throw std::runtime_error(message.str());
253 unsigned int idx)
const
262template<
typename CONT,
typename TRUTHCONT,
typename CONVTOOL>
265 const EventContext& ctx,
266 const CONT& container,
267 const TRUTHCONT& truth,
281 if (conv_tool->convertAndAugment(ctx, &container, xaod.
ptr(), obs_track_map, primaryVertex).isFailure()) {
283 << xaod.
name() <<
") with the converting tool");
288 if (conv_tool->convert(ctx, &container, xaod.
ptr(), primaryVertex).isFailure()) {
290 << xaod.
name() <<
") with the converting tool");
299 unsigned int trackCounter(0);
301 for (; itr_xaod != end_xaod; ++itr_xaod) {
318 int npix, nsct, ntrt, npixh, nscth, npixshim, npixsplit;
319 npix = nsct = ntrt = npixh = nscth = npixshim = npixsplit = -1;
331 msg() << MSG::DEBUG <<
"REGTEST: " << std::setw(5) << trackCounter
332 <<
" pT: " << std::setw(10) << particle->pt()
333 <<
" eta: " << particle->eta()
334 <<
" phi: " << particle->phi()
335 <<
" d0: " << particle->d0()
336 <<
" z0: " << particle->z0()
337 <<
"\t" << npix <<
"/" << nsct <<
"/" << ntrt <<
"/holes/" << npixh <<
"/" << nscth
347 unsigned int classification = 0;
348 float probability = -1.0;
352 association_to_src(*itr_xaod, itr_xaod - xaod->begin()), container);
354 ATH_MSG_WARNING(
"Failed to create ElementLink to Track/TrackParticle");
355 }
else if(truth->empty()){
359 auto result = truth->find(tpLink);
360 if (result == truth->end()) {
362 "Failed find truth associated with Track/TrackParticle");
367 << result->second.particleLink().eventIndex());
368 probability = result->second.probability();
369 link = truthLinkVec->
find(result->second.particleLink());
370 if (link.isValid()) {
373 <<
" eta " << (*link)->eta() <<
" phi "
376 if (result->second.particleLink().cptr() &&
379 result->second.particleLink());
380 type = truthClass.first;
381 origin = truthClass.second;
385 <<
static_cast<int>(origin)
386 <<
" classification "
387 <<
static_cast<unsigned int>(classification));
392 << result->second.particleLink());
399 static const SG::AuxElement::Accessor<
401 theLink(
"truthParticleLink");
402 static const SG::AuxElement::Accessor<float> theProbability(
403 "truthMatchProbability");
404 theLink(*particle) = link;
405 theProbability(*particle) = probability;
407 static const SG::AuxElement::Accessor<int> theType(
"truthType");
408 static const SG::AuxElement::Accessor<int> theOrigin(
"truthOrigin");
409 static const SG::AuxElement::Accessor<unsigned int> theClassification(
"truthClassification");
410 theType(*particle) =
static_cast<int>(
type);
411 theOrigin(*particle) =
static_cast<int>(origin);
412 theClassification(*particle) =
static_cast<unsigned int>(classification);
417 ATH_MSG_DEBUG(
"Converted [" << container.size() <<
" -> " << xaod->size()
418 <<
"] TrackParticles and stored in "
420 if (container.size() != xaod->size()) {
423 <<
" is not equal to the number of items in its converted "
436 const EventContext& ctx)
448 const EventContext& ctx)
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
Helpers for checking error return status codes and reporting errors.
Header file to be included by clients of the Monitored infrastructure.
std::map< int, std::tuple< Trk::Track *, double, xAOD::RejectionStep, xAOD::RejectionReason, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, float, float, int, std::vector< xAOD::RejectionStep >, std::vector< xAOD::RejectionReason > > > ObservedTrackMap
DataVector< Trk::Track > TrackCollection
This typedef represents a collection of Trk::Track objects.
bool msgLvl(const MSG::Level lvl) const
An algorithm that can be simultaneously executed in multiple threads.
DataModel_detail::iterator< DataVector > iterator
size_type size() const noexcept
Returns the number of elements in the collection.
ElementLink implementation for ROOT usage.
bool isValid() const
Check if the element can be found.
Group of local monitoring quantities and retain correlation when filling histograms
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
const std::string & name() const
Return the StoreGate ID for the referenced object.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
A summary of the information contained by a track.
const Trk::TrackSummary * trackSummary() const
Returns a pointer to the const Trk::TrackSummary owned by this const track (could be nullptr).
AssociationHelper(const Rec::TrackParticleContainer &cont_src, xAOD::TrackParticleContainer *cont_dest)
const Rec::TrackParticle * operator()(xAOD::TrackParticle *, unsigned int idx) const
const Rec::TrackParticleContainer * m_contSrc
AssociationHelper(const TrackCollection &, xAOD::TrackParticleContainer *)
const Trk::Track * operator()(xAOD::TrackParticle *track_particle, unsigned int) const
ToolHandle< xAODMaker::IRecTrackParticleContainerCnvTool > m_RecTrackParticleContainerCnvTool
Gaudi::Property< bool > m_convertAODTrackParticles
toggle on converting AOD track particles to xAOD
SG::ReadHandleKey< xAODTruthParticleLinkVector > m_truthParticleLinkVec
ToolHandle< GenericMonitoringTool > m_monTool
ToolHandle< ITrackParticleMonitoring > m_trackMonitoringTool
ToolHandle< xAODMaker::ITrackCollectionCnvTool > m_TrackCollectionCnvTool
virtual StatusCode initialize()
Function initialising the algorithm.
Gaudi::Property< bool > m_addTruthLink
toggle on adding truth links
SG::ReadHandleKey< Rec::TrackParticleContainer > m_aod
virtual StatusCode execute(const EventContext &ctx) const
Function executing the algorithm.
SG::ReadHandleKey< TrackParticleTruthCollection > m_aodTruth
SG::ReadHandleKey< TrackTruthCollection > m_trackTruth
SG::WriteHandleKey< xAOD::TrackParticleContainer > m_xaodTrackParticlesout
int convert(const EventContext &ctx, const CONT &, const TRUTHCONT &, CONVTOOL &tool, SG::WriteHandle< xAOD::TrackParticleContainer > &, const xAODTruthParticleLinkVector *, const xAOD::Vertex *primaryVertex=nullptr, const ObservedTrackMap *obs_track_map=0) const
SG::ReadHandleKey< ObservedTrackMap > m_tracksMap
TrackParticleCnvAlg(const std::string &name, ISvcLocator *svcLoc)
Regular algorithm constructor.
SG::WriteHandleKey< xAOD::TrackParticleContainer > m_xaodout
Gaudi::Property< bool > m_augmentObservedTracks
SG::ReadHandleKey< TrackCollection > m_tracks
SG::ReadHandleKey< xAOD::VertexContainer > m_primaryVertexContainer
xAOD::TrackParticle * createParticle(xAOD::TrackParticleContainer &xaod, const Rec::TrackParticleContainer &container, const Rec::TrackParticle &tp, const EventContext &ctx)
Gaudi::Property< bool > m_convertTracks
toggle on converting tracks to xAOD
ToolHandle< IMCTruthClassifier > m_truthClassifier
ToolHandle to truth classifier.
Gaudi::Property< bool > m_doMonitoring
ToolHandle< Trk::ITrackParticleCreatorTool > m_particleCreator
The key for the input TrackParticleTruthCollection.
ElementLink< xAOD::TruthParticleContainer > find(const HepMcParticleLink &hepMCLink) const
const Trk::Track * track() const
Returns a pointer (which can be NULL) to the Trk::Track which was used to make this TrackParticle.
float z() const
Returns the z position.
float y() const
Returns the y position.
float x() const
Returns the x position.
std::tuple< unsigned int, T > defOrigOfParticle(T thePart)
@ numberOfSCTHits
number of SCT holes
@ numberOfPixelHits
number of pixel layers on track with absence of hits
@ numberOfTRTHits
number of TRT outliers
@ numberOfSCTHoles
number of Holes in both sides of a SCT module
@ numberOfPixelHoles
number of pixels which have a ganged ambiguity.
@ NoVtx
Dummy vertex. TrackParticle was not used in vertex fit.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Vertex_v1 Vertex
Define the latest version of the vertex class.
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".