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";
110 LogDebug(
"SimTrackManager") <<
"Inside the reallyStoreTracks method object to be stored = " 121 unsigned int iParentID = trkH->parentID();
123 if (trk->trackID() == iParentID) {
124 pm = trk->momentum();
128 ig = trkH->genParticleID();
130 std::map<uint32_t, std::pair<math::XYZVectorD, math::XYZTLorentzVectorD> >::const_iterator cit =
132 std::pair<math::XYZVectorD, math::XYZTLorentzVectorD> tcinfo;
134 tcinfo = cit->second;
146 simEvent->
add(g4simtrack);
153 int id = trk->trackID();
154 if (
id == iParentID) {
170 unsigned int ptype = 0;
173 ptype =
pr->GetProcessSubType();
195 unsigned int n =
idsave.size();
202 for (
j = 0;
j <= jmax; ++
j) {
205 if (0 ==
id1 ||
id1 == idMother) {
222 for (
j = jmax;
j >= 0; --
j) {
223 if ((
idsave[
j]).first == idMother) {
225 if (0 ==
id1 ||
id1 == idMother) {
237 for (
j = jmax;
j >= 0; --
j) {
254 edm::LogError(
"SimTrackManager") <<
" SimTrackManager::fillMotherList track index corrupted";
284 if ((*m_trksForThisEvent).empty() &&
idsave.empty()) {
289 LogDebug(
"SimTrackManager") <<
"SimTrackManager::cleanTracksWithHistory has " <<
idsave.size()
290 <<
" mother-daughter relationships stored with lastTrack = " <<
lastTrack;
295 edm::LogError(
"SimTrackManager") <<
" SimTrackManager::cleanTracksWithHistory track index corrupted";
304 <<
" tracks with history before branching";
305 for (
unsigned int it = 0; it < (*m_trksForThisEvent).size(); it++) {
306 LogDebug(
"SimTrackManager") <<
" 1 - Track in position " << it <<
" G4 track number " 307 << (*m_trksForThisEvent)[it]->trackID() <<
" mother " 308 << (*m_trksForThisEvent)[it]->parentID() <<
" status " 309 << (*m_trksForThisEvent)[it]->saved();
321 int g4ID =
t->trackID();
322 if (
t->saved() ==
true) {
324 (*m_trksForThisEvent)[
num] =
t;
327 if (
xx.first == g4ID) {
340 LogDebug(
"SimTrackManager") <<
" AFTER CLEANING, I GET " << (*m_trksForThisEvent).size()
341 <<
" tracks to be saved persistently";
342 for (
unsigned int it < (*m_trksForThisEvent).size(); ++it) {
343 LogDebug(
"SimTrackManager") <<
" Track in position " << it <<
" G4 track number " 344 << (*m_trksForThisEvent)[it]->trackID() <<
" mother " 345 << (*m_trksForThisEvent)[it]->parentID() <<
" Status " 346 << (*m_trksForThisEvent)[it]->saved() <<
" id " 347 << (*m_trksForThisEvent)[it]->particleID()
348 <<
" E(MeV)= " << (*m_trksForThisEvent)[it]->totalEnergy();
354 lastTrack = (*m_trksForThisEvent).size();
362 int genParticleID = trkH->genParticleID();
363 if (genParticleID == -1) {
367 if (
xx.afterHector() == genParticleID) {
368 trkH->setGenParticleID(
xx.beforeHector());
void copyCrossedBoundaryVars(const TrackWithHistory *track)
double globalTime() const
int getOrCreateVertex(TrackWithHistory *, int, G4SimEvent *simEvent)
std::map< int, MapVertexPositionVector > MotherParticleToVertexMap
SimTrackManager(bool iCollapsePrimaryVertices=false)
const math::XYZVectorD & vertexPosition() const
Log< level::Error, false > LogError
void cleanTkCaloStateInfoMap()
void swap(Association< C > &lhs, Association< C > &rhs)
virtual ~SimTrackManager()
TrackContainer * m_trksForThisEvent
U second(std::pair< T, U > const &p)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > XYZVectorD
spatial vector with cartesian internal representation
std::vector< TrackWithHistory * > TrackContainer
void cleanTracksWithHistory()
MotherParticleToVertexMap m_vertexMap
void storeTracks(G4SimEvent *simEvent)
std::vector< std::pair< int, int > > idsave
std::map< uint32_t, std::pair< math::XYZVectorD, math::XYZTLorentzVectorD > > mapTkCaloStateInfo
std::pair< int, math::XYZVectorD > MapVertexPosition
this map contains association between vertex number and position
void saveTrackAndItsBranch(TrackWithHistory *)
this saves a track and all its parents looping over the non ordered vector
static const GlobalPoint notFound(0, 0, 0)
const edm::LHCTransportLinkContainer * theLHCTlink
void reallyStoreTracks(G4SimEvent *simEvent)
int idSavedTrack(int) const
std::vector< std::pair< int, int > > ancestorList
const G4VProcess * creatorProcess() const