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