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