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10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /error_propagation/src/G4ErrorSurfaceTrajState.cc (Version 11.3.0) and /error_propagation/src/G4ErrorSurfaceTrajState.cc (Version 11.0)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 //                                                 26 //
 27 // -------------------------------------------     27 // ------------------------------------------------------------
 28 //      GEANT 4 class implementation file          28 //      GEANT 4 class implementation file
 29 // -------------------------------------------     29 // ------------------------------------------------------------
 30 //                                                 30 //
 31                                                    31 
 32 #include "G4ErrorSurfaceTrajState.hh"              32 #include "G4ErrorSurfaceTrajState.hh"
 33 #include "G4ErrorPropagatorData.hh"                33 #include "G4ErrorPropagatorData.hh"
 34                                                    34 
 35 #include "G4PhysicalConstants.hh"                  35 #include "G4PhysicalConstants.hh"
 36 #include "G4SystemOfUnits.hh"                      36 #include "G4SystemOfUnits.hh"
 37 #include "G4Field.hh"                              37 #include "G4Field.hh"
 38 #include "G4FieldManager.hh"                       38 #include "G4FieldManager.hh"
 39 #include "G4TransportationManager.hh"              39 #include "G4TransportationManager.hh"
 40                                                    40 
 41 #include "G4ErrorMatrix.hh"                        41 #include "G4ErrorMatrix.hh"
 42                                                    42 
 43 #include <iomanip>                                 43 #include <iomanip>
 44                                                    44 
 45 //--------------------------------------------     45 //------------------------------------------------------------------------
 46 G4ErrorSurfaceTrajState::G4ErrorSurfaceTrajSta     46 G4ErrorSurfaceTrajState::G4ErrorSurfaceTrajState(
 47   const G4String& partType, const G4Point3D& p     47   const G4String& partType, const G4Point3D& pos, const G4Vector3D& mom,
 48   const G4Vector3D& vecU, const G4Vector3D& ve     48   const G4Vector3D& vecU, const G4Vector3D& vecV, const G4ErrorTrajErr& errmat)
 49   : G4ErrorTrajState(partType, pos, mom, errma     49   : G4ErrorTrajState(partType, pos, mom, errmat)
 50 {                                                  50 {
 51   Init();                                          51   Init();
 52   fTrajParam = G4ErrorSurfaceTrajParam(pos, mo     52   fTrajParam = G4ErrorSurfaceTrajParam(pos, mom, vecU, vecV);
 53 }                                                  53 }
 54                                                    54 
 55 //--------------------------------------------     55 //------------------------------------------------------------------------
 56 G4ErrorSurfaceTrajState::G4ErrorSurfaceTrajSta     56 G4ErrorSurfaceTrajState::G4ErrorSurfaceTrajState(const G4String& partType,
 57                                                    57                                                  const G4Point3D& pos,
 58                                                    58                                                  const G4Vector3D& mom,
 59                                                    59                                                  const G4Plane3D& plane,
 60                                                    60                                                  const G4ErrorTrajErr& errmat)
 61   : G4ErrorTrajState(partType, pos, mom, errma     61   : G4ErrorTrajState(partType, pos, mom, errmat)
 62 {                                                  62 {
 63   Init();                                          63   Init();
 64   fTrajParam = G4ErrorSurfaceTrajParam(pos, mo     64   fTrajParam = G4ErrorSurfaceTrajParam(pos, mom, plane);
 65 }                                                  65 }
 66                                                    66 
 67 //--------------------------------------------     67 //------------------------------------------------------------------------
 68 G4ErrorSurfaceTrajState::G4ErrorSurfaceTrajSta     68 G4ErrorSurfaceTrajState::G4ErrorSurfaceTrajState(G4ErrorFreeTrajState& tpSC,
 69                                                    69                                                  const G4Plane3D& plane)
 70   : G4ErrorTrajState(tpSC.GetParticleType(), t     70   : G4ErrorTrajState(tpSC.GetParticleType(), tpSC.GetPosition(),
 71                      tpSC.GetMomentum())           71                      tpSC.GetMomentum())
 72 {                                                  72 {
 73   //  fParticleType = tpSC.GetParticleType();      73   //  fParticleType = tpSC.GetParticleType();
 74   //  fPosition = tpSC.GetPosition();              74   //  fPosition = tpSC.GetPosition();
 75   //  fMomentum = tpSC.GetMomentum();              75   //  fMomentum = tpSC.GetMomentum();
 76   fTrajParam = G4ErrorSurfaceTrajParam(fPositi     76   fTrajParam = G4ErrorSurfaceTrajParam(fPosition, fMomentum, plane);
 77   Init();                                          77   Init();
 78                                                    78 
 79   //----- Get the error matrix in SC coordinat     79   //----- Get the error matrix in SC coordinates
 80   BuildErrorMatrix(tpSC, GetVectorV(), GetVect     80   BuildErrorMatrix(tpSC, GetVectorV(), GetVectorW());
 81 }                                                  81 }
 82                                                    82 
 83 //--------------------------------------------     83 //------------------------------------------------------------------------
 84 G4ErrorSurfaceTrajState::G4ErrorSurfaceTrajSta     84 G4ErrorSurfaceTrajState::G4ErrorSurfaceTrajState(G4ErrorFreeTrajState& tpSC,
 85                                                    85                                                  const G4Vector3D& vecU,
 86                                                    86                                                  const G4Vector3D& vecV,
 87                                                    87                                                  G4ErrorMatrix& transfM)
 88   : G4ErrorTrajState(tpSC.GetParticleType(), t     88   : G4ErrorTrajState(tpSC.GetParticleType(), tpSC.GetPosition(),
 89                      tpSC.GetMomentum())           89                      tpSC.GetMomentum())
 90 {                                                  90 {
 91   Init();  // needed to define charge sign         91   Init();  // needed to define charge sign
 92   fTrajParam = G4ErrorSurfaceTrajParam(fPositi     92   fTrajParam = G4ErrorSurfaceTrajParam(fPosition, fMomentum, vecU, vecV);
 93   //----- Get the error matrix in SC coordinat     93   //----- Get the error matrix in SC coordinates
 94   transfM = BuildErrorMatrix(tpSC, vecU, vecV)     94   transfM = BuildErrorMatrix(tpSC, vecU, vecV);
 95 }                                                  95 }
 96                                                    96 
 97 //--------------------------------------------     97 //------------------------------------------------------------------------
 98 G4ErrorMatrix G4ErrorSurfaceTrajState::BuildEr     98 G4ErrorMatrix G4ErrorSurfaceTrajState::BuildErrorMatrix(
 99   G4ErrorFreeTrajState& tpSC, const G4Vector3D     99   G4ErrorFreeTrajState& tpSC, const G4Vector3D&, const G4Vector3D&)
100 {                                                 100 {
101   G4double sclambda = tpSC.GetParameters().Get    101   G4double sclambda = tpSC.GetParameters().GetLambda();
102   G4double scphi    = tpSC.GetParameters().Get    102   G4double scphi    = tpSC.GetParameters().GetPhi();
103   if(G4ErrorPropagatorData::GetErrorPropagator    103   if(G4ErrorPropagatorData::GetErrorPropagatorData()->GetMode() ==
104      G4ErrorMode_PropBackwards)                   104      G4ErrorMode_PropBackwards)
105   {                                               105   {
106     sclambda *= -1;                               106     sclambda *= -1;
107     scphi += CLHEP::pi;                           107     scphi += CLHEP::pi;
108   }                                               108   }
109   G4double cosLambda = std::cos(sclambda);        109   G4double cosLambda = std::cos(sclambda);
110   G4double sinLambda = std::sin(sclambda);        110   G4double sinLambda = std::sin(sclambda);
111   G4double sinPhi    = std::sin(scphi);           111   G4double sinPhi    = std::sin(scphi);
112   G4double cosPhi    = std::cos(scphi);           112   G4double cosPhi    = std::cos(scphi);
113                                                   113 
114 #ifdef G4EVERBOSE                                 114 #ifdef G4EVERBOSE
115   if(iverbose >= 4)                               115   if(iverbose >= 4)
116     G4cout << " PM " << fMomentum.mag() << " p    116     G4cout << " PM " << fMomentum.mag() << " pLambda " << sclambda << " pPhi "
117            << scphi << G4endl;                    117            << scphi << G4endl;
118 #endif                                            118 #endif
119                                                   119 
120   G4ThreeVector vTN(cosLambda * cosPhi, cosLam    120   G4ThreeVector vTN(cosLambda * cosPhi, cosLambda * sinPhi, sinLambda);
121   G4ThreeVector vUN(-sinPhi, cosPhi, 0.);         121   G4ThreeVector vUN(-sinPhi, cosPhi, 0.);
122   G4ThreeVector vVN(-vTN.z() * vUN.y(), vTN.z(    122   G4ThreeVector vVN(-vTN.z() * vUN.y(), vTN.z() * vUN.x(), cosLambda);
123                                                   123 
124 #ifdef G4EVERBOSE                                 124 #ifdef G4EVERBOSE
125   if(iverbose >= 4)                               125   if(iverbose >= 4)
126     G4cout << " SC2SD: vTN " << vTN << " vUN "    126     G4cout << " SC2SD: vTN " << vTN << " vUN " << vUN << " vVN " << vVN
127            << G4endl;                             127            << G4endl;
128 #endif                                            128 #endif
129   G4double UJ = vUN * GetVectorV();               129   G4double UJ = vUN * GetVectorV();
130   G4double UK = vUN * GetVectorW();               130   G4double UK = vUN * GetVectorW();
131   G4double VJ = vVN * GetVectorV();               131   G4double VJ = vVN * GetVectorV();
132   G4double VK = vVN * GetVectorW();               132   G4double VK = vVN * GetVectorW();
133                                                   133 
134   //--- Get transformation first                  134   //--- Get transformation first
135   G4ErrorMatrix transfM(5, 5, 0);                 135   G4ErrorMatrix transfM(5, 5, 0);
136   //--- Get magnetic field                        136   //--- Get magnetic field
137   const G4Field* field = G4TransportationManag    137   const G4Field* field = G4TransportationManager::GetTransportationManager()
138                            ->GetFieldManager()    138                            ->GetFieldManager()
139                            ->GetDetectorField(    139                            ->GetDetectorField();
140                                                   140 
141   G4Vector3D vectorU = GetVectorV().cross(GetV    141   G4Vector3D vectorU = GetVectorV().cross(GetVectorW());
142   G4double T1R       = 1. / (vTN * vectorU);      142   G4double T1R       = 1. / (vTN * vectorU);
143                                                   143 
144 #ifdef G4EVERBOSE                                 144 #ifdef G4EVERBOSE
145   if(iverbose >= 4)                               145   if(iverbose >= 4)
146     G4cout << "surf vectors:U,V,W " << vectorU    146     G4cout << "surf vectors:U,V,W " << vectorU << " " << GetVectorV() << " "
147            << GetVectorW() << "  T1R:" << T1R     147            << GetVectorW() << "  T1R:" << T1R << G4endl;
148 #endif                                            148 #endif
149                                                   149 
150   if(fCharge != 0 && field)                       150   if(fCharge != 0 && field)
151   {                                               151   {
152     G4double pos[3];                              152     G4double pos[3];
153     pos[0] = fPosition.x() * cm;                  153     pos[0] = fPosition.x() * cm;
154     pos[1] = fPosition.y() * cm;                  154     pos[1] = fPosition.y() * cm;
155     pos[2] = fPosition.z() * cm;                  155     pos[2] = fPosition.z() * cm;
156     G4double Hd[3];                               156     G4double Hd[3];
157     field->GetFieldValue(pos, Hd);                157     field->GetFieldValue(pos, Hd);
158     G4ThreeVector H =                             158     G4ThreeVector H =
159       G4ThreeVector(Hd[0], Hd[1], Hd[2]) / tes    159       G4ThreeVector(Hd[0], Hd[1], Hd[2]) / tesla * 10.;  // in kilogauus
160     G4double magH  = H.mag();                     160     G4double magH  = H.mag();
161     G4double invP  = 1. / (fMomentum.mag() / G    161     G4double invP  = 1. / (fMomentum.mag() / GeV);
162     G4double magHM = magH * invP;                 162     G4double magHM = magH * invP;
163     if(magH != 0.)                                163     if(magH != 0.)
164     {                                             164     {
165       G4double magHM2 = fCharge / magH;           165       G4double magHM2 = fCharge / magH;
166       G4double Q      = -magHM * c_light / (km    166       G4double Q      = -magHM * c_light / (km / ns);
167 #ifdef G4EVERBOSE                                 167 #ifdef G4EVERBOSE
168       if(iverbose >= 4)                           168       if(iverbose >= 4)
169         G4cout << GeV << " Q " << Q << " magHM    169         G4cout << GeV << " Q " << Q << " magHM " << magHM << " c_light/(km/ns) "
170                << c_light / (km / ns) << G4end    170                << c_light / (km / ns) << G4endl;
171 #endif                                            171 #endif
172                                                   172 
173       G4double sinz = -H * vUN * magHM2;          173       G4double sinz = -H * vUN * magHM2;
174       G4double cosz = H * vVN * magHM2;           174       G4double cosz = H * vVN * magHM2;
175       G4double T3R  = Q * std::pow(T1R, 3);       175       G4double T3R  = Q * std::pow(T1R, 3);
176       G4double UI   = vUN * vectorU;              176       G4double UI   = vUN * vectorU;
177       G4double VI   = vVN * vectorU;              177       G4double VI   = vVN * vectorU;
178 #ifdef G4EVERBOSE                                 178 #ifdef G4EVERBOSE
179       if(iverbose >= 4)                           179       if(iverbose >= 4)
180       {                                           180       {
181         G4cout << " T1R " << T1R << " T3R " <<    181         G4cout << " T1R " << T1R << " T3R " << T3R << G4endl;
182         G4cout << " UI " << UI << " VI " << VI    182         G4cout << " UI " << UI << " VI " << VI << " vectorU " << vectorU
183                << G4endl;                         183                << G4endl;
184         G4cout << " UJ " << UJ << " VJ " << VJ    184         G4cout << " UJ " << UJ << " VJ " << VJ << G4endl;
185         G4cout << " UK " << UK << " VK " << VK    185         G4cout << " UK " << UK << " VK " << VK << G4endl;
186       }                                           186       }
187 #endif                                            187 #endif
188                                                   188 
189       transfM[1][3] = -UI * (VK * cosz - UK *     189       transfM[1][3] = -UI * (VK * cosz - UK * sinz) * T3R;
190       transfM[1][4] = -VI * (VK * cosz - UK *     190       transfM[1][4] = -VI * (VK * cosz - UK * sinz) * T3R;
191       transfM[2][3] = UI * (VJ * cosz - UJ * s    191       transfM[2][3] = UI * (VJ * cosz - UJ * sinz) * T3R;
192       transfM[2][4] = VI * (VJ * cosz - UJ * s    192       transfM[2][4] = VI * (VJ * cosz - UJ * sinz) * T3R;
193     }                                             193     }
194   }                                               194   }
195                                                   195 
196   G4double T2R  = T1R * T1R;                      196   G4double T2R  = T1R * T1R;
197   transfM[0][0] = 1.;                             197   transfM[0][0] = 1.;
198   transfM[1][1] = -UK * T2R;                      198   transfM[1][1] = -UK * T2R;
199   transfM[1][2] = VK * cosLambda * T2R;           199   transfM[1][2] = VK * cosLambda * T2R;
200   transfM[2][1] = UJ * T2R;                       200   transfM[2][1] = UJ * T2R;
201   transfM[2][2] = -VJ * cosLambda * T2R;          201   transfM[2][2] = -VJ * cosLambda * T2R;
202   transfM[3][3] = VK * T1R;                       202   transfM[3][3] = VK * T1R;
203   transfM[3][4] = -UK * T1R;                      203   transfM[3][4] = -UK * T1R;
204   transfM[4][3] = -VJ * T1R;                      204   transfM[4][3] = -VJ * T1R;
205   transfM[4][4] = UJ * T1R;                       205   transfM[4][4] = UJ * T1R;
206                                                   206 
207 #ifdef G4EVERBOSE                                 207 #ifdef G4EVERBOSE
208   if(iverbose >= 4)                               208   if(iverbose >= 4)
209     G4cout << " SC2SD transf matrix A= " << tr    209     G4cout << " SC2SD transf matrix A= " << transfM << G4endl;
210 #endif                                            210 #endif
211   fError = G4ErrorTrajErr(tpSC.GetError().simi    211   fError = G4ErrorTrajErr(tpSC.GetError().similarity(transfM));
212                                                   212 
213 #ifdef G4EVERBOSE                                 213 #ifdef G4EVERBOSE
214   if(iverbose >= 1)                               214   if(iverbose >= 1)
215     G4cout << "G4EP: error matrix SC2SD " << f    215     G4cout << "G4EP: error matrix SC2SD " << fError << G4endl;
216   if(iverbose >= 4)                               216   if(iverbose >= 4)
217     G4cout << "G4ErrorSurfaceTrajState from SC    217     G4cout << "G4ErrorSurfaceTrajState from SC " << *this << G4endl;
218 #endif                                            218 #endif
219                                                   219 
220   return transfM;  // want to use trasnfM for     220   return transfM;  // want to use trasnfM for the reverse transform
221 }                                                 221 }
222                                                   222 
223 //--------------------------------------------    223 //------------------------------------------------------------------------
224 void G4ErrorSurfaceTrajState::Init()              224 void G4ErrorSurfaceTrajState::Init()
225 {                                                 225 {
226   theTSType = G4eTS_OS;                           226   theTSType = G4eTS_OS;
227   BuildCharge();                                  227   BuildCharge();
228 }                                                 228 }
229                                                   229 
230 //--------------------------------------------    230 //------------------------------------------------------------------------
231 void G4ErrorSurfaceTrajState::Dump(std::ostrea    231 void G4ErrorSurfaceTrajState::Dump(std::ostream& out) const { out << *this; }
232                                                   232 
233 //--------------------------------------------    233 //------------------------------------------------------------------------
234 std::ostream& operator<<(std::ostream& out, co    234 std::ostream& operator<<(std::ostream& out, const G4ErrorSurfaceTrajState& ts)
235 {                                                 235 {
236   std::ios::fmtflags oldFlags = out.flags();      236   std::ios::fmtflags oldFlags = out.flags();
237   out.setf(std::ios::fixed, std::ios::floatfie    237   out.setf(std::ios::fixed, std::ios::floatfield);
238                                                   238 
239   ts.DumpPosMomError(out);                        239   ts.DumpPosMomError(out);
240                                                   240 
241   out << " G4ErrorSurfaceTrajState: Params: "     241   out << " G4ErrorSurfaceTrajState: Params: " << ts.fTrajParam << G4endl;
242   out.flags(oldFlags);                            242   out.flags(oldFlags);
243   return out;                                     243   return out;
244 }                                                 244 }
245                                                   245