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 (EventAction *ea, const edm::ParameterSet &ps, CMSSteppingVerbose *)
 
 ~TrackingAction () override
 

Public Attributes

SimActivityRegistry::BeginOfTrackSignal m_beginOfTrackSignal
 
SimActivityRegistry::EndOfTrackSignal m_endOfTrackSignal
 

Private Attributes

bool checkTrack_
 
TrackWithHistorycurrentTrack_
 
bool doFineCalo_
 
double eMinFine_
 
EventActioneventAction_
 
TrackInformationExtractor extractor_
 
const G4Track * g4Track_
 
bool saveCaloBoundaryInformation_
 
CMSSteppingVerbosesteppingVerbose_
 

Detailed Description

Definition at line 16 of file TrackingAction.h.

Constructor & Destructor Documentation

◆ TrackingAction()

TrackingAction::TrackingAction ( EventAction ea,
const edm::ParameterSet ps,
CMSSteppingVerbose sv 
)
explicit

Definition at line 19 of file TrackingAction.cc.

20  : eventAction_(e),
21  currentTrack_(nullptr),
23  g4Track_(nullptr),
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) {}
const G4Track * g4Track_
CMSSteppingVerbose * steppingVerbose_
TrackWithHistory * currentTrack_
EventAction * eventAction_
bool saveCaloBoundaryInformation_

◆ ~TrackingAction()

TrackingAction::~TrackingAction ( )
override

Definition at line 29 of file TrackingAction.cc.

29 {}

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(), and LowEnergyFastSimModel::ModelTrigger().

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 68 of file TrackingAction.cc.

References EventAction::addTkCaloStateInfo(), EventAction::addTrack(), TrackWithHistory::checkAtEnd(), checkTrack_, TrackInformation::crossedBoundary(), currentTrack_, doFineCalo_, EgHLTOffHistBins_cfi::et, eventAction_, extractor_, TrackInformation::getMomentumAtBoundary(), TrackInformation::getPositionAtBoundary(), m_endOfTrackSignal, AlCaHLTBitMon_ParallelJobs::p, TrackWithHistory::save(), saveCaloBoundaryInformation_, TrackWithHistory::saved(), TrackWithHistory::setCrossedBoundaryPosMom(), steppingVerbose_, EventAction::trackContainer(), CMSSteppingVerbose::TrackEnded(), and TrackWithHistory::trackID().

Referenced by RunManagerMTWorker::abortEvent().

