[814] | 1 | // |
---|
| 2 | // ******************************************************************** |
---|
| 3 | // * License and Disclaimer * |
---|
| 4 | // * * |
---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
| 7 | // * conditions of the Geant4 Software License, included in the file * |
---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
| 9 | // * include a list of copyright holders. * |
---|
| 10 | // * * |
---|
| 11 | // * Neither the authors of this software system, nor their employing * |
---|
| 12 | // * institutes,nor the agencies providing financial support for this * |
---|
| 13 | // * work make any representation or warranty, express or implied, * |
---|
| 14 | // * regarding this software system or assume any liability for its * |
---|
| 15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
| 16 | // * for the full disclaimer and the limitation of liability. * |
---|
| 17 | // * * |
---|
| 18 | // * This code implementation is the result of the scientific and * |
---|
| 19 | // * technical work of the GEANT4 collaboration. * |
---|
| 20 | // * By using, copying, modifying or distributing the software (or * |
---|
| 21 | // * any work based on the software) you agree to acknowledge its * |
---|
| 22 | // * use in resulting scientific publications, and indicate your * |
---|
| 23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
| 24 | // ******************************************************************** |
---|
| 25 | // |
---|
| 26 | // |
---|
| 27 | // $Id: G4VScoringMesh.hh,v 1.27 2007/11/06 17:17:14 asaim Exp $ |
---|
[850] | 28 | // GEANT4 tag $Name: HEAD $ |
---|
[814] | 29 | // |
---|
| 30 | |
---|
| 31 | #ifndef G4VScoringMesh_h |
---|
| 32 | #define G4VScoringMesh_h 1 |
---|
| 33 | |
---|
| 34 | #include "globals.hh" |
---|
| 35 | #include "G4THitsMap.hh" |
---|
| 36 | #include "G4RotationMatrix.hh" |
---|
| 37 | |
---|
| 38 | class G4VPhysicalVolume; |
---|
| 39 | class G4MultiFunctionalDetector; |
---|
| 40 | class G4VPrimitiveScorer; |
---|
| 41 | class G4VSDFilter; |
---|
| 42 | class G4VScoreColorMap; |
---|
| 43 | |
---|
| 44 | #include <map> |
---|
| 45 | |
---|
| 46 | enum MeshShape { boxMesh, cylinderMesh, sphereMesh }; |
---|
| 47 | typedef std::map<G4String,G4THitsMap<G4double>* > MeshScoreMap; |
---|
| 48 | // class description: |
---|
| 49 | // |
---|
| 50 | // This class represents a parallel world for interactive scoring purposes. |
---|
| 51 | // |
---|
| 52 | |
---|
| 53 | class G4VScoringMesh |
---|
| 54 | { |
---|
| 55 | public: |
---|
| 56 | G4VScoringMesh(G4String wName); |
---|
| 57 | ~G4VScoringMesh(); |
---|
| 58 | |
---|
| 59 | public: // with description |
---|
| 60 | // a pure virtual function to construct this mesh geometry |
---|
| 61 | virtual void Construct(G4VPhysicalVolume* fWorldPhys)=0; |
---|
| 62 | // list infomration of this mesh |
---|
| 63 | virtual void List() const; |
---|
| 64 | |
---|
| 65 | public: // with description |
---|
| 66 | // get the world name |
---|
| 67 | inline const G4String& GetWorldName() const |
---|
| 68 | { return fWorldName; } |
---|
| 69 | // get whether this mesh is active or not |
---|
| 70 | inline G4bool IsActive() const |
---|
| 71 | { return fActive; } |
---|
| 72 | // set an activity of this mesh |
---|
| 73 | inline void Activate(G4bool vl = true) |
---|
| 74 | { fActive = vl; } |
---|
| 75 | // get the shape of this mesh |
---|
| 76 | inline MeshShape GetShape() const |
---|
| 77 | { return fShape; } |
---|
| 78 | // accumulate hits in a registered primitive scorer |
---|
| 79 | inline void Accumulate(G4THitsMap<G4double> * map); |
---|
| 80 | // dump information of primitive socrers registered in this mesh |
---|
| 81 | void Dump(); |
---|
| 82 | // draw a projected quantity on a current viewer |
---|
| 83 | inline void DrawMesh(G4String psName,G4VScoreColorMap* colorMap,G4int axflg=111); |
---|
| 84 | // draw a column of a quantity on a current viewer |
---|
| 85 | inline void DrawMesh(G4String psName,G4int idxPlane,G4int iColumn,G4VScoreColorMap* colorMap); |
---|
| 86 | // draw a projected quantity on a current viewer |
---|
| 87 | virtual void Draw(std::map<G4int, G4double*> * map, G4VScoreColorMap* colorMap, G4int axflg=111) = 0; |
---|
| 88 | // draw a column of a quantity on a current viewer |
---|
| 89 | virtual void DrawColumn(std::map<G4int, G4double*> * map, G4VScoreColorMap* colorMap, |
---|
| 90 | G4int idxProj, G4int idxColumn) = 0; |
---|
| 91 | // reset registered primitive scorers |
---|
| 92 | void ResetScore(); |
---|
| 93 | |
---|
| 94 | // set size of this mesh |
---|
| 95 | void SetSize(G4double size[3]); |
---|
| 96 | // set position of center of this mesh |
---|
| 97 | void SetCenterPosition(G4double centerPosition[3]); |
---|
| 98 | // set a rotation angle around the x axis |
---|
| 99 | void RotateX(G4double delta); |
---|
| 100 | // set a rotation angle around the y axis |
---|
| 101 | void RotateY(G4double delta); |
---|
| 102 | // set a rotation angle around the z axis |
---|
| 103 | void RotateZ(G4double delta); |
---|
| 104 | // set number of segments of this mesh |
---|
| 105 | void SetNumberOfSegments(G4int nSegment[3]); |
---|
| 106 | // get number of segments of this mesh |
---|
| 107 | void GetNumberOfSegments(G4int nSegment[3]); |
---|
| 108 | // set positions to segment this mesh |
---|
| 109 | inline void SetSegmentPositions(std::vector<G4double> & sp) {fSegmentPositions = sp;} |
---|
| 110 | |
---|
| 111 | // register a primitive scorer to the MFD & set it to the current primitive scorer |
---|
| 112 | void SetPrimitiveScorer(G4VPrimitiveScorer * ps); |
---|
| 113 | // register a filter to a current primtive scorer |
---|
| 114 | void SetFilter(G4VSDFilter * filter); |
---|
| 115 | // set a primitive scorer to the current one by the name |
---|
| 116 | void SetCurrentPrimitiveScorer(G4String & name); |
---|
| 117 | // find registered primitive scorer by the name |
---|
| 118 | G4bool FindPrimitiveScorer(G4String & psname); |
---|
| 119 | // get whether current primitive scorer is set or not |
---|
| 120 | G4bool IsCurrentPrimitiveScorerNull() { |
---|
| 121 | if(fCurrentPS == NULL) return true; |
---|
| 122 | else return false; |
---|
| 123 | } |
---|
| 124 | // set current primitive scorer to NULL |
---|
| 125 | void SetNullToCurrentPrimitiveScorer() {fCurrentPS = NULL;} |
---|
| 126 | // set verbose level |
---|
| 127 | inline void SetVerboseLevel(G4int vl) |
---|
| 128 | { verboseLevel = vl; } |
---|
| 129 | // get the primitive scorer map |
---|
| 130 | MeshScoreMap GetScoreMap() {return fMap;} |
---|
| 131 | // get whether this mesh setup has been ready |
---|
| 132 | inline G4bool ReadyForQuantity() const |
---|
| 133 | { return (sizeIsSet && nMeshIsSet); } |
---|
| 134 | |
---|
| 135 | protected: |
---|
| 136 | // get registered primitive socrer by the name |
---|
| 137 | G4VPrimitiveScorer * GetPrimitiveScorer(G4String & name); |
---|
| 138 | |
---|
| 139 | protected: |
---|
| 140 | G4String fWorldName; |
---|
| 141 | G4VPrimitiveScorer * fCurrentPS; |
---|
| 142 | G4bool fConstructed; |
---|
| 143 | G4bool fActive; |
---|
| 144 | MeshShape fShape; |
---|
| 145 | |
---|
| 146 | G4double fSize[3]; |
---|
| 147 | G4ThreeVector fCenterPosition; |
---|
| 148 | G4RotationMatrix * fRotationMatrix; |
---|
| 149 | G4int fNSegment[3]; |
---|
| 150 | std::vector<G4double> fSegmentPositions; |
---|
| 151 | |
---|
| 152 | std::map<G4String, G4THitsMap<G4double>* > fMap; |
---|
| 153 | G4MultiFunctionalDetector * fMFD; |
---|
| 154 | |
---|
| 155 | G4int verboseLevel; |
---|
| 156 | |
---|
| 157 | G4bool sizeIsSet; |
---|
| 158 | G4bool nMeshIsSet; |
---|
| 159 | |
---|
| 160 | }; |
---|
| 161 | |
---|
| 162 | void G4VScoringMesh::Accumulate(G4THitsMap<G4double> * map) |
---|
| 163 | { |
---|
| 164 | G4String psName = map->GetName(); |
---|
| 165 | std::map<G4String, G4THitsMap<G4double>* >::const_iterator fMapItr = fMap.find(psName); |
---|
| 166 | *(fMapItr->second) += *map; |
---|
| 167 | |
---|
| 168 | if(verboseLevel > 9) { |
---|
| 169 | G4cout << G4endl; |
---|
| 170 | G4cout << "G4VScoringMesh::Accumulate()" << G4endl; |
---|
| 171 | G4cout << " PS name : " << psName << G4endl; |
---|
| 172 | if(fMapItr == fMap.end()) { |
---|
| 173 | G4cout << " " |
---|
| 174 | << psName << " was not found." << G4endl; |
---|
| 175 | } else { |
---|
| 176 | G4cout << " map size : " << map->GetSize() << G4endl; |
---|
| 177 | map->PrintAllHits(); |
---|
| 178 | } |
---|
| 179 | G4cout << G4endl; |
---|
| 180 | } |
---|
| 181 | } |
---|
| 182 | |
---|
| 183 | void G4VScoringMesh::DrawMesh(G4String psName,G4VScoreColorMap* colorMap,G4int axflg) |
---|
| 184 | { |
---|
| 185 | std::map<G4String, G4THitsMap<G4double>* >::const_iterator fMapItr = fMap.find(psName); |
---|
| 186 | if(fMapItr!=fMap.end()) |
---|
| 187 | { Draw(fMapItr->second->GetMap(),colorMap,axflg); } |
---|
| 188 | else |
---|
| 189 | { G4cerr << "Scorer <" << psName << "> is not defined. Method ignored." << G4endl; } |
---|
| 190 | } |
---|
| 191 | |
---|
| 192 | void G4VScoringMesh::DrawMesh(G4String psName,G4int idxPlane,G4int iColumn,G4VScoreColorMap* colorMap) |
---|
| 193 | { |
---|
| 194 | std::map<G4String, G4THitsMap<G4double>* >::const_iterator fMapItr = fMap.find(psName); |
---|
| 195 | if(fMapItr!=fMap.end()) |
---|
| 196 | { DrawColumn(fMapItr->second->GetMap(),colorMap,idxPlane,iColumn); } |
---|
| 197 | else |
---|
| 198 | { G4cerr << "Scorer <" << psName << "> is not defined. Method ignored." << G4endl; } |
---|
| 199 | } |
---|
| 200 | |
---|
| 201 | #endif |
---|
| 202 | |
---|