Import Geant4 8.1.0 source tree
This commit is contained in:
@@ -0,0 +1,328 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// File name: RadmonDetectorConstruction.cc
|
||||
// Creation date: Sep 2005
|
||||
// Main author: Riccardo Capra <capra@ge.infn.it>
|
||||
//
|
||||
// Id: $Id: RadmonDetectorConstruction.cc,v 1.4.2.2 2006/06/29 16:13:28 gunter Exp $
|
||||
// Tag: $Name: geant4-08-01 $
|
||||
//
|
||||
|
||||
// Include files
|
||||
#include "RadmonDetectorConstruction.hh"
|
||||
|
||||
#include "RadmonVDetectorLayout.hh"
|
||||
#include "RadmonVDetectorEntityConstructor.hh"
|
||||
#include "RadmonVDetectorEntitiesConstructorsFactory.hh"
|
||||
#include "RadmonMaterialsManager.hh"
|
||||
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4UIcommand.hh"
|
||||
#include "G4Sphere.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
|
||||
|
||||
|
||||
RadmonDetectorConstruction :: RadmonDetectorConstruction(RadmonVDetectorLayout * layout, RadmonVDetectorEntitiesConstructorsFactory * factory)
|
||||
:
|
||||
detectorLayout(layout),
|
||||
constructorsFactory(factory),
|
||||
environmentConstructor(0),
|
||||
environmentPhysicalVolume(0),
|
||||
environmentLogicalVolume(0),
|
||||
environmentSolid(0)
|
||||
{
|
||||
if (detectorLayout==0)
|
||||
G4Exception("RadmonDetectorConstruction::RadmonDetectorConstruction: layout==0.");
|
||||
|
||||
if (factory==0)
|
||||
G4Exception("RadmonDetectorConstruction::RadmonDetectorConstruction: factory==0.");
|
||||
|
||||
detectorLayout->AttachObserver(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
RadmonDetectorConstruction :: ~RadmonDetectorConstruction()
|
||||
{
|
||||
detectorLayout->DetachObserver(this);
|
||||
|
||||
Destruct();
|
||||
|
||||
delete constructorsFactory;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
G4VPhysicalVolume * RadmonDetectorConstruction :: Construct(void)
|
||||
{
|
||||
// This method will not change the detector layout
|
||||
RadmonVDetectorLayout const * const & const_detectorLayout(detectorLayout);
|
||||
|
||||
if (const_detectorLayout->IsEnabledEnvironment())
|
||||
BuildEnvironmentFromType(const_detectorLayout->GetEnvironmentType());
|
||||
else
|
||||
BuildEnvironmentSphere();
|
||||
|
||||
environmentPhysicalVolume=new G4PVPlacement(0, G4ThreeVector(), "worldPV", environmentLogicalVolume, 0, false, 0);
|
||||
|
||||
G4int placement(const_detectorLayout->GetNPlacements());
|
||||
while (placement>0)
|
||||
{
|
||||
placement--;
|
||||
BuildMultilayer(placement);
|
||||
}
|
||||
|
||||
return environmentPhysicalVolume;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorConstruction :: OnLayoutChange(void)
|
||||
{
|
||||
Destruct();
|
||||
G4RunManager::GetRunManager()->DefineWorldVolume(Construct(), true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorConstruction :: Destruct(void)
|
||||
{
|
||||
// Layers destruction
|
||||
LayerItem item;
|
||||
|
||||
while (!layersStack.empty())
|
||||
{
|
||||
item=layersStack.top();
|
||||
|
||||
environmentLogicalVolume->RemoveDaughter(item.second);
|
||||
delete item.second;
|
||||
delete item.first;
|
||||
|
||||
layersStack.pop();
|
||||
}
|
||||
|
||||
// Environment destruction
|
||||
delete environmentPhysicalVolume;
|
||||
environmentPhysicalVolume=0;
|
||||
|
||||
if (environmentConstructor)
|
||||
{
|
||||
delete environmentConstructor;
|
||||
environmentConstructor=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
delete environmentLogicalVolume;
|
||||
delete environmentSolid;
|
||||
environmentSolid=0;
|
||||
}
|
||||
|
||||
environmentLogicalVolume=0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorConstruction :: BuildEnvironmentFromType(const G4String & type)
|
||||
{
|
||||
environmentConstructor=constructorsFactory->CreateEntityConstructor(type);
|
||||
|
||||
if (environmentConstructor==0)
|
||||
{
|
||||
G4cout << "RadmonDetectorConstruction::BuildEnvironmentFromType: Environment type \"" << type << "\" not found. Environment ignored." << G4endl;
|
||||
BuildEnvironmentSphere();
|
||||
}
|
||||
|
||||
// This method will not change the detector layout
|
||||
RadmonVDetectorLayout const * const & const_detectorLayout(detectorLayout);
|
||||
|
||||
G4int n(const_detectorLayout->GetEnvironmentNAttributes());
|
||||
G4String name;
|
||||
G4String value;
|
||||
|
||||
while (n>0)
|
||||
{
|
||||
n--;
|
||||
name=const_detectorLayout->GetEnvironmentAttributeName(n);
|
||||
value=const_detectorLayout->GetEnvironmentAttribute(name, G4String());
|
||||
|
||||
environmentConstructor->SetEntityAttribute(name, value);
|
||||
}
|
||||
|
||||
environmentLogicalVolume=environmentConstructor->ConstructLogicalVolume();
|
||||
|
||||
if (environmentLogicalVolume==0)
|
||||
{
|
||||
delete environmentConstructor;
|
||||
environmentConstructor=0;
|
||||
G4cout << "RadmonDetectorConstruction::BuildEnvironmentFromType: Environment type \"" << type << "\" not built. Environment ignored." << G4endl;
|
||||
BuildEnvironmentSphere();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorConstruction :: BuildEnvironmentSphere(void)
|
||||
{
|
||||
// This method will not change the detector layout
|
||||
RadmonVDetectorLayout const * const & const_detectorLayout(detectorLayout);
|
||||
|
||||
G4double maxRadius(-0.1);
|
||||
G4double radius;
|
||||
G4ThreeVector vect;
|
||||
|
||||
G4int placement(const_detectorLayout->GetNPlacements());
|
||||
G4String placementLabel;
|
||||
G4String multilayerLabel;
|
||||
|
||||
while (placement>0)
|
||||
{
|
||||
placement--;
|
||||
placementLabel=const_detectorLayout->GetPlacementLabel(placement);
|
||||
multilayerLabel=const_detectorLayout->GetPlacementMultilayerType(placementLabel);
|
||||
|
||||
vect.setX(const_detectorLayout->GetMultilayerWidth(multilayerLabel));
|
||||
vect.setY(const_detectorLayout->GetMultilayerHeight(multilayerLabel));
|
||||
vect.setZ(const_detectorLayout->GetMultilayerTotalThickness(multilayerLabel));
|
||||
radius=const_detectorLayout->GetPlacementPosition(placementLabel).getR()+vect.getR()/2.;
|
||||
|
||||
if (radius>maxRadius)
|
||||
maxRadius=radius;
|
||||
}
|
||||
|
||||
if (maxRadius<=0.)
|
||||
maxRadius=5*m;
|
||||
|
||||
G4Material & vacuum(RadmonMaterialsManager::Instance()->GetMaterial("RADMON_VACUUM"));
|
||||
|
||||
environmentSolid=new G4Sphere("worldSphere", 0.*mm, maxRadius, 0.*deg, 360.*deg, 0.*deg, 180.*deg);
|
||||
environmentLogicalVolume=new G4LogicalVolume(environmentSolid, &vacuum, "worldLV", 0, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorConstruction :: BuildMultilayer(G4int index)
|
||||
{
|
||||
// This method will not change the detector layout
|
||||
RadmonVDetectorLayout const * const & const_detectorLayout(detectorLayout);
|
||||
|
||||
G4String placementLabel(const_detectorLayout->GetPlacementLabel(index));
|
||||
G4String multilayerLabel(const_detectorLayout->GetPlacementMultilayerType(placementLabel));
|
||||
G4RotationMatrix rotation(const_detectorLayout->GetPlacementRotation(placementLabel));
|
||||
G4ThreeVector position(const_detectorLayout->GetPlacementPosition(placementLabel));
|
||||
|
||||
G4double width(const_detectorLayout->GetMultilayerWidth(multilayerLabel));
|
||||
if (width<=0.)
|
||||
return;
|
||||
|
||||
G4String widthStr(G4UIcommand::ConvertToString(width/mm)+" mm");
|
||||
|
||||
G4double height(const_detectorLayout->GetMultilayerHeight(multilayerLabel));
|
||||
if (height<=0.)
|
||||
return;
|
||||
|
||||
G4String heightStr(G4UIcommand::ConvertToString(height/mm)+" mm");
|
||||
|
||||
G4double z(const_detectorLayout->GetMultilayerTotalThickness(multilayerLabel));
|
||||
if (z<=0.)
|
||||
return;
|
||||
|
||||
z/=2.;
|
||||
|
||||
G4int n(const_detectorLayout->GetMultilayerNLayers(multilayerLabel));
|
||||
if (n==0)
|
||||
return;
|
||||
|
||||
while (n>0)
|
||||
{
|
||||
n--;
|
||||
|
||||
G4String layerLabel(const_detectorLayout->GetMultilayerLayerLabel(multilayerLabel, n));
|
||||
G4String layerType(const_detectorLayout->GetLayerType(multilayerLabel, layerLabel));
|
||||
|
||||
G4double layerThickness(const_detectorLayout->GetLayerThickness(multilayerLabel, layerLabel));
|
||||
if (layerThickness<=0.)
|
||||
continue;
|
||||
|
||||
RadmonVDetectorEntityConstructor * entityConstructor(constructorsFactory->CreateEntityConstructor(layerType));
|
||||
|
||||
if (entityConstructor==0)
|
||||
{
|
||||
z-=layerThickness;
|
||||
G4cout << "RadmonDetectorConstruction::BuildMultilayer: Layer type \"" << layerType << "\" not found. Layer ignored." << G4endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
G4int m(const_detectorLayout->GetLayerNAttributes(multilayerLabel, layerLabel));
|
||||
G4String name;
|
||||
G4String value;
|
||||
|
||||
while (m>0)
|
||||
{
|
||||
m--;
|
||||
name=const_detectorLayout->GetLayerAttributeName(multilayerLabel, layerLabel, m);
|
||||
value=const_detectorLayout->GetLayerAttribute(multilayerLabel, layerLabel, name, G4String());
|
||||
|
||||
entityConstructor->SetEntityAttribute(name, value);
|
||||
}
|
||||
|
||||
entityConstructor->SetEntityAttribute("_WIDTH", widthStr);
|
||||
entityConstructor->SetEntityAttribute("_HEIGHT", heightStr);
|
||||
entityConstructor->SetEntityAttribute("_THICKNESS", G4UIcommand::ConvertToString(layerThickness/mm)+" mm");
|
||||
|
||||
G4LogicalVolume * entityLogicalVolume(entityConstructor->ConstructLogicalVolume());
|
||||
|
||||
if (entityLogicalVolume==0)
|
||||
{
|
||||
delete entityConstructor;
|
||||
G4cout << "RadmonDetectorConstruction::BuildMultilayer: Layer \"" << layerLabel << "\" from \"" << multilayerLabel << "\" not built. Layer ignored." << G4endl;
|
||||
z-=layerThickness;
|
||||
continue;
|
||||
}
|
||||
|
||||
layerThickness/=2.;
|
||||
|
||||
z-=layerThickness;
|
||||
G4ThreeVector layerPosition(rotation.colZ());
|
||||
layerPosition*=z;
|
||||
layerPosition+=position;
|
||||
|
||||
G4VPhysicalVolume * entityPhysicalVolume(new G4PVPlacement(G4Transform3D(rotation, layerPosition), entityLogicalVolume, placementLabel+"_"+multilayerLabel+"_"+layerLabel, environmentLogicalVolume, false, 0));
|
||||
|
||||
z-=layerThickness;
|
||||
|
||||
layersStack.push(LayerItem(entityConstructor, entityPhysicalVolume));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// File name: RadmonDetectorEnvironmentLayout.cc
|
||||
// Creation date: Sep 2005
|
||||
// Main author: Riccardo Capra <capra@ge.infn.it>
|
||||
//
|
||||
// Id: $Id: RadmonDetectorEnvironmentLayout.cc,v 1.5 2006/06/29 16:13:30 gunter Exp $
|
||||
// Tag: $Name: geant4-08-01 $
|
||||
//
|
||||
|
||||
// Include files
|
||||
#include "RadmonDetectorEnvironmentLayout.hh"
|
||||
#include "RadmonDumpStyle.hh"
|
||||
#include <iomanip>
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorEnvironmentLayout :: DumpLayout(std::ostream & out, const G4String & indent) const
|
||||
{
|
||||
if (!enabled)
|
||||
out << indent << "Environment disabled\n";
|
||||
else
|
||||
{
|
||||
G4int width(RADMONDUMP_INDENT_WIDTH-indent.length());
|
||||
if (width<0)
|
||||
width=0;
|
||||
|
||||
out << indent << std::setw(width); out.setf(std::ostream::left, std::ostream::adjustfield); out << "Type" << " = \"" << environmentType << "\"\n"
|
||||
<< indent << "Attributes:\n";
|
||||
|
||||
G4String indent2(indent);
|
||||
indent2.prepend(" ");
|
||||
|
||||
DumpAttributesLayout(out, indent2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// File name: RadmonDetectorFlatVolumeComponent.cc
|
||||
// Creation date: Sep 2005
|
||||
// Main author: Riccardo Capra <capra@ge.infn.it>
|
||||
//
|
||||
// Id: $Id: RadmonDetectorFlatVolumeComponent.cc,v 1.2.2.2 2006/06/29 16:13:32 gunter Exp $
|
||||
// Tag: $Name: geant4-08-01 $
|
||||
//
|
||||
|
||||
// Include files
|
||||
#include "RadmonDetectorFlatVolumeComponent.hh"
|
||||
#include "RadmonDetectorLayerVolumesList.hh"
|
||||
#include "RadmonDetectorLayerVolumeItem.hh"
|
||||
#include "RadmonVDetectorLabelledEntityConstructor.hh"
|
||||
#include "G4Box.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
RadmonDetectorFlatVolumeComponent :: ~RadmonDetectorFlatVolumeComponent()
|
||||
{
|
||||
delete visAttributes;
|
||||
delete box;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RadmonDetectorLayerVolumesList * RadmonDetectorFlatVolumeComponent :: GenerateVolumesList(void)
|
||||
{
|
||||
G4double width(owner->GetWidth());
|
||||
if (width<0)
|
||||
return 0;
|
||||
|
||||
G4double height(owner->GetHeight());
|
||||
if (height<0)
|
||||
return 0;
|
||||
|
||||
G4double thickness(owner->GetThickness());
|
||||
if (thickness<0)
|
||||
return 0;
|
||||
|
||||
G4Material * material(owner->GetMaterial("Material"));
|
||||
if (!material)
|
||||
return 0;
|
||||
|
||||
visAttributes=owner->AllocateVisAttributes("VisAttributes", material);
|
||||
box=new G4Box("FlatVolume", width/2., height/2., thickness/2.);
|
||||
|
||||
RadmonDetectorLayerVolumesList * list=new RadmonDetectorLayerVolumesList;
|
||||
RadmonDetectorLayerVolumeItem * item=list->AppendItem();
|
||||
|
||||
item->SetSolid(box);
|
||||
item->SetAttributes(visAttributes);
|
||||
item->SetMaterial(material);
|
||||
item->SetSensitiveDetector(owner->AllocateSensitiveDetector("SensitiveDetector", ""));
|
||||
item->SetName("FlatVolume");
|
||||
|
||||
return list;
|
||||
}
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// File name: RadmonDetectorLabelledEntitiesConstructorsFactory.cc
|
||||
// Creation date: Sep 2005
|
||||
// Main author: Riccardo Capra <capra@ge.infn.it>
|
||||
//
|
||||
// Id: $Id: RadmonDetectorLabelledEntitiesConstructorsFactory.cc,v 1.2.2.2 2006/06/29 16:13:34 gunter Exp $
|
||||
// Tag: $Name: geant4-08-01 $
|
||||
//
|
||||
|
||||
// Include files
|
||||
#include "RadmonDetectorLabelledEntitiesConstructorsFactory.hh"
|
||||
#include "RadmonDetectorLabelledEntitiesConstructorsMessenger.hh"
|
||||
#include "RadmonVDetectorLabelledEntityConstructor.hh"
|
||||
|
||||
|
||||
RadmonDetectorLabelledEntitiesConstructorsFactory :: ~RadmonDetectorLabelledEntitiesConstructorsFactory()
|
||||
{
|
||||
EntityConstructorsList::iterator i(entityConstructorsList.begin());
|
||||
EntityConstructorsList::iterator end(entityConstructorsList.end());
|
||||
|
||||
RadmonDetectorLabelledEntitiesConstructorsMessenger * messenger(RadmonDetectorLabelledEntitiesConstructorsMessenger::Instance());
|
||||
|
||||
while (i!=end)
|
||||
{
|
||||
messenger->RemoveAvailableConstructor((*i)->GetLabel());
|
||||
|
||||
delete (*i);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
RadmonVDetectorEntityConstructor * RadmonDetectorLabelledEntitiesConstructorsFactory :: CreateEntityConstructor(const G4String & entityName)
|
||||
{
|
||||
EntityConstructorsList::iterator i(entityConstructorsList.begin());
|
||||
EntityConstructorsList::iterator end(entityConstructorsList.end());
|
||||
|
||||
while (i!=end)
|
||||
{
|
||||
if ((*i)->GetLabel()==entityName)
|
||||
return (*i)->New();
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorLabelledEntitiesConstructorsFactory :: AppendLabelledEntityConstructor(RadmonVDetectorLabelledEntityConstructor * constructor)
|
||||
{
|
||||
entityConstructorsList.push_back(constructor);
|
||||
|
||||
RadmonDetectorLabelledEntitiesConstructorsMessenger * messenger(RadmonDetectorLabelledEntitiesConstructorsMessenger::Instance());
|
||||
messenger->AddAvailableConstructor(constructor->GetLabel());
|
||||
}
|
||||
+146
@@ -0,0 +1,146 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// File name: RadmonDetectorLabelledEntitiesConstructorsMessenger.cc
|
||||
// Creation date: Sep 2005
|
||||
// Main author: Riccardo Capra <capra@ge.infn.it>
|
||||
//
|
||||
// Id: $Id: RadmonDetectorLabelledEntitiesConstructorsMessenger.cc,v 1.5 2006/06/29 16:13:36 gunter Exp $
|
||||
// Tag: $Name: geant4-08-01 $
|
||||
//
|
||||
|
||||
// Messenger commands path
|
||||
#define COMMANDS_PATH "/radmon/detectorFactory/"
|
||||
|
||||
// Include files
|
||||
#include "RadmonDetectorLabelledEntitiesConstructorsMessenger.hh"
|
||||
|
||||
|
||||
|
||||
RadmonDetectorLabelledEntitiesConstructorsMessenger * RadmonDetectorLabelledEntitiesConstructorsMessenger :: Instance(void)
|
||||
{
|
||||
if (instance==0)
|
||||
{
|
||||
instance=new RadmonDetectorLabelledEntitiesConstructorsMessenger;
|
||||
|
||||
if (!instance)
|
||||
G4Exception("RadmonDetectorLabelledEntitiesConstructorsMessenger::Instance: RadmonDetectorLabelledEntitiesConstructorsMessenger singleton not allocated.");
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorLabelledEntitiesConstructorsMessenger :: AddAvailableConstructor(const G4String & name)
|
||||
{
|
||||
availableConstructors.insert(name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorLabelledEntitiesConstructorsMessenger :: RemoveAvailableConstructor(const G4String & name)
|
||||
{
|
||||
availableConstructors.erase(name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
RadmonDetectorLabelledEntitiesConstructorsMessenger :: RadmonDetectorLabelledEntitiesConstructorsMessenger()
|
||||
:
|
||||
RadmonMessenger(COMMANDS_PATH, "Interactive labelled detector entities constructors factory commands."),
|
||||
RADMON_INITIALIZE_COMMAND(Dump)
|
||||
{
|
||||
RADMON_CREATE_COMMAND_0ARGS(Dump, "Print out the current available detector entity constructors");
|
||||
}
|
||||
|
||||
|
||||
|
||||
RadmonDetectorLabelledEntitiesConstructorsMessenger :: ~RadmonDetectorLabelledEntitiesConstructorsMessenger()
|
||||
{
|
||||
RADMON_DESTROY_COMMAND(Dump);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
G4String RadmonDetectorLabelledEntitiesConstructorsMessenger :: GetCurrentValue(G4UIcommand * /* command */)
|
||||
{
|
||||
G4cout << "RadmonDetectorLabelledEntitiesConstructorsMessenger::GetCurrentValue(): Not supported" << G4endl;
|
||||
|
||||
return G4String();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorLabelledEntitiesConstructorsMessenger :: SetNewValue(G4UIcommand * command, G4String newValue)
|
||||
{
|
||||
RADMON_BEGIN_LIST_SET_COMMANDS
|
||||
RADMON_SET_COMMAND(Dump)
|
||||
RADMON_END_LIST_SET_COMMANDS
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Events
|
||||
void RadmonDetectorLabelledEntitiesConstructorsMessenger :: OnDump(const G4String & /* value */)
|
||||
{
|
||||
G4String indent("- ");
|
||||
|
||||
G4String indent2(indent);
|
||||
indent2.prepend(" ");
|
||||
|
||||
G4cout << indent << "Available constructors:\n";
|
||||
|
||||
AvailableConstructors::const_iterator i(availableConstructors.begin());
|
||||
AvailableConstructors::const_iterator end(availableConstructors.end());
|
||||
|
||||
if (i==end)
|
||||
G4cout << indent2 << "No constructors available.\n";
|
||||
else
|
||||
{
|
||||
while (i!=end)
|
||||
{
|
||||
G4cout << indent2 << (*i) << '\n';
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
G4cout << G4endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
RadmonDetectorLabelledEntitiesConstructorsMessenger * RadmonDetectorLabelledEntitiesConstructorsMessenger :: instance(0);
|
||||
@@ -0,0 +1,59 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// File name: RadmonDetectorLayerLayout.cc
|
||||
// Creation date: Sep 2005
|
||||
// Main author: Riccardo Capra <capra@ge.infn.it>
|
||||
//
|
||||
// Id: $Id: RadmonDetectorLayerLayout.cc,v 1.5 2006/06/29 16:13:39 gunter Exp $
|
||||
// Tag: $Name: geant4-08-01 $
|
||||
//
|
||||
|
||||
// Include files
|
||||
#include "RadmonDetectorLayerLayout.hh"
|
||||
#include "RadmonDumpStyle.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
#include <iomanip>
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorLayerLayout :: DumpLayout(std::ostream & out, const G4String & indent) const
|
||||
{
|
||||
G4int width(RADMONDUMP_INDENT_WIDTH-indent.length());
|
||||
if (width<0)
|
||||
width=0;
|
||||
|
||||
out << indent << std::setw(width); out.setf(std::ostream::left, std::ostream::adjustfield); out << "Label"; out.setf(std::ostream::right, std::ostream::adjustfield); out << " = \"" << layerLabel << "\"\n"
|
||||
<< indent << std::setw(width); out.setf(std::ostream::left, std::ostream::adjustfield); out << "Type"; out.setf(std::ostream::right, std::ostream::adjustfield); out << " = \"" << layerType << "\"\n"
|
||||
<< indent << std::setw(width); out.setf(std::ostream::left, std::ostream::adjustfield); out << "Thickness"; out.setf(std::ostream::right, std::ostream::adjustfield); out << " = " << std::setprecision(RADMONDUMP_DOUBLE_PRECISION) << G4BestUnit(layerThickness, "Length") << '\n'
|
||||
<< indent << "Attributes:\n";
|
||||
|
||||
G4String indent2(indent);
|
||||
indent2.prepend(" ");
|
||||
|
||||
DumpAttributesLayout(out, indent2);
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// File name: RadmonDetectorLayerVolumeItem.cc
|
||||
// Creation date: Sep 2005
|
||||
// Main author: Riccardo Capra <capra@ge.infn.it>
|
||||
//
|
||||
// Id: $Id: RadmonDetectorLayerVolumeItem.cc,v 1.2.2.2 2006/06/29 16:13:44 gunter Exp $
|
||||
// Tag: $Name: geant4-08-01 $
|
||||
//
|
||||
|
||||
// Include files
|
||||
#include "RadmonDetectorLayerVolumeItem.hh"
|
||||
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "G4Material.hh"
|
||||
#include "G4SDManager.hh"
|
||||
|
||||
RadmonDetectorLayerVolumeItem :: ~RadmonDetectorLayerVolumeItem()
|
||||
{
|
||||
if (volumePhysical)
|
||||
{
|
||||
volumeMother->GetLogicalVolume()->RemoveDaughter(volumePhysical);
|
||||
delete volumePhysical;
|
||||
}
|
||||
|
||||
if (volumeLogical->GetNoDaughters())
|
||||
G4Exception("RadmonDetectorLayerVolumeItem::~RadmonDetectorLayerVolumeItem: Logical volume removed prior of daughters");
|
||||
|
||||
delete volumeLogical;
|
||||
|
||||
if (volumeSensitiveDetector)
|
||||
{
|
||||
G4SDManager * manager(G4SDManager::GetSDMpointer());
|
||||
|
||||
if (manager)
|
||||
if (! manager->FindSensitiveDetector(volumeSensitiveDetector->GetFullPathName(), false))
|
||||
delete volumeSensitiveDetector;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
G4LogicalVolume * RadmonDetectorLayerVolumeItem :: GetLogicalVolume(void)
|
||||
{
|
||||
if (! volumeLogical)
|
||||
{
|
||||
if (volumeSensitiveDetector)
|
||||
{
|
||||
G4SDManager * manager(G4SDManager::GetSDMpointer());
|
||||
|
||||
if (manager)
|
||||
{
|
||||
G4VSensitiveDetector * sensitiveDetector(manager->FindSensitiveDetector(volumeSensitiveDetector->GetFullPathName(), false));
|
||||
|
||||
if (!sensitiveDetector)
|
||||
manager->AddNewDetector(volumeSensitiveDetector);
|
||||
else if (sensitiveDetector!=volumeSensitiveDetector)
|
||||
{
|
||||
delete volumeSensitiveDetector;
|
||||
volumeSensitiveDetector=sensitiveDetector;
|
||||
}
|
||||
|
||||
volumeSensitiveDetector->Activate(true);
|
||||
}
|
||||
}
|
||||
|
||||
volumeLogical=new G4LogicalVolume(volumeSolid, volumeMaterial, volumeName+"LV", 0, volumeSensitiveDetector, 0);
|
||||
if (volumeAttributes)
|
||||
volumeLogical->SetVisAttributes(volumeAttributes);
|
||||
|
||||
if (volumeMother)
|
||||
volumePhysical=new G4PVPlacement(&volumeRotation, volumePosition, volumeLogical, volumeName+"LV", volumeMother->GetLogicalVolume(), false, 0);
|
||||
}
|
||||
|
||||
return volumeLogical;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorLayerVolumeItem :: Assertion(void)
|
||||
{
|
||||
if (volumeLogical)
|
||||
G4Exception("RadmonDetectorLayerVolumeItem::Assertion: You cannot change a RadmonDetectorLayerVolumeItem after GetLogicalVolume call.");
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// File name: RadmonDetectorLayerVolumeItemIntersection.cc
|
||||
// Creation date: Sep 2005
|
||||
// Main author: Riccardo Capra <capra@ge.infn.it>
|
||||
//
|
||||
// Id: $Id: RadmonDetectorLayerVolumeItemIntersection.cc,v 1.3 2006/06/29 16:13:49 gunter Exp $
|
||||
// Tag: $Name: geant4-08-01 $
|
||||
//
|
||||
|
||||
// Include files
|
||||
#include "RadmonDetectorLayerVolumeItemIntersection.hh"
|
||||
#include "G4IntersectionSolid.hh"
|
||||
|
||||
G4VSolid * RadmonDetectorLayerVolumeItemIntersection :: Operate(G4VSolid * left, G4VSolid * right, G4RotationMatrix * relativeRotation, const G4ThreeVector & relativePosition)
|
||||
{
|
||||
return new G4IntersectionSolid(left->GetName()+" & "+right->GetName(), left, right, relativeRotation, relativePosition);
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// File name: RadmonDetectorLayerVolumeItemSubtraction.cc
|
||||
// Creation date: Sep 2005
|
||||
// Main author: Riccardo Capra <capra@ge.infn.it>
|
||||
//
|
||||
// Id: $Id: RadmonDetectorLayerVolumeItemSubtraction.cc,v 1.3 2006/06/29 16:13:53 gunter Exp $
|
||||
// Tag: $Name: geant4-08-01 $
|
||||
//
|
||||
|
||||
// Include files
|
||||
#include "RadmonDetectorLayerVolumeItemSubtraction.hh"
|
||||
#include "G4SubtractionSolid.hh"
|
||||
#include "G4DisplacedSolid.hh"
|
||||
|
||||
G4VSolid * RadmonDetectorLayerVolumeItemSubtraction :: Operate(G4VSolid * left, G4VSolid * right, G4RotationMatrix * relativeRotation, const G4ThreeVector & relativePosition)
|
||||
{
|
||||
if (opMode==leftMinusRight)
|
||||
return new G4SubtractionSolid(left->GetName()+" - "+right->GetName(), left, right, relativeRotation, relativePosition);
|
||||
|
||||
G4RotationMatrix * inverseRelativeRotation(AllocateMatrix());
|
||||
(*inverseRelativeRotation)=(*relativeRotation);
|
||||
inverseRelativeRotation->invert();
|
||||
G4VSolid *solid(new G4SubtractionSolid(right->GetName()+" - "+left->GetName(), right, left, inverseRelativeRotation, -relativePosition));
|
||||
OwnSolid(solid);
|
||||
|
||||
return new G4DisplacedSolid("- "+left->GetName()+" + "+right->GetName(), solid, relativeRotation, relativePosition);
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// File name: RadmonDetectorLayerVolumeItemUnion.cc
|
||||
// Creation date: Sep 2005
|
||||
// Main author: Riccardo Capra <capra@ge.infn.it>
|
||||
//
|
||||
// Id: $Id: RadmonDetectorLayerVolumeItemUnion.cc,v 1.3 2006/06/29 16:13:55 gunter Exp $
|
||||
// Tag: $Name: geant4-08-01 $
|
||||
//
|
||||
|
||||
// Include files
|
||||
#include "RadmonDetectorLayerVolumeItemUnion.hh"
|
||||
#include "G4UnionSolid.hh"
|
||||
|
||||
G4VSolid * RadmonDetectorLayerVolumeItemUnion :: Operate(G4VSolid * left, G4VSolid * right, G4RotationMatrix * relativeRotation, const G4ThreeVector & relativePosition)
|
||||
{
|
||||
return new G4UnionSolid(left->GetName()+" + "+right->GetName(), left, right, relativeRotation, relativePosition);
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// File name: RadmonDetectorLayerVolumesList.cc
|
||||
// Creation date: Sep 2005
|
||||
// Main author: Riccardo Capra <capra@ge.infn.it>
|
||||
//
|
||||
// Id: $Id: RadmonDetectorLayerVolumesList.cc,v 1.3 2006/06/29 16:13:57 gunter Exp $
|
||||
// Tag: $Name: geant4-08-01 $
|
||||
//
|
||||
|
||||
// Include files
|
||||
#include "RadmonDetectorLayerVolumesList.hh"
|
||||
#include "RadmonDetectorLayerVolumeItem.hh"
|
||||
|
||||
RadmonDetectorLayerVolumeItem * RadmonDetectorLayerVolumesList :: AppendItem(void)
|
||||
{
|
||||
RadmonDetectorLayerVolumeItem * item(new RadmonDetectorLayerVolumeItem);
|
||||
volumesVector.push_back(item);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorLayerVolumesList :: RemoveItem(G4int index)
|
||||
{
|
||||
VolumesVector::iterator i(volumesVector.begin());
|
||||
i+=index;
|
||||
|
||||
RemoveRange(i, i+1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorLayerVolumesList :: RemoveItemsByRange(G4int first, G4int last)
|
||||
{
|
||||
VolumesVector::iterator i(volumesVector.begin());
|
||||
|
||||
RemoveRange(i+first, i+last);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorLayerVolumesList :: RemoveAllItems(void)
|
||||
{
|
||||
RemoveRange(volumesVector.begin(), volumesVector.end());
|
||||
}
|
||||
|
||||
void RadmonDetectorLayerVolumesList :: RemoveRange(VolumesVector::iterator begin, VolumesVector::iterator end)
|
||||
{
|
||||
VolumesVector::iterator i;
|
||||
VolumesVector::iterator j;
|
||||
const VolumesVector::iterator endJ(volumesVector.end());
|
||||
|
||||
G4bool kill;
|
||||
G4bool somethingDone(true);
|
||||
G4bool stillSomethingToDo;
|
||||
|
||||
do
|
||||
{
|
||||
if (!somethingDone)
|
||||
G4Exception("RadmonDetectorLayerVolumesList::RemoveAllItems: Some dependencies cannot be removed.");
|
||||
|
||||
stillSomethingToDo=false;
|
||||
somethingDone=false;
|
||||
|
||||
i=begin;
|
||||
while (i!=end)
|
||||
{
|
||||
if (*i)
|
||||
{
|
||||
stillSomethingToDo=true;
|
||||
|
||||
kill=true;
|
||||
j=volumesVector.begin();
|
||||
|
||||
while (j!=endJ)
|
||||
{
|
||||
if (*j)
|
||||
if ((*j)->GetMotherVolumeItem()==(*i))
|
||||
{
|
||||
kill=false;
|
||||
break;
|
||||
}
|
||||
|
||||
j++;
|
||||
}
|
||||
}
|
||||
else
|
||||
kill=false;
|
||||
|
||||
if (kill)
|
||||
{
|
||||
delete (*i);
|
||||
(*i)=0;
|
||||
somethingDone=true;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
while (stillSomethingToDo);
|
||||
|
||||
volumesVector.erase(begin, end);
|
||||
}
|
||||
@@ -0,0 +1,801 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// File name: RadmonDetectorLayout.cc
|
||||
// Creation date: Sep 2005
|
||||
// Main author: Riccardo Capra <capra@ge.infn.it>
|
||||
//
|
||||
// Id: $Id: RadmonDetectorLayout.cc,v 1.3.2.2 2006/06/29 16:13:59 gunter Exp $
|
||||
// Tag: $Name: geant4-08-01 $
|
||||
//
|
||||
|
||||
// Include files
|
||||
#include "RadmonDetectorLayout.hh"
|
||||
|
||||
|
||||
|
||||
RadmonDetectorLayout :: RadmonDetectorLayout()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
RadmonDetectorLayout :: ~RadmonDetectorLayout()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorLayout :: EnableEnvironment(void)
|
||||
{
|
||||
if (environment.IsEnabled())
|
||||
return;
|
||||
|
||||
environment.Enable();
|
||||
NotifyChange();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorLayout :: DisableEnvironment(void)
|
||||
{
|
||||
if (!environment.IsEnabled())
|
||||
return;
|
||||
|
||||
environment.Disable();
|
||||
NotifyChange();
|
||||
}
|
||||
|
||||
|
||||
|
||||
G4bool RadmonDetectorLayout :: IsEnabledEnvironment(void) const
|
||||
{
|
||||
return environment.IsEnabled();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorLayout :: SetEnvironmentType(const G4String & type)
|
||||
{
|
||||
if (environment.GetType()==type)
|
||||
return;
|
||||
|
||||
environment.SetType(type);
|
||||
|
||||
if (environment.IsEnabled())
|
||||
NotifyChange();
|
||||
}
|
||||
|
||||
|
||||
|
||||
const G4String & RadmonDetectorLayout :: GetEnvironmentType() const
|
||||
{
|
||||
return environment.GetType();
|
||||
}
|
||||
|
||||
|
||||
|
||||
G4int RadmonDetectorLayout :: GetEnvironmentNAttributes(void) const
|
||||
{
|
||||
return environment.GetNAttributes();
|
||||
}
|
||||
|
||||
|
||||
|
||||
const G4String & RadmonDetectorLayout :: GetEnvironmentAttributeName(G4int index) const
|
||||
{
|
||||
return environment.GetAttributeName(index);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorLayout :: SetEnvironmentAttribute(const G4String & attributeName, const G4String & attributeValue)
|
||||
{
|
||||
if (attributeName=="")
|
||||
{
|
||||
G4cout << "RadmonDetectorLayout::FindPlacement: \"\" is not a valid attribute name." << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (environment.GetAttribute(attributeName, attributeValue+"#")==attributeValue)
|
||||
return;
|
||||
|
||||
environment.SetAttribute(attributeName, attributeValue);
|
||||
|
||||
if (environment.IsEnabled())
|
||||
NotifyChange();
|
||||
}
|
||||
|
||||
|
||||
|
||||
const G4String RadmonDetectorLayout :: GetEnvironmentAttribute(const G4String & attributeName, const G4String & defaultAttributeValue) const
|
||||
{
|
||||
return environment.GetAttribute(attributeName, defaultAttributeValue);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorLayout :: ClearEnvironmentAttribute(const G4String & attributeName)
|
||||
{
|
||||
if (!environment.ExistsAttribute(attributeName))
|
||||
{
|
||||
G4cout << "RadmonDetectorLayout::ClearEnvironmentAttribute: Attribute \"" << attributeName << "\" missing in environment." << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
environment.ClearAttribute(attributeName);
|
||||
|
||||
if (environment.IsEnabled())
|
||||
NotifyChange();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorLayout :: CreateMultilayer(const G4String & multilayerLabel)
|
||||
{
|
||||
if (multilayersCollection.ExistsMultilayerByLabel(multilayerLabel))
|
||||
{
|
||||
G4cout << "RadmonDetectorLayout::CreateMultilayer: Multilayer \"" << multilayerLabel << "\" just exists." << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
RadmonDetectorMultilayerLayout & multilayer(multilayersCollection.CreateMultilayer());
|
||||
multilayer.SetLabel(multilayerLabel);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorLayout :: RemoveMultilayer(const G4String & multilayerLabel)
|
||||
{
|
||||
if (IsPlaced(multilayerLabel))
|
||||
{
|
||||
G4cout << "RadmonDetectorLayout::RemoveMultilayer: Multilayer \"" << multilayerLabel << "\" is placed and cannot be deleted. Remove the placement first." << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!multilayersCollection.ExistsMultilayerByLabel(multilayerLabel))
|
||||
{
|
||||
G4cout << "RadmonDetectorLayout::RemoveMultilayer: Multilayer \"" << multilayerLabel << "\" does not exist." << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
multilayersCollection.RemoveMultilayersByLabel(multilayerLabel);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorLayout :: SetMultilayerWidth(const G4String & multilayerLabel, G4double width)
|
||||
{
|
||||
RadmonDetectorMultilayerLayout * multilayer(FindMultilayer(multilayerLabel));
|
||||
|
||||
if (!multilayer)
|
||||
return;
|
||||
|
||||
if (multilayer->GetWidth()==width)
|
||||
return;
|
||||
|
||||
multilayer->SetWidth(width);
|
||||
|
||||
if (IsPlaced(multilayerLabel))
|
||||
NotifyChange();
|
||||
}
|
||||
|
||||
|
||||
|
||||
G4double RadmonDetectorLayout :: GetMultilayerWidth(const G4String & multilayerLabel) const
|
||||
{
|
||||
const RadmonDetectorMultilayerLayout * multilayer(FindMultilayer(multilayerLabel));
|
||||
|
||||
if (!multilayer)
|
||||
return 0.;
|
||||
|
||||
return multilayer->GetWidth();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorLayout :: SetMultilayerHeight(const G4String & multilayerLabel, G4double height)
|
||||
{
|
||||
RadmonDetectorMultilayerLayout * multilayer(FindMultilayer(multilayerLabel));
|
||||
|
||||
if (!multilayer)
|
||||
return;
|
||||
|
||||
if (multilayer->GetHeight()==height)
|
||||
return;
|
||||
|
||||
multilayer->SetHeight(height);
|
||||
|
||||
if (IsPlaced(multilayerLabel))
|
||||
NotifyChange();
|
||||
}
|
||||
|
||||
|
||||
|
||||
G4double RadmonDetectorLayout :: GetMultilayerHeight(const G4String & multilayerLabel) const
|
||||
{
|
||||
const RadmonDetectorMultilayerLayout * multilayer(FindMultilayer(multilayerLabel));
|
||||
|
||||
if (!multilayer)
|
||||
return 0.;
|
||||
|
||||
return multilayer->GetHeight();
|
||||
}
|
||||
|
||||
|
||||
|
||||
G4double RadmonDetectorLayout :: GetMultilayerTotalThickness(const G4String & multilayerLabel) const
|
||||
{
|
||||
const RadmonDetectorMultilayerLayout * multilayer(FindMultilayer(multilayerLabel));
|
||||
|
||||
if (!multilayer)
|
||||
return 0.;
|
||||
|
||||
return multilayer->GetTotalThickness();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorLayout :: AppendLayerToMultilayer(const G4String & multilayerLabel, const G4String & layerLabel)
|
||||
{
|
||||
RadmonDetectorMultilayerLayout * multilayer(FindMultilayer(multilayerLabel));
|
||||
|
||||
if (!multilayer)
|
||||
return;
|
||||
|
||||
if (multilayer->ExistsLayerByLabel(layerLabel))
|
||||
{
|
||||
G4cout << "RadmonDetectorLayout::AppendLayerToMultilayer: Layer \"" << layerLabel << "\" just exists in multilayer \"" << multilayerLabel << "\"." << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
RadmonDetectorLayerLayout & layer(multilayer->AppendLayer());
|
||||
|
||||
layer.SetLabel(layerLabel);
|
||||
|
||||
if (IsPlaced(multilayerLabel))
|
||||
NotifyChange();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorLayout :: RemoveLayerFromMultilayer(const G4String & multilayerLabel, const G4String & layerLabel)
|
||||
{
|
||||
RadmonDetectorMultilayerLayout * multilayer(FindMultilayer(multilayerLabel));
|
||||
|
||||
if (!multilayer)
|
||||
return;
|
||||
|
||||
if (!multilayer->ExistsLayerByLabel(layerLabel))
|
||||
{
|
||||
G4cout << "RadmonDetectorLayout::RemoveLayerFromMultilayer: Layer \"" << layerLabel << "\" does not exist in multilayer \"" << multilayerLabel << "\"." << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
multilayer->RemoveLayersByLabel(layerLabel);
|
||||
|
||||
if (IsPlaced(multilayerLabel))
|
||||
NotifyChange();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorLayout :: RemoveAllLayersFromMultilayer(const G4String & multilayerLabel)
|
||||
{
|
||||
RadmonDetectorMultilayerLayout * multilayer(FindMultilayer(multilayerLabel));
|
||||
|
||||
if (!multilayer)
|
||||
return;
|
||||
|
||||
multilayer->RemoveAllLayers();
|
||||
|
||||
if (IsPlaced(multilayerLabel))
|
||||
NotifyChange();
|
||||
}
|
||||
|
||||
|
||||
|
||||
G4int RadmonDetectorLayout :: GetMultilayerNLayers(const G4String & multilayerLabel) const
|
||||
{
|
||||
const RadmonDetectorMultilayerLayout * multilayer(FindMultilayer(multilayerLabel));
|
||||
|
||||
if (!multilayer)
|
||||
return 0;
|
||||
|
||||
return multilayer->GetNLayers();
|
||||
}
|
||||
|
||||
|
||||
|
||||
const G4String & RadmonDetectorLayout :: GetMultilayerLayerLabel(const G4String & multilayerLabel, G4int index) const
|
||||
{
|
||||
const RadmonDetectorMultilayerLayout * multilayer(FindMultilayer(multilayerLabel));
|
||||
|
||||
if (!multilayer)
|
||||
return GetNullStr();
|
||||
|
||||
return multilayer->GetLayer(index).GetLabel();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorLayout :: SetLayerThickness(const G4String & multilayerLabel, const G4String & layerLabel, G4double thickness)
|
||||
{
|
||||
RadmonDetectorLayerLayout * layer(FindLayer(multilayerLabel, layerLabel));
|
||||
|
||||
if (!layer)
|
||||
return;
|
||||
|
||||
if (layer->GetThickness()==thickness)
|
||||
return;
|
||||
|
||||
layer->SetThickness(thickness);
|
||||
|
||||
if (IsPlaced(multilayerLabel))
|
||||
NotifyChange();
|
||||
}
|
||||
|
||||
|
||||
|
||||
G4double RadmonDetectorLayout :: GetLayerThickness(const G4String & multilayerLabel, const G4String & layerLabel) const
|
||||
{
|
||||
const RadmonDetectorLayerLayout * layer(FindLayer(multilayerLabel, layerLabel));
|
||||
|
||||
if (!layer)
|
||||
return 0.;
|
||||
|
||||
return layer->GetThickness();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorLayout :: SetLayerType(const G4String & multilayerLabel, const G4String & layerLabel, const G4String & type)
|
||||
{
|
||||
RadmonDetectorLayerLayout * layer(FindLayer(multilayerLabel, layerLabel));
|
||||
|
||||
if (!layer)
|
||||
return;
|
||||
|
||||
if (layer->GetType()==type)
|
||||
return;
|
||||
|
||||
layer->SetType(type);
|
||||
|
||||
if (IsPlaced(multilayerLabel))
|
||||
NotifyChange();
|
||||
}
|
||||
|
||||
|
||||
|
||||
const G4String & RadmonDetectorLayout :: GetLayerType(const G4String & multilayerLabel, const G4String & layerLabel) const
|
||||
{
|
||||
const RadmonDetectorLayerLayout * layer(FindLayer(multilayerLabel, layerLabel));
|
||||
|
||||
if (!layer)
|
||||
return GetNullStr();
|
||||
|
||||
return layer->GetType();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
G4int RadmonDetectorLayout :: GetLayerNAttributes(const G4String & multilayerLabel, const G4String & layerLabel) const
|
||||
{
|
||||
const RadmonDetectorLayerLayout * layer(FindLayer(multilayerLabel, layerLabel));
|
||||
|
||||
if (!layer)
|
||||
return 0;
|
||||
|
||||
return layer->GetNAttributes();
|
||||
}
|
||||
|
||||
|
||||
|
||||
const G4String & RadmonDetectorLayout :: GetLayerAttributeName(const G4String & multilayerLabel, const G4String & layerLabel, G4int index) const
|
||||
{
|
||||
const RadmonDetectorLayerLayout * layer(FindLayer(multilayerLabel, layerLabel));
|
||||
|
||||
if (!layer)
|
||||
return GetNullStr();
|
||||
|
||||
return layer->GetAttributeName(index);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorLayout :: SetLayerAttribute(const G4String & multilayerLabel, const G4String & layerLabel, const G4String & attributeName, const G4String & attributeValue)
|
||||
{
|
||||
if (attributeName=="")
|
||||
{
|
||||
G4cout << "RadmonDetectorLayout::FindPlacement: \"\" is not a valid attribute name." << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
RadmonDetectorLayerLayout * layer(FindLayer(multilayerLabel, layerLabel));
|
||||
|
||||
if (!layer)
|
||||
return;
|
||||
|
||||
if (layer->GetAttribute(attributeName, attributeValue+"#")==attributeValue)
|
||||
return;
|
||||
|
||||
layer->SetAttribute(attributeName, attributeValue);
|
||||
|
||||
if (IsPlaced(multilayerLabel))
|
||||
NotifyChange();
|
||||
}
|
||||
|
||||
|
||||
|
||||
const G4String RadmonDetectorLayout :: GetLayerAttribute(const G4String & multilayerLabel, const G4String & layerLabel, const G4String & attributeName, const G4String & defaultAttributeValue) const
|
||||
{
|
||||
const RadmonDetectorLayerLayout * layer(FindLayer(multilayerLabel, layerLabel));
|
||||
|
||||
if (!layer)
|
||||
return G4String("");
|
||||
|
||||
return layer->GetAttribute(attributeName, defaultAttributeValue);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorLayout :: ClearLayerAttribute(const G4String & multilayerLabel, const G4String & layerLabel, const G4String & attributeName)
|
||||
{
|
||||
RadmonDetectorLayerLayout * layer(FindLayer(multilayerLabel, layerLabel));
|
||||
|
||||
if (!layer)
|
||||
return;
|
||||
|
||||
if (!layer->ExistsAttribute(attributeName))
|
||||
{
|
||||
G4cout << "RadmonDetectorLayout::ClearLayerAttribute: Attribute \"" << attributeName << "\" missing in layer \"" << layerLabel << "\" of multilayer \"" << multilayerLabel << "\"." << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
layer->ClearAttribute(attributeName);
|
||||
|
||||
if (IsPlaced(multilayerLabel))
|
||||
NotifyChange();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorLayout :: CreatePlacement(const G4String & placementLabel, const G4String & multilayerName)
|
||||
{
|
||||
if (multilayerPlacementsCollection.ExistsPlacementByLabel(placementLabel))
|
||||
{
|
||||
G4cout << "RadmonDetectorLayout::CreateMultilayer: Placement \"" << placementLabel << "\" just exists." << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
RadmonDetectorMultilayerPlacementLayout & placement(multilayerPlacementsCollection.CreatePlacement());
|
||||
placement.SetLabel(placementLabel);
|
||||
placement.SetMultilayerLabel(multilayerName);
|
||||
|
||||
NotifyChange();
|
||||
}
|
||||
|
||||
|
||||
|
||||
G4int RadmonDetectorLayout :: GetNPlacements() const
|
||||
{
|
||||
return multilayerPlacementsCollection.GetNPlacements();
|
||||
}
|
||||
|
||||
|
||||
|
||||
const G4String & RadmonDetectorLayout :: GetPlacementLabel(G4int index) const
|
||||
{
|
||||
return multilayerPlacementsCollection.GetPlacement(index).GetLabel();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorLayout :: RemovePlacement(const G4String & placementLabel)
|
||||
{
|
||||
if (!multilayerPlacementsCollection.ExistsPlacementByLabel(placementLabel))
|
||||
{
|
||||
G4cout << "RadmonDetectorLayout::CreateMultilayer: Placement \"" << placementLabel << "\" does not exist." << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
multilayerPlacementsCollection.RemovePlacementByLabel(placementLabel);
|
||||
NotifyChange();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const G4String & RadmonDetectorLayout :: GetPlacementMultilayerType(const G4String & placementLabel) const
|
||||
{
|
||||
const RadmonDetectorMultilayerPlacementLayout * placement(FindPlacement(placementLabel));
|
||||
|
||||
if (!placement)
|
||||
return GetNullStr();
|
||||
|
||||
return placement->GetMultilayerLabel();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorLayout :: SetPlacementPosition(const G4String & placementLabel, const G4ThreeVector & position)
|
||||
{
|
||||
RadmonDetectorMultilayerPlacementLayout * placement(FindPlacement(placementLabel));
|
||||
|
||||
if (!placement)
|
||||
return;
|
||||
|
||||
placement->SetAbsolutePosition(position);
|
||||
NotifyChange();
|
||||
}
|
||||
|
||||
|
||||
|
||||
const G4ThreeVector & RadmonDetectorLayout :: GetPlacementPosition(const G4String & placementLabel) const
|
||||
{
|
||||
const RadmonDetectorMultilayerPlacementLayout * placement(FindPlacement(placementLabel));
|
||||
|
||||
if (!placement)
|
||||
return GetNullPosition();
|
||||
|
||||
return placement->GetAbsolutePosition();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorLayout :: SetPlacementPosition(const G4String & placementLabel, const G4String & originLabel, const G4ThreeVector & offset)
|
||||
{
|
||||
RadmonDetectorMultilayerPlacementLayout * placement(FindPlacement(placementLabel));
|
||||
|
||||
if (!placement)
|
||||
return;
|
||||
|
||||
const RadmonDetectorMultilayerPlacementLayout * origin(FindPlacement(originLabel));
|
||||
if (!origin)
|
||||
return;
|
||||
|
||||
placement->SetRelativePosition(*origin, offset);
|
||||
NotifyChange();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorLayout :: SetPlacementRotation(const G4String & placementLabel, const G4RotationMatrix & rotation)
|
||||
{
|
||||
RadmonDetectorMultilayerPlacementLayout * placement(FindPlacement(placementLabel));
|
||||
|
||||
if (!placement)
|
||||
return;
|
||||
|
||||
placement->SetAbsoluteRotation(rotation);
|
||||
NotifyChange();
|
||||
}
|
||||
|
||||
|
||||
|
||||
const G4RotationMatrix & RadmonDetectorLayout :: GetPlacementRotation(const G4String & placementLabel) const
|
||||
{
|
||||
const RadmonDetectorMultilayerPlacementLayout * placement(FindPlacement(placementLabel));
|
||||
|
||||
if (!placement)
|
||||
return GetNullRotationMatrix();
|
||||
|
||||
return placement->GetAbsoluteRotation();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorLayout :: SetPlacementRotation(const G4String & placementLabel, const G4String & originLabel, const G4RotationMatrix & relativeRotation)
|
||||
{
|
||||
RadmonDetectorMultilayerPlacementLayout * placement(FindPlacement(placementLabel));
|
||||
|
||||
if (!placement)
|
||||
return;
|
||||
|
||||
const RadmonDetectorMultilayerPlacementLayout * origin(FindPlacement(originLabel));
|
||||
if (!origin)
|
||||
return;
|
||||
|
||||
placement->SetRelativeRotation(*origin, relativeRotation);
|
||||
NotifyChange();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorLayout :: DumpLayout(std::ostream & out) const
|
||||
{
|
||||
const G4String indent(" - ");
|
||||
|
||||
out << "- Environment\n";
|
||||
environment.DumpLayout(out, indent);
|
||||
|
||||
out << "\n- Multilayers\n";
|
||||
multilayersCollection.DumpLayout(out, indent);
|
||||
|
||||
out << "\n- Placements\n";
|
||||
multilayerPlacementsCollection.DumpLayout(out, indent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
G4bool RadmonDetectorLayout :: Load(std::istream & /*in*/)
|
||||
{
|
||||
// TO BE DONE
|
||||
G4cout << "RadmonDetectorLayout::Load(): PLEASE CHECK" << G4endl;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
G4bool RadmonDetectorLayout :: Save(std::ostream & /*out*/) const
|
||||
{
|
||||
// TO BE DONE
|
||||
G4cout << "RadmonDetectorLayout::Save(): PLEASE CHECK" << G4endl;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
inline bool RadmonDetectorLayout :: IsPlaced(const G4String & multilayerLabel)
|
||||
{
|
||||
G4int n(multilayerPlacementsCollection.GetNPlacements());
|
||||
|
||||
while (n>0)
|
||||
{
|
||||
n--;
|
||||
|
||||
if (multilayerPlacementsCollection.GetPlacement(n).GetMultilayerLabel()==multilayerLabel)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline RadmonDetectorMultilayerLayout * RadmonDetectorLayout :: FindMultilayer(const G4String & multilayerLabel)
|
||||
{
|
||||
if (!multilayersCollection.ExistsMultilayerByLabel(multilayerLabel))
|
||||
{
|
||||
G4cout << "RadmonDetectorLayout::FindMultilayer: Multilayer \"" << multilayerLabel << "\" does not exist." << G4endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return &multilayersCollection.FindMultilayerByLabel(multilayerLabel);
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline const RadmonDetectorMultilayerLayout * RadmonDetectorLayout :: FindMultilayer(const G4String & multilayerLabel) const
|
||||
{
|
||||
return const_cast<RadmonDetectorLayout *>(this)->FindMultilayer(multilayerLabel);
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline RadmonDetectorMultilayerPlacementLayout * RadmonDetectorLayout :: FindPlacement(const G4String & placementLabel)
|
||||
{
|
||||
if (!multilayerPlacementsCollection.ExistsPlacementByLabel(placementLabel))
|
||||
{
|
||||
G4cout << "RadmonDetectorLayout::FindPlacement: Placement \"" << placementLabel << "\" does not exist." << G4endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return & multilayerPlacementsCollection.FindPlacementByLabel(placementLabel);
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline const RadmonDetectorMultilayerPlacementLayout * RadmonDetectorLayout :: FindPlacement(const G4String & placementLabel) const
|
||||
{
|
||||
return const_cast<RadmonDetectorLayout *>(this)->FindPlacement(placementLabel);
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline RadmonDetectorLayerLayout * RadmonDetectorLayout :: FindLayer(const G4String & multilayerLabel, const G4String & layerLabel)
|
||||
{
|
||||
RadmonDetectorMultilayerLayout * multilayer(FindMultilayer(multilayerLabel));
|
||||
|
||||
if (!multilayer)
|
||||
return 0;
|
||||
|
||||
if (!multilayer->ExistsLayerByLabel(layerLabel))
|
||||
{
|
||||
G4cout << "RadmonDetectorLayout::FindLayer: Layer \"" << layerLabel << "\" does not exist in multilayer \"" << multilayerLabel << "\"." << G4endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return &multilayer->FindLayerByLabel(layerLabel);
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline const RadmonDetectorLayerLayout * RadmonDetectorLayout :: FindLayer(const G4String & multilayerLabel, const G4String & layerLabel) const
|
||||
{
|
||||
return const_cast<RadmonDetectorLayout *>(this)->FindLayer(multilayerLabel, layerLabel);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
inline G4String & RadmonDetectorLayout :: GetNullStr() const
|
||||
{
|
||||
static G4String *nullStr(0);
|
||||
|
||||
if (nullStr==0)
|
||||
nullStr=new G4String("");
|
||||
|
||||
return *nullStr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline G4ThreeVector & RadmonDetectorLayout :: GetNullPosition() const
|
||||
{
|
||||
static G4ThreeVector *nullPosition(0);
|
||||
|
||||
if (nullPosition==0)
|
||||
nullPosition=new G4ThreeVector();
|
||||
|
||||
return *nullPosition;
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline G4RotationMatrix & RadmonDetectorLayout :: GetNullRotationMatrix() const
|
||||
{
|
||||
static G4RotationMatrix * nullRotationMatrix(0);
|
||||
|
||||
if (nullRotationMatrix==0)
|
||||
nullRotationMatrix=new G4RotationMatrix();
|
||||
|
||||
return *nullRotationMatrix;
|
||||
}
|
||||
@@ -0,0 +1,561 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// File name: RadmonDetectorMessenger.cc
|
||||
// Creation date: Sep 2005
|
||||
// Main author: Riccardo Capra <capra@ge.infn.it>
|
||||
//
|
||||
// Id: $Id: RadmonDetectorMessenger.cc,v 1.3.2.2 2006/06/29 16:14:01 gunter Exp $
|
||||
// Tag: $Name: geant4-08-01 $
|
||||
//
|
||||
|
||||
// Messenger commands path
|
||||
#define COMMANDS_PATH "/radmon/detector/"
|
||||
|
||||
// Include files
|
||||
#include "RadmonDetectorMessenger.hh"
|
||||
#include "RadmonVDetectorLayout.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
|
||||
|
||||
RadmonDetectorMessenger :: RadmonDetectorMessenger(RadmonVDetectorLayout * layout)
|
||||
:
|
||||
RadmonMessenger(COMMANDS_PATH, "Interactive detector construction commands."),
|
||||
detectorLayout(layout),
|
||||
RADMON_INITIALIZE_COMMAND(EnableEnvironment),
|
||||
RADMON_INITIALIZE_COMMAND(DisableEnvironment),
|
||||
RADMON_INITIALIZE_COMMAND(SetEnvironmentType),
|
||||
RADMON_INITIALIZE_COMMAND(SetEnvironmentAttribute),
|
||||
RADMON_INITIALIZE_COMMAND(ClearEnvironmentAttribute),
|
||||
RADMON_INITIALIZE_COMMAND(CreateMultilayer),
|
||||
RADMON_INITIALIZE_COMMAND(RemoveMultilayer),
|
||||
RADMON_INITIALIZE_COMMAND(SetMultilayerWidth),
|
||||
RADMON_INITIALIZE_COMMAND(SetMultilayerHeight),
|
||||
RADMON_INITIALIZE_COMMAND(AppendLayerToMultilayer),
|
||||
RADMON_INITIALIZE_COMMAND(RemoveLayerFromMultilayer),
|
||||
RADMON_INITIALIZE_COMMAND(RemoveAllLayersFromMultilayer),
|
||||
RADMON_INITIALIZE_COMMAND(SetLayerThickness),
|
||||
RADMON_INITIALIZE_COMMAND(SetLayerType),
|
||||
RADMON_INITIALIZE_COMMAND(SetLayerAttribute),
|
||||
RADMON_INITIALIZE_COMMAND(ClearLayerAttribute),
|
||||
RADMON_INITIALIZE_COMMAND(CreatePlacement),
|
||||
RADMON_INITIALIZE_COMMAND(RemovePlacement),
|
||||
RADMON_INITIALIZE_COMMAND(SetPlacementPosition),
|
||||
RADMON_INITIALIZE_COMMAND(SetPlacementRotation),
|
||||
RADMON_INITIALIZE_COMMAND(SetRelativePlacementPosition),
|
||||
RADMON_INITIALIZE_COMMAND(SetRelativePlacementRotation),
|
||||
RADMON_INITIALIZE_COMMAND(DumpLayout),
|
||||
RADMON_INITIALIZE_COMMAND(Load),
|
||||
RADMON_INITIALIZE_COMMAND(Save)
|
||||
{
|
||||
if (layout==0)
|
||||
G4Exception("RadmonDetectorMessenger::RadmonDetectorMessenger: layout==0.");
|
||||
|
||||
RADMON_CREATE_COMMAND_0ARGS(EnableEnvironment, "Enables the environment");
|
||||
RADMON_CREATE_COMMAND_0ARGS(DisableEnvironment, "Disables the environment");
|
||||
RADMON_CREATE_COMMAND_1ARG (SetEnvironmentType, "Define the type of environment", "type");
|
||||
RADMON_CREATE_COMMAND_2ARGS(SetEnvironmentAttribute, "Define an attribute of the environment", "name", "value");
|
||||
RADMON_CREATE_COMMAND_1ARG (ClearEnvironmentAttribute, "Removes an attribute of the environment", "name");
|
||||
RADMON_CREATE_COMMAND_1ARG (CreateMultilayer, "Creates a new multilayer", "name");
|
||||
RADMON_CREATE_COMMAND_1ARG (RemoveMultilayer, "Removes a multilayer", "name");
|
||||
RADMON_CREATE_COMMAND_3ARGS(SetMultilayerWidth, "Set the width of a multilayer", "name", "width", "unit");
|
||||
RADMON_CREATE_COMMAND_3ARGS(SetMultilayerHeight, "Set the height of a multilayer", "name", "height", "unit");
|
||||
RADMON_CREATE_COMMAND_2ARGS(AppendLayerToMultilayer, "Adds a layer to a multilayer", "multilayerName", "layerName");
|
||||
RADMON_CREATE_COMMAND_2ARGS(RemoveLayerFromMultilayer, "Removes a layer from a multilayer", "multilayerName", "layerName");
|
||||
RADMON_CREATE_COMMAND_1ARG (RemoveAllLayersFromMultilayer, "Removes all the layers of a multilayer", "multilayerName");
|
||||
RADMON_CREATE_COMMAND_4ARGS(SetLayerThickness, "Set the thickness of the layer of a multilayer", "multilayerName", "layerName", "width", "unit");
|
||||
RADMON_CREATE_COMMAND_3ARGS(SetLayerType, "Set the layer type of a multilayer", "multilayerName", "layerName", "type");
|
||||
RADMON_CREATE_COMMAND_4ARGS(SetLayerAttribute, "Set an attribute of a layer of a multilayer", "multilayerName", "layerName", "attributeName", "value");
|
||||
RADMON_CREATE_COMMAND_3ARGS(ClearLayerAttribute, "Removes an attribute of a layer of a multilayer", "multilayerName", "layerName", "attributeName");
|
||||
RADMON_CREATE_COMMAND_2ARGS(CreatePlacement, "Creates a new multilayer placement", "placementName", "multilayerName");
|
||||
RADMON_CREATE_COMMAND_1ARG (RemovePlacement, "Removes a multilayer placement", "name");
|
||||
RADMON_CREATE_COMMAND_5ARGS(SetPlacementPosition, "Changes the position of a placement", "name", "x", "y", "z", "unit");
|
||||
RADMON_CREATE_COMMAND_5ARGS(SetPlacementRotation, "Changes the orientation of a placement performing a rotation of delta along axis (theta, phi)", "name", "theta", "phi", "delta", "unit");
|
||||
RADMON_CREATE_COMMAND_6ARGS(SetRelativePlacementPosition, "Changes the position of a placement relative to another placement", "name", "fromName", "x", "y", "z", "unit");
|
||||
RADMON_CREATE_COMMAND_6ARGS(SetRelativePlacementRotation, "Changes the orientation of a placement relative to another placement", "name", "fromName", "theta", "phi", "delta", "unit");
|
||||
RADMON_CREATE_COMMAND_0ARGS(DumpLayout, "Print out the current layout");
|
||||
RADMON_CREATE_COMMAND_1ARG (Load, "Loads a layout from file", "fileName");
|
||||
RADMON_CREATE_COMMAND_1ARG (Save, "Saves a layout to file", "fileName");
|
||||
}
|
||||
|
||||
|
||||
|
||||
RadmonDetectorMessenger :: ~RadmonDetectorMessenger()
|
||||
{
|
||||
RADMON_DESTROY_COMMAND(Save);
|
||||
RADMON_DESTROY_COMMAND(Load);
|
||||
RADMON_DESTROY_COMMAND(DumpLayout);
|
||||
RADMON_DESTROY_COMMAND(SetRelativePlacementRotation);
|
||||
RADMON_DESTROY_COMMAND(SetRelativePlacementPosition);
|
||||
RADMON_DESTROY_COMMAND(SetPlacementRotation);
|
||||
RADMON_DESTROY_COMMAND(SetPlacementPosition);
|
||||
RADMON_DESTROY_COMMAND(RemovePlacement);
|
||||
RADMON_DESTROY_COMMAND(CreatePlacement);
|
||||
RADMON_DESTROY_COMMAND(ClearLayerAttribute);
|
||||
RADMON_DESTROY_COMMAND(SetLayerAttribute);
|
||||
RADMON_DESTROY_COMMAND(SetLayerType);
|
||||
RADMON_DESTROY_COMMAND(SetLayerThickness);
|
||||
RADMON_DESTROY_COMMAND(RemoveAllLayersFromMultilayer);
|
||||
RADMON_DESTROY_COMMAND(RemoveLayerFromMultilayer);
|
||||
RADMON_DESTROY_COMMAND(AppendLayerToMultilayer);
|
||||
RADMON_DESTROY_COMMAND(SetMultilayerHeight);
|
||||
RADMON_DESTROY_COMMAND(SetMultilayerWidth);
|
||||
RADMON_DESTROY_COMMAND(RemoveMultilayer);
|
||||
RADMON_DESTROY_COMMAND(CreateMultilayer);
|
||||
RADMON_DESTROY_COMMAND(ClearEnvironmentAttribute);
|
||||
RADMON_DESTROY_COMMAND(SetEnvironmentAttribute);
|
||||
RADMON_DESTROY_COMMAND(SetEnvironmentType);
|
||||
RADMON_DESTROY_COMMAND(DisableEnvironment);
|
||||
RADMON_DESTROY_COMMAND(EnableEnvironment);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
G4String RadmonDetectorMessenger :: GetCurrentValue(G4UIcommand * /* command */)
|
||||
{
|
||||
G4cout << "RadmonDetectorMessenger::GetCurrentValue(): Not supported" << G4endl;
|
||||
|
||||
return G4String();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMessenger :: SetNewValue(G4UIcommand * command, G4String newValue)
|
||||
{
|
||||
RADMON_BEGIN_LIST_SET_COMMANDS
|
||||
RADMON_SET_COMMAND(EnableEnvironment)
|
||||
RADMON_SET_COMMAND(DisableEnvironment)
|
||||
RADMON_SET_COMMAND(SetEnvironmentType)
|
||||
RADMON_SET_COMMAND(SetEnvironmentAttribute)
|
||||
RADMON_SET_COMMAND(ClearEnvironmentAttribute)
|
||||
RADMON_SET_COMMAND(CreateMultilayer)
|
||||
RADMON_SET_COMMAND(RemoveMultilayer)
|
||||
RADMON_SET_COMMAND(SetMultilayerWidth)
|
||||
RADMON_SET_COMMAND(SetMultilayerHeight)
|
||||
RADMON_SET_COMMAND(AppendLayerToMultilayer)
|
||||
RADMON_SET_COMMAND(RemoveLayerFromMultilayer)
|
||||
RADMON_SET_COMMAND(RemoveAllLayersFromMultilayer)
|
||||
RADMON_SET_COMMAND(SetLayerThickness)
|
||||
RADMON_SET_COMMAND(SetLayerType)
|
||||
RADMON_SET_COMMAND(SetLayerAttribute)
|
||||
RADMON_SET_COMMAND(ClearLayerAttribute)
|
||||
RADMON_SET_COMMAND(CreatePlacement)
|
||||
RADMON_SET_COMMAND(RemovePlacement)
|
||||
RADMON_SET_COMMAND(SetPlacementPosition)
|
||||
RADMON_SET_COMMAND(SetPlacementRotation)
|
||||
RADMON_SET_COMMAND(SetRelativePlacementPosition)
|
||||
RADMON_SET_COMMAND(SetRelativePlacementRotation)
|
||||
RADMON_SET_COMMAND(DumpLayout)
|
||||
RADMON_SET_COMMAND(Load)
|
||||
RADMON_SET_COMMAND(Save)
|
||||
RADMON_END_LIST_SET_COMMANDS
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Events
|
||||
void RadmonDetectorMessenger :: OnEnableEnvironment(const G4String & /* value */)
|
||||
{
|
||||
detectorLayout->EnableEnvironment();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMessenger :: OnDisableEnvironment(const G4String & /* value */)
|
||||
{
|
||||
detectorLayout->DisableEnvironment();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMessenger :: OnSetEnvironmentType(const G4String & value)
|
||||
{
|
||||
G4String args[1];
|
||||
|
||||
if (!ProcessArguments(value, 1, args))
|
||||
return;
|
||||
|
||||
detectorLayout->SetEnvironmentType(args[0]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMessenger :: OnSetEnvironmentAttribute(const G4String & value)
|
||||
{
|
||||
G4String args[2];
|
||||
|
||||
if (!ProcessArguments(value, 2, args))
|
||||
return;
|
||||
|
||||
detectorLayout->SetEnvironmentAttribute(args[0], args[1]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMessenger :: OnClearEnvironmentAttribute(const G4String & value)
|
||||
{
|
||||
G4String args[1];
|
||||
|
||||
if (!ProcessArguments(value, 1, args))
|
||||
return;
|
||||
|
||||
detectorLayout->ClearEnvironmentAttribute(args[0]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMessenger :: OnCreateMultilayer(const G4String & value)
|
||||
{
|
||||
G4String args[1];
|
||||
|
||||
if (!ProcessArguments(value, 1, args))
|
||||
return;
|
||||
|
||||
detectorLayout->CreateMultilayer(args[0]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMessenger :: OnRemoveMultilayer(const G4String & value)
|
||||
{
|
||||
G4String args[1];
|
||||
|
||||
if (!ProcessArguments(value, 1, args))
|
||||
return;
|
||||
|
||||
detectorLayout->RemoveMultilayer(args[0]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMessenger :: OnSetMultilayerWidth(const G4String & value)
|
||||
{
|
||||
G4String args[3];
|
||||
|
||||
if (!ProcessArguments(value, 3, args))
|
||||
return;
|
||||
|
||||
G4double dbl(GetUnit(args[2], "Length"));
|
||||
|
||||
if (dbl<=0.)
|
||||
return;
|
||||
|
||||
dbl*=G4UIcommand::ConvertToDouble(args[1]);
|
||||
|
||||
if (dbl<0.)
|
||||
{
|
||||
G4cout << "RadmonDetectorMessenger::OnSetMultilayerWidth(): Cannot set negative width." << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
detectorLayout->SetMultilayerWidth(args[0], dbl);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMessenger :: OnSetMultilayerHeight(const G4String & value)
|
||||
{
|
||||
G4String args[3];
|
||||
|
||||
if (!ProcessArguments(value, 3, args))
|
||||
return;
|
||||
|
||||
G4double dbl(GetUnit(args[2], "Length"));
|
||||
|
||||
if (dbl<=0.)
|
||||
return;
|
||||
|
||||
dbl*=G4UIcommand::ConvertToDouble(args[1]);
|
||||
|
||||
if (dbl<0)
|
||||
{
|
||||
G4cout << "RadmonDetectorMessenger::OnSetMultilayerHeight(): Cannot set negative height." << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
detectorLayout->SetMultilayerHeight(args[0], dbl);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMessenger :: OnAppendLayerToMultilayer(const G4String & value)
|
||||
{
|
||||
G4String args[2];
|
||||
|
||||
if (!ProcessArguments(value, 2, args))
|
||||
return;
|
||||
|
||||
detectorLayout->AppendLayerToMultilayer(args[0], args[1]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMessenger :: OnRemoveLayerFromMultilayer(const G4String & value)
|
||||
{
|
||||
G4String args[2];
|
||||
|
||||
if (!ProcessArguments(value, 2, args))
|
||||
return;
|
||||
|
||||
detectorLayout->RemoveLayerFromMultilayer(args[0], args[1]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMessenger :: OnRemoveAllLayersFromMultilayer(const G4String & value)
|
||||
{
|
||||
G4String args[1];
|
||||
|
||||
if (!ProcessArguments(value, 1, args))
|
||||
return;
|
||||
|
||||
detectorLayout->RemoveAllLayersFromMultilayer(args[0]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMessenger :: OnSetLayerThickness(const G4String & value)
|
||||
{
|
||||
G4String args[4];
|
||||
|
||||
if (!ProcessArguments(value, 4, args))
|
||||
return;
|
||||
|
||||
G4double dbl(GetUnit(args[3], "Length"));
|
||||
|
||||
if (dbl<=0.)
|
||||
return;
|
||||
|
||||
if (dbl<0.)
|
||||
{
|
||||
G4cout << "RadmonDetectorMessenger::OnSetLayerThickness(): Cannot set negative thickness." << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
dbl*=G4UIcommand::ConvertToDouble(args[2]);
|
||||
detectorLayout->SetLayerThickness(args[0], args[1], dbl);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMessenger :: OnSetLayerType(const G4String & value)
|
||||
{
|
||||
G4String args[3];
|
||||
|
||||
if (!ProcessArguments(value, 3, args))
|
||||
return;
|
||||
|
||||
detectorLayout->SetLayerType(args[0], args[1], args[2]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMessenger :: OnSetLayerAttribute(const G4String & value)
|
||||
{
|
||||
G4String args[4];
|
||||
|
||||
if (!ProcessArguments(value, 4, args))
|
||||
return;
|
||||
|
||||
detectorLayout->SetLayerAttribute(args[0], args[1], args[2], args[3]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMessenger :: OnClearLayerAttribute(const G4String & value)
|
||||
{
|
||||
G4String args[3];
|
||||
|
||||
if (!ProcessArguments(value, 3, args))
|
||||
return;
|
||||
|
||||
detectorLayout->ClearLayerAttribute(args[0], args[1], args[2]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMessenger :: OnCreatePlacement(const G4String & value)
|
||||
{
|
||||
G4String args[2];
|
||||
|
||||
if (!ProcessArguments(value, 2, args))
|
||||
return;
|
||||
|
||||
detectorLayout->CreatePlacement(args[0], args[1]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMessenger :: OnRemovePlacement(const G4String & value)
|
||||
{
|
||||
G4String args[1];
|
||||
|
||||
if (!ProcessArguments(value, 1, args))
|
||||
return;
|
||||
|
||||
detectorLayout->RemovePlacement(args[0]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMessenger :: OnSetPlacementPosition(const G4String & value)
|
||||
{
|
||||
G4String args[5];
|
||||
|
||||
if (!ProcessArguments(value, 5, args))
|
||||
return;
|
||||
|
||||
G4double x(GetUnit(args[4], "Length"));
|
||||
|
||||
if (x<=0.)
|
||||
return;
|
||||
|
||||
G4double y(x*G4UIcommand::ConvertToDouble(args[2]));
|
||||
G4double z(x*G4UIcommand::ConvertToDouble(args[3]));
|
||||
x*=G4UIcommand::ConvertToDouble(args[1]);
|
||||
|
||||
detectorLayout->SetPlacementPosition(args[0], G4ThreeVector(x, y, z));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMessenger :: OnSetPlacementRotation(const G4String & value)
|
||||
{
|
||||
G4String args[5];
|
||||
|
||||
if (!ProcessArguments(value, 5, args))
|
||||
return;
|
||||
|
||||
G4double theta(GetUnit(args[4], "Angle"));
|
||||
|
||||
if (theta<=0.)
|
||||
return;
|
||||
|
||||
G4double phi(theta*G4UIcommand::ConvertToDouble(args[2]));
|
||||
G4double delta(theta*G4UIcommand::ConvertToDouble(args[3]));
|
||||
theta*=G4UIcommand::ConvertToDouble(args[1]);
|
||||
|
||||
G4ThreeVector axis;
|
||||
axis.setRThetaPhi(1., theta/rad, phi/rad);
|
||||
detectorLayout->SetPlacementRotation(args[0], G4RotationMatrix(axis, delta/rad));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMessenger :: OnSetRelativePlacementPosition(const G4String & value)
|
||||
{
|
||||
G4String args[6];
|
||||
|
||||
if (!ProcessArguments(value, 6, args))
|
||||
return;
|
||||
|
||||
G4double x(GetUnit(args[5], "Length"));
|
||||
|
||||
if (x<=0.)
|
||||
return;
|
||||
|
||||
G4double y(x*G4UIcommand::ConvertToDouble(args[3]));
|
||||
G4double z(x*G4UIcommand::ConvertToDouble(args[4]));
|
||||
x*=G4UIcommand::ConvertToDouble(args[2]);
|
||||
|
||||
detectorLayout->SetPlacementPosition(args[0], args[1], G4ThreeVector(x, y, z));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMessenger :: OnSetRelativePlacementRotation(const G4String & value)
|
||||
{
|
||||
G4String args[6];
|
||||
|
||||
if (!ProcessArguments(value, 6, args))
|
||||
return;
|
||||
|
||||
G4double theta(GetUnit(args[5], "Angle"));
|
||||
|
||||
if (theta<=0.)
|
||||
return;
|
||||
|
||||
G4double phi(theta*G4UIcommand::ConvertToDouble(args[3]));
|
||||
G4double delta(theta*G4UIcommand::ConvertToDouble(args[4]));
|
||||
theta*=G4UIcommand::ConvertToDouble(args[2]);
|
||||
|
||||
G4ThreeVector axis;
|
||||
axis.setRThetaPhi(1., theta, phi);
|
||||
detectorLayout->SetPlacementRotation(args[0], args[1], G4RotationMatrix(axis, delta));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMessenger :: OnDumpLayout(const G4String & /* value */)
|
||||
{
|
||||
detectorLayout->DumpLayout(G4cout);
|
||||
G4cout << G4endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMessenger :: OnLoad(const G4String & value)
|
||||
{
|
||||
G4String args[1];
|
||||
|
||||
if (!ProcessArguments(value, 1, args))
|
||||
return;
|
||||
|
||||
std::istream * in(OpenForInput(args[0]));
|
||||
|
||||
if (!in)
|
||||
return;
|
||||
|
||||
if (!detectorLayout->Load(*in))
|
||||
G4cout << "RadmonDetectorMessenger::OnLoad(): Error reading from file \"" << args[0] << "\"." << G4endl;
|
||||
|
||||
delete in;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMessenger :: OnSave(const G4String & value)
|
||||
{
|
||||
G4String args[1];
|
||||
|
||||
if (!ProcessArguments(value, 1, args))
|
||||
return;
|
||||
|
||||
std::ostream * out(OpenForOutput(args[0]));
|
||||
|
||||
if (!out)
|
||||
return;
|
||||
|
||||
if (!detectorLayout->Save(*out))
|
||||
G4cout << "RadmonDetectorMessenger::OnSave(): Cannot write layout into file \"" << args[0] << "\"." << G4endl;
|
||||
|
||||
delete out;
|
||||
}
|
||||
@@ -0,0 +1,237 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// File name: RadmonDetectorMultilayerLayout.cc
|
||||
// Creation date: Sep 2005
|
||||
// Main author: Riccardo Capra <capra@ge.infn.it>
|
||||
//
|
||||
// Id: $Id: RadmonDetectorMultilayerLayout.cc,v 1.6.2.2 2006/06/29 16:14:03 gunter Exp $
|
||||
// Tag: $Name: geant4-08-01 $
|
||||
//
|
||||
|
||||
// Include files
|
||||
#include "RadmonDetectorMultilayerLayout.hh"
|
||||
#include "RadmonDumpStyle.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
#include <iomanip>
|
||||
|
||||
|
||||
|
||||
RadmonDetectorMultilayerLayout :: RadmonDetectorMultilayerLayout(const RadmonDetectorMultilayerLayout & copy)
|
||||
:
|
||||
multilayerLabel(copy.multilayerLabel),
|
||||
multilayerWidth(copy.multilayerWidth),
|
||||
multilayerHeight(copy.multilayerHeight),
|
||||
multilayerLayersCollection(copy.multilayerLayersCollection)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
RadmonDetectorMultilayerLayout & RadmonDetectorMultilayerLayout :: operator=(const RadmonDetectorMultilayerLayout & copy)
|
||||
{
|
||||
multilayerLabel=copy.multilayerLabel;
|
||||
multilayerWidth=copy.multilayerWidth;
|
||||
multilayerHeight=copy.multilayerHeight;
|
||||
multilayerLayersCollection=copy.multilayerLayersCollection;
|
||||
|
||||
return (*this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
G4double RadmonDetectorMultilayerLayout :: GetTotalThickness(void) const
|
||||
{
|
||||
G4int i(multilayerLayersCollection.GetNItems());
|
||||
G4double thickness(0);
|
||||
|
||||
while (i>0)
|
||||
{
|
||||
i--;
|
||||
thickness+=GetLayer(i).GetThickness();
|
||||
}
|
||||
|
||||
return thickness;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
G4int RadmonDetectorMultilayerLayout :: GetNLayers(void) const
|
||||
{
|
||||
return multilayerLayersCollection.GetNItems();
|
||||
}
|
||||
|
||||
|
||||
|
||||
G4bool RadmonDetectorMultilayerLayout :: Empty(void) const
|
||||
{
|
||||
return multilayerLayersCollection.Empty();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const RadmonDetectorLayerLayout & RadmonDetectorMultilayerLayout :: GetLayer(G4int index) const
|
||||
{
|
||||
return multilayerLayersCollection.GetItem(index);
|
||||
}
|
||||
|
||||
|
||||
|
||||
RadmonDetectorLayerLayout & RadmonDetectorMultilayerLayout :: GetLayer(G4int index)
|
||||
{
|
||||
return multilayerLayersCollection.GetItem(index);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
G4bool RadmonDetectorMultilayerLayout :: ExistsLayerByLabel(const G4String & layerLabel) const
|
||||
{
|
||||
return multilayerLayersCollection.ExistsItemByLabel(layerLabel);
|
||||
}
|
||||
|
||||
|
||||
|
||||
G4int RadmonDetectorMultilayerLayout :: MultiplicityLayerByLabel(const G4String & layerLabel) const
|
||||
{
|
||||
return multilayerLayersCollection.MultiplicityItemByLabel(layerLabel);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const RadmonDetectorLayerLayout & RadmonDetectorMultilayerLayout :: FindLayerByLabel(const G4String & layerLabel, G4int count) const
|
||||
{
|
||||
return multilayerLayersCollection.FindItemByLabel(layerLabel, count);
|
||||
}
|
||||
|
||||
|
||||
|
||||
RadmonDetectorLayerLayout & RadmonDetectorMultilayerLayout :: FindLayerByLabel(const G4String & layerLabel, G4int count)
|
||||
{
|
||||
return multilayerLayersCollection.FindItemByLabel(layerLabel, count);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
RadmonDetectorLayerLayout & RadmonDetectorMultilayerLayout :: AppendLayer(void)
|
||||
{
|
||||
return multilayerLayersCollection.AppendItem();
|
||||
}
|
||||
|
||||
|
||||
|
||||
RadmonDetectorLayerLayout & RadmonDetectorMultilayerLayout :: PrependLayer(void)
|
||||
{
|
||||
return multilayerLayersCollection.PrependItem();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMultilayerLayout :: RemoveLayerByLabel(const G4String & layerLabel, G4int count)
|
||||
{
|
||||
multilayerLayersCollection.RemoveItemByLabel(layerLabel, count);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMultilayerLayout :: RemoveLayersByLabel(const G4String & layerLabel)
|
||||
{
|
||||
multilayerLayersCollection.RemoveItemsByLabel(layerLabel);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMultilayerLayout :: RemoveLayer(G4int index)
|
||||
{
|
||||
multilayerLayersCollection.RemoveItem(index);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMultilayerLayout :: RemoveLayersByRange(G4int first, G4int last)
|
||||
{
|
||||
multilayerLayersCollection.RemoveItemsByRange(first, last);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMultilayerLayout :: RemoveAllLayers(void)
|
||||
{
|
||||
multilayerLayersCollection.RemoveAllItems();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMultilayerLayout :: DumpLayout(std::ostream & out, const G4String & indent) const
|
||||
{
|
||||
G4int width(RADMONDUMP_INDENT_WIDTH-indent.length());
|
||||
if (width<0)
|
||||
width=0;
|
||||
|
||||
out << indent << std::setw(width); out.setf(std::ostream::left, std::ostream::adjustfield); out << "Label"; out.setf(std::ostream::right, std::ostream::adjustfield); out << " = \"" << multilayerLabel << "\"\n"
|
||||
<< indent << std::setw(width); out.setf(std::ostream::left, std::ostream::adjustfield); out << "Size"; out.setf(std::ostream::right, std::ostream::adjustfield); out << " = (W) " << std::setprecision(RADMONDUMP_DOUBLE_PRECISION) << std::setw(RADMONDUMP_DOUBLE_WIDTH) << G4BestUnit(multilayerWidth, "Length")
|
||||
<< " x (H) " << std::setprecision(RADMONDUMP_DOUBLE_PRECISION) << std::setw(RADMONDUMP_DOUBLE_WIDTH) << G4BestUnit(multilayerHeight, "Length")
|
||||
<< " x (T) " << std::setprecision(RADMONDUMP_DOUBLE_PRECISION) << std::setw(RADMONDUMP_DOUBLE_WIDTH) << G4BestUnit(GetTotalThickness(), "Length") << '\n';
|
||||
|
||||
G4String indent2(indent);
|
||||
indent2.prepend(" ");
|
||||
|
||||
const G4int n(multilayerLayersCollection.GetNItems());
|
||||
|
||||
if (n==0)
|
||||
{
|
||||
out << indent2 << "No layers defined.\n";
|
||||
return;
|
||||
}
|
||||
|
||||
G4String indent3(indent2);
|
||||
indent3.prepend(" ");
|
||||
|
||||
for(G4int i(0); i<n; i++)
|
||||
{
|
||||
out << indent2 << "Layer # " << i << '\n';
|
||||
|
||||
GetLayer(i).DumpLayout(out, indent3);
|
||||
}
|
||||
}
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// File name: RadmonDetectorMultilayerPlacementLayout.cc
|
||||
// Creation date: Sep 2005
|
||||
// Main author: Riccardo Capra <capra@ge.infn.it>
|
||||
//
|
||||
// Id: $Id: RadmonDetectorMultilayerPlacementLayout.cc,v 1.5 2006/06/29 16:14:05 gunter Exp $
|
||||
// Tag: $Name: geant4-08-01 $
|
||||
//
|
||||
|
||||
// Include files
|
||||
#include "RadmonDetectorMultilayerPlacementLayout.hh"
|
||||
#include "RadmonDumpStyle.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
#include <iomanip>
|
||||
|
||||
|
||||
|
||||
G4ThreeVector RadmonDetectorMultilayerPlacementLayout :: GetRelativePosition(const RadmonDetectorMultilayerPlacementLayout & reference) const
|
||||
{
|
||||
G4ThreeVector v(multilayerPosition);
|
||||
v-=reference.multilayerPosition;
|
||||
|
||||
return reference.multilayerRotation.inverse()*v;
|
||||
}
|
||||
|
||||
|
||||
|
||||
G4RotationMatrix RadmonDetectorMultilayerPlacementLayout :: GetRelativeRotation(const RadmonDetectorMultilayerPlacementLayout & reference) const
|
||||
{
|
||||
return reference.multilayerRotation.inverse()*multilayerRotation;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMultilayerPlacementLayout :: SetRelativePosition(const RadmonDetectorMultilayerPlacementLayout & reference, const G4ThreeVector & position)
|
||||
{
|
||||
multilayerPosition=reference.multilayerRotation*position;
|
||||
multilayerPosition+=reference.multilayerPosition;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMultilayerPlacementLayout :: SetRelativeRotation(const RadmonDetectorMultilayerPlacementLayout & reference, const G4RotationMatrix & rotation)
|
||||
{
|
||||
multilayerRotation=reference.multilayerRotation;
|
||||
multilayerRotation*=rotation;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMultilayerPlacementLayout :: DumpLayout(std::ostream & out, const G4String &indent) const
|
||||
{
|
||||
G4int width(RADMONDUMP_INDENT_WIDTH-indent.length());
|
||||
if (width<0)
|
||||
width=0;
|
||||
|
||||
G4int width2(width+4+indent.length());
|
||||
|
||||
out << indent << std::setw(width); out.setf(std::ostream::left, std::ostream::adjustfield); out << "Label"; out.setf(std::ostream::right, std::ostream::adjustfield); out << " = \"" << placementLabel << "\"\n"
|
||||
<< indent << std::setw(width); out.setf(std::ostream::left, std::ostream::adjustfield); out << "Multilayer label"; out.setf(std::ostream::right, std::ostream::adjustfield); out << " = \"" << multilayerLabel << "\"\n"
|
||||
<< indent << std::setw(width); out.setf(std::ostream::left, std::ostream::adjustfield); out << "Position"; out.setf(std::ostream::right, std::ostream::adjustfield); out << " = (" << std::setprecision(RADMONDUMP_DOUBLE_PRECISION) << std::setw(RADMONDUMP_DOUBLE_WIDTH) << G4BestUnit(multilayerPosition.getX(), "Length") << ", "
|
||||
<< std::setprecision(RADMONDUMP_DOUBLE_PRECISION) << std::setw(RADMONDUMP_DOUBLE_WIDTH) << G4BestUnit(multilayerPosition.getY(), "Length") << ", "
|
||||
<< std::setprecision(RADMONDUMP_DOUBLE_PRECISION) << std::setw(RADMONDUMP_DOUBLE_WIDTH) << G4BestUnit(multilayerPosition.getZ(), "Length") << ")\n"
|
||||
<< std::setw(width2); out.setf(std::ostream::right, std::ostream::adjustfield); out << "|" << std::setprecision(RADMONDUMP_DOUBLE_PRECISION) << std::setw(RADMONDUMP_DOUBLE_WIDTH) << multilayerRotation.xx() << ", " << std::setprecision(RADMONDUMP_DOUBLE_PRECISION) << std::setw(RADMONDUMP_DOUBLE_WIDTH) << multilayerRotation.xy() << ", " << std::setprecision(RADMONDUMP_DOUBLE_PRECISION) << std::setw(RADMONDUMP_DOUBLE_WIDTH) << multilayerRotation.xz() << "|\n"
|
||||
<< indent << std::setw(width); out.setf(std::ostream::left, std::ostream::adjustfield); out << "Rotation"; out.setf(std::ostream::right, std::ostream::adjustfield); out << " = |" << std::setprecision(RADMONDUMP_DOUBLE_PRECISION) << std::setw(RADMONDUMP_DOUBLE_WIDTH) << multilayerRotation.yx() << ", " << std::setprecision(RADMONDUMP_DOUBLE_PRECISION) << std::setw(RADMONDUMP_DOUBLE_WIDTH) << multilayerRotation.yy() << ", " << std::setprecision(RADMONDUMP_DOUBLE_PRECISION) << std::setw(RADMONDUMP_DOUBLE_WIDTH) << multilayerRotation.yz() << "|\n"
|
||||
<< std::setw(width2); out.setf(std::ostream::right, std::ostream::adjustfield); out << "|" << std::setprecision(RADMONDUMP_DOUBLE_PRECISION) << std::setw(RADMONDUMP_DOUBLE_WIDTH) << multilayerRotation.zx() << ", " << std::setprecision(RADMONDUMP_DOUBLE_PRECISION) << std::setw(RADMONDUMP_DOUBLE_WIDTH) << multilayerRotation.zy() << ", " << std::setprecision(RADMONDUMP_DOUBLE_PRECISION) << std::setw(RADMONDUMP_DOUBLE_WIDTH) << multilayerRotation.zz() << "|\n";
|
||||
}
|
||||
+162
@@ -0,0 +1,162 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// File name: RadmonDetectorMultilayerPlacementsLayoutCollection.cc
|
||||
// Creation date: Sep 2005
|
||||
// Main author: Riccardo Capra <capra@ge.infn.it>
|
||||
//
|
||||
// Id: $Id: RadmonDetectorMultilayerPlacementsLayoutCollection.cc,v 1.4 2006/06/29 16:14:07 gunter Exp $
|
||||
// Tag: $Name: geant4-08-01 $
|
||||
//
|
||||
|
||||
// Include files
|
||||
#include "RadmonDetectorMultilayerPlacementsLayoutCollection.hh"
|
||||
|
||||
|
||||
|
||||
G4int RadmonDetectorMultilayerPlacementsLayoutCollection :: GetNPlacements(void) const
|
||||
{
|
||||
return multilayerPlacementsCollection.GetNItems();
|
||||
}
|
||||
|
||||
|
||||
|
||||
G4bool RadmonDetectorMultilayerPlacementsLayoutCollection :: Empty(void) const
|
||||
{
|
||||
return multilayerPlacementsCollection.Empty();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const RadmonDetectorMultilayerPlacementLayout & RadmonDetectorMultilayerPlacementsLayoutCollection :: GetPlacement(G4int index) const
|
||||
{
|
||||
return multilayerPlacementsCollection.GetItem(index);
|
||||
}
|
||||
|
||||
|
||||
|
||||
RadmonDetectorMultilayerPlacementLayout & RadmonDetectorMultilayerPlacementsLayoutCollection :: GetPlacement(G4int index)
|
||||
{
|
||||
return multilayerPlacementsCollection.GetItem(index);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
G4bool RadmonDetectorMultilayerPlacementsLayoutCollection :: ExistsPlacementByLabel(const G4String & label) const
|
||||
{
|
||||
return multilayerPlacementsCollection.ExistsItemByLabel(label);
|
||||
}
|
||||
|
||||
|
||||
|
||||
G4int RadmonDetectorMultilayerPlacementsLayoutCollection :: MultiplicityPlacementByLabel(const G4String & label) const
|
||||
{
|
||||
return multilayerPlacementsCollection.MultiplicityItemByLabel(label);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const RadmonDetectorMultilayerPlacementLayout & RadmonDetectorMultilayerPlacementsLayoutCollection :: FindPlacementByLabel(const G4String & label, G4int count) const
|
||||
{
|
||||
return multilayerPlacementsCollection.FindItemByLabel(label, count);
|
||||
}
|
||||
|
||||
|
||||
|
||||
RadmonDetectorMultilayerPlacementLayout & RadmonDetectorMultilayerPlacementsLayoutCollection :: FindPlacementByLabel(const G4String & label, G4int count)
|
||||
{
|
||||
return multilayerPlacementsCollection.FindItemByLabel(label, count);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
RadmonDetectorMultilayerPlacementLayout & RadmonDetectorMultilayerPlacementsLayoutCollection :: CreatePlacement(void)
|
||||
{
|
||||
return multilayerPlacementsCollection.AppendItem();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMultilayerPlacementsLayoutCollection :: RemovePlacementByLabel(const G4String & label, G4int count)
|
||||
{
|
||||
multilayerPlacementsCollection.RemoveItemByLabel(label, count);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMultilayerPlacementsLayoutCollection :: RemovePlacementsByLabel(const G4String & label)
|
||||
{
|
||||
multilayerPlacementsCollection.RemoveItemsByLabel(label);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMultilayerPlacementsLayoutCollection :: RemovePlacement(G4int index)
|
||||
{
|
||||
multilayerPlacementsCollection.RemoveItem(index);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMultilayerPlacementsLayoutCollection :: RemoveAllPlacements(void)
|
||||
{
|
||||
multilayerPlacementsCollection.RemoveAllItems();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMultilayerPlacementsLayoutCollection :: DumpLayout(std::ostream & out, const G4String & indent) const
|
||||
{
|
||||
G4String indent2(indent);
|
||||
indent2.prepend(" ");
|
||||
|
||||
const G4int n(multilayerPlacementsCollection.GetNItems());
|
||||
|
||||
if (n==0)
|
||||
out << indent << "No placements defined.\n";
|
||||
|
||||
for(G4int i(0); i<n; i++)
|
||||
{
|
||||
if (i!=0)
|
||||
out << '\n';
|
||||
|
||||
out << indent << "Placement # " << i << '\n';
|
||||
|
||||
GetPlacement(i).DumpLayout(out, indent2);
|
||||
}
|
||||
}
|
||||
+167
@@ -0,0 +1,167 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// File name: RadmonDetectorMultilayersLayoutCollection.cc
|
||||
// Creation date: Sep 2005
|
||||
// Main author: Riccardo Capra <capra@ge.infn.it>
|
||||
//
|
||||
// Id: $Id: RadmonDetectorMultilayersLayoutCollection.cc,v 1.5 2006/06/29 16:14:09 gunter Exp $
|
||||
// Tag: $Name: geant4-08-01 $
|
||||
//
|
||||
|
||||
// Include files
|
||||
#include "RadmonDetectorMultilayersLayoutCollection.hh"
|
||||
#include "RadmonDumpStyle.hh"
|
||||
#include <iomanip>
|
||||
|
||||
|
||||
|
||||
G4int RadmonDetectorMultilayersLayoutCollection :: GetNMultilayers(void) const
|
||||
{
|
||||
return multilayersCollection.GetNItems();
|
||||
}
|
||||
|
||||
|
||||
|
||||
G4bool RadmonDetectorMultilayersLayoutCollection :: Empty(void) const
|
||||
{
|
||||
return multilayersCollection.Empty();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const RadmonDetectorMultilayerLayout & RadmonDetectorMultilayersLayoutCollection :: GetMultilayer(G4int index) const
|
||||
{
|
||||
return multilayersCollection.GetItem(index);
|
||||
}
|
||||
|
||||
|
||||
|
||||
RadmonDetectorMultilayerLayout & RadmonDetectorMultilayersLayoutCollection :: GetMultilayer(G4int index)
|
||||
{
|
||||
return multilayersCollection.GetItem(index);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
G4bool RadmonDetectorMultilayersLayoutCollection :: ExistsMultilayerByLabel(const G4String & label) const
|
||||
{
|
||||
return multilayersCollection.ExistsItemByLabel(label);
|
||||
}
|
||||
|
||||
|
||||
|
||||
G4int RadmonDetectorMultilayersLayoutCollection :: MultiplicityMultilayerByLabel(const G4String & label) const
|
||||
{
|
||||
return multilayersCollection.MultiplicityItemByLabel(label);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const RadmonDetectorMultilayerLayout & RadmonDetectorMultilayersLayoutCollection :: FindMultilayerByLabel(const G4String & label, G4int count) const
|
||||
{
|
||||
return multilayersCollection.FindItemByLabel(label, count);
|
||||
}
|
||||
|
||||
|
||||
|
||||
RadmonDetectorMultilayerLayout & RadmonDetectorMultilayersLayoutCollection :: FindMultilayerByLabel(const G4String & label, G4int count)
|
||||
{
|
||||
return multilayersCollection.FindItemByLabel(label, count);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
RadmonDetectorMultilayerLayout & RadmonDetectorMultilayersLayoutCollection :: CreateMultilayer(void)
|
||||
{
|
||||
return multilayersCollection.AppendItem();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMultilayersLayoutCollection :: RemoveMultilayerByLabel(const G4String & label, G4int count)
|
||||
{
|
||||
multilayersCollection.RemoveItemByLabel(label, count);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMultilayersLayoutCollection :: RemoveMultilayersByLabel(const G4String & label)
|
||||
{
|
||||
multilayersCollection.RemoveItemsByLabel(label);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMultilayersLayoutCollection :: RemoveMultilayer(G4int index)
|
||||
{
|
||||
multilayersCollection.RemoveItem(index);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMultilayersLayoutCollection :: RemoveAllMultilayers(void)
|
||||
{
|
||||
multilayersCollection.RemoveAllItems();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorMultilayersLayoutCollection :: DumpLayout(std::ostream & out, const G4String & indent) const
|
||||
{
|
||||
const G4int n(multilayersCollection.GetNItems());
|
||||
|
||||
if (n==0)
|
||||
{
|
||||
out << indent << "No multilayers defined.\n";
|
||||
return;
|
||||
}
|
||||
|
||||
G4String indent2(indent);
|
||||
indent2.prepend(" ");
|
||||
|
||||
for(G4int i(0); i<n; i++)
|
||||
{
|
||||
if (i!=0)
|
||||
out << '\n';
|
||||
|
||||
out << indent << "Multilayer # " << i << '\n';
|
||||
|
||||
GetMultilayer(i).DumpLayout(out, indent2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// File name: RadmonDetectorPadsData.cc
|
||||
// Creation date: Sep 2005
|
||||
// Main author: Riccardo Capra <capra@ge.infn.it>
|
||||
//
|
||||
// Id: $Id: RadmonDetectorPadsData.cc,v 1.3 2006/06/29 16:14:11 gunter Exp $
|
||||
// Tag: $Name: geant4-08-01 $
|
||||
//
|
||||
|
||||
// Include files
|
||||
#include "RadmonDetectorPadsData.hh"
|
||||
#include "RadmonMessenger.hh"
|
||||
|
||||
RadmonDetectorPadsData :: RadmonDetectorPadsData(const RadmonDetectorPadsData & copy)
|
||||
:
|
||||
padWidth(copy.padWidth),
|
||||
padHeight(copy.padHeight),
|
||||
padMaterial(copy.padMaterial),
|
||||
padPositions(copy.padPositions),
|
||||
padRotations(copy.padRotations)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
G4int RadmonDetectorPadsData :: GetNPads(void) const
|
||||
{
|
||||
return padPositions.size();
|
||||
}
|
||||
|
||||
|
||||
|
||||
const G4ThreeVector & RadmonDetectorPadsData :: GetPosition(G4int index) const
|
||||
{
|
||||
return padPositions[index];
|
||||
}
|
||||
|
||||
|
||||
|
||||
const G4RotationMatrix & RadmonDetectorPadsData :: GetRotation(G4int index) const
|
||||
{
|
||||
return padRotations[index];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void RadmonDetectorPadsData :: AppendPositionAndRotation(const G4ThreeVector & position, const G4RotationMatrix & rotation)
|
||||
{
|
||||
padPositions.push_back(position);
|
||||
padRotations.push_back(rotation);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
RadmonDetectorPadsData & RadmonDetectorPadsData :: operator=(const RadmonDetectorPadsData & copy)
|
||||
{
|
||||
padWidth=copy.padWidth;
|
||||
padHeight=copy.padHeight;
|
||||
padMaterial=copy.padMaterial;
|
||||
padPositions=copy.padPositions;
|
||||
padRotations=copy.padRotations;
|
||||
|
||||
return (*this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool RadmonDetectorPadsData :: ReadPositionsAndRotationsFromString(const G4String & positionStr)
|
||||
{
|
||||
// (xx mm, yy mm, [delta deg])
|
||||
|
||||
G4bool somethingDone(false);
|
||||
G4String positions(positionStr);
|
||||
str_size i(0);
|
||||
const str_size size(positions.length());
|
||||
|
||||
while (i<size)
|
||||
{
|
||||
if (positions(i)==' ')
|
||||
{
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (positions(i)=='(')
|
||||
{
|
||||
str_size j(positions.index(')', i));
|
||||
|
||||
if (j==G4String::npos)
|
||||
return false;
|
||||
|
||||
somethingDone=true;
|
||||
G4String content(positions(i+1, j-i-1));
|
||||
|
||||
G4double x;
|
||||
G4double y;
|
||||
G4double delta;
|
||||
if (!ProcessElement(x, y, delta, content))
|
||||
return false;
|
||||
|
||||
G4RotationMatrix rotation(G4RotationMatrix::IDENTITY);
|
||||
rotation.setDelta(delta);
|
||||
AppendPositionAndRotation(G4ThreeVector(x, y, 0.), rotation);
|
||||
|
||||
i=j+1;
|
||||
continue;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return somethingDone;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool RadmonDetectorPadsData :: ProcessElement(G4double & x, G4double & y, G4double & delta, const G4String & content)
|
||||
{
|
||||
G4String cont(content);
|
||||
|
||||
str_size i(cont.index(','));
|
||||
str_size size(cont.length());
|
||||
while (size>1)
|
||||
{
|
||||
if (cont(size-1)!=' ')
|
||||
break;
|
||||
|
||||
size--;
|
||||
}
|
||||
|
||||
if (i==G4String::npos)
|
||||
return false;
|
||||
|
||||
if (!ReadUmis(x, cont(0, i), "Length"))
|
||||
return false;
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
i++;
|
||||
|
||||
if (i>=size)
|
||||
return false;
|
||||
}
|
||||
while (cont(i)==' ');
|
||||
|
||||
str_size j(cont.index(',', i));
|
||||
|
||||
if (j==G4String::npos)
|
||||
{
|
||||
delta=0.*deg;
|
||||
|
||||
return ReadUmis(y, cont(i, size-i), "Length");
|
||||
}
|
||||
|
||||
if (!ReadUmis(y, cont(i+1, j-i-1), "Length"))
|
||||
return false;
|
||||
|
||||
do
|
||||
{
|
||||
j++;
|
||||
|
||||
if (j>=size)
|
||||
return false;
|
||||
}
|
||||
while (cont(j)==' ');
|
||||
|
||||
return ReadUmis(y, cont(j, size-j), "Angle");
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool RadmonDetectorPadsData :: ReadUmis(G4double & value, const G4String & text, const char * category)
|
||||
{
|
||||
G4String args[2];
|
||||
|
||||
if (!RadmonMessenger::ProcessArguments(text, 2, args))
|
||||
return false;
|
||||
|
||||
value=RadmonMessenger::GetUnit(args[1], category);
|
||||
if (value<=0.)
|
||||
return false;
|
||||
|
||||
value*=G4UIcommand::ConvertToDouble(args[0]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
+260
@@ -0,0 +1,260 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// File name: RadmonVDetectorLabelledEntityConstructor.cc
|
||||
// Creation date: Sep 2005
|
||||
// Main author: Riccardo Capra <capra@ge.infn.it>
|
||||
//
|
||||
// Id: $Id: RadmonVDetectorLabelledEntityConstructor.cc,v 1.7 2006/06/29 16:14:13 gunter Exp $
|
||||
// Tag: $Name: geant4-08-01 $
|
||||
//
|
||||
|
||||
// Include files
|
||||
#include "RadmonVDetectorLabelledEntityConstructor.hh"
|
||||
#include "RadmonTokenizer.hh"
|
||||
#include "RadmonMaterialsManager.hh"
|
||||
#include "RadmonSensitiveDetector.hh"
|
||||
#include "G4SDManager.hh"
|
||||
#include "G4UIcommand.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
G4double RadmonVDetectorLabelledEntityConstructor :: GetWidth(void) const
|
||||
{
|
||||
G4double value(GetAttributeAsMeasure("_WIDTH", "Length", -1.));
|
||||
|
||||
if (value>=0)
|
||||
return value;
|
||||
|
||||
value=GetAttributeAsMeasure("Width", "Length", -1.);
|
||||
|
||||
if (value>=0)
|
||||
return value;
|
||||
|
||||
G4cout << "RadmonVDetectorLabelledEntityConstructor::GetWidth: \"Width\" attribute not defined." << G4endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
G4double RadmonVDetectorLabelledEntityConstructor :: GetHeight(void) const
|
||||
{
|
||||
G4double value(GetAttributeAsMeasure("_HEIGHT", "Length", -1.));
|
||||
|
||||
if (value>=0)
|
||||
return value;
|
||||
|
||||
value=GetAttributeAsMeasure("Height", "Length", -1.);
|
||||
|
||||
if (value>=0)
|
||||
return value;
|
||||
|
||||
G4cout << "RadmonVDetectorLabelledEntityConstructor::GetHeight: \"Height\" attribute not defined." << G4endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
G4double RadmonVDetectorLabelledEntityConstructor :: GetThickness(void) const
|
||||
{
|
||||
G4double value(GetAttributeAsMeasure("_THICKNESS", "Length", -1.));
|
||||
|
||||
if (value>=0)
|
||||
return value;
|
||||
|
||||
value=GetAttributeAsMeasure("Thickness", "Length", -1.);
|
||||
|
||||
if (value>=0)
|
||||
return value;
|
||||
|
||||
G4cout << "RadmonVDetectorLabelledEntityConstructor::GetThickness: \"Thickness\" attribute not defined." << G4endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
G4Material * RadmonVDetectorLabelledEntityConstructor :: GetMaterial(const G4String & attributeName) const
|
||||
{
|
||||
G4String materialStr(GetAttribute(attributeName, "#"));
|
||||
if (materialStr=="#")
|
||||
{
|
||||
G4cout << "RadmonDetectorSimpleBoxConstructor::ConstructLogicalVolume: \"" << attributeName << "\" attribute not defined." << G4endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
RadmonMaterialsManager * manager(RadmonMaterialsManager::Instance());
|
||||
if (!manager->ExistsMaterial(materialStr))
|
||||
{
|
||||
G4cout << "RadmonDetectorSimpleBoxConstructor::ConstructLogicalVolume: \"" << materialStr << "\" material not existent." << G4endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return &manager->GetMaterial(materialStr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
G4VisAttributes * RadmonVDetectorLabelledEntityConstructor :: AllocateVisAttributes(const G4String & attributeName, const G4Material * material) const
|
||||
{
|
||||
G4VisAttributes * visAttribute=new G4VisAttributes;
|
||||
|
||||
G4String materialName(material->GetName());
|
||||
|
||||
RadmonMaterialsManager * instance(RadmonMaterialsManager::Instance());
|
||||
|
||||
visAttribute->SetColor(instance->GetMaterialColor(materialName));
|
||||
visAttribute->SetVisibility(instance->GetMaterialVisibility(materialName));
|
||||
if (instance->GetMaterialForceSolid(materialName))
|
||||
visAttribute->SetForceSolid(true);
|
||||
else if (instance->GetMaterialForceWireframe(materialName))
|
||||
visAttribute->SetForceWireframe(true);
|
||||
|
||||
G4String str;
|
||||
str=GetAttribute(attributeName, "#");
|
||||
if (str!="#")
|
||||
{
|
||||
G4String arg;
|
||||
RadmonTokenizer args(str);
|
||||
|
||||
G4bool forceSolid(visAttribute->GetForcedDrawingStyle()==G4VisAttributes::solid && visAttribute->IsForceDrawingStyle());
|
||||
G4bool forceWireframe(visAttribute->GetForcedDrawingStyle()==G4VisAttributes::wireframe && visAttribute->IsForceDrawingStyle());
|
||||
G4bool visible(visAttribute->IsVisible());
|
||||
G4double alpha(visAttribute->GetColor().GetAlpha());
|
||||
G4double red(visAttribute->GetColor().GetRed());
|
||||
G4double green(visAttribute->GetColor().GetGreen());
|
||||
G4double blue(visAttribute->GetColor().GetBlue());
|
||||
|
||||
G4bool forceFound(false);
|
||||
G4bool visibleFound(false);
|
||||
G4int missingColors(4);
|
||||
|
||||
for (G4int i(0); i<6; i++)
|
||||
{
|
||||
if (args.eos())
|
||||
break;
|
||||
|
||||
arg=args();
|
||||
|
||||
if (arg=="hidden" || arg=="visible")
|
||||
{
|
||||
if (visibleFound || missingColors==2 || missingColors==3)
|
||||
{
|
||||
missingColors=-1;
|
||||
break;
|
||||
}
|
||||
|
||||
visibleFound=true;
|
||||
|
||||
visible=(arg=="visible");
|
||||
}
|
||||
else if (arg=="wireframe" || arg=="solid" || arg=="default")
|
||||
{
|
||||
if (forceFound || missingColors==2 || missingColors==3)
|
||||
{
|
||||
missingColors=-1;
|
||||
break;
|
||||
}
|
||||
|
||||
forceFound=true;
|
||||
|
||||
forceWireframe=(arg=="wireframe");
|
||||
forceSolid=(arg=="solid");
|
||||
}
|
||||
else
|
||||
{
|
||||
G4double component(G4UIcommand::ConvertToDouble(arg));
|
||||
if (component>1 || component<0 || missingColors==0)
|
||||
{
|
||||
missingColors=-1;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(missingColors)
|
||||
{
|
||||
case 4:
|
||||
red=component;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
green=component;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
blue=component;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
alpha=component;
|
||||
break;
|
||||
}
|
||||
|
||||
missingColors--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (missingColors!=0 && missingColors!=4 && missingColors!=1)
|
||||
G4cout << "RadmonVDetectorLabelledEntityConstructor::AllocateVisAttribute: Invalid visualization attribute in \"" << attributeName << "\"." << G4endl;
|
||||
else
|
||||
{
|
||||
visAttribute->SetColor(red, green, blue, alpha);
|
||||
visAttribute->SetVisibility(visible);
|
||||
if (forceWireframe)
|
||||
visAttribute->SetForceWireframe(true);
|
||||
else if (forceSolid)
|
||||
visAttribute->SetForceSolid(true);
|
||||
}
|
||||
}
|
||||
|
||||
return visAttribute;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
G4VSensitiveDetector * RadmonVDetectorLabelledEntityConstructor :: AllocateSensitiveDetector(const G4String & attributeName, const G4String & defaultAttrbuteValue) const
|
||||
{
|
||||
G4String name(GetAttribute(attributeName, defaultAttrbuteValue));
|
||||
|
||||
if (name.empty())
|
||||
return 0;
|
||||
|
||||
G4SDManager * manager(G4SDManager::GetSDMpointer());
|
||||
|
||||
G4VSensitiveDetector * sensitiveDetector(manager->FindSensitiveDetector(name, false));
|
||||
|
||||
if (sensitiveDetector)
|
||||
return sensitiveDetector;
|
||||
|
||||
return new RadmonSensitiveDetector(name);
|
||||
}
|
||||
|
||||
+245
@@ -0,0 +1,245 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// File name: RadmonVDetectorLayerVolumeItemOperation.cc
|
||||
// Creation date: Sep 2005
|
||||
// Main author: Riccardo Capra <capra@ge.infn.it>
|
||||
//
|
||||
// Id: $Id: RadmonVDetectorLayerVolumeItemOperation.cc,v 1.3 2006/06/29 16:14:15 gunter Exp $
|
||||
// Tag: $Name: geant4-08-01 $
|
||||
//
|
||||
|
||||
// Include files
|
||||
#include "RadmonVDetectorLayerVolumeItemOperation.hh"
|
||||
#include "RadmonDetectorLayerVolumeItem.hh"
|
||||
#include "G4VSolid.hh"
|
||||
|
||||
void RadmonVDetectorLayerVolumeItemOperation :: Initialize(G4VSolid * solid, const G4RotationMatrix & rotation, const G4ThreeVector & position, G4bool ownSolid)
|
||||
{
|
||||
Validate();
|
||||
|
||||
leftRotation=rotation;
|
||||
invLeftRotation=rotation.inverse();
|
||||
leftPosition=position;
|
||||
leftSolid=solid;
|
||||
|
||||
if (ownSolid)
|
||||
ownedSolids.push(solid);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonVDetectorLayerVolumeItemOperation :: Initialize(G4VSolid * solid, const G4ThreeVector & position, G4bool ownSolid)
|
||||
{
|
||||
Validate();
|
||||
|
||||
leftRotation=G4RotationMatrix::IDENTITY;
|
||||
invLeftRotation=G4RotationMatrix::IDENTITY;
|
||||
leftPosition=position;
|
||||
leftSolid=solid;
|
||||
|
||||
if (ownSolid)
|
||||
ownedSolids.push(solid);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonVDetectorLayerVolumeItemOperation :: Initialize(G4VSolid * solid, G4bool ownSolid)
|
||||
{
|
||||
Validate();
|
||||
|
||||
leftRotation=G4RotationMatrix::IDENTITY;
|
||||
invLeftRotation=G4RotationMatrix::IDENTITY;
|
||||
leftPosition=G4ThreeVector(0, 0, 0);
|
||||
leftSolid=solid;
|
||||
|
||||
if (ownSolid)
|
||||
ownedSolids.push(solid);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonVDetectorLayerVolumeItemOperation :: Initialize(const RadmonDetectorLayerVolumeItem * item)
|
||||
{
|
||||
Validate();
|
||||
|
||||
leftSolid=item->GetSolid();
|
||||
|
||||
Absolute(item, leftRotation, leftPosition);
|
||||
invLeftRotation=leftRotation.inverse();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
G4VSolid * RadmonVDetectorLayerVolumeItemOperation :: ApplyTo(G4VSolid * solid, const G4RotationMatrix & rotation, const G4ThreeVector & position, G4bool ownSolid, G4bool ownResult)
|
||||
{
|
||||
if (ownSolid)
|
||||
ownedSolids.push(solid);
|
||||
|
||||
G4ThreeVector relativePosition;
|
||||
ownedMatrices.push(G4RotationMatrix::IDENTITY);
|
||||
Merge(rotation, position, ownedMatrices.top(), relativePosition);
|
||||
|
||||
G4VSolid * result(Operate(leftSolid, solid, &ownedMatrices.top(), relativePosition));
|
||||
|
||||
if (ownResult)
|
||||
ownedSolids.push(result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonVDetectorLayerVolumeItemOperation :: ApplyTo(RadmonDetectorLayerVolumeItem * item, G4bool ownResult)
|
||||
{
|
||||
G4ThreeVector rightPosition;
|
||||
G4RotationMatrix rightRotation;
|
||||
Absolute(item, rightRotation, rightPosition);
|
||||
|
||||
G4ThreeVector relativePosition;
|
||||
ownedMatrices.push(G4RotationMatrix::IDENTITY);
|
||||
Merge(rightRotation, rightPosition, ownedMatrices.top(), relativePosition);
|
||||
|
||||
G4VSolid * result(Operate(leftSolid, item->GetSolid(), &ownedMatrices.top(), relativePosition));
|
||||
|
||||
if (ownResult)
|
||||
ownedSolids.push(result);
|
||||
|
||||
item->SetSolid(result);
|
||||
item->SetPosition(leftPosition);
|
||||
item->SetRotation(leftRotation);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
RadmonVDetectorLayerVolumeItemOperation :: RadmonVDetectorLayerVolumeItemOperation(G4VSolid * solid, const G4RotationMatrix & rotation, const G4ThreeVector & position, G4bool ownSolid)
|
||||
:
|
||||
leftRotation(rotation),
|
||||
invLeftRotation(rotation.inverse()),
|
||||
leftPosition(position),
|
||||
leftSolid(solid)
|
||||
{
|
||||
if (ownSolid)
|
||||
ownedSolids.push(solid);
|
||||
}
|
||||
|
||||
|
||||
|
||||
RadmonVDetectorLayerVolumeItemOperation :: RadmonVDetectorLayerVolumeItemOperation(G4VSolid * solid, const G4ThreeVector & position, G4bool ownSolid)
|
||||
:
|
||||
leftRotation(G4RotationMatrix::IDENTITY),
|
||||
invLeftRotation(G4RotationMatrix::IDENTITY),
|
||||
leftPosition(position),
|
||||
leftSolid(solid)
|
||||
{
|
||||
if (ownSolid)
|
||||
ownedSolids.push(solid);
|
||||
}
|
||||
|
||||
|
||||
|
||||
RadmonVDetectorLayerVolumeItemOperation :: RadmonVDetectorLayerVolumeItemOperation(G4VSolid * solid, G4bool ownSolid)
|
||||
:
|
||||
leftRotation(G4RotationMatrix::IDENTITY),
|
||||
invLeftRotation(G4RotationMatrix::IDENTITY),
|
||||
leftPosition(0, 0, 0),
|
||||
leftSolid(solid)
|
||||
{
|
||||
if (ownSolid)
|
||||
ownedSolids.push(solid);
|
||||
}
|
||||
|
||||
|
||||
|
||||
RadmonVDetectorLayerVolumeItemOperation :: RadmonVDetectorLayerVolumeItemOperation(const RadmonDetectorLayerVolumeItem * item)
|
||||
:
|
||||
leftSolid(item->GetSolid())
|
||||
{
|
||||
Absolute(item, leftRotation, leftPosition);
|
||||
invLeftRotation=leftRotation.inverse();
|
||||
}
|
||||
|
||||
|
||||
|
||||
RadmonVDetectorLayerVolumeItemOperation :: ~RadmonVDetectorLayerVolumeItemOperation()
|
||||
{
|
||||
while (! ownedSolids.empty())
|
||||
{
|
||||
delete ownedSolids.top();
|
||||
ownedSolids.pop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
inline void RadmonVDetectorLayerVolumeItemOperation :: Validate()
|
||||
{
|
||||
if (leftSolid!=0 || (!ownedSolids.empty()))
|
||||
G4Exception("RadmonVDetectorLayerVolumeItemOperation::Validate: Initialization happened twice.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void RadmonVDetectorLayerVolumeItemOperation :: Merge(const G4RotationMatrix & rightRotation, const G4ThreeVector & rightPosition, G4RotationMatrix & relativeRotation, G4ThreeVector & relativePosition) const
|
||||
{
|
||||
// X_a = O_r + R_r * X_r X_r --> X_a
|
||||
// X_a = O_l + R_l * X_l X_l --> X_a
|
||||
// X_l = R_l^-1 * (O_r - O_l) + R_l^-1 * R_r * X_r X_r --> X_l
|
||||
|
||||
relativeRotation=rightRotation;
|
||||
relativeRotation.transform(invLeftRotation);
|
||||
|
||||
relativePosition=rightPosition;
|
||||
relativePosition-=leftPosition;
|
||||
relativePosition.transform(invLeftRotation);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RadmonVDetectorLayerVolumeItemOperation :: Absolute(const RadmonDetectorLayerVolumeItem * item, G4RotationMatrix & rotation, G4ThreeVector & position) const
|
||||
{
|
||||
rotation=item->GetRotation();
|
||||
position=item->GetPosition();
|
||||
|
||||
for(;;)
|
||||
{
|
||||
item=item->GetMotherVolumeItem();
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
rotation.transform(item->GetRotation());
|
||||
position.transform(item->GetRotation());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user