Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions dd4hepplugins/OpticsSteppingAction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ void OpticsSteppingAction::operator()(const G4Step *step, G4SteppingManager *mgr

{
G4AutoLock lock(&genstep_mutex);
U4::CollectGenstep_DsG4Scintillation_r4695(track, step, numPhotons,
/*scnt=*/1, scintTime);
U4::CollectGenstep_Scintillation(track, step, numPhotons, /*scnt=*/1, scintTime);
}

if (verbose_ > 0)
Expand Down
3 changes: 1 addition & 2 deletions examples/MC_Truth/GPUMCTruth.h
Original file line number Diff line number Diff line change
Expand Up @@ -605,8 +605,7 @@ struct SteppingAction : G4UserSteppingAction
G4double SCINTILLATIONTIMECONSTANT1 = MPT->GetConstProperty(kSCINTILLATIONTIMECONSTANT1);

G4AutoLock lock(&genstep_mutex);
U4::CollectGenstep_DsG4Scintillation_r4695(aTrack, aStep, fNumPhotons, 1,
SCINTILLATIONTIMECONSTANT1);
U4::CollectGenstep_Scintillation(aTrack, aStep, fNumPhotons, 1, SCINTILLATIONTIMECONSTANT1);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions examples/async_gpu_launch/async_gpu_launch.h
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ static quad6 MakeGenstep_Scintillation(const G4Track* aTrack, const G4Step* aSte
gs.zero();
sscint* sc = (sscint*)(&gs);

sc->gentype = OpticksGenstep_DsG4Scintillation_r4695;
sc->gentype = OpticksGenstep_SCINTILLATION;
sc->trackid = aTrack->GetTrackID();
sc->matline = aMaterial->GetIndex() + SEvt::G4_INDEX_OFFSET;
sc->numphoton = numPhotons;
Expand Down Expand Up @@ -953,7 +953,7 @@ struct SteppingAction : G4UserSteppingAction
nRemaining -= nPhotComp;

if (nPhotComp > 0)
U4::CollectGenstep_DsG4Scintillation_r4695(aTrack, aStep, nPhotComp, c + 1, tc[c]);
U4::CollectGenstep_Scintillation(aTrack, aStep, nPhotComp, c + 1, tc[c]);
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions examples/async_gpu_std/async_gpu_std.h
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ static quad6 MakeGenstep_Scintillation(const G4Track* aTrack,
gs.zero();
sscint* sc = (sscint*)(&gs);

sc->gentype = OpticksGenstep_DsG4Scintillation_r4695;
sc->gentype = OpticksGenstep_SCINTILLATION;
sc->trackid = aTrack->GetTrackID();
sc->matline = mat->GetIndex() + SEvt::G4_INDEX_OFFSET;
sc->numphoton = numPhotons;
Expand Down Expand Up @@ -1006,8 +1006,7 @@ struct SteppingAction : G4UserSteppingAction
: static_cast<G4int>(numPhotons * yield[c] / yieldSum);
remaining -= n;
if (n > 0)
U4::CollectGenstep_DsG4Scintillation_r4695(track, aStep, n, c + 1,
tc[c]);
U4::CollectGenstep_Scintillation(track, aStep, n, c + 1, tc[c]);
}
}
}
Expand Down
1 change: 0 additions & 1 deletion qudarap/qsim.h
Original file line number Diff line number Diff line change
Expand Up @@ -2424,7 +2424,6 @@ inline QSIM_METHOD void qsim::generate_photon(sphoton& p, RNG& rng, const quad6&
case OpticksGenstep_CERENKOV:
cerenkov->generate( p, rng, gs, photon_id, genstep_id ) ; break ;

case OpticksGenstep_DsG4Scintillation_r4695:
case OpticksGenstep_SCINTILLATION:
if (scint != nullptr)
scint->generate(p, rng, gs, photon_id, genstep_id);
Expand Down
3 changes: 1 addition & 2 deletions src/GPUCerenkov.h
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,7 @@ struct SteppingAction : G4UserSteppingAction
G4double SCINTILLATIONTIMECONSTANT1 = MPT->GetConstProperty(kSCINTILLATIONTIMECONSTANT1);

G4AutoLock lock(&genstep_mutex);
U4::CollectGenstep_DsG4Scintillation_r4695(aTrack, aStep, fNumPhotons, 1,
SCINTILLATIONTIMECONSTANT1);
U4::CollectGenstep_Scintillation(aTrack, aStep, fNumPhotons, 1, SCINTILLATIONTIMECONSTANT1);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/GPURaytrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ struct SteppingAction : G4UserSteppingAction
nRemaining -= nPhotComp;

if (nPhotComp > 0)
U4::CollectGenstep_DsG4Scintillation_r4695(aTrack, aStep, nPhotComp, c + 1, tc[c]);
U4::CollectGenstep_Scintillation(aTrack, aStep, nPhotComp, c + 1, tc[c]);
}
}
}
Expand Down
35 changes: 3 additions & 32 deletions sysrap/OpticksGenstep.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ See also: npy/G4StepNPY.cpp (TODO: consolidate these?)
enum
{
OpticksGenstep_INVALID = 0,
OpticksGenstep_G4Cerenkov_1042 = 1,
OpticksGenstep_G4Scintillation_1042 = 2,
OpticksGenstep_DsG4Cerenkov_r3971 = 3,
OpticksGenstep_DsG4Scintillation_r3971 = 4,
OpticksGenstep_DsG4Scintillation_r4695 = 5,
// Values 1-5 are intentionally unused after retiring their legacy encodings.
OpticksGenstep_TORCH = 6,
OpticksGenstep_FABRICATED = 7,
OpticksGenstep_EMITSOURCE = 8,
Expand Down Expand Up @@ -52,11 +48,6 @@ enum
struct OpticksGenstep_
{
static constexpr const char* INVALID_ = "INVALID" ;
static constexpr const char* G4Cerenkov_1042_ = "G4Cerenkov_1042" ;
static constexpr const char* G4Scintillation_1042_ = "G4Scintillation_1042" ;
static constexpr const char* DsG4Cerenkov_r3971_ = "DsG4Cerenkov_r3971" ;
static constexpr const char* DsG4Scintillation_r3971_ = "DsG4Scintillation_r3971" ;
static constexpr const char* DsG4Scintillation_r4695_ = "DsG4Scintillation_r4695" ;
static constexpr const char* TORCH_ = "TORCH" ;
static constexpr const char* FABRICATED_ = "FABRICATED" ;
static constexpr const char* EMITSOURCE_ = "EMITSOURCE" ;
Expand Down Expand Up @@ -97,12 +88,7 @@ struct OpticksGenstep_
inline unsigned OpticksGenstep_::Type(const char* name)
{
unsigned type = OpticksGenstep_INVALID ;
if(strcmp(name,G4Cerenkov_1042_ )==0) type = OpticksGenstep_G4Cerenkov_1042 ;
if(strcmp(name,G4Scintillation_1042_ )==0) type = OpticksGenstep_G4Scintillation_1042 ;
if(strcmp(name,DsG4Cerenkov_r3971_ )==0) type = OpticksGenstep_DsG4Cerenkov_r3971 ;
if(strcmp(name,G4Cerenkov_modified_ )==0) type = OpticksGenstep_G4Cerenkov_modified ;
if(strcmp(name,DsG4Scintillation_r3971_ )==0) type = OpticksGenstep_DsG4Scintillation_r3971 ;
if(strcmp(name,DsG4Scintillation_r4695_ )==0) type = OpticksGenstep_DsG4Scintillation_r4695 ;
if(strcmp(name,TORCH_)==0) type = OpticksGenstep_TORCH ;
if(strcmp(name,FABRICATED_)==0) type = OpticksGenstep_FABRICATED ;
if(strcmp(name,EMITSOURCE_)==0) type = OpticksGenstep_EMITSOURCE ;
Expand Down Expand Up @@ -131,12 +117,7 @@ inline const char* OpticksGenstep_::Name(unsigned type)
switch(type)
{
case OpticksGenstep_INVALID: n = INVALID_ ; break ;
case OpticksGenstep_G4Cerenkov_1042: n = G4Cerenkov_1042_ ; break ;
case OpticksGenstep_G4Scintillation_1042: n = G4Scintillation_1042_ ; break ;
case OpticksGenstep_DsG4Cerenkov_r3971: n = DsG4Cerenkov_r3971_ ; break ;
case OpticksGenstep_G4Cerenkov_modified: n = G4Cerenkov_modified_ ; break ;
case OpticksGenstep_DsG4Scintillation_r3971: n = DsG4Scintillation_r3971_ ; break ;
case OpticksGenstep_DsG4Scintillation_r4695: n = DsG4Scintillation_r4695_ ; break ;
case OpticksGenstep_TORCH: n = TORCH_ ; break ;
case OpticksGenstep_FABRICATED: n = FABRICATED_ ; break ;
case OpticksGenstep_EMITSOURCE: n = EMITSOURCE_ ; break ;
Expand Down Expand Up @@ -167,19 +148,11 @@ inline bool OpticksGenstep_::IsValid(int gentype) // static

inline bool OpticksGenstep_::IsCerenkov(int gentype) // static
{
return gentype == OpticksGenstep_G4Cerenkov_1042 ||
gentype == OpticksGenstep_DsG4Cerenkov_r3971 ||
gentype == OpticksGenstep_CERENKOV ||
gentype == OpticksGenstep_G4Cerenkov_modified
;
return gentype == OpticksGenstep_CERENKOV || gentype == OpticksGenstep_G4Cerenkov_modified;
}
inline bool OpticksGenstep_::IsScintillation(int gentype) // static
{
return gentype == OpticksGenstep_G4Scintillation_1042 ||
gentype == OpticksGenstep_DsG4Scintillation_r3971 ||
gentype == OpticksGenstep_DsG4Scintillation_r4695 ||
gentype == OpticksGenstep_SCINTILLATION
;
return gentype == OpticksGenstep_SCINTILLATION;
}
inline bool OpticksGenstep_::IsTorchLike(int gentype) // static
{
Expand Down Expand Up @@ -263,5 +236,3 @@ inline unsigned OpticksGenstep_::GentypeToPhotonFlag(char gentype) // static


#endif


4 changes: 1 addition & 3 deletions sysrap/sscint.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ sscint.h : scintillation genstep helpers
========================================

* FOLLOWING PATTERN OF storch.h and scerenkov.h

For now just implemnet for JUNO specific variant : collectGenstep_DsG4Scintillation_r4695
* shared by collected and fabricated scintillation gensteps

**/


#if defined(__CUDACC__) || defined(__CUDABE__)
#define SSCINT_METHOD __device__
#else
Expand Down
1 change: 1 addition & 0 deletions sysrap/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ set(TEST_SOURCES
scanvasTest.cc

OpticksPhotonTest.cc
GenstepTest.cc
SUTest.cc
SEventConfigTest.cc
SFrameConfigTest.cc
Expand Down
39 changes: 39 additions & 0 deletions sysrap/tests/GenstepTest.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include <cassert>
#include <cstring>

#include "OpticksGenstep.h"

void test_retired_codes()
{
for (unsigned type = 1; type <= 5; ++type)
{
assert(std::strcmp(OpticksGenstep_::Name(type), OpticksGenstep_::INVALID_) == 0);
assert(!OpticksGenstep_::IsValid(type));
assert(!OpticksGenstep_::IsCerenkov(type));
assert(!OpticksGenstep_::IsScintillation(type));
assert(!OpticksGenstep_::IsExpected(type));
assert(OpticksGenstep_::GenstepToPhotonFlag(type) == NAN_ABORT);
}
}

void test_current_optical_codes()
{
static_assert(OpticksGenstep_TORCH == 6, "genstep protocol values must remain stable");
static_assert(OpticksGenstep_CERENKOV == 15, "genstep protocol values must remain stable");
static_assert(OpticksGenstep_SCINTILLATION == 16, "genstep protocol values must remain stable");

assert(OpticksGenstep_::Type("CERENKOV") == OpticksGenstep_CERENKOV);
assert(OpticksGenstep_::Type("SCINTILLATION") == OpticksGenstep_SCINTILLATION);
assert(OpticksGenstep_::IsCerenkov(OpticksGenstep_CERENKOV));
assert(OpticksGenstep_::IsCerenkov(OpticksGenstep_G4Cerenkov_modified));
assert(OpticksGenstep_::IsScintillation(OpticksGenstep_SCINTILLATION));
assert(OpticksGenstep_::GenstepToPhotonFlag(OpticksGenstep_CERENKOV) == CERENKOV);
assert(OpticksGenstep_::GenstepToPhotonFlag(OpticksGenstep_SCINTILLATION) == SCINTILLATION);
}

int main()
{
test_retired_codes();
test_current_optical_codes();
return 0;
}
31 changes: 15 additions & 16 deletions sysrap/tests/sgs_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,31 @@

void test_assign()
{
sgs gs ;
sgs gs;

gs = {} ;
std::cout << gs.desc() << std::endl ;
gs = {};
std::cout << gs.desc() << std::endl;

gs = { 101, 10000, 5000, OpticksGenstep_TORCH } ;
std::cout << gs.desc() << std::endl ;
gs = {101, 10000, 5000, OpticksGenstep_TORCH};
std::cout << gs.desc() << std::endl;

gs = { 202, 20000, 4000, OpticksGenstep_CERENKOV } ;
std::cout << gs.desc() << std::endl ;
gs = {202, 20000, 4000, OpticksGenstep_CERENKOV};
std::cout << gs.desc() << std::endl;

gs = { 303, 30000, 3000, OpticksGenstep_SCINTILLATION } ;
std::cout << gs.desc() << std::endl ;
gs = {303, 30000, 3000, OpticksGenstep_SCINTILLATION};
std::cout << gs.desc() << std::endl;

gs = { 303, 30000, 3000, OpticksGenstep_G4Cerenkov_1042 } ;
gs = {303, 30000, 3000, OpticksGenstep_G4Cerenkov_modified};
std::cout << gs.desc() << std::endl ;
}

void test_array()
{
sgs gs[] = {
{ 101, 10000, 5000, OpticksGenstep_TORCH },
{ 202, 20000, 4000, OpticksGenstep_CERENKOV },
{ 303, 30000, 3000, OpticksGenstep_SCINTILLATION },
{ 303, 30000, 3000, OpticksGenstep_G4Cerenkov_1042 }
};
sgs gs[] = {
{101, 10000, 5000, OpticksGenstep_TORCH},
{202, 20000, 4000, OpticksGenstep_CERENKOV},
{303, 30000, 3000, OpticksGenstep_SCINTILLATION},
{303, 30000, 3000, OpticksGenstep_G4Cerenkov_modified}};

std::cout
<< " sizeof(sgs) " << sizeof(sgs)
Expand Down
2 changes: 1 addition & 1 deletion u4/Local_DsG4Scintillation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ Local_DsG4Scintillation::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep
if(is_opticks_genstep && (m_opticksMode & 1))
{
NumPhoton = std::min( NumPhoton, 3 ); // for debugging purposes it helps to have less photons
U4::CollectGenstep_DsG4Scintillation_r4695( &aTrack, &aStep, NumPhoton, scnt, ScintillationTime);
U4::CollectGenstep_Scintillation(&aTrack, &aStep, NumPhoton, scnt, ScintillationTime);
}

if( m_opticksMode == 0 || (m_opticksMode & 2) )
Expand Down
55 changes: 24 additions & 31 deletions u4/U4.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ HMM: perhapa this state belongs better within SEvt together with the full genste

**/


static sgs gs = {} ; // updated by eg U4::CollectGenstep_DsG4Scintillation_r4695 prior to each photon generation loop
static sgs gs = {}; // updated by eg U4::CollectGenstep_Scintillation prior to each photon generation loop
static spho ancestor = {} ; // updated by U4::GenPhotonAncestor prior to the photon generation loop(s)
static spho pho = {} ; // updated by U4::GenPhotonBegin at start of photon generation loop
static spho secondary = {} ; // updated by U4::GenPhotonEnd at end of photon generation loop
Expand All @@ -65,13 +64,12 @@ Using hidden static non-member functions allows keeping Opticks types like quad6

**/

static quad6 MakeGenstep_DsG4Scintillation_r4695(
const G4Track* aTrack,
const G4Step* aStep,
G4int numPhotons,
G4int scnt,
G4double ScintillationTime
)
static quad6 MakeGenstep_Scintillation(
const G4Track* aTrack,
const G4Step* aStep,
G4int numPhotons,
G4int scnt,
G4double ScintillationTime)
{
G4StepPoint* pPreStepPoint = aStep->GetPreStepPoint();
G4StepPoint* pPostStepPoint = aStep->GetPostStepPoint();
Expand All @@ -89,7 +87,7 @@ static quad6 MakeGenstep_DsG4Scintillation_r4695(

sscint* gs = (sscint*)(&_gs) ; // warning: dereferencing type-punned pointer will break strict-aliasing rules

gs->gentype = OpticksGenstep_DsG4Scintillation_r4695 ;
gs->gentype = OpticksGenstep_SCINTILLATION;
gs->trackid = aTrack->GetTrackID() ;
gs->matline = aMaterial->GetIndex() + SEvt::G4_INDEX_OFFSET ; // offset signals that a mapping must be done in SEvt::setGenstep
gs->numphoton = numPhotons ;
Expand Down Expand Up @@ -125,15 +123,13 @@ static quad6 MakeGenstep_DsG4Scintillation_r4695(
return _gs ;
}


const char* U4::CollectGenstep_DsG4Scintillation_r4695_DISABLE = "U4__CollectGenstep_DsG4Scintillation_r4695_DISABLE" ;
const char* U4::CollectGenstep_DsG4Scintillation_r4695_ZEROPHO = "U4__CollectGenstep_DsG4Scintillation_r4695_ZEROPHO" ;

const char* U4::CollectGenstep_Scintillation_DISABLE = "U4__CollectGenstep_Scintillation_DISABLE";
const char* U4::CollectGenstep_Scintillation_ZEROPHO = "U4__CollectGenstep_Scintillation_ZEROPHO";

/**

U4::CollectGenstep_DsG4Scintillation_r4695
-------------------------------------------
U4::CollectGenstep_Scintillation
--------------------------------

1. makes quad6 gs_ collecting parameters needed to generate photons on GPU
2. adds gs_ to SEvt using SEvt::AddGenstep which collects into a vectors of quad6 for each SEvt
Expand All @@ -142,33 +138,30 @@ U4::CollectGenstep_DsG4Scintillation_r4695

**/

void U4::CollectGenstep_DsG4Scintillation_r4695(
const G4Track* aTrack,
const G4Step* aStep,
G4int numPhotons,
G4int scnt,
G4double ScintillationTime
)
void U4::CollectGenstep_Scintillation(
const G4Track* aTrack,
const G4Step* aStep,
G4int numPhotons,
G4int scnt,
G4double ScintillationTime)
{
if(getenv(CollectGenstep_DsG4Scintillation_r4695_DISABLE))
if (getenv(CollectGenstep_Scintillation_DISABLE))
{
LOG(error) << CollectGenstep_DsG4Scintillation_r4695_DISABLE ;
LOG(error) << CollectGenstep_Scintillation_DISABLE;
return ;
}
if(getenv(CollectGenstep_DsG4Scintillation_r4695_ZEROPHO))
if (getenv(CollectGenstep_Scintillation_ZEROPHO))
{
LOG(error) << CollectGenstep_DsG4Scintillation_r4695_ZEROPHO ;
LOG(error) << CollectGenstep_Scintillation_ZEROPHO;
numPhotons = 0 ;
}



quad6 gs_ = MakeGenstep_DsG4Scintillation_r4695( aTrack, aStep, numPhotons, scnt, ScintillationTime);
quad6 gs_ = MakeGenstep_Scintillation(aTrack, aStep, numPhotons, scnt, ScintillationTime);

gs = SEvt::AddGenstep(gs_); // returns sgs struct which is a simple 4 int label
// gs is private static genstep label

//if(dump) std::cout << "U4::CollectGenstep_DsG4Scintillation_r4695 " << gs.desc() << std::endl ;
// if(dump) std::cout << "U4::CollectGenstep_Scintillation " << gs.desc() << std::endl ;
LOG(LEVEL) << gs.desc();
}

Expand Down
Loading
Loading