Import Geant4 4.1.0 source tree
This commit is contained in:
@@ -0,0 +1,318 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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: G4GeoNav.cc,v 1.1 2002/06/04 07:40:20 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-01 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
// G4GeoNav
|
||||
//
|
||||
// Author: Martin Liendl - Martin.Liendl@cern.ch
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
//
|
||||
#include "G4GeoNav.hh"
|
||||
|
||||
G4GeoNav::G4GeoNav( G4LogicalVolume * rv )
|
||||
: theLVTree(new LVTree(rv))
|
||||
{
|
||||
theCurLV = theLVTree->root();
|
||||
theRootLV = theLVTree->root();
|
||||
RecursiveFill(theLVTree->root());
|
||||
}
|
||||
|
||||
G4GeoNav::~G4GeoNav()
|
||||
{}
|
||||
|
||||
|
||||
G4LogicalVolume * G4GeoNav::NextLV()
|
||||
{
|
||||
//FIXME: G4GeoNav::NextLV()
|
||||
|
||||
TreeNodeIterator<G4LogicalVolume*> tni(theCurLV);
|
||||
|
||||
G4LogicalVolume * v = 0;
|
||||
if (tni.next()) {
|
||||
v = tni.current()->data();
|
||||
theCurLV = tni.current();
|
||||
}
|
||||
return v;
|
||||
/*
|
||||
G4cerr << "DON'T CALL G4GeoNav::Next()!" << endl;
|
||||
exit(1);
|
||||
return 0;
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
G4int G4GeoNav::FilterLV(const G4String & aRegexStr,
|
||||
G4std::vector<G4LogicalVolume*> & result,
|
||||
G4bool stopAtFirst)
|
||||
{
|
||||
regex_t aRegex;
|
||||
const char * aRegexCStr = aRegexStr.data();
|
||||
if (regcomp(&aRegex,aRegexCStr,0)) {
|
||||
G4cerr << "failed to interpret regex-string" << G4endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
LVTree::node_t * aNode = theLVTree->root();
|
||||
FindLV(&aRegex,aNode,result,stopAtFirst);
|
||||
regfree(&aRegex);
|
||||
return result.size();
|
||||
}
|
||||
|
||||
|
||||
void G4GeoNav::FindLV(regex_t * aRegex, LVTree::node_t * node,
|
||||
G4std::vector<G4LogicalVolume*>& result,
|
||||
G4bool stopAtFirst)
|
||||
{
|
||||
if( !regexec(aRegex, node->data()->GetName().data(), 0,0,0))
|
||||
{
|
||||
result.push_back(node->data());
|
||||
if (stopAtFirst)
|
||||
{
|
||||
theCurLV = node;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
LVTree::node_t * i = node->firstChild();
|
||||
while(i) { // recursive
|
||||
FindLV(aRegex, i, result, stopAtFirst);
|
||||
i = i->nextSibling();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
G4int G4GeoNav::PathLV(G4std::vector<G4LogicalVolume*> & result)
|
||||
{
|
||||
result.push_back(theCurLV->data());
|
||||
G4int level=1;
|
||||
LVTree::node_t * node = theCurLV;
|
||||
while (node->parent())
|
||||
{
|
||||
node = node->parent();
|
||||
G4LogicalVolume * aLV = node->data();
|
||||
result.push_back(aLV);
|
||||
level++;
|
||||
}
|
||||
return level;
|
||||
}
|
||||
|
||||
|
||||
G4int G4GeoNav::Tokenize(const G4String & aStr,
|
||||
G4std::vector<G4String>& tokens)
|
||||
{
|
||||
G4String::size_type c = aStr.size();
|
||||
G4String::size_type idx = 0;
|
||||
G4String::size_type idx2 = 0;
|
||||
|
||||
// empty string means 'root'
|
||||
if (!c)
|
||||
{
|
||||
tokens.push_back("/");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// scan for '/'
|
||||
G4std::vector<G4int> pos;
|
||||
pos.push_back(0); // begin of input
|
||||
G4String sep("/");
|
||||
|
||||
if (aStr[idx]==sep[idx])
|
||||
tokens.push_back("/");
|
||||
|
||||
G4String curStr = aStr; // G4String("-") ;
|
||||
|
||||
G4String::size_type i=0;
|
||||
for (i=0; i<c; i++) {
|
||||
idx = i;
|
||||
if(curStr[idx]==sep[idx2]) {
|
||||
#ifdef QT_DEBUG_3
|
||||
G4cout << i << " " << curStr[i] << G4endl;
|
||||
#endif
|
||||
pos.push_back(i);
|
||||
}
|
||||
}
|
||||
pos.push_back(c-1); // end of input
|
||||
|
||||
#ifdef QT_DEBUG_3
|
||||
for (G4int i=0; i<pos.size(); i++ )
|
||||
G4cout << pos[i] << " ";
|
||||
G4cout << G4endl;
|
||||
#endif
|
||||
|
||||
for (i=1; i<pos.size(); i++)
|
||||
{
|
||||
G4String newString;
|
||||
|
||||
for(G4int j=pos[i-1]; j<=pos[i]; j++) {
|
||||
idx = j;
|
||||
if (curStr[idx]!=sep[idx2])
|
||||
newString.append(curStr[idx]);
|
||||
}
|
||||
if (newString.size())
|
||||
tokens.push_back(newString);
|
||||
}
|
||||
|
||||
#ifdef QT_DEBUG
|
||||
for (G4int i=0; i<tokens.size(); i++)
|
||||
G4cout << "tok " << i << " " << tokens[i] << G4endl;
|
||||
#endif
|
||||
|
||||
return tokens.size();
|
||||
}
|
||||
|
||||
|
||||
G4LogicalVolume * G4GeoNav::ChangeLV(const G4String & aRegExp)
|
||||
{
|
||||
G4std::vector<G4String> tokens;
|
||||
G4int c = Tokenize(aRegExp,tokens);
|
||||
|
||||
LVTree::node_t * anItem = theCurLV;
|
||||
LVTree::node_t * anItemBefore = theCurLV;
|
||||
if (c) {
|
||||
|
||||
G4std::vector<G4String>::iterator it = tokens.begin();
|
||||
if (*it==G4String("/"))
|
||||
{ // absolute or relative
|
||||
anItem = theRootLV;
|
||||
it++;
|
||||
}
|
||||
|
||||
while ( it != tokens.end() )
|
||||
{
|
||||
//regex_t aRegex;
|
||||
if (*it == G4String(".."))
|
||||
{
|
||||
anItem = anItem->parent();
|
||||
if (!anItem) {
|
||||
G4cerr << "not found!" << G4endl;
|
||||
return 0;
|
||||
}
|
||||
it++;
|
||||
}
|
||||
else
|
||||
{
|
||||
regex_t aRegex;
|
||||
const char * aRegexCStr = (*it).data();
|
||||
if (regcomp(&aRegex,aRegexCStr,0))
|
||||
{
|
||||
G4cerr << "failed to interpret regex-string" << G4endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
G4int children = anItem->childCount();
|
||||
|
||||
if (!children)
|
||||
{
|
||||
G4cerr << "not found!!" << G4endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//LVTree::node_t * temp = *(anItem->firstChild());
|
||||
//anItem = temp;
|
||||
|
||||
// loop over children
|
||||
LVTree::node_t * u= anItem->firstChild();
|
||||
G4bool found=false;
|
||||
while (u)
|
||||
{
|
||||
if ( !regexec(&aRegex, u->data()->GetName().data(),0,0,0))
|
||||
{
|
||||
found=true;
|
||||
anItem = u;
|
||||
break;
|
||||
}
|
||||
u = u->nextSibling();
|
||||
}
|
||||
|
||||
regfree(&aRegex);
|
||||
if (!found)
|
||||
{
|
||||
G4cerr << "not found!!!!" << G4endl;
|
||||
return 0;
|
||||
}
|
||||
it++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (anItem!=anItemBefore)
|
||||
{
|
||||
theCurLV=anItem;
|
||||
return anItem->data();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
G4int G4GeoNav::PwdLV(G4std::vector<G4LogicalVolume *>& result)
|
||||
{
|
||||
result.push_back(theCurLV->data());
|
||||
LVTree::node_t * temp = theCurLV;
|
||||
while (temp->parent())
|
||||
{
|
||||
temp = temp->parent();
|
||||
result.push_back(temp->data());
|
||||
}
|
||||
return result.size();
|
||||
}
|
||||
|
||||
|
||||
void G4GeoNav::RecursiveFill(LVTree::node_t* node)
|
||||
{
|
||||
G4LogicalVolume * lv = node->data();
|
||||
|
||||
G4std::set<G4LogicalVolume*> lvset;
|
||||
|
||||
for ( G4int i=0; i<lv->GetNoDaughters(); ++i)
|
||||
{
|
||||
lvset.insert(lv->GetDaughter(i)->GetLogicalVolume());
|
||||
}
|
||||
|
||||
G4std::set<G4LogicalVolume*>::iterator it = lvset.begin();
|
||||
for(;it!=lvset.end();++it)
|
||||
{
|
||||
LVTree::node_t * newnode = new LVTree::node_t(node, *it);
|
||||
//create new node '*it' in parent 'node'
|
||||
RecursiveFill(newnode);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
G4int G4GeoNav::LsLV(G4std::vector<G4LogicalVolume *>& result)
|
||||
{
|
||||
G4int c=0;
|
||||
LVTree::node_t * n = theCurLV->firstChild();
|
||||
while(n)
|
||||
{
|
||||
result.push_back(n->data());
|
||||
n = n->nextSibling();
|
||||
c++;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
@@ -0,0 +1,631 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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: OlapDetConstr.cc,v 1.1 2002/06/04 07:40:20 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-01 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
// OlapDetConstr
|
||||
//
|
||||
// Author: Martin Liendl - Martin.Liendl@cern.ch
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
//
|
||||
#include "OlapDetConstr.hh"
|
||||
#include "OlapGenerator.hh"
|
||||
|
||||
#include "SolidAnalyser.hh"
|
||||
#include "OlapManager.hh"
|
||||
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4VVisManager.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "G4PVReplica.hh"
|
||||
#include "G4PVParameterised.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4VisExtent.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "G4LogicalVolumeStore.hh"
|
||||
#include "G4Box.hh"
|
||||
#include "G4Polyline.hh"
|
||||
#include "G4Polycone.hh"
|
||||
#include "G4Polyhedra.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
|
||||
// debugging:
|
||||
//#define OLAPDEBUG1
|
||||
//#define OlapDetConstr_debug
|
||||
|
||||
OlapDetConstr::OlapDetConstr(G4VUserDetectorConstruction * aGeometry,
|
||||
G4VPhysicalVolume *aWorld) :
|
||||
theTheta(0),
|
||||
thePhi(0),
|
||||
theAlpha(0),
|
||||
theNewWorldRot(0),
|
||||
theFullGeometry(aGeometry),
|
||||
theWorld(aWorld),
|
||||
theNewWorld(0),
|
||||
theNewLV(0),
|
||||
theNewWorldBox(new G4Box("world",1.,1.,1.)),
|
||||
syncVis(true),
|
||||
nrLV(0)
|
||||
{
|
||||
//theNewWorldLV = new G4LogicalVolume
|
||||
visMother = new G4VisAttributes(G4Colour(7.0, 0.0, 0.0, 0.4)); // red
|
||||
visMother->SetForceWireframe(true);
|
||||
visDaughterA = new G4VisAttributes(G4Colour(.0, 0.0, 1.0, 0.3)); // blue
|
||||
visDaughterA->SetForceWireframe(false);
|
||||
visDaughterB = new G4VisAttributes(G4Colour(0., 0., 1.0, 0.3)); // light-blue
|
||||
visDaughterB->SetForceWireframe(false);
|
||||
visWorld = new G4VisAttributes(G4Colour(1., 0, 0, 1.)); // red
|
||||
visWorld->SetForceWireframe(false);
|
||||
visWorld->SetVisibility(true);
|
||||
|
||||
visFullWorld = new G4VisAttributes(G4Colour(1.,1.,1.,0.9));
|
||||
visFullWorld->SetForceWireframe(true);
|
||||
visWorld->SetVisibility(false);
|
||||
|
||||
visInvisible = new G4VisAttributes(G4Colour(1.,1.,1.,0.9));
|
||||
visInvisible->SetForceWireframe(true);
|
||||
visInvisible->SetVisibility(false);
|
||||
|
||||
visFirstLevel = new G4VisAttributes(G4Colour(1.,1.,1,1));
|
||||
visFirstLevel->SetForceWireframe(true);
|
||||
visFirstLevel->SetVisibility(true);
|
||||
}
|
||||
|
||||
|
||||
OlapDetConstr::~OlapDetConstr()
|
||||
{
|
||||
//delete theNewWorld;
|
||||
//delete theNewLV; not the owner!
|
||||
//delete theFullGeometry;
|
||||
//delete visMother;
|
||||
//delete visDaughterA;
|
||||
//delete visDaughterB;
|
||||
//delete visWorld;
|
||||
|
||||
//delete visFullWorld;
|
||||
//delete visInvisible;
|
||||
//delete visFirstLevel;
|
||||
}
|
||||
|
||||
|
||||
void OlapDetConstr::SetRotation(G4double t, G4double p, G4double a)
|
||||
{
|
||||
theTheta = t;
|
||||
thePhi = p;
|
||||
theAlpha = a;
|
||||
}
|
||||
|
||||
|
||||
G4VPhysicalVolume * OlapDetConstr::Construct()
|
||||
{
|
||||
if (!theWorld)
|
||||
theWorld = theFullGeometry->Construct();
|
||||
if (!theWorld)
|
||||
{
|
||||
G4cerr << "OlapDetConstr::Construct(): could not create full world." << G4endl;
|
||||
G4cerr << " exiting ..." << G4endl;
|
||||
G4Exception("ERROR - OlapDetConstr::Construct()");
|
||||
}
|
||||
|
||||
// logical volume which will have a box with its dimensions derived from
|
||||
// the extent of the 'new-mother' volume positioned inside
|
||||
// the size of this NewWorld will be set in 'SetNewWorld(..)'
|
||||
theNewWorldLV =
|
||||
new G4LogicalVolume(theNewWorldBox,
|
||||
theWorld->GetLogicalVolume()->GetMaterial(),
|
||||
"NewWorld"
|
||||
);
|
||||
|
||||
// physical volume which will serve as the 'small' NewWorld to be
|
||||
// used for overlap checking
|
||||
theNewWorld =
|
||||
new G4PVPlacement( 0, // rotation
|
||||
G4ThreeVector(), // translation
|
||||
"NewWorld", // name of phys = name of logical!!!
|
||||
theNewWorldLV, // own logical vol
|
||||
0, false, 0 // no mother, not MANY, cpNr=0
|
||||
);
|
||||
|
||||
theNewWorldLV->SetVisAttributes(visWorld);
|
||||
|
||||
//ResetColors();
|
||||
|
||||
|
||||
theNewLV = theWorld->GetLogicalVolume();
|
||||
nrLV = G4LogicalVolumeStore::GetInstance()->size();
|
||||
G4cout << "OlapDetConstr::Construct(): nr of lvs=" << nrLV << G4endl;
|
||||
return theWorld;
|
||||
}
|
||||
|
||||
|
||||
G4VPhysicalVolume * OlapDetConstr::SetNewWorld(G4LogicalVolume * aMotherLV,
|
||||
G4bool debugFlag)
|
||||
{
|
||||
if (debugFlag)
|
||||
{
|
||||
G4cout << "mother: " << aMotherLV->GetName() << " : "
|
||||
<< aMotherLV->GetSolid()->GetName() << G4endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//ML: ResetColors(theNewLV);
|
||||
theNewLV = aMotherLV;
|
||||
|
||||
ConstructNewWorld();
|
||||
|
||||
// set new world to Geant4-Kernel
|
||||
G4RunManager::GetRunManager()->DefineWorldVolume(theNewWorld);
|
||||
|
||||
// try to set the OlapGenerator
|
||||
const OlapGenerator * aGen = dynamic_cast<const OlapGenerator *>
|
||||
(G4RunManager::GetRunManager()->GetUserPrimaryGeneratorAction());
|
||||
if ( aGen )
|
||||
{
|
||||
OlapGenerator * aNonConstGen = const_cast<OlapGenerator*>(aGen);
|
||||
|
||||
// 'optimal' extent
|
||||
// aNonConstGen->SetExtent(theNewLV->GetSolid()->GetExtent());
|
||||
|
||||
// extent which allows arbitrary rotations ...
|
||||
G4Box * bx = dynamic_cast<G4Box*>
|
||||
(theNewWorld->GetLogicalVolume()->GetSolid());
|
||||
aNonConstGen->SetExtent(2.*bx->GetXHalfLength());
|
||||
}
|
||||
else
|
||||
{
|
||||
G4cerr << "Warning: Primary generator is not OlapGenerator!" << G4endl
|
||||
<< "Overlap Detection will not work!" << G4endl;
|
||||
}
|
||||
return theNewWorld;
|
||||
}
|
||||
|
||||
|
||||
G4VPhysicalVolume * OlapDetConstr::GetNewWorld()
|
||||
{
|
||||
return theNewWorld;
|
||||
}
|
||||
|
||||
|
||||
G4VPhysicalVolume * OlapDetConstr::GetFullWorld()
|
||||
{
|
||||
return theWorld;
|
||||
}
|
||||
|
||||
|
||||
void OlapDetConstr::DrawPolyOutline()
|
||||
{
|
||||
SolidAnalyser::GetSolidAnalyser();
|
||||
G4VSolid * solid = theNewLV->GetSolid();
|
||||
G4Polyline line, endline;
|
||||
G4double ex(0), first_r(0), first_z(0);
|
||||
G4double maxz(0), maxr(0);
|
||||
G4int nr(0);
|
||||
G4Polycone * s = dynamic_cast<G4Polycone*>(solid);
|
||||
G4Polyhedra * sh = dynamic_cast<G4Polyhedra*>(solid);
|
||||
if (s)
|
||||
{
|
||||
nr = s->GetNumRZCorner();
|
||||
|
||||
first_r = s->GetCorner(0).r;
|
||||
first_z = s->GetCorner(0).z;
|
||||
for (G4int i=0; i<nr; i++)
|
||||
{
|
||||
G4double r = s->GetCorner(i).r;
|
||||
G4double z = s->GetCorner(i).z;
|
||||
//line.push_back(G4ThreeVector(r,0.,z));
|
||||
line.push_back(G4ThreeVector(r,z,0));
|
||||
if (r>maxr)
|
||||
maxr=r;
|
||||
if (z>maxz)
|
||||
maxz=z;
|
||||
G4cout << G4ThreeVector(r,0,z) << G4endl;
|
||||
//endline.push_back(G4ThreeVector(s->GetCorner(nr-1).r, 0.,
|
||||
// s->GetCorner(nr-1).z));
|
||||
endline.push_back(G4ThreeVector(s->GetCorner(nr-1).r,
|
||||
s->GetCorner(nr-1).z,0));
|
||||
}
|
||||
}
|
||||
else if (sh)
|
||||
{
|
||||
nr = sh->GetNumRZCorner();
|
||||
|
||||
first_r = sh->GetCorner(0).r;
|
||||
first_z = sh->GetCorner(0).z;
|
||||
for (G4int i=0; i<nr; i++)
|
||||
{
|
||||
G4double r = sh->GetCorner(i).r;
|
||||
G4double z = sh->GetCorner(i).z;
|
||||
line.push_back(G4ThreeVector(r,0.,z));
|
||||
if (r>maxr)
|
||||
maxr=r;
|
||||
if (z>maxz)
|
||||
maxz=z;
|
||||
G4cout << G4ThreeVector(r,0,z) << G4endl;
|
||||
endline.push_back(G4ThreeVector(sh->GetCorner(nr-1).r, 0.,
|
||||
sh->GetCorner(nr-1).z));
|
||||
}
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
||||
//endline.push_back(G4ThreeVector(first_r,0.,first_z));
|
||||
endline.push_back(G4ThreeVector(first_r,first_z,0.));
|
||||
if (maxz>=maxr)
|
||||
ex = maxz;
|
||||
else
|
||||
ex = maxr;
|
||||
|
||||
G4cout << "ex=" << ex << G4endl;
|
||||
theNewWorldBox->SetXHalfLength(ex + ex/30.);
|
||||
theNewWorldBox->SetYHalfLength(ex + ex/30.);
|
||||
theNewWorldBox->SetZHalfLength(ex + ex/30.);
|
||||
|
||||
G4Colour colour;
|
||||
colour = G4Colour(1.,0.,0.);
|
||||
line.SetVisAttributes(theNewLV->GetVisAttributes()->GetColor());
|
||||
G4VVisManager::GetConcreteInstance()->Draw(line);
|
||||
colour = G4Colour(0.,1.,0.);
|
||||
endline.SetVisAttributes(theNewLV->GetVisAttributes()->GetColor());
|
||||
//endline.SetVisAttributes(attribs3);
|
||||
G4VVisManager::GetConcreteInstance()->Draw(endline);
|
||||
colour = G4Colour(0.,0.,1.);
|
||||
G4Polyline ax;
|
||||
//ax.push_back(G4ThreeVector(0.,0.,-ex));
|
||||
//ax.push_back(G4ThreeVector(0.,0.,ex));
|
||||
ax.push_back(G4ThreeVector(0.,-ex,0.));
|
||||
ax.push_back(G4ThreeVector(0.,ex,0.));
|
||||
G4VisAttributes attribs2(colour);
|
||||
ax.SetVisAttributes(attribs2);
|
||||
G4VVisManager::GetConcreteInstance()->Draw(ax);
|
||||
}
|
||||
|
||||
void OlapDetConstr::ConstructNewWorld()
|
||||
{
|
||||
// delete the current NewWorld
|
||||
DeleteNewWorld();
|
||||
|
||||
#ifdef OlapDetConstr_debug
|
||||
G4int checkb = G4LogicalVolumeStore::GetInstance()->size();
|
||||
G4cerr << "OlapDetConstr::ConstructNewWorld():"
|
||||
<< " nr of lvs after DeleteNewWorld is: " << checkb << G4endl;
|
||||
#endif
|
||||
|
||||
#ifdef somewhen_but_not_now
|
||||
OlapManager * m = OlapManager::GetOlapManager();
|
||||
// If polymode is set, don't create a overlap-detection world
|
||||
// but draw the outlines of the mother polycone/-hedra (if it is one)
|
||||
if (m->IsPolyMode())
|
||||
{
|
||||
DrawPolyOutline();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
G4int nr = theNewLV->GetNoDaughters();
|
||||
|
||||
// create a NewWorld with a 2% larger extent than the
|
||||
// solid of the NewMother
|
||||
|
||||
const G4VisExtent & ext = theNewLV->GetSolid()->GetExtent();
|
||||
G4double extX = (ext.GetXmax()-ext.GetXmin())/2.;
|
||||
G4double extY = (ext.GetYmax()-ext.GetYmin())/2.;
|
||||
G4double extZ = (ext.GetZmax()-ext.GetZmin())/2.;
|
||||
G4ThreeVector pos( (ext.GetXmax()+ext.GetXmin())/2. ,
|
||||
(ext.GetYmax()+ext.GetYmin())/2. ,
|
||||
(ext.GetZmax()+ext.GetZmin())/2.
|
||||
);
|
||||
pos=-pos;
|
||||
|
||||
/*
|
||||
extX += extX/1000.;
|
||||
extY += extY/1000.;
|
||||
extZ += extZ/1000.;
|
||||
*/
|
||||
G4double worldDim = sqrt(extX*extX + extY*extY + extZ*extZ);
|
||||
worldDim += worldDim/100.;
|
||||
// this automatically sets the dimensions of the
|
||||
// solid in theNewWorldLV, because it's a ptr to the same solid
|
||||
theNewWorldBox->SetXHalfLength(worldDim);
|
||||
theNewWorldBox->SetYHalfLength(worldDim);
|
||||
theNewWorldBox->SetZHalfLength(worldDim);
|
||||
|
||||
//G4LogicalVolume * aInbetweenLV =
|
||||
// new G4LogicalVolume(theNewWorldBox, theNewLV->GetMaterial(), "INBETWEEN");
|
||||
|
||||
//aInbetweenLV->SetVisAttributes(visWorld);
|
||||
|
||||
// create the mother with one layer of daughters
|
||||
G4LogicalVolume * aNewMotherLV =
|
||||
new G4LogicalVolume(theNewLV->GetSolid(),
|
||||
theNewLV->GetMaterial(),
|
||||
theNewLV->GetName()
|
||||
);
|
||||
|
||||
//LM
|
||||
// below the mother is fixed colored instead as taken from vis-atts of the
|
||||
// full detector
|
||||
//aNewMotherLV->SetVisAttributes(visMother);
|
||||
aNewMotherLV->SetVisAttributes(theNewLV->GetVisAttributes());
|
||||
|
||||
#ifdef OLAPDEBUG2
|
||||
G4cout << " mother: " << theNewLV->GetName() << G4endl;
|
||||
#endif
|
||||
|
||||
delete theNewWorldRot;
|
||||
G4ThreeVector rotAxis(cos(thePhi)*sin(theTheta),
|
||||
sin(thePhi)*sin(theTheta),
|
||||
cos(theTheta));
|
||||
|
||||
theNewWorldRot = new G4RotationMatrix(rotAxis,theAlpha);
|
||||
|
||||
/*
|
||||
new G4PVPlacement( theNewWorldRot, G4ThreeVector(), aInbetweenLV,
|
||||
theNewLV->GetName(),
|
||||
theNewWorldLV, false, 0);
|
||||
*/
|
||||
|
||||
// G4VPhysicalVolume * aNewMotherPV =
|
||||
new G4PVPlacement( theNewWorldRot, // rotation
|
||||
pos, // translation
|
||||
aNewMotherLV, // own logical vol
|
||||
theNewLV->GetName(), // name of phys = name of logical!!!
|
||||
|
||||
theNewWorldLV, // mother logical vol
|
||||
//aInbetweenLV,
|
||||
|
||||
false, 0 // not MANY, cpNr=0
|
||||
);
|
||||
|
||||
|
||||
// loop over daughters an copy them into the new world ...
|
||||
// - but don't iterate recursively over deeper layers of daughters!
|
||||
for (G4int i=0; i<nr; i++) {
|
||||
|
||||
G4VPhysicalVolume * pv = theNewLV->GetDaughter(i);
|
||||
#ifdef OLAPDEBUG2
|
||||
G4cout << i << " ";
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// only do the stuff, if OlapManager.NoOlapMap[lv] is set to false!
|
||||
// otherwise the volume should not be considered for olap detection
|
||||
|
||||
OlapManager * m = OlapManager::GetOlapManager();
|
||||
if (m->NoOlapMap[pv->GetLogicalVolume()])
|
||||
continue;
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
G4LogicalVolume * myLogical =
|
||||
new G4LogicalVolume(pv->GetLogicalVolume()->GetSolid(),
|
||||
pv->GetLogicalVolume()->GetMaterial(),
|
||||
pv->GetLogicalVolume()->GetName()
|
||||
);
|
||||
|
||||
//LM
|
||||
// take vis atts from whole detector instead of fixed values!
|
||||
myLogical->SetVisAttributes(pv->GetLogicalVolume()->GetVisAttributes());
|
||||
|
||||
// select between placements, replicas and parameterizations
|
||||
G4PVPlacement * pvPlace;
|
||||
if (dynamic_cast<G4PVPlacement*>(pv))
|
||||
{
|
||||
pvPlace = dynamic_cast<G4PVPlacement*>(pv);
|
||||
new G4PVPlacement( pvPlace->GetRotation(),
|
||||
pvPlace->GetTranslation(),
|
||||
myLogical, // my own logical vol
|
||||
pvPlace->GetName(),
|
||||
aNewMotherLV, // my mother logical vol
|
||||
false, // not many
|
||||
pvPlace->GetCopyNo()
|
||||
);
|
||||
#ifdef OLAPDEBUG2
|
||||
G4cout << " daughter: " << i << " " << pvPlace->GetName()
|
||||
<< " lv=" << pv->GetLogicalVolume()->GetName()
|
||||
<< " solid=" << pv->GetLogicalVolume()->GetSolid()->GetEntityType() << G4endl;
|
||||
#endif
|
||||
|
||||
}
|
||||
else if ( pv->IsReplicated() && ! pv->GetParameterisation() ) // Replicas
|
||||
{
|
||||
// retrieve replication data
|
||||
EAxis aAxis;
|
||||
G4int nReplicas;
|
||||
G4double aWidth, anOffset;
|
||||
G4bool aDummy;
|
||||
pv->GetReplicationData(aAxis, nReplicas, aWidth, anOffset, aDummy);
|
||||
|
||||
new G4PVReplica( pv->GetName(),
|
||||
myLogical,
|
||||
aNewMotherLV,
|
||||
aAxis,
|
||||
nReplicas,
|
||||
aWidth,
|
||||
anOffset
|
||||
);
|
||||
|
||||
#ifdef OLAPDEBUG2
|
||||
G4cout << " repl.daughter: " << i << " " << pv->GetName()
|
||||
<< " lv=" << pv->GetLogicalVolume()->GetName()
|
||||
<< " solid=" << pv->GetLogicalVolume()->GetSolid()->GetEntityType() << G4endl;
|
||||
#endif
|
||||
|
||||
}
|
||||
else if ( pv->IsReplicated() && pv->GetParameterisation() )
|
||||
{
|
||||
// retrieve replication/parameterisation data
|
||||
EAxis aAxis;
|
||||
G4int nReplicas;
|
||||
G4double aWidth, anOffset;
|
||||
G4bool aDummy;
|
||||
pv->GetReplicationData(aAxis, nReplicas, aWidth, anOffset, aDummy);
|
||||
G4VPVParameterisation *pParam = pv->GetParameterisation();
|
||||
|
||||
new G4PVParameterised( pv->GetName(),
|
||||
myLogical,
|
||||
aNewMotherLV,
|
||||
aAxis,
|
||||
nReplicas,
|
||||
pParam
|
||||
);
|
||||
#ifdef OLAPDEBUG2
|
||||
G4cout << " param.daughter: " << i << " " << pv->GetName()
|
||||
<< " lv=" << pv->GetLogicalVolume()->GetName()
|
||||
<< " solid="
|
||||
<< pv->GetLogicalVolume()->GetSolid()->GetEntityType()
|
||||
<< G4endl;
|
||||
#endif
|
||||
|
||||
}// end:placement?replica?parameterisation
|
||||
|
||||
} // end:Loop over Daughters
|
||||
|
||||
#ifdef OlapDetConstr_debug
|
||||
G4int check = G4LogicalVolumeStore::GetInstance()->size();
|
||||
G4cerr << "OlapDetConstr::ConstructNewWorld():"
|
||||
<< " nr of lvs after construction is: " << check
|
||||
<< G4endl << G4endl;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
void OlapDetConstr::DeleteNewWorld()
|
||||
{
|
||||
#ifdef OlapDetConstr_debug
|
||||
G4int checkb = G4LogicalVolumeStore::GetInstance()->size();
|
||||
G4cerr << "OlapDetConstr::DeleteNewWorld():"
|
||||
<< " nr of lvs before delete is: " << checkb << G4endl;
|
||||
#endif
|
||||
|
||||
G4int nr = theNewWorldLV->GetNoDaughters();
|
||||
|
||||
if (nr==0)
|
||||
{
|
||||
G4cerr << "OlapDetConstr::DeleteNewWorld(): no daughter in NewWorld!"
|
||||
<< G4endl << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (nr>1 || nr<0) // only one daughter is allowed!!!!
|
||||
{
|
||||
G4cerr << "OlapDetConstr::DeleteNewWorld(): "
|
||||
<< "too many daughters in NewWorldLV!" << nr << G4endl;
|
||||
G4cerr << " exiting ..." << G4endl;
|
||||
G4Exception("ERROR - OlapDetConstr::DeleteNewWorld()");
|
||||
}
|
||||
|
||||
G4LogicalVolume * aMother;
|
||||
G4VPhysicalVolume * aDaughter;
|
||||
|
||||
aMother = theNewWorldLV->GetDaughter(0)->GetLogicalVolume();
|
||||
|
||||
G4int nrd = aMother->GetNoDaughters();
|
||||
for (G4int i=0; i<nrd; i++)
|
||||
{
|
||||
aDaughter = aMother->GetDaughter(i);
|
||||
G4LogicalVolume * tmp = aDaughter->GetLogicalVolume();
|
||||
//aMother->RemoveDaughter(aDaughter);
|
||||
#ifdef OlapDetConstr_debug
|
||||
G4cerr << " deleting: i=" << i << " of " << nrd
|
||||
<< " : vol=" << tmp->GetName() << G4endl;
|
||||
#endif
|
||||
delete tmp;
|
||||
delete aDaughter;
|
||||
}
|
||||
|
||||
aDaughter = theNewWorldLV->GetDaughter(0);
|
||||
theNewWorldLV->RemoveDaughter(aDaughter);
|
||||
delete aDaughter;
|
||||
delete aMother;
|
||||
|
||||
#ifdef OlapDetConstr_debug
|
||||
G4int check = G4LogicalVolumeStore::GetInstance()->size();
|
||||
if (check!=nrLV) {
|
||||
G4cerr << "OlapDetConstr::DeleteNewWorld():"
|
||||
<< " nr of lvs should be: " << nrLV << " but is: "
|
||||
<< check << G4endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// set everything in the full geometry to invisible
|
||||
void OlapDetConstr::ResetColors()
|
||||
{
|
||||
/*
|
||||
G4ColorMap * aColMap = G4ColorMap::GetColorMap();
|
||||
aColMap->SetAllInvisible();
|
||||
*/
|
||||
//ColorFirstLevel();
|
||||
}
|
||||
|
||||
|
||||
// colors the first layer of daughters of the full geometry
|
||||
void OlapDetConstr::ColorFirstLevel()
|
||||
{
|
||||
/*
|
||||
G4ColorMap * aColMap = G4ColorMap::GetColorMap();
|
||||
|
||||
G4LogicalVolume * lvWorld = theWorld->GetLogicalVolume();
|
||||
aColMap->SetVisible(lvWorld,true);
|
||||
G4int nr = lvWorld->GetNoDaughters();
|
||||
for (G4int i = 0; i<nr; i++) {
|
||||
aColMap->SetVisible(lvWorld->GetDaughter(i)->GetLogicalVolume(),true);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
// sets NewWorld invisible
|
||||
void OlapDetConstr::ResetColors(G4LogicalVolume* lv)
|
||||
{
|
||||
/*
|
||||
G4ColorMap * aColMap = G4ColorMap::GetColorMap();
|
||||
G4int nr = lv->GetNoDaughters();
|
||||
for (G4int i =0; i<nr; i++) {
|
||||
aColMap->SetVisible(lv->GetDaughter(i)->GetLogicalVolume(),false);
|
||||
}
|
||||
aColMap->SetVisible(lv,false);
|
||||
*/
|
||||
//ColorFirstLevel();
|
||||
|
||||
}
|
||||
|
||||
|
||||
G4VPhysicalVolume * OlapDetConstr::SetFullWorld()
|
||||
{
|
||||
G4RunManager::GetRunManager()->DefineWorldVolume(theWorld);
|
||||
|
||||
return theWorld;
|
||||
}
|
||||
|
||||
|
||||
G4LogicalVolume * OlapDetConstr::GetOriginalWorld()
|
||||
{
|
||||
return theNewLV;
|
||||
}
|
||||
@@ -0,0 +1,403 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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: OlapEventAction.cc,v 1.1 2002/06/04 07:40:21 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-01 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
// OlapEventAction
|
||||
//
|
||||
// Author: Martin Liendl - Martin.Liendl@cern.ch
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
//
|
||||
#include "g4std/vector"
|
||||
#include "g4std/strstream"
|
||||
|
||||
#include "G4VVisManager.hh"
|
||||
#include "G4Trajectory.hh"
|
||||
#include "G4TrajectoryContainer.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4Event.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4Run.hh"
|
||||
|
||||
#include "OlapManager.hh"
|
||||
#include "OlapEventAction.hh"
|
||||
#include "OlapRunAction.hh"
|
||||
#include "OlapDetConstr.hh"
|
||||
#include "OlapGenerator.hh"
|
||||
|
||||
//#define OLAP_DEBUG
|
||||
//#define OLAP_DEBUG_2
|
||||
|
||||
G4std::ostream &
|
||||
operator<<(G4std::ostream& flux, OlapInfo & oi)
|
||||
{
|
||||
OlapStepInfo si;
|
||||
si.thePoint = oi.v1;
|
||||
si.theHist = oi.hist1;
|
||||
flux << "vol 1: point=" << oi.v1 << " vol 2: point=" << oi.v2
|
||||
<< " axis=" << oi.axis << " [" << oi.probNot << "] "
|
||||
<< oi.info << G4endl;
|
||||
if (oi.stAB.size())
|
||||
{
|
||||
flux << oi.stAB << G4endl << G4endl;
|
||||
flux << oi.stBA << G4endl;
|
||||
}
|
||||
flux << "A -> B:" << G4endl;
|
||||
flux << si << G4endl;
|
||||
flux << "B -> A:" << G4endl;
|
||||
si.thePoint=oi.v2;
|
||||
si.theHist=oi.hist2;
|
||||
flux << si << G4endl;
|
||||
return flux;
|
||||
}
|
||||
|
||||
|
||||
OlapInfo::~OlapInfo()
|
||||
{
|
||||
while( !stAB.empty() )
|
||||
{
|
||||
delete stAB.back();
|
||||
stAB.pop_back();
|
||||
}
|
||||
|
||||
while( !stBA.empty() )
|
||||
{
|
||||
delete stBA.back();
|
||||
stBA.pop_back();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
G4bool OlapInfo::operator==(const OlapInfo & rh)
|
||||
{
|
||||
/*
|
||||
const G4AffineTransform & in1 = rh.hist1.GetTopTransform();
|
||||
const G4AffineTransform & in2 = rh.hist2.GetTopTransform();
|
||||
const G4AffineTransform & th1 = hist1.GetTopTransform();
|
||||
const G4AffineTransform & th2 = hist2.GetTopTransform();
|
||||
|
||||
G4cout << "histories: 1 2: " << G4endl;
|
||||
for (G4int i=0; i<16; i++) {
|
||||
G4cout << th1[i] << '\t' << th2[i] << G4endl;
|
||||
G4cout << in1[i] << '\t' << in2[i] << G4endl;
|
||||
G4cout << "----------------------------" << G4endl;
|
||||
}
|
||||
*/
|
||||
G4bool result = false;
|
||||
if (
|
||||
(
|
||||
( hist1.GetTopVolume() == rh.hist1.GetTopVolume() ) &&
|
||||
( hist2.GetTopVolume() == rh.hist2.GetTopVolume() )
|
||||
)
|
||||
||
|
||||
(
|
||||
( hist1.GetTopVolume() == rh.hist2.GetTopVolume() ) &&
|
||||
( hist2.GetTopVolume() == rh.hist1.GetTopVolume() )
|
||||
)
|
||||
)
|
||||
result = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
OlapEventAction::OlapEventAction(OlapRunAction * aRunAction)
|
||||
: theRunAction(aRunAction), dontDelete(false)
|
||||
{
|
||||
const G4VUserDetectorConstruction * aDet =
|
||||
G4RunManager::GetRunManager()->GetUserDetectorConstruction();
|
||||
const OlapDetConstr * aConstDet =
|
||||
dynamic_cast<const OlapDetConstr *>(aDet);
|
||||
if (!aDet) {
|
||||
G4cerr << "OlapEventAction just can be used together with an OlapDetConstr!"
|
||||
<< G4endl << "exiting ..." << G4endl;
|
||||
G4Exception("ERROR - OlapEventAction::OlapEventAction()");
|
||||
}
|
||||
theDet = const_cast<OlapDetConstr *>(aConstDet);
|
||||
}
|
||||
|
||||
|
||||
OlapEventAction::~OlapEventAction()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void OlapEventAction::BeginOfEventAction(const G4Event* anEvent)
|
||||
{
|
||||
// G4cout << ">>>evt=" << anEvent->GetEventID() << " run=" <<
|
||||
// anEvent->G4endl;
|
||||
|
||||
while (!ABSteps.empty())
|
||||
{
|
||||
if (! dontDelete )
|
||||
delete ABSteps.back();
|
||||
ABSteps.pop_back();
|
||||
}
|
||||
|
||||
while (!BASteps.empty())
|
||||
{
|
||||
if (! dontDelete )
|
||||
delete BASteps.back();
|
||||
BASteps.pop_back();
|
||||
}
|
||||
|
||||
dontDelete=false;
|
||||
}
|
||||
|
||||
|
||||
void OlapEventAction::EndOfEventAction(const G4Event* anEvent)
|
||||
{
|
||||
|
||||
const OlapGenerator * aGen = dynamic_cast<const OlapGenerator *>
|
||||
(G4RunManager::GetRunManager()->GetUserPrimaryGeneratorAction());
|
||||
OlapGenerator * aGenerator=0;
|
||||
if ( aGen )
|
||||
{
|
||||
aGenerator = const_cast<OlapGenerator*>(aGen);
|
||||
}
|
||||
else
|
||||
{
|
||||
G4cerr << "Warning: Primary generator is not OlapGenerator!" << G4endl
|
||||
<< " Overlap Detection will not work!" << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (! (anEvent->GetEventID() % 1000))
|
||||
{
|
||||
G4cout << "Event=" << anEvent->GetEventID() << " : "
|
||||
<< theDet->GetNewWorld()->GetLogicalVolume()->GetDaughter(0)->GetName()
|
||||
<< G4endl;
|
||||
}
|
||||
|
||||
// try the starting points of AB and BA
|
||||
// they must be in the theWorldLV volume ...
|
||||
// G4LogicalVolume * startLV =
|
||||
// (ABSteps[0])->theHist.GetTopVolume()->GetLogicalVolume();
|
||||
|
||||
G4int axx = -1;
|
||||
if (aGenerator)
|
||||
axx = aGenerator->GetAxis();
|
||||
|
||||
G4double distAB, distBA;
|
||||
distAB = (ABSteps[0])->thePoint[axx]
|
||||
- (ABSteps[ABSteps.size()-1])->thePoint[axx];
|
||||
distBA = (BASteps[0])->thePoint[axx]
|
||||
- (BASteps[BASteps.size()-1])->thePoint[axx];
|
||||
#ifdef OLAP_DEBUG
|
||||
G4cout << "OlapEventAction::EndOfEventAction(): "
|
||||
<< "deltaAB="
|
||||
<< (ABSteps[0])->thePoint[axx]
|
||||
- (ABSteps[ABSteps.size()-1])->thePoint[axx]
|
||||
<< " deltaBA="
|
||||
<< (BASteps[0])->thePoint[axx]
|
||||
- (BASteps[BASteps.size()-1])->thePoint[axx]
|
||||
<< G4endl;
|
||||
#endif
|
||||
|
||||
G4double tolerance = OlapManager::GetOlapManager()->Delta();
|
||||
|
||||
if ( (ABSteps[ABSteps.size()-1])->theHist.GetTopVolume()->GetLogicalVolume() !=
|
||||
theDet->GetNewWorld()->GetLogicalVolume() ||
|
||||
(BASteps[BASteps.size()-1])->theHist.GetTopVolume()->GetLogicalVolume() !=
|
||||
theDet->GetNewWorld()->GetLogicalVolume()
|
||||
)
|
||||
{
|
||||
#ifdef OLAP_DEBUG_2
|
||||
G4cerr << "=============overlap: daughter protrudes mother" << G4endl;
|
||||
#endif
|
||||
//G4cerr << ABSteps[0]->theHist << G4endl;
|
||||
OlapInfo * oi =
|
||||
new OlapInfo( ABSteps[ABSteps.size()-1]->theHist,
|
||||
BASteps[BASteps.size()-1]->theHist,
|
||||
ABSteps[ABSteps.size()-1]->thePoint,
|
||||
BASteps[BASteps.size()-1]->thePoint,
|
||||
axx,
|
||||
OlapManager::GetOlapManager()->GetOriginalWorld() );
|
||||
oi->info = "daughter protrudes mother";
|
||||
oi->probNot = false; // it's an overlap
|
||||
oi->stAB = ABSteps;
|
||||
oi->stBA = BASteps;
|
||||
dontDelete = true;
|
||||
|
||||
if ( !InsertOI(oi) )
|
||||
{ // already detected!
|
||||
delete oi;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// just in case, not the OlapGenerator is used but
|
||||
// another particle generator
|
||||
if (!BASteps.size())
|
||||
return;
|
||||
|
||||
// do we have as many steps from AB as from BA?
|
||||
if (ABSteps.size() != BASteps.size()) {
|
||||
#ifdef OLAP_DEBUG
|
||||
G4cerr << "overlap: different no of steps AB, BA" << G4endl;
|
||||
#endif
|
||||
//G4cerr << ABSteps[0]->theHist << G4endl;
|
||||
//G4cerr << "in that case we're are not logging (yet) ..." << G4endl;
|
||||
OlapInfo * oi =
|
||||
new OlapInfo( ABSteps[1]->theHist,
|
||||
BASteps[1]->theHist,
|
||||
ABSteps[1]->thePoint,
|
||||
BASteps[1]->thePoint,
|
||||
axx,
|
||||
OlapManager::GetOlapManager()->GetOriginalWorld() );
|
||||
// copy all steps and prohibit deletion of their pointers ...
|
||||
oi->stAB = ABSteps;
|
||||
oi->stBA = BASteps;
|
||||
oi->probNot = true; // probably not an overlap, just numerics ....
|
||||
dontDelete = true;
|
||||
|
||||
G4std::ostrstream os;
|
||||
os << "A,B diff. steps AB:" << ABSteps.size()
|
||||
<< " BA:" << BASteps.size() << '\0';
|
||||
|
||||
oi->info = G4String(os.str());
|
||||
if ( !InsertOI(oi) )
|
||||
{
|
||||
delete oi;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// now forget about the first and the last points of AB and BA &
|
||||
// compare the remaining points of AB with the remaining points
|
||||
// of BA where the points of BA are in descending order while
|
||||
// the points of BA are in ascending order
|
||||
G4int siz = ABSteps.size();
|
||||
G4int j = siz-3;
|
||||
for (G4int i = 1; i<(siz-1); i++)
|
||||
{
|
||||
G4double delta =
|
||||
(ABSteps[i]->thePoint - BASteps[j]->thePoint).mag() ;
|
||||
if (delta>tolerance)
|
||||
{
|
||||
OlapInfo * oi =
|
||||
new OlapInfo( ABSteps[i]->theHist,
|
||||
BASteps[j]->theHist,
|
||||
ABSteps[i]->thePoint,
|
||||
BASteps[j]->thePoint,
|
||||
axx,
|
||||
OlapManager::GetOlapManager()->GetOriginalWorld() );
|
||||
#ifdef OLAP_DEBUG
|
||||
G4cerr << "overlap: delta=" << delta << G4endl;
|
||||
G4cerr << *oi << G4endl;
|
||||
#endif
|
||||
|
||||
if ( !InsertOI(oi) )
|
||||
{ // already detected!
|
||||
delete oi;
|
||||
}
|
||||
|
||||
/*
|
||||
G4cerr << "overlap: delta=" << delta << G4endl;
|
||||
G4cerr << *(ABSteps[i])
|
||||
<< *(BASteps[j]);
|
||||
*/
|
||||
}
|
||||
j--;
|
||||
}
|
||||
|
||||
// G4cout << "From A to B:" << G4endl;
|
||||
// G4cout << ABSteps << G4endl;
|
||||
// G4cout << "From B to A:" << G4endl;
|
||||
// G4cout << BASteps << G4endl;
|
||||
}
|
||||
|
||||
G4bool OlapEventAction::InsertOI(OlapInfo * oi)
|
||||
{
|
||||
G4std::vector<OlapInfo*>::iterator it = theRunAction->theOlaps.begin();
|
||||
G4bool flag(false);
|
||||
while (it != theRunAction->theOlaps.end())
|
||||
{
|
||||
if (*oi== *(*it)) { // already detected overlap
|
||||
flag=true;
|
||||
if ((*it)->probNot != oi->probNot )
|
||||
{ // probably a real overlap, not numerics
|
||||
flag=false;
|
||||
(*it)->probNot = false;
|
||||
oi->probNot = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
it++;
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
#ifdef OLAP_DEBUG
|
||||
G4cout << "===================================" << G4endl;
|
||||
G4cout << "No of detected Overlaps: " << theRunAction->theOlaps.size()
|
||||
<< G4endl;
|
||||
G4cout << "===================================" << G4endl;
|
||||
#endif
|
||||
return false; // already detected overlap
|
||||
}
|
||||
|
||||
theRunAction->theOlaps.push_back(oi);
|
||||
|
||||
#ifdef OLAP_DEBUG
|
||||
G4cout << "===================================" << G4endl;
|
||||
G4cout << "No of detected Overlaps: " << theRunAction->theOlaps.size()
|
||||
<< G4endl;
|
||||
G4cout << "===================================" << G4endl;
|
||||
G4cout << oi->hist1 << G4endl;
|
||||
G4cout << "CpNo: " << oi->hist1.GetTopVolume()->GetCopyNo() << G4endl;
|
||||
G4cout << "Pos: " << oi->hist1.GetTopTransform().NetTranslation()
|
||||
<< G4endl;
|
||||
G4cout << "Rot: " << oi->hist1.GetTopTransform().NetRotation().phiX()
|
||||
<< " " << oi->hist1.GetTopTransform().NetRotation().phiY() << " "
|
||||
<< oi->hist1.GetTopTransform().NetRotation().phiZ() << " "
|
||||
<< oi->hist1.GetTopTransform().NetRotation().thetaX() << " "
|
||||
<< oi->hist1.GetTopTransform().NetRotation().thetaY() << " "
|
||||
<< oi->hist1.GetTopTransform().NetRotation().thetaZ()
|
||||
<< G4endl ;
|
||||
G4cout << oi->v1 << G4endl << "----" << G4endl;
|
||||
|
||||
G4cout << oi->hist2 << G4endl;
|
||||
G4cout << "CpNo: " << oi->hist2.GetTopVolume()->GetCopyNo() << G4endl;
|
||||
G4cout << "Pos: " << oi->hist2.GetTopTransform().NetTranslation()
|
||||
<< G4endl;
|
||||
G4cout << "Rot: " << oi->hist2.GetTopTransform().NetRotation().phiX()
|
||||
<< " " << oi->hist2.GetTopTransform().NetRotation().phiY() << " "
|
||||
<< oi->hist2.GetTopTransform().NetRotation().phiZ() << " "
|
||||
<< oi->hist2.GetTopTransform().NetRotation().thetaX() << " "
|
||||
<< oi->hist2.GetTopTransform().NetRotation().thetaY() << " "
|
||||
<< oi->hist2.GetTopTransform().NetRotation().thetaZ()
|
||||
<< G4endl ;
|
||||
G4cout << oi->v2 << G4endl << "----" << G4endl;
|
||||
|
||||
#endif
|
||||
|
||||
static char * c = getenv("OLAP_LOG_EVENT");
|
||||
if (c)
|
||||
G4cerr << *oi << G4endl;
|
||||
|
||||
return true; // new overlap detected!
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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: OlapGenerator.cc,v 1.2 2002/06/04 09:23:44 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-01 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
// OlapGenerator
|
||||
//
|
||||
// Author: Martin Liendl - Martin.Liendl@cern.ch
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
//
|
||||
#include "OlapGenerator.hh"
|
||||
#include "G4Event.hh"
|
||||
#include "G4VisExtent.hh"
|
||||
#include "G4PrimaryParticle.hh"
|
||||
#include "G4Geantino.hh"
|
||||
#include "G4ChargedGeantino.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4Run.hh"
|
||||
#include "G4Event.hh"
|
||||
|
||||
//#define OLAPDEBUG1
|
||||
|
||||
OlapGrid::OlapGrid()
|
||||
: count(3,0), gsize(3,3), axis(0), eventsPerRun(27)
|
||||
{
|
||||
Reset();
|
||||
G4cout << "OlapGrid(): " << G4endl
|
||||
<< " gsize: " << gsize[0] << " " << gsize[1]
|
||||
<< " " << gsize[2] << G4endl;
|
||||
}
|
||||
|
||||
void OlapGrid::Next()
|
||||
{
|
||||
G4int out = (axis+1)%3; // outer loop
|
||||
G4int in = (axis+2)%3; // inner loop
|
||||
if ( !(count[in] = (count[in]+1)%gsize[in]) )
|
||||
{
|
||||
if( !(count[out] = (count[out]+1)%gsize[out]) )
|
||||
{
|
||||
axis = (axis+1)%3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OlapGenerator::OlapGenerator() : autoinc(false)
|
||||
{
|
||||
if (!ext.size())
|
||||
{
|
||||
ext.push_back(1);
|
||||
ext.push_back(2);
|
||||
ext.push_back(3);
|
||||
}
|
||||
/*
|
||||
ext[0]=1.;
|
||||
ext[1]=2.;
|
||||
ext[2]=3.;
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
OlapGenerator::~OlapGenerator()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void OlapGenerator::GeneratePrimaries(G4Event * anEvent)
|
||||
{
|
||||
G4int out = (grid.axis+1)%3; // outer loop
|
||||
G4int in = (grid.axis+2)%3; // inner loop
|
||||
|
||||
posAB[grid.axis]=-ext[grid.axis]/2.;
|
||||
posAB[in]=-ext[in]/2.+ext[in]/G4double(grid.gsize[in]-1)
|
||||
*G4double(grid.count[in]);
|
||||
posAB[out]=-ext[out]/2.+ext[out]/G4double(grid.gsize[out]-1)
|
||||
*G4double(grid.count[out]);
|
||||
|
||||
posBA = posAB;
|
||||
posBA[grid.axis]=-posBA[grid.axis];
|
||||
|
||||
G4ThreeVector dirAB, dirBA;
|
||||
dirAB[grid.axis] = 1;
|
||||
dirBA[grid.axis] = -1;
|
||||
|
||||
#ifdef OLAPDEBUG1
|
||||
G4int runID = G4RunManager::GetRunManager()->GetCurrentRun()->GetRunID();
|
||||
G4int evtID = anEvent->GetEventID();
|
||||
G4cout << "generator: "
|
||||
<< "run=" << runID << " evt=" << evtID
|
||||
<< " axis=" << grid.axis << " out=" << grid.count[out]
|
||||
<< " in=" << grid.count[in]
|
||||
<< " posAB=" << posAB
|
||||
<< " posBA=" << posBA << G4endl;
|
||||
#endif
|
||||
|
||||
// now generator 2 geantinos flying in opposite direction from A->B and B->A
|
||||
// ==========================
|
||||
G4ParticleDefinition* pd = G4Geantino::GeantinoDefinition();
|
||||
|
||||
// create 2 opposite positioned vertices
|
||||
G4PrimaryVertex* vertexAB =
|
||||
new G4PrimaryVertex(posAB,0);
|
||||
G4PrimaryVertex* vertexBA =
|
||||
new G4PrimaryVertex(posBA,0);
|
||||
|
||||
// create one geantino per vertex as primary
|
||||
G4double mass = pd->GetPDGMass();
|
||||
G4double energy = 1. + mass;
|
||||
G4double pmom = sqrt(energy*energy-mass*mass);
|
||||
G4double pxAB = pmom*dirAB.x();
|
||||
G4double pyAB = pmom*dirAB.y();
|
||||
G4double pzAB = pmom*dirAB.z();
|
||||
G4double pxBA = pmom*dirBA.x();
|
||||
G4double pyBA = pmom*dirBA.y();
|
||||
G4double pzBA = pmom*dirBA.z();
|
||||
|
||||
G4PrimaryParticle* particleAB = new G4PrimaryParticle(pd,pxAB,pyAB,pzAB);
|
||||
G4PrimaryParticle* particleBA = new G4PrimaryParticle(pd,pxBA,pyBA,pzBA);
|
||||
particleAB->SetMass( mass );
|
||||
particleBA->SetMass( mass );
|
||||
particleAB->SetCharge(0.);
|
||||
particleBA->SetCharge(0.);
|
||||
vertexAB->SetPrimary( particleAB );
|
||||
vertexBA->SetPrimary( particleBA );
|
||||
anEvent->AddPrimaryVertex( vertexAB );
|
||||
anEvent->AddPrimaryVertex( vertexBA );
|
||||
|
||||
// ok, set all counters to be ready for the next position
|
||||
if (autoinc)
|
||||
grid.Next();
|
||||
/*
|
||||
if ( !(count[in] = (count[in]+1)%grid[in]) ) {
|
||||
if( !(count[out] = (count[out]+1)%grid[out]) ) {
|
||||
axis = (axis+1)%3;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
void OlapGenerator::SetExtent(const G4VisExtent & anExt)
|
||||
{
|
||||
ext[0]=(anExt.GetXmax()-anExt.GetXmin());
|
||||
ext[1]=(anExt.GetYmax()-anExt.GetYmin());
|
||||
ext[2]=(anExt.GetZmax()-anExt.GetZmin());
|
||||
for (G4int i=0; i<3; i++)
|
||||
ext[i] += ext[i]/2000.; // enlarge by 1%
|
||||
|
||||
Reset();
|
||||
|
||||
}
|
||||
|
||||
void OlapGenerator::SetExtent(G4double e)
|
||||
{
|
||||
ext[0]=e;
|
||||
ext[1]=e;
|
||||
ext[2]=e;
|
||||
}
|
||||
|
||||
|
||||
void OlapGenerator::Reset()
|
||||
{
|
||||
grid.Reset();
|
||||
/*
|
||||
for (G4int i=0; i<3; i++) {
|
||||
count[i]=0;
|
||||
}
|
||||
|
||||
axis=0;
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
void OlapGenerator::SetGrid(G4int x, G4int y, G4int z)
|
||||
{
|
||||
if (x>2)
|
||||
grid.gsize[0]=x;
|
||||
else
|
||||
G4cerr << "Warning in OlapGenerator::SetGrid(): wrong x-grid parameter: " << x << G4endl;
|
||||
|
||||
|
||||
if (y>2)
|
||||
grid.gsize[1]=y;
|
||||
else
|
||||
G4cerr << "Warning in OlapGenerator::SetGrid(): wrong y-grid parameter: " << y << G4endl;
|
||||
|
||||
if (z>2)
|
||||
grid.gsize[2]=z;
|
||||
else
|
||||
G4cerr << "Warning in OlapGenerator::SetGrid(): wrong z-grid parameter: " << z << G4endl;
|
||||
|
||||
grid.eventsPerRun = x*y + y*z + x*z;
|
||||
Reset();
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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: OlapLogManager.cc,v 1.1 2002/06/04 07:40:21 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-01 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
// OlapLogManager
|
||||
//
|
||||
// Author: Martin Liendl - Martin.Liendl@cern.ch
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
//
|
||||
#include "OlapLogManager.hh"
|
||||
|
||||
#include "globals.hh"
|
||||
#include "g4std/fstream"
|
||||
|
||||
OlapLogManager * OlapLogManager::theInstance = 0;
|
||||
|
||||
|
||||
OlapLogManager::OlapLogManager()
|
||||
{
|
||||
areWeLogging = false;
|
||||
areWeLoggingByVolume = false;
|
||||
}
|
||||
|
||||
OlapLogManager::~OlapLogManager() {}
|
||||
|
||||
void OlapLogManager::Logging(G4String aValue)
|
||||
{
|
||||
if(aValue == "false")
|
||||
{
|
||||
areWeLogging = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
G4int lastLetter = aValue.length();
|
||||
G4String::size_type c = lastLetter-1;
|
||||
if (aValue[c] == '/')
|
||||
aValue = aValue + "olap.log";
|
||||
|
||||
areWeLogging = true;
|
||||
filename = aValue;
|
||||
G4cerr << "Output will be put into " << aValue << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void OlapLogManager::LogByVolume(G4String aPath)
|
||||
{
|
||||
if(aPath == "false")
|
||||
{
|
||||
areWeLoggingByVolume = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
areWeLoggingByVolume = true;
|
||||
logPath = aPath;
|
||||
G4cerr << "Output will be put into " << aPath
|
||||
<< "NameOfVolume.log" << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
OlapLogManager * OlapLogManager::GetOlapLogManager()
|
||||
{
|
||||
if (!theInstance)
|
||||
theInstance = new OlapLogManager();
|
||||
|
||||
return theInstance;
|
||||
}
|
||||
@@ -0,0 +1,367 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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: OlapManager.cc,v 1.1 2002/06/04 07:40:21 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-01 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
// OlapManager
|
||||
//
|
||||
// Author: Martin Liendl - Martin.Liendl@cern.ch
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
//
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "g4std/vector"
|
||||
|
||||
#include "OlapManager.hh"
|
||||
#include "OlapDetConstr.hh"
|
||||
#include "OlapManagerMessenger.hh"
|
||||
#include "OlapGenerator.hh"
|
||||
#include "OlapEventAction.hh"
|
||||
#include "G4GeoNav.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
OlapManager * OlapManager::theInstance = 0;
|
||||
|
||||
OlapManager::OlapManager() :
|
||||
olapGenerator(0), delta( kRadTolerance ),
|
||||
eventsPerRun(27), lvPos(0), polyMode(false),
|
||||
interrupt(false)
|
||||
{
|
||||
theMessenger = new OlapManagerMessenger(this);
|
||||
theLVStore = G4LogicalVolumeStore::GetInstance();
|
||||
// for SUN
|
||||
//G4std::vector<G4LogicalVolume*>::iterator aIt = theLVStore->begin();
|
||||
//G4LogicalVolumeStore::iterator aIt = theLVStore->begin();
|
||||
|
||||
theRunManager = G4RunManager::GetRunManager();
|
||||
const G4VUserDetectorConstruction * aTmp =
|
||||
theRunManager->GetUserDetectorConstruction();
|
||||
|
||||
const OlapDetConstr * aConstDetConstr =
|
||||
dynamic_cast<const OlapDetConstr*>(aTmp);
|
||||
if (!aConstDetConstr) {
|
||||
G4cerr << "OlapManger(): can't get the OlapDetConstr instance!" << G4endl;
|
||||
G4cerr << " exiting ..." << G4endl;
|
||||
G4Exception("ERROR - OlapManager::OlapManager()");
|
||||
}
|
||||
|
||||
// need a non-const instance for building NewWords!
|
||||
theDet = const_cast<OlapDetConstr*>(aConstDetConstr);
|
||||
|
||||
// instantiate the logical volume tree & add it to the Gui
|
||||
theGeoNav = new G4GeoNav(theDet->GetFullWorld()->GetLogicalVolume());
|
||||
|
||||
G4std::vector<G4LogicalVolume*>::iterator aIt2;
|
||||
for (aIt2=theLVStore->begin(); aIt2 != theLVStore->end(); aIt2++)
|
||||
NoOlapMap[*aIt2] = false;
|
||||
}
|
||||
|
||||
|
||||
OlapManager::~OlapManager()
|
||||
{
|
||||
delete theMessenger;
|
||||
delete theGeoNav;
|
||||
delete olapGenerator;
|
||||
}
|
||||
|
||||
|
||||
OlapManager * OlapManager::GetOlapManager()
|
||||
{
|
||||
if (!theInstance)
|
||||
theInstance = new OlapManager();
|
||||
|
||||
return theInstance;
|
||||
}
|
||||
|
||||
|
||||
void OlapManager::SetRotation(G4double theta, G4double phi, G4double alpha)
|
||||
{
|
||||
theDet->SetRotation(theta,phi,alpha);
|
||||
|
||||
// ?? set the current new-world again to activate the rotation??
|
||||
}
|
||||
|
||||
|
||||
|
||||
void OlapManager::TriggerRun()
|
||||
{
|
||||
const OlapGenerator * aGen = dynamic_cast<const OlapGenerator *>
|
||||
(G4RunManager::GetRunManager()->GetUserPrimaryGeneratorAction());
|
||||
OlapGenerator * aNonConstGen = 0;
|
||||
if ( aGen )
|
||||
{
|
||||
aNonConstGen = const_cast<OlapGenerator*>(aGen);
|
||||
}
|
||||
else
|
||||
{
|
||||
G4cerr << "Warning: Primary generator is not OlapGenerator!" << G4endl
|
||||
<< "Overlap Detection will not work!" << G4endl;
|
||||
return;
|
||||
}
|
||||
//while
|
||||
aNonConstGen->SetAutoIncrement(true);
|
||||
theRunManager->BeamOn(eventsPerRun);
|
||||
aNonConstGen->SetAutoIncrement(false);
|
||||
}
|
||||
|
||||
|
||||
void OlapManager::TriggerFull(G4int trg)
|
||||
{
|
||||
const OlapGenerator * aGen = dynamic_cast<const OlapGenerator *>
|
||||
(G4RunManager::GetRunManager()->GetUserPrimaryGeneratorAction());
|
||||
OlapGenerator * aNonConstGen = 0;
|
||||
if ( aGen )
|
||||
{
|
||||
aNonConstGen = const_cast<OlapGenerator*>(aGen);
|
||||
}
|
||||
else
|
||||
{
|
||||
G4cerr << "Warning: Primary generator is not OlapGenerator!" << G4endl
|
||||
<< "Overlap Detection will not work!" << G4endl;
|
||||
return;
|
||||
}
|
||||
//while
|
||||
aNonConstGen->SetAutoIncrement(true);
|
||||
|
||||
interrupt = false; // can be changed to 'true' in the following loop
|
||||
// by subclasses of OlapNotify. In that case,
|
||||
// the triggerFull-command will be stopped.
|
||||
|
||||
while (Next() && trg)
|
||||
{
|
||||
if (theDet->GetNewWorld()->GetLogicalVolume()->GetDaughter(0)->
|
||||
GetLogicalVolume()->GetNoDaughters())
|
||||
{
|
||||
theRunManager->BeamOn(eventsPerRun);
|
||||
trg--;
|
||||
if (interrupt)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
aNonConstGen->SetAutoIncrement(false);
|
||||
}
|
||||
|
||||
G4VPhysicalVolume * OlapManager::GetNewWorld()
|
||||
{
|
||||
return theDet->GetNewWorld();
|
||||
}
|
||||
|
||||
|
||||
G4VPhysicalVolume * OlapManager::GetFullWorld()
|
||||
{
|
||||
return theDet->GetFullWorld();
|
||||
}
|
||||
|
||||
G4bool OlapManager::Next()
|
||||
{
|
||||
G4LogicalVolume * nextlv = theGeoNav->NextLV();
|
||||
if(nextlv)
|
||||
{
|
||||
theDet->SetNewWorld(nextlv);
|
||||
G4cout << nextlv->GetName() << G4endl;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
G4bool OlapManager::SetNextWorld(G4int aOffs)
|
||||
{
|
||||
if (aOffs >= theLVs.size())
|
||||
{
|
||||
G4cout << aOffs << ">" << theLVs.size() -1 << G4endl;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
G4cout << "no daughters: " << (*theLVit)->GetNoDaughters() << G4endl;
|
||||
theDet->SetNewWorld(theLVs[aOffs]);
|
||||
lvPos=aOffs;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
G4bool OlapManager::SetPrevWorld(G4int aOffs)
|
||||
{
|
||||
//FIXME: OlapManager::SetPrevWorld(int) - remove this method!
|
||||
G4cerr << "DON'T CALL OlapManager::SetPrevWorld(..)!" << G4endl;
|
||||
G4Exception("ERROR - OlapManager::SetPrevWorld()");
|
||||
|
||||
for (G4int i=1; i<aOffs; i++)
|
||||
{
|
||||
if (theLVit == theLVs.begin())
|
||||
{
|
||||
theDet->SetNewWorld(*theLVit);
|
||||
return true;
|
||||
}
|
||||
theLVit--;
|
||||
}
|
||||
|
||||
if (theLVit != theLVs.begin())
|
||||
{
|
||||
theLVit--;
|
||||
if ( *theLVit != 0)
|
||||
{
|
||||
theDet->SetNewWorld(*theLVit);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
void OlapManager::ListLV(const G4String & aRegexStr)
|
||||
{
|
||||
G4cout << "logical volumes matching " << aRegexStr << ":" <<G4endl;
|
||||
|
||||
G4std::vector<G4LogicalVolume *> aLVVec;
|
||||
G4int c = theGeoNav->FilterLV(aRegexStr,aLVVec);
|
||||
|
||||
for(G4int i=0; i<c; i++)
|
||||
{
|
||||
G4cout << " " << (aLVVec[i])->GetName() << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void OlapManager::LsLV()
|
||||
{
|
||||
G4std::vector<G4LogicalVolume *> lvs;
|
||||
G4int c = theGeoNav->LsLV(lvs);
|
||||
for (G4int i = 0; i<c; i++)
|
||||
G4cout << " " << (lvs[i])->GetName() << G4endl;
|
||||
}
|
||||
|
||||
void OlapManager::PwdLV()
|
||||
{
|
||||
G4std::vector<G4LogicalVolume *> lvs;
|
||||
theGeoNav->PwdLV(lvs);
|
||||
G4String temp;
|
||||
G4cout << "/ = ";
|
||||
for (G4int i=lvs.size()-1; i>=0; i--)
|
||||
{
|
||||
G4cout << temp << (lvs[i])->GetName() << G4endl;
|
||||
temp = temp + G4String(" ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
G4int OlapManager::GetNrLVs()
|
||||
{
|
||||
return theDet->GetNrLVs();
|
||||
}
|
||||
|
||||
|
||||
void OlapManager::ChangeLV(const G4String & aDir)
|
||||
{
|
||||
G4LogicalVolume * aLv = theGeoNav->ChangeLV(aDir);
|
||||
if (aLv)
|
||||
{
|
||||
G4cout << "new world: " << aLv->GetName() << G4endl;
|
||||
theDet->SetNewWorld(aLv);
|
||||
notifyNewWorld(theDet->GetNewWorld()->GetLogicalVolume());
|
||||
}
|
||||
}
|
||||
|
||||
void OlapManager::GotoLV(const G4String & aRegexStr)
|
||||
{
|
||||
G4std::vector<G4LogicalVolume*> lvs;
|
||||
if (theGeoNav->FilterLV(aRegexStr,lvs,true))
|
||||
{
|
||||
G4cout << "new world: " << (lvs[0])->GetName() << G4endl;
|
||||
theDet->SetNewWorld((lvs[0]));
|
||||
notifyNewWorld(theDet->GetNewWorld()->GetLogicalVolume());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void OlapManager::SetNewWorld(G4LogicalVolume * nw)
|
||||
{
|
||||
if (nw)
|
||||
{
|
||||
theDet->SetNewWorld(nw);
|
||||
notifyNewWorld(theDet->GetNewWorld()->GetLogicalVolume());
|
||||
}
|
||||
}
|
||||
|
||||
void OlapManager::SetGrid(G4int x, G4int y, G4int z)
|
||||
{
|
||||
// try to find the OlapGenerator and set the new grid
|
||||
const OlapGenerator * aGen = dynamic_cast<const OlapGenerator *>
|
||||
(G4RunManager::GetRunManager()->GetUserPrimaryGeneratorAction());
|
||||
OlapGenerator * aNonConstGen = 0;
|
||||
if ( aGen )
|
||||
{
|
||||
aNonConstGen = const_cast<OlapGenerator*>(aGen);
|
||||
aNonConstGen->SetGrid(x,y,z);
|
||||
}
|
||||
else
|
||||
{
|
||||
G4cerr << "Warning: Primary generator is not OlapGenerator!" << G4endl
|
||||
<< "Overlap Detection will not work!" << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
eventsPerRun = x*y + y*z + x*z;
|
||||
G4cout << "/olap/trigger will trigger "
|
||||
<< eventsPerRun
|
||||
<< " events." << G4endl;
|
||||
}
|
||||
|
||||
|
||||
void OlapManager::notifyNewWorld(G4LogicalVolume* nw)
|
||||
{
|
||||
//G4cout << G4endl << "NewWorld-Notif: " << nw->GetName() << G4endl;
|
||||
G4std::set<OlapNotify*>::iterator i = theNotifs.begin();
|
||||
for(;i!=theNotifs.end();++i)
|
||||
(*i)->worldChanged(nw);
|
||||
}
|
||||
|
||||
|
||||
void OlapManager::notifyOlaps(const G4std::vector<OlapInfo*> & ov)
|
||||
{
|
||||
G4std::set<OlapNotify*>::iterator i = theNotifs.begin();
|
||||
for(;i!=theNotifs.end();++i)
|
||||
(*i)->overlaps(ov);
|
||||
}
|
||||
|
||||
|
||||
G4LogicalVolume* OlapManager::GetOriginalWorld()
|
||||
{
|
||||
if (theDet)
|
||||
{
|
||||
return theDet->GetOriginalWorld();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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: OlapManagerMessenger.cc,v 1.1 2002/06/04 07:40:21 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-01 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
// OlapManagerMessenger
|
||||
//
|
||||
// Author: Martin Liendl - Martin.Liendl@cern.ch
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
//
|
||||
#include "OlapManagerMessenger.hh"
|
||||
#include "OlapManager.hh"
|
||||
#include "OlapLogManager.hh"
|
||||
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4UIcmdWithAnInteger.hh"
|
||||
#include "G4UIcmdWithADoubleAndUnit.hh"
|
||||
#include "G4UIcmdWithoutParameter.hh"
|
||||
#include "G4UIcmdWith3Vector.hh"
|
||||
#include "G4UIcmdWithABool.hh"
|
||||
#include "G4UIcmdWith3VectorAndUnit.hh"
|
||||
|
||||
OlapManagerMessenger::OlapManagerMessenger(OlapManager* aManager)
|
||||
: theManager(aManager)
|
||||
{
|
||||
|
||||
theLogManager = OlapLogManager::GetOlapLogManager();
|
||||
|
||||
theOlapDir = new G4UIdirectory("/olap/");
|
||||
theOlapDir->SetGuidance("Overlap detection facility");
|
||||
|
||||
theRotationCmd = new G4UIcmdWith3VectorAndUnit("/olap/rotate",this);
|
||||
theRotationCmd->SetGuidance("rotate the new-world");
|
||||
theRotationCmd->AvailableForStates(Idle);
|
||||
theRotationCmd->SetUnitCategory("Angle");
|
||||
theRotationCmd->SetParameterName("rotAxisTheta", "rotAxisPhi", "rotAngle",true,true);
|
||||
|
||||
theTriggerCmd = new G4UIcmdWithoutParameter("/olap/trigger",this);
|
||||
theTriggerCmd->SetGuidance("starts a single mother-daughters overlap detection.");
|
||||
theTriggerCmd->AvailableForStates(Idle);
|
||||
|
||||
theTriggerFullCmd = new G4UIcmdWithAnInteger("/olap/triggerFull",this);
|
||||
theTriggerFullCmd->SetGuidance("starts a series of scans (only where mothers have");
|
||||
theTriggerFullCmd->SetGuidance("daughters. (-1 ... full detector)");
|
||||
theTriggerFullCmd->SetDefaultValue(1);
|
||||
theTriggerFullCmd->SetParameterName("nr",true);
|
||||
theTriggerFullCmd->SetRange("nr>=-1");
|
||||
theTriggerFullCmd->AvailableForStates(Idle);
|
||||
|
||||
theDeltaCmd = new G4UIcmdWithADoubleAndUnit("/olap/delta",this);
|
||||
theDeltaCmd->SetGuidance("set boundary tolerance for overlaps in units of length");
|
||||
theDeltaCmd->SetDefaultValue(kRadTolerance);
|
||||
theDeltaCmd->SetParameterName("delta",true);
|
||||
theDeltaCmd->SetRange("delta>=1.e-9"); // current G4-accuracy
|
||||
theDeltaCmd->SetUnitCategory("Length");
|
||||
theDeltaCmd->AvailableForStates(Idle);
|
||||
|
||||
theSetGridCmd = new G4UIcmdWith3Vector("/olap/grid",this);
|
||||
theSetGridCmd->SetGuidance("set the grid for the generator (x-, y-, z- grid)");
|
||||
theSetGridCmd->SetDefaultValue(G4ThreeVector(3.,3.,3.));
|
||||
theSetGridCmd->SetParameterName("xGrid", "yGrid", "zGrid", true);
|
||||
theSetGridCmd->SetRange("xGrid>2. && yGrid >2. && zGrid >2.");
|
||||
theSetGridCmd->AvailableForStates(Idle);
|
||||
|
||||
thePwdCmd = new G4UIcmdWithoutParameter("/olap/pwd",this);
|
||||
thePwdCmd->SetGuidance("show the position in the logical volume hierachy of the new world");
|
||||
thePwdCmd->AvailableForStates(Idle);
|
||||
|
||||
theLsCmd = new G4UIcmdWithoutParameter("/olap/ls",this);
|
||||
theLsCmd->SetGuidance("lists the logical daughters of the current NewWorld");
|
||||
theLsCmd->AvailableForStates(Idle);
|
||||
|
||||
theListCmd = new G4UIcmdWithAString("/olap/list",this);
|
||||
theListCmd->SetGuidance("lists all logical volumes which name matches regexp");
|
||||
theListCmd->AvailableForStates(Idle);
|
||||
|
||||
theCdCmd = new G4UIcmdWithAString("/olap/cd",this);
|
||||
theCdCmd->SetGuidance("change to NewWorld like unix-cd");
|
||||
theCdCmd->AvailableForStates(Idle);
|
||||
|
||||
theGotoWorldCmd = new G4UIcmdWithAString("/olap/goto",this);
|
||||
theGotoWorldCmd->SetGuidance("setting first logical vol matching regexp as NewWorld");
|
||||
theGotoWorldCmd->AvailableForStates(Idle);
|
||||
|
||||
theLogCmd = new G4UIcmdWithAString("/olap/log", this);
|
||||
theLogCmd->SetGuidance("puts output into a single logfile");
|
||||
theLogCmd->SetDefaultValue("olap.log");
|
||||
theLogCmd->SetParameterName("name of logfile",true);
|
||||
theLogCmd->AvailableForStates(Idle);
|
||||
|
||||
theLogByVolumeCmd = new G4UIcmdWithAString("/olap/logByVolume", this);
|
||||
theLogByVolumeCmd->SetGuidance("puts output into a logfile for each volume");
|
||||
theLogByVolumeCmd->SetDefaultValue("");
|
||||
theLogByVolumeCmd->SetParameterName("path of logfile(s)",true);
|
||||
theLogByVolumeCmd->AvailableForStates(Idle);
|
||||
|
||||
}
|
||||
|
||||
|
||||
OlapManagerMessenger::~OlapManagerMessenger()
|
||||
{
|
||||
delete theTriggerCmd;
|
||||
delete theTriggerFullCmd;
|
||||
delete theWhereIsCmd;
|
||||
delete theListCmd;
|
||||
delete theSetGridCmd;
|
||||
delete theGotoWorldCmd;
|
||||
delete theCdCmd;
|
||||
delete thePwdCmd;
|
||||
delete theLsCmd;
|
||||
delete theDeltaCmd;
|
||||
delete theOlapDir;
|
||||
delete theLogCmd;
|
||||
delete theLogByVolumeCmd;
|
||||
delete theRotationCmd;
|
||||
}
|
||||
|
||||
|
||||
void OlapManagerMessenger::SetNewValue(G4UIcommand* aCmd, G4String aVal)
|
||||
{
|
||||
|
||||
if( aCmd == theTriggerCmd )
|
||||
{ theManager->TriggerRun();}
|
||||
|
||||
if( aCmd == theTriggerFullCmd )
|
||||
{ theManager->TriggerFull(theTriggerFullCmd->GetNewIntValue(aVal)); }
|
||||
|
||||
if( aCmd == theLsCmd )
|
||||
{ theManager->LsLV(); }
|
||||
|
||||
if( aCmd == thePwdCmd )
|
||||
{ theManager->PwdLV(); }
|
||||
|
||||
if( aCmd == theListCmd )
|
||||
{ theManager->ListLV(aVal); }
|
||||
|
||||
if( aCmd == theGotoWorldCmd )
|
||||
{ theManager->GotoLV(aVal); }
|
||||
|
||||
if( aCmd == theCdCmd )
|
||||
{ theManager->ChangeLV(aVal); }
|
||||
|
||||
if ( aCmd == theSetGridCmd )
|
||||
{ G4ThreeVector vec = theSetGridCmd->GetNew3VectorValue(aVal);
|
||||
theManager->SetGrid(G4int(vec[0]),G4int(vec[1]),G4int(vec[2]));
|
||||
}
|
||||
|
||||
if ( aCmd == theDeltaCmd )
|
||||
{
|
||||
theManager->SetDelta(theDeltaCmd->GetNewDoubleValue(aVal));
|
||||
G4cout << "boundary tolerance set to " << theManager->Delta()/mm << "mm." << G4endl;
|
||||
}
|
||||
if ( aCmd == theLogCmd )
|
||||
{ theLogManager->Logging(aVal); }
|
||||
|
||||
if (aCmd == theLogByVolumeCmd )
|
||||
{ theLogManager->LogByVolume(aVal); }
|
||||
|
||||
if (aCmd == theRotationCmd )
|
||||
{ G4ThreeVector vec = theRotationCmd->GetNew3VectorValue(aVal);
|
||||
theManager->SetRotation(vec[0],vec[1],vec[2]); }
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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: OlapNotify.cc,v 1.1 2002/06/04 07:40:22 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-01 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
// OlapNotify
|
||||
//
|
||||
// Author: Martin Liendl - Martin.Liendl@cern.ch
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
//
|
||||
#include "OlapNotify.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "OlapManager.hh"
|
||||
|
||||
OlapNotify::OlapNotify()
|
||||
{
|
||||
//OlapManager * om = OlapManager::GetOlapManager();
|
||||
//om->registerNotification(this);
|
||||
}
|
||||
|
||||
OlapNotify::~OlapNotify()
|
||||
{
|
||||
//OlapManager * om = OlapManager::GetOlapManager();
|
||||
//om->deRegisterNotification(this);
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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: OlapPhysicsList.cc,v 1.1 2002/06/04 07:40:22 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-01 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
// OlapPhysicsList
|
||||
//
|
||||
// Author: Martin Liendl - Martin.Liendl@cern.ch
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
//
|
||||
#include "OlapPhysicsList.hh"
|
||||
|
||||
#include "G4ios.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ParticleWithCuts.hh"
|
||||
#include "G4ProcessManager.hh"
|
||||
#include "G4ProcessVector.hh"
|
||||
#include "G4ParticleTypes.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4Material.hh"
|
||||
|
||||
OlapPhysicsList::OlapPhysicsList(): G4VUserPhysicsList()
|
||||
{
|
||||
currentDefaultCut = defaultCutValue = 2.0*mm;
|
||||
cutForGamma = defaultCutValue;
|
||||
cutForElectron = defaultCutValue;
|
||||
cutForProton = defaultCutValue;
|
||||
|
||||
SetVerboseLevel(1);
|
||||
}
|
||||
|
||||
|
||||
OlapPhysicsList::~OlapPhysicsList()
|
||||
{}
|
||||
|
||||
|
||||
void OlapPhysicsList::ConstructParticle()
|
||||
{
|
||||
// In this method, static member functions should be called
|
||||
// for all particles which you want to use.
|
||||
// This ensures that objects of these particle types will be
|
||||
// created in the program.
|
||||
|
||||
ConstructBosons();
|
||||
}
|
||||
|
||||
|
||||
void OlapPhysicsList::ConstructBosons()
|
||||
{
|
||||
// pseudo-particles
|
||||
G4Geantino::GeantinoDefinition();
|
||||
}
|
||||
|
||||
|
||||
void OlapPhysicsList::ConstructProcess()
|
||||
{
|
||||
AddTransportation();
|
||||
|
||||
theParticleIterator->reset();
|
||||
//theParticleTable->DumpTable();
|
||||
|
||||
return;
|
||||
|
||||
// Olap-Process for stopping at user-defined surface ...
|
||||
/* will come in the next release
|
||||
while( (*theParticleIterator)() ){
|
||||
G4ParticleDefinition* particle = theParticleIterator->value();
|
||||
G4ProcessManager* pmanager = particle->GetProcessManager();
|
||||
pmanager->AddProcess(new OlapProc(),-1,-1,1);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
#include "G4Decay.hh"
|
||||
|
||||
|
||||
void OlapPhysicsList::SetCuts()
|
||||
{
|
||||
// don't need cuts because transportation is the only process ..
|
||||
return;
|
||||
}
|
||||
@@ -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: OlapRunAction.cc,v 1.2 2002/06/04 09:23:45 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-01 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
// OlapRunAction
|
||||
//
|
||||
// Author: Martin Liendl - Martin.Liendl@cern.ch
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
//
|
||||
#include "OlapRunAction.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4VVisManager.hh"
|
||||
|
||||
#include "OlapManager.hh"
|
||||
|
||||
#include "G4Run.hh"
|
||||
|
||||
#include "globals.hh"
|
||||
#include "g4std/fstream"
|
||||
|
||||
OlapRunAction::OlapRunAction()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
OlapRunAction::~OlapRunAction()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void OlapRunAction::BeginOfRunAction(const G4Run* aRun)
|
||||
{
|
||||
while ( !theOlaps.empty() )
|
||||
{
|
||||
delete theOlaps.back();
|
||||
theOlaps.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void OlapRunAction::EndOfRunAction(const G4Run* aRun)
|
||||
{
|
||||
if (!theOlaps.size())
|
||||
return;
|
||||
|
||||
//output to screen
|
||||
G4cerr << "===== collected overlaps of run [" << aRun->GetRunID() << "] "
|
||||
<< "(ol=" << theOlaps.size() << ")"<< G4endl;
|
||||
|
||||
OlapManager::GetOlapManager()->notifyOlaps(theOlaps);
|
||||
|
||||
G4std::vector<OlapInfo*>::iterator it = theOlaps.begin();
|
||||
G4int i=1;
|
||||
while (it!=theOlaps.end())
|
||||
{
|
||||
G4cerr << "--[" << i << "]--------------------------" << G4endl;
|
||||
G4cerr << "delta=" << ((*it)->v1 - (*it)->v2).mag() << G4endl;
|
||||
G4cerr << *(*it) << G4endl;
|
||||
|
||||
it++; i++;
|
||||
}
|
||||
|
||||
//output to file
|
||||
|
||||
OlapLogManager * logManager = OlapLogManager::GetOlapLogManager();
|
||||
if (logManager->areWeLogging || logManager->areWeLoggingByVolume)
|
||||
{
|
||||
it = theOlaps.begin();
|
||||
i=1;
|
||||
G4String fname;
|
||||
|
||||
if(logManager->areWeLogging)
|
||||
fname = logManager->filename;
|
||||
|
||||
else if(logManager->areWeLoggingByVolume)
|
||||
{
|
||||
G4String volume;
|
||||
if((*it)->hist1.GetDepth() >= 1)
|
||||
volume = (*it)->hist1.GetVolume(1)->GetName();
|
||||
else if((*it)->hist2.GetDepth() >= 1)
|
||||
volume = (*it)->hist2.GetVolume(1)->GetName();
|
||||
else
|
||||
G4cerr << "error: did not get the filename" << G4endl;
|
||||
|
||||
fname = logManager->logPath + volume + ".log";
|
||||
}
|
||||
|
||||
FILE.open(fname, G4std::ios::app);
|
||||
FILE << "===== collected overlaps of run [" << aRun->GetRunID() << "] "
|
||||
<< "(ol=" << theOlaps.size() << ")"<< G4endl;
|
||||
|
||||
while (it!=theOlaps.end()) {
|
||||
|
||||
FILE << "--[" << i << "]--------------------------" << G4endl;
|
||||
FILE << "delta=" << ((*it)->v1 - (*it)->v2).mag() << G4endl;
|
||||
FILE << *(*it) << G4endl;
|
||||
|
||||
it++; i++;
|
||||
}
|
||||
FILE << "-------------------------------------" << G4endl;
|
||||
FILE.close();
|
||||
|
||||
G4cerr << "Output has also been put into "<< fname << G4endl;
|
||||
}//end if
|
||||
|
||||
G4cerr << "-------------------------------------" << G4endl;
|
||||
DrawOlaps();
|
||||
|
||||
}
|
||||
|
||||
#include "g4std/vector"
|
||||
#include "G4Circle.hh"
|
||||
#include "G4Polyline.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "G4Colour.hh"
|
||||
#include "G4VSolid.hh"
|
||||
#include "G4Box.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "OlapManager.hh"
|
||||
|
||||
void OlapRunAction::DrawOlaps()
|
||||
{
|
||||
// iguana takes over ...
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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: OlapSteppingAction.cc,v 1.1 2002/06/04 07:40:23 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-01 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
// OlapSteppingAction
|
||||
//
|
||||
// Author: Martin Liendl - Martin.Liendl@cern.ch
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
//
|
||||
#include "OlapSteppingAction.hh"
|
||||
#include "OlapEventAction.hh"
|
||||
#include "G4EventManager.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4TouchableHistory.hh"
|
||||
#include "G4NavigationHistory.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4VSolid.hh"
|
||||
#include "SolidAnalyser.hh"
|
||||
|
||||
G4std::ostream&
|
||||
operator << (G4std::ostream& os, G4std::vector<OlapStepInfo*>& vec)
|
||||
{
|
||||
G4std::vector<OlapStepInfo*>::iterator it = vec.begin();
|
||||
while (it!=vec.end())
|
||||
{
|
||||
G4VPhysicalVolume * pv = (*it)->theHist.GetTopVolume();
|
||||
os << (*it)->thePoint << " [" << pv->GetName() << ":" << pv->GetCopyNo()
|
||||
<< "]" << G4endl;
|
||||
it++;
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
G4std::ostream&
|
||||
operator << (G4std::ostream& os, const OlapStepInfo& aStepInfo)
|
||||
{
|
||||
//G4cout << "History depth="<<aStepInfo.theHist.GetDepth()<< G4endl;
|
||||
for (G4int i=0;i<=aStepInfo.theHist.GetDepth();i++)
|
||||
{
|
||||
G4VSolid * solid =
|
||||
aStepInfo.theHist.GetVolume(i)->GetLogicalVolume()->GetSolid();
|
||||
SolidAnalyser * solAna = SolidAnalyser::GetSolidAnalyser();
|
||||
G4std::vector< G4std::pair<G4String,G4double> > param;
|
||||
solAna->GetParam(solid,param);
|
||||
|
||||
os << "["<<i<<"]: " ;
|
||||
const G4AffineTransform & transP = aStepInfo.theHist.GetTransform(i);
|
||||
G4ThreeVector locP(transP.TransformPoint(aStepInfo.thePoint));
|
||||
char c = '?';
|
||||
if (solid->Inside(locP)==kInside)
|
||||
c='i';
|
||||
if (solid->Inside(locP)==kOutside)
|
||||
c='o';
|
||||
if (solid->Inside(locP)==kSurface)
|
||||
c='s';
|
||||
os << " ins=[" << c << "] " ; // << "lok.pt.=" << locP;
|
||||
if( aStepInfo.theHist.GetVolume(i) != 0 ) {
|
||||
os << " PVName=["<< aStepInfo.theHist.GetVolume(i)->GetName() << ":"
|
||||
<< aStepInfo.theHist.GetVolume(i)->GetCopyNo()
|
||||
<< "] Type=[";
|
||||
switch(aStepInfo.theHist.GetVolumeType(i))
|
||||
{
|
||||
case kNormal:
|
||||
os <<"N";
|
||||
break;
|
||||
case kReplica:
|
||||
os <<"R" << aStepInfo.theHist.GetReplicaNo(i);
|
||||
break;
|
||||
case kParameterised:
|
||||
os <<"P" << aStepInfo.theHist.GetReplicaNo(i);
|
||||
break;
|
||||
}
|
||||
os << "] ";
|
||||
}else{
|
||||
os << "Phys = <Null>";
|
||||
}
|
||||
|
||||
const G4AffineTransform & trans =
|
||||
aStepInfo.theHist.GetTransform(i).Inverse();
|
||||
|
||||
os << "P=" << trans.NetTranslation()
|
||||
<< " R=[" << trans.NetRotation().phiX()/degree << ","
|
||||
<< trans.NetRotation().thetaX()/degree << ","
|
||||
<< trans.NetRotation().phiY()/degree << ","
|
||||
<< trans.NetRotation().thetaY()/degree << ","
|
||||
<< trans.NetRotation().phiZ()/degree << ","
|
||||
<< trans.NetRotation().thetaZ()/degree << "] ";
|
||||
|
||||
// solid specification
|
||||
|
||||
os << " " << solid->GetEntityType() << ": ";
|
||||
G4std::vector< G4std::pair<G4String,G4double> >::iterator it =
|
||||
param.begin();
|
||||
while ( it != param.end() )
|
||||
{
|
||||
os << (*it).first << '=' << (*it).second << " ";
|
||||
it++;
|
||||
}
|
||||
os << G4endl;
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
OlapSteppingAction::OlapSteppingAction(OlapEventAction * aEvAct)
|
||||
: theEventAction(aEvAct)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
OlapSteppingAction::~OlapSteppingAction()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void OlapSteppingAction::UserSteppingAction(const G4Step * aStep)
|
||||
{
|
||||
const G4Track * aTrack = aStep->GetTrack();
|
||||
const G4NavigationHistory & aHist = *(aTrack->GetTouchable()->GetHistory());
|
||||
G4int aTrackID = aTrack->GetTrackID();
|
||||
G4int aStepNo = aTrack->GetCurrentStepNumber();
|
||||
//G4cout << "Stepping: " << aTrack->GetVolume()->GetName()
|
||||
// << " CpNr: " << aTrack->GetVolume()->GetCopyNo() << G4endl;
|
||||
|
||||
if (aStepNo>999) {
|
||||
G4cerr << "OlapSteppingAction(): to many steps, killing track" << G4endl
|
||||
<< " pv=[" << aTrack->GetVolume()->GetName()
|
||||
<< "] cpnr=[" << aTrack->GetVolume()->GetCopyNo()
|
||||
<< "] pos=" << aTrack->GetPosition()
|
||||
<< G4endl;
|
||||
//G4EventManager::GetEventManager()->AbortCurrentEvent();
|
||||
//G4RunManager::GetRunManager()->AbortRun();
|
||||
G4Track * aNonConstTrack = const_cast<G4Track*>(aTrack);
|
||||
aNonConstTrack->SetTrackStatus(fStopAndKill);
|
||||
return;
|
||||
}
|
||||
OlapStepInfo * aStepInfo = new OlapStepInfo;
|
||||
|
||||
aStepInfo->thePoint = aTrack->GetPosition();
|
||||
aStepInfo->theHist = aHist;
|
||||
|
||||
if (aTrackID % 2)
|
||||
{
|
||||
theEventAction->ABSteps.push_back(aStepInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
theEventAction->BASteps.push_back(aStepInfo);
|
||||
}
|
||||
//G4cout << *aStepInfo << G4endl;
|
||||
}
|
||||
@@ -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: OlapVisManager.cc,v 1.1 2002/06/04 07:40:23 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-01 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
// OlapVisManager
|
||||
//
|
||||
// Author: Martin Liendl - Martin.Liendl@cern.ch
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
//
|
||||
#include "globals.hh"
|
||||
|
||||
#ifdef G4VIS_USE
|
||||
#include "OlapVisManager.hh"
|
||||
|
||||
// Supported drivers...
|
||||
|
||||
#ifdef G4VIS_USE_DAWN
|
||||
#include "G4FukuiRenderer.hh"
|
||||
#endif
|
||||
|
||||
#ifdef G4VIS_USE_DAWNFILE
|
||||
#include "G4DAWNFILE.hh"
|
||||
#endif
|
||||
|
||||
#ifdef G4VIS_USE_OPACS
|
||||
#include "G4Wo.hh"
|
||||
#include "G4Xo.hh"
|
||||
#endif
|
||||
|
||||
#ifdef G4VIS_USE_OPENGLX
|
||||
#include "G4OpenGLImmediateX.hh"
|
||||
#include "G4OpenGLStoredX.hh"
|
||||
#endif
|
||||
|
||||
#ifdef G4VIS_USE_OPENGLXM
|
||||
#include "G4OpenGLImmediateXm.hh"
|
||||
#include "G4OpenGLStoredXm.hh"
|
||||
#endif
|
||||
|
||||
#ifdef G4VIS_USE_OIX
|
||||
//#include "G4OpenInventorX.hh"
|
||||
#endif
|
||||
|
||||
#ifdef G4VIS_USE_OIWIN32
|
||||
//#include "G4OpenInventorWin32.hh"
|
||||
#endif
|
||||
|
||||
#ifdef G4VIS_USE_RAYX
|
||||
#include "G4RayX.hh"
|
||||
#endif
|
||||
|
||||
#ifdef G4VIS_USE_VRML
|
||||
//#include "G4VRML1.hh"
|
||||
#include "G4VRML2.hh"
|
||||
#endif
|
||||
|
||||
#ifdef G4VIS_USE_VRMLFILE
|
||||
//#include "G4VRML1File.hh"
|
||||
#include "G4VRML2File.hh"
|
||||
#endif
|
||||
|
||||
OlapVisManager::OlapVisManager (G4int verboseLevel)
|
||||
{
|
||||
SetVerboseLevel( verboseLevel );
|
||||
}
|
||||
|
||||
void OlapVisManager::RegisterGraphicsSystems ()
|
||||
{
|
||||
|
||||
#ifdef G4VIS_USE_DAWN
|
||||
RegisterGraphicsSystem (new G4FukuiRenderer);
|
||||
#endif
|
||||
|
||||
#ifdef G4VIS_USE_DAWNFILE
|
||||
RegisterGraphicsSystem (new G4DAWNFILE);
|
||||
#endif
|
||||
|
||||
#ifdef G4VIS_USE_OPACS
|
||||
RegisterGraphicsSystem (new G4Wo);
|
||||
RegisterGraphicsSystem (new G4Xo);
|
||||
#endif
|
||||
|
||||
#ifdef G4VIS_USE_OPENGLX
|
||||
RegisterGraphicsSystem (new G4OpenGLImmediateX);
|
||||
RegisterGraphicsSystem (new G4OpenGLStoredX);
|
||||
#endif
|
||||
|
||||
#ifdef G4VIS_USE_OPENGLXM
|
||||
RegisterGraphicsSystem (new G4OpenGLImmediateXm);
|
||||
RegisterGraphicsSystem (new G4OpenGLStoredXm);
|
||||
#endif
|
||||
|
||||
#ifdef G4VIS_USE_OIX
|
||||
// RegisterGraphicsSystem (new G4OpenInventorX);
|
||||
#endif
|
||||
|
||||
#ifdef G4VIS_USE_OIWIN32
|
||||
// RegisterGraphicsSystem (new G4OpenInventorWin32);
|
||||
#endif
|
||||
|
||||
#ifdef G4VIS_USE_RAYX
|
||||
RegisterGraphicsSystem (new G4RayX);
|
||||
#endif
|
||||
|
||||
#ifdef G4VIS_USE_VRML
|
||||
// RegisterGraphicsSystem (new G4VRML1);
|
||||
RegisterGraphicsSystem (new G4VRML2);
|
||||
#endif
|
||||
|
||||
#ifdef G4VIS_USE_VRMLFILE
|
||||
// RegisterGraphicsSystem (new G4VRML1File);
|
||||
RegisterGraphicsSystem (new G4VRML2File);
|
||||
#endif
|
||||
|
||||
if (fVerbose > 0)
|
||||
{
|
||||
G4cout << G4endl
|
||||
<< "You have successfully chosen to use the following graphics systems."
|
||||
<< G4endl;
|
||||
PrintAvailableGraphicsSystems ();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,120 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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: RandomDetector.cc,v 1.1 2002/06/04 07:40:23 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-01 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
// RandomDetector
|
||||
//
|
||||
// Author: Martin Liendl - Martin.Liendl@cern.ch
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
//
|
||||
#include "globals.hh"
|
||||
#include "Randomize.hh"
|
||||
#include "SystemOfUnits.h"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4Box.hh"
|
||||
#include "G4Material.hh"
|
||||
|
||||
#include "RandomDetector.hh"
|
||||
|
||||
//RandomDetector::RandomDetector(G4int levels, G4int perLevel, G4double prop)
|
||||
|
||||
RandomDetector::RandomDetector(G4double prop)
|
||||
: levels_(0),
|
||||
perLevel_(0),
|
||||
overlapProp_(prop),
|
||||
worldDim_(10.*m)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
RandomDetector::~RandomDetector()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
G4VPhysicalVolume * RandomDetector::Construct()
|
||||
{
|
||||
// Material: only one for all volumes ...
|
||||
G4double density = 1.390*g/cm3;
|
||||
G4double a = 39.95*g/mole;
|
||||
G4Material* lAr = new G4Material("liquidArgon", 18., a, density);
|
||||
|
||||
// world volume
|
||||
G4double halfDim = worldDim_/2.;
|
||||
G4Box * aWorldBox = new G4Box("WorldBox", halfDim, halfDim, halfDim);
|
||||
G4LogicalVolume * aWorldLV = new G4LogicalVolume(aWorldBox, lAr, "WorldLV");
|
||||
|
||||
// 2 daughters, overlapping with prop. p (protruding parent or each other)
|
||||
// G4double outer = sqrt(3.*halfDim*halfDim);
|
||||
G4double inner = halfDim;
|
||||
G4double childDim = halfDim/3.;
|
||||
G4double childRad = sqrt(3.*childDim*childDim);
|
||||
G4Box * aChildBox = new G4Box("ChildBox", childDim, childDim, childDim);
|
||||
G4LogicalVolume * child1 = new G4LogicalVolume(aChildBox, lAr, "Child_1_LV");
|
||||
G4LogicalVolume * child2 = new G4LogicalVolume(aChildBox, lAr, "Child_2_LV");
|
||||
|
||||
G4bool parentOverlap = G4UniformRand() < overlapProp_ ? true : false;
|
||||
G4bool childOverlap = G4UniformRand() < overlapProp_ ? true : false;
|
||||
|
||||
G4ThreeVector ax1(1.,1.,1.);
|
||||
G4RotationMatrix * rm1 = new G4RotationMatrix(ax1,30.*deg);
|
||||
G4ThreeVector ax2(0.2,-1.,0.45);
|
||||
G4RotationMatrix * rm2 = new G4RotationMatrix(ax2,70.*deg);
|
||||
|
||||
G4double t1 = G4UniformRand()*180.*deg;
|
||||
G4double p1 = G4UniformRand()*360.*deg;
|
||||
G4double t2 = G4UniformRand()*180.*deg;
|
||||
G4double p2 = G4UniformRand()*360.*deg;
|
||||
G4double r1, r2;
|
||||
|
||||
if (parentOverlap)
|
||||
{
|
||||
r1 = inner - childRad/3.;
|
||||
}
|
||||
else
|
||||
{
|
||||
r1 = inner - childRad - childRad/5.;
|
||||
}
|
||||
|
||||
r2 = inner - childRad - childRad/5.;
|
||||
|
||||
if (childOverlap)
|
||||
{
|
||||
t2 = t1;
|
||||
p2 = p1;
|
||||
}
|
||||
|
||||
G4ThreeVector tr1( r1*cos(p1)*sin(t1), r1*sin(p1)*sin(t1), r1*cos(t1));
|
||||
G4ThreeVector tr2( r2*cos(p2)*sin(t2), r2*sin(p2)*sin(t2), r2*cos(t2));
|
||||
|
||||
new G4PVPlacement(rm1,tr1,child1,"Child_1",aWorldLV,false,1);
|
||||
new G4PVPlacement(rm2,tr2,child2,"Child_2",aWorldLV,false,2);
|
||||
return new G4PVPlacement(0,G4ThreeVector(),aWorldLV,"Random",0,false,1);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,244 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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: SolidAnalyser.cc,v 1.2 2002/06/04 09:23:45 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-01 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
// SolidAnalyser
|
||||
//
|
||||
// Author: Martin Liendl - Martin.Liendl@cern.ch
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
//
|
||||
#include "SolidAnalyser.hh"
|
||||
|
||||
#include "g4std/strstream"
|
||||
|
||||
#include "G4Box.hh"
|
||||
#include "G4Cons.hh"
|
||||
#include "G4Polycone.hh"
|
||||
#include "G4Polyhedra.hh"
|
||||
#include "G4Trap.hh"
|
||||
#include "G4Trd.hh"
|
||||
#include "G4Tubs.hh"
|
||||
|
||||
SolidAnalyser * SolidAnalyser::theInstance = 0;
|
||||
|
||||
SolidAnalyser::SolidAnalyser()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
SolidAnalyser::~SolidAnalyser()
|
||||
{
|
||||
delete theInstance;
|
||||
}
|
||||
|
||||
|
||||
SolidAnalyser * SolidAnalyser::GetSolidAnalyser()
|
||||
{
|
||||
if (! theInstance)
|
||||
theInstance = new SolidAnalyser();
|
||||
|
||||
return theInstance;
|
||||
}
|
||||
|
||||
|
||||
G4int SolidAnalyser::GetParam(const G4VSolid * s,
|
||||
G4std::vector<G4std::pair<G4String,G4double> > & result ) const
|
||||
{
|
||||
const G4Box * box = dynamic_cast<const G4Box*>(s);
|
||||
if ( box ) return GetParam(box,result);
|
||||
|
||||
const G4Cons * cons = dynamic_cast<const G4Cons*>(s);
|
||||
if ( cons ) return GetParam(cons,result);
|
||||
|
||||
const G4Polycone * pcon = dynamic_cast<const G4Polycone*>(s);
|
||||
if ( pcon ) return GetParam(pcon,result);
|
||||
|
||||
const G4Polyhedra * phed = dynamic_cast<const G4Polyhedra*>(s);
|
||||
if ( phed ) return GetParam(phed,result);
|
||||
|
||||
const G4Trap * trap = dynamic_cast<const G4Trap*>(s);
|
||||
if ( trap ) return GetParam(trap,result);
|
||||
|
||||
const G4Trd * trd = dynamic_cast<const G4Trd*>(s);
|
||||
if ( trd ) return GetParam(trd,result);
|
||||
|
||||
const G4Tubs * tubs = dynamic_cast<const G4Tubs*>(s);
|
||||
if ( tubs ) return GetParam(tubs,result);
|
||||
|
||||
return NotImplemented(s,result);
|
||||
}
|
||||
|
||||
// default parameters for not implemented solids
|
||||
G4int SolidAnalyser::NotImplemented(const G4VSolid * s,
|
||||
G4std::vector<G4std::pair<G4String,G4double> > & result) const
|
||||
{
|
||||
G4String temp = s->GetEntityType() + G4String(": not impl.");
|
||||
result.push_back(G4std::make_pair(temp,-1.0));
|
||||
return -1;
|
||||
}
|
||||
|
||||
// G4Box
|
||||
G4int SolidAnalyser::GetParam(const G4Box * s,
|
||||
G4std::vector<G4std::pair<G4String,G4double> > & result) const
|
||||
{
|
||||
result.push_back(G4std::make_pair(G4String("x/2"), s->GetXHalfLength()));
|
||||
result.push_back(G4std::make_pair(G4String("y/2"), s->GetYHalfLength()));
|
||||
result.push_back(G4std::make_pair(G4String("z/2"), s->GetZHalfLength()));
|
||||
return 3;
|
||||
}
|
||||
|
||||
// G4Cons
|
||||
G4int SolidAnalyser::GetParam(const G4Cons * s,
|
||||
G4std::vector<G4std::pair<G4String,G4double> > & result) const
|
||||
{
|
||||
result.push_back(G4std::make_pair(G4String("z/2"),
|
||||
s->GetZHalfLength()));
|
||||
result.push_back(G4std::make_pair(G4String("rInZ-"),
|
||||
s->GetInnerRadiusMinusZ()));
|
||||
result.push_back(G4std::make_pair(G4String("rInZ+"),
|
||||
s->GetInnerRadiusPlusZ()));
|
||||
result.push_back(G4std::make_pair(G4String("rOutZ-"),
|
||||
s->GetOuterRadiusMinusZ()));
|
||||
result.push_back(G4std::make_pair(G4String("rOutZ+"),
|
||||
s->GetOuterRadiusPlusZ()));
|
||||
result.push_back(G4std::make_pair(G4String("startPhi"),
|
||||
s->GetStartPhiAngle()));
|
||||
result.push_back(G4std::make_pair(G4String("deltaPhi"),
|
||||
s->GetDeltaPhiAngle()));
|
||||
return 7;
|
||||
}
|
||||
|
||||
// G4Polycone
|
||||
G4int SolidAnalyser::GetParam(const G4Polycone * s,
|
||||
G4std::vector<G4std::pair<G4String,G4double> > & result) const
|
||||
{
|
||||
result.push_back(G4std::make_pair(G4String("startPhi"), s->GetStartPhi()));
|
||||
result.push_back(G4std::make_pair(G4String("endPhi"), s->GetEndPhi()));
|
||||
|
||||
G4int nr = s->GetNumRZCorner();
|
||||
G4String temp("nrRZ");
|
||||
result.push_back(G4std::make_pair(temp, G4double(nr)));
|
||||
for (G4int i=0; i<nr; i++)
|
||||
{
|
||||
G4std::ostrstream sstr_r, sstr_z;
|
||||
G4PolyconeSideRZ sideRz = s->GetCorner(i);
|
||||
sstr_z << "z_" << i << '\0';
|
||||
sstr_r << "r_" << i << '\0';
|
||||
G4String z_str(sstr_z.str());
|
||||
G4String r_str(sstr_r.str());
|
||||
result.push_back(G4std::make_pair(z_str, sideRz.z));
|
||||
result.push_back(G4std::make_pair(r_str, sideRz.r));
|
||||
}
|
||||
return 3 + 2*nr;
|
||||
}
|
||||
|
||||
// G4Polyhedra
|
||||
G4int SolidAnalyser::GetParam(const G4Polyhedra * s,
|
||||
G4std::vector<G4std::pair<G4String,G4double> > & result) const
|
||||
{
|
||||
result.push_back(G4std::make_pair(G4String("startPhi"), s->GetStartPhi()));
|
||||
result.push_back(G4std::make_pair(G4String("endPhi"), s->GetEndPhi()));
|
||||
result.push_back(G4std::make_pair(G4String("nrSide"),
|
||||
G4double(s->GetNumSide())));
|
||||
|
||||
G4int nr = s->GetNumRZCorner();
|
||||
|
||||
result.push_back(G4std::make_pair(G4String("nrRZ"), G4double(nr)));
|
||||
|
||||
for (G4int i=0; i<nr; i++)
|
||||
{
|
||||
G4std::ostrstream sstr_r, sstr_z;
|
||||
G4PolyhedraSideRZ sideRz = s->GetCorner(i);
|
||||
sstr_z << "z_" << i << '\0';
|
||||
sstr_r << "r_" << i << '\0';
|
||||
G4String z_str(sstr_z.str());
|
||||
G4String r_str(sstr_r.str());
|
||||
result.push_back(G4std::make_pair(z_str, sideRz.z));
|
||||
result.push_back(G4std::make_pair(r_str, sideRz.r));
|
||||
}
|
||||
return 4 + 2*nr;
|
||||
}
|
||||
|
||||
// G4Trap
|
||||
G4int SolidAnalyser::GetParam(const G4Trap * s,
|
||||
G4std::vector<G4std::pair<G4String,G4double> > & result) const
|
||||
{
|
||||
result.push_back(G4std::make_pair(G4String("z/2"), s->GetZHalfLength()));
|
||||
|
||||
result.push_back(G4std::make_pair(G4String("x/2_1"), s->GetXHalfLength1()));
|
||||
result.push_back(G4std::make_pair(G4String("x/2_2"), s->GetXHalfLength2()));
|
||||
result.push_back(G4std::make_pair(G4String("y/2_1"), s->GetYHalfLength1()));
|
||||
result.push_back(G4std::make_pair(G4String("tanAlpha_1"),s->GetTanAlpha1()));
|
||||
|
||||
result.push_back(G4std::make_pair(G4String("x/2_3"), s->GetXHalfLength3()));
|
||||
result.push_back(G4std::make_pair(G4String("x/2_4"), s->GetXHalfLength4()));
|
||||
result.push_back(G4std::make_pair(G4String("y/2_2"), s->GetYHalfLength2()));
|
||||
result.push_back(G4std::make_pair(G4String("tanAlpha_2"),s->GetTanAlpha2()));
|
||||
|
||||
return 9;
|
||||
}
|
||||
|
||||
// G4Trd
|
||||
G4int SolidAnalyser::GetParam(const G4Trd * s,
|
||||
G4std::vector<G4std::pair<G4String,G4double> > & result) const
|
||||
{
|
||||
result.push_back(G4std::make_pair(G4String("z/2"), s->GetZHalfLength()));
|
||||
|
||||
result.push_back(G4std::make_pair(G4String("x/2_1"), s->GetXHalfLength1()));
|
||||
result.push_back(G4std::make_pair(G4String("x/2_2"), s->GetXHalfLength2()));
|
||||
result.push_back(G4std::make_pair(G4String("y/2_1"), s->GetYHalfLength1()));
|
||||
result.push_back(G4std::make_pair(G4String("y/2_2"), s->GetYHalfLength2()));
|
||||
return 5;
|
||||
}
|
||||
|
||||
// G4Tubs
|
||||
G4int SolidAnalyser::GetParam(const G4Tubs * s,
|
||||
G4std::vector<G4std::pair<G4String,G4double> > & result) const
|
||||
{
|
||||
result.push_back(G4std::make_pair(G4String("z/2"), s->GetZHalfLength()));
|
||||
result.push_back(G4std::make_pair(G4String("rIn"), s->GetInnerRadius()));
|
||||
result.push_back(G4std::make_pair(G4String("rOut"), s->GetOuterRadius()));
|
||||
result.push_back(G4std::make_pair(G4String("startPhi"),
|
||||
s->GetStartPhiAngle()));
|
||||
result.push_back(G4std::make_pair(G4String("deltaPhi"),
|
||||
s->GetDeltaPhiAngle()));
|
||||
|
||||
return 5;
|
||||
}
|
||||
|
||||
G4std::ostream & operator<<(G4std::ostream& flux,
|
||||
G4std::vector<G4std::pair<G4String,G4double> > & v)
|
||||
{
|
||||
G4std::vector<G4std::pair<G4String,G4double> >::iterator it = v.begin();
|
||||
while ( it != v.end() )
|
||||
{
|
||||
flux << (*it).first << '=' << (*it).second << "<br/>" << G4endl;
|
||||
it++;
|
||||
}
|
||||
return flux;
|
||||
}
|
||||
Reference in New Issue
Block a user