RINDEX error - optical process

Hi all,

I am currently trying to simulate the optical process in scint bar. I keep getting this error that includes “NoRINDEX”

*** NoRINDEX ***
** Photon absorbed! **
Photon at Boundary!
thePrePV:  Sensor
thePostPV: World
Old Momentum Direction: (0.693987,-0.330524,0.639637)
Old Polarization:       (0.577768,-0.274447,-0.768677)
*** NoRINDEX ***
** Photon absorbed! **
** Photon absorbed! **
** Photon absorbed! **
** Photon absorbed! **
Photon at Boundary!
thePrePV:  Sensor
thePostPV: World
Old Momentum Direction: (0.173195,0.751267,0.636868)
Old Polarization:       (0.147362,0.619594,-0.770965)
*** NoRINDEX ***
** Photon absorbed! **
Photon at Boundary!
thePrePV:  Sensor
thePostPV: World
Old Momentum Direction: (-0.624366,0.455517,0.634564)
Old Polarization:       (-0.511779,0.375173,-0.77287)

I followed the framework and suggestion based on this forum discussion https://geant4-forum.web.cern.ch/t/optical-photon-at-boundary-lut-unified/5640 however I still keep getting that error.

Here is my code in DetectorConstruction.cc that defines optical properties:

 G4Material* scintMat = new G4Material ("plasticScint", 1.03*g/cm3, 1, kStateSolid); 
 scintMat->AddMaterial(G4NistManager::Instance()->FindOrBuildMaterial("G4_POLYSTYRENE"), 1.0);

// ------------ Generate & Add Material Properties Table ------------
 // Refractive index needed for Cherenkov process 
 
 const G4int nEntries = 32;
 G4double photonEnergy[nEntries] ={2.034 * eV, 2.068 * eV, 2.103 * eV, 2.139 * eV,
 2.177 * eV, 2.216 * eV, 2.256 * eV, 2.298 * eV,
 2.341 * eV, 2.386 * eV, 2.433 * eV, 2.481 * eV,
 2.532 * eV, 2.585 * eV, 2.640 * eV, 2.697 * eV,
 2.757 * eV, 2.820 * eV, 2.885 * eV, 2.954 * eV,
 3.026 * eV, 3.102 * eV, 3.181 * eV, 3.265 * eV,
 3.353 * eV, 3.446 * eV, 3.545 * eV, 3.649 * eV,
 3.760 * eV, 3.877 * eV, 4.002 * eV, 4.136 * eV};
 G4double absorption[nEntries]={3.5*m, 3.5*m, 3.5*m, 3.5*m, 3.5*m, 3.5*m, 3.5*m, 3.5*m, 3.5*m, 3.5*m, 3.5*m, 3.5*m, 3.5*m};
 G4double refractiveIndex[nEntries] ={1.57 , 1.57 , 1.57 , 1.57 , 1.57 ,
 1.57 , 1.57 , 1.57 , 1.57 ,1.57 ,
 1.57 , 1.57 , 1.57 , 1.57 ,1.57 ,
 1.57 , 1.57 , 1.57 , 1.57  ,1.57 ,
 1.57 , 1.57 , 1.57 , 1.57 , 1.57 ,
 1.57 , 1.57 , 1.57 , 1.57 , 1.57 ,
 1.57 , 1.57 };
 G4double ScintilFast[nEntries]={0.019, 0.037, 0.074, 0.111, 0.148, 0.185, 0.148, 
				      0.110, 0.074, 0.037, 0.033, 0.018, 0.006};
 
 G4MaterialPropertiesTable* myMPT1 = new G4MaterialPropertiesTable();
 myMPT1->AddProperty("RINDEX", photonEnergy, refractiveIndex, nEntries)->SetSpline(true); // myMPT1->AddProperty("RINDEX", photonEnergy, refractiveIndex, nEntries); makes no difference 
 myMPT1->AddProperty("ABSLENGTH",photonEnergy,absorption, nEntries); // kept same because of similarity to General G4_POLYSTERENE 
 
 // .................................//
 // Below are lines taken from scint frame however it crashes the simulation -> overload 
 
 // myMPT1->AddProperty("FASTCOMPONENT",photonEnergy, ScintilFast, nEntries);
 // myMPT1->AddConstProperty("SCINTILLATIONYIELD",7100./MeV);
 // myMPT1->AddConstProperty("RESOLUTIONSCALE",1.0);
 // myMPT1->AddConstProperty("FASTTIMECONSTANT", 7.0*ns);
 scintMat->SetMaterialPropertiesTable(myMPT1);
 scintMat->GetIonisation()->SetBirksConstant(0.126*mm/MeV); // Accounts for Birks effect in hits

