31 #include <particleflowreco/ParticleFlowElementv1.h>
32 #include <particleflowreco/ParticleFlowElementContainer.h>
34 #define HomogeneousField
46 #pragma GCC diagnostic push
47 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
48 #include <HepMC/GenEvent.h>
49 #include <HepMC/GenVertex.h>
50 #pragma GCC diagnostic pop
55 #include <TDatabasePDG.h>
69 , m_outputFileName(outputfilename)
70 , m_ptRangeReco(0, 100)
71 , m_ptRangeTruth(0, 100)
75 std::cout <<
"FullJetFinder::FullJetFinder(const std::string &name) Calling ctor" << std::endl;
81 std::cout <<
"FullJetFinder::~FullJetFinder() Calling dtor" << std::endl;
99 std::cout <<
"FullJetFinder::Init(PHCompositeNode *topNode) Initializing" << std::endl;
101 std::cout <<
"FullJetFinder::Init - Output to " <<
m_outputFileName << std::endl;
104 std::cout <<
"MyJetAnalysis::Init - Error number of inputs outside (0,10> " << std::endl;
111 m_T[
i] =
new TTree(
"Data",
"Data");
122 m_stat =
new TH1I(
"event_stat",
"event_stat",10,-0.5,9.5);
123 m_stat->GetXaxis()->SetBinLabel(1,
"n_events");
124 m_stat->GetXaxis()->SetBinLabel(2,
"GV_exists");
125 m_stat->GetXaxis()->SetBinLabel(3,
"GV_notempty");
135 std::cout <<
"FullJetFinder::InitRun(PHCompositeNode *topNode) Initializing for Run XXX" << std::endl;
144 CentralityInfo* cent_node = findNode::getClass<CentralityInfo>(topNode,
"CentralityInfo");
146 std::cout <<
"MyJetAnalysis::process_event - Error can not find centrality node " << std::endl;
152 std::cout <<
"MyJetAnalysis::process_event - Error in m_recoJetName size != m_truthJetName.size() or empty" << std::endl;
157 std::cout <<
"MyJetAnalysis::process_event - Error number of AddInput() calls does not match with number of inputs specified in constructor" << std::endl;
163 GlobalVertexMap *vertexmap = findNode::getClass<GlobalVertexMap>(topNode,
"GlobalVertexMap");
165 std::cout <<
"MyJetAnalysis::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." << std::endl;
172 if (vertexmap->
empty()){
173 std::cout <<
"MyJetAnalysis::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." << std::endl;
200 std::cout <<
PHWHERE <<
" ERROR: Can't find G4TruthInfo" << std::endl;
218 std::cout <<
"MyJetAnalysis::process_event - Error can not find DST Reco JetContainer node " <<
m_recoJetName.at(
input) << std::endl;
226 std::cout <<
"MyJetAnalysis::process_event - Error can not find DST Truth JetContainer node " <<
m_truthJetName.at(
input) << std::endl;
231 HepMC::GenEvent *hepMCGenEvent =
nullptr;
233 PHHepMCGenEventMap *hepmceventmap = findNode::getClass<PHHepMCGenEventMap>(topNode,
"PHHepMCGenEventMap");
238 <<
"HEPMC event map node is missing, can't collected HEPMC truth particles"
248 <<
"PHHepMCGenEvent node is missing, can't collected HEPMC truth particles"
253 hepMCGenEvent = hepmcevent->
getEvent();
263 <<
"ParticleFlowElements node is missing, can't collect particles"
268 for(
auto vertex : *vertexmap){
270 std::vector<GlobalVertex::VTXTYPE>
source;
272 primary.
id =
vertex.second->get_id();
273 primary.
x =
vertex.second->get_x();
274 primary.
y =
vertex.second->get_y();
275 primary.
z =
vertex.second->get_z();
276 primary.
x_unc = sqrt(
vertex.second->get_error(0,0));
277 primary.
y_unc = sqrt(
vertex.second->get_error(1,1));
278 primary.
z_unc = sqrt(
vertex.second->get_error(2,2));
283 for (
auto iter =
vertex.second->begin_vertexes(); iter !=
vertex.second->end_vertexes(); ++iter){
284 source.push_back(iter->first);
291 if((std::find(source.begin(), source.end(), GlobalVertex::VTXTYPE::SVTX) != source.end()) && (std::find(source.begin(), source.end(),
GlobalVertex::VTXTYPE::MBD) != source.end())) primary.
vtxtype = GlobalVertex::VTXTYPE::SVTX_MBD;
292 else if(std::find(source.begin(), source.end(), GlobalVertex::VTXTYPE::SVTX) != source.end()) primary.
vtxtype = GlobalVertex::VTXTYPE::SVTX;
301 for (
Jet* jet : *jets){
313 for (
const auto&
comp : jet->get_comp_vec()){
324 std::cout <<
"MyJetAnalysis::process_event - Fatal Error - Gvtx null." << std::endl;
329 float DCA_xy, DCA_xy_unc;
332 double sign = int(dot/std::abs(dot));
367 track_properties.
e = pflow->
get_e();
370 track_properties.
pt = pflow->
get_pt();
371 track_properties.
DCA_xy = DCA_xy;
373 track_properties.
sDCA_xy = sign*std::abs(DCA_xy/DCA_xy_unc);
374 track_properties.
n_mvtx = n_mvtx_hits;
375 track_properties.
n_intt = n_intt_hits;
376 track_properties.
n_tpc = n_tpc_hits;
385 neutral_properties.
e = pflow->
get_e();
392 recojet.
id = jet->get_id();
393 recojet.
area = jet->get_property(recojet_area_index);
396 recojet.
px = jet->get_px();
397 recojet.
py = jet->get_py();
398 recojet.
pz = jet->get_pz();
399 recojet.
pt = jet->get_pt();
400 recojet.
eta = jet->get_eta();
401 recojet.
phi = jet->get_phi();
402 recojet.
m = jet->get_mass();
403 recojet.
e = jet->get_e();
421 for (
Jet* truthjet : *jetsMC){
425 if(truthjet->get_pt() < 10.0)
continue;
429 mtruthjet.
id = truthjet->get_id();
430 mtruthjet.
area = truthjet->get_property(truthjet_area_index);
432 mtruthjet.
px = truthjet->get_px();
433 mtruthjet.
py = truthjet->get_py();
434 mtruthjet.
pz = truthjet->get_pz();
435 mtruthjet.
pt = truthjet->get_pt();
436 mtruthjet.
eta = truthjet->get_eta();
437 mtruthjet.
phi = truthjet->get_phi();
438 mtruthjet.
m = truthjet->get_mass();
439 mtruthjet.
e = truthjet->get_e();
443 TString taggedPDGIDs[] = {
"B-Meson",
"CharmedMeson",
"CharmedBaryon",
"B-Baryon"};
444 int forbiddenPDGIDs[] = {1,2,3,4,5,6,7,8,21,22};
445 int nChTrackstruth = 0;
449 for (
const auto&
comp : truthjet->get_comp_vec()){
452 HepMC::GenParticle* constituent = hepMCGenEvent->barcode_to_particle(g4part->
get_barcode());
453 if(std::abs((TDatabasePDG::Instance()->GetParticle((constituent)->pdg_id()))->Charge()) > 10
e-4) nChTrackstruth++;
456 if (std::find(
std::begin(taggedPDGIDs),
std::end(taggedPDGIDs), TString((TDatabasePDG::Instance()->GetParticle((constituent)->pdg_id()))->ParticleClass())) !=
std::end(taggedPDGIDs)){
462 while (!constituent->is_beam()){
463 bool breakOut =
false;
464 bool taggedHF =
false;
465 for (HepMC::GenVertex::particle_iterator mother = constituent->production_vertex()->particles_begin(HepMC::parents); mother != constituent->production_vertex()->particles_end(HepMC::parents); ++mother){
467 if (std::find(
std::begin(taggedPDGIDs),
std::end(taggedPDGIDs), TString((TDatabasePDG::Instance()->GetParticle((*mother)->pdg_id()))->ParticleClass())) !=
std::end(taggedPDGIDs)){
473 if (std::find(
std::begin(forbiddenPDGIDs),
std::end(forbiddenPDGIDs), abs((*mother)->pdg_id())) !=
std::end(forbiddenPDGIDs)){
477 constituent = *mother;
479 if (breakOut || taggedHF)
break;
505 std::cout <<
"FullJetFinder::EndRun(const int runnumber) Ending Run for Run " << runnumber << std::endl;
512 std::cout <<
"FullJetFinder::End - Output to " <<
m_outputFileName << std::endl;
533 std::cout <<
"FullJetFinder::End(PHCompositeNode *topNode) This is the End..." << std::endl;
540 std::cout <<
"FullJetFinder::Reset(PHCompositeNode *topNode) being Reset" << std::endl;
547 std::cout <<
"FullJetFinder::Print(const std::string &what) const Printing info for " << what << std::endl;
552 KFParticle::SetField(1.4e1);
556 float f_trackParameters[6] = {m_dst_track->
get_x(),
557 m_dst_track->
get_y(),
558 m_dst_track->
get_z(),
563 float f_trackCovariance[21];
564 unsigned int iterate = 0;
565 for (
unsigned int i = 0;
i < 6; ++
i)
566 for (
unsigned int j = 0;
j <=
i; ++
j)
568 f_trackCovariance[iterate] = m_dst_track->
get_error(
i,
j);
572 kfp_particle.
Create(f_trackParameters, f_trackCovariance, (Int_t) m_dst_track->
get_charge(), -1);
577 float f_vertexParameters[6] = {m_dst_vertex->
get_x(),
578 m_dst_vertex->
get_y(),
579 m_dst_vertex->
get_z(), 0, 0, 0};
581 float f_vertexCovariance[21];
582 unsigned int iterate2 = 0;
583 for (
unsigned int i = 0;
i < 3; ++
i)
584 for (
unsigned int j = 0;
j <=
i; ++
j)
586 f_vertexCovariance[iterate2] = m_dst_vertex->
get_error(
i,
j);
591 kfp_vertex.
Create(f_vertexParameters, f_vertexCovariance, 0, -1);