fix: code style

This commit is contained in:
liuyihui 2023-02-13 15:48:31 +08:00
parent dbc12a3d02
commit b1e07c6ade
8 changed files with 26 additions and 61 deletions

View File

@ -1,14 +1,11 @@
#ifndef GENEANALYSISMANAGER_HH #ifndef GENEANALYSISMANAGER_HH
#define GENEANALYSISMANAGER_HH 1 #define GENEANALYSISMANAGER_HH 1
#define ANALYSIS_USE
#include "globals.hh"
#ifdef ANALYSIS_USE
#include "TFile.h" #include "TFile.h"
#include "TROOT.h" #include "TROOT.h"
#include "TTree.h" #include "TTree.h"
#endif
#include "globals.hh"
struct detEvent { struct detEvent {
G4double Thetacm; G4double Thetacm;
@ -37,24 +34,20 @@ public:
void FillAng(G4double thetacm, G4double thetalab); void FillAng(G4double thetacm, G4double thetalab);
void FillDetData(G4int ndets, G4double *edet, G4int *ndet); void FillDetData(G4int ndets, G4double *edet, G4int *ndet);
// void EventNo(); // void EventNo();
#ifdef ANALYSIS_USE
void book(); void book();
void FillTree(); void FillTree();
void save(); void save();
#endif
private: private:
static GeneAnalysisManager *instance; static GeneAnalysisManager *instance;
struct detEvent mydata; struct detEvent mydata;
// G4int evtNo; // G4int evtNo;
G4String analysisFileName; G4String analysisFileName;
#ifdef ANALYSIS_USE
TFile *theTFile; TFile *theTFile;
TTree *tr; TTree *tr;
#endif
}; };
#endif #endif

View File

@ -2,24 +2,16 @@
GeneAnalysisManager* GeneAnalysisManager::instance = 0; GeneAnalysisManager* GeneAnalysisManager::instance = 0;
GeneAnalysisManager::GeneAnalysisManager() GeneAnalysisManager::GeneAnalysisManager() : analysisFileName("Simulation_C13an.root"), theTFile(0), tr(0) {
#ifdef ANALYSIS_USE // evtNo = 0;
: analysisFileName("Simulation_C13an.root"),
theTFile(0),
tr(0)
#endif
{
// evtNo = 0;
memset(&mydata, 0x00, sizeof(mydata)); memset(&mydata, 0x00, sizeof(mydata));
} }
GeneAnalysisManager::~GeneAnalysisManager() { GeneAnalysisManager::~GeneAnalysisManager() {
#ifdef ANALYSIS_USE
delete theTFile; delete theTFile;
theTFile = 0; theTFile = 0;
delete tr; delete tr;
tr = 0; tr = 0;
#endif
} }
GeneAnalysisManager* GeneAnalysisManager::GetInstance() { GeneAnalysisManager* GeneAnalysisManager::GetInstance() {
@ -42,13 +34,8 @@ void GeneAnalysisManager::FillAng(G4double thetacm, G4double thetalab) {
mydata.Thetalab = thetalab; mydata.Thetalab = thetalab;
} }
/* // void GeneAnalysisManager::EventNo() { evtNo++; }
void GeneAnalysisManager::EventNo(){
evtNo++;
}
*/
#ifdef ANALYSIS_USE
void GeneAnalysisManager::book() { void GeneAnalysisManager::book() {
// delete all associated variables created via new, moreover it delete itself. // delete all associated variables created via new, moreover it delete itself.
if (theTFile != 0) delete theTFile; if (theTFile != 0) delete theTFile;
@ -75,8 +62,6 @@ void GeneAnalysisManager::save() {
theTFile->Write(); theTFile->Write();
theTFile->Close(); theTFile->Close();
} }
// evtNo = 0; // evtNo = 0;
// G4cout<<" --> reactNum: "<< reactNum <<G4endl; // 4cout<<" --> reactNum: "<< reactNum <<G4endl;
} }
#endif

