]>
Commit | Line | Data |
---|---|---|
676fb573 | 1 | // $Id$ |
2 | // Category: event | |
3 | // | |
4 | // See the class description in the header file. | |
5 | ||
6 | #include "AliStackingAction.h" | |
7 | #include "AliStackingActionMessenger.h" | |
8 | #include "AliTrackingAction.h" | |
9 | #include "AliGlobals.h" | |
10 | ||
11 | #include <G4Track.hh> | |
12 | #include <G4StackedTrack.hh> | |
13 | #include <G4StackManager.hh> | |
14 | #include <G4ios.hh> | |
15 | ||
16 | AliStackingAction::AliStackingAction() | |
17 | : fStage(0), | |
18 | fVerboseLevel(0), | |
19 | fSavePrimaries(true), | |
20 | fTrackingAction(0) | |
21 | { | |
22 | // | |
23 | fPrimaryStack = new G4TrackStack(); | |
24 | fMessenger = new AliStackingActionMessenger(this); | |
25 | } | |
26 | ||
27 | AliStackingAction::AliStackingAction(const AliStackingAction& right) { | |
28 | // | |
29 | AliGlobals::Exception("AliStackingAction is protected from copying."); | |
30 | } | |
31 | ||
32 | AliStackingAction::~AliStackingAction() { | |
33 | // | |
34 | delete fPrimaryStack; | |
35 | delete fMessenger; | |
36 | } | |
37 | ||
38 | // operators | |
39 | ||
40 | AliStackingAction& | |
41 | AliStackingAction::operator=(const AliStackingAction &right) | |
42 | { | |
43 | // check assignement to self | |
44 | if (this == &right) return *this; | |
45 | ||
46 | AliGlobals::Exception("AliStackingAction is protected from assigning."); | |
47 | ||
48 | return *this; | |
49 | } | |
50 | ||
51 | // public methods | |
52 | ||
53 | G4ClassificationOfNewTrack | |
54 | AliStackingAction::ClassifyNewTrack(const G4Track* track) | |
55 | { | |
56 | // Classifies the new track. | |
57 | // --- | |
58 | ||
59 | G4ClassificationOfNewTrack classification; | |
60 | if (fStage == 0) { | |
61 | // move all primaries to PrimaryStack | |
62 | G4Track* nonconstTrack = (G4Track*)track; | |
63 | G4StackedTrack* newTrack = new G4StackedTrack(nonconstTrack); | |
64 | fPrimaryStack->PushToStack(newTrack); | |
65 | classification = fPostpone; | |
66 | ||
67 | // save primary particle info | |
68 | // (secondary particles are stored | |
69 | // by AlTrackingAction::PreUserTrackingAction() method) | |
70 | if (fSavePrimaries) | |
71 | fTrackingAction->SaveParticle(track, "primary"); | |
72 | } | |
73 | else { | |
74 | G4int parentID = track->GetParentID(); | |
75 | if (parentID ==0) { | |
76 | classification = fUrgent; | |
77 | } | |
78 | else { | |
79 | classification = fWaiting; | |
80 | } | |
81 | } | |
82 | return classification; | |
83 | } | |
84 | ||
85 | void AliStackingAction::NewStage() | |
86 | { | |
87 | // Called by G4 kernel at the new stage of stacking. | |
88 | // --- | |
89 | ||
90 | fStage++; | |
91 | if (fVerboseLevel>0) | |
92 | { | |
93 | G4cout << "AliStackingAction::NewStage " << fStage | |
5f1d09c5 | 94 | << " has been started." << G4endl; |
676fb573 | 95 | } |
96 | ||
97 | G4int nofUrgent = stackManager->GetNUrgentTrack(); | |
98 | if (nofUrgent == 0) | |
99 | { | |
100 | G4int nofPrimary = fPrimaryStack->GetNTrack(); | |
101 | if (nofPrimary>0) | |
102 | { | |
103 | G4StackedTrack* stackedTrack | |
104 | = fPrimaryStack->PopFromStack(); | |
105 | G4Track* primaryTrack | |
106 | = stackedTrack->GetTrack(); | |
107 | delete stackedTrack; | |
108 | stackManager->PushOneTrack(primaryTrack); | |
109 | } | |
110 | } | |
111 | } | |
112 | ||
113 | void AliStackingAction::ClearPrimaryStack() | |
114 | { | |
115 | // Clears the primary stack. | |
116 | // --- | |
117 | ||
118 | stackManager->ClearPostponeStack(); | |
119 | } | |
120 | ||
121 | void AliStackingAction::PrepareNewEvent() | |
122 | { | |
123 | // Called by G4 kernel at the beginning of event. | |
124 | // --- | |
125 | ||
126 | fStage = 0; | |
127 | ClearPrimaryStack(); | |
128 | fTrackingAction = AliTrackingAction::Instance(); | |
129 | fSavePrimaries = fTrackingAction->GetSavePrimaries(); | |
130 | } | |
131 | ||
132 |