4 // Author: I. Hrivnacova
6 // Class AliEventAction
7 // ---------------------
8 // See the class description in the header file.
11 // in order to avoid the odd dependency for the
12 // times system function this include must be the first
14 #include "AliEventAction.h"
15 #include "AliTrackingAction.h"
16 #include "AliGlobals.h"
18 #include "AliHeader.h"
21 #include <G4TrajectoryContainer.hh>
22 #include <G4Trajectory.hh>
23 #include <G4VVisManager.hh>
24 #include <G4UImanager.hh>
26 //_____________________________________________________________________________
27 AliEventAction::AliEventAction()
33 fTimer = new G4Timer();
36 //_____________________________________________________________________________
37 AliEventAction::AliEventAction(const AliEventAction& right)
40 AliGlobals::Exception("AliEventAction is protected from copying.");
43 //_____________________________________________________________________________
44 AliEventAction::~AliEventAction() {
51 //_____________________________________________________________________________
52 AliEventAction& AliEventAction::operator=(const AliEventAction &right)
54 // check assignement to self
55 if (this == &right) return *this;
57 AliGlobals::Exception("AliEventAction is protected from assigning.");
64 //_____________________________________________________________________________
65 void AliEventAction::DisplayEvent(const G4Event* event) const
67 // Draws trajectories.
70 // trajectories processing
71 G4TrajectoryContainer* trajectoryContainer
72 = event->GetTrajectoryContainer();
74 G4int nofTrajectories = 0;
75 if (trajectoryContainer)
76 { nofTrajectories = trajectoryContainer->entries(); }
78 if (fVerboseLevel>0 && nofTrajectories>0) {
79 G4cout << " " << nofTrajectories;
80 G4cout << " trajectories stored." << G4endl;
83 G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
84 if(pVVisManager && nofTrajectories>0)
86 G4UImanager::GetUIpointer()->ApplyCommand("/vis~/draw/current");
88 for (G4int i=0; i<nofTrajectories; i++)
90 G4VTrajectory* vtrajectory = (*(event->GetTrajectoryContainer()))[i];
91 G4Trajectory* trajectory = dynamic_cast<G4Trajectory*>(vtrajectory);
93 AliGlobals::Exception(
94 "AliEventAction::DisplayEvent: Unknown trajectory type.");
96 if ( (fDrawFlag == "ALL") ||
97 ((fDrawFlag == "CHARGED") && (trajectory->GetCharge() != 0.))){
98 trajectory->DrawTrajectory(50);
99 // the argument number defines the size of the step points
100 // use 2000 to make step points well visible
103 G4UImanager::GetUIpointer()->ApplyCommand("/vis~/show/view");
109 //_____________________________________________________________________________
110 void AliEventAction::BeginOfEventAction(const G4Event* event)
112 // Called by G4 kernel at the beginning of event.
115 G4int eventID = event->GetEventID();
117 // reset the tracks counters
118 if(AliTrackingAction::Instance())
119 AliTrackingAction::Instance()->PrepareNewEvent();
122 G4cout << ">>> Event " << event->GetEventID() << G4endl;
127 //_____________________________________________________________________________
128 void AliEventAction::EndOfEventAction(const G4Event* event)
130 // Called by G4 kernel at the end of event.
133 // finish the last primary track of the current event
134 AliTrackingAction* trackingAction = AliTrackingAction::Instance();
135 if (trackingAction) trackingAction->FinishPrimaryTrack();
138 if (fVerboseLevel>0) {
140 G4cout << ">>> End of Event " << event->GetEventID() << G4endl;
143 if (fVerboseLevel>1) {
144 //G4int nofPrimaryTracks = trackingAction->GetNofPrimaryTracks();
145 G4int nofPrimaryTracks = gAlice->GetHeader()->GetNprimary();
146 G4int nofSavedTracks = gAlice->GetNtrack();
148 G4cout << " " << nofPrimaryTracks <<
149 " primary tracks processed." << G4endl;
150 G4cout << " " << nofSavedTracks <<
151 " tracks saved." << G4endl;
152 if (trackingAction) {
153 G4int nofAllTracks = trackingAction->GetNofTracks();
154 G4cout << " " << nofAllTracks <<
155 " all tracks processed." << G4endl;
162 // aliroot finish event
163 gAlice->FinishEvent();
165 if (fVerboseLevel>1) {
168 G4cout << "Time of this event: " << *fTimer << G4endl;