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

References doFineCalo_, eMinFine_, and saveCaloBoundaryInformation_.

20  : trackManager_(stm),
22  endPrintTrackID_(p.getParameter<int>("EndPrintTrackID")),
23  checkTrack_(p.getUntrackedParameter<bool>("CheckTrack", false)),
24  doFineCalo_(p.getParameter<bool>("DoFineCalo")),
25  saveCaloBoundaryInformation_(p.getParameter<bool>("SaveCaloBoundaryInformation")),
26  eMinFine_(p.getParameter<double>("EminFineTrack") * CLHEP::MeV) {
27  if (!doFineCalo_) {
28  eMinFine_ = DBL_MAX;
29  }
30  edm::LogVerbatim("SimG4CoreApplication") << "TrackingAction: boundary: " << saveCaloBoundaryInformation_
31  << "; DoFineCalo: " << doFineCalo_ << "; EminFineTrack(MeV)=" << eMinFine_;
32 }
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 75 of file TrackingAction.cc.

References SimTrackManager::addTrack(), TrackInformation::crossedBoundary(), currentTrack_, doFineCalo_, EgHLTOffHistBins_cfi::et, TrackInformation::getIDonCaloSurface(), TrackInformation::getMomentumAtBoundary(), TrackInformation::getPositionAtBoundary(), TrackInformation::isAncestor(), TrackInformation::isInHistory(), m_endOfTrackSignal, convertSQLiteXML::ok, saveCaloBoundaryInformation_, TrackWithHistory::saved(), TrackWithHistory::setCrossedBoundaryPosMom(), TrackWithHistory::setToBeSaved(), TrackInformation::storeTrack(), trackManager_, and trkInfo_.

Referenced by RunManagerMTWorker::abortEvent().

75  {
76  // Add the post-step position for every track in history to the TrackManager.
77  // Tracks in history may be upgraded to stored tracks, at which point
78  // the post-step position is needed again.
79  int id = aTrack->GetTrackID();
80  bool ok = (trkInfo_->storeTrack() || currentTrack_->saved());
81  if (trkInfo_->crossedBoundary()) {
84  }
85  if (ok) {
87  }
88 
89  bool withAncestor = (trkInfo_->getIDonCaloSurface() == id || trkInfo_->isAncestor());
90  bool isInHistory = trkInfo_->isInHistory();
91 
92  trackManager_->addTrack(currentTrack_, aTrack, isInHistory, withAncestor);
93 
94 #ifdef EDM_ML_DEBUG
95  edm::LogVerbatim("TrackingAction") << "TrackingAction end track=" << id << " "
96  << aTrack->GetDefinition()->GetParticleName() << " ansestor= " << withAncestor
97  << " saved= " << currentTrack_->saved() << " end point " << aTrack->GetPosition();
98 #endif
99  if (!isInHistory) {
100  delete currentTrack_;
101  }
102 
103  EndOfTrack et(aTrack);
105 }
bool storeTrack() const
Log< level::Info, true > LogVerbatim
bool crossedBoundary() const
SimTrackManager * trackManager_
bool isAncestor() const
const math::XYZTLorentzVectorF & getPositionAtBoundary() const
TrackWithHistory * currentTrack_
bool isInHistory() const
TrackInformation * trkInfo_
bool saveCaloBoundaryInformation_
SimActivityRegistry::EndOfTrackSignal m_endOfTrackSignal
const math::XYZTLorentzVectorF & getMomentumAtBoundary() const
int getIDonCaloSurface() const
void addTrack(TrackWithHistory *iTrack, const G4Track *track, bool inHistory, bool withAncestor)
bool saved() const
void setCrossedBoundaryPosMom(int id, const math::XYZTLorentzVectorF &position, const math::XYZTLorentzVectorF &momentum)

◆ PreUserTrackingAction()

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

Definition at line 34 of file TrackingAction.cc.

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

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

◆ 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().