CMS 3D CMS Logo

TrackingAction.cc
Go to the documentation of this file.
10 
12 
13 #include "G4UImanager.hh"
14 #include "G4TrackingManager.hh"
15 
16 //#define EDM_ML_DEBUG
17 
19  : eventAction_(e),
20  currentTrack_(nullptr),
21  steppingVerbose_(sv),
22  g4Track_(nullptr),
23  checkTrack_(p.getUntrackedParameter<bool>("CheckTrack", false)) {}
24 
26 
27 void TrackingAction::PreUserTrackingAction(const G4Track* aTrack) {
28  g4Track_ = aTrack;
29  currentTrack_ = new TrackWithHistory(aTrack);
30 
31  BeginOfTrack bt(aTrack);
33 
34  TrackInformation* trkInfo = (TrackInformation*)aTrack->GetUserInformation();
35  if (trkInfo && trkInfo->isPrimary()) {
37  }
38  if (nullptr != steppingVerbose_) {
39  steppingVerbose_->TrackStarted(aTrack, false);
40  }
41 }
42 
43 void TrackingAction::PostUserTrackingAction(const G4Track* aTrack) {
44  if (eventAction_->trackContainer() != nullptr) {
45  if (extractor_(aTrack).storeTrack()) {
47 
48  math::XYZVectorD pos((aTrack->GetStep()->GetPostStepPoint()->GetPosition()).x(),
49  (aTrack->GetStep()->GetPostStepPoint()->GetPosition()).y(),
50  (aTrack->GetStep()->GetPostStepPoint()->GetPosition()).z());
52 
53  uint32_t id = aTrack->GetTrackID();
54 
55  std::pair<math::XYZVectorD, math::XYZTLorentzVectorD> p(pos, mom);
57 #ifdef EDM_ML_DEBUG
58  edm::LogVerbatim("SimTrackManager")
59  << "TrackingAction addTkCaloStateInfo " << id << " of momentum " << mom << " at " << pos;
60 #endif
61  }
62 
63  bool withAncestor =
64  ((extractor_(aTrack).getIDonCaloSurface() == aTrack->GetTrackID()) ||
65  (extractor_(aTrack).getIDfineCalo() == aTrack->GetTrackID()) || (extractor_(aTrack).isAncestor()));
66 
67  if (extractor_(aTrack).isInHistory()) {
68  // check with end-of-track information
69  if (checkTrack_) {
70  currentTrack_->checkAtEnd(aTrack);
71  }
72 
73  eventAction_->addTrack(currentTrack_, true, withAncestor);
74 
75 #ifdef EDM_ML_DEBUG
76  edm::LogVerbatim("SimTrackManager")
77  << "TrackingAction addTrack " << currentTrack_->trackID() << " E(GeV)= " << aTrack->GetKineticEnergy() << " "
78  << aTrack->GetDefinition()->GetParticleName() << " added= " << withAncestor << " at "
79  << aTrack->GetPosition();
80 
81  math::XYZVectorD pos((aTrack->GetStep()->GetPostStepPoint()->GetPosition()).x(),
82  (aTrack->GetStep()->GetPostStepPoint()->GetPosition()).y(),
83  (aTrack->GetStep()->GetPostStepPoint()->GetPosition()).z());
84  edm::LogVerbatim("SimTrackManager") << "TrackingAction addTrack " << currentTrack_->trackID() << " added with "
85  << true << " and " << withAncestor << " at " << pos;
86 #endif
87 
88  } else {
89  eventAction_->addTrack(currentTrack_, false, false);
90 
91 #ifdef EDM_ML_DEBUG
92  edm::LogVerbatim("SimTrackManager")
93  << "TrackingAction addTrack " << currentTrack_->trackID() << " added with " << false << " and " << false;
94 #endif
95 
96  delete currentTrack_;
97  }
98  }
99  if (nullptr != steppingVerbose_) {
100  steppingVerbose_->TrackEnded(aTrack);
101  }
102 
103  EndOfTrack et(aTrack);
105 
106  currentTrack_ = nullptr; // reset for next track
107 }
DDAxes::y
electrons_cff.bool
bool
Definition: electrons_cff.py:372
TrackingAction.h
EventAction::trackContainer
const TrackContainer * trackContainer() const
Definition: EventAction.h:33
MessageLogger.h
EventAction
Definition: EventAction.h:23
funct::false
false
Definition: Factorize.h:34
TrackingAction::TrackingAction
TrackingAction(EventAction *ea, const edm::ParameterSet &ps, CMSSteppingVerbose *)
Definition: TrackingAction.cc:18
TrackingAction::~TrackingAction
~TrackingAction() override
Definition: TrackingAction.cc:25
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
TrackingAction::PostUserTrackingAction
void PostUserTrackingAction(const G4Track *aTrack) override
Definition: TrackingAction.cc:43
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:41
TrackingAction::g4Track_
const G4Track * g4Track_
Definition: TrackingAction.h:36
EventAction.h
EndOfTrack.h
CurrentG4Track.h
CMSSteppingVerbose
Definition: CMSSteppingVerbose.h:25
TrackingAction::extractor_
TrackInformationExtractor extractor_
Definition: TrackingAction.h:32
DDAxes::x
TrackWithHistory::checkAtEnd
void checkAtEnd(const G4Track *)
Definition: TrackWithHistory.cc:56
EndOfTrack
Definition: EndOfTrack.h:6
BeginOfTrack.h
NewTrackAction.h
TrackingAction::currentTrack_
TrackWithHistory * currentTrack_
Definition: TrackingAction.h:34
TrackInformation::isPrimary
bool isPrimary() const
Definition: TrackInformation.h:23
pfDeepBoostedJetPreprocessParams_cfi.sv
sv
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:226
DDAxes::z
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
edm::ParameterSet
Definition: ParameterSet.h:36
TrackingAction::eventAction_
EventAction * eventAction_
Definition: TrackingAction.h:33
CMSSteppingVerbose::TrackStarted
void TrackStarted(const G4Track *, bool isKilled)
Definition: CMSSteppingVerbose.cc:62
TrackInformation
Definition: TrackInformation.h:8
edm::LogVerbatim
Definition: MessageLogger.h:297
EgHLTOffHistBins_cfi.et
et
Definition: EgHLTOffHistBins_cfi.py:8
TrackInformation.h
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
CMSSteppingVerbose.h
EventAction::addTkCaloStateInfo
void addTkCaloStateInfo(uint32_t t, const std::pair< math::XYZVectorD, math::XYZTLorentzVectorD > &p)
Definition: EventAction.cc:72
TrackingAction::checkTrack_
bool checkTrack_
Definition: TrackingAction.h:37
TrackingAction::steppingVerbose_
CMSSteppingVerbose * steppingVerbose_
Definition: TrackingAction.h:35
TrackingAction::PreUserTrackingAction
void PreUserTrackingAction(const G4Track *aTrack) override
Definition: TrackingAction.cc:27
EventAction::addTrack
void addTrack(TrackWithHistory *iTrack, bool inHistory, bool withAncestor)
Definition: EventAction.h:35
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
TrackWithHistory.h