CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
CMSSimEventManager Class Reference

#include <CMSSimEventManager.h>

Public Member Functions

void AbortCurrentEvent ()
 
 CMSSimEventManager (const edm::ParameterSet &iConfig)
 
 CMSSimEventManager (const CMSSimEventManager &right)=delete
 
void InitialiseWorker ()
 
CMSSimEventManageroperator= (const CMSSimEventManager &right)=delete
 
void ProcessOneEvent (G4Event *anEvent)
 
void SetUserAction (EventAction *ptr)
 
void SetUserAction (StackingAction *ptr)
 
void SetUserAction (TrackingAction *ptr)
 
void SetUserAction (G4UserSteppingAction *ptr)
 
 ~CMSSimEventManager ()
 

Private Member Functions

void StackTracks (G4TrackVector *, bool IDisSet)
 

Private Attributes

G4TrackingManager * m_defTrackManager
 
EventActionm_eventAction
 
G4Navigator * m_navigator
 
G4PrimaryTransformer * m_primaryTransformer
 
G4SDManager * m_sdManager
 
StackingActionm_stackingAction
 
G4StateManager * m_stateManager
 
TrackingActionm_trackingAction
 
std::vector< G4Track * > m_tracks
 
G4int trackID_ {0}
 
G4int verbose_
 

Detailed Description

Definition at line 31 of file CMSSimEventManager.h.

Constructor & Destructor Documentation

◆ CMSSimEventManager() [1/2]

CMSSimEventManager::CMSSimEventManager ( const edm::ParameterSet iConfig)

Definition at line 24 of file CMSSimEventManager.cc.

References m_defTrackManager, m_navigator, m_primaryTransformer, m_sdManager, m_stateManager, and m_tracks.

25  : verbose_(iConfig.getParameter<int>("EventVerbose")) {
26  m_stateManager = G4StateManager::GetStateManager();
27  m_defTrackManager = new G4TrackingManager();
28  m_primaryTransformer = new G4PrimaryTransformer();
29  m_sdManager = G4SDManager::GetSDMpointerIfExist();
30  m_navigator = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
31  m_tracks.reserve(1000);
32 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
G4PrimaryTransformer * m_primaryTransformer
G4TrackingManager * m_defTrackManager
G4Navigator * m_navigator
G4StateManager * m_stateManager
G4SDManager * m_sdManager
std::vector< G4Track * > m_tracks

◆ ~CMSSimEventManager()

CMSSimEventManager::~CMSSimEventManager ( )

Definition at line 34 of file CMSSimEventManager.cc.

References m_defTrackManager, m_eventAction, m_primaryTransformer, and m_stackingAction.

34  {
35  delete m_primaryTransformer;
36  delete m_defTrackManager;
37  delete m_eventAction;
38  delete m_stackingAction;
39 }
G4PrimaryTransformer * m_primaryTransformer
G4TrackingManager * m_defTrackManager
EventAction * m_eventAction
StackingAction * m_stackingAction

◆ CMSSimEventManager() [2/2]

CMSSimEventManager::CMSSimEventManager ( const CMSSimEventManager right)
delete

Member Function Documentation

◆ AbortCurrentEvent()

void CMSSimEventManager::AbortCurrentEvent ( )

◆ InitialiseWorker()

void CMSSimEventManager::InitialiseWorker ( )

◆ operator=()

CMSSimEventManager& CMSSimEventManager::operator= ( const CMSSimEventManager right)
delete

◆ ProcessOneEvent()

void CMSSimEventManager::ProcessOneEvent ( G4Event *  anEvent)

Definition at line 41 of file CMSSimEventManager.cc.

References EventAction::BeginOfEventAction(), EventAction::EndOfEventAction(), m_defTrackManager, m_eventAction, m_navigator, m_primaryTransformer, m_sdManager, m_stateManager, m_tracks, StackTracks(), HLT_2024v13_cff::track, trackID_, and verbose_.

41  {
42  trackID_ = 0;
43  m_stateManager->SetNewState(G4State_EventProc);
44 
45  // Resetting Navigator has been moved to CMSSimEventManager,
46  // so that resetting is now done for every event.
47  G4ThreeVector center(0, 0, 0);
48  m_navigator->LocateGlobalPointAndSetup(center, nullptr, false);
49 
50  G4Track* track = nullptr;
51 
52  anEvent->SetHCofThisEvent(m_sdManager->PrepareNewEvent());
53  m_sdManager->PrepareNewEvent();
55 
56  // Fill primary tracks
57  StackTracks(m_primaryTransformer->GimmePrimaries(anEvent), true);
58 
59  if (0 < verbose_) {
60  edm::LogVerbatim("CMSSimEventManager::ProcessOneEvent")
61  << "### Event #" << anEvent->GetEventID() << " " << trackID_ << " primary tracks";
62  }
63 
64  // Loop over main stack of tracks
65  do {
66  track = m_tracks.back();
67  m_tracks.pop_back();
68  m_defTrackManager->ProcessOneTrack(track);
69  G4TrackVector* secondaries = m_defTrackManager->GimmeSecondaries();
70  StackTracks(secondaries, false);
71  delete track;
72  } while (!m_tracks.empty());
73 
74  m_sdManager->TerminateCurrentEvent(anEvent->GetHCofThisEvent());
76  m_stateManager->SetNewState(G4State_GeomClosed);
77 }
Log< level::Info, true > LogVerbatim
G4PrimaryTransformer * m_primaryTransformer
G4TrackingManager * m_defTrackManager
void BeginOfEventAction(const G4Event *evt) override
Definition: EventAction.cc:24
G4Navigator * m_navigator
void StackTracks(G4TrackVector *, bool IDisSet)
void EndOfEventAction(const G4Event *evt) override
Definition: EventAction.cc:38
G4StateManager * m_stateManager
EventAction * m_eventAction
G4SDManager * m_sdManager
std::vector< G4Track * > m_tracks

◆ SetUserAction() [1/4]

void CMSSimEventManager::SetUserAction ( EventAction ptr)

Definition at line 101 of file CMSSimEventManager.cc.

References m_eventAction.

101 { m_eventAction = ptr; }
EventAction * m_eventAction

◆ SetUserAction() [2/4]

void CMSSimEventManager::SetUserAction ( StackingAction ptr)

Definition at line 103 of file CMSSimEventManager.cc.

References m_stackingAction.

103 { m_stackingAction = ptr; }
StackingAction * m_stackingAction

◆ SetUserAction() [3/4]

void CMSSimEventManager::SetUserAction ( TrackingAction ptr)

Definition at line 105 of file CMSSimEventManager.cc.

References m_defTrackManager, and m_trackingAction.

105  {
106  m_trackingAction = ptr;
107  m_defTrackManager->SetUserAction((G4UserTrackingAction*)ptr);
108 }
G4TrackingManager * m_defTrackManager
TrackingAction * m_trackingAction

◆ SetUserAction() [4/4]

void CMSSimEventManager::SetUserAction ( G4UserSteppingAction *  ptr)

Definition at line 110 of file CMSSimEventManager.cc.

References m_defTrackManager.

110 { m_defTrackManager->SetUserAction(ptr); }
G4TrackingManager * m_defTrackManager

◆ StackTracks()

void CMSSimEventManager::StackTracks ( G4TrackVector *  trackVector,
bool  IDisSet 
)
private

Definition at line 79 of file CMSSimEventManager.cc.

References StackingAction::ClassifyNewTrack(), m_stackingAction, m_tracks, createTree::pp, and trackID_.

Referenced by ProcessOneEvent().

79  {
80  if (trackVector == nullptr || trackVector->empty())
81  return;
82  for (auto& newTrack : *trackVector) {
83  ++trackID_;
84  if (!IDisSet) {
85  newTrack->SetTrackID(trackID_);
86  auto pp = newTrack->GetDynamicParticle()->GetPrimaryParticle();
87  if (pp != nullptr) {
88  pp->SetTrackID(trackID_);
89  }
90  }
91  if (m_stackingAction->ClassifyNewTrack(newTrack) == fKill) {
92  delete newTrack;
93  } else {
94  newTrack->SetOriginTouchableHandle(newTrack->GetTouchableHandle());
95  m_tracks.push_back(newTrack);
96  }
97  }
98  trackVector->clear();
99 }
G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track *aTrack) final
std::vector< G4Track * > m_tracks
StackingAction * m_stackingAction

