]>
Commit | Line | Data |
---|---|---|
676fb573 | 1 | // $Id$ |
2 | // Category: event | |
3 | // | |
7005154f | 4 | // Author: I. Hrivnacova |
5 | // | |
6 | // Class AliEventAction | |
7 | // --------------------- | |
676fb573 | 8 | // See the class description in the header file. |
9 | ||
b1327f8f | 10 | #include <G4Timer.hh> |
11 | // in order to avoid the odd dependency for the | |
12 | // times system function this include must be the first | |
13 | ||
676fb573 | 14 | #include "AliEventAction.h" |
676fb573 | 15 | #include "AliTrackingAction.h" |
676fb573 | 16 | #include "AliGlobals.h" |
03b03ccb | 17 | #include "AliRun.h" |
d68d8174 | 18 | #include "AliHeader.h" |
676fb573 | 19 | |
676fb573 | 20 | #include <G4Event.hh> |
21 | #include <G4TrajectoryContainer.hh> | |
22 | #include <G4Trajectory.hh> | |
23 | #include <G4VVisManager.hh> | |
24 | #include <G4UImanager.hh> | |
676fb573 | 25 | |
78ca1e9c | 26 | //_____________________________________________________________________________ |
676fb573 | 27 | AliEventAction::AliEventAction() |
7005154f | 28 | : fMessenger(this), |
29 | fVerboseLevel(1), | |
676fb573 | 30 | fDrawFlag("CHARGED") |
31 | { | |
32 | // | |
b1327f8f | 33 | fTimer = new G4Timer(); |
676fb573 | 34 | } |
35 | ||
78ca1e9c | 36 | //_____________________________________________________________________________ |
7005154f | 37 | AliEventAction::AliEventAction(const AliEventAction& right) |
38 | : fMessenger(this) { | |
676fb573 | 39 | // |
40 | AliGlobals::Exception("AliEventAction is protected from copying."); | |
41 | } | |
42 | ||
78ca1e9c | 43 | //_____________________________________________________________________________ |
676fb573 | 44 | AliEventAction::~AliEventAction() { |
45 | // | |
b1327f8f | 46 | delete fTimer; |
676fb573 | 47 | } |
48 | ||
49 | // operators | |
50 | ||
78ca1e9c | 51 | //_____________________________________________________________________________ |
676fb573 | 52 | AliEventAction& AliEventAction::operator=(const AliEventAction &right) |
53 | { | |
54 | // check assignement to self | |
55 | if (this == &right) return *this; | |
56 | ||
57 | AliGlobals::Exception("AliEventAction is protected from assigning."); | |
58 | ||
59 | return *this; | |
60 | } | |
61 | ||
62 | // private methods | |
63 | ||
78ca1e9c | 64 | //_____________________________________________________________________________ |
676fb573 | 65 | void AliEventAction::DisplayEvent(const G4Event* event) const |
66 | { | |
67 | // Draws trajectories. | |
68 | // --- | |
69 | ||
676fb573 | 70 | // trajectories processing |
71 | G4TrajectoryContainer* trajectoryContainer | |
72 | = event->GetTrajectoryContainer(); | |
73 | ||
74 | G4int nofTrajectories = 0; | |
75 | if (trajectoryContainer) | |
76 | { nofTrajectories = trajectoryContainer->entries(); } | |
77 | ||
03b03ccb | 78 | if (fVerboseLevel>0 && nofTrajectories>0) { |
676fb573 | 79 | G4cout << " " << nofTrajectories; |
5f1d09c5 | 80 | G4cout << " trajectories stored." << G4endl; |
676fb573 | 81 | } |
82 | ||
83 | G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance(); | |
84 | if(pVVisManager && nofTrajectories>0) | |
85 | { | |
86 | G4UImanager::GetUIpointer()->ApplyCommand("/vis~/draw/current"); | |
87 | ||
88 | for (G4int i=0; i<nofTrajectories; i++) | |
89 | { | |
90 | G4VTrajectory* vtrajectory = (*(event->GetTrajectoryContainer()))[i]; | |
91 | G4Trajectory* trajectory = dynamic_cast<G4Trajectory*>(vtrajectory); | |
92 | if (!trajectory) { | |
93 | AliGlobals::Exception( | |
94 | "AliEventAction::DisplayEvent: Unknown trajectory type."); | |
95 | } | |
5f1d09c5 | 96 | if ( (fDrawFlag == "ALL") || |
97 | ((fDrawFlag == "CHARGED") && (trajectory->GetCharge() != 0.))){ | |
98 | trajectory->DrawTrajectory(50); | |
0646e189 | 99 | // the argument number defines the size of the step points |
100 | // use 2000 to make step points well visible | |
676fb573 | 101 | } |
102 | } | |
103 | G4UImanager::GetUIpointer()->ApplyCommand("/vis~/show/view"); | |
104 | } | |
105 | } | |
106 | ||
107 | // public methods | |
108 | ||
78ca1e9c | 109 | //_____________________________________________________________________________ |
676fb573 | 110 | void AliEventAction::BeginOfEventAction(const G4Event* event) |
111 | { | |
112 | // Called by G4 kernel at the beginning of event. | |
113 | // --- | |
114 | ||
115 | G4int eventID = event->GetEventID(); | |
116 | ||
03b03ccb | 117 | // reset the tracks counters |
118 | AliTrackingAction::Instance()->PrepareNewEvent(); | |
676fb573 | 119 | |
120 | if (fVerboseLevel>0) | |
5f1d09c5 | 121 | G4cout << ">>> Event " << event->GetEventID() << G4endl; |
b1327f8f | 122 | |
123 | fTimer->Start(); | |
676fb573 | 124 | } |
125 | ||
78ca1e9c | 126 | //_____________________________________________________________________________ |
676fb573 | 127 | void AliEventAction::EndOfEventAction(const G4Event* event) |
128 | { | |
129 | // Called by G4 kernel at the end of event. | |
130 | // --- | |
131 | ||
03b03ccb | 132 | // finish the last primary track of the current event |
133 | AliTrackingAction* trackingAction = AliTrackingAction::Instance(); | |
134 | trackingAction->FinishPrimaryTrack(); | |
676fb573 | 135 | |
03b03ccb | 136 | // verbose output |
676fb573 | 137 | if (fVerboseLevel>0) { |
d68d8174 | 138 | G4cout << G4endl; |
139 | G4cout << ">>> End of Event " << event->GetEventID() << G4endl; | |
140 | } | |
141 | ||
142 | if (fVerboseLevel>1) { | |
03b03ccb | 143 | //G4int nofPrimaryTracks = trackingAction->GetNofPrimaryTracks(); |
144 | G4int nofPrimaryTracks = gAlice->GetHeader()->GetNprimary(); | |
145 | G4int nofSavedTracks = gAlice->GetNtrack(); | |
146 | G4int nofAllTracks = trackingAction->GetNofTracks(); | |
147 | ||
676fb573 | 148 | G4cout << " " << nofPrimaryTracks << |
5f1d09c5 | 149 | " primary tracks processed." << G4endl; |
03b03ccb | 150 | G4cout << " " << nofSavedTracks << |
151 | " tracks saved." << G4endl; | |
152 | G4cout << " " << nofAllTracks << | |
b1327f8f | 153 | " all tracks processed." << G4endl; |
676fb573 | 154 | } |
155 | ||
156 | // display event | |
157 | DisplayEvent(event); | |
158 | ||
03b03ccb | 159 | // aliroot finish event |
676fb573 | 160 | gAlice->FinishEvent(); |
676fb573 | 161 | |
d68d8174 | 162 | if (fVerboseLevel>1) { |
e012a2ec | 163 | // print time |
164 | fTimer->Stop(); | |
03b03ccb | 165 | G4cout << "Time of this event: " << *fTimer << G4endl; |
e012a2ec | 166 | } |
b1327f8f | 167 | } |