From c068c897b26ca9f4f7e7c6ba5c20d86b5bf0a9f1 Mon Sep 17 00:00:00 2001 From: Morfouace <pierre.morfouace@gmail.com> Date: Thu, 19 Mar 2020 08:58:17 +0100 Subject: [PATCH] updating scone geometry --- NPSimulation/Detectors/Scone/Scone.cc | 245 +++++++++++++++++++------- NPSimulation/Detectors/Scone/Scone.hh | 24 ++- 2 files changed, 197 insertions(+), 72 deletions(-) diff --git a/NPSimulation/Detectors/Scone/Scone.cc b/NPSimulation/Detectors/Scone/Scone.cc index 8d042e41e..35b23f69b 100644 --- a/NPSimulation/Detectors/Scone/Scone.cc +++ b/NPSimulation/Detectors/Scone/Scone.cc @@ -37,6 +37,7 @@ #include "G4PVPlacement.hh" #include "G4VisAttributes.hh" #include "G4Colour.hh" +#include "G4SubtractionSolid.hh" // NPTool header #include "Scone.hh" @@ -62,7 +63,9 @@ namespace Scone_NS{ const double ResoEnergy = 1.0*MeV ; const double XSection = 25.1*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"; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -72,56 +75,93 @@ namespace Scone_NS{ Scone::Scone(){ m_Event = new TSconeData() ; m_SconeScorer = 0; + m_SquareDetector = 0; - //m_CylindricalDetector = 0; + m_BuildRing1 = 1; + m_BuildRing2 = 1; + + m_Assembly = 0; // RGB Color + Transparency 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(){ } //....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 m_R.push_back(POS.mag()); m_Theta.push_back(POS.theta()); 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...... -G4AssemblyVolume* Scone::Build6x6Assembly(){ +G4AssemblyVolume* Scone::Build2x2Assembly(){ if(!m_SquareDetector){ - m_6x6Assembly = new G4AssemblyVolume(); + m_2x2Assembly = 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,Scone_NS::Length*0.5); + Scone_NS::YSection*0.5,Scone_NS::Length2x2*0.5); G4Material* DetectorMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary(Scone_NS::Material); 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); - Tv.setX(0); - m_6x6Assembly->AddPlacedVolume(m_SquareDetector, Tv, Rv); - Tv.setX(Scone_NS::XSection); - m_6x6Assembly->AddPlacedVolume(m_SquareDetector, Tv, Rv); + double posX = 0; + double posY = 0; + for(int i=0; i<2; i++){ + 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; @@ -132,7 +172,7 @@ G4AssemblyVolume* Scone::Build6x6Assembly(){ G4LogicalVolume* Scone::BuildSquareDetector(){ if(!m_SquareDetector){ 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); m_SquareDetector = new G4LogicalVolume(box,DetectorMaterial,"logic_Scone_Box",0,0,0); @@ -154,8 +194,7 @@ void Scone::ReadConfiguration(NPL::InputParser parser){ if(NPOptionManager::getInstance()->GetVerboseLevel()) cout << "//// " << blocks.size() << " detectors found " << endl; - vector<string> cart = {"POS","Shape"}; - vector<string> sphe = {"R","Theta","Phi","Shape"}; + vector<string> cart = {"POS","Ring1","Ring2"}; for(unsigned int i = 0 ; i < blocks.size() ; i++){ if(blocks[i]->HasTokenList(cart)){ @@ -163,17 +202,9 @@ void Scone::ReadConfiguration(NPL::InputParser parser){ cout << endl << "//// Scone " << i+1 << endl; G4ThreeVector Pos = NPS::ConvertVector(blocks[i]->GetTVector3("POS","mm")); - string Shape = blocks[i]->GetString("Shape"); - AddDetector(Pos,Shape); - } - 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); + m_BuildRing1 = blocks[i]->GetInt("Ring1"); + m_BuildRing2 = blocks[i]->GetInt("Ring2"); + AddDetector(Pos); } else{ cout << "ERROR: check your input file formatting " << endl; @@ -188,35 +219,123 @@ void Scone::ReadConfiguration(NPL::InputParser parser){ // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method void Scone::ConstructDetector(G4LogicalVolume* world){ - for (unsigned short i = 0 ; i < m_R.size() ; i++) { - - G4double wX = m_R[i] * sin(m_Theta[i] ) * cos(m_Phi[i] ) ; - G4double wY = m_R[i] * sin(m_Theta[i] ) * sin(m_Phi[i] ) ; - G4double wZ = m_R[i] * cos(m_Theta[i] ) ; - G4ThreeVector Det_pos = G4ThreeVector(wX, wY, wZ) ; - // So the face of the detector is at R instead of the middle - Det_pos+=Det_pos.unit()*Scone_NS::Length*0.5; - // Building Detector reference frame - G4double ii = cos(m_Theta[i]) * cos(m_Phi[i]); - G4double jj = cos(m_Theta[i]) * sin(m_Phi[i]); - G4double kk = -sin(m_Theta[i]); - G4ThreeVector Y(ii,jj,kk); - G4ThreeVector w = Det_pos.unit(); - G4ThreeVector u = w.cross(Y); - G4ThreeVector v = w.cross(u); - v = v.unit(); - u = u.unit(); - - 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); + Build2x2Block(world); + + if(m_BuildRing1==1) + BuildRing1(world); + + if(m_BuildRing2==1) + BuildRing2(world); +} +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void Scone::Build2x2Block(G4LogicalVolume* world){ + + G4RotationMatrix* Rot = new G4RotationMatrix(0,0,0); + double posX_orig = -0.5*Scone_NS::XSection; + double posX_neg = posX_orig - 2*Scone_NS::XSection; + double posX_pos = posX_orig + 2*Scone_NS::XSection; + double posY_orig = -0.5*Scone_NS::YSection; + double posY_neg = posY_orig - 2*Scone_NS::YSection; + double posY_pos = posY_orig + 2*Scone_NS::YSection; - } + 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...... // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method diff --git a/NPSimulation/Detectors/Scone/Scone.hh b/NPSimulation/Detectors/Scone/Scone.hh index 85d081043..431e8232c 100644 --- a/NPSimulation/Detectors/Scone/Scone.hh +++ b/NPSimulation/Detectors/Scone/Scone.hh @@ -50,18 +50,18 @@ class Scone : public NPS::VDetector{ /////// Specific Function of this Class /////////// //////////////////////////////////////////////////// public: - // Cartesian - void AddDetector(G4ThreeVector POS, string Shape); - // Spherical - void AddDetector(double R,double Theta,double Phi,string Shape); + void AddDetector(G4ThreeVector POS); - - G4AssemblyVolume* Build4x4Assembly(); - G4AssemblyVolume* Build6x6Assembly(); + G4AssemblyVolume* Build2x2Assembly(); + G4AssemblyVolume* Build6x6Assembly(double plastic_length); G4LogicalVolume* BuildSquareDetector(); + + void Build2x2Block(G4LogicalVolume* world); + void BuildRing1(G4LogicalVolume* world); + void BuildRing2(G4LogicalVolume* world); private: - G4AssemblyVolume* m_4x4Assembly; + G4AssemblyVolume* m_2x2Assembly; G4AssemblyVolume* m_6x6Assembly; G4LogicalVolume* m_SquareDetector; @@ -106,12 +106,18 @@ class Scone : public NPS::VDetector{ vector<double> m_Theta; vector<double> m_Phi; + int m_BuildRing1; + int m_BuildRing2; + int m_Assembly; + // Shape type vector<string> m_Shape ; // Visualisation Attribute G4VisAttributes* m_VisSquare; - G4VisAttributes* m_VisCylinder; + G4VisAttributes* m_Vis2x2; + G4VisAttributes* m_Vis6x6; + G4VisAttributes* m_Vis6x6R2; // Needed for dynamic loading of the library public: -- GitLab