change: AlAlloyS5 to Al;add: output

This commit is contained in:
liuyihui 2022-05-19 15:41:19 +08:00
parent a6dcf70dbf
commit c7c96ac270
8 changed files with 39 additions and 32 deletions

View File

@ -131,7 +131,10 @@
"senum": "cpp", "senum": "cpp",
"value": "cpp", "value": "cpp",
"ntuple": "cpp", "ntuple": "cpp",
"free_seg": "cpp" "free_seg": "cpp",
"base_histo": "cpp",
"c2d": "cpp",
"c3d": "cpp"
} }
} }
} }

View File

@ -22,7 +22,7 @@ public:
void SetPhantomModel(G4String); void SetPhantomModel(G4String);
void SetParticleType(G4String s) { particleType = s; }; void SetParticleType(G4String s) { particleType = s; };
void ConstructSDandField(); void ConstructSDandField();
G4String GetParticleType() const { return particleType; }; G4String GetParticleType() { return particleType; };
std::vector<G4String> GetSensitiveList() const { return sensitiveList; }; std::vector<G4String> GetSensitiveList() const { return sensitiveList; };
private: private:
@ -36,7 +36,7 @@ private:
private: private:
G4String sex = "Male"; G4String sex = "Male";
G4String model = "MIRD"; G4String model = "MIRD";
G4String particleType = "GCR_H"; G4String particleType = "TE";
std::vector<G4String> sensitiveList; std::vector<G4String> sensitiveList;
std::map<std::string, G4bool> sensitivities; std::map<std::string, G4bool> sensitivities;
G4HumanPhantomMaterial* material; G4HumanPhantomMaterial* material;

View File

@ -2,7 +2,6 @@
#define DESCSS_HumanPhantomMessenger_h 1 #define DESCSS_HumanPhantomMessenger_h 1
class DetectorConstruction; class DetectorConstruction;
class PrimaryGeneratorAction;
class G4UIcommand; class G4UIcommand;
class G4UIdirectory; class G4UIdirectory;

View File

@ -14,13 +14,12 @@ public:
PrimaryGeneratorAction(); PrimaryGeneratorAction();
~PrimaryGeneratorAction(); ~PrimaryGeneratorAction();
G4ParticleDefinition* DefineParticle();
virtual void GeneratePrimaries(G4Event*); virtual void GeneratePrimaries(G4Event*);
const G4ParticleGun* GetParticleGun() const { return fParticleGun; } void DefineParticle(G4String particleType);
const G4ParticleGun* GetParticleGun() const { return fParticleGun; };
private: private:
G4int Z; G4String particleType;
G4String particleType = "TE";
G4ParticleGun* fParticleGun = nullptr; G4ParticleGun* fParticleGun = nullptr;
}; };

View File

