Skip to content
Snippets Groups Projects
Commit c068c897 authored by Morfouace's avatar Morfouace
Browse files

updating scone geometry

parent 6ce31ad8
No related branches found
No related tags found
No related merge requests found
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "G4PVPlacement.hh" #include "G4PVPlacement.hh"
#include "G4VisAttributes.hh" #include "G4VisAttributes.hh"
#include "G4Colour.hh" #include "G4Colour.hh"
#include "G4SubtractionSolid.hh"
// NPTool header // NPTool header
#include "Scone.hh" #include "Scone.hh"
...@@ -62,7 +63,9 @@ namespace Scone_NS{ ...@@ -62,7 +63,9 @@ namespace Scone_NS{
const double ResoEnergy = 1.0*MeV ; const double ResoEnergy = 1.0*MeV ;
const double XSection = 25.1*mm ; const double XSection = 25.1*mm ;
const double YSection = 25.6*mm ; const double YSection = 25.6*mm ;
const double Length = 1000*mm ; const double LengthR1 = 1000*mm ;
const double LengthR2 = 500*mm ;
const double Length2x2 = 400*mm ;
const string Material = "CH2"; const string Material = "CH2";
} }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
...@@ -72,56 +75,93 @@ namespace Scone_NS{ ...@@ -72,56 +75,93 @@ namespace Scone_NS{
Scone::Scone(){ Scone::Scone(){
m_Event = new TSconeData() ; m_Event = new TSconeData() ;
m_SconeScorer = 0; m_SconeScorer = 0;
m_SquareDetector = 0; m_SquareDetector = 0;
//m_CylindricalDetector = 0;
m_BuildRing1 = 1;
m_BuildRing2 = 1;
m_Assembly = 0;
// RGB Color + Transparency // RGB Color + Transparency
m_VisSquare = new G4VisAttributes(G4Colour(0, 1, 0, 0.5)); m_VisSquare = new G4VisAttributes(G4Colour(0, 1, 0, 0.5));
//m_VisCylinder = new G4VisAttributes(G4Colour(0, 0, 1, 0.5)); m_Vis2x2 = new G4VisAttributes(G4Colour(0, 0.5, 0.6, 1.0));
m_Vis6x6 = new G4VisAttributes(G4Colour(0.2, 1, 1, 1));
m_Vis6x6R2 = new G4VisAttributes(G4Colour(0.2, 0.8, 0.6, 0.8));
} }
Scone::~Scone(){ Scone::~Scone(){
} }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Scone::AddDetector(G4ThreeVector POS, string Shape){ void Scone::AddDetector(G4ThreeVector POS){
// Convert the POS value to R theta Phi as Spherical coordinate is easier in G4 // Convert the POS value to R theta Phi as Spherical coordinate is easier in G4
m_R.push_back(POS.mag()); m_R.push_back(POS.mag());
m_Theta.push_back(POS.theta()); m_Theta.push_back(POS.theta());
m_Phi.push_back(POS.phi()); m_Phi.push_back(POS.phi());
m_Shape.push_back(Shape);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Scone::AddDetector(double R, double Theta, double Phi, string Shape){
m_R.push_back(R);
m_Theta.push_back(Theta);
m_Phi.push_back(Phi);
m_Shape.push_back(Shape);
} }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4AssemblyVolume* Scone::Build6x6Assembly(){ G4AssemblyVolume* Scone::Build2x2Assembly(){
if(!m_SquareDetector){ if(!m_SquareDetector){
m_6x6Assembly = new G4AssemblyVolume(); m_2x2Assembly = new G4AssemblyVolume();
G4RotationMatrix *Rv = new G4RotationMatrix(0,0,0); G4RotationMatrix *Rv = new G4RotationMatrix(0,0,0);
G4ThreeVector Tv; G4ThreeVector Tv;
Tv.setX(0); Tv.setY(0); Tv.setZ(0); Tv.setX(0); Tv.setY(0); Tv.setZ(0);
// One bar definitation // One bar definitation
G4Box* box = new G4Box("Scone_Box",Scone_NS::XSection*0.5, G4Box* box = new G4Box("Scone_Box",Scone_NS::XSection*0.5,
Scone_NS::YSection*0.5,Scone_NS::Length*0.5); Scone_NS::YSection*0.5,Scone_NS::Length2x2*0.5);
G4Material* DetectorMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary(Scone_NS::Material); G4Material* DetectorMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary(Scone_NS::Material);
m_SquareDetector = new G4LogicalVolume(box,DetectorMaterial,"logic_Scone_Box",0,0,0); m_SquareDetector = new G4LogicalVolume(box,DetectorMaterial,"logic_Scone_Box",0,0,0);
m_SquareDetector->SetVisAttributes(m_VisSquare); m_SquareDetector->SetVisAttributes(m_Vis2x2);
m_SquareDetector->SetSensitiveDetector(m_SconeScorer); m_SquareDetector->SetSensitiveDetector(m_SconeScorer);
Tv.setX(0); double posX = 0;
m_6x6Assembly->AddPlacedVolume(m_SquareDetector, Tv, Rv); double posY = 0;
Tv.setX(Scone_NS::XSection); for(int i=0; i<2; i++){
m_6x6Assembly->AddPlacedVolume(m_SquareDetector, Tv, Rv); for(int j=0; j<2; j++){
posX = i*Scone_NS::XSection;
posY = j*Scone_NS::YSection;
Tv.setX(posX);
Tv.setY(posY);
m_2x2Assembly->AddPlacedVolume(m_SquareDetector, Tv, Rv);
}
}
}
return m_2x2Assembly;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4AssemblyVolume* Scone::Build6x6Assembly(double plastic_length){
m_6x6Assembly = new G4AssemblyVolume();
G4RotationMatrix *Rv = new G4RotationMatrix(0,0,0);
G4ThreeVector Tv;
Tv.setX(0); Tv.setY(0); Tv.setZ(0);
// One bar definitation
G4Box* box = new G4Box("Scone_Box",Scone_NS::XSection*0.5,
Scone_NS::YSection*0.5,plastic_length*0.5);
G4Material* DetectorMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary(Scone_NS::Material);
m_SquareDetector = new G4LogicalVolume(box,DetectorMaterial,"logic_Scone_Box",0,0,0);
if(plastic_length == Scone_NS::LengthR2)
m_SquareDetector->SetVisAttributes(m_Vis6x6R2);
else
m_SquareDetector->SetVisAttributes(m_Vis6x6);
m_SquareDetector->SetSensitiveDetector(m_SconeScorer);
double posX = 0;
double posY = 0;
for(int i=0; i<6; i++){
for(int j=0; j<6; j++){
posX = i*Scone_NS::XSection;
posY = j*Scone_NS::YSection;
Tv.setX(posX);
Tv.setY(posY);
m_6x6Assembly->AddPlacedVolume(m_SquareDetector, Tv, Rv);
}
} }
return m_6x6Assembly; return m_6x6Assembly;
...@@ -132,7 +172,7 @@ G4AssemblyVolume* Scone::Build6x6Assembly(){ ...@@ -132,7 +172,7 @@ G4AssemblyVolume* Scone::Build6x6Assembly(){
G4LogicalVolume* Scone::BuildSquareDetector(){ G4LogicalVolume* Scone::BuildSquareDetector(){
if(!m_SquareDetector){ if(!m_SquareDetector){
G4Box* box = new G4Box("Scone_Box",Scone_NS::XSection*0.5, G4Box* box = new G4Box("Scone_Box",Scone_NS::XSection*0.5,
Scone_NS::YSection*0.5,Scone_NS::Length*0.5); Scone_NS::YSection*0.5,Scone_NS::LengthR1*0.5);
G4Material* DetectorMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary(Scone_NS::Material); G4Material* DetectorMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary(Scone_NS::Material);
m_SquareDetector = new G4LogicalVolume(box,DetectorMaterial,"logic_Scone_Box",0,0,0); m_SquareDetector = new G4LogicalVolume(box,DetectorMaterial,"logic_Scone_Box",0,0,0);
...@@ -154,8 +194,7 @@ void Scone::ReadConfiguration(NPL::InputParser parser){ ...@@ -154,8 +194,7 @@ void Scone::ReadConfiguration(NPL::InputParser parser){
if(NPOptionManager::getInstance()->GetVerboseLevel()) if(NPOptionManager::getInstance()->GetVerboseLevel())
cout << "//// " << blocks.size() << " detectors found " << endl; cout << "//// " << blocks.size() << " detectors found " << endl;
vector<string> cart = {"POS","Shape"}; vector<string> cart = {"POS","Ring1","Ring2"};
vector<string> sphe = {"R","Theta","Phi","Shape"};
for(unsigned int i = 0 ; i < blocks.size() ; i++){ for(unsigned int i = 0 ; i < blocks.size() ; i++){
if(blocks[i]->HasTokenList(cart)){ if(blocks[i]->HasTokenList(cart)){
...@@ -163,17 +202,9 @@ void Scone::ReadConfiguration(NPL::InputParser parser){ ...@@ -163,17 +202,9 @@ void Scone::ReadConfiguration(NPL::InputParser parser){
cout << endl << "//// Scone " << i+1 << endl; cout << endl << "//// Scone " << i+1 << endl;
G4ThreeVector Pos = NPS::ConvertVector(blocks[i]->GetTVector3("POS","mm")); G4ThreeVector Pos = NPS::ConvertVector(blocks[i]->GetTVector3("POS","mm"));
string Shape = blocks[i]->GetString("Shape"); m_BuildRing1 = blocks[i]->GetInt("Ring1");
AddDetector(Pos,Shape); m_BuildRing2 = blocks[i]->GetInt("Ring2");
} AddDetector(Pos);
else if(blocks[i]->HasTokenList(sphe)){
if(NPOptionManager::getInstance()->GetVerboseLevel())
cout << endl << "//// Scone " << i+1 << endl;
double R = blocks[i]->GetDouble("R","mm");
double Theta = blocks[i]->GetDouble("Theta","deg");
double Phi = blocks[i]->GetDouble("Phi","deg");
string Shape = blocks[i]->GetString("Shape");
AddDetector(R,Theta,Phi,Shape);
} }
else{ else{
cout << "ERROR: check your input file formatting " << endl; cout << "ERROR: check your input file formatting " << endl;
...@@ -188,35 +219,123 @@ void Scone::ReadConfiguration(NPL::InputParser parser){ ...@@ -188,35 +219,123 @@ void Scone::ReadConfiguration(NPL::InputParser parser){
// Construct detector and inialise sensitive part. // Construct detector and inialise sensitive part.
// Called After DetecorConstruction::AddDetector Method // Called After DetecorConstruction::AddDetector Method
void Scone::ConstructDetector(G4LogicalVolume* world){ void Scone::ConstructDetector(G4LogicalVolume* world){
for (unsigned short i = 0 ; i < m_R.size() ; i++) { Build2x2Block(world);
G4double wX = m_R[i] * sin(m_Theta[i] ) * cos(m_Phi[i] ) ; if(m_BuildRing1==1)
G4double wY = m_R[i] * sin(m_Theta[i] ) * sin(m_Phi[i] ) ; BuildRing1(world);
G4double wZ = m_R[i] * cos(m_Theta[i] ) ;
G4ThreeVector Det_pos = G4ThreeVector(wX, wY, wZ) ; if(m_BuildRing2==1)
// So the face of the detector is at R instead of the middle BuildRing2(world);
Det_pos+=Det_pos.unit()*Scone_NS::Length*0.5; }
// Building Detector reference frame //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double ii = cos(m_Theta[i]) * cos(m_Phi[i]); void Scone::Build2x2Block(G4LogicalVolume* world){
G4double jj = cos(m_Theta[i]) * sin(m_Phi[i]);
G4double kk = -sin(m_Theta[i]); G4RotationMatrix* Rot = new G4RotationMatrix(0,0,0);
G4ThreeVector Y(ii,jj,kk); double posX_orig = -0.5*Scone_NS::XSection;
G4ThreeVector w = Det_pos.unit(); double posX_neg = posX_orig - 2*Scone_NS::XSection;
G4ThreeVector u = w.cross(Y); double posX_pos = posX_orig + 2*Scone_NS::XSection;
G4ThreeVector v = w.cross(u); double posY_orig = -0.5*Scone_NS::YSection;
v = v.unit(); double posY_neg = posY_orig - 2*Scone_NS::YSection;
u = u.unit(); double posY_pos = posY_orig + 2*Scone_NS::YSection;
G4RotationMatrix* Rot = new G4RotationMatrix(u,v,w);
Build6x6Assembly()->MakeImprint(world,Det_pos,Rot,i);
//new G4PVPlacement(G4Transform3D(*Rot,Det_pos),
// BuildSquareDetector(),
// "Scone",world,false,i+1);
} double posX[16] = {posX_orig, posX_orig, posX_neg, posX_neg, posX_neg, posX_pos, posX_pos, posX_pos, posX_orig, posX_orig, posX_neg, posX_neg, posX_neg, posX_pos, posX_pos, posX_pos};
double posY[16] = {posY_neg, posY_pos, posY_neg, posY_orig, posY_pos, posY_neg, posY_orig, posY_pos, posY_neg, posY_pos, posY_neg, posY_orig, posY_pos, posY_neg, posY_orig, posY_pos};
double posZ[16] = {-300,-300,-300,-300,-300,-300,-300,-300,300,300,300,300,300,300,300,300};
G4ThreeVector Det_pos;
for(int i=0; i<16; i++)
{
Det_pos = G4ThreeVector(posX[i], posY[i], posZ[i]);
Build2x2Assembly()->MakeImprint(world, Det_pos, Rot, m_Assembly);
m_Assembly++;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Scone::BuildRing1(G4LogicalVolume* world){
G4RotationMatrix* Rot = new G4RotationMatrix(0,0,0);
double posX_orig = -2.5*Scone_NS::XSection;
double posX_neg = posX_orig - 6*Scone_NS::XSection;
double posX_pos = posX_orig + 6*Scone_NS::XSection;
double posY_orig = -2.5*Scone_NS::YSection;
double posY_neg = posY_orig - 6*Scone_NS::YSection;
double posY_pos = posY_orig + 6*Scone_NS::YSection;
double posX[8] = {posX_orig, posX_orig, posX_neg, posX_neg, posX_neg, posX_pos, posX_pos, posX_pos};
double posY[8] = {posY_neg, posY_pos, posY_neg, posY_orig, posY_pos, posY_neg, posY_orig, posY_pos};
double posZ[8] = {0,0,0,0,0,0,0,0};
G4ThreeVector Det_pos;
for(int i=0; i<8; i++)
{
Det_pos = G4ThreeVector(posX[i], posY[i], posZ[i]);
Build6x6Assembly(Scone_NS::LengthR1)->MakeImprint(world, Det_pos, Rot, m_Assembly);
m_Assembly++;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Scone::BuildRing2(G4LogicalVolume* world){
G4RotationMatrix* Rot = new G4RotationMatrix(0,0,0);
double posX_orig = -2.5*Scone_NS::XSection;
double posX_left = posX_orig - 12*Scone_NS::XSection;
double posX_right = posX_orig + 12*Scone_NS::XSection;
double posY_orig = -2.5*Scone_NS::YSection;
double posY_down = posY_orig - 12*Scone_NS::YSection;
double posY_up = posY_orig + 12*Scone_NS::YSection;
//double posX[16] = {posX_left, posX_left, posX_left, posX_left, posX_left};
//double posY[16] = {posY_down};
//double posZ[16] = {0};
G4ThreeVector Det_pos;
for(int i=0; i<5; i++)
{
double posX = posX_left;
double posY = posY_down + 6*i*Scone_NS::YSection;
Det_pos = G4ThreeVector(posX, posY, 0);
Build6x6Assembly(Scone_NS::LengthR2)->MakeImprint(world, Det_pos, Rot, m_Assembly);
m_Assembly++;
}
for(int i=0; i<5; i++)
{
double posX = posX_right;
double posY = posY_down + 6*i*Scone_NS::YSection;
Det_pos = G4ThreeVector(posX, posY, 0);
Build6x6Assembly(Scone_NS::LengthR2)->MakeImprint(world, Det_pos, Rot, m_Assembly);
m_Assembly++;
}
Det_pos = G4ThreeVector(posX_left + 6*Scone_NS::XSection, posY_down, 0);
Build6x6Assembly(Scone_NS::LengthR2)->MakeImprint(world, Det_pos, Rot, m_Assembly);
m_Assembly++;
Det_pos = G4ThreeVector(posX_left + 12*Scone_NS::XSection, posY_down, 0);
Build6x6Assembly(Scone_NS::LengthR2)->MakeImprint(world, Det_pos, Rot, m_Assembly);
m_Assembly++;
Det_pos = G4ThreeVector(posX_left + 18*Scone_NS::XSection, posY_down, 0);
Build6x6Assembly(Scone_NS::LengthR2)->MakeImprint(world, Det_pos, Rot, m_Assembly);
m_Assembly++;
Det_pos = G4ThreeVector(posX_left + 6*Scone_NS::XSection, posY_up, 0);
Build6x6Assembly(Scone_NS::LengthR2)->MakeImprint(world, Det_pos, Rot, m_Assembly);
m_Assembly++;
Det_pos = G4ThreeVector(posX_left + 12*Scone_NS::XSection, posY_up, 0);
Build6x6Assembly(Scone_NS::LengthR2)->MakeImprint(world, Det_pos, Rot, m_Assembly);
m_Assembly++;
Det_pos = G4ThreeVector(posX_left + 18*Scone_NS::XSection, posY_up, 0);
Build6x6Assembly(Scone_NS::LengthR2)->MakeImprint(world, Det_pos, Rot, m_Assembly);
m_Assembly++;
} }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
// Add Detector branch to the EventTree. // Add Detector branch to the EventTree.
// Called After DetecorConstruction::AddDetector Method // Called After DetecorConstruction::AddDetector Method
......
...@@ -50,18 +50,18 @@ class Scone : public NPS::VDetector{ ...@@ -50,18 +50,18 @@ class Scone : public NPS::VDetector{
/////// Specific Function of this Class /////////// /////// Specific Function of this Class ///////////
//////////////////////////////////////////////////// ////////////////////////////////////////////////////
public: public:
// Cartesian void AddDetector(G4ThreeVector POS);
void AddDetector(G4ThreeVector POS, string Shape);
// Spherical
void AddDetector(double R,double Theta,double Phi,string Shape);
G4AssemblyVolume* Build2x2Assembly();
G4AssemblyVolume* Build4x4Assembly(); G4AssemblyVolume* Build6x6Assembly(double plastic_length);
G4AssemblyVolume* Build6x6Assembly();
G4LogicalVolume* BuildSquareDetector(); G4LogicalVolume* BuildSquareDetector();
void Build2x2Block(G4LogicalVolume* world);
void BuildRing1(G4LogicalVolume* world);
void BuildRing2(G4LogicalVolume* world);
private: private:
G4AssemblyVolume* m_4x4Assembly; G4AssemblyVolume* m_2x2Assembly;
G4AssemblyVolume* m_6x6Assembly; G4AssemblyVolume* m_6x6Assembly;
G4LogicalVolume* m_SquareDetector; G4LogicalVolume* m_SquareDetector;
...@@ -106,12 +106,18 @@ class Scone : public NPS::VDetector{ ...@@ -106,12 +106,18 @@ class Scone : public NPS::VDetector{
vector<double> m_Theta; vector<double> m_Theta;
vector<double> m_Phi; vector<double> m_Phi;
int m_BuildRing1;
int m_BuildRing2;
int m_Assembly;
// Shape type // Shape type
vector<string> m_Shape ; vector<string> m_Shape ;
// Visualisation Attribute // Visualisation Attribute
G4VisAttributes* m_VisSquare; G4VisAttributes* m_VisSquare;
G4VisAttributes* m_VisCylinder; G4VisAttributes* m_Vis2x2;
G4VisAttributes* m_Vis6x6;
G4VisAttributes* m_Vis6x6R2;
// Needed for dynamic loading of the library // Needed for dynamic loading of the library
public: public:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment