Geant4 Cross Reference |
1 // ------------------------------------------------------------------- 2 // $Id: plot.C 70323 2013-05-29 07:57:44Z gcosmo $ 3 // ------------------------------------------------------------------- 4 // 5 // ********************************************************************* 6 // To execute this macro under ROOT after your simulation ended, 7 // 1 - launch ROOT (usually type 'root' at your machine's prompt) 8 // 2 - type '.X plot.C' at the ROOT session prompt 9 // ********************************************************************* 10 11 #include <iostream> 12 #include "TROOT.h" 13 #include "DNAVolumeType.hh" 14 using namespace std; 15 16 template<typename T> 17 class ThreeVector 18 { 19 private: 20 T _x, _y, _z; 21 public: 22 ThreeVector():_x(0),_y(0),_z(0){} 23 ThreeVector(T x, T y, T z) 24 :_x(x),_y(y),_z(z){} 25 ~ThreeVector(){} 26 T x() const 27 { 28 return _x; 29 } 30 T y() const 31 { 32 return _y; 33 } 34 T z() const 35 { 36 return _z; 37 } 38 39 bool operator ==(const ThreeVector<T>& right) const 40 { 41 return (_x == right._x) && 42 (_y == right._y) && 43 (_z == right._z); 44 } 45 46 ThreeVector<T>& operator =(const ThreeVector<T>& right) = default; 47 48 ClassDef(ThreeVector,1) 49 }; 50 51 #if !defined(__CLING__) 52 ClassImp(ThreeVector); 53 #endif 54 55 class Molecule 56 { 57 public: 58 Molecule(){} 59 Molecule(string name, 60 int copyNumber, 61 const ThreeVector<double>& position, 62 int strand) 63 : fName(name) 64 , fCopyNumber(copyNumber) 65 , fPosition(position) 66 , fStrand(strand) 67 {} 68 ~Molecule(){} 69 public: 70 string fName; 71 string fMaterial; 72 int fCopyNumber; 73 int fStrand; 74 75 ThreeVector<double> fPosition; 76 77 double fRadius; 78 double fRadiusWater; 79 80 ClassDef(Molecule,1) 81 }; 82 83 #if !defined(__CLING__) 84 ClassImp(Molecule); 85 #endif 86 87 std::vector<Molecule> molecule() 88 { 89 std::vector<Molecule> fMolecules; 90 double size; 91 string name; 92 ifstream file("VoxelStraight.fab2g4dna"); 93 if(!file.is_open()) 94 { 95 string msg ="VoxelStraight.fab2g4dna could not be opened"; 96 throw std::invalid_argument(msg); 97 } 98 99 string line; 100 while(getline(file, line) ) 101 { 102 if(line.empty()) 103 { 104 continue; 105 } 106 107 istringstream issLine(line); 108 string firstItem; 109 issLine >> firstItem; 110 if("_Size" == firstItem) 111 { 112 issLine >> size; 113 } 114 else if("_pl" == firstItem) 115 { 116 string name; 117 issLine >> name; 118 119 string material; 120 issLine >> material; 121 122 int strand; 123 issLine >> strand; 124 125 int copyNumber; 126 issLine >> copyNumber; 127 128 double x; 129 issLine >> x; 130 131 double y; 132 issLine >> y; 133 134 double z; 135 issLine >> z; 136 137 Molecule molecule(name, 138 copyNumber, 139 ThreeVector<double>(x, y, z), 140 strand); 141 fMolecules.push_back(molecule); 142 } 143 } 144 file.close(); 145 146 return fMolecules; 147 } 148