int PhotonJet::process_event(PHCompositeNode *topnode) { cout<<"at event number "<<nevents<<endl; //get the nodes from the NodeTree JetMap* truth_jets = findNode::getClass<JetMap>(topnode,"AntiKt_Truth_r04"); JetMap *reco_jets = findNode::getClass<JetMap>(topnode,"AntiKt_Tower_r04"); PHG4TruthInfoContainer* truthinfo = findNode::getClass<PHG4TruthInfoContainer>(topnode,"G4TruthInfo"); RawClusterContainer *clusters = findNode::getClass<RawClusterContainer>(topnode,"CLUSTER_CEMC"); SvtxTrackMap *trackmap = findNode::getClass<SvtxTrackMap>(topnode,"SvtxTrackMap"); JetEvalStack* _jetevalstack = new JetEvalStack(topnode,"AntiKt_Tower_r04","AntiKt_Truth_r04"); PHG4TruthInfoContainer::Range range = truthinfo->GetPrimaryParticleRange(); if(!truth_jets){ cout<<"no truth jets"<<endl; return 0; } if(!reco_jets){ cout<<"no reco jets"<<endl; return 0; } if(!truthinfo){ cout<<"no truth track info"<<endl; return 0; } if(!clusters){ cout<<"no cluster info"<<endl; return 0; } if(!trackmap){ cout<<"no track map"<<endl; return 0; } if(!_jetevalstack){ cout<<"no good truth jets"<<endl; return 0; } JetRecoEval* recoeval = _jetevalstack->get_reco_eval(); /*********************************************** GET THE TRUTH PARTICLES ************************************************/ for( PHG4TruthInfoContainer::ConstIterator iter = range.first; iter!=range.second; ++iter){ PHG4Particle *truth = iter->second; truthpx = truth->get_px(); truthpy = truth->get_py(); truthpz = truth->get_pz(); truthp = sqrt(truthpx*truthpx+truthpy*truthpy+truthpz*truthpz); truthenergy = truth->get_e(); TLorentzVector vec; vec.SetPxPyPzE(truthpx,truthpy,truthpz,truthenergy); truthpt = sqrt(truthpx*truthpx+truthpy*truthpy); if(truthpt<0.5) continue; truthphi = vec.Phi(); trutheta = vec.Eta(); truthpid = truth->get_pid(); truth_g4particles->Fill(); } /*********************************************** GET THE EMCAL CLUSTERS ************************************************/ RawClusterContainer::ConstRange begin_end = clusters->getClusters(); RawClusterContainer::ConstIterator clusiter; for(clusiter = begin_end.first; clusiter!=begin_end.second; ++clusiter){ RawCluster *cluster = clusiter->second; clus_energy = cluster->get_energy(); clus_eta = cluster->get_eta(); clus_theta = 2.*TMath::ATan((TMath::Exp(-1.*clus_eta))); clus_pt = clus_energy*TMath::Sin(clus_theta); clus_phi = cluster->get_phi(); if(clus_pt<0.5) continue; TLorentzVector *clus = new TLorentzVector(); clus->SetPtEtaPhiE(clus_pt,clus_eta,clus_phi,clus_energy); float dumarray[4]; clus->GetXYZT(dumarray); clus_x = dumarray[0]; clus_y = dumarray[1]; clus_z = dumarray[2]; clus_t = dumarray[3]; clus_px = clus_pt*TMath::Cos(clus_phi); clus_py = clus_pt*TMath::Sin(clus_phi); clus_pz = sqrt(clus_energy*clus_energy-clus_px*clus_px-clus_py*clus_py); cluster_tree->Fill(); //only interested in high pt photons to be isolated if(clus_pt<mincluspt) continue; if(fabs(clus_eta)>(1.0-isoconeradius)) continue; float energysum = ConeSum(cluster,clusters,trackmap,isoconeradius); bool conecut = energysum > 0.1*clus_energy; if(conecut) continue; isolated_clusters->Fill(); GetRecoHadronsAndJets(cluster, trackmap, reco_jets,recoeval); } /*********************************************** GET THE SVTX TRACKS ************************************************/ SvtxEvalStack *svtxevalstack = new SvtxEvalStack(topnode); svtxevalstack->next_event(topnode); SvtxTrackEval *trackeval = svtxevalstack->get_track_eval(); for(SvtxTrackMap::Iter iter = trackmap->begin(); iter!=trackmap->end(); ++iter){ SvtxTrack *track = iter->second; //get reco info tr_px = track->get_px(); tr_py = track->get_py(); tr_pz = track->get_pz(); tr_p = sqrt(tr_px*tr_px+tr_py*tr_py+tr_pz*tr_pz); tr_pt = sqrt(tr_px*tr_px+tr_py*tr_py); if(tr_pt<0.5) continue; tr_phi = track->get_phi(); tr_eta = track->get_eta(); if(fabs(tr_eta)>1) continue; charge = track->get_charge(); chisq = track->get_chisq(); ndf = track->get_ndf(); dca = track->get_dca(); tr_x = track->get_x(); tr_y = track->get_y(); tr_z = track->get_z(); //get truth info PHG4Particle *truthtrack = trackeval->max_truth_particle_by_nclusters(track); truth_is_primary = truthinfo->is_primary(truthtrack); truthtrackpx = truthtrack->get_px(); truthtrackpy = truthtrack->get_py(); truthtrackpz = truthtrack->get_pz(); truthtrackp = sqrt(truthtrackpx*truthtrackpx+truthtrackpy*truthtrackpy+truthtrackpz*truthtrackpz); truthtracke = truthtrack->get_e(); TLorentzVector *Truthtrack = new TLorentzVector(); Truthtrack->SetPxPyPzE(truthtrackpx,truthtrackpy,truthtrackpz,truthtracke); truthtrackpt = Truthtrack->Pt(); truthtrackphi = Truthtrack->Phi(); truthtracketa = Truthtrack->Eta(); truthtrackpid = truthtrack->get_pid(); tracktree->Fill(); } /*************************************** TRUTH JETS ***************************************/ for(JetMap::Iter iter = truth_jets->begin(); iter!=truth_jets->end(); ++iter){ Jet *jet = iter->second; truthjetpt = jet->get_pt(); if(truthjetpt<10.) continue; truthjeteta = jet->get_eta(); if(fabs(truthjeteta)>2.) continue; truthjetpx = jet->get_px(); truthjetpy = jet->get_py(); truthjetpz = jet->get_pz(); truthjetphi = jet->get_phi(); truthjetmass = jet->get_mass(); truthjetp = jet->get_p(); truthjetenergy = jet->get_e(); truthjettree->Fill(); } /*************************************** RECONSTRUCTED JETS ***************************************/ for(JetMap::Iter iter = reco_jets->begin(); iter!=reco_jets->end(); ++iter){ Jet *jet = iter->second; Jet *truthjet = recoeval->max_truth_jet_by_energy(jet); recojetpt = jet->get_pt(); if(recojetpt<4.) continue; recojeteta = jet->get_eta(); if(fabs(recojeteta)>2.) continue; recojetid = jet->get_id(); recojetpx = jet->get_px(); recojetpy = jet->get_py(); recojetpz = jet->get_pz(); recojetphi = jet->get_phi(); recojetmass = jet->get_mass(); recojetp = jet->get_p(); recojetenergy = jet->get_e(); if(truthjet){ truthjetid = truthjet->get_id(); truthjetp = truthjet->get_p(); truthjetphi = truthjet->get_phi(); truthjeteta = truthjet->get_eta(); truthjetpt = truthjet->get_pt(); truthjetenergy = truthjet->get_e(); truthjetpx = truthjet->get_px(); truthjetpy = truthjet->get_py(); truthjetpz = truthjet->get_pz(); } else{ truthjetid = 0; truthjetp = 0; truthjetphi = 0; truthjeteta = 0; truthjetpt = 0; truthjetenergy = 0; truthjetpx = 0; truthjetpy = 0; truthjetpz = 0; } recojettree->Fill(); } nevents++; tree->Fill(); return 0; }
void PhotonJet::GetRecoHadronsAndJets(RawCluster *trig, SvtxTrackMap *tracks, JetMap *jets, JetRecoEval *recoeval) { float trig_phi = trig->get_phi(); float trig_eta = trig->get_eta(); for(SvtxTrackMap::Iter iter = tracks->begin(); iter!=tracks->end(); ++iter){ SvtxTrack *track = iter->second; _tr_px = track->get_px(); _tr_py = track->get_py(); _tr_pz = track->get_pz(); _tr_pt = sqrt(_tr_px*_tr_px+_tr_py*_tr_py); if(_tr_pt<0.5) continue; _tr_p = sqrt(_tr_px*_tr_px+_tr_py*_tr_py+_tr_pz*_tr_pz); _tr_phi = track->get_phi(); _tr_eta = track->get_eta(); _charge = track->get_charge(); _chisq = track->get_chisq(); _ndf = track->get_ndf(); _dca = track->get_dca(); _tr_x = track->get_x(); _tr_y = track->get_y(); _tr_z = track->get_z(); haddphi = trig_phi-_tr_phi; if(haddphi<pi2) haddphi+=2.*pi; if(haddphi>threepi2) haddphi-=2.*pi; haddeta = trig_eta-_tr_eta; hadpout = _tr_p*TMath::Sin(haddphi); isophot_had_tree->Fill(); } for(JetMap::Iter iter = jets->begin(); iter!=jets->end(); ++iter){ Jet* jet = iter->second; Jet *truthjet = recoeval->max_truth_jet_by_energy(jet); _recojetpt = jet->get_pt(); if(_recojetpt<4.0) continue; _recojeteta = jet->get_eta(); if(fabs(_recojeteta)>1.) continue; _recojetpx = jet->get_px(); _recojetpy = jet->get_py(); _recojetpz = jet->get_pz(); _recojetphi = jet->get_phi(); _recojetmass = jet->get_mass(); _recojetp = jet->get_p(); _recojetenergy = jet->get_e(); _recojetid = jet->get_id(); if(truthjet){ _truthjetid = truthjet->get_id(); _truthjetp = truthjet->get_p(); _truthjetphi = truthjet->get_phi(); _truthjeteta = truthjet->get_eta(); _truthjetpt = truthjet->get_pt(); _truthjetenergy = truthjet->get_e(); _truthjetpx = truthjet->get_px(); _truthjetpy = truthjet->get_py(); _truthjetpz = truthjet->get_pz(); } else{ _truthjetid = 0; _truthjetp = 0; _truthjetphi = 0; _truthjeteta = 0; _truthjetpt = 0; _truthjetenergy = 0; _truthjetpx = 0; _truthjetpy = 0; _truthjetpz = 0; } jetdphi = trig_phi-_recojetphi; if(jetdphi<pi2) jetdphi+=2.*pi; if(jetdphi>threepi2) jetdphi-=2.*pi; jetdeta = trig_eta-_recojeteta; jetpout = _recojetpt*TMath::Sin(jetdphi); isophot_jet_tree->Fill(); } }