8 #include <calobase/RawCluster.h>
9 #include <calobase/RawClusterContainer.h>
10 #include <calobase/RawClusterUtility.h>
12 #include <g4vertex/GlobalVertex.h>
13 #include <g4vertex/GlobalVertexMap.h>
15 #include <g4hough/SvtxTrack.h>
16 #include <g4hough/SvtxTrackMap.h>
26 #include <fastjet/ClusterSequence.hh>
27 #include <fastjet/JetDefinition.hh>
28 #include <fastjet/PseudoJet.hh>
29 #include <fastjet/SISConePlugin.hh>
31 #include <g4jets/Jet.h>
32 #include <g4jets/JetMapV1.h>
33 #include <g4jets/JetV1.h>
47 using namespace Fun4AllReturnCodes;
49 typedef std::map<int, TLorentzVector*>
tlvmap;
71 if (algorithm ==
"AntiKt")
74 if (algorithm ==
"Kt")
103 cout <<
"------PHFlowJetMaker::Init(PHCompositeNode*)------" << endl;
120 cout <<
"DST Node missing. Doing nothing." << endl;
151 string nodeName =
"Flow";
153 stringstream snodeName;
154 snodeName <<
algorithm <<
"_" << nodeName <<
"_r" << setfill(
'0') << setw(2) << int(
r_param * 10);
155 nodeName = snodeName.str();
159 if (!flowJetNode->
addNode(PHFlowJetNode))
161 cout <<
"PHFlowJetMaker::create_node_tree() - Can't add node to tree!" << endl;
177 RawClusterContainer* emc_clusters = findNode::getClass<RawClusterContainer>(topNode,
"CLUSTER_CEMC");
178 RawClusterContainer* hci_clusters = findNode::getClass<RawClusterContainer>(topNode,
"CLUSTER_HCALIN");
179 RawClusterContainer* hco_clusters = findNode::getClass<RawClusterContainer>(topNode,
"CLUSTER_HCALOUT");
182 SvtxTrackMap* reco_tracks = findNode::getClass<SvtxTrackMap>(topNode,
"SvtxTrackMap");
185 GlobalVertexMap* vertexmap = findNode::getClass<GlobalVertexMap>(topNode,
"GlobalVertexMap");
188 cout <<
"PHFlowJetMaker::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;
194 if (vertexmap->empty())
196 cout <<
"PHFlowJetMaker::process_event - Fatal Error - GlobalVertexMap node is empty. Please turn on the do_bbc or tracking reco flags in the main macro in order to reconstruct the global vertex." << endl;
214 vector<fastjet::PseudoJet> flow_particles;
215 run_particle_flow(flow_particles, emc_clusters, hci_clusters, hco_clusters, reco_tracks, vtx);
216 fastjet::ClusterSequence jet_finder_flow(flow_particles, *
fJetAlgorithm);
217 vector<fastjet::PseudoJet> flow_jets = jet_finder_flow.inclusive_jets(
min_jet_pT);
232 for (
unsigned int i = 0;
i < flow_jets.size();
i++)
234 JetV1*
j =
new JetV1();
235 float px = flow_jets[
i].px();
236 float py = flow_jets[
i].py();
237 float pz = flow_jets[
i].pz();
238 float energy = flow_jets[
i].E();
271 double emc_energy = 0;
272 double hci_energy = 0;
273 double hco_energy = 0;
274 double cluster_energy = 0;
282 double track_energy = 0;
291 for (
unsigned int i = 0;
i < emc_clusters->
size();
i++)
298 emc_map[
i] =
new TLorentzVector();
300 emc_map[
i]->SetPxPyPzE(
304 E_vec_cluster.mag());
307 for (
unsigned int i = 0;
i < hci_clusters->
size();
i++)
312 hci_map[
i] =
new TLorentzVector();
319 E_vec_cluster.mag());
322 for (
unsigned int i = 0;
i < hco_clusters->
size();
i++)
327 hco_map[
i] =
new TLorentzVector();
334 E_vec_cluster.mag());
345 p = sqrt(px * px + py * py + pz * pz);
346 track_energy = TMath::Sqrt(p * p + 0.139 * 0.139);
348 eta = -log(tan(acos(pz / p) / 2.0));
349 et = track_energy / cosh(eta);
354 phi = phi + 2 * TMath::Pi();
356 else if (phi > 2 * TMath::Pi())
358 phi = phi + 2 * TMath::Pi();
373 tlvmap::iterator
it = emc_map.find(emcID);
374 if (it != emc_map.end())
376 emc_energy = emc_map[emcID]->Energy();
379 it = hci_map.find(hciID);
380 if (it != hci_map.end())
382 hci_energy = hci_map[hciID]->Energy();
385 it = hco_map.find(hcoID);
386 if (it != hco_map.end())
388 hco_energy = hco_map[hcoID]->Energy();
391 cluster_energy = emc_energy + hci_energy + hco_energy;
398 matched =
get_matched(cluster_energy, track_energy);
403 float fracEnergyEMC = emc_energy / cluster_energy;
404 float fracEnergyHCI = hci_energy / cluster_energy;
405 float fracEnergyHCO = hco_energy / cluster_energy;
407 it = emc_map.find(emcID);
408 if (it != emc_map.end())
410 (emc_map.find(emcID)->second)->SetE(emc_energy - fracEnergyEMC * track_energy);
413 it = hci_map.find(hciID);
414 if (it != hci_map.end())
416 (hci_map.find(hciID)->second)->SetE(hci_energy - fracEnergyHCI * track_energy);
419 it = hco_map.find(hcoID);
420 if (it != hco_map.end())
422 (hco_map.find(hcoID)->second)->SetE(hco_energy - fracEnergyHCO * track_energy);
425 else if (matched == 2)
427 it = emc_map.find(emcID);
428 if (it != emc_map.end())
430 delete emc_map[emcID];
431 emc_map.erase(emcID);
434 it = hci_map.find(hciID);
435 if (it != emc_map.end())
437 delete hci_map[hciID];
438 hci_map.erase(hciID);
441 it = hco_map.find(hcoID);
442 if (it != hco_map.end())
444 delete hco_map[hcoID];
445 hco_map.erase(hcoID);
448 else if (matched == 0)
458 track_energy = sqrt(et * et + pz * pz);
460 fastjet::PseudoJet pseudoJet_track(et * cos(phi), et * sin(phi), pz, track_energy);
461 flow_particles.push_back(pseudoJet_track);
465 for (tlvmap::iterator
it = emc_map.begin();
it != emc_map.end();
it++)
467 double energy_clus = (
it->second)->Energy();
468 double eta_clus = (
it->second)->
Eta();
469 double phi_clus = (
it->second)->Phi();
470 double et_clus = energy_clus / cosh(eta_clus);
471 double pz_clus = et * sinh(eta_clus);
473 if (et_clus < 0.000001)
476 pz_clus = et_clus * sinh(eta_clus);
477 energy_clus = sqrt(et_clus * et_clus + pz_clus * pz_clus);
479 fastjet::PseudoJet pseudoJet_clus(et_clus * cos(phi_clus), et_clus * sin(phi_clus), pz_clus, energy_clus);
480 flow_particles.push_back(pseudoJet_clus);
483 for (tlvmap::iterator
it = hci_map.begin();
it != hci_map.end();
it++)
485 double energy_clus = (
it->second)->Energy();
486 double eta_clus = (
it->second)->
Eta();
487 double phi_clus = (
it->second)->Phi();
488 double et_clus = energy_clus / cosh(eta_clus);
489 double pz_clus = et * sinh(eta_clus);
491 if (et_clus < 0.000001)
494 pz_clus = et_clus * sinh(eta_clus);
495 energy_clus = sqrt(et_clus * et_clus + pz_clus * pz_clus);
497 fastjet::PseudoJet pseudoJet_clus(et_clus * cos(phi_clus), et_clus * sin(phi_clus), pz_clus, energy_clus);
498 flow_particles.push_back(pseudoJet_clus);
501 for (tlvmap::iterator
it = hco_map.begin();
it != hco_map.end();
it++)
503 double energy_clus = (
it->second)->Energy();
504 double eta_clus = (
it->second)->
Eta();
505 double phi_clus = (
it->second)->Phi();
506 double et_clus = energy_clus / cosh(eta_clus);
507 double pz_clus = et * sinh(eta_clus);
509 if (et_clus < 0.000001)
512 pz_clus = et_clus * sinh(eta_clus);
513 energy_clus = sqrt(et_clus * et_clus + pz_clus * pz_clus);
515 fastjet::PseudoJet pseudoJet_clus(et_clus * cos(phi_clus), et_clus * sin(phi_clus), pz_clus, energy_clus);
516 flow_particles.push_back(pseudoJet_clus);
602 if (clus_energy < limLo)
607 else if (clus_energy > limHi)