Belle II Software development
StackingAction.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <simulation/kernel/StackingAction.h>
10#include <simulation/kernel/UserInfo.h>
11
12#include <G4ParticleDefinition.hh>
13#include <G4ParticleTypes.hh>
14#include <G4Track.hh>
15#include <G4VProcess.hh>
16
17#include <TRandom.h>
18
19using namespace std;
20using namespace Belle2;
21using namespace Simulation;
22
23
24StackingAction::StackingAction(): m_photonFraction(1.0)
25{
26 if (false) {
27 G4Track* aTrack;
28 ClassifyNewTrack(aTrack);
29 NewStage();
31 }
32}
33
35{
36
37}
38
39
40G4ClassificationOfNewTrack StackingAction::ClassifyNewTrack(const G4Track* aTrack)
41{
42 // look for optical photon
43 if (aTrack->GetDefinition() != G4OpticalPhoton::OpticalPhotonDefinition())
44 return fUrgent;
45
46 // check if creator process is available
47 if (!aTrack->GetCreatorProcess()) return fUrgent;
48
49 // look for Cerenkov photon
50 if (aTrack->GetCreatorProcess()->GetProcessName() != "Cerenkov") return fUrgent;
51
52 // get track info
53 TrackInfo* info = dynamic_cast<TrackInfo*>(aTrack->GetUserInformation());
54 if (!info) return fUrgent;
55
56 // chech if prescaling already done
57 if (info->getStatus() != 0) return fUrgent;
58
59 // if not, do it
60 if (gRandom->Uniform() > m_photonFraction) {
61 TrackInfo::getInfo(*aTrack).setIgnore();
62 return fKill;
63 }
64
65 // set new status and store prescaling fraction
66 info->setStatus(1);
67 info->setFraction(m_photonFraction);
68
69 return fUrgent;
70}
71
72
74{
75
76}
77
78
80{
81
82}
virtual void NewStage()
Function that is called at each event when "urgent" stack is empty.
double m_photonFraction
The fraction of Cerenkov photons which will be kept and propagated.
virtual G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track *aTrack)
Function that classifies new tracks.
~StackingAction()
The StackingAction destructor.
virtual void PrepareNewEvent()
Function called at begining of event.
UserInfo class which is used to attach additional information to Geant4 particles and tracks.
Definition: UserInfo.h:36
static Payload getInfo(Carrier &obj)
Static function to just return UserInformation attached to the obj of type Carrier.
Definition: UserInfo.h:100
Abstract base class for different kinds of events.
STL namespace.