Import Geant4 11.0.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2021-06-25 16:12:29 +02:00
parent c968e26a39
commit 6399a014b6
4200 changed files with 207479 additions and 237366 deletions
+18 -8
View File
@@ -16,12 +16,22 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
April 15th, 2021 M. Asai (detutil-V10-07-02)
- Making sure probe commands are not unnecessarily broadcasted to
the worker threads.
April 1st, 2021 B. Morgan (detutil-V10-07-01)
- Migrate build to modular CMake API
December 7th, 2020 M.Asai (detutil-V10-07-00)
- Extending cylindrical scoring mesh to tube and tube segment.
November 15th, 2020 M.Asai (detutils-V10-06-10)
- Adding Mutex lock to G4ScoringProbe::SetMaterial() to avoid the
race condition.
September 16th, 2020 M.Asai (detutils-V10-06-09)
- Adding /score/fill1D command that lets a primitive scorer to
- Adding /score/fill1D command that lets a primitive scorer to
directly fill a 1D histogram.
September 3rd, 2020 M.Asai (detutils-V10-06-08)
@@ -53,7 +63,7 @@ in trackLength scorer was changed.
December 29th, 2019 M.Asai (detutils-V10-06-00)
- G4ScoringManager, G4VScoreWriter, G4ScoringMessenger:
Add missing setter/getter functions.
October 23rd, 2019 M.Asai (detutils-V10-05-04)
- Revising utils/src/G4ScoringQuantiryMessenger.cc to better handle
ther error cases.
@@ -67,7 +77,7 @@ September 30th, 2019 M.Asai (detutils-V10-05-02)
September 19th, 2019 M.Asai (detutils-V10-05-01)
- Introducing G4ScoringRealWorld that allows to define command-based
scorers to a logical volume in the mass world.
scorers to a logical volume in the mass world.
- Co-working with run-V10-05-05.
July 8th, 2019 I. Hrivnacova (detutils-V10-05-00)
@@ -84,13 +94,13 @@ March 11, 2015 A.Kimura (detutils-V10-01-01)
March 11, 2015 A.Kimura (detutils-V10-01-00)
March 11, 2015 A.Kimura (detutils-V10-01-00)
- Revised G4ScoringBox::Draw(...), ::DrawColumn(...),
G4ScoringCylinder::Draw(...) and ::DrawColumn(...) to spped up
- Revised G4ScoringBox::Draw(...), ::DrawColumn(...),
G4ScoringCylinder::Draw(...) and ::DrawColumn(...) to spped up
drawing primitive scorers attached to the scoring meshes.
October 03, 2014 A.Kimura (detutils-V10-00-00)
- Added several sets of G4VisManager::BeginDraw2D() call and
G4VisManager::EndDraw() call in G4VScoreColorMap.cc for the speedup
- Added several sets of G4VisManager::BeginDraw2D() call and
G4VisManager::EndDraw() call in G4VScoreColorMap.cc for the speedup
of drawing the texts and the color chart.
October 05, 2013 A.Kimura (detutils-V09-06-00)
@@ -125,7 +135,7 @@ July 11, 2007 M.Asai (detutils-V09-00-00)
- Move all scorers and filters to digits_hits/scorer.
June 06, 2007 A.Howard (detutils-V08-03-02)
- Added modified G4PSPopulation removing event (circular) dependency
- Added modified G4PSPopulation removing event (circular) dependency
(file form T.Aso).
June 05, 2007 M.Asai (detutils-V08-03-01)
@@ -34,13 +34,12 @@
class G4DefaultLinearColorMap : public G4VScoreColorMap
{
public:
G4DefaultLinearColorMap(G4String mName);
virtual ~G4DefaultLinearColorMap();
public:
G4DefaultLinearColorMap(G4String mName);
virtual ~G4DefaultLinearColorMap();
public:
virtual void GetMapColor(G4double val, G4double color[4]);
public:
virtual void GetMapColor(G4double val, G4double color[4]);
};
#endif
@@ -34,18 +34,16 @@
class G4ScoreLogColorMap : public G4VScoreColorMap
{
public:
G4ScoreLogColorMap(G4String mName);
virtual ~G4ScoreLogColorMap();
public:
G4ScoreLogColorMap(G4String mName);
virtual ~G4ScoreLogColorMap();
public:
virtual void GetMapColor(G4double val, G4double color[4]);
public:
virtual void GetMapColor(G4double val, G4double color[4]);
// draw a color chart
virtual void DrawColorChartBar(G4int nPoint);
virtual void DrawColorChartText(G4int nPoint);
};
#endif
@@ -31,7 +31,6 @@
// 20-Jul-2010 T.Aso Specify unit for scorer
// 24-Mar-2011 T.Aso Add StepChecker for debugging.
#ifndef G4ScoreQuantityMessenger_h
#define G4ScoreQuantityMessenger_h 1
@@ -52,85 +51,77 @@ typedef std::vector<G4String> G4TokenVec;
// class description:
//
// This is a concrete class of G4UImessenger which handles the commands for
// G4ScoringManager.
// G4ScoringManager.
//
class G4ScoreQuantityMessenger: public G4UImessenger
class G4ScoreQuantityMessenger : public G4UImessenger
{
public:
G4ScoreQuantityMessenger(G4ScoringManager* SManager);
public:
G4ScoreQuantityMessenger(G4ScoringManager * SManager);
~G4ScoreQuantityMessenger();
~G4ScoreQuantityMessenger();
void SetNewValue(G4UIcommand* command, G4String newValues);
void SetNewValue(G4UIcommand * command,G4String newValues);
G4String GetCurrentValue(G4UIcommand*);
G4String GetCurrentValue(G4UIcommand * );
protected:
void FillTokenVec(G4String newValues, G4TokenVec& token);
protected:
void FParticleCommand(G4VScoringMesh* mesh, G4TokenVec& token);
void FParticleWithEnergyCommand(G4VScoringMesh* mesh, G4TokenVec& token);
void FillTokenVec(G4String newValues,G4TokenVec& token);
G4bool CheckMeshPS(G4VScoringMesh* mesh, G4String& psname,
G4UIcommand* command);
void FParticleCommand(G4VScoringMesh* mesh,G4TokenVec& token);
void FParticleWithEnergyCommand(G4VScoringMesh* mesh,G4TokenVec& token);
private:
void QuantityCommands();
void FilterCommands();
G4bool CheckMeshPS(G4VScoringMesh* mesh, G4String& psname,
G4UIcommand * command);
private:
void QuantityCommands();
void FilterCommands();
private:
G4ScoringManager* fSMan;
//
// Quantity commands
G4UIdirectory* quantityDir;
G4UIcmdWithAString* qTouchCmd;
G4UIcmdWithoutParameter* qGetUnitCmd;
G4UIcmdWithAString* qSetUnitCmd;
//
G4UIcommand* qCellChgCmd;
G4UIcommand* qCellFluxCmd;
G4UIcommand* qPassCellFluxCmd;
G4UIcommand* qeDepCmd;
G4UIcommand* qdoseDepCmd;
G4UIcommand* qnOfStepCmd;
G4UIcommand* qnOfSecondaryCmd;
//
G4UIcommand* qTrackLengthCmd;
G4UIcommand* qPassCellCurrCmd;
G4UIcommand* qPassTrackLengthCmd;
G4UIcommand* qFlatSurfCurrCmd;
G4UIcommand* qFlatSurfFluxCmd;
G4UIcommand* qVolFluxCmd;
// G4UIcommand* qSphereSurfCurrCmd;
// G4UIcommand* qSphereSurfFluxCmd;
// G4UIcommand* qCylSurfCurrCmd;
// G4UIcommand* qCylSurfFluxCmd;
G4UIcommand* qNofCollisionCmd;
G4UIcommand* qPopulationCmd;
G4UIcommand* qTrackCountCmd;
G4UIcommand* qTerminationCmd;
G4UIcommand* qMinKinEAtGeneCmd;
private:
G4ScoringManager* fSMan;
//
G4UIcommand* qStepCheckerCmd;
//
// Filter commands
G4UIdirectory* filterDir;
G4UIcmdWithAString* fchargedCmd;
G4UIcmdWithAString* fneutralCmd;
G4UIcommand* fkinECmd;
G4UIcommand* fparticleCmd;
G4UIcommand* fparticleKinECmd;
//
// Quantity commands
G4UIdirectory* quantityDir;
G4UIcmdWithAString* qTouchCmd;
G4UIcmdWithoutParameter* qGetUnitCmd;
G4UIcmdWithAString* qSetUnitCmd;
//
G4UIcommand* qCellChgCmd;
G4UIcommand* qCellFluxCmd;
G4UIcommand* qPassCellFluxCmd;
G4UIcommand* qeDepCmd;
G4UIcommand* qdoseDepCmd;
G4UIcommand* qnOfStepCmd;
G4UIcommand* qnOfSecondaryCmd;
//
G4UIcommand* qTrackLengthCmd;
G4UIcommand* qPassCellCurrCmd;
G4UIcommand* qPassTrackLengthCmd;
G4UIcommand* qFlatSurfCurrCmd;
G4UIcommand* qFlatSurfFluxCmd;
G4UIcommand* qVolFluxCmd;
// G4UIcommand* qSphereSurfCurrCmd;
// G4UIcommand* qSphereSurfFluxCmd;
// G4UIcommand* qCylSurfCurrCmd;
// G4UIcommand* qCylSurfFluxCmd;
G4UIcommand* qNofCollisionCmd;
G4UIcommand* qPopulationCmd;
G4UIcommand* qTrackCountCmd;
G4UIcommand* qTerminationCmd;
G4UIcommand* qMinKinEAtGeneCmd;
//
G4UIcommand* qStepCheckerCmd;
//
// Filter commands
G4UIdirectory* filterDir;
G4UIcmdWithAString* fchargedCmd;
G4UIcmdWithAString* fneutralCmd;
G4UIcommand* fkinECmd;
G4UIcommand* fparticleCmd;
G4UIcommand* fparticleKinECmd;
//
};
#endif
@@ -41,24 +41,24 @@ class G4VScoreColorMap;
class G4ScoringBox : public G4VScoringMesh
{
public:
public:
G4ScoringBox(G4String wName);
~G4ScoringBox();
protected:
protected:
// construct this mesh
virtual void SetupGeometry(G4VPhysicalVolume * fWorldPhys);
virtual void SetupGeometry(G4VPhysicalVolume* fWorldPhys);
public:
public:
void List() const;
void Draw(RunScore * map, G4VScoreColorMap* colorMap, G4int axflg=111);
void DrawColumn(RunScore * map, G4VScoreColorMap* colorMap,
G4int idxProj, G4int idxColumn);
void Draw(RunScore* map, G4VScoreColorMap* colorMap, G4int axflg = 111);
void DrawColumn(RunScore* map, G4VScoreColorMap* colorMap, G4int idxProj,
G4int idxColumn);
// set a direction to segment this mesh
void SetSegmentDirection(G4int dir) {fSegmentDirection = dir;}
void SetSegmentDirection(G4int dir) { fSegmentDirection = dir; }
private:
private:
// get replicated position from 3D index (x,y,z)
G4ThreeVector GetReplicaPosition(G4int x, G4int y, G4int z);
// get 3D index (x,y,z) from sequential index
@@ -66,13 +66,8 @@ private:
// get sequential index from 3D index (x,y,z)
G4int GetIndex(G4int x, G4int y, G4int z) const;
private:
G4int fSegmentDirection; // =1: x, =2: y, =3: z
private:
G4int fSegmentDirection; // =1: x, =2: y, =3: z
};
#endif
@@ -39,35 +39,44 @@ class G4VPrimitiveScorer;
class G4ScoringCylinder : public G4VScoringMesh
{
public:
G4ScoringCylinder(G4String wName);
~G4ScoringCylinder();
public:
G4ScoringCylinder(G4String wName);
~G4ScoringCylinder();
protected:
virtual void SetupGeometry(G4VPhysicalVolume * fWorldPhys);
protected:
virtual void SetupGeometry(G4VPhysicalVolume* fWorldPhys);
public:
virtual void List() const;
virtual void Draw(RunScore * map, G4VScoreColorMap* colorMap, G4int axflg=111);
virtual void DrawColumn(RunScore * map, G4VScoreColorMap* colorMap,
G4int idxProj, G4int idxColumn);
public:
virtual void List() const;
virtual void Draw(RunScore* map, G4VScoreColorMap* colorMap,
G4int axflg = 111);
virtual void DrawColumn(RunScore* map, G4VScoreColorMap* colorMap,
G4int idxProj, G4int idxColumn);
void SetRMax(G4double rMax) {fSize[0] = rMax;}
void SetZSize(G4double zSize) {fSize[1] = zSize;} // half height
void SetRMax(G4double rMax) { fSize[0] = rMax; }
void SetZSize(G4double zSize) { fSize[1] = zSize; } // half height
void RegisterPrimitives(std::vector<G4VPrimitiveScorer *> & vps);
void RegisterPrimitives(std::vector<G4VPrimitiveScorer*>& vps);
// get 3D index (z,phi,r) from sequential index
void GetRZPhi(G4int index, G4int q[3]) const;
//Xin Dong 09302011 for Scorers
public:
//private:
//enum IDX {IR, IZ, IPHI};
enum IDX {IZ, IPHI, IR};
// Xin Dong 09302011 for Scorers
public:
// private:
// enum IDX {IR, IZ, IPHI};
enum IDX
{
IZ,
IPHI,
IR
};
private:
void DumpVolumes();
void DumpSolids(G4int);
void DumpLogVols(G4int);
void DumpPhysVols(G4int);
};
#endif
@@ -51,128 +51,136 @@ class G4VScoreColorMap;
typedef std::vector<G4VScoringMesh*> MeshVec;
typedef std::vector<G4VScoringMesh*>::iterator MeshVecItr;
typedef std::vector<G4VScoringMesh*>::const_iterator MeshVecConstItr;
typedef std::map<G4String,G4VScoreColorMap*> ColorMapDict;
typedef std::map<G4String,G4VScoreColorMap*>::iterator ColorMapDictItr;
typedef std::map<G4String,G4VScoreColorMap*>::const_iterator ColorMapDictConstItr;
typedef std::map<G4int,G4VScoringMesh*> MeshMap;
typedef std::map<G4int,G4VScoringMesh*>::iterator MeshMapItr;
typedef std::map<G4int,G4VScoringMesh*>::const_iterator MeshMapConstItr;
typedef std::map<G4String, G4VScoreColorMap*> ColorMapDict;
typedef std::map<G4String, G4VScoreColorMap*>::iterator ColorMapDictItr;
typedef std::map<G4String, G4VScoreColorMap*>::const_iterator
ColorMapDictConstItr;
typedef std::map<G4int, G4VScoringMesh*> MeshMap;
typedef std::map<G4int, G4VScoringMesh*>::iterator MeshMapItr;
typedef std::map<G4int, G4VScoringMesh*>::const_iterator MeshMapConstItr;
class G4ScoringManager
class G4ScoringManager
{
public: // with description
static G4ScoringManager* GetScoringManager();
// Returns the pointer to the singleton object.
public:
static G4ScoringManager* GetScoringManagerIfExist();
public: // with description
static G4ScoringManager* GetScoringManager();
// Returns the pointer to the singleton object.
public:
static G4ScoringManager* GetScoringManagerIfExist();
public:
static void SetReplicaLevel(G4int);
static G4int GetReplicaLevel();
public:
static void SetReplicaLevel(G4int);
static G4int GetReplicaLevel();
protected:
G4ScoringManager();
protected:
G4ScoringManager();
public:
~G4ScoringManager();
public:
~G4ScoringManager();
public: // with description
void RegisterScoreColorMap(G4VScoreColorMap* colorMap);
// Register a color map. Once registered, it is available by /score/draw and /score/drawColumn
// commands.
public: // with description
void RegisterScoreColorMap(G4VScoreColorMap* colorMap);
// Register a color map. Once registered, it is available by /score/draw and
// /score/drawColumn commands.
public:
void Accumulate(G4VHitsCollection* map);
void Merge(const G4ScoringManager* scMan);
G4VScoringMesh* FindMesh(G4VHitsCollection* map);
G4VScoringMesh* FindMesh(const G4String&);
void List() const;
void Dump() const;
void DrawMesh(const G4String& meshName, const G4String& psName,
const G4String& colorMapName, G4int axflg=111);
void DrawMesh(const G4String& meshName, const G4String& psName,
G4int idxPlane, G4int iColumn, const G4String& colorMapName);
void DumpQuantityToFile(const G4String& meshName, const G4String& psName,
const G4String& fileName, const G4String& option = "");
void DumpAllQuantitiesToFile(const G4String& meshName,
const G4String& fileName,
const G4String& option = "");
G4VScoreColorMap* GetScoreColorMap(const G4String& mapName);
void ListScoreColorMaps();
public:
void Accumulate(G4VHitsCollection* map);
void Merge(const G4ScoringManager* scMan);
G4VScoringMesh* FindMesh(G4VHitsCollection* map);
G4VScoringMesh* FindMesh(const G4String&);
void List() const;
void Dump() const;
void DrawMesh(const G4String& meshName, const G4String& psName,
const G4String& colorMapName, G4int axflg = 111);
void DrawMesh(const G4String& meshName, const G4String& psName,
G4int idxPlane, G4int iColumn, const G4String& colorMapName);
void DumpQuantityToFile(const G4String& meshName, const G4String& psName,
const G4String& fileName,
const G4String& option = "");
void DumpAllQuantitiesToFile(const G4String& meshName,
const G4String& fileName,
const G4String& option = "");
G4VScoreColorMap* GetScoreColorMap(const G4String& mapName);
void ListScoreColorMaps();
private:
static G4ThreadLocal G4ScoringManager * fSManager;
static G4ThreadLocal G4int replicaLevel;
G4int verboseLevel;
G4ScoringMessenger* fMessenger;
G4ScoreQuantityMessenger* fQuantityMessenger;
private:
static G4ThreadLocal G4ScoringManager* fSManager;
static G4ThreadLocal G4int replicaLevel;
G4int verboseLevel;
G4ScoringMessenger* fMessenger;
G4ScoreQuantityMessenger* fQuantityMessenger;
MeshVec fMeshVec;
G4VScoringMesh* fCurrentMesh;
MeshVec fMeshVec;
G4VScoringMesh* fCurrentMesh;
G4VScoreWriter * writer;
G4VScoreColorMap * fDefaultLinearColorMap;
ColorMapDict * fColorMapDict;
G4VScoreWriter* writer;
G4VScoreColorMap* fDefaultLinearColorMap;
ColorMapDict* fColorMapDict;
MeshMap fMeshMap;
public:
inline void SetCurrentMesh(G4VScoringMesh* scm)
{ fCurrentMesh = scm; }
inline G4VScoringMesh* GetCurrentMesh() const
{ return fCurrentMesh; }
inline void CloseCurrentMesh()
{ fCurrentMesh = 0; }
inline void SetVerboseLevel(G4int vl)
{
verboseLevel = vl;
for(MeshVecItr itr = fMeshVec.begin(); itr != fMeshVec.end(); itr++) {
(*itr)->SetVerboseLevel(vl);
}
if(writer) writer->SetVerboseLevel(vl);
}
inline G4int GetVerboseLevel() const
{ return verboseLevel; }
inline size_t GetNumberOfMesh() const
{ return fMeshVec.size(); }
inline void RegisterScoringMesh(G4VScoringMesh * scm)
{
scm->SetVerboseLevel(verboseLevel);
fMeshVec.push_back(scm);
SetCurrentMesh(scm);
}
inline G4VScoringMesh* GetMesh(G4int i) const
{ return fMeshVec[i]; }
inline G4String GetWorldName(G4int i) const
{ return fMeshVec[i]->GetWorldName(); }
MeshMap fMeshMap;
public: // with description
inline void SetScoreWriter(G4VScoreWriter * sw)
{
if(writer) { delete writer; }
writer = sw;
if(writer) writer->SetVerboseLevel(verboseLevel);
}
// Replace score writers.
public:
inline void SetFactor(G4double val=1.0)
{ if(writer) writer->SetFactor(val); }
inline G4double GetFactor() const
public:
inline void SetCurrentMesh(G4VScoringMesh* scm) { fCurrentMesh = scm; }
inline G4VScoringMesh* GetCurrentMesh() const { return fCurrentMesh; }
inline void CloseCurrentMesh() { fCurrentMesh = 0; }
inline void SetVerboseLevel(G4int vl)
{
verboseLevel = vl;
for(MeshVecItr itr = fMeshVec.begin(); itr != fMeshVec.end(); itr++)
{
if(writer)
{ return writer->GetFactor(); }
else
{ return -1.0; }
(*itr)->SetVerboseLevel(vl);
}
if(writer)
writer->SetVerboseLevel(vl);
}
inline G4int GetVerboseLevel() const { return verboseLevel; }
inline size_t GetNumberOfMesh() const { return fMeshVec.size(); }
inline void RegisterScoringMesh(G4VScoringMesh* scm)
{
scm->SetVerboseLevel(verboseLevel);
fMeshVec.push_back(scm);
SetCurrentMesh(scm);
}
inline G4VScoringMesh* GetMesh(G4int i) const { return fMeshVec[i]; }
inline G4String GetWorldName(G4int i) const
{
return fMeshVec[i]->GetWorldName();
}
private:
//Disable copy constructor and assignement operator
G4ScoringManager(const G4ScoringManager&);
G4ScoringManager& operator=(const G4ScoringManager&);
public: // with description
inline void SetScoreWriter(G4VScoreWriter* sw)
{
if(writer)
{
delete writer;
}
writer = sw;
if(writer)
writer->SetVerboseLevel(verboseLevel);
}
// Replace score writers.
public:
inline void SetFactor(G4double val = 1.0)
{
if(writer)
writer->SetFactor(val);
}
inline G4double GetFactor() const
{
if(writer)
{
return writer->GetFactor();
}
else
{
return -1.0;
}
}
private:
// Disable copy constructor and assignement operator
G4ScoringManager(const G4ScoringManager&);
G4ScoringManager& operator=(const G4ScoringManager&);
};
#endif
@@ -31,7 +31,6 @@
// 18-Feb-2008 T.Aso Command for cylindrical scorer.
// 18-Feb-2008 T.Aso Command for color chart display.
#ifndef G4ScoringMessenger_h
#define G4ScoringMessenger_h 1
@@ -56,95 +55,88 @@ typedef std::vector<G4String> G4TokenVec;
// class description:
//
// This is a concrete class of G4UImessenger which handles the commands for
// G4ScoringManager.
// G4ScoringManager.
//
class G4ScoringMessenger: public G4UImessenger
class G4ScoringMessenger : public G4UImessenger
{
public:
G4ScoringMessenger(G4ScoringManager* SManager);
public:
G4ScoringMessenger(G4ScoringManager * SManager);
~G4ScoringMessenger();
~G4ScoringMessenger();
void SetNewValue(G4UIcommand* command, G4String newValues);
void SetNewValue(G4UIcommand * command,G4String newValues);
G4String GetCurrentValue(G4UIcommand* command);
G4String GetCurrentValue(G4UIcommand * command);
protected:
void FillTokenVec(G4String newValues,G4TokenVec& token);
void MeshBinCommand(G4VScoringMesh* mesh, G4TokenVec& token);
void Fill1D(G4UIcommand* cmd, G4String newValues);
private:
G4ScoringManager* fSMan;
G4UIdirectory* scoreDir;
G4UIcmdWithoutParameter* listCmd;
G4UIcmdWithoutParameter* dumpCmd;
G4UIcmdWithAnInteger* verboseCmd;
//
G4UIdirectory* meshCreateDir;
G4UIcmdWithAString* meshBoxCreateCmd;
G4UIcmdWithAString* meshCylinderCreateCmd;
// G4UIcmdWithAString* meshSphereCreateCmd;
G4UIcommand* meshRWLogVolCreateCmd;
G4UIcommand* probeCreateCmd;
//
// Mesh commands
G4UIdirectory* meshDir;
G4UIcmdWithAString* meshOpnCmd;
//
G4UIcmdWithoutParameter* meshClsCmd;
// G4UIcmdWithABool* meshActCmd;
//
// Size commands
G4UIcmdWith3VectorAndUnit* mBoxSizeCmd;
G4UIcommand* mCylinderSizeCmd;
// G4UIcmdWith3VectorAndUnit* mSphereSizeCmd;
//
// Division command
G4UIcommand* mBinCmd;
//
// Placement command
G4UIdirectory* mTransDir;
G4UIcmdWithoutParameter* mTResetCmd;
G4UIcmdWith3VectorAndUnit* mTXyzCmd;
G4UIdirectory* mRotDir;
// G4UIcmdWithoutParameter* mRResetCmd;
G4UIcmdWithADoubleAndUnit* mRotXCmd;
G4UIcmdWithADoubleAndUnit* mRotYCmd;
G4UIcmdWithADoubleAndUnit* mRotZCmd;
//
// Probe commands
G4UIdirectory* probeDir;
G4UIcmdWithAString* probeMatCmd;
G4UIcmdWith3VectorAndUnit* probeLocateCmd;
//
// Draw Command
G4UIcommand * drawCmd;
G4UIcommand * drawColumnCmd;
G4UIdirectory * colorMapDir;
G4UIcmdWithoutParameter * listColorMapCmd;
G4UIcmdWithAString * floatMinMaxCmd;
G4UIcommand * colorMapMinMaxCmd;
//G4UIcommand * chartCmd;
//
// Dump scoring result to file
G4UIcommand * dumpQtyToFileCmd;
G4UIcommand * dumpAllQtsToFileCmd;
G4UIcommand * dumpQtyWithFactorCmd;
G4UIcommand * dumpAllQtsWithFactorCmd;
//
// Command for direcly plotting to a histogram
G4UIcommand * fill1DCmd;
protected:
void FillTokenVec(G4String newValues, G4TokenVec& token);
void MeshBinCommand(G4VScoringMesh* mesh, G4TokenVec& token);
void Fill1D(G4UIcommand* cmd, G4String newValues);
private:
G4ScoringManager* fSMan;
G4UIdirectory* scoreDir;
G4UIcmdWithoutParameter* listCmd;
G4UIcmdWithoutParameter* dumpCmd;
G4UIcmdWithAnInteger* verboseCmd;
//
G4UIdirectory* meshCreateDir;
G4UIcmdWithAString* meshBoxCreateCmd;
G4UIcmdWithAString* meshCylinderCreateCmd;
// G4UIcmdWithAString* meshSphereCreateCmd;
G4UIcommand* meshRWLogVolCreateCmd;
G4UIcommand* probeCreateCmd;
//
// Mesh commands
G4UIdirectory* meshDir;
G4UIcmdWithAString* meshOpnCmd;
//
G4UIcmdWithoutParameter* meshClsCmd;
// G4UIcmdWithABool* meshActCmd;
//
// Size commands
G4UIcmdWith3VectorAndUnit* mBoxSizeCmd;
G4UIcommand* mCylinderSizeCmd;
G4UIcmdWithADoubleAndUnit* mCylinderRMinCmd;
G4UIcommand* mCylinderAngleCmd;
// G4UIcmdWith3VectorAndUnit* mSphereSizeCmd;
//
// Division command
G4UIcommand* mBinCmd;
//
// Placement command
G4UIdirectory* mTransDir;
G4UIcmdWithoutParameter* mTResetCmd;
G4UIcmdWith3VectorAndUnit* mTXyzCmd;
G4UIdirectory* mRotDir;
// G4UIcmdWithoutParameter* mRResetCmd;
G4UIcmdWithADoubleAndUnit* mRotXCmd;
G4UIcmdWithADoubleAndUnit* mRotYCmd;
G4UIcmdWithADoubleAndUnit* mRotZCmd;
//
// Probe commands
G4UIdirectory* probeDir;
G4UIcmdWithAString* probeMatCmd;
G4UIcmdWith3VectorAndUnit* probeLocateCmd;
//
// Draw Command
G4UIcommand* drawCmd;
G4UIcommand* drawColumnCmd;
G4UIdirectory* colorMapDir;
G4UIcmdWithoutParameter* listColorMapCmd;
G4UIcmdWithAString* floatMinMaxCmd;
G4UIcommand* colorMapMinMaxCmd;
// G4UIcommand * chartCmd;
//
// Dump scoring result to file
G4UIcommand* dumpQtyToFileCmd;
G4UIcommand* dumpAllQtsToFileCmd;
G4UIcommand* dumpQtyWithFactorCmd;
G4UIcommand* dumpAllQtsWithFactorCmd;
//
// Command for direcly plotting to a histogram
G4UIcommand* fill1DCmd;
};
#endif
@@ -36,51 +36,51 @@ class G4Material;
class G4ScoringProbe : public G4VScoringMesh
{
public:
G4ScoringProbe(G4String lvName,G4double half_size,G4bool checkOverlap=false);
public:
G4ScoringProbe(G4String lvName, G4double half_size,
G4bool checkOverlap = false);
~G4ScoringProbe();
protected:
protected:
// construct scoring volume
virtual void SetupGeometry(G4VPhysicalVolume* );
virtual void SetupGeometry(G4VPhysicalVolume*);
protected:
protected:
G4String logVolName;
std::vector<G4ThreeVector> posVec;
G4double probeSize;
G4bool chkOverlap;
G4String layeredMaterialName;
G4Material* layeredMaterial;
G4String regName;
G4String regName;
public:
public:
void LocateProbe(G4ThreeVector pos)
{
posVec.push_back(pos);
G4int nbin[] = {static_cast<G4int>(posVec.size()),1,1};
G4int nbin[] = { static_cast<G4int>(posVec.size()), 1, 1 };
SetNumberOfSegments(nbin);
}
G4int GetNumberOfProbes() const
{ return posVec.size(); }
void SetProbeSize(G4double val)
{ probeSize = val; }
G4double GetProbeSize() const
{ return probeSize; }
G4int GetNumberOfProbes() const { return posVec.size(); }
void SetProbeSize(G4double val) { probeSize = val; }
G4double GetProbeSize() const { return probeSize; }
G4bool SetMaterial(G4String val);
public:
public:
virtual void List() const;
public:
//++++++++++ visualization method not yet implemented
virtual void Draw(RunScore * /*map*/, G4VScoreColorMap* /*colorMap*/, G4int /*axflg=111*/)
{;}
virtual void DrawColumn(RunScore * /*map*/, G4VScoreColorMap* /*colorMap*/,
public:
//++++++++++ visualization method not yet implemented
virtual void Draw(RunScore* /*map*/, G4VScoreColorMap* /*colorMap*/,
G4int /*axflg=111*/)
{
;
}
virtual void DrawColumn(RunScore* /*map*/, G4VScoreColorMap* /*colorMap*/,
G4int /*idxProj*/, G4int /*idxColumn*/)
{;}
{
;
}
};
#endif
@@ -33,30 +33,32 @@ class G4LogicalVolume;
class G4ScoringRealWorld : public G4VScoringMesh
{
public:
public:
G4ScoringRealWorld(G4String lvName);
~G4ScoringRealWorld();
protected:
protected:
// construct this mesh
virtual void SetupGeometry(G4VPhysicalVolume* );
virtual void SetupGeometry(G4VPhysicalVolume*);
protected:
protected:
G4String logVolName;
public:
public:
virtual void List() const;
public:
//++++++++++ visualization method not yet implemented
virtual void Draw(RunScore * /*map*/, G4VScoreColorMap* /*colorMap*/, G4int /*axflg=111*/)
{;}
virtual void DrawColumn(RunScore * /*map*/, G4VScoreColorMap* /*colorMap*/,
public:
//++++++++++ visualization method not yet implemented
virtual void Draw(RunScore* /*map*/, G4VScoreColorMap* /*colorMap*/,
G4int /*axflg=111*/)
{
;
}
virtual void DrawColumn(RunScore* /*map*/, G4VScoreColorMap* /*colorMap*/,
G4int /*idxProj*/, G4int /*idxColumn*/)
{;}
{
;
}
};
#endif
@@ -38,7 +38,7 @@
class G4HCofThisEvent;
template <typename T>
template <typename T>
class G4TScoreNtupleWriterMessenger;
class G4HCofThisEvent;
@@ -50,50 +50,50 @@ class G4HCofThisEvent;
// the analysis manager type is defined via template.
//
// An ntuple with three columns is created for each primitive scorer:
// int column - eventNumber
// int column - eventNumber
// int column - copyNumber
// double column - scored value
template <typename T>
class G4TScoreNtupleWriter : public G4VScoreNtupleWriter
{
public:
G4TScoreNtupleWriter();
virtual ~G4TScoreNtupleWriter();
// methods
virtual G4bool Book(G4HCofThisEvent* hce);
virtual void OpenFile();
virtual void Fill(G4HCofThisEvent* hce, G4int eventNumber);
virtual void Write();
public:
G4TScoreNtupleWriter();
virtual ~G4TScoreNtupleWriter();
// set methods
void SetFileName(const G4String& fileName);
void SetVerboseLevel(G4int value);
// methods
virtual G4bool Book(G4HCofThisEvent* hce);
virtual void OpenFile();
virtual void Fill(G4HCofThisEvent* hce, G4int eventNumber);
virtual void Write();
// get methods
G4String GetFileName() const { return fFileName; }
G4int GetVerboseLevel() const { return fVerboseLevel; }
// set methods
void SetFileName(const G4String& fileName);
void SetVerboseLevel(G4int value);
protected:
// methods
virtual G4VScoreNtupleWriter* CreateInstance() const;
// get methods
G4String GetFileName() const { return fFileName; }
G4int GetVerboseLevel() const { return fVerboseLevel; }
private:
// methods
void CreateAnalysisManager();
protected:
// methods
virtual G4VScoreNtupleWriter* CreateInstance() const;
// data members
G4TScoreNtupleWriterMessenger<T>* fMessenger;
std::vector<G4int> fHCIds;
T* fAnalysisManager;
G4String fFileName;
G4int fVerboseLevel;
G4bool fHasAnalysisManager;
G4bool fHasAnalysisFile;
G4bool fIsBooked;
G4bool fIsInitialized;
G4int fFirstNtupleId;
private:
// methods
void CreateAnalysisManager();
// data members
G4TScoreNtupleWriterMessenger<T>* fMessenger;
std::vector<G4int> fHCIds;
T* fAnalysisManager;
G4String fFileName;
G4int fVerboseLevel;
G4bool fHasAnalysisManager;
G4bool fHasAnalysisFile;
G4bool fIsBooked;
G4bool fIsInitialized;
G4int fFirstNtupleId;
};
#include "G4TScoreNtupleWriter.icc"
@@ -39,19 +39,20 @@
//_____________________________________________________________________________
template <typename T>
G4TScoreNtupleWriter<T>::G4TScoreNtupleWriter()
: G4VScoreNtupleWriter(),
fMessenger(nullptr),
fHCIds(),
fAnalysisManager(nullptr),
fFileName("scoring"),
fVerboseLevel(1),
fHasAnalysisManager(false),
fHasAnalysisFile(false),
fIsBooked(false),
fIsInitialized(false),
fFirstNtupleId(0)
: G4VScoreNtupleWriter()
, fMessenger(nullptr)
, fHCIds()
, fAnalysisManager(nullptr)
, fFileName("scoring")
, fVerboseLevel(1)
, fHasAnalysisManager(false)
, fHasAnalysisFile(false)
, fIsBooked(false)
, fIsInitialized(false)
, fFirstNtupleId(0)
{
if ( G4Threading::IsMasterThread() ) {
if(G4Threading::IsMasterThread())
{
fMessenger = new G4TScoreNtupleWriterMessenger<T>(this);
}
}
@@ -60,7 +61,8 @@ G4TScoreNtupleWriter<T>::G4TScoreNtupleWriter()
template <typename T>
G4TScoreNtupleWriter<T>::~G4TScoreNtupleWriter()
{
if ( fHasAnalysisManager ) {
if(fHasAnalysisManager)
{
delete fAnalysisManager;
}
@@ -75,12 +77,14 @@ G4TScoreNtupleWriter<T>::~G4TScoreNtupleWriter()
template <typename T>
void G4TScoreNtupleWriter<T>::CreateAnalysisManager()
{
if ( fAnalysisManager ) return;
if(fAnalysisManager)
return;
// create analysis manager
if ( ! T::IsInstance() ) fHasAnalysisManager = true;
if(!T::IsInstance())
fHasAnalysisManager = true;
fAnalysisManager = T::Instance();
fAnalysisManager->SetVerboseLevel(fVerboseLevel);
}
@@ -108,63 +112,73 @@ template <typename T>
G4bool G4TScoreNtupleWriter<T>::Book(G4HCofThisEvent* hce)
{
#ifdef G4VERBOSE
if ( fVerboseLevel > 1 ) {
if(fVerboseLevel > 1)
{
G4cout << "--- G4TScoreNtupleWriter<T>::Book" << G4endl;
}
#endif
if ( ! hce) return false;
if(!hce)
return false;
// book collection ID if DoubleHitsMap
if (fHCIds.size() == 0) {
if(fHCIds.size() == 0)
{
#ifdef G4VERBOSE
if ( fVerboseLevel > 1 ) {
G4cout << "--- going to fill fHCIds " << G4endl;
if(fVerboseLevel > 1)
{
G4cout << "--- going to fill fHCIds " << G4endl;
}
#endif
for (G4int i=0; i<hce->GetNumberOfCollections(); ++i) {
auto hitsMap
= dynamic_cast<G4THitsMap<G4double>*>(hce->GetHC(i));
for(G4int i = 0; i < hce->GetNumberOfCollections(); ++i)
{
auto hitsMap = dynamic_cast<G4THitsMap<G4double>*>(hce->GetHC(i));
if ( hitsMap ) {
if(hitsMap)
{
#ifdef G4VERBOSE
if ( fVerboseLevel > 1 ) {
G4cout << "--- adding hcID = " << i << G4endl;
}
if(fVerboseLevel > 1)
{
G4cout << "--- adding hcID = " << i << G4endl;
}
#endif
fHCIds.push_back(i);
fHCIds.push_back(i);
}
}
}
// Create analysis manager
if ( fHCIds.size() ) {
if(fHCIds.size())
{
CreateAnalysisManager();
}
// Create ntuples (only once)
if ( ! fIsInitialized ) {
if(!fIsInitialized)
{
#ifdef G4VERBOSE
if ( fVerboseLevel > 1 ) {
if(fVerboseLevel > 1)
{
G4cout << "-- going to create ntuples " << G4endl;
}
#endif
auto first = true;
for (auto id : fHCIds) {
auto hitsMap
= static_cast<G4THitsMap<G4double>*>(hce->GetHC(id));
auto first = true;
for(auto id : fHCIds)
{
auto hitsMap = static_cast<G4THitsMap<G4double>*>(hce->GetHC(id));
// Create ntuple for this primitive
G4String ntupleName(hitsMap->GetSDname());
ntupleName.append("_");
ntupleName.append(hitsMap->GetName());
G4int ntupleId
= fAnalysisManager->CreateNtuple(ntupleName, ntupleName);
if ( first ) {
G4int ntupleId = fAnalysisManager->CreateNtuple(ntupleName, ntupleName);
if(first)
{
fFirstNtupleId = ntupleId;
#ifdef G4VERBOSE
if ( fVerboseLevel > 1 ) {
G4cout << "-- set first ntuple Id " << fFirstNtupleId << G4endl;
if(fVerboseLevel > 1)
{
G4cout << "-- set first ntuple Id " << fFirstNtupleId << G4endl;
}
#endif
first = false;
@@ -180,7 +194,7 @@ G4bool G4TScoreNtupleWriter<T>::Book(G4HCofThisEvent* hce)
colName.append("_score");
fAnalysisManager->CreateNtupleDColumn(colName);
fAnalysisManager->FinishNtuple();
fIsBooked = true;
fIsBooked = true;
}
fIsInitialized = true;
}
@@ -193,26 +207,31 @@ template <typename T>
void G4TScoreNtupleWriter<T>::OpenFile()
{
#ifdef G4VERBOSE
if ( fVerboseLevel > 1 ) {
G4cout << "--- G4TScoreNtupleWriter<T>::OpenFile" << G4endl;
if(fVerboseLevel > 1)
{
G4cout << "--- G4TScoreNtupleWriter<T>::OpenFile" << G4endl;
}
#endif
if ( fAnalysisManager->IsOpenFile() ) return;
if(fAnalysisManager->IsOpenFile())
return;
#ifdef G4VERBOSE
if ( fVerboseLevel > 1 ) {
G4cout << "--- G4TScoreNtupleWriter<T>::OpenFile executing" << G4endl;
if(fVerboseLevel > 1)
{
G4cout << "--- G4TScoreNtupleWriter<T>::OpenFile executing" << G4endl;
}
#endif
if ( fAnalysisManager->GetFileName() == "" ) {
if(fAnalysisManager->GetFileName() == "")
{
fAnalysisManager->SetFileName(fFileName);
}
fAnalysisManager->OpenFile();
#ifdef G4VERBOSE
if ( fVerboseLevel > 1 ) {
if(fVerboseLevel > 1)
{
G4cout << "--- G4TScoreNtupleWriter<T>::OpenFile isOpenFile: "
<< fAnalysisManager->IsOpenFile() << G4endl;
}
@@ -225,38 +244,45 @@ void G4TScoreNtupleWriter<T>::OpenFile()
template <typename T>
void G4TScoreNtupleWriter<T>::Fill(G4HCofThisEvent* hce, G4int eventNumber)
{
#ifdef G4VERBOSE
if ( fVerboseLevel > 1 ) {
if(fVerboseLevel > 1)
{
G4cout << "--- start G4TScoreNtupleWriter<T>::Fill" << G4endl;
}
#endif
auto counter = 0;
for (auto id : fHCIds) {
for(auto id : fHCIds)
{
#ifdef G4VERBOSE
if ( fVerboseLevel > 1 ) {
if(fVerboseLevel > 1)
{
G4cout << "in loop over fHCIds, counter " << counter << G4endl;
}
}
#endif
auto hitsMap
= static_cast<G4THitsMap<G4double>*>(hce->GetHC(id));
auto hitsMap = static_cast<G4THitsMap<G4double>*>(hce->GetHC(id));
//G4cout << eventNumber << ".. go to fill ntuple " << counter + fFirstNtupleId << G4endl;
// G4cout << eventNumber << ".. go to fill ntuple " << counter +
// fFirstNtupleId << G4endl;
// fill hits in ntuple
std::map<G4int, G4double*>::iterator it;
for ( it = hitsMap->GetMap()->begin(); it != hitsMap->GetMap()->end(); it++ ) {
fAnalysisManager->FillNtupleIColumn(counter + fFirstNtupleId, 0, eventNumber);
fAnalysisManager->FillNtupleIColumn(counter + fFirstNtupleId, 1, it->first);
fAnalysisManager->FillNtupleDColumn(counter + fFirstNtupleId, 2, *(it->second));
for(it = hitsMap->GetMap()->begin(); it != hitsMap->GetMap()->end(); it++)
{
fAnalysisManager->FillNtupleIColumn(counter + fFirstNtupleId, 0,
eventNumber);
fAnalysisManager->FillNtupleIColumn(counter + fFirstNtupleId, 1,
it->first);
fAnalysisManager->FillNtupleDColumn(counter + fFirstNtupleId, 2,
*(it->second));
fAnalysisManager->AddNtupleRow(counter + fFirstNtupleId);
}
counter++;
}
#ifdef G4VERBOSE
if ( fVerboseLevel > 1 ) {
if(fVerboseLevel > 1)
{
G4cout << "--- done G4TScoreNtupleWriter<T>::Fill" << G4endl;
}
#endif
@@ -267,14 +293,17 @@ template <typename T>
void G4TScoreNtupleWriter<T>::Write()
{
#ifdef G4VERBOSE
if ( fVerboseLevel > 1 ) {
if(fVerboseLevel > 1)
{
G4cout << "--- start G4TScoreNtupleWriter<T>::Write" << G4endl;
}
#endif
if ( fHasAnalysisFile ) {
if(fHasAnalysisFile)
{
#ifdef G4VERBOSE
if ( fVerboseLevel > 1 ) {
if(fVerboseLevel > 1)
{
G4cout << "--- G4TScoreNtupleWriter<T>::Write - has file" << G4endl;
}
#endif
@@ -284,7 +313,8 @@ void G4TScoreNtupleWriter<T>::Write()
}
#ifdef G4VERBOSE
if ( fVerboseLevel > 1 ) {
if(fVerboseLevel > 1)
{
G4cout << "--- done G4TScoreNtupleWriter<T>::Write" << G4endl;
}
#endif
@@ -293,9 +323,10 @@ void G4TScoreNtupleWriter<T>::Write()
//_____________________________________________________________________________
template <typename T>
void G4TScoreNtupleWriter<T>::SetVerboseLevel(G4int value)
{
fVerboseLevel = value;
if ( fAnalysisManager ) {
{
fVerboseLevel = value;
if(fAnalysisManager)
{
fAnalysisManager->SetVerboseLevel(value);
}
}
@@ -303,6 +334,6 @@ void G4TScoreNtupleWriter<T>::SetVerboseLevel(G4int value)
//_____________________________________________________________________________
template <typename T>
void G4TScoreNtupleWriter<T>::SetFileName(const G4String& fileName)
{
fFileName = fileName;
{
fFileName = fileName;
}
@@ -48,21 +48,20 @@ class G4UIcmdWithAnInteger;
//
template <typename T>
class G4TScoreNtupleWriterMessenger: public G4UImessenger
class G4TScoreNtupleWriterMessenger : public G4UImessenger
{
public:
G4TScoreNtupleWriterMessenger(G4TScoreNtupleWriter<T>* scoreNtupleWriter);
~G4TScoreNtupleWriterMessenger();
void SetNewValue(G4UIcommand * command,G4String newValues);
private:
G4TScoreNtupleWriter<T>* fScoreNtupleWriter;
G4UIdirectory* fDirectory;
G4UIcmdWithAString* fWriterFileNameCmd;
G4UIcmdWithAnInteger* fWriterVerboseCmd;
public:
G4TScoreNtupleWriterMessenger(G4TScoreNtupleWriter<T>* scoreNtupleWriter);
~G4TScoreNtupleWriterMessenger();
void SetNewValue(G4UIcommand* command, G4String newValues);
private:
G4TScoreNtupleWriter<T>* fScoreNtupleWriter;
G4UIdirectory* fDirectory;
G4UIcmdWithAString* fWriterFileNameCmd;
G4UIcmdWithAnInteger* fWriterVerboseCmd;
};
#include "G4TScoreNtupleWriterMessenger.icc"
#endif
@@ -32,27 +32,28 @@
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithAnInteger.hh"
//_____________________________________________________________________________
template <typename T>
G4TScoreNtupleWriterMessenger<T>::G4TScoreNtupleWriterMessenger(
G4TScoreNtupleWriter<T>* scoreNtupleWriter)
: G4UImessenger(),
fScoreNtupleWriter(scoreNtupleWriter),
fWriterFileNameCmd(nullptr),
fWriterVerboseCmd(nullptr)
: G4UImessenger()
, fScoreNtupleWriter(scoreNtupleWriter)
, fWriterFileNameCmd(nullptr)
, fWriterVerboseCmd(nullptr)
{
fDirectory = new G4UIdirectory("/score/ntuple/");
fDirectory->SetGuidance("Interactive score ntuple writer commands.");
fWriterFileNameCmd = new G4UIcmdWithAString("/score/ntuple/writerFileName",this);
fWriterFileNameCmd->SetGuidance( "Set the ntuple writer output file name.");
fWriterFileNameCmd->SetParameterName("outputFileName",false);
fWriterFileNameCmd =
new G4UIcmdWithAString("/score/ntuple/writerFileName", this);
fWriterFileNameCmd->SetGuidance("Set the ntuple writer output file name.");
fWriterFileNameCmd->SetParameterName("outputFileName", false);
fWriterFileNameCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fWriterVerboseCmd = new G4UIcmdWithAnInteger("/score/ntuple/writerVerbose",this);
fWriterVerboseCmd =
new G4UIcmdWithAnInteger("/score/ntuple/writerVerbose", this);
fWriterVerboseCmd->SetGuidance("Set the ntuple writer verbose level.");
fWriterVerboseCmd->SetParameterName("writerVerbose",false);
fWriterVerboseCmd->SetParameterName("writerVerbose", false);
fWriterVerboseCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
}
@@ -67,12 +68,16 @@ G4TScoreNtupleWriterMessenger<T>::~G4TScoreNtupleWriterMessenger()
//_____________________________________________________________________________
template <typename T>
void G4TScoreNtupleWriterMessenger<T>::SetNewValue(G4UIcommand * command,G4String newVal)
void G4TScoreNtupleWriterMessenger<T>::SetNewValue(G4UIcommand* command,
G4String newVal)
{
if ( command==fWriterFileNameCmd ) {
if(command == fWriterFileNameCmd)
{
fScoreNtupleWriter->SetFileName(newVal);
}
else if ( command==fWriterVerboseCmd ) {
fScoreNtupleWriter->SetVerboseLevel(fWriterVerboseCmd->GetNewIntValue(newVal));
else if(command == fWriterVerboseCmd)
{
fScoreNtupleWriter->SetVerboseLevel(
fWriterVerboseCmd->GetNewIntValue(newVal));
}
}
@@ -35,35 +35,35 @@ class G4VVisManager;
class G4VScoreColorMap
{
public:
G4VScoreColorMap(G4String mName);
virtual ~G4VScoreColorMap();
public:
G4VScoreColorMap(G4String mName);
virtual ~G4VScoreColorMap();
public:
virtual void GetMapColor(G4double val, G4double color[4]) = 0;
public:
virtual void GetMapColor(G4double val, G4double color[4]) = 0;
public:
inline G4String GetName() const
{ return fName; }
inline void SetFloatingMinMax(G4bool vl=true)
{ ifFloat = vl; }
inline G4bool IfFloatMinMax() const
{ return ifFloat; }
inline void SetMinMax(G4double minVal, G4double maxVal)
{
if(minVal >= maxVal)
{ G4cerr << "WARNING: G4VScoreColoMap::SetMinMax() : minimum is larger than or equal to maximum. Verify values you set, ["
<< minVal << ", " << maxVal << "]" << G4endl;
fMinVal = maxVal; fMaxVal = minVal;
}
else {
fMinVal = minVal; fMaxVal = maxVal;
}
}
inline G4double GetMin() const
{ return fMinVal; }
inline G4double GetMax() const
{ return fMaxVal; }
public:
inline G4String GetName() const { return fName; }
inline void SetFloatingMinMax(G4bool vl = true) { ifFloat = vl; }
inline G4bool IfFloatMinMax() const { return ifFloat; }
inline void SetMinMax(G4double minVal, G4double maxVal)
{
if(minVal >= maxVal)
{
G4cerr << "WARNING: G4VScoreColoMap::SetMinMax() : minimum is larger "
"than or equal to maximum. Verify values you set, ["
<< minVal << ", " << maxVal << "]" << G4endl;
fMinVal = maxVal;
fMaxVal = minVal;
}
else
{
fMinVal = minVal;
fMaxVal = maxVal;
}
}
inline G4double GetMin() const { return fMinVal; }
inline G4double GetMax() const { return fMaxVal; }
// draw a color chart
virtual void DrawColorChart(G4int nPoint = 5);
@@ -72,19 +72,17 @@ class G4VScoreColorMap
virtual void DrawColorChartText(G4int nPoint);
void SetPSUnit(G4String& unit) { fPSUnit = unit; }
void SetPSName(G4String& psName) { fPSName = psName; }
void SetPSUnit(G4String & unit) {fPSUnit = unit;}
void SetPSName(G4String & psName) {fPSName = psName;}
protected:
G4String fName;
G4bool ifFloat;
G4double fMinVal;
G4double fMaxVal;
G4VVisManager * fVisManager;
protected:
G4String fName;
G4bool ifFloat;
G4double fMinVal;
G4double fMaxVal;
G4VVisManager* fVisManager;
G4String fPSUnit;
G4String fPSName;
};
#endif
@@ -36,30 +36,30 @@ class G4HCofThisEvent;
// class description:
//
// This class implements the interface for storing hits collections of G4THitsMap<G4double>
// type vith Geant4 analysis tools.
// This class implements the interface for storing hits collections of
// G4THitsMap<G4double> type vith Geant4 analysis tools.
class G4VScoreNtupleWriter
{
public:
virtual ~G4VScoreNtupleWriter();
public:
virtual ~G4VScoreNtupleWriter();
// static methods
static G4VScoreNtupleWriter* Instance();
// static methods
static G4VScoreNtupleWriter* Instance();
// methods
virtual G4bool Book(G4HCofThisEvent* hce) = 0;
virtual void OpenFile() = 0;
virtual void Fill(G4HCofThisEvent* hce, G4int eventNumber) = 0;
virtual void Write() = 0;
// methods
virtual G4bool Book(G4HCofThisEvent* hce) = 0;
virtual void OpenFile() = 0;
virtual void Fill(G4HCofThisEvent* hce, G4int eventNumber) = 0;
virtual void Write() = 0;
protected:
G4VScoreNtupleWriter();
virtual G4VScoreNtupleWriter* CreateInstance() const = 0;
protected:
G4VScoreNtupleWriter();
virtual G4VScoreNtupleWriter* CreateInstance() const = 0;
// static data members
static G4VScoreNtupleWriter* fgMasterInstance;
static G4ThreadLocal G4VScoreNtupleWriter* fgInstance;
// static data members
static G4VScoreNtupleWriter* fgMasterInstance;
static G4ThreadLocal G4VScoreNtupleWriter* fgInstance;
};
#endif
@@ -37,13 +37,13 @@ class G4VScoringMesh;
// This class represents storing the scored quantity into a file.
//
class G4VScoreWriter {
public:
class G4VScoreWriter
{
public:
G4VScoreWriter();
virtual ~G4VScoreWriter();
public:
public:
// store a quantity into a file
virtual void DumpQuantityToFile(const G4String& psName,
const G4String& fileName,
@@ -53,23 +53,21 @@ public:
const G4String& option);
// set a socring mesh to retrieve its quantities
void SetScoringMesh(G4VScoringMesh * sm);
void SetScoringMesh(G4VScoringMesh* sm);
// set a verbose level
inline void SetVerboseLevel(G4int vl) { verboseLevel = vl; }
inline void SetFactor(G4double val=1.0) { fact = val; }
inline void SetFactor(G4double val = 1.0) { fact = val; }
inline G4double GetFactor() const { return fact; }
protected:
// get an index from (x,y,z)
protected:
// get an index from (x,y,z)
G4int GetIndex(G4int x, G4int y, G4int z) const;
protected:
G4int fNMeshSegments[3]; // number of segments of the mesh
G4VScoringMesh * fScoringMesh;
protected:
G4int fNMeshSegments[3]; // number of segments of the mesh
G4VScoringMesh* fScoringMesh;
G4int verboseLevel;
G4double fact;
};
#endif
@@ -46,66 +46,75 @@ class G4ParallelWorldProcess;
// class description:
//
// This class represents a multi-functional detector to be used by command-based scorer
// For parallel world scorer, this class creates a parallel world mesh geometry
// This class represents a multi-functional detector to be used by
// command-based scorer For parallel world scorer, this class creates a
// parallel world mesh geometry
//
class G4VScoringMesh
{
public:
enum class MeshShape { box, cylinder, sphere, realWorldLogVol, probe, undefined = -1};
using EventScore = G4THitsMap< G4double >;
using RunScore = G4THitsMap< G4StatDouble >;
using MeshScoreMap = std::map< G4String, RunScore* >;
public:
enum class MeshShape
{
box,
cylinder,
sphere,
realWorldLogVol,
probe,
undefined = -1
};
using EventScore = G4THitsMap<G4double>;
using RunScore = G4THitsMap<G4StatDouble>;
using MeshScoreMap = std::map<G4String, RunScore*>;
public:
public:
G4VScoringMesh(const G4String& wName);
virtual ~G4VScoringMesh();
public: // with description
public: // with description
// a pure virtual function to construct this mesh geometry
void Construct(G4VPhysicalVolume* fWorldPhys);
void WorkerConstruct(G4VPhysicalVolume* fWorldPhys);
protected:
virtual void SetupGeometry(G4VPhysicalVolume * fWorldPhys) = 0;
protected:
virtual void SetupGeometry(G4VPhysicalVolume* fWorldPhys) = 0;
public: // with description
// list infomration of this mesh
public: // with description
// list infomration of this mesh
virtual void List() const;
public: // with description
public: // with description
// get the world name
// If this ScoringMesh is for parallel world, it returns the name of the parallel world
// If this ScoringMesh is for real world logical volume, it returns name of logical volume
inline const G4String& GetWorldName() const
{ return fWorldName; }
// If this ScoringMesh is for parallel world, it returns the name of the
// parallel world If this ScoringMesh is for real world logical volume, it
// returns name of logical volume
inline const G4String& GetWorldName() const { return fWorldName; }
// get whether this mesh is active or not
inline G4bool IsActive() const
{ return fActive; }
inline G4bool IsActive() const { return fActive; }
// set an activity of this mesh
inline void Activate(G4bool vl = true)
{ fActive = vl; }
inline void Activate(G4bool vl = true) { fActive = vl; }
// get the shape of this mesh
inline MeshShape GetShape() const
{ return fShape; }
inline MeshShape GetShape() const { return fShape; }
// accumulate hits in a registered primitive scorer
void Accumulate(G4THitsMap<G4double> * map);
void Accumulate(G4THitsMap<G4StatDouble> * map);
void Accumulate(G4THitsMap<G4double>* map);
void Accumulate(G4THitsMap<G4StatDouble>* map);
// merge same kind of meshes
void Merge(const G4VScoringMesh * scMesh);
void Merge(const G4VScoringMesh* scMesh);
// dump information of primitive socrers registered in this mesh
void Dump();
// draw a projected quantity on a current viewer
void DrawMesh(const G4String& psName,G4VScoreColorMap* colorMap,G4int axflg=111);
void DrawMesh(const G4String& psName, G4VScoreColorMap* colorMap,
G4int axflg = 111);
// draw a column of a quantity on a current viewer
void DrawMesh(const G4String& psName,G4int idxPlane,G4int iColumn,G4VScoreColorMap* colorMap);
void DrawMesh(const G4String& psName, G4int idxPlane, G4int iColumn,
G4VScoreColorMap* colorMap);
// draw a projected quantity on a current viewer
virtual void Draw(RunScore * map, G4VScoreColorMap* colorMap, G4int axflg=111) = 0;
virtual void Draw(RunScore* map, G4VScoreColorMap* colorMap,
G4int axflg = 111) = 0;
// draw a column of a quantity on a current viewer
virtual void DrawColumn(RunScore * map, G4VScoreColorMap* colorMap,
G4int idxProj, G4int idxColumn) = 0;
virtual void DrawColumn(RunScore* map, G4VScoreColorMap* colorMap,
G4int idxProj, G4int idxColumn) = 0;
// reset registered primitive scorers
void ResetScore();
@@ -114,10 +123,12 @@ public: // with description
void SetSize(G4double size[3]);
// get size of this mesh
G4ThreeVector GetSize() const;
// set starting and span angles (used only for tube segment)
void SetAngles(G4double, G4double);
// set position of center of this mesh
void SetCenterPosition(G4double centerPosition[3]);
// get position of center of this mesh
G4ThreeVector GetTranslation() const {return fCenterPosition;}
G4ThreeVector GetTranslation() const { return fCenterPosition; }
// set a rotation angle around the x axis
void RotateX(G4double delta);
// set a rotation angle around the y axis
@@ -125,9 +136,12 @@ public: // with description
// set a rotation angle around the z axis
void RotateZ(G4double delta);
// get a rotation matrix
G4RotationMatrix GetRotationMatrix() const {
if(fRotationMatrix) return *fRotationMatrix;
else return G4RotationMatrix::IDENTITY;
G4RotationMatrix GetRotationMatrix() const
{
if(fRotationMatrix)
return *fRotationMatrix;
else
return G4RotationMatrix::IDENTITY;
}
// set number of segments of this mesh
@@ -135,63 +149,65 @@ public: // with description
// get number of segments of this mesh
void GetNumberOfSegments(G4int nSegment[3]);
// register a primitive scorer to the MFD & set it to the current primitive scorer
void SetPrimitiveScorer(G4VPrimitiveScorer * ps);
// register a primitive scorer to the MFD & set it to the current primitive
// scorer
void SetPrimitiveScorer(G4VPrimitiveScorer* ps);
// register a filter to a current primtive scorer
void SetFilter(G4VSDFilter * filter);
void SetFilter(G4VSDFilter* filter);
// set a primitive scorer to the current one by the name
void SetCurrentPrimitiveScorer(const G4String & name);
void SetCurrentPrimitiveScorer(const G4String& name);
// find registered primitive scorer by the name
G4bool FindPrimitiveScorer(const G4String & psname);
G4bool FindPrimitiveScorer(const G4String& psname);
// get whether current primitive scorer is set or not
G4bool IsCurrentPrimitiveScorerNull() {
if(fCurrentPS == nullptr) return true;
else return false;
G4bool IsCurrentPrimitiveScorerNull()
{
if(fCurrentPS == nullptr)
return true;
else
return false;
}
// get unit of primitive scorer by the name
G4String GetPSUnit(const G4String & psname);
G4String GetPSUnit(const G4String& psname);
// get unit of current primitive scorer
G4String GetCurrentPSUnit();
// set unit of current primitive scorer
void SetCurrentPSUnit(const G4String& unit);
// get unit value of primitive scorer by the name
G4double GetPSUnitValue(const G4String & psname);
G4double GetPSUnitValue(const G4String& psname);
// set PS name to be drawn
void SetDrawPSName(const G4String & psname) {fDrawPSName = psname;}
void SetDrawPSName(const G4String& psname) { fDrawPSName = psname; }
// get axis names of the hierarchical division in the divided order
void GetDivisionAxisNames(G4String divisionAxisNames[3]);
// set current primitive scorer to NULL
void SetNullToCurrentPrimitiveScorer() {fCurrentPS = nullptr;}
void SetNullToCurrentPrimitiveScorer() { fCurrentPS = nullptr; }
// set verbose level
inline void SetVerboseLevel(G4int vl)
{ verboseLevel = vl; }
inline void SetVerboseLevel(G4int vl) { verboseLevel = vl; }
// get the primitive scorer map
inline MeshScoreMap GetScoreMap() const
{ return fMap; }
inline MeshScoreMap GetScoreMap() const { return fMap; }
// get whether this mesh setup has been ready
inline G4bool ReadyForQuantity() const
{ return (sizeIsSet && nMeshIsSet); }
inline G4bool ReadyForQuantity() const { return (sizeIsSet && nMeshIsSet); }
//protected:
// protected:
// get registered primitive socrer by the name
G4VPrimitiveScorer * GetPrimitiveScorer(const G4String & name);
G4VPrimitiveScorer* GetPrimitiveScorer(const G4String& name);
protected:
G4String fWorldName;
G4VPrimitiveScorer * fCurrentPS;
G4bool fConstructed;
G4bool fActive;
protected:
G4String fWorldName;
G4VPrimitiveScorer* fCurrentPS;
G4bool fConstructed;
G4bool fActive;
MeshShape fShape;
G4double fSize[3];
G4double fAngle[2];
G4ThreeVector fCenterPosition;
G4RotationMatrix * fRotationMatrix;
G4RotationMatrix* fRotationMatrix;
G4int fNSegment[3];
MeshScoreMap fMap;
G4MultiFunctionalDetector * fMFD;
G4MultiFunctionalDetector* fMFD;
G4int verboseLevel;
@@ -204,47 +220,54 @@ protected:
G4String fDivisionAxisNames[3];
G4LogicalVolume * fMeshElementLogical;
G4LogicalVolume* fMeshElementLogical;
public:
public:
inline void SetMeshElementLogical(G4LogicalVolume* val)
{ fMeshElementLogical = val; }
{
fMeshElementLogical = val;
}
inline G4LogicalVolume* GetMeshElementLogical() const
{ return fMeshElementLogical; }
{
return fMeshElementLogical;
}
protected:
protected:
G4ParallelWorldProcess* fParallelWorldProcess;
G4bool fGeometryHasBeenDestroyed;
public:
public:
inline void SetParallelWorldProcess(G4ParallelWorldProcess* proc)
{ fParallelWorldProcess = proc; }
{
fParallelWorldProcess = proc;
}
inline G4ParallelWorldProcess* GetParallelWorldProcess() const
{ return fParallelWorldProcess; }
{
return fParallelWorldProcess;
}
inline void GeometryHasBeenDestroyed()
{
fGeometryHasBeenDestroyed = true;
fMeshElementLogical = nullptr;
fMeshElementLogical = nullptr;
}
protected:
protected:
G4int copyNumberLevel;
public:
public:
// Geometry hirarchy level (bottom = 0) to be used as the copy number
// This is used only for real-world scorer
inline void SetCopyNumberLevel(G4int val)
{ copyNumberLevel = val; }
inline G4int GetCopyNumberLevel() const
{ return copyNumberLevel; }
inline void SetCopyNumberLevel(G4int val) { copyNumberLevel = val; }
inline G4int GetCopyNumberLevel() const { return copyNumberLevel; }
protected:
protected:
// This flag may be set to true for Probe scoring mesh.
// There is no public set method for this boolean flag, but it should be set to true
// through SetMaterial() method of Probe scoring mesh.
// There is no public set method for this boolean flag, but it should be set
// to true through SetMaterial() method of Probe scoring mesh.
G4bool layeredMassFlg;
public:
G4bool LayeredMassFlg()
{ return layeredMassFlg; }
public:
G4bool LayeredMassFlg() { return layeredMassFlg; }
};
#endif
+7 -35
View File
@@ -1,13 +1,8 @@
#------------------------------------------------------------------------------
# Module : G4detutils
# Package: Geant4.src.G4digits_hits.G4detutils
#------------------------------------------------------------------------------
# - G4detutils module build definition
#
# Define the Geant4 Module.
#
geant4_define_module(NAME G4detutils
HEADERS
geant4_add_module(G4detutils
PUBLIC_HEADERS
G4DefaultLinearColorMap.hh
G4ScoreLogColorMap.hh
G4VScoreNtupleWriter.hh
@@ -39,31 +34,8 @@ geant4_define_module(NAME G4detutils
G4ScoringProbe.cc
G4VScoreColorMap.cc
G4VScoreWriter.cc
G4VScoringMesh.cc
GRANULAR_DEPENDENCIES
G4csg
G4detector
G4detscorer
G4digits
G4geomdivision
G4geometrymng
G4globman
G4graphics_reps
G4hits
G4intercoms
G4materials
G4navigation
G4partman
G4track
G4volumes
GLOBAL_DEPENDENCIES
G4geometry
G4global
G4graphics_reps
G4intercoms
G4materials
G4particles
G4track
)
G4VScoringMesh.cc)
# List any source specific properties here
geant4_module_link_libraries(G4detutils
PUBLIC G4hits G4intercoms G4hepnumerics G4globman
PRIVATE G4detector G4detscorer G4volumes G4geomdivision G4csg G4geometrymng G4graphics_reps G4materials)
@@ -29,40 +29,50 @@
#include "G4DefaultLinearColorMap.hh"
G4DefaultLinearColorMap::G4DefaultLinearColorMap(G4String mName)
:G4VScoreColorMap(mName)
{;}
: G4VScoreColorMap(mName)
{
;
}
G4DefaultLinearColorMap::~G4DefaultLinearColorMap()
{;}
G4DefaultLinearColorMap::~G4DefaultLinearColorMap() { ; }
void G4DefaultLinearColorMap::GetMapColor(G4double val, G4double color[4])
{
G4double value;
if(fMaxVal == fMinVal)
if(fMaxVal == fMinVal)
value = 0.;
else
value = (val-fMinVal)/(fMaxVal-fMinVal);
value = (val - fMinVal) / (fMaxVal - fMinVal);
if(value > 1.) {value=1.;}
if(value < 0.) {value=0.;}
if(value > 1.)
{
value = 1.;
}
if(value < 0.)
{
value = 0.;
}
// color map
const int NCOLOR = 6;
struct ColorMap {
struct ColorMap
{
G4double val;
G4double rgb[4];
} colormap[NCOLOR] = {{0.0, {1., 1., 1., 1.}}, // value, r, g, b, alpha
{0.2, {0., 0., 1., 1.}},
{0.4, {0., 1., 1., 1.}},
{0.6, {0., 1., 0., 1.}},
{0.8, {1., 1., 0., 1.}},
{1.0, {1., 0., 0., 1.}}};
} colormap[NCOLOR] = { { 0.0, { 1., 1., 1., 1. } }, // value, r, g, b, alpha
{ 0.2, { 0., 0., 1., 1. } },
{ 0.4, { 0., 1., 1., 1. } },
{ 0.6, { 0., 1., 0., 1. } },
{ 0.8, { 1., 1., 0., 1. } },
{ 1.0, { 1., 0., 0., 1. } } };
// search
G4int during[2] = {0, 0};
for(int i = 1; i < NCOLOR; i++) {
if(colormap[i].val >= value) {
during[0] = i-1;
G4int during[2] = { 0, 0 };
for(int i = 1; i < NCOLOR; i++)
{
if(colormap[i].val >= value)
{
during[0] = i - 1;
during[1] = i;
break;
}
@@ -71,12 +81,12 @@ void G4DefaultLinearColorMap::GetMapColor(G4double val, G4double color[4])
// interpolate
G4double a = std::fabs(value - colormap[during[0]].val);
G4double b = std::fabs(value - colormap[during[1]].val);
for(int i = 0; i < 4; i++) {
color[i] = (b*colormap[during[0]].rgb[i] + a*colormap[during[1]].rgb[i])
/(colormap[during[1]].val - colormap[during[0]].val);
if(color[i] > 1.) color[i] = 1.;
}
for(int i = 0; i < 4; i++)
{
color[i] =
(b * colormap[during[0]].rgb[i] + a * colormap[during[1]].rgb[i]) /
(colormap[during[1]].val - colormap[during[0]].val);
if(color[i] > 1.)
color[i] = 1.;
}
}
+133 -101
View File
@@ -32,7 +32,6 @@
#include <sstream>
#include <iomanip>
#include "G4VVisManager.hh"
#include "G4VisAttributes.hh"
#include "G4Text.hh"
@@ -41,33 +40,35 @@
#include "G4Colour.hh"
G4ScoreLogColorMap::G4ScoreLogColorMap(G4String mName)
:G4VScoreColorMap(mName)
{;}
: G4VScoreColorMap(mName)
{
;
}
G4ScoreLogColorMap::~G4ScoreLogColorMap()
{;}
G4ScoreLogColorMap::~G4ScoreLogColorMap() { ; }
#include "G4UIcommand.hh"
void G4ScoreLogColorMap::GetMapColor(G4double val, G4double color[4])
{
G4bool lmin = true, lmax = true, lval = true;
if(fMinVal < 0.) {
lmin = false;
if(fMinVal < 0.)
{
lmin = false;
G4String message = " The min. value (fMinVal) is negative. : ";
message += G4UIcommand::ConvertToString(fMinVal);
G4Exception("G4ScoreLogColorMap::GetMapColor()",
"DigiHitsUtilsScoreLogColorMap000", JustWarning,
message);
"DigiHitsUtilsScoreLogColorMap000", JustWarning, message);
}
if(fMaxVal < 0.) {
lmax = false;
if(fMaxVal < 0.)
{
lmax = false;
G4String message = " The max. value (fMaxVal) is negative. : ";
message += G4UIcommand::ConvertToString(fMaxVal);
G4Exception("G4ScoreLogColorMap::GetMapColor()",
"DigiHitsUtilsScoreLogColorMap001", JustWarning,
message);
"DigiHitsUtilsScoreLogColorMap001", JustWarning, message);
}
if(!lmin || !lmax) {
if(!lmin || !lmax)
{
color[0] = 0.;
color[1] = 0.;
color[2] = 0.;
@@ -75,15 +76,16 @@ void G4ScoreLogColorMap::GetMapColor(G4double val, G4double color[4])
return;
}
if(val < 0.) {
lval = false;
if(val < 0.)
{
lval = false;
G4String message = " 'val' (first argument) is negative : ";
message += G4UIcommand::ConvertToString(fMaxVal);
G4Exception("G4ScoreLogColorMap::GetMapColor()",
"DigiHitsUtilsScoreLogColorMap002", JustWarning,
message);
"DigiHitsUtilsScoreLogColorMap002", JustWarning, message);
}
if(!lval) {
if(!lval)
{
color[0] = 0.;
color[1] = 0.;
color[2] = 0.;
@@ -92,35 +94,48 @@ void G4ScoreLogColorMap::GetMapColor(G4double val, G4double color[4])
}
G4double logmin = 0., logmax = 0., logval = 0.;
if(lmin) {
if(fMinVal > 0.) logmin = std::log10(fMinVal);
else logmin =0.;
if(lmin)
{
if(fMinVal > 0.)
logmin = std::log10(fMinVal);
else
logmin = 0.;
}
if(lmax) logmax = std::log10(fMaxVal);
if(lval) logval = std::log10(val);
if(lmax)
logmax = std::log10(fMaxVal);
if(lval)
logval = std::log10(val);
G4double value = 0.;
if(lmax) value = (logval-logmin)/(logmax-logmin);
if(lmax)
value = (logval - logmin) / (logmax - logmin);
if(value > 1.) {value=1.;}
if(value < 0.) {value=0.;}
if(value > 1.)
{
value = 1.;
}
if(value < 0.)
{
value = 0.;
}
// color map
const int NCOLOR = 6;
struct ColorMap {
struct ColorMap
{
G4double val;
G4double rgb[4];
} colormap[] = {{0.0, {1., 1., 1., 1.}}, // value, r, g, b, alpha
{0.2, {0., 0., 1., 1.}},
{0.4, {0., 1., 1., 1.}},
{0.6, {0., 1., 0., 1.}},
{0.8, {1., 1., 0., 1.}},
{1.0, {1., 0., 0., 1.}}};
} colormap[] = { { 0.0, { 1., 1., 1., 1. } }, // value, r, g, b, alpha
{ 0.2, { 0., 0., 1., 1. } }, { 0.4, { 0., 1., 1., 1. } },
{ 0.6, { 0., 1., 0., 1. } }, { 0.8, { 1., 1., 0., 1. } },
{ 1.0, { 1., 0., 0., 1. } } };
// search
G4int during[2] = {0, 0};
for(int i = 1; i < NCOLOR; i++) {
if(colormap[i].val >= value) {
during[0] = i-1;
G4int during[2] = { 0, 0 };
for(int i = 1; i < NCOLOR; i++)
{
if(colormap[i].val >= value)
{
during[0] = i - 1;
during[1] = i;
break;
}
@@ -129,108 +144,126 @@ void G4ScoreLogColorMap::GetMapColor(G4double val, G4double color[4])
// interpolate
G4double a = std::fabs(value - colormap[during[0]].val);
G4double b = std::fabs(value - colormap[during[1]].val);
for(int i = 0; i < 4; i++) {
color[i] = (b*colormap[during[0]].rgb[i] + a*colormap[during[1]].rgb[i])
/(colormap[during[1]].val - colormap[during[0]].val);
if(color[i] > 1.) color[i] = 1.;
}
for(int i = 0; i < 4; i++)
{
color[i] =
(b * colormap[during[0]].rgb[i] + a * colormap[during[1]].rgb[i]) /
(colormap[during[1]].val - colormap[during[0]].val);
if(color[i] > 1.)
color[i] = 1.;
}
}
void G4ScoreLogColorMap::DrawColorChartBar(G4int _nPoint) {
//G4cout << "++++++ " << fMinVal << " - " << fMaxVal << G4endl;
void G4ScoreLogColorMap::DrawColorChartBar(G4int _nPoint)
{
// G4cout << "++++++ " << fMinVal << " - " << fMaxVal << G4endl;
G4bool lmin = true, lmax = true;
if(fMinVal <= 0.) lmin = false;
if(fMaxVal <= 0.) lmax = false;
if(fMinVal <= 0.)
lmin = false;
if(fMaxVal <= 0.)
lmax = false;
G4double min = 0.;
if(lmin) min = std::log10(fMinVal);
if(lmin)
min = std::log10(fMinVal);
G4double max = 0.;
if(lmax) max = std::log10(fMaxVal);
if(lmax)
max = std::log10(fMaxVal);
G4double smin = -0.89, smax = smin + 0.05*(_nPoint)*0.83, step=0.001;
G4double smin = -0.89, smax = smin + 0.05 * (_nPoint) *0.83, step = 0.001;
G4double c[4];
for(G4double y = smin; y < smax; y+=step) {
G4double ra = (y-smin)/(smax-smin), rb = 1.-ra;
for(G4double y = smin; y < smax; y += step)
{
G4double ra = (y - smin) / (smax - smin), rb = 1. - ra;
G4Polyline line;
line.push_back(G4Point3D(-0.96, y, 0.));
line.push_back(G4Point3D(-0.91, y, 0.));
G4double val = std::pow(10., (ra*max+rb*min)/(ra+rb));
G4double val = std::pow(10., (ra * max + rb * min) / (ra + rb));
this->GetMapColor(val, c);
if(c[0] == 0 && c[1] == 0 && c[2] == 0 && c[3] == 0) return;
if(c[0] == 0 && c[1] == 0 && c[2] == 0 && c[3] == -1.) continue;
if(c[0] == 0 && c[1] == 0 && c[2] == 0 && c[3] == 0)
return;
if(c[0] == 0 && c[1] == 0 && c[2] == 0 && c[3] == -1.)
continue;
G4Colour col(c[0], c[1], c[2]);
G4VisAttributes att(col);
line.SetVisAttributes(&att);
fVisManager->Draw2D(line);
}
}
void G4ScoreLogColorMap::DrawColorChartText(G4int _nPoint) {
void G4ScoreLogColorMap::DrawColorChartText(G4int _nPoint)
{
G4bool lmin = true, lmax = true;
if(fMinVal <= 0.) lmin = false;
if(fMaxVal <= 0.) lmax = false;
if(fMinVal <= 0.)
lmin = false;
if(fMaxVal <= 0.)
lmax = false;
G4double min = 0.;
if(lmin) min = std::log10(fMinVal);
//if(min > 0.) min = std::floor(min);
//else min = std::ceil(min);
if(lmin)
min = std::log10(fMinVal);
// if(min > 0.) min = std::floor(min);
// else min = std::ceil(min);
G4double max = 0.;
if(lmax) max = std::log10(fMaxVal);
//if(max > 0.) max = std::ceil(max);
//else max = std::floor(max);
if(lmax)
max = std::log10(fMaxVal);
// if(max > 0.) max = std::ceil(max);
// else max = std::floor(max);
G4double c[4] = {1., 1., 1., 1.};
G4double c[4] = { 1., 1., 1., 1. };
G4Colour black(0., 0., 0.);
for(int n = 0; n < _nPoint; n++) {
G4double a = n/(_nPoint-1.), b = 1.-a;
G4double v = (a*max + b*min)/(a+b);
for(int n = 0; n < _nPoint; n++)
{
G4double a = n / (_nPoint - 1.), b = 1. - a;
G4double v = (a * max + b * min) / (a + b);
this->GetMapColor(std::pow(10., v), c);
if(c[0] == 0 && c[1] == 0 && c[2] == 0 && c[3] == 0) return;
if(c[0] == 0 && c[1] == 0 && c[2] == 0 && c[3] == -1.) continue;
if(c[0] == 0 && c[1] == 0 && c[2] == 0 && c[3] == 0)
return;
if(c[0] == 0 && c[1] == 0 && c[2] == 0 && c[3] == -1.)
continue;
// background color
for(int l = 0; l < 21; l++) {
for(int l = 0; l < 21; l++)
{
G4Polyline line;
line.push_back(G4Point3D(-0.908, -0.905+0.05*n+0.002*l, 0.));
line.push_back(G4Point3D(-0.705, -0.905+0.05*n+0.002*l, 0.));
line.push_back(G4Point3D(-0.908, -0.905 + 0.05 * n + 0.002 * l, 0.));
line.push_back(G4Point3D(-0.705, -0.905 + 0.05 * n + 0.002 * l, 0.));
G4VisAttributes attblack(black);
line.SetVisAttributes(&attblack);
fVisManager->Draw2D(line);
}
// text
//char cstring[80];
//std::sprintf(cstring, "%8.1e", std::pow(10., v));
//G4String value(cstring);
// char cstring[80];
// std::sprintf(cstring, "%8.1e", std::pow(10., v));
// G4String value(cstring);
std::ostringstream oss;
oss << std::setw(8) << std::setprecision(1) << std::scientific << std::pow(10., v);
oss << std::setw(8) << std::setprecision(1) << std::scientific
<< std::pow(10., v);
std::string str = oss.str();
G4String value(str);//.c_str());
G4Text text(value, G4Point3D(-0.9, -0.9+0.05*n, 0));
G4String value(str); //.c_str());
G4Text text(value, G4Point3D(-0.9, -0.9 + 0.05 * n, 0));
G4double size = 12.;
text.SetScreenSize(size);
//this->GetMapColor(std::pow(10., v), c);
G4Colour color(1.,1.,1.);//c[0], c[1], c[2], 1.);
// this->GetMapColor(std::pow(10., v), c);
G4Colour color(1., 1., 1.); // c[0], c[1], c[2], 1.);
G4VisAttributes att(color);
text.SetVisAttributes(&att);
fVisManager->Draw2D(text);
}
// draw ps name
// background
G4int lpsname = 20;// fPSName.size();
if(lpsname > 0) {
for(int l = 0; l < 22; l++) {
G4int lpsname = 20; // fPSName.size();
if(lpsname > 0)
{
for(int l = 0; l < 22; l++)
{
G4Polyline line;
line.push_back(G4Point3D(-0.9, -0.965+0.002*l, 0.));
line.push_back(G4Point3D(-0.9+0.025*lpsname, -0.965+0.002*l, 0.));
line.push_back(G4Point3D(-0.9, -0.965 + 0.002 * l, 0.));
line.push_back(G4Point3D(-0.9 + 0.025 * lpsname, -0.965 + 0.002 * l, 0.));
G4VisAttributes attblack(black);
//G4VisAttributes attblack(G4Colour(.0, .5, .0));
// G4VisAttributes attblack(G4Colour(.0, .5, .0));
line.SetVisAttributes(&attblack);
fVisManager->Draw2D(line);
}
@@ -244,18 +277,18 @@ void G4ScoreLogColorMap::DrawColorChartText(G4int _nPoint) {
fVisManager->Draw2D(txtpsname);
}
// draw unit
// background
G4int len = fPSUnit.size();
if(len > 0) {
for(int l = 0; l < 21; l++) {
if(len > 0)
{
for(int l = 0; l < 21; l++)
{
G4Polyline line;
line.push_back(G4Point3D(-0.7, -0.9+0.002*l, 0.));
line.push_back(G4Point3D(-0.7+0.3, -0.9+0.002*l, 0.));
line.push_back(G4Point3D(-0.7, -0.9 + 0.002 * l, 0.));
line.push_back(G4Point3D(-0.7 + 0.3, -0.9 + 0.002 * l, 0.));
G4VisAttributes attblack(black);
//G4VisAttributes attblack(G4Colour(.5, .0, .0));
// G4VisAttributes attblack(G4Colour(.5, .0, .0));
line.SetVisAttributes(&attblack);
fVisManager->Draw2D(line);
}
@@ -269,5 +302,4 @@ void G4ScoreLogColorMap::DrawColorChartText(G4int _nPoint) {
txtunit.SetVisAttributes(&att);
fVisManager->Draw2D(txtunit);
}
}
File diff suppressed because it is too large Load Diff
@@ -28,7 +28,7 @@
// ---------------------------------------------------------------------
// Modifications
// 08-Oct-2010 T.Aso remove unit of G4PSPassageCellCurrent.
// 01-Jun-2012 T.Aso Support weighted/dividedByArea options
// 01-Jun-2012 T.Aso Support weighted/dividedByArea options
// in flatCurrent and flatFulx commands.
// 29-Mar-2013 T.Aso Support weighted options in the nOfTrack command.
// Support a boundary flag option in the nOfStep command
@@ -91,157 +91,154 @@ void G4ScoreQuantityMessenger::QuantityCommands()
quantityDir = new G4UIdirectory("/score/quantity/");
quantityDir->SetGuidance("Scoring quantity of the mesh.");
//
qTouchCmd= new G4UIcmdWithAString("/score/quantity/touch",this);
qTouchCmd->SetGuidance("Assign previously defined quantity to the current quantity.");
qTouchCmd->SetParameterName("qname",false);
qTouchCmd = new G4UIcmdWithAString("/score/quantity/touch", this);
qTouchCmd->SetGuidance(
"Assign previously defined quantity to the current quantity.");
qTouchCmd->SetParameterName("qname", false);
//
qGetUnitCmd = new G4UIcmdWithoutParameter("/score/quantity/get/unit",this);
qGetUnitCmd = new G4UIcmdWithoutParameter("/score/quantity/get/unit", this);
qGetUnitCmd->SetGuidance("Print output unit of the current quantity.");
//
qSetUnitCmd = new G4UIcmdWithAString("/score/quantity/set/unit",this);
qSetUnitCmd = new G4UIcmdWithAString("/score/quantity/set/unit", this);
qSetUnitCmd->SetGuidance("Set output unit of the current quantity.");
qSetUnitCmd->SetParameterName("unit",false);
qSetUnitCmd->SetParameterName("unit", false);
// Primitive Scorers
qeDepCmd = new G4UIcommand("/score/quantity/energyDeposit",this);
qeDepCmd = new G4UIcommand("/score/quantity/energyDeposit", this);
qeDepCmd->SetGuidance("Energy deposit scorer.");
qeDepCmd->
SetGuidance("[usage] /score/quantity/energyDeposit qname unit");
qeDepCmd->SetGuidance("[usage] /score/quantity/energyDeposit qname unit");
qeDepCmd->SetGuidance(" qname :(String) scorer name");
qeDepCmd->SetGuidance(" unit :(String) unit");
param = new G4UIparameter("qname",'s',false);
param = new G4UIparameter("qname", 's', false);
qeDepCmd->SetParameter(param);
param = new G4UIparameter("unit",'s',true);
param = new G4UIparameter("unit", 's', true);
param->SetDefaultUnit("MeV");
qeDepCmd->SetParameter(param);
//
qCellChgCmd = new G4UIcommand("/score/quantity/cellCharge",this);
qCellChgCmd = new G4UIcommand("/score/quantity/cellCharge", this);
qCellChgCmd->SetGuidance("Cell charge scorer.");
qCellChgCmd->
SetGuidance("[usage] /score/quantity/cellCharge qname unit");
qCellChgCmd->SetGuidance("[usage] /score/quantity/cellCharge qname unit");
qCellChgCmd->SetGuidance(" qname :(String) scorer name");
qCellChgCmd->SetGuidance(" unit :(String) unit");
param = new G4UIparameter("qname",'s',false);
param = new G4UIparameter("qname", 's', false);
qCellChgCmd->SetParameter(param);
param = new G4UIparameter("unit",'s',true);
param = new G4UIparameter("unit", 's', true);
param->SetDefaultUnit("e+");
qCellChgCmd->SetParameter(param);
//
qCellFluxCmd = new G4UIcommand("/score/quantity/cellFlux",this);
qCellFluxCmd = new G4UIcommand("/score/quantity/cellFlux", this);
qCellFluxCmd->SetGuidance("Cell flux scorer.");
qCellFluxCmd->
SetGuidance("[usage] /score/quantity/cellFlux qname unit");
qCellFluxCmd->SetGuidance("[usage] /score/quantity/cellFlux qname unit");
qCellFluxCmd->SetGuidance(" qname :(String) scorer name");
qCellFluxCmd->SetGuidance(" unit :(String) unit");
param = new G4UIparameter("qname",'s',false);
param = new G4UIparameter("qname", 's', false);
qCellFluxCmd->SetParameter(param);
param = new G4UIparameter("unit",'s',true);
param = new G4UIparameter("unit", 's', true);
param->SetDefaultValue("percm2");
qCellFluxCmd->SetParameter(param);
//
qPassCellFluxCmd = new G4UIcommand("/score/quantity/passageCellFlux",this);
qPassCellFluxCmd = new G4UIcommand("/score/quantity/passageCellFlux", this);
qPassCellFluxCmd->SetGuidance("Passage cell flux scorer");
qPassCellFluxCmd->
SetGuidance("[usage] /score/quantity/passageCellFlux qname unit");
qPassCellFluxCmd->SetGuidance(
"[usage] /score/quantity/passageCellFlux qname unit");
qPassCellFluxCmd->SetGuidance(" qname :(String) scorer name");
qPassCellFluxCmd->SetGuidance(" unit :(String) unit");
param = new G4UIparameter("qname",'s',false);
param = new G4UIparameter("qname", 's', false);
qPassCellFluxCmd->SetParameter(param);
param = new G4UIparameter("unit",'s',true);
param = new G4UIparameter("unit", 's', true);
param->SetDefaultValue("percm2");
qPassCellFluxCmd->SetParameter(param);
//
qdoseDepCmd = new G4UIcommand("/score/quantity/doseDeposit",this);
qdoseDepCmd = new G4UIcommand("/score/quantity/doseDeposit", this);
qdoseDepCmd->SetGuidance("Dose deposit scorer.");
qdoseDepCmd->
SetGuidance("[usage] /score/quantity/doseDeposit qname unit");
qdoseDepCmd->SetGuidance("[usage] /score/quantity/doseDeposit qname unit");
qdoseDepCmd->SetGuidance(" qname :(String) scorer name");
qdoseDepCmd->SetGuidance(" unit :(String) unit");
param = new G4UIparameter("qname",'s',false);
param = new G4UIparameter("qname", 's', false);
qdoseDepCmd->SetParameter(param);
param = new G4UIparameter("unit",'s',true);
param = new G4UIparameter("unit", 's', true);
param->SetDefaultUnit("Gy");
qdoseDepCmd->SetParameter(param);
//
qnOfStepCmd = new G4UIcommand("/score/quantity/nOfStep",this);
qnOfStepCmd = new G4UIcommand("/score/quantity/nOfStep", this);
qnOfStepCmd->SetGuidance("Number of step scorer.");
qnOfStepCmd->
SetGuidance("[usage] /score/quantity/nOfStep qname");
qnOfStepCmd->
SetGuidance("[usage] /score/quantity/nOfStep qname bflag");
qnOfStepCmd->SetGuidance("[usage] /score/quantity/nOfStep qname");
qnOfStepCmd->SetGuidance("[usage] /score/quantity/nOfStep qname bflag");
qnOfStepCmd->SetGuidance(" qname :(String) scorer name");
qnOfStepCmd->SetGuidance(" bflag :(Bool) Skip zero step ");
qnOfStepCmd->SetGuidance(" at geometry boundary if true");
param = new G4UIparameter("qname",'s',false);
param = new G4UIparameter("qname", 's', false);
qnOfStepCmd->SetParameter(param);
param = new G4UIparameter("bflag",'b',true);
param = new G4UIparameter("bflag", 'b', true);
param->SetDefaultValue("false");
qnOfStepCmd->SetParameter(param);
//
qnOfSecondaryCmd = new G4UIcommand("/score/quantity/nOfSecondary",this);
qnOfSecondaryCmd = new G4UIcommand("/score/quantity/nOfSecondary", this);
qnOfSecondaryCmd->SetGuidance("Number of secondary scorer.");
qnOfSecondaryCmd->
SetGuidance("[usage] /score/quantity/nOfSecondary qname");
qnOfSecondaryCmd->SetGuidance("[usage] /score/quantity/nOfSecondary qname");
qnOfSecondaryCmd->SetGuidance(" qname :(String) scorer name");
param = new G4UIparameter("qname",'s',false);
param = new G4UIparameter("qname", 's', false);
qnOfSecondaryCmd->SetParameter(param);
//
qTrackLengthCmd = new G4UIcommand("/score/quantity/trackLength",this);
qTrackLengthCmd = new G4UIcommand("/score/quantity/trackLength", this);
qTrackLengthCmd->SetGuidance("Track length scorer.");
qTrackLengthCmd->
SetGuidance("[usage] /score/quantity/trackLength qname wflag kflag vflag unit");
qTrackLengthCmd->SetGuidance(
"[usage] /score/quantity/trackLength qname wflag kflag vflag unit");
qTrackLengthCmd->SetGuidance(" qname :(String) scorer name");
qTrackLengthCmd->SetGuidance(" wflag :(Bool) weighted");
qTrackLengthCmd->SetGuidance(" kflag :(Bool) multiply kinetic energy");
qTrackLengthCmd->SetGuidance(" vflag :(Bool) divide by velocity");
qTrackLengthCmd->SetGuidance(" unit :(String) unit");
param = new G4UIparameter("qname",'s',false);
param = new G4UIparameter("qname", 's', false);
qTrackLengthCmd->SetParameter(param);
param = new G4UIparameter("wflag",'b',true);
param = new G4UIparameter("wflag", 'b', true);
param->SetDefaultValue("false");
qTrackLengthCmd->SetParameter(param);
param = new G4UIparameter("kflag",'b',true);
param = new G4UIparameter("kflag", 'b', true);
param->SetDefaultValue("false");
qTrackLengthCmd->SetParameter(param);
param = new G4UIparameter("vflag",'b',true);
param = new G4UIparameter("vflag", 'b', true);
param->SetDefaultValue("false");
qTrackLengthCmd->SetParameter(param);
param = new G4UIparameter("unit",'s',true);
param = new G4UIparameter("unit", 's', true);
param->SetDefaultValue("mm");
qTrackLengthCmd->SetParameter(param);
//
qPassCellCurrCmd = new G4UIcommand("/score/quantity/passageCellCurrent",this);
qPassCellCurrCmd =
new G4UIcommand("/score/quantity/passageCellCurrent", this);
qPassCellCurrCmd->SetGuidance("Passage cell current scorer.");
qPassCellCurrCmd->
SetGuidance("[usage] /score/quantity/passageCellCurrent qname wflag");
qPassCellCurrCmd->SetGuidance(
"[usage] /score/quantity/passageCellCurrent qname wflag");
qPassCellCurrCmd->SetGuidance(" qname :(String) scorer name");
qPassCellCurrCmd->SetGuidance(" wflag :(Bool) weighted");
param = new G4UIparameter("qname",'s',false);
param = new G4UIparameter("qname", 's', false);
qPassCellCurrCmd->SetParameter(param);
param = new G4UIparameter("wflag",'b',true);
param = new G4UIparameter("wflag", 'b', true);
param->SetDefaultValue("true");
qPassCellCurrCmd->SetParameter(param);
//
qPassTrackLengthCmd = new G4UIcommand("/score/quantity/passageTrackLength",this);
qPassTrackLengthCmd =
new G4UIcommand("/score/quantity/passageTrackLength", this);
qPassTrackLengthCmd->SetGuidance("Passage track length scorer.");
qPassTrackLengthCmd->
SetGuidance("[usage] /score/quantity/passageTrackLength qname wflag unit");
qPassTrackLengthCmd->SetGuidance(
"[usage] /score/quantity/passageTrackLength qname wflag unit");
qPassTrackLengthCmd->SetGuidance(" qname :(String) scorer name");
qPassTrackLengthCmd->SetGuidance(" wflag :(Bool) weighted");
qPassTrackLengthCmd->SetGuidance(" unit :(Bool) unit");
param = new G4UIparameter("qname",'s',false);
param = new G4UIparameter("qname", 's', false);
qPassTrackLengthCmd->SetParameter(param);
param = new G4UIparameter("wflag",'b',true);
param = new G4UIparameter("wflag", 'b', true);
param->SetDefaultValue("true");
qPassTrackLengthCmd->SetParameter(param);
param = new G4UIparameter("unit",'s',true);
param = new G4UIparameter("unit", 's', true);
param->SetDefaultUnit("mm");
qPassTrackLengthCmd->SetParameter(param);
//
qFlatSurfCurrCmd = new G4UIcommand("/score/quantity/flatSurfaceCurrent",this);
qFlatSurfCurrCmd =
new G4UIcommand("/score/quantity/flatSurfaceCurrent", this);
qFlatSurfCurrCmd->SetGuidance("Flat surface current Scorer.");
qFlatSurfCurrCmd->
SetGuidance("[usage] /score/quantity/flatSurfaceCurrent qname dflag wflag aflag unit");
qFlatSurfCurrCmd->SetGuidance(
"[usage] /score/quantity/flatSurfaceCurrent qname dflag wflag aflag unit");
qFlatSurfCurrCmd->SetGuidance(" qname :(String) scorer name");
qFlatSurfCurrCmd->SetGuidance(" dflag :(Int) direction flag");
qFlatSurfCurrCmd->SetGuidance(" : 0 = Both In and Out");
@@ -250,25 +247,25 @@ void G4ScoreQuantityMessenger::QuantityCommands()
qFlatSurfCurrCmd->SetGuidance(" wflag :(Bool) weighted");
qFlatSurfCurrCmd->SetGuidance(" aflag :(Bool) divide by area");
qFlatSurfCurrCmd->SetGuidance(" unit :(String) unit");
param = new G4UIparameter("qname",'s',false);
param = new G4UIparameter("qname", 's', false);
qFlatSurfCurrCmd->SetParameter(param);
param = new G4UIparameter("dflag",'i',true);
param = new G4UIparameter("dflag", 'i', true);
param->SetDefaultValue("0");
qFlatSurfCurrCmd->SetParameter(param);
param = new G4UIparameter("wflag",'b',true);
param = new G4UIparameter("wflag", 'b', true);
param->SetDefaultValue("true");
qFlatSurfCurrCmd->SetParameter(param);
param = new G4UIparameter("aflag",'b',true);
param = new G4UIparameter("aflag", 'b', true);
param->SetDefaultValue("true");
qFlatSurfCurrCmd->SetParameter(param);
param = new G4UIparameter("unit",'s',true);
param = new G4UIparameter("unit", 's', true);
param->SetDefaultValue("percm2");
qFlatSurfCurrCmd->SetParameter(param);
//
qFlatSurfFluxCmd = new G4UIcommand("/score/quantity/flatSurfaceFlux",this);
qFlatSurfFluxCmd = new G4UIcommand("/score/quantity/flatSurfaceFlux", this);
qFlatSurfFluxCmd->SetGuidance("Flat surface flux scorer.");
qFlatSurfFluxCmd->
SetGuidance("[usage] /score/quantity/flatSurfaceFlux qname dflag unit");
qFlatSurfFluxCmd->SetGuidance(
"[usage] /score/quantity/flatSurfaceFlux qname dflag unit");
qFlatSurfFluxCmd->SetGuidance(" qname :(String) scorer name");
qFlatSurfFluxCmd->SetGuidance(" dflag :(Int) direction flag");
qFlatSurfFluxCmd->SetGuidance(" : 0 = Both In and Out");
@@ -277,226 +274,233 @@ void G4ScoreQuantityMessenger::QuantityCommands()
qFlatSurfFluxCmd->SetGuidance(" wflag :(Bool) weighted");
qFlatSurfFluxCmd->SetGuidance(" aflag :(Bool) divide by area");
qFlatSurfFluxCmd->SetGuidance(" unit :(String) unit");
param = new G4UIparameter("qname",'s',false);
param = new G4UIparameter("qname", 's', false);
qFlatSurfFluxCmd->SetParameter(param);
param = new G4UIparameter("dflag",'i',true);
param = new G4UIparameter("dflag", 'i', true);
param->SetDefaultValue("0");
qFlatSurfFluxCmd->SetParameter(param);
param = new G4UIparameter("wflag",'b',true);
param = new G4UIparameter("wflag", 'b', true);
param->SetDefaultValue("true");
qFlatSurfFluxCmd->SetParameter(param);
param = new G4UIparameter("aflag",'b',true);
param = new G4UIparameter("aflag", 'b', true);
param->SetDefaultValue("true");
qFlatSurfFluxCmd->SetParameter(param);
param = new G4UIparameter("unit",'s',true);
param = new G4UIparameter("unit", 's', true);
param->SetDefaultValue("percm2");
qFlatSurfFluxCmd->SetParameter(param);
//
qVolFluxCmd = new G4UIcommand("/score/quantity/volumeFlux",this);
qVolFluxCmd = new G4UIcommand("/score/quantity/volumeFlux", this);
qVolFluxCmd->SetGuidance("Volume flux scorer.");
qVolFluxCmd->SetGuidance("This scorer scores the number of particles getting into the volume without normalized by the surface area.");
qVolFluxCmd->SetGuidance("[usage] /score/quantity/volumeFlux qname divcos dflag");
qVolFluxCmd->SetGuidance(
"This scorer scores the number of particles getting into the volume "
"without normalized by the surface area.");
qVolFluxCmd->SetGuidance(
"[usage] /score/quantity/volumeFlux qname divcos dflag");
qVolFluxCmd->SetGuidance(" qname :(String) scorer name");
qVolFluxCmd->SetGuidance(" divcos :(Bool) divide by cos(theta), where theta is the incident angle (default : false)");
qVolFluxCmd->SetGuidance(" dflag :(Int) direction, 1 : inward (default), 2 : outward");
param = new G4UIparameter("qname",'s',false);
qVolFluxCmd->SetGuidance(" divcos :(Bool) divide by cos(theta), where theta "
"is the incident angle (default : false)");
qVolFluxCmd->SetGuidance(
" dflag :(Int) direction, 1 : inward (default), 2 : outward");
param = new G4UIparameter("qname", 's', false);
qVolFluxCmd->SetParameter(param);
param = new G4UIparameter("divcos",'b',true);
param = new G4UIparameter("divcos", 'b', true);
param->SetDefaultValue(false);
qVolFluxCmd->SetParameter(param);
param = new G4UIparameter("dflag",'i',true);
param = new G4UIparameter("dflag", 'i', true);
param->SetParameterRange("dflag>=1 && dflag<=2");
param->SetDefaultValue(1);
qVolFluxCmd->SetParameter(param);
// qSphereSurfCurrCmd = new G4UIcommand("/score/quantity/sphereSurfaceCurrent",this);
// qSphereSurfCurrCmd->SetGuidance("Sphere surface current Scorer.");
// qSphereSurfCurrCmd->
// SetGuidance("[usage] /score/quantity/sphereSurfaceCurrent qname dflag wflag aflag unit");
// qSphereSurfCurrCmd->SetGuidance(" qname :(String) scorer name");
// qSphereSurfCurrCmd->SetGuidance(" dflag :(Int) direction flag");
// qSphereSurfCurrCmd->SetGuidance(" : 0 = Both In and Out");
// qSphereSurfCurrCmd->SetGuidance(" : 1 = In only");
// qSphereSurfCurrCmd->SetGuidance(" : 2 = Out only");
// qSphereSurfCurrCmd->SetGuidance(" wflag :(Bool) Weighted");
// qSphereSurfCurrCmd->SetGuidance(" aflag :(Bool) DivideByArea");
// qSphereSurfCurrCmd->SetGuidance(" unit :(String) unit");
// param = new G4UIparameter("qname",'s',false);
// qSphereSurfCurrCmd->SetParameter(param);
// param = new G4UIparameter("dflag",'i',true);
// param->SetDefaultValue("0");
// qSphereSurfCurrCmd->SetParameter(param);
// param = new G4UIparameter("wflag",'b',true);
// param->SetDefaultValue("true");
// qSphereSurfCurrCmd->SetParameter(param);
// param = new G4UIparameter("aflag",'b',true);
// param->SetDefaultValue("true");
// qSphereSurfCurrCmd->SetParameter(param);
// param = new G4UIparameter("unit",'s',true);
// param->SetDefaultValue("percm2");
// qSphereSurfCurrCmd->SetParameter(param);
// qSphereSurfCurrCmd = new
// G4UIcommand("/score/quantity/sphereSurfaceCurrent",this);
// qSphereSurfCurrCmd->SetGuidance("Sphere surface current Scorer.");
// qSphereSurfCurrCmd->
// SetGuidance("[usage] /score/quantity/sphereSurfaceCurrent qname dflag
// wflag aflag unit");
// qSphereSurfCurrCmd->SetGuidance(" qname :(String) scorer name");
// qSphereSurfCurrCmd->SetGuidance(" dflag :(Int) direction flag");
// qSphereSurfCurrCmd->SetGuidance(" : 0 = Both In and Out");
// qSphereSurfCurrCmd->SetGuidance(" : 1 = In only");
// qSphereSurfCurrCmd->SetGuidance(" : 2 = Out only");
// qSphereSurfCurrCmd->SetGuidance(" wflag :(Bool) Weighted");
// qSphereSurfCurrCmd->SetGuidance(" aflag :(Bool) DivideByArea");
// qSphereSurfCurrCmd->SetGuidance(" unit :(String) unit");
// param = new G4UIparameter("qname",'s',false);
// qSphereSurfCurrCmd->SetParameter(param);
// param = new G4UIparameter("dflag",'i',true);
// param->SetDefaultValue("0");
// qSphereSurfCurrCmd->SetParameter(param);
// param = new G4UIparameter("wflag",'b',true);
// param->SetDefaultValue("true");
// qSphereSurfCurrCmd->SetParameter(param);
// param = new G4UIparameter("aflag",'b',true);
// param->SetDefaultValue("true");
// qSphereSurfCurrCmd->SetParameter(param);
// param = new G4UIparameter("unit",'s',true);
// param->SetDefaultValue("percm2");
// qSphereSurfCurrCmd->SetParameter(param);
//
// qSphereSurfFluxCmd = new G4UIcommand("/score/quantity/sphereSurfaceFlux",this);
// qSphereSurfFluxCmd->SetGuidance("Sphere surface Flux Scorer.");
// qSphereSurfFluxCmd->
// SetGuidance("[usage] /score/quantity/sphereSurfaceFlux qname dflag unit");
// qSphereSurfFluxCmd->SetGuidance(" qname :(String) scorer name");
// qSphereSurfFluxCmd->SetGuidance(" dflag :(Int) direction flag");
// qSphereSurfFluxCmd->SetGuidance(" : 0 = Both In and Out");
// qSphereSurfFluxCmd->SetGuidance(" : 1 = In only");
// qSphereSurfFluxCmd->SetGuidance(" : 2 = Out only");
// qSphereSurfFluxCmd->SetGuidance(" wflag :(Bool) weighted");
// qSphereSurfFluxCmd->SetGuidance(" aflag :(Bool) divide by area");
// qSphereSurfFluxCmd->SetGuidance(" unit :(String) unit");
// param = new G4UIparameter("qname",'s',false);
// qSphereSurfFluxCmd->SetParameter(param);
// param = new G4UIparameter("dflag",'i',true);
// param->SetDefaultValue("0");
// qSphereSurfFluxCmd->SetParameter(param);
// param = new G4UIparameter("wflag",'b',true);
// param->SetDefaultValue("true");
// qSphereSurfFluxCmd->SetParameter(param);
// param = new G4UIparameter("aflag",'b',true);
// param->SetDefaultValue("true");
// qSphereSurfFluxCmd->SetParameter(param);
// param = new G4UIparameter("unit",'s',true);
// param->SetDefaultValue("percm2");
// qSphereSurfFluxCmd->SetParameter(param);
// qSphereSurfFluxCmd = new
// G4UIcommand("/score/quantity/sphereSurfaceFlux",this);
// qSphereSurfFluxCmd->SetGuidance("Sphere surface Flux Scorer.");
// qSphereSurfFluxCmd->
// SetGuidance("[usage] /score/quantity/sphereSurfaceFlux qname dflag unit");
// qSphereSurfFluxCmd->SetGuidance(" qname :(String) scorer name");
// qSphereSurfFluxCmd->SetGuidance(" dflag :(Int) direction flag");
// qSphereSurfFluxCmd->SetGuidance(" : 0 = Both In and Out");
// qSphereSurfFluxCmd->SetGuidance(" : 1 = In only");
// qSphereSurfFluxCmd->SetGuidance(" : 2 = Out only");
// qSphereSurfFluxCmd->SetGuidance(" wflag :(Bool) weighted");
// qSphereSurfFluxCmd->SetGuidance(" aflag :(Bool) divide by area");
// qSphereSurfFluxCmd->SetGuidance(" unit :(String) unit");
// param = new G4UIparameter("qname",'s',false);
// qSphereSurfFluxCmd->SetParameter(param);
// param = new G4UIparameter("dflag",'i',true);
// param->SetDefaultValue("0");
// qSphereSurfFluxCmd->SetParameter(param);
// param = new G4UIparameter("wflag",'b',true);
// param->SetDefaultValue("true");
// qSphereSurfFluxCmd->SetParameter(param);
// param = new G4UIparameter("aflag",'b',true);
// param->SetDefaultValue("true");
// qSphereSurfFluxCmd->SetParameter(param);
// param = new G4UIparameter("unit",'s',true);
// param->SetDefaultValue("percm2");
// qSphereSurfFluxCmd->SetParameter(param);
//
// qCylSurfCurrCmd = new G4UIcommand("/score/quantity/cylinderSurfaceCurrent",this);
// qCylSurfCurrCmd->SetGuidance("Cylinder surface current Scorer.");
// qCylSurfCurrCmd->
// SetGuidance("[usage] /score/quantity/cylinderSurfaceCurrent qname dflag wflag aflag unit");
// qCylSurfCurrCmd->SetGuidance(" qname :(String) scorer name");
// qCylSurfCurrCmd->SetGuidance(" dflag :(Int) direction flag");
// qCylSurfCurrCmd->SetGuidance(" : 0 = Both In and Out");
// qCylSurfCurrCmd->SetGuidance(" : 1 = In only");
// qCylSurfCurrCmd->SetGuidance(" : 2 = Out only");
// qCylSurfCurrCmd->SetGuidance(" wflag :(Bool) Weighted");
// qCylSurfCurrCmd->SetGuidance(" aflag :(Bool) DivideByArea");
// qCylSurfCurrCmd->SetGuidance(" unit :(String) unit");
// param = new G4UIparameter("qname",'s',false);
// qCylSurfCurrCmd->SetParameter(param);
// param = new G4UIparameter("dflag",'i',true);
// param->SetDefaultValue("0");
// qCylSurfCurrCmd->SetParameter(param);
// param = new G4UIparameter("wflag",'b',true);
// param->SetDefaultValue("true");
// qCylSurfCurrCmd->SetParameter(param);
// param = new G4UIparameter("aflag",'b',true);
// param->SetDefaultValue("true");
// qCylSurfCurrCmd->SetParameter(param);
// param = new G4UIparameter("unit",'s',true);
// param->SetDefaultValue("percm2");
// qCylSurfCurrCmd->SetParameter(param);
//
// qCylSurfFluxCmd = new G4UIcommand("/score/quantity/cylinderSurfaceFlux",this);
// qCylSurfFluxCmd->SetGuidance("Cylinder surface Flux Scorer.");
// qCylSurfFluxCmd->
// SetGuidance("[usage] /score/quantity/cylinderSurfaceFlux qname dflag unit");
// qCylSurfFluxCmd->SetGuidance(" qname :(String) scorer name");
// qCylSurfFluxCmd->SetGuidance(" dflag :(Int) direction flag");
// qCylSurfFluxCmd->SetGuidance(" : 0 = Both In and Out");
// qCylSurfFluxCmd->SetGuidance(" : 1 = In only");
// qCylSurfFluxCmd->SetGuidance(" : 2 = Out only");
// qCylSurfFluxCmd->SetGuidance(" wflag :(Bool) weighted");
// qCylSurfFluxCmd->SetGuidance(" aflag :(Bool) divide by area");
// qCylSurfFluxCmd->SetGuidance(" unit :(String) unit");
// param = new G4UIparameter("qname",'s',false);
// qCylSurfFluxCmd->SetParameter(param);
// param = new G4UIparameter("dflag",'i',true);
// param->SetDefaultValue("0");
// qCylSurfFluxCmd->SetParameter(param);
// param = new G4UIparameter("wflag",'b',true);
// param->SetDefaultValue("true");
// qCylSurfFluxCmd->SetParameter(param);
// param = new G4UIparameter("aflag",'b',true);
// param->SetDefaultValue("true");
// qCylSurfFluxCmd->SetParameter(param);
// param = new G4UIparameter("unit",'s',true);
// param->SetDefaultValue("percm2");
// qCylSurfFluxCmd->SetParameter(param);
//
// qCylSurfCurrCmd = new
// G4UIcommand("/score/quantity/cylinderSurfaceCurrent",this);
// qCylSurfCurrCmd->SetGuidance("Cylinder surface current Scorer.");
// qCylSurfCurrCmd->
// SetGuidance("[usage] /score/quantity/cylinderSurfaceCurrent qname dflag
// wflag aflag unit"); qCylSurfCurrCmd->SetGuidance(" qname :(String)
// scorer name"); qCylSurfCurrCmd->SetGuidance(" dflag :(Int) direction
// flag"); qCylSurfCurrCmd->SetGuidance(" : 0 = Both In and Out");
// qCylSurfCurrCmd->SetGuidance(" : 1 = In only");
// qCylSurfCurrCmd->SetGuidance(" : 2 = Out only");
// qCylSurfCurrCmd->SetGuidance(" wflag :(Bool) Weighted");
// qCylSurfCurrCmd->SetGuidance(" aflag :(Bool) DivideByArea");
// qCylSurfCurrCmd->SetGuidance(" unit :(String) unit");
// param = new G4UIparameter("qname",'s',false);
// qCylSurfCurrCmd->SetParameter(param);
// param = new G4UIparameter("dflag",'i',true);
// param->SetDefaultValue("0");
// qCylSurfCurrCmd->SetParameter(param);
// param = new G4UIparameter("wflag",'b',true);
// param->SetDefaultValue("true");
// qCylSurfCurrCmd->SetParameter(param);
// param = new G4UIparameter("aflag",'b',true);
// param->SetDefaultValue("true");
// qCylSurfCurrCmd->SetParameter(param);
// param = new G4UIparameter("unit",'s',true);
// param->SetDefaultValue("percm2");
// qCylSurfCurrCmd->SetParameter(param);
//
qNofCollisionCmd = new G4UIcommand("/score/quantity/nOfCollision",this);
// qCylSurfFluxCmd = new
// G4UIcommand("/score/quantity/cylinderSurfaceFlux",this);
// qCylSurfFluxCmd->SetGuidance("Cylinder surface Flux Scorer.");
// qCylSurfFluxCmd->
// SetGuidance("[usage] /score/quantity/cylinderSurfaceFlux qname dflag
// unit"); qCylSurfFluxCmd->SetGuidance(" qname :(String) scorer name");
// qCylSurfFluxCmd->SetGuidance(" dflag :(Int) direction flag");
// qCylSurfFluxCmd->SetGuidance(" : 0 = Both In and Out");
// qCylSurfFluxCmd->SetGuidance(" : 1 = In only");
// qCylSurfFluxCmd->SetGuidance(" : 2 = Out only");
// qCylSurfFluxCmd->SetGuidance(" wflag :(Bool) weighted");
// qCylSurfFluxCmd->SetGuidance(" aflag :(Bool) divide by area");
// qCylSurfFluxCmd->SetGuidance(" unit :(String) unit");
// param = new G4UIparameter("qname",'s',false);
// qCylSurfFluxCmd->SetParameter(param);
// param = new G4UIparameter("dflag",'i',true);
// param->SetDefaultValue("0");
// qCylSurfFluxCmd->SetParameter(param);
// param = new G4UIparameter("wflag",'b',true);
// param->SetDefaultValue("true");
// qCylSurfFluxCmd->SetParameter(param);
// param = new G4UIparameter("aflag",'b',true);
// param->SetDefaultValue("true");
// qCylSurfFluxCmd->SetParameter(param);
// param = new G4UIparameter("unit",'s',true);
// param->SetDefaultValue("percm2");
// qCylSurfFluxCmd->SetParameter(param);
//
//
qNofCollisionCmd = new G4UIcommand("/score/quantity/nOfCollision", this);
qNofCollisionCmd->SetGuidance("Number of collision scorer.");
qNofCollisionCmd->
SetGuidance("[usage] /score/quantity/nOfCollision qname wflag");
qNofCollisionCmd->SetGuidance(
"[usage] /score/quantity/nOfCollision qname wflag");
qNofCollisionCmd->SetGuidance(" qname :(String) scorer name");
param = new G4UIparameter("qname",'s',false);
param = new G4UIparameter("qname", 's', false);
qNofCollisionCmd->SetParameter(param);
param = new G4UIparameter("wflag",'b',true);
param = new G4UIparameter("wflag", 'b', true);
param->SetDefaultValue("false");
qNofCollisionCmd->SetParameter(param);
//
qPopulationCmd = new G4UIcommand("/score/quantity/population",this);
qPopulationCmd = new G4UIcommand("/score/quantity/population", this);
qPopulationCmd->SetGuidance("Population scorer.");
qPopulationCmd->
SetGuidance("[usage] /score/quantity/population qname wflag");
qPopulationCmd->SetGuidance("[usage] /score/quantity/population qname wflag");
qPopulationCmd->SetGuidance(" qname :(String) scorer name");
qPopulationCmd->SetGuidance(" wflag :(Bool) weighted");
param = new G4UIparameter("qname",'s',false);
param = new G4UIparameter("qname", 's', false);
qPopulationCmd->SetParameter(param);
param = new G4UIparameter("wflag",'b',true);
param = new G4UIparameter("wflag", 'b', true);
param->SetDefaultValue("false");
qPopulationCmd->SetParameter(param);
//
qTrackCountCmd = new G4UIcommand("/score/quantity/nOfTrack",this);
qTrackCountCmd = new G4UIcommand("/score/quantity/nOfTrack", this);
qTrackCountCmd->SetGuidance("Number of track scorer.");
qTrackCountCmd->
SetGuidance("[usage] /score/quantity/nOfTrack qname dflag wflag");
qTrackCountCmd->SetGuidance(
"[usage] /score/quantity/nOfTrack qname dflag wflag");
qTrackCountCmd->SetGuidance(" qname :(String) scorer name");
qTrackCountCmd->SetGuidance(" dflag :(Int) direction");
qTrackCountCmd->SetGuidance(" : 0 = Both In and Out");
qTrackCountCmd->SetGuidance(" : 1 = In only");
qTrackCountCmd->SetGuidance(" : 2 = Out only");
qTrackCountCmd->SetGuidance(" wflag :(Bool) weighted");
param = new G4UIparameter("qname",'s',false);
param = new G4UIparameter("qname", 's', false);
qTrackCountCmd->SetParameter(param);
param = new G4UIparameter("dflag",'i',true);
param = new G4UIparameter("dflag", 'i', true);
param->SetDefaultValue("0");
qTrackCountCmd->SetParameter(param);
param = new G4UIparameter("wflag",'b',true);
param = new G4UIparameter("wflag", 'b', true);
param->SetDefaultValue("false");
qTrackCountCmd->SetParameter(param);
//
qTerminationCmd = new G4UIcommand("/score/quantity/nOfTerminatedTrack",this);
qTerminationCmd = new G4UIcommand("/score/quantity/nOfTerminatedTrack", this);
qTerminationCmd->SetGuidance("Number of terminated tracks scorer.");
qTerminationCmd->
SetGuidance("[usage] /score/quantity/nOfTerminatedTrack qname wflag");
qTerminationCmd->SetGuidance(
"[usage] /score/quantity/nOfTerminatedTrack qname wflag");
qTerminationCmd->SetGuidance(" qname :(String) scorer name");
qTerminationCmd->SetGuidance(" wflag :(Bool) weighted");
param = new G4UIparameter("qname",'s',false);
param = new G4UIparameter("qname", 's', false);
qTerminationCmd->SetParameter(param);
param = new G4UIparameter("wflag",'b',true);
param = new G4UIparameter("wflag", 'b', true);
param->SetDefaultValue("false");
qTerminationCmd->SetParameter(param);
//
qMinKinEAtGeneCmd = new G4UIcommand("/score/quantity/minKinEAtGeneration",this);
qMinKinEAtGeneCmd =
new G4UIcommand("/score/quantity/minKinEAtGeneration", this);
qMinKinEAtGeneCmd->SetGuidance("Min Kinetic Energy at Generation");
qMinKinEAtGeneCmd->
SetGuidance("[usage] /score/quantity/minKinEAtGeneration qname unit");
qMinKinEAtGeneCmd->SetGuidance(
"[usage] /score/quantity/minKinEAtGeneration qname unit");
qMinKinEAtGeneCmd->SetGuidance(" qname :(String) scorer name");
qMinKinEAtGeneCmd->SetGuidance(" unit :(String) unit name");
param = new G4UIparameter("qname",'s',false);
param = new G4UIparameter("qname", 's', false);
qMinKinEAtGeneCmd->SetParameter(param);
param = new G4UIparameter("unit",'s',true);
param = new G4UIparameter("unit", 's', true);
param->SetDefaultUnit("MeV");
qMinKinEAtGeneCmd->SetParameter(param);
//
qStepCheckerCmd = new G4UIcommand("/score/quantity/stepChecker",this);
qStepCheckerCmd = new G4UIcommand("/score/quantity/stepChecker", this);
qStepCheckerCmd->SetGuidance("Display a comment when this PS is invoked");
qStepCheckerCmd->
SetGuidance("[usage] /score/quantity/stepChecker qname");
qStepCheckerCmd->SetGuidance("[usage] /score/quantity/stepChecker qname");
qStepCheckerCmd->SetGuidance(" qname :(String) scorer name");
param = new G4UIparameter("qname",'s',false);
param = new G4UIparameter("qname", 's', false);
qStepCheckerCmd->SetParameter(param);
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -49,24 +49,30 @@ G4ScoringManager* G4ScoringManager::GetScoringManager()
}
G4ScoringManager* G4ScoringManager::GetScoringManagerIfExist()
{ return fSManager; }
{
return fSManager;
}
G4ScoringManager::G4ScoringManager()
: verboseLevel(0),fCurrentMesh(nullptr)
: verboseLevel(0)
, fCurrentMesh(nullptr)
{
fMessenger = new G4ScoringMessenger(this);
fQuantityMessenger = new G4ScoreQuantityMessenger(this);
fColorMapDict = new ColorMapDict();
fMessenger = new G4ScoringMessenger(this);
fQuantityMessenger = new G4ScoreQuantityMessenger(this);
fColorMapDict = new ColorMapDict();
fDefaultLinearColorMap = new G4DefaultLinearColorMap("defaultLinearColorMap");
(*fColorMapDict)[fDefaultLinearColorMap->GetName()] = fDefaultLinearColorMap;
G4VScoreColorMap * logColorMap = new G4ScoreLogColorMap("logColorMap");
G4VScoreColorMap* logColorMap = new G4ScoreLogColorMap("logColorMap");
(*fColorMapDict)[logColorMap->GetName()] = logColorMap;
writer = new G4VScoreWriter();
writer = new G4VScoreWriter();
}
G4ScoringManager::~G4ScoringManager()
{
if (writer) { delete writer; }
if(writer)
{
delete writer;
}
delete fDefaultLinearColorMap;
delete fColorMapDict;
delete fQuantityMessenger;
@@ -74,56 +80,70 @@ G4ScoringManager::~G4ScoringManager()
fSManager = nullptr;
}
void G4ScoringManager::SetReplicaLevel(G4int lvl)
{ replicaLevel = lvl; }
G4int G4ScoringManager::GetReplicaLevel()
{ return replicaLevel; }
void G4ScoringManager::SetReplicaLevel(G4int lvl) { replicaLevel = lvl; }
G4int G4ScoringManager::GetReplicaLevel() { return replicaLevel; }
void G4ScoringManager::Accumulate(G4VHitsCollection* map)
{
auto sm = FindMesh(map);
if(!sm) return;
if(verboseLevel>9)
{ G4cout << "G4ScoringManager::Accumulate() for " << map->GetSDname() << " / " << map->GetName() << G4endl;
G4cout << " is calling G4VScoringMesh::Accumulate() of " << sm->GetWorldName() << G4endl; }
if(!sm)
return;
if(verboseLevel > 9)
{
G4cout << "G4ScoringManager::Accumulate() for " << map->GetSDname() << " / "
<< map->GetName() << G4endl;
G4cout << " is calling G4VScoringMesh::Accumulate() of "
<< sm->GetWorldName() << G4endl;
}
sm->Accumulate(static_cast<G4THitsMap<double>*>(map));
}
G4VScoringMesh* G4ScoringManager::FindMesh(G4VHitsCollection* map)
{
auto colID = map->GetColID();
auto colID = map->GetColID();
G4VScoringMesh* sm = nullptr;
auto msh = fMeshMap.find(colID);
if(msh==fMeshMap.end())
auto msh = fMeshMap.find(colID);
if(msh == fMeshMap.end())
{
auto wName = map->GetSDname();
sm = FindMesh(wName);
auto wName = map->GetSDname();
sm = FindMesh(wName);
fMeshMap[colID] = sm;
}
else
{ sm = (*msh).second; }
{
sm = (*msh).second;
}
return sm;
}
G4VScoringMesh* G4ScoringManager::FindMesh(const G4String& wName)
{
G4VScoringMesh* sm = nullptr;
for(auto msh : fMeshVec)
{ if(msh->GetWorldName()==wName) return msh; }
if(!sm && verboseLevel>9)
{ G4cout << "WARNING : G4ScoringManager::FindMesh() --- <" << wName << "> is not found. Null returned." << G4endl; }
{
if(msh->GetWorldName() == wName)
return msh;
}
if(!sm && verboseLevel > 9)
{
G4cout << "WARNING : G4ScoringManager::FindMesh() --- <" << wName
<< "> is not found. Null returned." << G4endl;
}
return nullptr;
}
void G4ScoringManager::List() const
{
G4cout << "G4ScoringManager has " << GetNumberOfMesh() << " scoring meshes." << G4endl;
for(auto msh : fMeshVec) msh->List();
G4cout << "G4ScoringManager has " << GetNumberOfMesh() << " scoring meshes."
<< G4endl;
for(auto msh : fMeshVec)
msh->List();
}
void G4ScoringManager::Dump() const
{
for(auto msh : fMeshVec) msh->Dump();
for(auto msh : fMeshVec)
msh->Dump();
}
void G4ScoringManager::DrawMesh(const G4String& meshName,
@@ -131,39 +151,44 @@ void G4ScoringManager::DrawMesh(const G4String& meshName,
const G4String& colorMapName, G4int axflg)
{
G4VScoringMesh* mesh = FindMesh(meshName);
if(mesh)
if(mesh)
{
G4VScoreColorMap* colorMap = GetScoreColorMap(colorMapName);
if(!colorMap)
{
G4cerr << "WARNING : Score color map <" << colorMapName << "> is not found. Default linear color map is used." << G4endl;
G4cerr << "WARNING : Score color map <" << colorMapName
<< "> is not found. Default linear color map is used." << G4endl;
colorMap = fDefaultLinearColorMap;
}
mesh->DrawMesh(psName,colorMap,axflg);
} else {
G4cerr << "ERROR : G4ScoringManager::DrawMesh() --- <"
<< meshName << "> is not found. Nothing is done." << G4endl;
mesh->DrawMesh(psName, colorMap, axflg);
}
else
{
G4cerr << "ERROR : G4ScoringManager::DrawMesh() --- <" << meshName
<< "> is not found. Nothing is done." << G4endl;
}
}
void G4ScoringManager::DrawMesh(const G4String& meshName,
const G4String& psName,
G4int idxPlane, G4int iColumn,
const G4String& colorMapName)
const G4String& psName, G4int idxPlane,
G4int iColumn, const G4String& colorMapName)
{
G4VScoringMesh* mesh = FindMesh(meshName);
if(mesh)
if(mesh)
{
G4VScoreColorMap* colorMap = GetScoreColorMap(colorMapName);
if(!colorMap)
{
G4cerr << "WARNING : Score color map <" << colorMapName << "> is not found. Default linear color map is used." << G4endl;
G4cerr << "WARNING : Score color map <" << colorMapName
<< "> is not found. Default linear color map is used." << G4endl;
colorMap = fDefaultLinearColorMap;
}
mesh->DrawMesh(psName,idxPlane,iColumn,colorMap);
} else {
G4cerr << "ERROR : G4ScoringManager::DrawMesh() --- <"
<< meshName << "> is not found. Nothing is done." << G4endl;
mesh->DrawMesh(psName, idxPlane, iColumn, colorMap);
}
else
{
G4cerr << "ERROR : G4ScoringManager::DrawMesh() --- <" << meshName
<< "> is not found. Nothing is done." << G4endl;
}
}
@@ -173,12 +198,15 @@ void G4ScoringManager::DumpQuantityToFile(const G4String& meshName,
const G4String& option)
{
G4VScoringMesh* mesh = FindMesh(meshName);
if(mesh) {
if(mesh)
{
writer->SetScoringMesh(mesh);
writer->DumpQuantityToFile(psName, fileName, option);
} else {
G4cerr << "ERROR : G4ScoringManager::DrawQuantityToFile() --- <"
<< meshName << "> is not found. Nothing is done." << G4endl;
}
else
{
G4cerr << "ERROR : G4ScoringManager::DrawQuantityToFile() --- <" << meshName
<< "> is not found. Nothing is done." << G4endl;
}
}
@@ -187,12 +215,15 @@ void G4ScoringManager::DumpAllQuantitiesToFile(const G4String& meshName,
const G4String& option)
{
G4VScoringMesh* mesh = FindMesh(meshName);
if(mesh) {
if(mesh)
{
writer->SetScoringMesh(mesh);
writer->DumpAllQuantitiesToFile(fileName, option);
} else {
}
else
{
G4cerr << "ERROR : G4ScoringManager::DrawAllQuantitiesToFile() --- <"
<< meshName << "> is not found. Nothing is done." << G4endl;
<< meshName << "> is not found. Nothing is done." << G4endl;
}
}
@@ -201,7 +232,8 @@ void G4ScoringManager::RegisterScoreColorMap(G4VScoreColorMap* colorMap)
if(fColorMapDict->find(colorMap->GetName()) != fColorMapDict->end())
{
G4cerr << "ERROR : G4ScoringManager::RegisterScoreColorMap -- "
<< colorMap->GetName() << " has already been registered. Method ignored." << G4endl;
<< colorMap->GetName()
<< " has already been registered. Method ignored." << G4endl;
}
else
{
@@ -212,27 +244,32 @@ void G4ScoringManager::RegisterScoreColorMap(G4VScoreColorMap* colorMap)
G4VScoreColorMap* G4ScoringManager::GetScoreColorMap(const G4String& mapName)
{
ColorMapDictItr mItr = fColorMapDict->find(mapName);
if(mItr == fColorMapDict->end()) { return nullptr; }
if(mItr == fColorMapDict->end())
{
return nullptr;
}
return (mItr->second);
}
void G4ScoringManager::ListScoreColorMaps()
{
G4cout << "Registered Score Color Maps -------------------------------------------------------" << G4endl;
G4cout << "Registered Score Color Maps "
"-------------------------------------------------------"
<< G4endl;
ColorMapDictItr mItr = fColorMapDict->begin();
for(;mItr!=fColorMapDict->end();mItr++)
{ G4cout << " " << mItr->first; }
for(; mItr != fColorMapDict->end(); mItr++)
{
G4cout << " " << mItr->first;
}
G4cout << G4endl;
}
void G4ScoringManager::Merge(const G4ScoringManager * mgr)
{
for(size_t i = 0; i< GetNumberOfMesh() ; i++)
void G4ScoringManager::Merge(const G4ScoringManager* mgr)
{
for(size_t i = 0; i < GetNumberOfMesh(); i++)
{
G4VScoringMesh* fMesh = GetMesh(i);
G4VScoringMesh* fMesh = GetMesh(i);
G4VScoringMesh* scMesh = mgr->GetMesh(i);
fMesh->Merge(scMesh);
}
}
File diff suppressed because it is too large Load Diff
+62 -46
View File
@@ -47,95 +47,111 @@
#include "G4SystemOfUnits.hh"
#include "G4VisAttributes.hh"
G4ScoringProbe::G4ScoringProbe(G4String lvName, G4double half_size, G4bool checkOverlap)
:G4VScoringMesh(lvName), chkOverlap(checkOverlap),
layeredMaterialName("none"), layeredMaterial(nullptr)
G4ScoringProbe::G4ScoringProbe(G4String lvName, G4double half_size,
G4bool checkOverlap)
: G4VScoringMesh(lvName)
, chkOverlap(checkOverlap)
, layeredMaterialName("none")
, layeredMaterial(nullptr)
{
fShape = MeshShape::probe;
logVolName = lvName;
probeSize = half_size;
G4double hs[] = {half_size,half_size,half_size};
fShape = MeshShape::probe;
logVolName = lvName;
probeSize = half_size;
G4double hs[] = { half_size, half_size, half_size };
SetSize(hs);
G4int nBin[] = {1,1,1};
G4int nBin[] = { 1, 1, 1 };
SetNumberOfSegments(nBin);
regName = lvName + "_region";
if(G4Threading::IsMasterThread())
{ new G4Region(regName); }
{
new G4Region(regName);
}
}
G4ScoringProbe::~G4ScoringProbe()
{
}
G4ScoringProbe::~G4ScoringProbe() {}
void G4ScoringProbe::List() const
{
G4cout << "G4ScoringProbe : " << logVolName << G4endl;
G4int np = posVec.size();
for(G4int i=0;i<np;i++)
{ G4cout << " >> probe #" << i << " at " << posVec[i] << G4endl; }
for(G4int i = 0; i < np; i++)
{
G4cout << " >> probe #" << i << " at " << posVec[i] << G4endl;
}
G4VScoringMesh::List();
}
#include "G4AutoLock.hh"
namespace { G4Mutex logvolmutex = G4MUTEX_INITIALIZER; }
namespace
{
G4Mutex logvolmutex = G4MUTEX_INITIALIZER;
}
void G4ScoringProbe::SetupGeometry(G4VPhysicalVolume* worldPhys)
void G4ScoringProbe::SetupGeometry(G4VPhysicalVolume* worldPhys)
{
if(G4Threading::IsMasterThread())
{
auto worldLog = worldPhys->GetLogicalVolume();
auto region = G4RegionStore::GetInstance()->GetRegion(regName);
assert(region!=nullptr);
auto region = G4RegionStore::GetInstance()->GetRegion(regName);
assert(region != nullptr);
region->AddRootLogicalVolume(worldLog);
region->SetWorld(worldPhys);
auto boxSolid = new G4Box(logVolName+"_solid",probeSize,probeSize,probeSize);
fMeshElementLogical = new G4LogicalVolume(boxSolid,layeredMaterial,logVolName+"_log");
auto boxSolid =
new G4Box(logVolName + "_solid", probeSize, probeSize, probeSize);
fMeshElementLogical =
new G4LogicalVolume(boxSolid, layeredMaterial, logVolName + "_log");
G4int np = posVec.size();
for(G4int i=0;i<np;i++)
{ new G4PVPlacement(0,posVec[i],fMeshElementLogical,logVolName+"_phy",worldLog,false,i,chkOverlap); }
for(G4int i = 0; i < np; i++)
{
new G4PVPlacement(0, posVec[i], fMeshElementLogical, logVolName + "_phy",
worldLog, false, i, chkOverlap);
}
G4VisAttributes* wisatt = new G4VisAttributes(G4Colour(.5,.5,.5));
G4VisAttributes* wisatt = new G4VisAttributes(G4Colour(.5, .5, .5));
wisatt->SetVisibility(false);
worldLog->SetVisAttributes(wisatt);
G4VisAttributes* visatt = new G4VisAttributes(G4Colour(.5,.5,.5));
G4VisAttributes* visatt = new G4VisAttributes(G4Colour(.5, .5, .5));
visatt->SetVisibility(true);
fMeshElementLogical->SetVisAttributes(visatt);
}
else
{
{
G4AutoLock l(&logvolmutex);
fMeshElementLogical = G4LogicalVolumeStore::GetInstance()->GetVolume(logVolName,false);
assert(fMeshElementLogical!=nullptr);
fMeshElementLogical =
G4LogicalVolumeStore::GetInstance()->GetVolume(logVolName, false);
assert(fMeshElementLogical != nullptr);
l.unlock();
}
fMeshElementLogical->SetSensitiveDetector(fMFD);
}
G4bool G4ScoringProbe::SetMaterial(G4String val)
{
G4AutoLock l(&logvolmutex);
if(val == "none")
if(G4Threading::IsMasterThread())
{
layeredMaterialName = val;
layeredMassFlg = false;
layeredMaterial = nullptr;
if(val == "none")
{
layeredMaterialName = val;
layeredMassFlg = false;
layeredMaterial = nullptr;
}
else
{
auto mat = G4NistManager::Instance()->FindOrBuildMaterial(val);
if(!mat)
{
return false;
}
layeredMaterialName = val;
layeredMassFlg = true;
layeredMaterial = mat;
}
auto region = G4RegionStore::GetInstance()->GetRegion(regName);
assert(region != nullptr);
region->UpdateMaterialList();
}
else
{
auto mat = G4NistManager::Instance()->FindOrBuildMaterial(val);
if(!mat)
{ return false; }
layeredMaterialName = val;
layeredMassFlg = true;
layeredMaterial = mat;
}
auto region = G4RegionStore::GetInstance()->GetRegion(regName);
assert(region!=nullptr);
region->UpdateMaterialList();
return true;
}
@@ -41,19 +41,17 @@
#include "G4SystemOfUnits.hh"
G4ScoringRealWorld::G4ScoringRealWorld(G4String lvName)
:G4VScoringMesh(lvName)
: G4VScoringMesh(lvName)
{
fShape = MeshShape::realWorldLogVol;
logVolName = lvName;
G4double size[] = {0.,0.,0.};
fShape = MeshShape::realWorldLogVol;
logVolName = lvName;
G4double size[] = { 0., 0., 0. };
SetSize(size);
G4int nBin[] = {1,1,1};
G4int nBin[] = { 1, 1, 1 };
SetNumberOfSegments(nBin);
}
G4ScoringRealWorld::~G4ScoringRealWorld()
{
}
G4ScoringRealWorld::~G4ScoringRealWorld() {}
void G4ScoringRealWorld::List() const
{
@@ -62,35 +60,41 @@ void G4ScoringRealWorld::List() const
}
#include "G4AutoLock.hh"
namespace { G4Mutex logvolmutex = G4MUTEX_INITIALIZER; }
void G4ScoringRealWorld::SetupGeometry(G4VPhysicalVolume* )
namespace
{
G4Mutex logvolmutex = G4MUTEX_INITIALIZER;
}
void G4ScoringRealWorld::SetupGeometry(G4VPhysicalVolume*)
{
G4AutoLock l(&logvolmutex);
auto store = G4LogicalVolumeStore::GetInstance();
auto itr = store->begin();
for(;itr!=store->end();itr++)
auto itr = store->begin();
for(; itr != store->end(); itr++)
{
if((*itr)->GetName()==logVolName)
if((*itr)->GetName() == logVolName)
{
fMeshElementLogical = (*itr); // Logical volume to score
G4int nb = 0;
auto pvStore = G4PhysicalVolumeStore::GetInstance();
auto pvItr = pvStore->begin();
for(;pvItr!=pvStore->end();pvItr++)
G4int nb = 0;
auto pvStore = G4PhysicalVolumeStore::GetInstance();
auto pvItr = pvStore->begin();
for(; pvItr != pvStore->end(); pvItr++)
{
if((*pvItr)->GetLogicalVolume()==(*itr))
{ nb += (*pvItr)->GetMultiplicity(); }
if((*pvItr)->GetLogicalVolume() == (*itr))
{
nb += (*pvItr)->GetMultiplicity();
}
}
G4int nBin[] = {nb,1,1};
G4int nBin[] = { nb, 1, 1 };
SetNumberOfSegments(nBin);
// check if this logical volume belongs to the real world
auto region = (*itr)->GetRegion();
if(region && !(region->IsInMassGeometry()))
{
G4ExceptionDescription ed;
ed << "Logical Volume with name <" << logVolName << "> is not used in the mass world.";
G4Exception("G4ScoringRealWorld","SWV0001",FatalException,ed);
}
ed << "Logical Volume with name <" << logVolName
<< "> is not used in the mass world.";
G4Exception("G4ScoringRealWorld", "SWV0001", FatalException, ed);
}
// set the sensitive detector
fMeshElementLogical->SetSensitiveDetector(fMFD);
return;
@@ -98,7 +102,5 @@ void G4ScoringRealWorld::SetupGeometry(G4VPhysicalVolume* )
}
G4ExceptionDescription ed;
ed << "Logical Volume with name <" << logVolName << "> is not found";
G4Exception("G4ScoringRealWorld","SWV0000",FatalException,ed);
G4Exception("G4ScoringRealWorld", "SWV0000", FatalException, ed);
}
@@ -40,17 +40,24 @@
#include "G4Polyhedron.hh"
G4VScoreColorMap::G4VScoreColorMap(G4String mName)
:fName(mName),ifFloat(true),fMinVal(0.),fMaxVal(DBL_MAX),fVisManager(nullptr)
{;}
: fName(mName)
, ifFloat(true)
, fMinVal(0.)
, fMaxVal(DBL_MAX)
, fVisManager(nullptr)
{
;
}
G4VScoreColorMap::~G4VScoreColorMap()
{;}
void G4VScoreColorMap::DrawColorChart(G4int _nPoint) {
G4VScoreColorMap::~G4VScoreColorMap() { ; }
void G4VScoreColorMap::DrawColorChart(G4int _nPoint)
{
fVisManager = G4VVisManager::GetConcreteInstance();
if(!fVisManager) {
G4cerr << "G4VScoringMesh::DrawColorChart(): no visualization system" << G4endl;
if(!fVisManager)
{
G4cerr << "G4VScoringMesh::DrawColorChart(): no visualization system"
<< G4endl;
return;
}
@@ -58,64 +65,66 @@ void G4VScoreColorMap::DrawColorChart(G4int _nPoint) {
DrawColorChartText(_nPoint);
}
void G4VScoreColorMap::DrawColorChartBar(G4int _nPoint) {
G4double min = this->GetMin();
G4double max = this->GetMax();
G4double smin = -0.89, smax = smin + 0.05*(_nPoint)*0.83, step=0.001;
void G4VScoreColorMap::DrawColorChartBar(G4int _nPoint)
{
G4double min = this->GetMin();
G4double max = this->GetMax();
G4double smin = -0.89, smax = smin + 0.05 * (_nPoint) *0.83, step = 0.001;
G4double c[4];
fVisManager->BeginDraw2D();
for(G4double y = smin; y < smax; y+=step) {
G4double ra = (y-smin)/(smax-smin), rb = 1.-ra;
for(G4double y = smin; y < smax; y += step)
{
G4double ra = (y - smin) / (smax - smin), rb = 1. - ra;
G4Polyline line;
line.push_back(G4Point3D(-0.96, y, 0.));
line.push_back(G4Point3D(-0.91, y, 0.));
this->GetMapColor((ra*max+rb*min)/(ra+rb), c);
this->GetMapColor((ra * max + rb * min) / (ra + rb), c);
G4Colour col(c[0], c[1], c[2]);
G4VisAttributes att(col);
line.SetVisAttributes(&att);
fVisManager->Draw2D(line);
}
fVisManager->EndDraw2D();
}
void G4VScoreColorMap::DrawColorChartText(G4int _nPoint) {
void G4VScoreColorMap::DrawColorChartText(G4int _nPoint)
{
G4double min = this->GetMin();
G4double max = this->GetMax();
G4double c[4];
G4Colour black(0.1, 0.1, 0.1, 0.8);
fVisManager->BeginDraw2D();
for(int n = 0; n < _nPoint; n++) {
G4double a = n/(_nPoint-1.), b = 1.-a;
G4double v = (a*max + b*min)/(a+b);
for(int n = 0; n < _nPoint; n++)
{
G4double a = n / (_nPoint - 1.), b = 1. - a;
G4double v = (a * max + b * min) / (a + b);
// background color
for(int l = 0; l < 21; l++) {
for(int l = 0; l < 21; l++)
{
G4Polyline line;
line.push_back(G4Point3D(-0.9, -0.905+0.05*n+0.002*l, 0.));
line.push_back(G4Point3D(-0.75, -0.905+0.05*n+0.002*l, 0.));
line.push_back(G4Point3D(-0.9, -0.905 + 0.05 * n + 0.002 * l, 0.));
line.push_back(G4Point3D(-0.75, -0.905 + 0.05 * n + 0.002 * l, 0.));
G4VisAttributes attblack(black);
line.SetVisAttributes(&attblack);
fVisManager->Draw2D(line);
}
// text
//char cstring[80];
//std::sprintf(cstring, "%8.2e", v);
//G4String value(cstring);
// char cstring[80];
// std::sprintf(cstring, "%8.2e", v);
// G4String value(cstring);
std::ostringstream oss;
oss << std::setw(8) << std::setprecision(1) << std::scientific << v;
std::string str = oss.str();
G4String value = str;//.c_str());
G4String value = str; //.c_str());
G4Text text(value, G4Point3D(-0.9, -0.9+0.05*n, 0.4));
G4Text text(value, G4Point3D(-0.9, -0.9 + 0.05 * n, 0.4));
G4double size = 12.;
text.SetScreenSize(size);
this->GetMapColor(v, c);
@@ -128,14 +137,17 @@ void G4VScoreColorMap::DrawColorChartText(G4int _nPoint) {
// draw ps name
// background
G4double lpsname = 2.+fPSName.size()*0.95;
if(lpsname > 0) {
for(int l = 0; l < 22; l++) {
G4double lpsname = 2. + fPSName.size() * 0.95;
if(lpsname > 0)
{
for(int l = 0; l < 22; l++)
{
G4Polyline line;
line.push_back(G4Point3D(-0.92, -0.965+0.002*l, 0.));
line.push_back(G4Point3D(-0.92+0.025*lpsname, -0.965+0.002*l, 0.));
line.push_back(G4Point3D(-0.92, -0.965 + 0.002 * l, 0.));
line.push_back(
G4Point3D(-0.92 + 0.025 * lpsname, -0.965 + 0.002 * l, 0.));
G4VisAttributes attblack(black);
//G4VisAttributes attblack(G4Colour(.5, .5, 1.));
// G4VisAttributes attblack(G4Colour(.5, .5, 1.));
line.SetVisAttributes(&attblack);
fVisManager->Draw2D(line);
}
@@ -148,19 +160,20 @@ void G4VScoreColorMap::DrawColorChartText(G4int _nPoint) {
G4VisAttributes att(color);
txtpsname.SetVisAttributes(&att);
fVisManager->Draw2D(txtpsname);
}
// draw unit
// background
G4double len = 2.+fPSUnit.size();
if(len > 0) {
for(int l = 0; l < 21; l++) {
G4double len = 2. + fPSUnit.size();
if(len > 0)
{
for(int l = 0; l < 21; l++)
{
G4Polyline line;
line.push_back(G4Point3D(-0.7, -0.9+0.002*l, 0.));
line.push_back(G4Point3D(-0.7+0.025*len, -0.9+0.002*l, 0.));
line.push_back(G4Point3D(-0.7, -0.9 + 0.002 * l, 0.));
line.push_back(G4Point3D(-0.7 + 0.025 * len, -0.9 + 0.002 * l, 0.));
G4VisAttributes attblack(black);
//G4VisAttributes attblack(G4Colour(.5, .5, .5));
// G4VisAttributes attblack(G4Colour(.5, .5, .5));
line.SetVisAttributes(&attblack);
fVisManager->Draw2D(line);
}
@@ -175,8 +188,6 @@ void G4VScoreColorMap::DrawColorChartText(G4int _nPoint) {
txtunit.SetVisAttributes(&att);
fVisManager->Draw2D(txtunit);
}
fVisManager->EndDraw2D();
}
@@ -30,26 +30,28 @@
#include "G4VScoreNtupleWriter.hh"
//_____________________________________________________________________________
G4VScoreNtupleWriter* G4VScoreNtupleWriter::fgMasterInstance = 0;
G4ThreadLocal G4VScoreNtupleWriter* G4VScoreNtupleWriter::fgInstance = 0;
G4VScoreNtupleWriter* G4VScoreNtupleWriter::fgMasterInstance = 0;
G4ThreadLocal G4VScoreNtupleWriter* G4VScoreNtupleWriter::fgInstance = 0;
//_____________________________________________________________________________
G4VScoreNtupleWriter* G4VScoreNtupleWriter::Instance()
{
// This function invokes creating the objects on workes,
// The master instance should be created by the user
// via the concrete class constructor
// This function invokes creating the objects on workes,
// The master instance should be created by the user
// via the concrete class constructor
G4bool isMaster = ! G4Threading::IsWorkerThread();
G4bool isMaster = !G4Threading::IsWorkerThread();
if ( ( ! isMaster ) && ( ! fgInstance ) ) {
if ( fgMasterInstance ) {
if((!isMaster) && (!fgInstance))
{
if(fgMasterInstance)
{
fgInstance = fgMasterInstance->CreateInstance();
}
}
return fgInstance;
}
}
//
// ctor, dtor
@@ -58,32 +60,30 @@ G4VScoreNtupleWriter* G4VScoreNtupleWriter::Instance()
//_____________________________________________________________________________
G4VScoreNtupleWriter::G4VScoreNtupleWriter()
{
G4bool isMaster = ! G4Threading::IsWorkerThread();
G4bool isMaster = !G4Threading::IsWorkerThread();
if ( isMaster && fgMasterInstance ) {
if(isMaster && fgMasterInstance)
{
G4ExceptionDescription description;
description
<< " "
<< "G4VScoreNtupleWriter on master already exists."
<< "Cannot create another instance.";
G4Exception("G4VScoreNtupleWriter::G4VScoreNtupleWriter()",
"Analysis_F001", FatalException, description);
description << " "
<< "G4VScoreNtupleWriter on master already exists."
<< "Cannot create another instance.";
G4Exception("G4VScoreNtupleWriter::G4VScoreNtupleWriter()", "Analysis_F001",
FatalException, description);
}
if ( fgInstance ) {
if(fgInstance)
{
G4ExceptionDescription description;
description
<< " "
<< "G4VScoreNtupleWriter on worker already exists."
<< "Cannot create another instance.";
G4Exception("G4VScoreNtupleWriter::G4VScoreNtupleWriter()",
"Analysis_F001", FatalException, description);
description << " "
<< "G4VScoreNtupleWriter on worker already exists."
<< "Cannot create another instance.";
G4Exception("G4VScoreNtupleWriter::G4VScoreNtupleWriter()", "Analysis_F001",
FatalException, description);
}
if ( isMaster ) fgMasterInstance = this;
if(isMaster)
fgMasterInstance = this;
fgInstance = this;
}
//_____________________________________________________________________________
G4VScoreNtupleWriter::~G4VScoreNtupleWriter()
{
fgInstance = 0;
}
G4VScoreNtupleWriter::~G4VScoreNtupleWriter() { fgInstance = 0; }
+144 -116
View File
@@ -37,41 +37,44 @@
#include <fstream>
G4VScoreWriter::G4VScoreWriter()
: fScoringMesh(nullptr), verboseLevel(0), fact(1.0)
: fScoringMesh(nullptr)
, verboseLevel(0)
, fact(1.0)
{
fNMeshSegments[0] = fNMeshSegments[1] = fNMeshSegments[2] = 0;
}
G4VScoreWriter::~G4VScoreWriter() {
}
G4VScoreWriter::~G4VScoreWriter() {}
void G4VScoreWriter::SetScoringMesh(G4VScoringMesh * sm) {
fScoringMesh = sm;
fScoringMesh->GetNumberOfSegments(fNMeshSegments);
void G4VScoreWriter::SetScoringMesh(G4VScoringMesh* sm)
{
fScoringMesh = sm;
fScoringMesh->GetNumberOfSegments(fNMeshSegments);
}
void G4VScoreWriter::DumpQuantityToFile(const G4String& psName,
const G4String& fileName,
const G4String& option) {
const G4String& option)
{
// change the option string into lowercase to the case-insensitive.
G4String opt = option;
std::transform(opt.begin(), opt.end(), opt.begin(), (int (*)(int))(tolower));
// confirm the option
if(opt.size() == 0) opt = "csv";
if(opt.size() == 0)
opt = "csv";
if(opt.find("csv") == std::string::npos &&
opt.find("sequence") == std::string::npos) {
G4cerr << "ERROR : DumpToFile : Unknown option -> "
<< option << G4endl;
opt.find("sequence") == std::string::npos)
{
G4cerr << "ERROR : DumpToFile : Unknown option -> " << option << G4endl;
return;
}
// open the file
std::ofstream ofile(fileName);
if(!ofile) {
G4cerr << "ERROR : DumpToFile : File open error -> "
<< fileName << G4endl;
if(!ofile)
{
G4cerr << "ERROR : DumpToFile : File open error -> " << fileName << G4endl;
return;
}
ofile << "# mesh name: " << fScoringMesh->GetWorldName() << G4endl;
@@ -79,177 +82,202 @@ void G4VScoreWriter::DumpQuantityToFile(const G4String& psName,
using MeshScoreMap = G4VScoringMesh::MeshScoreMap;
// retrieve the map
MeshScoreMap fSMap = fScoringMesh->GetScoreMap();
MeshScoreMap::const_iterator msMapItr = fSMap.find(psName);
if(msMapItr == fSMap.end()) {
G4cerr << "ERROR : DumpToFile : Unknown quantity, \""
<< psName << "\"." << G4endl;
if(msMapItr == fSMap.end())
{
G4cerr << "ERROR : DumpToFile : Unknown quantity, \"" << psName << "\"."
<< G4endl;
return;
}
std::map<G4int, G4StatDouble*> * score = msMapItr->second->GetMap();
std::map<G4int, G4StatDouble*>* score = msMapItr->second->GetMap();
ofile << "# primitive scorer name: " << msMapItr->first << std::endl;
if(fact!=1.0)
{ ofile << "# multiplied factor : " << fact << std::endl; }
if(fact != 1.0)
{
ofile << "# multiplied factor : " << fact << std::endl;
}
G4double unitValue = fScoringMesh->GetPSUnitValue(psName);
G4String unit = fScoringMesh->GetPSUnit(psName);
G4String unit = fScoringMesh->GetPSUnit(psName);
G4String divisionAxisNames[3];
fScoringMesh->GetDivisionAxisNames(divisionAxisNames);
// index order
ofile << "# i" << divisionAxisNames[0]
<< ", i" << divisionAxisNames[1]
<< ", i" << divisionAxisNames[2];
ofile << "# i" << divisionAxisNames[0] << ", i" << divisionAxisNames[1]
<< ", i" << divisionAxisNames[2];
// unit of scored value
ofile << ", total(value) ";
if(unit.size() > 0) ofile << "[" << unit << "]";
if(unit.size() > 0)
ofile << "[" << unit << "]";
ofile << ", total(val^2), entry" << G4endl;
// "sequence" option: write header info
if(opt.find("sequence") != std::string::npos) {
ofile << fNMeshSegments[0] << " " << fNMeshSegments[1] << " " << fNMeshSegments[2]
<< G4endl;
// "sequence" option: write header info
if(opt.find("sequence") != std::string::npos)
{
ofile << fNMeshSegments[0] << " " << fNMeshSegments[1] << " "
<< fNMeshSegments[2] << G4endl;
}
// write quantity
long count = 0;
ofile << std::setprecision(16); // for double value with 8 bytes
for(int x = 0; x < fNMeshSegments[0]; x++) {
for(int y = 0; y < fNMeshSegments[1]; y++) {
for(int z = 0; z < fNMeshSegments[2]; z++) {
G4int idx = GetIndex(x, y, z);
if(opt.find("csv") != std::string::npos)
ofile << x << "," << y << "," << z << ",";
ofile << std::setprecision(16); // for double value with 8 bytes
for(int x = 0; x < fNMeshSegments[0]; x++)
{
for(int y = 0; y < fNMeshSegments[1]; y++)
{
for(int z = 0; z < fNMeshSegments[2]; z++)
{
G4int idx = GetIndex(x, y, z);
std::map<G4int, G4StatDouble*>::iterator value = score->find(idx);
if(value == score->end()) {
ofile << 0. << "," << 0. << "," << 0;
} else {
ofile << (value->second->sum_wx())/unitValue*fact << ","
<< (value->second->sum_wx2())/unitValue/unitValue*fact*fact << ","
<< value->second->n();
}
if(opt.find("csv") != std::string::npos)
ofile << x << "," << y << "," << z << ",";
if(opt.find("csv") != std::string::npos) {
ofile << G4endl;
} else if(opt.find("sequence") != std::string::npos) {
ofile << " ";
if(count++%5 == 4) ofile << G4endl;
}
std::map<G4int, G4StatDouble*>::iterator value = score->find(idx);
if(value == score->end())
{
ofile << 0. << "," << 0. << "," << 0;
}
else
{
ofile << (value->second->sum_wx()) / unitValue * fact << ","
<< (value->second->sum_wx2()) / unitValue / unitValue * fact *
fact
<< "," << value->second->n();
}
} // z
} // y
} // x
if(opt.find("csv") != std::string::npos)
{
ofile << G4endl;
}
else if(opt.find("sequence") != std::string::npos)
{
ofile << " ";
if(count++ % 5 == 4)
ofile << G4endl;
}
} // z
} // y
} // x
ofile << std::setprecision(6);
// close the file
ofile.close();
}
void G4VScoreWriter::DumpAllQuantitiesToFile(const G4String& fileName,
const G4String& option) {
const G4String& option)
{
// change the option string into lowercase to the case-insensitive.
G4String opt = option;
std::transform(opt.begin(), opt.end(), opt.begin(), (int (*)(int))(tolower));
// confirm the option
if(opt.size() == 0) opt = "csv";
if(opt.size() == 0)
opt = "csv";
if(opt.find("csv") == std::string::npos &&
opt.find("sequence") == std::string::npos) {
G4cerr << "ERROR : DumpToFile : Unknown option -> "
<< option << G4endl;
opt.find("sequence") == std::string::npos)
{
G4cerr << "ERROR : DumpToFile : Unknown option -> " << option << G4endl;
return;
}
// open the file
std::ofstream ofile(fileName);
if(!ofile) {
G4cerr << "ERROR : DumpToFile : File open error -> "
<< fileName << G4endl;
if(!ofile)
{
G4cerr << "ERROR : DumpToFile : File open error -> " << fileName << G4endl;
return;
}
ofile << "# mesh name: " << fScoringMesh->GetWorldName() << G4endl;
if(fact!=1.0)
{ ofile << "# multiplied factor : " << fact << std::endl; }
if(fact != 1.0)
{
ofile << "# multiplied factor : " << fact << std::endl;
}
// retrieve the map
using MeshScoreMap = G4VScoringMesh::MeshScoreMap;
MeshScoreMap fSMap = fScoringMesh->GetScoreMap();
using MeshScoreMap = G4VScoringMesh::MeshScoreMap;
MeshScoreMap fSMap = fScoringMesh->GetScoreMap();
MeshScoreMap::const_iterator msMapItr = fSMap.begin();
std::map<G4int, G4StatDouble*> * score;
for(; msMapItr != fSMap.end(); msMapItr++) {
std::map<G4int, G4StatDouble*>* score;
for(; msMapItr != fSMap.end(); msMapItr++)
{
G4String psname = msMapItr->first;
score = msMapItr->second->GetMap();
ofile << "# primitive scorer name: " << msMapItr->first << std::endl;
G4double unitValue = fScoringMesh->GetPSUnitValue(psname);
G4String unit = fScoringMesh->GetPSUnit(psname);
G4String unit = fScoringMesh->GetPSUnit(psname);
G4String divisionAxisNames[3];
fScoringMesh->GetDivisionAxisNames(divisionAxisNames);
// index order
ofile << "# i" << divisionAxisNames[0]
<< ", i" << divisionAxisNames[1]
<< ", i" << divisionAxisNames[2];
ofile << "# i" << divisionAxisNames[0] << ", i" << divisionAxisNames[1]
<< ", i" << divisionAxisNames[2];
// unit of scored value
ofile << ", total(value) ";
if(unit.size() > 0) ofile << "[" << unit << "]";
if(unit.size() > 0)
ofile << "[" << unit << "]";
ofile << ", total(val^2), entry" << G4endl;
// "sequence" option: write header info
if(opt.find("sequence") != std::string::npos) {
ofile << fNMeshSegments[0] << " " << fNMeshSegments[1] << " " << fNMeshSegments[2]
<< G4endl;
// "sequence" option: write header info
if(opt.find("sequence") != std::string::npos)
{
ofile << fNMeshSegments[0] << " " << fNMeshSegments[1] << " "
<< fNMeshSegments[2] << G4endl;
}
// write quantity
long count = 0;
ofile << std::setprecision(16); // for double value with 8 bytes
for(int x = 0; x < fNMeshSegments[0]; x++) {
for(int y = 0; y < fNMeshSegments[1]; y++) {
for(int z = 0; z < fNMeshSegments[2]; z++) {
G4int idx = GetIndex(x, y, z);
if(opt.find("csv") != std::string::npos)
ofile << x << "," << y << "," << z << ",";
std::map<G4int, G4StatDouble*>::iterator value = score->find(idx);
if(value == score->end()) {
ofile << 0. << "," << 0. << "," << 0;
} else {
ofile << (value->second->sum_wx())/unitValue*fact << ","
<< (value->second->sum_wx2())/unitValue/unitValue*fact*fact << ","
<< value->second->n();
}
ofile << std::setprecision(16); // for double value with 8 bytes
for(int x = 0; x < fNMeshSegments[0]; x++)
{
for(int y = 0; y < fNMeshSegments[1]; y++)
{
for(int z = 0; z < fNMeshSegments[2]; z++)
{
G4int idx = GetIndex(x, y, z);
if(opt.find("csv") != std::string::npos) {
ofile << G4endl;
} else if(opt.find("sequence") != std::string::npos) {
ofile << " ";
if(count++%5 == 4) ofile << G4endl;
}
if(opt.find("csv") != std::string::npos)
ofile << x << "," << y << "," << z << ",";
} // z
} // y
} // x
std::map<G4int, G4StatDouble*>::iterator value = score->find(idx);
if(value == score->end())
{
ofile << 0. << "," << 0. << "," << 0;
}
else
{
ofile << (value->second->sum_wx()) / unitValue * fact << ","
<< (value->second->sum_wx2()) / unitValue / unitValue * fact *
fact
<< "," << value->second->n();
}
if(opt.find("csv") != std::string::npos)
{
ofile << G4endl;
}
else if(opt.find("sequence") != std::string::npos)
{
ofile << " ";
if(count++ % 5 == 4)
ofile << G4endl;
}
} // z
} // y
} // x
ofile << std::setprecision(6);
} // for(; msMapItr ....)
} // for(; msMapItr ....)
// close the file
ofile.close();
}
G4int G4VScoreWriter::GetIndex(G4int x, G4int y, G4int z) const {
//return x + y*fNMeshSegments[0] + z*fNMeshSegments[0]*fNMeshSegments[1];
return x*fNMeshSegments[1]*fNMeshSegments[2] +y*fNMeshSegments[2]+z;
G4int G4VScoreWriter::GetIndex(G4int x, G4int y, G4int z) const
{
// return x + y*fNMeshSegments[0] + z*fNMeshSegments[0]*fNMeshSegments[1];
return x * fNMeshSegments[1] * fNMeshSegments[2] + y * fNMeshSegments[2] + z;
}
+246 -167
View File
@@ -26,11 +26,11 @@
//
//
// ---------------------------------------------------------------------
// Modifications
// 17-Apr-2012 T.Aso SetSize() and SetNumberOfSegments() is not allowed
// Modifications
// 17-Apr-2012 T.Aso SetSize() and SetNumberOfSegments() is not allowed
// to call twice in same geometrical mesh. Add warning
// message to notify.
//
// message to notify.
//
// ---------------------------------------------------------------------
#include "G4VScoringMesh.hh"
@@ -43,236 +43,292 @@
#include "G4SDManager.hh"
G4VScoringMesh::G4VScoringMesh(const G4String& wName)
: fWorldName(wName),fCurrentPS(nullptr),fConstructed(false),fActive(true),
fShape(MeshShape::undefined),
fRotationMatrix(nullptr), fMFD(new G4MultiFunctionalDetector(wName)),
verboseLevel(0),sizeIsSet(false),nMeshIsSet(false),
fDrawUnit(""), fDrawUnitValue(1.), fMeshElementLogical(nullptr),
fParallelWorldProcess(nullptr), fGeometryHasBeenDestroyed(false),
copyNumberLevel(0), layeredMassFlg(false)
: fWorldName(wName)
, fCurrentPS(nullptr)
, fConstructed(false)
, fActive(true)
, fShape(MeshShape::undefined)
, fRotationMatrix(nullptr)
, fMFD(new G4MultiFunctionalDetector(wName))
, verboseLevel(0)
, sizeIsSet(false)
, nMeshIsSet(false)
, fDrawUnit("")
, fDrawUnitValue(1.)
, fMeshElementLogical(nullptr)
, fParallelWorldProcess(nullptr)
, fGeometryHasBeenDestroyed(false)
, copyNumberLevel(0)
, layeredMassFlg(false)
{
G4SDManager::GetSDMpointer()->AddNewDetector(fMFD);
fSize[0] = fSize[1] = fSize[2] = 0.;
fAngle[0] = 0.0;
fAngle[1] = CLHEP::twopi * rad;
fNSegment[0] = fNSegment[1] = fNSegment[2] = 1;
fDivisionAxisNames[0] = fDivisionAxisNames[1] = fDivisionAxisNames[2] = "";
}
G4VScoringMesh::~G4VScoringMesh() {
;
}
G4VScoringMesh::~G4VScoringMesh() { ; }
void G4VScoringMesh::ResetScore() {
if(verboseLevel > 9) G4cout << "G4VScoringMesh::ResetScore() is called." << G4endl;
void G4VScoringMesh::ResetScore()
{
if(verboseLevel > 9)
G4cout << "G4VScoringMesh::ResetScore() is called." << G4endl;
for(auto mp : fMap)
{
if(verboseLevel > 9) G4cout << "G4VScoringMesh::ResetScore()" << mp.first << G4endl;
if(verboseLevel > 9)
G4cout << "G4VScoringMesh::ResetScore()" << mp.first << G4endl;
mp.second->clear();
}
}
void G4VScoringMesh::SetSize(G4double size[3]) {
if ( !sizeIsSet ){
for(int i = 0; i < 3; i++) fSize[i] = size[i];
void G4VScoringMesh::SetSize(G4double size[3])
{
if(!sizeIsSet)
{
sizeIsSet = true;
}else{
G4String message = " The size of scoring mesh is updated.";
G4Exception("G4VScoringMesh::SetSize()",
"DigiHitsUtilsScoreVScoringMesh000", JustWarning,
message);
}
for(int i = 0; i < 3; i++)
{
fSize[i] = size[i];
}
}
G4ThreeVector G4VScoringMesh::GetSize() const {
G4ThreeVector G4VScoringMesh::GetSize() const
{
if(sizeIsSet)
return G4ThreeVector(fSize[0], fSize[1], fSize[2]);
else
return G4ThreeVector(0., 0., 0.);
}
void G4VScoringMesh::SetCenterPosition(G4double centerPosition[3]) {
fCenterPosition = G4ThreeVector(centerPosition[0], centerPosition[1], centerPosition[2]);
void G4VScoringMesh::SetAngles(G4double startAngle, G4double spanAngle)
{
fAngle[0] = startAngle;
fAngle[1] = spanAngle;
}
void G4VScoringMesh::SetNumberOfSegments(G4int nSegment[3]) {
if ( !nMeshIsSet || fShape==MeshShape::realWorldLogVol || fShape==MeshShape::probe ){
for(int i = 0; i < 3; i++) fNSegment[i] = nSegment[i];
void G4VScoringMesh::SetCenterPosition(G4double centerPosition[3])
{
fCenterPosition =
G4ThreeVector(centerPosition[0], centerPosition[1], centerPosition[2]);
}
void G4VScoringMesh::SetNumberOfSegments(G4int nSegment[3])
{
if(!nMeshIsSet || fShape == MeshShape::realWorldLogVol ||
fShape == MeshShape::probe)
{
for(int i = 0; i < 3; i++)
fNSegment[i] = nSegment[i];
nMeshIsSet = true;
} else {
}
else
{
G4String message = " The size of scoring segments can not be changed.";
G4Exception("G4VScoringMesh::SetNumberOfSegments()",
"DigiHitsUtilsScoreVScoringMesh000", JustWarning,
message);
"DigiHitsUtilsScoreVScoringMesh000", JustWarning, message);
}
}
void G4VScoringMesh::GetNumberOfSegments(G4int nSegment[3]) {
for(int i = 0; i < 3; i++) nSegment[i] = fNSegment[i];
void G4VScoringMesh::GetNumberOfSegments(G4int nSegment[3])
{
for(int i = 0; i < 3; i++)
nSegment[i] = fNSegment[i];
}
void G4VScoringMesh::RotateX(G4double delta) {
if(!fRotationMatrix) fRotationMatrix = new G4RotationMatrix();
void G4VScoringMesh::RotateX(G4double delta)
{
if(!fRotationMatrix)
fRotationMatrix = new G4RotationMatrix();
fRotationMatrix->rotateX(delta);
}
void G4VScoringMesh::RotateY(G4double delta) {
if(!fRotationMatrix) fRotationMatrix = new G4RotationMatrix();
void G4VScoringMesh::RotateY(G4double delta)
{
if(!fRotationMatrix)
fRotationMatrix = new G4RotationMatrix();
fRotationMatrix->rotateY(delta);
}
void G4VScoringMesh::RotateZ(G4double delta) {
if(!fRotationMatrix) fRotationMatrix = new G4RotationMatrix();
void G4VScoringMesh::RotateZ(G4double delta)
{
if(!fRotationMatrix)
fRotationMatrix = new G4RotationMatrix();
fRotationMatrix->rotateZ(delta);
}
void G4VScoringMesh::SetPrimitiveScorer(G4VPrimitiveScorer * prs) {
void G4VScoringMesh::SetPrimitiveScorer(G4VPrimitiveScorer* prs)
{
if(!ReadyForQuantity())
{
G4cerr << "ERROR : G4VScoringMesh::SetPrimitiveScorer() : "
<< prs->GetName()
<< " does not yet have mesh size or number of bins. Set them first." << G4endl
<< "This Method is ignored." << G4endl;
<< prs->GetName()
<< " does not yet have mesh size or number of bins. Set them first."
<< G4endl << "This Method is ignored." << G4endl;
return;
}
if(verboseLevel > 0) G4cout << "G4VScoringMesh::SetPrimitiveScorer() : "
<< prs->GetName() << " is registered."
<< " 3D size: ("
<< fNSegment[0] << ", "
<< fNSegment[1] << ", "
<< fNSegment[2] << ")" << G4endl;
if(verboseLevel > 0)
G4cout << "G4VScoringMesh::SetPrimitiveScorer() : " << prs->GetName()
<< " is registered."
<< " 3D size: (" << fNSegment[0] << ", " << fNSegment[1] << ", "
<< fNSegment[2] << ")" << G4endl;
prs->SetNijk(fNSegment[0], fNSegment[1], fNSegment[2]);
fCurrentPS = prs;
fMFD->RegisterPrimitive(prs);
G4THitsMap<G4StatDouble> * map = new G4THitsMap<G4StatDouble>(fWorldName, prs->GetName());
G4THitsMap<G4StatDouble>* map =
new G4THitsMap<G4StatDouble>(fWorldName, prs->GetName());
fMap[prs->GetName()] = map;
}
void G4VScoringMesh::SetFilter(G4VSDFilter * filter) {
if(!fCurrentPS) {
G4cerr << "ERROR : G4VScoringMesh::SetSDFilter() : a quantity must be defined first. This method is ignored." << G4endl;
void G4VScoringMesh::SetFilter(G4VSDFilter* filter)
{
if(!fCurrentPS)
{
G4cerr << "ERROR : G4VScoringMesh::SetSDFilter() : a quantity must be "
"defined first. This method is ignored."
<< G4endl;
return;
}
if(verboseLevel > 0) G4cout << "G4VScoringMesh::SetFilter() : "
<< filter->GetName()
<< " is set to "
<< fCurrentPS->GetName() << G4endl;
if(verboseLevel > 0)
G4cout << "G4VScoringMesh::SetFilter() : " << filter->GetName()
<< " is set to " << fCurrentPS->GetName() << G4endl;
G4VSDFilter* oldFilter = fCurrentPS->GetFilter();
if(oldFilter)
{
G4cout << "WARNING : G4VScoringMesh::SetFilter() : " << oldFilter->GetName()
G4cout << "WARNING : G4VScoringMesh::SetFilter() : " << oldFilter->GetName()
<< " is overwritten by " << filter->GetName() << G4endl;
}
fCurrentPS->SetFilter(filter);
}
void G4VScoringMesh::SetCurrentPrimitiveScorer(const G4String & name) {
void G4VScoringMesh::SetCurrentPrimitiveScorer(const G4String& name)
{
fCurrentPS = GetPrimitiveScorer(name);
if(!fCurrentPS) {
G4cerr << "ERROR : G4VScoringMesh::SetCurrentPrimitiveScorer() : The primitive scorer <"
<< name << "> does not found." << G4endl;
if(!fCurrentPS)
{
G4cerr << "ERROR : G4VScoringMesh::SetCurrentPrimitiveScorer() : The "
"primitive scorer <"
<< name << "> does not found." << G4endl;
}
}
G4bool G4VScoringMesh::FindPrimitiveScorer(const G4String & psname) {
G4bool G4VScoringMesh::FindPrimitiveScorer(const G4String& psname)
{
MeshScoreMap::iterator itr = fMap.find(psname);
if(itr == fMap.end()) return false;
if(itr == fMap.end())
return false;
return true;
}
G4String G4VScoringMesh::GetPSUnit(const G4String & psname) {
G4String G4VScoringMesh::GetPSUnit(const G4String& psname)
{
MeshScoreMap::iterator itr = fMap.find(psname);
if(itr == fMap.end()) {
if(itr == fMap.end())
{
return G4String("");
} else {
}
else
{
return GetPrimitiveScorer(psname)->GetUnit();
}
}
G4String G4VScoringMesh::GetCurrentPSUnit(){
G4String G4VScoringMesh::GetCurrentPSUnit()
{
G4String unit = "";
if(!fCurrentPS) {
G4String msg = "ERROR : G4VScoringMesh::GetCurrentPSUnit() : ";
msg += " Current primitive scorer is null.";
G4cerr << msg << G4endl;
}else{
unit = fCurrentPS->GetUnit();
if(!fCurrentPS)
{
G4String msg = "ERROR : G4VScoringMesh::GetCurrentPSUnit() : ";
msg += " Current primitive scorer is null.";
G4cerr << msg << G4endl;
}
else
{
unit = fCurrentPS->GetUnit();
}
return unit;
}
void G4VScoringMesh::SetCurrentPSUnit(const G4String& unit){
if(!fCurrentPS) {
G4String msg = "ERROR : G4VScoringMesh::GetCurrentPSUnit() : ";
msg += " Current primitive scorer is null.";
G4cerr << msg << G4endl;
}else{
fCurrentPS->SetUnit(unit);
void G4VScoringMesh::SetCurrentPSUnit(const G4String& unit)
{
if(!fCurrentPS)
{
G4String msg = "ERROR : G4VScoringMesh::GetCurrentPSUnit() : ";
msg += " Current primitive scorer is null.";
G4cerr << msg << G4endl;
}
else
{
fCurrentPS->SetUnit(unit);
}
}
G4double G4VScoringMesh::GetPSUnitValue(const G4String & psname) {
G4double G4VScoringMesh::GetPSUnitValue(const G4String& psname)
{
MeshScoreMap::iterator itr = fMap.find(psname);
if(itr == fMap.end()) {
if(itr == fMap.end())
{
return 1.;
} else {
}
else
{
return GetPrimitiveScorer(psname)->GetUnitValue();
}
}
void G4VScoringMesh::GetDivisionAxisNames(G4String divisionAxisNames[3]) {
for(int i = 0; i < 3; i++) divisionAxisNames[i] = fDivisionAxisNames[i];
void G4VScoringMesh::GetDivisionAxisNames(G4String divisionAxisNames[3])
{
for(int i = 0; i < 3; i++)
divisionAxisNames[i] = fDivisionAxisNames[i];
}
G4VPrimitiveScorer * G4VScoringMesh::GetPrimitiveScorer(const G4String & name) {
if(!fMFD) return nullptr;
G4VPrimitiveScorer* G4VScoringMesh::GetPrimitiveScorer(const G4String& name)
{
if(!fMFD)
return nullptr;
G4int nps = fMFD->GetNumberOfPrimitives();
for(G4int i = 0; i < nps; i++) {
G4VPrimitiveScorer * prs = fMFD->GetPrimitive(i);
if(name == prs->GetName()) return prs;
for(G4int i = 0; i < nps; i++)
{
G4VPrimitiveScorer* prs = fMFD->GetPrimitive(i);
if(name == prs->GetName())
return prs;
}
return nullptr;
}
void G4VScoringMesh::List() const {
G4cout << " # of segments: ("
<< fNSegment[0] << ", "
<< fNSegment[1] << ", "
<< fNSegment[2] << ")"
<< G4endl;
G4cout << " displacement: ("
<< fCenterPosition.x()/cm << ", "
<< fCenterPosition.y()/cm << ", "
<< fCenterPosition.z()/cm << ") [cm]"
<< G4endl;
if(fRotationMatrix != 0) {
G4cout << " rotation matrix: "
<< fRotationMatrix->xx() << " "
<< fRotationMatrix->xy() << " "
<< fRotationMatrix->xz() << G4endl
<< " "
<< fRotationMatrix->yx() << " "
<< fRotationMatrix->yy() << " "
<< fRotationMatrix->yz() << G4endl
<< " "
<< fRotationMatrix->zx() << " "
<< fRotationMatrix->zy() << " "
<< fRotationMatrix->zz() << G4endl;
void G4VScoringMesh::List() const
{
G4cout << " # of segments: (" << fNSegment[0] << ", " << fNSegment[1] << ", "
<< fNSegment[2] << ")" << G4endl;
G4cout << " displacement: (" << fCenterPosition.x() / cm << ", "
<< fCenterPosition.y() / cm << ", " << fCenterPosition.z() / cm
<< ") [cm]" << G4endl;
if(fRotationMatrix != 0)
{
G4cout << " rotation matrix: " << fRotationMatrix->xx() << " "
<< fRotationMatrix->xy() << " " << fRotationMatrix->xz() << G4endl
<< " " << fRotationMatrix->yx() << " "
<< fRotationMatrix->yy() << " " << fRotationMatrix->yz() << G4endl
<< " " << fRotationMatrix->zx() << " "
<< fRotationMatrix->zy() << " " << fRotationMatrix->zz() << G4endl;
}
G4cout << " registered primitve scorers : " << G4endl;
G4int nps = fMFD->GetNumberOfPrimitives();
G4VPrimitiveScorer * prs;
for(int i = 0; i < nps; i++) {
G4VPrimitiveScorer* prs;
for(int i = 0; i < nps; i++)
{
prs = fMFD->GetPrimitive(i);
G4cout << " " << i << " " << prs->GetName();
if(prs->GetFilter() != 0) G4cout << " with " << prs->GetFilter()->GetName();
if(prs->GetFilter() != 0)
G4cout << " with " << prs->GetFilter()->GetName();
G4cout << G4endl;
}
}
void G4VScoringMesh::Dump() {
void G4VScoringMesh::Dump()
{
G4cout << "scoring mesh name: " << fWorldName << G4endl;
G4cout << "# of G4THitsMap : " << fMap.size() << G4endl;
for(auto mp : fMap)
@@ -281,49 +337,61 @@ void G4VScoringMesh::Dump() {
mp.second->PrintAllHits();
}
G4cout << G4endl;
}
void G4VScoringMesh::DrawMesh(const G4String& psName,G4VScoreColorMap* colorMap,G4int axflg)
void G4VScoringMesh::DrawMesh(const G4String& psName,
G4VScoreColorMap* colorMap, G4int axflg)
{
fDrawPSName = psName;
fDrawPSName = psName;
MeshScoreMap::const_iterator fMapItr = fMap.find(psName);
if(fMapItr!=fMap.end()) {
fDrawUnit = GetPSUnit(psName);
if(fMapItr != fMap.end())
{
fDrawUnit = GetPSUnit(psName);
fDrawUnitValue = GetPSUnitValue(psName);
Draw(fMapItr->second, colorMap,axflg);
} else {
G4cerr << "Scorer <" << psName << "> is not defined. Method ignored." << G4endl;
Draw(fMapItr->second, colorMap, axflg);
}
else
{
G4cerr << "Scorer <" << psName << "> is not defined. Method ignored."
<< G4endl;
}
}
void G4VScoringMesh::DrawMesh(const G4String& psName,G4int idxPlane,G4int iColumn,G4VScoreColorMap* colorMap)
void G4VScoringMesh::DrawMesh(const G4String& psName, G4int idxPlane,
G4int iColumn, G4VScoreColorMap* colorMap)
{
fDrawPSName = psName;
fDrawPSName = psName;
MeshScoreMap::const_iterator fMapItr = fMap.find(psName);
if(fMapItr!=fMap.end()) {
fDrawUnit = GetPSUnit(psName);
if(fMapItr != fMap.end())
{
fDrawUnit = GetPSUnit(psName);
fDrawUnitValue = GetPSUnitValue(psName);
DrawColumn(fMapItr->second,colorMap,idxPlane,iColumn);
} else {
G4cerr << "Scorer <" << psName << "> is not defined. Method ignored." << G4endl;
DrawColumn(fMapItr->second, colorMap, idxPlane, iColumn);
}
else
{
G4cerr << "Scorer <" << psName << "> is not defined. Method ignored."
<< G4endl;
}
}
void G4VScoringMesh::Accumulate(G4THitsMap<G4double> * map)
void G4VScoringMesh::Accumulate(G4THitsMap<G4double>* map)
{
G4String psName = map->GetName();
G4String psName = map->GetName();
MeshScoreMap::const_iterator fMapItr = fMap.find(psName);
*(fMapItr->second) += *map;
if(verboseLevel > 9) {
if(verboseLevel > 9)
{
G4cout << G4endl;
G4cout << "G4VScoringMesh::Accumulate()" << G4endl;
G4cout << " PS name : " << psName << G4endl;
if(fMapItr == fMap.end()) {
if(fMapItr == fMap.end())
{
G4cout << " " << psName << " was not found." << G4endl;
} else {
}
else
{
G4cout << " map size : " << map->GetSize() << G4endl;
map->PrintAllHits();
}
@@ -331,19 +399,23 @@ void G4VScoringMesh::Accumulate(G4THitsMap<G4double> * map)
}
}
void G4VScoringMesh::Accumulate(G4THitsMap<G4StatDouble> * map)
void G4VScoringMesh::Accumulate(G4THitsMap<G4StatDouble>* map)
{
G4String psName = map->GetName();
G4String psName = map->GetName();
MeshScoreMap::const_iterator fMapItr = fMap.find(psName);
*(fMapItr->second) += *map;
if(verboseLevel > 9) {
if(verboseLevel > 9)
{
G4cout << G4endl;
G4cout << "G4VScoringMesh::Accumulate()" << G4endl;
G4cout << " PS name : " << psName << G4endl;
if(fMapItr == fMap.end()) {
if(fMapItr == fMap.end())
{
G4cout << " " << psName << " was not found." << G4endl;
} else {
}
else
{
G4cout << " map size : " << map->GetSize() << G4endl;
map->PrintAllHits();
}
@@ -353,17 +425,19 @@ void G4VScoringMesh::Accumulate(G4THitsMap<G4StatDouble> * map)
void G4VScoringMesh::Construct(G4VPhysicalVolume* fWorldPhys)
{
if(fConstructed) {
if(fGeometryHasBeenDestroyed) {
if(fConstructed)
{
if(fGeometryHasBeenDestroyed)
{
SetupGeometry(fWorldPhys);
fGeometryHasBeenDestroyed = false;
}
if(verboseLevel > 0)
G4cout << fWorldName << " --- All quantities are reset."
<< G4endl;
G4cout << fWorldName << " --- All quantities are reset." << G4endl;
ResetScore();
}
else {
else
{
fConstructed = true;
SetupGeometry(fWorldPhys);
}
@@ -371,32 +445,37 @@ void G4VScoringMesh::Construct(G4VPhysicalVolume* fWorldPhys)
void G4VScoringMesh::WorkerConstruct(G4VPhysicalVolume* fWorldPhys)
{
if(fConstructed) {
if(fGeometryHasBeenDestroyed) {
if(fConstructed)
{
if(fGeometryHasBeenDestroyed)
{
fMeshElementLogical->SetSensitiveDetector(fMFD);
fGeometryHasBeenDestroyed = false;
}
if(verboseLevel > 0)
G4cout << fWorldPhys->GetName() << " --- All quantities are reset." << G4endl;
G4cout << fWorldPhys->GetName() << " --- All quantities are reset."
<< G4endl;
ResetScore();
} else {
}
else
{
fConstructed = true;
fMeshElementLogical->SetSensitiveDetector(fMFD);
}
}
void G4VScoringMesh::Merge(const G4VScoringMesh * scMesh)
void G4VScoringMesh::Merge(const G4VScoringMesh* scMesh)
{
const MeshScoreMap scMap = scMesh->GetScoreMap();
MeshScoreMap::const_iterator fMapItr = fMap.begin();
MeshScoreMap::const_iterator mapItr = scMap.begin();
for(; fMapItr != fMap.end(); fMapItr++) {
if(verboseLevel > 9) G4cout << "G4VScoringMesh::Merge()" << fMapItr->first << G4endl;
MeshScoreMap::const_iterator mapItr = scMap.begin();
for(; fMapItr != fMap.end(); fMapItr++)
{
if(verboseLevel > 9)
G4cout << "G4VScoringMesh::Merge()" << fMapItr->first << G4endl;
*(fMapItr->second) += *(mapItr->second);
mapItr++;
}
}