68  {
69  if (eventAction_->trackContainer() != nullptr) {
70  uint32_t id = aTrack->GetTrackID();
71  math::XYZVectorD pos(aTrack->GetStep()->GetPostStepPoint()->GetPosition().x(),
72  aTrack->GetStep()->GetPostStepPoint()->GetPosition().y(),
73  aTrack->GetStep()->GetPostStepPoint()->GetPosition().z());
75  std::pair<math::XYZVectorD, math::XYZTLorentzVectorD> p(pos, mom);
76 
77 #ifdef EDM_ML_DEBUG
78  edm::LogVerbatim("DoFineCalo") << "PostUserTrackingAction:"
79  << " aTrack->GetTrackID()=" << aTrack->GetTrackID()
80  << " currentTrack_->saved()=" << currentTrack_->saved() << " PostStepPosition=("
81  << pos.x() << "," << pos.y() << "," << pos.z() << ")";
82 #endif
83 
84  if (doFineCalo_) {
85  TrackInformation* trkInfo = (TrackInformation*)aTrack->GetUserInformation();
86  // Add the post-step position for _every_ track
87  // in history to the TrackManager. Tracks in history _may_ be upgraded to stored
88  // tracks, at which point the post-step position is needed again.
90  if (trkInfo->crossedBoundary()) {
93 #ifdef EDM_ML_DEBUG
94  edm::LogVerbatim("DoFineCalo") << "PostUserTrackingAction:"
95  << " Track " << aTrack->GetTrackID() << " crossed boundary; pos=("
96  << trkInfo->getPositionAtBoundary().x() << ","
97  << trkInfo->getPositionAtBoundary().y() << ","
98  << trkInfo->getPositionAtBoundary().z() << ")"
99  << " mom[GeV]=(" << trkInfo->getMomentumAtBoundary().x() << ","
100  << trkInfo->getMomentumAtBoundary().y() << ","
101  << trkInfo->getMomentumAtBoundary().z() << ","
102  << trkInfo->getMomentumAtBoundary().e() << ")";
103 #endif
104  }
105  }
106 
107  TrackInformation* trkInfo = (TrackInformation*)aTrack->GetUserInformation();
108  if (extractor_(aTrack).storeTrack() || currentTrack_->saved() ||
110  if (trkInfo->crossedBoundary()) {
112  }
113  currentTrack_->save();
114 
116 #ifdef EDM_ML_DEBUG
117  edm::LogVerbatim("SimTrackManager")
118  << "TrackingAction addTkCaloStateInfo " << id << " of momentum " << mom << " at " << pos;
119 #endif
120  }
121 
122  bool withAncestor =
123  ((extractor_(aTrack).getIDonCaloSurface() == aTrack->GetTrackID()) || (extractor_(aTrack).isAncestor()));
124 
125  if (extractor_(aTrack).isInHistory()) {
126  // check with end-of-track information
127  if (checkTrack_) {
128  currentTrack_->checkAtEnd(aTrack);
129  }
130 
131  eventAction_->addTrack(currentTrack_, true, withAncestor);
132 
133 #ifdef EDM_ML_DEBUG
134  edm::LogVerbatim("SimTrackManager")
135  << "TrackingAction addTrack " << currentTrack_->trackID() << " E(GeV)= " << aTrack->GetKineticEnergy() << " "
136  << aTrack->GetDefinition()->GetParticleName() << " added= " << withAncestor << " at "
137  << aTrack->GetPosition();
138  edm::LogVerbatim("SimTrackManager") << "TrackingAction addTrack " << currentTrack_->trackID() << " added with "
139  << true << " and " << withAncestor << " at " << pos;
140 #endif
141 
142  } else {
143  eventAction_->addTrack(currentTrack_, false, false);
144 
145 #ifdef EDM_ML_DEBUG
146  edm::LogVerbatim("SimTrackManager")
147  << "TrackingAction addTrack " << currentTrack_->trackID() << " added with " << false << " and " << false;
148 #endif
149 
150  delete currentTrack_;
151  }
152  }
153  if (nullptr != steppingVerbose_) {
154  steppingVerbose_->TrackEnded(aTrack);
155  }
156 
157  EndOfTrack et(aTrack);
159 
160  currentTrack_ = nullptr; // reset for next track
161 }
const TrackContainer * trackContainer() const
Definition: EventAction.h:33
Log< level::Info, true > LogVerbatim
bool crossedBoundary() const
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:14
const math::XYZTLorentzVectorF & getPositionAtBoundary() const
TrackInformationExtractor extractor_
void setCrossedBoundaryPosMom(int id, const math::XYZTLorentzVectorF position, const math::XYZTLorentzVectorF momentum)
CMSSteppingVerbose * steppingVerbose_
TrackWithHistory * currentTrack_
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > XYZVectorD
spatial vector with cartesian internal representation
Definition: Vector3D.h:8
EventAction * eventAction_
void checkAtEnd(const G4Track *)
bool saveCaloBoundaryInformation_
SimActivityRegistry::EndOfTrackSignal m_endOfTrackSignal
const math::XYZTLorentzVectorF & getMomentumAtBoundary() const
bool saved() const
void addTkCaloStateInfo(uint32_t t, const std::pair< math::XYZVectorD, math::XYZTLorentzVectorD > &p)
Definition: EventAction.cc:72
void TrackEnded(const G4Track *) const
void addTrack(TrackWithHistory *iTrack, bool inHistory, bool withAncestor)
Definition: EventAction.h:35
unsigned int trackID() const

