CMS 3D CMS Logo

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

#include <TrackingAction.h>

Inheritance diagram for TrackingAction:

Public Member Functions

TrackWithHistorycurrentTrackWithHistory ()
 
const G4Track * geant4Track () const
 
G4TrackingManager * getTrackManager ()
 
void PostUserTrackingAction (const G4Track *aTrack) override
 
void PreUserTrackingAction (const G4Track *aTrack) override
 
 TrackingAction (SimTrackManager *, CMSSteppingVerbose *, const edm::ParameterSet &ps)
 
 ~TrackingAction () override=default
 

Public Attributes

SimActivityRegistry::BeginOfTrackSignal m_beginOfTrackSignal
 
SimActivityRegistry::EndOfTrackSignal m_endOfTrackSignal
 

Private Attributes

bool checkTrack_
 
TrackWithHistorycurrentTrack_ = nullptr
 
bool doFineCalo_
 
double eMinFine_
 
int endPrintTrackID_
 
const G4Track * g4Track_ = nullptr
 
bool saveCaloBoundaryInformation_
 
CMSSteppingVerbosesteppingVerbose_
 
SimTrackManagertrackManager_
 
TrackInformationtrkInfo_ = nullptr
 

Detailed Description

Definition at line 16 of file TrackingAction.h.

Constructor & Destructor Documentation

◆ TrackingAction()

TrackingAction::TrackingAction ( SimTrackManager stm,
CMSSteppingVerbose sv,
const edm::ParameterSet ps 
)
explicit

Definition at line 20 of file TrackingAction.cc.

References doFineCalo_, eMinFine_, and saveCaloBoundaryInformation_.

21  : trackManager_(stm),
23  endPrintTrackID_(p.getParameter<int>("EndPrintTrackID")),
24  checkTrack_(p.getUntrackedParameter<bool>("CheckTrack", false)),
25  doFineCalo_(p.getParameter<bool>("DoFineCalo")),
26  saveCaloBoundaryInformation_(p.getParameter<bool>("SaveCaloBoundaryInformation")),
27  eMinFine_(p.getParameter<double>("EminFineTrack") * CLHEP::MeV) {
28  if (!doFineCalo_) {
29  eMinFine_ = DBL_MAX;
30  }
31  edm::LogVerbatim("SimG4CoreApplication") << "TrackingAction: boundary: " << saveCaloBoundaryInformation_
32  << "; DoFineCalo: " << doFineCalo_ << "; EminFineTrack(MeV)=" << eMinFine_;
33 }
Log< level::Info, true > LogVerbatim
SimTrackManager * trackManager_
CMSSteppingVerbose * steppingVerbose_
bool saveCaloBoundaryInformation_

◆ ~TrackingAction()

TrackingAction::~TrackingAction ( )
overridedefault

Member Function Documentation

◆ currentTrackWithHistory()

TrackWithHistory* TrackingAction::currentTrackWithHistory ( )
inline

Definition at line 24 of file TrackingAction.h.

References currentTrack_.

24 { return currentTrack_; }
TrackWithHistory * currentTrack_

◆ geant4Track()

const G4Track* TrackingAction::geant4Track ( ) const
inline

Definition at line 25 of file TrackingAction.h.

References g4Track_.

Referenced by StackingAction::ClassifyNewTrack().

25 { return g4Track_; }
const G4Track * g4Track_

◆ getTrackManager()

G4TrackingManager* TrackingAction::getTrackManager ( )
inline

Definition at line 26 of file TrackingAction.h.

26 { return fpTrackingManager; }

◆ PostUserTrackingAction()

void TrackingAction::PostUserTrackingAction ( const G4Track *  aTrack)
override

Definition at line 76 of file TrackingAction.cc.

References SimTrackManager::addTkCaloStateInfo(), SimTrackManager::addTrack(), TrackWithHistory::checkAtEnd(), checkTrack_, TrackInformation::crossedBoundary(), currentTrack_, doFineCalo_, EgHLTOffHistBins_cfi::et, TrackInformation::getIDonCaloSurface(), TrackInformation::getMomentumAtBoundary(), TrackInformation::getPositionAtBoundary(), TrackInformation::isAncestor(), TrackInformation::isInHistory(), m_endOfTrackSignal, AlCaHLTBitMon_ParallelJobs::p, TrackWithHistory::save(), saveCaloBoundaryInformation_, TrackWithHistory::saved(), TrackWithHistory::setCrossedBoundaryPosMom(), TrackInformation::storeTrack(), trackManager_, and trkInfo_.

Referenced by RunManagerMTWorker::abortEvent().

