CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
TrackWithHistory Class Reference

#include <TrackWithHistory.h>

Public Member Functions

void checkAtEnd (const G4Track *)
 
const G4VProcess * creatorProcess () const
 
bool crossedBoundary () const
 
int genParticleID () const
 
int getIDAtBoundary () const
 
const math::XYZTLorentzVectorFgetMomentumAtBoundary () const
 
const math::XYZTLorentzVectorFgetPositionAtBoundary () const
 
double globalTime () const
 
double localTime () const
 
const math::XYZVectorDmomentum () const
 
void operator delete (void *TrackWithHistory)
 
void * operator new (size_t)
 
int parentID () const
 
int particleID () const
 
double properTime () const
 
void save ()
 
bool saved () const
 
void setCrossedBoundaryPosMom (int id, const math::XYZTLorentzVectorF position, const math::XYZTLorentzVectorF momentum)
 
void setGenParticleID (int i)
 
void setParentID (int i)
 
void setTrackID (int i)
 
bool storeTrack () const
 
double totalEnergy () const
 
unsigned int trackID () const
 
 TrackWithHistory (const G4Track *g4track)
 
const math::XYZVectorDvertexPosition () const
 
double weight () const
 
 ~TrackWithHistory ()
 

Private Member Functions

int extractGenID (const G4Track *gt) const
 

Private Attributes

const G4VProcess * creatorProcess_
 
bool crossedBoundary_
 
int genParticleID_
 
double globalTime_
 
int idAtBoundary_
 
bool isPrimary_
 
double localTime_
 
math::XYZVectorD momentum_
 
math::XYZTLorentzVectorF momentumAtBoundary_
 
int parentID_
 
int particleID_
 
math::XYZTLorentzVectorF positionAtBoundary_
 
double properTime_
 
bool saved_
 
bool storeTrack_
 
double totalEnergy_
 
unsigned int trackID_
 
math::XYZVectorD vertexPosition_
 
double weight_
 

Detailed Description

The part of the information about a SimTrack that we need from a G4Track

Definition at line 16 of file TrackWithHistory.h.

Constructor & Destructor Documentation

◆ TrackWithHistory()

TrackWithHistory::TrackWithHistory ( const G4Track *  g4track)

The constructor is called at PreUserTrackingAction time, when some of the information is not available yet.

Definition at line 17 of file TrackWithHistory.cc.

18  : trackID_(0),
19  particleID_(0),
20  parentID_(0),
21  momentum_(math::XYZVectorD(0., 0., 0.)),
22  totalEnergy_(0),
23  vertexPosition_(math::XYZVectorD(0., 0., 0.)),
24  globalTime_(0),
25  localTime_(0),
26  properTime_(0),
27  creatorProcess_(nullptr),
28  weight_(0),
29  storeTrack_(false),
30  saved_(false) {
31  if (g4trk != nullptr) {
32  TrackInformationExtractor extractor;
33  trackID_ = g4trk->GetTrackID();
35  parentID_ = g4trk->GetParentID();
36  momentum_ = math::XYZVectorD(g4trk->GetMomentum().x(), g4trk->GetMomentum().y(), g4trk->GetMomentum().z());
37  totalEnergy_ = g4trk->GetTotalEnergy();
38  vertexPosition_ = math::XYZVectorD(g4trk->GetPosition().x(), g4trk->GetPosition().y(), g4trk->GetPosition().z());
39  globalTime_ = g4trk->GetGlobalTime();
40  localTime_ = g4trk->GetLocalTime();
41  properTime_ = g4trk->GetProperTime();
42  creatorProcess_ = g4trk->GetCreatorProcess();
43  storeTrack_ = extractor(g4trk).storeTrack();
44  saved_ = false;
45  crossedBoundary_ = false;
47  // V.I. weight is computed in the same way as before
48  // without usage of G4Track::GetWeight()
49  weight_ = 10000 * genParticleID_;
50 #ifdef DEBUG
51  LogDebug("TrackInformation") << " TrackWithHistory : created history for " << trackID_ << " with mother "
52  << parentID_;
53 #endif
54  }
55 }

