Belle II Software  release-05-02-19
BeamBkgGeneratorModule.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2017 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Marko Staric *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 #include <framework/core/Module.h>
14 #include <string>
15 #include <vector>
16 #include <TFile.h>
17 #include <TTree.h>
18 #include <TRotation.h>
19 
20 namespace Belle2 {
29  class BeamBkgGeneratorModule : public Module {
30 
31  public:
32 
37 
41  virtual ~BeamBkgGeneratorModule();
42 
47  virtual void initialize() override;
48 
53  virtual void beginRun() override;
54 
58  virtual void event() override;
59 
64  virtual void endRun() override;
65 
70  virtual void terminate() override;
71 
72  private:
73 
78  int generateEntry() const;
79 
83  struct SADTree {
84  double s = 0;
85  double x = 0;
86  double px = 0;
87  double y = 0;
88  double py = 0;
89  double E = 0;
90  double rate = 0;
91  double ss = 0;
92  int nturn = 0;
93  double sraw = 0;
94  double ssraw = 0;
95  double xraw = 0;
96  double yraw = 0;
97  double r = 0;
98  double rr = 0;
99  double dp_over_p0 = 0;
100  double watt = 0;
101  };
102 
103  std::string m_fileName;
104  std::string m_treeName;
105  std::string m_ringName;
106  double m_realTime = 0;
108  TFile* m_file = 0;
109  TTree* m_tree = 0;
110  SADTree m_sad;
111  TRotation m_rotation;
112  int m_ring = 0 ;
113  std::vector<int> m_sectionOrdering;
115  std::vector<double> m_rates;
116  int m_numEvents = 0 ;
117  int m_eventCounter = 0;
118  std::vector<int> m_counters;
120  };
121 
123 } // Belle2 namespace
124 
Belle2::BeamBkgGeneratorModule::m_ring
int m_ring
ring number, 1-HER, 2-LER
Definition: BeamBkgGeneratorModule.h:120
Belle2::BeamBkgGeneratorModule::SADTree::y
double y
y at lost position [m]
Definition: BeamBkgGeneratorModule.h:95
Belle2::BeamBkgGeneratorModule::m_fileName
std::string m_fileName
name of the SAD file converted to root
Definition: BeamBkgGeneratorModule.h:111
Belle2::BeamBkgGeneratorModule::SADTree::px
double px
px at lost position [GeV]
Definition: BeamBkgGeneratorModule.h:94
Belle2::BeamBkgGeneratorModule::generateEntry
int generateEntry() const
Pick up particle randomly from the SAD file according to its rate.
Definition: BeamBkgGeneratorModule.cc:263
Belle2::BeamBkgGeneratorModule::SADTree::x
double x
x at lost position [m]
Definition: BeamBkgGeneratorModule.h:93
Belle2::BeamBkgGeneratorModule::SADTree::xraw
double xraw
x at lost position [m] before matching G4 beam pipe inner surface
Definition: BeamBkgGeneratorModule.h:103
Belle2::BeamBkgGeneratorModule::m_rates
std::vector< double > m_rates
cumulative rates of SAD particles [Hz]
Definition: BeamBkgGeneratorModule.h:123
Belle2::BeamBkgGeneratorModule::m_treeName
std::string m_treeName
name of the TTree in the SAD file
Definition: BeamBkgGeneratorModule.h:112
Belle2::BeamBkgGeneratorModule::SADTree::ssraw
double ssraw
scattered position [m]
Definition: BeamBkgGeneratorModule.h:102
Belle2::BeamBkgGeneratorModule::beginRun
virtual void beginRun() override
Called when entering a new run.
Definition: BeamBkgGeneratorModule.cc:163
Belle2::BeamBkgGeneratorModule::SADTree::yraw
double yraw
y at lost position [m] before matching G4 beam pipe inner surface
Definition: BeamBkgGeneratorModule.h:104
Belle2::BeamBkgGeneratorModule::SADTree::nturn
int nturn
number of turns from scattered to lost
Definition: BeamBkgGeneratorModule.h:100
Belle2::BeamBkgGeneratorModule::SADTree::py
double py
py at lost position [GeV]
Definition: BeamBkgGeneratorModule.h:96
Belle2::BeamBkgGeneratorModule::m_realTime
double m_realTime
equivalent SuperKEKB running time in [ns]
Definition: BeamBkgGeneratorModule.h:114
Belle2::BeamBkgGeneratorModule::m_sad
SADTree m_sad
TTree entry data.
Definition: BeamBkgGeneratorModule.h:118
Belle2::BeamBkgGeneratorModule::m_rotation
TRotation m_rotation
rotation from SAD to Belle II frame
Definition: BeamBkgGeneratorModule.h:119
Belle2::BeamBkgGeneratorModule::event
virtual void event() override
Event processor.
Definition: BeamBkgGeneratorModule.cc:167
Belle2::BeamBkgGeneratorModule::endRun
virtual void endRun() override
End-of-run action.
Definition: BeamBkgGeneratorModule.cc:233
Belle2::BeamBkgGeneratorModule::SADTree
Structure of the TTree in the SAD file.
Definition: BeamBkgGeneratorModule.h:91
Belle2::BeamBkgGeneratorModule::m_file
TFile * m_file
root file pointer
Definition: BeamBkgGeneratorModule.h:116
Belle2::BeamBkgGeneratorModule::m_counters
std::vector< int > m_counters
counters: how many times SAD particles are used
Definition: BeamBkgGeneratorModule.h:126
Belle2::BeamBkgGeneratorModule::m_eventCounter
int m_eventCounter
event counter
Definition: BeamBkgGeneratorModule.h:125
Belle2::BeamBkgGeneratorModule::SADTree::sraw
double sraw
s at lost position [m] before matching G4 beam pipe inner surface
Definition: BeamBkgGeneratorModule.h:101
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::BeamBkgGeneratorModule::initialize
virtual void initialize() override
Initialize the Module.
Definition: BeamBkgGeneratorModule.cc:74
Belle2::BeamBkgGeneratorModule::BeamBkgGeneratorModule
BeamBkgGeneratorModule()
Constructor.
Definition: BeamBkgGeneratorModule.cc:51
Belle2::BeamBkgGeneratorModule::SADTree::rr
double rr
sqrt(xraw*xraw+yraw*yraw) [m]
Definition: BeamBkgGeneratorModule.h:106
Belle2::BeamBkgGeneratorModule::SADTree::watt
double watt
loss wattage [W]
Definition: BeamBkgGeneratorModule.h:108
Belle2::BeamBkgGeneratorModule::SADTree::s
double s
lost position measured from IP along the ring [m]
Definition: BeamBkgGeneratorModule.h:92
Belle2::BeamBkgGeneratorModule::SADTree::dp_over_p0
double dp_over_p0
momentum deviation of the lost particle
Definition: BeamBkgGeneratorModule.h:107
Belle2::BeamBkgGeneratorModule::~BeamBkgGeneratorModule
virtual ~BeamBkgGeneratorModule()
Destructor.
Definition: BeamBkgGeneratorModule.cc:70
Belle2::BeamBkgGeneratorModule::SADTree::rate
double rate
lost rate [Hz]
Definition: BeamBkgGeneratorModule.h:98
Belle2::BeamBkgGeneratorModule::m_tree
TTree * m_tree
root tree pointer
Definition: BeamBkgGeneratorModule.h:117
Belle2::BeamBkgGeneratorModule::SADTree::ss
double ss
scattered position (|s|<Ltot/2) [m]
Definition: BeamBkgGeneratorModule.h:99
Belle2::BeamBkgGeneratorModule::m_numEvents
int m_numEvents
number of events to generate
Definition: BeamBkgGeneratorModule.h:124
Belle2::BeamBkgGeneratorModule::m_sectionOrdering
std::vector< int > m_sectionOrdering
superKEKB section ordering
Definition: BeamBkgGeneratorModule.h:121
Belle2::BeamBkgGeneratorModule::m_ringName
std::string m_ringName
name of the superKEKB ring (LER or HER)
Definition: BeamBkgGeneratorModule.h:113
Belle2::BeamBkgGeneratorModule::terminate
virtual void terminate() override
Termination action.
Definition: BeamBkgGeneratorModule.cc:237
Belle2::BeamBkgGeneratorModule::SADTree::r
double r
sqrt(x*x+y*y) [m]
Definition: BeamBkgGeneratorModule.h:105