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
#define GENEANALYSISMANAGER_HH 1
#define ANALYSIS_USE
#include "globals.hh"
#ifdef ANALYSIS_USE
#include "TFile.h"
#include "TROOT.h"
#include "TTree.h"
#endif
#include "globals.hh"
struct detEvent {
G4double Thetacm;
@ -39,11 +36,9 @@ public:
// void EventNo();
#ifdef ANALYSIS_USE
void book();
void FillTree();
void save();
#endif
private:
static GeneAnalysisManager *instance;
@ -52,9 +47,7 @@ private:
// G4int evtNo;
G4String analysisFileName;
#ifdef ANALYSIS_USE
TFile *theTFile;
TTree *tr;
#endif
};
#endif

View File

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

View File

@ -16,8 +16,6 @@
#include "GeneHe3detHit.hh"
#include "Randomize.hh"
#define ANALYSIS_USE
GeneEventAction::GeneEventAction() : GeneHe3detSDCollID(-1), drawFlag("non") {}
GeneEventAction::~GeneEventAction() {}
@ -66,9 +64,7 @@ void GeneEventAction::EndOfEventAction(const G4Event* evt) {
}
analysisManager->FillDetData(cpNo, Etot, Ndet);
// analysisManager->EventNo(); // evtNo++ only for detected events
#ifdef ANALYSIS_USE
analysisManager->FillTree();
#endif
}
}
}

View File

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

View File

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