References creatorProcess_, crossedBoundary_, extractGenID(), genParticleID_, globalTime_, localTime_, LogDebug, momentum_, parentID_, G4TrackToParticleID::particleID(), particleID_, properTime_, saved_, storeTrack_, totalEnergy_, trackID_, vertexPosition_, and weight_.

◆ ~TrackWithHistory()

TrackWithHistory::~TrackWithHistory ( )
inline

Definition at line 22 of file TrackWithHistory.h.

22 {}

Member Function Documentation

◆ checkAtEnd()

void TrackWithHistory::checkAtEnd ( const G4Track *  gt)

Internal consistency check (optional). Method called at PostUserTrackingAction time, to check if the information is consistent with that provided to the constructor.

Definition at line 57 of file TrackWithHistory.cc.

57  {
58  math::XYZVectorD vposdir(gt->GetVertexPosition().x(), gt->GetVertexPosition().y(), gt->GetVertexPosition().z());
59  math::XYZVectorD vmomdir(
60  gt->GetVertexMomentumDirection().x(), gt->GetVertexMomentumDirection().y(), gt->GetVertexMomentumDirection().z());
61  bool ok = true;
62  double epsilon = 1.e-6;
63  double eps2 = epsilon * epsilon;
64  if ((vertexPosition_ - vposdir).Mag2() > eps2) {
65  edm::LogWarning("TrackInformation") << "TrackWithHistory vertex position check failed"
66  << "\nAt construction: " << vertexPosition_ << "\nAt end: " << vposdir;
67  ok = false;
68  }
69  math::XYZVectorD dirDiff = momentum_.Unit() - vmomdir;
70  if (dirDiff.Mag2() > eps2 && momentum_.Unit().R() > eps2) {
71  edm::LogWarning("TrackInformation") << "TrackWithHistory momentum direction check failed"
72  << "\nAt construction: " << momentum_.Unit()
73  << "\nAt end: " << vmomdir;
74  ok = false;
75  }
76  if (!ok)
77  throw SimG4Exception("TrackWithHistory::checkAtEnd failed");
78 }

References geometryDiff::epsilon, submitPVValidationJobs::gt, momentum_, convertSQLiteXML::ok, and vertexPosition_.

Referenced by TrackingAction::PostUserTrackingAction().

◆ creatorProcess()

const G4VProcess* TrackWithHistory::creatorProcess ( ) const
inline

Definition at line 38 of file TrackWithHistory.h.

38 { return creatorProcess_; }

References creatorProcess_.

Referenced by SimTrackManager::getOrCreateVertex().

◆ crossedBoundary()

bool TrackWithHistory::crossedBoundary ( ) const
inline

Definition at line 55 of file TrackWithHistory.h.

55 { return crossedBoundary_; }

References crossedBoundary_.

Referenced by CaloSD::hitBookkeepingFineCalo().

◆ extractGenID()

int TrackWithHistory::extractGenID ( const G4Track *  gt) const
private

Definition at line 80 of file TrackWithHistory.cc.

80  {
81  void* vgprimary = gt->GetDynamicParticle()->GetPrimaryParticle();
82  if (vgprimary == nullptr)
83  return -1;
84  // replace old-style cast with appropriate new-style cast...
85  G4PrimaryParticle* gprimary = (G4PrimaryParticle*)vgprimary;
87  return ext(gprimary).id();
88 }

References submitPVValidationJobs::gt.

Referenced by TrackWithHistory().

◆ genParticleID()

int TrackWithHistory::genParticleID ( ) const
inline

Definition at line 31 of file TrackWithHistory.h.

31 { return genParticleID_; }

References genParticleID_.

Referenced by SimTrackManager::reallyStoreTracks(), and SimTrackManager::resetGenID().

◆ getIDAtBoundary()

int TrackWithHistory::getIDAtBoundary ( ) const
inline

Definition at line 58 of file TrackWithHistory.h.

58 { return idAtBoundary_; }

References idAtBoundary_.

