Skip to content

Commit

Permalink
Merge branch 'implement_MUSUN_input_generator' of github.com:MoritzNe…
Browse files Browse the repository at this point in the history
…uberger/remage into implement_MUSUN_input_generator
  • Loading branch information
MoritzNeuberger committed May 2, 2024
2 parents 44e9d08 + f4c3daa commit 7516259
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ __pycache__
*.dat

# python
.venv
.venv
1 change: 1 addition & 0 deletions include/RMGGeneratorMUSUNCosmicMuons.hh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class RMGGeneratorMUSUNCosmicMuons : public RMGVGenerator {
void GeneratePrimaries(G4Event* event);
virtual void SetParticlePosition(G4ThreeVector vec) override{};


void BeginOfRunAction(const G4Run*);
inline void EndOfRunAction(const G4Run*) {}

Expand Down
41 changes: 18 additions & 23 deletions src/RMGGeneratorMUSUNCosmicMuons.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,19 @@ void RMGGeneratorMUSUNCosmicMuons::BeginOfRunAction(const G4Run*) {
analysisReader->SetVerboseLevel(1);
analysisReader->SetFileName(fFileName);
G4int ntupleId = analysisReader->GetNtuple("MUSUN");
if(ntupleId < 0)
RMGLog::Out(RMGLog::fatal,
"MUSUN file not found!");

analysisReader->SetNtupleIColumn(0,"ID", fID );
analysisReader->SetNtupleIColumn(0,"type", fType );
analysisReader->SetNtupleDColumn(0,"Ekin", fEkin );
analysisReader->SetNtupleDColumn(0,"x", fX );
analysisReader->SetNtupleDColumn(0,"y", fY );
analysisReader->SetNtupleDColumn(0,"z", fZ );
analysisReader->SetNtupleDColumn(0,"theta", fTheta );
analysisReader->SetNtupleDColumn(0,"phi", fPhi );
analysisReader->SetNtupleDColumn(0,"px", fPx );
analysisReader->SetNtupleDColumn(0,"py", fPy );
analysisReader->SetNtupleDColumn(0,"pz", fPz );

if (ntupleId < 0) RMGLog::Out(RMGLog::fatal, "MUSUN file not found!");

analysisReader->SetNtupleIColumn(0, "ID", fID);
analysisReader->SetNtupleIColumn(0, "type", fType);
analysisReader->SetNtupleDColumn(0, "Ekin", fEkin);
analysisReader->SetNtupleDColumn(0, "x", fX);
analysisReader->SetNtupleDColumn(0, "y", fY);
analysisReader->SetNtupleDColumn(0, "z", fZ);
analysisReader->SetNtupleDColumn(0, "theta", fTheta);
analysisReader->SetNtupleDColumn(0, "phi", fPhi);
analysisReader->SetNtupleDColumn(0, "px", fPx);
analysisReader->SetNtupleDColumn(0, "py", fPy);
analysisReader->SetNtupleDColumn(0, "pz", fPz);
}


Expand All @@ -63,19 +60,19 @@ void RMGGeneratorMUSUNCosmicMuons::GeneratePrimaries(G4Event* event) {
fY * u::cm / u::m, fZ * u::cm / u::m);
fGun->SetParticlePosition({fX * u::cm, fY * u::cm, fZ * u::cm});

if(fTheta != 0 && fPhi != 0){
if (fTheta != 0 && fPhi != 0) {
G4ThreeVector d_cart(1, 1, 1);
d_cart.setTheta(fTheta); // in rad
d_cart.setPhi(fPhi); // in rad
d_cart.setMag(1 * u::m);
fGun->SetParticleMomentumDirection(d_cart);
RMGLog::OutFormat(RMGLog::debug, "...direction (θ,φ) = ({:.4g}, {:.4g}) deg", fTheta / u::deg,
fPhi / u::deg);
}
else{
} else {
G4ThreeVector d_cart(fPx, fPy, fPz);
fGun->SetParticleMomentumDirection(d_cart);
RMGLog::OutFormat(RMGLog::debug, "...direction (px,py,pz) = ({:.4g}, {:.4g}, {:.4g}) deg", fPx, fPy, fPz);
RMGLog::OutFormat(RMGLog::debug, "...direction (px,py,pz) = ({:.4g}, {:.4g}, {:.4g}) deg", fPx,
fPy, fPz);
}


Expand All @@ -85,9 +82,7 @@ void RMGGeneratorMUSUNCosmicMuons::GeneratePrimaries(G4Event* event) {
fGun->GeneratePrimaryVertex(event);
}

void RMGGeneratorMUSUNCosmicMuons::SetMUSUNFile(G4String fileName) {
fFileName = fileName;
}
void RMGGeneratorMUSUNCosmicMuons::SetMUSUNFile(G4String fileName) { fFileName = fileName; }

void RMGGeneratorMUSUNCosmicMuons::DefineCommands() {

Expand Down

0 comments on commit 7516259

Please sign in to comment.