Import Geant4 10.5.0 source tree
This commit is contained in:
@@ -23,14 +23,14 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: Dicom2ActionInitialization.cc $
|
||||
//
|
||||
/// \file Dicom2ActionInitialization.cc
|
||||
/// \brief Implementation of the Dicom2ActionInitialization class
|
||||
|
||||
#include "Dicom2ActionInitialization.hh"
|
||||
#include "Dicom2PrimaryGeneratorAction.hh"
|
||||
#include "DicomRunAction.hh"
|
||||
#include "DicomPrimaryGeneratorAction.hh"
|
||||
#include "Dicom2RunAction.hh"
|
||||
#include "DicomEventAction.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -48,21 +48,19 @@ Dicom2ActionInitialization::~Dicom2ActionInitialization()
|
||||
|
||||
void Dicom2ActionInitialization::BuildForMaster() const
|
||||
{
|
||||
DicomRunAction* runAction = new DicomRunAction;
|
||||
SetUserAction(runAction);
|
||||
// DICOM2 overload
|
||||
SetUserAction(new Dicom2RunAction);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Dicom2ActionInitialization::Build() const
|
||||
{
|
||||
// DICOM2 overload
|
||||
SetUserAction(new Dicom2RunAction);
|
||||
SetUserAction(new Dicom2PrimaryGeneratorAction);
|
||||
|
||||
DicomRunAction* runAction = new DicomRunAction;
|
||||
SetUserAction(runAction);
|
||||
|
||||
DicomEventAction* eventAction = new DicomEventAction();
|
||||
SetUserAction(eventAction);
|
||||
// from original DICOM
|
||||
SetUserAction(new DicomEventAction);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -23,15 +23,17 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: Dicom2PrimaryGeneratorAction.cc 94307 2015-11-11 13:42:46Z gcosmo $
|
||||
//
|
||||
/// \file Dicom2PrimaryGeneratorAction.cc
|
||||
/// \brief Implementation of the Dicom2PrimaryGeneratorAction class
|
||||
|
||||
#include "Dicom2PrimaryGeneratorAction.hh"
|
||||
#include "DicomDetectorConstruction.hh"
|
||||
|
||||
#include "G4LogicalVolumeStore.hh"
|
||||
#include "G4PhysicalVolumeStore.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4Box.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4ParticleGun.hh"
|
||||
@@ -39,25 +41,28 @@
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "Randomize.hh"
|
||||
#include "G4RandomDirection.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
Dicom2PrimaryGeneratorAction::Dicom2PrimaryGeneratorAction()
|
||||
: G4VUserPrimaryGeneratorAction(),
|
||||
fParticleGun(0),
|
||||
fEnvelopeBox(0)
|
||||
fParticleGun(new G4ParticleGun(1)),
|
||||
fEnvelopeBox(nullptr),
|
||||
fEnvelopeVol(nullptr),
|
||||
fPosCenter(G4ThreeVector(0.0)),
|
||||
fPosDelta(G4ThreeVector(0.0)),
|
||||
fGeomFactor(0.8)
|
||||
{
|
||||
G4int n_particle = 1;
|
||||
fParticleGun = new G4ParticleGun(n_particle);
|
||||
|
||||
// default particle kinematic
|
||||
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
|
||||
G4String particleName;
|
||||
G4ParticleDefinition* particle
|
||||
= particleTable->FindParticle(particleName="gamma");
|
||||
= particleTable->FindParticle(particleName="e-");
|
||||
fParticleGun->SetParticleDefinition(particle);
|
||||
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,1.));
|
||||
fParticleGun->SetParticleEnergy(6.*MeV);
|
||||
fParticleGun->SetParticleEnergy(10.*MeV);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -77,37 +82,66 @@ void Dicom2PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
|
||||
// In order to avoid dependence of PrimaryGeneratorAction
|
||||
// on DetectorConstruction class we get phantomContainer volume
|
||||
// from G4LogicalVolumeStore.
|
||||
|
||||
G4double envSizeXY = 0;
|
||||
G4double envSizeZ = 0;
|
||||
|
||||
if (!fEnvelopeBox)
|
||||
{
|
||||
G4LogicalVolume* envLV
|
||||
= G4LogicalVolumeStore::GetInstance()->GetVolume("phantomContainer");
|
||||
if ( envLV ) fEnvelopeBox = dynamic_cast<G4Box*>(envLV->GetSolid());
|
||||
if(envLV)
|
||||
fEnvelopeBox = dynamic_cast<G4Box*>(envLV->GetSolid());
|
||||
}
|
||||
|
||||
if ( fEnvelopeBox ) {
|
||||
envSizeXY = fEnvelopeBox->GetXHalfLength()*2.;
|
||||
envSizeZ = fEnvelopeBox->GetZHalfLength()*2.;
|
||||
if(!fEnvelopeVol)
|
||||
{
|
||||
fEnvelopeVol = G4PhysicalVolumeStore::GetInstance()->GetVolume("phantomContainer");
|
||||
}
|
||||
else {
|
||||
|
||||
// get the center of the phantom
|
||||
if(fEnvelopeVol)
|
||||
{
|
||||
fPosCenter = fEnvelopeVol->GetObjectTranslation();
|
||||
}
|
||||
else
|
||||
{
|
||||
G4ExceptionDescription msg;
|
||||
msg << "Envelope volume of box shape not found.\n";
|
||||
msg << "Perhaps you have changed geometry.\n";
|
||||
msg << "Envelope physical volume not found.\n";
|
||||
msg << "The gun will be place at the center.";
|
||||
G4Exception("Dicom2PrimaryGeneratorAction::GeneratePrimaries()",
|
||||
"MyCode0002",JustWarning,msg);
|
||||
"DICOM20002",JustWarning, msg);
|
||||
}
|
||||
|
||||
G4double size = 0.8;
|
||||
G4double x0 = size * envSizeXY * (G4UniformRand()-0.5);
|
||||
G4double y0 = size * envSizeXY * (G4UniformRand()-0.5);
|
||||
G4double z0 = -0.5 * envSizeZ;
|
||||
// get the size of the phantom
|
||||
if(fEnvelopeBox)
|
||||
{
|
||||
fPosDelta = G4ThreeVector(2.0 * fEnvelopeBox->GetXHalfLength(),
|
||||
2.0 * fEnvelopeBox->GetYHalfLength(),
|
||||
2.0 * fEnvelopeBox->GetZHalfLength());
|
||||
}
|
||||
else
|
||||
{
|
||||
G4ExceptionDescription msg;
|
||||
msg << "Envelope volume of box shape not found.\n";
|
||||
msg << "The gun will be place at the center.";
|
||||
G4Exception("Dicom2PrimaryGeneratorAction::GeneratePrimaries()",
|
||||
"DICOM20003",JustWarning, msg);
|
||||
}
|
||||
|
||||
fParticleGun->SetParticlePosition(G4ThreeVector(x0,y0,z0));
|
||||
// start at center
|
||||
G4ThreeVector pos = fPosCenter;
|
||||
// get a random displacement
|
||||
G4ThreeVector delta(fPosDelta.x() * (G4UniformRand()-0.5),
|
||||
fPosDelta.y() * (G4UniformRand()-0.5),
|
||||
fPosDelta.z() * (G4UniformRand()-0.5));
|
||||
// scale by geom factor
|
||||
delta *= fGeomFactor;
|
||||
|
||||
//G4cout << "Starting position: " << G4BestUnit(pos + delta, "Length")
|
||||
// << ", pos = " << G4BestUnit(fPosCenter, "Length")
|
||||
// << ", size = " << G4BestUnit(fPosDelta, "Length")
|
||||
// << ", delta = " << G4BestUnit(delta, "Length")
|
||||
// << G4endl;
|
||||
|
||||
fParticleGun->SetParticlePosition(pos + delta);
|
||||
fParticleGun->SetParticleMomentumDirection(G4RandomDirection());
|
||||
fParticleGun->GeneratePrimaryVertex(anEvent);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,258 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
/// \file medical/DICOM/src/Dicom2Run.cc
|
||||
/// \brief Implementation of the Dicom2Run class
|
||||
|
||||
//=====================================================================
|
||||
///
|
||||
/// (Description)
|
||||
/// Dicom2Run Class is for accumulating scored quantities which is
|
||||
/// scored using G4MutiFunctionalDetector and G4VPrimitiveScorer.
|
||||
/// Accumulation is done using G4THitsVector object.
|
||||
///
|
||||
/// The constructor Dicom2Run(const std::vector<G4String> mfdName)
|
||||
/// needs a vector filled with MultiFunctionalDetector names which
|
||||
/// was assigned at instantiation of MultiFunctionalDetector(MFD).
|
||||
/// Then Dicom2Run constructor automatically scans primitive scorers
|
||||
/// in the MFD, and obtains collectionIDs of all collections associated
|
||||
/// to those primitive scorers. Futhermore, the G4THitsVector objects
|
||||
/// for accumulating during a RUN are automatically created too.
|
||||
/// (*) Collection Name is same as primitive scorer name.
|
||||
///
|
||||
/// The resultant information is kept inside Dicom2Run objects as
|
||||
/// data members.
|
||||
/// std::vector<G4String> fCollName; // Collection Name,
|
||||
/// std::vector<G4int> fCollID; // Collection ID,
|
||||
/// std::vector<Dicom2RunVector*> fRunMap; // HitsVector for RUN.
|
||||
///
|
||||
/// The resualtant HitsVector objects are obtain using access method,
|
||||
/// GetHitsVector(..).
|
||||
///
|
||||
//=====================================================================
|
||||
|
||||
#include "Dicom2Run.hh"
|
||||
#include "DicomDetectorConstruction.hh"
|
||||
|
||||
#include "G4SDManager.hh"
|
||||
#include "G4MultiFunctionalDetector.hh"
|
||||
#include "G4VPrimitiveScorer.hh"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//
|
||||
// Constructor.
|
||||
Dicom2Run::Dicom2Run()
|
||||
: DicomRun()
|
||||
{ }
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//
|
||||
// Constructor.
|
||||
// (The vector of MultiFunctionalDetector name has to given.)
|
||||
Dicom2Run::Dicom2Run(const std::vector<G4String> mfdName)
|
||||
: DicomRun()
|
||||
{
|
||||
ConstructMFD(mfdName);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//
|
||||
// Destructor
|
||||
// clear all data members.
|
||||
Dicom2Run::~Dicom2Run()
|
||||
{
|
||||
//--- Clear HitsVector for RUN
|
||||
for(uintmax_t i = 0; i < fRunMap.size(); i++)
|
||||
{
|
||||
if(fRunMap[i])
|
||||
fRunMap[i]->clear();
|
||||
}
|
||||
fCollName.clear();
|
||||
fCollID.clear();
|
||||
fRunMap.clear();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//
|
||||
// Destructor
|
||||
// clear all data members.
|
||||
void Dicom2Run::ConstructMFD(const std::vector<G4String>& mfdName)
|
||||
{
|
||||
DicomRun::ConstructMFD(mfdName);
|
||||
|
||||
G4SDManager* SDman = G4SDManager::GetSDMpointer();
|
||||
//=================================================
|
||||
// Initalize RunMaps for accumulation.
|
||||
// Get CollectionIDs for HitCollections.
|
||||
//=================================================
|
||||
for(uintmax_t idet = 0; idet < mfdName.size(); idet++)
|
||||
{
|
||||
// Loop for all MFD.
|
||||
G4String detName = mfdName[idet];
|
||||
//--- Seek and Obtain MFD objects from SDmanager.
|
||||
G4MultiFunctionalDetector* mfd =
|
||||
(G4MultiFunctionalDetector*)
|
||||
(SDman->FindSensitiveDetector(detName));
|
||||
//
|
||||
if(mfd)
|
||||
{
|
||||
//--- Loop over the registered primitive scorers.
|
||||
for (G4int icol = 0; icol < mfd->GetNumberOfPrimitives(); icol++)
|
||||
{
|
||||
// Get Primitive Scorer object.
|
||||
G4VPrimitiveScorer* scorer = mfd->GetPrimitive(icol);
|
||||
// collection name and collectionID for HitsCollection,
|
||||
// where type of HitsCollection is G4THitsVector in case
|
||||
// of primitive scorer.
|
||||
// The collection name is given by :
|
||||
// <MFD name>/<Primitive Scorer name>.
|
||||
G4String collectionName = scorer->GetName();
|
||||
G4String fullCollectionName = detName+"/"+collectionName;
|
||||
G4int collectionID = SDman->GetCollectionID(fullCollectionName);
|
||||
//
|
||||
if(collectionID >= 0)
|
||||
{
|
||||
G4cout << "++ "<<fullCollectionName<< " id " << collectionID
|
||||
<< G4endl;
|
||||
// Store obtained HitsCollection information into data
|
||||
// members. qnd creates new G4THitsVector for accumulating
|
||||
// quantities during RUN.
|
||||
fCollName.push_back(fullCollectionName);
|
||||
fCollID.push_back(collectionID);
|
||||
fRunMap.push_back(new Dicom2RunVector(detName,
|
||||
collectionName));
|
||||
}
|
||||
else
|
||||
{
|
||||
G4cout << "** collection " << fullCollectionName << " not found. "
|
||||
<<G4endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//
|
||||
// RecordEvent is called at end of event.
|
||||
// For scoring purpose, the resultant quantity in a event,
|
||||
// is accumulated during a Run.
|
||||
void Dicom2Run::RecordEvent(const G4Event* aEvent)
|
||||
{
|
||||
DicomRun::RecordEvent(aEvent);
|
||||
|
||||
//G4cout << "Dicom Run :: Recording event " << aEvent->GetEventID()
|
||||
//<< "..." << G4endl;
|
||||
//=============================
|
||||
// HitsCollection of This Event
|
||||
//============================
|
||||
G4HCofThisEvent* HCE = aEvent->GetHCofThisEvent();
|
||||
if (!HCE)
|
||||
return;
|
||||
|
||||
//=======================================================
|
||||
// Sum up HitsVector of this Event into HitsVector of this RUN
|
||||
//=======================================================
|
||||
for(uintmax_t i = 0; i < fCollID.size(); i++)
|
||||
{
|
||||
// Loop over HitsCollection
|
||||
G4THitsMap<G4double>* EvtMap = nullptr;
|
||||
if(fCollID[i] >= 0)
|
||||
{
|
||||
// Collection is attached to HCE
|
||||
EvtMap = static_cast<G4THitsMap<G4double>*>(HCE->GetHC(fCollID[i]));
|
||||
}
|
||||
else
|
||||
{
|
||||
G4cout <<" Error EvtMap Not Found "<< i << G4endl;
|
||||
}
|
||||
|
||||
// if valid pointer, add the pointer
|
||||
if(EvtMap)
|
||||
{
|
||||
//for(auto itr = EvtMap->begin(); itr != EvtMap->end(); ++itr)
|
||||
// G4cout << "adding " << *EvtMap->GetObject(itr) << G4endl;
|
||||
//=== Sum up HitsVector of this event to HitsVector of RUN.===
|
||||
*fRunMap[i] += *EvtMap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
// Merge hits map from threads
|
||||
void Dicom2Run::Merge(const G4Run* aRun)
|
||||
{
|
||||
DicomRun::Merge(aRun);
|
||||
|
||||
const Dicom2Run* localRun = static_cast<const Dicom2Run*>(aRun);
|
||||
|
||||
Copy(fCollName, localRun->fCollName);
|
||||
Copy(fCollID, localRun->fCollID);
|
||||
unsigned ncopies = Copy(fRunMap, localRun->fRunMap);
|
||||
// copy function returns the fRunMap size if all data is copied
|
||||
// so this loop isn't executed the first time around
|
||||
for(uintmax_t i = ncopies; i < fRunMap.size(); ++i)
|
||||
*fRunMap[i] += *localRun->fRunMap[i];
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//=================================================================
|
||||
// Access method for HitsVector of the RUN
|
||||
//
|
||||
//-----
|
||||
// Access HitsVector.
|
||||
// By MultiFunctionalDetector name and Collection Name.
|
||||
Dicom2Run::Dicom2RunVector*
|
||||
Dicom2Run::GetHitsVector(const G4String& detName,
|
||||
const G4String& colName) const
|
||||
{
|
||||
G4String fullName = detName+"/"+colName;
|
||||
return GetHitsVector(fullName);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
// Access HitsVector.
|
||||
// By full description of collection name, that is
|
||||
// <MultiFunctional Detector Name>/<Primitive Scorer Name>
|
||||
Dicom2Run::Dicom2RunVector*
|
||||
Dicom2Run::GetHitsVector(const G4String& fullName) const
|
||||
{
|
||||
|
||||
G4int Ncol = fCollName.size();
|
||||
for(G4int i = 0; i < Ncol; i++)
|
||||
{
|
||||
if(fCollName[i] == fullName)
|
||||
{
|
||||
return fRunMap[i];
|
||||
}
|
||||
}
|
||||
|
||||
G4Exception("Dicom2Run", fullName.c_str(), JustWarning,
|
||||
"GetHitsVector failed to locate the requested HitsVector");
|
||||
return nullptr;
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
/// \file Dicom2RunAction.cc
|
||||
/// \brief Implementation of the Dicom2RunAction class
|
||||
//
|
||||
|
||||
#include "Dicom2RunAction.hh"
|
||||
#include "Dicom2Run.hh"
|
||||
|
||||
//-- In order to obtain detector information.
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include "G4THitsMap.hh"
|
||||
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4StatAnalysis.hh"
|
||||
|
||||
#include "G4RunManager.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
/// Constructor
|
||||
Dicom2RunAction::Dicom2RunAction()
|
||||
: DicomRunAction()
|
||||
{ }
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
/// Destructor.
|
||||
Dicom2RunAction::~Dicom2RunAction()
|
||||
{ }
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
G4Run* Dicom2RunAction::GenerateRun()
|
||||
{
|
||||
// Generate new RUN object, which is specially
|
||||
// dedicated for MultiFunctionalDetector scheme.
|
||||
// Detail description can be found in Dicom2Run.hh/cc.
|
||||
return fDcmrun = new Dicom2Run(fSDName);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void Dicom2RunAction::EndOfRunAction(const G4Run* aRun)
|
||||
{
|
||||
// Lock the output because of the external calls to DicomRunAction
|
||||
// otherwise, the output gets too confusing
|
||||
G4AutoLock l(G4TypeMutex<Dicom2RunAction>());
|
||||
|
||||
G4cout << G4endl;
|
||||
G4cout << "[==========================================================="
|
||||
<< " DICOM "
|
||||
<< "===========================================================]"
|
||||
<< G4endl;
|
||||
G4cout << G4endl;
|
||||
|
||||
DicomRunAction::EndOfRunAction(aRun);
|
||||
|
||||
G4cout << G4endl;
|
||||
G4cout << "[==========================================================="
|
||||
<< " DICOM2 "
|
||||
<< "==========================================================]"
|
||||
<< G4endl;
|
||||
G4cout << G4endl;
|
||||
|
||||
G4int nofEvents = aRun->GetNumberOfEvent();
|
||||
|
||||
G4StatAnalysis local_total_dose;
|
||||
|
||||
const Dicom2Run* dcm2Run = static_cast<const Dicom2Run*>(aRun);
|
||||
//--- Dump all scored quantities involved in Dicom2Run.
|
||||
for(uintmax_t i = 0; i < fSDName.size(); i++)
|
||||
{
|
||||
//
|
||||
//---------------------------------------------
|
||||
// Dump accumulated quantities for this RUN.
|
||||
// (Display only central region of x-y plane)
|
||||
// 0 ConcreteSD/DoseDeposit
|
||||
//---------------------------------------------
|
||||
Dicom2RunVector* DoseDeposit =
|
||||
dcm2Run->GetHitsVector(fSDName[i]+"/DoseDeposit");
|
||||
|
||||
if(DoseDeposit && DoseDeposit->size() != 0 )
|
||||
{
|
||||
for(auto itr = DoseDeposit->begin(); itr != DoseDeposit->end(); ++itr)
|
||||
{
|
||||
// this will sometimes return null pointers
|
||||
if(!DoseDeposit->GetObject(itr))
|
||||
continue;
|
||||
local_total_dose += (*DoseDeposit->GetObject(itr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(IsMaster())
|
||||
{
|
||||
G4cout << " ###### EndOfRunAction ###### " << G4endl;
|
||||
//- Dicom2Run object.
|
||||
const Dicom2Run* re02Run = static_cast<const Dicom2Run*>(aRun);
|
||||
//--- Dump all scored quantities involved in Dicom2Run.
|
||||
|
||||
for(uintmax_t i = 0; i < fSDName.size(); i++)
|
||||
{
|
||||
//
|
||||
//---------------------------------------------
|
||||
// Dump accumulated quantities for this RUN.
|
||||
// (Display only central region of x-y plane)
|
||||
// 0 ConcreteSD/DoseDeposit
|
||||
//---------------------------------------------
|
||||
Dicom2RunVector* DoseDeposit =
|
||||
re02Run->GetHitsVector(fSDName[i]+"/DoseDeposit");
|
||||
|
||||
G4cout << "============================================================="
|
||||
<<G4endl;
|
||||
G4cout << " Number of event processed : "
|
||||
<< aRun->GetNumberOfEvent() << G4endl;
|
||||
G4cout << "============================================================="
|
||||
<<G4endl;
|
||||
|
||||
std::ofstream fileout;
|
||||
G4String fname = "dicom2-vector.out";
|
||||
fileout.open(fname);
|
||||
G4cout << " opened file " << fname << " for dose output" << G4endl;
|
||||
|
||||
if(DoseDeposit && DoseDeposit->size() != 0)
|
||||
{
|
||||
std::ostream *myout = &G4cout;
|
||||
PrintHeader(myout);
|
||||
for(auto itr = DoseDeposit->begin(); itr != DoseDeposit->end();
|
||||
++itr)
|
||||
{
|
||||
auto _idx = DoseDeposit->GetIndex(itr);
|
||||
G4StatAnalysis* _stat = DoseDeposit->GetObject(itr);
|
||||
if(_stat && _stat->GetHits() > 0)
|
||||
{
|
||||
G4StatAnalysis _tmp_stat = *_stat;
|
||||
_tmp_stat /= CLHEP::gray;
|
||||
fileout << _idx << " " << (*_stat) << G4endl;
|
||||
}
|
||||
}
|
||||
G4cout << "============================================="<<G4endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
G4Exception("Dicom2RunAction", "000", JustWarning,
|
||||
"DoseDeposit HitsMap is either a null pointer "
|
||||
"of the HitsMap was empty");
|
||||
}
|
||||
fileout.close();
|
||||
G4cout << " closed file " << fname << " for dose output" << G4endl;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (IsMaster())
|
||||
{
|
||||
// convert to units of Gy
|
||||
local_total_dose /= gray;
|
||||
G4cout << "--------------------End of Global Run-----------------------"
|
||||
<< G4endl;
|
||||
G4cout << " The run was " << nofEvents << " events " << G4endl;
|
||||
G4cout << " TOTAL DOSE : \t" << local_total_dose << " Gy" << G4endl;
|
||||
if(nofEvents > 0)
|
||||
{
|
||||
local_total_dose /= nofEvents;
|
||||
G4cout << " TOTAL DOSE/Bq-s : \t" << local_total_dose << " Gy/Bq-s"
|
||||
<< G4endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// convert to units of Gy
|
||||
local_total_dose /= gray;
|
||||
G4cout << "--------------------End of Local Run------------------------"
|
||||
<< G4endl;
|
||||
G4cout << " The run was " << nofEvents << " events" << G4endl;
|
||||
G4cout << "LOCAL TOTAL DOSE : \t" << local_total_dose << " Gy" << G4endl;
|
||||
if(nofEvents > 0)
|
||||
{
|
||||
local_total_dose /= nofEvents;
|
||||
G4cout << " LOCAL DOSE/Bq-s : \t" << local_total_dose << " Gy/Bq-s"
|
||||
<< G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
G4cout << G4endl;
|
||||
G4cout << "Finished : End of Run Action " << aRun->GetRunID() << "\n" << G4endl;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user