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
27
32
33
34G4ClassificationOfNewTrack StackingAction::ClassifyNewTrack(const G4Track* aTrack)
35{
36 // look for optical photon
37 if (aTrack->GetDefinition() != G4OpticalPhoton::OpticalPhotonDefinition())
38 return fUrgent;
39
40 // check if creator process is available
41 if (!aTrack->GetCreatorProcess()) return fUrgent;
42
43 // look for Cerenkov photon
44 if (aTrack->GetCreatorProcess()->GetProcessName() != "Cerenkov") return fUrgent;
45
46 // get track info
47 TrackInfo* info = dynamic_cast<TrackInfo*>(aTrack->GetUserInformation());
48 if (!info) return fUrgent;
49
50 // check if prescaling already done
51 if (info->getStatus() != 0) return fUrgent;
52
53 // if not, do it
54 if (gRandom->Uniform() > m_photonFraction) {
55 TrackInfo::getInfo(*aTrack).setIgnore();
56 return fKill;
57 }
58
59 // set new status and store prescaling fraction
60 info->setStatus(1);
61 info->setFraction(m_photonFraction);
62
63 return fUrgent;
64}
65
66
68{
69
70}
71
72
StackingAction()
The StackingAction constructor.
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 beginning of event.
Abstract base class for different kinds of events.
STL namespace.