Donot See Photons in visualization for PbWO4 detector Volume

Dear Experts I am constructing a PbWO4 detector box for 1 cubic meter size and created particle gun with 10 GeV photon but when I run in visualization I can’t see photons interacting with the box. My construction.cc is as follows:
sim.cc (1.8 KB)


#include "construction.hh"

MyDetectorConstruction::MyDetectorConstruction()
{}
 
MyDetectorConstruction::~MyDetectorConstruction()
{}
    

G4VPhysicalVolume *MyDetectorConstruction::Construct()
{

     G4double a;  // atomic mass
     G4double z;  // atomic number
     G4double density, pressure, temperature, fractionmass;
     G4String name, symbol;
     G4int nel, natoms;
    
     a = 16.00*g/mole;
     G4Element* elO = new G4Element(name="Oxygen", symbol="O2", z=8., a);
   
     a = 183.85*g/mole;
     G4Element* elW = new G4Element(name="Tungsten", symbol="W", z=74., a);
    
     a = 207.19*g/mole;
     G4Element* elPb = new G4Element(name="Lead", symbol="Pb", z=82., a);
     
     a = 14.01*g/mole;
     G4Element* elN = new G4Element(name="Nitrogen", symbol="N2", z=7., a);
    
    
     //--- mixtures
  
     density = 1.290*mg/cm3;
     G4Material* Air = new G4Material(name="Air", density, nel=2);
     Air->AddElement(elN, 0.7);
     Air->AddElement(elO, 0.3);
    
     
     density = 8.28*g/cm3;
     G4Material* PbWO4 = new G4Material(name="PbWO4", density, nel=3);
     PbWO4->AddElement(elPb, natoms=1);
     PbWO4->AddElement(elW,  natoms=1);
     PbWO4->AddElement(elO,  natoms=4);
    
    G4NistManager *nist = G4NistManager::Instance();
    G4Material *worldMat = nist->FindOrBuildMaterial("G4_AIR"); 
    G4Material *theAbsorberMaterial = nist->FindOrBuildMaterial("PbWO4");  
    
    //define mother world
    G4Box *solidWorld = new G4Box("solidWorld", 4*m, 4*m, 4*m);
    G4LogicalVolume *logicWorld = new G4LogicalVolume(solidWorld, worldMat, "logicWorld");
    G4VPhysicalVolume *physWorld = new G4PVPlacement(0, G4ThreeVector(0., 0., 0.), logicWorld, "physWorld", 0, false, 0, true);
 
    //Define detector Volume
const G4double sizeCalo = 2.0*m;         // For normal calorimeter


 G4double xAbsorber = sizeCalo / 2.0;  // half dimension along x 
 G4double yAbsorber = sizeCalo / 2.0;  // half dimension along y
 G4double zAbsorber = sizeCalo / 2.0;  // half dimension along z

 G4Box* solidAbsorber = new G4Box("solidAbsorber", xAbsorber, yAbsorber, zAbsorber);

 G4LogicalVolume* logicAbsorber = new G4LogicalVolume(solidAbsorber,       // solid 
                                     theAbsorberMaterial, // material
                                     "logicAbsorber",     // name
                                     0,                   // field manager
                                     0,                   // sensitive detector
                                     0);                  // user limits

G4VPhysicalVolume* physiAbsorber = new G4PVPlacement(0, G4ThreeVector(0.,0.,0.), logicAbsorber, “physiAbsorber”, 0,false, 0, true);

logicAbsorber->SetMaterial( theAbsorberMaterial );

// PrintParameters();

return physWorld;

}

//void MyDetectorConstruction::ConstructSDandField()
//{
// MySensitiveDetector *sensDet = new MySensitiveDetector(“SensitiveDetector”);

//if(logicDetector != NULL)
  //  logicDetector->SetSensitiveDetector(sensDet);

//}Preformatted text

What does the main() program look like, and what physics lists are you using?

Main Program is as follows:`#include

#include “G4RunManager.hh”
//#include “G4MTRunManager.hh”
#include “G4UImanager.hh”
#include “G4VisManager.hh”
#include “G4VisExecutive.hh”
#include “G4UIExecutive.hh”
//#include “QGSP_BERT.hh”

#include “construction.hh”
#include “physics.hh”
#include “action.hh”

int main(int argc, char** argv)
{
//G4UIExecutive* ui = 0;

// #ifdef G4MULTITHREADED
// G4MTRunManager* runManager = new G4MTRunManager;
//#else
G4RunManager* runManager = new G4RunManager;
//#endif
// runManager->Initialize();
G4UIExecutive *ui = new G4UIExecutive(argc, argv);

G4VisManager *visManager = new G4VisExecutive();
visManager->Initialize();

G4UImanager *UImanager = G4UImanager::GetUIpointer();

runManager->SetUserInitialization(new MyDetectorConstruction());

runManager->SetUserInitialization(new MyPhysicsList());

runManager->SetUserInitialization(new MyActionInitialization());
runManager->Initialize();
//G4VModularPhysicsList* physics = new QGSP_BERT();
//physics->RegisterPhysics(new G4DecayPhysics());
//runManager->SetUserInitialization(physics);

//if (argc == 1)

// {
// ui = new G4UIExecutive(argc, argv);
// }

// if(ui)
// {
UImanager->ApplyCommand(“/vis/open OGL”);
UImanager->ApplyCommand(“/vis/viewer/set/viewpointVector 1 1 1”);
UImanager->ApplyCommand(“/vis/drawVolume”);
UImanager->ApplyCommand(“/vis/viewer/set/autoRefresh true”);

  UImanager->ApplyCommand("vis/scene/add/trajectories smooth");
 
 
 
    ui->SessionStart();
//}
//else

// {
// G4String command = "/control/execute ";
// G4String fileName = argv[1];
// UImanager->ApplyCommand(command+fileName);
// }

return 0;

}

and Physics list is as follows:
#include “physics.hh”

MyPhysicsList::MyPhysicsList()
{
RegisterPhysics (new G4EmStandardPhysics());
RegisterPhysics (new G4OpticalPhysics());

}

MyPhysicsList::~MyPhysicsList()
{}
and Primmary Generator action is as follows:
#include “generator.hh”

MyPrimaryGenerator::MyPrimaryGenerator()
{
fParticleGun = new G4ParticleGun(1);
}

MyPrimaryGenerator::~MyPrimaryGenerator()
{
delete fParticleGun;
}

void MyPrimaryGenerator::GeneratePrimaries(G4Event anEvent)
{
G4ParticleTable
particleTable = G4ParticleTable::GetParticleTable();
G4String particleName=“gamma”;
G4ParticleDefinition* particle = particleTable->FindParticle(“gamma”);

G4ThreeVector pos(0.,0.,0.);
G4ThreeVector mom(0.,0.,1.);
fParticleGun->SetParticlePosition(pos);
fParticleGun->SetParticleMomentumDirection(mom);
fParticleGun->SetParticleMomentum(10.*GeV);
fParticleGun->SetParticleDefinition(particle);
fParticleGun->GeneratePrimaryVertex(anEvent);

}`

