Belle II Software  release-05-02-19
ReaderSAD.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010-2012 Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Andreas Moll, Hiroyuki Nakayama, Igal Jaegle *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 #include <framework/core/FrameworkExceptions.h>
14 
15 #include <mdst/dataobjects/MCParticleGraph.h>
16 
17 #include <TGeoMatrix.h>
18 #include <TFile.h>
19 #include <TTree.h>
20 
21 #include <string>
22 
23 
24 namespace Belle2 {
37  class ReaderSAD {
38 
39  public:
40 
41  //Define exceptions
43  BELLE2_DEFINE_EXCEPTION(SADCouldNotOpenFileError, "Could not open file %1% !");
45  BELLE2_DEFINE_EXCEPTION(SADEndOfFile, "End of the SAD file.");
46 
48  enum AcceleratorRings {
49  c_HER = 0,
50  c_LER = 1
51  };
52 
57 
61  ~ReaderSAD();
62 
70  void initialize(TGeoHMatrix* transMatrix, double sRange, AcceleratorRings accRing, double readoutTime);
71 
76  void open(const std::string& filename);
77 
84  void setMomentumRes(double pxRes, double pyRes) { m_pxRes = pxRes; m_pyRes = pyRes; }
85 
93  double getSADParticle(MCParticleGraph& graph);
94 
102  bool getRealParticle(MCParticleGraph& graph);
103 
109  void addAllSADParticles(MCParticleGraph& graph);
110 
117  TGeoHMatrix SADtoGeant(ReaderSAD::AcceleratorRings accRing, double s);
118 
119 
120  protected:
121 
122  TFile* m_file;
123  TTree* m_tree;
125  TGeoHMatrix* m_transMatrix;
126  double m_sRange;
128  double m_pxRes;
129  double m_pyRes;
132  double m_readoutTime;
134  unsigned int m_realPartNum;
135  unsigned int m_realPartEntry;
138  double m_lostX;
139  double m_lostY;
140  double m_lostS;
141  double m_lostPx;
142  double m_lostPy;
143  double m_lostRate;
144  double m_lostE;
148  double m_inputSAD_ss;
149  double m_inputSAD_s;
150  double m_inputSAD_Lss;
152  double m_inputSAD_x;
153  double m_inputSAD_y;
154  double m_inputSAD_px;
155  double m_inputSAD_py;
158  double m_inputSAD_r;
159  double m_inputSAD_rr;
161  double m_inputSAD_E;
165  private:
166 
169 
175  void addParticleToMCParticles(MCParticleGraph& graph, bool gaussSmearing = false);
176 
182  int calculateRealParticleNumber(double rate);
183 
185 // TGeoHMatrix SADtoGeant(ReaderSAD::AcceleratorRings accRing, double s);
186 
187  struct straightElement {
188  double x0;
189  double z0;
190  double l;
191  double phi;
192  };
193 
195  struct bendingElement {
196  double rt;
197  double x0;
198  double z0;
199  double sphi;
200  double dphi;
201  };
202 
203  };
204 
206 }
207 
Belle2::ReaderSAD::m_lostY
double m_lostY
y at lost position [m].
Definition: ReaderSAD.h:147
Belle2::ReaderSAD::m_lostX
double m_lostX
x at lost position [m].
Definition: ReaderSAD.h:146
Belle2::ReaderSAD::m_inputSAD_py
double m_inputSAD_py
y momentum at lost position [m].
Definition: ReaderSAD.h:163
Belle2::ReaderSAD::m_inputSAD_rate
double m_inputSAD_rate
loss rate [Hz]
Definition: ReaderSAD.h:170
Belle2::ReaderSAD::m_accRing
AcceleratorRings m_accRing
The accelerator ring from which the particles originate.
Definition: ReaderSAD.h:135
Belle2::ReaderSAD::m_lostE
double m_lostE
energy at lost position [m].
Definition: ReaderSAD.h:152
Belle2::ReaderSAD::m_sRange
double m_sRange
The +- range for the s value for which particles are loaded.
Definition: ReaderSAD.h:134
Belle2::ReaderSAD::m_pxRes
double m_pxRes
The resolution for the x momentum component of the SAD real particle.
Definition: ReaderSAD.h:136
Belle2::ReaderSAD::m_lostS
double m_lostS
lost position [m] along ring.
Definition: ReaderSAD.h:148
Belle2::MCParticleGraph
Class to build, validate and sort a particle decay chain.
Definition: MCParticleGraph.h:48
Belle2::ReaderSAD::m_pyRes
double m_pyRes
The resolution for the y momentum component of the SAD real particle.
Definition: ReaderSAD.h:137
Belle2::ReaderSAD::setMomentumRes
void setMomentumRes(double pxRes, double pyRes)
Sets the resolution of the momentum for the real particles.
Definition: ReaderSAD.h:92
Belle2::ReaderSAD::~ReaderSAD
~ReaderSAD()
Destructor.
Definition: ReaderSAD.cc:65
Belle2::ReaderSAD::m_SADToRealFactor
double m_SADToRealFactor
The factor to calculate the number of real particles from a SAD particle.
Definition: ReaderSAD.h:139
Belle2::ReaderSAD::c_LER
@ c_LER
Low Energy Ring (positrons)
Definition: ReaderSAD.h:58
Belle2::ReaderSAD::c_HER
@ c_HER
High Energy Ring (electrons)
Definition: ReaderSAD.h:57
Belle2::ReaderSAD::straightElement::phi
double phi
Phi angle.
Definition: ReaderSAD.h:199
Belle2::ReaderSAD::getSADParticle
double getSADParticle(MCParticleGraph &graph)
Reads one SAD particle from the file and creates one event per SAD particle.
Definition: ReaderSAD.cc:123
Belle2::ReaderSAD::BELLE2_DEFINE_EXCEPTION
BELLE2_DEFINE_EXCEPTION(SADCouldNotOpenFileError, "Could not open file %1% !")
Exception is thrown if the SAD file could not be opened.
Belle2::ReaderSAD::m_inputSAD_x
double m_inputSAD_x
x at lost position [m].
Definition: ReaderSAD.h:160
Belle2::ReaderSAD::m_tree
TTree * m_tree
The input root tree.
Definition: ReaderSAD.h:131
Belle2::ReaderSAD::m_inputSAD_nturn
int m_inputSAD_nturn
number of turns from scattered to lost
Definition: ReaderSAD.h:159
Belle2::ReaderSAD::open
void open(const std::string &filename)
Opens a root file and prepares it for reading.
Definition: ReaderSAD.cc:81
Belle2::ReaderSAD::m_readEntry
int m_readEntry
The current number of the SAD entry that is read.
Definition: ReaderSAD.h:144
Belle2::ReaderSAD::m_inputSAD_rr
double m_inputSAD_rr
sqrt(x*x+y*y) [m] before matching onto beam pipe inner surface
Definition: ReaderSAD.h:167
Belle2::ReaderSAD::m_realPartEntry
unsigned int m_realPartEntry
The current number of the created real particles.
Definition: ReaderSAD.h:143
Belle2::ReaderSAD::SADtoGeant
TGeoHMatrix SADtoGeant(ReaderSAD::AcceleratorRings accRing, double s)
Transformation matrix.
Definition: ReaderSAD.cc:417
Belle2::ReaderSAD::getRealParticle
bool getRealParticle(MCParticleGraph &graph)
Reads one SAD particle from the file, calculates the number of real particles which are represented b...
Definition: ReaderSAD.cc:166
Belle2::ReaderSAD::m_inputSAD_watt
double m_inputSAD_watt
loss wattage [W]
Definition: ReaderSAD.h:171
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::ReaderSAD::m_readoutTime
double m_readoutTime
The readout time.
Definition: ReaderSAD.h:140
Belle2::ReaderSAD::m_inputSAD_sraw
double m_inputSAD_sraw
lost position [m
Definition: ReaderSAD.h:155
Belle2::ReaderSAD::bendingElement::rt
double rt
Parameter.
Definition: ReaderSAD.h:204
Belle2::ReaderSAD::addParticleToMCParticles
void addParticleToMCParticles(MCParticleGraph &graph, bool gaussSmearing=false)
Adds the current particle described by the member variables to the MCParticles collection.
Definition: ReaderSAD.cc:267
Belle2::ReaderSAD::m_inputSAD_px
double m_inputSAD_px
x momentum at lost position [m].
Definition: ReaderSAD.h:162
Belle2::ReaderSAD::convertParamsToSADUnits
void convertParamsToSADUnits()
Convert the parameters from the SAD units to the basf2 units.
Definition: ReaderSAD.cc:237
Belle2::ReaderSAD::bendingElement::z0
double z0
Initial position in Z
Definition: ReaderSAD.h:206
Belle2::ReaderSAD::m_inputSAD_ss
double m_inputSAD_ss
scattered position (|s|<Ltot/2) [m]
Definition: ReaderSAD.h:156
Belle2::ReaderSAD::m_transMatrix
TGeoHMatrix * m_transMatrix
Transformation matrix from local SAD to global geant4 space.
Definition: ReaderSAD.h:133
Belle2::ReaderSAD::bendingElement
Sensitive Element
Definition: ReaderSAD.h:203
Belle2::ReaderSAD::m_inputSAD_y
double m_inputSAD_y
y at lost position [m].
Definition: ReaderSAD.h:161
Belle2::ReaderSAD::initialize
void initialize(TGeoHMatrix *transMatrix, double sRange, AcceleratorRings accRing, double readoutTime)
Initializes the reader, sets the particle parameters and calculates important values.
Definition: ReaderSAD.cc:72
Belle2::ReaderSAD::m_lostPy
double m_lostPy
y momentum at lost position [m].
Definition: ReaderSAD.h:150
Belle2::ReaderSAD::AcceleratorRings
AcceleratorRings
The both accelerator rings.
Definition: ReaderSAD.h:56
Belle2::ReaderSAD::bendingElement::x0
double x0
Initial position in X
Definition: ReaderSAD.h:205
Belle2::ReaderSAD::m_inputSAD_Lss
double m_inputSAD_Lss
length of element in which scattered [m]
Definition: ReaderSAD.h:158
Belle2::ReaderSAD::m_file
TFile * m_file
The input root file.
Definition: ReaderSAD.h:130
Belle2::ReaderSAD::bendingElement::dphi
double dphi
Bending Angle for torus in phi.
Definition: ReaderSAD.h:208
Belle2::ReaderSAD::m_inputSAD_r
double m_inputSAD_r
sqrt(x*x+y*y) [m]
Definition: ReaderSAD.h:166
Belle2::ReaderSAD::m_inputSAD_dp_over_p0
double m_inputSAD_dp_over_p0
dp_over_p0
Definition: ReaderSAD.h:168
Belle2::ReaderSAD::m_inputSAD_s
double m_inputSAD_s
lost position (|s|<Ltot/2) [m]
Definition: ReaderSAD.h:157
Belle2::ReaderSAD::calculateRealParticleNumber
int calculateRealParticleNumber(double rate)
Calculates the number of real particles for a SAD particle.
Definition: ReaderSAD.cc:404
Belle2::ReaderSAD::bendingElement::sphi
double sphi
Bending Angle.
Definition: ReaderSAD.h:207
Belle2::ReaderSAD::m_inputSAD_xraw
double m_inputSAD_xraw
x at lost position [m] before matching onto beam pipe inner surface
Definition: ReaderSAD.h:164
Belle2::ReaderSAD::m_inputSAD_ssraw
double m_inputSAD_ssraw
scattered position [m]
Definition: ReaderSAD.h:154
Belle2::ReaderSAD::m_inputSAD_E
double m_inputSAD_E
energy at lost position [m].
Definition: ReaderSAD.h:169
Belle2::ReaderSAD::straightElement::l
double l
Parameter.
Definition: ReaderSAD.h:198
Belle2::ReaderSAD::straightElement
Calculates the transformation matrix from local SAD to global geant4 space.
Definition: ReaderSAD.h:195
Belle2::ReaderSAD::ReaderSAD
ReaderSAD()
Constructor of the ReaderSAD class.
Definition: ReaderSAD.cc:29
Belle2::ReaderSAD::addAllSADParticles
void addAllSADParticles(MCParticleGraph &graph)
Reads all SAD particles from the file into the MCParticles collection which are inside the specified ...
Definition: ReaderSAD.cc:213
Belle2::ReaderSAD::straightElement::x0
double x0
Initial position in X.
Definition: ReaderSAD.h:196
Belle2::ReaderSAD::m_lostPx
double m_lostPx
x momentum at lost position [m].
Definition: ReaderSAD.h:149
Belle2::ReaderSAD::m_lostRate
double m_lostRate
loss rate [Hz]>
Definition: ReaderSAD.h:151
Belle2::ReaderSAD::m_inputSAD_yraw
double m_inputSAD_yraw
y at lost position [m] before matching onto beam pipe inner surface
Definition: ReaderSAD.h:165
Belle2::ReaderSAD::m_realPartNum
unsigned int m_realPartNum
The current number of the created real particles.
Definition: ReaderSAD.h:142
Belle2::ReaderSAD::straightElement::z0
double z0
Initial position in Z.
Definition: ReaderSAD.h:197