27 #include "G4VProcess.hh" 29 #include "G4ThreeVector.hh" 30 #include <CLHEP/Units/SystemOfUnits.h> 34 const double invcm = 1.0 / CLHEP::cm;
35 const double r_limit2 = 1.e-6;
77 const auto&
v =
track->GetStep()->GetPostStepPoint()->GetPosition();
78 std::pair<int, math::XYZVectorD>
p(iTrack->
trackID(),
83 std::pair<int, int> thisPair(iTrack->
trackID(), 0);
91 if (trkH ==
nullptr) {
92 edm::LogError(
"SimTrackManager") <<
" SimTrackManager::saveTrackAndItsBranch got 0 pointer ";
93 throw cms::Exception(
"SimTrackManager::saveTrackAndItsBranch") <<
" cannot handle hits for tracking";
134 int iParentID = trkH->parentID();
135 int ig = trkH->genParticleID();
141 if (trk->trackID() == iParentID) {
153 int id = trkH->trackID();
154 if (trkH->crossedBoundary()) {
155 spos = trkH->getPositionAtBoundary();
156 smom = trkH->getMomentumAtBoundary();
158 for (
int i = 0;
i <
nn; ++
i) {
168 <<
" SimTrack ID " <<
id <<
" exceeds maximum allowed by PSimHit identifier" <<
PSimHit::k_tidOffset;
171 new TmpSimTrack(
id, trkH->particleID(), trkH->momentum(), trkH->totalEnergy(), ivertex, ig, pm, spos, smom);
180 int id = trk->trackID();
181 if (
id == iParentID) {
206 unsigned int n =
idsave.size();
213 for (
j = 0;
j <= jmax; ++
j) {
216 if (0 ==
id1 ||
id1 == idMother) {
233 for (
j = jmax;
j >= 0; --
j) {
234 if ((
idsave[
j]).first == idMother) {
236 if (0 ==
id1 ||
id1 == idMother) {
248 for (
j = jmax;
j >= 0; --
j) {
265 edm::LogError(
"SimTrackManager") <<
" SimTrackManager::fillMotherList track index corrupted";
270 for (
unsigned int i = 0;
i <
idsave.size(); ++
i) {
272 <<
" Mother ID = " << (
idsave[
i]).second;
294 LogDebug(
"SimTrackManager") <<
"SimTrackManager::cleanTracksWithHistory has " <<
idsave.size()
295 <<
" mother-daughter relationships stored with lastTrack = " <<
lastTrack;
300 edm::LogError(
"SimTrackManager") <<
" SimTrackManager::cleanTracksWithHistory track index corrupted";
307 LogDebug(
"SimTrackManager") <<
" SimTrackManager::cleanTracksWithHistory knows " << m_trksForThisEvent->size()
308 <<
" tracks with history before branching";
310 LogDebug(
"SimTrackManager") <<
" 1 - Track in position " <<
it <<
" G4 track number " 331 if (
xx.first == g4ID) {
345 <<
" tracks to be saved persistently";
363 int genParticleID = trkH->genParticleID();
364 if (genParticleID == -1) {
368 if (
xx.afterHector() == genParticleID) {
369 trkH->setGenParticleID(
xx.beforeHector());
381 <<
"Fail to get track " <<
id <<
" from SimTrackManager, container size= " <<
m_trackContainer.size();
Log< level::Info, true > LogVerbatim
std::vector< TrackWithHistory * > m_trackContainer
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
void addTrack(TmpSimTrack *t)
std::pair< int, math::XYZVectorD > VertexPosition
const math::XYZVectorD & vertexPosition() const
void copyCrossedBoundaryVars(const TrackWithHistory *track)
Log< level::Error, false > LogError
void swap(Association< C > &lhs, Association< C > &rhs)
U second(std::pair< T, U > const &p)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > XYZVectorD
spatial vector with cartesian internal representation
static constexpr unsigned int k_tidOffset
void cleanTracksWithHistory()
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
int idSavedTrack(int) const
int getOrCreateVertex(TrackWithHistory *, int)
std::vector< std::pair< int, int > > ancestorList
void ReportException(unsigned int id) const
void addVertex(TmpSimVertex *v)
SimTrackManager(TmpSimEvent *, int)
std::vector< std::pair< int, math::XYZVectorD > > m_endPoints