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) {}

◆ ~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.

24 { return currentTrack_; }

References currentTrack_.

◆ geant4Track()

const G4Track* TrackingAction::geant4Track ( ) const
inline

Definition at line 25 of file TrackingAction.h.

25 { return g4Track_; }

References g4Track_.

Referenced by StackingAction::ClassifyNewTrack(), and LowEnergyFastSimModel::ModelTrigger().

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

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 }

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

◆ PreUserTrackingAction()

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

Definition at line 31 of file TrackingAction.cc.

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 }

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

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

EventAction::trackContainer
const TrackContainer * trackContainer() const
Definition: EventAction.h:33
math::XYZTLorentzVectorD
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:14
TrackWithHistory
Definition: TrackWithHistory.h:16
pos
Definition: PixelAliasList.h:18
EventAction::prepareForNewPrimary
void prepareForNewPrimary()
Definition: EventAction.h:44
TrackingAction::g4Track_
const G4Track * g4Track_
Definition: TrackingAction.h:36
MeV
const double MeV
TrackingAction::extractor_
TrackInformationExtractor extractor_
Definition: TrackingAction.h:32
TrackInformation::putInHistory
void putInHistory()
Definition: TrackInformation.h:37
TrackInformation::getMomentumAtBoundary
const math::XYZTLorentzVectorF & getMomentumAtBoundary() const
Definition: TrackInformation.h:75
TrackWithHistory::checkAtEnd
void checkAtEnd(const G4Track *)
Definition: TrackWithHistory.cc:57
TrackWithHistory::setCrossedBoundaryPosMom
void setCrossedBoundaryPosMom(int id, const math::XYZTLorentzVectorF position, const math::XYZTLorentzVectorF momentum)
Definition: TrackWithHistory.h:47
EndOfTrack
Definition: EndOfTrack.h:6
TrackingAction::currentTrack_
TrackWithHistory * currentTrack_
Definition: TrackingAction.h:34
TrackInformation::isPrimary
bool isPrimary() const
Definition: TrackInformation.h:27
pfDeepBoostedJetPreprocessParams_cfi.sv
sv
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:352
TrackingAction::m_endOfTrackSignal
SimActivityRegistry::EndOfTrackSignal m_endOfTrackSignal
Definition: TrackingAction.h:29
BeginOfTrack
Definition: BeginOfTrack.h:6
TrackWithHistory::save
void save()
Definition: TrackWithHistory.h:27
math::XYZVectorD
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > XYZVectorD
spatial vector with cartesian internal representation
Definition: Vector3D.h:8
TrackInformation::getPositionAtBoundary
const math::XYZTLorentzVectorF & getPositionAtBoundary() const
Definition: TrackInformation.h:74
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
GeV
const double GeV
Definition: MathUtil.h:16
TrackingAction::eventAction_
EventAction * eventAction_
Definition: TrackingAction.h:33
TrackingAction::saveCaloBoundaryInformation_
bool saveCaloBoundaryInformation_
Definition: TrackingAction.h:39
CMSSteppingVerbose::TrackStarted
void TrackStarted(const G4Track *, bool isKilled)
Definition: CMSSteppingVerbose.cc:62
TrackInformation
Definition: TrackInformation.h:12
EgHLTOffHistBins_cfi.et
et
Definition: EgHLTOffHistBins_cfi.py:8
TrackInformation::crossedBoundary
bool crossedBoundary() const
Definition: TrackInformation.h:73
TrackingAction::m_beginOfTrackSignal
SimActivityRegistry::BeginOfTrackSignal m_beginOfTrackSignal
Definition: TrackingAction.h:28
TrackWithHistory::trackID
unsigned int trackID() const
Definition: TrackWithHistory.h:28
CMSSteppingVerbose::TrackEnded
void TrackEnded(const G4Track *) const
Definition: CMSSteppingVerbose.cc:130
TrackWithHistory::saved
bool saved() const
Definition: TrackWithHistory.h:44
EventAction::addTkCaloStateInfo
void addTkCaloStateInfo(uint32_t t, const std::pair< math::XYZVectorD, math::XYZTLorentzVectorD > &p)
Definition: EventAction.cc:72
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
TrackingAction::eMinFine_
double eMinFine_
Definition: TrackingAction.h:40
TrackingAction::doFineCalo_
bool doFineCalo_
Definition: TrackingAction.h:38
TrackingAction::checkTrack_
bool checkTrack_
Definition: TrackingAction.h:37
TrackingAction::steppingVerbose_
CMSSteppingVerbose * steppingVerbose_
Definition: TrackingAction.h:35
EventAction::addTrack
void addTrack(TrackWithHistory *iTrack, bool inHistory, bool withAncestor)
Definition: EventAction.h:35
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37