6 std::map<std::string, int>
Use =
16 : m_svtx_evalstack(nullptr)
27 iter != trackmap->
end();
30 if (iter->first == track_id) matched_track = iter->second;
41 iter != vertexmap->
end();
44 if (iter->first == vertex_id) matched_vertex = iter->second;
47 return matched_vertex;
72 m_tree->Branch(TString(daughter_number) +
"_true_ID", &
m_true_daughter_id[daughter_id], TString(daughter_number) +
"_true_ID/I");
73 if (m_constrain_to_vertex_truthMatch) m_tree->Branch(TString(daughter_number) +
"_true_IP", &
m_true_daughter_ip[daughter_id], TString(daughter_number) +
"_true_IP/F");
74 if (m_constrain_to_vertex_truthMatch) m_tree->Branch(TString(daughter_number) +
"_true_IP_xy", &
m_true_daughter_ip_xy[daughter_id], TString(daughter_number) +
"_true_IP_xy/F");
75 m_tree->Branch(TString(daughter_number) +
"_true_px", &
m_true_daughter_px[daughter_id], TString(daughter_number) +
"_true_px/F");
76 m_tree->Branch(TString(daughter_number) +
"_true_py", &
m_true_daughter_py[daughter_id], TString(daughter_number) +
"_true_py/F");
77 m_tree->Branch(TString(daughter_number) +
"_true_pz", &
m_true_daughter_pz[daughter_id], TString(daughter_number) +
"_true_pz/F");
78 m_tree->Branch(TString(daughter_number) +
"_true_p", &
m_true_daughter_p[daughter_id], TString(daughter_number) +
"_true_p/F");
79 m_tree->Branch(TString(daughter_number) +
"_true_pT", &
m_true_daughter_pt[daughter_id], TString(daughter_number) +
"_true_pT/F");
80 m_tree->Branch(TString(daughter_number) +
"_true_EV_x", &
m_true_daughter_vertex_x[daughter_id], TString(daughter_number) +
"_true_EV_x/F");
81 m_tree->Branch(TString(daughter_number) +
"_true_EV_y", &
m_true_daughter_vertex_y[daughter_id], TString(daughter_number) +
"_true_EV_y/F");
82 m_tree->Branch(TString(daughter_number) +
"_true_EV_z", &
m_true_daughter_vertex_z[daughter_id], TString(daughter_number) +
"_true_EV_z/F");
83 if (m_constrain_to_vertex_truthMatch)
85 m_tree->Branch(TString(daughter_number) +
"_true_PV_x", &
m_true_daughter_pv_x[daughter_id], TString(daughter_number) +
"_true_pv_x/F");
86 m_tree->Branch(TString(daughter_number) +
"_true_PV_y", &
m_true_daughter_pv_y[daughter_id], TString(daughter_number) +
"_true_pv_y/F");
87 m_tree->Branch(TString(daughter_number) +
"_true_PV_z", &
m_true_daughter_pv_z[daughter_id], TString(daughter_number) +
"_true_pv_x/F");
100 float true_px, true_py, true_pz, true_p, true_pt;
125 bool isParticleValid = g4particle ==
nullptr ? 0 : 1;
127 true_px = isParticleValid ? (
Float_t) g4particle->get_px() : 0.;
128 true_py = isParticleValid ? (
Float_t) g4particle->get_py() : 0.;
129 true_pz = isParticleValid ? (
Float_t) g4particle->get_pz() : 0.;
130 true_p = sqrt(pow(true_px, 2) + pow(true_py, 2) + pow(true_pz, 2));
131 true_pt = sqrt(pow(true_px, 2) + pow(true_py, 2));
149 if (m_constrain_to_vertex_truthMatch)
155 KFParticle trueKFParticleVertex;
157 float f_vertexParameters[6] = {0};
159 if (truePoint == NULL)
161 std::cout <<
"KFParticle truth matching: This event has no PHG4VtxPoint information!\n";
162 std::cout <<
"Your truth track DCA will be measured wrt a reconstructed vertex!" << std::endl;
164 f_vertexParameters[0] = recoVertex->
get_x();
165 f_vertexParameters[1] = recoVertex->
get_y();
166 f_vertexParameters[2] = recoVertex->
get_z();
170 f_vertexParameters[0] = truePoint->get_x();
171 f_vertexParameters[1] = truePoint->get_y();
172 f_vertexParameters[2] = truePoint->get_z();
175 float f_vertexCovariance[21] = {0};
177 trueKFParticleVertex.Create(f_vertexParameters, f_vertexCovariance, 0, -1);
179 KFParticle trueKFParticle;
188 float f_trackCovariance[21] = {0};
190 trueKFParticle.Create(f_trackParameters, f_trackCovariance, 1, -1);
192 m_true_daughter_ip[daughter_id] = trueKFParticle.GetDistanceFromVertex(trueKFParticleVertex);
204 HepMC::FourVector myFourVector = particle->momentum();
218 HepMC::GenParticle* dummyParticle =
new HepMC::GenParticle();
219 HepMC::FourVector dummyFourVector(0,0,0,0);
220 dummyParticle->set_momentum(dummyFourVector);
221 dummyParticle->set_pdg_id(0);
222 dummyParticle->set_generated_mass(0.);
238 bool isParticleValid = g4particle ==
nullptr ? 0 : 1;
240 if (!isParticleValid)
242 std::cout <<
"KFParticle truth matching: this track is a ghost" << std::endl;
247 m_geneventmap = findNode::getClass<PHHepMCGenEventMap>(topNode,
"PHHepMCGenEventMap");
250 std::cout <<
"KFParticle truth matching: Missing node PHHepMCGenEventMap" << std::endl;
251 std::cout <<
"You will have no mother information" << std::endl;
259 std::cout <<
"KFParticle truth matching: Missing node PHHepMCGenEvent" << std::endl;
260 std::cout <<
"You will have no mother information" << std::endl;
266 HepMC::GenParticle* prevParticle =
nullptr;
268 int forbiddenPDGIDs[] = {21,22};
270 for (HepMC::GenEvent::particle_const_iterator
p = theEvent->particles_begin();
p != theEvent->particles_end(); ++
p)
272 if (((*p)->barcode() == g4particle->get_barcode()))
275 while (!prevParticle->is_beam())
277 bool breakOut =
false;
278 for (HepMC::GenVertex::particle_iterator mother = prevParticle->production_vertex()->particles_begin(HepMC::parents);
279 mother != prevParticle->production_vertex()->particles_end(HepMC::parents); ++mother)
281 if (std::find(std::begin(forbiddenPDGIDs), std::end(forbiddenPDGIDs),
282 abs((*mother)->pdg_id())) != std::end(forbiddenPDGIDs)) {breakOut =
true;
break;}
285 prevParticle = *mother;
297 m_tree->Branch(TString(daughter_number) +
"_EMCAL_DeltaPhi", &
detector_emcal_deltaphi[daughter_id], TString(daughter_number) +
"_EMCAL_DeltaPhi/F");
298 m_tree->Branch(TString(daughter_number) +
"_EMCAL_DeltaEta", &
detector_emcal_deltaeta[daughter_id], TString(daughter_number) +
"_EMCAL_DeltaEta/F");
299 m_tree->Branch(TString(daughter_number) +
"_EMCAL_energy_3x3", &
detector_emcal_energy_3x3[daughter_id], TString(daughter_number) +
"_EMCAL_energy_3x3/F");
300 m_tree->Branch(TString(daughter_number) +
"_EMCAL_energy_5x5", &
detector_emcal_energy_5x5[daughter_id], TString(daughter_number) +
"_EMCAL_energy_5x5/F");
301 m_tree->Branch(TString(daughter_number) +
"_EMCAL_energy_cluster", &
detector_emcal_cluster_energy[daughter_id], TString(daughter_number) +
"_EMCAL_energy_cluster/F");
302 m_tree->Branch(TString(daughter_number) +
"_IHCAL_DeltaPhi", &
detector_ihcal_deltaphi[daughter_id], TString(daughter_number) +
"_IHCAL_DeltaPhi/F");
303 m_tree->Branch(TString(daughter_number) +
"_IHCAL_DeltaEta", &
detector_ihcal_deltaeta[daughter_id], TString(daughter_number) +
"_IHCAL_DeltaEta/F");
304 m_tree->Branch(TString(daughter_number) +
"_IHCAL_energy_3x3", &
detector_ihcal_energy_3x3[daughter_id], TString(daughter_number) +
"_IHCAL_energy_3x3/F");
305 m_tree->Branch(TString(daughter_number) +
"_IHCAL_energy_5x5", &
detector_ihcal_energy_5x5[daughter_id], TString(daughter_number) +
"_IHCAL_energy_5x5/F");
306 m_tree->Branch(TString(daughter_number) +
"_IHCAL_energy_cluster", &
detector_ihcal_cluster_energy[daughter_id], TString(daughter_number) +
"_IHCAL_energy_cluster/F");
307 m_tree->Branch(TString(daughter_number) +
"_OHCAL_DeltaPhi", &
detector_ohcal_deltaphi[daughter_id], TString(daughter_number) +
"_OHCAL_DeltaEta/F");
308 m_tree->Branch(TString(daughter_number) +
"_OHCAL_DeltaEta", &
detector_ohcal_deltaeta[daughter_id], TString(daughter_number) +
"_OHCAL_DeltaEta/F");
309 m_tree->Branch(TString(daughter_number) +
"_OHCAL_energy_3x3", &
detector_ohcal_energy_3x3[daughter_id], TString(daughter_number) +
"_OHCAL_energy_3x3/F");
310 m_tree->Branch(TString(daughter_number) +
"_OHCAL_energy_5x5", &
detector_ohcal_energy_5x5[daughter_id], TString(daughter_number) +
"_OHCAL_energy_5x5/F");
311 m_tree->Branch(TString(daughter_number) +
"_OHCAL_energy_cluster", &
detector_ohcal_cluster_energy[daughter_id], TString(daughter_number) +
"_OHCAL_energy_cluster/F");
315 TTree *, KFParticle daughter,
int daughter_id)
351 m_tree->Branch(TString(daughter_number) +
"_local_x", &
detector_local_x[daughter_id]);
352 m_tree->Branch(TString(daughter_number) +
"_local_y", &
detector_local_y[daughter_id]);
353 m_tree->Branch(TString(daughter_number) +
"_local_z", &
detector_local_z[daughter_id]);
354 m_tree->Branch(TString(daughter_number) +
"_layer", &
detector_layer[daughter_id]);
356 for (
auto const &subdetector : Use)
364 if (detectorName ==
"MVTX")
366 m_tree->Branch(TString(daughter_number) +
"_" + TString(detectorName) +
"_staveID", &
mvtx_staveID[daughter_id]);
367 m_tree->Branch(TString(daughter_number) +
"_" + TString(detectorName) +
"_chipID", &
mvtx_chipID[daughter_id]);
369 if (detectorName ==
"INTT")
371 m_tree->Branch(TString(daughter_number) +
"_" + TString(detectorName) +
"_ladderZID", &
intt_ladderZID[daughter_id]);
372 m_tree->Branch(TString(daughter_number) +
"_" + TString(detectorName) +
"_ladderPhiID", &
intt_ladderPhiID[daughter_id]);
374 if (detectorName ==
"TPC")
376 m_tree->Branch(TString(daughter_number) +
"_" + TString(detectorName) +
"_sectorID", &
tpc_sectorID[daughter_id]);
377 m_tree->Branch(TString(daughter_number) +
"_" + TString(detectorName) +
"_side", &
tpc_side[daughter_id]);
382 TTree *, KFParticle daughter,
int daughter_id)
399 dst_clustermap = findNode::getClass<TrkrClusterContainer>(topNode,
"TRKR_CLUSTER");
403 std::cout <<
"KFParticle detector info: TRKR_CLUSTER does not exist" << std::endl;
420 unsigned int staveId, chipId, ladderZId, ladderPhiId, sectorId, side;
421 staveId = chipId = ladderZId = ladderPhiId = sectorId = side = -99;
444 tpc_side[daughter_id].push_back(side);
450 KFParticle motherParticle,
451 std::vector<KFParticle> daughters,
452 std::vector<KFParticle> intermediates)
457 for (
unsigned int i = 0; i < primaryVertices.size(); ++i)
459 allPV_x.push_back(primaryVertices[i].GetX());
460 allPV_y.push_back(primaryVertices[i].GetY());
461 allPV_z.push_back(primaryVertices[i].GetZ());
463 allPV_mother_IP.push_back(motherParticle.GetDistanceFromVertex(primaryVertices[i]));
466 for (
unsigned int j = 0; j < daughters.size(); ++j)
468 allPV_daughter_IP[j].push_back(daughters[j].GetDistanceFromVertex(primaryVertices[i]));
472 for (
unsigned int j = 0; j < intermediates.size(); ++j)