17 #include "GaudiKernel/MsgStream.h"
31 declareInterface<DerivationFramework::IAugmentationTool>(
this);
65 return StatusCode::SUCCESS;
74 return StatusCode::SUCCESS;
79 const EventContext& ctx = Gaudi::Hive::currentContext();
80 std::unique_ptr<xAOD::TrackParticleContainer> outputRecoReplacedWithPseudo = std::make_unique<xAOD::TrackParticleContainer>();
81 std::unique_ptr<xAOD::TrackParticleAuxContainer> outputRecoReplacedWithPseudoAux = std::make_unique<xAOD::TrackParticleAuxContainer>();
82 outputRecoReplacedWithPseudo->setStore(outputRecoReplacedWithPseudoAux.get());
83 std::unique_ptr<xAOD::TrackParticleContainer> outputRecoReplacedWithPseudoFromB = std::make_unique<xAOD::TrackParticleContainer>();
84 std::unique_ptr<xAOD::TrackParticleAuxContainer> outputRecoReplacedWithPseudoFromBAux = std::make_unique<xAOD::TrackParticleAuxContainer>();
85 outputRecoReplacedWithPseudoFromB->setStore(outputRecoReplacedWithPseudoFromBAux.get());
86 std::unique_ptr<xAOD::TrackParticleContainer> outputRecoReplacedWithPseudoNotFromB = std::make_unique<xAOD::TrackParticleContainer>();
87 std::unique_ptr<xAOD::TrackParticleAuxContainer> outputRecoReplacedWithPseudoNotFromBAux = std::make_unique<xAOD::TrackParticleAuxContainer>();
88 outputRecoReplacedWithPseudoNotFromB->setStore(outputRecoReplacedWithPseudoNotFromBAux.get());
89 std::unique_ptr<xAOD::TrackParticleContainer> outputRecoPlusPseudo = std::make_unique<xAOD::TrackParticleContainer>();
90 std::unique_ptr<xAOD::TrackParticleAuxContainer> outputRecoPlusPseudoAux = std::make_unique<xAOD::TrackParticleAuxContainer>();
91 outputRecoPlusPseudo->setStore(outputRecoPlusPseudoAux.get());
92 std::unique_ptr<xAOD::TrackParticleContainer> outputRecoPlusPseudoFromB = std::make_unique<xAOD::TrackParticleContainer>();
93 std::unique_ptr<xAOD::TrackParticleAuxContainer> outputRecoPlusPseudoFromBAux = std::make_unique<xAOD::TrackParticleAuxContainer>();
94 outputRecoPlusPseudoFromB->setStore(outputRecoPlusPseudoFromBAux.get());
95 std::unique_ptr<xAOD::TrackParticleContainer> outputRecoPlusPseudoNotFromB = std::make_unique<xAOD::TrackParticleContainer>();
96 std::unique_ptr<xAOD::TrackParticleAuxContainer> outputRecoPlusPseudoNotFromBAux = std::make_unique<xAOD::TrackParticleAuxContainer>();
97 outputRecoPlusPseudoNotFromB->setStore(outputRecoPlusPseudoNotFromBAux.get());
98 std::unique_ptr<xAOD::TrackParticleContainer> outputRecoNoFakes = std::make_unique<xAOD::TrackParticleContainer>();
99 std::unique_ptr<xAOD::TrackParticleAuxContainer> outputRecoNoFakesAux = std::make_unique<xAOD::TrackParticleAuxContainer>();
100 outputRecoNoFakes->setStore(outputRecoNoFakesAux.get());
101 std::unique_ptr<xAOD::TrackParticleContainer> outputRecoNoFakesFromB = std::make_unique<xAOD::TrackParticleContainer>();
102 std::unique_ptr<xAOD::TrackParticleAuxContainer> outputRecoNoFakesFromBAux = std::make_unique<xAOD::TrackParticleAuxContainer>();
103 outputRecoNoFakesFromB->setStore(outputRecoNoFakesFromBAux.get());
104 std::unique_ptr<xAOD::TrackParticleContainer> outputRecoNoFakesNotFromB = std::make_unique<xAOD::TrackParticleContainer>();
105 std::unique_ptr<xAOD::TrackParticleAuxContainer> outputRecoNoFakesNotFromBAux = std::make_unique<xAOD::TrackParticleAuxContainer>();
106 outputRecoNoFakesNotFromB->setStore(outputRecoNoFakesNotFromBAux.get());
113 if (!recoTrackParticleCol.
isValid()){
115 return StatusCode::FAILURE;
117 if (!pseudoTrackParticleCol.
isValid()){
119 return StatusCode::FAILURE;
128 fillRecoPlusPseudo(recoTrackParticleCol.
cptr(), pseudoTrackParticleCol.
cptr(), outputRecoPlusPseudoNotFromB.get(),
false,
true);
131 fillRecoNoFakes(recoTrackParticleCol.
cptr(), outputRecoNoFakesNotFromB.get(),
false,
true);
134 ATH_MSG_DEBUG(
"outputRecoReplacedWithPseudo has "<<outputRecoReplacedWithPseudo.get()->
size()<<
" tracks");
136 ATH_CHECK(h_write_recoReplacedWithPseudo.
record(std::move(outputRecoReplacedWithPseudo), std::move(outputRecoReplacedWithPseudoAux)));
139 ATH_MSG_DEBUG(
"outputRecoReplacedWithPseudoFromB has "<<outputRecoReplacedWithPseudoFromB.get()->
size()<<
" tracks");
141 ATH_CHECK(h_write_recoReplacedWithPseudoFromB.
record(std::move(outputRecoReplacedWithPseudoFromB), std::move(outputRecoReplacedWithPseudoFromBAux)));
144 ATH_MSG_DEBUG(
"outputRecoReplacedWithPseudoNotFromB has "<<outputRecoReplacedWithPseudoNotFromB.get()->
size()<<
" tracks");
146 ATH_CHECK(h_write_recoReplacedWithPseudoNotFromB.
record(std::move(outputRecoReplacedWithPseudoNotFromB), std::move(outputRecoReplacedWithPseudoNotFromBAux)));
149 ATH_MSG_DEBUG(
"outputRecoPlusPseudo has "<<outputRecoPlusPseudo.get()->
size()<<
" tracks");
151 ATH_CHECK(h_write_recoPlusPseudo.
record(std::move(outputRecoPlusPseudo), std::move(outputRecoPlusPseudoAux)));
154 ATH_MSG_DEBUG(
"outputRecoPlusPseudoFromB has "<<outputRecoPlusPseudoFromB.get()->
size()<<
" tracks");
156 ATH_CHECK(h_write_recoPlusPseudoFromB.
record(std::move(outputRecoPlusPseudoFromB), std::move(outputRecoPlusPseudoFromBAux)));
159 ATH_MSG_DEBUG(
"outputRecoPlusPseudoNotFromB has "<<outputRecoPlusPseudoNotFromB.get()->
size()<<
" tracks");
161 ATH_CHECK(h_write_recoPlusPseudoNotFromB.
record(std::move(outputRecoPlusPseudoNotFromB), std::move(outputRecoPlusPseudoNotFromBAux)));
164 ATH_MSG_DEBUG(
"outputRecoNoFakes has "<<outputRecoNoFakes.get()->
size()<<
" tracks");
166 ATH_CHECK(h_write_recoNoFakes.
record(std::move(outputRecoNoFakes), std::move(outputRecoNoFakesAux)));
169 ATH_MSG_DEBUG(
"outputRecoNoFakesFromB has "<<outputRecoNoFakesFromB.get()->
size()<<
" tracks");
171 ATH_CHECK(h_write_recoNoFakesFromB.
record(std::move(outputRecoNoFakesFromB), std::move(outputRecoNoFakesFromBAux)));
174 ATH_MSG_DEBUG(
"outputRecoNoFakesNotFromB has "<<outputRecoNoFakesNotFromB.get()->
size()<<
" tracks");
176 ATH_CHECK(h_write_recoNoFakesNotFromB.
record(std::move(outputRecoNoFakesNotFromB), std::move(outputRecoNoFakesNotFromBAux)));
179 return StatusCode::SUCCESS;
190 bool onlyNotFromB )
const
192 ATH_MSG_DEBUG(
"Start fillRecoReplacedWithPseudo with onlyFromB = "<<onlyFromB<<
" and onlyNotFromB = "<<onlyNotFromB);
194 if((recoTrackParticleCol && !recoTrackParticleCol->
empty()) &&
195 (pseudoTrackParticleCol && !pseudoTrackParticleCol->
empty())) {
196 ATH_MSG_DEBUG(
"Size of reco track particle collection " << recoTrackParticleCol->
size());
197 ATH_MSG_DEBUG(
"Size of pseudo track particle collection " << pseudoTrackParticleCol->
size());
200 for(
const auto *
const tp_reco: *recoTrackParticleCol){
204 bool match_found =
false;
206 for(
const auto *
const tp_pseudo: *pseudoTrackParticleCol){
208 if (truth_reco == truth_pseudo){
212 if (!onlyFromB && !onlyNotFromB){
261 ATH_MSG_DEBUG(
"reco track that has truth link DOES NOT have truth-matched pseudo track! :(");
268 ATH_MSG_DEBUG(
"Size of output track particle collection " << outputCol->
size() <<
" (sanity: "<<n_saved<<
")");
276 bool onlyNotFromB )
const
278 ATH_MSG_DEBUG(
"Start fillRecoPlusPseudo with onlyFromB = "<<onlyFromB<<
" and onlyNotFromB = "<<onlyNotFromB);
280 if((recoTrackParticleCol && !recoTrackParticleCol->
empty()) &&
281 (pseudoTrackParticleCol && !pseudoTrackParticleCol->
empty())) {
282 ATH_MSG_DEBUG(
"Size of reco track particle collection " << recoTrackParticleCol->
size());
283 ATH_MSG_DEBUG(
"Size of pseudo track particle collection " << pseudoTrackParticleCol->
size());
286 for(
const auto *
const tp_reco: *recoTrackParticleCol){
292 for(
const auto *
const tp_pseudo: *pseudoTrackParticleCol){
293 bool match_found =
false;
295 for(
const auto *
const tp_reco: *recoTrackParticleCol){
299 if (truth_reco == truth_pseudo){
310 ATH_MSG_DEBUG(
"no match found, so adding pseudo track to output");
311 if(!onlyFromB && !onlyNotFromB){
333 ATH_MSG_DEBUG(
"match found so not adding pseudo track to output");
336 ATH_MSG_DEBUG(
"Size of output track particle collection " << outputCol->
size() <<
" (sanity: "<<n_saved<<
")");
343 bool onlyNotFromB )
const
345 ATH_MSG_DEBUG(
"Start fillRecoNoFakes with onlyFromB = "<<onlyFromB<<
" and onlyNotFromB = "<<onlyNotFromB);
347 if((recoTrackParticleCol && !recoTrackParticleCol->
empty())){
348 ATH_MSG_DEBUG(
"Size of reco track particle collection " << recoTrackParticleCol->
size());
353 for(
const auto *
const tp_reco: *recoTrackParticleCol){
355 if (!onlyFromB && !onlyNotFromB){
356 if( acc_truthProb( *tp_reco ) < 0.5) {
364 if( acc_truthProb( *tp_reco ) < 0.5) {
370 if( acc_truthProb( *tp_reco ) < 0.5) {
380 ATH_MSG_DEBUG(
"Size of output track particle collection " << outputCol->
size() <<
" (sanity: "<<n_saved<<
")");
407 linkedTruthParticle = (*link);
408 return linkedTruthParticle;