]>
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> | |
c97337f9 | 12 | #include <G4TrackStack.hh> |
676fb573 | 13 | #include <G4StackedTrack.hh> |
14 | #include <G4StackManager.hh> | |
cc4ca0eb | 15 | #include <G4NeutrinoE.hh> |
16 | #include <G4NeutrinoMu.hh> | |
17 | #include <G4NeutrinoTau.hh> | |
18 | #include <G4AntiNeutrinoE.hh> | |
19 | #include <G4AntiNeutrinoMu.hh> | |
20 | #include <G4AntiNeutrinoTau.hh> | |
676fb573 | 21 | |
78ca1e9c | 22 | //_____________________________________________________________________________ |
676fb573 | 23 | AliStackingAction::AliStackingAction() |
24 | : fStage(0), | |
25 | fVerboseLevel(0), | |
26 | fSavePrimaries(true), | |
27 | fTrackingAction(0) | |
28 | { | |
29 | // | |
30 | fPrimaryStack = new G4TrackStack(); | |
31 | fMessenger = new AliStackingActionMessenger(this); | |
32 | } | |
33 | ||
78ca1e9c | 34 | //_____________________________________________________________________________ |
676fb573 | 35 | AliStackingAction::AliStackingAction(const AliStackingAction& right) { |
36 | // | |
37 | AliGlobals::Exception("AliStackingAction is protected from copying."); | |
38 | } | |
39 | ||
78ca1e9c | 40 | //_____________________________________________________________________________ |
676fb573 | 41 | AliStackingAction::~AliStackingAction() { |
42 | // | |
43 | delete fPrimaryStack; | |
44 | delete fMessenger; | |
45 | } | |
46 | ||
47 | // operators | |
48 | ||
78ca1e9c | 49 | //_____________________________________________________________________________ |
676fb573 | 50 | AliStackingAction& |
51 | AliStackingAction::operator=(const AliStackingAction &right) | |
52 | { | |
53 | // check assignement to self | |
54 | if (this == &right) return *this; | |
55 | ||
56 | AliGlobals::Exception("AliStackingAction is protected from assigning."); | |
57 | ||
58 | return *this; | |
59 | } | |
60 | ||
61 | // public methods | |
62 | ||
78ca1e9c | 63 | //_____________________________________________________________________________ |
676fb573 | 64 | G4ClassificationOfNewTrack |
65 | AliStackingAction::ClassifyNewTrack(const G4Track* track) | |
66 | { | |
67 | // Classifies the new track. | |
68 | // --- | |
69 | ||
70 | G4ClassificationOfNewTrack classification; | |
71 | if (fStage == 0) { | |
72 | // move all primaries to PrimaryStack | |
73 | G4Track* nonconstTrack = (G4Track*)track; | |
74 | G4StackedTrack* newTrack = new G4StackedTrack(nonconstTrack); | |
75 | fPrimaryStack->PushToStack(newTrack); | |
76 | classification = fPostpone; | |
77 | ||
78 | // save primary particle info | |
79 | // (secondary particles are stored | |
80 | // by AlTrackingAction::PreUserTrackingAction() method) | |
81 | if (fSavePrimaries) | |
6faf4d8a | 82 | fTrackingAction->SaveTrack(track); |
676fb573 | 83 | } |
84 | else { | |
cc4ca0eb | 85 | // exclude neutrinos |
86 | G4ParticleDefinition* particle = track->GetDefinition(); | |
87 | if( particle == G4NeutrinoE::NeutrinoEDefinition() || | |
88 | particle == G4NeutrinoMu::NeutrinoMuDefinition() || | |
89 | particle == G4NeutrinoTau::NeutrinoTauDefinition() || | |
90 | particle == G4AntiNeutrinoE::AntiNeutrinoEDefinition() || | |
91 | particle == G4AntiNeutrinoMu::AntiNeutrinoMuDefinition() || | |
92 | particle == G4AntiNeutrinoTau::AntiNeutrinoTauDefinition()) { | |
93 | ||
94 | return fKill; | |
95 | } | |
96 | ||
676fb573 | 97 | G4int parentID = track->GetParentID(); |
98 | if (parentID ==0) { | |
cc4ca0eb | 99 | return fUrgent; |
676fb573 | 100 | } |
101 | else { | |
cc4ca0eb | 102 | return fWaiting; |
676fb573 | 103 | } |
104 | } | |
105 | return classification; | |
106 | } | |
107 | ||
78ca1e9c | 108 | //_____________________________________________________________________________ |
676fb573 | 109 | void AliStackingAction::NewStage() |
110 | { | |
111 | // Called by G4 kernel at the new stage of stacking. | |
112 | // --- | |
113 | ||
114 | fStage++; | |
115 | if (fVerboseLevel>0) | |
116 | { | |
117 | G4cout << "AliStackingAction::NewStage " << fStage | |
5f1d09c5 | 118 | << " has been started." << G4endl; |
676fb573 | 119 | } |
120 | ||
121 | G4int nofUrgent = stackManager->GetNUrgentTrack(); | |
122 | if (nofUrgent == 0) | |
123 | { | |
124 | G4int nofPrimary = fPrimaryStack->GetNTrack(); | |
125 | if (nofPrimary>0) | |
126 | { | |
127 | G4StackedTrack* stackedTrack | |
128 | = fPrimaryStack->PopFromStack(); | |
129 | G4Track* primaryTrack | |
130 | = stackedTrack->GetTrack(); | |
131 | delete stackedTrack; | |
132 | stackManager->PushOneTrack(primaryTrack); | |
133 | } | |
134 | } | |
135 | } | |
136 | ||
78ca1e9c | 137 | //_____________________________________________________________________________ |
676fb573 | 138 | void AliStackingAction::PrepareNewEvent() |
139 | { | |
140 | // Called by G4 kernel at the beginning of event. | |
141 | // --- | |
142 | ||
143 | fStage = 0; | |
d4998de6 | 144 | //stackManager->ClearPostponeStack(); |
145 | stackManager->ResetPostponeStack(); | |
676fb573 | 146 | fTrackingAction = AliTrackingAction::Instance(); |
147 | fSavePrimaries = fTrackingAction->GetSavePrimaries(); | |
148 | } | |
149 | ||
150 |