Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:01

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