Target made by 2 materials

Hello, I should simulate a 2 material target like in the figure


it’ s a circular target, the inner (Green) part is made in Be (or C) and the outer one (blue) in other material.

I know how to build it because I can make it using the G4bool with 2 G4tubs ie.

G4Tubs* InnerTub;
G4Tubs* OuterTub;
G4VSolid* TargetSolid; 
G4ThreeVector position(0,0,0);

InnerTub = new G4Tubs("InnerTub",  0, 0.25*cm, 1.5*mm, 0., 2*pi); 
OuterTub = new G4Tubs("OuterTub",  0, 0.75*cm, 1.5*mm, 0., 2*pi); 
TargetSolid = new G4IntersectionSolid("TargetSolid", OuterTub, InnerTub, &identity, position);

My problem is to assign the material, because when I build the logical volume

G4LogicalVolume* logicEnv;   
logicEnv= new G4LogicalVolume(TargetSolid, TargMat, "Target"); 

it assign the material “TargMat” to all the solid…instead I need only one logical volume but made of two differents material…How can I do it?

Thank you

In your case Boolean operations are not needed, just place the inner target into the outer target.

Hello, @evc thank you…but I need that the logical volume is only one…I explain.
In my stepping action, for example, to get muons outgoing the target I’ve

if(NextVol && ThisVol->GetName()=="Target" && NextVol->GetName()=="World" && step->GetTrack()->GetParentID()!=00 && (step->GetTrack()->GetDynamicParticle()->GetPDGcode()==13 || step->GetTrack()->GetDynamicParticle()->GetPDGcode()==-13)) { 

and to get the deposited energy in the target I’ve

if (volume == fScoringVolume) {
  G4double edepStep = step->GetTotalEnergyDeposit();

where fScoringVolume = logicEnv;

then if I build two different solids, for Geant they will be two different targets…instead it should be only one solid but having tow different materials…

since you only check for particles going from “Target” to “World”, you don’t need the logical volume to be “only one”. The inner volume does not have an interface to “World”, correct?

besides, I don’t think that it is possible to have a physical volume with different materials in different parts…

Hello @weller

the inner volume has interface with the world (ie. the 2 faces of the cylinder).

And is it possible to build two logical volumes like

 logicEnv1= new G4LogicalVolume(InnerTub, TargMat1, "TargetIn");    
    logicEnv2 = new G4LogicalVolume(OuterTub, TargMat2, "TargetOut"); 

then consider their sum



In that case, can you adjust the if-clause to contain both logicals?

sorry I mixed up physical and logical, I don’t think its possible to have a logical volume with different materials in different parts. As I understand, this is against how the concept of navigation/tracking is implemented in geant4.

what you could also try is to create/use a parallel world, and overwrite the material of the outer volume with a different material for only the child/inner volume. question is if that is better or less efficient than changing the if-condition!?

Hello @weller, I saw it’s imppsoible to sum 2 logical volumes …maybe the only way to get the deposited energy in all the target is to make channels…do you know how to do it?

with “channels” you mean something like this?

I would go through the example your code is probably based on (both .cc and .hh files) and look for all related lines and get inspired… duplicating these lines and adjusting for a second channel (if I understand you correctly) should be more or less straight forward.

Besides, I still wonder if you cannot simply add the second volume to your “if-statement”?

if(NextVol && (ThisVol->GetName()=="Target" || ThisVol->GetName()=="OtherTarget") && NextVol->GetName()=="World" && step->GetTrack()->GetParentID()!=00 && (step->GetTrack()->GetDynamicParticle()->GetPDGcode()==13 || step->GetTrack()->GetDynamicParticle()->GetPDGcode()==-13)) { 

Hello @weller I actually don’t know what is the channel…but I know that a researcher of my group simulated a calorimeter made by many layouts and he unified 2 layouts in one channel i.e. the deposited energy in two layout is stored together in one channel