ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
RE05StackingAction.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file RE05StackingAction.cc
1
//
2
// ********************************************************************
3
// * License and Disclaimer *
4
// * *
5
// * The Geant4 software is copyright of the Copyright Holders of *
6
// * the Geant4 Collaboration. It is provided under the terms and *
7
// * conditions of the Geant4 Software License, included in the file *
8
// * LICENSE and available at http://cern.ch/geant4/license . These *
9
// * include a list of copyright holders. *
10
// * *
11
// * Neither the authors of this software system, nor their employing *
12
// * institutes,nor the agencies providing financial support for this *
13
// * work make any representation or warranty, express or implied, *
14
// * regarding this software system or assume any liability for its *
15
// * use. Please see the license in the file LICENSE and URL above *
16
// * for the full disclaimer and the limitation of liability. *
17
// * *
18
// * This code implementation is the result of the scientific and *
19
// * technical work of the GEANT4 collaboration. *
20
// * By using, copying, modifying or distributing the software (or *
21
// * any work based on the software) you agree to acknowledge its *
22
// * use in resulting scientific publications, and indicate your *
23
// * acceptance of all terms of the Geant4 Software license. *
24
// ********************************************************************
25
//
26
//
29
//
30
31
#include "
RE05StackingAction.hh
"
32
#include "
G4SDManager.hh
"
33
#include "
G4RunManager.hh
"
34
#include "
G4Event.hh
"
35
#include "G4HCofThisEvent.hh"
36
#include "
G4Track.hh
"
37
#include "
G4TrackStatus.hh
"
38
#include "
G4ParticleDefinition.hh
"
39
#include "
G4ParticleTypes.hh
"
40
#include "
RE05StackingActionMessenger.hh
"
41
#include "
G4SystemOfUnits.hh
"
42
#include "
G4ios.hh
"
43
44
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
45
46
RE05StackingAction::RE05StackingAction
()
47
:
G4UserStackingAction
(),
48
fTrkHits(0), fMuonHits(0), fMessenger(0),
49
fStage(0),
50
fReqMuon(2),
51
fReqIso(10),
52
fAngRoI(30.0*
deg
)
53
{
54
fMessenger
=
new
RE05StackingActionMessenger
(
this
);
55
}
56
57
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58
59
RE05StackingAction::~RE05StackingAction
()
60
{
delete
fMessenger
; }
61
62
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
63
64
G4ClassificationOfNewTrack
65
RE05StackingAction::ClassifyNewTrack
(
const
G4Track
* aTrack)
66
{
67
G4ClassificationOfNewTrack
classification =
fWaiting
;
68
switch
(
fStage
)
69
{
70
case
0:
// Stage 0 : Primary muons only
71
if
(aTrack->
GetParentID
()==0)
72
{
73
G4ParticleDefinition
* particleType = aTrack->
GetDefinition
();
74
if
((particleType==
G4MuonPlus::MuonPlusDefinition
())
75
||(particleType==
G4MuonMinus::MuonMinusDefinition
()))
76
{ classification =
fUrgent
; }
77
}
78
break
;
79
80
case
1:
// Stage 1 : Charged primaries only
81
// Suspended tracks will be sent to the waiting stack
82
if
(aTrack->
GetParentID
()!=0) {
break
; }
83
if
(aTrack->
GetTrackStatus
()==
fSuspend
) {
break
; }
84
if
(aTrack->
GetDefinition
()->
GetPDGCharge
()==0.) {
break
; }
85
classification =
fUrgent
;
86
break
;
87
88
default
:
// Stage 2 : Accept all primaries
89
// Accept all secondaries in RoI
90
// Kill secondaries outside RoI
91
if
(aTrack->
GetParentID
()==0)
92
{
93
classification =
fUrgent
;
94
break
;
95
}
96
if
((
fAngRoI
<0.)||
InsideRoI
(aTrack,
fAngRoI
))
97
{
98
classification =
fUrgent
;
99
break
;
100
}
101
classification =
fKill
;
102
}
103
return
classification;
104
}
105
106
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
107
108
G4bool
RE05StackingAction::InsideRoI
(
const
G4Track
* aTrack,
G4double
ang)
109
{
110
if
(!
fMuonHits
)
111
{
fMuonHits
= (
RE05MuonHitsCollection
*)
GetCollection
(
"muonCollection"
); }
112
if
(!
fMuonHits
)
113
{
G4cerr
<<
"muonCollection NOT FOUND"
<<
G4endl
;
114
return
true
; }
115
116
G4int
nhits =
fMuonHits
->
entries
();
117
118
const
G4ThreeVector
trPos = aTrack->
GetPosition
();
119
for
(
G4int
i=0;i<nhits;i++)
120
{
121
G4ThreeVector
muHitPos = (*fMuonHits)[i]->GetPos();
122
G4double
angl = muHitPos.
angle
(trPos);
123
if
(angl<ang) {
return
true
; }
124
}
125
126
return
false
;
127
}
128
129
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
130
131
G4VHitsCollection
*
RE05StackingAction::GetCollection
(
G4String
colName)
132
{
133
G4SDManager
* SDMan =
G4SDManager::GetSDMpointer
();
134
G4RunManager
* runMan =
G4RunManager::GetRunManager
();
135
int
colID = SDMan->
GetCollectionID
(colName);
136
if
(colID>=0)
137
{
138
const
G4Event
* currentEvent = runMan->
GetCurrentEvent
();
139
G4HCofThisEvent
* HCE = currentEvent->
GetHCofThisEvent
();
140
return
HCE->
GetHC
(colID);
141
}
142
return
0;
143
}
144
145
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
146
147
void
RE05StackingAction::NewStage
()
148
{
149
fStage
++;
150
G4int
nhits;
151
if
(
fStage
==1)
152
{
153
// Stage 0->1 : check if at least "fReqMuon" hits on muon chamber
154
// otherwise abort current event
155
if
(!
fMuonHits
)
156
{
fMuonHits
= (
RE05MuonHitsCollection
*)
GetCollection
(
"muonCollection"
); }
157
if
(!
fMuonHits
)
158
{
G4cerr
<<
"muonCollection NOT FOUND"
<<
G4endl
;
159
return
; }
160
nhits =
fMuonHits
->
entries
();
163
if
(nhits<
fReqMuon
)
164
{
165
stackManager
->
clear
();
167
return
;
168
}
169
stackManager
->
ReClassify
();
170
return
;
171
}
172
173
else
if
(
fStage
==2)
174
{
175
// Stage 1->2 : check the isolation of muon tracks
176
// at least "fReqIsoMuon" isolated muons
177
// otherwise abort current event.
178
// Isolation requires "fReqIso" or less hits
179
// (including own hits) in the RoI region
180
// in the tracker layers.
181
nhits =
fMuonHits
->
entries
();
182
if
(!
fTrkHits
)
183
{
fTrkHits
= (
RE05TrackerHitsCollection
*)
GetCollection
(
"trackerCollection"
); }
184
if
(!
fTrkHits
)
185
{
G4cerr
<<
"trackerCollection NOT FOUND"
<<
G4endl
;
186
return
; }
187
G4int
nTrkhits =
fTrkHits
->
entries
();
188
G4int
isoMuon = 0;
189
for
(
G4int
j=0;j<nhits;j++)
190
{
191
G4ThreeVector
hitPos = (*fMuonHits)[j]->GetPos();
192
G4int
nhitIn = 0;
193
for
(
G4int
jj=0;(jj<nTrkhits)&&(nhitIn<=
fReqIso
);jj++)
194
{
195
G4ThreeVector
trkhitPos = (*fTrkHits)[jj]->GetPos();
196
if
(trkhitPos.
angle
(hitPos)<
fAngRoI
) nhitIn++;
197
}
198
if
(nhitIn<=
fReqIso
) isoMuon++;
199
}
201
if
(isoMuon<
fReqIsoMuon
)
202
{
203
stackManager
->
clear
();
205
return
;
206
}
207
stackManager
->
ReClassify
();
208
return
;
209
}
210
211
else
212
{
213
// Other fStage change : just re-classify
214
stackManager
->
ReClassify
();
215
}
216
}
217
218
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
219
220
void
RE05StackingAction::PrepareNewEvent
()
221
{
222
fStage
= 0;
223
fTrkHits
= 0;
224
fMuonHits
= 0;
225
}
226
227
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
geant4
tree
geant4-10.6-release
examples
extended
runAndEvent
RE05
src
RE05StackingAction.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:10
using
1.8.2 with
ECCE GitHub integration