41 DisableTool{ !m_convertAODTrackParticles }));
68 return StatusCode::SUCCESS;
91 return StatusCode::FAILURE;
103 return StatusCode::SUCCESS;
105 tracks = rh_tracks.
cptr();
116 <<
m_aodTruth.key() <<
" found. Do nothing.");
117 return StatusCode::SUCCESS;
119 aodTruth = rh_aodTruth.
cptr();
123 if (!rh_trackTruth.
isValid()) {
126 return StatusCode::SUCCESS;
128 trackTruth = rh_trackTruth.
cptr();
133 if (!rh_truthParticleLinkVec.
isValid()) {
136 return StatusCode::SUCCESS;
138 truthLinks = rh_truthParticleLinkVec.
cptr();
144 if (!vtx_container.
isValid()) {
146 return StatusCode::SUCCESS;
149 for(
auto vtx : *vtx_container) {
163 ATH_MSG_INFO(
"No primary vertex found, will use dummy vertex at "
164 << dummyVertex->
x() <<
"," << dummyVertex->
y() <<
","
165 << dummyVertex->
z());
166 primaryVertex = dummyVertex;
170 ATH_MSG_WARNING(
"Neither primary nor dummy vertex found. Do Nothing.");
171 return StatusCode::SUCCESS;
179 wh_xaodout.
record(std::make_unique<xAOD::TrackParticleContainer>(),
180 std::make_unique<xAOD::TrackParticleAuxContainer>()));
187 return StatusCode::FAILURE;
190 tracksMap = rh_tracksMap.
cptr();
195 truthLinks, primaryVertex, tracksMap);
198 truthLinks, primaryVertex);
208 std::make_unique<xAOD::TrackParticleContainer>(),
209 std::make_unique<xAOD::TrackParticleAuxContainer>()));
211 wh_xaodTrackParticlesout, truthLinks);
217 return StatusCode::SUCCESS;
220template<
typename CONT>
231 return track_particle->
track();
243 if (cont_src.
size() != cont_dest->
size()) {
244 std::stringstream message;
245 message << __FILE__ <<
":" << __LINE__
246 <<
" Expected one-to-one conversion from AOD to xAOD "
247 "TrackParticles but sizes differ: "
248 << cont_src.size() <<
" != " << cont_dest->size();
249 throw std::runtime_error(message.str());
254 unsigned int idx)
const
263template<
typename CONT,
typename TRUTHCONT,
typename CONVTOOL>
267 const TRUTHCONT& truth,
281 if (conv_tool->convertAndAugment(&
container, xaod.
ptr(), obs_track_map, primaryVertex).isFailure()) {
283 << xaod.
name() <<
") with the converting tool");
288 if (conv_tool->convert(&
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 float probability = -1.0;
351 association_to_src(*itr_xaod, itr_xaod - xaod->begin()),
container);
353 ATH_MSG_WARNING(
"Failed to create ElementLink to Track/TrackParticle");
354 }
else if(truth->empty()){
358 auto result = truth->find(tpLink);
359 if (
result == truth->end()) {
361 "Failed find truth associated with Track/TrackParticle");
366 <<
result->second.particleLink().eventIndex());
367 probability =
result->second.probability();
368 link = truthLinkVec->
find(
result->second.particleLink());
372 <<
" eta " << (*link)->eta() <<
" phi "
375 if (
result->second.particleLink().cptr() &&
378 result->second.particleLink());
379 type = truthClass.first;
380 origin = truthClass.second;
383 <<
static_cast<int>(origin));
388 <<
result->second.particleLink());
397 theLink(
"truthParticleLink");
399 "truthMatchProbability");
400 theLink(*particle) = link;
401 theProbability(*particle) = probability;
405 theType(*particle) =
static_cast<int>(
type);
406 theOrigin(*particle) =
static_cast<int>(origin);
412 <<
"] TrackParticles and stored in "
417 <<
" is not equal to the number of items in its converted "
441 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
Test to see if the link can be dereferenced.
Group of local monitoring quantities and retain correlation when filling histograms
SG::Accessor< T, ALLOC > Accessor
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.
int convert(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< TrackParticleTruthCollection > m_aodTruth
SG::ReadHandleKey< TrackTruthCollection > m_trackTruth
SG::WriteHandleKey< xAOD::TrackParticleContainer > m_xaodTrackParticlesout
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
Gaudi::Property< bool > m_convertTracks
toggle on converting tracks to xAOD
ToolHandle< IMCTruthClassifier > m_truthClassifier
ToolHandle to truth classifier.
xAOD::TrackParticle * createParticle(xAOD::TrackParticleContainer &xaod, const Rec::TrackParticleContainer &container, const Rec::TrackParticle &tp)
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.
@ 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".