26 #include "G4VProcess.hh" 28 #include "G4ThreeVector.hh" 29 #include "G4SystemOfUnits.hh" 72 const auto&
v =
track->GetStep()->GetPostStepPoint()->GetPosition();
73 const double invcm = 1.0 / CLHEP::cm;
74 std::pair<int, math::XYZVectorD>
p(iTrack->
trackID(),
79 std::pair<int, int> thisPair(iTrack->
trackID(), 0);
87 if (trkH ==
nullptr) {
88 edm::LogError(
"SimTrackManager") <<
" SimTrackManager::saveTrackAndItsBranch got 0 pointer ";
89 throw cms::Exception(
"SimTrackManager::saveTrackAndItsBranch") <<
" cannot handle hits for tracking";
130 unsigned int iParentID = trkH->parentID();
131 int ig = trkH->genParticleID();
137 if (trk->trackID() == iParentID) {
149 int id = trkH->trackID();
150 if (trkH->crossedBoundary()) {
151 spos = trkH->getPositionAtBoundary();
152 smom = trkH->getMomentumAtBoundary();
154 for (
int i = 0;
i <
nn; ++
i) {
163 new G4SimTrack(
id, trkH->particleID(), trkH->momentum(), trkH->totalEnergy(), ivertex, ig, pm, spos, smom);
165 simEvent->
add(g4simtrack);
172 int id = trk->trackID();
173 if (
id == iParentID) {
189 unsigned int ptype = 0;
192 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";
267 for (
unsigned int i = 0;
i <
idsave.size(); ++
i) {
269 <<
" Mother ID = " << (
idsave[
i]).second;
291 LogDebug(
"SimTrackManager") <<
"SimTrackManager::cleanTracksWithHistory has " <<
idsave.size()
292 <<
" mother-daughter relationships stored with lastTrack = " <<
lastTrack;
297 edm::LogError(
"SimTrackManager") <<
" SimTrackManager::cleanTracksWithHistory track index corrupted";
304 LogDebug(
"SimTrackManager") <<
" SimTrackManager::cleanTracksWithHistory knows " << m_trksForThisEvent->size()
305 <<
" tracks with history before branching";
307 LogDebug(
"SimTrackManager") <<
" 1 - Track in position " << it <<
" G4 track number " 328 if (
xx.first == g4ID) {
342 <<
" tracks to be saved persistently";
344 LogDebug(
"SimTrackManager") <<
" Track in position " << it <<
" G4 track number " <<
m_trackContainer[it]->trackID()
360 int genParticleID = trkH->genParticleID();
361 if (genParticleID == -1) {
365 if (
xx.afterHector() == genParticleID) {
366 trkH->setGenParticleID(
xx.beforeHector());
378 <<
"Fail to get track " <<
id <<
" from SimTrackManager, container size= " <<
m_trackContainer.size();
void copyCrossedBoundaryVars(const TrackWithHistory *track)
Log< level::Info, true > LogVerbatim
std::vector< TrackWithHistory * > m_trackContainer
double globalTime() const
int getOrCreateVertex(TrackWithHistory *, int, G4SimEvent *simEvent)
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
std::pair< int, math::XYZVectorD > VertexPosition
const math::XYZVectorD & vertexPosition() const
Log< level::Error, false > LogError
void swap(Association< C > &lhs, Association< C > &rhs)
virtual ~SimTrackManager()
U second(std::pair< T, U > const &p)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > XYZVectorD
spatial vector with cartesian internal representation
void cleanTracksWithHistory()
void storeTracks(G4SimEvent *simEvent)
void addTrack(TrackWithHistory *iTrack, const G4Track *track, bool inHistory, bool withAncestor)
std::vector< std::pair< int, int > > idsave
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
void ReportException(unsigned int id) const
const G4VProcess * creatorProcess() const
unsigned int trackID() const
std::vector< std::pair< int, math::XYZVectorD > > m_endPoints