18 "originalTrackParticle");
40 ATH_CHECK(m_gsfSGKey.initialize(m_streamName));
42 <<
" as the source collection for GSF track particles");
44 <<
"GSF track particles associated with objects in "
45 << m_egammaKey.key() <<
'\n'
46 <<
" will be marked as kept true in the ThinningHandle "
47 <<
"otherwise as kept false");
49 ATH_CHECK(m_inDetSGKey.initialize(m_streamName, !m_inDetSGKey.empty()));
50 if (!m_inDetSGKey.empty()) {
54 <<
" as the source collection for inner detector track particles");
56 ATH_MSG_INFO(
"Inner detector track particles refitted to produce"
57 << m_gsfSGKey.key() <<
'\n'
58 <<
" will be retained when the corresponding "
59 << m_gsfSGKey.key() <<
" track particle will be retained");
62 "Inner detector track particles in a cone dr "
63 << m_coneSize <<
" around the " << m_egammaKey.key() <<
'\n'
64 <<
" obects will be marked as kept true in the ThinningHandle "
65 <<
"otherwise as kept false");
69 ATH_CHECK(m_gsfVtxSGKey.initialize(m_streamName, !m_gsfVtxSGKey.empty()));
70 if (!m_gsfVtxSGKey.empty()) {
72 <<
" as the source collection for GSF conversion vertices");
73 ATH_MSG_INFO((m_bestVtxMatchOnly ?
"Best match " :
"ALL ")
74 <<
" GSF conversion vertices will be kept");
79 if (!m_selectionString.empty()) {
80 ATH_CHECK(initializeParser(m_selectionString));
83 return StatusCode::SUCCESS;
89 ATH_MSG_INFO(
"Selected " << m_nSelEgammas <<
" out of " << m_nEgammas
90 <<
" objects from " << m_egammaKey.key());
91 ATH_MSG_INFO(
"Kept " << m_nGSFPass <<
" out of " << m_ntotGSF
92 <<
" objects from " << m_gsfSGKey.key());
93 if (!m_gsfVtxSGKey.empty()) {
94 ATH_MSG_INFO(
"Kept " << m_nGSFVtxPass <<
" out of " << m_ntotGSFVtx
95 <<
" vertices from " << m_gsfVtxSGKey.key());
97 if (!m_inDetSGKey.empty()) {
98 ATH_MSG_INFO(
"Kept " << m_npass <<
"out of " << m_ntot <<
" objects from "
99 << m_inDetSGKey.key());
103 return StatusCode::SUCCESS;
110 const EventContext& ctx = Gaudi::Hive::currentContext();
115 std::unique_ptr<SG::ThinningHandle<xAOD::TrackParticleContainer>>
116 importedTrackParticles =
nullptr;
117 if (!m_inDetSGKey.empty()) {
118 importedTrackParticles =
119 std::make_unique<SG::ThinningHandle<xAOD::TrackParticleContainer>>(
125 ? importedTrackParticles->cptr()
128 unsigned int nTracks = tps ? tps->
size() : 0;
129 unsigned int nGSF = gsfs->
size();
131 ATH_MSG_DEBUG(
"nTracks : " << nTracks <<
" , nGSF : " << nGSF);
132 if (nTracks == 0 && nGSF == 0) {
134 return StatusCode::SUCCESS;
138 std::vector<bool>
mask, gsfMask;
139 mask.assign(nTracks,
false);
140 gsfMask.assign(nGSF,
false);
146 if (!importedEgamma.
isValid()) {
147 ATH_MSG_ERROR(
"No e-gamma collection with name " << m_egammaKey.key()
148 <<
" found in StoreGate!");
149 return StatusCode::FAILURE;
152 size_t nEgammas(importedEgamma->
size());
154 m_nEgammas += nEgammas;
155 bool doSelect = !m_selectionString.empty();
160 std::vector<int>
entries = m_parser->evaluateAsVector();
164 ATH_MSG_ERROR(
"Sizes incompatible! Are you sure your selection string "
165 "used e-gamma objects??");
166 return StatusCode::FAILURE;
169 for (
unsigned int i = 0;
i < nEgammas; ++
i)
177 m_nSelEgammas += egToCheck->
size();
180 setElectronMasks(
mask, gsfMask, egToCheck, tps, gsfs);
182 setPhotonMasks(
mask, gsfMask, egToCheck, tps, gsfs);
185 "nor for Photons ??");
187 else if (!m_gsfVtxSGKey.empty()) {
192 unsigned int n_pass = 0;
193 for (
unsigned int i = 0;
i < nTracks; ++
i) {
199 unsigned int n_gsf_pass = 0;
200 for (
unsigned int i = 0;
i < nGSF; ++
i) {
205 m_nGSFPass += n_gsf_pass;
208 importedGSFTrackParticles.
keep(gsfMask);
210 importedTrackParticles->keep(
mask);
213 return StatusCode::SUCCESS;
217 const EventContext& ctx)
const
222 unsigned int nGSFVtx = gsfVtxs->
size();
227 std::vector<bool> gsfVtxMask(nGSFVtx,
false);
228 m_ntotGSFVtx += nGSFVtx;
230 importedGSFConversionVtx.
keep(gsfVtxMask);
235 std::vector<bool>&
mask,
236 std::vector<bool>& gsfMask,
241 if (m_gsfVtxSGKey.empty()) {
242 ATH_MSG_ERROR(
"Thinning track particles/vertices associated to photons"
243 "but no conversion vertex key provided");
248 m_gsfVtxSGKey, Gaudi::Hive::currentContext());
250 unsigned int nGSFVtx = gsfVtxs->
size(), n_gsfVtx_pass = 0;
251 std::vector<bool> gsfVtxMask(nGSFVtx,
false);
252 m_ntotGSFVtx += nGSFVtx;
256 for (
const auto*
egamma : *egammas) {
262 "EgammaTrackParticleThinning::setPhotonMasks");
265 if (tps && m_coneSize > 0.0) {
269 std::vector<ElementLink<xAOD::VertexContainer>> vertexLinks =
271 unsigned int nLinks = vertexLinks.size();
275 if (!m_bestVtxMatchOnly) {
276 for (
unsigned int i = 0;
i < nLinks; ++
i) {
277 if (!(vertexLinks[
i])) {
283 gsfVtxMask[vertexLinks[
i].index()] =
true;
286 if (m_bestMatchOnly) {
289 for (
unsigned int i = 0;
i < nLinks; ++
i) {
293 gsfVtxMask[vertexLinks[
i].index()] =
true;
300 if (!link.isValid()) {
303 gsfMask[link.index()] =
true;
306 orig(*((*gsfs)[link.index()]));
308 int inDetIndex = origTrackLink.
index();
309 mask[inDetIndex] =
true;
315 importedGSFConversionVtx.
keep(gsfVtxMask);
316 for (
bool b : gsfVtxMask) {
320 m_nGSFVtxPass += n_gsfVtx_pass;
325 std::vector<bool>&
mask,
326 std::vector<bool>& gsfMask,
332 for (
const auto *
egamma : *egammas) {
340 "EgammaTrackParticleThinning::setElectronMasks");
343 if (tps && m_coneSize > 0.0)
349 unsigned int nGSFLinks = m_bestMatchOnly ? 1 :
electron->nTrackParticles();
350 for (
unsigned int i = 0;
i < nGSFLinks; ++
i) {
351 if (!(
electron->trackParticleLink(
i).isValid())) {
354 int gsfIndex =
electron->trackParticleLink(
i).index();
355 gsfMask[gsfIndex] =
true;
358 orig(*((*gsfs)[gsfIndex]));
360 int inDetIndex = origTrackLink.
index();
361 mask[inDetIndex] =
true;