76  {
77  int id = aTrack->GetTrackID();
78  const auto& ppos = aTrack->GetStep()->GetPostStepPoint()->GetPosition();
79  math::XYZVectorD pos(ppos.x(), ppos.y(), ppos.z());
81  std::pair<math::XYZVectorD, math::XYZTLorentzVectorD> p(pos, mom);
82 
83 #ifdef EDM_ML_DEBUG
84  edm::LogVerbatim("DoFineCalo") << "PostUserTrackingAction:"
85  << " aTrack->GetTrackID()=" << id
86  << " currentTrack_->saved()=" << currentTrack_->saved();
87 #endif
88 
89  bool boundary = false;
90  if (doFineCalo_) {
91  // Add the post-step position for _every_ track
92  // in history to the TrackManager. Tracks in history _may_ be upgraded to stored
93  // tracks, at which point the post-step position is needed again.
95  boundary = true;
96  } else if (trkInfo_->storeTrack() || currentTrack_->saved() ||
100  boundary = true;
101  }
102  if (boundary && trkInfo_->crossedBoundary()) {
104  currentTrack_->save();
105 
106 #ifdef EDM_ML_DEBUG
107  edm::LogVerbatim("DoFineCalo") << "PostUserTrackingAction:"
108  << " Track " << id << " crossed boundary; pos=("
109  << trkInfo_->getPositionAtBoundary().x() << ","
110  << trkInfo_->getPositionAtBoundary().y() << ","
111  << trkInfo_->getPositionAtBoundary().z() << ")"
112  << " mom[GeV]=(" << trkInfo_->getMomentumAtBoundary().x() << ","
113  << trkInfo_->getMomentumAtBoundary().y() << ","
114  << trkInfo_->getMomentumAtBoundary().z() << ","
115  << trkInfo_->getMomentumAtBoundary().e() << ")";
116 #endif
117  }
118 
119  bool withAncestor = (trkInfo_->getIDonCaloSurface() == id || trkInfo_->isAncestor());
120 
121  if (trkInfo_->isInHistory()) {
122  // check with end-of-track information
123  if (checkTrack_) {
124  currentTrack_->checkAtEnd(aTrack);
125  }
126 
127  trackManager_->addTrack(currentTrack_, true, withAncestor);
128 
129 #ifdef EDM_ML_DEBUG
130  edm::LogVerbatim("SimTrackManager") << "TrackingAction addTrack " << id << " "
131  << aTrack->GetDefinition()->GetParticleName() << " added= " << withAncestor
132  << " at " << aTrack->GetPosition();
133 #endif
134 
135  } else {
136  trackManager_->addTrack(currentTrack_, false, false);
137  delete currentTrack_;
138 
139 #ifdef EDM_ML_DEBUG
140  edm::LogVerbatim("SimTrackManager") << "TrackingAction addTrack " << id << " added with false flags and deleted";
141 #endif
142  }
143 
144  EndOfTrack et(aTrack);
146 }
bool storeTrack() const
Log< level::Info, true > LogVerbatim
void addTrack(TrackWithHistory *iTrack, bool inHistory, bool withAncestor)
bool crossedBoundary() const
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:14
SimTrackManager * trackManager_
bool isAncestor() const
const math::XYZTLorentzVectorF & getPositionAtBoundary() const
void setCrossedBoundaryPosMom(int id, const math::XYZTLorentzVectorF position, const math::XYZTLorentzVectorF momentum)
TrackWithHistory * currentTrack_
bool isInHistory() const
TrackInformation * trkInfo_
void addTkCaloStateInfo(uint32_t t, const std::pair< math::XYZVectorD, math::XYZTLorentzVectorD > &p)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > XYZVectorD
spatial vector with cartesian internal representation
Definition: Vector3D.h:8
void checkAtEnd(const G4Track *)
bool saveCaloBoundaryInformation_
SimActivityRegistry::EndOfTrackSignal m_endOfTrackSignal
const math::XYZTLorentzVectorF & getMomentumAtBoundary() const
int getIDonCaloSurface() const
bool saved() const

◆ PreUserTrackingAction()

void TrackingAction::PreUserTrackingAction ( const G4Track *  aTrack)
override

Definition at line 35 of file TrackingAction.cc.

References SimTrackManager::cleanTracksWithHistory(), currentTrack_, eMinFine_, endPrintTrackID_, g4Track_, TrackInformation::isPrimary(), m_beginOfTrackSignal, TrackInformation::putInHistory(), TrackWithHistory::save(), steppingVerbose_, CMSSteppingVerbose::stopEventPrint(), trackManager_, CMSSteppingVerbose::trackStarted(), and trkInfo_.

