24 #include "G4VProcess.hh" 31 m_collapsePrimaryVertices(iCollapsePrimaryVertices),
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";
81 TrackContainer::const_iterator tk_itr = std::lower_bound(
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;
155 for (std::vector<TrackWithHistory*>::const_iterator it = (*m_trksForThisEvent).begin();
156 it != (*m_trksForThisEvent).end();
158 if ((*it)->trackID() == uint32_t(parent)) {
168 VertexMap::const_iterator iterator =
m_vertexMap.find(parent);
178 unsigned int ptype = 0;
181 ptype = pr->GetProcessSubType();
203 unsigned int n =
idsave.size();
210 for (j = 0; j <= jmax; ++j) {
213 if (0 == id1 || id1 == idMother) {
230 for (j = jmax; j >= 0; --j) {
231 if ((
idsave[j]).first == idMother) {
233 if (0 == id1 || id1 == idMother) {
245 for (j = jmax; j >= 0; --j) {
262 edm::LogError(
"SimTrackManager") <<
" SimTrackManager::fillMotherList track index corrupted";
292 if ((*m_trksForThisEvent).empty() &&
idsave.empty()) {
297 LogDebug(
"SimTrackManager") <<
"SimTrackManager::cleanTracksWithHistory has " <<
idsave.size()
298 <<
" mother-daughter relationships stored with lastTrack = " <<
lastTrack;
303 edm::LogError(
"SimTrackManager") <<
" SimTrackManager::cleanTracksWithHistory track index corrupted";
312 <<
" tracks with history before branching";
313 for (
unsigned int it = 0; it < (*m_trksForThisEvent).size(); it++) {
314 LogDebug(
"SimTrackManager") <<
" 1 - Track in position " << it <<
" G4 track number " 315 << (*m_trksForThisEvent)[it]->trackID() <<
" mother " 316 << (*m_trksForThisEvent)[it]->parentID() <<
" status " 317 << (*m_trksForThisEvent)[it]->saved();
331 if (t->
saved() ==
true) {
333 (*m_trksForThisEvent)[
num] =
t;
335 for (
unsigned int itr = 0; itr <
idsave.size(); itr++) {
336 if ((
idsave[itr]).first == g4ID) {
346 (*m_trksForThisEvent).resize(num);
349 LogDebug(
"SimTrackManager") <<
" AFTER CLEANING, I GET " << (*m_trksForThisEvent).size()
350 <<
" tracks to be saved persistently";
351 for (
unsigned int it = 0; it < (*m_trksForThisEvent).size(); it++) {
352 LogDebug(
"SimTrackManager") <<
" Track in position " << it <<
" G4 track number " 353 << (*m_trksForThisEvent)[it]->trackID() <<
" mother " 354 << (*m_trksForThisEvent)[it]->parentID() <<
" Status " 355 << (*m_trksForThisEvent)[it]->saved() <<
" id " 356 << (*m_trksForThisEvent)[it]->particleID()
357 <<
" E(MeV)= " << (*m_trksForThisEvent)[it]->totalEnergy();
363 lastTrack = (*m_trksForThisEvent).size();
373 if (genParticleID_ == -1) {
376 for (
unsigned int itrlink = 0; itrlink < (*theLHCTlink).size(); itrlink++) {
377 if ((*
theLHCTlink)[itrlink].afterHector() == genParticleID_) {
int getOrCreateVertex(TrackWithHistory *, int, G4SimEvent *simEvent)
std::map< int, MapVertexPositionVector > MotherParticleToVertexMap
double totalEnergy() const
SimTrackManager(bool iCollapsePrimaryVertices=false)
void setGenParticleID(int i)
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
unsigned int trackID() const
void cleanTracksWithHistory()
MotherParticleToVertexMap m_vertexMap
void storeTracks(G4SimEvent *simEvent)
int idSavedTrack(int) const
const G4VProcess * creatorProcess() const
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
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