◆ PreUserTrackingAction()

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

Definition at line 31 of file TrackingAction.cc.

References currentTrack_, doFineCalo_, eventAction_, g4Track_, TrackInformation::isPrimary(), m_beginOfTrackSignal, EventAction::prepareForNewPrimary(), TrackInformation::putInHistory(), TrackWithHistory::save(), steppingVerbose_, and CMSSteppingVerbose::TrackStarted().

31  {
32  g4Track_ = aTrack;
33  currentTrack_ = new TrackWithHistory(aTrack);
34 
35  BeginOfTrack bt(aTrack);
37 
38  TrackInformation* trkInfo = (TrackInformation*)aTrack->GetUserInformation();
39  if (trkInfo && trkInfo->isPrimary()) {
41  }
42  if (nullptr != steppingVerbose_) {
43  steppingVerbose_->TrackStarted(aTrack, false);
44  }
45 
46  if (doFineCalo_) {
47 #ifdef EDM_ML_DEBUG
48  edm::LogVerbatim("DoFineCalo") << "PreUserTrackingAction: Start processing track " << aTrack->GetTrackID()
49  << " pdgid=" << aTrack->GetDefinition()->GetPDGEncoding()
50  << " ekin[GeV]=" << aTrack->GetKineticEnergy() / CLHEP::GeV << " vertex[cm]=("
51  << aTrack->GetVertexPosition().x() / CLHEP::cm << ","
52  << aTrack->GetVertexPosition().y() / CLHEP::cm << ","
53  << aTrack->GetVertexPosition().z() / CLHEP::cm << ")"
54  << " parentid=" << aTrack->GetParentID();
55 #endif
56  // It is impossible to tell whether daughter tracks if this track may need to be saved at
57  // this point; Therefore, *every* track is put in history, so that it can potentially be saved
58  // later.
59  trkInfo->putInHistory();
60  // Always save primaries
61  // Decays from primaries are marked as primaries (see NewTrackAction), but are not saved by
62  // default. The primary is the earliest ancestor, and it must be saved.
63  if (trkInfo->isPrimary())
65  }
66 }
Log< level::Info, true > LogVerbatim
bool isPrimary() const
const G4Track * g4Track_
CMSSteppingVerbose * steppingVerbose_
TrackWithHistory * currentTrack_
void prepareForNewPrimary()
Definition: EventAction.h:44
EventAction * eventAction_
void TrackStarted(const G4Track *, bool isKilled)
SimActivityRegistry::BeginOfTrackSignal m_beginOfTrackSignal

Member Data Documentation

◆ checkTrack_

bool TrackingAction::checkTrack_
private

Definition at line 37 of file TrackingAction.h.

Referenced by PostUserTrackingAction().

◆ currentTrack_

TrackWithHistory* TrackingAction::currentTrack_
private

◆ doFineCalo_

bool TrackingAction::doFineCalo_
private

Definition at line 38 of file TrackingAction.h.

Referenced by PostUserTrackingAction(), and PreUserTrackingAction().

◆ eMinFine_

double TrackingAction::eMinFine_
private

Definition at line 40 of file TrackingAction.h.

◆ eventAction_

EventAction* TrackingAction::eventAction_
private

Definition at line 33 of file TrackingAction.h.

Referenced by PostUserTrackingAction(), and PreUserTrackingAction().

◆ extractor_

TrackInformationExtractor TrackingAction::extractor_
private

Definition at line 32 of file TrackingAction.h.

Referenced by PostUserTrackingAction().

◆ g4Track_

const G4Track* TrackingAction::g4Track_
private

Definition at line 36 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 39 of file TrackingAction.h.

Referenced by PostUserTrackingAction().

◆ steppingVerbose_

CMSSteppingVerbose* TrackingAction::steppingVerbose_
private

Definition at line 35 of file TrackingAction.h.

Referenced by PostUserTrackingAction(), and PreUserTrackingAction().