@ -9,6 +9,7 @@
#include "G4VisExecutive.hh" #include "G4VisExecutive.hh"
#include "QBBC.hh" #include "QBBC.hh"
int main(int argc, char** argv) { int main(int argc, char** argv) {
G4UIExecutive* ui = nullptr; G4UIExecutive* ui = nullptr;
if (argc == 1) ui = new G4UIExecutive(argc, argv); if (argc == 1) ui = new G4UIExecutive(argc, argv);

View File

@ -24,16 +24,17 @@ void DefineMaterials() {
// 5系铝合金 0.4 Si + 0.35 Fe + 0.1 Cu + 0.7 Mn + 4.5 Mg + 0.15 Cr + 0.25 Zn + 0.15 Ti + 93.4 Al // 5系铝合金 0.4 Si + 0.35 Fe + 0.1 Cu + 0.7 Mn + 4.5 Mg + 0.15 Cr + 0.25 Zn + 0.15 Ti + 93.4 Al
density = 2.68 * g / cm3; density = 2.68 * g / cm3;
G4Material* AlAlloyS5 = new G4Material("AluminumAlloySeries5", density, ncomponents = 9); G4Material* AlAlloyS5 = new G4Material("AluminumAlloySeries5", density, ncomponents = 1);
AlAlloyS5->AddElement(nist->FindOrBuildElement("Si"), fractionmass = .4 * perCent); // AlAlloyS5->AddElement(nist->FindOrBuildElement("Si"), fractionmass = .4 * perCent);
AlAlloyS5->AddElement(nist->FindOrBuildElement("Fe"), fractionmass = .35 * perCent); // AlAlloyS5->AddElement(nist->FindOrBuildElement("Fe"), fractionmass = .35 * perCent);
AlAlloyS5->AddElement(nist->FindOrBuildElement("Cu"), fractionmass = .1 * perCent); // AlAlloyS5->AddElement(nist->FindOrBuildElement("Cu"), fractionmass = .1 * perCent);
AlAlloyS5->AddElement(nist->FindOrBuildElement("Mn"), fractionmass = .7 * perCent); // AlAlloyS5->AddElement(nist->FindOrBuildElement("Mn"), fractionmass = .7 * perCent);
AlAlloyS5->AddElement(nist->FindOrBuildElement("Mg"), fractionmass = 4.5 * perCent); // AlAlloyS5->AddElement(nist->FindOrBuildElement("Mg"), fractionmass = 4.5 * perCent);
AlAlloyS5->AddElement(nist->FindOrBuildElement("Cr"), fractionmass = .15 * perCent); // AlAlloyS5->AddElement(nist->FindOrBuildElement("Cr"), fractionmass = .15 * perCent);
AlAlloyS5->AddElement(nist->FindOrBuildElement("Zn"), fractionmass = .25 * perCent); // AlAlloyS5->AddElement(nist->FindOrBuildElement("Zn"), fractionmass = .25 * perCent);
AlAlloyS5->AddElement(nist->FindOrBuildElement("Ti"), fractionmass = .15 * perCent); // AlAlloyS5->AddElement(nist->FindOrBuildElement("Ti"), fractionmass = .15 * perCent);
AlAlloyS5->AddElement(nist->FindOrBuildElement("Al"), fractionmass = 93.4 * perCent); // AlAlloyS5->AddElement(nist->FindOrBuildElement("Al"), fractionmass = 93.4 * perCent);
AlAlloyS5->AddElement(nist->FindOrBuildElement("Al"), fractionmass = 100. * perCent);
// 泰普龙 Taparan // 泰普龙 Taparan
density = 1.44 * g / cm3; density = 1.44 * g / cm3;

View File

@ -14,19 +14,17 @@ G4double M = 931.5;
G4double C1, C2, C3, C4, sum; G4double C1, C2, C3, C4, sum;
PrimaryGeneratorAction::PrimaryGeneratorAction() { PrimaryGeneratorAction::PrimaryGeneratorAction() {
G4ParticleDefinition* ion = DefineParticle(); DetectorConstruction* detConstruction =
fParticleGun = new G4ParticleGun(); (DetectorConstruction*)(G4RunManager::GetRunManager()->GetUserDetectorConstruction());
fParticleGun->SetParticleCharge(this->Z * eplus);
fParticleGun->SetParticleDefinition(ion);
const DetectorConstruction* detConstruction = fParticleGun = new G4ParticleGun();
static_cast<const DetectorConstruction*>(G4RunManager::GetRunManager()->GetUserDetectorConstruction());
particleType = detConstruction->GetParticleType(); particleType = detConstruction->GetParticleType();
DefineParticle(particleType);
} }
PrimaryGeneratorAction::~PrimaryGeneratorAction() { delete fParticleGun; } PrimaryGeneratorAction::~PrimaryGeneratorAction() { delete fParticleGun; }
G4ParticleDefinition* PrimaryGeneratorAction::DefineParticle() { void PrimaryGeneratorAction::DefineParticle(G4String particleType) {
G4double Z, A; G4double Z, A;
std::string tmp, line, name; std::string tmp, line, name;
std::ifstream modelFile("assets/model.txt"); std::ifstream modelFile("assets/model.txt");
@ -62,8 +60,8 @@ G4ParticleDefinition* PrimaryGeneratorAction::DefineParticle() {
else else
ion = G4IonTable::GetIonTable()->GetIon(Z, A, 0.); ion = G4IonTable::GetIonTable()->GetIon(Z, A, 0.);
this->Z = Z; fParticleGun->SetParticleCharge(Z * eplus);
return ion; fParticleGun->SetParticleDefinition(ion);
} }
G4double randomPhi() { G4double randomPhi() {
@ -162,6 +160,13 @@ void PrimaryGeneratorAction::GeneratePrimaries(G4Event* e) {
G4ThreeVector pos = randomPos(); G4ThreeVector pos = randomPos();
G4ThreeVector dir = randomDir(pos); G4ThreeVector dir = randomDir(pos);
DetectorConstruction* detConstruction =
(DetectorConstruction*)(G4RunManager::GetRunManager()->GetUserDetectorConstruction());
if (particleType != detConstruction->GetParticleType()) {
particleType = detConstruction->GetParticleType();
DefineParticle(particleType);
}
if (particleType == "TE") if (particleType == "TE")
E = ITM(0.1, 10, pdfTElectronInv); E = ITM(0.1, 10, pdfTElectronInv);
else if (particleType == "TP") else if (particleType == "TP")

View File

@ -55,15 +55,14 @@ void RunAction::EndOfRunAction(const G4Run* run) {
} }
if (IsMaster()) { if (IsMaster()) {
const DetectorConstruction* detConstruction = DetectorConstruction* detConstruction =
static_cast<const DetectorConstruction*>(G4RunManager::GetRunManager()->GetUserDetectorConstruction()); (DetectorConstruction*)(G4RunManager::GetRunManager()->GetUserDetectorConstruction());
std::ofstream edepFile("result/edep_" + detConstruction->GetParticleType() + ".txt"); std::ofstream edepFile("result/edep_" + detConstruction->GetParticleType() + ".txt");
for (int i = 0; i < sensitiveList.size(); i++) { for (int i = 0; i < sensitiveList.size(); i++) {
G4String name = sensitiveList[i]; G4String name = sensitiveList[i];
edepFile << "bodyPart: " << std::setw(30) << name << " | eDep: " << std::setw(15) edepFile << "bodyPart: " << std::setw(30) << name << " | eDep: " << std::setw(15) << edep[name] / MeV
<< edep[name] / MeV << " MeV | eDep2: " << std::setw(15) << " MeV | eDep2: " << std::setw(15) << edep2[name] / MeV << " MeV | rms: " << std::setw(15)
<< edep2[name] / MeV << " MeV | rms: " << std::setw(15)
<< rms[name] / MeV << " MeV" << G4endl; << rms[name] / MeV << " MeV" << G4endl;
} }