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;
@ -39,11 +36,9 @@ public:
// 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;
@ -52,9 +47,7 @@ private:
// 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
: analysisFileName("Simulation_C13an.root"),
theTFile(0),
tr(0)
#endif
{
// evtNo = 0; // 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;
@ -76,7 +63,5 @@ void GeneAnalysisManager::save() {
theTFile->Close(); theTFile->Close();
} }
// evtNo = 0; // evtNo = 0;
// G4cout<<" --> reactNum: "<< reactNum <<G4endl; // 4cout<<" --> reactNum: "<< reactNum <<G4endl;
} }
#endif

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() {}
@ -66,9 +64,7 @@ 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
} }
} }
} }

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
} }