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
 
int genParticleID () 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 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_
 
int genParticleID_
 
double globalTime_
 
double localTime_
 
math::XYZVectorD momentum_
 
int parentID_
 
int particleID_
 
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 ( 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.

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

Referenced by ~TrackWithHistory().

17  :
21  storeTrack_(false),saved_(false) {
22 
23  if (g4trk!=0) {
24  TrackInformationExtractor extractor;
25  trackID_ = g4trk->GetTrackID();
27  parentID_ = g4trk->GetParentID();
28  momentum_ = math::XYZVectorD(g4trk->GetMomentum().x(),g4trk->GetMomentum().y(),g4trk->GetMomentum().z());
29  totalEnergy_ = g4trk->GetTotalEnergy();
30  vertexPosition_ = math::XYZVectorD(g4trk->GetPosition().x(),g4trk->GetPosition().y(),g4trk->GetPosition().z());
31  globalTime_ = g4trk->GetGlobalTime();
32  localTime_ = g4trk->GetLocalTime();
33  properTime_ = g4trk->GetProperTime();
34  creatorProcess_ = g4trk->GetCreatorProcess();
35  storeTrack_ = extractor(g4trk).storeTrack();
36  saved_ = false;
37  genParticleID_ = extractGenID( g4trk);
38  // V.I. weight is computed in the same way as before
39  // without usage of G4Track::GetWeight()
40  weight_ = 10000*genParticleID_;
41 #ifdef DEBUG
42  LogDebug("TrackInformation") << " TrackWithHistory : created history for " << trackID_
43  << " with mother " << parentID_;
44 #endif
45  }
46 }
#define LogDebug(id)
const G4VProcess * creatorProcess_
int extractGenID(const G4Track *gt) const
math::XYZVectorD vertexPosition_
math::XYZVectorD momentum_
unsigned int trackID_
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > XYZVectorD
spatial vector with cartesian internal representation
Definition: Vector3D.h:8
static int particleID(const G4Track *)
TrackWithHistory::~TrackWithHistory ( )
inline

Definition at line 23 of file TrackWithHistory.h.

References TrackWithHistory().

23 {}

Member Function Documentation

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 48 of file TrackWithHistory.cc.

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

Referenced by TrackingAction::PostUserTrackingAction(), and saved().

48  {
49 
50  math::XYZVectorD vposdir(gt->GetVertexPosition().x(),gt->GetVertexPosition().y(),gt->GetVertexPosition().z());
51  math::XYZVectorD vmomdir(gt->GetVertexMomentumDirection().x(),gt->GetVertexMomentumDirection().y(),gt->GetVertexMomentumDirection().z());
52  bool ok = true;
53  double epsilon = 1.e-6;
54  double eps2 = epsilon*epsilon;
55  if ((vertexPosition_-vposdir).Mag2() > eps2) {
56  edm::LogWarning("TrackInformation") << "TrackWithHistory vertex position check failed"
57  << "\nAt construction: " << vertexPosition_
58  << "\nAt end: " << vposdir;
59  ok = false;
60  }
61  math::XYZVectorD dirDiff = momentum_.Unit() - vmomdir;
62  if (dirDiff.Mag2() > eps2 && momentum_.Unit().R() > eps2) {
63  edm::LogWarning("TrackInformation") << "TrackWithHistory momentum direction check failed"
64  << "\nAt construction: " << momentum_.Unit()
65  << "\nAt end: " << vmomdir;
66  ok = false;
67  }
68  if (!ok) throw SimG4Exception("TrackWithHistory::checkAtEnd failed");
69 }
math::XYZVectorD vertexPosition_
math::XYZVectorD momentum_
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > XYZVectorD
spatial vector with cartesian internal representation
Definition: Vector3D.h:8
const G4VProcess* TrackWithHistory::creatorProcess ( ) const
inline

Definition at line 39 of file TrackWithHistory.h.

References creatorProcess_.

Referenced by SimTrackManager::getOrCreateVertex().

39 { return creatorProcess_; }
const G4VProcess * creatorProcess_
int TrackWithHistory::extractGenID ( const G4Track *  gt) const
private

Definition at line 71 of file TrackWithHistory.cc.

Referenced by TrackWithHistory().

71  {
72  void * vgprimary = gt->GetDynamicParticle()->GetPrimaryParticle();
73  if (vgprimary == 0) return -1;
74  // replace old-style cast with appropriate new-style cast...
75  G4PrimaryParticle* gprimary = (G4PrimaryParticle*) vgprimary;
77  return ext(gprimary).id();
78 }
Definition: memstream.h:15
int TrackWithHistory::genParticleID ( ) const
inline

Definition at line 32 of file TrackWithHistory.h.

References genParticleID_.

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

32 { return genParticleID_; }
double TrackWithHistory::globalTime ( ) const
inline

Definition at line 36 of file TrackWithHistory.h.

References globalTime_.

Referenced by SimTrackManager::getOrCreateVertex().

36 { return globalTime_; }
double TrackWithHistory::localTime ( ) const
inline

Definition at line 37 of file TrackWithHistory.h.

References localTime_.

37 { return localTime_; }
const math::XYZVectorD& TrackWithHistory::momentum ( ) const
inline

Definition at line 33 of file TrackWithHistory.h.

References momentum_.

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

33 { return momentum_; }
math::XYZVectorD momentum_
void TrackWithHistory::operator delete ( void *  TrackWithHistory)
inline

Definition at line 78 of file TrackWithHistory.h.

References fpTrackWithHistoryAllocator.

78  {
79  fpTrackWithHistoryAllocator->FreeSingle((TrackWithHistory*) aTwH);
80 }
G4ThreadLocal G4Allocator< TrackWithHistory > * fpTrackWithHistoryAllocator
void * TrackWithHistory::operator new ( size_t  )
inline

Definition at line 72 of file TrackWithHistory.h.

References fpTrackWithHistoryAllocator.

72  {
74  new G4Allocator<TrackWithHistory>;
75  return (void*)fpTrackWithHistoryAllocator->MallocSingle();
76 }
G4ThreadLocal G4Allocator< TrackWithHistory > * fpTrackWithHistoryAllocator
int TrackWithHistory::parentID ( ) const
inline
int TrackWithHistory::particleID ( ) const
inline

Definition at line 30 of file TrackWithHistory.h.

References particleID_.

Referenced by SimTrackManager::reallyStoreTracks().

30 { return particleID_; }
double TrackWithHistory::properTime ( ) const
inline

Definition at line 38 of file TrackWithHistory.h.

References properTime_.

38 { return properTime_; }
void TrackWithHistory::save ( )
inline
bool TrackWithHistory::saved ( ) const
inline

Definition at line 45 of file TrackWithHistory.h.

References checkAtEnd(), and saved_.

Referenced by SimTrackManager::cleanTracksWithHistory().

45 { return saved_; }
void TrackWithHistory::setGenParticleID ( int  i)
inline

Definition at line 43 of file TrackWithHistory.h.

References genParticleID_, and mps_fire::i.

Referenced by SimTrackManager::resetGenID().

void TrackWithHistory::setParentID ( int  i)
inline

Definition at line 42 of file TrackWithHistory.h.

References mps_fire::i, and parentID_.

void TrackWithHistory::setTrackID ( int  i)
inline

Definition at line 41 of file TrackWithHistory.h.

References mps_fire::i, and trackID_.

41 { trackID_ = i; }
unsigned int trackID_
bool TrackWithHistory::storeTrack ( ) const
inline

Definition at line 44 of file TrackWithHistory.h.

References storeTrack_.

44 { return storeTrack_; }
double TrackWithHistory::totalEnergy ( ) const
inline

Definition at line 34 of file TrackWithHistory.h.

References totalEnergy_.

Referenced by SimTrackManager::reallyStoreTracks().

34 { return totalEnergy_; }
unsigned int TrackWithHistory::trackID ( ) const
inline
const math::XYZVectorD& TrackWithHistory::vertexPosition ( ) const
inline

Definition at line 35 of file TrackWithHistory.h.

References vertexPosition_.

Referenced by SimTrackManager::getOrCreateVertex().

35 { return vertexPosition_; }
math::XYZVectorD vertexPosition_
double TrackWithHistory::weight ( void  ) const
inline

Definition at line 40 of file TrackWithHistory.h.

References weight_.

40 { return weight_; }

Member Data Documentation

const G4VProcess* TrackWithHistory::creatorProcess_
private

Definition at line 63 of file TrackWithHistory.h.

Referenced by creatorProcess(), and TrackWithHistory().

int TrackWithHistory::genParticleID_
private

Definition at line 56 of file TrackWithHistory.h.

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

double TrackWithHistory::globalTime_
private

Definition at line 60 of file TrackWithHistory.h.

Referenced by globalTime(), and TrackWithHistory().

double TrackWithHistory::localTime_
private

Definition at line 61 of file TrackWithHistory.h.

Referenced by localTime(), and TrackWithHistory().

math::XYZVectorD TrackWithHistory::momentum_
private

Definition at line 57 of file TrackWithHistory.h.

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

int TrackWithHistory::parentID_
private

Definition at line 55 of file TrackWithHistory.h.

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

int TrackWithHistory::particleID_
private

Definition at line 54 of file TrackWithHistory.h.

Referenced by particleID(), and TrackWithHistory().

double TrackWithHistory::properTime_
private

Definition at line 62 of file TrackWithHistory.h.

Referenced by properTime(), and TrackWithHistory().

bool TrackWithHistory::saved_
private

Definition at line 66 of file TrackWithHistory.h.

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

bool TrackWithHistory::storeTrack_
private

Definition at line 65 of file TrackWithHistory.h.

Referenced by storeTrack(), and TrackWithHistory().

double TrackWithHistory::totalEnergy_
private

Definition at line 58 of file TrackWithHistory.h.

Referenced by totalEnergy(), and TrackWithHistory().

unsigned int TrackWithHistory::trackID_
private

Definition at line 53 of file TrackWithHistory.h.

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

math::XYZVectorD TrackWithHistory::vertexPosition_
private

Definition at line 59 of file TrackWithHistory.h.

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

double TrackWithHistory::weight_
private

Definition at line 64 of file TrackWithHistory.h.

Referenced by TrackWithHistory(), and weight().