Skip to content
Snippets Groups Projects
Commit 66979583 authored by Walter Lampl's avatar Walter Lampl
Browse files

Merge branch 'master-JetClusterer-ClusterSequence' into 'master'

Improve memory management of fastjet::ClusterSequence in JetClusterer

See merge request atlas/athena!38817
parents d2e003d0 b493e993
No related branches found
No related tags found
6 merge requests!58791DataQualityConfigurations: Modify L1Calo config for web display,!46784MuonCondInterface: Enable thread-safety checking.,!46776Updated LArMonitoring config file for WD to match new files produced using MT,!45405updated ART test cron job,!42417Draft: DIRE and VINCIA Base Fragments for Pythia 8.3,!38817Improve memory management of fastjet::ClusterSequence in JetClusterer
......@@ -95,18 +95,18 @@ std::pair<std::unique_ptr<xAOD::JetContainer>, std::unique_ptr<SG::IAuxStore> >
// -----------------------
// Build the cluster sequence
fastjet::JetDefinition jetdef(m_fjalg, m_jetrad);
fastjet::ClusterSequence *clSequence = nullptr;
std::unique_ptr<fastjet::ClusterSequence> clSequence(nullptr);
bool useArea = m_ghostarea > 0 ;
if ( useArea ) {
// Prepare ghost area specifications -------------
ATH_MSG_DEBUG("Creating input area cluster sequence");
bool seedsok=true;
fastjet::AreaDefinition adef = buildAreaDefinition(seedsok);
if(seedsok) {clSequence = new fastjet::ClusterSequenceArea(*pseudoJetVector, jetdef, adef);}
if(seedsok) {clSequence = std::make_unique<fastjet::ClusterSequenceArea>(*pseudoJetVector, jetdef, adef);}
else {return nullreturn;}
} else {
ATH_MSG_DEBUG("Creating input cluster sequence");
clSequence = new fastjet::ClusterSequence(*pseudoJetVector, jetdef);
clSequence = std::make_unique<fastjet::ClusterSequence>(*pseudoJetVector, jetdef);
}
......@@ -122,41 +122,47 @@ std::pair<std::unique_ptr<xAOD::JetContainer>, std::unique_ptr<SG::IAuxStore> >
}
}
// Let fastjet deal with deletion of ClusterSequence, so we don't need to also put it in the EventStore.
clSequence->delete_self_when_unused();
// -------------------------------------
// translate to xAOD::Jet
ATH_MSG_DEBUG("Converting pseudojets to xAOD::Jet");
static SG::AuxElement::Accessor<const fastjet::PseudoJet*> pjAccessor("PseudoJet");
PseudoJetTranslator pjTranslator(useArea, useArea);
for (const fastjet::PseudoJet & pj: *pjVector ) {
// create the xAOD::Jet from the PseudoJet, doing the signal & ghost constituents extraction
xAOD::Jet& jet = pjTranslator.translate(pj, *pjContHandle, *jets);
// Add the PseudoJet onto the xAOD jet. Maybe we should do it in the above JetFromPseudojet call ??
pjAccessor(jet) = &pj;
jet.setInputType( xAOD::JetInput::Type( (int) m_inputType) ) ;
xAOD::JetAlgorithmType::ID ialg = xAOD::JetAlgorithmType::algId(m_fjalg);
jet.setAlgorithmType(ialg);
jet.setSizeParameter((float)m_jetrad);
if(useArea) jet.setAttribute(xAOD::JetAttribute::JetGhostArea, (float)m_ghostarea);
ATH_MSG_VERBOSE( " xAOD::Jet with pt " << std::setprecision(4) << jet.pt()*1e-3 << " has " << jet.getConstituents().size() << " constituents" );
ATH_MSG_VERBOSE( " Leading constituent is of type " << jet.getConstituents()[0].rawConstituent()->type());
}
// No PseudoJets, so there's nothing else to do
// Delete the cluster sequence before we go
if(!pjVector->empty()) {
// Let fastjet deal with deletion of ClusterSequence, so we don't need to also put it in the EventStore.
// Release the memory from the unique_ptr
clSequence->delete_self_when_unused();
clSequence.release();
// -------------------------------------
// translate to xAOD::Jet
ATH_MSG_DEBUG("Converting pseudojets to xAOD::Jet");
static SG::AuxElement::Accessor<const fastjet::PseudoJet*> pjAccessor("PseudoJet");
PseudoJetTranslator pjTranslator(useArea, useArea);
for (const fastjet::PseudoJet & pj: *pjVector ) {
// create the xAOD::Jet from the PseudoJet, doing the signal & ghost constituents extraction
xAOD::Jet& jet = pjTranslator.translate(pj, *pjContHandle, *jets);
// Add the PseudoJet onto the xAOD jet. Maybe we should do it in the above JetFromPseudojet call ??
pjAccessor(jet) = &pj;
jet.setInputType( xAOD::JetInput::Type( (int) m_inputType) ) ;
xAOD::JetAlgorithmType::ID ialg = xAOD::JetAlgorithmType::algId(m_fjalg);
jet.setAlgorithmType(ialg);
jet.setSizeParameter((float)m_jetrad);
if(useArea) jet.setAttribute(xAOD::JetAttribute::JetGhostArea, (float)m_ghostarea);
ATH_MSG_VERBOSE( " xAOD::Jet with pt " << std::setprecision(4) << jet.pt()*1e-3 << " has " << jet.getConstituents().size() << " constituents" );
ATH_MSG_VERBOSE( " Leading constituent is of type " << jet.getConstituents()[0].rawConstituent()->type());
}
// -------------------------------------
// record final PseudoJetVector
SG::WriteHandle<PseudoJetVector> pjVectorHandle(m_finalPseudoJets);
if(!pjVectorHandle.record(std::move(pjVector))){
ATH_MSG_ERROR("Can't record PseudoJetVector under key "<< m_finalPseudoJets);
return nullreturn;
// -------------------------------------
// record final PseudoJetVector
SG::WriteHandle<PseudoJetVector> pjVectorHandle(m_finalPseudoJets);
if(!pjVectorHandle.record(std::move(pjVector))){
ATH_MSG_ERROR("Can't record PseudoJetVector under key "<< m_finalPseudoJets);
return nullreturn;
}
}
ATH_MSG_DEBUG("Reconstructed jet count: " << jets->size() << " clusterseq="<<clSequence);
ATH_MSG_DEBUG("Reconstructed jet count: " << jets->size() << " clusterseq="<<clSequence.get());
// Return the jet container and aux, use move to transfer
// ownership of pointers to caller
return std::make_pair(std::move(jets), std::move(auxCont));
......
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