24 #include "G4VProcess.hh" 29 m_trksForThisEvent(
nullptr),m_nVertices(0),
30 m_collapsePrimaryVertices(iCollapsePrimaryVertices),
31 lastTrack(0),lastHist(0),theLHCTlink(
nullptr){}
48 delete (*m_trksForThisEvent)[
i];
55 std::vector<std::pair <int, int> >().
swap(
idsave);
64 delete (*m_trksForThisEvent)[
i];
78 <<
" SimTrackManager::saveTrackAndItsBranch got 0 pointer ";
80 <<
" cannot handle hits for tracking";
85 TrackContainer::const_iterator tk_itr =
86 std::lower_bound((*m_trksForThisEvent).begin(),(*m_trksForThisEvent).end(),
120 <<
"Inside the reallyStoreTracks method object to be stored = " 133 unsigned int iParentID = trkH->
parentID();
137 pm = (*m_trksForThisEvent)[iit]->momentum();
143 std::map<uint32_t,std::pair<math::XYZVectorD,math::XYZTLorentzVectorD> >::const_iterator cit =
145 std::pair<math::XYZVectorD,math::XYZTLorentzVectorD> tcinfo;
147 tcinfo = cit->second;
151 ivertex,ig,pm,tcinfo.first,tcinfo.second));
161 for( std::vector<TrackWithHistory*>::const_iterator it = (*m_trksForThisEvent).begin();
162 it!= (*m_trksForThisEvent).end();it++)
164 if ((*it)->trackID() == uint32_t(parent)) {
170 if(check==-1) { parent = -1; }
172 VertexMap::const_iterator iterator =
m_vertexMap.find(parent);
182 unsigned int ptype = 0;
184 if(pr) { ptype = pr->GetProcessSubType(); }
209 unsigned int n =
idsave.size();
216 for(j=0; j<=jmax; ++j) {
219 if(0 == id1 || id1 == idMother) {
return id1; }
226 if(notFound) {
return 0; }
233 for(j=jmax; j>=0; --j) {
234 if((
idsave[j]).first == idMother) {
236 if(0 == id1 || id1 == idMother) {
return id1; }
246 for(j=jmax; j>=0; --j) {
265 <<
" SimTrackManager::fillMotherList track index corrupted";
298 if ((*m_trksForThisEvent).empty() &&
idsave.empty()) {
return; }
302 <<
"SimTrackManager::cleanTracksWithHistory has " 304 <<
" mother-daughter relationships stored with lastTrack = " <<
lastTrack;
310 <<
" SimTrackManager::cleanTracksWithHistory track index corrupted";
320 <<
" tracks with history before branching";
321 for (
unsigned int it =0; it <(*m_trksForThisEvent).size(); it++) {
323 <<
" 1 - Track in position " << it <<
" G4 track number " 324 << (*m_trksForThisEvent)[it]->trackID()
325 <<
" mother " << (*m_trksForThisEvent)[it]->parentID()
326 <<
" status " << (*m_trksForThisEvent)[it]->saved();
340 if (t->
saved() ==
true)
342 if (it>num) (*m_trksForThisEvent)[
num] =
t;
344 for (
unsigned int itr=0; itr<
idsave.size(); itr++) {
345 if ((
idsave[itr]).first == g4ID) {
357 (*m_trksForThisEvent).resize(num);
361 <<
" AFTER CLEANING, I GET " << (*m_trksForThisEvent).size()
362 <<
" tracks to be saved persistently";
363 for (
unsigned int it = 0; it < (*m_trksForThisEvent).size(); it++) {
365 <<
" Track in position " << it
366 <<
" G4 track number " << (*m_trksForThisEvent)[it]->trackID()
367 <<
" mother " << (*m_trksForThisEvent)[it]->parentID()
368 <<
" Status " << (*m_trksForThisEvent)[it]->saved()
369 <<
" id " << (*m_trksForThisEvent)[it]->particleID()
370 <<
" E(MeV)= " << (*m_trksForThisEvent)[it]->totalEnergy();
376 lastTrack = (*m_trksForThisEvent).size();
387 if ( genParticleID_ == -1 ) {
continue; }
389 for (
unsigned int itrlink = 0; itrlink < (*theLHCTlink).size(); itrlink++ ) {
390 if ( (*
theLHCTlink)[itrlink].afterHector() == genParticleID_ ) {
int getOrCreateVertex(TrackWithHistory *, int, G4SimEvent *simEvent)
double totalEnergy() const
SimTrackManager(bool iCollapsePrimaryVertices=false)
void setGenParticleID(int i)
void cleanTkCaloStateInfoMap()
std::map< uint32_t, std::pair< math::XYZVectorD, math::XYZTLorentzVectorD > > mapTkCaloStateInfo
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
std::vector< std::pair< int, int > > idsave
unsigned int trackID() const
void cleanTracksWithHistory()
std::pair< int, math::XYZVectorD > MapVertexPosition
this map contains association between vertex number and position
MotherParticleToVertexMap m_vertexMap
void storeTracks(G4SimEvent *simEvent)
int idSavedTrack(int) const
const G4VProcess * creatorProcess() const
std::map< int, MapVertexPositionVector > MotherParticleToVertexMap
const math::XYZVectorD & momentum() const
void saveTrackAndItsBranch(TrackWithHistory *)
this saves a track and all its parents looping over the non ordered vector
double globalTime() const
static const GlobalPoint notFound(0, 0, 0)
const edm::LHCTransportLinkContainer * theLHCTlink
void reallyStoreTracks(G4SimEvent *simEvent)
std::vector< std::pair< int, int > > ancestorList
const math::XYZVectorD & vertexPosition() const
int genParticleID() const