Referenced by CaloSD::hitBookkeepingFineCalo().

◆ getMomentumAtBoundary()

const math::XYZTLorentzVectorF& TrackWithHistory::getMomentumAtBoundary ( ) const
inline

Definition at line 57 of file TrackWithHistory.h.

57 { return momentumAtBoundary_; }

References momentumAtBoundary_.

Referenced by CaloSD::hitBookkeepingFineCalo().

◆ getPositionAtBoundary()

const math::XYZTLorentzVectorF& TrackWithHistory::getPositionAtBoundary ( ) const
inline

Definition at line 56 of file TrackWithHistory.h.

56 { return positionAtBoundary_; }

References positionAtBoundary_.

Referenced by CaloSD::hitBookkeepingFineCalo().

◆ globalTime()

double TrackWithHistory::globalTime ( ) const
inline

Definition at line 35 of file TrackWithHistory.h.

35 { return globalTime_; }

References globalTime_.

Referenced by SimTrackManager::getOrCreateVertex().

◆ localTime()

double TrackWithHistory::localTime ( ) const
inline

Definition at line 36 of file TrackWithHistory.h.

36 { return localTime_; }

References localTime_.

◆ momentum()

const math::XYZVectorD& TrackWithHistory::momentum ( ) const
inline

Definition at line 32 of file TrackWithHistory.h.

32 { return momentum_; }

References momentum_.

Referenced by CaloSD::createNewHit(), SimTrackManager::reallyStoreTracks(), and setCrossedBoundaryPosMom().

◆ operator delete()

void TrackWithHistory::operator delete ( void *  TrackWithHistory)
inline

Definition at line 99 of file TrackWithHistory.h.

99  {
100  fpTrackWithHistoryAllocator->FreeSingle((TrackWithHistory *)aTwH);
101 }

References fpTrackWithHistoryAllocator.

◆ operator new()

void * TrackWithHistory::operator new ( size_t  )
inline

Definition at line 93 of file TrackWithHistory.h.

93  {
95  fpTrackWithHistoryAllocator = new G4Allocator<TrackWithHistory>;
96  return (void *)fpTrackWithHistoryAllocator->MallocSingle();
97 }

References fpTrackWithHistoryAllocator.

◆ parentID()

int TrackWithHistory::parentID ( ) const
inline

◆ particleID()

int TrackWithHistory::particleID ( ) const
inline

Definition at line 29 of file TrackWithHistory.h.

29 { return particleID_; }

References particleID_.

Referenced by SimTrackManager::reallyStoreTracks().

◆ properTime()

double TrackWithHistory::properTime ( ) const
inline

Definition at line 37 of file TrackWithHistory.h.

37 { return properTime_; }

References properTime_.

◆ save()

void TrackWithHistory::save ( )
inline

◆ saved()

bool TrackWithHistory::saved ( ) const
inline

Definition at line 44 of file TrackWithHistory.h.

44 { return saved_; }

References saved_.

Referenced by CaloSD::hitBookkeepingFineCalo(), and TrackingAction::PostUserTrackingAction().

◆ setCrossedBoundaryPosMom()

void TrackWithHistory::setCrossedBoundaryPosMom ( int  id,
const math::XYZTLorentzVectorF  position,
const math::XYZTLorentzVectorF  momentum 
)
inline

◆ setGenParticleID()

void TrackWithHistory::setGenParticleID ( int  i)
inline

Definition at line 42 of file TrackWithHistory.h.

42 { genParticleID_ = i; }

References genParticleID_, and mps_fire::i.

Referenced by SimTrackManager::resetGenID().

◆ setParentID()

void TrackWithHistory::setParentID ( int  i)
inline

Definition at line 41 of file TrackWithHistory.h.

41 { parentID_ = i; }

References mps_fire::i, and parentID_.

◆ setTrackID()

void TrackWithHistory::setTrackID ( int  i)
inline

Definition at line 40 of file TrackWithHistory.h.

40 { trackID_ = i; }

References mps_fire::i, and trackID_.

◆ storeTrack()

bool TrackWithHistory::storeTrack ( ) const
inline

