int PHG4DstCompressReco::process_event(PHCompositeNode *topNode) { if (_g4hits.empty() && _g4cells.empty() && _towers.empty()) return Fun4AllReturnCodes::EVENT_OK; //---cells-------------------------------------------------------------------- for (std::set<PHG4CellContainer*>::iterator iter = _g4cells.begin(); iter != _g4cells.end(); ++iter) { PHG4CellContainer* cells = *iter; cells->Reset(); // DROP ALL COMPRESSED G4CELLS } //---hits--------------------------------------------------------------------- for (std::set<PHG4HitContainer*>::iterator iter = _g4hits.begin(); iter != _g4hits.end(); ++iter) { PHG4HitContainer* hits = *iter; hits->Reset(); // DROP ALL COMPRESSED G4HITS } //---secondary particles and vertexes----------------------------------------- std::set<int> keep_particle_ids; for (std::set<PHG4HitContainer*>::iterator iter = _keep_g4hits.begin(); iter != _keep_g4hits.end(); ++iter) { PHG4HitContainer* hits = *iter; for (PHG4HitContainer::ConstIterator jter = hits->getHits().first; jter != hits->getHits().second; ++jter) { PHG4Hit* hit = jter->second; keep_particle_ids.insert(hit->get_trkid()); // this will need to include all parents too in a trace back to // the primary, but let's start here for now } } std::set<int> keep_vertex_ids; PHG4TruthInfoContainer::Range range = _truth_info->GetSecondaryParticleRange(); for (PHG4TruthInfoContainer::Iterator iter = range.first; iter != range.second; ) { int id = iter->first; PHG4Particle* particle = iter->second; if (keep_particle_ids.find(id) != keep_particle_ids.end()) { ++iter; keep_vertex_ids.insert(particle->get_vtx_id()); continue; } else { _truth_info->delete_particle(iter++); // DROP PARTICLES NOT ASSOCIATED TO A PRESERVED HIT } } PHG4TruthInfoContainer::VtxRange vrange = _truth_info->GetSecondaryVtxRange(); for (PHG4TruthInfoContainer::VtxIterator iter = vrange.first; iter != vrange.second; ) { int id = iter->first; if (keep_vertex_ids.find(id) != keep_vertex_ids.end()) { ++iter; continue; } else { _truth_info->delete_vtx(iter++); // DROP VERTEXES NOT ASSOCIATED TO A PRESERVED HIT } } //---shower entries----------------------------------------------------------- PHG4TruthInfoContainer::ShowerRange srange = _truth_info->GetShowerRange(); for (PHG4TruthInfoContainer::ShowerIterator iter = srange.first; iter != srange.second; ++iter) { PHG4Shower* shower = iter->second; shower->clear_g4particle_id(); shower->clear_g4vertex_id(); shower->clear_g4hit_id(); } //---tower cell entries------------------------------------------------------- for (std::set<RawTowerContainer*>::iterator iter = _towers.begin(); iter != _towers.end(); ++iter) { RawTowerContainer* towers = *iter; // loop over all the towers for (RawTowerContainer::Iterator jter = towers->getTowers().first; jter != towers->getTowers().second; ++jter) { RawTower* tower = jter->second; tower->clear_g4cells(); } } return Fun4AllReturnCodes::EVENT_OK; }