Skip to content
Snippets Groups Projects
Commit 9a095007 authored by John Derek Chapman's avatar John Derek Chapman Committed by Tadej Novak
Browse files

Use the GenEvent event_number in HepMcParticleLink constructors where it is known

Use the GenEvent event_number in HepMcParticleLink constructors where it is known
parent e232b2b1
No related branches found
No related tags found
No related merge requests found
/*
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
*/
//////////////////////////////////////////////////////////////////
......@@ -426,7 +426,7 @@ void InDet::TrackStatHelper::addEvent(const TrackCollection * recTr
bool matched = false;
int nmatched = 0;
HepMcParticleLink hmpl2(particle,truth->second,HepMcParticleLink::IS_EVENTNUM); // FIXME truth->second is actually the position of the GenEvent in the McEventCollection!! See InDetRecStatisticsAlg::selectGenSignal(...) method (only client of TrackStatsHelper)
HepMcParticleLink hmpl2(particle,particle->parent_event()->event_number(),HepMcParticleLink::IS_EVENTNUM);
recoToTruthMap::iterator rttIter=rttMap.find(hmpl2);
if(rttIter != rttMap.end()){
for(imap = rttMap.lower_bound(hmpl2); imap !=rttMap.upper_bound(hmpl2); ++imap){
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
*/
// Niels van Eldik 2010
......@@ -41,18 +41,19 @@ namespace Muon {
// copy the outer half to result
while (!tmp.empty()) {
ATH_MSG_DEBUG(" Adding daughter: " << current);
result->emplace_back(tmp.top(),0,HepMcParticleLink::IS_EVENTNUM); // FIXME should not be using eventIndex=0 with IS_EVENTNUM either obtain event number from GenParticlePtr or use IS_POSITION
ATH_MSG_DEBUG(" Adding daughter: " << current); // FIXME "current" is not changed in this loop - it might make sense to print tmp.top() instead here?
result->emplace_back(tmp.top(),tmp.top()->parent_event()->event_number(),HepMcParticleLink::IS_EVENTNUM);
tmp.pop();
}
// The input particle itself
result->emplace_back(input,0,HepMcParticleLink::IS_EVENTNUM); // FIXME should not be using eventIndex=0 with IS_EVENTNUM either obtain event number from GenParticlePtr or use IS_POSITION
result->emplace_back(input,input->parent_event()->event_number(),HepMcParticleLink::IS_EVENTNUM);
// Now continue towards the interaction point
while ((next = getMother(current))) {
ATH_MSG_DEBUG(" Adding mother: " << current);
result->emplace_back(current = next,0,HepMcParticleLink::IS_EVENTNUM); // FIXME should not be using eventIndex=0 with IS_EVENTNUM either obtain event number from GenParticlePtr or use IS_POSITION
ATH_MSG_DEBUG(" Adding mother: " << current); // FIXME "current" here refers to the child particle rather than the mother? Consider moving this after "current = next"
current = next;
result->emplace_back(current,current->parent_event()->event_number(),HepMcParticleLink::IS_EVENTNUM);
}
ATH_MSG_DEBUG(" Final TruthTrajectory: ");
......
......@@ -40,8 +40,7 @@ ATLAS_NO_CHECK_FILE_THREAD_SAFETY;
#include "GeoPrimitives/GeoPrimitives.h"
// HepMC
#include "AtlasHepMC/GenParticle.h"
#include "AtlasHepMC/GenVertex.h"
#include "AtlasHepMC/GenEvent.h"
#include "AtlasHepMC/Operators.h"
#include "GeneratorObjects/HepMcParticleLink.h"
#include "GeneratorObjects/McEventCollection.h"
......@@ -205,13 +204,15 @@ TEST_F(InputConverter_test, convertParticle_using_generated_mass) {
// create dummy input McEventCollection containing a dummy GenEvent
SG::WriteHandle<McEventCollection> inputTestDataHandle{"GEN_EVENT"};
inputTestDataHandle = std::make_unique<McEventCollection>();
inputTestDataHandle->push_back(new HepMC::GenEvent());
const int signal_process_id{1};
const int event_number{1};
inputTestDataHandle->push_back(HepMC::newGenEvent(signal_process_id, event_number));
HepMC::GenEvent& ge = *(inputTestDataHandle->at(0));
ge.add_vertex( prodVtx );
//AV: we set barcode here because only here the particle in HepMC3 enters event and can have a meaningful barcode.
HepMC::suggest_barcode(genPart,particleBarcode);
HepMC::fillBarcodesAttribute(&ge);
HepMcParticleLink* trackLink = new HepMcParticleLink(particleBarcode, 0, HepMcParticleLink::IS_EVENTNUM, HepMcParticleLink::IS_BARCODE); // FIXME barcode-based syntax
HepMcParticleLink* trackLink = new HepMcParticleLink(particleBarcode, event_number, HepMcParticleLink::IS_EVENTNUM, HepMcParticleLink::IS_BARCODE); // FIXME barcode-based syntax
Amg::Vector3D expectedPos(9.8, 7.65, 4.3);
Amg::Vector3D expectedMom(12.3, 45.6, 78.9);
......@@ -261,13 +262,15 @@ TEST_F(InputConverter_test, convertParticle_using_particleDataTable_photon) {
// create dummy input McEventCollection containing a dummy GenEvent
SG::WriteHandle<McEventCollection> inputTestDataHandle{"GEN_EVENT"};
inputTestDataHandle = std::make_unique<McEventCollection>();
inputTestDataHandle->push_back(new HepMC::GenEvent());
const int signal_process_id{1};
const int event_number{1};
inputTestDataHandle->push_back(HepMC::newGenEvent(signal_process_id, event_number));
HepMC::GenEvent& ge = *(inputTestDataHandle->at(0));
ge.add_vertex( prodVtx );
//AV: we set barcode here because only here the particle in HepMC3 enters event and can have a meaningful barcode.
HepMC::suggest_barcode(genPart,particleBarcode);
HepMC::fillBarcodesAttribute(&ge);
HepMcParticleLink* trackLink = new HepMcParticleLink(particleBarcode, 0, HepMcParticleLink::IS_EVENTNUM, HepMcParticleLink::IS_BARCODE);
HepMcParticleLink* trackLink = new HepMcParticleLink(particleBarcode, event_number, HepMcParticleLink::IS_EVENTNUM, HepMcParticleLink::IS_BARCODE);
Amg::Vector3D expectedPos(9.8, 7.65, 4.3);
Amg::Vector3D expectedMom(12.3, 45.6, 78.9);
......@@ -317,11 +320,13 @@ TEST_F(InputConverter_test, convertParticle_using_particleDataTable_electron) {
// create dummy input McEventCollection containing a dummy GenEvent
SG::WriteHandle<McEventCollection> inputTestDataHandle{"GEN_EVENT"};
inputTestDataHandle = std::make_unique<McEventCollection>();
inputTestDataHandle->push_back(new HepMC::GenEvent());
const int signal_process_id{1};
const int event_number{1};
inputTestDataHandle->push_back(HepMC::newGenEvent(signal_process_id, event_number));
HepMC::GenEvent& ge = *(inputTestDataHandle->at(0));
ge.add_vertex( prodVtx );
HepMC::suggest_barcode(genPart,particleBarcode);
HepMcParticleLink* trackLink = new HepMcParticleLink(particleBarcode, 0, HepMcParticleLink::IS_EVENTNUM, HepMcParticleLink::IS_BARCODE);
HepMcParticleLink* trackLink = new HepMcParticleLink(particleBarcode, event_number, HepMcParticleLink::IS_EVENTNUM, HepMcParticleLink::IS_BARCODE);
Amg::Vector3D expectedPos(9.8, 7.65, 4.3);
Amg::Vector3D expectedMom(12.3, 45.6, 78.9);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment