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_ = nullptr
 
bool doFineCalo_
 
double eMinFine_
 
EventActioneventAction_
 
const G4Track * g4Track_ = nullptr
 
bool saveCaloBoundaryInformation_
 
CMSSteppingVerbosesteppingVerbose_
 
TrackInformationtrkInfo_ = nullptr
 

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.

References doFineCalo_, eMinFine_, and saveCaloBoundaryInformation_.

20  : eventAction_(e),
22  checkTrack_(p.getUntrackedParameter<bool>("CheckTrack", false)),
23  doFineCalo_(p.getParameter<bool>("DoFineCalo")),
24  saveCaloBoundaryInformation_(p.getParameter<bool>("SaveCaloBoundaryInformation")),
25  eMinFine_(p.getParameter<double>("EminFineTrack") * CLHEP::MeV) {
26  if (!doFineCalo_) {
27  eMinFine_ = DBL_MAX;
28  }
29  edm::LogVerbatim("SimG4CoreApplication") << "TrackingAction: boundary: " << saveCaloBoundaryInformation_
30  << "; DoFineCalo: " << doFineCalo_ << "; EminFineTrack(MeV)=" << eMinFine_;
31 }
Log< level::Info, true > LogVerbatim
CMSSteppingVerbose * steppingVerbose_
EventAction * eventAction_
bool saveCaloBoundaryInformation_

◆ ~TrackingAction()

TrackingAction::~TrackingAction ( )
override

Definition at line 33 of file TrackingAction.cc.

33 {}

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

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

Referenced by RunManagerMTWorker::abortEvent().

73  {
74  int id = aTrack->GetTrackID();
75  const auto& ppos = aTrack->GetStep()->GetPostStepPoint()->GetPosition();
76  math::XYZVectorD pos(ppos.x(), ppos.y(), ppos.z());
78  std::pair<math::XYZVectorD, math::XYZTLorentzVectorD> p(pos, mom);
79 
80 #ifdef EDM_ML_DEBUG
81  edm::LogVerbatim("DoFineCalo") << "PostUserTrackingAction:"
82  << " aTrack->GetTrackID()=" << id
83  << " currentTrack_->saved()=" << currentTrack_->saved();
84 #endif
85 
86  bool boundary = false;
87  if (doFineCalo_) {
88  // Add the post-step position for _every_ track
89  // in history to the TrackManager. Tracks in history _may_ be upgraded to stored
90  // tracks, at which point the post-step position is needed again.
92  boundary = true;
93  } else if (trkInfo_->storeTrack() || currentTrack_->saved() ||
97  boundary = true;
98  }
99  if (boundary && trkInfo_->crossedBoundary()) {
101  currentTrack_->save();
102 
103 #ifdef EDM_ML_DEBUG
104  edm::LogVerbatim("DoFineCalo") << "PostUserTrackingAction:"
105  << " Track " << id << " crossed boundary; pos=("
106  << trkInfo_->getPositionAtBoundary().x() << ","
107  << trkInfo_->getPositionAtBoundary().y() << ","
108  << trkInfo_->getPositionAtBoundary().z() << ")"
109  << " mom[GeV]=(" << trkInfo_->getMomentumAtBoundary().x() << ","
110  << trkInfo_->getMomentumAtBoundary().y() << ","
111  << trkInfo_->getMomentumAtBoundary().z() << ","
112  << trkInfo_->getMomentumAtBoundary().e() << ")";
113 #endif
114  }
115 
116  bool withAncestor = (trkInfo_->getIDonCaloSurface() == id || trkInfo_->isAncestor());
117 
118  if (trkInfo_->isInHistory()) {
119  // check with end-of-track information
120  if (checkTrack_) {
121  currentTrack_->checkAtEnd(aTrack);
122  }
123 
124  eventAction_->addTrack(currentTrack_, true, withAncestor);
125 
126 #ifdef EDM_ML_DEBUG
127  edm::LogVerbatim("SimTrackManager") << "TrackingAction addTrack " << id << " "
128  << aTrack->GetDefinition()->GetParticleName() << " added= " << withAncestor
129  << " at " << aTrack->GetPosition();
130 #endif
131 
132  } else {
133  eventAction_->addTrack(currentTrack_, false, false);
134 
135 #ifdef EDM_ML_DEBUG
136  edm::LogVerbatim("SimTrackManager") << "TrackingAction addTrack " << id << " added with " << false << " and "
137  << false;
138 #endif
139  delete currentTrack_;
140  }
141  if (nullptr != steppingVerbose_) {
142  steppingVerbose_->TrackEnded(aTrack);
143  }
144 
145  EndOfTrack et(aTrack);
147 }
bool storeTrack() const
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
bool isAncestor() const
const math::XYZTLorentzVectorF & getPositionAtBoundary() const
void setCrossedBoundaryPosMom(int id, const math::XYZTLorentzVectorF position, const math::XYZTLorentzVectorF momentum)
CMSSteppingVerbose * steppingVerbose_
TrackWithHistory * currentTrack_
bool isInHistory() const
TrackInformation * trkInfo_
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
int getIDonCaloSurface() const
bool saved() const
void addTkCaloStateInfo(uint32_t t, const std::pair< math::XYZVectorD, math::XYZTLorentzVectorD > &p)
Definition: EventAction.cc:71
void TrackEnded(const G4Track *) const
void addTrack(TrackWithHistory *iTrack, bool inHistory, bool withAncestor)
Definition: EventAction.h:35

◆ PreUserTrackingAction()

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

Definition at line 35 of file TrackingAction.cc.

References currentTrack_, eMinFine_, eventAction_, g4Track_, TrackInformation::isPrimary(), m_beginOfTrackSignal, EventAction::prepareForNewPrimary(), TrackInformation::putInHistory(), TrackWithHistory::save(), steppingVerbose_, 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  }
54  double ekin = aTrack->GetKineticEnergy();
55 
56 #ifdef EDM_ML_DEBUG
57  edm::LogVerbatim("DoFineCalo") << "PreUserTrackingAction: Start processing track " << aTrack->GetTrackID()
58  << " pdgid=" << aTrack->GetDefinition()->GetPDGEncoding()
59  << " ekin[GeV]=" << ekin / CLHEP::GeV << " vertex[cm]=("
60  << aTrack->GetVertexPosition().x() / CLHEP::cm << ","
61  << aTrack->GetVertexPosition().y() / CLHEP::cm << ","
62  << aTrack->GetVertexPosition().z() / CLHEP::cm << ")"
63  << " parentid=" << aTrack->GetParentID();
64 #endif
65  if (ekin > eMinFine_) {
66  // It is impossible to tell whether daughter tracks if this track may need to be saved at
67  // this point; Therefore, every track above the threshold is put in history,
68  // so that it can potentially be saved later.
70  }
71 }
Log< level::Info, true > LogVerbatim
bool isPrimary() const
const G4Track * g4Track_
CMSSteppingVerbose * steppingVerbose_
TrackWithHistory * currentTrack_
TrackInformation * trkInfo_
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_ = nullptr
private

◆ doFineCalo_

bool TrackingAction::doFineCalo_
private

Definition at line 38 of file TrackingAction.h.

Referenced by PostUserTrackingAction(), and TrackingAction().

◆ eMinFine_

double TrackingAction::eMinFine_
private

Definition at line 40 of file TrackingAction.h.

Referenced by PreUserTrackingAction(), and TrackingAction().

◆ eventAction_

EventAction* TrackingAction::eventAction_
private

Definition at line 32 of file TrackingAction.h.

Referenced by PostUserTrackingAction(), and 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 39 of file TrackingAction.h.

Referenced by PostUserTrackingAction(), and TrackingAction().

◆ steppingVerbose_

CMSSteppingVerbose* TrackingAction::steppingVerbose_
private

Definition at line 33 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().