And in my physics list I enabled optical process:

// Optical Physics
  G4OpticalPhysics* opticalPhysics = new G4OpticalPhysics(); 
  RegisterPhysics(opticalPhysics); 
  
  opticalPhysics->SetScintillationYieldFactor(1.);
  opticalPhysics->SetScintillationExcitationRatio(0.); 
  
  opticalPhysics->SetTrackSecondariesFirst(kScintillation,false);

What am I missing? I added RINDEX with AddProperty() over increasing specified range however it still shows RINDEX error when I use muon particle gun. Also the code which I commented regarding myMPT1


 // myMPT1->AddProperty("FASTCOMPONENT",photonEnergy, ScintilFast, nEntries);
 // myMPT1->AddConstProperty("SCINTILLATIONYIELD",7100./MeV);
 // myMPT1->AddConstProperty("RESOLUTIONSCALE",1.0);
 // myMPT1->AddConstProperty("FASTTIMECONSTANT", 7.0*ns);

when ran crashes/ stalls the GEANT4 Visualization. Any help advice would be greatly appreciated!

In the DetectorConstruction.cc code you have set nEntries to 32. There are 32 entries provided to initialize the length 32 arrays photonEnergy and refractiveIndex. However, only 13 entries are provided for absorption and ScintilFast even though they are declared to be of length 32. Thus ABSLENGTH and FASTCOMPONENT each get loaded with two arrays of different size. This means that for some photonEnergy values, absorption and ScintilFast are not defined. This can cause problems and may be the cause of yours.

Thank you for your reply, I did fix the entries with length size (making 13 default) but it still didn’t solve the RINDEX issue. The simulation does run slightly better. Is it perhaps defining of G4_Air that needs to be maybe redefined?

The “NoRINDEX” message occurs at the boundary between two materials. Do you have an RINDEX set for whatever surrounds the scintillator?

The issue with vis is likely that there are many optical photons produced. Try turning the scintillation yield down. Or maybe there are vis commands to not plot optical photons.

Hello , Thank you again for feedback, the scintillator is surrounded by G4_Air which RINDEX should be provided by default (I also tried manually but the same result).

I also changed the scintillation yield down but it didn’t change anything. Maybe it has to do something with physics list ?

I just enabled optical physics and added these three lines:

opticalPhysics->SetScintillationYieldFactor(1.);
opticalPhysics->SetScintillationExcitationRatio(0.); 
opticalPhysics->SetScintillationStackPhotons(false);

No optical properties are provided “by default.” You have to specify all the properties you need, for all the materials or volumes, in your application.

Thank for the clarification. I added RINDEX however I still get the error. I changed air to vacuum and added these properties below

G4Material* Material_Vacuum = new G4Material("Vacuum", 1., 1.01 * g/mole, universe_mean_density, kStateGas, 0.1 * kelvin, 1.e-19 * pascal);   
        
G4double refractiveIndex_Vacuum= 1.0;
G4MaterialPropertiesTable * mpt_Vc = new G4MaterialPropertiesTable();
mpt_Vc->AddConstProperty("RINDEX", refractiveIndex_Vacuum);
Material_Vacuum->SetMaterialPropertiesTable(mpt_Vc);

Please try to replicate how it is done either in the Book for Application Developers, or in the OpNovice extended example. There are still at least two things wrong:
1.

RINDEX needs to be provided as a table of RINDEX vs energy (like you did for the scintillator material), and added using AddProperty. There needs to be at least two values. If the RINDEX is constant, like you have, choose the energies to be the min and max energy of interest, and set the RINDEX to the same for both.

This prevents generation of scintillation photons. Remove it, or set the argument to ‘true’.

Further to John’s comment. Starting in Geant4 version 10.7, the C arrays with material properties:

can be replaced with std::vectors. This enables the program to automatically check that the lengths are correct. This is the recommended way. See the examples or Book for Application Developers for details.

Hello, thank you, I coded from scratch and took your advice on referring to OpNovice extended example (modifying it). It seems to finally seems to run without any error. Just another question - is there a way to simulate photons getting emitted when muon just hits the scintillator (emission seems to occur inside the scintillator).

I suppose you could create two materials with the same composition, but give different optical properties to them. Let one have a scintillation yield, and the other not. Put a thin layer of the one with a yield on the outside of the ‘scintillator’.

What scintillator only has scintillation at the surface?

1 Like

Thank you for advice, for now I consider this matter resolved. Scintillation seems to work as intended.