ATLAS Offline Software
Loading...
Searching...
No Matches
InDetSplittedTracksCreator.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
7#include "TrkTrack/Track.h"
8//#include "TrkParameters/MeasuredPerigee.h"
10
11
12
13
15InDet::InDetSplittedTracksCreator::InDetSplittedTracksCreator(const std::string& name, ISvcLocator* pSvcLocator) :
16AthReentrantAlgorithm(name, pSvcLocator),
17// m_sgSvc(0),
18m_TrackCol("Tracks"),
20
21{
22 // Properties go here
23 declareProperty("TrackCollection" , m_TrackCol);
24 declareProperty("OutputTrackCollection" , m_OutputTrackCol);
25 declareProperty("TrackSplitterTool" , m_trackSplitterTool);
26 declareProperty("makeSiOnlyTracks" , m_makeSiOnlyTracks=false);
27 declareProperty("takeUpperSegment" , m_takeUpperSegment=true);
28 declareProperty("takeLowerSegment" , m_takeLowerSegment=true);
29}
30
32
33// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
35
36 ATH_MSG_DEBUG("InDetSplittedTracksCreator initialize()");
37
38 if (m_trackSplitterTool.empty()) {
39 ATH_MSG_DEBUG("No track splitter tool configured");
40 } else if (m_trackSplitterTool.retrieve().isFailure()) {
41 if (msgLvl(MSG::WARNING)) msg(MSG::WARNING)<< "Could not retrieve InDetTrackSplitterTool" << endmsg;
42 } else{
43 ATH_MSG_VERBOSE ("Retrieved tool InDetTrackSplitterTool");
44 }
45 ATH_CHECK( m_TrackCol.initialize() );
46 ATH_CHECK( m_OutputTrackCol.initialize() );
47 return StatusCode::SUCCESS;
48}
49// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
50StatusCode InDet::InDetSplittedTracksCreator::execute(const EventContext& ctx) const {
51 ATH_MSG_DEBUG("InDetSplittedTracksCreator execute()");
52 ATH_MSG_DEBUG("Input Track Collection: " << m_TrackCol);
53
54 //return if no input collection is found
56 if (!trks.isValid()) {
57 ATH_MSG_ERROR(" Could not retrieve the track collection " <<m_TrackCol.key() );
58 return StatusCode::SUCCESS;
59 }
60
61 // @In athenaMT the algorithm should not be scheduled if the splitted tracks exist already or they are overwritten
62 // TrackCollection* splittedTracks=0;
63 // if ((not evtStore()->contains<TrackCollection>(m_OutputTrackCol)) or
64 // (evtStore()->retrieve(splittedTracks,m_OutputTrackCol)).isFailure()) {
65 // splittedTracks = new TrackCollection;
66 // } else {
67 // ATH_MSG_WARNING("Output split track collection already exists: " << m_OutputTrackCol.key() << ". Quitting.");
68 // return StatusCode::SUCCESS;
69 // }
70
72 if (splittedTracks.record( std::make_unique<TrackCollection>() ).isFailure()){
73 ATH_MSG_ERROR("Failed to record output collection " << m_OutputTrackCol.key());
74 return StatusCode::FAILURE;
75 }
76
77
78 //loop over tracks and split them in upper and lower part
79 TrackCollection::const_iterator it = trks->begin();
80 TrackCollection::const_iterator itE = trks->end();
81 for (; it != itE; ++it){
82 ATH_MSG_VERBOSE("Splitting Track");
83 std::pair<Trk::Track*, Trk::Track*> splitTracks = std::pair<Trk::Track*, Trk::Track*> (0,0);
84 splitTracks = m_trackSplitterTool->splitInUpperLowerTrack(**it,m_makeSiOnlyTracks);
85 //only save them if both track fits succeeded
86 if(splitTracks.first && splitTracks.second){
88 ATH_MSG_DEBUG("** InDetSplittedTracksCreator ** Accept upper segment ");
89 splittedTracks->push_back( splitTracks.first );
90 }
92 ATH_MSG_DEBUG("** InDetSplittedTracksCreator ** Accept lower segment ");
93 splittedTracks->push_back( splitTracks.second );
94 }
95 } else {
96 delete splitTracks.first; delete splitTracks.second;
97 }
98
99 }
100 ATH_MSG_DEBUG("** InDetSplittedTracksCreator ** SplittedTracks->size() " << splittedTracks->size() << " stored in " << m_OutputTrackCol.key() );
101
102
103 return StatusCode::SUCCESS;
104}
105// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
107 ATH_MSG_VERBOSE("InDetSplittedTracksCreator finalize()");
108 return StatusCode::SUCCESS;
109}
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
bool msgLvl(const MSG::Level lvl) const
An algorithm that can be simultaneously executed in multiple threads.
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
ToolHandle< InDet::IInDetTrackSplitterTool > m_trackSplitterTool
instances of IInDet
InDetSplittedTracksCreator(const std::string &name, ISvcLocator *pSvcLocator)
Standard Athena-Algorithm Constructor.
bool m_takeUpperSegment
flag to accept the upper segment
bool m_makeSiOnlyTracks
flag for using TRT standalone tracks
StatusCode initialize()
standard Athena-Algorithm method
StatusCode finalize()
standard Athena-Algorithm method
SG::WriteHandleKey< TrackCollection > m_OutputTrackCol
holds the names the output track collection written to store gate
bool m_takeLowerSegment
flag to accept the lower segment
StatusCode execute(const EventContext &ctx) const
standard Athena-Algorithm method
~InDetSplittedTracksCreator()
Default Destructor.
SG::ReadHandleKey< TrackCollection > m_TrackCol
holds the name of the track coll to be used
virtual bool isValid() override final
Can the handle be successfully dereferenced?
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.