void CaloEvaluator::fillOutputNtuples(PHCompositeNode *topNode) { if (verbosity > 2) cout << "CaloEvaluator::fillOutputNtuples() entered" << endl; CaloRawClusterEval* clustereval = _caloevalstack->get_rawcluster_eval(); CaloRawTowerEval* towereval = _caloevalstack->get_rawtower_eval(); CaloTruthEval* trutheval = _caloevalstack->get_truth_eval(); //---------------------- // fill the Event NTuple //---------------------- if (_do_gpoint_eval) { // need things off of the DST... PHG4TruthInfoContainer* truthinfo = findNode::getClass<PHG4TruthInfoContainer>(topNode,"G4TruthInfo"); if (!truthinfo) { cerr << PHWHERE << " ERROR: Can't find G4TruthInfo" << endl; exit(-1); } // need things off of the DST... SvtxVertexMap* vertexmap = findNode::getClass<SvtxVertexMap>(topNode,"SvtxVertexMap"); 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; if (vertexmap) { if (!vertexmap->empty()) { SvtxVertex* vertex = (vertexmap->begin()->second); vx = vertex->get_x(); vy = vertex->get_y(); vz = vertex->get_z(); } } float gpoint_data[7] = {_ievent, gvx, gvy, gvz, vx, vy, vz }; _ntp_gpoint->Fill(gpoint_data); } //------------------------ // fill the Gshower NTuple //------------------------ if (_ntp_gshower) { if (verbosity > 1) cout << "CaloEvaluator::filling gshower ntuple..." << endl; PHG4TruthInfoContainer* truthinfo = findNode::getClass<PHG4TruthInfoContainer>(topNode,"G4TruthInfo"); if (!truthinfo) { cerr << PHWHERE << " ERROR: Can't find G4TruthInfo" << endl; exit(-1); } PHG4TruthInfoContainer::ConstRange range = truthinfo->GetPrimaryParticleRange(); for (PHG4TruthInfoContainer::ConstIterator iter = range.first; iter != range.second; ++iter) { PHG4Particle* primary = iter->second; if (primary->get_e() < _truth_e_threshold) continue; if (!_truth_trace_embed_flags.empty()) { if (_truth_trace_embed_flags.find(trutheval->get_embed(primary)) == _truth_trace_embed_flags.end()) continue; } float gparticleID = primary->get_track_id(); float gflavor = primary->get_pid(); std::set<PHG4Hit*> g4hits = trutheval->get_shower_from_primary(primary); float gnhits = g4hits.size(); float gpx = primary->get_px(); float gpy = primary->get_py(); float gpz = primary->get_pz(); float ge = primary->get_e(); float gpt = sqrt(gpx*gpx+gpy*gpy); float geta = NAN; if (gpt != 0.0) geta = asinh(gpz/gpt); float gphi = atan2(gpy,gpx); PHG4VtxPoint* vtx = trutheval->get_vertex(primary); float gvx = vtx->get_x(); float gvy = vtx->get_y(); float gvz = vtx->get_z(); float gembed = trutheval->get_embed(primary); float gedep = trutheval->get_shower_energy_deposit(primary); float gmrad = trutheval->get_shower_moliere_radius(primary); RawCluster* cluster = clustereval->best_cluster_from(primary); float clusterID = NAN; float ntowers = NAN; float eta = NAN; float phi = NAN; float e = NAN; float efromtruth = NAN; if (cluster) { clusterID = cluster->get_id(); ntowers = cluster->getNTowers(); eta = cluster->get_eta(); phi = cluster->get_phi(); e = cluster->get_energy(); efromtruth = clustereval->get_energy_contribution(cluster, primary); } float shower_data[20] = {_ievent, gparticleID, gflavor, gnhits, geta, gphi, ge, gpt, gvx, gvy, gvz, gembed, gedep, gmrad, clusterID, ntowers, eta, phi, e, efromtruth }; _ntp_gshower->Fill(shower_data); } } //---------------------- // fill the Tower NTuple //---------------------- if (_do_tower_eval) { if (verbosity > 1) cout << "CaloEvaluator::filling tower ntuple..." << endl; string towernode = "TOWER_CALIB_" + _caloname; RawTowerContainer* towers = findNode::getClass<RawTowerContainer>(topNode,towernode.c_str()); if (!towers) { cerr << PHWHERE << " ERROR: Can't find " << towernode << endl; exit(-1); } string towergeomnode = "TOWERGEOM_" + _caloname; RawTowerGeomContainer* towergeom = findNode::getClass<RawTowerGeomContainer>(topNode,towergeomnode.c_str()); if (!towergeom) { cerr << PHWHERE << " ERROR: Can't find " << towergeomnode << endl; exit(-1); } RawTowerContainer::ConstRange begin_end = towers->getTowers(); RawTowerContainer::ConstIterator rtiter; for (rtiter = begin_end.first; rtiter != begin_end.second; ++rtiter) { RawTower *tower = rtiter->second; if (tower->get_energy() < _reco_e_threshold) continue; float towerid = tower->get_id(); float ieta = tower->get_bineta(); float iphi = tower->get_binphi(); float eta = towergeom->get_etacenter(tower->get_bineta()); float phi = towergeom->get_phicenter(tower->get_binphi()); float e = tower->get_energy(); PHG4Particle* primary = towereval->max_truth_primary_by_energy(tower); float gparticleID = NAN; float gflavor = NAN; float gnhits = NAN; float gpx = NAN; float gpy = NAN; float gpz = NAN; float ge = NAN; float gpt = NAN; float geta = NAN; float gphi = NAN; float gvx = NAN; float gvy = NAN; float gvz = NAN; float gembed = NAN; float gedep = NAN; float gmrad = NAN; float efromtruth = NAN; if (primary) { gparticleID = primary->get_track_id(); gflavor = primary->get_pid(); std::set<PHG4Hit*> g4hits = trutheval->get_shower_from_primary(primary); gnhits = g4hits.size(); gpx = primary->get_px(); gpy = primary->get_py(); gpz = primary->get_pz(); ge = primary->get_e(); gpt = sqrt(gpx * gpx + gpy * gpy); if (gpt != 0.0) geta = asinh(gpz / gpt); gphi = atan2(gpy, gpx); PHG4VtxPoint* vtx = trutheval->get_vertex(primary); if (vtx) { gvx = vtx->get_x(); gvy = vtx->get_y(); gvz = vtx->get_z(); } gembed = trutheval->get_embed(primary); gedep = trutheval->get_shower_energy_deposit(primary); gmrad = trutheval->get_shower_moliere_radius(primary); efromtruth = towereval->get_energy_contribution(tower, primary); } float tower_data[21] = {_ievent, towerid, ieta, iphi, eta, phi, e, gparticleID, gflavor, gnhits, geta, gphi, ge, gpt, gvx, gvy, gvz, gembed, gedep, gmrad, efromtruth }; _ntp_tower->Fill(tower_data); } } //------------------------ // fill the Cluster NTuple //------------------------ if (_do_cluster_eval) { if (verbosity > 1) cout << "CaloEvaluator::filling gcluster ntuple..." << endl; string clusternode = "CLUSTER_" + _caloname; RawClusterContainer* clusters = findNode::getClass<RawClusterContainer>(topNode,clusternode.c_str()); if (!clusters) { cerr << PHWHERE << " ERROR: Can't find " << clusternode << endl; exit(-1); } // for every cluster for (unsigned int icluster = 0; icluster < clusters->size(); icluster++) { RawCluster *cluster = clusters->getCluster(icluster); if (cluster->get_energy() < _reco_e_threshold) continue; float clusterID = cluster->get_id(); float ntowers = cluster->getNTowers(); float eta = cluster->get_eta(); float phi = cluster->get_phi(); float e = cluster->get_energy(); PHG4Particle* primary = clustereval->max_truth_primary_by_energy(cluster); float gparticleID = NAN; float gflavor = NAN; float gnhits = NAN; float gpx = NAN; float gpy = NAN; float gpz = NAN; float ge = NAN; float gpt = NAN; float geta = NAN; float gphi = NAN; float gvx = NAN; float gvy = NAN; float gvz = NAN; float gembed = NAN; float gedep = NAN; float gmrad = NAN; float efromtruth = NAN; if (primary) { gparticleID = primary->get_track_id(); gflavor = primary->get_pid(); std::set<PHG4Hit*> g4hits = trutheval->get_shower_from_primary(primary); gnhits = g4hits.size(); gpx = primary->get_px(); gpy = primary->get_py(); gpz = primary->get_pz(); ge = primary->get_e(); gpt = sqrt(gpx * gpx + gpy * gpy); if (gpt != 0.0) geta = asinh(gpz / gpt); gphi = atan2(gpy, gpx); PHG4VtxPoint* vtx = trutheval->get_vertex(primary); if (vtx) { gvx = vtx->get_x(); gvy = vtx->get_y(); gvz = vtx->get_z(); } gembed = trutheval->get_embed(primary); gedep = trutheval->get_shower_energy_deposit(primary); gmrad = trutheval->get_shower_moliere_radius(primary); efromtruth = clustereval->get_energy_contribution(cluster, primary); } float cluster_data[20] = {_ievent, clusterID, ntowers, eta, phi, e, gparticleID, gflavor, gnhits, geta, gphi, ge, gpt, gvx, gvy, gvz, gembed, gedep, gmrad, efromtruth }; _ntp_cluster->Fill(cluster_data); } } return; }
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; }
void CaloEvaluator::printOutputInfo(PHCompositeNode *topNode) { if (verbosity > 2) cout << "CaloEvaluator::printOutputInfo() entered" << endl; CaloRawClusterEval* clustereval = _caloevalstack->get_rawcluster_eval(); CaloTruthEval* trutheval = _caloevalstack->get_truth_eval(); //========================================== // print out some useful stuff for debugging //========================================== if (verbosity > 1) { // event information cout << endl; cout << PHWHERE << " NEW OUTPUT FOR EVENT " << _ievent << endl; cout << endl; // need things off of the DST... PHG4TruthInfoContainer* truthinfo = findNode::getClass<PHG4TruthInfoContainer>(topNode,"G4TruthInfo"); if (!truthinfo) { cerr << PHWHERE << " ERROR: Can't find G4TruthInfo" << endl; exit(-1); } // need things off of the DST... SvtxVertexMap* vertexmap = findNode::getClass<SvtxVertexMap>(topNode,"SvtxVertexMap"); 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; if (vertexmap) { if (!vertexmap->empty()) { SvtxVertex* vertex = (vertexmap->begin()->second); vx = vertex->get_x(); vy = vertex->get_y(); vz = vertex->get_z(); } } cout << "vtrue = (" << gvx << "," << gvy << "," << gvz << ") => vreco = (" << vx << "," << vy << "," << vz << ")" << endl; PHG4TruthInfoContainer::ConstRange range = truthinfo->GetPrimaryParticleRange(); for (PHG4TruthInfoContainer::ConstIterator iter = range.first; iter != range.second; ++iter) { PHG4Particle* primary = iter->second; cout << endl; cout << "===Primary PHG4Particle=========================================" << endl; cout << " particle id = " << primary->get_track_id() << endl; cout << " flavor = " << primary->get_pid() << endl; cout << " (px,py,pz,e) = ("; float gpx = primary->get_px(); float gpy = primary->get_py(); float gpz = primary->get_pz(); float ge = primary->get_e(); cout.width(5); cout << gpx; cout << ","; cout.width(5); cout << gpy; cout << ","; cout.width(5); cout << gpz; cout << ","; cout.width(5); cout << ge; cout << ")" << endl; float gpt = sqrt(gpx*gpx+gpy*gpy); float geta = NAN; if (gpt != 0.0) geta = asinh(gpz/gpt); float gphi = atan2(gpy,gpx); cout << "(eta,phi,e,pt) = ("; cout.width(5); cout << geta; cout << ","; cout.width(5); cout << gphi; cout << ","; cout.width(5); cout << ge; cout << ","; cout.width(5); cout << gpt; cout << ")" << endl; PHG4VtxPoint* vtx = trutheval->get_vertex(primary); float gvx = vtx->get_x(); float gvy = vtx->get_y(); float gvz = vtx->get_z(); cout << " vtrue = ("; cout.width(5); cout << gvx; cout << ","; cout.width(5); cout << gvy; cout << ","; cout.width(5); cout << gvz; cout << ")" << endl; cout << " embed = " << trutheval->get_embed(primary) << endl; cout << " edep = " << trutheval->get_shower_energy_deposit(primary) << endl; cout << " mrad = " << trutheval->get_shower_moliere_radius(primary) << endl; std::set<RawCluster*> clusters = clustereval->all_clusters_from(primary); for (std::set<RawCluster*>::iterator clusiter = clusters.begin(); clusiter != clusters.end(); ++clusiter) { RawCluster* cluster = (*clusiter); float ntowers = cluster->getNTowers(); float eta = cluster->get_eta(); float phi = cluster->get_phi(); float e = cluster->get_energy(); float efromtruth = clustereval->get_energy_contribution(cluster, primary); cout << " => #" << cluster->get_id() << " (eta,phi,e) = ("; cout.width(5); cout << eta; cout << ","; cout.width(5); cout << phi; cout << ","; cout.width(5); cout << e; cout << "), ntowers = "<< ntowers <<", efromtruth = " << efromtruth << endl; } } cout << endl; } return; }