Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-03 09:14:23

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 // Qss_misc
0027 //
0028 // Auxiliary namespace for QSS data.
0029 //
0030 // Authors: Lucio Santi, Rodrigo Castro (Univ. Buenos Aires), 2018-2021 
0031 // --------------------------------------------------------------------
0032 #ifndef _QSS_MISC_H_
0033 #define _QSS_MISC_H_ 1
0034 
0035 #include "G4Types.hh"
0036 
0037 using QSS_simulator = struct QSS_simulator_*;
0038 using QSSSubstep = struct QSSSubstep_*;
0039 
0040 /**
0041  * @brief Qss_misc defines an auxiliary namespace for QSS drivers data.
0042  */
0043 
0044 namespace Qss_misc
0045 { 
0046   // Convention of Geant4 notation of indices
0047   constexpr unsigned int PXidx= 0;
0048   constexpr unsigned int PYidx= 1;
0049   constexpr unsigned int PZidx= 2;
0050 
0051   constexpr unsigned int VXidx= 3;
0052   constexpr unsigned int VYidx= 4;
0053   constexpr unsigned int VZidx= 5;
0054 
0055   // Method parameters & constants
0056   constexpr unsigned int MAX_QSS_STEPPER_ORDER= 3;
0057   constexpr unsigned int VAR_IDX_END= 6;
0058   constexpr unsigned int MIN_SUBSTEPS= 20;
0059 
0060   constexpr G4double INF= 1.0e20;
0061 }
0062 
0063 #if defined(WIN32) || defined(__MINGW32__)
0064 #define unlikely(x)   (x)  // Until C++20 can be assumed
0065 #define   likely(x)   (x)  //    >> ditto >>
0066 #else
0067 #define unlikely(x)   __builtin_expect((x),0)   // gcc/clang extension - not portable
0068 #define   likely(x)   __builtin_expect((x),1)
0069 #endif
0070 
0071 // #define likely(x)   (x)  // [[likely]]     // The C++20 portable way
0072 // #define likely(x)   (x)  // [[unlikely]]   //     >>    >> 
0073 // This syntax appears to be part of C++20
0074 // See
0075 // - https://en.cppreference.com/w/cpp/language/attributes/likely
0076 // - https://stackoverflow.com/questions/51797959/how-to-use-c20s-likely-unlikely-attribute-in-if-else-statement
0077 // - https://usingstdcpp.org/2018/03/18/jacksonville18-iso-cpp-report/
0078 
0079 #define SUBSTEP_STRUCT(sim, i)     (sim->substeps[i])
0080 #define SUBSTEP_START(sim, i)      (sim->substeps[(i)].start_time)
0081 #define SUBSTEP_X(sim, i)          (sim->substeps[(i)].x)
0082 #define SUBSTEP_TX(sim, i)         (sim->substeps[(i)].tx)
0083 #define SUBSTEP_LEN(sim, i)        (sim->substeps[(i)].len)
0084 
0085 #define LAST_SUBSTEP_STRUCT(sim)     (SUBSTEP_STRUCT(sim, sim->cur_substep_idx-1))
0086 
0087 #define CUR_SUBSTEP_START(sim)      (SUBSTEP_START(sim, sim->cur_substep_idx))
0088 #define CUR_SUBSTEP_X(sim)          (SUBSTEP_X(sim, sim->cur_substep_idx))
0089 #define CUR_SUBSTEP_TX(sim)         (SUBSTEP_TX(sim, sim->cur_substep_idx))
0090 #define CUR_SUBSTEP_LEN(sim)        (SUBSTEP_LEN(sim, sim->cur_substep_idx))
0091 
0092 #define CUR_SUBSTEP(sim)            (sim->cur_substep_idx)
0093 #define LAST_SUBSTEP(sim)           (sim->cur_substep_idx-1)
0094 #define MAX_SUBSTEP(sim)            (sim->max_substep_idx)
0095 #define SUBSTEPS(sim)               (sim->substeps)
0096 
0097 struct QSSSubstep_
0098 {
0099   G4double x[Qss_misc::VAR_IDX_END*(Qss_misc::MAX_QSS_STEPPER_ORDER+1)];
0100   G4double tx[Qss_misc::VAR_IDX_END];
0101 
0102   G4double start_time;
0103   G4double len;
0104 };
0105 
0106 struct QSS_simulator_
0107 {
0108   G4double x[Qss_misc::VAR_IDX_END*(Qss_misc::MAX_QSS_STEPPER_ORDER+1)];
0109   G4double tx[Qss_misc::VAR_IDX_END];
0110 
0111   G4double q[Qss_misc::VAR_IDX_END*(Qss_misc::MAX_QSS_STEPPER_ORDER+1)];
0112   G4double tq[Qss_misc::VAR_IDX_END];
0113 
0114   G4double nextStateTime[Qss_misc::VAR_IDX_END];
0115   G4double time;
0116   G4int minIndex;
0117 
0118   G4double dQMin[Qss_misc::VAR_IDX_END];
0119   G4double dQRel[Qss_misc::VAR_IDX_END];
0120   G4double lqu[Qss_misc::VAR_IDX_END];
0121 
0122   G4double alg[Qss_misc::VAR_IDX_END];
0123   G4double it;
0124 
0125   G4int *SD[Qss_misc::VAR_IDX_END];
0126   G4int states;
0127 
0128   QSSSubstep substeps;
0129   G4int cur_substep_idx;
0130   G4int max_substep_idx;
0131 };
0132 
0133 #endif