musrsim/include/musrPrimaryGeneratorAction.hh
Kamil Sedlak b5594b4513 11.20.2009. - Kamil Sedlak
This svn update includes several smaller corrections and updates accumulated
over last few months:
1) For the Geant4.9.2 it was necessary to remove the privately modified file
   src/G4EqEMFieldWithSpin.cc.  Our corrections in this file (and also in
   the file src/G4DecayWithSpin.cc) were adopted by the Geant developers into
   the official Geant code, and therefore these two files were deleted.
   However, if one uses older version of Geant (i.e. Geant4.9.1 or older),
   one should rename the G4EqEMFieldWithSpin.cc_for_Geant4.9.1_and_older in
   his/her src directory to G4EqEMFieldWithSpin.cc to correct for a Geant
   bug.
2) Implementation of save_polx, save_poly and save_polz variables
3) Implementation of the field map normalisation within the field map
   itself (was already possible for the field-map formats generated by Toni,
   now it is extended also for the field maps generated by OPERA).
4) Possibility to swap and invert x and y axis read out from the TURTLE
   file.
5) Perhaps some other tiny changes
2009-11-20 10:29:02 +00:00

138 lines
6.5 KiB
C++

/***************************************************************************
* musrSim - the program for the simulation of (mainly) muSR instruments. *
* More info on http://lmu.web.psi.ch/simulation/index.html . *
* musrSim is based od Geant4 (http://geant4.web.cern.ch/geant4/) *
* *
* Copyright (C) 2009 by Paul Scherrer Institut, 5232 Villigen PSI, *
* Switzerland *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
***************************************************************************/
#ifndef musrPrimaryGeneratorAction_h
#define musrPrimaryGeneratorAction_h 1
#include "G4VUserPrimaryGeneratorAction.hh"
#include "globals.hh"
#include "Randomize.hh"
#include "G4ThreeVector.hh"
#include "G4ParticleDefinition.hh"
#include <stdio.h>
#include <vector>
class G4GeneralParticleSource;
class G4ParticleGun;
class G4Event;
class musrDetectorConstruction;
class musrPrimaryGeneratorMessenger;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
class musrPrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
{
public:
musrPrimaryGeneratorAction(musrDetectorConstruction*);
~musrPrimaryGeneratorAction();
public:
void GeneratePrimaries(G4Event*);
void SetRndmFlag(G4String val) { rndmFlag = val;}
void Setvertex(G4ThreeVector v) {x0=v[0]; y0=v[1]; z0=v[2];}
void SetvertexSigma(G4ThreeVector v) {xSigma=v[0]; ySigma=v[1]; zSigma=v[2];}
void SetvertexBoundary(G4ThreeVector v) {rMaxAllowed=v[0]; zMinAllowed=v[1]; zMaxAllowed=v[2];}
void SetMuonTime(G4double val) {t0=val;} //P.B. 13 May 2009
void SetMuonTimeSigma(G4double val) {tSigma=val;} //P.B. 13 May 2009
void SetKEnergy(G4double val);
void SetMomentum(G4double val) {p0=val;}
void SetMomentumSmearing(G4double val) {pSigma=val;}
void SetMomentumBoundary(G4ThreeVector v){pMinAllowed=v[0]; pMaxAllowed=v[1];}
void SetTilt(G4ThreeVector v) {xangle0=v[0]; yangle0=v[1];}
void SetSigmaTilt(G4ThreeVector v) {xangleSigma=v[0]; yangleSigma=v[1];}
void SetPitch(G4double val) {pitch=val;}
void SetInitialMuonPolariz(G4ThreeVector vIniPol);
void SetInitialPolarizFraction(G4double val) {
if ((val>1.)||(val<-1.)) {
G4cout<<"musrPrimaryGeneratorAction.hh: SetInitialPolarizFraction(): polarisation fraction out of range ("<<val<<")"<<G4endl;
exit(1);
}
polarisFraction=val;
}
void SetMuonDecayTimeLimits(G4ThreeVector decayTimeLimits);
void SetTurtleInput(G4String turtleFileName);
void SetTurtleInputFileToEventNo(G4int lineNumberOfTurtleFile);
void SetTurtleZ0(G4double val) {z0_InitialTurtle=val;}
void SetTurtleInterpretAxes(G4String interpretAxes){turtleInterpretAxes=interpretAxes;}
void SetOrReadTheRandomNumberSeeds(G4int eventID);
void SetTurtleMomentumBite (G4ThreeVector smearingParam)
{turtleMomentumBite=true; turtleMomentumP0=smearingParam[0]*MeV; turtleSmearingFactor=smearingParam[1]*0.01;}
void SetPrimaryParticule(G4String particleName);
static G4String GetPrimaryName();
private:
G4ParticleGun* particleGun; // pointer a to G4 service class
G4GeneralParticleSource* particleSource; // pointer to the G4GeneralParticleSource, needed for radioactive samples
musrDetectorConstruction* musrDetector; // pointer to the geometry
musrPrimaryGeneratorMessenger* gunMessenger; // messenger of this class
G4String rndmFlag; // flag for a random impact point
G4String turtleInterpretAxes; // specifies how to intrpret the TURTLE position axes x, y and z
// cks delete G4ParticleDefinition* muonMinusParticle;
// cks Alpha and proton particles implemented for the simulation of Juan Pablo Urrego
G4ParticleDefinition* alphaParticle;
G4ParticleDefinition* protonParticle;
// csk
static G4String thePrimaryParticleName ;
G4double x0, y0, z0, xSigma, ySigma, zSigma, rMaxAllowed, zMinAllowed, zMaxAllowed;
G4double t0, tSigma; //P.B. 13 May 2009
G4double p0, pSigma, pMinAllowed, pMaxAllowed;
G4double xangle0, yangle0, xangleSigma, yangleSigma, pitch;
G4bool UnpolarisedMuonBeam, TransversalyUnpolarisedMuonBeam;
G4double xPolarisIni, yPolarisIni, zPolarisIni;
G4double polarisFraction;
G4double muonDecayTimeMin;
G4double muonDecayTimeMax;
G4double muonMeanLife;
// For the Turtle input:
FILE* fTurtleFile;
G4bool takeMuonsFromTurtleFile;
G4double z0_InitialTurtle; // z0 at whith the turtle file was generated.
G4int numberOfGeneratedEvents; // number of generated events at the input (e.g. including Turtle events out of the beampipe)
G4bool boolPrintInfoAboutGeneratedParticles;
G4bool turtleMomentumBite;
G4double turtleMomentumP0;
G4double turtleSmearingFactor;
void swapTheAxisInTurtle(float& x_x, float& x_xprime, float& y_y, float& y_yprime);
public:
static G4bool setRandomNrSeedAccordingEventNr;
static G4bool setRandomNrSeedFromFile;
static G4bool setRandomNrSeedFromFile_RNDM;
static G4int nRndmEventToSaveSeeds;
static std::vector<int> * GetPointerToSeedVector();
G4double decaytime;
private:
static std::vector<int> * pointerToSeedVector;
};
#endif