00001 #ifndef BDSBunchUserFile_h 00002 #define BDSBunchUserFile_h 00003 00004 #include "BDSBunchInterface.hh" 00005 #include <fstream> 00006 #include <list> 00007 00008 class BDSBunchUserFile : public BDSBunchInterface { 00009 private: 00010 void ParseFileFormat(); 00011 void OpenBunchFile(); 00012 void CloseBunchFile(); 00013 void skip(G4int nvalues); 00014 std::ifstream InputBunchFile; 00015 template <typename Type> G4bool ReadValue(Type &value); 00016 struct Doublet { 00017 G4String name; 00018 G4double unit; 00019 }; 00020 std::list<struct Doublet> fields; 00021 void SetDistribFile(G4String filename); 00022 void SetBunchFormat(G4String val) {bunchFormat=val;} 00023 void SetNLinesIgnore(G4int val) {nlinesIgnore=val;} 00024 G4double ParseEnergyUnit(G4String &fmt); 00025 G4double ParseLengthUnit(G4String &fmt); 00026 G4double ParseAngleUnit(G4String &fmt); 00027 G4double ParseTimeUnit(G4String &fmt); 00028 00029 protected : 00030 G4String distribFile; 00031 G4String bunchFormat; 00032 G4int nlinesIgnore; 00033 00034 public: 00035 BDSBunchUserFile(); 00036 ~BDSBunchUserFile(); 00037 virtual void SetOptions(struct Options& opt); 00038 virtual void GetNextParticle(G4double& x0, G4double& y0, G4double& z0, 00039 G4double& xp, G4double& yp, G4double& zp, 00040 G4double& t , G4double& E, G4double& weight); 00041 }; 00042 00043 #endif