ATLAS Offline Software
TruthQualitySelectionTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include <GaudiKernel/StatusCode.h>
9 
10 
12  : asg::AsgTool( name ) { }
13 
15  ATH_CHECK(not m_truthTool.empty());
16  ATH_CHECK(m_truthTool.retrieve());
17  return StatusCode::SUCCESS;
18 }
19 
20 
22  std::vector< const xAOD::TruthParticle* > selected;
23  for ( auto trk: trkAnaColls.truthPartVec(IDTPM::TrackAnalysisCollections::FS)) {
24  if ( m_truthTool->accept(trk) and this->accept(trk)) {
25  selected.push_back(trk);
26  }
27  }
28  ATH_MSG_DEBUG("Size before selection: " << trkAnaColls.truthPartVec(IDTPM::TrackAnalysisCollections::FS).size() << "\t Size after selection: " << selected.size());
30  return StatusCode::SUCCESS;
31 }
32 
33 
35  if (m_maxEta!=-9999. and (eta(*truth)) > m_maxEta ) return false;
36  if (m_minEta!=-9999. and (eta(*truth)) < m_minEta ) return false;
37  if (m_minPhi!=-9999. and (phi(*truth)) < m_minPhi ) return false;
38  if (m_maxPhi!=-9999. and (phi(*truth)) > m_maxPhi ) return false;
39  if (m_minD0!=-9999. and (d0(*truth)) < m_minD0 ) return false;
40  if (m_maxD0!=-9999. and (d0(*truth)) > m_maxD0 ) return false;
41  if (m_minZ0!=-9999. and (z0(*truth)) < m_minZ0 ) return false;
42  if (m_maxZ0!=-9999. and (z0(*truth)) > m_maxZ0 ) return false;
43  if (m_minQoPT!=-9999. and (qOverPT(*truth)) < m_minQoPT ) return false;
44  if (m_maxQoPT!=-9999. and (qOverPT(*truth)) > m_maxQoPT ) return false;
45  if (m_minAbsEta!=-9999. and std::fabs(eta(*truth)) < m_minAbsEta ) return false;
46  if (m_minAbsPhi!=-9999. and std::fabs(phi(*truth)) < m_minAbsPhi ) return false;
47  if (m_maxAbsPhi!=-9999. and std::fabs(phi(*truth)) > m_maxAbsPhi ) return false;
48  if (m_minAbsD0!=-9999. and std::fabs(d0(*truth)) < m_minAbsD0 ) return false;
49  if (m_maxAbsD0!=-9999. and std::fabs(d0(*truth)) > m_maxAbsD0 ) return false;
50  if (m_minAbsZ0!=-9999. and std::fabs(z0(*truth)) < m_minAbsZ0 ) return false;
51  if (m_maxAbsZ0!=-9999. and std::fabs(z0(*truth)) > m_maxAbsZ0 ) return false;
52  if (m_minAbsQoPT!=-9999. and std::fabs(qOverPT(*truth)) < m_minAbsQoPT ) return false;
53  if (m_maxAbsQoPT!=-9999. and std::fabs(qOverPT(*truth)) > m_maxAbsQoPT ) return false;
54  if (m_isHadron and not isHadron(*truth) ) return false;
55  return true;
56 }
IDTPM::TrackAnalysisCollections
Definition: TrackAnalysisCollections.h:44
IDTPM::TruthQualitySelectionTool::accept
bool accept(const xAOD::TruthParticle *truth)
Definition: TruthQualitySelectionTool.cxx:34
IDTPM::TruthQualitySelectionTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: TruthQualitySelectionTool.cxx:14
IDTPM::TruthQualitySelectionTool::selectTracks
virtual StatusCode selectTracks(TrackAnalysisCollections &trkAnaColls) override
Definition: TruthQualitySelectionTool.cxx:21
IDTPM::z0
float z0(const U &p)
Definition: TrackParametersHelper.h:70
IDTPM::isHadron
float isHadron(const U &p)
Definition: TrackParametersHelper.h:256
asg
Definition: DataHandleTestTool.h:28
TrackAnalysisCollections.h
Class to hold for each event collections needed in the TrkAnalsis.
IDTPM::phi
float phi(const U &p)
Definition: TrackParametersHelper.h:59
IDTPM::TrackAnalysisCollections::fillTruthPartVec
StatusCode fillTruthPartVec(const std::vector< const xAOD::TruthParticle * > &vec, Stage stage=FULL)
get truth/offline/trigger track vector (TEST or REFERENCE)
Definition: TrackAnalysisCollections.cxx:306
TrackParametersHelper.h
Utility methods to access track/truth particles parmeters in a consitent way in this package.
IDTPM::qOverPT
float qOverPT(const U &p)
Definition: TrackParametersHelper.h:112
IDTPM::TruthQualitySelectionTool::TruthQualitySelectionTool
TruthQualitySelectionTool(const std::string &name)
Definition: TruthQualitySelectionTool.cxx:11
IDTPM::eta
float eta(const U &p)
Accessor utility function for getting the value of eta.
Definition: TrackParametersHelper.h:41
TruthQualitySelectionTool.h
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
IDTPM::TrackAnalysisCollections::FS
@ FS
Definition: TrackAnalysisCollections.h:52
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:37
IDTPM::d0
float d0(const U &p)
Definition: TrackParametersHelper.h:82
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
IDTPM::TrackAnalysisCollections::truthPartVec
const std::vector< const xAOD::TruthParticle * > & truthPartVec(Stage stage=FULL)
get truth/offline/trigger track vector (TEST or REFERENCE)
Definition: TrackAnalysisCollections.h:164