G4VScoringMesh.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 
00030 #ifndef G4VScoringMesh_h
00031 #define G4VScoringMesh_h 1
00032 
00033 #include "globals.hh"
00034 #include "G4THitsMap.hh"
00035 #include "G4RotationMatrix.hh"
00036 
00037 class G4VPhysicalVolume;
00038 class G4MultiFunctionalDetector;
00039 class G4VPrimitiveScorer;
00040 class G4VSDFilter;
00041 class G4VScoreColorMap;
00042 
00043 #include <map>
00044 
00045 enum MeshShape { boxMesh, cylinderMesh, sphereMesh };
00046 typedef std::map<G4String,G4THitsMap<G4double>* > MeshScoreMap;
00047 // class description:
00048 //
00049 //  This class represents a parallel world for interactive scoring purposes.
00050 //
00051 
00052 class G4VScoringMesh
00053 {
00054   public:
00055   G4VScoringMesh(const G4String& wName);
00056   virtual ~G4VScoringMesh();
00057 
00058   public: // with description
00059   // a pure virtual function to construct this mesh geometry
00060   virtual void Construct(G4VPhysicalVolume* fWorldPhys)=0;
00061   // list infomration of this mesh 
00062   virtual void List() const;
00063   
00064   public: // with description
00065   // get the world name
00066   inline const G4String& GetWorldName() const
00067   { return fWorldName; }
00068   // get whether this mesh is active or not
00069   inline G4bool IsActive() const
00070   { return fActive; }
00071   // set an activity of this mesh
00072   inline void Activate(G4bool vl = true)
00073   { fActive = vl; }
00074   // get the shape of this mesh
00075   inline MeshShape GetShape() const
00076   { return fShape; }
00077   // accumulate hits in a registered primitive scorer
00078   inline void Accumulate(G4THitsMap<G4double> * map);
00079   // dump information of primitive socrers registered in this mesh
00080   void Dump();
00081   // draw a projected quantity on a current viewer
00082   void DrawMesh(const G4String& psName,G4VScoreColorMap* colorMap,G4int axflg=111);
00083   // draw a column of a quantity on a current viewer
00084   void DrawMesh(const G4String& psName,G4int idxPlane,G4int iColumn,G4VScoreColorMap* colorMap);
00085   // draw a projected quantity on a current viewer
00086   virtual void Draw(std::map<G4int, G4double*> * map, G4VScoreColorMap* colorMap, G4int axflg=111) = 0;
00087   // draw a column of a quantity on a current viewer
00088   virtual void DrawColumn(std::map<G4int, G4double*> * map, G4VScoreColorMap* colorMap,
00089                           G4int idxProj, G4int idxColumn) = 0;
00090   // reset registered primitive scorers
00091   void ResetScore();
00092 
00093   // set size of this mesh
00094   void SetSize(G4double size[3]);
00095   // get size of this mesh
00096   G4ThreeVector GetSize() const;
00097   // set position of center of this mesh
00098   void SetCenterPosition(G4double centerPosition[3]);
00099   // get position of center of this mesh
00100   G4ThreeVector GetTranslation() const {return fCenterPosition;}
00101   // set a rotation angle around the x axis
00102   void RotateX(G4double delta);
00103   // set a rotation angle around the y axis
00104   void RotateY(G4double delta);
00105   // set a rotation angle around the z axis
00106   void RotateZ(G4double delta);
00107   // get a rotation matrix
00108   G4RotationMatrix GetRotationMatrix() const {
00109     if(fRotationMatrix) return *fRotationMatrix;
00110     else return G4RotationMatrix::IDENTITY;
00111   }
00112   // set number of segments of this mesh
00113   void SetNumberOfSegments(G4int nSegment[3]);
00114   // get number of segments of this mesh
00115   void GetNumberOfSegments(G4int nSegment[3]);
00116 
00117   // register a primitive scorer to the MFD & set it to the current primitive scorer
00118   void SetPrimitiveScorer(G4VPrimitiveScorer * ps);
00119   // register a filter to a current primtive scorer
00120   void SetFilter(G4VSDFilter * filter);
00121   // set a primitive scorer to the current one by the name
00122   void SetCurrentPrimitiveScorer(const G4String & name);
00123   // find registered primitive scorer by the name
00124   G4bool FindPrimitiveScorer(const G4String & psname);
00125   // get whether current primitive scorer is set or not
00126   G4bool IsCurrentPrimitiveScorerNull() {
00127     if(fCurrentPS == NULL) return true;
00128     else return false;
00129   }
00130   // get unit of primitive scorer by the name
00131   G4String GetPSUnit(const G4String & psname);
00132   // get unit of current primitive scorer
00133   G4String GetCurrentPSUnit();
00134   // set unit of current primitive scorer
00135   void SetCurrentPSUnit(const G4String& unit);
00136   // get unit value of primitive scorer by the name
00137   G4double GetPSUnitValue(const G4String & psname);
00138   // set PS name to be drawn
00139   void SetDrawPSName(const G4String & psname) {fDrawPSName = psname;}
00140 
00141   // get axis names of the hierarchical division in the divided order
00142   void GetDivisionAxisNames(G4String divisionAxisNames[3]);
00143 
00144   // set current  primitive scorer to NULL
00145   void SetNullToCurrentPrimitiveScorer() {fCurrentPS = NULL;}
00146   // set verbose level
00147   inline void SetVerboseLevel(G4int vl) 
00148   { verboseLevel = vl; }
00149   // get the primitive scorer map
00150   MeshScoreMap GetScoreMap() {return fMap;}
00151   // get whether this mesh setup has been ready
00152   inline G4bool ReadyForQuantity() const
00153   { return (sizeIsSet && nMeshIsSet); }
00154 
00155 protected:
00156   // get registered primitive socrer by the name
00157   G4VPrimitiveScorer * GetPrimitiveScorer(const G4String & name);
00158 
00159 protected:
00160   G4String  fWorldName;
00161   G4VPrimitiveScorer * fCurrentPS;
00162   G4bool    fConstructed;
00163   G4bool    fActive;
00164   MeshShape fShape;
00165 
00166   G4double fSize[3];
00167   G4ThreeVector fCenterPosition;
00168   G4RotationMatrix * fRotationMatrix;
00169   G4int fNSegment[3];
00170 
00171   std::map<G4String, G4THitsMap<G4double>* > fMap;
00172   G4MultiFunctionalDetector * fMFD;
00173 
00174   G4int verboseLevel;
00175 
00176   G4bool sizeIsSet;
00177   G4bool nMeshIsSet;
00178 
00179   G4String fDrawUnit;
00180   G4double fDrawUnitValue;
00181   G4String fDrawPSName;
00182 
00183   G4String fDivisionAxisNames[3];
00184 };
00185 
00186 void G4VScoringMesh::Accumulate(G4THitsMap<G4double> * map)
00187 {
00188   G4String psName = map->GetName();
00189   std::map<G4String, G4THitsMap<G4double>* >::const_iterator fMapItr = fMap.find(psName);
00190   *(fMapItr->second) += *map;
00191 
00192   if(verboseLevel > 9) {
00193     G4cout << G4endl;
00194     G4cout << "G4VScoringMesh::Accumulate()" << G4endl;
00195     G4cout << "  PS name : " << psName << G4endl;
00196     if(fMapItr == fMap.end()) {
00197       G4cout << "  "
00198              << psName << " was not found." << G4endl;
00199     } else {
00200       G4cout << "  map size : " << map->GetSize() << G4endl;
00201       map->PrintAllHits();
00202     }
00203     G4cout << G4endl;
00204   }
00205 }
00206 
00207 #endif
00208 

Generated on Mon May 27 17:50:22 2013 for Geant4 by  doxygen 1.4.7