ATLAS Offline Software
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 
15 InDet::InDetSplittedTracksCreator::InDetSplittedTracksCreator(const std::string& name, ISvcLocator* pSvcLocator) :
16 AthReentrantAlgorithm(name, pSvcLocator),
17 // m_sgSvc(0),
18 m_TrackCol("Tracks"),
19 m_trackSplitterTool()
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
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();
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){
87  if (m_takeUpperSegment) {
88  ATH_MSG_DEBUG("** InDetSplittedTracksCreator ** Accept upper segment ");
89  splittedTracks->push_back( splitTracks.first );
90  }
91  if (m_takeLowerSegment) {
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 }
InDet::InDetSplittedTracksCreator::finalize
StatusCode finalize()
standard Athena-Algorithm method
Definition: InDetSplittedTracksCreator.cxx:106
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
InDet::InDetSplittedTracksCreator::m_takeUpperSegment
bool m_takeUpperSegment
flag to accept the upper segment
Definition: InDetSplittedTracksCreator.h:52
InDet::InDetSplittedTracksCreator::m_TrackCol
SG::ReadHandleKey< TrackCollection > m_TrackCol
holds the name of the track coll to be used
Definition: InDetSplittedTracksCreator.h:44
InDet::InDetSplittedTracksCreator::m_makeSiOnlyTracks
bool m_makeSiOnlyTracks
flag for using TRT standalone tracks
Definition: InDetSplittedTracksCreator.h:50
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
skel.it
it
Definition: skel.GENtoEVGEN.py:423
AthCommonMsg< Gaudi::Algorithm >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
InDet::InDetSplittedTracksCreator::m_OutputTrackCol
SG::WriteHandleKey< TrackCollection > m_OutputTrackCol
holds the names the output track collection written to store gate
Definition: InDetSplittedTracksCreator.h:46
InDet::InDetSplittedTracksCreator::m_takeLowerSegment
bool m_takeLowerSegment
flag to accept the lower segment
Definition: InDetSplittedTracksCreator.h:54
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
TruthTest.itE
itE
Definition: TruthTest.py:25
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
Track.h
InDet::InDetSplittedTracksCreator::initialize
StatusCode initialize()
standard Athena-Algorithm method
Definition: InDetSplittedTracksCreator.cxx:34
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
InDet::InDetSplittedTracksCreator::m_trackSplitterTool
ToolHandle< InDet::IInDetTrackSplitterTool > m_trackSplitterTool
instances of IInDet
Definition: InDetSplittedTracksCreator.h:56
TrackCollection.h
InDet::InDetSplittedTracksCreator::~InDetSplittedTracksCreator
~InDetSplittedTracksCreator()
Default Destructor.
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
InDet::InDetSplittedTracksCreator::execute
StatusCode execute(const EventContext &ctx) const
standard Athena-Algorithm method
Definition: InDetSplittedTracksCreator.cxx:50
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
InDet::InDetSplittedTracksCreator::InDetSplittedTracksCreator
InDetSplittedTracksCreator(const std::string &name, ISvcLocator *pSvcLocator)
Standard Athena-Algorithm Constructor.
Definition: InDetSplittedTracksCreator.cxx:15
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
IInDetTrackSplitterTool.h
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
AthCommonMsg< Gaudi::Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
InDetSplittedTracksCreator.h