Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-14 08:54:58

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