File indexing completed on 2026-04-09 07:49:35
0001 #pragma once
0002 #include <string>
0003 #include <vector>
0004 #include <limits>
0005 #include <cstdint>
0006 #include "plog/Severity.h"
0007 #include "SYSRAP_API_EXPORT.hh"
0008
0009 struct NP ;
0010
0011 struct scontext ;
0012 struct salloc ;
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186 struct SYSRAP_API SEventConfig
0187 {
0188 static const plog::Severity LEVEL ;
0189 static constexpr const int MISSING_INDEX = std::numeric_limits<int>::max() ;
0190
0191 static int RecordLimit();
0192 static void LIMIT_Check();
0193 static void ORDER_Check();
0194 static std::string Desc();
0195
0196
0197 static std::string HitMaskLabel();
0198
0199
0200
0201 static const char* OutDir( const char* reldir);
0202 static const char* OutDir();
0203 static const char* OutPath( const char* stem, int index, const char* ext, bool unique );
0204 static const char* OutPath( const char* reldir, const char* stem, int index, const char* ext, bool unique );
0205 static std::string DescOutPath( const char* stem, int index, const char* ext, bool unique ) ;
0206
0207
0208 static constexpr const int64_t G = 1000000000 ;
0209 static constexpr const int64_t M = 1000000 ;
0210 static constexpr const int64_t K = 1000 ;
0211
0212 static constexpr const char* WITH_STATE_LIMIT = "M3" ;
0213 static constexpr const char* NO_STATE_LIMIT = "G1000" ;
0214 static constexpr const char* NO_STATE_LIMIT_GENSTEP = "M10" ;
0215
0216 static constexpr const char* kIntegrationMode = "OPTICKS_INTEGRATION_MODE" ;
0217 static constexpr const char* kEventMode = "OPTICKS_EVENT_MODE" ;
0218 static constexpr const char* kEventName = "OPTICKS_EVENT_NAME" ;
0219 static constexpr const char* kRunningMode = "OPTICKS_RUNNING_MODE" ;
0220
0221 static constexpr const char* kStartIndex = "OPTICKS_START_INDEX" ;
0222 static constexpr const char* kNumEvent = "OPTICKS_NUM_EVENT" ;
0223 static constexpr const char* kNumPhoton = "OPTICKS_NUM_PHOTON" ;
0224 static constexpr const char* kNumGenstep = "OPTICKS_NUM_GENSTEP" ;
0225 static constexpr const char* kEventSkipahead = "OPTICKS_EVENT_SKIPAHEAD" ;
0226
0227 static constexpr const char* kG4StateSpec = "OPTICKS_G4STATE_SPEC" ;
0228 static constexpr const char* kG4StateRerun = "OPTICKS_G4STATE_RERUN" ;
0229
0230 static constexpr const char* kMaxCurand = "OPTICKS_MAX_CURAND" ;
0231 static constexpr const char* kMaxSlot = "OPTICKS_MAX_SLOT" ;
0232
0233 static constexpr const char* kMaxGenstep = "OPTICKS_MAX_GENSTEP" ;
0234 static constexpr const char* kMaxPhoton = "OPTICKS_MAX_PHOTON" ;
0235 static constexpr const char* kMaxSimtrace = "OPTICKS_MAX_SIMTRACE" ;
0236
0237 static constexpr const char* kMaxBounce = "OPTICKS_MAX_BOUNCE" ;
0238 static constexpr const char* kMaxTime = "OPTICKS_MAX_TIME" ;
0239
0240 static constexpr const char* kMaxRecord = "OPTICKS_MAX_RECORD" ;
0241 static constexpr const char* kMaxRec = "OPTICKS_MAX_REC" ;
0242 static constexpr const char* kMaxAux = "OPTICKS_MAX_AUX" ;
0243 static constexpr const char* kMaxSup = "OPTICKS_MAX_SUP" ;
0244 static constexpr const char* kMaxSeq = "OPTICKS_MAX_SEQ" ;
0245 static constexpr const char* kMaxPrd = "OPTICKS_MAX_PRD" ;
0246 static constexpr const char* kMaxTag = "OPTICKS_MAX_TAG" ;
0247 static constexpr const char* kMaxFlat = "OPTICKS_MAX_FLAT" ;
0248
0249 static constexpr const char* kModeSave = "OPTICKS_MODE_SAVE" ;
0250 static constexpr const char* kModeClient = "OPTICKS_MODE_CLIENT" ;
0251 static constexpr const char* kModeLite = "OPTICKS_MODE_LITE" ;
0252 static constexpr const char* kModeMerge = "OPTICKS_MODE_MERGE" ;
0253 static constexpr const char* kMergeWindow = "OPTICKS_MERGE_WINDOW" ;
0254
0255 static constexpr const char* kMaxExtentDomain = "OPTICKS_MAX_EXTENT_DOMAIN" ;
0256 static constexpr const char* kMaxTimeDomain = "OPTICKS_MAX_TIME_DOMAIN" ;
0257
0258 static constexpr const char* kOutPrefix = "OPTICKS_OUT_PREFIX" ;
0259 static constexpr const char* kOutFold = "OPTICKS_OUT_FOLD" ;
0260 static constexpr const char* kOutName = "OPTICKS_OUT_NAME" ;
0261 static constexpr const char* kEventReldir = "OPTICKS_EVENT_RELDIR" ;
0262 static constexpr const char* kHitMask = "OPTICKS_HIT_MASK" ;
0263 static constexpr const char* kRGMode = "OPTICKS_RG_MODE" ;
0264
0265
0266 static constexpr const char* kGatherComp = "OPTICKS_GATHER_COMP" ;
0267 static constexpr const char* kSaveComp = "OPTICKS_SAVE_COMP" ;
0268
0269 static constexpr const char* kPropagateEpsilon = "OPTICKS_PROPAGATE_EPSILON" ;
0270 static constexpr const char* kPropagateEpsilon0 = "OPTICKS_PROPAGATE_EPSILON0" ;
0271 static constexpr const char* kPropagateEpsilon0Mask = "OPTICKS_PROPAGATE_EPSILON0_MASK" ;
0272 static constexpr const char* kPropagateRefine = "OPTICKS_PROPAGATE_REFINE" ;
0273 static constexpr const char* kPropagateRefineDistance = "OPTICKS_PROPAGATE_REFINE_DISTANCE" ;
0274
0275 static constexpr const char* kInputGenstep = "OPTICKS_INPUT_GENSTEP" ;
0276 static constexpr const char* kInputGenstepSelection = "OPTICKS_INPUT_GENSTEP_SELECTION" ;
0277 static constexpr const char* kInputPhoton = "OPTICKS_INPUT_PHOTON" ;
0278 static constexpr const char* kInputPhotonFrame = "OPTICKS_INPUT_PHOTON_FRAME" ;
0279 static constexpr const char* kInputPhotonChangeTime = "OPTICKS_INPUT_PHOTON_CHANGE_TIME" ;
0280 static constexpr const char* kInputPhotonRecordTime = "OPTICKS_INPUT_PHOTON_RECORD_TIME" ;
0281 static constexpr const char* kInputPhotonRecordSlice = "OPTICKS_INPUT_PHOTON_RECORD_SLICE" ;
0282
0283
0284 static int IntegrationMode();
0285 static bool GPU_Simulation() ;
0286 static bool CPU_Simulation() ;
0287
0288 static const char* EventMode();
0289 static const char* EventName();
0290 static const char* DeviceName();
0291 static bool HasDevice();
0292
0293 static int RunningMode();
0294 static const char* RunningModeLabel();
0295
0296 static bool IsRunningModeDefault();
0297 static bool IsRunningModeG4StateSave();
0298 static bool IsRunningModeG4StateRerun();
0299
0300 static bool IsRunningModeTorch();
0301 static bool IsRunningModeInputPhoton();
0302 static bool IsRunningModeInputGenstep();
0303 static bool IsRunningModeGun();
0304
0305 static int EventSkipahead();
0306 static const char* G4StateSpec();
0307 static int G4StateRerun();
0308
0309 static int64_t MaxCurand();
0310 static int64_t MaxSlot();
0311
0312 static int64_t MaxGenstep();
0313 static int64_t MaxPhoton();
0314 static int64_t MaxSimtrace();
0315
0316 static int64_t MaxBounce();
0317 static float MaxTime();
0318
0319 static int64_t MaxRecord();
0320 static int64_t MaxRec();
0321 static int64_t MaxAux();
0322
0323
0324
0325 static int64_t MaxSup();
0326 static int64_t MaxSeq();
0327 static int64_t MaxPrd();
0328 static int64_t MaxTag();
0329 static int64_t MaxFlat();
0330
0331 static int64_t ModeSave();
0332 static int64_t ModeClient();
0333 static int64_t ModeLite();
0334 static int64_t ModeMerge();
0335 static float MergeWindow();
0336
0337 static float MaxExtentDomain() ;
0338 static float MaxTimeDomain() ;
0339
0340 static const char* OutFold();
0341 static const char* OutName();
0342 static const char* EventReldir();
0343 static unsigned HitMask();
0344
0345 static unsigned GatherComp();
0346 static unsigned SaveComp();
0347
0348 static float PropagateEpsilon();
0349 static float PropagateEpsilon0();
0350 static unsigned PropagateEpsilon0Mask();
0351 static std::string PropagateEpsilon0MaskLabel();
0352 static float PropagateRefineDistance();
0353 static unsigned PropagateRefine();
0354
0355 static const char* _InputGenstepPath(int idx=-1);
0356 static const char* InputGenstep(int idx=-1);
0357 static const char* InputGenstepSelection(int idx=-1);
0358 static bool InputGenstepPathExists(int idx);
0359
0360
0361 static const char* InputPhoton();
0362 static const char* InputPhotonFrame();
0363 static float InputPhotonChangeTime();
0364 static const char* InputPhotonRecordTime();
0365 static const char* InputPhotonRecordSlice();
0366
0367 static int RGMode();
0368 static bool IsRGModeRender();
0369 static bool IsRGModeSimtrace();
0370 static bool IsRGModeSimulate();
0371 static bool IsRGModeTest();
0372
0373 static const char* RGModeLabel();
0374
0375 static std::string DescGatherComp();
0376 static std::string DescSaveComp();
0377
0378 static bool HasComp_(unsigned comp, const char* q_names, char q_delim=',');
0379 static bool HasSaveComp( const char* q_names, char q_delim=',');
0380 static bool HasGatherComp(const char* q_names, char q_delim=',');
0381
0382
0383
0384
0385 static void GatherCompList( std::vector<unsigned>& gather_comp ) ;
0386 static int NumGatherComp();
0387
0388 static void SaveCompList( std::vector<unsigned>& save_comp ) ;
0389 static int NumSaveComp();
0390
0391 static constexpr const char* DebugHeavy = "DebugHeavy" ;
0392 static constexpr const char* DebugLite = "DebugLite" ;
0393 static constexpr const char* Nothing = "Nothing" ;
0394 static constexpr const char* Minimal = "Minimal" ;
0395 static constexpr const char* Hit = "Hit" ;
0396 static constexpr const char* HitPhoton = "HitPhoton" ;
0397 static constexpr const char* HitPhotonSeq = "HitPhotonSeq" ;
0398 static constexpr const char* HitSeq = "HitSeq" ;
0399
0400 static void SetDebugHeavy();
0401 static void SetDebugLite();
0402 static void SetNothing();
0403 static void SetMinimal();
0404 static void SetHit();
0405 static void SetHitPhoton();
0406 static void SetHitPhotonSeq();
0407 static void SetHitSeq();
0408
0409 static bool IsDebugHeavy();
0410 static bool IsDebugLite();
0411 static bool IsNothing();
0412 static bool IsMinimal();
0413 static bool IsHit();
0414 static bool IsHitPhoton();
0415 static bool IsHitPhotonSeq();
0416 static bool IsHitSeq();
0417
0418 static bool IsMinimalOrNothing();
0419
0420 static std::string DescEventMode() ;
0421 static std::string DescEventModeCheck() ;
0422
0423 static void SetIntegrationMode(int mode);
0424 static void SetEventMode(const char* mode);
0425 static void SetEventName(const char* name);
0426 static void SetRunningMode(const char* mode);
0427
0428 static void SetStartIndex(int index0);
0429 static void SetNumEvent(int nevt);
0430 static void SetNumPhoton(const char* spec);
0431
0432 static void SetEventSkipahead(int offset);
0433 static void SetG4StateSpec(const char* spec);
0434 static void SetG4StateRerun(int id);
0435
0436 static void SetMaxCurand( int max_curand);
0437 static void SetMaxSlot( int max_slot);
0438
0439 static void SetMaxGenstep(int max_genstep);
0440 static void SetMaxPhoton( int max_photon);
0441 static void SetMaxSimtrace( int max_simtrace);
0442
0443 static void SetMaxBounce( int max_bounce);
0444 static void SetMaxTime( float max_time );
0445
0446 static void SetMaxRecord( int max_record);
0447 static void SetMaxRec( int max_rec);
0448 static void SetMaxAux( int max_aux);
0449 static void SetMaxSup( int max_sup);
0450 static void SetMaxSeq( int max_seq);
0451 static void SetMaxPrd( int max_prd);
0452 static void SetMaxTag( int max_tag);
0453 static void SetMaxFlat( int max_flat);
0454
0455 static void SetModeSave( int mode );
0456 static void SetModeClient( int mode );
0457 static void SetModeLite( int mode );
0458 static void SetModeMerge( int mode );
0459 static void SetMergeWindow( float merge_window_ns );
0460
0461 static void SetMaxExtentDomain( float max_extent);
0462 static void SetMaxTimeDomain( float max_time );
0463
0464
0465
0466
0467 static void SetOutFold( const char* out_fold);
0468 static void SetOutName( const char* out_name);
0469 static void SetEventReldir( const char* evt_reldir);
0470 static void SetHitMask(const char* abrseq, char delim=',' );
0471
0472 static void SetRGMode( const char* rg_mode) ;
0473 static void SetRGModeSimulate() ;
0474 static void SetRGModeSimtrace() ;
0475 static void SetRGModeRender() ;
0476 static void SetRGModeTest() ;
0477
0478 static void SetPropagateEpsilon( float eps) ;
0479 static void SetPropagateEpsilon0( float eps) ;
0480 static void SetPropagateEpsilon0Mask( const char* abrseq, char delim=',' ) ;
0481 static void SetPropagateRefineDistance( float refine_distance ) ;
0482 static void SetPropagateRefine( unsigned refine ) ;
0483
0484 static void SetInputGenstep(const char* input_genstep);
0485 static void SetInputGenstepSelection(const char* input_genstep_selection);
0486 static void SetInputPhoton(const char* input_photon);
0487 static void SetInputPhotonFrame(const char* input_photon_frame);
0488 static void SetInputPhotonChangeTime( float t0 ) ;
0489 static void SetInputPhotonRecordTime( const char* record_time ) ;
0490 static void SetInputPhotonRecordSlice( const char* iprs ) ;
0491
0492 static void SetGatherComp_(unsigned mask);
0493 static void SetGatherComp(const char* names, char delim=',') ;
0494 static bool GatherRecord();
0495
0496 static void SetSaveComp_(unsigned mask);
0497 static void SetSaveComp(const char* names, char delim=',') ;
0498 static bool IsCompConfigured();
0499
0500
0501
0502 static int _IntegrationModeDefault ;
0503 static const char* _EventModeDefault ;
0504 static const char* _EventNameDefault ;
0505 static const char* _RunningModeDefault ;
0506 static int _StartIndexDefault ;
0507 static int _NumEventDefault ;
0508 static const char* _NumPhotonDefault ;
0509 static const char* _NumGenstepDefault ;
0510
0511 static int _EventSkipaheadDefault ;
0512 static const char* _G4StateSpecDefault ;
0513 static const char* _G4StateSpecNotes ;
0514 static int _G4StateRerunDefault ;
0515
0516 static const char* _MaxBounceNotes ;
0517 static const char* _MaxTimeNotes ;
0518
0519 static const char* _MaxCurandDefault ;
0520 static const char* _MaxSlotDefault ;
0521
0522 static const char* _MaxGenstepDefault ;
0523 static const char* _MaxPhotonDefault ;
0524 static const char* _MaxSimtraceDefault ;
0525
0526 static float _MaxTimeDefault ;
0527 static int _MaxBounceDefault ;
0528 static int _MaxRecordDefault ;
0529 static int _MaxRecDefault ;
0530 static int _MaxAuxDefault ;
0531 static int _MaxSupDefault ;
0532 static int _MaxSeqDefault ;
0533 static int _MaxPrdDefault ;
0534 static int _MaxTagDefault ;
0535 static int _MaxFlatDefault ;
0536
0537 static int _ModeSaveDefault ;
0538 static int _ModeClientDefault ;
0539 static int _ModeLiteDefault ;
0540 static int _ModeMergeDefault ;
0541 static float _MergeWindowDefault ;
0542
0543 static float _MaxExtentDomainDefault ;
0544 static float _MaxTimeDomainDefault ;
0545
0546 static const char* _OutFoldDefault ;
0547 static const char* _OutNameDefault ;
0548 static const char* _EventReldirDefault ;
0549 static const char* _HitMaskDefault ;
0550
0551 static const char* _RGModeDefault ;
0552
0553 static const char* _GatherCompDefault ;
0554 static const char* _SaveCompDefault ;
0555
0556 static float _PropagateEpsilonDefault ;
0557 static float _PropagateEpsilon0Default ;
0558 static const char* _PropagateEpsilon0MaskDefault ;
0559 static float _PropagateRefineDistanceDefault ;
0560 static unsigned _PropagateRefineDefault ;
0561
0562 static const char* _InputGenstepDefault ;
0563 static const char* _InputGenstepSelectionDefault ;
0564 static const char* _InputPhotonDefault ;
0565 static const char* _InputPhotonFrameDefault ;
0566 static float _InputPhotonChangeTimeDefault ;
0567 static const char* _InputPhotonRecordTimeDefault ;
0568 static const char* _InputPhotonRecordSliceDefault ;
0569
0570 static int _IntegrationMode ;
0571 static const char* _EventMode ;
0572 static const char* _EventName ;
0573 static const char* _DeviceName ;
0574 static int _RunningMode ;
0575 static int _StartIndex ;
0576 static int _NumEvent ;
0577
0578 static std::vector<int64_t>* _GetNumPhotonPerEvent();
0579 static std::vector<int64_t>* _NumPhotonPerEvent ;
0580
0581 static std::vector<int64_t>* _GetNumGenstepPerEvent();
0582 static std::vector<int64_t>* _NumGenstepPerEvent ;
0583
0584 static int64_t _GetNumPhoton(int idx);
0585 static int64_t _GetNumGenstep(int idx);
0586
0587
0588 static int _GetNumEvent();
0589 static int64_t NumPhoton(int idx);
0590 static int NumGenstep(int idx);
0591 static int NumEvent();
0592 static int EventIndex(int idx) ;
0593 static int EventIndexArg(int index) ;
0594 static bool IsFirstEvent(int idx);
0595 static bool IsLastEvent(int idx);
0596
0597 static int _EventSkipahead ;
0598 static const char* _G4StateSpec ;
0599 static int _G4StateRerun ;
0600
0601 static int64_t _MaxCurand ;
0602 static int64_t _MaxSlot ;
0603
0604 static int64_t _MaxGenstep ;
0605 static int64_t _MaxPhoton ;
0606 static int64_t _MaxSimtrace ;
0607
0608 static float _MaxTime ;
0609 static int _MaxBounce ;
0610 static int _MaxRecord ;
0611 static int _MaxRec ;
0612 static int _MaxAux ;
0613 static int _MaxSup ;
0614 static int _MaxSeq ;
0615 static int _MaxPrd ;
0616 static int _MaxTag ;
0617 static int _MaxFlat ;
0618
0619 static int _ModeSave ;
0620 static int _ModeClient ;
0621 static int _ModeLite ;
0622 static int _ModeMerge ;
0623 static float _MergeWindow ;
0624
0625 static float _MaxExtentDomain ;
0626 static float _MaxTimeDomain ;
0627
0628 static const char* _OutFold ;
0629 static const char* _OutName ;
0630 static const char* _EventReldir ;
0631 static unsigned _HitMask ;
0632 static int _RGMode ;
0633
0634 static unsigned _GatherComp ;
0635 static unsigned _SaveComp ;
0636
0637 static float _PropagateEpsilon ;
0638 static float _PropagateEpsilon0 ;
0639 static unsigned _PropagateEpsilon0Mask ;
0640 static float _PropagateRefineDistance ;
0641 static unsigned _PropagateRefine ;
0642
0643 static const char* _InputGenstep ;
0644 static const char* _InputGenstepSelection ;
0645 static const char* _InputPhoton ;
0646 static const char* _InputPhotonFrame ;
0647 static float _InputPhotonChangeTime ;
0648 static const char* _InputPhotonRecordTime ;
0649 static const char* _InputPhotonRecordSlice ;
0650
0651 static scontext* CONTEXT ;
0652 static salloc* ALLOC ;
0653 static std::string GetGPUMeta();
0654
0655 static int Initialize_COUNT ;
0656 static void Initialize_Meta();
0657 static int Initialize();
0658
0659 static void Initialize_EventName();
0660
0661
0662 static const char* DebugHeavy_NOTE ;
0663 static const char* DebugLite_NOTE ;
0664 static const char* Nothing_NOTE ;
0665 static const char* Minimal_NOTE ;
0666 static const char* Hit_NOTE ;
0667 static const char* HitPhoton_NOTE ;
0668 static const char* HitPhotonSeq_NOTE ;
0669 static const char* HitSeq_NOTE ;
0670 static const char* EventMode_NOTE() ;
0671
0672 static void Initialize_Comp();
0673
0674 static unsigned PhotonComp();
0675 static unsigned PhotonCompOne();
0676 static const char* PhotonCompOneName();
0677
0678 static unsigned HitComp();
0679 static unsigned HitCompOne();
0680 static const char* HitCompOneName();
0681
0682
0683 static void Initialize_Comp_Simulate_(unsigned& gather_mask, unsigned& save_mask );
0684 static void Initialize_Comp_Simtrace_(unsigned& gather_mask, unsigned& save_mask );
0685 static void Initialize_Comp_Render_( unsigned& gather_mask, unsigned& save_mask );
0686
0687
0688 static constexpr const char* NAME = "SEventConfig.npy" ;
0689 static NP* Serialize();
0690 static void Save(const char* dir) ;
0691
0692 static void SetDevice( size_t totalGlobalMem_bytes, std::string name );
0693 static void SetDeviceName( const char* name );
0694
0695 static size_t HeuristicMaxSlot( size_t totalGlobalMem_bytes, int lite, int merge );
0696 static size_t HeuristicMaxSlot_Rounded( size_t totalGlobalMem_bytes, int lite, int merge );
0697 static std::string DescDevice(size_t totalGlobalMem_bytes, std::string name );
0698
0699 static salloc* AllocEstimate(int _max_slot=0);
0700 static uint64_t AllocEstimateTotal(int _max_slot=0);
0701
0702
0703
0704 };