24 #include "G4VProcess.hh"
29 : m_trksForThisEvent(nullptr),
31 m_collapsePrimaryVertices(iCollapsePrimaryVertices),
34 theLHCTlink(nullptr) {}
49 delete (*m_trksForThisEvent)[
i];
56 std::vector<std::pair<int, int> >().
swap(
idsave);
64 delete (*m_trksForThisEvent)[
i];
74 if (trkH ==
nullptr) {
75 edm::LogError(
"SimTrackManager") <<
" SimTrackManager::saveTrackAndItsBranch got 0 pointer ";
76 throw cms::Exception(
"SimTrackManager::saveTrackAndItsBranch") <<
" cannot handle hits for tracking";
112 LogDebug(
"SimTrackManager") <<
"Inside the reallyStoreTracks method object to be stored = "
124 unsigned int iParentID = trkH->
parentID();
127 pm = (*m_trksForThisEvent)[iit]->momentum();
133 std::map<uint32_t, std::pair<math::XYZVectorD, math::XYZTLorentzVectorD> >::const_iterator cit =
135 std::pair<math::XYZVectorD, math::XYZTLorentzVectorD> tcinfo;
137 tcinfo = cit->second;
149 simEvent->
add(g4simtrack);
157 for (std::vector<TrackWithHistory*>::const_iterator it = (*m_trksForThisEvent).begin();
158 it != (*m_trksForThisEvent).end();
160 if ((*it)->trackID() == uint32_t(
parent)) {
180 unsigned int ptype = 0;
183 ptype =
pr->GetProcessSubType();
205 unsigned int n =
idsave.size();
212 for (
j = 0;
j <= jmax; ++
j) {
215 if (0 ==
id1 ||
id1 == idMother) {
232 for (
j = jmax;
j >= 0; --
j) {
233 if ((
idsave[
j]).first == idMother) {
235 if (0 ==
id1 ||
id1 == idMother) {
247 for (
j = jmax;
j >= 0; --
j) {
264 edm::LogError(
"SimTrackManager") <<
" SimTrackManager::fillMotherList track index corrupted";
294 if ((*m_trksForThisEvent).empty() &&
idsave.empty()) {
299 LogDebug(
"SimTrackManager") <<
"SimTrackManager::cleanTracksWithHistory has " <<
idsave.size()
300 <<
" mother-daughter relationships stored with lastTrack = " <<
lastTrack;
305 edm::LogError(
"SimTrackManager") <<
" SimTrackManager::cleanTracksWithHistory track index corrupted";
314 <<
" tracks with history before branching";
315 for (
unsigned int it = 0; it < (*m_trksForThisEvent).size(); it++) {
316 LogDebug(
"SimTrackManager") <<
" 1 - Track in position " << it <<
" G4 track number "
317 << (*m_trksForThisEvent)[it]->trackID() <<
" mother "
318 << (*m_trksForThisEvent)[it]->parentID() <<
" status "
319 << (*m_trksForThisEvent)[it]->saved();
332 int g4ID =
t->trackID();
333 if (
t->saved() ==
true) {
335 (*m_trksForThisEvent)[
num] =
t;
337 for (
unsigned int itr = 0; itr <
idsave.size(); itr++) {
338 if ((
idsave[itr]).first == g4ID) {
348 (*m_trksForThisEvent).resize(
num);
351 LogDebug(
"SimTrackManager") <<
" AFTER CLEANING, I GET " << (*m_trksForThisEvent).size()
352 <<
" tracks to be saved persistently";
353 for (
unsigned int it = 0; it < (*m_trksForThisEvent).size(); it++) {
354 LogDebug(
"SimTrackManager") <<
" Track in position " << it <<
" G4 track number "
355 << (*m_trksForThisEvent)[it]->trackID() <<
" mother "
356 << (*m_trksForThisEvent)[it]->parentID() <<
" Status "
357 << (*m_trksForThisEvent)[it]->saved() <<
" id "
358 << (*m_trksForThisEvent)[it]->particleID()
359 <<
" E(MeV)= " << (*m_trksForThisEvent)[it]->totalEnergy();
365 lastTrack = (*m_trksForThisEvent).size();
375 if (genParticleID_ == -1) {
378 for (
unsigned int itrlink = 0; itrlink < (*theLHCTlink).size(); itrlink++) {
379 if ((*
theLHCTlink)[itrlink].afterHector() == genParticleID_) {