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 ] [ 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 /geometry/magneticfield/src/G4DriverReporter.cc (Version 11.3.0) and /geometry/magneticfield/src/G4DriverReporter.cc (Version 11.2.2)


  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 // G4DriverReporter                                26 // G4DriverReporter
 27 //                                                 27 //
 28 // Implementation                                  28 // Implementation
 29 //                                                 29 //
 30 //                                                 30 //
 31 // Authors: J.Apostolakis        -   January/M     31 // Authors: J.Apostolakis        -   January/March 2020
 32 // -------------------------------------------     32 // -------------------------------------------------------------------
 33                                                    33 
 34 #include "G4DriverReporter.hh"                     34 #include "G4DriverReporter.hh"
 35                                                    35 
 36 // -------------------------------------------     36 // ---------------------------------------------------------------------------
 37                                                    37 
 38 void G4DriverReporter::PrintStatus( const G4do     38 void G4DriverReporter::PrintStatus( const G4double* StartArr,  
 39                                           G4do     39                                           G4double  xstart,
 40                                     const G4do     40                                     const G4double* CurrentArr, 
 41                                           G4do     41                                           G4double  xcurrent,
 42                                           G4do     42                                           G4double  requestStep, 
 43                                     unsigned i     43                                     unsigned int    subStepNo,
 44                                     unsigned i     44                                     unsigned int    noIntegrationVariables
 45    )                                               45    )
 46   // Potentially add as arguments:                 46   // Potentially add as arguments:  
 47   //                                 <dydx>        47   //                                 <dydx>           - as Initial Force
 48   //                                 stepTaken     48   //                                 stepTaken(hdid)  - last step taken
 49   //                                 nextStep      49   //                                 nextStep (hnext) - proposal for size
 50 {                                                  50 {
 51    G4FieldTrack  StartFT(G4ThreeVector(0,0,0),     51    G4FieldTrack  StartFT(G4ThreeVector(0,0,0),
 52                  G4ThreeVector(0,0,0), 0., 0.,     52                  G4ThreeVector(0,0,0), 0., 0., 0., 0. );
 53    G4FieldTrack  CurrentFT (StartFT);              53    G4FieldTrack  CurrentFT (StartFT);
 54                                                    54 
 55    StartFT.LoadFromArray( StartArr, noIntegrat     55    StartFT.LoadFromArray( StartArr, noIntegrationVariables); 
 56    StartFT.SetCurveLength( xstart);                56    StartFT.SetCurveLength( xstart);
 57    CurrentFT.LoadFromArray( CurrentArr, noInte     57    CurrentFT.LoadFromArray( CurrentArr, noIntegrationVariables); 
 58    CurrentFT.SetCurveLength( xcurrent );           58    CurrentFT.SetCurveLength( xcurrent );
 59                                                    59 
 60    PrintStatus(StartFT, CurrentFT, requestStep     60    PrintStatus(StartFT, CurrentFT, requestStep, subStepNo ); 
 61 }                                                  61 }
 62                                                    62 
 63 // -------------------------------------------     63 // ---------------------------------------------------------------------------
 64 const G4int noPrecision = 8;                       64 const G4int noPrecision = 8;
 65 const G4int prec7= noPrecision+2;                  65 const G4int prec7= noPrecision+2;
 66 const G4int prec8= noPrecision+3;                  66 const G4int prec8= noPrecision+3;    
 67 const G4int prec9= noPrecision+4;                  67 const G4int prec9= noPrecision+4;
 68                                                    68 
 69 void G4DriverReporter::PrintStatus(const G4Fie     69 void G4DriverReporter::PrintStatus(const G4FieldTrack& StartFT,
 70                                    const G4Fie     70                                    const G4FieldTrack& CurrentFT, 
 71                                          G4dou     71                                          G4double      requestStep, 
 72                                    unsigned in     72                                    unsigned int        subStepNo)
 73 {                                                  73 {
 74     G4int verboseLevel= 2; // fVerboseLevel;       74     G4int verboseLevel= 2; // fVerboseLevel;
 75     G4long oldPrec= G4cout.precision(noPrecisi     75     G4long oldPrec= G4cout.precision(noPrecision);
 76     // G4cout.setf(ios_base::fixed,ios_base::f     76     // G4cout.setf(ios_base::fixed,ios_base::floatfield);
 77                                                    77         
 78     const G4ThreeVector StartPosition=       S     78     const G4ThreeVector StartPosition=       StartFT.GetPosition();
 79     const G4ThreeVector StartUnitVelocity=   S     79     const G4ThreeVector StartUnitVelocity=   StartFT.GetMomentumDir();
 80     const G4ThreeVector CurrentPosition=     C     80     const G4ThreeVector CurrentPosition=     CurrentFT.GetPosition();
 81     const G4ThreeVector CurrentUnitVelocity= C     81     const G4ThreeVector CurrentUnitVelocity= CurrentFT.GetMomentumDir();
 82                                                    82 
 83     G4double  DotStartCurrentVeloc= StartUnitV     83     G4double  DotStartCurrentVeloc= StartUnitVelocity.dot(CurrentUnitVelocity);
 84                                                    84 
 85     G4double step_len= CurrentFT.GetCurveLengt     85     G4double step_len= CurrentFT.GetCurveLength() - StartFT.GetCurveLength();
 86     G4double subStepSize = step_len;               86     G4double subStepSize = step_len;
 87                                                    87      
 88     if( (subStepNo <= 1) || (verboseLevel > 3)     88     if( (subStepNo <= 1) || (verboseLevel > 3) )
 89     {                                              89     {
 90        subStepNo = - subStepNo;        // To a     90        subStepNo = - subStepNo;        // To allow printing banner
 91                                                    91 
 92        G4cout << "----------------------------     92        G4cout << "------------------------------------------------------------------"
 93               << G4endl;                           93               << G4endl;
 94        G4cout << std::setw( 6)  << " " << std:     94        G4cout << std::setw( 6)  << " " << std::setw( 25)
 95               << " G4DriverReporter: Current P     95               << " G4DriverReporter: Current Position  and  Direction" << " "
 96               << G4endl;                           96               << G4endl; 
 97        G4cout << std::setw( 5) << "Step#" << "     97        G4cout << std::setw( 5) << "Step#" << " "
 98               << std::setw( prec7) << "s-curve     98               << std::setw( prec7) << "s-curve" << " "
 99               << std::setw( prec9) << "X(mm)"      99               << std::setw( prec9) << "X(mm)" << " "
100               << std::setw( prec9) << "Y(mm)"     100               << std::setw( prec9) << "Y(mm)" << " "  
101               << std::setw( prec9) << "Z(mm)"     101               << std::setw( prec9) << "Z(mm)" << " "
102               << std::setw( prec8) << " N_x "     102               << std::setw( prec8) << " N_x " << " "
103               << std::setw( prec8) << " N_y "     103               << std::setw( prec8) << " N_y " << " "
104               << std::setw( prec8) << " N_z "     104               << std::setw( prec8) << " N_z " << " "
105               << std::setw( 6) << " N^2-1 " <<    105               << std::setw( 6) << " N^2-1 " << " "
106               << std::setw(10) << " N(0).N " <    106               << std::setw(10) << " N(0).N " << " "
107               << std::setw( 7) << "KinEner " <    107               << std::setw( 7) << "KinEner " << " "
108               << std::setw(12) << "Track-l" <<    108               << std::setw(12) << "Track-l" << " "   // Add the Sub-step ??
109               << std::setw(12) << "Step-len" <    109               << std::setw(12) << "Step-len" << " " 
110               << std::setw(12) << "Step-len" <    110               << std::setw(12) << "Step-len" << " " 
111               << std::setw( 9) << "ReqStep" <<    111               << std::setw( 9) << "ReqStep" << " "  
112               << G4endl;                          112               << G4endl;
113     }                                             113     }
114                                                   114 
115     G4cout.precision(noPrecision);                115     G4cout.precision(noPrecision);
116                                                   116     
117     if( (subStepNo <= 0) )                        117     if( (subStepNo <= 0) )
118     {                                             118     {
119       PrintStat_Aux( StartFT,  requestStep, 0.    119       PrintStat_Aux( StartFT,  requestStep, 0., 
120                        0,        0.0,             120                        0,        0.0,         1.0);
121     }                                             121     }
122                                                   122 
123     // if( verboseLevel <= 3 )                    123     // if( verboseLevel <= 3 )
124     {                                             124     {
125       G4cout.precision(noPrecision);              125       G4cout.precision(noPrecision);
126       PrintStat_Aux( CurrentFT, requestStep, s    126       PrintStat_Aux( CurrentFT, requestStep, step_len, 
127                      subStepNo, subStepSize, D    127                      subStepNo, subStepSize, DotStartCurrentVeloc );
128     }                                             128     }
129     G4cout << "-------------------------------    129     G4cout << "------------------------------------------------------------------"
130            << G4endl;                             130            << G4endl;
131     G4cout.precision(oldPrec);                    131     G4cout.precision(oldPrec);
132 }                                                 132 }
133                                                   133 
134 // -------------------------------------------    134 // ---------------------------------------------------------------------------
135                                                   135 
136 void G4DriverReporter::PrintStat_Aux(const G4F    136 void G4DriverReporter::PrintStat_Aux(const G4FieldTrack& aFieldTrack,
137                                           G4do    137                                           G4double      requestStep, 
138                                           G4do    138                                           G4double      step_len,
139                                           G4in    139                                           G4int         subStepNo,
140                                           G4do    140                                           G4double      subStepSize,
141                                           G4do    141                                           G4double      dotVeloc_StartCurr)
142 {                                                 142 {
143     const G4ThreeVector Position = aFieldTrack    143     const G4ThreeVector Position = aFieldTrack.GetPosition();
144     const G4ThreeVector UnitVelocity = aFieldT    144     const G4ThreeVector UnitVelocity = aFieldTrack.GetMomentumDir();
145                                                   145 
146     G4long oldprec= G4cout.precision(noPrecisi    146     G4long oldprec= G4cout.precision(noPrecision);
147                                                   147     
148     if( subStepNo >= 0)                           148     if( subStepNo >= 0)
149     {                                             149     {
150        G4cout << std::setw( 5) << subStepNo <<    150        G4cout << std::setw( 5) << subStepNo << " ";
151     }                                             151     }
152     else                                          152     else
153     {                                             153     {
154        G4cout << std::setw( 5) << "Start" << "    154        G4cout << std::setw( 5) << "Start" << " ";
155     }                                             155     }
156     G4double curveLen= aFieldTrack.GetCurveLen    156     G4double curveLen= aFieldTrack.GetCurveLength();
157     G4cout << std::setw( 7) << curveLen;          157     G4cout << std::setw( 7) << curveLen;
158     // G4cout.precision(noPrecision);             158     // G4cout.precision(noPrecision);
159     G4cout << std::setw( prec9) << Position.x(    159     G4cout << std::setw( prec9) << Position.x() << " "
160            << std::setw( prec9) << Position.y(    160            << std::setw( prec9) << Position.y() << " "
161            << std::setw( prec9) << Position.z(    161            << std::setw( prec9) << Position.z() << " "
162            << std::setw( prec8) << UnitVelocit    162            << std::setw( prec8) << UnitVelocity.x() << " "
163            << std::setw( prec8) << UnitVelocit    163            << std::setw( prec8) << UnitVelocity.y() << " "
164            << std::setw( prec8) << UnitVelocit    164            << std::setw( prec8) << UnitVelocity.z() << " ";
165     G4cout.precision(3);                          165     G4cout.precision(3);
166     G4double unitMagDif = UnitVelocity.mag2()-    166     G4double unitMagDif = UnitVelocity.mag2()-1.0;
167     if( std::fabs( unitMagDif ) < 1.0e-15 ) {     167     if( std::fabs( unitMagDif ) < 1.0e-15 ) { unitMagDif = 0.0; }        
168     G4cout << std::setw( 8) << unitMagDif << "    168     G4cout << std::setw( 8) << unitMagDif << " ";
169     G4cout.precision(6);                          169     G4cout.precision(6);
170     G4cout << std::setw(10) << dotVeloc_StartC    170     G4cout << std::setw(10) << dotVeloc_StartCurr << " ";
171     G4cout.precision(oldprec);                    171     G4cout.precision(oldprec);
172     G4cout << std::setw( prec7) << aFieldTrack    172     G4cout << std::setw( prec7) << aFieldTrack.GetKineticEnergy();
173     G4cout << std::setw(12) << step_len << " "    173     G4cout << std::setw(12) << step_len << " ";
174                                                   174 
175     static G4ThreadLocal G4double oldCurveLeng    175     static G4ThreadLocal G4double oldCurveLength = 0.0;
176     static G4ThreadLocal G4double oldSubStepLe    176     static G4ThreadLocal G4double oldSubStepLength = 0.0;
177     static G4ThreadLocal G4int oldSubStepNo =     177     static G4ThreadLocal G4int oldSubStepNo = -1;
178                                                   178 
179     G4double subStep_len = 0.0;                   179     G4double subStep_len = 0.0;
180     if( curveLen > oldCurveLength )               180     if( curveLen > oldCurveLength )
181     {                                             181     {
182       subStep_len= curveLen - oldCurveLength;     182       subStep_len= curveLen - oldCurveLength;
183     }                                             183     }
184     else if (subStepNo == oldSubStepNo)           184     else if (subStepNo == oldSubStepNo)
185     {                                             185     {
186       subStep_len= oldSubStepLength;              186       subStep_len= oldSubStepLength;
187     }                                             187     }
188     oldCurveLength= curveLen;                     188     oldCurveLength= curveLen;
189     oldSubStepLength= subStep_len;                189     oldSubStepLength= subStep_len;
190                                                   190 
191     G4cout << std::setw(12) << subStep_len <<     191     G4cout << std::setw(12) << subStep_len << " "; 
192     G4cout << std::setw(12) << subStepSize <<     192     G4cout << std::setw(12) << subStepSize << " "; 
193     if( requestStep != -1.0 )                     193     if( requestStep != -1.0 )
194     {                                             194     {
195       G4cout << std::setw( prec9) << requestSt    195       G4cout << std::setw( prec9) << requestStep << " ";
196     }                                             196     }
197     else                                          197     else
198     {                                             198     {
199        G4cout << std::setw( prec9) << " Initia    199        G4cout << std::setw( prec9) << " InitialStep " << " ";
200     }                                             200     }
201     G4cout << G4endl;                             201     G4cout << G4endl;
202 }                                                 202 }
203                                                   203