23 #include "G4VProcess.hh" 40 m_trksForThisEvent(
nullptr),m_nVertices(0),
41 m_collapsePrimaryVertices(iCollapsePrimaryVertices),
42 lastTrack(0),lastHist(0),theLHCTlink(
nullptr){}
59 delete (*m_trksForThisEvent)[
i];
66 std::vector<std::pair <int, int> >().
swap(
idsave);
75 delete (*m_trksForThisEvent)[
i];
89 <<
" SimTrackManager::saveTrackAndItsBranch got 0 pointer ";
91 <<
" cannot handle hits for tracking";
96 TrackContainer::const_iterator tk_itr =
97 std::lower_bound((*m_trksForThisEvent).begin(),(*m_trksForThisEvent).end(),
131 <<
"Inside the reallyStoreTracks method object to be stored = " 144 unsigned int iParentID = trkH->
parentID();
148 pm = (*m_trksForThisEvent)[iit]->momentum();
154 std::map<uint32_t,std::pair<math::XYZVectorD,math::XYZTLorentzVectorD> >::const_iterator cit =
156 std::pair<math::XYZVectorD,math::XYZTLorentzVectorD> tcinfo;
158 tcinfo = cit->second;
162 ivertex,ig,pm,tcinfo.first,tcinfo.second));
172 for( std::vector<TrackWithHistory*>::const_iterator it = (*m_trksForThisEvent).begin();
173 it!= (*m_trksForThisEvent).end();it++)
175 if ((*it)->trackID() == uint32_t(parent)) {
181 if(check==-1) { parent = -1; }
183 VertexMap::const_iterator iterator =
m_vertexMap.find(parent);
193 unsigned int ptype = 0;
195 if(pr) { ptype = pr->GetProcessSubType(); }
220 unsigned int n =
idsave.size();
227 for(j=0; j<=jmax; ++j) {
230 if(0 == id1 || id1 == idMother) {
return id1; }
237 if(notFound) {
return 0; }
244 for(j=jmax; j>=0; --j) {
245 if((
idsave[j]).first == idMother) {
247 if(0 == id1 || id1 == idMother) {
return id1; }
257 for(j=jmax; j>=0; --j) {
276 <<
" SimTrackManager::fillMotherList track index corrupted";
309 if ((*m_trksForThisEvent).empty() &&
idsave.empty()) {
return; }
313 <<
"SimTrackManager::cleanTracksWithHistory has " 315 <<
" mother-daughter relationships stored with lastTrack = " <<
lastTrack;
321 <<
" SimTrackManager::cleanTracksWithHistory track index corrupted";
331 <<
" tracks with history before branching";
332 for (
unsigned int it =0; it <(*m_trksForThisEvent).size(); it++) {
334 <<
" 1 - Track in position " << it <<
" G4 track number " 335 << (*m_trksForThisEvent)[it]->trackID()
336 <<
" mother " << (*m_trksForThisEvent)[it]->parentID()
337 <<
" status " << (*m_trksForThisEvent)[it]->saved();
351 if (t->
saved() ==
true)
353 if (it>num) (*m_trksForThisEvent)[
num] =
t;
355 for (
unsigned int itr=0; itr<
idsave.size(); itr++) {
356 if ((
idsave[itr]).first == g4ID) {
368 (*m_trksForThisEvent).resize(num);
372 <<
" AFTER CLEANING, I GET " << (*m_trksForThisEvent).size()
373 <<
" tracks to be saved persistently";
374 for (
unsigned int it = 0; it < (*m_trksForThisEvent).size(); it++) {
376 <<
" Track in position " << it
377 <<
" G4 track number " << (*m_trksForThisEvent)[it]->trackID()
378 <<
" mother " << (*m_trksForThisEvent)[it]->parentID()
379 <<
" Status " << (*m_trksForThisEvent)[it]->saved()
380 <<
" id " << (*m_trksForThisEvent)[it]->particleID()
381 <<
" E(MeV)= " << (*m_trksForThisEvent)[it]->totalEnergy();
387 lastTrack = (*m_trksForThisEvent).size();
398 if ( genParticleID_ == -1 ) {
continue; }
400 for (
unsigned int itrlink = 0; itrlink < (*theLHCTlink).size(); itrlink++ ) {
401 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