From dbc12a3d02907aba0b7648a68fc5b03adce130a5 Mon Sep 17 00:00:00 2001 From: liuyihui Date: Mon, 13 Feb 2023 15:10:21 +0800 Subject: [PATCH] fix: code style, include path --- .gitignore | 1 + .vscode/c_cpp_properties.json | 5 +++-- include/GeneHe3detHit.hh | 8 -------- include/GeneHe3detSD.hh | 2 -- main.cpp | 2 +- src/GeneDetectorConstruction.cc | 6 +++--- src/GeneEventAction.cc | 7 ------- src/GeneHe3detHit.cc | 15 --------------- src/GeneHe3detSD.cc | 18 ------------------ src/GeneRunAction.cc | 1 - vis.mac | 2 ++ 11 files changed, 10 insertions(+), 57 deletions(-) diff --git a/.gitignore b/.gitignore index e40a34f..b925cfd 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ lib/ # Data *.root +*.data diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index ce03177..b12b0a0 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -5,8 +5,9 @@ "includePath": [ "${default}", "${workspaceFolder}/include", - "/home/fox/G4Kit/Geant4/include", - "/home/fox/G4Kit/ROOT/include" + "/home/fox/G4Kit/ROOT/include", + "/home/fox/G4Kit/CLHEP/include", + "/home/fox/G4Kit/Geant4/include/Geant4" ], "defines": [ "_DEBUG", diff --git a/include/GeneHe3detHit.hh b/include/GeneHe3detHit.hh index e088f1f..eeac527 100644 --- a/include/GeneHe3detHit.hh +++ b/include/GeneHe3detHit.hh @@ -6,8 +6,6 @@ #include "G4ThreeVector.hh" #include "G4VHit.hh" -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... - class GeneHe3detHit : public G4VHit { public: GeneHe3detHit(); @@ -46,22 +44,16 @@ private: G4double particleEnergy; }; -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... - typedef G4THitsCollection GeneHe3detHitsCollection; extern G4Allocator GeneHe3detHitAllocator; -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... - inline void* GeneHe3detHit::operator new(size_t) { void* aHit; aHit = (void*)GeneHe3detHitAllocator.MallocSingle(); return aHit; } -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... - inline void GeneHe3detHit::operator delete(void* aHit) { GeneHe3detHitAllocator.FreeSingle((GeneHe3detHit*)aHit); } #endif diff --git a/include/GeneHe3detSD.hh b/include/GeneHe3detSD.hh index 5091e9c..23c9322 100644 --- a/include/GeneHe3detSD.hh +++ b/include/GeneHe3detSD.hh @@ -8,8 +8,6 @@ class G4Step; class G4HCofThisEvent; -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... - class GeneHe3detSD : public G4VSensitiveDetector { public: GeneHe3detSD(G4String); diff --git a/main.cpp b/main.cpp index 282b36e..7f2eb2d 100644 --- a/main.cpp +++ b/main.cpp @@ -17,7 +17,7 @@ #include "Randomize.hh" int main(int argc, char **argv) { - G4UIExecutive* ui = nullptr; + G4UIExecutive *ui = nullptr; if (argc == 1) ui = new G4UIExecutive(argc, argv); gROOT->GetInterpreter(); diff --git a/src/GeneDetectorConstruction.cc b/src/GeneDetectorConstruction.cc index 24e70dc..a59c73d 100644 --- a/src/GeneDetectorConstruction.cc +++ b/src/GeneDetectorConstruction.cc @@ -39,9 +39,9 @@ G4VPhysicalVolume* GeneDetectorConstruction::Construct() { // world G4Material* Air = manager->FindOrBuildMaterial("G4_AIR"); G4double world_xyz = 2. * m; - G4Box* solidWorld = new G4Box("world_S", 0.5 * world_xyz, 0.5 * world_xyz, 0.5 * world_xyz); - logicalWorld = new G4LogicalVolume(solidWorld, Air, "world_L", 0, 0, 0); - physicalWorld = new G4PVPlacement(0, G4ThreeVector(), "world_P", logicalWorld, + G4Box* solidWorld = new G4Box("world", 0.5 * world_xyz, 0.5 * world_xyz, 0.5 * world_xyz); + logicalWorld = new G4LogicalVolume(solidWorld, Air, "world", 0, 0, 0); + physicalWorld = new G4PVPlacement(0, G4ThreeVector(), "world", logicalWorld, NULL, // mother volume false, // no boolean operation 0); // copy number diff --git a/src/GeneEventAction.cc b/src/GeneEventAction.cc index e72b095..56e1122 100644 --- a/src/GeneEventAction.cc +++ b/src/GeneEventAction.cc @@ -17,16 +17,11 @@ #include "Randomize.hh" #define ANALYSIS_USE -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... GeneEventAction::GeneEventAction() : GeneHe3detSDCollID(-1), drawFlag("non") {} -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... - GeneEventAction::~GeneEventAction() {} -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... - void GeneEventAction::BeginOfEventAction(const G4Event* evt) { G4int evtNb = evt->GetEventID(); if (evtNb % 1000 == 0) G4cout << "Event No." << evtNb << G4endl; @@ -37,8 +32,6 @@ void GeneEventAction::BeginOfEventAction(const G4Event* evt) { } } -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... - void GeneEventAction::EndOfEventAction(const G4Event* evt) { // G4int event_id = evt->GetEventID(); G4HCofThisEvent* HCE = evt->GetHCofThisEvent(); diff --git a/src/GeneHe3detHit.cc b/src/GeneHe3detHit.cc index 1d5ec55..e11ba20 100644 --- a/src/GeneHe3detHit.cc +++ b/src/GeneHe3detHit.cc @@ -10,8 +10,6 @@ G4Allocator GeneHe3detHitAllocator; -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... - GeneHe3detHit::GeneHe3detHit() { cpNo = -1; edep = 0.; @@ -21,12 +19,8 @@ GeneHe3detHit::GeneHe3detHit() { particleEnergy = 0.; } -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... - GeneHe3detHit::~GeneHe3detHit() { ; } -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... - GeneHe3detHit::GeneHe3detHit(const GeneHe3detHit& right) : G4VHit(right) { cpNo = right.cpNo; edep = right.edep; @@ -36,8 +30,6 @@ GeneHe3detHit::GeneHe3detHit(const GeneHe3detHit& right) : G4VHit(right) { particleEnergy = right.particleEnergy; } -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... - const GeneHe3detHit& GeneHe3detHit::operator=(const GeneHe3detHit& right) { cpNo = right.cpNo; edep = right.edep; @@ -48,18 +40,11 @@ const GeneHe3detHit& GeneHe3detHit::operator=(const GeneHe3detHit& right) { return *this; } -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... - int GeneHe3detHit::operator==(const GeneHe3detHit& right) const { return (this == &right) ? 1 : 0; } -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... void GeneHe3detHit::Draw() { ; } -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... - void GeneHe3detHit::Print() { G4cout << " He3 detector hitcollection: " << std::setw(5) << G4BestUnit(edep, "Energy") << ", at " << G4BestUnit(pos, "Length") << G4endl; } - -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... diff --git a/src/GeneHe3detSD.cc b/src/GeneHe3detSD.cc index 431bd4b..2ab7a4b 100644 --- a/src/GeneHe3detSD.cc +++ b/src/GeneHe3detSD.cc @@ -10,27 +10,19 @@ #include "G4ios.hh" #include "GeneHe3detHit.hh" -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... - GeneHe3detSD::GeneHe3detSD(G4String name) : G4VSensitiveDetector(name) { G4String HCname = "GeneHe3detHitCollection"; collectionName.insert(HCname); } -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... - GeneHe3detSD::~GeneHe3detSD() {} -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... - void GeneHe3detSD::Initialize(G4HCofThisEvent*) { scintillatorCollection = new GeneHe3detHitsCollection(SensitiveDetectorName, collectionName[0]); HitID = -1; } -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... - G4bool GeneHe3detSD::ProcessHits(G4Step* aStep, G4TouchableHistory*) { G4double edep = aStep->GetTotalEnergyDeposit(); G4ParticleDefinition* particleType = aStep->GetTrack()->GetDefinition(); @@ -59,8 +51,6 @@ G4bool GeneHe3detSD::ProcessHits(G4Step* aStep, G4TouchableHistory*) { return true; } -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... - void GeneHe3detSD::EndOfEvent(G4HCofThisEvent* HCE) { G4String HCname = collectionName[0]; static G4int HCID = -1; @@ -72,16 +62,8 @@ void GeneHe3detSD::EndOfEvent(G4HCofThisEvent* HCE) { if (verboseLevel >= 2) scintillatorCollection->PrintAllHits(); } -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... - void GeneHe3detSD::clear() {} -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... - void GeneHe3detSD::DrawAll() {} -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... - void GeneHe3detSD::PrintAll() {} - -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... diff --git a/src/GeneRunAction.cc b/src/GeneRunAction.cc index b23056b..8f02d21 100644 --- a/src/GeneRunAction.cc +++ b/src/GeneRunAction.cc @@ -31,7 +31,6 @@ void GeneRunAction::BeginOfRunAction(const G4Run*) { analysisManager->book(); #endif } -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... void GeneRunAction::EndOfRunAction(const G4Run*) { // Run ended, update the visualization diff --git a/vis.mac b/vis.mac index ebdbbad..bbd8762 100644 --- a/vis.mac +++ b/vis.mac @@ -20,6 +20,8 @@ # 设置颜色 /vis/viewer/set/style surface +# 设置 World 不可见 +/vis/geometry/set/visibility world 0 false # 坐标轴 /vis/scene/add/scale # Simple scale line