Definition at line 43 of file TrackWithHistory.h.

43 { return storeTrack_; }

References storeTrack_.

◆ totalEnergy()

double TrackWithHistory::totalEnergy ( ) const
inline

Definition at line 33 of file TrackWithHistory.h.

33 { return totalEnergy_; }

References totalEnergy_.

Referenced by SimTrackManager::reallyStoreTracks().

◆ trackID()

unsigned int TrackWithHistory::trackID ( ) const
inline

◆ vertexPosition()

const math::XYZVectorD& TrackWithHistory::vertexPosition ( ) const
inline

Definition at line 34 of file TrackWithHistory.h.

34 { return vertexPosition_; }

References vertexPosition_.

Referenced by SimTrackManager::getOrCreateVertex().

◆ weight()

double TrackWithHistory::weight ( ) const
inline

Definition at line 39 of file TrackWithHistory.h.

39 { return weight_; }

References weight_.

Member Data Documentation

◆ creatorProcess_

const G4VProcess* TrackWithHistory::creatorProcess_
private

Definition at line 77 of file TrackWithHistory.h.

Referenced by creatorProcess(), and TrackWithHistory().

◆ crossedBoundary_

bool TrackWithHistory::crossedBoundary_
private

Definition at line 83 of file TrackWithHistory.h.

Referenced by crossedBoundary(), setCrossedBoundaryPosMom(), and TrackWithHistory().

◆ genParticleID_

int TrackWithHistory::genParticleID_
private

Definition at line 70 of file TrackWithHistory.h.

Referenced by genParticleID(), setGenParticleID(), and TrackWithHistory().

◆ globalTime_

double TrackWithHistory::globalTime_
private

Definition at line 74 of file TrackWithHistory.h.

Referenced by globalTime(), and TrackWithHistory().

◆ idAtBoundary_

int TrackWithHistory::idAtBoundary_
private

Definition at line 84 of file TrackWithHistory.h.

Referenced by getIDAtBoundary(), and setCrossedBoundaryPosMom().

◆ isPrimary_

bool TrackWithHistory::isPrimary_
private

Definition at line 82 of file TrackWithHistory.h.

◆ localTime_

double TrackWithHistory::localTime_
private

Definition at line 75 of file TrackWithHistory.h.

Referenced by localTime(), and TrackWithHistory().

◆ momentum_

math::XYZVectorD TrackWithHistory::momentum_
private

Definition at line 71 of file TrackWithHistory.h.

Referenced by checkAtEnd(), momentum(), and TrackWithHistory().

◆ momentumAtBoundary_

math::XYZTLorentzVectorF TrackWithHistory::momentumAtBoundary_
private

Definition at line 86 of file TrackWithHistory.h.

Referenced by getMomentumAtBoundary(), and setCrossedBoundaryPosMom().

◆ parentID_

int TrackWithHistory::parentID_
private

Definition at line 69 of file TrackWithHistory.h.

Referenced by parentID(), setParentID(), and TrackWithHistory().

◆ particleID_

int TrackWithHistory::particleID_
private

Definition at line 68 of file TrackWithHistory.h.

Referenced by particleID(), and TrackWithHistory().

◆ positionAtBoundary_

math::XYZTLorentzVectorF TrackWithHistory::positionAtBoundary_
private

Definition at line 85 of file TrackWithHistory.h.

Referenced by getPositionAtBoundary(), and setCrossedBoundaryPosMom().

◆ properTime_

double TrackWithHistory::properTime_
private

Definition at line 76 of file TrackWithHistory.h.

Referenced by properTime(), and TrackWithHistory().

◆ saved_

bool TrackWithHistory::saved_
private

Definition at line 80 of file TrackWithHistory.h.

Referenced by save(), saved(), and TrackWithHistory().

◆ storeTrack_

bool TrackWithHistory::storeTrack_
private

Definition at line 79 of file TrackWithHistory.h.

Referenced by storeTrack(), and TrackWithHistory().

◆ totalEnergy_

double TrackWithHistory::totalEnergy_
private

