Пример #1
0
std::set<PHG4VtxPoint*> SvtxVertexEval::all_truth_points(SvtxVertex* vertex) {

 if ((_do_cache) && (_cache_all_truth_points.find(vertex) !=
		     _cache_all_truth_points.end())) {
    return _cache_all_truth_points[vertex];
  }
  
  PHG4TruthInfoContainer* truthinfo = findNode::getClass<PHG4TruthInfoContainer>(_topNode,"G4TruthInfo");
  if (!truthinfo) {
    cerr << PHWHERE << " ERROR: Can't find G4TruthInfo" << endl;
    exit(-1);
  }

  std::set<PHG4VtxPoint*> points;
  
  std::set<PHG4Particle*> particles = all_truth_particles(vertex);
  for (std::set<PHG4Particle*>::iterator iter = particles.begin();
       iter != particles.end();
       ++iter) {
    PHG4Particle* particle = *iter;

    // only consider primary particles
    PHG4TruthInfoContainer::Map primarymap = truthinfo->GetPrimaryMap();
    if (primarymap.find(particle->get_track_id()) == primarymap.end()) continue;
        
    points.insert(truthinfo->GetPrimaryVtx(particle->get_vtx_id()));
  }

  if (_do_cache) _cache_all_truth_points.insert(make_pair(vertex,points));
  
  return points;
}
Пример #2
0
// overlap calculations
unsigned int SvtxVertexEval::get_ntracks_contribution(SvtxVertex* vertex, PHG4VtxPoint* truthpoint) {

  if ((_do_cache) && (_cache_get_ntracks_contribution.find(make_pair(vertex,truthpoint)) !=
		      _cache_get_ntracks_contribution.end())) {
    return _cache_get_ntracks_contribution[make_pair(vertex,truthpoint)];
  }
  
  SvtxTrackMap* trackmap = findNode::getClass<SvtxTrackMap>(_topNode,"SvtxTrackMap");
  if (!trackmap) {
    cerr << PHWHERE << " ERROR: Can't find SvtxTrackMap" << endl;
    exit(-1);
  }

  PHG4TruthInfoContainer* truthinfo = findNode::getClass<PHG4TruthInfoContainer>(_topNode,"G4TruthInfo");
  if (!truthinfo) {
    cerr << PHWHERE << " ERROR: Can't find G4TruthInfo" << endl;
    exit(-1);
  }
  
  unsigned int ntracks = 0;

  for (SvtxVertex::TrackIter iter = vertex->begin_tracks();
       iter != vertex->end_tracks();
       ++iter) {
    
    SvtxTrack* track = trackmap->get(*iter);
    PHG4Particle* particle = _trackeval.max_truth_particle_by_nclusters(track);

    // only consider primary particles
    PHG4TruthInfoContainer::Map primarymap = truthinfo->GetPrimaryMap();
    if (primarymap.find(particle->get_track_id()) == primarymap.end()) continue;

    PHG4VtxPoint* candidate = truthinfo->GetPrimaryVtx(particle->get_vtx_id());
    if (candidate->get_id() == truthpoint->get_id()) ++ntracks;
  }
  
  if (_do_cache) _cache_get_ntracks_contribution.insert(make_pair(make_pair(vertex,truthpoint),ntracks));
  
  return ntracks;
}
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 MomentumEvaluator::process_event( PHCompositeNode *topNode )
{
	PHG4TruthInfoContainer* truthinfo = findNode::getClass<PHG4TruthInfoContainer>(topNode,"G4TruthInfo");

	PHG4HitContainer* g4hits = findNode::getClass<PHG4HitContainer>(topNode,"G4HIT_SVTX");
	if(g4hits == nullptr){cout<<"can't find PHG4HitContainer"<<endl;exit(1);}
	PHG4HitContainer::ConstRange g4range = g4hits->getHits();

	// set<int> trkids;
	map<int, pair<unsigned int,unsigned int> > trkids;

	for( PHG4HitContainer::ConstIterator iter = g4range.first; iter != g4range.second; ++iter )
	{
		PHG4Hit* hit = iter->second;

		int layer = hit->get_layer();
		float length = outer_z_length;
		if(((unsigned int)layer)<n_inner_layers){length=inner_z_length;}
		if(fabs(hit->get_z(0))>length){continue;}

		int trk_id = hit->get_trkid();
		if(trkids.find(trk_id) == trkids.end())
		{
			trkids[trk_id].first = 0;
			trkids[trk_id].second = 0;
		}
		if( hit->get_layer() < 32 )
		{
			trkids[trk_id].first = (trkids[trk_id].first | (1<<(hit->get_layer())));
		}
		else
		{
			trkids[trk_id].second = (trkids[trk_id].second | (1<<(hit->get_layer()-32)));
		}
		
		// cout<<"trk_id = "<<trk_id<<endl;
		// cout<<"layer = "<<hit->get_layer()<<endl;
		// cout<<"nlayer = "<<__builtin_popcount(trkids[trk_id].first)+__builtin_popcount(trkids[trk_id].second)<<endl<<endl;
		// trkids.insert(trk_id);
	}


	SvtxTrackMap* trackmap = findNode::getClass<SvtxTrackMap>(topNode,"SvtxTrackMap");

	PHG4VtxPoint *gvertex = truthinfo->GetPrimaryVtx( truthinfo->GetPrimaryVertexIndex() );
	float gvx = gvertex->get_x();
	float gvy = gvertex->get_y();
	float gvz = gvertex->get_z();

	RecursiveMomentumContainer true_sorted( -20., 20., -20., 20., -20., 20., 10 );

	// PHG4TruthInfoContainer::Map primarymap = truthinfo->GetPrimaryMap();
	PHG4TruthInfoContainer::Map primarymap = truthinfo->GetMap();
   for(PHG4TruthInfoContainer::Iterator iter = primarymap.begin();iter != primarymap.end();++iter)
   {
   	PHG4Particle *particle = iter->second;

   	float vx = truthinfo->GetVtx(particle->get_vtx_id())->get_x();
   	float vy = truthinfo->GetVtx(particle->get_vtx_id())->get_y();
   	float vz = truthinfo->GetVtx(particle->get_vtx_id())->get_z();
   	
   	TrivialTrack track( particle->get_px(), particle->get_py(), particle->get_pz(), vx-gvx, vy-gvy, vz-gvz );

   	if( ( (track.px * track.px) + (track.py * track.py) ) < (0.1*0.1) ){continue;}

   	if( trkids.find(particle->get_track_id()) == trkids.end() )
   	{
   		continue;
   	}

   	// cout<<"trk, nhits = "<<particle->get_track_id()<<" "<<__builtin_popcount(trkids[particle->get_track_id()].first)+__builtin_popcount(trkids[particle->get_track_id()].second)<<endl;

   	if( __builtin_popcount(trkids[particle->get_track_id()].first)+__builtin_popcount(trkids[particle->get_track_id()].second) < (int)n_required_layers )
   	{
   		continue;
   	}

   	true_sorted.insert( track );
   }


   RecursiveMomentumContainer reco_sorted( -20., 20., -20., 20., -20., 20., 10 );
   for(SvtxTrackMap::Iter iter = trackmap->begin();iter != trackmap->end();++iter)
   {
   	SvtxTrack* track = iter->second;

   	TrivialTrack ttrack( track->get_px(), track->get_py(), track->get_pz(), track->get_x()-gvx, track->get_y()-gvy, track->get_z()-gvz, track->get_quality() );
   	reco_sorted.insert(ttrack);
   }


   TrivialTrack* t_track = true_sorted.begin();
   vector<TrivialTrack*> pointer_list;
   while(t_track != nullptr)
   {
   	pointer_list.clear();

   	float pt = sqrt((t_track->px * t_track->px) + (t_track->py * t_track->py));
   	float pt_diff = pt*pt_search_scale;
   	float px_lo = t_track->px - pt_diff;
   	float px_hi = t_track->px + pt_diff;
   	float py_lo = t_track->py - pt_diff;
   	float py_hi = t_track->py + pt_diff;
   	float pz_diff = fabs( t_track->pz )*pz_search_scale;
   	float pz_lo = t_track->pz - pz_diff;
   	float pz_hi = t_track->pz + pz_diff;

   	reco_sorted.append_list( pointer_list, px_lo,px_hi, py_lo,py_hi, pz_lo,pz_hi );

   	if(pointer_list.size() > 0)
   	{
   		float mom_true = sqrt(pt*pt + (t_track->pz)*(t_track->pz));
   		float best_ind = 0;
   		float mom_reco = sqrt( (pointer_list[0]->px)*(pointer_list[0]->px) + (pointer_list[0]->py)*(pointer_list[0]->py) + (pointer_list[0]->pz)*(pointer_list[0]->pz) );
   		float best_mom = mom_reco;
   		for(unsigned int i=1;i<pointer_list.size();++i)
   		{
   			mom_reco = sqrt( (pointer_list[i]->px)*(pointer_list[i]->px) + (pointer_list[i]->py)*(pointer_list[i]->py) + (pointer_list[i]->pz)*(pointer_list[i]->pz) );
   			if( fabs( mom_true - mom_reco ) < fabs( mom_true - best_mom )  )
   			{
   				best_mom = mom_reco;
   				best_ind = i;
   			}
   		}
   		
   		float ntp_data[14] = { (float) event_counter, t_track->px, t_track->py, t_track->pz, t_track->dcax, t_track->dcay, t_track->dcaz, pointer_list[best_ind]->px, pointer_list[best_ind]->py, pointer_list[best_ind]->pz, pointer_list[best_ind]->dcax, pointer_list[best_ind]->dcay, pointer_list[best_ind]->dcaz, pointer_list[best_ind]->quality };
   		ntp_true->Fill(ntp_data);
   	}
   	else
   	{
   		float ntp_data[14] = { (float) event_counter, t_track->px, t_track->py, t_track->pz, t_track->dcax, t_track->dcay, t_track->dcaz, -9999.,-9999.,-9999.,-9999.,-9999.,-9999., -9999. };
   		ntp_true->Fill(ntp_data);
   	}

   	t_track = true_sorted.next();
   }

   TrivialTrack* r_track = reco_sorted.begin();
   while(r_track != nullptr)
   {
   	pointer_list.clear();

   	float pt = sqrt((r_track->px * r_track->px) + (r_track->py * r_track->py));
   	float pt_diff = pt*pt_search_scale;
   	float px_lo = r_track->px - pt_diff;
   	float px_hi = r_track->px + pt_diff;
   	float py_lo = r_track->py - pt_diff;
   	float py_hi = r_track->py + pt_diff;
   	float pz_diff = fabs( r_track->pz )*pz_search_scale;
   	float pz_lo = r_track->pz - pz_diff;
   	float pz_hi = r_track->pz + pz_diff;

   	true_sorted.append_list( pointer_list, px_lo,px_hi, py_lo,py_hi, pz_lo,pz_hi );

   	if(pointer_list.size() > 0)
   	{
   		float mom_reco = sqrt(pt*pt + (r_track->pz)*(r_track->pz));
   		float best_ind = 0;
   		float mom_true = sqrt( (pointer_list[0]->px)*(pointer_list[0]->px) + (pointer_list[0]->py)*(pointer_list[0]->py) + (pointer_list[0]->pz)*(pointer_list[0]->pz) );
   		float best_mom = mom_true;
   		for(unsigned int i=1;i<pointer_list.size();++i)
   		{
   			mom_true = sqrt( (pointer_list[i]->px)*(pointer_list[i]->px) + (pointer_list[i]->py)*(pointer_list[i]->py) + (pointer_list[i]->pz)*(pointer_list[i]->pz) );
   			if( fabs( mom_reco - mom_true ) < fabs( mom_reco - best_mom )  )
   			{
   				best_mom = mom_true;
   				best_ind = i;
   			}
   		}
   		
   		float ntp_data[14] = { (float) event_counter, r_track->px, r_track->py, r_track->pz, r_track->dcax, r_track->dcay, r_track->dcaz, pointer_list[best_ind]->px, pointer_list[best_ind]->py, pointer_list[best_ind]->pz, pointer_list[best_ind]->dcax, pointer_list[best_ind]->dcay, pointer_list[best_ind]->dcaz, r_track->quality };
   		ntp_reco->Fill(ntp_data);
   	}
   	else
   	{
   		float ntp_data[14] = { (float) event_counter, r_track->px, r_track->py, r_track->pz, r_track->dcax, r_track->dcay, r_track->dcaz, -9999.,-9999.,-9999.,-9999.,-9999.,-9999., r_track->quality };
   		ntp_reco->Fill(ntp_data);
   	}

   	r_track = reco_sorted.next();
   }


   event_counter += 1;
   return Fun4AllReturnCodes::EVENT_OK;
}
Пример #5
0
void SvtxEvaluator::printOutputInfo(PHCompositeNode *topNode) {
  
  if (verbosity > 1) cout << "SvtxEvaluator::printOutputInfo() entered" << endl;

  //==========================================
  // print out some useful stuff for debugging
  //==========================================

  if (verbosity > 0) {
    
    SvtxTrackEval*     trackeval = _svtxevalstack->get_track_eval();
    SvtxClusterEval* clustereval = _svtxevalstack->get_cluster_eval();
    SvtxTruthEval*     trutheval = _svtxevalstack->get_truth_eval();
  
    // event information
    cout << endl;
    cout << PHWHERE << "   NEW OUTPUT FOR EVENT " << _ievent << endl;
    cout << endl;

    PHG4TruthInfoContainer* truthinfo = findNode::getClass<PHG4TruthInfoContainer>(topNode,"G4TruthInfo");
    
    PHG4VtxPoint *gvertex = truthinfo->GetPrimaryVtx( truthinfo->GetPrimaryVertexIndex() );
    float gvx = gvertex->get_x();
    float gvy = gvertex->get_y();
    float gvz = gvertex->get_z();

    float vx = NAN;
    float vy = NAN;
    float vz = NAN;

    SvtxVertexMap* vertexmap = findNode::getClass<SvtxVertexMap>(topNode,"SvtxVertexMap");    
    if (vertexmap) {
      if (!vertexmap->empty()) {
	SvtxVertex* vertex = (vertexmap->begin()->second);
	
	vx = vertex->get_x();
	vy = vertex->get_y();
	vz = vertex->get_z();
      }
    }

    cout << "===Vertex Reconstruction=======================" << endl;
    cout << "vtrue = (" << gvx << "," << gvy << "," << gvz << ") => vreco = (" << vx << "," << vy << "," << vz << ")" << endl;
    cout << endl;

    cout << "===Tracking Summary============================" << endl;
    unsigned int ng4hits[100] = {0};
    std::set<PHG4Hit*> g4hits = trutheval->all_truth_hits();
    for (std::set<PHG4Hit*>::iterator iter = g4hits.begin();
	 iter != g4hits.end();
	 ++iter) {
      PHG4Hit *g4hit = *iter;
      ++ng4hits[g4hit->get_layer()];
    }

    SvtxHitMap* hitmap = findNode::getClass<SvtxHitMap>(topNode,"SvtxHitMap");
    unsigned int nhits[100] = {0};
    if (hitmap) {
      for (SvtxHitMap::Iter iter = hitmap->begin();
	   iter != hitmap->end();
	   ++iter) {
	SvtxHit* hit = iter->second;
	++nhits[hit->get_layer()];
      }
    }
    
    SvtxClusterMap* clustermap = findNode::getClass<SvtxClusterMap>(topNode,"SvtxClusterMap");
    unsigned int nclusters[100] = {0};
    if (clustermap) {
      for (SvtxClusterMap::Iter iter = clustermap->begin();
	   iter != clustermap->end();
	   ++iter) {
	SvtxCluster* cluster = iter->second;
	++nclusters[cluster->get_layer()];
      }
    }

    for (unsigned int ilayer = 0; ilayer < 100; ++ilayer) {
      cout << "layer " << ilayer << ": nG4hits = " << ng4hits[ilayer]
	   << " => nHits = " << nhits[ilayer]
	   << " => nClusters = " << nclusters[ilayer] << endl;
    }

    SvtxTrackMap* trackmap = findNode::getClass<SvtxTrackMap>(topNode,"SvtxTrackMap");
    
    cout << "nGtracks = " << std::distance(truthinfo->GetPrimaryParticleRange().first,
					  truthinfo->GetPrimaryParticleRange().second);
    cout << " => nTracks = ";
    if (trackmap) cout << trackmap->size() << endl;
    else cout << 0 << endl;

    // cluster wise information
    if (verbosity > 1) {
 
      for(std::set<PHG4Hit*>::iterator iter = g4hits.begin();
	  iter != g4hits.end();
	  ++iter) {
	PHG4Hit *g4hit = *iter;

	cout << endl;
        cout << "===PHG4Hit===================================" << endl;
	cout << " PHG4Hit: "; g4hit->identify();

	std::set<SvtxCluster*> clusters = clustereval->all_clusters_from(g4hit);

	for (std::set<SvtxCluster*>::iterator jter = clusters.begin();
	     jter != clusters.end();
	     ++jter) {
	  SvtxCluster *cluster = *jter;
	  cout << "===Created-SvtxCluster================" << endl;      
	  cout << "SvtxCluster: "; cluster->identify();
	}
      }

      PHG4TruthInfoContainer::ConstRange range = truthinfo->GetPrimaryParticleRange();
      for (PHG4TruthInfoContainer::ConstIterator iter = range.first;
	   iter != range.second; 
	   ++iter) {
	
	PHG4Particle *particle = iter->second;

	// track-wise information
	cout << endl;

	cout << "=== Gtrack ===================================================" << endl;
	cout << " PHG4Particle id = " << particle->get_track_id() << endl;
	particle->identify();
	cout << " ptrue = (";
	cout.width(5); cout << particle->get_px();
	cout << ",";
	cout.width(5); cout << particle->get_py();
	cout << ",";
	cout.width(5); cout << particle->get_pz();
	cout << ")" << endl;

	cout << " vtrue = (";
	cout.width(5); cout << truthinfo->GetVtx(particle->get_vtx_id())->get_x();
	cout << ",";
	cout.width(5); cout << truthinfo->GetVtx(particle->get_vtx_id())->get_y();
	cout << ",";
	cout.width(5); cout << truthinfo->GetVtx(particle->get_vtx_id())->get_z();
	cout << ")" << endl;
	  
	cout << " pt = " << sqrt(pow(particle->get_px(),2)+pow(particle->get_py(),2)) << endl;
	cout << " phi = " << atan2(particle->get_py(),particle->get_px()) << endl;
	cout << " eta = " << asinh(particle->get_pz()/sqrt(pow(particle->get_px(),2)+pow(particle->get_py(),2))) << endl;
	  
	cout << " embed flag = " << truthinfo->isEmbeded(particle->get_track_id()) << endl;

	cout << " ---Associated-PHG4Hits-----------------------------------------" << endl;
	std::set<PHG4Hit*> g4hits = trutheval->all_truth_hits(particle);
	for(std::set<PHG4Hit*>::iterator jter = g4hits.begin();
	    jter != g4hits.end();
	    ++jter) {
	  PHG4Hit *g4hit = *jter;

	  float x = 0.5*(g4hit->get_x(0)+g4hit->get_x(1));
	  float y = 0.5*(g4hit->get_y(0)+g4hit->get_y(1));
	  float z = 0.5*(g4hit->get_z(0)+g4hit->get_z(1));
	      
	  cout << " #" << g4hit->get_hit_id() << " xtrue = (";
	  cout.width(5); cout << x;
	  cout << ",";
	  cout.width(5); cout << y;
	  cout << ",";
	  cout.width(5); cout << z;
	  cout << ")";

	  std::set<SvtxCluster*> clusters = clustereval->all_clusters_from(g4hit);
	  for (std::set<SvtxCluster*>::iterator kter = clusters.begin();
	       kter != clusters.end();
	       ++kter) {
	  
	    SvtxCluster *cluster = *kter;

	    float x = cluster->get_x();
	    float y = cluster->get_y();
	    float z = cluster->get_z();
		 
	    cout << " => #" << cluster->get_id(); 
	    cout << " xreco = (";
	    cout.width(5); cout << x;
	    cout << ",";
	    cout.width(5); cout << y;
	    cout << ",";
	    cout.width(5); cout << z;
	    cout << ")";
	  }

	  cout << endl;
	}

	if (trackmap&&clustermap) {

	  std::set<SvtxTrack*> tracks = trackeval->all_tracks_from(particle);
	  for (std::set<SvtxTrack*>::iterator jter = tracks.begin();
	       jter != tracks.end();
	       ++jter) {
	  
	    SvtxTrack *track = *jter;

	    float px = track->get_px();
	    float py = track->get_py();
	    float pz = track->get_pz();

	    cout << "===Created-SvtxTrack==========================================" << endl;
	    cout << " SvtxTrack id = " << track->get_id() << endl;
	    cout << " preco = (";
	    cout.width(5); cout << px;
	    cout << ",";
	    cout.width(5); cout << py;
	    cout << ",";
	    cout.width(5); cout << pz;
	    cout << ")" << endl;
	    cout << " quality = " << track->get_quality() << endl;
	    cout << " nfromtruth = " << trackeval->get_nclusters_contribution(track,particle) << endl;

	    cout << " ---Associated-SvtxClusters-to-PHG4Hits-------------------------" << endl;    

	    for (SvtxTrack::ConstClusterIter iter = track->begin_clusters();
		 iter != track->end_clusters();
		 ++iter) {
	      unsigned int cluster_id = *iter;
	      SvtxCluster* cluster = clustermap->get(cluster_id);
	      		  
	      float x = cluster->get_x();
	      float y = cluster->get_y();
	      float z = cluster->get_z();
			  
	      cout << " #" << cluster->get_id() << " xreco = (";
	      cout.width(5); cout << x;
	      cout << ",";
	      cout.width(5); cout << y;
	      cout << ",";
	      cout.width(5); cout << z;
	      cout << ") =>";

	      PHG4Hit* g4hit = clustereval->max_truth_hit_by_energy(cluster);
	      if ((g4hit) && (g4hit->get_trkid() == particle->get_track_id())) {
			  
		x = 0.5*(g4hit->get_x(0)+g4hit->get_x(1));
		y = 0.5*(g4hit->get_y(0)+g4hit->get_y(1));
		z = 0.5*(g4hit->get_z(0)+g4hit->get_z(1));
			    
		cout << " #" << g4hit->get_hit_id()
		     << " xtrue = (";
		cout.width(5); cout << x;
		cout << ",";
		cout.width(5); cout << y;
		cout << ",";
		cout.width(5); cout << z;
		cout << ") => Gtrack id = " << g4hit->get_trkid();
	      } else {
		cout << " noise hit";
	      }
	    }
  
	    cout << endl;
	  }
	}
      }
    }
      
    cout << endl;

  } // if verbosity

  return;
}
Пример #6
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;
}