35  {
36  g4Track_ = aTrack;
37  currentTrack_ = new TrackWithHistory(aTrack);
38 
39  BeginOfTrack bt(aTrack);
41 
42  trkInfo_ = static_cast<TrackInformation*>(aTrack->GetUserInformation());
43 
44  // Always save primaries
45  // Decays from primaries are marked as primaries (see NewTrackAction), but are not saved by
46  // default. The primary is the earliest ancestor, and it must be saved.
47  if (trkInfo_->isPrimary()) {
50  }
51  if (nullptr != steppingVerbose_) {
52  steppingVerbose_->trackStarted(aTrack, false);
53  if (aTrack->GetTrackID() == endPrintTrackID_) {
55  }
56  }
57  double ekin = aTrack->GetKineticEnergy();
58 
59 #ifdef EDM_ML_DEBUG
60  edm::LogVerbatim("DoFineCalo") << "PreUserTrackingAction: Start processing track " << aTrack->GetTrackID()
61  << " pdgid=" << aTrack->GetDefinition()->GetPDGEncoding()
62  << " ekin[GeV]=" << ekin / CLHEP::GeV << " vertex[cm]=("
63  << aTrack->GetVertexPosition().x() / CLHEP::cm << ","
64  << aTrack->GetVertexPosition().y() / CLHEP::cm << ","
65  << aTrack->GetVertexPosition().z() / CLHEP::cm << ")"
66  << " parentid=" << aTrack->GetParentID();
67 #endif
68  if (ekin > eMinFine_) {
69  // It is impossible to tell whether daughter tracks if this track may need to be saved at
70  // this point; Therefore, every track above the threshold is put in history,
71  // so that it can potentially be saved later.
73  }
74 }
Log< level::Info, true > LogVerbatim
bool isPrimary() const
SimTrackManager * trackManager_
const G4Track * g4Track_
CMSSteppingVerbose * steppingVerbose_
TrackWithHistory * currentTrack_
TrackInformation * trkInfo_
void cleanTracksWithHistory()
void trackStarted(const G4Track *, bool isKilled)
SimActivityRegistry::BeginOfTrackSignal m_beginOfTrackSignal

Member Data Documentation

◆ checkTrack_

bool TrackingAction::checkTrack_
private

Definition at line 38 of file TrackingAction.h.

Referenced by PostUserTrackingAction().

◆ currentTrack_

TrackWithHistory* TrackingAction::currentTrack_ = nullptr
private

◆ doFineCalo_

bool TrackingAction::doFineCalo_
private

Definition at line 39 of file TrackingAction.h.

Referenced by PostUserTrackingAction(), and TrackingAction().

◆ eMinFine_

double TrackingAction::eMinFine_
private

Definition at line 41 of file TrackingAction.h.

Referenced by PreUserTrackingAction(), and TrackingAction().

◆ endPrintTrackID_

int TrackingAction::endPrintTrackID_
private

Definition at line 37 of file TrackingAction.h.

Referenced by PreUserTrackingAction().

◆ g4Track_

const G4Track* TrackingAction::g4Track_ = nullptr
private

Definition at line 34 of file TrackingAction.h.

Referenced by geant4Track(), and PreUserTrackingAction().

◆ m_beginOfTrackSignal

SimActivityRegistry::BeginOfTrackSignal TrackingAction::m_beginOfTrackSignal

Definition at line 28 of file TrackingAction.h.

Referenced by RunManagerMTWorker::Connect(), and PreUserTrackingAction().

◆ m_endOfTrackSignal

SimActivityRegistry::EndOfTrackSignal TrackingAction::m_endOfTrackSignal

Definition at line 29 of file TrackingAction.h.

Referenced by RunManagerMTWorker::Connect(), and PostUserTrackingAction().

◆ saveCaloBoundaryInformation_

bool TrackingAction::saveCaloBoundaryInformation_
private

Definition at line 40 of file TrackingAction.h.

Referenced by PostUserTrackingAction(), and TrackingAction().

◆ steppingVerbose_

CMSSteppingVerbose* TrackingAction::steppingVerbose_
private

Definition at line 33 of file TrackingAction.h.

Referenced by PreUserTrackingAction().

◆ trackManager_

SimTrackManager* TrackingAction::trackManager_
private

Definition at line 32 of file TrackingAction.h.

Referenced by PostUserTrackingAction(), and PreUserTrackingAction().

◆ trkInfo_

TrackInformation* TrackingAction::trkInfo_ = nullptr
private

Definition at line 35 of file TrackingAction.h.

Referenced by PostUserTrackingAction(), and PreUserTrackingAction().