00001
00002
00003
00004
00005
00006
00007
00008 #ifndef PrimaryGeneratorAction_h
00009 #define PrimaryGeneratorAction_h 1
00010
00011 #include <map>
00012 #include <vector>
00013
00014 #include "G4VUserPrimaryGeneratorAction.hh"
00015 #include "myglobals.hh"
00016
00017 #include "MyConfigure.hh"
00018 #include "TF1.h"
00019 #include "TH2F.h"
00020 #include "TH3F.h"
00021 #include "THnSparse.h"
00022
00023 class G4ParticleGun;
00024 class G4Event;
00025 class PrimaryGeneratorMessenger;
00026 class TChain;
00027 class TFile;
00028 class TH1F;
00029 class G4ParticleDefinition;
00030
00031 class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction,
00032 public MyConfigure
00033 {
00034 public:
00035 PrimaryGeneratorAction();
00036 virtual ~PrimaryGeneratorAction();
00037
00038 void GeneratePrimaries(G4Event*);
00039
00040 void Initialize();
00041
00042 void ResetGen(G4String);
00043
00044 void ReadCard(G4String);
00045
00046 void* get_extra(G4String);
00047
00048 static PrimaryGeneratorAction* GetPrimaryGeneratorAction();
00049
00050 void Dump();
00051
00052 void Reset();
00053
00054 void set_EnergyMode(G4String val) { EnergyMode= val; }
00055 void set_DirectionMode(G4String val) { DirectionMode= val; }
00056 void set_PositionMode(G4String val) { PositionMode= val; }
00057 void set_TimeMode(G4String val) { TimeMode= val; }
00058 void set_pidMode(G4String val) { pidMode= val; }
00059 void set_EM_hist_filename(G4String val) { EM_hist_filename= val; }
00060 void set_EM_hist_histname(G4String val) { EM_hist_histname= val; }
00061 void set_DM_hist_filename(G4String val) { DM_hist_filename= val; }
00062 void set_DM_hist_histname(G4String val) { DM_hist_histname= val; }
00063 void set_PM_hist_filename(G4String val) { PM_hist_filename= val; }
00064 void set_PM_hist_histname(G4String val) { PM_hist_histname= val; }
00065 void set_root_filename(G4String val) { root_filename= val; }
00066 void set_root_treename(G4String val) { root_treename= val; }
00067 void set_root_index(int val){root_index=val;}
00068
00069
00070 void SetUniformDirection();
00071 void SetRandomDirection();
00072 void SetRandomPosition();
00073 void SetRandomEnergy();
00074 void SetUniformPosition();
00075 void BuildHistoFromFile();
00076 void root_get_para();
00077 void root_build();
00078 void root_set_Position();
00079 void root_set_Energy();
00080 void root_set_Time();
00081 void root_set_pid();
00082 void root_set_Rand();
00083 void root_set_extra();
00084
00085
00086
00087
00088
00089 private:
00090 void InformEventHeaderHeader();
00091
00092 private:
00093
00094
00095 G4ParticleGun* particleGun;
00096 PrimaryGeneratorMessenger* gunMessenger;
00097 G4ParticleDefinition* fParticle;
00098
00099 static PrimaryGeneratorAction* fPrimaryGeneratorAction;
00100
00101
00102 G4String fType;
00103 G4String ParticleName;
00104 G4int Z,A,C;
00105 G4double E;
00106 G4double Pa;
00107 G4double Ekin;
00108 G4double mass;
00109 G4int EnergyType;
00110 G4double Px,Py,Pz;
00111 G4double Theta,Phi;
00112 G4double x,y,z,t;
00113 G4double xSpread,ySpread,zSpread;
00114 G4double PosLimit2;
00115 G4double MomSpread;
00116 G4double EkinSpread;
00117 G4String RandMode;
00118 G4String EnergyMode;
00119 G4String PositionMode;
00120 G4String TimeMode;
00121 G4String pidMode;
00122 G4String DirectionMode;
00123 G4String PhiMode;
00124 G4String ThetaMode;
00125 G4double ThetaSpread,PhiSpread;
00126 G4double Ephi;
00127 G4double Etheta;
00128 G4double Epsi;
00129
00130
00131 TH1F* EM_hist;
00132 G4String EM_hist_filename;
00133 G4String EM_hist_histname;
00134 TH1F* DM_hist;
00135 G4String DM_hist_filename;
00136 G4String DM_hist_histname;
00137 TH3* PM_hist;
00138 THnSparseF* PM_hist_sparse;
00139 G4String PM_hist_filename;
00140 G4String PM_hist_histname;
00141
00142
00143 G4String UP_SubDet;
00144 G4String UP_Volume;
00145 G4String UP_Type;
00146
00147
00148
00149 G4bool UseRoot;
00150 TChain* m_TChain;
00151 G4int root_num;
00152 G4int root_index;
00153 G4String root_filename;
00154 G4String root_treename;
00155 double root_double[20];
00156 int root_int[5];
00157 std::string *root_str[2];
00158 TFile *fp;
00159
00160
00161 bool flag_weight;
00162 bool flag_ox;
00163 bool flag_oy;
00164 bool flag_oz;
00165 bool flag_opx;
00166 bool flag_opy;
00167 bool flag_opz;
00168 bool flag_ipx;
00169 bool flag_ipy;
00170 bool flag_ipz;
00171 bool flag_ot;
00172 bool flag_process;
00173 bool flag_volume;
00174 bool flag_R0;
00175 bool flag_R1;
00176 bool flag_ppid;
00177 bool flag_ptid;
00178
00179
00180 TF1* fXPositionFinalFocusFit;
00181 double fXPositionFinalFocus_Lower;
00182 double fXPositionFinalFocus_Upper;
00183
00184 TF1* fYPositionFinalFocusFit;
00185 double fYPositionFinalFocus_Lower;
00186 double fYPositionFinalFocus_Upper;
00187
00188 TH2F* fMuPCBeamDistHist;
00189
00190 TH2F* fMuPCBeamDistRandom;
00191 TH2F* fFFBeamDistRandom;
00192
00193
00194 TH3F* fCollimatedInputHist_XYPz;
00195 TH3F* fCollimatedInputHist_XPxPz;
00196 TH3F* fCollimatedInputHist_YPyPz;
00197
00198
00199 TF1* fEnergyLoss;
00200 };
00201
00202 #endif
00203