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"
17 #include <G4TrajectoryContainer.hh>
18 #include <G4Trajectory.hh>
19 #include <G4VVisManager.hh>
20 #include <G4UImanager.hh>
22 AliEventAction::AliEventAction()
27 fMessenger = new AliEventActionMessenger(this);
28 fTimer = new G4Timer();
31 AliEventAction::AliEventAction(const AliEventAction& right) {
33 AliGlobals::Exception("AliEventAction is protected from copying.");
36 AliEventAction::~AliEventAction() {
44 AliEventAction& AliEventAction::operator=(const AliEventAction &right)
46 // check assignement to self
47 if (this == &right) return *this;
49 AliGlobals::Exception("AliEventAction is protected from assigning.");
56 void AliEventAction::DisplayEvent(const G4Event* event) const
58 // Draws trajectories.
61 // trajectories processing
62 G4TrajectoryContainer* trajectoryContainer
63 = event->GetTrajectoryContainer();
65 G4int nofTrajectories = 0;
66 if (trajectoryContainer)
67 { nofTrajectories = trajectoryContainer->entries(); }
69 if (fVerboseLevel>0 && nofTrajectories>0) {
70 G4cout << " " << nofTrajectories;
71 G4cout << " trajectories stored." << G4endl;
74 G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
75 if(pVVisManager && nofTrajectories>0)
77 G4UImanager::GetUIpointer()->ApplyCommand("/vis~/draw/current");
79 for (G4int i=0; i<nofTrajectories; i++)
81 G4VTrajectory* vtrajectory = (*(event->GetTrajectoryContainer()))[i];
82 G4Trajectory* trajectory = dynamic_cast<G4Trajectory*>(vtrajectory);
84 AliGlobals::Exception(
85 "AliEventAction::DisplayEvent: Unknown trajectory type.");
87 if ( (fDrawFlag == "ALL") ||
88 ((fDrawFlag == "CHARGED") && (trajectory->GetCharge() != 0.))){
89 trajectory->DrawTrajectory(50);
90 // the argument number defines the size of the step points
91 // use 2000 to make step points well visible
94 G4UImanager::GetUIpointer()->ApplyCommand("/vis~/show/view");
100 void AliEventAction::BeginOfEventAction(const G4Event* event)
102 // Called by G4 kernel at the beginning of event.
105 G4int eventID = event->GetEventID();
107 // reset the tracks counters
108 AliTrackingAction::Instance()->PrepareNewEvent();
111 G4cout << ">>> Event " << event->GetEventID() << G4endl;
116 void AliEventAction::EndOfEventAction(const G4Event* event)
118 // Called by G4 kernel at the end of event.
121 // finish the last primary track of the current event
122 AliTrackingAction* trackingAction = AliTrackingAction::Instance();
123 trackingAction->FinishPrimaryTrack();
126 if (fVerboseLevel>0) {
127 //G4int nofPrimaryTracks = trackingAction->GetNofPrimaryTracks();
128 G4int nofPrimaryTracks = gAlice->GetHeader()->GetNprimary();
129 G4int nofSavedTracks = gAlice->GetNtrack();
130 G4int nofAllTracks = trackingAction->GetNofTracks();
132 G4cout << " " << nofPrimaryTracks <<
133 " primary tracks processed." << G4endl;
134 G4cout << " " << nofSavedTracks <<
135 " tracks saved." << G4endl;
136 G4cout << " " << nofAllTracks <<
137 " all tracks processed." << G4endl;
143 // aliroot finish event
144 gAlice->FinishEvent();
146 if (fVerboseLevel>0) {
149 G4cout << "Time of this event: " << *fTimer << G4endl;