ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
DerivationFramework
DerivationFrameworkInDet
src
TrackMeasurementThinning.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
// TrackMeasurementThinning.cxx, (c) ATLAS Detector software
8
// Author: David Salek (David.Salek@cern.ch)
9
// Thinning tool for TrackMeasurementValidationContainer
10
11
#include "
DerivationFrameworkInDet/TrackMeasurementThinning.h
"
12
#include "
StoreGate/ThinningHandle.h
"
13
#include "
xAODTracking/TrackMeasurementValidationContainer.h
"
14
#include <vector>
15
#include <string>
16
17
// Constructor
18
DerivationFramework::TrackMeasurementThinning::TrackMeasurementThinning
(
const
std::string& t,
19
const
std::string& n,
20
const
IInterface* p ) :
21
base_class(t,n,p)
22
{
23
}
24
25
// Destructor
26
DerivationFramework::TrackMeasurementThinning::~TrackMeasurementThinning
() =
default
;
27
28
// Athena initialize and finalize
29
StatusCode
DerivationFramework::TrackMeasurementThinning::initialize
()
30
{
31
ATH_MSG_VERBOSE
(
"initialize() ..."
);
32
if
(
m_selectionString
.empty()) {
33
ATH_MSG_FATAL
(
"No inner detector track selection string provided!"
);
34
return
StatusCode::FAILURE;
35
}
else
{
ATH_MSG_INFO
(
"Track thinning selection string: "
<<
m_selectionString
);}
36
37
//check xAOD::InDetTrackParticle collection
38
ATH_CHECK
(
m_SGKey
.initialize (
m_streamName
) );
39
ATH_MSG_INFO
(
"Using "
<<
m_SGKey
<<
"as the source collection for thinning."
);
40
41
// Set up the text-parsing machinery for thinning the tracks directly according to user cuts
42
if
(!
m_selectionString
.empty()) {
43
ATH_CHECK
( initializeParser(
m_selectionString
) );
44
}
45
return
StatusCode::SUCCESS;
46
}
47
StatusCode
DerivationFramework::TrackMeasurementThinning::finalize
()
48
{
49
ATH_MSG_VERBOSE
(
"finalize() ..."
);
50
ATH_MSG_INFO
(
"Processed "
<<
m_ntot
<<
" measurements, "
<<
m_npass
<<
" were retained "
);
51
ATH_CHECK
( finalizeParser());
52
return
StatusCode::SUCCESS;
53
}
54
55
// The thinning itself
56
StatusCode
DerivationFramework::TrackMeasurementThinning::doThinning
(
const
EventContext& ctx)
const
57
{
58
59
// Get the cluster container
60
SG::ThinningHandle<xAOD::TrackMeasurementValidationContainer>
clusters
61
(
m_SGKey
, ctx);
62
63
// Check the event contains clusters
64
unsigned
int
nClusters = clusters->size();
65
if
(nClusters==0)
return
StatusCode::SUCCESS;
66
67
// Set up a mask with the same entries as the full collection
68
std::vector<bool> mask;
69
mask.assign(nClusters,
false
);
// default: don't keep anything
70
m_ntot
+= nClusters;
71
72
// Execute the text parser and update the mask
73
if
(m_parser) {
74
std::vector<int>
entries
= m_parser->evaluateAsVector();
75
unsigned
int
nEntries =
entries
.size();
76
// check the sizes are compatible
77
if
(nClusters != nEntries ) {
78
ATH_MSG_ERROR
(
"Sizes incompatible! Are you sure your selection string used the same collection as the input collection??"
);
79
return
StatusCode::FAILURE;
80
}
else
{
81
// set mask
82
for
(
unsigned
int
i=0; i<nClusters; ++i)
if
(
entries
[i]==1) mask[i]=
true
;
83
}
84
}
85
// Count the mask
86
unsigned
int
n_pass=0;
87
for
(
unsigned
int
i=0; i<nClusters; ++i) {
88
if
(mask[i]) ++n_pass;
89
}
90
m_npass
+= n_pass;
91
92
// Execute the thinning service based on the mask. Finish.
93
clusters.keep (mask);
94
95
return
StatusCode::SUCCESS;
96
}
97
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition
AthMsgStreamMacros.h:34
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
ThinningHandle.h
Handle for requesting thinning for a data object.
TrackMeasurementThinning.h
TrackMeasurementValidationContainer.h
DerivationFramework::TrackMeasurementThinning::m_ntot
std::atomic< unsigned int > m_ntot
Definition
TrackMeasurementThinning.h:52
DerivationFramework::TrackMeasurementThinning::initialize
virtual StatusCode initialize() override
Definition
TrackMeasurementThinning.cxx:29
DerivationFramework::TrackMeasurementThinning::finalize
virtual StatusCode finalize() override
Definition
TrackMeasurementThinning.cxx:47
DerivationFramework::TrackMeasurementThinning::m_npass
std::atomic< unsigned int > m_npass
Definition
TrackMeasurementThinning.h:53
DerivationFramework::TrackMeasurementThinning::m_streamName
StringProperty m_streamName
Definition
TrackMeasurementThinning.h:55
DerivationFramework::TrackMeasurementThinning::m_SGKey
SG::ThinningHandleKey< xAOD::TrackMeasurementValidationContainer > m_SGKey
Definition
TrackMeasurementThinning.h:58
DerivationFramework::TrackMeasurementThinning::~TrackMeasurementThinning
virtual ~TrackMeasurementThinning()
Destructor.
DerivationFramework::TrackMeasurementThinning::m_selectionString
Gaudi::Property< std::string > m_selectionString
Definition
TrackMeasurementThinning.h:50
DerivationFramework::TrackMeasurementThinning::TrackMeasurementThinning
TrackMeasurementThinning(const std::string &t, const std::string &n, const IInterface *p)
Constructor with parameters.
Definition
TrackMeasurementThinning.cxx:18
DerivationFramework::TrackMeasurementThinning::doThinning
virtual StatusCode doThinning(const EventContext &ctx) const override
Check that the current event passes this filter.
Definition
TrackMeasurementThinning.cxx:56
SG::ThinningHandle
Handle for requesting thinning for a data object.
Definition
ThinningHandle.h:84
entries
double entries
Definition
listroot.cxx:49
Generated on
for ATLAS Offline Software by
1.17.0