Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
KFParticleField.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file KFParticleField.h
1 /*
2  * This file is part of KFParticle package
3  * Copyright (C) 2007-2019 FIAS Frankfurt Institute for Advanced Studies
4  * 2007-2019 Goethe University of Frankfurt
5  * 2007-2019 Ivan Kisel <I.Kisel@compeng.uni-frankfurt.de>
6  * 2007-2019 Maksym Zyzak
7  * 2007-2019 Sergey Gorbunov
8  *
9  * KFParticle is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * KFParticle is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <https://www.gnu.org/licenses/>.
21  */
22 
23 #ifndef KFParticleField_h
24 #define KFParticleField_h 1
25 
26 #include <iostream>
27 
40 {
41  public:
42  KFParticleFieldValue():x(0.f),y(0.f),z(0.f){};
43 
44  float_v x;
45  float_v y;
46  float_v z;
47 
48  void Combine( KFParticleFieldValue &B, float_v w )
49  {
55  x+= w*( B.x - x );
56  y+= w*( B.y - y );
57  z+= w*( B.z - z );
58  }
59 
64  friend std::ostream& operator<<(std::ostream& out, KFParticleFieldValue &B){
65  return out << B.x[0] << " | " << B.y[0] << " | " << B.z[0];
66  };
67 };
68 
82 {
83  public:
85  KFParticleFieldRegion(const float field[10])
86  {
90  for(int i=0; i<10; i++)
91  fField[i] = field[i];
92  }
93 
94  KFParticleFieldValue Get(const float_v z)
95  {
99  float_v dz = (z-fField[9]);
100  float_v dz2 = dz*dz;
102  B.x = fField[0] + fField[1]*dz + fField[2]*dz2;
103  B.y = fField[3] + fField[4]*dz + fField[5]*dz2;
104  B.z = fField[6] + fField[7]*dz + fField[8]*dz2;
105  return B;
106  }
107 
108  void Set( const KFParticleFieldValue &B0, const float_v B0z,
109  const KFParticleFieldValue &B1, const float_v B1z,
110  const KFParticleFieldValue &B2, const float_v B2z )
111  {
120  fField[9] = B0z;
121  float_v dz1 = B1z-B0z, dz2 = B2z-B0z;
122  float_v det = 1.f/(float_v(dz1*dz2*(dz2-dz1)));
123  float_v w21 = -dz2*det;
124  float_v w22 = dz1*det;
125  float_v w11 = -dz2*w21;
126  float_v w12 = -dz1*w22;
127 
128  float_v dB1 = B1.x - B0.x;
129  float_v dB2 = B2.x - B0.x;
130  fField[0] = B0.x;
131  fField[1] = dB1*w11 + dB2*w12 ;
132  fField[2] = dB1*w21 + dB2*w22 ;
133 
134  dB1 = B1.y - B0.y;
135  dB2 = B2.y - B0.y;
136  fField[3] = B0.y;
137  fField[4] = dB1*w11 + dB2*w12 ;
138  fField[5] = dB1*w21 + dB2*w22 ;
139 
140  dB1 = B1.z - B0.z;
141  dB2 = B2.z - B0.z;
142  fField[6] = B0.z;
143  fField[7] = dB1*w11 + dB2*w12 ;
144  fField[8] = dB1*w21 + dB2*w22 ;
145  }
146 
147  void Set( const KFParticleFieldValue &B0, const float_v B0z,
148  const KFParticleFieldValue &B1, const float_v B1z )
149  {
156  fField[9] = B0z;
157  float_v dzi = 1.f/(float_v( B1z - B0z));
158  fField[0] = B0.x;
159  fField[3] = B0.y;
160  fField[6] = B0.z;
161  fField[1] = ( B1.x - B0.x )*dzi;
162  fField[4] = ( B1.y - B0.y )*dzi;
163  fField[7] = ( B1.z - B0.z )*dzi;
164  fField[2] = fField[5] = fField[8] = 0.f;
165  }
166 
167  void SetOneEntry( const float* field, int iEntry=0 )
168  {
173  for(int i=0; i<10; i++)
174  fField[i][iEntry] = field[i];
175  }
176 
177  void SetOneEntry( const int i0, const KFParticleFieldRegion &f1, const int i1 )
178  {
184  for(int i=0; i<10; i++)
185  fField[i][i0] = f1.fField[i][i1];
186  }
187 
197  float_v fField[10];
198 };
199 
200 
201 #endif