Problem 2450 - The speed of simulation slowed down from Geant4(10.3) due to the update of G4TwistedTub class
Summary: The speed of simulation slowed down from Geant4(10.3) due to the update of G...
Status: RESOLVED FIXED
Alias: None
Product: Geant4
Classification: Unclassified
Component: geometry/solids (show other problems)
Version: 10.3
Hardware: All All
: P4 minor
Assignee: Evgueni.Tcherniaev
URL:
Depends on:
Blocks:
 
Reported: 2021-12-06 09:30 CET by suntong
Modified: 2021-12-06 10:22 CET (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this problem.
Description suntong 2021-12-06 09:30:13 CET
Dear Geant4 Team,

We installed Geant4(10.3) and Geant4(10.2.p3) independently on CentOS7 and create a toyMC to simulate geantino going through the detector. The detector was constructed with G4TwistedTub and G4Hype only. We put only one G4Hype in the world and put G4TwistedTub in the G4Hype. The simulation is generating geantino from center toward outside with uniform distribution on space. The code for geometry definition is shown below and the full simple toyMC can be found at this link: https://code.ihep.ac.cn/suntong/toymc

//world
	G4Material* world_mat = nist->FindOrBuildMaterial("G4_AIR");
	G4Box* solidWorld = new G4Box("World",263.5*cm,263.5*cm,287.5*cm);
	G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld,world_mat,"World"); 
	G4VPhysicalVolume* physWorld = new G4PVPlacement(0,G4ThreeVector(),logicWorld,"World",0,false,0,checkOverlaps);
	logicWorld->SetVisAttributes(blue);
	//Envelope
	G4Hype* solidHype = new G4Hype("Hype",629.527*mm, 645.866*mm,0.0620536*rad,0.0636596*rad,1132*mm);
	G4LogicalVolume* logicHype = new G4LogicalVolume(solidHype,world_mat,"Hype"); 
	G4VPhysicalVolume* physHype = new G4PVPlacement(0,G4ThreeVector(),logicHype,"Hype",logicWorld,false,0,checkOverlaps);
	logicWorld->SetVisAttributes(red);
	// Shape 1
	G4int replicaNo;
	G4double spanAngle;
	replicaNo=240;
	spanAngle=360./replicaNo*deg;
	G4TwistedTubs* twistTub=new G4TwistedTubs("shape1", -0.22253*rad, 633.445*mm, 649.883*mm, 1132*mm, spanAngle);
	G4LogicalVolume* twistTub_log=new G4LogicalVolume(twistTub, world_mat,"shape1",0,0,0);
	twistTub_log->SetVisAttributes(green);
	//Put shape1 into world
	G4int j;
	for(j=replicaNo-1;j>-1;j--){
		G4RotationMatrix* cellRot=new G4RotationMatrix();
		cellRot->rotateZ(-spanAngle*j);
		std::ostringstream shapeName;
		shapeName<<"shape1_"<<j;
		G4VPhysicalVolume* twistTub_phys;
		twistTub_phys=new G4PVPlacement(cellRot,G4ThreeVector(0,0,0),twistTub_log,shapeName.str(),logicHype,false,j,checkOverlaps);
	}

Here are two tests I did:
1. Use the same toyMC for those two versions of Geant4. First, 1million geantino going through the detector on Geant4(10.3) and it takes 1148s to finish. Then 1million geantino going through the detector on Geant4(10.2.p3) and it takes 74s. 
2. Replace the src&include files of G4TwistedTub class in Geant4(10.3) with the files of same class in Geant4(10.2.p3), leave all other files of Geant4(10.3) unchanged. After replacing, redo the toyMC simulation on Geant4(10.3), it takes 64s to simulate 1million geantino going through the detector. More specifically, the definition of toyMC did not change on this two simulations and the only difference is to use different versions of G4TwistedTub in simulation. 

Based on the above, I suspect that the speed of simulation slowed down from Geant4(10.3) due to some update of the G4TwistedTub class from 10.2.p3 to 10.3. 
What is the reason can be for this?

Best regards,
Tong Sun
Comment 1 Evgueni.Tcherniaev 2021-12-06 10:22:27 CET
The reason of the slowdown was too large dimensions of a bounding box returned by BoundingLimits(), which resulted in non-optimal construction of the voxel structure.

An accurate calculation of the bounding box has been implemented and will be available in the upcoming Geant4.11