Import Geant4 4.1.0 source tree
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * 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. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: ExN02ChamberParameterisation.hh,v 1.1 2002/03/05 15:21:56 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-01 $
|
||||
//
|
||||
//
|
||||
// A parameterisation that describes a series of boxes along Z
|
||||
// The boxes have equal width, & their lengths are a linear equation.
|
||||
// They are spaced an equal distance apart, starting from given location.
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef ExN02ChamberParameterisation_H
|
||||
#define ExN02ChamberParameterisation_H 1
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4VPVParameterisation.hh"
|
||||
|
||||
class G4VPhysicalVolume;
|
||||
class G4Box;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class ExN02ChamberParameterisation : public G4VPVParameterisation
|
||||
{
|
||||
public:
|
||||
|
||||
ExN02ChamberParameterisation(G4int NoChambers,
|
||||
G4double startZ,
|
||||
G4double spacing,
|
||||
G4double widthChamber,
|
||||
G4double lengthInitial,
|
||||
G4double lengthFinal );
|
||||
|
||||
virtual
|
||||
~ExN02ChamberParameterisation();
|
||||
|
||||
void ComputeTransformation (const G4int copyNo,
|
||||
G4VPhysicalVolume* physVol) const;
|
||||
|
||||
void ComputeDimensions (G4Box & trackerLayer, const G4int copyNo,
|
||||
const G4VPhysicalVolume* physVol) const;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
G4int fNoChambers;
|
||||
G4double fStartZ;
|
||||
G4double fHalfWidth; // The half-width of each tracker chamber
|
||||
G4double fSpacing; // The distance between the chambers' center
|
||||
G4double fHalfLengthFirst; // The first half-length
|
||||
G4double fHalfLengthIncr; // The Increment for the half-length
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * 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. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: ExN02DetectorConstruction.hh,v 1.1 2002/03/05 15:21:56 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-01 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef ExN02DetectorConstruction_h
|
||||
#define ExN02DetectorConstruction_h 1
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4VUserDetectorConstruction.hh"
|
||||
#include "ExN02MagneticField.hh"
|
||||
|
||||
class G4Box;
|
||||
class G4LogicalVolume;
|
||||
class G4VPhysicalVolume;
|
||||
class G4Material;
|
||||
class ExN02DetectorMessenger;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class ExN02DetectorConstruction : public G4VUserDetectorConstruction
|
||||
{
|
||||
public:
|
||||
|
||||
ExN02DetectorConstruction();
|
||||
~ExN02DetectorConstruction();
|
||||
|
||||
public:
|
||||
|
||||
G4VPhysicalVolume* Construct();
|
||||
|
||||
const
|
||||
G4VPhysicalVolume* GetTracker() {return physiTracker;};
|
||||
G4double GetTrackerFullLength() {return fTrackerLength;};
|
||||
G4double GetTargetFullLength() {return fTargetLength;};
|
||||
G4double GetWorldFullLength() {return fWorldLength;};
|
||||
|
||||
void setTargetMaterial (G4String);
|
||||
void setChamberMaterial(G4String);
|
||||
void SetMagField(G4double);
|
||||
|
||||
private:
|
||||
|
||||
G4Box* solidWorld; // pointer to the solid envelope
|
||||
G4LogicalVolume* logicWorld; // pointer to the logical envelope
|
||||
G4VPhysicalVolume* physiWorld; // pointer to the physical envelope
|
||||
|
||||
G4Box* solidTarget; // pointer to the solid Target
|
||||
G4LogicalVolume* logicTarget; // pointer to the logical Target
|
||||
G4VPhysicalVolume* physiTarget; // pointer to the physical Target
|
||||
|
||||
G4Box* solidTracker; // pointer to the solid Tracker
|
||||
G4LogicalVolume* logicTracker; // pointer to the logical Tracker
|
||||
G4VPhysicalVolume* physiTracker; // pointer to the physical Tracker
|
||||
|
||||
G4Box* solidChamber; // pointer to the solid Chamber
|
||||
G4LogicalVolume* logicChamber; // pointer to the logical Chamber
|
||||
G4VPhysicalVolume* physiChamber; // pointer to the physical Chamber
|
||||
|
||||
G4Material* TargetMater; // pointer to the target material
|
||||
G4Material* ChamberMater; // pointer to the chamber material
|
||||
ExN02MagneticField* fpMagField; // pointer to the magnetic field
|
||||
|
||||
ExN02DetectorMessenger* detectorMessenger; // pointer to the Messenger
|
||||
|
||||
G4double fWorldLength; // Full length of the world volume
|
||||
G4double fTargetLength; // Full length of Target
|
||||
G4double fTrackerLength; // Full length of Tracker
|
||||
G4int NbOfChambers; // Nb of chambers in the tracker region
|
||||
G4double ChamberWidth; // width of the chambers
|
||||
G4double ChamberSpacing; // distance between chambers
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,63 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * 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. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: ExN02DetectorMessenger.hh,v 1.1 2002/03/05 15:21:56 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-01 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef ExN02DetectorMessenger_h
|
||||
#define ExN02DetectorMessenger_h 1
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4UImessenger.hh"
|
||||
|
||||
class ExN02DetectorConstruction;
|
||||
class G4UIdirectory;
|
||||
class G4UIcmdWithAString;
|
||||
class G4UIcmdWithADoubleAndUnit;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class ExN02DetectorMessenger: public G4UImessenger
|
||||
{
|
||||
public:
|
||||
ExN02DetectorMessenger(ExN02DetectorConstruction*);
|
||||
~ExN02DetectorMessenger();
|
||||
|
||||
void SetNewValue(G4UIcommand*, G4String);
|
||||
|
||||
private:
|
||||
ExN02DetectorConstruction* myDetector;
|
||||
|
||||
G4UIdirectory* mydetDir;
|
||||
G4UIcmdWithAString* TargMatCmd;
|
||||
G4UIcmdWithAString* ChamMatCmd;
|
||||
G4UIcmdWithADoubleAndUnit* FieldCmd;
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * 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. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: ExN02EventAction.hh,v 1.1 2002/03/05 15:21:56 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-01 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef ExN02EventAction_h
|
||||
#define ExN02EventAction_h 1
|
||||
|
||||
#include "G4UserEventAction.hh"
|
||||
|
||||
class G4Event;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class ExN02EventAction : public G4UserEventAction
|
||||
{
|
||||
public:
|
||||
ExN02EventAction();
|
||||
~ExN02EventAction();
|
||||
|
||||
public:
|
||||
void BeginOfEventAction(const G4Event*);
|
||||
void EndOfEventAction(const G4Event*);
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * 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. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: ExN02MagneticField.hh,v 1.1 2002/03/05 15:21:57 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-01 $
|
||||
//
|
||||
//
|
||||
// A class for control of the Magnetic Field of the detector.
|
||||
// The field is assumed to be uniform.
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef ExN02MagneticField_H
|
||||
#define ExN02MagneticField_H
|
||||
|
||||
#include "G4UniformMagField.hh"
|
||||
|
||||
class G4FieldManager;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
|
||||
class ExN02MagneticField: public G4UniformMagField
|
||||
{
|
||||
public:
|
||||
|
||||
ExN02MagneticField(G4ThreeVector); // The value of the field
|
||||
ExN02MagneticField(); // A zero field
|
||||
~ExN02MagneticField();
|
||||
|
||||
//Set the field (fieldValue,0,0)
|
||||
void SetFieldValue(G4double fieldValue);
|
||||
void SetFieldValue(G4ThreeVector fieldVector);
|
||||
|
||||
G4ThreeVector GetConstantFieldValue();
|
||||
|
||||
protected:
|
||||
|
||||
// Find the global Field Manager
|
||||
G4FieldManager* GetGlobalFieldManager(); // static
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,69 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * 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. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: ExN02PhysicsList.hh,v 1.1 2002/03/05 15:21:57 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-01 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef ExN02PhysicsList_h
|
||||
#define ExN02PhysicsList_h 1
|
||||
|
||||
#include "G4VUserPhysicsList.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class ExN02PhysicsList: public G4VUserPhysicsList
|
||||
{
|
||||
public:
|
||||
ExN02PhysicsList();
|
||||
~ExN02PhysicsList();
|
||||
|
||||
protected:
|
||||
// Construct particle and physics
|
||||
void ConstructParticle();
|
||||
void ConstructProcess();
|
||||
|
||||
void SetCuts();
|
||||
|
||||
|
||||
protected:
|
||||
// these methods Construct particles
|
||||
void ConstructBosons();
|
||||
void ConstructLeptons();
|
||||
void ConstructMesons();
|
||||
void ConstructBaryons();
|
||||
|
||||
protected:
|
||||
// these methods Construct physics processes and register them
|
||||
void ConstructGeneral();
|
||||
void ConstructEM();
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * 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. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: ExN02PrimaryGeneratorAction.hh,v 1.1 2002/03/05 15:21:57 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-01 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef ExN02PrimaryGeneratorAction_h
|
||||
#define ExN02PrimaryGeneratorAction_h 1
|
||||
|
||||
#include "G4VUserPrimaryGeneratorAction.hh"
|
||||
|
||||
class ExN02DetectorConstruction;
|
||||
class G4ParticleGun;
|
||||
class G4Event;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class ExN02PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
|
||||
{
|
||||
public:
|
||||
ExN02PrimaryGeneratorAction(ExN02DetectorConstruction*);
|
||||
~ExN02PrimaryGeneratorAction();
|
||||
|
||||
public:
|
||||
void GeneratePrimaries(G4Event*);
|
||||
|
||||
private:
|
||||
G4ParticleGun* particleGun;
|
||||
ExN02DetectorConstruction* myDetector;
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * 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. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: ExN02RunAction.hh,v 1.1 2002/03/05 15:21:57 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-01 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef ExN02RunAction_h
|
||||
#define ExN02RunAction_h 1
|
||||
|
||||
#include "G4UserRunAction.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class G4Run;
|
||||
|
||||
class ExN02RunAction : public G4UserRunAction
|
||||
{
|
||||
public:
|
||||
ExN02RunAction();
|
||||
~ExN02RunAction();
|
||||
|
||||
public:
|
||||
void BeginOfRunAction(const G4Run*);
|
||||
void EndOfRunAction(const G4Run*);
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * 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. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: ExN02SteppingAction.hh,v 1.1 2002/03/05 15:21:57 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-01 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef ExN02SteppingAction_h
|
||||
#define ExN02SteppingAction_h 1
|
||||
|
||||
#include "G4UserSteppingAction.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class ExN02SteppingAction : public G4UserSteppingAction
|
||||
{
|
||||
public:
|
||||
ExN02SteppingAction();
|
||||
~ExN02SteppingAction(){};
|
||||
|
||||
void UserSteppingAction(const G4Step*);
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,57 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * 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. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: ExN02SteppingVerbose.hh,v 1.1 2002/03/05 15:21:57 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-01 $
|
||||
//
|
||||
// This class manages the verbose outputs in G4SteppingManager.
|
||||
// It inherits from G4SteppingVerbose.
|
||||
// It shows how to extract informations during the tracking of a particle.
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class ExN02SteppingVerbose;
|
||||
|
||||
#ifndef ExN02SteppingVerbose_h
|
||||
#define ExN02SteppingVerbose_h 1
|
||||
|
||||
#include "G4SteppingVerbose.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class ExN02SteppingVerbose : public G4SteppingVerbose
|
||||
{
|
||||
public:
|
||||
|
||||
ExN02SteppingVerbose();
|
||||
~ExN02SteppingVerbose();
|
||||
|
||||
void StepInfo();
|
||||
void TrackingStarted();
|
||||
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,102 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * 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. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: ExN02TrackerHit.hh,v 1.1 2002/03/05 15:21:58 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-01 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef ExN02TrackerHit_h
|
||||
#define ExN02TrackerHit_h 1
|
||||
|
||||
#include "G4VHit.hh"
|
||||
#include "G4THitsCollection.hh"
|
||||
#include "G4Allocator.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class ExN02TrackerHit : public G4VHit
|
||||
{
|
||||
public:
|
||||
|
||||
ExN02TrackerHit();
|
||||
~ExN02TrackerHit();
|
||||
ExN02TrackerHit(const ExN02TrackerHit&);
|
||||
const ExN02TrackerHit& operator=(const ExN02TrackerHit&);
|
||||
int operator==(const ExN02TrackerHit&) const;
|
||||
|
||||
inline void* operator new(size_t);
|
||||
inline void operator delete(void*);
|
||||
|
||||
void Draw();
|
||||
void Print();
|
||||
|
||||
public:
|
||||
|
||||
void SetTrackID (G4int track) { trackID = track; };
|
||||
void SetChamberNb(G4int chamb) { chamberNb = chamb; };
|
||||
void SetEdep (G4double de) { edep = de; };
|
||||
void SetPos (G4ThreeVector xyz){ pos = xyz; };
|
||||
|
||||
G4int GetTrackID() { return trackID; };
|
||||
G4int GetChamberNb() { return chamberNb; };
|
||||
G4double GetEdep() { return edep; };
|
||||
G4ThreeVector GetPos(){ return pos; };
|
||||
|
||||
private:
|
||||
|
||||
G4int trackID;
|
||||
G4int chamberNb;
|
||||
G4double edep;
|
||||
G4ThreeVector pos;
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
typedef G4THitsCollection<ExN02TrackerHit> ExN02TrackerHitsCollection;
|
||||
|
||||
extern G4Allocator<ExN02TrackerHit> ExN02TrackerHitAllocator;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
inline void* ExN02TrackerHit::operator new(size_t)
|
||||
{
|
||||
void *aHit;
|
||||
aHit = (void *) ExN02TrackerHitAllocator.MallocSingle();
|
||||
return aHit;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
inline void ExN02TrackerHit::operator delete(void *aHit)
|
||||
{
|
||||
ExN02TrackerHitAllocator.FreeSingle((ExN02TrackerHit*) aHit);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * 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. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: ExN02TrackerSD.hh,v 1.1 2002/03/05 15:21:58 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-01 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef ExN02TrackerSD_h
|
||||
#define ExN02TrackerSD_h 1
|
||||
|
||||
#include "G4VSensitiveDetector.hh"
|
||||
#include "ExN02TrackerHit.hh"
|
||||
|
||||
class G4Step;
|
||||
class G4HCofThisEvent;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class ExN02TrackerSD : public G4VSensitiveDetector
|
||||
{
|
||||
public:
|
||||
ExN02TrackerSD(G4String);
|
||||
~ExN02TrackerSD();
|
||||
|
||||
void Initialize(G4HCofThisEvent*);
|
||||
G4bool ProcessHits(G4Step*, G4TouchableHistory*);
|
||||
void EndOfEvent(G4HCofThisEvent*);
|
||||
|
||||
private:
|
||||
ExN02TrackerHitsCollection* trackerCollection;
|
||||
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * 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. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: ExN02VisManager.hh,v 1.1 2002/03/05 15:21:58 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-01 $
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
// Example Visualization Manager implementing virtual function
|
||||
// RegisterGraphicsSystems. Exploits C-pre-processor variables
|
||||
// G4VIS_USE_DAWN, etc., which are set by the GNUmakefiles if
|
||||
// environment variables of the same name are set.
|
||||
|
||||
// So all you have to do is set environment variables and compile and
|
||||
// instantiate this in your main().
|
||||
|
||||
// Alternatively, you can implement an empty function here and just
|
||||
// register the systems you want in your main(), e.g.:
|
||||
// G4VisManager* myVisManager = new MyVisManager;
|
||||
// myVisManager -> RegisterGraphicsSystem (new MyGraphicsSystem);
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef ExN02VisManager_h
|
||||
#define ExN02VisManager_h 1
|
||||
|
||||
#ifdef G4VIS_USE
|
||||
|
||||
#include "G4VisManager.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class ExN02VisManager: public G4VisManager {
|
||||
|
||||
public:
|
||||
|
||||
ExN02VisManager ();
|
||||
|
||||
private:
|
||||
|
||||
void RegisterGraphicsSystems ();
|
||||
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,149 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * 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. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: ParExMarshaledHits.hh,v 1.1 2002/03/05 15:21:58 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-01 $
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// Parallel Library for Geant4
|
||||
//
|
||||
// Gene Cooperman <gene@ccs.neu.edu>, 2001
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#ifndef ParExMarshaledHits_h
|
||||
#define ParExMarshaledHits_h 1
|
||||
|
||||
#include "G4THitsCollection.hh"
|
||||
#include "ParMarshaledObj.hh"
|
||||
|
||||
#include "G4SDManager.hh"
|
||||
#include "G4RunManager.hh"
|
||||
|
||||
// Calling sequence:
|
||||
// MarshaledHCofThisEvent::MarshaledHCofThisEvent()
|
||||
// -> MarshaledHCofThisEvent::MarshalHitsCollection
|
||||
// (G4VHitsCollection * aBaseHC, G4String HCname)
|
||||
// -> TMarshaledHitsCollection<T>::Marshal(G4VHitsCollection * aBaseHC)
|
||||
// -> TMarshaledHitsCollection<T>::MarshalHit(T *aHit)
|
||||
// MarshaledHCofThisEvent::UnmarshalSlaveHCofThisEvent()
|
||||
// -> TMarshaledHitsCollection<T>::UnmarshalSlaveHitsCollection
|
||||
// (G4String HCname, G4String SDname)
|
||||
// -> TMarshaledHitsCollection<T>::Unmarshal(G4THitsCollection<T> * aHC)
|
||||
// -> TMarshaledHitsCollection<T>::UnmarshalHit(T * aHit)
|
||||
|
||||
// class T derived from G4VHit
|
||||
template <class T> class TMarshaledHitsCollection
|
||||
: public MarshaledObj
|
||||
{
|
||||
public:
|
||||
inline void Marshal(G4VHitsCollection * aBaseHC); // Marshal hits of aBaseHC
|
||||
|
||||
inline void UnmarshalSlaveHitsCollection(G4String & HCname, G4String & SDname);
|
||||
inline void Unmarshal(G4THitsCollection<T> * aHC);
|
||||
|
||||
// By default, we a hit of type T as a void pointer
|
||||
inline void MarshalHit( T *aHit )
|
||||
{ MarshaledObj::Marshal((void *)aHit, sizeof(*aHit)); }
|
||||
|
||||
// Unmarshal hits into HC for T. By default assume it was marshaled
|
||||
// as a void pointer (ObjPtr)
|
||||
inline void UnmarshalHit(T * aHit)
|
||||
{
|
||||
if (isNewHitsCollection)
|
||||
*aHit = *(T *)MarshaledObj::UnmarshalAsSharedObjPtr();
|
||||
else
|
||||
G4Exception(
|
||||
"Event Level Parallelism: Every hit collection sent to master"
|
||||
" should be new.\n Current hit collection, "
|
||||
+ collectionName + ", is not new.\n"
|
||||
);
|
||||
}
|
||||
|
||||
protected:
|
||||
static G4bool isNewHitsCollection;
|
||||
static G4String collectionName;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
G4bool TMarshaledHitsCollection<T>::isNewHitsCollection = true;
|
||||
|
||||
template <class T>
|
||||
G4String TMarshaledHitsCollection<T>::collectionName = "<not initialized>";
|
||||
|
||||
template <class T>
|
||||
inline void TMarshaledHitsCollection<T>::Marshal(G4VHitsCollection * aBaseHC)
|
||||
{ G4THitsCollection<T> *aHC = (G4THitsCollection<T> *)aBaseHC;
|
||||
G4int numHits = aHC->entries();
|
||||
MarshaledObj::Marshal( numHits );
|
||||
#ifdef TOPC_DEBUG
|
||||
G4cout << "Marshaled numHits: " << numHits << G4endl;
|
||||
#endif
|
||||
for (int j = 0; j < numHits; j++) {
|
||||
T *aHit = (*aHC)[j];
|
||||
MarshalHit( aHit );
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void TMarshaledHitsCollection<T>::Unmarshal
|
||||
(G4THitsCollection<T> * aHC)
|
||||
{
|
||||
G4int numHits;
|
||||
MarshaledObj::Unmarshal( numHits );
|
||||
#ifdef TOPC_DEBUG
|
||||
G4cout << "numHits: " << numHits << G4endl;
|
||||
#endif
|
||||
for (int j = 0; j < numHits; j++) {
|
||||
T *aHit = new T;
|
||||
UnmarshalHit( aHit );
|
||||
aHC->insert( aHit );
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void TMarshaledHitsCollection<T>::UnmarshalSlaveHitsCollection
|
||||
(G4String & HCname, G4String & SDname)
|
||||
{
|
||||
G4HCofThisEvent *HCE = G4RunManager::GetRunManager()->
|
||||
GetCurrentEvent()->
|
||||
GetHCofThisEvent();
|
||||
// Find or create HitsCollection, aHC, with name HCname
|
||||
G4THitsCollection<T> *aHC;
|
||||
// HCname is unique.
|
||||
collectionName = HCname;
|
||||
G4int HCID = G4SDManager::GetSDMpointer()->GetCollectionID(HCname);
|
||||
if (HCID < 0)
|
||||
{ aHC = new G4THitsCollection<T>(SDname, HCname);
|
||||
HCID = G4SDManager::GetSDMpointer()->GetCollectionID(HCname);
|
||||
HCE->AddHitsCollection( HCID, aHC );
|
||||
isNewHitsCollection = true;
|
||||
}
|
||||
else {
|
||||
aHC = (G4THitsCollection<T> *)HCE->GetHC(HCID);
|
||||
isNewHitsCollection = ( aHC->entries() == 0 ? true : false );
|
||||
}
|
||||
|
||||
Unmarshal(aHC);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,278 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * 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. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: ParMarshaledObj.hh,v 1.1 2002/03/05 15:21:58 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-01 $
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// Parallel Library for Geant4
|
||||
//
|
||||
// Gene Cooperman <gene@ccs.neu.edu>, 2001
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#ifndef ParMarshaledObj_h
|
||||
#define ParMarshaledObj_h 1
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
// Geant4 types; Which of these is the official one? G4types.hh or globals.hh
|
||||
// G4types.hh included from G4ios.hh
|
||||
#include "G4Event.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
// A MarshaledObj is conceptually a
|
||||
// dynamically resizable buffer, size, and cursor.
|
||||
// Data structure of buffer: <field1, field2, ...>
|
||||
// Note that buffer has no internal construct to determine size of buffer
|
||||
// It is the responsibility of the user to know types of field1, ...
|
||||
// There are two types of MarshaledObj, depending on whether
|
||||
// IsUnmarshaling() is true or false.
|
||||
// I use malloc/free because I can also use realloc to extend the buffer.
|
||||
|
||||
class MarshaledObj {
|
||||
private:
|
||||
// Make sure all marshaled objects are word aligned.
|
||||
static const int WORD_SIZE = sizeof(long);
|
||||
static inline int ROUND_UP( int x )
|
||||
{ return (((x)+(WORD_SIZE-1)) / WORD_SIZE) * WORD_SIZE; }
|
||||
|
||||
public:
|
||||
inline MarshaledObj(int total_size)
|
||||
:extent(ROUND_UP(total_size)),size(0)
|
||||
{ if (extent > 0)
|
||||
buffer = (char *)malloc(extent);
|
||||
else
|
||||
buffer = NULL;
|
||||
cursor = buffer + size;
|
||||
}
|
||||
inline MarshaledObj()
|
||||
:extent(128),size(0)
|
||||
{ buffer = (char *)malloc(extent);
|
||||
cursor = buffer + size;
|
||||
}
|
||||
// this is for an arbitrary buffer; we specify the size explicitly
|
||||
// if buf_len == 0, then we'll be unmarshaling
|
||||
inline MarshaledObj(void *buf, int buf_len = 0)
|
||||
:extent(ROUND_UP(buf_len+sizeof(int))),
|
||||
size(ROUND_UP(buf_len+sizeof(buf_len)))
|
||||
{ if ( buf_len <= 0 ) {
|
||||
extent = size = 0; // IMPLIES: IsUnmarshaling() => true
|
||||
buffer = (char *)buf;
|
||||
cursor = buffer;
|
||||
} else {
|
||||
buffer = (char *)malloc(extent);
|
||||
*(int *)buffer = buf_len;
|
||||
memcpy( buffer+sizeof(int), (char *)buf, extent );
|
||||
cursor = buffer + size;
|
||||
}
|
||||
}
|
||||
inline ~MarshaledObj()
|
||||
{ if ( ! IsUnmarshaling() )
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
inline bool IsUnmarshaling() { return (extent <= 0); }
|
||||
|
||||
private:
|
||||
// Don't use copy constructor
|
||||
const MarshaledObj& operator=(const MarshaledObj& right);
|
||||
|
||||
protected:
|
||||
char *buffer; /* First entry is size of buffer */
|
||||
private:
|
||||
int extent; /* extent is number of bytes allocated, extent >= size */
|
||||
int size; /* Initially, buffer has entry for size */
|
||||
char *cursor;
|
||||
|
||||
inline void ResizeBuffer( size_t new_size )
|
||||
{ int displacement = cursor - buffer;
|
||||
extent = new_size;
|
||||
buffer = (char *)realloc( buffer, extent );
|
||||
cursor = buffer + displacement;
|
||||
}
|
||||
|
||||
public:
|
||||
inline int BufferSize()
|
||||
{ return cursor - buffer; }
|
||||
inline void *GetBuffer() {
|
||||
return buffer;
|
||||
}
|
||||
// inline void SetNewBuffer(void *buf) {
|
||||
// free(buffer);
|
||||
// buffer = (char *)buf;
|
||||
// size = 0; /* unknown size */
|
||||
// cursor = buffer;
|
||||
// }
|
||||
|
||||
#define MarshalDefinition(TYPE) \
|
||||
inline void Marshal(TYPE a##TYPE) { \
|
||||
if (IsUnmarshaling()) \
|
||||
throw "Tried to marshal in object marked isUnmarshaling = true"; \
|
||||
size += ROUND_UP(sizeof(a##TYPE)); \
|
||||
while ( size > extent ) \
|
||||
ResizeBuffer( 2 * extent ); \
|
||||
*(TYPE *)cursor = a##TYPE; \
|
||||
cursor = buffer + size; \
|
||||
} \
|
||||
inline void Unmarshal(TYPE & a##TYPE) { \
|
||||
a##TYPE = *(TYPE *)cursor; \
|
||||
cursor += ROUND_UP(sizeof(a##TYPE)); \
|
||||
} \
|
||||
inline TYPE UnmarshalAs##TYPE() { \
|
||||
TYPE a##TYPE = *(TYPE *)cursor; \
|
||||
cursor += ROUND_UP(sizeof(a##TYPE)); \
|
||||
return a##TYPE; \
|
||||
}
|
||||
|
||||
// This works for any inline objects (no embedded pointers)
|
||||
MarshalDefinition(G4int)
|
||||
MarshalDefinition(G4double)
|
||||
MarshalDefinition(G4ThreeVector)
|
||||
// MarshalDefinition(int)
|
||||
// MarshalDefinition(double)
|
||||
|
||||
|
||||
// These cannot follow the pattern, since the data is not inline.
|
||||
inline void MarshalG4String(G4String& aG4String) {
|
||||
if (IsUnmarshaling())
|
||||
throw "Tried to marshal in object marked isUnmarshaling = true";
|
||||
size += ROUND_UP( aG4String.length() + 1 ); // 1 for final NULL char
|
||||
while ( size > extent )
|
||||
ResizeBuffer( 2 * extent );
|
||||
strcpy( (char *)cursor, aG4String );
|
||||
cursor = buffer + size;
|
||||
}
|
||||
inline void Marshal(G4String& aG4String)
|
||||
{ MarshalG4String( aG4String ); }
|
||||
inline void Unmarshal(G4String& aG4String) {
|
||||
aG4String = (char *)cursor;
|
||||
cursor += ROUND_UP( aG4String.length() + 1 ); // 1 for final NULL char
|
||||
}
|
||||
// INEFFICIENT? (copies return value)
|
||||
inline G4String UnmarshalAsG4String() {
|
||||
G4String aG4String = (char *)cursor;
|
||||
cursor += ROUND_UP( aG4String.length() + 1 ); // 1 for final NULL char
|
||||
return aG4String;
|
||||
}
|
||||
|
||||
// USAGE: MarshalObjPtr( &aG4obj, sizeof(aG4obj) );
|
||||
// USAGE: MarshaledObj tmp;
|
||||
// G4Obj *aObjPtr = tmp.UnmarshalObjPtr();
|
||||
// ...
|
||||
// delete aObjPtr;
|
||||
inline void MarshalObjPtr(const void * aObjPtr, int obj_size)
|
||||
{
|
||||
if (IsUnmarshaling())
|
||||
throw "Tried to marshal in object marked isUnmarshaling = true";
|
||||
size += ROUND_UP( obj_size + sizeof(int) );
|
||||
while ( size > extent )
|
||||
ResizeBuffer( 2 * extent );
|
||||
*(int *)cursor = obj_size;
|
||||
memcpy( cursor+sizeof(int), aObjPtr, obj_size );
|
||||
cursor = buffer + size;
|
||||
}
|
||||
inline void Marshal(const void * aObjPtr, int obj_size)
|
||||
{ MarshalObjPtr(aObjPtr,obj_size); }
|
||||
inline void Unmarshal(void * & aObjPtr)
|
||||
{
|
||||
int obj_size = *(int *)cursor;
|
||||
aObjPtr = malloc( obj_size );
|
||||
memcpy( aObjPtr, cursor+sizeof(int), obj_size );
|
||||
cursor += ROUND_UP( obj_size + sizeof(int) );
|
||||
}
|
||||
inline void * UnmarshalAsObjPtr()
|
||||
{
|
||||
void *aObjPtr;
|
||||
Unmarshal(aObjPtr);
|
||||
return aObjPtr;
|
||||
}
|
||||
inline void * UnmarshalAsSharedObjPtr()
|
||||
{
|
||||
int obj_size = *(int *)cursor;
|
||||
void *aObjPtr;
|
||||
aObjPtr = cursor+sizeof(int);
|
||||
cursor += ROUND_UP( obj_size + sizeof(int) );
|
||||
return aObjPtr;
|
||||
}
|
||||
// UnmarshalAsSharedObjPtr: return value points into buffer of curr. obj.
|
||||
|
||||
inline void MarshalMarshaledObj(MarshaledObj& aMarshaledObj) {
|
||||
if (IsUnmarshaling())
|
||||
throw "Tried to marshal in object marked isUnmarshaling = true";
|
||||
MarshalObjPtr( aMarshaledObj.GetBuffer(), aMarshaledObj.BufferSize() );
|
||||
}
|
||||
// INEFFICIENT? (copies return value)
|
||||
inline MarshaledObj UnmarshalAsMarshaledObj() {
|
||||
MarshaledObj aMarshaledObj( ((char *)cursor)+sizeof(int), *(int *)cursor );
|
||||
cursor += ROUND_UP( aMarshaledObj.BufferSize()+sizeof(int) );
|
||||
return aMarshaledObj;
|
||||
}
|
||||
};
|
||||
|
||||
class MarshaledHCofThisEvent : public MarshaledObj
|
||||
{
|
||||
public:
|
||||
inline MarshaledHCofThisEvent(int size) : MarshaledObj(size) { }
|
||||
// Trivial constructor. MarshaledHCofThisEvent(0) creates nothing.
|
||||
MarshaledHCofThisEvent();
|
||||
// Constructor copies hits from HCE of master in this marshaled object
|
||||
MarshaledHCofThisEvent(G4Event *anEvent);
|
||||
// Constructor copies hits from HCE of anEvent in this marshaled object
|
||||
inline MarshaledHCofThisEvent(void *buf)
|
||||
: MarshaledObj(buf) // Object will be set for IsUnmarshaling
|
||||
{ }
|
||||
|
||||
void UnmarshalSlaveHCofThisEvent();
|
||||
// Unmarshal copies hits from slave in HCE of master
|
||||
// We inherit destructor of ParMarshaledObj
|
||||
// It does so by calling UnmarshalSlaveHitsCollection for dispatching
|
||||
void UnmarshalSlaveHitsCollection(G4String & HCname, G4String & SDname);
|
||||
|
||||
void MarshalHitsCollection(G4VHitsCollection * aBaseHC, G4String HCname);
|
||||
// To be defined in ParExN02MarshaledHits.cc or other
|
||||
// application-specific file.
|
||||
|
||||
private:
|
||||
// Don't use copy constructor
|
||||
const MarshaledHCofThisEvent& operator=(const MarshaledHCofThisEvent& right);
|
||||
void MarshalHitsCollection(const G4Event *anEvent);
|
||||
};
|
||||
|
||||
/*
|
||||
main() {
|
||||
MarshaledObj tmp = MarshaledObj();
|
||||
tmp.Marshal(5);
|
||||
tmp.Marshal(5.3);
|
||||
tmp.Marshal(7);
|
||||
|
||||
MarshaledObj tmp2;
|
||||
tmp2.MarshalMarshaledObj(tmp);
|
||||
cout << tmp2.UnmarshalAsG4int() << "\n";
|
||||
cout << tmp2.UnmarshalAsG4double() << "\n";
|
||||
cout << tmp2.UnmarshalAsG4int() << "\n";
|
||||
}
|
||||
*/
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,85 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * 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. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: ParRandomState.hh,v 1.1 2002/03/05 15:21:58 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-01 $
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// Parallel Library for Geant4
|
||||
//
|
||||
// Gene Cooperman <gene@ccs.neu.edu>, 2001
|
||||
// --------------------------------------------------------------------
|
||||
// Each of the three members below must be modified for the application.
|
||||
// This default version simply sets the random seed on the slave using
|
||||
// the eventID.
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#ifndef ParMarshaledRandomState_h
|
||||
#define ParMarshaledRandomState_h 1
|
||||
|
||||
#include "ParMarshaledObj.hh"
|
||||
|
||||
class ParMarshaledRandomState : public MarshaledObj
|
||||
{
|
||||
public:
|
||||
// If 0, GetNextRandomStateForSlave not called.
|
||||
static const int RANDOM_STATE_SIZE = sizeof(long);
|
||||
|
||||
// Called on master
|
||||
inline void *GetNextRandomStateForSlave()
|
||||
{ static long * nextSeed = new long;
|
||||
*nextSeed = (long) (100000000L * HepRandom::getTheGenerator()->flat());
|
||||
#ifdef TOPC_DEBUG
|
||||
G4cout << "GET SEED: " << *nextSeed << G4endl;
|
||||
#endif
|
||||
return nextSeed;
|
||||
}
|
||||
|
||||
// Called on slave at beginning of new event.
|
||||
inline void SetNextRandomStateForSlave( G4int eventID, void *randomState )
|
||||
{ HepRandom::setTheSeed( *(long *)randomState );
|
||||
#ifdef TOPC_DEBUG
|
||||
G4cout << "SET SEED: " << *(long *)randomState << G4endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
public:
|
||||
// The constructors do not need to be modified.
|
||||
inline ParMarshaledRandomState( G4int eventID )
|
||||
: MarshaledObj(RANDOM_STATE_SIZE+sizeof(int)+sizeof(G4int))
|
||||
{ Marshal(eventID);
|
||||
Marshal( GetNextRandomStateForSlave(), RANDOM_STATE_SIZE );
|
||||
}
|
||||
inline ParMarshaledRandomState( void *buf )
|
||||
: MarshaledObj(buf)
|
||||
// MarshaledObj() called with buf and 0 size, creates object for unmarshaling
|
||||
{ }
|
||||
|
||||
inline void unmarshalEventIDandSetState( G4int & eventID )
|
||||
{ Unmarshal(eventID);
|
||||
// SharedObjPtr is pointer to random state.
|
||||
SetNextRandomStateForSlave( eventID, UnmarshalAsSharedObjPtr() );
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * 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. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: ParRunManager.hh,v 1.2 2002/06/06 17:05:02 cooperma Exp $
|
||||
// GEANT4 tag $Name: geant4-04-01 $
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// Parallel Library for Geant4
|
||||
//
|
||||
// Gene Cooperman <gene@ccs.neu.edu>, 2001
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#ifndef ParRunManager_h
|
||||
#define ParRunManager_h 1
|
||||
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4StateManager.hh"
|
||||
#include "G4UserEventAction.hh"
|
||||
#include "topc.h"
|
||||
|
||||
class ParRunManager : public G4RunManager
|
||||
{
|
||||
|
||||
protected:
|
||||
virtual void DoEventLoop(G4int n_event,
|
||||
const char* macroFile=0,
|
||||
G4int n_select=-1);
|
||||
|
||||
private: // TOP-C callbacks
|
||||
TOPC_BUF GenerateEventInput();
|
||||
TOPC_BUF DoEvent( void * input_buf );
|
||||
TOPC_ACTION CheckEventResult( void * input_buf, void * ignore );
|
||||
|
||||
static ParRunManager* myRunManager;
|
||||
static TOPC_BUF MyGenerateEventInput();
|
||||
static TOPC_BUF MyDoEvent( void * input_buf );
|
||||
static TOPC_ACTION MyCheckEventResult( void * input_buf, void * ignore );
|
||||
|
||||
// Copies of local variables of G4RunManager::DoEventLoop()
|
||||
static G4StateManager* stateManager;
|
||||
static G4int n_event;
|
||||
static G4int n_select;
|
||||
static G4String msg;
|
||||
|
||||
G4int i_event; // Used in lieu of i_event in RunManager::DoEventLoop()
|
||||
|
||||
inline void ImportDoEventLoopLocals(
|
||||
G4StateManager* stateManager, G4int n_event,
|
||||
G4int n_select, G4String msg )
|
||||
{
|
||||
ParRunManager::stateManager = stateManager;
|
||||
ParRunManager::n_event = n_event;
|
||||
ParRunManager::n_select = n_select;
|
||||
ParRunManager::msg = msg;
|
||||
ParRunManager::myRunManager = this;
|
||||
}
|
||||
|
||||
// Copy of userEventAction: see ParRunManager.cc for further comments
|
||||
G4UserEventAction * origUserEventAction;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user