int RICHParticleID::process_event(PHCompositeNode *topNode) { _ievent ++; /* Get all photon hits in RICH for this event */ PHG4HitContainer* richhits = findNode::getClass<PHG4HitContainer>(topNode,_richhits_name); /* Get track collection with all tracks in this event */ SvtxTrackMap* trackmap = findNode::getClass<SvtxTrackMap>(topNode,_trackmap_name); /* Check if trackmap found */ if (!trackmap) { cout << PHWHERE << "SvtxTrackMap node not found on node tree" << endl; return Fun4AllReturnCodes::ABORTEVENT; } /* Loop over tracks */ for (SvtxTrackMap::ConstIter track_itr = trackmap->begin(); track_itr != trackmap->end(); track_itr++) { SvtxTrack_FastSim* track_j = dynamic_cast<SvtxTrack_FastSim*>(track_itr->second); /* Get mean emission point from track in RICH */ double m_emi[3] = {0.,0.,0.}; /* 'Continue' with next track if RICH not found in state list for this track */ if ( ! get_position_from_track_state( track_j, _trackstate_name, m_emi ) ) continue; /* Fill momv object which is the normalized momentum vector of the track in the RICH (i.e. its direction) */ double momv[3] = {0.,0.,0.}; /* 'Continue' with next track if RICH not found in state list for this track */ if ( ! get_momentum_from_track_state( track_j, _trackstate_name, momv ) ) continue; double momv_norm = sqrt( momv[0]*momv[0] + momv[1]*momv[1] + momv[2]*momv[2] ); momv[0] /= momv_norm; momv[1] /= momv_norm; momv[2] /= momv_norm; /* Calculate true emission angle for output tree */ _theta_true = 0; /* get truth info node */ PHG4TruthInfoContainer* truthinfo = findNode::getClass<PHG4TruthInfoContainer>(topNode, "G4TruthInfo"); /* If truth info found use it to calculate truth emission angle */ if ( truthinfo ) { _theta_true = calculate_true_emission_angle( truthinfo , track_j , _refractive_index ); } /* Loop over all G4Hits in container (i.e. RICH photons in event) */ PHG4HitContainer::ConstRange rich_hits_begin_end = richhits->getHits(); PHG4HitContainer::ConstIterator rich_hits_iter; for (rich_hits_iter = rich_hits_begin_end.first; rich_hits_iter != rich_hits_begin_end.second; ++rich_hits_iter) { PHG4Hit *hit_i = rich_hits_iter->second; /* Set reconstructed emission angle for output tree */ _theta_reco = calculate_emission_angle( m_emi, momv, hit_i ); /* Fill tree */ _tree_rich->Fill(); } // END loop over photons } // END loop over tracks return 0; }
int RICHEvaluator::process_event(PHCompositeNode *topNode) { _ievent ++; /* Get truth information */ PHG4TruthInfoContainer* truthinfo = findNode::getClass<PHG4TruthInfoContainer>(topNode, "G4TruthInfo"); /* Get all photon hits in RICH for this event */ PHG4HitContainer* richhits = findNode::getClass<PHG4HitContainer>(topNode,_richhits_name); /* Get track collection with all tracks in this event */ SvtxTrackMap* trackmap = findNode::getClass<SvtxTrackMap>(topNode,_trackmap_name); /* Check if collections found */ if (!truthinfo) { cout << PHWHERE << "PHG4TruthInfoContainer not found on node tree" << endl; return Fun4AllReturnCodes::ABORTEVENT; } if (!richhits) { cout << PHWHERE << "PHG4HitContainer not found on node tree" << endl; return Fun4AllReturnCodes::ABORTEVENT; } if (!trackmap) { cout << PHWHERE << "SvtxTrackMap node not found on node tree" << endl; return Fun4AllReturnCodes::ABORTEVENT; } /* Loop over tracks */ for (SvtxTrackMap::ConstIter track_itr = trackmap->begin(); track_itr != trackmap->end(); track_itr++) { bool use_reconstructed_momentum = false; bool use_truth_momentum = false; bool use_emission_momentum = true; bool use_reconstructed_point = false; bool use_approximate_point = true; /* Store angles to get RMS value */ TH1F *ch_ang = new TH1F("","",1000,0.0,1.0); SvtxTrack* track_j = dynamic_cast<SvtxTrack*>(track_itr->second); /* Check if track_j is a null pointer. */ if (track_j == NULL) continue; /* Fill momv object which is the normalized momentum vector of the track in the RICH (i.e. its direction) */ double momv[3] = {0.,0.,0.}; if (use_reconstructed_momentum) { /* 'Continue' with next track if RICH projection not found for this track */ if ( ! _trackproj->get_projected_momentum( track_j, momv, TrackProjectorPid::SPHERE, _radius ) ) { cout << "RICH track projection momentum NOT FOUND; next iteration" << endl; continue; } } if (use_truth_momentum) { /* Fill with truth momentum instead of reco */ if ( ! _acquire->get_true_momentum( truthinfo, track_j, momv) ) { cout << "No truth momentum found for track; next iteration" << endl; continue; } } if (use_emission_momentum) { /* Fill with vector constructed from emission points (from truth) */ if ( ! _acquire->get_emission_momentum( truthinfo, richhits, track_j, momv) ) { cout << "No truth momentum from emission points found for track; next iteration" << endl; continue; } } double momv_norm = sqrt( momv[0]*momv[0] + momv[1]*momv[1] + momv[2]*momv[2] ); momv[0] /= momv_norm; momv[1] /= momv_norm; momv[2] /= momv_norm; /* Get mean emission point from track in RICH */ double m_emi[3] = {0.,0.,0.}; if (use_reconstructed_point) { /* 'Continue' with next track if RICH projection not found for this track */ if ( ! _trackproj->get_projected_position( track_j, m_emi, TrackProjectorPid::SPHERE, _radius ) ) { cout << "RICH track projection position NOT FOUND; next iteration" << endl; continue; } } if (use_approximate_point) { m_emi[0] = ((_radius)/momv[2])*momv[0]; m_emi[1] = ((_radius)/momv[2])*momv[1]; m_emi[2] = ((_radius)/momv[2])*momv[2]; } /* 'Continue' with next track if track doesn't pass through RICH */ if ( ! _trackproj->is_in_RICH( momv ) ) continue; /* Calculate truth emission angle and truth mass */ if (truthinfo) { _theta_true = calculate_true_emission_angle( truthinfo , track_j , _refractive_index ); } /* Loop over all G4Hits in container (i.e. RICH photons in event) */ PHG4HitContainer::ConstRange rich_hits_begin_end = richhits->getHits(); PHG4HitContainer::ConstIterator rich_hits_iter; for (rich_hits_iter = rich_hits_begin_end.first; rich_hits_iter != rich_hits_begin_end.second; ++rich_hits_iter) { PHG4Hit *hit_i = rich_hits_iter->second; PHG4Particle* particle = NULL; PHG4Particle* parent = NULL; PHG4VtxPoint* vertex = NULL; if ( truthinfo ) { particle = truthinfo->GetParticle( hit_i->get_trkid() ); parent = truthinfo->GetParticle( particle->get_parent_id() ); vertex = truthinfo->GetVtx( particle->get_vtx_id() ); } _hit_x0 = hit_i->get_x(0); _hit_y0 = hit_i->get_y(0); _hit_z0 = hit_i->get_z(0); _emi_x = vertex->get_x(); _emi_y = vertex->get_y(); _emi_z = vertex->get_z(); _track_px = particle->get_px(); _track_py = particle->get_py(); _track_pz = particle->get_pz(); _mtrack_px = parent->get_px(); _mtrack_py = parent->get_py(); _mtrack_pz = parent->get_pz(); _mtrack_ptot = sqrt( _mtrack_px*_mtrack_px + _mtrack_py*_mtrack_py + _mtrack_pz*_mtrack_pz ); _track_e = particle->get_e(); _mtrack_e = parent->get_e(); _edep = hit_i->get_edep(); _bankid = 0; _volumeid = hit_i->get_detid(); _hitid = hit_i->get_hit_id(); _pid = particle->get_pid(); _mpid = parent->get_pid(); _trackid = particle->get_track_id(); _mtrackid = parent->get_track_id(); _otrackid = track_j->get_id(); /* Set reconstructed emission angle and reconstructed mass for output tree */ _theta_reco = _acquire->calculate_emission_angle( m_emi, momv, hit_i ); ch_ang->Fill(_theta_reco); /* Fill tree */ _tree_rich->Fill(); } // END loop over photons _theta_rms = ch_ang->GetRMS(); _theta_mean = ch_ang->GetMean(); /* Fill condensed tree after every track */ _tree_rich_small->Fill(); } // END loop over tracks return 0; }
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; }