Import Geant4 7.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 11:11:55 +02:00
parent e083ffb441
commit 516dbf1a58
5914 changed files with 202605 additions and 71141 deletions
@@ -22,7 +22,7 @@
//
//
// $Id: ExN02ChamberParameterisation.hh,v 1.3 2003/12/03 14:15:03 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00-patch-01 $
// GEANT4 tag $Name: geant4-07-00-cand-01 $
//
//
// A parameterisation that describes a series of boxes along Z
@@ -22,7 +22,7 @@
//
//
// $Id: ExN02DetectorConstruction.hh,v 1.1 2002/03/05 15:21:56 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-02-patch-01 $
// GEANT4 tag $Name: geant4-07-00-cand-01 $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -22,7 +22,7 @@
//
//
// $Id: ExN02DetectorMessenger.hh,v 1.2 2003/12/03 14:15:03 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00-patch-01 $
// GEANT4 tag $Name: geant4-07-00-cand-01 $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -22,7 +22,7 @@
//
//
// $Id: ExN02EventAction.hh,v 1.1 2002/03/05 15:21:56 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-02-patch-01 $
// GEANT4 tag $Name: geant4-07-00-cand-01 $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -22,7 +22,7 @@
//
//
// $Id: ExN02MagneticField.hh,v 1.1 2002/03/05 15:21:57 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-02-patch-01 $
// GEANT4 tag $Name: geant4-07-00-cand-01 $
//
//
// A class for control of the Magnetic Field of the detector.
@@ -22,7 +22,7 @@
//
//
// $Id: ExN02PhysicsList.hh,v 1.1 2002/03/05 15:21:57 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-02-patch-01 $
// GEANT4 tag $Name: geant4-07-00-cand-01 $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -22,7 +22,7 @@
//
//
// $Id: ExN02PrimaryGeneratorAction.hh,v 1.1 2002/03/05 15:21:57 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-02-patch-01 $
// GEANT4 tag $Name: geant4-07-00-cand-01 $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -22,7 +22,7 @@
//
//
// $Id: ExN02RunAction.hh,v 1.1 2002/03/05 15:21:57 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-02-patch-01 $
// GEANT4 tag $Name: geant4-07-00-cand-01 $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -22,7 +22,7 @@
//
//
// $Id: ExN02SteppingAction.hh,v 1.1 2002/03/05 15:21:57 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-02-patch-01 $
// GEANT4 tag $Name: geant4-07-00-cand-01 $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -22,7 +22,7 @@
//
//
// $Id: ExN02SteppingVerbose.hh,v 1.1 2002/03/05 15:21:57 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-02-patch-01 $
// GEANT4 tag $Name: geant4-07-00-cand-01 $
//
// This class manages the verbose outputs in G4SteppingManager.
// It inherits from G4SteppingVerbose.
@@ -22,7 +22,7 @@
//
//
// $Id: ExN02TrackerHit.hh,v 1.3 2003/12/03 14:15:03 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00-patch-01 $
// GEANT4 tag $Name: geant4-07-00-cand-01 $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -22,7 +22,7 @@
//
//
// $Id: ExN02TrackerSD.hh,v 1.1 2002/03/05 15:21:58 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-02-patch-01 $
// GEANT4 tag $Name: geant4-07-00-cand-01 $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -22,7 +22,7 @@
//
//
// $Id: ExN02VisManager.hh,v 1.1 2002/03/05 15:21:58 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-02-patch-01 $
// GEANT4 tag $Name: geant4-07-00-cand-01 $
//
//
@@ -0,0 +1,26 @@
MARSHALGEN_PATH = /afs/cern.ch/user/c/cooperma/vietha/Marshalgen
MARSHAL=$(MARSHALGEN_PATH)/marshalgen
default: all
all: G4String G4THits G4VHits ExN02TrackerHit G4HCofThisEvent
(cp -p ../AnnotatedFiles/Marshaled* .; cp -p $(MARSHALGEN_PATH)/MarshaledObj.h .)
ExN02TrackerHit: ExN02TrackerHit.hh
$(MARSHAL) $?
G4String: ../AnnotatedFiles/G4String.hh
$(MARSHAL) $?
G4HCofThisEvent: ../AnnotatedFiles/G4HCofThisEvent.hh
$(MARSHAL) $?
G4THits: ../AnnotatedFiles/G4THitsCollection.hh
$(MARSHAL) $?
G4VHits: ../AnnotatedFiles/G4VHitsCollection.hh
$(MARSHAL) $?
clean:
rm *.msh Marshaled* ../AnnotatedFiles/*.msh ../AnnotatedFiles/Marshaled*
@@ -0,0 +1,310 @@
// This file was generated automatically by marshalgen.
#ifndef MarshaledExN02TrackerHit_H
#define MarshaledExN02TrackerHit_H
#include <ExN02TrackerHit.hh>
//MSH_include_begin
#include "MarshaledG4String.h"
//MSH_include_end
#include <stdio.h>
#include <string.h>
#include "MarshaledObj.h"
class MarshaledExN02TrackerHit;
class ShadowedMarshaledExN02TrackerHit : public ExN02TrackerHit{
friend class MarshaledExN02TrackerHit;
};
class MarshaledExN02TrackerHit : public MarshaledObj {
public:
ExN02TrackerHit* param;
ShadowedMarshaledExN02TrackerHit* Shadowed_param;
public:
// Function implementations
MarshaledExN02TrackerHit(ExN02TrackerHit* objptr) : MarshaledObj() {
msh_isUnmarshalDone = false;
this->param = objptr;
this->Shadowed_param = (ShadowedMarshaledExN02TrackerHit*)this->param;
if (objptr == NULL)
return;
marshal1();
marshal2();
marshal3();
marshal4();
}
MarshaledExN02TrackerHit(void *buf, char isUnmarshaling = 'u')
: MarshaledObj(buf, isUnmarshaling) {
msh_isUnmarshalDone = false;
}
~MarshaledExN02TrackerHit() {
//if(msh_isUnmarshalDone && this->param != NULL) {
//delete this->param;
//}
}
ExN02TrackerHit* unmarshal() {
//We don't want to unmarshal the buffer is empty.
if(msh_size <= MSH_HEADER_SIZE) {
//This is buggy, we can't always assume that
//obj == NULL <==> List is empty.
return NULL;
} else {
{
param = new ExN02TrackerHit();
}
this->Shadowed_param = (ShadowedMarshaledExN02TrackerHit*)this->param;
this->msh_isUnmarshalDone = true;
unmarshal1();
unmarshal2();
unmarshal3();
unmarshal4();
return this->param;
}
}
void unmarshalTo(ExN02TrackerHit* obj) {
//We don't want to unmarshal the buffer is empty.
if(msh_size <= MSH_HEADER_SIZE) {
//This is buggy, we can't always assume that
//obj == NULL <==> List is empty.
return;
} else {
this->param = obj;
this->Shadowed_param = (ShadowedMarshaledExN02TrackerHit*)this->param;
this->msh_isUnmarshalDone = true;
unmarshal1();
unmarshal2();
unmarshal3();
unmarshal4();
}
}
void marshal1() {
//declare field_size to be the size of this field
int msh_currentSize = 0;
if (isUnmarshaling())
throw "Tried to marshal in obj marked isUnmarshaling == true";
//Copy the sizespec into msh_currentSize here:
{
msh_currentSize = sizeof(G4ThreeVector);
}
//Increase the size of buffer if needed
EXTEND_BUFFER(msh_currentSize + sizeof(int) + sizeof(int)); // 4 bytes for the total size of field, 4 bytes for the number of elements in the array (in the case of array marshaling)
//Mark the beginning position for this field, will write the total size of this field here later
msh_field_begin = msh_cursor;
//Advance cursor of distance = sizeof(int)
msh_cursor += sizeof(int);
//Now just copy "get" functions here
{
G4ThreeVector anElement;
anElement = param->GetPos();
memcpy(msh_cursor, &anElement, sizeof(G4ThreeVector));
}
//Now advance the cursor
msh_cursor += msh_currentSize;
//Now set the size of this field
int tmp; //use memcpy instead of *(int*)... =... to prevent bus error
tmp = (msh_cursor-msh_field_begin) - sizeof(int);
memcpy(msh_field_begin, &tmp, sizeof(int));
//Now set msh_size
msh_size = msh_cursor - msh_buffer;
MSH_SET_TOTALSIZE(msh_size); MSH_SET_TYPECHOICE(msh_typechoice);
}
void unmarshal1() {
//declare currentSize to be the size of this field
int msh_currentSize = 0;
//copy the size of the current field into currentSize
memcpy(&msh_currentSize, msh_cursor, sizeof(int));
msh_cursor += sizeof(int);
//Now copy the setspec here
{
G4ThreeVector anElement;
memcpy(&anElement, msh_cursor, sizeof(G4ThreeVector));
param->SetPos(anElement);
}
msh_cursor += msh_currentSize;
}
void marshal2() {
//declare field_size to be the size of this field
int msh_currentSize = 0;
if (isUnmarshaling())
throw "Tried to marshal in obj marked isUnmarshaling == true";
//Copy the sizespec into msh_currentSize here:
{
msh_currentSize = sizeof(G4double);
}
//Increase the size of buffer if needed
EXTEND_BUFFER(msh_currentSize + sizeof(int) + sizeof(int)); // 4 bytes for the total size of field, 4 bytes for the number of elements in the array (in the case of array marshaling)
//Mark the beginning position for this field, will write the total size of this field here later
msh_field_begin = msh_cursor;
//Advance cursor of distance = sizeof(int)
msh_cursor += sizeof(int);
//Now just copy "get" functions here
{
G4double anElement;
anElement = param->GetEdep();
memcpy(msh_cursor, &anElement, sizeof(G4double));
}
//Now advance the cursor
msh_cursor += msh_currentSize;
//Now set the size of this field
int tmp; //use memcpy instead of *(int*)... =... to prevent bus error
tmp = (msh_cursor-msh_field_begin) - sizeof(int);
memcpy(msh_field_begin, &tmp, sizeof(int));
//Now set msh_size
msh_size = msh_cursor - msh_buffer;
MSH_SET_TOTALSIZE(msh_size); MSH_SET_TYPECHOICE(msh_typechoice);
}
void unmarshal2() {
//declare currentSize to be the size of this field
int msh_currentSize = 0;
//copy the size of the current field into currentSize
memcpy(&msh_currentSize, msh_cursor, sizeof(int));
msh_cursor += sizeof(int);
//Now copy the setspec here
{
G4double anElement;
memcpy(&anElement, msh_cursor, sizeof(G4double));
param->SetEdep(anElement);
}
msh_cursor += msh_currentSize;
}
void marshal3() {
//declare field_size to be the size of this field
int msh_currentSize = 0;
if (isUnmarshaling())
throw "Tried to marshal in obj marked isUnmarshaling == true";
//Copy the sizespec into msh_currentSize here:
{
msh_currentSize = sizeof(G4int );
}
//Increase the size of buffer if needed
EXTEND_BUFFER(msh_currentSize + sizeof(int) + sizeof(int)); // 4 bytes for the total size of field, 4 bytes for the number of elements in the array (in the case of array marshaling)
//Mark the beginning position for this field, will write the total size of this field here later
msh_field_begin = msh_cursor;
//Advance cursor of distance = sizeof(int)
msh_cursor += sizeof(int);
//Now just copy "get" functions here
{
G4int anElement;
anElement = param->GetTrackID();
memcpy(msh_cursor, &anElement, sizeof(G4int ));
}
//Now advance the cursor
msh_cursor += msh_currentSize;
//Now set the size of this field
int tmp; //use memcpy instead of *(int*)... =... to prevent bus error
tmp = (msh_cursor-msh_field_begin) - sizeof(int);
memcpy(msh_field_begin, &tmp, sizeof(int));
//Now set msh_size
msh_size = msh_cursor - msh_buffer;
MSH_SET_TOTALSIZE(msh_size); MSH_SET_TYPECHOICE(msh_typechoice);
}
void unmarshal3() {
//declare currentSize to be the size of this field
int msh_currentSize = 0;
//copy the size of the current field into currentSize
memcpy(&msh_currentSize, msh_cursor, sizeof(int));
msh_cursor += sizeof(int);
//Now copy the setspec here
{
G4int anElement;
memcpy(&anElement, msh_cursor, sizeof(G4int ));
param->SetTrackID(anElement);
}
msh_cursor += msh_currentSize;
}
void marshal4() {
//declare field_size to be the size of this field
int msh_currentSize = 0;
if (isUnmarshaling())
throw "Tried to marshal in obj marked isUnmarshaling == true";
//Copy the sizespec into msh_currentSize here:
{
msh_currentSize = sizeof(G4int );
}
//Increase the size of buffer if needed
EXTEND_BUFFER(msh_currentSize + sizeof(int) + sizeof(int)); // 4 bytes for the total size of field, 4 bytes for the number of elements in the array (in the case of array marshaling)
//Mark the beginning position for this field, will write the total size of this field here later
msh_field_begin = msh_cursor;
//Advance cursor of distance = sizeof(int)
msh_cursor += sizeof(int);
//Now just copy "get" functions here
{
G4int anElement;
anElement = param->GetChamberNb();
memcpy(msh_cursor, &anElement, sizeof(G4int ));
}
//Now advance the cursor
msh_cursor += msh_currentSize;
//Now set the size of this field
int tmp; //use memcpy instead of *(int*)... =... to prevent bus error
tmp = (msh_cursor-msh_field_begin) - sizeof(int);
memcpy(msh_field_begin, &tmp, sizeof(int));
//Now set msh_size
msh_size = msh_cursor - msh_buffer;
MSH_SET_TOTALSIZE(msh_size); MSH_SET_TYPECHOICE(msh_typechoice);
}
void unmarshal4() {
//declare currentSize to be the size of this field
int msh_currentSize = 0;
//copy the size of the current field into currentSize
memcpy(&msh_currentSize, msh_cursor, sizeof(int));
msh_cursor += sizeof(int);
//Now copy the setspec here
{
G4int anElement;
memcpy(&anElement, msh_cursor, sizeof(G4int ));
param->SetChamberNb(anElement);
}
msh_cursor += msh_currentSize;
}
};
#endif
@@ -0,0 +1,162 @@
// This file was generated automatically by marshalgen.
#ifndef MarshaledG4HCofThisEvent_H
#define MarshaledG4HCofThisEvent_H
#include <G4HCofThisEvent.hh>
//MSH_include_begin
#include "G4SDManager.hh"
#include "G4THitsCollection.hh"
#include "ExN02TrackerHit.hh"
#include "MarshaledExN02TrackerHit.h"
#include "MarshaledG4THitsCollection.h"
#include "MarshaledG4VHitsCollection.h"
//MSH_include_end
#include <stdio.h>
#include <string.h>
#include "MarshaledObj.h"
class MarshaledG4HCofThisEvent;
class ShadowedMarshaledG4HCofThisEvent : public G4HCofThisEvent{
friend class MarshaledG4HCofThisEvent;
};
class MarshaledG4HCofThisEvent : public MarshaledObj {
public:
G4HCofThisEvent* param;
ShadowedMarshaledG4HCofThisEvent* Shadowed_param;
public:
// Function implementations
MarshaledG4HCofThisEvent(G4HCofThisEvent* objptr) : MarshaledObj() {
msh_isUnmarshalDone = false;
this->param = objptr;
this->Shadowed_param = (ShadowedMarshaledG4HCofThisEvent*)this->param;
if (objptr == NULL)
return;
marshal1();
}
MarshaledG4HCofThisEvent(void *buf, char isUnmarshaling = 'u')
: MarshaledObj(buf, isUnmarshaling) {
msh_isUnmarshalDone = false;
}
~MarshaledG4HCofThisEvent() {
//if(msh_isUnmarshalDone && this->param != NULL) {
//delete this->param;
//}
}
G4HCofThisEvent* unmarshal() {
//We don't want to unmarshal the buffer is empty.
if(msh_size <= MSH_HEADER_SIZE) {
//This is buggy, we can't always assume that
//obj == NULL <==> List is empty.
return NULL;
} else {
{
param = new G4HCofThisEvent();
}
this->Shadowed_param = (ShadowedMarshaledG4HCofThisEvent*)this->param;
this->msh_isUnmarshalDone = true;
unmarshal1();
return this->param;
}
}
void unmarshalTo(G4HCofThisEvent* obj) {
//We don't want to unmarshal the buffer is empty.
if(msh_size <= MSH_HEADER_SIZE) {
//This is buggy, we can't always assume that
//obj == NULL <==> List is empty.
return;
} else {
this->param = obj;
this->Shadowed_param = (ShadowedMarshaledG4HCofThisEvent*)this->param;
this->msh_isUnmarshalDone = true;
unmarshal1();
}
}
void marshal1() {
//declare field_size to be the size of this field
int msh_currentSize = 0;
if (isUnmarshaling())
throw "Tried to marshal in obj marked isUnmarshaling == true";
//Copy the sizespec into msh_currentSize here:
{
}
//Increase the size of buffer if needed
EXTEND_BUFFER(msh_currentSize + sizeof(int) + sizeof(int)); // 4 bytes for the total size of field, 4 bytes for the number of elements in the array (in the case of array marshaling)
//Mark the beginning position for this field, will write the total size of this field here later
msh_field_begin = msh_cursor;
//Advance cursor of distance = sizeof(int)
msh_cursor += sizeof(int);
//Now just copy "get" functions here
{
int copy_off = 0;
int elementNum;
elementNum = param->GetNumberOfCollections();
memcpy( msh_cursor+copy_off, &elementNum,sizeof(int));
copy_off += sizeof(int);
for(int index=0;index<elementNum;index++){
G4VHitsCollection* anElement;
anElement = param->GetHC(index);
MarshaledG4VHitsCollection marEle(anElement);
EXTEND_BUFFER(marEle.getBufferSize());
memcpy(msh_cursor+copy_off, marEle.getBuffer(), marEle.getBufferSize());
copy_off += marEle.getBufferSize();
}
msh_currentSize = copy_off;
}
//Now advance the cursor
msh_cursor += msh_currentSize;
//Now set the size of this field
int tmp; //use memcpy instead of *(int*)... =... to prevent bus error
tmp = (msh_cursor-msh_field_begin) - sizeof(int);
memcpy(msh_field_begin, &tmp, sizeof(int));
//Now set msh_size
msh_size = msh_cursor - msh_buffer;
MSH_SET_TOTALSIZE(msh_size); MSH_SET_TYPECHOICE(msh_typechoice);
}
void unmarshal1() {
//declare currentSize to be the size of this field
int msh_currentSize = 0;
//copy the size of the current field into currentSize
memcpy(&msh_currentSize, msh_cursor, sizeof(int));
msh_cursor += sizeof(int);
//Now copy the setspec here
{
int copy_off = 0;
int elementNum;
memcpy(&elementNum, msh_cursor+copy_off, sizeof(int));
copy_off += sizeof(int);
for(int index=0;index<elementNum;index++){
MarshaledG4VHitsCollection marEle(msh_cursor+copy_off);
G4VHitsCollection* anElement = (G4VHitsCollection*)marEle.unmarshal();
copy_off += marEle.getBufferSize();
param->AddHitsCollection(index, anElement);
}
}
msh_cursor += msh_currentSize;
}
};
#endif
@@ -0,0 +1,137 @@
// This file was generated automatically by marshalgen.
#ifndef MarshaledG4String_H
#define MarshaledG4String_H
#include <G4String.hh>
#include <stdio.h>
#include <string.h>
#include "MarshaledObj.h"
class MarshaledG4String;
class ShadowedMarshaledG4String : public G4String{
friend class MarshaledG4String;
};
class MarshaledG4String : public MarshaledObj {
public:
G4String* param;
ShadowedMarshaledG4String* Shadowed_param;
public:
// Function implementations
MarshaledG4String(G4String* objptr) : MarshaledObj() {
msh_isUnmarshalDone = false;
this->param = objptr;
this->Shadowed_param = (ShadowedMarshaledG4String*)this->param;
if (objptr == NULL)
return;
marshal1();
}
MarshaledG4String(void *buf, char isUnmarshaling = 'u')
: MarshaledObj(buf, isUnmarshaling) {
msh_isUnmarshalDone = false;
}
~MarshaledG4String() {
//if(msh_isUnmarshalDone && this->param != NULL) {
//delete this->param;
//}
}
G4String* unmarshal() {
//We don't want to unmarshal the buffer is empty.
if(msh_size <= MSH_HEADER_SIZE) {
//This is buggy, we can't always assume that
//obj == NULL <==> List is empty.
return NULL;
} else {
{
param = new G4String();
}
this->Shadowed_param = (ShadowedMarshaledG4String*)this->param;
this->msh_isUnmarshalDone = true;
unmarshal1();
return this->param;
}
}
void unmarshalTo(G4String* obj) {
//We don't want to unmarshal the buffer is empty.
if(msh_size <= MSH_HEADER_SIZE) {
//This is buggy, we can't always assume that
//obj == NULL <==> List is empty.
return;
} else {
this->param = obj;
this->Shadowed_param = (ShadowedMarshaledG4String*)this->param;
this->msh_isUnmarshalDone = true;
unmarshal1();
}
}
void marshal1() {
//declare field_size to be the size of this field
int msh_currentSize = 0;
if (isUnmarshaling())
throw "Tried to marshal in obj marked isUnmarshaling == true";
//Copy the sizespec into msh_currentSize here:
{
int size = param->size()+1;
while(size%8) size++;
msh_currentSize = size;
}
//Increase the size of buffer if needed
EXTEND_BUFFER(msh_currentSize + sizeof(int) + sizeof(int)); // 4 bytes for the total size of field, 4 bytes for the number of elements in the array (in the case of array marshaling)
//Mark the beginning position for this field, will write the total size of this field here later
msh_field_begin = msh_cursor;
//Advance cursor of distance = sizeof(int)
msh_cursor += sizeof(int);
//Now just copy "get" functions here
{
memcpy(msh_cursor, param->c_str(), param->size());
*(msh_cursor+param->size()) = '\0';
}
//Now advance the cursor
msh_cursor += msh_currentSize;
//Now set the size of this field
int tmp; //use memcpy instead of *(int*)... =... to prevent bus error
tmp = (msh_cursor-msh_field_begin) - sizeof(int);
memcpy(msh_field_begin, &tmp, sizeof(int));
//Now set msh_size
msh_size = msh_cursor - msh_buffer;
MSH_SET_TOTALSIZE(msh_size); MSH_SET_TYPECHOICE(msh_typechoice);
}
void unmarshal1() {
//declare currentSize to be the size of this field
int msh_currentSize = 0;
//copy the size of the current field into currentSize
memcpy(&msh_currentSize, msh_cursor, sizeof(int));
msh_cursor += sizeof(int);
//Now copy the setspec here
{
G4String* s = new G4String(msh_cursor);
memcpy(param, s, sizeof(G4String));
}
msh_cursor += msh_currentSize;
}
};
#endif
@@ -0,0 +1,279 @@
// This file was generated automatically by marshalgen.
#ifndef MarshaledG4HitsCollection_H
#define MarshaledG4HitsCollection_H
#include <G4THitsCollection.hh>
#include <stdio.h>
#include <string.h>
#include "MarshaledObj.h"
class MarshaledG4HitsCollection;
class ShadowedMarshaledG4HitsCollection : public G4HitsCollection{
friend class MarshaledG4HitsCollection;
};
template <class T> class MarshaledG4THitsCollection;
template <class T> class ShadowedMarshaledG4THitsCollection : public G4THitsCollection<T>{
friend class MarshaledG4THitsCollection<T>;
};
class MarshaledG4HitsCollection : public MarshaledObj {
public:
G4HitsCollection* param;
ShadowedMarshaledG4HitsCollection* Shadowed_param;
public:
// Function implementations
MarshaledG4HitsCollection(G4HitsCollection* objptr) : MarshaledObj() {
msh_isUnmarshalDone = false;
this->param = objptr;
this->Shadowed_param = (ShadowedMarshaledG4HitsCollection*)this->param;
if (objptr == NULL)
return;
marshal1();
}
MarshaledG4HitsCollection(void *buf, char isUnmarshaling = 'u')
: MarshaledObj(buf, isUnmarshaling) {
msh_isUnmarshalDone = false;
}
~MarshaledG4HitsCollection() {
//if(msh_isUnmarshalDone && this->param != NULL) {
//delete this->param;
//}
}
G4HitsCollection* unmarshal() {
//We don't want to unmarshal the buffer is empty.
if(msh_size <= MSH_HEADER_SIZE) {
//This is buggy, we can't always assume that
//obj == NULL <==> List is empty.
return NULL;
} else {
{
param = new G4HitsCollection();
}
this->Shadowed_param = (ShadowedMarshaledG4HitsCollection*)this->param;
this->msh_isUnmarshalDone = true;
unmarshal1();
return this->param;
}
}
void unmarshalTo(G4HitsCollection* obj) {
//We don't want to unmarshal the buffer is empty.
if(msh_size <= MSH_HEADER_SIZE) {
//This is buggy, we can't always assume that
//obj == NULL <==> List is empty.
return;
} else {
this->param = obj;
this->Shadowed_param = (ShadowedMarshaledG4HitsCollection*)this->param;
this->msh_isUnmarshalDone = true;
unmarshal1();
}
}
void marshal1() {
//declare field_size to be the size of this field
int msh_currentSize = 0;
if (isUnmarshaling())
throw "Tried to marshal in obj marked isUnmarshaling == true";
//Copy the sizespec into msh_currentSize here:
{
}
//Increase the size of buffer if needed
EXTEND_BUFFER(msh_currentSize + sizeof(int) + sizeof(int)); // 4 bytes for the total size of field, 4 bytes for the number of elements in the array (in the case of array marshaling)
//Mark the beginning position for this field, will write the total size of this field here later
msh_field_begin = msh_cursor;
//Advance cursor of distance = sizeof(int)
msh_cursor += sizeof(int);
//Now just copy "get" functions here
{
int copy_off = 0;
int elementNum;
elementNum = ((G4THitsCollection<ExN02TrackerHit>*)param)->entries();
memcpy( msh_cursor+copy_off, &elementNum,sizeof(int));
copy_off += sizeof(int);
for(int index=0;index<elementNum;index++){
ExN02TrackerHit* anElement;
anElement = (*((G4THitsCollection<ExN02TrackerHit>*)param))[index];
MarshaledExN02TrackerHit marEle(anElement);
EXTEND_BUFFER(marEle.getBufferSize());
memcpy(msh_cursor+copy_off, marEle.getBuffer(), marEle.getBufferSize());
copy_off += marEle.getBufferSize();
}
msh_currentSize = copy_off;
}
//Now advance the cursor
msh_cursor += msh_currentSize;
//Now set the size of this field
int tmp; //use memcpy instead of *(int*)... =... to prevent bus error
tmp = (msh_cursor-msh_field_begin) - sizeof(int);
memcpy(msh_field_begin, &tmp, sizeof(int));
//Now set msh_size
msh_size = msh_cursor - msh_buffer;
MSH_SET_TOTALSIZE(msh_size); MSH_SET_TYPECHOICE(msh_typechoice);
}
void unmarshal1() {
//declare currentSize to be the size of this field
int msh_currentSize = 0;
//copy the size of the current field into currentSize
memcpy(&msh_currentSize, msh_cursor, sizeof(int));
msh_cursor += sizeof(int);
//Now copy the setspec here
{
int copy_off = 0;
int elementNum;
memcpy(&elementNum, msh_cursor+copy_off, sizeof(int));
copy_off += sizeof(int);
for(int index=0;index<elementNum;index++){
MarshaledExN02TrackerHit marEle(msh_cursor+copy_off);
ExN02TrackerHit* anElement = (ExN02TrackerHit* )marEle.unmarshal();
copy_off += marEle.getBufferSize();
((G4THitsCollection<ExN02TrackerHit>*)param)->insert((ExN02TrackerHit*)anElement);
}
}
msh_cursor += msh_currentSize;
}
};
template <class T> class MarshaledG4THitsCollection : public MarshaledObj {
public:
G4THitsCollection<T>* param;
ShadowedMarshaledG4THitsCollection<T>* Shadowed_param;
public:
// Function implementations
MarshaledG4THitsCollection(G4THitsCollection<T>* objptr) : MarshaledObj() {
msh_isUnmarshalDone = false;
this->param = objptr;
this->Shadowed_param = (ShadowedMarshaledG4THitsCollection<T>*)this->param;
if (objptr == NULL)
return;
marshal1();
}
MarshaledG4THitsCollection(void *buf, char isUnmarshaling = 'u')
: MarshaledObj(buf, isUnmarshaling) {
msh_isUnmarshalDone = false;
}
~MarshaledG4THitsCollection() {
//if(msh_isUnmarshalDone && this->param != NULL) {
//delete this->param;
//}
}
G4THitsCollection<T>* unmarshal() {
//We don't want to unmarshal the buffer is empty.
if(msh_size <= MSH_HEADER_SIZE) {
//This is buggy, we can't always assume that
//obj == NULL <==> List is empty.
return NULL;
} else {
{
param = new G4THitsCollection<T>();
}
this->Shadowed_param = (ShadowedMarshaledG4THitsCollection<T>*)this->param;
this->msh_isUnmarshalDone = true;
unmarshal1();
return this->param;
}
}
void unmarshalTo(G4THitsCollection<T>* obj) {
//We don't want to unmarshal the buffer is empty.
if(msh_size <= MSH_HEADER_SIZE) {
//This is buggy, we can't always assume that
//obj == NULL <==> List is empty.
return;
} else {
this->param = obj;
this->Shadowed_param = (ShadowedMarshaledG4THitsCollection<T>*)this->param;
this->msh_isUnmarshalDone = true;
unmarshal1();
}
}
void marshal1() {
//declare field_size to be the size of this field
int msh_currentSize = 0;
if (isUnmarshaling())
throw "Tried to marshal in obj marked isUnmarshaling == true";
//Copy the sizespec into msh_currentSize here:
{
//code for size, just dummy code because the size will be set correctly at the end of marshaling code
}
//Increase the size of buffer if needed
EXTEND_BUFFER(msh_currentSize + sizeof(int) + sizeof(int)); // 4 bytes for the total size of field, 4 bytes for the number of elements in the array (in the case of array marshaling)
//Mark the beginning position for this field, will write the total size of this field here later
msh_field_begin = msh_cursor;
//Advance cursor of distance = sizeof(int)
msh_cursor += sizeof(int);
//Now just copy "get" functions here
{
MarshaledG4HitsCollection marParent(param);
EXTEND_BUFFER(marParent.getBufferSize());
memcpy(msh_cursor,marParent.getBuffer(), marParent.getBufferSize());
msh_currentSize = marParent.getBufferSize();
}
//Now advance the cursor
msh_cursor += msh_currentSize;
//Now set the size of this field
int tmp; //use memcpy instead of *(int*)... =... to prevent bus error
tmp = (msh_cursor-msh_field_begin) - sizeof(int);
memcpy(msh_field_begin, &tmp, sizeof(int));
//Now set msh_size
msh_size = msh_cursor - msh_buffer;
MSH_SET_TOTALSIZE(msh_size); MSH_SET_TYPECHOICE(msh_typechoice);
}
void unmarshal1() {
//declare currentSize to be the size of this field
int msh_currentSize = 0;
//copy the size of the current field into currentSize
memcpy(&msh_currentSize, msh_cursor, sizeof(int));
msh_cursor += sizeof(int);
//Now copy the setspec here
{
MarshaledG4HitsCollection marObj(msh_cursor);
marObj.unmarshalTo(param);
}
msh_cursor += msh_currentSize;
}
};
#endif
@@ -0,0 +1,262 @@
// This file was generated automatically by marshalgen.
#ifndef MarshaledG4VHitsCollection_H
#define MarshaledG4VHitsCollection_H
#include <G4VHitsCollection.hh>
#include <stdio.h>
#include <string.h>
#include "MarshaledObj.h"
class MarshaledG4VHitsCollection;
class ShadowedMarshaledG4VHitsCollection : public G4VHitsCollection{
friend class MarshaledG4VHitsCollection;
};
class MarshaledG4VHitsCollection : public MarshaledObj {
public:
G4VHitsCollection* param;
ShadowedMarshaledG4VHitsCollection* Shadowed_param;
public:
// Function implementations
MarshaledG4VHitsCollection(G4VHitsCollection* objptr) : MarshaledObj() {
msh_isUnmarshalDone = false;
this->param = objptr;
this->Shadowed_param = (ShadowedMarshaledG4VHitsCollection*)this->param;
if (objptr == NULL)
return;
marshal1();
marshal2();
marshal3();
}
MarshaledG4VHitsCollection(void *buf, char isUnmarshaling = 'u')
: MarshaledObj(buf, isUnmarshaling) {
msh_isUnmarshalDone = false;
}
~MarshaledG4VHitsCollection() {
//if(msh_isUnmarshalDone && this->param != NULL) {
//delete this->param;
//}
}
G4VHitsCollection* unmarshal() {
//We don't want to unmarshal the buffer is empty.
if(msh_size <= MSH_HEADER_SIZE) {
//This is buggy, we can't always assume that
//obj == NULL <==> List is empty.
return NULL;
} else {
{
param = new G4THitsCollection<ExN02TrackerHit>("","");
}
this->Shadowed_param = (ShadowedMarshaledG4VHitsCollection*)this->param;
this->msh_isUnmarshalDone = true;
unmarshal1();
unmarshal2();
unmarshal3();
return this->param;
}
}
void unmarshalTo(G4VHitsCollection* obj) {
//We don't want to unmarshal the buffer is empty.
if(msh_size <= MSH_HEADER_SIZE) {
//This is buggy, we can't always assume that
//obj == NULL <==> List is empty.
return;
} else {
this->param = obj;
this->Shadowed_param = (ShadowedMarshaledG4VHitsCollection*)this->param;
this->msh_isUnmarshalDone = true;
unmarshal1();
unmarshal2();
unmarshal3();
}
}
void marshal1() {
//declare field_size to be the size of this field
int msh_currentSize = 0;
if (isUnmarshaling())
throw "Tried to marshal in obj marked isUnmarshaling == true";
//Copy the sizespec into msh_currentSize here:
{
// no need to declare size since msh_currentSize is already assigned in the MARSHAL field
}
//Increase the size of buffer if needed
EXTEND_BUFFER(msh_currentSize + sizeof(int) + sizeof(int)); // 4 bytes for the total size of field, 4 bytes for the number of elements in the array (in the case of array marshaling)
//Mark the beginning position for this field, will write the total size of this field here later
msh_field_begin = msh_cursor;
//Advance cursor of distance = sizeof(int)
msh_cursor += sizeof(int);
//Now just copy "get" functions here
{
G4String anElement;
anElement = param->GetName();
MarshaledG4String var(&anElement);
EXTEND_BUFFER(var.getBufferSize());
msh_currentSize = var.getBufferSize();
memcpy(msh_cursor, var.getBuffer(), var.getBufferSize());
}
//Now advance the cursor
msh_cursor += msh_currentSize;
//Now set the size of this field
int tmp; //use memcpy instead of *(int*)... =... to prevent bus error
tmp = (msh_cursor-msh_field_begin) - sizeof(int);
memcpy(msh_field_begin, &tmp, sizeof(int));
//Now set msh_size
msh_size = msh_cursor - msh_buffer;
MSH_SET_TOTALSIZE(msh_size); MSH_SET_TYPECHOICE(msh_typechoice);
}
void unmarshal1() {
//declare currentSize to be the size of this field
int msh_currentSize = 0;
//copy the size of the current field into currentSize
memcpy(&msh_currentSize, msh_cursor, sizeof(int));
msh_cursor += sizeof(int);
//Now copy the setspec here
{
MarshaledG4String var(msh_cursor, 'u');
G4String anElement;
var.unmarshalTo(&anElement);
Shadowed_param->collectionName=anElement;
}
msh_cursor += msh_currentSize;
}
void marshal2() {
//declare field_size to be the size of this field
int msh_currentSize = 0;
if (isUnmarshaling())
throw "Tried to marshal in obj marked isUnmarshaling == true";
//Copy the sizespec into msh_currentSize here:
{
// no need to declare size since msh_currentSize is already assigned in the MARSHAL field
}
//Increase the size of buffer if needed
EXTEND_BUFFER(msh_currentSize + sizeof(int) + sizeof(int)); // 4 bytes for the total size of field, 4 bytes for the number of elements in the array (in the case of array marshaling)
//Mark the beginning position for this field, will write the total size of this field here later
msh_field_begin = msh_cursor;
//Advance cursor of distance = sizeof(int)
msh_cursor += sizeof(int);
//Now just copy "get" functions here
{
G4String anElement;
anElement = param->GetSDname();
MarshaledG4String var(&anElement);
EXTEND_BUFFER(var.getBufferSize());
msh_currentSize = var.getBufferSize();
memcpy(msh_cursor, var.getBuffer(), var.getBufferSize());
}
//Now advance the cursor
msh_cursor += msh_currentSize;
//Now set the size of this field
int tmp; //use memcpy instead of *(int*)... =... to prevent bus error
tmp = (msh_cursor-msh_field_begin) - sizeof(int);
memcpy(msh_field_begin, &tmp, sizeof(int));
//Now set msh_size
msh_size = msh_cursor - msh_buffer;
MSH_SET_TOTALSIZE(msh_size); MSH_SET_TYPECHOICE(msh_typechoice);
}
void unmarshal2() {
//declare currentSize to be the size of this field
int msh_currentSize = 0;
//copy the size of the current field into currentSize
memcpy(&msh_currentSize, msh_cursor, sizeof(int));
msh_cursor += sizeof(int);
//Now copy the setspec here
{
MarshaledG4String var(msh_cursor, 'u');
G4String anElement;
var.unmarshalTo(&anElement);
Shadowed_param->SDname=anElement;
}
msh_cursor += msh_currentSize;
}
void marshal3() {
//declare field_size to be the size of this field
int msh_currentSize = 0;
if (isUnmarshaling())
throw "Tried to marshal in obj marked isUnmarshaling == true";
//Copy the sizespec into msh_currentSize here:
{
//code for size, just dummy code because the size will be set correctly at the end of marshaling code
}
//Increase the size of buffer if needed
EXTEND_BUFFER(msh_currentSize + sizeof(int) + sizeof(int)); // 4 bytes for the total size of field, 4 bytes for the number of elements in the array (in the case of array marshaling)
//Mark the beginning position for this field, will write the total size of this field here later
msh_field_begin = msh_cursor;
//Advance cursor of distance = sizeof(int)
msh_cursor += sizeof(int);
//Now just copy "get" functions here
{
G4THitsCollection<ExN02TrackerHit> *aObj100 = (G4THitsCollection<ExN02TrackerHit>*)param;
MarshaledG4THitsCollection<ExN02TrackerHit> marChild(aObj100);
EXTEND_BUFFER(marChild.getBufferSize());
memcpy(msh_cursor,marChild.getBuffer(), marChild.getBufferSize());
msh_currentSize = marChild.getBufferSize();
msh_typechoice = 0;
}
//Now advance the cursor
msh_cursor += msh_currentSize;
//Now set the size of this field
int tmp; //use memcpy instead of *(int*)... =... to prevent bus error
tmp = (msh_cursor-msh_field_begin) - sizeof(int);
memcpy(msh_field_begin, &tmp, sizeof(int));
//Now set msh_size
msh_size = msh_cursor - msh_buffer;
MSH_SET_TOTALSIZE(msh_size); MSH_SET_TYPECHOICE(msh_typechoice);
}
void unmarshal3() {
//declare currentSize to be the size of this field
int msh_currentSize = 0;
//copy the size of the current field into currentSize
memcpy(&msh_currentSize, msh_cursor, sizeof(int));
msh_cursor += sizeof(int);
//Now copy the setspec here
{
MarshaledG4THitsCollection<ExN02TrackerHit> marObj(msh_cursor);
marObj.unmarshalTo((G4THitsCollection<ExN02TrackerHit>*)param);
}
msh_cursor += msh_currentSize;
}
};
#endif
@@ -0,0 +1,203 @@
/**********************************************************************
* Parallel Library for Geant4 *
* Copyright (c) 2001 Gene Cooperman <gene@ccs.neu.edu> *
* *
* This library is free software distributed under the GNU *
* Lesser General Public License. See the file COPYING for details. *
**********************************************************************/
#ifndef PARMARSHALEDOBJ_H
#define PARMARSHALEDOBJ_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#define MSH_ASSERT(X) {assert(X);}
#define MSH_HEADER_SIZE (sizeof(int)*2)
// the first field (first sizeof(int) bytes) contains the $TYPE_CHOICE
// the second field contains the size including the header
#define MSH_TOTALSIZE_OFFSET (sizeof(int))
#define MSH_TYPECHOICE_OFFSET 0
#define MSH_SET_TYPECHOICE(X) { memcpy(msh_buffer+MSH_TYPECHOICE_OFFSET,&(X),sizeof(int));}
#define MSH_SET_TOTALSIZE(X) { memcpy(msh_buffer+MSH_TOTALSIZE_OFFSET,&(X),sizeof(int));}
#define MSH_GET_TYPECHOICE(X,BUF) { memcpy(&(X), ((char*)BUF)+MSH_TYPECHOICE_OFFSET,sizeof(int));}
#define MSH_GET_TOTALSIZE(X,BUF) { memcpy(&(X), ((char*)BUF)+MSH_TOTALSIZE_OFFSET,sizeof(int));}
class MarshaledObj {
private:
// Make sure all marshaled objects are word aligned.
static const int WORD_SIZE = sizeof(long);
public:
static int ROUND_UP( int x ){
return (((x)+(WORD_SIZE-1)) / WORD_SIZE) * WORD_SIZE;
}
public:
// Constructs an empty MarshaledObj,
MarshaledObj(){
msh_extent = 128;
msh_size = MSH_HEADER_SIZE;
msh_isUnmarshalDone = false;
msh_buffer = (char *)malloc(msh_extent);
MSH_ASSERT(msh_buffer);
msh_cursor = msh_buffer + MSH_HEADER_SIZE;
msh_field_begin = msh_cursor;
msh_typechoice = 0;
int totalsize = msh_cursor-msh_buffer;
MSH_SET_TYPECHOICE(msh_typechoice);
MSH_SET_TOTALSIZE(totalsize);
}
//MarshaledObj(void *buf);
// This constructs a MarshledObj from a buffer (of type char*) for unmarshaling.
// buf is obtain from an already marshaled object.
// The first field of buf must be an int that contains the size of the buf
// NOT including itself.
// isUnmarshaling must be 'u' (for unmarshaling) .
MarshaledObj(void *buf, char isUnmarshaling) {
msh_isUnmarshalDone = false;
if(isUnmarshaling != 'u') {
printf("MarshaledObj(void*, char): wrong argument\n");
return;
}
//msh_extent = ROUND_UP(*(int *)buf + sizeof(int));
MSH_GET_TYPECHOICE(msh_typechoice,buf);
MSH_GET_TOTALSIZE(msh_size,buf);
msh_extent = ROUND_UP(msh_size);
msh_buffer = (char *)malloc(msh_extent);
MSH_ASSERT(msh_buffer);
memcpy(msh_buffer, (char *)buf, msh_extent);
msh_cursor = msh_buffer + MSH_HEADER_SIZE;
msh_field_begin = msh_cursor;
//MSH_SET_TYPECHOICE(msh_typechoice);
}
~MarshaledObj() {
if ( ! isUnmarshaling() )
free(msh_buffer);
}
inline bool isUnmarshaling() {
return (msh_extent <= 0);
}
private:
// Dont use copy constructor
const MarshaledObj& operator=(const MarshaledObj& right);
protected:
int msh_typechoice; // alias of $TYPE_CHOICE
// points to the buffer (header+body)
char *msh_buffer;
// msh_field_begin points to the size of the current field being marshaled
char* msh_field_begin;
// msh_size contains the total size of msh_buffer. i.e.,
int msh_size;
// msh_cursor points to the next field to be marshaled.
char *msh_cursor;
// msh_extent is the total allocated space for msh_buffer.
// msh_extent is always >= msh_size
int msh_extent;
bool msh_isUnmarshalDone; //Is unmarshaling done yet?
public:
inline void EXTEND_BUFFER(int size){
msh_size += size;
if(msh_size > msh_extent){
resizeBuffer(msh_size);
}
}
void resizeBuffer(int new_size ) {
int msh_displacement = msh_cursor - msh_buffer;
int field_displacement = msh_field_begin - msh_buffer;
while(new_size > msh_extent)
msh_extent *= 2;
msh_buffer = (char *)realloc( msh_buffer, msh_extent);
MSH_ASSERT(msh_buffer);
msh_cursor = msh_buffer + msh_displacement;
msh_field_begin = msh_buffer + field_displacement;
}
public:
// Returns the total size of buffer
inline int getBufferSize() {
return msh_size;
}
inline char *getBuffer() {
return msh_buffer;
}
/* p: pointer to the data field, size: size of that primitive data field */
void marshalPrimitive(void* p, int size) {
int msh_currentSize;
if (isUnmarshaling())
throw "Tried to marshal in object marked isUnmarshaling = true";
msh_currentSize = size;
EXTEND_BUFFER(msh_currentSize + sizeof(int));
// *(int *)msh_cursor = msh_currentSize;
memcpy(msh_cursor, &msh_currentSize, sizeof(int));
msh_cursor += sizeof(int);
memcpy(msh_cursor, p, size);
msh_cursor += msh_currentSize;
msh_size = msh_cursor - msh_buffer;
MSH_SET_TOTALSIZE(msh_size);
}
void unmarshalPrimitive(void* p, int size) {
int msh_currentSize;
//memcpy(&msh_currentSize, msh_cursor, sizeof(int));
/* in case *msh_cursor is invalid, use "size" not to crash the memory */
msh_currentSize = size;
msh_cursor += sizeof(int);
memcpy(p, msh_cursor, msh_currentSize);
msh_cursor += msh_currentSize;
//msh_size = msh_cursor - msh_buffer;
}
};
/* Used for distinguish the class types of the template parameter
vietha 2003.05.01 */
template <class T,class>
class MSH_IsSameClass
{
public:
enum {Is = 0};
};
template<class T>
class MSH_IsSameClass<T,T>
{
public:
enum {Is = 1};
};
#endif
@@ -1,149 +0,0 @@
//
// ********************************************************************
// * 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-05-02-patch-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
@@ -1,278 +0,0 @@
//
// ********************************************************************
// * 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-05-02-patch-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
@@ -1,85 +0,0 @@
//
// ********************************************************************
// * 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.2 2003/07/04 15:36:51 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-02-patch-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, 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
@@ -21,7 +21,7 @@
// ********************************************************************
//
// $Id: ParRunManager.hh,v 1.2 2002/06/06 17:05:02 cooperma Exp $
// GEANT4 tag $Name: geant4-05-02-patch-01 $
// GEANT4 tag $Name: geant4-07-00-cand-01 $
//
// --------------------------------------------------------------------
// Parallel Library for Geant4