-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into lobis-cosmic-revamp
- Loading branch information
Showing
8 changed files
with
186 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?> | ||
|
||
<restG4> | ||
<globals> | ||
<parameter name="mainDataPath" value=""/> | ||
<parameter name="verboseLevel" value="essential"/> | ||
</globals> | ||
|
||
<TRestRun> | ||
<parameter name="experimentName" value="IsotropicWithRange"/> | ||
<parameter name="runType" value="simulation"/> | ||
<parameter name="runNumber" value="1"/> | ||
<parameter name="runTag" value="IsotropicWithRange"/> | ||
<parameter name="outputFileName" value="IsotropicWithRange.root"/> | ||
<parameter name="runDescription" value=""/> | ||
<parameter name="user" value="${USER}"/> | ||
<parameter name="overwrite" value="off"/> | ||
<parameter name="readOnly" value="false"/> | ||
</TRestRun> | ||
|
||
<TRestGeant4Metadata> | ||
<parameter name="gdmlFile" value="geometry/setup.gdml"/> | ||
<parameter name="seed" value="171981"/> | ||
<parameter name="nEvents" value="1000000"/> | ||
<parameter name="saveAllEvents" value="true"/> | ||
<generator type="surface" shape="circle" | ||
position="(0,100,0)mm" size="(400,0,0)mm" | ||
rotationAngle="90deg" rotationAxis="(1,0,0)"> | ||
<source particle="geantino"> | ||
<angular type="isotropic" direction="(0,-1,0)" coneHalfAngle="15deg"/> | ||
<energy type="mono" energy="10.0" units="MeV"/> | ||
</source> | ||
</generator> | ||
|
||
<detector> | ||
<parameter name="energyRange" value="(0,10)" units="GeV"/> | ||
<volume name="gasVolume" sensitive="true" maxStepSize="1mm"/> | ||
</detector> | ||
|
||
</TRestGeant4Metadata> | ||
|
||
<TRestGeant4PhysicsLists name="default" title="First physics list implementation"/> | ||
</restG4> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
#include <TRestGeant4Event.h> | ||
|
||
Int_t ValidateIsotropicWithRange(const char* filename) { | ||
cout << "Starting validation for '" << filename << "'" << endl; | ||
|
||
TRestRun run(filename); | ||
|
||
cout << "Run entries: " << run.GetEntries() << endl; | ||
if (run.GetEntries() != 1000000) { | ||
cout << "Bad number of entries: " << run.GetEntries() << endl; | ||
return 2; | ||
} | ||
|
||
auto metadata = (TRestGeant4Metadata*)run.GetMetadataClass("TRestGeant4Metadata"); | ||
TRestGeant4Event* event = run.GetInputEvent<TRestGeant4Event>(); | ||
TVector3 sourceDirection = metadata->GetParticleSource()->GetDirection(); | ||
cout << "original source direction: (" << sourceDirection.X() << ", " << sourceDirection.Y() << ", " | ||
<< sourceDirection.Z() << ")" << endl; | ||
|
||
constexpr double tolerance = 0.1; | ||
|
||
double thetaAverage = 0, thetaMin = TMath::Infinity(), thetaMax = 0; | ||
constexpr double thetaAverageRef = 10.0, thetaMinRef = 0.0, thetaMaxRef = 15.0; | ||
|
||
double energyPrimaryAverage = 0, energyPrimaryMin = TMath::Infinity(), energyPrimaryMax = 0; | ||
constexpr double energyPrimaryAverageRef = 10000.0, energyPrimaryMinRef = 10000.0, | ||
energyPrimaryMaxRef = 10000.0; | ||
|
||
for (int i = 0; i < run.GetEntries(); i++) { | ||
run.GetEntry(i); | ||
TVector3 direction = event->GetPrimaryEventDirection(); | ||
const auto theta = sourceDirection.Angle(direction) * TMath::RadToDeg(); | ||
|
||
thetaAverage += theta / run.GetEntries(); | ||
if (theta < thetaMin) { | ||
thetaMin = theta; | ||
} | ||
if (theta > thetaMax) { | ||
thetaMax = theta; | ||
} | ||
|
||
Double_t energy = event->GetPrimaryEventEnergy(); | ||
energyPrimaryAverage += energy / run.GetEntries(); | ||
if (energy < energyPrimaryMin) { | ||
energyPrimaryMin = energy; | ||
} | ||
if (energy > energyPrimaryMax) { | ||
energyPrimaryMax = energy; | ||
} | ||
} | ||
|
||
cout << "Average theta (deg): " << thetaAverage << endl; | ||
cout << "Minimum theta (deg): " << thetaMin << endl; | ||
cout << "Maximum theta (deg): " << thetaMax << endl; | ||
|
||
cout << "Average energy (keV): " << energyPrimaryAverage << endl; | ||
cout << "Minimum energy (keV): " << energyPrimaryMin << endl; | ||
cout << "Maximum energy (keV): " << energyPrimaryMax << endl; | ||
|
||
if (TMath::Abs(thetaAverage - thetaAverageRef) / thetaAverageRef > tolerance) { | ||
cout << "The average theta of the distribution is wrong!" << endl; | ||
cout << "thetaAverage (deg): " << thetaAverage << endl; | ||
return 3; | ||
} | ||
if (TMath::Abs(thetaMin - thetaMinRef) / (thetaMinRef + 1) > tolerance) { | ||
cout << "The minimum theta of the distribution is wrong!" << endl; | ||
cout << "thetaMin (deg): " << thetaMin << endl; | ||
return 4; | ||
} | ||
if (TMath::Abs(thetaMax - thetaMaxRef) / thetaMaxRef > tolerance) { | ||
cout << "The maximum theta of the distribution is wrong!" << endl; | ||
cout << "thetaMax (deg): " << thetaMax << endl; | ||
return 5; | ||
} | ||
|
||
if (TMath::Abs(energyPrimaryAverage - energyPrimaryAverageRef) / energyPrimaryAverageRef > tolerance) { | ||
cout << "The average energy of the distribution is wrong!" << endl; | ||
cout << "energyPrimaryAverage (keV): " << energyPrimaryAverage << endl; | ||
return 6; | ||
} | ||
if (TMath::Abs(energyPrimaryMin - energyPrimaryMinRef) / energyPrimaryMinRef > tolerance) { | ||
cout << "The minimum energy of the distribution is wrong!" << endl; | ||
cout << "energyPrimaryMin (keV): " << energyPrimaryMin << endl; | ||
return 7; | ||
} | ||
if (TMath::Abs(energyPrimaryMax - energyPrimaryMaxRef) / energyPrimaryMaxRef > tolerance) { | ||
cout << "The maximum energy of the distribution is wrong!" << endl; | ||
cout << "energyPrimaryMax (keV): " << energyPrimaryMax << endl; | ||
return 8; | ||
} | ||
|
||
cout << "All tests passed! [\033[32mOK\033[0m]\n"; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters