23 #include "G4VProcess.hh"
40 m_trksForThisEvent(0),m_nVertices(0),
41 m_collapsePrimaryVertices(iCollapsePrimaryVertices),
42 lastTrack(0),lastHist(0),theLHCTlink(0){}
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 ";
93 unsigned int parent = trkH->parentID();
95 TrackContainer::const_iterator tk_itr =
96 std::lower_bound((*m_trksForThisEvent).begin(),(*m_trksForThisEvent).end(),
130 <<
"Inside the reallyStoreTracks method object to be stored = "
143 unsigned int iParentID = trkH->
parentID();
147 pm = (*m_trksForThisEvent)[iit]->momentum();
153 std::map<uint32_t,std::pair<math::XYZVectorD,math::XYZTLorentzVectorD> >::const_iterator cit =
155 std::pair<math::XYZVectorD,math::XYZTLorentzVectorD> tcinfo;
157 tcinfo = cit->second;
161 ivertex,ig,pm,tcinfo.first,tcinfo.second));
171 for( std::vector<TrackWithHistory*>::const_iterator it = (*m_trksForThisEvent).begin();
172 it!= (*m_trksForThisEvent).end();it++)
174 if ((*it)->trackID() == uint32_t(parent)) {
180 if(check==-1) { parent = -1; }
182 VertexMap::const_iterator iterator =
m_vertexMap.find(parent);
192 unsigned int ptype = 0;
194 if(pr) { ptype = pr->GetProcessSubType(); }
219 unsigned int n =
idsave.size();
226 for(j=0; j<=jmax; ++
j) {
229 if(0 == id1 || id1 == idMother) {
return id1; }
236 if(notFound) {
return 0; }
243 for(j=jmax; j>=0; --
j) {
244 if((
idsave[j]).first == idMother) {
246 if(0 == id1 || id1 == idMother) {
return id1; }
256 for(j=jmax; j>=0; --
j) {
275 <<
" SimTrackManager::fillMotherList track index corrupted";
308 if ((*m_trksForThisEvent).size() == 0 &&
idsave.size() == 0) {
return; }
312 <<
"SimTrackManager::cleanTracksWithHistory has "
314 <<
" mother-daughter relationships stored with lastTrack = " <<
lastTrack;
320 <<
" SimTrackManager::cleanTracksWithHistory track index corrupted";
330 <<
" tracks with history before branching";
331 for (
unsigned int it =0; it <(*m_trksForThisEvent).size(); it++) {
333 <<
" 1 - Track in position " << it <<
" G4 track number "
334 << (*m_trksForThisEvent)[it]->trackID()
335 <<
" mother " << (*m_trksForThisEvent)[it]->parentID()
336 <<
" status " << (*m_trksForThisEvent)[it]->saved();
350 if (t->
saved() ==
true)
352 if (it>num) (*m_trksForThisEvent)[
num] =
t;
354 for (
unsigned int itr=0; itr<
idsave.size(); itr++) {
355 if ((
idsave[itr]).first == g4ID) {
367 (*m_trksForThisEvent).resize(num);
371 <<
" AFTER CLEANING, I GET " << (*m_trksForThisEvent).size()
372 <<
" tracks to be saved persistently";
373 for (
unsigned int it = 0; it < (*m_trksForThisEvent).size(); it++) {
375 <<
" Track in position " << it
376 <<
" G4 track number " << (*m_trksForThisEvent)[it]->trackID()
377 <<
" mother " << (*m_trksForThisEvent)[it]->parentID()
378 <<
" Status " << (*m_trksForThisEvent)[it]->saved()
379 <<
" id " << (*m_trksForThisEvent)[it]->particleID()
380 <<
" E(MeV)= " << (*m_trksForThisEvent)[it]->totalEnergy();
386 lastTrack = (*m_trksForThisEvent).size();
397 if ( genParticleID_ == -1 ) {
continue; }
399 for (
unsigned int itrlink = 0; itrlink < (*theLHCTlink).size(); itrlink++ ) {
400 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