4 // See the class description in the header file.
7 // in order to avoid the odd dependency for the
8 // times system function this include must be the first
10 #include "AliEventAction.h"
11 #include "AliEventActionMessenger.h"
13 #include "AliTrackingAction.h"
14 #include "AliSensitiveDetector.h"
15 #include "AliGlobals.h"
17 #include "TG4GeometryManager.h"
20 #include <G4TrajectoryContainer.hh>
21 #include <G4Trajectory.hh>
22 #include <G4VVisManager.hh>
23 #include <G4UImanager.hh>
24 #include <G4LogicalVolumeStore.hh>
25 #include <G4VSensitiveDetector.hh>
27 AliEventAction::AliEventAction()
32 fMessenger = new AliEventActionMessenger(this);
33 fTimer = new G4Timer();
36 AliEventAction::AliEventAction(const AliEventAction& right) {
38 AliGlobals::Exception("AliEventAction is protected from copying.");
41 AliEventAction::~AliEventAction() {
49 AliEventAction& AliEventAction::operator=(const AliEventAction &right)
51 // check assignement to self
52 if (this == &right) return *this;
54 AliGlobals::Exception("AliEventAction is protected from assigning.");
61 void AliEventAction::DisplayEvent(const G4Event* event) const
63 // Draws trajectories.
67 // trajectories processing
68 G4TrajectoryContainer* trajectoryContainer
69 = event->GetTrajectoryContainer();
71 G4int nofTrajectories = 0;
72 if (trajectoryContainer)
73 { nofTrajectories = trajectoryContainer->entries(); }
75 if (fVerboseLevel>0) {
76 G4cout << " " << nofTrajectories;
77 G4cout << " trajectories stored." << G4endl;
80 G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
81 if(pVVisManager && nofTrajectories>0)
83 G4UImanager::GetUIpointer()->ApplyCommand("/vis~/draw/current");
85 for (G4int i=0; i<nofTrajectories; i++)
87 G4VTrajectory* vtrajectory = (*(event->GetTrajectoryContainer()))[i];
88 G4Trajectory* trajectory = dynamic_cast<G4Trajectory*>(vtrajectory);
90 AliGlobals::Exception(
91 "AliEventAction::DisplayEvent: Unknown trajectory type.");
93 if ( (fDrawFlag == "ALL") ||
94 ((fDrawFlag == "CHARGED") && (trajectory->GetCharge() != 0.))){
95 trajectory->DrawTrajectory(50);
96 // the argument number defines the size of the step points
97 // use 2000 to make step points well visible
100 G4UImanager::GetUIpointer()->ApplyCommand("/vis~/show/view");
106 void AliEventAction::BeginOfEventAction(const G4Event* event)
108 // Called by G4 kernel at the beginning of event.
111 G4int eventID = event->GetEventID();
113 // reset the counters (primary tracks, saved tracks)
114 AliTrackingAction* trackingAction
115 = AliTrackingAction::Instance();
116 trackingAction->PrepareNewEvent();
119 G4cout << ">>> Event " << event->GetEventID() << G4endl;
124 void AliEventAction::EndOfEventAction(const G4Event* event)
126 // Called by G4 kernel at the end of event.
129 // save the last primary track store of
131 AliTrackingAction* trackingAction
132 = AliTrackingAction::Instance();
133 trackingAction->SaveAndDestroyTrack();
135 if (fVerboseLevel>0) {
136 G4int nofPrimaryTracks = trackingAction->GetNofPrimaryTracks();
137 G4int nofTracks = trackingAction->GetNofTracks();
138 G4cout << " " << nofPrimaryTracks <<
139 " primary tracks processed." << G4endl;
140 G4cout << " " << nofTracks <<
141 " all tracks processed." << G4endl;
148 // store event header data
149 gAlice->GetHeader()->SetEvent(event->GetEventID());
150 gAlice->GetHeader()->SetNvertex(event->GetNumberOfPrimaryVertex());
151 gAlice->GetHeader()->SetNprimary(trackingAction->GetNofPrimaryTracks());
152 gAlice->GetHeader()->SetNtrack(trackingAction->GetNofSavedTracks());
154 gAlice->FinishEvent();
156 if (fVerboseLevel>0) {
159 G4cout << "Time of this event = " << *fTimer << G4endl;