Skip to content
Snippets Groups Projects
Commit ade56004 authored by Edward Moyse's avatar Edward Moyse
Browse files

Merge branch 'fix/tilehit' into 'master'

Fix a leak in TileHitVecToCntTool

See merge request atlas/athena!46690
parents 9c10df76 53afaf4a
No related branches found
No related tags found
No related merge requests found
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
//**************************************************************************
......@@ -32,6 +32,7 @@
#include "TileIdentifier/TileFragHash.h"
#include "TileSimEvent/TileHitVector.h"
#include "TileEvent/TileHitContainer.h"
#include "TileEvent/TileHitNonConstContainer.h"
#include "TileConditions/TileCablingSvc.h"
// Athena includes
......@@ -53,7 +54,6 @@ class TileID;
class TileTBID;
class TileHit;
class TileInfo;
class TileHitNonConstContainer;
class TileDetDescrManager;
class Identifier;
class TileCablingService;
......@@ -96,10 +96,10 @@ private:
StatusCode createContainers();
void processHitVectorForOverlay(const TileHitVector* inputHits, int& nHit, double& eHitTot);
void processHitVectorForPileUp(const TileHitVector* inputHits, double SubEvtTimOffset, int& nHit, double& eHitTot, bool isSignal = false);
void processHitVectorWithoutPileUp(const TileHitVector* inputHits, int& nHit, double& eHitTot, TileHitNonConstContainer* &hitCont, CLHEP::HepRandomEngine * engine);
void processHitVectorWithoutPileUp(const TileHitVector* inputHits, int& nHit, double& eHitTot, TileHitNonConstContainer* hitCont, CLHEP::HepRandomEngine * engine);
double applyPhotoStatistics(double energy, Identifier pmt_id, CLHEP::HepRandomEngine * engine); //!< Method to apply photostatistics effect
void findAndMergeE1(TileHitCollection* coll, int frag_id, TileHitNonConstContainer* &hitCont);
void findAndMergeMBTS(TileHitCollection* coll, int frag_id, TileHitNonConstContainer* &hitCont);
void findAndMergeE1(TileHitCollection* coll, int frag_id, TileHitNonConstContainer* hitCont);
void findAndMergeMBTS(TileHitCollection* coll, int frag_id, TileHitNonConstContainer* hitCont);
Gaudi::Property<bool> m_onlyUseContainerName{this, "OnlyUseContainerName", true, "Don't use the ReadHandleKey directly. Just extract the container name from it."};
......@@ -156,8 +156,8 @@ private:
std::vector<TileHit*> m_allHits; //!< vector for all TileHits
std::vector<TileHit*> m_allHits_DigiHSTruth; //!< vector for all TileHits
TileHitNonConstContainer* m_hits{}; //!< pointer to hits container
TileHitNonConstContainer* m_hits_DigiHSTruth{}; //!< pointer to hits container
std::unique_ptr<TileHitNonConstContainer> m_hits{}; //!< pointer to hits container
std::unique_ptr<TileHitNonConstContainer> m_hits_DigiHSTruth{}; //!< pointer to hits container
int m_mbtsOffset{0}; //<! index of first MBTS hit in m_allHits vector
static const int N_SIDE = 2;
......
......@@ -12,7 +12,6 @@
#include "TileSimAlgs/TileHitVecToCntTool.h"
#include "TileIdentifier/TileHWID.h"
#include "TileDetDescr/TileDetDescrManager.h"
#include "TileEvent/TileHitNonConstContainer.h"
#include "TileConditions/TileInfo.h"
#include "TileConditions/TileCablingService.h"
......@@ -284,7 +283,7 @@ StatusCode TileHitVecToCntTool::createContainers() {
ATH_MSG_VERBOSE("TileHitVecToCntTool createContainers started");
if (m_pileUp) {
m_hits = new TileHitNonConstContainer(SG::VIEW_ELEMENTS);
m_hits = std::make_unique<TileHitNonConstContainer>(SG::VIEW_ELEMENTS);
std::vector<TileHit *>::iterator iHit = m_allHits.begin();
std::vector<TileHit *>::iterator lastHit = m_allHits.end();
for (; iHit != lastHit; ++iHit) {
......@@ -293,7 +292,7 @@ StatusCode TileHitVecToCntTool::createContainers() {
}
if(m_doDigiTruth){
m_hits_DigiHSTruth = new TileHitNonConstContainer(SG::OWN_ELEMENTS);
m_hits_DigiHSTruth = std::make_unique<TileHitNonConstContainer>(SG::OWN_ELEMENTS);
iHit = m_allHits_DigiHSTruth.begin();
lastHit = m_allHits_DigiHSTruth.end();
for (; iHit != lastHit; ++iHit) {
......@@ -304,8 +303,8 @@ StatusCode TileHitVecToCntTool::createContainers() {
}
}
} else {
m_hits = new TileHitNonConstContainer(SG::OWN_ELEMENTS);
if(m_doDigiTruth) m_hits_DigiHSTruth = new TileHitNonConstContainer(SG::OWN_ELEMENTS);
m_hits = std::make_unique<TileHitNonConstContainer>(SG::OWN_ELEMENTS);
if(m_doDigiTruth) m_hits_DigiHSTruth = std::make_unique<TileHitNonConstContainer>(SG::OWN_ELEMENTS);
}
......@@ -505,7 +504,7 @@ void TileHitVecToCntTool::processHitVectorForPileUp(const TileHitVector* inputHi
return;
}
void TileHitVecToCntTool::processHitVectorWithoutPileUp(const TileHitVector* inputHits, int& nHit, double& eHitTot, TileHitNonConstContainer* &hitCont, CLHEP::HepRandomEngine * engine) {
void TileHitVecToCntTool::processHitVectorWithoutPileUp(const TileHitVector* inputHits, int& nHit, double& eHitTot, TileHitNonConstContainer* hitCont, CLHEP::HepRandomEngine * engine) {
TileHitVecConstIterator inpItr = inputHits->begin();
TileHitVecConstIterator end = inputHits->end();
......@@ -757,8 +756,8 @@ StatusCode TileHitVecToCntTool::processBunchXing(int bunchXing
ATH_MSG_ERROR(" Tile Hit container not found for event key " << hitVectorName);
}
this->processHitVectorWithoutPileUp(inputHits, nHit, eHitTot, m_hits, engine);
if(m_doDigiTruth) this->processHitVectorWithoutPileUp(inputHits, nHit, eHitTot, m_hits_DigiHSTruth, engine);
this->processHitVectorWithoutPileUp(inputHits, nHit, eHitTot, m_hits.get(), engine);
if(m_doDigiTruth) this->processHitVectorWithoutPileUp(inputHits, nHit, eHitTot, m_hits_DigiHSTruth.get(), engine);
} // to pile-up or not
} // end of the loop over different input hitVectorNames (normal hits and MBTS hits)
......@@ -798,7 +797,7 @@ StatusCode TileHitVecToCntTool::processAllSubEvents(const EventContext& ctx) {
// get HitVector for this subevent
ATH_MSG_DEBUG(" New HitCont. TimeOffset=" << SubEvtTimeOffset << ", size =" << inputHits->size());
this->processHitVectorForOverlay(inputHits.cptr(), nHit, eHitTot);
if(m_doDigiTruth) this->processHitVectorWithoutPileUp(inputHits.cptr(), nHit, eHitTot, m_hits_DigiHSTruth, engine);
if(m_doDigiTruth) this->processHitVectorWithoutPileUp(inputHits.cptr(), nHit, eHitTot, m_hits_DigiHSTruth.get(), engine);
}
ATH_CHECK(this->mergeEvent(ctx));
return StatusCode::SUCCESS;
......@@ -829,7 +828,7 @@ StatusCode TileHitVecToCntTool::processAllSubEvents(const EventContext& ctx) {
const TileHitVector* inputHits = &(*(iCont->second));
ATH_MSG_DEBUG(" New HitCont. TimeOffset=" << SubEvtTimeOffset << ", size =" << inputHits->size());
this->processHitVectorForOverlay(inputHits, nHit, eHitTot);
if(m_doDigiTruth) this->processHitVectorWithoutPileUp(inputHits, nHit, eHitTot, m_hits_DigiHSTruth, engine);
if(m_doDigiTruth) this->processHitVectorWithoutPileUp(inputHits, nHit, eHitTot, m_hits_DigiHSTruth.get(), engine);
}
}
} else if (m_pileUp) { // pileup code
......@@ -855,8 +854,8 @@ StatusCode TileHitVecToCntTool::processAllSubEvents(const EventContext& ctx) {
ATH_MSG_WARNING("Hit Vector "<< hitVectorName << " not found in StoreGate");
continue; // continue to the next hit vector
}
this->processHitVectorWithoutPileUp(inputHits.cptr(), nHit, eHitTot, m_hits, engine);
if(m_doDigiTruth) this->processHitVectorWithoutPileUp(inputHits.cptr(), nHit, eHitTot, m_hits_DigiHSTruth, engine);
this->processHitVectorWithoutPileUp(inputHits.cptr(), nHit, eHitTot, m_hits.get(), engine);
if(m_doDigiTruth) this->processHitVectorWithoutPileUp(inputHits.cptr(), nHit, eHitTot, m_hits_DigiHSTruth.get(), engine);
}
} // end of the loop over different input hitVectorNames (normal hits and MBTS hits)
......@@ -910,8 +909,8 @@ StatusCode TileHitVecToCntTool::mergeEvent(const EventContext& ctx) {
int frag_id = coll->identify();
IdentifierHash frag_hash = m_fragHashFunc(frag_id);
if (m_E1merged[frag_hash])
findAndMergeE1(coll.get(), frag_id, m_hits);
else if (m_MBTSmerged[frag_hash]) findAndMergeMBTS(coll.get(), frag_id, m_hits);
findAndMergeE1(coll.get(), frag_id, m_hits.get());
else if (m_MBTSmerged[frag_hash]) findAndMergeMBTS(coll.get(), frag_id, m_hits.get());
}
if(m_doDigiTruth){
TileHitNonConstContainer::iterator collIt = m_hits_DigiHSTruth->begin();
......@@ -920,8 +919,8 @@ StatusCode TileHitVecToCntTool::mergeEvent(const EventContext& ctx) {
for (; collIt != endcollIt; ++collIt) {
int frag_id = (*collIt)->identify();
IdentifierHash frag_hash = m_fragHashFunc(frag_id);
if (m_E1merged[frag_hash]) findAndMergeE1((*collIt).get(), frag_id, m_hits_DigiHSTruth);
else if (m_MBTSmerged[frag_hash]) findAndMergeMBTS((*collIt).get(), frag_id, m_hits_DigiHSTruth);
if (m_E1merged[frag_hash]) findAndMergeE1((*collIt).get(), frag_id, m_hits_DigiHSTruth.get());
else if (m_MBTSmerged[frag_hash]) findAndMergeMBTS((*collIt).get(), frag_id, m_hits_DigiHSTruth.get());
}
}
}
......@@ -1115,7 +1114,7 @@ double TileHitVecToCntTool::applyPhotoStatistics(double energy, Identifier pmt_i
}
void TileHitVecToCntTool::findAndMergeE1(TileHitCollection* coll, int frag_id, TileHitNonConstContainer* &hitCont) {
void TileHitVecToCntTool::findAndMergeE1(TileHitCollection* coll, int frag_id, TileHitNonConstContainer* hitCont) {
int module = frag_id & 0x3F;
TileHitCollection::iterator hitIt = coll->begin();
......@@ -1168,7 +1167,7 @@ void TileHitVecToCntTool::findAndMergeE1(TileHitCollection* coll, int frag_id, T
}
void TileHitVecToCntTool::findAndMergeMBTS(TileHitCollection* coll, int frag_id, TileHitNonConstContainer* &hitCont) {
void TileHitVecToCntTool::findAndMergeMBTS(TileHitCollection* coll, int frag_id, TileHitNonConstContainer* hitCont) {
int module = frag_id & 0x3F;
TileHitCollection::iterator hitIt = coll->begin();
......
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