View File

@ -121,9 +121,9 @@ G4VPhysicalVolume* GeneDetectorConstruction::Construct() {
G4VisAttributes* He3active_vis = new G4VisAttributes(G4Colour(1.0, 0.0, 0.0)); G4VisAttributes* He3active_vis = new G4VisAttributes(G4Colour(1.0, 0.0, 0.0));
He3active_vis->SetForceSolid(true); He3active_vis->SetForceSolid(true);
He3active_log->SetVisAttributes(He3active_vis); He3active_log->SetVisAttributes(He3active_vis);
// He3gas_log -> SetVisAttributes(G4VisAttributes::GetInvisible); // He3gas_log -> SetVisAttributes(G4VisAttributes::GetInvisible);
He3tub_log->SetVisAttributes(G4VisAttributes::GetInvisible); He3tub_log->SetVisAttributes(G4VisAttributes::GetInvisible);
// He3active_log -> SetVisAttributes(G4VisAttributes::GetInvisible); // He3active_log -> SetVisAttributes(G4VisAttributes::GetInvisible);
G4SubtractionSolid* solid_PE = new G4SubtractionSolid("solid_PE", PE_box, PE_hole); G4SubtractionSolid* solid_PE = new G4SubtractionSolid("solid_PE", PE_box, PE_hole);
G4SubtractionSolid* sub_BPE = new G4SubtractionSolid("sub_BPE", BPE_box, PE_box); G4SubtractionSolid* sub_BPE = new G4SubtractionSolid("sub_BPE", BPE_box, PE_box);
@ -161,12 +161,12 @@ G4VPhysicalVolume* GeneDetectorConstruction::Construct() {
// PE_vis->SetForceWireframe(true); // PE_vis->SetForceWireframe(true);
PE_log->SetVisAttributes(PE_vis); PE_log->SetVisAttributes(PE_vis);
// G4VisAttributes* BPE_vis= new G4VisAttributes(G4Colour(1.0,1.0,1.0,0.1)); // G4VisAttributes* BPE_vis= new G4VisAttributes(G4Colour(1.0,1.0,1.0,0.1));
// BPE_vis->SetForceSolid(true); // BPE_vis->SetForceSolid(true);
// BPE_vis->SetForceWireframe(true); // BPE_vis->SetForceWireframe(true);
// BPE_log->SetVisAttributes(BPE_vis); // BPE_log->SetVisAttributes(BPE_vis);
// PE_log -> SetVisAttributes(G4VisAttributes::GetInvisible); // PE_log -> SetVisAttributes(G4VisAttributes::GetInvisible);
BPE_log->SetVisAttributes(G4VisAttributes::GetInvisible); BPE_log->SetVisAttributes(G4VisAttributes::GetInvisible);
G4double posz = tube_hole_len - 0.5 * BPE_xyz - 0.5 * tube_len; G4double posz = tube_hole_len - 0.5 * BPE_xyz - 0.5 * tube_len;
@ -258,10 +258,10 @@ G4VPhysicalVolume* GeneDetectorConstruction::Construct() {
CuSubstrate_log1->SetVisAttributes(CuSub_vis); CuSubstrate_log1->SetVisAttributes(CuSub_vis);
CuSubstrate_log2->SetVisAttributes(CuSub_vis); CuSubstrate_log2->SetVisAttributes(CuSub_vis);
CuSubstrate_log3->SetVisAttributes(CuSub_vis); CuSubstrate_log3->SetVisAttributes(CuSub_vis);
// CuSubstrate_log0 -> SetVisAttributes(G4VisAttributes::GetInvisible); // CuSubstrate_log0 -> SetVisAttributes(G4VisAttributes::GetInvisible);
// CuSubstrate_log1 -> SetVisAttributes(G4VisAttributes::GetInvisible); // CuSubstrate_log1 -> SetVisAttributes(G4VisAttributes::GetInvisible);
// CuSubstrate_log2 -> SetVisAttributes(G4VisAttributes::GetInvisible); // CuSubstrate_log2 -> SetVisAttributes(G4VisAttributes::GetInvisible);
// CuSubstrate_log3 -> SetVisAttributes(G4VisAttributes::GetInvisible); // CuSubstrate_log3 -> SetVisAttributes(G4VisAttributes::GetInvisible);
// Target flange // Target flange
G4double flange0_thickness = 9.0 * mm; G4double flange0_thickness = 9.0 * mm;

View File

@ -15,7 +15,7 @@ GeneDetectorConstructionMessenger::GeneDetectorConstructionMessenger(GeneDetecto
ZoffsetCmd->SetGuidance("Set detector Z offset"); ZoffsetCmd->SetGuidance("Set detector Z offset");
ZoffsetCmd->SetParameterName("Zoffset", false); ZoffsetCmd->SetParameterName("Zoffset", false);
ZoffsetCmd->SetUnitCategory("Length"); ZoffsetCmd->SetUnitCategory("Length");
// ZoffsetCmd->SetRange("Zoffset>0"); // ZoffsetCmd->SetRange("Zoffset>0");
ZoffsetCmd->AvailableForStates(G4State_PreInit, G4State_Idle); ZoffsetCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
ZactiveshiftCmd = new G4UIcmdWithADoubleAndUnit("/Gene/Detector/SetZactiveshift", this); ZactiveshiftCmd = new G4UIcmdWithADoubleAndUnit("/Gene/Detector/SetZactiveshift", this);

View File

@ -16,8 +16,6 @@
#include "GeneHe3detHit.hh" #include "GeneHe3detHit.hh"
#include "Randomize.hh" #include "Randomize.hh"
#define ANALYSIS_USE
GeneEventAction::GeneEventAction() : GeneHe3detSDCollID(-1), drawFlag("non") {} GeneEventAction::GeneEventAction() : GeneHe3detSDCollID(-1), drawFlag("non") {}
GeneEventAction::~GeneEventAction() {} GeneEventAction::~GeneEventAction() {}
@ -33,7 +31,7 @@ void GeneEventAction::BeginOfEventAction(const G4Event* evt) {
} }
void GeneEventAction::EndOfEventAction(const G4Event* evt) { void GeneEventAction::EndOfEventAction(const G4Event* evt) {
// G4int event_id = evt->GetEventID(); // G4int event_id = evt->GetEventID();
G4HCofThisEvent* HCE = evt->GetHCofThisEvent(); G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
GeneHe3detHitsCollection* GeneHe3detHC = 0; GeneHe3detHitsCollection* GeneHe3detHC = 0;
GeneAnalysisManager* analysisManager = GeneAnalysisManager::GetInstance(); GeneAnalysisManager* analysisManager = GeneAnalysisManager::GetInstance();
@ -65,15 +63,13 @@ void GeneEventAction::EndOfEventAction(const G4Event* evt) {
} }
} }
analysisManager->FillDetData(cpNo, Etot, Ndet); analysisManager->FillDetData(cpNo, Etot, Ndet);
// analysisManager->EventNo(); // evtNo++ only for detected events // analysisManager->EventNo(); // evtNo++ only for detected events
#ifdef ANALYSIS_USE
analysisManager->FillTree(); analysisManager->FillTree();
#endif
} }
} }
} }
// G4cout<<"--> EndOfEventAction in EventAction"<<G4endl; // G4cout<<"--> EndOfEventAction in EventAction"<<G4endl;
if (drawFlag == "all") drawtracks(evt); if (drawFlag == "all") drawtracks(evt);
} }