Definition at line 72 of file TrackWithHistory.h.

Referenced by totalEnergy(), and TrackWithHistory().

◆ trackID_

unsigned int TrackWithHistory::trackID_
private

Definition at line 67 of file TrackWithHistory.h.

Referenced by setTrackID(), trackID(), and TrackWithHistory().

◆ vertexPosition_

math::XYZVectorD TrackWithHistory::vertexPosition_
private

Definition at line 73 of file TrackWithHistory.h.

Referenced by checkAtEnd(), TrackWithHistory(), and vertexPosition().

◆ weight_

double TrackWithHistory::weight_
private

Definition at line 78 of file TrackWithHistory.h.

Referenced by TrackWithHistory(), and weight().

TrackWithHistory::parentID_
int parentID_
Definition: TrackWithHistory.h:69
ext
Definition: memstream.h:15
mps_fire.i
i
Definition: mps_fire.py:428
TrackWithHistory::weight_
double weight_
Definition: TrackWithHistory.h:78
TrackWithHistory::trackID_
unsigned int trackID_
Definition: TrackWithHistory.h:67
TrackWithHistory::localTime_
double localTime_
Definition: TrackWithHistory.h:75
TrackWithHistory
Definition: TrackWithHistory.h:16
SimG4Exception
Definition: SimG4Exception.h:13
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
TrackWithHistory::totalEnergy_
double totalEnergy_
Definition: TrackWithHistory.h:72
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
G4TrackToParticleID::particleID
static int particleID(const G4Track *)
Definition: G4TrackToParticleID.cc:7
TrackWithHistory::positionAtBoundary_
math::XYZTLorentzVectorF positionAtBoundary_
Definition: TrackWithHistory.h:85
geometryDiff.epsilon
int epsilon
Definition: geometryDiff.py:26
TrackWithHistory::idAtBoundary_
int idAtBoundary_
Definition: TrackWithHistory.h:84
GenParticleInfoExtractor
Definition: GenParticleInfoExtractor.h:8
TrackWithHistory::creatorProcess_
const G4VProcess * creatorProcess_
Definition: TrackWithHistory.h:77
TrackInformationExtractor
Definition: TrackInformationExtractor.h:20
submitPVValidationJobs.gt
list gt
Definition: submitPVValidationJobs.py:663
TrackWithHistory::vertexPosition_
math::XYZVectorD vertexPosition_
Definition: TrackWithHistory.h:73
TrackWithHistory::storeTrack_
bool storeTrack_
Definition: TrackWithHistory.h:79
TrackWithHistory::momentumAtBoundary_
math::XYZTLorentzVectorF momentumAtBoundary_
Definition: TrackWithHistory.h:86
TrackWithHistory::saved_
bool saved_
Definition: TrackWithHistory.h:80
math::XYZVectorD
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > XYZVectorD
spatial vector with cartesian internal representation
Definition: Vector3D.h:8
TrackWithHistory::momentum_
math::XYZVectorD momentum_
Definition: TrackWithHistory.h:71
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
fpTrackWithHistoryAllocator
G4ThreadLocal G4Allocator< TrackWithHistory > * fpTrackWithHistoryAllocator
Definition: TrackWithHistory.cc:13
position
static int position[264][3]
Definition: ReadPGInfo.cc:289
TrackWithHistory::globalTime_
double globalTime_
Definition: TrackWithHistory.h:74
TrackWithHistory::crossedBoundary_
bool crossedBoundary_
Definition: TrackWithHistory.h:83
TrackWithHistory::extractGenID
int extractGenID(const G4Track *gt) const
Definition: TrackWithHistory.cc:80
TrackWithHistory::particleID_
int particleID_
Definition: TrackWithHistory.h:68
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
TrackWithHistory::momentum
const math::XYZVectorD & momentum() const
Definition: TrackWithHistory.h:32
TrackWithHistory::genParticleID_
int genParticleID_
Definition: TrackWithHistory.h:70
TrackWithHistory::properTime_
double properTime_
Definition: TrackWithHistory.h:76