Import Geant4 9.5.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 16:46:55 +02:00
parent 89a9605df1
commit b1eb5424d2
10957 changed files with 888481 additions and 160139 deletions
@@ -0,0 +1,49 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
//
// WARNING : This class is released as a prototype.
// It might strongly evolve or even disapear in the next releases.
//
// History:
// -----------
// 10 Oct 2011 M.Karamitros created
//
// -------------------------------------------------------------------
#ifndef ADDClone_DEF
#define ADDClone_DEF
#define G4IT_TO_BE_CLONED(parent_class) \
virtual parent_class* Clone() const { return 0;}
#define G4IT_ADD_CLONE(parent_class, kid_class) \
virtual parent_class* Clone() const {\
return new kid_class(*this);\
}
#endif // ADDClone_DEF
@@ -0,0 +1,133 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
//
// WARNING : This class is released as a prototype.
// It might strongly evolve or even disapear in the next releases.
//
// History:
// -----------
// 10 Oct 2011 M.Karamitros created
//
// -------------------------------------------------------------------
#ifndef G4AllITManager_h
#define G4AllITManager_h 1
#include <globals.hh>
#include <map>
#include <vector>
#include "G4ITType.hh"
#include "G4ThreeVector.hh"
#include <memory>
class G4IT;
class G4VITManager;
class G4ITBox;
class G4Track;
template<typename T> class G4ITManager;
/**
* Holds all IT Manager, and take care of deleting them
* when AllITManager is deleted
* Set general verbose for all IT Manager
*/
class G4AllITManager
{
public :
static G4AllITManager* Instance();
static void DeleteInstance();
/**
* To delete the Instance you should use DeleteInstance()
* rather than the destructor
*/
~G4AllITManager();
template<typename T> G4ITManager<T>* Instance();
G4VITManager* GetInstance(G4ITType);
G4ITBox* GetBox(const G4Track*);
void RegisterManager(G4VITManager* manager);
void Push(G4Track* track);
/**
* Set General verbose for all IT Manager
* See ITManager builder
*/
void SetVerboseLevel(G4int level)
{
fVerbose = level;
}
G4int GetVerboseLevel()
{
return fVerbose;
}
void UpdatePositionMap();
void CreateTree();
template<typename T> inline std::vector<std::pair<G4IT*, double> >* FindNearest(const G4ThreeVector& pos, const T* it);
template<typename T> inline std::vector<std::pair<G4IT*, double> >* FindNearest(const T* it0, const T* it);
template<typename T> inline std::vector<std::pair<G4IT*, double> >* FindNearestInRange(const G4ThreeVector& pos,
const T* it, G4double range);
template<typename T> inline std::vector<std::pair<G4IT*, double> >* FindNearestInRange(const T* it0, const T* it, G4double range);
private :
G4AllITManager();
static std::auto_ptr<G4AllITManager> fInstance;
std::map<G4ITType, G4VITManager*> fITSubManager ;
int fVerbose ;
};
template<typename T>
inline std::vector<std::pair<G4IT*, double> >* G4AllITManager::FindNearest(const G4ThreeVector& pos, const T* it)
{
return G4ITManager<T>::Instance()->FindNearest(pos,it);
}
template<typename T>
inline std::vector<std::pair<G4IT*, double> >* G4AllITManager::FindNearest(const T* it0, const T* it)
{
return G4ITManager<T>::Instance()->FindNearest(it0, it) ;
}
template<typename T>
inline std::vector<std::pair<G4IT*, double> >* G4AllITManager::FindNearestInRange(const G4ThreeVector& pos, const T* it, G4double range)
{
return G4ITManager<T>::Instance()->FindNearestInRange(pos, it, range);
}
template<typename T>
inline std::vector<std::pair<G4IT*, double> >* G4AllITManager::FindNearestInRange(const T* it0, const T* it, G4double range)
{
return G4ITManager<T>::Instance()->FindNearestInRange(it0, it, range);
}
#endif
@@ -0,0 +1,265 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
//
// WARNING : This class is released as a prototype.
// It might strongly evolve or even disapear in the next releases.
//
// History:
// -----------
// 10 Oct 2011 M.Karamitros created
//
// -------------------------------------------------------------------
#ifndef G4IT_h
#define G4IT_h 1
#include "globals.hh"
#include "G4ITType.hh"
#include "G4ThreeVector.hh"
#include "G4VUserTrackInformation.hh"
#include "G4TrackingInformation.hh"
///
// To implement your own IT class, you should use
// ITDef(MyClass) in the class define in your MyClass.hh
// and ITImp(MyClass) in your MyClass.cc
// For instance, see G4Molecule
///
class G4IT;
class G4KDNode;
class G4ITBox;
class G4Track;
G4IT* GetIT(const G4Track* track) ;
G4IT* GetIT(const G4Track& track) ;
#if defined G4EM_ALLOC_EXPORT
extern G4DLLEXPORT G4Allocator<G4IT> aITAllocator;
#else
extern G4DLLIMPORT G4Allocator<G4IT> aITAllocator;
#endif
class G4TrackListNode;
/**
* G4IT is a interface which allows the inheriting object :
* - to be included in ITManager for the search of nearest
* neighbour
* - to be tracked using G4ITStepManager
* The inheriting class must implement the operator < , ==
* and != in order to enable the sorting out.
* also the concrete header of MyIT ("MyIt.hh") should contain : ITDef(MyIT)
* and the source of MyIT.cc : ITImp(MyIT)
*/
class G4IT : public virtual G4VUserTrackInformation
{
public :
G4IT();
G4IT(G4Track*);
virtual ~G4IT();
inline void *operator new(size_t);
inline void operator delete(void *aIT);
virtual void Print() const {}
virtual const G4String& GetName() const = 0 ;
///
// You should not worried of implementing diff, equal
// and GetType.
// When using ITDef(MyClass) this will be done.
// However, you need to implement in the concrete class
// even fake operators for < and ==
// They will be used by diff and equal.
///
virtual G4bool diff(const G4IT& right) const = 0 ;
virtual G4bool equal(const G4IT& right) const = 0 ;
G4bool operator<(const G4IT& right) const;
G4bool operator==(const G4IT& right) const;
G4bool operator!=(const G4IT& right) const;
void SetTrack(G4Track*);
inline G4Track* GetTrack();
inline const G4Track* GetTrack() const;
void RecordCurrentPositionNTime();
inline void SetPrevious(G4IT*);
inline void SetNext(G4IT*);
inline G4IT* GetPrevious();
inline G4IT* GetNext();
inline const G4IT* GetPrevious() const;
inline const G4IT* GetNext() const;
inline void SetITBox(G4ITBox*);
inline const G4ITBox* GetITBox() const;
void TakeOutBox();
inline void SetNode(G4KDNode*);
inline void SetParentID(int,int);
inline void GetParentID(int&,int&);
inline const G4ThreeVector& GetPreStepPosition() const;
inline G4double GetPreStepLocalTime() const;
inline G4double GetPreStepGlobalTime() const;
inline G4KDNode* GetNode() const;
inline G4TrackingInformation* GetTrackingInfo(){return fTrackingInformation;}
inline G4TrackListNode* GetTrackListNode(){return fTrackNode;}
inline void SetTrackListNode(G4TrackListNode* node){ fTrackNode = node;}
virtual const G4ITType GetITType() const = 0 ;
protected :
G4IT(const G4IT&);
G4IT& operator=(const G4IT&);
G4Track* fTrack ;
private :
G4ITBox * fITBox;
G4IT* fPreviousIT;
G4IT* fNextIT;
G4KDNode* fKDNode ;
int fParentID_A;
int fParentID_B;
G4TrackingInformation* fTrackingInformation ;
G4TrackListNode* fTrackNode;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
///
// Inline methods
///
inline void* G4IT::operator new(size_t)
{
void *aIT;
aIT = (void *) aITAllocator.MallocSingle();
return aIT;
}
inline void G4IT::operator delete(void *aIT)
{ aITAllocator.FreeSingle((G4IT *) aIT);}
inline const G4ITBox* G4IT::GetITBox() const
{
return fITBox ;
}
inline void G4IT::SetITBox(G4ITBox * aITBox)
{
fITBox = aITBox;
}
inline void G4IT::SetPrevious(G4IT* aIT)
{
fPreviousIT = aIT;
}
inline void G4IT::SetNext(G4IT* aIT)
{
fNextIT = aIT;
}
inline G4IT* G4IT::GetPrevious()
{
return fPreviousIT;
}
inline G4IT* G4IT::GetNext()
{
return fNextIT;
}
inline void G4IT::SetTrack(G4Track* track)
{
fTrack = track;
}
inline G4Track* G4IT::GetTrack()
{
return fTrack;
}
inline const G4Track* G4IT::GetTrack() const
{
return fTrack;
}
inline void G4IT::SetParentID(int p_a, int p_b)
{
fParentID_A = p_a;
fParentID_B = p_b;
}
inline void G4IT::GetParentID(int& p_a,int&p_b)
{
p_a = fParentID_A;
p_b = fParentID_B ;
}
inline G4double G4IT::GetPreStepGlobalTime() const
{
return fTrackingInformation->GetPreStepGlobalTime();
}
inline G4double G4IT::GetPreStepLocalTime() const
{
return fTrackingInformation->GetPreStepLocalTime();
}
inline const G4ThreeVector& G4IT::GetPreStepPosition() const
{
return fTrackingInformation->GetPreStepPosition();
}
inline const G4IT* G4IT::GetPrevious() const
{
return fPreviousIT ;
}
inline const G4IT* G4IT::GetNext() const
{
return fNextIT ;
}
inline void G4IT::SetNode(G4KDNode* aNode)
{
fKDNode = aNode ;
}
inline G4KDNode* G4IT::GetNode() const
{
return fKDNode ;
}
#endif
@@ -0,0 +1,141 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
//
// WARNING : This class is released as a prototype.
// It might strongly evolve or even disapear in the next releases.
//
// History:
// -----------
// 10 Oct 2011 M.Karamitros created
//
// -------------------------------------------------------------------
#ifndef G4ITBox_h
#define G4ITBox_h
#include "G4IT.hh"
/**
* A G4ITBox contains all IT of the same kind.
* eg : all °OH
* It behaves just like a stack.
*/
class G4ITBox
{
public :
G4ITBox();
~G4ITBox();
void ResetStack();
void Push(G4IT*);
void Extract(G4IT*);
/** The FindIT methods are used for check only.
* Those methods are not effective due to the
* linear search. It is better to use GetIT(track)
* in order to retrieve the IT and GetIT(track)->GetBox()
* in order to check which is the box pointer.
*/
G4IT* FindIT(const G4Track&) ;
const G4IT* FindIT(const G4Track&) const;
void TransferTo(G4ITBox*);
inline G4bool Empty() const;
inline G4int GetNTrack() const;
inline G4IT* GetFirstIT();
inline G4IT* GetLastIT();
inline const G4IT* GetFirstIT() const;
inline const G4IT* GetLastIT() const;
inline void SetNextBox(G4ITBox* box);
inline G4ITBox* GetNextBox();
inline void SetPreviousBox(G4ITBox* box);
inline G4ITBox* GetPreviousBox();
private :
const G4ITBox & operator=
(const G4ITBox &right);
G4int fNbIT;
G4IT * fFirstIT;
G4IT * fLastIT;
G4ITBox* fPreviousBox;
G4ITBox* fNextBox;
};
inline G4bool G4ITBox::Empty() const
{
return (fNbIT==0);
}
inline G4int G4ITBox::GetNTrack() const
{
return fNbIT ;
}
inline G4IT* G4ITBox::GetFirstIT()
{
return fFirstIT ;
}
inline G4IT* G4ITBox::GetLastIT()
{
return fLastIT ;
}
inline const G4IT* G4ITBox::GetFirstIT() const
{
return fFirstIT ;
}
inline const G4IT* G4ITBox::GetLastIT() const
{
return fLastIT ;
}
inline void G4ITBox::SetNextBox(G4ITBox* box)
{
fNextBox = box;
}
inline G4ITBox* G4ITBox::GetNextBox()
{
return fNextBox ;
}
inline void G4ITBox::SetPreviousBox(G4ITBox* box)
{
fPreviousBox = box;
}
inline G4ITBox* G4ITBox::GetPreviousBox()
{
return fPreviousBox ;
}
#endif
@@ -0,0 +1,255 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
//
// WARNING : This class is released as a prototype.
// It might strongly evolve or even disapear in the next releases.
//
// History:
// -----------
// 10 Oct 2011 M.Karamitros created
//
// -------------------------------------------------------------------
#ifndef G4ITManager_hh
#define G4ITManager_hh 1
#include "globals.hh"
#include <map>
#include "G4AllITManager.hh"
#include "G4ITBox.hh"
#include "G4KDTree.hh"
#include "G4Track.hh"
/**
* G4VITManager is just a virtual interface for G4ITManager.
* For more details, please have a look at the description
* of ITManager.
*/
class G4VITManager
{
protected :
G4ITType fType ;
G4int fVerbose;
public :
G4VITManager();
virtual ~G4VITManager(){;}
void SetVerboseLevel(G4int level)
{
fVerbose = level;
}
G4int GetVerboseLevel()
{
return fVerbose;
}
virtual void UpdatePositionMap() = 0;
virtual void CreateTree() {;}
virtual void Push(G4Track*) = 0 ;
G4ITType GetITType()
{
return fType;
}
G4ITBox* GetBox(const G4Track* track)
{
return GetBox(GetIT(track));
}
virtual G4ITBox* GetBox(const G4IT*) = 0;
// Navigate between boxes
virtual G4ITBox* GetFirstBox() = 0;
virtual G4ITBox* GetNextBox(G4ITBox*) = 0;
virtual G4ITBox* GetLastBox() = 0;
public :
class iterator
{
public :
iterator(G4ITBox*);
virtual ~iterator(){;}
virtual G4bool begin();
virtual G4bool end();
iterator& operator= (const iterator& i);
iterator& operator++(G4int);
G4IT* operator*();
G4ITBox* GetBox();
protected :
//_____________________________________
// Print "G4IT* friendIT" status :
void PrintNext() const;
//_____________________________________
// Attributes
G4IT* fNextIT; // the one you are looking reactants for
G4ITBox* fCurrentBox;
};
class allbox_iterator : public iterator
{
public :
allbox_iterator(G4ITType);
allbox_iterator(G4VITManager*);
virtual ~allbox_iterator() {;}
allbox_iterator& operator= (const allbox_iterator& i);
allbox_iterator& operator++(G4int);
protected :
G4VITManager* fInstance ;
};
class const_iterator : public G4VITManager::iterator
{
public :
const_iterator(G4ITBox*);
virtual ~const_iterator(){;}
const G4IT* operator*();
};
};
/**
* G4ITManager is able to save into different boxes
* the ITs that will be used in the simulation.
* It is a stack-like.
* Those boxes are used to fill a tree which helps
* finding the closest neighboor.
*/
template<typename T>
class G4ITManager : public G4VITManager
{
static G4ITManager<T> * fInstance;
G4ITManager<T>();
typedef std::map<const T,G4ITBox* > BoxMap;
BoxMap fBox;
typedef std::map<const T, G4KDTree* > TreeMap ;
TreeMap fTree;
TreeMap fPrevious_tree;
public :
static G4ITManager<T> * Instance();
virtual ~G4ITManager();
virtual void Push(G4Track*);
//Make a method to extract number of IT from Box
G4int NbElements(const G4IT*);
void EraseABox(T*);
void EraseABox(G4ITBox*);
void SetVerboseLevel(G4int level)
{
fVerbose = level;
}
G4int GetVerboseLevel()
{
return fVerbose;
}
virtual void UpdatePositionMap();
static void iUpdatePositionMap();
G4KDTreeResultHandle FindNearestInRange(const T*, const T*, G4double);
G4KDTreeResultHandle FindNearest(const G4ThreeVector&, const T* it);
G4KDTreeResultHandle FindNearest(const T* it0, const T* it);
G4KDTreeResultHandle FindNearestInRange(const G4ThreeVector&, const T*, G4double);
inline G4ITBox* GetBox(const T* IT)
{
typename BoxMap::const_iterator it = fBox.find(*IT);
if(it == fBox.end()) return 0;
return it->second;
}
inline virtual G4ITBox* GetBox(const G4IT* IT)
{
const T* myIT = dynamic_cast<const T*>(IT);
if(myIT == 0)
{
G4ExceptionDescription exceptionDescription ("You are requested a bad IT");
G4Exception("G4ITManager::GetBox","ITManager001",
FatalErrorInArgument,exceptionDescription);
}
return GetBox(myIT);
}
virtual G4ITBox* GetFirstBox()
{
typename BoxMap::iterator it = fBox.begin();
if(it != fBox.end())
{
return it->second;
}
return 0;
}
virtual G4ITBox* GetNextBox(G4ITBox* box)
{
if(box)
{
return box->GetNextBox();
}
return 0;
}
virtual G4ITBox* GetLastBox()
{
typename BoxMap::reverse_iterator it = fBox.rbegin();
if(it != fBox.rend())
{
return it->second;
}
return 0;
}
};
#ifdef TEMPLATE
#undef TEMPLATE
#endif
#define TEMPLATE template<typename T>
#define G4ITMANAGER G4ITManager<T>
#include "G4ITManager.icc"
#undef TEMPLATE
#undef G4ITMANAGER
#endif
@@ -0,0 +1,395 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
//
// WARNING : This class is released as a prototype.
// It might strongly evolve or even disapear in the next releases.
//
// History:
// -----------
// 10 Oct 2011 M.Karamitros created
//
// -------------------------------------------------------------------
TEMPLATE
G4ITMANAGER * G4ITMANAGER::fInstance(0);
TEMPLATE
G4ITMANAGER * G4ITMANAGER::Instance()
{
if(!fInstance)
fInstance = new G4ITManager();
return fInstance;
}
TEMPLATE
G4ITMANAGER::G4ITManager() : G4VITManager()
{
fType = T::ITType();
SetVerboseLevel(G4AllITManager::Instance()->GetVerboseLevel());
G4AllITManager::Instance()->RegisterManager(this);
}
TEMPLATE
G4ITMANAGER::~G4ITManager()
{
{
typename BoxMap::iterator it;
for(it = fBox.begin() ; it != fBox.end() ; it++)
{
if(it->second)
delete it->second;
}
fBox.clear();
}
{
typename TreeMap::iterator it;
for(it = fTree.begin() ; it != fTree.end() ; it++)
{
if(it->second)
delete it->second;
}
fTree.clear();
for(it = fPrevious_tree.begin() ; it != fPrevious_tree.end() ; it++)
{
if(it->second)
delete it->second;
}
fPrevious_tree.clear();
}
}
TEMPLATE
void G4ITMANAGER::iUpdatePositionMap()
{
fInstance->UpdatePositionMap();
}
TEMPLATE
void G4ITMANAGER::Push(G4Track* track)
{
G4IT* aIT = GetIT(track) ;
aIT->RecordCurrentPositionNTime();
const T& key = dynamic_cast<const T&>(*aIT);
typename BoxMap::iterator it = fBox.find(key);
if(it != fBox.end())
{
G4ITBox* theBox = it->second;
theBox->Push(aIT);
}
else
{
G4ITBox * itBox = new G4ITBox();
std::pair<typename BoxMap::iterator,bool> ret = fBox.insert(std::make_pair (T(key), itBox)) ;
typename BoxMap::iterator box_placement = ret.first;
typename BoxMap::iterator previous_placement = ret.first;
previous_placement--;
typename BoxMap::iterator next_placement = ret.first;
next_placement++;
typename BoxMap::iterator last_placement = fBox.end();
last_placement--;
if(box_placement != fBox.begin())
{
G4ITBox* previous_box = previous_placement->second;
if(previous_box)
{
itBox->SetPreviousBox(previous_box);
previous_box->SetNextBox(itBox);
}
}
if(box_placement != last_placement)
{
G4ITBox* next_box = next_placement->second;
if(next_box)
{
itBox->SetNextBox(next_placement->second);
next_box->SetPreviousBox(itBox);
}
}
itBox -> Push(aIT);
}
if(!(aIT->GetNode()))
{
G4KDNode* node = 0;
G4ThreeVector position = aIT->GetTrack()->GetPosition();
typename TreeMap::iterator it_fTree = fTree.find(key);
if(it_fTree != fTree.end())
{
node=it_fTree->second->Insert(position.x(),
position.y(),
position.z(),
aIT);
}
else
{
G4KDTree* aTree = new G4KDTree() ;
fTree.insert(std::make_pair(T(key),aTree));
node = aTree->Insert(position.x(),
position.y(),
position.z(),
aIT);
}
aIT->SetNode(node);
}
}
TEMPLATE
void G4ITMANAGER::EraseABox(T* aIT)
{
// G4cout<<"G4ITMANAGER::EraseABox : " << aIT->GetName()<<G4endl;
const T& key = dynamic_cast<const T&>(*aIT);
typename BoxMap::iterator it = fBox.find(key);
if(it != fBox.end())
{
fBox.erase(it);
}
}
TEMPLATE
void G4ITMANAGER::EraseABox(G4ITBox* aStack)
{
typename BoxMap::iterator it;
for ( it=fBox.begin() ; it != fBox.end(); it++)
{
if(it->second == aStack)
{
break;
}
}
fBox.erase(it);
}
TEMPLATE
G4int G4ITMANAGER::NbElements(const G4IT* aIT)
{
const T& key = dynamic_cast<const T&>(*aIT);
typename BoxMap::iterator it = fBox.find(key);
if(it != fBox.end()) return it->second->GetNTrack();
return -1;
}
TEMPLATE
G4KDTreeResultHandle G4ITMANAGER::FindNearest(const G4ThreeVector& position, const T* key)
{
typename TreeMap::iterator it = fTree.find(*key);
if(it!= fTree.end())
return it->second->Nearest(position.x(),position.y(),position.z());
else
{
return 0;
}
return 0;
}
TEMPLATE
G4KDTreeResultHandle G4ITMANAGER::FindNearest(const T* point0, const T* key)
{
if(*point0 == *key)
{
// DEBUG
// G4cout << "Equal keys !"<< G4endl;
G4KDNode* node0 = point0->GetNode() ;
if(node0 == 0)
{
G4ExceptionDescription exceptionDescription
("Bad request : no node found in the IT you are searching closest neighbourg for");
G4Exception("G4ITManager::FindNearest","ITManager002",
FatalErrorInArgument,exceptionDescription);
}
typename TreeMap::iterator it = fTree.find(*key);
if(it!= fTree.end())
{
G4KDTreeResultHandle output(it->second->Nearest(node0));
if(!output)
{
// G4cout << "NO OUTPUT " << point0->GetName() << " " << key -> GetName() << G4endl;
return 0;
}
// G4cout << "OUTPUT" << G4endl;
return output;
}
else
{
// DEBUG
// G4cout << "Pas trouve dans la map"<< key->GetName() << G4endl;
return 0;
}
}
else
{
// DEBUG
// G4cout << "Not equal keys !"<< G4endl;
const G4ThreeVector& position = point0->GetTrack()->GetPosition() ;
typename TreeMap::iterator it = fTree.find(*key);
if(it!= fTree.end())
{
G4KDTreeResultHandle output(it->second->Nearest(position.x(),position.y(),position.z()));
if(!output)
{
// G4cout << "NO OUTPUT" << G4endl;
return 0;
}
// G4cout << "OUTPUT" << G4endl;
return output;
}
else
{
// DEBUG
// G4cout << "Pas trouve dans la map : "<< key->GetName() << G4endl;
return 0;
}
}
return 0;
}
TEMPLATE
G4KDTreeResultHandle G4ITMANAGER::FindNearestInRange(const G4ThreeVector& position, const T* key, G4double R)
{
typename TreeMap::iterator it = fTree.find(*key);
if(it!= fTree.end())
return it->second->NearestInRange(position.x(),position.y(),position.z(), R);
else
{
return 0;
}
return 0;
}
TEMPLATE
G4KDTreeResultHandle G4ITMANAGER::FindNearestInRange(const T* point0, const T* key, G4double R)
{
if(*point0 == *key)
{
G4KDNode* node0 = point0->GetNode() ;
typename TreeMap::iterator it = fTree.find(*key);
if(it!= fTree.end())
return it->second->NearestInRange(node0, R);
else
{
return 0;
}
}
else
{
const G4ThreeVector& position = point0->GetTrack()->GetPosition() ;
typename TreeMap::iterator it = fTree.find(*key);
if(it!= fTree.end())
return it->second->NearestInRange(position.x(),position.y(),position.z(), R);
else
{
return 0;
}
}
return 0;
}
TEMPLATE
void G4ITMANAGER::UpdatePositionMap()
{
allbox_iterator allbox(this) ;
const G4ITBox* currentBox = 0 ;
const G4ITBox* buffBox = 0;
G4KDTree* currentTree = 0;
G4IT* currentIT = 0 ;
typename TreeMap::iterator it_fTree ;
if(!(fPrevious_tree.empty()))
{
for(it_fTree = fPrevious_tree.begin() ; it_fTree != fPrevious_tree.end() ; it_fTree ++)
{
if(it_fTree->second)
delete (it_fTree->second) ;
}
fPrevious_tree.clear();
}
for(allbox.begin() ; allbox.end() ; allbox++)
{
buffBox = allbox.GetBox() ;
currentIT = (*allbox);
if(currentBox != buffBox)
{
currentTree = 0 ;
currentBox = buffBox;
const T& key = dynamic_cast<const T&>(*currentIT);
it_fTree = fTree.find(key);
if(it_fTree != fTree.end())
{
currentTree = it_fTree ->second ;
if(currentTree)
{
fPrevious_tree[key] = currentTree ;
// currentTree->Clear();
}
}
// Re-initialize fTree
currentTree = new G4KDTree();
fTree[key] = currentTree ;
}
const G4ThreeVector& position = currentIT-> GetTrack()->GetPosition();
G4KDNode* node = currentTree->Insert(position.x(),
position.y(),
position.z(),
currentIT);
currentIT->SetNode(node);
}
}
@@ -0,0 +1,105 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
//
// WARNING : This class is released as a prototype.
// It might strongly evolve or even disapear in the next releases.
//
// History:
// -----------
// 10 Oct 2011 M.Karamitros created
//
// -------------------------------------------------------------------
#ifndef G4ITModelHandler_H
#define G4ITModelHandler_H
#include "G4ITType.hh"
#include "G4ITModelManager.hh"
/**
* G4ITModelHandler holds for two IT types the corresponding model manager
*/
class G4ITModelHandler
{
public:
G4ITModelHandler();
G4ITModelHandler(const G4ITModelHandler& other);
G4ITModelHandler& operator=(const G4ITModelHandler& rhs);
/** Default destructor */
~G4ITModelHandler();
void Initialize();
// Register a model at a starting time (time1)
// if a second model is registered at a later time (time2);
// the second model will be considered from
// time2 to the end of simulation
void RegisterModel(G4VITModel* aModel, const G4double globalTime);
// Model applying for type 1 and type 2
inline G4ITModelManager* GetModelManager(G4ITType, G4ITType);
void SetModel(G4ITType, G4ITType, G4VITModel* aModel, G4double startingTime);
G4VITModel* GetModel(G4ITType, G4ITType, const G4double globalTime);
//
inline const std::vector<std::vector<G4ITModelManager*> >* GetAllModelManager()
{
return &fModelManager;
}
inline bool GetTimeStepComputerFlag() {return fTimeStepComputerFlag;}
inline bool GetReactionProcessFlag() {return fReactionProcessFlag;}
protected:
G4bool fIsInitialized;
std::vector<std::vector<G4ITModelManager*> > fModelManager ;
G4bool fTimeStepComputerFlag; // Set true if a computer is registered
G4bool fReactionProcessFlag; // Set true if a reaction process is registered
};
inline
G4ITModelManager* G4ITModelHandler::GetModelManager(G4ITType type1, G4ITType type2)
{
if(fModelManager.empty())
{
return 0;
}
if((int) fModelManager.size() < type1) return 0;
std::vector<G4ITModelManager*>* v = &(fModelManager.at(type1));
if((int) v->size() < type2) return 0;
return v->at(type2);
}
#endif // G4ITModelHandler_H
@@ -0,0 +1,67 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
//
// WARNING : This class is released as a prototype.
// It might strongly evolve or even disapear in the next releases.
//
// History:
// -----------
// 10 Oct 2011 M.Karamitros created
//
// -------------------------------------------------------------------
#ifndef G4ITMODELMANAGER_H
#define G4ITMODELMANAGER_H
#include "globals.hh"
#include <map>
#include "G4VITModel.hh"
/**
* G4ITModelManager chooses which model to use according
* to the global simulation time.
*/
class G4ITModelManager
{
public:
G4ITModelManager();
~G4ITModelManager();
void Initialize();
G4ITModelManager(const G4ITModelManager& other);
G4ITModelManager& operator=(const G4ITModelManager& rhs);
void SetModel(G4VITModel* aModel, G4double startingTime);
G4VITModel* GetModel(const G4double globalTime);
protected :
typedef std::map<G4double /*startingTime*/, G4VITModel* /*aModel*/> mapModels ;
mapModels fModels ;
G4bool fIsInitialized ;
};
#endif // G4ITMODELMANAGER_H
@@ -0,0 +1,179 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
//
// WARNING : This class is released as a prototype.
// It might strongly evolve or even disapear in the next releases.
//
// History:
// -----------
// 10 Oct 2011 M.Karamitros created
//
// -------------------------------------------------------------------
#ifndef G4ITMODELPROCESSOR_H
#define G4ITMODELPROCESSOR_H
#include <vector>
#include "G4ITReactionChange.hh"
#include "G4ITType.hh"
#include "G4ITModelHandler.hh"
class G4VITTimeStepper;
class G4VITReactionProcess;
class G4ITModelHandler;
typedef G4ReferenceCountedHandle< std::vector<G4Track*> > G4TrackVectorHandle;
/**
* The G4ITModelProcessor will call the two processes defined in G4VITModel.
* This processes act at the beginning and end of each step.
* The first one, the TimeStepper will calculate a time step to propagate all
* the track and eventually it can return some tracks that can likely react
* at the end of the step.
* The second one, the ReactionProcess will make the tracks reacting.
*/
class G4ITModelProcessor
{
public:
/** Default constructor */
G4ITModelProcessor();
/** Default destructor */
virtual ~G4ITModelProcessor();
inline void SetModelHandler(G4ITModelHandler*);
void Initialize();
/**
* Restaure original state of the modelProcessor.
* This method should be call only by the ITStepManager
*/
inline void CleanProcessor();
//____________________________________________________________
// Time stepper part
void InitializeStepper(const G4double& currentGlobalTime,
const G4double& userMinTime);
protected :
const G4Track* fTrack;
G4double fUserMinTimeStep;
inline void SetTrack(const G4Track*);
public :
void CalculateTimeStep(const G4Track*, const G4double);
void DoCalculateStep();
//____________________________________________________________
// Reaction process part
void FindReaction(std::map<G4Track*, G4TrackVectorHandle>*,
const double currentStepTime,
const double previousStepTime,
const bool reachedUserStepTimeLimit) ;
//____________________________________________________________
// Get results
inline const std::vector<std::vector<G4VITModel*> >* GetCurrentModel();
inline std::vector<G4ITReactionChange*>* GetReactionInfo()
{
return &fReactionInfo;
}
const G4Track* GetTrack() const
{
return fTrack;
}
protected:
/** Copy constructor
* \param other Object to copy from
*/
G4ITModelProcessor(const G4ITModelProcessor& other);
/** Assignment operator
* \param other Object to assign from
* \return A reference to this
*/
G4ITModelProcessor& operator=(const G4ITModelProcessor& other);
//_____________________________
// Members
G4bool fInitialized;
G4ITModelHandler* fpModelHandler ;
// Attributes for interaction between many IT types
// eg : electron/proton
std::vector<std::vector<G4VITModel*> > fCurrentModel;
// Attributes for interaction between one type of IT
// eg : molecule/molecule or electron/electron
G4VITModel* fpModel;
G4ITModelManager* fpModelManager;
// G4double fNextTimeChangeModel ;
G4ITType fCurrentType1;
G4ITType fCurrentType2;
// Atribute for reactions
std::vector<G4ITReactionChange*> fReactionInfo ;
static std::map<const G4Track*, G4bool> fHasReacted;
};
///
// Inline methods
///
inline void G4ITModelProcessor::SetTrack(const G4Track* track)
{
fTrack = track;
}
inline const std::vector<std::vector<G4VITModel*> >* G4ITModelProcessor::GetCurrentModel()
{
return &fCurrentModel ;
}
inline void G4ITModelProcessor::SetModelHandler(G4ITModelHandler* modelHandler)
{
if(fInitialized == 1)
{
G4ExceptionDescription exceptionDescription ;
exceptionDescription << "You are trying to set a new model while the model processor has alreaday be initialized";
G4Exception("G4ITModelProcessor::SetModelHandler","ITModelProcessor001",
FatalErrorInArgument,exceptionDescription);
}
fpModelHandler = modelHandler;
}
inline void G4ITModelProcessor::CleanProcessor()
{
fTrack = 0;
}
#endif // G4ITMODELPROCESSOR_H
@@ -0,0 +1,134 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
//
// WARNING : This class is released as a prototype.
// It might strongly evolve or even disapear in the next releases.
//
// History:
// -----------
// 10 Oct 2011 M.Karamitros created
//
// -------------------------------------------------------------------
#ifndef G4ITReactionChange_H
#define G4ITReactionChange_H
#include "globals.hh"
#include "G4ParticleChange.hh"
#include "G4TrackFastVector.hh"
/** Similar to G4ParticleChange, but deal with two tracks
* rather than one.
*/
class G4ITReactionChange
{
public:
/** Default constructor */
G4ITReactionChange();
/** Default destructor */
virtual ~G4ITReactionChange();
//_____________________________________________________
// To be used by reaction processes
void Initialize(const G4Track&,
const G4Track&,
G4VParticleChange* particleChangeA = 0,
G4VParticleChange* particleChangeB = 0
) ;
void AddSecondary(G4Track* aSecondary);
inline void KillParents(G4bool);
// If both parents are not killed therefore
// we can used the particle change
// you will have to give the pointers
// of your particleChange while intializing
// but it might tell you that energy is not
// conserved for instance
G4VParticleChange* GetParticleChange(const G4Track*);
//_____________________________________________________
// Not to be used in reaction processes
void UpdateStepInfo(G4Step*, G4Step*);
G4Track* GetSecondary(G4int) const;
G4TrackFastVector* GetfSecondary() ;
G4int GetNumberOfSecondaries() const;
G4bool WereParentsKilled() const;
const G4Track* GetTrackA();
const G4Track* GetTrackB();
protected:
/** Copy constructor
* \param other Object to copy from
*/
G4ITReactionChange(const G4ITReactionChange& other);
/** Assignment operator
* \param other Object to assign from
* \return A reference to this
*/
G4ITReactionChange& operator=(const G4ITReactionChange& other);
// equal/unequal operator
G4bool operator==(const G4ITReactionChange &right) const;
G4bool operator!=(const G4ITReactionChange &right) const;
// "equal" means that the objects have the same pointer.
protected:
std::map<const G4Track*, G4VParticleChange*> fParticleChange;
G4TrackFastVector* fSecondaries ;
G4int fNumberOfSecondaries;
G4bool fKillParents ;
G4bool fParticleChangeIsSet;
};
inline G4Track* G4ITReactionChange::GetSecondary(G4int anIndex) const
{
return (*fSecondaries)[anIndex];
}
inline G4int G4ITReactionChange::GetNumberOfSecondaries() const
{
return fNumberOfSecondaries;
}
inline void G4ITReactionChange::KillParents(G4bool kill)
{
fKillParents = kill;
}
inline G4bool G4ITReactionChange::WereParentsKilled() const
{
return fKillParents ;
}
inline G4TrackFastVector* G4ITReactionChange::GetfSecondary()
{
return fSecondaries;
}
#endif // G4ITReactionChange_H
@@ -0,0 +1,64 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
//
// WARNING : This class is released as a prototype.
// It might strongly evolve or even disapear in the next releases.
//
// History:
// -----------
// 10 Oct 2011 M.Karamitros created
//
// -------------------------------------------------------------------
#ifndef G4ITREACTIONTABLE_H
#define G4ITREACTIONTABLE_H
/**
* Free interface to define reaction information
*/
class G4ITReactionTable
{
public:
/** Default constructor */
G4ITReactionTable();
/** Default destructor */
virtual ~G4ITReactionTable();
/** Copy constructor
* \param other Object to copy from
*/
G4ITReactionTable(const G4ITReactionTable& /*other*/);
/** Assignment operator
* \param other Object to assign from
* \return A reference to this
*/
G4ITReactionTable& operator=(const G4ITReactionTable& /*other*/);
protected:
private:
};
#endif // G4ITREACTIONTABLE_H
@@ -0,0 +1,250 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
//
// WARNING : This class is released as a prototype.
// It might strongly evolve or even disapear in the next releases.
//
// History:
// -----------
// 10 Oct 2011 M.Karamitros created
//
// -------------------------------------------------------------------
#ifndef G4ITStepManager_h
#define G4ITStepManager_h
#include "globals.hh"
#include "G4TrackList.hh"
#include "G4ITModelHandler.hh"
#include <vector>
#include <map>
#include <memory>
class G4ITTrackingManager;
class G4ITModelProcessor;
class G4ITStepProcessor;
class G4Track ;
class G4UserReactionAction;
/**
* G4ITStepManager enables to synchronize in time
* the step of tracks.
*/
class G4ITStepManager
{
public :
static G4ITStepManager* Instance();
/** DeleteInstance should be used instead
* of the destructor
*/
static void DeleteInstance();
~G4ITStepManager();
void Initialize() ;
void Reset();
void Process() ;
void PushTrack(G4Track*);
void ClearList();
void SetEndTime(const double);
inline void SetTimeTolerance(double);
// Two tracks below the time tolerance are supposed to be
// in the same time slice
inline double GetTimeTolerance() const;
inline G4ITModelHandler* GetModelHandler();
inline void SetTimeSteps(std::map<double,double>*);
inline G4int GetNbSteps() const;
inline G4double GetEndTime() const;
inline G4double GetTimeStep() const;
inline G4double GetPreviousTimeStep() const;
inline G4double GetGlobalTime() const;
inline void SetUserAction(G4UserReactionAction*);
inline G4UserReactionAction* GetUserReactionAction() const;
inline void SetVerbose(int);
// 1 : Reaction information
// 2 : (1) + step information
// 3 : (2) + trackList processing info + push track info
inline int GetVerbose() const;
protected:
void DoProcess();
void SynchronizeTracks();
void Stepping();
void FindUserPreDefinedTimeStep();
void CalculateMinTimeStep() ;
void ComputeInteractionLength();
void DoIt();
void ComputeTrackReaction();
void MergeSecondariesWithMainList();
void PushSecondaries(G4ITStepProcessor*);
void _PushTrack(G4Track*);
void PushDelayed(G4Track*, const G4double&);
void EndTracking(G4Track*);
void KillTracks();
void EndTracking();
void ExtractTimeStepperData(G4ITModelProcessor*);
void ExtractILData(G4ITStepProcessor*);
void ExtractDoItData(G4ITStepProcessor*);
void AddTrackID(G4Track*);
private:
G4ITStepManager();
static std::auto_ptr<G4ITStepManager> fgStepManager ;
int fVerbose;
bool fInitialized;
bool fRunning ;
int fNbTracks ;
int fNbSteps ;
// Time members
double fTimeTolerance;
double fGlobalTime;
double fTmpGlobalTime ;
double fEndTime ; // fEndTime : stores the biggest global time steps here (for synchronizing tracks)
double fTmpEndTime ; // fTmpEndTime : Stores the biggest end time here (for synchronizing tracks)
double fPreviousStepTime;
// Flags
bool fComputeTimeStep;
bool fComputeReaction;
double fTimeStep ; // The selected minimum time step
double fTSTimeStep; // Time calculated by the time stepper in CalculateMinTimeStep()
double fILTimeStep; // Time calculated by the interaction length methods in ComputeInteractionLength()
// User steps
bool fUsePreDefinedTimeSteps ;
std::map<double, double>* fpUserTimeSteps ; // One can give time steps in respect to the global time
double fDefinedMinTimeStep ; // selected user time step in respect to the global time
bool fReachedUserTimeLimit ; // if fMinTimeStep == the user time step
std::map<G4Track*, G4TrackVectorHandle> fReactingTracks ;
std::vector<G4Track*> fLeadingTracks ;
bool fInteractionStep ;
// Flag : if the step is lead by the interaction with the matter and NOT by tracks' reaction
G4TrackList* fpMainList ;
G4TrackList fSecondaries ; //to merge with fpMainList
G4TrackList* fpWaitingList ; // Waiting queue of currentList
std::map<double,G4TrackList* > fDelayedList ;
G4TrackList fToBeKilledList ;
G4ITStepProcessor* fpStepProcessor ;
G4ITStepProcessor* fpMasterStepProcessor ;
G4ITModelProcessor* fpModelProcessor;
G4ITModelProcessor* fpMasterModelProcessor;
G4ITModelHandler* fpModelHandler;
G4ITTrackingManager* fpTrackingManager;
G4UserReactionAction* fpUserReactionAction;
};
inline G4ITModelHandler* G4ITStepManager::GetModelHandler() {return fpModelHandler;}
inline void G4ITStepManager::SetEndTime(const double __endtime) { fEndTime = __endtime ;}
inline void G4ITStepManager::SetTimeSteps(std::map<double,double>* steps)
{
fUsePreDefinedTimeSteps = true;
fpUserTimeSteps = steps ;
}
inline G4int G4ITStepManager::GetNbSteps() const
{
return fNbSteps;
}
inline G4double G4ITStepManager::GetEndTime() const
{
return fEndTime;
}
inline G4double G4ITStepManager::GetTimeStep() const
{
return fTimeStep ;
}
inline G4double G4ITStepManager::GetGlobalTime() const
{
return fGlobalTime ;
}
inline void G4ITStepManager::SetUserAction(G4UserReactionAction* userITAction)
{
fpUserReactionAction = userITAction;
}
inline G4UserReactionAction* G4ITStepManager::GetUserReactionAction() const
{
return fpUserReactionAction;
}
inline void G4ITStepManager::SetVerbose(int verbose)
{
fVerbose = verbose;
}
inline int G4ITStepManager::GetVerbose() const
{
return fVerbose ;
}
inline void G4ITStepManager::SetTimeTolerance(double time)
{
fTimeTolerance = time;
}
inline double G4ITStepManager::GetTimeTolerance() const
{
return fTimeTolerance;
}
inline G4double G4ITStepManager::GetPreviousTimeStep() const
{
return fPreviousStepTime;
}
#endif
@@ -0,0 +1,309 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
//
// WARNING : This class is released as a prototype.
// It might strongly evolve or even disapear in the next releases.
//
// History:
// -----------
// 10 Oct 2011 M.Karamitros created
//
// -------------------------------------------------------------------
#ifndef G4ITSTEPPROCESSOR_H
#define G4ITSTEPPROCESSOR_H
#include "G4ios.hh" // Include from 'system'
#include "globals.hh" // Include from 'global'
#include "Randomize.hh" // Include from 'global'
#include "G4Navigator.hh" // Include from 'geometry'
#include "G4LogicalVolume.hh" // Include from 'geometry'
#include "G4VPhysicalVolume.hh" // Include from 'geometry'
#include "G4ProcessManager.hh" // Include from 'piim'
#include "G4Track.hh" // Include from 'track'
#include "G4TrackVector.hh" // Include from 'track'
#include "G4TrackStatus.hh" // Include from 'track'
#include "G4StepStatus.hh" // Include from 'track'
//#include "G4UserSteppingAction.hh" // Include from 'tracking'
//#include "G4UserTrackingAction.hh" // Include from 'tracking'
#include "G4Step.hh" // Include from 'track'
#include "G4StepPoint.hh" // Include from 'track'
#include "G4TouchableHandle.hh" // Include from 'geometry'
#include "G4TouchableHistoryHandle.hh" // Include from 'geometry'
class G4ParticleDefinition ;
class G4ITTrackingManager;
class G4IT;
class G4TrackingInformation;
class G4ITTransportation;
class G4VITProcess;
typedef class std::vector<int, std::allocator<int> > G4SelectedAtRestDoItVector;
typedef class std::vector<int, std::allocator<int> > G4SelectedAlongStepDoItVector;
typedef class std::vector<int, std::allocator<int> > G4SelectedPostStepDoItVector;
/**
* Its role is the same as G4StepManager :
* - Find the minimum physical length and corresponding time step
* - Step one track BUT on a given time step.
*/
class G4ITStepProcessor
{
public:
G4ITStepProcessor();
virtual ~G4ITStepProcessor();
G4Track* GetTrack() {return fpTrack;}
G4Step* GetStep() {return fpStep;}
const G4Step* GetStep() const {return fpStep;}
void SetStep(G4Step* val) {fpStep = val;}
inline G4TrackVector* GetSecondaries() {return fpSecondary;}
inline void SetTrackingManager(G4ITTrackingManager* trackMan) {fpTrackingManager = trackMan;}
inline G4ITTrackingManager* GetTrackingManager() {return fpTrackingManager;}
virtual void Initialize(void* o = 0);
void Initialize(G4Track*);
void DefinePhysicalStepLength(G4Track*);
void Stepping(G4Track*, const double&);
void CalculateStep(G4Track*, const double&);
void CalculateStep(G4Track*);
void DoIt(G4Track*,double);
void FindTransportationStep();
void UpdateTrack(G4Track*);
inline double GetInteractionTime();
inline const G4Track* GetTrack() const ;
inline void CleanProcessor();
protected:
void SetTrack(G4Track*);
void GetProcessNumber();
void SetupMembers();
void ResetSecondaries();
void InitDefineStep();
void InitStepping(G4Track*);
void SetInitialStep();
void GetAtRestIL();
void DoDefinePhysicalStepLength();
G4StepStatus DoStepping();
void CalculateStep();
void DoCalculateStep();
void CloneProcesses();
void ActiveOnlyITProcess();
void ActiveOnlyITProcess(G4ProcessManager*);
void DealWithSecondaries(G4int&);
void InvokeAtRestDoItProcs();
void InvokeAlongStepDoItProcs();
void InvokePostStepDoItProcs();
void InvokePSDIP(size_t); //
void InvokeTransportationProc();
void SetNavigator(G4Navigator* value);
G4double CalculateSafety();
// Return the estimated safety value at the PostStepPoint
void ApplyProductionCut(G4Track*);
G4ITStepProcessor(const G4ITStepProcessor& other);
G4ITStepProcessor& operator=(const G4ITStepProcessor& other);
private:
G4ITTrackingManager* fpTrackingManager;
// Member attributes
G4ProcessVector* fpAtRestDoItVector;
G4ProcessVector* fpAlongStepDoItVector;
G4ProcessVector* fpPostStepDoItVector;
G4ProcessVector* fpAtRestGetPhysIntVector;
G4ProcessVector* fpAlongStepGetPhysIntVector;
G4ProcessVector* fpPostStepGetPhysIntVector;
//
// Note: DoItVector has inverse order against GetPhysIntVector
// and SelectedPostStepDoItVector.
//
G4ITTransportation* fpTransportation ;
G4SelectedAtRestDoItVector* fpSelectedAtRestDoItVector;
G4SelectedAlongStepDoItVector* fpSelectedAlongStepDoItVector;
G4SelectedPostStepDoItVector* fpSelectedPostStepDoItVector;
G4StepStatus* fpStepStatus;
G4VITProcess* fpCurrentProcess;
// The pointer to the process of which DoIt or
// GetPhysicalInteractionLength has been just executed
size_t MAXofAtRestLoops;
size_t MAXofAlongStepLoops;
size_t MAXofPostStepLoops;
size_t fAtRestDoItProcTriggered;
size_t fAlongStepDoItProcTriggered;
size_t fPostStepDoItProcTriggered;
G4int fN2ndariesAtRestDoIt;
G4int fN2ndariesAlongStepDoIt;
G4int fN2ndariesPostStepDoIt;
// These are the numbers of secondaries generated by the process
// just executed.
//*********************************************************
G4TrackVector* fpSecondary ;
// G4UserSteppingAction* fpUserSteppingAction;
G4bool KillVerbose;
G4double* fpPhysicalStep; // Taken from G4TrackingInformation
G4double fPreviousStepSize;
G4double fTimeStep ;
G4double fPreviousStepTime ;
G4VParticleChange* fpParticleChange;
G4Track* fpTrack;
G4IT* fpITrack ;
G4TrackingInformation* fpTrackingInfo ;
G4Step* fpStep;
G4StepPoint* fpPreStepPoint;
G4StepPoint* fpPostStepPoint;
G4VPhysicalVolume* fpCurrentVolume;
G4VSensitiveDetector* fpSensitive;
G4Navigator* fpNavigator;
G4int fStoreTrajectory;
G4int verboseLevel;
G4TouchableHandle* fpTouchableHandle;
G4SteppingControl StepControlFlag;
G4double kCarTolerance;
// Cached geometrical tolerance on surface
G4double proposedSafety;
// This keeps the minimum safety value proposed by AlongStepGPILs.
G4ThreeVector endpointSafOrigin;
G4double endpointSafety;
// To get the true safety value at the PostStepPoint, you have
// to subtract the distance to 'endpointSafOrigin' from this value.
G4double physIntLength;
G4ForceCondition fCondition;
G4GPILSelection fGPILSelection;
// Above three variables are for the method
// DefinePhysicalStepLength(). To pass these information to
// the method Verbose, they are kept at here. Need a more
// elegant mechanism.
};
inline const G4Track* G4ITStepProcessor::GetTrack() const
{
return fpTrack;
}
inline G4double G4ITStepProcessor::CalculateSafety()
{
return std::max( endpointSafety -
(endpointSafOrigin - fpPostStepPoint->GetPosition()).mag(),
kCarTolerance );
}
inline void G4ITStepProcessor::SetNavigator(G4Navigator* value)
{
fpNavigator = value;
}
inline void G4ITStepProcessor::CleanProcessor()
{
fTimeStep = DBL_MAX ;
fpPhysicalStep = 0 ;
fpTrack = 0 ;
fpITrack = 0;
fpStep = 0 ;
fpTrackingInfo = 0 ;
fpParticleChange = 0;
fpTrack = 0;
fpITrack = 0;
fpStep = 0;
fpPreStepPoint = 0;
fpPostStepPoint = 0;
fpCurrentVolume = 0;
fpSensitive = 0;
fpSecondary = 0 ;
fpAtRestDoItVector = 0;
fpAlongStepDoItVector = 0;
fpPostStepDoItVector= 0;
fpAtRestGetPhysIntVector= 0;
fpAlongStepGetPhysIntVector= 0;
fpPostStepGetPhysIntVector= 0;
fpTransportation = 0;
fpSelectedAtRestDoItVector = 0;
fpSelectedAlongStepDoItVector= 0;
fpSelectedPostStepDoItVector= 0;
fpStepStatus= 0;
fpCurrentProcess= 0;
}
//______________________________________________________________________________
inline double G4ITStepProcessor::GetInteractionTime()
{
return fTimeStep ;
}
#endif // G4ITSTEPPROCESSOR_H
@@ -0,0 +1,102 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
//
// WARNING : This class is released as a prototype.
// It might strongly evolve or even disapear in the next releases.
//
// History:
// -----------
// 10 Oct 2011 M.Karamitros created
//
// -------------------------------------------------------------------
#ifndef G4ITTRACKINGMANAGER_HH
#define G4ITTRACKINGMANAGER_HH
#include "G4TrackList.hh"
/***
#include "G4VTrajectory.hh"
***/
class G4ITTrackingManager;
class G4UserTrackingAction;
class G4Step;
class G4Track;
class G4Trajectory_Lock
{
friend class G4ITTrackingManager;
G4Trajectory_Lock()
/*** : fpTrajectory(0)***/
{;}
~G4Trajectory_Lock()
{;}
/***G4VTrajectory* fpTrajectory;***/
};
class G4ITTrackingManager
{
int fStoreTrajectory;
int fVerboseLevel;
/*** G4UserTrackingAction* fpUserTrackingAction; ***/
bool fSetNewUserTrackingAction;
public:
G4ITTrackingManager();
~G4ITTrackingManager();
void Initialize();
void StartTracking(G4Track*);
void TrackBanner(G4Track* track, const G4String& message = "");
void AppendTrajectory(G4Track* track, G4Step* step);
void EndTracking(G4Track*);
inline void SetVerbose(int);
// if not set, will use tracking action of standard G4TrackingManager
/***
void SetUserTrackingAction(G4UserTrackingAction*);
inline G4UserTrackingAction* GetUserTrackingAction();
***/
};
/***
inline G4UserTrackingAction* G4ITTrackingManager::GetUserTrackingAction()
{
return fpUserTrackingAction;
}
***/
inline void G4ITTrackingManager::SetVerbose(int flag)
{
fVerboseLevel = flag;
}
#endif // G4ITTRACKINGMANAGER_HH
@@ -0,0 +1,241 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// This class is a slightly modified version of G4Transportation
// But it should use the exact same algorithm
//
// WARNING : This class is released as a prototype.
// It might strongly evolve or even disapear in the next releases.
//
// History:
// -----------
// 10 Oct 2011 M.Karamitros created
//
// -------------------------------------------------------------------
#ifndef G4ITTransportation_H
#define G4ITTransportation_H
#include "G4IT.hh"
#include "G4VITProcess.hh"
#include "G4Track.hh"
#include "G4Step.hh"
#include "G4ParticleChangeForTransport.hh"
class G4Navigator;
class G4SafetyHelper;
class G4PropagatorInField;
class G4ITTransportation : public G4VITProcess
{
// Concrete class that does the geometrical transport
public: // with description
G4ITTransportation(const G4String& aName = "ITTransportation",G4int verbosityLevel= 1);
virtual ~G4ITTransportation();
G4ITTransportation(const G4ITTransportation&);
G4IT_ADD_CLONE(G4VITProcess, G4ITTransportation)
virtual void BuildPhysicsTable(const G4ParticleDefinition&){;}
virtual void ComputeStep(const G4Track&,
const G4Step&,
const double timeStep,
double& spaceStep) ;
virtual void StartTracking(G4Track* aTrack);
// Give to the track a pointer to the transportation state
//________________________________________________________
public: // without description
virtual G4double AtRestGetPhysicalInteractionLength(
const G4Track& ,
G4ForceCondition*
)
{
return -1.0;
}
// No operation in AtRestDoIt.
virtual G4VParticleChange* AtRestDoIt(
const G4Track& ,
const G4Step&
)
{
return 0;
}
// No operation in AtRestDoIt.
virtual G4double AlongStepGetPhysicalInteractionLength(
const G4Track& track,
G4double , // previousStepSize
G4double currentMinimumStep,
G4double& currentSafety,
G4GPILSelection* selection);
virtual G4double PostStepGetPhysicalInteractionLength(
const G4Track& , // track
G4double , // previousStepSize
G4ForceCondition* pForceCond);
virtual G4VParticleChange* AlongStepDoIt( const G4Track& track,
const G4Step& stepData );
virtual G4VParticleChange* PostStepDoIt( const G4Track& track,
const G4Step& ) ;
//________________________________________________________
// inline virtual G4double GetTransportationTime() ;
G4PropagatorInField* GetPropagatorInField();
void SetPropagatorInField( G4PropagatorInField* pFieldPropagator);
// Access/set the assistant class that Propagate in a Field.
inline void SetVerboseLevel( G4int verboseLevel );
inline G4int GetVerboseLevel() const;
// Level of warnings regarding eg energy conservation
// in field integration.
inline G4double GetThresholdWarningEnergy() const;
inline G4double GetThresholdImportantEnergy() const;
inline G4int GetThresholdTrials() const;
inline void SetThresholdWarningEnergy( G4double newEnWarn );
inline void SetThresholdImportantEnergy( G4double newEnImp );
inline void SetThresholdTrials(G4int newMaxTrials );
// Get/Set parameters for killing loopers:
// Above 'important' energy a 'looping' particle in field will
// *NOT* be abandoned, except after fThresholdTrials attempts.
// Below Warning energy, no verbosity for looping particles is issued
inline G4double GetMaxEnergyKilled() const;
inline G4double GetSumEnergyKilled() const;
inline void ResetKilledStatistics( G4int report = 1);
// Statistics for tracks killed (currently due to looping in field)
inline void EnableShortStepOptimisation(G4bool optimise=true);
// Whether short steps < safety will avoid to call Navigator (if field=0)
protected :
//________________________________________________________________
// Protected methods
G4bool DoesGlobalFieldExist();
// Checks whether a field exists for the "global" field manager.
//________________________________________________________________
// Process information
struct G4ITTransportationState : public G4ProcessState
{
public :
G4ITTransportationState();
virtual ~G4ITTransportationState();
G4ThreeVector fTransportEndPosition;
G4ThreeVector fTransportEndMomentumDir;
G4double fTransportEndKineticEnergy;
G4ThreeVector fTransportEndSpin;
G4bool fMomentumChanged;
G4bool fEnergyChanged;
G4bool fEndGlobalTimeComputed;
G4double fCandidateEndGlobalTime;
G4bool fParticleIsLooping;
// The particle's state after this Step, Store for DoIt
G4TouchableHandle fCurrentTouchableHandle;
G4bool fGeometryLimitedStep;
// Flag to determine whether a boundary was reached.
G4ThreeVector fPreviousSftOrigin;
G4double fPreviousSafety;
// Remember last safety origin & value.
// Counter for steps in which particle reports 'looping',
// if it is above 'Important' Energy
G4int fNoLooperTrials;
// G4bool fFieldExists;
// Whether a magnetic field exists ...
// A data member for this is problematic: it is useful only if it
// can be initialised and updated -- and a scheme is not yet possible.
G4double endpointDistance;
};
G4ITTransportationState* const & fTransportationState;
//________________________________________________________________
// Informations relative to the process only (meaning no information
// relative to the treated particle)
G4Navigator* fLinearNavigator;
G4PropagatorInField* fFieldPropagator;
// The Propagators used to transport the particle
static const G4TouchableHandle nullTouchableHandle; // Points to (G4VTouchable*) 0
G4ParticleChangeForTransport fParticleChange;
// New ParticleChange
// Thresholds for looping particles:
//
G4double fThreshold_Warning_Energy; // Warn above this energy
G4double fThreshold_Important_Energy; // Hesitate above this
G4int fThresholdTrials; // for this no of trials
// Above 'important' energy a 'looping' particle in field will
// *NOT* be abandoned, except after fThresholdTrials attempts.
G4double fUnimportant_Energy;
// Below this energy, no verbosity for looping particles is issued
// Statistics for tracks abandoned
G4double fSumEnergyKilled;
G4double fMaxEnergyKilled;
// Whether to avoid calling G4Navigator for short step ( < safety)
// If using it, the safety estimate for endpoint will likely be smaller.
G4bool fShortStepOptimisation;
G4SafetyHelper* fpSafetyHelper; // To pass it the safety value obtained
// Verbosity
G4int fVerboseLevel;
// Verbosity level for warnings
// eg about energy non-conservation in magnetic field.
void SetInstantiateProcessState(G4bool flag)
{ fInstantiateProcessState = flag; }
G4bool InstantiateProcessState() { return fInstantiateProcessState; }
private :
G4bool fInstantiateProcessState;
G4ITTransportation& operator=(const G4ITTransportation&);
};
#include "G4ITTransportation.icc"
#endif // G4ITTransportation_H
@@ -0,0 +1,122 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// This class is a slightly modified version of G4Transportation
// But it should use the exact same algorithm
//
// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
//
// WARNING : This class is released as a prototype.
// It might strongly evolve or even disapear in the next releases.
//
// History:
// -----------
// 10 Oct 2011 M.Karamitros created
//
// -------------------------------------------------------------------
inline void
G4ITTransportation::SetPropagatorInField( G4PropagatorInField* pFieldPropagator)
{
fFieldPropagator= pFieldPropagator;
}
inline G4PropagatorInField* G4ITTransportation::GetPropagatorInField()
{
return fFieldPropagator;
}
inline void G4ITTransportation::SetVerboseLevel( G4int verboseLev )
{
fVerboseLevel= verboseLev;
}
inline G4int G4ITTransportation::GetVerboseLevel( ) const
{
return fVerboseLevel;
}
inline G4double G4ITTransportation::GetThresholdWarningEnergy() const
{
return fThreshold_Warning_Energy;
}
inline G4double G4ITTransportation::GetThresholdImportantEnergy() const
{
return fThreshold_Important_Energy;
}
inline G4int G4ITTransportation::GetThresholdTrials() const
{
return fThresholdTrials;
}
inline void G4ITTransportation::SetThresholdWarningEnergy( G4double newEnWarn )
{
fThreshold_Warning_Energy= newEnWarn;
}
inline void G4ITTransportation::SetThresholdImportantEnergy( G4double newEnImp )
{
fThreshold_Important_Energy = newEnImp;
}
inline void G4ITTransportation::SetThresholdTrials(G4int newMaxTrials )
{
fThresholdTrials = newMaxTrials;
}
// Get/Set parameters for killing loopers:
// Above 'important' energy a 'looping' particle in field will
// *NOT* be abandoned, except after fThresholdTrials attempts.
// Below Warning energy, no verbosity for looping particles is issued
inline G4double G4ITTransportation::GetMaxEnergyKilled() const
{
return fMaxEnergyKilled;
}
inline G4double G4ITTransportation::GetSumEnergyKilled() const
{
return fSumEnergyKilled;
}
inline void G4ITTransportation::ResetKilledStatistics(G4int report)
{
if( report ) {
G4cout << " G4ITTransportation: Statistics for looping particles " << G4endl;
G4cout << " Sum of energy of loopers killed: " << fSumEnergyKilled << G4endl;
G4cout << " Max energy of loopers killed: " << fMaxEnergyKilled << G4endl;
}
fSumEnergyKilled= 0;
fMaxEnergyKilled= -1.0*GeV;
}
// Statistics for tracks killed (currently due to looping in field)
inline void G4ITTransportation::EnableShortStepOptimisation(G4bool optimiseShortStep)
{
fShortStepOptimisation=optimiseShortStep;
}
@@ -0,0 +1,122 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
//
// WARNING : This class is released as a prototype.
// It might strongly evolve or even disapear in the next releases.
//
// History:
// -----------
// 10 Oct 2011 M.Karamitros created
//
// -------------------------------------------------------------------
#ifndef G4ITTYPE_HH
#define G4ITTYPE_HH 1
#include <cstddef>
/**
* Tag the G4IT
* Should be automatically setup by G4IT
* using : ITDef(MyIT) and ITImp(MyIT)
*/
struct G4ITType
{
private :
friend G4ITType operator +(const G4ITType& left,const int& right);
friend G4ITType operator -(const G4ITType& left,const int& right);
int fValue;
public :
static size_t size();
G4ITType(const int d_ = 0) : fValue(d_) {;}
G4ITType(const G4ITType & d_) : fValue(d_.fValue){;}
G4ITType & operator=(const G4ITType & rhs);
inline G4ITType & operator=(const int & rhs) { fValue = rhs; return *this;}
inline operator int & () { return fValue; }
inline operator const int & () const { return fValue; }
inline bool operator==(const G4ITType & rhs) const { return fValue == rhs.fValue; }
inline bool operator==(const int & rhs) const { return fValue == rhs; }
inline bool operator<(const G4ITType & rhs) const { return fValue < rhs.fValue; }
inline void operator++() { fValue++; }
};
inline G4ITType operator +(const G4ITType& left,const int& right) {
G4ITType output( left.fValue + right );
return output;
}
inline G4ITType operator -(const G4ITType& left,const int& right) {
G4ITType output( left.fValue - right );
return output;
}
class G4ITTypeManager
{
private:
static G4ITTypeManager* fInstance ;
G4ITType fLastType;
G4ITTypeManager();
virtual ~G4ITTypeManager();
public :
G4ITType NewType() ;
size_t size() const;
static G4ITTypeManager* Instance();
static void DeleteInstance();
};
#define ITDef(T)\
public:\
static G4ITType fType;\
static const G4ITType ITType()\
{\
return fType;\
}\
const G4ITType GetITType() const\
{\
return fType;\
}\
virtual G4bool equal(const G4IT &right) const \
{\
const T& right_mol = (const T&)right ;\
return (this->operator==(right_mol));\
}\
virtual G4bool diff(const G4IT &right) const\
{\
const T& right_mol = (const T&)right ;\
return (this->operator<(right_mol));\
}
#define ITImp(T) \
G4ITType T::fType = G4ITTypeManager::Instance()->NewType();
#endif // G4ITTYPE_HH
@@ -0,0 +1,156 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
//
// WARNING : This class is released as a prototype.
// It might strongly evolve or even disapear in the next releases.
//
// History:
// -----------
// 10 Oct 2011 M.Karamitros created
//
// -------------------------------------------------------------------
#ifndef G4KDNODE_HH
#define G4KDNODE_HH
#include <list>
class G4KDTree;
/**
* G4KDNode stores one entity in G4KDTree
* This class is for internal use only
*/
class G4KDNode
{
public :
// For root node :
// parent = 0, axis = 0, side = 0
G4KDNode(G4KDTree*, const double* /*position*/, void* /*data*/,
G4KDNode* /*parent*/, int axis0);
virtual ~G4KDNode();
inline G4KDTree* GetTree();
inline void SetTree(G4KDTree*);
inline const double* GetPosition();
int GetDim();
inline int GetAxis();
inline void* GetData();
inline void SetData(void*);
inline G4KDNode* GetParent();
inline G4KDNode* GetLeft();
inline G4KDNode* GetRight();
G4KDNode* FindParent(const double* x0);
G4KDNode* Insert(const double* p, void* data);
int Insert(G4KDNode* newNode, double* p);
int Insert(G4KDNode* newNode, const double& x, const double& y, const double& z);
int Insert(G4KDNode* newNode);
void InactiveNode();
void PullSubTree();
void RetrieveNodeList(std::list<G4KDNode*>& node_list);
protected :
int SetPosition(const double* newposition);
//°°°°°°°°°°°
// Members
//°°°°°°°°°°°
double* fPosition;
int fAxis; // axis : x, y, z ...
void *fData;
int fSide ; // left/right
/* fSide == 0 : Is the root node
* fSide == -1 : It is the left of the parent node
* fSide == 1 : It is the right of the parent node
*/
G4KDTree* fTree ;
G4KDNode *fLeft, *fRight, *fParent;
/* Left : fLeft->fPosition[axis] < this->fPosition[axis]
* Right : fRight->fPosition[axis] > this->fPosition[axis]
* Root node : fParent = 0
*/
private :
G4KDNode(const G4KDNode& right);
G4KDNode& operator=(const G4KDNode& right);
};
inline int G4KDNode::GetAxis()
{
return fAxis;
}
inline void* G4KDNode::GetData()
{
return fData;
}
inline void G4KDNode::SetData(void* data)
{
fData = data;
}
inline const double* G4KDNode::GetPosition()
{
return fPosition;
}
inline G4KDNode* G4KDNode::GetParent()
{
return fParent;
}
inline G4KDNode* G4KDNode::GetLeft()
{
return fLeft;
}
inline G4KDNode* G4KDNode::GetRight()
{
return fRight;
}
inline G4KDTree* G4KDNode::GetTree()
{
return fTree;
}
inline void G4KDNode::SetTree(G4KDTree* tree)
{
fTree = tree;
}
#endif // G4KDNODE_HH
@@ -0,0 +1,145 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
//
// WARNING : This class is released as a prototype.
// It might strongly evolve or even disapear in the next releases.
//
// History:
// -----------
// 10 Oct 2011 M.Karamitros created
//
// -------------------------------------------------------------------
#ifndef G4KDTREE_HH
#define G4KDTREE_HH
#include <vector>
#include "G4KDTreeResult.hh"
//__________________________________
// Methods to act on kdnode
// Methods defined in G4KDNode.cc :
void InactiveNode(G4KDNode*);
void Free(G4KDNode*&);
void* GetData(G4KDNode*);
const double* GetNodePosition(G4KDNode*);
//__________________________________
/**
* G4KDTree is used by the ITManager to locate the neareast neighbours.
* A kdtree sorts out node in such a way that it reduces the number of node check.
* The results of this search can be retrieved by G4KDTreeResultHandle.
*/
class G4KDTree
{
friend class G4KDNode ;
int fDim;
struct HyperRect *fRect;
void (*fDestr)(void*);
int fNbNodes;
protected :
G4KDNode *fRoot;
public :
G4KDTree(int dim = 3);
virtual ~G4KDTree();
void Clear();
inline int GetDim();
inline void SetDataDestructor(void (*fDestr)(void*));
int GetNbNodes() { return fNbNodes; }
G4KDNode* GetRoot() { return fRoot ; }
// Insert and attache the data to a node at the specified position
// In return, it gives you the corresponding node
G4KDNode* Insert(const double *pos, void *data);
G4KDNode* Insert(const double& x, const double& y, const double& z, void *data); // 3D
/* Find one of the nearest nodes from the specified point.
*
* This function returns a pointer to a result set with at most one element.
*/
G4KDTreeResultHandle Nearest( const double *pos);
G4KDTreeResultHandle Nearest( const double& x, const double& y, const double& z); // 3D
G4KDTreeResultHandle Nearest( G4KDNode* node);
/* Find any nearest nodes from the specified point within a range.
*
* This function returns a pointer to a result set, which can be manipulated
* by the G4KDTreeResult.
* The returned pointer can be null as an indication of an error. Otherwise
* a valid result set is always returned which may contain 0 or more elements.
*/
G4KDTreeResultHandle NearestInRange( const double *pos, const double& range);
G4KDTreeResultHandle NearestInRange( const double& x,
const double& y,
const double& z,
const double& range); // 3D
G4KDTreeResultHandle NearestInRange( G4KDNode* node, const double& range);
protected :
void __Clear_Rec(G4KDNode *node) ;
int __NearestInRange(G4KDNode *node,
const double *pos,
const double& range_sq,
const double& range,
G4KDTreeResult& list,
int ordered,
G4KDNode *source_node = 0);
void __NearestToPosition(G4KDNode *node,
const double *pos,
G4KDNode *&result,
double *result_dist_sq,
struct HyperRect* fRect);
void __NearestToNode(G4KDNode *source_node,
G4KDNode *node,
const double *pos,
std::vector<G4KDNode*>& result,
double *result_dist_sq,
struct HyperRect* fRect,
int& nbresult) ;
};
inline int G4KDTree::GetDim()
{
return fDim ;
}
void G4KDTree::SetDataDestructor(void (*fct)(void*))
{
fDestr = fct;
}
#endif // G4KDTREE_HH
@@ -0,0 +1,100 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
//
// WARNING : This class is released as a prototype.
// It might strongly evolve or even disapear in the next releases.
//
// History:
// -----------
// 10 Oct 2011 M.Karamitros created
//
// -------------------------------------------------------------------
#ifndef G4KDTREERESULT_HH
#define G4KDTREERESULT_HH
#include <list>
#include "globals.hh"
#include "G4ReferenceCountedHandle.hh"
class G4KDTree;
class G4KDNode;
struct ResNode;
class G4KDTreeResult;
typedef G4ReferenceCountedHandle<G4KDTreeResult> G4KDTreeResultHandle;
typedef G4ReferenceCountedHandle<ResNode> ResNodeHandle;
/**
* G4KDTreeResult enables to go through the nearest entities found
* by G4KDTree.
*/
class G4KDTreeResult : protected std::list<ResNode>
{
protected :
G4KDTree *fTree;
std::list<ResNode>::iterator fIterator;
public:
G4KDTreeResult(G4KDTree*);
virtual ~G4KDTreeResult();
void Insert(double, G4KDNode*);
void Clear();
void Sort();
/* returns the size of the result set (in elements) */
size_t GetSize();
size_t size();
/* rewinds the result set iterator */
void Rewind();
/* returns non-zero if the set iterator reached the end after the last element */
bool End();
/* advances the result set iterator
*/
void Next();
/* returns the data pointer (can be null) of the current result set item
* and optionally sets its position to the pointers(s) if not null.
*/
void* GetItemData();
void* GetItem(double*& /*position*/);
void* GetItem(double& x, double& y, double& z); // 3D
void* GetItemNDistanceSQ(double& /*distance*/);
void* GetItemNDistanceSQ(double*& /*position*/, double& /*distance*/);
double GetDistanceSqr();
};
#endif // G4KDTREERESULT_HH
@@ -0,0 +1,43 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
#ifndef G4REFERENCECAST_HH
#define G4REFERENCECAST_HH
template<typename ReturnType, typename OriginalType>
ReturnType&
reference_cast(OriginalType& source)
{
return (ReturnType &) source;
}
template<typename ReturnType, typename OriginalType>
ReturnType&
reference_cast(ReturnType&, OriginalType& source)
{
return (ReturnType &) source;
}
#endif // G4REFERENCECAST_HH
@@ -0,0 +1,288 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
//
// WARNING : This class is released as a prototype.
// It might strongly evolve or even disapear in the next releases.
//
// History:
// -----------
// 10 Oct 2011 M.Karamitros created
//
// -------------------------------------------------------------------
#ifndef G4TRACKLIST_H
#define G4TRACKLIST_H
#include "globals.hh"
#include "G4ReferenceCountedHandle.hh"
class G4Track;
class G4TrackList;
class G4TrackList_Boundary;
/** Comments :
* - A track cannot belong to two different track lists
* - Erase a given track is constant complexity
* - This development was thought to be used together with G4IT
*/
struct _ListRef
{
friend class G4TrackList ;
protected :
inline _ListRef(G4TrackList* __list) :fTrackList(__list)
{;}
G4TrackList* fTrackList;
};
/**
* G4TrackListNode is the entity actually stored
* by the G4TrackList. A G4TrackListNode should
* belong only to one list. Also, a track
* should belong only to one list.
*/
class G4TrackListNode
{
friend class G4TrackList;
public :
G4Track* GetTrack() { return fTrack; }
G4TrackListNode* GetNext() { return fNext;}
G4TrackListNode* GetPrevious() { return fPrevious;}
bool IsAttached() { return fAttachedToList;}
protected:
/** Default constructor */
G4TrackListNode(G4Track* track= 0);
/** Default destructor */
~G4TrackListNode();
void SetNext(G4TrackListNode* node) { fNext = node;}
void SetPrevious(G4TrackListNode* node) { fPrevious = node;}
void SetAttachedToList(bool flag) { fAttachedToList = flag;}
bool fAttachedToList;
G4ReferenceCountedHandle<_ListRef> fListRef;
G4Track* fTrack;
G4TrackListNode* fPrevious;
G4TrackListNode* fNext;
};
struct G4TrackList_iterator ;
/**
* G4TrackList is used by G4ITStepManager to save
* G4IT tracks only. Its advantage lies to a fast
* search of a track in this list.
*/
class G4TrackList
{
private :
G4int fNbTracks;
G4TrackListNode * fStart;
G4TrackListNode * fFinish;
G4ReferenceCountedHandle<_ListRef> fListRef;
G4TrackListNode fBoundary;
// Must be empty and link to the last non-empty node of the list
// and to the first non-empty node of the list (begin())
// The iterator returned by end() is linked to this empty node
public:
typedef G4TrackList_iterator iterator;
G4TrackList();
~G4TrackList();
inline G4Track* back()
{
if(fNbTracks != 0)
return fFinish->GetTrack();
else return 0 ;
}
inline G4int size() const
{
return fNbTracks;
}
inline bool empty() const;
iterator insert(iterator /*position*/, G4Track*);
inline iterator begin();
inline iterator end();
/**
* return an iterator that contains an empty node
* use for boundary checking only
*/
bool Holds(const G4Track*) const;
inline void push_front(G4Track* __track);
inline void push_back(G4Track* __track);
G4Track* pop_back();
void remove(G4Track*);
iterator pop(G4Track*);
iterator pop(iterator __first, iterator __last);
iterator erase(G4Track*);
/**
* Complexity = constant
* By storing the node inside the object, we avoid
* searching through all the container.
*/
iterator erase(iterator __first, iterator __last);
/**
* Complexity = linear in size between __first and __last
*/
void transferTo(G4TrackList*);
/**
* Complexity = constant
*/
protected:
G4TrackListNode* CreateNode(G4Track*);
G4TrackListNode* Flag(G4Track*);
G4TrackListNode* Unflag(G4Track*);
void CheckFlag(G4TrackListNode*);
void DeleteTrack(G4Track*);
void Hook(G4TrackListNode* /*position*/, G4TrackListNode* /*toHook*/);
void Unhook(G4TrackListNode*);
G4TrackListNode* EraseTrackListNode(G4Track*);
private:
G4TrackList(const G4TrackList& other);
G4TrackList & operator=
(const G4TrackList &right);
G4int operator==(const G4TrackList &right) const;
G4int operator!=(const G4TrackList &right) const;
};
/**
* G4TrackList_iterator enables to go through
* the tracks contained by a list.
*/
struct G4TrackList_iterator
{
friend class G4TrackList;
typedef G4TrackList_iterator _Self;
typedef G4TrackListNode _Node;
G4TrackList_iterator()
: fNode() { }
explicit
G4TrackList_iterator(_Node* __x)
: fNode(__x) { }
_Node* GetNode()
{ return fNode; }
G4Track*
operator*();
const G4Track*
operator*() const;
G4Track*
operator->() ;
const G4Track*
operator->() const;
_Self&
operator++()
{
fNode = fNode->GetNext();
return *this;
}
_Self
operator++(int)
{
_Self __tmp = *this;
fNode = fNode->GetNext();
return __tmp;
}
_Self&
operator--()
{
fNode = fNode->GetPrevious();
return *this;
}
_Self
operator--(int)
{
_Self __tmp = *this;
fNode = fNode->GetPrevious();
return __tmp;
}
bool
operator==(const _Self& __x) const
{ return (fNode == __x.fNode); }
bool
operator!=(const _Self& __x) const
{
return (fNode != __x.fNode);
}
private:
// The only member points to the G4TrackList_iterator element.
_Node* fNode;
};
inline bool G4TrackList::empty() const
{ return (fNbTracks == 0); }
inline G4TrackList::iterator G4TrackList::begin()
{ return iterator(fStart); }
inline G4TrackList::iterator G4TrackList::end()
{ return iterator( &(fBoundary) ); }
// return an iterator that contains an empty node
// use for boundary checking only
inline void G4TrackList::push_front(G4Track* track)
{
insert(begin(), track);
}
inline void G4TrackList::push_back(G4Track* track)
{
insert(end(), track);
}
#endif // G4TRACKLIST_H
@@ -0,0 +1,176 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
//
// WARNING : This class is released as a prototype.
// It might strongly evolve or even disapear in the next releases.
//
// History:
// -----------
// 10 Oct 2011 M.Karamitros created
//
// -------------------------------------------------------------------
#ifndef G4TRACKINGINFORMATION_HH
#define G4TRACKINGINFORMATION_HH
#include "globals.hh"
#include <vector>
#include "G4StepStatus.hh"
#include "G4ThreeVector.hh"
#include "G4TouchableHandle.hh"
class G4ITStepProcessor;
typedef std::vector<G4int>
G4SelectedAtRestDoItVector;
typedef std::vector<G4int>
G4SelectedAlongStepDoItVector;
typedef std::vector<G4int>
G4SelectedPostStepDoItVector;
class G4Trajectory_Lock;
class G4Track;
struct G4ProcessState_Lock;
/** The class G4TrackingInformation (hold by G4IT)
* emcompasses processes informations computed
* at the PS/AS/AtRest/InteractionLength stage,
* and also, the selection of processes for the
* given step.
*/
class G4TrackingInformation
{
public:
G4TrackingInformation();
~G4TrackingInformation();
//________________________________________________
/** If the track is the one having the minimum step time,
* then it "leads" the step. It will interact will all the
* other tracks will be transported.
*/
inline bool IsLeadingStep(){return fStepLeader;}
inline void SetLeadingStep(bool value ){fStepLeader = value;}
//________________________________________________
/** Every process should store the information
* computed at the InteractionLegth stage in the track.
*/
G4ProcessState_Lock* GetProcessState(G4int index);
inline void RecordProcessState(G4ProcessState_Lock*,
G4int index);
inline G4Trajectory_Lock* GetTrajectory_Lock()
{
return fpTrajectory_Lock ;
}
inline void SetTrajectory_Lock(G4Trajectory_Lock* trajLock)
{
fpTrajectory_Lock = trajLock;
}
void RecordCurrentPositionNTime(G4Track*);
inline const G4ThreeVector& GetPreStepPosition() const;
inline G4double GetPreStepLocalTime() const;
inline G4double GetPreStepGlobalTime() const;
//-------------
protected:
//-------------
friend class G4ITStepProcessor;
//_______________________________________________________
G4bool fStepLeader ;
G4StepStatus fStepStatus;
//_______________________________________________________
G4double fPhysicalStep ;
G4double fSafety;
G4double fPreviousStepSize;
//_______________________________________________________
G4TouchableHandle fTouchableHandle;
//_______________________________________________________
G4Trajectory_Lock* fpTrajectory_Lock;
//_______________________________________________________
G4ThreeVector fRecordedTrackPosition;
G4double fRecordedTrackLocalTime;
G4double fRecordedTrackGlobalTime;
//_______________________________________________________
G4SelectedAtRestDoItVector fSelectedAtRestDoItVector;
G4SelectedAlongStepDoItVector fSelectedAlongStepDoItVector;
G4SelectedPostStepDoItVector fSelectedPostStepDoItVector;
//_______________________________________________________
/** Holds the information related to processes
* Indexed on GetPhysIntVector
* (cf. G4ITStepProcessor header)
*/
std::vector<G4ProcessState_Lock*> fProcessState;
//_______________________________________________________
/** Copy constructor
* \param other Object to copy from
*/
G4TrackingInformation(const G4TrackingInformation& other);
/** Assignment operator
* \param other Object to assign from
* \return A reference to this
*/
G4TrackingInformation& operator=(const G4TrackingInformation& other);
};
inline void G4TrackingInformation::RecordProcessState(G4ProcessState_Lock* state,
G4int index)
{
fProcessState[index] = state;
}
inline G4double G4TrackingInformation::GetPreStepGlobalTime() const
{
return fRecordedTrackGlobalTime;
}
inline G4double G4TrackingInformation::GetPreStepLocalTime() const
{
return fRecordedTrackLocalTime;
}
inline const G4ThreeVector& G4TrackingInformation::GetPreStepPosition() const
{
return fRecordedTrackPosition;
}
#endif // G4TRACKINGINFORMATION_HH
@@ -0,0 +1,81 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// WARNING : This class is released as a prototype.
// It might strongly evolve or even disapear in the next releases.
//
// Author: Mathieu Karamitros (kara@cenbg.in2p3.fr)
//
// History:
// -----------
// 10 Oct 2011 M.Karamitros created
//
// -------------------------------------------------------------------
#ifndef G4VUSERITACTION_H
#define G4VUSERITACTION_H
#include "globals.hh"
#include "G4Track.hh"
#include "G4TrackFastVector.hh"
/**
* G4UserReactionAction is used by G4ITStepManager.
* - StartProcessing called before processing
* - TimeStepAction called at every global step
* - UserReactionAction called when a reaction occurs
* - EndProcessing called after processing
*/
class G4UserReactionAction
{
public:
G4UserReactionAction();
G4UserReactionAction(const G4UserReactionAction& );
virtual ~G4UserReactionAction();
virtual void StartProcessing(){;}
/** In this method, the user can use :
* G4ITStepManager::Instance()->GetGlobalTime(), to know the current simulation time
* G4ITStepManager::Instance()->GetMinTime(), to know the selected minimum time
* WARNING : The call of this method happens before the call of DoIT methods
*/
virtual void TimeStepAction(){;}
/**
* This method enables to kill products right after they are generated
*/
virtual void UserReactionAction(const G4Track& /*trackA*/,const G4Track& /*trackB*/,
const G4TrackFastVector& /*products*/,
int /*nbProducts*/){;}
virtual void EndProcessing(){;}
private:
G4UserReactionAction& operator=(const G4UserReactionAction& );
};
#endif // G4VUSERITACTION_H
@@ -0,0 +1,137 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
//
// WARNING : This class is released as a prototype.
// It might strongly evolve or even disapear in the next releases.
//
// History:
// -----------
// 10 Oct 2011 M.Karamitros created
//
// -------------------------------------------------------------------
#ifndef G4VITMODEL_HH
#define G4VITMODEL_HH
#include "AddClone_def.hh"
#include "G4VITTimeStepper.hh"
#include "G4VITReactionProcess.hh"
#include "G4ITReactionTable.hh"
/**
* Define what to do before stepping and after stepping.
* The concrete implementation of G4VITModel defines the interaction
* between two G4IT types. The type might be just equal like :
* Molecule + Molecule, or different : Molecule + Atom.
*/
class G4VITModel
{
public:
/** Default constructor */
G4VITModel(const G4String& aName = "NoName");
/** Default destructor */
virtual ~G4VITModel();
/* Macro define in AddClone_def*/
G4IT_TO_BE_CLONED(G4VITModel)
void IsApplicable(G4ITType& type1, G4ITType& type2) ;
void virtual PrintInfo(){;}
virtual void Initialize();
inline void SetTimeStepper(G4VITTimeStepper* timeStepper);
inline void SetReactionProcess(G4VITReactionProcess* reactionProcess);
inline G4VITTimeStepper* GetTimeStepper();
inline const G4String& GetName();
inline G4VITReactionProcess* GetReactionProcess();
inline void SetReactionTable(G4ITReactionTable*);
inline const G4ITReactionTable* GetReactionTable();
protected:
G4String fName;
G4VITTimeStepper* fTimeStepper;
G4VITReactionProcess* fReactionProcess;
const G4ITReactionTable* fReactionTable ;
G4ITType fType1;
G4ITType fType2;
protected :
/** Copy constructor
* \param other Object to copy from
*/
G4VITModel(const G4VITModel& other);
/** Assignment operator
* \param other Object to assign from
* \return A reference to this
*/
G4VITModel& operator=(const G4VITModel& other);
};
inline void G4VITModel::SetReactionTable(G4ITReactionTable* table)
{
fReactionTable = table;
}
inline const G4ITReactionTable* G4VITModel::GetReactionTable()
{
return fReactionTable ;
}
inline void G4VITModel::SetTimeStepper(G4VITTimeStepper* timeStepper)
{
fTimeStepper = timeStepper ;
}
inline void G4VITModel::SetReactionProcess(G4VITReactionProcess* reactionProcess)
{
fReactionProcess = reactionProcess ;
}
inline G4VITTimeStepper* G4VITModel::GetTimeStepper()
{
return fTimeStepper;
}
inline G4VITReactionProcess* G4VITModel::GetReactionProcess()
{
return fReactionProcess ;
}
inline const G4String& G4VITModel::GetName()
{
return fName;
}
#endif // G4VITMODEL_HH
@@ -0,0 +1,199 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
//
// WARNING : This class is released as a prototype.
// It might strongly evolve or even disapear in the next releases.
//
// History:
// -----------
// 10 Oct 2011 M.Karamitros created
//
// -------------------------------------------------------------------
#ifndef G4VITProcess_H
#define G4VITProcess_H
#include <G4VProcess.hh>
#include "AddClone_def.hh"
#include "G4ReferenceCast.hh"
class G4IT ;
class G4TrackingInformation ;
struct G4ProcessState_Lock{
inline virtual ~G4ProcessState_Lock(){;}
};
#define InitProcessState(destination,source) \
destination(reference_cast(destination,source))
/**
* G4VITProcess inherits from G4VProcess.
* A G4VITProcess is able to save its current state for a given track into G4IT.
* This state may be retrieve latter on to be used by the G4VITProcess.
* Each G4VITProcess is tagged.
*/
class G4VITProcess : public G4VProcess
{
public:
//__________________________________
// Constructors & destructors
G4VITProcess(const G4String& name, G4ProcessType type = fNotDefined);
virtual ~G4VITProcess();
G4VITProcess(const G4VITProcess& other);
G4VITProcess& operator=(const G4VITProcess& other);
// equal opperators
G4int operator==(const G4VITProcess &right) const;
G4int operator!=(const G4VITProcess &right) const;
G4IT_TO_BE_CLONED(G4VITProcess)
G4int GetProcessID()
{
return fProcessID;
}
G4ProcessState_Lock* GetProcessState()
{
return fState;
}
void SetProcessState(G4ProcessState_Lock* aProcInfo)
{
fState = (G4ProcessState*) aProcInfo;
}
//__________________________________
// Initialize and Save process info
virtual void StartTracking(G4Track*);
inline G4double GetInteractionTimeLeft();
/** WARNING : Redefine the method of G4VProcess
* reset (determine the value of)NumberOfInteractionLengthLeft
*/
virtual void ResetNumberOfInteractionLengthLeft();
inline static int GetMaxProcessIndex();
protected: // with description
void RetrieveProcessInfo();
void CreateInfo();
//__________________________________
// Process info
// friend class G4TrackingInformation ;
struct G4ProcessState : public G4ProcessState_Lock
{
public:
G4ProcessState();
virtual ~G4ProcessState();
G4double theNumberOfInteractionLengthLeft;
// The flight length left for the current tracking particle
// in unit of "Interaction length".
G4double theInteractionTimeLeft;
// Time left before the interaction : for at rest processes
G4double currentInteractionLength;
// The InteractionLength in the current material
};
G4ProcessState* fState ;
inline virtual void ClearInteractionTimeLeft();
//_________________________________________________
// Redefine needed members and method of G4VProcess
virtual void SubtractNumberOfInteractionLengthLeft(
G4double previousStepSize
);
// subtract NumberOfInteractionLengthLeft by the value corresponding to
// previousStepSize
inline virtual void ClearNumberOfInteractionLengthLeft();
// clear NumberOfInteractionLengthLeft
// !!! This method should be at the end of PostStepDoIt()
// !!! and AtRestDoIt
//_________________________________________________
void SetInstantiateProcessState(G4bool flag)
{ fInstantiateProcessState = flag; }
G4bool InstantiateProcessState() { return fInstantiateProcessState; }
private :
const G4int fProcessID; // During all the simulation will identify a
// process, so if two identical process are created using a copy constructor
// they will have the same fProcessID
static G4int fNbProcess ;
G4bool fInstantiateProcessState;
//_________________________________________________
// Redefine needed members and method of G4VProcess
G4double* theNumberOfInteractionLengthLeft;
G4double* currentInteractionLength;
G4double* theInteractionTimeLeft;
};
inline void G4VITProcess::ClearInteractionTimeLeft()
{
fState->theInteractionTimeLeft = -1.0;
}
inline void G4VITProcess::ClearNumberOfInteractionLengthLeft()
{
fState->theNumberOfInteractionLengthLeft = -1.0;
}
inline void G4VITProcess::ResetNumberOfInteractionLengthLeft()
{
fState->theNumberOfInteractionLengthLeft = -std::log( G4UniformRand() );
}
inline G4double G4VITProcess::GetInteractionTimeLeft()
{
if(fState)
return fState->theInteractionTimeLeft ;
return -1 ;
}
inline int G4VITProcess::GetMaxProcessIndex()
{
return fNbProcess ;
}
#endif // G4VITProcess_H
@@ -0,0 +1,117 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
//
// WARNING : This class is released as a prototype.
// It might strongly evolve or even disapear in the next releases.
//
// History:
// -----------
// 10 Oct 2011 M.Karamitros created
//
// -------------------------------------------------------------------
#ifndef G4VITREACTIONPROCESS_H
#define G4VITREACTIONPROCESS_H
#include "globals.hh"
#include "G4IT.hh"
#include "G4ITReactionChange.hh"
#include "G4ITReactionTable.hh"
#include "AddClone_def.hh"
/**
* G4VITReactionProcess defines the reaction between two G4IT.
* It should be stored in a G4VITModel.
*/
class G4VITReactionProcess
{
public:
/** Default constructor */
G4VITReactionProcess();
/** Default destructor */
virtual ~G4VITReactionProcess();
/** Copy constructor
* \param other Object to copy from
*/
G4VITReactionProcess(const G4VITReactionProcess& other);
/** Will Clone the reaction process
* i.e. new reaction process will be created with same features
* as the parent one.
* Use preprocessor macro : AddCloneReactionProcess
* the copy constructor of the derived class must be
* implemented.
* This macro is defined in AddClone_def
*/
G4IT_TO_BE_CLONED(G4VITReactionProcess)
/** Assignment operator
* \param other Object to assign from
* \return A reference to this
*/
G4VITReactionProcess& operator=(const G4VITReactionProcess& other);
/** First initialization (done once for all at the begin of the run)
* eg. check if the reaction table is given ...
*/
virtual void Initialize(){;}
virtual G4bool IsApplicable(G4ITType,G4ITType) const {return true;}
virtual void GetApplicableTypes(G4ITType&, G4ITType&) const;
virtual G4bool TestReactibility(const G4Track&,
const G4Track&,
const double /*currentStepTime*/,
const double /*previousStepTime*/,
bool /*reachedUserStepTimeLimit*/) = 0;
virtual G4ITReactionChange* MakeReaction(const G4Track&, const G4Track&) = 0;
inline void SetReactionTable(const G4ITReactionTable*);
inline void ResetChanges();
protected:
G4ITType fApplicableType1;
G4ITType fApplicableType2;
const G4ITReactionTable* fReactionTable;
G4ITReactionChange* fChanges ;
G4String fName ;
};
inline void G4VITReactionProcess::SetReactionTable(const G4ITReactionTable* table)
{
fReactionTable = table;
}
inline void G4VITReactionProcess::ResetChanges()
{
fChanges = 0;
}
#endif // G4VITREACTIONPROCESS_H
@@ -0,0 +1,218 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// Identical to G4VRestDiscreteProcess with dependency from G4VITProcess
//
// WARNING : This class is released as a prototype.
// It might strongly evolve or even disapear in the next releases.
//
// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
//
// History:
// -----------
// 10 Oct 2011 M.Karamitros created
//
// -------------------------------------------------------------------
#ifndef G4VITRESTDISCRETEPROCESS_H
#define G4VITRESTDISCRETEPROCESS_H
#include "G4VITProcess.hh"
/**
* Identical to G4VRestDiscreteProcess with dependency from G4VITProcess
*/
class G4VITRestDiscreteProcess : public G4VITProcess
{
// Abstract class which defines the public behavior of
// rest + discrete physics interactions.
public:
G4VITRestDiscreteProcess(const G4String& ,
G4ProcessType aType = fNotDefined );
G4VITRestDiscreteProcess(G4VITRestDiscreteProcess &);
virtual ~G4VITRestDiscreteProcess();
public :// with description
virtual G4double PostStepGetPhysicalInteractionLength(
const G4Track& track,
G4double previousStepSize,
G4ForceCondition* condition
);
virtual G4VParticleChange* PostStepDoIt(
const G4Track& ,
const G4Step&
);
virtual G4double AtRestGetPhysicalInteractionLength(
const G4Track& ,
G4ForceCondition*
);
virtual G4VParticleChange* AtRestDoIt(
const G4Track& ,
const G4Step&
);
// no operation in AlongStepDoIt
virtual G4double AlongStepGetPhysicalInteractionLength(
const G4Track&,
G4double ,
G4double ,
G4double& ,
G4GPILSelection*
){ return -1.0; }
// no operation in AlongStepDoIt
virtual G4VParticleChange* AlongStepDoIt(
const G4Track& ,
const G4Step&
) {return 0;}
protected:// with description
virtual G4double GetMeanFreePath(const G4Track& aTrack,
G4double previousStepSize,
G4ForceCondition* condition
)=0;
// Calculates from the macroscopic cross section a mean
// free path, the value is returned in units of distance.
virtual G4double GetMeanLifeTime(const G4Track& aTrack,G4ForceCondition* condition)=0;
// Calculates the mean life-time (i.e. for decays) of the
// particle at rest due to the occurence of the given process,
// or converts the probability of interaction (i.e. for
// annihilation) into the life-time of the particle for the
// occurence of the given process.
private:
// hide default constructor and assignment operator as private
G4VITRestDiscreteProcess();
G4VITRestDiscreteProcess & operator=(const G4VITRestDiscreteProcess &right);
};
// -----------------------------------------
// inlined function members implementation
// -----------------------------------------
inline
G4double G4VITRestDiscreteProcess::PostStepGetPhysicalInteractionLength(
const G4Track& track,
G4double previousStepSize,
G4ForceCondition* condition
)
{
if ( (previousStepSize < 0.0) || (fState->theNumberOfInteractionLengthLeft<=0.0)) {
// beggining of tracking (or just after DoIt of this process)
ResetNumberOfInteractionLengthLeft();
} else if ( previousStepSize > 0.0) {
// subtract NumberOfInteractionLengthLeft
SubtractNumberOfInteractionLengthLeft(previousStepSize);
} else {
// zero step
// DO NOTHING
}
// condition is set to "Not Forced"
*condition = NotForced;
// get mean free path
fState->currentInteractionLength = GetMeanFreePath(track, previousStepSize, condition);
G4double value;
if (fState->currentInteractionLength <DBL_MAX) {
value = fState->theNumberOfInteractionLengthLeft * (fState->currentInteractionLength);
} else {
value = DBL_MAX;
}
#ifdef G4VERBOSE
if (verboseLevel>1){
G4cout << "G4VITRestDiscreteProcess::PostStepGetPhysicalInteractionLength ";
G4cout << "[ " << GetProcessName() << "]" <<G4endl;
track.GetDynamicParticle()->DumpInfo();
G4cout << " in Material " << track.GetMaterial()->GetName() <<G4endl;
G4cout << "InteractionLength= " << value/cm <<"[cm] " <<G4endl;
}
#endif
return value;
}
inline G4VParticleChange* G4VITRestDiscreteProcess::PostStepDoIt(
const G4Track& ,
const G4Step&
)
{
// reset NumberOfInteractionLengthLeft
ClearNumberOfInteractionLengthLeft();
return pParticleChange;
}
inline G4double G4VITRestDiscreteProcess::AtRestGetPhysicalInteractionLength(
const G4Track& track,
G4ForceCondition* condition
)
{
// beggining of tracking
ResetNumberOfInteractionLengthLeft();
// condition is set to "Not Forced"
*condition = NotForced;
// get mean life time
fState->currentInteractionLength = GetMeanLifeTime(track, condition);
#ifdef G4VERBOSE
if ((fState->currentInteractionLength <0.0) || (verboseLevel>2)){
G4cout << "G4VITRestDiscreteProcess::AtRestGetPhysicalInteractionLength ";
G4cout << "[ " << GetProcessName() << "]" <<G4endl;
track.GetDynamicParticle()->DumpInfo();
G4cout << " in Material " << track.GetMaterial()->GetName() <<G4endl;
G4cout << "MeanLifeTime = " << fState->currentInteractionLength/ns << "[ns]" <<G4endl;
}
#endif
return fState->theNumberOfInteractionLengthLeft * (fState->currentInteractionLength);
}
inline G4VParticleChange* G4VITRestDiscreteProcess::AtRestDoIt(
const G4Track&,
const G4Step&
)
{
// clear NumberOfInteractionLengthLeft
ClearNumberOfInteractionLengthLeft();
return pParticleChange;
}
#endif
@@ -0,0 +1,160 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// Identical to G4VRestProcess with dependency from G4VITProcess
//
// WARNING : This class is released as a prototype.
// It might strongly evolve or even disapear in the next releases.
//
// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
//
// History:
// -----------
// 10 Oct 2011 M.Karamitros created
//
// -------------------------------------------------------------------
#ifndef G4VITRestProcess_h
#define G4VITRestProcess_h 1
#include "G4VITProcess.hh"
/**
* Identical to G4VRestProcess with dependency from G4VITProcess
*/
class G4VITRestProcess : public G4VITProcess
{
// Abstract class which defines the public behavior of
// physics interactions at rest.
public:
G4VITRestProcess(const G4String& ,
G4ProcessType aType = fNotDefined );
G4VITRestProcess(const G4VITRestProcess& );
virtual ~G4VITRestProcess();
public: // with description
virtual G4double AtRestGetPhysicalInteractionLength(
const G4Track& track,
G4ForceCondition* condition
);
virtual G4VParticleChange* AtRestDoIt(
const G4Track& ,
const G4Step&
);
// no operation in PostStepDoIt and AlongStepDoIt
virtual G4double AlongStepGetPhysicalInteractionLength(
const G4Track&,
G4double ,
G4double ,
G4double& ,
G4GPILSelection*
){ return -1.0; }
virtual G4double PostStepGetPhysicalInteractionLength(
const G4Track& ,
G4double ,
G4ForceCondition*
) { return -1.0; }
// no operation in PostStepDoIt and AlongStepDoIt
virtual G4VParticleChange* PostStepDoIt(
const G4Track& ,
const G4Step&
) {return 0;}
virtual G4VParticleChange* AlongStepDoIt(
const G4Track& ,
const G4Step&
) {return 0;}
protected: // with description
virtual G4double GetMeanLifeTime(const G4Track& aTrack,G4ForceCondition* condition)=0;
// Calculates the mean life-time (i.e. for decays) of the
// particle at rest due to the occurence of the given process,
// or converts the probability of interaction (i.e. for
// annihilation) into the life-time of the particle for the
// occurence of the given process.
protected:
// hide default constructor and assignment operator as private
G4VITRestProcess();
G4VITRestProcess & operator=(const G4VITRestProcess &right);
};
// -----------------------------------------
// inlined function members implementation
// -----------------------------------------
inline G4double G4VITRestProcess::AtRestGetPhysicalInteractionLength(
const G4Track& track,
G4ForceCondition* condition
)
{
// beggining of tracking
ResetNumberOfInteractionLengthLeft();
// condition is set to "Not Forced"
*condition = NotForced;
// get mean life time
fState->currentInteractionLength = GetMeanLifeTime(track, condition);
#ifdef G4VERBOSE
if ((fState->currentInteractionLength <0.0) || (verboseLevel>2)){
G4cout << "G4VITRestProcess::AtRestGetPhysicalInteractionLength ";
G4cout << "[ " << GetProcessName() << "]" <<G4endl;
track.GetDynamicParticle()->DumpInfo();
G4cout << " in Material " << track.GetMaterial()->GetName() <<G4endl;
G4cout << "MeanLifeTime = " << fState->currentInteractionLength/ns << "[ns]" <<G4endl;
}
#endif
return (fState->theNumberOfInteractionLengthLeft) * (fState->currentInteractionLength);
}
inline G4VParticleChange* G4VITRestProcess::AtRestDoIt(
const G4Track&,
const G4Step&
)
{
// clear NumberOfInteractionLengthLeft
ClearNumberOfInteractionLengthLeft();
return pParticleChange;
}
#endif
@@ -0,0 +1,123 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
//
// WARNING : This class is released as a prototype.
// It might strongly evolve or even disapear in the next releases.
//
// History:
// -----------
// 10 Oct 2011 M.Karamitros created
//
// -------------------------------------------------------------------
#ifndef G4VITTimeStepper_H
#define G4VITTimeStepper_H
#include "G4Track.hh"
#include "G4ITReactionTable.hh"
#include "G4ReferenceCountedHandle.hh"
#include "AddClone_def.hh"
typedef G4ReferenceCountedHandle< std::vector<G4Track*> > G4TrackVectorHandle;
/**
* Before stepping all tracks G4ITStepManager calls all the G4VITModel
* which may contain a G4VITTimeStepper (optionnal).
* G4VITTimeStepper returns what should be the next global time step.
* Time step that will be used to step all tracks.
*/
class G4VITTimeStepper
{
public:
G4VITTimeStepper();
virtual ~G4VITTimeStepper();
G4VITTimeStepper(const G4VITTimeStepper&);
G4VITTimeStepper& operator=(const G4VITTimeStepper& other);
/** This macro defined in AddClone_def **/
G4IT_TO_BE_CLONED(G4VITTimeStepper)
// First initialization (done once for all at the begin of the run)
// eg. check if the reaction table is given ...
inline virtual void Initialize(){;}
// Preparation part
static void SetTimes(const G4double&, const G4double&);
inline virtual void PrepareForAllProcessors(){;}
inline virtual void Prepare() ;
virtual G4double CalculateStep(const G4Track&, const G4double&) = 0;
inline G4TrackVectorHandle GetReactants();
inline virtual void ResetReactants(){fReactants = 0;}
//
inline G4double GetSampledMinTimeStep() ;
inline void SetReactionTable(const G4ITReactionTable*);
inline const G4ITReactionTable* GetReactionTable();
protected :
static G4double fCurrentGlobalTime ;
static G4double fUserMinTimeStep ;
G4double fSampledMinTimeStep ;
G4TrackVectorHandle fReactants;
const G4ITReactionTable* fReactionTable;
private:
G4int fVerbose ;
};
inline void G4VITTimeStepper::SetReactionTable(const G4ITReactionTable* table)
{
fReactionTable = table;
}
inline const G4ITReactionTable* G4VITTimeStepper::GetReactionTable()
{
return fReactionTable ;
}
inline void G4VITTimeStepper::Prepare()
{
fReactants = 0 ;
}
inline G4double G4VITTimeStepper::GetSampledMinTimeStep()
{
return fSampledMinTimeStep ;
}
inline G4TrackVectorHandle G4VITTimeStepper::GetReactants()
{
return fReactants ;
}
#endif // G4VITTimeStepper_H