10 #include <calobase/RawCluster.h>
11 #include <calobase/RawClusterContainer.h>
12 #include <calobase/RawClusterUtility.h>
13 #include <calobase/RawTower.h>
14 #include <calobase/RawTowerContainer.h>
15 #include <calobase/RawTowerGeom.h>
16 #include <calobase/RawTowerGeomContainer.h>
17 #include <calotrigger/CaloTriggerInfo.h>
19 #include <g4jets/Jet.h>
20 #include <g4jets/JetMap.h>
21 #include <g4vertex/GlobalVertex.h>
22 #include <g4vertex/GlobalVertexMap.h>
25 #include <trackbase_historic/SvtxVertex.h>
26 #include <trackbase_historic/SvtxVertexMap.h>
34 #include <HepMC/GenEvent.h>
35 #include <HepMC/GenVertex.h>
40 #include <TLorentzVector.h>
99 cout <<
"COLLECTING PHOTON-JET PAIRS FOR THE FOLLOWING: " << endl;
101 cout <<
"GATHERING IN ETA: [" <<
etalow
102 <<
"," <<
etahigh <<
"]" << endl;
104 cout <<
"USING ISOLATION CONE: " <<
use_isocone << endl;
113 ";E_{photon}/E_{jet}; Counts", 200, 0, 2);
114 histo =
new TH1F(
"histo",
"histo", 100, -3, 3);
117 tree =
new TTree(
"tree",
"a tree");
130 cout <<
"at event number " <<
nevents << endl;
133 ostringstream truthjetsize;
134 ostringstream recojetsize;
135 ostringstream trackjetsize;
138 truthjetsize.str(
"");
139 truthjetsize <<
"AntiKt_Truth_r";
141 recojetsize <<
"AntiKt_Tower_r";
142 trackjetsize.str(
"");
143 trackjetsize <<
"AntiKt_Track_r";
147 truthjetsize <<
"02";
149 trackjetsize <<
"02";
153 truthjetsize <<
"03";
155 trackjetsize <<
"03";
159 truthjetsize <<
"04";
161 trackjetsize <<
"04";
165 truthjetsize <<
"05";
167 trackjetsize <<
"05";
171 truthjetsize <<
"06";
173 trackjetsize <<
"06";
178 truthjetsize <<
"07";
180 trackjetsize <<
"07";
186 truthjetsize <<
"04";
192 cout <<
"Gathering RECO Jets: " << recojetsize.str().c_str() << endl;
193 cout <<
"Gathering TRUTH Jets: " << truthjetsize.str().c_str() << endl;
200 findNode::getClass<JetMap>(topnode, truthjetsize.str().c_str());
205 reco_jets = findNode::getClass<JetMap>(topnode, recojetsize.str().c_str());
209 findNode::getClass<JetMap>(topnode, trackjetsize.str().c_str());
217 clusters = findNode::getClass<RawClusterContainer>(topnode,
"CLUSTER_CEMC");
221 clusters = findNode::getClass<RawClusterContainer>(topnode,
"CLUSTER_POS_COR_CEMC");
224 SvtxTrackMap *trackmap = findNode::getClass<SvtxTrackMap>(topnode,
"SvtxTrackMap");
227 CaloTriggerInfo *trigger = findNode::getClass<CaloTriggerInfo>(topnode,
"CaloTriggerInfo");
237 recojetsize <<
"_Sub1";
239 findNode::getClass<JetMap>(topnode, recojetsize.str().c_str());
247 truthjetsize.str().c_str());
253 "AntiKt_Tower_r04_Sub1",
256 GlobalVertexMap *vertexmap = findNode::getClass<GlobalVertexMap>(topnode,
"GlobalVertexMap");
259 cout <<
"PhotonJet::process_event - Fatal Error - GlobalVertexMap node is missing. Please turn on the do_global flag in the main macro in order to reconstruct the global vertex." << endl;
265 if (vertexmap->
empty())
267 cout <<
"PhotonJet::process_event - Fatal Error - GlobalVertexMap node is empty. Please turn on the do_global flag in the main macro in order to reconstruct the global vertex." << endl;
272 if (vtx ==
nullptr)
return 0;
275 RawTowerContainer *_cemctowers = findNode::getClass<RawTowerContainer>(topnode,
"TOWER_CALIB_CEMC");
276 RawTowerContainer *_hcalintowers = findNode::getClass<RawTowerContainer>(topnode,
"TOWER_CALIB_HCALIN");
277 RawTowerContainer *_hcalouttowers = findNode::getClass<RawTowerContainer>(topnode,
"TOWER_CALIB_HCALOUT");
278 RawTowerGeomContainer *_cemctowergeom = findNode::getClass<RawTowerGeomContainer>(topnode,
"TOWERGEOM_CEMC");
279 RawTowerGeomContainer *_hcalintowergeom = findNode::getClass<RawTowerGeomContainer>(topnode,
"TOWERGEOM_HCALIN");
280 RawTowerGeomContainer *_hcalouttowergeom = findNode::getClass<RawTowerGeomContainer>(topnode,
"TOWERGEOM_HCALOUT");
293 cout <<
"NO TRIGGER EMULATOR, BAILING" << endl;
298 cout <<
"no tracked jets, bailing" << endl;
303 cout <<
"no truth jets" << endl;
308 cout <<
"no reco jets" << endl;
313 cout <<
"no truth track info" << endl;
318 cout <<
"no cluster info" << endl;
323 cout <<
"no track map" << endl;
328 cout <<
"no good truth jets" << endl;
347 PHHepMCGenEventMap *hepmceventmap = findNode::getClass<PHHepMCGenEventMap>(topnode,
"PHHepMCGenEventMap");
351 cout <<
"hepmc event map node is missing, BAILING" << endl;
357 cout <<
"Getting HEPMC truth particles " << endl;
363 iterr != hepmceventmap->
end();
371 HepMC::GenEvent *truthevent = hepmcevent->
getEvent();
374 cout <<
PHWHERE <<
"no evt pointer under phhepmvgeneventmap found " << endl;
379 if (truthevent->valid_beam_particles())
381 HepMC::GenParticle *part1 = truthevent->beam_particles().first;
388 HepMC::PdfInfo *pdfinfo = truthevent->pdf_info();
396 mpi = truthevent->mpi();
404 for (HepMC::GenEvent::particle_const_iterator iter = truthevent->particles_begin();
405 iter != truthevent->particles_end();
412 trutheta = (*iter)->momentum().pseudoRapidity();
413 truthphi = (*iter)->momentum().phi();
414 truthpx = (*iter)->momentum().px();
415 truthpy = (*iter)->momentum().py();
416 truthpz = (*iter)->momentum().pz();
431 float lastenergy = 0;
435 cout <<
"get G4 stable truth particles" << endl;
440 iter != range.second;
487 cout <<
"get the truth jets" << endl;
491 float hardest_jet = 0;
499 iter != truth_jets->
end();
502 Jet *jet = iter->second;
528 std::set<PHG4Particle *> truthjetcomp =
531 float truthjetenergysum = 0;
532 float truthjethighestphoton = 0;
534 for (std::set<PHG4Particle *>::iterator iter2 = truthjetcomp.begin();
535 iter2 != truthjetcomp.end();
542 cout <<
"no truth particles in the jet??" << endl;
548 int constpid = truthpart->
get_pid();
549 float conste = truthpart->
get_e();
551 truthjetenergysum += conste;
555 if (conste > truthjethighestphoton)
556 truthjethighestphoton = conste;
568 if (percent_photon > 0.8)
597 cout <<
"get trigger emulator info" << endl;
607 E_4x4 = trigger->get_best_EMCal_4x4_E();
608 phi_4x4 = trigger->get_best_EMCal_4x4_phi();
609 eta_4x4 = trigger->get_best_EMCal_4x4_eta();
612 E_2x2 = trigger->get_best_EMCal_2x2_E();
613 phi_2x2 = trigger->get_best_EMCal_2x2_phi();
614 eta_2x2 = trigger->get_best_EMCal_2x2_eta();
624 cout <<
"Get EMCal Cluster" << endl;
631 for (clusiter = begin_end.first;
632 clusiter != begin_end.second;
645 clus_eta = E_vec_cluster.pseudoRapidity();
647 clus_pt = E_vec_cluster.perp();
658 TLorentzVector *clus =
new TLorentzVector();
662 clus->GetXYZT(dumarray);
696 iter != range.second;
743 reco_jets, tracked_jets,
768 cout <<
"Get the Tracks" << endl;
771 iter != trackmap->end();
790 if (tr_eta < etalow || tr_eta >
etahigh)
812 TLorentzVector *Truthtrack =
new TLorentzVector();
831 cout <<
"Get all Reco Jets" << endl;
835 iter != reco_jets->end();
838 Jet *jet = iter->second;
877 std::set<PHG4Particle *> truthjetcomp =
880 float truthjetenergysum = 0;
881 float truthjethighestphoton = 0;
882 for (std::set<PHG4Particle *>::iterator iter2 = truthjetcomp.begin();
883 iter2 != truthjetcomp.end();
889 cout <<
"no truth particles in the jet??" << endl;
894 int constpid = truthpart->
get_pid();
895 float conste = truthpart->
get_e();
897 truthjetenergysum += conste;
901 if (conste > truthjethighestphoton)
902 truthjethighestphoton = conste;
909 if (percent_photon > 0.8)
923 cout <<
"matching by distance jet" << endl;
938 float closestjet = 9999;
940 iter3 != truth_jets->
end();
943 Jet *jet = iter3->second;
945 float thisjetpt = jet->
get_pt();
949 float thisjeteta = jet->
get_eta();
950 float thisjetphi = jet->
get_phi();
953 if (dphi > 3. *
pi / 2.)
955 if (dphi < -1. *
pi / 2.)
960 dR = sqrt(pow(dphi, 2.) + pow(deta, 2.));
962 if (dR < reco_jets->get_par() &&
dR < closestjet)
994 unsigned int index = constiter->second;
999 thetower = _cemctowers->
getTower(index);
1003 thetower = _hcalintowers->getTower(index);
1007 thetower = _hcalouttowers->getTower(index);
1015 double constphi = -9999;
1016 double consteta = -9999;
1019 constphi = _cemctowergeom->get_phicenter(tower_phi_bin);
1020 consteta = _cemctowergeom->get_etacenter(tower_eta_bin);
1024 constphi = _hcalintowergeom->get_phicenter(tower_phi_bin);
1025 consteta = _hcalintowergeom->get_etacenter(tower_eta_bin);
1029 constphi = _hcalouttowergeom->get_phicenter(tower_phi_bin);
1030 consteta = _hcalouttowergeom->get_etacenter(tower_eta_bin);
1033 if(checkdphi < -1 * TMath::Pi() / 2.)
1034 checkdphi += 2. * TMath::Pi();
1035 if(checkdphi > 3. * TMath::Pi() / 2.)
1036 checkdphi -= 2. * TMath::Pi();
1052 cout <<
"finished event" << endl;
1062 std::cout <<
" DONE PROCESSING PHOTONJET PACKAGE" << endl;
1078 float trig_phi = E_vec_cluster.getPhi();
1079 float trig_eta = E_vec_cluster.pseudoRapidity();
1086 iter != range.second;
1121 iter != recojets->
end();
1124 Jet *jet = iter->second;
1131 if (_recojeteta < etalow || _recojeteta >
etahigh)
1156 float closestjet = 9999;
1159 Jet *truthjet = iter->second;
1161 float thisjetpt = truthjet->
get_pt();
1165 float thisjeteta = truthjet->
get_eta();
1166 float thisjetphi = truthjet->
get_phi();
1169 if (dphi > 3. *
pi / 2.)
1171 if (dphi < -1. *
pi / 2.)
1176 float dR = sqrt(pow(dphi, 2.) + pow(deta, 2.));
1178 if (dR < recojets->get_par() && dR < closestjet)
1192 if (dR < closestjet)
1226 float trig_phi = E_vec_cluster.getPhi();
1227 float trig_eta = E_vec_cluster.pseudoRapidity();
1233 iter != range.second;
1270 cout <<
"evaluating tracked hadrons opposite the direct photon" << endl;
1273 iter != tracks->
end();
1314 TLorentzVector *Truthtrack =
new TLorentzVector();
1330 iter != trackedjets->
end();
1333 Jet *jet = iter->second;
1400 iter != jets->
end();
1403 Jet *jet = iter->second;
1411 if (_recojeteta < etalow || _recojeteta >
etahigh)
1422 int pair_ntruthconstituents = 0;
1438 std::set<PHG4Particle *> truthjetcomp =
1441 float truthjetenergysum = 0;
1442 float truthjethighestphoton = 0;
1443 for (std::set<PHG4Particle *>::iterator iter2 = truthjetcomp.begin();
1444 iter2 != truthjetcomp.end();
1450 cout <<
"no truth particles in the jet??" << endl;
1453 pair_ntruthconstituents++;
1455 int constpid = truthpart->
get_pid();
1456 float conste = truthpart->
get_e();
1458 truthjetenergysum += conste;
1462 if (conste > truthjethighestphoton)
1463 truthjethighestphoton = conste;
1482 float closestjet = 9999;
1485 Jet *trutherjet = iter->second;
1487 float thisjetpt = trutherjet->
get_pt();
1491 float thisjeteta = trutherjet->
get_eta();
1492 float thisjetphi = trutherjet->
get_phi();
1495 if (dphi > 3. *
pi / 2.)
1497 if (dphi < -1. *
pi / 2.)
1502 float dR = sqrt(pow(dphi, 2.) + pow(deta, 2.));
1504 if (dR < jets->get_par() && dR < closestjet)
1518 if (dR < closestjet)
1524 if (!
is_AA && pair_ntruthconstituents < 3)
1550 float energyptsum = 0;
1558 for (clusiter = begin_end.first;
1559 clusiter != begin_end.second;
1567 if (conecluster->
get_z() == cluster->
get_z())
1572 float cone_pt = E_vec_conecluster.perp();
1578 float cone_eta = E_vec_conecluster.pseudoRapidity();
1579 float cone_phi = E_vec_conecluster.getPhi();
1587 float deta = E_vec_cluster.pseudoRapidity() - cone_eta;
1589 float radius = sqrt(dphi * dphi + deta * deta);
1591 if (radius < coneradius)
1593 energyptsum += cone_e;
1601 float trackpx = track->
get_px();
1602 float trackpy = track->
get_py();
1603 float trackpt = sqrt(trackpx * trackpx + trackpy * trackpy);
1606 float trackphi = track->
get_phi();
1607 float tracketa = track->
get_eta();
1608 float dphi = E_vec_cluster.getPhi() - trackphi;
1609 float deta = E_vec_cluster.pseudoRapidity() - tracketa;
1610 float radius = sqrt(dphi * dphi + deta * deta);
1612 if (radius < coneradius)
1614 energyptsum += trackpt;
1623 cluster_tree =
new TTree(
"clustertree",
"A tree with EMCal cluster information");
1649 isolated_clusters =
new TTree(
"isolated_clusters",
"a tree with isolated EMCal clusters");
1682 tracktree =
new TTree(
"tracktree",
"a tree with svtx tracks");
1714 truthjettree =
new TTree(
"truthjettree",
"a tree with truth jets");
1738 recojettree =
new TTree(
"recojettree",
"a tree with reco jets");
1777 "a tree with correlated isolated photons and jets");
1833 "a tree with correlated isolated photons and track jets");
1888 isophot_had_tree =
new TTree(
"isophoton-hads",
"a tree with correlated isolated photons and hadrons");
1948 truth_g4particles =
new TTree(
"truthtree_g4",
"a tree with all truth g4 particles");
1971 truthtree =
new TTree(
"truthtree",
"a tree with all truth pythia particles");
1989 event_tree =
new TTree(
"eventtree",
"A tree with 2 to 2 event info");