View File

@ -27,9 +27,9 @@ G4bool GeneHe3detSD::ProcessHits(G4Step* aStep, G4TouchableHistory*) {
G4double edep = aStep->GetTotalEnergyDeposit(); G4double edep = aStep->GetTotalEnergyDeposit();
G4ParticleDefinition* particleType = aStep->GetTrack()->GetDefinition(); G4ParticleDefinition* particleType = aStep->GetTrack()->GetDefinition();
G4String particleName = particleType->GetParticleName(); G4String particleName = particleType->GetParticleName();
// G4double stepl = 0.; // G4double stepl = 0.;
// if (particleType->GetPDGCharge() != 0.) // if (particleType->GetPDGCharge() != 0.)
// stepl = aStep->GetStepLength(); // stepl = aStep->GetStepLength();
if (particleName == "opticalphoton") return false; if (particleName == "opticalphoton") return false;
if ((edep == 0.)) return false; if ((edep == 0.)) return false;

View File

@ -15,8 +15,6 @@
#include "fstream" #include "fstream"
#define ANALYSIS_USE
GenePrimaryGeneratorAction::GenePrimaryGeneratorAction() { GenePrimaryGeneratorAction::GenePrimaryGeneratorAction() {
G4int n_particle = 1; G4int n_particle = 1;
particleGun = new G4ParticleGun(n_particle); particleGun = new G4ParticleGun(n_particle);
@ -190,10 +188,8 @@ void GenePrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent) {
G4double y0 = std::sin(thetalabr) * std::sin(phi); G4double y0 = std::sin(thetalabr) * std::sin(phi);
G4double z0 = std::cos(thetalabr); G4double z0 = std::cos(thetalabr);
#ifdef ANALYSIS_USE
GeneAnalysisManager* analysisManager = GeneAnalysisManager::GetInstance(); GeneAnalysisManager* analysisManager = GeneAnalysisManager::GetInstance();
analysisManager->FillAng(thetacmr, thetalabr); analysisManager->FillAng(thetacmr, thetalabr);
#endif
particleGun->SetParticleMomentumDirection(G4ThreeVector(x0, y0, z0)); particleGun->SetParticleMomentumDirection(G4ThreeVector(x0, y0, z0));

View File

@ -8,7 +8,6 @@
#include "GeneAnalysisManager.hh" #include "GeneAnalysisManager.hh"
#include "GeneRunActionMessenger.hh" #include "GeneRunActionMessenger.hh"
#define ANALYSIS_USE
GeneRunAction::GeneRunAction() : G4UserRunAction() { GeneRunAction::GeneRunAction() : G4UserRunAction() {
RunNo = "00"; RunNo = "00";
pMessenger = new GeneRunActionMessenger(this); pMessenger = new GeneRunActionMessenger(this);
@ -23,13 +22,11 @@ void GeneRunAction::BeginOfRunAction(const G4Run*) {
UI->ApplyCommand("/vis/scene/notifyHandlers"); UI->ApplyCommand("/vis/scene/notifyHandlers");
} }
#ifdef ANALYSIS_USE
GeneAnalysisManager* analysisManager = GeneAnalysisManager::GetInstance(); GeneAnalysisManager* analysisManager = GeneAnalysisManager::GetInstance();
G4String sFileName = "Simulation_RunNo" + RunNo + ".root"; G4String sFileName = "Simulation_RunNo" + RunNo + ".root";
analysisManager->SetAnalysisFileName(sFileName); analysisManager->SetAnalysisFileName(sFileName);
// Open an output file // Open an output file
analysisManager->book(); analysisManager->book();
#endif
} }
void GeneRunAction::EndOfRunAction(const G4Run*) { void GeneRunAction::EndOfRunAction(const G4Run*) {
@ -38,8 +35,6 @@ void GeneRunAction::EndOfRunAction(const G4Run*) {
G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/update"); G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/update");
} }
#ifdef ANALYSIS_USE
GeneAnalysisManager* analysisManager = GeneAnalysisManager::GetInstance(); GeneAnalysisManager* analysisManager = GeneAnalysisManager::GetInstance();
analysisManager->save(); analysisManager->save();
#endif
} }