Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/Geant4/G4QSSDriver.icc was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // --------------------------------------------------------------------
0027 
0028 template <class T>
0029 G4QSSDriver<T>::G4QSSDriver(T* pStepper) : G4InterpolationDriver<T, true>(0, pStepper)
0030 {
0031   // TODO: Remove additional stepper instances - should be a separate Driver class
0032   this->fSteppers.resize(1);
0033 }
0034 
0035 template <class T>
0036 void G4QSSDriver<T>::OnStartTracking()
0037 {
0038   Base::OnStartTracking();
0039   if (! initializedOnFirstRun) {
0040     // this->SetPrecision( G4QSSMessenger::instance()->dQRel, G4QSSMessenger::instance()->dQMin);
0041 
0042     G4double dqRel = G4QSSMessenger::instance()->dQRel;
0043     G4double dQMin = G4QSSMessenger::instance()->dQMin;
0044     if (dqRel == 0) {
0045       dqRel = 0.001;
0046     }
0047     if (dQMin == 0) {
0048       dQMin = 0.0001;
0049     }
0050     this->SetPrecision(dqRel, dQMin);
0051 
0052     initializedOnFirstRun = true;
0053   }
0054 }
0055 
0056 template <class T>
0057 void G4QSSDriver<T>::SetPrecision(G4double dq_rel, G4double dq_min)
0058 {
0059   G4cout << "Setting QSS precision parameters: "
0060          << "dQRel = " << dq_rel << " - "
0061          << "dQMin = " << dq_min << G4endl;
0062 
0063   for (const auto& item : this->fSteppers) {
0064     item.stepper->SetPrecision(dq_rel, dq_min);
0065   }
0066 }
0067 
0068 template <class T>
0069 G4double G4QSSDriver<T>::AdvanceChordLimited(
0070   G4FieldTrack& track, G4double hstep, G4double epsStep, G4double chordDistance)
0071 {
0072   // For now, just extract functionality that we don't use from G4InterpolationDriver
0073   // We should probably end up making  a custom G4QSSDriver separated from it
0074   ++this->fTotalStepsForTrack;
0075   this->fLastStepper = this->fSteppers.begin();
0076 
0077   const G4double preCurveLength = track.GetCurveLength();
0078   G4double postCurveLength = preCurveLength;
0079   auto it = this->fSteppers.begin();
0080 
0081   it->stepper->reset(const_cast<const G4FieldTrack*>(&track));
0082 
0083   field_utils::State yBegin, y;
0084   track.DumpToArray(yBegin);
0085   track.DumpToArray(y);
0086 
0087   G4double hdid = OneGoodStep(it, y, this->fdydx, hstep, epsStep, preCurveLength, &track);
0088   postCurveLength += hdid;
0089 
0090   G4double dChordStep = this->DistChord(yBegin, preCurveLength, y, postCurveLength);
0091 
0092   // update chord step estimate
0093   hdid = this->FindNextChord(
0094     yBegin, preCurveLength, y, postCurveLength, dChordStep, chordDistance);
0095 
0096   track.LoadFromArray(y, this->fSteppers[0].stepper->GetNumberOfVariables());
0097   track.SetCurveLength(preCurveLength + hdid);
0098 
0099   return hdid;
0100 }
0101 
0102 template <class T>
0103 G4double G4QSSDriver<T>::OneGoodStep(typename G4InterpolationDriver<T, true>::StepperIterator it,
0104   field_utils::State& y, field_utils::State& dydx, G4double& hstep, G4double /*epsStep*/,
0105   G4double curveLength, G4FieldTrack* /*track*/)
0106 {
0107   G4double yerr[G4FieldTrack::ncompSVEC], ytemp[G4FieldTrack::ncompSVEC];
0108   it->stepper->Stepper(y, dydx, hstep, ytemp, yerr);
0109   G4double h = it->stepper->GetLastStepLength();
0110 
0111   // set interpolation interval
0112   it->begin = curveLength;
0113   it->end = curveLength + h;
0114   it->inverseLength = 1. / h;
0115 
0116   field_utils::copy(y, ytemp);
0117 
0118   return h;
0119 }