diff --git a/examples/DDG4/src/HitTupleAction.cpp b/examples/DDG4/src/HitTupleAction.cpp index 3eb7f4b00..d7d5f0db1 100644 --- a/examples/DDG4/src/HitTupleAction.cpp +++ b/examples/DDG4/src/HitTupleAction.cpp @@ -50,7 +50,7 @@ namespace myanalysis { /// We want to write a separate branch for all deposits of one container(sub-detector) typedef std::pair > Data; /// The intermediate storage of the hit deposits to be written to ROOT - std::map > m_deposits; + std::map > m_deposits; public: /// Standard constructor @@ -162,12 +162,11 @@ void myanalysis::HitTupleAction::end(const G4Event* event) { // Seperate loop. We need fixed addresses when creating the branches for(const auto& c : m_containers) { m_deposits[c].first = 0; - m_deposits[c].second = new Data(); - m_deposits[c].second->first = 0e0; - m_deposits[c].second->second.clear(); + m_deposits[c].second.first = 0e0; + m_deposits[c].second.second.clear(); } for(const auto& c : m_containers) { - std::pair& e = m_deposits[c]; + std::pair& e = m_deposits[c]; e.first = m_outTree->Branch(c.c_str(), &e.second); e.first->SetAutoDelete(false); printout(ALWAYS,"HitTupleAction","+++ Prepare hit branch %s in root file.",c.c_str()); @@ -186,11 +185,11 @@ void myanalysis::HitTupleAction::end(const G4Event* event) { if ( find(m_containers.begin(),m_containers.end(),nam) != m_containers.end() ) { Geant4HitCollection* coll = dynamic_cast(hc); if ( coll ) { - std::pair& e = m_deposits[nam]; + std::pair& e = m_deposits[nam]; size_t nhits = coll->GetSize(); - Data* d = e.second; - d->first = 0e0; - d->second.clear(); + Data& d = e.second; + d.first = 0e0; + d.second.clear(); for ( size_t j=0; j 0 ) { - d->first += dep; - d->second.push_back(dep); + d.first += dep; + d.second.push_back(dep); } } }