Sorry, but could you format that code using fenced code blocks please, i.e.:

```c++
int main()
{
…other code
}
```

That will help to see what’s going on!

Main Program is as follows:`#include

#include “G4RunManager.hh”
//#include “G4MTRunManager.hh”
#include “G4UImanager.hh”
#include “G4VisManager.hh”
#include “G4VisExecutive.hh”
#include “G4UIExecutive.hh”
//#include “QGSP_BERT.hh”

#include “construction.hh”
#include “physics.hh”
#include “action.hh”

int main(int argc, char** argv)
{
//G4UIExecutive* ui = 0;

// #ifdef G4MULTITHREADED
// G4MTRunManager* runManager = new G4MTRunManager;
//#else
G4RunManager* runManager = new G4RunManager;
//#endif
// runManager->Initialize();
G4UIExecutive *ui = new G4UIExecutive(argc, argv);

G4VisManager *visManager = new G4VisExecutive();
visManager->Initialize();

G4UImanager *UImanager = G4UImanager::GetUIpointer();
runManager->SetUserInitialization(new MyDetectorConstruction());

runManager->SetUserInitialization(new MyPhysicsList());

runManager->SetUserInitialization(new MyActionInitialization());
runManager->Initialize();
//G4VModularPhysicsList* physics = new QGSP_BERT();
//physics->RegisterPhysics(new G4DecayPhysics());
//runManager->SetUserInitialization(physics);

//if (argc == 1)
// {
// ui = new G4UIExecutive(argc, argv);
// }

// if(ui)
// {
UImanager->ApplyCommand(“/vis/open OGL”);
UImanager->ApplyCommand(“/vis/viewer/set/viewpointVector 1 1 1”);
UImanager->ApplyCommand(“/vis/drawVolume”);
UImanager->ApplyCommand(“/vis/viewer/set/autoRefresh true”);

  UImanager->ApplyCommand("vis/scene/add/trajectories smooth");
 
 
 
    ui->SessionStart();
//}
//else
// {
// G4String command = "/control/execute ";
// G4String fileName = argv[1];
// UImanager->ApplyCommand(command+fileName);
// }

return 0;
}

and Physics list is as follows:
#include “physics.hh”

MyPhysicsList::MyPhysicsList()
{
RegisterPhysics (new G4EmStandardPhysics());
RegisterPhysics (new G4OpticalPhysics());

}

MyPhysicsList::~MyPhysicsList()
{}
and Primmary Generator action is as follows:
#include “generator.hh”

MyPrimaryGenerator::MyPrimaryGenerator()
{
fParticleGun = new G4ParticleGun(1);
}

MyPrimaryGenerator::~MyPrimaryGenerator()
{
delete fParticleGun;
}

void MyPrimaryGenerator::GeneratePrimaries(G4Event anEvent)
{
G4ParticleTable particleTable = G4ParticleTable::GetParticleTable();
G4String particleName=“gamma”;
G4ParticleDefinition* particle = particleTable->FindParticle(“gamma”);

G4ThreeVector pos(0.,0.,0.);
G4ThreeVector mom(0.,0.,1.);
fParticleGun->SetParticlePosition(pos);
fParticleGun->SetParticleMomentumDirection(mom);
fParticleGun->SetParticleMomentum(10.*GeV);
fParticleGun->SetParticleDefinition(particle);
fParticleGun->GeneratePrimaryVertex(anEvent);

}`


I’d suggest just using the builtin physics list, so

runManager->SetUserInitialization(new QGSP_BERT());
runManager->SetUserInitialization(new MyActionInitialization());
runManager->Initialize();

to begin with. Check that this runs and you can see particles first, then see the Optical Extended Examples for examples of how to add optical physics and particles to the physics list.

Ok thanks I will check and update


I can still see no photons

Sorry for the delay in replying - the next step is now to look at examples like OpNovice and OpNovice2 to add the needed particles and processes via the builtin physics lists. E.g. see

in conjunction with the Optical physics section of the Application Developer Manual