Member Data Documentation

◆ m_defTrackManager

G4TrackingManager* CMSSimEventManager::m_defTrackManager
private

◆ m_eventAction

EventAction* CMSSimEventManager::m_eventAction
private

Definition at line 61 of file CMSSimEventManager.h.

Referenced by ProcessOneEvent(), SetUserAction(), and ~CMSSimEventManager().

◆ m_navigator

G4Navigator* CMSSimEventManager::m_navigator
private

Definition at line 59 of file CMSSimEventManager.h.

Referenced by CMSSimEventManager(), and ProcessOneEvent().

◆ m_primaryTransformer

G4PrimaryTransformer* CMSSimEventManager::m_primaryTransformer
private

Definition at line 58 of file CMSSimEventManager.h.

Referenced by CMSSimEventManager(), ProcessOneEvent(), and ~CMSSimEventManager().

◆ m_sdManager

G4SDManager* CMSSimEventManager::m_sdManager
private

Definition at line 57 of file CMSSimEventManager.h.

Referenced by CMSSimEventManager(), and ProcessOneEvent().

◆ m_stackingAction

StackingAction* CMSSimEventManager::m_stackingAction
private

Definition at line 62 of file CMSSimEventManager.h.

Referenced by SetUserAction(), StackTracks(), and ~CMSSimEventManager().

◆ m_stateManager

G4StateManager* CMSSimEventManager::m_stateManager
private

Definition at line 55 of file CMSSimEventManager.h.

Referenced by CMSSimEventManager(), and ProcessOneEvent().

◆ m_trackingAction

TrackingAction* CMSSimEventManager::m_trackingAction
private

Definition at line 63 of file CMSSimEventManager.h.

Referenced by SetUserAction().

◆ m_tracks

std::vector<G4Track*> CMSSimEventManager::m_tracks
private

Definition at line 68 of file CMSSimEventManager.h.

Referenced by CMSSimEventManager(), ProcessOneEvent(), and StackTracks().

◆ trackID_

G4int CMSSimEventManager::trackID_ {0}
private

Definition at line 65 of file CMSSimEventManager.h.

Referenced by ProcessOneEvent(), and StackTracks().

◆ verbose_

G4int CMSSimEventManager::verbose_
private

Definition at line 66 of file CMSSimEventManager.h.

Referenced by ProcessOneEvent().