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