Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-10 07:50:30

0001 #pragma once
0002 /**
0003 U4.hh
0004 ======
0005 
0006 Genstep Collection
0007 --------------------
0008 
0009 Genstep collection within  Geant4 Scintillation+Cerenkov processes 
0010 is central to Opticks operation, as the gensteps are the parameters 
0011 that allow photons to be generated on GPU.  
0012 
0013 Optical Photon Labelling
0014 ----------------------------
0015 
0016 In pure Opticks running (junosw/opticksMode:1) there is no Geant4 generation loop, 
0017 only in validation running (junosw/opticksMode:3) where both CPU and GPU propagations are done 
0018 and instrumented Geant4 running (junosw/opticksMode:2) 
0019 does generation loop monitoring become relevant and useful. 
0020 Geant4 generation loop photon labelling is done using the API::
0021 
0022    U4::GenPhotonAncestor
0023    U4::GenPhotonBegin
0024    U4::GenPhotonEnd
0025 
0026 With Geant4 generation loop monitoring every optical photon G4Track gets an spho.h label that 
0027 is stored using G4VUserTrackInformation, via U4PhotonInfo. 
0028 The label identifies exactly the originating photon and genstep 
0029 and how many reemission generations have been undergone. 
0030 
0031 Note about opticksMode
0032 -------------------------
0033 
0034 There is no Opticks API accepting an opticksMode argument, 
0035 nevetheless integrations of Opticks with detector simulation 
0036 frameworks will often find it useful to implement an opticksMode
0037 in order to assist with controlling Opticks and comparing 
0038 it with Geant4.  
0039 
0040 Photon labels
0041 ---------------
0042 
0043 TODO: check junosw/opticksMode:1 running, are the labels provided ?
0044  
0045 Example of labels with {gs,ix,id,gx} ::
0046 
0047    In [1]: f30h
0048     Out[1]: 
0049     array([[  0,  15,  15,   0],
0050            [  1,  22,  56,   2],
0051            [  1,  10,  44,   1],
0052            [  1,   8,  42,   1],
0053            [  1,   3,  37,   0],
0054            [  1,   2,  36,   1],
0055            [  2,   3,  60,   2],
0056            [  3,  41, 102,   1],
0057            [  3,  36,  97,   2],
0058            [  3,  29,  90,   1],
0059            [  3,  19,  80,   1],
0060            [  4,  26, 157,   4],
0061            [  5,   7, 174,   1],
0062            [  6,   2, 195,   1]], dtype=int32)
0063 
0064 spho.h::
0065                 
0066     struct spho
0067     {
0068         int gs ; // 0-based genstep index within the event
0069         int ix ; // 0-based photon index within the genstep
0070         int id ; // 0-based photon identity index within the event 
0071         int gn ; // 0-based reemission index incremented at each reemission 
0072     ...
0073     };
0074 
0075 
0076 Implementation Notes
0077 -------------------------
0078 
0079 Note that Opticks types are mostly kept out of this header in order to simplify 
0080 usage from detector framework code.  For example this is done by:
0081 
0082 1. using private methods that create the Opticks types
0083 2. retaining pointers to results in standard places elsewhere, mostly in SEvt, 
0084    rather than directly returning them. 
0085 
0086 **/
0087 
0088 #include "plog/Severity.h"
0089 
0090 struct NP ; 
0091 class G4VParticleChange ; 
0092 class G4Track ; 
0093 class G4Step ; 
0094 
0095 #include "G4Types.hh"
0096 #include "U4_API_EXPORT.hh"
0097 
0098 struct U4_API U4
0099 {
0100     static const plog::Severity LEVEL ;
0101 
0102     // genstep collection
0103     static const char* CollectGenstep_DsG4Scintillation_r4695_DISABLE ; 
0104     static const char* CollectGenstep_DsG4Scintillation_r4695_ZEROPHO ; 
0105     static void CollectGenstep_DsG4Scintillation_r4695( 
0106          const G4Track* aTrack,
0107          const G4Step* aStep,
0108          G4int    numPhotons,
0109          G4int    scnt,        
0110          G4double ScintillationTime
0111     ); 
0112 
0113     static const char* CollectGenstep_G4Cerenkov_modified_DISABLE ; 
0114     static const char* CollectGenstep_G4Cerenkov_modified_ZEROPHO ; 
0115     static void CollectGenstep_G4Cerenkov_modified( 
0116         const G4Track* aTrack,
0117         const G4Step* aStep,
0118         G4int    numPhotons,
0119         G4double    betaInverse,
0120         G4double    pmin,
0121         G4double    pmax,
0122         G4double    maxCos,
0123         G4double    maxSin2,
0124         G4double    meanNumberOfPhotons1,
0125         G4double    meanNumberOfPhotons2
0126     );
0127 
0128     // optical photon labelling 
0129     static void GenPhotonAncestor(const G4Track* aTrack );                    // prior to photon generation loop(s)
0130     static void GenPhotonBegin( int genloop_idx );                            // start of generation loop
0131     static void GenPhotonEnd(   int genloop_idx, G4Track* aSecondaryTrack );  // end of generation loop
0132 
0133     // other 
0134     static NP* CollectOpticalSecondaries(const G4VParticleChange* pc ); 
0135 
0136     // put back old unused API, until can get integration changes thru into JUNOSW 
0137     static void GenPhotonSecondaries( const G4Track* , const G4VParticleChange* ); 
0138 
0139 
0140 };
0141 
0142