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 !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> > ...@@ -95,18 +95,18 @@ std::pair<std::unique_ptr<xAOD::JetContainer>, std::unique_ptr<SG::IAuxStore> >
// ----------------------- // -----------------------
// Build the cluster sequence // Build the cluster sequence
fastjet::JetDefinition jetdef(m_fjalg, m_jetrad); fastjet::JetDefinition jetdef(m_fjalg, m_jetrad);
fastjet::ClusterSequence *clSequence = nullptr; std::unique_ptr<fastjet::ClusterSequence> clSequence(nullptr);
bool useArea = m_ghostarea > 0 ; bool useArea = m_ghostarea > 0 ;
if ( useArea ) { if ( useArea ) {
// Prepare ghost area specifications ------------- // Prepare ghost area specifications -------------
ATH_MSG_DEBUG("Creating input area cluster sequence"); ATH_MSG_DEBUG("Creating input area cluster sequence");
bool seedsok=true; bool seedsok=true;
fastjet::AreaDefinition adef = buildAreaDefinition(seedsok); 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 {return nullreturn;}
} else { } else {
ATH_MSG_DEBUG("Creating input cluster sequence"); 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> > ...@@ -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. // No PseudoJets, so there's nothing else to do
clSequence->delete_self_when_unused(); // 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.
// translate to xAOD::Jet // Release the memory from the unique_ptr
ATH_MSG_DEBUG("Converting pseudojets to xAOD::Jet"); clSequence->delete_self_when_unused();
static SG::AuxElement::Accessor<const fastjet::PseudoJet*> pjAccessor("PseudoJet"); clSequence.release();
PseudoJetTranslator pjTranslator(useArea, useArea);
for (const fastjet::PseudoJet & pj: *pjVector ) { // -------------------------------------
// create the xAOD::Jet from the PseudoJet, doing the signal & ghost constituents extraction // translate to xAOD::Jet
xAOD::Jet& jet = pjTranslator.translate(pj, *pjContHandle, *jets); ATH_MSG_DEBUG("Converting pseudojets to xAOD::Jet");
static SG::AuxElement::Accessor<const fastjet::PseudoJet*> pjAccessor("PseudoJet");
// Add the PseudoJet onto the xAOD jet. Maybe we should do it in the above JetFromPseudojet call ?? PseudoJetTranslator pjTranslator(useArea, useArea);
pjAccessor(jet) = &pj; for (const fastjet::PseudoJet & pj: *pjVector ) {
// create the xAOD::Jet from the PseudoJet, doing the signal & ghost constituents extraction
jet.setInputType( xAOD::JetInput::Type( (int) m_inputType) ) ; xAOD::Jet& jet = pjTranslator.translate(pj, *pjContHandle, *jets);
xAOD::JetAlgorithmType::ID ialg = xAOD::JetAlgorithmType::algId(m_fjalg);
jet.setAlgorithmType(ialg); // Add the PseudoJet onto the xAOD jet. Maybe we should do it in the above JetFromPseudojet call ??
jet.setSizeParameter((float)m_jetrad); pjAccessor(jet) = &pj;
if(useArea) jet.setAttribute(xAOD::JetAttribute::JetGhostArea, (float)m_ghostarea);
jet.setInputType( xAOD::JetInput::Type( (int) m_inputType) ) ;
ATH_MSG_VERBOSE( " xAOD::Jet with pt " << std::setprecision(4) << jet.pt()*1e-3 << " has " << jet.getConstituents().size() << " constituents" ); xAOD::JetAlgorithmType::ID ialg = xAOD::JetAlgorithmType::algId(m_fjalg);
ATH_MSG_VERBOSE( " Leading constituent is of type " << jet.getConstituents()[0].rawConstituent()->type()); 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 // record final PseudoJetVector
SG::WriteHandle<PseudoJetVector> pjVectorHandle(m_finalPseudoJets); SG::WriteHandle<PseudoJetVector> pjVectorHandle(m_finalPseudoJets);
if(!pjVectorHandle.record(std::move(pjVector))){ if(!pjVectorHandle.record(std::move(pjVector))){
ATH_MSG_ERROR("Can't record PseudoJetVector under key "<< m_finalPseudoJets); ATH_MSG_ERROR("Can't record PseudoJetVector under key "<< m_finalPseudoJets);
return nullreturn; 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 // Return the jet container and aux, use move to transfer
// ownership of pointers to caller // ownership of pointers to caller
return std::make_pair(std::move(jets), std::move(auxCont)); 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