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"
12 #include "AliTrackingAction.h"
13 #include "AliGlobals.h"
15 #include "AliHeader.h"
18 #include <G4TrajectoryContainer.hh>
19 #include <G4Trajectory.hh>
20 #include <G4VVisManager.hh>
21 #include <G4UImanager.hh>
23 AliEventAction::AliEventAction()
28 fMessenger = new AliEventActionMessenger(this);
29 fTimer = new G4Timer();
32 AliEventAction::AliEventAction(const AliEventAction& right) {
34 AliGlobals::Exception("AliEventAction is protected from copying.");
37 AliEventAction::~AliEventAction() {
45 AliEventAction& AliEventAction::operator=(const AliEventAction &right)
47 // check assignement to self
48 if (this == &right) return *this;
50 AliGlobals::Exception("AliEventAction is protected from assigning.");
57 void AliEventAction::DisplayEvent(const G4Event* event) const
59 // Draws trajectories.
62 // trajectories processing
63 G4TrajectoryContainer* trajectoryContainer
64 = event->GetTrajectoryContainer();
66 G4int nofTrajectories = 0;
67 if (trajectoryContainer)
68 { nofTrajectories = trajectoryContainer->entries(); }
70 if (fVerboseLevel>0 && nofTrajectories>0) {
71 G4cout << " " << nofTrajectories;
72 G4cout << " trajectories stored." << G4endl;
75 G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
76 if(pVVisManager && nofTrajectories>0)
78 G4UImanager::GetUIpointer()->ApplyCommand("/vis~/draw/current");
80 for (G4int i=0; i<nofTrajectories; i++)
82 G4VTrajectory* vtrajectory = (*(event->GetTrajectoryContainer()))[i];
83 G4Trajectory* trajectory = dynamic_cast<G4Trajectory*>(vtrajectory);
85 AliGlobals::Exception(
86 "AliEventAction::DisplayEvent: Unknown trajectory type.");
88 if ( (fDrawFlag == "ALL") ||
89 ((fDrawFlag == "CHARGED") && (trajectory->GetCharge() != 0.))){
90 trajectory->DrawTrajectory(50);
91 // the argument number defines the size of the step points
92 // use 2000 to make step points well visible
95 G4UImanager::GetUIpointer()->ApplyCommand("/vis~/show/view");
101 void AliEventAction::BeginOfEventAction(const G4Event* event)
103 // Called by G4 kernel at the beginning of event.
106 G4int eventID = event->GetEventID();
108 // reset the tracks counters
109 AliTrackingAction::Instance()->PrepareNewEvent();
112 G4cout << ">>> Event " << event->GetEventID() << G4endl;
117 void AliEventAction::EndOfEventAction(const G4Event* event)
119 // Called by G4 kernel at the end of event.
122 // finish the last primary track of the current event
123 AliTrackingAction* trackingAction = AliTrackingAction::Instance();
124 trackingAction->FinishPrimaryTrack();
127 if (fVerboseLevel>0) {
129 G4cout << ">>> End of Event " << event->GetEventID() << G4endl;
132 if (fVerboseLevel>1) {
133 //G4int nofPrimaryTracks = trackingAction->GetNofPrimaryTracks();
134 G4int nofPrimaryTracks = gAlice->GetHeader()->GetNprimary();
135 G4int nofSavedTracks = gAlice->GetNtrack();
136 G4int nofAllTracks = trackingAction->GetNofTracks();
138 G4cout << " " << nofPrimaryTracks <<
139 " primary tracks processed." << G4endl;
140 G4cout << " " << nofSavedTracks <<
141 " tracks saved." << G4endl;
142 G4cout << " " << nofAllTracks <<
143 " all tracks processed." << G4endl;
149 // aliroot finish event
150 gAlice->FinishEvent();
152 if (fVerboseLevel>1) {
155 G4cout << "Time of this event: " << *fTimer << G4endl;