From 817e4b81e8b1be2c32da1478c3ef7094f6a99554 Mon Sep 17 00:00:00 2001 From: Adrien Matta <matta@lpccaen.in2p3.fr> Date: Tue, 17 May 2022 18:00:34 +0200 Subject: [PATCH] * Fixing Invisible disparition from Geant4 - now replaced by GetInvisible() for some reason --- NPSimulation/Core/Chamber.cc | 5749 ++++++++--------- NPSimulation/Core/DetectorConstruction.cc | 172 +- NPSimulation/Core/MaterialManager.cc | 394 +- NPSimulation/Detectors/AnnularS1/AnnularS1.cc | 351 +- NPSimulation/Detectors/Catana/Catana.cc | 712 +- .../ComptonTelescope/ComptonTelescope.cc | 1391 ++-- NPSimulation/Detectors/CsI/CsI.cc | 838 ++- NPSimulation/Detectors/Eurogam/Eurogam.cc | 997 ++- NPSimulation/Detectors/Exogam/Exogam.cc | 734 +-- NPSimulation/Detectors/Fatima/Fatima.cc | 271 +- .../Detectors/GASPARD/GaspardScorers.hh | 517 +- .../GASPARD/GaspardTrackerAnnular.cc | 860 ++- .../GASPARD/GaspardTrackerDummyShape.cc | 1357 ++-- NPSimulation/Detectors/GeTAMU/GeTAMU.cc | 685 +- NPSimulation/Detectors/Helios/Helios.cc | 362 +- NPSimulation/Detectors/Hira/Hira.cc | 901 ++- .../Detectors/Hyde2/Hyde2TrackerSquare1.cc | 2069 +++--- .../Detectors/Hyde2/Hyde2TrackerTrapezoid1.cc | 2140 +++--- .../Detectors/Hyde2/Hyde2TrackerTrapezoid2.cc | 2141 +++--- NPSimulation/Detectors/Lassa/Lassa.cc | 601 +- NPSimulation/Detectors/LightPipe/LightPipe.cc | 745 ++- NPSimulation/Detectors/MUST2/MUST2Array.cc | 836 +-- NPSimulation/Detectors/Miniball/Miniball.cc | 308 +- NPSimulation/Detectors/Minos/Minos.cc | 709 +- NPSimulation/Detectors/Mugast/Mugast.cc | 739 +-- NPSimulation/Detectors/Nana/Nana.cc | 477 +- NPSimulation/Detectors/Paris/Paris.cc | 408 +- NPSimulation/Detectors/Pyramid/Pyramid.cc | 565 +- NPSimulation/Detectors/QQQ/QQQ.cc | 406 +- NPSimulation/Detectors/SSSD/SSSD.cc | 330 +- NPSimulation/Detectors/Sharc/Sharc.cc | 757 +-- NPSimulation/Detectors/Spice/Spice.cc | 127 +- NPSimulation/Detectors/Strasse/Strasse.cc | 1518 ++--- NPSimulation/Detectors/SuperX3/SuperX3.cc | 2 +- NPSimulation/Detectors/Tiara/Tiara.cc | 852 ++- NPSimulation/Detectors/Tigress/Tigress.cc | 664 +- NPSimulation/Detectors/W1/W1.cc | 934 ++- NPSimulation/Detectors/eAGanil/eAGanil.cc | 302 +- 38 files changed, 15995 insertions(+), 17926 deletions(-) diff --git a/NPSimulation/Core/Chamber.cc b/NPSimulation/Core/Chamber.cc index 8f1d79f13..3473e11df 100644 --- a/NPSimulation/Core/Chamber.cc +++ b/NPSimulation/Core/Chamber.cc @@ -30,382 +30,369 @@ #endif // G4 geometry header -#include "G4Tubs.hh" -#include "G4Sphere.hh" #include "G4Box.hh" -#include "G4Trap.hh" #include "G4Polycone.hh" +#include "G4Sphere.hh" #include "G4SubtractionSolid.hh" +#include "G4Trap.hh" +#include "G4Tubs.hh" -//G4 various headers +// G4 various headers #include "G4Colour.hh" -#include "G4NistManager.hh" // NIST database of material -#include "G4Material.hh" -#include "G4MaterialTable.hh" #include "G4Element.hh" #include "G4ElementTable.hh" -#include "G4RotationMatrix.hh" -#include "G4PVPlacement.hh" -#include "G4VPhysicalVolume.hh" -#include "G4PVPlacement.hh" -#include "G4VisAttributes.hh" -#include "G4Colour.hh" #include "G4EmCalculator.hh" +#include "G4Material.hh" +#include "G4MaterialTable.hh" +#include "G4NistManager.hh" // NIST database of material +#include "G4PVPlacement.hh" #include "G4ParticleDefinition.hh" #include "G4ParticleTable.hh" +#include "G4RotationMatrix.hh" +#include "G4VPhysicalVolume.hh" +#include "G4VisAttributes.hh" #include "Randomize.hh" -using namespace CLHEP ; +using namespace CLHEP; // NPTool header -#include"Chamber.hh" -#include"MaterialManager.hh" +#include "Chamber.hh" +#include "MaterialManager.hh" #include "NPOptionManager.h" using namespace std; - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Specific Method of this class -Chamber::Chamber(): nStripsX(60),nStripsY(40) -{ - - - //m_ChamberType = true; - m_ChamberType = 0 ; // normal - m_ChamberRmin = 0 ; - m_ChamberRmax = 0 ; - m_ChamberPhiMin = 0 ; - m_ChamberPhiMax = 0 ; - m_ChamberThetaMin = 0 ; - m_ChamberThetaMax = 0 ; - - DefineMaterials(); - - //----------------------------- - //defaults for Planar - fPlanarGuard = 5.0*mm; - fPlanarGe_W = 120.0*mm; - fPlanarGe_H = 60.0*mm; - fPlanarGe_T = 15.0*mm; - - fEndCapThickness = 2.7*mm; //Notes state a 2.2 mm thick rib supporting a 0.5 mm Be window - fAlWindowThickness = 1.1*mm; - fBeWindowThickness = 0.5*mm; - - fPlanarGeGapFront = 14.0*mm; //Front face Al -> Front face Ge - fPlanarGeGapBack = 9.0*mm; //Back face Al -> Back face Ge - fPlanarGeGapFront = 16.0*mm; //Front face Al -> Front face Ge - fPlanarGeGapBack = 7.0*mm; //Back face Al -> Back face Ge - - fPlanarTotalL = 2.*fEndCapThickness + fPlanarGeGapFront + fPlanarGeGapBack + fPlanarGe_T; - - //--------------------------------------- - // I measured 39.5 mm for fPlanarTotalL - // => put end cap thickness 2.75 mm - // => add 1 mm to one of the gaps (most likely the retards put fPlanarGeGapFront = 15 mm !) - fPlanarTotalL = fEndCapThickness + fPlanarGeGapFront + fPlanarGeGapBack + fPlanarGe_T + fAlWindowThickness; - - fdeltaZ_Support = 0.0*mm; //looks like there is a little gap between the cooling block and the planar cut-out - fGap_PCB_2_Planar = 6.0*mm; //the gap between the downstrean part of the PCB and the upstream face of planar - fGap_PCB_2_Planar += fdeltaZ_Support; - fLengthOfPlanarCut = 55.0*mm; //the Z dimension of the cut out used to remove the planar - //-------------------------------------------------------------- - // Cooling block dimensions - fCoolingBlockL = 79.0*mm; - fCoolingBlockH = 152.0*mm; - fCoolingBlockW = 176.7*mm; - fCoolingBlockT = 6.0*mm; //excellent idea for low energy transparency ! - - // Size of cut-out for the tunnel (and DSSD) - fCoolingBlockCutOutH = 74.4*mm; - fCoolingBlockCutOutW = fCoolingBlockW - 2.*fCoolingBlockT; - fCoolingBlockDSSDCentre = fCoolingBlockH - fCoolingBlockT - fCoolingBlockCutOutH/2.; - fDSSD_BoardL = 2.0*mm; //thickness of Si implantation detector support board - - fCoolingBlockZ = fLengthOfPlanarCut + fDSSD_BoardL + fdeltaZ_Support; //distance between chamber inner wall and downstream side of detector support - - G4cout << "fCoolingBlockZ " << fCoolingBlockZ << G4endl; - - - //----------------------------- - //default DSSD - fDSSD_H = 40.0*mm; //active - fDSSD_W = 60.0*mm; //active - fDSSD_T = 0.3*mm; - fDSSD_Guard = 1.0*mm; - - - //----------------------------------------------------- - // Put these defaults here so I can easily compare them - //----------------------------------------------------- - //some default PhaseII detector parameters - fTotalGeL_PhaseII = 70.0 * mm; //was 70 - fCrystalR_PhaseII = 24.0 * mm; //was 25 - fEndCap2Ge_PhaseII = 20.0 * mm; //Distance from Al outer face to Ge - //added to fudge PTG's efficiency measurements for close-geometry STUK config. - fFudge = 8.0*mm; - fEndCap2Ge_PhaseII += fFudge; - - //modify it to make it 5 mm - //fEndCap2Ge_PhaseII -= 23*mm; - - fGapBetweenLeaves_PhaseII = 0.8*mm; - - fHoleR_PhaseII = 5.0 * mm; //was 5.0 - //fPassiveThick_PhaseII = 0.5 * mm; - fContactThick_PhaseII = 0.5 * mm; - - //make the PhaseII solids - CreateCloverIISolids(); - //----------------------------------------------------- - - - //----------------------------------------------------- - //some default GREAT Clover parameters - fTotalGeL_GREAT = 105.0 * mm; - fTaperGeL_GREAT = 30.0 * mm; - fCrystalR_GREAT = 35.0 * mm; - - fFrontFaceSquare_GREAT = 54.00 * mm; - fBackFaceSquare_GREAT = 61.50 * mm; - fEndCap2Ge_GREAT = 10.00 * mm; //Distance from Al outer face to Ge - - fGapBetweenLeaves_GREAT = 0.8*mm; - - fHoleR_GREAT = 5.0 * mm; //was 5.0 - //fPassiveThick_GREAT = 0.5 * mm; - fContactThick_GREAT = 0.5 * mm; - //gap between GREAT clover and chamber in "TOP" position - fGeTopGap = 1.5 * mm; - - //make the GREAT Clover solids - CreateGREATCloverSolids(); - - //----------------------------------------------------- - //Default position of Ges relative to DSSD - geTopPosition = 0. * mm; //-1.5 mm puts the downstream endcap of the GREAT detector level with chamber - geSidePosition = 0. * mm; - //----------------------------------------------------- - - - - //Centre of Si Implantation detector [UPSTREAM] - fDSSD_BoardZ = -fDSSD_BoardL/2.; - fDSSD_BoardZ = 0.0 * mm; - G4cout << "Default SiSuport Z " << fDSSD_BoardZ - fDSSD_BoardL/2. << G4endl; - - - +Chamber::Chamber() : nStripsX(60), nStripsY(40) { + + // m_ChamberType = true; + m_ChamberType = 0; // normal + m_ChamberRmin = 0; + m_ChamberRmax = 0; + m_ChamberPhiMin = 0; + m_ChamberPhiMax = 0; + m_ChamberThetaMin = 0; + m_ChamberThetaMax = 0; + + DefineMaterials(); + + //----------------------------- + // defaults for Planar + fPlanarGuard = 5.0 * mm; + fPlanarGe_W = 120.0 * mm; + fPlanarGe_H = 60.0 * mm; + fPlanarGe_T = 15.0 * mm; + + fEndCapThickness = 2.7 * mm; // Notes state a 2.2 mm thick rib supporting a 0.5 mm Be window + fAlWindowThickness = 1.1 * mm; + fBeWindowThickness = 0.5 * mm; + + fPlanarGeGapFront = 14.0 * mm; // Front face Al -> Front face Ge + fPlanarGeGapBack = 9.0 * mm; // Back face Al -> Back face Ge + fPlanarGeGapFront = 16.0 * mm; // Front face Al -> Front face Ge + fPlanarGeGapBack = 7.0 * mm; // Back face Al -> Back face Ge + + fPlanarTotalL = 2. * fEndCapThickness + fPlanarGeGapFront + fPlanarGeGapBack + fPlanarGe_T; + + //--------------------------------------- + // I measured 39.5 mm for fPlanarTotalL + // => put end cap thickness 2.75 mm + // => add 1 mm to one of the gaps (most likely the retards put fPlanarGeGapFront = 15 mm !) + fPlanarTotalL = fEndCapThickness + fPlanarGeGapFront + fPlanarGeGapBack + fPlanarGe_T + fAlWindowThickness; + + fdeltaZ_Support = 0.0 * mm; // looks like there is a little gap between the cooling block and the planar cut-out + fGap_PCB_2_Planar = 6.0 * mm; // the gap between the downstrean part of the PCB and the upstream face of planar + fGap_PCB_2_Planar += fdeltaZ_Support; + fLengthOfPlanarCut = 55.0 * mm; // the Z dimension of the cut out used to remove the planar + //-------------------------------------------------------------- + // Cooling block dimensions + fCoolingBlockL = 79.0 * mm; + fCoolingBlockH = 152.0 * mm; + fCoolingBlockW = 176.7 * mm; + fCoolingBlockT = 6.0 * mm; // excellent idea for low energy transparency ! + + // Size of cut-out for the tunnel (and DSSD) + fCoolingBlockCutOutH = 74.4 * mm; + fCoolingBlockCutOutW = fCoolingBlockW - 2. * fCoolingBlockT; + fCoolingBlockDSSDCentre = fCoolingBlockH - fCoolingBlockT - fCoolingBlockCutOutH / 2.; + fDSSD_BoardL = 2.0 * mm; // thickness of Si implantation detector support board + + fCoolingBlockZ = fLengthOfPlanarCut + fDSSD_BoardL + + fdeltaZ_Support; // distance between chamber inner wall and downstream side of detector support + + G4cout << "fCoolingBlockZ " << fCoolingBlockZ << G4endl; + + //----------------------------- + // default DSSD + fDSSD_H = 40.0 * mm; // active + fDSSD_W = 60.0 * mm; // active + fDSSD_T = 0.3 * mm; + fDSSD_Guard = 1.0 * mm; + + //----------------------------------------------------- + // Put these defaults here so I can easily compare them + //----------------------------------------------------- + // some default PhaseII detector parameters + fTotalGeL_PhaseII = 70.0 * mm; // was 70 + fCrystalR_PhaseII = 24.0 * mm; // was 25 + fEndCap2Ge_PhaseII = 20.0 * mm; // Distance from Al outer face to Ge + // added to fudge PTG's efficiency measurements for close-geometry STUK config. + fFudge = 8.0 * mm; + fEndCap2Ge_PhaseII += fFudge; + + // modify it to make it 5 mm + // fEndCap2Ge_PhaseII -= 23*mm; + + fGapBetweenLeaves_PhaseII = 0.8 * mm; + + fHoleR_PhaseII = 5.0 * mm; // was 5.0 + // fPassiveThick_PhaseII = 0.5 * mm; + fContactThick_PhaseII = 0.5 * mm; + + // make the PhaseII solids + CreateCloverIISolids(); + //----------------------------------------------------- + + //----------------------------------------------------- + // some default GREAT Clover parameters + fTotalGeL_GREAT = 105.0 * mm; + fTaperGeL_GREAT = 30.0 * mm; + fCrystalR_GREAT = 35.0 * mm; + + fFrontFaceSquare_GREAT = 54.00 * mm; + fBackFaceSquare_GREAT = 61.50 * mm; + fEndCap2Ge_GREAT = 10.00 * mm; // Distance from Al outer face to Ge + + fGapBetweenLeaves_GREAT = 0.8 * mm; + + fHoleR_GREAT = 5.0 * mm; // was 5.0 + // fPassiveThick_GREAT = 0.5 * mm; + fContactThick_GREAT = 0.5 * mm; + // gap between GREAT clover and chamber in "TOP" position + fGeTopGap = 1.5 * mm; + + // make the GREAT Clover solids + CreateGREATCloverSolids(); + + //----------------------------------------------------- + // Default position of Ges relative to DSSD + geTopPosition = 0. * mm; //-1.5 mm puts the downstream endcap of the GREAT detector level with chamber + geSidePosition = 0. * mm; + //----------------------------------------------------- + + // Centre of Si Implantation detector [UPSTREAM] + fDSSD_BoardZ = -fDSSD_BoardL / 2.; + fDSSD_BoardZ = 0.0 * mm; + G4cout << "Default SiSuport Z " << fDSSD_BoardZ - fDSSD_BoardL / 2. << G4endl; } -G4Material* Chamber::GetMaterialFromLibrary(G4String MaterialName){ +G4Material* Chamber::GetMaterialFromLibrary(G4String MaterialName) { - if (MaterialName == "Alu") { - G4Material* myMaterial = new G4Material("Alu", 13, 26.98*g/mole, 2.7*g/cm3); - //G4Material* myMaterial = man->FindOrBuildMaterial("G4_Al"); - return myMaterial; - - } - if (MaterialName == "Cu") { - - G4Material* myMaterial = new G4Material("Cu", 29, 63.546*g/mole, 8.96*g/cm3); - // G4Material* myMaterial = man->FindOrBuildMaterial("G4_Cu"); - return myMaterial; - } - if (MaterialName == "12C") { - - G4Material* myMaterial = new G4Material("12C", 6, 12.011*g/mole, 2.62*g/cm3); - //G4Material* myMaterial = man->FindOrBuildMaterial("G4_C"); - - return myMaterial; - } + if (MaterialName == "Alu") { + G4Material* myMaterial = new G4Material("Alu", 13, 26.98 * g / mole, 2.7 * g / cm3); + // G4Material* myMaterial = man->FindOrBuildMaterial("G4_Al"); + return myMaterial; + } + if (MaterialName == "Cu") { - else { - G4cout << "No Matching Material in the Chamber Library Default is Vacuum" << G4endl; - G4Element* N = new G4Element("Nitrogen", "N", 7., 14.01*g / mole); - G4Element* O = new G4Element("Oxygen" , "O", 8., 16.00*g / mole); - G4Material* myMaterial = new G4Material("Vacuum", 0.000000001*mg / cm3, 2); - myMaterial->AddElement(N, .7); - myMaterial->AddElement(O, .3); + G4Material* myMaterial = new G4Material("Cu", 29, 63.546 * g / mole, 8.96 * g / cm3); + // G4Material* myMaterial = man->FindOrBuildMaterial("G4_Cu"); + return myMaterial; + } + if (MaterialName == "12C") { - //G4Material* myMaterial = man->FindOrBuildMaterial("G4_Galactic"); - //G4Element* N = man->FindOrBuildElement("G4_N"); - //G4Element* O = man->FindOrBuildElement("G4_O"); - //const std::vector<G4int> Zvac; - //const std::vector<G4double> Wvac; - //G4Material* myMaterial = man->FindOrBuildMaterial("Vacuum"); - //myMaterial = man->ConstructNewMaterial("Vacuum", Zvac,Wvac,0.000000001*mg / cm3); + G4Material* myMaterial = new G4Material("12C", 6, 12.011 * g / mole, 2.62 * g / cm3); + // G4Material* myMaterial = man->FindOrBuildMaterial("G4_C"); + return myMaterial; + } - return(myMaterial); - } + else { + G4cout << "No Matching Material in the Chamber Library Default is Vacuum" << G4endl; + G4Element* N = new G4Element("Nitrogen", "N", 7., 14.01 * g / mole); + G4Element* O = new G4Element("Oxygen", "O", 8., 16.00 * g / mole); + G4Material* myMaterial = new G4Material("Vacuum", 0.000000001 * mg / cm3, 2); + myMaterial->AddElement(N, .7); + myMaterial->AddElement(O, .3); + + // G4Material* myMaterial = man->FindOrBuildMaterial("G4_Galactic"); + // G4Element* N = man->FindOrBuildElement("G4_N"); + // G4Element* O = man->FindOrBuildElement("G4_O"); + // const std::vector<G4int> Zvac; + // const std::vector<G4double> Wvac; + // G4Material* myMaterial = man->FindOrBuildMaterial("Vacuum"); + // myMaterial = man->ConstructNewMaterial("Vacuum", Zvac,Wvac,0.000000001*mg / cm3); + + return (myMaterial); + } } - - //------------------------------------------------------------------ -//Materials Definitions -void Chamber::DefineMaterials() -{ - G4double a; // atomic mass - G4double z; // atomic number +// Materials Definitions +void Chamber::DefineMaterials() { + G4double a; // atomic mass + G4double z; // atomic number G4double density; G4String name, symbol; - G4int ncomponents, natoms; + G4int ncomponents, natoms; G4double fractionmass; - + //--------------------------------- - //some elements - a = 1.0078*g/mole; - G4Element* elH = new G4Element(name="Hydrogen", symbol="H", z=1., a); - - a = 12.00*g/mole; - G4Element* elC = new G4Element(name="Carbon", symbol="C", z=6., a); - - a = 14.01*g/mole; - G4Element* elN = new G4Element(name="Nitrogen", symbol="N", z=7., a); - - a = 16.00*g/mole; - G4Element* elO = new G4Element(name="Oxygen", symbol="O", z=8., a); - - a = 24.305*g/mole; - G4Element* elMg = new G4Element(name="Magnesium", symbol="Mg", z=12., a); - - a = 26.98*g/mole; - G4Element* elAl = new G4Element(name="Aluminium", symbol="Al", z=13., a); - - a = 35.45*g/mole; - G4Element* elCl = new G4Element(name="Chlorine", symbol="Cl", z=17., a); - - a = 51.9961*g/mole; - G4Element* elCr = new G4Element(name="Chromium", symbol="Cr", z=24., a); - - a = 54.938*g/mole; - G4Element* elMn = new G4Element(name="Manganse", symbol="Mn", z=25., a); - - a = 55.845*g/mole; - G4Element* elFe = new G4Element(name="Iron", symbol="Fe", z=26., a); - - a = 58.6934*g/mole; - G4Element* elNi = new G4Element(name="Nickel", symbol="Ni", z=28., a); - - a = 63.54*g/mole; - G4Element* elCu = new G4Element(name="Copper", symbol="Cu", z=29., a); - - a = 65.39*g/mole; - G4Element* elZn = new G4Element(name="Zinc", symbol="Zn", z=30., a); - - a = 72.61*g/mole; - G4Element* elGe = new G4Element(name="Germanium", symbol="Ge", z=32., a); - - a =208.98*g/mole; - G4Element* elBi = new G4Element(name="Bismuth", symbol="Bi", z=83., a); - - //elements for physics.... - a =251.00*g/mole; - G4Element* elEs = new G4Element(name="Einsteinium",symbol="Es", z=99., a); + // some elements + a = 1.0078 * g / mole; + G4Element* elH = new G4Element(name = "Hydrogen", symbol = "H", z = 1., a); + + a = 12.00 * g / mole; + G4Element* elC = new G4Element(name = "Carbon", symbol = "C", z = 6., a); + + a = 14.01 * g / mole; + G4Element* elN = new G4Element(name = "Nitrogen", symbol = "N", z = 7., a); + + a = 16.00 * g / mole; + G4Element* elO = new G4Element(name = "Oxygen", symbol = "O", z = 8., a); + + a = 24.305 * g / mole; + G4Element* elMg = new G4Element(name = "Magnesium", symbol = "Mg", z = 12., a); + + a = 26.98 * g / mole; + G4Element* elAl = new G4Element(name = "Aluminium", symbol = "Al", z = 13., a); + + a = 35.45 * g / mole; + G4Element* elCl = new G4Element(name = "Chlorine", symbol = "Cl", z = 17., a); + + a = 51.9961 * g / mole; + G4Element* elCr = new G4Element(name = "Chromium", symbol = "Cr", z = 24., a); + + a = 54.938 * g / mole; + G4Element* elMn = new G4Element(name = "Manganse", symbol = "Mn", z = 25., a); + + a = 55.845 * g / mole; + G4Element* elFe = new G4Element(name = "Iron", symbol = "Fe", z = 26., a); + + a = 58.6934 * g / mole; + G4Element* elNi = new G4Element(name = "Nickel", symbol = "Ni", z = 28., a); + + a = 63.54 * g / mole; + G4Element* elCu = new G4Element(name = "Copper", symbol = "Cu", z = 29., a); + + a = 65.39 * g / mole; + G4Element* elZn = new G4Element(name = "Zinc", symbol = "Zn", z = 30., a); + + a = 72.61 * g / mole; + G4Element* elGe = new G4Element(name = "Germanium", symbol = "Ge", z = 32., a); + + a = 208.98 * g / mole; + G4Element* elBi = new G4Element(name = "Bismuth", symbol = "Bi", z = 83., a); + + // elements for physics.... + a = 251.00 * g / mole; + G4Element* elEs = new G4Element(name = "Einsteinium", symbol = "Es", z = 99., a); einsteinium = elEs; - a =251.00*g/mole; - G4Element* elFm = new G4Element(name="Fermium", symbol="Fm", z=100., a); + a = 251.00 * g / mole; + G4Element* elFm = new G4Element(name = "Fermium", symbol = "Fm", z = 100., a); fermium = elFm; - + //--------------------------------- - //Define required materials - a=6.941*g/mole; density=0.534*g/cm3; - G4Material* Li=new G4Material(name="Lithium", z=3., a, density); - - a=9.0122*g/mole; density=1.85*g/cm3; - G4Material* Be=new G4Material(name="Berilium", z=4., a, density); - - a=28.0855*g/mole; density=2.33*g/cm3; - G4Material* Si=new G4Material(name="Silicon", z=14., a, density); - - a=72.61*g/mole; density=5.32*g/cm3; - G4Material* Ge=new G4Material(name="Germanium", z=32., a, density); - - a=26.98*g/mole; density=2.7*g/cm3; - //G4Material* Al=new G4Material(name="Aluminium", z=13., a, density); - - a=63.54*g/mole; density=8.96*g/cm3; - //G4Material* Cu=new G4Material(name="Copper", z=29., a, density); - - a=183.84*g/mole; density=19.3*g/cm3; - //G4Material* W=new G4Material(name="Tungsten", z=74., a, density); - + // Define required materials + a = 6.941 * g / mole; + density = 0.534 * g / cm3; + G4Material* Li = new G4Material(name = "Lithium", z = 3., a, density); + + a = 9.0122 * g / mole; + density = 1.85 * g / cm3; + G4Material* Be = new G4Material(name = "Berilium", z = 4., a, density); + + a = 28.0855 * g / mole; + density = 2.33 * g / cm3; + G4Material* Si = new G4Material(name = "Silicon", z = 14., a, density); + + a = 72.61 * g / mole; + density = 5.32 * g / cm3; + G4Material* Ge = new G4Material(name = "Germanium", z = 32., a, density); + + a = 26.98 * g / mole; + density = 2.7 * g / cm3; + // G4Material* Al=new G4Material(name="Aluminium", z=13., a, density); + + a = 63.54 * g / mole; + density = 8.96 * g / cm3; + // G4Material* Cu=new G4Material(name="Copper", z=29., a, density); + + a = 183.84 * g / mole; + density = 19.3 * g / cm3; + // G4Material* W=new G4Material(name="Tungsten", z=74., a, density); + //--------------------------------- // AIR - density = 1.290*mg/cm3; - G4Material* Air = new G4Material(name="Air", density, ncomponents=2); - Air->AddElement(elN, fractionmass=70*perCent); - Air->AddElement(elO, fractionmass=30*perCent); - - density = 1.e-5*g/cm3; //taken from ExN03 - G4double pressure = 2.e-7*bar; + density = 1.290 * mg / cm3; + G4Material* Air = new G4Material(name = "Air", density, ncomponents = 2); + Air->AddElement(elN, fractionmass = 70 * perCent); + Air->AddElement(elO, fractionmass = 30 * perCent); + + density = 1.e-5 * g / cm3; // taken from ExN03 + G4double pressure = 2.e-7 * bar; G4double temperature = STP_Temperature; - G4Material* Vacuum=new G4Material(name="Vacuum", density, ncomponents=1, - kStateGas, temperature, pressure); - Vacuum->AddMaterial(Air, fractionmass=1.); + G4Material* Vacuum = new G4Material(name = "Vacuum", density, ncomponents = 1, kStateGas, temperature, pressure); + Vacuum->AddMaterial(Air, fractionmass = 1.); //--------------------------------- // Pentane - density = 0.620*g/cm3; //liquid ! - density = 5.9e-6*g/cm3; //gas - pressure = 1.5/760.0*atmosphere; - temperature = 310*kelvin; - G4Material* Pentane=new G4Material(name="Pentane", density, ncomponents=2, - kStateGas, temperature, pressure); - Pentane->AddElement(elH, natoms=12); - Pentane->AddElement(elC, natoms=5); + density = 0.620 * g / cm3; // liquid ! + density = 5.9e-6 * g / cm3; // gas + pressure = 1.5 / 760.0 * atmosphere; + temperature = 310 * kelvin; + G4Material* Pentane = new G4Material(name = "Pentane", density, ncomponents = 2, kStateGas, temperature, pressure); + Pentane->AddElement(elH, natoms = 12); + Pentane->AddElement(elC, natoms = 5); //------------------------------------------------------------------ - //18-8 (stainless) steel - density = 8.00*g/cm3; - G4Material* Steel = new G4Material(name="Steel", density, ncomponents=3); - Steel->AddElement(elCr, natoms= 8); - Steel->AddElement(elNi, natoms=18); - Steel->AddElement(elFe, natoms=74); - + // 18-8 (stainless) steel + density = 8.00 * g / cm3; + G4Material* Steel = new G4Material(name = "Steel", density, ncomponents = 3); + Steel->AddElement(elCr, natoms = 8); + Steel->AddElement(elNi, natoms = 18); + Steel->AddElement(elFe, natoms = 74); + //------------------------------------------------------------------ - //Brass (there are many compositions) - density = 8.87*g/cm3; - G4Material* Brass = new G4Material(name="Brass", density, ncomponents=3); - Brass->AddElement(elCu, fractionmass=70.0*perCent); - Brass->AddElement(elZn, fractionmass=28.8*perCent); - Brass->AddElement(elMn, fractionmass= 1.2*perCent); + // Brass (there are many compositions) + density = 8.87 * g / cm3; + G4Material* Brass = new G4Material(name = "Brass", density, ncomponents = 3); + Brass->AddElement(elCu, fractionmass = 70.0 * perCent); + Brass->AddElement(elZn, fractionmass = 28.8 * perCent); + Brass->AddElement(elMn, fractionmass = 1.2 * perCent); //------------------------------------------------------------------ - //DurAl [3-4% Cu, 0.5% Mg, 0.25-1%Mn, remainder Al] : use average val - density = 2.8*g/cm3; - G4Material* DurAl = new G4Material(name="DurAluminium", - density, ncomponents=4); - DurAl->AddElement(elCu, fractionmass= 3.5*perCent); - DurAl->AddElement(elMg, fractionmass= 0.5*perCent); - DurAl->AddElement(elMn, fractionmass= 0.6*perCent); - DurAl->AddElement(elAl, fractionmass=95.4*perCent); + // DurAl [3-4% Cu, 0.5% Mg, 0.25-1%Mn, remainder Al] : use average val + density = 2.8 * g / cm3; + G4Material* DurAl = new G4Material(name = "DurAluminium", density, ncomponents = 4); + DurAl->AddElement(elCu, fractionmass = 3.5 * perCent); + DurAl->AddElement(elMg, fractionmass = 0.5 * perCent); + DurAl->AddElement(elMn, fractionmass = 0.6 * perCent); + DurAl->AddElement(elAl, fractionmass = 95.4 * perCent); //------------------------------------------------------------------ - //Epoxy for Si detector support - density = 1.18*g/cm3;//cast - density = 1.85*g/cm3;//molded - G4Material* Epoxy = new G4Material(name="Epoxy", density, ncomponents=3); - Epoxy->AddElement(elH, natoms=19); - Epoxy->AddElement(elC, natoms=18); - Epoxy->AddElement(elO, natoms= 3); + // Epoxy for Si detector support + density = 1.18 * g / cm3; // cast + density = 1.85 * g / cm3; // molded + G4Material* Epoxy = new G4Material(name = "Epoxy", density, ncomponents = 3); + Epoxy->AddElement(elH, natoms = 19); + Epoxy->AddElement(elC, natoms = 18); + Epoxy->AddElement(elO, natoms = 3); //------------------------------------------------------------------ - //Plastic support for the Si detector support - density = 1.68*g/cm3;//PVC - G4Material* Pvc = new G4Material(name="PVC", density, ncomponents=3); - Pvc->AddElement(elH, natoms=3); - Pvc->AddElement(elC, natoms=2); - Pvc->AddElement(elCl, natoms=1); + // Plastic support for the Si detector support + density = 1.68 * g / cm3; // PVC + G4Material* Pvc = new G4Material(name = "PVC", density, ncomponents = 3); + Pvc->AddElement(elH, natoms = 3); + Pvc->AddElement(elC, natoms = 2); + Pvc->AddElement(elCl, natoms = 1); //------------------------------------------------------------------ - //BGO - density = 7.13*g/cm3;//cast - G4Material* BGO = new G4Material(name="BGO", density, ncomponents=3); - BGO->AddElement(elBi, natoms= 4); - BGO->AddElement(elGe, natoms= 3); - BGO->AddElement(elO, natoms=12); + // BGO + density = 7.13 * g / cm3; // cast + G4Material* BGO = new G4Material(name = "BGO", density, ncomponents = 3); + BGO->AddElement(elBi, natoms = 4); + BGO->AddElement(elGe, natoms = 3); + BGO->AddElement(elO, natoms = 12); //--------------------------------- //--------------------------------- @@ -414,27 +401,24 @@ void Chamber::DefineMaterials() G4cout << *(G4Material::GetMaterialTable()) << G4endl; //--------------------------------- - //Default materials - WorldMaterial = Air; - chamberMaterial = DurAl; - //backplateMaterial = DurAl; - defaultMaterial = Ge; - eDetMat = Si; - boardMaterial = Epoxy; - supportMaterial = Steel; - metalbarMaterial = Steel; - geMaterial = Ge; - endCapMaterial = DurAl; - contactMaterial = Li; - //vacuumInVacChamMat = Pentane; - vacuumMaterial = Vacuum; - beMaterial = Be; - //coolMaterial = Cu; + // Default materials + WorldMaterial = Air; + chamberMaterial = DurAl; + // backplateMaterial = DurAl; + defaultMaterial = Ge; + eDetMat = Si; + boardMaterial = Epoxy; + supportMaterial = Steel; + metalbarMaterial = Steel; + geMaterial = Ge; + endCapMaterial = DurAl; + contactMaterial = Li; + // vacuumInVacChamMat = Pentane; + vacuumMaterial = Vacuum; + beMaterial = Be; + // coolMaterial = Cu; } - - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -442,143 +426,137 @@ void Chamber::DefineMaterials() // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -//void Chamber::ReadConfiguration(string Path) +// void Chamber::ReadConfiguration(string Path) //{ -void Chamber::ReadConfiguration(NPL::InputParser parser){ - vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithTokenAndValue("Chamber","Great-Karl"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " GREAT Chmaber found " << endl; - - vector<string> token = {"Heightmin","Heightmax","Widthmin","Widthmax","Depthmin","Depthmax","Material"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - - if(blocks[i]->HasTokenList(token)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Great chamber as defined by Karl " << i+1 << endl; - m_ChamberType = 3 ; - m_ChamberHmin = blocks[i]->GetDouble("Heightmin","mm"); - m_ChamberHmax = blocks[i]->GetDouble("Heightmax","mm"); - m_ChamberWmin = blocks[i]->GetDouble("Widthmin","mm"); - m_ChamberWmax = blocks[i]->GetDouble("Widthmax","mm"); - m_ChamberDmin = blocks[i]->GetDouble("Depthmin","mm"); - m_ChamberDmax = blocks[i]->GetDouble("Depthmax","mm"); - m_ChamberMaterial=GetMaterialFromLibrary(blocks[i]->GetString("Material")); +void Chamber::ReadConfiguration(NPL::InputParser parser) { + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithTokenAndValue("Chamber", "Great-Karl"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " GREAT Chmaber found " << endl; + + vector<string> token = {"Heightmin", "Heightmax", "Widthmin", "Widthmax", "Depthmin", "Depthmax", "Material"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + + if (blocks[i]->HasTokenList(token)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Great chamber as defined by Karl " << i + 1 << endl; + m_ChamberType = 3; + m_ChamberHmin = blocks[i]->GetDouble("Heightmin", "mm"); + m_ChamberHmax = blocks[i]->GetDouble("Heightmax", "mm"); + m_ChamberWmin = blocks[i]->GetDouble("Widthmin", "mm"); + m_ChamberWmax = blocks[i]->GetDouble("Widthmax", "mm"); + m_ChamberDmin = blocks[i]->GetDouble("Depthmin", "mm"); + m_ChamberDmax = blocks[i]->GetDouble("Depthmax", "mm"); + m_ChamberMaterial = GetMaterialFromLibrary(blocks[i]->GetString("Material")); } - else{ + else { cout << "Warning: check your input file formatting " << endl; } } blocks.clear(); - blocks = parser.GetAllBlocksWithTokenAndValue("Chamber","Great"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " Great Chamber found " << endl; - - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(token)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Great standard chamber " << i+1 << endl; - m_ChamberType = 2 ; - m_ChamberHmin = blocks[i]->GetDouble("Heightmin","mm"); - m_ChamberHmax = blocks[i]->GetDouble("Heightmax","mm"); - m_ChamberWmin = blocks[i]->GetDouble("Widthmin","mm"); - m_ChamberWmax = blocks[i]->GetDouble("Widthmax","mm"); - m_ChamberDmin = blocks[i]->GetDouble("Depthmin","mm"); - m_ChamberDmax = blocks[i]->GetDouble("Depthmax","mm"); - m_ChamberMaterial=GetMaterialFromLibrary(blocks[i]->GetString("Material")); + blocks = parser.GetAllBlocksWithTokenAndValue("Chamber", "Great"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " Great Chamber found " << endl; + + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(token)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Great standard chamber " << i + 1 << endl; + m_ChamberType = 2; + m_ChamberHmin = blocks[i]->GetDouble("Heightmin", "mm"); + m_ChamberHmax = blocks[i]->GetDouble("Heightmax", "mm"); + m_ChamberWmin = blocks[i]->GetDouble("Widthmin", "mm"); + m_ChamberWmax = blocks[i]->GetDouble("Widthmax", "mm"); + m_ChamberDmin = blocks[i]->GetDouble("Depthmin", "mm"); + m_ChamberDmax = blocks[i]->GetDouble("Depthmax", "mm"); + m_ChamberMaterial = GetMaterialFromLibrary(blocks[i]->GetString("Material")); } - else{ + else { cout << "Warning: check your input file formatting " << endl; } } blocks.clear(); - blocks = parser.GetAllBlocksWithTokenAndValue("Chamber",""); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " Chamber found " << endl; - - token = {"Rmin","Rmax","PhiMin","PhiMax","ThetaMin","ThetaMax","Material"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(token)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Generic Chamber " << i+1 << endl; - m_ChamberType = 0 ; - m_ChamberRmin = blocks[i]->GetDouble("Rmin","mm"); - m_ChamberRmax = blocks[i]->GetDouble("Rmax","mm"); - m_ChamberPhiMin = blocks[i]->GetDouble("PhiMin","deg"); - m_ChamberPhiMax = blocks[i]->GetDouble("PhiMax","deg"); - m_ChamberThetaMin = blocks[i]->GetDouble("ThetaMin","deg"); - m_ChamberThetaMax = blocks[i]->GetDouble("ThetaMax","deg"); - m_ChamberMaterial=GetMaterialFromLibrary(blocks[i]->GetString("Material")); + blocks = parser.GetAllBlocksWithTokenAndValue("Chamber", ""); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " Chamber found " << endl; + + token = {"Rmin", "Rmax", "PhiMin", "PhiMax", "ThetaMin", "ThetaMax", "Material"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(token)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Generic Chamber " << i + 1 << endl; + m_ChamberType = 0; + m_ChamberRmin = blocks[i]->GetDouble("Rmin", "mm"); + m_ChamberRmax = blocks[i]->GetDouble("Rmax", "mm"); + m_ChamberPhiMin = blocks[i]->GetDouble("PhiMin", "deg"); + m_ChamberPhiMax = blocks[i]->GetDouble("PhiMax", "deg"); + m_ChamberThetaMin = blocks[i]->GetDouble("ThetaMin", "deg"); + m_ChamberThetaMax = blocks[i]->GetDouble("ThetaMax", "deg"); + m_ChamberMaterial = GetMaterialFromLibrary(blocks[i]->GetString("Material")); } - else{ + else { cout << "Warning: check your input file formatting " << endl; } } - blocks.clear(); - blocks = parser.GetAllBlocksWithTokenAndValue("Chamber","MARA"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " MARA chamber found " << endl; + blocks = parser.GetAllBlocksWithTokenAndValue("Chamber", "MARA"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " MARA chamber found " << endl; - token = {"GDMLFilePath","GDMLFileName","GDMLWorldName"}; + token = {"GDMLFilePath", "GDMLFileName", "GDMLWorldName"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(token)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Great standard chamber " << i+1 << endl; - m_ChamberType = 4 ; + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(token)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Great standard chamber " << i + 1 << endl; + m_ChamberType = 4; m_GDMLPath = blocks[i]->GetString("GDMLFilePath"); m_GDMLName = blocks[i]->GetString("GDMLFileName"); m_GDMLWorld = blocks[i]->GetString("GDMLWorldName"); } - else{ + else { cout << "Warning: check your input file formatting " << endl; } } blocks.clear(); - blocks = parser.GetAllBlocksWithTokenAndValue("Chamber","MUGAST"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " MuGasT chamber found " << endl; - - token = {"GDMLFilePath","GDMLFileName","GDMLWorldName"}; + blocks = parser.GetAllBlocksWithTokenAndValue("Chamber", "MUGAST"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " MuGasT chamber found " << endl; + token = {"GDMLFilePath", "GDMLFileName", "GDMLWorldName"}; - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(token)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// standard chamber " << i+1 << endl; - m_ChamberType = 5 ; + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(token)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// standard chamber " << i + 1 << endl; + m_ChamberType = 5; m_GDMLPath = blocks[i]->GetString("GDMLFilePath"); m_GDMLName = blocks[i]->GetString("GDMLFileName"); m_GDMLWorld = blocks[i]->GetString("GDMLWorldName"); } - else{ + else { cout << "Warning: check your input file formatting " << endl; } } - } - /* ifstream ConfigFile; ConfigFile.open(Path.c_str()); string LineBuffer; string DataBuffer; - + bool ReadingStatusChamber = false ; bool ReadingStatusGREATChamber = false ; bool ReadingStatusMARAChamber = false ; @@ -598,7 +576,7 @@ void Chamber::ReadConfiguration(NPL::InputParser parser){ bool check_Wmax = false ; bool check_Dmin = false ; bool check_Dmax = false ; - + bool check_GDMLPath = false ; bool check_GDMLName = false ; bool check_GDMLWorld = false ; @@ -617,7 +595,7 @@ void Chamber::ReadConfiguration(NPL::InputParser parser){ // m_ChamberType = false ; // ReadingStatusCryoChamber = true ; //} - + else if (LineBuffer.compare(0, 12, "GREATChamber") == 0) { cout << "GREAT Chamber Found" << endl; m_ChamberType = 2 ; @@ -633,182 +611,186 @@ void Chamber::ReadConfiguration(NPL::InputParser parser){ m_ChamberType = 4 ; ReadingStatusMARAChamber = true ; } - + while (ReadingStatusChamber) { ConfigFile >> DataBuffer; - - //Search for comment Symbol % - if (DataBuffer.compare(0, 1, "%") == 0) { ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );} - - else if (DataBuffer.compare(0, 5, "Rmin=") == 0) { - check_Rmin = true ; - ConfigFile >> DataBuffer; - m_ChamberRmin = atof(DataBuffer.c_str()) * mm; - cout << "Chamber inner radius: " << m_ChamberRmin << endl ; - } - - else if (DataBuffer.compare(0, 5, "Rmax=") == 0) { - check_Rmax = true ; - ConfigFile >> DataBuffer; - m_ChamberRmax = atof(DataBuffer.c_str()) * mm; - cout << "Chamber outer radius: " << m_ChamberRmax << endl ; - } - - else if (DataBuffer.compare(0, 7, "PhiMin=") == 0) { - check_PhiMin = true ; - ConfigFile >> DataBuffer; - m_ChamberPhiMin = atof(DataBuffer.c_str()) * rad; - cout << "Chamber PhiMin: " << m_ChamberPhiMin << endl ; - } - else if (DataBuffer.compare(0, 7, "PhiMax=") == 0) { - check_PhiMax = true ; - ConfigFile >> DataBuffer; - m_ChamberPhiMax = atof(DataBuffer.c_str()) * rad; - cout << "Chamber PhiMax: " << m_ChamberPhiMax << endl ; - } - else if (DataBuffer.compare(0, 9, "ThetaMin=") == 0) { - check_ThetaMin = true ; - ConfigFile >> DataBuffer; - m_ChamberThetaMin = atof(DataBuffer.c_str()) * rad; - cout << "Chamber ThetaMin: " << m_ChamberThetaMin << endl ; - } - else if (DataBuffer.compare(0, 9, "ThetaMax=") == 0) { - check_ThetaMax = true ; - ConfigFile >> DataBuffer; - m_ChamberThetaMax = atof(DataBuffer.c_str()) * rad; - cout << "Chamber ThetaMax: " << m_ChamberThetaMax << endl ; - } - - else if (DataBuffer.compare(0, 9, "MATERIAL=") == 0) { - check_Material = true ; - ConfigFile >> DataBuffer; - m_ChamberMaterial = GetMaterialFromLibrary(DataBuffer); - cout << "Chamber Material: " << m_ChamberMaterial << endl ; - } - - /////////////////////////////////////////////////// - // If no Beam Token and no comment, toggle out - else - {ReadingStatusChamber = false; G4cout << "WARNING : Wrong Token Sequence: Getting out " << G4endl ;} - - /////////////////////////////////////////////////// - // If all Token found toggle out - if( check_Rmin && check_Rmax && check_Material && check_PhiMin && check_PhiMax && check_ThetaMin && check_ThetaMax ) - ReadingStatusChamber = false ; - - } - + + //Search for comment Symbol % + if (DataBuffer.compare(0, 1, "%") == 0) { ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), +'\n' );} + + else if (DataBuffer.compare(0, 5, "Rmin=") == 0) { + check_Rmin = true ; + ConfigFile >> DataBuffer; + m_ChamberRmin = atof(DataBuffer.c_str()) * mm; + cout << "Chamber inner radius: " << m_ChamberRmin << endl ; + } + + else if (DataBuffer.compare(0, 5, "Rmax=") == 0) { + check_Rmax = true ; + ConfigFile >> DataBuffer; + m_ChamberRmax = atof(DataBuffer.c_str()) * mm; + cout << "Chamber outer radius: " << m_ChamberRmax << endl ; + } + + else if (DataBuffer.compare(0, 7, "PhiMin=") == 0) { + check_PhiMin = true ; + ConfigFile >> DataBuffer; + m_ChamberPhiMin = atof(DataBuffer.c_str()) * rad; + cout << "Chamber PhiMin: " << m_ChamberPhiMin << endl ; + } + else if (DataBuffer.compare(0, 7, "PhiMax=") == 0) { + check_PhiMax = true ; + ConfigFile >> DataBuffer; + m_ChamberPhiMax = atof(DataBuffer.c_str()) * rad; + cout << "Chamber PhiMax: " << m_ChamberPhiMax << endl ; + } + else if (DataBuffer.compare(0, 9, "ThetaMin=") == 0) { + check_ThetaMin = true ; + ConfigFile >> DataBuffer; + m_ChamberThetaMin = atof(DataBuffer.c_str()) * rad; + cout << "Chamber ThetaMin: " << m_ChamberThetaMin << endl ; + } + else if (DataBuffer.compare(0, 9, "ThetaMax=") == 0) { + check_ThetaMax = true ; + ConfigFile >> DataBuffer; + m_ChamberThetaMax = atof(DataBuffer.c_str()) * rad; + cout << "Chamber ThetaMax: " << m_ChamberThetaMax << endl ; + } + + else if (DataBuffer.compare(0, 9, "MATERIAL=") == 0) { + check_Material = true ; + ConfigFile >> DataBuffer; + m_ChamberMaterial = GetMaterialFromLibrary(DataBuffer); + cout << "Chamber Material: " << m_ChamberMaterial << endl ; + } + + /////////////////////////////////////////////////// + // If no Beam Token and no comment, toggle out + else + {ReadingStatusChamber = false; G4cout << "WARNING : Wrong Token Sequence: Getting out " << G4endl ;} + + /////////////////////////////////////////////////// + // If all Token found toggle out + if( check_Rmin && check_Rmax && check_Material && check_PhiMin && check_PhiMax && check_ThetaMin && +check_ThetaMax ) ReadingStatusChamber = false ; + + } + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// For MARA Chamber while (ReadingStatusMARAChamber) { ConfigFile >> DataBuffer; - - //Search for comment Symbol % - if (DataBuffer.compare(0, 1, "%") == 0) { ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );} - - else if (DataBuffer.compare(0, 13, "GDMLFilePath=") == 0) { - check_GDMLPath = true ; - ConfigFile >> DataBuffer; - m_GDMLPath = DataBuffer.c_str(); - cout << "Path: " << m_GDMLPath << endl ; - } - else if (DataBuffer.compare(0, 13, "GDMLFileName=") == 0) { - check_GDMLName = true ; - ConfigFile >> DataBuffer; - m_GDMLName = DataBuffer.c_str(); - cout << "Name: " << m_GDMLName << endl ; - } - else if (DataBuffer.compare(0, 14, "GDMLWorldName=") == 0) { - check_GDMLWorld = true ; - ConfigFile >> DataBuffer; - m_GDMLWorld = DataBuffer.c_str(); - cout << "World Name: " << m_GDMLWorld << endl ; - } - /////////////////////////////////////////////////// - // If no Beam Token and no comment, toggle out - else - {ReadingStatusMARAChamber = false; G4cout << "WARNING : Wrong Token Sequence for MARA: Getting out " << G4endl ;} - // If all Token found toggle out - if( check_GDMLPath && check_GDMLName && check_GDMLWorld ) - ReadingStatusMARAChamber = false ; - - - } - - - + + //Search for comment Symbol % + if (DataBuffer.compare(0, 1, "%") == 0) { ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), +'\n' );} + + else if (DataBuffer.compare(0, 13, "GDMLFilePath=") == 0) { + check_GDMLPath = true ; + ConfigFile >> DataBuffer; + m_GDMLPath = DataBuffer.c_str(); + cout << "Path: " << m_GDMLPath << endl ; + } + else if (DataBuffer.compare(0, 13, "GDMLFileName=") == 0) { + check_GDMLName = true ; + ConfigFile >> DataBuffer; + m_GDMLName = DataBuffer.c_str(); + cout << "Name: " << m_GDMLName << endl ; + } + else if (DataBuffer.compare(0, 14, "GDMLWorldName=") == 0) { + check_GDMLWorld = true ; + ConfigFile >> DataBuffer; + m_GDMLWorld = DataBuffer.c_str(); + cout << "World Name: " << m_GDMLWorld << endl ; + } + /////////////////////////////////////////////////// + // If no Beam Token and no comment, toggle out + else + {ReadingStatusMARAChamber = false; G4cout << "WARNING : Wrong Token Sequence for MARA: Getting out " << +G4endl ;} + // If all Token found toggle out + if( check_GDMLPath && check_GDMLName && check_GDMLWorld ) + ReadingStatusMARAChamber = false ; + + + } + + + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// For GREAT Chamber while (ReadingStatusGREATChamber) { ConfigFile >> DataBuffer; - - //Search for comment Symbol % - if (DataBuffer.compare(0, 1, "%") == 0) { ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );} - - else if (DataBuffer.compare(0, 10, "Heightmin=") == 0) { - check_Hmin = true ; - ConfigFile >> DataBuffer; - m_ChamberHmin = atof(DataBuffer.c_str()) * mm; - cout << "Chamber inner radius: " << m_ChamberHmin << endl ; - } - - else if (DataBuffer.compare(0, 10, "Heightmax=") == 0) { - check_Hmax = true ; - ConfigFile >> DataBuffer; - m_ChamberHmax = atof(DataBuffer.c_str()) * mm; - cout << "Chamber outer radius: " << m_ChamberHmax << endl ; - } - else if (DataBuffer.compare(0, 9, "Widthmin=") == 0) { - check_Wmin = true ; - ConfigFile >> DataBuffer; - m_ChamberWmin = atof(DataBuffer.c_str()) * mm; - cout << "Chamber inner radius: " << m_ChamberWmin << endl ; - } - - else if (DataBuffer.compare(0, 9, "Widthmax=") == 0) { - check_Wmax = true ; - ConfigFile >> DataBuffer; - m_ChamberWmax = atof(DataBuffer.c_str()) * mm; - cout << "Chamber outer radius: " << m_ChamberWmax << endl ; - } - else if (DataBuffer.compare(0, 9, "Depthmin=") == 0) { - check_Dmin = true ; - ConfigFile >> DataBuffer; - m_ChamberDmin = atof(DataBuffer.c_str()) * mm; - cout << "Chamber inner radius: " << m_ChamberDmin << endl ; - } - - else if (DataBuffer.compare(0, 9, "Depthmax=") == 0) { - check_Dmax = true ; - ConfigFile >> DataBuffer; - m_ChamberDmax = atof(DataBuffer.c_str()) * mm; - cout << "Chamber outer radius: " << m_ChamberDmax << endl ; - } - - - else if (DataBuffer.compare(0, 9, "MATERIAL=") == 0) { - check_Material = true ; - ConfigFile >> DataBuffer; - m_ChamberMaterial = GetMaterialFromLibrary(DataBuffer); - cout << "Chamber Material: " << m_ChamberMaterial << endl ; - } - - /////////////////////////////////////////////////// - // If no Beam Token and no comment, toggle out - else - {ReadingStatusGREATChamber = false; G4cout << "WARNING : Wrong Token Sequence: Getting out " << G4endl ;} - - /////////////////////////////////////////////////// - // If all Token found toggle out - if( check_Hmin && check_Hmax && check_Material && check_Wmin && check_Wmax && check_Dmin && check_Dmax ) - ReadingStatusGREATChamber = false ; - - } - - - + + //Search for comment Symbol % + if (DataBuffer.compare(0, 1, "%") == 0) { ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), +'\n' );} + + else if (DataBuffer.compare(0, 10, "Heightmin=") == 0) { + check_Hmin = true ; + ConfigFile >> DataBuffer; + m_ChamberHmin = atof(DataBuffer.c_str()) * mm; + cout << "Chamber inner radius: " << m_ChamberHmin << endl ; + } + + else if (DataBuffer.compare(0, 10, "Heightmax=") == 0) { + check_Hmax = true ; + ConfigFile >> DataBuffer; + m_ChamberHmax = atof(DataBuffer.c_str()) * mm; + cout << "Chamber outer radius: " << m_ChamberHmax << endl ; + } + else if (DataBuffer.compare(0, 9, "Widthmin=") == 0) { + check_Wmin = true ; + ConfigFile >> DataBuffer; + m_ChamberWmin = atof(DataBuffer.c_str()) * mm; + cout << "Chamber inner radius: " << m_ChamberWmin << endl ; + } + + else if (DataBuffer.compare(0, 9, "Widthmax=") == 0) { + check_Wmax = true ; + ConfigFile >> DataBuffer; + m_ChamberWmax = atof(DataBuffer.c_str()) * mm; + cout << "Chamber outer radius: " << m_ChamberWmax << endl ; + } + else if (DataBuffer.compare(0, 9, "Depthmin=") == 0) { + check_Dmin = true ; + ConfigFile >> DataBuffer; + m_ChamberDmin = atof(DataBuffer.c_str()) * mm; + cout << "Chamber inner radius: " << m_ChamberDmin << endl ; + } + + else if (DataBuffer.compare(0, 9, "Depthmax=") == 0) { + check_Dmax = true ; + ConfigFile >> DataBuffer; + m_ChamberDmax = atof(DataBuffer.c_str()) * mm; + cout << "Chamber outer radius: " << m_ChamberDmax << endl ; + } + + + else if (DataBuffer.compare(0, 9, "MATERIAL=") == 0) { + check_Material = true ; + ConfigFile >> DataBuffer; + m_ChamberMaterial = GetMaterialFromLibrary(DataBuffer); + cout << "Chamber Material: " << m_ChamberMaterial << endl ; + } + + /////////////////////////////////////////////////// + // If no Beam Token and no comment, toggle out + else + {ReadingStatusGREATChamber = false; G4cout << "WARNING : Wrong Token Sequence: Getting out " << G4endl ;} + + /////////////////////////////////////////////////// + // If all Token found toggle out + if( check_Hmin && check_Hmax && check_Material && check_Wmin && check_Wmax && check_Dmin && check_Dmax ) + ReadingStatusGREATChamber = false ; + + } + + + } @@ -817,1499 +799,1429 @@ void Chamber::ReadConfiguration(NPL::InputParser parser){ // Little trick to avoid warning in compilation: Use a PVPlacement "buffer". // If don't you will have a Warning unused variable 'myPVP' - G4VPhysicalVolume* PVPBuffer ; - +G4VPhysicalVolume* PVPBuffer; // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void Chamber::ConstructDetector(G4LogicalVolume* world) -{ - - if (m_ChamberType==0) { // case of standard Chamber +void Chamber::ConstructDetector(G4LogicalVolume* world) { - G4Sphere* solidChamber - = new G4Sphere("solidChamber", m_ChamberRmin, m_ChamberRmax, m_ChamberPhiMin, m_ChamberPhiMax, m_ChamberThetaMin, m_ChamberThetaMax ); + if (m_ChamberType == 0) { // case of standard Chamber - G4LogicalVolume* logicChamber = new G4LogicalVolume(solidChamber, m_ChamberMaterial, "logicChamber"); + G4Sphere* solidChamber = new G4Sphere("solidChamber", m_ChamberRmin, m_ChamberRmax, m_ChamberPhiMin, + m_ChamberPhiMax, m_ChamberThetaMin, m_ChamberThetaMax); - // rotation of target - //G4RotationMatrix *rotation = new G4RotationMatrix(); - //rotation->rotateY(m_ChamberAngle); + G4LogicalVolume* logicChamber = new G4LogicalVolume(solidChamber, m_ChamberMaterial, "logicChamber"); - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector(0., 0., 0.), logicChamber, "Chamber", world, false, 0); + // rotation of target + // G4RotationMatrix *rotation = new G4RotationMatrix(); + // rotation->rotateY(m_ChamberAngle); - G4VisAttributes* ChamberVisAtt = new G4VisAttributes(G4Colour(0., 1., 1.)); - logicChamber->SetVisAttributes(ChamberVisAtt); - // } - } - - else if(m_ChamberType==1){ // case of cryogenic target + PVPBuffer = new G4PVPlacement(0, G4ThreeVector(0., 0., 0.), logicChamber, "Chamber", world, false, 0); + G4VisAttributes* ChamberVisAtt = new G4VisAttributes(G4Colour(0., 1., 1.)); + logicChamber->SetVisAttributes(ChamberVisAtt); + // } + } - } + else if (m_ChamberType == 1) { // case of cryogenic target + } #ifdef NPS_GDML - else if(m_ChamberType==4){ // MARA chamber - G4GDMLParser m_gdmlparser; - //m_gdmlparser.Read("/mnt/hgfs/Echanges/gdml/honeycomb/HoneyComb.gdml"); - m_gdmlparser.Read(m_GDMLPath+m_GDMLName); - //m_LogicalGDML= m_gdmlparser.GetVolume("MARA_world"); - m_LogicalGDML= m_gdmlparser.GetVolume(m_GDMLWorld); + else if (m_ChamberType == 4) { // MARA chamber + G4GDMLParser m_gdmlparser; + // m_gdmlparser.Read("/mnt/hgfs/Echanges/gdml/honeycomb/HoneyComb.gdml"); + m_gdmlparser.Read(m_GDMLPath + m_GDMLName); + // m_LogicalGDML= m_gdmlparser.GetVolume("MARA_world"); + m_LogicalGDML = m_gdmlparser.GetVolume(m_GDMLWorld); - //G4RotationMatrix* rm= new G4RotationMatrix(); - //G4RotationMatrix rmY, rmZ; - //rmZ.rotateZ(0.*deg); - //rmY.rotateY(0.*deg); - - //*rm=rmY*rmZ; + // G4RotationMatrix* rm= new G4RotationMatrix(); + // G4RotationMatrix rmY, rmZ; + // rmZ.rotateZ(0.*deg); + // rmY.rotateY(0.*deg); - //G4Transform3D TF(rm, rm*G4ThreeVector(0., 0., 0.)); + //*rm=rmY*rmZ; - // gdml World box - m_LogicalGDML->SetVisAttributes(G4VisAttributes::Invisible); - - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector(0., 0., -0.15*cm), m_LogicalGDML, "MARA", world, false, 0 ); + // G4Transform3D TF(rm, rm*G4ThreeVector(0., 0., 0.)); + // gdml World box + m_LogicalGDML->SetVisAttributes(G4VisAttributes::GetInvisible()); - } - - else if(m_ChamberType==5){ // MuGast chamber - G4GDMLParser m_gdmlparser; - m_gdmlparser.Read(m_GDMLPath+m_GDMLName); - m_LogicalGDML= m_gdmlparser.GetVolume(m_GDMLWorld); + PVPBuffer = new G4PVPlacement(0, G4ThreeVector(0., 0., -0.15 * cm), m_LogicalGDML, "MARA", world, false, 0); + } - //G4RotationMatrix* rm= new G4RotationMatrix(); - //G4RotationMatrix rmY, rmZ; - //rmZ.rotateZ(0.*deg); - //rmY.rotateY(0.*deg); - - //*rm=rmY*rmZ; + else if (m_ChamberType == 5) { // MuGast chamber + G4GDMLParser m_gdmlparser; + m_gdmlparser.Read(m_GDMLPath + m_GDMLName); + m_LogicalGDML = m_gdmlparser.GetVolume(m_GDMLWorld); - //G4Transform3D TF(rm, rm*G4ThreeVector(0., 0., 0.)); + // G4RotationMatrix* rm= new G4RotationMatrix(); + // G4RotationMatrix rmY, rmZ; + // rmZ.rotateZ(0.*deg); + // rmY.rotateY(0.*deg); - // gdml World box - m_LogicalGDML->SetVisAttributes(G4VisAttributes::Invisible); - - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector(0., 0., 0.*cm), m_LogicalGDML, "MuGasTChamber", world, false, 0 ); + //*rm=rmY*rmZ; + // G4Transform3D TF(rm, rm*G4ThreeVector(0., 0., 0.)); - } + // gdml World box + m_LogicalGDML->SetVisAttributes(G4VisAttributes::GetInvisible()); + + PVPBuffer = new G4PVPlacement(0, G4ThreeVector(0., 0., 0. * cm), m_LogicalGDML, "MuGasTChamber", world, false, 0); + } #endif - - else if(m_ChamberType==2){ // case of GREAT chamber - G4Box* solidExtChamber - = new G4Box("solidExtChamber", m_ChamberWmax/2, m_ChamberHmax/2, m_ChamberDmax/2 ); - G4Box* solidIntChamber - = new G4Box("solidIntChamber", m_ChamberWmin/2, m_ChamberHmin/2, m_ChamberDmin/2 ); + else if (m_ChamberType == 2) { // case of GREAT chamber - G4SubtractionSolid* solidChamber=new G4SubtractionSolid("SolidChamber",solidExtChamber, solidIntChamber, 0, G4ThreeVector(0.,0.,-0.5*cm)); + G4Box* solidExtChamber = new G4Box("solidExtChamber", m_ChamberWmax / 2, m_ChamberHmax / 2, m_ChamberDmax / 2); + G4Box* solidIntChamber = new G4Box("solidIntChamber", m_ChamberWmin / 2, m_ChamberHmin / 2, m_ChamberDmin / 2); + G4SubtractionSolid* solidChamber = + new G4SubtractionSolid("SolidChamber", solidExtChamber, solidIntChamber, 0, G4ThreeVector(0., 0., -0.5 * cm)); - G4LogicalVolume* logicChamber = new G4LogicalVolume(solidChamber, m_ChamberMaterial, "logicChamber"); + G4LogicalVolume* logicChamber = new G4LogicalVolume(solidChamber, m_ChamberMaterial, "logicChamber"); - // rotation of target - //G4RotationMatrix *rotation = new G4RotationMatrix(); - //rotation->rotateY(m_ChamberAngle); + // rotation of target + // G4RotationMatrix *rotation = new G4RotationMatrix(); + // rotation->rotateY(m_ChamberAngle); - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector(0., -2.92325*cm/2, 0.), logicChamber, "Chamber", world, false, 0); + PVPBuffer = + new G4PVPlacement(0, G4ThreeVector(0., -2.92325 * cm / 2, 0.), logicChamber, "Chamber", world, false, 0); - G4VisAttributes* ChamberVisAtt = new G4VisAttributes(G4Colour(0., 1., 1.)); - logicChamber->SetVisAttributes(ChamberVisAtt); + G4VisAttributes* ChamberVisAtt = new G4VisAttributes(G4Colour(0., 1., 1.)); + logicChamber->SetVisAttributes(ChamberVisAtt); + /* Eleanor's additions: */ + /* - /* Eleanor's additions: *//* +// for the DSSSD (considered as passive here !!): - // for the DSSSD (considered as passive here !!): +G4Material* m_DSSSDMaterial = new G4Material("Si", 14, 28.0855*g/mole, 2.33*g/cm3); - G4Material* m_DSSSDMaterial = new G4Material("Si", 14, 28.0855*g/mole, 2.33*g/cm3); - - G4Box* solidDSSSD - = new G4Box("solidDSSSD", 6.*cm/2, 4.*cm/2, 0.03*cm/2 ); // +G4Box* solidDSSSD += new G4Box("solidDSSSD", 6.*cm/2, 4.*cm/2, 0.03*cm/2 ); // - G4LogicalVolume* logicDSSSD = new G4LogicalVolume(solidDSSSD, m_DSSSDMaterial, "logicDSSSD"); +G4LogicalVolume* logicDSSSD = new G4LogicalVolume(solidDSSSD, m_DSSSDMaterial, "logicDSSSD"); - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector(-3.2*cm, 0., 0.), logicDSSSD, "DSSSD", world, false, 0); - //new G4PVPlacement(0, G4ThreeVector(-3.2*cm, 2.92325*cm/2, 0.), logicDSSSD, "DSSSD", logicChamber, false, 0); - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector( 3.2*cm, 0., 0.), logicDSSSD, "DSSSD", world, false, 1); - //new G4PVPlacement(0, G4ThreeVector( 3.2*cm, 2.92325*cm/2, 0.), logicDSSSD, "DSSSD", logicChamber, false, 1); +PVPBuffer = +new G4PVPlacement(0, G4ThreeVector(-3.2*cm, 0., 0.), logicDSSSD, "DSSSD", world, false, 0); +//new G4PVPlacement(0, G4ThreeVector(-3.2*cm, 2.92325*cm/2, 0.), logicDSSSD, "DSSSD", logicChamber, false, 0); +PVPBuffer = +new G4PVPlacement(0, G4ThreeVector( 3.2*cm, 0., 0.), logicDSSSD, "DSSSD", world, false, 1); +//new G4PVPlacement(0, G4ThreeVector( 3.2*cm, 2.92325*cm/2, 0.), logicDSSSD, "DSSSD", logicChamber, false, 1); - G4VisAttributes* DSSSDVisAtt = new G4VisAttributes(G4Colour(0., 0., 1.)); - logicDSSSD->SetVisAttributes(DSSSDVisAtt); +G4VisAttributes* DSSSDVisAtt = new G4VisAttributes(G4Colour(0., 0., 1.)); +logicDSSSD->SetVisAttributes(DSSSDVisAtt); - // for the solid aluminium support : - - G4Box* solid_alu_support_ext - = new G4Box("solid_alu_support_ext", (18.32-0.65)*cm/2, (12.343-0.65)*cm/2, 8.5*cm/2 ); // - - G4Box* solid_alu_support_int - = new G4Box("solid_alu_support_int",16.27*cm/2, 10.295*cm/2, 8.6*cm/2 ); // - G4SubtractionSolid* solidsupport=new G4SubtractionSolid("Solidsupport",solid_alu_support_ext, solid_alu_support_int, 0, G4ThreeVector(0.,0.,0)); - G4LogicalVolume* logicALU = new G4LogicalVolume(solidsupport, m_ChamberMaterial, "logicALU"); +// for the solid aluminium support : - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector(0., -2.92325*cm/2,-4.265*cm), logicALU, "Aluminium", world, false, 0); +G4Box* solid_alu_support_ext += new G4Box("solid_alu_support_ext", (18.32-0.65)*cm/2, (12.343-0.65)*cm/2, 8.5*cm/2 ); // - G4VisAttributes* alusupportVisAtt = new G4VisAttributes(G4Colour(0.5, 0., 0.3)); - logicALU->SetVisAttributes(alusupportVisAtt); +G4Box* solid_alu_support_int += new G4Box("solid_alu_support_int",16.27*cm/2, 10.295*cm/2, 8.6*cm/2 ); // +G4SubtractionSolid* solidsupport=new G4SubtractionSolid("Solidsupport",solid_alu_support_ext, solid_alu_support_int, 0, +G4ThreeVector(0.,0.,0)); G4LogicalVolume* logicALU = new G4LogicalVolume(solidsupport, m_ChamberMaterial, "logicALU"); +PVPBuffer = +new G4PVPlacement(0, G4ThreeVector(0., -2.92325*cm/2,-4.265*cm), logicALU, "Aluminium", world, false, 0); - G4Box* solid_alu_support_int1 - = new G4Box("solid_alu_support_int1",16.27*cm/2, 0.55*cm/2, 8.6*cm/2 ); // - - G4LogicalVolume* logicALUint1 = new G4LogicalVolume(solid_alu_support_int1, m_ChamberMaterial, "logicALUint1"); +G4VisAttributes* alusupportVisAtt = new G4VisAttributes(G4Colour(0.5, 0., 0.3)); +logicALU->SetVisAttributes(alusupportVisAtt); - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector(0, -2.5215*cm-2.92325*cm/2, -4.265*cm), logicALUint1, "Aluminium", world, false, 0); - - G4VisAttributes* solid_alu_support_int1VisAtt = new G4VisAttributes(G4Colour(0.9, 0., 0.)); - logicALUint1->SetVisAttributes(solid_alu_support_int1VisAtt); +G4Box* solid_alu_support_int1 += new G4Box("solid_alu_support_int1",16.27*cm/2, 0.55*cm/2, 8.6*cm/2 ); // - G4Box* solid_alu_support_int2 - = new G4Box("solid_alu_support_int2",1.4*cm/2, 2.35*cm/2, 8.6*cm/2 ); // +G4LogicalVolume* logicALUint1 = new G4LogicalVolume(solid_alu_support_int1, m_ChamberMaterial, "logicALUint1"); - G4LogicalVolume* logicALUint2 = new G4LogicalVolume(solid_alu_support_int2, m_ChamberMaterial, "logicALUint2"); +PVPBuffer = +new G4PVPlacement(0, G4ThreeVector(0, -2.5215*cm-2.92325*cm/2, -4.265*cm), logicALUint1, "Aluminium", world, false, 0); - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector(0, -3.9715*cm-2.92325*cm/2, -4.265*cm), logicALUint2, "Aluminium", world, false, 0); +G4VisAttributes* solid_alu_support_int1VisAtt = new G4VisAttributes(G4Colour(0.9, 0., 0.)); +logicALUint1->SetVisAttributes(solid_alu_support_int1VisAtt); - - G4VisAttributes* solid_alu_support_int2VisAtt = new G4VisAttributes(G4Colour(0.9, 0., 0.)); - logicALUint2->SetVisAttributes(solid_alu_support_int2VisAtt); +G4Box* solid_alu_support_int2 += new G4Box("solid_alu_support_int2",1.4*cm/2, 2.35*cm/2, 8.6*cm/2 ); // - G4Box* solid_DSSSD_coating1 - = new G4Box("solid_DSSSD_coating1",16.27*cm/2, 0.1*cm/2, 8.6*cm/2 ); // +G4LogicalVolume* logicALUint2 = new G4LogicalVolume(solid_alu_support_int2, m_ChamberMaterial, "logicALUint2"); - G4LogicalVolume* logicSiliconCoating1 = new G4LogicalVolume(solid_DSSSD_coating1, m_DSSSDMaterial, "logicSiliconCoating1"); - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector(0, -2.5215*cm-2.92325*cm/2+0.05*cm+0.55*cm/2, -4.265*cm), logicSiliconCoating1, "PinDiode1", world, false, 0); +PVPBuffer = +new G4PVPlacement(0, G4ThreeVector(0, -3.9715*cm-2.92325*cm/2, -4.265*cm), logicALUint2, "Aluminium", world, false, 0); - G4VisAttributes* solid_DSSSD_coating1VisAtt = new G4VisAttributes(G4Colour(0., 0.2, 0.8)); - logicSiliconCoating1->SetVisAttributes(solid_DSSSD_coating1VisAtt); +G4VisAttributes* solid_alu_support_int2VisAtt = new G4VisAttributes(G4Colour(0.9, 0., 0.)); +logicALUint2->SetVisAttributes(solid_alu_support_int2VisAtt); - G4Box* solid_DSSSD_coating2 - = new G4Box("solid_DSSSD_coating2",16.27*cm/2, 0.1*cm/2, 8.6*cm/2 ); // - G4LogicalVolume* logicSiliconCoating2 = new G4LogicalVolume(solid_DSSSD_coating2, m_DSSSDMaterial, "logicSiliconCoating2"); - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector(0, 5.1055*cm-2.92325*cm/2-0.05*cm, -4.265*cm), logicSiliconCoating2, "PinDiode2", world, false, 0); +G4Box* solid_DSSSD_coating1 += new G4Box("solid_DSSSD_coating1",16.27*cm/2, 0.1*cm/2, 8.6*cm/2 ); // - G4VisAttributes* solid_DSSSD_coating2VisAtt = new G4VisAttributes(G4Colour(0., 0.2, 0.8)); - logicSiliconCoating2->SetVisAttributes(solid_DSSSD_coating2VisAtt); +G4LogicalVolume* logicSiliconCoating1 = new G4LogicalVolume(solid_DSSSD_coating1, m_DSSSDMaterial, +"logicSiliconCoating1"); PVPBuffer = new G4PVPlacement(0, G4ThreeVector(0, -2.5215*cm-2.92325*cm/2+0.05*cm+0.55*cm/2, +-4.265*cm), logicSiliconCoating1, "PinDiode1", world, false, 0); +G4VisAttributes* solid_DSSSD_coating1VisAtt = new G4VisAttributes(G4Colour(0., 0.2, 0.8)); +logicSiliconCoating1->SetVisAttributes(solid_DSSSD_coating1VisAtt); - G4Box* solid_DSSSD_coating3 - = new G4Box("solid_DSSSD_coating3",0.1*cm/2, 7.393*cm/2, 8.6*cm/2 ); // - G4LogicalVolume* logicSiliconCoating3 = new G4LogicalVolume(solid_DSSSD_coating3, m_DSSSDMaterial, "logicSiliconCoating3"); - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector(8.085*cm, 1.4375*cm-2.92325*cm/2, -4.265*cm), logicSiliconCoating3, "PinDiode3", world, false, 0); - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector(-8.085*cm, 1.4375*cm-2.92325*cm/2, -4.265*cm), logicSiliconCoating3, "PinDiode4", world, false, 1); - - G4VisAttributes* solid_DSSSD_coating3VisAtt = new G4VisAttributes(G4Colour(0., 0.2, 0.8)); - logicSiliconCoating3->SetVisAttributes(solid_DSSSD_coating3VisAtt); +G4Box* solid_DSSSD_coating2 += new G4Box("solid_DSSSD_coating2",16.27*cm/2, 0.1*cm/2, 8.6*cm/2 ); // +G4LogicalVolume* logicSiliconCoating2 = new G4LogicalVolume(solid_DSSSD_coating2, m_DSSSDMaterial, +"logicSiliconCoating2"); PVPBuffer = new G4PVPlacement(0, G4ThreeVector(0, 5.1055*cm-2.92325*cm/2-0.05*cm, -4.265*cm), +logicSiliconCoating2, "PinDiode2", world, false, 0); +G4VisAttributes* solid_DSSSD_coating2VisAtt = new G4VisAttributes(G4Colour(0., 0.2, 0.8)); +logicSiliconCoating2->SetVisAttributes(solid_DSSSD_coating2VisAtt); - // Preamps and connectors board - // PCB - +G4Box* solid_DSSSD_coating3 += new G4Box("solid_DSSSD_coating3",0.1*cm/2, 7.393*cm/2, 8.6*cm/2 ); // - G4Element* Si = new G4Element("Silicon" , "Si" , 14 , 28.0855 * g / mole); - G4Element* C = new G4Element("Carbon" , "C" , 6 , 12.011 * g / mole); - G4Element* H = new G4Element("Hydrogen" , "H" , 1 , 1.0079 * g / mole); - G4Element* Br = new G4Element("Bromine" , "Br" , 35 , 79.904 * g / mole); - G4Element* O = new G4Element("Oxigen" , "O" , 8 , 16.00 * g / mole); +G4LogicalVolume* logicSiliconCoating3 = new G4LogicalVolume(solid_DSSSD_coating3, m_DSSSDMaterial, +"logicSiliconCoating3"); PVPBuffer = new G4PVPlacement(0, G4ThreeVector(8.085*cm, 1.4375*cm-2.92325*cm/2, -4.265*cm), +logicSiliconCoating3, "PinDiode3", world, false, 0); PVPBuffer = new G4PVPlacement(0, +G4ThreeVector(-8.085*cm, 1.4375*cm-2.92325*cm/2, -4.265*cm), logicSiliconCoating3, "PinDiode4", world, false, 1); - G4double density = 1.7 * g / cm3; - G4int ncomponents; - G4Material* PCB = new G4Material("PCB", density, ncomponents = 5); - PCB->AddElement(Si, .181); - PCB->AddElement(O, .406); - PCB->AddElement(C, .278); - PCB->AddElement(H, .068); - PCB->AddElement(Br, .067); +G4VisAttributes* solid_DSSSD_coating3VisAtt = new G4VisAttributes(G4Colour(0., 0.2, 0.8)); +logicSiliconCoating3->SetVisAttributes(solid_DSSSD_coating3VisAtt); - G4Box* pre_amp_board1 - = new G4Box("pre_amp_board1",6.756*cm/2, 1.675*cm/2, 7.976*cm/2 ); // +// Preamps and connectors board - G4LogicalVolume* logicpre_amp1 = new G4LogicalVolume(pre_amp_board1, PCB, "logicpre_amp1"); - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector(4.0675*cm, 5.267875*cm, -4.265*cm), logicpre_amp1, "pre_amp_board1", world, false, 0); - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector(-4.0675*cm, 5.267875*cm, -4.265*cm), logicpre_amp1, "pre_amp_board1", world, false, 1); - +// PCB - G4VisAttributes* pre_amp_board1VisAtt = new G4VisAttributes(G4Colour(0., 0.7, 0.)); - logicpre_amp1->SetVisAttributes(pre_amp_board1VisAtt); - G4Box* pre_amp_board2 - = new G4Box("pre_amp_board2",1.675*cm/2, 6.756*cm/2, 7.976*cm/2 ); // +G4Element* Si = new G4Element("Silicon" , "Si" , 14 , 28.0855 * g / mole); +G4Element* C = new G4Element("Carbon" , "C" , 6 , 12.011 * g / mole); +G4Element* H = new G4Element("Hydrogen" , "H" , 1 , 1.0079 * g / mole); +G4Element* Br = new G4Element("Bromine" , "Br" , 35 , 79.904 * g / mole); +G4Element* O = new G4Element("Oxigen" , "O" , 8 , 16.00 * g / mole); - G4LogicalVolume* logicpre_amp2 = new G4LogicalVolume(pre_amp_board2, PCB, "logicpre_amp2"); - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector(9.6625*cm, 2.413375*cm, -4.265*cm), logicpre_amp2, "pre_amp_board2", world, false, 0); - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector(9.6625*cm, -5.336625*cm, -4.265*cm), logicpre_amp2, "pre_amp_board2", world, false, 1); - +G4double density = 1.7 * g / cm3; +G4int ncomponents; +G4Material* PCB = new G4Material("PCB", density, ncomponents = 5); +PCB->AddElement(Si, .181); +PCB->AddElement(O, .406); +PCB->AddElement(C, .278); +PCB->AddElement(H, .068); +PCB->AddElement(Br, .067); - G4VisAttributes* pre_amp_board2VisAtt = new G4VisAttributes(G4Colour(0., 0.7, 0.)); - logicpre_amp2->SetVisAttributes(pre_amp_board2VisAtt); - - G4Box* pre_amp_board3 - = new G4Box("pre_amp_board3",1.675*cm/2, 6.756*cm/2, 7.976*cm/2 ); // - G4LogicalVolume* logicpre_amp3 = new G4LogicalVolume(pre_amp_board3, PCB, "logicpre_amp3"); - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector(-9.6725*cm, 2.413375*cm, -4.265*cm), logicpre_amp3, "pre_amp_board3", world, false, 0); - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector(-9.6725*cm, -5.336625*cm, -4.265*cm), logicpre_amp3, "pre_amp_board3", world, false, 1); - +G4Box* pre_amp_board1 += new G4Box("pre_amp_board1",6.756*cm/2, 1.675*cm/2, 7.976*cm/2 ); // - G4VisAttributes* pre_amp_board3VisAtt = new G4VisAttributes(G4Colour(0., 0.7, 0.)); - logicpre_amp3->SetVisAttributes(pre_amp_board3VisAtt); +G4LogicalVolume* logicpre_amp1 = new G4LogicalVolume(pre_amp_board1, PCB, "logicpre_amp1"); +PVPBuffer = +new G4PVPlacement(0, G4ThreeVector(4.0675*cm, 5.267875*cm, -4.265*cm), logicpre_amp1, "pre_amp_board1", world, false, +0); PVPBuffer = new G4PVPlacement(0, G4ThreeVector(-4.0675*cm, 5.267875*cm, -4.265*cm), logicpre_amp1, "pre_amp_board1", +world, false, 1); - */ /* end of Eleanor's additions */ +G4VisAttributes* pre_amp_board1VisAtt = new G4VisAttributes(G4Colour(0., 0.7, 0.)); +logicpre_amp1->SetVisAttributes(pre_amp_board1VisAtt); +G4Box* pre_amp_board2 += new G4Box("pre_amp_board2",1.675*cm/2, 6.756*cm/2, 7.976*cm/2 ); // +G4LogicalVolume* logicpre_amp2 = new G4LogicalVolume(pre_amp_board2, PCB, "logicpre_amp2"); +PVPBuffer = +new G4PVPlacement(0, G4ThreeVector(9.6625*cm, 2.413375*cm, -4.265*cm), logicpre_amp2, "pre_amp_board2", world, false, +0); PVPBuffer = new G4PVPlacement(0, G4ThreeVector(9.6625*cm, -5.336625*cm, -4.265*cm), logicpre_amp2, "pre_amp_board2", +world, false, 1); - } +G4VisAttributes* pre_amp_board2VisAtt = new G4VisAttributes(G4Colour(0., 0.7, 0.)); +logicpre_amp2->SetVisAttributes(pre_amp_board2VisAtt); - else if(m_ChamberType==3){ // case of GREAT chamber as defined by Karl - - fChamberH = m_ChamberHmax; - fChamberW = m_ChamberWmax; - //fChamberL = m_ChamberDmax; - fChamberThickness= m_ChamberHmax-m_ChamberHmin; - - fVacuumH = fChamberH - fChamberThickness; - - G4cout << "fChamberH=" << fChamberH << G4endl; - G4cout << "fChamberW=" << fChamberW << G4endl; - G4cout << "fChamberThickness=" << fChamberThickness << G4endl; - - //----------------------------- - // more dimesions for chamber - fChamberL = fCoolingBlockL + fLengthOfPlanarCut + fDSSD_BoardL + fdeltaZ_Support + 2.*fChamberThickness + 10.0*mm; - - - //--------------------------------------------------------------------------------- - // This shift in the position of the chamber is to put the DSSD centred at y = 0 - fShiftChamberY = fCoolingBlockH - fCoolingBlockT - fCoolingBlockCutOutH/2.; //height of centre wrt cooling block base - fShiftChamberY -= fChamberH/2.; - - //Define the downstream face of the DSSD to be at 0 (ie the centre of the DSSD PCB board) - fShiftChamberZ = fCoolingBlockZ + fChamberThickness - fDSSD_BoardL/2.; //a discrepency of 1 mm somewhere - - //the centre of the DSSD wrt the vacuum chamber - fCentreOfDSSD_Y = -fVacuumH/2. + fCoolingBlockH - fCoolingBlockT - fCoolingBlockCutOutH/2.; //+ fChamberThickness - cout << G4endl << " DSSD_Y at 0 mm , but wrt vacuum DSSD_Y @ " << fCentreOfDSSD_Y << G4endl; - - - - - - //-------------------------------------------- - //[partial] Vacuum Chamber (Walls+Vacuum) and end BackPlate - //Set the Upstream side of the Chamber @ Z=0mm - - - //G4Box* solidChamber = new G4Box("chamber",fChamberW/2., fChamberH/2., fChamberL/2.); - // replaced by achamber with a substraction of the Planar area: - G4Box* solidChamberEnv = new G4Box("chamberEnv",fChamberW/2., fChamberH/2., fChamberL/2.); - G4double PlanarCap_W = fPlanarGe_W + 2.*fPlanarGuard + 80.*mm; //A GUESS - G4double PlanarCap_H = 150.*mm; - PlanarCap_H = fPlanarGe_H + 70*mm; - G4double PlanarCap_T = fPlanarTotalL; - G4cout << G4endl << "Planar end-cap thickness " << PlanarCap_T << " cf 41. mm" << G4endl; - fShiftPlanar = fChamberL/2. - fChamberThickness + PlanarCap_T/2. - fLengthOfPlanarCut + fGap_PCB_2_Planar; - G4double Planar_z = fShiftPlanar; - G4Box* solidPlanarCapEnv = new G4Box("planar-cap-Env", PlanarCap_W/2., PlanarCap_H/2., PlanarCap_T/2.); - G4SubtractionSolid* solidChamber = - new G4SubtractionSolid("chamber", solidChamberEnv, solidPlanarCapEnv, 0, G4ThreeVector(0.0*mm, fCentreOfDSSD_Y, Planar_z)); - - // end of replacement - - G4LogicalVolume* logicChamber = new G4LogicalVolume(solidChamber, //it's solid - m_ChamberMaterial,//it's material - //chamberMaterial,//it's material - //vacuumMaterial,//it's material - "Chamber", //it's name - 0, 0, 0); // field manager, sensitive det, user limits - - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.0*mm,-fShiftChamberY,-fChamberL/2.+fShiftChamberZ), - logicChamber, //its logical volume - "Chamber", //its name - world, //its mother - false, //no boolean operat - 0, //copy number - true); //overlap check - - //viewing the chamber - G4VisAttributes* visAttChamber = new G4VisAttributes(G4Colour(1.0,1.0,1.0) ); - visAttChamber->SetVisibility(true); - visAttChamber->SetForceWireframe(true); - logicChamber->SetVisAttributes(visAttChamber); - //logicChamber->SetVisAttributes(G4VisAttributes::Invisible); - - - - //Vacuum within above partial chamber - - G4double vacH = fChamberH - fChamberThickness; - G4double vacW = fChamberW - 2.*fChamberThickness; - G4double vacL = fChamberL - 2.*fChamberThickness; - - //G4Box* solidChamVac = new G4Box("chamVac",vacW/2., vacH/2., vacL/2.); - //Replaced by - G4Box* solidChamVacEnv = new G4Box("chamVacEnV",vacW/2., vacH/2., vacL/2.); - //G4Box* solidPlanarCapEnv = new G4Box("planar-cap-Env", PlanarCap_W/2., PlanarCap_H/2., PlanarCap_T/2.); - G4SubtractionSolid* solidChamVac = - new G4SubtractionSolid("chamVac", solidChamVacEnv, solidPlanarCapEnv, 0, G4ThreeVector(0.0*mm, fCentreOfDSSD_Y+fChamberThickness/2., Planar_z)); - - - G4LogicalVolume* logicChamVac = new G4LogicalVolume(solidChamVac, //it's solid - vacuumMaterial, //it's material - "chamVac", //it's name - 0, 0, 0); // field manager, sensitive det, user limits - - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.0*cm, -fChamberThickness/2., 0.0*cm), - logicChamVac, //its logical volume - "ChamVac", //its name - logicChamber, //its mother - false, //no boolean operat - 0, //copy number - true); //overlap check - - //logicChamVac->SetVisAttributes(G4VisAttributes::Invisible); - logicChamVac->SetVisAttributes(visAttChamber); - - - - /* Uncomment if you want the planar in the geometry and you are not using GRTPlan */ - /* - //---------------------------------------------------------------------- - // The Planar - //---------------------------------------------------------------------- - G4double PlanarCap_W = fPlanarGe_W + 2.*fPlanarGuard + 80.*mm; //A GUESS - G4double PlanarCap_H = 150.*mm; - PlanarCap_H = fPlanarGe_H + 70*mm; - G4double PlanarCap_T = fPlanarTotalL; - G4cout << G4endl << "Planar end-cap thickness " << PlanarCap_T << " cf 41. mm" << G4endl; - - // - editted 07/11/2011 - fShiftPlanar = fChamberL/2. - fChamberThickness + PlanarCap_T/2. - fLengthOfPlanarCut + fGap_PCB_2_Planar; - G4double Planar_z = fShiftPlanar; - fPlanar_PosZ = Planar_z; - - //starting endCap sold - G4Box* solidPlanarCap = new G4Box("planar-cap", PlanarCap_W/2., PlanarCap_H/2., PlanarCap_T/2.); - - //cut outs for Be window : planar end-cap is deliberately symmetric to make positioning more simple - //3 mm wide support rib that is 2.2 mm thick. Add the Be thickness => endCap thickness - G4Box* solidBeCutOut = new G4Box("be-cut-out", fPlanarGe_W/4.-1.5*mm, fPlanarGe_H/2., fEndCapThickness/2.);//is it total 120 mm or 120+gap ? - G4ThreeVector beCutOutTrans1(-fPlanarGe_W/4.-1.5*mm, 0.0*mm, -PlanarCap_T/2.+fEndCapThickness/2.); - G4ThreeVector beCutOutTrans2(+fPlanarGe_W/4.+1.5*mm, 0.0*mm, -PlanarCap_T/2.+fEndCapThickness/2.); - - - G4SubtractionSolid* solidPlanarCap_tmp1 = - new G4SubtractionSolid("planar-capo-1", solidPlanarCap, solidBeCutOut, 0, beCutOutTrans1); - - G4SubtractionSolid* solidPlanarCap_tmp2 = - new G4SubtractionSolid("planar-capo-2", solidPlanarCap_tmp1, solidBeCutOut, 0, beCutOutTrans2); - - - //cut outs for Al window at rear - G4Box* solidAlCutOut = new G4Box("Al-cut-out", fPlanarGe_W/2., fPlanarGe_H/2., fAlWindowThickness/2.); - G4ThreeVector alCutOutTrans(0.0*mm, 0.0*mm, PlanarCap_T/2.-fAlWindowThickness/2.); //ends up being 0.9 mm instead of 1.1 mm thick: CORRECT IT - - G4SubtractionSolid* solidPlanarCap_tmp3 = - new G4SubtractionSolid("planar-capo-3", solidPlanarCap_tmp2, solidAlCutOut, 0, alCutOutTrans); - - - G4LogicalVolume* logicPlanarCap = new G4LogicalVolume(solidPlanarCap_tmp3, // it's solid - //logicPlanarCap = new G4LogicalVolume(solidPlanarCap, // it's solid - endCapMaterial, // it's material - "planar-cap", // it's name - 0, 0, 0); // field manager, sensitive det, user limits - - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.0*mm, fCentreOfDSSD_Y, Planar_z), - logicPlanarCap, //its logical volume - "PlanarCap", //its name - logicChamVac, //its mother - false, //no boolean operat - 0, //copy number - true); //overlap check - - - - - G4VisAttributes* visAttPlanarCapo = new G4VisAttributes(G4Colour(1.0,0.8,1.0) ); - visAttPlanarCapo->SetVisibility(true); - //visAttPlanarCapo->SetVisibility(false); - visAttPlanarCapo->SetForceWireframe(true); - logicPlanarCap->SetVisAttributes(visAttPlanarCapo); - - - //----------------------------------------------------------------------------------------------- - //add the Be window - G4double PlanarBeWindow_z = -PlanarCap_T/2. + fBeWindowThickness/2.; - - G4Box* solidPlanarBeWindow = new G4Box("planar-be", fPlanarGe_W/2., fPlanarGe_H/2., fBeWindowThickness/2.); - - G4LogicalVolume* logicPlanarBeWindow = new G4LogicalVolume(solidPlanarBeWindow,// it's solid - beMaterial, // it's material - "planar-be", // it's name - 0, 0, 0); // field manager, sensitive det, user limits - - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.0*mm, 0.0*mm, PlanarBeWindow_z), - logicPlanarBeWindow, //its logical volume - "Planar-Be", //its name - logicPlanarCap, //its mother - false, //no boolean operat - 0, //copy number - true); //overlap check - - G4VisAttributes* visAttBeWindow = new G4VisAttributes(G4Colour(0.9,1.0,0.9) ); - visAttBeWindow->SetVisibility(true); - //visAttBeWindow->SetVisibility(false); - visAttBeWindow->SetForceWireframe(true); - logicPlanarBeWindow->SetVisAttributes(visAttBeWindow); - //----------------------------------------------------------------------------------------------- - //special cut out for Vacuum.... - //fAlWindowThickness - //fEndCapThickness - //PlanarCap_T - 2*fEndCapThickness - - - - //cut outs for windows and vacuum - G4Box* solidPlanarVac = new G4Box("planar-vac", PlanarCap_W/2.-fEndCapThickness, PlanarCap_H/2.-fEndCapThickness, PlanarCap_T/2.-fEndCapThickness); - - G4LogicalVolume* logicPlanarVac = new G4LogicalVolume(solidPlanarVac,// it's solid - vacuumMaterial, // it's material - "planar-vac", // it's name - 0, 0, 0); // field manager, sensitive det, user limits - - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.0*mm, 0.0*mm, 0.0*mm), - logicPlanarVac, //its logical volume - "Planar-Vac", //its name - logicPlanarCap, //its mother - false, //no boolean operat - 0, //copy number - true); //overlap check - - G4cout << "Got Here" << G4endl; - - //visual attributes of the planar end-cap - //G4VisAttributes* visAttPlanarCapo = new G4VisAttributes(G4Colour(1.0,0.8,1.0) ); - //visAttPlanarCapo->SetVisibility(true); - //visAttPlanarCapo->SetVisibility(false); - //visAttPlanarCapo->SetForceWireframe(true); - //logicPlanarCap->SetVisAttributes(visAttPlanarCapo); - logicPlanarVac->SetVisAttributes(visAttPlanarCapo); - - - - - // the planar Ge - G4double PlanarGe_z = -PlanarCap_T/2. + fPlanarGe_T/2. + fPlanarGeGapFront; - - //add in a slab of Ge to accomodate the guard-rail - //and into this slab add the pixels - G4Box* solidPlanarOuterGe = new G4Box("planar-outer-ge", fPlanarGe_W/2.+fPlanarGuard, fPlanarGe_H/2.+fPlanarGuard, fPlanarGe_T/2.); - G4LogicalVolume* logicPlanarOuterGe = new G4LogicalVolume(solidPlanarOuterGe, // it's solid - geMaterial, // it's material - "planar-outer-ge", // it's name - 0, 0, 0); // field manager, sensitive det, user limits - - //G4PVPlacement* physiPlanarOuterGe = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm, 0.0*mm, PlanarGe_z), - logicPlanarOuterGe, //its logical volume - "Planar-Outer-Ge", //its name - logicPlanarVac, //its mother - false, //no boolean operat - 0, true); //copy number - - G4VisAttributes* visAttPlanarOuterGe = new G4VisAttributes(G4Colour(0.9,0.9,1.0) ); - visAttPlanarOuterGe->SetVisibility(true); - //visAttPlanarOuterGe->SetVisibility(false); - visAttPlanarOuterGe->SetForceWireframe(true); - logicPlanarOuterGe->SetVisAttributes(visAttPlanarOuterGe); - - - - //segment the detector - G4int nSegsH = 12; //(y) - G4int nSegsW = 24; //(x) - - //nSegsH = 1; - //nSegsW = 1; - - //common planar "pixel" shape - G4double planarPixel_H = fPlanarGe_H/(G4double) nSegsH; - G4double planarPixel_W = fPlanarGe_W/(G4double) nSegsW; - - G4Box* solidPlanarGe = new G4Box("planar-ge", planarPixel_W/2., planarPixel_H/2., fPlanarGe_T/2.); - - G4VisAttributes* visAttPlanarGe = new G4VisAttributes(G4Colour(1.0,1.0,1.0) ); - visAttPlanarGe->SetVisibility(true); - //visAttPlanarGe->SetVisibility(false); - visAttPlanarGe->SetForceWireframe(true); - logicPlanarOuterGe->SetVisAttributes(visAttPlanarGe); - - //starting y-position for lowest row - G4double thisY = -fPlanarGe_H/2. + planarPixel_H/2.;// + fDSSD_PosY; - - for(G4int ny = 0; ny < nSegsH; ny++) { - //starting x-position - G4double thisX = -fPlanarGe_W/2. + planarPixel_W/2.; - //G4double posY = (2*ny-1)*planarPixel_H/2.; - - for(G4int nx = 0; nx < nSegsW; nx++) { - //G4double posX = -fPlanarGe_W/2. + planarPixel_W/2. + nx*planarPixel_W; - //G4int copyNo = ny*nSegsW+nx; - //G4cout << "Check Planar CopyNo " << copyNo << " @ " << posX << " " << posY << G4endl; - G4int copyNo = ny*100+nx; - G4cout << "Check Planar CopyNo " << copyNo << " @ " << thisX << " " << thisY << G4endl; - - //logicPlanarGe[copyNo] = new G4LogicalVolume(solidPlanarGe,// it's solid - logicPlanarGe[ny][nx] = new G4LogicalVolume(solidPlanarGe,// it's solid - geMaterial, // it's material - "planar-ge", // it's name - 0, 0, 0); // field manager, sensitive det, user limits - - - //physiPlanarGe[copyNo] = new G4PVPlacement(0, //rotation - //G4ThreeVector(posX, posY, 0.0*mm), - //physiPlanarGe[ny][nx] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(thisX, thisY, 0.0*mm), - //logicPlanarGe[copyNo], //its logical volume - logicPlanarGe[ny][nx], //its logical volume - "Planar-Ge", //its name - logicPlanarOuterGe, //its mother - false, //no boolean operat - copyNo); //copy number - - //set attributes - logicPlanarGe[ny][nx]->SetVisAttributes(visAttPlanarGe); - - //move along.... - thisX += planarPixel_W; - } - thisY += planarPixel_H; - } - - */ - - //---------------------------------------------------------- - // Cooling Frame: Tunnel and DSSD Detector Support - //---------------------------------------------------------- - G4VisAttributes* visAttCoolingBlock = new G4VisAttributes(G4Colour(0.8,0.8,0.8)); - visAttCoolingBlock->SetVisibility(true); - //visAttCoolingBlock->SetVisibility(false); - visAttCoolingBlock->SetForceWireframe(true); - - G4Box* OuterBox = new G4Box("OuterBox",fCoolingBlockW/2., fCoolingBlockH/2., fCoolingBlockL/2.); - - //place the support on the bottom of the chamber - G4double DSSD_SupPos_y = -fChamberH/2. + fCoolingBlockH/2. + fChamberThickness/2.; - - //position wrt BackPlate/VacChamber - G4double DSSD_SupPos_z = fChamberL/2. - fChamberThickness - fCoolingBlockL/2. - fCoolingBlockZ; - - //now cut a hole out for the DSSD's - G4double Hole4DSSD_W = fCoolingBlockCutOutW; - G4double Hole4DSSD_H = fCoolingBlockCutOutH; - - //from the above can determine the centre of the DSSD wrt centre of Cooling block - fCoolingBlockCutOut_PosY = fCoolingBlockH/2. - fCoolingBlockT - fCoolingBlockCutOutH/2.; //save this frequently used position - G4cout << "fCoolingBlockCutOut_PosY " << fCoolingBlockCutOut_PosY << " cf " << fCoolingBlockDSSDCentre << G4endl; - - G4Box* hole1 = new G4Box("Hole #1",Hole4DSSD_W/2., Hole4DSSD_H/2., fCoolingBlockL/2.); - - G4double dy = fCoolingBlockH/2. - fCoolingBlockT - Hole4DSSD_H/2.; - G4double dx = 0.0*mm; - G4double dz = 0.0*mm; - G4ThreeVector hole1trans(dx, dy, dz); - - G4SubtractionSolid* solid_CB_Temp1 = - new G4SubtractionSolid("fCoolingBlockTemp1", OuterBox, hole1, 0, hole1trans); - - //now cut a hole out for preamps - G4Box* holePreAmp = new G4Box("Hole PreAmp",34.5/2.*mm, 22./2.*mm, fCoolingBlockL/2.); - dx = -fCoolingBlockW/2.+fCoolingBlockT+34.5/2.*mm; - dy = fCoolingBlockH/2. - fCoolingBlockT - Hole4DSSD_H - fCoolingBlockT - 22./2.*mm; - G4ThreeVector holePreAmpTrans1(dx, dy, dz); - dx += (34.5*mm + fCoolingBlockT); - G4ThreeVector holePreAmpTrans2(dx, dy, dz); - dx += (34.5*mm + 14.7*mm); - G4ThreeVector holePreAmpTrans3(dx, dy, dz); - dx += (34.5*mm + fCoolingBlockT); - G4ThreeVector holePreAmpTrans4(dx, dy, dz); - - G4SubtractionSolid* solid_CB_Temp2 = - new G4SubtractionSolid("fCoolingBlockTemp2", solid_CB_Temp1, holePreAmp, 0, holePreAmpTrans1); - - G4SubtractionSolid* solid_CB_Temp3 = - new G4SubtractionSolid("fCoolingBlockTemp3", solid_CB_Temp2, holePreAmp, 0, holePreAmpTrans2); - - G4SubtractionSolid* solid_CB_Temp4 = - new G4SubtractionSolid("fCoolingBlockTemp4", solid_CB_Temp3, holePreAmp, 0, holePreAmpTrans3); - - G4SubtractionSolid* solid_CB_Temp5 = - new G4SubtractionSolid("fCoolingBlockTemp5", solid_CB_Temp4, holePreAmp, 0, holePreAmpTrans4); - - G4LogicalVolume* logicDSSD_Sup = new G4LogicalVolume(solid_CB_Temp5, - supportMaterial, "Cylinder-Box", 0, 0, 0); - //vacuumMaterial, "Cylinder-Box", 0, 0, 0); - - logicDSSD_Sup->SetVisAttributes(visAttCoolingBlock); - - - PVPBuffer = new G4PVPlacement(0,//rotation - G4ThreeVector(0.0*cm, DSSD_SupPos_y, DSSD_SupPos_z), - logicDSSD_Sup, //its logical volume - "fCoolingBlock", //its name - logicChamVac, //its mother - false, //no boolean operat - 1, //copy number - true); //overlap check - - - - - - //------------------------------------------------------------------------------------------- - // DSSD detector Epoxy board....for some reason 2 cut outs are not working => make 2 PCB wafers - G4double DSSD_BrdW = 106.0 * mm * 2.; //Put the 2 boards in one plate - G4double DSSD_BrdH = 157.0 * mm; //SupportH; - G4double DSSD_BrdL = fDSSD_BoardL; //Thickness - - //recess to house DSSD's - G4double siImpBrdCutOutL = fDSSD_BoardL/2.; - // making 2 boards => - G4double DSSD_BrdL1 = DSSD_BrdL - siImpBrdCutOutL; - G4double DSSD_BrdL2 = siImpBrdCutOutL; - - G4double CutOut_dY = 44.0*mm; // distance from top of PCB to top of the first cut-out in the PCB - G4double CutOut1_H = 43.5*mm; // vertical dimension of the cut-out to half thickness - G4double CutOut2_H = 41.0*mm; // vertical dimension of total-thickness cut-ou ie a mounting lip of 1.25 mm - - G4double CutOut1_W = 63.5*mm; //fDSSD_H-2.0*boardLipDSSD; - G4double CutOut2_W = 61.0*mm; //fDSSD_H; - - G4double dssdLip = (CutOut1_W-CutOut2_W)/2.; - G4double central_bar = 1.25*mm; //each side - - G4double DSSD_PCB_Pos_y = -fVacuumH/2. - DSSD_BrdH/2.; //puts top of circuit board at bottom of chamber - DSSD_PCB_Pos_y += (fCoolingBlockDSSDCentre + CutOut_dY + CutOut1_H/2.); - - G4double gapBetweenDSSD = 3.0 * mm; //Gap between the two DSSD's - - //gapBetweenDSSD = 0.01*mm; - - //position wrt centre of vacuum in chamber - G4double DSSD_BrdPos_z = fChamberL/2 - fChamberThickness - fCoolingBlockZ + DSSD_BrdL1/2 + DSSD_BrdL2; - - G4Box* solidDSSD_Board1_tmp1 = - new G4Box("siImpBrd1_tmp", DSSD_BrdW/2., DSSD_BrdH/2., DSSD_BrdL1/2.); - - G4Box* cutOut1a = new G4Box("Box R #1a",CutOut1_W/2., CutOut1_H/2., DSSD_BrdL1/2.); - G4ThreeVector cutOut1aTrans(CutOut1_W/2., DSSD_BrdH/2.-CutOut1_H/2.-CutOut_dY, 0.0*mm); - - G4Box* cutOut1b = new G4Box("Box R #1b",CutOut1_W/2.,CutOut1_H/2.,DSSD_BrdL1/2.); - G4ThreeVector cutOut1bTrans(-CutOut1_W/2., DSSD_BrdH/2.-CutOut1_H/2.-CutOut_dY, 0.0*mm); - - - G4SubtractionSolid* solidDSSD_Board1_a = - new G4SubtractionSolid("siImpBrd1_a", solidDSSD_Board1_tmp1, cutOut1a, 0, cutOut1aTrans); - - G4SubtractionSolid* solidDSSD_Board1 = - new G4SubtractionSolid("siImpBrd1", solidDSSD_Board1_a, cutOut1b, 0, cutOut1bTrans); - - G4LogicalVolume* logicDSSD_Board1 = new G4LogicalVolume(solidDSSD_Board1,// it's solid : with cut-out - boardMaterial, // it's material - //vacuumMaterial, - "DSSD_Brd1", // it's name - 0, 0, 0); // field manager, sensitive det, user limits - - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.0*mm,DSSD_PCB_Pos_y,DSSD_BrdPos_z), - logicDSSD_Board1, //its logical volume - "DSSD_Brd1", //its name - logicChamVac, //its mother - false, //no boolean operat - 0, //copy number - true); //overlap check - - - DSSD_BrdPos_z -= DSSD_BrdL1/2; - DSSD_BrdPos_z -= DSSD_BrdL2/2; - - G4Box* solidDSSD_Board2_tmp1 = - new G4Box("siImpBrd2_tmp", DSSD_BrdW/2., DSSD_BrdH/2., DSSD_BrdL2/2.); - - G4Box* cutOut2a = new G4Box("Box R #2a",CutOut2_W/2.,CutOut2_H/2.,DSSD_BrdL2/2.); - G4ThreeVector cutOut2aTrans(CutOut2_W/2.+central_bar, DSSD_BrdH/2.-CutOut2_H/2.-CutOut_dY-dssdLip, 0.0*mm); - - G4Box* cutOut2b = new G4Box("Box R #2b",CutOut2_W/2.,CutOut2_H/2.,DSSD_BrdL2/2.); - G4ThreeVector cutOut2bTrans(-CutOut2_W/2.-central_bar, DSSD_BrdH/2.-CutOut2_H/2.-CutOut_dY-dssdLip, 0.0*mm); - - G4SubtractionSolid* solidDSSD_Board2_a = - new G4SubtractionSolid("siImpBrd2_a", solidDSSD_Board2_tmp1, cutOut2a, 0, cutOut2aTrans); - - G4SubtractionSolid* solidDSSD_Board2 = - new G4SubtractionSolid("siImpBrd2", solidDSSD_Board2_a, cutOut2b, 0, cutOut2bTrans); - - G4LogicalVolume* logicDSSD_Board2 = new G4LogicalVolume(solidDSSD_Board2,// it's solid : with cut-out - boardMaterial, // it's material - //vacuumMaterial, - "DSSD_Brd2", // it's name - 0, 0, 0); // field manager, sensitive det, user limits - - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.0*mm,DSSD_PCB_Pos_y,DSSD_BrdPos_z), - logicDSSD_Board2, //its logical volume - "DSSD_Brd2", //its name - logicChamVac, //its mother - false, //no boolean operat - 0, //copy number - true); //overlap check - - - - //-------------------------------------------- - // Implantation detectors - //first make two Si boards -> gauard ring... - G4VisAttributes* visAttDSSD_1 = new G4VisAttributes(G4Colour(0.6,0.4,0.4) ); - visAttDSSD_1->SetVisibility(true); - //visAttDSSD_1->SetVisibility(false); - visAttDSSD_1->SetForceWireframe(true); - - G4double DSSD_z = DSSD_BrdPos_z - DSSD_BrdL/2. - 3.*fDSSD_T/2. + (DSSD_BrdL-siImpBrdCutOutL); - DSSD_z = fChamberL/2 - fChamberThickness - fCoolingBlockZ + DSSD_BrdL2 - fDSSD_T/2.; - G4cout << "DSSD Z wrt ChamberVac " << DSSD_z << G4endl; - - G4double totalDSSD_H = fDSSD_H+2.*fDSSD_Guard; - G4double totalDSSD_W = fDSSD_W+2.*fDSSD_Guard; - G4Box* solidSi1 = new G4Box("Si1", totalDSSD_W/2., totalDSSD_H/2., fDSSD_T/2.); //Si: 62x42 - G4LogicalVolume* logicSi1 = new G4LogicalVolume(solidSi1, // it's solid - eDetMat, // it's material //vacuumMaterial, - "dssd1", // it's name - 0, 0, 0); // field manager, sensitive det, user limits - - logicSi1->SetVisAttributes(visAttDSSD_1); - - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(totalDSSD_W/2.+0.75*mm,fCentreOfDSSD_Y,DSSD_z), - //G4ThreeVector(0.0*mm,fCentreOfDSSD_Y,DSSD_z), - logicSi1, //its logical volume - "dssd1", //its name - logicChamVac, //its mother - false, //no boolean operat - 1); //, //copy number - - G4LogicalVolume* logicSi2 = new G4LogicalVolume(solidSi1, // it's solid - eDetMat, // it's material //vacuumMaterial, - "dssd2", // it's name - 0, 0, 0); // field manager, sensitive det, user limits - - logicSi2->SetVisAttributes(visAttDSSD_1); - - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(-totalDSSD_W/2.-0.75*mm,fCentreOfDSSD_Y,DSSD_z), - //G4ThreeVector(0.0*mm,fCentreOfDSSD_Y,DSSD_z), - logicSi2, //its logical volume - "dssd2", //its name - logicChamVac, //its mother - false, //no boolean operat - 2); //, //copy number - - - // The ChamberVac is located wrt centre of Chamber => z0 = -fChamberL/2. - fDSSD_PosZ = DSSD_z - fChamberL/2. - fDSSD_T/2.; - G4cout << "Upstream DSSD face @ Z = " << fDSSD_PosZ << G4endl; - - - //common dssd "pixel" shape - G4VisAttributes* visAttDSSD = new G4VisAttributes(G4Colour(0.8,0.3,0.3) ); - visAttDSSD->SetVisibility(true); - //visAttDSSD->SetVisibility(false); - visAttDSSD->SetForceWireframe(true); - - - - - G4double fDSSD_Pixel_Lx = fDSSD_W/(1.0*nStripsX); - G4double fDSSD_Pixel_Ly = fDSSD_H/(1.0*nStripsY); - - G4Box* solidDSSD = new G4Box("dssd", fDSSD_Pixel_Lx/2., fDSSD_Pixel_Ly/2., fDSSD_T/2.); - - - //starting y-position for lowest row - G4double thisy = -nStripsY/2.*fDSSD_Pixel_Ly + fDSSD_Pixel_Ly/2. + fCoolingBlockCutOut_PosY; - thisy = -nStripsY/2.*fDSSD_Pixel_Ly + fDSSD_Pixel_Ly/2. + fCentreOfDSSD_Y; - - G4double thisy2 = -fDSSD_H/2. + fDSSD_Pixel_Ly/2.; - - for(G4int iy = 0; iy < nStripsY; iy++) { - //starting x-position - G4double thisx = -nStripsX*fDSSD_Pixel_Lx + fDSSD_Pixel_Lx/2. - gapBetweenDSSD/2.; - G4double thisx2 = -fDSSD_W/2. + fDSSD_Pixel_Lx/2.; - for(G4int ix = 0; ix < nStripsX; ix++) { - - //DSSD_A - logicDSSD_A[iy][ix] = new G4LogicalVolume(solidDSSD, // it's solid - eDetMat, // it's material - //vacuumMaterial, - "dssd-pixel",// it's name - 0, 0, 0); // field manager, sensitive det, user limits - - PVPBuffer = new G4PVPlacement(0, //rotation - //G4ThreeVector(thisx,thisy,DSSD_z), - G4ThreeVector(thisx2,thisy2,0.0*mm), - logicDSSD_A[iy][ix],//its logical volume - "DSSD_A", //its name - logicSi2, //its mother - false, //no boolean operat - iy*100+ix);//, //copy number - - - //DSSD_B - logicDSSD_B[iy][ix] = new G4LogicalVolume(solidDSSD, // it's solid - eDetMat, // it's material - //vacuumMaterial, - "dssd-pixel",// it's name - 0, 0, 0); // field manager, sensitive det, user limits - - PVPBuffer = new G4PVPlacement(0, //rotation - //G4ThreeVector(thisx+fDSSD_W+gapBetweenDSSD,thisy,DSSD_z), - G4ThreeVector(thisx2,thisy2,0.0*mm), - logicDSSD_B[iy][ix],//its logical volume - "DSSD_B", //its name - logicSi1, //its mother - false, //no boolean operat - iy*100+ix);//, //copy number - - - //visu - logicDSSD_A[iy][ix]->SetVisAttributes(visAttDSSD); - logicDSSD_B[iy][ix]->SetVisAttributes(visAttDSSD); - - //move along please - //thisN++; - thisx += fDSSD_Pixel_Lx; - thisx2 += fDSSD_Pixel_Lx; - } - thisy += fDSSD_Pixel_Ly; - thisy2 += fDSSD_Pixel_Ly; - } +G4Box* pre_amp_board3 += new G4Box("pre_amp_board3",1.675*cm/2, 6.756*cm/2, 7.976*cm/2 ); // + +G4LogicalVolume* logicpre_amp3 = new G4LogicalVolume(pre_amp_board3, PCB, "logicpre_amp3"); +PVPBuffer = +new G4PVPlacement(0, G4ThreeVector(-9.6725*cm, 2.413375*cm, -4.265*cm), logicpre_amp3, "pre_amp_board3", world, false, +0); PVPBuffer = new G4PVPlacement(0, G4ThreeVector(-9.6725*cm, -5.336625*cm, -4.265*cm), logicpre_amp3, +"pre_amp_board3", world, false, 1); - //-------------------------------------------- - // The PINS - //-------------------------------------------- - G4double PinL = 30.0 * mm; //PinLxPinL - G4double PinT = 1.0 * mm; //0.5 * mm; //Thickness - G4double PinGuard = 1.0 * mm; //Guardrail - G4double PinGap = 1.0 * mm; //between PINS - G4double PinToEdge = 3.0 * mm; //gap from the end - G4double PinEpoxyT = 1.6 * mm; //thickness of pcb board -// G4double PinSupportLip = PinT+PinEpoxyT; //thickness of pcb board - - //horizontal-side dimensions [approxiamted as a single board] - G4double PinBoard_H_W = PinL*5.; - G4double PinBoard_H_H = PinEpoxyT; - G4double PinBoard_H_L = PinToEdge + PinL + PinGap + PinL + 13.0*mm; - - //vertical-side dimensions [approximated as a single board] - G4double PinBoard_V_H = PinL*2.; - G4double PinBoard_V_W = PinEpoxyT; - G4double PinBoard_V_L = PinToEdge + PinL + PinGap + PinL + 13.0*mm; - - //the PCB board for the PINS sits on top of another board [oh yeah transparency !] - G4double PinBoardSupport_T = 4.75*mm; //nominally 4.75*mm; - - //positions wrt cahmaber vacuum : put it at downstream side of the support block - G4double PinBoard_z = DSSD_SupPos_z + fCoolingBlockL/2 - PinBoard_H_L/2.; - PinBoard_z -= 1.5*mm; //move back due to support - - G4double PinBoard_H_x = 0.0 * mm; - G4double PinBoard_H_dy = Hole4DSSD_H/2. - PinEpoxyT/2. - PinBoardSupport_T; - G4double PinBoard_V_x = Hole4DSSD_W/2. - PinEpoxyT/2. - PinBoardSupport_T; - fDSSD_PosY = fCentreOfDSSD_Y; - G4double PinBoard_V_y = fDSSD_PosY; - - //The epoxy board for the pins - G4VisAttributes* visAttPIN_Board = new G4VisAttributes( G4Colour(0.3,0.9,0.3) ); - visAttPIN_Board->SetVisibility(true); - //visAttPIN_Board->SetVisibility(false); - visAttPIN_Board->SetForceWireframe(true); - - //Pin PCB/Epoxy boards - G4Box* solidPinBoard_H = new G4Box("pin-pcb", PinBoard_H_W/2., PinBoard_H_H/2., PinBoard_H_L/2.); - G4Box* solidPinBoard_V = new G4Box("pin-pcb", PinBoard_V_W/2., PinBoard_V_H/2., PinBoard_V_L/2.); - - - G4LogicalVolume* logicPinBoard_H = new G4LogicalVolume(solidPinBoard_H, // it's solid - boardMaterial, // it's material - "pin-pcb", // it's name - 0,0,0); // field manager etc - - G4LogicalVolume* logicPinBoard_V = new G4LogicalVolume(solidPinBoard_V, // it's solid - boardMaterial, // it's material - "pin-pcb", // it's name - 0,0,0); // field manager etc - - logicPinBoard_H->SetVisAttributes(visAttPIN_Board); - logicPinBoard_V->SetVisAttributes(visAttPIN_Board); - - - //G4PVPlacement* physiPinBoard_H[2]; - //G4PVPlacement* physiPinBoard_V[2]; - - for(G4int i = 0; i < 2; i++) { - - G4double dyPos = (2*i-1)*PinBoard_H_dy; - - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(PinBoard_H_x, fCentreOfDSSD_Y + dyPos, PinBoard_z), - logicPinBoard_H, //its logical volume - "PinPCB_H", //its name - logicChamVac, //its mother - false, //no boolean operat - i+1); //copy number - - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector( PinBoard_V_x*(2*i-1), PinBoard_V_y, PinBoard_z), - logicPinBoard_V, //its logical volume - "PinPCB_V", //its name - logicChamVac, //its mother - false, //no boolean operat - i+1); //copy number - +G4VisAttributes* pre_amp_board3VisAtt = new G4VisAttributes(G4Colour(0., 0.7, 0.)); +logicpre_amp3->SetVisAttributes(pre_amp_board3VisAtt); + +*/ /* end of Eleanor's additions */ } + else if (m_ChamberType == 3) { // case of GREAT chamber as defined by Karl + + fChamberH = m_ChamberHmax; + fChamberW = m_ChamberWmax; + // fChamberL = m_ChamberDmax; + fChamberThickness = m_ChamberHmax - m_ChamberHmin; + + fVacuumH = fChamberH - fChamberThickness; + + G4cout << "fChamberH=" << fChamberH << G4endl; + G4cout << "fChamberW=" << fChamberW << G4endl; + G4cout << "fChamberThickness=" << fChamberThickness << G4endl; + + //----------------------------- + // more dimesions for chamber + fChamberL = + fCoolingBlockL + fLengthOfPlanarCut + fDSSD_BoardL + fdeltaZ_Support + 2. * fChamberThickness + 10.0 * mm; + + //--------------------------------------------------------------------------------- + // This shift in the position of the chamber is to put the DSSD centred at y = 0 + fShiftChamberY = + fCoolingBlockH - fCoolingBlockT - fCoolingBlockCutOutH / 2.; // height of centre wrt cooling block base + fShiftChamberY -= fChamberH / 2.; + + // Define the downstream face of the DSSD to be at 0 (ie the centre of the DSSD PCB board) + fShiftChamberZ = fCoolingBlockZ + fChamberThickness - fDSSD_BoardL / 2.; // a discrepency of 1 mm somewhere + + // the centre of the DSSD wrt the vacuum chamber + fCentreOfDSSD_Y = + -fVacuumH / 2. + fCoolingBlockH - fCoolingBlockT - fCoolingBlockCutOutH / 2.; //+ fChamberThickness + cout << G4endl << " DSSD_Y at 0 mm , but wrt vacuum DSSD_Y @ " << fCentreOfDSSD_Y << G4endl; + + //-------------------------------------------- + //[partial] Vacuum Chamber (Walls+Vacuum) and end BackPlate + // Set the Upstream side of the Chamber @ Z=0mm + + // G4Box* solidChamber = new G4Box("chamber",fChamberW/2., fChamberH/2., fChamberL/2.); + // replaced by achamber with a substraction of the Planar area: + G4Box* solidChamberEnv = new G4Box("chamberEnv", fChamberW / 2., fChamberH / 2., fChamberL / 2.); + G4double PlanarCap_W = fPlanarGe_W + 2. * fPlanarGuard + 80. * mm; // A GUESS + G4double PlanarCap_H = 150. * mm; + PlanarCap_H = fPlanarGe_H + 70 * mm; + G4double PlanarCap_T = fPlanarTotalL; + G4cout << G4endl << "Planar end-cap thickness " << PlanarCap_T << " cf 41. mm" << G4endl; + fShiftPlanar = fChamberL / 2. - fChamberThickness + PlanarCap_T / 2. - fLengthOfPlanarCut + fGap_PCB_2_Planar; + G4double Planar_z = fShiftPlanar; + G4Box* solidPlanarCapEnv = new G4Box("planar-cap-Env", PlanarCap_W / 2., PlanarCap_H / 2., PlanarCap_T / 2.); + G4SubtractionSolid* solidChamber = new G4SubtractionSolid("chamber", solidChamberEnv, solidPlanarCapEnv, 0, + G4ThreeVector(0.0 * mm, fCentreOfDSSD_Y, Planar_z)); + + // end of replacement + + G4LogicalVolume* logicChamber = new G4LogicalVolume(solidChamber, // it's solid + m_ChamberMaterial, // it's material + // chamberMaterial,//it's material + // vacuumMaterial,//it's material + "Chamber", // it's name + 0, 0, 0); // field manager, sensitive det, user limits + + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0.0 * mm, -fShiftChamberY, -fChamberL / 2. + fShiftChamberZ), + logicChamber, // its logical volume + "Chamber", // its name + world, // its mother + false, // no boolean operat + 0, // copy number + true); // overlap check + + // viewing the chamber + G4VisAttributes* visAttChamber = new G4VisAttributes(G4Colour(1.0, 1.0, 1.0)); + visAttChamber->SetVisibility(true); + visAttChamber->SetForceWireframe(true); + logicChamber->SetVisAttributes(visAttChamber); + // logicChamber->SetVisAttributes(G4VisAttributes::GetInvisible()); + + // Vacuum within above partial chamber + + G4double vacH = fChamberH - fChamberThickness; + G4double vacW = fChamberW - 2. * fChamberThickness; + G4double vacL = fChamberL - 2. * fChamberThickness; + + // G4Box* solidChamVac = new G4Box("chamVac",vacW/2., vacH/2., vacL/2.); + // Replaced by + G4Box* solidChamVacEnv = new G4Box("chamVacEnV", vacW / 2., vacH / 2., vacL / 2.); + // G4Box* solidPlanarCapEnv = new G4Box("planar-cap-Env", PlanarCap_W/2., PlanarCap_H/2., PlanarCap_T/2.); + G4SubtractionSolid* solidChamVac = + new G4SubtractionSolid("chamVac", solidChamVacEnv, solidPlanarCapEnv, 0, + G4ThreeVector(0.0 * mm, fCentreOfDSSD_Y + fChamberThickness / 2., Planar_z)); + + G4LogicalVolume* logicChamVac = new G4LogicalVolume(solidChamVac, // it's solid + vacuumMaterial, // it's material + "chamVac", // it's name + 0, 0, 0); // field manager, sensitive det, user limits + + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0.0 * cm, -fChamberThickness / 2., 0.0 * cm), + logicChamVac, // its logical volume + "ChamVac", // its name + logicChamber, // its mother + false, // no boolean operat + 0, // copy number + true); // overlap check + + // logicChamVac->SetVisAttributes(G4VisAttributes::GetInvisible()); + logicChamVac->SetVisAttributes(visAttChamber); + + /* Uncomment if you want the planar in the geometry and you are not using GRTPlan */ + /* + //---------------------------------------------------------------------- + // The Planar + //---------------------------------------------------------------------- + G4double PlanarCap_W = fPlanarGe_W + 2.*fPlanarGuard + 80.*mm; //A GUESS + G4double PlanarCap_H = 150.*mm; + PlanarCap_H = fPlanarGe_H + 70*mm; + G4double PlanarCap_T = fPlanarTotalL; + G4cout << G4endl << "Planar end-cap thickness " << PlanarCap_T << " cf 41. mm" << G4endl; + + // - editted 07/11/2011 + fShiftPlanar = fChamberL/2. - fChamberThickness + PlanarCap_T/2. - fLengthOfPlanarCut + fGap_PCB_2_Planar; + G4double Planar_z = fShiftPlanar; + fPlanar_PosZ = Planar_z; + + //starting endCap sold + G4Box* solidPlanarCap = new G4Box("planar-cap", PlanarCap_W/2., PlanarCap_H/2., PlanarCap_T/2.); + + //cut outs for Be window : planar end-cap is deliberately symmetric to make positioning more simple + //3 mm wide support rib that is 2.2 mm thick. Add the Be thickness => endCap thickness + G4Box* solidBeCutOut = new G4Box("be-cut-out", fPlanarGe_W/4.-1.5*mm, fPlanarGe_H/2., fEndCapThickness/2.);//is it + total 120 mm or 120+gap ? G4ThreeVector beCutOutTrans1(-fPlanarGe_W/4.-1.5*mm, 0.0*mm, + -PlanarCap_T/2.+fEndCapThickness/2.); G4ThreeVector beCutOutTrans2(+fPlanarGe_W/4.+1.5*mm, 0.0*mm, + -PlanarCap_T/2.+fEndCapThickness/2.); + + + G4SubtractionSolid* solidPlanarCap_tmp1 = + new G4SubtractionSolid("planar-capo-1", solidPlanarCap, solidBeCutOut, 0, beCutOutTrans1); + + G4SubtractionSolid* solidPlanarCap_tmp2 = + new G4SubtractionSolid("planar-capo-2", solidPlanarCap_tmp1, solidBeCutOut, 0, beCutOutTrans2); + + + //cut outs for Al window at rear + G4Box* solidAlCutOut = new G4Box("Al-cut-out", fPlanarGe_W/2., fPlanarGe_H/2., fAlWindowThickness/2.); + G4ThreeVector alCutOutTrans(0.0*mm, 0.0*mm, PlanarCap_T/2.-fAlWindowThickness/2.); //ends up being 0.9 mm instead + of 1.1 mm thick: CORRECT IT + + G4SubtractionSolid* solidPlanarCap_tmp3 = + new G4SubtractionSolid("planar-capo-3", solidPlanarCap_tmp2, solidAlCutOut, 0, alCutOutTrans); + + + G4LogicalVolume* logicPlanarCap = new G4LogicalVolume(solidPlanarCap_tmp3, // it's solid + //logicPlanarCap = new G4LogicalVolume(solidPlanarCap, // it's solid + endCapMaterial, // it's material + "planar-cap", // it's name + 0, 0, 0); // field manager, sensitive det, user limits + + PVPBuffer = new G4PVPlacement(0, //rotation + G4ThreeVector(0.0*mm, fCentreOfDSSD_Y, Planar_z), + logicPlanarCap, //its logical volume + "PlanarCap", //its name + logicChamVac, //its mother + false, //no boolean operat + 0, //copy number + true); //overlap check + + + + + G4VisAttributes* visAttPlanarCapo = new G4VisAttributes(G4Colour(1.0,0.8,1.0) ); + visAttPlanarCapo->SetVisibility(true); + //visAttPlanarCapo->SetVisibility(false); + visAttPlanarCapo->SetForceWireframe(true); + logicPlanarCap->SetVisAttributes(visAttPlanarCapo); + + + //----------------------------------------------------------------------------------------------- + //add the Be window + G4double PlanarBeWindow_z = -PlanarCap_T/2. + fBeWindowThickness/2.; + + G4Box* solidPlanarBeWindow = new G4Box("planar-be", fPlanarGe_W/2., fPlanarGe_H/2., fBeWindowThickness/2.); + + G4LogicalVolume* logicPlanarBeWindow = new G4LogicalVolume(solidPlanarBeWindow,// it's solid + beMaterial, // it's material + "planar-be", // it's name + 0, 0, 0); // field manager, sensitive det, user limits + + PVPBuffer = new G4PVPlacement(0, //rotation + G4ThreeVector(0.0*mm, 0.0*mm, PlanarBeWindow_z), + logicPlanarBeWindow, //its logical volume + "Planar-Be", //its name + logicPlanarCap, //its mother + false, //no boolean operat + 0, //copy number + true); //overlap check + + G4VisAttributes* visAttBeWindow = new G4VisAttributes(G4Colour(0.9,1.0,0.9) ); + visAttBeWindow->SetVisibility(true); + //visAttBeWindow->SetVisibility(false); + visAttBeWindow->SetForceWireframe(true); + logicPlanarBeWindow->SetVisAttributes(visAttBeWindow); + //----------------------------------------------------------------------------------------------- + //special cut out for Vacuum.... + //fAlWindowThickness + //fEndCapThickness + //PlanarCap_T - 2*fEndCapThickness + + + + //cut outs for windows and vacuum + G4Box* solidPlanarVac = new G4Box("planar-vac", PlanarCap_W/2.-fEndCapThickness, PlanarCap_H/2.-fEndCapThickness, + PlanarCap_T/2.-fEndCapThickness); + + G4LogicalVolume* logicPlanarVac = new G4LogicalVolume(solidPlanarVac,// it's solid + vacuumMaterial, // it's material + "planar-vac", // it's name + 0, 0, 0); // field manager, sensitive det, user limits + + PVPBuffer = new G4PVPlacement(0, //rotation + G4ThreeVector(0.0*mm, 0.0*mm, 0.0*mm), + logicPlanarVac, //its logical volume + "Planar-Vac", //its name + logicPlanarCap, //its mother + false, //no boolean operat + 0, //copy number + true); //overlap check + + G4cout << "Got Here" << G4endl; + + //visual attributes of the planar end-cap + //G4VisAttributes* visAttPlanarCapo = new G4VisAttributes(G4Colour(1.0,0.8,1.0) ); + //visAttPlanarCapo->SetVisibility(true); + //visAttPlanarCapo->SetVisibility(false); + //visAttPlanarCapo->SetForceWireframe(true); + //logicPlanarCap->SetVisAttributes(visAttPlanarCapo); + logicPlanarVac->SetVisAttributes(visAttPlanarCapo); + + + + + // the planar Ge + G4double PlanarGe_z = -PlanarCap_T/2. + fPlanarGe_T/2. + fPlanarGeGapFront; + + //add in a slab of Ge to accomodate the guard-rail + //and into this slab add the pixels + G4Box* solidPlanarOuterGe = new G4Box("planar-outer-ge", fPlanarGe_W/2.+fPlanarGuard, fPlanarGe_H/2.+fPlanarGuard, + fPlanarGe_T/2.); G4LogicalVolume* logicPlanarOuterGe = new G4LogicalVolume(solidPlanarOuterGe, // it's solid + geMaterial, // it's material + "planar-outer-ge", // it's name + 0, 0, 0); // field manager, sensitive det, user limits + + //G4PVPlacement* physiPlanarOuterGe = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, //rotation + G4ThreeVector(0.*mm, 0.0*mm, PlanarGe_z), + logicPlanarOuterGe, //its logical volume + "Planar-Outer-Ge", //its name + logicPlanarVac, //its mother + false, //no boolean operat + 0, true); //copy number + + G4VisAttributes* visAttPlanarOuterGe = new G4VisAttributes(G4Colour(0.9,0.9,1.0) ); + visAttPlanarOuterGe->SetVisibility(true); + //visAttPlanarOuterGe->SetVisibility(false); + visAttPlanarOuterGe->SetForceWireframe(true); + logicPlanarOuterGe->SetVisAttributes(visAttPlanarOuterGe); + + + + //segment the detector + G4int nSegsH = 12; //(y) + G4int nSegsW = 24; //(x) + + //nSegsH = 1; + //nSegsW = 1; + + //common planar "pixel" shape + G4double planarPixel_H = fPlanarGe_H/(G4double) nSegsH; + G4double planarPixel_W = fPlanarGe_W/(G4double) nSegsW; + + G4Box* solidPlanarGe = new G4Box("planar-ge", planarPixel_W/2., planarPixel_H/2., fPlanarGe_T/2.); + + G4VisAttributes* visAttPlanarGe = new G4VisAttributes(G4Colour(1.0,1.0,1.0) ); + visAttPlanarGe->SetVisibility(true); + //visAttPlanarGe->SetVisibility(false); + visAttPlanarGe->SetForceWireframe(true); + logicPlanarOuterGe->SetVisAttributes(visAttPlanarGe); + + //starting y-position for lowest row + G4double thisY = -fPlanarGe_H/2. + planarPixel_H/2.;// + fDSSD_PosY; + + for(G4int ny = 0; ny < nSegsH; ny++) { + //starting x-position + G4double thisX = -fPlanarGe_W/2. + planarPixel_W/2.; + //G4double posY = (2*ny-1)*planarPixel_H/2.; + + for(G4int nx = 0; nx < nSegsW; nx++) { + //G4double posX = -fPlanarGe_W/2. + planarPixel_W/2. + nx*planarPixel_W; + //G4int copyNo = ny*nSegsW+nx; + //G4cout << "Check Planar CopyNo " << copyNo << " @ " << posX << " " << posY << G4endl; + G4int copyNo = ny*100+nx; + G4cout << "Check Planar CopyNo " << copyNo << " @ " << thisX << " " << thisY << G4endl; + + //logicPlanarGe[copyNo] = new G4LogicalVolume(solidPlanarGe,// it's solid + logicPlanarGe[ny][nx] = new G4LogicalVolume(solidPlanarGe,// it's solid + geMaterial, // it's material + "planar-ge", // it's name + 0, 0, 0); // field manager, sensitive det, user limits + + + //physiPlanarGe[copyNo] = new G4PVPlacement(0, //rotation + //G4ThreeVector(posX, posY, 0.0*mm), + //physiPlanarGe[ny][nx] = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, //rotation + G4ThreeVector(thisX, thisY, 0.0*mm), + //logicPlanarGe[copyNo], //its logical volume + logicPlanarGe[ny][nx], //its logical volume + "Planar-Ge", //its name + logicPlanarOuterGe, //its mother + false, //no boolean operat + copyNo); //copy number + + //set attributes + logicPlanarGe[ny][nx]->SetVisAttributes(visAttPlanarGe); + + //move along.... + thisX += planarPixel_W; + } + thisY += planarPixel_H; + } + */ - //----------------------------------------- - //Horiz Support for Pin Epoxy : the PCB board for the PINS sits on top of another board [oh yeah transparency !] - G4VisAttributes* visAttPIN_BoardSup = new G4VisAttributes( G4Colour(0.9,0.9,0.9) ); - visAttPIN_BoardSup->SetVisibility(true); - //visAttPIN_BoardSup->SetVisibility(false); - visAttPIN_BoardSup->SetForceWireframe(true); - - G4double PinBoardSupport_H_W = fCoolingBlockCutOutW; - G4double PinBoardSupport_H_H = 3.75*mm; - G4double PinBoardSupport_H_L = 80.*mm; + //---------------------------------------------------------- + // Cooling Frame: Tunnel and DSSD Detector Support + //---------------------------------------------------------- + G4VisAttributes* visAttCoolingBlock = new G4VisAttributes(G4Colour(0.8, 0.8, 0.8)); + visAttCoolingBlock->SetVisibility(true); + // visAttCoolingBlock->SetVisibility(false); + visAttCoolingBlock->SetForceWireframe(true); + G4Box* OuterBox = new G4Box("OuterBox", fCoolingBlockW / 2., fCoolingBlockH / 2., fCoolingBlockL / 2.); - G4Box* solidPinSupportBoard_H_temp = new G4Box("pin-pcb-support", PinBoardSupport_H_W/2., PinBoardSupport_H_H/2., PinBoardSupport_H_L/2.); - - G4double cutOutPinBoard_H_x = 28.6*mm; - G4Box* cutOutPinBoard_H = new G4Box("Box Pin Board #1",cutOutPinBoard_H_x/2.,PinBoardSupport_H_H/2.,70.*mm/2.); - - G4ThreeVector cutOutPinBoard_H_centre(0.0*mm, 0.0*mm, 5.0*mm); - G4ThreeVector cutOutPinBoard_H_p1( PinL, 0.0*mm, 5.0*mm); - G4ThreeVector cutOutPinBoard_H_m1(-PinL, 0.0*mm, 5.0*mm); - G4ThreeVector cutOutPinBoard_H_p2( 2*PinL, 0.0*mm, 5.0*mm); - G4ThreeVector cutOutPinBoard_H_m2(-2*PinL, 0.0*mm, 5.0*mm); - - G4SubtractionSolid* solidPinSupportBoard_H0 = - new G4SubtractionSolid("pin-pcb-support_0", solidPinSupportBoard_H_temp, cutOutPinBoard_H, 0, cutOutPinBoard_H_centre); - - G4SubtractionSolid* solidPinSupportBoard_HA = - new G4SubtractionSolid("pin-pcb-support_a", solidPinSupportBoard_H0, cutOutPinBoard_H, 0, cutOutPinBoard_H_p1); - - G4SubtractionSolid* solidPinSupportBoard_HB = - new G4SubtractionSolid("pin-pcb-support_b", solidPinSupportBoard_HA, cutOutPinBoard_H, 0, cutOutPinBoard_H_m1); - - G4SubtractionSolid* solidPinSupportBoard_HC = - new G4SubtractionSolid("pin-pcb-support_b", solidPinSupportBoard_HB, cutOutPinBoard_H, 0, cutOutPinBoard_H_p2); - - G4SubtractionSolid* solidPinSupportBoard_H = - new G4SubtractionSolid("pin-pcb-support_b", solidPinSupportBoard_HC, cutOutPinBoard_H, 0, cutOutPinBoard_H_m2); - - - - G4LogicalVolume* logicPinSupportBoard_H = new G4LogicalVolume(solidPinSupportBoard_H, // it's solid - m_ChamberMaterial, // it's material - "pin-pcb-support", // it's name - 0,0,0); // field manager etc - logicPinSupportBoard_H->SetVisAttributes(visAttPIN_BoardSup); - - G4double PinBoardSupport_Z = DSSD_SupPos_z + fCoolingBlockL/2. - PinBoardSupport_H_L/2. - 1.0*mm; - - - - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(PinBoard_H_x, fDSSD_PosY + fCoolingBlockCutOutH/2. - PinBoardSupport_H_H/2., PinBoardSupport_Z), - logicPinSupportBoard_H, //its logical volume - "PinPCB_Support", //its name - logicChamVac, //its mother - false, //no boolean operat - 1); //copy number - - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(PinBoard_H_x, fDSSD_PosY - fCoolingBlockCutOutH/2. + PinBoardSupport_H_H/2., PinBoardSupport_Z), - logicPinSupportBoard_H, //its logical volume - "PinPCB_Support", //its name - logicChamVac, //its mother - false, //no boolean operat - 2); //copy number - - - - G4double PinBoardSupport_W_W = 3.75*mm; - G4double PinBoardSupport_W_H = fCoolingBlockCutOutH - 2.*PinBoardSupport_H_H; - G4double PinBoardSupport_W_L = 80.*mm; - - //Vertical Support Pin Epoxy - G4Box* solidPinSupportBoard_V_temp = new G4Box("pin-pcb-support", PinBoardSupport_W_W/2., PinBoardSupport_W_H/2., PinBoardSupport_W_L/2.); - - G4Box* cutOutPinBoard_V = new G4Box("Box Pin Board #1",PinBoardSupport_W_W/2.,cutOutPinBoard_H_x/2.,70.*mm/2.); - G4double cutOutSpine_x = (PinL + PinGap - cutOutPinBoard_H_x)/2.; - - G4ThreeVector cutOutPinBoard_V_p1( 0.0*mm, (cutOutSpine_x+cutOutPinBoard_H_x)/2., 5.0*mm); - G4ThreeVector cutOutPinBoard_V_m1( 0.0*mm, -(cutOutSpine_x+cutOutPinBoard_H_x)/2., 5.0*mm); - - G4SubtractionSolid* solidPinSupportBoard_V0 = - new G4SubtractionSolid("pin-pcb-support_0", solidPinSupportBoard_V_temp, cutOutPinBoard_V, 0, cutOutPinBoard_V_p1); - - G4SubtractionSolid* solidPinSupportBoard_V = - new G4SubtractionSolid("pin-pcb-support_b", solidPinSupportBoard_V0, cutOutPinBoard_V, 0, cutOutPinBoard_V_m1); - - - - G4LogicalVolume* logicPinSupportBoard_V = new G4LogicalVolume(solidPinSupportBoard_V, // it's solid - m_ChamberMaterial, // it's material - "pin-pcb-support", // it's name - 0,0,0); // field manager etc - - logicPinSupportBoard_V->SetVisAttributes(visAttPIN_BoardSup); - - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector( fCoolingBlockCutOutW/2. - PinBoardSupport_W_W/2., fDSSD_PosY, PinBoardSupport_Z), - logicPinSupportBoard_V, //its logical volume - "PinPCBSupport", //its name - logicChamVac, //its mother - false, //no boolean operat - 1); //copy number - - PVPBuffer= new G4PVPlacement(0, //rotation - G4ThreeVector(-fCoolingBlockCutOutW/2. + PinBoardSupport_W_W/2., fDSSD_PosY, PinBoardSupport_Z), - logicPinSupportBoard_V, //its logical volume - "PinPCBSupport", //its name - logicChamVac, //its mother - false, //no boolean operat - 2); //copy number - - - //add the fucking ridiculous flange.... - G4double PinFlange_Z = DSSD_SupPos_z + fCoolingBlockL/2. - 0.5*mm; - G4Box* PinFlange_outer = new G4Box("Box Pin Flange #1",fCoolingBlockCutOutW/2.,fCoolingBlockCutOutH/2.,1.0*mm/2.); //probably even thicker just to make sure no low E gammas are seen ! - G4Box* PinFlange_hole = new G4Box("Box Pin Flange #2",fCoolingBlockCutOutW/2.-4.0*mm,fCoolingBlockCutOutH/2.-4.0*mm,1.0*mm/2.); - - G4SubtractionSolid* solidPinFlange = - new G4SubtractionSolid("pin-flange", PinFlange_outer, PinFlange_hole, 0, G4ThreeVector(0.*mm, 0.*mm, 0.*mm)); - - - G4LogicalVolume* logicPinFlange = new G4LogicalVolume(solidPinFlange, // it's solid - m_ChamberMaterial, // it's material - "pin-flange", // it's name - 0,0,0); // field manager etc - - logicPinFlange->SetVisAttributes(visAttPIN_BoardSup); - - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.0*mm, fDSSD_PosY, PinFlange_Z), - logicPinFlange, //its logical volume - "PinFlange", //its name - logicChamVac, //its mother - false, //no boolean operat - 1); //copy number - - //now the PINS..... - G4VisAttributes* visAttPIN = new G4VisAttributes( G4Colour(0.9,0.9,0.3) ); - visAttPIN->SetVisibility(true); - //visAttPIN->SetVisibility(false); - visAttPIN->SetForceWireframe(true); - - G4double Pin_z1 = PinBoard_z + PinBoard_V_L/2. - PinToEdge - PinL/2; - //G4double Pin_z2 = Pin_z1 - PinGap - PinL; - - //total Si area - G4Box* solidPINS_H = new G4Box("pins-passive", PinL/2., PinT/2., PinL/2); //horizontal - new G4Box("pins-passive", PinT/2., PinL/2., PinL/2); //vertical - - //active Si - G4Box* solidPINS_Active_H = new G4Box("pins", PinL/2.-PinGuard, PinT/2., PinL/2-PinGuard); //horizontal - new G4Box("pins", PinT/2., PinL/2.-PinGuard, PinL/2-PinGuard); //vertical - - - //horizontal rows could put an index[i] = copyNo to match position in real array !! - for(G4int nH = 0; nH < 2; nH++) { //up/down - G4double posY = fDSSD_PosY + (2*nH - 1)*(PinBoard_H_dy - PinBoard_H_H/2. - PinT/2.); - - for(G4int i = 1; i <= 5; i++) { //across in x - G4double posX = -PinBoard_H_W/2. + PinL/2. + (i-1)*PinL; - - for(G4int r = 1; r <= 2; r++) { //2 rows (in z) - G4double posZ = Pin_z1 - (r%2)*(PinGap + PinL); - G4int copyNo = nH*10+2*(i-1)+r; - G4cout << "Checking PIN copyNo " << copyNo << G4endl; - - logicPINS[copyNo-1] = new G4LogicalVolume(solidPINS_H, // it's solid - eDetMat, // it's material - "pin-pass-h", // it's name - 0,0,0); // field manager etc - - logicPINS[copyNo-1]->SetVisAttributes(visAttPIN); - - - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(posX, posY, posZ), - logicPINS[copyNo-1], //its logical volume - "PinPass", //its name - logicChamVac, //its mother - false, //no boolean operat - copyNo, //copy number - true); //check for overlaps - - - logicPINS_Active[copyNo-1] = new G4LogicalVolume(solidPINS_Active_H, // it's solid - eDetMat, // it's material - "pin-h", // it's name - 0,0,0); // field manager etc - - logicPINS_Active[copyNo-1]->SetVisAttributes(visAttPIN); - - - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm,0.*mm), - logicPINS_Active[copyNo-1], //its logical volume - "Pin", //its name - logicPINS[copyNo-1], //its mother - false, //no boolean operat - copyNo); //copy number - - } - } - } + // place the support on the bottom of the chamber + G4double DSSD_SupPos_y = -fChamberH / 2. + fCoolingBlockH / 2. + fChamberThickness / 2.; + // position wrt BackPlate/VacChamber + G4double DSSD_SupPos_z = fChamberL / 2. - fChamberThickness - fCoolingBlockL / 2. - fCoolingBlockZ; + // now cut a hole out for the DSSD's + G4double Hole4DSSD_W = fCoolingBlockCutOutW; + G4double Hole4DSSD_H = fCoolingBlockCutOutH; - //-------------------------------------------- - // The DSSD pre-amp boards - //-------------------------------------------- - //dimensions of the main support board - G4double PA_SupportBoard_T = 3.0*mm; - G4double PA_SupportBoard_W = 67.0*mm; - G4double PA_SupportBoard_L = fCoolingBlockL; //along z + // from the above can determine the centre of the DSSD wrt centre of Cooling block + fCoolingBlockCutOut_PosY = + fCoolingBlockH / 2. - fCoolingBlockT - fCoolingBlockCutOutH / 2.; // save this frequently used position + G4cout << "fCoolingBlockCutOut_PosY " << fCoolingBlockCutOut_PosY << " cf " << fCoolingBlockDSSDCentre << G4endl; - //dimensions of the individual pcb boards - G4double PA_Board_T = 0.8*mm; - G4double PA_Board_W = 14.0*mm; - G4double PA_Board_L = 33.0*mm; - - //fudge a capacitor in there.... - G4double PA_Capacitor_T = 2.0*mm; - G4double PA_Capacitor_R = 4.0*mm; + G4Box* hole1 = new G4Box("Hole #1", Hole4DSSD_W / 2., Hole4DSSD_H / 2., fCoolingBlockL / 2.); - //and the connectors... - G4double connectorW = 26.0*mm; - G4double connectorL = 14.0*mm; - G4double connectorT = 5.0*mm; + G4double dy = fCoolingBlockH / 2. - fCoolingBlockT - Hole4DSSD_H / 2.; + G4double dx = 0.0 * mm; + G4double dz = 0.0 * mm; + G4ThreeVector hole1trans(dx, dy, dz); - - //delta-pos for each pre-amp - const G4int nPA = 20; //per support board - G4double PA_dPos = PA_SupportBoard_W / ((G4double) (nPA+1)); + G4SubtractionSolid* solid_CB_Temp1 = new G4SubtractionSolid("fCoolingBlockTemp1", OuterBox, hole1, 0, hole1trans); - //positions wrt chamaber vacuum : put it at downstream side of the support block - G4double PA_SupportBoard_z = DSSD_SupPos_z + fCoolingBlockL/2. - PA_SupportBoard_L/2.; + // now cut a hole out for preamps + G4Box* holePreAmp = new G4Box("Hole PreAmp", 34.5 / 2. * mm, 22. / 2. * mm, fCoolingBlockL / 2.); + dx = -fCoolingBlockW / 2. + fCoolingBlockT + 34.5 / 2. * mm; + dy = fCoolingBlockH / 2. - fCoolingBlockT - Hole4DSSD_H - fCoolingBlockT - 22. / 2. * mm; + G4ThreeVector holePreAmpTrans1(dx, dy, dz); + dx += (34.5 * mm + fCoolingBlockT); + G4ThreeVector holePreAmpTrans2(dx, dy, dz); + dx += (34.5 * mm + 14.7 * mm); + G4ThreeVector holePreAmpTrans3(dx, dy, dz); + dx += (34.5 * mm + fCoolingBlockT); + G4ThreeVector holePreAmpTrans4(dx, dy, dz); - G4Box* solidPA_SupportBoard = new G4Box("dssd-pa-support-pcb", PA_SupportBoard_T/2., PA_SupportBoard_W/2., PA_SupportBoard_L/2.); - G4Box* solidPA_Board = new G4Box("dssd-pa-pcb", PA_Board_W/2., PA_Board_T/2., PA_Board_L/2.); - G4Tubs* solidPA_Capacitor = new G4Tubs("dssd-pa-cap", 0.0*mm, PA_Capacitor_R, PA_Capacitor_T/2., 0.*degree, 360.*degree); - G4Box* solidDSSD_Connector = new G4Box("dssd-connector", connectorW/2., connectorT/2., connectorL/2.); + G4SubtractionSolid* solid_CB_Temp2 = + new G4SubtractionSolid("fCoolingBlockTemp2", solid_CB_Temp1, holePreAmp, 0, holePreAmpTrans1); + G4SubtractionSolid* solid_CB_Temp3 = + new G4SubtractionSolid("fCoolingBlockTemp3", solid_CB_Temp2, holePreAmp, 0, holePreAmpTrans2); - G4VisAttributes* visAtt_PA_SupportBoard = new G4VisAttributes(G4Colour(0.2,0.9,0.2) ); - visAtt_PA_SupportBoard->SetVisibility(true); - // visAtt_PA_SupportBoard->SetVisibility(false); - visAtt_PA_SupportBoard->SetForceWireframe(true); + G4SubtractionSolid* solid_CB_Temp4 = + new G4SubtractionSolid("fCoolingBlockTemp4", solid_CB_Temp3, holePreAmp, 0, holePreAmpTrans3); - G4VisAttributes* visAtt_PA_Board = new G4VisAttributes(G4Colour(0.1,0.9,0.1) ); - visAtt_PA_Board->SetVisibility(true); - // visAtt_PA_Board->SetVisibility(false); - visAtt_PA_Board->SetForceWireframe(true); + G4SubtractionSolid* solid_CB_Temp5 = + new G4SubtractionSolid("fCoolingBlockTemp5", solid_CB_Temp4, holePreAmp, 0, holePreAmpTrans4); - //visualise the capacitors - G4VisAttributes* visCapacitor = new G4VisAttributes(G4Colour(0.3,0.1,0.9) ); - visCapacitor->SetVisibility(true); - //visCapacitor->SetVisibility(false); - visCapacitor->SetForceWireframe(true); + G4LogicalVolume* logicDSSD_Sup = new G4LogicalVolume(solid_CB_Temp5, supportMaterial, "Cylinder-Box", 0, 0, 0); + // vacuumMaterial, "Cylinder-Box", 0, 0, 0); + logicDSSD_Sup->SetVisAttributes(visAttCoolingBlock); - G4LogicalVolume* logicPA_SupportBoard = new G4LogicalVolume(solidPA_SupportBoard, // it's solid - boardMaterial, // it's material - "dssd-pa-support-pcb", // it's name - 0,0,0); // field manager etc + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0.0 * cm, DSSD_SupPos_y, DSSD_SupPos_z), + logicDSSD_Sup, // its logical volume + "fCoolingBlock", // its name + logicChamVac, // its mother + false, // no boolean operat + 1, // copy number + true); // overlap check + //------------------------------------------------------------------------------------------- + // DSSD detector Epoxy board....for some reason 2 cut outs are not working => make 2 PCB wafers + G4double DSSD_BrdW = 106.0 * mm * 2.; // Put the 2 boards in one plate + G4double DSSD_BrdH = 157.0 * mm; // SupportH; + G4double DSSD_BrdL = fDSSD_BoardL; // Thickness + + // recess to house DSSD's + G4double siImpBrdCutOutL = fDSSD_BoardL / 2.; + // making 2 boards => + G4double DSSD_BrdL1 = DSSD_BrdL - siImpBrdCutOutL; + G4double DSSD_BrdL2 = siImpBrdCutOutL; + + G4double CutOut_dY = 44.0 * mm; // distance from top of PCB to top of the first cut-out in the PCB + G4double CutOut1_H = 43.5 * mm; // vertical dimension of the cut-out to half thickness + G4double CutOut2_H = 41.0 * mm; // vertical dimension of total-thickness cut-ou ie a mounting lip of 1.25 mm + + G4double CutOut1_W = 63.5 * mm; // fDSSD_H-2.0*boardLipDSSD; + G4double CutOut2_W = 61.0 * mm; // fDSSD_H; + + G4double dssdLip = (CutOut1_W - CutOut2_W) / 2.; + G4double central_bar = 1.25 * mm; // each side + + G4double DSSD_PCB_Pos_y = -fVacuumH / 2. - DSSD_BrdH / 2.; // puts top of circuit board at bottom of chamber + DSSD_PCB_Pos_y += (fCoolingBlockDSSDCentre + CutOut_dY + CutOut1_H / 2.); + + G4double gapBetweenDSSD = 3.0 * mm; // Gap between the two DSSD's + + // gapBetweenDSSD = 0.01*mm; + + // position wrt centre of vacuum in chamber + G4double DSSD_BrdPos_z = fChamberL / 2 - fChamberThickness - fCoolingBlockZ + DSSD_BrdL1 / 2 + DSSD_BrdL2; + + G4Box* solidDSSD_Board1_tmp1 = new G4Box("siImpBrd1_tmp", DSSD_BrdW / 2., DSSD_BrdH / 2., DSSD_BrdL1 / 2.); + + G4Box* cutOut1a = new G4Box("Box R #1a", CutOut1_W / 2., CutOut1_H / 2., DSSD_BrdL1 / 2.); + G4ThreeVector cutOut1aTrans(CutOut1_W / 2., DSSD_BrdH / 2. - CutOut1_H / 2. - CutOut_dY, 0.0 * mm); + + G4Box* cutOut1b = new G4Box("Box R #1b", CutOut1_W / 2., CutOut1_H / 2., DSSD_BrdL1 / 2.); + G4ThreeVector cutOut1bTrans(-CutOut1_W / 2., DSSD_BrdH / 2. - CutOut1_H / 2. - CutOut_dY, 0.0 * mm); + + G4SubtractionSolid* solidDSSD_Board1_a = + new G4SubtractionSolid("siImpBrd1_a", solidDSSD_Board1_tmp1, cutOut1a, 0, cutOut1aTrans); + + G4SubtractionSolid* solidDSSD_Board1 = + new G4SubtractionSolid("siImpBrd1", solidDSSD_Board1_a, cutOut1b, 0, cutOut1bTrans); + + G4LogicalVolume* logicDSSD_Board1 = new G4LogicalVolume(solidDSSD_Board1, // it's solid : with cut-out + boardMaterial, // it's material + // vacuumMaterial, + "DSSD_Brd1", // it's name + 0, 0, 0); // field manager, sensitive det, user limits + + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0.0 * mm, DSSD_PCB_Pos_y, DSSD_BrdPos_z), + logicDSSD_Board1, // its logical volume + "DSSD_Brd1", // its name + logicChamVac, // its mother + false, // no boolean operat + 0, // copy number + true); // overlap check + + DSSD_BrdPos_z -= DSSD_BrdL1 / 2; + DSSD_BrdPos_z -= DSSD_BrdL2 / 2; + + G4Box* solidDSSD_Board2_tmp1 = new G4Box("siImpBrd2_tmp", DSSD_BrdW / 2., DSSD_BrdH / 2., DSSD_BrdL2 / 2.); + + G4Box* cutOut2a = new G4Box("Box R #2a", CutOut2_W / 2., CutOut2_H / 2., DSSD_BrdL2 / 2.); + G4ThreeVector cutOut2aTrans(CutOut2_W / 2. + central_bar, DSSD_BrdH / 2. - CutOut2_H / 2. - CutOut_dY - dssdLip, + 0.0 * mm); + + G4Box* cutOut2b = new G4Box("Box R #2b", CutOut2_W / 2., CutOut2_H / 2., DSSD_BrdL2 / 2.); + G4ThreeVector cutOut2bTrans(-CutOut2_W / 2. - central_bar, DSSD_BrdH / 2. - CutOut2_H / 2. - CutOut_dY - dssdLip, + 0.0 * mm); + + G4SubtractionSolid* solidDSSD_Board2_a = + new G4SubtractionSolid("siImpBrd2_a", solidDSSD_Board2_tmp1, cutOut2a, 0, cutOut2aTrans); + + G4SubtractionSolid* solidDSSD_Board2 = + new G4SubtractionSolid("siImpBrd2", solidDSSD_Board2_a, cutOut2b, 0, cutOut2bTrans); + + G4LogicalVolume* logicDSSD_Board2 = new G4LogicalVolume(solidDSSD_Board2, // it's solid : with cut-out + boardMaterial, // it's material + // vacuumMaterial, + "DSSD_Brd2", // it's name + 0, 0, 0); // field manager, sensitive det, user limits + + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0.0 * mm, DSSD_PCB_Pos_y, DSSD_BrdPos_z), + logicDSSD_Board2, // its logical volume + "DSSD_Brd2", // its name + logicChamVac, // its mother + false, // no boolean operat + 0, // copy number + true); // overlap check + + //-------------------------------------------- + // Implantation detectors + // first make two Si boards -> gauard ring... + G4VisAttributes* visAttDSSD_1 = new G4VisAttributes(G4Colour(0.6, 0.4, 0.4)); + visAttDSSD_1->SetVisibility(true); + // visAttDSSD_1->SetVisibility(false); + visAttDSSD_1->SetForceWireframe(true); + + G4double DSSD_z = DSSD_BrdPos_z - DSSD_BrdL / 2. - 3. * fDSSD_T / 2. + (DSSD_BrdL - siImpBrdCutOutL); + DSSD_z = fChamberL / 2 - fChamberThickness - fCoolingBlockZ + DSSD_BrdL2 - fDSSD_T / 2.; + G4cout << "DSSD Z wrt ChamberVac " << DSSD_z << G4endl; + + G4double totalDSSD_H = fDSSD_H + 2. * fDSSD_Guard; + G4double totalDSSD_W = fDSSD_W + 2. * fDSSD_Guard; + G4Box* solidSi1 = new G4Box("Si1", totalDSSD_W / 2., totalDSSD_H / 2., fDSSD_T / 2.); // Si: 62x42 + G4LogicalVolume* logicSi1 = new G4LogicalVolume(solidSi1, // it's solid + eDetMat, // it's material //vacuumMaterial, + "dssd1", // it's name + 0, 0, 0); // field manager, sensitive det, user limits + + logicSi1->SetVisAttributes(visAttDSSD_1); + + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(totalDSSD_W / 2. + 0.75 * mm, fCentreOfDSSD_Y, DSSD_z), + // G4ThreeVector(0.0*mm,fCentreOfDSSD_Y,DSSD_z), + logicSi1, // its logical volume + "dssd1", // its name + logicChamVac, // its mother + false, // no boolean operat + 1); //, //copy number + + G4LogicalVolume* logicSi2 = new G4LogicalVolume(solidSi1, // it's solid + eDetMat, // it's material //vacuumMaterial, + "dssd2", // it's name + 0, 0, 0); // field manager, sensitive det, user limits + + logicSi2->SetVisAttributes(visAttDSSD_1); + + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(-totalDSSD_W / 2. - 0.75 * mm, fCentreOfDSSD_Y, DSSD_z), + // G4ThreeVector(0.0*mm,fCentreOfDSSD_Y,DSSD_z), + logicSi2, // its logical volume + "dssd2", // its name + logicChamVac, // its mother + false, // no boolean operat + 2); //, //copy number + + // The ChamberVac is located wrt centre of Chamber => z0 = -fChamberL/2. + fDSSD_PosZ = DSSD_z - fChamberL / 2. - fDSSD_T / 2.; + G4cout << "Upstream DSSD face @ Z = " << fDSSD_PosZ << G4endl; + + // common dssd "pixel" shape + G4VisAttributes* visAttDSSD = new G4VisAttributes(G4Colour(0.8, 0.3, 0.3)); + visAttDSSD->SetVisibility(true); + // visAttDSSD->SetVisibility(false); + visAttDSSD->SetForceWireframe(true); + + G4double fDSSD_Pixel_Lx = fDSSD_W / (1.0 * nStripsX); + G4double fDSSD_Pixel_Ly = fDSSD_H / (1.0 * nStripsY); + + G4Box* solidDSSD = new G4Box("dssd", fDSSD_Pixel_Lx / 2., fDSSD_Pixel_Ly / 2., fDSSD_T / 2.); + + // starting y-position for lowest row + G4double thisy = -nStripsY / 2. * fDSSD_Pixel_Ly + fDSSD_Pixel_Ly / 2. + fCoolingBlockCutOut_PosY; + thisy = -nStripsY / 2. * fDSSD_Pixel_Ly + fDSSD_Pixel_Ly / 2. + fCentreOfDSSD_Y; + + G4double thisy2 = -fDSSD_H / 2. + fDSSD_Pixel_Ly / 2.; + + for (G4int iy = 0; iy < nStripsY; iy++) { + // starting x-position + G4double thisx = -nStripsX * fDSSD_Pixel_Lx + fDSSD_Pixel_Lx / 2. - gapBetweenDSSD / 2.; + G4double thisx2 = -fDSSD_W / 2. + fDSSD_Pixel_Lx / 2.; + for (G4int ix = 0; ix < nStripsX; ix++) { + + // DSSD_A + logicDSSD_A[iy][ix] = new G4LogicalVolume(solidDSSD, // it's solid + eDetMat, // it's material + // vacuumMaterial, + "dssd-pixel", // it's name + 0, 0, 0); // field manager, sensitive det, user limits + + PVPBuffer = new G4PVPlacement(0, // rotation + // G4ThreeVector(thisx,thisy,DSSD_z), + G4ThreeVector(thisx2, thisy2, 0.0 * mm), + logicDSSD_A[iy][ix], // its logical volume + "DSSD_A", // its name + logicSi2, // its mother + false, // no boolean operat + iy * 100 + ix); //, //copy number + + // DSSD_B + logicDSSD_B[iy][ix] = new G4LogicalVolume(solidDSSD, // it's solid + eDetMat, // it's material + // vacuumMaterial, + "dssd-pixel", // it's name + 0, 0, 0); // field manager, sensitive det, user limits + + PVPBuffer = new G4PVPlacement(0, // rotation + // G4ThreeVector(thisx+fDSSD_W+gapBetweenDSSD,thisy,DSSD_z), + G4ThreeVector(thisx2, thisy2, 0.0 * mm), + logicDSSD_B[iy][ix], // its logical volume + "DSSD_B", // its name + logicSi1, // its mother + false, // no boolean operat + iy * 100 + ix); //, //copy number + + // visu + logicDSSD_A[iy][ix]->SetVisAttributes(visAttDSSD); + logicDSSD_B[iy][ix]->SetVisAttributes(visAttDSSD); + + // move along please + // thisN++; + thisx += fDSSD_Pixel_Lx; + thisx2 += fDSSD_Pixel_Lx; + } + thisy += fDSSD_Pixel_Ly; + thisy2 += fDSSD_Pixel_Ly; + } - G4LogicalVolume* logicDSSD_Connector = new G4LogicalVolume(solidDSSD_Connector, // it's solid - boardMaterial, // it's material - "dssd-connector", // it's name - 0,0,0); // field manager etc + //-------------------------------------------- + // The PINS + //-------------------------------------------- + G4double PinL = 30.0 * mm; // PinLxPinL + G4double PinT = 1.0 * mm; // 0.5 * mm; //Thickness + G4double PinGuard = 1.0 * mm; // Guardrail + G4double PinGap = 1.0 * mm; // between PINS + G4double PinToEdge = 3.0 * mm; // gap from the end + G4double PinEpoxyT = 1.6 * mm; // thickness of pcb board + // G4double PinSupportLip = PinT+PinEpoxyT; //thickness of pcb board + + // horizontal-side dimensions [approxiamted as a single board] + G4double PinBoard_H_W = PinL * 5.; + G4double PinBoard_H_H = PinEpoxyT; + G4double PinBoard_H_L = PinToEdge + PinL + PinGap + PinL + 13.0 * mm; + + // vertical-side dimensions [approximated as a single board] + G4double PinBoard_V_H = PinL * 2.; + G4double PinBoard_V_W = PinEpoxyT; + G4double PinBoard_V_L = PinToEdge + PinL + PinGap + PinL + 13.0 * mm; + + // the PCB board for the PINS sits on top of another board [oh yeah transparency !] + G4double PinBoardSupport_T = 4.75 * mm; // nominally 4.75*mm; + + // positions wrt cahmaber vacuum : put it at downstream side of the support block + G4double PinBoard_z = DSSD_SupPos_z + fCoolingBlockL / 2 - PinBoard_H_L / 2.; + PinBoard_z -= 1.5 * mm; // move back due to support + + G4double PinBoard_H_x = 0.0 * mm; + G4double PinBoard_H_dy = Hole4DSSD_H / 2. - PinEpoxyT / 2. - PinBoardSupport_T; + G4double PinBoard_V_x = Hole4DSSD_W / 2. - PinEpoxyT / 2. - PinBoardSupport_T; + fDSSD_PosY = fCentreOfDSSD_Y; + G4double PinBoard_V_y = fDSSD_PosY; + + // The epoxy board for the pins + G4VisAttributes* visAttPIN_Board = new G4VisAttributes(G4Colour(0.3, 0.9, 0.3)); + visAttPIN_Board->SetVisibility(true); + // visAttPIN_Board->SetVisibility(false); + visAttPIN_Board->SetForceWireframe(true); + + // Pin PCB/Epoxy boards + G4Box* solidPinBoard_H = new G4Box("pin-pcb", PinBoard_H_W / 2., PinBoard_H_H / 2., PinBoard_H_L / 2.); + G4Box* solidPinBoard_V = new G4Box("pin-pcb", PinBoard_V_W / 2., PinBoard_V_H / 2., PinBoard_V_L / 2.); + + G4LogicalVolume* logicPinBoard_H = new G4LogicalVolume(solidPinBoard_H, // it's solid + boardMaterial, // it's material + "pin-pcb", // it's name + 0, 0, 0); // field manager etc + + G4LogicalVolume* logicPinBoard_V = new G4LogicalVolume(solidPinBoard_V, // it's solid + boardMaterial, // it's material + "pin-pcb", // it's name + 0, 0, 0); // field manager etc + + logicPinBoard_H->SetVisAttributes(visAttPIN_Board); + logicPinBoard_V->SetVisAttributes(visAttPIN_Board); + + // G4PVPlacement* physiPinBoard_H[2]; + // G4PVPlacement* physiPinBoard_V[2]; + + for (G4int i = 0; i < 2; i++) { + + G4double dyPos = (2 * i - 1) * PinBoard_H_dy; + + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(PinBoard_H_x, fCentreOfDSSD_Y + dyPos, PinBoard_z), + logicPinBoard_H, // its logical volume + "PinPCB_H", // its name + logicChamVac, // its mother + false, // no boolean operat + i + 1); // copy number + + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(PinBoard_V_x * (2 * i - 1), PinBoard_V_y, PinBoard_z), + logicPinBoard_V, // its logical volume + "PinPCB_V", // its name + logicChamVac, // its mother + false, // no boolean operat + i + 1); // copy number + } + //----------------------------------------- + // Horiz Support for Pin Epoxy : the PCB board for the PINS sits on top of another board [oh yeah transparency !] + G4VisAttributes* visAttPIN_BoardSup = new G4VisAttributes(G4Colour(0.9, 0.9, 0.9)); + visAttPIN_BoardSup->SetVisibility(true); + // visAttPIN_BoardSup->SetVisibility(false); + visAttPIN_BoardSup->SetForceWireframe(true); - G4LogicalVolume* logicPA_Board = new G4LogicalVolume(solidPA_Board, // it's solid - boardMaterial, // it's material - "dssd-pa-pcb", // it's name - 0,0,0); // field manager etc - + G4double PinBoardSupport_H_W = fCoolingBlockCutOutW; + G4double PinBoardSupport_H_H = 3.75 * mm; + G4double PinBoardSupport_H_L = 80. * mm; - G4LogicalVolume* logicPA_Capacitor = new G4LogicalVolume(solidPA_Capacitor, // it's solid - boardMaterial, // it's material - "dssd-pa-cap", // it's name - 0,0,0); // field manager etc + G4Box* solidPinSupportBoard_H_temp = + new G4Box("pin-pcb-support", PinBoardSupport_H_W / 2., PinBoardSupport_H_H / 2., PinBoardSupport_H_L / 2.); - logicPA_SupportBoard->SetVisAttributes(visAtt_PA_SupportBoard); - logicDSSD_Connector->SetVisAttributes(visAtt_PA_SupportBoard); - logicPA_Board->SetVisAttributes(visAtt_PA_Board); - logicPA_Capacitor->SetVisAttributes(visCapacitor); + G4double cutOutPinBoard_H_x = 28.6 * mm; + G4Box* cutOutPinBoard_H = + new G4Box("Box Pin Board #1", cutOutPinBoard_H_x / 2., PinBoardSupport_H_H / 2., 70. * mm / 2.); + G4ThreeVector cutOutPinBoard_H_centre(0.0 * mm, 0.0 * mm, 5.0 * mm); + G4ThreeVector cutOutPinBoard_H_p1(PinL, 0.0 * mm, 5.0 * mm); + G4ThreeVector cutOutPinBoard_H_m1(-PinL, 0.0 * mm, 5.0 * mm); + G4ThreeVector cutOutPinBoard_H_p2(2 * PinL, 0.0 * mm, 5.0 * mm); + G4ThreeVector cutOutPinBoard_H_m2(-2 * PinL, 0.0 * mm, 5.0 * mm); - //G4PVPlacement* physiPA_SupportBoard[6]; - //G4PVPlacement* physiDSSD_Connector[12]; + G4SubtractionSolid* solidPinSupportBoard_H0 = new G4SubtractionSolid( + "pin-pcb-support_0", solidPinSupportBoard_H_temp, cutOutPinBoard_H, 0, cutOutPinBoard_H_centre); - G4double top_of_DSSD_Brd = DSSD_PCB_Pos_y + DSSD_BrdH/2.; - G4double gapConnector_2_DSSD_Board_V = 15.0*mm; //Gap between the top of the top connector and top of DSSD board = 15.0 mm - G4double gapConnector_2_DSSD_Board_H = 15.0*mm; //Gap between the end of the centre connector to the centre of the DSSD board = 15.0 mm - G4double gapConnector_PA_Board = 4.0*mm; + G4SubtractionSolid* solidPinSupportBoard_HA = + new G4SubtractionSolid("pin-pcb-support_a", solidPinSupportBoard_H0, cutOutPinBoard_H, 0, cutOutPinBoard_H_p1); + G4SubtractionSolid* solidPinSupportBoard_HB = + new G4SubtractionSolid("pin-pcb-support_b", solidPinSupportBoard_HA, cutOutPinBoard_H, 0, cutOutPinBoard_H_m1); - G4RotationMatrix* rmCap = new G4RotationMatrix; - rmCap->set(0,0,0); - rmCap->rotateX(90.*degree); + G4SubtractionSolid* solidPinSupportBoard_HC = + new G4SubtractionSolid("pin-pcb-support_b", solidPinSupportBoard_HB, cutOutPinBoard_H, 0, cutOutPinBoard_H_p2); - G4RotationMatrix* rot_90_Z = new G4RotationMatrix; - rot_90_Z->set(0,0,0); - rot_90_Z->rotateZ(90.*degree); - - G4RotationMatrix* rot_90_Y = new G4RotationMatrix; - rot_90_Y->set(0,0,0); - rot_90_Y->rotateY(90.*degree); - - //vertical boards.... - //G4PVPlacement* physiPA_Board[6][nPA]; - //G4PVPlacement* physiPA_Capacitor[6][nPA]; - - for(G4int i = 0; i < 4; i++) { - - G4double xPos = fCoolingBlockW/2. + PA_SupportBoard_T/2. + 3.0*mm; - G4double yPos = top_of_DSSD_Brd - PA_SupportBoard_W/2. - gapConnector_2_DSSD_Board_V + gapConnector_PA_Board; - - if(i >= 2) xPos *= -1.; - if(i%2 != 0) yPos -= (PA_SupportBoard_W + 7.0*mm); + G4SubtractionSolid* solidPinSupportBoard_H = + new G4SubtractionSolid("pin-pcb-support_b", solidPinSupportBoard_HC, cutOutPinBoard_H, 0, cutOutPinBoard_H_m2); - PVPBuffer = - new G4PVPlacement(0, //rotation - G4ThreeVector(xPos, yPos, PA_SupportBoard_z), - logicPA_SupportBoard, //its logical volume - "dssd-pa-support-pcb", //its name - logicChamVac, //its mother - false, //no boolean operat - i+1); //copy number - - - xPos = DSSD_BrdW/2. - 9.0*mm; - yPos = top_of_DSSD_Brd - gapConnector_2_DSSD_Board_V - connectorW/2.; - - switch (i) { - case 0 : - break; - case 1 : yPos -= (7.0*mm + connectorW); - break; - case 2 : yPos -= (15.0*mm + connectorW); - break; - case 3 : yPos -= (7.0*mm + connectorW); - break; - } + G4LogicalVolume* logicPinSupportBoard_H = new G4LogicalVolume(solidPinSupportBoard_H, // it's solid + m_ChamberMaterial, // it's material + "pin-pcb-support", // it's name + 0, 0, 0); // field manager etc + logicPinSupportBoard_H->SetVisAttributes(visAttPIN_BoardSup); - - PVPBuffer = - new G4PVPlacement(rot_90_Z, //rotation - G4ThreeVector(xPos, yPos, PA_SupportBoard_z+PA_SupportBoard_L/2.-connectorL/2.), - logicDSSD_Connector, //its logical volume - "dssd-pa-support-pcb", //its name - logicChamVac, //its mother - false, //no boolean operat - i+1); //copy number + G4double PinBoardSupport_Z = DSSD_SupPos_z + fCoolingBlockL / 2. - PinBoardSupport_H_L / 2. - 1.0 * mm; PVPBuffer = - new G4PVPlacement(rot_90_Z, //rotation - G4ThreeVector(-xPos, yPos, PA_SupportBoard_z+PA_SupportBoard_L/2.-connectorL/2.), - logicDSSD_Connector, //its logical volume - "dssd-pa-support-pcb", //its name - logicChamVac, //its mother - false, //no boolean operat - i+1+4); //copy number - - //place the preamp boards and capacitors - G4double PA_PosY = top_of_DSSD_Brd - gapConnector_2_DSSD_Board_V + gapConnector_PA_Board; - G4double PA_PosX = fCoolingBlockW/2.+PA_SupportBoard_T+3.0*mm+PA_Board_W/2.; - - if(i >= 2) PA_PosX *= -1.; - if(i%2 != 0) PA_PosY -= (PA_SupportBoard_W + 7.0*mm); - - for(G4int j = 0; j < nPA; j++) { - G4double thisY = PA_PosY - PA_dPos*(j+1); - PVPBuffer = - new G4PVPlacement(0, //rotation - G4ThreeVector(PA_PosX, thisY, PA_SupportBoard_z-10*mm), - logicPA_Board, //its logical volume - "dssd-pa-pcb", //its name - logicChamVac, //its mother - false, //no boolean operat - j+1); //copy number + new G4PVPlacement(0, // rotation + G4ThreeVector(PinBoard_H_x, fDSSD_PosY + fCoolingBlockCutOutH / 2. - PinBoardSupport_H_H / 2., + PinBoardSupport_Z), + logicPinSupportBoard_H, // its logical volume + "PinPCB_Support", // its name + logicChamVac, // its mother + false, // no boolean operat + 1); // copy number - PVPBuffer = - new G4PVPlacement(rmCap, //rotation - G4ThreeVector(PA_PosX, thisY, PA_SupportBoard_z+20.*mm), - logicPA_Capacitor, //its logical volume - "dssd-pa-cap", //its name - logicChamVac, //its mother - false, //no boolean operat - j+1); //copy number - - } - } - - - //horizontal... - for(G4int i = 4; i < 6; i++) { - - G4double xPos = PA_SupportBoard_W/2.+gapConnector_2_DSSD_Board_H-gapConnector_PA_Board; - G4double yPos = top_of_DSSD_Brd-13.*mm-connectorT-PA_SupportBoard_T/2.+ 1.0*mm; - - if(i == 5) xPos *= -1.; - - PVPBuffer= - new G4PVPlacement(rot_90_Z, //rotation - G4ThreeVector(xPos, yPos, PA_SupportBoard_z), - logicPA_SupportBoard, //its logical volume - "dssd-pa-support-pcb", //its name - logicChamVac, //its mother - false, //no boolean operat - i+1); //copy number - - for(G4int j = 0; j < 2; j++) { - PVPBuffer = - new G4PVPlacement(0, //rotation - G4ThreeVector(xPos+((2*j-1)*(connectorW/2.+3.5*mm)), yPos+PA_SupportBoard_T/2.+connectorT/2., PA_SupportBoard_z+PA_SupportBoard_L/2.-connectorL/2.), - logicDSSD_Connector, //its logical volume - "dssd-pa-support-pcb", //its name - logicChamVac, //its mother - false, //no boolean operat - 1+4+2*i+j); //copy number + PVPBuffer = + new G4PVPlacement(0, // rotation + G4ThreeVector(PinBoard_H_x, fDSSD_PosY - fCoolingBlockCutOutH / 2. + PinBoardSupport_H_H / 2., + PinBoardSupport_Z), + logicPinSupportBoard_H, // its logical volume + "PinPCB_Support", // its name + logicChamVac, // its mother + false, // no boolean operat + 2); // copy number + + G4double PinBoardSupport_W_W = 3.75 * mm; + G4double PinBoardSupport_W_H = fCoolingBlockCutOutH - 2. * PinBoardSupport_H_H; + G4double PinBoardSupport_W_L = 80. * mm; + + // Vertical Support Pin Epoxy + G4Box* solidPinSupportBoard_V_temp = + new G4Box("pin-pcb-support", PinBoardSupport_W_W / 2., PinBoardSupport_W_H / 2., PinBoardSupport_W_L / 2.); + + G4Box* cutOutPinBoard_V = + new G4Box("Box Pin Board #1", PinBoardSupport_W_W / 2., cutOutPinBoard_H_x / 2., 70. * mm / 2.); + G4double cutOutSpine_x = (PinL + PinGap - cutOutPinBoard_H_x) / 2.; + + G4ThreeVector cutOutPinBoard_V_p1(0.0 * mm, (cutOutSpine_x + cutOutPinBoard_H_x) / 2., 5.0 * mm); + G4ThreeVector cutOutPinBoard_V_m1(0.0 * mm, -(cutOutSpine_x + cutOutPinBoard_H_x) / 2., 5.0 * mm); + + G4SubtractionSolid* solidPinSupportBoard_V0 = new G4SubtractionSolid( + "pin-pcb-support_0", solidPinSupportBoard_V_temp, cutOutPinBoard_V, 0, cutOutPinBoard_V_p1); + + G4SubtractionSolid* solidPinSupportBoard_V = + new G4SubtractionSolid("pin-pcb-support_b", solidPinSupportBoard_V0, cutOutPinBoard_V, 0, cutOutPinBoard_V_m1); + + G4LogicalVolume* logicPinSupportBoard_V = new G4LogicalVolume(solidPinSupportBoard_V, // it's solid + m_ChamberMaterial, // it's material + "pin-pcb-support", // it's name + 0, 0, 0); // field manager etc + + logicPinSupportBoard_V->SetVisAttributes(visAttPIN_BoardSup); + + PVPBuffer = new G4PVPlacement( + 0, // rotation + G4ThreeVector(fCoolingBlockCutOutW / 2. - PinBoardSupport_W_W / 2., fDSSD_PosY, PinBoardSupport_Z), + logicPinSupportBoard_V, // its logical volume + "PinPCBSupport", // its name + logicChamVac, // its mother + false, // no boolean operat + 1); // copy number + + PVPBuffer = new G4PVPlacement( + 0, // rotation + G4ThreeVector(-fCoolingBlockCutOutW / 2. + PinBoardSupport_W_W / 2., fDSSD_PosY, PinBoardSupport_Z), + logicPinSupportBoard_V, // its logical volume + "PinPCBSupport", // its name + logicChamVac, // its mother + false, // no boolean operat + 2); // copy number + + // add the fucking ridiculous flange.... + G4double PinFlange_Z = DSSD_SupPos_z + fCoolingBlockL / 2. - 0.5 * mm; + G4Box* PinFlange_outer = + new G4Box("Box Pin Flange #1", fCoolingBlockCutOutW / 2., fCoolingBlockCutOutH / 2., + 1.0 * mm / 2.); // probably even thicker just to make sure no low E gammas are seen ! + G4Box* PinFlange_hole = new G4Box("Box Pin Flange #2", fCoolingBlockCutOutW / 2. - 4.0 * mm, + fCoolingBlockCutOutH / 2. - 4.0 * mm, 1.0 * mm / 2.); + + G4SubtractionSolid* solidPinFlange = new G4SubtractionSolid("pin-flange", PinFlange_outer, PinFlange_hole, 0, + G4ThreeVector(0. * mm, 0. * mm, 0. * mm)); + + G4LogicalVolume* logicPinFlange = new G4LogicalVolume(solidPinFlange, // it's solid + m_ChamberMaterial, // it's material + "pin-flange", // it's name + 0, 0, 0); // field manager etc + + logicPinFlange->SetVisAttributes(visAttPIN_BoardSup); + + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0.0 * mm, fDSSD_PosY, PinFlange_Z), + logicPinFlange, // its logical volume + "PinFlange", // its name + logicChamVac, // its mother + false, // no boolean operat + 1); // copy number + + // now the PINS..... + G4VisAttributes* visAttPIN = new G4VisAttributes(G4Colour(0.9, 0.9, 0.3)); + visAttPIN->SetVisibility(true); + // visAttPIN->SetVisibility(false); + visAttPIN->SetForceWireframe(true); + + G4double Pin_z1 = PinBoard_z + PinBoard_V_L / 2. - PinToEdge - PinL / 2; + // G4double Pin_z2 = Pin_z1 - PinGap - PinL; + + // total Si area + G4Box* solidPINS_H = new G4Box("pins-passive", PinL / 2., PinT / 2., PinL / 2); // horizontal + new G4Box("pins-passive", PinT / 2., PinL / 2., PinL / 2); // vertical + + // active Si + G4Box* solidPINS_Active_H = new G4Box("pins", PinL / 2. - PinGuard, PinT / 2., PinL / 2 - PinGuard); // horizontal + new G4Box("pins", PinT / 2., PinL / 2. - PinGuard, PinL / 2 - PinGuard); // vertical + + // horizontal rows could put an index[i] = copyNo to match position in real array !! + for (G4int nH = 0; nH < 2; nH++) { // up/down + G4double posY = fDSSD_PosY + (2 * nH - 1) * (PinBoard_H_dy - PinBoard_H_H / 2. - PinT / 2.); + + for (G4int i = 1; i <= 5; i++) { // across in x + G4double posX = -PinBoard_H_W / 2. + PinL / 2. + (i - 1) * PinL; + + for (G4int r = 1; r <= 2; r++) { // 2 rows (in z) + G4double posZ = Pin_z1 - (r % 2) * (PinGap + PinL); + G4int copyNo = nH * 10 + 2 * (i - 1) + r; + G4cout << "Checking PIN copyNo " << copyNo << G4endl; + + logicPINS[copyNo - 1] = new G4LogicalVolume(solidPINS_H, // it's solid + eDetMat, // it's material + "pin-pass-h", // it's name + 0, 0, 0); // field manager etc + + logicPINS[copyNo - 1]->SetVisAttributes(visAttPIN); + + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(posX, posY, posZ), + logicPINS[copyNo - 1], // its logical volume + "PinPass", // its name + logicChamVac, // its mother + false, // no boolean operat + copyNo, // copy number + true); // check for overlaps + + logicPINS_Active[copyNo - 1] = new G4LogicalVolume(solidPINS_Active_H, // it's solid + eDetMat, // it's material + "pin-h", // it's name + 0, 0, 0); // field manager etc + + logicPINS_Active[copyNo - 1]->SetVisAttributes(visAttPIN); + + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, 0. * mm), + logicPINS_Active[copyNo - 1], // its logical volume + "Pin", // its name + logicPINS[copyNo - 1], // its mother + false, // no boolean operat + copyNo); // copy number + } + } } - - //place the preamp boards and capacitors - G4double PA_PosY = yPos + PA_Board_W/2. + PA_SupportBoard_T/2.; - G4double PA_PosX = xPos + PA_SupportBoard_W/2.; - - - //if(i >= 2) PA_PosX *= -1.; - //if(i%2 != 0) PA_PosY -= (PA_SupportBoard_W + 7.0*mm); - - for(G4int j = 0; j < nPA; j++) { - G4double thisX = PA_PosX - PA_dPos*(j+1); + + //-------------------------------------------- + // The DSSD pre-amp boards + //-------------------------------------------- + // dimensions of the main support board + G4double PA_SupportBoard_T = 3.0 * mm; + G4double PA_SupportBoard_W = 67.0 * mm; + G4double PA_SupportBoard_L = fCoolingBlockL; // along z + + // dimensions of the individual pcb boards + G4double PA_Board_T = 0.8 * mm; + G4double PA_Board_W = 14.0 * mm; + G4double PA_Board_L = 33.0 * mm; + + // fudge a capacitor in there.... + G4double PA_Capacitor_T = 2.0 * mm; + G4double PA_Capacitor_R = 4.0 * mm; + + // and the connectors... + G4double connectorW = 26.0 * mm; + G4double connectorL = 14.0 * mm; + G4double connectorT = 5.0 * mm; + + // delta-pos for each pre-amp + const G4int nPA = 20; // per support board + G4double PA_dPos = PA_SupportBoard_W / ((G4double)(nPA + 1)); + + // positions wrt chamaber vacuum : put it at downstream side of the support block + G4double PA_SupportBoard_z = DSSD_SupPos_z + fCoolingBlockL / 2. - PA_SupportBoard_L / 2.; + + G4Box* solidPA_SupportBoard = + new G4Box("dssd-pa-support-pcb", PA_SupportBoard_T / 2., PA_SupportBoard_W / 2., PA_SupportBoard_L / 2.); + G4Box* solidPA_Board = new G4Box("dssd-pa-pcb", PA_Board_W / 2., PA_Board_T / 2., PA_Board_L / 2.); + G4Tubs* solidPA_Capacitor = + new G4Tubs("dssd-pa-cap", 0.0 * mm, PA_Capacitor_R, PA_Capacitor_T / 2., 0. * degree, 360. * degree); + G4Box* solidDSSD_Connector = new G4Box("dssd-connector", connectorW / 2., connectorT / 2., connectorL / 2.); + + G4VisAttributes* visAtt_PA_SupportBoard = new G4VisAttributes(G4Colour(0.2, 0.9, 0.2)); + visAtt_PA_SupportBoard->SetVisibility(true); + // visAtt_PA_SupportBoard->SetVisibility(false); + visAtt_PA_SupportBoard->SetForceWireframe(true); + + G4VisAttributes* visAtt_PA_Board = new G4VisAttributes(G4Colour(0.1, 0.9, 0.1)); + visAtt_PA_Board->SetVisibility(true); + // visAtt_PA_Board->SetVisibility(false); + visAtt_PA_Board->SetForceWireframe(true); + + // visualise the capacitors + G4VisAttributes* visCapacitor = new G4VisAttributes(G4Colour(0.3, 0.1, 0.9)); + visCapacitor->SetVisibility(true); + // visCapacitor->SetVisibility(false); + visCapacitor->SetForceWireframe(true); + + G4LogicalVolume* logicPA_SupportBoard = new G4LogicalVolume(solidPA_SupportBoard, // it's solid + boardMaterial, // it's material + "dssd-pa-support-pcb", // it's name + 0, 0, 0); // field manager etc + + G4LogicalVolume* logicDSSD_Connector = new G4LogicalVolume(solidDSSD_Connector, // it's solid + boardMaterial, // it's material + "dssd-connector", // it's name + 0, 0, 0); // field manager etc + + G4LogicalVolume* logicPA_Board = new G4LogicalVolume(solidPA_Board, // it's solid + boardMaterial, // it's material + "dssd-pa-pcb", // it's name + 0, 0, 0); // field manager etc + + G4LogicalVolume* logicPA_Capacitor = new G4LogicalVolume(solidPA_Capacitor, // it's solid + boardMaterial, // it's material + "dssd-pa-cap", // it's name + 0, 0, 0); // field manager etc + + logicPA_SupportBoard->SetVisAttributes(visAtt_PA_SupportBoard); + logicDSSD_Connector->SetVisAttributes(visAtt_PA_SupportBoard); + logicPA_Board->SetVisAttributes(visAtt_PA_Board); + logicPA_Capacitor->SetVisAttributes(visCapacitor); + + // G4PVPlacement* physiPA_SupportBoard[6]; + // G4PVPlacement* physiDSSD_Connector[12]; + + G4double top_of_DSSD_Brd = DSSD_PCB_Pos_y + DSSD_BrdH / 2.; + G4double gapConnector_2_DSSD_Board_V = + 15.0 * mm; // Gap between the top of the top connector and top of DSSD board = 15.0 mm + G4double gapConnector_2_DSSD_Board_H = + 15.0 * mm; // Gap between the end of the centre connector to the centre of the DSSD board = 15.0 mm + G4double gapConnector_PA_Board = 4.0 * mm; + + G4RotationMatrix* rmCap = new G4RotationMatrix; + rmCap->set(0, 0, 0); + rmCap->rotateX(90. * degree); + + G4RotationMatrix* rot_90_Z = new G4RotationMatrix; + rot_90_Z->set(0, 0, 0); + rot_90_Z->rotateZ(90. * degree); + + G4RotationMatrix* rot_90_Y = new G4RotationMatrix; + rot_90_Y->set(0, 0, 0); + rot_90_Y->rotateY(90. * degree); + + // vertical boards.... + // G4PVPlacement* physiPA_Board[6][nPA]; + // G4PVPlacement* physiPA_Capacitor[6][nPA]; + + for (G4int i = 0; i < 4; i++) { + + G4double xPos = fCoolingBlockW / 2. + PA_SupportBoard_T / 2. + 3.0 * mm; + G4double yPos = top_of_DSSD_Brd - PA_SupportBoard_W / 2. - gapConnector_2_DSSD_Board_V + gapConnector_PA_Board; + + if (i >= 2) + xPos *= -1.; + if (i % 2 != 0) + yPos -= (PA_SupportBoard_W + 7.0 * mm); + + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(xPos, yPos, PA_SupportBoard_z), + logicPA_SupportBoard, // its logical volume + "dssd-pa-support-pcb", // its name + logicChamVac, // its mother + false, // no boolean operat + i + 1); // copy number + + xPos = DSSD_BrdW / 2. - 9.0 * mm; + yPos = top_of_DSSD_Brd - gapConnector_2_DSSD_Board_V - connectorW / 2.; + + switch (i) { + case 0: + break; + case 1: + yPos -= (7.0 * mm + connectorW); + break; + case 2: + yPos -= (15.0 * mm + connectorW); + break; + case 3: + yPos -= (7.0 * mm + connectorW); + break; + } + PVPBuffer = - new G4PVPlacement(rot_90_Z, //rotation - G4ThreeVector(thisX, PA_PosY, PA_SupportBoard_z-10*mm), - logicPA_Board, //its logical volume - "dssd-pa-pcb", //its name - logicChamVac, //its mother - false, //no boolean operat - j+1); //copy number - + new G4PVPlacement(rot_90_Z, // rotation + G4ThreeVector(xPos, yPos, PA_SupportBoard_z + PA_SupportBoard_L / 2. - connectorL / 2.), + logicDSSD_Connector, // its logical volume + "dssd-pa-support-pcb", // its name + logicChamVac, // its mother + false, // no boolean operat + i + 1); // copy number + PVPBuffer = - new G4PVPlacement(rot_90_Y, //rotation - G4ThreeVector(thisX, PA_PosY, PA_SupportBoard_z+20.*mm), - logicPA_Capacitor, //its logical volume - "dssd-pa-cap", //its name - logicChamVac, //its mother - false, //no boolean operat - j+1); //copy number - + new G4PVPlacement(rot_90_Z, // rotation + G4ThreeVector(-xPos, yPos, PA_SupportBoard_z + PA_SupportBoard_L / 2. - connectorL / 2.), + logicDSSD_Connector, // its logical volume + "dssd-pa-support-pcb", // its name + logicChamVac, // its mother + false, // no boolean operat + i + 1 + 4); // copy number + + // place the preamp boards and capacitors + G4double PA_PosY = top_of_DSSD_Brd - gapConnector_2_DSSD_Board_V + gapConnector_PA_Board; + G4double PA_PosX = fCoolingBlockW / 2. + PA_SupportBoard_T + 3.0 * mm + PA_Board_W / 2.; + + if (i >= 2) + PA_PosX *= -1.; + if (i % 2 != 0) + PA_PosY -= (PA_SupportBoard_W + 7.0 * mm); + + for (G4int j = 0; j < nPA; j++) { + G4double thisY = PA_PosY - PA_dPos * (j + 1); + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(PA_PosX, thisY, PA_SupportBoard_z - 10 * mm), + logicPA_Board, // its logical volume + "dssd-pa-pcb", // its name + logicChamVac, // its mother + false, // no boolean operat + j + 1); // copy number + + PVPBuffer = new G4PVPlacement(rmCap, // rotation + G4ThreeVector(PA_PosX, thisY, PA_SupportBoard_z + 20. * mm), + logicPA_Capacitor, // its logical volume + "dssd-pa-cap", // its name + logicChamVac, // its mother + false, // no boolean operat + j + 1); // copy number + } } - } - - //================================================ - G4cout << "Placing the clovers......." << G4endl; + // horizontal... + for (G4int i = 4; i < 6; i++) { + + G4double xPos = PA_SupportBoard_W / 2. + gapConnector_2_DSSD_Board_H - gapConnector_PA_Board; + G4double yPos = top_of_DSSD_Brd - 13. * mm - connectorT - PA_SupportBoard_T / 2. + 1.0 * mm; + + if (i == 5) + xPos *= -1.; + + PVPBuffer = new G4PVPlacement(rot_90_Z, // rotation + G4ThreeVector(xPos, yPos, PA_SupportBoard_z), + logicPA_SupportBoard, // its logical volume + "dssd-pa-support-pcb", // its name + logicChamVac, // its mother + false, // no boolean operat + i + 1); // copy number + + for (G4int j = 0; j < 2; j++) { + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(xPos + ((2 * j - 1) * (connectorW / 2. + 3.5 * mm)), + yPos + PA_SupportBoard_T / 2. + connectorT / 2., + PA_SupportBoard_z + PA_SupportBoard_L / 2. - connectorL / 2.), + logicDSSD_Connector, // its logical volume + "dssd-pa-support-pcb", // its name + logicChamVac, // its mother + false, // no boolean operat + 1 + 4 + 2 * i + j); // copy number + } - //by default place 2 PhaseII clovers on either side of the chamber + // place the preamp boards and capacitors + G4double PA_PosY = yPos + PA_Board_W / 2. + PA_SupportBoard_T / 2.; + G4double PA_PosX = xPos + PA_SupportBoard_W / 2.; + + // if(i >= 2) PA_PosX *= -1.; + // if(i%2 != 0) PA_PosY -= (PA_SupportBoard_W + 7.0*mm); + + for (G4int j = 0; j < nPA; j++) { + G4double thisX = PA_PosX - PA_dPos * (j + 1); + PVPBuffer = new G4PVPlacement(rot_90_Z, // rotation + G4ThreeVector(thisX, PA_PosY, PA_SupportBoard_z - 10 * mm), + logicPA_Board, // its logical volume + "dssd-pa-pcb", // its name + logicChamVac, // its mother + false, // no boolean operat + j + 1); // copy number + + PVPBuffer = new G4PVPlacement(rot_90_Y, // rotation + G4ThreeVector(thisX, PA_PosY, PA_SupportBoard_z + 20. * mm), + logicPA_Capacitor, // its logical volume + "dssd-pa-cap", // its name + logicChamVac, // its mother + false, // no boolean operat + j + 1); // copy number + } + } - // uncomment this to put clovers on the sides !! - //Place_PhaseIIs_Left_and_Right(world); //usual + //================================================ + G4cout << "Placing the clovers......." << G4endl; - //Place_GREAT_On_the_Top(world); //usual // Now you can use GRTClov detector instead + // by default place 2 PhaseII clovers on either side of the chamber - //Place_GREAT_Left_and_Right(); //compare - //Place_PhaseII_LookingUpstream(); //usual + // uncomment this to put clovers on the sides !! + // Place_PhaseIIs_Left_and_Right(world); //usual - G4cout << ".....placed" << G4endl; - + // Place_GREAT_On_the_Top(world); //usual // Now you can use GRTClov detector instead + // Place_GREAT_Left_and_Right(); //compare + // Place_PhaseII_LookingUpstream(); //usual - } + G4cout << ".....placed" << G4endl; + } } // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void Chamber::InitializeRootOutput() -{} +void Chamber::InitializeRootOutput() {} // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAction -void Chamber::ReadSensitive(const G4Event*) -{} - - +void Chamber::ReadSensitive(const G4Event*) {} //################################################################################################################################################# - - //------------------------------------------------------------------ // Should add a ResetNumberOfCloversHere //------------------------------------------------------------------ @@ -2318,179 +2230,170 @@ void Chamber::ReadSensitive(const G4Event*) // Should add a delta-Z so I can check effect of sliding the detectors up and down //------------------------------------------------------------------ -// Clover numbering scheme : +// Clover numbering scheme : // Left = 0 => Crystals 0, 1, 2, 3 // Right = 4 => Crystals 4, 5, 6, 7 // Top = 8 => Crystals 8, 9,10,11 // Upstream = 12 => Crystals 12,13,14,15 //------------------------------------------------------------------ //------------------------------------------------------------------ -void Chamber::Place_PhaseIIs_Left_and_Right(G4LogicalVolume* world) -{ +void Chamber::Place_PhaseIIs_Left_and_Right(G4LogicalVolume* world) { //================================================================================= - //Do not know why, but the positioning seems to be with respect to the Taper-part : - //setting the z-position as endCapTaperL/2 puts the front face at z = 0 mm + // Do not know why, but the positioning seems to be with respect to the Taper-part : + // setting the z-position as endCapTaperL/2 puts the front face at z = 0 mm //================================================================================= G4cout << "\t placing two Phase-II's" << G4endl; - G4double endCap_PosX; + G4double endCap_PosX; G4double vacuum_PosZ; G4double geLeaf_PosZ; - //position is with respect to centre of tapered part (UnionSolid) - endCap_PosX = fChamberW/2. + fEndCapTaperL_PhaseII/2. + 2.0*mm; + // position is with respect to centre of tapered part (UnionSolid) + endCap_PosX = fChamberW / 2. + fEndCapTaperL_PhaseII / 2. + 2.0 * mm; vacuum_PosZ = fVacuumPosZ_PhaseII; geLeaf_PosZ = fGeLeafPosZ_PhaseII; - - G4RotationMatrix rm ; + G4RotationMatrix rm; G4double theta = 90. * deg; - G4double phi = 0. * deg; - - - //for(G4int det = prevNumber; det < numberOfClovers; det++) { - for(G4int det = 0; det < 2; det++) { - logicEndCap_CloverLR[det] = new G4LogicalVolume(solidEndCap_PhaseII, endCapMaterial, "clover_EC", 0, 0, 0); - logicVacuum_CloverLR[det] = new G4LogicalVolume(solidVacuum_PhaseII, vacuumMaterial, "clover_Vac", 0, 0, 0); - - for(G4int l = 0; l < 4; l++) { - logicGeLeaf_CloverLR[det][l] = new G4LogicalVolume(solidGeLeaf_PhaseII, geMaterial, "clover_Leaf", 0, 0, 0); - logicPassivated_CloverLR[det][l] = new G4LogicalVolume(solidPassivated_PhaseII, geMaterial, "passivatedGe", 0, 0, 0); //should be Ge - logicContact_CloverLR[det][l] = new G4LogicalVolume(solidContact_PhaseII, contactMaterial, "inner_contact", 0, 0, 0); //should be Li - logicBoreHole_CloverLR[det][l] = new G4LogicalVolume(solidBoreHole_PhaseII, vacuumMaterial, "bore-hole", 0, 0, 0); + G4double phi = 0. * deg; + + // for(G4int det = prevNumber; det < numberOfClovers; det++) { + for (G4int det = 0; det < 2; det++) { + logicEndCap_CloverLR[det] = new G4LogicalVolume(solidEndCap_PhaseII, endCapMaterial, "clover_EC", 0, 0, 0); + logicVacuum_CloverLR[det] = new G4LogicalVolume(solidVacuum_PhaseII, vacuumMaterial, "clover_Vac", 0, 0, 0); + + for (G4int l = 0; l < 4; l++) { + logicGeLeaf_CloverLR[det][l] = new G4LogicalVolume(solidGeLeaf_PhaseII, geMaterial, "clover_Leaf", 0, 0, 0); + logicPassivated_CloverLR[det][l] = + new G4LogicalVolume(solidPassivated_PhaseII, geMaterial, "passivatedGe", 0, 0, 0); // should be Ge + logicContact_CloverLR[det][l] = + new G4LogicalVolume(solidContact_PhaseII, contactMaterial, "inner_contact", 0, 0, 0); // should be Li + logicBoreHole_CloverLR[det][l] = new G4LogicalVolume(solidBoreHole_PhaseII, vacuumMaterial, "bore-hole", 0, 0, 0); } - - //rotation for each clover..... - rm.set(0,0,0); + // rotation for each clover..... + rm.set(0, 0, 0); phi = 180.0 * deg * det; rm.rotateY(theta); rm.rotateX(phi); rm.invert(); - - //traslate position: the centre of the DSSD has been placed @ Y = 0.0*mm - G4ThreeVector translation(-endCap_PosX*sin(theta)*cos(phi), - endCap_PosX*sin(theta)*sin(phi) + 0.0*mm, //fDSSD_PosY, - geSidePosition); - - G4cout << "Clover " << det << " x " << -endCap_PosX*sin(theta)*cos(phi) << G4endl; - - //Physical placement of these solids...... + + // traslate position: the centre of the DSSD has been placed @ Y = 0.0*mm + G4ThreeVector translation(-endCap_PosX * sin(theta) * cos(phi), + endCap_PosX * sin(theta) * sin(phi) + 0.0 * mm, // fDSSD_PosY, + geSidePosition); + + G4cout << "Clover " << det << " x " << -endCap_PosX * sin(theta) * cos(phi) << G4endl; + + // Physical placement of these solids...... PVPBuffer = new G4PVPlacement(G4Transform3D(rm, translation), - logicEndCap_CloverLR[det],//its logical volume - "Clover_EC", //its name - world, //its mother - true, //no boolean operat - det*4, //copy number - true); //overlap check - - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm,vacuum_PosZ), - logicVacuum_CloverLR[det], //its logical volume - "Clover_Vac", //its name - logicEndCap_CloverLR[det], //its mother - true, //no boolean operat - det*4, //copy number - true); //overlap check + logicEndCap_CloverLR[det], // its logical volume + "Clover_EC", // its name + world, // its mother + true, // no boolean operat + det * 4, // copy number + true); // overlap check + + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, vacuum_PosZ), + logicVacuum_CloverLR[det], // its logical volume + "Clover_Vac", // its name + logicEndCap_CloverLR[det], // its mother + true, // no boolean operat + det * 4, // copy number + true); // overlap check } - - //Now for the placement of the leaves in each clover...... + + // Now for the placement of the leaves in each clover...... G4RotationMatrix* rmC; G4double leafX; G4double leafY; - - - for(G4int l = 0; l < 4; l++) { - //the rotation + + for (G4int l = 0; l < 4; l++) { + // the rotation rmC = new G4RotationMatrix; - rmC->set(0,0,0); - rmC->rotateZ(90.*degree*(4-l)); + rmC->set(0, 0, 0); + rmC->rotateZ(90. * degree * (4 - l)); rmC->invert(); - //the x-translation - if(l < 2) { - leafX = 22.15*mm; - } else { - leafX = -22.15*mm; + // the x-translation + if (l < 2) { + leafX = 22.15 * mm; } - //the y-translation - if(l == 0 || l == 3 ) { - leafY = 22.15*mm; - } else { - leafY = -22.15*mm; + else { + leafX = -22.15 * mm; } - - - //for(G4int det = prevNumber; det < numberOfClovers; det++) { - for(G4int det = 0; det < 2; det++) { - //physiGeLeaf_CloverLR[det][l] = new G4PVPlacement(rmC, //rotation - PVPBuffer = new G4PVPlacement(rmC, //rotation - G4ThreeVector(leafX,leafY,geLeaf_PosZ), - logicGeLeaf_CloverLR[det][l], //its logical volume - "Clover",//detName[det].data(), //its name - logicVacuum_CloverLR[det], //its mother - true, //no boolean operat - det*4+l, //copy number - true); //overlap check - - //physiPassivated_CloverLR[det][l] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(-fHole_dX_PhaseII, -fHole_dY_PhaseII, fContact_dZ_PhaseII), - logicPassivated_CloverLR[det][l], - "GePassivated", - logicGeLeaf_CloverLR[det][l], - false,det*4+l,true); - - //physiContact_CloverLR[det][l] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm, 0.0*mm),//-fContact_dZ_PhaseII), - logicContact_CloverLR[det][l], - "LiContact", - logicPassivated_CloverLR[det][l], - false,det*4+l,true); - - //physiBoreHole_CloverLR[det][l] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm, 0.0*mm),//-fContact_dZ_PhaseII), - logicBoreHole_CloverLR[det][l], - "BoreHole", - logicContact_CloverLR[det][l], - false,det*4+l,true); - + // the y-translation + if (l == 0 || l == 3) { + leafY = 22.15 * mm; + } + else { + leafY = -22.15 * mm; + } + + // for(G4int det = prevNumber; det < numberOfClovers; det++) { + for (G4int det = 0; det < 2; det++) { + // physiGeLeaf_CloverLR[det][l] = new G4PVPlacement(rmC, //rotation + PVPBuffer = new G4PVPlacement(rmC, // rotation + G4ThreeVector(leafX, leafY, geLeaf_PosZ), + logicGeLeaf_CloverLR[det][l], // its logical volume + "Clover", // detName[det].data(), //its name + logicVacuum_CloverLR[det], // its mother + true, // no boolean operat + det * 4 + l, // copy number + true); // overlap check + + // physiPassivated_CloverLR[det][l] = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(-fHole_dX_PhaseII, -fHole_dY_PhaseII, fContact_dZ_PhaseII), + logicPassivated_CloverLR[det][l], "GePassivated", logicGeLeaf_CloverLR[det][l], + false, det * 4 + l, true); + + // physiContact_CloverLR[det][l] = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, 0.0 * mm), //-fContact_dZ_PhaseII), + logicContact_CloverLR[det][l], "LiContact", logicPassivated_CloverLR[det][l], false, + det * 4 + l, true); + + // physiBoreHole_CloverLR[det][l] = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, 0.0 * mm), //-fContact_dZ_PhaseII), + logicBoreHole_CloverLR[det][l], "BoreHole", logicContact_CloverLR[det][l], false, + det * 4 + l, true); } } - //define the visual attributes - G4VisAttributes* visAttAlCap = new G4VisAttributes( G4Colour(0.9,0.9,0.9) ); + // define the visual attributes + G4VisAttributes* visAttAlCap = new G4VisAttributes(G4Colour(0.9, 0.9, 0.9)); visAttAlCap->SetForceWireframe(true); visAttAlCap->SetVisibility(true); - //visAttAlCap->SetVisibility(false); - - G4VisAttributes* visAttGeVac = new G4VisAttributes( G4Colour(0.9,1.0,0.9) ); + // visAttAlCap->SetVisibility(false); + + G4VisAttributes* visAttGeVac = new G4VisAttributes(G4Colour(0.9, 1.0, 0.9)); visAttGeVac->SetForceWireframe(true); visAttGeVac->SetVisibility(true); - //visAttGeVac->SetVisibility(false); - - G4VisAttributes* visAttActive = new G4VisAttributes( G4Colour(1.0,1.0,0.0) ); + // visAttGeVac->SetVisibility(false); + + G4VisAttributes* visAttActive = new G4VisAttributes(G4Colour(1.0, 1.0, 0.0)); visAttActive->SetForceWireframe(true); visAttActive->SetVisibility(true); - //visAttActive->SetVisibility(false); - - G4VisAttributes* visAttPassive = new G4VisAttributes(G4Colour(0.0,1.0,1.0) ); + // visAttActive->SetVisibility(false); + + G4VisAttributes* visAttPassive = new G4VisAttributes(G4Colour(0.0, 1.0, 1.0)); visAttPassive->SetForceWireframe(true); visAttPassive->SetVisibility(true); - //visAttPassive->SetVisibility(false); - - G4VisAttributes* visAttLiContact = new G4VisAttributes(G4Colour(1.0,0.0,1.0) ); + // visAttPassive->SetVisibility(false); + + G4VisAttributes* visAttLiContact = new G4VisAttributes(G4Colour(1.0, 0.0, 1.0)); visAttLiContact->SetVisibility(true); - //visAttLiContact->SetVisibility(false); - - G4VisAttributes* visAttHole = new G4VisAttributes( G4Colour(0.0,0.0,1.0) ); + // visAttLiContact->SetVisibility(false); + + G4VisAttributes* visAttHole = new G4VisAttributes(G4Colour(0.0, 0.0, 1.0)); visAttHole->SetVisibility(true); - //visAttHole->SetVisibility(false); - - for(G4int det = 0; det < 2; det++) { + // visAttHole->SetVisibility(false); + + for (G4int det = 0; det < 2; det++) { logicEndCap_CloverLR[det]->SetVisAttributes(visAttAlCap); logicVacuum_CloverLR[det]->SetVisAttributes(visAttGeVac); - for(G4int l = 0; l < 4; l++) { + for (G4int l = 0; l < 4; l++) { logicGeLeaf_CloverLR[det][l]->SetVisAttributes(visAttActive); logicPassivated_CloverLR[det][l]->SetVisAttributes(visAttPassive); logicContact_CloverLR[det][l]->SetVisAttributes(visAttLiContact); @@ -2499,161 +2402,150 @@ void Chamber::Place_PhaseIIs_Left_and_Right(G4LogicalVolume* world) } } - //------------------------------------------------------------------ -void Chamber::Place_PhaseII_On_the_Top(G4LogicalVolume* world) -{ +void Chamber::Place_PhaseII_On_the_Top(G4LogicalVolume* world) { //================================================================================= - //Do not know why, but the positioning seems to be with respect to the Taper-part : - //setting the z-position as endCapTaperL/2 puts the front face at z = 0 mm + // Do not know why, but the positioning seems to be with respect to the Taper-part : + // setting the z-position as endCapTaperL/2 puts the front face at z = 0 mm //================================================================================= - G4double endCap_PosX; + G4double endCap_PosX; G4double vacuum_PosZ; G4double geLeaf_PosZ; - //reset scale - endCap_PosX = fChamberH/2. + fEndCapTaperL_PhaseII/2. + fGeTopGap; + // reset scale + endCap_PosX = fChamberH / 2. + fEndCapTaperL_PhaseII / 2. + fGeTopGap; vacuum_PosZ = fVacuumPosZ_PhaseII; geLeaf_PosZ = fGeLeafPosZ_PhaseII; - - - G4RotationMatrix rm ; + + G4RotationMatrix rm; G4double theta = 90. * deg; - G4double phi = 0. * deg; - - - logicEndCap_CloverT = new G4LogicalVolume(solidEndCap_PhaseII, endCapMaterial, "clover_EC", 0, 0, 0); - logicVacuum_CloverT = new G4LogicalVolume(solidVacuum_PhaseII, vacuumMaterial, "clover_Vac", 0, 0, 0); - - for(G4int l = 0; l < 4; l++) { - logicGeLeaf_CloverT[l] = new G4LogicalVolume(solidGeLeaf_PhaseII, geMaterial, "clover_Leaf", 0, 0, 0); - logicPassivated_CloverT[l] = new G4LogicalVolume(solidPassivated_PhaseII, geMaterial, "passivatedGe", 0, 0, 0); //should be Ge - logicContact_CloverT[l] = new G4LogicalVolume(solidContact_PhaseII, contactMaterial, "inner_contact", 0, 0, 0); //should be Li - logicBoreHole_CloverT[l] = new G4LogicalVolume(solidBoreHole_PhaseII, vacuumMaterial, "bore-hole", 0, 0, 0); + G4double phi = 0. * deg; + + logicEndCap_CloverT = new G4LogicalVolume(solidEndCap_PhaseII, endCapMaterial, "clover_EC", 0, 0, 0); + logicVacuum_CloverT = new G4LogicalVolume(solidVacuum_PhaseII, vacuumMaterial, "clover_Vac", 0, 0, 0); + + for (G4int l = 0; l < 4; l++) { + logicGeLeaf_CloverT[l] = new G4LogicalVolume(solidGeLeaf_PhaseII, geMaterial, "clover_Leaf", 0, 0, 0); + logicPassivated_CloverT[l] = + new G4LogicalVolume(solidPassivated_PhaseII, geMaterial, "passivatedGe", 0, 0, 0); // should be Ge + logicContact_CloverT[l] = + new G4LogicalVolume(solidContact_PhaseII, contactMaterial, "inner_contact", 0, 0, 0); // should be Li + logicBoreHole_CloverT[l] = new G4LogicalVolume(solidBoreHole_PhaseII, vacuumMaterial, "bore-hole", 0, 0, 0); } - //rotate - rm.set(0,0,0); + // rotate + rm.set(0, 0, 0); phi = 90.0 * deg; rm.rotateY(theta); rm.rotateX(phi); rm.invert(); - - //traslate position - G4ThreeVector translation(-endCap_PosX*sin(theta)*cos(phi), - endCap_PosX*sin(theta)*sin(phi), - geTopPosition); - - G4cout << "Top Clover " << " x " << -endCap_PosX*sin(theta)*cos(phi) << G4endl; - - //Physical placement of these solids...... - //physiEndCap_CloverT = new G4PVPlacement(G4Transform3D(rm, translation), + + // traslate position + G4ThreeVector translation(-endCap_PosX * sin(theta) * cos(phi), endCap_PosX * sin(theta) * sin(phi), geTopPosition); + + G4cout << "Top Clover " + << " x " << -endCap_PosX * sin(theta) * cos(phi) << G4endl; + + // Physical placement of these solids...... + // physiEndCap_CloverT = new G4PVPlacement(G4Transform3D(rm, translation), PVPBuffer = new G4PVPlacement(G4Transform3D(rm, translation), - logicEndCap_CloverT,//its logical volume - "Clover_EC", //its name - world, //its mother - true, //no boolean operat - 8, //copy number - true); //overlap check - - //physiVacuum_CloverT = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm,vacuum_PosZ), - logicVacuum_CloverT, //its logical volume - "Clover_Vac", //its name - logicEndCap_CloverT, //its mother - true, //no boolean operat - 8, //copy number - true); //overlap check - - //Now for the placement of the leaves in each clover...... + logicEndCap_CloverT, // its logical volume + "Clover_EC", // its name + world, // its mother + true, // no boolean operat + 8, // copy number + true); // overlap check + + // physiVacuum_CloverT = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, vacuum_PosZ), + logicVacuum_CloverT, // its logical volume + "Clover_Vac", // its name + logicEndCap_CloverT, // its mother + true, // no boolean operat + 8, // copy number + true); // overlap check + + // Now for the placement of the leaves in each clover...... G4RotationMatrix* rmC; G4double leafX; G4double leafY; - - for(G4int l = 0; l < 4; l++) { - //the rotation + + for (G4int l = 0; l < 4; l++) { + // the rotation rmC = new G4RotationMatrix; - rmC->set(0,0,0); - rmC->rotateZ(90.*degree*(4-l)); + rmC->set(0, 0, 0); + rmC->rotateZ(90. * degree * (4 - l)); rmC->invert(); - //the x-translation - if(l < 2) { - leafX = 22.15*mm; - } else { - leafX = -22.15*mm; + // the x-translation + if (l < 2) { + leafX = 22.15 * mm; + } + else { + leafX = -22.15 * mm; + } + // the y-translation + if (l == 0 || l == 3) { + leafY = 22.15 * mm; } - //the y-translation - if(l == 0 || l == 3 ) { - leafY = 22.15*mm; - } else { - leafY = -22.15*mm; + else { + leafY = -22.15 * mm; } - //the z-translation - - - //physiGeLeaf_CloverT[l] = new G4PVPlacement(rmC, //rotation - PVPBuffer = new G4PVPlacement(rmC, //rotation - G4ThreeVector(leafX,leafY,geLeaf_PosZ), - logicGeLeaf_CloverT[l], //its logical volume - "Clover", //its name - logicVacuum_CloverT, //its mother - true, //no boolean operat - 8+l, //copy number - true); //overlap check - - //physiPassivated_CloverT[l] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(-fHole_dX_PhaseII, -fHole_dY_PhaseII, fContact_dZ_PhaseII), - logicPassivated_CloverT[l], - "GePassivated", - logicGeLeaf_CloverT[l], - false,8+l,true); - - //physiContact_CloverT[l] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm, 0.0*mm),//-fContact_dZ_PhaseII), - logicContact_CloverT[l], - "LiContact", - logicPassivated_CloverT[l], - false,8+l,true); - - //physiBoreHole_CloverT[l] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm, 0.0*mm),//-fContact_dZ_PhaseII), - logicBoreHole_CloverT[l], - "BoreHole", - logicContact_CloverT[l], - false,8+l,true); - + // the z-translation + + // physiGeLeaf_CloverT[l] = new G4PVPlacement(rmC, //rotation + PVPBuffer = new G4PVPlacement(rmC, // rotation + G4ThreeVector(leafX, leafY, geLeaf_PosZ), + logicGeLeaf_CloverT[l], // its logical volume + "Clover", // its name + logicVacuum_CloverT, // its mother + true, // no boolean operat + 8 + l, // copy number + true); // overlap check + + // physiPassivated_CloverT[l] = new G4PVPlacement(0, //rotation + PVPBuffer = + new G4PVPlacement(0, // rotation + G4ThreeVector(-fHole_dX_PhaseII, -fHole_dY_PhaseII, fContact_dZ_PhaseII), + logicPassivated_CloverT[l], "GePassivated", logicGeLeaf_CloverT[l], false, 8 + l, true); + + // physiContact_CloverT[l] = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, 0.0 * mm), //-fContact_dZ_PhaseII), + logicContact_CloverT[l], "LiContact", logicPassivated_CloverT[l], false, 8 + l, true); + + // physiBoreHole_CloverT[l] = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, 0.0 * mm), //-fContact_dZ_PhaseII), + logicBoreHole_CloverT[l], "BoreHole", logicContact_CloverT[l], false, 8 + l, true); } - //define the visual attributes - G4VisAttributes* visAttAlCap = new G4VisAttributes( G4Colour(0.9,0.9,0.9) ); + // define the visual attributes + G4VisAttributes* visAttAlCap = new G4VisAttributes(G4Colour(0.9, 0.9, 0.9)); visAttAlCap->SetVisibility(true); visAttAlCap->SetForceWireframe(true); - - G4VisAttributes* visAttGeVac = new G4VisAttributes( G4Colour(0.9,1.0,0.9) ); + + G4VisAttributes* visAttGeVac = new G4VisAttributes(G4Colour(0.9, 1.0, 0.9)); visAttGeVac->SetForceWireframe(true); visAttGeVac->SetVisibility(true); - - G4VisAttributes* visAttActive = new G4VisAttributes( G4Colour(1.0,1.0,0.0) ); + + G4VisAttributes* visAttActive = new G4VisAttributes(G4Colour(1.0, 1.0, 0.0)); visAttActive->SetForceWireframe(true); visAttActive->SetVisibility(true); - - G4VisAttributes* visAttPassive = new G4VisAttributes(G4Colour(0.0,1.0,1.0) ); + + G4VisAttributes* visAttPassive = new G4VisAttributes(G4Colour(0.0, 1.0, 1.0)); visAttPassive->SetForceWireframe(true); visAttPassive->SetVisibility(true); - - G4VisAttributes* visAttLiContact = new G4VisAttributes(G4Colour(1.0,0.0,1.0) ); + + G4VisAttributes* visAttLiContact = new G4VisAttributes(G4Colour(1.0, 0.0, 1.0)); visAttLiContact->SetVisibility(true); - - G4VisAttributes* visAttHole = new G4VisAttributes( G4Colour(0.0,0.0,1.0) ); + + G4VisAttributes* visAttHole = new G4VisAttributes(G4Colour(0.0, 0.0, 1.0)); visAttHole->SetVisibility(true); - + logicEndCap_CloverT->SetVisAttributes(visAttAlCap); logicVacuum_CloverT->SetVisAttributes(visAttGeVac); - for(G4int l = 0; l < 4; l++) { + for (G4int l = 0; l < 4; l++) { logicGeLeaf_CloverT[l]->SetVisAttributes(visAttActive); logicPassivated_CloverT[l]->SetVisAttributes(visAttPassive); logicContact_CloverT[l]->SetVisAttributes(visAttLiContact); @@ -2661,165 +2553,153 @@ void Chamber::Place_PhaseII_On_the_Top(G4LogicalVolume* world) } } - //------------------------------------------------------------------ -void Chamber::Place_GREAT_On_the_Top(G4LogicalVolume* world) -{ +void Chamber::Place_GREAT_On_the_Top(G4LogicalVolume* world) { //================================================================================= // The positioning for boolean solids is odd : for this det it is with respect to the Taper-part : - //setting the z-position as endCapTaperL/2 puts the front face at z = 0 mm + // setting the z-position as endCapTaperL/2 puts the front face at z = 0 mm //================================================================================= - G4double endCap_PosX = fChamberH/2. - fShiftChamberY + fEndCapTaperL_GREAT/2. + fGeTopGap; + G4double endCap_PosX = fChamberH / 2. - fShiftChamberY + fEndCapTaperL_GREAT / 2. + fGeTopGap; G4double vacuum_PosZ = fVacuumPosZ_GREAT; G4double geLeaf_PosZ = fGeLeafPosZ_GREAT; - - - G4RotationMatrix rm ; + + G4RotationMatrix rm; G4double theta = 90. * deg; - G4double phi = 0. * deg; - - - logicEndCap_CloverT = new G4LogicalVolume(solidEndCap_GREAT, endCapMaterial, "clover_EC", 0, 0, 0); - logicVacuum_CloverT = new G4LogicalVolume(solidVacuum_GREAT, vacuumMaterial, "clover_Vac", 0, 0, 0); - - for(G4int l = 0; l < 4; l++) { - logicGeLeaf_CloverT[l] = new G4LogicalVolume(solidGeLeaf_GREAT, geMaterial, "clover_Leaf", 0, 0, 0); - logicPassivated_CloverT[l] = new G4LogicalVolume(solidPassivated_GREAT, geMaterial, "passivatedGe", 0, 0, 0); - logicContact_CloverT[l] = new G4LogicalVolume(solidContact_GREAT, contactMaterial, "inner_contact", 0, 0, 0); - logicBoreHole_CloverT[l] = new G4LogicalVolume(solidBoreHole_GREAT, vacuumMaterial, "bore_hole", 0, 0, 0); + G4double phi = 0. * deg; + + logicEndCap_CloverT = new G4LogicalVolume(solidEndCap_GREAT, endCapMaterial, "clover_EC", 0, 0, 0); + logicVacuum_CloverT = new G4LogicalVolume(solidVacuum_GREAT, vacuumMaterial, "clover_Vac", 0, 0, 0); + + for (G4int l = 0; l < 4; l++) { + logicGeLeaf_CloverT[l] = new G4LogicalVolume(solidGeLeaf_GREAT, geMaterial, "clover_Leaf", 0, 0, 0); + logicPassivated_CloverT[l] = new G4LogicalVolume(solidPassivated_GREAT, geMaterial, "passivatedGe", 0, 0, 0); + logicContact_CloverT[l] = new G4LogicalVolume(solidContact_GREAT, contactMaterial, "inner_contact", 0, 0, 0); + logicBoreHole_CloverT[l] = new G4LogicalVolume(solidBoreHole_GREAT, vacuumMaterial, "bore_hole", 0, 0, 0); } - //rotate - rm.set(0,0,0); + // rotate + rm.set(0, 0, 0); phi = 90.0 * deg; rm.rotateY(theta); rm.rotateX(phi); rm.invert(); - - //traslate position - G4ThreeVector translation(-endCap_PosX*sin(theta)*cos(phi), - endCap_PosX*sin(theta)*sin(phi), - geTopPosition +fCorrection); - - G4cout << "Top Clover " << " x " << -endCap_PosX*sin(theta)*cos(phi) << G4endl; - - //Physical placement of these solids...... - //physiEndCap_CloverT = new G4PVPlacement(G4Transform3D(rm, translation), + + // traslate position + G4ThreeVector translation(-endCap_PosX * sin(theta) * cos(phi), endCap_PosX * sin(theta) * sin(phi), + geTopPosition + fCorrection); + + G4cout << "Top Clover " + << " x " << -endCap_PosX * sin(theta) * cos(phi) << G4endl; + + // Physical placement of these solids...... + // physiEndCap_CloverT = new G4PVPlacement(G4Transform3D(rm, translation), PVPBuffer = new G4PVPlacement(G4Transform3D(rm, translation), - logicEndCap_CloverT,//its logical volume - "Clover_EC", //its name - world, //its mother - true, //no boolean operat - 8, //copy number - true); //overlap check - - //physiVacuum_CloverT = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm,vacuum_PosZ), - logicVacuum_CloverT, //its logical volume - "Clover_Vac", //its name - logicEndCap_CloverT, //its mother - true, //no boolean operat - 8, //copy number - true); //overlap check - - //Now for the placement of the leaves in each clover...... + logicEndCap_CloverT, // its logical volume + "Clover_EC", // its name + world, // its mother + true, // no boolean operat + 8, // copy number + true); // overlap check + + // physiVacuum_CloverT = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, vacuum_PosZ), + logicVacuum_CloverT, // its logical volume + "Clover_Vac", // its name + logicEndCap_CloverT, // its mother + true, // no boolean operat + 8, // copy number + true); // overlap check + + // Now for the placement of the leaves in each clover...... G4RotationMatrix* rmC; - G4double dPos = fGeLeaf_dX_GREAT + fGapBetweenLeaves_GREAT/2.; + G4double dPos = fGeLeaf_dX_GREAT + fGapBetweenLeaves_GREAT / 2.; G4double leafX; G4double leafY; G4double leafZ; - - for(G4int l = 0; l < 4; l++) { - //the rotation + + for (G4int l = 0; l < 4; l++) { + // the rotation rmC = new G4RotationMatrix; - rmC->set(0,0,0); - rmC->rotateZ(90.*degree*(4-l)); + rmC->set(0, 0, 0); + rmC->rotateZ(90. * degree * (4 - l)); rmC->invert(); - //the x-translation - if(l < 2) { + // the x-translation + if (l < 2) { leafX = dPos; - } else { + } + else { leafX = -dPos; } - //the y-translation - if(l == 0 || l == 3 ) { + // the y-translation + if (l == 0 || l == 3) { leafY = dPos; - } else { + } + else { leafY = -dPos; } - //the z-translation + // the z-translation leafZ = geLeaf_PosZ; - - - //physiGeLeaf_CloverT[l] = new G4PVPlacement(rmC, //rotation - PVPBuffer = new G4PVPlacement(rmC, //rotation - G4ThreeVector(leafX, leafY, leafZ), - logicGeLeaf_CloverT[l], //its logical volume - "Clover", //its name - logicVacuum_CloverT, //its mother - true, //no boolean operat - 8+l, //copy number - true); //overlap check - - //physiPassivated_CloverT[l] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(fHole_dX_GREAT, fHole_dY_GREAT, fContact_dZ_GREAT), - logicPassivated_CloverT[l], - "GePassivated", - logicGeLeaf_CloverT[l], - false,8+l,true); - - //physiContact_CloverT[l] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm, 0.0*mm),//-fContact_dZ_GREAT), - logicContact_CloverT[l], - "LiContact", - logicPassivated_CloverT[l], - false,8+l,true); - - //physiBoreHole_CloverT[l] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm, 0.0*mm), - logicBoreHole_CloverT[l], - "BoreHole", - logicContact_CloverT[l], - false,8+l,true); - + + // physiGeLeaf_CloverT[l] = new G4PVPlacement(rmC, //rotation + PVPBuffer = new G4PVPlacement(rmC, // rotation + G4ThreeVector(leafX, leafY, leafZ), + logicGeLeaf_CloverT[l], // its logical volume + "Clover", // its name + logicVacuum_CloverT, // its mother + true, // no boolean operat + 8 + l, // copy number + true); // overlap check + + // physiPassivated_CloverT[l] = new G4PVPlacement(0, //rotation + PVPBuffer = + new G4PVPlacement(0, // rotation + G4ThreeVector(fHole_dX_GREAT, fHole_dY_GREAT, fContact_dZ_GREAT), logicPassivated_CloverT[l], + "GePassivated", logicGeLeaf_CloverT[l], false, 8 + l, true); + + // physiContact_CloverT[l] = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, 0.0 * mm), //-fContact_dZ_GREAT), + logicContact_CloverT[l], "LiContact", logicPassivated_CloverT[l], false, 8 + l, true); + + // physiBoreHole_CloverT[l] = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, 0.0 * mm), logicBoreHole_CloverT[l], "BoreHole", + logicContact_CloverT[l], false, 8 + l, true); } - //define the visual attributes - G4VisAttributes* visAttAlCap = new G4VisAttributes( G4Colour(0.9,0.9,0.9) ); + // define the visual attributes + G4VisAttributes* visAttAlCap = new G4VisAttributes(G4Colour(0.9, 0.9, 0.9)); visAttAlCap->SetVisibility(true); - //visAttAlCap->SetVisibility(false); + // visAttAlCap->SetVisibility(false); visAttAlCap->SetForceWireframe(true); - - G4VisAttributes* visAttGeVac = new G4VisAttributes( G4Colour(0.9,1.0,0.9) ); + + G4VisAttributes* visAttGeVac = new G4VisAttributes(G4Colour(0.9, 1.0, 0.9)); visAttGeVac->SetVisibility(true); - //visAttGeVac->SetVisibility(false); + // visAttGeVac->SetVisibility(false); visAttGeVac->SetForceWireframe(true); - - G4VisAttributes* visAttActive = new G4VisAttributes( G4Colour(1.0,1.0,0.0) ); + + G4VisAttributes* visAttActive = new G4VisAttributes(G4Colour(1.0, 1.0, 0.0)); visAttActive->SetVisibility(true); - //visAttActive->SetVisibility(false); + // visAttActive->SetVisibility(false); visAttActive->SetForceWireframe(true); - - G4VisAttributes* visAttPassive = new G4VisAttributes(G4Colour(0.0,1.0,1.0) ); + + G4VisAttributes* visAttPassive = new G4VisAttributes(G4Colour(0.0, 1.0, 1.0)); visAttPassive->SetVisibility(true); - //visAttPassive->SetVisibility(false); + // visAttPassive->SetVisibility(false); visAttPassive->SetForceWireframe(true); - - G4VisAttributes* visAttLiContact = new G4VisAttributes(G4Colour(1.0,0.0,1.0) ); + + G4VisAttributes* visAttLiContact = new G4VisAttributes(G4Colour(1.0, 0.0, 1.0)); visAttLiContact->SetVisibility(true); - //visAttLiContact->SetVisibility(false); - - G4VisAttributes* visAttHole = new G4VisAttributes( G4Colour(0.0,0.0,1.0) ); + // visAttLiContact->SetVisibility(false); + + G4VisAttributes* visAttHole = new G4VisAttributes(G4Colour(0.0, 0.0, 1.0)); visAttHole->SetVisibility(true); - //visAttHole->SetVisibility(false); - + // visAttHole->SetVisibility(false); + logicEndCap_CloverT->SetVisAttributes(visAttAlCap); logicVacuum_CloverT->SetVisAttributes(visAttGeVac); - for(G4int l = 0; l < 4; l++) { + for (G4int l = 0; l < 4; l++) { logicGeLeaf_CloverT[l]->SetVisAttributes(visAttActive); logicPassivated_CloverT[l]->SetVisAttributes(visAttPassive); logicContact_CloverT[l]->SetVisAttributes(visAttLiContact); @@ -2828,169 +2708,161 @@ void Chamber::Place_GREAT_On_the_Top(G4LogicalVolume* world) } //------------------------------------------------------------------ -// Clover numbering scheme : +// Clover numbering scheme : // Left = 0 => Crystals 0, 1, 2, 3 // Right = 4 => Crystals 4, 5, 6, 7 // Top = 8 => Crystals 8, 9,10,11 // Upstream = 12 => Crystals 12,13,14,15 //------------------------------------------------------------------ //------------------------------------------------------------------ -void Chamber::Place_GREAT_Left_and_Right(G4LogicalVolume* world) -{ +void Chamber::Place_GREAT_Left_and_Right(G4LogicalVolume* world) { //================================================================================= // The positioning for boolean solids is odd : for this det it is with respect to the Taper-part : - //setting the z-position as endCapTaperL/2 puts the front face at z = 0 mm + // setting the z-position as endCapTaperL/2 puts the front face at z = 0 mm //================================================================================= - G4double endCap_PosX = fChamberW/2. + fEndCapTaperL_GREAT/2. + 3.0*mm; + G4double endCap_PosX = fChamberW / 2. + fEndCapTaperL_GREAT / 2. + 3.0 * mm; G4double vacuum_PosZ = fVacuumPosZ_GREAT; G4double geLeaf_PosZ = fGeLeafPosZ_GREAT; - - - G4RotationMatrix rm ; + + G4RotationMatrix rm; G4double theta = 90. * deg; - G4double phi = 0. * deg; - - - //for(G4int det = prevNumber; det < numberOfClovers; det++) { - for(G4int det = 0; det < 2; det++) { - logicEndCap_CloverLR[det] = new G4LogicalVolume(solidEndCap_GREAT, endCapMaterial, "clover_EC", 0, 0, 0); - logicVacuum_CloverLR[det] = new G4LogicalVolume(solidVacuum_GREAT, vacuumMaterial, "clover_Vac", 0, 0, 0); - - for(G4int l = 0; l < 4; l++) { - logicGeLeaf_CloverLR[det][l] = new G4LogicalVolume(solidGeLeaf_GREAT, geMaterial, "clover_Leaf", 0, 0, 0); - logicPassivated_CloverLR[det][l] = new G4LogicalVolume(solidPassivated_GREAT, geMaterial, "passivatedGe", 0, 0, 0); //should be Ge - logicContact_CloverLR[det][l] = new G4LogicalVolume(solidContact_GREAT, contactMaterial, "inner_contact", 0, 0, 0); //should be Li - logicBoreHole_CloverLR[det][l] = new G4LogicalVolume(solidBoreHole_GREAT, vacuumMaterial, "bore-hole", 0, 0, 0); + G4double phi = 0. * deg; + + // for(G4int det = prevNumber; det < numberOfClovers; det++) { + for (G4int det = 0; det < 2; det++) { + logicEndCap_CloverLR[det] = new G4LogicalVolume(solidEndCap_GREAT, endCapMaterial, "clover_EC", 0, 0, 0); + logicVacuum_CloverLR[det] = new G4LogicalVolume(solidVacuum_GREAT, vacuumMaterial, "clover_Vac", 0, 0, 0); + + for (G4int l = 0; l < 4; l++) { + logicGeLeaf_CloverLR[det][l] = new G4LogicalVolume(solidGeLeaf_GREAT, geMaterial, "clover_Leaf", 0, 0, 0); + logicPassivated_CloverLR[det][l] = + new G4LogicalVolume(solidPassivated_GREAT, geMaterial, "passivatedGe", 0, 0, 0); // should be Ge + logicContact_CloverLR[det][l] = + new G4LogicalVolume(solidContact_GREAT, contactMaterial, "inner_contact", 0, 0, 0); // should be Li + logicBoreHole_CloverLR[det][l] = new G4LogicalVolume(solidBoreHole_GREAT, vacuumMaterial, "bore-hole", 0, 0, 0); } - - //rotation for each clover..... - rm.set(0,0,0); + // rotation for each clover..... + rm.set(0, 0, 0); phi = 180.0 * deg * det; rm.rotateY(theta); rm.rotateX(phi); rm.invert(); - - //traslate position: the centre of the DSSD has been placed @ Y = 0.0*mm - G4ThreeVector translation(-endCap_PosX*sin(theta)*cos(phi), - endCap_PosX*sin(theta)*sin(phi) + 0.0*mm, //fDSSD_PosY, - 0.0*mm); - - G4cout << "Clover " << det << " x " << -endCap_PosX*sin(theta)*cos(phi) << G4endl; - - //Physical placement of these solids...... - //physiEndCap_CloverLR[det] = new G4PVPlacement(G4Transform3D(rm, translation), + + // traslate position: the centre of the DSSD has been placed @ Y = 0.0*mm + G4ThreeVector translation(-endCap_PosX * sin(theta) * cos(phi), + endCap_PosX * sin(theta) * sin(phi) + 0.0 * mm, // fDSSD_PosY, + 0.0 * mm); + + G4cout << "Clover " << det << " x " << -endCap_PosX * sin(theta) * cos(phi) << G4endl; + + // Physical placement of these solids...... + // physiEndCap_CloverLR[det] = new G4PVPlacement(G4Transform3D(rm, translation), PVPBuffer = new G4PVPlacement(G4Transform3D(rm, translation), - logicEndCap_CloverLR[det],//its logical volume - "Clover_EC", //its name - world, //its mother - true, //no boolean operat - det*4, //copy number - true); //overlap check - - //physiVacuum_CloverLR[det] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm,vacuum_PosZ), - logicVacuum_CloverLR[det], //its logical volume - "Clover_Vac", //its name - logicEndCap_CloverLR[det], //its mother - true, //no boolean operat - det*4, //copy number - true); //overlap check + logicEndCap_CloverLR[det], // its logical volume + "Clover_EC", // its name + world, // its mother + true, // no boolean operat + det * 4, // copy number + true); // overlap check + + // physiVacuum_CloverLR[det] = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, vacuum_PosZ), + logicVacuum_CloverLR[det], // its logical volume + "Clover_Vac", // its name + logicEndCap_CloverLR[det], // its mother + true, // no boolean operat + det * 4, // copy number + true); // overlap check } - - //Now for the placement of the leaves in each clover...... + + // Now for the placement of the leaves in each clover...... G4RotationMatrix* rmC; - G4double dPos = fGeLeaf_dX_GREAT + fGapBetweenLeaves_GREAT/2.; + G4double dPos = fGeLeaf_dX_GREAT + fGapBetweenLeaves_GREAT / 2.; G4double leafX; G4double leafY; - - for(G4int l = 0; l < 4; l++) { - //the rotation + + for (G4int l = 0; l < 4; l++) { + // the rotation rmC = new G4RotationMatrix; - rmC->set(0,0,0); - rmC->rotateZ(90.*degree*(4-l)); + rmC->set(0, 0, 0); + rmC->rotateZ(90. * degree * (4 - l)); rmC->invert(); - //the x-translation - if(l < 2) { + // the x-translation + if (l < 2) { leafX = dPos; - } else { + } + else { leafX = -dPos; } - //the y-translation - if(l == 0 || l == 3 ) { + // the y-translation + if (l == 0 || l == 3) { leafY = dPos; - } else { + } + else { leafY = -dPos; } - - - //for(G4int det = prevNumber; det < numberOfClovers; det++) { - for(G4int det = 0; det < 2; det++) { - //physiGeLeaf_CloverLR[det][l] = new G4PVPlacement(rmC, //rotation - PVPBuffer = new G4PVPlacement(rmC, //rotation - G4ThreeVector(leafX,leafY,geLeaf_PosZ), - logicGeLeaf_CloverLR[det][l], //its logical volume - "Clover",//detName[det].data(), //its name - logicVacuum_CloverLR[det], //its mother - true, //no boolean operat - det*4+l, //copy number - true); //overlap check - - //physiPassivated_CloverLR[det][l] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(-fHole_dX_PhaseII, -fHole_dY_PhaseII, fContact_dZ_GREAT), - logicPassivated_CloverLR[det][l], - "GePassivated", - logicGeLeaf_CloverLR[det][l], - false,det*4+l,true); - - //physiContact_CloverLR[det][l] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm, 0.0*mm),//-fContact_dZ_GREAT), - logicContact_CloverLR[det][l], - "LiContact", - logicPassivated_CloverLR[det][l], - false,det*4+l,true); - - //physiBoreHole_CloverLR[det][l] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm, 0.0*mm),//-fContact_dZ_GREAT), - logicBoreHole_CloverLR[det][l], - "BoreHole", - logicContact_CloverLR[det][l], - false,det*4+l,true); - + + // for(G4int det = prevNumber; det < numberOfClovers; det++) { + for (G4int det = 0; det < 2; det++) { + // physiGeLeaf_CloverLR[det][l] = new G4PVPlacement(rmC, //rotation + PVPBuffer = new G4PVPlacement(rmC, // rotation + G4ThreeVector(leafX, leafY, geLeaf_PosZ), + logicGeLeaf_CloverLR[det][l], // its logical volume + "Clover", // detName[det].data(), //its name + logicVacuum_CloverLR[det], // its mother + true, // no boolean operat + det * 4 + l, // copy number + true); // overlap check + + // physiPassivated_CloverLR[det][l] = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(-fHole_dX_PhaseII, -fHole_dY_PhaseII, fContact_dZ_GREAT), + logicPassivated_CloverLR[det][l], "GePassivated", logicGeLeaf_CloverLR[det][l], + false, det * 4 + l, true); + + // physiContact_CloverLR[det][l] = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, 0.0 * mm), //-fContact_dZ_GREAT), + logicContact_CloverLR[det][l], "LiContact", logicPassivated_CloverLR[det][l], false, + det * 4 + l, true); + + // physiBoreHole_CloverLR[det][l] = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, 0.0 * mm), //-fContact_dZ_GREAT), + logicBoreHole_CloverLR[det][l], "BoreHole", logicContact_CloverLR[det][l], false, + det * 4 + l, true); } } - //define the visual attributes - G4VisAttributes* visAttAlCap = new G4VisAttributes( G4Colour(0.9,0.9,0.9) ); + // define the visual attributes + G4VisAttributes* visAttAlCap = new G4VisAttributes(G4Colour(0.9, 0.9, 0.9)); visAttAlCap->SetVisibility(true); visAttAlCap->SetForceWireframe(true); - - G4VisAttributes* visAttGeVac = new G4VisAttributes( G4Colour(0.9,1.0,0.9) ); + + G4VisAttributes* visAttGeVac = new G4VisAttributes(G4Colour(0.9, 1.0, 0.9)); visAttGeVac->SetForceWireframe(true); visAttGeVac->SetVisibility(true); - - G4VisAttributes* visAttActive = new G4VisAttributes( G4Colour(1.0,1.0,0.0) ); + + G4VisAttributes* visAttActive = new G4VisAttributes(G4Colour(1.0, 1.0, 0.0)); visAttActive->SetForceWireframe(true); visAttActive->SetVisibility(true); - - G4VisAttributes* visAttPassive = new G4VisAttributes(G4Colour(0.0,1.0,1.0) ); + + G4VisAttributes* visAttPassive = new G4VisAttributes(G4Colour(0.0, 1.0, 1.0)); visAttPassive->SetForceWireframe(true); visAttPassive->SetVisibility(true); - - G4VisAttributes* visAttLiContact = new G4VisAttributes(G4Colour(1.0,0.0,1.0) ); + + G4VisAttributes* visAttLiContact = new G4VisAttributes(G4Colour(1.0, 0.0, 1.0)); visAttLiContact->SetVisibility(true); - - G4VisAttributes* visAttHole = new G4VisAttributes( G4Colour(0.0,0.0,1.0) ); + + G4VisAttributes* visAttHole = new G4VisAttributes(G4Colour(0.0, 0.0, 1.0)); visAttHole->SetVisibility(true); - - for(G4int det = 0; det < 2; det++) { + + for (G4int det = 0; det < 2; det++) { logicEndCap_CloverLR[det]->SetVisAttributes(visAttAlCap); logicVacuum_CloverLR[det]->SetVisAttributes(visAttGeVac); - for(G4int l = 0; l < 4; l++) { + for (G4int l = 0; l < 4; l++) { logicGeLeaf_CloverLR[det][l]->SetVisAttributes(visAttActive); logicPassivated_CloverLR[det][l]->SetVisAttributes(visAttPassive); logicContact_CloverLR[det][l]->SetVisAttributes(visAttLiContact); @@ -2999,142 +2871,132 @@ void Chamber::Place_GREAT_Left_and_Right(G4LogicalVolume* world) } } - - //------------------------------------------------------------------ -void Chamber::Place_PhaseII_LookingUpstream(G4LogicalVolume* world) -{ +void Chamber::Place_PhaseII_LookingUpstream(G4LogicalVolume* world) { //================================================================================= // The positioning for boolean solids is odd : for this det it is with respect to the Taper-part : - //setting the z-position as endCapTaperL/2 puts the front face at z = 0 mm + // setting the z-position as endCapTaperL/2 puts the front face at z = 0 mm //================================================================================= - G4double endCap_PosZ = fEndCapTaperL_PhaseII/2. + 3.0*mm; + G4double endCap_PosZ = fEndCapTaperL_PhaseII / 2. + 3.0 * mm; G4double vacuum_PosZ = fVacuumPosZ_PhaseII; G4double geLeaf_PosZ = fGeLeafPosZ_PhaseII; - - logicEndCap_CloverU = new G4LogicalVolume(solidEndCap_PhaseII, endCapMaterial, "clover_EC", 0, 0, 0); - logicVacuum_CloverU = new G4LogicalVolume(solidVacuum_PhaseII, vacuumMaterial, "clover_Vac", 0, 0, 0); - - for(G4int l = 0; l < 4; l++) { - logicGeLeaf_CloverU[l] = new G4LogicalVolume(solidGeLeaf_PhaseII, geMaterial, "clover_Leaf", 0, 0, 0); - logicPassivated_CloverU[l] = new G4LogicalVolume(solidPassivated_PhaseII, geMaterial, "passivatedGe", 0, 0, 0); - logicContact_CloverU[l] = new G4LogicalVolume(solidContact_PhaseII, contactMaterial, "inner_contact", 0, 0, 0); - logicBoreHole_CloverU[l] = new G4LogicalVolume(solidBoreHole_PhaseII, vacuumMaterial, "bore_hole", 0, 0, 0); + + logicEndCap_CloverU = new G4LogicalVolume(solidEndCap_PhaseII, endCapMaterial, "clover_EC", 0, 0, 0); + logicVacuum_CloverU = new G4LogicalVolume(solidVacuum_PhaseII, vacuumMaterial, "clover_Vac", 0, 0, 0); + + for (G4int l = 0; l < 4; l++) { + logicGeLeaf_CloverU[l] = new G4LogicalVolume(solidGeLeaf_PhaseII, geMaterial, "clover_Leaf", 0, 0, 0); + logicPassivated_CloverU[l] = new G4LogicalVolume(solidPassivated_PhaseII, geMaterial, "passivatedGe", 0, 0, 0); + logicContact_CloverU[l] = new G4LogicalVolume(solidContact_PhaseII, contactMaterial, "inner_contact", 0, 0, 0); + logicBoreHole_CloverU[l] = new G4LogicalVolume(solidBoreHole_PhaseII, vacuumMaterial, "bore_hole", 0, 0, 0); } - //Physical placement of these solids...... - //traslate position: the centre of the DSSD has been placed @ Y = 0.0*mm - //physiEndCap_CloverU = new G4PVPlacement(0, //no rotation - PVPBuffer = new G4PVPlacement(0, //no rotation - G4ThreeVector(0.*mm, 0.0*mm, endCap_PosZ), - logicEndCap_CloverU,//its logical volume - "Clover_EC", //its name - world, //its mother - true, //no boolean operat - 12, //copy number - true); //overlap check - - //physiVacuum_CloverU = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm,vacuum_PosZ), - logicVacuum_CloverU, //its logical volume - "Clover_Vac", //its name - logicEndCap_CloverU, //its mother - true, //no boolean operat - 12, //copy number - true); //overlap check - - //Now for the placement of the leaves in each clover...... + // Physical placement of these solids...... + // traslate position: the centre of the DSSD has been placed @ Y = 0.0*mm + // physiEndCap_CloverU = new G4PVPlacement(0, //no rotation + PVPBuffer = new G4PVPlacement(0, // no rotation + G4ThreeVector(0. * mm, 0.0 * mm, endCap_PosZ), + logicEndCap_CloverU, // its logical volume + "Clover_EC", // its name + world, // its mother + true, // no boolean operat + 12, // copy number + true); // overlap check + + // physiVacuum_CloverU = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, vacuum_PosZ), + logicVacuum_CloverU, // its logical volume + "Clover_Vac", // its name + logicEndCap_CloverU, // its mother + true, // no boolean operat + 12, // copy number + true); // overlap check + + // Now for the placement of the leaves in each clover...... G4RotationMatrix* rmC; - G4double dPos = fGeLeaf_dX_PhaseII + fGapBetweenLeaves_PhaseII/2.; + G4double dPos = fGeLeaf_dX_PhaseII + fGapBetweenLeaves_PhaseII / 2.; G4double leafX; G4double leafY; G4double leafZ; - - for(G4int l = 0; l < 4; l++) { - //the rotation + + for (G4int l = 0; l < 4; l++) { + // the rotation rmC = new G4RotationMatrix; - rmC->set(0,0,0); - rmC->rotateZ(90.*degree*(4-l)); + rmC->set(0, 0, 0); + rmC->rotateZ(90. * degree * (4 - l)); rmC->invert(); - //the x-translation - if(l < 2) { + // the x-translation + if (l < 2) { leafX = dPos; - } else { + } + else { leafX = -dPos; } - //the y-translation - if(l == 0 || l == 3 ) { + // the y-translation + if (l == 0 || l == 3) { leafY = dPos; - } else { + } + else { leafY = -dPos; } - //the z-translation + // the z-translation leafZ = geLeaf_PosZ; - - - //physiGeLeaf_CloverU[l] = new G4PVPlacement(rmC, //rotation - PVPBuffer = new G4PVPlacement(rmC, //rotation - G4ThreeVector(leafX, leafY, leafZ), - logicGeLeaf_CloverU[l], //its logical volume - "Clover", //its name - logicVacuum_CloverU, //its mother - true, //no boolean operat - 12+l, //copy number - true); //overlap check - - //physiPassivated_CloverU[l] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(-fHole_dX_PhaseII, -fHole_dY_PhaseII, fContact_dZ_PhaseII), - logicPassivated_CloverU[l], - "GePassivated", - logicGeLeaf_CloverU[l], - false,12+l,true); - - //physiContact_CloverU[l] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm, 0.0*mm),//-fContact_dZ_GREAT), - logicContact_CloverU[l], - "LiContact", - logicPassivated_CloverU[l], - false,12+l,true); - - //physiBoreHole_CloverU[l] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm, 0.0*mm), - logicBoreHole_CloverU[l], - "BoreHole", - logicContact_CloverU[l], - false,12+l,true); - + + // physiGeLeaf_CloverU[l] = new G4PVPlacement(rmC, //rotation + PVPBuffer = new G4PVPlacement(rmC, // rotation + G4ThreeVector(leafX, leafY, leafZ), + logicGeLeaf_CloverU[l], // its logical volume + "Clover", // its name + logicVacuum_CloverU, // its mother + true, // no boolean operat + 12 + l, // copy number + true); // overlap check + + // physiPassivated_CloverU[l] = new G4PVPlacement(0, //rotation + PVPBuffer = + new G4PVPlacement(0, // rotation + G4ThreeVector(-fHole_dX_PhaseII, -fHole_dY_PhaseII, fContact_dZ_PhaseII), + logicPassivated_CloverU[l], "GePassivated", logicGeLeaf_CloverU[l], false, 12 + l, true); + + // physiContact_CloverU[l] = new G4PVPlacement(0, //rotation + PVPBuffer = + new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, 0.0 * mm), //-fContact_dZ_GREAT), + logicContact_CloverU[l], "LiContact", logicPassivated_CloverU[l], false, 12 + l, true); + + // physiBoreHole_CloverU[l] = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, 0.0 * mm), logicBoreHole_CloverU[l], "BoreHole", + logicContact_CloverU[l], false, 12 + l, true); } - //define the visual attributes - G4VisAttributes* visAttAlCap = new G4VisAttributes( G4Colour(0.9,0.9,0.9) ); + // define the visual attributes + G4VisAttributes* visAttAlCap = new G4VisAttributes(G4Colour(0.9, 0.9, 0.9)); visAttAlCap->SetVisibility(true); visAttAlCap->SetForceWireframe(true); - - G4VisAttributes* visAttGeVac = new G4VisAttributes( G4Colour(0.9,1.0,0.9) ); + + G4VisAttributes* visAttGeVac = new G4VisAttributes(G4Colour(0.9, 1.0, 0.9)); visAttGeVac->SetForceWireframe(true); visAttGeVac->SetVisibility(true); - - G4VisAttributes* visAttActive = new G4VisAttributes( G4Colour(1.0,1.0,0.0) ); + + G4VisAttributes* visAttActive = new G4VisAttributes(G4Colour(1.0, 1.0, 0.0)); visAttActive->SetForceWireframe(true); visAttActive->SetVisibility(true); - - G4VisAttributes* visAttPassive = new G4VisAttributes(G4Colour(0.0,1.0,1.0) ); + + G4VisAttributes* visAttPassive = new G4VisAttributes(G4Colour(0.0, 1.0, 1.0)); visAttPassive->SetForceWireframe(true); visAttPassive->SetVisibility(true); - - G4VisAttributes* visAttLiContact = new G4VisAttributes(G4Colour(1.0,0.0,1.0) ); + + G4VisAttributes* visAttLiContact = new G4VisAttributes(G4Colour(1.0, 0.0, 1.0)); visAttLiContact->SetVisibility(true); - - G4VisAttributes* visAttHole = new G4VisAttributes( G4Colour(0.0,0.0,1.0) ); + + G4VisAttributes* visAttHole = new G4VisAttributes(G4Colour(0.0, 0.0, 1.0)); visAttHole->SetVisibility(true); - + logicEndCap_CloverU->SetVisAttributes(visAttAlCap); logicVacuum_CloverU->SetVisAttributes(visAttGeVac); - for(G4int l = 0; l < 4; l++) { + for (G4int l = 0; l < 4; l++) { logicGeLeaf_CloverU[l]->SetVisAttributes(visAttActive); logicPassivated_CloverU[l]->SetVisAttributes(visAttPassive); logicContact_CloverU[l]->SetVisAttributes(visAttLiContact); @@ -3145,139 +3007,131 @@ void Chamber::Place_PhaseII_LookingUpstream(G4LogicalVolume* world) //------------------------------------------------------------------ // This is just as a comparison with the current position //------------------------------------------------------------------ -void Chamber::Place_GREAT_LookingUpstream(G4LogicalVolume* world) -{ +void Chamber::Place_GREAT_LookingUpstream(G4LogicalVolume* world) { //================================================================================= // The positioning for boolean solids is odd : for this det it is with respect to the Taper-part : - //setting the z-position as endCapTaperL/2 puts the front face at z = 0 mm + // setting the z-position as endCapTaperL/2 puts the front face at z = 0 mm //================================================================================= - G4double endCap_PosZ = fEndCapTaperL_GREAT/2. + 3.0*mm; + G4double endCap_PosZ = fEndCapTaperL_GREAT / 2. + 3.0 * mm; G4double vacuum_PosZ = fVacuumPosZ_GREAT; G4double geLeaf_PosZ = fGeLeafPosZ_GREAT; - - logicEndCap_CloverU = new G4LogicalVolume(solidEndCap_GREAT, endCapMaterial, "clover_EC", 0, 0, 0); - logicVacuum_CloverU = new G4LogicalVolume(solidVacuum_GREAT, vacuumMaterial, "clover_Vac", 0, 0, 0); - - for(G4int l = 0; l < 4; l++) { - logicGeLeaf_CloverU[l] = new G4LogicalVolume(solidGeLeaf_GREAT, geMaterial, "clover_Leaf", 0, 0, 0); - logicPassivated_CloverU[l] = new G4LogicalVolume(solidPassivated_GREAT, geMaterial, "passivatedGe", 0, 0, 0); - logicContact_CloverU[l] = new G4LogicalVolume(solidContact_GREAT, contactMaterial, "inner_contact", 0, 0, 0); - logicBoreHole_CloverU[l] = new G4LogicalVolume(solidBoreHole_GREAT, vacuumMaterial, "bore_hole", 0, 0, 0); + + logicEndCap_CloverU = new G4LogicalVolume(solidEndCap_GREAT, endCapMaterial, "clover_EC", 0, 0, 0); + logicVacuum_CloverU = new G4LogicalVolume(solidVacuum_GREAT, vacuumMaterial, "clover_Vac", 0, 0, 0); + + for (G4int l = 0; l < 4; l++) { + logicGeLeaf_CloverU[l] = new G4LogicalVolume(solidGeLeaf_GREAT, geMaterial, "clover_Leaf", 0, 0, 0); + logicPassivated_CloverU[l] = new G4LogicalVolume(solidPassivated_GREAT, geMaterial, "passivatedGe", 0, 0, 0); + logicContact_CloverU[l] = new G4LogicalVolume(solidContact_GREAT, contactMaterial, "inner_contact", 0, 0, 0); + logicBoreHole_CloverU[l] = new G4LogicalVolume(solidBoreHole_GREAT, vacuumMaterial, "bore_hole", 0, 0, 0); } - //Physical placement of these solids...... - //traslate position: the centre of the DSSD has been placed @ Y = 0.0*mm - //physiEndCap_CloverU = new G4PVPlacement(0, //no rotation - PVPBuffer = new G4PVPlacement(0, //no rotation - G4ThreeVector(0.*mm, 0.0*mm, endCap_PosZ), - logicEndCap_CloverU,//its logical volume - "Clover_EC", //its name - world, //its mother - true, //no boolean operat - 12, //copy number - true); //overlap check - - //physiVacuum_CloverU = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm,vacuum_PosZ), - logicVacuum_CloverU, //its logical volume - "Clover_Vac", //its name - logicEndCap_CloverU, //its mother - true, //no boolean operat - 12, //copy number - true); //overlap check - - //Now for the placement of the leaves in each clover...... + // Physical placement of these solids...... + // traslate position: the centre of the DSSD has been placed @ Y = 0.0*mm + // physiEndCap_CloverU = new G4PVPlacement(0, //no rotation + PVPBuffer = new G4PVPlacement(0, // no rotation + G4ThreeVector(0. * mm, 0.0 * mm, endCap_PosZ), + logicEndCap_CloverU, // its logical volume + "Clover_EC", // its name + world, // its mother + true, // no boolean operat + 12, // copy number + true); // overlap check + + // physiVacuum_CloverU = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, vacuum_PosZ), + logicVacuum_CloverU, // its logical volume + "Clover_Vac", // its name + logicEndCap_CloverU, // its mother + true, // no boolean operat + 12, // copy number + true); // overlap check + + // Now for the placement of the leaves in each clover...... G4RotationMatrix* rmC; - G4double dPos = fGeLeaf_dX_GREAT + fGapBetweenLeaves_GREAT/2.; + G4double dPos = fGeLeaf_dX_GREAT + fGapBetweenLeaves_GREAT / 2.; G4double leafX; G4double leafY; G4double leafZ; - - for(G4int l = 0; l < 4; l++) { - //the rotation + + for (G4int l = 0; l < 4; l++) { + // the rotation rmC = new G4RotationMatrix; - rmC->set(0,0,0); - rmC->rotateZ(90.*degree*(4-l)); + rmC->set(0, 0, 0); + rmC->rotateZ(90. * degree * (4 - l)); rmC->invert(); - //the x-translation - if(l < 2) { + // the x-translation + if (l < 2) { leafX = dPos; - } else { + } + else { leafX = -dPos; } - //the y-translation - if(l == 0 || l == 3 ) { + // the y-translation + if (l == 0 || l == 3) { leafY = dPos; - } else { + } + else { leafY = -dPos; } - //the z-translation + // the z-translation leafZ = geLeaf_PosZ; - - - //physiGeLeaf_CloverU[l] = new G4PVPlacement(rmC, //rotation - PVPBuffer = new G4PVPlacement(rmC, //rotation - G4ThreeVector(leafX, leafY, leafZ), - logicGeLeaf_CloverU[l], //its logical volume - "Clover", //its name - logicVacuum_CloverU, //its mother - true, //no boolean operat - 12+l, //copy number - true); //overlap check - - //physiPassivated_CloverU[l] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(fHole_dX_GREAT, fHole_dY_GREAT, fContact_dZ_GREAT), - logicPassivated_CloverU[l], - "GePassivated", - logicGeLeaf_CloverU[l], - false,12+l,true); - - //physiContact_CloverU[l] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm, 0.0*mm),//-fContact_dZ_GREAT), - logicContact_CloverU[l], - "LiContact", - logicPassivated_CloverU[l], - false,12+l,true); - - //physiBoreHole_CloverU[l] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm, 0.0*mm), - logicBoreHole_CloverU[l], - "BoreHole", - logicContact_CloverU[l], - false,12+l,true); - + + // physiGeLeaf_CloverU[l] = new G4PVPlacement(rmC, //rotation + PVPBuffer = new G4PVPlacement(rmC, // rotation + G4ThreeVector(leafX, leafY, leafZ), + logicGeLeaf_CloverU[l], // its logical volume + "Clover", // its name + logicVacuum_CloverU, // its mother + true, // no boolean operat + 12 + l, // copy number + true); // overlap check + + // physiPassivated_CloverU[l] = new G4PVPlacement(0, //rotation + PVPBuffer = + new G4PVPlacement(0, // rotation + G4ThreeVector(fHole_dX_GREAT, fHole_dY_GREAT, fContact_dZ_GREAT), logicPassivated_CloverU[l], + "GePassivated", logicGeLeaf_CloverU[l], false, 12 + l, true); + + // physiContact_CloverU[l] = new G4PVPlacement(0, //rotation + PVPBuffer = + new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, 0.0 * mm), //-fContact_dZ_GREAT), + logicContact_CloverU[l], "LiContact", logicPassivated_CloverU[l], false, 12 + l, true); + + // physiBoreHole_CloverU[l] = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, 0.0 * mm), logicBoreHole_CloverU[l], "BoreHole", + logicContact_CloverU[l], false, 12 + l, true); } - //define the visual attributes - G4VisAttributes* visAttAlCap = new G4VisAttributes( G4Colour(0.9,0.9,0.9) ); + // define the visual attributes + G4VisAttributes* visAttAlCap = new G4VisAttributes(G4Colour(0.9, 0.9, 0.9)); visAttAlCap->SetVisibility(true); visAttAlCap->SetForceWireframe(true); - - G4VisAttributes* visAttGeVac = new G4VisAttributes( G4Colour(0.9,1.0,0.9) ); + + G4VisAttributes* visAttGeVac = new G4VisAttributes(G4Colour(0.9, 1.0, 0.9)); visAttGeVac->SetForceWireframe(true); visAttGeVac->SetVisibility(true); - - G4VisAttributes* visAttActive = new G4VisAttributes( G4Colour(1.0,1.0,0.0) ); + + G4VisAttributes* visAttActive = new G4VisAttributes(G4Colour(1.0, 1.0, 0.0)); visAttActive->SetForceWireframe(true); visAttActive->SetVisibility(true); - - G4VisAttributes* visAttPassive = new G4VisAttributes(G4Colour(0.0,1.0,1.0) ); + + G4VisAttributes* visAttPassive = new G4VisAttributes(G4Colour(0.0, 1.0, 1.0)); visAttPassive->SetForceWireframe(true); visAttPassive->SetVisibility(true); - - G4VisAttributes* visAttLiContact = new G4VisAttributes(G4Colour(1.0,0.0,1.0) ); + + G4VisAttributes* visAttLiContact = new G4VisAttributes(G4Colour(1.0, 0.0, 1.0)); visAttLiContact->SetVisibility(true); - - G4VisAttributes* visAttHole = new G4VisAttributes( G4Colour(0.0,0.0,1.0) ); + + G4VisAttributes* visAttHole = new G4VisAttributes(G4Colour(0.0, 0.0, 1.0)); visAttHole->SetVisibility(true); - + logicEndCap_CloverU->SetVisAttributes(visAttAlCap); logicVacuum_CloverU->SetVisAttributes(visAttGeVac); - for(G4int l = 0; l < 4; l++) { + for (G4int l = 0; l < 4; l++) { logicGeLeaf_CloverU[l]->SetVisAttributes(visAttActive); logicPassivated_CloverU[l]->SetVisAttributes(visAttPassive); logicContact_CloverU[l]->SetVisAttributes(visAttLiContact); @@ -3288,325 +3142,318 @@ void Chamber::Place_GREAT_LookingUpstream(G4LogicalVolume* world) //--------------------------------------------------------------------- // Create the solids defining Phase-II Clovers //--------------------------------------------------------------------- -void Chamber::CreateCloverIISolids() -{ - //An approximate CloverII +void Chamber::CreateCloverIISolids() { + // An approximate CloverII G4cout << G4endl << "Constructing archetypal PhaseII Clover" << G4endl; - + //--------------------------------------------------------- - //end-cap - G4double endCapFrontThickness = 1.2*mm; //was 1.5 - G4double endCapTaperThickness = 1.5*mm; - G4double endCapSideThickness = 1.5*mm; - - G4double GeGap = fEndCap2Ge_PhaseII; - G4double taperAngle = 7.0*degree; - - G4double endCapTotalL = fTotalGeL_PhaseII + GeGap + endCapFrontThickness + 5.*mm; //+ Gap at rear end - G4double endCapFrontD = 43.5*mm; - G4double endCapBackD = 50.5*mm; - G4double endCapTaperL = 55.0*mm; - - G4double endCapBoxL = endCapTotalL - endCapTaperL; - - //the tapered part - G4Trap* solidTaperedCloverEC - = new G4Trap("taperedCloverEC", - endCapTaperL/2., //Half z-length [pDz] - 0.00*degree, //Polar angle of line joining centres of the faces @ -/+pDz - 14.0*degree, //aequivalent zimuthal angle - endCapFrontD, //pDy1 half y length at -pDz - endCapFrontD, //pDx1 half x length at -pDz, -pDy1 - endCapFrontD, //pDx2 half x length at -pDz, +pDy1 - 0.00*degree,//pAlpha1 wrt y-axis from the centre of the side (lower endcap) - endCapBackD, //pDy2 half y length at +pDz - endCapBackD, //pDx3 half x length at +pDz, -pDy2 - endCapBackD, //pDx4 half x length at +pDz, +pDy2 - 0.00*degree); //pAlpha2 wrt y-axis from the centre of the side (upper endcap) - - //the rectangular part..... - G4Box* endCapBox = new G4Box("endCapBox",endCapBackD,endCapBackD,endCapBoxL/2.); - G4ThreeVector transECBox( 0.*mm, 0.*mm, endCapTaperL/2.+endCapBoxL/2.); - - //add the two together - solidEndCap_PhaseII = new G4UnionSolid("Box+Taper",solidTaperedCloverEC,endCapBox,0,transECBox); - //need the taperL for placement + // end-cap + G4double endCapFrontThickness = 1.2 * mm; // was 1.5 + G4double endCapTaperThickness = 1.5 * mm; + G4double endCapSideThickness = 1.5 * mm; + + G4double GeGap = fEndCap2Ge_PhaseII; + G4double taperAngle = 7.0 * degree; + + G4double endCapTotalL = fTotalGeL_PhaseII + GeGap + endCapFrontThickness + 5. * mm; //+ Gap at rear end + G4double endCapFrontD = 43.5 * mm; + G4double endCapBackD = 50.5 * mm; + G4double endCapTaperL = 55.0 * mm; + + G4double endCapBoxL = endCapTotalL - endCapTaperL; + + // the tapered part + G4Trap* solidTaperedCloverEC = + new G4Trap("taperedCloverEC", + endCapTaperL / 2., // Half z-length [pDz] + 0.00 * degree, // Polar angle of line joining centres of the faces @ -/+pDz + 14.0 * degree, // aequivalent zimuthal angle + endCapFrontD, // pDy1 half y length at -pDz + endCapFrontD, // pDx1 half x length at -pDz, -pDy1 + endCapFrontD, // pDx2 half x length at -pDz, +pDy1 + 0.00 * degree, // pAlpha1 wrt y-axis from the centre of the side (lower endcap) + endCapBackD, // pDy2 half y length at +pDz + endCapBackD, // pDx3 half x length at +pDz, -pDy2 + endCapBackD, // pDx4 half x length at +pDz, +pDy2 + 0.00 * degree); // pAlpha2 wrt y-axis from the centre of the side (upper endcap) + + // the rectangular part..... + G4Box* endCapBox = new G4Box("endCapBox", endCapBackD, endCapBackD, endCapBoxL / 2.); + G4ThreeVector transECBox(0. * mm, 0. * mm, endCapTaperL / 2. + endCapBoxL / 2.); + + // add the two together + solidEndCap_PhaseII = new G4UnionSolid("Box+Taper", solidTaperedCloverEC, endCapBox, 0, transECBox); + // need the taperL for placement fEndCapTaperL_PhaseII = endCapTaperL; - - + //--------------------------------------------------------- - //end-cap inner vacuum - G4double endCapDelta_1 = endCapTaperThickness/cos(taperAngle) - endCapFrontThickness*tan(taperAngle); - G4double endCapDelta_2 = ( endCapSideThickness - (endCapTaperThickness*sin(taperAngle)*tan(taperAngle) + - endCapTaperThickness*cos(taperAngle) ) )/tan(taperAngle); - + // end-cap inner vacuum + G4double endCapDelta_1 = endCapTaperThickness / cos(taperAngle) - endCapFrontThickness * tan(taperAngle); + G4double endCapDelta_2 = (endCapSideThickness - (endCapTaperThickness * sin(taperAngle) * tan(taperAngle) + + endCapTaperThickness * cos(taperAngle))) / + tan(taperAngle); + G4cout << endCapDelta_1 << " " << endCapDelta_2 << endl; - - G4double endCapVacTaperL = endCapTaperL - endCapFrontThickness;// - endCapDelta_2; - G4double endCapVacBoxL = endCapBoxL - endCapFrontThickness; + + G4double endCapVacTaperL = endCapTaperL - endCapFrontThickness; // - endCapDelta_2; + G4double endCapVacBoxL = endCapBoxL - endCapFrontThickness; G4double endCapVacTotalL = endCapVacBoxL + endCapVacTaperL; G4double endCapVacFrontD = endCapFrontD - endCapDelta_1; - G4double endCapVacBackD = endCapBackD - endCapSideThickness; - - //position of vacuum wrt end-cap - fVacuumPosZ_PhaseII = (-endCapTotalL + endCapVacTotalL )/2. + 1.5*endCapFrontThickness; - - //tapered part... - G4Trap* solidTaperVac - = new G4Trap("cloverTaperVac", - endCapVacTaperL/2., //Half z-length [pDz] - 0.00*degree, //Polar angle of line joining centres of the faces @ -/+pDz - 14.0*degree, //aequivalent zimuthal angle - endCapVacFrontD, //pDy1 half y length at -pDz - endCapVacFrontD, //pDx1 half x length at -pDz, -pDy1 - endCapVacFrontD, //pDx2 half x length at -pDz, +pDy1 - 0.00*degree,//pAlpha1 wrt y-axis from the centre of the side (lower endcap) - endCapVacBackD, //pDy2 half y length at +pDz - endCapVacBackD, //pDx3 half x length at +pDz, -pDy2 - endCapVacBackD, //pDx4 half x length at +pDz, +pDy2 - 0.00*degree); //pAlpha2 wrt y-axis from the centre of the side (upper endcap) - + G4double endCapVacBackD = endCapBackD - endCapSideThickness; + + // position of vacuum wrt end-cap + fVacuumPosZ_PhaseII = (-endCapTotalL + endCapVacTotalL) / 2. + 1.5 * endCapFrontThickness; + + // tapered part... + G4Trap* solidTaperVac = new G4Trap("cloverTaperVac", + endCapVacTaperL / 2., // Half z-length [pDz] + 0.00 * degree, // Polar angle of line joining centres of the faces @ -/+pDz + 14.0 * degree, // aequivalent zimuthal angle + endCapVacFrontD, // pDy1 half y length at -pDz + endCapVacFrontD, // pDx1 half x length at -pDz, -pDy1 + endCapVacFrontD, // pDx2 half x length at -pDz, +pDy1 + 0.00 * degree, // pAlpha1 wrt y-axis from the centre of the side (lower endcap) + endCapVacBackD, // pDy2 half y length at +pDz + endCapVacBackD, // pDx3 half x length at +pDz, -pDy2 + endCapVacBackD, // pDx4 half x length at +pDz, +pDy2 + 0.00 * degree); // pAlpha2 wrt y-axis from the centre of the side (upper endcap) + G4cout << endCapTotalL << " " << endCapVacTotalL << endl; - - //rectangular part - G4Box* endCapVacBox = new G4Box("endCapBox",endCapVacBackD,endCapVacBackD,endCapVacBoxL/2.); - G4ThreeVector transVacBox( 0.*mm, 0.*mm, (endCapVacTaperL/2.+endCapVacBoxL/2.-0.0001*mm)); - - //add them together - solidVacuum_PhaseII = new G4UnionSolid("Vac_Box+Taper",solidTaperVac,endCapVacBox,0,transVacBox); - + + // rectangular part + G4Box* endCapVacBox = new G4Box("endCapBox", endCapVacBackD, endCapVacBackD, endCapVacBoxL / 2.); + G4ThreeVector transVacBox(0. * mm, 0. * mm, (endCapVacTaperL / 2. + endCapVacBoxL / 2. - 0.0001 * mm)); + + // add them together + solidVacuum_PhaseII = new G4UnionSolid("Vac_Box+Taper", solidTaperVac, endCapVacBox, 0, transVacBox); //--------------------------------------------------------- - //The Ge crystal... - G4double GeTaperL = 36.0*mm; - G4double GeTotalL = fTotalGeL_PhaseII; //70.0 * mm; - G4double smallSquare = 41.0*mm; - G4double largeSquare = 45.5*mm; - - G4double transX = (largeSquare-smallSquare)/2.; - G4double transY = (largeSquare-smallSquare)/2.; - fHole_dX_PhaseII = transX; //transX /= 2.; - fHole_dY_PhaseII = transY; //transY /= 2.; - - //tapered part...... - G4Trap* solidTaper - = new G4Trap("cloverTaper", - GeTaperL/2., //Half ? z-length [pDz] - 5.05*degree, //Polar angle of line joining centres of the faces @ -/+pDz - 45.*degree, //equivalent azimuthal angle //DOES NOT MAKE SENSE !! - smallSquare/2., //pDy1 half y length at -pDz - smallSquare/2., //pDx1 half x length at -pDz, -pDy1 - smallSquare/2., //pDx2 half x length at -pDz, +pDy1 - 0.00*degree,//pAlpha1 wrt y-axis from the centre of the side (lower endcap) - largeSquare/2., //pDy2 half y length at +pDz - largeSquare/2., //pDx3 half x length at +pDz, -pDy2 - largeSquare/2., //pDx4 half x length at +pDz, +pDy2 - 0.0*degree); //pAlpha2 wrt y-axis from the centre of the side (upper endcap) - - //HERE !! - const G4int numZPlanesGe=4; // no. polycone planes + // The Ge crystal... + G4double GeTaperL = 36.0 * mm; + G4double GeTotalL = fTotalGeL_PhaseII; // 70.0 * mm; + G4double smallSquare = 41.0 * mm; + G4double largeSquare = 45.5 * mm; + + G4double transX = (largeSquare - smallSquare) / 2.; + G4double transY = (largeSquare - smallSquare) / 2.; + fHole_dX_PhaseII = transX; // transX /= 2.; + fHole_dY_PhaseII = transY; // transY /= 2.; + + // tapered part...... + G4Trap* solidTaper = new G4Trap("cloverTaper", + GeTaperL / 2., // Half ? z-length [pDz] + 5.05 * degree, // Polar angle of line joining centres of the faces @ -/+pDz + 45. * degree, // equivalent azimuthal angle //DOES NOT MAKE SENSE !! + smallSquare / 2., // pDy1 half y length at -pDz + smallSquare / 2., // pDx1 half x length at -pDz, -pDy1 + smallSquare / 2., // pDx2 half x length at -pDz, +pDy1 + 0.00 * degree, // pAlpha1 wrt y-axis from the centre of the side (lower endcap) + largeSquare / 2., // pDy2 half y length at +pDz + largeSquare / 2., // pDx3 half x length at +pDz, -pDy2 + largeSquare / 2., // pDx4 half x length at +pDz, +pDy2 + 0.0 * degree); // pAlpha2 wrt y-axis from the centre of the side (upper endcap) + + // HERE !! + const G4int numZPlanesGe = 4; // no. polycone planes G4double zPlaneGe[numZPlanesGe]; // positions of planes - zPlaneGe[0] = 0.00*mm; - zPlaneGe[1] = 2.06*mm; - zPlaneGe[2] = 5.00*mm; + zPlaneGe[0] = 0.00 * mm; + zPlaneGe[1] = 2.06 * mm; + zPlaneGe[2] = 5.00 * mm; zPlaneGe[3] = GeTaperL; G4double rInnerGe[numZPlanesGe]; // interior radii - rInnerGe[0] = rInnerGe[1] = rInnerGe[2] = rInnerGe[3] = 0.0*mm; + rInnerGe[0] = rInnerGe[1] = rInnerGe[2] = rInnerGe[3] = 0.0 * mm; G4double rOuterGe[numZPlanesGe]; // exterior radii - rOuterGe[0] = 20.5*mm; rOuterGe[1] = 23.54*mm; + rOuterGe[0] = 20.5 * mm; + rOuterGe[1] = 23.54 * mm; rOuterGe[2] = rOuterGe[3] = fCrystalR_PhaseII; - - - G4Polycone* solidCone = new G4Polycone("cloverCone", 0.0*degree, 360.0*degree, - numZPlanesGe, - zPlaneGe, - rInnerGe, - rOuterGe); - - G4ThreeVector transGeCone( -transX/2., -transY/2., -GeTaperL/2.); - G4IntersectionSolid* taperedCone = new G4IntersectionSolid("Taper+Cone",solidTaper,solidCone,0,transGeCone); - - //back part.... + + G4Polycone* solidCone = + new G4Polycone("cloverCone", 0.0 * degree, 360.0 * degree, numZPlanesGe, zPlaneGe, rInnerGe, rOuterGe); + + G4ThreeVector transGeCone(-transX / 2., -transY / 2., -GeTaperL / 2.); + G4IntersectionSolid* taperedCone = new G4IntersectionSolid("Taper+Cone", solidTaper, solidCone, 0, transGeCone); + + // back part.... G4double geBoxL = fTotalGeL_PhaseII - GeTaperL; - G4Box* GeBox = new G4Box("GeBox",largeSquare/2.,largeSquare/2.,geBoxL/2.); - G4Tubs* GeCyl = new G4Tubs("GeCyl",0.0*mm,fCrystalR_PhaseII,geBoxL/2.,0.*degree,360.*degree); - - G4ThreeVector transGeBox( transX, transY, 0.0*mm); - G4IntersectionSolid* backPart = new G4IntersectionSolid("Box+Cyl",GeCyl,GeBox,0,transGeBox); + G4Box* GeBox = new G4Box("GeBox", largeSquare / 2., largeSquare / 2., geBoxL / 2.); + G4Tubs* GeCyl = new G4Tubs("GeCyl", 0.0 * mm, fCrystalR_PhaseII, geBoxL / 2., 0. * degree, 360. * degree); - //add front and back - G4ThreeVector transBack( -transX/2., -transY/2., (GeTaperL/2.+geBoxL/2.)); - solidGeLeaf_PhaseII = new G4UnionSolid("germanium",taperedCone,backPart,0,transBack); + G4ThreeVector transGeBox(transX, transY, 0.0 * mm); + G4IntersectionSolid* backPart = new G4IntersectionSolid("Box+Cyl", GeCyl, GeBox, 0, transGeBox); - //z-position of Ge-leaf wrt vacuum - fGeLeafPosZ_PhaseII = -endCapVacTaperL/2. + GeTaperL/2. + GeGap - endCapFrontThickness; + // add front and back + G4ThreeVector transBack(-transX / 2., -transY / 2., (GeTaperL / 2. + geBoxL / 2.)); + solidGeLeaf_PhaseII = new G4UnionSolid("germanium", taperedCone, backPart, 0, transBack); - G4cout << "end-cap : box/2 " << endCapBoxL/2. << " taper/2 " << endCapTaperL/2. << " total/2 " << endCapTotalL << G4endl; - G4cout << "vacuum : box/2 " << endCapVacBoxL/2. << " taper/2 " << endCapVacTaperL/2. << " total/2 " << endCapVacTotalL << G4endl; - G4cout << "ge : box/2 " << geBoxL/2. << " taper/2 " << GeTaperL/2. << " total/2 " << GeTotalL << G4endl; + // z-position of Ge-leaf wrt vacuum + fGeLeafPosZ_PhaseII = -endCapVacTaperL / 2. + GeTaperL / 2. + GeGap - endCapFrontThickness; + G4cout << "end-cap : box/2 " << endCapBoxL / 2. << " taper/2 " << endCapTaperL / 2. << " total/2 " << endCapTotalL + << G4endl; + G4cout << "vacuum : box/2 " << endCapVacBoxL / 2. << " taper/2 " << endCapVacTaperL / 2. << " total/2 " + << endCapVacTotalL << G4endl; + G4cout << "ge : box/2 " << geBoxL / 2. << " taper/2 " << GeTaperL / 2. << " total/2 " << GeTotalL << G4endl; //------------------------------------------------------------------ // Inner bore hole + lithium contact + passivated Ge - G4double GeDepth = 15.00 * mm; //Hole dirilled to this far from face - G4double passiveThick = 0.5 * mm; //fPassiveThick_PhaseII; //passivated Ge - G4double contactThick = fContactThick_PhaseII; //Li contact - - G4double holeR = fHoleR_PhaseII; - G4double contactR = holeR + contactThick; - G4double passiveR = contactR + passiveThick; - G4double holeL = fTotalGeL_PhaseII - GeDepth; - G4double tubeL = holeL - holeR; - - //the same translation works for all the following rounded tubes - G4ThreeVector transSphere(0.01*mm, 0.01*mm, -tubeL/2.-0.1*mm); //if offsets are 0. it does not display !! - - //now add a passivated layer - G4Sphere* passivatedSphere = new G4Sphere("passSphere", 0.0*mm, passiveR, 0.*degree, 360.*degree, 0.*degree, 180.*degree); - G4Tubs* passivatedTube = new G4Tubs( "passTube", 0.0*mm, passiveR, tubeL/2., 0.*degree, 360.*degree); - solidPassivated_PhaseII = new G4UnionSolid("passivatedGe",passivatedTube,passivatedSphere,0,transSphere); - - //and the Li contact - G4Sphere* contactSphere = new G4Sphere("sphere1", 0.0*mm, contactR, 0.*deg, 360.*deg, 0.*deg, 180.*deg); - G4Tubs* contactTube = new G4Tubs( "tube1", 0.0*mm, contactR, tubeL/2., 0.*deg, 360.*deg); - solidContact_PhaseII = new G4UnionSolid("liContact",contactTube,contactSphere,0,transSphere); - - //bore out a hole - G4Sphere* boreSphere = new G4Sphere( "boreSphere", 0.0*mm, holeR, 0.*degree, 360.*degree, 0.*degree, 180.*degree); - G4Tubs* boreTube = new G4Tubs( "boreTube", 0.0*mm, holeR, tubeL/2., 0.*degree, 360.*degree); - solidBoreHole_PhaseII = new G4UnionSolid("boreHole",boreTube,boreSphere,0,transSphere); - - //save these for placements.... - fContact_dZ_PhaseII = holeL/2. - contactThick;// - passiveThick; - - //put corners @ (0,0) - fGeLeaf_dX_PhaseII = largeSquare/2. - transX/2.; + G4double GeDepth = 15.00 * mm; // Hole dirilled to this far from face + G4double passiveThick = 0.5 * mm; // fPassiveThick_PhaseII; //passivated Ge + G4double contactThick = fContactThick_PhaseII; // Li contact + + G4double holeR = fHoleR_PhaseII; + G4double contactR = holeR + contactThick; + G4double passiveR = contactR + passiveThick; + G4double holeL = fTotalGeL_PhaseII - GeDepth; + G4double tubeL = holeL - holeR; + + // the same translation works for all the following rounded tubes + G4ThreeVector transSphere(0.01 * mm, 0.01 * mm, -tubeL / 2. - 0.1 * mm); // if offsets are 0. it does not display !! + + // now add a passivated layer + G4Sphere* passivatedSphere = + new G4Sphere("passSphere", 0.0 * mm, passiveR, 0. * degree, 360. * degree, 0. * degree, 180. * degree); + G4Tubs* passivatedTube = new G4Tubs("passTube", 0.0 * mm, passiveR, tubeL / 2., 0. * degree, 360. * degree); + solidPassivated_PhaseII = new G4UnionSolid("passivatedGe", passivatedTube, passivatedSphere, 0, transSphere); + + // and the Li contact + G4Sphere* contactSphere = new G4Sphere("sphere1", 0.0 * mm, contactR, 0. * deg, 360. * deg, 0. * deg, 180. * deg); + G4Tubs* contactTube = new G4Tubs("tube1", 0.0 * mm, contactR, tubeL / 2., 0. * deg, 360. * deg); + solidContact_PhaseII = new G4UnionSolid("liContact", contactTube, contactSphere, 0, transSphere); + + // bore out a hole + G4Sphere* boreSphere = + new G4Sphere("boreSphere", 0.0 * mm, holeR, 0. * degree, 360. * degree, 0. * degree, 180. * degree); + G4Tubs* boreTube = new G4Tubs("boreTube", 0.0 * mm, holeR, tubeL / 2., 0. * degree, 360. * degree); + solidBoreHole_PhaseII = new G4UnionSolid("boreHole", boreTube, boreSphere, 0, transSphere); + + // save these for placements.... + fContact_dZ_PhaseII = holeL / 2. - contactThick; // - passiveThick; + + // put corners @ (0,0) + fGeLeaf_dX_PhaseII = largeSquare / 2. - transX / 2.; } - - - //--------------------------------------------------------------------- // Create the solids defining Phase-II Clovers //--------------------------------------------------------------------- -void Chamber::CreateGREATCloverSolids() -{ - //An approximate CloverII +void Chamber::CreateGREATCloverSolids() { + // An approximate CloverII G4cout << G4endl << "Constructing archetypal GREAT Clover" << G4endl; //--------------------------------------------------------- - //end-cap - G4double endCapFrontThickness = 2.0*mm; - G4double endCapTaperThickness = 2.0*mm; - G4double endCapSideThickness = 2.0*mm; - - G4double GeGap = fEndCap2Ge_GREAT - endCapFrontThickness; - G4double taperAngle = 15.*degree; - - G4double endCapTotalL = fTotalGeL_GREAT + GeGap + 2.*endCapFrontThickness + 5.*mm; //+ Gap at rear end - G4double endCapFrontD = 60.09*mm; - G4double endCapBackD = 70.00*mm; - G4double endCapTaperL = 37.00*mm; - - G4double endCapBoxL = endCapTotalL - endCapTaperL; - - //the tapered part.... - G4Trap* solidTaperedCloverEC = new G4Trap("taperedCloverEC", - endCapTaperL/2., //Half z-length [pDz] - 0.00*degree, //Polar angle of line joining centres of the faces @ -/+pDz - 45.0*degree, //aequivalent zimuthal angle //Does not make sense ! - endCapFrontD, //pDy1 half y length at -pDz - endCapFrontD, //pDx1 half x length at -pDz, -pDy1 - endCapFrontD, //pDx2 half x length at -pDz, +pDy1 - 0.00*degree,//pAlpha1 wrt y-axis from the centre of the side (lower endcap) - endCapBackD, //pDy2 half y length at +pDz - endCapBackD, //pDx3 half x length at +pDz, -pDy2 - endCapBackD, //pDx4 half x length at +pDz, +pDy2 - 0.00*degree); //pAlpha2 wrt y-axis from the centre of the side (upper endcap) - - //the rectangular part..... - G4Box* endCapBox = new G4Box("endCapBox",endCapBackD,endCapBackD,endCapBoxL/2.); - G4ThreeVector transECBox( 0.*mm, 0.*mm, endCapTaperL/2.+endCapBoxL/2.); - - //add the two together - solidEndCap_GREAT = new G4UnionSolid("Box+Taper",solidTaperedCloverEC,endCapBox,0,transECBox); - //need the taperL for placement + // end-cap + G4double endCapFrontThickness = 2.0 * mm; + G4double endCapTaperThickness = 2.0 * mm; + G4double endCapSideThickness = 2.0 * mm; + + G4double GeGap = fEndCap2Ge_GREAT - endCapFrontThickness; + G4double taperAngle = 15. * degree; + + G4double endCapTotalL = fTotalGeL_GREAT + GeGap + 2. * endCapFrontThickness + 5. * mm; //+ Gap at rear end + G4double endCapFrontD = 60.09 * mm; + G4double endCapBackD = 70.00 * mm; + G4double endCapTaperL = 37.00 * mm; + + G4double endCapBoxL = endCapTotalL - endCapTaperL; + + // the tapered part.... + G4Trap* solidTaperedCloverEC = + new G4Trap("taperedCloverEC", + endCapTaperL / 2., // Half z-length [pDz] + 0.00 * degree, // Polar angle of line joining centres of the faces @ -/+pDz + 45.0 * degree, // aequivalent zimuthal angle //Does not make sense ! + endCapFrontD, // pDy1 half y length at -pDz + endCapFrontD, // pDx1 half x length at -pDz, -pDy1 + endCapFrontD, // pDx2 half x length at -pDz, +pDy1 + 0.00 * degree, // pAlpha1 wrt y-axis from the centre of the side (lower endcap) + endCapBackD, // pDy2 half y length at +pDz + endCapBackD, // pDx3 half x length at +pDz, -pDy2 + endCapBackD, // pDx4 half x length at +pDz, +pDy2 + 0.00 * degree); // pAlpha2 wrt y-axis from the centre of the side (upper endcap) + + // the rectangular part..... + G4Box* endCapBox = new G4Box("endCapBox", endCapBackD, endCapBackD, endCapBoxL / 2.); + G4ThreeVector transECBox(0. * mm, 0. * mm, endCapTaperL / 2. + endCapBoxL / 2.); + + // add the two together + solidEndCap_GREAT = new G4UnionSolid("Box+Taper", solidTaperedCloverEC, endCapBox, 0, transECBox); + // need the taperL for placement fEndCapTaperL_GREAT = endCapTaperL; - - + //--------------------------------------------------------- - //end-cap inner vacuum - G4double endCapDelta_1 = endCapTaperThickness/cos(taperAngle) - endCapFrontThickness*tan(taperAngle); - G4double endCapDelta_2 = ( endCapSideThickness - (endCapTaperThickness*sin(taperAngle)*tan(taperAngle) + - endCapTaperThickness*cos(taperAngle) ) )/tan(taperAngle); - + // end-cap inner vacuum + G4double endCapDelta_1 = endCapTaperThickness / cos(taperAngle) - endCapFrontThickness * tan(taperAngle); + G4double endCapDelta_2 = (endCapSideThickness - (endCapTaperThickness * sin(taperAngle) * tan(taperAngle) + + endCapTaperThickness * cos(taperAngle))) / + tan(taperAngle); + G4cout << endCapDelta_1 << " " << endCapDelta_2 << endl; - + G4double endCapVacTaperL = endCapTaperL - endCapFrontThickness - endCapDelta_2; - G4double endCapVacBoxL = endCapBoxL + endCapDelta_2; + G4double endCapVacBoxL = endCapBoxL + endCapDelta_2; G4double endCapVacTotalL = endCapVacBoxL + endCapVacTaperL; G4double endCapVacFrontD = endCapFrontD - endCapDelta_1; - G4double endCapVacBackD = endCapBackD - endCapSideThickness; - - //position of vacuum wrt end-cap - fVacuumPosZ_GREAT = (-endCapTotalL + endCapVacTotalL - endCapDelta_2)/2. + endCapFrontThickness; - - //tapered part... - G4Trap* solidTaperVac = new G4Trap("cloverTaperVac", - endCapVacTaperL/2., //Half z-length [pDz] - 0.00*degree, //Polar angle of line joining centres of the faces @ -/+pDz - 45.0*degree, //aequivalent zimuthal angle - endCapVacFrontD, //pDy1 half y length at -pDz - endCapVacFrontD, //pDx1 half x length at -pDz, -pDy1 - endCapVacFrontD, //pDx2 half x length at -pDz, +pDy1 - 0.00*degree,//pAlpha1 wrt y-axis from the centre of the side (lower endcap) - endCapVacBackD, //pDy2 half y length at +pDz - endCapVacBackD, //pDx3 half x length at +pDz, -pDy2 - endCapVacBackD, //pDx4 half x length at +pDz, +pDy2 - 0.00*degree); //pAlpha2 wrt y-axis from the centre of the side (upper endcap) - + G4double endCapVacBackD = endCapBackD - endCapSideThickness; + + // position of vacuum wrt end-cap + fVacuumPosZ_GREAT = (-endCapTotalL + endCapVacTotalL - endCapDelta_2) / 2. + endCapFrontThickness; + + // tapered part... + G4Trap* solidTaperVac = new G4Trap("cloverTaperVac", + endCapVacTaperL / 2., // Half z-length [pDz] + 0.00 * degree, // Polar angle of line joining centres of the faces @ -/+pDz + 45.0 * degree, // aequivalent zimuthal angle + endCapVacFrontD, // pDy1 half y length at -pDz + endCapVacFrontD, // pDx1 half x length at -pDz, -pDy1 + endCapVacFrontD, // pDx2 half x length at -pDz, +pDy1 + 0.00 * degree, // pAlpha1 wrt y-axis from the centre of the side (lower endcap) + endCapVacBackD, // pDy2 half y length at +pDz + endCapVacBackD, // pDx3 half x length at +pDz, -pDy2 + endCapVacBackD, // pDx4 half x length at +pDz, +pDy2 + 0.00 * degree); // pAlpha2 wrt y-axis from the centre of the side (upper endcap) + G4cout << endCapTotalL << " " << endCapVacTotalL << endl; - - //rectangular part - G4Box* endCapVacBox = new G4Box("endCapBox",endCapVacBackD,endCapVacBackD,endCapVacBoxL/2.); - G4ThreeVector transVacBox( 0.*mm, 0.*mm, endCapVacTaperL/2.+endCapVacBoxL/2.); - - //add them together - solidVacuum_GREAT = new G4UnionSolid("Vac_Box+Taper",solidTaperVac,endCapVacBox,0,transVacBox); - + + // rectangular part + G4Box* endCapVacBox = new G4Box("endCapBox", endCapVacBackD, endCapVacBackD, endCapVacBoxL / 2.); + G4ThreeVector transVacBox(0. * mm, 0. * mm, endCapVacTaperL / 2. + endCapVacBoxL / 2.); + + // add them together + solidVacuum_GREAT = new G4UnionSolid("Vac_Box+Taper", solidTaperVac, endCapVacBox, 0, transVacBox); //--------------------------------------------------------- - //The Ge crystal... - G4double GeTaperL = fTaperGeL_GREAT; //30.0*mm; - G4double GeTotalL = fTotalGeL_GREAT; //105 ? 140.0 * mm; - + // The Ge crystal... + G4double GeTaperL = fTaperGeL_GREAT; // 30.0*mm; + G4double GeTotalL = fTotalGeL_GREAT; // 105 ? 140.0 * mm; + G4double smallSquare = fFrontFaceSquare_GREAT; G4double largeSquare = fBackFaceSquare_GREAT; - G4double transX = (largeSquare-smallSquare)/2.; - G4double transY = (largeSquare-smallSquare)/2.; + G4double transX = (largeSquare - smallSquare) / 2.; + G4double transY = (largeSquare - smallSquare) / 2.; transX /= 2.; transY /= 2.; - + G4cout << "Got to the point of creating the clover leaf" << G4endl; - //don't understand this G4Trap : expect an angle of 12.15 degrees ! + // don't understand this G4Trap : expect an angle of 12.15 degrees ! G4Trap* solidTaper = new G4Trap("cloverTaper", - GeTaperL/2., //Half z-length [pDz] - 9.63*degree, //This is a fudge angle and is diff from debug //Polar angle of line joining centres of the faces @ -/+pDz - 45.0*degree, //equivalent zimuthal angle - smallSquare/2., //pDy1 half y length at -pDz - smallSquare/2., //pDx1 half x length at -pDz, -pDy1 - smallSquare/2., //pDx2 half x length at -pDz, +pDy1 - 0.00*degree,//pAlpha1 wrt y-axis from the centre of the side (lower endcap) - largeSquare/2., //pDy2 half y length at +pDz - largeSquare/2., //pDx3 half x length at +pDz, -pDy2 - largeSquare/2., //pDx4 half x length at +pDz, +pDy2 - 0.0*degree); //pAlpha2 wrt y-axis from the centre of the side (upper endcap) - + GeTaperL / 2., // Half z-length [pDz] + 9.63 * degree, // This is a fudge angle and is diff from debug //Polar angle of line + // joining centres of the faces @ -/+pDz + 45.0 * degree, // equivalent zimuthal angle + smallSquare / 2., // pDy1 half y length at -pDz + smallSquare / 2., // pDx1 half x length at -pDz, -pDy1 + smallSquare / 2., // pDx2 half x length at -pDz, +pDy1 + 0.00 * degree, // pAlpha1 wrt y-axis from the centre of the side (lower endcap) + largeSquare / 2., // pDy2 half y length at +pDz + largeSquare / 2., // pDx3 half x length at +pDz, -pDy2 + largeSquare / 2., // pDx4 half x length at +pDz, +pDy2 + 0.0 * degree); // pAlpha2 wrt y-axis from the centre of the side (upper endcap) + /* This was used for a phaseII to make rounded edges const G4int numZPlanesGe=4; // no. polycone planes @@ -3621,81 +3468,83 @@ void Chamber::CreateGREATCloverSolids() G4double rOuterGe[numZPlanesGe]; // exterior radii rOuterGe[0] = 20.5*mm; rOuterGe[1] = 23.04*mm; //23.54*mm;//exagerate it more rOuterGe[2] = rOuterGe[3] = fCrystalR_PhaseII; - - G4Polycone* solidCone = new G4Polycone("cloverCone", 0.0*degree, 360.0*degree,numZPlanesGe, zPlaneGe, rInnerGe, rOuterGe); - G4ThreeVector transGeCone( -transX/2., -transY/2., -GeTaperL/2.); - G4IntersectionSolid* taperedCone = new G4IntersectionSolid("Taper+Cone",solidTaper,solidCone,0,transGeCone); + + G4Polycone* solidCone = new G4Polycone("cloverCone", 0.0*degree, 360.0*degree,numZPlanesGe, zPlaneGe, rInnerGe, + rOuterGe); G4ThreeVector transGeCone( -transX/2., -transY/2., -GeTaperL/2.); G4IntersectionSolid* taperedCone = new + G4IntersectionSolid("Taper+Cone",solidTaper,solidCone,0,transGeCone); */ - //back part.... + // back part.... G4double geBoxL = GeTotalL - GeTaperL; - G4Box* GeBox = new G4Box("GeBox", largeSquare/2., largeSquare/2., geBoxL/2.); - - //add back box and front tapered parts - G4ThreeVector transGeBox( transX, transX, GeTaperL/2.+geBoxL/2.); - G4UnionSolid* newTaper = new G4UnionSolid("Box+Taper",solidTaper,GeBox,0,transGeBox); - - - //now make a cylinder 90x60 which needs to be displaced before intersection - //the centres of the cylinders should be 56 mm apart, but the gap between leaves - // is 0.8 mm => centre of cylinder should be at (27.6,27.6) wrt inner corner - G4double dx1 = 27.60*mm; - G4double dx2 = largeSquare/2.; + G4Box* GeBox = new G4Box("GeBox", largeSquare / 2., largeSquare / 2., geBoxL / 2.); + + // add back box and front tapered parts + G4ThreeVector transGeBox(transX, transX, GeTaperL / 2. + geBoxL / 2.); + G4UnionSolid* newTaper = new G4UnionSolid("Box+Taper", solidTaper, GeBox, 0, transGeBox); + + // now make a cylinder 90x60 which needs to be displaced before intersection + // the centres of the cylinders should be 56 mm apart, but the gap between leaves + // is 0.8 mm => centre of cylinder should be at (27.6,27.6) wrt inner corner + G4double dx1 = 27.60 * mm; + G4double dx2 = largeSquare / 2.; G4cout << "transX " << transX << " dx2 " << dx2 << ".....hole_dX " << fHole_dX_GREAT << G4endl; - fHole_dX_GREAT = transX + dx1 - dx2; //save the displacements for the bore-hole placements + fHole_dX_GREAT = transX + dx1 - dx2; // save the displacements for the bore-hole placements fHole_dY_GREAT = transY + dx1 - dx2; - - G4Tubs* GeCyl = new G4Tubs("GeCyl",0.0*mm, 35*mm, GeTotalL/2.,0.*degree,360.*degree); - G4ThreeVector transGeCyl( fHole_dX_GREAT, fHole_dY_GREAT, (GeTotalL-GeTaperL)/2.); - //add all of this together for the Ge.... - solidGeLeaf_GREAT = new G4IntersectionSolid("Box+Taper+Cyl",newTaper,GeCyl,0,transGeCyl); - + G4Tubs* GeCyl = new G4Tubs("GeCyl", 0.0 * mm, 35 * mm, GeTotalL / 2., 0. * degree, 360. * degree); + G4ThreeVector transGeCyl(fHole_dX_GREAT, fHole_dY_GREAT, (GeTotalL - GeTaperL) / 2.); + + // add all of this together for the Ge.... + solidGeLeaf_GREAT = new G4IntersectionSolid("Box+Taper+Cyl", newTaper, GeCyl, 0, transGeCyl); - //put corners @ (0,0) - fGeLeaf_dX_GREAT = largeSquare/2. - transX; - //fGeLeaf_dY_GREAT = largeSquare/2. - transY; + // put corners @ (0,0) + fGeLeaf_dX_GREAT = largeSquare / 2. - transX; + // fGeLeaf_dY_GREAT = largeSquare/2. - transY; G4cout << "shift leaves " << fGeLeaf_dX_GREAT << "....." << fHole_dX_GREAT << G4endl; - //z-position of Ge-leaf wrt vacuum - fGeLeafPosZ_GREAT = -endCapVacTaperL/2. + GeTaperL/2. + GeGap; //wrt clover Vacuum + // z-position of Ge-leaf wrt vacuum + fGeLeafPosZ_GREAT = -endCapVacTaperL / 2. + GeTaperL / 2. + GeGap; // wrt clover Vacuum - //1.875 28.875.....-1.575 27.6 + // 1.875 28.875.....-1.575 27.6 //------------------------------------------------------- // Inner bore hole + lithium contact + passivated Ge - G4double GeDepth = 15.00 * mm; - G4double holeL = GeTotalL - GeDepth; //length of bore hole - G4double passiveThick = 0.30 * mm; //passivated Ge - G4double contactThick = 0.50 * mm; //Li contact - - G4double holeR = 5.00 * mm; //fHoleR_PhaseII; - G4double contactR = holeR + contactThick; - G4double passiveR = contactR + passiveThick; - G4double tubeL = holeL - holeR; - - //the same translation works for all the following rounded tubes - G4ThreeVector transSphere(0.001*mm, 0.001*mm, -tubeL/2.-0.001*mm); //if offsets are 0. it does not display !! - - //now add a passivated layer - G4Sphere* passivatedSphere = new G4Sphere("passSphere", 0.0*mm, passiveR, 0.*degree, 360.*degree, 0.*degree, 180.*degree); - G4Tubs* passivatedTube = new G4Tubs( "passTube", 0.0*mm, passiveR, tubeL/2., 0.*degree, 360.*degree); - solidPassivated_GREAT = new G4UnionSolid("passivatedGe",passivatedTube,passivatedSphere,0,transSphere); - - //and the Li contact - G4Sphere* contactSphere = new G4Sphere("sphere1", 0.0*mm, contactR, 0.*deg, 360.*deg, 0.*deg, 180.*deg); - G4Tubs* contactTube = new G4Tubs( "tube1", 0.0*mm, contactR, tubeL/2., 0.*deg, 360.*deg); - solidContact_GREAT = new G4UnionSolid("liContact",contactTube,contactSphere,0,transSphere); - - //bore out a hole - G4Sphere* boreSphere = new G4Sphere( "boreSphere", 0.0*mm, holeR, 0.*degree, 360.*degree, 0.*degree, 180.*degree); - G4Tubs* boreTube = new G4Tubs( "boreTube", 0.0*mm, holeR, tubeL/2., 0.*degree, 360.*degree); - solidBoreHole_GREAT = new G4UnionSolid("boreHole",boreTube,boreSphere,0,transSphere); - - //save this for placement - fContact_dZ_GREAT = -GeTaperL/2 + tubeL/2 + holeR + GeDepth; + G4double GeDepth = 15.00 * mm; + G4double holeL = GeTotalL - GeDepth; // length of bore hole + G4double passiveThick = 0.30 * mm; // passivated Ge + G4double contactThick = 0.50 * mm; // Li contact + + G4double holeR = 5.00 * mm; // fHoleR_PhaseII; + G4double contactR = holeR + contactThick; + G4double passiveR = contactR + passiveThick; + G4double tubeL = holeL - holeR; + + // the same translation works for all the following rounded tubes + G4ThreeVector transSphere(0.001 * mm, 0.001 * mm, + -tubeL / 2. - 0.001 * mm); // if offsets are 0. it does not display !! + + // now add a passivated layer + G4Sphere* passivatedSphere = + new G4Sphere("passSphere", 0.0 * mm, passiveR, 0. * degree, 360. * degree, 0. * degree, 180. * degree); + G4Tubs* passivatedTube = new G4Tubs("passTube", 0.0 * mm, passiveR, tubeL / 2., 0. * degree, 360. * degree); + solidPassivated_GREAT = new G4UnionSolid("passivatedGe", passivatedTube, passivatedSphere, 0, transSphere); + + // and the Li contact + G4Sphere* contactSphere = new G4Sphere("sphere1", 0.0 * mm, contactR, 0. * deg, 360. * deg, 0. * deg, 180. * deg); + G4Tubs* contactTube = new G4Tubs("tube1", 0.0 * mm, contactR, tubeL / 2., 0. * deg, 360. * deg); + solidContact_GREAT = new G4UnionSolid("liContact", contactTube, contactSphere, 0, transSphere); + + // bore out a hole + G4Sphere* boreSphere = + new G4Sphere("boreSphere", 0.0 * mm, holeR, 0. * degree, 360. * degree, 0. * degree, 180. * degree); + G4Tubs* boreTube = new G4Tubs("boreTube", 0.0 * mm, holeR, tubeL / 2., 0. * degree, 360. * degree); + solidBoreHole_GREAT = new G4UnionSolid("boreHole", boreTube, boreSphere, 0, transSphere); + + // save this for placement + fContact_dZ_GREAT = -GeTaperL / 2 + tubeL / 2 + holeR + GeDepth; G4cout << "fContact_dZ_GREAT " << fContact_dZ_GREAT << G4endl; - G4cout << "totalL/2 " << GeTotalL/2 << " taperL/2 " << GeTaperL/2 << " tubeL/2 " << tubeL/2 << " : GeDepth " << GeDepth << G4endl; + G4cout << "totalL/2 " << GeTotalL / 2 << " taperL/2 " << GeTaperL / 2 << " tubeL/2 " << tubeL / 2 << " : GeDepth " + << GeDepth << G4endl; } diff --git a/NPSimulation/Core/DetectorConstruction.cc b/NPSimulation/Core/DetectorConstruction.cc index b002ce962..92a5cca55 100644 --- a/NPSimulation/Core/DetectorConstruction.cc +++ b/NPSimulation/Core/DetectorConstruction.cc @@ -25,62 +25,59 @@ #include "DetectorConstruction.hh" // G4 -#include "G4Material.hh" #include "G4Box.hh" +#include "G4GeometryManager.hh" #include "G4LogicalVolume.hh" -#include "G4ThreeVector.hh" +#include "G4LogicalVolumeStore.hh" +#include "G4Material.hh" #include "G4PVPlacement.hh" -#include "G4VisAttributes.hh" -#include "G4GeometryManager.hh" #include "G4PhysicalVolumeStore.hh" -#include "G4LogicalVolumeStore.hh" -#include "G4VPhysicalVolume.hh" -#include "G4SolidStore.hh" +#include "G4RegionStore.hh" #include "G4RunManager.hh" #include "G4SDManager.hh" -#include "G4RegionStore.hh" +#include "G4SolidStore.hh" +#include "G4ThreeVector.hh" #include "G4TransportationManager.hh" +#include "G4VPhysicalVolume.hh" +#include "G4VisAttributes.hh" #ifdef NPS_GDML -#include"G4GDMLParser.hh" +#include "G4GDMLParser.hh" #endif // STL -#include<cstdlib> -#include<fstream> -#include<string> -#include<set> +#include <cstdlib> +#include <fstream> +#include <set> +#include <string> // NPL -#include "RootOutput.h" -#include "NPOptionManager.h" #include "NPInputParser.h" +#include "NPOptionManager.h" +#include "RootOutput.h" // NPS -#include "NPSDetectorFactory.hh" -#include "MaterialManager.hh" #include "DetectorMessenger.hh" +#include "MaterialManager.hh" +#include "NPSDetectorFactory.hh" //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -DetectorConstruction::DetectorConstruction(){ - world_log = NULL; - world_phys = NULL; - world_box = NULL; - m_Target = NULL; - m_Chamber = NULL ; - m_Messenger = new DetectorMessenger(this); +DetectorConstruction::DetectorConstruction() { + world_log = NULL; + world_phys = NULL; + world_box = NULL; + m_Target = NULL; + m_Chamber = NULL; + m_Messenger = new DetectorMessenger(this); m_ReadSensitivePtr = &NPS::VDetector::ReadSensitive; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -DetectorConstruction::~DetectorConstruction(){ -} +DetectorConstruction::~DetectorConstruction() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4VPhysicalVolume* DetectorConstruction::Construct(){ - return ReadConfigurationFile(); -} +G4VPhysicalVolume* DetectorConstruction::Construct() { return ReadConfigurationFile(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void DetectorConstruction::AddDetector(NPS::VDetector* NewDetector){ +void DetectorConstruction::AddDetector(NPS::VDetector* NewDetector) { // Add new detector to vector m_Detectors.push_back(NewDetector); @@ -94,9 +91,8 @@ void DetectorConstruction::AddDetector(NPS::VDetector* NewDetector){ NewDetector->InitializeRootOutput(); } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4VPhysicalVolume* DetectorConstruction::ReadConfigurationFile(){ +G4VPhysicalVolume* DetectorConstruction::ReadConfigurationFile() { // Construct the World volume G4Material* Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); @@ -105,19 +101,17 @@ G4VPhysicalVolume* DetectorConstruction::ReadConfigurationFile(){ G4double world_y = 100.0 * m; G4double world_z = 100.0 * m; - if(!world_box) + if (!world_box) world_box = new G4Box("world_box", world_x, world_y, world_z); - if(!world_log) + if (!world_log) world_log = new G4LogicalVolume(world_box, Vacuum, "world_log", 0, 0, 0); - - if(!world_phys) - world_phys = new G4PVPlacement(0, G4ThreeVector(), world_log, "world", 0, false, 0); - - G4VisAttributes* VisAtt = new G4VisAttributes(G4VisAttributes::Invisible); - world_log->SetVisAttributes(VisAtt); + if (!world_phys) + world_phys = new G4PVPlacement(0, G4ThreeVector(), world_log, "world", 0, false, 0); + G4VisAttributes* VisAtt = new G4VisAttributes(G4VisAttributes::GetInvisible()); + world_log->SetVisAttributes(VisAtt); //------------------------------------------------------------------ @@ -128,22 +122,21 @@ G4VPhysicalVolume* DetectorConstruction::ReadConfigurationFile(){ ////////General Reading needs//////// std::string LineBuffer; std::string DataBuffer; - static bool already=false; + static bool already = false; std::set<std::string> check; - int VerboseLevel = 0 ; - if(!already){ + int VerboseLevel = 0; + if (!already) { VerboseLevel = NPOptionManager::getInstance()->GetVerboseLevel(); already = 1; } else VerboseLevel = 0; - if(VerboseLevel) - cout << endl << "\033[1;36m//// Reading detector file "<< Path << endl<<endl; - - if(already) - cout << endl << "\033[1;36m//// Changing detector file to "<< Path << endl<<endl; + if (VerboseLevel) + cout << endl << "\033[1;36m//// Reading detector file " << Path << endl << endl; + if (already) + cout << endl << "\033[1;36m//// Changing detector file to " << Path << endl << endl; // Access the DetectorFactory and ask it to load the Class List std::string classlist = getenv("NPTOOL"); @@ -156,19 +149,19 @@ G4VPhysicalVolume* DetectorConstruction::ReadConfigurationFile(){ /////////// Search for Target ///////////// //////////////////////////////////////////// std::vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Target"); - if(blocks.size()==1){ + if (blocks.size() == 1) { m_Target = new Target(); m_Target->ReadConfiguration(parser); AddDetector(m_Target); } - else{ + else { blocks = parser.GetAllBlocksWithToken("CryogenicTarget"); - if(blocks.size()==1){ + if (blocks.size() == 1) { m_Target = new Target(); m_Target->ReadConfiguration(parser); AddDetector(m_Target); } - else{ + else { cout << "WARNING: No target found in detector input file! Use with caution" << endl; } } @@ -177,33 +170,33 @@ G4VPhysicalVolume* DetectorConstruction::ReadConfigurationFile(){ //////////////////////////////////////////// blocks.clear(); blocks = parser.GetAllBlocksWithToken("Chamber"); - if(blocks.size()==1){ + if (blocks.size() == 1) { m_Chamber = new Chamber(); m_Chamber->ReadConfiguration(parser); AddDetector(m_Chamber); - } + } //////////////////////////////////////////// /////////// Search for Detectors /////////// //////////////////////////////////////////// // Get the list of main token std::vector<std::string> token = parser.GetAllBlocksToken(); // Look for detectors among them - for(unsigned int i = 0 ; i < token.size() ; i++){ + for (unsigned int i = 0; i < token.size(); i++) { NPS::VDetector* detector = theFactory->Construct(token[i]); - if(detector!=NULL && check.find(token[i])==check.end()){ + if (detector != NULL && check.find(token[i]) == check.end()) { cout << "/////////////////////////////////////////" << endl; - cout << "//// Adding Detector " << token[i] << endl; + cout << "//// Adding Detector " << token[i] << endl; detector->ReadConfiguration(parser); cout << "/////////////////////////////////////////" << endl; // Add array to the VDetector Vector AddDetector(detector); check.insert(token[i]); } - else if(detector!=NULL) + else if (detector != NULL) delete detector; } - cout << "\033[0m" ; + cout << "\033[0m"; // Create the Material sample for DEDX tables MaterialManager::getInstance()->CreateSampleVolumes(world_log); @@ -211,29 +204,27 @@ G4VPhysicalVolume* DetectorConstruction::ReadConfigurationFile(){ } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void DetectorConstruction::ReadAllSensitive(const G4Event* event){ - unsigned int mysize = m_Detectors.size(); - for (unsigned short i = 0 ; i < mysize ; i++) { - (m_Detectors[i]->*m_ReadSensitivePtr)(event); +void DetectorConstruction::ReadAllSensitive(const G4Event* event) { + unsigned int mysize = m_Detectors.size(); + for (unsigned short i = 0; i < mysize; i++) { + (m_Detectors[i]->*m_ReadSensitivePtr)(event); } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* DetectorConstruction::GetWorldLogic(){ - return world_log; -} +G4LogicalVolume* DetectorConstruction::GetWorldLogic() { return world_log; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void DetectorConstruction::ClearGeometry(){ +void DetectorConstruction::ClearGeometry() { unsigned int mySize = m_Detectors.size(); - for (unsigned short i = 0 ; i < mySize ; i++) { + for (unsigned short i = 0; i < mySize; i++) { delete m_Detectors[i]; } m_Detectors.clear(); - // Delete previous Sensitive Detector (Scorer) + // Delete previous Sensitive Detector (Scorer) delete G4SDManager::GetSDMpointer(); G4GeometryManager::GetInstance()->OpenGeometry(); @@ -241,56 +232,55 @@ void DetectorConstruction::ClearGeometry(){ // Cleaning stores by hand (everything but the world) // Cleaning the PVP G4PhysicalVolumeStore* PVP = G4PhysicalVolumeStore::GetInstance(); - while(PVP->size()>1){ - delete PVP->at(PVP->size()-1); + while (PVP->size() > 1) { + delete PVP->at(PVP->size() - 1); PVP->pop_back(); } // Cleaning the Logical Volume G4LogicalVolumeStore* LV = G4LogicalVolumeStore::GetInstance(); - while(LV->size()>1) { - delete LV->at(LV->size()-1); + while (LV->size() > 1) { + delete LV->at(LV->size() - 1); LV->pop_back(); } // Cleaning the Solid store G4SolidStore* SL = G4SolidStore::GetInstance(); - while(SL->size()>1) { - delete SL->at(SL->size()-1); + while (SL->size() > 1) { + delete SL->at(SL->size() - 1); SL->pop_back(); } - - G4Region* reg = G4RegionStore::GetInstance()->GetRegion("NPSimulationProcess",false); - if(reg) + + G4Region* reg = G4RegionStore::GetInstance()->GetRegion("NPSimulationProcess", false); + if (reg) G4RegionStore::GetInstance()->DeRegister(reg); - + delete reg; - m_Target = 0; - m_Chamber = 0; + m_Target = 0; + m_Chamber = 0; world_log->ClearDaughters(); } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void DetectorConstruction::RedefineGeometry(std::string file){ - ClearGeometry() ; +void DetectorConstruction::RedefineGeometry(std::string file) { + ClearGeometry(); - if(file!="") + if (file != "") NPOptionManager::getInstance()->SetDetectorFile(file); Construct(); - - if(m_Target) + + if (m_Target) m_Target->SetReactionRegion(); G4RunManager::GetRunManager()->GeometryHasBeenModified(); - G4RunManager::GetRunManager()->PhysicsHasBeenModified() ; + G4RunManager::GetRunManager()->PhysicsHasBeenModified(); G4RunManager::GetRunManager()->Initialize(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void DetectorConstruction::ExportGeometry(string file){ +void DetectorConstruction::ExportGeometry(string file) { #ifdef NPS_GDML - G4GDMLParser parser ; - parser.Write(file.c_str(),world_log); + G4GDMLParser parser; + parser.Write(file.c_str(), world_log); #else // To silenced the compiler file = ""; diff --git a/NPSimulation/Core/MaterialManager.cc b/NPSimulation/Core/MaterialManager.cc index c207c08ce..3802a0efa 100644 --- a/NPSimulation/Core/MaterialManager.cc +++ b/NPSimulation/Core/MaterialManager.cc @@ -20,7 +20,7 @@ * Comment: * * * *****************************************************************************/ -//NPL +// NPL #include "NPOptionManager.h" // NPS @@ -56,8 +56,8 @@ MaterialManager::~MaterialManager() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... MaterialManager::MaterialManager() { - m_D = NULL; - m_T = NULL; + m_D = NULL; + m_T = NULL; m_He3 = NULL; } @@ -75,14 +75,13 @@ void MaterialManager::ClearMaterialLibrary() { // we can forget about them but not delete it // as they can be deleted by the kernel e.g. when Cleaning the PVPStore m_Material.clear(); - m_D = NULL; - m_T = NULL; + m_D = NULL; + m_T = NULL; m_He3 = NULL; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4Material* MaterialManager::GetMaterialFromLibrary(string Name, - double density) { +G4Material* MaterialManager::GetMaterialFromLibrary(string Name, double density) { // Search if the material is already instantiate map<string, G4Material*>::iterator it; it = m_Material.find(Name); @@ -91,8 +90,7 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, if (it == m_Material.end()) { // Usual compound - if (Name == "Vacuum" || Name == "Vaccum" || Name == "Vaccuum" - || Name == "Vacum") { + if (Name == "Vacuum" || Name == "Vaccum" || Name == "Vaccuum" || Name == "Vacum") { if (!density) density = 0.000000001 * mg / cm3; G4Material* material = new G4Material("NPS_" + Name, density, 2); @@ -148,7 +146,6 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, return material; } - else if (Name == "Rogers4003C") { if (!density) density = 1.79 * g / cm3; @@ -224,9 +221,8 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, else if (Name == "N2_liquid") { if (!density) density = 0.808 * g / cm3; - G4Material* material = new G4Material("NPS_" + Name, 7, 14.01 * g / mole, - density, kStateLiquid, 77 * kelvin); - m_Material[Name] = material; + G4Material* material = new G4Material("NPS_" + Name, 7, 14.01 * g / mole, density, kStateLiquid, 77 * kelvin); + m_Material[Name] = material; return material; } @@ -264,11 +260,9 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, else if (Name == "EJ200") { if (!density) density = 1.023 * g / cm3; - G4Material* material = new G4Material("NPS_" + Name, density, 2, - kStateSolid, 293 * kelvin); - G4Element* C = new G4Element("C", "C", 6, 12 * g / mole); - G4Element* H - = new G4Element("TS_H_of_Polyethylene", "H", 1., 1.0079 * g / mole); + G4Material* material = new G4Material("NPS_" + Name, density, 2, kStateSolid, 293 * kelvin); + G4Element* C = new G4Element("C", "C", 6, 12 * g / mole); + G4Element* H = new G4Element("TS_H_of_Polyethylene", "H", 1., 1.0079 * g / mole); material->AddElement(C, 5); material->AddElement(H, 4); // material->AddElement(GetElementFromLibrary("C"), 5); @@ -299,7 +293,6 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, return material; } - else if (Name == "Cu") { if (!density) density = 8.96 * g / cm3; @@ -326,8 +319,7 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, G4Isotope* isotope = new G4Isotope("235U", 92, 235); U235->AddIsotope(isotope, 1); - G4Material* material = new G4Material("NPS_" + Name, density, 1, - kStateSolid, 293.15 * kelvin); + G4Material* material = new G4Material("NPS_" + Name, density, 1, kStateSolid, 293.15 * kelvin); material->AddElement(U235, 1); m_Material[Name] = material; return material; @@ -341,8 +333,7 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, G4Isotope* isotope = new G4Isotope("238U", 92, 238); U238->AddIsotope(isotope, 1); - G4Material* material = new G4Material("NPS_" + Name, density, 1, - kStateSolid, 293.15 * kelvin); + G4Material* material = new G4Material("NPS_" + Name, density, 1, kStateSolid, 293.15 * kelvin); material->AddElement(U238, 1); m_Material[Name] = material; return material; @@ -372,8 +363,7 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, isotope = new G4Isotope("160Gd", 64, 160); Gd->AddIsotope(isotope, 0.2186); - G4Material* material = new G4Material("NPS_" + Name, density, 1, - kStateSolid, 293.15 * kelvin); + G4Material* material = new G4Material("NPS_" + Name, density, 1, kStateSolid, 293.15 * kelvin); material->AddElement(Gd, 1); m_Material[Name] = material; return material; @@ -423,28 +413,32 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, material->AddElement(GetElementFromLibrary("H"), 2); m_Material[Name] = material; return material; - } else if (Name == "H2_gas") { + } + else if (Name == "H2_gas") { if (!density) density = 3.34e-11 * g / cm3; G4Material* material = new G4Material("NPS_" + Name, density, 1); material->AddElement(GetElementFromLibrary("H"), 2); m_Material[Name] = material; return material; - } else if (Name == "He_gas") { + } + else if (Name == "He_gas") { if (!density) density = 0.0001665 * g / cm3; // room temp, 1 atm G4Material* material = new G4Material("NPS_" + Name, density, 1); material->AddElement(GetElementFromLibrary("He"), 1); m_Material[Name] = material; return material; - } else if (Name == "O2_gas") { + } + else if (Name == "O2_gas") { if (!density) density = 0.001331 * g / cm3; // room temp, 1 atm G4Material* material = new G4Material("NPS_" + Name, density, 1); material->AddElement(GetElementFromLibrary("O"), 2); m_Material[Name] = material; return material; - } else if (Name == "Ti") { + } + else if (Name == "Ti") { if (!density) density = 4.5189 * g / cm3; G4Material* material = new G4Material("NPS_" + Name, density, 1); @@ -461,7 +455,7 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, material->AddElement(GetElementFromLibrary("O"), 1); m_Material[Name] = material; return material; - } + } else if (Name == "mixMINOS") { // cyril if (!density) density = 0.0019836 * g / cm3; @@ -471,7 +465,7 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, material->AddElement(GetElementFromLibrary("Ar"), .82); m_Material[Name] = material; return material; - } + } else if (Name == "mumetal") { // cyril if (!density) density = 8.7 * g / cm3; @@ -481,14 +475,16 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, material->AddElement(GetElementFromLibrary("Mo"), .05); m_Material[Name] = material; return material; - } else if (Name == "LH2") { // cyril + } + else if (Name == "LH2") { // cyril if (!density) density = 0.07293 * g / cm3; G4Material* material = new G4Material("NPS_" + Name, density, 1); material->AddElement(GetElementFromLibrary("H"), 2); m_Material[Name] = material; return material; - } else if (Name == "Rohacell") { // cyril + } + else if (Name == "Rohacell") { // cyril if (!density) density = 0.075 * g / cm3; G4Material* material = new G4Material("NPS_" + Name, density, 4); @@ -508,15 +504,15 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, material->AddElement(GetElementFromLibrary("Si"), 1); // Adding Optical property: - double* energy_r = new double[2]; - double* rindex = new double[2]; + double* energy_r = new double[2]; + double* rindex = new double[2]; double* absorption = new double[2]; energy_r[0] = 1 * eV; energy_r[1] = 1 * MeV; - rindex[0] = 1; - rindex[1] = 1; + rindex[0] = 1; + rindex[1] = 1; absorption[0] = 1 * um; absorption[1] = 1 * um; @@ -596,23 +592,23 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, else if (Name == "para-Terphenyl_Scintillator") { if (!density) - density = 1.23 * g / cm3; // good + density = 1.23 * g / cm3; // good G4Material* material = new G4Material("NPS_" + Name, density, 2); // check - material->AddElement(GetElementFromLibrary("H"), 14); // good - material->AddElement(GetElementFromLibrary("C"), 18); // good + material->AddElement(GetElementFromLibrary("H"), 14); // good + material->AddElement(GetElementFromLibrary("C"), 18); // good // Adding Scintillation property: - int NumberOfPoints = 10; // check - double wlmin = 0.25 * um; // check - double wlmax = 67 * um; // check - double step = (wlmax - wlmin) / NumberOfPoints; - double* energy_r = new double[NumberOfPoints]; - double* rindex = new double[NumberOfPoints]; - double* absorption = new double[NumberOfPoints]; + int NumberOfPoints = 10; // check + double wlmin = 0.25 * um; // check + double wlmax = 67 * um; // check + double step = (wlmax - wlmin) / NumberOfPoints; + double* energy_r = new double[NumberOfPoints]; + double* rindex = new double[NumberOfPoints]; + double* absorption = new double[NumberOfPoints]; double* energy_e = new double[5]; - double* fast = new double[5]; - double* slow = new double[5]; - double* scint = new double[5]; + double* fast = new double[5]; + double* slow = new double[5]; + double* scint = new double[5]; // check block below energy_e[0] = h_Planck * c_light / (450 * nm); @@ -624,7 +620,7 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, for (int i = 0; i < 5; i++) { // fast[0] = 1 ; fast[1]=1; // slow[0] = 1 ; slow[1]=1; - fast[i] = 2.1; // good + fast[i] = 2.1; // good slow[i] = 22.6; // check } // check below block @@ -640,14 +636,10 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, for (int i = 0; i < NumberOfPoints; i++) { wl = wlmin + i * step; // Formula from www.refractiveindex.info - rindex[i] = sqrt(1 + 0.27587 + 0.68689 / (1 - pow(0.130 / wl, 2)) - + 0.26090 / (1 - pow(0.147 / wl, 2)) - + 0.06256 / (1 - pow(0.163 / wl, 2)) - + 0.06527 / (1 - pow(0.177 / wl, 2)) - + 0.14991 / (1 - pow(0.185 / wl, 2)) - + 0.51818 / (1 - pow(0.206 / wl, 2)) - + 0.01918 / (1 - pow(0.218 / wl, 2)) - + 3.38229 / (1 - pow(161.29 / wl, 2))); + rindex[i] = sqrt(1 + 0.27587 + 0.68689 / (1 - pow(0.130 / wl, 2)) + 0.26090 / (1 - pow(0.147 / wl, 2)) + + 0.06256 / (1 - pow(0.163 / wl, 2)) + 0.06527 / (1 - pow(0.177 / wl, 2)) + + 0.14991 / (1 - pow(0.185 / wl, 2)) + 0.51818 / (1 - pow(0.206 / wl, 2)) + + 0.01918 / (1 - pow(0.218 / wl, 2)) + 3.38229 / (1 - pow(161.29 / wl, 2))); // check below block energy_r[i] = h_Planck * c_light / wl; // To be defined properly @@ -657,19 +649,19 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, G4MaterialPropertiesTable* MPT = new G4MaterialPropertiesTable(); // From St Gobain - MPT->AddConstProperty("SCINTILLATIONYIELD", 27000000 / keV); // good - MPT->AddProperty("SCINTILLATION", energy_e, scint, 5); // check + MPT->AddConstProperty("SCINTILLATIONYIELD", 27000000 / keV); // good + MPT->AddProperty("SCINTILLATION", energy_e, scint, 5); // check MPT->AddProperty("RINDEX", energy_r, rindex, NumberOfPoints); // check MPT->AddProperty("ABSLENGTH", energy_r, absorption, - NumberOfPoints); // check + NumberOfPoints); // check MPT->AddProperty("FASTCOMPONENT", energy_e, fast, 5); // good MPT->AddProperty("SLOWCOMPONENT", energy_e, slow, 5); // good - MPT->AddConstProperty("RESOLUTIONSCALE", 1.0); // check + MPT->AddConstProperty("RESOLUTIONSCALE", 1.0); // check MPT->AddConstProperty("FASTTIMECONSTANT", 1000 * ns); // check MPT->AddConstProperty("SLOWTIMECONSTANT", 1000 * ns); // check - MPT->AddConstProperty("YIELDRATIO", 1.0); // check - material->SetMaterialPropertiesTable(MPT); // good - m_Material[Name] = material; // good + MPT->AddConstProperty("YIELDRATIO", 1.0); // check + material->SetMaterialPropertiesTable(MPT); // good + m_Material[Name] = material; // good return material; } @@ -742,18 +734,18 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, material->AddElement(GetElementFromLibrary("Cs"), 1); material->AddElement(GetElementFromLibrary("I"), 1); // Adding Scintillation property: - int NumberOfPoints = 10; - double wlmin = 0.25 * um; - double wlmax = 67 * um; - double step = (wlmax - wlmin) / NumberOfPoints; - double* energy_r = new double[NumberOfPoints]; - double* rindex = new double[NumberOfPoints]; - double* absorption = new double[NumberOfPoints]; + int NumberOfPoints = 10; + double wlmin = 0.25 * um; + double wlmax = 67 * um; + double step = (wlmax - wlmin) / NumberOfPoints; + double* energy_r = new double[NumberOfPoints]; + double* rindex = new double[NumberOfPoints]; + double* absorption = new double[NumberOfPoints]; double* energy_e = new double[5]; - double* fast = new double[5]; - double* slow = new double[5]; - double* scint = new double[5]; + double* fast = new double[5]; + double* slow = new double[5]; + double* scint = new double[5]; energy_e[0] = h_Planck * c_light / (450 * nm); energy_e[1] = h_Planck * c_light / (500 * nm); @@ -778,14 +770,10 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, for (int i = 0; i < NumberOfPoints; i++) { wl = wlmin + i * step; // Formula from www.refractiveindex.info - rindex[i] = sqrt(1 + 0.27587 + 0.68689 / (1 - pow(0.130 / wl, 2)) - + 0.26090 / (1 - pow(0.147 / wl, 2)) - + 0.06256 / (1 - pow(0.163 / wl, 2)) - + 0.06527 / (1 - pow(0.177 / wl, 2)) - + 0.14991 / (1 - pow(0.185 / wl, 2)) - + 0.51818 / (1 - pow(0.206 / wl, 2)) - + 0.01918 / (1 - pow(0.218 / wl, 2)) - + 3.38229 / (1 - pow(161.29 / wl, 2))); + rindex[i] = sqrt(1 + 0.27587 + 0.68689 / (1 - pow(0.130 / wl, 2)) + 0.26090 / (1 - pow(0.147 / wl, 2)) + + 0.06256 / (1 - pow(0.163 / wl, 2)) + 0.06527 / (1 - pow(0.177 / wl, 2)) + + 0.14991 / (1 - pow(0.185 / wl, 2)) + 0.51818 / (1 - pow(0.206 / wl, 2)) + + 0.01918 / (1 - pow(0.218 / wl, 2)) + 3.38229 / (1 - pow(161.29 / wl, 2))); energy_r[i] = h_Planck * c_light / wl; // To be defined properly @@ -823,7 +811,7 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, else if (Name == "LaBr3_Ce") { if (!density) density = 5.29 * g / cm3; - G4Material* base = GetMaterialFromLibrary("LaBr3"); + G4Material* base = GetMaterialFromLibrary("LaBr3"); G4Material* material = new G4Material("NPS_" + Name, density, 2); material->AddMaterial(base, 95 * perCent); material->AddElement(GetElementFromLibrary("Ce"), 5 * perCent); @@ -856,8 +844,6 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, return material; } - - else if (Name == "BaF2") { if (!density) density = 4.89 * g / cm3; @@ -917,8 +903,7 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, else if (Name == "P10_1atm") { if (!density) density = 1.74 * mg / cm3; - G4Material* material - = new G4Material("NPS_" + Name, density, 3); //@ 0K, 1 atm + G4Material* material = new G4Material("NPS_" + Name, density, 3); //@ 0K, 1 atm material->AddElement(GetElementFromLibrary("Ar"), 0.9222); material->AddElement(GetElementFromLibrary("C"), 0.0623); material->AddElement(GetElementFromLibrary("H"), 0.0155); @@ -929,8 +914,7 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, else if (Name == "P10") { if (!density) density = 0.57 * mg / cm3; - G4Material* material - = new G4Material("NPS_" + Name, density, 3); //@ 0K, 1/3 atm + G4Material* material = new G4Material("NPS_" + Name, density, 3); //@ 0K, 1/3 atm material->AddElement(GetElementFromLibrary("Ar"), 0.9222); material->AddElement(GetElementFromLibrary("C"), 0.0623); material->AddElement(GetElementFromLibrary("H"), 0.0155); @@ -949,7 +933,7 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, } else if (Name == "iC4H10" || Name == "Isobutane" || Name == "isobutane") { - density = 0.002506 * g / cm3; + density = 0.002506 * g / cm3; G4Material* material = new G4Material("NPS_" + Name, density, 2); material->AddElement(GetElementFromLibrary("C"), 4); material->AddElement(GetElementFromLibrary("H"), 10); @@ -960,8 +944,7 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, else if (Name == "CF4") { // 52 torr if (!density) density = 3.78 * mg / cm3; - G4Material* material = new G4Material("NPS_" + Name, density, 2, - kStateGas, 300, 0.0693276 * bar); + G4Material* material = new G4Material("NPS_" + Name, density, 2, kStateGas, 300, 0.0693276 * bar); material->AddElement(GetElementFromLibrary("C"), 1); material->AddElement(GetElementFromLibrary("F"), 4); material->GetIonisation()->SetMeanExcitationEnergy(20.0 * eV); @@ -1017,17 +1000,13 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, //--------------------- PMMA optical Properties ---------------------// const G4int NUMENTRIES = 15; - G4double PMMA_PP[NUMENTRIES] - = {10 * eV, 3.25 * eV, 3.099 * eV, 2.88 * eV, 2.695 * eV, - 2.53 * eV, 2.38 * eV, 2.254 * eV, 2.138 * eV, 2.033 * eV, - 1.937 * eV, 1.859 * eV, 1.771 * eV, 1.6 * eV, 0 * eV}; - G4double PMMA_RIND[NUMENTRIES] - = {1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, - 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47}; - G4double PMMA_ABSL[NUMENTRIES] - = {35. * cm, 35. * cm, 35. * cm, 35. * cm, 35. * cm, - 35. * cm, 35. * cm, 35. * cm, 35. * cm, 35. * cm, - 35. * cm, 35. * cm, 35. * cm, 35. * cm, 35. * cm}; + G4double PMMA_PP[NUMENTRIES] = {10 * eV, 3.25 * eV, 3.099 * eV, 2.88 * eV, 2.695 * eV, + 2.53 * eV, 2.38 * eV, 2.254 * eV, 2.138 * eV, 2.033 * eV, + 1.937 * eV, 1.859 * eV, 1.771 * eV, 1.6 * eV, 0 * eV}; + G4double PMMA_RIND[NUMENTRIES] = {1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, + 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47}; + G4double PMMA_ABSL[NUMENTRIES] = {35. * cm, 35. * cm, 35. * cm, 35. * cm, 35. * cm, 35. * cm, 35. * cm, 35. * cm, + 35. * cm, 35. * cm, 35. * cm, 35. * cm, 35. * cm, 35. * cm, 35. * cm}; G4MaterialPropertiesTable* myMPT2 = new G4MaterialPropertiesTable(); myMPT2->AddProperty("RINDEX", PMMA_PP, PMMA_RIND, NUMENTRIES); @@ -1043,9 +1022,9 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, if (!density) density = 2.71 * g / cm3; G4Material* material = new G4Material("NPS_" + Name, density, 2); - material->AddElement(GetElementFromLibrary("Al"), 99.5/100.); + material->AddElement(GetElementFromLibrary("Al"), 99.5 / 100.); // To get to 100% - material->AddElement(GetElementFromLibrary("Fe"), 0.5/100.); + material->AddElement(GetElementFromLibrary("Fe"), 0.5 / 100.); // Not 100% from wiki... // material->AddElement(GetElementFromLibrary("Cu"), 0.05/100.); // material->AddElement(GetElementFromLibrary("Fe"), 0.4/100.); @@ -1063,9 +1042,9 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, if (!density) density = 2.67 * g / cm3; G4Material* material = new G4Material("NPS_" + Name, density, 2); - //Realistic - material->AddElement(GetElementFromLibrary("Al"), 97/100.); - material->AddElement(GetElementFromLibrary("Mg"), 3/100.); + // Realistic + material->AddElement(GetElementFromLibrary("Al"), 97 / 100.); + material->AddElement(GetElementFromLibrary("Mg"), 3 / 100.); // Not 100% from Wiki... // material->AddElement(GetElementFromLibrary("Al"), 97.4/100.); // material->AddElement(GetElementFromLibrary("Cr"), 0.3/100.); @@ -1080,7 +1059,6 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, return material; } - else if (Name == "NE213") { if (!density) density = 0.874 * g / cm3; @@ -1101,22 +1079,16 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, //--------------------- Optical Properties ---------------------// const G4int NUMENTRIES = 15; - G4double CsI_PP[NUMENTRIES] - = {10 * eV, 3.5 * eV, 3.25 * eV, 3.2 * eV, 3.15 * eV, - 3.099 * eV, 3.0 * eV, 2.95 * eV, 2.88 * eV, 2.75 * eV, - 2.695 * eV, 2.53 * eV, 2.38 * eV, 2.30 * eV, 0 * eV}; - - G4double CsI_SCINT[NUMENTRIES] - = {0.0, 0.0, 0.1, 0.2, 0.4, 0.65, 0.8, 0.95, - 0.82, 0.7, 0.5, 0.21, 0.05, 0, 0}; - - G4double CsI_RIND[NUMENTRIES] - = {1.505, 1.505, 1.505, 1.505, 1.505, 1.505, 1.505, 1.505, - 1.505, 1.505, 1.505, 1.505, 1.505, 1.505, 1.505}; - G4double CsI_ABSL[NUMENTRIES] - = {1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m, - 1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m, - 1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m}; + G4double CsI_PP[NUMENTRIES] = {10 * eV, 3.5 * eV, 3.25 * eV, 3.2 * eV, 3.15 * eV, + 3.099 * eV, 3.0 * eV, 2.95 * eV, 2.88 * eV, 2.75 * eV, + 2.695 * eV, 2.53 * eV, 2.38 * eV, 2.30 * eV, 0 * eV}; + + G4double CsI_SCINT[NUMENTRIES] = {0.0, 0.0, 0.1, 0.2, 0.4, 0.65, 0.8, 0.95, 0.82, 0.7, 0.5, 0.21, 0.05, 0, 0}; + + G4double CsI_RIND[NUMENTRIES] = {1.505, 1.505, 1.505, 1.505, 1.505, 1.505, 1.505, 1.505, + 1.505, 1.505, 1.505, 1.505, 1.505, 1.505, 1.505}; + G4double CsI_ABSL[NUMENTRIES] = {1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m, + 1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m}; G4MaterialPropertiesTable* myMPT1 = new G4MaterialPropertiesTable(); myMPT1->AddProperty("RINDEX", CsI_PP, CsI_RIND, NUMENTRIES); /// Constant? @@ -1141,13 +1113,12 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, else { cout << "INFO: trying to get " << Name << " material from NIST" << endl; - G4NistManager* man = G4NistManager::Instance(); - G4Material* material = man->FindOrBuildMaterial(Name.c_str()); - m_Material[Name] = material; + G4NistManager* man = G4NistManager::Instance(); + G4Material* material = man->FindOrBuildMaterial(Name.c_str()); + m_Material[Name] = material; material->SetName("NPS_" + material->GetName()); if (!material) { - cout << "ERROR: Material requested \"" << Name - << "\" is not available in the nptool material library or NIST" + cout << "ERROR: Material requested \"" << Name << "\" is not available in the nptool material library or NIST" << endl; exit(1); } @@ -1162,17 +1133,14 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void MaterialManager::AddMaterialToLibrary(G4Material* material) { - m_Material[material->GetName()] = material; -} +void MaterialManager::AddMaterialToLibrary(G4Material* material) { m_Material[material->GetName()] = material; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4Element* MaterialManager::GetElementFromLibrary(string Name) { if (Name == "D" || Name == "d") { if (!m_D) { m_D = new G4Element(Name.c_str(), Name.c_str(), 1); - G4Isotope* isotope - = new G4Isotope(Name.c_str(), 1, 2, 2.01410178 * g / mole); + G4Isotope* isotope = new G4Isotope(Name.c_str(), 1, 2, 2.01410178 * g / mole); m_D->AddIsotope(isotope, 1); } return m_D; @@ -1181,8 +1149,7 @@ G4Element* MaterialManager::GetElementFromLibrary(string Name) { else if (Name == "T" || Name == "t") { if (!m_T) { m_T = new G4Element(Name.c_str(), Name.c_str(), 1); - G4Isotope* isotope - = new G4Isotope(Name.c_str(), 1, 3, 3.0160492 * g / mole); + G4Isotope* isotope = new G4Isotope(Name.c_str(), 1, 3, 3.0160492 * g / mole); m_T->AddIsotope(isotope, 1); } return m_T; @@ -1191,8 +1158,7 @@ G4Element* MaterialManager::GetElementFromLibrary(string Name) { else if (Name == "He3" || Name == "3He") { if (!m_He3) { m_He3 = new G4Element(Name.c_str(), Name.c_str(), 1); - G4Isotope* isotope - = new G4Isotope(Name.c_str(), 2, 1, 3.0160293 * g / mole); + G4Isotope* isotope = new G4Isotope(Name.c_str(), 2, 1, 3.0160293 * g / mole); m_He3->AddIsotope(isotope, 1); } return m_He3; @@ -1204,11 +1170,10 @@ G4Element* MaterialManager::GetElementFromLibrary(string Name) { //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // -G4Material* MaterialManager::GetGasFromLibrary(string Name, double Pressure, - double Temperature) { +G4Material* MaterialManager::GetGasFromLibrary(string Name, double Pressure, double Temperature) { ostringstream oss; oss << Name << "_" << Pressure << "_" << Temperature; - string newName = oss.str(); + string newName = oss.str(); map<string, G4Material*>::iterator it; it = m_Material.find(Name); @@ -1219,12 +1184,11 @@ G4Material* MaterialManager::GetGasFromLibrary(string Name, double Pressure, // The element is not found if (it == m_Material.end()) { if (Name == "CF4") { // 52 torr - density = 3.72 * kg / m3; + density = 3.72 * kg / m3; double refTemp = (273.15 + 15) * kelvin; double refPres = 1.01325 * bar; - density = density * (refTemp / Temperature) / (refPres / Pressure); - G4Material* material = new G4Material("NPS_" + newName, density, 2, - kStateGas, Temperature, Pressure); + density = density * (refTemp / Temperature) / (refPres / Pressure); + G4Material* material = new G4Material("NPS_" + newName, density, 2, kStateGas, Temperature, Pressure); material->AddElement(GetElementFromLibrary("C"), 1); material->AddElement(GetElementFromLibrary("F"), 4); m_Material[newName] = material; @@ -1232,18 +1196,16 @@ G4Material* MaterialManager::GetGasFromLibrary(string Name, double Pressure, } if (Name == "He") { - density = (4.0026 / Vm) * mg / cm3; - G4Material* material = new G4Material("NPS_" + newName, density, 1, - kStateGas, Temperature, Pressure); + density = (4.0026 / Vm) * mg / cm3; + G4Material* material = new G4Material("NPS_" + newName, density, 1, kStateGas, Temperature, Pressure); material->AddElement(GetElementFromLibrary("He"), 1); m_Material[newName] = material; return material; } if (Name == "iC4H10" || Name == "Isobutane" || Name == "isobutane") { - density = ((4 * 12.0107 + 10 * 1.00794) / Vm) * mg / cm3; - G4Material* material = new G4Material("NPS_" + newName, density, 2, - kStateGas, Temperature, Pressure); + density = ((4 * 12.0107 + 10 * 1.00794) / Vm) * mg / cm3; + G4Material* material = new G4Material("NPS_" + newName, density, 2, kStateGas, Temperature, Pressure); material->AddElement(GetElementFromLibrary("C"), 4); material->AddElement(GetElementFromLibrary("H"), 10); m_Material[newName] = material; @@ -1251,9 +1213,8 @@ G4Material* MaterialManager::GetGasFromLibrary(string Name, double Pressure, } if (Name == "CH4") { - density = ((12.0107 + 4 * 1.00794) / Vm) * mg / cm3; - G4Material* material = new G4Material("NPS_" + newName, density, 2, - kStateGas, Temperature, Pressure); + density = ((12.0107 + 4 * 1.00794) / Vm) * mg / cm3; + G4Material* material = new G4Material("NPS_" + newName, density, 2, kStateGas, Temperature, Pressure); material->AddElement(GetElementFromLibrary("C"), 1); material->AddElement(GetElementFromLibrary("H"), 4); m_Material[newName] = material; @@ -1261,9 +1222,8 @@ G4Material* MaterialManager::GetGasFromLibrary(string Name, double Pressure, } if (Name == "P80") { - density = ((0.2*36 + 0.8*(12.0107 + 4 * 1.00794) )/ Vm) * mg / cm3; - G4Material* material = new G4Material("NPS_" + newName, density, 3, - kStateGas, Temperature, Pressure); + density = ((0.2 * 36 + 0.8 * (12.0107 + 4 * 1.00794)) / Vm) * mg / cm3; + G4Material* material = new G4Material("NPS_" + newName, density, 3, kStateGas, Temperature, Pressure); material->AddElement(GetElementFromLibrary("Ar"), 0.2); material->AddElement(GetElementFromLibrary("C"), 0.64); material->AddElement(GetElementFromLibrary("H"), 0.16); @@ -1271,11 +1231,9 @@ G4Material* MaterialManager::GetGasFromLibrary(string Name, double Pressure, return material; } - if (Name == "CO2") { - density = ((12.0107 + 2 * 16) / Vm) * mg / cm3; - G4Material* material = new G4Material("NPS_" + newName, density, 2, - kStateGas, Temperature, Pressure); + density = ((12.0107 + 2 * 16) / Vm) * mg / cm3; + G4Material* material = new G4Material("NPS_" + newName, density, 2, kStateGas, Temperature, Pressure); material->AddElement(GetElementFromLibrary("C"), 1); material->AddElement(GetElementFromLibrary("O"), 2); m_Material[newName] = material; @@ -1283,9 +1241,8 @@ G4Material* MaterialManager::GetGasFromLibrary(string Name, double Pressure, } if (Name == "H2") { - density = (2 * 1.00794 / Vm) * mg / cm3; - G4Material* material = new G4Material("NPS_" + newName, density, 1, - kStateGas, Temperature, Pressure); + density = (2 * 1.00794 / Vm) * mg / cm3; + G4Material* material = new G4Material("NPS_" + newName, density, 1, kStateGas, Temperature, Pressure); material->AddElement(GetElementFromLibrary("H"), 2); // material->AddElement(GetElementFromLibrary("H"), 1); m_Material[newName] = material; @@ -1293,27 +1250,25 @@ G4Material* MaterialManager::GetGasFromLibrary(string Name, double Pressure, } if (Name == "D2") { - density = (2 * 2.0140 / Vm) * mg / cm3; - G4Material* material = new G4Material("NPS_" + newName, density, 1, - kStateGas, Temperature, Pressure); + density = (2 * 2.0140 / Vm) * mg / cm3; + G4Material* material = new G4Material("NPS_" + newName, density, 1, kStateGas, Temperature, Pressure); material->AddElement(GetElementFromLibrary("D"), 2); // material->AddElement(GetElementFromLibrary("D"), 1); m_Material[newName] = material; return material; } - if (Name == "MixTwinMusic") { - density = ((0.01*(12.0107 + 2*16.) + 0.2*36 + 0.79*(12.0107 + 4 * 1.00794) )/ Vm) * mg / cm3; - G4Material* material = new G4Material("NPS_" + newName, density, 3, - kStateGas, Temperature, Pressure); - - material->AddMaterial(GetGasFromLibrary("CH4",Pressure,Temperature),0.79); - material->AddMaterial(GetGasFromLibrary("CO2",Pressure,Temperature),0.01); + if (Name == "MixTwinMusic") { + density = ((0.01 * (12.0107 + 2 * 16.) + 0.2 * 36 + 0.79 * (12.0107 + 4 * 1.00794)) / Vm) * mg / cm3; + G4Material* material = new G4Material("NPS_" + newName, density, 3, kStateGas, Temperature, Pressure); + + material->AddMaterial(GetGasFromLibrary("CH4", Pressure, Temperature), 0.79); + material->AddMaterial(GetGasFromLibrary("CO2", Pressure, Temperature), 0.01); material->AddElement(GetElementFromLibrary("Ar"), .20); m_Material[Name] = material; return material; - } - + } + else { exit(1); } @@ -1323,19 +1278,18 @@ G4Material* MaterialManager::GetGasFromLibrary(string Name, double Pressure, //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Generate a DEDX file table using the material used in the geometry -void MaterialManager::WriteDEDXTable(G4ParticleDefinition* Particle, - G4double Emin, G4double Emax) { +void MaterialManager::WriteDEDXTable(G4ParticleDefinition* Particle, G4double Emin, G4double Emax) { map<string, G4Material*>::iterator it; if (Particle->GetPDGCharge() == 0) return; for (it = m_Material.begin(); it != m_Material.end(); it++) { // Opening hte output file - G4String GlobalPath =NPOptionManager::getInstance()->GetEnergyLossPath(); - G4String Name = it->second->GetName(); + G4String GlobalPath = NPOptionManager::getInstance()->GetEnergyLossPath(); + G4String Name = it->second->GetName(); // Remove NPS name Name.erase(0, 4); - G4String Path = GlobalPath +"/"+ Particle->GetParticleName() + "_" + Name + ".G4table"; + G4String Path = GlobalPath + "/" + Particle->GetParticleName() + "_" + Name + ".G4table"; ofstream File; File.open(Path); @@ -1344,22 +1298,20 @@ void MaterialManager::WriteDEDXTable(G4ParticleDefinition* Particle, return; File << "Table from Geant4 generate using NPSimulation \t" - << "Particle: " << Particle->GetParticleName() - << "\tMaterial: " << it->second->GetName() << G4endl; + << "Particle: " << Particle->GetParticleName() << "\tMaterial: " << it->second->GetName() << G4endl; // G4cout << Particle->GetParticleName() << "\tMaterial: " << // it->second->GetName() <<endl; G4EmCalculator emCalculator; - G4double dedx; + G4double dedx; // Tipical Range needed, if Emax is larger, then adapted if (Emax < 1 * TeV) Emax = 1 * TeV; - double step = 1 * keV; + double step = 1 * keV; double before = 0; for (G4double E = Emin; E < Emax; E += step) { - dedx = emCalculator.ComputeTotalDEDX(E, Particle, it->second) - / (MeV / micrometer); + dedx = emCalculator.ComputeTotalDEDX(E, Particle, it->second) / (MeV / micrometer); if (before) { if (abs(before - dedx) / abs(before) < 0.01) step *= 2; @@ -1374,20 +1326,17 @@ void MaterialManager::WriteDEDXTable(G4ParticleDefinition* Particle, } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Generate a DEDX file table using the material used in the geometry -void MaterialManager::WriteDEDXTable(std::set<string> Particle, G4double Emin, - G4double Emax) { +void MaterialManager::WriteDEDXTable(std::set<string> Particle, G4double Emin, G4double Emax) { std::set<string>::iterator it; for (it = Particle.begin(); it != Particle.end(); it++) { - G4ParticleDefinition* p - = G4ParticleTable::GetParticleTable()->FindParticle((*it)); + G4ParticleDefinition* p = G4ParticleTable::GetParticleTable()->FindParticle((*it)); WriteDEDXTable(p, Emin, Emax); } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Generate Cross Section table using the material used in the geomtry -void MaterialManager::WriteCrossSectionTable(G4ParticleDefinition* Particle, - G4double Emin, G4double Emax) { +void MaterialManager::WriteCrossSectionTable(G4ParticleDefinition* Particle, G4double Emin, G4double Emax) { G4HadronicProcessStore* store = G4HadronicProcessStore::Instance(); map<string, G4Material*>::iterator it; @@ -1404,16 +1353,12 @@ void MaterialManager::WriteCrossSectionTable(G4ParticleDefinition* Particle, G4String path4; G4String ParticleName = Particle->GetParticleName(); G4String MaterialName = it->second->GetName(); - G4String ElementName = it->second->GetElement(i)->GetName(); + G4String ElementName = it->second->GetElement(i)->GetName(); - path1 = GlobalPath + "/Inputs/CrossSection/" + "G4XS_elastic_" - + ParticleName + "_" + ElementName + ".dat"; - path2 = GlobalPath + "/Inputs/CrossSection/" + "G4XS_inelastic_" - + ParticleName + "_" + ElementName + ".dat"; - path3 = GlobalPath + "/Inputs/CrossSection/" + "G4XS_capture_" - + ParticleName + "_" + ElementName + ".dat"; - path4 = GlobalPath + "/Inputs/CrossSection/" + "G4XS_fission_" - + ParticleName + "_" + ElementName + ".dat"; + path1 = GlobalPath + "/Inputs/CrossSection/" + "G4XS_elastic_" + ParticleName + "_" + ElementName + ".dat"; + path2 = GlobalPath + "/Inputs/CrossSection/" + "G4XS_inelastic_" + ParticleName + "_" + ElementName + ".dat"; + path3 = GlobalPath + "/Inputs/CrossSection/" + "G4XS_capture_" + ParticleName + "_" + ElementName + ".dat"; + path4 = GlobalPath + "/Inputs/CrossSection/" + "G4XS_fission_" + ParticleName + "_" + ElementName + ".dat"; ofstream ofile_elastic; ofstream ofile_inelastic; @@ -1426,7 +1371,7 @@ void MaterialManager::WriteCrossSectionTable(G4ParticleDefinition* Particle, // std::cout << path << std::endl; double xs; double step_keV = 1 * keV; - double step_eV = 1 * eV; + double step_eV = 1 * eV; double step_meV = 50e-3 * eV; // for(G4double E=Emin+step; E<Emax; E+=step){ double E = Emin; @@ -1441,23 +1386,19 @@ void MaterialManager::WriteCrossSectionTable(G4ParticleDefinition* Particle, E += step_keV; if (E > 1 * keV) { // Elastic Cross Section - xs = store->GetElasticCrossSectionPerAtom( - Particle, E, it->second->GetElement(i), it->second); + xs = store->GetElasticCrossSectionPerAtom(Particle, E, it->second->GetElement(i), it->second); ofile_elastic << E / MeV << " " << xs / barn << G4endl; // Inelastic Cross Section - xs = store->GetInelasticCrossSectionPerAtom( - Particle, E, it->second->GetElement(i), it->second); + xs = store->GetInelasticCrossSectionPerAtom(Particle, E, it->second->GetElement(i), it->second); ofile_inelastic << E / MeV << " " << xs / barn << G4endl; } // Capture Cross Section - xs = store->GetCaptureCrossSectionPerAtom( - Particle, E, it->second->GetElement(i), it->second); + xs = store->GetCaptureCrossSectionPerAtom(Particle, E, it->second->GetElement(i), it->second); ofile_capture << E / MeV << " " << xs / barn << G4endl; // Fission Cross Section - xs = store->GetFissionCrossSectionPerAtom( - Particle, E, it->second->GetElement(i), it->second); + xs = store->GetFissionCrossSectionPerAtom(Particle, E, it->second->GetElement(i), it->second); ofile_fission << E / MeV << " " << xs / barn << G4endl; } @@ -1471,12 +1412,10 @@ void MaterialManager::WriteCrossSectionTable(G4ParticleDefinition* Particle, //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Generate Cross Section table using the material used in the geomtry -void MaterialManager::WriteCrossSectionTable(std::set<string> Particle, - G4double Emin, G4double Emax) { +void MaterialManager::WriteCrossSectionTable(std::set<string> Particle, G4double Emin, G4double Emax) { std::set<string>::iterator it; for (it = Particle.begin(); it != Particle.end(); it++) { - G4ParticleDefinition* p - = G4ParticleTable::GetParticleTable()->FindParticle((*it)); + G4ParticleDefinition* p = G4ParticleTable::GetParticleTable()->FindParticle((*it)); if (p->GetParticleName() == "neutron") { WriteCrossSectionTable(p, Emin, Emax); } @@ -1489,20 +1428,17 @@ void MaterialManager::CreateSampleVolumes(G4LogicalVolume* world_log) { // Create a micrometer size cube for each material G4double SampleSize = 1 * um; - G4double WorldSize = 10.0 * m; - G4Box* sample_box - = new G4Box("sample_box", SampleSize, SampleSize, SampleSize); - G4int i = 1; - G4double Coord1 = WorldSize - SampleSize; - G4double Coord2 = 0; + G4double WorldSize = 10.0 * m; + G4Box* sample_box = new G4Box("sample_box", SampleSize, SampleSize, SampleSize); + G4int i = 1; + G4double Coord1 = WorldSize - SampleSize; + G4double Coord2 = 0; map<string, G4Material*>::iterator it; for (it = m_Material.begin(); it != m_Material.end(); it++) { - G4LogicalVolume* sample_log - = new G4LogicalVolume(sample_box, it->second, "sample_log", 0, 0, 0); - sample_log->SetVisAttributes(G4VisAttributes::Invisible); + G4LogicalVolume* sample_log = new G4LogicalVolume(sample_box, it->second, "sample_log", 0, 0, 0); + sample_log->SetVisAttributes(G4VisAttributes::GetInvisible()); Coord2 = WorldSize - i * 2 * SampleSize; i++; - new G4PVPlacement(0, G4ThreeVector(Coord1, Coord2, -Coord1), sample_log, - "sample", world_log, false, 0); + new G4PVPlacement(0, G4ThreeVector(Coord1, Coord2, -Coord1), sample_log, "sample", world_log, false, 0); } } diff --git a/NPSimulation/Detectors/AnnularS1/AnnularS1.cc b/NPSimulation/Detectors/AnnularS1/AnnularS1.cc index fbad5cdbe..78d2bc4b5 100644 --- a/NPSimulation/Detectors/AnnularS1/AnnularS1.cc +++ b/NPSimulation/Detectors/AnnularS1/AnnularS1.cc @@ -21,34 +21,34 @@ *****************************************************************************/ // C++ headers +#include <cmath> #include <sstream> #include <string> -#include <cmath> -// Geant4 +// Geant4 #include "G4Box.hh" -#include "G4Tubs.hh" -#include "G4Material.hh" -#include "G4VisAttributes.hh" #include "G4Colour.hh" -#include "G4RotationMatrix.hh" -#include "G4Transform3D.hh" -#include "G4PVPlacement.hh" -#include "G4PVDivision.hh" #include "G4ExtrudedSolid.hh" -#include "G4SubtractionSolid.hh" -#include "G4SDManager.hh" +#include "G4Material.hh" #include "G4MultiFunctionalDetector.hh" +#include "G4PVDivision.hh" +#include "G4PVPlacement.hh" +#include "G4RotationMatrix.hh" +#include "G4SDManager.hh" +#include "G4SubtractionSolid.hh" +#include "G4Transform3D.hh" +#include "G4Tubs.hh" +#include "G4VisAttributes.hh" // NPTool headers -#include "MaterialManager.hh" -#include "NPSDetectorFactory.hh" #include "AnnularS1.hh" #include "DSSDScorers.hh" #include "InteractionScorers.hh" -#include "TS1Data.h" -#include "RootOutput.h" +#include "MaterialManager.hh" #include "NPOptionManager.h" +#include "NPSDetectorFactory.hh" +#include "RootOutput.h" +#include "TS1Data.h" // CLHEP #include "CLHEP/Random/RandGauss.h" @@ -57,24 +57,21 @@ using namespace CLHEP; using namespace ANNULARS1; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -AnnularS1::AnnularS1(){ +AnnularS1::AnnularS1() { m_Event = new TS1Data(); - m_LogicalDetector = 0 ; + m_LogicalDetector = 0; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -AnnularS1::~AnnularS1(){ -} +AnnularS1::~AnnularS1() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void AnnularS1::AddModule(G4double PosZ){ - m_PosZ.push_back(PosZ); -} +void AnnularS1::AddModule(G4double PosZ) { m_PosZ.push_back(PosZ); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* AnnularS1::ConstructVolume(){ +G4LogicalVolume* AnnularS1::ConstructVolume() { - if(!m_LogicalDetector){ + if (!m_LogicalDetector) { G4Material* Silicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); G4Material* Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); //////////////////////////////////////////////////////////////// @@ -86,139 +83,93 @@ G4LogicalVolume* AnnularS1::ConstructVolume(){ // Building the PCB // The PCB is a simple extruded volume from 8reference point vector<G4TwoVector> polygon; - for(unsigned int i = 0 ; i < 8 ; i++){ - G4TwoVector Point(PCBPointsX[i],PCBPointsY[i]); + for (unsigned int i = 0; i < 8; i++) { + G4TwoVector Point(PCBPointsX[i], PCBPointsY[i]); polygon.push_back(Point); } // Mast volume containing all the detector - G4ExtrudedSolid* solidAnnularS1 = new G4ExtrudedSolid(Name, - polygon, - PCBThickness*0.5, - G4TwoVector(0,0),1, - G4TwoVector(0,0),1); + G4ExtrudedSolid* solidAnnularS1 = + new G4ExtrudedSolid(Name, polygon, PCBThickness * 0.5, G4TwoVector(0, 0), 1, G4TwoVector(0, 0), 1); // Definition of the volume containing the sensitive detector m_LogicalDetector = new G4LogicalVolume(solidAnnularS1, Vacuum, Name, 0, 0, 0); - m_LogicalDetector->SetVisAttributes(G4VisAttributes::Invisible); + m_LogicalDetector->SetVisAttributes(G4VisAttributes::GetInvisible()); // PCB Base - G4ExtrudedSolid* solidPCBBase = new G4ExtrudedSolid("PCBBase", - polygon, - PCBThickness*0.5, - G4TwoVector(0,0),1, - G4TwoVector(0,0),1); + G4ExtrudedSolid* solidPCBBase = + new G4ExtrudedSolid("PCBBase", polygon, PCBThickness * 0.5, G4TwoVector(0, 0), 1, G4TwoVector(0, 0), 1); // Wafer Shape to be substracted to the PCB - G4Tubs* solidWaferShapeBase = new G4Tubs("WaferShape", - 0, - WaferOutterRadius, - PCBThickness, - 0*deg, - 360*deg); + G4Tubs* solidWaferShapeBase = new G4Tubs("WaferShape", 0, WaferOutterRadius, PCBThickness, 0 * deg, 360 * deg); // A no rotation matrix is always handy ;) - G4RotationMatrix* norotation = new G4RotationMatrix(); - // Rotation of the box that make the Si cut - G4RotationMatrix* cutrotation = new G4RotationMatrix(G4ThreeVector(0,0,1),45*deg); - G4ThreeVector cutposition1(80*mm+WaferRCut,0,0); cutposition1.setPhi(45*deg); - G4Transform3D transform1(*cutrotation,cutposition1); - - G4Box* solidCutout = new G4Box("cuttout",80*mm,80*mm,80*mm); + G4RotationMatrix* norotation = new G4RotationMatrix(); + // Rotation of the box that make the Si cut + G4RotationMatrix* cutrotation = new G4RotationMatrix(G4ThreeVector(0, 0, 1), 45 * deg); + G4ThreeVector cutposition1(80 * mm + WaferRCut, 0, 0); + cutposition1.setPhi(45 * deg); + G4Transform3D transform1(*cutrotation, cutposition1); - G4SubtractionSolid* solidWaferShape1 = new G4SubtractionSolid("WaferShape1", - solidWaferShapeBase, - solidCutout, - transform1); + G4Box* solidCutout = new G4Box("cuttout", 80 * mm, 80 * mm, 80 * mm); + G4SubtractionSolid* solidWaferShape1 = + new G4SubtractionSolid("WaferShape1", solidWaferShapeBase, solidCutout, transform1); - G4ThreeVector cutposition2(-80*mm-WaferRCut,0,0); cutposition2.setPhi(-135*deg); - G4Transform3D transform2(*cutrotation,cutposition2); - G4SubtractionSolid* solidWaferShape = new G4SubtractionSolid("WaferShape", - solidWaferShape1, - solidCutout, - transform2); - + G4ThreeVector cutposition2(-80 * mm - WaferRCut, 0, 0); + cutposition2.setPhi(-135 * deg); + G4Transform3D transform2(*cutrotation, cutposition2); + G4SubtractionSolid* solidWaferShape = + new G4SubtractionSolid("WaferShape", solidWaferShape1, solidCutout, transform2); // PCB final - G4SubtractionSolid* solidPCB = new G4SubtractionSolid("AnnularS1_PCB1", - solidPCBBase, - solidWaferShape); + G4SubtractionSolid* solidPCB = new G4SubtractionSolid("AnnularS1_PCB1", solidPCBBase, solidWaferShape); G4LogicalVolume* logicPCB = new G4LogicalVolume(solidPCB, Vacuum, "AnnularS1_PCB", 0, 0, 0); - new G4PVPlacement(G4Transform3D(*norotation, G4ThreeVector()), - logicPCB, - "AnnularS1_PCB", - m_LogicalDetector, - false, - 0); + new G4PVPlacement(G4Transform3D(*norotation, G4ThreeVector()), logicPCB, "AnnularS1_PCB", m_LogicalDetector, false, + 0); - G4VisAttributes* PCBVisAtt = new G4VisAttributes(G4Colour(0.2, 0.5, 0.2)) ; + G4VisAttributes* PCBVisAtt = new G4VisAttributes(G4Colour(0.2, 0.5, 0.2)); logicPCB->SetVisAttributes(PCBVisAtt); - // Wafer itself - G4Tubs* solidWaferBase = new G4Tubs("Wafer", - WaferInnerRadius, - WaferOutterRadius, - 0.5*WaferThickness, - 0*deg, - 360*deg); - - G4SubtractionSolid* solidWafer1 = new G4SubtractionSolid("Wafer1", - solidWaferBase, - solidCutout, - transform1); - - G4SubtractionSolid* solidWafer = new G4SubtractionSolid("Wafer", - solidWafer1, - solidCutout, - transform2); + G4Tubs* solidWaferBase = + new G4Tubs("Wafer", WaferInnerRadius, WaferOutterRadius, 0.5 * WaferThickness, 0 * deg, 360 * deg); + + G4SubtractionSolid* solidWafer1 = new G4SubtractionSolid("Wafer1", solidWaferBase, solidCutout, transform1); + + G4SubtractionSolid* solidWafer = new G4SubtractionSolid("Wafer", solidWafer1, solidCutout, transform2); G4LogicalVolume* logicWafer = new G4LogicalVolume(solidWafer, Silicon, "AnnularS1_Wafer", 0, 0, 0); - new G4PVPlacement(G4Transform3D(*norotation, G4ThreeVector()), - logicWafer, - "AnnularS1_Wafer", - m_LogicalDetector, - false, - 0); + new G4PVPlacement(G4Transform3D(*norotation, G4ThreeVector()), logicWafer, "AnnularS1_Wafer", m_LogicalDetector, + false, 0); - G4VisAttributes* SiVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)) ; - logicWafer->SetVisAttributes(SiVisAtt); + G4VisAttributes* SiVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)); + logicWafer->SetVisAttributes(SiVisAtt); // Active Wafer - G4Tubs* solidActiveWaferBase = new G4Tubs("ActiveWafer", - ActiveWaferInnerRadius, - ActiveWaferOutterRadius, - 0.5*WaferThickness, - 0*deg, - 360*deg); - - - G4ThreeVector activecutposition1(80*mm+ActiveWaferRCut,0,0); activecutposition1.setPhi(45*deg); - G4Transform3D activetransform1(*cutrotation,activecutposition1); - - G4SubtractionSolid* solidActiveWafer1 = new G4SubtractionSolid("ActiveWafer1", - solidActiveWaferBase, - solidCutout, - activetransform1); - - G4ThreeVector activecutposition2(-80*mm-ActiveWaferRCut,0,0); activecutposition2.setPhi(-135*deg); - G4Transform3D activetransform2(*cutrotation,activecutposition2); - - G4SubtractionSolid* solidActiveWafer = new G4SubtractionSolid("ActiveWafer", - solidActiveWafer1, - solidCutout, - activetransform2); - - G4LogicalVolume* logicActiveWafer = new G4LogicalVolume(solidActiveWafer, Silicon, "AnnularS1_ActiveWafer", 0, 0, 0); - new G4PVPlacement(G4Transform3D(*norotation, G4ThreeVector()), - logicActiveWafer, - "AnnularS1_ActiveWafer", - logicWafer, - false, - 0); + G4Tubs* solidActiveWaferBase = new G4Tubs("ActiveWafer", ActiveWaferInnerRadius, ActiveWaferOutterRadius, + 0.5 * WaferThickness, 0 * deg, 360 * deg); + + G4ThreeVector activecutposition1(80 * mm + ActiveWaferRCut, 0, 0); + activecutposition1.setPhi(45 * deg); + G4Transform3D activetransform1(*cutrotation, activecutposition1); + + G4SubtractionSolid* solidActiveWafer1 = + new G4SubtractionSolid("ActiveWafer1", solidActiveWaferBase, solidCutout, activetransform1); + + G4ThreeVector activecutposition2(-80 * mm - ActiveWaferRCut, 0, 0); + activecutposition2.setPhi(-135 * deg); + G4Transform3D activetransform2(*cutrotation, activecutposition2); + + G4SubtractionSolid* solidActiveWafer = + new G4SubtractionSolid("ActiveWafer", solidActiveWafer1, solidCutout, activetransform2); + + G4LogicalVolume* logicActiveWafer = + new G4LogicalVolume(solidActiveWafer, Silicon, "AnnularS1_ActiveWafer", 0, 0, 0); + new G4PVPlacement(G4Transform3D(*norotation, G4ThreeVector()), logicActiveWafer, "AnnularS1_ActiveWafer", + logicWafer, false, 0); logicActiveWafer->SetVisAttributes(SiVisAtt); @@ -226,7 +177,6 @@ G4LogicalVolume* AnnularS1::ConstructVolume(){ logicActiveWafer->SetSensitiveDetector(m_Scorer); } return m_LogicalDetector; - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -237,19 +187,19 @@ G4LogicalVolume* AnnularS1::ConstructVolume(){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void AnnularS1::ReadConfiguration(NPL::InputParser parser){ - vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("AnnularS1"); - cout << "//// " << blocks.size() << " detectors found " << endl; +void AnnularS1::ReadConfiguration(NPL::InputParser parser) { + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("AnnularS1"); + cout << "//// " << blocks.size() << " detectors found " << endl; vector<string> token = {"Z"}; - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(token)){ - double Z = blocks[i]->GetDouble("Z","mm"); + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(token)) { + double Z = blocks[i]->GetDouble("Z", "mm"); AddModule(Z); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } @@ -259,11 +209,11 @@ void AnnularS1::ReadConfiguration(NPL::InputParser parser){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void AnnularS1::ConstructDetector(G4LogicalVolume* world){ +void AnnularS1::ConstructDetector(G4LogicalVolume* world) { G4RotationMatrix* rotation = NULL; - G4ThreeVector position = G4ThreeVector(0, 0, 0); + G4ThreeVector position = G4ThreeVector(0, 0, 0); - G4int NumberOfModule = m_PosZ.size() ; + G4int NumberOfModule = m_PosZ.size(); for (G4int i = 0; i < NumberOfModule; i++) { // translation to position the module @@ -272,85 +222,80 @@ void AnnularS1::ConstructDetector(G4LogicalVolume* world){ // Passage Matrix from Lab Referential to Module Referential // Identity matrix by default rotation = new G4RotationMatrix(); - if (position.z() < 0) rotation->rotateX(180*deg); - - new G4PVPlacement(G4Transform3D(*rotation, position), - ConstructVolume(), - "AnnularS1", - world, - false, - i+1); + if (position.z() < 0) + rotation->rotateX(180 * deg); + + new G4PVPlacement(G4Transform3D(*rotation, position), ConstructVolume(), "AnnularS1", world, false, i + 1); } - delete rotation ; + delete rotation; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Connect the GaspardTrackingData class to the output TTree // of the simulation -void AnnularS1::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("AnnularS1")){ +void AnnularS1::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("AnnularS1")) { pTree->Branch("AnnularS1", "TS1Data", &m_Event); } - pTree->SetBranchAddress("AnnularS1",&m_Event); + pTree->SetBranchAddress("AnnularS1", &m_Event); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void AnnularS1::ReadSensitive(const G4Event*){ +void AnnularS1::ReadSensitive(const G4Event*) { // Clear ROOT objects m_Event->Clear(); - DSSDScorers::PS_Annular* Scorer= (DSSDScorers::PS_Annular*) m_Scorer->GetPrimitive(0); - + DSSDScorers::PS_Annular* Scorer = (DSSDScorers::PS_Annular*)m_Scorer->GetPrimitive(0); + // Loop on Silicon Ring Hit unsigned int sizeRing = Scorer->GetRingMult(); - for(unsigned int i = 0 ; i < sizeRing ; i++){ + for (unsigned int i = 0; i < sizeRing; i++) { double Energy = Scorer->GetEnergyRing(i); - if(Energy>EnergyThreshold){ - double Time = Scorer->GetTimeRing(i); - unsigned int DetNbr = Scorer->GetDetectorRing(i);; - unsigned int StripTheta = Scorer->GetStripRing(i); - - + if (Energy > EnergyThreshold) { + double Time = Scorer->GetTimeRing(i); + unsigned int DetNbr = Scorer->GetDetectorRing(i); + ; + unsigned int StripTheta = Scorer->GetStripRing(i); + // Check for associated Quadrant strip int StripQuadrant = 0; unsigned int sizeQ = Scorer->GetQuadrantMult(); - for(unsigned int q = 0 ; q < sizeQ ; q++){ - if(Scorer->GetDetectorQuadrant(q)==DetNbr){ - StripQuadrant = Scorer->GetStripQuadrant(q)-1; + for (unsigned int q = 0; q < sizeQ; q++) { + if (Scorer->GetDetectorQuadrant(q) == DetNbr) { + StripQuadrant = Scorer->GetStripQuadrant(q) - 1; break; - } + } } m_Event->SetS1ThetaEDetectorNbr(DetNbr); - m_Event->SetS1ThetaEStripNbr(StripTheta+StripQuadrant*NbrRingStrips); + m_Event->SetS1ThetaEStripNbr(StripTheta + StripQuadrant * NbrRingStrips); m_Event->SetS1ThetaEEnergy(RandGauss::shoot(Energy, ResoEnergy)); m_Event->SetS1ThetaTDetectorNbr(DetNbr); - m_Event->SetS1ThetaTStripNbr(StripTheta+StripQuadrant*NbrRingStrips); + m_Event->SetS1ThetaTStripNbr(StripTheta + StripQuadrant * NbrRingStrips); m_Event->SetS1ThetaTTime(RandGauss::shoot(Time, ResoTime)); - - } - + } } - - // Loop on Silicon Sector Hit - unsigned int sizeSector = Scorer->GetSectorMult(); - for(unsigned int i = 0 ; i < sizeSector ; i++){ + + // Loop on Silicon Sector Hit + unsigned int sizeSector = Scorer->GetSectorMult(); + for (unsigned int i = 0; i < sizeSector; i++) { double Energy = Scorer->GetEnergyRing(i); - if(Energy>EnergyThreshold){ - double Time = Scorer->GetTimeRing(i); - unsigned int DetNbr = Scorer->GetDetectorRing(i);; - unsigned int StripPhi = Scorer->GetStripSector(i); - + if (Energy > EnergyThreshold) { + double Time = Scorer->GetTimeRing(i); + unsigned int DetNbr = Scorer->GetDetectorRing(i); + ; + unsigned int StripPhi = Scorer->GetStripSector(i); + m_Event->SetS1PhiEDetectorNbr(DetNbr); - m_Event->SetS1PhiEStripNbr(StripPhi); + m_Event->SetS1PhiEStripNbr(StripPhi); m_Event->SetS1PhiEEnergy(RandGauss::shoot(Energy, ResoEnergy)); m_Event->SetS1PhiTDetectorNbr(DetNbr); @@ -361,26 +306,21 @@ void AnnularS1::ReadSensitive(const G4Event*){ } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -// Initilize the Scorer use to read out the sensitive volume -void AnnularS1::InitializeScorers(){ - bool already_exist = false; +// Initilize the Scorer use to read out the sensitive volume +void AnnularS1::InitializeScorers() { + bool already_exist = false; // Associate Scorer - m_Scorer = CheckScorer("AnnularS1_Scorer",already_exist); - if(already_exist) return; + m_Scorer = CheckScorer("AnnularS1_Scorer", already_exist); + if (already_exist) + return; G4VPrimitiveScorer* AnnularScorer = - new DSSDScorers::PS_Annular("AnnularS1_Scorer", - 2, - ActiveWaferInnerRadius, - ActiveWaferOutterRadius, - -8*22.5*deg, //MUST2 campaign 2009, See: Phd Sandra Giron - +8*22.5*deg, - NbrRingStrips, - NbrSectorStrips, - NbQuadrant); + new DSSDScorers::PS_Annular("AnnularS1_Scorer", 2, ActiveWaferInnerRadius, ActiveWaferOutterRadius, + -8 * 22.5 * deg, // MUST2 campaign 2009, See: Phd Sandra Giron + +8 * 22.5 * deg, NbrRingStrips, NbrSectorStrips, NbQuadrant); m_Scorer->RegisterPrimitive(AnnularScorer); - G4VPrimitiveScorer* InteractionScorer = new InteractionScorers::PS_Interactions("InteractionS1",ms_InterCoord,2); + G4VPrimitiveScorer* InteractionScorer = new InteractionScorers::PS_Interactions("InteractionS1", ms_InterCoord, 2); m_Scorer->RegisterPrimitive(InteractionScorer); // Add All Scorer to the Global Scorer Manager G4SDManager::GetSDMpointer()->AddNewDetector(m_Scorer); @@ -388,23 +328,20 @@ void AnnularS1::InitializeScorers(){ //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* AnnularS1::Construct(){ - return (NPS::VDetector*) new AnnularS1(); -} +NPS::VDetector* AnnularS1::Construct() { return (NPS::VDetector*)new AnnularS1(); } //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern "C"{ -class proxy_nps_annulars1{ - public: - proxy_nps_annulars1(){ - NPS::DetectorFactory::getInstance()->AddToken("AnnularS1","AnnularS1"); - NPS::DetectorFactory::getInstance()->AddDetector("AnnularS1",AnnularS1::Construct); - } +extern "C" { +class proxy_nps_annulars1 { + public: + proxy_nps_annulars1() { + NPS::DetectorFactory::getInstance()->AddToken("AnnularS1", "AnnularS1"); + NPS::DetectorFactory::getInstance()->AddDetector("AnnularS1", AnnularS1::Construct); + } }; proxy_nps_annulars1 p_nps_annulars1; } - diff --git a/NPSimulation/Detectors/Catana/Catana.cc b/NPSimulation/Detectors/Catana/Catana.cc index bc634efbe..9ff6023b7 100644 --- a/NPSimulation/Detectors/Catana/Catana.cc +++ b/NPSimulation/Detectors/Catana/Catana.cc @@ -24,58 +24,57 @@ *****************************************************************************/ // C++ headers -#include <sstream> -#include <fstream> #include <cmath> +#include <fstream> #include <limits> -//G4 Geometry object -#include "G4Tubs.hh" +#include <sstream> +// G4 Geometry object #include "G4Box.hh" -#include "G4Trap.hh" #include "G4SubtractionSolid.hh" +#include "G4Trap.hh" +#include "G4Tubs.hh" -//G4 sensitive -#include "G4SDManager.hh" +// G4 sensitive #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" -//G4 various object +// G4 various object +#include "G4Colour.hh" #include "G4Material.hh" -#include "G4Transform3D.hh" #include "G4PVPlacement.hh" +#include "G4Transform3D.hh" #include "G4VisAttributes.hh" -#include "G4Colour.hh" // NPTool header -#include "Catana.hh" #include "CalorimeterScorers.hh" +#include "Catana.hh" #include "InteractionScorers.hh" -#include "RootOutput.h" #include "MaterialManager.hh" -#include "NPSDetectorFactory.hh" #include "NPOptionManager.h" +#include "NPSDetectorFactory.hh" #include "NPSHitsMap.hh" +#include "RootOutput.h" // CLHEP header #include "CLHEP/Random/RandGauss.h" using namespace std; using namespace CLHEP; - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -namespace Catana_NS{ +namespace Catana_NS { // Energy and time Resolution - const double EnergyThreshold = 0.1*MeV; - const double ResoTime = 4.5*ns ; - const double ResoEnergy = 0.08*MeV ; - double Length = 600*mm ; + const double EnergyThreshold = 0.1 * MeV; + const double ResoTime = 4.5 * ns; + const double ResoEnergy = 0.08 * MeV; + double Length = 600 * mm; string Material = "CsI"; -} +} // namespace Catana_NS //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Catana Specific Method -Catana::Catana(){ - m_Event = new TCatanaData() ; +Catana::Catana() { + m_Event = new TCatanaData(); m_CatanaScorer = 0; m_DetectorType1 = 0; m_DetectorType2 = 0; @@ -84,21 +83,19 @@ Catana::Catana(){ m_DetectorType5 = 0; // RGB Color + Transparency - m_VisCrystal1 = new G4VisAttributes(G4Colour(0.8, 0.3, 0.3, 1)); - m_VisCrystal2 = new G4VisAttributes(G4Colour(0.3, 0.8, 0.3, 1)); - m_VisCrystal3 = new G4VisAttributes(G4Colour(0.3, 0.3, 0.8, 1)); - m_VisCrystal4 = new G4VisAttributes(G4Colour(0.3, 0.8, 0.8, 1)); - m_VisCrystal5 = new G4VisAttributes(G4Colour(0.8, 0.3, 0.8, 1)); - m_VisHousing = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3, 0.2)); - m_VisReflector = new G4VisAttributes(G4Colour(1, 1, 1, 0.1)); - + m_VisCrystal1 = new G4VisAttributes(G4Colour(0.8, 0.3, 0.3, 1)); + m_VisCrystal2 = new G4VisAttributes(G4Colour(0.3, 0.8, 0.3, 1)); + m_VisCrystal3 = new G4VisAttributes(G4Colour(0.3, 0.3, 0.8, 1)); + m_VisCrystal4 = new G4VisAttributes(G4Colour(0.3, 0.8, 0.8, 1)); + m_VisCrystal5 = new G4VisAttributes(G4Colour(0.8, 0.3, 0.8, 1)); + m_VisHousing = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3, 0.2)); + m_VisReflector = new G4VisAttributes(G4Colour(1, 1, 1, 0.1)); } -Catana::~Catana(){ -} +Catana::~Catana() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Catana::AddDetector(double X,double Y, double Z, double Theta, double Phi, int ID, int Type,double Rshift){ +void Catana::AddDetector(double X, double Y, double Z, double Theta, double Phi, int ID, int Type, double Rshift) { m_X.push_back(X); m_Y.push_back(Y); m_Z.push_back(Z); @@ -110,274 +107,260 @@ void Catana::AddDetector(double X,double Y, double Z, double Theta, double Phi, } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Catana::ReadCSV(string path,double Rshift){ - std::ifstream csv(path); - if(!csv.is_open()){ +void Catana::ReadCSV(string path, double Rshift) { + std::ifstream csv(path); + if (!csv.is_open()) { std::ostringstream message; message << "Catana csv file " << path << " not found " << std::endl; } - - int ID, type,layer; - double X,Y,Z,Theta,Phi; + int ID, type, layer; + double X, Y, Z, Theta, Phi; string buffer; // ignore first line - getline(csv,buffer); - while(csv >> ID >> buffer >> type >> buffer >> layer >> buffer >> X >> buffer >> Y >> buffer >> Z >> buffer >> Theta >> buffer >> Phi){ - if(type<6) - AddDetector(X,Y,Z,Theta*deg,Phi*deg,ID,type,Rshift); - else{ - // ignore other type for which I don't have the geometry - } + getline(csv, buffer); + while (csv >> ID >> buffer >> type >> buffer >> layer >> buffer >> X >> buffer >> Y >> buffer >> Z >> buffer >> + Theta >> buffer >> Phi) { + if (type < 6) + AddDetector(X, Y, Z, Theta * deg, Phi * deg, ID, type, Rshift); + else { + // ignore other type for which I don't have the geometry + } } return; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Catana::BuildDetector(int Type){ +G4LogicalVolume* Catana::BuildDetector(int Type) { // Check if the requested detector already exist - if(Type==1 && m_DetectorType1) - return m_DetectorType1; - - else if(Type==2 && m_DetectorType2) - return m_DetectorType2; - - else if(Type==3 && m_DetectorType3) - return m_DetectorType3; + if (Type == 1 && m_DetectorType1) + return m_DetectorType1; + + else if (Type == 2 && m_DetectorType2) + return m_DetectorType2; - else if(Type==4 && m_DetectorType4) - return m_DetectorType4; + else if (Type == 3 && m_DetectorType3) + return m_DetectorType3; - else if(Type==5 && m_DetectorType5) - return m_DetectorType5; + else if (Type == 4 && m_DetectorType4) + return m_DetectorType4; + else if (Type == 5 && m_DetectorType5) + return m_DetectorType5; // Define the requested geometry - double x1,x2,x3,x4,y1,y2,z,crystalz; - //int pmttype; // 1: H7195, 2:H11934 - double seal_dt = 12*mm, housing_dt = 0.5*mm, reflector_dt = 0.5*mm; + double x1, x2, x3, x4, y1, y2, z, crystalz; + // int pmttype; // 1: H7195, 2:H11934 + double seal_dt = 12 * mm, housing_dt = 0.5 * mm, reflector_dt = 0.5 * mm; + + if (Type == 1) { // crystal type 1 + x1 = 62.3 * mm; + x2 = 62.3 * mm; + x3 = 95.7 * mm; + y1 = 36.6 * mm; + y2 = 56.3 * mm; + z = 107 * mm; + crystalz = 93. * mm; // pmttype = 1; + } + if (Type == 2) { // crystal type 2 + x1 = 57.1 * mm; + x2 = 63.6 * mm; + x3 = 84.5 * mm; + y1 = 34.9 * mm; + y2 = 55.4 * mm; + z = 117 * mm; + crystalz = 103. * mm; // pmttype = 1; + } + if (Type == 3) { // crystal type 3 + x1 = 49.7 * mm; + x2 = 58.5 * mm; + x3 = 74.9 * mm; + y1 = 38.3 * mm; + y2 = 64.7 * mm; + z = 137 * mm; + crystalz = 123. * mm; // pmttype = 1; + } + if (Type == 4) { // crystal type 4 + x1 = 40.0 * mm; + x2 = 50.2 * mm; + x3 = 60.3 * mm; + y1 = 38.3 * mm; + y2 = 66.4 * mm; + z = 152 * mm; + crystalz = 138.5 * mm; // pmttype = 1; + } + if (Type == 5) { // crystal type 5 + x1 = 28.4 * mm; + x2 = 39.7 * mm; + x3 = 41.5 * mm; + y1 = 38.3 * mm; + y2 = 69.9 * mm; + z = 162 * mm; + crystalz = 148.5 * mm; // pmttype = 2; + } + x4 = x3 + (y2 / y1) * (x2 - x1); // planarity condition + Double_t beta1 = 90 * deg + std::atan((x2 - x1) / (y1 * 2)); // should be + Double_t beta2 = 90 * deg + std::atan((x4 - x3) / (y2 * 2)); // beta1 = beta2 + if (std::abs(beta1 - beta2) > 1e-4) { + std::cout << "Housing type " << Type << " is not planar" << std::endl; + } - if(Type == 1){ // crystal type 1 - x1 = 62.3*mm; x2 = 62.3*mm; x3 = 95.7*mm; y1 = 36.6*mm; y2 = 56.3*mm; - z = 107*mm; crystalz = 93.*mm; //pmttype = 1; - } - if(Type == 2){ // crystal type 2 - x1 = 57.1*mm; x2 = 63.6*mm; x3 = 84.5*mm; y1 = 34.9*mm; y2 = 55.4*mm; - z = 117*mm; crystalz = 103.*mm; //pmttype = 1; - } - if(Type == 3){ // crystal type 3 - x1 = 49.7*mm; x2 = 58.5*mm; x3 = 74.9*mm; y1 = 38.3*mm; y2 = 64.7*mm; - z = 137*mm; crystalz = 123.*mm; //pmttype = 1; - } - if(Type == 4){ // crystal type 4 - x1 = 40.0*mm; x2 = 50.2*mm; x3 = 60.3*mm; y1 = 38.3*mm; y2 = 66.4*mm; - z = 152*mm; crystalz = 138.5*mm; //pmttype = 1; - } - if(Type == 5){ // crystal type 5 - x1 = 28.4*mm; x2 = 39.7*mm; x3 = 41.5*mm; y1 = 38.3*mm; y2 = 69.9*mm; - z = 162*mm; crystalz = 148.5*mm; //pmttype = 2; - } - x4 = x3 + (y2/y1)*(x2-x1); // planarity condition - Double_t beta1 = 90*deg + std::atan((x2-x1)/(y1*2));// should be - Double_t beta2 = 90*deg + std::atan((x4-x3)/(y2*2));// beta1 = beta2 - if(std::abs(beta1-beta2)>1e-4){ - std::cout << "Housing type " << Type << " is not planar" << std::endl; - } + // Define Material + G4Material* CsI = MaterialManager::getInstance()->GetMaterialFromLibrary("CsI"); + G4Material* Al = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); + G4Material* Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); + G4Material* Teflon = MaterialManager::getInstance()->GetMaterialFromLibrary("G4_TEFLON"); + G4RotationMatrix* Rot = new G4RotationMatrix(); + + // Parameters for G4Trap + double pDz, pDy1, pDy2, pDx1, pDx2, pDx3, pDx4; + double pTheta = 0. * deg, pPhi = 0. * deg, pAlp1 = 0. * deg, pAlp2 = 0 * deg; + + // housing outside + pDz = z * 0.5; + pDy1 = y1 * 0.5; + pDy2 = y2 * 0.5; + pDx1 = x1 * 0.5; + pDx2 = x2 * 0.5; + pDx3 = x3 * 0.5; + pDx4 = x4 * 0.5; + + G4Trap* solidHousingOUT = + new G4Trap("solidHousingOut", pDz, pTheta, pPhi, pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3, pDx4, pAlp2); + + G4LogicalVolume* result = 0; + if (Type == 1) { + m_DetectorType1 = new G4LogicalVolume(solidHousingOUT, Vacuum, "logicDetectorType1", 0, 0, 0); + result = m_DetectorType1; + } + else if (Type == 2) { + m_DetectorType2 = new G4LogicalVolume(solidHousingOUT, Vacuum, "logicDetectorType2", 0, 0, 0); + result = m_DetectorType2; + } - // Define Material - G4Material* CsI = MaterialManager::getInstance()->GetMaterialFromLibrary("CsI"); - G4Material* Al = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); - G4Material* Vacuum= MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); - G4Material* Teflon= MaterialManager::getInstance()->GetMaterialFromLibrary("G4_TEFLON"); - G4RotationMatrix* Rot= new G4RotationMatrix(); - - - // Parameters for G4Trap - double pDz, pDy1, pDy2, pDx1, pDx2, pDx3, pDx4; - double pTheta=0.*deg, pPhi=0.*deg, pAlp1=0.*deg, pAlp2=0*deg; - - // housing outside - pDz = z*0.5; - pDy1 = y1*0.5; - pDy2 = y2*0.5; - pDx1 = x1*0.5; - pDx2 = x2*0.5; - pDx3 = x3*0.5; - pDx4 = x4*0.5; - - G4Trap *solidHousingOUT = new G4Trap("solidHousingOut", pDz, pTheta, pPhi, - pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3, - pDx4, pAlp2); - - G4LogicalVolume* result = 0; - if(Type==1){ - m_DetectorType1 = new G4LogicalVolume(solidHousingOUT, - Vacuum, - "logicDetectorType1", - 0,0,0); - result = m_DetectorType1; - } - else if(Type==2){ - m_DetectorType2 = new G4LogicalVolume(solidHousingOUT, - Vacuum, - "logicDetectorType2", - 0,0,0); - result = m_DetectorType2; - } - - - else if(Type==3){ - m_DetectorType3 = new G4LogicalVolume(solidHousingOUT, - Vacuum, - "logicDetectorType3", - 0,0,0); - result = m_DetectorType3; - } - - - else if(Type==4){ - m_DetectorType4 = new G4LogicalVolume(solidHousingOUT, - Vacuum, - "logicDetectorType4", - 0,0,0); - result = m_DetectorType4; - } - - else if(Type==5){ - m_DetectorType5 = new G4LogicalVolume(solidHousingOUT, - Vacuum, - "logicDetectorType5", - 0,0,0); - result = m_DetectorType5; - } - - - result->SetVisAttributes(G4VisAttributes::Invisible); - - - // -- Al housing inside - double length = z; - double ax1 = pDx1; - double bx1 = pDx3; - double ax2 = pDx2; - double bx2 = pDx4; - double ay1 = pDy1; - double by1 = pDy2; - - pDz = (length - seal_dt - housing_dt)/2.; - pDy1 = (by1-ay1)/length * housing_dt + ay1 - housing_dt; - pDx1 = (bx1-ax1)/length * housing_dt + ax1 - housing_dt; - pDx2 = (bx2-ax2)/length * housing_dt + ax2 - housing_dt; - pDy2 = (by1-ay1)/length * (length - seal_dt) + ay1 - housing_dt; - pDx3 = (bx1-ax1)/length * (length - seal_dt) + ax1 - housing_dt; - //pDx4 = (bx2-ax2)/length * (length - seal_dt) + ax2 - housing_dt; - pDx4 = pDx3 + (pDy2 / pDy1)*(pDx2 - pDx1); // planarity condition - - G4Trap* solidHousingIN = new G4Trap("solidHousingIN", pDz, pTheta, pPhi, - pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3, - pDx4, pAlp2); - - - double offset = -(length*0.5 - pDz - housing_dt); - G4SubtractionSolid* solidHousing = - new G4SubtractionSolid("solidHousing", solidHousingOUT,// mother - solidHousingIN, Rot, - G4ThreeVector(0.,0.,offset)); - - G4LogicalVolume* LogicHousing = new G4LogicalVolume(solidHousing, Al,"logicHousing",0,0,0); - LogicHousing->SetVisAttributes(m_VisHousing); - - // -- Crystal -- - double space = 2.*mm; // space btw. crystal and housing - length = pDz * 2.; // housing inner z length - ax1 = pDx1; - bx1 = pDx3; - ax2 = pDx2; - bx2 = pDx4; - ay1 = pDy1; - by1 = pDy2; - - pDz = crystalz*0.5; - pDy1 = (by1-ay1)/length * reflector_dt + ay1 - space; - pDx1 = (bx1-ax1)/length * reflector_dt + ax1 - space; - pDx2 = (bx2-ax2)/length * reflector_dt + ax2 - space; - pDy2 = (by1-ay1)/length * (reflector_dt + crystalz) + ay1 - space; - pDx3 = (bx1-ax1)/length * (reflector_dt + crystalz) + ax1 - space; - //pDx4 = (bx2-ax2)/length * (reflector_dt + crystalz) + ax2 - space; - pDx4 = pDx3 + (pDy2 / pDy1)*(pDx2 - pDx1); // planarity condition - - G4Trap* solidCrystal = new G4Trap("solidCrystal", pDz, pTheta, pPhi, - pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3, - pDx4, pAlp2); - - G4LogicalVolume* LogicCrystal = new G4LogicalVolume(solidCrystal,// solid - CsI, - "SolidCrystal", - 0,0,0); - if(Type==1) - LogicCrystal->SetVisAttributes(m_VisCrystal1); - - else if(Type==2) - LogicCrystal->SetVisAttributes(m_VisCrystal2); - - else if(Type==3) - LogicCrystal->SetVisAttributes(m_VisCrystal3); - - else if(Type==4) - LogicCrystal->SetVisAttributes(m_VisCrystal4); - - else if(Type==5) - LogicCrystal->SetVisAttributes(m_VisCrystal5); - - - LogicCrystal->SetSensitiveDetector(m_CatanaScorer); - - // -- Teflon reflector - length = crystalz; - ax1 = pDx1; - bx1 = pDx3; - ax2 = pDx2; - bx2 = pDx4; - ay1 = pDy1; - by1 = pDy2; - - pDz = crystalz*0.5 + reflector_dt; - pDy1 = (by1-ay1)/length * -reflector_dt + ay1 + reflector_dt; - pDx1 = (bx1-ax1)/length * -reflector_dt + ax1 + reflector_dt; - pDx2 = (bx2-ax2)/length * -reflector_dt + ax2 + reflector_dt; - pDy2 = (by1-ay1)/length * (reflector_dt + crystalz) + ay1 + reflector_dt; - pDx3 = (bx1-ax1)/length * (reflector_dt + crystalz) + ax1 + reflector_dt; - //pDx4 = (bx2-ax2)/length * (reflector_dt + crystalz) + ax2 + reflector_dt; - pDx4 = pDx3 + (pDy2 / pDy1)*(pDx2 - pDx1); // planarity condition - - G4Trap* solidReflector = new G4Trap("solidReflector",pDz, pTheta, - pPhi, pDy1, pDx1, pDx2, pAlp1, - pDy2, pDx3, pDx4, pAlp2); - - G4LogicalVolume* LogicReflector = new G4LogicalVolume(solidReflector, Teflon, - "logicReflector", - 0,0,0); - - LogicReflector->SetVisAttributes(m_VisReflector); - - // Place volume in each other: - new G4PVPlacement(G4Transform3D(*Rot,G4ThreeVector(0,0,0)), - LogicHousing, - "CatanaHousing",result,false,0); - - - m_Zoffset[Type] = (z - crystalz)*0.5 - housing_dt - reflector_dt; - - new G4PVPlacement(G4Transform3D(*Rot,G4ThreeVector(0,0,-m_Zoffset[Type])), - LogicReflector, - "CatanaReflector",result,false,0); - - new G4PVPlacement(G4Transform3D(*Rot,G4ThreeVector(0,0,0)), - LogicCrystal, - "CatanaCrystal",LogicReflector,false,0); - - return result; + else if (Type == 3) { + m_DetectorType3 = new G4LogicalVolume(solidHousingOUT, Vacuum, "logicDetectorType3", 0, 0, 0); + result = m_DetectorType3; + } + + else if (Type == 4) { + m_DetectorType4 = new G4LogicalVolume(solidHousingOUT, Vacuum, "logicDetectorType4", 0, 0, 0); + result = m_DetectorType4; + } + else if (Type == 5) { + m_DetectorType5 = new G4LogicalVolume(solidHousingOUT, Vacuum, "logicDetectorType5", 0, 0, 0); + result = m_DetectorType5; + } + + result->SetVisAttributes(G4VisAttributes::GetInvisible()); + + // -- Al housing inside + double length = z; + double ax1 = pDx1; + double bx1 = pDx3; + double ax2 = pDx2; + double bx2 = pDx4; + double ay1 = pDy1; + double by1 = pDy2; + + pDz = (length - seal_dt - housing_dt) / 2.; + pDy1 = (by1 - ay1) / length * housing_dt + ay1 - housing_dt; + pDx1 = (bx1 - ax1) / length * housing_dt + ax1 - housing_dt; + pDx2 = (bx2 - ax2) / length * housing_dt + ax2 - housing_dt; + pDy2 = (by1 - ay1) / length * (length - seal_dt) + ay1 - housing_dt; + pDx3 = (bx1 - ax1) / length * (length - seal_dt) + ax1 - housing_dt; + // pDx4 = (bx2-ax2)/length * (length - seal_dt) + ax2 - housing_dt; + pDx4 = pDx3 + (pDy2 / pDy1) * (pDx2 - pDx1); // planarity condition + + G4Trap* solidHousingIN = + new G4Trap("solidHousingIN", pDz, pTheta, pPhi, pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3, pDx4, pAlp2); + + double offset = -(length * 0.5 - pDz - housing_dt); + G4SubtractionSolid* solidHousing = new G4SubtractionSolid("solidHousing", solidHousingOUT, // mother + solidHousingIN, Rot, G4ThreeVector(0., 0., offset)); + + G4LogicalVolume* LogicHousing = new G4LogicalVolume(solidHousing, Al, "logicHousing", 0, 0, 0); + LogicHousing->SetVisAttributes(m_VisHousing); + + // -- Crystal -- + double space = 2. * mm; // space btw. crystal and housing + length = pDz * 2.; // housing inner z length + ax1 = pDx1; + bx1 = pDx3; + ax2 = pDx2; + bx2 = pDx4; + ay1 = pDy1; + by1 = pDy2; + + pDz = crystalz * 0.5; + pDy1 = (by1 - ay1) / length * reflector_dt + ay1 - space; + pDx1 = (bx1 - ax1) / length * reflector_dt + ax1 - space; + pDx2 = (bx2 - ax2) / length * reflector_dt + ax2 - space; + pDy2 = (by1 - ay1) / length * (reflector_dt + crystalz) + ay1 - space; + pDx3 = (bx1 - ax1) / length * (reflector_dt + crystalz) + ax1 - space; + // pDx4 = (bx2-ax2)/length * (reflector_dt + crystalz) + ax2 - space; + pDx4 = pDx3 + (pDy2 / pDy1) * (pDx2 - pDx1); // planarity condition + + G4Trap* solidCrystal = + new G4Trap("solidCrystal", pDz, pTheta, pPhi, pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3, pDx4, pAlp2); + + G4LogicalVolume* LogicCrystal = new G4LogicalVolume(solidCrystal, // solid + CsI, "SolidCrystal", 0, 0, 0); + if (Type == 1) + LogicCrystal->SetVisAttributes(m_VisCrystal1); + + else if (Type == 2) + LogicCrystal->SetVisAttributes(m_VisCrystal2); + + else if (Type == 3) + LogicCrystal->SetVisAttributes(m_VisCrystal3); + + else if (Type == 4) + LogicCrystal->SetVisAttributes(m_VisCrystal4); + + else if (Type == 5) + LogicCrystal->SetVisAttributes(m_VisCrystal5); + + LogicCrystal->SetSensitiveDetector(m_CatanaScorer); + + // -- Teflon reflector + length = crystalz; + ax1 = pDx1; + bx1 = pDx3; + ax2 = pDx2; + bx2 = pDx4; + ay1 = pDy1; + by1 = pDy2; + + pDz = crystalz * 0.5 + reflector_dt; + pDy1 = (by1 - ay1) / length * -reflector_dt + ay1 + reflector_dt; + pDx1 = (bx1 - ax1) / length * -reflector_dt + ax1 + reflector_dt; + pDx2 = (bx2 - ax2) / length * -reflector_dt + ax2 + reflector_dt; + pDy2 = (by1 - ay1) / length * (reflector_dt + crystalz) + ay1 + reflector_dt; + pDx3 = (bx1 - ax1) / length * (reflector_dt + crystalz) + ax1 + reflector_dt; + // pDx4 = (bx2-ax2)/length * (reflector_dt + crystalz) + ax2 + reflector_dt; + pDx4 = pDx3 + (pDy2 / pDy1) * (pDx2 - pDx1); // planarity condition + + G4Trap* solidReflector = + new G4Trap("solidReflector", pDz, pTheta, pPhi, pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3, pDx4, pAlp2); + + G4LogicalVolume* LogicReflector = new G4LogicalVolume(solidReflector, Teflon, "logicReflector", 0, 0, 0); + + LogicReflector->SetVisAttributes(m_VisReflector); + + // Place volume in each other: + new G4PVPlacement(G4Transform3D(*Rot, G4ThreeVector(0, 0, 0)), LogicHousing, "CatanaHousing", result, false, 0); + + m_Zoffset[Type] = (z - crystalz) * 0.5 - housing_dt - reflector_dt; + + new G4PVPlacement(G4Transform3D(*Rot, G4ThreeVector(0, 0, -m_Zoffset[Type])), LogicReflector, "CatanaReflector", + result, false, 0); + + new G4PVPlacement(G4Transform3D(*Rot, G4ThreeVector(0, 0, 0)), LogicCrystal, "CatanaCrystal", LogicReflector, false, + 0); + + return result; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -387,138 +370,135 @@ G4LogicalVolume* Catana::BuildDetector(int Type){ // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Catana::ReadConfiguration(NPL::InputParser parser){ +void Catana::ReadConfiguration(NPL::InputParser parser) { // CSV config - vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithTokenAndValue("Catana","CSV"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " CSV block found " << endl; + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithTokenAndValue("Catana", "CSV"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " CSV block found " << endl; - vector<string> token = {"Path","Pos","Rshift"}; + vector<string> token = {"Path", "Pos", "Rshift"}; - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(token)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Catana " << i+1 << endl; + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(token)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Catana " << i + 1 << endl; string path = blocks[i]->GetString("Path"); - double Rshift = blocks[i]->GetDouble("Rshift","micrometer"); + double Rshift = blocks[i]->GetDouble("Rshift", "micrometer"); // Reference position of the whole array - m_Ref = NPS::ConvertVector(blocks[i]->GetTVector3("Pos","mm")); - ReadCSV(path,Rshift); + m_Ref = NPS::ConvertVector(blocks[i]->GetTVector3("Pos", "mm")); + ReadCSV(path, Rshift); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } } - + // Type 1 - blocks = parser.GetAllBlocksWithTokenAndValue("Catana","Detector"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " detectors found " << endl; - - token = {"X","Y","Z","Theta","Phi","ID","Type"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(token)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Catana " << i+1 << endl; - double X = blocks[i]->GetDouble("X","mm"); - double Y = blocks[i]->GetDouble("Y","mm"); - double Z = blocks[i]->GetDouble("Z","mm"); - double Theta = blocks[i]->GetDouble("Theta","deg"); - double Phi = blocks[i]->GetDouble("Phi","deg"); - int ID = blocks[i]->GetInt("ID"); - int Type = blocks[i]->GetInt("Type"); - AddDetector(X,Y,Z,Theta,Phi,ID,Type); + blocks = parser.GetAllBlocksWithTokenAndValue("Catana", "Detector"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + + token = {"X", "Y", "Z", "Theta", "Phi", "ID", "Type"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(token)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Catana " << i + 1 << endl; + double X = blocks[i]->GetDouble("X", "mm"); + double Y = blocks[i]->GetDouble("Y", "mm"); + double Z = blocks[i]->GetDouble("Z", "mm"); + double Theta = blocks[i]->GetDouble("Theta", "deg"); + double Phi = blocks[i]->GetDouble("Phi", "deg"); + int ID = blocks[i]->GetInt("ID"); + int Type = blocks[i]->GetInt("Type"); + AddDetector(X, Y, Z, Theta, Phi, ID, Type); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } } - } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void Catana::ConstructDetector(G4LogicalVolume* world){ - for (unsigned short i = 0 ; i < m_X.size() ; i++) { - if(m_Type[i]>5) +void Catana::ConstructDetector(G4LogicalVolume* world) { + for (unsigned short i = 0; i < m_X.size(); i++) { + if (m_Type[i] > 5) exit(1); BuildDetector(m_Type[i]); // Reference coordinate given for center of crystal - G4ThreeVector Det_pos = G4ThreeVector(m_X[i],m_Y[i],m_Z[i]) ; - // But placed volume is casing which is shifted w/respect to crystal + G4ThreeVector Det_pos = G4ThreeVector(m_X[i], m_Y[i], m_Z[i]); + // But placed volume is casing which is shifted w/respect to crystal G4ThreeVector Det_dir = Det_pos; Det_dir.unit(); // had to add a 70micron in radius to avoid overlap when using official // csv simulation file - Det_dir.setMag(m_Zoffset[m_Type[i]]+m_Rshift[i]); - Det_pos+=Det_dir+m_Ref; + Det_dir.setMag(m_Zoffset[m_Type[i]] + m_Rshift[i]); + Det_pos += Det_dir + m_Ref; G4RotationMatrix* Rot = new G4RotationMatrix(); Rot->rotateX(-m_Theta[i]); Rot->rotateZ(m_Phi[i]); - new G4PVPlacement(G4Transform3D(*Rot,Det_pos), - BuildDetector(m_Type[i]), - "Catana",world,false,m_ID[i]); + new G4PVPlacement(G4Transform3D(*Rot, Det_pos), BuildDetector(m_Type[i]), "Catana", world, false, m_ID[i]); } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void Catana::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("Catana")){ - pTree->Branch("Catana", "TCatanaData", &m_Event) ; +void Catana::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("Catana")) { + pTree->Branch("Catana", "TCatanaData", &m_Event); } - pTree->SetBranchAddress("Catana", &m_Event) ; + pTree->SetBranchAddress("Catana", &m_Event); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Catana::ReadSensitive(const G4Event* ){ +void Catana::ReadSensitive(const G4Event*) { m_Event->Clear(); /////////// // Calorimeter scorer - CalorimeterScorers::PS_Calorimeter* Scorer= (CalorimeterScorers::PS_Calorimeter*) m_CatanaScorer->GetPrimitive(0); - - unsigned int size = Scorer->GetMult(); - for(unsigned int i = 0 ; i < size ; i++){ - vector<unsigned int> level = Scorer->GetLevel(i); - double Energy = RandGauss::shoot(Scorer->GetEnergy(i),Catana_NS::ResoEnergy); - if(Energy>Catana_NS::EnergyThreshold){ - double Time = RandGauss::shoot(Scorer->GetTime(i),Catana_NS::ResoTime); + CalorimeterScorers::PS_Calorimeter* Scorer = (CalorimeterScorers::PS_Calorimeter*)m_CatanaScorer->GetPrimitive(0); + + unsigned int size = Scorer->GetMult(); + for (unsigned int i = 0; i < size; i++) { + vector<unsigned int> level = Scorer->GetLevel(i); + double Energy = RandGauss::shoot(Scorer->GetEnergy(i), Catana_NS::ResoEnergy); + if (Energy > Catana_NS::EnergyThreshold) { + double Time = RandGauss::shoot(Scorer->GetTime(i), Catana_NS::ResoTime); int DetectorNbr = level[0]; - m_Event->SetEnergy(DetectorNbr,Energy); - m_Event->SetTime(DetectorNbr,Time); + m_Event->SetEnergy(DetectorNbr, Energy); + m_Event->SetTime(DetectorNbr, Time); } } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -//////////////////////////////////////////////////////////////// -void Catana::InitializeScorers() { +//////////////////////////////////////////////////////////////// +void Catana::InitializeScorers() { // This check is necessary in case the geometry is reloaded - bool already_exist = false; - m_CatanaScorer = CheckScorer("CatanaScorer",already_exist) ; + bool already_exist = false; + m_CatanaScorer = CheckScorer("CatanaScorer", already_exist); - if(already_exist) - return ; + if (already_exist) + return; // Otherwise the scorer is initialised - vector<int> level; level.push_back(2); - G4VPrimitiveScorer* Calorimeter= new CalorimeterScorers::PS_Calorimeter("Calorimeter",level, 0) ; - G4VPrimitiveScorer* Interaction= new InteractionScorers::PS_Interactions("Interaction",ms_InterCoord, 0) ; - //and register it to the multifunctionnal detector + vector<int> level; + level.push_back(2); + G4VPrimitiveScorer* Calorimeter = new CalorimeterScorers::PS_Calorimeter("Calorimeter", level, 0); + G4VPrimitiveScorer* Interaction = new InteractionScorers::PS_Interactions("Interaction", ms_InterCoord, 0); + // and register it to the multifunctionnal detector m_CatanaScorer->RegisterPrimitive(Calorimeter); m_CatanaScorer->RegisterPrimitive(Interaction); - G4SDManager::GetSDMpointer()->AddNewDetector(m_CatanaScorer) ; + G4SDManager::GetSDMpointer()->AddNewDetector(m_CatanaScorer); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -527,22 +507,20 @@ void Catana::InitializeScorers() { //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* Catana::Construct(){ - return (NPS::VDetector*) new Catana(); -} +NPS::VDetector* Catana::Construct() { return (NPS::VDetector*)new Catana(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_Catana{ - public: - proxy_nps_Catana(){ - NPS::DetectorFactory::getInstance()->AddToken("Catana","Catana"); - NPS::DetectorFactory::getInstance()->AddDetector("Catana",Catana::Construct); - } - }; - - proxy_nps_Catana p_nps_Catana; +extern "C" { +class proxy_nps_Catana { + public: + proxy_nps_Catana() { + NPS::DetectorFactory::getInstance()->AddToken("Catana", "Catana"); + NPS::DetectorFactory::getInstance()->AddDetector("Catana", Catana::Construct); + } +}; + +proxy_nps_Catana p_nps_Catana; } diff --git a/NPSimulation/Detectors/ComptonTelescope/ComptonTelescope.cc b/NPSimulation/Detectors/ComptonTelescope/ComptonTelescope.cc index cb8e38a15..1c3b38595 100644 --- a/NPSimulation/Detectors/ComptonTelescope/ComptonTelescope.cc +++ b/NPSimulation/Detectors/ComptonTelescope/ComptonTelescope.cc @@ -25,35 +25,35 @@ *****************************************************************************/ // C++ headers +#include <cmath> #include <sstream> #include <string> -#include <cmath> // ROOT headers #include "TString.h" // G4 Geometry headers -#include "G4Trd.hh" #include "G4Box.hh" #include "G4Trap.hh" +#include "G4Trd.hh" // G4 various headers -#include "G4Material.hh" -#include "G4VisAttributes.hh" #include "G4Colour.hh" +#include "G4Material.hh" +#include "G4PVDivision.hh" +#include "G4PVPlacement.hh" #include "G4RotationMatrix.hh" #include "G4Transform3D.hh" -#include "G4PVPlacement.hh" -#include "G4PVDivision.hh" +#include "G4VisAttributes.hh" // NPTool headers #include "ComptonTelescope.hh" #include "ComptonTelescopeScorers.hh" -#include "ObsoleteGeneralScorers.hh" #include "MaterialManager.hh" +#include "NPOptionManager.h" #include "NPSDetectorFactory.hh" +#include "ObsoleteGeneralScorers.hh" #include "RootOutput.h" -#include "NPOptionManager.h" // CLHEP #include "CLHEP/Random/RandGauss.h" @@ -62,188 +62,154 @@ using namespace CLHEP; using namespace COMPTONTELESCOPE; - - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -ComptonTelescope::ComptonTelescope() - : m_Event(new TComptonTelescopeData()), - m_ProcessEvent(new TComptonTelescopeProcessData()), - m_NumberOfDSSSD(1), - m_SizeOfDSSSD(100), - m_NumberOfStrips(50), - m_ThicknessOfDSSSD(2), - m_DistanceInterDSSSD(7), - m_ThicknessOfCalorimeter(50), - m_DistanceTrackerCalorimeter(7) +ComptonTelescope::ComptonTelescope() + : m_Event(new TComptonTelescopeData()), m_ProcessEvent(new TComptonTelescopeProcessData()), m_NumberOfDSSSD(1), + m_SizeOfDSSSD(100), m_NumberOfStrips(50), m_ThicknessOfDSSSD(2), m_DistanceInterDSSSD(7), + m_ThicknessOfCalorimeter(50), m_DistanceTrackerCalorimeter(7) { - // calculate tower height - m_TowerHeight = (m_NumberOfDSSSD-1) * m_DistanceInterDSSSD + m_ThicknessOfDSSSD - + m_DistanceTrackerCalorimeter + m_ThicknessOfCalorimeter; - - // initialize materials - InitializeMaterial(); -} - + // calculate tower height + m_TowerHeight = (m_NumberOfDSSSD - 1) * m_DistanceInterDSSSD + m_ThicknessOfDSSSD + m_DistanceTrackerCalorimeter + + m_ThicknessOfCalorimeter; + // initialize materials + InitializeMaterial(); +} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -ComptonTelescope::~ComptonTelescope() -{ - // Materials - delete m_MaterialSilicon; - delete m_MaterialAluminium; - delete m_MaterialLaBr3; - delete m_MaterialVacuum; - - // Data - delete m_Event; - - // Scorers - delete m_TrackerScorer; - delete m_CalorimeterScorer; +ComptonTelescope::~ComptonTelescope() { + // Materials + delete m_MaterialSilicon; + delete m_MaterialAluminium; + delete m_MaterialLaBr3; + delete m_MaterialVacuum; + + // Data + delete m_Event; + + // Scorers + delete m_TrackerScorer; + delete m_CalorimeterScorer; } - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void ComptonTelescope::AddModule(G4ThreeVector X1_Y1 , - G4ThreeVector X128_Y1 , - G4ThreeVector X1_Y128 , - G4ThreeVector X128_Y128 , - bool wTracker , - bool wCalorimeter) -{ - m_DefinitionType.push_back(true) ; - - m_X1_Y1.push_back(X1_Y1) ; - m_X128_Y1.push_back(X128_Y1) ; - m_X1_Y128.push_back(X1_Y128) ; - m_X128_Y128.push_back(X128_Y128) ; - m_wTracker.push_back(wTracker) ; - m_wCalorimeter.push_back(wCalorimeter) ; - - m_R.push_back(0) ; - m_Theta.push_back(0) ; - m_Phi.push_back(0) ; - m_beta_u.push_back(0) ; - m_beta_v.push_back(0) ; - m_beta_w.push_back(0) ; +void ComptonTelescope::AddModule(G4ThreeVector X1_Y1, G4ThreeVector X128_Y1, G4ThreeVector X1_Y128, + G4ThreeVector X128_Y128, bool wTracker, bool wCalorimeter) { + m_DefinitionType.push_back(true); + + m_X1_Y1.push_back(X1_Y1); + m_X128_Y1.push_back(X128_Y1); + m_X1_Y128.push_back(X1_Y128); + m_X128_Y128.push_back(X128_Y128); + m_wTracker.push_back(wTracker); + m_wCalorimeter.push_back(wCalorimeter); + + m_R.push_back(0); + m_Theta.push_back(0); + m_Phi.push_back(0); + m_beta_u.push_back(0); + m_beta_v.push_back(0); + m_beta_w.push_back(0); } - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void ComptonTelescope::AddModule(G4double R , - G4double Theta , - G4double Phi , - G4double beta_u , - G4double beta_v , - G4double beta_w , - bool wTracker , - bool wCalorimeter) -{ - G4ThreeVector empty = G4ThreeVector(0, 0, 0); - - m_DefinitionType.push_back(false); - - m_R.push_back(R) ; - m_Theta.push_back(Theta) ; - m_Phi.push_back(Phi) ; - m_beta_u.push_back(beta_u) ; - m_beta_v.push_back(beta_v) ; - m_beta_w.push_back(beta_w) ; - m_wTracker.push_back(wTracker) ; - m_wCalorimeter.push_back(wCalorimeter) ; - - m_X1_Y1.push_back(empty) ; - m_X128_Y1.push_back(empty) ; - m_X1_Y128.push_back(empty) ; - m_X128_Y128.push_back(empty) ; +void ComptonTelescope::AddModule(G4double R, G4double Theta, G4double Phi, G4double beta_u, G4double beta_v, + G4double beta_w, bool wTracker, bool wCalorimeter) { + G4ThreeVector empty = G4ThreeVector(0, 0, 0); + + m_DefinitionType.push_back(false); + + m_R.push_back(R); + m_Theta.push_back(Theta); + m_Phi.push_back(Phi); + m_beta_u.push_back(beta_u); + m_beta_v.push_back(beta_v); + m_beta_w.push_back(beta_w); + m_wTracker.push_back(wTracker); + m_wCalorimeter.push_back(wCalorimeter); + + m_X1_Y1.push_back(empty); + m_X128_Y1.push_back(empty); + m_X1_Y128.push_back(empty); + m_X128_Y128.push_back(empty); } - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void ComptonTelescope::VolumeMaker(G4int TelescopeNumber, - G4ThreeVector CTpos, - G4RotationMatrix* CTrot, - bool wTracker, - bool wCalorimeter, - G4LogicalVolume* world) -{ - G4double NbrTelescopes = TelescopeNumber ; - G4String DetectorNumber ; - ostringstream Number ; - Number << NbrTelescopes ; - DetectorNumber = Number.str() ; - - //////////////////////////////////////////////////////////////// - ////////////// Starting Volume Definition ////////////////////// - //////////////////////////////////////////////////////////////// - G4String Name = "ComptonTelescopeTower" + DetectorNumber; - - // calculate tower height - m_TowerHeight = (m_NumberOfDSSSD-1) * m_DistanceInterDSSSD + m_ThicknessOfDSSSD - + m_DistanceTrackerCalorimeter + m_ThicknessOfCalorimeter; - - G4Box* solidComptonTelescope = new G4Box(Name, 0.5*m_SizeOfDSSSD, 0.5*m_SizeOfDSSSD, 0.5*m_TowerHeight); - G4LogicalVolume* logicComptonTelescope = new G4LogicalVolume(solidComptonTelescope, m_MaterialVacuum, Name, 0, 0, 0); - - new G4PVPlacement(G4Transform3D(*CTrot, CTpos), logicComptonTelescope, Name, world, false, 0); - - logicComptonTelescope->SetVisAttributes(G4VisAttributes::Invisible); - if (m_non_sensitive_part_visiualisation) logicComptonTelescope->SetVisAttributes(G4VisAttributes(G4Colour(0.90, 0.90, 0.90))); - - - //////////////////////////////////////////////////////////// - //////////////// Tracker Construction ////////////////////// - //////////////////////////////////////////////////////////// - if (wTracker) { - // tracker detector itself - G4Box* solidTracker = new G4Box("solidTracker", 0.5*m_SizeOfDSSSD, 0.5*m_SizeOfDSSSD, 0.5*m_ThicknessOfDSSSD); - G4LogicalVolume* logicTracker = new G4LogicalVolume(solidTracker, m_MaterialSilicon, "logicTracker", 0, 0, 0); - - G4ThreeVector positionTracker; - for (G4int i = 0; i < m_NumberOfDSSSD; ++i) { // loop on number of DSSSDs - G4double position = -m_TowerHeight/2 + m_ThicknessOfDSSSD/2 + i*m_DistanceInterDSSSD; - positionTracker = G4ThreeVector(0, 0, position); - G4String nameTracker = Name + "_Tracker"; - ostringstream index; - index << i; - nameTracker = nameTracker + index.str(); - new G4PVPlacement(0, positionTracker, logicTracker, nameTracker, logicComptonTelescope, false, i); - } // end loop on number of DSSSDs - - // set tracker sensible - logicTracker->SetSensitiveDetector(m_TrackerScorer); - - // visualisation of tracker - G4VisAttributes* TrackerVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)); // blue - logicTracker->SetVisAttributes(TrackerVisAtt); - } - - - //////////////////////////////////////////////////////////////// - ///////////////// Calorimeter Construction ///////////////////// - //////////////////////////////////////////////////////////////// - if (wCalorimeter) { - // calorimeter detector - G4Box* solidCalorimeter = new G4Box("solidCalorimeter", 0.5*m_SizeOfDSSSD, 0.5*m_SizeOfDSSSD, 0.5*m_ThicknessOfCalorimeter); - G4LogicalVolume* logicCalorimeter = new G4LogicalVolume(solidCalorimeter, m_MaterialSilicon, "logicCalorimeter", 0, 0, 0); - - G4double position = m_TowerHeight/2 - m_ThicknessOfCalorimeter/2; - G4ThreeVector positionCalorimeter = G4ThreeVector(0, 0, position); - new G4PVPlacement(0, positionCalorimeter, logicCalorimeter, Name + "_Calorimeter", logicComptonTelescope, false, 0); - - // Set Third Stage sensible - logicCalorimeter->SetSensitiveDetector(m_CalorimeterScorer); - - ///Visualisation of Third Stage - G4VisAttributes* CalorimeterVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // green - logicCalorimeter->SetVisAttributes(CalorimeterVisAtt); - } +void ComptonTelescope::VolumeMaker(G4int TelescopeNumber, G4ThreeVector CTpos, G4RotationMatrix* CTrot, bool wTracker, + bool wCalorimeter, G4LogicalVolume* world) { + G4double NbrTelescopes = TelescopeNumber; + G4String DetectorNumber; + ostringstream Number; + Number << NbrTelescopes; + DetectorNumber = Number.str(); + + //////////////////////////////////////////////////////////////// + ////////////// Starting Volume Definition ////////////////////// + //////////////////////////////////////////////////////////////// + G4String Name = "ComptonTelescopeTower" + DetectorNumber; + + // calculate tower height + m_TowerHeight = (m_NumberOfDSSSD - 1) * m_DistanceInterDSSSD + m_ThicknessOfDSSSD + m_DistanceTrackerCalorimeter + + m_ThicknessOfCalorimeter; + + G4Box* solidComptonTelescope = new G4Box(Name, 0.5 * m_SizeOfDSSSD, 0.5 * m_SizeOfDSSSD, 0.5 * m_TowerHeight); + G4LogicalVolume* logicComptonTelescope = new G4LogicalVolume(solidComptonTelescope, m_MaterialVacuum, Name, 0, 0, 0); + + new G4PVPlacement(G4Transform3D(*CTrot, CTpos), logicComptonTelescope, Name, world, false, 0); + + logicComptonTelescope->SetVisAttributes(G4VisAttributes::GetInvisible()); + if (m_non_sensitive_part_visiualisation) + logicComptonTelescope->SetVisAttributes(G4VisAttributes(G4Colour(0.90, 0.90, 0.90))); + + //////////////////////////////////////////////////////////// + //////////////// Tracker Construction ////////////////////// + //////////////////////////////////////////////////////////// + if (wTracker) { + // tracker detector itself + G4Box* solidTracker = new G4Box("solidTracker", 0.5 * m_SizeOfDSSSD, 0.5 * m_SizeOfDSSSD, 0.5 * m_ThicknessOfDSSSD); + G4LogicalVolume* logicTracker = new G4LogicalVolume(solidTracker, m_MaterialSilicon, "logicTracker", 0, 0, 0); + + G4ThreeVector positionTracker; + for (G4int i = 0; i < m_NumberOfDSSSD; ++i) { // loop on number of DSSSDs + G4double position = -m_TowerHeight / 2 + m_ThicknessOfDSSSD / 2 + i * m_DistanceInterDSSSD; + positionTracker = G4ThreeVector(0, 0, position); + G4String nameTracker = Name + "_Tracker"; + ostringstream index; + index << i; + nameTracker = nameTracker + index.str(); + new G4PVPlacement(0, positionTracker, logicTracker, nameTracker, logicComptonTelescope, false, i); + } // end loop on number of DSSSDs + + // set tracker sensible + logicTracker->SetSensitiveDetector(m_TrackerScorer); + + // visualisation of tracker + G4VisAttributes* TrackerVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)); // blue + logicTracker->SetVisAttributes(TrackerVisAtt); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Calorimeter Construction ///////////////////// + //////////////////////////////////////////////////////////////// + if (wCalorimeter) { + // calorimeter detector + G4Box* solidCalorimeter = + new G4Box("solidCalorimeter", 0.5 * m_SizeOfDSSSD, 0.5 * m_SizeOfDSSSD, 0.5 * m_ThicknessOfCalorimeter); + G4LogicalVolume* logicCalorimeter = + new G4LogicalVolume(solidCalorimeter, m_MaterialSilicon, "logicCalorimeter", 0, 0, 0); + + G4double position = m_TowerHeight / 2 - m_ThicknessOfCalorimeter / 2; + G4ThreeVector positionCalorimeter = G4ThreeVector(0, 0, position); + new G4PVPlacement(0, positionCalorimeter, logicCalorimeter, Name + "_Calorimeter", logicComptonTelescope, false, 0); + + // Set Third Stage sensible + logicCalorimeter->SetSensitiveDetector(m_CalorimeterScorer); + + /// Visualisation of Third Stage + G4VisAttributes* CalorimeterVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // green + logicCalorimeter->SetVisAttributes(CalorimeterVisAtt); + } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -253,34 +219,47 @@ void ComptonTelescope::VolumeMaker(G4int TelescopeNumber, // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void ComptonTelescope::ReadConfiguration(NPL::InputParser parser ){ +void ComptonTelescope::ReadConfiguration(NPL::InputParser parser) { vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("ComptonTelescope"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " detectors found " << endl; - - vector<string> token = {"R","THETA","PHI","BETA","SIZE_DSSSD","NUMBER_DSSSD","DISTANCE_INTER_DSSSD","THICKNESS_DSSSD","NUMBER_STRIPS","DISTANCE_TRACKER_CALORIMETER","THICKNESS_CALORIMETER","TRACKER","CALORIMETER","VIS"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(token)){ - double R = blocks[i]->GetDouble("R","mm"); - double Theta = blocks[i]->GetDouble("THETA","deg"); - double Phi = blocks[i]->GetDouble("PHI","deg"); - vector<double> beta = blocks[i]->GetVectorDouble("BETA","deg"); - m_SizeOfDSSSD = blocks[i]->GetDouble("SIZE_DSSSD","mm"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + + vector<string> token = {"R", + "THETA", + "PHI", + "BETA", + "SIZE_DSSSD", + "NUMBER_DSSSD", + "DISTANCE_INTER_DSSSD", + "THICKNESS_DSSSD", + "NUMBER_STRIPS", + "DISTANCE_TRACKER_CALORIMETER", + "THICKNESS_CALORIMETER", + "TRACKER", + "CALORIMETER", + "VIS"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(token)) { + double R = blocks[i]->GetDouble("R", "mm"); + double Theta = blocks[i]->GetDouble("THETA", "deg"); + double Phi = blocks[i]->GetDouble("PHI", "deg"); + vector<double> beta = blocks[i]->GetVectorDouble("BETA", "deg"); + m_SizeOfDSSSD = blocks[i]->GetDouble("SIZE_DSSSD", "mm"); m_NumberOfDSSSD = blocks[i]->GetInt("NUMBER_DSSSD"); - m_DistanceInterDSSSD = blocks[i]->GetDouble("DISTANCE_INTER_DSSSD","mm"); - m_ThicknessOfDSSSD= blocks[i]->GetDouble("THICKNESS_DSSSD","mm"); + m_DistanceInterDSSSD = blocks[i]->GetDouble("DISTANCE_INTER_DSSSD", "mm"); + m_ThicknessOfDSSSD = blocks[i]->GetDouble("THICKNESS_DSSSD", "mm"); m_NumberOfStrips = blocks[i]->GetInt("NUMBER_STRIPS"); - m_DistanceTrackerCalorimeter = blocks[i]->GetDouble("DISTANCE_TRACKER_CALORIMETER","mm"); - m_ThicknessOfCalorimeter = blocks[i]->GetDouble("THICKNESS_CALORIMETER","mm"); - int tracker = blocks[i]->GetInt("TRACKER"); - int calorimeter = blocks[i]->GetInt("CALORIMETER"); + m_DistanceTrackerCalorimeter = blocks[i]->GetDouble("DISTANCE_TRACKER_CALORIMETER", "mm"); + m_ThicknessOfCalorimeter = blocks[i]->GetDouble("THICKNESS_CALORIMETER", "mm"); + int tracker = blocks[i]->GetInt("TRACKER"); + int calorimeter = blocks[i]->GetInt("CALORIMETER"); m_non_sensitive_part_visiualisation = blocks[i]->GetInt("VIS"); - AddModule(R,Theta,Phi,beta[0],beta[1],beta[2],tracker== 1 ,calorimeter== 1); + AddModule(R, Theta, Phi, beta[0], beta[1], beta[2], tracker == 1, calorimeter == 1); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } @@ -289,533 +268,537 @@ void ComptonTelescope::ReadConfiguration(NPL::InputParser parser ){ // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void ComptonTelescope::ConstructDetector(G4LogicalVolume* world) -{ - G4RotationMatrix* CTrot = NULL ; - G4ThreeVector CTpos = G4ThreeVector(0, 0, 0) ; - G4ThreeVector CTu = G4ThreeVector(0, 0, 0) ; - G4ThreeVector CTv = G4ThreeVector(0, 0, 0) ; - G4ThreeVector CTw = G4ThreeVector(0, 0, 0) ; - G4ThreeVector CTCenter = G4ThreeVector(0, 0, 0) ; - bool FirstStage = true; - bool SecondStage = true; - - G4int NumberOfTelescope = m_DefinitionType.size() ; - - for (G4int i = 0; i < NumberOfTelescope; i++) { - // By Point - if (m_DefinitionType[i]) { - // (u,v,w) unitary vector associated to telescope referencial - // (u,v) // to silicon plan - // w perpendicular to (u,v) plan and pointing ThirdStage - CTu = m_X128_Y1[i] - m_X1_Y1[i]; - CTu = CTu.unit(); - - CTv = m_X1_Y128[i] - m_X1_Y1[i]; - CTv = CTv.unit(); - - CTw = CTu.cross(CTv); - CTw = CTw.unit(); - - CTCenter = (m_X1_Y1[i] + m_X1_Y128[i] + m_X128_Y1[i] + m_X128_Y128[i]) / 4; - - // Passage Matrix from Lab Referential to Telescope Referential - CTrot = new G4RotationMatrix(CTu, CTv, CTw); - // translation to place Telescope - CTpos = CTw * m_TowerHeight * 0.5 + CTCenter; - } +void ComptonTelescope::ConstructDetector(G4LogicalVolume* world) { + G4RotationMatrix* CTrot = NULL; + G4ThreeVector CTpos = G4ThreeVector(0, 0, 0); + G4ThreeVector CTu = G4ThreeVector(0, 0, 0); + G4ThreeVector CTv = G4ThreeVector(0, 0, 0); + G4ThreeVector CTw = G4ThreeVector(0, 0, 0); + G4ThreeVector CTCenter = G4ThreeVector(0, 0, 0); + bool FirstStage = true; + bool SecondStage = true; + + G4int NumberOfTelescope = m_DefinitionType.size(); + + for (G4int i = 0; i < NumberOfTelescope; i++) { + // By Point + if (m_DefinitionType[i]) { + // (u,v,w) unitary vector associated to telescope referencial + // (u,v) // to silicon plan + // w perpendicular to (u,v) plan and pointing ThirdStage + CTu = m_X128_Y1[i] - m_X1_Y1[i]; + CTu = CTu.unit(); + + CTv = m_X1_Y128[i] - m_X1_Y1[i]; + CTv = CTv.unit(); + + CTw = CTu.cross(CTv); + CTw = CTw.unit(); + + CTCenter = (m_X1_Y1[i] + m_X1_Y128[i] + m_X128_Y1[i] + m_X128_Y128[i]) / 4; + + // Passage Matrix from Lab Referential to Telescope Referential + CTrot = new G4RotationMatrix(CTu, CTv, CTw); + // translation to place Telescope + CTpos = CTw * m_TowerHeight * 0.5 + CTCenter; + } - // By Angle - else { - G4double Theta = m_Theta[i] ; - G4double Phi = m_Phi[i] ; - - // (u,v,w) unitary vector associated to telescope referencial - // (u,v) // to silicon plan - // w perpendicular to (u,v) plan and pointing ThirdStage - // Phi is angle between X axis and projection in (X,Y) plan - // Theta is angle between position vector and z axis - G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad); - G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad); - G4double wZ = m_R[i] * cos(Theta / rad); - CTw = G4ThreeVector(wX, wY, wZ); - - // vector corresponding to the center of the module - CTCenter = CTw; - - // vector parallel to one axis of silicon plane - G4double ii = cos(Theta / rad) * cos(Phi / rad); - G4double jj = cos(Theta / rad) * sin(Phi / rad); - G4double kk = -sin(Theta / rad); - G4ThreeVector Y = G4ThreeVector(ii, jj, kk); - - CTw = CTw.unit(); - CTu = CTw.cross(Y); - CTv = CTw.cross(CTu); - CTv = CTv.unit(); - CTu = CTu.unit(); - - // Passage Matrix from Lab Referential to Telescope Referential - // MUST2 - CTrot = new G4RotationMatrix(CTu, CTv, CTw); - // Telescope is rotate of Beta angle around CTv axis. - CTrot->rotate(m_beta_u[i], CTu); - CTrot->rotate(m_beta_v[i], CTv); - CTrot->rotate(m_beta_w[i], CTw); - // translation to place Telescope - CTpos = CTw * m_TowerHeight * 0.5 + CTCenter; - } + // By Angle + else { + G4double Theta = m_Theta[i]; + G4double Phi = m_Phi[i]; + + // (u,v,w) unitary vector associated to telescope referencial + // (u,v) // to silicon plan + // w perpendicular to (u,v) plan and pointing ThirdStage + // Phi is angle between X axis and projection in (X,Y) plan + // Theta is angle between position vector and z axis + G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad); + G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad); + G4double wZ = m_R[i] * cos(Theta / rad); + CTw = G4ThreeVector(wX, wY, wZ); + + // vector corresponding to the center of the module + CTCenter = CTw; + + // vector parallel to one axis of silicon plane + G4double ii = cos(Theta / rad) * cos(Phi / rad); + G4double jj = cos(Theta / rad) * sin(Phi / rad); + G4double kk = -sin(Theta / rad); + G4ThreeVector Y = G4ThreeVector(ii, jj, kk); + + CTw = CTw.unit(); + CTu = CTw.cross(Y); + CTv = CTw.cross(CTu); + CTv = CTv.unit(); + CTu = CTu.unit(); + + // Passage Matrix from Lab Referential to Telescope Referential + // MUST2 + CTrot = new G4RotationMatrix(CTu, CTv, CTw); + // Telescope is rotate of Beta angle around CTv axis. + CTrot->rotate(m_beta_u[i], CTu); + CTrot->rotate(m_beta_v[i], CTv); + CTrot->rotate(m_beta_w[i], CTw); + // translation to place Telescope + CTpos = CTw * m_TowerHeight * 0.5 + CTCenter; + } - FirstStage = m_wTracker[i] ; - SecondStage = m_wCalorimeter[i] ; + FirstStage = m_wTracker[i]; + SecondStage = m_wCalorimeter[i]; - VolumeMaker(i + 1, CTpos, CTrot, FirstStage, SecondStage, world); - } + VolumeMaker(i + 1, CTpos, CTrot, FirstStage, SecondStage, world); + } - delete CTrot ; + delete CTrot; } - - // Connect the GaspardTrackingData class to the output TTree // of the simulation -void ComptonTelescope::InitializeRootOutput() -{ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("ComptonTelescope")){ - pTree->Branch("ComptonTelescope", "TComptonTelescopeData", &m_Event); - } - if(!pTree->FindBranch("ComptonTelescopeProcess")){ +void ComptonTelescope::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("ComptonTelescope")) { + pTree->Branch("ComptonTelescope", "TComptonTelescopeData", &m_Event); + } + if (!pTree->FindBranch("ComptonTelescopeProcess")) { pTree->Branch("ComptonTelescopeProcess", "TComptonTelescopeProcessData", &m_ProcessEvent); - } - pTree->SetBranchAddress("ComptonTelescope", &m_Event); - pTree->SetBranchAddress("ComptonTelescopeProcess", &m_ProcessEvent); - + } + pTree->SetBranchAddress("ComptonTelescope", &m_Event); + pTree->SetBranchAddress("ComptonTelescopeProcess", &m_ProcessEvent); } - - // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void ComptonTelescope::ReadSensitive(const G4Event* event) -{ - m_Event->Clear(); - - ////////////////////////////////////////////////////////////////////////////////////// - //////////////////////// Used to Read Event Map of detector ////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - // Tracker - std::map<G4int, G4int*>::iterator TowerNumber_itr; - std::map<G4int, G4int*>::iterator DSSSDNumber_itr; - std::map<G4int, G4double*>::iterator Energy_itr; - std::map<G4int, G4double*>::iterator Time_itr; -/* std::map<G4int, G4int*>::iterator X_itr; - std::map<G4int, G4int*>::iterator Y_itr; - std::map<G4int, G4double*>::iterator Pos_X_itr; - std::map<G4int, G4double*>::iterator Pos_Y_itr; - std::map<G4int, G4double*>::iterator Pos_Z_itr; - std::map<G4int, G4double*>::iterator Ang_Theta_itr; - std::map<G4int, G4double*>::iterator Ang_Phi_itr; -*/ - NPS::HitsMap<G4int>* TowerNumberHitMap; - NPS::HitsMap<G4int>* DSSSDNumberHitMap; - NPS::HitsMap<G4double>* EnergyHitMap; - NPS::HitsMap<G4double>* TimeHitMap; -/* NPS::HitsMap<G4int>* XHitMap; - NPS::HitsMap<G4int>* YHitMap; - NPS::HitsMap<G4double>* PosXHitMap; - NPS::HitsMap<G4double>* PosYHitMap; - NPS::HitsMap<G4double>* PosZHitMap; - NPS::HitsMap<G4double>* AngThetaHitMap; - NPS::HitsMap<G4double>* AngPhiHitMap; -*/ - // Calorimeter - std::map<G4int, G4int*>::iterator CalorimeterTowerNumber_itr; - std::map<G4int, G4int*>::iterator CalorimeterDetectorNumber_itr; - std::map<G4int, G4double*>::iterator CalorimeterEnergy_itr; -// std::map<G4int, G4double*>::iterator CalorimeterTime_itr; - NPS::HitsMap<G4int>* CalorimeterTowerNumberHitMap; - NPS::HitsMap<G4int>* CalorimeterDetectorNumberHitMap; - NPS::HitsMap<G4double>* CalorimeterEnergyHitMap; -// NPS::HitsMap<G4double>* CalorimeterTimeHitMap; - - - // Read scorers associated to the tracker part - // tower number - G4int TrackTowCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/TowerNumber"); - TowerNumberHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(TrackTowCollectionID)); - TowerNumber_itr = TowerNumberHitMap->GetMap()->begin(); - - // detector number - G4int TrackDetCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/DSSSDNumber"); - DSSSDNumberHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(TrackDetCollectionID)); - DSSSDNumber_itr = DSSSDNumberHitMap->GetMap()->begin(); - - // energy - G4int TrackEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/Energy"); - EnergyHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(TrackEnergyCollectionID)) ; - Energy_itr = EnergyHitMap->GetMap()->begin(); - - // time of flight - G4int TrackTimeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/Time"); - TimeHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(TrackTimeCollectionID)); - Time_itr = TimeHitMap->GetMap()->begin(); -/* - //Track Number X - G4int TrackXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/NumberX"); - XHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(TrackXCollectionID)); - X_itr = XHitMap->GetMap()->begin(); - - //Track Number Y - G4int TrackYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/TrackNumberY") ; - YHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(TrackYCollectionID)); - Y_itr = YHitMap->GetMap()->begin(); - - //Interaction Coordinate X - G4int InterCoordXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/InterCoordX") ; - PosXHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordXCollectionID)) ; - Pos_X_itr = PosXHitMap->GetMap()->begin() ; - - //Interaction Coordinate Y - G4int InterCoordYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/InterCoordY") ; - PosYHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordYCollectionID)) ; - Pos_Y_itr = PosYHitMap->GetMap()->begin() ; - - //Interaction Coordinate Z - G4int InterCoordZCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/InterCoordZ") ; - PosZHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordZCollectionID)) ; - Pos_Z_itr = PosXHitMap->GetMap()->begin() ; - - //Interaction Coordinate Angle Theta - G4int InterCoordAngThetaCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/InterCoordAngTheta") ; - AngThetaHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngThetaCollectionID)) ; - Ang_Theta_itr = AngThetaHitMap->GetMap()->begin() ; - - //Interaction Coordinate Angle Phi - G4int InterCoordAngPhiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/InterCoordAngPhi") ; - AngPhiHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngPhiCollectionID)) ; - Ang_Phi_itr = AngPhiHitMap->GetMap()->begin() ; -*/ - - // read the scorers associated to the calorimeter - // tower number - G4int CaloTowCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("CalorimeterScorerComptonTelescope/TowerNumber"); - CalorimeterTowerNumberHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(CaloTowCollectionID)); - CalorimeterTowerNumber_itr = CalorimeterTowerNumberHitMap->GetMap()->begin(); - - // detector number - G4int CaloDetCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("CalorimeterScorerComptonTelescope/DetectorNumber"); - CalorimeterDetectorNumberHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(CaloDetCollectionID)); - CalorimeterDetectorNumber_itr = CalorimeterDetectorNumberHitMap->GetMap()->begin(); - - // energy - G4int CaloEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("CalorimeterScorerComptonTelescope/Energy"); - CalorimeterEnergyHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(CaloEnergyCollectionID)) ; - CalorimeterEnergy_itr = CalorimeterEnergyHitMap->GetMap()->begin(); -/* - // time of flight - G4int CaloTimeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("CalorimeterScorerComptonTelescope/Time"); - CalorimeterTimeHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(CaloTimeCollectionID)); - CalorimeterTime_itr = CalorimeterTimeHitMap->GetMap()->begin(); -*/ - - // Calorimeter -// G4int sizeCaloTower = ->entries(); - - // Check the size of different map - G4int sizeTrackerNtower = TowerNumberHitMap->entries(); - G4int sizeTrackerNdsssd = DSSSDNumberHitMap->entries(); sizeTrackerNdsssd *= 1; - G4int sizeTrackerE = EnergyHitMap->entries(); - G4int sizeTrackerT = TimeHitMap->entries(); -// G4cout << sizeTrackerNtower << "\t" << sizeTrackerNdsssd << "\t" << sizeTrackerE << "\t" << sizeTrackerT << G4endl; -// G4int sizeTrackerX = XHitMap->entries(); -// G4int sizeTrackerY = YHitMap->entries(); - -// if (sizeE != sizeT || sizeT != sizeX || sizeX != sizeY) { - if (sizeTrackerE != sizeTrackerT) { - G4cout << "No match size Si Event Map: sE:" << sizeTrackerE << " sT:" << sizeTrackerT << G4endl ; - return; - } - - G4double Etot = 0; - - // Loop on FirstStage number - for (G4int l = 0; l < sizeTrackerNtower; l++) { - G4double N = *(TowerNumber_itr->second); - G4int NTrackID = TowerNumber_itr->first - N; -// G4cout << N << "\t" << NTrackID << G4endl; - - if (N > 0) { - // Fill tower number - m_Event->SetCTTrackerFrontETowerNbr(N); - m_Event->SetCTTrackerFrontTTowerNbr(N); - m_Event->SetCTTrackerBackEDetectorNbr(N); - m_Event->SetCTTrackerBackTDetectorNbr(N); - - // Energy - Energy_itr = EnergyHitMap->GetMap()->begin(); - for (G4int ll = 0 ; ll < sizeTrackerE ; ll++) { - G4int ETrackID = Energy_itr->first - N; - G4double E = *(Energy_itr->second); - if (ETrackID == NTrackID) { - Etot += E; - m_Event->SetCTTrackerFrontEEnergy(RandGauss::shoot(E, EnergyResolutionTracker)); -// m_Event->SetCTTrackerBackEEnergy(RandGauss::shoot(E, EnergyResolutionTracker)); - } - Energy_itr++; - } - - // Time - Time_itr = TimeHitMap->GetMap()->begin(); - for (G4int h = 0 ; h < sizeTrackerT ; h++) { - G4int TTrackID = Time_itr->first - N; - G4double T = *(Time_itr->second); - if (TTrackID == NTrackID) { - m_Event->SetCTTrackerFrontTTime(RandGauss::shoot(T, TimeResolutionTracker)); - m_Event->SetCTTrackerBackTTime(RandGauss::shoot(T, TimeResolutionTracker)); - } - Time_itr++; - } -/* - // X - X_itr = XHitMap->GetMap()->begin(); - for (G4int h = 0 ; h < sizeTrackerX ; h++) { - G4int XTrackID = X_itr->first - N; - G4int X = *(X_itr->second); - if (XTrackID == NTrackID) { - m_Event->SetCTFrontEStripNbr(X); - m_Event->SetCTFrontTStripNbr(X); - } - - X_itr++; - } - - // Y - Y_itr = YHitMap->GetMap()->begin() ; - for (G4int h = 0 ; h < sizeTrackerY ; h++) { - G4int YTrackID = Y_itr->first - N; - G4int Y = *(Y_itr->second); - if (YTrackID == NTrackID) { - m_Event->SetCTBackEStripNbr(Y); - m_Event->SetCTBackTStripNbr(Y); - } - - Y_itr++; - } - - // Pos X - Pos_X_itr = PosXHitMap->GetMap()->begin(); - for (G4int h = 0; h < PosXHitMap->entries(); h++) { - G4int PosXTrackID = Pos_X_itr->first - N ; - G4double PosX = *(Pos_X_itr->second) ; - if (PosXTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionX(PosX) ; - } - Pos_X_itr++; - } - - // Pos Y - Pos_Y_itr = PosYHitMap->GetMap()->begin(); - for (G4int h = 0; h < PosYHitMap->entries(); h++) { - G4int PosYTrackID = Pos_Y_itr->first - N ; - G4double PosY = *(Pos_Y_itr->second) ; - if (PosYTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionY(PosY) ; - } - Pos_Y_itr++; - } - - // Pos Z - Pos_Z_itr = PosZHitMap->GetMap()->begin(); - for (G4int h = 0; h < PosZHitMap->entries(); h++) { - G4int PosZTrackID = Pos_Z_itr->first - N ; - G4double PosZ = *(Pos_Z_itr->second) ; - if (PosZTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionZ(PosZ) ; - } - Pos_Z_itr++; - } - - // Angle Theta - Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); - for (G4int h = 0; h < AngThetaHitMap->entries(); h++) { - G4int AngThetaTrackID = Ang_Theta_itr->first - N ; - G4double AngTheta = *(Ang_Theta_itr->second) ; - if (AngThetaTrackID == NTrackID) { - ms_InterCoord->SetDetectedAngleTheta(AngTheta) ; - } - Ang_Theta_itr++; - } - - // Angle Phi - Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); - for (G4int h = 0; h < AngPhiHitMap->entries(); h++) { - G4int AngPhiTrackID = Ang_Phi_itr->first - N ; - G4double AngPhi = *(Ang_Phi_itr->second) ; - if (AngPhiTrackID == NTrackID) { - ms_InterCoord->SetDetectedAnglePhi(AngPhi) ; - } - Ang_Phi_itr++; - } -*/ -/* - // Third Stage - ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin() ; - for (G4int h = 0 ; h < ThirdStageEnergyHitMap->entries() ; h++) { - G4int ThirdStageEnergyTrackID = ThirdStageEnergy_itr->first - N; - G4double ThirdStageEnergy = *(ThirdStageEnergy_itr->second) ; - - if (ThirdStageEnergyTrackID == NTrackID) { - m_Event->SetGPDTrkThirdStageEEnergy(RandGauss::shoot(ThirdStageEnergy, ResoThirdStage)); - m_Event->SetGPDTrkThirdStageEPadNbr(1); - m_Event->SetGPDTrkThirdStageTPadNbr(1); - m_Event->SetGPDTrkThirdStageTTime(1); - m_Event->SetGPDTrkThirdStageTDetectorNbr(m_index["Square"] + N); - m_Event->SetGPDTrkThirdStageEDetectorNbr(m_index["Square"] + N); - } - - ThirdStageEnergy_itr++; - } -*/ - } - TowerNumber_itr++; - - } - - // Fill total energy here - if (Etot > 0) m_Event->SetCTTrackerBackEEnergy(RandGauss::shoot(Etot, EnergyResolutionTracker)); - - // clear map for next event - TowerNumberHitMap -> clear(); - DSSSDNumberHitMap -> clear(); - EnergyHitMap -> clear(); - TimeHitMap -> clear(); -/* XHitMap ->clear() ; - YHitMap ->clear() ; - PosXHitMap ->clear(); - PosYHitMap ->clear(); - PosZHitMap ->clear(); - AngThetaHitMap ->clear(); - AngPhiHitMap ->clear();*/ -// ThirdStageEnergyHitMap ->clear(); - - /////////////////////////////////////////////////// - // counting processes (compton, .....) // - /////////////////////////////////////////////////// - // clear root object - m_ProcessEvent->Clear(); - - // scorers for processes.... - std::map<G4int, G4double*>::iterator TrkProcC_itr; - NPS::HitsMap<G4double>* TrkProcCHitMap; - G4int TrkProcCCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/Process"); - TrkProcCHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(TrkProcCCollectionID)) ; - TrkProcC_itr = TrkProcCHitMap->GetMap()->begin(); - - for (G4int l = 0; l < TrkProcCHitMap->entries(); l++) { - // get electron energy - G4double ElectronKineticEnergy = *(TrkProcC_itr->second); - // get tower, dssd number & trackID - G4int index = TrkProcC_itr->first; -// G4cout << "Read Sensitive : " << l << "\t" << index << G4endl; - G4int towerID = index / (G4int)pow(100.,2.); - index -= towerID * (G4int)pow(100.,2.); - G4int dsssdID = index / (G4int)pow(100.,1.); - G4int trackID = index - dsssdID * (G4int)pow(100.,1.); - trackID *= 1; -// G4cout << "IDs : " << towerID << "\t" << dsssdID << "\t" << trackID << G4endl; -// G4cout << "Energy : " << ElectronKineticEnergy << G4endl; - // fill process data class - m_ProcessEvent->SetCTTrackerComptonTowerNbr(towerID); - m_ProcessEvent->SetCTTrackerComptonDetectorNbr(dsssdID); - m_ProcessEvent->SetCTTrackerComptonEnergy(ElectronKineticEnergy); - - TrkProcC_itr++; - } - TrkProcCHitMap->clear(); +void ComptonTelescope::ReadSensitive(const G4Event* event) { + m_Event->Clear(); + + ////////////////////////////////////////////////////////////////////////////////////// + //////////////////////// Used to Read Event Map of detector ////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + // Tracker + std::map<G4int, G4int*>::iterator TowerNumber_itr; + std::map<G4int, G4int*>::iterator DSSSDNumber_itr; + std::map<G4int, G4double*>::iterator Energy_itr; + std::map<G4int, G4double*>::iterator Time_itr; + /* std::map<G4int, G4int*>::iterator X_itr; + std::map<G4int, G4int*>::iterator Y_itr; + std::map<G4int, G4double*>::iterator Pos_X_itr; + std::map<G4int, G4double*>::iterator Pos_Y_itr; + std::map<G4int, G4double*>::iterator Pos_Z_itr; + std::map<G4int, G4double*>::iterator Ang_Theta_itr; + std::map<G4int, G4double*>::iterator Ang_Phi_itr; + */ + NPS::HitsMap<G4int>* TowerNumberHitMap; + NPS::HitsMap<G4int>* DSSSDNumberHitMap; + NPS::HitsMap<G4double>* EnergyHitMap; + NPS::HitsMap<G4double>* TimeHitMap; + /* NPS::HitsMap<G4int>* XHitMap; + NPS::HitsMap<G4int>* YHitMap; + NPS::HitsMap<G4double>* PosXHitMap; + NPS::HitsMap<G4double>* PosYHitMap; + NPS::HitsMap<G4double>* PosZHitMap; + NPS::HitsMap<G4double>* AngThetaHitMap; + NPS::HitsMap<G4double>* AngPhiHitMap; + */ + // Calorimeter + std::map<G4int, G4int*>::iterator CalorimeterTowerNumber_itr; + std::map<G4int, G4int*>::iterator CalorimeterDetectorNumber_itr; + std::map<G4int, G4double*>::iterator CalorimeterEnergy_itr; + // std::map<G4int, G4double*>::iterator CalorimeterTime_itr; + NPS::HitsMap<G4int>* CalorimeterTowerNumberHitMap; + NPS::HitsMap<G4int>* CalorimeterDetectorNumberHitMap; + NPS::HitsMap<G4double>* CalorimeterEnergyHitMap; + // NPS::HitsMap<G4double>* CalorimeterTimeHitMap; + + // Read scorers associated to the tracker part + // tower number + G4int TrackTowCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/TowerNumber"); + TowerNumberHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(TrackTowCollectionID)); + TowerNumber_itr = TowerNumberHitMap->GetMap()->begin(); + + // detector number + G4int TrackDetCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/DSSSDNumber"); + DSSSDNumberHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(TrackDetCollectionID)); + DSSSDNumber_itr = DSSSDNumberHitMap->GetMap()->begin(); + + // energy + G4int TrackEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/Energy"); + EnergyHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(TrackEnergyCollectionID)); + Energy_itr = EnergyHitMap->GetMap()->begin(); + + // time of flight + G4int TrackTimeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/Time"); + TimeHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(TrackTimeCollectionID)); + Time_itr = TimeHitMap->GetMap()->begin(); + /* + //Track Number X + G4int TrackXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/NumberX"); + XHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(TrackXCollectionID)); + X_itr = XHitMap->GetMap()->begin(); + + //Track Number Y + G4int TrackYCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/TrackNumberY") ; YHitMap = + (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(TrackYCollectionID)); Y_itr = YHitMap->GetMap()->begin(); + + //Interaction Coordinate X + G4int InterCoordXCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/InterCoordX") ; PosXHitMap = + (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordXCollectionID)) ; + Pos_X_itr = PosXHitMap->GetMap()->begin() ; + + //Interaction Coordinate Y + G4int InterCoordYCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/InterCoordY") ; PosYHitMap = + (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordYCollectionID)) ; + Pos_Y_itr = PosYHitMap->GetMap()->begin() ; + + //Interaction Coordinate Z + G4int InterCoordZCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/InterCoordZ") ; PosZHitMap = + (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordZCollectionID)) ; + Pos_Z_itr = PosXHitMap->GetMap()->begin() ; + + //Interaction Coordinate Angle Theta + G4int InterCoordAngThetaCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/InterCoordAngTheta") ; + AngThetaHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngThetaCollectionID)) ; + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin() ; + + //Interaction Coordinate Angle Phi + G4int InterCoordAngPhiCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/InterCoordAngPhi") ; AngPhiHitMap = + (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngPhiCollectionID)) ; Ang_Phi_itr = + AngPhiHitMap->GetMap()->begin() ; + */ + + // read the scorers associated to the calorimeter + // tower number + G4int CaloTowCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("CalorimeterScorerComptonTelescope/TowerNumber"); + CalorimeterTowerNumberHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(CaloTowCollectionID)); + CalorimeterTowerNumber_itr = CalorimeterTowerNumberHitMap->GetMap()->begin(); + + // detector number + G4int CaloDetCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("CalorimeterScorerComptonTelescope/DetectorNumber"); + CalorimeterDetectorNumberHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(CaloDetCollectionID)); + CalorimeterDetectorNumber_itr = CalorimeterDetectorNumberHitMap->GetMap()->begin(); + + // energy + G4int CaloEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("CalorimeterScorerComptonTelescope/Energy"); + CalorimeterEnergyHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(CaloEnergyCollectionID)); + CalorimeterEnergy_itr = CalorimeterEnergyHitMap->GetMap()->begin(); + /* + // time of flight + G4int CaloTimeCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("CalorimeterScorerComptonTelescope/Time"); CalorimeterTimeHitMap = + (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(CaloTimeCollectionID)); CalorimeterTime_itr = + CalorimeterTimeHitMap->GetMap()->begin(); + */ + + // Calorimeter + // G4int sizeCaloTower = ->entries(); + + // Check the size of different map + G4int sizeTrackerNtower = TowerNumberHitMap->entries(); + G4int sizeTrackerNdsssd = DSSSDNumberHitMap->entries(); + sizeTrackerNdsssd *= 1; + G4int sizeTrackerE = EnergyHitMap->entries(); + G4int sizeTrackerT = TimeHitMap->entries(); + // G4cout << sizeTrackerNtower << "\t" << sizeTrackerNdsssd << "\t" << sizeTrackerE << "\t" << sizeTrackerT << + // G4endl; G4int sizeTrackerX = XHitMap->entries(); G4int sizeTrackerY = YHitMap->entries(); + + // if (sizeE != sizeT || sizeT != sizeX || sizeX != sizeY) { + if (sizeTrackerE != sizeTrackerT) { + G4cout << "No match size Si Event Map: sE:" << sizeTrackerE << " sT:" << sizeTrackerT << G4endl; + return; + } -} + G4double Etot = 0; + + // Loop on FirstStage number + for (G4int l = 0; l < sizeTrackerNtower; l++) { + G4double N = *(TowerNumber_itr->second); + G4int NTrackID = TowerNumber_itr->first - N; + // G4cout << N << "\t" << NTrackID << G4endl; + + if (N > 0) { + // Fill tower number + m_Event->SetCTTrackerFrontETowerNbr(N); + m_Event->SetCTTrackerFrontTTowerNbr(N); + m_Event->SetCTTrackerBackEDetectorNbr(N); + m_Event->SetCTTrackerBackTDetectorNbr(N); + + // Energy + Energy_itr = EnergyHitMap->GetMap()->begin(); + for (G4int ll = 0; ll < sizeTrackerE; ll++) { + G4int ETrackID = Energy_itr->first - N; + G4double E = *(Energy_itr->second); + if (ETrackID == NTrackID) { + Etot += E; + m_Event->SetCTTrackerFrontEEnergy(RandGauss::shoot(E, EnergyResolutionTracker)); + // m_Event->SetCTTrackerBackEEnergy(RandGauss::shoot(E, EnergyResolutionTracker)); + } + Energy_itr++; + } + // Time + Time_itr = TimeHitMap->GetMap()->begin(); + for (G4int h = 0; h < sizeTrackerT; h++) { + G4int TTrackID = Time_itr->first - N; + G4double T = *(Time_itr->second); + if (TTrackID == NTrackID) { + m_Event->SetCTTrackerFrontTTime(RandGauss::shoot(T, TimeResolutionTracker)); + m_Event->SetCTTrackerBackTTime(RandGauss::shoot(T, TimeResolutionTracker)); + } + Time_itr++; + } + /* + // X + X_itr = XHitMap->GetMap()->begin(); + for (G4int h = 0 ; h < sizeTrackerX ; h++) { + G4int XTrackID = X_itr->first - N; + G4int X = *(X_itr->second); + if (XTrackID == NTrackID) { + m_Event->SetCTFrontEStripNbr(X); + m_Event->SetCTFrontTStripNbr(X); + } + + X_itr++; + } + + // Y + Y_itr = YHitMap->GetMap()->begin() ; + for (G4int h = 0 ; h < sizeTrackerY ; h++) { + G4int YTrackID = Y_itr->first - N; + G4int Y = *(Y_itr->second); + if (YTrackID == NTrackID) { + m_Event->SetCTBackEStripNbr(Y); + m_Event->SetCTBackTStripNbr(Y); + } + + Y_itr++; + } + + // Pos X + Pos_X_itr = PosXHitMap->GetMap()->begin(); + for (G4int h = 0; h < PosXHitMap->entries(); h++) { + G4int PosXTrackID = Pos_X_itr->first - N ; + G4double PosX = *(Pos_X_itr->second) ; + if (PosXTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionX(PosX) ; + } + Pos_X_itr++; + } + + // Pos Y + Pos_Y_itr = PosYHitMap->GetMap()->begin(); + for (G4int h = 0; h < PosYHitMap->entries(); h++) { + G4int PosYTrackID = Pos_Y_itr->first - N ; + G4double PosY = *(Pos_Y_itr->second) ; + if (PosYTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionY(PosY) ; + } + Pos_Y_itr++; + } + + // Pos Z + Pos_Z_itr = PosZHitMap->GetMap()->begin(); + for (G4int h = 0; h < PosZHitMap->entries(); h++) { + G4int PosZTrackID = Pos_Z_itr->first - N ; + G4double PosZ = *(Pos_Z_itr->second) ; + if (PosZTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionZ(PosZ) ; + } + Pos_Z_itr++; + } + + // Angle Theta + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); + for (G4int h = 0; h < AngThetaHitMap->entries(); h++) { + G4int AngThetaTrackID = Ang_Theta_itr->first - N ; + G4double AngTheta = *(Ang_Theta_itr->second) ; + if (AngThetaTrackID == NTrackID) { + ms_InterCoord->SetDetectedAngleTheta(AngTheta) ; + } + Ang_Theta_itr++; + } + + // Angle Phi + Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); + for (G4int h = 0; h < AngPhiHitMap->entries(); h++) { + G4int AngPhiTrackID = Ang_Phi_itr->first - N ; + G4double AngPhi = *(Ang_Phi_itr->second) ; + if (AngPhiTrackID == NTrackID) { + ms_InterCoord->SetDetectedAnglePhi(AngPhi) ; + } + Ang_Phi_itr++; + } + */ + /* + // Third Stage + ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin() ; + for (G4int h = 0 ; h < ThirdStageEnergyHitMap->entries() ; h++) { + G4int ThirdStageEnergyTrackID = ThirdStageEnergy_itr->first - N; + G4double ThirdStageEnergy = *(ThirdStageEnergy_itr->second) ; + + if (ThirdStageEnergyTrackID == NTrackID) { + m_Event->SetGPDTrkThirdStageEEnergy(RandGauss::shoot(ThirdStageEnergy, ResoThirdStage)); + m_Event->SetGPDTrkThirdStageEPadNbr(1); + m_Event->SetGPDTrkThirdStageTPadNbr(1); + m_Event->SetGPDTrkThirdStageTTime(1); + m_Event->SetGPDTrkThirdStageTDetectorNbr(m_index["Square"] + N); + m_Event->SetGPDTrkThirdStageEDetectorNbr(m_index["Square"] + N); + } + + ThirdStageEnergy_itr++; + } + */ + } + TowerNumber_itr++; + } -void ComptonTelescope::InitializeMaterial() -{ - m_MaterialSilicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); - m_MaterialAluminium = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); - m_MaterialLaBr3 = MaterialManager::getInstance()->GetMaterialFromLibrary("LaBr3"); - m_MaterialVacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); + // Fill total energy here + if (Etot > 0) + m_Event->SetCTTrackerBackEEnergy(RandGauss::shoot(Etot, EnergyResolutionTracker)); + + // clear map for next event + TowerNumberHitMap->clear(); + DSSSDNumberHitMap->clear(); + EnergyHitMap->clear(); + TimeHitMap->clear(); + /* XHitMap ->clear() ; + YHitMap ->clear() ; + PosXHitMap ->clear(); + PosYHitMap ->clear(); + PosZHitMap ->clear(); + AngThetaHitMap ->clear(); + AngPhiHitMap ->clear();*/ + // ThirdStageEnergyHitMap ->clear(); + + /////////////////////////////////////////////////// + // counting processes (compton, .....) // + /////////////////////////////////////////////////// + // clear root object + m_ProcessEvent->Clear(); + + // scorers for processes.... + std::map<G4int, G4double*>::iterator TrkProcC_itr; + NPS::HitsMap<G4double>* TrkProcCHitMap; + G4int TrkProcCCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/Process"); + TrkProcCHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(TrkProcCCollectionID)); + TrkProcC_itr = TrkProcCHitMap->GetMap()->begin(); + + for (G4int l = 0; l < TrkProcCHitMap->entries(); l++) { + // get electron energy + G4double ElectronKineticEnergy = *(TrkProcC_itr->second); + // get tower, dssd number & trackID + G4int index = TrkProcC_itr->first; + // G4cout << "Read Sensitive : " << l << "\t" << index << G4endl; + G4int towerID = index / (G4int)pow(100., 2.); + index -= towerID * (G4int)pow(100., 2.); + G4int dsssdID = index / (G4int)pow(100., 1.); + G4int trackID = index - dsssdID * (G4int)pow(100., 1.); + trackID *= 1; + // G4cout << "IDs : " << towerID << "\t" << dsssdID << "\t" << trackID << G4endl; + // G4cout << "Energy : " << ElectronKineticEnergy << G4endl; + // fill process data class + m_ProcessEvent->SetCTTrackerComptonTowerNbr(towerID); + m_ProcessEvent->SetCTTrackerComptonDetectorNbr(dsssdID); + m_ProcessEvent->SetCTTrackerComptonEnergy(ElectronKineticEnergy); + + TrkProcC_itr++; + } + TrkProcCHitMap->clear(); } +void ComptonTelescope::InitializeMaterial() { + m_MaterialSilicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); + m_MaterialAluminium = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); + m_MaterialLaBr3 = MaterialManager::getInstance()->GetMaterialFromLibrary("LaBr3"); + m_MaterialVacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); +} - -void ComptonTelescope::InitializeScorers() -{ - - bool already_exist = false; - // First stage Associate Scorer - m_TrackerScorer = CheckScorer("TrackerScorerComptonTelescope",already_exist); - if(already_exist) return; - - G4VPrimitiveScorer* TowerNbr = new ComptonTelescopeScorerTrackerTowerNumber("TowerNumber", "ComptonTelescopeTower", 0); - G4VPrimitiveScorer* DSSSDNbr = new ComptonTelescopeScorerTrackerDSSSDNumber("DSSSDNumber", "ComptonTelescopeTower", 0); - G4VPrimitiveScorer* Energy = new ComptonTelescopeScorerTrackerEnergy("Energy", "ComptonTelescopeTower", 0); - G4VPrimitiveScorer* TOF = new ComptonTelescopeScorerTrackerTOF("Time", "ComptonTelescopeTower", 0); - G4VPrimitiveScorer* ProcessTypeCompt = new ComptonTelescopeScorerProcess("Process", "ComptonTelescopeTower", "compt", 0); -/* G4VPrimitiveScorer* StripPositionX = new GPDScorerFirstStageFrontStripSquare("StripNumberX", 0, m_NumberOfStrips); - G4VPrimitiveScorer* StripPositionY = new GPDScorerFirstStageBackStripSquare("StripNumberY", 0, m_NumberOfStrips); - G4VPrimitiveScorer* InteractionCoordinatesX = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesX("InterCoordX","", 0); - G4VPrimitiveScorer* InteractionCoordinatesY = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesY("InterCoordY","", 0); - G4VPrimitiveScorer* InteractionCoordinatesZ = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ","", 0); - G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta","", 0); - G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi","", 0); -*/ - //and register it to the multifunctionnal detector - m_TrackerScorer->RegisterPrimitive(TowerNbr); - m_TrackerScorer->RegisterPrimitive(DSSSDNbr); - m_TrackerScorer->RegisterPrimitive(Energy); - m_TrackerScorer->RegisterPrimitive(TOF); - m_TrackerScorer->RegisterPrimitive(ProcessTypeCompt); -/* m_TrackerScorer->RegisterPrimitive(StripPositionX); - m_TrackerScorer->RegisterPrimitive(StripPositionY); - m_TrackerScorer->RegisterPrimitive(InteractionCoordinatesX); - m_TrackerScorer->RegisterPrimitive(InteractionCoordinatesY); - m_TrackerScorer->RegisterPrimitive(InteractionCoordinatesZ); - m_TrackerScorer->RegisterPrimitive(InteractionCoordinatesAngleTheta); - m_TrackerScorer->RegisterPrimitive(InteractionCoordinatesAnglePhi); -*/ - // Third stage Associate Scorer - m_CalorimeterScorer = new G4MultiFunctionalDetector("CalorimeterScorerComptonTelescope"); - G4VPrimitiveScorer* CaloTower = new ComptonTelescopeScorerCalorimeterTowerNumber("TowerNumber", "ComptonTelescopeTower", 0); - G4VPrimitiveScorer* CaloDetector = new ComptonTelescopeScorerCalorimeterDetectorNumber("DetectorNumber", "ComptonTelescopeTower", 0); - G4VPrimitiveScorer* CaloEnergy = new ComptonTelescopeScorerCalorimeterEnergy("Energy", "ComptonTelescopeTower", 0); -// G4VPrimitiveScorer* CaloTime = new ComptonTelescopeScorerCalorimeterTOF("Time", "ComptonTelescopeTower", 0); - m_CalorimeterScorer->RegisterPrimitive(CaloTower); - m_CalorimeterScorer->RegisterPrimitive(CaloDetector); - m_CalorimeterScorer->RegisterPrimitive(CaloEnergy); -// m_CalorimeterScorer->RegisterPrimitive(CaloTime); - - // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_TrackerScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_CalorimeterScorer); +void ComptonTelescope::InitializeScorers() { + + bool already_exist = false; + // First stage Associate Scorer + m_TrackerScorer = CheckScorer("TrackerScorerComptonTelescope", already_exist); + if (already_exist) + return; + + G4VPrimitiveScorer* TowerNbr = + new ComptonTelescopeScorerTrackerTowerNumber("TowerNumber", "ComptonTelescopeTower", 0); + G4VPrimitiveScorer* DSSSDNbr = + new ComptonTelescopeScorerTrackerDSSSDNumber("DSSSDNumber", "ComptonTelescopeTower", 0); + G4VPrimitiveScorer* Energy = new ComptonTelescopeScorerTrackerEnergy("Energy", "ComptonTelescopeTower", 0); + G4VPrimitiveScorer* TOF = new ComptonTelescopeScorerTrackerTOF("Time", "ComptonTelescopeTower", 0); + G4VPrimitiveScorer* ProcessTypeCompt = + new ComptonTelescopeScorerProcess("Process", "ComptonTelescopeTower", "compt", 0); + /* G4VPrimitiveScorer* StripPositionX = new GPDScorerFirstStageFrontStripSquare("StripNumberX", 0, + m_NumberOfStrips); G4VPrimitiveScorer* StripPositionY = new + GPDScorerFirstStageBackStripSquare("StripNumberY", 0, m_NumberOfStrips); G4VPrimitiveScorer* + InteractionCoordinatesX = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesX("InterCoordX","", 0); + G4VPrimitiveScorer* InteractionCoordinatesY = new + OBSOLETEGENERALSCORERS::PSInteractionCoordinatesY("InterCoordY","", 0); G4VPrimitiveScorer* InteractionCoordinatesZ + = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ","", 0); G4VPrimitiveScorer* + InteractionCoordinatesAngleTheta = new + OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta","", 0); G4VPrimitiveScorer* + InteractionCoordinatesAnglePhi = new + OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi","", 0); + */ + // and register it to the multifunctionnal detector + m_TrackerScorer->RegisterPrimitive(TowerNbr); + m_TrackerScorer->RegisterPrimitive(DSSSDNbr); + m_TrackerScorer->RegisterPrimitive(Energy); + m_TrackerScorer->RegisterPrimitive(TOF); + m_TrackerScorer->RegisterPrimitive(ProcessTypeCompt); + /* m_TrackerScorer->RegisterPrimitive(StripPositionX); + m_TrackerScorer->RegisterPrimitive(StripPositionY); + m_TrackerScorer->RegisterPrimitive(InteractionCoordinatesX); + m_TrackerScorer->RegisterPrimitive(InteractionCoordinatesY); + m_TrackerScorer->RegisterPrimitive(InteractionCoordinatesZ); + m_TrackerScorer->RegisterPrimitive(InteractionCoordinatesAngleTheta); + m_TrackerScorer->RegisterPrimitive(InteractionCoordinatesAnglePhi); + */ + // Third stage Associate Scorer + m_CalorimeterScorer = new G4MultiFunctionalDetector("CalorimeterScorerComptonTelescope"); + G4VPrimitiveScorer* CaloTower = + new ComptonTelescopeScorerCalorimeterTowerNumber("TowerNumber", "ComptonTelescopeTower", 0); + G4VPrimitiveScorer* CaloDetector = + new ComptonTelescopeScorerCalorimeterDetectorNumber("DetectorNumber", "ComptonTelescopeTower", 0); + G4VPrimitiveScorer* CaloEnergy = new ComptonTelescopeScorerCalorimeterEnergy("Energy", "ComptonTelescopeTower", 0); + // G4VPrimitiveScorer* CaloTime = new ComptonTelescopeScorerCalorimeterTOF("Time", "ComptonTelescopeTower", 0); + m_CalorimeterScorer->RegisterPrimitive(CaloTower); + m_CalorimeterScorer->RegisterPrimitive(CaloDetector); + m_CalorimeterScorer->RegisterPrimitive(CaloEnergy); + // m_CalorimeterScorer->RegisterPrimitive(CaloTime); + + // Add All Scorer to the Global Scorer Manager + G4SDManager::GetSDMpointer()->AddNewDetector(m_TrackerScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_CalorimeterScorer); } - //////////////////////////////////////////////////////////////////////////////// - // Construct Method to be pass to the DetectorFactory // - //////////////////////////////////////////////////////////////////////////////// - NPS::VDetector* ComptonTelescope::Construct(){ - return (NPS::VDetector*) new ComptonTelescope(); - } - - //////////////////////////////////////////////////////////////////////////////// - // Registering the construct method to the factory // - //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_comptontelescope{ - public: - proxy_nps_comptontelescope(){ - NPS::DetectorFactory::getInstance()->AddToken("ComptonTelescope","ComptonTelescope"); - NPS::DetectorFactory::getInstance()->AddDetector("ComptonTelescope",ComptonTelescope::Construct); - } +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the DetectorFactory // +//////////////////////////////////////////////////////////////////////////////// +NPS::VDetector* ComptonTelescope::Construct() { return (NPS::VDetector*)new ComptonTelescope(); } + +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern "C" { +class proxy_nps_comptontelescope { + public: + proxy_nps_comptontelescope() { + NPS::DetectorFactory::getInstance()->AddToken("ComptonTelescope", "ComptonTelescope"); + NPS::DetectorFactory::getInstance()->AddDetector("ComptonTelescope", ComptonTelescope::Construct); + } }; - proxy_nps_comptontelescope p_nps_comptontelescope; - } +proxy_nps_comptontelescope p_nps_comptontelescope; +} diff --git a/NPSimulation/Detectors/CsI/CsI.cc b/NPSimulation/Detectors/CsI/CsI.cc index 6a7775264..48d0d3c79 100644 --- a/NPSimulation/Detectors/CsI/CsI.cc +++ b/NPSimulation/Detectors/CsI/CsI.cc @@ -22,526 +22,462 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> -//G4 Geometry object -#include "G4Tubs.hh" +#include <sstream> +// G4 Geometry object #include "G4Box.hh" #include "G4Trd.hh" +#include "G4Tubs.hh" -//G4 sensitive -#include "G4SDManager.hh" +// G4 sensitive #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" -//G4 various object +// G4 various object +#include "G4Colour.hh" #include "G4Material.hh" -#include "G4Transform3D.hh" #include "G4PVPlacement.hh" +#include "G4Transform3D.hh" #include "G4VisAttributes.hh" -#include "G4Colour.hh" - // NPTool header +#include "CalorimeterScorers.hh" #include "CsI.hh" -#include "ObsoleteGeneralScorers.hh" -#include "RootOutput.h" -#include "MaterialManager.hh" #include "InteractionScorers.hh" -#include "PhotoDiodeScorers.hh" -#include "CalorimeterScorers.hh" -#include "NPSDetectorFactory.hh" +#include "MaterialManager.hh" #include "NPOptionManager.h" -//using namespace OBSOLETEGENERALSCORERS ; -// CLHEP header +#include "NPSDetectorFactory.hh" +#include "ObsoleteGeneralScorers.hh" +#include "PhotoDiodeScorers.hh" +#include "RootOutput.h" +// using namespace OBSOLETEGENERALSCORERS ; +// CLHEP header #include "CLHEP/Random/RandGauss.h" using namespace std; using namespace CLHEP; - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // CsI Specific Method -CsI::CsI(){ - m_Event = new TCsIData() ; - m_CsIScorer = 0; - ResoCsI = 2.5/2.35;// 2.5% FWHM - PhotoDiodeFace = 18.;//mm - PhotoDiodeThickness = 3.;//mm +CsI::CsI() { + m_Event = new TCsIData(); + m_CsIScorer = 0; + ResoCsI = 2.5 / 2.35; // 2.5% FWHM + PhotoDiodeFace = 18.; // mm + PhotoDiodeThickness = 3.; // mm } -CsI::~CsI(){ -} +CsI::~CsI() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void CsI::AddCsI( G4double R , - G4double Theta , - G4double Phi , - G4double CsIThickness , - G4double CsIRadius , - G4String Scintillator , - G4double LeadThickness ) -{ - - m_R.push_back(R) ; - m_Theta.push_back(Theta) ; - m_Phi.push_back(Phi) ; - m_CsIThickness.push_back(CsIThickness) ; - m_LeadThickness.push_back(LeadThickness) ; - m_Scintillator.push_back(Scintillator) ; - m_CsIRadius.push_back(CsIRadius) ; // cylindrical shape - m_CsIFaceFront.push_back(-1) ; // Trapezoidal shape - m_CsIFaceBack.push_back(-1) ; // Trapezoidal shape +void CsI::AddCsI(G4double R, G4double Theta, G4double Phi, G4double CsIThickness, G4double CsIRadius, + G4String Scintillator, G4double LeadThickness) { + + m_R.push_back(R); + m_Theta.push_back(Theta); + m_Phi.push_back(Phi); + m_CsIThickness.push_back(CsIThickness); + m_LeadThickness.push_back(LeadThickness); + m_Scintillator.push_back(Scintillator); + m_CsIRadius.push_back(CsIRadius); // cylindrical shape + m_CsIFaceFront.push_back(-1); // Trapezoidal shape + m_CsIFaceBack.push_back(-1); // Trapezoidal shape } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void CsI::AddCsI( G4double R , - G4double Theta , - G4double Phi , - G4double FaceFront , - G4double FaceBack , - G4double CsIThickness , - G4String Scintillator , - G4double LeadThickness ) -{ - m_R.push_back(R) ; - m_Theta.push_back(Theta) ; - m_Phi.push_back(Phi) ; - m_CsIThickness.push_back(CsIThickness) ; - m_LeadThickness.push_back(LeadThickness) ; - m_Scintillator.push_back(Scintillator) ; - m_CsIRadius.push_back(-1) ; // cylindrical shape - m_CsIFaceFront.push_back(FaceFront) ; // Trapezoidal shape - m_CsIFaceBack.push_back(FaceBack) ; // Trapezoidal shape - +void CsI::AddCsI(G4double R, G4double Theta, G4double Phi, G4double FaceFront, G4double FaceBack, G4double CsIThickness, + G4String Scintillator, G4double LeadThickness) { + m_R.push_back(R); + m_Theta.push_back(Theta); + m_Phi.push_back(Phi); + m_CsIThickness.push_back(CsIThickness); + m_LeadThickness.push_back(LeadThickness); + m_Scintillator.push_back(Scintillator); + m_CsIRadius.push_back(-1); // cylindrical shape + m_CsIFaceFront.push_back(FaceFront); // Trapezoidal shape + m_CsIFaceBack.push_back(FaceBack); // Trapezoidal shape } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Virtual Method of VDetector class - // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void CsI::ReadConfiguration(NPL::InputParser parser ){ - vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("CsI"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " detectors found " << endl; - - vector<string> cart = {"X","Y","Z"}; - vector<string> sphe = {"R","Theta","Phi"}; - vector<string> trapez= {"Shape","FaceFront","FaceBack","Thickness","Scintillator","LeadThickness"}; - vector<string> cylind= {"Shape","Radius","Thickness","Scintillator","LeadThickness"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(cart)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Plastic " << i+1 << endl; - double X = blocks[i]->GetDouble("X","mm"); - double Y = blocks[i]->GetDouble("Y","mm"); - double Z = blocks[i]->GetDouble("Z","mm"); - double R = sqrt (X*X+Y*Y+Z*Z); - double Theta = acos(Z / (R) ); - double Phi = atan2(Y,X); - - if(blocks[i]->HasTokenList(trapez)){ - string Shape = blocks[i]->GetString("Shape"); - double FaceFront = blocks[i]->GetDouble("FaceFront","mm"); - double FaceBack = blocks[i]->GetDouble("FaceBack","mm"); - double Thickness = blocks[i]->GetDouble("Thickness","mm"); - string Scintillator= blocks[i]->GetString("Scintillator"); - double LeadThickness = blocks[i]->GetDouble("LeadThickness","mm"); - AddCsI(R,Theta,Phi,FaceFront,FaceBack,Thickness,Scintillator,LeadThickness); - } - - else if(blocks[i]->HasTokenList(cylind)){ - string Shape = blocks[i]->GetString("Shape"); - double Radius = blocks[i]->GetDouble("Radius","mm"); - double Thickness = blocks[i]->GetDouble("Thickness","mm"); - string Scintillator= blocks[i]->GetString("Scintillator"); - double LeadThickness = blocks[i]->GetDouble("LeadThickness","mm"); - AddCsI(R,Theta,Phi,Thickness,Radius,Scintillator,LeadThickness); - } - - } - else if(blocks[i]->HasTokenList(sphe)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Plastic " << i+1 << endl; - double R = blocks[i]->GetDouble("R","mm"); - double Theta = blocks[i]->GetDouble("Theta","deg"); - double Phi = blocks[i]->GetDouble("Phi","deg"); - - if(blocks[i]->HasTokenList(trapez)){ - string Shape = blocks[i]->GetString("Shape"); - double FaceFront = blocks[i]->GetDouble("FaceFront","mm"); - double FaceBack = blocks[i]->GetDouble("FaceBack","mm"); - double Thickness = blocks[i]->GetDouble("Thickness","mm"); - string Scintillator = blocks[i]->GetString("Scintillator"); - double LeadThickness = blocks[i]->GetDouble("LeadThickness","mm"); - AddCsI(R,Theta,Phi,FaceFront,FaceBack,Thickness,Scintillator,LeadThickness); - } - - else if(blocks[i]->HasTokenList(cylind)){ - string Shape = blocks[i]->GetString("Shape"); - double Radius = blocks[i]->GetDouble("Radius","mm"); - double Thickness = blocks[i]->GetDouble("Thickness","mm"); - string Scintillator = blocks[i]->GetString("Scintillator"); - double LeadThickness = blocks[i]->GetDouble("LeadThickness","mm"); - AddCsI(R,Theta,Phi,Thickness,Radius,Scintillator,LeadThickness); - } - - } - - - else{ - cout << "ERROR: check your input file formatting " << endl; - exit(1); - } +void CsI::ReadConfiguration(NPL::InputParser parser) { + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("CsI"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + + vector<string> cart = {"X", "Y", "Z"}; + vector<string> sphe = {"R", "Theta", "Phi"}; + vector<string> trapez = {"Shape", "FaceFront", "FaceBack", "Thickness", "Scintillator", "LeadThickness"}; + vector<string> cylind = {"Shape", "Radius", "Thickness", "Scintillator", "LeadThickness"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(cart)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Plastic " << i + 1 << endl; + double X = blocks[i]->GetDouble("X", "mm"); + double Y = blocks[i]->GetDouble("Y", "mm"); + double Z = blocks[i]->GetDouble("Z", "mm"); + double R = sqrt(X * X + Y * Y + Z * Z); + double Theta = acos(Z / (R)); + double Phi = atan2(Y, X); + + if (blocks[i]->HasTokenList(trapez)) { + string Shape = blocks[i]->GetString("Shape"); + double FaceFront = blocks[i]->GetDouble("FaceFront", "mm"); + double FaceBack = blocks[i]->GetDouble("FaceBack", "mm"); + double Thickness = blocks[i]->GetDouble("Thickness", "mm"); + string Scintillator = blocks[i]->GetString("Scintillator"); + double LeadThickness = blocks[i]->GetDouble("LeadThickness", "mm"); + AddCsI(R, Theta, Phi, FaceFront, FaceBack, Thickness, Scintillator, LeadThickness); + } + + else if (blocks[i]->HasTokenList(cylind)) { + string Shape = blocks[i]->GetString("Shape"); + double Radius = blocks[i]->GetDouble("Radius", "mm"); + double Thickness = blocks[i]->GetDouble("Thickness", "mm"); + string Scintillator = blocks[i]->GetString("Scintillator"); + double LeadThickness = blocks[i]->GetDouble("LeadThickness", "mm"); + AddCsI(R, Theta, Phi, Thickness, Radius, Scintillator, LeadThickness); + } } + else if (blocks[i]->HasTokenList(sphe)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Plastic " << i + 1 << endl; + double R = blocks[i]->GetDouble("R", "mm"); + double Theta = blocks[i]->GetDouble("Theta", "deg"); + double Phi = blocks[i]->GetDouble("Phi", "deg"); + + if (blocks[i]->HasTokenList(trapez)) { + string Shape = blocks[i]->GetString("Shape"); + double FaceFront = blocks[i]->GetDouble("FaceFront", "mm"); + double FaceBack = blocks[i]->GetDouble("FaceBack", "mm"); + double Thickness = blocks[i]->GetDouble("Thickness", "mm"); + string Scintillator = blocks[i]->GetString("Scintillator"); + double LeadThickness = blocks[i]->GetDouble("LeadThickness", "mm"); + AddCsI(R, Theta, Phi, FaceFront, FaceBack, Thickness, Scintillator, LeadThickness); + } + + else if (blocks[i]->HasTokenList(cylind)) { + string Shape = blocks[i]->GetString("Shape"); + double Radius = blocks[i]->GetDouble("Radius", "mm"); + double Thickness = blocks[i]->GetDouble("Thickness", "mm"); + string Scintillator = blocks[i]->GetString("Scintillator"); + double LeadThickness = blocks[i]->GetDouble("LeadThickness", "mm"); + AddCsI(R, Theta, Phi, Thickness, Radius, Scintillator, LeadThickness); + } + } + + else { + cout << "ERROR: check your input file formatting " << endl; + exit(1); + } + } } // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void CsI::ConstructDetector(G4LogicalVolume* world){ - G4ThreeVector Det_pos = G4ThreeVector(0, 0, 0) ; - - 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] ) ; - Det_pos = G4ThreeVector(wX, wY, wZ) ; - VolumeMaker(Det_pos , i+1, world) ; - } - +void CsI::ConstructDetector(G4LogicalVolume* world) { + G4ThreeVector Det_pos = G4ThreeVector(0, 0, 0); + + 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]); + Det_pos = G4ThreeVector(wX, wY, wZ); + VolumeMaker(Det_pos, i + 1, world); + } } -void CsI::VolumeMaker(G4ThreeVector Det_pos, int DetNumber, G4LogicalVolume* world){ - //////////////////////////////////////////////////////////////// - ////////////// Starting Volume Definition ////////////////////// - //////////////////////////////////////////////////////////////// - // Name of the module - std::ostringstream DetectorNumber ; - DetectorNumber << DetNumber ; - G4String Name = "CsI" + DetectorNumber.str() ; - - int i = DetNumber-1; - - G4Material* CsIMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary(m_Scintillator[i]) ; - G4Material* Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum") ; - - //Create experimental hall - G4double expHall_x = 1.*m; - G4double expHall_y = 1.*m; - G4double expHall_z = 1.*m; - - G4Box* fExperimentalHall_box = new G4Box("expHall_box",expHall_x,expHall_y,expHall_z); - G4LogicalVolume* fExperimentalHall_log = new G4LogicalVolume(fExperimentalHall_box, - Vacuum,"expHall_log",0,0,0); - G4VPhysicalVolume* fExperimentalHall_phys = new G4PVPlacement(0,G4ThreeVector(), - fExperimentalHall_log,"expHall",0,false,0); - - fExperimentalHall_log->SetVisAttributes(G4VisAttributes::Invisible); - - - // Definition of the volume containing the sensitive detector - - // Cylindrical Case - if(m_CsIRadius[i]!=-1){ - if(m_CsIThickness[i]>0 && m_CsIRadius[i]>0){ - - // CsI crystal - G4Tubs* solidCsI = new G4Tubs( Name , - 0 , - m_CsIRadius[i] , - m_CsIThickness[i]/2 , - 0*deg , - 360*deg); - - G4LogicalVolume* logicCsI = new G4LogicalVolume(solidCsI, CsIMaterial, Name+ "_Scintillator", 0, 0, 0); - logicCsI->SetSensitiveDetector(m_CsIScorer); - - G4VisAttributes* CsIVisAtt = new G4VisAttributes(G4Colour(1.0, 0.5, 0.0,0.25)) ; - logicCsI->SetVisAttributes(CsIVisAtt) ; - - G4VPhysicalVolume* physCsI = new G4PVPlacement(0 , - Det_pos , - logicCsI , - Name + "_Scintillator" , - world , - false , - 0 ); - - G4OpticalSurface* OpticalCrysralSurface = new G4OpticalSurface("CrystalSurface"); - OpticalCrysralSurface->SetType(dielectric_metal); - //polished: smooth perfectly polished surcface - //ground: rough surface - OpticalCrysralSurface->SetFinish(polished); - //unified - //glisur - OpticalCrysralSurface->SetModel(glisur); - - G4double pp[] = {0.1*eV, 10*eV}; - const G4int num = sizeof(pp)/sizeof(G4double); - G4double reflectivity[] = {0., 0.}; - assert(sizeof(reflectivity) == sizeof(pp)); - G4double efficiency[] = {1., 1.}; - assert(sizeof(efficiency) == sizeof(pp)); - - G4MaterialPropertiesTable* OpticalCrysralSurfaceProperty = new G4MaterialPropertiesTable(); - - OpticalCrysralSurfaceProperty->AddProperty("REFLECTIVITY",pp,reflectivity,num); - OpticalCrysralSurfaceProperty->AddProperty("EFFICIENCY",pp,efficiency,num); - OpticalCrysralSurface->SetMaterialPropertiesTable(OpticalCrysralSurfaceProperty); - - new G4LogicalBorderSurface("CrystalSurface", physCsI, fExperimentalHall_phys, OpticalCrysralSurface); - //new G4LogicalSkinSurface("OpticalCrysralSurface",logicCsI,OpticalCrysralSurface); - - // Photodiode - G4String NamePD = Name+"PhotoDiode"; - - G4Material* PDMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); - - G4Box* solidPhotoDiode = new G4Box(NamePD,0.5*PhotoDiodeFace,0.5*PhotoDiodeFace,0.5*PhotoDiodeThickness); - - G4LogicalVolume* logicPD = new G4LogicalVolume(solidPhotoDiode, PDMaterial, NamePD,0,0,0); - logicPD->SetSensitiveDetector(m_PDScorer); - - G4VisAttributes* PDVisAtt = new G4VisAttributes(G4Colour(0.1, 0.2, 0.3)) ; - logicPD->SetVisAttributes(PDVisAtt); - - new G4PVPlacement(0 , - Det_pos+(m_CsIThickness[i]*0.5+PhotoDiodeThickness*0.5)*Det_pos.unit() , - logicPD , - NamePD , - world , - false , - 0 ); - } - - if(m_LeadThickness[i]>0&& m_CsIRadius[i]>0){ - G4Tubs* solidLead = new G4Tubs(Name+"_Lead", - 0, - m_CsIRadius[i], - m_LeadThickness[i]/2, - 0*deg, - 360*deg); - - G4Material* MaterialLead = MaterialManager::getInstance()->GetMaterialFromLibrary("Pb"); - G4LogicalVolume* logicLead = new G4LogicalVolume(solidLead, MaterialLead, Name+"_Lead", 0, 0, 0);//AC changed lead to Al - G4VisAttributes* LeadVisAtt = new G4VisAttributes(G4Colour(0.1, 0.1, 0.1)) ; - logicLead->SetVisAttributes(LeadVisAtt) ; - - G4PVPlacement( 0, - Det_pos+(m_CsIThickness[i]/2+m_LeadThickness[i]/2)*Det_pos.unit(), - logicLead, - Name+"_Lead", - world, - false, - 0); - } +void CsI::VolumeMaker(G4ThreeVector Det_pos, int DetNumber, G4LogicalVolume* world) { + //////////////////////////////////////////////////////////////// + ////////////// Starting Volume Definition ////////////////////// + //////////////////////////////////////////////////////////////// + // Name of the module + std::ostringstream DetectorNumber; + DetectorNumber << DetNumber; + G4String Name = "CsI" + DetectorNumber.str(); + + int i = DetNumber - 1; + + G4Material* CsIMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary(m_Scintillator[i]); + G4Material* Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); + + // Create experimental hall + G4double expHall_x = 1. * m; + G4double expHall_y = 1. * m; + G4double expHall_z = 1. * m; + + G4Box* fExperimentalHall_box = new G4Box("expHall_box", expHall_x, expHall_y, expHall_z); + G4LogicalVolume* fExperimentalHall_log = new G4LogicalVolume(fExperimentalHall_box, Vacuum, "expHall_log", 0, 0, 0); + G4VPhysicalVolume* fExperimentalHall_phys = + new G4PVPlacement(0, G4ThreeVector(), fExperimentalHall_log, "expHall", 0, false, 0); + + fExperimentalHall_log->SetVisAttributes(G4VisAttributes::GetInvisible()); + + // Definition of the volume containing the sensitive detector + + // Cylindrical Case + if (m_CsIRadius[i] != -1) { + if (m_CsIThickness[i] > 0 && m_CsIRadius[i] > 0) { + + // CsI crystal + G4Tubs* solidCsI = new G4Tubs(Name, 0, m_CsIRadius[i], m_CsIThickness[i] / 2, 0 * deg, 360 * deg); + + G4LogicalVolume* logicCsI = new G4LogicalVolume(solidCsI, CsIMaterial, Name + "_Scintillator", 0, 0, 0); + logicCsI->SetSensitiveDetector(m_CsIScorer); + + G4VisAttributes* CsIVisAtt = new G4VisAttributes(G4Colour(1.0, 0.5, 0.0, 0.25)); + logicCsI->SetVisAttributes(CsIVisAtt); + + G4VPhysicalVolume* physCsI = new G4PVPlacement(0, Det_pos, logicCsI, Name + "_Scintillator", world, false, 0); + + G4OpticalSurface* OpticalCrysralSurface = new G4OpticalSurface("CrystalSurface"); + OpticalCrysralSurface->SetType(dielectric_metal); + // polished: smooth perfectly polished surcface + // ground: rough surface + OpticalCrysralSurface->SetFinish(polished); + // unified + // glisur + OpticalCrysralSurface->SetModel(glisur); + + G4double pp[] = {0.1 * eV, 10 * eV}; + const G4int num = sizeof(pp) / sizeof(G4double); + G4double reflectivity[] = {0., 0.}; + assert(sizeof(reflectivity) == sizeof(pp)); + G4double efficiency[] = {1., 1.}; + assert(sizeof(efficiency) == sizeof(pp)); + + G4MaterialPropertiesTable* OpticalCrysralSurfaceProperty = new G4MaterialPropertiesTable(); + + OpticalCrysralSurfaceProperty->AddProperty("REFLECTIVITY", pp, reflectivity, num); + OpticalCrysralSurfaceProperty->AddProperty("EFFICIENCY", pp, efficiency, num); + OpticalCrysralSurface->SetMaterialPropertiesTable(OpticalCrysralSurfaceProperty); + + new G4LogicalBorderSurface("CrystalSurface", physCsI, fExperimentalHall_phys, OpticalCrysralSurface); + // new G4LogicalSkinSurface("OpticalCrysralSurface",logicCsI,OpticalCrysralSurface); + + // Photodiode + G4String NamePD = Name + "PhotoDiode"; + + G4Material* PDMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); + + G4Box* solidPhotoDiode = new G4Box(NamePD, 0.5 * PhotoDiodeFace, 0.5 * PhotoDiodeFace, 0.5 * PhotoDiodeThickness); + + G4LogicalVolume* logicPD = new G4LogicalVolume(solidPhotoDiode, PDMaterial, NamePD, 0, 0, 0); + logicPD->SetSensitiveDetector(m_PDScorer); + + G4VisAttributes* PDVisAtt = new G4VisAttributes(G4Colour(0.1, 0.2, 0.3)); + logicPD->SetVisAttributes(PDVisAtt); + + new G4PVPlacement(0, Det_pos + (m_CsIThickness[i] * 0.5 + PhotoDiodeThickness * 0.5) * Det_pos.unit(), logicPD, + NamePD, world, false, 0); + } + + if (m_LeadThickness[i] > 0 && m_CsIRadius[i] > 0) { + G4Tubs* solidLead = new G4Tubs(Name + "_Lead", 0, m_CsIRadius[i], m_LeadThickness[i] / 2, 0 * deg, 360 * deg); + + G4Material* MaterialLead = MaterialManager::getInstance()->GetMaterialFromLibrary("Pb"); + G4LogicalVolume* logicLead = + new G4LogicalVolume(solidLead, MaterialLead, Name + "_Lead", 0, 0, 0); // AC changed lead to Al + G4VisAttributes* LeadVisAtt = new G4VisAttributes(G4Colour(0.1, 0.1, 0.1)); + logicLead->SetVisAttributes(LeadVisAtt); + + G4PVPlacement(0, Det_pos + (m_CsIThickness[i] / 2 + m_LeadThickness[i] / 2) * Det_pos.unit(), logicLead, + Name + "_Lead", world, false, 0); + } + } + + // Trapezoidal case + if (m_CsIFaceFront[i] != -1) { + if (m_CsIThickness[i] > 0 && m_CsIFaceFront[i] > 0 && m_CsIFaceBack[i] > 0) { + + G4Trd* solidCsI = new G4Trd("solidCsICrystal", 0.5 * m_CsIFaceFront[i], 0.5 * m_CsIFaceBack[i], + 0.5 * m_CsIFaceFront[i], 0.5 * m_CsIFaceBack[i], 0.5 * m_CsIThickness[i]); + + // G4Box* solidCsI = new G4Box(Name, 0.5*m_CsIFaceBack[i], 0.5*m_CsIFaceFront[i], 0.5*m_CsIThickness[i]); + G4LogicalVolume* logicCsI = new G4LogicalVolume(solidCsI, CsIMaterial, Name + "_Scintillator", 0, 0, 0); + logicCsI->SetSensitiveDetector(m_CsIScorer); + + G4VisAttributes* PlastVisAtt = new G4VisAttributes(G4Colour(1.0, 0.5, 0.0)); + logicCsI->SetVisAttributes(PlastVisAtt); + + G4RotationMatrix Rot3D; + Rot3D.set(0, 0, 0); + + G4VPhysicalVolume* physCsI = + new G4PVPlacement(G4Transform3D(Rot3D, Det_pos), logicCsI, Name + "_Scintillator", world, false, 0); + + G4OpticalSurface* OpticalCrysralSurface = new G4OpticalSurface("CrystalSurface"); + OpticalCrysralSurface->SetType(dielectric_metal); + // polished: smooth perfectly polished surcface + // ground: rough surface + OpticalCrysralSurface->SetFinish(polished); + // unified + // glisur + OpticalCrysralSurface->SetModel(glisur); + + G4double pp[] = {0.1 * eV, 10 * eV}; + const G4int num = sizeof(pp) / sizeof(G4double); + G4double reflectivity[] = {0., 0.}; + assert(sizeof(reflectivity) == sizeof(pp)); + G4double efficiency[] = {1., 1.}; + assert(sizeof(efficiency) == sizeof(pp)); + + G4MaterialPropertiesTable* OpticalCrysralSurfaceProperty = new G4MaterialPropertiesTable(); + + OpticalCrysralSurfaceProperty->AddProperty("REFLECTIVITY", pp, reflectivity, num); + OpticalCrysralSurfaceProperty->AddProperty("EFFICIENCY", pp, efficiency, num); + OpticalCrysralSurface->SetMaterialPropertiesTable(OpticalCrysralSurfaceProperty); + + new G4LogicalBorderSurface("CrystalSurface", physCsI, fExperimentalHall_phys, OpticalCrysralSurface); + // new G4LogicalSkinSurface("OpticalCrysralSurface",logicCsI,OpticalCrysralSurface); + + // Photodiode + /*G4String NamePD = Name+"PhotoDiode"; + + G4Material* PDMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); + + G4Box* solidPhotoDiode = new G4Box(NamePD,0.5*PhotoDiodeFace,0.5*PhotoDiodeFace,0.5*PhotoDiodeThickness); + + G4LogicalVolume* logicPD = new G4LogicalVolume(solidPhotoDiode, PDMaterial, NamePD,0,0,0); + logicPD->SetSensitiveDetector(m_PDScorer); + + G4VisAttributes* PDVisAtt = new G4VisAttributes(G4Colour(0.1, 0.2, 0.3)) ; + logicPD->SetVisAttributes(PDVisAtt); + + new G4PVPlacement(0 , + Det_pos+(m_CsIThickness[i]*0.5+PhotoDiodeThickness*0.5)*Det_pos.unit() , + logicPD , + NamePD , + world , + false , + 0 );*/ } - - // Trapezoidal case - if(m_CsIFaceFront[i]!=-1){ - if(m_CsIThickness[i]>0 && m_CsIFaceFront[i]>0 && m_CsIFaceBack[i]>0){ - - G4Trd* solidCsI = new G4Trd("solidCsICrystal",0.5*m_CsIFaceFront[i],0.5*m_CsIFaceBack[i],0.5*m_CsIFaceFront[i],0.5*m_CsIFaceBack[i],0.5*m_CsIThickness[i]); - - //G4Box* solidCsI = new G4Box(Name, 0.5*m_CsIFaceBack[i], 0.5*m_CsIFaceFront[i], 0.5*m_CsIThickness[i]); - G4LogicalVolume* logicCsI = new G4LogicalVolume(solidCsI, CsIMaterial, Name+ "_Scintillator", 0, 0, 0); - logicCsI->SetSensitiveDetector(m_CsIScorer); - - G4VisAttributes* PlastVisAtt = new G4VisAttributes(G4Colour(1.0, 0.5, 0.0)) ; - logicCsI->SetVisAttributes(PlastVisAtt) ; - - G4RotationMatrix Rot3D; - Rot3D.set(0, 0, 0); - - G4VPhysicalVolume* physCsI = new G4PVPlacement( G4Transform3D(Rot3D,Det_pos), - logicCsI, - Name + "_Scintillator" , - world, - false, - 0); - - G4OpticalSurface* OpticalCrysralSurface = new G4OpticalSurface("CrystalSurface"); - OpticalCrysralSurface->SetType(dielectric_metal); - //polished: smooth perfectly polished surcface - //ground: rough surface - OpticalCrysralSurface->SetFinish(polished); - //unified - //glisur - OpticalCrysralSurface->SetModel(glisur); - - G4double pp[] = {0.1*eV, 10*eV}; - const G4int num = sizeof(pp)/sizeof(G4double); - G4double reflectivity[] = {0., 0.}; - assert(sizeof(reflectivity) == sizeof(pp)); - G4double efficiency[] = {1., 1.}; - assert(sizeof(efficiency) == sizeof(pp)); - - G4MaterialPropertiesTable* OpticalCrysralSurfaceProperty = new G4MaterialPropertiesTable(); - - OpticalCrysralSurfaceProperty->AddProperty("REFLECTIVITY",pp,reflectivity,num); - OpticalCrysralSurfaceProperty->AddProperty("EFFICIENCY",pp,efficiency,num); - OpticalCrysralSurface->SetMaterialPropertiesTable(OpticalCrysralSurfaceProperty); - - new G4LogicalBorderSurface("CrystalSurface", physCsI, fExperimentalHall_phys, OpticalCrysralSurface); - //new G4LogicalSkinSurface("OpticalCrysralSurface",logicCsI,OpticalCrysralSurface); - - // Photodiode - /*G4String NamePD = Name+"PhotoDiode"; - - G4Material* PDMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); - - G4Box* solidPhotoDiode = new G4Box(NamePD,0.5*PhotoDiodeFace,0.5*PhotoDiodeFace,0.5*PhotoDiodeThickness); - - G4LogicalVolume* logicPD = new G4LogicalVolume(solidPhotoDiode, PDMaterial, NamePD,0,0,0); - logicPD->SetSensitiveDetector(m_PDScorer); - - G4VisAttributes* PDVisAtt = new G4VisAttributes(G4Colour(0.1, 0.2, 0.3)) ; - logicPD->SetVisAttributes(PDVisAtt); - - new G4PVPlacement(0 , - Det_pos+(m_CsIThickness[i]*0.5+PhotoDiodeThickness*0.5)*Det_pos.unit() , - logicPD , - NamePD , - world , - false , - 0 );*/ - - } - - if(m_LeadThickness[i]>0&& m_CsIFaceFront[i]>0 && m_CsIFaceBack[i]>0){ - G4Box* solidLead = new G4Box(Name+"_Lead", 0.5*m_CsIFaceBack[i], 0.5*m_CsIFaceFront[i], 0.5*m_LeadThickness[i]); - - G4Material* MaterialLead = MaterialManager::getInstance()->GetMaterialFromLibrary("Pb"); - G4LogicalVolume* logicLead = new G4LogicalVolume(solidLead, MaterialLead, Name+"_Lead", 0, 0, 0); - G4VisAttributes* LeadVisAtt = new G4VisAttributes(G4Colour(0.1, 0.1, 0.1)) ; - logicLead->SetVisAttributes(LeadVisAtt) ; - - new G4PVPlacement(0, - Det_pos+(m_CsIThickness[i]/2+m_LeadThickness[i]/2)*Det_pos.unit() +G4ThreeVector(0,0,-10*cm) , - logicLead, - Name+"_Lead", - world, - false, - 0); - } + + if (m_LeadThickness[i] > 0 && m_CsIFaceFront[i] > 0 && m_CsIFaceBack[i] > 0) { + G4Box* solidLead = + new G4Box(Name + "_Lead", 0.5 * m_CsIFaceBack[i], 0.5 * m_CsIFaceFront[i], 0.5 * m_LeadThickness[i]); + + G4Material* MaterialLead = MaterialManager::getInstance()->GetMaterialFromLibrary("Pb"); + G4LogicalVolume* logicLead = new G4LogicalVolume(solidLead, MaterialLead, Name + "_Lead", 0, 0, 0); + G4VisAttributes* LeadVisAtt = new G4VisAttributes(G4Colour(0.1, 0.1, 0.1)); + logicLead->SetVisAttributes(LeadVisAtt); + + new G4PVPlacement(0, + Det_pos + (m_CsIThickness[i] / 2 + m_LeadThickness[i] / 2) * Det_pos.unit() + + G4ThreeVector(0, 0, -10 * cm), + logicLead, Name + "_Lead", world, false, 0); } + } } // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void CsI::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("CsI")){ - pTree->Branch("CsI", "TCsIData", &m_Event) ; - } - pTree->SetBranchAddress("CsI", &m_Event) ; +void CsI::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("CsI")) { + pTree->Branch("CsI", "TCsIData", &m_Event); + } + pTree->SetBranchAddress("CsI", &m_Event); } // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void CsI::ReadSensitive(const G4Event* event){ - //G4String DetectorNumber; - m_Event->Clear(); - - // CsI // - CalorimeterScorers::PS_Calorimeter* Scorer= (CalorimeterScorers::PS_Calorimeter*) m_CsIScorer->GetPrimitive(0); - - unsigned int size = Scorer->GetMult(); - for(unsigned int i = 0 ; i < size ; i++){ - vector<unsigned int> level = Scorer->GetLevel(i); - double E_CsI = RandGauss::shoot(Scorer->GetEnergy(i),Scorer->GetEnergy(i)*ResoCsI/100); - m_Event->SetCsIEEnergy(E_CsI); - m_Event->SetENumber(level[i]); - } - - // PhotoDiode // - NPS::HitsMap<G4double*>* PhotoDiodeHitMap; - std::map<G4int, G4double**>::iterator PhotoDiode_itr; - - G4int PhotoDiodeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("PDScorer/PhotoDiode"); - PhotoDiodeHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(PhotoDiodeCollectionID)); - - // Loop on the PhotoDiode map - vector<double> NumberOfOpticalPhoton; - NumberOfOpticalPhoton.clear(); - for (PhotoDiode_itr = PhotoDiodeHitMap->GetMap()->begin() ; PhotoDiode_itr != PhotoDiodeHitMap->GetMap()->end() ; PhotoDiode_itr++){ - G4double* Info = *(PhotoDiode_itr->second); - - m_Event->SetPhotoDiodeEnergy(Info[0]); - m_Event->SetPhotoDiodeEDetectorNbr(Info[7]); - - m_Event->SetPhotoDiodeTime(Info[1]); - m_Event->SetPhotoDiodeTDetectorNbr(Info[7]); - NumberOfOpticalPhoton.push_back(Info[8]); - //cout << "CsI class Info[8] = " << Info[8] << endl;; - //m_Event->SetNumberOfOpticalPhoton(Info[8]); - } - //cout << "CsI class total optical photon = " << NumberOfOpticalPhoton.size() << endl; - m_Event->SetNumberOfOpticalPhoton(NumberOfOpticalPhoton.size()); - PhotoDiodeHitMap->clear(); - -} +void CsI::ReadSensitive(const G4Event* event) { + // G4String DetectorNumber; + m_Event->Clear(); + + // CsI // + CalorimeterScorers::PS_Calorimeter* Scorer = (CalorimeterScorers::PS_Calorimeter*)m_CsIScorer->GetPrimitive(0); + unsigned int size = Scorer->GetMult(); + for (unsigned int i = 0; i < size; i++) { + vector<unsigned int> level = Scorer->GetLevel(i); + double E_CsI = RandGauss::shoot(Scorer->GetEnergy(i), Scorer->GetEnergy(i) * ResoCsI / 100); + m_Event->SetCsIEEnergy(E_CsI); + m_Event->SetENumber(level[i]); + } + + // PhotoDiode // + NPS::HitsMap<G4double*>* PhotoDiodeHitMap; + std::map<G4int, G4double**>::iterator PhotoDiode_itr; + + G4int PhotoDiodeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("PDScorer/PhotoDiode"); + PhotoDiodeHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(PhotoDiodeCollectionID)); + + // Loop on the PhotoDiode map + vector<double> NumberOfOpticalPhoton; + NumberOfOpticalPhoton.clear(); + for (PhotoDiode_itr = PhotoDiodeHitMap->GetMap()->begin(); PhotoDiode_itr != PhotoDiodeHitMap->GetMap()->end(); + PhotoDiode_itr++) { + G4double* Info = *(PhotoDiode_itr->second); + + m_Event->SetPhotoDiodeEnergy(Info[0]); + m_Event->SetPhotoDiodeEDetectorNbr(Info[7]); + + m_Event->SetPhotoDiodeTime(Info[1]); + m_Event->SetPhotoDiodeTDetectorNbr(Info[7]); + NumberOfOpticalPhoton.push_back(Info[8]); + // cout << "CsI class Info[8] = " << Info[8] << endl;; + // m_Event->SetNumberOfOpticalPhoton(Info[8]); + } + // cout << "CsI class total optical photon = " << NumberOfOpticalPhoton.size() << endl; + m_Event->SetNumberOfOpticalPhoton(NumberOfOpticalPhoton.size()); + PhotoDiodeHitMap->clear(); +} //////////////////////////////////////////////////////////////// void CsI::InitializeScorers() { - bool already_exist = false; - vector<G4int> NestingLevel; - NestingLevel.push_back(0); - NestingLevel.push_back(1); - m_CsIScorer = CheckScorer("CsIScorer",already_exist) ; - m_PDScorer = CheckScorer("PDScorer",already_exist) ; - - if(already_exist) return ; - - G4VPrimitiveScorer* CsIScorer= new CalorimeterScorers::PS_Calorimeter("CsI",NestingLevel); - m_CsIScorer->RegisterPrimitive(CsIScorer); - - - G4VPrimitiveScorer* Interaction= new InteractionScorers::PS_Interactions("InteractionCsI",ms_InterCoord,1); - m_CsIScorer->RegisterPrimitive(Interaction); - - - G4VPrimitiveScorer* PDScorer = new PHOTODIODESCORERS::PS_PhotoDiode_Rectangle("PhotoDiode",0, - PhotoDiodeFace, - PhotoDiodeFace, - 1, - 1); - m_PDScorer->RegisterPrimitive(PDScorer); - - G4SDManager::GetSDMpointer()->AddNewDetector(m_PDScorer) ; - G4SDManager::GetSDMpointer()->AddNewDetector(m_CsIScorer) ; - + bool already_exist = false; + vector<G4int> NestingLevel; + NestingLevel.push_back(0); + NestingLevel.push_back(1); + m_CsIScorer = CheckScorer("CsIScorer", already_exist); + m_PDScorer = CheckScorer("PDScorer", already_exist); + + if (already_exist) + return; + + G4VPrimitiveScorer* CsIScorer = new CalorimeterScorers::PS_Calorimeter("CsI", NestingLevel); + m_CsIScorer->RegisterPrimitive(CsIScorer); + + G4VPrimitiveScorer* Interaction = new InteractionScorers::PS_Interactions("InteractionCsI", ms_InterCoord, 1); + m_CsIScorer->RegisterPrimitive(Interaction); + + G4VPrimitiveScorer* PDScorer = + new PHOTODIODESCORERS::PS_PhotoDiode_Rectangle("PhotoDiode", 0, PhotoDiodeFace, PhotoDiodeFace, 1, 1); + m_PDScorer->RegisterPrimitive(PDScorer); + + G4SDManager::GetSDMpointer()->AddNewDetector(m_PDScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_CsIScorer); } //////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* CsI::Construct(){ - return (NPS::VDetector*) new CsI(); -} +NPS::VDetector* CsI::Construct() { return (NPS::VDetector*)new CsI(); } //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_csi{ - public: - proxy_nps_csi(){ - NPS::DetectorFactory::getInstance()->AddToken("CsI","CsI"); - NPS::DetectorFactory::getInstance()->AddDetector("CsI",CsI::Construct); - } - }; - - proxy_nps_csi p_nps_csi; +extern "C" { +class proxy_nps_csi { + public: + proxy_nps_csi() { + NPS::DetectorFactory::getInstance()->AddToken("CsI", "CsI"); + NPS::DetectorFactory::getInstance()->AddDetector("CsI", CsI::Construct); + } +}; + +proxy_nps_csi p_nps_csi; } diff --git a/NPSimulation/Detectors/Eurogam/Eurogam.cc b/NPSimulation/Detectors/Eurogam/Eurogam.cc index f11a1fe09..dd6950e1a 100755 --- a/NPSimulation/Detectors/Eurogam/Eurogam.cc +++ b/NPSimulation/Detectors/Eurogam/Eurogam.cc @@ -20,36 +20,36 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> +#include <sstream> -//G4 Geometry object +// G4 Geometry object #include "G4Box.hh" -#include "G4Tubs.hh" #include "G4Cons.hh" -#include "G4UnionSolid.hh" -#include "G4SubtractionSolid.hh" #include "G4IntersectionSolid.hh" +#include "G4SubtractionSolid.hh" +#include "G4Tubs.hh" +#include "G4UnionSolid.hh" -//G4 sensitive -#include "G4SDManager.hh" +// G4 sensitive #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" -//G4 various object +// G4 various object +#include "G4Colour.hh" #include "G4Material.hh" -#include "G4Transform3D.hh" #include "G4PVPlacement.hh" +#include "G4Transform3D.hh" #include "G4VisAttributes.hh" -#include "G4Colour.hh" // NPTool header #include "Eurogam.hh" -#include "ObsoleteGeneralScorers.hh" #include "MaterialManager.hh" +#include "NPOptionManager.h" #include "NPSDetectorFactory.hh" +#include "ObsoleteGeneralScorers.hh" #include "RootOutput.h" -#include "NPOptionManager.h" using namespace OBSOLETEGENERALSCORERS; // CLHEP header @@ -59,66 +59,55 @@ using namespace std; using namespace CLHEP; using namespace EUROGAMDETECTOR; - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Eurogam Specific Method -Eurogam::Eurogam() -{ - InitializeMaterial(); - m_Event = new TEurogamData(); +Eurogam::Eurogam() { + InitializeMaterial(); + m_Event = new TEurogamData(); } +Eurogam::~Eurogam() { + // Materials + delete m_Material_Vacuum; + delete m_Material_Aluminium; + delete m_Material_Silicon; + delete m_Material_Germanium; - -Eurogam::~Eurogam() -{ - // Materials - delete m_Material_Vacuum; - delete m_Material_Aluminium; - delete m_Material_Silicon; - delete m_Material_Germanium; - - delete m_Event; - delete m_EurogamScorer; + delete m_Event; + delete m_EurogamScorer; } - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Eurogam::AddEurogamModule(G4double R, G4double Theta, G4double Phi, - G4double beta_u, G4double beta_v, G4double beta_w) -{ - m_R.push_back(R); - m_Theta.push_back(Theta); - m_Phi.push_back(Phi); - m_beta_u.push_back(beta_u); - m_beta_v.push_back(beta_v); - m_beta_w.push_back(beta_w); +void Eurogam::AddEurogamModule(G4double R, G4double Theta, G4double Phi, G4double beta_u, G4double beta_v, + G4double beta_w) { + m_R.push_back(R); + m_Theta.push_back(Theta); + m_Phi.push_back(Phi); + m_beta_u.push_back(beta_u); + m_beta_v.push_back(beta_v); + m_beta_w.push_back(beta_w); } - - // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Eurogam::ReadConfiguration(NPL::InputParser parser){ +void Eurogam::ReadConfiguration(NPL::InputParser parser) { vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Eurogam"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " detectors found " << endl; + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; - vector<string> token = {"R","Theta","Phi"}; + vector<string> token = {"R", "Theta", "Phi"}; - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(token)){ - double R = blocks[i]->GetDouble("R","mm"); - double Theta = blocks[i]->GetDouble("Theta","deg"); - double Phi = blocks[i]->GetDouble("Phi","deg"); - vector<double> beta = blocks[i]->GetVectorDouble("BETA","deg"); + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(token)) { + double R = blocks[i]->GetDouble("R", "mm"); + double Theta = blocks[i]->GetDouble("Theta", "deg"); + double Phi = blocks[i]->GetDouble("Phi", "deg"); + vector<double> beta = blocks[i]->GetVectorDouble("BETA", "deg"); AddEurogamModule(R, Theta, Phi, beta[0], beta[1], beta[2]); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } @@ -127,484 +116,470 @@ void Eurogam::ReadConfiguration(NPL::InputParser parser){ // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void Eurogam::ConstructDetector(G4LogicalVolume* world) -{ - G4ThreeVector Det_pos = G4ThreeVector(0, 0, 0); - G4RotationMatrix* Det_rot = new G4RotationMatrix(); - - for (unsigned short i = 0; i < m_R.size(); i++) { - G4double Theta = m_Theta[i]; - G4double Phi = m_Phi[i]; - - // (u,v,w) unitary vector associated to the detector referencial - // (u,v) // to detector front - // w perpendicular to (u,v) plan and pointing to the detector back - // Phi is angle between X axis and projection in (X,Y) plan - // Theta is angle between position vector and z axis - G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad); - G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad); - G4double wZ = m_R[i] * cos(Theta / rad); - G4ThreeVector dirw = G4ThreeVector(wX, wY, wZ); - - // vector corresponding to the center of the module - Det_pos = dirw; - dirw = dirw.unit(); - - // vector parallel to one axis of silicon plane - G4double ii = cos(Theta / rad) * cos(Phi / rad); - G4double jj = cos(Theta / rad) * sin(Phi / rad); - G4double kk = -sin(Theta / rad); - G4ThreeVector Y = G4ThreeVector(ii, jj, kk); - - // build rotation matrix to go from the lab referential - // to the telescope referential - G4ThreeVector diru = dirw.cross(Y); - G4ThreeVector dirv = dirw.cross(diru); - dirv = dirv.unit(); - diru = diru.unit(); - Det_rot = new G4RotationMatrix(diru, dirv, dirw); - - // Detector is rotated by Beta angles around the v axis. - Det_rot->rotate(m_beta_u[i], diru); - Det_rot->rotate(m_beta_v[i], dirv); - Det_rot->rotate(m_beta_w[i], dirw); - - // translation to place the detector - Det_pos += dirw * EurogamDepth * 0.5; - - // Build geometry - VolumeMaker(i + 1, Det_pos, Det_rot, world); - } +void Eurogam::ConstructDetector(G4LogicalVolume* world) { + G4ThreeVector Det_pos = G4ThreeVector(0, 0, 0); + G4RotationMatrix* Det_rot = new G4RotationMatrix(); + + for (unsigned short i = 0; i < m_R.size(); i++) { + G4double Theta = m_Theta[i]; + G4double Phi = m_Phi[i]; + + // (u,v,w) unitary vector associated to the detector referencial + // (u,v) // to detector front + // w perpendicular to (u,v) plan and pointing to the detector back + // Phi is angle between X axis and projection in (X,Y) plan + // Theta is angle between position vector and z axis + G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad); + G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad); + G4double wZ = m_R[i] * cos(Theta / rad); + G4ThreeVector dirw = G4ThreeVector(wX, wY, wZ); + + // vector corresponding to the center of the module + Det_pos = dirw; + dirw = dirw.unit(); + + // vector parallel to one axis of silicon plane + G4double ii = cos(Theta / rad) * cos(Phi / rad); + G4double jj = cos(Theta / rad) * sin(Phi / rad); + G4double kk = -sin(Theta / rad); + G4ThreeVector Y = G4ThreeVector(ii, jj, kk); + + // build rotation matrix to go from the lab referential + // to the telescope referential + G4ThreeVector diru = dirw.cross(Y); + G4ThreeVector dirv = dirw.cross(diru); + dirv = dirv.unit(); + diru = diru.unit(); + Det_rot = new G4RotationMatrix(diru, dirv, dirw); + + // Detector is rotated by Beta angles around the v axis. + Det_rot->rotate(m_beta_u[i], diru); + Det_rot->rotate(m_beta_v[i], dirv); + Det_rot->rotate(m_beta_w[i], dirw); + + // translation to place the detector + Det_pos += dirw * EurogamDepth * 0.5; + + // Build geometry + VolumeMaker(i + 1, Det_pos, Det_rot, world); + } } - - -void Eurogam::VolumeMaker(G4int DetNumber, - G4ThreeVector DetPos, - G4RotationMatrix* DetRot, - G4LogicalVolume* world) -{ - - //////////////////////////////////////////////////////////////// - ////////////// Starting Volume Definition ////////////////////// - //////////////////////////////////////////////////////////////// - // Name of the module - std::ostringstream DetectorNumber; - DetectorNumber << DetNumber; - G4String Name = "Eurogam" + DetectorNumber.str(); - - // EUROGAM box - G4Box* solidEurogam = new G4Box(Name, EurogamSize/2, EurogamSize/2, EurogamDepth/2); - - G4LogicalVolume* logicEurogam = new G4LogicalVolume(solidEurogam, m_Material_Vacuum, Name, 0, 0, 0); - - new G4PVPlacement(G4Transform3D(*DetRot, DetPos), logicEurogam, Name, world, false, 0); - - logicEurogam->SetVisAttributes(G4VisAttributes::Invisible); - - // Germanium detector itself - // Capot en Aluminium - // Epaisseur du capot - G4double AluThickness = 1*mm; - // Fermeture du capot par 2 disques pleins - G4double RMinFront = 0, RMaxFront = 66.2/2*mm, DzFront = AluThickness; - G4double RMinBack = 0, RMaxBack = 86.2/2*mm, DzBack = AluThickness; - // Composante conique du capot - G4double RMin1Cone = RMaxFront - DzFront, RMax1Cone = RMaxFront; - G4double RMin2Cone = RMaxBack - DzBack, RMax2Cone = RMaxBack; - G4double DzCone = 101.5*mm; - // Composante cylindrique du capot - G4double RMinCylin = RMaxBack - DzBack, RMaxCylin = RMaxBack; - G4double DzCylin = 163.1*mm; - - // Capot avant - G4VSolid* solidCapotFront = new G4Tubs("solidCapotFront", RMinFront, RMaxFront, DzFront/2, 0*degree, 360*degree); - - G4LogicalVolume* logicCapotFront = new G4LogicalVolume(solidCapotFront, // its solid - m_Material_Aluminium, // its material - "logicCapotFront"); // its name - - G4double OffsetZCapotFront = -(EurogamDepth - DzFront)/2; - G4ThreeVector ZposCapotFront = G4ThreeVector(0, 0, OffsetZCapotFront); - new G4PVPlacement(0, // no rotation - ZposCapotFront, // at (0,0,Dz) - logicCapotFront, // its logical name - Name + "_CapotFront", // its name - logicEurogam, // its mother name - false, // no boolean operation - 0); // copy number - - // Partie conique - G4VSolid* solidCapotCone = new G4Cons("solidCapotCone", RMin1Cone, RMax1Cone, RMin2Cone, RMax2Cone, DzCone/2, 0*degree, 360*degree); - - G4LogicalVolume* logicCapotCone = new G4LogicalVolume(solidCapotCone, //its solid - m_Material_Aluminium, //its material - "logicCapotCone"); //its name - - G4double OffsetZCapotCone = -(EurogamDepth/2 - DzFront - DzCone/2); - G4ThreeVector ZposCapotCone = G4ThreeVector(0, 0, OffsetZCapotCone); - new G4PVPlacement(0, // no rotation - ZposCapotCone, // at (0,0,Dz) - logicCapotCone, // its logical name - Name + "_CapotCone", // its name - logicEurogam, // its mother name - false, // no boolean operation - 0); // copy number - - // Partie cylindrique - G4VSolid* solidCapotCylin = new G4Tubs("solidCapotCylin", RMinCylin, RMaxCylin, DzCylin/2, 0*degree, 360*degree); - - G4LogicalVolume* logicCapotCylin = new G4LogicalVolume(solidCapotCylin, //its solid - m_Material_Aluminium, //its material - "logicCapotCylin"); //its name - - G4double OffsetZCapotCylin = -(EurogamDepth/2 - DzFront - DzCone - DzCylin/2); - G4ThreeVector ZposCapotCylin = G4ThreeVector(0, 0, OffsetZCapotCylin); - new G4PVPlacement(0, // no rotation - ZposCapotCylin, // at (0,0,Dz) - logicCapotCylin, // its logical name - Name + "_CapotCylin", // its name - logicEurogam, // its mother name - false, // no boolean operation - 0); // copy number +void Eurogam::VolumeMaker(G4int DetNumber, G4ThreeVector DetPos, G4RotationMatrix* DetRot, G4LogicalVolume* world) { + + //////////////////////////////////////////////////////////////// + ////////////// Starting Volume Definition ////////////////////// + //////////////////////////////////////////////////////////////// + // Name of the module + std::ostringstream DetectorNumber; + DetectorNumber << DetNumber; + G4String Name = "Eurogam" + DetectorNumber.str(); + + // EUROGAM box + G4Box* solidEurogam = new G4Box(Name, EurogamSize / 2, EurogamSize / 2, EurogamDepth / 2); + + G4LogicalVolume* logicEurogam = new G4LogicalVolume(solidEurogam, m_Material_Vacuum, Name, 0, 0, 0); + + new G4PVPlacement(G4Transform3D(*DetRot, DetPos), logicEurogam, Name, world, false, 0); + + logicEurogam->SetVisAttributes(G4VisAttributes::GetInvisible()); + + // Germanium detector itself + // Capot en Aluminium + // Epaisseur du capot + G4double AluThickness = 1 * mm; + // Fermeture du capot par 2 disques pleins + G4double RMinFront = 0, RMaxFront = 66.2 / 2 * mm, DzFront = AluThickness; + G4double RMinBack = 0, RMaxBack = 86.2 / 2 * mm, DzBack = AluThickness; + // Composante conique du capot + G4double RMin1Cone = RMaxFront - DzFront, RMax1Cone = RMaxFront; + G4double RMin2Cone = RMaxBack - DzBack, RMax2Cone = RMaxBack; + G4double DzCone = 101.5 * mm; + // Composante cylindrique du capot + G4double RMinCylin = RMaxBack - DzBack, RMaxCylin = RMaxBack; + G4double DzCylin = 163.1 * mm; + + // Capot avant + G4VSolid* solidCapotFront = + new G4Tubs("solidCapotFront", RMinFront, RMaxFront, DzFront / 2, 0 * degree, 360 * degree); + + G4LogicalVolume* logicCapotFront = new G4LogicalVolume(solidCapotFront, // its solid + m_Material_Aluminium, // its material + "logicCapotFront"); // its name + + G4double OffsetZCapotFront = -(EurogamDepth - DzFront) / 2; + G4ThreeVector ZposCapotFront = G4ThreeVector(0, 0, OffsetZCapotFront); + new G4PVPlacement(0, // no rotation + ZposCapotFront, // at (0,0,Dz) + logicCapotFront, // its logical name + Name + "_CapotFront", // its name + logicEurogam, // its mother name + false, // no boolean operation + 0); // copy number + + // Partie conique + G4VSolid* solidCapotCone = + new G4Cons("solidCapotCone", RMin1Cone, RMax1Cone, RMin2Cone, RMax2Cone, DzCone / 2, 0 * degree, 360 * degree); + + G4LogicalVolume* logicCapotCone = new G4LogicalVolume(solidCapotCone, // its solid + m_Material_Aluminium, // its material + "logicCapotCone"); // its name + + G4double OffsetZCapotCone = -(EurogamDepth / 2 - DzFront - DzCone / 2); + G4ThreeVector ZposCapotCone = G4ThreeVector(0, 0, OffsetZCapotCone); + new G4PVPlacement(0, // no rotation + ZposCapotCone, // at (0,0,Dz) + logicCapotCone, // its logical name + Name + "_CapotCone", // its name + logicEurogam, // its mother name + false, // no boolean operation + 0); // copy number + + // Partie cylindrique + G4VSolid* solidCapotCylin = + new G4Tubs("solidCapotCylin", RMinCylin, RMaxCylin, DzCylin / 2, 0 * degree, 360 * degree); + + G4LogicalVolume* logicCapotCylin = new G4LogicalVolume(solidCapotCylin, // its solid + m_Material_Aluminium, // its material + "logicCapotCylin"); // its name + + G4double OffsetZCapotCylin = -(EurogamDepth / 2 - DzFront - DzCone - DzCylin / 2); + G4ThreeVector ZposCapotCylin = G4ThreeVector(0, 0, OffsetZCapotCylin); + new G4PVPlacement(0, // no rotation + ZposCapotCylin, // at (0,0,Dz) + logicCapotCylin, // its logical name + Name + "_CapotCylin", // its name + logicEurogam, // its mother name + false, // no boolean operation + 0); // copy number // Capot arriere - G4VSolid* solidCapotBack = new G4Tubs("solidCapotBack", RMinBack, RMaxBack, DzBack/2, 0*degree, 360*degree); - - G4LogicalVolume* logicCapotBack = new G4LogicalVolume(solidCapotBack, //its solid - m_Material_Aluminium, //its material - "logicCapotBack"); //its name - - G4double OffsetZCapotBack = -(EurogamDepth/2 - DzFront - DzCone - DzCylin - DzBack/2); - G4ThreeVector ZposCapotBack = G4ThreeVector(0, 0, OffsetZCapotBack); - new G4PVPlacement(0, // no rotation - ZposCapotBack, // at (0,0,Dz) - logicCapotBack, // its logical name - Name + "_CapotBack", // its name - logicEurogam, // its mother name - false, // no boolean operation - 0); // copy number - - // cristal de Ge et doigt froid - G4double RMinGe = 0, RMaxGe = 63.1/2*mm, DzGe = 78.5*mm; - G4double SPhiGe = 0, DPhiGe = 360*degree; - G4double distCapotGe = 20*mm; - G4double RMinDoigt = 0, RMaxDoigt = 11.2/2*mm, DzDoigt = 70*mm; - G4double SPhiDoigt = 0*degree, DPhiDoigt = 360*degree; - - G4VSolid* solidDetec = new G4Tubs("solidGermanium", //its name - RMinGe, RMaxGe, DzGe/2, //its size - SPhiGe, DPhiGe); //its size - - G4VSolid* solidDoigt = new G4Tubs("solidDoigt", - RMinDoigt, RMaxDoigt, DzDoigt/2, - SPhiDoigt, DPhiDoigt); - - // !!! pour soustraire le doigt froid du cristal initial de Germainum - // cela se fait dans le repere du cristal de Germanium - // *************** changer signe - en signe + ??????????? - G4double OffsetZDoigt = - (DzGe/2 - DzDoigt/2); - G4ThreeVector ZposDoigt = G4ThreeVector(0, 0, OffsetZDoigt); - G4VSolid* solidSubtrac = new G4SubtractionSolid("solidCristalGe", solidDetec, solidDoigt, 0, ZposDoigt); - - G4LogicalVolume* logicDetec= new G4LogicalVolume(solidSubtrac, //its solid -// m_Material_Germanium, //its material - m_Material_Silicon, //its material - "logicCristalGe"); //its name - -// G4LogicalVolume* logicDetec= new G4LogicalVolume(solidDetec, //its solid -// m_Material_Germanium, //its material -// "logicCristalGe"); //its name - - - G4double OffsetZGe = -(EurogamDepth/2 - distCapotGe - DzGe/2); - G4ThreeVector ZposGe = G4ThreeVector(0, 0, OffsetZGe); - new G4PVPlacement(0, //no rotation - ZposGe, //at (0,0,0) - logicDetec, //its logical volume - Name + "_CristalGe", //its name - logicEurogam, //its mother volume - false, //no boolean operation - 0); //copy number - - // Set Ge detector sensible - logicDetec->SetSensitiveDetector(m_EurogamScorer); - - // Visualisation of FirstStage Strip - G4VisAttributes* DetectorVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)); // blue - logicDetec->SetVisAttributes(DetectorVisAtt); + G4VSolid* solidCapotBack = new G4Tubs("solidCapotBack", RMinBack, RMaxBack, DzBack / 2, 0 * degree, 360 * degree); + + G4LogicalVolume* logicCapotBack = new G4LogicalVolume(solidCapotBack, // its solid + m_Material_Aluminium, // its material + "logicCapotBack"); // its name + + G4double OffsetZCapotBack = -(EurogamDepth / 2 - DzFront - DzCone - DzCylin - DzBack / 2); + G4ThreeVector ZposCapotBack = G4ThreeVector(0, 0, OffsetZCapotBack); + new G4PVPlacement(0, // no rotation + ZposCapotBack, // at (0,0,Dz) + logicCapotBack, // its logical name + Name + "_CapotBack", // its name + logicEurogam, // its mother name + false, // no boolean operation + 0); // copy number + + // cristal de Ge et doigt froid + G4double RMinGe = 0, RMaxGe = 63.1 / 2 * mm, DzGe = 78.5 * mm; + G4double SPhiGe = 0, DPhiGe = 360 * degree; + G4double distCapotGe = 20 * mm; + G4double RMinDoigt = 0, RMaxDoigt = 11.2 / 2 * mm, DzDoigt = 70 * mm; + G4double SPhiDoigt = 0 * degree, DPhiDoigt = 360 * degree; + + G4VSolid* solidDetec = new G4Tubs("solidGermanium", // its name + RMinGe, RMaxGe, DzGe / 2, // its size + SPhiGe, DPhiGe); // its size + + G4VSolid* solidDoigt = new G4Tubs("solidDoigt", RMinDoigt, RMaxDoigt, DzDoigt / 2, SPhiDoigt, DPhiDoigt); + + // !!! pour soustraire le doigt froid du cristal initial de Germainum + // cela se fait dans le repere du cristal de Germanium + // *************** changer signe - en signe + ??????????? + G4double OffsetZDoigt = -(DzGe / 2 - DzDoigt / 2); + G4ThreeVector ZposDoigt = G4ThreeVector(0, 0, OffsetZDoigt); + G4VSolid* solidSubtrac = new G4SubtractionSolid("solidCristalGe", solidDetec, solidDoigt, 0, ZposDoigt); + + G4LogicalVolume* logicDetec = + new G4LogicalVolume(solidSubtrac, // its solid + // m_Material_Germanium, //its material + m_Material_Silicon, // its material + "logicCristalGe"); // its name + + // G4LogicalVolume* logicDetec= new G4LogicalVolume(solidDetec, //its solid + // m_Material_Germanium, //its material + // "logicCristalGe"); //its name + + G4double OffsetZGe = -(EurogamDepth / 2 - distCapotGe - DzGe / 2); + G4ThreeVector ZposGe = G4ThreeVector(0, 0, OffsetZGe); + new G4PVPlacement(0, // no rotation + ZposGe, // at (0,0,0) + logicDetec, // its logical volume + Name + "_CristalGe", // its name + logicEurogam, // its mother volume + false, // no boolean operation + 0); // copy number + + // Set Ge detector sensible + logicDetec->SetSensitiveDetector(m_EurogamScorer); + + // Visualisation of FirstStage Strip + G4VisAttributes* DetectorVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)); // blue + logicDetec->SetVisAttributes(DetectorVisAtt); } - - // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void Eurogam::InitializeRootOutput() -{ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("Eurogam")){ - pTree->Branch("Eurogam", "TEurogamData", &m_Event) ; - } - pTree->SetBranchAddress("Eurogam", &m_Event) ; - +void Eurogam::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("Eurogam")) { + pTree->Branch("Eurogam", "TEurogamData", &m_Event); + } + pTree->SetBranchAddress("Eurogam", &m_Event); } - - // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Eurogam::ReadSensitive(const G4Event* event) -{ - // Clear the data of the TEurogamData object - m_Event->Clear(); - - ////////////////////////////////////////////////////////////////////////////////////// - //////////////////////// Used to Read Event Map of detector ////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - std::map<G4int, G4int*>::iterator DetectorNumber_itr; - std::map<G4int, G4double*>::iterator Energy_itr; - std::map<G4int, G4double*>::iterator Time_itr; - std::map<G4int, G4double*>::iterator Pos_X_itr; - std::map<G4int, G4double*>::iterator Pos_Y_itr; - std::map<G4int, G4double*>::iterator Pos_Z_itr; - std::map<G4int, G4double*>::iterator Ang_Theta_itr; - std::map<G4int, G4double*>::iterator Ang_Phi_itr; - - NPS::HitsMap<G4int>* DetectorNumberHitMap; - NPS::HitsMap<G4double>* EnergyHitMap; - NPS::HitsMap<G4double>* TimeHitMap; - NPS::HitsMap<G4double>* PosXHitMap; - NPS::HitsMap<G4double>* PosYHitMap; - NPS::HitsMap<G4double>* PosZHitMap; - NPS::HitsMap<G4double>* AngThetaHitMap; - NPS::HitsMap<G4double>* AngPhiHitMap; - - // Read the Scorer associate to the Silicon Strip - //Detector Number - G4int DetCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("EurogamScorer/DetectorNumber"); - DetectorNumberHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(DetCollectionID)); - DetectorNumber_itr = DetectorNumberHitMap->GetMap()->begin(); - - // Energy - G4int EnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("EurogamScorer/Energy"); - EnergyHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(EnergyCollectionID)); - Energy_itr = EnergyHitMap->GetMap()->begin(); - - //Time of Flight - G4int TimeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("EurogamScorer/Time"); - TimeHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(TimeCollectionID)); - Time_itr = TimeHitMap->GetMap()->begin(); - - //Interaction Coordinate X - G4int InterCoordXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("EurogamScorer/InterCoordX"); - PosXHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordXCollectionID)); - Pos_X_itr = PosXHitMap->GetMap()->begin(); - - //Interaction Coordinate Y - G4int InterCoordYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("EurogamScorer/InterCoordY"); - PosYHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordYCollectionID)); - Pos_Y_itr = PosYHitMap->GetMap()->begin(); - - //Interaction Coordinate Z - G4int InterCoordZCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("EurogamScorer/InterCoordZ"); - PosZHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordZCollectionID)); - Pos_Z_itr = PosXHitMap->GetMap()->begin(); - - //Interaction Coordinate Angle Theta - G4int InterCoordAngThetaCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("EurogamScorer/InterCoordAngTheta"); - AngThetaHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngThetaCollectionID)); - Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); - - //Interaction Coordinate Angle Phi - G4int InterCoordAngPhiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("EurogamScorer/InterCoordAngPhi"); - AngPhiHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngPhiCollectionID)); - Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); - - // Check the size of different map - G4int sizeN = DetectorNumberHitMap->entries(); - G4int sizeE = EnergyHitMap->entries(); - G4int sizeT = TimeHitMap->entries(); - G4int sizeX = PosXHitMap->entries(); - -/* if (sizeN != sizeE || sizeE != sizeT) { - G4cout << "No match size Eurogam Event Map: sE:" << sizeE << " sT:" << sizeT << G4endl; - return; - }*/ - G4cout << "*******SIZE********: " << sizeN << " " << sizeE << " " << sizeT << " " << sizeX << G4endl; - - G4double Etot = 0; - - // Loop on detector number - for (G4int l = 0; l < sizeN; l++) { - G4double N = *(DetectorNumber_itr->second); - G4int NTrackID = DetectorNumber_itr->first - N; - G4cout << "NTrackID: " << NTrackID << " " << N << G4endl; - - if (N > 0) { - // Fill detector number - m_Event->SetEurogamDetectorNumber(N); - - // Energy - Energy_itr = EnergyHitMap->GetMap()->begin(); - for (G4int ll = 0; ll < sizeE; ll++) { - G4int ETrackID = Energy_itr->first - N; - G4double E = *(Energy_itr->second); - G4cout << "ETrackID, E: " << ETrackID << " " << E << G4endl; - if (ETrackID == NTrackID) { - Etot += E; -// m_Event->SetEurogamEnergy(RandGauss::shoot(E, 1)); - // Fill energy loss for each step -// m_Event->SetEurogamEnergy(E*1e3); - } - Energy_itr++; - } - - // Time - Time_itr = TimeHitMap->GetMap()->begin(); - for (G4int h = 0; h < sizeT; h++) { - G4int TTrackID = Time_itr->first - N; - G4double T = *(Time_itr->second); - if (TTrackID == NTrackID) { - m_Event->SetEurogamTime(RandGauss::shoot(T, 1)); - } - Time_itr++; - } - - // Pos X - Pos_X_itr = PosXHitMap->GetMap()->begin(); - for (G4int h = 0; h < PosXHitMap->entries(); h++) { - G4int PosXTrackID = Pos_X_itr->first - N; - G4double PosX = *(Pos_X_itr->second); - if (PosXTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionX(PosX); - } - Pos_X_itr++; - } - - // Pos Y - Pos_Y_itr = PosYHitMap->GetMap()->begin(); - for (G4int h = 0; h < PosYHitMap->entries(); h++) { - G4int PosYTrackID = Pos_Y_itr->first - N; - G4double PosY = *(Pos_Y_itr->second); - if (PosYTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionY(PosY); - } - Pos_Y_itr++; - } - - // Pos Z - Pos_Z_itr = PosZHitMap->GetMap()->begin(); - for (G4int h = 0; h < PosZHitMap->entries(); h++) { - G4int PosZTrackID = Pos_Z_itr->first - N; - G4double PosZ = *(Pos_Z_itr->second); - if (PosZTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionZ(PosZ); - } - Pos_Z_itr++; - } - - // Angle Theta - Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); - for (G4int h = 0; h < AngThetaHitMap->entries(); h++) { - G4int AngThetaTrackID = Ang_Theta_itr->first - N; - G4double AngTheta = *(Ang_Theta_itr->second); - if (AngThetaTrackID == NTrackID) { - ms_InterCoord->SetDetectedAngleTheta(AngTheta); - } - Ang_Theta_itr++; - } - - // Angle Phi - Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); - for (G4int h = 0; h < AngPhiHitMap->entries(); h++) { - G4int AngPhiTrackID = Ang_Phi_itr->first - N; - G4double AngPhi = *(Ang_Phi_itr->second); - if (AngPhiTrackID == NTrackID) { - ms_InterCoord->SetDetectedAnglePhi(AngPhi); - } - Ang_Phi_itr++; - } +void Eurogam::ReadSensitive(const G4Event* event) { + // Clear the data of the TEurogamData object + m_Event->Clear(); + + ////////////////////////////////////////////////////////////////////////////////////// + //////////////////////// Used to Read Event Map of detector ////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + std::map<G4int, G4int*>::iterator DetectorNumber_itr; + std::map<G4int, G4double*>::iterator Energy_itr; + std::map<G4int, G4double*>::iterator Time_itr; + std::map<G4int, G4double*>::iterator Pos_X_itr; + std::map<G4int, G4double*>::iterator Pos_Y_itr; + std::map<G4int, G4double*>::iterator Pos_Z_itr; + std::map<G4int, G4double*>::iterator Ang_Theta_itr; + std::map<G4int, G4double*>::iterator Ang_Phi_itr; + + NPS::HitsMap<G4int>* DetectorNumberHitMap; + NPS::HitsMap<G4double>* EnergyHitMap; + NPS::HitsMap<G4double>* TimeHitMap; + NPS::HitsMap<G4double>* PosXHitMap; + NPS::HitsMap<G4double>* PosYHitMap; + NPS::HitsMap<G4double>* PosZHitMap; + NPS::HitsMap<G4double>* AngThetaHitMap; + NPS::HitsMap<G4double>* AngPhiHitMap; + + // Read the Scorer associate to the Silicon Strip + // Detector Number + G4int DetCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("EurogamScorer/DetectorNumber"); + DetectorNumberHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(DetCollectionID)); + DetectorNumber_itr = DetectorNumberHitMap->GetMap()->begin(); + + // Energy + G4int EnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("EurogamScorer/Energy"); + EnergyHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(EnergyCollectionID)); + Energy_itr = EnergyHitMap->GetMap()->begin(); + + // Time of Flight + G4int TimeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("EurogamScorer/Time"); + TimeHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(TimeCollectionID)); + Time_itr = TimeHitMap->GetMap()->begin(); + + // Interaction Coordinate X + G4int InterCoordXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("EurogamScorer/InterCoordX"); + PosXHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordXCollectionID)); + Pos_X_itr = PosXHitMap->GetMap()->begin(); + + // Interaction Coordinate Y + G4int InterCoordYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("EurogamScorer/InterCoordY"); + PosYHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordYCollectionID)); + Pos_Y_itr = PosYHitMap->GetMap()->begin(); + + // Interaction Coordinate Z + G4int InterCoordZCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("EurogamScorer/InterCoordZ"); + PosZHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordZCollectionID)); + Pos_Z_itr = PosXHitMap->GetMap()->begin(); + + // Interaction Coordinate Angle Theta + G4int InterCoordAngThetaCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("EurogamScorer/InterCoordAngTheta"); + AngThetaHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngThetaCollectionID)); + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); + + // Interaction Coordinate Angle Phi + G4int InterCoordAngPhiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("EurogamScorer/InterCoordAngPhi"); + AngPhiHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngPhiCollectionID)); + Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); + + // Check the size of different map + G4int sizeN = DetectorNumberHitMap->entries(); + G4int sizeE = EnergyHitMap->entries(); + G4int sizeT = TimeHitMap->entries(); + G4int sizeX = PosXHitMap->entries(); + + /* if (sizeN != sizeE || sizeE != sizeT) { + G4cout << "No match size Eurogam Event Map: sE:" << sizeE << " sT:" << sizeT << G4endl; + return; + }*/ + G4cout << "*******SIZE********: " << sizeN << " " << sizeE << " " << sizeT << " " << sizeX << G4endl; + + G4double Etot = 0; + + // Loop on detector number + for (G4int l = 0; l < sizeN; l++) { + G4double N = *(DetectorNumber_itr->second); + G4int NTrackID = DetectorNumber_itr->first - N; + G4cout << "NTrackID: " << NTrackID << " " << N << G4endl; + + if (N > 0) { + // Fill detector number + m_Event->SetEurogamDetectorNumber(N); + + // Energy + Energy_itr = EnergyHitMap->GetMap()->begin(); + for (G4int ll = 0; ll < sizeE; ll++) { + G4int ETrackID = Energy_itr->first - N; + G4double E = *(Energy_itr->second); + G4cout << "ETrackID, E: " << ETrackID << " " << E << G4endl; + if (ETrackID == NTrackID) { + Etot += E; + // m_Event->SetEurogamEnergy(RandGauss::shoot(E, 1)); + // Fill energy loss for each step + // m_Event->SetEurogamEnergy(E*1e3); + } + Energy_itr++; + } + // Time + Time_itr = TimeHitMap->GetMap()->begin(); + for (G4int h = 0; h < sizeT; h++) { + G4int TTrackID = Time_itr->first - N; + G4double T = *(Time_itr->second); + if (TTrackID == NTrackID) { + m_Event->SetEurogamTime(RandGauss::shoot(T, 1)); + } + Time_itr++; } - DetectorNumber_itr++; - } - - // Fill total energy here - if (Etot > 0) m_Event->SetEurogamEnergy(RandGauss::shoot(Etot*1e3, 1)); - - // clear map for next event - DetectorNumberHitMap -> clear(); - EnergyHitMap -> clear(); - TimeHitMap -> clear(); - PosXHitMap -> clear(); - PosYHitMap -> clear(); - PosZHitMap -> clear(); - AngThetaHitMap -> clear(); - AngPhiHitMap -> clear(); -} + // Pos X + Pos_X_itr = PosXHitMap->GetMap()->begin(); + for (G4int h = 0; h < PosXHitMap->entries(); h++) { + G4int PosXTrackID = Pos_X_itr->first - N; + G4double PosX = *(Pos_X_itr->second); + if (PosXTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionX(PosX); + } + Pos_X_itr++; + } + // Pos Y + Pos_Y_itr = PosYHitMap->GetMap()->begin(); + for (G4int h = 0; h < PosYHitMap->entries(); h++) { + G4int PosYTrackID = Pos_Y_itr->first - N; + G4double PosY = *(Pos_Y_itr->second); + if (PosYTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionY(PosY); + } + Pos_Y_itr++; + } -//////////////////////////////////////////////////////////////// -void Eurogam::InitializeMaterial() -{ - m_Material_Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); - m_Material_Aluminium = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); - m_Material_Silicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); - m_Material_Germanium = MaterialManager::getInstance()->GetMaterialFromLibrary("Ge"); -} + // Pos Z + Pos_Z_itr = PosZHitMap->GetMap()->begin(); + for (G4int h = 0; h < PosZHitMap->entries(); h++) { + G4int PosZTrackID = Pos_Z_itr->first - N; + G4double PosZ = *(Pos_Z_itr->second); + if (PosZTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionZ(PosZ); + } + Pos_Z_itr++; + } + // Angle Theta + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); + for (G4int h = 0; h < AngThetaHitMap->entries(); h++) { + G4int AngThetaTrackID = Ang_Theta_itr->first - N; + G4double AngTheta = *(Ang_Theta_itr->second); + if (AngThetaTrackID == NTrackID) { + ms_InterCoord->SetDetectedAngleTheta(AngTheta); + } + Ang_Theta_itr++; + } + // Angle Phi + Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); + for (G4int h = 0; h < AngPhiHitMap->entries(); h++) { + G4int AngPhiTrackID = Ang_Phi_itr->first - N; + G4double AngPhi = *(Ang_Phi_itr->second); + if (AngPhiTrackID == NTrackID) { + ms_InterCoord->SetDetectedAnglePhi(AngPhi); + } + Ang_Phi_itr++; + } + } + DetectorNumber_itr++; + } -//////////////////////////////////////////////////////////////// -void Eurogam::InitializeScorers() -{ - bool already_exist = false; - // Eurogam associated scorer - m_EurogamScorer = CheckScorer("EurogamScorer",already_exist); - if(already_exist) return; - - G4VPrimitiveScorer* DetNbr = new OBSOLETEGENERALSCORERS::PSDetectorNumber("DetectorNumber", "Eurogam", 0); - G4VPrimitiveScorer* Energy = new OBSOLETEGENERALSCORERS::PSEnergy("Energy","Eurogam", 0); - G4VPrimitiveScorer* TOF = new OBSOLETEGENERALSCORERS::PSTOF("Time", "Eurogam", 0); - G4VPrimitiveScorer* InteractionCoordinatesX = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesX("InterCoordX", "Eurogam", 0); - G4VPrimitiveScorer* InteractionCoordinatesY = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesY("InterCoordY", "Eurogam", 0); - G4VPrimitiveScorer* InteractionCoordinatesZ = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ", "Eurogam", 0); - G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta", "Eurogam", 0); - G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi", "Eurogam", 0); - - //and register it to the multifunctionnal detector - m_EurogamScorer->RegisterPrimitive(DetNbr); - m_EurogamScorer->RegisterPrimitive(Energy); - m_EurogamScorer->RegisterPrimitive(TOF); - m_EurogamScorer->RegisterPrimitive(InteractionCoordinatesX); - m_EurogamScorer->RegisterPrimitive(InteractionCoordinatesY); - m_EurogamScorer->RegisterPrimitive(InteractionCoordinatesZ); - m_EurogamScorer->RegisterPrimitive(InteractionCoordinatesAngleTheta); - m_EurogamScorer->RegisterPrimitive(InteractionCoordinatesAnglePhi); - - // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_EurogamScorer); + // Fill total energy here + if (Etot > 0) + m_Event->SetEurogamEnergy(RandGauss::shoot(Etot * 1e3, 1)); + + // clear map for next event + DetectorNumberHitMap->clear(); + EnergyHitMap->clear(); + TimeHitMap->clear(); + PosXHitMap->clear(); + PosYHitMap->clear(); + PosZHitMap->clear(); + AngThetaHitMap->clear(); + AngPhiHitMap->clear(); } - //////////////////////////////////////////////////////////////////////////////// - // Construct Method to be pass to the DetectorFactory // - //////////////////////////////////////////////////////////////////////////////// - NPS::VDetector* Eurogam::Construct(){ - return (NPS::VDetector*) new Eurogam(); - } - - //////////////////////////////////////////////////////////////////////////////// - // Registering the construct method to the factory // - //////////////////////////////////////////////////////////////////////////////// - extern"C" { - class proxy_nps_eurogam{ - public: - proxy_nps_eurogam(){ - NPS::DetectorFactory::getInstance()->AddToken("Eurogam","Eurogam"); - NPS::DetectorFactory::getInstance()->AddDetector("Eurogam",Eurogam::Construct); - } + +//////////////////////////////////////////////////////////////// +void Eurogam::InitializeMaterial() { + m_Material_Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); + m_Material_Aluminium = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); + m_Material_Silicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); + m_Material_Germanium = MaterialManager::getInstance()->GetMaterialFromLibrary("Ge"); +} + +//////////////////////////////////////////////////////////////// +void Eurogam::InitializeScorers() { + bool already_exist = false; + // Eurogam associated scorer + m_EurogamScorer = CheckScorer("EurogamScorer", already_exist); + if (already_exist) + return; + + G4VPrimitiveScorer* DetNbr = new OBSOLETEGENERALSCORERS::PSDetectorNumber("DetectorNumber", "Eurogam", 0); + G4VPrimitiveScorer* Energy = new OBSOLETEGENERALSCORERS::PSEnergy("Energy", "Eurogam", 0); + G4VPrimitiveScorer* TOF = new OBSOLETEGENERALSCORERS::PSTOF("Time", "Eurogam", 0); + G4VPrimitiveScorer* InteractionCoordinatesX = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesX("InterCoordX", "Eurogam", 0); + G4VPrimitiveScorer* InteractionCoordinatesY = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesY("InterCoordY", "Eurogam", 0); + G4VPrimitiveScorer* InteractionCoordinatesZ = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ", "Eurogam", 0); + G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta", "Eurogam", 0); + G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi", "Eurogam", 0); + + // and register it to the multifunctionnal detector + m_EurogamScorer->RegisterPrimitive(DetNbr); + m_EurogamScorer->RegisterPrimitive(Energy); + m_EurogamScorer->RegisterPrimitive(TOF); + m_EurogamScorer->RegisterPrimitive(InteractionCoordinatesX); + m_EurogamScorer->RegisterPrimitive(InteractionCoordinatesY); + m_EurogamScorer->RegisterPrimitive(InteractionCoordinatesZ); + m_EurogamScorer->RegisterPrimitive(InteractionCoordinatesAngleTheta); + m_EurogamScorer->RegisterPrimitive(InteractionCoordinatesAnglePhi); + + // Add All Scorer to the Global Scorer Manager + G4SDManager::GetSDMpointer()->AddNewDetector(m_EurogamScorer); +} +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the DetectorFactory // +//////////////////////////////////////////////////////////////////////////////// +NPS::VDetector* Eurogam::Construct() { return (NPS::VDetector*)new Eurogam(); } + +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern "C" { +class proxy_nps_eurogam { + public: + proxy_nps_eurogam() { + NPS::DetectorFactory::getInstance()->AddToken("Eurogam", "Eurogam"); + NPS::DetectorFactory::getInstance()->AddDetector("Eurogam", Eurogam::Construct); + } }; - proxy_nps_eurogam p_nps_eurogam; - } +proxy_nps_eurogam p_nps_eurogam; +} diff --git a/NPSimulation/Detectors/Exogam/Exogam.cc b/NPSimulation/Detectors/Exogam/Exogam.cc index 698523717..666fdab2d 100644 --- a/NPSimulation/Detectors/Exogam/Exogam.cc +++ b/NPSimulation/Detectors/Exogam/Exogam.cc @@ -20,96 +20,93 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> -//G4 Geometry object -#include "G4Tubs.hh" +#include <sstream> +// G4 Geometry object #include "G4Box.hh" #include "G4Cons.hh" -#include "G4Trap.hh" -#include "G4Trd.hh" -#include "G4Para.hh" -#include "G4Polyhedra.hh" -#include "G4Polycone.hh" #include "G4LogicalVolume.hh" -#include "G4ThreeVector.hh" #include "G4PVPlacement.hh" +#include "G4Para.hh" +#include "G4Polycone.hh" +#include "G4Polyhedra.hh" #include "G4RotationMatrix.hh" +#include "G4ThreeVector.hh" #include "G4Transform3D.hh" +#include "G4Trap.hh" +#include "G4Trd.hh" +#include "G4Tubs.hh" #include "G4PVReplica.hh" #include "G4SubtractionSolid.hh" #include "G4UnionSolid.hh" -//G4 sensitive -#include "G4SDManager.hh" +// G4 sensitive #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" -//G4 various object +// G4 various object +#include "G4Colour.hh" #include "G4Material.hh" -#include "G4Transform3D.hh" #include "G4PVPlacement.hh" +#include "G4Transform3D.hh" #include "G4VisAttributes.hh" -#include "G4Colour.hh" // NPTool header -#include "Exogam.hh" #include "CalorimeterScorers.hh" -#include "RootOutput.h" +#include "Exogam.hh" #include "MaterialManager.hh" -#include "NPSDetectorFactory.hh" #include "NPOptionManager.h" +#include "NPSDetectorFactory.hh" #include "NPSHitsMap.hh" +#include "RootOutput.h" // CLHEP header #include "CLHEP/Random/RandGauss.h" using namespace std; using namespace CLHEP; - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -namespace Exogam_NS{ +namespace Exogam_NS { // Energy and time Resolution - const double EnergyThreshold = 10*keV; - //const double ResoTime = 4.5*ns ; //not used - const double ResoEnergy = 2.*keV ; -} + const double EnergyThreshold = 10 * keV; + // const double ResoTime = 4.5*ns ; //not used + const double ResoEnergy = 2. * keV; +} // namespace Exogam_NS //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Exogam Specific Method -Exogam::Exogam(){ - m_Event = new TExogamData() ; +Exogam::Exogam() { + m_Event = new TExogamData(); m_ExogamScorer = 0; - + InitializeMaterials(); - HalfLengthCan = 7.35*cm; - TaperLengthCan = 4.325*cm; - distCollimatorToBGOSShield = 2.95*cm; + HalfLengthCan = 7.35 * cm; + TaperLengthCan = 4.325 * cm; + distCollimatorToBGOSShield = 2.95 * cm; - rm90.rotateZ(90.*deg); - rm90m.rotateZ(-90.*deg); - rm180.rotateZ(180.*deg); - rm270.rotateZ(270.*deg); + rm90.rotateZ(90. * deg); + rm90m.rotateZ(-90. * deg); + rm180.rotateZ(180. * deg); + rm270.rotateZ(270. * deg); } -Exogam::~Exogam(){ -} +Exogam::~Exogam() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4int Exogam::InitializeMaterials() -{ +G4int Exogam::InitializeMaterials() { m_Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); m_Aluminum = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); m_Copper = MaterialManager::getInstance()->GetMaterialFromLibrary("Cu"); m_Germanium = MaterialManager::getInstance()->GetMaterialFromLibrary("Ge"); - m_BGO = new G4Material("BGO", 7.13*g/cm3, 3, kStateSolid); //BGO does not exist in nptool !! - m_BGO->AddElement(MaterialManager::getInstance()->GetElementFromLibrary("Bi"),4); - m_BGO->AddElement(MaterialManager::getInstance()->GetElementFromLibrary("Ge"),3); - m_BGO->AddElement(MaterialManager::getInstance()->GetElementFromLibrary("O"),12); + m_BGO = new G4Material("BGO", 7.13 * g / cm3, 3, kStateSolid); // BGO does not exist in nptool !! + m_BGO->AddElement(MaterialManager::getInstance()->GetElementFromLibrary("Bi"), 4); + m_BGO->AddElement(MaterialManager::getInstance()->GetElementFromLibrary("Ge"), 3); + m_BGO->AddElement(MaterialManager::getInstance()->GetElementFromLibrary("O"), 12); m_CsI = MaterialManager::getInstance()->GetMaterialFromLibrary("CsI"); @@ -117,34 +114,32 @@ G4int Exogam::InitializeMaterials() } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Exogam::BuildClover(int i_clo, G4LogicalVolume* world) -{ - // enveloppe of the whole Clover (i.e. suppressed Clover) called 'SupClover' including: +void Exogam::BuildClover(int i_clo, G4LogicalVolume* world) { + // enveloppe of the whole Clover (i.e. suppressed Clover) called 'SupClover' including: // the cryostat, dewar, side shield, back catcher, collimator - G4double dzEnv = 40.472*cm; - G4double dx1Env = 3.17*cm; - G4double dy1Env = 3.17*cm; - G4double dx2Env = 2.*dzEnv*tan(22.5*deg)+dx1Env; - G4double dy2Env = 2.*dzEnv*tan(22.5*deg)+dy1Env; + G4double dzEnv = 40.472 * cm; + G4double dx1Env = 3.17 * cm; + G4double dy1Env = 3.17 * cm; + G4double dx2Env = 2. * dzEnv * tan(22.5 * deg) + dx1Env; + G4double dy2Env = 2. * dzEnv * tan(22.5 * deg) + dy1Env; - G4Trd* solidSupClover = new G4Trd("SupClover",dx1Env,dx2Env,dy1Env,dy2Env,dzEnv); - G4LogicalVolume * logicSupClover = new G4LogicalVolume(solidSupClover,m_Vacuum,"SupClover"); + G4Trd* solidSupClover = new G4Trd("SupClover", dx1Env, dx2Env, dy1Env, dy2Env, dzEnv); + G4LogicalVolume* logicSupClover = new G4LogicalVolume(solidSupClover, m_Vacuum, "SupClover"); - Offset=dzEnv;//-distCollimatorToGeCan; + Offset = dzEnv; //-distCollimatorToGeCan; G4RotationMatrix rm; - rm.rotateX(m_ThetaX[i_clo]/rad).rotateY(m_ThetaY[i_clo]/rad).rotateZ(m_ThetaZ[i_clo]/rad); + rm.rotateX(m_ThetaX[i_clo] / rad).rotateY(m_ThetaY[i_clo] / rad).rotateZ(m_ThetaZ[i_clo] / rad); - new G4PVPlacement(G4Transform3D(rm, - G4ThreeVector(m_X[i_clo]*mm, m_Y[i_clo]*mm, m_Z[i_clo]*mm+Offset)), - logicSupClover,"Clover",world,false,i_clo+1,false); //this void overlaps the whole setup + new G4PVPlacement(G4Transform3D(rm, G4ThreeVector(m_X[i_clo] * mm, m_Y[i_clo] * mm, m_Z[i_clo] * mm + Offset)), + logicSupClover, "Clover", world, false, i_clo + 1, false); // this void overlaps the whole setup // The Cryostat //////////////// // The Aluminum Clover can ( "CloverCan" )... // - G4double PhiStartCan = 45.*deg; - G4double PhiTotCan = 360.*deg; + G4double PhiStartCan = 45. * deg; + G4double PhiTotCan = 360. * deg; G4double zPlaneCan[3]; G4double rInnerCan[3]; @@ -154,395 +149,381 @@ void Exogam::BuildClover(int i_clo, G4LogicalVolume* world) G4double rOuterVac[3]; zPlaneCan[0] = -HalfLengthCan; - zPlaneCan[1] = -HalfLengthCan+TaperLengthCan; - zPlaneCan[2] = HalfLengthCan; + zPlaneCan[1] = -HalfLengthCan + TaperLengthCan; + zPlaneCan[2] = HalfLengthCan; - G4double rOuterCan[3]; // used to build the shield - rOuterCan[0] = 4.4085*cm; - rOuterCan[1] = 6.2*cm; - rOuterCan[2] = 6.2*cm; + G4double rOuterCan[3]; // used to build the shield + rOuterCan[0] = 4.4085 * cm; + rOuterCan[1] = 6.2 * cm; + rOuterCan[2] = 6.2 * cm; - rInnerCan[0] = rInnerCan[1] = rInnerCan[2] = 0.*cm; + rInnerCan[0] = rInnerCan[1] = rInnerCan[2] = 0. * cm; - G4Polyhedra* solidCloverCan = new G4Polyhedra("CloverCan",PhiStartCan,PhiTotCan,4,3, - zPlaneCan,rInnerCan,rOuterCan); + G4Polyhedra* solidCloverCan = + new G4Polyhedra("CloverCan", PhiStartCan, PhiTotCan, 4, 3, zPlaneCan, rInnerCan, rOuterCan); - G4LogicalVolume* logicCloverCan = new G4LogicalVolume(solidCloverCan,m_Aluminum,"CloverCan"); + G4LogicalVolume* logicCloverCan = new G4LogicalVolume(solidCloverCan, m_Aluminum, "CloverCan"); // The position of the Clover can in the SupClover: -G4ThreeVector posClover(0.*cm,0.*cm,-Offset+HalfLengthCan+0.001*mm); //+0.001mm to avoid roundoff errors - -new G4PVPlacement(0,posClover, logicCloverCan,"CloverCan",logicSupClover,false,i_clo+1,true); //There is an overlap with vacuum SupClover + G4ThreeVector posClover(0. * cm, 0. * cm, -Offset + HalfLengthCan + 0.001 * mm); //+0.001mm to avoid roundoff errors -// The vacuum clover ( "Vac" ) ... -// -G4double HalfLengthVac = 7.175*cm; -G4double TaperLengthVac = 4.0842*cm; + new G4PVPlacement(0, posClover, logicCloverCan, "CloverCan", logicSupClover, false, i_clo + 1, + true); // There is an overlap with vacuum SupClover -zPlaneVac[0] = -HalfLengthVac; -zPlaneVac[1] = -HalfLengthVac+TaperLengthVac; -zPlaneVac[2] = HalfLengthVac; -rOuterVac[0] = 4.3083*cm; -rOuterVac[1] = 6.0*cm; -rOuterVac[2] = 6.0*cm; + // The vacuum clover ( "Vac" ) ... + // + G4double HalfLengthVac = 7.175 * cm; + G4double TaperLengthVac = 4.0842 * cm; -rInnerVac[0] = rInnerVac[1] = rInnerVac[2] = 0.*cm; + zPlaneVac[0] = -HalfLengthVac; + zPlaneVac[1] = -HalfLengthVac + TaperLengthVac; + zPlaneVac[2] = HalfLengthVac; + rOuterVac[0] = 4.3083 * cm; + rOuterVac[1] = 6.0 * cm; + rOuterVac[2] = 6.0 * cm; -G4Polyhedra* solidVac = new G4Polyhedra("Vac",PhiStartCan,PhiTotCan,4,3, - zPlaneVac,rInnerVac,rOuterVac); -G4LogicalVolume * logicVac = new G4LogicalVolume(solidVac,m_Vacuum,"Vac"); + rInnerVac[0] = rInnerVac[1] = rInnerVac[2] = 0. * cm; -G4ThreeVector positionVac = G4ThreeVector(0.*cm,0.*cm,-0.25*mm); -new G4PVPlacement(0,positionVac, logicVac,"Vac",logicCloverCan,false,i_clo+1,true); + G4Polyhedra* solidVac = new G4Polyhedra("Vac", PhiStartCan, PhiTotCan, 4, 3, zPlaneVac, rInnerVac, rOuterVac); + G4LogicalVolume* logicVac = new G4LogicalVolume(solidVac, m_Vacuum, "Vac"); + G4ThreeVector positionVac = G4ThreeVector(0. * cm, 0. * cm, -0.25 * mm); + new G4PVPlacement(0, positionVac, logicVac, "Vac", logicCloverCan, false, i_clo + 1, true); -// -// The enveloppe of the cold finger from the back side of the can to the Dewar -// + // + // The enveloppe of the cold finger from the back side of the can to the Dewar + // -G4double zPlaneEnvColdFinger[6]; -G4double rInnerEnvColdFinger[6]; -G4double rOuterEnvColdFinger[6]; + G4double zPlaneEnvColdFinger[6]; + G4double rInnerEnvColdFinger[6]; + G4double rOuterEnvColdFinger[6]; -G4double PhiStart = 0.*deg; -G4double PhiTot = 360.*deg; -G4double EnvColdFingerHalfLength = 7.24*cm; + G4double PhiStart = 0. * deg; + G4double PhiTot = 360. * deg; + G4double EnvColdFingerHalfLength = 7.24 * cm; -zPlaneEnvColdFinger[0] = -EnvColdFingerHalfLength; -zPlaneEnvColdFinger[1] = -EnvColdFingerHalfLength+4.1*cm; -zPlaneEnvColdFinger[2] = -EnvColdFingerHalfLength+4.1*cm; -zPlaneEnvColdFinger[3] = -EnvColdFingerHalfLength+4.9*cm; -zPlaneEnvColdFinger[4] = -EnvColdFingerHalfLength+4.9*cm; -zPlaneEnvColdFinger[5] = EnvColdFingerHalfLength; + zPlaneEnvColdFinger[0] = -EnvColdFingerHalfLength; + zPlaneEnvColdFinger[1] = -EnvColdFingerHalfLength + 4.1 * cm; + zPlaneEnvColdFinger[2] = -EnvColdFingerHalfLength + 4.1 * cm; + zPlaneEnvColdFinger[3] = -EnvColdFingerHalfLength + 4.9 * cm; + zPlaneEnvColdFinger[4] = -EnvColdFingerHalfLength + 4.9 * cm; + zPlaneEnvColdFinger[5] = EnvColdFingerHalfLength; -rInnerEnvColdFinger[0]=rInnerEnvColdFinger[1]=rInnerEnvColdFinger[2]=0.*cm; -rInnerEnvColdFinger[3]=rInnerEnvColdFinger[4]=rInnerEnvColdFinger[5]=0.*cm; + rInnerEnvColdFinger[0] = rInnerEnvColdFinger[1] = rInnerEnvColdFinger[2] = 0. * cm; + rInnerEnvColdFinger[3] = rInnerEnvColdFinger[4] = rInnerEnvColdFinger[5] = 0. * cm; -rOuterEnvColdFinger[0]=2.225*cm; -rOuterEnvColdFinger[1]=2.225*cm; -rOuterEnvColdFinger[2]=3.1*cm; -rOuterEnvColdFinger[3]=3.1*cm; -rOuterEnvColdFinger[4]=2.225*cm; -rOuterEnvColdFinger[5]=2.225*cm; + rOuterEnvColdFinger[0] = 2.225 * cm; + rOuterEnvColdFinger[1] = 2.225 * cm; + rOuterEnvColdFinger[2] = 3.1 * cm; + rOuterEnvColdFinger[3] = 3.1 * cm; + rOuterEnvColdFinger[4] = 2.225 * cm; + rOuterEnvColdFinger[5] = 2.225 * cm; -G4Polycone* solidEnvColdFinger = new G4Polycone("EnvColdFinger",PhiStart,PhiTot,6, - zPlaneEnvColdFinger,rInnerEnvColdFinger,rOuterEnvColdFinger); + G4Polycone* solidEnvColdFinger = new G4Polycone("EnvColdFinger", PhiStart, PhiTot, 6, zPlaneEnvColdFinger, + rInnerEnvColdFinger, rOuterEnvColdFinger); -G4LogicalVolume* logicEnvColdFinger = new G4LogicalVolume(solidEnvColdFinger,m_Aluminum,"EnvColdFinger"); + G4LogicalVolume* logicEnvColdFinger = new G4LogicalVolume(solidEnvColdFinger, m_Aluminum, "EnvColdFinger"); -G4ThreeVector posEnvColdFinger = - G4ThreeVector(0.*cm,0.*cm,-Offset+2.*HalfLengthCan+EnvColdFingerHalfLength+0.005*mm); + G4ThreeVector posEnvColdFinger = + G4ThreeVector(0. * cm, 0. * cm, -Offset + 2. * HalfLengthCan + EnvColdFingerHalfLength + 0.005 * mm); - new G4PVPlacement(0,posEnvColdFinger,logicEnvColdFinger,"EnvColdFinger",logicSupClover,false,i_clo+1,true); + new G4PVPlacement(0, posEnvColdFinger, logicEnvColdFinger, "EnvColdFinger", logicSupClover, false, i_clo + 1, true); // Its internal vacuum... - G4double minRadiusIntEnvColdFinger = 0.*cm; - G4double maxRadiusIntEnvColdFinger = 2.025*cm; - G4double HalfLengthIntEnvColdFinger = 7.24*cm; - G4double startPhiIntEnvColdFinger = 0.*deg; - G4double deltaPhiIntEnvColdFinger = 360.*deg; + G4double minRadiusIntEnvColdFinger = 0. * cm; + G4double maxRadiusIntEnvColdFinger = 2.025 * cm; + G4double HalfLengthIntEnvColdFinger = 7.24 * cm; + G4double startPhiIntEnvColdFinger = 0. * deg; + G4double deltaPhiIntEnvColdFinger = 360. * deg; - G4Tubs* solidIntEnvColdFinger = new G4Tubs("IntDewar",minRadiusIntEnvColdFinger,maxRadiusIntEnvColdFinger, - HalfLengthIntEnvColdFinger,startPhiIntEnvColdFinger,deltaPhiIntEnvColdFinger); + G4Tubs* solidIntEnvColdFinger = + new G4Tubs("IntDewar", minRadiusIntEnvColdFinger, maxRadiusIntEnvColdFinger, HalfLengthIntEnvColdFinger, + startPhiIntEnvColdFinger, deltaPhiIntEnvColdFinger); - G4LogicalVolume* logicIntEnvColdFinger = new G4LogicalVolume(solidIntEnvColdFinger,m_Vacuum,"IntEnvColdFinger"); + G4LogicalVolume* logicIntEnvColdFinger = new G4LogicalVolume(solidIntEnvColdFinger, m_Vacuum, "IntEnvColdFinger"); // and its position in the cold finger enveloppe. - new G4PVPlacement(0,G4ThreeVector(0.,0.,0.),logicIntEnvColdFinger,"IntEnvColdFinger",logicEnvColdFinger,false,i_clo+1,true); + new G4PVPlacement(0, G4ThreeVector(0., 0., 0.), logicIntEnvColdFinger, "IntEnvColdFinger", logicEnvColdFinger, false, + i_clo + 1, true); - // The cold finger and the associated plate // - G4double xHalfLengthCFPlate = 5.04*cm; - G4double yHalfLengthCFPlate = 5.04*cm; - G4double zHalfLengthCFPlate = 1.*mm; + G4double xHalfLengthCFPlate = 5.04 * cm; + G4double yHalfLengthCFPlate = 5.04 * cm; + G4double zHalfLengthCFPlate = 1. * mm; - G4Box* solidCFPlate = new G4Box("CFPlate",xHalfLengthCFPlate,yHalfLengthCFPlate, - zHalfLengthCFPlate); + G4Box* solidCFPlate = new G4Box("CFPlate", xHalfLengthCFPlate, yHalfLengthCFPlate, zHalfLengthCFPlate); - G4LogicalVolume* logicCFPlate = new G4LogicalVolume(solidCFPlate,m_Copper,"CFPlate"); + G4LogicalVolume* logicCFPlate = new G4LogicalVolume(solidCFPlate, m_Copper, "CFPlate"); - G4ThreeVector posCFPlate(0.*cm,0.*cm,-HalfLengthVac+9.65*cm); // 0.55(d(IntCan-Ge) - // +9.(Ge length)+0.1(half length plate) - new G4PVPlacement(0,posCFPlate,logicCFPlate,"CFPlate",logicVac,false,i_clo+1,true); + G4ThreeVector posCFPlate(0. * cm, 0. * cm, -HalfLengthVac + 9.65 * cm); // 0.55(d(IntCan-Ge) + // +9.(Ge length)+0.1(half length plate) + new G4PVPlacement(0, posCFPlate, logicCFPlate, "CFPlate", logicVac, false, i_clo + 1, true); // The cold finger (internal part) // - G4double minRadiusIntCF = 0.*cm; - G4double maxRadiusIntCF = 1.5*cm; - G4double HalfLengthIntCF = 2.30*cm; - G4double startPhiIntCF = 0.*deg; - G4double deltaPhiIntCF = 360.*deg; + G4double minRadiusIntCF = 0. * cm; + G4double maxRadiusIntCF = 1.5 * cm; + G4double HalfLengthIntCF = 2.30 * cm; + G4double startPhiIntCF = 0. * deg; + G4double deltaPhiIntCF = 360. * deg; - G4Tubs* solidIntCF = new G4Tubs("IntCF",minRadiusIntCF,maxRadiusIntCF, - HalfLengthIntCF,startPhiIntCF,deltaPhiIntCF); + G4Tubs* solidIntCF = + new G4Tubs("IntCF", minRadiusIntCF, maxRadiusIntCF, HalfLengthIntCF, startPhiIntCF, deltaPhiIntCF); - G4LogicalVolume* logicIntCF = - new G4LogicalVolume(solidIntCF,m_Copper,"IntCF"); + G4LogicalVolume* logicIntCF = new G4LogicalVolume(solidIntCF, m_Copper, "IntCF"); // its position vs CloverCan... - G4ThreeVector posIntCF(0.*cm,0.*cm,4.875*cm); // -7.175 (halflengthcan internal) - // +0.55 (ext Can - Ge) - // +9.0 (Ge length) - // +0.2 (CF plate) - // +2.3 (IntCF length) + G4ThreeVector posIntCF(0. * cm, 0. * cm, 4.875 * cm); // -7.175 (halflengthcan internal) + // +0.55 (ext Can - Ge) + // +9.0 (Ge length) + // +0.2 (CF plate) + // +2.3 (IntCF length) - new G4PVPlacement(0,posIntCF,logicIntCF,"IntCF",logicVac,false,i_clo+1,true); + new G4PVPlacement(0, posIntCF, logicIntCF, "IntCF", logicVac, false, i_clo + 1, true); // The cold finger (external part) // - G4double minRadiusExtCF = 0.*cm; - G4double maxRadiusExtCF = 2.0*cm; - G4double HalfLengthExtCF = 7.2*cm; - G4double startPhiExtCF = 0.*deg; - G4double deltaPhiExtCF = 360.*deg; + G4double minRadiusExtCF = 0. * cm; + G4double maxRadiusExtCF = 2.0 * cm; + G4double HalfLengthExtCF = 7.2 * cm; + G4double startPhiExtCF = 0. * deg; + G4double deltaPhiExtCF = 360. * deg; - G4Tubs* solidExtCF = new G4Tubs("IntCF",minRadiusExtCF,maxRadiusExtCF, - HalfLengthExtCF,startPhiExtCF,deltaPhiExtCF); + G4Tubs* solidExtCF = + new G4Tubs("IntCF", minRadiusExtCF, maxRadiusExtCF, HalfLengthExtCF, startPhiExtCF, deltaPhiExtCF); - G4LogicalVolume* logicExtCF = - new G4LogicalVolume(solidExtCF,m_Copper,"ExtCF"); + G4LogicalVolume* logicExtCF = new G4LogicalVolume(solidExtCF, m_Copper, "ExtCF"); // its position vs EnvColdFinger... - G4ThreeVector posExtCF(0.*cm,0.*cm,0.*cm); - new G4PVPlacement(0,posExtCF,logicExtCF,"ExtCF",logicIntEnvColdFinger,false,i_clo+1,true); + G4ThreeVector posExtCF(0. * cm, 0. * cm, 0. * cm); + new G4PVPlacement(0, posExtCF, logicExtCF, "ExtCF", logicIntEnvColdFinger, false, i_clo + 1, true); // The Dewar // - G4double minRadiusDewar = 0.*cm; - G4double maxRadiusDewar = 10.9*cm; - G4double HalfLengthDewar = 15.2*cm; - G4double startPhiDewar = 0.*deg; - G4double deltaPhiDewar = 360.*deg; + G4double minRadiusDewar = 0. * cm; + G4double maxRadiusDewar = 10.9 * cm; + G4double HalfLengthDewar = 15.2 * cm; + G4double startPhiDewar = 0. * deg; + G4double deltaPhiDewar = 360. * deg; - G4Tubs* solidDewar = new G4Tubs("Dewar",minRadiusDewar,maxRadiusDewar, - HalfLengthDewar,startPhiDewar,deltaPhiDewar); + G4Tubs* solidDewar = + new G4Tubs("Dewar", minRadiusDewar, maxRadiusDewar, HalfLengthDewar, startPhiDewar, deltaPhiDewar); - G4LogicalVolume* logicDewar = new G4LogicalVolume(solidDewar,m_Aluminum,"Dewar"); + G4LogicalVolume* logicDewar = new G4LogicalVolume(solidDewar, m_Aluminum, "Dewar"); - G4double distFrontToMidDewar = - -Offset+2.*(HalfLengthCan+EnvColdFingerHalfLength)+HalfLengthDewar+0.01*mm; + G4double distFrontToMidDewar = -Offset + 2. * (HalfLengthCan + EnvColdFingerHalfLength) + HalfLengthDewar + 0.01 * mm; //+0.01mm to avoid roundoff errors - G4ThreeVector posDewar = G4ThreeVector(0.*cm,0.*cm,distFrontToMidDewar); - new G4PVPlacement(0,posDewar,logicDewar,"Dewar",logicSupClover,false,i_clo+1,true); + G4ThreeVector posDewar = G4ThreeVector(0. * cm, 0. * cm, distFrontToMidDewar); + new G4PVPlacement(0, posDewar, logicDewar, "Dewar", logicSupClover, false, i_clo + 1, true); ///////////////////////////////////////// // Construction of the active Ge volume: ///////////////////////////////////////// // A: Ge diode built from cuts subtracted from a cylinder (the "GeDiode") // - G4double minRadiusGeDiode = 0.*cm; - G4double maxRadiusGeDiode = 3.0*cm; - G4double HalfLengthGeDiode = 4.5*cm; - G4double startPhiGeDiode = 0.*deg; - G4double deltaPhiGeDiode = 360.*deg; - - G4Tubs* solidGeDiode = new G4Tubs("GeDiode",minRadiusGeDiode,maxRadiusGeDiode, - HalfLengthGeDiode,startPhiGeDiode,deltaPhiGeDiode); + G4double minRadiusGeDiode = 0. * cm; + G4double maxRadiusGeDiode = 3.0 * cm; + G4double HalfLengthGeDiode = 4.5 * cm; + G4double startPhiGeDiode = 0. * deg; + G4double deltaPhiGeDiode = 360. * deg; + + G4Tubs* solidGeDiode = + new G4Tubs("GeDiode", minRadiusGeDiode, maxRadiusGeDiode, HalfLengthGeDiode, startPhiGeDiode, deltaPhiGeDiode); // // External Tapered volume all along the diode ( "Cut1&2" ) // // // Cut 1 : // - G4double dummy = acos(2.9/3.0); - G4double xHalfLengthCut1 = 0.5*mm; - G4double yHalfLengthCut1 = 2.9*tan(dummy)*cm; - G4double zHalfLengthCut1 = 4.55*cm; + G4double dummy = acos(2.9 / 3.0); + G4double xHalfLengthCut1 = 0.5 * mm; + G4double yHalfLengthCut1 = 2.9 * tan(dummy) * cm; + G4double zHalfLengthCut1 = 4.55 * cm; - G4Box* solidCut1 = new G4Box("Cut1",xHalfLengthCut1,yHalfLengthCut1, - zHalfLengthCut1); + G4Box* solidCut1 = new G4Box("Cut1", xHalfLengthCut1, yHalfLengthCut1, zHalfLengthCut1); // //... and its position vs GeDiode // - G4ThreeVector transCut1(2.95*cm,0.*cm,0.*cm); - G4SubtractionSolid* solidGeMinusCut1 = - new G4SubtractionSolid("GeMinusCut1",solidGeDiode,solidCut1,0,transCut1); + G4ThreeVector transCut1(2.95 * cm, 0. * cm, 0. * cm); + G4SubtractionSolid* solidGeMinusCut1 = new G4SubtractionSolid("GeMinusCut1", solidGeDiode, solidCut1, 0, transCut1); - G4ThreeVector transCut2(0.,2.95*cm,0.); - G4Transform3D positionCut2(rm90,transCut2); + G4ThreeVector transCut2(0., 2.95 * cm, 0.); + G4Transform3D positionCut2(rm90, transCut2); - G4SubtractionSolid* solidGeMinusCut12 = - new G4SubtractionSolid("GeMinusCut12",solidGeMinusCut1,solidCut1,positionCut2); + G4SubtractionSolid* solidGeMinusCut12 = + new G4SubtractionSolid("GeMinusCut12", solidGeMinusCut1, solidCut1, positionCut2); // // External Tapered volume at the front face ( "Cut3&4" ) - G4double cosTap = cos(22.5*deg); - G4double sinTap = sin(22.5*deg); - G4double tanTap = tan(22.5*deg); + G4double cosTap = cos(22.5 * deg); + G4double sinTap = sin(22.5 * deg); + G4double tanTap = tan(22.5 * deg); - G4double xHalfLengthCut3 = 3.0*cm; - G4double yHalfLengthCut3 = 1.5*cm*sinTap; - G4double zHalfLengthCut3 = 1.5*cm/cosTap; + G4double xHalfLengthCut3 = 3.0 * cm; + G4double yHalfLengthCut3 = 1.5 * cm * sinTap; + G4double zHalfLengthCut3 = 1.5 * cm / cosTap; - G4Box* solidCut3 = new G4Box("Cut3",xHalfLengthCut3,yHalfLengthCut3, - zHalfLengthCut3+0.5*cm); - - G4double yCut3 = 2.9*cm-1.5*cm*tanTap+yHalfLengthCut3*cosTap; + G4Box* solidCut3 = new G4Box("Cut3", xHalfLengthCut3, yHalfLengthCut3, zHalfLengthCut3 + 0.5 * cm); - G4double temp = zHalfLengthCut3*cosTap-yHalfLengthCut3*sinTap; - G4double zCut3 = -HalfLengthGeDiode+temp; + G4double yCut3 = 2.9 * cm - 1.5 * cm * tanTap + yHalfLengthCut3 * cosTap; + + G4double temp = zHalfLengthCut3 * cosTap - yHalfLengthCut3 * sinTap; + G4double zCut3 = -HalfLengthGeDiode + temp; G4RotationMatrix rmCut3; - rmCut3.rotateX(-22.5*deg); + rmCut3.rotateX(-22.5 * deg); - G4ThreeVector transCut3(0.,yCut3,zCut3); - G4Transform3D positionCut3(rmCut3,transCut3); + G4ThreeVector transCut3(0., yCut3, zCut3); + G4Transform3D positionCut3(rmCut3, transCut3); - G4SubtractionSolid* solidGeMinusCut123 = - new G4SubtractionSolid("GeMinusCut123",solidGeMinusCut12,solidCut3,positionCut3); + G4SubtractionSolid* solidGeMinusCut123 = + new G4SubtractionSolid("GeMinusCut123", solidGeMinusCut12, solidCut3, positionCut3); - G4Box* solidCut4 = new G4Box("Cut4",yHalfLengthCut3,xHalfLengthCut3, - zHalfLengthCut3); + G4Box* solidCut4 = new G4Box("Cut4", yHalfLengthCut3, xHalfLengthCut3, zHalfLengthCut3); G4RotationMatrix rmCut4; - rmCut4.rotateY(22.5*deg); + rmCut4.rotateY(22.5 * deg); - G4ThreeVector transCut4(yCut3,0.,zCut3); - G4Transform3D positionCut4(rmCut4,transCut4); + G4ThreeVector transCut4(yCut3, 0., zCut3); + G4Transform3D positionCut4(rmCut4, transCut4); - G4SubtractionSolid* solidGeMinusCut1234 = - new G4SubtractionSolid("GeMinusCut1234",solidGeMinusCut123,solidCut4,positionCut4); + G4SubtractionSolid* solidGeMinusCut1234 = + new G4SubtractionSolid("GeMinusCut1234", solidGeMinusCut123, solidCut4, positionCut4); - dummy = acos(2.45/3.0); - G4double xHalfLengthCut5 = 5.5*mm; - G4double yHalfLengthCut5 = 2.45*tan(dummy)*cm; - G4double zHalfLengthCut5 = 4.55*cm; + dummy = acos(2.45 / 3.0); + G4double xHalfLengthCut5 = 5.5 * mm; + G4double yHalfLengthCut5 = 2.45 * tan(dummy) * cm; + G4double zHalfLengthCut5 = 4.55 * cm; - G4Box* solidCut5 = new G4Box("Cut5",xHalfLengthCut5,yHalfLengthCut5, - zHalfLengthCut5); + G4Box* solidCut5 = new G4Box("Cut5", xHalfLengthCut5, yHalfLengthCut5, zHalfLengthCut5); - G4ThreeVector transCut5(-3.0*cm,0.*cm,0.*cm); + G4ThreeVector transCut5(-3.0 * cm, 0. * cm, 0. * cm); - G4SubtractionSolid* solidGeMinusCut12345 = - new G4SubtractionSolid("GeMinusCut12345",solidGeMinusCut1234,solidCut5,0,transCut5); + G4SubtractionSolid* solidGeMinusCut12345 = + new G4SubtractionSolid("GeMinusCut12345", solidGeMinusCut1234, solidCut5, 0, transCut5); - G4ThreeVector transCut6(0.,-3.0*cm,0.); - G4Transform3D positionCut6(rm90,transCut6); + G4ThreeVector transCut6(0., -3.0 * cm, 0.); + G4Transform3D positionCut6(rm90, transCut6); - G4SubtractionSolid* solidGe = - new G4SubtractionSolid("Ge",solidGeMinusCut12345,solidCut5,positionCut6); + G4SubtractionSolid* solidGe = new G4SubtractionSolid("Ge", solidGeMinusCut12345, solidCut5, positionCut6); // Now the individual diode is built; create logical volumes for each of // the four individual diodes A, B, C and D: - G4LogicalVolume * logicGeA = new G4LogicalVolume(solidGe,m_Germanium,"GeA"); - G4LogicalVolume * logicGeB = new G4LogicalVolume(solidGe,m_Germanium,"GeB"); - G4LogicalVolume * logicGeC = new G4LogicalVolume(solidGe,m_Germanium,"GeC"); - G4LogicalVolume * logicGeD = new G4LogicalVolume(solidGe,m_Germanium,"GeD"); + G4LogicalVolume* logicGeA = new G4LogicalVolume(solidGe, m_Germanium, "GeA"); + G4LogicalVolume* logicGeB = new G4LogicalVolume(solidGe, m_Germanium, "GeB"); + G4LogicalVolume* logicGeC = new G4LogicalVolume(solidGe, m_Germanium, "GeC"); + G4LogicalVolume* logicGeD = new G4LogicalVolume(solidGe, m_Germanium, "GeD"); - logicGeA -> SetSensitiveDetector(m_ExogamScorer); - logicGeB -> SetSensitiveDetector(m_ExogamScorer); - logicGeC -> SetSensitiveDetector(m_ExogamScorer); - logicGeD -> SetSensitiveDetector(m_ExogamScorer); + logicGeA->SetSensitiveDetector(m_ExogamScorer); + logicGeB->SetSensitiveDetector(m_ExogamScorer); + logicGeC->SetSensitiveDetector(m_ExogamScorer); + logicGeD->SetSensitiveDetector(m_ExogamScorer); // positioning the tapered partial diodes (A to D) // into the real vacuum of the can - G4double HalfDistanceBetweenDiodes = 0.5*mm; + G4double HalfDistanceBetweenDiodes = 0.5 * mm; - G4double xDumVac = 2.45*cm+HalfDistanceBetweenDiodes; - G4double yDumVac = 2.45*cm+HalfDistanceBetweenDiodes; - G4double zDumVac = -HalfLengthVac+5.05*cm; // 5.05 = 0.55 d(int can to Ge) +4.5(half length Ge) + G4double xDumVac = 2.45 * cm + HalfDistanceBetweenDiodes; + G4double yDumVac = 2.45 * cm + HalfDistanceBetweenDiodes; + G4double zDumVac = -HalfLengthVac + 5.05 * cm; // 5.05 = 0.55 d(int can to Ge) +4.5(half length Ge) - G4ThreeVector positionVacA(xDumVac,yDumVac,zDumVac); + G4ThreeVector positionVacA(xDumVac, yDumVac, zDumVac); - G4ThreeVector posDumVacB(xDumVac,-yDumVac,zDumVac); - G4Transform3D positionVacB(rm270,posDumVacB); + G4ThreeVector posDumVacB(xDumVac, -yDumVac, zDumVac); + G4Transform3D positionVacB(rm270, posDumVacB); - G4ThreeVector posDumVacC(-xDumVac,-yDumVac,zDumVac); - G4Transform3D positionVacC(rm180,posDumVacC); + G4ThreeVector posDumVacC(-xDumVac, -yDumVac, zDumVac); + G4Transform3D positionVacC(rm180, posDumVacC); - G4ThreeVector posDumVacD(-xDumVac,yDumVac,zDumVac); - G4Transform3D positionVacD(rm90,posDumVacD); + G4ThreeVector posDumVacD(-xDumVac, yDumVac, zDumVac); + G4Transform3D positionVacD(rm90, posDumVacD); - new G4PVPlacement(0,positionVacA,logicGeA,"GeA",logicVac,false,1,true); //There is an overlap with vacumm Vac - new G4PVPlacement(positionVacB,logicGeB,"GeB",logicVac,false,2,true); - new G4PVPlacement(positionVacC,logicGeC,"GeC",logicVac,false,3,true); - new G4PVPlacement(positionVacD,logicGeD,"GeD",logicVac, false,4, true); + new G4PVPlacement(0, positionVacA, logicGeA, "GeA", logicVac, false, 1, true); // There is an overlap with vacumm Vac + new G4PVPlacement(positionVacB, logicGeB, "GeB", logicVac, false, 2, true); + new G4PVPlacement(positionVacC, logicGeC, "GeC", logicVac, false, 3, true); + new G4PVPlacement(positionVacD, logicGeD, "GeD", logicVac, false, 4, true); // // some material between the diodes to reproduce the experimental addback factor ... // - G4double xAbsorb1 = 4.16*cm; - G4double yAbsorb1 = 200.*um; // max = HalfDistanceBetweenDiodes = 0.5*mm; - G4double zAbsorb1 = 4.5*cm; + G4double xAbsorb1 = 4.16 * cm; + G4double yAbsorb1 = 200. * um; // max = HalfDistanceBetweenDiodes = 0.5*mm; + G4double zAbsorb1 = 4.5 * cm; - G4Box* solidAbsorb1 = new G4Box("Absorb1",xAbsorb1,yAbsorb1,zAbsorb1); + G4Box* solidAbsorb1 = new G4Box("Absorb1", xAbsorb1, yAbsorb1, zAbsorb1); - G4double xAbsorb2 = 200*um; // max = HalfDistanceBetweenDiodes = 0.5*mm; - G4double yAbsorb2 = 4.16*cm; - G4double zAbsorb2 = 4.5*cm; + G4double xAbsorb2 = 200 * um; // max = HalfDistanceBetweenDiodes = 0.5*mm; + G4double yAbsorb2 = 4.16 * cm; + G4double zAbsorb2 = 4.5 * cm; - G4Box* solidAbsorb2 = new G4Box("Absorb2",xAbsorb2,yAbsorb2,zAbsorb2); + G4Box* solidAbsorb2 = new G4Box("Absorb2", xAbsorb2, yAbsorb2, zAbsorb2); - //G4UnionSolid* solidAbsorb = - //new G4UnionSolid("Absorb",solidAbsorb1,solidAbsorb2,0,0); - G4UnionSolid* solidAbsorb = - new G4UnionSolid("Absorb",solidAbsorb1,solidAbsorb2); + // G4UnionSolid* solidAbsorb = + // new G4UnionSolid("Absorb",solidAbsorb1,solidAbsorb2,0,0); + G4UnionSolid* solidAbsorb = new G4UnionSolid("Absorb", solidAbsorb1, solidAbsorb2); - G4LogicalVolume* logicAbsorb = new G4LogicalVolume(solidAbsorb,m_Copper,"Absorb"); + G4LogicalVolume* logicAbsorb = new G4LogicalVolume(solidAbsorb, m_Copper, "Absorb"); - G4ThreeVector positionAbsorb(0.,0.,zDumVac); + G4ThreeVector positionAbsorb(0., 0., zDumVac); - new G4PVPlacement(0,positionAbsorb,logicAbsorb,"Absorb",logicVac,false,i_clo+1,true); + new G4PVPlacement(0, positionAbsorb, logicAbsorb, "Absorb", logicVac, false, i_clo + 1, true); // // Now: takes care of the holes and amorphous Ge in each diode: - // Central hole with amorphous Ge for each diode. + // Central hole with amorphous Ge for each diode. // - G4double minRadiusAGe1 = 0.*cm; - G4double maxRadiusAGe1 = 0.52*cm; - G4double HalfLengthAGe1 = 3.75*cm; - G4double startPhiAGe1 = 0.*deg; - G4double deltaPhiAGe1 = 360.*deg; + G4double minRadiusAGe1 = 0. * cm; + G4double maxRadiusAGe1 = 0.52 * cm; + G4double HalfLengthAGe1 = 3.75 * cm; + G4double startPhiAGe1 = 0. * deg; + G4double deltaPhiAGe1 = 360. * deg; + + // G4Tubs* solidAGe1 = new G4Tubs("AGe1",minRadiusAGe1,maxRadiusAGe1, + // HalfLengthAGe1,startPhiAGe1,deltaPhiAGe1); - //G4Tubs* solidAGe1 = new G4Tubs("AGe1",minRadiusAGe1,maxRadiusAGe1, - // HalfLengthAGe1,startPhiAGe1,deltaPhiAGe1); + // G4LogicalVolume* logicAGe1 = new G4LogicalVolume(solidAGe1,m_Germanium,"AGe1"); - //G4LogicalVolume* logicAGe1 = new G4LogicalVolume(solidAGe1,m_Germanium,"AGe1"); - // ... and second the hole in it: - G4Tubs* solidHole1 = new G4Tubs("Hole1",minRadiusAGe1,maxRadiusAGe1-2.*mm, - HalfLengthAGe1,startPhiAGe1,deltaPhiAGe1); + G4Tubs* solidHole1 = + new G4Tubs("Hole1", minRadiusAGe1, maxRadiusAGe1 - 2. * mm, HalfLengthAGe1, startPhiAGe1, deltaPhiAGe1); - G4LogicalVolume* logicHole1 = new G4LogicalVolume(solidHole1,m_Vacuum,"Hole1"); + G4LogicalVolume* logicHole1 = new G4LogicalVolume(solidHole1, m_Vacuum, "Hole1"); // Visu - G4VisAttributes* CanVisAtt= new G4VisAttributes(G4Colour(0.5,0.5,0.5, 0.7)); // Grey - G4VisAttributes* DewarVisAtt= new G4VisAttributes(G4Colour(0.5,0.5,0.5)); // Grey - - logicCloverCan ->SetVisAttributes(CanVisAtt); - logicEnvColdFinger ->SetVisAttributes(CanVisAtt); - logicDewar ->SetVisAttributes(DewarVisAtt); - logicSupClover->SetVisAttributes (G4VisAttributes::Invisible); - - G4VisAttributes* HoleVisAtt= new G4VisAttributes(G4Colour(0.0,0.0,0.0)); // Black - G4VisAttributes* AbsorbVisAtt= new G4VisAttributes(G4Colour(0.5,0.0,0.5,1)); // purple - G4VisAttributes* GeAVisAtt= new G4VisAttributes(G4Colour(1.0,0.0,0.0, 0.6)); //Red - G4VisAttributes* GeBVisAtt= new G4VisAttributes(G4Colour(0.0,1.0,0.0, 0.6)); //Green - G4VisAttributes* GeCVisAtt= new G4VisAttributes(G4Colour(0.0,0.0,1.0, 0.6)); //Blue - G4VisAttributes* GeDVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0, 0.6)); //White - - logicHole1 ->SetVisAttributes(HoleVisAtt); - logicAbsorb ->SetVisAttributes(AbsorbVisAtt); - logicGeA ->SetVisAttributes(GeAVisAtt); - logicGeB ->SetVisAttributes(GeBVisAtt); - logicGeC ->SetVisAttributes(GeCVisAtt); - logicGeD ->SetVisAttributes(GeDVisAtt); - logicVac->SetVisAttributes (G4VisAttributes::Invisible); - + G4VisAttributes* CanVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5, 0.7)); // Grey + G4VisAttributes* DewarVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)); // Grey + + logicCloverCan->SetVisAttributes(CanVisAtt); + logicEnvColdFinger->SetVisAttributes(CanVisAtt); + logicDewar->SetVisAttributes(DewarVisAtt); + logicSupClover->SetVisAttributes(G4VisAttributes::GetInvisible()); + + G4VisAttributes* HoleVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.0)); // Black + G4VisAttributes* AbsorbVisAtt = new G4VisAttributes(G4Colour(0.5, 0.0, 0.5, 1)); // purple + G4VisAttributes* GeAVisAtt = new G4VisAttributes(G4Colour(1.0, 0.0, 0.0, 0.6)); // Red + G4VisAttributes* GeBVisAtt = new G4VisAttributes(G4Colour(0.0, 1.0, 0.0, 0.6)); // Green + G4VisAttributes* GeCVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 1.0, 0.6)); // Blue + G4VisAttributes* GeDVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 1.0, 0.6)); // White + + logicHole1->SetVisAttributes(HoleVisAtt); + logicAbsorb->SetVisAttributes(AbsorbVisAtt); + logicGeA->SetVisAttributes(GeAVisAtt); + logicGeB->SetVisAttributes(GeBVisAtt); + logicGeC->SetVisAttributes(GeCVisAtt); + logicGeD->SetVisAttributes(GeDVisAtt); + logicVac->SetVisAttributes(G4VisAttributes::GetInvisible()); } - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Exogam::AddDetector(double X, double Y, double Z, double ThetaX, double ThetaY, double ThetaZ){ +void Exogam::AddDetector(double X, double Y, double Z, double ThetaX, double ThetaY, double ThetaZ) { m_X.push_back(X); m_Y.push_back(Y); m_Z.push_back(Z); @@ -551,7 +532,6 @@ void Exogam::AddDetector(double X, double Y, double Z, double ThetaX, double T m_ThetaZ.push_back(ThetaZ); } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -559,86 +539,82 @@ void Exogam::AddDetector(double X, double Y, double Z, double ThetaX, double T // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Exogam::ReadConfiguration(NPL::InputParser parser){ +void Exogam::ReadConfiguration(NPL::InputParser parser) { vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Exogam"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " detectors found " << endl; - - vector<string> coord = {"X", "Y", "Z","ThetaX","ThetaY","ThetaZ"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(coord)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Exogam " << i+1 << endl; - double X = blocks[i]->GetDouble("X","mm"); - double Y = blocks[i]->GetDouble("Y","mm"); - double Z = blocks[i]->GetDouble("Z","mm"); - double ThetaX = blocks[i]->GetDouble("ThetaX","deg"); - double ThetaY = blocks[i]->GetDouble("ThetaY","deg"); - double ThetaZ = blocks[i]->GetDouble("ThetaZ","deg"); - AddDetector(X,Y,Z,ThetaX, ThetaY, ThetaZ); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + + vector<string> coord = {"X", "Y", "Z", "ThetaX", "ThetaY", "ThetaZ"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(coord)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Exogam " << i + 1 << endl; + double X = blocks[i]->GetDouble("X", "mm"); + double Y = blocks[i]->GetDouble("Y", "mm"); + double Z = blocks[i]->GetDouble("Z", "mm"); + double ThetaX = blocks[i]->GetDouble("ThetaX", "deg"); + double ThetaY = blocks[i]->GetDouble("ThetaY", "deg"); + double ThetaZ = blocks[i]->GetDouble("ThetaZ", "deg"); + AddDetector(X, Y, Z, ThetaX, ThetaY, ThetaZ); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } } } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void Exogam::ConstructDetector(G4LogicalVolume* world){ - //G4double distBGOSShieldToGeCan = 3.2*cm; // distance from the front face of the - // BGO Side Shield to the front face of the - // Ge can (theory: 3.2*cm) - //G4double distCollimatorToGeCan=6.15*cm; // distance from front face of the collimator - // to the front face of the Ge can - - for ( unsigned i = 0; i < m_X.size(); ++i ) - { +void Exogam::ConstructDetector(G4LogicalVolume* world) { + // G4double distBGOSShieldToGeCan = 3.2*cm; // distance from the front face of the + // BGO Side Shield to the front face of the + // Ge can (theory: 3.2*cm) + // G4double distCollimatorToGeCan=6.15*cm; // distance from front face of the collimator + // to the front face of the Ge can + + for (unsigned i = 0; i < m_X.size(); ++i) { // Build and place Clover and its enveloppe BuildClover(i, world); - - //BuildSideCatcher(); - //BuildBackCatcher(); - //BuildSideShield(); - //BuildCollimator(); + // BuildSideCatcher(); + // BuildBackCatcher(); + + // BuildSideShield(); + // BuildCollimator(); } } - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void Exogam::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("Exogam")){ - pTree->Branch("Exogam", "TExogamData", &m_Event) ; +void Exogam::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("Exogam")) { + pTree->Branch("Exogam", "TExogamData", &m_Event); } - pTree->SetBranchAddress("Exogam", &m_Event) ; + pTree->SetBranchAddress("Exogam", &m_Event); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Exogam::ReadSensitive(const G4Event*){ +void Exogam::ReadSensitive(const G4Event*) { m_Event->Clear(); /////////// // Calorimeter scorer - CalorimeterScorers::PS_Calorimeter* Scorer= (CalorimeterScorers::PS_Calorimeter*) m_ExogamScorer->GetPrimitive(0); + CalorimeterScorers::PS_Calorimeter* Scorer = (CalorimeterScorers::PS_Calorimeter*)m_ExogamScorer->GetPrimitive(0); - unsigned int size = Scorer->GetMult(); - for(unsigned int i = 0 ; i < size ; i++){ - double Energy = RandGauss::shoot(Scorer->GetEnergy(i),Exogam_NS::ResoEnergy); - if(Energy>Exogam_NS::EnergyThreshold){ + unsigned int size = Scorer->GetMult(); + for (unsigned int i = 0; i < size; i++) { + double Energy = RandGauss::shoot(Scorer->GetEnergy(i), Exogam_NS::ResoEnergy); + if (Energy > Exogam_NS::EnergyThreshold) { double Time = Scorer->GetTime(i); int CristalNbr = Scorer->GetLevel(i)[0]; int CloverNbr = Scorer->GetLevel(i)[1]; @@ -648,24 +624,22 @@ void Exogam::ReadSensitive(const G4Event*){ m_Event->SetTime(Time); } } - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -//////////////////////////////////////////////////////////////// -void Exogam::InitializeScorers() { - bool already_exist = false; - m_ExogamScorer = CheckScorer("ExogamScorer",already_exist) ; +//////////////////////////////////////////////////////////////// +void Exogam::InitializeScorers() { + bool already_exist = false; + m_ExogamScorer = CheckScorer("ExogamScorer", already_exist); - if(already_exist) - return ; + if (already_exist) + return; // Otherwise the scorer is initialised - vector<int> level({0, 1}); - - m_ExogamScorer->RegisterPrimitive( - new CalorimeterScorers::PS_Calorimeter("Cristal",level, 0)); - G4SDManager::GetSDMpointer()->AddNewDetector(m_ExogamScorer) ; + vector<int> level({0, 1}); + + m_ExogamScorer->RegisterPrimitive(new CalorimeterScorers::PS_Calorimeter("Cristal", level, 0)); + G4SDManager::GetSDMpointer()->AddNewDetector(m_ExogamScorer); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -674,22 +648,20 @@ void Exogam::InitializeScorers() { //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* Exogam::Construct(){ - return (NPS::VDetector*) new Exogam(); -} +NPS::VDetector* Exogam::Construct() { return (NPS::VDetector*)new Exogam(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_Exogam{ - public: - proxy_nps_Exogam(){ - NPS::DetectorFactory::getInstance()->AddToken("Exogam","Exogam"); - NPS::DetectorFactory::getInstance()->AddDetector("Exogam",Exogam::Construct); - } - }; - - proxy_nps_Exogam p_nps_Exogam; +extern "C" { +class proxy_nps_Exogam { + public: + proxy_nps_Exogam() { + NPS::DetectorFactory::getInstance()->AddToken("Exogam", "Exogam"); + NPS::DetectorFactory::getInstance()->AddDetector("Exogam", Exogam::Construct); + } +}; + +proxy_nps_Exogam p_nps_Exogam; } diff --git a/NPSimulation/Detectors/Fatima/Fatima.cc b/NPSimulation/Detectors/Fatima/Fatima.cc index dffd966af..5f8f79504 100644 --- a/NPSimulation/Detectors/Fatima/Fatima.cc +++ b/NPSimulation/Detectors/Fatima/Fatima.cc @@ -20,21 +20,21 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> +#include <sstream> using namespace std; -//Geant4 -#include "G4VSolid.hh" +// Geant4 #include "G4Box.hh" -#include "G4Tubs.hh" -#include "G4UnionSolid.hh" -#include "G4SubtractionSolid.hh" +#include "G4Colour.hh" +#include "G4PVPlacement.hh" #include "G4SDManager.hh" +#include "G4SubtractionSolid.hh" #include "G4Transform3D.hh" -#include "G4PVPlacement.hh" -#include "G4Colour.hh" +#include "G4Tubs.hh" +#include "G4UnionSolid.hh" +#include "G4VSolid.hh" // NPS #include "Fatima.hh" @@ -53,7 +53,7 @@ using namespace CLHEP; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Fatima Specific Method -Fatima::Fatima(){ +Fatima::Fatima() { m_Event = new TFatimaData(); // Blue @@ -63,31 +63,31 @@ Fatima::Fatima(){ m_PMTVisAtt = new G4VisAttributes(G4Colour(0.1, 0.1, 0.1)); // Grey wireframe - m_DetectorCasingVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5,0.2)); + m_DetectorCasingVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5, 0.2)); m_LogicalDetector = 0; - m_LaBr3Scorer = 0 ; + m_LaBr3Scorer = 0; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Fatima::~Fatima(){ -} +Fatima::~Fatima() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Fatima::AddDetector(G4ThreeVector Pos1, G4ThreeVector Pos2, G4ThreeVector Pos3, G4ThreeVector Pos4){ - G4ThreeVector Pos=(Pos1+Pos2+Pos3+Pos4)/4.; - G4ThreeVector u = Pos1-Pos2; - G4ThreeVector v = Pos1-Pos4; - u = u.unit(); v = v.unit(); +void Fatima::AddDetector(G4ThreeVector Pos1, G4ThreeVector Pos2, G4ThreeVector Pos3, G4ThreeVector Pos4) { + G4ThreeVector Pos = (Pos1 + Pos2 + Pos3 + Pos4) / 4.; + G4ThreeVector u = Pos1 - Pos2; + G4ThreeVector v = Pos1 - Pos4; + u = u.unit(); + v = v.unit(); G4ThreeVector w = Pos.unit(); - Pos = Pos + w*Length*0.5; + Pos = Pos + w * Length * 0.5; m_Pos.push_back(Pos); - m_Rot.push_back(new G4RotationMatrix(u,v,w)); + m_Rot.push_back(new G4RotationMatrix(u, v, w)); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Fatima::AddDetector(G4ThreeVector Pos, double beta_u, double beta_v, double beta_w){ +void Fatima::AddDetector(G4ThreeVector Pos, double beta_u, double beta_v, double beta_w) { double Theta = Pos.theta(); double Phi = Pos.phi(); @@ -103,10 +103,10 @@ void Fatima::AddDetector(G4ThreeVector Pos, double beta_u, double beta_v, double v = v.unit(); u = u.unit(); - G4RotationMatrix* r = new G4RotationMatrix(u,v,w); - r->rotate(beta_u,u); - r->rotate(beta_v,v); - r->rotate(beta_w,w); + G4RotationMatrix* r = new G4RotationMatrix(u, v, w); + r->rotate(beta_u, u); + r->rotate(beta_v, v); + r->rotate(beta_w, w); m_Pos.push_back(Pos); m_Rot.push_back(r); @@ -116,38 +116,38 @@ void Fatima::AddDetector(G4ThreeVector Pos, double beta_u, double beta_v, double // Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Fatima::ReadConfiguration(NPL::InputParser parser){ +void Fatima::ReadConfiguration(NPL::InputParser parser) { vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Fatima"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " detectors found " << endl; - for(unsigned int i = 0 ; i < blocks.size() ; i++){ + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + for (unsigned int i = 0; i < blocks.size(); i++) { // Cartesian Case - vector<string> cart = {"A","B","C","D"}; + vector<string> cart = {"A", "B", "C", "D"}; // Spherical Case - vector<string> sphe= {"R","THETA","PHI","BETA"}; - - if(blocks[i]->HasTokenList(cart)){ - cout << endl << "//// Fatima " << i+1 << endl; - G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("A","mm")); - G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("B","mm")); - G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("C","mm")); - G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("D","mm")); - AddDetector(A,B,C,D) ; + vector<string> sphe = {"R", "THETA", "PHI", "BETA"}; + + if (blocks[i]->HasTokenList(cart)) { + cout << endl << "//// Fatima " << i + 1 << endl; + G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("A", "mm")); + G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("B", "mm")); + G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("C", "mm")); + G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("D", "mm")); + AddDetector(A, B, C, D); } - else if(blocks[i]->HasTokenList(sphe)){ - cout << endl << "//// Fatima " << i+1 << endl; - double Theta = blocks[i]->GetDouble("THETA","deg"); - double Phi= blocks[i]->GetDouble("PHI","deg"); - double R = blocks[i]->GetDouble("R","mm"); - vector<double> beta = blocks[i]->GetVectorDouble("BETA","deg"); - R = R + 0.5*Length; - G4ThreeVector Pos(R*sin(Theta)*cos(Phi),R*sin(Theta)*sin(Phi),R*cos(Theta)); - AddDetector(Pos,beta[0],beta[1],beta[2]); + else if (blocks[i]->HasTokenList(sphe)) { + cout << endl << "//// Fatima " << i + 1 << endl; + double Theta = blocks[i]->GetDouble("THETA", "deg"); + double Phi = blocks[i]->GetDouble("PHI", "deg"); + double R = blocks[i]->GetDouble("R", "mm"); + vector<double> beta = blocks[i]->GetVectorDouble("BETA", "deg"); + R = R + 0.5 * Length; + G4ThreeVector Pos(R * sin(Theta) * cos(Phi), R * sin(Theta) * sin(Phi), R * cos(Theta)); + AddDetector(Pos, beta[0], beta[1], beta[2]); } - else{ + else { cout << "ERROR: Missing token for Fatima blocks, check your input file" << endl; exit(1); } @@ -157,16 +157,16 @@ void Fatima::ReadConfiguration(NPL::InputParser parser){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void Fatima::ConstructDetector(G4LogicalVolume* world){ +void Fatima::ConstructDetector(G4LogicalVolume* world) { unsigned int mysize = m_Pos.size(); - for(unsigned int i = 0 ; i < mysize ; i++){ - new G4PVPlacement(G4Transform3D(*m_Rot[i], m_Pos[i]), ConstructDetector(), "FatimaDetector", world, false, i+1); + for (unsigned int i = 0; i < mysize; i++) { + new G4PVPlacement(G4Transform3D(*m_Rot[i], m_Pos[i]), ConstructDetector(), "FatimaDetector", world, false, i + 1); } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Fatima::ConstructDetector(){ - if(!m_LogicalDetector){ +G4LogicalVolume* Fatima::ConstructDetector() { + if (!m_LogicalDetector) { G4Material* Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); G4Material* Alu = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); @@ -174,27 +174,19 @@ G4LogicalVolume* Fatima::ConstructDetector(){ G4Material* LaBr3 = MaterialManager::getInstance()->GetMaterialFromLibrary("LaBr3"); // Mother Volume - G4Tubs* solidFatimaDetector = - new G4Tubs("Fatima",0, 0.5*FaceFront, 0.5*Length, 0.*deg, 360.*deg); - m_LogicalDetector = - new G4LogicalVolume(solidFatimaDetector, Vacuum, "Fatima", 0, 0, 0); + G4Tubs* solidFatimaDetector = new G4Tubs("Fatima", 0, 0.5 * FaceFront, 0.5 * Length, 0. * deg, 360. * deg); + m_LogicalDetector = new G4LogicalVolume(solidFatimaDetector, Vacuum, "Fatima", 0, 0, 0); - m_LogicalDetector->SetVisAttributes(G4VisAttributes::Invisible); + m_LogicalDetector->SetVisAttributes(G4VisAttributes::GetInvisible()); // Detector construction // LaBr3 - G4ThreeVector positionLaBr3 = G4ThreeVector(0, 0, LaBr3_PosZ); + G4ThreeVector positionLaBr3 = G4ThreeVector(0, 0, LaBr3_PosZ); - G4Tubs* solidLaBr3 = new G4Tubs("solidLaBr3", 0., 0.5*LaBr3Face, 0.5*LaBr3Thickness, 0.*deg, 360.*deg); + G4Tubs* solidLaBr3 = new G4Tubs("solidLaBr3", 0., 0.5 * LaBr3Face, 0.5 * LaBr3Thickness, 0. * deg, 360. * deg); G4LogicalVolume* logicLaBr3 = new G4LogicalVolume(solidLaBr3, LaBr3, "logicLaBr3", 0, 0, 0); - new G4PVPlacement(0, - positionLaBr3, - logicLaBr3, - "Fatima_LaBr3", - m_LogicalDetector, - false, - 0); + new G4PVPlacement(0, positionLaBr3, logicLaBr3, "Fatima_LaBr3", m_LogicalDetector, false, 0); // Set LaBr3 sensible logicLaBr3->SetSensitiveDetector(m_LaBr3Scorer); @@ -204,87 +196,63 @@ G4LogicalVolume* Fatima::ConstructDetector(){ // Aluminium can around LaBr3 // LaBr3 Can - G4ThreeVector positionLaBr3Can = G4ThreeVector(0, 0, LaBr3Can_PosZ); + G4ThreeVector positionLaBr3Can = G4ThreeVector(0, 0, LaBr3Can_PosZ); - G4Tubs* solidLaBr3Can = new G4Tubs("solidLaBr3Can", 0.5*CanInnerDiameter, 0.5*CanOuterDiameter, 0.5*CanLength, 0.*deg, 360.*deg); + G4Tubs* solidLaBr3Can = new G4Tubs("solidLaBr3Can", 0.5 * CanInnerDiameter, 0.5 * CanOuterDiameter, 0.5 * CanLength, + 0. * deg, 360. * deg); G4LogicalVolume* logicLaBr3Can = new G4LogicalVolume(solidLaBr3Can, Alu, "logicLaBr3Can", 0, 0, 0); - new G4PVPlacement(0, - positionLaBr3Can, - logicLaBr3Can, - "Fatima_LaBr3Can", - m_LogicalDetector, - false, - 0); + new G4PVPlacement(0, positionLaBr3Can, logicLaBr3Can, "Fatima_LaBr3Can", m_LogicalDetector, false, 0); // Visualisation of LaBr3Can logicLaBr3Can->SetVisAttributes(m_DetectorCasingVisAtt); // Aluminium window in front of LaBr3 // LaBr3 Window - G4ThreeVector positionLaBr3Win = G4ThreeVector(0, 0, LaBr3Win_PosZ); + G4ThreeVector positionLaBr3Win = G4ThreeVector(0, 0, LaBr3Win_PosZ); - G4Tubs* solidLaBr3Win = new G4Tubs("solidLaBr3Win", 0.5*WinInnerDiameter, 0.5*WinOuterDiameter, 0.5*WinLength, 0.*deg, 360.*deg); + G4Tubs* solidLaBr3Win = new G4Tubs("solidLaBr3Win", 0.5 * WinInnerDiameter, 0.5 * WinOuterDiameter, 0.5 * WinLength, + 0. * deg, 360. * deg); G4LogicalVolume* logicLaBr3Win = new G4LogicalVolume(solidLaBr3Win, Alu, "logicLaBr3Win", 0, 0, 0); - new G4PVPlacement(0, - positionLaBr3Win, - logicLaBr3Win, - "Fatima_LaBr3Win", - m_LogicalDetector, - false, - 0); + new G4PVPlacement(0, positionLaBr3Win, logicLaBr3Win, "Fatima_LaBr3Win", m_LogicalDetector, false, 0); // Visualisation of LaBr3Win logicLaBr3Win->SetVisAttributes(m_DetectorCasingVisAtt); // PMT - G4ThreeVector positionPMT = G4ThreeVector(0, 0, PMT_PosZ); + G4ThreeVector positionPMT = G4ThreeVector(0, 0, PMT_PosZ); - G4Tubs* solidPMout = new G4Tubs("solidPMOut", 0.5*LaBr3Face, 0.5*PMTFace, 0.5*PMTThickness, 0.*deg, 360.*deg); - G4Tubs* solidPMin = new G4Tubs("solidPMIn", 0.5*LaBr3Face-0.1*cm, 0.5*PMTFace-0.5*cm, 0.5*(PMTThickness-2.*cm)-0.1*cm, 0.*deg, 360.*deg); - G4RotationMatrix* RotMat=NULL; - const G4ThreeVector &Trans= G4ThreeVector(0.,0.,1.*cm); - G4SubtractionSolid* solidPMT = new G4SubtractionSolid("solidPMT", solidPMout,solidPMin, RotMat, Trans); + G4Tubs* solidPMout = + new G4Tubs("solidPMOut", 0.5 * LaBr3Face, 0.5 * PMTFace, 0.5 * PMTThickness, 0. * deg, 360. * deg); + G4Tubs* solidPMin = new G4Tubs("solidPMIn", 0.5 * LaBr3Face - 0.1 * cm, 0.5 * PMTFace - 0.5 * cm, + 0.5 * (PMTThickness - 2. * cm) - 0.1 * cm, 0. * deg, 360. * deg); + G4RotationMatrix* RotMat = NULL; + const G4ThreeVector& Trans = G4ThreeVector(0., 0., 1. * cm); + G4SubtractionSolid* solidPMT = new G4SubtractionSolid("solidPMT", solidPMout, solidPMin, RotMat, Trans); G4LogicalVolume* logicPMT = new G4LogicalVolume(solidPMT, Alu, "logicPMT", 0, 0, 0); - new G4PVPlacement(0, - positionPMT, - logicPMT, - "Fatima_PMT", - m_LogicalDetector, - false, - 0); + new G4PVPlacement(0, positionPMT, logicPMT, "Fatima_PMT", m_LogicalDetector, false, 0); // Visualisation of PMT Strip logicPMT->SetVisAttributes(m_PMTVisAtt); // Lead shielding // A - G4ThreeVector positionLeadAShield = G4ThreeVector(0, 0, LeadAShield_PosZ); - G4Tubs* solidLeadA = new G4Tubs("solidLead", 0.5*LeadAMinR, 0.5*LeadAMaxR, 0.5*LeadALength, 0.*deg, 360.*deg); + G4ThreeVector positionLeadAShield = G4ThreeVector(0, 0, LeadAShield_PosZ); + G4Tubs* solidLeadA = + new G4Tubs("solidLead", 0.5 * LeadAMinR, 0.5 * LeadAMaxR, 0.5 * LeadALength, 0. * deg, 360. * deg); G4LogicalVolume* logicLeadAShield = new G4LogicalVolume(solidLeadA, Lead, "logicLeadAShield", 0, 0, 0); - new G4PVPlacement(0, - positionLeadAShield, - logicLeadAShield, - "Fatima_LeadAShield", - m_LogicalDetector, - false, - 0); + new G4PVPlacement(0, positionLeadAShield, logicLeadAShield, "Fatima_LeadAShield", m_LogicalDetector, false, 0); // B - G4ThreeVector positionLeadBShield = G4ThreeVector(0, 0, LeadBShield_PosZ); - G4Tubs* solidLeadB = new G4Tubs("solidLead", 0.5*LeadBMinR, 0.5*LeadBMaxR, 0.5*LeadBLength, 0.*deg, 360.*deg); + G4ThreeVector positionLeadBShield = G4ThreeVector(0, 0, LeadBShield_PosZ); + G4Tubs* solidLeadB = + new G4Tubs("solidLead", 0.5 * LeadBMinR, 0.5 * LeadBMaxR, 0.5 * LeadBLength, 0. * deg, 360. * deg); G4LogicalVolume* logicLeadBShield = new G4LogicalVolume(solidLeadB, Lead, "logicLeadBShield", 0, 0, 0); - new G4PVPlacement(0, - positionLeadBShield, - logicLeadBShield, - "Fatima_LeadBShield", - m_LogicalDetector, - false, - 0); + new G4PVPlacement(0, positionLeadBShield, logicLeadBShield, "Fatima_LeadBShield", m_LogicalDetector, false, 0); // Visualisation of PMT Strip G4VisAttributes* LeadVisAtt = new G4VisAttributes(G4Colour(1., 1., 0.)); @@ -298,79 +266,76 @@ G4LogicalVolume* Fatima::ConstructDetector(){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void Fatima::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("Fatima")){ - pTree->Branch("Fatima", "TFatimaData", &m_Event) ; - } - pTree->SetBranchAddress("Fatima", &m_Event) ; +void Fatima::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("Fatima")) { + pTree->Branch("Fatima", "TFatimaData", &m_Event); + } + pTree->SetBranchAddress("Fatima", &m_Event); } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Fatima::ReadSensitive(const G4Event* ){ +void Fatima::ReadSensitive(const G4Event*) { m_Event->Clear(); /////////// // LaBr3 - CalorimeterScorers::PS_Calorimeter* Scorer= (CalorimeterScorers::PS_Calorimeter*) m_LaBr3Scorer->GetPrimitive(0); - unsigned int size = Scorer->GetMult(); - for(unsigned int i = 0 ; i < size ; i++){ - vector<unsigned int> level = Scorer->GetLevel(i); + CalorimeterScorers::PS_Calorimeter* Scorer = (CalorimeterScorers::PS_Calorimeter*)m_LaBr3Scorer->GetPrimitive(0); + unsigned int size = Scorer->GetMult(); + for (unsigned int i = 0; i < size; i++) { + vector<unsigned int> level = Scorer->GetLevel(i); double Energy = RandGauss::shoot(Scorer->GetEnergy(i), EnergyResolution); - if(Energy>EnergyThreshold){ + if (Energy > EnergyThreshold) { double Time = Scorer->GetTime(i); int DetectorNbr = level[0]; - m_Event->SetFatimaLaBr3E(DetectorNbr,Energy); - m_Event->SetFatimaLaBr3T(DetectorNbr,Time); + m_Event->SetFatimaLaBr3E(DetectorNbr, Energy); + m_Event->SetFatimaLaBr3T(DetectorNbr, Time); } } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Fatima::InitializeScorers(){ +void Fatima::InitializeScorers() { vector<G4int> NestingLevel; NestingLevel.push_back(1); // LaBr3 Associate Scorer bool already_exist = false; - m_LaBr3Scorer = CheckScorer("Fatima_LaBr3Scorer",already_exist); + m_LaBr3Scorer = CheckScorer("Fatima_LaBr3Scorer", already_exist); // if the scorer were created previously nothing else need to be made - if(already_exist) return; + if (already_exist) + return; - G4VPrimitiveScorer* LaBr3Scorer = - new CalorimeterScorers::PS_Calorimeter("FatimaLaBr3",NestingLevel); - //and register it to the multifunctionnal detector + G4VPrimitiveScorer* LaBr3Scorer = new CalorimeterScorers::PS_Calorimeter("FatimaLaBr3", NestingLevel); + // and register it to the multifunctionnal detector m_LaBr3Scorer->RegisterPrimitive(LaBr3Scorer); // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_LaBr3Scorer) ; + G4SDManager::GetSDMpointer()->AddNewDetector(m_LaBr3Scorer); } //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* Fatima::Construct(){ - return (NPS::VDetector*) new Fatima(); -} +NPS::VDetector* Fatima::Construct() { return (NPS::VDetector*)new Fatima(); } //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_fatima{ - public: - proxy_nps_fatima(){ - NPS::DetectorFactory::getInstance()->AddToken("Fatima","Fatima"); - NPS::DetectorFactory::getInstance()->AddDetector("Fatima",Fatima::Construct); - } - }; - - proxy_nps_fatima p_nps_fatima; +extern "C" { +class proxy_nps_fatima { + public: + proxy_nps_fatima() { + NPS::DetectorFactory::getInstance()->AddToken("Fatima", "Fatima"); + NPS::DetectorFactory::getInstance()->AddDetector("Fatima", Fatima::Construct); + } +}; + +proxy_nps_fatima p_nps_fatima; } diff --git a/NPSimulation/Detectors/GASPARD/GaspardScorers.hh b/NPSimulation/Detectors/GASPARD/GaspardScorers.hh index 79b24b244..bc56d4dc1 100644 --- a/NPSimulation/Detectors/GASPARD/GaspardScorers.hh +++ b/NPSimulation/Detectors/GASPARD/GaspardScorers.hh @@ -21,279 +21,248 @@ * * *****************************************************************************/ -#include "G4VPrimitiveScorer.hh" #include "G4THitsMap.hh" - -namespace GPDSCORERS -{ - // This Threshold is used in all scorers - // Any energy deposit under this threshold will not create an entry - const double TriggerThreshold = 0.1 * keV; - -class GPDScorerFirstStageEnergy : public G4VPrimitiveScorer -{ -public: // with description - GPDScorerFirstStageEnergy(G4String name, G4String volumeName, G4int depth = 0); - virtual ~GPDScorerFirstStageEnergy(); - -protected: // with description - virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); - -public: - virtual void Initialize(G4HCofThisEvent*); - virtual void EndOfEvent(G4HCofThisEvent*); - virtual void clear(); - virtual void DrawAll(); - virtual void PrintAll(); - -private: - G4String m_VolumeName; - G4int HCID; - G4THitsMap<G4double>* EvtMap; -}; - - - -class GPDScorerSecondStageEnergy : public G4VPrimitiveScorer -{ -public: // with description - GPDScorerSecondStageEnergy(G4String name, G4String volumeName, G4int depth = 0); - virtual ~GPDScorerSecondStageEnergy(); - -protected: // with description - virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); - -public: - virtual void Initialize(G4HCofThisEvent*); - virtual void EndOfEvent(G4HCofThisEvent*); - virtual void clear(); - virtual void DrawAll(); - virtual void PrintAll(); - -private: - G4String m_VolumeName; - G4int HCID; - G4THitsMap<G4double>* EvtMap; -}; - - - -class GPDScorerThirdStageEnergy : public G4VPrimitiveScorer -{ -public: // with description - GPDScorerThirdStageEnergy(G4String name, G4String volumeName, G4int depth = 0); - virtual ~GPDScorerThirdStageEnergy(); - -protected: // with description - virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); - -public: - virtual void Initialize(G4HCofThisEvent*); - virtual void EndOfEvent(G4HCofThisEvent*); - virtual void clear(); - virtual void DrawAll(); - virtual void PrintAll(); - -private: - G4String m_VolumeName; - G4int HCID; - G4THitsMap<G4double>* EvtMap; -}; - - - - -class GPDScorerFirstStageFrontStripDummyShape : public G4VPrimitiveScorer -{ -public: // with description - GPDScorerFirstStageFrontStripDummyShape(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); - virtual ~GPDScorerFirstStageFrontStripDummyShape(); - -protected: // with description - virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); - -public: - virtual void Initialize(G4HCofThisEvent*); - virtual void EndOfEvent(G4HCofThisEvent*); - virtual void clear(); - virtual void DrawAll(); - virtual void PrintAll(); - -private: - G4int m_NumberOfStrip ; - G4int HCID; - G4THitsMap<G4int>* EvtMap; -}; - - - -class GPDScorerFirstStageBackStripDummyShape : public G4VPrimitiveScorer -{ -public: // with description - GPDScorerFirstStageBackStripDummyShape(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); - virtual ~GPDScorerFirstStageBackStripDummyShape(); - -protected: // with description - virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); - -public: - virtual void Initialize(G4HCofThisEvent*); - virtual void EndOfEvent(G4HCofThisEvent*); - virtual void clear(); - virtual void DrawAll(); - virtual void PrintAll(); - -private: - G4int m_NumberOfStrip ; - G4int HCID; - G4THitsMap<G4int>* EvtMap; -}; - - - -class GPDScorerFirstStageFrontStripSquare : public G4VPrimitiveScorer -{ -public: // with description - GPDScorerFirstStageFrontStripSquare(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); - virtual ~GPDScorerFirstStageFrontStripSquare(); - -protected: // with description - virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); - -public: - virtual void Initialize(G4HCofThisEvent*); - virtual void EndOfEvent(G4HCofThisEvent*); - virtual void clear(); - virtual void DrawAll(); - virtual void PrintAll(); - -private: - G4int m_NumberOfStrip ; - G4int HCID; - G4THitsMap<G4int>* EvtMap; -}; - - - -class GPDScorerFirstStageBackStripSquare : public G4VPrimitiveScorer -{ -public: // with description - GPDScorerFirstStageBackStripSquare(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); - virtual ~GPDScorerFirstStageBackStripSquare(); - -protected: // with description - virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); - -public: - virtual void Initialize(G4HCofThisEvent*); - virtual void EndOfEvent(G4HCofThisEvent*); - virtual void clear(); - virtual void DrawAll(); - virtual void PrintAll(); - -private: - G4int m_NumberOfStrip ; - G4int HCID; - G4THitsMap<G4int>* EvtMap; -}; - - - -class GPDScorerFirstStageFrontStripTrapezoid : public G4VPrimitiveScorer -{ -public: // with description - GPDScorerFirstStageFrontStripTrapezoid(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); - virtual ~GPDScorerFirstStageFrontStripTrapezoid(); - -protected: // with description - virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); - -public: - virtual void Initialize(G4HCofThisEvent*); - virtual void EndOfEvent(G4HCofThisEvent*); - virtual void clear(); - virtual void DrawAll(); - virtual void PrintAll(); - -private: - G4int m_NumberOfStrip ; - G4int HCID; - G4THitsMap<G4int>* EvtMap; -}; - - - -class GPDScorerFirstStageBackStripTrapezoid : public G4VPrimitiveScorer -{ -public: // with description - GPDScorerFirstStageBackStripTrapezoid(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); - virtual ~GPDScorerFirstStageBackStripTrapezoid(); - -protected: // with description - virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); - -public: - virtual void Initialize(G4HCofThisEvent*); - virtual void EndOfEvent(G4HCofThisEvent*); - virtual void clear(); - virtual void DrawAll(); - virtual void PrintAll(); - -private: - G4int m_NumberOfStrip ; - G4int HCID; - G4THitsMap<G4int>* EvtMap; -}; - - - -class GPDScorerFirstStageFrontStripAnnular : public G4VPrimitiveScorer -{ -public: // with description - GPDScorerFirstStageFrontStripAnnular(G4String name, G4int depth = 0, G4double StripPlaneSize = 98, G4int NumberOfStrip = 128); - virtual ~GPDScorerFirstStageFrontStripAnnular(); - -protected: // with description - virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); - -public: - virtual void Initialize(G4HCofThisEvent*); - virtual void EndOfEvent(G4HCofThisEvent*); - virtual void clear(); - virtual void DrawAll(); - virtual void PrintAll(); - -private: - G4double m_StripPlaneSize; - G4int m_NumberOfStrip ; - G4int HCID; - G4THitsMap<G4int>* EvtMap; -}; - - - -class GPDScorerFirstStageBackStripAnnular : public G4VPrimitiveScorer -{ -public: // with description - GPDScorerFirstStageBackStripAnnular(G4String name, G4int depth = 0, G4double StripPlaneSize = 98, G4int NumberOfStrip = 128); - virtual ~GPDScorerFirstStageBackStripAnnular(); - -protected: // with description - virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); - -public: - virtual void Initialize(G4HCofThisEvent*); - virtual void EndOfEvent(G4HCofThisEvent*); - virtual void clear(); - virtual void DrawAll(); - virtual void PrintAll(); - -private: - G4double m_StripPlaneSize; - G4int m_NumberOfStrip ; - G4int HCID; - G4THitsMap<G4int>* EvtMap; -}; - -} +#include "G4VPrimitiveScorer.hh" +using namespace CLHEP; +namespace GPDSCORERS { + // This Threshold is used in all scorers + // Any energy deposit under this threshold will not create an entry + const double TriggerThreshold = 0.1 * keV; + + class GPDScorerFirstStageEnergy : public G4VPrimitiveScorer { + public: // with description + GPDScorerFirstStageEnergy(G4String name, G4String volumeName, G4int depth = 0); + virtual ~GPDScorerFirstStageEnergy(); + + protected: // with description + virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); + + public: + virtual void Initialize(G4HCofThisEvent*); + virtual void EndOfEvent(G4HCofThisEvent*); + virtual void clear(); + virtual void DrawAll(); + virtual void PrintAll(); + + private: + G4String m_VolumeName; + G4int HCID; + G4THitsMap<G4double>* EvtMap; + }; + + class GPDScorerSecondStageEnergy : public G4VPrimitiveScorer { + public: // with description + GPDScorerSecondStageEnergy(G4String name, G4String volumeName, G4int depth = 0); + virtual ~GPDScorerSecondStageEnergy(); + + protected: // with description + virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); + + public: + virtual void Initialize(G4HCofThisEvent*); + virtual void EndOfEvent(G4HCofThisEvent*); + virtual void clear(); + virtual void DrawAll(); + virtual void PrintAll(); + + private: + G4String m_VolumeName; + G4int HCID; + G4THitsMap<G4double>* EvtMap; + }; + + class GPDScorerThirdStageEnergy : public G4VPrimitiveScorer { + public: // with description + GPDScorerThirdStageEnergy(G4String name, G4String volumeName, G4int depth = 0); + virtual ~GPDScorerThirdStageEnergy(); + + protected: // with description + virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); + + public: + virtual void Initialize(G4HCofThisEvent*); + virtual void EndOfEvent(G4HCofThisEvent*); + virtual void clear(); + virtual void DrawAll(); + virtual void PrintAll(); + + private: + G4String m_VolumeName; + G4int HCID; + G4THitsMap<G4double>* EvtMap; + }; + + class GPDScorerFirstStageFrontStripDummyShape : public G4VPrimitiveScorer { + public: // with description + GPDScorerFirstStageFrontStripDummyShape(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); + virtual ~GPDScorerFirstStageFrontStripDummyShape(); + + protected: // with description + virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); + + public: + virtual void Initialize(G4HCofThisEvent*); + virtual void EndOfEvent(G4HCofThisEvent*); + virtual void clear(); + virtual void DrawAll(); + virtual void PrintAll(); + + private: + G4int m_NumberOfStrip; + G4int HCID; + G4THitsMap<G4int>* EvtMap; + }; + + class GPDScorerFirstStageBackStripDummyShape : public G4VPrimitiveScorer { + public: // with description + GPDScorerFirstStageBackStripDummyShape(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); + virtual ~GPDScorerFirstStageBackStripDummyShape(); + + protected: // with description + virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); + + public: + virtual void Initialize(G4HCofThisEvent*); + virtual void EndOfEvent(G4HCofThisEvent*); + virtual void clear(); + virtual void DrawAll(); + virtual void PrintAll(); + + private: + G4int m_NumberOfStrip; + G4int HCID; + G4THitsMap<G4int>* EvtMap; + }; + + class GPDScorerFirstStageFrontStripSquare : public G4VPrimitiveScorer { + public: // with description + GPDScorerFirstStageFrontStripSquare(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); + virtual ~GPDScorerFirstStageFrontStripSquare(); + + protected: // with description + virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); + + public: + virtual void Initialize(G4HCofThisEvent*); + virtual void EndOfEvent(G4HCofThisEvent*); + virtual void clear(); + virtual void DrawAll(); + virtual void PrintAll(); + + private: + G4int m_NumberOfStrip; + G4int HCID; + G4THitsMap<G4int>* EvtMap; + }; + + class GPDScorerFirstStageBackStripSquare : public G4VPrimitiveScorer { + public: // with description + GPDScorerFirstStageBackStripSquare(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); + virtual ~GPDScorerFirstStageBackStripSquare(); + + protected: // with description + virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); + + public: + virtual void Initialize(G4HCofThisEvent*); + virtual void EndOfEvent(G4HCofThisEvent*); + virtual void clear(); + virtual void DrawAll(); + virtual void PrintAll(); + + private: + G4int m_NumberOfStrip; + G4int HCID; + G4THitsMap<G4int>* EvtMap; + }; + + class GPDScorerFirstStageFrontStripTrapezoid : public G4VPrimitiveScorer { + public: // with description + GPDScorerFirstStageFrontStripTrapezoid(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); + virtual ~GPDScorerFirstStageFrontStripTrapezoid(); + + protected: // with description + virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); + + public: + virtual void Initialize(G4HCofThisEvent*); + virtual void EndOfEvent(G4HCofThisEvent*); + virtual void clear(); + virtual void DrawAll(); + virtual void PrintAll(); + + private: + G4int m_NumberOfStrip; + G4int HCID; + G4THitsMap<G4int>* EvtMap; + }; + + class GPDScorerFirstStageBackStripTrapezoid : public G4VPrimitiveScorer { + public: // with description + GPDScorerFirstStageBackStripTrapezoid(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); + virtual ~GPDScorerFirstStageBackStripTrapezoid(); + + protected: // with description + virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); + + public: + virtual void Initialize(G4HCofThisEvent*); + virtual void EndOfEvent(G4HCofThisEvent*); + virtual void clear(); + virtual void DrawAll(); + virtual void PrintAll(); + + private: + G4int m_NumberOfStrip; + G4int HCID; + G4THitsMap<G4int>* EvtMap; + }; + + class GPDScorerFirstStageFrontStripAnnular : public G4VPrimitiveScorer { + public: // with description + GPDScorerFirstStageFrontStripAnnular(G4String name, G4int depth = 0, G4double StripPlaneSize = 98, + G4int NumberOfStrip = 128); + virtual ~GPDScorerFirstStageFrontStripAnnular(); + + protected: // with description + virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); + + public: + virtual void Initialize(G4HCofThisEvent*); + virtual void EndOfEvent(G4HCofThisEvent*); + virtual void clear(); + virtual void DrawAll(); + virtual void PrintAll(); + + private: + G4double m_StripPlaneSize; + G4int m_NumberOfStrip; + G4int HCID; + G4THitsMap<G4int>* EvtMap; + }; + + class GPDScorerFirstStageBackStripAnnular : public G4VPrimitiveScorer { + public: // with description + GPDScorerFirstStageBackStripAnnular(G4String name, G4int depth = 0, G4double StripPlaneSize = 98, + G4int NumberOfStrip = 128); + virtual ~GPDScorerFirstStageBackStripAnnular(); + + protected: // with description + virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); + + public: + virtual void Initialize(G4HCofThisEvent*); + virtual void EndOfEvent(G4HCofThisEvent*); + virtual void clear(); + virtual void DrawAll(); + virtual void PrintAll(); + + private: + G4double m_StripPlaneSize; + G4int m_NumberOfStrip; + G4int HCID; + G4THitsMap<G4int>* EvtMap; + }; + +} // namespace GPDSCORERS #endif diff --git a/NPSimulation/Detectors/GASPARD/GaspardTrackerAnnular.cc b/NPSimulation/Detectors/GASPARD/GaspardTrackerAnnular.cc index b519cf882..0ecf72d27 100644 --- a/NPSimulation/Detectors/GASPARD/GaspardTrackerAnnular.cc +++ b/NPSimulation/Detectors/GASPARD/GaspardTrackerAnnular.cc @@ -23,37 +23,37 @@ *****************************************************************************/ // C++ headers +#include <cmath> #include <sstream> #include <string> -#include <cmath> // G4 Geometry headers #include "G4Box.hh" #include "G4Tubs.hh" // G4 various headers -#include "G4MaterialTable.hh" +#include "G4Colour.hh" #include "G4Element.hh" #include "G4ElementTable.hh" -#include "G4VisAttributes.hh" -#include "G4Colour.hh" +#include "G4MaterialTable.hh" +#include "G4PVDivision.hh" +#include "G4PVPlacement.hh" #include "G4RotationMatrix.hh" #include "G4Transform3D.hh" -#include "G4PVPlacement.hh" -#include "G4PVDivision.hh" +#include "G4VisAttributes.hh" // G4 sensitive -#include "G4SDManager.hh" #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" // NPTool headers #include "GaspardTrackerAnnular.hh" #include "ObsoleteGeneralScorers.hh" //#include "GaspardScorers.hh" +#include "NPSVDetector.hh" +#include "RootOutput.h" #include "SiliconScorers.hh" #include "TGaspardTrackerData.h" -#include "RootOutput.h" -#include "NPSVDetector.hh" // CLHEP #include "CLHEP/Random/RandGauss.h" @@ -61,511 +61,437 @@ using namespace std; using namespace CLHEP; using namespace GPDANNULAR; -//using namespace GPDSCORERS; +// using namespace GPDSCORERS; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -GaspardTrackerAnnular::GaspardTrackerAnnular() -{ - ms_InterCoord = 0; -} - - +GaspardTrackerAnnular::GaspardTrackerAnnular() { ms_InterCoord = 0; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -GaspardTrackerAnnular::~GaspardTrackerAnnular() -{ -} - - +GaspardTrackerAnnular::~GaspardTrackerAnnular() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void GaspardTrackerAnnular::AddModule(G4double PosZ, - G4double Rmin, - G4double Rmax, - bool wFirstStage, - bool wSecondStage, - bool wThirdStage) -{ - m_FirstStagePosZ.push_back(PosZ); - m_FirstStageRmin.push_back(Rmin); - m_FirstStageRmax.push_back(Rmax); - - m_wFirstStage.push_back(wFirstStage) ; - m_wSecondStage.push_back(wSecondStage) ; - m_wThirdStage.push_back(wThirdStage) ; +void GaspardTrackerAnnular::AddModule(G4double PosZ, G4double Rmin, G4double Rmax, bool wFirstStage, bool wSecondStage, + bool wThirdStage) { + m_FirstStagePosZ.push_back(PosZ); + m_FirstStageRmin.push_back(Rmin); + m_FirstStageRmax.push_back(Rmax); + + m_wFirstStage.push_back(wFirstStage); + m_wSecondStage.push_back(wSecondStage); + m_wThirdStage.push_back(wThirdStage); } +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void GaspardTrackerAnnular::VolumeMaker(G4int DetectorNumber, G4ThreeVector MMpos, G4RotationMatrix* MMrot, + bool wFirstStage, bool wSecondStage, bool wThirdStage, G4LogicalVolume* world) { + G4double TelNbr = DetectorNumber; + G4String DetNumber; + ostringstream Number; + Number << TelNbr; + DetNumber = Number.str(); + cout << "FF DetectorNumber: " << DetectorNumber << endl; + cout << "FF m_FSRmin[DetecNbr-1]: " << m_FirstStageRmin[DetectorNumber - 1] << endl; + cout << "FF m_FSRmax[DetecNbr-1]: " << m_FirstStageRmax[DetectorNumber - 1] << endl; + + //////////////////////////////////////////////////////////////// + ////////////// Starting Volume Definition ////////////////////// + //////////////////////////////////////////////////////////////// + // Name of the module + G4String Name = "GPDAnnular" + DetNumber; -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void GaspardTrackerAnnular::VolumeMaker(G4int DetectorNumber, - G4ThreeVector MMpos, - G4RotationMatrix* MMrot, - bool wFirstStage, - bool wSecondStage, - bool wThirdStage, - G4LogicalVolume* world) -{ - G4double TelNbr = DetectorNumber ; - G4String DetNumber ; - ostringstream Number ; - Number << TelNbr ; - DetNumber = Number.str() ; - - cout<<"FF DetectorNumber: "<<DetectorNumber<<endl; - cout<<"FF m_FSRmin[DetecNbr-1]: "<<m_FirstStageRmin[DetectorNumber-1]<<endl; - cout<<"FF m_FSRmax[DetecNbr-1]: "<<m_FirstStageRmax[DetectorNumber-1]<<endl; - - //////////////////////////////////////////////////////////////// - ////////////// Starting Volume Definition ////////////////////// - //////////////////////////////////////////////////////////////// - // Name of the module - G4String Name = "GPDAnnular" + DetNumber; - - // Definition of the volume containing the sensitive detector - G4Tubs* solidMM = new G4Tubs(Name, - LogicRmin, - LogicRmax, - LogicLength/2, - 0*deg, - 360*deg); - - G4LogicalVolume* logicMM = new G4LogicalVolume(solidMM, m_MaterialVacuum, Name, 0, 0, 0); - - new G4PVPlacement(G4Transform3D(*MMrot, MMpos), logicMM, Name, world, false, DetectorNumber); - - logicMM->SetVisAttributes(G4VisAttributes::Invisible); - if (m_non_sensitive_part_visiualisation){ - G4VisAttributes VisAtt(G4Colour(0.90, 0.90, 0.90)); - VisAtt.SetForceWireframe(true); - logicMM->SetVisAttributes(VisAtt); - } - // Definition of a vaccuum volume - G4ThreeVector positionVacBox = G4ThreeVector(0, 0, VacBox_PosZ); - - G4Tubs* solidVacBox = new G4Tubs("solidVacBox", - m_FirstStageRmin[DetectorNumber-1], - m_FirstStageRmax[DetectorNumber-1], - VacBoxThickness/2, - 0*deg, - 360*deg); - - G4LogicalVolume* logicVacBox = new G4LogicalVolume(solidVacBox, m_MaterialVacuum, "logicVacBox", 0, 0, 0); - - G4PVPlacement(0, positionVacBox, logicVacBox, "G" + DetNumber + "VacBox", logicMM, false, DetectorNumber); - - logicVacBox->SetVisAttributes(G4VisAttributes::Invisible); - - //////////////////////////////////////////////////////////////// - /////////////////// First Stage Construction//////////////////// - //////////////////////////////////////////////////////////////// - if (wFirstStage) { - // Aluminium dead layers - G4ThreeVector positionAluStripFront = G4ThreeVector(0, 0, AluStripFront_PosZ); - G4ThreeVector positionAluStripBack = G4ThreeVector(0, 0, AluStripBack_PosZ); - - G4Tubs* solidAluStrip = new G4Tubs("AluBox", - m_FirstStageRmin[DetectorNumber-1], - m_FirstStageRmax[DetectorNumber-1], - AluStripThickness/2, - 0*deg, - 360*deg); - -// G4LogicalVolume* logicAluStrip = new G4LogicalVolume(solidAluStrip, Aluminium, "logicAluStrip", 0, 0, 0); - G4LogicalVolume* logicAluStrip = new G4LogicalVolume(solidAluStrip, m_MaterialVacuum, "logicAluStrip", 0, 0, 0); - - new G4PVPlacement(0, positionAluStripFront, logicAluStrip, "G" + DetNumber + "AluStripFront", logicMM, false, DetectorNumber); - new G4PVPlacement(0, positionAluStripBack, logicAluStrip, "G" + DetNumber + "AluStripBack", logicMM, false, DetectorNumber); - - logicAluStrip->SetVisAttributes(G4VisAttributes::Invisible); - - // Silicon detector itself - G4ThreeVector positionSilicon = G4ThreeVector(0, 0, Silicon_PosZ); - - G4Tubs* solidSilicon = new G4Tubs("solidSilicon", - m_FirstStageRmin[DetectorNumber-1], - m_FirstStageRmax[DetectorNumber-1], - FirstStageThickness/2, - 0*deg, - 360*deg); - G4LogicalVolume* logicSilicon = new G4LogicalVolume(solidSilicon, m_MaterialSilicon, "logicSilicon", 0, 0, 0); - - new G4PVPlacement(0, positionSilicon, logicSilicon, Name + "_Silicon", logicMM, false, DetectorNumber); - - // Set First Stage sensible - logicSilicon->SetSensitiveDetector(m_FirstStageScorer); - - ///Visualisation of Silicon Strip - G4VisAttributes* SiliconVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)) ; // blue - logicSilicon->SetVisAttributes(SiliconVisAtt) ; - } - - //////////////////////////////////////////////////////////////// - //////////////// Second Stage Construction //////////////////// - //////////////////////////////////////////////////////////////// - if (wSecondStage) { - // Second stage silicon detector - G4ThreeVector positionSecondStage = G4ThreeVector(0, 0, SecondStage_PosZ); - - G4Tubs* solidSecondStage = new G4Tubs("solidSecondStage", - m_FirstStageRmin[DetectorNumber-1], - m_FirstStageRmax[DetectorNumber-1], - SecondStageThickness/2, - 0*deg, - 360*deg); - - G4LogicalVolume* logicSecondStage = new G4LogicalVolume(solidSecondStage, m_MaterialSilicon, "logicSecondStage", 0, 0, 0); - - new G4PVPlacement(0, positionSecondStage, logicSecondStage, Name + "_SecondStage", logicMM, false, 0); - - ///Visualisation of Second Stage - G4VisAttributes* SecondStageVisAtt = new G4VisAttributes(G4Colour(0.9, 0, 0)); // red - logicSecondStage->SetVisAttributes(SecondStageVisAtt); - - // Set Second Stage sensible - logicSecondStage->SetSensitiveDetector(m_SecondStageScorer); - } - - //////////////////////////////////////////////////////////////// - ///////////////// Third Stage Construction ///////////////////// - //////////////////////////////////////////////////////////////// - if (wThirdStage) { - // Third stage silicon detector - G4ThreeVector positionThirdStage = G4ThreeVector(0, 0, ThirdStage_PosZ); - - G4Tubs* solidThirdStage = new G4Tubs("solidThirdStage", - m_FirstStageRmin[DetectorNumber-1], - m_FirstStageRmax[DetectorNumber-1], - ThirdStageThickness/2, - 0*deg, - 360*deg); - - G4LogicalVolume* logicThirdStage = new G4LogicalVolume(solidThirdStage, m_MaterialSilicon, "logicThirdStage", 0, 0, 0); - - new G4PVPlacement(0, positionThirdStage, logicThirdStage, Name + "_ThirdStage", logicMM, false, 0); - - ///Visualisation of Third Stage - G4VisAttributes* ThirdStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.)) ; // green - logicThirdStage->SetVisAttributes(ThirdStageVisAtt) ; - - // Set Third Stage sensible - logicThirdStage->SetSensitiveDetector(m_ThirdStageScorer); - } -} + // Definition of the volume containing the sensitive detector + G4Tubs* solidMM = new G4Tubs(Name, LogicRmin, LogicRmax, LogicLength / 2, 0 * deg, 360 * deg); -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -// Virtual Method of NPS::VDetector class + G4LogicalVolume* logicMM = new G4LogicalVolume(solidMM, m_MaterialVacuum, Name, 0, 0, 0); -// Read stream at Configfile to pick-up parameters of detector (Position,...) -// Called in DetecorConstruction::ReadDetextorConfiguration Method -void GaspardTrackerAnnular::ReadConfiguration(NPL::InputParser parser){ - vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("GaspardTracker"); - vector<string> tokenp= {"Z","RMIN","RMAX"}; + new G4PVPlacement(G4Transform3D(*MMrot, MMpos), logicMM, Name, world, false, DetectorNumber); - vector<string> token={"FIRSTSTAGE","SECONDSTAGE","THIRDSTAGE"}; + logicMM->SetVisAttributes(G4VisAttributes::GetInvisible()); + if (m_non_sensitive_part_visiualisation) { + G4VisAttributes VisAtt(G4Colour(0.90, 0.90, 0.90)); + VisAtt.SetForceWireframe(true); + logicMM->SetVisAttributes(VisAtt); + } + // Definition of a vaccuum volume + G4ThreeVector positionVacBox = G4ThreeVector(0, 0, VacBox_PosZ); - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->GetMainValue() == "Annular" && blocks[i]->HasTokenList(token) ){ - cout << "Gaspard Annular " << i+1 << ":" << endl; + G4Tubs* solidVacBox = new G4Tubs("solidVacBox", m_FirstStageRmin[DetectorNumber - 1], + m_FirstStageRmax[DetectorNumber - 1], VacBoxThickness / 2, 0 * deg, 360 * deg); - bool first = blocks[i]->GetInt("FIRSTSTAGE"); - bool second = blocks[i]->GetInt("SECONDSTAGE"); - bool third = blocks[i]->GetInt("THIRDSTAGE"); - m_non_sensitive_part_visiualisation = blocks[i]->GetInt("VIS"); - if(blocks[i]->HasTokenList(tokenp)){ - // Add module - double Z = blocks[i]->GetDouble("Z","mm"); - double Rmin = blocks[i]->GetDouble("Rmin","mm"); - double Rmax = blocks[i]->GetDouble("Rmax","mm"); - AddModule(Z,Rmin,Rmax,first,second,third); - } - else{ - cout << "ERROR: Check input formatting for Gaspard" << endl; - exit(1); - } - } - } -} + G4LogicalVolume* logicVacBox = new G4LogicalVolume(solidVacBox, m_MaterialVacuum, "logicVacBox", 0, 0, 0); -// Construct detector and inialise sensitive part. -// Called After DetecorConstruction::AddDetector Method -void GaspardTrackerAnnular::ConstructDetector(G4LogicalVolume* world) -{ - G4RotationMatrix* MMrot = NULL ; - G4ThreeVector MMpos = G4ThreeVector(0, 0, 0) ; - - bool FirstStage = true ; - bool SecondStage = true ; - bool ThirdStage = true ; - - G4int NumberOfModule = m_FirstStagePosZ.size() ; - - for (G4int i = 0; i < NumberOfModule; i++) { - // translation to position the module - // test if module is in the forward or backward hemisphere - (m_FirstStagePosZ[i] < 0) ? m_FirstStagePosZ[i] -= 0.5*LogicLength : m_FirstStagePosZ[i] += 0.5*LogicLength; - MMpos = G4ThreeVector(0, 0, m_FirstStagePosZ[i]); - - // Passage Matrix from Lab Referential to Module Referential - // Identity matrix by default - MMrot = new G4RotationMatrix(); - if (MMpos.z() < 0) MMrot->rotateX(180*deg); - - // Presence of 1st, 2nd and 3rd stage - FirstStage = m_wFirstStage[i] ; - SecondStage = m_wSecondStage[i] ; - ThirdStage = m_wThirdStage[i] ; - - // Build geometry and declare scorers - VolumeMaker(i + 1, MMpos, MMrot, FirstStage, SecondStage, ThirdStage , world); - } - - delete MMrot ; -} + G4PVPlacement(0, positionVacBox, logicVacBox, "G" + DetNumber + "VacBox", logicMM, false, DetectorNumber); + logicVacBox->SetVisAttributes(G4VisAttributes::GetInvisible()); + //////////////////////////////////////////////////////////////// + /////////////////// First Stage Construction//////////////////// + //////////////////////////////////////////////////////////////// + if (wFirstStage) { + // Aluminium dead layers + G4ThreeVector positionAluStripFront = G4ThreeVector(0, 0, AluStripFront_PosZ); + G4ThreeVector positionAluStripBack = G4ThreeVector(0, 0, AluStripBack_PosZ); -// Connect the GaspardTrackingData class to the output TTree -// of the simulation -void GaspardTrackerAnnular::InitializeRootOutput() -{ -} + G4Tubs* solidAluStrip = new G4Tubs("AluBox", m_FirstStageRmin[DetectorNumber - 1], + m_FirstStageRmax[DetectorNumber - 1], AluStripThickness / 2, 0 * deg, 360 * deg); + // G4LogicalVolume* logicAluStrip = new G4LogicalVolume(solidAluStrip, Aluminium, "logicAluStrip", 0, 0, 0); + G4LogicalVolume* logicAluStrip = new G4LogicalVolume(solidAluStrip, m_MaterialVacuum, "logicAluStrip", 0, 0, 0); + new G4PVPlacement(0, positionAluStripFront, logicAluStrip, "G" + DetNumber + "AluStripFront", logicMM, false, + DetectorNumber); + new G4PVPlacement(0, positionAluStripBack, logicAluStrip, "G" + DetNumber + "AluStripBack", logicMM, false, + DetectorNumber); -// Set the TinteractionCoordinates object from NPS::VDetector to the present class -void GaspardTrackerAnnular::SetInterCoordPointer(TInteractionCoordinates* interCoord) -{ - ms_InterCoord = interCoord; -} + logicAluStrip->SetVisAttributes(G4VisAttributes::GetInvisible()); + // Silicon detector itself + G4ThreeVector positionSilicon = G4ThreeVector(0, 0, Silicon_PosZ); + G4Tubs* solidSilicon = + new G4Tubs("solidSilicon", m_FirstStageRmin[DetectorNumber - 1], m_FirstStageRmax[DetectorNumber - 1], + FirstStageThickness / 2, 0 * deg, 360 * deg); + G4LogicalVolume* logicSilicon = new G4LogicalVolume(solidSilicon, m_MaterialSilicon, "logicSilicon", 0, 0, 0); -// Read sensitive part and fill the Root tree. -// Called at in the EventAction::EndOfEventAvtion -void GaspardTrackerAnnular::ReadSensitive(const G4Event* event) -{ - ////////////// - // First stage - NPS::HitsMap<G4double*>* GPD1HitMap; - std::map<G4int, G4double**>::iterator GPD1_itr; - - G4int GPD1CollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDAnnular/GPDAnnularFirstStage"); - GPD1HitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(GPD1CollectionID)); - - // Loop on the GPD map - for (GPD1_itr = GPD1HitMap->GetMap()->begin(); GPD1_itr != GPD1HitMap->GetMap()->end(); GPD1_itr++) { - G4double* Info = *(GPD1_itr->second); - - double Energy = Info[0]; - if (Energy > EnergyThreshold) { - double Time = Info[1]; - int DetNbr = (int) Info[7]; - int StripFront = (int) Info[8]; - int StripBack = (int) Info[9]; - - // detector number - ms_Event->SetGPDTrkFirstStageFrontEDetectorNbr(m_index["Annular"] + DetNbr); - ms_Event->SetGPDTrkFirstStageFrontTDetectorNbr(m_index["Annular"] + DetNbr); - ms_Event->SetGPDTrkFirstStageBackEDetectorNbr(m_index["Annular"] + DetNbr); - ms_Event->SetGPDTrkFirstStageBackTDetectorNbr(m_index["Annular"] + DetNbr); - - // energy - ms_Event->SetGPDTrkFirstStageFrontEEnergy(RandGauss::shoot(Energy, ResoFirstStage)); - ms_Event->SetGPDTrkFirstStageBackEEnergy(RandGauss::shoot(Energy, ResoFirstStage)); - - // time - Time = RandGauss::shoot(Time, ResoTimePPAC); - ms_Event->SetGPDTrkFirstStageFrontTTime(RandGauss::shoot(Time, ResoTimeGpd)); - ms_Event->SetGPDTrkFirstStageBackTTime(RandGauss::shoot(Time, ResoTimeGpd)); - - // strips X and Y - ms_Event->SetGPDTrkFirstStageFrontEStripNbr(StripFront); - ms_Event->SetGPDTrkFirstStageFrontTStripNbr(StripFront); - ms_Event->SetGPDTrkFirstStageBackEStripNbr(StripBack); - ms_Event->SetGPDTrkFirstStageBackTStripNbr(StripBack); - - // Interaction Coordinates - ms_InterCoord->SetDetectedPositionX(Info[2]); - ms_InterCoord->SetDetectedPositionY(Info[3]); - ms_InterCoord->SetDetectedPositionZ(Info[4]); - ms_InterCoord->SetDetectedAngleTheta(Info[5]/deg); - ms_InterCoord->SetDetectedAnglePhi(Info[6]/deg); + new G4PVPlacement(0, positionSilicon, logicSilicon, Name + "_Silicon", logicMM, false, DetectorNumber); - } - } - // clear map for next event - GPD1HitMap->clear(); + // Set First Stage sensible + logicSilicon->SetSensitiveDetector(m_FirstStageScorer); + /// Visualisation of Silicon Strip + G4VisAttributes* SiliconVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)); // blue + logicSilicon->SetVisAttributes(SiliconVisAtt); + } - ////////////// - // Second stage - NPS::HitsMap<G4double*>* GPD2HitMap; - std::map<G4int, G4double**>::iterator GPD2_itr; + //////////////////////////////////////////////////////////////// + //////////////// Second Stage Construction //////////////////// + //////////////////////////////////////////////////////////////// + if (wSecondStage) { + // Second stage silicon detector + G4ThreeVector positionSecondStage = G4ThreeVector(0, 0, SecondStage_PosZ); - G4int GPD2CollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("SecondStageScorerGPDAnnular/GPDAnnularSecondStage"); - GPD2HitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(GPD2CollectionID)); + G4Tubs* solidSecondStage = + new G4Tubs("solidSecondStage", m_FirstStageRmin[DetectorNumber - 1], m_FirstStageRmax[DetectorNumber - 1], + SecondStageThickness / 2, 0 * deg, 360 * deg); - // Loop on the GPD map - for (GPD2_itr = GPD2HitMap->GetMap()->begin(); GPD2_itr != GPD2HitMap->GetMap()->end(); GPD2_itr++) { - G4double* Info = *(GPD2_itr->second); + G4LogicalVolume* logicSecondStage = + new G4LogicalVolume(solidSecondStage, m_MaterialSilicon, "logicSecondStage", 0, 0, 0); - double Energy = Info[0]; - if (Energy > EnergyThreshold) { - double Time = Info[1]; - int DetNbr = (int) Info[7]; - int StripFront = (int) Info[8]; + new G4PVPlacement(0, positionSecondStage, logicSecondStage, Name + "_SecondStage", logicMM, false, 0); - // detector number - ms_Event->SetGPDTrkSecondStageEDetectorNbr(m_index["Annular"] + DetNbr); - ms_Event->SetGPDTrkSecondStageTDetectorNbr(m_index["Annular"] + DetNbr); + /// Visualisation of Second Stage + G4VisAttributes* SecondStageVisAtt = new G4VisAttributes(G4Colour(0.9, 0, 0)); // red + logicSecondStage->SetVisAttributes(SecondStageVisAtt); - // energy - ms_Event->SetGPDTrkSecondStageEEnergy(RandGauss::shoot(Energy, ResoSecondStage)); + // Set Second Stage sensible + logicSecondStage->SetSensitiveDetector(m_SecondStageScorer); + } - // time - Time = RandGauss::shoot(Time, ResoTimePPAC); - ms_Event->SetGPDTrkSecondStageTTime(RandGauss::shoot(Time, ResoTimeGpd)); + //////////////////////////////////////////////////////////////// + ///////////////// Third Stage Construction ///////////////////// + //////////////////////////////////////////////////////////////// + if (wThirdStage) { + // Third stage silicon detector + G4ThreeVector positionThirdStage = G4ThreeVector(0, 0, ThirdStage_PosZ); - // strips X and Y - ms_Event->SetGPDTrkSecondStageEPadNbr(StripFront); - ms_Event->SetGPDTrkSecondStageTPadNbr(StripFront); - } - } - // clear map for next event - GPD2HitMap->clear(); + G4Tubs* solidThirdStage = + new G4Tubs("solidThirdStage", m_FirstStageRmin[DetectorNumber - 1], m_FirstStageRmax[DetectorNumber - 1], + ThirdStageThickness / 2, 0 * deg, 360 * deg); + G4LogicalVolume* logicThirdStage = + new G4LogicalVolume(solidThirdStage, m_MaterialSilicon, "logicThirdStage", 0, 0, 0); - ////////////// - // Third stage - NPS::HitsMap<G4double*>* GPD3HitMap; - std::map<G4int, G4double**>::iterator GPD3_itr; + new G4PVPlacement(0, positionThirdStage, logicThirdStage, Name + "_ThirdStage", logicMM, false, 0); - G4int GPD3CollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ThirdStageScorerGPDAnnular/GPDAnnularThirdStage"); - GPD3HitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(GPD3CollectionID)); + /// Visualisation of Third Stage + G4VisAttributes* ThirdStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.)); // green + logicThirdStage->SetVisAttributes(ThirdStageVisAtt); - // Loop on the GPD map - for (GPD3_itr = GPD3HitMap->GetMap()->begin(); GPD3_itr != GPD3HitMap->GetMap()->end(); GPD3_itr++) { - G4double* Info = *(GPD3_itr->second); + // Set Third Stage sensible + logicThirdStage->SetSensitiveDetector(m_ThirdStageScorer); + } +} - double Energy = Info[0]; - if (Energy > EnergyThreshold) { - double Time = Info[1]; - int DetNbr = (int) Info[7]; - int StripFront = (int) Info[8]; +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// Virtual Method of NPS::VDetector class - // detector number - ms_Event->SetGPDTrkThirdStageEDetectorNbr(m_index["Annular"] + DetNbr); - ms_Event->SetGPDTrkThirdStageTDetectorNbr(m_index["Annular"] + DetNbr); +// Read stream at Configfile to pick-up parameters of detector (Position,...) +// Called in DetecorConstruction::ReadDetextorConfiguration Method +void GaspardTrackerAnnular::ReadConfiguration(NPL::InputParser parser) { + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("GaspardTracker"); + vector<string> tokenp = {"Z", "RMIN", "RMAX"}; - // energy - ms_Event->SetGPDTrkThirdStageEEnergy(RandGauss::shoot(Energy, ResoThirdStage)); + vector<string> token = {"FIRSTSTAGE", "SECONDSTAGE", "THIRDSTAGE"}; - // time - Time = RandGauss::shoot(Time, ResoTimePPAC); - ms_Event->SetGPDTrkThirdStageTTime(RandGauss::shoot(Time, ResoTimeGpd)); + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->GetMainValue() == "Annular" && blocks[i]->HasTokenList(token)) { + cout << "Gaspard Annular " << i + 1 << ":" << endl; - // strips X and Y - ms_Event->SetGPDTrkThirdStageEPadNbr(StripFront); - ms_Event->SetGPDTrkThirdStageTPadNbr(StripFront); + bool first = blocks[i]->GetInt("FIRSTSTAGE"); + bool second = blocks[i]->GetInt("SECONDSTAGE"); + bool third = blocks[i]->GetInt("THIRDSTAGE"); + m_non_sensitive_part_visiualisation = blocks[i]->GetInt("VIS"); + if (blocks[i]->HasTokenList(tokenp)) { + // Add module + double Z = blocks[i]->GetDouble("Z", "mm"); + double Rmin = blocks[i]->GetDouble("Rmin", "mm"); + double Rmax = blocks[i]->GetDouble("Rmax", "mm"); + AddModule(Z, Rmin, Rmax, first, second, third); + } + else { + cout << "ERROR: Check input formatting for Gaspard" << endl; + exit(1); } - } - // clear map for next event - GPD3HitMap->clear(); + } + } +} + +// Construct detector and inialise sensitive part. +// Called After DetecorConstruction::AddDetector Method +void GaspardTrackerAnnular::ConstructDetector(G4LogicalVolume* world) { + G4RotationMatrix* MMrot = NULL; + G4ThreeVector MMpos = G4ThreeVector(0, 0, 0); + + bool FirstStage = true; + bool SecondStage = true; + bool ThirdStage = true; + + G4int NumberOfModule = m_FirstStagePosZ.size(); + + for (G4int i = 0; i < NumberOfModule; i++) { + // translation to position the module + // test if module is in the forward or backward hemisphere + (m_FirstStagePosZ[i] < 0) ? m_FirstStagePosZ[i] -= 0.5 * LogicLength : m_FirstStagePosZ[i] += 0.5 * LogicLength; + MMpos = G4ThreeVector(0, 0, m_FirstStagePosZ[i]); + + // Passage Matrix from Lab Referential to Module Referential + // Identity matrix by default + MMrot = new G4RotationMatrix(); + if (MMpos.z() < 0) + MMrot->rotateX(180 * deg); + + // Presence of 1st, 2nd and 3rd stage + FirstStage = m_wFirstStage[i]; + SecondStage = m_wSecondStage[i]; + ThirdStage = m_wThirdStage[i]; + + // Build geometry and declare scorers + VolumeMaker(i + 1, MMpos, MMrot, FirstStage, SecondStage, ThirdStage, world); + } + + delete MMrot; } +// Connect the GaspardTrackingData class to the output TTree +// of the simulation +void GaspardTrackerAnnular::InitializeRootOutput() {} +// Set the TinteractionCoordinates object from NPS::VDetector to the present class +void GaspardTrackerAnnular::SetInterCoordPointer(TInteractionCoordinates* interCoord) { ms_InterCoord = interCoord; } + +// Read sensitive part and fill the Root tree. +// Called at in the EventAction::EndOfEventAvtion +void GaspardTrackerAnnular::ReadSensitive(const G4Event* event) { + ////////////// + // First stage + NPS::HitsMap<G4double*>* GPD1HitMap; + std::map<G4int, G4double**>::iterator GPD1_itr; + + G4int GPD1CollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDAnnular/GPDAnnularFirstStage"); + GPD1HitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(GPD1CollectionID)); + + // Loop on the GPD map + for (GPD1_itr = GPD1HitMap->GetMap()->begin(); GPD1_itr != GPD1HitMap->GetMap()->end(); GPD1_itr++) { + G4double* Info = *(GPD1_itr->second); + + double Energy = Info[0]; + if (Energy > EnergyThreshold) { + double Time = Info[1]; + int DetNbr = (int)Info[7]; + int StripFront = (int)Info[8]; + int StripBack = (int)Info[9]; + + // detector number + ms_Event->SetGPDTrkFirstStageFrontEDetectorNbr(m_index["Annular"] + DetNbr); + ms_Event->SetGPDTrkFirstStageFrontTDetectorNbr(m_index["Annular"] + DetNbr); + ms_Event->SetGPDTrkFirstStageBackEDetectorNbr(m_index["Annular"] + DetNbr); + ms_Event->SetGPDTrkFirstStageBackTDetectorNbr(m_index["Annular"] + DetNbr); + + // energy + ms_Event->SetGPDTrkFirstStageFrontEEnergy(RandGauss::shoot(Energy, ResoFirstStage)); + ms_Event->SetGPDTrkFirstStageBackEEnergy(RandGauss::shoot(Energy, ResoFirstStage)); + + // time + Time = RandGauss::shoot(Time, ResoTimePPAC); + ms_Event->SetGPDTrkFirstStageFrontTTime(RandGauss::shoot(Time, ResoTimeGpd)); + ms_Event->SetGPDTrkFirstStageBackTTime(RandGauss::shoot(Time, ResoTimeGpd)); + + // strips X and Y + ms_Event->SetGPDTrkFirstStageFrontEStripNbr(StripFront); + ms_Event->SetGPDTrkFirstStageFrontTStripNbr(StripFront); + ms_Event->SetGPDTrkFirstStageBackEStripNbr(StripBack); + ms_Event->SetGPDTrkFirstStageBackTStripNbr(StripBack); + + // Interaction Coordinates + ms_InterCoord->SetDetectedPositionX(Info[2]); + ms_InterCoord->SetDetectedPositionY(Info[3]); + ms_InterCoord->SetDetectedPositionZ(Info[4]); + ms_InterCoord->SetDetectedAngleTheta(Info[5] / deg); + ms_InterCoord->SetDetectedAnglePhi(Info[6] / deg); + } + } + // clear map for next event + GPD1HitMap->clear(); + + ////////////// + // Second stage + NPS::HitsMap<G4double*>* GPD2HitMap; + std::map<G4int, G4double**>::iterator GPD2_itr; + + G4int GPD2CollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("SecondStageScorerGPDAnnular/GPDAnnularSecondStage"); + GPD2HitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(GPD2CollectionID)); + + // Loop on the GPD map + for (GPD2_itr = GPD2HitMap->GetMap()->begin(); GPD2_itr != GPD2HitMap->GetMap()->end(); GPD2_itr++) { + G4double* Info = *(GPD2_itr->second); + + double Energy = Info[0]; + if (Energy > EnergyThreshold) { + double Time = Info[1]; + int DetNbr = (int)Info[7]; + int StripFront = (int)Info[8]; + + // detector number + ms_Event->SetGPDTrkSecondStageEDetectorNbr(m_index["Annular"] + DetNbr); + ms_Event->SetGPDTrkSecondStageTDetectorNbr(m_index["Annular"] + DetNbr); + + // energy + ms_Event->SetGPDTrkSecondStageEEnergy(RandGauss::shoot(Energy, ResoSecondStage)); + + // time + Time = RandGauss::shoot(Time, ResoTimePPAC); + ms_Event->SetGPDTrkSecondStageTTime(RandGauss::shoot(Time, ResoTimeGpd)); + + // strips X and Y + ms_Event->SetGPDTrkSecondStageEPadNbr(StripFront); + ms_Event->SetGPDTrkSecondStageTPadNbr(StripFront); + } + } + // clear map for next event + GPD2HitMap->clear(); + + ////////////// + // Third stage + NPS::HitsMap<G4double*>* GPD3HitMap; + std::map<G4int, G4double**>::iterator GPD3_itr; + + G4int GPD3CollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("ThirdStageScorerGPDAnnular/GPDAnnularThirdStage"); + GPD3HitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(GPD3CollectionID)); + + // Loop on the GPD map + for (GPD3_itr = GPD3HitMap->GetMap()->begin(); GPD3_itr != GPD3HitMap->GetMap()->end(); GPD3_itr++) { + G4double* Info = *(GPD3_itr->second); + + double Energy = Info[0]; + if (Energy > EnergyThreshold) { + double Time = Info[1]; + int DetNbr = (int)Info[7]; + int StripFront = (int)Info[8]; + + // detector number + ms_Event->SetGPDTrkThirdStageEDetectorNbr(m_index["Annular"] + DetNbr); + ms_Event->SetGPDTrkThirdStageTDetectorNbr(m_index["Annular"] + DetNbr); + + // energy + ms_Event->SetGPDTrkThirdStageEEnergy(RandGauss::shoot(Energy, ResoThirdStage)); + + // time + Time = RandGauss::shoot(Time, ResoTimePPAC); + ms_Event->SetGPDTrkThirdStageTTime(RandGauss::shoot(Time, ResoTimeGpd)); + + // strips X and Y + ms_Event->SetGPDTrkThirdStageEPadNbr(StripFront); + ms_Event->SetGPDTrkThirdStageTPadNbr(StripFront); + } + } + // clear map for next event + GPD3HitMap->clear(); +} -void GaspardTrackerAnnular::InitializeScorers() -{ - // check whether scorers are already defined - bool already_exist = false; - m_FirstStageScorer = NPS::VDetector::CheckScorer("FirstStageScorerGPDAnnular", already_exist); - m_SecondStageScorer = NPS::VDetector::CheckScorer("SecondStageScorerGPDAnnular", already_exist); - m_ThirdStageScorer = NPS::VDetector::CheckScorer("ThirdStageScorerGPDAnnular", already_exist); - if (already_exist) return; - - - // First stage scorer - G4VPrimitiveScorer* GPDScorerFirstStage = - new SILICONSCORERS::PS_Silicon_Annular("GPDAnnularFirstStage", - 0, - m_FirstStageRmin[0], - m_FirstStageRmax[0], - 360*deg, - 0*deg, - NbThetaStrips, - NbPhiStrips, - 1); - - // Second stage scorer - G4VPrimitiveScorer* GPDScorerSecondStage = - new SILICONSCORERS::PS_Silicon_Annular("GPDAnnularSecondStage", - 0, - m_FirstStageRmin[0], - m_FirstStageRmax[0], - 0*deg, - 360*deg, - 1, - 1, - 1); - - // Third stage scorer - G4VPrimitiveScorer* GPDScorerThirdStage = - new SILICONSCORERS::PS_Silicon_Annular("GPDAnnularThirdStage", - 0, - m_FirstStageRmin[0], - m_FirstStageRmax[0], - 0*deg, - 360*deg, - 1, - 1, - 1); - - // register scorers to the multifunctionnal detector - m_FirstStageScorer ->RegisterPrimitive(GPDScorerFirstStage); - m_SecondStageScorer ->RegisterPrimitive(GPDScorerSecondStage); - m_ThirdStageScorer ->RegisterPrimitive(GPDScorerThirdStage); - - - -/* - // First stage Associate Scorer - G4VPrimitiveScorer* DetNbr = new OBSOLETEGENERALSCORERS::PSDetectorNumber("DetectorNumber", "GPDAnnular", 0); - G4VPrimitiveScorer* TOF = new OBSOLETEGENERALSCORERS::PSTOF("StripTime","GPDAnnular", 0); - G4VPrimitiveScorer* InteractionCoordinatesX = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesX("InterCoordX","GPDAnnular", 0); - G4VPrimitiveScorer* InteractionCoordinatesY = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesY("InterCoordY","GPDAnnular", 0); - G4VPrimitiveScorer* InteractionCoordinatesZ = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ","GPDAnnular", 0); - G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta","GPDAnnular", 0); - G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi","GPDAnnular", 0); - G4VPrimitiveScorer* Energy = new GPDScorerFirstStageEnergy("StripEnergy", "GPDAnnular", 0); - G4VPrimitiveScorer* StripPositionX = new GPDScorerFirstStageFrontStripAnnular("StripNumberX", 0, FirstStageRmax, 128); - G4VPrimitiveScorer* StripPositionY = new GPDScorerFirstStageBackStripAnnular("StripNumberY", 0, FirstStageRmax, 128); - - //and register it to the multifunctionnal detector - m_FirstStageScorer->RegisterPrimitive(DetNbr); - m_FirstStageScorer->RegisterPrimitive(Energy); - m_FirstStageScorer->RegisterPrimitive(TOF); - m_FirstStageScorer->RegisterPrimitive(StripPositionX); - m_FirstStageScorer->RegisterPrimitive(StripPositionY); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesX); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesY); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesZ); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAngleTheta); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAnglePhi); - - // Second stage Associate Scorer - G4VPrimitiveScorer* SecondStageEnergy = new GPDScorerSecondStageEnergy("SecondStageEnergy", "GPDAnnular", 0); - m_SecondStageScorer->RegisterPrimitive(SecondStageEnergy); - - // Third stage Associate Scorer - G4VPrimitiveScorer* ThirdStageEnergy = new GPDScorerThirdStageEnergy("ThirdStageEnergy", "GPDAnnular", 0); - m_ThirdStageScorer->RegisterPrimitive(ThirdStageEnergy); -*/ - // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_FirstStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_SecondStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_ThirdStageScorer); +void GaspardTrackerAnnular::InitializeScorers() { + // check whether scorers are already defined + bool already_exist = false; + m_FirstStageScorer = NPS::VDetector::CheckScorer("FirstStageScorerGPDAnnular", already_exist); + m_SecondStageScorer = NPS::VDetector::CheckScorer("SecondStageScorerGPDAnnular", already_exist); + m_ThirdStageScorer = NPS::VDetector::CheckScorer("ThirdStageScorerGPDAnnular", already_exist); + if (already_exist) + return; + + // First stage scorer + G4VPrimitiveScorer* GPDScorerFirstStage = + new SILICONSCORERS::PS_Silicon_Annular("GPDAnnularFirstStage", 0, m_FirstStageRmin[0], m_FirstStageRmax[0], + 360 * deg, 0 * deg, NbThetaStrips, NbPhiStrips, 1); + + // Second stage scorer + G4VPrimitiveScorer* GPDScorerSecondStage = new SILICONSCORERS::PS_Silicon_Annular( + "GPDAnnularSecondStage", 0, m_FirstStageRmin[0], m_FirstStageRmax[0], 0 * deg, 360 * deg, 1, 1, 1); + + // Third stage scorer + G4VPrimitiveScorer* GPDScorerThirdStage = new SILICONSCORERS::PS_Silicon_Annular( + "GPDAnnularThirdStage", 0, m_FirstStageRmin[0], m_FirstStageRmax[0], 0 * deg, 360 * deg, 1, 1, 1); + + // register scorers to the multifunctionnal detector + m_FirstStageScorer->RegisterPrimitive(GPDScorerFirstStage); + m_SecondStageScorer->RegisterPrimitive(GPDScorerSecondStage); + m_ThirdStageScorer->RegisterPrimitive(GPDScorerThirdStage); + + /* + // First stage Associate Scorer + G4VPrimitiveScorer* DetNbr = new + OBSOLETEGENERALSCORERS::PSDetectorNumber("DetectorNumber", "GPDAnnular", 0); G4VPrimitiveScorer* TOF = new + OBSOLETEGENERALSCORERS::PSTOF("StripTime","GPDAnnular", 0); G4VPrimitiveScorer* InteractionCoordinatesX = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesX("InterCoordX","GPDAnnular", 0); G4VPrimitiveScorer* + InteractionCoordinatesY = new + OBSOLETEGENERALSCORERS::PSInteractionCoordinatesY("InterCoordY","GPDAnnular", 0); G4VPrimitiveScorer* + InteractionCoordinatesZ = new + OBSOLETEGENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ","GPDAnnular", 0); G4VPrimitiveScorer* + InteractionCoordinatesAngleTheta = new + OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta","GPDAnnular", 0); + G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new + OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi","GPDAnnular", 0); G4VPrimitiveScorer* + Energy = new GPDScorerFirstStageEnergy("StripEnergy", "GPDAnnular", 0); + G4VPrimitiveScorer* StripPositionX = new GPDScorerFirstStageFrontStripAnnular("StripNumberX", 0, + FirstStageRmax, 128); G4VPrimitiveScorer* StripPositionY = new + GPDScorerFirstStageBackStripAnnular("StripNumberY", 0, FirstStageRmax, 128); + + //and register it to the multifunctionnal detector + m_FirstStageScorer->RegisterPrimitive(DetNbr); + m_FirstStageScorer->RegisterPrimitive(Energy); + m_FirstStageScorer->RegisterPrimitive(TOF); + m_FirstStageScorer->RegisterPrimitive(StripPositionX); + m_FirstStageScorer->RegisterPrimitive(StripPositionY); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesX); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesY); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesZ); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAngleTheta); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAnglePhi); + + // Second stage Associate Scorer + G4VPrimitiveScorer* SecondStageEnergy = new GPDScorerSecondStageEnergy("SecondStageEnergy", "GPDAnnular", 0); + m_SecondStageScorer->RegisterPrimitive(SecondStageEnergy); + + // Third stage Associate Scorer + G4VPrimitiveScorer* ThirdStageEnergy = new GPDScorerThirdStageEnergy("ThirdStageEnergy", "GPDAnnular", 0); + m_ThirdStageScorer->RegisterPrimitive(ThirdStageEnergy); + */ + // Add All Scorer to the Global Scorer Manager + G4SDManager::GetSDMpointer()->AddNewDetector(m_FirstStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_SecondStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_ThirdStageScorer); } diff --git a/NPSimulation/Detectors/GASPARD/GaspardTrackerDummyShape.cc b/NPSimulation/Detectors/GASPARD/GaspardTrackerDummyShape.cc index 2e3118bf8..68f5f79af 100644 --- a/NPSimulation/Detectors/GASPARD/GaspardTrackerDummyShape.cc +++ b/NPSimulation/Detectors/GASPARD/GaspardTrackerDummyShape.cc @@ -28,38 +28,38 @@ *****************************************************************************/ // C++ headers +#include <cmath> #include <sstream> #include <string> -#include <cmath> // G4 Geometry headers -#include "G4Trd.hh" #include "G4Box.hh" #include "G4Trap.hh" +#include "G4Trd.hh" // G4 various headers -#include "G4MaterialTable.hh" +#include "G4Colour.hh" #include "G4Element.hh" #include "G4ElementTable.hh" -#include "G4VisAttributes.hh" -#include "G4Colour.hh" +#include "G4MaterialTable.hh" +#include "G4PVDivision.hh" +#include "G4PVPlacement.hh" #include "G4RotationMatrix.hh" #include "G4Transform3D.hh" -#include "G4PVPlacement.hh" -#include "G4PVDivision.hh" +#include "G4VisAttributes.hh" // G4 sensitive -#include "G4SDManager.hh" #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" // NPTool headers -#include "GaspardTrackerDummyShape.hh" -#include "ObsoleteGeneralScorers.hh" #include "GaspardScorers.hh" -#include "RootOutput.h" -#include "NPSVDetector.hh" +#include "GaspardTrackerDummyShape.hh" #include "NPOptionManager.h" #include "NPSDetectorFactory.hh" +#include "NPSVDetector.hh" +#include "ObsoleteGeneralScorers.hh" +#include "RootOutput.h" // CLHEP #include "CLHEP/Random/RandGauss.h" @@ -69,751 +69,698 @@ using namespace CLHEP; using namespace GPDDUMMYSHAPE; using namespace GPDSCORERS; - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -GaspardTrackerDummyShape::GaspardTrackerDummyShape() -{ - ms_InterCoord = 0; -} - - +GaspardTrackerDummyShape::GaspardTrackerDummyShape() { ms_InterCoord = 0; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -GaspardTrackerDummyShape::~GaspardTrackerDummyShape() -{ -} - - +GaspardTrackerDummyShape::~GaspardTrackerDummyShape() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void GaspardTrackerDummyShape::AddModule(G4ThreeVector X1_Y1 , - G4ThreeVector X128_Y1 , - G4ThreeVector X1_Y128 , - G4ThreeVector X128_Y128 , - bool wFirstStage , - bool wSecondStage , - bool wThirdStage) -{ - m_DefinitionType.push_back(true) ; - - m_X1_Y1.push_back(X1_Y1) ; - m_X128_Y1.push_back(X128_Y1) ; - m_X1_Y128.push_back(X1_Y128) ; - m_X128_Y128.push_back(X128_Y128) ; - - m_R.push_back(0) ; - m_Theta.push_back(0) ; - m_Phi.push_back(0) ; - m_beta_u.push_back(0) ; - m_beta_v.push_back(0) ; - m_beta_w.push_back(0) ; - - m_wFirstStage.push_back(wFirstStage) ; - m_wSecondStage.push_back(wSecondStage) ; - m_wThirdStage.push_back(wThirdStage) ; - -// m_wNumberStrip.push_back(wNumberStrip); +void GaspardTrackerDummyShape::AddModule(G4ThreeVector X1_Y1, G4ThreeVector X128_Y1, G4ThreeVector X1_Y128, + G4ThreeVector X128_Y128, bool wFirstStage, bool wSecondStage, + bool wThirdStage) { + m_DefinitionType.push_back(true); + + m_X1_Y1.push_back(X1_Y1); + m_X128_Y1.push_back(X128_Y1); + m_X1_Y128.push_back(X1_Y128); + m_X128_Y128.push_back(X128_Y128); + + m_R.push_back(0); + m_Theta.push_back(0); + m_Phi.push_back(0); + m_beta_u.push_back(0); + m_beta_v.push_back(0); + m_beta_w.push_back(0); + + m_wFirstStage.push_back(wFirstStage); + m_wSecondStage.push_back(wSecondStage); + m_wThirdStage.push_back(wThirdStage); + + // m_wNumberStrip.push_back(wNumberStrip); } - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void GaspardTrackerDummyShape::AddModule(G4double R , - G4double Theta , - G4double Phi , - G4double beta_u , - G4double beta_v , - G4double beta_w , - bool wFirstStage , - bool wSecondStage , - bool wThirdStage) -{ - G4ThreeVector empty = G4ThreeVector(0, 0, 0); - - m_DefinitionType.push_back(false); - - m_X1_Y1.push_back(empty) ; - m_X128_Y1.push_back(empty) ; - m_X1_Y128.push_back(empty) ; - m_X128_Y128.push_back(empty) ; - - m_R.push_back(R) ; - m_Theta.push_back(Theta) ; - m_Phi.push_back(Phi) ; - m_beta_u.push_back(beta_u) ; - m_beta_v.push_back(beta_v) ; - m_beta_w.push_back(beta_w) ; - - m_wFirstStage.push_back(wFirstStage) ; - m_wSecondStage.push_back(wSecondStage) ; - m_wThirdStage.push_back(wThirdStage) ; +void GaspardTrackerDummyShape::AddModule(G4double R, G4double Theta, G4double Phi, G4double beta_u, G4double beta_v, + G4double beta_w, bool wFirstStage, bool wSecondStage, bool wThirdStage) { + G4ThreeVector empty = G4ThreeVector(0, 0, 0); + + m_DefinitionType.push_back(false); + + m_X1_Y1.push_back(empty); + m_X128_Y1.push_back(empty); + m_X1_Y128.push_back(empty); + m_X128_Y128.push_back(empty); + + m_R.push_back(R); + m_Theta.push_back(Theta); + m_Phi.push_back(Phi); + m_beta_u.push_back(beta_u); + m_beta_v.push_back(beta_v); + m_beta_w.push_back(beta_w); + + m_wFirstStage.push_back(wFirstStage); + m_wSecondStage.push_back(wSecondStage); + m_wThirdStage.push_back(wThirdStage); } - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void GaspardTrackerDummyShape::VolumeMaker(G4int DetectorNumber, - G4ThreeVector MMpos, - G4RotationMatrix* MMrot, - bool wFirstStage, - bool wSecondStage, - bool wThirdStage, - G4LogicalVolume* world) -{ - G4double NbrTelescopes = DetectorNumber ; - G4String DetNumber ; - ostringstream Number ; - Number << NbrTelescopes ; - DetNumber = Number.str() ; - - ///////////////////////////////////////////////////////////////// - ////////////// Starting Volume Definition ////////////////////// - //////////////////////////////////////////////////////////////// - G4String Name = "GPDDummyShape" + DetNumber ; - - G4Box* solidGPDDummyShape = new G4Box(Name, 0.5*FaceFront, 0.5*FaceFront, 0.5*Length); - G4LogicalVolume* logicGPDDummyShape = new G4LogicalVolume(solidGPDDummyShape, m_MaterialVacuum, Name, 0, 0, 0); - - new G4PVPlacement(G4Transform3D(*MMrot, MMpos) , - logicGPDDummyShape , - Name , - world , - false , - DetectorNumber); - - logicGPDDummyShape->SetVisAttributes(G4VisAttributes::Invisible); - if (m_non_sensitive_part_visiualisation) logicGPDDummyShape->SetVisAttributes(G4VisAttributes(G4Colour(0.90, 0.90, 0.90))); - - //Place two marker to identify the u and v axis on silicon face: - //marker are placed a bit before the silicon itself so they don't perturbate simulation - //Uncomment to help debugging or if you want to understand the way the code work. - //I should recommand to Comment it during simulation to avoid perturbation of simulation - //Remember G4 is limitationg step on geometry constraints. - G4ThreeVector positionMarkerU = MMCenter*0.8 + MMu*FirstStageFace/4; - G4Box* solidMarkerU = new G4Box("solidMarkerU", FirstStageFace/4, 1*mm, 1*mm); - G4LogicalVolume* logicMarkerU = new G4LogicalVolume(solidMarkerU, m_MaterialVacuum, "logicMarkerU", 0, 0, 0); - new G4PVPlacement(G4Transform3D(*MMrot,positionMarkerU), logicMarkerU, "MarkerU", world, false, 0); - - G4VisAttributes* MarkerUVisAtt= new G4VisAttributes(G4Colour(0.,0.,0.5)); //blue - logicMarkerU->SetVisAttributes(MarkerUVisAtt); - - G4ThreeVector positionMarkerV = MMCenter*0.8 + MMv*FirstStageFace/4; - G4Box* solidMarkerV = new G4Box("solidMarkerU", 1*mm, FirstStageFace/4, 1*mm); - G4LogicalVolume* logicMarkerV = new G4LogicalVolume(solidMarkerV, m_MaterialVacuum, "logicMarkerV", 0, 0, 0); - new G4PVPlacement(G4Transform3D(*MMrot,positionMarkerV), logicMarkerV, "MarkerV", world, false, 0); - - G4VisAttributes* MarkerVVisAtt= new G4VisAttributes(G4Colour(0.,0.5,0.)); //green - logicMarkerV->SetVisAttributes(MarkerVVisAtt); - - //////////////////////////////////////////////////////////////// - ///////////////// First Stage Construction ///////////////////// - //////////////////////////////////////////////////////////////// - if (wFirstStage) { - // Dead layers -/* G4ThreeVector positionFirstStageDLFront = G4ThreeVector(0, 0, FirstStage_DL_Front_PosZ); - G4ThreeVector positionFirstStageDLBack = G4ThreeVector(0, 0, FirstStage_DL_Back_PosZ); - - G4Box* solidFirstStageDL = new G4Box("solidFirstStageDL", 0.5*FirstStageFace, 0.5*FirstStageFace, 0.5*FirstStageDeadLayer); - G4LogicalVolume* logicFirstStageDL = new G4LogicalVolume(solidFirstStageDL, Aluminium, "logicFirstStageDL", 0, 0, 0); - - PVPBuffer = new G4PVPlacement(0, positionFirstStageDLFront, logicFirstStageDL, Name + "_DLFront", logicGPDDummyShape, false, 0); - PVPBuffer = new G4PVPlacement(0, positionFirstStageDLBack, logicFirstStageDL, Name + "_DLBack", logicGPDDummyShape, false, 0); - - logicFirstStageDL->SetVisAttributes(G4VisAttributes::Invisible); -*/ - - // Silicon detector itself - G4ThreeVector positionFirstStage = G4ThreeVector(0, 0, FirstStage_PosZ); - - G4Box* solidFirstStage = new G4Box("solidFirstStage", 0.5*FirstStageFace, 0.5*FirstStageFace, 0.5*FirstStageThickness); - G4LogicalVolume* logicFirstStage = new G4LogicalVolume(solidFirstStage, m_MaterialSilicon, "logicFirstStage", 0, 0, 0); - - new G4PVPlacement(0, - positionFirstStage, - logicFirstStage, - Name + "_FirstStage", - logicGPDDummyShape, - false, - DetectorNumber); - - // Set First Stage sensible - logicFirstStage->SetSensitiveDetector(m_FirstStageScorer); - - ///Visualisation of FirstStage Strip - G4VisAttributes* FirstStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)); // blue - logicFirstStage->SetVisAttributes(FirstStageVisAtt); - } - - //////////////////////////////////////////////////////////////// - //////////////////// Second Stage Construction //////////////// - //////////////////////////////////////////////////////////////// - if (wSecondStage) { - // Dead layers -/* G4ThreeVector positionSecondStageDLFront = G4ThreeVector(0, 0, SecondStage_DL_Front_PosZ); - G4ThreeVector positionSecondStageDLBack = G4ThreeVector(0, 0, SecondStage_DL_Back_PosZ); - - G4Box* solidSecondStageDL = new G4Box("solidSecondStageDL", 0.5*SecondStageFace, 0.5*SecondStageFace, 0.5*SecondStageDeadLayer); - G4LogicalVolume* logicSecondStageDL = new G4LogicalVolume(solidSecondStageDL, Aluminium, "logicSecondStageDL", 0, 0, 0); - - PVPBuffer = new G4PVPlacement(0, positionSecondStageDLFront, logicSecondStageDL, Name + "_DLFront", logicGPDDummyShape, false, 0); - PVPBuffer = new G4PVPlacement(0, positionSecondStageDLBack, logicSecondStageDL, Name + "_DLBack", logicGPDDummyShape, false, 0); - - logicSecondStageDL->SetVisAttributes(G4VisAttributes::Invisible); -*/ - - // Second stage silicon detector - G4ThreeVector positionSecondStage = G4ThreeVector(0, 0, SecondStage_PosZ); - - G4Box* solidSecondStage = new G4Box("solidSecondStage", 0.5*SecondStageFace, 0.5*SecondStageFace, 0.5*SecondStageThickness); - G4LogicalVolume* logicSecondStage = new G4LogicalVolume(solidSecondStage, m_MaterialSilicon, "logicSecondStage", 0, 0, 0); - - new G4PVPlacement(0, - positionSecondStage, - logicSecondStage, - Name + "_SecondStage", - logicGPDDummyShape, - false, - DetectorNumber); - - // Set Second Stage sensible - logicSecondStage->SetSensitiveDetector(m_SecondStageScorer); - - ///Visualisation of SecondStage Strip - G4VisAttributes* SecondStageVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)); - logicSecondStage->SetVisAttributes(SecondStageVisAtt); - } - - //////////////////////////////////////////////////////////////// - ///////////////// Third Stage Construction ///////////////////// - //////////////////////////////////////////////////////////////// - if (wThirdStage) { - // Dead layers -/* G4ThreeVector positionThirdStageDLFront = G4ThreeVector(0, 0, ThirdStage_DL_Front_PosZ); - G4ThreeVector positionThirdStageDLBack = G4ThreeVector(0, 0, ThirdStage_DL_Back_PosZ); - - G4Box* solidThirdStageDL = new G4Box("solidThirdStageDL", 0.5*ThirdStageFace, 0.5*ThirdStageFace, 0.5*ThirdStageDeadLayer); - G4LogicalVolume* logicThirdStageDL = new G4LogicalVolume(solidThirdStageDL, Aluminium, "logicThirdStageDL", 0, 0, 0); - - PVPBuffer = new G4PVPlacement(0, positionThirdStageDLFront, logicThirdStageDL, Name + "_DLFront", logicGPDDummyShape, false, 0); - PVPBuffer = new G4PVPlacement(0, positionThirdStageDLBack, logicThirdStageDL, Name + "_DLBack", logicGPDDummyShape, false, 0); - - logicThirdStageDL->SetVisAttributes(G4VisAttributes::Invisible); -*/ - - // Third stage silicon detector - G4ThreeVector positionThirdStage = G4ThreeVector(0, 0, ThirdStage_PosZ); - - G4Box* solidThirdStage = new G4Box("solidThirdStage", 0.5*ThirdStageFace, 0.5*ThirdStageFace, 0.5*ThirdStageThickness); - G4LogicalVolume* logicThirdStage = new G4LogicalVolume(solidThirdStage, m_MaterialSilicon, "logicThirdStage", 0, 0, 0); - - new G4PVPlacement(0, - positionThirdStage, - logicThirdStage, - Name + "_ThirdStage", - logicGPDDummyShape, - false, - DetectorNumber); - - // Set Third Stage sensible - logicThirdStage->SetSensitiveDetector(m_ThirdStageScorer); - - ///Visualisation of Third Stage - G4VisAttributes* ThirdStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // green - logicThirdStage->SetVisAttributes(ThirdStageVisAtt); - } +void GaspardTrackerDummyShape::VolumeMaker(G4int DetectorNumber, G4ThreeVector MMpos, G4RotationMatrix* MMrot, + bool wFirstStage, bool wSecondStage, bool wThirdStage, + G4LogicalVolume* world) { + G4double NbrTelescopes = DetectorNumber; + G4String DetNumber; + ostringstream Number; + Number << NbrTelescopes; + DetNumber = Number.str(); + + ///////////////////////////////////////////////////////////////// + ////////////// Starting Volume Definition ////////////////////// + //////////////////////////////////////////////////////////////// + G4String Name = "GPDDummyShape" + DetNumber; + + G4Box* solidGPDDummyShape = new G4Box(Name, 0.5 * FaceFront, 0.5 * FaceFront, 0.5 * Length); + G4LogicalVolume* logicGPDDummyShape = new G4LogicalVolume(solidGPDDummyShape, m_MaterialVacuum, Name, 0, 0, 0); + + new G4PVPlacement(G4Transform3D(*MMrot, MMpos), logicGPDDummyShape, Name, world, false, DetectorNumber); + + logicGPDDummyShape->SetVisAttributes(G4VisAttributes::GetInvisible()); + if (m_non_sensitive_part_visiualisation) + logicGPDDummyShape->SetVisAttributes(G4VisAttributes(G4Colour(0.90, 0.90, 0.90))); + + // Place two marker to identify the u and v axis on silicon face: + // marker are placed a bit before the silicon itself so they don't perturbate simulation + // Uncomment to help debugging or if you want to understand the way the code work. + // I should recommand to Comment it during simulation to avoid perturbation of simulation + // Remember G4 is limitationg step on geometry constraints. + G4ThreeVector positionMarkerU = MMCenter * 0.8 + MMu * FirstStageFace / 4; + G4Box* solidMarkerU = new G4Box("solidMarkerU", FirstStageFace / 4, 1 * mm, 1 * mm); + G4LogicalVolume* logicMarkerU = new G4LogicalVolume(solidMarkerU, m_MaterialVacuum, "logicMarkerU", 0, 0, 0); + new G4PVPlacement(G4Transform3D(*MMrot, positionMarkerU), logicMarkerU, "MarkerU", world, false, 0); + + G4VisAttributes* MarkerUVisAtt = new G4VisAttributes(G4Colour(0., 0., 0.5)); // blue + logicMarkerU->SetVisAttributes(MarkerUVisAtt); + + G4ThreeVector positionMarkerV = MMCenter * 0.8 + MMv * FirstStageFace / 4; + G4Box* solidMarkerV = new G4Box("solidMarkerU", 1 * mm, FirstStageFace / 4, 1 * mm); + G4LogicalVolume* logicMarkerV = new G4LogicalVolume(solidMarkerV, m_MaterialVacuum, "logicMarkerV", 0, 0, 0); + new G4PVPlacement(G4Transform3D(*MMrot, positionMarkerV), logicMarkerV, "MarkerV", world, false, 0); + + G4VisAttributes* MarkerVVisAtt = new G4VisAttributes(G4Colour(0., 0.5, 0.)); // green + logicMarkerV->SetVisAttributes(MarkerVVisAtt); + + //////////////////////////////////////////////////////////////// + ///////////////// First Stage Construction ///////////////////// + //////////////////////////////////////////////////////////////// + if (wFirstStage) { + // Dead layers + /* G4ThreeVector positionFirstStageDLFront = G4ThreeVector(0, 0, FirstStage_DL_Front_PosZ); + G4ThreeVector positionFirstStageDLBack = G4ThreeVector(0, 0, FirstStage_DL_Back_PosZ); + + G4Box* solidFirstStageDL = new G4Box("solidFirstStageDL", 0.5*FirstStageFace, 0.5*FirstStageFace, + 0.5*FirstStageDeadLayer); G4LogicalVolume* logicFirstStageDL = new G4LogicalVolume(solidFirstStageDL, Aluminium, + "logicFirstStageDL", 0, 0, 0); + + PVPBuffer = new G4PVPlacement(0, positionFirstStageDLFront, logicFirstStageDL, Name + "_DLFront", + logicGPDDummyShape, false, 0); PVPBuffer = new G4PVPlacement(0, positionFirstStageDLBack, logicFirstStageDL, + Name + "_DLBack", logicGPDDummyShape, false, 0); + + logicFirstStageDL->SetVisAttributes(G4VisAttributes::GetInvisible()); + */ + + // Silicon detector itself + G4ThreeVector positionFirstStage = G4ThreeVector(0, 0, FirstStage_PosZ); + + G4Box* solidFirstStage = + new G4Box("solidFirstStage", 0.5 * FirstStageFace, 0.5 * FirstStageFace, 0.5 * FirstStageThickness); + G4LogicalVolume* logicFirstStage = + new G4LogicalVolume(solidFirstStage, m_MaterialSilicon, "logicFirstStage", 0, 0, 0); + + new G4PVPlacement(0, positionFirstStage, logicFirstStage, Name + "_FirstStage", logicGPDDummyShape, false, + DetectorNumber); + + // Set First Stage sensible + logicFirstStage->SetSensitiveDetector(m_FirstStageScorer); + + /// Visualisation of FirstStage Strip + G4VisAttributes* FirstStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)); // blue + logicFirstStage->SetVisAttributes(FirstStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + //////////////////// Second Stage Construction //////////////// + //////////////////////////////////////////////////////////////// + if (wSecondStage) { + // Dead layers + /* G4ThreeVector positionSecondStageDLFront = G4ThreeVector(0, 0, SecondStage_DL_Front_PosZ); + G4ThreeVector positionSecondStageDLBack = G4ThreeVector(0, 0, SecondStage_DL_Back_PosZ); + + G4Box* solidSecondStageDL = new G4Box("solidSecondStageDL", 0.5*SecondStageFace, + 0.5*SecondStageFace, 0.5*SecondStageDeadLayer); G4LogicalVolume* logicSecondStageDL = new + G4LogicalVolume(solidSecondStageDL, Aluminium, "logicSecondStageDL", 0, 0, 0); + + PVPBuffer = new G4PVPlacement(0, positionSecondStageDLFront, logicSecondStageDL, Name + "_DLFront", + logicGPDDummyShape, false, 0); PVPBuffer = new G4PVPlacement(0, positionSecondStageDLBack, logicSecondStageDL, + Name + "_DLBack", logicGPDDummyShape, false, 0); + + logicSecondStageDL->SetVisAttributes(G4VisAttributes::GetInvisible()); + */ + + // Second stage silicon detector + G4ThreeVector positionSecondStage = G4ThreeVector(0, 0, SecondStage_PosZ); + + G4Box* solidSecondStage = + new G4Box("solidSecondStage", 0.5 * SecondStageFace, 0.5 * SecondStageFace, 0.5 * SecondStageThickness); + G4LogicalVolume* logicSecondStage = + new G4LogicalVolume(solidSecondStage, m_MaterialSilicon, "logicSecondStage", 0, 0, 0); + + new G4PVPlacement(0, positionSecondStage, logicSecondStage, Name + "_SecondStage", logicGPDDummyShape, false, + DetectorNumber); + + // Set Second Stage sensible + logicSecondStage->SetSensitiveDetector(m_SecondStageScorer); + + /// Visualisation of SecondStage Strip + G4VisAttributes* SecondStageVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)); + logicSecondStage->SetVisAttributes(SecondStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Third Stage Construction ///////////////////// + //////////////////////////////////////////////////////////////// + if (wThirdStage) { + // Dead layers + /* G4ThreeVector positionThirdStageDLFront = G4ThreeVector(0, 0, ThirdStage_DL_Front_PosZ); + G4ThreeVector positionThirdStageDLBack = G4ThreeVector(0, 0, ThirdStage_DL_Back_PosZ); + + G4Box* solidThirdStageDL = new G4Box("solidThirdStageDL", 0.5*ThirdStageFace, 0.5*ThirdStageFace, + 0.5*ThirdStageDeadLayer); G4LogicalVolume* logicThirdStageDL = new G4LogicalVolume(solidThirdStageDL, Aluminium, + "logicThirdStageDL", 0, 0, 0); + + PVPBuffer = new G4PVPlacement(0, positionThirdStageDLFront, logicThirdStageDL, Name + "_DLFront", + logicGPDDummyShape, false, 0); PVPBuffer = new G4PVPlacement(0, positionThirdStageDLBack, logicThirdStageDL, + Name + "_DLBack", logicGPDDummyShape, false, 0); + + logicThirdStageDL->SetVisAttributes(G4VisAttributes::GetInvisible()); + */ + + // Third stage silicon detector + G4ThreeVector positionThirdStage = G4ThreeVector(0, 0, ThirdStage_PosZ); + + G4Box* solidThirdStage = + new G4Box("solidThirdStage", 0.5 * ThirdStageFace, 0.5 * ThirdStageFace, 0.5 * ThirdStageThickness); + G4LogicalVolume* logicThirdStage = + new G4LogicalVolume(solidThirdStage, m_MaterialSilicon, "logicThirdStage", 0, 0, 0); + + new G4PVPlacement(0, positionThirdStage, logicThirdStage, Name + "_ThirdStage", logicGPDDummyShape, false, + DetectorNumber); + + // Set Third Stage sensible + logicThirdStage->SetSensitiveDetector(m_ThirdStageScorer); + + /// Visualisation of Third Stage + G4VisAttributes* ThirdStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // green + logicThirdStage->SetVisAttributes(ThirdStageVisAtt); + } } - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void GaspardTrackerDummyShape::ReadConfiguration(NPL::InputParser parser){ +void GaspardTrackerDummyShape::ReadConfiguration(NPL::InputParser parser) { vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("GaspardTracker"); - vector<string> token_cart= {"X1_Y1","X128_Y1","X1_Y128","X128_Y128"}; - vector<string> token_sphe= {"R","THETA","PHI","BETA"}; + vector<string> token_cart = {"X1_Y1", "X128_Y1", "X1_Y128", "X128_Y128"}; + vector<string> token_sphe = {"R", "THETA", "PHI", "BETA"}; - vector<string> token={"FIRSTSTAGE","SECONDSTAGE","THIRDSTAGE"}; + vector<string> token = {"FIRSTSTAGE", "SECONDSTAGE", "THIRDSTAGE"}; - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->GetMainValue() == "DummyShape" && blocks[i]->HasTokenList(token) ){ - cout << "Gaspard Dummy Shape " << i+1 << ":" << endl; + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->GetMainValue() == "DummyShape" && blocks[i]->HasTokenList(token)) { + cout << "Gaspard Dummy Shape " << i + 1 << ":" << endl; - bool first = blocks[i]->GetInt("FIRSTSTAGE"); bool second = blocks[i]->GetInt("SECONDSTAGE"); bool third = blocks[i]->GetInt("THIRDSTAGE"); - if(blocks[i]->HasToken("VIS")) - m_non_sensitive_part_visiualisation = blocks[i]->GetInt("VIS"); + if (blocks[i]->HasToken("VIS")) + m_non_sensitive_part_visiualisation = blocks[i]->GetInt("VIS"); - if(blocks[i]->HasTokenList(token_cart)){ + if (blocks[i]->HasTokenList(token_cart)) { // Add module - G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("X1_Y1","mm")); - G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("X128_Y1","mm")); - G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("X1_Y128","mm")); - G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("X128_Y128","mm")); - - AddModule(A,B,C,D,first,second,third); + G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("X1_Y1", "mm")); + G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("X128_Y1", "mm")); + G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("X1_Y128", "mm")); + G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("X128_Y128", "mm")); + + AddModule(A, B, C, D, first, second, third); } - else if(blocks[i]->HasTokenList(token_sphe)){ + else if (blocks[i]->HasTokenList(token_sphe)) { // Add module - double R = blocks[i]->GetDouble("R","mm"); - double Theta = blocks[i]->GetDouble("THETA","deg"); - double Phi = blocks[i]->GetDouble("PHI","deg"); - vector<double> beta = blocks[i]->GetVectorDouble("BETA","deg"); - - AddModule(R,Theta,Phi,beta[0],beta[1],beta[2],first,second,third); + double R = blocks[i]->GetDouble("R", "mm"); + double Theta = blocks[i]->GetDouble("THETA", "deg"); + double Phi = blocks[i]->GetDouble("PHI", "deg"); + vector<double> beta = blocks[i]->GetVectorDouble("BETA", "deg"); + + AddModule(R, Theta, Phi, beta[0], beta[1], beta[2], first, second, third); } } - } + } } // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void GaspardTrackerDummyShape::ConstructDetector(G4LogicalVolume* world) -{ - G4RotationMatrix* MMrot = NULL ; - G4ThreeVector MMpos = G4ThreeVector(0, 0, 0) ; -// G4ThreeVector MMu = G4ThreeVector(0, 0, 0) ; -// G4ThreeVector MMv = G4ThreeVector(0, 0, 0) ; - G4ThreeVector MMw = G4ThreeVector(0, 0, 0) ; -// G4ThreeVector MMCenter = G4ThreeVector(0, 0, 0) ; - bool FirstStage = true ; - bool SecondStage = true ; - bool ThirdStage = true ; - - G4int NumberOfTelescope = m_DefinitionType.size() ; - - for (G4int i = 0; i < NumberOfTelescope; i++) { - // By Point - if (m_DefinitionType[i]) { - // (u,v,w) unitary vector associated to telescope referencial - // (u,v) // to silicon plan - // w perpendicular to (u,v) plan and pointing ThirdStage - MMu = m_X128_Y1[i] - m_X1_Y1[i]; - MMu = MMu.unit(); - - MMv = m_X1_Y128[i] - m_X1_Y1[i]; - MMv = MMv.unit(); - MMw = MMu.cross(MMv); - MMw = MMw.unit(); - - MMCenter = (m_X1_Y1[i] + m_X1_Y128[i] + m_X128_Y1[i] + m_X128_Y128[i]) / 4; - - // Passage Matrix from Lab Referential to Telescope Referential - MMrot = new G4RotationMatrix(MMu, MMv, MMw); - // translation to place Telescope - MMpos = MMw * Length * 0.5 + MMCenter; - } +void GaspardTrackerDummyShape::ConstructDetector(G4LogicalVolume* world) { + G4RotationMatrix* MMrot = NULL; + G4ThreeVector MMpos = G4ThreeVector(0, 0, 0); + // G4ThreeVector MMu = G4ThreeVector(0, 0, 0) ; + // G4ThreeVector MMv = G4ThreeVector(0, 0, 0) ; + G4ThreeVector MMw = G4ThreeVector(0, 0, 0); + // G4ThreeVector MMCenter = G4ThreeVector(0, 0, 0) ; + bool FirstStage = true; + bool SecondStage = true; + bool ThirdStage = true; + + G4int NumberOfTelescope = m_DefinitionType.size(); + + for (G4int i = 0; i < NumberOfTelescope; i++) { + // By Point + if (m_DefinitionType[i]) { + // (u,v,w) unitary vector associated to telescope referencial + // (u,v) // to silicon plan + // w perpendicular to (u,v) plan and pointing ThirdStage + MMu = m_X128_Y1[i] - m_X1_Y1[i]; + MMu = MMu.unit(); + + MMv = m_X1_Y128[i] - m_X1_Y1[i]; + MMv = MMv.unit(); + MMw = MMu.cross(MMv); + MMw = MMw.unit(); + + MMCenter = (m_X1_Y1[i] + m_X1_Y128[i] + m_X128_Y1[i] + m_X128_Y128[i]) / 4; + + // Passage Matrix from Lab Referential to Telescope Referential + MMrot = new G4RotationMatrix(MMu, MMv, MMw); + // translation to place Telescope + MMpos = MMw * Length * 0.5 + MMCenter; + } - // By Angle - else { - G4double Theta = m_Theta[i] ; - G4double Phi = m_Phi[i] ; - - // (u,v,w) unitary vector associated to telescope referencial - // (u,v) // to silicon plan - // w perpendicular to (u,v) plan and pointing ThirdStage - // Phi is angle between X axis and projection in (X,Y) plan - // Theta is angle between position vector and z axis - G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad); - G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad); - G4double wZ = m_R[i] * cos(Theta / rad); - MMw = G4ThreeVector(wX, wY, wZ); - - // vector corresponding to the center of the module - MMCenter = MMw; - - // vector parallel to one axis of silicon plane - G4double ii = cos(Theta / rad) * cos(Phi / rad); - G4double jj = cos(Theta / rad) * sin(Phi / rad); - G4double kk = -sin(Theta / rad); - G4ThreeVector Y = G4ThreeVector(ii, jj, kk); - - MMw = MMw.unit(); - MMu = MMw.cross(Y); - MMv = MMw.cross(MMu); - MMv = MMv.unit(); - MMu = MMu.unit(); - - // Passage Matrix from Lab Referential to Telescope Referential - MMrot = new G4RotationMatrix(MMu, MMv, MMw); - // Telescope is rotate of Beta angle around MMv axis. - MMrot->rotate(m_beta_u[i], MMu); - MMrot->rotate(m_beta_v[i], MMv); - MMrot->rotate(m_beta_w[i], MMw); - // translation to place Telescope - MMpos = MMw * Length * 0.5 + MMCenter; - } + // By Angle + else { + G4double Theta = m_Theta[i]; + G4double Phi = m_Phi[i]; + + // (u,v,w) unitary vector associated to telescope referencial + // (u,v) // to silicon plan + // w perpendicular to (u,v) plan and pointing ThirdStage + // Phi is angle between X axis and projection in (X,Y) plan + // Theta is angle between position vector and z axis + G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad); + G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad); + G4double wZ = m_R[i] * cos(Theta / rad); + MMw = G4ThreeVector(wX, wY, wZ); + + // vector corresponding to the center of the module + MMCenter = MMw; + + // vector parallel to one axis of silicon plane + G4double ii = cos(Theta / rad) * cos(Phi / rad); + G4double jj = cos(Theta / rad) * sin(Phi / rad); + G4double kk = -sin(Theta / rad); + G4ThreeVector Y = G4ThreeVector(ii, jj, kk); + + MMw = MMw.unit(); + MMu = MMw.cross(Y); + MMv = MMw.cross(MMu); + MMv = MMv.unit(); + MMu = MMu.unit(); + + // Passage Matrix from Lab Referential to Telescope Referential + MMrot = new G4RotationMatrix(MMu, MMv, MMw); + // Telescope is rotate of Beta angle around MMv axis. + MMrot->rotate(m_beta_u[i], MMu); + MMrot->rotate(m_beta_v[i], MMv); + MMrot->rotate(m_beta_w[i], MMw); + // translation to place Telescope + MMpos = MMw * Length * 0.5 + MMCenter; + } - FirstStage = m_wFirstStage[i] ; - SecondStage = m_wSecondStage[i] ; - ThirdStage = m_wThirdStage[i] ; + FirstStage = m_wFirstStage[i]; + SecondStage = m_wSecondStage[i]; + ThirdStage = m_wThirdStage[i]; - VolumeMaker(i + 1, MMpos, MMrot, FirstStage, SecondStage, ThirdStage, world); - } + VolumeMaker(i + 1, MMpos, MMrot, FirstStage, SecondStage, ThirdStage, world); + } - delete MMrot ; + delete MMrot; } - - // Connect the GaspardTrackingData class to the output TTree // of the simulation -void GaspardTrackerDummyShape::InitializeRootOutput() -{ -} +void GaspardTrackerDummyShape::InitializeRootOutput() {} +// Set the TinteractionCoordinates object from NPS::VDetector to the present class +void GaspardTrackerDummyShape::SetInterCoordPointer(TInteractionCoordinates* interCoord) { ms_InterCoord = interCoord; } +// Read sensitive part and fill the Root tree. +// Called at in the EventAction::EndOfEventAvtion +void GaspardTrackerDummyShape::ReadSensitive(const G4Event* event) { + ////////////////////////////////////////////////////////////////////////////////////// + //////////////////////// Used to Read Event Map of detector ////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + // First Stage + std::map<G4int, G4int*>::iterator DetectorNumber_itr; + std::map<G4int, G4double*>::iterator Energy_itr; + std::map<G4int, G4double*>::iterator Time_itr; + std::map<G4int, G4int*>::iterator X_itr; + std::map<G4int, G4int*>::iterator Y_itr; + std::map<G4int, G4double*>::iterator Pos_X_itr; + std::map<G4int, G4double*>::iterator Pos_Y_itr; + std::map<G4int, G4double*>::iterator Pos_Z_itr; + std::map<G4int, G4double*>::iterator Ang_Theta_itr; + std::map<G4int, G4double*>::iterator Ang_Phi_itr; + + NPS::HitsMap<G4int>* DetectorNumberHitMap; + NPS::HitsMap<G4double>* EnergyHitMap; + NPS::HitsMap<G4double>* TimeHitMap; + NPS::HitsMap<G4int>* XHitMap; + NPS::HitsMap<G4int>* YHitMap; + NPS::HitsMap<G4double>* PosXHitMap; + NPS::HitsMap<G4double>* PosYHitMap; + NPS::HitsMap<G4double>* PosZHitMap; + NPS::HitsMap<G4double>* AngThetaHitMap; + NPS::HitsMap<G4double>* AngPhiHitMap; + + // NULL pointer are given to avoid warning at compilation + // Second Stage + std::map<G4int, G4double*>::iterator SecondStageEnergy_itr; + NPS::HitsMap<G4double>* SecondStageEnergyHitMap = NULL; + // Third Stage + std::map<G4int, G4double*>::iterator ThirdStageEnergy_itr; + NPS::HitsMap<G4double>* ThirdStageEnergyHitMap = NULL; + + // Read the Scorer associate to the Silicon Strip + // Detector Number + G4int StripDetCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/DetectorNumber"); + DetectorNumberHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripDetCollectionID)); + DetectorNumber_itr = DetectorNumberHitMap->GetMap()->begin(); + + // Energy + G4int StripEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/StripEnergy"); + EnergyHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripEnergyCollectionID)); + Energy_itr = EnergyHitMap->GetMap()->begin(); + + // Time of Flight + G4int StripTimeCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/StripTime"); + TimeHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripTimeCollectionID)); + Time_itr = TimeHitMap->GetMap()->begin(); + + // Strip Number X + G4int StripXCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/StripIDFront"); + XHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripXCollectionID)); + X_itr = XHitMap->GetMap()->begin(); + + // Strip Number Y + G4int StripYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/StripIDBack"); + YHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripYCollectionID)); + Y_itr = YHitMap->GetMap()->begin(); + + // Interaction Coordinate X + G4int InterCoordXCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/InterCoordX"); + PosXHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordXCollectionID)); + Pos_X_itr = PosXHitMap->GetMap()->begin(); + + // Interaction Coordinate Y + G4int InterCoordYCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/InterCoordY"); + PosYHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordYCollectionID)); + Pos_Y_itr = PosYHitMap->GetMap()->begin(); + + // Interaction Coordinate Z + G4int InterCoordZCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/InterCoordZ"); + PosZHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordZCollectionID)); + Pos_Z_itr = PosXHitMap->GetMap()->begin(); + + // Interaction Coordinate Angle Theta + G4int InterCoordAngThetaCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/InterCoordAngTheta"); + AngThetaHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngThetaCollectionID)); + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); + + // Interaction Coordinate Angle Phi + G4int InterCoordAngPhiCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/InterCoordAngPhi"); + AngPhiHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngPhiCollectionID)); + Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); + + // Read the Scorer associate to the SecondStage + // Energy + G4int SecondStageEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("SecondStageScorerGPDDummyShape/SecondStageEnergy"); + SecondStageEnergyHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(SecondStageEnergyCollectionID)); + SecondStageEnergy_itr = SecondStageEnergyHitMap->GetMap()->begin(); + + // Read the Scorer associate to the ThirdStage + // Energy + G4int ThirdStageEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("ThirdStageScorerGPDDummyShape/ThirdStageEnergy"); + ThirdStageEnergyHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(ThirdStageEnergyCollectionID)); + ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin(); + + // Check the size of different map + G4int sizeN = DetectorNumberHitMap->entries(); + G4int sizeE = EnergyHitMap->entries(); + G4int sizeT = TimeHitMap->entries(); + G4int sizeX = XHitMap->entries(); + G4int sizeY = YHitMap->entries(); + + // G4cout << "sizeN:" << sizeN << G4endl; + + if (sizeE != sizeT || sizeT != sizeX || sizeX != sizeY) { + G4cout << "No match size Si Event Map: sE:" << sizeE << " sT:" << sizeT << " sX:" << sizeX << " sY:" << sizeY + << G4endl; + return; + } + + // Loop on FirstStage number + for (G4int l = 0; l < sizeN; l++) { + G4double N = *(DetectorNumber_itr->second); + G4int NTrackID = DetectorNumber_itr->first - N; + + if (N > 0) { + // Fill detector number + ms_Event->SetGPDTrkFirstStageFrontEDetectorNbr(m_index["DummyShape"] + N); + ms_Event->SetGPDTrkFirstStageFrontTDetectorNbr(m_index["DummyShape"] + N); + ms_Event->SetGPDTrkFirstStageBackEDetectorNbr(m_index["DummyShape"] + N); + ms_Event->SetGPDTrkFirstStageBackTDetectorNbr(m_index["DummyShape"] + N); + + // Energy + Energy_itr = EnergyHitMap->GetMap()->begin(); + for (G4int ll = 0; ll < sizeE; ll++) { + G4int ETrackID = Energy_itr->first - N; + G4double E = *(Energy_itr->second); + if (ETrackID == NTrackID) { + ms_Event->SetGPDTrkFirstStageFrontEEnergy(RandGauss::shoot(E, ResoFirstStage)); + ms_Event->SetGPDTrkFirstStageBackEEnergy(RandGauss::shoot(E, ResoFirstStage)); + } + Energy_itr++; + } -// Set the TinteractionCoordinates object from NPS::VDetector to the present class -void GaspardTrackerDummyShape::SetInterCoordPointer(TInteractionCoordinates* interCoord) -{ - ms_InterCoord = interCoord; -} + // Time + Time_itr = TimeHitMap->GetMap()->begin(); + for (G4int h = 0; h < sizeT; h++) { + G4int TTrackID = Time_itr->first - N; + G4double T = *(Time_itr->second); + if (TTrackID == NTrackID) { + ms_Event->SetGPDTrkFirstStageFrontTTime(RandGauss::shoot(T, ResoTimeGpd)); + ms_Event->SetGPDTrkFirstStageBackTTime(RandGauss::shoot(T, ResoTimeGpd)); + } + Time_itr++; + } + // Strip X + X_itr = XHitMap->GetMap()->begin(); + for (G4int h = 0; h < sizeX; h++) { + G4int XTrackID = X_itr->first - N; + G4int X = *(X_itr->second); + if (XTrackID == NTrackID) { + ms_Event->SetGPDTrkFirstStageFrontEStripNbr(X); + ms_Event->SetGPDTrkFirstStageFrontTStripNbr(X); + } + X_itr++; + } + // Strip Y + Y_itr = YHitMap->GetMap()->begin(); + for (G4int h = 0; h < sizeY; h++) { + G4int YTrackID = Y_itr->first - N; + G4int Y = *(Y_itr->second); + if (YTrackID == NTrackID) { + ms_Event->SetGPDTrkFirstStageBackEStripNbr(Y); + ms_Event->SetGPDTrkFirstStageBackTStripNbr(Y); + } + Y_itr++; + } -// Read sensitive part and fill the Root tree. -// Called at in the EventAction::EndOfEventAvtion -void GaspardTrackerDummyShape::ReadSensitive(const G4Event* event) -{ - ////////////////////////////////////////////////////////////////////////////////////// - //////////////////////// Used to Read Event Map of detector ////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - // First Stage - std::map<G4int, G4int*>::iterator DetectorNumber_itr; - std::map<G4int, G4double*>::iterator Energy_itr; - std::map<G4int, G4double*>::iterator Time_itr; - std::map<G4int, G4int*>::iterator X_itr; - std::map<G4int, G4int*>::iterator Y_itr; - std::map<G4int, G4double*>::iterator Pos_X_itr; - std::map<G4int, G4double*>::iterator Pos_Y_itr; - std::map<G4int, G4double*>::iterator Pos_Z_itr; - std::map<G4int, G4double*>::iterator Ang_Theta_itr; - std::map<G4int, G4double*>::iterator Ang_Phi_itr; - - NPS::HitsMap<G4int>* DetectorNumberHitMap; - NPS::HitsMap<G4double>* EnergyHitMap; - NPS::HitsMap<G4double>* TimeHitMap; - NPS::HitsMap<G4int>* XHitMap; - NPS::HitsMap<G4int>* YHitMap; - NPS::HitsMap<G4double>* PosXHitMap; - NPS::HitsMap<G4double>* PosYHitMap; - NPS::HitsMap<G4double>* PosZHitMap; - NPS::HitsMap<G4double>* AngThetaHitMap; - NPS::HitsMap<G4double>* AngPhiHitMap; - - // NULL pointer are given to avoid warning at compilation - // Second Stage - std::map<G4int, G4double*>::iterator SecondStageEnergy_itr ; - NPS::HitsMap<G4double>* SecondStageEnergyHitMap = NULL ; - // Third Stage - std::map<G4int, G4double*>::iterator ThirdStageEnergy_itr ; - NPS::HitsMap<G4double>* ThirdStageEnergyHitMap = NULL ; - - - // Read the Scorer associate to the Silicon Strip - //Detector Number - G4int StripDetCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/DetectorNumber") ; - DetectorNumberHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripDetCollectionID)) ; - DetectorNumber_itr = DetectorNumberHitMap->GetMap()->begin() ; - - //Energy - G4int StripEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/StripEnergy") ; - EnergyHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripEnergyCollectionID)) ; - Energy_itr = EnergyHitMap->GetMap()->begin() ; - - //Time of Flight - G4int StripTimeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/StripTime") ; - TimeHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripTimeCollectionID)) ; - Time_itr = TimeHitMap->GetMap()->begin() ; - - //Strip Number X - G4int StripXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/StripIDFront") ; - XHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripXCollectionID)) ; - X_itr = XHitMap->GetMap()->begin() ; - - //Strip Number Y - G4int StripYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/StripIDBack"); - YHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripYCollectionID)) ; - Y_itr = YHitMap->GetMap()->begin() ; - - //Interaction Coordinate X - G4int InterCoordXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/InterCoordX") ; - PosXHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordXCollectionID)) ; - Pos_X_itr = PosXHitMap->GetMap()->begin() ; - - //Interaction Coordinate Y - G4int InterCoordYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/InterCoordY") ; - PosYHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordYCollectionID)) ; - Pos_Y_itr = PosYHitMap->GetMap()->begin() ; - - //Interaction Coordinate Z - G4int InterCoordZCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/InterCoordZ") ; - PosZHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordZCollectionID)) ; - Pos_Z_itr = PosXHitMap->GetMap()->begin() ; - - //Interaction Coordinate Angle Theta - G4int InterCoordAngThetaCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/InterCoordAngTheta") ; - AngThetaHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngThetaCollectionID)) ; - Ang_Theta_itr = AngThetaHitMap->GetMap()->begin() ; - - //Interaction Coordinate Angle Phi - G4int InterCoordAngPhiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/InterCoordAngPhi") ; - AngPhiHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngPhiCollectionID)) ; - Ang_Phi_itr = AngPhiHitMap->GetMap()->begin() ; - - - // Read the Scorer associate to the SecondStage - //Energy - G4int SecondStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("SecondStageScorerGPDDummyShape/SecondStageEnergy") ; - SecondStageEnergyHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(SecondStageEnergyCollectionID)) ; - SecondStageEnergy_itr = SecondStageEnergyHitMap->GetMap()->begin() ; - - - // Read the Scorer associate to the ThirdStage - //Energy - G4int ThirdStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ThirdStageScorerGPDDummyShape/ThirdStageEnergy"); - ThirdStageEnergyHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(ThirdStageEnergyCollectionID)); - ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin(); - - - // Check the size of different map - G4int sizeN = DetectorNumberHitMap->entries(); - G4int sizeE = EnergyHitMap->entries(); - G4int sizeT = TimeHitMap->entries(); - G4int sizeX = XHitMap->entries(); - G4int sizeY = YHitMap->entries(); - - - //G4cout << "sizeN:" << sizeN << G4endl; - - if (sizeE != sizeT || sizeT != sizeX || sizeX != sizeY) { - G4cout << "No match size Si Event Map: sE:" - << sizeE << " sT:" << sizeT << " sX:" << sizeX << " sY:" << sizeY << G4endl ; - return; - } - - // Loop on FirstStage number - for (G4int l = 0; l < sizeN; l++) { - G4double N = *(DetectorNumber_itr->second); - G4int NTrackID = DetectorNumber_itr->first - N; - - if (N > 0) { - // Fill detector number - ms_Event->SetGPDTrkFirstStageFrontEDetectorNbr(m_index["DummyShape"] + N); - ms_Event->SetGPDTrkFirstStageFrontTDetectorNbr(m_index["DummyShape"] + N); - ms_Event->SetGPDTrkFirstStageBackEDetectorNbr(m_index["DummyShape"] + N); - ms_Event->SetGPDTrkFirstStageBackTDetectorNbr(m_index["DummyShape"] + N); - - // Energy - Energy_itr = EnergyHitMap->GetMap()->begin(); - for (G4int ll = 0 ; ll < sizeE ; ll++) { - G4int ETrackID = Energy_itr->first - N; - G4double E = *(Energy_itr->second); - if (ETrackID == NTrackID) { - ms_Event->SetGPDTrkFirstStageFrontEEnergy(RandGauss::shoot(E, ResoFirstStage)); - ms_Event->SetGPDTrkFirstStageBackEEnergy(RandGauss::shoot(E, ResoFirstStage)); - } - Energy_itr++; - } - - // Time - Time_itr = TimeHitMap->GetMap()->begin(); - for (G4int h = 0 ; h < sizeT ; h++) { - G4int TTrackID = Time_itr->first - N; - G4double T = *(Time_itr->second); - if (TTrackID == NTrackID) { - ms_Event->SetGPDTrkFirstStageFrontTTime(RandGauss::shoot(T, ResoTimeGpd)); - ms_Event->SetGPDTrkFirstStageBackTTime(RandGauss::shoot(T, ResoTimeGpd)); - } - Time_itr++; - } - - // Strip X - X_itr = XHitMap->GetMap()->begin(); - for (G4int h = 0 ; h < sizeX ; h++) { - G4int XTrackID = X_itr->first - N; - G4int X = *(X_itr->second); - if (XTrackID == NTrackID) { - ms_Event->SetGPDTrkFirstStageFrontEStripNbr(X); - ms_Event->SetGPDTrkFirstStageFrontTStripNbr(X); - } - X_itr++; - } - - // Strip Y - Y_itr = YHitMap->GetMap()->begin() ; - for (G4int h = 0 ; h < sizeY ; h++) { - G4int YTrackID = Y_itr->first - N; - G4int Y = *(Y_itr->second); - if (YTrackID == NTrackID) { - ms_Event->SetGPDTrkFirstStageBackEStripNbr(Y); - ms_Event->SetGPDTrkFirstStageBackTStripNbr(Y); - } - Y_itr++; - } - - // Pos X - Pos_X_itr = PosXHitMap->GetMap()->begin(); - for (G4int h = 0; h < PosXHitMap->entries(); h++) { - G4int PosXTrackID = Pos_X_itr->first - N ; - G4double PosX = *(Pos_X_itr->second) ; - if (PosXTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionX(PosX) ; - } - Pos_X_itr++; - } - - // Pos Y - Pos_Y_itr = PosYHitMap->GetMap()->begin(); - for (G4int h = 0 ; h < PosYHitMap->entries(); h++) { - G4int PosYTrackID = Pos_Y_itr->first - N ; - G4double PosY = *(Pos_Y_itr->second) ; - if (PosYTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionY(PosY) ; - } - Pos_Y_itr++; - } - - // Pos Z - Pos_Z_itr = PosZHitMap->GetMap()->begin(); - for (G4int h = 0 ; h < PosZHitMap->entries(); h++) { - G4int PosZTrackID = Pos_Z_itr->first - N ; - G4double PosZ = *(Pos_Z_itr->second) ; - if (PosZTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionZ(PosZ) ; - } - Pos_Z_itr++; - } - - // Angle Theta - Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); - for (G4int h = 0; h < AngThetaHitMap->entries(); h++) { - G4int AngThetaTrackID = Ang_Theta_itr->first - N ; - G4double AngTheta = *(Ang_Theta_itr->second) ; - if (AngThetaTrackID == NTrackID) { - ms_InterCoord->SetDetectedAngleTheta(AngTheta) ; - } - Ang_Theta_itr++; - } - - // Angle Phi - Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); - for (G4int h = 0; h < AngPhiHitMap->entries(); h++) { - G4int AngPhiTrackID = Ang_Phi_itr->first - N ; - G4double AngPhi = *(Ang_Phi_itr->second) ; - if (AngPhiTrackID == NTrackID) { - ms_InterCoord->SetDetectedAnglePhi(AngPhi) ; - } - Ang_Phi_itr++; - } - - // Second Stage - SecondStageEnergy_itr = SecondStageEnergyHitMap->GetMap()->begin() ; - for (G4int h = 0 ; h < SecondStageEnergyHitMap->entries() ; h++) { - G4int SecondStageEnergyTrackID = SecondStageEnergy_itr->first - N; - G4double SecondStageEnergy = *(SecondStageEnergy_itr->second); - - if (SecondStageEnergyTrackID == NTrackID) { - ms_Event->SetGPDTrkSecondStageEEnergy(RandGauss::shoot(SecondStageEnergy, ResoSecondStage)) ; - ms_Event->SetGPDTrkSecondStageEPadNbr(1); - ms_Event->SetGPDTrkSecondStageTPadNbr(1); - ms_Event->SetGPDTrkSecondStageTTime(1); - ms_Event->SetGPDTrkSecondStageTDetectorNbr(m_index["DummyShape"] + N); - ms_Event->SetGPDTrkSecondStageEDetectorNbr(m_index["DummyShape"] + N); - } - SecondStageEnergy_itr++; - } - - // Third Stage - ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin() ; - for (G4int h = 0 ; h < ThirdStageEnergyHitMap->entries() ; h++) { - G4int ThirdStageEnergyTrackID = ThirdStageEnergy_itr->first - N; - G4double ThirdStageEnergy = *(ThirdStageEnergy_itr->second); - - if (ThirdStageEnergyTrackID == NTrackID) { - ms_Event->SetGPDTrkThirdStageEEnergy(RandGauss::shoot(ThirdStageEnergy, ResoThirdStage)); - ms_Event->SetGPDTrkThirdStageEPadNbr(1); - ms_Event->SetGPDTrkThirdStageTPadNbr(1); - ms_Event->SetGPDTrkThirdStageTTime(1); - ms_Event->SetGPDTrkThirdStageTDetectorNbr(m_index["DummyShape"] + N); - ms_Event->SetGPDTrkThirdStageEDetectorNbr(m_index["DummyShape"] + N); - } - ThirdStageEnergy_itr++; - } + // Pos X + Pos_X_itr = PosXHitMap->GetMap()->begin(); + for (G4int h = 0; h < PosXHitMap->entries(); h++) { + G4int PosXTrackID = Pos_X_itr->first - N; + G4double PosX = *(Pos_X_itr->second); + if (PosXTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionX(PosX); + } + Pos_X_itr++; + } + // Pos Y + Pos_Y_itr = PosYHitMap->GetMap()->begin(); + for (G4int h = 0; h < PosYHitMap->entries(); h++) { + G4int PosYTrackID = Pos_Y_itr->first - N; + G4double PosY = *(Pos_Y_itr->second); + if (PosYTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionY(PosY); + } + Pos_Y_itr++; } - DetectorNumber_itr++; - - - } - // clear map for next event - DetectorNumberHitMap -> clear(); - EnergyHitMap -> clear(); - TimeHitMap -> clear(); - XHitMap -> clear(); - YHitMap -> clear(); - PosXHitMap -> clear(); - PosYHitMap -> clear(); - PosZHitMap -> clear(); - AngThetaHitMap -> clear(); - AngPhiHitMap -> clear(); - SecondStageEnergyHitMap -> clear(); - ThirdStageEnergyHitMap -> clear(); -} + // Pos Z + Pos_Z_itr = PosZHitMap->GetMap()->begin(); + for (G4int h = 0; h < PosZHitMap->entries(); h++) { + G4int PosZTrackID = Pos_Z_itr->first - N; + G4double PosZ = *(Pos_Z_itr->second); + if (PosZTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionZ(PosZ); + } + Pos_Z_itr++; + } + // Angle Theta + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); + for (G4int h = 0; h < AngThetaHitMap->entries(); h++) { + G4int AngThetaTrackID = Ang_Theta_itr->first - N; + G4double AngTheta = *(Ang_Theta_itr->second); + if (AngThetaTrackID == NTrackID) { + ms_InterCoord->SetDetectedAngleTheta(AngTheta); + } + Ang_Theta_itr++; + } + + // Angle Phi + Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); + for (G4int h = 0; h < AngPhiHitMap->entries(); h++) { + G4int AngPhiTrackID = Ang_Phi_itr->first - N; + G4double AngPhi = *(Ang_Phi_itr->second); + if (AngPhiTrackID == NTrackID) { + ms_InterCoord->SetDetectedAnglePhi(AngPhi); + } + Ang_Phi_itr++; + } + + // Second Stage + SecondStageEnergy_itr = SecondStageEnergyHitMap->GetMap()->begin(); + for (G4int h = 0; h < SecondStageEnergyHitMap->entries(); h++) { + G4int SecondStageEnergyTrackID = SecondStageEnergy_itr->first - N; + G4double SecondStageEnergy = *(SecondStageEnergy_itr->second); + + if (SecondStageEnergyTrackID == NTrackID) { + ms_Event->SetGPDTrkSecondStageEEnergy(RandGauss::shoot(SecondStageEnergy, ResoSecondStage)); + ms_Event->SetGPDTrkSecondStageEPadNbr(1); + ms_Event->SetGPDTrkSecondStageTPadNbr(1); + ms_Event->SetGPDTrkSecondStageTTime(1); + ms_Event->SetGPDTrkSecondStageTDetectorNbr(m_index["DummyShape"] + N); + ms_Event->SetGPDTrkSecondStageEDetectorNbr(m_index["DummyShape"] + N); + } + SecondStageEnergy_itr++; + } + + // Third Stage + ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin(); + for (G4int h = 0; h < ThirdStageEnergyHitMap->entries(); h++) { + G4int ThirdStageEnergyTrackID = ThirdStageEnergy_itr->first - N; + G4double ThirdStageEnergy = *(ThirdStageEnergy_itr->second); + + if (ThirdStageEnergyTrackID == NTrackID) { + ms_Event->SetGPDTrkThirdStageEEnergy(RandGauss::shoot(ThirdStageEnergy, ResoThirdStage)); + ms_Event->SetGPDTrkThirdStageEPadNbr(1); + ms_Event->SetGPDTrkThirdStageTPadNbr(1); + ms_Event->SetGPDTrkThirdStageTTime(1); + ms_Event->SetGPDTrkThirdStageTDetectorNbr(m_index["DummyShape"] + N); + ms_Event->SetGPDTrkThirdStageEDetectorNbr(m_index["DummyShape"] + N); + } + ThirdStageEnergy_itr++; + } + } + DetectorNumber_itr++; + } + // clear map for next event + DetectorNumberHitMap->clear(); + EnergyHitMap->clear(); + TimeHitMap->clear(); + XHitMap->clear(); + YHitMap->clear(); + PosXHitMap->clear(); + PosYHitMap->clear(); + PosZHitMap->clear(); + AngThetaHitMap->clear(); + AngPhiHitMap->clear(); + SecondStageEnergyHitMap->clear(); + ThirdStageEnergyHitMap->clear(); +} -void GaspardTrackerDummyShape::InitializeScorers() -{ - bool already_exist = false; - m_FirstStageScorer = NPS::VDetector::CheckScorer("FirstStageScorerGPDDummyShape", already_exist); - m_SecondStageScorer = NPS::VDetector::CheckScorer("SecondStageScorerGPDDummyShape",already_exist); - m_ThirdStageScorer = NPS::VDetector::CheckScorer("ThirdStageScorerGPDDummyShape",already_exist); - if(already_exist) return; - - // First stage Associate Scorer - G4VPrimitiveScorer* DetNbr = new OBSOLETEGENERALSCORERS::PSDetectorNumber("DetectorNumber", "GPDDummyShape", 0); - G4VPrimitiveScorer* TOF = new OBSOLETEGENERALSCORERS::PSTOF("StripTime","GPDDummyShape", 0); - G4VPrimitiveScorer* InteractionCoordinatesX = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesX("InterCoordX","GPDDummyShape", 0); - G4VPrimitiveScorer* InteractionCoordinatesY = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesY("InterCoordY","GPDDummyShape", 0); - G4VPrimitiveScorer* InteractionCoordinatesZ = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ","GPDDummyShape", 0); - G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta","GPDDummyShape", 0); - G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi","GPDDummyShape", 0); - G4VPrimitiveScorer* Energy = new GPDScorerFirstStageEnergy("StripEnergy", "GPDDummyShape", 0); - G4VPrimitiveScorer* StripPositionX = new GPDScorerFirstStageFrontStripDummyShape("StripIDFront", 0, NumberOfStrips); - G4VPrimitiveScorer* StripPositionY = new GPDScorerFirstStageBackStripDummyShape("StripIDBack", 0, NumberOfStrips); - - //and register it to the multifunctionnal detector - m_FirstStageScorer->RegisterPrimitive(DetNbr); - m_FirstStageScorer->RegisterPrimitive(Energy); - m_FirstStageScorer->RegisterPrimitive(TOF); - m_FirstStageScorer->RegisterPrimitive(StripPositionX); - m_FirstStageScorer->RegisterPrimitive(StripPositionY); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesX); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesY); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesZ); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAngleTheta); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAnglePhi); - - - // Second stage Associate Scorer - G4VPrimitiveScorer* SecondStageEnergy = new GPDScorerSecondStageEnergy("SecondStageEnergy", "GPDDummyShape", 0); - m_SecondStageScorer->RegisterPrimitive(SecondStageEnergy); - - - // Third stage Associate Scorer - G4VPrimitiveScorer* ThirdStageEnergy = new GPDScorerThirdStageEnergy("ThirdStageEnergy", "GPDDummyShape", 0); - m_ThirdStageScorer->RegisterPrimitive(ThirdStageEnergy); - - - // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_FirstStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_SecondStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_ThirdStageScorer); +void GaspardTrackerDummyShape::InitializeScorers() { + bool already_exist = false; + m_FirstStageScorer = NPS::VDetector::CheckScorer("FirstStageScorerGPDDummyShape", already_exist); + m_SecondStageScorer = NPS::VDetector::CheckScorer("SecondStageScorerGPDDummyShape", already_exist); + m_ThirdStageScorer = NPS::VDetector::CheckScorer("ThirdStageScorerGPDDummyShape", already_exist); + if (already_exist) + return; + + // First stage Associate Scorer + G4VPrimitiveScorer* DetNbr = new OBSOLETEGENERALSCORERS::PSDetectorNumber("DetectorNumber", "GPDDummyShape", 0); + G4VPrimitiveScorer* TOF = new OBSOLETEGENERALSCORERS::PSTOF("StripTime", "GPDDummyShape", 0); + G4VPrimitiveScorer* InteractionCoordinatesX = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesX("InterCoordX", "GPDDummyShape", 0); + G4VPrimitiveScorer* InteractionCoordinatesY = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesY("InterCoordY", "GPDDummyShape", 0); + G4VPrimitiveScorer* InteractionCoordinatesZ = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ", "GPDDummyShape", 0); + G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta", "GPDDummyShape", 0); + G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi", "GPDDummyShape", 0); + G4VPrimitiveScorer* Energy = new GPDScorerFirstStageEnergy("StripEnergy", "GPDDummyShape", 0); + G4VPrimitiveScorer* StripPositionX = new GPDScorerFirstStageFrontStripDummyShape("StripIDFront", 0, NumberOfStrips); + G4VPrimitiveScorer* StripPositionY = new GPDScorerFirstStageBackStripDummyShape("StripIDBack", 0, NumberOfStrips); + + // and register it to the multifunctionnal detector + m_FirstStageScorer->RegisterPrimitive(DetNbr); + m_FirstStageScorer->RegisterPrimitive(Energy); + m_FirstStageScorer->RegisterPrimitive(TOF); + m_FirstStageScorer->RegisterPrimitive(StripPositionX); + m_FirstStageScorer->RegisterPrimitive(StripPositionY); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesX); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesY); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesZ); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAngleTheta); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAnglePhi); + + // Second stage Associate Scorer + G4VPrimitiveScorer* SecondStageEnergy = new GPDScorerSecondStageEnergy("SecondStageEnergy", "GPDDummyShape", 0); + m_SecondStageScorer->RegisterPrimitive(SecondStageEnergy); + + // Third stage Associate Scorer + G4VPrimitiveScorer* ThirdStageEnergy = new GPDScorerThirdStageEnergy("ThirdStageEnergy", "GPDDummyShape", 0); + m_ThirdStageScorer->RegisterPrimitive(ThirdStageEnergy); + + // Add All Scorer to the Global Scorer Manager + G4SDManager::GetSDMpointer()->AddNewDetector(m_FirstStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_SecondStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_ThirdStageScorer); } diff --git a/NPSimulation/Detectors/GeTAMU/GeTAMU.cc b/NPSimulation/Detectors/GeTAMU/GeTAMU.cc index 39fb0f2db..7fbf81099 100644 --- a/NPSimulation/Detectors/GeTAMU/GeTAMU.cc +++ b/NPSimulation/Detectors/GeTAMU/GeTAMU.cc @@ -20,37 +20,36 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> -//G4 Geometry object +#include <sstream> +// G4 Geometry object #include "G4Box.hh" -#include "G4Tubs.hh" -#include "G4Trd.hh" -#include "G4Trap.hh" #include "G4Cons.hh" +#include "G4Trap.hh" +#include "G4Trd.hh" +#include "G4Tubs.hh" -//G4 sensitive -#include "G4SDManager.hh" +// G4 sensitive #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" -//G4 various object +// G4 various object +#include "G4Colour.hh" +#include "G4IntersectionSolid.hh" +#include "G4LogicalVolume.hh" #include "G4Material.hh" +#include "G4PVPlacement.hh" #include "G4Polycone.hh" #include "G4Polyhedra.hh" -#include "G4LogicalVolume.hh" -#include "G4ThreeVector.hh" -#include "G4Transform3D.hh" #include "G4RotationMatrix.hh" -#include "G4PVPlacement.hh" -#include "G4VisAttributes.hh" -#include "G4Colour.hh" #include "G4RunManager.hh" -#include "G4ios.hh" #include "G4SubtractionSolid.hh" -#include "G4IntersectionSolid.hh" -#include "G4UnionSolid.hh" #include "G4ThreeVector.hh" +#include "G4Transform3D.hh" +#include "G4UnionSolid.hh" +#include "G4VisAttributes.hh" +#include "G4ios.hh" // NPS #include "GeTAMU.hh" @@ -73,75 +72,74 @@ using namespace CLHEP; namespace { -// Ge crystal -// Cylindrical part -const G4double CrystalOuterRadius = 30.0*mm; // outer radius for crystal -const G4double CrystalInnerRadius = 5.0*mm; // inner radius for hole in crystal -const G4double CrystalLength = 90.0*mm; // crystal length -const G4double CrystalHoleDepth = 15.0*mm; // depth at which starts the hole -//const G4double CrystaHoleRadius = 0*cm; -//const G4double CrystalInterDistance = 0.6*mm; // Distance between two crystal + // Ge crystal + // Cylindrical part + const G4double CrystalOuterRadius = 30.0 * mm; // outer radius for crystal + const G4double CrystalInnerRadius = 5.0 * mm; // inner radius for hole in crystal + const G4double CrystalLength = 90.0 * mm; // crystal length + const G4double CrystalHoleDepth = 15.0 * mm; // depth at which starts the hole + // const G4double CrystaHoleRadius = 0*cm; + // const G4double CrystalInterDistance = 0.6*mm; // Distance between two crystal -// Squared part -const G4double CrystalWidth = 56.5*mm; // Width of one crystal + // Squared part + const G4double CrystalWidth = 56.5 * mm; // Width of one crystal -// Exogam Stuff -const G4double CrystalEdgeOffset1 = 26.0*mm; // distance of the edge from the center of the crystal -const G4double CrystalEdgeOffset2 = 28.5*mm; // distance of the edge from the center of the crystal + // Exogam Stuff + const G4double CrystalEdgeOffset1 = 26.0 * mm; // distance of the edge from the center of the crystal + const G4double CrystalEdgeOffset2 = 28.5 * mm; // distance of the edge from the center of the crystal -const G4double CapsuleWidth = 1.5*mm; // capsule width -const G4double CapsuleLength = 110.*mm; // capsule length -const G4double CapsuleEdgeDepth = 3.3*cm; // same as crystal ! -const G4double CrystalToCapsule = 7*mm; // to be adjusted .. + const G4double CapsuleWidth = 1.5 * mm; // capsule width + const G4double CapsuleLength = 110. * mm; // capsule length + const G4double CapsuleEdgeDepth = 3.3 * cm; // same as crystal ! + const G4double CrystalToCapsule = 7 * mm; // to be adjusted .. -//const G4double BGOLength = 120.0*mm; -//const G4double BGOWidth = 25.0*mm; + // const G4double BGOLength = 120.0*mm; + // const G4double BGOWidth = 25.0*mm; -//const G4double CsILength = 20.0*mm; -} + // const G4double CsILength = 20.0*mm; +} // namespace //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // GeTAMU Specific Method -GeTAMU::GeTAMU(){ +GeTAMU::GeTAMU() { InitializeMaterial(); m_GeTAMUData = new TGeTAMUData(); - BlueVisAtt = new G4VisAttributes(G4Colour(0, 0, 1)) ; - GreenVisAtt = new G4VisAttributes(G4Colour(0, 1, 0)) ; - RedVisAtt = new G4VisAttributes(G4Colour(1, 0, 0)) ; - WhiteVisAtt = new G4VisAttributes(G4Colour(1, 1, 1)) ; - TrGreyVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5, 0.5)) ; + BlueVisAtt = new G4VisAttributes(G4Colour(0, 0, 1)); + GreenVisAtt = new G4VisAttributes(G4Colour(0, 1, 0)); + RedVisAtt = new G4VisAttributes(G4Colour(1, 0, 0)); + WhiteVisAtt = new G4VisAttributes(G4Colour(1, 1, 1)); + TrGreyVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5, 0.5)); m_LogicClover = 0; - } -GeTAMU::~GeTAMU(){ -// delete m_MaterialVacuum; +GeTAMU::~GeTAMU() { + // delete m_MaterialVacuum; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void GeTAMU::ReadConfiguration(NPL::InputParser parser){ - - vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithTokenAndValue("GeTAMU","Clover"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " clovers found " << endl; - - vector<string> token = {"CloverID","R","Theta","Phi","Beta"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(token)){ - double R = blocks[i]->GetDouble("R","mm"); - double Theta = blocks[i]->GetDouble("Theta","deg"); - double Phi = blocks[i]->GetDouble("Phi","deg"); - vector<double> beta = blocks[i]->GetVectorDouble("Beta","deg"); - int id = blocks[i]->GetInt("CloverID"); - AddCloverFreePosition(id,R,Theta,Phi,beta[0],beta[1],beta[2]); +void GeTAMU::ReadConfiguration(NPL::InputParser parser) { + + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithTokenAndValue("GeTAMU", "Clover"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " clovers found " << endl; + + vector<string> token = {"CloverID", "R", "Theta", "Phi", "Beta"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(token)) { + double R = blocks[i]->GetDouble("R", "mm"); + double Theta = blocks[i]->GetDouble("Theta", "deg"); + double Phi = blocks[i]->GetDouble("Phi", "deg"); + vector<double> beta = blocks[i]->GetVectorDouble("Beta", "deg"); + int id = blocks[i]->GetInt("CloverID"); + AddCloverFreePosition(id, R, Theta, Phi, beta[0], beta[1], beta[2]); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } @@ -150,177 +148,175 @@ void GeTAMU::ReadConfiguration(NPL::InputParser parser){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Return a G4VSolid modeling the Crystal -G4LogicalVolume* GeTAMU::ConstructCrystal(){ - G4Tubs* Crystal_Cylinder = new G4Tubs("Crystal_Cylinder", 0, CrystalOuterRadius, CrystalLength*0.5, 0, 2*M_PI); +G4LogicalVolume* GeTAMU::ConstructCrystal() { + G4Tubs* Crystal_Cylinder = new G4Tubs("Crystal_Cylinder", 0, CrystalOuterRadius, CrystalLength * 0.5, 0, 2 * M_PI); // Central Hole for cold finger - G4RotationMatrix* BoxRotation = new G4RotationMatrix(0,0,0); - G4Tubs* Crystal_Hole = new G4Tubs("Crystal_Hole", 0, CrystalInnerRadius, (CrystalLength-CrystalHoleDepth)*0.5, 0, 2*M_PI); - G4SubtractionSolid* Crystal_Stage1 = new G4SubtractionSolid("Crystal_Stage1",Crystal_Cylinder,Crystal_Hole,BoxRotation,G4ThreeVector(0,0,CrystalHoleDepth)); + G4RotationMatrix* BoxRotation = new G4RotationMatrix(0, 0, 0); + G4Tubs* Crystal_Hole = + new G4Tubs("Crystal_Hole", 0, CrystalInnerRadius, (CrystalLength - CrystalHoleDepth) * 0.5, 0, 2 * M_PI); + G4SubtractionSolid* Crystal_Stage1 = new G4SubtractionSolid("Crystal_Stage1", Crystal_Cylinder, Crystal_Hole, + BoxRotation, G4ThreeVector(0, 0, CrystalHoleDepth)); // Flat surface on the side - G4Box* Crystal_Box1 = new G4Box("Crystal_Box1", CrystalWidth*0.6, CrystalWidth*0.6,CrystalLength*0.6); - G4SubtractionSolid* Crystal_Stage2 = new G4SubtractionSolid("Crystal_Stage2",Crystal_Stage1,Crystal_Box1,BoxRotation,G4ThreeVector(24.5+CrystalWidth*0.6,0,0)); - G4SubtractionSolid* Crystal_Stage3 = new G4SubtractionSolid("Crystal_Stage3",Crystal_Stage2,Crystal_Box1,BoxRotation,G4ThreeVector(-29-CrystalWidth*0.6,0,0)); - G4SubtractionSolid* Crystal_Stage4 = new G4SubtractionSolid("Crystal_Stage4",Crystal_Stage3,Crystal_Box1,BoxRotation,G4ThreeVector(0,29+CrystalWidth*0.6,0)); - G4SubtractionSolid* Crystal_Stage5 = new G4SubtractionSolid("Crystal_Stage5",Crystal_Stage4,Crystal_Box1,BoxRotation,G4ThreeVector(0,-24.5-CrystalWidth*0.6,0)); + G4Box* Crystal_Box1 = new G4Box("Crystal_Box1", CrystalWidth * 0.6, CrystalWidth * 0.6, CrystalLength * 0.6); + G4SubtractionSolid* Crystal_Stage2 = new G4SubtractionSolid( + "Crystal_Stage2", Crystal_Stage1, Crystal_Box1, BoxRotation, G4ThreeVector(24.5 + CrystalWidth * 0.6, 0, 0)); + G4SubtractionSolid* Crystal_Stage3 = new G4SubtractionSolid( + "Crystal_Stage3", Crystal_Stage2, Crystal_Box1, BoxRotation, G4ThreeVector(-29 - CrystalWidth * 0.6, 0, 0)); + G4SubtractionSolid* Crystal_Stage4 = new G4SubtractionSolid( + "Crystal_Stage4", Crystal_Stage3, Crystal_Box1, BoxRotation, G4ThreeVector(0, 29 + CrystalWidth * 0.6, 0)); + G4SubtractionSolid* Crystal_Stage5 = new G4SubtractionSolid( + "Crystal_Stage5", Crystal_Stage4, Crystal_Box1, BoxRotation, G4ThreeVector(0, -24.5 - CrystalWidth * 0.6, 0)); // Bezel - G4RotationMatrix* BoxRotation1 = new G4RotationMatrix(0,0,0); - BoxRotation1->rotate(22.5*deg,G4ThreeVector(1,0,0)); - G4SubtractionSolid* Crystal_Stage6= new G4SubtractionSolid("Crystal_Stage6",Crystal_Stage5,Crystal_Box1,BoxRotation1,G4ThreeVector(0,20.54*mm+CrystalWidth*0.6,-45*mm)); - - G4RotationMatrix* BoxRotation2 = new G4RotationMatrix(0,0,0); - BoxRotation2->rotate(22.5*deg,G4ThreeVector(0,1,0)); - G4SubtractionSolid* Crystal_Stage7= new G4SubtractionSolid("Crystal_Stage7",Crystal_Stage6,Crystal_Box1,BoxRotation2,G4ThreeVector(-20.54*mm-CrystalWidth*0.6,0,-45*mm)); - - G4LogicalVolume* logicCrystal = - new G4LogicalVolume(Crystal_Stage7,m_MaterialGe,"LogicCrystal", 0, 0, 0); - - return logicCrystal; + G4RotationMatrix* BoxRotation1 = new G4RotationMatrix(0, 0, 0); + BoxRotation1->rotate(22.5 * deg, G4ThreeVector(1, 0, 0)); + G4SubtractionSolid* Crystal_Stage6 = + new G4SubtractionSolid("Crystal_Stage6", Crystal_Stage5, Crystal_Box1, BoxRotation1, + G4ThreeVector(0, 20.54 * mm + CrystalWidth * 0.6, -45 * mm)); + + G4RotationMatrix* BoxRotation2 = new G4RotationMatrix(0, 0, 0); + BoxRotation2->rotate(22.5 * deg, G4ThreeVector(0, 1, 0)); + G4SubtractionSolid* Crystal_Stage7 = + new G4SubtractionSolid("Crystal_Stage7", Crystal_Stage6, Crystal_Box1, BoxRotation2, + G4ThreeVector(-20.54 * mm - CrystalWidth * 0.6, 0, -45 * mm)); + + G4LogicalVolume* logicCrystal = new G4LogicalVolume(Crystal_Stage7, m_MaterialGe, "LogicCrystal", 0, 0, 0); + + return logicCrystal; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Return a G4VSolid modeling the Capsule -G4LogicalVolume* GeTAMU::ConstructCapsule(){ +G4LogicalVolume* GeTAMU::ConstructCapsule() { G4int nbslice = 7; - const G4double widthface = 45.5*mm; - G4double zSlice[7] = { 0.0*mm, - CapsuleWidth-0.1*mm, - CapsuleWidth, - CapsuleEdgeDepth, - CapsuleLength-CapsuleWidth, - CapsuleLength-CapsuleWidth-0.1*mm, - CapsuleLength }; - - G4double InnNullRad[7] = {0,0,0,0,0,0,0}; - - G4double InnRad[7] = { 0.0*mm, - 0.0*mm, - widthface-CapsuleWidth, - CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule - CapsuleWidth, - CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule - CapsuleWidth, - 0.0*mm, - 0.0*mm}; - - G4double OutRad[7] = { widthface-1.5*mm, - widthface, - widthface, - CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule, - CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule, - CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule, - CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule}; + const G4double widthface = 45.5 * mm; + G4double zSlice[7] = {0.0 * mm, CapsuleWidth - 0.1 * mm, CapsuleWidth, + CapsuleEdgeDepth, CapsuleLength - CapsuleWidth, CapsuleLength - CapsuleWidth - 0.1 * mm, + CapsuleLength}; + + G4double InnNullRad[7] = {0, 0, 0, 0, 0, 0, 0}; + + G4double InnRad[7] = {0.0 * mm, + 0.0 * mm, + widthface - CapsuleWidth, + CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule - CapsuleWidth, + CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule - CapsuleWidth, + 0.0 * mm, + 0.0 * mm}; + + G4double OutRad[7] = {widthface - 1.5 * mm, + widthface, + widthface, + CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule, + CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule, + CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule, + CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule}; // The whole volume of the Capsule, made of N2 - G4Polyhedra* caps = new G4Polyhedra(G4String("Capsule"), 45.*deg, 360.*deg, 4, nbslice, zSlice, InnNullRad, OutRad); - G4LogicalVolume* LogicCapsule= - new G4LogicalVolume(caps,m_MaterialN2,"LogicCapsule", 0, 0, 0); - LogicCapsule->SetVisAttributes(G4VisAttributes::Invisible); + G4Polyhedra* caps = + new G4Polyhedra(G4String("Capsule"), 45. * deg, 360. * deg, 4, nbslice, zSlice, InnNullRad, OutRad); + G4LogicalVolume* LogicCapsule = new G4LogicalVolume(caps, m_MaterialN2, "LogicCapsule", 0, 0, 0); + LogicCapsule->SetVisAttributes(G4VisAttributes::GetInvisible()); // The wall of the Capsule made of Al - G4Polyhedra* capsWall = new G4Polyhedra(G4String("CapsuleWall"), 45.*deg, 360.*deg, 4, nbslice, zSlice, InnRad, OutRad); - G4LogicalVolume* logicCapsuleWall = - new G4LogicalVolume(capsWall,m_MaterialAl,"LogicCapsuleWall", 0, 0, 0); + G4Polyhedra* capsWall = + new G4Polyhedra(G4String("CapsuleWall"), 45. * deg, 360. * deg, 4, nbslice, zSlice, InnRad, OutRad); + G4LogicalVolume* logicCapsuleWall = new G4LogicalVolume(capsWall, m_MaterialAl, "LogicCapsuleWall", 0, 0, 0); - new G4PVPlacement(G4Transform3D(*(new G4RotationMatrix()), G4ThreeVector(0,0,0)), - logicCapsuleWall,"CapsuleWall",LogicCapsule,false,1); + new G4PVPlacement(G4Transform3D(*(new G4RotationMatrix()), G4ThreeVector(0, 0, 0)), logicCapsuleWall, "CapsuleWall", + LogicCapsule, false, 1); logicCapsuleWall->SetVisAttributes(TrGreyVisAtt); return LogicCapsule; - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* GeTAMU::ConstructDewar(){ - G4Tubs* DewarSolid = new G4Tubs("DewarSolid",0,90*mm*0.5,90*mm*0.5,0,2*M_PI); - G4Tubs* DewarCFSolid = new G4Tubs("DewarCFSolid",0,45*mm*0.5,145*mm*0.5,0,2*M_PI); +G4LogicalVolume* GeTAMU::ConstructDewar() { + G4Tubs* DewarSolid = new G4Tubs("DewarSolid", 0, 90 * mm * 0.5, 90 * mm * 0.5, 0, 2 * M_PI); + G4Tubs* DewarCFSolid = new G4Tubs("DewarCFSolid", 0, 45 * mm * 0.5, 145 * mm * 0.5, 0, 2 * M_PI); + + G4UnionSolid* DewarFull = new G4UnionSolid("Dewarfull", DewarSolid, DewarCFSolid, new G4RotationMatrix(), + G4ThreeVector(0, 0, -90 * mm - (145 - 90) * 0.5 * mm)); - G4UnionSolid* DewarFull = - new G4UnionSolid("Dewarfull", DewarSolid, DewarCFSolid, new G4RotationMatrix(),G4ThreeVector(0,0,-90*mm-(145-90)*0.5*mm)); + G4LogicalVolume* LogicDewar = new G4LogicalVolume(DewarFull, m_MaterialAl, "LogicDewar", 0, 0, 0); - G4LogicalVolume* LogicDewar = new G4LogicalVolume(DewarFull,m_MaterialAl,"LogicDewar",0,0,0); + G4Tubs* N2Solid = new G4Tubs("N2Solid", 0, 90 * mm * 0.5 - 1 * mm, 90 * mm * 0.5 - 1 * mm, 0, 2 * M_PI); + G4Tubs* N2CFSolid = new G4Tubs("N2CFSolid", 0, 45 * mm * 0.5 - 1 * mm, 145 * mm * 0.5 - 1 * mm, 0, 2 * M_PI); - G4Tubs* N2Solid = new G4Tubs("N2Solid",0,90*mm*0.5-1*mm,90*mm*0.5-1*mm,0,2*M_PI); - G4Tubs* N2CFSolid = new G4Tubs("N2CFSolid",0,45*mm*0.5-1*mm,145*mm*0.5-1*mm,0,2*M_PI); + G4LogicalVolume* LogicN2 = new G4LogicalVolume(N2Solid, m_MaterialN2, "LogicN2", 0, 0, 0); + G4LogicalVolume* LogicN2CF = new G4LogicalVolume(N2CFSolid, m_MaterialN2, "LogicN2CF", 0, 0, 0); - G4LogicalVolume* LogicN2 = new G4LogicalVolume(N2Solid,m_MaterialN2,"LogicN2",0,0,0); - G4LogicalVolume* LogicN2CF = new G4LogicalVolume(N2CFSolid,m_MaterialN2,"LogicN2CF",0,0,0); - LogicN2->SetVisAttributes(GreenVisAtt); LogicN2CF->SetVisAttributes(GreenVisAtt); - new G4PVPlacement(G4Transform3D(*(new G4RotationMatrix()), G4ThreeVector(0,0,0)), - LogicN2,"N2 Deware",LogicDewar,false,1); - - //new G4PVPlacement(G4Transform3D(*(new G4RotationMatrix()), G4ThreeVector(0,0,-90*mm)), - // LogicN2CF,"N2 Deware",LogicDewar,false,1); + new G4PVPlacement(G4Transform3D(*(new G4RotationMatrix()), G4ThreeVector(0, 0, 0)), LogicN2, "N2 Deware", LogicDewar, + false, 1); + + // new G4PVPlacement(G4Transform3D(*(new G4RotationMatrix()), G4ThreeVector(0,0,-90*mm)), + // LogicN2CF,"N2 Deware",LogicDewar,false,1); LogicDewar->SetVisAttributes(TrGreyVisAtt); return LogicDewar; } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Return a G4VSolid modeling the BGO -G4LogicalVolume* GeTAMU::ConstructBGO(){ - - return NULL; - -} +G4LogicalVolume* GeTAMU::ConstructBGO() { return NULL; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Return a clover in the configuration given by option (not use a the moment) -void GeTAMU::ConstructClover(){ - if(m_LogicClover==0){ +void GeTAMU::ConstructClover() { + if (m_LogicClover == 0) { // Construct the clover itself m_LogicClover = ConstructCapsule(); - + // Place the cristal in the clover - double CrystalOffset = (24.5*mm+0.5*mm); + double CrystalOffset = (24.5 * mm + 0.5 * mm); G4LogicalVolume* logicCrystal = ConstructCrystal(); - G4RotationMatrix* CrystalRotation = new G4RotationMatrix(0,0,0); - G4ThreeVector CrystalPositionB = G4ThreeVector(-CrystalOffset,+CrystalOffset,0.5*CrystalLength+7*mm); - new G4PVPlacement(G4Transform3D(*CrystalRotation, CrystalPositionB), - logicCrystal,"LogicCrystalB",m_LogicClover,false,1); + G4RotationMatrix* CrystalRotation = new G4RotationMatrix(0, 0, 0); + G4ThreeVector CrystalPositionB = G4ThreeVector(-CrystalOffset, +CrystalOffset, 0.5 * CrystalLength + 7 * mm); + new G4PVPlacement(G4Transform3D(*CrystalRotation, CrystalPositionB), logicCrystal, "LogicCrystalB", m_LogicClover, + false, 1); logicCrystal->SetVisAttributes(BlueVisAtt); - CrystalRotation->rotate(-90*deg, G4ThreeVector(0,0,1)); - G4ThreeVector CrystalPositionG = G4ThreeVector(+CrystalOffset,+CrystalOffset,0.5*CrystalLength+7*mm); - new G4PVPlacement(G4Transform3D(*CrystalRotation, CrystalPositionG), - logicCrystal,"LogicCrystalG",m_LogicClover,false,2); - - CrystalRotation->rotate(-90*deg, G4ThreeVector(0,0,1)); - G4ThreeVector CrystalPositionR = G4ThreeVector(+CrystalOffset,-CrystalOffset,0.5*CrystalLength+7*mm); - new G4PVPlacement(G4Transform3D(*CrystalRotation, CrystalPositionR), - logicCrystal,"LogicCrystalR",m_LogicClover,false,3); + CrystalRotation->rotate(-90 * deg, G4ThreeVector(0, 0, 1)); + G4ThreeVector CrystalPositionG = G4ThreeVector(+CrystalOffset, +CrystalOffset, 0.5 * CrystalLength + 7 * mm); + new G4PVPlacement(G4Transform3D(*CrystalRotation, CrystalPositionG), logicCrystal, "LogicCrystalG", m_LogicClover, + false, 2); - CrystalRotation->rotate(-90*deg, G4ThreeVector(0,0,1)); - G4ThreeVector CrystalPositionW = G4ThreeVector(-CrystalOffset,-CrystalOffset,0.5*CrystalLength+7*mm); - new G4PVPlacement(G4Transform3D(*CrystalRotation, CrystalPositionW), - logicCrystal,"LogicCrystalW",m_LogicClover,false,4); + CrystalRotation->rotate(-90 * deg, G4ThreeVector(0, 0, 1)); + G4ThreeVector CrystalPositionR = G4ThreeVector(+CrystalOffset, -CrystalOffset, 0.5 * CrystalLength + 7 * mm); + new G4PVPlacement(G4Transform3D(*CrystalRotation, CrystalPositionR), logicCrystal, "LogicCrystalR", m_LogicClover, + false, 3); - logicCrystal->SetSensitiveDetector(m_HPGeScorer); - // m_LogicClover->SetSensitiveDetector(m_HPGeScorer); - } + CrystalRotation->rotate(-90 * deg, G4ThreeVector(0, 0, 1)); + G4ThreeVector CrystalPositionW = G4ThreeVector(-CrystalOffset, -CrystalOffset, 0.5 * CrystalLength + 7 * mm); + new G4PVPlacement(G4Transform3D(*CrystalRotation, CrystalPositionW), logicCrystal, "LogicCrystalW", m_LogicClover, + false, 4); + logicCrystal->SetSensitiveDetector(m_HPGeScorer); + // m_LogicClover->SetSensitiveDetector(m_HPGeScorer); + } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void GeTAMU::ConstructDetector(G4LogicalVolume* world){ +void GeTAMU::ConstructDetector(G4LogicalVolume* world) { ConstructClover(); - G4RotationMatrix* DetectorRotation = new G4RotationMatrix(0,0,0); - for (unsigned int i = 0 ; i < m_CloverId.size(); i++) { + G4RotationMatrix* DetectorRotation = new G4RotationMatrix(0, 0, 0); + for (unsigned int i = 0; i < m_CloverId.size(); i++) { // Constructing the Detector referential and the transition matrix - G4ThreeVector U,V,W; - G4double wX = sin(m_Theta[i]) * cos(m_Phi[i]) ; - G4double wY = sin(m_Theta[i]) * sin(m_Phi[i]) ; + G4ThreeVector U, V, W; + G4double wX = sin(m_Theta[i]) * cos(m_Phi[i]); + G4double wY = sin(m_Theta[i]) * sin(m_Phi[i]); G4double wZ = cos(m_Theta[i]); - W = G4ThreeVector(wX, wY, wZ) ; + W = G4ThreeVector(wX, wY, wZ); // vector parallel to one axis of the entrance plane G4double vX = cos(m_Theta[i]) * cos(m_Phi[i]); @@ -340,194 +336,193 @@ void GeTAMU::ConstructDetector(G4LogicalVolume* world){ DetectorRotation->rotate(m_BetaX[i], U); DetectorRotation->rotate(m_BetaY[i], V); DetectorRotation->rotate(m_BetaZ[i], W); - G4ThreeVector DetectorPosition = m_R[i]*W; - - new G4PVPlacement(G4Transform3D(*DetectorRotation, DetectorPosition), - m_LogicClover,"Clover",world,false,m_CloverId[i]); - - G4LogicalVolume* LogicDewar = ConstructDewar(); - - new G4PVPlacement(G4Transform3D(*DetectorRotation, DetectorPosition+W*((90*mm+(145)*mm)+CapsuleLength*0.5+90*0.5*mm)), - LogicDewar,"Dewar",world,false,m_CloverId[i]); + G4ThreeVector DetectorPosition = m_R[i] * W; + + new G4PVPlacement(G4Transform3D(*DetectorRotation, DetectorPosition), m_LogicClover, "Clover", world, false, + m_CloverId[i]); + G4LogicalVolume* LogicDewar = ConstructDewar(); + new G4PVPlacement(G4Transform3D(*DetectorRotation, DetectorPosition + W * ((90 * mm + (145) * mm) + + CapsuleLength * 0.5 + 90 * 0.5 * mm)), + LogicDewar, "Dewar", world, false, m_CloverId[i]); } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add clover at the standard position of the array // Take as argument the standard clover Id. -void GeTAMU::AddCloverStandard(vector<int> CloverId){ +void GeTAMU::AddCloverStandard(vector<int> CloverId) { - for (unsigned int i = 0 ; i < CloverId.size(); i++) { - if(CloverId[i] == 1 ){ + for (unsigned int i = 0; i < CloverId.size(); i++) { + if (CloverId[i] == 1) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(45*deg); - m_Phi.push_back(22.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(45 * deg); + m_Phi.push_back(22.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); m_BetaZ.push_back(0); } - else if(CloverId[i] == 2 ){ + else if (CloverId[i] == 2) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(45*deg); - m_Phi.push_back(112.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(45 * deg); + m_Phi.push_back(112.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); m_BetaZ.push_back(0); } - else if(CloverId[i] == 3 ){ + else if (CloverId[i] == 3) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(45*deg); - m_Phi.push_back(202.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(45 * deg); + m_Phi.push_back(202.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); m_BetaZ.push_back(0); } - else if(CloverId[i] == 4 ){ + else if (CloverId[i] == 4) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(45*deg); - m_Phi.push_back(292.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(45 * deg); + m_Phi.push_back(292.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); m_BetaZ.push_back(0); } - else if(CloverId[i] == 5 ){ + else if (CloverId[i] == 5) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(90*deg); - m_Phi.push_back(22.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(90 * deg); + m_Phi.push_back(22.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 6 ){ + else if (CloverId[i] == 6) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(90*deg); - m_Phi.push_back(67.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(90 * deg); + m_Phi.push_back(67.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 7 ){ + else if (CloverId[i] == 7) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(90*deg); - m_Phi.push_back(112.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(90 * deg); + m_Phi.push_back(112.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 8 ){ + else if (CloverId[i] == 8) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(90*deg); - m_Phi.push_back(157.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(90 * deg); + m_Phi.push_back(157.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 9 ){ + else if (CloverId[i] == 9) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(90*deg); - m_Phi.push_back(202.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(90 * deg); + m_Phi.push_back(202.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 10 ){ + else if (CloverId[i] == 10) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(90*deg); - m_Phi.push_back(247.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(90 * deg); + m_Phi.push_back(247.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 11 ){ + else if (CloverId[i] == 11) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(90*deg); - m_Phi.push_back(292.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(90 * deg); + m_Phi.push_back(292.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 12 ){ + else if (CloverId[i] == 12) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(90*deg); - m_Phi.push_back(337.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(90 * deg); + m_Phi.push_back(337.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 13 ){ + else if (CloverId[i] == 13) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(135*deg); - m_Phi.push_back(22.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(135 * deg); + m_Phi.push_back(22.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 14 ){ + else if (CloverId[i] == 14) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(135*deg); - m_Phi.push_back(112.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(135 * deg); + m_Phi.push_back(112.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 15 ){ + else if (CloverId[i] == 15) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(135*deg); - m_Phi.push_back(202.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(135 * deg); + m_Phi.push_back(202.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 16 ){ + else if (CloverId[i] == 16) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(135*deg); - m_Phi.push_back(292.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(135 * deg); + m_Phi.push_back(292.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } } - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add clover at a free position in space with coordinate // in spherical coordinate // Beta are the three angles of rotation in the Clover frame -void GeTAMU::AddCloverFreePosition(int CloverId,double R,double Theta,double Phi,double BetaX,double BetaY,double BetaZ){ +void GeTAMU::AddCloverFreePosition(int CloverId, double R, double Theta, double Phi, double BetaX, double BetaY, + double BetaZ) { m_CloverId.push_back(CloverId); m_R.push_back(R); @@ -536,46 +531,45 @@ void GeTAMU::AddCloverFreePosition(int CloverId,double R,double Theta,double Phi m_BetaX.push_back(BetaX); m_BetaY.push_back(BetaY); m_BetaZ.push_back(BetaZ); - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void GeTAMU::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("GeTAMU")){ - pTree->Branch("GeTAMU", "TGeTAMUData", &m_GeTAMUData) ; - } - pTree->SetBranchAddress("GeTAMU", &m_GeTAMUData) ; +void GeTAMU::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("GeTAMU")) { + pTree->Branch("GeTAMU", "TGeTAMUData", &m_GeTAMUData); + } + pTree->SetBranchAddress("GeTAMU", &m_GeTAMUData); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void GeTAMU::ReadSensitive(const G4Event* event){ +void GeTAMU::ReadSensitive(const G4Event* event) { m_GeTAMUData->Clear(); /////////// // HPGE - NPS::HitsMap<G4double*>* HPGEHitMap; - std::map<G4int, G4double**>::iterator HPGE_itr; + NPS::HitsMap<G4double*>* HPGEHitMap; + std::map<G4int, G4double**>::iterator HPGE_itr; G4int HPGECollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("GeTAMU_Scorer/GeTAMU"); - if(HPGECollectionID == -1) { - G4cerr << "ERROR: No Collection found for HPGeScorer: Skipping processing of HPGe Hit" << G4endl; - return; - } + if (HPGECollectionID == -1) { + G4cerr << "ERROR: No Collection found for HPGeScorer: Skipping processing of HPGe Hit" << G4endl; + return; + } HPGEHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(HPGECollectionID)); // Loop on the HPGE map - for (HPGE_itr = HPGEHitMap->GetMap()->begin() ; HPGE_itr != HPGEHitMap->GetMap()->end() ; HPGE_itr++){ - - G4double* Info = *(HPGE_itr->second); + for (HPGE_itr = HPGEHitMap->GetMap()->begin(); HPGE_itr != HPGEHitMap->GetMap()->end(); HPGE_itr++) { - G4double Energy = Info[0]; - G4double Time = Info[1]; + G4double* Info = *(HPGE_itr->second); + + G4double Energy = Info[0]; + G4double Time = Info[1]; // G4double InterPos_X = Info[2]; G4double InterPos_Y = Info[3]; @@ -583,96 +577,99 @@ void GeTAMU::ReadSensitive(const G4Event* event){ G4double InterPos_Theta = Info[5]; G4double InterPos_Phi = Info[6]; // - G4int CloverNbr = (int)Info[7]; - G4int CrystalNbr = (int)Info[8]; - - // Figure out segment number - G4int SegmentNbr = 0; - if(fabs(InterPos_Z) < 20*mm) { SegmentNbr = 2; } // MIDDLE - else if(CrystalNbr == 1 || CrystalNbr == 4) { SegmentNbr = 1; } // RIGHT - else { SegmentNbr = 3; } // LEFT - - if(Energy>0.0*keV){ - m_GeTAMUData->SetCoreE(CloverNbr, CrystalNbr, Energy/keV); - m_GeTAMUData->SetCoreT(CloverNbr, CrystalNbr, Time/ns); - m_GeTAMUData->SetSegmentE(CloverNbr, SegmentNbr, Energy/keV); - m_GeTAMUData->SetSegmentT(CloverNbr, SegmentNbr, Time/ns); - - // If event passes through first stage fill the Interaction Coordinates - //Always calculated with respect to (0,0,0) - ms_InterCoord->SetDetectedPositionX(InterPos_X) ; - ms_InterCoord->SetDetectedPositionY(InterPos_Y) ; - ms_InterCoord->SetDetectedPositionZ(InterPos_Z) ; - ms_InterCoord->SetDetectedAngleTheta(InterPos_Theta/deg) ; - ms_InterCoord->SetDetectedAnglePhi(InterPos_Phi/deg) ; - - //add resolutions + G4int CloverNbr = (int)Info[7]; + G4int CrystalNbr = (int)Info[8]; + + // Figure out segment number + G4int SegmentNbr = 0; + if (fabs(InterPos_Z) < 20 * mm) { + SegmentNbr = 2; + } // MIDDLE + else if (CrystalNbr == 1 || CrystalNbr == 4) { + SegmentNbr = 1; + } // RIGHT + else { + SegmentNbr = 3; + } // LEFT + + if (Energy > 0.0 * keV) { + m_GeTAMUData->SetCoreE(CloverNbr, CrystalNbr, Energy / keV); + m_GeTAMUData->SetCoreT(CloverNbr, CrystalNbr, Time / ns); + m_GeTAMUData->SetSegmentE(CloverNbr, SegmentNbr, Energy / keV); + m_GeTAMUData->SetSegmentT(CloverNbr, SegmentNbr, Time / ns); + + // If event passes through first stage fill the Interaction Coordinates + // Always calculated with respect to (0,0,0) + ms_InterCoord->SetDetectedPositionX(InterPos_X); + ms_InterCoord->SetDetectedPositionY(InterPos_Y); + ms_InterCoord->SetDetectedPositionZ(InterPos_Z); + ms_InterCoord->SetDetectedAngleTheta(InterPos_Theta / deg); + ms_InterCoord->SetDetectedAnglePhi(InterPos_Phi / deg); + + // add resolutions G4double energyCry = RandGauss::shoot(Energy, ResoCry); G4double energySeg = RandGauss::shoot(Energy, ResoSeg); G4double time = RandGauss::shoot(Time, ResoTime); - - if(Energy > EnergyThreshold){ - m_GeTAMUData->SetCoreE(CloverNbr, CrystalNbr, energyCry/keV); - m_GeTAMUData->SetCoreT(CloverNbr, CrystalNbr, time/ns); - m_GeTAMUData->SetSegmentE(CloverNbr, SegmentNbr, energySeg/keV); - m_GeTAMUData->SetSegmentT(CloverNbr, SegmentNbr, time/ns); - } - + + if (Energy > EnergyThreshold) { + m_GeTAMUData->SetCoreE(CloverNbr, CrystalNbr, energyCry / keV); + m_GeTAMUData->SetCoreT(CloverNbr, CrystalNbr, time / ns); + m_GeTAMUData->SetSegmentE(CloverNbr, SegmentNbr, energySeg / keV); + m_GeTAMUData->SetSegmentT(CloverNbr, SegmentNbr, time / ns); + } } - } + } // clear map for next event HPGEHitMap->clear(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void GeTAMU::InitializeScorers(){ - //Look for previous definition of the scorer (geometry reload) - //n.b. calls new G4MultiFunctionalDetector("GeTAMU_CoreScorer"); +void GeTAMU::InitializeScorers() { + // Look for previous definition of the scorer (geometry reload) + // n.b. calls new G4MultiFunctionalDetector("GeTAMU_CoreScorer"); bool already_exist = false; - m_HPGeScorer = CheckScorer("GeTAMU_Scorer",already_exist); + m_HPGeScorer = CheckScorer("GeTAMU_Scorer", already_exist); + + // if the scorer were created previously nothing else need to be made + if (already_exist) + return; - // if the scorer were created previously nothing else need to be made - if(already_exist) return; - // HPGe Associate Scorer - G4VPrimitiveScorer* HPGeScorer = new GETAMUSCORERS::PS_GeTAMU("GeTAMU",0); + G4VPrimitiveScorer* HPGeScorer = new GETAMUSCORERS::PS_GeTAMU("GeTAMU", 0); - //and register it to the multifunctionnal detector + // and register it to the multifunctionnal detector m_HPGeScorer->RegisterPrimitive(HPGeScorer); - // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_HPGeScorer) ; + // Add All Scorer to the Global Scorer Manager + G4SDManager::GetSDMpointer()->AddNewDetector(m_HPGeScorer); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //////////////////////////////////////////////////////////////// /////////////////Material Definition /////////////////////////// //////////////////////////////////////////////////////////////// -void GeTAMU::InitializeMaterial(){ +void GeTAMU::InitializeMaterial() { m_MaterialVacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); - m_MaterialGe= MaterialManager::getInstance()->GetMaterialFromLibrary("Ge"); - m_MaterialAl= MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); - m_MaterialN2= MaterialManager::getInstance()->GetMaterialFromLibrary("N2_liquid"); + m_MaterialGe = MaterialManager::getInstance()->GetMaterialFromLibrary("Ge"); + m_MaterialAl = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); + m_MaterialN2 = MaterialManager::getInstance()->GetMaterialFromLibrary("N2_liquid"); } - //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* GeTAMU::Construct(){ - return (NPS::VDetector*) new GeTAMU(); -} +NPS::VDetector* GeTAMU::Construct() { return (NPS::VDetector*)new GeTAMU(); } //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { -class proxy_nps_getamu{ -public: - proxy_nps_getamu(){ - NPS::DetectorFactory::getInstance()->AddToken("GeTAMU","GeTAMU"); - NPS::DetectorFactory::getInstance()->AddDetector("GeTAMU",GeTAMU::Construct); - } +extern "C" { +class proxy_nps_getamu { + public: + proxy_nps_getamu() { + NPS::DetectorFactory::getInstance()->AddToken("GeTAMU", "GeTAMU"); + NPS::DetectorFactory::getInstance()->AddDetector("GeTAMU", GeTAMU::Construct); + } }; proxy_nps_getamu p_nps_getamu; diff --git a/NPSimulation/Detectors/Helios/Helios.cc b/NPSimulation/Detectors/Helios/Helios.cc index c518a32d4..0adfb7800 100644 --- a/NPSimulation/Detectors/Helios/Helios.cc +++ b/NPSimulation/Detectors/Helios/Helios.cc @@ -20,40 +20,40 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> -//G4 Geometry object -#include "G4Tubs.hh" +#include <sstream> +// G4 Geometry object #include "G4Box.hh" #include "G4SubtractionSolid.hh" +#include "G4Tubs.hh" -//G4 sensitive -#include "G4SDManager.hh" +// G4 sensitive #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" -//G4 various object +// G4 various object +#include "G4Colour.hh" #include "G4Material.hh" -#include "G4Transform3D.hh" #include "G4PVPlacement.hh" +#include "G4Transform3D.hh" #include "G4VisAttributes.hh" -#include "G4Colour.hh" // G4 Field #include "G4FieldManager.hh" #include "G4MagneticField.hh" -#include "G4UniformMagField.hh" #include "G4TransportationManager.hh" +#include "G4UniformMagField.hh" // NPTool header -#include "Helios.hh" #include "DSSDScorers.hh" +#include "Helios.hh" #include "InteractionScorers.hh" -#include "RootOutput.h" #include "MaterialManager.hh" +#include "NPOptionManager.h" #include "NPSDetectorFactory.hh" +#include "RootOutput.h" #include "Target.hh" -#include "NPOptionManager.h" // CLHEP header #include "CLHEP/Random/RandGauss.h" @@ -61,141 +61,130 @@ using namespace std; using namespace CLHEP; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -namespace Helios_NS{ +namespace Helios_NS { // Energy and time Resolution - const double EnergyThreshold = 100*keV; - const double ResoTime = 1*ns ; - const double ResoEnergyFront = 50*keV ; - const double ResoEnergyBack = 24*keV; - const double MagnetInnerRadius = 46*cm; - const double MagnetOutterRadius = 1*m; - const double MagnetLength = 2.35*m; - - const double SquareTubeSide = 16*mm; - const double SquareTubeExcess = 2.4*mm;// Wafer to Wafer distance - const double SquareTubeRadius = 5*mm; - const double WaferWidth = 12*mm ; - const double WaferLength = 56 *mm ; - const double ActiveWaferWidth = 9*mm ; - const double ActiveWaferLength = 50.5 *mm ; - const double AluThicness = 0.3*micrometer; - const double WaferThickness = 700* micrometer; -} + const double EnergyThreshold = 100 * keV; + const double ResoTime = 1 * ns; + const double ResoEnergyFront = 50 * keV; + const double ResoEnergyBack = 24 * keV; + const double MagnetInnerRadius = 46 * cm; + const double MagnetOutterRadius = 1 * m; + const double MagnetLength = 2.35 * m; + + const double SquareTubeSide = 16 * mm; + const double SquareTubeExcess = 2.4 * mm; // Wafer to Wafer distance + const double SquareTubeRadius = 5 * mm; + const double WaferWidth = 12 * mm; + const double WaferLength = 56 * mm; + const double ActiveWaferWidth = 9 * mm; + const double ActiveWaferLength = 50.5 * mm; + const double AluThicness = 0.3 * micrometer; + const double WaferThickness = 700 * micrometer; +} // namespace Helios_NS //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Helios Specific Method -Helios::Helios(){ - m_Event = new THeliosData() ; +Helios::Helios() { + m_Event = new THeliosData(); m_HeliosScorer = 0; m_SquareTube = 0; m_SiliconWafer = 0; m_ActiveWafer = 0; m_Magnet = 0; - m_B=0; + m_B = 0; // RGB Color + Transparency - m_VisSquareTube = new G4VisAttributes(G4Colour(0.8, 0.8, 0.8, 0.5)); - m_VisPassiveSilicon = new G4VisAttributes(G4Colour(0.1, 0.1, 0.1, 1)); - m_VisSilicon = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3, 1)); - m_VisMagnet = new G4VisAttributes(G4Colour(0, 0.5, 1, 0.3)); + m_VisSquareTube = new G4VisAttributes(G4Colour(0.8, 0.8, 0.8, 0.5)); + m_VisPassiveSilicon = new G4VisAttributes(G4Colour(0.1, 0.1, 0.1, 1)); + m_VisSilicon = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3, 1)); + m_VisMagnet = new G4VisAttributes(G4Colour(0, 0.5, 1, 0.3)); } -Helios::~Helios(){ -} +Helios::~Helios() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Helios::AddHelios(double Z, string Face){ +void Helios::AddHelios(double Z, string Face) { m_Z.push_back(Z); m_Face.push_back(Face); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Helios::BuildSquareTube(){ - if(!m_SquareTube){ - G4Box* box = new G4Box("Helios_Box",Helios_NS::SquareTubeSide*0.5, - Helios_NS::SquareTubeSide*0.5,0.5*(Helios_NS::SquareTubeExcess+Helios_NS::WaferLength)); - - G4Tubs* tubs = new G4Tubs("Helios_Box",0,Helios_NS::SquareTubeRadius, - (Helios_NS::SquareTubeExcess+Helios_NS::WaferLength),0,360*deg); +G4LogicalVolume* Helios::BuildSquareTube() { + if (!m_SquareTube) { + G4Box* box = new G4Box("Helios_Box", Helios_NS::SquareTubeSide * 0.5, Helios_NS::SquareTubeSide * 0.5, + 0.5 * (Helios_NS::SquareTubeExcess + Helios_NS::WaferLength)); + G4Tubs* tubs = new G4Tubs("Helios_Box", 0, Helios_NS::SquareTubeRadius, + (Helios_NS::SquareTubeExcess + Helios_NS::WaferLength), 0, 360 * deg); G4RotationMatrix* R = new G4RotationMatrix(); - G4ThreeVector P(0,0,0); - G4SubtractionSolid* sub = new G4SubtractionSolid("Helios_Sub",box,tubs,R,P); + G4ThreeVector P(0, 0, 0); + G4SubtractionSolid* sub = new G4SubtractionSolid("Helios_Sub", box, tubs, R, P); - G4Material* Al= MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); - m_SquareTube= new G4LogicalVolume(sub,Al,"logic_Helios_Box",0,0,0); + G4Material* Al = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); + m_SquareTube = new G4LogicalVolume(sub, Al, "logic_Helios_Box", 0, 0, 0); m_SquareTube->SetVisAttributes(m_VisSquareTube); } return m_SquareTube; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Helios::BuildSiliconWafer(){ - if(!m_SiliconWafer){ - G4Box* box1 = new G4Box("Helios_Box1",Helios_NS::WaferWidth*0.5, - Helios_NS::WaferThickness*0.5+Helios_NS::AluThicness,Helios_NS::WaferLength*0.5); - - G4Box* box2 = new G4Box("Helios_Box2",Helios_NS::ActiveWaferWidth*0.5, - Helios_NS::WaferThickness*0.5,Helios_NS::ActiveWaferLength*0.5); +G4LogicalVolume* Helios::BuildSiliconWafer() { + if (!m_SiliconWafer) { + G4Box* box1 = new G4Box("Helios_Box1", Helios_NS::WaferWidth * 0.5, + Helios_NS::WaferThickness * 0.5 + Helios_NS::AluThicness, Helios_NS::WaferLength * 0.5); + G4Box* box2 = new G4Box("Helios_Box2", Helios_NS::ActiveWaferWidth * 0.5, Helios_NS::WaferThickness * 0.5, + Helios_NS::ActiveWaferLength * 0.5); - G4Material* Si= MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); - G4Material* Al= MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); + G4Material* Si = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); + G4Material* Al = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); - m_SiliconWafer= new G4LogicalVolume(box1,Al,"logic_Helios_Wafer",0,0,0); - m_ActiveWafer= new G4LogicalVolume(box2,Si,"logic_Helios_ActiveWafer",0,0,0); + m_SiliconWafer = new G4LogicalVolume(box1, Al, "logic_Helios_Wafer", 0, 0, 0); + m_ActiveWafer = new G4LogicalVolume(box2, Si, "logic_Helios_ActiveWafer", 0, 0, 0); - G4ThreeVector AWPos(0,0,0); + G4ThreeVector AWPos(0, 0, 0); G4RotationMatrix* AWRot = new G4RotationMatrix(); - new G4PVPlacement(G4Transform3D(*AWRot,AWPos),m_ActiveWafer, - "Helios_ActiveWafer",m_SiliconWafer, true, 0); + new G4PVPlacement(G4Transform3D(*AWRot, AWPos), m_ActiveWafer, "Helios_ActiveWafer", m_SiliconWafer, true, 0); m_ActiveWafer->SetSensitiveDetector(m_HeliosScorer); m_SiliconWafer->SetVisAttributes(m_VisPassiveSilicon); m_ActiveWafer->SetVisAttributes(m_VisSilicon); - } - return m_SiliconWafer; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Helios::BuildMagnet(){ - if(!m_Magnet){ - G4Tubs* tubs1 = new G4Tubs("Helios_MainFull",0, - Helios_NS::MagnetOutterRadius,Helios_NS::MagnetLength*0.5,0,360*deg); +G4LogicalVolume* Helios::BuildMagnet() { + if (!m_Magnet) { + G4Tubs* tubs1 = + new G4Tubs("Helios_MainFull", 0, Helios_NS::MagnetOutterRadius, Helios_NS::MagnetLength * 0.5, 0, 360 * deg); // Inner part of the Soleinoid minus the Target it self (placed in the world) - G4SubtractionSolid* tubs = new G4SubtractionSolid("Helios_Main", - tubs1, Target::GetTarget()->GetTargetSolid(), new G4RotationMatrix() ,Target::GetTarget()->GetTargetPosition()); + G4SubtractionSolid* tubs = new G4SubtractionSolid("Helios_Main", tubs1, Target::GetTarget()->GetTargetSolid(), + new G4RotationMatrix(), Target::GetTarget()->GetTargetPosition()); - G4Tubs* tubs2 = new G4Tubs("Helios_Mag",Helios_NS::MagnetInnerRadius, - Helios_NS::MagnetOutterRadius,Helios_NS::MagnetLength*0.5,0,360*deg); + G4Tubs* tubs2 = new G4Tubs("Helios_Mag", Helios_NS::MagnetInnerRadius, Helios_NS::MagnetOutterRadius, + Helios_NS::MagnetLength * 0.5, 0, 360 * deg); - G4Material* Fe= MaterialManager::getInstance()->GetMaterialFromLibrary("Fe"); - G4Material* Vc= MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); + G4Material* Fe = MaterialManager::getInstance()->GetMaterialFromLibrary("Fe"); + G4Material* Vc = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); - m_Magnet= new G4LogicalVolume(tubs,Vc,"logic_Helios_Main",0,0,0); - G4LogicalVolume* Mag = new G4LogicalVolume(tubs2,Fe,"logic_Helios_Magnet",0,0,0); + m_Magnet = new G4LogicalVolume(tubs, Vc, "logic_Helios_Main", 0, 0, 0); + G4LogicalVolume* Mag = new G4LogicalVolume(tubs2, Fe, "logic_Helios_Magnet", 0, 0, 0); Mag->SetVisAttributes(m_VisMagnet); - m_Magnet->SetVisAttributes(G4VisAttributes::Invisible); + m_Magnet->SetVisAttributes(G4VisAttributes::GetInvisible()); // Place the Solenoid - G4ThreeVector MagPos(0,0,0); + G4ThreeVector MagPos(0, 0, 0); G4RotationMatrix* MagRot = new G4RotationMatrix(); - new G4PVPlacement(G4Transform3D(*MagRot,MagPos), - Mag, - "Helios_Magnet",m_Magnet,false,0); - + new G4PVPlacement(G4Transform3D(*MagRot, MagPos), Mag, "Helios_Magnet", m_Magnet, false, 0); } return m_Magnet; } - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -203,26 +192,26 @@ G4LogicalVolume* Helios::BuildMagnet(){ // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Helios::ReadConfiguration(NPL::InputParser parser ){ +void Helios::ReadConfiguration(NPL::InputParser parser) { vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Helios"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " detectors found " << endl; + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; - vector<string> token = {"Z","Face"}; + vector<string> token = {"Z", "Face"}; - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasToken("MagneticField")) - m_B=blocks[i]->GetDouble("MagneticField","T"); + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasToken("MagneticField")) + m_B = blocks[i]->GetDouble("MagneticField", "T"); - if(blocks[i]->HasTokenList(token)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Helios " << i+1 << endl; - double Z = blocks[i]->GetDouble("Z","mm"); + if (blocks[i]->HasTokenList(token)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Helios " << i + 1 << endl; + double Z = blocks[i]->GetDouble("Z", "mm"); string Face = blocks[i]->GetString("Face"); - AddHelios(Z,Face); + AddHelios(Z, Face); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } @@ -233,148 +222,143 @@ void Helios::ReadConfiguration(NPL::InputParser parser ){ // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void Helios::ConstructDetector(G4LogicalVolume* world){ +void Helios::ConstructDetector(G4LogicalVolume* world) { // Place the Solenoid - G4ThreeVector MagPos(0,0,0); + G4ThreeVector MagPos(0, 0, 0); G4RotationMatrix* MagRot = new G4RotationMatrix(); - new G4PVPlacement(G4Transform3D(*MagRot,MagPos), - BuildMagnet(), - "Helios",world,false,0); + new G4PVPlacement(G4Transform3D(*MagRot, MagPos), BuildMagnet(), "Helios", world, false, 0); // Add the Magnetic field static G4FieldManager* fieldMgr = new G4FieldManager(); - G4MagneticField* magField = new G4UniformMagField(G4ThreeVector(0.,0.,m_B)); + G4MagneticField* magField = new G4UniformMagField(G4ThreeVector(0., 0., m_B)); fieldMgr->SetDetectorField(magField); - if(!fieldMgr->GetChordFinder()) - fieldMgr->CreateChordFinder(magField); - BuildMagnet()->SetFieldManager(fieldMgr,true); + if (!fieldMgr->GetChordFinder()) + fieldMgr->CreateChordFinder(magField); + BuildMagnet()->SetFieldManager(fieldMgr, true); - fieldMgr->SetMinimumEpsilonStep( 1*mm); - fieldMgr->SetMaximumEpsilonStep( 10*m ); - fieldMgr->SetDeltaOneStep( 1 * mm ); + fieldMgr->SetMinimumEpsilonStep(1 * mm); + fieldMgr->SetMaximumEpsilonStep(10 * m); + fieldMgr->SetDeltaOneStep(1 * mm); // Place detectors and support inside it - for (unsigned short i = 0 ; i < m_Z.size() ; i++) { + for (unsigned short i = 0; i < m_Z.size(); i++) { G4ThreeVector DetPos; G4RotationMatrix* DetRot = NULL; - if(m_Face[i]=="Up"){ - DetPos = G4ThreeVector(0,Helios_NS::SquareTubeSide*0.5+1*mm,m_Z[i]); + if (m_Face[i] == "Up") { + DetPos = G4ThreeVector(0, Helios_NS::SquareTubeSide * 0.5 + 1 * mm, m_Z[i]); DetRot = new G4RotationMatrix(); } - else if(m_Face[i]=="Right"){ - DetPos = G4ThreeVector(Helios_NS::SquareTubeSide*0.5+1*mm,0,m_Z[i]); + else if (m_Face[i] == "Right") { + DetPos = G4ThreeVector(Helios_NS::SquareTubeSide * 0.5 + 1 * mm, 0, m_Z[i]); DetRot = new G4RotationMatrix(); - DetRot->rotateZ(90*deg); + DetRot->rotateZ(90 * deg); } - else if(m_Face[i]=="Down"){ - DetPos = G4ThreeVector(0,-Helios_NS::SquareTubeSide*0.5-1*mm,m_Z[i]); + else if (m_Face[i] == "Down") { + DetPos = G4ThreeVector(0, -Helios_NS::SquareTubeSide * 0.5 - 1 * mm, m_Z[i]); DetRot = new G4RotationMatrix(); - DetRot->rotateZ(180*deg); + DetRot->rotateZ(180 * deg); } - else if(m_Face[i]=="Left"){ - DetPos = G4ThreeVector(-Helios_NS::SquareTubeSide*0.5-1*mm,0,m_Z[i]); + else if (m_Face[i] == "Left") { + DetPos = G4ThreeVector(-Helios_NS::SquareTubeSide * 0.5 - 1 * mm, 0, m_Z[i]); DetRot = new G4RotationMatrix(); - DetRot->rotateZ(270*deg); + DetRot->rotateZ(270 * deg); } - else{ - cout << "Face orientation for Helios 2 detector "<< m_Face[i] << " Not Valid!" << endl; + else { + cout << "Face orientation for Helios 2 detector " << m_Face[i] << " Not Valid!" << endl; exit(1); } // Place the Silicon Wafer - new G4PVPlacement(G4Transform3D(*DetRot,DetPos), - BuildSiliconWafer(), - "Helios_SiliconWafer",BuildMagnet(),false,i+1); + new G4PVPlacement(G4Transform3D(*DetRot, DetPos), BuildSiliconWafer(), "Helios_SiliconWafer", BuildMagnet(), false, + i + 1); // Place the Square Tub - if(m_UsedZ.find(m_Z[i])==m_UsedZ.end()){ - G4ThreeVector TubePos(0,0,m_Z[i]); + if (m_UsedZ.find(m_Z[i]) == m_UsedZ.end()) { + G4ThreeVector TubePos(0, 0, m_Z[i]); G4RotationMatrix* TubeRot = new G4RotationMatrix(); - new G4PVPlacement(G4Transform3D(*TubeRot,TubePos), - BuildSquareTube(), - "Helios_SquareTube",BuildMagnet(),false,i+1); + new G4PVPlacement(G4Transform3D(*TubeRot, TubePos), BuildSquareTube(), "Helios_SquareTube", BuildMagnet(), false, + i + 1); m_UsedZ.insert(m_Z[i]); } } - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void Helios::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("Helios")){ - pTree->Branch("Helios", "THeliosData", &m_Event) ; +void Helios::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("Helios")) { + pTree->Branch("Helios", "THeliosData", &m_Event); } - pTree->SetBranchAddress("Helios", &m_Event) ; - + pTree->SetBranchAddress("Helios", &m_Event); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Helios::ReadSensitive(const G4Event* ){ +void Helios::ReadSensitive(const G4Event*) { m_Event->Clear(); /////////// // Resistiverimeter scorer - DSSDScorers::PS_Resistive* Scorer= (DSSDScorers::PS_Resistive*) m_HeliosScorer->GetPrimitive(0); - + DSSDScorers::PS_Resistive* Scorer = (DSSDScorers::PS_Resistive*)m_HeliosScorer->GetPrimitive(0); + // Loop on the Back unsigned int sizeBack = Scorer->GetBackMult(); - for(unsigned int i = 0 ; i < sizeBack ; i++){ - double EBack = RandGauss::shoot(Scorer->GetEnergyBack(i),Helios_NS::ResoEnergyBack); - double TBack = RandGauss::shoot(Scorer->GetTimeBack(i),Helios_NS::ResoTime); - if(EBack>Helios_NS::EnergyThreshold){ - m_Event->SetEBack(Scorer->GetDetectorBack(i),EBack); - m_Event->SetTBack(Scorer->GetDetectorBack(i),TBack); + for (unsigned int i = 0; i < sizeBack; i++) { + double EBack = RandGauss::shoot(Scorer->GetEnergyBack(i), Helios_NS::ResoEnergyBack); + double TBack = RandGauss::shoot(Scorer->GetTimeBack(i), Helios_NS::ResoTime); + if (EBack > Helios_NS::EnergyThreshold) { + m_Event->SetEBack(Scorer->GetDetectorBack(i), EBack); + m_Event->SetTBack(Scorer->GetDetectorBack(i), TBack); } } - // Loop on the Up + // Loop on the Up unsigned int sizeUp = Scorer->GetUpMult(); - for(unsigned int i = 0 ; i < sizeUp ; i++){ - double EUp = RandGauss::shoot(Scorer->GetEnergyUp(i),Helios_NS::ResoEnergyFront); - double TUp = RandGauss::shoot(Scorer->GetTimeUp(i),Helios_NS::ResoTime); - if(EUp>Helios_NS::EnergyThreshold){ - m_Event->SetEUp(Scorer->GetDetectorUp(i),EUp); - m_Event->SetTUp(Scorer->GetDetectorUp(i),TUp); + for (unsigned int i = 0; i < sizeUp; i++) { + double EUp = RandGauss::shoot(Scorer->GetEnergyUp(i), Helios_NS::ResoEnergyFront); + double TUp = RandGauss::shoot(Scorer->GetTimeUp(i), Helios_NS::ResoTime); + if (EUp > Helios_NS::EnergyThreshold) { + m_Event->SetEUp(Scorer->GetDetectorUp(i), EUp); + m_Event->SetTUp(Scorer->GetDetectorUp(i), TUp); } } - - // Loop on the Down + + // Loop on the Down unsigned int sizeDown = Scorer->GetDownMult(); - for(unsigned int i = 0 ; i < sizeDown ; i++){ - double EDw = RandGauss::shoot(Scorer->GetEnergyDown(i),Helios_NS::ResoEnergyFront); - double TDw = RandGauss::shoot(Scorer->GetTimeDown(i),Helios_NS::ResoTime); - if(EDw>Helios_NS::EnergyThreshold){ - m_Event->SetEDw(Scorer->GetDetectorDown(i),EDw); - m_Event->SetTDw(Scorer->GetDetectorDown(i),TDw); + for (unsigned int i = 0; i < sizeDown; i++) { + double EDw = RandGauss::shoot(Scorer->GetEnergyDown(i), Helios_NS::ResoEnergyFront); + double TDw = RandGauss::shoot(Scorer->GetTimeDown(i), Helios_NS::ResoTime); + if (EDw > Helios_NS::EnergyThreshold) { + m_Event->SetEDw(Scorer->GetDetectorDown(i), EDw); + m_Event->SetTDw(Scorer->GetDetectorDown(i), TDw); } } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -//////////////////////////////////////////////////////////////// -void Helios::InitializeScorers() { +//////////////////////////////////////////////////////////////// +void Helios::InitializeScorers() { // This check is necessary in case the geometry is reloaded - bool already_exist = false; - m_HeliosScorer = CheckScorer("HeliosScorer",already_exist) ; + bool already_exist = false; + m_HeliosScorer = CheckScorer("HeliosScorer", already_exist); - if(already_exist) - return ; + if (already_exist) + return; // Otherwise the scorer is initialised - G4VPrimitiveScorer* Resistive= new DSSDScorers::PS_Resistive("Resistive",1,Helios_NS::WaferLength,Helios_NS::WaferWidth,1) ; - //and register it to the multifunctionnal detector + G4VPrimitiveScorer* Resistive = + new DSSDScorers::PS_Resistive("Resistive", 1, Helios_NS::WaferLength, Helios_NS::WaferWidth, 1); + // and register it to the multifunctionnal detector m_HeliosScorer->RegisterPrimitive(Resistive); - G4VPrimitiveScorer* Inter = new InteractionScorers::PS_Interactions("Resistive",ms_InterCoord,1) ; + G4VPrimitiveScorer* Inter = new InteractionScorers::PS_Interactions("Resistive", ms_InterCoord, 1); m_HeliosScorer->RegisterPrimitive(Inter); - G4SDManager::GetSDMpointer()->AddNewDetector(m_HeliosScorer) ; + G4SDManager::GetSDMpointer()->AddNewDetector(m_HeliosScorer); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -383,22 +367,20 @@ void Helios::InitializeScorers() { //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* Helios::Construct(){ - return (NPS::VDetector*) new Helios(); -} +NPS::VDetector* Helios::Construct() { return (NPS::VDetector*)new Helios(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_Helios{ - public: - proxy_nps_Helios(){ - NPS::DetectorFactory::getInstance()->AddToken("Helios","Helios"); - NPS::DetectorFactory::getInstance()->AddDetector("Helios",Helios::Construct); - } - }; - - proxy_nps_Helios p_nps_Helios; +extern "C" { +class proxy_nps_Helios { + public: + proxy_nps_Helios() { + NPS::DetectorFactory::getInstance()->AddToken("Helios", "Helios"); + NPS::DetectorFactory::getInstance()->AddDetector("Helios", Helios::Construct); + } +}; + +proxy_nps_Helios p_nps_Helios; } diff --git a/NPSimulation/Detectors/Hira/Hira.cc b/NPSimulation/Detectors/Hira/Hira.cc index b68c39c58..efb504727 100644 --- a/NPSimulation/Detectors/Hira/Hira.cc +++ b/NPSimulation/Detectors/Hira/Hira.cc @@ -20,41 +20,41 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> -//G4 Geometry object +#include <sstream> +// G4 Geometry object #include "G4Box.hh" -#include "G4Trd.hh" -#include "G4Trap.hh" -#include "G4Tubs.hh" #include "G4Cons.hh" -#include "G4UnionSolid.hh" #include "G4ExtrudedSolid.hh" +#include "G4Trap.hh" +#include "G4Trd.hh" +#include "G4Tubs.hh" #include "G4TwoVector.hh" -//G4 sensitive +#include "G4UnionSolid.hh" +// G4 sensitive #include "G4SDManager.hh" -//G4 various object -#include "G4Material.hh" -#include "G4Transform3D.hh" -#include "G4PVPlacement.hh" +// G4 various object #include "G4Colour.hh" +#include "G4Material.hh" #include "G4PVDivision.hh" +#include "G4PVPlacement.hh" #include "G4SubtractionSolid.hh" +#include "G4Transform3D.hh" // NPS +#include "CalorimeterScorers.hh" #include "Hira.hh" #include "MaterialManager.hh" #include "SiliconScorers.hh" -#include "CalorimeterScorers.hh" // NPL #include "NPOptionManager.h" -#include "RootOutput.h" #include "NPSDetectorFactory.hh" +#include "RootOutput.h" -//using namespace OBSOLETEGENERALSCORERS ; +// using namespace OBSOLETEGENERALSCORERS ; using namespace HIRA; @@ -65,495 +65,480 @@ using namespace std; using namespace CLHEP; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Hira::Hira(){ - InitializeMaterial(); - m_EventHira = new THiraData(); - - // Silicon - m_SiliconVisAtt = new G4VisAttributes(G4Colour(0.3, 0.28, 0.3, 0.95)) ; - m_SiliconVisAtt2 = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)) ; - // CsI Color - m_CsIVisAtt = new G4VisAttributes(G4Colour(0.529412, 0.807843, 0.980392, 0.95)) ; - m_CsIVisAtt->SetForceWireframe(false); - m_LogicThinSi = 0; - m_LogicThickSi = 0; - m_LogicCsICrystal = 0; - m_LogicCluster = 0; - - m_build_ThickSi= 1; - m_build_ThinSi= 1; - m_build_CsI= 1; +Hira::Hira() { + InitializeMaterial(); + m_EventHira = new THiraData(); + + // Silicon + m_SiliconVisAtt = new G4VisAttributes(G4Colour(0.3, 0.28, 0.3, 0.95)); + m_SiliconVisAtt2 = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)); + // CsI Color + m_CsIVisAtt = new G4VisAttributes(G4Colour(0.529412, 0.807843, 0.980392, 0.95)); + m_CsIVisAtt->SetForceWireframe(false); + m_LogicThinSi = 0; + m_LogicThickSi = 0; + m_LogicCsICrystal = 0; + m_LogicCluster = 0; + + m_build_ThickSi = 1; + m_build_ThinSi = 1; + m_build_CsI = 1; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Hira::~Hira(){ -} +Hira::~Hira() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Virtual Method of VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Hira::ReadConfiguration(NPL::InputParser parser ){ - vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("HiraTelescope"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " Telescope found " << endl; - - // Cartesian Case - vector<string> cart = {"A","B","C","D","ThickSi_E","ThinSi_DE","CsI"}; - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(cart)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Hira Telescope " << i+1 << endl; - G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("A","mm")); - G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("B","mm")); - G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("C","mm")); - G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("D","mm")); - m_build_ThinSi = blocks[i]->GetInt("ThinSi_DE"); - m_build_ThickSi = blocks[i]->GetInt("ThickSi_E"); - m_build_CsI = blocks[i]->GetInt("CsI"); - - AddTelescope(A,B,C,D) ; - } - - else{ - cout << "ERROR: Missing token for M2Telescope blocks, check your input file" << endl; - exit(1); - } +void Hira::ReadConfiguration(NPL::InputParser parser) { + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("HiraTelescope"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " Telescope found " << endl; + + // Cartesian Case + vector<string> cart = {"A", "B", "C", "D", "ThickSi_E", "ThinSi_DE", "CsI"}; + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(cart)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Hira Telescope " << i + 1 << endl; + G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("A", "mm")); + G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("B", "mm")); + G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("C", "mm")); + G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("D", "mm")); + m_build_ThinSi = blocks[i]->GetInt("ThinSi_DE"); + m_build_ThickSi = blocks[i]->GetInt("ThickSi_E"); + m_build_CsI = blocks[i]->GetInt("CsI"); + + AddTelescope(A, B, C, D); } + + else { + cout << "ERROR: Missing token for M2Telescope blocks, check your input file" << endl; + exit(1); + } + } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Hira::AddTelescope(G4ThreeVector Pos1, G4ThreeVector Pos2, G4ThreeVector Pos3, G4ThreeVector Pos4){ - G4ThreeVector Pos=(Pos1+Pos2+Pos3+Pos4)/4.; - G4ThreeVector u = Pos4-Pos2; - G4ThreeVector w = Pos.unit(); - G4ThreeVector v = w.cross(u); - u = u.unit(); v = v.unit(); w = w.unit(); - Pos = Pos + w*Length*0.5; - - m_Type.push_back(1); - m_Pos.push_back(Pos); - m_Rot.push_back(new G4RotationMatrix(u,v,w)); +void Hira::AddTelescope(G4ThreeVector Pos1, G4ThreeVector Pos2, G4ThreeVector Pos3, G4ThreeVector Pos4) { + G4ThreeVector Pos = (Pos1 + Pos2 + Pos3 + Pos4) / 4.; + G4ThreeVector u = Pos4 - Pos2; + G4ThreeVector w = Pos.unit(); + G4ThreeVector v = w.cross(u); + u = u.unit(); + v = v.unit(); + w = w.unit(); + Pos = Pos + w * Length * 0.5; + + m_Type.push_back(1); + m_Pos.push_back(Pos); + m_Rot.push_back(new G4RotationMatrix(u, v, w)); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void Hira::ConstructDetector(G4LogicalVolume* world){ - unsigned int mysize = m_Pos.size(); - - for(unsigned int i = 0 ; i < mysize ; i++){ - VolumeMaker(i + 1, m_Pos[i], m_Rot[i], world); - } -} - +void Hira::ConstructDetector(G4LogicalVolume* world) { + unsigned int mysize = m_Pos.size(); + for (unsigned int i = 0; i < mysize; i++) { + VolumeMaker(i + 1, m_Pos[i], m_Rot[i], world); + } +} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Hira::ReadSensitive(const G4Event* event){ - m_EventHira->Clear(); - - // ThinSi // - if(m_build_ThinSi){ - NPS::HitsMap<G4double*>* ThinSiHitMap; - std::map<G4int, G4double**>::iterator ThinSi_itr; - - G4int ThinSiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("Hira_ThinSiScorer/ThinSi"); - ThinSiHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(ThinSiCollectionID)); - - // Loop on the ThinSi map - for (ThinSi_itr = ThinSiHitMap->GetMap()->begin() ; ThinSi_itr != ThinSiHitMap->GetMap()->end() ; ThinSi_itr++){ - G4double* Info = *(ThinSi_itr->second); - double E_ThinSi = RandGauss::shoot(Info[0],ResoThinSi); - - if(E_ThinSi>EnergyThreshold){ - m_EventHira->SetHiraThinSiStripEEnergy(E_ThinSi); - m_EventHira->SetHiraThinSiStripEDetectorNbr(Info[7]-1); - m_EventHira->SetHiraThinSiStripEStripNbr(Info[8]-1); - - m_EventHira->SetHiraThinSiStripTTime(Info[1]); - m_EventHira->SetHiraThinSiStripTDetectorNbr(Info[7]-1); - m_EventHira->SetHiraThinSiStripTStripNbr(Info[8]-1); - } - } - - // Clear Map for next event - ThinSiHitMap->clear(); +void Hira::ReadSensitive(const G4Event* event) { + m_EventHira->Clear(); + + // ThinSi // + if (m_build_ThinSi) { + NPS::HitsMap<G4double*>* ThinSiHitMap; + std::map<G4int, G4double**>::iterator ThinSi_itr; + + G4int ThinSiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("Hira_ThinSiScorer/ThinSi"); + ThinSiHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(ThinSiCollectionID)); + + // Loop on the ThinSi map + for (ThinSi_itr = ThinSiHitMap->GetMap()->begin(); ThinSi_itr != ThinSiHitMap->GetMap()->end(); ThinSi_itr++) { + G4double* Info = *(ThinSi_itr->second); + double E_ThinSi = RandGauss::shoot(Info[0], ResoThinSi); + + if (E_ThinSi > EnergyThreshold) { + m_EventHira->SetHiraThinSiStripEEnergy(E_ThinSi); + m_EventHira->SetHiraThinSiStripEDetectorNbr(Info[7] - 1); + m_EventHira->SetHiraThinSiStripEStripNbr(Info[8] - 1); + + m_EventHira->SetHiraThinSiStripTTime(Info[1]); + m_EventHira->SetHiraThinSiStripTDetectorNbr(Info[7] - 1); + m_EventHira->SetHiraThinSiStripTStripNbr(Info[8] - 1); + } } - - // ThickSi // - if(m_build_ThickSi){ - NPS::HitsMap<G4double*>* ThickSiHitMap; - std::map<G4int, G4double**>::iterator ThickSi_itr; - G4int ThickSiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("Hira_ThickSiScorer/ThickSi"); - ThickSiHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(ThickSiCollectionID)); - - // Loop on the ThickSi map - for (ThickSi_itr = ThickSiHitMap->GetMap()->begin() ; ThickSi_itr != ThickSiHitMap->GetMap()->end() ; ThickSi_itr++){ - G4double* Info = *(ThickSi_itr->second); - double EF = RandGauss::shoot(Info[0],ResoThickSi); - double EB = RandGauss::shoot(Info[0],ResoThickSi); - - // Interraction Coordinates - ms_InterCoord->SetDetectedPositionX(Info[2]) ; - ms_InterCoord->SetDetectedPositionY(Info[3]) ; - ms_InterCoord->SetDetectedPositionZ(Info[4]) ; - ms_InterCoord->SetDetectedAngleTheta(Info[5]/deg) ; - ms_InterCoord->SetDetectedAnglePhi(Info[6]/deg) ; - - if(EF>EnergyThreshold){ - m_EventHira->SetHiraThickSiStripXEEnergy(EF); - m_EventHira->SetHiraThickSiStripXEDetectorNbr(Info[7]-1); - m_EventHira->SetHiraThickSiStripXEStripNbr(Info[8]-1); - - m_EventHira->SetHiraThickSiStripXTTime(Info[1]); - m_EventHira->SetHiraThickSiStripXTDetectorNbr(Info[7]-1); - m_EventHira->SetHiraThickSiStripXTStripNbr(Info[8]-1); - } - - if(EB>EnergyThreshold){ - m_EventHira->SetHiraThickSiStripYEEnergy(EB); - m_EventHira->SetHiraThickSiStripYEDetectorNbr(Info[7]-1); - m_EventHira->SetHiraThickSiStripYEStripNbr(Info[9]-1); - - m_EventHira->SetHiraThickSiStripYTTime(Info[1]); - m_EventHira->SetHiraThickSiStripYTDetectorNbr(Info[7]-1); - m_EventHira->SetHiraThickSiStripYTStripNbr(Info[9]-1); - - } - } - // Clear Map for next event - ThickSiHitMap->clear(); + + // Clear Map for next event + ThinSiHitMap->clear(); + } + + // ThickSi // + if (m_build_ThickSi) { + NPS::HitsMap<G4double*>* ThickSiHitMap; + std::map<G4int, G4double**>::iterator ThickSi_itr; + G4int ThickSiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("Hira_ThickSiScorer/ThickSi"); + ThickSiHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(ThickSiCollectionID)); + + // Loop on the ThickSi map + for (ThickSi_itr = ThickSiHitMap->GetMap()->begin(); ThickSi_itr != ThickSiHitMap->GetMap()->end(); ThickSi_itr++) { + G4double* Info = *(ThickSi_itr->second); + double EF = RandGauss::shoot(Info[0], ResoThickSi); + double EB = RandGauss::shoot(Info[0], ResoThickSi); + + // Interraction Coordinates + ms_InterCoord->SetDetectedPositionX(Info[2]); + ms_InterCoord->SetDetectedPositionY(Info[3]); + ms_InterCoord->SetDetectedPositionZ(Info[4]); + ms_InterCoord->SetDetectedAngleTheta(Info[5] / deg); + ms_InterCoord->SetDetectedAnglePhi(Info[6] / deg); + + if (EF > EnergyThreshold) { + m_EventHira->SetHiraThickSiStripXEEnergy(EF); + m_EventHira->SetHiraThickSiStripXEDetectorNbr(Info[7] - 1); + m_EventHira->SetHiraThickSiStripXEStripNbr(Info[8] - 1); + + m_EventHira->SetHiraThickSiStripXTTime(Info[1]); + m_EventHira->SetHiraThickSiStripXTDetectorNbr(Info[7] - 1); + m_EventHira->SetHiraThickSiStripXTStripNbr(Info[8] - 1); + } + + if (EB > EnergyThreshold) { + m_EventHira->SetHiraThickSiStripYEEnergy(EB); + m_EventHira->SetHiraThickSiStripYEDetectorNbr(Info[7] - 1); + m_EventHira->SetHiraThickSiStripYEStripNbr(Info[9] - 1); + + m_EventHira->SetHiraThickSiStripYTTime(Info[1]); + m_EventHira->SetHiraThickSiStripYTDetectorNbr(Info[7] - 1); + m_EventHira->SetHiraThickSiStripYTStripNbr(Info[9] - 1); + } } - - // CsI // - if(m_build_CsI){ - CalorimeterScorers::PS_Calorimeter* Scorer= (CalorimeterScorers::PS_Calorimeter*) m_CsIScorer->GetPrimitive(0); - unsigned int size = Scorer->GetMult(); - for(unsigned int i = 0 ; i < size ; i++){ - vector<unsigned int> level = Scorer->GetLevel(i); - double E_CsI = RandGauss::shoot(Scorer->GetEnergy(i),ResoCsI); - if(E_CsI>EnergyThreshold){ - m_EventHira->SetHiraCsIEEnergy(E_CsI); - m_EventHira->SetHiraCsIEDetectorNbr(level[0]-1); - m_EventHira->SetHiraCsIECristalNbr(level[1]-1); - } - } + // Clear Map for next event + ThickSiHitMap->clear(); + } + + // CsI // + if (m_build_CsI) { + CalorimeterScorers::PS_Calorimeter* Scorer = (CalorimeterScorers::PS_Calorimeter*)m_CsIScorer->GetPrimitive(0); + unsigned int size = Scorer->GetMult(); + for (unsigned int i = 0; i < size; i++) { + vector<unsigned int> level = Scorer->GetLevel(i); + double E_CsI = RandGauss::shoot(Scorer->GetEnergy(i), ResoCsI); + if (E_CsI > EnergyThreshold) { + m_EventHira->SetHiraCsIEEnergy(E_CsI); + m_EventHira->SetHiraCsIEDetectorNbr(level[0] - 1); + m_EventHira->SetHiraCsIECristalNbr(level[1] - 1); + } } + } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Hira::InitializeScorers(){ - //Look for previous definition of the scorer (geometry reload) - bool already_exist = false; - vector<G4int> NestingLevel; - NestingLevel.push_back(0); - NestingLevel.push_back(2); - - m_ThinSiStripScorer = CheckScorer("Hira_ThinSiScorer",already_exist); - m_ThickSiStripScorer = CheckScorer("Hira_ThickSiScorer",already_exist); - m_CsIScorer = CheckScorer("Hira_CsIScorer",already_exist); - - // if the scorer were created previously nothing else need to be made - if(already_exist) return; - - G4VPrimitiveScorer* ThinSiScorer = new SILICONSCORERS::PS_Silicon_Rectangle("ThinSi",0, - SiliconFace, - SiliconFace, - NumberOfStrip, - 1); - - m_ThinSiStripScorer->RegisterPrimitive(ThinSiScorer); - - G4VPrimitiveScorer* ThickSiScorer = new SILICONSCORERS::PS_Silicon_Rectangle("ThickSi",0, - SiliconFace, - SiliconFace, - NumberOfStrip, - NumberOfStrip); - - m_ThickSiStripScorer->RegisterPrimitive(ThickSiScorer); - - G4VPrimitiveScorer* CsIScorer= new CalorimeterScorers::PS_Calorimeter("CsI",NestingLevel); - - m_CsIScorer->RegisterPrimitive(CsIScorer); - - // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_ThinSiStripScorer) ; - G4SDManager::GetSDMpointer()->AddNewDetector(m_ThickSiStripScorer) ; - G4SDManager::GetSDMpointer()->AddNewDetector(m_CsIScorer) ; +void Hira::InitializeScorers() { + // Look for previous definition of the scorer (geometry reload) + bool already_exist = false; + vector<G4int> NestingLevel; + NestingLevel.push_back(0); + NestingLevel.push_back(2); + + m_ThinSiStripScorer = CheckScorer("Hira_ThinSiScorer", already_exist); + m_ThickSiStripScorer = CheckScorer("Hira_ThickSiScorer", already_exist); + m_CsIScorer = CheckScorer("Hira_CsIScorer", already_exist); + + // if the scorer were created previously nothing else need to be made + if (already_exist) + return; + + G4VPrimitiveScorer* ThinSiScorer = + new SILICONSCORERS::PS_Silicon_Rectangle("ThinSi", 0, SiliconFace, SiliconFace, NumberOfStrip, 1); + + m_ThinSiStripScorer->RegisterPrimitive(ThinSiScorer); + + G4VPrimitiveScorer* ThickSiScorer = + new SILICONSCORERS::PS_Silicon_Rectangle("ThickSi", 0, SiliconFace, SiliconFace, NumberOfStrip, NumberOfStrip); + + m_ThickSiStripScorer->RegisterPrimitive(ThickSiScorer); + + G4VPrimitiveScorer* CsIScorer = new CalorimeterScorers::PS_Calorimeter("CsI", NestingLevel); + + m_CsIScorer->RegisterPrimitive(CsIScorer); + + // Add All Scorer to the Global Scorer Manager + G4SDManager::GetSDMpointer()->AddNewDetector(m_ThinSiStripScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_ThickSiStripScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_CsIScorer); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Hira::InitializeRootOutput(){ - TTree *pTree = RootOutput::getInstance()->GetTree(); - if(!pTree->FindBranch("Hira")){ - pTree->Branch("Hira", "THiraData", &m_EventHira) ; - } - // This insure that the object are correctly bind in case of - // a redifinition of the geometry in the simulation - pTree->SetBranchAddress("Hira", &m_EventHira) ; +void Hira::InitializeRootOutput() { + TTree* pTree = RootOutput::getInstance()->GetTree(); + if (!pTree->FindBranch("Hira")) { + pTree->Branch("Hira", "THiraData", &m_EventHira); + } + // This insure that the object are correctly bind in case of + // a redifinition of the geometry in the simulation + pTree->SetBranchAddress("Hira", &m_EventHira); } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Hira::VolumeMaker(G4int DetectorNumber, - G4ThreeVector MMpos, - G4RotationMatrix* MMrot, - G4LogicalVolume* world) -{ - G4double NbrTelescopes = DetectorNumber ; - G4String DetNumber ; - ostringstream Number ; - Number << NbrTelescopes ; - DetNumber = Number.str() ; - - - //////////////////////////////////////////////////////////////// - ////////////// Starting Volume Definition ////////////////////// - //////////////////////////////////////////////////////////////// - G4String Name = "Hira" + DetNumber ; - - // Definition of the volume containing the sensitive detector - G4Box* solidMotherVolume = new G4Box(Name, 0.5*FaceFront, 0.5*FaceBack, 0.5*Length); - m_logicMotherVolume = new G4LogicalVolume(solidMotherVolume, m_MaterialVacuum, Name, 0, 0, 0); - - new G4PVPlacement(G4Transform3D(*MMrot, MMpos), m_logicMotherVolume, Name, world, false, DetectorNumber); - - G4VisAttributes* MotherVolumeVisAtt = new G4VisAttributes(G4Colour(0.90, 0.90, 0.90)); - MotherVolumeVisAtt->SetForceWireframe(true); - m_logicMotherVolume->SetVisAttributes(G4VisAttributes::Invisible); - - /////////////////////////////////////////////////// - ///////////////////// Thin Si ///////////////////// - /////////////////////////////////////////////////// - G4String NameThinSi = "ThinSi"+DetNumber; - //if(!m_LogicThinSi){ - if(m_build_ThinSi){ - G4Box* solidThinSi = new G4Box(NameThinSi, 0.5*SiliconFace, 0.5*SiliconFace, 0.5*ThinSiThickness); ; - m_LogicThinSi = new G4LogicalVolume(solidThinSi, m_MaterialSilicon, "logicThinSi", 0, 0, 0); - - G4ThreeVector positionThinSi = G4ThreeVector(0, 0, ThinSi_PosZ); - - new G4PVPlacement(new G4RotationMatrix(0,0,0), - positionThinSi, - m_LogicThinSi,"ThinSi", - m_logicMotherVolume,false,DetectorNumber); - - // Set ThinSi sensible - m_LogicThinSi->SetSensitiveDetector(m_ThinSiStripScorer); - - // Visualisation of ThinSi - m_LogicThinSi->SetVisAttributes(m_SiliconVisAtt) ; - } - - /////////////////////////////////////////////////// - ///////////////////// Thick Si //////////////////// - /////////////////////////////////////////////////// - G4String NameThickSi = "ThickSi"+DetNumber; - //if(!m_LogicThickSi){ - if(m_build_ThickSi){ - G4Box* solidThickSi = new G4Box(NameThickSi, 0.5*SiliconFace, 0.5*SiliconFace, 0.5*ThickSiThickness); - m_LogicThickSi = new G4LogicalVolume(solidThickSi, m_MaterialSilicon, "logicThickSi", 0, 0, 0); - - G4ThreeVector positionThickSi = G4ThreeVector(0, 0, ThickSi_PosZ); - - new G4PVPlacement(new G4RotationMatrix(0,0,0), - positionThickSi, - m_LogicThickSi,"ThickSi", - m_logicMotherVolume,false,DetectorNumber); - - // Set ThickSi sensible - m_LogicThickSi->SetSensitiveDetector(m_ThickSiStripScorer); - - // Visualisation of ThickSi - m_LogicThickSi->SetVisAttributes(m_SiliconVisAtt2) ; - } - - /////////////////////////////////////////////////// - /////////////////////// CsI /////////////////////// - /////////////////////////////////////////////////// - G4String NameCsI = "CsI"+DetNumber; - - double X1 = (CsIXFront-CsIXBack)/2.; - double Y1 = (CsIYFront-CsIYBack)/2.; - double l = sqrt(pow(X1,2) + pow(Y1,2)); - - double pDz = 0.5*CsIThickness; - double pTheta = -atan( (l)/(CsIThickness) ); - double pPhi = atan( X1/Y1 ); - double pDy1 = 0.5*CsIYFront; - double pDx1 = 0.5*CsIXFront; - double pDx2 = 0.5*CsIXFront; - double pAlp1 = 0; - double pDy2 = 0.5*CsIYBack; - double pDx3 = 0.5*CsIXBack; - double pDx4 = 0.5*CsIXBack; - double pAlp2 = 0; - - G4Trap* solidCsIStage = new G4Trap(NameCsI, pDz, pTheta, pPhi, pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3, pDx4, pAlp2); - - m_LogicCsICrystal = new G4LogicalVolume(solidCsIStage, m_MaterialCsI, "logicCsICrystal", 0, 0, 0); - - // Set CsI sensible - m_LogicCsICrystal->SetSensitiveDetector(m_CsIScorer); - - // Visualisation of CsI - m_LogicCsICrystal->SetVisAttributes(m_CsIVisAtt); - - //if(!m_LogicCluster){ - if(m_build_CsI){ - // Sub Mother Volume - G4Trd* solidCluster = new G4Trd("SolidCluster", 0.5*ClusterFaceFront,0.5*ClusterFaceBack,0.5*ClusterFaceFront,0.5*ClusterFaceBack, 0.5*CsIThickness); - m_LogicCluster = new G4LogicalVolume(solidCluster, m_MaterialVacuum, "LogicSolidCluster", 0, 0, 0); - m_LogicCluster->SetVisAttributes(G4VisAttributes::Invisible); - G4VisAttributes* TempVisAtt = new G4VisAttributes(G4Colour(0.415686, 0.352941, 0.803922, 0.1)) ; - TempVisAtt->SetForceWireframe(true); - m_LogicCluster->SetVisAttributes(TempVisAtt); - - G4ThreeVector FramePos(0,0,CsI_PosZ); - - new G4PVPlacement(new G4RotationMatrix(0,0,0), - FramePos, - m_LogicCluster,"Cluster", - m_logicMotherVolume,false,0); - - //double alpha = atan((CsIXBack-CsIXFront)/CsIThickness); - //double dl = (CsIThickness/2)*tan(alpha); - double dl = (CsIXBack-CsIXFront)/4; - const G4double CsIXMiddle = 0.5*CsIXFront + dl; - const G4double CsIYMiddle = 0.5*CsIYFront + dl; - const G4double DistInterCsIX = CsIXMiddle+0.5*DistInterCsI; - const G4double DistInterCsIY = CsIYMiddle+0.5*DistInterCsI; - - G4ThreeVector Origin(-(DistInterCsIX),-(DistInterCsIY),0); - G4ThreeVector Pos; - const G4double dangle = 90.*deg; - // A cluster is a 2 by 2 aggregat of CsI crystal - unsigned int CsINbr = 1; - for(unsigned int i = 0 ; i < 2 ; i++){ - for(unsigned int j = 0 ; j < 2 ; j++){ - G4RotationMatrix* rotM = new G4RotationMatrix; - unsigned int CrystalNbr = CsINbr++; - if(i==0 && j==0)rotM->rotateZ(0); - if(i==1 && j==0)rotM->rotateZ(dangle); - if(i==0 && j==1)rotM->rotateZ(-dangle); - if(i==1 && j==1)rotM->rotateZ(2*dangle); - - if(i==0 && j==0) Pos = Origin; - if(i==1 && j==0) Pos = G4ThreeVector((DistInterCsIX),-(DistInterCsIY),0); - if(i==0 && j==1) Pos = G4ThreeVector(-(DistInterCsIX),(DistInterCsIY),0); - if(i==1 && j==1) Pos = G4ThreeVector((DistInterCsIX),(DistInterCsIY),0); - //Pos = Origin + G4ThreeVector(i*(DistInterCsIX),j*(DistInterCsIY),0); - - new G4PVPlacement(G4Transform3D(*rotM,Pos), - m_LogicCsICrystal, - "CsI_Cristal", - m_LogicCluster, - false, - CrystalNbr,false); - delete rotM; - } - } - - ///////////////////// - // 3x3 CsI crystal // - ///////////////////// - /*double pTheta_1 = -5.6*deg; - double pPhi_1 = 46.5*deg; - G4Trap* solidCsI1 = new G4Trap(NameCsI, 0.5*CsIThickness, pTheta_1, pPhi_1, 0.5*23.73, 0.5*23.73, 0.5*23.73, 0, 0.5*32.53, 0.5*32.53, 0.5*32.53, 0); - - cout << "Theta1= " << pTheta_1*180/3.1415 << endl; - cout << "Phi1= " << pPhi_1*180/3.1415 << endl; - - double pTheta_2 = -4.0*deg; - double pPhi_2 = 0*deg; - G4Trap* solidCsI2 = new G4Trap(NameCsI, 0.5*CsIThickness, pTheta_2, pPhi_2, 0.5*22.55, 0.5*23.73, 0.5*23.73, 0, 0.5*28.05, 0.5*32.53, 0.5*32.53, 0); - - G4Trd* solidCsI3 = new G4Trd("SolidCluster", 0.5*22.55,0.5*28.05,0.5*22.55,0.5*28.05, 0.5*CsIThickness); - - G4RotationMatrix* rotM1 = new G4RotationMatrix; - m_LogicCsICrystal = new G4LogicalVolume(solidCsI1, m_MaterialCsI, "logicCsICrystal", 0, 0, 0); - m_LogicCsICrystal->SetSensitiveDetector(m_CsIScorer); - m_LogicCsICrystal->SetVisAttributes(m_CsIVisAtt); - double Xpos = 27; - double Ypos = 27; - Pos = G4ThreeVector(-Xpos,-Ypos,0); - rotM1->rotateZ(0*deg); - new G4PVPlacement(G4Transform3D(*rotM1,Pos),m_LogicCsICrystal,"CsI_Cristal1",m_LogicCluster,false,1,true); - - rotM1->rotateZ(-90*deg); - Pos = G4ThreeVector(-Xpos,Ypos,0); - new G4PVPlacement(G4Transform3D(*rotM1,Pos),m_LogicCsICrystal,"CsI_Cristal2",m_LogicCluster,false,3,true); - - rotM1->rotateZ(-90*deg); - Pos = G4ThreeVector(Xpos,Ypos,0); - new G4PVPlacement(G4Transform3D(*rotM1,Pos),m_LogicCsICrystal,"CsI_Cristal7",m_LogicCluster,false,7,true); - - rotM1->rotateZ(-90*deg); - Pos = G4ThreeVector(Xpos,-Ypos,0); - new G4PVPlacement(G4Transform3D(*rotM1,Pos),m_LogicCsICrystal,"CsI_Cristal9",m_LogicCluster,false,9,true); - - G4RotationMatrix* rotM3 = new G4RotationMatrix; - m_LogicCsICrystal = new G4LogicalVolume(solidCsI3, m_MaterialCsI, "logicCsICrystal", 0, 0, 0); - m_LogicCsICrystal->SetSensitiveDetector(m_CsIScorer); - m_LogicCsICrystal->SetVisAttributes(m_CsIVisAtt); - Pos = G4ThreeVector(0.,0.,0); - rotM3->rotateZ(0); - new G4PVPlacement(G4Transform3D(*rotM3,Pos),m_LogicCsICrystal,"CsI_Cristal5",m_LogicCluster,false,5,true); - - G4RotationMatrix* rotM2 = new G4RotationMatrix; - m_LogicCsICrystal = new G4LogicalVolume(solidCsI2, m_MaterialCsI, "logicCsICrystal", 0, 0, 0); - m_LogicCsICrystal->SetSensitiveDetector(m_CsIScorer); - m_LogicCsICrystal->SetVisAttributes(m_CsIVisAtt); - Pos = G4ThreeVector(-Xpos,0.,0); - rotM2->rotateZ(0*deg); - new G4PVPlacement(G4Transform3D(*rotM2,Pos),m_LogicCsICrystal,"CsI_Cristal2",m_LogicCluster,false,2,true); - - Pos = G4ThreeVector(Xpos,0.,0); - rotM2->rotateZ(180*deg); - new G4PVPlacement(G4Transform3D(*rotM2,Pos),m_LogicCsICrystal,"CsI_Cristal8",m_LogicCluster,false,8,true); - Pos = G4ThreeVector(0,-Ypos,0); - rotM2->rotateZ(-90*deg); - new G4PVPlacement(G4Transform3D(*rotM2,Pos),m_LogicCsICrystal,"CsI_Cristal4",m_LogicCluster,false,4,true); - - Pos = G4ThreeVector(0,Ypos,0); - rotM2->rotateZ(180*deg); - new G4PVPlacement(G4Transform3D(*rotM2,Pos),m_LogicCsICrystal,"CsI_Cristal6",m_LogicCluster,false,6,true);*/ - +void Hira::VolumeMaker(G4int DetectorNumber, G4ThreeVector MMpos, G4RotationMatrix* MMrot, G4LogicalVolume* world) { + G4double NbrTelescopes = DetectorNumber; + G4String DetNumber; + ostringstream Number; + Number << NbrTelescopes; + DetNumber = Number.str(); + + //////////////////////////////////////////////////////////////// + ////////////// Starting Volume Definition ////////////////////// + //////////////////////////////////////////////////////////////// + G4String Name = "Hira" + DetNumber; + + // Definition of the volume containing the sensitive detector + G4Box* solidMotherVolume = new G4Box(Name, 0.5 * FaceFront, 0.5 * FaceBack, 0.5 * Length); + m_logicMotherVolume = new G4LogicalVolume(solidMotherVolume, m_MaterialVacuum, Name, 0, 0, 0); + + new G4PVPlacement(G4Transform3D(*MMrot, MMpos), m_logicMotherVolume, Name, world, false, DetectorNumber); + + G4VisAttributes* MotherVolumeVisAtt = new G4VisAttributes(G4Colour(0.90, 0.90, 0.90)); + MotherVolumeVisAtt->SetForceWireframe(true); + m_logicMotherVolume->SetVisAttributes(G4VisAttributes::GetInvisible()); + + /////////////////////////////////////////////////// + ///////////////////// Thin Si ///////////////////// + /////////////////////////////////////////////////// + G4String NameThinSi = "ThinSi" + DetNumber; + // if(!m_LogicThinSi){ + if (m_build_ThinSi) { + G4Box* solidThinSi = new G4Box(NameThinSi, 0.5 * SiliconFace, 0.5 * SiliconFace, 0.5 * ThinSiThickness); + ; + m_LogicThinSi = new G4LogicalVolume(solidThinSi, m_MaterialSilicon, "logicThinSi", 0, 0, 0); + + G4ThreeVector positionThinSi = G4ThreeVector(0, 0, ThinSi_PosZ); + + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), positionThinSi, m_LogicThinSi, "ThinSi", m_logicMotherVolume, + false, DetectorNumber); + + // Set ThinSi sensible + m_LogicThinSi->SetSensitiveDetector(m_ThinSiStripScorer); + + // Visualisation of ThinSi + m_LogicThinSi->SetVisAttributes(m_SiliconVisAtt); + } + + /////////////////////////////////////////////////// + ///////////////////// Thick Si //////////////////// + /////////////////////////////////////////////////// + G4String NameThickSi = "ThickSi" + DetNumber; + // if(!m_LogicThickSi){ + if (m_build_ThickSi) { + G4Box* solidThickSi = new G4Box(NameThickSi, 0.5 * SiliconFace, 0.5 * SiliconFace, 0.5 * ThickSiThickness); + m_LogicThickSi = new G4LogicalVolume(solidThickSi, m_MaterialSilicon, "logicThickSi", 0, 0, 0); + + G4ThreeVector positionThickSi = G4ThreeVector(0, 0, ThickSi_PosZ); + + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), positionThickSi, m_LogicThickSi, "ThickSi", m_logicMotherVolume, + false, DetectorNumber); + + // Set ThickSi sensible + m_LogicThickSi->SetSensitiveDetector(m_ThickSiStripScorer); + + // Visualisation of ThickSi + m_LogicThickSi->SetVisAttributes(m_SiliconVisAtt2); + } + + /////////////////////////////////////////////////// + /////////////////////// CsI /////////////////////// + /////////////////////////////////////////////////// + G4String NameCsI = "CsI" + DetNumber; + + double X1 = (CsIXFront - CsIXBack) / 2.; + double Y1 = (CsIYFront - CsIYBack) / 2.; + double l = sqrt(pow(X1, 2) + pow(Y1, 2)); + + double pDz = 0.5 * CsIThickness; + double pTheta = -atan((l) / (CsIThickness)); + double pPhi = atan(X1 / Y1); + double pDy1 = 0.5 * CsIYFront; + double pDx1 = 0.5 * CsIXFront; + double pDx2 = 0.5 * CsIXFront; + double pAlp1 = 0; + double pDy2 = 0.5 * CsIYBack; + double pDx3 = 0.5 * CsIXBack; + double pDx4 = 0.5 * CsIXBack; + double pAlp2 = 0; + + G4Trap* solidCsIStage = new G4Trap(NameCsI, pDz, pTheta, pPhi, pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3, pDx4, pAlp2); + + m_LogicCsICrystal = new G4LogicalVolume(solidCsIStage, m_MaterialCsI, "logicCsICrystal", 0, 0, 0); + + // Set CsI sensible + m_LogicCsICrystal->SetSensitiveDetector(m_CsIScorer); + + // Visualisation of CsI + m_LogicCsICrystal->SetVisAttributes(m_CsIVisAtt); + + // if(!m_LogicCluster){ + if (m_build_CsI) { + // Sub Mother Volume + G4Trd* solidCluster = new G4Trd("SolidCluster", 0.5 * ClusterFaceFront, 0.5 * ClusterFaceBack, + 0.5 * ClusterFaceFront, 0.5 * ClusterFaceBack, 0.5 * CsIThickness); + m_LogicCluster = new G4LogicalVolume(solidCluster, m_MaterialVacuum, "LogicSolidCluster", 0, 0, 0); + m_LogicCluster->SetVisAttributes(G4VisAttributes::GetInvisible()); + G4VisAttributes* TempVisAtt = new G4VisAttributes(G4Colour(0.415686, 0.352941, 0.803922, 0.1)); + TempVisAtt->SetForceWireframe(true); + m_LogicCluster->SetVisAttributes(TempVisAtt); + + G4ThreeVector FramePos(0, 0, CsI_PosZ); + + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), FramePos, m_LogicCluster, "Cluster", m_logicMotherVolume, false, + 0); + + // double alpha = atan((CsIXBack-CsIXFront)/CsIThickness); + // double dl = (CsIThickness/2)*tan(alpha); + double dl = (CsIXBack - CsIXFront) / 4; + const G4double CsIXMiddle = 0.5 * CsIXFront + dl; + const G4double CsIYMiddle = 0.5 * CsIYFront + dl; + const G4double DistInterCsIX = CsIXMiddle + 0.5 * DistInterCsI; + const G4double DistInterCsIY = CsIYMiddle + 0.5 * DistInterCsI; + + G4ThreeVector Origin(-(DistInterCsIX), -(DistInterCsIY), 0); + G4ThreeVector Pos; + const G4double dangle = 90. * deg; + // A cluster is a 2 by 2 aggregat of CsI crystal + unsigned int CsINbr = 1; + for (unsigned int i = 0; i < 2; i++) { + for (unsigned int j = 0; j < 2; j++) { + G4RotationMatrix* rotM = new G4RotationMatrix; + unsigned int CrystalNbr = CsINbr++; + if (i == 0 && j == 0) + rotM->rotateZ(0); + if (i == 1 && j == 0) + rotM->rotateZ(dangle); + if (i == 0 && j == 1) + rotM->rotateZ(-dangle); + if (i == 1 && j == 1) + rotM->rotateZ(2 * dangle); + + if (i == 0 && j == 0) + Pos = Origin; + if (i == 1 && j == 0) + Pos = G4ThreeVector((DistInterCsIX), -(DistInterCsIY), 0); + if (i == 0 && j == 1) + Pos = G4ThreeVector(-(DistInterCsIX), (DistInterCsIY), 0); + if (i == 1 && j == 1) + Pos = G4ThreeVector((DistInterCsIX), (DistInterCsIY), 0); + // Pos = Origin + G4ThreeVector(i*(DistInterCsIX),j*(DistInterCsIY),0); + + new G4PVPlacement(G4Transform3D(*rotM, Pos), m_LogicCsICrystal, "CsI_Cristal", m_LogicCluster, false, + CrystalNbr, false); + delete rotM; + } } -} + ///////////////////// + // 3x3 CsI crystal // + ///////////////////// + /*double pTheta_1 = -5.6*deg; + double pPhi_1 = 46.5*deg; + G4Trap* solidCsI1 = new G4Trap(NameCsI, 0.5*CsIThickness, pTheta_1, pPhi_1, 0.5*23.73, 0.5*23.73, 0.5*23.73, 0, + 0.5*32.53, 0.5*32.53, 0.5*32.53, 0); + + cout << "Theta1= " << pTheta_1*180/3.1415 << endl; + cout << "Phi1= " << pPhi_1*180/3.1415 << endl; + + double pTheta_2 = -4.0*deg; + double pPhi_2 = 0*deg; + G4Trap* solidCsI2 = new G4Trap(NameCsI, 0.5*CsIThickness, pTheta_2, pPhi_2, 0.5*22.55, 0.5*23.73, 0.5*23.73, 0, + 0.5*28.05, 0.5*32.53, 0.5*32.53, 0); + + G4Trd* solidCsI3 = new G4Trd("SolidCluster", 0.5*22.55,0.5*28.05,0.5*22.55,0.5*28.05, 0.5*CsIThickness); + + G4RotationMatrix* rotM1 = new G4RotationMatrix; + m_LogicCsICrystal = new G4LogicalVolume(solidCsI1, m_MaterialCsI, "logicCsICrystal", 0, 0, 0); + m_LogicCsICrystal->SetSensitiveDetector(m_CsIScorer); + m_LogicCsICrystal->SetVisAttributes(m_CsIVisAtt); + double Xpos = 27; + double Ypos = 27; + Pos = G4ThreeVector(-Xpos,-Ypos,0); + rotM1->rotateZ(0*deg); + new G4PVPlacement(G4Transform3D(*rotM1,Pos),m_LogicCsICrystal,"CsI_Cristal1",m_LogicCluster,false,1,true); + + rotM1->rotateZ(-90*deg); + Pos = G4ThreeVector(-Xpos,Ypos,0); + new G4PVPlacement(G4Transform3D(*rotM1,Pos),m_LogicCsICrystal,"CsI_Cristal2",m_LogicCluster,false,3,true); + + rotM1->rotateZ(-90*deg); + Pos = G4ThreeVector(Xpos,Ypos,0); + new G4PVPlacement(G4Transform3D(*rotM1,Pos),m_LogicCsICrystal,"CsI_Cristal7",m_LogicCluster,false,7,true); + + rotM1->rotateZ(-90*deg); + Pos = G4ThreeVector(Xpos,-Ypos,0); + new G4PVPlacement(G4Transform3D(*rotM1,Pos),m_LogicCsICrystal,"CsI_Cristal9",m_LogicCluster,false,9,true); + + G4RotationMatrix* rotM3 = new G4RotationMatrix; + m_LogicCsICrystal = new G4LogicalVolume(solidCsI3, m_MaterialCsI, "logicCsICrystal", 0, 0, 0); + m_LogicCsICrystal->SetSensitiveDetector(m_CsIScorer); + m_LogicCsICrystal->SetVisAttributes(m_CsIVisAtt); + Pos = G4ThreeVector(0.,0.,0); + rotM3->rotateZ(0); + new G4PVPlacement(G4Transform3D(*rotM3,Pos),m_LogicCsICrystal,"CsI_Cristal5",m_LogicCluster,false,5,true); + + G4RotationMatrix* rotM2 = new G4RotationMatrix; + m_LogicCsICrystal = new G4LogicalVolume(solidCsI2, m_MaterialCsI, "logicCsICrystal", 0, 0, 0); + m_LogicCsICrystal->SetSensitiveDetector(m_CsIScorer); + m_LogicCsICrystal->SetVisAttributes(m_CsIVisAtt); + Pos = G4ThreeVector(-Xpos,0.,0); + rotM2->rotateZ(0*deg); + new G4PVPlacement(G4Transform3D(*rotM2,Pos),m_LogicCsICrystal,"CsI_Cristal2",m_LogicCluster,false,2,true); + + Pos = G4ThreeVector(Xpos,0.,0); + rotM2->rotateZ(180*deg); + new G4PVPlacement(G4Transform3D(*rotM2,Pos),m_LogicCsICrystal,"CsI_Cristal8",m_LogicCluster,false,8,true); + Pos = G4ThreeVector(0,-Ypos,0); + rotM2->rotateZ(-90*deg); + new G4PVPlacement(G4Transform3D(*rotM2,Pos),m_LogicCsICrystal,"CsI_Cristal4",m_LogicCluster,false,4,true); + + Pos = G4ThreeVector(0,Ypos,0); + rotM2->rotateZ(180*deg); + new G4PVPlacement(G4Transform3D(*rotM2,Pos),m_LogicCsICrystal,"CsI_Cristal6",m_LogicCluster,false,6,true);*/ + } +} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Hira::InitializeMaterial(){ - m_MaterialSilicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); - m_MaterialAluminium = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); - m_MaterialCsI = MaterialManager::getInstance()->GetMaterialFromLibrary("CsI"); - m_MaterialMylar = MaterialManager::getInstance()->GetMaterialFromLibrary("Mylar"); - m_MaterialPCB = MaterialManager::getInstance()->GetMaterialFromLibrary("PCB"); - m_MaterialVacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); +void Hira::InitializeMaterial() { + m_MaterialSilicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); + m_MaterialAluminium = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); + m_MaterialCsI = MaterialManager::getInstance()->GetMaterialFromLibrary("CsI"); + m_MaterialMylar = MaterialManager::getInstance()->GetMaterialFromLibrary("Mylar"); + m_MaterialPCB = MaterialManager::getInstance()->GetMaterialFromLibrary("PCB"); + m_MaterialVacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); } //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* Hira::Construct(){ - return (NPS::VDetector*) new Hira(); -} +NPS::VDetector* Hira::Construct() { return (NPS::VDetector*)new Hira(); } //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_hira{ - public: - proxy_nps_hira(){ - NPS::DetectorFactory::getInstance()->AddToken("HiraTelescope","Hira"); - NPS::DetectorFactory::getInstance()->AddDetector("HiraTelescope",Hira::Construct); - } - }; - - proxy_nps_hira p_nps_hira; +extern "C" { +class proxy_nps_hira { + public: + proxy_nps_hira() { + NPS::DetectorFactory::getInstance()->AddToken("HiraTelescope", "Hira"); + NPS::DetectorFactory::getInstance()->AddDetector("HiraTelescope", Hira::Construct); + } +}; + +proxy_nps_hira p_nps_hira; } diff --git a/NPSimulation/Detectors/Hyde2/Hyde2TrackerSquare1.cc b/NPSimulation/Detectors/Hyde2/Hyde2TrackerSquare1.cc index e1b5daddc..cb4f1f111 100644 --- a/NPSimulation/Detectors/Hyde2/Hyde2TrackerSquare1.cc +++ b/NPSimulation/Detectors/Hyde2/Hyde2TrackerSquare1.cc @@ -25,36 +25,36 @@ *****************************************************************************/ // C++ headers +#include <cmath> #include <sstream> #include <string> -#include <cmath> // G4 Geometry headers -#include "G4Trd.hh" #include "G4Box.hh" #include "G4Trap.hh" +#include "G4Trd.hh" // G4 various headers -#include "G4MaterialTable.hh" +#include "G4Colour.hh" #include "G4Element.hh" #include "G4ElementTable.hh" -#include "G4VisAttributes.hh" -#include "G4Colour.hh" +#include "G4MaterialTable.hh" +#include "G4PVDivision.hh" +#include "G4PVPlacement.hh" #include "G4RotationMatrix.hh" #include "G4Transform3D.hh" -#include "G4PVPlacement.hh" -#include "G4PVDivision.hh" +#include "G4VisAttributes.hh" // G4 sensitive -#include "G4SDManager.hh" #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" // NPTool headers +#include "Hyde2Scorers.hh" #include "Hyde2TrackerSquare1.hh" +#include "NPSVDetector.hh" #include "ObsoleteGeneralScorers.hh" -#include "Hyde2Scorers.hh" #include "RootOutput.h" -#include "NPSVDetector.hh" // CLHEP #include "CLHEP/Random/RandGauss.h" @@ -62,137 +62,97 @@ using namespace std; using namespace CLHEP; using namespace HYD2SQUARE1; - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Hyde2TrackerSquare1::Hyde2TrackerSquare1() -{ - ms_InterCoord = 0; -} - - +Hyde2TrackerSquare1::Hyde2TrackerSquare1() { ms_InterCoord = 0; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Hyde2TrackerSquare1::~Hyde2TrackerSquare1() -{ -} - - +Hyde2TrackerSquare1::~Hyde2TrackerSquare1() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Hyde2TrackerSquare1::AddModule(G4ThreeVector X1_Y1 , - G4ThreeVector X128_Y1 , - G4ThreeVector X1_Y128 , - G4ThreeVector X128_Y128 , - bool wFirstStage , - bool wSecondStage , - bool wThirdStage , - bool wFourthStage , - bool wFifthStage , - bool wSixthStage) -{ - m_DefinitionType.push_back(true) ; - - m_X1_Y1.push_back(X1_Y1) ; - m_X128_Y1.push_back(X128_Y1) ; - m_X1_Y128.push_back(X1_Y128) ; - m_X128_Y128.push_back(X128_Y128) ; - m_wFirstStage.push_back(wFirstStage) ; - m_wSecondStage.push_back(wSecondStage) ; - m_wThirdStage.push_back(wThirdStage) ; - m_wFourthStage.push_back(wFourthStage) ; - m_wFifthStage.push_back(wFifthStage) ; - m_wSixthStage.push_back(wSixthStage) ; - - m_R.push_back(0) ; - m_Theta.push_back(0) ; - m_Phi.push_back(0) ; - m_beta_u.push_back(0) ; - m_beta_v.push_back(0) ; - m_beta_w.push_back(0) ; +void Hyde2TrackerSquare1::AddModule(G4ThreeVector X1_Y1, G4ThreeVector X128_Y1, G4ThreeVector X1_Y128, + G4ThreeVector X128_Y128, bool wFirstStage, bool wSecondStage, bool wThirdStage, + bool wFourthStage, bool wFifthStage, bool wSixthStage) { + m_DefinitionType.push_back(true); + + m_X1_Y1.push_back(X1_Y1); + m_X128_Y1.push_back(X128_Y1); + m_X1_Y128.push_back(X1_Y128); + m_X128_Y128.push_back(X128_Y128); + m_wFirstStage.push_back(wFirstStage); + m_wSecondStage.push_back(wSecondStage); + m_wThirdStage.push_back(wThirdStage); + m_wFourthStage.push_back(wFourthStage); + m_wFifthStage.push_back(wFifthStage); + m_wSixthStage.push_back(wSixthStage); + + m_R.push_back(0); + m_Theta.push_back(0); + m_Phi.push_back(0); + m_beta_u.push_back(0); + m_beta_v.push_back(0); + m_beta_w.push_back(0); } - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Hyde2TrackerSquare1::AddModule(G4double R , - G4double Theta , - G4double Phi , - G4double beta_u , - G4double beta_v , - G4double beta_w , - bool wFirstStage , - bool wSecondStage , - bool wThirdStage , - bool wFourthStage , - bool wFifthStage , - bool wSixthStage) -{ - G4ThreeVector empty = G4ThreeVector(0, 0, 0); - - m_DefinitionType.push_back(false); - - m_R.push_back(R) ; - m_Theta.push_back(Theta) ; - m_Phi.push_back(Phi) ; - m_beta_u.push_back(beta_u) ; - m_beta_v.push_back(beta_v) ; - m_beta_w.push_back(beta_w) ; - m_wFirstStage.push_back(wFirstStage) ; - m_wSecondStage.push_back(wSecondStage) ; - m_wThirdStage.push_back(wThirdStage) ; - m_wFourthStage.push_back(wFourthStage) ; - m_wFifthStage.push_back(wFifthStage) ; - m_wSixthStage.push_back(wSixthStage) ; - - m_X1_Y1.push_back(empty) ; - m_X128_Y1.push_back(empty) ; - m_X1_Y128.push_back(empty) ; - m_X128_Y128.push_back(empty) ; +void Hyde2TrackerSquare1::AddModule(G4double R, G4double Theta, G4double Phi, G4double beta_u, G4double beta_v, + G4double beta_w, bool wFirstStage, bool wSecondStage, bool wThirdStage, + bool wFourthStage, bool wFifthStage, bool wSixthStage) { + G4ThreeVector empty = G4ThreeVector(0, 0, 0); + + m_DefinitionType.push_back(false); + + m_R.push_back(R); + m_Theta.push_back(Theta); + m_Phi.push_back(Phi); + m_beta_u.push_back(beta_u); + m_beta_v.push_back(beta_v); + m_beta_w.push_back(beta_w); + m_wFirstStage.push_back(wFirstStage); + m_wSecondStage.push_back(wSecondStage); + m_wThirdStage.push_back(wThirdStage); + m_wFourthStage.push_back(wFourthStage); + m_wFifthStage.push_back(wFifthStage); + m_wSixthStage.push_back(wSixthStage); + + m_X1_Y1.push_back(empty); + m_X128_Y1.push_back(empty); + m_X1_Y128.push_back(empty); + m_X128_Y128.push_back(empty); } - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Hyde2TrackerSquare1::VolumeMaker(G4int TelescopeNumber, - G4ThreeVector MMpos, - G4RotationMatrix* MMrot, - bool wFirstStage, - bool wSecondStage, - bool wThirdStage, - bool wFourthStage, - bool wFifthStage , - bool wSixthStage , - G4LogicalVolume* world) -{ - G4double NbrTelescopes = TelescopeNumber ; - G4String DetectorNumber ; - ostringstream Number ; - Number << NbrTelescopes ; - DetectorNumber = Number.str() ; - - //////////////////////////////////////////////////////////////// - ////////////// Starting Volume Definition ////////////////////// - //////////////////////////////////////////////////////////////// - G4String Name = "HYD2Square1" + DetectorNumber; - - G4Box* solidHYD2Square1 = new G4Box(Name, 0.5*FaceFront, 0.5*FaceFront, 0.5*Length); - G4LogicalVolume* logicHYD2Square1 = new G4LogicalVolume(solidHYD2Square1, m_MaterialVacuum, Name, 0, 0, 0); - - new G4PVPlacement(G4Transform3D(*MMrot, MMpos), logicHYD2Square1, Name, world, false, 0); - - logicHYD2Square1->SetVisAttributes(G4VisAttributes::Invisible); - if (m_non_sensitive_part_visiualisation) logicHYD2Square1->SetVisAttributes(G4VisAttributes(G4Colour(0.90, 0.90, 0.90))); - - //Place two marker to identify the u and v axis on silicon face: - //marker are placed a bit before the silicon itself so they don't perturbate simulation - //Uncomment to help debugging or if you want to understand the way the code work. - //I should recommand to Comment it during simulation to avoid perturbation of simulation - //Remember G4 is limitationg step on geometry constraints. - /* +void Hyde2TrackerSquare1::VolumeMaker(G4int TelescopeNumber, G4ThreeVector MMpos, G4RotationMatrix* MMrot, + bool wFirstStage, bool wSecondStage, bool wThirdStage, bool wFourthStage, + bool wFifthStage, bool wSixthStage, G4LogicalVolume* world) { + G4double NbrTelescopes = TelescopeNumber; + G4String DetectorNumber; + ostringstream Number; + Number << NbrTelescopes; + DetectorNumber = Number.str(); + + //////////////////////////////////////////////////////////////// + ////////////// Starting Volume Definition ////////////////////// + //////////////////////////////////////////////////////////////// + G4String Name = "HYD2Square1" + DetectorNumber; + + G4Box* solidHYD2Square1 = new G4Box(Name, 0.5 * FaceFront, 0.5 * FaceFront, 0.5 * Length); + G4LogicalVolume* logicHYD2Square1 = new G4LogicalVolume(solidHYD2Square1, m_MaterialVacuum, Name, 0, 0, 0); + + new G4PVPlacement(G4Transform3D(*MMrot, MMpos), logicHYD2Square1, Name, world, false, 0); + + logicHYD2Square1->SetVisAttributes(G4VisAttributes::GetInvisible()); + if (m_non_sensitive_part_visiualisation) + logicHYD2Square1->SetVisAttributes(G4VisAttributes(G4Colour(0.90, 0.90, 0.90))); + + // Place two marker to identify the u and v axis on silicon face: + // marker are placed a bit before the silicon itself so they don't perturbate simulation + // Uncomment to help debugging or if you want to understand the way the code work. + // I should recommand to Comment it during simulation to avoid perturbation of simulation + // Remember G4 is limitationg step on geometry constraints. + /* G4ThreeVector positionMarkerU = CT*0.98 + MMu*SiliconFace/4; G4Box* solidMarkerU = new G4Box( "solidMarkerU" , SiliconFace/4 , 1*mm , 1*mm ) ; - G4LogicalVolume* logicMarkerU = new G4LogicalVolume( solidMarkerU , m_MaterialVacuum , "logicMarkerU",0,0,0) ; + G4LogicalVolume* logicMarkerU = new G4LogicalVolume( solidMarkerU , m_MaterialVacuum , "logicMarkerU",0,0,0) ; PVPBuffer = new G4PVPlacement(G4Transform3D(*MMrot,positionMarkerU),logicMarkerU,"MarkerU",world,false,0) ; G4VisAttributes* MarkerUVisAtt= new G4VisAttributes(G4Colour(0.,0.,0.5));//blue @@ -200,169 +160,144 @@ void Hyde2TrackerSquare1::VolumeMaker(G4int TelescopeNumber, G4ThreeVector positionMarkerV = CT*0.98 + MMv*SiliconFace/4; G4Box* solidMarkerV = new G4Box( "solidMarkerU" , 1*mm , SiliconFace/4 , 1*mm ) ; - G4LogicalVolume* logicMarkerV = new G4LogicalVolume( solidMarkerV , m_MaterialVacuum , "logicMarkerV",0,0,0) ; + G4LogicalVolume* logicMarkerV = new G4LogicalVolume( solidMarkerV , m_MaterialVacuum , "logicMarkerV",0,0,0) ; PVPBuffer = new G4PVPlacement(G4Transform3D(*MMrot,positionMarkerV),logicMarkerV,"MarkerV",world,false,0) ; G4VisAttributes* MarkerVVisAtt= new G4VisAttributes(G4Colour(0.,0.5,0.5));//green logicMarkerV->SetVisAttributes(MarkerVVisAtt); */ - //////////////////////////////////////////////////////////////// - //////////////// First Stage Construction ////////////////////// - //////////////////////////////////////////////////////////////// - if (wFirstStage) { - // Silicon detector itself - G4ThreeVector positionFirstStage = G4ThreeVector(0, 0, FirstStage_PosZ); - - G4Box* solidFirstStage = new G4Box("solidFirstStage", 0.5*FirstStageFace, 0.5*FirstStageFace, 0.5*FirstStageThickness); - G4LogicalVolume* logicFirstStage = new G4LogicalVolume(solidFirstStage, m_MaterialSilicon, "logicFirstStage", 0, 0, 0); - - new G4PVPlacement(0, - positionFirstStage, - logicFirstStage, - Name + "_FirstStage", - logicHYD2Square1, - false, - 0); - - // Set First Stage sensible - logicFirstStage->SetSensitiveDetector(m_FirstStageScorer); - - ///Visualisation of FirstStage Strip - G4VisAttributes* FirstStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)); // blue - logicFirstStage->SetVisAttributes(FirstStageVisAtt); - } - - //////////////////////////////////////////////////////////////// - //////////////////// Second Stage Construction //////////////// - //////////////////////////////////////////////////////////////// - if (wSecondStage) { - // Second stage silicon detector - G4ThreeVector positionSecondStage = G4ThreeVector(0, 0, SecondStage_PosZ); - - G4Box* solidSecondStage = new G4Box("solidSecondStage", 0.5*SecondStageFace, 0.5*SecondStageFace, 0.5*SecondStageThickness); - G4LogicalVolume* logicSecondStage = new G4LogicalVolume(solidSecondStage, m_MaterialSilicon, "logicSecondStage", 0, 0, 0); - - new G4PVPlacement(0, - positionSecondStage, - logicSecondStage, - Name + "_SecondStage", - logicHYD2Square1, - false, - 0); - - // Set Second Stage sensible - logicSecondStage->SetSensitiveDetector(m_SecondStageScorer); - - ///Visualisation of SecondStage Strip - G4VisAttributes* SecondStageVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)) ; - logicSecondStage->SetVisAttributes(SecondStageVisAtt) ; - } - - //////////////////////////////////////////////////////////////// - ///////////////// Third Stage Construction ///////////////////// - //////////////////////////////////////////////////////////////// - if (wThirdStage) { - // Third stage silicon detector - G4ThreeVector positionThirdStage = G4ThreeVector(0, 0, ThirdStage_PosZ); - - G4Box* solidThirdStage = new G4Box("solidThirdStage", 0.5*ThirdStageFace, 0.5*ThirdStageFace, 0.5*ThirdStageThickness); - G4LogicalVolume* logicThirdStage = new G4LogicalVolume(solidThirdStage, m_MaterialSilicon, "logicThirdStage", 0, 0, 0); - - new G4PVPlacement(0, - positionThirdStage, - logicThirdStage, - Name + "_ThirdStage", - logicHYD2Square1, - false, - 0); - - // Set Third Stage sensible - logicThirdStage->SetSensitiveDetector(m_ThirdStageScorer); - - ///Visualisation of Third Stage - G4VisAttributes* ThirdStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // green - logicThirdStage->SetVisAttributes(ThirdStageVisAtt); - } - - //////////////////////////////////////////////////////////////// - ///////////////// Fourth Stage Construction///////////////////// - //////////////////////////////////////////////////////////////// - if (wFourthStage) { - // Fourth stage silicon detector - G4ThreeVector positionFourthStage = G4ThreeVector(0, 0, FourthStage_PosZ); - - G4Box* solidFourthStage = new G4Box("solidFourthStage", 0.5*FourthStageFace, 0.5*FourthStageFace, 0.5*FourthStageThickness); - G4LogicalVolume* logicFourthStage = new G4LogicalVolume(solidFourthStage, m_MaterialSilicon, "logicFourthStage", 0, 0, 0); - - new G4PVPlacement(0, - positionFourthStage, - logicFourthStage, - Name + "_FourthStage", - logicHYD2Square1, - false, - 0); - - // Set Fourth Stage sensible - logicFourthStage->SetSensitiveDetector(m_FourthStageScorer); - - ///Visualisation of Fourth Stage - G4VisAttributes* FourthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // green - logicFourthStage->SetVisAttributes(FourthStageVisAtt); - } - - //////////////////////////////////////////////////////////////// - ///////////////// Fifth Stage Construction///////////////////// - //////////////////////////////////////////////////////////////// - if (wFifthStage) { - // Fifth stage silicon detector - G4ThreeVector positionFifthStage = G4ThreeVector(0, 0, FifthStage_PosZ); - - G4Box* solidFifthStage = new G4Box("solidFifthStage", 0.5*FifthStageFace, 0.5*FifthStageFace, 0.5*FifthStageThickness); - G4LogicalVolume* logicFifthStage = new G4LogicalVolume(solidFifthStage, m_MaterialSilicon, "logicFifthStage", 0, 0, 0); - - new G4PVPlacement(0, - positionFifthStage, - logicFifthStage, - Name + "_FifthStage", - logicHYD2Square1, - false, - 0); - - // Set Fifth Stage sensible - logicFifthStage->SetSensitiveDetector(m_FifthStageScorer); - - ///Visualisation of Fifth Stage - G4VisAttributes* FifthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // green - logicFifthStage->SetVisAttributes(FifthStageVisAtt); - } - - //////////////////////////////////////////////////////////////// - ///////////////// Sixth Stage Construction///////////////////// - //////////////////////////////////////////////////////////////// - if (wSixthStage) { - // Sixth stage silicon detector - G4ThreeVector positionSixthStage = G4ThreeVector(0, 0, SixthStage_PosZ); - - G4Box* solidSixthStage = new G4Box("solidSixthStage", 0.5*SixthStageFace, 0.5*SixthStageFace, 0.5*SixthStageThickness); - G4LogicalVolume* logicSixthStage = new G4LogicalVolume(solidSixthStage, m_MaterialSilicon, "logicSixthStage", 0, 0, 0); - - new G4PVPlacement(0, - positionSixthStage, - logicSixthStage, - Name + "_SixthStage", - logicHYD2Square1, - false, - 0); - - // Set Sixth Stage sensible - logicSixthStage->SetSensitiveDetector(m_SixthStageScorer); - - ///Visualisation of Sixth Stage - G4VisAttributes* SixthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // green - logicSixthStage->SetVisAttributes(SixthStageVisAtt); - } - + //////////////////////////////////////////////////////////////// + //////////////// First Stage Construction ////////////////////// + //////////////////////////////////////////////////////////////// + if (wFirstStage) { + // Silicon detector itself + G4ThreeVector positionFirstStage = G4ThreeVector(0, 0, FirstStage_PosZ); + + G4Box* solidFirstStage = + new G4Box("solidFirstStage", 0.5 * FirstStageFace, 0.5 * FirstStageFace, 0.5 * FirstStageThickness); + G4LogicalVolume* logicFirstStage = + new G4LogicalVolume(solidFirstStage, m_MaterialSilicon, "logicFirstStage", 0, 0, 0); + + new G4PVPlacement(0, positionFirstStage, logicFirstStage, Name + "_FirstStage", logicHYD2Square1, false, 0); + + // Set First Stage sensible + logicFirstStage->SetSensitiveDetector(m_FirstStageScorer); + + /// Visualisation of FirstStage Strip + G4VisAttributes* FirstStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)); // blue + logicFirstStage->SetVisAttributes(FirstStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + //////////////////// Second Stage Construction //////////////// + //////////////////////////////////////////////////////////////// + if (wSecondStage) { + // Second stage silicon detector + G4ThreeVector positionSecondStage = G4ThreeVector(0, 0, SecondStage_PosZ); + + G4Box* solidSecondStage = + new G4Box("solidSecondStage", 0.5 * SecondStageFace, 0.5 * SecondStageFace, 0.5 * SecondStageThickness); + G4LogicalVolume* logicSecondStage = + new G4LogicalVolume(solidSecondStage, m_MaterialSilicon, "logicSecondStage", 0, 0, 0); + + new G4PVPlacement(0, positionSecondStage, logicSecondStage, Name + "_SecondStage", logicHYD2Square1, false, 0); + + // Set Second Stage sensible + logicSecondStage->SetSensitiveDetector(m_SecondStageScorer); + + /// Visualisation of SecondStage Strip + G4VisAttributes* SecondStageVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)); + logicSecondStage->SetVisAttributes(SecondStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Third Stage Construction ///////////////////// + //////////////////////////////////////////////////////////////// + if (wThirdStage) { + // Third stage silicon detector + G4ThreeVector positionThirdStage = G4ThreeVector(0, 0, ThirdStage_PosZ); + + G4Box* solidThirdStage = + new G4Box("solidThirdStage", 0.5 * ThirdStageFace, 0.5 * ThirdStageFace, 0.5 * ThirdStageThickness); + G4LogicalVolume* logicThirdStage = + new G4LogicalVolume(solidThirdStage, m_MaterialSilicon, "logicThirdStage", 0, 0, 0); + + new G4PVPlacement(0, positionThirdStage, logicThirdStage, Name + "_ThirdStage", logicHYD2Square1, false, 0); + + // Set Third Stage sensible + logicThirdStage->SetSensitiveDetector(m_ThirdStageScorer); + + /// Visualisation of Third Stage + G4VisAttributes* ThirdStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // green + logicThirdStage->SetVisAttributes(ThirdStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Fourth Stage Construction///////////////////// + //////////////////////////////////////////////////////////////// + if (wFourthStage) { + // Fourth stage silicon detector + G4ThreeVector positionFourthStage = G4ThreeVector(0, 0, FourthStage_PosZ); + + G4Box* solidFourthStage = + new G4Box("solidFourthStage", 0.5 * FourthStageFace, 0.5 * FourthStageFace, 0.5 * FourthStageThickness); + G4LogicalVolume* logicFourthStage = + new G4LogicalVolume(solidFourthStage, m_MaterialSilicon, "logicFourthStage", 0, 0, 0); + + new G4PVPlacement(0, positionFourthStage, logicFourthStage, Name + "_FourthStage", logicHYD2Square1, false, 0); + + // Set Fourth Stage sensible + logicFourthStage->SetSensitiveDetector(m_FourthStageScorer); + + /// Visualisation of Fourth Stage + G4VisAttributes* FourthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // green + logicFourthStage->SetVisAttributes(FourthStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Fifth Stage Construction///////////////////// + //////////////////////////////////////////////////////////////// + if (wFifthStage) { + // Fifth stage silicon detector + G4ThreeVector positionFifthStage = G4ThreeVector(0, 0, FifthStage_PosZ); + + G4Box* solidFifthStage = + new G4Box("solidFifthStage", 0.5 * FifthStageFace, 0.5 * FifthStageFace, 0.5 * FifthStageThickness); + G4LogicalVolume* logicFifthStage = + new G4LogicalVolume(solidFifthStage, m_MaterialSilicon, "logicFifthStage", 0, 0, 0); + + new G4PVPlacement(0, positionFifthStage, logicFifthStage, Name + "_FifthStage", logicHYD2Square1, false, 0); + + // Set Fifth Stage sensible + logicFifthStage->SetSensitiveDetector(m_FifthStageScorer); + + /// Visualisation of Fifth Stage + G4VisAttributes* FifthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // green + logicFifthStage->SetVisAttributes(FifthStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Sixth Stage Construction///////////////////// + //////////////////////////////////////////////////////////////// + if (wSixthStage) { + // Sixth stage silicon detector + G4ThreeVector positionSixthStage = G4ThreeVector(0, 0, SixthStage_PosZ); + + G4Box* solidSixthStage = + new G4Box("solidSixthStage", 0.5 * SixthStageFace, 0.5 * SixthStageFace, 0.5 * SixthStageThickness); + G4LogicalVolume* logicSixthStage = + new G4LogicalVolume(solidSixthStage, m_MaterialSilicon, "logicSixthStage", 0, 0, 0); + + new G4PVPlacement(0, positionSixthStage, logicSixthStage, Name + "_SixthStage", logicHYD2Square1, false, 0); + + // Set Sixth Stage sensible + logicSixthStage->SetSensitiveDetector(m_SixthStageScorer); + + /// Visualisation of Sixth Stage + G4VisAttributes* SixthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // green + logicSixthStage->SetVisAttributes(SixthStageVisAtt); + } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -372,819 +307,803 @@ void Hyde2TrackerSquare1::VolumeMaker(G4int TelescopeNumber, // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Hyde2TrackerSquare1::ReadConfiguration(string Path) -{ - ifstream ConfigFile ; - ConfigFile.open(Path.c_str()) ; - string LineBuffer ; - string DataBuffer ; - - // A:X1_Y1 --> X:1 Y:1 - // B:X128_Y1 --> X:128 Y:1 - // C:X1_Y128 --> X:1 Y:128 - // D:X128_Y128 --> X:128 Y:128 - - G4double Ax , Bx , Cx , Dx , Ay , By , Cy , Dy , Az , Bz , Cz , Dz ; - G4ThreeVector A , B , C , D ; - G4double Theta = 0 , Phi = 0 , R = 0 , beta_u = 0 , beta_v = 0 , beta_w = 0 ; - int FIRSTSTAGE = 0 , SECONDSTAGE = 0 , THIRDSTAGE = 0 , FOURTHSTAGE = 0 , FIFTHSTAGE = 0, SIXTHSTAGE = 0 ; - - bool ReadingStatus = false ; - - bool check_A = false ; - bool check_C = false ; - bool check_B = false ; - bool check_D = false ; - - bool check_Theta = false ; - bool check_Phi = false ; - bool check_R = false ; -// bool check_beta = false ; - - bool check_FirstStage = false ; - bool check_SecondStage = false ; - bool check_ThirdStage = false ; - bool check_FourthStage = false ; - bool check_FifthStage = false ; - bool check_SixthStage = false ; - bool checkVis = false ; - - while (!ConfigFile.eof()) { - getline(ConfigFile, LineBuffer); - if (LineBuffer.compare(0, 11, "HYD2Square1") == 0) { - G4cout << "///" << G4endl ; - G4cout << "Square1 element found: " << G4endl ; - ReadingStatus = true ; - } - - while(ReadingStatus){ - - ConfigFile >> DataBuffer; - // Comment Line - if (DataBuffer.compare(0, 1, "%") == 0) {/*do nothing */;} - - // Position method - else if (DataBuffer.compare(0, 6, "X1_Y1=") == 0) { - check_A = true; - ConfigFile >> DataBuffer ; - Ax = atof(DataBuffer.c_str()) ; - Ax = Ax * mm ; - ConfigFile >> DataBuffer ; - Ay = atof(DataBuffer.c_str()) ; - Ay = Ay * mm ; - ConfigFile >> DataBuffer ; - Az = atof(DataBuffer.c_str()) ; - Az = Az * mm ; - - A = G4ThreeVector(Ax, Ay, Az); - G4cout << "X1 Y1 corner position : " << A << G4endl; - } - - else if (DataBuffer.compare(0, 8, "X128_Y1=") == 0) { - check_B = true; - ConfigFile >> DataBuffer ; - Bx = atof(DataBuffer.c_str()) ; - Bx = Bx * mm ; - ConfigFile >> DataBuffer ; - By = atof(DataBuffer.c_str()) ; - By = By * mm ; - ConfigFile >> DataBuffer ; - Bz = atof(DataBuffer.c_str()) ; - Bz = Bz * mm ; - - B = G4ThreeVector(Bx, By, Bz); - G4cout << "X128 Y1 corner position : " << B << G4endl; - } - - else if (DataBuffer.compare(0, 8, "X1_Y128=") == 0) { - check_C = true; - ConfigFile >> DataBuffer ; - Cx = atof(DataBuffer.c_str()) ; - Cx = Cx * mm ; - ConfigFile >> DataBuffer ; - Cy = atof(DataBuffer.c_str()) ; - Cy = Cy * mm ; - ConfigFile >> DataBuffer ; - Cz = atof(DataBuffer.c_str()) ; - Cz = Cz * mm ; - - C = G4ThreeVector(Cx, Cy, Cz); - G4cout << "X1 Y128 corner position : " << C << G4endl; - } - - else if (DataBuffer.compare(0, 10, "X128_Y128=") == 0) { - check_D = true; - ConfigFile >> DataBuffer ; - Dx = atof(DataBuffer.c_str()) ; - Dx = Dx * mm ; - ConfigFile >> DataBuffer ; - Dy = atof(DataBuffer.c_str()) ; - Dy = Dy * mm ; - ConfigFile >> DataBuffer ; - Dz = atof(DataBuffer.c_str()) ; - Dz = Dz * mm ; - - D = G4ThreeVector(Dx, Dy, Dz); - G4cout << "X128 Y128 corner position : " << D << G4endl; - } - - - // Angle method - else if (DataBuffer.compare(0, 6, "THETA=") == 0) { - check_Theta = true; - ConfigFile >> DataBuffer ; - Theta = atof(DataBuffer.c_str()) ; - Theta = Theta * deg; - G4cout << "Theta: " << Theta / deg << G4endl; - } - - else if (DataBuffer.compare(0, 4, "PHI=") == 0) { - check_Phi = true; - ConfigFile >> DataBuffer ; - Phi = atof(DataBuffer.c_str()) ; - Phi = Phi * deg; - G4cout << "Phi: " << Phi / deg << G4endl; - } - - else if (DataBuffer.compare(0, 2, "R=") == 0) { - check_R = true; - ConfigFile >> DataBuffer ; - R = atof(DataBuffer.c_str()) ; - R = R * mm; - G4cout << "R: " << R / mm << G4endl; - } - - else if (DataBuffer.compare(0, 5, "BETA=") == 0) { -// check_beta = true; - ConfigFile >> DataBuffer ; - beta_u = atof(DataBuffer.c_str()) ; - beta_u = beta_u * deg ; - ConfigFile >> DataBuffer ; - beta_v = atof(DataBuffer.c_str()) ; - beta_v = beta_v * deg ; - ConfigFile >> DataBuffer ; - beta_w = atof(DataBuffer.c_str()) ; - beta_w = beta_w * deg ; - G4cout << "Beta: " << beta_u / deg << " " << beta_v / deg << " " << beta_w / deg << G4endl ; - } - - else if (DataBuffer.compare(0, 11, "FIRSTSTAGE=") == 0) { - check_FirstStage = true ; - ConfigFile >> DataBuffer; - FIRSTSTAGE = atof(DataBuffer.c_str()) ; - } - - else if (DataBuffer.compare(0, 12, "SECONDSTAGE=") == 0) { - check_SecondStage = true ; - ConfigFile >> DataBuffer; - SECONDSTAGE = atof(DataBuffer.c_str()) ; - } - - else if (DataBuffer.compare(0, 11, "THIRDSTAGE=") == 0) { - check_ThirdStage = true ; - ConfigFile >> DataBuffer; - THIRDSTAGE = atof(DataBuffer.c_str()) ; - } - - else if (DataBuffer.compare(0, 12, "FOURTHSTAGE=") == 0) { - check_FourthStage = true ; - ConfigFile >> DataBuffer; - FOURTHSTAGE = atof(DataBuffer.c_str()) ; - } - - else if (DataBuffer.compare(0, 11, "FIFTHSTAGE=") == 0) { - check_FifthStage = true ; - ConfigFile >> DataBuffer; - FIFTHSTAGE = atof(DataBuffer.c_str()) ; - } - - else if (DataBuffer.compare(0, 11, "SIXTHSTAGE=") == 0) { - check_SixthStage = true ; - ConfigFile >> DataBuffer; - SIXTHSTAGE = atof(DataBuffer.c_str()) ; - } - - else if (DataBuffer.compare(0, 4, "VIS=") == 0) { - checkVis = true ; - ConfigFile >> DataBuffer; - if (DataBuffer.compare(0, 3, "all") == 0) m_non_sensitive_part_visiualisation = true; - } - - else G4cout << "WARNING: Wrong Token, Hyde2TrackerSquare1: Square1 Element not added" << G4endl; - - //Add The previously define telescope - //With position method - if ((check_A && check_B && check_C && check_D && check_FirstStage && check_SecondStage && check_ThirdStage && check_FourthStage && check_FifthStage && check_SixthStage && checkVis) && !(check_Theta && check_Phi && check_R)) { - - ReadingStatus = false ; - check_A = false ; - check_C = false ; - check_B = false ; - check_D = false ; - check_FirstStage = false ; - check_SecondStage = false ; - check_ThirdStage = false ; - check_FourthStage = false ; - check_FifthStage = false ; - check_SixthStage = false ; - checkVis = false ; - - AddModule(A , - B , - C , - D , - FIRSTSTAGE == 1 , - SECONDSTAGE == 1 , - THIRDSTAGE == 1 , - FOURTHSTAGE == 1 , - FIFTHSTAGE == 1 , - SIXTHSTAGE == 1); - } - - //with angle method - if ((check_Theta && check_Phi && check_R && check_FirstStage && check_SecondStage && check_ThirdStage && check_FourthStage && check_FifthStage && check_SixthStage && checkVis) && !(check_A && check_B && check_C && check_D)) { - ReadingStatus = false ; - check_Theta = false ; - check_Phi = false ; - check_R = false ; -// check_beta = false ; - check_FirstStage = false ; - check_SecondStage = false ; - check_ThirdStage = false ; - check_FourthStage = false ; - check_FifthStage = false ; - check_SixthStage = false ; - checkVis = false ; - - AddModule(R , - Theta , - Phi , - beta_u , - beta_v , - beta_w , - FIRSTSTAGE == 1 , - SECONDSTAGE == 1 , - THIRDSTAGE == 1 , - FOURTHSTAGE == 1 , - FIFTHSTAGE == 1 , - SIXTHSTAGE == 1); - } - - +void Hyde2TrackerSquare1::ReadConfiguration(string Path) { + ifstream ConfigFile; + ConfigFile.open(Path.c_str()); + string LineBuffer; + string DataBuffer; + + // A:X1_Y1 --> X:1 Y:1 + // B:X128_Y1 --> X:128 Y:1 + // C:X1_Y128 --> X:1 Y:128 + // D:X128_Y128 --> X:128 Y:128 + + G4double Ax, Bx, Cx, Dx, Ay, By, Cy, Dy, Az, Bz, Cz, Dz; + G4ThreeVector A, B, C, D; + G4double Theta = 0, Phi = 0, R = 0, beta_u = 0, beta_v = 0, beta_w = 0; + int FIRSTSTAGE = 0, SECONDSTAGE = 0, THIRDSTAGE = 0, FOURTHSTAGE = 0, FIFTHSTAGE = 0, SIXTHSTAGE = 0; + + bool ReadingStatus = false; + + bool check_A = false; + bool check_C = false; + bool check_B = false; + bool check_D = false; + + bool check_Theta = false; + bool check_Phi = false; + bool check_R = false; + // bool check_beta = false ; + + bool check_FirstStage = false; + bool check_SecondStage = false; + bool check_ThirdStage = false; + bool check_FourthStage = false; + bool check_FifthStage = false; + bool check_SixthStage = false; + bool checkVis = false; + + while (!ConfigFile.eof()) { + getline(ConfigFile, LineBuffer); + if (LineBuffer.compare(0, 11, "HYD2Square1") == 0) { + G4cout << "///" << G4endl; + G4cout << "Square1 element found: " << G4endl; + ReadingStatus = true; + } + + while (ReadingStatus) { + + ConfigFile >> DataBuffer; + // Comment Line + if (DataBuffer.compare(0, 1, "%") == 0) { /*do nothing */ + ; } - } -} -// Construct detector and inialise sensitive part. -// Called After DetecorConstruction::AddDetector Method -void Hyde2TrackerSquare1::ConstructDetector(G4LogicalVolume* world) -{ - G4RotationMatrix* MMrot = NULL ; - G4ThreeVector MMpos = G4ThreeVector(0, 0, 0) ; - G4ThreeVector MMu = G4ThreeVector(0, 0, 0) ; - G4ThreeVector MMv = G4ThreeVector(0, 0, 0) ; - G4ThreeVector MMw = G4ThreeVector(0, 0, 0) ; - G4ThreeVector MMCenter = G4ThreeVector(0, 0, 0) ; - bool FirstStage = true; - bool SecondStage = true; - bool ThirdStage = true; - bool FourthStage = true; - bool FifthStage = true; - bool SixthStage = true; - - G4int NumberOfTelescope = m_DefinitionType.size() ; - - for (G4int i = 0; i < NumberOfTelescope; i++) { - // By Point - if (m_DefinitionType[i]) { - // (u,v,w) unitary vector associated to telescope referencial - // (u,v) // to silicon plan - // w perpendicular to (u,v) plan and pointing ThirdStage - MMu = m_X128_Y1[i] - m_X1_Y1[i]; - MMu = MMu.unit(); - - MMv = m_X1_Y128[i] - m_X1_Y1[i]; - MMv = MMv.unit(); - - MMw = MMu.cross(MMv); - MMw = MMw.unit(); - - MMCenter = (m_X1_Y1[i] + m_X1_Y128[i] + m_X128_Y1[i] + m_X128_Y128[i]) / 4; - - // Passage Matrix from Lab Referential to Telescope Referential - MMrot = new G4RotationMatrix(MMu, MMv, MMw); - // translation to place Telescope - MMpos = MMw * Length * 0.5 + MMCenter; + // Position method + else if (DataBuffer.compare(0, 6, "X1_Y1=") == 0) { + check_A = true; + ConfigFile >> DataBuffer; + Ax = atof(DataBuffer.c_str()); + Ax = Ax * mm; + ConfigFile >> DataBuffer; + Ay = atof(DataBuffer.c_str()); + Ay = Ay * mm; + ConfigFile >> DataBuffer; + Az = atof(DataBuffer.c_str()); + Az = Az * mm; + + A = G4ThreeVector(Ax, Ay, Az); + G4cout << "X1 Y1 corner position : " << A << G4endl; } - // By Angle - else { - G4double Theta = m_Theta[i] ; - G4double Phi = m_Phi[i] ; - - // (u,v,w) unitary vector associated to telescope referencial - // (u,v) // to silicon plan - // w perpendicular to (u,v) plan and pointing ThirdStage - // Phi is angle between X axis and projection in (X,Y) plan - // Theta is angle between position vector and z axis - G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad); - G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad); - G4double wZ = m_R[i] * cos(Theta / rad); - MMw = G4ThreeVector(wX, wY, wZ); - - // vector corresponding to the center of the module - MMCenter = MMw; - - // vector parallel to one axis of silicon plane - G4double ii = cos(Theta / rad) * cos(Phi / rad); - G4double jj = cos(Theta / rad) * sin(Phi / rad); - G4double kk = -sin(Theta / rad); - G4ThreeVector Y = G4ThreeVector(ii, jj, kk); - - MMw = MMw.unit(); - MMu = MMw.cross(Y); - MMv = MMw.cross(MMu); - MMv = MMv.unit(); - MMu = MMu.unit(); - - // Passage Matrix from Lab Referential to Telescope Referential - // MUST2 - MMrot = new G4RotationMatrix(MMu, MMv, MMw); - // Telescope is rotate of Beta angle around MMv axis. - MMrot->rotate(m_beta_u[i], MMu); - MMrot->rotate(m_beta_v[i], MMv); - MMrot->rotate(m_beta_w[i], MMw); - // translation to place Telescope - MMpos = MMw * Length * 0.5 + MMCenter; + else if (DataBuffer.compare(0, 8, "X128_Y1=") == 0) { + check_B = true; + ConfigFile >> DataBuffer; + Bx = atof(DataBuffer.c_str()); + Bx = Bx * mm; + ConfigFile >> DataBuffer; + By = atof(DataBuffer.c_str()); + By = By * mm; + ConfigFile >> DataBuffer; + Bz = atof(DataBuffer.c_str()); + Bz = Bz * mm; + + B = G4ThreeVector(Bx, By, Bz); + G4cout << "X128 Y1 corner position : " << B << G4endl; } - FirstStage = m_wFirstStage[i] ; - SecondStage = m_wSecondStage[i] ; - ThirdStage = m_wThirdStage[i] ; - FourthStage = m_wFourthStage[i] ; - FifthStage = m_wFifthStage[i] ; - SixthStage = m_wSixthStage[i] ; + else if (DataBuffer.compare(0, 8, "X1_Y128=") == 0) { + check_C = true; + ConfigFile >> DataBuffer; + Cx = atof(DataBuffer.c_str()); + Cx = Cx * mm; + ConfigFile >> DataBuffer; + Cy = atof(DataBuffer.c_str()); + Cy = Cy * mm; + ConfigFile >> DataBuffer; + Cz = atof(DataBuffer.c_str()); + Cz = Cz * mm; + + C = G4ThreeVector(Cx, Cy, Cz); + G4cout << "X1 Y128 corner position : " << C << G4endl; + } - VolumeMaker(i + 1, MMpos, MMrot, FirstStage, SecondStage, ThirdStage , FourthStage, FifthStage, SixthStage, world); - } + else if (DataBuffer.compare(0, 10, "X128_Y128=") == 0) { + check_D = true; + ConfigFile >> DataBuffer; + Dx = atof(DataBuffer.c_str()); + Dx = Dx * mm; + ConfigFile >> DataBuffer; + Dy = atof(DataBuffer.c_str()); + Dy = Dy * mm; + ConfigFile >> DataBuffer; + Dz = atof(DataBuffer.c_str()); + Dz = Dz * mm; + + D = G4ThreeVector(Dx, Dy, Dz); + G4cout << "X128 Y128 corner position : " << D << G4endl; + } - delete MMrot ; -} + // Angle method + else if (DataBuffer.compare(0, 6, "THETA=") == 0) { + check_Theta = true; + ConfigFile >> DataBuffer; + Theta = atof(DataBuffer.c_str()); + Theta = Theta * deg; + G4cout << "Theta: " << Theta / deg << G4endl; + } + else if (DataBuffer.compare(0, 4, "PHI=") == 0) { + check_Phi = true; + ConfigFile >> DataBuffer; + Phi = atof(DataBuffer.c_str()); + Phi = Phi * deg; + G4cout << "Phi: " << Phi / deg << G4endl; + } + else if (DataBuffer.compare(0, 2, "R=") == 0) { + check_R = true; + ConfigFile >> DataBuffer; + R = atof(DataBuffer.c_str()); + R = R * mm; + G4cout << "R: " << R / mm << G4endl; + } -// Connect the Hyde2TrackingData class to the output TTree -// of the simulation -void Hyde2TrackerSquare1::InitializeRootOutput() -{ -} + else if (DataBuffer.compare(0, 5, "BETA=") == 0) { + // check_beta = true; + ConfigFile >> DataBuffer; + beta_u = atof(DataBuffer.c_str()); + beta_u = beta_u * deg; + ConfigFile >> DataBuffer; + beta_v = atof(DataBuffer.c_str()); + beta_v = beta_v * deg; + ConfigFile >> DataBuffer; + beta_w = atof(DataBuffer.c_str()); + beta_w = beta_w * deg; + G4cout << "Beta: " << beta_u / deg << " " << beta_v / deg << " " << beta_w / deg << G4endl; + } + else if (DataBuffer.compare(0, 11, "FIRSTSTAGE=") == 0) { + check_FirstStage = true; + ConfigFile >> DataBuffer; + FIRSTSTAGE = atof(DataBuffer.c_str()); + } + else if (DataBuffer.compare(0, 12, "SECONDSTAGE=") == 0) { + check_SecondStage = true; + ConfigFile >> DataBuffer; + SECONDSTAGE = atof(DataBuffer.c_str()); + } -// Set the TinteractionCoordinates object from NPS::VDetector to the present class -void Hyde2TrackerSquare1::SetInterCoordPointer(TInteractionCoordinates* interCoord) -{ - ms_InterCoord = interCoord; + else if (DataBuffer.compare(0, 11, "THIRDSTAGE=") == 0) { + check_ThirdStage = true; + ConfigFile >> DataBuffer; + THIRDSTAGE = atof(DataBuffer.c_str()); + } + + else if (DataBuffer.compare(0, 12, "FOURTHSTAGE=") == 0) { + check_FourthStage = true; + ConfigFile >> DataBuffer; + FOURTHSTAGE = atof(DataBuffer.c_str()); + } + + else if (DataBuffer.compare(0, 11, "FIFTHSTAGE=") == 0) { + check_FifthStage = true; + ConfigFile >> DataBuffer; + FIFTHSTAGE = atof(DataBuffer.c_str()); + } + + else if (DataBuffer.compare(0, 11, "SIXTHSTAGE=") == 0) { + check_SixthStage = true; + ConfigFile >> DataBuffer; + SIXTHSTAGE = atof(DataBuffer.c_str()); + } + + else if (DataBuffer.compare(0, 4, "VIS=") == 0) { + checkVis = true; + ConfigFile >> DataBuffer; + if (DataBuffer.compare(0, 3, "all") == 0) + m_non_sensitive_part_visiualisation = true; + } + + else + G4cout << "WARNING: Wrong Token, Hyde2TrackerSquare1: Square1 Element not added" << G4endl; + + // Add The previously define telescope + // With position method + if ((check_A && check_B && check_C && check_D && check_FirstStage && check_SecondStage && check_ThirdStage && + check_FourthStage && check_FifthStage && check_SixthStage && checkVis) && + !(check_Theta && check_Phi && check_R)) { + + ReadingStatus = false; + check_A = false; + check_C = false; + check_B = false; + check_D = false; + check_FirstStage = false; + check_SecondStage = false; + check_ThirdStage = false; + check_FourthStage = false; + check_FifthStage = false; + check_SixthStage = false; + checkVis = false; + + AddModule(A, B, C, D, FIRSTSTAGE == 1, SECONDSTAGE == 1, THIRDSTAGE == 1, FOURTHSTAGE == 1, FIFTHSTAGE == 1, + SIXTHSTAGE == 1); + } + + // with angle method + if ((check_Theta && check_Phi && check_R && check_FirstStage && check_SecondStage && check_ThirdStage && + check_FourthStage && check_FifthStage && check_SixthStage && checkVis) && + !(check_A && check_B && check_C && check_D)) { + ReadingStatus = false; + check_Theta = false; + check_Phi = false; + check_R = false; + // check_beta = false ; + check_FirstStage = false; + check_SecondStage = false; + check_ThirdStage = false; + check_FourthStage = false; + check_FifthStage = false; + check_SixthStage = false; + checkVis = false; + + AddModule(R, Theta, Phi, beta_u, beta_v, beta_w, FIRSTSTAGE == 1, SECONDSTAGE == 1, THIRDSTAGE == 1, + FOURTHSTAGE == 1, FIFTHSTAGE == 1, SIXTHSTAGE == 1); + } + } + } +} + +// Construct detector and inialise sensitive part. +// Called After DetecorConstruction::AddDetector Method +void Hyde2TrackerSquare1::ConstructDetector(G4LogicalVolume* world) { + G4RotationMatrix* MMrot = NULL; + G4ThreeVector MMpos = G4ThreeVector(0, 0, 0); + G4ThreeVector MMu = G4ThreeVector(0, 0, 0); + G4ThreeVector MMv = G4ThreeVector(0, 0, 0); + G4ThreeVector MMw = G4ThreeVector(0, 0, 0); + G4ThreeVector MMCenter = G4ThreeVector(0, 0, 0); + bool FirstStage = true; + bool SecondStage = true; + bool ThirdStage = true; + bool FourthStage = true; + bool FifthStage = true; + bool SixthStage = true; + + G4int NumberOfTelescope = m_DefinitionType.size(); + + for (G4int i = 0; i < NumberOfTelescope; i++) { + // By Point + if (m_DefinitionType[i]) { + // (u,v,w) unitary vector associated to telescope referencial + // (u,v) // to silicon plan + // w perpendicular to (u,v) plan and pointing ThirdStage + MMu = m_X128_Y1[i] - m_X1_Y1[i]; + MMu = MMu.unit(); + + MMv = m_X1_Y128[i] - m_X1_Y1[i]; + MMv = MMv.unit(); + + MMw = MMu.cross(MMv); + MMw = MMw.unit(); + + MMCenter = (m_X1_Y1[i] + m_X1_Y128[i] + m_X128_Y1[i] + m_X128_Y128[i]) / 4; + + // Passage Matrix from Lab Referential to Telescope Referential + MMrot = new G4RotationMatrix(MMu, MMv, MMw); + // translation to place Telescope + MMpos = MMw * Length * 0.5 + MMCenter; + } + + // By Angle + else { + G4double Theta = m_Theta[i]; + G4double Phi = m_Phi[i]; + + // (u,v,w) unitary vector associated to telescope referencial + // (u,v) // to silicon plan + // w perpendicular to (u,v) plan and pointing ThirdStage + // Phi is angle between X axis and projection in (X,Y) plan + // Theta is angle between position vector and z axis + G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad); + G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad); + G4double wZ = m_R[i] * cos(Theta / rad); + MMw = G4ThreeVector(wX, wY, wZ); + + // vector corresponding to the center of the module + MMCenter = MMw; + + // vector parallel to one axis of silicon plane + G4double ii = cos(Theta / rad) * cos(Phi / rad); + G4double jj = cos(Theta / rad) * sin(Phi / rad); + G4double kk = -sin(Theta / rad); + G4ThreeVector Y = G4ThreeVector(ii, jj, kk); + + MMw = MMw.unit(); + MMu = MMw.cross(Y); + MMv = MMw.cross(MMu); + MMv = MMv.unit(); + MMu = MMu.unit(); + + // Passage Matrix from Lab Referential to Telescope Referential + // MUST2 + MMrot = new G4RotationMatrix(MMu, MMv, MMw); + // Telescope is rotate of Beta angle around MMv axis. + MMrot->rotate(m_beta_u[i], MMu); + MMrot->rotate(m_beta_v[i], MMv); + MMrot->rotate(m_beta_w[i], MMw); + // translation to place Telescope + MMpos = MMw * Length * 0.5 + MMCenter; + } + + FirstStage = m_wFirstStage[i]; + SecondStage = m_wSecondStage[i]; + ThirdStage = m_wThirdStage[i]; + FourthStage = m_wFourthStage[i]; + FifthStage = m_wFifthStage[i]; + SixthStage = m_wSixthStage[i]; + + VolumeMaker(i + 1, MMpos, MMrot, FirstStage, SecondStage, ThirdStage, FourthStage, FifthStage, SixthStage, world); + } + + delete MMrot; } +// Connect the Hyde2TrackingData class to the output TTree +// of the simulation +void Hyde2TrackerSquare1::InitializeRootOutput() {} +// Set the TinteractionCoordinates object from NPS::VDetector to the present class +void Hyde2TrackerSquare1::SetInterCoordPointer(TInteractionCoordinates* interCoord) { ms_InterCoord = interCoord; } // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Hyde2TrackerSquare1::ReadSensitive(const G4Event* event) -{ -////////////////////////////////////////////////////////////////////////////////////// -//////////////////////// Used to Read Event Map of detector ////////////////////////// -////////////////////////////////////////////////////////////////////////////////////// - // First Stage - std::map<G4int, G4int*>::iterator DetectorNumber_itr; - std::map<G4int, G4double*>::iterator Energy_itr; - std::map<G4int, G4double*>::iterator Time_itr; - std::map<G4int, G4double*>::iterator X_itr; - std::map<G4int, G4double*>::iterator Y_itr; - std::map<G4int, G4double*>::iterator Pos_X_itr; - std::map<G4int, G4double*>::iterator Pos_Y_itr; - std::map<G4int, G4double*>::iterator Pos_Z_itr; - std::map<G4int, G4double*>::iterator Ang_Theta_itr; - std::map<G4int, G4double*>::iterator Ang_Phi_itr; - - G4THitsMap<G4int>* DetectorNumberHitMap; - G4THitsMap<G4double>* EnergyHitMap; - G4THitsMap<G4double>* TimeHitMap; - G4THitsMap<G4double>* XHitMap; - G4THitsMap<G4double>* YHitMap; - G4THitsMap<G4double>* PosXHitMap; - G4THitsMap<G4double>* PosYHitMap; - G4THitsMap<G4double>* PosZHitMap; - G4THitsMap<G4double>* AngThetaHitMap; - G4THitsMap<G4double>* AngPhiHitMap; - - // NULL pointer are given to avoid warning at compilation - // Second Stage - std::map<G4int, G4double*>::iterator SecondStageEnergy_itr ; - G4THitsMap<G4double>* SecondStageEnergyHitMap = NULL ; - // Third Stage - std::map<G4int, G4double*>::iterator ThirdStageEnergy_itr ; - G4THitsMap<G4double>* ThirdStageEnergyHitMap = NULL ; - // Fourth Stage - std::map<G4int, G4double*>::iterator FourthStageEnergy_itr ; - G4THitsMap<G4double>* FourthStageEnergyHitMap = NULL ; - // Fifth Stage - std::map<G4int, G4double*>::iterator FifthStageEnergy_itr ; - G4THitsMap<G4double>* FifthStageEnergyHitMap = NULL ; - // Sixth Stage - std::map<G4int, G4double*>::iterator SixthStageEnergy_itr ; - G4THitsMap<G4double>* SixthStageEnergyHitMap = NULL ; - - - - // Read the Scorer associate to the Silicon Strip - //Detector Number - G4int StripDetCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/DetectorNumber") ; - DetectorNumberHitMap = (G4THitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripDetCollectionID)) ; - DetectorNumber_itr = DetectorNumberHitMap->GetMap()->begin() ; - - //Energy - G4int StripEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/StripEnergy") ; - EnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripEnergyCollectionID)) ; - Energy_itr = EnergyHitMap->GetMap()->begin() ; - - //Time of Flight - G4int StripTimeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/StripTime") ; - TimeHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripTimeCollectionID)) ; - Time_itr = TimeHitMap->GetMap()->begin() ; - - //Strip Number X - G4int StripXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/StripNumberX") ; - XHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripXCollectionID)) ; - X_itr = XHitMap->GetMap()->begin() ; - - //Strip Number Y - G4int StripYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/StripNumberY") ; - YHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripYCollectionID)) ; - Y_itr = YHitMap->GetMap()->begin() ; - - //Interaction Coordinate X - G4int InterCoordXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/InterCoordX") ; - PosXHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordXCollectionID)) ; - Pos_X_itr = PosXHitMap->GetMap()->begin() ; - - //Interaction Coordinate Y - G4int InterCoordYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/InterCoordY") ; - PosYHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordYCollectionID)) ; - Pos_Y_itr = PosYHitMap->GetMap()->begin() ; - - //Interaction Coordinate Z - G4int InterCoordZCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/InterCoordZ") ; - PosZHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordZCollectionID)) ; - Pos_Z_itr = PosXHitMap->GetMap()->begin() ; - - //Interaction Coordinate Angle Theta - G4int InterCoordAngThetaCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/InterCoordAngTheta") ; - AngThetaHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngThetaCollectionID)) ; - Ang_Theta_itr = AngThetaHitMap->GetMap()->begin() ; - - //Interaction Coordinate Angle Phi - G4int InterCoordAngPhiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/InterCoordAngPhi") ; - AngPhiHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngPhiCollectionID)) ; - Ang_Phi_itr = AngPhiHitMap->GetMap()->begin() ; - - - // Read the Scorer associate to the SecondStage - //Energy - G4int SecondStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("SecondStageScorerHYD2Square1/SecondStageEnergy") ; - SecondStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(SecondStageEnergyCollectionID)) ; - SecondStageEnergy_itr = SecondStageEnergyHitMap->GetMap()->begin() ; - - - // Read the Scorer associate to the ThirdStage - //Energy - G4int ThirdStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ThirdStageScorerHYD2Square1/ThirdStageEnergy"); - ThirdStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(ThirdStageEnergyCollectionID)); - ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin(); - - // Read the Scorer associate to the FourthStage - //Energy - G4int FourthStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FourthStageScorerHYD2Square1/FourthStageEnergy"); - FourthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(FourthStageEnergyCollectionID)); - FourthStageEnergy_itr = FourthStageEnergyHitMap->GetMap()->begin(); - - // Read the Scorer associate to the FifthStage - //Energy - G4int FifthStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FifthStageScorerHYD2Square1/FifthStageEnergy"); - FifthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(FifthStageEnergyCollectionID)); - FifthStageEnergy_itr = FifthStageEnergyHitMap->GetMap()->begin(); - - // Read the Scorer associate to the SixthStage - //Energy - G4int SixthStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("SixthStageScorerHYD2Square1/SixthStageEnergy"); - SixthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(SixthStageEnergyCollectionID)); - SixthStageEnergy_itr = SixthStageEnergyHitMap->GetMap()->begin(); - - // Check the size of different map - G4int sizeN = DetectorNumberHitMap->entries(); - G4int sizeE = EnergyHitMap->entries(); - G4int sizeT = TimeHitMap->entries(); - G4int sizeX = XHitMap->entries(); - G4int sizeY = YHitMap->entries(); - - if (sizeE != sizeT || sizeT != sizeX || sizeX != sizeY) { - G4cout << "No match size Si Event Map: sE:" - << sizeE << " sT:" << sizeT << " sX:" << sizeX << " sY:" << sizeY << G4endl ; - return; - } - - // Loop on FirstStage number - for (G4int l = 0; l < sizeN; l++) { - G4double N = *(DetectorNumber_itr->second); - G4int NTrackID = DetectorNumber_itr->first - N; - - if (N > 0) { - // Fill detector number - ms_Event->SetHYD2TrkFirstStageFrontEDetectorNbr(m_index["Square1"] + N); - ms_Event->SetHYD2TrkFirstStageFrontTDetectorNbr(m_index["Square1"] + N); - ms_Event->SetHYD2TrkFirstStageBackEDetectorNbr(m_index["Square1"] + N); - ms_Event->SetHYD2TrkFirstStageBackTDetectorNbr(m_index["Square1"] + N); - - // Energy - for (G4int ll = 0 ; ll < sizeE ; ll++) { - G4int ETrackID = Energy_itr->first - N; - G4double E = *(Energy_itr->second); - if (ETrackID == NTrackID) { - ms_Event->SetHYD2TrkFirstStageFrontEEnergy(RandGauss::shoot(E, ResoFirstStage)); - ms_Event->SetHYD2TrkFirstStageBackEEnergy(RandGauss::shoot(E, ResoFirstStage)); - } - Energy_itr++; - } - - // Time - Time_itr = TimeHitMap->GetMap()->begin(); - for (G4int h = 0 ; h < sizeT ; h++) { - G4int TTrackID = Time_itr->first - N; - G4double T = *(Time_itr->second); - if (TTrackID == NTrackID) { - T = RandGauss::shoot(T, ResoTimePPAC) ; - ms_Event->SetHYD2TrkFirstStageFrontTTime(RandGauss::shoot(T, ResoTimeHyd2)) ; - ms_Event->SetHYD2TrkFirstStageBackTTime(RandGauss::shoot(T, ResoTimeHyd2)) ; - } - Time_itr++; - } - - // X - X_itr = XHitMap->GetMap()->begin(); - for (G4int h = 0 ; h < sizeX ; h++) { - G4int XTrackID = X_itr->first - N; - G4double X = *(X_itr->second); - if (XTrackID == NTrackID) { - ms_Event->SetHYD2TrkFirstStageFrontEStripNbr(X); - ms_Event->SetHYD2TrkFirstStageFrontTStripNbr(X); - } - - X_itr++; - } - - // Y - Y_itr = YHitMap->GetMap()->begin() ; - for (G4int h = 0 ; h < sizeY ; h++) { - G4int YTrackID = Y_itr->first - N; - G4double Y = *(Y_itr->second); - if (YTrackID == NTrackID) { - ms_Event->SetHYD2TrkFirstStageBackEStripNbr(Y); - ms_Event->SetHYD2TrkFirstStageBackTStripNbr(Y); - } - - Y_itr++; - } - - // Pos X - Pos_X_itr = PosXHitMap->GetMap()->begin(); - for (unsigned int h = 0; h < PosXHitMap->entries(); h++) { - G4int PosXTrackID = Pos_X_itr->first - N ; - G4double PosX = *(Pos_X_itr->second) ; - if (PosXTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionX(PosX) ; - } - Pos_X_itr++; - } - - // Pos Y - Pos_Y_itr = PosYHitMap->GetMap()->begin(); - for (unsigned int h = 0; h < PosYHitMap->entries(); h++) { - G4int PosYTrackID = Pos_Y_itr->first - N ; - G4double PosY = *(Pos_Y_itr->second) ; - if (PosYTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionY(PosY) ; - } - Pos_Y_itr++; - } - - // Pos Z - Pos_Z_itr = PosZHitMap->GetMap()->begin(); - for (unsigned int h = 0; h < PosZHitMap->entries(); h++) { - G4int PosZTrackID = Pos_Z_itr->first - N ; - G4double PosZ = *(Pos_Z_itr->second) ; - if (PosZTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionZ(PosZ) ; - } - Pos_Z_itr++; - } - - // Angle Theta - Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); - for (unsigned int h = 0; h < AngThetaHitMap->entries(); h++) { - G4int AngThetaTrackID = Ang_Theta_itr->first - N ; - G4double AngTheta = *(Ang_Theta_itr->second) ; - if (AngThetaTrackID == NTrackID) { - ms_InterCoord->SetDetectedAngleTheta(AngTheta) ; - } - Ang_Theta_itr++; - } - - // Angle Phi - Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); - for (unsigned int h = 0; h < AngPhiHitMap->entries(); h++) { - G4int AngPhiTrackID = Ang_Phi_itr->first - N ; - G4double AngPhi = *(Ang_Phi_itr->second) ; - if (AngPhiTrackID == NTrackID) { - ms_InterCoord->SetDetectedAnglePhi(AngPhi) ; - } - Ang_Phi_itr++; - } - - // Second Stage - SecondStageEnergy_itr = SecondStageEnergyHitMap->GetMap()->begin() ; - for (unsigned int h = 0 ; h < SecondStageEnergyHitMap->entries() ; h++) { - G4int SecondStageEnergyTrackID = SecondStageEnergy_itr->first - N; - G4double SecondStageEnergy = *(SecondStageEnergy_itr->second); - - if (SecondStageEnergyTrackID == NTrackID) { - ms_Event->SetHYD2TrkSecondStageEEnergy(RandGauss::shoot(SecondStageEnergy, ResoSecondStage)) ; - ms_Event->SetHYD2TrkSecondStageEPadNbr(1); - ms_Event->SetHYD2TrkSecondStageTPadNbr(1); - ms_Event->SetHYD2TrkSecondStageTTime(1); - ms_Event->SetHYD2TrkSecondStageTDetectorNbr(m_index["Square1"] + N); - ms_Event->SetHYD2TrkSecondStageEDetectorNbr(m_index["Square1"] + N); - } - - SecondStageEnergy_itr++; - } - - // Third Stage - ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin() ; - for (unsigned int h = 0 ; h < ThirdStageEnergyHitMap->entries() ; h++) { - G4int ThirdStageEnergyTrackID = ThirdStageEnergy_itr->first - N; - G4double ThirdStageEnergy = *(ThirdStageEnergy_itr->second) ; - - if (ThirdStageEnergyTrackID == NTrackID) { - ms_Event->SetHYD2TrkThirdStageEEnergy(RandGauss::shoot(ThirdStageEnergy, ResoThirdStage)); - ms_Event->SetHYD2TrkThirdStageEPadNbr(1); - ms_Event->SetHYD2TrkThirdStageTPadNbr(1); - ms_Event->SetHYD2TrkThirdStageTTime(1); - ms_Event->SetHYD2TrkThirdStageTDetectorNbr(m_index["Square1"] + N); - ms_Event->SetHYD2TrkThirdStageEDetectorNbr(m_index["Square1"] + N); - } - - ThirdStageEnergy_itr++; - } - - // Fourth Stage - FourthStageEnergy_itr = FourthStageEnergyHitMap->GetMap()->begin() ; - for (unsigned int h = 0 ; h < FourthStageEnergyHitMap->entries() ; h++) { - G4int FourthStageEnergyTrackID = FourthStageEnergy_itr->first - N; - G4double FourthStageEnergy = *(FourthStageEnergy_itr->second) ; - - if (FourthStageEnergyTrackID == NTrackID) { - ms_Event->SetHYD2TrkFourthStageEEnergy(RandGauss::shoot(FourthStageEnergy, ResoFourthStage)); - ms_Event->SetHYD2TrkFourthStageEPadNbr(1); - ms_Event->SetHYD2TrkFourthStageTPadNbr(1); - ms_Event->SetHYD2TrkFourthStageTTime(1); - ms_Event->SetHYD2TrkFourthStageTDetectorNbr(m_index["Square1"] + N); - ms_Event->SetHYD2TrkFourthStageEDetectorNbr(m_index["Square1"] + N); - } - - FourthStageEnergy_itr++; - } - - // Fifth Stage - FifthStageEnergy_itr = FifthStageEnergyHitMap->GetMap()->begin() ; - for (unsigned int h = 0 ; h < FifthStageEnergyHitMap->entries() ; h++) { - G4int FifthStageEnergyTrackID = FifthStageEnergy_itr->first - N; - G4double FifthStageEnergy = *(FifthStageEnergy_itr->second) ; - - if (FifthStageEnergyTrackID == NTrackID) { - ms_Event->SetHYD2TrkFifthStageEEnergy(RandGauss::shoot(FifthStageEnergy, ResoFifthStage)); - ms_Event->SetHYD2TrkFifthStageEPadNbr(1); - ms_Event->SetHYD2TrkFifthStageTPadNbr(1); - ms_Event->SetHYD2TrkFifthStageTTime(1); - ms_Event->SetHYD2TrkFifthStageTDetectorNbr(m_index["Square1"] + N); - ms_Event->SetHYD2TrkFifthStageEDetectorNbr(m_index["Square1"] + N); - } - - FifthStageEnergy_itr++; - } - - // Sixth Stage - SixthStageEnergy_itr = SixthStageEnergyHitMap->GetMap()->begin() ; - for (unsigned int h = 0 ; h < SixthStageEnergyHitMap->entries() ; h++) { - G4int SixthStageEnergyTrackID = SixthStageEnergy_itr->first - N; - G4double SixthStageEnergy = *(SixthStageEnergy_itr->second) ; - - if (SixthStageEnergyTrackID == NTrackID) { - ms_Event->SetHYD2TrkSixthStageEEnergy(RandGauss::shoot(SixthStageEnergy, ResoSixthStage)); - ms_Event->SetHYD2TrkSixthStageEPadNbr(1); - ms_Event->SetHYD2TrkSixthStageTPadNbr(1); - ms_Event->SetHYD2TrkSixthStageTTime(1); - ms_Event->SetHYD2TrkSixthStageTDetectorNbr(m_index["Square1"] + N); - ms_Event->SetHYD2TrkSixthStageEDetectorNbr(m_index["Square1"] + N); - } - - SixthStageEnergy_itr++; - } - - DetectorNumber_itr++; +void Hyde2TrackerSquare1::ReadSensitive(const G4Event* event) { + ////////////////////////////////////////////////////////////////////////////////////// + //////////////////////// Used to Read Event Map of detector ////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + // First Stage + std::map<G4int, G4int*>::iterator DetectorNumber_itr; + std::map<G4int, G4double*>::iterator Energy_itr; + std::map<G4int, G4double*>::iterator Time_itr; + std::map<G4int, G4double*>::iterator X_itr; + std::map<G4int, G4double*>::iterator Y_itr; + std::map<G4int, G4double*>::iterator Pos_X_itr; + std::map<G4int, G4double*>::iterator Pos_Y_itr; + std::map<G4int, G4double*>::iterator Pos_Z_itr; + std::map<G4int, G4double*>::iterator Ang_Theta_itr; + std::map<G4int, G4double*>::iterator Ang_Phi_itr; + + G4THitsMap<G4int>* DetectorNumberHitMap; + G4THitsMap<G4double>* EnergyHitMap; + G4THitsMap<G4double>* TimeHitMap; + G4THitsMap<G4double>* XHitMap; + G4THitsMap<G4double>* YHitMap; + G4THitsMap<G4double>* PosXHitMap; + G4THitsMap<G4double>* PosYHitMap; + G4THitsMap<G4double>* PosZHitMap; + G4THitsMap<G4double>* AngThetaHitMap; + G4THitsMap<G4double>* AngPhiHitMap; + + // NULL pointer are given to avoid warning at compilation + // Second Stage + std::map<G4int, G4double*>::iterator SecondStageEnergy_itr; + G4THitsMap<G4double>* SecondStageEnergyHitMap = NULL; + // Third Stage + std::map<G4int, G4double*>::iterator ThirdStageEnergy_itr; + G4THitsMap<G4double>* ThirdStageEnergyHitMap = NULL; + // Fourth Stage + std::map<G4int, G4double*>::iterator FourthStageEnergy_itr; + G4THitsMap<G4double>* FourthStageEnergyHitMap = NULL; + // Fifth Stage + std::map<G4int, G4double*>::iterator FifthStageEnergy_itr; + G4THitsMap<G4double>* FifthStageEnergyHitMap = NULL; + // Sixth Stage + std::map<G4int, G4double*>::iterator SixthStageEnergy_itr; + G4THitsMap<G4double>* SixthStageEnergyHitMap = NULL; + + // Read the Scorer associate to the Silicon Strip + // Detector Number + G4int StripDetCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/DetectorNumber"); + DetectorNumberHitMap = (G4THitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripDetCollectionID)); + DetectorNumber_itr = DetectorNumberHitMap->GetMap()->begin(); + + // Energy + G4int StripEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/StripEnergy"); + EnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripEnergyCollectionID)); + Energy_itr = EnergyHitMap->GetMap()->begin(); + + // Time of Flight + G4int StripTimeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/StripTime"); + TimeHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripTimeCollectionID)); + Time_itr = TimeHitMap->GetMap()->begin(); + + // Strip Number X + G4int StripXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/StripNumberX"); + XHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripXCollectionID)); + X_itr = XHitMap->GetMap()->begin(); + + // Strip Number Y + G4int StripYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/StripNumberY"); + YHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripYCollectionID)); + Y_itr = YHitMap->GetMap()->begin(); + + // Interaction Coordinate X + G4int InterCoordXCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/InterCoordX"); + PosXHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordXCollectionID)); + Pos_X_itr = PosXHitMap->GetMap()->begin(); + + // Interaction Coordinate Y + G4int InterCoordYCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/InterCoordY"); + PosYHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordYCollectionID)); + Pos_Y_itr = PosYHitMap->GetMap()->begin(); + + // Interaction Coordinate Z + G4int InterCoordZCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/InterCoordZ"); + PosZHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordZCollectionID)); + Pos_Z_itr = PosXHitMap->GetMap()->begin(); + + // Interaction Coordinate Angle Theta + G4int InterCoordAngThetaCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/InterCoordAngTheta"); + AngThetaHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngThetaCollectionID)); + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); + + // Interaction Coordinate Angle Phi + G4int InterCoordAngPhiCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/InterCoordAngPhi"); + AngPhiHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngPhiCollectionID)); + Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); + + // Read the Scorer associate to the SecondStage + // Energy + G4int SecondStageEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("SecondStageScorerHYD2Square1/SecondStageEnergy"); + SecondStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(SecondStageEnergyCollectionID)); + SecondStageEnergy_itr = SecondStageEnergyHitMap->GetMap()->begin(); + + // Read the Scorer associate to the ThirdStage + // Energy + G4int ThirdStageEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("ThirdStageScorerHYD2Square1/ThirdStageEnergy"); + ThirdStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(ThirdStageEnergyCollectionID)); + ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin(); + + // Read the Scorer associate to the FourthStage + // Energy + G4int FourthStageEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FourthStageScorerHYD2Square1/FourthStageEnergy"); + FourthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(FourthStageEnergyCollectionID)); + FourthStageEnergy_itr = FourthStageEnergyHitMap->GetMap()->begin(); + + // Read the Scorer associate to the FifthStage + // Energy + G4int FifthStageEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FifthStageScorerHYD2Square1/FifthStageEnergy"); + FifthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(FifthStageEnergyCollectionID)); + FifthStageEnergy_itr = FifthStageEnergyHitMap->GetMap()->begin(); + + // Read the Scorer associate to the SixthStage + // Energy + G4int SixthStageEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("SixthStageScorerHYD2Square1/SixthStageEnergy"); + SixthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(SixthStageEnergyCollectionID)); + SixthStageEnergy_itr = SixthStageEnergyHitMap->GetMap()->begin(); + + // Check the size of different map + G4int sizeN = DetectorNumberHitMap->entries(); + G4int sizeE = EnergyHitMap->entries(); + G4int sizeT = TimeHitMap->entries(); + G4int sizeX = XHitMap->entries(); + G4int sizeY = YHitMap->entries(); + + if (sizeE != sizeT || sizeT != sizeX || sizeX != sizeY) { + G4cout << "No match size Si Event Map: sE:" << sizeE << " sT:" << sizeT << " sX:" << sizeX << " sY:" << sizeY + << G4endl; + return; + } + + // Loop on FirstStage number + for (G4int l = 0; l < sizeN; l++) { + G4double N = *(DetectorNumber_itr->second); + G4int NTrackID = DetectorNumber_itr->first - N; + + if (N > 0) { + // Fill detector number + ms_Event->SetHYD2TrkFirstStageFrontEDetectorNbr(m_index["Square1"] + N); + ms_Event->SetHYD2TrkFirstStageFrontTDetectorNbr(m_index["Square1"] + N); + ms_Event->SetHYD2TrkFirstStageBackEDetectorNbr(m_index["Square1"] + N); + ms_Event->SetHYD2TrkFirstStageBackTDetectorNbr(m_index["Square1"] + N); + + // Energy + for (G4int ll = 0; ll < sizeE; ll++) { + G4int ETrackID = Energy_itr->first - N; + G4double E = *(Energy_itr->second); + if (ETrackID == NTrackID) { + ms_Event->SetHYD2TrkFirstStageFrontEEnergy(RandGauss::shoot(E, ResoFirstStage)); + ms_Event->SetHYD2TrkFirstStageBackEEnergy(RandGauss::shoot(E, ResoFirstStage)); + } + Energy_itr++; } - // clear map for next event - DetectorNumberHitMap ->clear(); - EnergyHitMap ->clear() ; - TimeHitMap ->clear() ; - XHitMap ->clear() ; - YHitMap ->clear() ; - PosXHitMap ->clear(); - PosYHitMap ->clear(); - PosZHitMap ->clear(); - AngThetaHitMap ->clear(); - AngPhiHitMap ->clear(); - SecondStageEnergyHitMap ->clear() ; - ThirdStageEnergyHitMap ->clear() ; - FourthStageEnergyHitMap ->clear() ; - FifthStageEnergyHitMap ->clear() ; - SixthStageEnergyHitMap ->clear() ; - } -} + // Time + Time_itr = TimeHitMap->GetMap()->begin(); + for (G4int h = 0; h < sizeT; h++) { + G4int TTrackID = Time_itr->first - N; + G4double T = *(Time_itr->second); + if (TTrackID == NTrackID) { + T = RandGauss::shoot(T, ResoTimePPAC); + ms_Event->SetHYD2TrkFirstStageFrontTTime(RandGauss::shoot(T, ResoTimeHyd2)); + ms_Event->SetHYD2TrkFirstStageBackTTime(RandGauss::shoot(T, ResoTimeHyd2)); + } + Time_itr++; + } + // X + X_itr = XHitMap->GetMap()->begin(); + for (G4int h = 0; h < sizeX; h++) { + G4int XTrackID = X_itr->first - N; + G4double X = *(X_itr->second); + if (XTrackID == NTrackID) { + ms_Event->SetHYD2TrkFirstStageFrontEStripNbr(X); + ms_Event->SetHYD2TrkFirstStageFrontTStripNbr(X); + } + + X_itr++; + } + // Y + Y_itr = YHitMap->GetMap()->begin(); + for (G4int h = 0; h < sizeY; h++) { + G4int YTrackID = Y_itr->first - N; + G4double Y = *(Y_itr->second); + if (YTrackID == NTrackID) { + ms_Event->SetHYD2TrkFirstStageBackEStripNbr(Y); + ms_Event->SetHYD2TrkFirstStageBackTStripNbr(Y); + } + + Y_itr++; + } + + // Pos X + Pos_X_itr = PosXHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < PosXHitMap->entries(); h++) { + G4int PosXTrackID = Pos_X_itr->first - N; + G4double PosX = *(Pos_X_itr->second); + if (PosXTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionX(PosX); + } + Pos_X_itr++; + } + + // Pos Y + Pos_Y_itr = PosYHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < PosYHitMap->entries(); h++) { + G4int PosYTrackID = Pos_Y_itr->first - N; + G4double PosY = *(Pos_Y_itr->second); + if (PosYTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionY(PosY); + } + Pos_Y_itr++; + } + + // Pos Z + Pos_Z_itr = PosZHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < PosZHitMap->entries(); h++) { + G4int PosZTrackID = Pos_Z_itr->first - N; + G4double PosZ = *(Pos_Z_itr->second); + if (PosZTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionZ(PosZ); + } + Pos_Z_itr++; + } + + // Angle Theta + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < AngThetaHitMap->entries(); h++) { + G4int AngThetaTrackID = Ang_Theta_itr->first - N; + G4double AngTheta = *(Ang_Theta_itr->second); + if (AngThetaTrackID == NTrackID) { + ms_InterCoord->SetDetectedAngleTheta(AngTheta); + } + Ang_Theta_itr++; + } + + // Angle Phi + Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < AngPhiHitMap->entries(); h++) { + G4int AngPhiTrackID = Ang_Phi_itr->first - N; + G4double AngPhi = *(Ang_Phi_itr->second); + if (AngPhiTrackID == NTrackID) { + ms_InterCoord->SetDetectedAnglePhi(AngPhi); + } + Ang_Phi_itr++; + } + + // Second Stage + SecondStageEnergy_itr = SecondStageEnergyHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < SecondStageEnergyHitMap->entries(); h++) { + G4int SecondStageEnergyTrackID = SecondStageEnergy_itr->first - N; + G4double SecondStageEnergy = *(SecondStageEnergy_itr->second); + + if (SecondStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkSecondStageEEnergy(RandGauss::shoot(SecondStageEnergy, ResoSecondStage)); + ms_Event->SetHYD2TrkSecondStageEPadNbr(1); + ms_Event->SetHYD2TrkSecondStageTPadNbr(1); + ms_Event->SetHYD2TrkSecondStageTTime(1); + ms_Event->SetHYD2TrkSecondStageTDetectorNbr(m_index["Square1"] + N); + ms_Event->SetHYD2TrkSecondStageEDetectorNbr(m_index["Square1"] + N); + } + + SecondStageEnergy_itr++; + } + + // Third Stage + ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < ThirdStageEnergyHitMap->entries(); h++) { + G4int ThirdStageEnergyTrackID = ThirdStageEnergy_itr->first - N; + G4double ThirdStageEnergy = *(ThirdStageEnergy_itr->second); + + if (ThirdStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkThirdStageEEnergy(RandGauss::shoot(ThirdStageEnergy, ResoThirdStage)); + ms_Event->SetHYD2TrkThirdStageEPadNbr(1); + ms_Event->SetHYD2TrkThirdStageTPadNbr(1); + ms_Event->SetHYD2TrkThirdStageTTime(1); + ms_Event->SetHYD2TrkThirdStageTDetectorNbr(m_index["Square1"] + N); + ms_Event->SetHYD2TrkThirdStageEDetectorNbr(m_index["Square1"] + N); + } + + ThirdStageEnergy_itr++; + } + + // Fourth Stage + FourthStageEnergy_itr = FourthStageEnergyHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < FourthStageEnergyHitMap->entries(); h++) { + G4int FourthStageEnergyTrackID = FourthStageEnergy_itr->first - N; + G4double FourthStageEnergy = *(FourthStageEnergy_itr->second); + + if (FourthStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkFourthStageEEnergy(RandGauss::shoot(FourthStageEnergy, ResoFourthStage)); + ms_Event->SetHYD2TrkFourthStageEPadNbr(1); + ms_Event->SetHYD2TrkFourthStageTPadNbr(1); + ms_Event->SetHYD2TrkFourthStageTTime(1); + ms_Event->SetHYD2TrkFourthStageTDetectorNbr(m_index["Square1"] + N); + ms_Event->SetHYD2TrkFourthStageEDetectorNbr(m_index["Square1"] + N); + } + + FourthStageEnergy_itr++; + } + + // Fifth Stage + FifthStageEnergy_itr = FifthStageEnergyHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < FifthStageEnergyHitMap->entries(); h++) { + G4int FifthStageEnergyTrackID = FifthStageEnergy_itr->first - N; + G4double FifthStageEnergy = *(FifthStageEnergy_itr->second); + + if (FifthStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkFifthStageEEnergy(RandGauss::shoot(FifthStageEnergy, ResoFifthStage)); + ms_Event->SetHYD2TrkFifthStageEPadNbr(1); + ms_Event->SetHYD2TrkFifthStageTPadNbr(1); + ms_Event->SetHYD2TrkFifthStageTTime(1); + ms_Event->SetHYD2TrkFifthStageTDetectorNbr(m_index["Square1"] + N); + ms_Event->SetHYD2TrkFifthStageEDetectorNbr(m_index["Square1"] + N); + } + + FifthStageEnergy_itr++; + } + + // Sixth Stage + SixthStageEnergy_itr = SixthStageEnergyHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < SixthStageEnergyHitMap->entries(); h++) { + G4int SixthStageEnergyTrackID = SixthStageEnergy_itr->first - N; + G4double SixthStageEnergy = *(SixthStageEnergy_itr->second); + + if (SixthStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkSixthStageEEnergy(RandGauss::shoot(SixthStageEnergy, ResoSixthStage)); + ms_Event->SetHYD2TrkSixthStageEPadNbr(1); + ms_Event->SetHYD2TrkSixthStageTPadNbr(1); + ms_Event->SetHYD2TrkSixthStageTTime(1); + ms_Event->SetHYD2TrkSixthStageTDetectorNbr(m_index["Square1"] + N); + ms_Event->SetHYD2TrkSixthStageEDetectorNbr(m_index["Square1"] + N); + } + + SixthStageEnergy_itr++; + } + + DetectorNumber_itr++; + } + + // clear map for next event + DetectorNumberHitMap->clear(); + EnergyHitMap->clear(); + TimeHitMap->clear(); + XHitMap->clear(); + YHitMap->clear(); + PosXHitMap->clear(); + PosYHitMap->clear(); + PosZHitMap->clear(); + AngThetaHitMap->clear(); + AngPhiHitMap->clear(); + SecondStageEnergyHitMap->clear(); + ThirdStageEnergyHitMap->clear(); + FourthStageEnergyHitMap->clear(); + FifthStageEnergyHitMap->clear(); + SixthStageEnergyHitMap->clear(); + } +} -void Hyde2TrackerSquare1::InitializeScorers() -{ - bool already_exist = false; - m_FirstStageScorer = NPS::VDetector::CheckScorer("FirstStageScorerHYD2Square1",already_exist); - m_SecondStageScorer = NPS::VDetector::CheckScorer("SecondStageScorerHYD2Square1",already_exist); - m_ThirdStageScorer = NPS::VDetector::CheckScorer("ThirdStageScorerHYD2Square1",already_exist); - m_FourthStageScorer = NPS::VDetector::CheckScorer("FourthStageScorerHYD2Square1",already_exist); - m_FifthStageScorer = NPS::VDetector::CheckScorer("FifthStageScorerHYD2Square1",already_exist); - m_SixthStageScorer = NPS::VDetector::CheckScorer("SixthStageScorerHYD2Square1",already_exist); - if(already_exist) return; - - // First stage Associate Scorer - G4VPrimitiveScorer* DetNbr = new OBSOLETEGENERALSCORERS::PSDetectorNumber("DetectorNumber", "HYD2Square1", 0); - G4VPrimitiveScorer* TOF = new OBSOLETEGENERALSCORERS::PSTOF("StripTime","HYD2Square1", 0); - G4VPrimitiveScorer* InteractionCoordinatesX = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesX("InterCoordX","HYD2Square1", 0); - G4VPrimitiveScorer* InteractionCoordinatesY = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesY("InterCoordY","HYD2Square1", 0); - G4VPrimitiveScorer* InteractionCoordinatesZ = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ","HYD2Square1", 0); - G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta","HYD2Square1", 0); - G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi","HYD2Square1", 0); - G4VPrimitiveScorer* Energy = new HYD2ScorerFirstStageEnergy("StripEnergy", "HYD2Square1", 0); - G4VPrimitiveScorer* StripPositionX = new HYD2ScorerFirstStageFrontStripSquare1("StripNumberX", 0, NumberOfStrips); - G4VPrimitiveScorer* StripPositionY = new HYD2ScorerFirstStageBackStripSquare1("StripNumberY", 0, NumberOfStrips); - - //and register it to the multifunctionnal detector - m_FirstStageScorer->RegisterPrimitive(DetNbr); - m_FirstStageScorer->RegisterPrimitive(Energy); - m_FirstStageScorer->RegisterPrimitive(TOF); - m_FirstStageScorer->RegisterPrimitive(StripPositionX); - m_FirstStageScorer->RegisterPrimitive(StripPositionY); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesX); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesY); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesZ); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAngleTheta); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAnglePhi); - - // Second stage Associate Scorer - G4VPrimitiveScorer* SecondStageEnergy = new HYD2ScorerSecondStageEnergy("SecondStageEnergy", "HYD2Square1", 0); - m_SecondStageScorer->RegisterPrimitive(SecondStageEnergy); - - // Third stage Associate Scorer - G4VPrimitiveScorer* ThirdStageEnergy = new HYD2ScorerThirdStageEnergy("ThirdStageEnergy", "HYD2Square1", 0); - m_ThirdStageScorer->RegisterPrimitive(ThirdStageEnergy); - - // Fourth stage Associate Scorer - G4VPrimitiveScorer* FourthStageEnergy = new HYD2ScorerFourthStageEnergy("FourthStageEnergy", "HYD2Square1", 0); - m_FourthStageScorer->RegisterPrimitive(FourthStageEnergy); - - // Fifth stage Associate Scorer - G4VPrimitiveScorer* FifthStageEnergy = new HYD2ScorerFifthStageEnergy("FifthStageEnergy", "HYD2Square1", 0); - m_FifthStageScorer->RegisterPrimitive(FifthStageEnergy); - - // Sixth stage Associate Scorer - G4VPrimitiveScorer* SixthStageEnergy = new HYD2ScorerSixthStageEnergy("SixthStageEnergy", "HYD2Square1", 0); - m_SixthStageScorer->RegisterPrimitive(SixthStageEnergy); - - // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_FirstStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_SecondStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_ThirdStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_FourthStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_FifthStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_SixthStageScorer); +void Hyde2TrackerSquare1::InitializeScorers() { + bool already_exist = false; + m_FirstStageScorer = NPS::VDetector::CheckScorer("FirstStageScorerHYD2Square1", already_exist); + m_SecondStageScorer = NPS::VDetector::CheckScorer("SecondStageScorerHYD2Square1", already_exist); + m_ThirdStageScorer = NPS::VDetector::CheckScorer("ThirdStageScorerHYD2Square1", already_exist); + m_FourthStageScorer = NPS::VDetector::CheckScorer("FourthStageScorerHYD2Square1", already_exist); + m_FifthStageScorer = NPS::VDetector::CheckScorer("FifthStageScorerHYD2Square1", already_exist); + m_SixthStageScorer = NPS::VDetector::CheckScorer("SixthStageScorerHYD2Square1", already_exist); + if (already_exist) + return; + + // First stage Associate Scorer + G4VPrimitiveScorer* DetNbr = new OBSOLETEGENERALSCORERS::PSDetectorNumber("DetectorNumber", "HYD2Square1", 0); + G4VPrimitiveScorer* TOF = new OBSOLETEGENERALSCORERS::PSTOF("StripTime", "HYD2Square1", 0); + G4VPrimitiveScorer* InteractionCoordinatesX = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesX("InterCoordX", "HYD2Square1", 0); + G4VPrimitiveScorer* InteractionCoordinatesY = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesY("InterCoordY", "HYD2Square1", 0); + G4VPrimitiveScorer* InteractionCoordinatesZ = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ", "HYD2Square1", 0); + G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta", "HYD2Square1", 0); + G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi", "HYD2Square1", 0); + G4VPrimitiveScorer* Energy = new HYD2ScorerFirstStageEnergy("StripEnergy", "HYD2Square1", 0); + G4VPrimitiveScorer* StripPositionX = new HYD2ScorerFirstStageFrontStripSquare1("StripNumberX", 0, NumberOfStrips); + G4VPrimitiveScorer* StripPositionY = new HYD2ScorerFirstStageBackStripSquare1("StripNumberY", 0, NumberOfStrips); + + // and register it to the multifunctionnal detector + m_FirstStageScorer->RegisterPrimitive(DetNbr); + m_FirstStageScorer->RegisterPrimitive(Energy); + m_FirstStageScorer->RegisterPrimitive(TOF); + m_FirstStageScorer->RegisterPrimitive(StripPositionX); + m_FirstStageScorer->RegisterPrimitive(StripPositionY); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesX); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesY); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesZ); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAngleTheta); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAnglePhi); + + // Second stage Associate Scorer + G4VPrimitiveScorer* SecondStageEnergy = new HYD2ScorerSecondStageEnergy("SecondStageEnergy", "HYD2Square1", 0); + m_SecondStageScorer->RegisterPrimitive(SecondStageEnergy); + + // Third stage Associate Scorer + G4VPrimitiveScorer* ThirdStageEnergy = new HYD2ScorerThirdStageEnergy("ThirdStageEnergy", "HYD2Square1", 0); + m_ThirdStageScorer->RegisterPrimitive(ThirdStageEnergy); + + // Fourth stage Associate Scorer + G4VPrimitiveScorer* FourthStageEnergy = new HYD2ScorerFourthStageEnergy("FourthStageEnergy", "HYD2Square1", 0); + m_FourthStageScorer->RegisterPrimitive(FourthStageEnergy); + + // Fifth stage Associate Scorer + G4VPrimitiveScorer* FifthStageEnergy = new HYD2ScorerFifthStageEnergy("FifthStageEnergy", "HYD2Square1", 0); + m_FifthStageScorer->RegisterPrimitive(FifthStageEnergy); + + // Sixth stage Associate Scorer + G4VPrimitiveScorer* SixthStageEnergy = new HYD2ScorerSixthStageEnergy("SixthStageEnergy", "HYD2Square1", 0); + m_SixthStageScorer->RegisterPrimitive(SixthStageEnergy); + + // Add All Scorer to the Global Scorer Manager + G4SDManager::GetSDMpointer()->AddNewDetector(m_FirstStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_SecondStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_ThirdStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_FourthStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_FifthStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_SixthStageScorer); } diff --git a/NPSimulation/Detectors/Hyde2/Hyde2TrackerTrapezoid1.cc b/NPSimulation/Detectors/Hyde2/Hyde2TrackerTrapezoid1.cc index f4585fad7..3ed6b3d12 100644 --- a/NPSimulation/Detectors/Hyde2/Hyde2TrackerTrapezoid1.cc +++ b/NPSimulation/Detectors/Hyde2/Hyde2TrackerTrapezoid1.cc @@ -23,177 +23,135 @@ *****************************************************************************/ // C++ headers +#include <cmath> #include <sstream> #include <string> -#include <cmath> // G4 Geometry headers #include "G4Box.hh" #include "G4Trap.hh" // G4 various headers -#include "G4MaterialTable.hh" +#include "G4Colour.hh" #include "G4Element.hh" #include "G4ElementTable.hh" -#include "G4VisAttributes.hh" -#include "G4Colour.hh" +#include "G4MaterialTable.hh" +#include "G4PVDivision.hh" +#include "G4PVPlacement.hh" #include "G4RotationMatrix.hh" #include "G4Transform3D.hh" -#include "G4PVPlacement.hh" -#include "G4PVDivision.hh" +#include "G4VisAttributes.hh" // G4 sensitive -#include "G4SDManager.hh" #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" // NPTool headers +#include "Hyde2Scorers.hh" #include "Hyde2TrackerTrapezoid1.hh" +#include "NPSVDetector.hh" #include "ObsoleteGeneralScorers.hh" -#include "Hyde2Scorers.hh" #include "RootOutput.h" -#include "NPSVDetector.hh" // CLHEP #include "CLHEP/Random/RandGauss.h" using namespace std; using namespace CLHEP; -using namespace HYD2TRAP1 ; - - +using namespace HYD2TRAP1; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Hyde2TrackerTrapezoid1::Hyde2TrackerTrapezoid1() -{ - ms_InterCoord = 0; -} - - +Hyde2TrackerTrapezoid1::Hyde2TrackerTrapezoid1() { ms_InterCoord = 0; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Hyde2TrackerTrapezoid1::~Hyde2TrackerTrapezoid1() -{ -} - - +Hyde2TrackerTrapezoid1::~Hyde2TrackerTrapezoid1() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Hyde2TrackerTrapezoid1::AddModule(G4ThreeVector X1_Y1 , - G4ThreeVector X128_Y1 , - G4ThreeVector X1_Y128 , - G4ThreeVector X128_Y128 , - bool wFirstStage , - bool wSecondStage , - bool wThirdStage , - bool wFourthStage , - bool wFifthStage , - bool wSixthStage) -{ - m_DefinitionType.push_back(true) ; - - m_X1_Y1.push_back(X1_Y1) ; - m_X128_Y1.push_back(X128_Y1) ; - m_X1_Y128.push_back(X1_Y128) ; - m_X128_Y128.push_back(X128_Y128) ; - m_wFirstStage.push_back(wFirstStage) ; - m_wSecondStage.push_back(wSecondStage) ; - m_wThirdStage.push_back(wThirdStage) ; - m_wFourthStage.push_back(wFourthStage) ; - m_wFifthStage.push_back(wFifthStage) ; - m_wSixthStage.push_back(wSixthStage) ; - - m_R.push_back(0) ; - m_Theta.push_back(0) ; - m_Phi.push_back(0) ; - m_beta_u.push_back(0) ; - m_beta_v.push_back(0) ; - m_beta_w.push_back(0) ; +void Hyde2TrackerTrapezoid1::AddModule(G4ThreeVector X1_Y1, G4ThreeVector X128_Y1, G4ThreeVector X1_Y128, + G4ThreeVector X128_Y128, bool wFirstStage, bool wSecondStage, bool wThirdStage, + bool wFourthStage, bool wFifthStage, bool wSixthStage) { + m_DefinitionType.push_back(true); + + m_X1_Y1.push_back(X1_Y1); + m_X128_Y1.push_back(X128_Y1); + m_X1_Y128.push_back(X1_Y128); + m_X128_Y128.push_back(X128_Y128); + m_wFirstStage.push_back(wFirstStage); + m_wSecondStage.push_back(wSecondStage); + m_wThirdStage.push_back(wThirdStage); + m_wFourthStage.push_back(wFourthStage); + m_wFifthStage.push_back(wFifthStage); + m_wSixthStage.push_back(wSixthStage); + + m_R.push_back(0); + m_Theta.push_back(0); + m_Phi.push_back(0); + m_beta_u.push_back(0); + m_beta_v.push_back(0); + m_beta_w.push_back(0); } - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Hyde2TrackerTrapezoid1::AddModule(G4double R , - G4double Theta , - G4double Phi , - G4double beta_u , - G4double beta_v , - G4double beta_w , - bool wFirstStage , - bool wSecondStage , - bool wThirdStage , - bool wFourthStage , - bool wFifthStage , - bool wSixthStage) -{ - G4ThreeVector empty = G4ThreeVector(0, 0, 0); - - m_DefinitionType.push_back(false); - - m_R.push_back(R) ; - m_Theta.push_back(Theta) ; - m_Phi.push_back(Phi) ; - m_beta_u.push_back(beta_u) ; - m_beta_v.push_back(beta_v) ; - m_beta_w.push_back(beta_w) ; - m_wFirstStage.push_back(wFirstStage) ; - m_wSecondStage.push_back(wSecondStage) ; - m_wThirdStage.push_back(wThirdStage) ; - m_wFourthStage.push_back(wFourthStage) ; - m_wFifthStage.push_back(wFifthStage) ; - m_wSixthStage.push_back(wSixthStage) ; - - m_X1_Y1.push_back(empty) ; - m_X128_Y1.push_back(empty) ; - m_X1_Y128.push_back(empty) ; - m_X128_Y128.push_back(empty) ; +void Hyde2TrackerTrapezoid1::AddModule(G4double R, G4double Theta, G4double Phi, G4double beta_u, G4double beta_v, + G4double beta_w, bool wFirstStage, bool wSecondStage, bool wThirdStage, + bool wFourthStage, bool wFifthStage, bool wSixthStage) { + G4ThreeVector empty = G4ThreeVector(0, 0, 0); + + m_DefinitionType.push_back(false); + + m_R.push_back(R); + m_Theta.push_back(Theta); + m_Phi.push_back(Phi); + m_beta_u.push_back(beta_u); + m_beta_v.push_back(beta_v); + m_beta_w.push_back(beta_w); + m_wFirstStage.push_back(wFirstStage); + m_wSecondStage.push_back(wSecondStage); + m_wThirdStage.push_back(wThirdStage); + m_wFourthStage.push_back(wFourthStage); + m_wFifthStage.push_back(wFifthStage); + m_wSixthStage.push_back(wSixthStage); + + m_X1_Y1.push_back(empty); + m_X128_Y1.push_back(empty); + m_X1_Y128.push_back(empty); + m_X128_Y128.push_back(empty); } - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Hyde2TrackerTrapezoid1::VolumeMaker(G4int TelescopeNumber , - G4ThreeVector MMpos , - G4RotationMatrix* MMrot , - bool wFirstStage , - bool wSecondStage , - bool wThirdStage , - bool wFourthStage , - bool wFifthStage , - bool wSixthStage , - G4LogicalVolume* world) -{ - G4double NbrTelescopes = TelescopeNumber ; - G4String DetectorNumber ; - ostringstream Number ; - Number << NbrTelescopes ; - DetectorNumber = Number.str() ; - - //////////////////////////////////////////////////////////////// - ////////////// Starting Volume Definition ////////////////////// - //////////////////////////////////////////////////////////////// - G4String Name = "HYD2Trapezoid1" + DetectorNumber ; - - // Definition of the volume containing the sensitive detector - G4Trap* solidHYD2Trapezoid1 = new G4Trap(Name, - Length/2, 0*deg, 0*deg, - Height/2, BaseLarge/2, BaseSmall/2, 0*deg, - Height/2, BaseLarge/2, BaseSmall/2, 0*deg); - G4LogicalVolume* logicHYD2Trapezoid1 = new G4LogicalVolume(solidHYD2Trapezoid1, m_MaterialVacuum, Name, 0, 0, 0); - - new G4PVPlacement(G4Transform3D(*MMrot, MMpos), logicHYD2Trapezoid1, Name, world, false, 0); - - logicHYD2Trapezoid1->SetVisAttributes(G4VisAttributes::Invisible); - if (m_non_sensitive_part_visiualisation) logicHYD2Trapezoid1->SetVisAttributes(G4VisAttributes(G4Colour(0.90, 0.90, 0.90))); - - //Place two marker to identify the u and v axis on silicon face: - //marker are placed a bit before the silicon itself so they don't perturbate simulation - //Uncomment to help debugging or if you want to understand the way the code work. - //I should recommand to Comment it during simulation to avoid perturbation of simulation - //Remember G4 is limitationg step on geometry constraints. - /* +void Hyde2TrackerTrapezoid1::VolumeMaker(G4int TelescopeNumber, G4ThreeVector MMpos, G4RotationMatrix* MMrot, + bool wFirstStage, bool wSecondStage, bool wThirdStage, bool wFourthStage, + bool wFifthStage, bool wSixthStage, G4LogicalVolume* world) { + G4double NbrTelescopes = TelescopeNumber; + G4String DetectorNumber; + ostringstream Number; + Number << NbrTelescopes; + DetectorNumber = Number.str(); + + //////////////////////////////////////////////////////////////// + ////////////// Starting Volume Definition ////////////////////// + //////////////////////////////////////////////////////////////// + G4String Name = "HYD2Trapezoid1" + DetectorNumber; + + // Definition of the volume containing the sensitive detector + G4Trap* solidHYD2Trapezoid1 = new G4Trap(Name, Length / 2, 0 * deg, 0 * deg, Height / 2, BaseLarge / 2, BaseSmall / 2, + 0 * deg, Height / 2, BaseLarge / 2, BaseSmall / 2, 0 * deg); + G4LogicalVolume* logicHYD2Trapezoid1 = new G4LogicalVolume(solidHYD2Trapezoid1, m_MaterialVacuum, Name, 0, 0, 0); + + new G4PVPlacement(G4Transform3D(*MMrot, MMpos), logicHYD2Trapezoid1, Name, world, false, 0); + + logicHYD2Trapezoid1->SetVisAttributes(G4VisAttributes::GetInvisible()); + if (m_non_sensitive_part_visiualisation) + logicHYD2Trapezoid1->SetVisAttributes(G4VisAttributes(G4Colour(0.90, 0.90, 0.90))); + + // Place two marker to identify the u and v axis on silicon face: + // marker are placed a bit before the silicon itself so they don't perturbate simulation + // Uncomment to help debugging or if you want to understand the way the code work. + // I should recommand to Comment it during simulation to avoid perturbation of simulation + // Remember G4 is limitationg step on geometry constraints. + /* G4ThreeVector positionMarkerU = CT*0.98 + MMu*SiliconFace/4; G4Box* solidMarkerU = new G4Box( "solidMarkerU" , SiliconFace/4 , 1*mm , 1*mm ) ; - G4LogicalVolume* logicMarkerU = new G4LogicalVolume( solidMarkerU , m_MaterialVacuum , "logicMarkerU",0,0,0) ; + G4LogicalVolume* logicMarkerU = new G4LogicalVolume( solidMarkerU , m_MaterialVacuum , "logicMarkerU",0,0,0) ; PVPBuffer = new G4PVPlacement(G4Transform3D(*MMrot,positionMarkerU),logicMarkerU,"MarkerU",world,false,0) ; G4VisAttributes* MarkerUVisAtt= new G4VisAttributes(G4Colour(0.,0.,0.5));//blue @@ -201,187 +159,156 @@ void Hyde2TrackerTrapezoid1::VolumeMaker(G4int TelescopeNumber , G4ThreeVector positionMarkerV = CT*0.98 + MMv*SiliconFace/4; G4Box* solidMarkerV = new G4Box( "solidMarkerU" , 1*mm , SiliconFace/4 , 1*mm ) ; - G4LogicalVolume* logicMarkerV = new G4LogicalVolume( solidMarkerV , m_MaterialVacuum , "logicMarkerV",0,0,0) ; + G4LogicalVolume* logicMarkerV = new G4LogicalVolume( solidMarkerV , m_MaterialVacuum , "logicMarkerV",0,0,0) ; PVPBuffer = new G4PVPlacement(G4Transform3D(*MMrot,positionMarkerV),logicMarkerV,"MarkerV",world,false,0) ; G4VisAttributes* MarkerVVisAtt= new G4VisAttributes(G4Colour(0.,0.5,0.5));//green logicMarkerV->SetVisAttributes(MarkerVVisAtt); */ - //////////////////////////////////////////////////////////////// - /////////////////// First Stage Construction//////////////////// - //////////////////////////////////////////////////////////////// - if (wFirstStage) { - // Silicon detector itself - G4ThreeVector positionFirstStage = G4ThreeVector(0, 0, FirstStage_PosZ); - - G4Trap* solidFirstStage = new G4Trap("solidFirstStage", - FirstStageThickness/2, 0*deg, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg); - G4LogicalVolume* logicFirstStage = new G4LogicalVolume(solidFirstStage, m_MaterialSilicon, "logicFirstStage", 0, 0, 0); - - new G4PVPlacement(0, - positionFirstStage, - logicFirstStage, - Name + "_FirstStage", - logicHYD2Trapezoid1, - false, - 0); - - // Set First Stage sensible - logicFirstStage->SetSensitiveDetector(m_FirstStageScorer); - - ///Visualisation of FirstStage Strip - G4VisAttributes* FirstStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)); // blue - logicFirstStage->SetVisAttributes(FirstStageVisAtt); - } - - //////////////////////////////////////////////////////////////// - //////////////// Second Stage Construction //////////////////// - //////////////////////////////////////////////////////////////// - if (wSecondStage) { - // Second stage silicon detector - G4ThreeVector positionSecondStage = G4ThreeVector(0, 0, SecondStage_PosZ); - - G4Trap* solidSecondStage = new G4Trap("solidSecondStage", - SecondStageThickness/2, 0*deg, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg); - G4LogicalVolume* logicSecondStage = new G4LogicalVolume(solidSecondStage, m_MaterialSilicon, "logicSecondStage", 0, 0, 0); - - new G4PVPlacement(0, - positionSecondStage, - logicSecondStage, - Name + "_SecondStage", - logicHYD2Trapezoid1, - false, - 0); - - // Set Second Stage sensible - logicSecondStage->SetSensitiveDetector(m_SecondStageScorer); - - ///Visualisation of SecondStage Strip - G4VisAttributes* SecondStageVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)); - logicSecondStage->SetVisAttributes(SecondStageVisAtt); - } - - //////////////////////////////////////////////////////////////// - ///////////////// Third Stage Construction ///////////////////// - //////////////////////////////////////////////////////////////// - if (wThirdStage) { - // Third stage silicon detector - G4ThreeVector positionThirdStage = G4ThreeVector(0, 0, ThirdStage_PosZ); - - G4Trap* solidThirdStage = new G4Trap("solidThirdStage", - ThirdStageThickness/2, 0*deg, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg); - G4LogicalVolume* logicThirdStage = new G4LogicalVolume(solidThirdStage, m_MaterialSilicon, "logicThirdStage", 0, 0, 0); - - new G4PVPlacement(0, - positionThirdStage, - logicThirdStage, - Name + "_ThirdStage", - logicHYD2Trapezoid1, - false, - 0); - - // Set Third Stage sensible - logicThirdStage->SetSensitiveDetector(m_ThirdStageScorer); - - ///Visualisation of Third Stage - G4VisAttributes* ThirdStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red - logicThirdStage->SetVisAttributes(ThirdStageVisAtt); - } - - //////////////////////////////////////////////////////////////// - ///////////////// Fourth Stage Construction //////////////////// - //////////////////////////////////////////////////////////////// - if (wFourthStage) { - // Fourth stage silicon detector - G4ThreeVector positionFourthStage = G4ThreeVector(0, 0, FourthStage_PosZ); - - G4Trap* solidFourthStage = new G4Trap("solidFourthStage", - FourthStageThickness/2, 0*deg, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg); - G4LogicalVolume* logicFourthStage = new G4LogicalVolume(solidFourthStage, m_MaterialSilicon, "logicFourthStage", 0, 0, 0); - - new G4PVPlacement(0, - positionFourthStage, - logicFourthStage, - Name + "_FourthStage", - logicHYD2Trapezoid1, - false, - 0); - - // Set Fourth Stage sensible - logicFourthStage->SetSensitiveDetector(m_FourthStageScorer); - - ///Visualisation of Fourth Stage - G4VisAttributes* FourthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red - logicFourthStage->SetVisAttributes(FourthStageVisAtt); - } - - //////////////////////////////////////////////////////////////// - ///////////////// Fifth Stage Construction ///////////////////// - //////////////////////////////////////////////////////////////// - if (wFifthStage) { - // Fifth stage silicon detector - G4ThreeVector positionFifthStage = G4ThreeVector(0, 0, FifthStage_PosZ); - - G4Trap* solidFifthStage = new G4Trap("solidFifthStage", - FifthStageThickness/2, 0*deg, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg); - G4LogicalVolume* logicFifthStage = new G4LogicalVolume(solidFifthStage, m_MaterialSilicon, "logicFifthStage", 0, 0, 0); - - new G4PVPlacement(0, - positionFifthStage, - logicFifthStage, - Name + "_FifthStage", - logicHYD2Trapezoid1, - false, - 0); - - // Set Fifth Stage sensible - logicFifthStage->SetSensitiveDetector(m_FifthStageScorer); - - ///Visualisation of Fifth Stage - G4VisAttributes* FifthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red - logicFifthStage->SetVisAttributes(FifthStageVisAtt); - } - - //////////////////////////////////////////////////////////////// - ///////////////// Sixth Stage Construction ///////////////////// - //////////////////////////////////////////////////////////////// - if (wSixthStage) { - // Sixth stage silicon detector - G4ThreeVector positionSixthStage = G4ThreeVector(0, 0, SixthStage_PosZ); - - G4Trap* solidSixthStage = new G4Trap("solidSixthStage", - SixthStageThickness/2, 0*deg, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg); - G4LogicalVolume* logicSixthStage = new G4LogicalVolume(solidSixthStage, m_MaterialSilicon, "logicSixthStage", 0, 0, 0); - - new G4PVPlacement(0, - positionSixthStage, - logicSixthStage, - Name + "_SixthStage", - logicHYD2Trapezoid1, - false, - 0); - - // Set Sixth Stage sensible - logicSixthStage->SetSensitiveDetector(m_SixthStageScorer); - - ///Visualisation of Sixth Stage - G4VisAttributes* SixthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red - logicSixthStage->SetVisAttributes(SixthStageVisAtt); - } - + //////////////////////////////////////////////////////////////// + /////////////////// First Stage Construction//////////////////// + //////////////////////////////////////////////////////////////// + if (wFirstStage) { + // Silicon detector itself + G4ThreeVector positionFirstStage = G4ThreeVector(0, 0, FirstStage_PosZ); + + G4Trap* solidFirstStage = + new G4Trap("solidFirstStage", FirstStageThickness / 2, 0 * deg, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg); + G4LogicalVolume* logicFirstStage = + new G4LogicalVolume(solidFirstStage, m_MaterialSilicon, "logicFirstStage", 0, 0, 0); + + new G4PVPlacement(0, positionFirstStage, logicFirstStage, Name + "_FirstStage", logicHYD2Trapezoid1, false, 0); + + // Set First Stage sensible + logicFirstStage->SetSensitiveDetector(m_FirstStageScorer); + + /// Visualisation of FirstStage Strip + G4VisAttributes* FirstStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)); // blue + logicFirstStage->SetVisAttributes(FirstStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + //////////////// Second Stage Construction //////////////////// + //////////////////////////////////////////////////////////////// + if (wSecondStage) { + // Second stage silicon detector + G4ThreeVector positionSecondStage = G4ThreeVector(0, 0, SecondStage_PosZ); + + G4Trap* solidSecondStage = + new G4Trap("solidSecondStage", SecondStageThickness / 2, 0 * deg, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg); + G4LogicalVolume* logicSecondStage = + new G4LogicalVolume(solidSecondStage, m_MaterialSilicon, "logicSecondStage", 0, 0, 0); + + new G4PVPlacement(0, positionSecondStage, logicSecondStage, Name + "_SecondStage", logicHYD2Trapezoid1, false, 0); + + // Set Second Stage sensible + logicSecondStage->SetSensitiveDetector(m_SecondStageScorer); + + /// Visualisation of SecondStage Strip + G4VisAttributes* SecondStageVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)); + logicSecondStage->SetVisAttributes(SecondStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Third Stage Construction ///////////////////// + //////////////////////////////////////////////////////////////// + if (wThirdStage) { + // Third stage silicon detector + G4ThreeVector positionThirdStage = G4ThreeVector(0, 0, ThirdStage_PosZ); + + G4Trap* solidThirdStage = + new G4Trap("solidThirdStage", ThirdStageThickness / 2, 0 * deg, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg); + G4LogicalVolume* logicThirdStage = + new G4LogicalVolume(solidThirdStage, m_MaterialSilicon, "logicThirdStage", 0, 0, 0); + + new G4PVPlacement(0, positionThirdStage, logicThirdStage, Name + "_ThirdStage", logicHYD2Trapezoid1, false, 0); + + // Set Third Stage sensible + logicThirdStage->SetSensitiveDetector(m_ThirdStageScorer); + + /// Visualisation of Third Stage + G4VisAttributes* ThirdStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red + logicThirdStage->SetVisAttributes(ThirdStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Fourth Stage Construction //////////////////// + //////////////////////////////////////////////////////////////// + if (wFourthStage) { + // Fourth stage silicon detector + G4ThreeVector positionFourthStage = G4ThreeVector(0, 0, FourthStage_PosZ); + + G4Trap* solidFourthStage = + new G4Trap("solidFourthStage", FourthStageThickness / 2, 0 * deg, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg); + G4LogicalVolume* logicFourthStage = + new G4LogicalVolume(solidFourthStage, m_MaterialSilicon, "logicFourthStage", 0, 0, 0); + + new G4PVPlacement(0, positionFourthStage, logicFourthStage, Name + "_FourthStage", logicHYD2Trapezoid1, false, 0); + + // Set Fourth Stage sensible + logicFourthStage->SetSensitiveDetector(m_FourthStageScorer); + + /// Visualisation of Fourth Stage + G4VisAttributes* FourthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red + logicFourthStage->SetVisAttributes(FourthStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Fifth Stage Construction ///////////////////// + //////////////////////////////////////////////////////////////// + if (wFifthStage) { + // Fifth stage silicon detector + G4ThreeVector positionFifthStage = G4ThreeVector(0, 0, FifthStage_PosZ); + + G4Trap* solidFifthStage = + new G4Trap("solidFifthStage", FifthStageThickness / 2, 0 * deg, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg); + G4LogicalVolume* logicFifthStage = + new G4LogicalVolume(solidFifthStage, m_MaterialSilicon, "logicFifthStage", 0, 0, 0); + + new G4PVPlacement(0, positionFifthStage, logicFifthStage, Name + "_FifthStage", logicHYD2Trapezoid1, false, 0); + + // Set Fifth Stage sensible + logicFifthStage->SetSensitiveDetector(m_FifthStageScorer); + + /// Visualisation of Fifth Stage + G4VisAttributes* FifthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red + logicFifthStage->SetVisAttributes(FifthStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Sixth Stage Construction ///////////////////// + //////////////////////////////////////////////////////////////// + if (wSixthStage) { + // Sixth stage silicon detector + G4ThreeVector positionSixthStage = G4ThreeVector(0, 0, SixthStage_PosZ); + + G4Trap* solidSixthStage = + new G4Trap("solidSixthStage", SixthStageThickness / 2, 0 * deg, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg); + G4LogicalVolume* logicSixthStage = + new G4LogicalVolume(solidSixthStage, m_MaterialSilicon, "logicSixthStage", 0, 0, 0); + + new G4PVPlacement(0, positionSixthStage, logicSixthStage, Name + "_SixthStage", logicHYD2Trapezoid1, false, 0); + + // Set Sixth Stage sensible + logicSixthStage->SetSensitiveDetector(m_SixthStageScorer); + + /// Visualisation of Sixth Stage + G4VisAttributes* SixthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red + logicSixthStage->SetVisAttributes(SixthStageVisAtt); + } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -391,836 +318,825 @@ void Hyde2TrackerTrapezoid1::VolumeMaker(G4int TelescopeNumber , // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Hyde2TrackerTrapezoid1::ReadConfiguration(string Path) -{ - ifstream ConfigFile ; - ConfigFile.open(Path.c_str()) ; - string LineBuffer ; - string DataBuffer ; - - // A:X1_Y1 --> X:1 Y:1 - // B:X128_Y1 --> X:128 Y:1 - // C:X1_Y128 --> X:1 Y:128 - // D:X128_Y128 --> X:128 Y:128 - - G4double Ax , Bx , Cx , Dx , Ay , By , Cy , Dy , Az , Bz , Cz , Dz ; - G4ThreeVector A , B , C , D ; - G4double Theta = 0 , Phi = 0 , R = 0 , beta_u = 0 , beta_v = 0 , beta_w = 0 ; - int FIRSTSTAGE = 0 , SECONDSTAGE = 0 , THIRDSTAGE = 0 , FOURTHSTAGE = 0 , FIFTHSTAGE = 0 , SIXTHSTAGE = 0 ; - - bool ReadingStatus = false ; - - bool check_A = false ; - bool check_C = false ; - bool check_B = false ; - bool check_D = false ; - - bool check_Theta = false ; - bool check_Phi = false ; - bool check_R = false ; -// bool check_beta = false ; - - bool check_FirstStage = false ; - bool check_SecondStage = false ; - bool check_ThirdStage = false ; - bool check_FourthStage = false ; - bool check_FifthStage = false ; - bool check_SixthStage = false ; - bool checkVis = false ; - - while (!ConfigFile.eof()) { - getline(ConfigFile, LineBuffer); - if (LineBuffer.compare(0, 14, "HYD2Trapezoid1") == 0) { - G4cout << "///" << G4endl ; - G4cout << "Trapezoid1 element found: " << G4endl ; - ReadingStatus = true ; - } - - while(ReadingStatus){ - - ConfigFile >> DataBuffer; - // Comment Line - if (DataBuffer.compare(0, 1, "%") == 0) {/*do nothing */;} - - // Position method - else if (DataBuffer.compare(0, 6, "X1_Y1=") == 0) { - check_A = true; - ConfigFile >> DataBuffer ; - Ax = atof(DataBuffer.c_str()) ; - Ax = Ax * mm ; - ConfigFile >> DataBuffer ; - Ay = atof(DataBuffer.c_str()) ; - Ay = Ay * mm ; - ConfigFile >> DataBuffer ; - Az = atof(DataBuffer.c_str()) ; - Az = Az * mm ; - - A = G4ThreeVector(Ax, Ay, Az); - G4cout << "X1 Y1 corner position : " << A << G4endl; - } - - else if (DataBuffer.compare(0, 8, "X128_Y1=") == 0) { - check_B = true; - ConfigFile >> DataBuffer ; - Bx = atof(DataBuffer.c_str()) ; - Bx = Bx * mm ; - ConfigFile >> DataBuffer ; - By = atof(DataBuffer.c_str()) ; - By = By * mm ; - ConfigFile >> DataBuffer ; - Bz = atof(DataBuffer.c_str()) ; - Bz = Bz * mm ; - - B = G4ThreeVector(Bx, By, Bz); - G4cout << "X128 Y1 corner position : " << B << G4endl; - } - - else if (DataBuffer.compare(0, 8, "X1_Y128=") == 0) { - check_C = true; - ConfigFile >> DataBuffer ; - Cx = atof(DataBuffer.c_str()) ; - Cx = Cx * mm ; - ConfigFile >> DataBuffer ; - Cy = atof(DataBuffer.c_str()) ; - Cy = Cy * mm ; - ConfigFile >> DataBuffer ; - Cz = atof(DataBuffer.c_str()) ; - Cz = Cz * mm ; - - C = G4ThreeVector(Cx, Cy, Cz); - G4cout << "X1 Y128 corner position : " << C << G4endl; - } - - else if (DataBuffer.compare(0, 10, "X128_Y128=") == 0) { - check_D = true; - ConfigFile >> DataBuffer ; - Dx = atof(DataBuffer.c_str()) ; - Dx = Dx * mm ; - ConfigFile >> DataBuffer ; - Dy = atof(DataBuffer.c_str()) ; - Dy = Dy * mm ; - ConfigFile >> DataBuffer ; - Dz = atof(DataBuffer.c_str()) ; - Dz = Dz * mm ; - - D = G4ThreeVector(Dx, Dy, Dz); - G4cout << "X128 Y128 corner position : " << D << G4endl; - } - - - // Angle method - else if (DataBuffer.compare(0, 6, "THETA=") == 0) { - check_Theta = true; - ConfigFile >> DataBuffer ; - Theta = atof(DataBuffer.c_str()) ; - Theta = Theta * deg; - G4cout << "Theta: " << Theta / deg << G4endl; - } - - else if (DataBuffer.compare(0, 4, "PHI=") == 0) { - check_Phi = true; - ConfigFile >> DataBuffer ; - Phi = atof(DataBuffer.c_str()) ; - Phi = Phi * deg; - G4cout << "Phi: " << Phi / deg << G4endl; - } - - else if (DataBuffer.compare(0, 2, "R=") == 0) { - check_R = true; - ConfigFile >> DataBuffer ; - R = atof(DataBuffer.c_str()) ; - R = R * mm; - G4cout << "R: " << R / mm << G4endl; - } - - else if (DataBuffer.compare(0, 5, "BETA=") == 0) { -// check_beta = true; - ConfigFile >> DataBuffer ; - beta_u = atof(DataBuffer.c_str()) ; - beta_u = beta_u * deg ; - ConfigFile >> DataBuffer ; - beta_v = atof(DataBuffer.c_str()) ; - beta_v = beta_v * deg ; - ConfigFile >> DataBuffer ; - beta_w = atof(DataBuffer.c_str()) ; - beta_w = beta_w * deg ; - G4cout << "Beta: " << beta_u / deg << " " << beta_v / deg << " " << beta_w / deg << G4endl ; - } - - else if (DataBuffer.compare(0, 11, "FIRSTSTAGE=") == 0) { - check_FirstStage = true ; - ConfigFile >> DataBuffer; - FIRSTSTAGE = atof(DataBuffer.c_str()) ; - } - - else if (DataBuffer.compare(0, 12, "SECONDSTAGE=") == 0) { - check_SecondStage = true ; - ConfigFile >> DataBuffer; - SECONDSTAGE = atof(DataBuffer.c_str()) ; - } - - else if (DataBuffer.compare(0, 11, "THIRDSTAGE=") == 0) { - check_ThirdStage = true ; - ConfigFile >> DataBuffer; - THIRDSTAGE = atof(DataBuffer.c_str()) ; - } - - else if (DataBuffer.compare(0, 12, "FOURTHSTAGE=") == 0) { - check_FourthStage = true ; - ConfigFile >> DataBuffer; - FOURTHSTAGE = atof(DataBuffer.c_str()) ; - } - - else if (DataBuffer.compare(0, 11, "FIFTHSTAGE=") == 0) { - check_FifthStage = true ; - ConfigFile >> DataBuffer; - FIFTHSTAGE = atof(DataBuffer.c_str()) ; - } - - else if (DataBuffer.compare(0, 11, "SIXTHSTAGE=") == 0) { - check_SixthStage = true ; - ConfigFile >> DataBuffer; - SIXTHSTAGE = atof(DataBuffer.c_str()) ; - } - - else if (DataBuffer.compare(0, 4, "VIS=") == 0) { - checkVis = true ; - ConfigFile >> DataBuffer; - if (DataBuffer.compare(0, 3, "all") == 0) m_non_sensitive_part_visiualisation = true; - } - - else G4cout << "WARNING: Wrong Token, Hyde2TrackerTrapezoid1: Trapezoid1 Element not added" << G4endl; - - //Add The previously define telescope - //With position method - if ((check_A && check_B && check_C && check_D && check_FirstStage && check_SecondStage && check_ThirdStage && check_FourthStage && check_FifthStage && check_SixthStage && checkVis) && !(check_Theta && check_Phi && check_R)) { - - ReadingStatus = false ; - check_A = false ; - check_C = false ; - check_B = false ; - check_D = false ; - check_FirstStage = false ; - check_SecondStage = false ; - check_ThirdStage = false ; - check_FourthStage = false ; - check_FifthStage = false ; - check_SixthStage = false ; - checkVis = false ; - - AddModule(A , - B , - C , - D , - FIRSTSTAGE == 1 , - SECONDSTAGE == 1 , - THIRDSTAGE == 1 , - FOURTHSTAGE == 1 , - FIFTHSTAGE == 1 , - SIXTHSTAGE == 1); - } - - //with angle method - if ((check_Theta && check_Phi && check_R && check_FirstStage && check_SecondStage && check_ThirdStage && check_FourthStage && check_FifthStage && check_SixthStage && checkVis) && !(check_A && check_B && check_C && check_D)) { - ReadingStatus = false ; - check_Theta = false ; - check_Phi = false ; - check_R = false ; -// check_beta = false ; - check_FirstStage = false ; - check_SecondStage = false ; - check_ThirdStage = false ; - check_FourthStage = false ; - check_FifthStage = false ; - check_SixthStage = false ; - checkVis = false ; - - AddModule(R , - Theta , - Phi , - beta_u , - beta_v , - beta_w , - FIRSTSTAGE == 1 , - SECONDSTAGE == 1 , - THIRDSTAGE == 1 , - FOURTHSTAGE == 1 , - FIFTHSTAGE == 1 , - SIXTHSTAGE == 1); - } - - +void Hyde2TrackerTrapezoid1::ReadConfiguration(string Path) { + ifstream ConfigFile; + ConfigFile.open(Path.c_str()); + string LineBuffer; + string DataBuffer; + + // A:X1_Y1 --> X:1 Y:1 + // B:X128_Y1 --> X:128 Y:1 + // C:X1_Y128 --> X:1 Y:128 + // D:X128_Y128 --> X:128 Y:128 + + G4double Ax, Bx, Cx, Dx, Ay, By, Cy, Dy, Az, Bz, Cz, Dz; + G4ThreeVector A, B, C, D; + G4double Theta = 0, Phi = 0, R = 0, beta_u = 0, beta_v = 0, beta_w = 0; + int FIRSTSTAGE = 0, SECONDSTAGE = 0, THIRDSTAGE = 0, FOURTHSTAGE = 0, FIFTHSTAGE = 0, SIXTHSTAGE = 0; + + bool ReadingStatus = false; + + bool check_A = false; + bool check_C = false; + bool check_B = false; + bool check_D = false; + + bool check_Theta = false; + bool check_Phi = false; + bool check_R = false; + // bool check_beta = false ; + + bool check_FirstStage = false; + bool check_SecondStage = false; + bool check_ThirdStage = false; + bool check_FourthStage = false; + bool check_FifthStage = false; + bool check_SixthStage = false; + bool checkVis = false; + + while (!ConfigFile.eof()) { + getline(ConfigFile, LineBuffer); + if (LineBuffer.compare(0, 14, "HYD2Trapezoid1") == 0) { + G4cout << "///" << G4endl; + G4cout << "Trapezoid1 element found: " << G4endl; + ReadingStatus = true; + } + + while (ReadingStatus) { + + ConfigFile >> DataBuffer; + // Comment Line + if (DataBuffer.compare(0, 1, "%") == 0) { /*do nothing */ + ; } - } -} -// Construct detector and inialise sensitive part. -// Called After DetecorConstruction::AddDetector Method -void Hyde2TrackerTrapezoid1::ConstructDetector(G4LogicalVolume* world) -{ - G4RotationMatrix* MMrot = NULL; - G4ThreeVector MMpos = G4ThreeVector(0, 0, 0); - G4ThreeVector MMu = G4ThreeVector(0, 0, 0); - G4ThreeVector MMv = G4ThreeVector(0, 0, 0); - G4ThreeVector MMw = G4ThreeVector(0, 0, 0); - G4ThreeVector MMCenter = G4ThreeVector(0, 0, 0); - - bool FirstStage = true ; - bool SecondStage = true ; - bool ThirdStage = true ; - bool FourthStage = true ; - bool FifthStage = true ; - bool SixthStage = true ; - - G4int NumberOfModule = m_DefinitionType.size() ; - - for (G4int i = 0; i < NumberOfModule; i++) { - // By Point - if (m_DefinitionType[i]) { - // (u,v,w) unitary vector associated to trapezoidal referencial - // (u,v) // to silicon plan - // ------- - // / \ ^ - // / \ | v - // / \ | - // --------------- <------ - // u - // w perpendicular to (u,v) plan and pointing ThirdStage - G4cout << "XXXXXXXXXXXX Trapezoid1 " << i << " XXXXXXXXXXXXX" << G4endl; - MMu = m_X128_Y1[i] - m_X1_Y1[i]; - MMu = MMu.unit(); - G4cout << "MMu: " << MMu << G4endl; - - MMv = 0.5 * (m_X1_Y128[i] + m_X128_Y128[i] - m_X1_Y1[i] - m_X128_Y1[i]); - MMv = MMv.unit(); - G4cout << "MMv: " << MMv << G4endl; - - MMw = MMu.cross(MMv); - MMw = MMw.unit(); - G4cout << "MMw: " << MMw << G4endl; - - // Center of the module - MMCenter = (m_X1_Y1[i] + m_X1_Y128[i] + m_X128_Y1[i] + m_X128_Y128[i]) / 4; - - // Passage Matrix from Lab Referential to Module Referential - MMrot = new G4RotationMatrix(MMu, MMv, MMw); - // translation to place Module - MMpos = MMw * Length * 0.5 + MMCenter; + // Position method + else if (DataBuffer.compare(0, 6, "X1_Y1=") == 0) { + check_A = true; + ConfigFile >> DataBuffer; + Ax = atof(DataBuffer.c_str()); + Ax = Ax * mm; + ConfigFile >> DataBuffer; + Ay = atof(DataBuffer.c_str()); + Ay = Ay * mm; + ConfigFile >> DataBuffer; + Az = atof(DataBuffer.c_str()); + Az = Az * mm; + + A = G4ThreeVector(Ax, Ay, Az); + G4cout << "X1 Y1 corner position : " << A << G4endl; } - // By Angle - else { - G4double Theta = m_Theta[i]; - G4double Phi = m_Phi[i]; - - // (u,v,w) unitary vector associated to telescope referencial - // (u,v) // to silicon plan - // ------- - // / \ ^ - // / \ | v - // / \ | - // --------------- <------ - // u - // w perpendicular to (u,v) plan and pointing ThirdStage - // Phi is angle between X axis and projection in (X,Y) plan - // Theta is angle between position vector and z axis - G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad); - G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad); - G4double wZ = m_R[i] * cos(Theta / rad); - MMw = G4ThreeVector(wX, wY, wZ); - - // vector corresponding to the center of the module - MMCenter = MMw; - - // vector parallel to one axis of silicon plane - // in fact, this is vector u - G4double ii = cos(Theta / rad) * cos(Phi / rad); - G4double jj = cos(Theta / rad) * sin(Phi / rad); - G4double kk = -sin(Theta / rad); - G4ThreeVector Y = G4ThreeVector(ii, jj, kk); - - MMw = MMw.unit(); - MMv = MMw.cross(Y); - MMu = MMv.cross(MMw); - MMv = MMv.unit(); - MMu = MMu.unit(); - - G4cout << "XXXXXXXXXXXX Trapezoid1 " << i << " XXXXXXXXXXXXX" << G4endl; - G4cout << "MMu: " << MMu << G4endl; - G4cout << "MMv: " << MMv << G4endl; - G4cout << "MMw: " << MMw << G4endl; - - // Passage Matrix from Lab Referential to Telescope Referential - MMrot = new G4RotationMatrix(MMu, MMv, MMw); - // Telescope is rotate of Beta angle around MMv axis. - MMrot->rotate(m_beta_u[i], MMu); - MMrot->rotate(m_beta_v[i], MMv); - MMrot->rotate(m_beta_w[i], MMw); - // translation to place Telescope - MMpos = MMw * Length * 0.5 + MMCenter; + else if (DataBuffer.compare(0, 8, "X128_Y1=") == 0) { + check_B = true; + ConfigFile >> DataBuffer; + Bx = atof(DataBuffer.c_str()); + Bx = Bx * mm; + ConfigFile >> DataBuffer; + By = atof(DataBuffer.c_str()); + By = By * mm; + ConfigFile >> DataBuffer; + Bz = atof(DataBuffer.c_str()); + Bz = Bz * mm; + + B = G4ThreeVector(Bx, By, Bz); + G4cout << "X128 Y1 corner position : " << B << G4endl; } - FirstStage = m_wFirstStage[i]; - SecondStage = m_wSecondStage[i]; - ThirdStage = m_wThirdStage[i]; - FourthStage = m_wFourthStage[i]; - FifthStage = m_wFifthStage[i]; - SixthStage = m_wSixthStage[i]; + else if (DataBuffer.compare(0, 8, "X1_Y128=") == 0) { + check_C = true; + ConfigFile >> DataBuffer; + Cx = atof(DataBuffer.c_str()); + Cx = Cx * mm; + ConfigFile >> DataBuffer; + Cy = atof(DataBuffer.c_str()); + Cy = Cy * mm; + ConfigFile >> DataBuffer; + Cz = atof(DataBuffer.c_str()); + Cz = Cz * mm; + + C = G4ThreeVector(Cx, Cy, Cz); + G4cout << "X1 Y128 corner position : " << C << G4endl; + } - VolumeMaker(i + 1, MMpos, MMrot, FirstStage, SecondStage, ThirdStage, FourthStage, FifthStage, SixthStage, world); - } + else if (DataBuffer.compare(0, 10, "X128_Y128=") == 0) { + check_D = true; + ConfigFile >> DataBuffer; + Dx = atof(DataBuffer.c_str()); + Dx = Dx * mm; + ConfigFile >> DataBuffer; + Dy = atof(DataBuffer.c_str()); + Dy = Dy * mm; + ConfigFile >> DataBuffer; + Dz = atof(DataBuffer.c_str()); + Dz = Dz * mm; + + D = G4ThreeVector(Dx, Dy, Dz); + G4cout << "X128 Y128 corner position : " << D << G4endl; + } - delete MMrot; -} + // Angle method + else if (DataBuffer.compare(0, 6, "THETA=") == 0) { + check_Theta = true; + ConfigFile >> DataBuffer; + Theta = atof(DataBuffer.c_str()); + Theta = Theta * deg; + G4cout << "Theta: " << Theta / deg << G4endl; + } + else if (DataBuffer.compare(0, 4, "PHI=") == 0) { + check_Phi = true; + ConfigFile >> DataBuffer; + Phi = atof(DataBuffer.c_str()); + Phi = Phi * deg; + G4cout << "Phi: " << Phi / deg << G4endl; + } + else if (DataBuffer.compare(0, 2, "R=") == 0) { + check_R = true; + ConfigFile >> DataBuffer; + R = atof(DataBuffer.c_str()); + R = R * mm; + G4cout << "R: " << R / mm << G4endl; + } -// Connect the Hyde2TrackingData class to the output TTree -// of the simulation -void Hyde2TrackerTrapezoid1::InitializeRootOutput() -{ -} + else if (DataBuffer.compare(0, 5, "BETA=") == 0) { + // check_beta = true; + ConfigFile >> DataBuffer; + beta_u = atof(DataBuffer.c_str()); + beta_u = beta_u * deg; + ConfigFile >> DataBuffer; + beta_v = atof(DataBuffer.c_str()); + beta_v = beta_v * deg; + ConfigFile >> DataBuffer; + beta_w = atof(DataBuffer.c_str()); + beta_w = beta_w * deg; + G4cout << "Beta: " << beta_u / deg << " " << beta_v / deg << " " << beta_w / deg << G4endl; + } + else if (DataBuffer.compare(0, 11, "FIRSTSTAGE=") == 0) { + check_FirstStage = true; + ConfigFile >> DataBuffer; + FIRSTSTAGE = atof(DataBuffer.c_str()); + } + else if (DataBuffer.compare(0, 12, "SECONDSTAGE=") == 0) { + check_SecondStage = true; + ConfigFile >> DataBuffer; + SECONDSTAGE = atof(DataBuffer.c_str()); + } -// Set the TinteractionCoordinates object from NPS::VDetector to the present class -void Hyde2TrackerTrapezoid1::SetInterCoordPointer(TInteractionCoordinates* interCoord) -{ - ms_InterCoord = interCoord; + else if (DataBuffer.compare(0, 11, "THIRDSTAGE=") == 0) { + check_ThirdStage = true; + ConfigFile >> DataBuffer; + THIRDSTAGE = atof(DataBuffer.c_str()); + } + + else if (DataBuffer.compare(0, 12, "FOURTHSTAGE=") == 0) { + check_FourthStage = true; + ConfigFile >> DataBuffer; + FOURTHSTAGE = atof(DataBuffer.c_str()); + } + + else if (DataBuffer.compare(0, 11, "FIFTHSTAGE=") == 0) { + check_FifthStage = true; + ConfigFile >> DataBuffer; + FIFTHSTAGE = atof(DataBuffer.c_str()); + } + + else if (DataBuffer.compare(0, 11, "SIXTHSTAGE=") == 0) { + check_SixthStage = true; + ConfigFile >> DataBuffer; + SIXTHSTAGE = atof(DataBuffer.c_str()); + } + + else if (DataBuffer.compare(0, 4, "VIS=") == 0) { + checkVis = true; + ConfigFile >> DataBuffer; + if (DataBuffer.compare(0, 3, "all") == 0) + m_non_sensitive_part_visiualisation = true; + } + + else + G4cout << "WARNING: Wrong Token, Hyde2TrackerTrapezoid1: Trapezoid1 Element not added" << G4endl; + + // Add The previously define telescope + // With position method + if ((check_A && check_B && check_C && check_D && check_FirstStage && check_SecondStage && check_ThirdStage && + check_FourthStage && check_FifthStage && check_SixthStage && checkVis) && + !(check_Theta && check_Phi && check_R)) { + + ReadingStatus = false; + check_A = false; + check_C = false; + check_B = false; + check_D = false; + check_FirstStage = false; + check_SecondStage = false; + check_ThirdStage = false; + check_FourthStage = false; + check_FifthStage = false; + check_SixthStage = false; + checkVis = false; + + AddModule(A, B, C, D, FIRSTSTAGE == 1, SECONDSTAGE == 1, THIRDSTAGE == 1, FOURTHSTAGE == 1, FIFTHSTAGE == 1, + SIXTHSTAGE == 1); + } + + // with angle method + if ((check_Theta && check_Phi && check_R && check_FirstStage && check_SecondStage && check_ThirdStage && + check_FourthStage && check_FifthStage && check_SixthStage && checkVis) && + !(check_A && check_B && check_C && check_D)) { + ReadingStatus = false; + check_Theta = false; + check_Phi = false; + check_R = false; + // check_beta = false ; + check_FirstStage = false; + check_SecondStage = false; + check_ThirdStage = false; + check_FourthStage = false; + check_FifthStage = false; + check_SixthStage = false; + checkVis = false; + + AddModule(R, Theta, Phi, beta_u, beta_v, beta_w, FIRSTSTAGE == 1, SECONDSTAGE == 1, THIRDSTAGE == 1, + FOURTHSTAGE == 1, FIFTHSTAGE == 1, SIXTHSTAGE == 1); + } + } + } } +// Construct detector and inialise sensitive part. +// Called After DetecorConstruction::AddDetector Method +void Hyde2TrackerTrapezoid1::ConstructDetector(G4LogicalVolume* world) { + G4RotationMatrix* MMrot = NULL; + G4ThreeVector MMpos = G4ThreeVector(0, 0, 0); + G4ThreeVector MMu = G4ThreeVector(0, 0, 0); + G4ThreeVector MMv = G4ThreeVector(0, 0, 0); + G4ThreeVector MMw = G4ThreeVector(0, 0, 0); + G4ThreeVector MMCenter = G4ThreeVector(0, 0, 0); + + bool FirstStage = true; + bool SecondStage = true; + bool ThirdStage = true; + bool FourthStage = true; + bool FifthStage = true; + bool SixthStage = true; + + G4int NumberOfModule = m_DefinitionType.size(); + + for (G4int i = 0; i < NumberOfModule; i++) { + // By Point + if (m_DefinitionType[i]) { + // (u,v,w) unitary vector associated to trapezoidal referencial + // (u,v) // to silicon plan + // ------- + // / \ ^ + // / \ | v + // / \ | + // --------------- <------ + // u + // w perpendicular to (u,v) plan and pointing ThirdStage + G4cout << "XXXXXXXXXXXX Trapezoid1 " << i << " XXXXXXXXXXXXX" << G4endl; + MMu = m_X128_Y1[i] - m_X1_Y1[i]; + MMu = MMu.unit(); + G4cout << "MMu: " << MMu << G4endl; + + MMv = 0.5 * (m_X1_Y128[i] + m_X128_Y128[i] - m_X1_Y1[i] - m_X128_Y1[i]); + MMv = MMv.unit(); + G4cout << "MMv: " << MMv << G4endl; + + MMw = MMu.cross(MMv); + MMw = MMw.unit(); + G4cout << "MMw: " << MMw << G4endl; + + // Center of the module + MMCenter = (m_X1_Y1[i] + m_X1_Y128[i] + m_X128_Y1[i] + m_X128_Y128[i]) / 4; + + // Passage Matrix from Lab Referential to Module Referential + MMrot = new G4RotationMatrix(MMu, MMv, MMw); + // translation to place Module + MMpos = MMw * Length * 0.5 + MMCenter; + } + + // By Angle + else { + G4double Theta = m_Theta[i]; + G4double Phi = m_Phi[i]; + + // (u,v,w) unitary vector associated to telescope referencial + // (u,v) // to silicon plan + // ------- + // / \ ^ + // / \ | v + // / \ | + // --------------- <------ + // u + // w perpendicular to (u,v) plan and pointing ThirdStage + // Phi is angle between X axis and projection in (X,Y) plan + // Theta is angle between position vector and z axis + G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad); + G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad); + G4double wZ = m_R[i] * cos(Theta / rad); + MMw = G4ThreeVector(wX, wY, wZ); + + // vector corresponding to the center of the module + MMCenter = MMw; + + // vector parallel to one axis of silicon plane + // in fact, this is vector u + G4double ii = cos(Theta / rad) * cos(Phi / rad); + G4double jj = cos(Theta / rad) * sin(Phi / rad); + G4double kk = -sin(Theta / rad); + G4ThreeVector Y = G4ThreeVector(ii, jj, kk); + + MMw = MMw.unit(); + MMv = MMw.cross(Y); + MMu = MMv.cross(MMw); + MMv = MMv.unit(); + MMu = MMu.unit(); + + G4cout << "XXXXXXXXXXXX Trapezoid1 " << i << " XXXXXXXXXXXXX" << G4endl; + G4cout << "MMu: " << MMu << G4endl; + G4cout << "MMv: " << MMv << G4endl; + G4cout << "MMw: " << MMw << G4endl; + + // Passage Matrix from Lab Referential to Telescope Referential + MMrot = new G4RotationMatrix(MMu, MMv, MMw); + // Telescope is rotate of Beta angle around MMv axis. + MMrot->rotate(m_beta_u[i], MMu); + MMrot->rotate(m_beta_v[i], MMv); + MMrot->rotate(m_beta_w[i], MMw); + // translation to place Telescope + MMpos = MMw * Length * 0.5 + MMCenter; + } + + FirstStage = m_wFirstStage[i]; + SecondStage = m_wSecondStage[i]; + ThirdStage = m_wThirdStage[i]; + FourthStage = m_wFourthStage[i]; + FifthStage = m_wFifthStage[i]; + SixthStage = m_wSixthStage[i]; + + VolumeMaker(i + 1, MMpos, MMrot, FirstStage, SecondStage, ThirdStage, FourthStage, FifthStage, SixthStage, world); + } + + delete MMrot; +} +// Connect the Hyde2TrackingData class to the output TTree +// of the simulation +void Hyde2TrackerTrapezoid1::InitializeRootOutput() {} + +// Set the TinteractionCoordinates object from NPS::VDetector to the present class +void Hyde2TrackerTrapezoid1::SetInterCoordPointer(TInteractionCoordinates* interCoord) { ms_InterCoord = interCoord; } // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Hyde2TrackerTrapezoid1::ReadSensitive(const G4Event* event) -{ -////////////////////////////////////////////////////////////////////////////////////// -//////////////////////// Used to Read Event Map of detector ////////////////////////// -////////////////////////////////////////////////////////////////////////////////////// - // First Stage - std::map<G4int, G4int*>::iterator DetectorNumber_itr; - std::map<G4int, G4double*>::iterator Energy_itr; - std::map<G4int, G4double*>::iterator Time_itr; - std::map<G4int, G4double*>::iterator X_itr; - std::map<G4int, G4double*>::iterator Y_itr; - std::map<G4int, G4double*>::iterator Pos_X_itr; - std::map<G4int, G4double*>::iterator Pos_Y_itr; - std::map<G4int, G4double*>::iterator Pos_Z_itr; - std::map<G4int, G4double*>::iterator Ang_Theta_itr; - std::map<G4int, G4double*>::iterator Ang_Phi_itr; - - G4THitsMap<G4int>* DetectorNumberHitMap; - G4THitsMap<G4double>* EnergyHitMap; - G4THitsMap<G4double>* TimeHitMap; - G4THitsMap<G4double>* XHitMap; - G4THitsMap<G4double>* YHitMap; - G4THitsMap<G4double>* PosXHitMap; - G4THitsMap<G4double>* PosYHitMap; - G4THitsMap<G4double>* PosZHitMap; - G4THitsMap<G4double>* AngThetaHitMap; - G4THitsMap<G4double>* AngPhiHitMap; - - // NULL pointer are given to avoid warning at compilation - // Second Stage - std::map<G4int, G4double*>::iterator SecondStageEnergy_itr; - G4THitsMap<G4double>* SecondStageEnergyHitMap = NULL; - // Third Stage - std::map<G4int, G4double*>::iterator ThirdStageEnergy_itr; - G4THitsMap<G4double>* ThirdStageEnergyHitMap = NULL; - - // Fourth Stage - std::map<G4int, G4double*>::iterator FourthStageEnergy_itr; - G4THitsMap<G4double>* FourthStageEnergyHitMap = NULL; - - // Fifth Stage - std::map<G4int, G4double*>::iterator FifthStageEnergy_itr; - G4THitsMap<G4double>* FifthStageEnergyHitMap = NULL; - - // Sixth Stage - std::map<G4int, G4double*>::iterator SixthStageEnergy_itr; - G4THitsMap<G4double>* SixthStageEnergyHitMap = NULL; - - // Read the Scorer associated to the first Stage - //Detector Number - G4int StripDetCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/DetectorNumber") ; - DetectorNumberHitMap = (G4THitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripDetCollectionID)) ; - DetectorNumber_itr = DetectorNumberHitMap->GetMap()->begin() ; - - //Energy - G4int StripEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/StripEnergy") ; - EnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripEnergyCollectionID)) ; - Energy_itr = EnergyHitMap->GetMap()->begin() ; - - //Time of Flight - G4int StripTimeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/StripTime") ; - TimeHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripTimeCollectionID)) ; - Time_itr = TimeHitMap->GetMap()->begin() ; - - //Strip Number X - G4int StripXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/StripNumberX") ; - XHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripXCollectionID)) ; - X_itr = XHitMap->GetMap()->begin() ; - - //Strip Number Y - G4int StripYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/StripNumberY") ; - YHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripYCollectionID)) ; - Y_itr = YHitMap->GetMap()->begin() ; - - //Interaction Coordinate X - G4int InterCoordXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/InterCoordX") ; - PosXHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordXCollectionID)) ; - Pos_X_itr = PosXHitMap->GetMap()->begin() ; - - //Interaction Coordinate Y - G4int InterCoordYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/InterCoordY") ; - PosYHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordYCollectionID)) ; - Pos_Y_itr = PosYHitMap->GetMap()->begin() ; - - //Interaction Coordinate Z - G4int InterCoordZCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/InterCoordZ") ; - PosZHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordZCollectionID)) ; - Pos_Z_itr = PosXHitMap->GetMap()->begin() ; - - //Interaction Coordinate Angle Theta - G4int InterCoordAngThetaCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/InterCoordAngTheta") ; - AngThetaHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngThetaCollectionID)) ; - Ang_Theta_itr = AngThetaHitMap->GetMap()->begin() ; - - //Interaction Coordinate Angle Phi - G4int InterCoordAngPhiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/InterCoordAngPhi") ; - AngPhiHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngPhiCollectionID)) ; - Ang_Phi_itr = AngPhiHitMap->GetMap()->begin() ; - - // Read the Scorer associated to the Second and Third Stage - // Energy second stage - G4int SecondStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("SecondStageScorerHYD2Trapezoid1/SecondStageEnergy") ; - SecondStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(SecondStageEnergyCollectionID)) ; - SecondStageEnergy_itr = SecondStageEnergyHitMap->GetMap()->begin() ; - // Energy third stage - G4int ThirdStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ThirdStageScorerHYD2Trapezoid1/ThirdStageEnergy") ; - ThirdStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(ThirdStageEnergyCollectionID)) ; - ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin() ; - // Energy Fourth stage - G4int FourthStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FourthStageScorerHYD2Trapezoid1/FourthStageEnergy") ; - FourthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(FourthStageEnergyCollectionID)) ; - FourthStageEnergy_itr = FourthStageEnergyHitMap->GetMap()->begin() ; - // Energy Fifth stage - G4int FifthStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FifthStageScorerHYD2Trapezoid1/FifthStageEnergy") ; - FifthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(FifthStageEnergyCollectionID)) ; - FifthStageEnergy_itr = FifthStageEnergyHitMap->GetMap()->begin() ; - // Energy Sixth stage - G4int SixthStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("SixthStageScorerHYD2Trapezoid1/SixthStageEnergy") ; - SixthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(SixthStageEnergyCollectionID)) ; - SixthStageEnergy_itr = SixthStageEnergyHitMap->GetMap()->begin() ; - - // Check the size of different map - G4int sizeN = DetectorNumberHitMap->entries(); - G4int sizeE = EnergyHitMap->entries(); - G4int sizeT = TimeHitMap->entries(); - G4int sizeX = XHitMap->entries(); - G4int sizeY = YHitMap->entries(); - - if (sizeE != sizeT || sizeT != sizeX || sizeX != sizeY) { - G4cout << "No match size Si Event Map: sE:" - << sizeE << " sT:" << sizeT << " sX:" << sizeX << " sY:" << sizeY << G4endl ; - return; +void Hyde2TrackerTrapezoid1::ReadSensitive(const G4Event* event) { + ////////////////////////////////////////////////////////////////////////////////////// + //////////////////////// Used to Read Event Map of detector ////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + // First Stage + std::map<G4int, G4int*>::iterator DetectorNumber_itr; + std::map<G4int, G4double*>::iterator Energy_itr; + std::map<G4int, G4double*>::iterator Time_itr; + std::map<G4int, G4double*>::iterator X_itr; + std::map<G4int, G4double*>::iterator Y_itr; + std::map<G4int, G4double*>::iterator Pos_X_itr; + std::map<G4int, G4double*>::iterator Pos_Y_itr; + std::map<G4int, G4double*>::iterator Pos_Z_itr; + std::map<G4int, G4double*>::iterator Ang_Theta_itr; + std::map<G4int, G4double*>::iterator Ang_Phi_itr; + + G4THitsMap<G4int>* DetectorNumberHitMap; + G4THitsMap<G4double>* EnergyHitMap; + G4THitsMap<G4double>* TimeHitMap; + G4THitsMap<G4double>* XHitMap; + G4THitsMap<G4double>* YHitMap; + G4THitsMap<G4double>* PosXHitMap; + G4THitsMap<G4double>* PosYHitMap; + G4THitsMap<G4double>* PosZHitMap; + G4THitsMap<G4double>* AngThetaHitMap; + G4THitsMap<G4double>* AngPhiHitMap; + + // NULL pointer are given to avoid warning at compilation + // Second Stage + std::map<G4int, G4double*>::iterator SecondStageEnergy_itr; + G4THitsMap<G4double>* SecondStageEnergyHitMap = NULL; + // Third Stage + std::map<G4int, G4double*>::iterator ThirdStageEnergy_itr; + G4THitsMap<G4double>* ThirdStageEnergyHitMap = NULL; + + // Fourth Stage + std::map<G4int, G4double*>::iterator FourthStageEnergy_itr; + G4THitsMap<G4double>* FourthStageEnergyHitMap = NULL; + + // Fifth Stage + std::map<G4int, G4double*>::iterator FifthStageEnergy_itr; + G4THitsMap<G4double>* FifthStageEnergyHitMap = NULL; + + // Sixth Stage + std::map<G4int, G4double*>::iterator SixthStageEnergy_itr; + G4THitsMap<G4double>* SixthStageEnergyHitMap = NULL; + + // Read the Scorer associated to the first Stage + // Detector Number + G4int StripDetCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/DetectorNumber"); + DetectorNumberHitMap = (G4THitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripDetCollectionID)); + DetectorNumber_itr = DetectorNumberHitMap->GetMap()->begin(); + + // Energy + G4int StripEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/StripEnergy"); + EnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripEnergyCollectionID)); + Energy_itr = EnergyHitMap->GetMap()->begin(); + + // Time of Flight + G4int StripTimeCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/StripTime"); + TimeHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripTimeCollectionID)); + Time_itr = TimeHitMap->GetMap()->begin(); + + // Strip Number X + G4int StripXCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/StripNumberX"); + XHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripXCollectionID)); + X_itr = XHitMap->GetMap()->begin(); + + // Strip Number Y + G4int StripYCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/StripNumberY"); + YHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripYCollectionID)); + Y_itr = YHitMap->GetMap()->begin(); + + // Interaction Coordinate X + G4int InterCoordXCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/InterCoordX"); + PosXHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordXCollectionID)); + Pos_X_itr = PosXHitMap->GetMap()->begin(); + + // Interaction Coordinate Y + G4int InterCoordYCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/InterCoordY"); + PosYHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordYCollectionID)); + Pos_Y_itr = PosYHitMap->GetMap()->begin(); + + // Interaction Coordinate Z + G4int InterCoordZCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/InterCoordZ"); + PosZHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordZCollectionID)); + Pos_Z_itr = PosXHitMap->GetMap()->begin(); + + // Interaction Coordinate Angle Theta + G4int InterCoordAngThetaCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/InterCoordAngTheta"); + AngThetaHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngThetaCollectionID)); + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); + + // Interaction Coordinate Angle Phi + G4int InterCoordAngPhiCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/InterCoordAngPhi"); + AngPhiHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngPhiCollectionID)); + Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); + + // Read the Scorer associated to the Second and Third Stage + // Energy second stage + G4int SecondStageEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("SecondStageScorerHYD2Trapezoid1/SecondStageEnergy"); + SecondStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(SecondStageEnergyCollectionID)); + SecondStageEnergy_itr = SecondStageEnergyHitMap->GetMap()->begin(); + // Energy third stage + G4int ThirdStageEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("ThirdStageScorerHYD2Trapezoid1/ThirdStageEnergy"); + ThirdStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(ThirdStageEnergyCollectionID)); + ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin(); + // Energy Fourth stage + G4int FourthStageEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FourthStageScorerHYD2Trapezoid1/FourthStageEnergy"); + FourthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(FourthStageEnergyCollectionID)); + FourthStageEnergy_itr = FourthStageEnergyHitMap->GetMap()->begin(); + // Energy Fifth stage + G4int FifthStageEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FifthStageScorerHYD2Trapezoid1/FifthStageEnergy"); + FifthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(FifthStageEnergyCollectionID)); + FifthStageEnergy_itr = FifthStageEnergyHitMap->GetMap()->begin(); + // Energy Sixth stage + G4int SixthStageEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("SixthStageScorerHYD2Trapezoid1/SixthStageEnergy"); + SixthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(SixthStageEnergyCollectionID)); + SixthStageEnergy_itr = SixthStageEnergyHitMap->GetMap()->begin(); + + // Check the size of different map + G4int sizeN = DetectorNumberHitMap->entries(); + G4int sizeE = EnergyHitMap->entries(); + G4int sizeT = TimeHitMap->entries(); + G4int sizeX = XHitMap->entries(); + G4int sizeY = YHitMap->entries(); + + if (sizeE != sizeT || sizeT != sizeX || sizeX != sizeY) { + G4cout << "No match size Si Event Map: sE:" << sizeE << " sT:" << sizeT << " sX:" << sizeX << " sY:" << sizeY + << G4endl; + return; + } + + // Loop on FirstStage number + for (G4int l = 0; l < sizeN; l++) { + G4double N = *(DetectorNumber_itr->second); + G4int NTrackID = DetectorNumber_itr->first - N; + + if (N > 0) { + // Fill detector number + ms_Event->SetHYD2TrkFirstStageFrontEDetectorNbr(m_index["Trapezoid1"] + N); + ms_Event->SetHYD2TrkFirstStageFrontTDetectorNbr(m_index["Trapezoid1"] + N); + ms_Event->SetHYD2TrkFirstStageBackEDetectorNbr(m_index["Trapezoid1"] + N); + ms_Event->SetHYD2TrkFirstStageBackTDetectorNbr(m_index["Trapezoid1"] + N); + + // Energy + for (G4int ll = 0; ll < sizeE; ll++) { + G4int ETrackID = Energy_itr->first - N; + G4double E = *(Energy_itr->second); + if (ETrackID == NTrackID) { + ms_Event->SetHYD2TrkFirstStageFrontEEnergy(RandGauss::shoot(E, ResoFirstStage)); + ms_Event->SetHYD2TrkFirstStageBackEEnergy(RandGauss::shoot(E, ResoFirstStage)); + } + Energy_itr++; } - // Loop on FirstStage number - for (G4int l = 0; l < sizeN; l++) { - G4double N = *(DetectorNumber_itr->second); - G4int NTrackID = DetectorNumber_itr->first - N; - - if (N > 0) { - // Fill detector number - ms_Event->SetHYD2TrkFirstStageFrontEDetectorNbr(m_index["Trapezoid1"] + N); - ms_Event->SetHYD2TrkFirstStageFrontTDetectorNbr(m_index["Trapezoid1"] + N); - ms_Event->SetHYD2TrkFirstStageBackEDetectorNbr(m_index["Trapezoid1"] + N); - ms_Event->SetHYD2TrkFirstStageBackTDetectorNbr(m_index["Trapezoid1"] + N); - - // Energy - for (G4int ll = 0 ; ll < sizeE ; ll++) { - G4int ETrackID = Energy_itr->first - N; - G4double E = *(Energy_itr->second); - if (ETrackID == NTrackID) { - ms_Event->SetHYD2TrkFirstStageFrontEEnergy(RandGauss::shoot(E, ResoFirstStage)); - ms_Event->SetHYD2TrkFirstStageBackEEnergy(RandGauss::shoot(E, ResoFirstStage)); - } - Energy_itr++; - } - - // Time - Time_itr = TimeHitMap->GetMap()->begin(); - for (G4int h = 0 ; h < sizeT ; h++) { - G4int TTrackID = Time_itr->first - N; - G4double T = *(Time_itr->second); - - if (TTrackID == NTrackID) { - T = RandGauss::shoot(T, ResoTimePPAC) ; - ms_Event->SetHYD2TrkFirstStageFrontTTime(RandGauss::shoot(T, ResoTimeHyd2)) ; - ms_Event->SetHYD2TrkFirstStageBackTTime(RandGauss::shoot(T, ResoTimeHyd2)) ; - } - Time_itr++; - } - - // X - X_itr = XHitMap->GetMap()->begin(); - for (G4int h = 0 ; h < sizeX ; h++) { - G4int XTrackID = X_itr->first - N; - G4double X = *(X_itr->second); - if (XTrackID == NTrackID) { - ms_Event->SetHYD2TrkFirstStageFrontEStripNbr(X); - ms_Event->SetHYD2TrkFirstStageFrontTStripNbr(X); - } - - X_itr++; - } - - // Y - Y_itr = YHitMap->GetMap()->begin() ; - for (G4int h = 0 ; h < sizeY ; h++) { - G4int YTrackID = Y_itr->first - N; - G4double Y = *(Y_itr->second); - if (YTrackID == NTrackID) { - ms_Event->SetHYD2TrkFirstStageBackEStripNbr(Y); - ms_Event->SetHYD2TrkFirstStageBackTStripNbr(Y); - } - - Y_itr++; - } - - // Pos X - Pos_X_itr = PosXHitMap->GetMap()->begin(); - for (unsigned int h = 0; h < PosXHitMap->entries(); h++) { - G4int PosXTrackID = Pos_X_itr->first - N ; - G4double PosX = *(Pos_X_itr->second) ; - if (PosXTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionX(PosX) ; - } - Pos_X_itr++; - } - - // Pos Y - Pos_Y_itr = PosYHitMap->GetMap()->begin(); - for (unsigned int h = 0; h < PosYHitMap->entries(); h++) { - G4int PosYTrackID = Pos_Y_itr->first - N ; - G4double PosY = *(Pos_Y_itr->second) ; - if (PosYTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionY(PosY) ; - } - Pos_Y_itr++; - } - - // Pos Z - Pos_Z_itr = PosZHitMap->GetMap()->begin(); - for (unsigned int h = 0; h < PosZHitMap->entries(); h++) { - G4int PosZTrackID = Pos_Z_itr->first - N ; - G4double PosZ = *(Pos_Z_itr->second) ; - if (PosZTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionZ(PosZ) ; - } - Pos_Z_itr++; - } - - // Angle Theta - Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); - for (unsigned int h = 0; h < AngThetaHitMap->entries(); h++) { - G4int AngThetaTrackID = Ang_Theta_itr->first - N ; - G4double AngTheta = *(Ang_Theta_itr->second) ; - if (AngThetaTrackID == NTrackID) { - ms_InterCoord->SetDetectedAngleTheta(AngTheta) ; - } - Ang_Theta_itr++; - } - - // Angle Phi - Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); - for (unsigned int h = 0; h < AngPhiHitMap->entries(); h++) { - G4int AngPhiTrackID = Ang_Phi_itr->first - N ; - G4double AngPhi = *(Ang_Phi_itr->second) ; - if (AngPhiTrackID == NTrackID) { - ms_InterCoord->SetDetectedAnglePhi(AngPhi) ; - } - Ang_Phi_itr++; - } - - // Second Stage - SecondStageEnergy_itr = SecondStageEnergyHitMap->GetMap()->begin() ; - for (unsigned int h = 0 ; h < SecondStageEnergyHitMap->entries() ; h++) { - G4int SecondStageEnergyTrackID = SecondStageEnergy_itr->first - N; - G4double SecondStageEnergy = *(SecondStageEnergy_itr->second); - - if (SecondStageEnergyTrackID == NTrackID) { - ms_Event->SetHYD2TrkSecondStageEEnergy(RandGauss::shoot(SecondStageEnergy, ResoSecondStage)); - ms_Event->SetHYD2TrkSecondStageEPadNbr(1); - ms_Event->SetHYD2TrkSecondStageTPadNbr(1); - ms_Event->SetHYD2TrkSecondStageTTime(1); - ms_Event->SetHYD2TrkSecondStageTDetectorNbr(m_index["Trapezoid1"] + N); - ms_Event->SetHYD2TrkSecondStageEDetectorNbr(m_index["Trapezoid1"] + N); - } - - SecondStageEnergy_itr++; - } - - // Third Stage - ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin() ; - for (unsigned int h = 0 ; h < ThirdStageEnergyHitMap->entries() ; h++) { - G4int ThirdStageEnergyTrackID = ThirdStageEnergy_itr->first - N; - G4double ThirdStageEnergy = *(ThirdStageEnergy_itr->second); - - if (ThirdStageEnergyTrackID == NTrackID) { - ms_Event->SetHYD2TrkThirdStageEEnergy(RandGauss::shoot(ThirdStageEnergy, ResoThirdStage)); - ms_Event->SetHYD2TrkThirdStageEPadNbr(1); - ms_Event->SetHYD2TrkThirdStageTPadNbr(1); - ms_Event->SetHYD2TrkThirdStageTTime(1); - ms_Event->SetHYD2TrkThirdStageTDetectorNbr(m_index["Trapezoid1"] + N); - ms_Event->SetHYD2TrkThirdStageEDetectorNbr(m_index["Trapezoid1"] + N); - } - - ThirdStageEnergy_itr++; - } - - // Fourth Stage - FourthStageEnergy_itr = FourthStageEnergyHitMap->GetMap()->begin() ; - for (unsigned int h = 0 ; h < FourthStageEnergyHitMap->entries() ; h++) { - G4int FourthStageEnergyTrackID = FourthStageEnergy_itr->first - N; - G4double FourthStageEnergy = *(FourthStageEnergy_itr->second); - - if (FourthStageEnergyTrackID == NTrackID) { - ms_Event->SetHYD2TrkFourthStageEEnergy(RandGauss::shoot(FourthStageEnergy, ResoFourthStage)); - ms_Event->SetHYD2TrkFourthStageEPadNbr(1); - ms_Event->SetHYD2TrkFourthStageTPadNbr(1); - ms_Event->SetHYD2TrkFourthStageTTime(1); - ms_Event->SetHYD2TrkFourthStageTDetectorNbr(m_index["Trapezoid1"] + N); - ms_Event->SetHYD2TrkFourthStageEDetectorNbr(m_index["Trapezoid1"] + N); - } - - FourthStageEnergy_itr++; - } - - // Fifth Stage - FifthStageEnergy_itr = FifthStageEnergyHitMap->GetMap()->begin() ; - for (unsigned int h = 0 ; h < FifthStageEnergyHitMap->entries() ; h++) { - G4int FifthStageEnergyTrackID = FifthStageEnergy_itr->first - N; - G4double FifthStageEnergy = *(FifthStageEnergy_itr->second); - - if (FifthStageEnergyTrackID == NTrackID) { - ms_Event->SetHYD2TrkFifthStageEEnergy(RandGauss::shoot(FifthStageEnergy, ResoFifthStage)); - ms_Event->SetHYD2TrkFifthStageEPadNbr(1); - ms_Event->SetHYD2TrkFifthStageTPadNbr(1); - ms_Event->SetHYD2TrkFifthStageTTime(1); - ms_Event->SetHYD2TrkFifthStageTDetectorNbr(m_index["Trapezoid1"] + N); - ms_Event->SetHYD2TrkFifthStageEDetectorNbr(m_index["Trapezoid1"] + N); - } - - FifthStageEnergy_itr++; - } - - // Sixth Stage - SixthStageEnergy_itr = SixthStageEnergyHitMap->GetMap()->begin() ; - for (unsigned int h = 0 ; h < SixthStageEnergyHitMap->entries() ; h++) { - G4int SixthStageEnergyTrackID = SixthStageEnergy_itr->first - N; - G4double SixthStageEnergy = *(SixthStageEnergy_itr->second); - - if (SixthStageEnergyTrackID == NTrackID) { - ms_Event->SetHYD2TrkSixthStageEEnergy(RandGauss::shoot(SixthStageEnergy, ResoSixthStage)); - ms_Event->SetHYD2TrkSixthStageEPadNbr(1); - ms_Event->SetHYD2TrkSixthStageTPadNbr(1); - ms_Event->SetHYD2TrkSixthStageTTime(1); - ms_Event->SetHYD2TrkSixthStageTDetectorNbr(m_index["Trapezoid1"] + N); - ms_Event->SetHYD2TrkSixthStageEDetectorNbr(m_index["Trapezoid1"] + N); - } - - SixthStageEnergy_itr++; - } - - DetectorNumber_itr++; + // Time + Time_itr = TimeHitMap->GetMap()->begin(); + for (G4int h = 0; h < sizeT; h++) { + G4int TTrackID = Time_itr->first - N; + G4double T = *(Time_itr->second); + + if (TTrackID == NTrackID) { + T = RandGauss::shoot(T, ResoTimePPAC); + ms_Event->SetHYD2TrkFirstStageFrontTTime(RandGauss::shoot(T, ResoTimeHyd2)); + ms_Event->SetHYD2TrkFirstStageBackTTime(RandGauss::shoot(T, ResoTimeHyd2)); + } + Time_itr++; } - // clear map for next event - DetectorNumberHitMap ->clear(); - EnergyHitMap ->clear(); - TimeHitMap ->clear(); - XHitMap ->clear(); - YHitMap ->clear(); - PosXHitMap ->clear(); - PosYHitMap ->clear(); - PosZHitMap ->clear(); - AngThetaHitMap ->clear(); - AngPhiHitMap ->clear(); - SecondStageEnergyHitMap ->clear(); - ThirdStageEnergyHitMap ->clear(); - FourthStageEnergyHitMap ->clear(); - FifthStageEnergyHitMap ->clear(); - SixthStageEnergyHitMap ->clear(); - } -} + // X + X_itr = XHitMap->GetMap()->begin(); + for (G4int h = 0; h < sizeX; h++) { + G4int XTrackID = X_itr->first - N; + G4double X = *(X_itr->second); + if (XTrackID == NTrackID) { + ms_Event->SetHYD2TrkFirstStageFrontEStripNbr(X); + ms_Event->SetHYD2TrkFirstStageFrontTStripNbr(X); + } + + X_itr++; + } + // Y + Y_itr = YHitMap->GetMap()->begin(); + for (G4int h = 0; h < sizeY; h++) { + G4int YTrackID = Y_itr->first - N; + G4double Y = *(Y_itr->second); + if (YTrackID == NTrackID) { + ms_Event->SetHYD2TrkFirstStageBackEStripNbr(Y); + ms_Event->SetHYD2TrkFirstStageBackTStripNbr(Y); + } + + Y_itr++; + } + + // Pos X + Pos_X_itr = PosXHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < PosXHitMap->entries(); h++) { + G4int PosXTrackID = Pos_X_itr->first - N; + G4double PosX = *(Pos_X_itr->second); + if (PosXTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionX(PosX); + } + Pos_X_itr++; + } + + // Pos Y + Pos_Y_itr = PosYHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < PosYHitMap->entries(); h++) { + G4int PosYTrackID = Pos_Y_itr->first - N; + G4double PosY = *(Pos_Y_itr->second); + if (PosYTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionY(PosY); + } + Pos_Y_itr++; + } + + // Pos Z + Pos_Z_itr = PosZHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < PosZHitMap->entries(); h++) { + G4int PosZTrackID = Pos_Z_itr->first - N; + G4double PosZ = *(Pos_Z_itr->second); + if (PosZTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionZ(PosZ); + } + Pos_Z_itr++; + } + + // Angle Theta + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < AngThetaHitMap->entries(); h++) { + G4int AngThetaTrackID = Ang_Theta_itr->first - N; + G4double AngTheta = *(Ang_Theta_itr->second); + if (AngThetaTrackID == NTrackID) { + ms_InterCoord->SetDetectedAngleTheta(AngTheta); + } + Ang_Theta_itr++; + } + + // Angle Phi + Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < AngPhiHitMap->entries(); h++) { + G4int AngPhiTrackID = Ang_Phi_itr->first - N; + G4double AngPhi = *(Ang_Phi_itr->second); + if (AngPhiTrackID == NTrackID) { + ms_InterCoord->SetDetectedAnglePhi(AngPhi); + } + Ang_Phi_itr++; + } + // Second Stage + SecondStageEnergy_itr = SecondStageEnergyHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < SecondStageEnergyHitMap->entries(); h++) { + G4int SecondStageEnergyTrackID = SecondStageEnergy_itr->first - N; + G4double SecondStageEnergy = *(SecondStageEnergy_itr->second); + + if (SecondStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkSecondStageEEnergy(RandGauss::shoot(SecondStageEnergy, ResoSecondStage)); + ms_Event->SetHYD2TrkSecondStageEPadNbr(1); + ms_Event->SetHYD2TrkSecondStageTPadNbr(1); + ms_Event->SetHYD2TrkSecondStageTTime(1); + ms_Event->SetHYD2TrkSecondStageTDetectorNbr(m_index["Trapezoid1"] + N); + ms_Event->SetHYD2TrkSecondStageEDetectorNbr(m_index["Trapezoid1"] + N); + } + + SecondStageEnergy_itr++; + } + + // Third Stage + ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < ThirdStageEnergyHitMap->entries(); h++) { + G4int ThirdStageEnergyTrackID = ThirdStageEnergy_itr->first - N; + G4double ThirdStageEnergy = *(ThirdStageEnergy_itr->second); + + if (ThirdStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkThirdStageEEnergy(RandGauss::shoot(ThirdStageEnergy, ResoThirdStage)); + ms_Event->SetHYD2TrkThirdStageEPadNbr(1); + ms_Event->SetHYD2TrkThirdStageTPadNbr(1); + ms_Event->SetHYD2TrkThirdStageTTime(1); + ms_Event->SetHYD2TrkThirdStageTDetectorNbr(m_index["Trapezoid1"] + N); + ms_Event->SetHYD2TrkThirdStageEDetectorNbr(m_index["Trapezoid1"] + N); + } + + ThirdStageEnergy_itr++; + } + + // Fourth Stage + FourthStageEnergy_itr = FourthStageEnergyHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < FourthStageEnergyHitMap->entries(); h++) { + G4int FourthStageEnergyTrackID = FourthStageEnergy_itr->first - N; + G4double FourthStageEnergy = *(FourthStageEnergy_itr->second); + + if (FourthStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkFourthStageEEnergy(RandGauss::shoot(FourthStageEnergy, ResoFourthStage)); + ms_Event->SetHYD2TrkFourthStageEPadNbr(1); + ms_Event->SetHYD2TrkFourthStageTPadNbr(1); + ms_Event->SetHYD2TrkFourthStageTTime(1); + ms_Event->SetHYD2TrkFourthStageTDetectorNbr(m_index["Trapezoid1"] + N); + ms_Event->SetHYD2TrkFourthStageEDetectorNbr(m_index["Trapezoid1"] + N); + } + + FourthStageEnergy_itr++; + } + + // Fifth Stage + FifthStageEnergy_itr = FifthStageEnergyHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < FifthStageEnergyHitMap->entries(); h++) { + G4int FifthStageEnergyTrackID = FifthStageEnergy_itr->first - N; + G4double FifthStageEnergy = *(FifthStageEnergy_itr->second); + + if (FifthStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkFifthStageEEnergy(RandGauss::shoot(FifthStageEnergy, ResoFifthStage)); + ms_Event->SetHYD2TrkFifthStageEPadNbr(1); + ms_Event->SetHYD2TrkFifthStageTPadNbr(1); + ms_Event->SetHYD2TrkFifthStageTTime(1); + ms_Event->SetHYD2TrkFifthStageTDetectorNbr(m_index["Trapezoid1"] + N); + ms_Event->SetHYD2TrkFifthStageEDetectorNbr(m_index["Trapezoid1"] + N); + } + + FifthStageEnergy_itr++; + } + + // Sixth Stage + SixthStageEnergy_itr = SixthStageEnergyHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < SixthStageEnergyHitMap->entries(); h++) { + G4int SixthStageEnergyTrackID = SixthStageEnergy_itr->first - N; + G4double SixthStageEnergy = *(SixthStageEnergy_itr->second); + + if (SixthStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkSixthStageEEnergy(RandGauss::shoot(SixthStageEnergy, ResoSixthStage)); + ms_Event->SetHYD2TrkSixthStageEPadNbr(1); + ms_Event->SetHYD2TrkSixthStageTPadNbr(1); + ms_Event->SetHYD2TrkSixthStageTTime(1); + ms_Event->SetHYD2TrkSixthStageTDetectorNbr(m_index["Trapezoid1"] + N); + ms_Event->SetHYD2TrkSixthStageEDetectorNbr(m_index["Trapezoid1"] + N); + } + + SixthStageEnergy_itr++; + } + + DetectorNumber_itr++; + } + + // clear map for next event + DetectorNumberHitMap->clear(); + EnergyHitMap->clear(); + TimeHitMap->clear(); + XHitMap->clear(); + YHitMap->clear(); + PosXHitMap->clear(); + PosYHitMap->clear(); + PosZHitMap->clear(); + AngThetaHitMap->clear(); + AngPhiHitMap->clear(); + SecondStageEnergyHitMap->clear(); + ThirdStageEnergyHitMap->clear(); + FourthStageEnergyHitMap->clear(); + FifthStageEnergyHitMap->clear(); + SixthStageEnergyHitMap->clear(); + } +} -void Hyde2TrackerTrapezoid1::InitializeScorers() -{ - bool already_exist = false; - m_FirstStageScorer = NPS::VDetector::CheckScorer("FirstStageScorerHYD2Trapezoid1",already_exist); - m_SecondStageScorer = NPS::VDetector::CheckScorer("SecondStageScorerHYD2Trapezoid1",already_exist); - m_ThirdStageScorer = NPS::VDetector::CheckScorer("ThirdStageScorerHYD2Trapezoid1",already_exist); - m_FourthStageScorer = NPS::VDetector::CheckScorer("FourthStageScorerHYD2Trapezoid1",already_exist); - m_FifthStageScorer = NPS::VDetector::CheckScorer("FifthStageScorerHYD2Trapezoid1",already_exist); - m_SixthStageScorer = NPS::VDetector::CheckScorer("SixthStageScorerHYD2Trapezoid1",already_exist); - if(already_exist) return; - - - - // First stage Associate Scorer - G4VPrimitiveScorer* DetNbr = new OBSOLETEGENERALSCORERS::PSDetectorNumber("DetectorNumber", "HYD2Trapezoid1", 0); - G4VPrimitiveScorer* TOF = new OBSOLETEGENERALSCORERS::PSTOF("StripTime","HYD2Trapezoid1", 0); - G4VPrimitiveScorer* InteractionCoordinatesX = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesX("InterCoordX","HYD2Trapezoid1", 0); - G4VPrimitiveScorer* InteractionCoordinatesY = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesY("InterCoordY","HYD2Trapezoid1", 0); - G4VPrimitiveScorer* InteractionCoordinatesZ = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ","HYD2Trapezoid1", 0); - G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta","HYD2Trapezoid1", 0); - G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi","HYD2Trapezoid1", 0); - G4VPrimitiveScorer* Energy = new HYD2ScorerFirstStageEnergy("StripEnergy", "HYD2Trapezoid1", 0); - G4VPrimitiveScorer* StripPositionX = new HYD2ScorerFirstStageFrontStripTrapezoid1("StripNumberX", 0, NumberOfStripsX); - G4VPrimitiveScorer* StripPositionY = new HYD2ScorerFirstStageBackStripTrapezoid1("StripNumberY", 0, NumberOfStripsY); - - //and register it to the multifunctionnal detector - m_FirstStageScorer->RegisterPrimitive(DetNbr); - m_FirstStageScorer->RegisterPrimitive(Energy); - m_FirstStageScorer->RegisterPrimitive(TOF); - m_FirstStageScorer->RegisterPrimitive(StripPositionX); - m_FirstStageScorer->RegisterPrimitive(StripPositionY); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesX); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesY); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesZ); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAngleTheta); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAnglePhi); - - // Second stage Associate Scorer - G4VPrimitiveScorer* SecondStageEnergy = new HYD2ScorerSecondStageEnergy("SecondStageEnergy", "HYD2Trapezoid1", 0); - m_SecondStageScorer->RegisterPrimitive(SecondStageEnergy); - - // Third stage Associate Scorer - G4VPrimitiveScorer* ThirdStageEnergy = new HYD2ScorerThirdStageEnergy("ThirdStageEnergy", "HYD2Trapezoid1", 0); - m_ThirdStageScorer->RegisterPrimitive(ThirdStageEnergy); - - // Fourth stage Associate Scorer - G4VPrimitiveScorer* FourthStageEnergy = new HYD2ScorerFourthStageEnergy("FourthStageEnergy", "HYD2Trapezoid1", 0); - m_FourthStageScorer->RegisterPrimitive(FourthStageEnergy); - - // Fifth stage Associate Scorer - G4VPrimitiveScorer* FifthStageEnergy = new HYD2ScorerFifthStageEnergy("FifthStageEnergy", "HYD2Trapezoid1", 0); - m_FifthStageScorer->RegisterPrimitive(FifthStageEnergy); - - // Sixth stage Associate Scorer - G4VPrimitiveScorer* SixthStageEnergy = new HYD2ScorerSixthStageEnergy("SixthStageEnergy", "HYD2Trapezoid1", 0); - m_SixthStageScorer->RegisterPrimitive(SixthStageEnergy); - - // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_FirstStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_SecondStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_ThirdStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_FourthStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_FifthStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_SixthStageScorer); +void Hyde2TrackerTrapezoid1::InitializeScorers() { + bool already_exist = false; + m_FirstStageScorer = NPS::VDetector::CheckScorer("FirstStageScorerHYD2Trapezoid1", already_exist); + m_SecondStageScorer = NPS::VDetector::CheckScorer("SecondStageScorerHYD2Trapezoid1", already_exist); + m_ThirdStageScorer = NPS::VDetector::CheckScorer("ThirdStageScorerHYD2Trapezoid1", already_exist); + m_FourthStageScorer = NPS::VDetector::CheckScorer("FourthStageScorerHYD2Trapezoid1", already_exist); + m_FifthStageScorer = NPS::VDetector::CheckScorer("FifthStageScorerHYD2Trapezoid1", already_exist); + m_SixthStageScorer = NPS::VDetector::CheckScorer("SixthStageScorerHYD2Trapezoid1", already_exist); + if (already_exist) + return; + + // First stage Associate Scorer + G4VPrimitiveScorer* DetNbr = new OBSOLETEGENERALSCORERS::PSDetectorNumber("DetectorNumber", "HYD2Trapezoid1", 0); + G4VPrimitiveScorer* TOF = new OBSOLETEGENERALSCORERS::PSTOF("StripTime", "HYD2Trapezoid1", 0); + G4VPrimitiveScorer* InteractionCoordinatesX = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesX("InterCoordX", "HYD2Trapezoid1", 0); + G4VPrimitiveScorer* InteractionCoordinatesY = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesY("InterCoordY", "HYD2Trapezoid1", 0); + G4VPrimitiveScorer* InteractionCoordinatesZ = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ", "HYD2Trapezoid1", 0); + G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta", "HYD2Trapezoid1", 0); + G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi", "HYD2Trapezoid1", 0); + G4VPrimitiveScorer* Energy = new HYD2ScorerFirstStageEnergy("StripEnergy", "HYD2Trapezoid1", 0); + G4VPrimitiveScorer* StripPositionX = new HYD2ScorerFirstStageFrontStripTrapezoid1("StripNumberX", 0, NumberOfStripsX); + G4VPrimitiveScorer* StripPositionY = new HYD2ScorerFirstStageBackStripTrapezoid1("StripNumberY", 0, NumberOfStripsY); + + // and register it to the multifunctionnal detector + m_FirstStageScorer->RegisterPrimitive(DetNbr); + m_FirstStageScorer->RegisterPrimitive(Energy); + m_FirstStageScorer->RegisterPrimitive(TOF); + m_FirstStageScorer->RegisterPrimitive(StripPositionX); + m_FirstStageScorer->RegisterPrimitive(StripPositionY); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesX); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesY); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesZ); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAngleTheta); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAnglePhi); + + // Second stage Associate Scorer + G4VPrimitiveScorer* SecondStageEnergy = new HYD2ScorerSecondStageEnergy("SecondStageEnergy", "HYD2Trapezoid1", 0); + m_SecondStageScorer->RegisterPrimitive(SecondStageEnergy); + + // Third stage Associate Scorer + G4VPrimitiveScorer* ThirdStageEnergy = new HYD2ScorerThirdStageEnergy("ThirdStageEnergy", "HYD2Trapezoid1", 0); + m_ThirdStageScorer->RegisterPrimitive(ThirdStageEnergy); + + // Fourth stage Associate Scorer + G4VPrimitiveScorer* FourthStageEnergy = new HYD2ScorerFourthStageEnergy("FourthStageEnergy", "HYD2Trapezoid1", 0); + m_FourthStageScorer->RegisterPrimitive(FourthStageEnergy); + + // Fifth stage Associate Scorer + G4VPrimitiveScorer* FifthStageEnergy = new HYD2ScorerFifthStageEnergy("FifthStageEnergy", "HYD2Trapezoid1", 0); + m_FifthStageScorer->RegisterPrimitive(FifthStageEnergy); + + // Sixth stage Associate Scorer + G4VPrimitiveScorer* SixthStageEnergy = new HYD2ScorerSixthStageEnergy("SixthStageEnergy", "HYD2Trapezoid1", 0); + m_SixthStageScorer->RegisterPrimitive(SixthStageEnergy); + + // Add All Scorer to the Global Scorer Manager + G4SDManager::GetSDMpointer()->AddNewDetector(m_FirstStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_SecondStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_ThirdStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_FourthStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_FifthStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_SixthStageScorer); } diff --git a/NPSimulation/Detectors/Hyde2/Hyde2TrackerTrapezoid2.cc b/NPSimulation/Detectors/Hyde2/Hyde2TrackerTrapezoid2.cc index bf8856276..f11cdc94c 100644 --- a/NPSimulation/Detectors/Hyde2/Hyde2TrackerTrapezoid2.cc +++ b/NPSimulation/Detectors/Hyde2/Hyde2TrackerTrapezoid2.cc @@ -23,177 +23,135 @@ *****************************************************************************/ // C++ headers +#include <cmath> #include <sstream> #include <string> -#include <cmath> // G4 Geometry headers #include "G4Box.hh" #include "G4Trap.hh" // G4 various headers -#include "G4MaterialTable.hh" +#include "G4Colour.hh" #include "G4Element.hh" #include "G4ElementTable.hh" -#include "G4VisAttributes.hh" -#include "G4Colour.hh" +#include "G4MaterialTable.hh" +#include "G4PVDivision.hh" +#include "G4PVPlacement.hh" #include "G4RotationMatrix.hh" #include "G4Transform3D.hh" -#include "G4PVPlacement.hh" -#include "G4PVDivision.hh" +#include "G4VisAttributes.hh" // G4 sensitive -#include "G4SDManager.hh" #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" // NPTool headers +#include "Hyde2Scorers.hh" #include "Hyde2TrackerTrapezoid2.hh" +#include "NPSVDetector.hh" #include "ObsoleteGeneralScorers.hh" -#include "Hyde2Scorers.hh" #include "RootOutput.h" -#include "NPSVDetector.hh" // CLHEP #include "CLHEP/Random/RandGauss.h" using namespace std; using namespace CLHEP; -using namespace HYD2TRAP2 ; - - +using namespace HYD2TRAP2; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Hyde2TrackerTrapezoid2::Hyde2TrackerTrapezoid2() -{ - ms_InterCoord = 0; -} - - +Hyde2TrackerTrapezoid2::Hyde2TrackerTrapezoid2() { ms_InterCoord = 0; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Hyde2TrackerTrapezoid2::~Hyde2TrackerTrapezoid2() -{ -} - - +Hyde2TrackerTrapezoid2::~Hyde2TrackerTrapezoid2() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Hyde2TrackerTrapezoid2::AddModule(G4ThreeVector X1_Y1 , - G4ThreeVector X128_Y1 , - G4ThreeVector X1_Y128 , - G4ThreeVector X128_Y128 , - bool wFirstStage , - bool wSecondStage , - bool wThirdStage , - bool wFourthStage , - bool wFifthStage , - bool wSixthStage) -{ - m_DefinitionType.push_back(true) ; - - m_X1_Y1.push_back(X1_Y1) ; - m_X128_Y1.push_back(X128_Y1) ; - m_X1_Y128.push_back(X1_Y128) ; - m_X128_Y128.push_back(X128_Y128) ; - m_wFirstStage.push_back(wFirstStage) ; - m_wSecondStage.push_back(wSecondStage) ; - m_wThirdStage.push_back(wThirdStage) ; - m_wFourthStage.push_back(wFourthStage) ; - m_wFifthStage.push_back(wFifthStage) ; - m_wSixthStage.push_back(wSixthStage) ; - - m_R.push_back(0) ; - m_Theta.push_back(0) ; - m_Phi.push_back(0) ; - m_beta_u.push_back(0) ; - m_beta_v.push_back(0) ; - m_beta_w.push_back(0) ; +void Hyde2TrackerTrapezoid2::AddModule(G4ThreeVector X1_Y1, G4ThreeVector X128_Y1, G4ThreeVector X1_Y128, + G4ThreeVector X128_Y128, bool wFirstStage, bool wSecondStage, bool wThirdStage, + bool wFourthStage, bool wFifthStage, bool wSixthStage) { + m_DefinitionType.push_back(true); + + m_X1_Y1.push_back(X1_Y1); + m_X128_Y1.push_back(X128_Y1); + m_X1_Y128.push_back(X1_Y128); + m_X128_Y128.push_back(X128_Y128); + m_wFirstStage.push_back(wFirstStage); + m_wSecondStage.push_back(wSecondStage); + m_wThirdStage.push_back(wThirdStage); + m_wFourthStage.push_back(wFourthStage); + m_wFifthStage.push_back(wFifthStage); + m_wSixthStage.push_back(wSixthStage); + + m_R.push_back(0); + m_Theta.push_back(0); + m_Phi.push_back(0); + m_beta_u.push_back(0); + m_beta_v.push_back(0); + m_beta_w.push_back(0); } - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Hyde2TrackerTrapezoid2::AddModule(G4double R , - G4double Theta , - G4double Phi , - G4double beta_u , - G4double beta_v , - G4double beta_w , - bool wFirstStage , - bool wSecondStage , - bool wThirdStage , - bool wFourthStage , - bool wFifthStage , - bool wSixthStage) -{ - G4ThreeVector empty = G4ThreeVector(0, 0, 0); - - m_DefinitionType.push_back(false); - - m_R.push_back(R) ; - m_Theta.push_back(Theta) ; - m_Phi.push_back(Phi) ; - m_beta_u.push_back(beta_u) ; - m_beta_v.push_back(beta_v) ; - m_beta_w.push_back(beta_w) ; - m_wFirstStage.push_back(wFirstStage) ; - m_wSecondStage.push_back(wSecondStage) ; - m_wThirdStage.push_back(wThirdStage) ; - m_wFourthStage.push_back(wFourthStage) ; - m_wFifthStage.push_back(wFifthStage) ; - m_wSixthStage.push_back(wSixthStage) ; - - m_X1_Y1.push_back(empty) ; - m_X128_Y1.push_back(empty) ; - m_X1_Y128.push_back(empty) ; - m_X128_Y128.push_back(empty) ; +void Hyde2TrackerTrapezoid2::AddModule(G4double R, G4double Theta, G4double Phi, G4double beta_u, G4double beta_v, + G4double beta_w, bool wFirstStage, bool wSecondStage, bool wThirdStage, + bool wFourthStage, bool wFifthStage, bool wSixthStage) { + G4ThreeVector empty = G4ThreeVector(0, 0, 0); + + m_DefinitionType.push_back(false); + + m_R.push_back(R); + m_Theta.push_back(Theta); + m_Phi.push_back(Phi); + m_beta_u.push_back(beta_u); + m_beta_v.push_back(beta_v); + m_beta_w.push_back(beta_w); + m_wFirstStage.push_back(wFirstStage); + m_wSecondStage.push_back(wSecondStage); + m_wThirdStage.push_back(wThirdStage); + m_wFourthStage.push_back(wFourthStage); + m_wFifthStage.push_back(wFifthStage); + m_wSixthStage.push_back(wSixthStage); + + m_X1_Y1.push_back(empty); + m_X128_Y1.push_back(empty); + m_X1_Y128.push_back(empty); + m_X128_Y128.push_back(empty); } - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Hyde2TrackerTrapezoid2::VolumeMaker(G4int TelescopeNumber , - G4ThreeVector MMpos , - G4RotationMatrix* MMrot , - bool wFirstStage , - bool wSecondStage , - bool wThirdStage , - bool wFourthStage , - bool wFifthStage , - bool wSixthStage , - G4LogicalVolume* world) -{ - G4double NbrTelescopes = TelescopeNumber ; - G4String DetectorNumber ; - ostringstream Number ; - Number << NbrTelescopes ; - DetectorNumber = Number.str() ; - - //////////////////////////////////////////////////////////////// - ////////////// Starting Volume Definition ////////////////////// - //////////////////////////////////////////////////////////////// - G4String Name = "HYD2Trapezoid2" + DetectorNumber ; - - // Definition of the volume containing the sensitive detector - G4Trap* solidHYD2Trapezoid2 = new G4Trap(Name, - Length/2, 0*deg, 0*deg, - Height/2, BaseLarge/2, BaseSmall/2, 0*deg, - Height/2, BaseLarge/2, BaseSmall/2, 0*deg); - G4LogicalVolume* logicHYD2Trapezoid2 = new G4LogicalVolume(solidHYD2Trapezoid2, m_MaterialVacuum, Name, 0, 0, 0); - - new G4PVPlacement(G4Transform3D(*MMrot, MMpos), logicHYD2Trapezoid2, Name, world, false, 0); - - logicHYD2Trapezoid2->SetVisAttributes(G4VisAttributes::Invisible); - if (m_non_sensitive_part_visiualisation) logicHYD2Trapezoid2->SetVisAttributes(G4VisAttributes(G4Colour(0.90, 0.90, 0.90))); - - //Place two marker to identify the u and v axis on silicon face: - //marker are placed a bit before the silicon itself so they don't perturbate simulation - //Uncomment to help debugging or if you want to understand the way the code work. - //I should recommand to Comment it during simulation to avoid perturbation of simulation - //Remember G4 is limitationg step on geometry constraints. - /* +void Hyde2TrackerTrapezoid2::VolumeMaker(G4int TelescopeNumber, G4ThreeVector MMpos, G4RotationMatrix* MMrot, + bool wFirstStage, bool wSecondStage, bool wThirdStage, bool wFourthStage, + bool wFifthStage, bool wSixthStage, G4LogicalVolume* world) { + G4double NbrTelescopes = TelescopeNumber; + G4String DetectorNumber; + ostringstream Number; + Number << NbrTelescopes; + DetectorNumber = Number.str(); + + //////////////////////////////////////////////////////////////// + ////////////// Starting Volume Definition ////////////////////// + //////////////////////////////////////////////////////////////// + G4String Name = "HYD2Trapezoid2" + DetectorNumber; + + // Definition of the volume containing the sensitive detector + G4Trap* solidHYD2Trapezoid2 = new G4Trap(Name, Length / 2, 0 * deg, 0 * deg, Height / 2, BaseLarge / 2, BaseSmall / 2, + 0 * deg, Height / 2, BaseLarge / 2, BaseSmall / 2, 0 * deg); + G4LogicalVolume* logicHYD2Trapezoid2 = new G4LogicalVolume(solidHYD2Trapezoid2, m_MaterialVacuum, Name, 0, 0, 0); + + new G4PVPlacement(G4Transform3D(*MMrot, MMpos), logicHYD2Trapezoid2, Name, world, false, 0); + + logicHYD2Trapezoid2->SetVisAttributes(G4VisAttributes::GetInvisible()); + if (m_non_sensitive_part_visiualisation) + logicHYD2Trapezoid2->SetVisAttributes(G4VisAttributes(G4Colour(0.90, 0.90, 0.90))); + + // Place two marker to identify the u and v axis on silicon face: + // marker are placed a bit before the silicon itself so they don't perturbate simulation + // Uncomment to help debugging or if you want to understand the way the code work. + // I should recommand to Comment it during simulation to avoid perturbation of simulation + // Remember G4 is limitationg step on geometry constraints. + /* G4ThreeVector positionMarkerU = CT*0.98 + MMu*SiliconFace/4; G4Box* solidMarkerU = new G4Box( "solidMarkerU" , SiliconFace/4 , 1*mm , 1*mm ) ; - G4LogicalVolume* logicMarkerU = new G4LogicalVolume( solidMarkerU , m_MaterialVacuum , "logicMarkerU",0,0,0) ; + G4LogicalVolume* logicMarkerU = new G4LogicalVolume( solidMarkerU , m_MaterialVacuum , "logicMarkerU",0,0,0) ; PVPBuffer = new G4PVPlacement(G4Transform3D(*MMrot,positionMarkerU),logicMarkerU,"MarkerU",world,false,0) ; G4VisAttributes* MarkerUVisAtt= new G4VisAttributes(G4Colour(0.,0.,0.5));//blue @@ -201,187 +159,156 @@ void Hyde2TrackerTrapezoid2::VolumeMaker(G4int TelescopeNumber , G4ThreeVector positionMarkerV = CT*0.98 + MMv*SiliconFace/4; G4Box* solidMarkerV = new G4Box( "solidMarkerU" , 1*mm , SiliconFace/4 , 1*mm ) ; - G4LogicalVolume* logicMarkerV = new G4LogicalVolume( solidMarkerV , m_MaterialVacuum , "logicMarkerV",0,0,0) ; + G4LogicalVolume* logicMarkerV = new G4LogicalVolume( solidMarkerV , m_MaterialVacuum , "logicMarkerV",0,0,0) ; PVPBuffer = new G4PVPlacement(G4Transform3D(*MMrot,positionMarkerV),logicMarkerV,"MarkerV",world,false,0) ; G4VisAttributes* MarkerVVisAtt= new G4VisAttributes(G4Colour(0.,0.5,0.5));//green logicMarkerV->SetVisAttributes(MarkerVVisAtt); */ - //////////////////////////////////////////////////////////////// - /////////////////// First Stage Construction//////////////////// - //////////////////////////////////////////////////////////////// - if (wFirstStage) { - // Silicon detector itself - G4ThreeVector positionFirstStage = G4ThreeVector(0, 0, FirstStage_PosZ); - - G4Trap* solidFirstStage = new G4Trap("solidFirstStage", - FirstStageThickness/2, 0*deg, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg); - G4LogicalVolume* logicFirstStage = new G4LogicalVolume(solidFirstStage, m_MaterialSilicon, "logicFirstStage", 0, 0, 0); - - new G4PVPlacement(0, - positionFirstStage, - logicFirstStage, - Name + "_FirstStage", - logicHYD2Trapezoid2, - false, - 0); - - // Set First Stage sensible - logicFirstStage->SetSensitiveDetector(m_FirstStageScorer); - - ///Visualisation of FirstStage Strip - G4VisAttributes* FirstStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)); // blue - logicFirstStage->SetVisAttributes(FirstStageVisAtt); - } - - //////////////////////////////////////////////////////////////// - //////////////// Second Stage Construction //////////////////// - //////////////////////////////////////////////////////////////// - if (wSecondStage) { - // Second stage silicon detector - G4ThreeVector positionSecondStage = G4ThreeVector(0, 0, SecondStage_PosZ); - - G4Trap* solidSecondStage = new G4Trap("solidSecondStage", - SecondStageThickness/2, 0*deg, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg); - G4LogicalVolume* logicSecondStage = new G4LogicalVolume(solidSecondStage, m_MaterialSilicon, "logicSecondStage", 0, 0, 0); - - new G4PVPlacement(0, - positionSecondStage, - logicSecondStage, - Name + "_SecondStage", - logicHYD2Trapezoid2, - false, - 0); - - // Set Second Stage sensible - logicSecondStage->SetSensitiveDetector(m_SecondStageScorer); - - ///Visualisation of SecondStage Strip - G4VisAttributes* SecondStageVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)); - logicSecondStage->SetVisAttributes(SecondStageVisAtt); - } - - //////////////////////////////////////////////////////////////// - ///////////////// Third Stage Construction ///////////////////// - //////////////////////////////////////////////////////////////// - if (wThirdStage) { - // Third stage silicon detector - G4ThreeVector positionThirdStage = G4ThreeVector(0, 0, ThirdStage_PosZ); - - G4Trap* solidThirdStage = new G4Trap("solidThirdStage", - ThirdStageThickness/2, 0*deg, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg); - G4LogicalVolume* logicThirdStage = new G4LogicalVolume(solidThirdStage, m_MaterialSilicon, "logicThirdStage", 0, 0, 0); - - new G4PVPlacement(0, - positionThirdStage, - logicThirdStage, - Name + "_ThirdStage", - logicHYD2Trapezoid2, - false, - 0); - - // Set Third Stage sensible - logicThirdStage->SetSensitiveDetector(m_ThirdStageScorer); - - ///Visualisation of Third Stage - G4VisAttributes* ThirdStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red - logicThirdStage->SetVisAttributes(ThirdStageVisAtt); - } - - //////////////////////////////////////////////////////////////// - ///////////////// Fourth Stage Construction //////////////////// - //////////////////////////////////////////////////////////////// - if (wFourthStage) { - // Fourth stage silicon detector - G4ThreeVector positionFourthStage = G4ThreeVector(0, 0, FourthStage_PosZ); - - G4Trap* solidFourthStage = new G4Trap("solidFourthStage", - FourthStageThickness/2, 0*deg, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg); - G4LogicalVolume* logicFourthStage = new G4LogicalVolume(solidFourthStage, m_MaterialSilicon, "logicFourthStage", 0, 0, 0); - - new G4PVPlacement(0, - positionFourthStage, - logicFourthStage, - Name + "_FourthStage", - logicHYD2Trapezoid2, - false, - 0); - - // Set Fourth Stage sensible - logicFourthStage->SetSensitiveDetector(m_FourthStageScorer); - - ///Visualisation of Fourth Stage - G4VisAttributes* FourthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red - logicFourthStage->SetVisAttributes(FourthStageVisAtt); - } - - //////////////////////////////////////////////////////////////// - ///////////////// Fifth Stage Construction ///////////////////// - //////////////////////////////////////////////////////////////// - if (wFifthStage) { - // Fifth stage silicon detector - G4ThreeVector positionFifthStage = G4ThreeVector(0, 0, FifthStage_PosZ); - - G4Trap* solidFifthStage = new G4Trap("solidFifthStage", - FifthStageThickness/2, 0*deg, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg); - G4LogicalVolume* logicFifthStage = new G4LogicalVolume(solidFifthStage, m_MaterialSilicon, "logicFifthStage", 0, 0, 0); - - new G4PVPlacement(0, - positionFifthStage, - logicFifthStage, - Name + "_FifthStage", - logicHYD2Trapezoid2, - false, - 0); - - // Set Fifth Stage sensible - logicFifthStage->SetSensitiveDetector(m_FifthStageScorer); - - ///Visualisation of Fifth Stage - G4VisAttributes* FifthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red - logicFifthStage->SetVisAttributes(FifthStageVisAtt); - } - - //////////////////////////////////////////////////////////////// - ///////////////// Sixth Stage Construction ///////////////////// - //////////////////////////////////////////////////////////////// - if (wSixthStage) { - // Sixth stage silicon detector - G4ThreeVector positionSixthStage = G4ThreeVector(0, 0, SixthStage_PosZ); - - G4Trap* solidSixthStage = new G4Trap("solidSixthStage", - SixthStageThickness/2, 0*deg, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg); - G4LogicalVolume* logicSixthStage = new G4LogicalVolume(solidSixthStage, m_MaterialSilicon, "logicSixthStage", 0, 0, 0); - - new G4PVPlacement(0, - positionSixthStage, - logicSixthStage, - Name + "_SixthStage", - logicHYD2Trapezoid2, - false, - 0); - - // Set Sixth Stage sensible - logicSixthStage->SetSensitiveDetector(m_SixthStageScorer); - - ///Visualisation of Sixth Stage - G4VisAttributes* SixthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red - logicSixthStage->SetVisAttributes(SixthStageVisAtt); - } - + //////////////////////////////////////////////////////////////// + /////////////////// First Stage Construction//////////////////// + //////////////////////////////////////////////////////////////// + if (wFirstStage) { + // Silicon detector itself + G4ThreeVector positionFirstStage = G4ThreeVector(0, 0, FirstStage_PosZ); + + G4Trap* solidFirstStage = + new G4Trap("solidFirstStage", FirstStageThickness / 2, 0 * deg, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg); + G4LogicalVolume* logicFirstStage = + new G4LogicalVolume(solidFirstStage, m_MaterialSilicon, "logicFirstStage", 0, 0, 0); + + new G4PVPlacement(0, positionFirstStage, logicFirstStage, Name + "_FirstStage", logicHYD2Trapezoid2, false, 0); + + // Set First Stage sensible + logicFirstStage->SetSensitiveDetector(m_FirstStageScorer); + + /// Visualisation of FirstStage Strip + G4VisAttributes* FirstStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)); // blue + logicFirstStage->SetVisAttributes(FirstStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + //////////////// Second Stage Construction //////////////////// + //////////////////////////////////////////////////////////////// + if (wSecondStage) { + // Second stage silicon detector + G4ThreeVector positionSecondStage = G4ThreeVector(0, 0, SecondStage_PosZ); + + G4Trap* solidSecondStage = + new G4Trap("solidSecondStage", SecondStageThickness / 2, 0 * deg, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg); + G4LogicalVolume* logicSecondStage = + new G4LogicalVolume(solidSecondStage, m_MaterialSilicon, "logicSecondStage", 0, 0, 0); + + new G4PVPlacement(0, positionSecondStage, logicSecondStage, Name + "_SecondStage", logicHYD2Trapezoid2, false, 0); + + // Set Second Stage sensible + logicSecondStage->SetSensitiveDetector(m_SecondStageScorer); + + /// Visualisation of SecondStage Strip + G4VisAttributes* SecondStageVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)); + logicSecondStage->SetVisAttributes(SecondStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Third Stage Construction ///////////////////// + //////////////////////////////////////////////////////////////// + if (wThirdStage) { + // Third stage silicon detector + G4ThreeVector positionThirdStage = G4ThreeVector(0, 0, ThirdStage_PosZ); + + G4Trap* solidThirdStage = + new G4Trap("solidThirdStage", ThirdStageThickness / 2, 0 * deg, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg); + G4LogicalVolume* logicThirdStage = + new G4LogicalVolume(solidThirdStage, m_MaterialSilicon, "logicThirdStage", 0, 0, 0); + + new G4PVPlacement(0, positionThirdStage, logicThirdStage, Name + "_ThirdStage", logicHYD2Trapezoid2, false, 0); + + // Set Third Stage sensible + logicThirdStage->SetSensitiveDetector(m_ThirdStageScorer); + + /// Visualisation of Third Stage + G4VisAttributes* ThirdStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red + logicThirdStage->SetVisAttributes(ThirdStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Fourth Stage Construction //////////////////// + //////////////////////////////////////////////////////////////// + if (wFourthStage) { + // Fourth stage silicon detector + G4ThreeVector positionFourthStage = G4ThreeVector(0, 0, FourthStage_PosZ); + + G4Trap* solidFourthStage = + new G4Trap("solidFourthStage", FourthStageThickness / 2, 0 * deg, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg); + G4LogicalVolume* logicFourthStage = + new G4LogicalVolume(solidFourthStage, m_MaterialSilicon, "logicFourthStage", 0, 0, 0); + + new G4PVPlacement(0, positionFourthStage, logicFourthStage, Name + "_FourthStage", logicHYD2Trapezoid2, false, 0); + + // Set Fourth Stage sensible + logicFourthStage->SetSensitiveDetector(m_FourthStageScorer); + + /// Visualisation of Fourth Stage + G4VisAttributes* FourthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red + logicFourthStage->SetVisAttributes(FourthStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Fifth Stage Construction ///////////////////// + //////////////////////////////////////////////////////////////// + if (wFifthStage) { + // Fifth stage silicon detector + G4ThreeVector positionFifthStage = G4ThreeVector(0, 0, FifthStage_PosZ); + + G4Trap* solidFifthStage = + new G4Trap("solidFifthStage", FifthStageThickness / 2, 0 * deg, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg); + G4LogicalVolume* logicFifthStage = + new G4LogicalVolume(solidFifthStage, m_MaterialSilicon, "logicFifthStage", 0, 0, 0); + + new G4PVPlacement(0, positionFifthStage, logicFifthStage, Name + "_FifthStage", logicHYD2Trapezoid2, false, 0); + + // Set Fifth Stage sensible + logicFifthStage->SetSensitiveDetector(m_FifthStageScorer); + + /// Visualisation of Fifth Stage + G4VisAttributes* FifthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red + logicFifthStage->SetVisAttributes(FifthStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Sixth Stage Construction ///////////////////// + //////////////////////////////////////////////////////////////// + if (wSixthStage) { + // Sixth stage silicon detector + G4ThreeVector positionSixthStage = G4ThreeVector(0, 0, SixthStage_PosZ); + + G4Trap* solidSixthStage = + new G4Trap("solidSixthStage", SixthStageThickness / 2, 0 * deg, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg); + G4LogicalVolume* logicSixthStage = + new G4LogicalVolume(solidSixthStage, m_MaterialSilicon, "logicSixthStage", 0, 0, 0); + + new G4PVPlacement(0, positionSixthStage, logicSixthStage, Name + "_SixthStage", logicHYD2Trapezoid2, false, 0); + + // Set Sixth Stage sensible + logicSixthStage->SetSensitiveDetector(m_SixthStageScorer); + + /// Visualisation of Sixth Stage + G4VisAttributes* SixthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red + logicSixthStage->SetVisAttributes(SixthStageVisAtt); + } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -391,837 +318,825 @@ void Hyde2TrackerTrapezoid2::VolumeMaker(G4int TelescopeNumber , // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Hyde2TrackerTrapezoid2::ReadConfiguration(string Path) -{ - ifstream ConfigFile ; - ConfigFile.open(Path.c_str()) ; - string LineBuffer ; - string DataBuffer ; - - // A:X1_Y1 --> X:1 Y:1 - // B:X128_Y1 --> X:128 Y:1 - // C:X1_Y128 --> X:1 Y:128 - // D:X128_Y128 --> X:128 Y:128 - - G4double Ax , Bx , Cx , Dx , Ay , By , Cy , Dy , Az , Bz , Cz , Dz ; - G4ThreeVector A , B , C , D ; - G4double Theta = 0 , Phi = 0 , R = 0 , beta_u = 0 , beta_v = 0 , beta_w = 0 ; - int FIRSTSTAGE = 0 , SECONDSTAGE = 0 , THIRDSTAGE = 0 , FOURTHSTAGE = 0 , FIFTHSTAGE = 0 , SIXTHSTAGE = 0 ; - - bool ReadingStatus = false ; - - bool check_A = false ; - bool check_C = false ; - bool check_B = false ; - bool check_D = false ; - - bool check_Theta = false ; - bool check_Phi = false ; - bool check_R = false ; -// bool check_beta = false ; - - bool check_FirstStage = false ; - bool check_SecondStage = false ; - bool check_ThirdStage = false ; - bool check_FourthStage = false ; - bool check_FifthStage = false ; - bool check_SixthStage = false ; - bool checkVis = false ; - - while (!ConfigFile.eof()) { - getline(ConfigFile, LineBuffer); - if (LineBuffer.compare(0, 14, "HYD2Trapezoid2") == 0) { - G4cout << "///" << G4endl ; - G4cout << "Trapezoid2 element found: " << G4endl ; - ReadingStatus = true ; - } - - while(ReadingStatus){ - - ConfigFile >> DataBuffer; - // Comment Line - if (DataBuffer.compare(0, 1, "%") == 0) {/*do nothing */;} - - // Position method - else if (DataBuffer.compare(0, 6, "X1_Y1=") == 0) { - check_A = true; - ConfigFile >> DataBuffer ; - Ax = atof(DataBuffer.c_str()) ; - Ax = Ax * mm ; - ConfigFile >> DataBuffer ; - Ay = atof(DataBuffer.c_str()) ; - Ay = Ay * mm ; - ConfigFile >> DataBuffer ; - Az = atof(DataBuffer.c_str()) ; - Az = Az * mm ; - - A = G4ThreeVector(Ax, Ay, Az); - G4cout << "X1 Y1 corner position : " << A << G4endl; - } - - else if (DataBuffer.compare(0, 8, "X128_Y1=") == 0) { - check_B = true; - ConfigFile >> DataBuffer ; - Bx = atof(DataBuffer.c_str()) ; - Bx = Bx * mm ; - ConfigFile >> DataBuffer ; - By = atof(DataBuffer.c_str()) ; - By = By * mm ; - ConfigFile >> DataBuffer ; - Bz = atof(DataBuffer.c_str()) ; - Bz = Bz * mm ; - - B = G4ThreeVector(Bx, By, Bz); - G4cout << "X128 Y1 corner position : " << B << G4endl; - } - - else if (DataBuffer.compare(0, 8, "X1_Y128=") == 0) { - check_C = true; - ConfigFile >> DataBuffer ; - Cx = atof(DataBuffer.c_str()) ; - Cx = Cx * mm ; - ConfigFile >> DataBuffer ; - Cy = atof(DataBuffer.c_str()) ; - Cy = Cy * mm ; - ConfigFile >> DataBuffer ; - Cz = atof(DataBuffer.c_str()) ; - Cz = Cz * mm ; - - C = G4ThreeVector(Cx, Cy, Cz); - G4cout << "X1 Y128 corner position : " << C << G4endl; - } - - else if (DataBuffer.compare(0, 10, "X128_Y128=") == 0) { - check_D = true; - ConfigFile >> DataBuffer ; - Dx = atof(DataBuffer.c_str()) ; - Dx = Dx * mm ; - ConfigFile >> DataBuffer ; - Dy = atof(DataBuffer.c_str()) ; - Dy = Dy * mm ; - ConfigFile >> DataBuffer ; - Dz = atof(DataBuffer.c_str()) ; - Dz = Dz * mm ; - - D = G4ThreeVector(Dx, Dy, Dz); - G4cout << "X128 Y128 corner position : " << D << G4endl; - } - - - // Angle method - else if (DataBuffer.compare(0, 6, "THETA=") == 0) { - check_Theta = true; - ConfigFile >> DataBuffer ; - Theta = atof(DataBuffer.c_str()) ; - Theta = Theta * deg; - G4cout << "Theta: " << Theta / deg << G4endl; - } - - else if (DataBuffer.compare(0, 4, "PHI=") == 0) { - check_Phi = true; - ConfigFile >> DataBuffer ; - Phi = atof(DataBuffer.c_str()) ; - Phi = Phi * deg; - G4cout << "Phi: " << Phi / deg << G4endl; - } - - else if (DataBuffer.compare(0, 2, "R=") == 0) { - check_R = true; - ConfigFile >> DataBuffer ; - R = atof(DataBuffer.c_str()) ; - R = R * mm; - G4cout << "R: " << R / mm << G4endl; - } - - else if (DataBuffer.compare(0, 5, "BETA=") == 0) { -// check_beta = true; - ConfigFile >> DataBuffer ; - beta_u = atof(DataBuffer.c_str()) ; - beta_u = beta_u * deg ; - ConfigFile >> DataBuffer ; - beta_v = atof(DataBuffer.c_str()) ; - beta_v = beta_v * deg ; - ConfigFile >> DataBuffer ; - beta_w = atof(DataBuffer.c_str()) ; - beta_w = beta_w * deg ; - G4cout << "Beta: " << beta_u / deg << " " << beta_v / deg << " " << beta_w / deg << G4endl ; - } - - else if (DataBuffer.compare(0, 11, "FIRSTSTAGE=") == 0) { - check_FirstStage = true ; - ConfigFile >> DataBuffer; - FIRSTSTAGE = atof(DataBuffer.c_str()) ; - } - - else if (DataBuffer.compare(0, 12, "SECONDSTAGE=") == 0) { - check_SecondStage = true ; - ConfigFile >> DataBuffer; - SECONDSTAGE = atof(DataBuffer.c_str()) ; - } - - else if (DataBuffer.compare(0, 11, "THIRDSTAGE=") == 0) { - check_ThirdStage = true ; - ConfigFile >> DataBuffer; - THIRDSTAGE = atof(DataBuffer.c_str()) ; - } - - else if (DataBuffer.compare(0, 12, "FOURTHSTAGE=") == 0) { - check_FourthStage = true ; - ConfigFile >> DataBuffer; - FOURTHSTAGE = atof(DataBuffer.c_str()) ; - } - - else if (DataBuffer.compare(0, 11, "FIFTHSTAGE=") == 0) { - check_FifthStage = true ; - ConfigFile >> DataBuffer; - FIFTHSTAGE = atof(DataBuffer.c_str()) ; - } - - else if (DataBuffer.compare(0, 11, "SIXTHSTAGE=") == 0) { - check_SixthStage = true ; - ConfigFile >> DataBuffer; - SIXTHSTAGE = atof(DataBuffer.c_str()) ; - } - - else if (DataBuffer.compare(0, 4, "VIS=") == 0) { - checkVis = true ; - ConfigFile >> DataBuffer; - if (DataBuffer.compare(0, 3, "all") == 0) m_non_sensitive_part_visiualisation = true; - } - - else G4cout << "WARNING: Wrong Token, Hyde2TrackerTrapezoid2: Trapezoid2 Element not added" << G4endl; - - //Add The previously define telescope - //With position method - if ((check_A && check_B && check_C && check_D && check_FirstStage && check_SecondStage && check_ThirdStage && check_FourthStage && check_FifthStage && check_SixthStage && checkVis) && !(check_Theta && check_Phi && check_R)) { - - ReadingStatus = false ; - check_A = false ; - check_C = false ; - check_B = false ; - check_D = false ; - check_FirstStage = false ; - check_SecondStage = false ; - check_ThirdStage = false ; - check_FourthStage = false ; - check_FifthStage = false ; - check_SixthStage = false ; - checkVis = false ; - - AddModule(A , - B , - C , - D , - FIRSTSTAGE == 1 , - SECONDSTAGE == 1 , - THIRDSTAGE == 1 , - FOURTHSTAGE == 1 , - FIFTHSTAGE == 1 , - SIXTHSTAGE == 1); - } - - //with angle method - if ((check_Theta && check_Phi && check_R && check_FirstStage && check_SecondStage && check_ThirdStage && check_FourthStage && check_FifthStage && check_SixthStage && checkVis) && !(check_A && check_B && check_C && check_D)) { - ReadingStatus = false ; - check_Theta = false ; - check_Phi = false ; - check_R = false ; -// check_beta = false ; - check_FirstStage = false ; - check_SecondStage = false ; - check_ThirdStage = false ; - check_FourthStage = false ; - check_FifthStage = false ; - check_SixthStage = false ; - checkVis = false ; - - AddModule(R , - Theta , - Phi , - beta_u , - beta_v , - beta_w , - FIRSTSTAGE == 1 , - SECONDSTAGE == 1 , - THIRDSTAGE == 1 , - FOURTHSTAGE == 1 , - FIFTHSTAGE == 1 , - SIXTHSTAGE == 1); - } - - +void Hyde2TrackerTrapezoid2::ReadConfiguration(string Path) { + ifstream ConfigFile; + ConfigFile.open(Path.c_str()); + string LineBuffer; + string DataBuffer; + + // A:X1_Y1 --> X:1 Y:1 + // B:X128_Y1 --> X:128 Y:1 + // C:X1_Y128 --> X:1 Y:128 + // D:X128_Y128 --> X:128 Y:128 + + G4double Ax, Bx, Cx, Dx, Ay, By, Cy, Dy, Az, Bz, Cz, Dz; + G4ThreeVector A, B, C, D; + G4double Theta = 0, Phi = 0, R = 0, beta_u = 0, beta_v = 0, beta_w = 0; + int FIRSTSTAGE = 0, SECONDSTAGE = 0, THIRDSTAGE = 0, FOURTHSTAGE = 0, FIFTHSTAGE = 0, SIXTHSTAGE = 0; + + bool ReadingStatus = false; + + bool check_A = false; + bool check_C = false; + bool check_B = false; + bool check_D = false; + + bool check_Theta = false; + bool check_Phi = false; + bool check_R = false; + // bool check_beta = false ; + + bool check_FirstStage = false; + bool check_SecondStage = false; + bool check_ThirdStage = false; + bool check_FourthStage = false; + bool check_FifthStage = false; + bool check_SixthStage = false; + bool checkVis = false; + + while (!ConfigFile.eof()) { + getline(ConfigFile, LineBuffer); + if (LineBuffer.compare(0, 14, "HYD2Trapezoid2") == 0) { + G4cout << "///" << G4endl; + G4cout << "Trapezoid2 element found: " << G4endl; + ReadingStatus = true; + } + + while (ReadingStatus) { + + ConfigFile >> DataBuffer; + // Comment Line + if (DataBuffer.compare(0, 1, "%") == 0) { /*do nothing */ + ; } - } -} -// Construct detector and inialise sensitive part. -// Called After DetecorConstruction::AddDetector Method -void Hyde2TrackerTrapezoid2::ConstructDetector(G4LogicalVolume* world) -{ - G4RotationMatrix* MMrot = NULL; - G4ThreeVector MMpos = G4ThreeVector(0, 0, 0); - G4ThreeVector MMu = G4ThreeVector(0, 0, 0); - G4ThreeVector MMv = G4ThreeVector(0, 0, 0); - G4ThreeVector MMw = G4ThreeVector(0, 0, 0); - G4ThreeVector MMCenter = G4ThreeVector(0, 0, 0); - - bool FirstStage = true ; - bool SecondStage = true ; - bool ThirdStage = true ; - bool FourthStage = true ; - bool FifthStage = true ; - bool SixthStage = true ; - - G4int NumberOfModule = m_DefinitionType.size() ; - - for (G4int i = 0; i < NumberOfModule; i++) { - // By Point - if (m_DefinitionType[i]) { - // (u,v,w) unitary vector associated to trapezoidal referencial - // (u,v) // to silicon plan - // ------- - // / \ ^ - // / \ | v - // / \ | - // --------------- <------ - // u - // w perpendicular to (u,v) plan and pointing ThirdStage - G4cout << "XXXXXXXXXXXX Trapezoid2 " << i << " XXXXXXXXXXXXX" << G4endl; - MMu = m_X128_Y1[i] - m_X1_Y1[i]; - MMu = MMu.unit(); - G4cout << "MMu: " << MMu << G4endl; - - MMv = 0.5 * (m_X1_Y128[i] + m_X128_Y128[i] - m_X1_Y1[i] - m_X128_Y1[i]); - MMv = MMv.unit(); - G4cout << "MMv: " << MMv << G4endl; - - MMw = MMu.cross(MMv); - MMw = MMw.unit(); - G4cout << "MMw: " << MMw << G4endl; - - // Center of the module - MMCenter = (m_X1_Y1[i] + m_X1_Y128[i] + m_X128_Y1[i] + m_X128_Y128[i]) / 4; - - // Passage Matrix from Lab Referential to Module Referential - MMrot = new G4RotationMatrix(MMu, MMv, MMw); - // translation to place Module - MMpos = MMw * Length * 0.5 + MMCenter; + // Position method + else if (DataBuffer.compare(0, 6, "X1_Y1=") == 0) { + check_A = true; + ConfigFile >> DataBuffer; + Ax = atof(DataBuffer.c_str()); + Ax = Ax * mm; + ConfigFile >> DataBuffer; + Ay = atof(DataBuffer.c_str()); + Ay = Ay * mm; + ConfigFile >> DataBuffer; + Az = atof(DataBuffer.c_str()); + Az = Az * mm; + + A = G4ThreeVector(Ax, Ay, Az); + G4cout << "X1 Y1 corner position : " << A << G4endl; } - // By Angle - else { - G4double Theta = m_Theta[i]; - G4double Phi = m_Phi[i]; - - // (u,v,w) unitary vector associated to telescope referencial - // (u,v) // to silicon plan - // ------- - // / \ ^ - // / \ | v - // / \ | - // --------------- <------ - // u - // w perpendicular to (u,v) plan and pointing ThirdStage - // Phi is angle between X axis and projection in (X,Y) plan - // Theta is angle between position vector and z axis - G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad); - G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad); - G4double wZ = m_R[i] * cos(Theta / rad); - MMw = G4ThreeVector(wX, wY, wZ); - - // vector corresponding to the center of the module - MMCenter = MMw; - - // vector parallel to one axis of silicon plane - // in fact, this is vector u - G4double ii = cos(Theta / rad) * cos(Phi / rad); - G4double jj = cos(Theta / rad) * sin(Phi / rad); - G4double kk = -sin(Theta / rad); - G4ThreeVector Y = G4ThreeVector(ii, jj, kk); - - MMw = MMw.unit(); - MMv = MMw.cross(Y); - MMu = MMv.cross(MMw); - MMv = MMv.unit(); - MMu = MMu.unit(); - - G4cout << "XXXXXXXXXXXX Trapezoid2 " << i << " XXXXXXXXXXXXX" << G4endl; - G4cout << "MMu: " << MMu << G4endl; - G4cout << "MMv: " << MMv << G4endl; - G4cout << "MMw: " << MMw << G4endl; - - // Passage Matrix from Lab Referential to Telescope Referential - MMrot = new G4RotationMatrix(MMu, MMv, MMw); - // Telescope is rotate of Beta angle around MMv axis. - MMrot->rotate(m_beta_u[i], MMu); - MMrot->rotate(m_beta_v[i], MMv); - MMrot->rotate(m_beta_w[i], MMw); - // translation to place Telescope - MMpos = MMw * Length * 0.5 + MMCenter; + else if (DataBuffer.compare(0, 8, "X128_Y1=") == 0) { + check_B = true; + ConfigFile >> DataBuffer; + Bx = atof(DataBuffer.c_str()); + Bx = Bx * mm; + ConfigFile >> DataBuffer; + By = atof(DataBuffer.c_str()); + By = By * mm; + ConfigFile >> DataBuffer; + Bz = atof(DataBuffer.c_str()); + Bz = Bz * mm; + + B = G4ThreeVector(Bx, By, Bz); + G4cout << "X128 Y1 corner position : " << B << G4endl; } - FirstStage = m_wFirstStage[i]; - SecondStage = m_wSecondStage[i]; - ThirdStage = m_wThirdStage[i]; - FourthStage = m_wFourthStage[i]; - FifthStage = m_wFifthStage[i]; - SixthStage = m_wSixthStage[i]; + else if (DataBuffer.compare(0, 8, "X1_Y128=") == 0) { + check_C = true; + ConfigFile >> DataBuffer; + Cx = atof(DataBuffer.c_str()); + Cx = Cx * mm; + ConfigFile >> DataBuffer; + Cy = atof(DataBuffer.c_str()); + Cy = Cy * mm; + ConfigFile >> DataBuffer; + Cz = atof(DataBuffer.c_str()); + Cz = Cz * mm; + + C = G4ThreeVector(Cx, Cy, Cz); + G4cout << "X1 Y128 corner position : " << C << G4endl; + } - VolumeMaker(i + 1, MMpos, MMrot, FirstStage, SecondStage, ThirdStage, FourthStage, FifthStage, SixthStage, world); - } + else if (DataBuffer.compare(0, 10, "X128_Y128=") == 0) { + check_D = true; + ConfigFile >> DataBuffer; + Dx = atof(DataBuffer.c_str()); + Dx = Dx * mm; + ConfigFile >> DataBuffer; + Dy = atof(DataBuffer.c_str()); + Dy = Dy * mm; + ConfigFile >> DataBuffer; + Dz = atof(DataBuffer.c_str()); + Dz = Dz * mm; + + D = G4ThreeVector(Dx, Dy, Dz); + G4cout << "X128 Y128 corner position : " << D << G4endl; + } - delete MMrot; -} + // Angle method + else if (DataBuffer.compare(0, 6, "THETA=") == 0) { + check_Theta = true; + ConfigFile >> DataBuffer; + Theta = atof(DataBuffer.c_str()); + Theta = Theta * deg; + G4cout << "Theta: " << Theta / deg << G4endl; + } + else if (DataBuffer.compare(0, 4, "PHI=") == 0) { + check_Phi = true; + ConfigFile >> DataBuffer; + Phi = atof(DataBuffer.c_str()); + Phi = Phi * deg; + G4cout << "Phi: " << Phi / deg << G4endl; + } + else if (DataBuffer.compare(0, 2, "R=") == 0) { + check_R = true; + ConfigFile >> DataBuffer; + R = atof(DataBuffer.c_str()); + R = R * mm; + G4cout << "R: " << R / mm << G4endl; + } -// Connect the Hyde2TrackingData class to the output TTree -// of the simulation -void Hyde2TrackerTrapezoid2::InitializeRootOutput() -{ -} + else if (DataBuffer.compare(0, 5, "BETA=") == 0) { + // check_beta = true; + ConfigFile >> DataBuffer; + beta_u = atof(DataBuffer.c_str()); + beta_u = beta_u * deg; + ConfigFile >> DataBuffer; + beta_v = atof(DataBuffer.c_str()); + beta_v = beta_v * deg; + ConfigFile >> DataBuffer; + beta_w = atof(DataBuffer.c_str()); + beta_w = beta_w * deg; + G4cout << "Beta: " << beta_u / deg << " " << beta_v / deg << " " << beta_w / deg << G4endl; + } + else if (DataBuffer.compare(0, 11, "FIRSTSTAGE=") == 0) { + check_FirstStage = true; + ConfigFile >> DataBuffer; + FIRSTSTAGE = atof(DataBuffer.c_str()); + } + else if (DataBuffer.compare(0, 12, "SECONDSTAGE=") == 0) { + check_SecondStage = true; + ConfigFile >> DataBuffer; + SECONDSTAGE = atof(DataBuffer.c_str()); + } -// Set the TinteractionCoordinates object from NPS::VDetector to the present class -void Hyde2TrackerTrapezoid2::SetInterCoordPointer(TInteractionCoordinates* interCoord) -{ - ms_InterCoord = interCoord; + else if (DataBuffer.compare(0, 11, "THIRDSTAGE=") == 0) { + check_ThirdStage = true; + ConfigFile >> DataBuffer; + THIRDSTAGE = atof(DataBuffer.c_str()); + } + + else if (DataBuffer.compare(0, 12, "FOURTHSTAGE=") == 0) { + check_FourthStage = true; + ConfigFile >> DataBuffer; + FOURTHSTAGE = atof(DataBuffer.c_str()); + } + + else if (DataBuffer.compare(0, 11, "FIFTHSTAGE=") == 0) { + check_FifthStage = true; + ConfigFile >> DataBuffer; + FIFTHSTAGE = atof(DataBuffer.c_str()); + } + + else if (DataBuffer.compare(0, 11, "SIXTHSTAGE=") == 0) { + check_SixthStage = true; + ConfigFile >> DataBuffer; + SIXTHSTAGE = atof(DataBuffer.c_str()); + } + + else if (DataBuffer.compare(0, 4, "VIS=") == 0) { + checkVis = true; + ConfigFile >> DataBuffer; + if (DataBuffer.compare(0, 3, "all") == 0) + m_non_sensitive_part_visiualisation = true; + } + + else + G4cout << "WARNING: Wrong Token, Hyde2TrackerTrapezoid2: Trapezoid2 Element not added" << G4endl; + + // Add The previously define telescope + // With position method + if ((check_A && check_B && check_C && check_D && check_FirstStage && check_SecondStage && check_ThirdStage && + check_FourthStage && check_FifthStage && check_SixthStage && checkVis) && + !(check_Theta && check_Phi && check_R)) { + + ReadingStatus = false; + check_A = false; + check_C = false; + check_B = false; + check_D = false; + check_FirstStage = false; + check_SecondStage = false; + check_ThirdStage = false; + check_FourthStage = false; + check_FifthStage = false; + check_SixthStage = false; + checkVis = false; + + AddModule(A, B, C, D, FIRSTSTAGE == 1, SECONDSTAGE == 1, THIRDSTAGE == 1, FOURTHSTAGE == 1, FIFTHSTAGE == 1, + SIXTHSTAGE == 1); + } + + // with angle method + if ((check_Theta && check_Phi && check_R && check_FirstStage && check_SecondStage && check_ThirdStage && + check_FourthStage && check_FifthStage && check_SixthStage && checkVis) && + !(check_A && check_B && check_C && check_D)) { + ReadingStatus = false; + check_Theta = false; + check_Phi = false; + check_R = false; + // check_beta = false ; + check_FirstStage = false; + check_SecondStage = false; + check_ThirdStage = false; + check_FourthStage = false; + check_FifthStage = false; + check_SixthStage = false; + checkVis = false; + + AddModule(R, Theta, Phi, beta_u, beta_v, beta_w, FIRSTSTAGE == 1, SECONDSTAGE == 1, THIRDSTAGE == 1, + FOURTHSTAGE == 1, FIFTHSTAGE == 1, SIXTHSTAGE == 1); + } + } + } } +// Construct detector and inialise sensitive part. +// Called After DetecorConstruction::AddDetector Method +void Hyde2TrackerTrapezoid2::ConstructDetector(G4LogicalVolume* world) { + G4RotationMatrix* MMrot = NULL; + G4ThreeVector MMpos = G4ThreeVector(0, 0, 0); + G4ThreeVector MMu = G4ThreeVector(0, 0, 0); + G4ThreeVector MMv = G4ThreeVector(0, 0, 0); + G4ThreeVector MMw = G4ThreeVector(0, 0, 0); + G4ThreeVector MMCenter = G4ThreeVector(0, 0, 0); + + bool FirstStage = true; + bool SecondStage = true; + bool ThirdStage = true; + bool FourthStage = true; + bool FifthStage = true; + bool SixthStage = true; + + G4int NumberOfModule = m_DefinitionType.size(); + + for (G4int i = 0; i < NumberOfModule; i++) { + // By Point + if (m_DefinitionType[i]) { + // (u,v,w) unitary vector associated to trapezoidal referencial + // (u,v) // to silicon plan + // ------- + // / \ ^ + // / \ | v + // / \ | + // --------------- <------ + // u + // w perpendicular to (u,v) plan and pointing ThirdStage + G4cout << "XXXXXXXXXXXX Trapezoid2 " << i << " XXXXXXXXXXXXX" << G4endl; + MMu = m_X128_Y1[i] - m_X1_Y1[i]; + MMu = MMu.unit(); + G4cout << "MMu: " << MMu << G4endl; + + MMv = 0.5 * (m_X1_Y128[i] + m_X128_Y128[i] - m_X1_Y1[i] - m_X128_Y1[i]); + MMv = MMv.unit(); + G4cout << "MMv: " << MMv << G4endl; + + MMw = MMu.cross(MMv); + MMw = MMw.unit(); + G4cout << "MMw: " << MMw << G4endl; + + // Center of the module + MMCenter = (m_X1_Y1[i] + m_X1_Y128[i] + m_X128_Y1[i] + m_X128_Y128[i]) / 4; + + // Passage Matrix from Lab Referential to Module Referential + MMrot = new G4RotationMatrix(MMu, MMv, MMw); + // translation to place Module + MMpos = MMw * Length * 0.5 + MMCenter; + } + + // By Angle + else { + G4double Theta = m_Theta[i]; + G4double Phi = m_Phi[i]; + + // (u,v,w) unitary vector associated to telescope referencial + // (u,v) // to silicon plan + // ------- + // / \ ^ + // / \ | v + // / \ | + // --------------- <------ + // u + // w perpendicular to (u,v) plan and pointing ThirdStage + // Phi is angle between X axis and projection in (X,Y) plan + // Theta is angle between position vector and z axis + G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad); + G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad); + G4double wZ = m_R[i] * cos(Theta / rad); + MMw = G4ThreeVector(wX, wY, wZ); + + // vector corresponding to the center of the module + MMCenter = MMw; + + // vector parallel to one axis of silicon plane + // in fact, this is vector u + G4double ii = cos(Theta / rad) * cos(Phi / rad); + G4double jj = cos(Theta / rad) * sin(Phi / rad); + G4double kk = -sin(Theta / rad); + G4ThreeVector Y = G4ThreeVector(ii, jj, kk); + + MMw = MMw.unit(); + MMv = MMw.cross(Y); + MMu = MMv.cross(MMw); + MMv = MMv.unit(); + MMu = MMu.unit(); + + G4cout << "XXXXXXXXXXXX Trapezoid2 " << i << " XXXXXXXXXXXXX" << G4endl; + G4cout << "MMu: " << MMu << G4endl; + G4cout << "MMv: " << MMv << G4endl; + G4cout << "MMw: " << MMw << G4endl; + + // Passage Matrix from Lab Referential to Telescope Referential + MMrot = new G4RotationMatrix(MMu, MMv, MMw); + // Telescope is rotate of Beta angle around MMv axis. + MMrot->rotate(m_beta_u[i], MMu); + MMrot->rotate(m_beta_v[i], MMv); + MMrot->rotate(m_beta_w[i], MMw); + // translation to place Telescope + MMpos = MMw * Length * 0.5 + MMCenter; + } + + FirstStage = m_wFirstStage[i]; + SecondStage = m_wSecondStage[i]; + ThirdStage = m_wThirdStage[i]; + FourthStage = m_wFourthStage[i]; + FifthStage = m_wFifthStage[i]; + SixthStage = m_wSixthStage[i]; + + VolumeMaker(i + 1, MMpos, MMrot, FirstStage, SecondStage, ThirdStage, FourthStage, FifthStage, SixthStage, world); + } + + delete MMrot; +} +// Connect the Hyde2TrackingData class to the output TTree +// of the simulation +void Hyde2TrackerTrapezoid2::InitializeRootOutput() {} + +// Set the TinteractionCoordinates object from NPS::VDetector to the present class +void Hyde2TrackerTrapezoid2::SetInterCoordPointer(TInteractionCoordinates* interCoord) { ms_InterCoord = interCoord; } // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Hyde2TrackerTrapezoid2::ReadSensitive(const G4Event* event) -{ -////////////////////////////////////////////////////////////////////////////////////// -//////////////////////// Used to Read Event Map of detector ////////////////////////// -////////////////////////////////////////////////////////////////////////////////////// - // First Stage - std::map<G4int, G4int*>::iterator DetectorNumber_itr; - std::map<G4int, G4double*>::iterator Energy_itr; - std::map<G4int, G4double*>::iterator Time_itr; - std::map<G4int, G4double*>::iterator X_itr; - std::map<G4int, G4double*>::iterator Y_itr; - std::map<G4int, G4double*>::iterator Pos_X_itr; - std::map<G4int, G4double*>::iterator Pos_Y_itr; - std::map<G4int, G4double*>::iterator Pos_Z_itr; - std::map<G4int, G4double*>::iterator Ang_Theta_itr; - std::map<G4int, G4double*>::iterator Ang_Phi_itr; - - G4THitsMap<G4int>* DetectorNumberHitMap; - G4THitsMap<G4double>* EnergyHitMap; - G4THitsMap<G4double>* TimeHitMap; - G4THitsMap<G4double>* XHitMap; - G4THitsMap<G4double>* YHitMap; - G4THitsMap<G4double>* PosXHitMap; - G4THitsMap<G4double>* PosYHitMap; - G4THitsMap<G4double>* PosZHitMap; - G4THitsMap<G4double>* AngThetaHitMap; - G4THitsMap<G4double>* AngPhiHitMap; - - // NULL pointer are given to avoid warning at compilation - // Second Stage - std::map<G4int, G4double*>::iterator SecondStageEnergy_itr; - G4THitsMap<G4double>* SecondStageEnergyHitMap = NULL; - // Third Stage - std::map<G4int, G4double*>::iterator ThirdStageEnergy_itr; - G4THitsMap<G4double>* ThirdStageEnergyHitMap = NULL; - - // Fourth Stage - std::map<G4int, G4double*>::iterator FourthStageEnergy_itr; - G4THitsMap<G4double>* FourthStageEnergyHitMap = NULL; - - // Fifth Stage - std::map<G4int, G4double*>::iterator FifthStageEnergy_itr; - G4THitsMap<G4double>* FifthStageEnergyHitMap = NULL; - - // Sixth Stage - std::map<G4int, G4double*>::iterator SixthStageEnergy_itr; - G4THitsMap<G4double>* SixthStageEnergyHitMap = NULL; - - // Read the Scorer associated to the first Stage - //Detector Number - G4int StripDetCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/DetectorNumber") ; - DetectorNumberHitMap = (G4THitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripDetCollectionID)) ; - DetectorNumber_itr = DetectorNumberHitMap->GetMap()->begin() ; - - //Energy - G4int StripEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/StripEnergy") ; - EnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripEnergyCollectionID)) ; - Energy_itr = EnergyHitMap->GetMap()->begin() ; - - //Time of Flight - G4int StripTimeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/StripTime") ; - TimeHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripTimeCollectionID)) ; - Time_itr = TimeHitMap->GetMap()->begin() ; - - //Strip Number X - G4int StripXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/StripNumberX") ; - XHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripXCollectionID)) ; - X_itr = XHitMap->GetMap()->begin() ; - - //Strip Number Y - G4int StripYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/StripNumberY") ; - YHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripYCollectionID)) ; - Y_itr = YHitMap->GetMap()->begin() ; - - //Interaction Coordinate X - G4int InterCoordXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/InterCoordX") ; - PosXHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordXCollectionID)) ; - Pos_X_itr = PosXHitMap->GetMap()->begin() ; - - //Interaction Coordinate Y - G4int InterCoordYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/InterCoordY") ; - PosYHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordYCollectionID)) ; - Pos_Y_itr = PosYHitMap->GetMap()->begin() ; - - //Interaction Coordinate Z - G4int InterCoordZCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/InterCoordZ") ; - PosZHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordZCollectionID)) ; - Pos_Z_itr = PosXHitMap->GetMap()->begin() ; - - //Interaction Coordinate Angle Theta - G4int InterCoordAngThetaCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/InterCoordAngTheta") ; - AngThetaHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngThetaCollectionID)) ; - Ang_Theta_itr = AngThetaHitMap->GetMap()->begin() ; - - //Interaction Coordinate Angle Phi - G4int InterCoordAngPhiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/InterCoordAngPhi") ; - AngPhiHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngPhiCollectionID)) ; - Ang_Phi_itr = AngPhiHitMap->GetMap()->begin() ; - - // Read the Scorer associated to the Second and Third Stage - // Energy second stage - G4int SecondStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("SecondStageScorerHYD2Trapezoid2/SecondStageEnergy") ; - SecondStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(SecondStageEnergyCollectionID)) ; - SecondStageEnergy_itr = SecondStageEnergyHitMap->GetMap()->begin() ; - // Energy third stage - G4int ThirdStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ThirdStageScorerHYD2Trapezoid2/ThirdStageEnergy") ; - ThirdStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(ThirdStageEnergyCollectionID)) ; - ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin() ; - // Energy Fourth stage - G4int FourthStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FourthStageScorerHYD2Trapezoid2/FourthStageEnergy") ; - FourthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(FourthStageEnergyCollectionID)) ; - FourthStageEnergy_itr = FourthStageEnergyHitMap->GetMap()->begin() ; - // Energy Fifth stage - G4int FifthStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FifthStageScorerHYD2Trapezoid2/FifthStageEnergy") ; - FifthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(FifthStageEnergyCollectionID)) ; - FifthStageEnergy_itr = FifthStageEnergyHitMap->GetMap()->begin() ; - // Energy Sixth stage - G4int SixthStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("SixthStageScorerHYD2Trapezoid2/SixthStageEnergy") ; - SixthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(SixthStageEnergyCollectionID)) ; - SixthStageEnergy_itr = SixthStageEnergyHitMap->GetMap()->begin() ; - - // Check the size of different map - G4int sizeN = DetectorNumberHitMap->entries(); - G4int sizeE = EnergyHitMap->entries(); - G4int sizeT = TimeHitMap->entries(); - G4int sizeX = XHitMap->entries(); - G4int sizeY = YHitMap->entries(); - - if (sizeE != sizeT || sizeT != sizeX || sizeX != sizeY) { - G4cout << "No match size Si Event Map: sE:" - << sizeE << " sT:" << sizeT << " sX:" << sizeX << " sY:" << sizeY << G4endl ; - return; +void Hyde2TrackerTrapezoid2::ReadSensitive(const G4Event* event) { + ////////////////////////////////////////////////////////////////////////////////////// + //////////////////////// Used to Read Event Map of detector ////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + // First Stage + std::map<G4int, G4int*>::iterator DetectorNumber_itr; + std::map<G4int, G4double*>::iterator Energy_itr; + std::map<G4int, G4double*>::iterator Time_itr; + std::map<G4int, G4double*>::iterator X_itr; + std::map<G4int, G4double*>::iterator Y_itr; + std::map<G4int, G4double*>::iterator Pos_X_itr; + std::map<G4int, G4double*>::iterator Pos_Y_itr; + std::map<G4int, G4double*>::iterator Pos_Z_itr; + std::map<G4int, G4double*>::iterator Ang_Theta_itr; + std::map<G4int, G4double*>::iterator Ang_Phi_itr; + + G4THitsMap<G4int>* DetectorNumberHitMap; + G4THitsMap<G4double>* EnergyHitMap; + G4THitsMap<G4double>* TimeHitMap; + G4THitsMap<G4double>* XHitMap; + G4THitsMap<G4double>* YHitMap; + G4THitsMap<G4double>* PosXHitMap; + G4THitsMap<G4double>* PosYHitMap; + G4THitsMap<G4double>* PosZHitMap; + G4THitsMap<G4double>* AngThetaHitMap; + G4THitsMap<G4double>* AngPhiHitMap; + + // NULL pointer are given to avoid warning at compilation + // Second Stage + std::map<G4int, G4double*>::iterator SecondStageEnergy_itr; + G4THitsMap<G4double>* SecondStageEnergyHitMap = NULL; + // Third Stage + std::map<G4int, G4double*>::iterator ThirdStageEnergy_itr; + G4THitsMap<G4double>* ThirdStageEnergyHitMap = NULL; + + // Fourth Stage + std::map<G4int, G4double*>::iterator FourthStageEnergy_itr; + G4THitsMap<G4double>* FourthStageEnergyHitMap = NULL; + + // Fifth Stage + std::map<G4int, G4double*>::iterator FifthStageEnergy_itr; + G4THitsMap<G4double>* FifthStageEnergyHitMap = NULL; + + // Sixth Stage + std::map<G4int, G4double*>::iterator SixthStageEnergy_itr; + G4THitsMap<G4double>* SixthStageEnergyHitMap = NULL; + + // Read the Scorer associated to the first Stage + // Detector Number + G4int StripDetCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/DetectorNumber"); + DetectorNumberHitMap = (G4THitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripDetCollectionID)); + DetectorNumber_itr = DetectorNumberHitMap->GetMap()->begin(); + + // Energy + G4int StripEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/StripEnergy"); + EnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripEnergyCollectionID)); + Energy_itr = EnergyHitMap->GetMap()->begin(); + + // Time of Flight + G4int StripTimeCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/StripTime"); + TimeHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripTimeCollectionID)); + Time_itr = TimeHitMap->GetMap()->begin(); + + // Strip Number X + G4int StripXCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/StripNumberX"); + XHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripXCollectionID)); + X_itr = XHitMap->GetMap()->begin(); + + // Strip Number Y + G4int StripYCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/StripNumberY"); + YHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripYCollectionID)); + Y_itr = YHitMap->GetMap()->begin(); + + // Interaction Coordinate X + G4int InterCoordXCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/InterCoordX"); + PosXHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordXCollectionID)); + Pos_X_itr = PosXHitMap->GetMap()->begin(); + + // Interaction Coordinate Y + G4int InterCoordYCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/InterCoordY"); + PosYHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordYCollectionID)); + Pos_Y_itr = PosYHitMap->GetMap()->begin(); + + // Interaction Coordinate Z + G4int InterCoordZCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/InterCoordZ"); + PosZHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordZCollectionID)); + Pos_Z_itr = PosXHitMap->GetMap()->begin(); + + // Interaction Coordinate Angle Theta + G4int InterCoordAngThetaCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/InterCoordAngTheta"); + AngThetaHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngThetaCollectionID)); + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); + + // Interaction Coordinate Angle Phi + G4int InterCoordAngPhiCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/InterCoordAngPhi"); + AngPhiHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngPhiCollectionID)); + Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); + + // Read the Scorer associated to the Second and Third Stage + // Energy second stage + G4int SecondStageEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("SecondStageScorerHYD2Trapezoid2/SecondStageEnergy"); + SecondStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(SecondStageEnergyCollectionID)); + SecondStageEnergy_itr = SecondStageEnergyHitMap->GetMap()->begin(); + // Energy third stage + G4int ThirdStageEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("ThirdStageScorerHYD2Trapezoid2/ThirdStageEnergy"); + ThirdStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(ThirdStageEnergyCollectionID)); + ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin(); + // Energy Fourth stage + G4int FourthStageEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FourthStageScorerHYD2Trapezoid2/FourthStageEnergy"); + FourthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(FourthStageEnergyCollectionID)); + FourthStageEnergy_itr = FourthStageEnergyHitMap->GetMap()->begin(); + // Energy Fifth stage + G4int FifthStageEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FifthStageScorerHYD2Trapezoid2/FifthStageEnergy"); + FifthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(FifthStageEnergyCollectionID)); + FifthStageEnergy_itr = FifthStageEnergyHitMap->GetMap()->begin(); + // Energy Sixth stage + G4int SixthStageEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("SixthStageScorerHYD2Trapezoid2/SixthStageEnergy"); + SixthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(SixthStageEnergyCollectionID)); + SixthStageEnergy_itr = SixthStageEnergyHitMap->GetMap()->begin(); + + // Check the size of different map + G4int sizeN = DetectorNumberHitMap->entries(); + G4int sizeE = EnergyHitMap->entries(); + G4int sizeT = TimeHitMap->entries(); + G4int sizeX = XHitMap->entries(); + G4int sizeY = YHitMap->entries(); + + if (sizeE != sizeT || sizeT != sizeX || sizeX != sizeY) { + G4cout << "No match size Si Event Map: sE:" << sizeE << " sT:" << sizeT << " sX:" << sizeX << " sY:" << sizeY + << G4endl; + return; + } + + // Loop on FirstStage number + for (G4int l = 0; l < sizeN; l++) { + G4double N = *(DetectorNumber_itr->second); + G4int NTrackID = DetectorNumber_itr->first - N; + + if (N > 0) { + // Fill detector number + ms_Event->SetHYD2TrkFirstStageFrontEDetectorNbr(m_index["Trapezoid2"] + N); + ms_Event->SetHYD2TrkFirstStageFrontTDetectorNbr(m_index["Trapezoid2"] + N); + ms_Event->SetHYD2TrkFirstStageBackEDetectorNbr(m_index["Trapezoid2"] + N); + ms_Event->SetHYD2TrkFirstStageBackTDetectorNbr(m_index["Trapezoid2"] + N); + + // Energy + for (G4int ll = 0; ll < sizeE; ll++) { + G4int ETrackID = Energy_itr->first - N; + G4double E = *(Energy_itr->second); + if (ETrackID == NTrackID) { + ms_Event->SetHYD2TrkFirstStageFrontEEnergy(RandGauss::shoot(E, ResoFirstStage)); + ms_Event->SetHYD2TrkFirstStageBackEEnergy(RandGauss::shoot(E, ResoFirstStage)); + } + Energy_itr++; } - // Loop on FirstStage number - for (G4int l = 0; l < sizeN; l++) { - G4double N = *(DetectorNumber_itr->second); - G4int NTrackID = DetectorNumber_itr->first - N; - - if (N > 0) { - // Fill detector number - ms_Event->SetHYD2TrkFirstStageFrontEDetectorNbr(m_index["Trapezoid2"] + N); - ms_Event->SetHYD2TrkFirstStageFrontTDetectorNbr(m_index["Trapezoid2"] + N); - ms_Event->SetHYD2TrkFirstStageBackEDetectorNbr(m_index["Trapezoid2"] + N); - ms_Event->SetHYD2TrkFirstStageBackTDetectorNbr(m_index["Trapezoid2"] + N); - - // Energy - for (G4int ll = 0 ; ll < sizeE ; ll++) { - G4int ETrackID = Energy_itr->first - N; - G4double E = *(Energy_itr->second); - if (ETrackID == NTrackID) { - ms_Event->SetHYD2TrkFirstStageFrontEEnergy(RandGauss::shoot(E, ResoFirstStage)); - ms_Event->SetHYD2TrkFirstStageBackEEnergy(RandGauss::shoot(E, ResoFirstStage)); - } - Energy_itr++; - } - - // Time - Time_itr = TimeHitMap->GetMap()->begin(); - for (G4int h = 0 ; h < sizeT ; h++) { - G4int TTrackID = Time_itr->first - N; - G4double T = *(Time_itr->second); - - if (TTrackID == NTrackID) { - T = RandGauss::shoot(T, ResoTimePPAC) ; - ms_Event->SetHYD2TrkFirstStageFrontTTime(RandGauss::shoot(T, ResoTimeHyd2)) ; - ms_Event->SetHYD2TrkFirstStageBackTTime(RandGauss::shoot(T, ResoTimeHyd2)) ; - } - Time_itr++; - } - - // X - X_itr = XHitMap->GetMap()->begin(); - for (G4int h = 0 ; h < sizeX ; h++) { - G4int XTrackID = X_itr->first - N; - G4double X = *(X_itr->second); - if (XTrackID == NTrackID) { - ms_Event->SetHYD2TrkFirstStageFrontEStripNbr(X); - ms_Event->SetHYD2TrkFirstStageFrontTStripNbr(X); - } - - X_itr++; - } - - // Y - Y_itr = YHitMap->GetMap()->begin() ; - for (G4int h = 0 ; h < sizeY ; h++) { - G4int YTrackID = Y_itr->first - N; - G4double Y = *(Y_itr->second); - if (YTrackID == NTrackID) { - ms_Event->SetHYD2TrkFirstStageBackEStripNbr(Y); - ms_Event->SetHYD2TrkFirstStageBackTStripNbr(Y); - } - - Y_itr++; - } - - // Pos X - Pos_X_itr = PosXHitMap->GetMap()->begin(); - for (unsigned int h = 0; h < PosXHitMap->entries(); h++) { - G4int PosXTrackID = Pos_X_itr->first - N ; - G4double PosX = *(Pos_X_itr->second) ; - if (PosXTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionX(PosX) ; - } - Pos_X_itr++; - } - - // Pos Y - Pos_Y_itr = PosYHitMap->GetMap()->begin(); - for (unsigned int h = 0; h < PosYHitMap->entries(); h++) { - G4int PosYTrackID = Pos_Y_itr->first - N ; - G4double PosY = *(Pos_Y_itr->second) ; - if (PosYTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionY(PosY) ; - } - Pos_Y_itr++; - } - - // Pos Z - Pos_Z_itr = PosZHitMap->GetMap()->begin(); - for (unsigned int h = 0; h < PosZHitMap->entries(); h++) { - G4int PosZTrackID = Pos_Z_itr->first - N ; - G4double PosZ = *(Pos_Z_itr->second) ; - if (PosZTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionZ(PosZ) ; - } - Pos_Z_itr++; - } - - // Angle Theta - Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); - for (unsigned int h = 0; h < AngThetaHitMap->entries(); h++) { - G4int AngThetaTrackID = Ang_Theta_itr->first - N ; - G4double AngTheta = *(Ang_Theta_itr->second) ; - if (AngThetaTrackID == NTrackID) { - ms_InterCoord->SetDetectedAngleTheta(AngTheta) ; - } - Ang_Theta_itr++; - } - - // Angle Phi - Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); - for (unsigned int h = 0; h < AngPhiHitMap->entries(); h++) { - G4int AngPhiTrackID = Ang_Phi_itr->first - N ; - G4double AngPhi = *(Ang_Phi_itr->second) ; - if (AngPhiTrackID == NTrackID) { - ms_InterCoord->SetDetectedAnglePhi(AngPhi) ; - } - Ang_Phi_itr++; - } - - // Second Stage - SecondStageEnergy_itr = SecondStageEnergyHitMap->GetMap()->begin() ; - for (unsigned int h = 0 ; h < SecondStageEnergyHitMap->entries() ; h++) { - G4int SecondStageEnergyTrackID = SecondStageEnergy_itr->first - N; - G4double SecondStageEnergy = *(SecondStageEnergy_itr->second); - - if (SecondStageEnergyTrackID == NTrackID) { - ms_Event->SetHYD2TrkSecondStageEEnergy(RandGauss::shoot(SecondStageEnergy, ResoSecondStage)); - ms_Event->SetHYD2TrkSecondStageEPadNbr(1); - ms_Event->SetHYD2TrkSecondStageTPadNbr(1); - ms_Event->SetHYD2TrkSecondStageTTime(1); - ms_Event->SetHYD2TrkSecondStageTDetectorNbr(m_index["Trapezoid2"] + N); - ms_Event->SetHYD2TrkSecondStageEDetectorNbr(m_index["Trapezoid2"] + N); - } - - SecondStageEnergy_itr++; - } - - // Third Stage - ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin() ; - for (unsigned int h = 0 ; h < ThirdStageEnergyHitMap->entries() ; h++) { - G4int ThirdStageEnergyTrackID = ThirdStageEnergy_itr->first - N; - G4double ThirdStageEnergy = *(ThirdStageEnergy_itr->second); - - if (ThirdStageEnergyTrackID == NTrackID) { - ms_Event->SetHYD2TrkThirdStageEEnergy(RandGauss::shoot(ThirdStageEnergy, ResoThirdStage)); - ms_Event->SetHYD2TrkThirdStageEPadNbr(1); - ms_Event->SetHYD2TrkThirdStageTPadNbr(1); - ms_Event->SetHYD2TrkThirdStageTTime(1); - ms_Event->SetHYD2TrkThirdStageTDetectorNbr(m_index["Trapezoid2"] + N); - ms_Event->SetHYD2TrkThirdStageEDetectorNbr(m_index["Trapezoid2"] + N); - } - - ThirdStageEnergy_itr++; - } - - // Fourth Stage - FourthStageEnergy_itr = FourthStageEnergyHitMap->GetMap()->begin() ; - for (unsigned int h = 0 ; h < FourthStageEnergyHitMap->entries() ; h++) { - G4int FourthStageEnergyTrackID = FourthStageEnergy_itr->first - N; - G4double FourthStageEnergy = *(FourthStageEnergy_itr->second); - - if (FourthStageEnergyTrackID == NTrackID) { - ms_Event->SetHYD2TrkFourthStageEEnergy(RandGauss::shoot(FourthStageEnergy, ResoFourthStage)); - ms_Event->SetHYD2TrkFourthStageEPadNbr(1); - ms_Event->SetHYD2TrkFourthStageTPadNbr(1); - ms_Event->SetHYD2TrkFourthStageTTime(1); - ms_Event->SetHYD2TrkFourthStageTDetectorNbr(m_index["Trapezoid2"] + N); - ms_Event->SetHYD2TrkFourthStageEDetectorNbr(m_index["Trapezoid2"] + N); - } - - FourthStageEnergy_itr++; - } - - // Fifth Stage - FifthStageEnergy_itr = FifthStageEnergyHitMap->GetMap()->begin() ; - for (unsigned int h = 0 ; h < FifthStageEnergyHitMap->entries() ; h++) { - G4int FifthStageEnergyTrackID = FifthStageEnergy_itr->first - N; - G4double FifthStageEnergy = *(FifthStageEnergy_itr->second); - - if (FifthStageEnergyTrackID == NTrackID) { - ms_Event->SetHYD2TrkFifthStageEEnergy(RandGauss::shoot(FifthStageEnergy, ResoFifthStage)); - ms_Event->SetHYD2TrkFifthStageEPadNbr(1); - ms_Event->SetHYD2TrkFifthStageTPadNbr(1); - ms_Event->SetHYD2TrkFifthStageTTime(1); - ms_Event->SetHYD2TrkFifthStageTDetectorNbr(m_index["Trapezoid2"] + N); - ms_Event->SetHYD2TrkFifthStageEDetectorNbr(m_index["Trapezoid2"] + N); - } - - FifthStageEnergy_itr++; - } - - // Sixth Stage - SixthStageEnergy_itr = SixthStageEnergyHitMap->GetMap()->begin() ; - for (unsigned int h = 0 ; h < SixthStageEnergyHitMap->entries() ; h++) { - G4int SixthStageEnergyTrackID = SixthStageEnergy_itr->first - N; - G4double SixthStageEnergy = *(SixthStageEnergy_itr->second); - - if (SixthStageEnergyTrackID == NTrackID) { - ms_Event->SetHYD2TrkSixthStageEEnergy(RandGauss::shoot(SixthStageEnergy, ResoSixthStage)); - ms_Event->SetHYD2TrkSixthStageEPadNbr(1); - ms_Event->SetHYD2TrkSixthStageTPadNbr(1); - ms_Event->SetHYD2TrkSixthStageTTime(1); - ms_Event->SetHYD2TrkSixthStageTDetectorNbr(m_index["Trapezoid2"] + N); - ms_Event->SetHYD2TrkSixthStageEDetectorNbr(m_index["Trapezoid2"] + N); - } - - SixthStageEnergy_itr++; - } - - DetectorNumber_itr++; + // Time + Time_itr = TimeHitMap->GetMap()->begin(); + for (G4int h = 0; h < sizeT; h++) { + G4int TTrackID = Time_itr->first - N; + G4double T = *(Time_itr->second); + + if (TTrackID == NTrackID) { + T = RandGauss::shoot(T, ResoTimePPAC); + ms_Event->SetHYD2TrkFirstStageFrontTTime(RandGauss::shoot(T, ResoTimeHyd2)); + ms_Event->SetHYD2TrkFirstStageBackTTime(RandGauss::shoot(T, ResoTimeHyd2)); + } + Time_itr++; } - // clear map for next event - DetectorNumberHitMap ->clear(); - EnergyHitMap ->clear(); - TimeHitMap ->clear(); - XHitMap ->clear(); - YHitMap ->clear(); - PosXHitMap ->clear(); - PosYHitMap ->clear(); - PosZHitMap ->clear(); - AngThetaHitMap ->clear(); - AngPhiHitMap ->clear(); - SecondStageEnergyHitMap ->clear(); - ThirdStageEnergyHitMap ->clear(); - FourthStageEnergyHitMap ->clear(); - FifthStageEnergyHitMap ->clear(); - SixthStageEnergyHitMap ->clear(); - } -} + // X + X_itr = XHitMap->GetMap()->begin(); + for (G4int h = 0; h < sizeX; h++) { + G4int XTrackID = X_itr->first - N; + G4double X = *(X_itr->second); + if (XTrackID == NTrackID) { + ms_Event->SetHYD2TrkFirstStageFrontEStripNbr(X); + ms_Event->SetHYD2TrkFirstStageFrontTStripNbr(X); + } + + X_itr++; + } + // Y + Y_itr = YHitMap->GetMap()->begin(); + for (G4int h = 0; h < sizeY; h++) { + G4int YTrackID = Y_itr->first - N; + G4double Y = *(Y_itr->second); + if (YTrackID == NTrackID) { + ms_Event->SetHYD2TrkFirstStageBackEStripNbr(Y); + ms_Event->SetHYD2TrkFirstStageBackTStripNbr(Y); + } + + Y_itr++; + } + + // Pos X + Pos_X_itr = PosXHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < PosXHitMap->entries(); h++) { + G4int PosXTrackID = Pos_X_itr->first - N; + G4double PosX = *(Pos_X_itr->second); + if (PosXTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionX(PosX); + } + Pos_X_itr++; + } + + // Pos Y + Pos_Y_itr = PosYHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < PosYHitMap->entries(); h++) { + G4int PosYTrackID = Pos_Y_itr->first - N; + G4double PosY = *(Pos_Y_itr->second); + if (PosYTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionY(PosY); + } + Pos_Y_itr++; + } + + // Pos Z + Pos_Z_itr = PosZHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < PosZHitMap->entries(); h++) { + G4int PosZTrackID = Pos_Z_itr->first - N; + G4double PosZ = *(Pos_Z_itr->second); + if (PosZTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionZ(PosZ); + } + Pos_Z_itr++; + } + + // Angle Theta + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < AngThetaHitMap->entries(); h++) { + G4int AngThetaTrackID = Ang_Theta_itr->first - N; + G4double AngTheta = *(Ang_Theta_itr->second); + if (AngThetaTrackID == NTrackID) { + ms_InterCoord->SetDetectedAngleTheta(AngTheta); + } + Ang_Theta_itr++; + } + + // Angle Phi + Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < AngPhiHitMap->entries(); h++) { + G4int AngPhiTrackID = Ang_Phi_itr->first - N; + G4double AngPhi = *(Ang_Phi_itr->second); + if (AngPhiTrackID == NTrackID) { + ms_InterCoord->SetDetectedAnglePhi(AngPhi); + } + Ang_Phi_itr++; + } + // Second Stage + SecondStageEnergy_itr = SecondStageEnergyHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < SecondStageEnergyHitMap->entries(); h++) { + G4int SecondStageEnergyTrackID = SecondStageEnergy_itr->first - N; + G4double SecondStageEnergy = *(SecondStageEnergy_itr->second); + + if (SecondStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkSecondStageEEnergy(RandGauss::shoot(SecondStageEnergy, ResoSecondStage)); + ms_Event->SetHYD2TrkSecondStageEPadNbr(1); + ms_Event->SetHYD2TrkSecondStageTPadNbr(1); + ms_Event->SetHYD2TrkSecondStageTTime(1); + ms_Event->SetHYD2TrkSecondStageTDetectorNbr(m_index["Trapezoid2"] + N); + ms_Event->SetHYD2TrkSecondStageEDetectorNbr(m_index["Trapezoid2"] + N); + } + + SecondStageEnergy_itr++; + } + + // Third Stage + ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < ThirdStageEnergyHitMap->entries(); h++) { + G4int ThirdStageEnergyTrackID = ThirdStageEnergy_itr->first - N; + G4double ThirdStageEnergy = *(ThirdStageEnergy_itr->second); + + if (ThirdStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkThirdStageEEnergy(RandGauss::shoot(ThirdStageEnergy, ResoThirdStage)); + ms_Event->SetHYD2TrkThirdStageEPadNbr(1); + ms_Event->SetHYD2TrkThirdStageTPadNbr(1); + ms_Event->SetHYD2TrkThirdStageTTime(1); + ms_Event->SetHYD2TrkThirdStageTDetectorNbr(m_index["Trapezoid2"] + N); + ms_Event->SetHYD2TrkThirdStageEDetectorNbr(m_index["Trapezoid2"] + N); + } + + ThirdStageEnergy_itr++; + } + + // Fourth Stage + FourthStageEnergy_itr = FourthStageEnergyHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < FourthStageEnergyHitMap->entries(); h++) { + G4int FourthStageEnergyTrackID = FourthStageEnergy_itr->first - N; + G4double FourthStageEnergy = *(FourthStageEnergy_itr->second); + + if (FourthStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkFourthStageEEnergy(RandGauss::shoot(FourthStageEnergy, ResoFourthStage)); + ms_Event->SetHYD2TrkFourthStageEPadNbr(1); + ms_Event->SetHYD2TrkFourthStageTPadNbr(1); + ms_Event->SetHYD2TrkFourthStageTTime(1); + ms_Event->SetHYD2TrkFourthStageTDetectorNbr(m_index["Trapezoid2"] + N); + ms_Event->SetHYD2TrkFourthStageEDetectorNbr(m_index["Trapezoid2"] + N); + } + + FourthStageEnergy_itr++; + } + + // Fifth Stage + FifthStageEnergy_itr = FifthStageEnergyHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < FifthStageEnergyHitMap->entries(); h++) { + G4int FifthStageEnergyTrackID = FifthStageEnergy_itr->first - N; + G4double FifthStageEnergy = *(FifthStageEnergy_itr->second); + + if (FifthStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkFifthStageEEnergy(RandGauss::shoot(FifthStageEnergy, ResoFifthStage)); + ms_Event->SetHYD2TrkFifthStageEPadNbr(1); + ms_Event->SetHYD2TrkFifthStageTPadNbr(1); + ms_Event->SetHYD2TrkFifthStageTTime(1); + ms_Event->SetHYD2TrkFifthStageTDetectorNbr(m_index["Trapezoid2"] + N); + ms_Event->SetHYD2TrkFifthStageEDetectorNbr(m_index["Trapezoid2"] + N); + } + + FifthStageEnergy_itr++; + } + + // Sixth Stage + SixthStageEnergy_itr = SixthStageEnergyHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < SixthStageEnergyHitMap->entries(); h++) { + G4int SixthStageEnergyTrackID = SixthStageEnergy_itr->first - N; + G4double SixthStageEnergy = *(SixthStageEnergy_itr->second); + + if (SixthStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkSixthStageEEnergy(RandGauss::shoot(SixthStageEnergy, ResoSixthStage)); + ms_Event->SetHYD2TrkSixthStageEPadNbr(1); + ms_Event->SetHYD2TrkSixthStageTPadNbr(1); + ms_Event->SetHYD2TrkSixthStageTTime(1); + ms_Event->SetHYD2TrkSixthStageTDetectorNbr(m_index["Trapezoid2"] + N); + ms_Event->SetHYD2TrkSixthStageEDetectorNbr(m_index["Trapezoid2"] + N); + } + + SixthStageEnergy_itr++; + } + + DetectorNumber_itr++; + } + + // clear map for next event + DetectorNumberHitMap->clear(); + EnergyHitMap->clear(); + TimeHitMap->clear(); + XHitMap->clear(); + YHitMap->clear(); + PosXHitMap->clear(); + PosYHitMap->clear(); + PosZHitMap->clear(); + AngThetaHitMap->clear(); + AngPhiHitMap->clear(); + SecondStageEnergyHitMap->clear(); + ThirdStageEnergyHitMap->clear(); + FourthStageEnergyHitMap->clear(); + FifthStageEnergyHitMap->clear(); + SixthStageEnergyHitMap->clear(); + } +} -void Hyde2TrackerTrapezoid2::InitializeScorers() -{ - bool already_exist = false; - m_FirstStageScorer = NPS::VDetector::CheckScorer("FirstStageScorerHYD2Trapezoid2",already_exist); - m_SecondStageScorer = NPS::VDetector::CheckScorer("SecondStageScorerHYD2Trapezoid2",already_exist); - m_ThirdStageScorer = NPS::VDetector::CheckScorer("ThirdStageScorerHYD2Trapezoid2",already_exist); - m_FourthStageScorer = NPS::VDetector::CheckScorer("FourthStageScorerHYD2Trapezoid2",already_exist); - m_FifthStageScorer = NPS::VDetector::CheckScorer("FifthStageScorerHYD2Trapezoid2",already_exist); - m_SixthStageScorer = NPS::VDetector::CheckScorer("SixthStageScorerHYD2Trapezoid2",already_exist); - if(already_exist) return; - - - - - // First stage Associate Scorer - G4VPrimitiveScorer* DetNbr = new OBSOLETEGENERALSCORERS::PSDetectorNumber("DetectorNumber", "HYD2Trapezoid2", 0); - G4VPrimitiveScorer* TOF = new OBSOLETEGENERALSCORERS::PSTOF("StripTime","HYD2Trapezoid2", 0); - G4VPrimitiveScorer* InteractionCoordinatesX = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesX("InterCoordX","HYD2Trapezoid2", 0); - G4VPrimitiveScorer* InteractionCoordinatesY = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesY("InterCoordY","HYD2Trapezoid2", 0); - G4VPrimitiveScorer* InteractionCoordinatesZ = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ","HYD2Trapezoid2", 0); - G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta","HYD2Trapezoid2", 0); - G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi","HYD2Trapezoid2", 0); - G4VPrimitiveScorer* Energy = new HYD2ScorerFirstStageEnergy("StripEnergy", "HYD2Trapezoid2", 0); - G4VPrimitiveScorer* StripPositionX = new HYD2ScorerFirstStageFrontStripTrapezoid2("StripNumberX", 0, NumberOfStripsX); - G4VPrimitiveScorer* StripPositionY = new HYD2ScorerFirstStageBackStripTrapezoid2("StripNumberY", 0, NumberOfStripsY); - - //and register it to the multifunctionnal detector - m_FirstStageScorer->RegisterPrimitive(DetNbr); - m_FirstStageScorer->RegisterPrimitive(Energy); - m_FirstStageScorer->RegisterPrimitive(TOF); - m_FirstStageScorer->RegisterPrimitive(StripPositionX); - m_FirstStageScorer->RegisterPrimitive(StripPositionY); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesX); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesY); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesZ); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAngleTheta); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAnglePhi); - - // Second stage Associate Scorer - G4VPrimitiveScorer* SecondStageEnergy = new HYD2ScorerSecondStageEnergy("SecondStageEnergy", "HYD2Trapezoid2", 0); - m_SecondStageScorer->RegisterPrimitive(SecondStageEnergy); - - // Third stage Associate Scorer - G4VPrimitiveScorer* ThirdStageEnergy = new HYD2ScorerThirdStageEnergy("ThirdStageEnergy", "HYD2Trapezoid2", 0); - m_ThirdStageScorer->RegisterPrimitive(ThirdStageEnergy); - - // Fourth stage Associate Scorer - G4VPrimitiveScorer* FourthStageEnergy = new HYD2ScorerFourthStageEnergy("FourthStageEnergy", "HYD2Trapezoid2", 0); - m_FourthStageScorer->RegisterPrimitive(FourthStageEnergy); - - // Fifth stage Associate Scorer - G4VPrimitiveScorer* FifthStageEnergy = new HYD2ScorerFifthStageEnergy("FifthStageEnergy", "HYD2Trapezoid2", 0); - m_FifthStageScorer->RegisterPrimitive(FifthStageEnergy); - - // Sixth stage Associate Scorer - G4VPrimitiveScorer* SixthStageEnergy = new HYD2ScorerSixthStageEnergy("SixthStageEnergy", "HYD2Trapezoid2", 0); - m_SixthStageScorer->RegisterPrimitive(SixthStageEnergy); - - // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_FirstStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_SecondStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_ThirdStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_FourthStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_FifthStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_SixthStageScorer); +void Hyde2TrackerTrapezoid2::InitializeScorers() { + bool already_exist = false; + m_FirstStageScorer = NPS::VDetector::CheckScorer("FirstStageScorerHYD2Trapezoid2", already_exist); + m_SecondStageScorer = NPS::VDetector::CheckScorer("SecondStageScorerHYD2Trapezoid2", already_exist); + m_ThirdStageScorer = NPS::VDetector::CheckScorer("ThirdStageScorerHYD2Trapezoid2", already_exist); + m_FourthStageScorer = NPS::VDetector::CheckScorer("FourthStageScorerHYD2Trapezoid2", already_exist); + m_FifthStageScorer = NPS::VDetector::CheckScorer("FifthStageScorerHYD2Trapezoid2", already_exist); + m_SixthStageScorer = NPS::VDetector::CheckScorer("SixthStageScorerHYD2Trapezoid2", already_exist); + if (already_exist) + return; + + // First stage Associate Scorer + G4VPrimitiveScorer* DetNbr = new OBSOLETEGENERALSCORERS::PSDetectorNumber("DetectorNumber", "HYD2Trapezoid2", 0); + G4VPrimitiveScorer* TOF = new OBSOLETEGENERALSCORERS::PSTOF("StripTime", "HYD2Trapezoid2", 0); + G4VPrimitiveScorer* InteractionCoordinatesX = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesX("InterCoordX", "HYD2Trapezoid2", 0); + G4VPrimitiveScorer* InteractionCoordinatesY = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesY("InterCoordY", "HYD2Trapezoid2", 0); + G4VPrimitiveScorer* InteractionCoordinatesZ = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ", "HYD2Trapezoid2", 0); + G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta", "HYD2Trapezoid2", 0); + G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi", "HYD2Trapezoid2", 0); + G4VPrimitiveScorer* Energy = new HYD2ScorerFirstStageEnergy("StripEnergy", "HYD2Trapezoid2", 0); + G4VPrimitiveScorer* StripPositionX = new HYD2ScorerFirstStageFrontStripTrapezoid2("StripNumberX", 0, NumberOfStripsX); + G4VPrimitiveScorer* StripPositionY = new HYD2ScorerFirstStageBackStripTrapezoid2("StripNumberY", 0, NumberOfStripsY); + + // and register it to the multifunctionnal detector + m_FirstStageScorer->RegisterPrimitive(DetNbr); + m_FirstStageScorer->RegisterPrimitive(Energy); + m_FirstStageScorer->RegisterPrimitive(TOF); + m_FirstStageScorer->RegisterPrimitive(StripPositionX); + m_FirstStageScorer->RegisterPrimitive(StripPositionY); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesX); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesY); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesZ); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAngleTheta); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAnglePhi); + + // Second stage Associate Scorer + G4VPrimitiveScorer* SecondStageEnergy = new HYD2ScorerSecondStageEnergy("SecondStageEnergy", "HYD2Trapezoid2", 0); + m_SecondStageScorer->RegisterPrimitive(SecondStageEnergy); + + // Third stage Associate Scorer + G4VPrimitiveScorer* ThirdStageEnergy = new HYD2ScorerThirdStageEnergy("ThirdStageEnergy", "HYD2Trapezoid2", 0); + m_ThirdStageScorer->RegisterPrimitive(ThirdStageEnergy); + + // Fourth stage Associate Scorer + G4VPrimitiveScorer* FourthStageEnergy = new HYD2ScorerFourthStageEnergy("FourthStageEnergy", "HYD2Trapezoid2", 0); + m_FourthStageScorer->RegisterPrimitive(FourthStageEnergy); + + // Fifth stage Associate Scorer + G4VPrimitiveScorer* FifthStageEnergy = new HYD2ScorerFifthStageEnergy("FifthStageEnergy", "HYD2Trapezoid2", 0); + m_FifthStageScorer->RegisterPrimitive(FifthStageEnergy); + + // Sixth stage Associate Scorer + G4VPrimitiveScorer* SixthStageEnergy = new HYD2ScorerSixthStageEnergy("SixthStageEnergy", "HYD2Trapezoid2", 0); + m_SixthStageScorer->RegisterPrimitive(SixthStageEnergy); + + // Add All Scorer to the Global Scorer Manager + G4SDManager::GetSDMpointer()->AddNewDetector(m_FirstStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_SecondStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_ThirdStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_FourthStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_FifthStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_SixthStageScorer); } diff --git a/NPSimulation/Detectors/Lassa/Lassa.cc b/NPSimulation/Detectors/Lassa/Lassa.cc index 857e4f02f..4ebaa8d3c 100644 --- a/NPSimulation/Detectors/Lassa/Lassa.cc +++ b/NPSimulation/Detectors/Lassa/Lassa.cc @@ -20,40 +20,40 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> -//G4 Geometry object +#include <sstream> +// G4 Geometry object #include "G4Box.hh" -#include "G4Trd.hh" -#include "G4Trap.hh" -#include "G4Tubs.hh" #include "G4Cons.hh" -#include "G4UnionSolid.hh" #include "G4ExtrudedSolid.hh" +#include "G4Trap.hh" +#include "G4Trd.hh" +#include "G4Tubs.hh" #include "G4TwoVector.hh" -//G4 sensitive +#include "G4UnionSolid.hh" +// G4 sensitive #include "G4SDManager.hh" -//G4 various object -#include "G4Material.hh" -#include "G4Transform3D.hh" -#include "G4PVPlacement.hh" +// G4 various object #include "G4Colour.hh" +#include "G4Material.hh" #include "G4PVDivision.hh" +#include "G4PVPlacement.hh" #include "G4SubtractionSolid.hh" +#include "G4Transform3D.hh" // NPS +#include "CalorimeterScorers.hh" #include "Lassa.hh" #include "MaterialManager.hh" #include "SiliconScorers.hh" -#include "CalorimeterScorers.hh" // NPL #include "NPOptionManager.h" -#include "RootOutput.h" #include "NPSDetectorFactory.hh" -//using namespace OBSOLETEGENERALSCORERS ; +#include "RootOutput.h" +// using namespace OBSOLETEGENERALSCORERS ; using namespace LASSA; @@ -64,46 +64,45 @@ using namespace std; using namespace CLHEP; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Lassa::Lassa(){ - InitializeMaterial(); - m_EventLassa = new TLassaData(); - - // Dark Grey - m_SiliconVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)) ; - - m_CsIVisAtt = new G4VisAttributes(G4Colour(0.529412, 0.807843, 0.980392, 0.95)) ; - //m_CsIVisAtt->SetForceWireframe(true); - m_LogicThickSi = 0; - m_LogicCsICrystal = 0; - m_LogicCluster = 0; +Lassa::Lassa() { + InitializeMaterial(); + m_EventLassa = new TLassaData(); + + // Dark Grey + m_SiliconVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)); + + m_CsIVisAtt = new G4VisAttributes(G4Colour(0.529412, 0.807843, 0.980392, 0.95)); + // m_CsIVisAtt->SetForceWireframe(true); + m_LogicThickSi = 0; + m_LogicCsICrystal = 0; + m_LogicCluster = 0; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Lassa::~Lassa(){ -} +Lassa::~Lassa() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Virtual Method of VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Lassa::ReadConfiguration(NPL::InputParser parser){ +void Lassa::ReadConfiguration(NPL::InputParser parser) { vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("LassaTelescope"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " Telescope found " << endl; + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " Telescope found " << endl; // Cartesian Case - vector<string> cart = {"A","B","C","D"}; - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(cart)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Lassa Telescope " << i+1 << endl; - G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("A","mm")); - G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("B","mm")); - G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("C","mm")); - G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("D","mm")); - AddTelescope(A,B,C,D) ; + vector<string> cart = {"A", "B", "C", "D"}; + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(cart)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Lassa Telescope " << i + 1 << endl; + G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("A", "mm")); + G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("B", "mm")); + G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("C", "mm")); + G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("D", "mm")); + AddTelescope(A, B, C, D); } - else{ + else { cout << "ERROR: Missing token for M2Telescope blocks, check your input file" << endl; exit(1); } @@ -111,305 +110,291 @@ void Lassa::ReadConfiguration(NPL::InputParser parser){ } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Lassa::AddTelescope(G4ThreeVector Pos1, G4ThreeVector Pos2, G4ThreeVector Pos3, G4ThreeVector Pos4){ - G4ThreeVector Pos=(Pos1+Pos2+Pos3+Pos4)/4.; - G4ThreeVector u = Pos4-Pos2; - G4ThreeVector w = Pos.unit(); - G4ThreeVector v = w.cross(u); - u = u.unit(); v = v.unit(); w = w.unit(); - Pos = Pos + w*Length*0.5; - - m_Type.push_back(1); - m_Pos.push_back(Pos); - m_Rot.push_back(new G4RotationMatrix(u,v,w)); +void Lassa::AddTelescope(G4ThreeVector Pos1, G4ThreeVector Pos2, G4ThreeVector Pos3, G4ThreeVector Pos4) { + G4ThreeVector Pos = (Pos1 + Pos2 + Pos3 + Pos4) / 4.; + G4ThreeVector u = Pos4 - Pos2; + G4ThreeVector w = Pos.unit(); + G4ThreeVector v = w.cross(u); + u = u.unit(); + v = v.unit(); + w = w.unit(); + Pos = Pos + w * Length * 0.5; + + m_Type.push_back(1); + m_Pos.push_back(Pos); + m_Rot.push_back(new G4RotationMatrix(u, v, w)); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void Lassa::ConstructDetector(G4LogicalVolume* world){ - unsigned int mysize = m_Pos.size(); - - for(unsigned int i = 0 ; i < mysize ; i++){ - VolumeMaker(i+1, m_Pos[i], m_Rot[i], world); - } -} - +void Lassa::ConstructDetector(G4LogicalVolume* world) { + unsigned int mysize = m_Pos.size(); + for (unsigned int i = 0; i < mysize; i++) { + VolumeMaker(i + 1, m_Pos[i], m_Rot[i], world); + } +} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Lassa::ReadSensitive(const G4Event* event){ - m_EventLassa->Clear(); - - // ThickSi // - NPS::HitsMap<G4double*>* ThickSiHitMap; - std::map<G4int, G4double**>::iterator ThickSi_itr; - G4int ThickSiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("Lassa_ThickSiScorer/ThickSi"); - ThickSiHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(ThickSiCollectionID)); - - // Loop on the ThickSi map - for (ThickSi_itr = ThickSiHitMap->GetMap()->begin() ; ThickSi_itr != ThickSiHitMap->GetMap()->end() ; ThickSi_itr++){ - G4double* Info = *(ThickSi_itr->second); - double E_ThickSi = RandGauss::shoot(Info[0],ResoThickSi); - if(E_ThickSi>EnergyThreshold){ - m_EventLassa->SetLassaThickSiStripXEEnergy(E_ThickSi); - m_EventLassa->SetLassaThickSiStripXEDetectorNbr(Info[7]-1); - m_EventLassa->SetLassaThickSiStripXEStripNbr(Info[8]-1); - - m_EventLassa->SetLassaThickSiStripXTTime(Info[1]); - m_EventLassa->SetLassaThickSiStripXTDetectorNbr(Info[7]-1); - m_EventLassa->SetLassaThickSiStripXTStripNbr(Info[8]-1); - - m_EventLassa->SetLassaThickSiStripYEEnergy(E_ThickSi); - m_EventLassa->SetLassaThickSiStripYEDetectorNbr(Info[7]-1); - m_EventLassa->SetLassaThickSiStripYEStripNbr(Info[9]-1); - - m_EventLassa->SetLassaThickSiStripYTTime(Info[1]); - m_EventLassa->SetLassaThickSiStripYTDetectorNbr(Info[7]-1); - m_EventLassa->SetLassaThickSiStripYTStripNbr(Info[9]-1); - - // Interraction Coordinates - ms_InterCoord->SetDetectedPositionX(Info[2]) ; - ms_InterCoord->SetDetectedPositionY(Info[3]) ; - ms_InterCoord->SetDetectedPositionZ(Info[4]) ; - ms_InterCoord->SetDetectedAngleTheta(Info[5]/deg) ; - ms_InterCoord->SetDetectedAnglePhi(Info[6]/deg) ; - } +void Lassa::ReadSensitive(const G4Event* event) { + m_EventLassa->Clear(); + + // ThickSi // + NPS::HitsMap<G4double*>* ThickSiHitMap; + std::map<G4int, G4double**>::iterator ThickSi_itr; + G4int ThickSiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("Lassa_ThickSiScorer/ThickSi"); + ThickSiHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(ThickSiCollectionID)); + + // Loop on the ThickSi map + for (ThickSi_itr = ThickSiHitMap->GetMap()->begin(); ThickSi_itr != ThickSiHitMap->GetMap()->end(); ThickSi_itr++) { + G4double* Info = *(ThickSi_itr->second); + double E_ThickSi = RandGauss::shoot(Info[0], ResoThickSi); + if (E_ThickSi > EnergyThreshold) { + m_EventLassa->SetLassaThickSiStripXEEnergy(E_ThickSi); + m_EventLassa->SetLassaThickSiStripXEDetectorNbr(Info[7] - 1); + m_EventLassa->SetLassaThickSiStripXEStripNbr(Info[8] - 1); + + m_EventLassa->SetLassaThickSiStripXTTime(Info[1]); + m_EventLassa->SetLassaThickSiStripXTDetectorNbr(Info[7] - 1); + m_EventLassa->SetLassaThickSiStripXTStripNbr(Info[8] - 1); + + m_EventLassa->SetLassaThickSiStripYEEnergy(E_ThickSi); + m_EventLassa->SetLassaThickSiStripYEDetectorNbr(Info[7] - 1); + m_EventLassa->SetLassaThickSiStripYEStripNbr(Info[9] - 1); + + m_EventLassa->SetLassaThickSiStripYTTime(Info[1]); + m_EventLassa->SetLassaThickSiStripYTDetectorNbr(Info[7] - 1); + m_EventLassa->SetLassaThickSiStripYTStripNbr(Info[9] - 1); + + // Interraction Coordinates + ms_InterCoord->SetDetectedPositionX(Info[2]); + ms_InterCoord->SetDetectedPositionY(Info[3]); + ms_InterCoord->SetDetectedPositionZ(Info[4]); + ms_InterCoord->SetDetectedAngleTheta(Info[5] / deg); + ms_InterCoord->SetDetectedAnglePhi(Info[6] / deg); } - // Clear Map for next event - ThickSiHitMap->clear(); - - CalorimeterScorers::PS_Calorimeter* Scorer= (CalorimeterScorers::PS_Calorimeter*) m_CsIScorer->GetPrimitive(0); - - unsigned int size = Scorer->GetMult(); - for(unsigned int i = 0 ; i < size ; i++){ - vector<unsigned int> level = Scorer->GetLevel(i); - double E_CsI = RandGauss::shoot(Scorer->GetEnergy(i),ResoCsI); - if(E_CsI>EnergyThreshold){ - m_EventLassa->SetLassaCsIEEnergy(E_CsI); - m_EventLassa->SetLassaCsIEDetectorNbr(level[0]-1); - m_EventLassa->SetLassaCsIECristalNbr(level[1]-1); - } + } + // Clear Map for next event + ThickSiHitMap->clear(); + + CalorimeterScorers::PS_Calorimeter* Scorer = (CalorimeterScorers::PS_Calorimeter*)m_CsIScorer->GetPrimitive(0); + + unsigned int size = Scorer->GetMult(); + for (unsigned int i = 0; i < size; i++) { + vector<unsigned int> level = Scorer->GetLevel(i); + double E_CsI = RandGauss::shoot(Scorer->GetEnergy(i), ResoCsI); + if (E_CsI > EnergyThreshold) { + m_EventLassa->SetLassaCsIEEnergy(E_CsI); + m_EventLassa->SetLassaCsIEDetectorNbr(level[0] - 1); + m_EventLassa->SetLassaCsIECristalNbr(level[1] - 1); } + } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Lassa::InitializeScorers(){ - //Look for previous definition of the scorer (geometry reload) - bool already_exist = false; - vector<G4int> NestingLevel; - NestingLevel.push_back(0); - NestingLevel.push_back(2); - - m_ThickSiStripScorer = CheckScorer("Lassa_ThickSiScorer",already_exist); - m_CsIScorer = CheckScorer("Lassa_CsIScorer",already_exist); - - // if the scorer were created previously nothing else need to be made - if(already_exist) return; - - G4VPrimitiveScorer* ThickSiScorer = new SILICONSCORERS::PS_Silicon_Rectangle("ThickSi",0, - SiliconFace, - SiliconFace, - NumberOfStrip, - NumberOfStrip); - - m_ThickSiStripScorer->RegisterPrimitive(ThickSiScorer); - - G4VPrimitiveScorer* CsIScorer= new CalorimeterScorers::PS_Calorimeter("CsI",NestingLevel); - - m_CsIScorer->RegisterPrimitive(CsIScorer); - - // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_ThickSiStripScorer) ; - G4SDManager::GetSDMpointer()->AddNewDetector(m_CsIScorer) ; +void Lassa::InitializeScorers() { + // Look for previous definition of the scorer (geometry reload) + bool already_exist = false; + vector<G4int> NestingLevel; + NestingLevel.push_back(0); + NestingLevel.push_back(2); + + m_ThickSiStripScorer = CheckScorer("Lassa_ThickSiScorer", already_exist); + m_CsIScorer = CheckScorer("Lassa_CsIScorer", already_exist); + + // if the scorer were created previously nothing else need to be made + if (already_exist) + return; + + G4VPrimitiveScorer* ThickSiScorer = + new SILICONSCORERS::PS_Silicon_Rectangle("ThickSi", 0, SiliconFace, SiliconFace, NumberOfStrip, NumberOfStrip); + + m_ThickSiStripScorer->RegisterPrimitive(ThickSiScorer); + + G4VPrimitiveScorer* CsIScorer = new CalorimeterScorers::PS_Calorimeter("CsI", NestingLevel); + + m_CsIScorer->RegisterPrimitive(CsIScorer); + + // Add All Scorer to the Global Scorer Manager + G4SDManager::GetSDMpointer()->AddNewDetector(m_ThickSiStripScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_CsIScorer); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Lassa::InitializeRootOutput(){ - TTree *pTree = RootOutput::getInstance()->GetTree(); - if(!pTree->FindBranch("Lassa")){ - pTree->Branch("Lassa", "TLassaData", &m_EventLassa) ; - } - // This insure that the object are correctly bind in case of - // a redifinition of the geometry in the simulation - pTree->SetBranchAddress("Lassa", &m_EventLassa) ; +void Lassa::InitializeRootOutput() { + TTree* pTree = RootOutput::getInstance()->GetTree(); + if (!pTree->FindBranch("Lassa")) { + pTree->Branch("Lassa", "TLassaData", &m_EventLassa); + } + // This insure that the object are correctly bind in case of + // a redifinition of the geometry in the simulation + pTree->SetBranchAddress("Lassa", &m_EventLassa); } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Lassa::VolumeMaker(G4int DetectorNumber, - G4ThreeVector MMpos, - G4RotationMatrix* MMrot, - G4LogicalVolume* world) -{ - G4double NbrTelescopes = DetectorNumber ; - G4String DetNumber ; - ostringstream Number ; - Number << NbrTelescopes ; - DetNumber = Number.str() ; - - - //////////////////////////////////////////////////////////////// - ////////////// Starting Volume Definition ////////////////////// - //////////////////////////////////////////////////////////////// - G4String Name = "Lassa" + DetNumber ; - - // Definition of the volume containing the sensitive detector - G4Box* solidMotherVolume = new G4Box(Name, 0.5*FaceFront, 0.5*FaceBack, 0.5*Length); - m_logicMotherVolume = new G4LogicalVolume(solidMotherVolume, m_MaterialVacuum, Name, 0, 0, 0); - - new G4PVPlacement(G4Transform3D(*MMrot, MMpos), m_logicMotherVolume, Name, world, false, DetectorNumber); - - G4VisAttributes* MotherVolumeVisAtt = new G4VisAttributes(G4Colour(0.90, 0.90, 0.90)); - MotherVolumeVisAtt->SetForceWireframe(true); - m_logicMotherVolume->SetVisAttributes(G4VisAttributes::Invisible); - - /////////////////////////////////////////////////// - ///////////////////// Thick Si //////////////////// - /////////////////////////////////////////////////// - G4String NameThickSi = "ThickSi"+DetNumber; - //if(!m_LogicThickSi){ - if(0==0){ - G4Box* solidThickSi = new G4Box(NameThickSi, 0.5*SiliconFace, 0.5*SiliconFace, 0.5*ThickSiThickness); - m_LogicThickSi = new G4LogicalVolume(solidThickSi, m_MaterialSilicon, "logicThickSi", 0, 0, 0); - - G4ThreeVector positionThickSi = G4ThreeVector(0, 0, ThickSi_PosZ); - - new G4PVPlacement(new G4RotationMatrix(0,0,0), - positionThickSi, - m_LogicThickSi,"ThickSi", - m_logicMotherVolume,false,DetectorNumber); - - // Set ThickSi sensible - m_LogicThickSi->SetSensitiveDetector(m_ThickSiStripScorer); - - // Visualisation of ThickSi - m_LogicThickSi->SetVisAttributes(m_SiliconVisAtt) ; - } - - /////////////////////////////////////////////////// - /////////////////////// CsI /////////////////////// - /////////////////////////////////////////////////// - G4String NameCsI = "CsI"+DetNumber; - - double X1 = (CsIXFront-CsIXBack)/2.; - double Y1 = (CsIYFront-CsIYBack)/2.; - double l = sqrt(pow(X1,2) + pow(Y1,2)); - - double pDz = 0.5*CsIThickness; - double pTheta = -atan( (l)/(CsIThickness) ); - double pPhi = atan( X1/Y1 ); - double pDy1 = 0.5*CsIYFront; - double pDx1 = 0.5*CsIXFront; - double pDx2 = 0.5*CsIXFront; - double pAlp1 = 0; - double pDy2 = 0.5*CsIYBack; - double pDx3 = 0.5*CsIXBack; - double pDx4 = 0.5*CsIXBack; - double pAlp2 = 0; - - G4Trap* solidCsIStage = new G4Trap(NameCsI, pDz, pTheta, pPhi, pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3, pDx4, pAlp2); - - - m_LogicCsICrystal = new G4LogicalVolume(solidCsIStage, m_MaterialCsI, "logicCsICrystal", 0, 0, 0); - - // Set CsI sensible - m_LogicCsICrystal->SetSensitiveDetector(m_CsIScorer); - - // Visualisation of CsI - m_LogicCsICrystal->SetVisAttributes(m_CsIVisAtt); - - //if(!m_LogicCluster){ - if(0==0){ - // Sub Mother Volume - G4Trd* solidCluster = new G4Trd("SolidCluster", 0.5*ClusterFaceFront,0.5*ClusterFaceBack,0.5*ClusterFaceFront,0.5*ClusterFaceBack, 0.5*CsIThickness); - m_LogicCluster = new G4LogicalVolume(solidCluster, m_MaterialVacuum, "LogicSolidCluster", 0, 0, 0); - m_LogicCluster->SetVisAttributes(G4VisAttributes::Invisible); - - G4ThreeVector FramePos(0,0,CsI_PosZ); - - new G4PVPlacement(new G4RotationMatrix(0,0,0), - FramePos, - m_LogicCluster,"Cluster", - m_logicMotherVolume,false,0); - - //const G4double CsIXMiddle = CsIXFront + (CsIThickness/2)*tan(-pTheta)*sin(pPhi); - //const G4double CsIYMiddle = CsIYFront + (CsIThickness/2)*tan(-pTheta)*cos(pPhi); - //double alpha = atan((CsIXBack-CsIXFront)/CsIThickness); - //double dl = (CsIThickness/2)*tan(alpha); - double dl = (CsIXBack-CsIXFront)/4; - const G4double CsIXMiddle = 0.5*CsIXFront + dl; - const G4double CsIYMiddle = 0.5*CsIYFront + dl; - const G4double DistInterCsIX = CsIXMiddle+0.5*DistInterCsI; - const G4double DistInterCsIY = CsIYMiddle+0.5*DistInterCsI; - - G4ThreeVector Origin(-DistInterCsIX,-DistInterCsIY,0); - G4ThreeVector Pos; - const G4double dangle = 90.*deg; - // A cluster is a 2 by 2 aggregat of CsI crystal - unsigned int CsINbr = 1; - for(unsigned int i = 0 ; i < 2 ; i++){ - for(unsigned int j = 0 ; j < 2 ; j++){ - G4RotationMatrix* rotM = new G4RotationMatrix; - unsigned int CrystalNbr = CsINbr++; - if(i==0 && j==0)rotM->rotateZ(0); - if(i==1 && j==0)rotM->rotateZ(dangle); - if(i==0 && j==1)rotM->rotateZ(-dangle); - if(i==1 && j==1)rotM->rotateZ(2*dangle); - - if(i==0 && j==0) Pos = Origin; - if(i==1 && j==0) Pos = G4ThreeVector((DistInterCsIX),-(DistInterCsIY),0); - if(i==0 && j==1) Pos = G4ThreeVector(-(DistInterCsIX),(DistInterCsIY),0); - if(i==1 && j==1) Pos = G4ThreeVector((DistInterCsIX),(DistInterCsIY),0); - //Pos = Origin + G4ThreeVector(i*DistInterCsIX,j*DistInterCsIY,0); - - new G4PVPlacement(G4Transform3D(*rotM,Pos), - m_LogicCsICrystal, - "CsI_Cristal", - m_LogicCluster, - false, - CrystalNbr, true); - delete rotM; - } - } - +void Lassa::VolumeMaker(G4int DetectorNumber, G4ThreeVector MMpos, G4RotationMatrix* MMrot, G4LogicalVolume* world) { + G4double NbrTelescopes = DetectorNumber; + G4String DetNumber; + ostringstream Number; + Number << NbrTelescopes; + DetNumber = Number.str(); + + //////////////////////////////////////////////////////////////// + ////////////// Starting Volume Definition ////////////////////// + //////////////////////////////////////////////////////////////// + G4String Name = "Lassa" + DetNumber; + + // Definition of the volume containing the sensitive detector + G4Box* solidMotherVolume = new G4Box(Name, 0.5 * FaceFront, 0.5 * FaceBack, 0.5 * Length); + m_logicMotherVolume = new G4LogicalVolume(solidMotherVolume, m_MaterialVacuum, Name, 0, 0, 0); + + new G4PVPlacement(G4Transform3D(*MMrot, MMpos), m_logicMotherVolume, Name, world, false, DetectorNumber); + + G4VisAttributes* MotherVolumeVisAtt = new G4VisAttributes(G4Colour(0.90, 0.90, 0.90)); + MotherVolumeVisAtt->SetForceWireframe(true); + m_logicMotherVolume->SetVisAttributes(G4VisAttributes::GetInvisible()); + + /////////////////////////////////////////////////// + ///////////////////// Thick Si //////////////////// + /////////////////////////////////////////////////// + G4String NameThickSi = "ThickSi" + DetNumber; + // if(!m_LogicThickSi){ + if (0 == 0) { + G4Box* solidThickSi = new G4Box(NameThickSi, 0.5 * SiliconFace, 0.5 * SiliconFace, 0.5 * ThickSiThickness); + m_LogicThickSi = new G4LogicalVolume(solidThickSi, m_MaterialSilicon, "logicThickSi", 0, 0, 0); + + G4ThreeVector positionThickSi = G4ThreeVector(0, 0, ThickSi_PosZ); + + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), positionThickSi, m_LogicThickSi, "ThickSi", m_logicMotherVolume, + false, DetectorNumber); + + // Set ThickSi sensible + m_LogicThickSi->SetSensitiveDetector(m_ThickSiStripScorer); + + // Visualisation of ThickSi + m_LogicThickSi->SetVisAttributes(m_SiliconVisAtt); + } + + /////////////////////////////////////////////////// + /////////////////////// CsI /////////////////////// + /////////////////////////////////////////////////// + G4String NameCsI = "CsI" + DetNumber; + + double X1 = (CsIXFront - CsIXBack) / 2.; + double Y1 = (CsIYFront - CsIYBack) / 2.; + double l = sqrt(pow(X1, 2) + pow(Y1, 2)); + + double pDz = 0.5 * CsIThickness; + double pTheta = -atan((l) / (CsIThickness)); + double pPhi = atan(X1 / Y1); + double pDy1 = 0.5 * CsIYFront; + double pDx1 = 0.5 * CsIXFront; + double pDx2 = 0.5 * CsIXFront; + double pAlp1 = 0; + double pDy2 = 0.5 * CsIYBack; + double pDx3 = 0.5 * CsIXBack; + double pDx4 = 0.5 * CsIXBack; + double pAlp2 = 0; + + G4Trap* solidCsIStage = new G4Trap(NameCsI, pDz, pTheta, pPhi, pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3, pDx4, pAlp2); + + m_LogicCsICrystal = new G4LogicalVolume(solidCsIStage, m_MaterialCsI, "logicCsICrystal", 0, 0, 0); + + // Set CsI sensible + m_LogicCsICrystal->SetSensitiveDetector(m_CsIScorer); + + // Visualisation of CsI + m_LogicCsICrystal->SetVisAttributes(m_CsIVisAtt); + + // if(!m_LogicCluster){ + if (0 == 0) { + // Sub Mother Volume + G4Trd* solidCluster = new G4Trd("SolidCluster", 0.5 * ClusterFaceFront, 0.5 * ClusterFaceBack, + 0.5 * ClusterFaceFront, 0.5 * ClusterFaceBack, 0.5 * CsIThickness); + m_LogicCluster = new G4LogicalVolume(solidCluster, m_MaterialVacuum, "LogicSolidCluster", 0, 0, 0); + m_LogicCluster->SetVisAttributes(G4VisAttributes::GetInvisible()); + + G4ThreeVector FramePos(0, 0, CsI_PosZ); + + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), FramePos, m_LogicCluster, "Cluster", m_logicMotherVolume, false, + 0); + + // const G4double CsIXMiddle = CsIXFront + (CsIThickness/2)*tan(-pTheta)*sin(pPhi); + // const G4double CsIYMiddle = CsIYFront + (CsIThickness/2)*tan(-pTheta)*cos(pPhi); + // double alpha = atan((CsIXBack-CsIXFront)/CsIThickness); + // double dl = (CsIThickness/2)*tan(alpha); + double dl = (CsIXBack - CsIXFront) / 4; + const G4double CsIXMiddle = 0.5 * CsIXFront + dl; + const G4double CsIYMiddle = 0.5 * CsIYFront + dl; + const G4double DistInterCsIX = CsIXMiddle + 0.5 * DistInterCsI; + const G4double DistInterCsIY = CsIYMiddle + 0.5 * DistInterCsI; + + G4ThreeVector Origin(-DistInterCsIX, -DistInterCsIY, 0); + G4ThreeVector Pos; + const G4double dangle = 90. * deg; + // A cluster is a 2 by 2 aggregat of CsI crystal + unsigned int CsINbr = 1; + for (unsigned int i = 0; i < 2; i++) { + for (unsigned int j = 0; j < 2; j++) { + G4RotationMatrix* rotM = new G4RotationMatrix; + unsigned int CrystalNbr = CsINbr++; + if (i == 0 && j == 0) + rotM->rotateZ(0); + if (i == 1 && j == 0) + rotM->rotateZ(dangle); + if (i == 0 && j == 1) + rotM->rotateZ(-dangle); + if (i == 1 && j == 1) + rotM->rotateZ(2 * dangle); + + if (i == 0 && j == 0) + Pos = Origin; + if (i == 1 && j == 0) + Pos = G4ThreeVector((DistInterCsIX), -(DistInterCsIY), 0); + if (i == 0 && j == 1) + Pos = G4ThreeVector(-(DistInterCsIX), (DistInterCsIY), 0); + if (i == 1 && j == 1) + Pos = G4ThreeVector((DistInterCsIX), (DistInterCsIY), 0); + // Pos = Origin + G4ThreeVector(i*DistInterCsIX,j*DistInterCsIY,0); + + new G4PVPlacement(G4Transform3D(*rotM, Pos), m_LogicCsICrystal, "CsI_Cristal", m_LogicCluster, false, + CrystalNbr, true); + delete rotM; + } } + } } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Lassa::InitializeMaterial(){ - m_MaterialSilicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); - m_MaterialAluminium = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); - m_MaterialCsI = MaterialManager::getInstance()->GetMaterialFromLibrary("CsI"); - m_MaterialMylar = MaterialManager::getInstance()->GetMaterialFromLibrary("Mylar"); - m_MaterialPCB = MaterialManager::getInstance()->GetMaterialFromLibrary("PCB"); - m_MaterialVacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); +void Lassa::InitializeMaterial() { + m_MaterialSilicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); + m_MaterialAluminium = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); + m_MaterialCsI = MaterialManager::getInstance()->GetMaterialFromLibrary("CsI"); + m_MaterialMylar = MaterialManager::getInstance()->GetMaterialFromLibrary("Mylar"); + m_MaterialPCB = MaterialManager::getInstance()->GetMaterialFromLibrary("PCB"); + m_MaterialVacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); } //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* Lassa::Construct(){ - return (NPS::VDetector*) new Lassa(); -} +NPS::VDetector* Lassa::Construct() { return (NPS::VDetector*)new Lassa(); } //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_lassa{ - public: - proxy_nps_lassa(){ - NPS::DetectorFactory::getInstance()->AddToken("LASSAArray","Lassa"); - NPS::DetectorFactory::getInstance()->AddDetector("LASSAArray",Lassa::Construct); - } - }; - - proxy_nps_lassa p_nps_lassa; -} - +extern "C" { +class proxy_nps_lassa { + public: + proxy_nps_lassa() { + NPS::DetectorFactory::getInstance()->AddToken("LASSAArray", "Lassa"); + NPS::DetectorFactory::getInstance()->AddDetector("LASSAArray", Lassa::Construct); + } +}; +proxy_nps_lassa p_nps_lassa; +} diff --git a/NPSimulation/Detectors/LightPipe/LightPipe.cc b/NPSimulation/Detectors/LightPipe/LightPipe.cc index b9c0ee23a..af89e7440 100644 --- a/NPSimulation/Detectors/LightPipe/LightPipe.cc +++ b/NPSimulation/Detectors/LightPipe/LightPipe.cc @@ -20,226 +20,215 @@ *****************************************************************************/ // C++ headers -#include <sstream> +#include <algorithm> #include <cmath> -#include <limits> #include <fstream> -#include <algorithm> -//G4 Geometry object -#include "G4Tubs.hh" +#include <limits> +#include <sstream> +// G4 Geometry object #include "G4Box.hh" +#include "G4Tubs.hh" -//G4 sensitive -#include "G4SDManager.hh" +// G4 sensitive #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" -//G4 various object -#include "G4Material.hh" -#include "G4Transform3D.hh" -#include "G4PVPlacement.hh" -#include "G4VisAttributes.hh" +// G4 various object #include "G4Colour.hh" -#include "G4OpticalSurface.hh" #include "G4LogicalBorderSurface.hh" #include "G4LogicalSkinSurface.hh" +#include "G4Material.hh" +#include "G4OpticalSurface.hh" +#include "G4PVPlacement.hh" +#include "G4Transform3D.hh" +#include "G4VisAttributes.hh" // ROOT -#include "TSystem.h" #include "TMath.h" +#include "TSystem.h" // NPTool header -#include "LightPipe.hh" #include "CalorimeterScorers.hh" -#include "PhotoDiodeScorers.hh" -#include "RootOutput.h" +#include "LightPipe.hh" #include "MaterialManager.hh" -#include "NPSDetectorFactory.hh" #include "NPOptionManager.h" +#include "NPSDetectorFactory.hh" #include "NPSHitsMap.hh" +#include "PhotoDiodeScorers.hh" +#include "RootOutput.h" // CLHEP header #include "CLHEP/Random/RandGauss.h" using namespace std; using namespace CLHEP; - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // LightPipe Specific Method -LightPipe::LightPipe(){ - m_Event = new TLightPipeData() ; +LightPipe::LightPipe() { + m_Event = new TLightPipeData(); m_LightPipeScorer = 0; // RGB Color + Transparency m_VisSquare = new G4VisAttributes(G4Colour(0, 0, 1, 0.5)); - m_VisPipe = new G4VisAttributes(G4Colour(0, 1, 0, 0.5)); - m_VisPD = new G4VisAttributes(G4Colour(0.1, 0.2, 0.3)); - m_ScintillatorMaterial = CreateScintillatorMaterial(); - m_PipeMaterial = CreatePipeMaterial(); - //m_WrappingMaterial = CreateWrappingMaterial(); -// m_WrappingMaterial = NULL; - m_ReflectiveSurface = CreateReflectiveSurface(); - - m_VisSquare->SetForceWireframe(true); - m_VisPipe->SetForceWireframe(true); + m_VisPipe = new G4VisAttributes(G4Colour(0, 1, 0, 0.5)); + m_VisPD = new G4VisAttributes(G4Colour(0.1, 0.2, 0.3)); + m_ScintillatorMaterial = CreateScintillatorMaterial(); + m_PipeMaterial = CreatePipeMaterial(); + // m_WrappingMaterial = CreateWrappingMaterial(); + // m_WrappingMaterial = NULL; + m_ReflectiveSurface = CreateReflectiveSurface(); + + m_VisSquare->SetForceWireframe(true); + m_VisPipe->SetForceWireframe(true); } -LightPipe::~LightPipe(){ -} +LightPipe::~LightPipe() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void LightPipe::AddDetector(G4int nrow, G4int ncol, G4int nlayer, G4double width, G4double thickness, G4double pipe_width, G4double pipe_thickness){ - m_Detector.emplace_back(make_tuple(nrow,ncol,nlayer,width,thickness,pipe_width,pipe_thickness)); +void LightPipe::AddDetector(G4int nrow, G4int ncol, G4int nlayer, G4double width, G4double thickness, + G4double pipe_width, G4double pipe_thickness) { + m_Detector.emplace_back(make_tuple(nrow, ncol, nlayer, width, thickness, pipe_width, pipe_thickness)); } - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void LightPipe::ReadConfiguration(NPL::InputParser parser){ +void LightPipe::ReadConfiguration(NPL::InputParser parser) { - G4double width = 10*mm; - G4double thickness = 10*mm; - G4double pipe_width = 3*mm; - G4double pipe_thickness = 1*mm; - G4int nrow = 1; - G4int ncol = 1; - G4int nlayer = 1; + G4double width = 10 * mm; + G4double thickness = 10 * mm; + G4double pipe_width = 3 * mm; + G4double pipe_thickness = 1 * mm; + G4int nrow = 1; + G4int ncol = 1; + G4int nlayer = 1; vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("LightPipe"); - if(true || NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " detectors found " << endl; - vector<string> lp = {"WIDTH","THICKNESS","PIPE_WIDTH","PIPE_THICKNESS","NROW","NCOL","NLAYER"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(lp)){ - if(true || NPOptionManager::getInstance()->GetVerboseLevel()){ - cout << endl << "//// LightPipe " << i+1 << endl; - } - width = blocks[i]->GetDouble("WIDTH", "mm"); - thickness = blocks[i]->GetDouble("THICKNESS", "mm"); - pipe_width = blocks[i]->GetDouble("PIPE_WIDTH", "mm"); - pipe_thickness = blocks[i]->GetDouble("PIPE_THICKNESS", "mm"); - nrow = blocks[i]->GetInt("NROW"); - ncol = blocks[i]->GetInt("NCOL"); - nlayer = blocks[i]->GetInt("NLAYER"); + if (true || NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + vector<string> lp = {"WIDTH", "THICKNESS", "PIPE_WIDTH", "PIPE_THICKNESS", "NROW", "NCOL", "NLAYER"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(lp)) { + if (true || NPOptionManager::getInstance()->GetVerboseLevel()) { + cout << endl << "//// LightPipe " << i + 1 << endl; + } + width = blocks[i]->GetDouble("WIDTH", "mm"); + thickness = blocks[i]->GetDouble("THICKNESS", "mm"); + pipe_width = blocks[i]->GetDouble("PIPE_WIDTH", "mm"); + pipe_thickness = blocks[i]->GetDouble("PIPE_THICKNESS", "mm"); + nrow = blocks[i]->GetInt("NROW"); + ncol = blocks[i]->GetInt("NCOL"); + nlayer = blocks[i]->GetInt("NLAYER"); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } } - // - AddDetector(nrow, ncol, nlayer, width, thickness, pipe_width, pipe_thickness); + // + AddDetector(nrow, ncol, nlayer, width, thickness, pipe_width, pipe_thickness); } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void LightPipe::ConstructDetector(G4LogicalVolume* world){ - bool warnOverlap = false; - - - //Create experimental hall - G4Material* Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum") ; - G4double expHall_x = 10.*m; - G4double expHall_y = 10.*m; - G4double expHall_z = 10.*m; - - G4Box* fExperimentalHall_box = new G4Box("expHall_box",expHall_x,expHall_y,expHall_z); - G4LogicalVolume* fExperimentalHall_log = new G4LogicalVolume(fExperimentalHall_box, - Vacuum,"expHall_log",0,0,0); - G4VPhysicalVolume* fExperimentalHall_phys = new G4PVPlacement(0,G4ThreeVector(), - fExperimentalHall_log,"expHall",0,false,0); - - fExperimentalHall_log->SetVisAttributes(G4VisAttributes::Invisible); - - auto BuildRectangle = [this](G4double width, G4double length, G4double thickness, G4Material* material){ - G4Box* box = new G4Box("LightPipe_Box",width*0.5, - length*0.5,thickness*0.5); - G4LogicalVolume* Detector = new G4LogicalVolume(box,material,"logic_LightPipe_Box",0,0,0); +void LightPipe::ConstructDetector(G4LogicalVolume* world) { + bool warnOverlap = false; + + // Create experimental hall + G4Material* Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); + G4double expHall_x = 10. * m; + G4double expHall_y = 10. * m; + G4double expHall_z = 10. * m; + + G4Box* fExperimentalHall_box = new G4Box("expHall_box", expHall_x, expHall_y, expHall_z); + G4LogicalVolume* fExperimentalHall_log = new G4LogicalVolume(fExperimentalHall_box, Vacuum, "expHall_log", 0, 0, 0); + G4VPhysicalVolume* fExperimentalHall_phys = + new G4PVPlacement(0, G4ThreeVector(), fExperimentalHall_log, "expHall", 0, false, 0); + + fExperimentalHall_log->SetVisAttributes(G4VisAttributes::GetInvisible()); + + auto BuildRectangle = [this](G4double width, G4double length, G4double thickness, G4Material* material) { + G4Box* box = new G4Box("LightPipe_Box", width * 0.5, length * 0.5, thickness * 0.5); + G4LogicalVolume* Detector = new G4LogicalVolume(box, material, "logic_LightPipe_Box", 0, 0, 0); Detector->SetVisAttributes(this->m_VisSquare); -// Detector->SetSensitiveDetector(this->m_LightPipeScorer); - return Detector; - }; - auto getCenter = [&](int i, int imax, double width){ - return (i - (imax/2.))*width + width/2.; - }; - - //int i=0, j=0, k=0; - - int iPipeX=1,/* iPipeY=1,*/ iDet=1; - for(const auto& det : m_Detector) { - const G4int& nrow = get<0>(det); - const G4int& ncol = get<1>(det); - //const G4int& nlayer = get<2>(det); - const G4double& width = get<3>(det); - const G4double& thickness = get<4>(det); - const G4double& pipe_width = get<5>(det); - const G4double& pipe_thickness = get<6>(det); - //const G4double pd_thickness = 1*mm; - - vector<vector<G4PVPlacement*> > physVol(nrow); - for(auto& v : physVol) { v.resize(ncol); } - - - auto buildRow = [&](G4int irow, G4double z){ - //G4double rowWidthX = nrow*width; - G4double pipe_length = width*ncol + 1*cm; - // - // Build light pipe above detectors - // - // Create geometric object - G4ThreeVector pipePos( - 0, getCenter(irow, nrow, width) + width/2. + pipe_thickness/2., z); - auto pipe = BuildRectangle( - pipe_length, pipe_width, pipe_thickness, m_PipeMaterial); - pipe->SetVisAttributes(m_VisPipe); - // Rotate it - G4RotationMatrix* myRotation = new G4RotationMatrix(); - myRotation->rotateX(90.*deg); - // Create PV Placement - new G4PVPlacement( - myRotation, pipePos, pipe, "LightPipe_PipeX", world, false, iPipeX++, warnOverlap); - - std::vector<G4PVPlacement*> pvRow; - for(int icol=0; icol< ncol; ++icol){ - // - // Build row of detectors - // - // - // Create geometric object - G4ThreeVector Det_pos - (getCenter(icol,ncol,width), getCenter(irow,nrow,width), z); - auto Scintillator = BuildRectangle(width, width, thickness, m_ScintillatorMaterial); -// Scintillator->SetSensitiveDetector(this->m_LightPipeScorer); - // Create PV placement - pvRow.push_back( - new G4PVPlacement( - 0, Det_pos, Scintillator, "LightPipe_Detector", world, false, iDet++, warnOverlap) ); - } - // Create reflective surfaces between detectors - for(int icol=0; icol< ncol; ++icol){ - // to the left - if(icol != 0) { - new G4LogicalBorderSurface("CrystalSurface", pvRow.at(icol-1), pvRow.at(icol), m_ReflectiveSurface); - } else { - new G4LogicalBorderSurface("CrystalSurface", fExperimentalHall_phys, pvRow.at(icol), m_ReflectiveSurface); - } - // to the right - if(icol != ncol-1) { - new G4LogicalBorderSurface("CrystalSurface", pvRow.at(icol), pvRow.at(icol+1), m_ReflectiveSurface); - } else { - new G4LogicalBorderSurface("CrystalSurface", pvRow.at(icol), fExperimentalHall_phys, m_ReflectiveSurface); - } - } - return pvRow; - }; + // Detector->SetSensitiveDetector(this->m_LightPipeScorer); + return Detector; + }; + auto getCenter = [&](int i, int imax, double width) { return (i - (imax / 2.)) * width + width / 2.; }; + + // int i=0, j=0, k=0; + + int iPipeX = 1, /* iPipeY=1,*/ iDet = 1; + for (const auto& det : m_Detector) { + const G4int& nrow = get<0>(det); + const G4int& ncol = get<1>(det); + // const G4int& nlayer = get<2>(det); + const G4double& width = get<3>(det); + const G4double& thickness = get<4>(det); + const G4double& pipe_width = get<5>(det); + const G4double& pipe_thickness = get<6>(det); + // const G4double pd_thickness = 1*mm; + + vector<vector<G4PVPlacement*>> physVol(nrow); + for (auto& v : physVol) { + v.resize(ncol); + } - buildRow(5,0); + auto buildRow = [&](G4int irow, G4double z) { + // G4double rowWidthX = nrow*width; + G4double pipe_length = width * ncol + 1 * cm; + // + // Build light pipe above detectors + // + // Create geometric object + G4ThreeVector pipePos(0, getCenter(irow, nrow, width) + width / 2. + pipe_thickness / 2., z); + auto pipe = BuildRectangle(pipe_length, pipe_width, pipe_thickness, m_PipeMaterial); + pipe->SetVisAttributes(m_VisPipe); + // Rotate it + G4RotationMatrix* myRotation = new G4RotationMatrix(); + myRotation->rotateX(90. * deg); + // Create PV Placement + new G4PVPlacement(myRotation, pipePos, pipe, "LightPipe_PipeX", world, false, iPipeX++, warnOverlap); + + std::vector<G4PVPlacement*> pvRow; + for (int icol = 0; icol < ncol; ++icol) { + // + // Build row of detectors + // + // + // Create geometric object + G4ThreeVector Det_pos(getCenter(icol, ncol, width), getCenter(irow, nrow, width), z); + auto Scintillator = BuildRectangle(width, width, thickness, m_ScintillatorMaterial); + // Scintillator->SetSensitiveDetector(this->m_LightPipeScorer); + // Create PV placement + pvRow.push_back( + new G4PVPlacement(0, Det_pos, Scintillator, "LightPipe_Detector", world, false, iDet++, warnOverlap)); + } + // Create reflective surfaces between detectors + for (int icol = 0; icol < ncol; ++icol) { + // to the left + if (icol != 0) { + new G4LogicalBorderSurface("CrystalSurface", pvRow.at(icol - 1), pvRow.at(icol), m_ReflectiveSurface); + } + else { + new G4LogicalBorderSurface("CrystalSurface", fExperimentalHall_phys, pvRow.at(icol), m_ReflectiveSurface); + } + // to the right + if (icol != ncol - 1) { + new G4LogicalBorderSurface("CrystalSurface", pvRow.at(icol), pvRow.at(icol + 1), m_ReflectiveSurface); + } + else { + new G4LogicalBorderSurface("CrystalSurface", pvRow.at(icol), fExperimentalHall_phys, m_ReflectiveSurface); + } + } + return pvRow; + }; + + buildRow(5, 0); #if 0 int pdNum = 1; @@ -363,26 +352,26 @@ void LightPipe::ConstructDetector(G4LogicalVolume* world){ buildPipe(true, detZ); } // for(ilayer) #endif - } + } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void LightPipe::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("LightPipe")){ - pTree->Branch("LightPipe", "TLightPipeData", &m_Event) ; +void LightPipe::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("LightPipe")) { + pTree->Branch("LightPipe", "TLightPipeData", &m_Event); } - pTree->SetBranchAddress("LightPipe", &m_Event) ; + pTree->SetBranchAddress("LightPipe", &m_Event); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void LightPipe::ReadSensitive(const G4Event* event){ +void LightPipe::ReadSensitive(const G4Event* event) { m_Event->Clear(); - return; + return; /////////// // Calorimeter scorer NPS::HitsMap<G4double*>* CaloHitMap; @@ -407,222 +396,224 @@ void LightPipe::ReadSensitive(const G4Event* event){ // clear map for next event CaloHitMap->clear(); - // PhotoDiode // - NPS::HitsMap<G4double*>* PhotoDiodeHitMap; - std::map<G4int, G4double**>::iterator PhotoDiode_itr; - - G4int PhotoDiodeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("PDScorer/PhotoDiode"); - PhotoDiodeHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(PhotoDiodeCollectionID)); - - // Loop on the PhotoDiode map - map<int, int> NumberOfOpticalPhoton; // <det no, # photons> - for(const auto& hit : *PhotoDiodeHitMap->GetMap()) { - G4double* Info = *(hit.second); - G4int detectorNumber = Info[7]; - if(NumberOfOpticalPhoton.find(detectorNumber) == NumberOfOpticalPhoton.end()){ - NumberOfOpticalPhoton[detectorNumber] = 0; - } - NumberOfOpticalPhoton[detectorNumber] += Info[8]; - } - - for(const auto& pd : NumberOfOpticalPhoton) { - int det = pd.first; // detector number - int numPhoton = pd.second; - auto detMap = m_DetectorMap.find(det); - if(detMap != m_DetectorMap.end()){ - const auto& side = get<0>(detMap->second); - const auto& layer = get<1>(detMap->second); - const auto& row = get<2>(detMap->second); - m_Event->SetEnergy(side, layer, row, numPhoton); - } else { - std::cerr << "WARNING:: Detector number encountered without map! The number is: " << det << "\nSkipping event...\n"; - } - } - - PhotoDiodeHitMap->clear(); + // PhotoDiode // + NPS::HitsMap<G4double*>* PhotoDiodeHitMap; + std::map<G4int, G4double**>::iterator PhotoDiode_itr; + + G4int PhotoDiodeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("PDScorer/PhotoDiode"); + PhotoDiodeHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(PhotoDiodeCollectionID)); + + // Loop on the PhotoDiode map + map<int, int> NumberOfOpticalPhoton; // <det no, # photons> + for (const auto& hit : *PhotoDiodeHitMap->GetMap()) { + G4double* Info = *(hit.second); + G4int detectorNumber = Info[7]; + if (NumberOfOpticalPhoton.find(detectorNumber) == NumberOfOpticalPhoton.end()) { + NumberOfOpticalPhoton[detectorNumber] = 0; + } + NumberOfOpticalPhoton[detectorNumber] += Info[8]; + } + + for (const auto& pd : NumberOfOpticalPhoton) { + int det = pd.first; // detector number + int numPhoton = pd.second; + auto detMap = m_DetectorMap.find(det); + if (detMap != m_DetectorMap.end()) { + const auto& side = get<0>(detMap->second); + const auto& layer = get<1>(detMap->second); + const auto& row = get<2>(detMap->second); + m_Event->SetEnergy(side, layer, row, numPhoton); + } + else { + std::cerr << "WARNING:: Detector number encountered without map! The number is: " << det + << "\nSkipping event...\n"; + } + } + + PhotoDiodeHitMap->clear(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -//////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////// void LightPipe::InitializeScorers() { // This check is necessary in case the geometry is reloaded bool already_exist = false; - vector<G4int> NestingLevel; - NestingLevel.push_back(0); - NestingLevel.push_back(1); - m_LightPipeScorer = CheckScorer("LightPipeScorer",already_exist) ; - m_PDScorer = CheckScorer("PDScorer",already_exist) ; - - if(already_exist) { - return ; - } + vector<G4int> NestingLevel; + NestingLevel.push_back(0); + NestingLevel.push_back(1); + m_LightPipeScorer = CheckScorer("LightPipeScorer", already_exist); + m_PDScorer = CheckScorer("PDScorer", already_exist); + + if (already_exist) { + return; + } // Otherwise the scorer is initialised - vector<int> level; level.push_back(0); - G4VPrimitiveScorer* Calorimeter= new CalorimeterScorers::PS_Calorimeter("Calorimeter",NestingLevel, 0) ; - //and register it to the multifunctionnal detector + vector<int> level; + level.push_back(0); + G4VPrimitiveScorer* Calorimeter = new CalorimeterScorers::PS_Calorimeter("Calorimeter", NestingLevel, 0); + // and register it to the multifunctionnal detector m_LightPipeScorer->RegisterPrimitive(Calorimeter); - G4VPrimitiveScorer* PDScorer = - new PHOTODIODESCORERS::PS_PhotoDiode_Rectangle - ("PhotoDiode",0,GetPipeWidth(0),GetPipeWidth(0),1,1); - m_PDScorer->RegisterPrimitive(PDScorer); - - G4SDManager::GetSDMpointer()->AddNewDetector(m_LightPipeScorer) ; - G4SDManager::GetSDMpointer()->AddNewDetector(m_PDScorer) ; + G4VPrimitiveScorer* PDScorer = + new PHOTODIODESCORERS::PS_PhotoDiode_Rectangle("PhotoDiode", 0, GetPipeWidth(0), GetPipeWidth(0), 1, 1); + m_PDScorer->RegisterPrimitive(PDScorer); + + G4SDManager::GetSDMpointer()->AddNewDetector(m_LightPipeScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_PDScorer); } - + G4Material* LightPipe::CreateScintillatorMaterial() const { - // p-Terphenyl - // Taken from Proteus, Inc. specs - // See here: http://people.physics.tamu.edu/christian/files/p-terphenyl.png - // - G4double specificGravity = 1.23; // from proteus - G4double densityReference = 0.999972*g/cm3; // water @4-deg C [ the standard ] - G4double density = specificGravity*densityReference; - - G4Material* material = new G4Material("p_Terphenyl_Scint", density, 2); - material->AddElement(MaterialManager::getInstance()->GetElementFromLibrary("H"), 10); - material->AddElement(MaterialManager::getInstance()->GetElementFromLibrary("C"), 14); - - // Adding Scintillation property: - vector<double> energy, scint, fast, slow, rindx, atten; - { - // Read emission spectrum from datfile (+ add constant parameters) - ifstream ifs(gSystem->ExpandPathName("$NPTOOL/NPSimulation/Detectors/LightPipe/p-terphenyl_emission.dat")); - if(!ifs.good()){ - std::cerr << "ERROR: Couldn't open file: \"$NPTOOL/NPSimulation/Detectors/LightPipe/p-terphenyl_emission.dat\"\n"; - exit(1); - } - double wl, pr; - while(ifs >> wl >> pr) { - energy.emplace_back( h_Planck*c_light / (wl*nm) ); // convert to energy - scint.emplace_back(pr); // scintillation probability - rindx.emplace_back(1.65); // refractive index - fast.emplace_back(3*ns); // FAST component ??? - slow.emplace_back(100*ns); // SLOW component ??? - atten.emplace_back(4.73*mm); // Attenuation length (from https://arxiv.org/pdf/1305.0442.pdf) - } - } - - // Set Material Properties - G4int numPoints = energy.size(); - G4MaterialPropertiesTable* MPT = new G4MaterialPropertiesTable(); - MPT->AddConstProperty("SCINTILLATIONYIELD", 27000/MeV); // from proteus - MPT->AddProperty("SCINTILLATION", &energy[0], &scint[0], numPoints); - MPT->AddProperty("RINDEX", &energy[0], &rindx[0], numPoints) ; - MPT->AddProperty("ABSLENGTH", &energy[0], &atten[0], numPoints); - MPT->AddProperty("FASTCOMPONENT", &energy[0], &fast[0], numPoints); - MPT->AddProperty("SLOWCOMPONENT", &energy[0], &slow[0], numPoints); - MPT->AddConstProperty("RESOLUTIONSCALE", 1.0); - MPT->AddConstProperty("FASTTIMECONSTANT", 20*ns); // ????? - MPT->AddConstProperty("SLOWTIMECONSTANT", 100*ns); // ????? - MPT->AddConstProperty("YIELDRATIO",1.0); // ????? - material->SetMaterialPropertiesTable(MPT); - return material; + // p-Terphenyl + // Taken from Proteus, Inc. specs + // See here: http://people.physics.tamu.edu/christian/files/p-terphenyl.png + // + G4double specificGravity = 1.23; // from proteus + G4double densityReference = 0.999972 * g / cm3; // water @4-deg C [ the standard ] + G4double density = specificGravity * densityReference; + + G4Material* material = new G4Material("p_Terphenyl_Scint", density, 2); + material->AddElement(MaterialManager::getInstance()->GetElementFromLibrary("H"), 10); + material->AddElement(MaterialManager::getInstance()->GetElementFromLibrary("C"), 14); + + // Adding Scintillation property: + vector<double> energy, scint, fast, slow, rindx, atten; + { + // Read emission spectrum from datfile (+ add constant parameters) + ifstream ifs(gSystem->ExpandPathName("$NPTOOL/NPSimulation/Detectors/LightPipe/p-terphenyl_emission.dat")); + if (!ifs.good()) { + std::cerr << "ERROR: Couldn't open file: \"$NPTOOL/NPSimulation/Detectors/LightPipe/p-terphenyl_emission.dat\"\n"; + exit(1); + } + double wl, pr; + while (ifs >> wl >> pr) { + energy.emplace_back(h_Planck * c_light / (wl * nm)); // convert to energy + scint.emplace_back(pr); // scintillation probability + rindx.emplace_back(1.65); // refractive index + fast.emplace_back(3 * ns); // FAST component ??? + slow.emplace_back(100 * ns); // SLOW component ??? + atten.emplace_back(4.73 * mm); // Attenuation length (from https://arxiv.org/pdf/1305.0442.pdf) + } + } + + // Set Material Properties + G4int numPoints = energy.size(); + G4MaterialPropertiesTable* MPT = new G4MaterialPropertiesTable(); + MPT->AddConstProperty("SCINTILLATIONYIELD", 27000 / MeV); // from proteus + MPT->AddProperty("SCINTILLATION", &energy[0], &scint[0], numPoints); + MPT->AddProperty("RINDEX", &energy[0], &rindx[0], numPoints); + MPT->AddProperty("ABSLENGTH", &energy[0], &atten[0], numPoints); + MPT->AddProperty("FASTCOMPONENT", &energy[0], &fast[0], numPoints); + MPT->AddProperty("SLOWCOMPONENT", &energy[0], &slow[0], numPoints); + MPT->AddConstProperty("RESOLUTIONSCALE", 1.0); + MPT->AddConstProperty("FASTTIMECONSTANT", 20 * ns); // ????? + MPT->AddConstProperty("SLOWTIMECONSTANT", 100 * ns); // ????? + MPT->AddConstProperty("YIELDRATIO", 1.0); // ????? + material->SetMaterialPropertiesTable(MPT); + return material; } G4Material* LightPipe::CreatePipeMaterial() const { - // Bicron BC-482A - // https://www.crystals.saint-gobain.com/sites/imdf.crystals.com/files/documents/bc482a-bc484-data-sheet.pdf - // https://www.crystals.saint-gobain.com/sites/imdf.crystals.com/files/documents/organics-plastic-scintillators.pdf - // - G4double density = 1.03*g/cm3; - - G4Material* material = new G4Material("BC482A_WLS", density, 2); - material->AddElement(MaterialManager::getInstance()->GetElementFromLibrary("H"), 10); // H:C ratio - 1.110 - material->AddElement(MaterialManager::getInstance()->GetElementFromLibrary("C"), 9); - - // Adding WLS property - auto readDatfile = [](const char* fname, vector<double>& energy, vector<double>& abs, vector<double>& emit){ - ifstream ifs(gSystem->ExpandPathName(fname)); - if(!ifs.good()) { - std::cerr << "ERROR: no file: \"" << fname << "\"\n"; - exit(1); - } - // skip header - std::string dummy; - std::getline(ifs, dummy); - - double wl, pr_a, pr_e; - while(ifs >> wl >> pr_a >> pr_e) { - energy.emplace_back( h_Planck*c_light / (wl*nm) ); // convert to energy - abs.emplace_back(pr_a); // absorption probability - emit.emplace_back(pr_e); // emission probability - } - // SORT IN ORDER OF INCREASING ENERGY - vector<int> isort(energy.size()); - vector<double> e0 = energy, pa0 = abs, pe0 = emit; - TMath::Sort((int)energy.size(), &energy[0], &isort[0]); - for(size_t i=0; i< energy.size(); ++i){ - energy.at(i) = e0.at(isort.at(i)); - abs.at(i) = pa0.at(isort.at(i)); - emit.at(i) = pe0.at(isort.at(i)); - } - }; - // Absorption & Emission - vector<double> energy, p_abs, p_emit; - readDatfile("$NPTOOL/NPSimulation/Detectors/LightPipe/BC482A_properties.dat", energy, p_abs, p_emit); - // - // Absorption is given as a probability, but GEANT4 needs a length - // Invert and set the minimum to 0.4336 mm, which is the (measured) - // attenuation length for EJ-280 @peak absorption. - // This is not exact, but it's close. - // For absorption of 0, set attenuation length very long (5 m) - for(auto&& p : p_abs) { - p = p > 0 ? (0.4336*mm) / p : 5*m; - } - - // - const size_t numPoints = energy.size(); - vector<double> rindx(numPoints, 1.59); - vector<double> abslength(numPoints, 400*cm); // BULK attenuation length - - // Set Material Properties - G4MaterialPropertiesTable* MPT = new G4MaterialPropertiesTable(); - MPT->AddProperty("RINDEX", &energy[0], &rindx[0], numPoints); - MPT->AddProperty("ABSLENGTH", &energy[0], &abslength[0], numPoints); - MPT->AddProperty("WLSABSLENGTH", &energy[0], &p_abs[0], numPoints); - MPT->AddProperty("WLSCOMPONENT", &energy[0], &p_emit[0], numPoints); - MPT->AddConstProperty("WLSTIMECONSTANT", 12.*ns); - MPT->AddConstProperty("WLSMEANNUMBEROFPHOTONS", 0.86); - - material->SetMaterialPropertiesTable(MPT); - return material; + // Bicron BC-482A + // https://www.crystals.saint-gobain.com/sites/imdf.crystals.com/files/documents/bc482a-bc484-data-sheet.pdf + // https://www.crystals.saint-gobain.com/sites/imdf.crystals.com/files/documents/organics-plastic-scintillators.pdf + // + G4double density = 1.03 * g / cm3; + + G4Material* material = new G4Material("BC482A_WLS", density, 2); + material->AddElement(MaterialManager::getInstance()->GetElementFromLibrary("H"), 10); // H:C ratio - 1.110 + material->AddElement(MaterialManager::getInstance()->GetElementFromLibrary("C"), 9); + + // Adding WLS property + auto readDatfile = [](const char* fname, vector<double>& energy, vector<double>& abs, vector<double>& emit) { + ifstream ifs(gSystem->ExpandPathName(fname)); + if (!ifs.good()) { + std::cerr << "ERROR: no file: \"" << fname << "\"\n"; + exit(1); + } + // skip header + std::string dummy; + std::getline(ifs, dummy); + + double wl, pr_a, pr_e; + while (ifs >> wl >> pr_a >> pr_e) { + energy.emplace_back(h_Planck * c_light / (wl * nm)); // convert to energy + abs.emplace_back(pr_a); // absorption probability + emit.emplace_back(pr_e); // emission probability + } + // SORT IN ORDER OF INCREASING ENERGY + vector<int> isort(energy.size()); + vector<double> e0 = energy, pa0 = abs, pe0 = emit; + TMath::Sort((int)energy.size(), &energy[0], &isort[0]); + for (size_t i = 0; i < energy.size(); ++i) { + energy.at(i) = e0.at(isort.at(i)); + abs.at(i) = pa0.at(isort.at(i)); + emit.at(i) = pe0.at(isort.at(i)); + } + }; + // Absorption & Emission + vector<double> energy, p_abs, p_emit; + readDatfile("$NPTOOL/NPSimulation/Detectors/LightPipe/BC482A_properties.dat", energy, p_abs, p_emit); + // + // Absorption is given as a probability, but GEANT4 needs a length + // Invert and set the minimum to 0.4336 mm, which is the (measured) + // attenuation length for EJ-280 @peak absorption. + // This is not exact, but it's close. + // For absorption of 0, set attenuation length very long (5 m) + for (auto&& p : p_abs) { + p = p > 0 ? (0.4336 * mm) / p : 5 * m; + } + + // + const size_t numPoints = energy.size(); + vector<double> rindx(numPoints, 1.59); + vector<double> abslength(numPoints, 400 * cm); // BULK attenuation length + + // Set Material Properties + G4MaterialPropertiesTable* MPT = new G4MaterialPropertiesTable(); + MPT->AddProperty("RINDEX", &energy[0], &rindx[0], numPoints); + MPT->AddProperty("ABSLENGTH", &energy[0], &abslength[0], numPoints); + MPT->AddProperty("WLSABSLENGTH", &energy[0], &p_abs[0], numPoints); + MPT->AddProperty("WLSCOMPONENT", &energy[0], &p_emit[0], numPoints); + MPT->AddConstProperty("WLSTIMECONSTANT", 12. * ns); + MPT->AddConstProperty("WLSMEANNUMBEROFPHOTONS", 0.86); + + material->SetMaterialPropertiesTable(MPT); + return material; } G4Material* LightPipe::CreateWrappingMaterial() const { - // Teflon (C2F4) -- for now - // - G4double density = 2.2*g/cm3; - - G4Material* material = new G4Material("TEFLON", density, 2); - material->AddElement(MaterialManager::getInstance()->GetElementFromLibrary("F"), 4); // H:C ratio - 1.110 - material->AddElement(MaterialManager::getInstance()->GetElementFromLibrary("C"), 2); - return material; + // Teflon (C2F4) -- for now + // + G4double density = 2.2 * g / cm3; + + G4Material* material = new G4Material("TEFLON", density, 2); + material->AddElement(MaterialManager::getInstance()->GetElementFromLibrary("F"), 4); // H:C ratio - 1.110 + material->AddElement(MaterialManager::getInstance()->GetElementFromLibrary("C"), 2); + return material; } G4OpticalSurface* LightPipe::CreateReflectiveSurface() const { - G4OpticalSurface* OpticalCrystalSurface = new G4OpticalSurface("CrystalSurface"); - OpticalCrystalSurface->SetType(dielectric_metal); - //polished: smooth perfectly polished surcface - //ground: rough surface - OpticalCrystalSurface->SetFinish(polished); - //unified - //glisur - OpticalCrystalSurface->SetModel(glisur); - - G4double pp[] = {0.01*eV, 10*eV}; - const G4int num = sizeof(pp)/sizeof(G4double); - G4double reflectivity[] = {1., 1.}; - G4double efficiency[] = {1., 1.}; - - G4MaterialPropertiesTable* OpticalCrystalSurfaceProperty = new G4MaterialPropertiesTable(); - - OpticalCrystalSurfaceProperty->AddProperty("REFLECTIVITY",pp,reflectivity,num); - OpticalCrystalSurfaceProperty->AddProperty("EFFICIENCY",pp,efficiency,num); - OpticalCrystalSurface->SetMaterialPropertiesTable(OpticalCrystalSurfaceProperty); - return OpticalCrystalSurface; + G4OpticalSurface* OpticalCrystalSurface = new G4OpticalSurface("CrystalSurface"); + OpticalCrystalSurface->SetType(dielectric_metal); + // polished: smooth perfectly polished surcface + // ground: rough surface + OpticalCrystalSurface->SetFinish(polished); + // unified + // glisur + OpticalCrystalSurface->SetModel(glisur); + + G4double pp[] = {0.01 * eV, 10 * eV}; + const G4int num = sizeof(pp) / sizeof(G4double); + G4double reflectivity[] = {1., 1.}; + G4double efficiency[] = {1., 1.}; + + G4MaterialPropertiesTable* OpticalCrystalSurfaceProperty = new G4MaterialPropertiesTable(); + + OpticalCrystalSurfaceProperty->AddProperty("REFLECTIVITY", pp, reflectivity, num); + OpticalCrystalSurfaceProperty->AddProperty("EFFICIENCY", pp, efficiency, num); + OpticalCrystalSurface->SetMaterialPropertiesTable(OpticalCrystalSurfaceProperty); + return OpticalCrystalSurface; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -631,21 +622,19 @@ G4OpticalSurface* LightPipe::CreateReflectiveSurface() const { //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* LightPipe::Construct(){ - return (NPS::VDetector*) new LightPipe(); -} +NPS::VDetector* LightPipe::Construct() { return (NPS::VDetector*)new LightPipe(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { -class proxy_nps_LightPipe{ -public: - proxy_nps_LightPipe(){ - NPS::DetectorFactory::getInstance()->AddToken("LightPipe","LightPipe"); - NPS::DetectorFactory::getInstance()->AddDetector("LightPipe",LightPipe::Construct); - } +extern "C" { +class proxy_nps_LightPipe { + public: + proxy_nps_LightPipe() { + NPS::DetectorFactory::getInstance()->AddToken("LightPipe", "LightPipe"); + NPS::DetectorFactory::getInstance()->AddDetector("LightPipe", LightPipe::Construct); + } }; proxy_nps_LightPipe p_nps_LightPipe; diff --git a/NPSimulation/Detectors/MUST2/MUST2Array.cc b/NPSimulation/Detectors/MUST2/MUST2Array.cc index 1545d2bdc..439dc81ad 100644 --- a/NPSimulation/Detectors/MUST2/MUST2Array.cc +++ b/NPSimulation/Detectors/MUST2/MUST2Array.cc @@ -69,18 +69,15 @@ MUST2Array::MUST2Array() { m_Event = new TMust2Data(); InitializeMaterial(); m_StripScorer = 0; - m_SiLiScorer = 0; - m_CsIScorer = 0; + m_SiLiScorer = 0; + m_CsIScorer = 0; } MUST2Array::~MUST2Array() {} - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void MUST2Array::AddTelescope(G4ThreeVector X1_Y1, G4ThreeVector X128_Y1, - G4ThreeVector X1_Y128, G4ThreeVector X128_Y128, - bool wSi, bool wSiLi, bool wCsI) { +void MUST2Array::AddTelescope(G4ThreeVector X1_Y1, G4ThreeVector X128_Y1, G4ThreeVector X1_Y128, + G4ThreeVector X128_Y128, bool wSi, bool wSiLi, bool wCsI) { m_DefinitionType.push_back(true); m_X1_Y1.push_back(X1_Y1); @@ -99,9 +96,8 @@ void MUST2Array::AddTelescope(G4ThreeVector X1_Y1, G4ThreeVector X128_Y1, m_beta_w.push_back(0); } -void MUST2Array::AddTelescope(G4double R, G4double Theta, G4double Phi, - G4double beta_u, G4double beta_v, G4double beta_w, - bool wSi, bool wSiLi, bool wCsI) { +void MUST2Array::AddTelescope(G4double R, G4double Theta, G4double Phi, G4double beta_u, G4double beta_v, + G4double beta_w, bool wSi, bool wSiLi, bool wCsI) { G4ThreeVector empty = G4ThreeVector(0, 0, 0); m_DefinitionType.push_back(false); @@ -123,11 +119,10 @@ void MUST2Array::AddTelescope(G4double R, G4double Theta, G4double Phi, } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void MUST2Array::VolumeMaker(G4int TelescopeNumber, G4ThreeVector MMpos, - G4RotationMatrix* MMrot, bool wSi, bool wSiLi, - bool wCsI, G4LogicalVolume* world) { - G4double NbrTelescopes = TelescopeNumber; - G4String DetectorNumber; +void MUST2Array::VolumeMaker(G4int TelescopeNumber, G4ThreeVector MMpos, G4RotationMatrix* MMrot, bool wSi, bool wSiLi, + bool wCsI, G4LogicalVolume* world) { + G4double NbrTelescopes = TelescopeNumber; + G4String DetectorNumber; std::ostringstream Number; Number << NbrTelescopes; DetectorNumber = Number.str(); @@ -135,36 +130,30 @@ void MUST2Array::VolumeMaker(G4int TelescopeNumber, G4ThreeVector MMpos, //////////////////////////////////////////////////////////////// ////////////// Starting Volume Definition ////////////////////// //////////////////////////////////////////////////////////////// - G4Trd* solidMM = new G4Trd("MUST2Telescope" + DetectorNumber, 0.5 * FaceFront, - 0.5 * FaceBack, 0.5 * FaceFront, 0.5 * FaceBack, - 0.5 * Length); - G4LogicalVolume* logicMM = new G4LogicalVolume( - solidMM, m_MaterialIron, "MUST2Telescope" + DetectorNumber, 0, 0, 0); + G4Trd* solidMM = new G4Trd("MUST2Telescope" + DetectorNumber, 0.5 * FaceFront, 0.5 * FaceBack, 0.5 * FaceFront, + 0.5 * FaceBack, 0.5 * Length); + G4LogicalVolume* logicMM = new G4LogicalVolume(solidMM, m_MaterialIron, "MUST2Telescope" + DetectorNumber, 0, 0, 0); G4String Name = "MUST2Telescope" + DetectorNumber; - new G4PVPlacement(G4Transform3D(*MMrot, MMpos), logicMM, Name, world, false, - TelescopeNumber); + new G4PVPlacement(G4Transform3D(*MMrot, MMpos), logicMM, Name, world, false, TelescopeNumber); if (m_non_sensitive_part_visiualisation) { - G4VisAttributes* FrameVisAtt - = new G4VisAttributes(G4Colour(0.80, 0.80, 0.80)); + G4VisAttributes* FrameVisAtt = new G4VisAttributes(G4Colour(0.80, 0.80, 0.80)); FrameVisAtt->SetForceWireframe(true); logicMM->SetVisAttributes(FrameVisAtt); - } else - logicMM->SetVisAttributes(G4VisAttributes::Invisible); + } + else + logicMM->SetVisAttributes(G4VisAttributes::GetInvisible()); G4ThreeVector positionVacBox = G4ThreeVector(0, 0, VacBox_PosZ); - G4Trd* solidVacBox - = new G4Trd("solidVacBox", 0.5 * SiliconFace, 0.5 * CsIFaceFront, - 0.5 * SiliconFace, 0.5 * CsIFaceFront, 0.5 * VacBoxThickness); - G4LogicalVolume* logicVacBox = new G4LogicalVolume( - solidVacBox, m_MaterialVacuum, "logicVacBox", 0, 0, 0); + G4Trd* solidVacBox = new G4Trd("solidVacBox", 0.5 * SiliconFace, 0.5 * CsIFaceFront, 0.5 * SiliconFace, + 0.5 * CsIFaceFront, 0.5 * VacBoxThickness); + G4LogicalVolume* logicVacBox = new G4LogicalVolume(solidVacBox, m_MaterialVacuum, "logicVacBox", 0, 0, 0); - new G4PVPlacement(0, positionVacBox, logicVacBox, Name + "_VacBox", logicMM, - false, TelescopeNumber); + new G4PVPlacement(0, positionVacBox, logicVacBox, Name + "_VacBox", logicMM, false, TelescopeNumber); - logicVacBox->SetVisAttributes(G4VisAttributes::Invisible); + logicVacBox->SetVisAttributes(G4VisAttributes::GetInvisible()); G4VisAttributes* SiliconVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)); @@ -173,32 +162,24 @@ void MUST2Array::VolumeMaker(G4int TelescopeNumber, G4ThreeVector MMpos, //////////////////////////////////////////////////////////////// if (wSi) { - G4ThreeVector positionAluStripFront - = G4ThreeVector(0, 0, AluStripFront_PosZ); + G4ThreeVector positionAluStripFront = G4ThreeVector(0, 0, AluStripFront_PosZ); G4ThreeVector positionAluStripBack = G4ThreeVector(0, 0, AluStripBack_PosZ); - G4Box* solidAluStrip - = new G4Box("AluBox", 0.5 * SiliconFace, 0.5 * SiliconFace, - 0.5 * AluStripThickness); - G4LogicalVolume* logicAluStrip = new G4LogicalVolume( - solidAluStrip, m_MaterialAluminium, "logicAluStrip", 0, 0, 0); + G4Box* solidAluStrip = new G4Box("AluBox", 0.5 * SiliconFace, 0.5 * SiliconFace, 0.5 * AluStripThickness); + G4LogicalVolume* logicAluStrip = new G4LogicalVolume(solidAluStrip, m_MaterialAluminium, "logicAluStrip", 0, 0, 0); - new G4PVPlacement(0, positionAluStripFront, logicAluStrip, - Name + "_AluStripFront", logicMM, false, TelescopeNumber); - new G4PVPlacement(0, positionAluStripBack, logicAluStrip, - Name + "_AluStripBack", logicMM, false, TelescopeNumber); + new G4PVPlacement(0, positionAluStripFront, logicAluStrip, Name + "_AluStripFront", logicMM, false, + TelescopeNumber); + new G4PVPlacement(0, positionAluStripBack, logicAluStrip, Name + "_AluStripBack", logicMM, false, TelescopeNumber); - logicAluStrip->SetVisAttributes(G4VisAttributes::Invisible); + logicAluStrip->SetVisAttributes(G4VisAttributes::GetInvisible()); G4ThreeVector positionSilicon = G4ThreeVector(0, 0, Silicon_PosZ); - G4Box* solidSilicon = new G4Box("solidSilicon", 0.5 * SiliconFace, - 0.5 * SiliconFace, 0.5 * SiliconThickness); - G4LogicalVolume* logicSilicon = new G4LogicalVolume( - solidSilicon, m_MaterialSilicon, "logicSilicon", 0, 0, 0); + G4Box* solidSilicon = new G4Box("solidSilicon", 0.5 * SiliconFace, 0.5 * SiliconFace, 0.5 * SiliconThickness); + G4LogicalVolume* logicSilicon = new G4LogicalVolume(solidSilicon, m_MaterialSilicon, "logicSilicon", 0, 0, 0); - new G4PVPlacement(0, positionSilicon, logicSilicon, Name + "_Silicon", - logicMM, false, TelescopeNumber); + new G4PVPlacement(0, positionSilicon, logicSilicon, Name + "_Silicon", logicMM, false, TelescopeNumber); /// Set Silicon strip sensible logicSilicon->SetSensitiveDetector(m_StripScorer); @@ -212,207 +193,148 @@ void MUST2Array::VolumeMaker(G4int TelescopeNumber, G4ThreeVector MMpos, //////////////////////////////////////////////////////////////// if (wSiLi) { - G4double SiLiSpace = 8 * mm; - G4RotationMatrix* rotSiLi = new G4RotationMatrix(0, 0, 0); - G4Box* solidSiLi = new G4Box("SiLi", 0.5 * SiliconFace + 0.5 * SiLiSpace, - 0.5 * SiliconFace, 0.5 * SiLiThickness); - G4LogicalVolume* logicSiLi = new G4LogicalVolume( - solidSiLi, m_MaterialAluminium, Name + "_SiLi", 0, 0, 0); + G4double SiLiSpace = 8 * mm; + G4RotationMatrix* rotSiLi = new G4RotationMatrix(0, 0, 0); + G4Box* solidSiLi = new G4Box("SiLi", 0.5 * SiliconFace + 0.5 * SiLiSpace, 0.5 * SiliconFace, 0.5 * SiLiThickness); + G4LogicalVolume* logicSiLi = new G4LogicalVolume(solidSiLi, m_MaterialAluminium, Name + "_SiLi", 0, 0, 0); - logicSiLi->SetVisAttributes(G4VisAttributes::Invisible); + logicSiLi->SetVisAttributes(G4VisAttributes::GetInvisible()); - new G4PVPlacement(G4Transform3D(*rotSiLi, G4ThreeVector(0, 0, 0)), - logicSiLi, Name + "_SiLi", logicVacBox, false, 0); + new G4PVPlacement(G4Transform3D(*rotSiLi, G4ThreeVector(0, 0, 0)), logicSiLi, Name + "_SiLi", logicVacBox, false, + 0); // SiLi are placed inside of the VacBox... // Left/Right define when looking to detector from Si to CsI - G4double SiLi_HighY_Upper = 19.86 * mm; + G4double SiLi_HighY_Upper = 19.86 * mm; G4double SiLi_HighY_Center = 25.39 * mm; - G4double SiLi_WidthX_Left = 22.85 * mm; + G4double SiLi_WidthX_Left = 22.85 * mm; G4double SiLi_WidthX_Right = 24.9 * mm; - G4double SiLi_ShiftX = 0.775 * mm; + G4double SiLi_ShiftX = 0.775 * mm; // SiLi are organized by two group of 8 Up(9 to 15) and Down(1 to 8). - G4ThreeVector ShiftSiLiUp - = G4ThreeVector(-0.25 * SiliconFace - 0.5 * SiLiSpace, 0, 0); - G4ThreeVector ShiftSiLiDown - = G4ThreeVector(0.25 * SiliconFace + 0.5 * SiLiSpace, 0, 0); + G4ThreeVector ShiftSiLiUp = G4ThreeVector(-0.25 * SiliconFace - 0.5 * SiLiSpace, 0, 0); + G4ThreeVector ShiftSiLiDown = G4ThreeVector(0.25 * SiliconFace + 0.5 * SiLiSpace, 0, 0); // SiLi : left side of SiLi detector - G4Box* solidSiLi_LT - = new G4Box("SiLi_LT", 0.5 * SiLi_WidthX_Left, 0.5 * SiLi_HighY_Upper, - 0.5 * SiLiThickness); - G4Box* solidSiLi_RT - = new G4Box("SiLi_RT", 0.5 * SiLi_WidthX_Right, 0.5 * SiLi_HighY_Upper, - 0.5 * SiLiThickness); - G4Box* solidSiLi_LC1 - = new G4Box("SiLi_LC1", 0.5 * SiLi_WidthX_Left, 0.5 * SiLi_HighY_Center, - 0.5 * SiLiThickness); - G4Box* solidSiLi_RC1 - = new G4Box("SiLi_RC1", 0.5 * SiLi_WidthX_Right, - 0.5 * SiLi_HighY_Center, 0.5 * SiLiThickness); - G4Box* solidSiLi_LB - = new G4Box("SiLi_LB", 0.5 * SiLi_WidthX_Left, 0.5 * SiLi_HighY_Upper, - 0.5 * SiLiThickness); - G4Box* solidSiLi_RB - = new G4Box("SiLi_RB", 0.5 * SiLi_WidthX_Right, 0.5 * SiLi_HighY_Upper, - 0.5 * SiLiThickness); - G4Box* solidSiLi_LC2 - = new G4Box("SiLi_LC2", 0.5 * SiLi_WidthX_Left, 0.5 * SiLi_HighY_Center, - 0.5 * SiLiThickness); - G4Box* solidSiLi_RC2 - = new G4Box("SiLi_RC2", 0.5 * SiLi_WidthX_Right, - 0.5 * SiLi_HighY_Center, 0.5 * SiLiThickness); - - G4LogicalVolume* logicSiLi_LT = new G4LogicalVolume( - solidSiLi_LT, m_MaterialSilicon, "SiLi_LT", 0, 0, 0); - G4LogicalVolume* logicSiLi_RT = new G4LogicalVolume( - solidSiLi_RT, m_MaterialSilicon, "SiLi_RT", 0, 0, 0); - G4LogicalVolume* logicSiLi_LC1 = new G4LogicalVolume( - solidSiLi_LC1, m_MaterialSilicon, "SiLi_LC1", 0, 0, 0); - G4LogicalVolume* logicSiLi_RC1 = new G4LogicalVolume( - solidSiLi_RC1, m_MaterialSilicon, "SiLi_RC1", 0, 0, 0); - G4LogicalVolume* logicSiLi_LB = new G4LogicalVolume( - solidSiLi_LB, m_MaterialSilicon, "SiLi_LB", 0, 0, 0); - G4LogicalVolume* logicSiLi_RB = new G4LogicalVolume( - solidSiLi_RB, m_MaterialSilicon, "SiLi_RB", 0, 0, 0); - G4LogicalVolume* logicSiLi_LC2 = new G4LogicalVolume( - solidSiLi_LC2, m_MaterialSilicon, "SiLi_LC2", 0, 0, 0); - G4LogicalVolume* logicSiLi_RC2 = new G4LogicalVolume( - solidSiLi_RC2, m_MaterialSilicon, "SiLi_RC2", 0, 0, 0); + G4Box* solidSiLi_LT = new G4Box("SiLi_LT", 0.5 * SiLi_WidthX_Left, 0.5 * SiLi_HighY_Upper, 0.5 * SiLiThickness); + G4Box* solidSiLi_RT = new G4Box("SiLi_RT", 0.5 * SiLi_WidthX_Right, 0.5 * SiLi_HighY_Upper, 0.5 * SiLiThickness); + G4Box* solidSiLi_LC1 = new G4Box("SiLi_LC1", 0.5 * SiLi_WidthX_Left, 0.5 * SiLi_HighY_Center, 0.5 * SiLiThickness); + G4Box* solidSiLi_RC1 = new G4Box("SiLi_RC1", 0.5 * SiLi_WidthX_Right, 0.5 * SiLi_HighY_Center, 0.5 * SiLiThickness); + G4Box* solidSiLi_LB = new G4Box("SiLi_LB", 0.5 * SiLi_WidthX_Left, 0.5 * SiLi_HighY_Upper, 0.5 * SiLiThickness); + G4Box* solidSiLi_RB = new G4Box("SiLi_RB", 0.5 * SiLi_WidthX_Right, 0.5 * SiLi_HighY_Upper, 0.5 * SiLiThickness); + G4Box* solidSiLi_LC2 = new G4Box("SiLi_LC2", 0.5 * SiLi_WidthX_Left, 0.5 * SiLi_HighY_Center, 0.5 * SiLiThickness); + G4Box* solidSiLi_RC2 = new G4Box("SiLi_RC2", 0.5 * SiLi_WidthX_Right, 0.5 * SiLi_HighY_Center, 0.5 * SiLiThickness); + + G4LogicalVolume* logicSiLi_LT = new G4LogicalVolume(solidSiLi_LT, m_MaterialSilicon, "SiLi_LT", 0, 0, 0); + G4LogicalVolume* logicSiLi_RT = new G4LogicalVolume(solidSiLi_RT, m_MaterialSilicon, "SiLi_RT", 0, 0, 0); + G4LogicalVolume* logicSiLi_LC1 = new G4LogicalVolume(solidSiLi_LC1, m_MaterialSilicon, "SiLi_LC1", 0, 0, 0); + G4LogicalVolume* logicSiLi_RC1 = new G4LogicalVolume(solidSiLi_RC1, m_MaterialSilicon, "SiLi_RC1", 0, 0, 0); + G4LogicalVolume* logicSiLi_LB = new G4LogicalVolume(solidSiLi_LB, m_MaterialSilicon, "SiLi_LB", 0, 0, 0); + G4LogicalVolume* logicSiLi_RB = new G4LogicalVolume(solidSiLi_RB, m_MaterialSilicon, "SiLi_RB", 0, 0, 0); + G4LogicalVolume* logicSiLi_LC2 = new G4LogicalVolume(solidSiLi_LC2, m_MaterialSilicon, "SiLi_LC2", 0, 0, 0); + G4LogicalVolume* logicSiLi_RC2 = new G4LogicalVolume(solidSiLi_RC2, m_MaterialSilicon, "SiLi_RC2", 0, 0, 0); G4double interSiLi = 0.5 * mm; // Top - G4ThreeVector positionSiLi_LT_up = G4ThreeVector( - -0.5 * SiLi_WidthX_Left - interSiLi - SiLi_ShiftX, - 0.5 * SiLi_HighY_Upper + SiLi_HighY_Center + 1.5 * interSiLi, 0); + G4ThreeVector positionSiLi_LT_up = G4ThreeVector(-0.5 * SiLi_WidthX_Left - interSiLi - SiLi_ShiftX, + 0.5 * SiLi_HighY_Upper + SiLi_HighY_Center + 1.5 * interSiLi, 0); positionSiLi_LT_up += ShiftSiLiUp; - G4ThreeVector positionSiLi_RT_up = G4ThreeVector( - 0.5 * SiLi_WidthX_Right - SiLi_ShiftX, - 0.5 * SiLi_HighY_Upper + SiLi_HighY_Center + 1.5 * interSiLi, 0); + G4ThreeVector positionSiLi_RT_up = G4ThreeVector(0.5 * SiLi_WidthX_Right - SiLi_ShiftX, + 0.5 * SiLi_HighY_Upper + SiLi_HighY_Center + 1.5 * interSiLi, 0); positionSiLi_RT_up += ShiftSiLiUp; - G4ThreeVector positionSiLi_LC1_up - = G4ThreeVector(-0.5 * SiLi_WidthX_Left - interSiLi - SiLi_ShiftX, - 0.5 * SiLi_HighY_Center + 0.5 * interSiLi, 0); + G4ThreeVector positionSiLi_LC1_up = + G4ThreeVector(-0.5 * SiLi_WidthX_Left - interSiLi - SiLi_ShiftX, 0.5 * SiLi_HighY_Center + 0.5 * interSiLi, 0); positionSiLi_LC1_up += ShiftSiLiUp; - G4ThreeVector positionSiLi_RC1_up - = G4ThreeVector(0.5 * SiLi_WidthX_Right - SiLi_ShiftX, - 0.5 * SiLi_HighY_Center + 0.5 * interSiLi, 0); + G4ThreeVector positionSiLi_RC1_up = + G4ThreeVector(0.5 * SiLi_WidthX_Right - SiLi_ShiftX, 0.5 * SiLi_HighY_Center + 0.5 * interSiLi, 0); positionSiLi_RC1_up += ShiftSiLiUp; - G4ThreeVector positionSiLi_LB_up = G4ThreeVector( - -0.5 * SiLi_WidthX_Left - interSiLi - SiLi_ShiftX, - -0.5 * SiLi_HighY_Upper - SiLi_HighY_Center - 1.5 * interSiLi, 0); + G4ThreeVector positionSiLi_LB_up = G4ThreeVector(-0.5 * SiLi_WidthX_Left - interSiLi - SiLi_ShiftX, + -0.5 * SiLi_HighY_Upper - SiLi_HighY_Center - 1.5 * interSiLi, 0); positionSiLi_LB_up += ShiftSiLiUp; - G4ThreeVector positionSiLi_RB_up = G4ThreeVector( - 0.5 * SiLi_WidthX_Right - SiLi_ShiftX, - -0.5 * SiLi_HighY_Upper - SiLi_HighY_Center - 1.5 * interSiLi, 0); + G4ThreeVector positionSiLi_RB_up = G4ThreeVector(0.5 * SiLi_WidthX_Right - SiLi_ShiftX, + -0.5 * SiLi_HighY_Upper - SiLi_HighY_Center - 1.5 * interSiLi, 0); positionSiLi_RB_up += ShiftSiLiUp; - G4ThreeVector positionSiLi_LC2_up - = G4ThreeVector(-0.5 * SiLi_WidthX_Left - interSiLi - SiLi_ShiftX, - -0.5 * SiLi_HighY_Center - 0.5 * interSiLi, 0); + G4ThreeVector positionSiLi_LC2_up = + G4ThreeVector(-0.5 * SiLi_WidthX_Left - interSiLi - SiLi_ShiftX, -0.5 * SiLi_HighY_Center - 0.5 * interSiLi, 0); positionSiLi_LC2_up += ShiftSiLiUp; - G4ThreeVector positionSiLi_RC2_up - = G4ThreeVector(0.5 * SiLi_WidthX_Right - SiLi_ShiftX, - -0.5 * SiLi_HighY_Center - 0.5 * interSiLi, 0); + G4ThreeVector positionSiLi_RC2_up = + G4ThreeVector(0.5 * SiLi_WidthX_Right - SiLi_ShiftX, -0.5 * SiLi_HighY_Center - 0.5 * interSiLi, 0); positionSiLi_RC2_up += ShiftSiLiUp; // Down - G4ThreeVector positionSiLi_LT_down = G4ThreeVector( - -0.5 * SiLi_WidthX_Left - interSiLi - SiLi_ShiftX, - 0.5 * SiLi_HighY_Upper + SiLi_HighY_Center + 1.5 * interSiLi, 0); + G4ThreeVector positionSiLi_LT_down = G4ThreeVector(-0.5 * SiLi_WidthX_Left - interSiLi - SiLi_ShiftX, + 0.5 * SiLi_HighY_Upper + SiLi_HighY_Center + 1.5 * interSiLi, 0); positionSiLi_LT_down += ShiftSiLiDown; - G4ThreeVector positionSiLi_RT_down = G4ThreeVector( - 0.5 * SiLi_WidthX_Right - SiLi_ShiftX, - 0.5 * SiLi_HighY_Upper + SiLi_HighY_Center + 1.5 * interSiLi, 0); + G4ThreeVector positionSiLi_RT_down = G4ThreeVector(0.5 * SiLi_WidthX_Right - SiLi_ShiftX, + 0.5 * SiLi_HighY_Upper + SiLi_HighY_Center + 1.5 * interSiLi, 0); positionSiLi_RT_down += ShiftSiLiDown; - G4ThreeVector positionSiLi_LC1_down - = G4ThreeVector(-0.5 * SiLi_WidthX_Left - interSiLi - SiLi_ShiftX, - 0.5 * SiLi_HighY_Center + 0.5 * interSiLi, 0); + G4ThreeVector positionSiLi_LC1_down = + G4ThreeVector(-0.5 * SiLi_WidthX_Left - interSiLi - SiLi_ShiftX, 0.5 * SiLi_HighY_Center + 0.5 * interSiLi, 0); positionSiLi_LC1_down += ShiftSiLiDown; - G4ThreeVector positionSiLi_RC1_down - = G4ThreeVector(0.5 * SiLi_WidthX_Right - SiLi_ShiftX, - 0.5 * SiLi_HighY_Center + 0.5 * interSiLi, 0); + G4ThreeVector positionSiLi_RC1_down = + G4ThreeVector(0.5 * SiLi_WidthX_Right - SiLi_ShiftX, 0.5 * SiLi_HighY_Center + 0.5 * interSiLi, 0); positionSiLi_RC1_down += ShiftSiLiDown; - G4ThreeVector positionSiLi_LB_down = G4ThreeVector( - -0.5 * SiLi_WidthX_Left - interSiLi - SiLi_ShiftX, - -0.5 * SiLi_HighY_Upper - SiLi_HighY_Center - 1.5 * interSiLi, 0); + G4ThreeVector positionSiLi_LB_down = + G4ThreeVector(-0.5 * SiLi_WidthX_Left - interSiLi - SiLi_ShiftX, + -0.5 * SiLi_HighY_Upper - SiLi_HighY_Center - 1.5 * interSiLi, 0); positionSiLi_LB_down += ShiftSiLiDown; G4ThreeVector positionSiLi_RB_down = G4ThreeVector( - 0.5 * SiLi_WidthX_Right - SiLi_ShiftX, - -0.5 * SiLi_HighY_Upper - SiLi_HighY_Center - 1.5 * interSiLi, 0); + 0.5 * SiLi_WidthX_Right - SiLi_ShiftX, -0.5 * SiLi_HighY_Upper - SiLi_HighY_Center - 1.5 * interSiLi, 0); positionSiLi_RB_down += ShiftSiLiDown; - G4ThreeVector positionSiLi_LC2_down - = G4ThreeVector(-0.5 * SiLi_WidthX_Left - interSiLi - SiLi_ShiftX, - -0.5 * SiLi_HighY_Center - 0.5 * interSiLi, 0); + G4ThreeVector positionSiLi_LC2_down = + G4ThreeVector(-0.5 * SiLi_WidthX_Left - interSiLi - SiLi_ShiftX, -0.5 * SiLi_HighY_Center - 0.5 * interSiLi, 0); positionSiLi_LC2_down += ShiftSiLiDown; - G4ThreeVector positionSiLi_RC2_down - = G4ThreeVector(0.5 * SiLi_WidthX_Right - SiLi_ShiftX, - -0.5 * SiLi_HighY_Center - 0.5 * interSiLi, 0); + G4ThreeVector positionSiLi_RC2_down = + G4ThreeVector(0.5 * SiLi_WidthX_Right - SiLi_ShiftX, -0.5 * SiLi_HighY_Center - 0.5 * interSiLi, 0); positionSiLi_RC2_down += ShiftSiLiDown; - new G4PVPlacement(0, positionSiLi_RT_down, logicSiLi_RT, - Name + "_SiLi_Pad1", logicSiLi, false, 1); - new G4PVPlacement(0, positionSiLi_LT_down, logicSiLi_LT, - Name + "_SiLi_Pad2", logicSiLi, false, 2); - new G4PVPlacement(0, positionSiLi_RC1_down, logicSiLi_RC1, - Name + "_SiLi_Pad3", logicSiLi, false, 3); - new G4PVPlacement(0, positionSiLi_LC1_down, logicSiLi_LC1, - Name + "_SiLi_Pad4", logicSiLi, false, 4); - new G4PVPlacement(0, positionSiLi_LC2_down, logicSiLi_LC2, - Name + "_SiLi_Pad5", logicSiLi, false, 5); - new G4PVPlacement(0, positionSiLi_RC2_down, logicSiLi_RC2, - Name + "_SiLi_Pad6", logicSiLi, false, 6); - new G4PVPlacement(0, positionSiLi_LB_down, logicSiLi_LB, - Name + "_SiLi_Pad7", logicSiLi, false, 7); - new G4PVPlacement(0, positionSiLi_RB_down, logicSiLi_RB, - Name + "_SiLi_Pad8", logicSiLi, false, 8); - new G4PVPlacement(0, positionSiLi_LT_up, logicSiLi_LT, Name + "_SiLi_Pad9", - logicSiLi, false, 9); - new G4PVPlacement(0, positionSiLi_RT_up, logicSiLi_RT, Name + "_SiLi_Pad10", - logicSiLi, false, 10); - new G4PVPlacement(0, positionSiLi_LC1_up, logicSiLi_LC1, - Name + "_SiLi_Pad11", logicSiLi, false, 11); - new G4PVPlacement(0, positionSiLi_RC1_up, logicSiLi_RC1, - Name + "_SiLi_Pad12", logicSiLi, false, 12); - new G4PVPlacement(0, positionSiLi_RC2_up, logicSiLi_RC2, - Name + "_SiLi_Pad13", logicSiLi, false, 13); - new G4PVPlacement(0, positionSiLi_LC2_up, logicSiLi_LC2, - Name + "_SiLi_Pad14", logicSiLi, false, 14); - new G4PVPlacement(0, positionSiLi_RB_up, logicSiLi_RB, Name + "_SiLi_Pad15", - logicSiLi, false, 15); - new G4PVPlacement(0, positionSiLi_LB_up, logicSiLi_LB, Name + "_SiLi_Pad16", - logicSiLi, false, 16); + new G4PVPlacement(0, positionSiLi_RT_down, logicSiLi_RT, Name + "_SiLi_Pad1", logicSiLi, false, 1); + new G4PVPlacement(0, positionSiLi_LT_down, logicSiLi_LT, Name + "_SiLi_Pad2", logicSiLi, false, 2); + new G4PVPlacement(0, positionSiLi_RC1_down, logicSiLi_RC1, Name + "_SiLi_Pad3", logicSiLi, false, 3); + new G4PVPlacement(0, positionSiLi_LC1_down, logicSiLi_LC1, Name + "_SiLi_Pad4", logicSiLi, false, 4); + new G4PVPlacement(0, positionSiLi_LC2_down, logicSiLi_LC2, Name + "_SiLi_Pad5", logicSiLi, false, 5); + new G4PVPlacement(0, positionSiLi_RC2_down, logicSiLi_RC2, Name + "_SiLi_Pad6", logicSiLi, false, 6); + new G4PVPlacement(0, positionSiLi_LB_down, logicSiLi_LB, Name + "_SiLi_Pad7", logicSiLi, false, 7); + new G4PVPlacement(0, positionSiLi_RB_down, logicSiLi_RB, Name + "_SiLi_Pad8", logicSiLi, false, 8); + new G4PVPlacement(0, positionSiLi_LT_up, logicSiLi_LT, Name + "_SiLi_Pad9", logicSiLi, false, 9); + new G4PVPlacement(0, positionSiLi_RT_up, logicSiLi_RT, Name + "_SiLi_Pad10", logicSiLi, false, 10); + new G4PVPlacement(0, positionSiLi_LC1_up, logicSiLi_LC1, Name + "_SiLi_Pad11", logicSiLi, false, 11); + new G4PVPlacement(0, positionSiLi_RC1_up, logicSiLi_RC1, Name + "_SiLi_Pad12", logicSiLi, false, 12); + new G4PVPlacement(0, positionSiLi_RC2_up, logicSiLi_RC2, Name + "_SiLi_Pad13", logicSiLi, false, 13); + new G4PVPlacement(0, positionSiLi_LC2_up, logicSiLi_LC2, Name + "_SiLi_Pad14", logicSiLi, false, 14); + new G4PVPlacement(0, positionSiLi_RB_up, logicSiLi_RB, Name + "_SiLi_Pad15", logicSiLi, false, 15); + new G4PVPlacement(0, positionSiLi_LB_up, logicSiLi_LB, Name + "_SiLi_Pad16", logicSiLi, false, 16); // Set SiLi sensible logicSiLi_LT->SetSensitiveDetector(m_SiLiScorer); @@ -446,104 +368,82 @@ void MUST2Array::VolumeMaker(G4int TelescopeNumber, G4ThreeVector MMpos, //////////////////////////////////////////////////////////////// if (wCsI) { - m_MaterialMyl - = MaterialManager::getInstance()->GetMaterialFromLibrary("Mylar"); - m_MaterialCsI - = MaterialManager::getInstance()->GetMaterialFromLibrary("CsI"); + m_MaterialMyl = MaterialManager::getInstance()->GetMaterialFromLibrary("Mylar"); + m_MaterialCsI = MaterialManager::getInstance()->GetMaterialFromLibrary("CsI"); G4ThreeVector positionCsI = G4ThreeVector(0, 0, CsI_PosZ); - G4Trd* solidCsI - = new G4Trd("csI", 0.5 * CsIFaceFront, 0.5 * CsIFaceBack, - 0.5 * CsIFaceFront, 0.5 * CsIFaceBack, 0.5 * CsIThickness); + G4Trd* solidCsI = new G4Trd("csI", 0.5 * CsIFaceFront, 0.5 * CsIFaceBack, 0.5 * CsIFaceFront, 0.5 * CsIFaceBack, + 0.5 * CsIThickness); - G4LogicalVolume* logicCsI = new G4LogicalVolume( - solidCsI, m_MaterialAluminium, Name + "_CsI_Mylar", 0, 0, 0); - new G4PVPlacement(0, positionCsI, logicCsI, Name + "_CsI_Mylar", logicMM, - false, 0); + G4LogicalVolume* logicCsI = new G4LogicalVolume(solidCsI, m_MaterialAluminium, Name + "_CsI_Mylar", 0, 0, 0); + new G4PVPlacement(0, positionCsI, logicCsI, Name + "_CsI_Mylar", logicMM, false, 0); - G4ThreeVector positionMylarCsI - = G4ThreeVector(0, 0, MylarCsIThickness * 0.5 - CsIThickness * 0.5); + G4ThreeVector positionMylarCsI = G4ThreeVector(0, 0, MylarCsIThickness * 0.5 - CsIThickness * 0.5); - G4Box* solidMylarCsI - = new G4Box("MylarCsIBox", 0.5 * CsIFaceFront, 0.5 * CsIFaceFront, - 0.5 * MylarCsIThickness); - G4LogicalVolume* logicMylarCsI = new G4LogicalVolume( - solidMylarCsI, m_MaterialMyl, Name + "_CsI_Mylar", 0, 0, 0); + G4Box* solidMylarCsI = new G4Box("MylarCsIBox", 0.5 * CsIFaceFront, 0.5 * CsIFaceFront, 0.5 * MylarCsIThickness); + G4LogicalVolume* logicMylarCsI = new G4LogicalVolume(solidMylarCsI, m_MaterialMyl, Name + "_CsI_Mylar", 0, 0, 0); - new G4PVPlacement(0, positionMylarCsI, logicMylarCsI, Name + "_CsI_Mylar", - logicCsI, false, 0); + new G4PVPlacement(0, positionMylarCsI, logicMylarCsI, Name + "_CsI_Mylar", logicCsI, false, 0); - logicCsI->SetVisAttributes(G4VisAttributes::Invisible); - logicMylarCsI->SetVisAttributes(G4VisAttributes::Invisible); + logicCsI->SetVisAttributes(G4VisAttributes::GetInvisible()); + logicMylarCsI->SetVisAttributes(G4VisAttributes::GetInvisible()); // Cristal1 - G4Trap* solidCristal1 = new G4Trap( - "Cristal1", 40. * mm / 2., 6.693896 * deg, 41.97814 * deg, - 33.1 * mm / 2., 37.39 * mm / 2., 37.39 * mm / 2., 0. * deg, - 26.9 * mm / 2., 30.41 * mm / 2., 30.41 * mm / 2., 0. * deg); - G4LogicalVolume* logicCristal1 = new G4LogicalVolume( - solidCristal1, m_MaterialCsI, Name + "_CsI_Cristal1", 0, 0, 0); + G4Trap* solidCristal1 = + new G4Trap("Cristal1", 40. * mm / 2., 6.693896 * deg, 41.97814 * deg, 33.1 * mm / 2., 37.39 * mm / 2., + 37.39 * mm / 2., 0. * deg, 26.9 * mm / 2., 30.41 * mm / 2., 30.41 * mm / 2., 0. * deg); + G4LogicalVolume* logicCristal1 = new G4LogicalVolume(solidCristal1, m_MaterialCsI, Name + "_CsI_Cristal1", 0, 0, 0); // Cristal2 - G4Trap* solidCristal2 = new G4Trap( - "Cristal2", 40. * mm / 2., 17.8836 * deg, (74.3122 + 180) * deg, - 43.49 * mm / 2., 37.39 * mm / 2., 37.39 * mm / 2., 0. * deg, - 31.0377 * mm / 2., 30.41 * mm / 2., 30.41 * mm / 2., 0. * deg); - G4LogicalVolume* logicCristal2 = new G4LogicalVolume( - solidCristal2, m_MaterialCsI, Name + "_CsI_Cristal2", 0, 0, 0); + G4Trap* solidCristal2 = + new G4Trap("Cristal2", 40. * mm / 2., 17.8836 * deg, (74.3122 + 180) * deg, 43.49 * mm / 2., 37.39 * mm / 2., + 37.39 * mm / 2., 0. * deg, 31.0377 * mm / 2., 30.41 * mm / 2., 30.41 * mm / 2., 0. * deg); + G4LogicalVolume* logicCristal2 = new G4LogicalVolume(solidCristal2, m_MaterialCsI, Name + "_CsI_Cristal2", 0, 0, 0); // Cristal3 - G4Trap* solidCristal3 = new G4Trap( - "Cristal3", 40. * mm / 2., 18.243 * deg, 13.5988 * deg, 33.11 * mm / 2., - 39.25 * mm / 2., 39.25 * mm / 2., 0. * deg, 26.91 * mm / 2., - 27.58 * mm / 2., 27.58 * mm / 2., 0. * deg); - G4LogicalVolume* logicCristal3 = new G4LogicalVolume( - solidCristal3, m_MaterialCsI, Name + "_CsI_Cristal3", 0, 0, 0); + G4Trap* solidCristal3 = + new G4Trap("Cristal3", 40. * mm / 2., 18.243 * deg, 13.5988 * deg, 33.11 * mm / 2., 39.25 * mm / 2., + 39.25 * mm / 2., 0. * deg, 26.91 * mm / 2., 27.58 * mm / 2., 27.58 * mm / 2., 0. * deg); + G4LogicalVolume* logicCristal3 = new G4LogicalVolume(solidCristal3, m_MaterialCsI, Name + "_CsI_Cristal3", 0, 0, 0); // Cristal4 - G4Trap* solidCristal4 = new G4Trap( - "Cristal4", 40. * mm / 2., 24.0482 * deg, 44.1148 * deg, - 43.49 * mm / 2., 39.19 * mm / 2., 39.19 * mm / 2., 0. * deg, - 31.04 * mm / 2., 27.52 * mm / 2., 27.52 * mm / 2., 0. * deg); - G4LogicalVolume* logicCristal4 = new G4LogicalVolume( - solidCristal4, m_MaterialCsI, Name + "_CsI_Cristal4", 0, 0, 0); + G4Trap* solidCristal4 = + new G4Trap("Cristal4", 40. * mm / 2., 24.0482 * deg, 44.1148 * deg, 43.49 * mm / 2., 39.19 * mm / 2., + 39.19 * mm / 2., 0. * deg, 31.04 * mm / 2., 27.52 * mm / 2., 27.52 * mm / 2., 0. * deg); + G4LogicalVolume* logicCristal4 = new G4LogicalVolume(solidCristal4, m_MaterialCsI, Name + "_CsI_Cristal4", 0, 0, 0); // Cristal1s - G4Trap* solidCristal1s = new G4Trap( - "Cristal1s", 40. * mm / 2., 6.693896 * deg, -41.97814 * deg, - 33.1 * mm / 2., 37.39 * mm / 2., 37.39 * mm / 2., 0. * deg, - 26.9 * mm / 2., 30.41 * mm / 2., 30.41 * mm / 2., 0. * deg); - G4LogicalVolume* logicCristal1s = new G4LogicalVolume( - solidCristal1s, m_MaterialCsI, Name + "_CsI_Cristal1s", 0, 0, 0); + G4Trap* solidCristal1s = + new G4Trap("Cristal1s", 40. * mm / 2., 6.693896 * deg, -41.97814 * deg, 33.1 * mm / 2., 37.39 * mm / 2., + 37.39 * mm / 2., 0. * deg, 26.9 * mm / 2., 30.41 * mm / 2., 30.41 * mm / 2., 0. * deg); + G4LogicalVolume* logicCristal1s = + new G4LogicalVolume(solidCristal1s, m_MaterialCsI, Name + "_CsI_Cristal1s", 0, 0, 0); // Cristal2s - G4Trap* solidCristal2s = new G4Trap( - "Cristal2s", 40. * mm / 2., 17.8836 * deg, -(74.3122 + 180) * deg, - 43.49 * mm / 2., 37.39 * mm / 2., 37.39 * mm / 2., 0. * deg, - 31.0377 * mm / 2., 30.41 * mm / 2., 30.41 * mm / 2., 0. * deg); - G4LogicalVolume* logicCristal2s = new G4LogicalVolume( - solidCristal2s, m_MaterialCsI, Name + "_CsI_Cristal2s", 0, 0, 0); + G4Trap* solidCristal2s = + new G4Trap("Cristal2s", 40. * mm / 2., 17.8836 * deg, -(74.3122 + 180) * deg, 43.49 * mm / 2., 37.39 * mm / 2., + 37.39 * mm / 2., 0. * deg, 31.0377 * mm / 2., 30.41 * mm / 2., 30.41 * mm / 2., 0. * deg); + G4LogicalVolume* logicCristal2s = + new G4LogicalVolume(solidCristal2s, m_MaterialCsI, Name + "_CsI_Cristal2s", 0, 0, 0); // Cristal3s - G4Trap* solidCristal3s = new G4Trap( - "Cristal3s", 40. * mm / 2., 18.243 * deg, -13.5988 * deg, - 33.11 * mm / 2., 39.25 * mm / 2., 39.25 * mm / 2., 0. * deg, - 26.91 * mm / 2., 27.58 * mm / 2., 27.58 * mm / 2., 0. * deg); - G4LogicalVolume* logicCristal3s = new G4LogicalVolume( - solidCristal3s, m_MaterialCsI, Name + "_CsI_Cristal3s", 0, 0, 0); + G4Trap* solidCristal3s = + new G4Trap("Cristal3s", 40. * mm / 2., 18.243 * deg, -13.5988 * deg, 33.11 * mm / 2., 39.25 * mm / 2., + 39.25 * mm / 2., 0. * deg, 26.91 * mm / 2., 27.58 * mm / 2., 27.58 * mm / 2., 0. * deg); + G4LogicalVolume* logicCristal3s = + new G4LogicalVolume(solidCristal3s, m_MaterialCsI, Name + "_CsI_Cristal3s", 0, 0, 0); // Cristal4s - G4Trap* solidCristal4s = new G4Trap( - "Cristal4s", 40. * mm / 2., 24.0482 * deg, -44.1148 * deg, - 43.49 * mm / 2., 39.19 * mm / 2., 39.19 * mm / 2., 0. * deg, - 31.04 * mm / 2., 27.52 * mm / 2., 27.52 * mm / 2., 0. * deg); - G4LogicalVolume* logicCristal4s = new G4LogicalVolume( - solidCristal4s, m_MaterialCsI, Name + "_CsI_Cristal4s", 0, 0, 0); + G4Trap* solidCristal4s = + new G4Trap("Cristal4s", 40. * mm / 2., 24.0482 * deg, -44.1148 * deg, 43.49 * mm / 2., 39.19 * mm / 2., + 39.19 * mm / 2., 0. * deg, 31.04 * mm / 2., 27.52 * mm / 2., 27.52 * mm / 2., 0. * deg); + G4LogicalVolume* logicCristal4s = + new G4LogicalVolume(solidCristal4s, m_MaterialCsI, Name + "_CsI_Cristal4s", 0, 0, 0); G4double XEdge1 = 16.96 * mm + DistInterCsI * 0.5; G4double YEdge1 = 15.01 * mm + DistInterCsI * 0.5; @@ -555,63 +455,63 @@ void MUST2Array::VolumeMaker(G4int TelescopeNumber, G4ThreeVector MMpos, G4ThreeVector positionCristal3 = G4ThreeVector(-XEdge2, YEdge1, 0); G4ThreeVector positionCristal4 = G4ThreeVector(-XEdge2, YEdge2, 0); - new G4PVPlacement(Rotation(180., 0., 0.), positionCristal1, logicCristal1, - Name + "_CsI_Cristal1", logicCsI, false, 6); // 1 - new G4PVPlacement(Rotation(180., 0., 180.), positionCristal2, logicCristal2, - Name + "_CsI_Cristal2", logicCsI, false, 3); // 2 - new G4PVPlacement(Rotation(180., 0., 0.), positionCristal3, logicCristal3, - Name + "_CsI_Cristal3", logicCsI, false, 5); // 3 - new G4PVPlacement(Rotation(180., 0., 0.), positionCristal4, logicCristal4, - Name + "_CsI_Cristal4", logicCsI, false, 4); // 4 + new G4PVPlacement(Rotation(180., 0., 0.), positionCristal1, logicCristal1, Name + "_CsI_Cristal1", logicCsI, false, + 6); // 1 + new G4PVPlacement(Rotation(180., 0., 180.), positionCristal2, logicCristal2, Name + "_CsI_Cristal2", logicCsI, + false, 3); // 2 + new G4PVPlacement(Rotation(180., 0., 0.), positionCristal3, logicCristal3, Name + "_CsI_Cristal3", logicCsI, false, + 5); // 3 + new G4PVPlacement(Rotation(180., 0., 0.), positionCristal4, logicCristal4, Name + "_CsI_Cristal4", logicCsI, false, + 4); // 4 G4ThreeVector positionCristal1b = G4ThreeVector(XEdge1, -YEdge1, 0 * mm); G4ThreeVector positionCristal2b = G4ThreeVector(XEdge1, -YEdge2, 0); G4ThreeVector positionCristal3b = G4ThreeVector(XEdge2, -YEdge1, 0); G4ThreeVector positionCristal4b = G4ThreeVector(XEdge2, -YEdge2, 0); - new G4PVPlacement(Rotation(180., 0., 180.), positionCristal1b, - logicCristal1, Name + "_CsI_Cristal5", logicCsI, false, - 11); // 5 - new G4PVPlacement(Rotation(180., 0., 0.), positionCristal2b, logicCristal2, - Name + "_CsI_Cristal6", logicCsI, false, 15); // 6 - new G4PVPlacement(Rotation(180., 0., 180.), positionCristal3b, - logicCristal3, Name + "_CsI_Cristal7", logicCsI, false, - 12); // 7 - new G4PVPlacement(Rotation(180., 0., 180.), positionCristal4b, - logicCristal4, Name + "_CsI_Cristal8", logicCsI, false, - 16); // 8 + new G4PVPlacement(Rotation(180., 0., 180.), positionCristal1b, logicCristal1, Name + "_CsI_Cristal5", logicCsI, + false, + 11); // 5 + new G4PVPlacement(Rotation(180., 0., 0.), positionCristal2b, logicCristal2, Name + "_CsI_Cristal6", logicCsI, false, + 15); // 6 + new G4PVPlacement(Rotation(180., 0., 180.), positionCristal3b, logicCristal3, Name + "_CsI_Cristal7", logicCsI, + false, + 12); // 7 + new G4PVPlacement(Rotation(180., 0., 180.), positionCristal4b, logicCristal4, Name + "_CsI_Cristal8", logicCsI, + false, + 16); // 8 G4ThreeVector positionCristal1s = G4ThreeVector(-XEdge1, -YEdge1, 0 * mm); G4ThreeVector positionCristal2s = G4ThreeVector(-XEdge1, -YEdge2, 0); G4ThreeVector positionCristal3s = G4ThreeVector(-XEdge2, -YEdge1, 0); G4ThreeVector positionCristal4s = G4ThreeVector(-XEdge2, -YEdge2, 0); - new G4PVPlacement(Rotation(180., 0., 0.), positionCristal1s, logicCristal1s, - Name + "_CsI_Cristal9", logicCsI, false, 10); // 9 - new G4PVPlacement(Rotation(180., 0., 180.), positionCristal2s, - logicCristal2s, Name + "_CsI_Cristal10", logicCsI, false, - 14); // 10 - new G4PVPlacement(Rotation(180., 0., 0.), positionCristal3s, logicCristal3s, - Name + "_CsI_Cristal11", logicCsI, false, 9); // 11 - new G4PVPlacement(Rotation(180., 0., 0.), positionCristal4s, logicCristal4s, - Name + "_CsI_Cristal12", logicCsI, false, 13); // 12 + new G4PVPlacement(Rotation(180., 0., 0.), positionCristal1s, logicCristal1s, Name + "_CsI_Cristal9", logicCsI, + false, 10); // 9 + new G4PVPlacement(Rotation(180., 0., 180.), positionCristal2s, logicCristal2s, Name + "_CsI_Cristal10", logicCsI, + false, + 14); // 10 + new G4PVPlacement(Rotation(180., 0., 0.), positionCristal3s, logicCristal3s, Name + "_CsI_Cristal11", logicCsI, + false, 9); // 11 + new G4PVPlacement(Rotation(180., 0., 0.), positionCristal4s, logicCristal4s, Name + "_CsI_Cristal12", logicCsI, + false, 13); // 12 G4ThreeVector positionCristal1sb = G4ThreeVector(XEdge1, YEdge1, 0 * mm); G4ThreeVector positionCristal2sb = G4ThreeVector(XEdge1, YEdge2, 0); G4ThreeVector positionCristal3sb = G4ThreeVector(XEdge2, YEdge1, 0); G4ThreeVector positionCristal4sb = G4ThreeVector(XEdge2, YEdge2, 0); - new G4PVPlacement(Rotation(180., 0., 180.), positionCristal1sb, - logicCristal1s, Name + "_CsI_Cristal13", logicCsI, false, - 7); // 13 - new G4PVPlacement(Rotation(180, 0, 0), positionCristal2sb, logicCristal2s, - Name + "_CsI_Cristal14", logicCsI, false, 2); // 14 - new G4PVPlacement(Rotation(180., 0., 180.), positionCristal3sb, - logicCristal3s, Name + "_CsI_Cristal15", logicCsI, false, - 8); // 15 - new G4PVPlacement(Rotation(180., 0., 180.), positionCristal4sb, - logicCristal4s, Name + "_CsI_Cristal16", logicCsI, false, - 1); // 16 + new G4PVPlacement(Rotation(180., 0., 180.), positionCristal1sb, logicCristal1s, Name + "_CsI_Cristal13", logicCsI, + false, + 7); // 13 + new G4PVPlacement(Rotation(180, 0, 0), positionCristal2sb, logicCristal2s, Name + "_CsI_Cristal14", logicCsI, false, + 2); // 14 + new G4PVPlacement(Rotation(180., 0., 180.), positionCristal3sb, logicCristal3s, Name + "_CsI_Cristal15", logicCsI, + false, + 8); // 15 + new G4PVPlacement(Rotation(180., 0., 180.), positionCristal4sb, logicCristal4s, Name + "_CsI_Cristal16", logicCsI, + false, + 1); // 16 /// Set CsI sensible logicCristal1->SetSensitiveDetector(m_CsIScorer); @@ -652,43 +552,37 @@ void MUST2Array::ReadConfiguration(NPL::InputParser parser) { if (NPOptionManager::getInstance()->GetVerboseLevel()) cout << endl << "//// Must 2 Telecope " << i + 1 << endl; // Cartesian Case - vector<string> cart - = {"X1_Y1", "X1_Y128", "X128_Y1", "X128_Y128", "SI", "SILI", "CSI"}; + vector<string> cart = {"X1_Y1", "X1_Y128", "X128_Y1", "X128_Y128", "SI", "SILI", "CSI"}; // Spherical Case vector<string> sphe = {"R", "THETA", "PHI", "BETA", "SI", "SILI", "CSI"}; if (blocks[i]->HasTokenList(cart)) { - G4ThreeVector A - = NPS::ConvertVector(blocks[i]->GetTVector3("X1_Y1", "mm")); - G4ThreeVector B - = NPS::ConvertVector(blocks[i]->GetTVector3("X128_Y1", "mm")); - G4ThreeVector C - = NPS::ConvertVector(blocks[i]->GetTVector3("X1_Y128", "mm")); - G4ThreeVector D - = NPS::ConvertVector(blocks[i]->GetTVector3("X128_Y128", "mm")); - int SI = blocks[i]->GetInt("SI"); + G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("X1_Y1", "mm")); + G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("X128_Y1", "mm")); + G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("X1_Y128", "mm")); + G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("X128_Y128", "mm")); + int SI = blocks[i]->GetInt("SI"); int SILI = blocks[i]->GetInt("SILI"); - int CSI = blocks[i]->GetInt("CSI"); + int CSI = blocks[i]->GetInt("CSI"); AddTelescope(A, B, C, D, SI == 1, SILI == 1, CSI == 1); } else if (blocks[i]->HasTokenList(sphe)) { - double Theta = blocks[i]->GetDouble("THETA", "deg"); - double Phi = blocks[i]->GetDouble("PHI", "deg"); - double R = blocks[i]->GetDouble("R", "mm"); - vector<double> beta = blocks[i]->GetVectorDouble("BETA", "deg"); - int SI = blocks[i]->GetInt("SI"); - int SILI = blocks[i]->GetInt("SILI"); - int CSI = blocks[i]->GetInt("CSI"); - AddTelescope(R, Theta, Phi, beta[0], beta[1], beta[2], SI == 1, SILI == 1, - CSI == 1); + double Theta = blocks[i]->GetDouble("THETA", "deg"); + double Phi = blocks[i]->GetDouble("PHI", "deg"); + double R = blocks[i]->GetDouble("R", "mm"); + vector<double> beta = blocks[i]->GetVectorDouble("BETA", "deg"); + int SI = blocks[i]->GetInt("SI"); + int SILI = blocks[i]->GetInt("SILI"); + int CSI = blocks[i]->GetInt("CSI"); + AddTelescope(R, Theta, Phi, beta[0], beta[1], beta[2], SI == 1, SILI == 1, CSI == 1); } else { cout << "WARNING: Missing token for M2Telescope blocks, check your input " - "file" - << endl; + "file" + << endl; exit(1); } @@ -697,9 +591,9 @@ void MUST2Array::ReadConfiguration(NPL::InputParser parser) { } //////////////////// - //Read the thresholds from the analysis config - //////////////////// - + // Read the thresholds from the analysis config + //////////////////// + bool ReadingStatus = false; // path to file @@ -736,81 +630,81 @@ void MUST2Array::ReadConfiguration(NPL::InputParser parser) { if (whatToDo.compare(0, 1, "%") == 0) { AnalysisConfigFile.ignore(numeric_limits<streamsize>::max(), '\n'); } - //Resolutions + // Resolutions else if (whatToDo == "SI_E_RESOLUTION") { AnalysisConfigFile >> DataBuffer; ResoStrip = atof(DataBuffer.c_str()); - ResoStrip = ResoStrip*keV/2.35; - cout << whatToDo << " " << ResoStrip << " MeV/2.35 "<< endl; + ResoStrip = ResoStrip * keV / 2.35; + cout << whatToDo << " " << ResoStrip << " MeV/2.35 " << endl; } else if (whatToDo == "SILI_E_RESOLUTION") { AnalysisConfigFile >> DataBuffer; ResoSiLi = atof(DataBuffer.c_str()); - ResoSiLi = ResoSiLi*keV/2.35; - cout << whatToDo << " " << ResoSiLi << " MeV/2.35 "<< endl; + ResoSiLi = ResoSiLi * keV / 2.35; + cout << whatToDo << " " << ResoSiLi << " MeV/2.35 " << endl; } else if (whatToDo == "CSI_E_RESOLUTION") { AnalysisConfigFile >> DataBuffer; ResoCsI = atof(DataBuffer.c_str()); - ResoCsI = ResoCsI*keV/2.35; - cout << whatToDo << " " << ResoCsI << " MeV/2.35 "<< endl; + ResoCsI = ResoCsI * keV / 2.35; + cout << whatToDo << " " << ResoCsI << " MeV/2.35 " << endl; } - //Time + // Time else if (whatToDo == "MUST_T_RESOLUTION") { AnalysisConfigFile >> DataBuffer; ResoTimeMust = atof(DataBuffer.c_str()); - ResoTimeMust = ResoTimeMust*ns/2.35; - cout << whatToDo << " " << ResoTimeMust << " ns/2.35 "<< endl; + ResoTimeMust = ResoTimeMust * ns / 2.35; + cout << whatToDo << " " << ResoTimeMust << " ns/2.35 " << endl; } else if (whatToDo == "SI_T_OFFSET") { AnalysisConfigFile >> DataBuffer; TimeOffset = atof(DataBuffer.c_str()); - TimeOffset = TimeOffset*ns; - cout << whatToDo << " " << TimeOffset << " ns "<< endl; + TimeOffset = TimeOffset * ns; + cout << whatToDo << " " << TimeOffset << " ns " << endl; } - //Thresholds + // Thresholds else if (whatToDo == "SI_X_E_THRESHOLD") { AnalysisConfigFile >> DataBuffer; ThresholdSiX = atof(DataBuffer.c_str()); - ThresholdSiX = ThresholdSiX*keV; - cout << whatToDo << " " << ThresholdSiX << " MeV "<< endl; + ThresholdSiX = ThresholdSiX * keV; + cout << whatToDo << " " << ThresholdSiX << " MeV " << endl; } else if (whatToDo == "SI_Y_E_THRESHOLD") { AnalysisConfigFile >> DataBuffer; ThresholdSiY = atof(DataBuffer.c_str()); - ThresholdSiY = ThresholdSiY*keV; - cout << whatToDo << " " << ThresholdSiY << " MeV "<< endl; + ThresholdSiY = ThresholdSiY * keV; + cout << whatToDo << " " << ThresholdSiY << " MeV " << endl; } else if (whatToDo == "SILI_E_THRESHOLD") { AnalysisConfigFile >> DataBuffer; ThresholdSiLi = atof(DataBuffer.c_str()); - ThresholdSiLi = ThresholdSiLi*keV; - cout << whatToDo << " " << ThresholdSiLi << " MeV "<< endl; + ThresholdSiLi = ThresholdSiLi * keV; + cout << whatToDo << " " << ThresholdSiLi << " MeV " << endl; } else if (whatToDo == "CSI_E_THRESHOLD") { AnalysisConfigFile >> DataBuffer; ThresholdCsI = atof(DataBuffer.c_str()); - ThresholdCsI = ThresholdCsI*keV; - cout << whatToDo << " " << ThresholdCsI << " MeV "<< endl; - } - else if (AnalysisConfigFile.eof()) ReadingStatus = false; + ThresholdCsI = ThresholdCsI * keV; + cout << whatToDo << " " << ThresholdCsI << " MeV " << endl; + } + else if (AnalysisConfigFile.eof()) + ReadingStatus = false; } } } - // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method void MUST2Array::ConstructDetector(G4LogicalVolume* world) { - G4RotationMatrix* MMrot = NULL; - G4ThreeVector MMpos = G4ThreeVector(0, 0, 0); - G4ThreeVector MMu = G4ThreeVector(0, 0, 0); - G4ThreeVector MMv = G4ThreeVector(0, 0, 0); - G4ThreeVector MMw = G4ThreeVector(0, 0, 0); - G4ThreeVector MMCenter = G4ThreeVector(0, 0, 0); - bool Si = true; - bool SiLi = true; - bool CsI = true; + G4RotationMatrix* MMrot = NULL; + G4ThreeVector MMpos = G4ThreeVector(0, 0, 0); + G4ThreeVector MMu = G4ThreeVector(0, 0, 0); + G4ThreeVector MMv = G4ThreeVector(0, 0, 0); + G4ThreeVector MMw = G4ThreeVector(0, 0, 0); + G4ThreeVector MMCenter = G4ThreeVector(0, 0, 0); + bool Si = true; + bool SiLi = true; + bool CsI = true; G4int NumberOfTelescope = m_DefinitionType.size(); @@ -830,8 +724,7 @@ void MUST2Array::ConstructDetector(G4LogicalVolume* world) { // if (MMw.z() > 0)MMw = MMv.cross(MMu) ; MMw = MMw.unit(); - MMCenter - = (m_X1_Y1[i] + m_X1_Y128[i] + m_X128_Y1[i] + m_X128_Y128[i]) / 4; + MMCenter = (m_X1_Y1[i] + m_X1_Y128[i] + m_X128_Y1[i] + m_X128_Y128[i]) / 4; // Passage Matrix from Lab Referential to Telescope Referential MMrot = new G4RotationMatrix(MMv, MMu, MMw); @@ -841,7 +734,7 @@ void MUST2Array::ConstructDetector(G4LogicalVolume* world) { // By Angle else { G4double Theta = m_Theta[i]; - G4double Phi = m_Phi[i]; + G4double Phi = m_Phi[i]; // (u,v,w) unitary vector associated to telescope referencial // (u,v) // to silicon plan @@ -851,16 +744,16 @@ void MUST2Array::ConstructDetector(G4LogicalVolume* world) { G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad); G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad); G4double wZ = m_R[i] * cos(Theta / rad); - MMw = G4ThreeVector(wX, wY, wZ); + MMw = G4ThreeVector(wX, wY, wZ); // vector corresponding to the center of the module G4ThreeVector CT = MMw; // vector parallel to one axis of silicon plane - G4double ii = cos(Theta / rad) * cos(Phi / rad); - G4double jj = cos(Theta / rad) * sin(Phi / rad); - G4double kk = -sin(Theta / rad); - G4ThreeVector Y = G4ThreeVector(ii, jj, kk); + G4double ii = cos(Theta / rad) * cos(Phi / rad); + G4double jj = cos(Theta / rad) * sin(Phi / rad); + G4double kk = -sin(Theta / rad); + G4ThreeVector Y = G4ThreeVector(ii, jj, kk); MMw = MMw.unit(); MMu = MMw.cross(Y); @@ -879,9 +772,9 @@ void MUST2Array::ConstructDetector(G4LogicalVolume* world) { MMpos = MMw * Length * 0.5 + CT; } - Si = m_wSi[i]; + Si = m_wSi[i]; SiLi = m_wSiLi[i]; - CsI = m_wCsI[i]; + CsI = m_wCsI[i]; VolumeMaker(i + 1, MMpos, MMrot, Si, SiLi, CsI, world); } @@ -894,7 +787,7 @@ void MUST2Array::ConstructDetector(G4LogicalVolume* world) { void MUST2Array::InitializeRootOutput() { RootOutput* pAnalysis = RootOutput::getInstance(); - TTree* pTree = pAnalysis->GetTree(); + TTree* pTree = pAnalysis->GetTree(); if (!pTree->FindBranch("MUST2")) { pTree->Branch("MUST2", "TMust2Data", &m_Event); } @@ -913,145 +806,133 @@ void MUST2Array::ReadSensitive(const G4Event*) { ///////////////////// // Read the Scorer associate to the Silicon Strip - DSSDScorers::PS_Images* SiScorer - = (DSSDScorers::PS_Images*)m_StripScorer->GetPrimitive(0); + DSSDScorers::PS_Images* SiScorer = (DSSDScorers::PS_Images*)m_StripScorer->GetPrimitive(0); - bool SiScoredHit; // flag true if first stage scores a hit above threshold - set<int> trig; // list of telescope that got a Si trigger + bool SiScoredHit; // flag true if first stage scores a hit above threshold + set<int> trig; // list of telescope that got a Si trigger unsigned int sizeFront = SiScorer->GetFrontMult(); - unsigned int sizeBack = SiScorer->GetBackMult(); + unsigned int sizeBack = SiScorer->GetBackMult(); - // Check for double match Strip : + // Check for double match Strip : // rare case where a particle hit a strip and then an interstrip // since the map idex is build on pixel value, we end up with the same strip // fired twice, which is impossible in reality. - std::map< unsigned int, std::pair<double,double> > mapFront; - std::map< unsigned int, std::pair<double,double> >::iterator it; + std::map<unsigned int, std::pair<double, double>> mapFront; + std::map<unsigned int, std::pair<double, double>>::iterator it; for (unsigned int i = 0; i < sizeFront; i++) { - double energy = SiScorer->GetEnergyFront(i); - int detectorNbr = SiScorer->GetDetectorFront(i); - double time = SiScorer->GetTimeFront(i); + double energy = SiScorer->GetEnergyFront(i); + int detectorNbr = SiScorer->GetDetectorFront(i); + double time = SiScorer->GetTimeFront(i); // Pixel value at interaction point unsigned int a, r, g, b; // pixel SiScorer->GetARGBFront(i, a, r, g, b); if (r == 0) { - mapFront[b+detectorNbr*1e6].first+=energy; - mapFront[b+detectorNbr*1e6].second=time; - } + mapFront[b + detectorNbr * 1e6].first += energy; + mapFront[b + detectorNbr * 1e6].second = time; + } else { // Interstrip X, keep maximum shared energy double rand = G4UniformRand(); if (rand > 0.5) { double energyX = rand * energy; - mapFront[b+detectorNbr*1e6].first+=energyX; - mapFront[b+detectorNbr*1e6].second=time; - } + mapFront[b + detectorNbr * 1e6].first += energyX; + mapFront[b + detectorNbr * 1e6].second = time; + } else { - double energyX = (1 - rand) * energy; - mapFront[g+detectorNbr*1e6].first+=energyX; - mapFront[g+detectorNbr*1e6].second=time; - } + double energyX = (1 - rand) * energy; + mapFront[g + detectorNbr * 1e6].first += energyX; + mapFront[g + detectorNbr * 1e6].second = time; } } + } - for(it=mapFront.begin();it!=mapFront.end();it++){ + for (it = mapFront.begin(); it != mapFront.end(); it++) { double energyX = RandGauss::shoot(it->second.first, ResoStrip); double timeX = TimeOffset - RandGauss::shoot(it->second.second, ResoTimeMust); - unsigned int strip = it->first-1000000*(it->first/1000000); - unsigned int det = it->first/1000000; + unsigned int strip = it->first - 1000000 * (it->first / 1000000); + unsigned int det = it->first / 1000000; if (energyX > ThresholdSiX) { trig.insert(det); SiScoredHit = true; - m_Event->SetStripXE(det, strip , - NPL::EnergyToADC(energyX, 0, 63, 8192, 16384)); - m_Event->SetStripXT(det, strip , - NPL::EnergyToADC(timeX, 0, 1000, 8192, 16384)); + m_Event->SetStripXE(det, strip, NPL::EnergyToADC(energyX, 0, 63, 8192, 16384)); + m_Event->SetStripXT(det, strip, NPL::EnergyToADC(timeX, 0, 1000, 8192, 16384)); } } - // Check for double match Strip : + // Check for double match Strip : // rare case where a particle hit a strip and then an interstrip // since the map idex is build on pixel value, we end up with the same strip // fired twice, which is impossible in reality. - std::map< unsigned int, std::pair<double,double> > mapBack; + std::map<unsigned int, std::pair<double, double>> mapBack; for (unsigned int i = 0; i < sizeBack; i++) { - double energy = SiScorer->GetEnergyBack(i); - int detectorNbr = SiScorer->GetDetectorBack(i); - double time = SiScorer->GetTimeBack(i); - - // Pixel value at interaction point - unsigned int a, r, g, b; - // pixel - SiScorer->GetARGBBack(i, a, r, g, b); - if (r == 0) { - mapBack[b+detectorNbr*1e6].first+=energy; - mapBack[b+detectorNbr*1e6].second=time; - } - else { // Interstrip Y, keep both strip with shared energy - double rand = G4UniformRand(); - double energyY1 = rand * energy; - mapBack[b+detectorNbr*1e6].first+=energyY1; - mapBack[b+detectorNbr*1e6].second=time; - - double energyY2 = (1 - rand) * energy; - mapBack[g+detectorNbr*1e6].first+=energyY2; - mapBack[g+detectorNbr*1e6].second=time; - } - } + double energy = SiScorer->GetEnergyBack(i); + int detectorNbr = SiScorer->GetDetectorBack(i); + double time = SiScorer->GetTimeBack(i); - for(it=mapBack.begin();it!=mapBack.end();it++){ + // Pixel value at interaction point + unsigned int a, r, g, b; + // pixel + SiScorer->GetARGBBack(i, a, r, g, b); + if (r == 0) { + mapBack[b + detectorNbr * 1e6].first += energy; + mapBack[b + detectorNbr * 1e6].second = time; + } + else { // Interstrip Y, keep both strip with shared energy + double rand = G4UniformRand(); + double energyY1 = rand * energy; + mapBack[b + detectorNbr * 1e6].first += energyY1; + mapBack[b + detectorNbr * 1e6].second = time; + + double energyY2 = (1 - rand) * energy; + mapBack[g + detectorNbr * 1e6].first += energyY2; + mapBack[g + detectorNbr * 1e6].second = time; + } + } + + for (it = mapBack.begin(); it != mapBack.end(); it++) { double energyY = RandGauss::shoot(it->second.first, ResoStrip); double timeY = TimeOffset - RandGauss::shoot(it->second.second, ResoTimeMust); - unsigned int strip = it->first-1000000*(it->first/1000000); - unsigned int det = it->first/1000000; + unsigned int strip = it->first - 1000000 * (it->first / 1000000); + unsigned int det = it->first / 1000000; if (energyY > ThresholdSiY) { trig.insert(det); SiScoredHit = true; - m_Event->SetStripYE(det, strip , - NPL::EnergyToADC(energyY, 0, 63, 8192, 0)); - m_Event->SetStripYT(det, strip , - NPL::EnergyToADC(timeY, 0, 1000, 8192, 16384)); + m_Event->SetStripYE(det, strip, NPL::EnergyToADC(energyY, 0, 63, 8192, 0)); + m_Event->SetStripYT(det, strip, NPL::EnergyToADC(timeY, 0, 1000, 8192, 16384)); } } - // Look for 2nd and 3rd stage only if 1st stage is hit if (SiScoredHit) { // SiLi // - CalorimeterScorers::PS_Calorimeter* SiLiScorer - = (CalorimeterScorers::PS_Calorimeter*)m_SiLiScorer->GetPrimitive(0); + CalorimeterScorers::PS_Calorimeter* SiLiScorer = (CalorimeterScorers::PS_Calorimeter*)m_SiLiScorer->GetPrimitive(0); unsigned int sizeSiLi = SiLiScorer->GetMult(); for (unsigned int i = 0; i < sizeSiLi; i++) { double ESiLi = RandGauss::shoot(SiLiScorer->GetEnergy(i), ResoSiLi); vector<unsigned int> level = SiLiScorer->GetLevel(i); - if(ESiLi>ThresholdSiLi){ - m_Event->SetSiLiE(level[0], level[1], - NPL::EnergyToADC(ESiLi, 0, 250, 8192, 16384)); + if (ESiLi > ThresholdSiLi) { + m_Event->SetSiLiE(level[0], level[1], NPL::EnergyToADC(ESiLi, 0, 250, 8192, 16384)); double timeSiLi = RandGauss::shoot(SiLiScorer->GetTime(i), ResoTimeMust); - m_Event->SetSiLiT(level[0], level[1], - NPL::EnergyToADC(timeSiLi, 0, 1000, 16384, 8192)); + m_Event->SetSiLiT(level[0], level[1], NPL::EnergyToADC(timeSiLi, 0, 1000, 16384, 8192)); } } // CsI // - CalorimeterScorers::PS_Calorimeter* CsIScorer - = (CalorimeterScorers::PS_Calorimeter*)m_CsIScorer->GetPrimitive(0); + CalorimeterScorers::PS_Calorimeter* CsIScorer = (CalorimeterScorers::PS_Calorimeter*)m_CsIScorer->GetPrimitive(0); unsigned int sizeCsI = CsIScorer->GetMult(); for (unsigned int i = 0; i < sizeCsI; i++) { double ECsI = RandGauss::shoot(CsIScorer->GetEnergy(i), ResoCsI); vector<unsigned int> level = CsIScorer->GetLevel(i); - if(ECsI>ThresholdCsI){ - m_Event->SetCsIE(level[0], level[1], - NPL::EnergyToADC(ECsI, 0, 250, 8192, 16384)); + if (ECsI > ThresholdCsI) { + m_Event->SetCsIE(level[0], level[1], NPL::EnergyToADC(ECsI, 0, 250, 8192, 16384)); double timeCsI = RandGauss::shoot(CsIScorer->GetTime(i), ResoTimeMust); - m_Event->SetCsIT(level[0], level[1], - NPL::EnergyToADC(timeCsI, 0, 1000, 16384, 8192)); + m_Event->SetCsIT(level[0], level[1], NPL::EnergyToADC(timeCsI, 0, 1000, 16384, 8192)); } } } @@ -1062,37 +943,33 @@ void MUST2Array::InitializeScorers() { // Silicon Associate Scorer bool already_exist = false; - m_StripScorer = CheckScorer("MUST2_StripScorer", already_exist); - m_SiLiScorer = CheckScorer("MUST2_SiLiScorer", already_exist); - m_CsIScorer = CheckScorer("MUST2_CsIScorer", already_exist); + m_StripScorer = CheckScorer("MUST2_StripScorer", already_exist); + m_SiLiScorer = CheckScorer("MUST2_SiLiScorer", already_exist); + m_CsIScorer = CheckScorer("MUST2_CsIScorer", already_exist); // if the scorer were created previously nothing else need to be made if (already_exist) return; - string nptool = getenv("NPTOOL"); + string nptool = getenv("NPTOOL"); G4VPrimitiveScorer* SiScorer = new DSSDScorers::PS_Images( "SiScorer", nptool + "/NPLib/Detectors/MUST2/ressources/maskFront.png", - nptool + "/NPLib/Detectors/MUST2/ressources/maskBack.png", 97.22/12800, 97.22/12800, 0, - 0, 0xffff0000, 0); + nptool + "/NPLib/Detectors/MUST2/ressources/maskBack.png", 97.22 / 12800, 97.22 / 12800, 0, 0, 0xffff0000, 0); - G4VPrimitiveScorer* InterScorer - = new InteractionScorers::PS_Interactions("SiScorer", ms_InterCoord, 0); + G4VPrimitiveScorer* InterScorer = new InteractionScorers::PS_Interactions("SiScorer", ms_InterCoord, 0); // and register it to the multifunctionnal detector m_StripScorer->RegisterPrimitive(SiScorer); m_StripScorer->RegisterPrimitive(InterScorer); // SiLi Associate Scorer - vector<int> SiLi_nesting = {3, 0}; - G4VPrimitiveScorer* SiLiScorer - = new CalorimeterScorers::PS_Calorimeter("SiLiScorer", SiLi_nesting); + vector<int> SiLi_nesting = {3, 0}; + G4VPrimitiveScorer* SiLiScorer = new CalorimeterScorers::PS_Calorimeter("SiLiScorer", SiLi_nesting); m_SiLiScorer->RegisterPrimitive(SiLiScorer); // CsI Associate Scorer - vector<int> CsI_nesting = {2, 0}; - G4VPrimitiveScorer* CsIScorer - = new CalorimeterScorers::PS_Calorimeter("CsIScorer", CsI_nesting, 0); + vector<int> CsI_nesting = {2, 0}; + G4VPrimitiveScorer* CsIScorer = new CalorimeterScorers::PS_Calorimeter("CsIScorer", CsI_nesting, 0); m_CsIScorer->RegisterPrimitive(CsIScorer); // Add All Scorer to the Global Scorer Manager @@ -1104,32 +981,24 @@ void MUST2Array::InitializeScorers() { //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void MUST2Array::InitializeMaterial() { - m_MaterialSilicon - = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); - m_MaterialAluminium - = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); + m_MaterialSilicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); + m_MaterialAluminium = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); m_MaterialIron = MaterialManager::getInstance()->GetMaterialFromLibrary("Fe"); - m_MaterialVacuum - = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); + m_MaterialVacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4RotationMatrix* Rotation(double tetaX, double tetaY, double tetaZ) { - double PI = 3.141592653589793238; + double PI = 3.141592653589793238; double radX = tetaX * PI / 180.; double radY = tetaY * PI / 180.; double radZ = tetaZ * PI / 180.; - G4ThreeVector col1 = G4ThreeVector(cos(radZ) * cos(radY), - -sin(radZ) * cos(radY), -sin(radY)); - G4ThreeVector col2 - = G4ThreeVector(sin(radZ) * cos(radX) - cos(radZ) * sin(radY) * sin(radX), - cos(radZ) * cos(radX) + sin(radZ) * sin(radY) * sin(radX), - -cos(radY) * sin(radX)); - G4ThreeVector col3 - = G4ThreeVector(sin(radZ) * sin(radX) + cos(radZ) * sin(radY) * sin(radX), - cos(radZ) * sin(radX) - sin(radZ) * sin(radY) * cos(radX), - cos(radY) * cos(radX)); + G4ThreeVector col1 = G4ThreeVector(cos(radZ) * cos(radY), -sin(radZ) * cos(radY), -sin(radY)); + G4ThreeVector col2 = G4ThreeVector(sin(radZ) * cos(radX) - cos(radZ) * sin(radY) * sin(radX), + cos(radZ) * cos(radX) + sin(radZ) * sin(radY) * sin(radX), -cos(radY) * sin(radX)); + G4ThreeVector col3 = G4ThreeVector(sin(radZ) * sin(radX) + cos(radZ) * sin(radY) * sin(radX), + cos(radZ) * sin(radX) - sin(radZ) * sin(radY) * cos(radX), cos(radY) * cos(radX)); return (new G4RotationMatrix(col1, col2, col3)); } @@ -1137,22 +1006,19 @@ G4RotationMatrix* Rotation(double tetaX, double tetaY, double tetaZ) { //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* MUST2Array::Construct() { - return (NPS::VDetector*)new MUST2Array(); -} +NPS::VDetector* MUST2Array::Construct() { return (NPS::VDetector*)new MUST2Array(); } //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// extern "C" { - class proxy_nps_must2 { - public: - proxy_nps_must2() { - NPS::DetectorFactory::getInstance()->AddToken("M2Telescope", "MUST2"); - NPS::DetectorFactory::getInstance()->AddDetector("M2Telescope", - MUST2Array::Construct); - } - }; +class proxy_nps_must2 { + public: + proxy_nps_must2() { + NPS::DetectorFactory::getInstance()->AddToken("M2Telescope", "MUST2"); + NPS::DetectorFactory::getInstance()->AddDetector("M2Telescope", MUST2Array::Construct); + } +}; - proxy_nps_must2 p_nps_must2; +proxy_nps_must2 p_nps_must2; } diff --git a/NPSimulation/Detectors/Miniball/Miniball.cc b/NPSimulation/Detectors/Miniball/Miniball.cc index d8bcf5ae7..fac982b5b 100644 --- a/NPSimulation/Detectors/Miniball/Miniball.cc +++ b/NPSimulation/Detectors/Miniball/Miniball.cc @@ -20,151 +20,150 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> -//G4 Geometry object -#include "G4Tubs.hh" +#include <sstream> +// G4 Geometry object #include "G4Box.hh" +#include "G4Tubs.hh" -//G4 sensitive -#include "G4SDManager.hh" +// G4 sensitive #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" -//G4 various object +// G4 various object +#include "G4Colour.hh" #include "G4Material.hh" -#include "G4Transform3D.hh" #include "G4PVPlacement.hh" +#include "G4Transform3D.hh" #include "G4VisAttributes.hh" -#include "G4Colour.hh" // NPTool header -#include "Miniball.hh" #include "CalorimeterScorers.hh" #include "InteractionScorers.hh" -#include "RootOutput.h" #include "MaterialManager.hh" -#include "NPSDetectorFactory.hh" +#include "Miniball.hh" #include "NPOptionManager.h" +#include "NPSDetectorFactory.hh" +#include "RootOutput.h" // CLHEP header #include "CLHEP/Random/RandGauss.h" using namespace std; using namespace CLHEP; - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -namespace Miniball_NS{ +namespace Miniball_NS { // Energy and time Resolution - const double EnergyThreshold = 0.01*MeV; - const double ResoTime = 4.5*ns ; - const double ResoEnergy = 0.003*MeV ; - const double ResoAngle = 5*deg; -} + const double EnergyThreshold = 0.01 * MeV; + const double ResoTime = 4.5 * ns; + const double ResoEnergy = 0.003 * MeV; + const double ResoAngle = 5 * deg; +} // namespace Miniball_NS //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Miniball Specific Method -Miniball::Miniball(){ - m_Event = new TMiniballData() ; +Miniball::Miniball() { + m_Event = new TMiniballData(); m_MiniballScorer = 0; m_ClusterDetector = 0; m_NumberOfPlacedVolume = 0; - m_Inter=new TInteractionCoordinates(); + m_Inter = new TInteractionCoordinates(); } -Miniball::~Miniball(){ -} +Miniball::~Miniball() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Miniball::AddMiniball(double R, double Theta, double Phi){ +void Miniball::AddMiniball(double R, double Theta, double Phi) { m_R.push_back(R); m_Theta.push_back(Theta); m_Phi.push_back(Phi); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4AssemblyVolume* Miniball::BuildClusterDetector(){ - if(!m_ClusterDetector){ - m_ClusterDetector= new G4AssemblyVolume(); - cout << "Miniball geometry is based on Munich Group Simulation exported in GDML"<< endl; +G4AssemblyVolume* Miniball::BuildClusterDetector() { + if (!m_ClusterDetector) { + m_ClusterDetector = new G4AssemblyVolume(); + cout << "Miniball geometry is based on Munich Group Simulation exported in GDML" << endl; string basepath = getenv("NPTOOL"); - string path=basepath+"/NPSimulation/Detectors/Miniball/Miniball.gdml"; - m_gdmlparser.Read(path,false); + string path = basepath + "/NPSimulation/Detectors/Miniball/Miniball.gdml"; + m_gdmlparser.Read(path, false); - G4VisAttributes* Red = new G4VisAttributes(G4Color(1,0.5,0.5)); - G4VisAttributes* Green= new G4VisAttributes(G4Color(0.5,1,0.5)); - G4VisAttributes* Blue = new G4VisAttributes(G4Color(0.5,0.5,1)); - G4VisAttributes* Caps = new G4VisAttributes(G4Color(0.5,0.5,0.5,0.5)); + G4VisAttributes* Red = new G4VisAttributes(G4Color(1, 0.5, 0.5)); + G4VisAttributes* Green = new G4VisAttributes(G4Color(0.5, 1, 0.5)); + G4VisAttributes* Blue = new G4VisAttributes(G4Color(0.5, 0.5, 1)); + G4VisAttributes* Caps = new G4VisAttributes(G4Color(0.5, 0.5, 0.5, 0.5)); - G4VisAttributes* DL = new G4VisAttributes(G4VisAttributes::Invisible); + G4VisAttributes* DL = new G4VisAttributes(G4VisAttributes::GetInvisible()); - G4LogicalVolume* World = m_gdmlparser.GetVolume("MexpHall_log"); - string name,dname; - for(unsigned int i = 0 ; i < World->GetNoDaughters () ;i++){ + G4LogicalVolume* World = m_gdmlparser.GetVolume("MexpHall_log"); + string name, dname; + for (unsigned int i = 0; i < World->GetNoDaughters(); i++) { G4VPhysicalVolume* VPV = World->GetDaughter(i); name = VPV->GetLogicalVolume()->GetName(); - if(name == "cluster0_0_HPGe_A_0_det_env_log"){ - G4LogicalVolume* HPGE = VPV->GetLogicalVolume(); + if (name == "cluster0_0_HPGe_A_0_det_env_log") { + G4LogicalVolume* HPGE = VPV->GetLogicalVolume(); HPGE->GetDaughter(0)->GetLogicalVolume()->SetSensitiveDetector(m_MiniballScorer); HPGE->SetVisAttributes(Red); - G4RotationMatrix* Rot = VPV->GetObjectRotation(); - G4ThreeVector Pos = VPV->GetObjectTranslation(); - G4Transform3D Trans(*Rot,Pos); - m_ClusterDetector->AddPlacedVolume(HPGE,Trans); + G4RotationMatrix* Rot = VPV->GetObjectRotation(); + G4ThreeVector Pos = VPV->GetObjectTranslation(); + G4Transform3D Trans(*Rot, Pos); + m_ClusterDetector->AddPlacedVolume(HPGE, Trans); m_NumberOfPlacedVolume++; - for(unsigned int d = 0 ; d < HPGE->GetNoDaughters () ;d++){ - G4VPhysicalVolume* dVPV = HPGE->GetDaughter(d); + for (unsigned int d = 0; d < HPGE->GetNoDaughters(); d++) { + G4VPhysicalVolume* dVPV = HPGE->GetDaughter(d); dname = dVPV->GetLogicalVolume()->GetName(); - if(dname == "cluster0_0_HPGe_A_0_deadlayer_log"){ - G4LogicalVolume* DeadLayer = dVPV->GetLogicalVolume(); - DeadLayer->SetVisAttributes(DL); + if (dname == "cluster0_0_HPGe_A_0_deadlayer_log") { + G4LogicalVolume* DeadLayer = dVPV->GetLogicalVolume(); + DeadLayer->SetVisAttributes(DL); } } } - else if(name == "cluster0_0_HPGe_B_1_det_env_log"){ - G4LogicalVolume* HPGE = VPV->GetLogicalVolume(); + else if (name == "cluster0_0_HPGe_B_1_det_env_log") { + G4LogicalVolume* HPGE = VPV->GetLogicalVolume(); HPGE->GetDaughter(0)->GetLogicalVolume()->SetSensitiveDetector(m_MiniballScorer); HPGE->SetVisAttributes(Green); - G4RotationMatrix* Rot = VPV->GetObjectRotation(); - G4ThreeVector Pos = VPV->GetObjectTranslation(); - G4Transform3D Trans(*Rot,Pos); - m_ClusterDetector->AddPlacedVolume(HPGE,Trans); + G4RotationMatrix* Rot = VPV->GetObjectRotation(); + G4ThreeVector Pos = VPV->GetObjectTranslation(); + G4Transform3D Trans(*Rot, Pos); + m_ClusterDetector->AddPlacedVolume(HPGE, Trans); m_NumberOfPlacedVolume++; - for(unsigned int d = 0 ; d < HPGE->GetNoDaughters () ;d++){ - G4VPhysicalVolume* dVPV = HPGE->GetDaughter(d); + for (unsigned int d = 0; d < HPGE->GetNoDaughters(); d++) { + G4VPhysicalVolume* dVPV = HPGE->GetDaughter(d); dname = dVPV->GetLogicalVolume()->GetName(); - if(dname == "cluster0_0_HPGe_B_1_deadlayer_log"){ - G4LogicalVolume* DeadLayer = dVPV->GetLogicalVolume(); - DeadLayer->SetVisAttributes(DL); + if (dname == "cluster0_0_HPGe_B_1_deadlayer_log") { + G4LogicalVolume* DeadLayer = dVPV->GetLogicalVolume(); + DeadLayer->SetVisAttributes(DL); } } } - else if(name == "cluster0_0_HPGe_C_2_det_env_log"){ - G4LogicalVolume* HPGE = VPV->GetLogicalVolume(); + else if (name == "cluster0_0_HPGe_C_2_det_env_log") { + G4LogicalVolume* HPGE = VPV->GetLogicalVolume(); HPGE->GetDaughter(0)->GetLogicalVolume()->SetSensitiveDetector(m_MiniballScorer); HPGE->SetVisAttributes(Blue); - G4RotationMatrix* Rot = VPV->GetObjectRotation(); - G4ThreeVector Pos = VPV->GetObjectTranslation(); - G4Transform3D Trans(*Rot,Pos); - m_ClusterDetector->AddPlacedVolume(HPGE,Trans); - for(unsigned int d = 0 ; d < HPGE->GetNoDaughters () ;d++){ - G4VPhysicalVolume* dVPV = HPGE->GetDaughter(d); + G4RotationMatrix* Rot = VPV->GetObjectRotation(); + G4ThreeVector Pos = VPV->GetObjectTranslation(); + G4Transform3D Trans(*Rot, Pos); + m_ClusterDetector->AddPlacedVolume(HPGE, Trans); + for (unsigned int d = 0; d < HPGE->GetNoDaughters(); d++) { + G4VPhysicalVolume* dVPV = HPGE->GetDaughter(d); dname = dVPV->GetLogicalVolume()->GetName(); - if(dname == "cluster0_0_HPGe_C_2_deadlayer_log"){ - G4LogicalVolume* DeadLayer = dVPV->GetLogicalVolume(); - DeadLayer->SetVisAttributes(DL); + if (dname == "cluster0_0_HPGe_C_2_deadlayer_log") { + G4LogicalVolume* DeadLayer = dVPV->GetLogicalVolume(); + DeadLayer->SetVisAttributes(DL); } - } m_NumberOfPlacedVolume++; + } + m_NumberOfPlacedVolume++; } - else if(name.compare(0,8,"cluster0")==0 || name == "nozzle_log"){ - G4LogicalVolume* Capsule= VPV->GetLogicalVolume(); + else if (name.compare(0, 8, "cluster0") == 0 || name == "nozzle_log") { + G4LogicalVolume* Capsule = VPV->GetLogicalVolume(); Capsule->SetVisAttributes(Caps); - G4RotationMatrix* Rot = VPV->GetObjectRotation(); - G4ThreeVector Pos = VPV->GetObjectTranslation(); - G4Transform3D Trans(*Rot,Pos); - m_ClusterDetector->AddPlacedVolume(Capsule,Trans); + G4RotationMatrix* Rot = VPV->GetObjectRotation(); + G4ThreeVector Pos = VPV->GetObjectTranslation(); + G4Transform3D Trans(*Rot, Pos); + m_ClusterDetector->AddPlacedVolume(Capsule, Trans); m_NumberOfPlacedVolume++; } } @@ -179,25 +178,25 @@ G4AssemblyVolume* Miniball::BuildClusterDetector(){ // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Miniball::ReadConfiguration(NPL::InputParser parser){ +void Miniball::ReadConfiguration(NPL::InputParser parser) { vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Miniball"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " detectors found " << endl; + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; - vector<string> token = {"R","Theta","Phi"}; + vector<string> token = {"R", "Theta", "Phi"}; - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(token)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Miniball Cluster" << i+1 << endl; - double R = blocks[i]->GetDouble("R","mm"); - double Theta = blocks[i]->GetDouble("Theta","deg"); - double Phi = blocks[i]->GetDouble("Phi","deg"); + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(token)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Miniball Cluster" << i + 1 << endl; + double R = blocks[i]->GetDouble("R", "mm"); + double Theta = blocks[i]->GetDouble("Theta", "deg"); + double Phi = blocks[i]->GetDouble("Phi", "deg"); - AddMiniball(R,Theta,Phi); + AddMiniball(R, Theta, Phi); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } @@ -207,106 +206,107 @@ void Miniball::ReadConfiguration(NPL::InputParser parser){ // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void Miniball::ConstructDetector(G4LogicalVolume* world){ +void Miniball::ConstructDetector(G4LogicalVolume* world) { BuildClusterDetector(); - for (unsigned short i = 0 ; i < m_R.size() ; i++) { + 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) ; + 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); G4ThreeVector d = Det_pos.unit(); - Det_pos= Det_pos-d*100*mm; + Det_pos = Det_pos - d * 100 * mm; // 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 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); - G4Transform3D Trans(*Rot,Det_pos); - m_ClusterDetector->MakeImprint(world,Det_pos, Rot,i+1); - // set a nicer name - std::vector< G4VPhysicalVolume * >::iterator it = m_ClusterDetector->GetVolumesIterator(); - it+=m_ClusterDetector->GetImprintsCount()*m_NumberOfPlacedVolume-1; - for(unsigned int l = 0 ; l < m_NumberOfPlacedVolume-3 ; l++){ + G4RotationMatrix* Rot = new G4RotationMatrix(u, v, w); + G4Transform3D Trans(*Rot, Det_pos); + m_ClusterDetector->MakeImprint(world, Det_pos, Rot, i + 1); + // set a nicer name + std::vector<G4VPhysicalVolume*>::iterator it = m_ClusterDetector->GetVolumesIterator(); + it += m_ClusterDetector->GetImprintsCount() * m_NumberOfPlacedVolume - 1; + for (unsigned int l = 0; l < m_NumberOfPlacedVolume - 3; l++) { (*it)->SetName("Capsule"); - (*it)->SetCopyNo(i+1); + (*it)->SetCopyNo(i + 1); it--; - } (*it)->SetName("HPGe_A"); - (*it)->SetCopyNo(i+1); + (*it)->SetCopyNo(i + 1); it--; (*it)->SetName("HPGe_B"); - (*it)->SetCopyNo(i+1); + (*it)->SetCopyNo(i + 1); it--; (*it)->SetName("HPGe_C"); - (*it)->SetCopyNo(i+1);; + (*it)->SetCopyNo(i + 1); + ; } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void Miniball::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("Miniball")){ - pTree->Branch("Miniball", "TMiniballData", &m_Event) ; +void Miniball::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("Miniball")) { + pTree->Branch("Miniball", "TMiniballData", &m_Event); } - pTree->SetBranchAddress("Miniball", &m_Event) ; + pTree->SetBranchAddress("Miniball", &m_Event); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAction -void Miniball::ReadSensitive(const G4Event* ){ +void Miniball::ReadSensitive(const G4Event*) { m_Event->Clear(); /////////// - CalorimeterScorers::PS_Calorimeter* Scorer= (CalorimeterScorers::PS_Calorimeter*) m_MiniballScorer->GetPrimitive(0); - // InteractionScorers::PS_Interactions* Inter= (InteractionScorers::PS_Interactions*) m_MiniballScorer->GetPrimitive(1); - - unsigned int size = Scorer->GetMult(); - for(unsigned int i = 0 ; i < size ; i++){ - vector<unsigned int> level = Scorer->GetLevel(i); - double Energy = RandGauss::shoot(Scorer->GetEnergy(i),Miniball_NS::ResoEnergy); - if(Energy>Miniball_NS::EnergyThreshold){ - double Time = RandGauss::shoot(Scorer->GetTime(i),Miniball_NS::ResoTime); + CalorimeterScorers::PS_Calorimeter* Scorer = (CalorimeterScorers::PS_Calorimeter*)m_MiniballScorer->GetPrimitive(0); + // InteractionScorers::PS_Interactions* Inter= (InteractionScorers::PS_Interactions*) + // m_MiniballScorer->GetPrimitive(1); + + unsigned int size = Scorer->GetMult(); + for (unsigned int i = 0; i < size; i++) { + vector<unsigned int> level = Scorer->GetLevel(i); + double Energy = RandGauss::shoot(Scorer->GetEnergy(i), Miniball_NS::ResoEnergy); + if (Energy > Miniball_NS::EnergyThreshold) { + double Time = RandGauss::shoot(Scorer->GetTime(i), Miniball_NS::ResoTime); int DetectorNbr = level[0]; - //double Angle = RandGauss::shoot(Info[5]/deg,Miniball_NS::ResoAngle); - m_Event->SetEnergy(DetectorNbr,Energy); - //m_Event->SetAngle(DetectorNbr,Angle); - m_Event->SetTime(DetectorNbr,Time); + // double Angle = RandGauss::shoot(Info[5]/deg,Miniball_NS::ResoAngle); + m_Event->SetEnergy(DetectorNbr, Energy); + // m_Event->SetAngle(DetectorNbr,Angle); + m_Event->SetTime(DetectorNbr, Time); m_Event->SetAngle(DetectorNbr, m_Inter->GetDetectedAngleTheta(i)); } } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -//////////////////////////////////////////////////////////////// -void Miniball::InitializeScorers() { +//////////////////////////////////////////////////////////////// +void Miniball::InitializeScorers() { // This check is necessary in case the geometry is reloaded - bool already_exist = false; - m_MiniballScorer = CheckScorer("MiniballScorer",already_exist) ; + bool already_exist = false; + m_MiniballScorer = CheckScorer("MiniballScorer", already_exist); - if(already_exist) - return ; + if (already_exist) + return; // Otherwise the scorer is initialised - vector<int> level; level.push_back(1); - G4VPrimitiveScorer* Calorimeter= new CalorimeterScorers::PS_Calorimeter("Crystal",level, 0) ; - G4VPrimitiveScorer* Inter= new InteractionScorers::PS_Interactions("Inter",m_Inter, 1) ; - //and register it to the multifunctionnal detector + vector<int> level; + level.push_back(1); + G4VPrimitiveScorer* Calorimeter = new CalorimeterScorers::PS_Calorimeter("Crystal", level, 0); + G4VPrimitiveScorer* Inter = new InteractionScorers::PS_Interactions("Inter", m_Inter, 1); + // and register it to the multifunctionnal detector m_MiniballScorer->RegisterPrimitive(Calorimeter); m_MiniballScorer->RegisterPrimitive(Inter); - G4SDManager::GetSDMpointer()->AddNewDetector(m_MiniballScorer) ; + G4SDManager::GetSDMpointer()->AddNewDetector(m_MiniballScorer); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -315,22 +315,20 @@ void Miniball::InitializeScorers() { //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* Miniball::Construct(){ - return (NPS::VDetector*) new Miniball(); -} +NPS::VDetector* Miniball::Construct() { return (NPS::VDetector*)new Miniball(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_plastic{ - public: - proxy_nps_plastic(){ - NPS::DetectorFactory::getInstance()->AddToken("Miniball","Miniball"); - NPS::DetectorFactory::getInstance()->AddDetector("Miniball",Miniball::Construct); - } - }; +extern "C" { +class proxy_nps_plastic { + public: + proxy_nps_plastic() { + NPS::DetectorFactory::getInstance()->AddToken("Miniball", "Miniball"); + NPS::DetectorFactory::getInstance()->AddDetector("Miniball", Miniball::Construct); + } +}; - proxy_nps_plastic p_nps_plastic; +proxy_nps_plastic p_nps_plastic; } diff --git a/NPSimulation/Detectors/Minos/Minos.cc b/NPSimulation/Detectors/Minos/Minos.cc index 2d19c944d..88a18ed5c 100644 --- a/NPSimulation/Detectors/Minos/Minos.cc +++ b/NPSimulation/Detectors/Minos/Minos.cc @@ -21,134 +21,131 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> -//G4 Geometry object -#include "G4Tubs.hh" +#include <sstream> +// G4 Geometry object #include "G4Box.hh" #include "G4Trd.hh" +#include "G4Tubs.hh" -//G4 sensitive -#include "G4SDManager.hh" +// G4 sensitive #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" -//G4 various object -#include "G4Material.hh" -#include "G4Transform3D.hh" -#include "G4PVPlacement.hh" -#include "G4VisAttributes.hh" +// G4 various object #include "G4Colour.hh" -#include "G4PVReplica.hh" +#include "G4Material.hh" #include "G4PVParameterised.hh" +#include "G4PVPlacement.hh" +#include "G4PVReplica.hh" +#include "G4Transform3D.hh" #include "G4VPVParameterisation.hh" +#include "G4VisAttributes.hh" // G4 Field -#include "G4FieldManager.hh" +#include "G4ChordFinder.hh" +#include "G4ClassicalRK4.hh" #include "G4ElectricField.hh" -#include "G4UniformElectricField.hh" -#include "G4TransportationManager.hh" #include "G4EqMagElectricField.hh" -#include "G4MagIntegratorStepper.hh" -#include "G4ClassicalRK4.hh" +#include "G4FieldManager.hh" #include "G4MagIntegratorDriver.hh" -#include "G4ChordFinder.hh" +#include "G4MagIntegratorStepper.hh" #include "G4MaterialPropertiesTable.hh" +#include "G4TransportationManager.hh" +#include "G4UniformElectricField.hh" // NPTool header -#include "Minos.hh" #include "InteractionScorers.hh" +#include "Minos.hh" /* #include "TPCScorers.hh" */ #include "CylinderTPCScorers.hh" #include "MaterialManager.hh" -#include "NPSDetectorFactory.hh" #include "NPOptionManager.h" +#include "NPSDetectorFactory.hh" #include "NPSHitsMap.hh" // CLHEP header #include "CLHEP/Random/RandGauss.h" // ROOT -#include "TH1F.h" -#include "TF1.h" #include "RootOutput.h" +#include "TF1.h" +#include "TH1F.h" using namespace std; using namespace CLHEP; - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -namespace Minos_NS{ +namespace Minos_NS { // TPC - const G4double ChamberInnerRadius = 37.*mm; - /* const G4double ChamberInnerRadius = 29*mm; */ //big TPC - //const G4double ChamberThickness = 2.*mm; - const G4double ChamberLength = 300.*mm; - const G4double KaptonThickness = 0.125*mm; - const G4double RohacellThickness = 2.*mm; - const G4double TPCRadiusExt = 91.525*mm; + const G4double ChamberInnerRadius = 37. * mm; + /* const G4double ChamberInnerRadius = 29*mm; */ // big TPC + // const G4double ChamberThickness = 2.*mm; + const G4double ChamberLength = 300. * mm; + const G4double KaptonThickness = 0.125 * mm; + const G4double RohacellThickness = 2. * mm; + const G4double TPCRadiusExt = 91.525 * mm; /* const G4double TPCRadiusExt = 150*mm; //big TPC */ // MINOS - const G4double TargetRadius = 28.*mm; - const G4double WindowThickness = 0.150*mm; + const G4double TargetRadius = 28. * mm; + const G4double WindowThickness = 0.150 * mm; -} +} // namespace Minos_NS using namespace Minos_NS; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Minos Specific Method -Minos::Minos(){ - m_Event = new TMinosData() ; +Minos::Minos() { + m_Event = new TMinosData(); m_MinosPadScorer = 0; - m_ReactionRegion=NULL; + m_ReactionRegion = NULL; // RGB Color + Transparency - m_VisTarget= new G4VisAttributes(G4Colour(0.6,1.,1., .4)); - m_VissimpleBox= new G4VisAttributes(G4Colour(0,1,0,.6)); - m_VisTPC= new G4VisAttributes(G4Colour(1.,0.5,0.6,0.3)); - m_VisRohacell= new G4VisAttributes(G4Colour(1.,1.,1., .8)); - m_VisKapton = new G4VisAttributes(G4Colour(1.,1.,0.6,0.4)); - m_VisTargetCell = new G4VisAttributes(G4Colour(0,0,1, .4)); + m_VisTarget = new G4VisAttributes(G4Colour(0.6, 1., 1., .4)); + m_VissimpleBox = new G4VisAttributes(G4Colour(0, 1, 0, .6)); + m_VisTPC = new G4VisAttributes(G4Colour(1., 0.5, 0.6, 0.3)); + m_VisRohacell = new G4VisAttributes(G4Colour(1., 1., 1., .8)); + m_VisKapton = new G4VisAttributes(G4Colour(1., 1., 0.6, 0.4)); + m_VisTargetCell = new G4VisAttributes(G4Colour(0, 0, 1, .4)); m_VisTargetCell->SetForceSolid(true); - m_VisOuterKapton = new G4VisAttributes(G4Colour(1.,1.,0.6,0.8)); + m_VisOuterKapton = new G4VisAttributes(G4Colour(1., 1., 0.6, 0.8)); - Raw_Signal = new TH1F("raw_Signal","raw_Signal",512,0,512); - Elec_Signal = new TH1F("Elec_Signal","Elec_Signal",512,0,512); + Raw_Signal = new TH1F("raw_Signal", "raw_Signal", 512, 0, 512); + Elec_Signal = new TH1F("Elec_Signal", "Elec_Signal", 512, 0, 512); /* Raw_Signal = new TH1F;*/ /* Elec_Signal = new TH1F;*/ - - fa1 = new TF1("fa1","abs((x>[1]&&x<512)*([0]*exp(-3.*(x-[1])/[2]) * sin((x-[1])/[2]) * pow((x-[1])/[2],3))+[3])",0,1000); + fa1 = new TF1("fa1", "abs((x>[1]&&x<512)*([0]*exp(-3.*(x-[1])/[2]) * sin((x-[1])/[2]) * pow((x-[1])/[2],3))+[3])", 0, + 1000); fa1->SetNpx(512); - solidTarget=0; - logicTarget=0; - solidChamber=0; - logicChamber=0; - solidTPC=0; - logicTPC=0; - solidWindow0=0; - logicWindow0=0; - solidRohacell=0; - logicRohacell=0; - solidKapton=0; - logicKapton=0; + solidTarget = 0; + logicTarget = 0; + solidChamber = 0; + logicChamber = 0; + solidTPC = 0; + logicTPC = 0; + solidWindow0 = 0; + logicWindow0 = 0; + solidRohacell = 0; + logicRohacell = 0; + solidKapton = 0; + logicKapton = 0; } -Minos::~Minos(){ -} +Minos::~Minos() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - - /* void Minos::AddDetector(G4ThreeVector POS, double LengthOfTarget, int PresenceOfMinos){ */ -void Minos::AddDetector(G4ThreeVector POS,double TargetZOffset, double LengthOfTarget, G4String MaterialOfTarget,G4String MaterialOfCell, int PresenceOfMinos){ +void Minos::AddDetector(G4ThreeVector POS, double TargetZOffset, double LengthOfTarget, G4String MaterialOfTarget, + G4String MaterialOfCell, int PresenceOfMinos) { m_POS.push_back(POS); m_TargetLength.push_back(LengthOfTarget); m_TargetMaterial.push_back(MaterialOfTarget); @@ -159,7 +156,6 @@ void Minos::AddDetector(G4ThreeVector POS,double TargetZOffset, double LengthOfT //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -167,32 +163,31 @@ void Minos::AddDetector(G4ThreeVector POS,double TargetZOffset, double LengthOfT // vis/OpenInventor driver : //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Minos::BuildTarget(){ - if(!logicTarget){ - // +G4LogicalVolume* Minos::BuildTarget() { + if (!logicTarget) { + // // Target - // - solidTarget = new G4Tubs("Target", //its name - 0.,TargetRadius,m_TargetLength[0]/2.,0,360.);//size - logicTarget = new G4LogicalVolume(solidTarget, //its solid - TargetMaterial, //its material - "Target"); //its name + // + solidTarget = new G4Tubs("Target", // its name + 0., TargetRadius, m_TargetLength[0] / 2., 0, 360.); // size + logicTarget = new G4LogicalVolume(solidTarget, // its solid + TargetMaterial, // its material + "Target"); // its name logicTarget->SetVisAttributes(m_VisTarget); } return logicTarget; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Minos::BuildTPC(){ - if(!logicTPC){ - // +G4LogicalVolume* Minos::BuildTPC() { + if (!logicTPC) { + // // TPC // - solidTPC = new G4Tubs("TPC", - ChamberInnerRadius ,TPCRadiusExt,ChamberLength/2.,0,360.); - logicTPC = new G4LogicalVolume(solidTPC, //its solid - TPCMaterial, //its material - "TPC"); //name + solidTPC = new G4Tubs("TPC", ChamberInnerRadius, TPCRadiusExt, ChamberLength / 2., 0, 360.); + logicTPC = new G4LogicalVolume(solidTPC, // its solid + TPCMaterial, // its material + "TPC"); // name logicTPC->SetVisAttributes(m_VisTPC); } return logicTPC; @@ -205,7 +200,7 @@ G4LogicalVolume* Minos::BuildTPC(){ /* ChamberInnerRadius,ChamberInnerRadius+ChamberThickness,ChamberLength/2.,0,360.); //size */ /* logicChamber = new G4LogicalVolume(solidChamber, //its solid */ /* ChamberMaterial, //its material */ -/* "Chamber"); //its name */ +/* "Chamber"); //its name */ /* m_VissimpleBox->SetVisibility(true); */ /* logicChamber->SetVisAttributes(m_VissimpleBox); */ /* } */ @@ -213,13 +208,14 @@ G4LogicalVolume* Minos::BuildTPC(){ /* } */ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Minos::BuildInnerRohacell(){ - if(!logicRohacell){ - solidRohacell = new G4Tubs("InnerRohacell", //its name - ChamberInnerRadius ,ChamberInnerRadius + RohacellThickness ,ChamberLength/2.,0,360.); //size - logicRohacell = new G4LogicalVolume(solidRohacell, //its solid - RohacellMaterial, //its material - "InnerRohacell"); //its name +G4LogicalVolume* Minos::BuildInnerRohacell() { + if (!logicRohacell) { + solidRohacell = + new G4Tubs("InnerRohacell", // its name + ChamberInnerRadius, ChamberInnerRadius + RohacellThickness, ChamberLength / 2., 0, 360.); // size + logicRohacell = new G4LogicalVolume(solidRohacell, // its solid + RohacellMaterial, // its material + "InnerRohacell"); // its name logicRohacell->SetVisAttributes(m_VisRohacell); } return logicRohacell; @@ -227,60 +223,60 @@ G4LogicalVolume* Minos::BuildInnerRohacell(){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - -G4LogicalVolume* Minos::BuildOuterRohacell(){ - if(logicRohacell){ - solidRohacell = new G4Tubs("OuterRohacell", //its name - TPCRadiusExt-RohacellThickness, TPCRadiusExt ,ChamberLength/2.,0,360.); //size - logicRohacell = new G4LogicalVolume(solidRohacell, //its solid - RohacellMaterial, //its material - "OuterRohacell"); //its name +G4LogicalVolume* Minos::BuildOuterRohacell() { + if (logicRohacell) { + solidRohacell = new G4Tubs("OuterRohacell", // its name + TPCRadiusExt - RohacellThickness, TPCRadiusExt, ChamberLength / 2., 0, 360.); // size + logicRohacell = new G4LogicalVolume(solidRohacell, // its solid + RohacellMaterial, // its material + "OuterRohacell"); // its name logicRohacell->SetVisAttributes(m_VisRohacell); } return logicRohacell; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Minos::BuildKapton(){ - if(!logicKapton){ - solidKapton = new G4Tubs("Kapton", //its name - ChamberInnerRadius+RohacellThickness ,ChamberInnerRadius+RohacellThickness+KaptonThickness,ChamberLength/2.,0,360.); //size - logicKapton = new G4LogicalVolume(solidKapton, //its solid - KaptonMaterial, //its material - "Kapton"); //its name +G4LogicalVolume* Minos::BuildKapton() { + if (!logicKapton) { + solidKapton = + new G4Tubs("Kapton", // its name + ChamberInnerRadius + RohacellThickness, ChamberInnerRadius + RohacellThickness + KaptonThickness, + ChamberLength / 2., 0, 360.); // size + logicKapton = new G4LogicalVolume(solidKapton, // its solid + KaptonMaterial, // its material + "Kapton"); // its name logicKapton->SetVisAttributes(m_VisKapton); } return logicKapton; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Minos::BuildOuterKapton(){ - if(logicKapton){ - solidKapton = new G4Tubs("Kapton", //its name - TPCRadiusExt-RohacellThickness-KaptonThickness, TPCRadiusExt-RohacellThickness,ChamberLength/2.,0,360.); //size - logicKapton = new G4LogicalVolume(solidKapton, //its solid - KaptonMaterial, //its material - "Kapton"); //its name +G4LogicalVolume* Minos::BuildOuterKapton() { + if (logicKapton) { + solidKapton = new G4Tubs("Kapton", // its name + TPCRadiusExt - RohacellThickness - KaptonThickness, TPCRadiusExt - RohacellThickness, + ChamberLength / 2., 0, 360.); // size + logicKapton = new G4LogicalVolume(solidKapton, // its solid + KaptonMaterial, // its material + "Kapton"); // its name logicKapton->SetVisAttributes(m_VisOuterKapton); } return logicKapton; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -// +// // windows // //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Minos::BuildWindow0(){ - if(!logicWindow0){ - solidWindow0 = new G4Tubs("WindowTube", //its name - 0.,TargetRadius+WindowThickness,m_TargetLength[0]/2.+WindowThickness,0,360.); - logicWindow0 = new G4LogicalVolume(solidWindow0, //its solid - WindowMaterial, //its material - "WindowTube"); //name +G4LogicalVolume* Minos::BuildWindow0() { + if (!logicWindow0) { + solidWindow0 = new G4Tubs("WindowTube", // its name + 0., TargetRadius + WindowThickness, m_TargetLength[0] / 2. + WindowThickness, 0, 360.); + logicWindow0 = new G4LogicalVolume(solidWindow0, // its solid + WindowMaterial, // its material + "WindowTube"); // name logicWindow0->SetVisAttributes(m_VisTargetCell); } return logicWindow0; @@ -292,279 +288,274 @@ G4LogicalVolume* Minos::BuildWindow0(){ // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Minos::ReadConfiguration(NPL::InputParser parser){ +void Minos::ReadConfiguration(NPL::InputParser parser) { vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Minos"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " detectors found " << endl; + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; vector<string> simu = {"TPCOnly"}; - vector<string> token= {"XML","Position","TargetZOffset","TargetMaterial","TargetLength","CellMaterial","TimeBin","ShapingTime","Baseline","Sampling","ZOffset"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(token)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Minos " << i+1 << endl; - G4ThreeVector Pos = NPS::ConvertVector(blocks[i]->GetTVector3("Position","mm")); - double TargetLength = blocks[i]->GetDouble("TargetLength","mm"); - double TargetZOffset= blocks[i]->GetDouble("TargetZOffset","mm"); + vector<string> token = {"XML", "Position", "TargetZOffset", "TargetMaterial", "TargetLength", "CellMaterial", + "TimeBin", "ShapingTime", "Baseline", "Sampling", "ZOffset"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(token)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Minos " << i + 1 << endl; + G4ThreeVector Pos = NPS::ConvertVector(blocks[i]->GetTVector3("Position", "mm")); + double TargetLength = blocks[i]->GetDouble("TargetLength", "mm"); + double TargetZOffset = blocks[i]->GetDouble("TargetZOffset", "mm"); G4String TargetMaterialname = blocks[i]->GetString("TargetMaterial"); G4String CellMaterial = blocks[i]->GetString("CellMaterial"); - m_ShapingTime = blocks[i]->GetDouble("ShapingTime","ns")/ns; - m_TimeBin = blocks[i]->GetDouble("TimeBin","ns")/ns; - m_Sampling= blocks[i]->GetInt("Sampling"); - m_Baseline= blocks[i]->GetInt("BaseLine"); - m_ZOffset = blocks[i]->GetDouble("ZOffset","mm"); + m_ShapingTime = blocks[i]->GetDouble("ShapingTime", "ns") / ns; + m_TimeBin = blocks[i]->GetDouble("TimeBin", "ns") / ns; + m_Sampling = blocks[i]->GetInt("Sampling"); + m_Baseline = blocks[i]->GetInt("BaseLine"); + m_ZOffset = blocks[i]->GetDouble("ZOffset", "mm"); string xmlpath = blocks[i]->GetString("XML"); NPL::XmlParser xml; xml.LoadFile(xmlpath); ReadXML(xml); - TPCOnly=1; - if(blocks[i]->HasTokenList(simu)) + TPCOnly = 1; + if (blocks[i]->HasTokenList(simu)) TPCOnly = blocks[i]->GetInt("TPCOnly"); - AddDetector(Pos,TargetZOffset,TargetLength,TargetMaterialname, CellMaterial, TPCOnly); - + AddDetector(Pos, TargetZOffset, TargetLength, TargetMaterialname, CellMaterial, TPCOnly); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } } } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void Minos::ConstructDetector(G4LogicalVolume* world){ - for (unsigned short i = 0 ; i < m_POS.size() ; i++) { +void Minos::ConstructDetector(G4LogicalVolume* world) { + for (unsigned short i = 0; i < m_POS.size(); i++) { bool TPCOnly = m_TPCOnly[i]; - /* TargetMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); */ - TargetMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("LH2"); + /* TargetMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); */ + TargetMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("LH2"); WindowMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Mylar"); - ChamberMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); + ChamberMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); KaptonMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Kapton"); RohacellMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Rohacell"); TPCMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("mixMINOS"); - /* TargetMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); */ + /* TargetMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); */ /* WindowMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); */ - /* ChamberMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); */ + /* ChamberMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); */ /* KaptonMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); */ /* RohacellMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); */ /* TPCMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("mixMINOS"); */ ///////// Drift properties - G4MaterialPropertiesTable* MPT = new G4MaterialPropertiesTable(); - MPT->AddConstProperty("DE_PAIRENERGY",30*eV); - MPT->AddConstProperty("DE_ABSLENGTH",10*pc); - MPT->AddConstProperty("DE_DRIFTSPEED",3.475*cm/microsecond); - MPT->AddConstProperty("DE_TRANSVERSALSPREAD",7e-5*mm2/ns); - MPT->AddConstProperty("DE_LONGITUDINALSPREAD",7e-5*mm2/ns); + G4MaterialPropertiesTable* MPT = new G4MaterialPropertiesTable(); + MPT->AddConstProperty("DE_PAIRENERGY", 30 * eV); + MPT->AddConstProperty("DE_ABSLENGTH", 10 * pc); + MPT->AddConstProperty("DE_DRIFTSPEED", 3.475 * cm / microsecond); + MPT->AddConstProperty("DE_TRANSVERSALSPREAD", 7e-5 * mm2 / ns); + MPT->AddConstProperty("DE_LONGITUDINALSPREAD", 7e-5 * mm2 / ns); /* MPT->AddConstProperty("DE_TRANSVERSALSPREAD",0*mm2/ns); */ /* MPT->AddConstProperty("DE_LONGITUDINALSPREAD",0*mm2/ns); */ TPCMaterial->SetMaterialPropertiesTable(MPT); - G4ThreeVector Det_pos = m_POS[i] ; + G4ThreeVector Det_pos = m_POS[i]; - double MinosX = Det_pos.x(); - double MinosY= Det_pos.y(); - double MinosZ = Det_pos.z() + m_TargetLength[i]/2. ; + double MinosX = Det_pos.x(); + double MinosY = Det_pos.y(); + double MinosZ = Det_pos.z() + m_TargetLength[i] / 2.; - new G4PVPlacement(0,//its name - G4ThreeVector(0,0,+ChamberLength/2 ), - /* G4ThreeVector(wX,wY, wZ + ChamberLength - m_TargetLength[i]-WindowThickness*2. - 5*mm ), // Z positioning putting TPC beginn and Target beginning w/ difference of 5mm */ - BuildTPC(), //its logical volume - "TPC", //its name - world, //its mother volume - false, //no boolean operation - 0); //copy number + new G4PVPlacement(0, // its name + G4ThreeVector(0, 0, +ChamberLength / 2), + /* G4ThreeVector(wX,wY, wZ + ChamberLength - m_TargetLength[i]-WindowThickness*2. - 5*mm ), // Z + positioning putting TPC beginn and Target beginning w/ difference of 5mm */ + BuildTPC(), // its logical volume + "TPC", // its name + world, // its mother volume + false, // no boolean operation + 0); // copy number //////// ELECTRIC FIELD - G4ElectricField* field = new G4UniformElectricField(G4ThreeVector(0.0,0.0,200*volt/cm)); + G4ElectricField* field = new G4UniformElectricField(G4ThreeVector(0.0, 0.0, 200 * volt / cm)); // Create an equation of motion for this field - G4EqMagElectricField* Equation = new G4EqMagElectricField(field); - G4MagIntegratorStepper* Stepper = new G4ClassicalRK4( Equation, 8 ); - // Get the global field manager - G4FieldManager* FieldManager= new G4FieldManager(); - // Set this field to the global field manager - FieldManager->SetDetectorField(field ); - BuildTPC()->SetFieldManager(FieldManager,true); - - G4MagInt_Driver* IntgrDriver = new G4MagInt_Driver(0.1*mm, - Stepper, - Stepper->GetNumberOfVariables() ); + G4EqMagElectricField* Equation = new G4EqMagElectricField(field); + G4MagIntegratorStepper* Stepper = new G4ClassicalRK4(Equation, 8); + // Get the global field manager + G4FieldManager* FieldManager = new G4FieldManager(); + // Set this field to the global field manager + FieldManager->SetDetectorField(field); + BuildTPC()->SetFieldManager(FieldManager, true); + + G4MagInt_Driver* IntgrDriver = new G4MagInt_Driver(0.1 * mm, Stepper, Stepper->GetNumberOfVariables()); G4ChordFinder* ChordFinder = new G4ChordFinder(IntgrDriver); - FieldManager->SetChordFinder( ChordFinder ); + FieldManager->SetChordFinder(ChordFinder); - G4Material* Cu - = MaterialManager::getInstance()->GetMaterialFromLibrary("Cu"); + G4Material* Cu = MaterialManager::getInstance()->GetMaterialFromLibrary("Cu"); - ///////// CONSTRUCT PADS using parametrized volumes or replica (uncomment the correct section) + ///////// CONSTRUCT PADS using parametrized volumes or replica (uncomment the correct section) //// Using REPLICA // Construct Pads ring by ring - for (int RingNbr = 0; RingNbr < 18; RingNbr++){ + for (int RingNbr = 0; RingNbr < 18; RingNbr++) { - int PadsPerRing[18]={144,152,156,164,172,176,184,192,196,204,212,216,224,228,236,244,248,256}; + int PadsPerRing[18] = {144, 152, 156, 164, 172, 176, 184, 192, 196, 204, 212, 216, 224, 228, 236, 244, 248, 256}; /* G4double InnerRadius = (45.2+RingNbr*2.1+0.02)*mm;// 0.02 mm between each ring */ - G4double InnerRadius = (45.75+RingNbr*2.1)*mm; - G4double OuterRadius = (47.75+RingNbr*2.1)*mm; - - //Volume where are placed replica pads - G4VSolid* AnodeRing = new G4Tubs("ring",InnerRadius,OuterRadius, - 0.01*mm,0.,360*deg); - G4LogicalVolume * AnodeRing_log = new G4LogicalVolume(AnodeRing, - /* mix, "ringL", 0, 0, 0); */ - TPCMaterial, "ringL", 0, 0, 0); - - {G4VisAttributes* atb= new G4VisAttributes(G4Colour(0.8, 0.4, 0.,0.4)); - AnodeRing_log->SetVisAttributes(atb);} + G4double InnerRadius = (45.75 + RingNbr * 2.1) * mm; + G4double OuterRadius = (47.75 + RingNbr * 2.1) * mm; + + // Volume where are placed replica pads + G4VSolid* AnodeRing = new G4Tubs("ring", InnerRadius, OuterRadius, 0.01 * mm, 0., 360 * deg); + G4LogicalVolume* AnodeRing_log = new G4LogicalVolume(AnodeRing, + /* mix, "ringL", 0, 0, 0); */ + TPCMaterial, "ringL", 0, 0, 0); + + { + G4VisAttributes* atb = new G4VisAttributes(G4Colour(0.8, 0.4, 0., 0.4)); + AnodeRing_log->SetVisAttributes(atb); + } - new G4PVPlacement(0,G4ThreeVector(0,0,-ChamberLength/2+0.01*mm), - AnodeRing_log,"ring", logicTPC, false, RingNbr); + new G4PVPlacement(0, G4ThreeVector(0, 0, -ChamberLength / 2 + 0.01 * mm), AnodeRing_log, "ring", logicTPC, false, + RingNbr); - G4double Pad_dPhi = (360./(PadsPerRing[RingNbr]+1))*deg; // longitudinal component of Pad - G4double Pad_shift = (360./PadsPerRing[RingNbr])*deg; // dPhi between each Pads + G4double Pad_dPhi = (360. / (PadsPerRing[RingNbr] + 1)) * deg; // longitudinal component of Pad + G4double Pad_shift = (360. / PadsPerRing[RingNbr]) * deg; // dPhi between each Pads - G4VSolid* Pad = new G4Tubs("div_ring", InnerRadius, OuterRadius, - 0.01*mm,0, Pad_dPhi); + G4VSolid* Pad = new G4Tubs("div_ring", InnerRadius, OuterRadius, 0.01 * mm, 0, Pad_dPhi); - G4LogicalVolume* Pad_log = new G4LogicalVolume(Pad, - Cu,"div_ringL",0,0,0); + G4LogicalVolume* Pad_log = new G4LogicalVolume(Pad, Cu, "div_ringL", 0, 0, 0); - {G4VisAttributes* atb= new G4VisAttributes(G4Colour(0.8, 0.4, 0.,0.4)); - Pad_log->SetVisAttributes(atb);} + { + G4VisAttributes* atb = new G4VisAttributes(G4Colour(0.8, 0.4, 0., 0.4)); + Pad_log->SetVisAttributes(atb); + } Pad_log->SetSensitiveDetector(m_MinosPadScorer); - new G4PVReplica("div_ring_phys", Pad_log, - AnodeRing_log, kPhi, PadsPerRing[RingNbr],Pad_shift ,0); + new G4PVReplica("div_ring_phys", Pad_log, AnodeRing_log, kPhi, PadsPerRing[RingNbr], Pad_shift, 0); } ////////////////////////////////////// - new G4PVPlacement(0, //its name - G4ThreeVector(0,0,0), //at (0,0,0) - BuildInnerRohacell(), //its logical volume - "InnerRohacell", //its name - logicTPC, //its mother volume - false, //no boolean operation - 0); //copy number - - new G4PVPlacement(0, //its name - G4ThreeVector(0,0,0), //at (0,0,0) - BuildOuterRohacell(), //its logical volume - "OuterRohacell", //its name - logicTPC, //its mother volume - /* logicTPC, //its mother volume */ - false, //no boolean operation - 0); //copy number - - new G4PVPlacement(0, G4ThreeVector(0,0,0), //at (0,0,0) - BuildKapton(), //its logical volume - "InnerKapton", //its name - logicTPC, //its mother volume - false, //no boolean operation - 0); //copy number - - new G4PVPlacement(0, //its name - G4ThreeVector(0,0,0), //at (0,0,0) - BuildOuterKapton(), //its logical volume - "OuterKapton", //its name - logicTPC, //its mother volume - false, //no boolean operation - 0); //copy number - - if(TPCOnly!=1){ - new G4PVPlacement(0, //its name - G4ThreeVector(MinosX,MinosY,MinosZ+m_TargetZOffset[0]), //at (0,0,TargetZOffset) - BuildWindow0(), //its logical volume - "WindowTube", //its name - world, //its mother volume - false, //no boolean operation - 0); - - new G4PVPlacement(0,//no rotation - G4ThreeVector(0,0,0), //at (0,0,0) - BuildTarget(), //its logical volume - "Target", //its name - logicWindow0, //its mother volume - false, //no boolean operation - 0); //copy number - - if(!m_ReactionRegion){ - m_ReactionRegion= new G4Region("NPSimulationProcess"); - m_ReactionRegion -> AddRootLogicalVolume(logicTarget); - m_ReactionRegion->SetUserLimits(new G4UserLimits(1.2*mm)); //??? + new G4PVPlacement(0, // its name + G4ThreeVector(0, 0, 0), // at (0,0,0) + BuildInnerRohacell(), // its logical volume + "InnerRohacell", // its name + logicTPC, // its mother volume + false, // no boolean operation + 0); // copy number + + new G4PVPlacement(0, // its name + G4ThreeVector(0, 0, 0), // at (0,0,0) + BuildOuterRohacell(), // its logical volume + "OuterRohacell", // its name + logicTPC, // its mother volume + /* logicTPC, //its mother volume */ + false, // no boolean operation + 0); // copy number + + new G4PVPlacement(0, G4ThreeVector(0, 0, 0), // at (0,0,0) + BuildKapton(), // its logical volume + "InnerKapton", // its name + logicTPC, // its mother volume + false, // no boolean operation + 0); // copy number + + new G4PVPlacement(0, // its name + G4ThreeVector(0, 0, 0), // at (0,0,0) + BuildOuterKapton(), // its logical volume + "OuterKapton", // its name + logicTPC, // its mother volume + false, // no boolean operation + 0); // copy number + + if (TPCOnly != 1) { + new G4PVPlacement(0, // its name + G4ThreeVector(MinosX, MinosY, MinosZ + m_TargetZOffset[0]), // at (0,0,TargetZOffset) + BuildWindow0(), // its logical volume + "WindowTube", // its name + world, // its mother volume + false, // no boolean operation + 0); + + new G4PVPlacement(0, // no rotation + G4ThreeVector(0, 0, 0), // at (0,0,0) + BuildTarget(), // its logical volume + "Target", // its name + logicWindow0, // its mother volume + false, // no boolean operation + 0); // copy number + + if (!m_ReactionRegion) { + m_ReactionRegion = new G4Region("NPSimulationProcess"); + m_ReactionRegion->AddRootLogicalVolume(logicTarget); + m_ReactionRegion->SetUserLimits(new G4UserLimits(1.2 * mm)); //??? } G4FastSimulationManager* mng = m_ReactionRegion->GetFastSimulationManager(); unsigned int size = m_ReactionModel.size(); - for(unsigned int o = 0 ; o < size ; o++){ + for (unsigned int o = 0; o < size; o++) { mng->RemoveFastSimulationModel(m_ReactionModel[o]); } m_ReactionModel.clear(); G4VFastSimulationModel* fsm; - fsm = new NPS::BeamReaction("BeamReaction",m_ReactionRegion); - ((NPS::BeamReaction*) fsm)->SetStepSize(1.2*mm); + fsm = new NPS::BeamReaction("BeamReaction", m_ReactionRegion); + ((NPS::BeamReaction*)fsm)->SetStepSize(1.2 * mm); m_ReactionModel.push_back(fsm); - fsm = new NPS::Decay("Decay",m_ReactionRegion); + fsm = new NPS::Decay("Decay", m_ReactionRegion); m_ReactionModel.push_back(fsm); } } // Visualization attributes - world->SetVisAttributes (G4VisAttributes::Invisible); - + world->SetVisAttributes(G4VisAttributes::GetInvisible()); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void Minos::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("Minos")){ - pTree->Branch("Minos", "TMinosData", &m_Event) ; +void Minos::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("Minos")) { + pTree->Branch("Minos", "TMinosData", &m_Event); } - pTree->SetBranchAddress("Minos", &m_Event) ; + pTree->SetBranchAddress("Minos", &m_Event); } //....oooOO0OOooo.; // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAction -void Minos::ReadSensitive(const G4Event* ){ +void Minos::ReadSensitive(const G4Event*) { m_Event->Clear(); /////////// // DriftElectron scorer - CylinderTPCScorers::PS_TPCAnode* Scorer2= (CylinderTPCScorers::PS_TPCAnode*) m_MinosPadScorer->GetPrimitive(0); + CylinderTPCScorers::PS_TPCAnode* Scorer2 = (CylinderTPCScorers::PS_TPCAnode*)m_MinosPadScorer->GetPrimitive(0); unsigned int size2 = Scorer2->GetMult(); - for(unsigned int i = 0 ; i < size2 ; i++){ - int Pad = FindPadID(Scorer2->GetPad(i),Scorer2->GetX(i),Scorer2->GetY(i)); - SimulateGainAndDigitizer(Scorer2->GetT(i), Scorer2->GetQ(i),T,Q); + for (unsigned int i = 0; i < size2; i++) { + int Pad = FindPadID(Scorer2->GetPad(i), Scorer2->GetX(i), Scorer2->GetY(i)); + SimulateGainAndDigitizer(Scorer2->GetT(i), Scorer2->GetQ(i), T, Q); - m_Event->SetPad(Pad, Scorer2->GetQ(i)->size(),&T,&Q); + m_Event->SetPad(Pad, Scorer2->GetQ(i)->size(), &T, &Q); } - } -void Minos::SimulateGainAndDigitizer(vector<double>* rawT, vector<double>* rawQ,vector<int>& T, vector<int>& Q){ +void Minos::SimulateGainAndDigitizer(vector<double>* rawT, vector<double>* rawQ, vector<int>& T, vector<int>& Q) { T.clear(); Q.clear(); Raw_Signal->Reset(); Elec_Signal->Reset(); - // Add white noise; + // Add white noise; /* for( int bin = 0 ; bin < Elec_Signal->GetNbinsX() ; bin++) */ - /* Elec_Signal->SetBinContent(bin,20+(10-gRandom->Uniform(20)*20)); */ + /* Elec_Signal->SetBinContent(bin,20+(10-gRandom->Uniform(20)*20)); */ // Reallocate electrons from each pack /* if (rawQ.sze()==1) { */ @@ -574,106 +565,108 @@ void Minos::SimulateGainAndDigitizer(vector<double>* rawT, vector<double>* rawQ, /* } */ /* else{ */ /* for ( int j = 1; j < rawQ.size()-1; j++){ */ - /* time = (rawT[j+1]-rawT[j-1])/rawQ[j]; */ + /* time = (rawT[j+1]-rawT[j-1])/rawQ[j]; */ /* for ( int k = -rawQ[0]/2; k < (rawQ[0]/2); k++){ */ /* Raw_Signal->Fill((rawT[j]+k*time)/30.); */ /* } */ /* } */ /* } */ - for ( unsigned int j = 0; j < rawQ->size(); j++){ - for ( int i = 0 ; i < (*rawQ)[j]; i++ ){ - Raw_Signal->Fill(((*rawT)[j])/m_TimeBin); + for (unsigned int j = 0; j < rawQ->size(); j++) { + for (int i = 0; i < (*rawQ)[j]; i++) { + Raw_Signal->Fill(((*rawT)[j]) / m_TimeBin); } } // Application of the electronic reponse function - for ( int x=0; x < Raw_Signal->GetNbinsX(); x++){ - if(Raw_Signal->GetBinContent(x) > 0.5){ + for (int x = 0; x < Raw_Signal->GetNbinsX(); x++) { + if (Raw_Signal->GetBinContent(x) > 0.5) { start = Raw_Signal->GetBinCenter(x); - end = Raw_Signal->GetBinCenter(x)+512; + end = Raw_Signal->GetBinCenter(x) + 512; // DriftTime = Raw_Signal->GetBinCenter(x); fa1->SetRange(start, end); - fa1->SetParameter(0,1500); - fa1->SetParameter(1,start); - fa1->SetParameter(2,m_ShapingTime/(log(2)*m_TimeBin)); - fa1->SetParameter(3,0); - - for (int p=0; p < Raw_Signal->GetBinContent(x)*1500; p++) - Elec_Signal->Fill(fa1->GetRandom(start,end)); - } + fa1->SetParameter(0, 1500); + fa1->SetParameter(1, start); + fa1->SetParameter(2, m_ShapingTime / (log(2) * m_TimeBin)); + fa1->SetParameter(3, 0); + + for (int p = 0; p < Raw_Signal->GetBinContent(x) * 1500; p++) + Elec_Signal->Fill(fa1->GetRandom(start, end)); + } } - for ( int bin=0; bin < Elec_Signal->GetNbinsX(); bin++){ - if(Elec_Signal->GetBinContent(bin)){ - Q.push_back(Elec_Signal->GetBinContent(bin)+m_Baseline); - T.push_back(Elec_Signal->GetBinCenter(bin)); - } - } + for (int bin = 0; bin < Elec_Signal->GetNbinsX(); bin++) { + if (Elec_Signal->GetBinContent(bin)) { + Q.push_back(Elec_Signal->GetBinContent(bin) + m_Baseline); + T.push_back(Elec_Signal->GetBinCenter(bin)); + } + } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -//////////////////////////////////////////////////////////////// -void Minos::InitializeScorers() { +//////////////////////////////////////////////////////////////// +void Minos::InitializeScorers() { // This check is necessary in case the geometry is reloaded bool already_exist = false; bool already_exist2 = false; bool already_exist3 = false; - m_MinosPadScorer = CheckScorer("MinosPadScorer",already_exist3) ; + m_MinosPadScorer = CheckScorer("MinosPadScorer", already_exist3); - if(already_exist && already_exist2 && already_exist3 ) - return ; + if (already_exist && already_exist2 && already_exist3) + return; // Otherwise the scorer is initialised - vector<int> level; level.push_back(0); + vector<int> level; + level.push_back(0); - G4VPrimitiveScorer* DriftElectronMinosTPCScorer= new CylinderTPCScorers::PS_TPCAnode("DriftElectronsScore",level, 0) ; + G4VPrimitiveScorer* DriftElectronMinosTPCScorer = + new CylinderTPCScorers::PS_TPCAnode("DriftElectronsScore", level, 0); - //and register it to the multifunctionnal detector + // and register it to the multifunctionnal detector m_MinosPadScorer->RegisterPrimitive(DriftElectronMinosTPCScorer); - G4VPrimitiveScorer* PadScorer= new CylinderTPCScorers::PS_TPCAnode("MinosTPCAnode",level, 0); + G4VPrimitiveScorer* PadScorer = new CylinderTPCScorers::PS_TPCAnode("MinosTPCAnode", level, 0); m_MinosPadScorer->RegisterPrimitive(PadScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_MinosPadScorer) ; + G4SDManager::GetSDMpointer()->AddNewDetector(m_MinosPadScorer); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Minos::ReadXML(NPL::XmlParser& xml){ - std::vector<NPL::XML::block*> b = xml.GetAllBlocksWithName("MINOS"); +void Minos::ReadXML(NPL::XmlParser& xml) { + std::vector<NPL::XML::block*> b = xml.GetAllBlocksWithName("MINOS"); unsigned int size = b.size(); - for(unsigned int i = 0 ; i < size ; i++){ - unsigned short ID = b[i]->AsInt("ID"); - m_XY[ID] = std::make_pair(b[i]->AsDouble("X"),b[i]->AsDouble("Y")); + for (unsigned int i = 0; i < size; i++) { + unsigned short ID = b[i]->AsInt("ID"); + m_XY[ID] = std::make_pair(b[i]->AsDouble("X"), b[i]->AsDouble("Y")); } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -unsigned int Minos::FindPadID(unsigned int G4ID, double X,double Y){ - // if no XML is provided, do nothing - if(m_XY.size()==0) - return G4ID; - // The pad is already identified - if(m_ID.find(G4ID)!=m_ID.end()) - return m_ID[G4ID]; - - // look for the closest pad - else{ - double d = 1e6; - double id=0; - for(auto it = m_XY.begin();it!=m_XY.end();it++){ - double dd = sqrt((it->second.first-X)*(it->second.first-X)+(it->second.second-Y)*(it->second.second-Y)); - if(dd<d){ - d=dd; - id=it->first; - } - } - //cout << G4ID << " " << id << endl; - m_ID[G4ID]=id; - return id; - } - +unsigned int Minos::FindPadID(unsigned int G4ID, double X, double Y) { + // if no XML is provided, do nothing + if (m_XY.size() == 0) + return G4ID; + // The pad is already identified + if (m_ID.find(G4ID) != m_ID.end()) + return m_ID[G4ID]; + + // look for the closest pad + else { + double d = 1e6; + double id = 0; + for (auto it = m_XY.begin(); it != m_XY.end(); it++) { + double dd = + sqrt((it->second.first - X) * (it->second.first - X) + (it->second.second - Y) * (it->second.second - Y)); + if (dd < d) { + d = dd; + id = it->first; + } + } + // cout << G4ID << " " << id << endl; + m_ID[G4ID] = id; + return id; + } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -682,22 +675,20 @@ unsigned int Minos::FindPadID(unsigned int G4ID, double X,double Y){ //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* Minos::Construct(){ - return (NPS::VDetector*) new Minos(); -} +NPS::VDetector* Minos::Construct() { return (NPS::VDetector*)new Minos(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_Minos{ - public: - proxy_nps_Minos(){ - NPS::DetectorFactory::getInstance()->AddToken("Minos","Minos"); - NPS::DetectorFactory::getInstance()->AddDetector("Minos",Minos::Construct); - } - }; +extern "C" { +class proxy_nps_Minos { + public: + proxy_nps_Minos() { + NPS::DetectorFactory::getInstance()->AddToken("Minos", "Minos"); + NPS::DetectorFactory::getInstance()->AddDetector("Minos", Minos::Construct); + } +}; - proxy_nps_Minos p_nps_Minos; +proxy_nps_Minos p_nps_Minos; } diff --git a/NPSimulation/Detectors/Mugast/Mugast.cc b/NPSimulation/Detectors/Mugast/Mugast.cc index 6efd81e8b..5ed8c94e2 100644 --- a/NPSimulation/Detectors/Mugast/Mugast.cc +++ b/NPSimulation/Detectors/Mugast/Mugast.cc @@ -20,38 +20,38 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> -//G4 Geometry object -#include "G4Tubs.hh" +#include <sstream> +// G4 Geometry object #include "G4Box.hh" #include "G4Trap.hh" +#include "G4Tubs.hh" -//G4 sensitive -#include "G4SDManager.hh" +// G4 sensitive #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" -//G4 various object -#include "G4Material.hh" -#include "G4Transform3D.hh" -#include "G4PVPlacement.hh" -#include "G4VisAttributes.hh" +// G4 various object #include "G4Colour.hh" -#include "G4TwoVector.hh" #include "G4ExtrudedSolid.hh" +#include "G4Material.hh" +#include "G4PVPlacement.hh" #include "G4SubtractionSolid.hh" +#include "G4Transform3D.hh" +#include "G4TwoVector.hh" +#include "G4VisAttributes.hh" // NPTool header -#include "Mugast.hh" -#include "MugastReverseMap.h" #include "DSSDScorers.hh" #include "InteractionScorers.hh" -#include "RootOutput.h" #include "MaterialManager.hh" -#include "NPSDetectorFactory.hh" +#include "Mugast.hh" +#include "MugastReverseMap.h" +#include "NPCore.h" #include "NPOptionManager.h" +#include "NPSDetectorFactory.hh" #include "NPSHitsMap.hh" -#include "NPCore.h" +#include "RootOutput.h" // CLHEP header #include "CLHEP/Random/RandGauss.h" @@ -59,182 +59,164 @@ using namespace std; using namespace CLHEP; - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -namespace Mugast_NS{ +namespace Mugast_NS { // Resolution - const G4double SigmaTime = 0.212765957 ;// = 500ps - const G4double SigmaEnergy = 0.019 ;// -// const G4double TimeOffset = 500 ;// 500 ns stop + const G4double SigmaTime = 0.212765957; // = 500ps + const G4double SigmaEnergy = 0.019; // + // const G4double TimeOffset = 500 ;// 500 ns stop // Threshold const G4double EnergyThreshold = 1 * MeV; // Geometry - //const G4double AluStripThickness = 0.4*micrometer ; - const G4double SiliconThickness = 300*micrometer ; + // const G4double AluStripThickness = 0.4*micrometer ; + const G4double SiliconThickness = 300 * micrometer; // Square // const G4double SquareBase = 88*mm; // const G4double SquareHeight = 87*mm; - const G4double SquareBase = 91.716*mm; - const G4double SquareHeight = 94.916*mm; + const G4double SquareBase = 91.716 * mm; + const G4double SquareHeight = 94.916 * mm; // const G4double SquareHeight = 194.916*mm; - const G4double SquareLength = 1*cm; - // Trapezoid - const G4double TrapezoidBaseLarge = 91.48*mm; - const G4double TrapezoidBaseSmall = 26*mm; - const G4double TrapezoidHeight = 104.688*mm; - const G4double TrapezoidLength = 1*cm; - //Annular - const G4int NbrRingStrips = 16; - const G4int NbrSectorStrips = 16; - const G4int NbQuadrant = 4; - const G4double WaferOutterRadius = 50*mm; - const G4double WaferInnerRadius = 23*mm; - const G4double WaferThickness = 500*micrometer; - const G4double WaferRCut = 45.5*mm; - const G4double ActiveWaferOutterRadius = 48*mm; - const G4double ActiveWaferInnerRadius = 24*mm; - const G4double ActiveWaferRCut = 44.5*mm; - const G4double PCBPointsX[8]={-40,40,60,60,40,-40,-60,-60}; - const G4double PCBPointsY[8]={60,60,40,-40,-60,-60,-40,40}; - const G4double PCBThickness=3.2*mm; - //const G4double PCBInnerRadius=0*mm; - - - -} + const G4double SquareLength = 1 * cm; + // Trapezoid + const G4double TrapezoidBaseLarge = 91.48 * mm; + const G4double TrapezoidBaseSmall = 26 * mm; + const G4double TrapezoidHeight = 104.688 * mm; + const G4double TrapezoidLength = 1 * cm; + // Annular + const G4int NbrRingStrips = 16; + const G4int NbrSectorStrips = 16; + const G4int NbQuadrant = 4; + const G4double WaferOutterRadius = 50 * mm; + const G4double WaferInnerRadius = 23 * mm; + const G4double WaferThickness = 500 * micrometer; + const G4double WaferRCut = 45.5 * mm; + const G4double ActiveWaferOutterRadius = 48 * mm; + const G4double ActiveWaferInnerRadius = 24 * mm; + const G4double ActiveWaferRCut = 44.5 * mm; + const G4double PCBPointsX[8] = {-40, 40, 60, 60, 40, -40, -60, -60}; + const G4double PCBPointsY[8] = {60, 60, 40, -40, -60, -60, -40, 40}; + const G4double PCBThickness = 3.2 * mm; + // const G4double PCBInnerRadius=0*mm; + +} // namespace Mugast_NS using namespace Mugast_NS; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Mugast Specific Method -Mugast::Mugast(){ - m_Event = new TMugastData() ; - m_SquareScorer= 0; - m_TrapezoidScorer= 0; - m_AnnularScorer= 0; +Mugast::Mugast() { + m_Event = new TMugastData(); + m_SquareScorer = 0; + m_TrapezoidScorer = 0; + m_AnnularScorer = 0; m_SquareDetector = 0; m_TrapezoidDetector = 0; m_AnnularDetector = 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_VisSquare = new G4VisAttributes(G4Colour(0, 1, 0, 0.5)); + m_VisCylinder = new G4VisAttributes(G4Colour(0, 0, 1, 0.5)); } -Mugast::~Mugast(){ -} +Mugast::~Mugast() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Mugast::AddDetector(int DetectorNumber,string Shape,G4ThreeVector PX1_Y1 ,G4ThreeVector PX1_Y128 ,G4ThreeVector PX128_Y1,G4ThreeVector PX128_Y128){ - m_X1_Y1.push_back(PX1_Y1); // Top Left Corner Position Vector - m_X1_Y128.push_back(PX1_Y128); // Bottom Left Corner Position Vector - m_X128_Y1.push_back(PX128_Y1); // Bottom Right Corner Position Vector +void Mugast::AddDetector(int DetectorNumber, string Shape, G4ThreeVector PX1_Y1, G4ThreeVector PX1_Y128, + G4ThreeVector PX128_Y1, G4ThreeVector PX128_Y128) { + m_X1_Y1.push_back(PX1_Y1); // Top Left Corner Position Vector + m_X1_Y128.push_back(PX1_Y128); // Bottom Left Corner Position Vector + m_X128_Y1.push_back(PX128_Y1); // Bottom Right Corner Position Vector m_X128_Y128.push_back(PX128_Y128); // Center Corner Position Vector m_DetectorNumber.push_back(DetectorNumber); m_Shape.push_back(Shape); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Mugast::BuildSquareDetector(){ - if(!m_SquareDetector){ +G4LogicalVolume* Mugast::BuildSquareDetector() { + if (!m_SquareDetector) { G4String Name = "MugastSquare"; - G4Box* solidSquare = new G4Box(Name, 0.5*SquareBase, 0.5*SquareHeight, 0.5*SquareLength); - G4LogicalVolume* logicSquare = new G4LogicalVolume(solidSquare, - MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"), - Name, 0, 0, 0); + G4Box* solidSquare = new G4Box(Name, 0.5 * SquareBase, 0.5 * SquareHeight, 0.5 * SquareLength); + G4LogicalVolume* logicSquare = new G4LogicalVolume( + solidSquare, MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"), Name, 0, 0, 0); - G4VisAttributes* SquareVisAtt = new G4VisAttributes(G4Colour(0.90, 0.90, 0.90)); - SquareVisAtt->SetForceWireframe(true); + G4VisAttributes* SquareVisAtt = new G4VisAttributes(G4Colour(0.90, 0.90, 0.90)); + SquareVisAtt->SetForceWireframe(true); logicSquare->SetVisAttributes(SquareVisAtt); // Silicon detector itself - G4ThreeVector positionFirstStage = G4ThreeVector(0, 0, 0); + G4ThreeVector positionFirstStage = G4ThreeVector(0, 0, 0); - G4Box* solidFirstStage = new G4Box("solidFirstStage", 0.5*SquareBase, 0.5*SquareHeight, 0.5*SiliconThickness); - G4LogicalVolume* logicFirstStage = new G4LogicalVolume(solidFirstStage, - MaterialManager::getInstance()->GetMaterialFromLibrary("Si"), - "logicFirstStage", - 0, 0, 0); + G4Box* solidFirstStage = new G4Box("solidFirstStage", 0.5 * SquareBase, 0.5 * SquareHeight, 0.5 * SiliconThickness); + G4LogicalVolume* logicFirstStage = new G4LogicalVolume( + solidFirstStage, MaterialManager::getInstance()->GetMaterialFromLibrary("Si"), "logicFirstStage", 0, 0, 0); new G4PVPlacement(0, positionFirstStage, logicFirstStage, Name + "_FirstStage", logicSquare, false, 0); m_SquareDetector = logicSquare; // Set First Stage sensible logicFirstStage->SetSensitiveDetector(m_SquareScorer); - ///Visualisation of FirstStage Strip - G4VisAttributes* FirstStageVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)); + /// Visualisation of FirstStage Strip + G4VisAttributes* FirstStageVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)); logicFirstStage->SetVisAttributes(FirstStageVisAtt); } return m_SquareDetector; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Mugast::BuildTrapezoidDetector(){ - if(!m_TrapezoidDetector){ +G4LogicalVolume* Mugast::BuildTrapezoidDetector() { + if (!m_TrapezoidDetector) { G4String Name = "MugastTrapezoid"; // Definition of the volume containing the sensitive detector - G4Trap* solidTrapezoid = new G4Trap(Name, - TrapezoidLength*0.5, 0*deg, 0*deg, - TrapezoidHeight*0.5, TrapezoidBaseSmall*0.5,TrapezoidBaseLarge*0.5, 0*deg, - TrapezoidHeight*0.5, TrapezoidBaseSmall*0.5,TrapezoidBaseLarge*0.5, 0*deg); - G4LogicalVolume* logicTrapezoid = new G4LogicalVolume(solidTrapezoid, - MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"), - Name, - 0, 0, 0); + G4Trap* solidTrapezoid = + new G4Trap(Name, TrapezoidLength * 0.5, 0 * deg, 0 * deg, TrapezoidHeight * 0.5, TrapezoidBaseSmall * 0.5, + TrapezoidBaseLarge * 0.5, 0 * deg, TrapezoidHeight * 0.5, TrapezoidBaseSmall * 0.5, + TrapezoidBaseLarge * 0.5, 0 * deg); + G4LogicalVolume* logicTrapezoid = new G4LogicalVolume( + solidTrapezoid, MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"), Name, 0, 0, 0); G4VisAttributes* TrapezoideVisAtt = new G4VisAttributes(G4Colour(0.90, 0.90, 0.90)); - TrapezoideVisAtt->SetForceWireframe(true); + TrapezoideVisAtt->SetForceWireframe(true); logicTrapezoid->SetVisAttributes(TrapezoideVisAtt); // Silicon detector itself - G4ThreeVector positionFirstStage = G4ThreeVector(0, 0, 0); - - G4Trap* solidFirstStage = new G4Trap("solidFirstStage", - 0.5*SiliconThickness, 0*deg, 0*deg, - TrapezoidHeight*0.5, TrapezoidBaseSmall*0.5,TrapezoidBaseLarge*0.5, 0*deg, - TrapezoidHeight*0.5, TrapezoidBaseSmall*0.5,TrapezoidBaseLarge*0.5, 0*deg); - G4LogicalVolume* logicFirstStage = new G4LogicalVolume(solidFirstStage, - MaterialManager::getInstance()->GetMaterialFromLibrary("Si"), - "logicFirstStage", - 0, 0, 0); - - new G4PVPlacement(0, - positionFirstStage, - logicFirstStage, - Name + "_FirstStage", - logicTrapezoid, - false, - 0); + G4ThreeVector positionFirstStage = G4ThreeVector(0, 0, 0); + + G4Trap* solidFirstStage = + new G4Trap("solidFirstStage", 0.5 * SiliconThickness, 0 * deg, 0 * deg, TrapezoidHeight * 0.5, + TrapezoidBaseSmall * 0.5, TrapezoidBaseLarge * 0.5, 0 * deg, TrapezoidHeight * 0.5, + TrapezoidBaseSmall * 0.5, TrapezoidBaseLarge * 0.5, 0 * deg); + G4LogicalVolume* logicFirstStage = new G4LogicalVolume( + solidFirstStage, MaterialManager::getInstance()->GetMaterialFromLibrary("Si"), "logicFirstStage", 0, 0, 0); + + new G4PVPlacement(0, positionFirstStage, logicFirstStage, Name + "_FirstStage", logicTrapezoid, false, 0); // Set First Stage sensible logicFirstStage->SetSensitiveDetector(m_TrapezoidScorer); - ///Visualisation of FirstStage Strip - G4VisAttributes* FirstStageVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)); + /// Visualisation of FirstStage Strip + G4VisAttributes* FirstStageVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)); logicFirstStage->SetVisAttributes(FirstStageVisAtt); - m_TrapezoidDetector=logicTrapezoid; + m_TrapezoidDetector = logicTrapezoid; } return m_TrapezoidDetector; } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Mugast::BuildAnnularDetector(){ +G4LogicalVolume* Mugast::BuildAnnularDetector() { - if(!m_AnnularDetector){ + if (!m_AnnularDetector) { G4Material* Silicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); - G4Material* Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); - G4Material* PCB = MaterialManager::getInstance()->GetMaterialFromLibrary("PCB"); + G4Material* Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); + G4Material* PCB = MaterialManager::getInstance()->GetMaterialFromLibrary("PCB"); //////////////////////////////////////////////////////////////// ////////////// Starting Volume Definition ////////////////////// //////////////////////////////////////////////////////////////// @@ -244,139 +226,93 @@ G4LogicalVolume* Mugast::BuildAnnularDetector(){ // Building the PCB // The PCB is a simple extruded volume from 8 reference points vector<G4TwoVector> polygon; - for(unsigned int i = 0 ; i < 8 ; i++){ - G4TwoVector Point(PCBPointsX[i],PCBPointsY[i]); + for (unsigned int i = 0; i < 8; i++) { + G4TwoVector Point(PCBPointsX[i], PCBPointsY[i]); polygon.push_back(Point); } // Master volume containing all the detector - G4ExtrudedSolid* solidAnnularS1 = new G4ExtrudedSolid(Name, - polygon, - PCBThickness*0.5, - G4TwoVector(0,0),1, - G4TwoVector(0,0),1); + G4ExtrudedSolid* solidAnnularS1 = + new G4ExtrudedSolid(Name, polygon, PCBThickness * 0.5, G4TwoVector(0, 0), 1, G4TwoVector(0, 0), 1); // Definition of the volume containing the sensitive detector - m_AnnularDetector= new G4LogicalVolume(solidAnnularS1, Vacuum, Name, 0, 0, 0); - m_AnnularDetector->SetVisAttributes(G4VisAttributes::Invisible); + m_AnnularDetector = new G4LogicalVolume(solidAnnularS1, Vacuum, Name, 0, 0, 0); + m_AnnularDetector->SetVisAttributes(G4VisAttributes::GetInvisible()); // PCB Base - G4ExtrudedSolid* solidPCBBase = new G4ExtrudedSolid("PCBBase", - polygon, - PCBThickness*0.5, - G4TwoVector(0,0),1, - G4TwoVector(0,0),1); + G4ExtrudedSolid* solidPCBBase = + new G4ExtrudedSolid("PCBBase", polygon, PCBThickness * 0.5, G4TwoVector(0, 0), 1, G4TwoVector(0, 0), 1); // Wafer Shape to be substracted to the PCB - G4Tubs* solidWaferShapeBase = new G4Tubs("WaferShape", - 0, - WaferOutterRadius, - PCBThickness, - 0*deg, - 360*deg); + G4Tubs* solidWaferShapeBase = new G4Tubs("WaferShape", 0, WaferOutterRadius, PCBThickness, 0 * deg, 360 * deg); // A no rotation matrix is always handy ;) - G4RotationMatrix* norotation = new G4RotationMatrix(); - // Rotation of the box that make the Si cut - G4RotationMatrix* cutrotation = new G4RotationMatrix(G4ThreeVector(0,0,1),45*deg); - G4ThreeVector cutposition1(80*mm+WaferRCut,0,0); cutposition1.setPhi(45*deg); - G4Transform3D transform1(*cutrotation,cutposition1); + G4RotationMatrix* norotation = new G4RotationMatrix(); + // Rotation of the box that make the Si cut + G4RotationMatrix* cutrotation = new G4RotationMatrix(G4ThreeVector(0, 0, 1), 45 * deg); + G4ThreeVector cutposition1(80 * mm + WaferRCut, 0, 0); + cutposition1.setPhi(45 * deg); + G4Transform3D transform1(*cutrotation, cutposition1); - G4Box* solidCutout = new G4Box("cuttout",80*mm,80*mm,80*mm); + G4Box* solidCutout = new G4Box("cuttout", 80 * mm, 80 * mm, 80 * mm); - G4SubtractionSolid* solidWaferShape1 = new G4SubtractionSolid("WaferShape1", - solidWaferShapeBase, - solidCutout, - transform1); - - - G4ThreeVector cutposition2(-80*mm-WaferRCut,0,0); cutposition2.setPhi(-135*deg); - G4Transform3D transform2(*cutrotation,cutposition2); - G4SubtractionSolid* solidWaferShape = new G4SubtractionSolid("WaferShape", - solidWaferShape1, - solidCutout, - transform2); + G4SubtractionSolid* solidWaferShape1 = + new G4SubtractionSolid("WaferShape1", solidWaferShapeBase, solidCutout, transform1); + G4ThreeVector cutposition2(-80 * mm - WaferRCut, 0, 0); + cutposition2.setPhi(-135 * deg); + G4Transform3D transform2(*cutrotation, cutposition2); + G4SubtractionSolid* solidWaferShape = + new G4SubtractionSolid("WaferShape", solidWaferShape1, solidCutout, transform2); // PCB final - G4SubtractionSolid* solidPCB = new G4SubtractionSolid("MugastAnnular_PCB1", - solidPCBBase, - solidWaferShape); + G4SubtractionSolid* solidPCB = new G4SubtractionSolid("MugastAnnular_PCB1", solidPCBBase, solidWaferShape); G4LogicalVolume* logicPCB = new G4LogicalVolume(solidPCB, PCB, "MugastAnnular_PCB", 0, 0, 0); - new G4PVPlacement(G4Transform3D(*norotation, G4ThreeVector()), - logicPCB, - "MugastAnnular_PCB", - m_AnnularDetector, - false, - 0); + new G4PVPlacement(G4Transform3D(*norotation, G4ThreeVector()), logicPCB, "MugastAnnular_PCB", m_AnnularDetector, + false, 0); - G4VisAttributes* PCBVisAtt = new G4VisAttributes(G4Colour(0.2, 0.5, 0.2)) ; + G4VisAttributes* PCBVisAtt = new G4VisAttributes(G4Colour(0.2, 0.5, 0.2)); logicPCB->SetVisAttributes(PCBVisAtt); - // Wafer itself - G4Tubs* solidWaferBase = new G4Tubs("Wafer", - WaferInnerRadius, - WaferOutterRadius, - 0.5*WaferThickness, - 0*deg, - 360*deg); - - G4SubtractionSolid* solidWafer1 = new G4SubtractionSolid("Wafer1", - solidWaferBase, - solidCutout, - transform1); - - G4SubtractionSolid* solidWafer = new G4SubtractionSolid("Wafer", - solidWafer1, - solidCutout, - transform2); + G4Tubs* solidWaferBase = + new G4Tubs("Wafer", WaferInnerRadius, WaferOutterRadius, 0.5 * WaferThickness, 0 * deg, 360 * deg); + + G4SubtractionSolid* solidWafer1 = new G4SubtractionSolid("Wafer1", solidWaferBase, solidCutout, transform1); + + G4SubtractionSolid* solidWafer = new G4SubtractionSolid("Wafer", solidWafer1, solidCutout, transform2); G4LogicalVolume* logicWafer = new G4LogicalVolume(solidWafer, Silicon, "MugastAnnular_Wafer", 0, 0, 0); - new G4PVPlacement(G4Transform3D(*norotation, G4ThreeVector()), - logicWafer, - "MugastAnnular_Wafer", - m_AnnularDetector, - false, - 0); + new G4PVPlacement(G4Transform3D(*norotation, G4ThreeVector()), logicWafer, "MugastAnnular_Wafer", m_AnnularDetector, + false, 0); - G4VisAttributes* SiVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)) ; - logicWafer->SetVisAttributes(SiVisAtt); + G4VisAttributes* SiVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)); + logicWafer->SetVisAttributes(SiVisAtt); // Active Wafer - G4Tubs* solidActiveWaferBase = new G4Tubs("ActiveWafer", - ActiveWaferInnerRadius, - ActiveWaferOutterRadius, - 0.5*WaferThickness, - 0*deg, - 360*deg); - - - G4ThreeVector activecutposition1(80*mm+ActiveWaferRCut,0,0); activecutposition1.setPhi(45*deg); - G4Transform3D activetransform1(*cutrotation,activecutposition1); - - G4SubtractionSolid* solidActiveWafer1 = new G4SubtractionSolid("ActiveWafer1", - solidActiveWaferBase, - solidCutout, - activetransform1); - - G4ThreeVector activecutposition2(-80*mm-ActiveWaferRCut,0,0); activecutposition2.setPhi(-135*deg); - G4Transform3D activetransform2(*cutrotation,activecutposition2); - - G4SubtractionSolid* solidActiveWafer = new G4SubtractionSolid("ActiveWafer", - solidActiveWafer1, - solidCutout, - activetransform2); - - G4LogicalVolume* logicActiveWafer = new G4LogicalVolume(solidActiveWafer, Silicon, "MugastAnnular_ActiveWafer", 0, 0, 0); - new G4PVPlacement(G4Transform3D(*norotation, G4ThreeVector()), - logicActiveWafer, - "MugastAnnular_ActiveWafer", - logicWafer, - false, - 0); + G4Tubs* solidActiveWaferBase = new G4Tubs("ActiveWafer", ActiveWaferInnerRadius, ActiveWaferOutterRadius, + 0.5 * WaferThickness, 0 * deg, 360 * deg); + + G4ThreeVector activecutposition1(80 * mm + ActiveWaferRCut, 0, 0); + activecutposition1.setPhi(45 * deg); + G4Transform3D activetransform1(*cutrotation, activecutposition1); + + G4SubtractionSolid* solidActiveWafer1 = + new G4SubtractionSolid("ActiveWafer1", solidActiveWaferBase, solidCutout, activetransform1); + + G4ThreeVector activecutposition2(-80 * mm - ActiveWaferRCut, 0, 0); + activecutposition2.setPhi(-135 * deg); + G4Transform3D activetransform2(*cutrotation, activecutposition2); + + G4SubtractionSolid* solidActiveWafer = + new G4SubtractionSolid("ActiveWafer", solidActiveWafer1, solidCutout, activetransform2); + + G4LogicalVolume* logicActiveWafer = + new G4LogicalVolume(solidActiveWafer, Silicon, "MugastAnnular_ActiveWafer", 0, 0, 0); + new G4PVPlacement(G4Transform3D(*norotation, G4ThreeVector()), logicActiveWafer, "MugastAnnular_ActiveWafer", + logicWafer, false, 0); logicActiveWafer->SetVisAttributes(SiVisAtt); @@ -386,10 +322,6 @@ G4LogicalVolume* Mugast::BuildAnnularDetector(){ return m_AnnularDetector; } - - - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -403,8 +335,8 @@ void Mugast::ReadConfiguration(NPL::InputParser parser) { cout << "//// " << blocks.size() << " detector found" << endl; // Cartesian Case - vector<string> cart = {"DetectorNumber","X1_Y1", "X1_Y128", "X128_Y1", "X128_Y128"}; - vector<string> annular = {"DetectorNumber","Center"}; + vector<string> cart = {"DetectorNumber", "X1_Y1", "X1_Y128", "X128_Y1", "X128_Y128"}; + vector<string> annular = {"DetectorNumber", "Center"}; for (unsigned int i = 0; i < blocks.size(); i++) { @@ -413,30 +345,25 @@ void Mugast::ReadConfiguration(NPL::InputParser parser) { if (NPOptionManager::getInstance()->GetVerboseLevel()) cout << endl << "//// Mugast detector " << shape << endl; - if (blocks[i]->HasTokenList(cart)&& (shape=="Square"|| shape=="Trapezoid")) { + if (blocks[i]->HasTokenList(cart) && (shape == "Square" || shape == "Trapezoid")) { int DetectorNumber = blocks[i]->GetInt("DetectorNumber"); - G4ThreeVector A - = NPS::ConvertVector(blocks[i]->GetTVector3("X1_Y1", "mm")); - G4ThreeVector B - = NPS::ConvertVector(blocks[i]->GetTVector3("X1_Y128", "mm")); - G4ThreeVector C - = NPS::ConvertVector(blocks[i]->GetTVector3("X128_Y1", "mm")); - G4ThreeVector D - = NPS::ConvertVector(blocks[i]->GetTVector3("X128_Y128", "mm")); - - AddDetector(DetectorNumber,shape,A,B,C,D); + G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("X1_Y1", "mm")); + G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("X1_Y128", "mm")); + G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("X128_Y1", "mm")); + G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("X128_Y128", "mm")); + + AddDetector(DetectorNumber, shape, A, B, C, D); } - else if (blocks[i]->HasTokenList(annular)&& (shape=="Annular")) { + else if (blocks[i]->HasTokenList(annular) && (shape == "Annular")) { int DetectorNumber = blocks[i]->GetInt("DetectorNumber"); - G4ThreeVector A - = NPS::ConvertVector(blocks[i]->GetTVector3("Center", "mm")); - AddDetector(DetectorNumber,shape,A); + G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("Center", "mm")); + AddDetector(DetectorNumber, shape, A); } else { cout << "WARNING: Missing token for Mugast blocks, check your input " - "file" - << endl; + "file" + << endl; exit(1); } } @@ -447,16 +374,16 @@ void Mugast::ReadConfiguration(NPL::InputParser parser) { // Construct detector and inialise sensitive part. // Called After Detecor // onstruction::AddDetector Method -void Mugast::ConstructDetector(G4LogicalVolume* world){ - - for (unsigned short i = 0 ; i < m_DetectorNumber.size() ; i++) { - if(m_Shape[i]=="Square"){ - G4RotationMatrix* rot = NULL ; - G4ThreeVector pos = G4ThreeVector(0, 0, 0) ; - G4ThreeVector u = G4ThreeVector(0, 0, 0) ; - G4ThreeVector v = G4ThreeVector(0, 0, 0) ; - G4ThreeVector w = G4ThreeVector(0, 0, 0) ; - G4ThreeVector Center = G4ThreeVector(0, 0, 0) ; +void Mugast::ConstructDetector(G4LogicalVolume* world) { + + for (unsigned short i = 0; i < m_DetectorNumber.size(); i++) { + if (m_Shape[i] == "Square") { + G4RotationMatrix* rot = NULL; + G4ThreeVector pos = G4ThreeVector(0, 0, 0); + G4ThreeVector u = G4ThreeVector(0, 0, 0); + G4ThreeVector v = G4ThreeVector(0, 0, 0); + G4ThreeVector w = G4ThreeVector(0, 0, 0); + G4ThreeVector Center = G4ThreeVector(0, 0, 0); // (u,v,w) unitary vector associated to telescope referencial // (u,v) // to silicon plan // w perpendicular to (u,v) plan and pointing ThirdStage @@ -474,23 +401,24 @@ void Mugast::ConstructDetector(G4LogicalVolume* world){ // Passage Matrix from Lab Referential to Telescope Referential rot = new G4RotationMatrix(u, v, w); // translation to place Telescope - pos = w * SiliconThickness* 0.5 + Center; - new G4PVPlacement(G4Transform3D(*rot, pos), BuildSquareDetector(), "MugastSquare", world, false, m_DetectorNumber[i]); + pos = w * SiliconThickness * 0.5 + Center; + new G4PVPlacement(G4Transform3D(*rot, pos), BuildSquareDetector(), "MugastSquare", world, false, + m_DetectorNumber[i]); } - else if(m_Shape[i]=="Trapezoid"){ - G4RotationMatrix* rot = NULL ; - G4ThreeVector pos = G4ThreeVector(0, 0, 0) ; - G4ThreeVector u = G4ThreeVector(0, 0, 0) ; - G4ThreeVector v = G4ThreeVector(0, 0, 0) ; - G4ThreeVector w = G4ThreeVector(0, 0, 0) ; - G4ThreeVector Center = G4ThreeVector(0, 0, 0) ; + else if (m_Shape[i] == "Trapezoid") { + G4RotationMatrix* rot = NULL; + G4ThreeVector pos = G4ThreeVector(0, 0, 0); + G4ThreeVector u = G4ThreeVector(0, 0, 0); + G4ThreeVector v = G4ThreeVector(0, 0, 0); + G4ThreeVector w = G4ThreeVector(0, 0, 0); + G4ThreeVector Center = G4ThreeVector(0, 0, 0); // (u,v,w) unitary vector associated to telescope referencial // (u,v) // to silicon plan // w perpendicular to (u,v) plan and pointing ThirdStage u = m_X128_Y1[i] - m_X1_Y1[i]; u = u.unit(); - v = (m_X1_Y128[i] + m_X128_Y128[i] - m_X1_Y1[i] - m_X128_Y1[i] ); + v = (m_X1_Y128[i] + m_X128_Y128[i] - m_X1_Y1[i] - m_X128_Y1[i]); v = v.unit(); w = u.cross(v); @@ -500,80 +428,76 @@ void Mugast::ConstructDetector(G4LogicalVolume* world){ // Passage Matrix from Lab Referential to Telescope Referential rot = new G4RotationMatrix(u, v, w); - rot->rotate(180*deg,w); + rot->rotate(180 * deg, w); // translation to place Telescope - pos = w * SiliconThickness* 0.5 + Center; - new G4PVPlacement(G4Transform3D(*rot, pos), BuildTrapezoidDetector(), "MugastTrapezoid", world, false, m_DetectorNumber[i]); + pos = w * SiliconThickness * 0.5 + Center; + new G4PVPlacement(G4Transform3D(*rot, pos), BuildTrapezoidDetector(), "MugastTrapezoid", world, false, + m_DetectorNumber[i]); } - else if(m_Shape[i]=="Annular"){ + else if (m_Shape[i] == "Annular") { G4RotationMatrix* rot = new G4RotationMatrix(); - new G4PVPlacement(G4Transform3D(*rot,m_X1_Y1[i]), BuildAnnularDetector(), "MugastAnnular", world, false, m_DetectorNumber[i]); - } + new G4PVPlacement(G4Transform3D(*rot, m_X1_Y1[i]), BuildAnnularDetector(), "MugastAnnular", world, false, + m_DetectorNumber[i]); + } } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void Mugast::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("Mugast")){ - pTree->Branch("Mugast", "TMugastData", &m_Event) ; +void Mugast::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("Mugast")) { + pTree->Branch("Mugast", "TMugastData", &m_Event); } - pTree->SetBranchAddress("Mugast", &m_Event) ; + pTree->SetBranchAddress("Mugast", &m_Event); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Mugast::ReadSensitive(const G4Event* ){ +void Mugast::ReadSensitive(const G4Event*) { m_Event->Clear(); /////////// // Square - DSSDScorers::PS_Rectangle* SquareScorer = (DSSDScorers::PS_Rectangle*) m_SquareScorer->GetPrimitive(0); - + DSSDScorers::PS_Rectangle* SquareScorer = (DSSDScorers::PS_Rectangle*)m_SquareScorer->GetPrimitive(0); // Loop on the Square map - unsigned int sizeFront= SquareScorer->GetLengthMult(); + unsigned int sizeFront = SquareScorer->GetLengthMult(); - for (unsigned int i=0 ; i<sizeFront ; i++){ + for (unsigned int i = 0; i < sizeFront; i++) { double Energy = RandGauss::shoot(SquareScorer->GetEnergyLength(i), SigmaEnergy); - if(Energy>EnergyThreshold){ - double Time = RandGauss::shoot(SquareScorer->GetTimeLength(i), SigmaTime); - int DetNbr = SquareScorer->GetDetectorLength(i); - int StripFront = SquareScorer->GetStripLength(i); + if (Energy > EnergyThreshold) { + double Time = RandGauss::shoot(SquareScorer->GetTimeLength(i), SigmaTime); + int DetNbr = SquareScorer->GetDetectorLength(i); + int StripFront = SquareScorer->GetStripLength(i); - m_Event->SetDSSDXE(MG_DetectorType::MG_NOCHANGE,DetNbr, - MUGAST_MAP::ReverseSquareX[StripFront-1], - NPL::EnergyToADC(Energy, 0, 63, 8192, 16384)); - - m_Event->SetDSSDXT(MG_DetectorType::MG_NOCHANGE,DetNbr, - MUGAST_MAP::ReverseSquareX[StripFront-1], - NPL::EnergyToADC(Time, 0, 1000, 8192, 16384)); + m_Event->SetDSSDXE(MG_DetectorType::MG_NOCHANGE, DetNbr, MUGAST_MAP::ReverseSquareX[StripFront - 1], + NPL::EnergyToADC(Energy, 0, 63, 8192, 16384)); + m_Event->SetDSSDXT(MG_DetectorType::MG_NOCHANGE, DetNbr, MUGAST_MAP::ReverseSquareX[StripFront - 1], + NPL::EnergyToADC(Time, 0, 1000, 8192, 16384)); } - } + } - unsigned int sizeBack= SquareScorer->GetWidthMult(); - for (unsigned int i=0 ; i<sizeBack ; i++){ + unsigned int sizeBack = SquareScorer->GetWidthMult(); + for (unsigned int i = 0; i < sizeBack; i++) { double Energy = RandGauss::shoot(SquareScorer->GetEnergyWidth(i), SigmaEnergy); - if(Energy>EnergyThreshold){ - double Time = RandGauss::shoot(SquareScorer->GetTimeWidth(i), SigmaTime); - int DetNbr = SquareScorer->GetDetectorWidth(i); - int StripBack = SquareScorer->GetStripWidth(i); + if (Energy > EnergyThreshold) { + double Time = RandGauss::shoot(SquareScorer->GetTimeWidth(i), SigmaTime); + int DetNbr = SquareScorer->GetDetectorWidth(i); + int StripBack = SquareScorer->GetStripWidth(i); - m_Event->SetDSSDYE(MG_DetectorType::MG_NOCHANGE,DetNbr, - MUGAST_MAP::ReverseSquareY[StripBack-1], - NPL::EnergyToADC(Energy, 0, 63, 8192, 0)); + m_Event->SetDSSDYE(MG_DetectorType::MG_NOCHANGE, DetNbr, MUGAST_MAP::ReverseSquareY[StripBack - 1], + NPL::EnergyToADC(Energy, 0, 63, 8192, 0)); - m_Event->SetDSSDYT(MG_DetectorType::MG_NOCHANGE,DetNbr, - MUGAST_MAP::ReverseSquareY[StripBack-1], - NPL::EnergyToADC(Time, 0, 1000, 8192, 16384)); + m_Event->SetDSSDYT(MG_DetectorType::MG_NOCHANGE, DetNbr, MUGAST_MAP::ReverseSquareY[StripBack - 1], + NPL::EnergyToADC(Time, 0, 1000, 8192, 16384)); } } // clear map for next event @@ -581,49 +505,43 @@ void Mugast::ReadSensitive(const G4Event* ){ /////////// // Trapezoid - DSSDScorers::PS_Rectangle* TrapezoidScorer = (DSSDScorers::PS_Rectangle*) m_TrapezoidScorer->GetPrimitive(0); - + DSSDScorers::PS_Rectangle* TrapezoidScorer = (DSSDScorers::PS_Rectangle*)m_TrapezoidScorer->GetPrimitive(0); // Loop on the Trapezoid map - sizeFront= TrapezoidScorer->GetLengthMult(); + sizeFront = TrapezoidScorer->GetLengthMult(); - for (unsigned int i=0 ; i<sizeFront ; i++){ + for (unsigned int i = 0; i < sizeFront; i++) { double Energy = RandGauss::shoot(TrapezoidScorer->GetEnergyLength(i), SigmaEnergy); - if(Energy>EnergyThreshold){ - double Time = RandGauss::shoot(TrapezoidScorer->GetTimeLength(i), SigmaTime); - int DetNbr = TrapezoidScorer->GetDetectorLength(i); - int StripFront = TrapezoidScorer->GetStripLength(i); + if (Energy > EnergyThreshold) { + double Time = RandGauss::shoot(TrapezoidScorer->GetTimeLength(i), SigmaTime); + int DetNbr = TrapezoidScorer->GetDetectorLength(i); + int StripFront = TrapezoidScorer->GetStripLength(i); - m_Event->SetDSSDXE(MG_DetectorType::MG_NOCHANGE,DetNbr, - MUGAST_MAP::ReverseTrapezeX[StripFront-1], - NPL::EnergyToADC(Energy, 0, 63, 8192, 16384)); - - m_Event->SetDSSDXT(MG_DetectorType::MG_NOCHANGE,DetNbr, - MUGAST_MAP::ReverseTrapezeX[StripFront-1], - NPL::EnergyToADC(Time, 0, 1000, 8192, 16384)); + m_Event->SetDSSDXE(MG_DetectorType::MG_NOCHANGE, DetNbr, MUGAST_MAP::ReverseTrapezeX[StripFront - 1], + NPL::EnergyToADC(Energy, 0, 63, 8192, 16384)); + m_Event->SetDSSDXT(MG_DetectorType::MG_NOCHANGE, DetNbr, MUGAST_MAP::ReverseTrapezeX[StripFront - 1], + NPL::EnergyToADC(Time, 0, 1000, 8192, 16384)); } - } + } - sizeBack= TrapezoidScorer->GetWidthMult(); - for (unsigned int i=0 ; i<sizeBack ; i++){ + sizeBack = TrapezoidScorer->GetWidthMult(); + for (unsigned int i = 0; i < sizeBack; i++) { double Energy = RandGauss::shoot(TrapezoidScorer->GetEnergyWidth(i), SigmaEnergy); - if(Energy>EnergyThreshold){ - double Time = RandGauss::shoot(TrapezoidScorer->GetTimeWidth(i), SigmaTime); - int DetNbr = TrapezoidScorer->GetDetectorWidth(i); - int StripBack = 128-TrapezoidScorer->GetStripWidth(i)+1; + if (Energy > EnergyThreshold) { + double Time = RandGauss::shoot(TrapezoidScorer->GetTimeWidth(i), SigmaTime); + int DetNbr = TrapezoidScorer->GetDetectorWidth(i); + int StripBack = 128 - TrapezoidScorer->GetStripWidth(i) + 1; - m_Event->SetDSSDYE(MG_DetectorType::MG_NOCHANGE,DetNbr, - MUGAST_MAP::ReverseTrapezeY[StripBack-1], - NPL::EnergyToADC(Energy, 0, 63, 8192, 0)); + m_Event->SetDSSDYE(MG_DetectorType::MG_NOCHANGE, DetNbr, MUGAST_MAP::ReverseTrapezeY[StripBack - 1], + NPL::EnergyToADC(Energy, 0, 63, 8192, 0)); - m_Event->SetDSSDYT(MG_DetectorType::MG_NOCHANGE,DetNbr, - MUGAST_MAP::ReverseTrapezeY[StripBack-1], - NPL::EnergyToADC(Time, 0, 1000, 8192, 16384)); + m_Event->SetDSSDYT(MG_DetectorType::MG_NOCHANGE, DetNbr, MUGAST_MAP::ReverseTrapezeY[StripBack - 1], + NPL::EnergyToADC(Time, 0, 1000, 8192, 16384)); } } // clear map for next event @@ -631,107 +549,86 @@ void Mugast::ReadSensitive(const G4Event* ){ /////////// // Annular - DSSDScorers::PS_Annular* AnnularScorer = (DSSDScorers::PS_Annular*) m_AnnularScorer->GetPrimitive(0); - + DSSDScorers::PS_Annular* AnnularScorer = (DSSDScorers::PS_Annular*)m_AnnularScorer->GetPrimitive(0); // Loop on the Annular map - sizeFront= AnnularScorer->GetRingMult(); - unsigned int sizeQuadrant= AnnularScorer->GetQuadrantMult(); + sizeFront = AnnularScorer->GetRingMult(); + unsigned int sizeQuadrant = AnnularScorer->GetQuadrantMult(); - for (unsigned int i=0 ; i<sizeFront ; i++){ + for (unsigned int i = 0; i < sizeFront; i++) { double Energy = RandGauss::shoot(AnnularScorer->GetEnergyRing(i), SigmaEnergy); - if(Energy>EnergyThreshold){ - double Time = RandGauss::shoot(AnnularScorer->GetTimeRing(i), SigmaTime); - unsigned int DetNbr = AnnularScorer->GetDetectorRing(i); - unsigned int StripFront = AnnularScorer->GetStripRing(i); - + if (Energy > EnergyThreshold) { + double Time = RandGauss::shoot(AnnularScorer->GetTimeRing(i), SigmaTime); + unsigned int DetNbr = AnnularScorer->GetDetectorRing(i); + unsigned int StripFront = AnnularScorer->GetStripRing(i); + // Check for associated Quadrant strip int StripQuadrant = 0; - for(unsigned int q = 0 ; q < sizeQuadrant ; q++){ - if(AnnularScorer->GetDetectorQuadrant(q)==DetNbr){ - StripQuadrant = AnnularScorer->GetStripQuadrant(q)-1; + for (unsigned int q = 0; q < sizeQuadrant; q++) { + if (AnnularScorer->GetDetectorQuadrant(q) == DetNbr) { + StripQuadrant = AnnularScorer->GetStripQuadrant(q) - 1; break; - } + } } - StripFront=StripFront+StripQuadrant*NbrRingStrips; - m_Event->SetDSSDXE(MG_DetectorType::MG_NOCHANGE,DetNbr, - MUGAST_MAP::ReverseAnnularX[StripFront-1], - NPL::EnergyToADC(Energy, 0, 63, 8192, 16384)); - - m_Event->SetDSSDXT(MG_DetectorType::MG_NOCHANGE,DetNbr, - MUGAST_MAP::ReverseAnnularX[StripFront-1], - NPL::EnergyToADC(Time, 0, 1000, 8192, 16384)); + StripFront = StripFront + StripQuadrant * NbrRingStrips; + m_Event->SetDSSDXE(MG_DetectorType::MG_NOCHANGE, DetNbr, MUGAST_MAP::ReverseAnnularX[StripFront - 1], + NPL::EnergyToADC(Energy, 0, 63, 8192, 16384)); + m_Event->SetDSSDXT(MG_DetectorType::MG_NOCHANGE, DetNbr, MUGAST_MAP::ReverseAnnularX[StripFront - 1], + NPL::EnergyToADC(Time, 0, 1000, 8192, 16384)); } - } + } - sizeBack= AnnularScorer->GetSectorMult(); - for (unsigned int i=0 ; i<sizeBack ; i++){ + sizeBack = AnnularScorer->GetSectorMult(); + for (unsigned int i = 0; i < sizeBack; i++) { double Energy = RandGauss::shoot(AnnularScorer->GetEnergySector(i), SigmaEnergy); - if(Energy>EnergyThreshold){ - double Time = RandGauss::shoot(AnnularScorer->GetTimeSector(i), SigmaTime); - int DetNbr = AnnularScorer->GetDetectorSector(i); - int StripBack = AnnularScorer->GetStripSector(i); - m_Event->SetDSSDYE(MG_DetectorType::MG_NOCHANGE,DetNbr, - MUGAST_MAP::ReverseAnnularY[StripBack-1], - NPL::EnergyToADC(Energy, 0, 63, 8192, 0)); - - m_Event->SetDSSDYT(MG_DetectorType::MG_NOCHANGE,DetNbr, - MUGAST_MAP::ReverseAnnularY[StripBack-1], - NPL::EnergyToADC(Time, 0, 1000, 8192, 16384)); + if (Energy > EnergyThreshold) { + double Time = RandGauss::shoot(AnnularScorer->GetTimeSector(i), SigmaTime); + int DetNbr = AnnularScorer->GetDetectorSector(i); + int StripBack = AnnularScorer->GetStripSector(i); + m_Event->SetDSSDYE(MG_DetectorType::MG_NOCHANGE, DetNbr, MUGAST_MAP::ReverseAnnularY[StripBack - 1], + NPL::EnergyToADC(Energy, 0, 63, 8192, 0)); + + m_Event->SetDSSDYT(MG_DetectorType::MG_NOCHANGE, DetNbr, MUGAST_MAP::ReverseAnnularY[StripBack - 1], + NPL::EnergyToADC(Time, 0, 1000, 8192, 16384)); } } // clear map for next event AnnularScorer->clear(); - - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -//////////////////////////////////////////////////////////////// -void Mugast::InitializeScorers() { +//////////////////////////////////////////////////////////////// +void Mugast::InitializeScorers() { // This check is necessary in case the geometry is reloaded - bool already_exist = false; - m_SquareScorer= CheckScorer("SquareScorer",already_exist) ; - m_TrapezoidScorer= CheckScorer("TrapezoidScorer",already_exist) ; - m_AnnularScorer= CheckScorer("AnnularScorer",already_exist) ; + bool already_exist = false; + m_SquareScorer = CheckScorer("SquareScorer", already_exist); + m_TrapezoidScorer = CheckScorer("TrapezoidScorer", already_exist); + m_AnnularScorer = CheckScorer("AnnularScorer", already_exist); - if(already_exist) - return ; + if (already_exist) + return; // Otherwise the scorer is initialised - G4VPrimitiveScorer* SquareScorer = new DSSDScorers::PS_Rectangle("MugastSquareScorer",1, - SquareBase, - SquareHeight, - 128, - 128); - - - G4VPrimitiveScorer* TrapezoidScorer = new DSSDScorers::PS_Rectangle("MugastTrapezoidScorer",1, - TrapezoidBaseLarge, - TrapezoidHeight, - 128, - 128); - - G4VPrimitiveScorer* AnnularScorer = new DSSDScorers::PS_Annular("MugastAnnularScorer", - 2, - ActiveWaferInnerRadius, - ActiveWaferOutterRadius, - -8*22.5*deg, //MUST2 campaign 2009, See: Phd Sandra Giron - +8*22.5*deg, - NbrRingStrips, - NbrSectorStrips, - NbQuadrant); - - - G4VPrimitiveScorer* InteractionS= new InteractionScorers::PS_Interactions("InteractionS",ms_InterCoord, 0) ; - G4VPrimitiveScorer* InteractionT= new InteractionScorers::PS_Interactions("InteractionT",ms_InterCoord, 0) ; - G4VPrimitiveScorer* InteractionA= new InteractionScorers::PS_Interactions("InteractionA",ms_InterCoord, 0) ; - //and register it to the multifunctionnal detector + G4VPrimitiveScorer* SquareScorer = + new DSSDScorers::PS_Rectangle("MugastSquareScorer", 1, SquareBase, SquareHeight, 128, 128); + + G4VPrimitiveScorer* TrapezoidScorer = + new DSSDScorers::PS_Rectangle("MugastTrapezoidScorer", 1, TrapezoidBaseLarge, TrapezoidHeight, 128, 128); + + G4VPrimitiveScorer* AnnularScorer = + new DSSDScorers::PS_Annular("MugastAnnularScorer", 2, ActiveWaferInnerRadius, ActiveWaferOutterRadius, + -8 * 22.5 * deg, // MUST2 campaign 2009, See: Phd Sandra Giron + +8 * 22.5 * deg, NbrRingStrips, NbrSectorStrips, NbQuadrant); + + G4VPrimitiveScorer* InteractionS = new InteractionScorers::PS_Interactions("InteractionS", ms_InterCoord, 0); + G4VPrimitiveScorer* InteractionT = new InteractionScorers::PS_Interactions("InteractionT", ms_InterCoord, 0); + G4VPrimitiveScorer* InteractionA = new InteractionScorers::PS_Interactions("InteractionA", ms_InterCoord, 0); + // and register it to the multifunctionnal detector m_SquareScorer->RegisterPrimitive(SquareScorer); m_SquareScorer->RegisterPrimitive(InteractionS); m_TrapezoidScorer->RegisterPrimitive(TrapezoidScorer); @@ -739,9 +636,9 @@ void Mugast::InitializeScorers() { m_AnnularScorer->RegisterPrimitive(AnnularScorer); m_AnnularScorer->RegisterPrimitive(InteractionA); - G4SDManager::GetSDMpointer()->AddNewDetector(m_SquareScorer) ; - G4SDManager::GetSDMpointer()->AddNewDetector(m_TrapezoidScorer) ; - G4SDManager::GetSDMpointer()->AddNewDetector(m_AnnularScorer) ; + G4SDManager::GetSDMpointer()->AddNewDetector(m_SquareScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_TrapezoidScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_AnnularScorer); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -750,22 +647,20 @@ void Mugast::InitializeScorers() { //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* Mugast::Construct(){ - return (NPS::VDetector*) new Mugast(); -} +NPS::VDetector* Mugast::Construct() { return (NPS::VDetector*)new Mugast(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_Mugast{ - public: - proxy_nps_Mugast(){ - NPS::DetectorFactory::getInstance()->AddToken("Mugast","Mugast"); - NPS::DetectorFactory::getInstance()->AddDetector("Mugast",Mugast::Construct); - } - }; +extern "C" { +class proxy_nps_Mugast { + public: + proxy_nps_Mugast() { + NPS::DetectorFactory::getInstance()->AddToken("Mugast", "Mugast"); + NPS::DetectorFactory::getInstance()->AddDetector("Mugast", Mugast::Construct); + } +}; - proxy_nps_Mugast p_nps_Mugast; +proxy_nps_Mugast p_nps_Mugast; } diff --git a/NPSimulation/Detectors/Nana/Nana.cc b/NPSimulation/Detectors/Nana/Nana.cc index f5058b431..f3c02c1de 100644 --- a/NPSimulation/Detectors/Nana/Nana.cc +++ b/NPSimulation/Detectors/Nana/Nana.cc @@ -20,23 +20,23 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> +#include <sstream> using namespace std; -//Geant4 -#include "G4VSolid.hh" +// Geant4 #include "G4Box.hh" -#include "G4Tubs.hh" +#include "G4Colour.hh" #include "G4ExtrudedSolid.hh" -#include "G4TwoVector.hh" -#include "G4UnionSolid.hh" -#include "G4SubtractionSolid.hh" +#include "G4PVPlacement.hh" #include "G4SDManager.hh" +#include "G4SubtractionSolid.hh" #include "G4Transform3D.hh" -#include "G4PVPlacement.hh" -#include "G4Colour.hh" +#include "G4Tubs.hh" +#include "G4TwoVector.hh" +#include "G4UnionSolid.hh" +#include "G4VSolid.hh" // NPS #include "Nana.hh" @@ -55,7 +55,7 @@ using namespace CLHEP; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Nana Specific Method -Nana::Nana(){ +Nana::Nana() { m_Event = new TNanaData(); // Blue @@ -68,28 +68,28 @@ Nana::Nana(){ m_DetectorCasingVisAtt = new G4VisAttributes(G4Colour(0.125, 0.125, 0.125, 0.4)); m_LogicalDetector = 0; - m_LaBr3Scorer = 0 ; + m_LaBr3Scorer = 0; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Nana::~Nana(){ -} +Nana::~Nana() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Nana::AddDetector(G4ThreeVector Pos1, G4ThreeVector Pos2, G4ThreeVector Pos3, G4ThreeVector Pos4){ - G4ThreeVector Pos=(Pos1+Pos2+Pos3+Pos4)/4.; - G4ThreeVector u = Pos1-Pos2; - G4ThreeVector v = Pos1-Pos4; - u = u.unit(); v = v.unit(); +void Nana::AddDetector(G4ThreeVector Pos1, G4ThreeVector Pos2, G4ThreeVector Pos3, G4ThreeVector Pos4) { + G4ThreeVector Pos = (Pos1 + Pos2 + Pos3 + Pos4) / 4.; + G4ThreeVector u = Pos1 - Pos2; + G4ThreeVector v = Pos1 - Pos4; + u = u.unit(); + v = v.unit(); G4ThreeVector w = Pos.unit(); - Pos = Pos + w*Length*0.5; + Pos = Pos + w * Length * 0.5; m_Pos.push_back(Pos); - m_Rot.push_back(new G4RotationMatrix(u,v,w)); + m_Rot.push_back(new G4RotationMatrix(u, v, w)); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Nana::AddDetector(G4ThreeVector Pos, double beta_u, double beta_v, double beta_w){ +void Nana::AddDetector(G4ThreeVector Pos, double beta_u, double beta_v, double beta_w) { double Theta = Pos.theta(); double Phi = Pos.phi(); @@ -105,10 +105,10 @@ void Nana::AddDetector(G4ThreeVector Pos, double beta_u, double beta_v, double b v = v.unit(); u = u.unit(); - G4RotationMatrix* r = new G4RotationMatrix(u,v,w); - r->rotate(beta_u,u); - r->rotate(beta_v,v); - r->rotate(beta_w,w); + G4RotationMatrix* r = new G4RotationMatrix(u, v, w); + r->rotate(beta_u, u); + r->rotate(beta_v, v); + r->rotate(beta_w, w); m_Pos.push_back(Pos); m_Rot.push_back(r); @@ -118,38 +118,37 @@ void Nana::AddDetector(G4ThreeVector Pos, double beta_u, double beta_v, double b // Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Nana::ReadConfiguration(NPL::InputParser parser){ +void Nana::ReadConfiguration(NPL::InputParser parser) { vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Nana"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " detectors found " << endl; - - - vector<string> cart = {"A","B","C","D"}; - vector<string> sphe= {"R","Theta","Phi","Beta"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(cart)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Nana " << i+1 << endl; - G4ThreeVector A = NPS::ConvertVector( blocks[i]->GetTVector3("A","mm")); - G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("B","mm")); - G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("C","mm")); - G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("D","mm")); - AddDetector(A,B,C,D) ; + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + + vector<string> cart = {"A", "B", "C", "D"}; + vector<string> sphe = {"R", "Theta", "Phi", "Beta"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(cart)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Nana " << i + 1 << endl; + G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("A", "mm")); + G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("B", "mm")); + G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("C", "mm")); + G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("D", "mm")); + AddDetector(A, B, C, D); } - - else if(blocks[i]->HasTokenList(sphe)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Nana " << i+1 << endl; - double R = blocks[i]->GetDouble("R","mm"); - double Theta = blocks[i]->GetDouble("Theta","deg"); - double Phi = blocks[i]->GetDouble("Phi","deg"); - vector<double> Beta = blocks[i]->GetVectorDouble("Beta","def"); - R = R + 0.5*Length; - G4ThreeVector Pos(R*sin(Theta)*cos(Phi),R*sin(Theta)*sin(Phi),R*cos(Theta)); - AddDetector(Pos,Beta[0],Beta[1],Beta[2]) ; + + else if (blocks[i]->HasTokenList(sphe)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Nana " << i + 1 << endl; + double R = blocks[i]->GetDouble("R", "mm"); + double Theta = blocks[i]->GetDouble("Theta", "deg"); + double Phi = blocks[i]->GetDouble("Phi", "deg"); + vector<double> Beta = blocks[i]->GetVectorDouble("Beta", "def"); + R = R + 0.5 * Length; + G4ThreeVector Pos(R * sin(Theta) * cos(Phi), R * sin(Theta) * sin(Phi), R * cos(Theta)); + AddDetector(Pos, Beta[0], Beta[1], Beta[2]); } - else{ + else { cout << "ERROR: Missing token for M2Telescope blocks, check your input file" << endl; exit(1); } @@ -159,130 +158,111 @@ void Nana::ReadConfiguration(NPL::InputParser parser){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void Nana::ConstructDetector(G4LogicalVolume* world){ +void Nana::ConstructDetector(G4LogicalVolume* world) { // Lead block supporting Detector G4Material* Lead = MaterialManager::getInstance()->GetMaterialFromLibrary("Pb"); - // G4Box* solidLead = new G4Box("solidLead",10*cm,5*cm,12.5*cm); + // G4Box* solidLead = new G4Box("solidLead",10*cm,5*cm,12.5*cm); std::vector<G4TwoVector> polygon; - polygon.push_back(G4TwoVector(0,50)); - polygon.push_back(G4TwoVector(-25,25)); - polygon.push_back(G4TwoVector(-25,-75)); - polygon.push_back(G4TwoVector(0,-50)); - polygon.push_back(G4TwoVector(25,-75)); - polygon.push_back(G4TwoVector(25,25)); - - std::vector<G4ExtrudedSolid::ZSection> zsections; - zsections.push_back(G4ExtrudedSolid::ZSection(-6.25*cm,G4TwoVector(0,0),1)); - zsections.push_back(G4ExtrudedSolid::ZSection(+6.25*cm,G4TwoVector(0,0),1)); - - G4ExtrudedSolid* solidLead = new G4ExtrudedSolid("solidLead", - polygon, - zsections); - - G4LogicalVolume* logicLead = new G4LogicalVolume(solidLead, Lead, "logicLead", 0, 0, 0); - G4VisAttributes* lead_vis= new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)); + polygon.push_back(G4TwoVector(0, 50)); + polygon.push_back(G4TwoVector(-25, 25)); + polygon.push_back(G4TwoVector(-25, -75)); + polygon.push_back(G4TwoVector(0, -50)); + polygon.push_back(G4TwoVector(25, -75)); + polygon.push_back(G4TwoVector(25, 25)); + + std::vector<G4ExtrudedSolid::ZSection> zsections; + zsections.push_back(G4ExtrudedSolid::ZSection(-6.25 * cm, G4TwoVector(0, 0), 1)); + zsections.push_back(G4ExtrudedSolid::ZSection(+6.25 * cm, G4TwoVector(0, 0), 1)); + + G4ExtrudedSolid* solidLead = new G4ExtrudedSolid("solidLead", polygon, zsections); + + G4LogicalVolume* logicLead = new G4LogicalVolume(solidLead, Lead, "logicLead", 0, 0, 0); + G4VisAttributes* lead_vis = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)); logicLead->SetVisAttributes(lead_vis); - unsigned int mysize = m_Pos.size(); - for(unsigned int i = 0 ; i < mysize ; i++){ - new G4PVPlacement(G4Transform3D(*m_Rot[i], m_Pos[i]), ConstructDetector(), "NanaDetector", world, false, i+2); - - - G4Material* Wood = MaterialManager::getInstance()->GetMaterialFromLibrary("Wood"); - - G4Box* table = new G4Box("Table",1*m,1*m,1*cm); - G4LogicalVolume* logicTable= new G4LogicalVolume(table, Wood, "logicTable", 0, 0, 0); - - G4RotationMatrix* r = new G4RotationMatrix(); - r->rotateX(90*deg); - new G4PVPlacement(r,G4ThreeVector(0,-5*cm,0), - logicTable, - "Nana_Table", - world, - false, - 0); - - - - -/* G4RotationMatrix* r = new G4RotationMatrix(); - r->rotateX(-90*deg); - r->rotateY(60*deg); - - G4ThreeVector Pos(PMTFace,0.25*6.25*cm, 90*mm); - Pos.setTheta(60*deg); - new G4PVPlacement(G4Transform3D(*r, Pos+G4ThreeVector(0,0, +PMTFace)), - logicLead, - "Nana_Lead_Support", - world, - false, - i+1); - - new G4PVPlacement(G4Transform3D(*r, Pos+G4ThreeVector(1.1*PMTFace,0, -0.5*PMTFace)), - logicLead, - "Nana_Lead_Support", - world, - false, - i+1); - - G4RotationMatrix* r2 = new G4RotationMatrix(); - r2->rotateX(-90*deg); - r2->rotateY(300*deg); - - G4ThreeVector Pos2(PMTFace,-0.25*6.25*cm, 90*mm); - Pos2.setTheta(300*deg); - new G4PVPlacement(G4Transform3D(*r2, Pos2+G4ThreeVector(0,0, +PMTFace)), - logicLead, - "Nana_Lead_Support", - world, - false, - i+1); - - new G4PVPlacement(G4Transform3D(*r2, Pos2+G4ThreeVector(-1.1*PMTFace,0, -0.5*PMTFace)), - logicLead, - "Nana_Lead_Support", - world, - false, - i+1); -*/ + unsigned int mysize = m_Pos.size(); + for (unsigned int i = 0; i < mysize; i++) { + new G4PVPlacement(G4Transform3D(*m_Rot[i], m_Pos[i]), ConstructDetector(), "NanaDetector", world, false, i + 2); + + G4Material* Wood = MaterialManager::getInstance()->GetMaterialFromLibrary("Wood"); + + G4Box* table = new G4Box("Table", 1 * m, 1 * m, 1 * cm); + G4LogicalVolume* logicTable = new G4LogicalVolume(table, Wood, "logicTable", 0, 0, 0); + + G4RotationMatrix* r = new G4RotationMatrix(); + r->rotateX(90 * deg); + new G4PVPlacement(r, G4ThreeVector(0, -5 * cm, 0), logicTable, "Nana_Table", world, false, 0); + + /* G4RotationMatrix* r = new G4RotationMatrix(); + r->rotateX(-90*deg); + r->rotateY(60*deg); + + G4ThreeVector Pos(PMTFace,0.25*6.25*cm, 90*mm); + Pos.setTheta(60*deg); + new G4PVPlacement(G4Transform3D(*r, Pos+G4ThreeVector(0,0, +PMTFace)), + logicLead, + "Nana_Lead_Support", + world, + false, + i+1); + + new G4PVPlacement(G4Transform3D(*r, Pos+G4ThreeVector(1.1*PMTFace,0, -0.5*PMTFace)), + logicLead, + "Nana_Lead_Support", + world, + false, + i+1); + + G4RotationMatrix* r2 = new G4RotationMatrix(); + r2->rotateX(-90*deg); + r2->rotateY(300*deg); + + G4ThreeVector Pos2(PMTFace,-0.25*6.25*cm, 90*mm); + Pos2.setTheta(300*deg); + new G4PVPlacement(G4Transform3D(*r2, Pos2+G4ThreeVector(0,0, +PMTFace)), + logicLead, + "Nana_Lead_Support", + world, + false, + i+1); + + new G4PVPlacement(G4Transform3D(*r2, Pos2+G4ThreeVector(-1.1*PMTFace,0, -0.5*PMTFace)), + logicLead, + "Nana_Lead_Support", + world, + false, + i+1); + */ } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Nana::ConstructDetector(){ - if(!m_LogicalDetector){ +G4LogicalVolume* Nana::ConstructDetector() { + if (!m_LogicalDetector) { G4Material* Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); G4Material* Alu = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); - G4Material* Kovar= MaterialManager::getInstance()->GetMaterialFromLibrary("Kovar"); + G4Material* Kovar = MaterialManager::getInstance()->GetMaterialFromLibrary("Kovar"); G4Material* Lead = MaterialManager::getInstance()->GetMaterialFromLibrary("Pb"); G4Material* LaBr3 = MaterialManager::getInstance()->GetMaterialFromLibrary("LaBr3_Ce"); - G4Material* Glass= MaterialManager::getInstance()->GetMaterialFromLibrary("Borosillicate_Glass"); + G4Material* Glass = MaterialManager::getInstance()->GetMaterialFromLibrary("Borosillicate_Glass"); // Mother Volume - G4Tubs* solidNanaDetector = - new G4Tubs("Nana",0, 0.5*FaceFront, 0.5*Length, 0.*deg, 360.*deg); - m_LogicalDetector = - new G4LogicalVolume(solidNanaDetector, Vacuum, "Nana", 0, 0, 0); + G4Tubs* solidNanaDetector = new G4Tubs("Nana", 0, 0.5 * FaceFront, 0.5 * Length, 0. * deg, 360. * deg); + m_LogicalDetector = new G4LogicalVolume(solidNanaDetector, Vacuum, "Nana", 0, 0, 0); - m_LogicalDetector->SetVisAttributes(G4VisAttributes::Invisible); + m_LogicalDetector->SetVisAttributes(G4VisAttributes::GetInvisible()); // Detector construction // LaBr3 - G4ThreeVector positionLaBr3 = G4ThreeVector(0, 0, LaBr3_PosZ); + G4ThreeVector positionLaBr3 = G4ThreeVector(0, 0, LaBr3_PosZ); - G4Tubs* solidLaBr3 = new G4Tubs("solidLaBr3", 0., 0.5*LaBr3Face, 0.5*LaBr3Thickness, 0.*deg, 360.*deg); + G4Tubs* solidLaBr3 = new G4Tubs("solidLaBr3", 0., 0.5 * LaBr3Face, 0.5 * LaBr3Thickness, 0. * deg, 360. * deg); G4LogicalVolume* logicLaBr3 = new G4LogicalVolume(solidLaBr3, LaBr3, "logicLaBr3", 0, 0, 0); - new G4PVPlacement(0, - positionLaBr3, - logicLaBr3, - "Nana_LaBr3", - m_LogicalDetector, - false, - 0); + new G4PVPlacement(0, positionLaBr3, logicLaBr3, "Nana_LaBr3", m_LogicalDetector, false, 0); // Set LaBr3 sensible logicLaBr3->SetSensitiveDetector(m_LaBr3Scorer); @@ -292,76 +272,53 @@ G4LogicalVolume* Nana::ConstructDetector(){ // Aluminium can around LaBr3 // LaBr3 Can - G4ThreeVector positionLaBr3Can = G4ThreeVector(0, 0, LaBr3Can_PosZ); + G4ThreeVector positionLaBr3Can = G4ThreeVector(0, 0, LaBr3Can_PosZ); - G4Tubs* solidLaBr3Can = new G4Tubs("solidLaBr3Can", 0.5*CanInnerDiameter, 0.5*CanOuterDiameter, 0.5*CanLength, 0.*deg, 360.*deg); + G4Tubs* solidLaBr3Can = new G4Tubs("solidLaBr3Can", 0.5 * CanInnerDiameter, 0.5 * CanOuterDiameter, 0.5 * CanLength, + 0. * deg, 360. * deg); G4LogicalVolume* logicLaBr3Can = new G4LogicalVolume(solidLaBr3Can, Glass, "logicLaBr3Can", 0, 0, 0); - new G4PVPlacement(0, - positionLaBr3Can, - logicLaBr3Can, - "Nana_LaBr3Can", - m_LogicalDetector, - false, - 0); + new G4PVPlacement(0, positionLaBr3Can, logicLaBr3Can, "Nana_LaBr3Can", m_LogicalDetector, false, 0); // Visualisation of LaBr3Can logicLaBr3Can->SetVisAttributes(m_DetectorCasingVisAtt); // Aluminium window in front of LaBr3 // LaBr3 Window - G4ThreeVector positionLaBr3Win = G4ThreeVector(0, 0, LaBr3Win_PosZ); + G4ThreeVector positionLaBr3Win = G4ThreeVector(0, 0, LaBr3Win_PosZ); - G4Tubs* solidLaBr3Win = new G4Tubs("solidLaBr3Win", 0.5*WinInnerDiameter, 0.5*WinOuterDiameter, 0.5*WinLength, 0.*deg, 360.*deg); + G4Tubs* solidLaBr3Win = new G4Tubs("solidLaBr3Win", 0.5 * WinInnerDiameter, 0.5 * WinOuterDiameter, 0.5 * WinLength, + 0. * deg, 360. * deg); G4LogicalVolume* logicLaBr3Win = new G4LogicalVolume(solidLaBr3Win, Alu, "logicLaBr3Win", 0, 0, 0); - new G4PVPlacement(0, - positionLaBr3Win, - logicLaBr3Win, - "Nana_LaBr3Win", - m_LogicalDetector, - false, - 0); + new G4PVPlacement(0, positionLaBr3Win, logicLaBr3Win, "Nana_LaBr3Win", m_LogicalDetector, false, 0); // Visualisation of LaBr3Win logicLaBr3Win->SetVisAttributes(m_DetectorCasingVisAtt); // PMT - G4ThreeVector positionPMT = G4ThreeVector(0, 0, PMT_PosZ); + G4ThreeVector positionPMT = G4ThreeVector(0, 0, PMT_PosZ); /* G4Tubs* solidPMout = new G4Tubs("solidPMOut", 0.5*LaBr3Face, 0.5*PMTFace, 0.5*PMTThickness, 0.*deg, 360.*deg); - G4Tubs* solidPMin = new G4Tubs("solidPMIn", 0.5*LaBr3Face-0.1*cm, 0.5*PMTFace-0.5*cm, 0.5*(PMTThickness-2.*cm)-0.1*cm, 0.*deg, 360.*deg); - G4RotationMatrix* RotMat=NULL; - const G4ThreeVector &Trans= G4ThreeVector(0.,0.,1.*cm); - G4SubtractionSolid* solidPMT = new G4SubtractionSolid("solidPMT", solidPMout,solidPMin, RotMat, Trans); + G4Tubs* solidPMin = new G4Tubs("solidPMIn", 0.5*LaBr3Face-0.1*cm, 0.5*PMTFace-0.5*cm, + 0.5*(PMTThickness-2.*cm)-0.1*cm, 0.*deg, 360.*deg); G4RotationMatrix* RotMat=NULL; const G4ThreeVector &Trans= + G4ThreeVector(0.,0.,1.*cm); G4SubtractionSolid* solidPMT = new G4SubtractionSolid("solidPMT", + solidPMout,solidPMin, RotMat, Trans); */ - G4Tubs* solidPMT= new G4Tubs("solidPMOut", 0.5*LaBr3Face, 0.5*PMTFace, 0.5*PMTThickness, 0.*deg, 360.*deg); + G4Tubs* solidPMT = + new G4Tubs("solidPMOut", 0.5 * LaBr3Face, 0.5 * PMTFace, 0.5 * PMTThickness, 0. * deg, 360. * deg); G4LogicalVolume* logicPMT = new G4LogicalVolume(solidPMT, Kovar, "logicPMT", 0, 0, 0); - G4Tubs* solidPMTWin = new G4Tubs("solidPMTWin", 0, 0.5*LaBr3Face, 0.5*WinLength, 0.*deg, 360.*deg); + G4Tubs* solidPMTWin = new G4Tubs("solidPMTWin", 0, 0.5 * LaBr3Face, 0.5 * WinLength, 0. * deg, 360. * deg); G4LogicalVolume* logicPMTWin = new G4LogicalVolume(solidPMTWin, Glass, "logicPMTWin", 0, 0, 0); + new G4PVPlacement(0, positionPMT, logicPMT, "Nana_PMT", m_LogicalDetector, false, 0); - new G4PVPlacement(0, - positionPMT, - logicPMT, - "Nana_PMT", - m_LogicalDetector, - false, - 0); - - new G4PVPlacement(0, - positionPMT+G4ThreeVector(0,0,-0.45*PMTThickness), - logicPMTWin, - "Nana_PMTWind", - m_LogicalDetector, - false, - 0); - + new G4PVPlacement(0, positionPMT + G4ThreeVector(0, 0, -0.45 * PMTThickness), logicPMTWin, "Nana_PMTWind", + m_LogicalDetector, false, 0); // Visualisation of PMT Strip logicPMT->SetVisAttributes(m_PMTVisAtt); - /* // Plastic Lead shielding //plastic definition @@ -385,24 +342,24 @@ G4LogicalVolume* Nana::ConstructDetector(){ G4Tubs* solidLeadA = new G4Tubs("solidLead", 0.5*LeadAMinR, 0.5*LeadAMaxR, 0.5*LeadALength, 0.*deg, 360.*deg); G4LogicalVolume* logicLeadAShield = new G4LogicalVolume(solidLeadA, PCA, "logicLeadAShield", 0, 0, 0); - new G4PVPlacement(0, - positionLeadAShield, - logicLeadAShield, - "Nana_LeadAShield", - m_LogicalDetector, - false, + new G4PVPlacement(0, + positionLeadAShield, + logicLeadAShield, + "Nana_LeadAShield", + m_LogicalDetector, + false, 0); // B G4ThreeVector positionLeadBShield = G4ThreeVector(0, 0, LeadBShield_PosZ); - G4Tubs* solidLeadB = new G4Tubs("solidLead", 0.5*LeadBMinR, 0.5*LeadBMaxR, 0.5*LeadBLength, 0.*deg, 360.*deg); - G4LogicalVolume* logicLeadBShield = new G4LogicalVolume(solidLeadB, PCA, "logicLeadBShield", 0, 0, 0); - - new G4PVPlacement(0, - positionLeadBShield, - logicLeadBShield, - "Nana_LeadBShield", - m_LogicalDetector, - false, + G4Tubs* solidLeadB = new G4Tubs("solidLead", 0.5*LeadBMinR, 0.5*LeadBMaxR, 0.5*LeadBLength, 0.*deg, + 360.*deg); G4LogicalVolume* logicLeadBShield = new G4LogicalVolume(solidLeadB, PCA, "logicLeadBShield", 0, 0, 0); + + new G4PVPlacement(0, + positionLeadBShield, + logicLeadBShield, + "Nana_LeadBShield", + m_LogicalDetector, + false, 0); @@ -417,36 +374,25 @@ G4LogicalVolume* Nana::ConstructDetector(){ */ // Lead shielding // A - G4ThreeVector positionLeadAShield = G4ThreeVector(0, 0, LeadAShield_PosZ); - G4Tubs* solidLeadA = new G4Tubs("solidLead", 0.5*LeadAMinR, 0.5*LeadAMaxR, 0.5*LeadALength, 0.*deg, 360.*deg); + G4ThreeVector positionLeadAShield = G4ThreeVector(0, 0, LeadAShield_PosZ); + G4Tubs* solidLeadA = + new G4Tubs("solidLead", 0.5 * LeadAMinR, 0.5 * LeadAMaxR, 0.5 * LeadALength, 0. * deg, 360. * deg); G4LogicalVolume* logicLeadAShield = new G4LogicalVolume(solidLeadA, Lead, "logicLeadAShield", 0, 0, 0); - new G4PVPlacement(0, - positionLeadAShield, - logicLeadAShield, - "Nana_LeadAShield", - m_LogicalDetector, - false, - 0); + new G4PVPlacement(0, positionLeadAShield, logicLeadAShield, "Nana_LeadAShield", m_LogicalDetector, false, 0); // B - G4ThreeVector positionLeadBShield = G4ThreeVector(0, 0, LeadBShield_PosZ); - G4Tubs* solidLeadB = new G4Tubs("solidLead", 0.5*LeadBMinR, 0.5*LeadBMaxR, 0.5*LeadBLength, 0.*deg, 360.*deg); + G4ThreeVector positionLeadBShield = G4ThreeVector(0, 0, LeadBShield_PosZ); + G4Tubs* solidLeadB = + new G4Tubs("solidLead", 0.5 * LeadBMinR, 0.5 * LeadBMaxR, 0.5 * LeadBLength, 0. * deg, 360. * deg); G4LogicalVolume* logicLeadBShield = new G4LogicalVolume(solidLeadB, Lead, "logicLeadBShield", 0, 0, 0); - new G4PVPlacement(0, - positionLeadBShield, - logicLeadBShield, - "Nana_LeadBShield", - m_LogicalDetector, - false, - 0); + new G4PVPlacement(0, positionLeadBShield, logicLeadBShield, "Nana_LeadBShield", m_LogicalDetector, false, 0); // Visualisation of PMT Strip G4VisAttributes* LeadVisAtt = new G4VisAttributes(G4Colour(.66, .66, .66)); logicLeadAShield->SetVisAttributes(LeadVisAtt); logicLeadBShield->SetVisAttributes(LeadVisAtt); - } return m_LogicalDetector; @@ -455,76 +401,73 @@ G4LogicalVolume* Nana::ConstructDetector(){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void Nana::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("Nana")){ - pTree->Branch("Nana", "TNanaData", &m_Event) ; +void Nana::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("Nana")) { + pTree->Branch("Nana", "TNanaData", &m_Event); } - pTree->SetBranchAddress("Nana", &m_Event) ; + pTree->SetBranchAddress("Nana", &m_Event); } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Nana::ReadSensitive(const G4Event* ){ +void Nana::ReadSensitive(const G4Event*) { m_Event->Clear(); /////////// - CalorimeterScorers::PS_Calorimeter* Scorer= (CalorimeterScorers::PS_Calorimeter*) m_LaBr3Scorer->GetPrimitive(0); - - unsigned int size = Scorer->GetMult(); - for(unsigned int i = 0 ; i < size ; i++){ - double E = Scorer->GetEnergy(i); - double Energy = RandGauss::shoot(E,(E*0.0325637)/(2.35*pow(E-0.00975335,0.475759))); - if(Energy>EnergyThreshold){ - double Time = Scorer->GetTime(i); - int DetectorNbr = Scorer->GetLevel(i)[0]; - m_Event->SetNanaLaBr3(DetectorNbr,Energy,Energy,(unsigned short) Time,0,0); + CalorimeterScorers::PS_Calorimeter* Scorer = (CalorimeterScorers::PS_Calorimeter*)m_LaBr3Scorer->GetPrimitive(0); + + unsigned int size = Scorer->GetMult(); + for (unsigned int i = 0; i < size; i++) { + double E = Scorer->GetEnergy(i); + double Energy = RandGauss::shoot(E, (E * 0.0325637) / (2.35 * pow(E - 0.00975335, 0.475759))); + if (Energy > EnergyThreshold) { + double Time = Scorer->GetTime(i); + int DetectorNbr = Scorer->GetLevel(i)[0]; + m_Event->SetNanaLaBr3(DetectorNbr, Energy, Energy, (unsigned short)Time, 0, 0); } } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Nana::InitializeScorers(){ +void Nana::InitializeScorers() { vector<G4int> NestingLevel; NestingLevel.push_back(1); // LaBr3 Associate Scorer bool already_exist = false; - m_LaBr3Scorer = CheckScorer("Nana_LaBr3Scorer",already_exist); + m_LaBr3Scorer = CheckScorer("Nana_LaBr3Scorer", already_exist); // if the scorer were created previously nothing else need to be made - if(already_exist) return; + if (already_exist) + return; - G4VPrimitiveScorer* LaBr3Scorer = - new CalorimeterScorers::PS_Calorimeter("NanaLaBr3",NestingLevel); - //and register it to the multifunctionnal detector + G4VPrimitiveScorer* LaBr3Scorer = new CalorimeterScorers::PS_Calorimeter("NanaLaBr3", NestingLevel); + // and register it to the multifunctionnal detector m_LaBr3Scorer->RegisterPrimitive(LaBr3Scorer); // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_LaBr3Scorer) ; + G4SDManager::GetSDMpointer()->AddNewDetector(m_LaBr3Scorer); } //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* Nana::Construct(){ - return (NPS::VDetector*) new Nana(); -} +NPS::VDetector* Nana::Construct() { return (NPS::VDetector*)new Nana(); } //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_nana{ - public: - proxy_nps_nana(){ - NPS::DetectorFactory::getInstance()->AddToken("Nana","Nana"); - NPS::DetectorFactory::getInstance()->AddDetector("Nana",Nana::Construct); - } - }; - - proxy_nps_nana p_nps_nana; +extern "C" { +class proxy_nps_nana { + public: + proxy_nps_nana() { + NPS::DetectorFactory::getInstance()->AddToken("Nana", "Nana"); + NPS::DetectorFactory::getInstance()->AddDetector("Nana", Nana::Construct); + } +}; + +proxy_nps_nana p_nps_nana; } diff --git a/NPSimulation/Detectors/Paris/Paris.cc b/NPSimulation/Detectors/Paris/Paris.cc index 21d25b80a..8ab683330 100644 --- a/NPSimulation/Detectors/Paris/Paris.cc +++ b/NPSimulation/Detectors/Paris/Paris.cc @@ -20,21 +20,21 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> +#include <sstream> using namespace std; -//Geant4 -#include "G4VSolid.hh" +// Geant4 #include "G4Box.hh" -#include "G4Tubs.hh" -#include "G4UnionSolid.hh" -#include "G4SubtractionSolid.hh" +#include "G4Colour.hh" +#include "G4PVPlacement.hh" #include "G4SDManager.hh" +#include "G4SubtractionSolid.hh" #include "G4Transform3D.hh" -#include "G4PVPlacement.hh" -#include "G4Colour.hh" +#include "G4Tubs.hh" +#include "G4UnionSolid.hh" +#include "G4VSolid.hh" // NPS #include "Paris.hh" @@ -53,11 +53,11 @@ using namespace CLHEP; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Paris Specific Method -Paris::Paris(){ +Paris::Paris() { m_Event = new TParisData(); - // Orange - m_NaIVisAtt = new G4VisAttributes(G4Colour(1, 0.5, 0)) ; + // Orange + m_NaIVisAtt = new G4VisAttributes(G4Colour(1, 0.5, 0)); // Blue m_LaBr3VisAtt = new G4VisAttributes(G4Colour(0, 0.5, 1)); @@ -66,36 +66,36 @@ Paris::Paris(){ m_PMTVisAtt = new G4VisAttributes(G4Colour(0.1, 0.1, 0.1)); // Grey wireframe - m_PhoswichCasingVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5,0.2)); + m_PhoswichCasingVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5, 0.2)); // White wireframe - m_ClusterCasingVisAtt = new G4VisAttributes(G4Colour(0.7, 0.7, 0.7)); + m_ClusterCasingVisAtt = new G4VisAttributes(G4Colour(0.7, 0.7, 0.7)); m_LogicalPhoswich = 0; - m_LogicalCluster = 0; - m_NaIScorer = 0 ; - m_LaBr3Scorer = 0 ; + m_LogicalCluster = 0; + m_NaIScorer = 0; + m_LaBr3Scorer = 0; } -Paris::~Paris(){ -} +Paris::~Paris() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Paris::AddCluster(G4ThreeVector Pos1, G4ThreeVector Pos2, G4ThreeVector Pos3, G4ThreeVector Pos4){ - G4ThreeVector Pos=(Pos1+Pos2+Pos3+Pos4)/4.; - G4ThreeVector u = Pos1-Pos2; - G4ThreeVector v = Pos1-Pos4; - u = u.unit(); v = v.unit(); +void Paris::AddCluster(G4ThreeVector Pos1, G4ThreeVector Pos2, G4ThreeVector Pos3, G4ThreeVector Pos4) { + G4ThreeVector Pos = (Pos1 + Pos2 + Pos3 + Pos4) / 4.; + G4ThreeVector u = Pos1 - Pos2; + G4ThreeVector v = Pos1 - Pos4; + u = u.unit(); + v = v.unit(); G4ThreeVector w = v.cross(u); - Pos = Pos + w*Length*0.5; + Pos = Pos + w * Length * 0.5; - m_Type.push_back(1); + m_Type.push_back(1); m_Pos.push_back(Pos); - m_Rot.push_back(new G4RotationMatrix(u,v,w)); + m_Rot.push_back(new G4RotationMatrix(u, v, w)); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Paris::AddCluster(G4ThreeVector Pos, double beta_u, double beta_v, double beta_w){ +void Paris::AddCluster(G4ThreeVector Pos, double beta_u, double beta_v, double beta_w) { double Theta = Pos.theta(); double Phi = Pos.phi(); @@ -111,10 +111,10 @@ void Paris::AddCluster(G4ThreeVector Pos, double beta_u, double beta_v, double b v = v.unit(); u = u.unit(); - G4RotationMatrix* r = new G4RotationMatrix(u,v,w); - r->rotate(beta_u,u); - r->rotate(beta_v,v); - r->rotate(beta_w,w); + G4RotationMatrix* r = new G4RotationMatrix(u, v, w); + r->rotate(beta_u, u); + r->rotate(beta_v, v); + r->rotate(beta_w, w); m_Type.push_back(1); m_Pos.push_back(Pos); @@ -122,21 +122,22 @@ void Paris::AddCluster(G4ThreeVector Pos, double beta_u, double beta_v, double b } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Paris::AddPhoswich(G4ThreeVector Pos1, G4ThreeVector Pos2, G4ThreeVector Pos3, G4ThreeVector Pos4){ - G4ThreeVector Pos=(Pos1+Pos2+Pos3+Pos4)/4.; - G4ThreeVector u = Pos1-Pos2; - G4ThreeVector v = Pos1-Pos4; - u = u.unit(); v = v.unit(); +void Paris::AddPhoswich(G4ThreeVector Pos1, G4ThreeVector Pos2, G4ThreeVector Pos3, G4ThreeVector Pos4) { + G4ThreeVector Pos = (Pos1 + Pos2 + Pos3 + Pos4) / 4.; + G4ThreeVector u = Pos1 - Pos2; + G4ThreeVector v = Pos1 - Pos4; + u = u.unit(); + v = v.unit(); G4ThreeVector w = Pos.unit(); - Pos = Pos + w*Length*0.5; + Pos = Pos + w * Length * 0.5; - m_Type.push_back(0); + m_Type.push_back(0); m_Pos.push_back(Pos); - m_Rot.push_back(new G4RotationMatrix(u,v,w)); + m_Rot.push_back(new G4RotationMatrix(u, v, w)); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Paris::AddPhoswich(G4ThreeVector Pos, double beta_u, double beta_v, double beta_w){ +void Paris::AddPhoswich(G4ThreeVector Pos, double beta_u, double beta_v, double beta_w) { double Theta = Pos.theta(); double Phi = Pos.phi(); @@ -152,10 +153,10 @@ void Paris::AddPhoswich(G4ThreeVector Pos, double beta_u, double beta_v, double v = v.unit(); u = u.unit(); - G4RotationMatrix* r = new G4RotationMatrix(u,v,w); - r->rotate(beta_u,u); - r->rotate(beta_v,v); - r->rotate(beta_w,w); + G4RotationMatrix* r = new G4RotationMatrix(u, v, w); + r->rotate(beta_u, u); + r->rotate(beta_v, v); + r->rotate(beta_w, w); m_Type.push_back(0); m_Pos.push_back(Pos); @@ -166,60 +167,60 @@ void Paris::AddPhoswich(G4ThreeVector Pos, double beta_u, double beta_v, double // Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Paris::ReadConfiguration(NPL::InputParser parser){ +void Paris::ReadConfiguration(NPL::InputParser parser) { vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Paris"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " detectors found " << endl; - - vector<string> cart = {"A","B","C","D"}; - vector<string> sphe = {"R","THETA","PHI","BETA"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(cart) && blocks[i]->GetMainValue()=="Cluster"){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Cluster " << i+1 << endl; - G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("A","mm")); - G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("B","mm")); - G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("C","mm")); - G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("D","mm")); - - AddCluster(A,B,C,D); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + + vector<string> cart = {"A", "B", "C", "D"}; + vector<string> sphe = {"R", "THETA", "PHI", "BETA"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(cart) && blocks[i]->GetMainValue() == "Cluster") { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Cluster " << i + 1 << endl; + G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("A", "mm")); + G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("B", "mm")); + G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("C", "mm")); + G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("D", "mm")); + + AddCluster(A, B, C, D); } - else if(blocks[i]->HasTokenList(sphe)&& blocks[i]->GetMainValue()=="Cluster"){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Cluster " << i+1 << endl; - double R = blocks[i]->GetDouble("R","mm"); - double Theta = blocks[i]->GetDouble("THETA","deg"); - double Phi = blocks[i]->GetDouble("PHI","deg"); - vector<double> Beta = blocks[i]->GetVectorDouble("BETA","deg"); - R = R + 0.5*Length; - G4ThreeVector Pos(R*sin(Theta)*cos(Phi),R*sin(Theta)*sin(Phi),R*cos(Theta)); - AddCluster(Pos,Beta[0],Beta[1],Beta[2]); + else if (blocks[i]->HasTokenList(sphe) && blocks[i]->GetMainValue() == "Cluster") { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Cluster " << i + 1 << endl; + double R = blocks[i]->GetDouble("R", "mm"); + double Theta = blocks[i]->GetDouble("THETA", "deg"); + double Phi = blocks[i]->GetDouble("PHI", "deg"); + vector<double> Beta = blocks[i]->GetVectorDouble("BETA", "deg"); + R = R + 0.5 * Length; + G4ThreeVector Pos(R * sin(Theta) * cos(Phi), R * sin(Theta) * sin(Phi), R * cos(Theta)); + AddCluster(Pos, Beta[0], Beta[1], Beta[2]); } - else if(blocks[i]->HasTokenList(cart)&& blocks[i]->GetMainValue()=="Phoswich"){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Phoswich" << i+1 << endl; - G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("A","mm")); - G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("B","mm")); - G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("C","mm")); - G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("D","mm")); - - AddPhoswich(A,B,C,D); + else if (blocks[i]->HasTokenList(cart) && blocks[i]->GetMainValue() == "Phoswich") { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Phoswich" << i + 1 << endl; + G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("A", "mm")); + G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("B", "mm")); + G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("C", "mm")); + G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("D", "mm")); + + AddPhoswich(A, B, C, D); } - else if(blocks[i]->HasTokenList(sphe)&& blocks[i]->GetMainValue()=="Phoswich"){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Phoswich " << i+1 << endl; - double R = blocks[i]->GetDouble("R","mm"); - double Theta = blocks[i]->GetDouble("THETA","deg"); - double Phi = blocks[i]->GetDouble("PHI","deg"); - vector<double> Beta = blocks[i]->GetVectorDouble("BETA","deg"); - R = R + 0.5*Length; - G4ThreeVector Pos(R*sin(Theta)*cos(Phi),R*sin(Theta)*sin(Phi),R*cos(Theta)); - AddPhoswich(Pos,Beta[0],Beta[1],Beta[2]); + else if (blocks[i]->HasTokenList(sphe) && blocks[i]->GetMainValue() == "Phoswich") { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Phoswich " << i + 1 << endl; + double R = blocks[i]->GetDouble("R", "mm"); + double Theta = blocks[i]->GetDouble("THETA", "deg"); + double Phi = blocks[i]->GetDouble("PHI", "deg"); + vector<double> Beta = blocks[i]->GetVectorDouble("BETA", "deg"); + R = R + 0.5 * Length; + G4ThreeVector Pos(R * sin(Theta) * cos(Phi), R * sin(Theta) * sin(Phi), R * cos(Theta)); + AddPhoswich(Pos, Beta[0], Beta[1], Beta[2]); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } @@ -229,92 +230,72 @@ void Paris::ReadConfiguration(NPL::InputParser parser){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void Paris::ConstructDetector(G4LogicalVolume* world){ +void Paris::ConstructDetector(G4LogicalVolume* world) { unsigned int mysize = m_Pos.size(); - for(unsigned int i = 0 ; i < mysize ; i++){ - if(m_Type[i]) - new G4PVPlacement(G4Transform3D(*m_Rot[i], m_Pos[i]), ConstructCluster(), "ParisCluster", world, false, i+1); + for (unsigned int i = 0; i < mysize; i++) { + if (m_Type[i]) + new G4PVPlacement(G4Transform3D(*m_Rot[i], m_Pos[i]), ConstructCluster(), "ParisCluster", world, false, i + 1); else - new G4PVPlacement(G4Transform3D(*m_Rot[i], m_Pos[i]), ConstructPhoswich(), "ParisPhoswich", world, false, i+1); + new G4PVPlacement(G4Transform3D(*m_Rot[i], m_Pos[i]), ConstructPhoswich(), "ParisPhoswich", world, false, i + 1); } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Paris::ConstructPhoswich(){ +G4LogicalVolume* Paris::ConstructPhoswich() { - if(!m_LogicalPhoswich){ + if (!m_LogicalPhoswich) { G4Material* Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); G4Material* Alu = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); G4Material* NaI = MaterialManager::getInstance()->GetMaterialFromLibrary("NaI"); G4Material* LaBr3 = MaterialManager::getInstance()->GetMaterialFromLibrary("LaBr3"); - G4Box* solidParisPhoswich = new G4Box("SolidParisPhoswich", 0.5*PhoswichCasingWidth, 0.5*PhoswichCasingWidth, 0.5*PhoswichCasingLenth+0.5*PMTLength); + G4Box* solidParisPhoswich = new G4Box("SolidParisPhoswich", 0.5 * PhoswichCasingWidth, 0.5 * PhoswichCasingWidth, + 0.5 * PhoswichCasingLenth + 0.5 * PMTLength); m_LogicalPhoswich = new G4LogicalVolume(solidParisPhoswich, Vacuum, "LogicParisPhoswich", 0, 0, 0); - m_LogicalPhoswich->SetVisAttributes(G4VisAttributes::Invisible); + m_LogicalPhoswich->SetVisAttributes(G4VisAttributes::GetInvisible()); // Phoswich construction // Casing - G4Box* solidCasing = new G4Box("SolidParisPhoswichCasing", 0.5*PhoswichCasingWidth, 0.5*PhoswichCasingWidth, 0.5*PhoswichCasingLenth); + G4Box* solidCasing = new G4Box("SolidParisPhoswichCasing", 0.5 * PhoswichCasingWidth, 0.5 * PhoswichCasingWidth, + 0.5 * PhoswichCasingLenth); G4LogicalVolume* LogicalCasing = new G4LogicalVolume(solidCasing, Alu, "LogicParisPhoswichCasing", 0, 0, 0); LogicalCasing->SetVisAttributes(m_PhoswichCasingVisAtt); - new G4PVPlacement(0, - G4ThreeVector(0,0,-PMTLength), - LogicalCasing, - "ParisPhoswich_Casing", - m_LogicalPhoswich, - false, - 0); + new G4PVPlacement(0, G4ThreeVector(0, 0, -PMTLength), LogicalCasing, "ParisPhoswich_Casing", m_LogicalPhoswich, + false, 0); // PMT - G4Tubs* solidPMT = new G4Tubs("SolidPMT",0,PMTRadius,0.5*PMTLength,0,360*deg); - G4LogicalVolume* LogicalPMT = new G4LogicalVolume(solidPMT, Alu, "LogicPMT" ,0,0,0); - new G4PVPlacement(0, - G4ThreeVector(0,0,0.5*Length-PMTLength), - LogicalPMT, - "ParisPhoswich_PMT", - m_LogicalPhoswich, - false, - 0); + G4Tubs* solidPMT = new G4Tubs("SolidPMT", 0, PMTRadius, 0.5 * PMTLength, 0, 360 * deg); + G4LogicalVolume* LogicalPMT = new G4LogicalVolume(solidPMT, Alu, "LogicPMT", 0, 0, 0); + new G4PVPlacement(0, G4ThreeVector(0, 0, 0.5 * Length - PMTLength), LogicalPMT, "ParisPhoswich_PMT", + m_LogicalPhoswich, false, 0); LogicalPMT->SetVisAttributes(m_PMTVisAtt); // LaBr3 - G4Box* solidLaBr3Stage = new G4Box("solidLaBr3Stage", 0.5*LaBr3Face, 0.5*LaBr3Face, 0.5*LaBr3Thickness); + G4Box* solidLaBr3Stage = new G4Box("solidLaBr3Stage", 0.5 * LaBr3Face, 0.5 * LaBr3Face, 0.5 * LaBr3Thickness); G4LogicalVolume* logicLaBr3Stage = new G4LogicalVolume(solidLaBr3Stage, LaBr3, "logicLaBr3Stage", 0, 0, 0); - G4ThreeVector positionLaBr3Stage = G4ThreeVector(0, 0, LaBr3Stage_PosZ); + G4ThreeVector positionLaBr3Stage = G4ThreeVector(0, 0, LaBr3Stage_PosZ); - new G4PVPlacement(0, - positionLaBr3Stage, - logicLaBr3Stage, - "ParisPhoswich_LaBr3Stage", - LogicalCasing, - false, - 0); + new G4PVPlacement(0, positionLaBr3Stage, logicLaBr3Stage, "ParisPhoswich_LaBr3Stage", LogicalCasing, false, 0); // Set LaBr3 sensible logicLaBr3Stage->SetSensitiveDetector(m_LaBr3Scorer); - // Visualisation of LaBr3 stage + // Visualisation of LaBr3 stage logicLaBr3Stage->SetVisAttributes(m_LaBr3VisAtt); // NaI - G4ThreeVector positionNaIStage = G4ThreeVector(0, 0, NaIStage_PosZ); + G4ThreeVector positionNaIStage = G4ThreeVector(0, 0, NaIStage_PosZ); - G4Box* solidNaIStage = new G4Box("solidNaIStage", 0.5*NaIFace, 0.5*NaIFace, 0.5*NaIThickness); + G4Box* solidNaIStage = new G4Box("solidNaIStage", 0.5 * NaIFace, 0.5 * NaIFace, 0.5 * NaIThickness); G4LogicalVolume* logicNaIStage = new G4LogicalVolume(solidNaIStage, NaI, "logicNaIStage", 0, 0, 0); - new G4PVPlacement(0, - positionNaIStage, - logicNaIStage, - "ParisPhoswich_NaIStage", - LogicalCasing, - false, - 0); + new G4PVPlacement(0, positionNaIStage, logicNaIStage, "ParisPhoswich_NaIStage", LogicalCasing, false, 0); // Set NaI sensible logicNaIStage->SetSensitiveDetector(m_NaIScorer); - // Visualisation of the NaI stage + // Visualisation of the NaI stage logicNaIStage->SetVisAttributes(m_NaIVisAtt); } @@ -322,177 +303,162 @@ G4LogicalVolume* Paris::ConstructPhoswich(){ } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Paris::ConstructCluster(){ +G4LogicalVolume* Paris::ConstructCluster() { - if(!m_LogicalCluster){ - G4Material* Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); - G4Material* Alu = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); + if (!m_LogicalCluster) { + G4Material* Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); + G4Material* Alu = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); // Mother Volume - G4Box* solidParisCluster1 = new G4Box("SolidParisCluster1", 0.5*FaceFront, 0.5*FaceFront, 0.5*Length); - G4Box* solidParisCluster2 = new G4Box("SolidParisCluster2", 0.5*ClusterFrameWidth, 0.5*ClusterFrameWidth, 0.5*ClusterFrameLength); + G4Box* solidParisCluster1 = new G4Box("SolidParisCluster1", 0.5 * FaceFront, 0.5 * FaceFront, 0.5 * Length); + G4Box* solidParisCluster2 = + new G4Box("SolidParisCluster2", 0.5 * ClusterFrameWidth, 0.5 * ClusterFrameWidth, 0.5 * ClusterFrameLength); // The cluster is made of a metal frame that hold the phoswich via the pmt - G4ThreeVector FramePos(0,0,Length*0.5-PMTLength+ClusterFrameLength*0.5+ClusterOffset); - G4UnionSolid* solidParisCluster = new G4UnionSolid("solidParisCluster",solidParisCluster1,solidParisCluster2,0,FramePos); + G4ThreeVector FramePos(0, 0, Length * 0.5 - PMTLength + ClusterFrameLength * 0.5 + ClusterOffset); + G4UnionSolid* solidParisCluster = + new G4UnionSolid("solidParisCluster", solidParisCluster1, solidParisCluster2, 0, FramePos); m_LogicalCluster = new G4LogicalVolume(solidParisCluster, Vacuum, "LogicSolidParisCluster", 0, 0, 0); - m_LogicalCluster->SetVisAttributes(G4VisAttributes::Invisible); + m_LogicalCluster->SetVisAttributes(G4VisAttributes::GetInvisible()); - if(!m_LogicalPhoswich) ConstructPhoswich(); + if (!m_LogicalPhoswich) + ConstructPhoswich(); // The frame is a plate with hole for the PMT G4VSolid* solidClusterFrame = solidParisCluster2; - G4ThreeVector Origin(-PhoswichCasingWidth,-PhoswichCasingWidth,0.5*PMTLength); - G4Tubs* solidPMT = new G4Tubs("SolidPMT",0,PMTRadius,10*PMTLength,0,360*deg); + G4ThreeVector Origin(-PhoswichCasingWidth, -PhoswichCasingWidth, 0.5 * PMTLength); + G4Tubs* solidPMT = new G4Tubs("SolidPMT", 0, PMTRadius, 10 * PMTLength, 0, 360 * deg); // A cluster is a 3 by 3 aggregat of phoswich unsigned int PhoswichNbr = 1; - for(unsigned int i = 0 ; i < 3 ; i++){ - for(unsigned int j = 0 ; j <3 ; j++){ - G4ThreeVector Pos = Origin + G4ThreeVector(i*PhoswichCasingWidth,j*PhoswichCasingWidth,0); - new G4PVPlacement(0, - Pos, - m_LogicalPhoswich, - "Paris_Phoswich", - m_LogicalCluster, - false, - PhoswichNbr++); + for (unsigned int i = 0; i < 3; i++) { + for (unsigned int j = 0; j < 3; j++) { + G4ThreeVector Pos = Origin + G4ThreeVector(i * PhoswichCasingWidth, j * PhoswichCasingWidth, 0); + new G4PVPlacement(0, Pos, m_LogicalPhoswich, "Paris_Phoswich", m_LogicalCluster, false, PhoswichNbr++); // make room for the PMT in the cluster frame - solidClusterFrame = new G4SubtractionSolid("ClusterFrame",solidClusterFrame,solidPMT,0,Pos); + solidClusterFrame = new G4SubtractionSolid("ClusterFrame", solidClusterFrame, solidPMT, 0, Pos); } } - G4LogicalVolume* LogicalClusterFrame = new G4LogicalVolume(solidClusterFrame, Alu, "LogicSolidClusterFrame", 0, 0, 0); + G4LogicalVolume* LogicalClusterFrame = + new G4LogicalVolume(solidClusterFrame, Alu, "LogicSolidClusterFrame", 0, 0, 0); LogicalClusterFrame->SetVisAttributes(m_ClusterCasingVisAtt); - new G4PVPlacement(0, - FramePos, - LogicalClusterFrame, - "Paris_ClusterFrame", - m_LogicalCluster, - false, - 0); - + new G4PVPlacement(0, FramePos, LogicalClusterFrame, "Paris_ClusterFrame", m_LogicalCluster, false, 0); } return m_LogicalCluster; - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void Paris::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("Paris")){ - pTree->Branch("Paris", "TParisData", &m_Event) ; +void Paris::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("Paris")) { + pTree->Branch("Paris", "TParisData", &m_Event); } - pTree->SetBranchAddress("Paris", &m_Event) ; + pTree->SetBranchAddress("Paris", &m_Event); } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Paris::ReadSensitive(const G4Event* ){ +void Paris::ReadSensitive(const G4Event*) { m_Event->Clear(); /////////// // LaBr3 - CalorimeterScorers::PS_Calorimeter* ScorerLaBr= (CalorimeterScorers::PS_Calorimeter*) m_LaBr3Scorer->GetPrimitive(0); + CalorimeterScorers::PS_Calorimeter* ScorerLaBr = (CalorimeterScorers::PS_Calorimeter*)m_LaBr3Scorer->GetPrimitive(0); - unsigned int sizeLaBr = ScorerLaBr->GetMult(); - for(unsigned int i = 0 ; i < sizeLaBr ; i++){ - vector<unsigned int> level = ScorerLaBr->GetLevel(i); - double Energy = RandGauss::shoot(ScorerLaBr->GetEnergy(i),ResoFirstStage); + unsigned int sizeLaBr = ScorerLaBr->GetMult(); + for (unsigned int i = 0; i < sizeLaBr; i++) { + vector<unsigned int> level = ScorerLaBr->GetLevel(i); + double Energy = RandGauss::shoot(ScorerLaBr->GetEnergy(i), ResoFirstStage); - if(Energy>EnergyThreshold){ + if (Energy > EnergyThreshold) { double Time = ScorerLaBr->GetTime(i); int PhoswichNbr = level[0]; int ClusterNbr = level[1]; - m_Event->SetParisLaBr3E(ClusterNbr,PhoswichNbr,Energy); - m_Event->SetParisLaBr3T(ClusterNbr,PhoswichNbr,Time); + m_Event->SetParisLaBr3E(ClusterNbr, PhoswichNbr, Energy); + m_Event->SetParisLaBr3T(ClusterNbr, PhoswichNbr, Time); } } /////////// // NaI - CalorimeterScorers::PS_Calorimeter* ScorerNaI= (CalorimeterScorers::PS_Calorimeter*) m_NaIScorer->GetPrimitive(0); + CalorimeterScorers::PS_Calorimeter* ScorerNaI = (CalorimeterScorers::PS_Calorimeter*)m_NaIScorer->GetPrimitive(0); - unsigned int sizeNaI = ScorerNaI->GetMult(); - for(unsigned int i = 0 ; i < sizeNaI ; i++){ - vector<unsigned int> level = ScorerNaI->GetLevel(i); - double Energy = RandGauss::shoot(ScorerNaI->GetEnergy(i),ResoSecondStage); + unsigned int sizeNaI = ScorerNaI->GetMult(); + for (unsigned int i = 0; i < sizeNaI; i++) { + vector<unsigned int> level = ScorerNaI->GetLevel(i); + double Energy = RandGauss::shoot(ScorerNaI->GetEnergy(i), ResoSecondStage); - if(Energy>EnergyThreshold){ + if (Energy > EnergyThreshold) { double Time = ScorerNaI->GetTime(i); int PhoswichNbr = level[0]; int ClusterNbr = level[1]; - m_Event->SetParisNaIE(ClusterNbr,PhoswichNbr,Energy); - m_Event->SetParisNaIT(ClusterNbr,PhoswichNbr,Time); + m_Event->SetParisNaIE(ClusterNbr, PhoswichNbr, Energy); + m_Event->SetParisNaIT(ClusterNbr, PhoswichNbr, Time); } } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Paris::InitializeScorers(){ +void Paris::InitializeScorers() { vector<G4int> NestingLevel; NestingLevel.push_back(2); NestingLevel.push_back(3); // LaBr3 Associate Scorer bool already_exist = false; - m_LaBr3Scorer = CheckScorer("Paris_LaBr3Scorer",already_exist); + m_LaBr3Scorer = CheckScorer("Paris_LaBr3Scorer", already_exist); // if the scorer were created previously nothing else need to be made - if(already_exist) return; + if (already_exist) + return; - G4VPrimitiveScorer* LaBr3Scorer = - new CalorimeterScorers::PS_Calorimeter("ParisLaBr3",NestingLevel); - //and register it to the multifunctionnal detector + G4VPrimitiveScorer* LaBr3Scorer = new CalorimeterScorers::PS_Calorimeter("ParisLaBr3", NestingLevel); + // and register it to the multifunctionnal detector m_LaBr3Scorer->RegisterPrimitive(LaBr3Scorer); // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_LaBr3Scorer) ; - + G4SDManager::GetSDMpointer()->AddNewDetector(m_LaBr3Scorer); // NaI Associate Scorer already_exist = false; - m_NaIScorer = CheckScorer("Paris_NaIScorer",already_exist); + m_NaIScorer = CheckScorer("Paris_NaIScorer", already_exist); // if the scorer were created previously nothing else need to be made - if(already_exist) return; + if (already_exist) + return; - G4VPrimitiveScorer* NaIScorer = - new CalorimeterScorers::PS_Calorimeter("ParisNaI",NestingLevel); - //and register it to the multifunctionnal detector + G4VPrimitiveScorer* NaIScorer = new CalorimeterScorers::PS_Calorimeter("ParisNaI", NestingLevel); + // and register it to the multifunctionnal detector m_NaIScorer->RegisterPrimitive(NaIScorer); // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_NaIScorer) ; - + G4SDManager::GetSDMpointer()->AddNewDetector(m_NaIScorer); } //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* Paris::Construct(){ - return (NPS::VDetector*) new Paris(); -} +NPS::VDetector* Paris::Construct() { return (NPS::VDetector*)new Paris(); } //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_paris{ - public: - proxy_nps_paris(){ - NPS::DetectorFactory::getInstance()->AddToken("Paris","Paris"); - NPS::DetectorFactory::getInstance()->AddDetector("Paris",Paris::Construct); - } - }; +extern "C" { +class proxy_nps_paris { + public: + proxy_nps_paris() { + NPS::DetectorFactory::getInstance()->AddToken("Paris", "Paris"); + NPS::DetectorFactory::getInstance()->AddDetector("Paris", Paris::Construct); + } +}; - proxy_nps_paris p_nps_proxy; +proxy_nps_paris p_nps_proxy; } diff --git a/NPSimulation/Detectors/Pyramid/Pyramid.cc b/NPSimulation/Detectors/Pyramid/Pyramid.cc index 87a128c6c..733e058fe 100644 --- a/NPSimulation/Detectors/Pyramid/Pyramid.cc +++ b/NPSimulation/Detectors/Pyramid/Pyramid.cc @@ -19,34 +19,33 @@ * Comment: * * * *****************************************************************************/ - + // C++ headers -#include <sstream> #include <cmath> #include <limits> -//G4 Geometry object +#include <sstream> +// G4 Geometry object #include "G4Box.hh" -#include "G4Tubs.hh" #include "G4Cons.hh" -#include "G4UnionSolid.hh" #include "G4ExtrudedSolid.hh" +#include "G4Tubs.hh" #include "G4TwoVector.hh" -//G4 sensitive +#include "G4UnionSolid.hh" +// G4 sensitive #include "G4SDManager.hh" -//G4 various object -#include "G4Material.hh" -#include "G4Transform3D.hh" -#include "G4PVPlacement.hh" +// G4 various object #include "G4Colour.hh" +#include "G4Material.hh" #include "G4PVDivision.hh" +#include "G4PVPlacement.hh" #include "G4SubtractionSolid.hh" +#include "G4Transform3D.hh" // NPS -#include "Pyramid.hh" -#include "NPSDetectorFactory.hh" #include "MaterialManager.hh" #include "NPSDetectorFactory.hh" +#include "Pyramid.hh" #include "SiliconScorers.hh" // NPL @@ -60,94 +59,87 @@ using namespace PYRAMID; using namespace std; using namespace CLHEP; - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Pyramid::Pyramid(){ +Pyramid::Pyramid() { InitializeMaterial(); m_EventPyramid = new TPyramidData(); // Dark Grey - SiliconVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)) ; + SiliconVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)); // Green - PCBVisAtt = new G4VisAttributes(G4Colour(0.2, 0.5, 0.2)) ; + PCBVisAtt = new G4VisAttributes(G4Colour(0.2, 0.5, 0.2)); // Gold Yellow - PADVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.2)) ; + PADVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.2)); // Light Grey - FrameVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)) ; + FrameVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)); // Light Blue - GuardRingVisAtt = new G4VisAttributes(G4Colour(0.1, 0.1, 0.1)) ; + GuardRingVisAtt = new G4VisAttributes(G4Colour(0.1, 0.1, 0.1)); m_boolChamber = false; m_boolInner.clear(); m_boolOuter.clear(); m_ANGLE.clear(); m_Z.clear(); - - m_InnerScorer = 0 ; - m_OuterScorer = 0 ; + m_InnerScorer = 0; + m_OuterScorer = 0; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Pyramid::~Pyramid(){ -} +Pyramid::~Pyramid() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Pyramid::ReadConfiguration(NPL::InputParser parser){ +void Pyramid::ReadConfiguration(NPL::InputParser parser) { vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Pyramid"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) + if (NPOptionManager::getInstance()->GetVerboseLevel()) cout << "//// " << blocks.size() << " detectors found " << endl; - vector<string> token = {"Inner","Outer","Z","ANGLE"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(token)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Pyramid " << i+1 << endl; + vector<string> token = {"Inner", "Outer", "Z", "ANGLE"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(token)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Pyramid " << i + 1 << endl; m_boolInner.push_back(blocks[i]->GetInt("Inner")); m_boolOuter.push_back(blocks[i]->GetInt("Outer")); - //m_boolChamber = blocks[i]->GetInt("Chamber"); - m_Z.push_back(blocks[i]->GetDouble("Z","mm")); - m_ANGLE.push_back(blocks[i]->GetDouble("ANGLE","deg")); + // m_boolChamber = blocks[i]->GetInt("Chamber"); + m_Z.push_back(blocks[i]->GetDouble("Z", "mm")); + m_ANGLE.push_back(blocks[i]->GetDouble("ANGLE", "deg")); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } } blocks.clear(); - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void Pyramid::ConstructDetector(G4LogicalVolume* world){ +void Pyramid::ConstructDetector(G4LogicalVolume* world) { - if(m_boolChamber) + if (m_boolChamber) ConstructChamber(world); - for (unsigned i = 0 ; i < m_boolInner.size() ; i++) - if(m_boolInner[i]) + for (unsigned i = 0; i < m_boolInner.size(); i++) + if (m_boolInner[i]) ConstructInner(world, m_ANGLE[i], m_Z[i]); - for (unsigned i = 0 ; i < m_boolOuter.size() ; i++) - if(m_boolOuter[i]) + for (unsigned i = 0; i < m_boolOuter.size(); i++) + if (m_boolOuter[i]) ConstructOuter(world, m_ANGLE[i], m_Z[i]); - } // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Pyramid::ReadSensitive(const G4Event* event){ +void Pyramid::ReadSensitive(const G4Event* event) { m_EventPyramid->Clear(); - // Inner // NPS::HitsMap<G4double*>* InnerHitMap; std::map<G4int, G4double**>::iterator Inner_itr; @@ -155,36 +147,37 @@ void Pyramid::ReadSensitive(const G4Event* event){ InnerHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(InnerCollectionID)); // Loop on the Inner map - for (Inner_itr = InnerHitMap->GetMap()->begin() ; Inner_itr != InnerHitMap->GetMap()->end() ; Inner_itr++){ + for (Inner_itr = InnerHitMap->GetMap()->begin(); Inner_itr != InnerHitMap->GetMap()->end(); Inner_itr++) { G4double* Info = *(Inner_itr->second); // Downstream Energy - double ED = RandGauss::shoot(Info[0],ResoEnergyInner); - if(ED>EnergyThreshold){ - m_EventPyramid->SetFrontDownstreamE(Info[3],Info[4],ED); - m_EventPyramid->SetFrontDownstreamT(Info[3],Info[4],Info[2]); + double ED = RandGauss::shoot(Info[0], ResoEnergyInner); + if (ED > EnergyThreshold) { + m_EventPyramid->SetFrontDownstreamE(Info[3], Info[4], ED); + m_EventPyramid->SetFrontDownstreamT(Info[3], Info[4], Info[2]); } // Upstream Energy - double EU = RandGauss::shoot(Info[1],ResoEnergyInner); - if(EU>EnergyThreshold){ - m_EventPyramid->SetFrontUpstreamE(Info[3],Info[4],EU); - m_EventPyramid->SetFrontUpstreamT(Info[3],Info[4],Info[2]); - //cout << "Pyramid " << Info[3] << " STRIP " << Info[4] << " " << Info[9]/deg << " " << Info[5] << " " << Info[6] << " " << Info[7] << endl; + double EU = RandGauss::shoot(Info[1], ResoEnergyInner); + if (EU > EnergyThreshold) { + m_EventPyramid->SetFrontUpstreamE(Info[3], Info[4], EU); + m_EventPyramid->SetFrontUpstreamT(Info[3], Info[4], Info[2]); + // cout << "Pyramid " << Info[3] << " STRIP " << Info[4] << " " << Info[9]/deg << " " << Info[5] << " " << Info[6] + // << " " << Info[7] << endl; } // Back Energy - double EB = RandGauss::shoot(Info[1]+Info[0],ResoEnergyInner); - if(EB>EnergyThreshold){ - m_EventPyramid->SetBackE(Info[3],EB); - m_EventPyramid->SetBackT(Info[3],Info[2]); + double EB = RandGauss::shoot(Info[1] + Info[0], ResoEnergyInner); + if (EB > EnergyThreshold) { + m_EventPyramid->SetBackE(Info[3], EB); + m_EventPyramid->SetBackT(Info[3], Info[2]); } - // Interaction Coordinates - ms_InterCoord->SetDetectedPositionX(Info[5]) ; - ms_InterCoord->SetDetectedPositionY(Info[6]) ; - ms_InterCoord->SetDetectedPositionZ(Info[7]) ; - ms_InterCoord->SetDetectedAngleTheta(Info[8]/deg) ; - ms_InterCoord->SetDetectedAnglePhi(Info[9]/deg) ; + // Interaction Coordinates + ms_InterCoord->SetDetectedPositionX(Info[5]); + ms_InterCoord->SetDetectedPositionY(Info[6]); + ms_InterCoord->SetDetectedPositionZ(Info[7]); + ms_InterCoord->SetDetectedAngleTheta(Info[8] / deg); + ms_InterCoord->SetDetectedAnglePhi(Info[9] / deg); } // Clear Map for next event InnerHitMap->clear(); @@ -196,76 +189,65 @@ void Pyramid::ReadSensitive(const G4Event* event){ OuterHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(OuterCollectionID)); // Loop on the Outer map - for (Outer_itr = OuterHitMap->GetMap()->begin() ; Outer_itr != OuterHitMap->GetMap()->end() ; Outer_itr++){ + for (Outer_itr = OuterHitMap->GetMap()->begin(); Outer_itr != OuterHitMap->GetMap()->end(); Outer_itr++) { G4double* Info = *(Outer_itr->second); - double E = RandGauss::shoot(Info[0]/keV,ResoEnergyOuter); - if(E>EnergyThreshold){ - m_EventPyramid->SetOuterE(Info[7],Info[9],E); - m_EventPyramid->SetOuterT(Info[7],Info[9],Info[1]); + double E = RandGauss::shoot(Info[0] / keV, ResoEnergyOuter); + if (E > EnergyThreshold) { + m_EventPyramid->SetOuterE(Info[7], Info[9], E); + m_EventPyramid->SetOuterT(Info[7], Info[9], Info[1]); } - // Interaction Coordinates - ms_InterCoord->SetDetectedPositionX(Info[5]) ; - ms_InterCoord->SetDetectedPositionY(Info[6]) ; - ms_InterCoord->SetDetectedPositionZ(Info[7]) ; - ms_InterCoord->SetDetectedAngleTheta(Info[8]/deg) ; - ms_InterCoord->SetDetectedAnglePhi(Info[9]/deg) ; + // Interaction Coordinates + ms_InterCoord->SetDetectedPositionX(Info[5]); + ms_InterCoord->SetDetectedPositionY(Info[6]); + ms_InterCoord->SetDetectedPositionZ(Info[7]); + ms_InterCoord->SetDetectedAngleTheta(Info[8] / deg); + ms_InterCoord->SetDetectedAnglePhi(Info[9] / deg); } // Clear Map for next event OuterHitMap->clear(); - - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Pyramid::InitializeScorers(){ - //Look for previous definition of the scorer (geometry reload) +void Pyramid::InitializeScorers() { + // Look for previous definition of the scorer (geometry reload) bool already_exist = false; - m_InnerScorer = CheckScorer("Pyramid_InnerScorer",already_exist); - m_OuterScorer = CheckScorer("Pyramid_OuterScorer",already_exist); - + m_InnerScorer = CheckScorer("Pyramid_InnerScorer", already_exist); + m_OuterScorer = CheckScorer("Pyramid_OuterScorer", already_exist); // if the scorer were created previously nothing else need to be made - if(already_exist) return; + if (already_exist) + return; - G4VPrimitiveScorer* Inner = new SILICONSCORERS::PS_Silicon_Resistive("Inner",1, - Inner_ActiveWafer_Length, - Inner_ActiveWafer_Width, - Inner_NumberOfStrip); + G4VPrimitiveScorer* Inner = new SILICONSCORERS::PS_Silicon_Resistive("Inner", 1, Inner_ActiveWafer_Length, + Inner_ActiveWafer_Width, Inner_NumberOfStrip); m_InnerScorer->RegisterPrimitive(Inner); - G4VPrimitiveScorer* Outer = new SILICONSCORERS::PS_Silicon_Rectangle("Outer",1, - Inner_ActiveWafer_Length, - Inner_ActiveWafer_Width, - 1, - Outer_NumberOfStrip); + G4VPrimitiveScorer* Outer = new SILICONSCORERS::PS_Silicon_Rectangle("Outer", 1, Inner_ActiveWafer_Length, + Inner_ActiveWafer_Width, 1, Outer_NumberOfStrip); m_OuterScorer->RegisterPrimitive(Outer); - // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_InnerScorer) ; - G4SDManager::GetSDMpointer()->AddNewDetector(m_OuterScorer) ; - + G4SDManager::GetSDMpointer()->AddNewDetector(m_InnerScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_OuterScorer); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Pyramid::InitializeRootOutput(){ - TTree *pTree = RootOutput::getInstance()->GetTree(); - if(!pTree->FindBranch("Pyramid")){ - pTree->Branch("Pyramid", "TPyramidData", &m_EventPyramid) ; +void Pyramid::InitializeRootOutput() { + TTree* pTree = RootOutput::getInstance()->GetTree(); + if (!pTree->FindBranch("Pyramid")) { + pTree->Branch("Pyramid", "TPyramidData", &m_EventPyramid); } - // This insure that the object are correctly bind in case of // a redifinition of the geometry in the simulation - pTree->SetBranchAddress("Pyramid", &m_EventPyramid) ; - + pTree->SetBranchAddress("Pyramid", &m_EventPyramid); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Pyramid::ConstructInner(G4LogicalVolume* world, double angle, double z){ +void Pyramid::ConstructInner(G4LogicalVolume* world, double angle, double z) { // Pyramid Pyramid // The Pyramid is made of 4 identical resistive strip detector // The PCB is made from a G4ExtrudeSolid, because it has beveled edge @@ -276,100 +258,74 @@ void Pyramid::ConstructInner(G4LogicalVolume* world, double angle, double z){ // Start by making a full pcb // We start by the definition of the point forming a PCB cross section vector<G4TwoVector> PCBCrossSection; - double l1 = Inner_PCB_Thickness*0.5/tan(Inner_PCB_Bevel1_Theta); - double l2 = Inner_PCB_Thickness*0.5/tan(Inner_PCB_Bevel2_Theta); + double l1 = Inner_PCB_Thickness * 0.5 / tan(Inner_PCB_Bevel1_Theta); + double l2 = Inner_PCB_Thickness * 0.5 / tan(Inner_PCB_Bevel2_Theta); - PCBCrossSection.push_back(G4TwoVector(Inner_PCB_Width/2.-l2,-Inner_PCB_Thickness*0.5)); - PCBCrossSection.push_back(G4TwoVector(Inner_PCB_Width/2.,0)); - PCBCrossSection.push_back(G4TwoVector(Inner_PCB_Width/2.-l1,Inner_PCB_Thickness*0.5)); + PCBCrossSection.push_back(G4TwoVector(Inner_PCB_Width / 2. - l2, -Inner_PCB_Thickness * 0.5)); + PCBCrossSection.push_back(G4TwoVector(Inner_PCB_Width / 2., 0)); + PCBCrossSection.push_back(G4TwoVector(Inner_PCB_Width / 2. - l1, Inner_PCB_Thickness * 0.5)); - PCBCrossSection.push_back(G4TwoVector(-Inner_PCB_Width/2.+l1,Inner_PCB_Thickness*0.5)); - PCBCrossSection.push_back(G4TwoVector(-Inner_PCB_Width/2.,0)); - PCBCrossSection.push_back(G4TwoVector(-Inner_PCB_Width/2.+l2,-Inner_PCB_Thickness*0.5)); + PCBCrossSection.push_back(G4TwoVector(-Inner_PCB_Width / 2. + l1, Inner_PCB_Thickness * 0.5)); + PCBCrossSection.push_back(G4TwoVector(-Inner_PCB_Width / 2., 0)); + PCBCrossSection.push_back(G4TwoVector(-Inner_PCB_Width / 2. + l2, -Inner_PCB_Thickness * 0.5)); - G4ExtrudedSolid* PCBFull = - new G4ExtrudedSolid("PCBFull", - PCBCrossSection, - Inner_PCB_Length/2., - G4TwoVector(0,0),1, - G4TwoVector(0,0),1); + G4ExtrudedSolid* PCBFull = new G4ExtrudedSolid("PCBFull", PCBCrossSection, Inner_PCB_Length / 2., G4TwoVector(0, 0), + 1, G4TwoVector(0, 0), 1); // A box having Wafer dimension but thicker than the PCB // Will be used to remove material from the PCB to have space for the wafer // Calculate the hole shift within the PCB - G4ThreeVector HoleShift = G4ThreeVector( - 0, - 0, - Inner_PCB_Offset-(Inner_PCB_Length/2-Inner_PCB_HoleLength/2)); + G4ThreeVector HoleShift = G4ThreeVector(0, 0, Inner_PCB_Offset - (Inner_PCB_Length / 2 - Inner_PCB_HoleLength / 2)); - G4Box* HoleShape = new G4Box("HoleShape", - Inner_ActiveWafer_Width/2., - Inner_PCB_Thickness/2.+0.1*mm, - Inner_PCB_HoleLength/2.); + G4Box* HoleShape = new G4Box("HoleShape", Inner_ActiveWafer_Width / 2., Inner_PCB_Thickness / 2. + 0.1 * mm, + Inner_PCB_HoleLength / 2.); - G4Box* WaferShape = new G4Box("WaferShape", - Inner_InertWafer_Width/2., - Inner_PCB_Thickness/2., - Inner_InertWafer_Length/2.); + G4Box* WaferShape = + new G4Box("WaferShape", Inner_InertWafer_Width / 2., Inner_PCB_Thickness / 2., Inner_InertWafer_Length / 2.); // The Silicon Wafer itself - G4Box* InertWaferFull = new G4Box("InertWaferFull", - Inner_InertWafer_Width/2., - Inner_InertWafer_Thickness/2., - Inner_InertWafer_Length/2.); - - G4Box* ActiveWafer = new G4Box("ActiveWafer", - Inner_ActiveWafer_Width/2., - Inner_ActiveWafer_Thickness/2., - Inner_ActiveWafer_Length/2.); + G4Box* InertWaferFull = new G4Box("InertWaferFull", Inner_InertWafer_Width / 2., Inner_InertWafer_Thickness / 2., + Inner_InertWafer_Length / 2.); - G4Box* DeadLayer = new G4Box("DeadLayer", - Inner_ActiveWafer_Width/2., - Inner_ActiveWafer_DeadLayerThickness/2., - Inner_ActiveWafer_Length/2.); + G4Box* ActiveWafer = new G4Box("ActiveWafer", Inner_ActiveWafer_Width / 2., Inner_ActiveWafer_Thickness / 2., + Inner_ActiveWafer_Length / 2.); - G4Box* ActiveWaferShape = new G4Box("ActiveWaferShape", - Inner_ActiveWafer_Width/2., - Inner_PCB_Thickness/2., - Inner_ActiveWafer_Length/2.); + G4Box* DeadLayer = new G4Box("DeadLayer", Inner_ActiveWafer_Width / 2., Inner_ActiveWafer_DeadLayerThickness / 2., + Inner_ActiveWafer_Length / 2.); + G4Box* ActiveWaferShape = new G4Box("ActiveWaferShape", Inner_ActiveWafer_Width / 2., Inner_PCB_Thickness / 2., + Inner_ActiveWafer_Length / 2.); // Substracting the hole Shape from the Stock PCB - G4SubtractionSolid* PCB_1 = new G4SubtractionSolid("PCB_1", PCBFull, HoleShape, - new G4RotationMatrix,HoleShift); + G4SubtractionSolid* PCB_1 = new G4SubtractionSolid("PCB_1", PCBFull, HoleShape, new G4RotationMatrix, HoleShift); // Substracting the wafer space from the Stock PCB - G4SubtractionSolid* PCB = new G4SubtractionSolid("PCB", PCB_1, WaferShape, - new G4RotationMatrix, - G4ThreeVector(0,Inner_PCB_Thickness/2.-Inner_PCB_WaferDepth,0)); + G4SubtractionSolid* PCB = + new G4SubtractionSolid("PCB", PCB_1, WaferShape, new G4RotationMatrix, + G4ThreeVector(0, Inner_PCB_Thickness / 2. - Inner_PCB_WaferDepth, 0)); // Substract active part from inert part of the Wafer G4SubtractionSolid* InertWafer = new G4SubtractionSolid("InertWafer", InertWaferFull, ActiveWaferShape, - new G4RotationMatrix, - G4ThreeVector(0,0,0)); + new G4RotationMatrix, G4ThreeVector(0, 0, 0)); // Master Volume that encompass everything else - G4LogicalVolume* logicPyramidDetector = - new G4LogicalVolume(PCBFull,m_MaterialVacuum,"logicBoxDetector", 0, 0, 0); - logicPyramidDetector->SetVisAttributes(G4VisAttributes::Invisible); + G4LogicalVolume* logicPyramidDetector = new G4LogicalVolume(PCBFull, m_MaterialVacuum, "logicBoxDetector", 0, 0, 0); + logicPyramidDetector->SetVisAttributes(G4VisAttributes::GetInvisible()); // Sub Volume PCB - G4LogicalVolume* logicPCB = - new G4LogicalVolume(PCB,m_MaterialPCB,"logicPCB", 0, 0, 0); + G4LogicalVolume* logicPCB = new G4LogicalVolume(PCB, m_MaterialPCB, "logicPCB", 0, 0, 0); logicPCB->SetVisAttributes(PCBVisAtt); // Sub Volume Wafer - G4LogicalVolume* logicInertWafer = - new G4LogicalVolume(InertWafer,m_MaterialSilicon,"logicInertWafer", 0, 0, 0); + G4LogicalVolume* logicInertWafer = new G4LogicalVolume(InertWafer, m_MaterialSilicon, "logicInertWafer", 0, 0, 0); logicInertWafer->SetVisAttributes(GuardRingVisAtt); - G4LogicalVolume* logicActiveWafer = - new G4LogicalVolume(ActiveWafer,m_MaterialSilicon,"logicActiveWafer", 0, 0, 0); + G4LogicalVolume* logicActiveWafer = new G4LogicalVolume(ActiveWafer, m_MaterialSilicon, "logicActiveWafer", 0, 0, 0); logicActiveWafer->SetVisAttributes(SiliconVisAtt); G4LogicalVolume* logicDeadLayer = - new G4LogicalVolume(DeadLayer,m_MaterialSilicon,"logicActiveWaferDeadLayer", 0, 0, 0); + new G4LogicalVolume(DeadLayer, m_MaterialSilicon, "logicActiveWaferDeadLayer", 0, 0, 0); logicDeadLayer->SetVisAttributes(SiliconVisAtt); // Set the sensitive volume @@ -378,66 +334,51 @@ void Pyramid::ConstructInner(G4LogicalVolume* world, double angle, double z){ // Place the sub volumes in the master volume // Last argument is the detector number, used in the scorer to get the // revelant information - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0), - logicPCB,"Pyramid_Pyramid_PCB",logicPyramidDetector, - false,0); - - G4ThreeVector WaferPosition(0, - 0.5*(Inner_PCB_Thickness+Inner_InertWafer_Thickness)-Inner_PCB_WaferDepth - ,0); - - G4ThreeVector DeadLayerPositionF = WaferPosition + G4ThreeVector(0,-Inner_ActiveWafer_Thickness*0.5-Inner_ActiveWafer_DeadLayerThickness*0.5,0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicPCB, "Pyramid_Pyramid_PCB", + logicPyramidDetector, false, 0); - G4ThreeVector DeadLayerPositionB = WaferPosition + G4ThreeVector(0,Inner_ActiveWafer_Thickness*0.5+Inner_ActiveWafer_DeadLayerThickness*0.5,0); + G4ThreeVector WaferPosition(0, 0.5 * (Inner_PCB_Thickness + Inner_InertWafer_Thickness) - Inner_PCB_WaferDepth, 0); + G4ThreeVector DeadLayerPositionF = + WaferPosition + + G4ThreeVector(0, -Inner_ActiveWafer_Thickness * 0.5 - Inner_ActiveWafer_DeadLayerThickness * 0.5, 0); + G4ThreeVector DeadLayerPositionB = + WaferPosition + + G4ThreeVector(0, Inner_ActiveWafer_Thickness * 0.5 + Inner_ActiveWafer_DeadLayerThickness * 0.5, 0); - new G4PVPlacement(new G4RotationMatrix(0,0,0), - WaferPosition, - logicActiveWafer,"Pyramid_Wafer", - logicPyramidDetector,false,0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), WaferPosition, logicActiveWafer, "Pyramid_Wafer", + logicPyramidDetector, false, 0); - new G4PVPlacement(new G4RotationMatrix(0,0,0), - DeadLayerPositionF, - logicDeadLayer,"Pyramid_WaferDeadLayerFront", - logicPyramidDetector,false,0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), DeadLayerPositionF, logicDeadLayer, "Pyramid_WaferDeadLayerFront", + logicPyramidDetector, false, 0); - new G4PVPlacement(new G4RotationMatrix(0,0,0), - DeadLayerPositionB, - logicDeadLayer,"Pyramid_WaferDeadLayerBack", - logicPyramidDetector,false,0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), DeadLayerPositionB, logicDeadLayer, "Pyramid_WaferDeadLayerBack", + logicPyramidDetector, false, 0); - - new G4PVPlacement(new G4RotationMatrix(0,0,0), - WaferPosition, - logicInertWafer,"Pyramid_Wafer_GuardRing", - logicPyramidDetector,false,0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), WaferPosition, logicInertWafer, "Pyramid_Wafer_GuardRing", + logicPyramidDetector, false, 0); // The Distance from target is given by half the width of a detector - G4double DistanceFromTarget = Inner_PCB_Width*(0.5) - + Inner_PCB_Length*(0.5)*fabs(sin(angle)) ; - for( unsigned int i = 0; i < 4; i ++){ + G4double DistanceFromTarget = Inner_PCB_Width * (0.5) + Inner_PCB_Length * (0.5) * fabs(sin(angle)); + for (unsigned int i = 0; i < 4; i++) { // The following builds the Pyramid, with detector one at the top // and going anticlockwise looking downstream - double sign = -z/fabs(z); + double sign = -z / fabs(z); // Detector are rotate by 90deg with each other - G4RotationMatrix* DetectorRotation = - new G4RotationMatrix(0,sign*angle,i*90*deg); + G4RotationMatrix* DetectorRotation = new G4RotationMatrix(0, sign * angle, i * 90 * deg); // There center is also rotated by 90deg - G4ThreeVector DetectorPosition(0,DistanceFromTarget,z-(0.5)*Inner_ActiveWafer_Length); - DetectorPosition.rotate(i*90*deg,G4ThreeVector(0,0,-1)); + G4ThreeVector DetectorPosition(0, DistanceFromTarget, z - (0.5) * Inner_ActiveWafer_Length); + DetectorPosition.rotate(i * 90 * deg, G4ThreeVector(0, 0, -1)); // Place the Master volume with its two daugther volume at the final place - new G4PVPlacement(G4Transform3D(*DetectorRotation,DetectorPosition), - logicPyramidDetector,"Pyramid_Inner_Detector", - world,false,i+1); + new G4PVPlacement(G4Transform3D(*DetectorRotation, DetectorPosition), logicPyramidDetector, + "Pyramid_Inner_Detector", world, false, i + 1); } - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Pyramid::ConstructOuter(G4LogicalVolume* world, double angle, double z){ +void Pyramid::ConstructOuter(G4LogicalVolume* world, double angle, double z) { // Pyramid Outer Pyramid // The outer Pyramid is identical to the inner Pyramid but wider in terms of // geometry. It feature four non resistive strip on the front face @@ -445,91 +386,67 @@ void Pyramid::ConstructOuter(G4LogicalVolume* world, double angle, double z){ // Start by making a full pcb // We start by the definition of the point forming a PCB cross section vector<G4TwoVector> PCBCrossSection; - double l1 = Outer_PCB_Thickness*0.5/tan(Outer_PCB_Bevel1_Theta); - double l2 = Outer_PCB_Thickness*0.5/tan(Outer_PCB_Bevel2_Theta); + double l1 = Outer_PCB_Thickness * 0.5 / tan(Outer_PCB_Bevel1_Theta); + double l2 = Outer_PCB_Thickness * 0.5 / tan(Outer_PCB_Bevel2_Theta); - PCBCrossSection.push_back(G4TwoVector(Outer_PCB_Width/2.-l2,-Outer_PCB_Thickness*0.5)); - PCBCrossSection.push_back(G4TwoVector(Outer_PCB_Width/2.,0)); - PCBCrossSection.push_back(G4TwoVector(Outer_PCB_Width/2.-l1,Outer_PCB_Thickness*0.5)); + PCBCrossSection.push_back(G4TwoVector(Outer_PCB_Width / 2. - l2, -Outer_PCB_Thickness * 0.5)); + PCBCrossSection.push_back(G4TwoVector(Outer_PCB_Width / 2., 0)); + PCBCrossSection.push_back(G4TwoVector(Outer_PCB_Width / 2. - l1, Outer_PCB_Thickness * 0.5)); - PCBCrossSection.push_back(G4TwoVector(-Outer_PCB_Width/2.+l1,Outer_PCB_Thickness*0.5)); - PCBCrossSection.push_back(G4TwoVector(-Outer_PCB_Width/2.,0)); - PCBCrossSection.push_back(G4TwoVector(-Outer_PCB_Width/2.+l2,-Outer_PCB_Thickness*0.5)); + PCBCrossSection.push_back(G4TwoVector(-Outer_PCB_Width / 2. + l1, Outer_PCB_Thickness * 0.5)); + PCBCrossSection.push_back(G4TwoVector(-Outer_PCB_Width / 2., 0)); + PCBCrossSection.push_back(G4TwoVector(-Outer_PCB_Width / 2. + l2, -Outer_PCB_Thickness * 0.5)); - G4ExtrudedSolid* PCBFull = - new G4ExtrudedSolid("PCBFull", - PCBCrossSection, - Outer_PCB_Length/2., - G4TwoVector(0,0),1, - G4TwoVector(0,0),1); + G4ExtrudedSolid* PCBFull = new G4ExtrudedSolid("PCBFull", PCBCrossSection, Outer_PCB_Length / 2., G4TwoVector(0, 0), + 1, G4TwoVector(0, 0), 1); // A box having Wafer dimension but thicker than the PCB // Will be used to remove material from the PCB to have space for the wafer // Calculate the hole shift within the PCB - G4ThreeVector HoleShift = G4ThreeVector( - 0, - 0, - Outer_PCB_Offset-(Outer_PCB_Length/2-Outer_PCB_HoleLength/2)); + G4ThreeVector HoleShift = G4ThreeVector(0, 0, Outer_PCB_Offset - (Outer_PCB_Length / 2 - Outer_PCB_HoleLength / 2)); - G4Box* HoleShape = new G4Box("HoleShape", - Outer_ActiveWafer_Width/2., - Outer_PCB_Thickness/2.+0.1*mm, - Outer_PCB_HoleLength/2.); + G4Box* HoleShape = new G4Box("HoleShape", Outer_ActiveWafer_Width / 2., Outer_PCB_Thickness / 2. + 0.1 * mm, + Outer_PCB_HoleLength / 2.); - G4Box* WaferShape = new G4Box("WaferShape", - Outer_InertWafer_Width/2., - Outer_PCB_Thickness/2., - Outer_InertWafer_Length/2.); + G4Box* WaferShape = + new G4Box("WaferShape", Outer_InertWafer_Width / 2., Outer_PCB_Thickness / 2., Outer_InertWafer_Length / 2.); // The Silicon Wafer itself - G4Box* InertWaferFull = new G4Box("InertWaferFull", - Outer_InertWafer_Width/2., - Outer_ActiveWafer_Thickness/2., - Outer_InertWafer_Length/2.); - - G4Box* ActiveWafer = new G4Box("ActiveWafer", - Outer_ActiveWafer_Width/2., - Outer_ActiveWafer_Thickness/2., - Outer_ActiveWafer_Length/2.); + G4Box* InertWaferFull = new G4Box("InertWaferFull", Outer_InertWafer_Width / 2., Outer_ActiveWafer_Thickness / 2., + Outer_InertWafer_Length / 2.); - G4Box* ActiveWaferShape = new G4Box("ActiveWaferShape", - Outer_ActiveWafer_Width/2., - Outer_PCB_Thickness/2., - Outer_ActiveWafer_Length/2.); + G4Box* ActiveWafer = new G4Box("ActiveWafer", Outer_ActiveWafer_Width / 2., Outer_ActiveWafer_Thickness / 2., + Outer_ActiveWafer_Length / 2.); + G4Box* ActiveWaferShape = new G4Box("ActiveWaferShape", Outer_ActiveWafer_Width / 2., Outer_PCB_Thickness / 2., + Outer_ActiveWafer_Length / 2.); // Substracting the hole Shape from the Stock PCB - G4SubtractionSolid* PCB_1 = new G4SubtractionSolid("PCB_1", PCBFull, HoleShape, - new G4RotationMatrix,HoleShift); + G4SubtractionSolid* PCB_1 = new G4SubtractionSolid("PCB_1", PCBFull, HoleShape, new G4RotationMatrix, HoleShift); // Substracting the wafer space from the Stock PCB - G4SubtractionSolid* PCB = new G4SubtractionSolid("PCB", PCB_1, WaferShape, - new G4RotationMatrix, - G4ThreeVector(0,Outer_PCB_Thickness/2.-Outer_PCB_WaferDepth,0)); + G4SubtractionSolid* PCB = + new G4SubtractionSolid("PCB", PCB_1, WaferShape, new G4RotationMatrix, + G4ThreeVector(0, Outer_PCB_Thickness / 2. - Outer_PCB_WaferDepth, 0)); // Substract active part from inert part of the Wafer G4SubtractionSolid* InertWafer = new G4SubtractionSolid("InertWafer", InertWaferFull, ActiveWaferShape, - new G4RotationMatrix, - G4ThreeVector(0,0,0)); + new G4RotationMatrix, G4ThreeVector(0, 0, 0)); // Master Volume that encompass everything else - G4LogicalVolume* logicPyramidDetector = - new G4LogicalVolume(PCBFull,m_MaterialVacuum,"logicBoxDetector", 0, 0, 0); - logicPyramidDetector->SetVisAttributes(G4VisAttributes::Invisible); + G4LogicalVolume* logicPyramidDetector = new G4LogicalVolume(PCBFull, m_MaterialVacuum, "logicBoxDetector", 0, 0, 0); + logicPyramidDetector->SetVisAttributes(G4VisAttributes::GetInvisible()); // Sub Volume PCB - G4LogicalVolume* logicPCB = - new G4LogicalVolume(PCB,m_MaterialPCB,"logicPCB", 0, 0, 0); + G4LogicalVolume* logicPCB = new G4LogicalVolume(PCB, m_MaterialPCB, "logicPCB", 0, 0, 0); logicPCB->SetVisAttributes(PCBVisAtt); // Sub Volume Wafer - G4LogicalVolume* logicInertWafer = - new G4LogicalVolume(InertWafer,m_MaterialSilicon,"logicInertWafer", 0, 0, 0); + G4LogicalVolume* logicInertWafer = new G4LogicalVolume(InertWafer, m_MaterialSilicon, "logicInertWafer", 0, 0, 0); logicInertWafer->SetVisAttributes(GuardRingVisAtt); - G4LogicalVolume* logicActiveWafer = - new G4LogicalVolume(ActiveWafer,m_MaterialSilicon,"logicActiveWafer", 0, 0, 0); + G4LogicalVolume* logicActiveWafer = new G4LogicalVolume(ActiveWafer, m_MaterialSilicon, "logicActiveWafer", 0, 0, 0); logicActiveWafer->SetVisAttributes(SiliconVisAtt); // Set the sensitive detector @@ -537,56 +454,41 @@ void Pyramid::ConstructOuter(G4LogicalVolume* world, double angle, double z){ // The Distance from target is given by half the width of a detector // plus 0.75 cm - G4double DistanceFromTarget = Inner_PCB_Width*(0.5)+0.5*cm - + Inner_PCB_Length*(0.5)*fabs(sin(angle)) ; - + G4double DistanceFromTarget = Inner_PCB_Width * (0.5) + 0.5 * cm + Inner_PCB_Length * (0.5) * fabs(sin(angle)); + // Place the sub volumes in the master volume // Last argument is the detector number, used in the scorer to get the // revelant information - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0), - logicPCB,"Pyramid_Outer_PCB",logicPyramidDetector, - false,0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicPCB, "Pyramid_Outer_PCB", + logicPyramidDetector, false, 0); + G4ThreeVector WaferPosition(0, 0.5 * (Outer_PCB_Thickness + Outer_ActiveWafer_Thickness) - Outer_PCB_WaferDepth, 0); - G4ThreeVector WaferPosition(0, - 0.5*(Outer_PCB_Thickness+Outer_ActiveWafer_Thickness)-Outer_PCB_WaferDepth - ,0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), WaferPosition, logicActiveWafer, "Outer_Wafer", logicPyramidDetector, + false, 0); - new G4PVPlacement(new G4RotationMatrix(0,0,0), - WaferPosition, - logicActiveWafer,"Outer_Wafer", - logicPyramidDetector,false,0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), WaferPosition, logicInertWafer, "Outer_Wafer_GuardRing", + logicPyramidDetector, false, 0); - new G4PVPlacement(new G4RotationMatrix(0,0,0), - WaferPosition, - logicInertWafer,"Outer_Wafer_GuardRing", - logicPyramidDetector,false,0); - - // The following build the Pyramid, with detector one at the top // and going clowise looking upstrea - for( unsigned int i = 0; i < 4; i ++){ + for (unsigned int i = 0; i < 4; i++) { // Detector are rotate by 90 deg with each other - double sign = -z/fabs(z); - G4RotationMatrix* DetectorRotation = - new G4RotationMatrix(0*deg,sign*angle,i*90*deg); + double sign = -z / fabs(z); + G4RotationMatrix* DetectorRotation = new G4RotationMatrix(0 * deg, sign * angle, i * 90 * deg); // There center is also rotated by 90deg - G4ThreeVector DetectorPosition(0,DistanceFromTarget,z); - DetectorPosition.rotate(i*90*deg,G4ThreeVector(0,0,-1)); + G4ThreeVector DetectorPosition(0, DistanceFromTarget, z); + DetectorPosition.rotate(i * 90 * deg, G4ThreeVector(0, 0, -1)); // Place the Master volume with its daugthers at the final place - new G4PVPlacement(G4Transform3D(*DetectorRotation,DetectorPosition), - logicPyramidDetector,"Pyramid_Outer_Detector", - world,false,i+1); + new G4PVPlacement(G4Transform3D(*DetectorRotation, DetectorPosition), logicPyramidDetector, + "Pyramid_Outer_Detector", world, false, i + 1); } - } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Pyramid::ConstructChamber(G4LogicalVolume* world){ +void Pyramid::ConstructChamber(G4LogicalVolume* world) { // Vaccum Chamber of Pyramid // The chamber is made of a central cylinder surrounding the Pyramid Si // Two Cone that expeand out of the central cylinder to let room for Exogam @@ -598,61 +500,52 @@ void Pyramid::ConstructChamber(G4LogicalVolume* world){ // Central Tube G4Tubs* solidCentralTube = - new G4Tubs("PyramidChamberCentralTube",CHAMBER_CentralTube_Inner_Radius, - CHAMBER_CentralTube_Outer_Radius,CHAMBER_CentralTube_Length/2., - 0*deg,360*deg); + new G4Tubs("PyramidChamberCentralTube", CHAMBER_CentralTube_Inner_Radius, CHAMBER_CentralTube_Outer_Radius, + CHAMBER_CentralTube_Length / 2., 0 * deg, 360 * deg); // Forward-Backward Cones G4Cons* solidOuterCone = - new G4Cons("PyramidChamberOuterCone",CHAMBER_CentralTube_Inner_Radius, - CHAMBER_CentralTube_Outer_Radius,CHAMBER_OuterCylinder_Inner_Radius, - CHAMBER_OuterCylinder_Outer_Radius,CHAMBER_OuterCone_Length/2., - 0*deg,360*deg); + new G4Cons("PyramidChamberOuterCone", CHAMBER_CentralTube_Inner_Radius, CHAMBER_CentralTube_Outer_Radius, + CHAMBER_OuterCylinder_Inner_Radius, CHAMBER_OuterCylinder_Outer_Radius, CHAMBER_OuterCone_Length / 2., + 0 * deg, 360 * deg); // Outer Cylinder G4Tubs* solidOuterCylinder = - new G4Tubs("PyramidChamberOuterCylinder",CHAMBER_OuterCylinder_Inner_Radius, - CHAMBER_OuterCylinder_Outer_Radius,CHAMBER_OuterCylinder_Length/2., - 0*deg,360*deg); + new G4Tubs("PyramidChamberOuterCylinder", CHAMBER_OuterCylinder_Inner_Radius, CHAMBER_OuterCylinder_Outer_Radius, + CHAMBER_OuterCylinder_Length / 2., 0 * deg, 360 * deg); // Add the volume together G4UnionSolid* solidPyramidChamberStep1 = - new G4UnionSolid("PyramidChamber", solidCentralTube, solidOuterCone, - new G4RotationMatrix, - G4ThreeVector(0,0,CHAMBER_OuterCone_Z_Pos)); + new G4UnionSolid("PyramidChamber", solidCentralTube, solidOuterCone, new G4RotationMatrix, + G4ThreeVector(0, 0, CHAMBER_OuterCone_Z_Pos)); G4UnionSolid* solidPyramidChamberStep2 = - new G4UnionSolid("PyramidChamber", solidPyramidChamberStep1, solidOuterCone, - new G4RotationMatrix(0,180*deg,0), - G4ThreeVector(0,0,-CHAMBER_OuterCone_Z_Pos)); + new G4UnionSolid("PyramidChamber", solidPyramidChamberStep1, solidOuterCone, + new G4RotationMatrix(0, 180 * deg, 0), G4ThreeVector(0, 0, -CHAMBER_OuterCone_Z_Pos)); G4UnionSolid* solidPyramidChamberStep3 = - new G4UnionSolid("PyramidChamber", solidPyramidChamberStep2, solidOuterCylinder, - new G4RotationMatrix, - G4ThreeVector(0,0,CHAMBER_OuterCylinder_Z_Pos)); + new G4UnionSolid("PyramidChamber", solidPyramidChamberStep2, solidOuterCylinder, new G4RotationMatrix, + G4ThreeVector(0, 0, CHAMBER_OuterCylinder_Z_Pos)); G4UnionSolid* solidPyramidChamberStep4 = - new G4UnionSolid("PyramidChamber", solidPyramidChamberStep3, solidOuterCylinder, - new G4RotationMatrix, - G4ThreeVector(0,0,-CHAMBER_OuterCylinder_Z_Pos)); + new G4UnionSolid("PyramidChamber", solidPyramidChamberStep3, solidOuterCylinder, new G4RotationMatrix, + G4ThreeVector(0, 0, -CHAMBER_OuterCylinder_Z_Pos)); // Create Logic Volume G4LogicalVolume* logicPyramidChamber = - new G4LogicalVolume(solidPyramidChamberStep4,m_MaterialAl,"logicPyramidChamber", 0, 0, 0); + new G4LogicalVolume(solidPyramidChamberStep4, m_MaterialAl, "logicPyramidChamber", 0, 0, 0); // Visual Attribute - G4VisAttributes* ChamberVisAtt - = new G4VisAttributes(G4Colour(0.0,0.4,0.5,0.2)); + G4VisAttributes* ChamberVisAtt = new G4VisAttributes(G4Colour(0.0, 0.4, 0.5, 0.2)); logicPyramidChamber->SetVisAttributes(ChamberVisAtt); // Place the whole chamber - new G4PVPlacement(new G4RotationMatrix(0,0,0), G4ThreeVector(0,0,0), - logicPyramidChamber,"PyramidChamber",world,false,0); - + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicPyramidChamber, "PyramidChamber", world, + false, 0); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Pyramid::InitializeMaterial(){ +void Pyramid::InitializeMaterial() { m_MaterialSilicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); m_MaterialAl = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); m_MaterialPCB = MaterialManager::getInstance()->GetMaterialFromLibrary("PCB"); @@ -662,23 +555,21 @@ void Pyramid::InitializeMaterial(){ //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* Pyramid::Construct(){ - return (NPS::VDetector*) new Pyramid(); -} +NPS::VDetector* Pyramid::Construct() { return (NPS::VDetector*)new Pyramid(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_Pyramid{ - public: - proxy_nps_Pyramid(){ - NPS::DetectorFactory::getInstance()->AddToken("Pyramid","Pyramid"); - NPS::DetectorFactory::getInstance()->AddDetector("Pyramid",Pyramid::Construct); - } - }; - - proxy_nps_Pyramid p_nps_Pyramid; +extern "C" { +class proxy_nps_Pyramid { + public: + proxy_nps_Pyramid() { + NPS::DetectorFactory::getInstance()->AddToken("Pyramid", "Pyramid"); + NPS::DetectorFactory::getInstance()->AddDetector("Pyramid", Pyramid::Construct); + } +}; + +proxy_nps_Pyramid p_nps_Pyramid; } diff --git a/NPSimulation/Detectors/QQQ/QQQ.cc b/NPSimulation/Detectors/QQQ/QQQ.cc index 43fd01420..d593a28d0 100644 --- a/NPSimulation/Detectors/QQQ/QQQ.cc +++ b/NPSimulation/Detectors/QQQ/QQQ.cc @@ -20,35 +20,35 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> -//G4 Geometry object -#include "G4Trd.hh" +#include <sstream> +// G4 Geometry object #include "G4Box.hh" -#include "G4Tubs.hh" #include "G4Trap.hh" +#include "G4Trd.hh" +#include "G4Tubs.hh" -//G4 sensitive -#include "G4SDManager.hh" +// G4 sensitive #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" -//G4 various object -#include "G4Material.hh" -#include "G4Transform3D.hh" -#include "G4PVPlacement.hh" -#include "G4VisAttributes.hh" +// G4 various object #include "G4Colour.hh" +#include "G4Material.hh" #include "G4PVDivision.hh" +#include "G4PVPlacement.hh" #include "G4SubtractionSolid.hh" +#include "G4Transform3D.hh" +#include "G4VisAttributes.hh" // NPTool header -#include "QQQ.hh" #include "MaterialManager.hh" +#include "NPOptionManager.h" #include "NPSDetectorFactory.hh" -#include "SiliconScorers.hh" +#include "QQQ.hh" #include "RootOutput.h" -#include "NPOptionManager.h" +#include "SiliconScorers.hh" using namespace QQQ_LOCAL; // CLHEP header @@ -61,21 +61,16 @@ using namespace CLHEP; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // QQQ Specific Method -QQQ::QQQ(){ +QQQ::QQQ() { InitializeMaterial(); m_Event = new TQQQData(); - m_StripScorer=0; + m_StripScorer = 0; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -QQQ::~QQQ(){ -} +QQQ::~QQQ() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void QQQ::AddTelescope( G4ThreeVector TL, - G4ThreeVector BL, - G4ThreeVector BR, - G4ThreeVector TR) -{ +void QQQ::AddTelescope(G4ThreeVector TL, G4ThreeVector BL, G4ThreeVector BR, G4ThreeVector TR) { m_DefinitionType.push_back(true); m_TL.push_back(TL); @@ -91,13 +86,7 @@ void QQQ::AddTelescope( G4ThreeVector TL, m_beta_w.push_back(0); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void QQQ::AddTelescope( G4double R, - G4double Theta, - G4double Phi, - G4double beta_u, - G4double beta_v, - G4double beta_w) -{ +void QQQ::AddTelescope(G4double R, G4double Theta, G4double Phi, G4double beta_u, G4double beta_v, G4double beta_w) { G4ThreeVector empty = G4ThreeVector(0, 0, 0); m_DefinitionType.push_back(false); @@ -113,20 +102,15 @@ void QQQ::AddTelescope( G4double R, m_BL.push_back(empty); m_BR.push_back(empty); m_TR.push_back(empty); - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void QQQ::VolumeMaker( G4int DetNumber , - G4ThreeVector Det_pos , - G4RotationMatrix* Det_rot , - G4LogicalVolume* world ) -{ - G4double NbrTelescopes = DetNumber ; - G4String DetectorNumber ; - std::ostringstream Number ; - Number << NbrTelescopes ; - DetectorNumber = Number.str() ; +void QQQ::VolumeMaker(G4int DetNumber, G4ThreeVector Det_pos, G4RotationMatrix* Det_rot, G4LogicalVolume* world) { + G4double NbrTelescopes = DetNumber; + G4String DetectorNumber; + std::ostringstream Number; + Number << NbrTelescopes; + DetectorNumber = Number.str(); //////////////////////////////////////////////////////////////// /////////General Geometry Parameter Definition ///////////////// @@ -134,124 +118,105 @@ void QQQ::VolumeMaker( G4int DetNumber , /////// Starting Volume Definition /////// G4String Name = "QQQ" + DetectorNumber; -// G4Box* solidQQQ = new G4Box(Name+"Solid", 0.5*DetectorSize, 0.5*DetectorSize, 0.5*FrameThickness); - G4Tubs* solidQQQ = new G4Tubs(Name+"Solid", FrameRMin, FrameRMax, 0.5*FrameThickness, FrameStartPhi, FrameDeltaPhi); + // G4Box* solidQQQ = new G4Box(Name+"Solid", 0.5*DetectorSize, 0.5*DetectorSize, 0.5*FrameThickness); + G4Tubs* solidQQQ = + new G4Tubs(Name + "Solid", FrameRMin, FrameRMax, 0.5 * FrameThickness, FrameStartPhi, FrameDeltaPhi); + + G4LogicalVolume* logicQQQ = new G4LogicalVolume(solidQQQ, m_MaterialVacuum, Name + "_logic", 0, 0); - G4LogicalVolume* logicQQQ = - new G4LogicalVolume(solidQQQ, m_MaterialVacuum, Name+"_logic", 0, 0); + new G4PVPlacement(G4Transform3D(*Det_rot, Det_pos), logicQQQ, Name, world, false, DetNumber); - new G4PVPlacement( G4Transform3D(*Det_rot, Det_pos) , - logicQQQ , - Name , - world , - false , - DetNumber); + logicQQQ->SetVisAttributes(G4VisAttributes::GetInvisible()); - logicQQQ->SetVisAttributes(G4VisAttributes::Invisible); - // Frame is made of 4 thick box (2 Horizontal and 2 Vertical) - //G4Box* solidFrameHorizontal = new G4Box(Name + "_Frame", 0.5*SiliconSize, 0.5*(DetectorSize - SiliconSize) / 2, 0.5*FrameThickness*mm) ; - //G4Box* solidFrameVertical = new G4Box(Name + "_Frame", 0.5*(DetectorSize - SiliconSize) / 2, 0.5*DetectorSize, 0.5*FrameThickness*mm) ; - - //G4LogicalVolume* logicFrameHorizontal = new G4LogicalVolume(solidFrameHorizontal, m_MaterialAl, Name, 0, 0); - //G4VisAttributes* VisAtt1 = new G4VisAttributes(G4Colour(0.0, 0.5, 1)); - //logicFrameHorizontal->SetVisAttributes(VisAtt1); - - - //G4LogicalVolume* logicFrameVertical = new G4LogicalVolume(solidFrameVertical, m_MaterialAl, Name, 0, 0); - //logicFrameVertical->SetVisAttributes(VisAtt1); - - //G4ThreeVector FrameTopPosition = G4ThreeVector(0 , 0.5 * SiliconSize + 0.5 * (DetectorSize - SiliconSize) / 2 , 0) ; - //G4ThreeVector FrameBottomPosition = G4ThreeVector(0 , -0.5 * SiliconSize - 0.5 * (DetectorSize - SiliconSize) / 2 , 0) ; - //G4ThreeVector FrameLeftPosition = G4ThreeVector(0.5 * SiliconSize + 0.5 * (DetectorSize - SiliconSize) / 2 , 0 , 0) ; - //G4ThreeVector FrameRightPosition = G4ThreeVector(-0.5 * SiliconSize - 0.5 * (DetectorSize - SiliconSize) / 2 , 0 , 0) ; - - - //new G4PVPlacement( 0, - // FrameTopPosition, - // logicFrameHorizontal, - // Name + "_Frame", - // logicQQQ, - // false, - // DetNumber); - - //new G4PVPlacement( 0, - // FrameBottomPosition, - // logicFrameHorizontal, - // Name + "_Frame", - // logicQQQ, - // false, - // DetNumber); - - //new G4PVPlacement( 0, - // FrameLeftPosition, - // logicFrameVertical, - // Name + "_Frame", - // logicQQQ, - // false, - // DetNumber); - - //new G4PVPlacement( 0, - // FrameRightPosition, + // G4Box* solidFrameHorizontal = new G4Box(Name + "_Frame", 0.5*SiliconSize, 0.5*(DetectorSize - SiliconSize) / 2, + // 0.5*FrameThickness*mm) ; G4Box* solidFrameVertical = new G4Box(Name + "_Frame", 0.5*(DetectorSize - SiliconSize) + // / 2, 0.5*DetectorSize, 0.5*FrameThickness*mm) ; + + // G4LogicalVolume* logicFrameHorizontal = new G4LogicalVolume(solidFrameHorizontal, m_MaterialAl, Name, 0, 0); + // G4VisAttributes* VisAtt1 = new G4VisAttributes(G4Colour(0.0, 0.5, 1)); + // logicFrameHorizontal->SetVisAttributes(VisAtt1); + + // G4LogicalVolume* logicFrameVertical = new G4LogicalVolume(solidFrameVertical, m_MaterialAl, Name, 0, 0); + // logicFrameVertical->SetVisAttributes(VisAtt1); + + // G4ThreeVector FrameTopPosition = G4ThreeVector(0 , 0.5 * SiliconSize + 0.5 * (DetectorSize - SiliconSize) / 2 , + // 0) ; G4ThreeVector FrameBottomPosition = G4ThreeVector(0 , -0.5 * SiliconSize - 0.5 * (DetectorSize - SiliconSize) + // / 2 , 0) ; G4ThreeVector FrameLeftPosition = G4ThreeVector(0.5 * SiliconSize + 0.5 * (DetectorSize - SiliconSize) + // / 2 , 0 , 0) ; G4ThreeVector FrameRightPosition = G4ThreeVector(-0.5 * SiliconSize - 0.5 * (DetectorSize - + // SiliconSize) / 2 , 0 , 0) ; + + // new G4PVPlacement( 0, + // FrameTopPosition, + // logicFrameHorizontal, + // Name + "_Frame", + // logicQQQ, + // false, + // DetNumber); + + // new G4PVPlacement( 0, + // FrameBottomPosition, + // logicFrameHorizontal, + // Name + "_Frame", + // logicQQQ, + // false, + // DetNumber); + + // new G4PVPlacement( 0, + // FrameLeftPosition, // logicFrameVertical, - // Name + "_Frame", - // logicQQQ, - // false, - // DetNumber); - + // Name + "_Frame", + // logicQQQ, + // false, + // DetNumber); - G4ThreeVector posAluFront = G4ThreeVector(0 , 0 , AluStripFront_PosZ) ; - G4ThreeVector posSi1 = G4ThreeVector(0 , 0 , 0 ) ; - G4ThreeVector posSi2 = G4ThreeVector(0 , 0 , 0.5*SiliconThickness1 + AluThickness + DetGap + 0.5*SiliconThickness2 ) ; - G4ThreeVector posAluBack = G4ThreeVector(0 , 0 , AluStripBack_PosZ ) ; + // new G4PVPlacement( 0, + // FrameRightPosition, + // logicFrameVertical, + // Name + "_Frame", + // logicQQQ, + // false, + // DetNumber); - G4Tubs* solidAlu = - new G4Tubs("QQQAlu", DetectorRMin, DetectorRMax, 0.5*AluThickness, DetStartPhi, DetDeltaPhi) ; + G4ThreeVector posAluFront = G4ThreeVector(0, 0, AluStripFront_PosZ); + G4ThreeVector posSi1 = G4ThreeVector(0, 0, 0); + G4ThreeVector posSi2 = G4ThreeVector(0, 0, 0.5 * SiliconThickness1 + AluThickness + DetGap + 0.5 * SiliconThickness2); + G4ThreeVector posAluBack = G4ThreeVector(0, 0, AluStripBack_PosZ); - G4LogicalVolume* logicAlu = - new G4LogicalVolume(solidAlu, m_MaterialAl, "logicAlu", 0, 0, 0) ; + G4Tubs* solidAlu = new G4Tubs("QQQAlu", DetectorRMin, DetectorRMax, 0.5 * AluThickness, DetStartPhi, DetDeltaPhi); + G4LogicalVolume* logicAlu = new G4LogicalVolume(solidAlu, m_MaterialAl, "logicAlu", 0, 0, 0); - new G4PVPlacement(0 , posAluFront , logicAlu , Name + "_AluFront" , logicQQQ , true, DetNumber) ; - new G4PVPlacement(0 , posAluBack , logicAlu , Name + "_AluBack" , logicQQQ , true, DetNumber) ; + new G4PVPlacement(0, posAluFront, logicAlu, Name + "_AluFront", logicQQQ, true, DetNumber); + new G4PVPlacement(0, posAluBack, logicAlu, Name + "_AluBack", logicQQQ, true, DetNumber); + // delta E detector -// delta E detector + G4Tubs* solidSi1 = new G4Tubs("QQQ1", DetectorRMin, DetectorRMax, 0.5 * SiliconThickness1, DetStartPhi, DetDeltaPhi); - G4Tubs* solidSi1 = - new G4Tubs("QQQ1", DetectorRMin, DetectorRMax, 0.5*SiliconThickness1, DetStartPhi,DetDeltaPhi); + G4LogicalVolume* logicSi1 = new G4LogicalVolume(solidSi1, m_MaterialSilicon, "logicSi1", 0, 0, 0); - G4LogicalVolume* logicSi1 = - new G4LogicalVolume(solidSi1, m_MaterialSilicon, "logicSi1", 0, 0, 0); - - //logicAlu->SetVisAttributes(G4VisAttributes::Invisible); + // logicAlu->SetVisAttributes(G4VisAttributes::GetInvisible()); new G4PVPlacement(0, posSi1, logicSi1, Name + "_Si", logicQQQ, true, DetNumber); + logicSi1->SetVisAttributes(G4VisAttributes(G4Colour(1.0, 0.0, 0.0))); // red - logicSi1->SetVisAttributes(G4VisAttributes(G4Colour(1.0, 0.0, 0.0))); // red - -// E detector: + // E detector: - G4Tubs* solidSi2 = - new G4Tubs("QQQ2", DetectorRMin, DetectorRMax, 0.5*SiliconThickness2, DetStartPhi,DetDeltaPhi); + G4Tubs* solidSi2 = new G4Tubs("QQQ2", DetectorRMin, DetectorRMax, 0.5 * SiliconThickness2, DetStartPhi, DetDeltaPhi); - G4LogicalVolume* logicSi2 = - new G4LogicalVolume(solidSi2, m_MaterialSilicon, "logicSi2", 0, 0, 0); + G4LogicalVolume* logicSi2 = new G4LogicalVolume(solidSi2, m_MaterialSilicon, "logicSi2", 0, 0, 0); - //logicAlu->SetVisAttributes(G4VisAttributes::Invisible); + // logicAlu->SetVisAttributes(G4VisAttributes::GetInvisible()); new G4PVPlacement(0, posSi2, logicSi2, Name + "_Si", logicQQQ, true, DetNumber); + logicSi2->SetVisAttributes(G4VisAttributes(G4Colour(1.0, 0.0, 0.0))); // red - logicSi2->SetVisAttributes(G4VisAttributes(G4Colour(1.0, 0.0, 0.0))); // red - - - //attach it to the Silicon plate - logicSi1 ->SetSensitiveDetector(m_StripScorer); - logicSi2 ->SetSensitiveDetector(m_StripScorer); - - + // attach it to the Silicon plate + logicSi1->SetSensitiveDetector(m_StripScorer); + logicSi2->SetSensitiveDetector(m_StripScorer); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -262,56 +227,54 @@ void QQQ::VolumeMaker( G4int DetNumber , //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void QQQ::ReadConfiguration(NPL::InputParser parser){ +void QQQ::ReadConfiguration(NPL::InputParser parser) { vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("QQQ"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " detectors found " << endl; - - vector<string> cart = {"A","B","C","D"}; - vector<string> sphe = {"R","THETA","PHI","BETA"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(cart)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// QQQ " << i+1 << endl; - G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("A","mm")); - G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("B","mm")); - G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("C","mm")); - G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("D","mm")); - AddTelescope(A,B,C,D); - + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + + vector<string> cart = {"A", "B", "C", "D"}; + vector<string> sphe = {"R", "THETA", "PHI", "BETA"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(cart)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// QQQ " << i + 1 << endl; + G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("A", "mm")); + G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("B", "mm")); + G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("C", "mm")); + G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("D", "mm")); + AddTelescope(A, B, C, D); } - else if(blocks[i]->HasTokenList(sphe)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// QQQ " << i+1 << endl; - double R = blocks[i]->GetDouble("R","mm"); - double Theta = blocks[i]->GetDouble("THETA","deg"); - double Phi = blocks[i]->GetDouble("PHI","deg"); - vector<double> beta = blocks[i]->GetVectorDouble("BETA","deg"); - AddTelescope(R,Theta,Phi,beta[0],beta[1],beta[2]); + else if (blocks[i]->HasTokenList(sphe)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// QQQ " << i + 1 << endl; + double R = blocks[i]->GetDouble("R", "mm"); + double Theta = blocks[i]->GetDouble("THETA", "deg"); + double Phi = blocks[i]->GetDouble("PHI", "deg"); + vector<double> beta = blocks[i]->GetVectorDouble("BETA", "deg"); + AddTelescope(R, Theta, Phi, beta[0], beta[1], beta[2]); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } } } - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void QQQ::ConstructDetector(G4LogicalVolume* world){ +void QQQ::ConstructDetector(G4LogicalVolume* world) { - G4RotationMatrix* Det_rot = NULL; - G4ThreeVector Det_pos = G4ThreeVector(0, 0, 0); - G4ThreeVector Det_u = G4ThreeVector(0, 0, 0); - G4ThreeVector Det_v = G4ThreeVector(0, 0, 0); - G4ThreeVector Det_w = G4ThreeVector(0, 0, 0); + G4RotationMatrix* Det_rot = NULL; + G4ThreeVector Det_pos = G4ThreeVector(0, 0, 0); + G4ThreeVector Det_u = G4ThreeVector(0, 0, 0); + G4ThreeVector Det_v = G4ThreeVector(0, 0, 0); + G4ThreeVector Det_w = G4ThreeVector(0, 0, 0); G4int NumberOfDetector = m_DefinitionType.size(); - for (G4int i = 0 ; i < NumberOfDetector ; i++) { + for (G4int i = 0; i < NumberOfDetector; i++) { // By Point if (m_DefinitionType[i]) { // (u,v,w) unitary vector associated to telescope referencial @@ -327,26 +290,28 @@ void QQQ::ConstructDetector(G4LogicalVolume* world){ // MUST2 Det_rot = new G4RotationMatrix(Det_u, Det_v, Det_w); // translation to place Telescope - Det_pos = (m_TR[i]+m_TL[i]+m_BL[i]+m_BR[i])/4 ; + Det_pos = (m_TR[i] + m_TL[i] + m_BL[i] + m_BR[i]) / 4; } // By Angle else { G4double Theta = m_Theta[i]; - G4double Phi = m_Phi[i]; - //This part because if Phi and Theta = 0 equation are false - if (Theta == 0) Theta = 0.0001; - if (Theta == 2*cos(0)) Theta = 2 * acos(0) - 0.00001; - if (Phi == 0) Phi = 0.0001; - + G4double Phi = m_Phi[i]; + // This part because if Phi and Theta = 0 equation are false + if (Theta == 0) + Theta = 0.0001; + if (Theta == 2 * cos(0)) + Theta = 2 * acos(0) - 0.00001; + if (Phi == 0) + Phi = 0.0001; // (u,v,w) unitary vector associated to telescope referencial // (u,v) // to silicon plan // w perpendicular to (u,v) plan and pointing ThirdStage // Phi is angle between X axis and projection in (X,Y) plan // Theta is angle between position vector and z axis - G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad) ; - G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad) ; + G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad); + G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad); G4double wZ = m_R[i] * cos(Theta / rad); Det_w = G4ThreeVector(wX, wY, wZ); @@ -373,79 +338,73 @@ void QQQ::ConstructDetector(G4LogicalVolume* world){ Det_rot->rotate(m_beta_v[i], Det_v); Det_rot->rotate(m_beta_w[i], Det_w); // translation to place Telescope - Det_pos = Det_w + CT ; + Det_pos = Det_w + CT; } - VolumeMaker(i + 1 , Det_pos , Det_rot , world); + VolumeMaker(i + 1, Det_pos, Det_rot, world); } - delete Det_rot ; + delete Det_rot; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void QQQ::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("QQQ")){ - pTree->Branch("QQQ", "TQQQData", &m_Event) ; +void QQQ::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("QQQ")) { + pTree->Branch("QQQ", "TQQQData", &m_Event); } - pTree->SetBranchAddress("QQQ", &m_Event) ; + pTree->SetBranchAddress("QQQ", &m_Event); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void QQQ::ReadSensitive(const G4Event* event){ +void QQQ::ReadSensitive(const G4Event* event) { m_Event->Clear(); /////////// NPS::HitsMap<G4double*>* StripHitMap; std::map<G4int, G4double**>::iterator Strip_itr; - + G4int StripCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("QQQ_Scorer/StripScorer"); StripHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(StripCollectionID)); - + // Loop on the Strip map - for (Strip_itr = StripHitMap->GetMap()->begin() ; Strip_itr != StripHitMap->GetMap()->end() ; Strip_itr++){ - + for (Strip_itr = StripHitMap->GetMap()->begin(); Strip_itr != StripHitMap->GetMap()->end(); Strip_itr++) { + G4double* Info = *(Strip_itr->second); - + double Energy = Info[0]; - - if(Energy>EnergyThreshold){ - double Time = Info[1]; - int DetNbr = (int) Info[7]; - int StripFront = (int) Info[8]; + + if (Energy > EnergyThreshold) { + double Time = Info[1]; + int DetNbr = (int)Info[7]; + int StripFront = (int)Info[8]; m_Event->SetEnergyDetectorNbr(DetNbr); m_Event->SetEnergyStripNbr(StripFront); m_Event->SetEnergy(RandGauss::shoot(Energy, ResoEnergy)); - + m_Event->SetTimeDetectorNbr(DetNbr); m_Event->SetTimeStripNbr(StripFront); m_Event->SetTime(RandGauss::shoot(Time, ResoTime)); - } } // clear map for next event StripHitMap->clear(); - - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void QQQ::InitializeScorers(){ +void QQQ::InitializeScorers() { bool already_exist = false; // Silicon Associate Scorer - m_StripScorer = CheckScorer("QQQ_Scorer",already_exist); - if(already_exist) return; + m_StripScorer = CheckScorer("QQQ_Scorer", already_exist); + if (already_exist) + return; G4VPrimitiveScorer* StripScorer = - new SILICONSCORERS::PS_Silicon_Rectangle("StripScorer",0, - DetectorSize, - DetectorSize, - NumberOfStrip, - 1); + new SILICONSCORERS::PS_Silicon_Rectangle("StripScorer", 0, DetectorSize, DetectorSize, NumberOfStrip, 1); m_StripScorer->RegisterPrimitive(StripScorer); G4SDManager::GetSDMpointer()->AddNewDetector(m_StripScorer); @@ -455,7 +414,7 @@ void QQQ::InitializeScorers(){ //////////////////////////////////////////////////////////////// /////////////////Material Definition /////////////////////////// //////////////////////////////////////////////////////////////// -void QQQ::InitializeMaterial(){ +void QQQ::InitializeMaterial() { m_MaterialSilicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); m_MaterialAl = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); m_MaterialVacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); @@ -464,25 +423,22 @@ void QQQ::InitializeMaterial(){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* QQQ::Construct(){ - return (NPS::VDetector*) new QQQ(); -} +NPS::VDetector* QQQ::Construct() { return (NPS::VDetector*)new QQQ(); } //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_qqq{ - public: - proxy_nps_qqq(){ - NPS::DetectorFactory::getInstance()->AddToken("QQQ","QQQ"); - NPS::DetectorFactory::getInstance()->AddDetector("QQQ",QQQ::Construct); - } - }; - - proxy_nps_qqq p_nps_qqq; +extern "C" { +class proxy_nps_qqq { + public: + proxy_nps_qqq() { + NPS::DetectorFactory::getInstance()->AddToken("QQQ", "QQQ"); + NPS::DetectorFactory::getInstance()->AddDetector("QQQ", QQQ::Construct); + } +}; + +proxy_nps_qqq p_nps_qqq; } diff --git a/NPSimulation/Detectors/SSSD/SSSD.cc b/NPSimulation/Detectors/SSSD/SSSD.cc index f97dd4f90..218c52c7b 100644 --- a/NPSimulation/Detectors/SSSD/SSSD.cc +++ b/NPSimulation/Detectors/SSSD/SSSD.cc @@ -20,34 +20,34 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> -//G4 Geometry object -#include "G4Trd.hh" +#include <sstream> +// G4 Geometry object #include "G4Box.hh" #include "G4Trap.hh" +#include "G4Trd.hh" -//G4 sensitive -#include "G4SDManager.hh" +// G4 sensitive #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" -//G4 various object -#include "G4Material.hh" -#include "G4Transform3D.hh" -#include "G4PVPlacement.hh" -#include "G4VisAttributes.hh" +// G4 various object #include "G4Colour.hh" +#include "G4Material.hh" #include "G4PVDivision.hh" +#include "G4PVPlacement.hh" #include "G4SubtractionSolid.hh" +#include "G4Transform3D.hh" +#include "G4VisAttributes.hh" // NPTool header -#include "SSSD.hh" #include "MaterialManager.hh" +#include "NPOptionManager.h" #include "NPSDetectorFactory.hh" -#include "SiliconScorers.hh" #include "RootOutput.h" -#include "NPOptionManager.h" +#include "SSSD.hh" +#include "SiliconScorers.hh" using namespace SSSD_LOCAL; // CLHEP header @@ -60,21 +60,16 @@ using namespace CLHEP; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // SSSD Specific Method -SSSD::SSSD(){ +SSSD::SSSD() { InitializeMaterial(); m_Event = new TSSSDData(); - m_StripScorer=0; + m_StripScorer = 0; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -SSSD::~SSSD(){ -} +SSSD::~SSSD() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void SSSD::AddTelescope( G4ThreeVector TL, - G4ThreeVector BL, - G4ThreeVector BR, - G4ThreeVector TR) -{ +void SSSD::AddTelescope(G4ThreeVector TL, G4ThreeVector BL, G4ThreeVector BR, G4ThreeVector TR) { m_DefinitionType.push_back(true); m_TL.push_back(TL); @@ -90,13 +85,7 @@ void SSSD::AddTelescope( G4ThreeVector TL, m_beta_w.push_back(0); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void SSSD::AddTelescope( G4double R, - G4double Theta, - G4double Phi, - G4double beta_u, - G4double beta_v, - G4double beta_w) -{ +void SSSD::AddTelescope(G4double R, G4double Theta, G4double Phi, G4double beta_u, G4double beta_v, G4double beta_w) { G4ThreeVector empty = G4ThreeVector(0, 0, 0); m_DefinitionType.push_back(false); @@ -112,20 +101,15 @@ void SSSD::AddTelescope( G4double R, m_BL.push_back(empty); m_BR.push_back(empty); m_TR.push_back(empty); - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void SSSD::VolumeMaker( G4int DetNumber , - G4ThreeVector Det_pos , - G4RotationMatrix* Det_rot , - G4LogicalVolume* world ) -{ - G4double NbrTelescopes = DetNumber ; - G4String DetectorNumber ; - std::ostringstream Number ; - Number << NbrTelescopes ; - DetectorNumber = Number.str() ; +void SSSD::VolumeMaker(G4int DetNumber, G4ThreeVector Det_pos, G4RotationMatrix* Det_rot, G4LogicalVolume* world) { + G4double NbrTelescopes = DetNumber; + G4String DetectorNumber; + std::ostringstream Number; + Number << NbrTelescopes; + DetectorNumber = Number.str(); //////////////////////////////////////////////////////////////// /////////General Geometry Parameter Definition ///////////////// @@ -133,97 +117,61 @@ void SSSD::VolumeMaker( G4int DetNumber , /////// Starting Volume Definition /////// G4String Name = "SSSD" + DetectorNumber; - G4Box* solidSSSD = new G4Box(Name+"Solid", 0.5*DetectorSize, 0.5*DetectorSize, 0.5*FrameThickness); + G4Box* solidSSSD = new G4Box(Name + "Solid", 0.5 * DetectorSize, 0.5 * DetectorSize, 0.5 * FrameThickness); - G4LogicalVolume* logicSSSD = - new G4LogicalVolume(solidSSSD, m_MaterialVacuum, Name+"_logic", 0, 0); + G4LogicalVolume* logicSSSD = new G4LogicalVolume(solidSSSD, m_MaterialVacuum, Name + "_logic", 0, 0); - new G4PVPlacement( G4Transform3D(*Det_rot, Det_pos) , - logicSSSD , - Name , - world , - false , - DetNumber); + new G4PVPlacement(G4Transform3D(*Det_rot, Det_pos), logicSSSD, Name, world, false, DetNumber); - logicSSSD->SetVisAttributes(G4VisAttributes::Invisible); + logicSSSD->SetVisAttributes(G4VisAttributes::GetInvisible()); // Frame is made of 4 thick box (2 Horizontal and 2 Vertical) - G4Box* solidFrameHorizontal = new G4Box(Name + "_Frame", 0.5*SiliconSize, 0.5*(DetectorSize - SiliconSize) / 2, 0.5*FrameThickness*mm) ; - G4Box* solidFrameVertical = new G4Box(Name + "_Frame", 0.5*(DetectorSize - SiliconSize) / 2, 0.5*DetectorSize, 0.5*FrameThickness*mm) ; + G4Box* solidFrameHorizontal = + new G4Box(Name + "_Frame", 0.5 * SiliconSize, 0.5 * (DetectorSize - SiliconSize) / 2, 0.5 * FrameThickness * mm); + G4Box* solidFrameVertical = + new G4Box(Name + "_Frame", 0.5 * (DetectorSize - SiliconSize) / 2, 0.5 * DetectorSize, 0.5 * FrameThickness * mm); G4LogicalVolume* logicFrameHorizontal = new G4LogicalVolume(solidFrameHorizontal, m_MaterialAl, Name, 0, 0); G4VisAttributes* VisAtt1 = new G4VisAttributes(G4Colour(0.0, 0.5, 1)); logicFrameHorizontal->SetVisAttributes(VisAtt1); - G4LogicalVolume* logicFrameVertical = new G4LogicalVolume(solidFrameVertical, m_MaterialAl, Name, 0, 0); - logicFrameVertical->SetVisAttributes(VisAtt1); - - G4ThreeVector FrameTopPosition = G4ThreeVector(0 , 0.5 * SiliconSize + 0.5 * (DetectorSize - SiliconSize) / 2 , 0) ; - G4ThreeVector FrameBottomPosition = G4ThreeVector(0 , -0.5 * SiliconSize - 0.5 * (DetectorSize - SiliconSize) / 2 , 0) ; - G4ThreeVector FrameLeftPosition = G4ThreeVector(0.5 * SiliconSize + 0.5 * (DetectorSize - SiliconSize) / 2 , 0 , 0) ; - G4ThreeVector FrameRightPosition = G4ThreeVector(-0.5 * SiliconSize - 0.5 * (DetectorSize - SiliconSize) / 2 , 0 , 0) ; - + logicFrameVertical->SetVisAttributes(VisAtt1); - new G4PVPlacement( 0, - FrameTopPosition, - logicFrameHorizontal, - Name + "_Frame", - logicSSSD, - false, - DetNumber); + G4ThreeVector FrameTopPosition = G4ThreeVector(0, 0.5 * SiliconSize + 0.5 * (DetectorSize - SiliconSize) / 2, 0); + G4ThreeVector FrameBottomPosition = G4ThreeVector(0, -0.5 * SiliconSize - 0.5 * (DetectorSize - SiliconSize) / 2, 0); + G4ThreeVector FrameLeftPosition = G4ThreeVector(0.5 * SiliconSize + 0.5 * (DetectorSize - SiliconSize) / 2, 0, 0); + G4ThreeVector FrameRightPosition = G4ThreeVector(-0.5 * SiliconSize - 0.5 * (DetectorSize - SiliconSize) / 2, 0, 0); - new G4PVPlacement( 0, - FrameBottomPosition, - logicFrameHorizontal, - Name + "_Frame", - logicSSSD, - false, - DetNumber); + new G4PVPlacement(0, FrameTopPosition, logicFrameHorizontal, Name + "_Frame", logicSSSD, false, DetNumber); - new G4PVPlacement( 0, - FrameLeftPosition, - logicFrameVertical, - Name + "_Frame", - logicSSSD, - false, - DetNumber); + new G4PVPlacement(0, FrameBottomPosition, logicFrameHorizontal, Name + "_Frame", logicSSSD, false, DetNumber); - new G4PVPlacement( 0, - FrameRightPosition, - logicFrameVertical, - Name + "_Frame", - logicSSSD, - false, - DetNumber); + new G4PVPlacement(0, FrameLeftPosition, logicFrameVertical, Name + "_Frame", logicSSSD, false, DetNumber); + new G4PVPlacement(0, FrameRightPosition, logicFrameVertical, Name + "_Frame", logicSSSD, false, DetNumber); - G4ThreeVector posAluFront = G4ThreeVector(0 , 0 , AluStripFront_PosZ) ; - G4ThreeVector posSi = G4ThreeVector(0 , 0 , 0 ) ; - G4ThreeVector posAluBack = G4ThreeVector(0 , 0 , AluStripBack_PosZ ) ; + G4ThreeVector posAluFront = G4ThreeVector(0, 0, AluStripFront_PosZ); + G4ThreeVector posSi = G4ThreeVector(0, 0, 0); + G4ThreeVector posAluBack = G4ThreeVector(0, 0, AluStripBack_PosZ); - G4Box* solidAlu = - new G4Box("SSSDAlu", 0.5*SiliconSize, 0.5*SiliconSize, 0.5*AluThickness) ; + G4Box* solidAlu = new G4Box("SSSDAlu", 0.5 * SiliconSize, 0.5 * SiliconSize, 0.5 * AluThickness); - G4LogicalVolume* logicAlu = - new G4LogicalVolume(solidAlu, m_MaterialAl, "logicAlu", 0, 0, 0) ; + G4LogicalVolume* logicAlu = new G4LogicalVolume(solidAlu, m_MaterialAl, "logicAlu", 0, 0, 0); + new G4PVPlacement(0, posAluFront, logicAlu, Name + "_AluFront", logicSSSD, true, DetNumber); - new G4PVPlacement(0 , posAluFront , logicAlu , Name + "_AluFront" , logicSSSD , true, DetNumber) ; + new G4PVPlacement(0, posAluBack, logicAlu, Name + "_AluBack", logicSSSD, true, DetNumber); - new G4PVPlacement(0 , posAluBack , logicAlu , Name + "_AluBack" , logicSSSD , true, DetNumber) ; + G4Box* solidSi = new G4Box("SSSD", 0.5 * SiliconSize, 0.5 * SiliconSize, 0.5 * SiliconThickness); - G4Box* solidSi = - new G4Box("SSSD", 0.5*SiliconSize, 0.5*SiliconSize, 0.5*SiliconThickness); + G4LogicalVolume* logicSi = new G4LogicalVolume(solidSi, m_MaterialSilicon, "logicSi", 0, 0, 0); - G4LogicalVolume* logicSi = - new G4LogicalVolume(solidSi, m_MaterialSilicon, "logicSi", 0, 0, 0); - - logicAlu->SetVisAttributes(G4VisAttributes::Invisible); + logicAlu->SetVisAttributes(G4VisAttributes::GetInvisible()); new G4PVPlacement(0, posSi, logicSi, Name + "_Si", logicSSSD, true, DetNumber); - //attach it to the Silicon plate - logicSi ->SetSensitiveDetector(m_StripScorer); + // attach it to the Silicon plate + logicSi->SetSensitiveDetector(m_StripScorer); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -234,55 +182,54 @@ void SSSD::VolumeMaker( G4int DetNumber , //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void SSSD::ReadConfiguration(NPL::InputParser parser){ -vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("SSSD"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " detectors found " << endl; - - vector<string> cart = {"A","B","C","D"}; - vector<string> sphe = {"R","THETA","PHI","BETA"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(cart)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// SSSD " << i+1 << endl; - G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("A","mm")); - G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("B","mm")); - G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("C","mm")); - G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("D","mm")); - AddTelescope(A,B,C,D); +void SSSD::ReadConfiguration(NPL::InputParser parser) { + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("SSSD"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + + vector<string> cart = {"A", "B", "C", "D"}; + vector<string> sphe = {"R", "THETA", "PHI", "BETA"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(cart)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// SSSD " << i + 1 << endl; + G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("A", "mm")); + G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("B", "mm")); + G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("C", "mm")); + G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("D", "mm")); + AddTelescope(A, B, C, D); } - else if(blocks[i]->HasTokenList(sphe)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// SSSD " << i+1 << endl; - double R = blocks[i]->GetDouble("R","mm"); - double Theta = blocks[i]->GetDouble("THETA","deg"); - double Phi = blocks[i]->GetDouble("PHI","deg"); - vector<double> beta = blocks[i]->GetVectorDouble("BETA","deg"); - AddTelescope(R,Theta,Phi,beta[0],beta[1],beta[2]); + else if (blocks[i]->HasTokenList(sphe)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// SSSD " << i + 1 << endl; + double R = blocks[i]->GetDouble("R", "mm"); + double Theta = blocks[i]->GetDouble("THETA", "deg"); + double Phi = blocks[i]->GetDouble("PHI", "deg"); + vector<double> beta = blocks[i]->GetVectorDouble("BETA", "deg"); + AddTelescope(R, Theta, Phi, beta[0], beta[1], beta[2]); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } } } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void SSSD::ConstructDetector(G4LogicalVolume* world){ +void SSSD::ConstructDetector(G4LogicalVolume* world) { - G4RotationMatrix* Det_rot = NULL; - G4ThreeVector Det_pos = G4ThreeVector(0, 0, 0); - G4ThreeVector Det_u = G4ThreeVector(0, 0, 0); - G4ThreeVector Det_v = G4ThreeVector(0, 0, 0); - G4ThreeVector Det_w = G4ThreeVector(0, 0, 0); + G4RotationMatrix* Det_rot = NULL; + G4ThreeVector Det_pos = G4ThreeVector(0, 0, 0); + G4ThreeVector Det_u = G4ThreeVector(0, 0, 0); + G4ThreeVector Det_v = G4ThreeVector(0, 0, 0); + G4ThreeVector Det_w = G4ThreeVector(0, 0, 0); G4int NumberOfDetector = m_DefinitionType.size(); - for (G4int i = 0 ; i < NumberOfDetector ; i++) { + for (G4int i = 0; i < NumberOfDetector; i++) { // By Point if (m_DefinitionType[i]) { // (u,v,w) unitary vector associated to telescope referencial @@ -298,26 +245,28 @@ void SSSD::ConstructDetector(G4LogicalVolume* world){ // MUST2 Det_rot = new G4RotationMatrix(Det_u, Det_v, Det_w); // translation to place Telescope - Det_pos = (m_TR[i]+m_TL[i]+m_BL[i]+m_BR[i])/4 ; + Det_pos = (m_TR[i] + m_TL[i] + m_BL[i] + m_BR[i]) / 4; } // By Angle else { G4double Theta = m_Theta[i]; - G4double Phi = m_Phi[i]; - //This part because if Phi and Theta = 0 equation are false - if (Theta == 0) Theta = 0.0001; - if (Theta == 2*cos(0)) Theta = 2 * acos(0) - 0.00001; - if (Phi == 0) Phi = 0.0001; - + G4double Phi = m_Phi[i]; + // This part because if Phi and Theta = 0 equation are false + if (Theta == 0) + Theta = 0.0001; + if (Theta == 2 * cos(0)) + Theta = 2 * acos(0) - 0.00001; + if (Phi == 0) + Phi = 0.0001; // (u,v,w) unitary vector associated to telescope referencial // (u,v) // to silicon plan // w perpendicular to (u,v) plan and pointing ThirdStage // Phi is angle between X axis and projection in (X,Y) plan // Theta is angle between position vector and z axis - G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad) ; - G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad) ; + G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad); + G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad); G4double wZ = m_R[i] * cos(Theta / rad); Det_w = G4ThreeVector(wX, wY, wZ); @@ -344,79 +293,73 @@ void SSSD::ConstructDetector(G4LogicalVolume* world){ Det_rot->rotate(m_beta_v[i], Det_v); Det_rot->rotate(m_beta_w[i], Det_w); // translation to place Telescope - Det_pos = Det_w + CT ; + Det_pos = Det_w + CT; } - VolumeMaker(i + 1 , Det_pos , Det_rot , world); + VolumeMaker(i + 1, Det_pos, Det_rot, world); } - delete Det_rot ; + delete Det_rot; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void SSSD::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("SSSD")){ - pTree->Branch("SSSD", "TSSSDData", &m_Event) ; +void SSSD::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("SSSD")) { + pTree->Branch("SSSD", "TSSSDData", &m_Event); } - pTree->SetBranchAddress("SSSD", &m_Event) ; + pTree->SetBranchAddress("SSSD", &m_Event); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void SSSD::ReadSensitive(const G4Event* event){ +void SSSD::ReadSensitive(const G4Event* event) { m_Event->Clear(); /////////// NPS::HitsMap<G4double*>* StripHitMap; std::map<G4int, G4double**>::iterator Strip_itr; - + G4int StripCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("SSSD_Scorer/StripScorer"); StripHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(StripCollectionID)); - + // Loop on the Strip map - for (Strip_itr = StripHitMap->GetMap()->begin() ; Strip_itr != StripHitMap->GetMap()->end() ; Strip_itr++){ - + for (Strip_itr = StripHitMap->GetMap()->begin(); Strip_itr != StripHitMap->GetMap()->end(); Strip_itr++) { + G4double* Info = *(Strip_itr->second); - + double Energy = Info[0]; - - if(Energy>EnergyThreshold){ - double Time = Info[1]; - int DetNbr = (int) Info[7]; - int StripFront = (int) Info[8]; + + if (Energy > EnergyThreshold) { + double Time = Info[1]; + int DetNbr = (int)Info[7]; + int StripFront = (int)Info[8]; m_Event->SetEnergyDetectorNbr(DetNbr); m_Event->SetEnergyStripNbr(StripFront); m_Event->SetEnergy(RandGauss::shoot(Energy, ResoEnergy)); - + m_Event->SetTimeDetectorNbr(DetNbr); m_Event->SetTimeStripNbr(StripFront); m_Event->SetTime(RandGauss::shoot(Time, ResoTime)); - } } // clear map for next event StripHitMap->clear(); - - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void SSSD::InitializeScorers(){ +void SSSD::InitializeScorers() { bool already_exist = false; // Silicon Associate Scorer - m_StripScorer = CheckScorer("SSSD_Scorer",already_exist); - if(already_exist) return; + m_StripScorer = CheckScorer("SSSD_Scorer", already_exist); + if (already_exist) + return; G4VPrimitiveScorer* StripScorer = - new SILICONSCORERS::PS_Silicon_Rectangle("StripScorer",0, - DetectorSize, - DetectorSize, - NumberOfStrip, - 1); + new SILICONSCORERS::PS_Silicon_Rectangle("StripScorer", 0, DetectorSize, DetectorSize, NumberOfStrip, 1); m_StripScorer->RegisterPrimitive(StripScorer); G4SDManager::GetSDMpointer()->AddNewDetector(m_StripScorer); @@ -426,7 +369,7 @@ void SSSD::InitializeScorers(){ //////////////////////////////////////////////////////////////// /////////////////Material Definition /////////////////////////// //////////////////////////////////////////////////////////////// -void SSSD::InitializeMaterial(){ +void SSSD::InitializeMaterial() { m_MaterialSilicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); m_MaterialAl = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); m_MaterialVacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); @@ -435,25 +378,22 @@ void SSSD::InitializeMaterial(){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* SSSD::Construct(){ - return (NPS::VDetector*) new SSSD(); -} +NPS::VDetector* SSSD::Construct() { return (NPS::VDetector*)new SSSD(); } //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_sssd{ - public: - proxy_nps_sssd(){ - NPS::DetectorFactory::getInstance()->AddToken("SSSD","SSSD"); - NPS::DetectorFactory::getInstance()->AddDetector("SSSD",SSSD::Construct); - } - }; - - proxy_nps_sssd p_nps_sssd; +extern "C" { +class proxy_nps_sssd { + public: + proxy_nps_sssd() { + NPS::DetectorFactory::getInstance()->AddToken("SSSD", "SSSD"); + NPS::DetectorFactory::getInstance()->AddDetector("SSSD", SSSD::Construct); + } +}; + +proxy_nps_sssd p_nps_sssd; } diff --git a/NPSimulation/Detectors/Sharc/Sharc.cc b/NPSimulation/Detectors/Sharc/Sharc.cc index fc0dd0dec..8def44b37 100644 --- a/NPSimulation/Detectors/Sharc/Sharc.cc +++ b/NPSimulation/Detectors/Sharc/Sharc.cc @@ -20,32 +20,32 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> -//G4 Geometry object +#include <sstream> +// G4 Geometry object #include "G4Box.hh" #include "G4Tubs.hh" -//G4 sensitive +// G4 sensitive #include "G4SDManager.hh" -//G4 various object -#include "G4MaterialTable.hh" +// G4 various object +#include "G4Colour.hh" #include "G4Element.hh" #include "G4ElementTable.hh" -#include "G4Transform3D.hh" -#include "G4PVPlacement.hh" -#include "G4Colour.hh" +#include "G4MaterialTable.hh" #include "G4PVDivision.hh" +#include "G4PVPlacement.hh" #include "G4SubtractionSolid.hh" +#include "G4Transform3D.hh" #include "G4UnionSolid.hh" // NPS -#include "Sharc.hh" #include "DSSDScorers.hh" #include "InteractionScorers.hh" #include "MaterialManager.hh" #include "NPSDetectorFactory.hh" +#include "Sharc.hh" // NPL #include "NPOptionManager.h" @@ -60,33 +60,34 @@ using namespace CLHEP; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Sharc Specific Method -Sharc::Sharc(){ +Sharc::Sharc() { InitializeMaterial(); m_Event = new TSharcData(); // Dark Grey - SiliconVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)) ; + SiliconVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)); // Green - PCBVisAtt = new G4VisAttributes(G4Colour(0.2, 0.5, 0.2)) ; + PCBVisAtt = new G4VisAttributes(G4Colour(0.2, 0.5, 0.2)); // Gold Yellow - PADVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.2)) ; + PADVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.2)); // Light Grey - FrameVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)) ; + FrameVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)); - m_BOXScorer = 0 ; - m_PADScorer = 0 ; + m_BOXScorer = 0; + m_PADScorer = 0; m_QQQScorer = 0; - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Sharc::~Sharc(){ - //delete m_BOXScorer; - //delete m_PADScorer; - //delete m_QQQScorer; +Sharc::~Sharc() { + // delete m_BOXScorer; + // delete m_PADScorer; + // delete m_QQQScorer; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Sharc::AddBoxDetector(G4double Z,G4double Thickness1,G4double Thickness2,G4double Thickness3,G4double Thickness4,G4double ThicknessPAD1,G4double ThicknessPAD2,G4double ThicknessPAD3,G4double ThicknessPAD4){ +void Sharc::AddBoxDetector(G4double Z, G4double Thickness1, G4double Thickness2, G4double Thickness3, + G4double Thickness4, G4double ThicknessPAD1, G4double ThicknessPAD2, G4double ThicknessPAD3, + G4double ThicknessPAD4) { m_Type.push_back(true); m_Z.push_back(Z); @@ -104,11 +105,10 @@ void Sharc::AddBoxDetector(G4double Z,G4double Thickness1,G4double Thickness2,G4 ThicknessPAD.push_back(ThicknessPAD3); ThicknessPAD.push_back(ThicknessPAD4); m_ThicknessPAD.push_back(ThicknessPAD); - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Sharc::AddQQQDetector(G4ThreeVector Pos,G4double Thickness){ +void Sharc::AddQQQDetector(G4ThreeVector Pos, G4double Thickness) { m_Type.push_back(false); m_Pos.push_back(Pos); m_ThicknessQQQ.push_back(Thickness); @@ -118,43 +118,50 @@ void Sharc::AddQQQDetector(G4ThreeVector Pos,G4double Thickness){ // Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Sharc::ReadConfiguration(NPL::InputParser parser){ +void Sharc::ReadConfiguration(NPL::InputParser parser) { vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Sharc"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " detectors found " << endl; - - vector<string> tokenQQQ = {"Z","R","Phi","ThicknessDetector"}; - vector<string> tokenBOX = {"Z","ThicknessDetector1","ThicknessDetector2","ThicknessDetector3","ThicknessDetector4","ThicknessPAD1","ThicknessPAD2","ThicknessPAD3","ThicknessPAD4"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - - if(blocks[i]->GetMainValue()=="QQQ" && blocks[i]->HasTokenList(tokenQQQ)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Sharc QQQ " << i+1 << endl; - double Z = blocks[i]->GetDouble("Z","mm"); - double R = blocks[i]->GetDouble("R","mm"); - double Phi = blocks[i]->GetDouble("Phi","deg"); - double Thickness= blocks[i]->GetDouble("ThicknessDetector","micrometer"); - AddQQQDetector(G4ThreeVector(R,Phi,Z),Thickness); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + + vector<string> tokenQQQ = {"Z", "R", "Phi", "ThicknessDetector"}; + vector<string> tokenBOX = {"Z", + "ThicknessDetector1", + "ThicknessDetector2", + "ThicknessDetector3", + "ThicknessDetector4", + "ThicknessPAD1", + "ThicknessPAD2", + "ThicknessPAD3", + "ThicknessPAD4"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + + if (blocks[i]->GetMainValue() == "QQQ" && blocks[i]->HasTokenList(tokenQQQ)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Sharc QQQ " << i + 1 << endl; + double Z = blocks[i]->GetDouble("Z", "mm"); + double R = blocks[i]->GetDouble("R", "mm"); + double Phi = blocks[i]->GetDouble("Phi", "deg"); + double Thickness = blocks[i]->GetDouble("ThicknessDetector", "micrometer"); + AddQQQDetector(G4ThreeVector(R, Phi, Z), Thickness); } - else if(blocks[i]->GetMainValue()=="BOX" && blocks[i]->HasTokenList(tokenBOX)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Sharc Box " << i+1 << endl; - double Z = blocks[i]->GetDouble("Z","mm"); - double Thickness1= blocks[i]->GetDouble("ThicknessDetector1","micrometer"); - double Thickness2= blocks[i]->GetDouble("ThicknessDetector2","micrometer"); - double Thickness3= blocks[i]->GetDouble("ThicknessDetector3","micrometer"); - double Thickness4= blocks[i]->GetDouble("ThicknessDetector4","micrometer"); - double ThicknessPAD1 = blocks[i]->GetDouble("ThicknessPAD1","micrometer"); - double ThicknessPAD2 = blocks[i]->GetDouble("ThicknessPAD2","micrometer"); - double ThicknessPAD3 = blocks[i]->GetDouble("ThicknessPAD3","micrometer"); - double ThicknessPAD4 = blocks[i]->GetDouble("ThicknessPAD4","micrometer"); - AddBoxDetector(Z,Thickness1,Thickness2,Thickness3,Thickness4, - ThicknessPAD1,ThicknessPAD2,ThicknessPAD3,ThicknessPAD4); - + else if (blocks[i]->GetMainValue() == "BOX" && blocks[i]->HasTokenList(tokenBOX)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Sharc Box " << i + 1 << endl; + double Z = blocks[i]->GetDouble("Z", "mm"); + double Thickness1 = blocks[i]->GetDouble("ThicknessDetector1", "micrometer"); + double Thickness2 = blocks[i]->GetDouble("ThicknessDetector2", "micrometer"); + double Thickness3 = blocks[i]->GetDouble("ThicknessDetector3", "micrometer"); + double Thickness4 = blocks[i]->GetDouble("ThicknessDetector4", "micrometer"); + double ThicknessPAD1 = blocks[i]->GetDouble("ThicknessPAD1", "micrometer"); + double ThicknessPAD2 = blocks[i]->GetDouble("ThicknessPAD2", "micrometer"); + double ThicknessPAD3 = blocks[i]->GetDouble("ThicknessPAD3", "micrometer"); + double ThicknessPAD4 = blocks[i]->GetDouble("ThicknessPAD4", "micrometer"); + AddBoxDetector(Z, Thickness1, Thickness2, Thickness3, Thickness4, ThicknessPAD1, ThicknessPAD2, ThicknessPAD3, + ThicknessPAD4); } - else{ + else { cout << "Warning: check your input file formatting " << endl; } } @@ -163,166 +170,136 @@ void Sharc::ReadConfiguration(NPL::InputParser parser){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void Sharc::ConstructDetector(G4LogicalVolume* world){ +void Sharc::ConstructDetector(G4LogicalVolume* world) { ConstructBOXDetector(world); ConstructQQQDetector(world); ConstructTargetFan(world); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Sharc::ConstructTargetFan(G4LogicalVolume* world){ - G4double FanBase_OutterRadius = 8*mm; - G4double FanBase_InnerRadius = 4*mm; - G4double FanBase_Thickness = 9*mm; - - G4double FanPlate_OutterRadius = 66*mm; - G4double FanPlate_InnerRadius = 0*mm; - G4double FanPlateHole_OutterRadius = 53*mm; - G4double FanPlateHole_InnerRadius = 18*mm; - G4double FanPlate_Thickness = 3*mm; - - //G4double TargetFrame_Thickness; - //TargetFrame_Thickness= 0.5*mm; - G4double Fan_Shift = 70*mm+16*mm; - - G4Tubs* FanBaseSolid= new G4Tubs("TargetFanBase" , - FanBase_InnerRadius, - FanBase_OutterRadius, - FanBase_Thickness*0.5, - 0., - M_PI*2); - - G4Tubs* FanPlateWholeSolid= new G4Tubs("TargetFanPlate" , - FanPlate_InnerRadius, - FanPlate_OutterRadius, - FanPlate_Thickness*0.5, - 0*deg, - 60*deg); - - G4Tubs* FanPlateHoleSolid= new G4Tubs("TargetFanPlateHole" , - FanPlateHole_InnerRadius, - FanPlateHole_OutterRadius, - FanPlate_Thickness, - 0*deg, - 60*deg); - - G4SubtractionSolid* FanPlateSolid = - new G4SubtractionSolid("TargetFanSolid",FanPlateWholeSolid,FanPlateHoleSolid,new G4RotationMatrix(),G4ThreeVector(8*mm*sin(60*deg),8*mm*cos(60*deg),0)); +void Sharc::ConstructTargetFan(G4LogicalVolume* world) { + G4double FanBase_OutterRadius = 8 * mm; + G4double FanBase_InnerRadius = 4 * mm; + G4double FanBase_Thickness = 9 * mm; + G4double FanPlate_OutterRadius = 66 * mm; + G4double FanPlate_InnerRadius = 0 * mm; + G4double FanPlateHole_OutterRadius = 53 * mm; + G4double FanPlateHole_InnerRadius = 18 * mm; + G4double FanPlate_Thickness = 3 * mm; - G4UnionSolid* TargetFanSolid = - new G4UnionSolid("TargetFanSolid",FanPlateSolid,FanBaseSolid,new G4RotationMatrix(),G4ThreeVector(16*mm*sin(60*deg),16*mm*cos(60*deg),FanPlate_Thickness)); + // G4double TargetFrame_Thickness; + // TargetFrame_Thickness= 0.5*mm; + G4double Fan_Shift = 70 * mm + 16 * mm; + G4Tubs* FanBaseSolid = + new G4Tubs("TargetFanBase", FanBase_InnerRadius, FanBase_OutterRadius, FanBase_Thickness * 0.5, 0., M_PI * 2); - G4LogicalVolume* TargetFan = - new G4LogicalVolume(TargetFanSolid,m_MaterialVacuum,"TargetFan", 0, 0, 0); + G4Tubs* FanPlateWholeSolid = new G4Tubs("TargetFanPlate", FanPlate_InnerRadius, FanPlate_OutterRadius, + FanPlate_Thickness * 0.5, 0 * deg, 60 * deg); - G4RotationMatrix* Rot = new G4RotationMatrix(); - Rot->rotateZ(30*deg-9*deg); - new G4PVPlacement(Rot, - G4ThreeVector(-Fan_Shift,0,0.5*FanPlate_Thickness), - TargetFan,"TargetFan",world,false,0); + G4Tubs* FanPlateHoleSolid = new G4Tubs("TargetFanPlateHole", FanPlateHole_InnerRadius, FanPlateHole_OutterRadius, + FanPlate_Thickness, 0 * deg, 60 * deg); + G4SubtractionSolid* FanPlateSolid = + new G4SubtractionSolid("TargetFanSolid", FanPlateWholeSolid, FanPlateHoleSolid, new G4RotationMatrix(), + G4ThreeVector(8 * mm * sin(60 * deg), 8 * mm * cos(60 * deg), 0)); + G4UnionSolid* TargetFanSolid = + new G4UnionSolid("TargetFanSolid", FanPlateSolid, FanBaseSolid, new G4RotationMatrix(), + G4ThreeVector(16 * mm * sin(60 * deg), 16 * mm * cos(60 * deg), FanPlate_Thickness)); + + G4LogicalVolume* TargetFan = new G4LogicalVolume(TargetFanSolid, m_MaterialVacuum, "TargetFan", 0, 0, 0); + + G4RotationMatrix* Rot = new G4RotationMatrix(); + Rot->rotateZ(30 * deg - 9 * deg); + new G4PVPlacement(Rot, G4ThreeVector(-Fan_Shift, 0, 0.5 * FanPlate_Thickness), TargetFan, "TargetFan", world, false, + 0); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Sharc::ConstructBOXDetector(G4LogicalVolume* world){ - for(unsigned int i = 0 ; i < m_Z.size() ; i++){ - for (unsigned int j = 0 ; j < 4; j++) { +void Sharc::ConstructBOXDetector(G4LogicalVolume* world) { + for (unsigned int i = 0; i < m_Z.size(); i++) { + for (unsigned int j = 0; j < 4; j++) { int DetNbr = 0; - if(m_Z[i]<0) DetNbr=j+1+4; - else DetNbr=j+1+8; + if (m_Z[i] < 0) + DetNbr = j + 1 + 4; + else + DetNbr = j + 1 + 8; // create the Box DSSD // Make the a single detector geometry - G4Box* PCBFull = new G4Box("PCBFull" , - BOX_PCB_Length/2., - BOX_PCB_Width/2., - BOX_PCB_Thickness/2.); - - G4Box* WaferShape = new G4Box("WaferShape", - BOX_Wafer_Length/2., - BOX_Wafer_Width/2., - BOX_PCB_Thickness/2.+0.1*mm); - - G4Box* Wafer = new G4Box("Wafer", - BOX_Wafer_Length/2., - BOX_Wafer_Width/2., - m_ThicknessBOX[i][j]/2.); - - G4Box* ActiveWafer = new G4Box("ActiveWafer", - BOX_ActiveWafer_Length/2., - BOX_ActiveWafer_Width/2., - m_ThicknessBOX[i][j]/2.); + G4Box* PCBFull = new G4Box("PCBFull", BOX_PCB_Length / 2., BOX_PCB_Width / 2., BOX_PCB_Thickness / 2.); + + G4Box* WaferShape = + new G4Box("WaferShape", BOX_Wafer_Length / 2., BOX_Wafer_Width / 2., BOX_PCB_Thickness / 2. + 0.1 * mm); + + G4Box* Wafer = new G4Box("Wafer", BOX_Wafer_Length / 2., BOX_Wafer_Width / 2., m_ThicknessBOX[i][j] / 2.); + + G4Box* ActiveWafer = + new G4Box("ActiveWafer", BOX_ActiveWafer_Length / 2., BOX_ActiveWafer_Width / 2., m_ThicknessBOX[i][j] / 2.); G4double BOX_PCB_Slot_Width; G4double BOX_PCB_Slot_Deepness; G4double BOX_PCB_Slot_Position; G4double BOX_DetectorSpacing; - if(m_ThicknessPAD[i][j]>0){ //PAD Case + if (m_ThicknessPAD[i][j] > 0) { // PAD Case BOX_PCB_Slot_Width = BOX_PCB_Slot_Width2; BOX_PCB_Slot_Deepness = BOX_PCB_Slot_Deepness2; BOX_PCB_Slot_Position = BOX_PCB_Slot_Position2; - BOX_DetectorSpacing = BOX_DetectorSpacing2; + BOX_DetectorSpacing = BOX_DetectorSpacing2; } - else{ // No Pad Case + else { // No Pad Case BOX_PCB_Slot_Width = BOX_PCB_Slot_Width1; BOX_PCB_Slot_Deepness = BOX_PCB_Slot_Deepness1; BOX_PCB_Slot_Position = BOX_PCB_Slot_Position1; - BOX_DetectorSpacing = BOX_DetectorSpacing1 ; + BOX_DetectorSpacing = BOX_DetectorSpacing1; } - G4Box* SlotShape = new G4Box("SlotShape", - BOX_PCB_Slot_Width/2., - BOX_PCB_Width/2.+0.1*mm, - BOX_PCB_Slot_Deepness); + G4Box* SlotShape = + new G4Box("SlotShape", BOX_PCB_Slot_Width / 2., BOX_PCB_Width / 2. + 0.1 * mm, BOX_PCB_Slot_Deepness); - - G4ThreeVector Box_Wafer_Offset ; - if(m_Z[i]<0 ){ - Box_Wafer_Offset = G4ThreeVector(BOX_Wafer_Length_Offset1, BOX_Wafer_Width_Offset1,0 ); + G4ThreeVector Box_Wafer_Offset; + if (m_Z[i] < 0) { + Box_Wafer_Offset = G4ThreeVector(BOX_Wafer_Length_Offset1, BOX_Wafer_Width_Offset1, 0); } - else{ - Box_Wafer_Offset = G4ThreeVector(BOX_Wafer_Length_Offset2, BOX_Wafer_Width_Offset2,0 ); + else { + Box_Wafer_Offset = G4ThreeVector(BOX_Wafer_Length_Offset2, BOX_Wafer_Width_Offset2, 0); } - G4SubtractionSolid* PCB1 = new G4SubtractionSolid("PCB", PCBFull, SlotShape,new G4RotationMatrix,G4ThreeVector(BOX_PCB_Slot_Position, 0,0.5*BOX_PCB_Thickness)); - G4SubtractionSolid* PCB = new G4SubtractionSolid("PCB", PCB1, WaferShape,new G4RotationMatrix,Box_Wafer_Offset); + G4SubtractionSolid* PCB1 = + new G4SubtractionSolid("PCB", PCBFull, SlotShape, new G4RotationMatrix, + G4ThreeVector(BOX_PCB_Slot_Position, 0, 0.5 * BOX_PCB_Thickness)); + G4SubtractionSolid* PCB = new G4SubtractionSolid("PCB", PCB1, WaferShape, new G4RotationMatrix, Box_Wafer_Offset); // Master Volume - G4LogicalVolume* logicBoxDetector = - new G4LogicalVolume(PCB1,m_MaterialVacuum,"logicBoxDetector", 0, 0, 0); - logicBoxDetector->SetVisAttributes(G4VisAttributes::Invisible); + G4LogicalVolume* logicBoxDetector = new G4LogicalVolume(PCB1, m_MaterialVacuum, "logicBoxDetector", 0, 0, 0); + logicBoxDetector->SetVisAttributes(G4VisAttributes::GetInvisible()); // Sub Volume PCB - G4LogicalVolume* logicPCB = - new G4LogicalVolume(PCB,m_MaterialPCB,"logicPCB", 0, 0, 0); + G4LogicalVolume* logicPCB = new G4LogicalVolume(PCB, m_MaterialPCB, "logicPCB", 0, 0, 0); logicPCB->SetVisAttributes(PCBVisAtt); // Sub Volume Wafer - G4LogicalVolume* logicWafer = - new G4LogicalVolume(Wafer,m_MaterialSilicon,"logicWafer", 0, 0, 0); + G4LogicalVolume* logicWafer = new G4LogicalVolume(Wafer, m_MaterialSilicon, "logicWafer", 0, 0, 0); G4LogicalVolume* logicActiveWafer = - new G4LogicalVolume(ActiveWafer,m_MaterialSilicon,"logicActiveWafer", 0, 0, 0); + new G4LogicalVolume(ActiveWafer, m_MaterialSilicon, "logicActiveWafer", 0, 0, 0); logicWafer->SetVisAttributes(SiliconVisAtt); logicActiveWafer->SetVisAttributes(SiliconVisAtt); // Place the sub volume in the master volume - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0), - logicPCB,"Box_PCB",logicBoxDetector,false,DetNbr); - - if(m_ThicknessBOX[i][j]>0){ - new G4PVPlacement(new G4RotationMatrix(0,0,0), - Box_Wafer_Offset+G4ThreeVector(0,0,0.5*BOX_PCB_Thickness-0.5*m_ThicknessBOX[i][j]), - logicWafer,"Box_Wafer",logicBoxDetector,false,DetNbr); - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0), - logicActiveWafer,"Box_ActiveWafer",logicWafer,false,DetNbr); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicPCB, "Box_PCB", logicBoxDetector, + false, DetNbr); + + if (m_ThicknessBOX[i][j] > 0) { + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), + Box_Wafer_Offset + G4ThreeVector(0, 0, 0.5 * BOX_PCB_Thickness - 0.5 * m_ThicknessBOX[i][j]), + logicWafer, "Box_Wafer", logicBoxDetector, false, DetNbr); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicActiveWafer, "Box_ActiveWafer", + logicWafer, false, DetNbr); logicActiveWafer->SetSensitiveDetector(m_BOXScorer); } @@ -331,397 +308,322 @@ void Sharc::ConstructBOXDetector(G4LogicalVolume* world){ // Make a single detector geometry G4LogicalVolume* logicPADDetector = NULL; - G4ThreeVector PAD_Wafer_Offset = - G4ThreeVector(PAD_Wafer_Length_Offset, PAD_Wafer_Width_Offset,0 ); - if(m_ThicknessPAD[i][j]>0){ - G4Box* PADDetector = new G4Box("PADDetector" , - PAD_PCB_Length/2., - PAD_PCB_Width/2., - PAD_PCB_Thickness/2.); - - G4Box* PADPCBFull = new G4Box("PCBFull" , - PAD_PCB_Length/2., - PAD_PCB_Width/2., - PAD_PCB_Thickness/2.); + G4ThreeVector PAD_Wafer_Offset = G4ThreeVector(PAD_Wafer_Length_Offset, PAD_Wafer_Width_Offset, 0); + if (m_ThicknessPAD[i][j] > 0) { + G4Box* PADDetector = new G4Box("PADDetector", PAD_PCB_Length / 2., PAD_PCB_Width / 2., PAD_PCB_Thickness / 2.); - G4Box* PADWaferShape = new G4Box("PADWaferShape", - PAD_Wafer_Length/2., - PAD_Wafer_Width/2., - PAD_PCB_Thickness/2.+0.1*mm); + G4Box* PADPCBFull = new G4Box("PCBFull", PAD_PCB_Length / 2., PAD_PCB_Width / 2., PAD_PCB_Thickness / 2.); - G4Box* PADWafer = new G4Box("PADWafer", - PAD_Wafer_Length/2., - PAD_Wafer_Width/2., - m_ThicknessPAD[i][j]/2.); + G4Box* PADWaferShape = + new G4Box("PADWaferShape", PAD_Wafer_Length / 2., PAD_Wafer_Width / 2., PAD_PCB_Thickness / 2. + 0.1 * mm); - G4Box* PADActiveWafer = new G4Box("PADActiveWafer", - PAD_ActiveWafer_Length/2., - PAD_ActiveWafer_Width/2., - m_ThicknessPAD[i][j]/2.); + G4Box* PADWafer = new G4Box("PADWafer", PAD_Wafer_Length / 2., PAD_Wafer_Width / 2., m_ThicknessPAD[i][j] / 2.); + G4Box* PADActiveWafer = new G4Box("PADActiveWafer", PAD_ActiveWafer_Length / 2., PAD_ActiveWafer_Width / 2., + m_ThicknessPAD[i][j] / 2.); - G4SubtractionSolid* PADPCB = new G4SubtractionSolid("PADPCB", PADPCBFull, PADWaferShape,new G4RotationMatrix,PAD_Wafer_Offset); + G4SubtractionSolid* PADPCB = + new G4SubtractionSolid("PADPCB", PADPCBFull, PADWaferShape, new G4RotationMatrix, PAD_Wafer_Offset); // Master Volume - logicPADDetector = - new G4LogicalVolume(PADDetector,m_MaterialVacuum,"logicPADDetector", 0, 0, 0); - logicPADDetector->SetVisAttributes(G4VisAttributes::Invisible); + logicPADDetector = new G4LogicalVolume(PADDetector, m_MaterialVacuum, "logicPADDetector", 0, 0, 0); + logicPADDetector->SetVisAttributes(G4VisAttributes::GetInvisible()); // Sub Volume PCB - G4LogicalVolume* logicPADPCB = - new G4LogicalVolume(PADPCB,m_MaterialPCB,"logicPADPCB", 0, 0, 0); + G4LogicalVolume* logicPADPCB = new G4LogicalVolume(PADPCB, m_MaterialPCB, "logicPADPCB", 0, 0, 0); logicPADPCB->SetVisAttributes(PADVisAtt); // Sub Volume Wafer - G4LogicalVolume* logicPADWafer = - new G4LogicalVolume(PADWafer,m_MaterialSilicon,"logicPADWafer", 0, 0, 0); + G4LogicalVolume* logicPADWafer = new G4LogicalVolume(PADWafer, m_MaterialSilicon, "logicPADWafer", 0, 0, 0); logicPADWafer->SetVisAttributes(SiliconVisAtt); // Sub Volume ActiveWafer G4LogicalVolume* logicPADActiveWafer = - new G4LogicalVolume(PADActiveWafer,m_MaterialSilicon,"logicPADActiveWafer", 0, 0, 0); + new G4LogicalVolume(PADActiveWafer, m_MaterialSilicon, "logicPADActiveWafer", 0, 0, 0); logicPADActiveWafer->SetVisAttributes(SiliconVisAtt); // Sensitive Volume logicPADActiveWafer->SetSensitiveDetector(m_PADScorer); // Place the sub volume in the master volume - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0), - logicPADPCB,"PAD_PCB",logicPADDetector,false,DetNbr); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicPADPCB, "PAD_PCB", + logicPADDetector, false, DetNbr); - new G4PVPlacement(new G4RotationMatrix(0,0,0), - PAD_Wafer_Offset-G4ThreeVector(0,0,0.5*PAD_PCB_Thickness-0.5*m_ThicknessPAD[i][j]), - logicPADWafer,"PAD_Wafer",logicPADDetector,false,DetNbr); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), + PAD_Wafer_Offset - G4ThreeVector(0, 0, 0.5 * PAD_PCB_Thickness - 0.5 * m_ThicknessPAD[i][j]), + logicPADWafer, "PAD_Wafer", logicPADDetector, false, DetNbr); - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0), - logicPADActiveWafer,"PAD_ActiveWafer",logicPADWafer,false,DetNbr); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicPADActiveWafer, "PAD_ActiveWafer", + logicPADWafer, false, DetNbr); } /////////////////////////////////////////////////////////////////////////////////// // Place the detector in the world // Position of the center of the PCB G4ThreeVector DetectorPosition; - if(m_ThicknessPAD[i][j]>0){ //PAD Case - DetectorPosition = G4ThreeVector(-BOX_CenterOffset2,-Box_Wafer_Offset.y(),0); + if (m_ThicknessPAD[i][j] > 0) { // PAD Case + DetectorPosition = G4ThreeVector(-BOX_CenterOffset2, -Box_Wafer_Offset.y(), 0); } - else{ // No Pad Case - DetectorPosition = G4ThreeVector(-BOX_CenterOffset1,-Box_Wafer_Offset.y(),0); + else { // No Pad Case + DetectorPosition = G4ThreeVector(-BOX_CenterOffset1, -Box_Wafer_Offset.y(), 0); } // Distance of the PCB to the target - G4ThreeVector DetectorSpacing = - -G4ThreeVector(0,0,BOX_DetectorSpacing); + G4ThreeVector DetectorSpacing = -G4ThreeVector(0, 0, BOX_DetectorSpacing); - DetectorPosition+=DetectorSpacing; - - G4ThreeVector PADDetectorPosition = DetectorPosition ; - G4ThreeVector PADDetectorSpacing = - -G4ThreeVector(0,0,0.5*BOX_PCB_Thickness+0.5*PAD_PCB_Thickness); + DetectorPosition += DetectorSpacing; + G4ThreeVector PADDetectorPosition = DetectorPosition; + G4ThreeVector PADDetectorSpacing = -G4ThreeVector(0, 0, 0.5 * BOX_PCB_Thickness + 0.5 * PAD_PCB_Thickness); PADDetectorPosition += PADDetectorSpacing; - G4RotationMatrix* DetectorRotation= new G4RotationMatrix; + G4RotationMatrix* DetectorRotation = new G4RotationMatrix; // The Rotation Matrix is different for each detector - double Z= 0; - if(m_Z[i]<0){ - if(j==0){ - DetectorRotation->rotateX(90*deg); + double Z = 0; + if (m_Z[i] < 0) { + if (j == 0) { + DetectorRotation->rotateX(90 * deg); } - else if(j==1){ - DetectorRotation->rotateX(90*deg); - DetectorRotation->rotateZ(-90*deg); + else if (j == 1) { + DetectorRotation->rotateX(90 * deg); + DetectorRotation->rotateZ(-90 * deg); } - else if(j==2){ - DetectorRotation->rotateZ(180*deg); - DetectorRotation->rotateX(-90*deg); + else if (j == 2) { + DetectorRotation->rotateZ(180 * deg); + DetectorRotation->rotateX(-90 * deg); } - else if(j==3){ - DetectorRotation->rotateX(90*deg); - DetectorRotation->rotateZ(90*deg); + else if (j == 3) { + DetectorRotation->rotateX(90 * deg); + DetectorRotation->rotateZ(90 * deg); } - DetectorRotation->rotateY(180*deg); - Z = m_Z[i] -2*mm; + DetectorRotation->rotateY(180 * deg); + Z = m_Z[i] - 2 * mm; } - else{ - if(j==0){ - DetectorRotation->rotateX(90*deg); + else { + if (j == 0) { + DetectorRotation->rotateX(90 * deg); } - else if(j==1){ - DetectorRotation->rotateX(90*deg); - DetectorRotation->rotateZ(90*deg); - + else if (j == 1) { + DetectorRotation->rotateX(90 * deg); + DetectorRotation->rotateZ(90 * deg); } - else if(j==2){ - DetectorRotation->rotateZ(180*deg); - DetectorRotation->rotateX(-90*deg); + else if (j == 2) { + DetectorRotation->rotateZ(180 * deg); + DetectorRotation->rotateX(-90 * deg); } - else if(j==3){ - DetectorRotation->rotateX(90*deg); - DetectorRotation->rotateZ(-90*deg); + else if (j == 3) { + DetectorRotation->rotateX(90 * deg); + DetectorRotation->rotateZ(-90 * deg); } - Z= m_Z[i]+2*mm; + Z = m_Z[i] + 2 * mm; } DetectorPosition.transform(*DetectorRotation); - DetectorPosition+=G4ThreeVector(0,0,Z); + DetectorPosition += G4ThreeVector(0, 0, Z); PADDetectorPosition.transform(*DetectorRotation); - PADDetectorPosition+=G4ThreeVector(0,0,Z); + PADDetectorPosition += G4ThreeVector(0, 0, Z); - new G4PVPlacement(G4Transform3D(*DetectorRotation,DetectorPosition), logicBoxDetector,"Box",world,false,DetNbr); + new G4PVPlacement(G4Transform3D(*DetectorRotation, DetectorPosition), logicBoxDetector, "Box", world, false, + DetNbr); - if(m_ThicknessPAD[i][j]>0){ - new G4PVPlacement(G4Transform3D(*DetectorRotation, PADDetectorPosition), - logicPADDetector,"PAD",world,false,DetNbr); + if (m_ThicknessPAD[i][j] > 0) { + new G4PVPlacement(G4Transform3D(*DetectorRotation, PADDetectorPosition), logicPADDetector, "PAD", world, false, + DetNbr); } } } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Sharc::ConstructQQQDetector(G4LogicalVolume* world){ +void Sharc::ConstructQQQDetector(G4LogicalVolume* world) { // create the QQQ - for(unsigned int i = 0 ; i < m_Pos.size() ; i++){ + for (unsigned int i = 0; i < m_Pos.size(); i++) { int DetNbr = 0; - if(m_Pos[i].z()<0) DetNbr = i+1; - else DetNbr = i+1 + 8; + if (m_Pos[i].z() < 0) + DetNbr = i + 1; + else + DetNbr = i + 1 + 8; // Make the a single detector geometry - G4Tubs* QQQDetector = new G4Tubs("QQQDetector" , - QQQ_PCB_Inner_Radius, - QQQ_PCB_Outer_Radius, - QQQ_PCB_Thickness*0.5, - 0., - M_PI/2.); - - G4Tubs* PCBFull = new G4Tubs("PCBFull" , - QQQ_PCB_Inner_Radius, - QQQ_PCB_Outer_Radius, - QQQ_PCB_Thickness*0.5, - 0., - M_PI*0.5); - - G4Tubs* WaferShape = new G4Tubs("WaferShape" , - QQQ_Wafer_Inner_Radius, - QQQ_Wafer_Outer_Radius, - QQQ_PCB_Thickness*0.5+0.1*mm, - QQQ_Wafer_Starting_Phi, - QQQ_Wafer_Stopping_Phi); - - G4Tubs* Wafer = new G4Tubs("Wafer" , - QQQ_Wafer_Inner_Radius, - QQQ_Wafer_Outer_Radius, - m_ThicknessQQQ[i]*0.5, - QQQ_Wafer_Starting_Phi, - QQQ_Wafer_Stopping_Phi); - - G4SubtractionSolid* PCB = - new G4SubtractionSolid("PCB", PCBFull, WaferShape,new G4RotationMatrix, - G4ThreeVector(0, 0,0)); + G4Tubs* QQQDetector = + new G4Tubs("QQQDetector", QQQ_PCB_Inner_Radius, QQQ_PCB_Outer_Radius, QQQ_PCB_Thickness * 0.5, 0., M_PI / 2.); + + G4Tubs* PCBFull = + new G4Tubs("PCBFull", QQQ_PCB_Inner_Radius, QQQ_PCB_Outer_Radius, QQQ_PCB_Thickness * 0.5, 0., M_PI * 0.5); + + G4Tubs* WaferShape = new G4Tubs("WaferShape", QQQ_Wafer_Inner_Radius, QQQ_Wafer_Outer_Radius, + QQQ_PCB_Thickness * 0.5 + 0.1 * mm, QQQ_Wafer_Starting_Phi, QQQ_Wafer_Stopping_Phi); + + G4Tubs* Wafer = new G4Tubs("Wafer", QQQ_Wafer_Inner_Radius, QQQ_Wafer_Outer_Radius, m_ThicknessQQQ[i] * 0.5, + QQQ_Wafer_Starting_Phi, QQQ_Wafer_Stopping_Phi); + + G4SubtractionSolid* PCB = + new G4SubtractionSolid("PCB", PCBFull, WaferShape, new G4RotationMatrix, G4ThreeVector(0, 0, 0)); // Master Volume - G4LogicalVolume* logicQQQDetector = - new G4LogicalVolume(QQQDetector,m_MaterialVacuum,"logicQQQDetector", 0, 0, 0); - logicQQQDetector->SetVisAttributes(G4VisAttributes::Invisible); + G4LogicalVolume* logicQQQDetector = new G4LogicalVolume(QQQDetector, m_MaterialVacuum, "logicQQQDetector", 0, 0, 0); + logicQQQDetector->SetVisAttributes(G4VisAttributes::GetInvisible()); // Sub Volume PCB - G4LogicalVolume* logicPCB = - new G4LogicalVolume(PCB,m_MaterialPCB,"logicPCB", 0, 0, 0); + G4LogicalVolume* logicPCB = new G4LogicalVolume(PCB, m_MaterialPCB, "logicPCB", 0, 0, 0); logicPCB->SetVisAttributes(PCBVisAtt); // Sub Volume Wafer - G4LogicalVolume* logicWafer = - new G4LogicalVolume(Wafer,m_MaterialSilicon,"logicWafer", 0, 0, 0); + G4LogicalVolume* logicWafer = new G4LogicalVolume(Wafer, m_MaterialSilicon, "logicWafer", 0, 0, 0); logicWafer->SetVisAttributes(SiliconVisAtt); logicWafer->SetSensitiveDetector(m_QQQScorer); - // Place the sub volume in the master volume - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0), - logicPCB,"QQQ_PCB",logicQQQDetector,false,DetNbr); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicPCB, "QQQ_PCB", logicQQQDetector, + false, DetNbr); - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0), - logicWafer,"QQQ_Wafer",logicQQQDetector,false,DetNbr); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicWafer, "QQQ_Wafer", logicQQQDetector, + false, DetNbr); // Place the masters volume in the world - new G4PVPlacement(new G4RotationMatrix(0,0,m_Pos[i].y()), - G4ThreeVector(0,0,m_Pos[i].z()), - logicQQQDetector,"QQQ",world,false,DetNbr); + new G4PVPlacement(new G4RotationMatrix(0, 0, m_Pos[i].y()), G4ThreeVector(0, 0, m_Pos[i].z()), logicQQQDetector, + "QQQ", world, false, DetNbr); } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void Sharc::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("Sharc")){ - pTree->Branch("Sharc", "TSharcData", &m_Event) ; +void Sharc::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("Sharc")) { + pTree->Branch("Sharc", "TSharcData", &m_Event); } - pTree->SetBranchAddress("Sharc", &m_Event) ; - + pTree->SetBranchAddress("Sharc", &m_Event); } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Sharc::ReadSensitive(const G4Event* ){ +void Sharc::ReadSensitive(const G4Event*) { m_Event->Clear(); /////////// // BOX - DSSDScorers::PS_Rectangle* BOXScorer = (DSSDScorers::PS_Rectangle*) m_BOXScorer->GetPrimitive(0); - + DSSDScorers::PS_Rectangle* BOXScorer = (DSSDScorers::PS_Rectangle*)m_BOXScorer->GetPrimitive(0); // Loop on the BOX map - unsigned int sizeFront= BOXScorer->GetLengthMult(); + unsigned int sizeFront = BOXScorer->GetLengthMult(); - for (unsigned int i=0 ; i<sizeFront ; i++){ + for (unsigned int i = 0; i < sizeFront; i++) { double Energy = BOXScorer->GetEnergyLength(i); - if(Energy>EnergyThreshold){ - double Time = BOXScorer->GetTimeLength(i); - int DetNbr = BOXScorer->GetDetectorLength(i); - int StripFront = BOXScorer->GetStripLength(i); - - m_Event->SetFront(DetNbr, - StripFront, - RandGauss::shoot(Energy, ResoEnergy), - RandGauss::shoot(Time, ResoTime), - RandGauss::shoot(Time, ResoTime)); + if (Energy > EnergyThreshold) { + double Time = BOXScorer->GetTimeLength(i); + int DetNbr = BOXScorer->GetDetectorLength(i); + int StripFront = BOXScorer->GetStripLength(i); + + m_Event->SetFront(DetNbr, StripFront, RandGauss::shoot(Energy, ResoEnergy), RandGauss::shoot(Time, ResoTime), + RandGauss::shoot(Time, ResoTime)); } - } + } - unsigned int sizeBack= BOXScorer->GetWidthMult(); - for (unsigned int i=0 ; i<sizeBack ; i++){ + unsigned int sizeBack = BOXScorer->GetWidthMult(); + for (unsigned int i = 0; i < sizeBack; i++) { double Energy = BOXScorer->GetEnergyWidth(i); - if(Energy>EnergyThreshold){ - double Time = BOXScorer->GetTimeWidth(i); - int DetNbr = BOXScorer->GetDetectorWidth(i); - int StripBack = BOXScorer->GetStripWidth(i); + if (Energy > EnergyThreshold) { + double Time = BOXScorer->GetTimeWidth(i); + int DetNbr = BOXScorer->GetDetectorWidth(i); + int StripBack = BOXScorer->GetStripWidth(i); - m_Event->SetBack(DetNbr, - BOX_Wafer_Back_NumberOfStrip-StripBack+1, - RandGauss::shoot(Energy, ResoEnergy), - RandGauss::shoot(Time, ResoTime), - RandGauss::shoot(Time, ResoTime)); + m_Event->SetBack(DetNbr, BOX_Wafer_Back_NumberOfStrip - StripBack + 1, RandGauss::shoot(Energy, ResoEnergy), + RandGauss::shoot(Time, ResoTime), RandGauss::shoot(Time, ResoTime)); } } // clear map for next event BOXScorer->clear(); /////////// // PAD - DSSDScorers::PS_Rectangle* PADScorer = (DSSDScorers::PS_Rectangle*) m_PADScorer->GetPrimitive(0); - + DSSDScorers::PS_Rectangle* PADScorer = (DSSDScorers::PS_Rectangle*)m_PADScorer->GetPrimitive(0); // Loop on the PAD map - unsigned int sizePAD= PADScorer->GetLengthMult(); - for (unsigned int i=0 ; i<sizePAD ; i++){ + unsigned int sizePAD = PADScorer->GetLengthMult(); + for (unsigned int i = 0; i < sizePAD; i++) { double Energy = PADScorer->GetEnergyLength(i); - if(Energy>EnergyThreshold){ - double Time = PADScorer->GetTimeLength(i); - int DetNbr = PADScorer->GetDetectorLength(i); - m_Event->SetPAD(DetNbr, - RandGauss::shoot(Energy, ResoEnergy), - RandGauss::shoot(Time, ResoTime), - RandGauss::shoot(Time, ResoTime)); + if (Energy > EnergyThreshold) { + double Time = PADScorer->GetTimeLength(i); + int DetNbr = PADScorer->GetDetectorLength(i); + m_Event->SetPAD(DetNbr, RandGauss::shoot(Energy, ResoEnergy), RandGauss::shoot(Time, ResoTime), + RandGauss::shoot(Time, ResoTime)); } - } + } // clear map for next event PADScorer->clear(); /////////// // QQQ - DSSDScorers::PS_Annular* QQQScorer = (DSSDScorers::PS_Annular*) m_QQQScorer->GetPrimitive(0); + DSSDScorers::PS_Annular* QQQScorer = (DSSDScorers::PS_Annular*)m_QQQScorer->GetPrimitive(0); // Loop on the QQQ map - unsigned int sizeRing= QQQScorer->GetRingMult(); - for (unsigned int i=0 ; i<sizeRing ; i++){ + unsigned int sizeRing = QQQScorer->GetRingMult(); + for (unsigned int i = 0; i < sizeRing; i++) { double Energy = QQQScorer->GetEnergyRing(i); - if(Energy>EnergyThreshold){ - double Time = QQQScorer->GetTimeRing(i); - int DetNbr = QQQScorer->GetDetectorRing(i); - int StripRing = QQQScorer->GetStripRing(i); - m_Event->SetFront(DetNbr, - QQQ_Wafer_NumberOf_AnnularStrip-StripRing+1, - RandGauss::shoot(Energy, ResoEnergy), - RandGauss::shoot(Time, ResoTime), - RandGauss::shoot(Time, ResoTime)); + if (Energy > EnergyThreshold) { + double Time = QQQScorer->GetTimeRing(i); + int DetNbr = QQQScorer->GetDetectorRing(i); + int StripRing = QQQScorer->GetStripRing(i); + m_Event->SetFront(DetNbr, QQQ_Wafer_NumberOf_AnnularStrip - StripRing + 1, RandGauss::shoot(Energy, ResoEnergy), + RandGauss::shoot(Time, ResoTime), RandGauss::shoot(Time, ResoTime)); } - } + } - unsigned int sizeSector= QQQScorer->GetSectorMult(); - for (unsigned int i=0 ; i<sizeSector ; i++){ + unsigned int sizeSector = QQQScorer->GetSectorMult(); + for (unsigned int i = 0; i < sizeSector; i++) { double Energy = QQQScorer->GetEnergySector(i); - if(Energy>EnergyThreshold){ - double Time = QQQScorer->GetTimeSector(i); - int DetNbr = QQQScorer->GetDetectorSector(i); - int StripSector = QQQScorer->GetStripSector(i); + if (Energy > EnergyThreshold) { + double Time = QQQScorer->GetTimeSector(i); + int DetNbr = QQQScorer->GetDetectorSector(i); + int StripSector = QQQScorer->GetStripSector(i); - m_Event->SetBack(DetNbr, - StripSector, - RandGauss::shoot(Energy, ResoEnergy), - RandGauss::shoot(Time, ResoTime), - RandGauss::shoot(Time, ResoTime)); + m_Event->SetBack(DetNbr, StripSector, RandGauss::shoot(Energy, ResoEnergy), RandGauss::shoot(Time, ResoTime), + RandGauss::shoot(Time, ResoTime)); } } // clear map for next event QQQScorer->clear(); - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Sharc::InitializeScorers(){ +void Sharc::InitializeScorers() { // Silicon Associate Scorer bool already_exist = false; - m_BOXScorer = CheckScorer("Sharc_BOXScorer",already_exist); - m_PADScorer = CheckScorer("Sharc_PADScorer",already_exist); - m_QQQScorer = CheckScorer("Sharc_QQQScorer",already_exist); + m_BOXScorer = CheckScorer("Sharc_BOXScorer", already_exist); + m_PADScorer = CheckScorer("Sharc_PADScorer", already_exist); + m_QQQScorer = CheckScorer("Sharc_QQQScorer", already_exist); // if the scorer were created previously nothing else need to be made - if(already_exist) return; + if (already_exist) + return; G4VPrimitiveScorer* BOXScorer = - new DSSDScorers::PS_Rectangle("SharcBOX",0, - BOX_ActiveWafer_Length, - BOX_ActiveWafer_Width, - BOX_Wafer_Front_NumberOfStrip , - BOX_Wafer_Back_NumberOfStrip); - - G4VPrimitiveScorer* PADScorer = - new DSSDScorers::PS_Rectangle("SharcPAD",0, - PAD_Wafer_Length, - PAD_Wafer_Width, - 1 , - 0); - - G4VPrimitiveScorer* QQQScorer = - new DSSDScorers::PS_Annular("SharcQQQ",0, - QQQ_Wafer_Inner_Radius, - QQQ_Wafer_Outer_Radius, - QQQ_Wafer_Starting_Phi, - QQQ_Wafer_Stopping_Phi, - QQQ_Wafer_NumberOf_AnnularStrip, - QQQ_Wafer_NumberOf_RadialStrip,1); - - G4VPrimitiveScorer* InterScorerBOX = - new InteractionScorers::PS_Interactions("SharcBOXInteractionScorer",ms_InterCoord,0); - - G4VPrimitiveScorer* InterScorerQQQ = - new InteractionScorers::PS_Interactions("SharcQQQInteractionScorer",ms_InterCoord,0); - - //and register it to the multifunctionnal detector + new DSSDScorers::PS_Rectangle("SharcBOX", 0, BOX_ActiveWafer_Length, BOX_ActiveWafer_Width, + BOX_Wafer_Front_NumberOfStrip, BOX_Wafer_Back_NumberOfStrip); + + G4VPrimitiveScorer* PADScorer = new DSSDScorers::PS_Rectangle("SharcPAD", 0, PAD_Wafer_Length, PAD_Wafer_Width, 1, 0); + + G4VPrimitiveScorer* QQQScorer = new DSSDScorers::PS_Annular( + "SharcQQQ", 0, QQQ_Wafer_Inner_Radius, QQQ_Wafer_Outer_Radius, QQQ_Wafer_Starting_Phi, QQQ_Wafer_Stopping_Phi, + QQQ_Wafer_NumberOf_AnnularStrip, QQQ_Wafer_NumberOf_RadialStrip, 1); + + G4VPrimitiveScorer* InterScorerBOX = + new InteractionScorers::PS_Interactions("SharcBOXInteractionScorer", ms_InterCoord, 0); + + G4VPrimitiveScorer* InterScorerQQQ = + new InteractionScorers::PS_Interactions("SharcQQQInteractionScorer", ms_InterCoord, 0); + + // and register it to the multifunctionnal detector m_BOXScorer->RegisterPrimitive(BOXScorer); m_BOXScorer->RegisterPrimitive(InterScorerBOX); m_PADScorer->RegisterPrimitive(PADScorer); @@ -730,42 +632,37 @@ void Sharc::InitializeScorers(){ G4SDManager::GetSDMpointer()->ListTree(); // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_BOXScorer) ; - G4SDManager::GetSDMpointer()->AddNewDetector(m_PADScorer) ; - G4SDManager::GetSDMpointer()->AddNewDetector(m_QQQScorer) ; - + G4SDManager::GetSDMpointer()->AddNewDetector(m_BOXScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_PADScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_QQQScorer); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //////////////////////////////////////////////////////////////// /////////////////Material Definition /////////////////////////// //////////////////////////////////////////////////////////////// -void Sharc::InitializeMaterial(){ +void Sharc::InitializeMaterial() { m_MaterialSilicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); m_MaterialPCB = MaterialManager::getInstance()->GetMaterialFromLibrary("PCB"); m_MaterialVacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); - } - //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* Sharc::Construct(){ - return (NPS::VDetector*) new Sharc(); -} +NPS::VDetector* Sharc::Construct() { return (NPS::VDetector*)new Sharc(); } //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_sharc{ - public: - proxy_nps_sharc(){ - NPS::DetectorFactory::getInstance()->AddToken("Sharc","Sharc"); - NPS::DetectorFactory::getInstance()->AddDetector("Sharc",Sharc::Construct); - } - }; +extern "C" { +class proxy_nps_sharc { + public: + proxy_nps_sharc() { + NPS::DetectorFactory::getInstance()->AddToken("Sharc", "Sharc"); + NPS::DetectorFactory::getInstance()->AddDetector("Sharc", Sharc::Construct); + } +}; - proxy_nps_sharc p_nps_sharc; +proxy_nps_sharc p_nps_sharc; } diff --git a/NPSimulation/Detectors/Spice/Spice.cc b/NPSimulation/Detectors/Spice/Spice.cc index 86ce150ff..b03cd6aad 100644 --- a/NPSimulation/Detectors/Spice/Spice.cc +++ b/NPSimulation/Detectors/Spice/Spice.cc @@ -21,61 +21,57 @@ *****************************************************************************/ // C++ headers +#include <cmath> #include <sstream> #include <string> -#include <cmath> -// Geant4 +// Geant4 #include "G4Box.hh" -#include "G4Tubs.hh" -#include "G4VisAttributes.hh" #include "G4Colour.hh" -#include "G4RotationMatrix.hh" -#include "G4Transform3D.hh" -#include "G4PVPlacement.hh" +#include "G4MultiFunctionalDetector.hh" #include "G4PVDivision.hh" +#include "G4PVPlacement.hh" +#include "G4RotationMatrix.hh" #include "G4SDManager.hh" -#include "G4MultiFunctionalDetector.hh" +#include "G4Transform3D.hh" +#include "G4Tubs.hh" +#include "G4VisAttributes.hh" // NPTool headers -#include "Spice.hh" #include "MaterialManager.hh" +#include "NPOptionManager.h" #include "NPSDetectorFactory.hh" -#include "SiliconScorers.hh" #include "RootOutput.h" -#include "NPOptionManager.h" +#include "SiliconScorers.hh" +#include "Spice.hh" // CLHEP #include "CLHEP/Random/RandGauss.h" using namespace std; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Spice::Spice(){ - m_LogicalDetector=0; -} +Spice::Spice() { m_LogicalDetector = 0; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Spice::~Spice(){ -} +Spice::~Spice() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Spice::ConstructVolume(){ - if(!m_LogicalDetector){ +G4LogicalVolume* Spice::ConstructVolume() { + if (!m_LogicalDetector) { m_gdmlparser.Read("Spice/Spice.gdml"); - m_LogicalDetector= m_gdmlparser.GetVolume("World"); + m_LogicalDetector = m_gdmlparser.GetVolume("World"); // Set a few visual attribute - G4VisAttributes* MagnetVisAtt = new G4VisAttributes(G4Colour(0.2,0.2, 1, 0.5)) ; - G4VisAttributes* PhotonShieldVisAtt = new G4VisAttributes(G4Colour(0.2,1, 0.2, 0.5)) ; + G4VisAttributes* MagnetVisAtt = new G4VisAttributes(G4Colour(0.2, 0.2, 1, 0.5)); + G4VisAttributes* PhotonShieldVisAtt = new G4VisAttributes(G4Colour(0.2, 1, 0.2, 0.5)); - G4VisAttributes* SiliconVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)) ; - G4VisAttributes* ColdFingerVisAtt = new G4VisAttributes(G4Colour(0.8, 0.3, 0.3)) ; - G4VisAttributes* TargetMechanismVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.3)) ; + G4VisAttributes* SiliconVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)); + G4VisAttributes* ColdFingerVisAtt = new G4VisAttributes(G4Colour(0.8, 0.3, 0.3)); + G4VisAttributes* TargetMechanismVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.3)); - G4VisAttributes* ChamberVisAtt - = new G4VisAttributes(G4Colour(0.0,0.4,0.5,0.2)); + G4VisAttributes* ChamberVisAtt = new G4VisAttributes(G4Colour(0.0, 0.4, 0.5, 0.2)); // World box - m_LogicalDetector->SetVisAttributes(G4VisAttributes::Invisible); + m_LogicalDetector->SetVisAttributes(G4VisAttributes::GetInvisible()); // chamber m_gdmlparser.GetVolume("electro_box_log")->SetVisAttributes(ChamberVisAtt); @@ -87,19 +83,17 @@ G4LogicalVolume* Spice::ConstructVolume(){ // Cold Finger m_gdmlparser.GetVolume("cold_finger_log")->SetVisAttributes(ColdFingerVisAtt); - // Magnet - m_gdmlparser.GetVolume("magnet_log")->SetVisAttributes(MagnetVisAtt); - m_gdmlparser.GetVolume("magnet_clamp_chamber_log")->SetVisAttributes(MagnetVisAtt); - m_gdmlparser.GetVolume("magnet_clamp_shield_log")->SetVisAttributes(MagnetVisAtt); + m_gdmlparser.GetVolume("magnet_log")->SetVisAttributes(MagnetVisAtt); + m_gdmlparser.GetVolume("magnet_clamp_chamber_log")->SetVisAttributes(MagnetVisAtt); + m_gdmlparser.GetVolume("magnet_clamp_shield_log")->SetVisAttributes(MagnetVisAtt); // Photon Shield - m_gdmlparser.GetVolume("photon_shield_layer_one_log")->SetVisAttributes(PhotonShieldVisAtt); - m_gdmlparser.GetVolume("photon_shield_layer_two_log")->SetVisAttributes(PhotonShieldVisAtt); - m_gdmlparser.GetVolume("photon_shield_layer_three_log")->SetVisAttributes(PhotonShieldVisAtt); - m_gdmlparser.GetVolume("ps_detector_clamp_log")->SetVisAttributes(PhotonShieldVisAtt); - m_gdmlparser.GetVolume("ps_target_clamp_log")->SetVisAttributes(PhotonShieldVisAtt); - + m_gdmlparser.GetVolume("photon_shield_layer_one_log")->SetVisAttributes(PhotonShieldVisAtt); + m_gdmlparser.GetVolume("photon_shield_layer_two_log")->SetVisAttributes(PhotonShieldVisAtt); + m_gdmlparser.GetVolume("photon_shield_layer_three_log")->SetVisAttributes(PhotonShieldVisAtt); + m_gdmlparser.GetVolume("ps_detector_clamp_log")->SetVisAttributes(PhotonShieldVisAtt); + m_gdmlparser.GetVolume("ps_target_clamp_log")->SetVisAttributes(PhotonShieldVisAtt); // Target Mechanism m_gdmlparser.GetVolume("target_wheel_log")->SetVisAttributes(TargetMechanismVisAtt); @@ -111,28 +105,24 @@ G4LogicalVolume* Spice::ConstructVolume(){ m_gdmlparser.GetVolume("gear_stick_log")->SetVisAttributes(TargetMechanismVisAtt); m_gdmlparser.GetVolume("target_mount_plate_log")->SetVisAttributes(TargetMechanismVisAtt); - - - // S3 color - for(unsigned int ring = 1 ; ring < 24 ; ring++){ + for (unsigned int ring = 1; ring < 24; ring++) { ostringstream os; os << "siDetS3Ring_" << ring << "_Log"; - m_gdmlparser.GetVolume(os.str())->SetVisAttributes(SiliconVisAtt); + m_gdmlparser.GetVolume(os.str())->SetVisAttributes(SiliconVisAtt); } - //Spice color - for(unsigned int ring = 0 ; ring < 10 ; ring++){ + // Spice color + for (unsigned int ring = 0; ring < 10; ring++) { ostringstream os; os << "siDetSpiceRing_" << ring << "_Log"; - m_gdmlparser.GetVolume(os.str())->SetVisAttributes(SiliconVisAtt); + m_gdmlparser.GetVolume(os.str())->SetVisAttributes(SiliconVisAtt); } - m_gdmlparser.GetVolume("innerGuardRing")->SetVisAttributes(SiliconVisAtt); - m_gdmlparser.GetVolume("outerGuardRing")->SetVisAttributes(SiliconVisAtt); + m_gdmlparser.GetVolume("innerGuardRing")->SetVisAttributes(SiliconVisAtt); + m_gdmlparser.GetVolume("outerGuardRing")->SetVisAttributes(SiliconVisAtt); } return m_LogicalDetector; - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -143,58 +133,49 @@ G4LogicalVolume* Spice::ConstructVolume(){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Spice::ReadConfiguration(NPL::InputParser){ -} +void Spice::ReadConfiguration(NPL::InputParser) {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void Spice::ConstructDetector(G4LogicalVolume* world){ +void Spice::ConstructDetector(G4LogicalVolume* world) { ConstructVolume(); - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0), - m_LogicalDetector,"Spice",world,false,1); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), m_LogicalDetector, "Spice", world, false, 1); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Connect the GaspardTrackingData class to the output TTree // of the simulation -void Spice::InitializeRootOutput(){ -} +void Spice::InitializeRootOutput() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Spice::ReadSensitive(const G4Event* event){ - if(event) +void Spice::ReadSensitive(const G4Event* event) { + if (event) event = 0; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -// Initilize the Scorer use to read out the sensitive volume -void Spice::InitializeScorers(){ - m_Scorer = 0; -} +// Initilize the Scorer use to read out the sensitive volume +void Spice::InitializeScorers() { m_Scorer = 0; } //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* Spice::Construct(){ - return (NPS::VDetector*) new Spice(); -} +NPS::VDetector* Spice::Construct() { return (NPS::VDetector*)new Spice(); } //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern "C"{ -class proxy_nps_spice{ - public: - proxy_nps_spice(){ - NPS::DetectorFactory::getInstance()->AddToken("Spice","Spice"); - NPS::DetectorFactory::getInstance()->AddDetector("Spice",Spice::Construct); - } +extern "C" { +class proxy_nps_spice { + public: + proxy_nps_spice() { + NPS::DetectorFactory::getInstance()->AddToken("Spice", "Spice"); + NPS::DetectorFactory::getInstance()->AddDetector("Spice", Spice::Construct); + } }; proxy_nps_spice p_nps_spice; } - diff --git a/NPSimulation/Detectors/Strasse/Strasse.cc b/NPSimulation/Detectors/Strasse/Strasse.cc index f751000d7..230a0e44e 100644 --- a/NPSimulation/Detectors/Strasse/Strasse.cc +++ b/NPSimulation/Detectors/Strasse/Strasse.cc @@ -20,38 +20,38 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> -//G4 Geometry object -#include "G4Tubs.hh" +#include <sstream> +// G4 Geometry object #include "G4Box.hh" -#include "G4Sphere.hh" -#include "G4UnionSolid.hh" #include "G4ExtrudedSolid.hh" +#include "G4Sphere.hh" #include "G4SubtractionSolid.hh" +#include "G4Tubs.hh" #include "G4TwoVector.hh" +#include "G4UnionSolid.hh" -//G4 sensitive -#include "G4SDManager.hh" +// G4 sensitive #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" -//G4 various object +// G4 various object +#include "G4Colour.hh" #include "G4Material.hh" -#include "G4Transform3D.hh" #include "G4PVPlacement.hh" +#include "G4Transform3D.hh" #include "G4VisAttributes.hh" -#include "G4Colour.hh" // NPTool header -#include "Strasse.hh" #include "DSSDScorers.hh" #include "InteractionScorers.hh" -#include "RootOutput.h" #include "MaterialManager.hh" -#include "NPSDetectorFactory.hh" #include "NPOptionManager.h" +#include "NPSDetectorFactory.hh" #include "NPSHitsMap.hh" +#include "RootOutput.h" +#include "Strasse.hh" // CLHEP header #include "CLHEP/Random/RandGauss.h" @@ -61,122 +61,120 @@ using namespace std; using namespace CLHEP; - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -namespace Strasse_NS{ +namespace Strasse_NS { // Energy and time Resolution - const double EnergyThreshold = 10*keV; - const double ResoEnergy = 0.015*MeV ; + const double EnergyThreshold = 10 * keV; + const double ResoEnergy = 0.015 * MeV; //////////////////// // Inner Detector // //////////////////// // Wafer parameter - double Inner_Wafer_Length=100*mm; - double Inner_Wafer_Width=50*mm; - double Inner_Wafer_Thickness=300*micrometer; - double Inner_Wafer_AlThickness=0.4*micrometer; - double Inner_Wafer_PADExternal=1*cm; - double Inner_Wafer_PADInternal=1*mm; - double Inner_Wafer_GuardRing=0.5*mm; + double Inner_Wafer_Length = 100 * mm; + double Inner_Wafer_Width = 50 * mm; + double Inner_Wafer_Thickness = 300 * micrometer; + double Inner_Wafer_AlThickness = 0.4 * micrometer; + double Inner_Wafer_PADExternal = 1 * cm; + double Inner_Wafer_PADInternal = 1 * mm; + double Inner_Wafer_GuardRing = 0.5 * mm; // PCB parameter - double Inner_PCB_PortWidth=1*cm; - double Inner_PCB_StarboardWidth=2*mm; - double Inner_PCB_BevelAngle= 60*deg; - double Inner_PCB_UpstreamWidth=1*cm; - double Inner_PCB_DownstreamWidth=2*mm; - double Inner_PCB_MidWidth=2*mm; - double Inner_PCB_Thickness=3*mm; - double Inner_PCB_Ledge = 1*mm ; - double Inner_PCB_Step = 2*mm ; - double Inner_Wafer_TransverseStrips= 128; - double Inner_Wafer_LongitudinalStrips= 128; + double Inner_PCB_PortWidth = 1 * cm; + double Inner_PCB_StarboardWidth = 2 * mm; + double Inner_PCB_BevelAngle = 60 * deg; + double Inner_PCB_UpstreamWidth = 1 * cm; + double Inner_PCB_DownstreamWidth = 2 * mm; + double Inner_PCB_MidWidth = 2 * mm; + double Inner_PCB_Thickness = 3 * mm; + double Inner_PCB_Ledge = 1 * mm; + double Inner_PCB_Step = 2 * mm; + double Inner_Wafer_TransverseStrips = 128; + double Inner_Wafer_LongitudinalStrips = 128; //////////////////// // Outer Detector // //////////////////// // Wafer parameter - double Outer_Wafer_Length=150*mm; - double Outer_Wafer_Width=75*mm; - double Outer_Wafer_Thickness=300*micrometer; - double Outer_Wafer_AlThickness=0.4*micrometer; - double Outer_Wafer_PADExternal=1*cm; - double Outer_Wafer_PADInternal=1*mm; - double Outer_Wafer_GuardRing=0.5*mm; + double Outer_Wafer_Length = 150 * mm; + double Outer_Wafer_Width = 75 * mm; + double Outer_Wafer_Thickness = 300 * micrometer; + double Outer_Wafer_AlThickness = 0.4 * micrometer; + double Outer_Wafer_PADExternal = 1 * cm; + double Outer_Wafer_PADInternal = 1 * mm; + double Outer_Wafer_GuardRing = 0.5 * mm; // PCB parameter - double Outer_PCB_PortWidth=1*cm; - double Outer_PCB_StarboardWidth=2*mm; - double Outer_PCB_BevelAngle= 60*deg; - double Outer_PCB_UpstreamWidth=1*cm; - double Outer_PCB_DownstreamWidth=2*mm; - double Outer_PCB_MidWidth=2*mm; - double Outer_PCB_Thickness=3*mm; - double Outer_PCB_Ledge = 1*mm ; - double Outer_PCB_Step = 2*mm ; - double Outer_Wafer_TransverseStrips= 128; - double Outer_Wafer_LongitudinalStrips= 128; + double Outer_PCB_PortWidth = 1 * cm; + double Outer_PCB_StarboardWidth = 2 * mm; + double Outer_PCB_BevelAngle = 60 * deg; + double Outer_PCB_UpstreamWidth = 1 * cm; + double Outer_PCB_DownstreamWidth = 2 * mm; + double Outer_PCB_MidWidth = 2 * mm; + double Outer_PCB_Thickness = 3 * mm; + double Outer_PCB_Ledge = 1 * mm; + double Outer_PCB_Step = 2 * mm; + double Outer_Wafer_TransverseStrips = 128; + double Outer_Wafer_LongitudinalStrips = 128; //////////////////// // Vacuum Chamber // //////////////////// - double Chamber_Thickness= 3*mm; - double Chamber_Cylinder_Length= 400*mm; - double Chamber_Radius= 180*mm; - double Chamber_ExitTube_Radius= 79.5*mm ; - double Chamber_ExitTube_Length= 100*mm; - double Chamber_Flange_Inner_Radius= 150*mm; - double Chamber_Sphere_Radius= 220*mm ; - double Chamber_Sphere_Shift= 60*mm; + double Chamber_Thickness = 3 * mm; + double Chamber_Cylinder_Length = 400 * mm; + double Chamber_Radius = 180 * mm; + double Chamber_ExitTube_Radius = 79.5 * mm; + double Chamber_ExitTube_Length = 100 * mm; + double Chamber_Flange_Inner_Radius = 150 * mm; + double Chamber_Sphere_Radius = 220 * mm; + double Chamber_Sphere_Shift = 60 * mm; -} +} // namespace Strasse_NS using namespace Strasse_NS; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Strasse Specific Method -Strasse::Strasse(){ +Strasse::Strasse() { InitializeMaterial(); - m_Event = new TStrasseData() ; + m_Event = new TStrasseData(); m_InnerScorer1 = 0; m_OuterScorer1 = 0; m_InnerScorer2 = 0; m_OuterScorer2 = 0; - m_InnerDetector=0; - m_OuterDetector=0; - m_Chamber=0; - m_Blades=0; - m_Stars=0; - m_Base=0; - m_Electronic=0; + m_InnerDetector = 0; + m_OuterDetector = 0; + m_Chamber = 0; + m_Blades = 0; + m_Stars = 0; + m_Base = 0; + m_Electronic = 0; found_chamber = false; found_stars = false; found_blades = false; found_base = false; // Dark Grey - SiliconVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)) ; + SiliconVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)); // Green - PCBVisAtt = new G4VisAttributes(G4Colour(0.2, 0.5, 0.2)) ; + PCBVisAtt = new G4VisAttributes(G4Colour(0.2, 0.5, 0.2)); // Gold Yellow - PADVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.2)) ; + PADVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.2)); // Light Grey - StarsVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)) ; + StarsVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)); // Space transparent - ChamberVisAtt = new G4VisAttributes(G4Colour(0.3, 0.4, 0.5,0.2)) ; + ChamberVisAtt = new G4VisAttributes(G4Colour(0.3, 0.4, 0.5, 0.2)); // Light Blue - GuardRingVisAtt = new G4VisAttributes(G4Colour(0.85, 0.85, 0.85,0.5)) ; + GuardRingVisAtt = new G4VisAttributes(G4Colour(0.85, 0.85, 0.85, 0.5)); // Light Blue - BladeVisAtt = new G4VisAttributes(G4Colour(1, 0.65, 0.0,0.7)) ; + BladeVisAtt = new G4VisAttributes(G4Colour(1, 0.65, 0.0, 0.7)); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Strasse::~Strasse(){ -} +Strasse::~Strasse() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Strasse::AddInnerDetector(double R, double Z, double Phi, double Shift, G4ThreeVector Ref){ +void Strasse::AddInnerDetector(double R, double Z, double Phi, double Shift, G4ThreeVector Ref) { m_Inner_R.push_back(R); m_Inner_Z.push_back(Z); m_Inner_Phi.push_back(Phi); @@ -185,7 +183,7 @@ void Strasse::AddInnerDetector(double R, double Z, double Phi, double Shift, } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Strasse::AddOuterDetector(double R, double Z, double Phi, double Shift, G4ThreeVector Ref){ +void Strasse::AddOuterDetector(double R, double Z, double Phi, double Shift, G4ThreeVector Ref) { m_Outer_R.push_back(R); m_Outer_Z.push_back(Z); m_Outer_Phi.push_back(Phi); @@ -194,444 +192,366 @@ void Strasse::AddOuterDetector(double R, double Z, double Phi, double Shift, } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Strasse::AddChamber(double Z){ - m_Chamber_Z.push_back(Z); -} +void Strasse::AddChamber(double Z) { m_Chamber_Z.push_back(Z); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Strasse::BuildInnerDetector(){ - if(!m_InnerDetector){ +G4LogicalVolume* Strasse::BuildInnerDetector() { + if (!m_InnerDetector) { // Compute the needed full length of the PCB // along beam axis - double Inner_PCB_Length= 2*Inner_Wafer_Length - +Inner_PCB_UpstreamWidth - +Inner_PCB_MidWidth - +Inner_PCB_DownstreamWidth; + double Inner_PCB_Length = + 2 * Inner_Wafer_Length + Inner_PCB_UpstreamWidth + Inner_PCB_MidWidth + Inner_PCB_DownstreamWidth; // perpendicular to beam axis - double Inner_PCB_Width= Inner_Wafer_Width - +Inner_PCB_StarboardWidth - +Inner_PCB_PortWidth; + double Inner_PCB_Width = Inner_Wafer_Width + Inner_PCB_StarboardWidth + Inner_PCB_PortWidth; vector<G4TwoVector> PCBCrossSection; - + double l1; - if(Inner_PCB_BevelAngle==90) l1 = 0; - else l1 = Inner_PCB_Thickness*0.5/tan(Inner_PCB_BevelAngle); + if (Inner_PCB_BevelAngle == 90) + l1 = 0; + else + l1 = Inner_PCB_Thickness * 0.5 / tan(Inner_PCB_BevelAngle); - PCBCrossSection.push_back(G4TwoVector(Inner_PCB_Width*0.5-l1,-Inner_PCB_Thickness*0.5)); - PCBCrossSection.push_back(G4TwoVector(Inner_PCB_Width*0.5,Inner_PCB_Thickness*0.5)); - PCBCrossSection.push_back(G4TwoVector(-Inner_PCB_Width*0.5,Inner_PCB_Thickness*0.5)); - PCBCrossSection.push_back(G4TwoVector(-Inner_PCB_Width*0.5+l1,-Inner_PCB_Thickness*0.5)); + PCBCrossSection.push_back(G4TwoVector(Inner_PCB_Width * 0.5 - l1, -Inner_PCB_Thickness * 0.5)); + PCBCrossSection.push_back(G4TwoVector(Inner_PCB_Width * 0.5, Inner_PCB_Thickness * 0.5)); + PCBCrossSection.push_back(G4TwoVector(-Inner_PCB_Width * 0.5, Inner_PCB_Thickness * 0.5)); + PCBCrossSection.push_back(G4TwoVector(-Inner_PCB_Width * 0.5 + l1, -Inner_PCB_Thickness * 0.5)); - G4ExtrudedSolid* PCBFull = - new G4ExtrudedSolid("PCBFull", - PCBCrossSection, - Inner_PCB_Length*0.5,// half length - G4TwoVector(0,0),1,// offset, scale - G4TwoVector(0,0),1);// offset, scale + G4ExtrudedSolid* PCBFull = new G4ExtrudedSolid("PCBFull", PCBCrossSection, + Inner_PCB_Length * 0.5, // half length + G4TwoVector(0, 0), 1, // offset, scale + G4TwoVector(0, 0), 1); // offset, scale // Master Volume that encompass everything else - m_InnerDetector = - new G4LogicalVolume(PCBFull,m_MaterialVacuum,"logicBoxDetector", 0, 0, 0); - m_InnerDetector->SetVisAttributes(G4VisAttributes::Invisible); + m_InnerDetector = new G4LogicalVolume(PCBFull, m_MaterialVacuum, "logicBoxDetector", 0, 0, 0); + m_InnerDetector->SetVisAttributes(G4VisAttributes::GetInvisible()); /////////////////////////////////////////////////////////////////////////// // Build the external PCB frame // Calculate the hole shift within the PCB - double Width_Shift= -0.5*Inner_PCB_Width + 0.5*Inner_Wafer_Width // Flush to border - +Inner_PCB_PortWidth; // add the port side shift + double Width_Shift = -0.5 * Inner_PCB_Width + 0.5 * Inner_Wafer_Width // Flush to border + + Inner_PCB_PortWidth; // add the port side shift - double Length_Shift1 = -0.5*Inner_PCB_Length + 0.5*Inner_Wafer_Length // Flush to border - + Inner_PCB_UpstreamWidth;// add Upstream side shift + double Length_Shift1 = -0.5 * Inner_PCB_Length + 0.5 * Inner_Wafer_Length // Flush to border + + Inner_PCB_UpstreamWidth; // add Upstream side shift - double Length_Shift2 = Length_Shift1 // overlap detector 1 - + Inner_Wafer_Length // at opposing edge - + Inner_PCB_MidWidth; // after mid width + double Length_Shift2 = Length_Shift1 // overlap detector 1 + + Inner_Wafer_Length // at opposing edge + + Inner_PCB_MidWidth; // after mid width G4ThreeVector HoleShift1 = G4ThreeVector(Width_Shift, 0, Length_Shift1); G4ThreeVector HoleShift2 = G4ThreeVector(Width_Shift, 0, Length_Shift2); - G4Box* HoleShape = new G4Box("HoleShape", - Inner_Wafer_Width*0.5, - Inner_PCB_Thickness*0.5+0.1*mm, - Inner_Wafer_Length*0.5); + G4Box* HoleShape = + new G4Box("HoleShape", Inner_Wafer_Width * 0.5, Inner_PCB_Thickness * 0.5 + 0.1 * mm, Inner_Wafer_Length * 0.5); // Substracting the hole Shape from the Stock PCB - G4SubtractionSolid* PCB_1 = new G4SubtractionSolid("PCB_1", PCBFull, HoleShape, - new G4RotationMatrix,HoleShift1); - G4SubtractionSolid* PCB = new G4SubtractionSolid("PCB", PCB_1, HoleShape, - new G4RotationMatrix,HoleShift2); + G4SubtractionSolid* PCB_1 = new G4SubtractionSolid("PCB_1", PCBFull, HoleShape, new G4RotationMatrix, HoleShift1); + G4SubtractionSolid* PCB = new G4SubtractionSolid("PCB", PCB_1, HoleShape, new G4RotationMatrix, HoleShift2); // Sub Volume PCB - G4LogicalVolume* logicPCB = - new G4LogicalVolume(PCB,m_MaterialPCB,"logicPCB", 0, 0, 0); + G4LogicalVolume* logicPCB = new G4LogicalVolume(PCB, m_MaterialPCB, "logicPCB", 0, 0, 0); logicPCB->SetVisAttributes(PCBVisAtt); - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0), - logicPCB,"Strasse_Inner_PCB",m_InnerDetector, - false,0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicPCB, "Strasse_Inner_PCB", + m_InnerDetector, false, 0); /////////////////////////////////////////////////////////////////////////// // Build the PCB Ledge on wich Silicon is glued - double Inner_PCB2_Thickness = Inner_PCB_Step; //Step size - double offsetPCB2 = Inner_PCB2_Thickness - Inner_PCB_Thickness; + double Inner_PCB2_Thickness = Inner_PCB_Step; // Step size + double offsetPCB2 = Inner_PCB2_Thickness - Inner_PCB_Thickness; - double Inner_PCB2_MidWidth = Inner_PCB_MidWidth; + double Inner_PCB2_MidWidth = Inner_PCB_MidWidth; // perpendicular to beam axis - double Inner_PCB2_Width= Inner_Wafer_Width; + double Inner_PCB2_Width = Inner_Wafer_Width; vector<G4TwoVector> PCB2CrossSection; - PCB2CrossSection.push_back(G4TwoVector(Inner_PCB2_Width*0.5,-Inner_PCB2_Thickness*0.5)); - PCB2CrossSection.push_back(G4TwoVector(Inner_PCB2_Width*0.5,Inner_PCB2_Thickness*0.5)); - PCB2CrossSection.push_back(G4TwoVector(-Inner_PCB2_Width*0.5,Inner_PCB2_Thickness*0.5)); - PCB2CrossSection.push_back(G4TwoVector(-Inner_PCB2_Width*0.5,-Inner_PCB2_Thickness*0.5)); - - //double Inner_PCB2_Length= Inner_PCB_Length; - double Inner_PCB2_Length= 2*Inner_Wafer_Length + Inner_PCB_MidWidth; - - G4ExtrudedSolid* PCB2Full = - new G4ExtrudedSolid("PCB2Full", - PCB2CrossSection, - Inner_PCB2_Length*0.5,// half length - G4TwoVector(0,0),1,// offset, scale - G4TwoVector(0,0),1);// offset, scale - - - double Length_Shift21 = -0.5*Inner_PCB_Length // Flush to border - + 0.5*(Inner_PCB_UpstreamWidth+Inner_PCB_DownstreamWidth) // add Upstream side shift - + 0.5*Inner_Wafer_Length; - double Length_Shift22 = Length_Shift21 // overlap detector 1 - + Inner_Wafer_Length // at opposing edge - + Inner_PCB_MidWidth; // after mid width + PCB2CrossSection.push_back(G4TwoVector(Inner_PCB2_Width * 0.5, -Inner_PCB2_Thickness * 0.5)); + PCB2CrossSection.push_back(G4TwoVector(Inner_PCB2_Width * 0.5, Inner_PCB2_Thickness * 0.5)); + PCB2CrossSection.push_back(G4TwoVector(-Inner_PCB2_Width * 0.5, Inner_PCB2_Thickness * 0.5)); + PCB2CrossSection.push_back(G4TwoVector(-Inner_PCB2_Width * 0.5, -Inner_PCB2_Thickness * 0.5)); + + // double Inner_PCB2_Length= Inner_PCB_Length; + double Inner_PCB2_Length = 2 * Inner_Wafer_Length + Inner_PCB_MidWidth; + + G4ExtrudedSolid* PCB2Full = new G4ExtrudedSolid("PCB2Full", PCB2CrossSection, + Inner_PCB2_Length * 0.5, // half length + G4TwoVector(0, 0), 1, // offset, scale + G4TwoVector(0, 0), 1); // offset, scale + + double Length_Shift21 = -0.5 * Inner_PCB_Length // Flush to border + + 0.5 * (Inner_PCB_UpstreamWidth + Inner_PCB_DownstreamWidth) // add Upstream side shift + + 0.5 * Inner_Wafer_Length; + double Length_Shift22 = Length_Shift21 // overlap detector 1 + + Inner_Wafer_Length // at opposing edge + + Inner_PCB_MidWidth; // after mid width G4ThreeVector HoleShift21 = G4ThreeVector(0, 0, Length_Shift21); G4ThreeVector HoleShift22 = G4ThreeVector(0, 0, Length_Shift22); - G4Box* HoleShape2 = new G4Box("HoleShape2", - Inner_Wafer_Width*0.5 - Inner_PCB_Ledge, - Inner_PCB2_Thickness, - Inner_Wafer_Length*0.5 - Inner_PCB_Ledge); + G4Box* HoleShape2 = new G4Box("HoleShape2", Inner_Wafer_Width * 0.5 - Inner_PCB_Ledge, Inner_PCB2_Thickness, + Inner_Wafer_Length * 0.5 - Inner_PCB_Ledge); // Substracting the hole Shape from the Stock PCB - G4SubtractionSolid* PCB2_1 = new G4SubtractionSolid("PCB2_1", PCB2Full, HoleShape2, - new G4RotationMatrix,HoleShift21); - G4SubtractionSolid* PCB2_2 = new G4SubtractionSolid("PCB2_2", PCB2_1, HoleShape2, - new G4RotationMatrix,HoleShift22); + G4SubtractionSolid* PCB2_1 = + new G4SubtractionSolid("PCB2_1", PCB2Full, HoleShape2, new G4RotationMatrix, HoleShift21); + G4SubtractionSolid* PCB2_2 = + new G4SubtractionSolid("PCB2_2", PCB2_1, HoleShape2, new G4RotationMatrix, HoleShift22); G4ThreeVector HoleCenterBar = G4ThreeVector(0, 0, 0); - G4Box* HoleShapeCenterBar = new G4Box("HoleShapeCenterBar", - Inner_PCB2_Width*0.5+0.1, - Inner_PCB2_Thickness, - Inner_PCB2_MidWidth*0.5); + G4Box* HoleShapeCenterBar = + new G4Box("HoleShapeCenterBar", Inner_PCB2_Width * 0.5 + 0.1, Inner_PCB2_Thickness, Inner_PCB2_MidWidth * 0.5); - G4SubtractionSolid* PCB2_3 = new G4SubtractionSolid("PCB2_3", PCB2_2, HoleShapeCenterBar, - new G4RotationMatrix,HoleCenterBar); + G4SubtractionSolid* PCB2_3 = + new G4SubtractionSolid("PCB2_3", PCB2_2, HoleShapeCenterBar, new G4RotationMatrix, HoleCenterBar); // Sub Volume PCB - G4LogicalVolume* logicPCB2 = - new G4LogicalVolume(PCB2_3,m_MaterialPCB,"logicPCB2", 0, 0, 0); + G4LogicalVolume* logicPCB2 = new G4LogicalVolume(PCB2_3, m_MaterialPCB, "logicPCB2", 0, 0, 0); logicPCB2->SetVisAttributes(PADVisAtt); // Offset along beam axis between PCB middle and (2*Wafer+MiddleBar) volume center - double CentralZOffset = - Inner_PCB_Length*0.5 - + Inner_PCB_UpstreamWidth - + Inner_Wafer_Length - + Inner_PCB_MidWidth*0.5; - - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,-0.5*offsetPCB2,CentralZOffset), - logicPCB2,"Strasse_Inner_PCB2",m_InnerDetector, - false,0); + double CentralZOffset = + -Inner_PCB_Length * 0.5 + Inner_PCB_UpstreamWidth + Inner_Wafer_Length + Inner_PCB_MidWidth * 0.5; + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, -0.5 * offsetPCB2, CentralZOffset), logicPCB2, + "Strasse_Inner_PCB2", m_InnerDetector, false, 0); - /////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////// // Build the Wafer // Sub volume Wafer - G4Box* WaferShape = new G4Box("WaferShape", - Inner_Wafer_Width*0.5, - Inner_Wafer_Thickness*0.5+Inner_Wafer_AlThickness, - Inner_Wafer_Length*0.5); + G4Box* WaferShape = new G4Box("WaferShape", Inner_Wafer_Width * 0.5, + Inner_Wafer_Thickness * 0.5 + Inner_Wafer_AlThickness, Inner_Wafer_Length * 0.5); - G4LogicalVolume* logicWafer1 = - new G4LogicalVolume(WaferShape,m_MaterialSilicon,"logicWafer1", 0, 0, 0); + G4LogicalVolume* logicWafer1 = new G4LogicalVolume(WaferShape, m_MaterialSilicon, "logicWafer1", 0, 0, 0); logicWafer1->SetVisAttributes(GuardRingVisAtt); - G4LogicalVolume* logicWafer2 = - new G4LogicalVolume(WaferShape,m_MaterialSilicon,"logicWafer2", 0, 0, 0); + G4LogicalVolume* logicWafer2 = new G4LogicalVolume(WaferShape, m_MaterialSilicon, "logicWafer2", 0, 0, 0); logicWafer2->SetVisAttributes(GuardRingVisAtt); // Shift along Y to flush the wafer to the pcb ledge on one side - G4ThreeVector WaferShiftY = G4ThreeVector(0,-0.5*Inner_Wafer_Thickness - -Inner_Wafer_AlThickness - -0.5*Inner_PCB_Thickness - -offsetPCB2-0.05,0); - - //G4ThreeVector WaferShiftZ = G4ThreeVector(0,0,-Inner_PCB_UpstreamWidth-Inner_PCB_MidWidth); - G4ThreeVector WaferShiftZ = G4ThreeVector(0,0,CentralZOffset); - - new G4PVPlacement(new G4RotationMatrix(0,0,0), - WaferShiftY+WaferShiftZ // Shift along Y - +HoleShift21, // Shift along Z to putwafer in the 1st hole - logicWafer1,"Strasse_Inner_Wafer1",m_InnerDetector, - false,0); - - new G4PVPlacement(new G4RotationMatrix(0,0,0), - WaferShiftY+WaferShiftZ// Shift along Y - +HoleShift22, // Shift along Z to put wafer in the 2nd hole - logicWafer2,"Strasse_Inner_Wafer2",m_InnerDetector, - false,0); + G4ThreeVector WaferShiftY = G4ThreeVector( + 0, -0.5 * Inner_Wafer_Thickness - Inner_Wafer_AlThickness - 0.5 * Inner_PCB_Thickness - offsetPCB2 - 0.05, 0); + + // G4ThreeVector WaferShiftZ = G4ThreeVector(0,0,-Inner_PCB_UpstreamWidth-Inner_PCB_MidWidth); + G4ThreeVector WaferShiftZ = G4ThreeVector(0, 0, CentralZOffset); + + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), + WaferShiftY + WaferShiftZ // Shift along Y + + HoleShift21, // Shift along Z to putwafer in the 1st hole + logicWafer1, "Strasse_Inner_Wafer1", m_InnerDetector, false, 0); + + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), + WaferShiftY + WaferShiftZ // Shift along Y + + HoleShift22, // Shift along Z to put wafer in the 2nd hole + logicWafer2, "Strasse_Inner_Wafer2", m_InnerDetector, false, 0); // Sub volume Active Wafer - G4Box* ActiveWaferShape = new G4Box("InnerActiveWaferShape", - 0.5*m_Active_InnerWafer_Width, - 0.5*Inner_Wafer_Thickness, - 0.5*m_Active_InnerWafer_Length); + G4Box* ActiveWaferShape = new G4Box("InnerActiveWaferShape", 0.5 * m_Active_InnerWafer_Width, + 0.5 * Inner_Wafer_Thickness, 0.5 * m_Active_InnerWafer_Length); G4LogicalVolume* logicActiveWafer1 = - new G4LogicalVolume(ActiveWaferShape,m_MaterialSilicon,"logicActiveWafer1", 0, 0, 0); + new G4LogicalVolume(ActiveWaferShape, m_MaterialSilicon, "logicActiveWafer1", 0, 0, 0); logicActiveWafer1->SetVisAttributes(SiliconVisAtt); logicActiveWafer1->SetSensitiveDetector(m_InnerScorer1); G4LogicalVolume* logicActiveWafer2 = - new G4LogicalVolume(ActiveWaferShape,m_MaterialSilicon,"logicActiveWafer2", 0, 0, 0); + new G4LogicalVolume(ActiveWaferShape, m_MaterialSilicon, "logicActiveWafer2", 0, 0, 0); logicActiveWafer2->SetVisAttributes(SiliconVisAtt); logicActiveWafer2->SetSensitiveDetector(m_InnerScorer2); - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0.5*(Inner_Wafer_PADExternal-Inner_Wafer_PADInternal)), // assymetric pading for bounding - logicActiveWafer1,"Strasse_Inner_ActiveWafer1",logicWafer1, - false,1); - - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,-0.5*(Inner_Wafer_PADExternal-Inner_Wafer_PADInternal)), // assymetric pading for bounding - logicActiveWafer2,"Strasse_Inner_ActiveWafer2",logicWafer2, - false,2); - + new G4PVPlacement( + new G4RotationMatrix(0, 0, 0), + G4ThreeVector(0, 0, + 0.5 * (Inner_Wafer_PADExternal - Inner_Wafer_PADInternal)), // assymetric pading for bounding + logicActiveWafer1, "Strasse_Inner_ActiveWafer1", logicWafer1, false, 1); + + new G4PVPlacement( + new G4RotationMatrix(0, 0, 0), + G4ThreeVector(0, 0, + -0.5 * (Inner_Wafer_PADExternal - Inner_Wafer_PADInternal)), // assymetric pading for bounding + logicActiveWafer2, "Strasse_Inner_ActiveWafer2", logicWafer2, false, 2); } return m_InnerDetector; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Strasse::BuildOuterDetector(){ - if(!m_OuterDetector){ +G4LogicalVolume* Strasse::BuildOuterDetector() { + if (!m_OuterDetector) { // Compute the needed full length of the PCB // along beam axis - double Outer_PCB_Length= 2*Outer_Wafer_Length - +Outer_PCB_UpstreamWidth - +Outer_PCB_MidWidth - +Outer_PCB_DownstreamWidth; + double Outer_PCB_Length = + 2 * Outer_Wafer_Length + Outer_PCB_UpstreamWidth + Outer_PCB_MidWidth + Outer_PCB_DownstreamWidth; // perpendicular to beam axis - double Outer_PCB_Width= Outer_Wafer_Width - +Outer_PCB_StarboardWidth - +Outer_PCB_PortWidth; - + double Outer_PCB_Width = Outer_Wafer_Width + Outer_PCB_StarboardWidth + Outer_PCB_PortWidth; vector<G4TwoVector> PCBCrossSection; double l1; - if(Outer_PCB_BevelAngle==90) l1 = 0; - else l1 = Outer_PCB_Thickness*0.5/tan(Outer_PCB_BevelAngle); + if (Outer_PCB_BevelAngle == 90) + l1 = 0; + else + l1 = Outer_PCB_Thickness * 0.5 / tan(Outer_PCB_BevelAngle); - PCBCrossSection.push_back(G4TwoVector(Outer_PCB_Width*0.5-l1,-Outer_PCB_Thickness*0.5)); - PCBCrossSection.push_back(G4TwoVector(Outer_PCB_Width*0.5,Outer_PCB_Thickness*0.5)); - PCBCrossSection.push_back(G4TwoVector(-Outer_PCB_Width*0.5,Outer_PCB_Thickness*0.5)); - PCBCrossSection.push_back(G4TwoVector(-Outer_PCB_Width*0.5+l1,-Outer_PCB_Thickness*0.5)); + PCBCrossSection.push_back(G4TwoVector(Outer_PCB_Width * 0.5 - l1, -Outer_PCB_Thickness * 0.5)); + PCBCrossSection.push_back(G4TwoVector(Outer_PCB_Width * 0.5, Outer_PCB_Thickness * 0.5)); + PCBCrossSection.push_back(G4TwoVector(-Outer_PCB_Width * 0.5, Outer_PCB_Thickness * 0.5)); + PCBCrossSection.push_back(G4TwoVector(-Outer_PCB_Width * 0.5 + l1, -Outer_PCB_Thickness * 0.5)); - G4ExtrudedSolid* PCBFull = - new G4ExtrudedSolid("PCBFull", - PCBCrossSection, - Outer_PCB_Length*0.5,// half length - G4TwoVector(0,0),1,// offset, scale - G4TwoVector(0,0),1);// offset, scale + G4ExtrudedSolid* PCBFull = new G4ExtrudedSolid("PCBFull", PCBCrossSection, + Outer_PCB_Length * 0.5, // half length + G4TwoVector(0, 0), 1, // offset, scale + G4TwoVector(0, 0), 1); // offset, scale // Master Volume that encompass everything else - m_OuterDetector = - new G4LogicalVolume(PCBFull,m_MaterialVacuum,"logicBoxDetector", 0, 0, 0); - m_OuterDetector->SetVisAttributes(G4VisAttributes::Invisible); + m_OuterDetector = new G4LogicalVolume(PCBFull, m_MaterialVacuum, "logicBoxDetector", 0, 0, 0); + m_OuterDetector->SetVisAttributes(G4VisAttributes::GetInvisible()); // Build the PCB // Calculate the hole shift within the PCB - double Width_Shift= -0.5*Outer_PCB_Width + 0.5*Outer_Wafer_Width // Flush to border - +Outer_PCB_PortWidth; // add the port side shift + double Width_Shift = -0.5 * Outer_PCB_Width + 0.5 * Outer_Wafer_Width // Flush to border + + Outer_PCB_PortWidth; // add the port side shift - double Length_Shift1 = -0.5*Outer_PCB_Length + 0.5*Outer_Wafer_Length // Flush to border - + Outer_PCB_UpstreamWidth;// add Upstream side shift + double Length_Shift1 = -0.5 * Outer_PCB_Length + 0.5 * Outer_Wafer_Length // Flush to border + + Outer_PCB_UpstreamWidth; // add Upstream side shift - double Length_Shift2 = Length_Shift1 // overlap detector 1 - + Outer_Wafer_Length // at opposing edge - + Outer_PCB_MidWidth; // after mid width + double Length_Shift2 = Length_Shift1 // overlap detector 1 + + Outer_Wafer_Length // at opposing edge + + Outer_PCB_MidWidth; // after mid width G4ThreeVector HoleShift1 = G4ThreeVector(Width_Shift, 0, Length_Shift1); G4ThreeVector HoleShift2 = G4ThreeVector(Width_Shift, 0, Length_Shift2); - G4Box* HoleShape = new G4Box("HoleShape", - Outer_Wafer_Width*0.5, - Outer_PCB_Thickness*0.5+0.1*mm, - Outer_Wafer_Length*0.5); + G4Box* HoleShape = + new G4Box("HoleShape", Outer_Wafer_Width * 0.5, Outer_PCB_Thickness * 0.5 + 0.1 * mm, Outer_Wafer_Length * 0.5); // Substracting the hole Shape from the Stock PCB - G4SubtractionSolid* PCB_1 = new G4SubtractionSolid("PCB_1", PCBFull, HoleShape, - new G4RotationMatrix,HoleShift1); - G4SubtractionSolid* PCB = new G4SubtractionSolid("PCB", PCB_1, HoleShape, - new G4RotationMatrix,HoleShift2); + G4SubtractionSolid* PCB_1 = new G4SubtractionSolid("PCB_1", PCBFull, HoleShape, new G4RotationMatrix, HoleShift1); + G4SubtractionSolid* PCB = new G4SubtractionSolid("PCB", PCB_1, HoleShape, new G4RotationMatrix, HoleShift2); // Sub Volume PCB - G4LogicalVolume* logicPCB = - new G4LogicalVolume(PCB,m_MaterialPCB,"logicPCB", 0, 0, 0); + G4LogicalVolume* logicPCB = new G4LogicalVolume(PCB, m_MaterialPCB, "logicPCB", 0, 0, 0); logicPCB->SetVisAttributes(PCBVisAtt); - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0), - logicPCB,"Strasse_Outer_PCB",m_OuterDetector, - false,0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicPCB, "Strasse_Outer_PCB", + m_OuterDetector, false, 0); /////////////////////////////////////////////////////////////////////////// // Build the internal PCB layer - double Outer_PCB2_Thickness = Outer_PCB_Step;//Step size + double Outer_PCB2_Thickness = Outer_PCB_Step; // Step size double offsetPCB2 = Outer_PCB2_Thickness - Outer_PCB_Thickness; - double Outer_PCB2_MidWidth = Outer_PCB_MidWidth; + double Outer_PCB2_MidWidth = Outer_PCB_MidWidth; // perpendicular to beam axis - double Outer_PCB2_Width= Outer_Wafer_Width; + double Outer_PCB2_Width = Outer_Wafer_Width; vector<G4TwoVector> PCB2CrossSection; - PCB2CrossSection.push_back(G4TwoVector(Outer_PCB2_Width*0.5,-Outer_PCB2_Thickness*0.5)); - PCB2CrossSection.push_back(G4TwoVector(Outer_PCB2_Width*0.5,Outer_PCB2_Thickness*0.5)); - PCB2CrossSection.push_back(G4TwoVector(-Outer_PCB2_Width*0.5,Outer_PCB2_Thickness*0.5)); - PCB2CrossSection.push_back(G4TwoVector(-Outer_PCB2_Width*0.5,-Outer_PCB2_Thickness*0.5)); - - - double Outer_PCB2_Length= 2*Outer_Wafer_Length + Outer_PCB_MidWidth; + PCB2CrossSection.push_back(G4TwoVector(Outer_PCB2_Width * 0.5, -Outer_PCB2_Thickness * 0.5)); + PCB2CrossSection.push_back(G4TwoVector(Outer_PCB2_Width * 0.5, Outer_PCB2_Thickness * 0.5)); + PCB2CrossSection.push_back(G4TwoVector(-Outer_PCB2_Width * 0.5, Outer_PCB2_Thickness * 0.5)); + PCB2CrossSection.push_back(G4TwoVector(-Outer_PCB2_Width * 0.5, -Outer_PCB2_Thickness * 0.5)); - G4ExtrudedSolid* PCB2Full = - new G4ExtrudedSolid("PCB2Full", - PCB2CrossSection, - Outer_PCB2_Length*0.5,// half length - G4TwoVector(0,0),1,// offset, scale - G4TwoVector(0,0),1);// offset, scale + double Outer_PCB2_Length = 2 * Outer_Wafer_Length + Outer_PCB_MidWidth; + G4ExtrudedSolid* PCB2Full = new G4ExtrudedSolid("PCB2Full", PCB2CrossSection, + Outer_PCB2_Length * 0.5, // half length + G4TwoVector(0, 0), 1, // offset, scale + G4TwoVector(0, 0), 1); // offset, scale - double Length_Shift21 = -0.5*Outer_PCB_Length // Flush to border - + 0.5*(Outer_PCB_UpstreamWidth+Outer_PCB_DownstreamWidth) - + 0.5*Outer_Wafer_Length; - double Length_Shift22 = Length_Shift21 // overlap detector 1 - + Outer_Wafer_Length // at opposing edge - + Outer_PCB_MidWidth; // after mid width + double Length_Shift21 = -0.5 * Outer_PCB_Length // Flush to border + + 0.5 * (Outer_PCB_UpstreamWidth + Outer_PCB_DownstreamWidth) + 0.5 * Outer_Wafer_Length; + double Length_Shift22 = Length_Shift21 // overlap detector 1 + + Outer_Wafer_Length // at opposing edge + + Outer_PCB_MidWidth; // after mid width G4ThreeVector HoleShift21 = G4ThreeVector(0, 0, Length_Shift21); G4ThreeVector HoleShift22 = G4ThreeVector(0, 0, Length_Shift22); - G4Box* HoleShape2 = new G4Box("HoleShape2", - Outer_Wafer_Width*0.5 - Outer_PCB_Ledge, - Outer_PCB2_Thickness, - Outer_Wafer_Length*0.5 - Outer_PCB_Ledge); + G4Box* HoleShape2 = new G4Box("HoleShape2", Outer_Wafer_Width * 0.5 - Outer_PCB_Ledge, Outer_PCB2_Thickness, + Outer_Wafer_Length * 0.5 - Outer_PCB_Ledge); // Substracting the hole Shape from the Stock PCB - G4SubtractionSolid* PCB2_1 = new G4SubtractionSolid("PCB2_1", PCB2Full, HoleShape2, - new G4RotationMatrix,HoleShift21); - G4SubtractionSolid* PCB2_2 = new G4SubtractionSolid("PCB2_2", PCB2_1, HoleShape2, - new G4RotationMatrix,HoleShift22); - + G4SubtractionSolid* PCB2_1 = + new G4SubtractionSolid("PCB2_1", PCB2Full, HoleShape2, new G4RotationMatrix, HoleShift21); + G4SubtractionSolid* PCB2_2 = + new G4SubtractionSolid("PCB2_2", PCB2_1, HoleShape2, new G4RotationMatrix, HoleShift22); + G4ThreeVector HoleCenterBar = G4ThreeVector(0, 0, 0); - G4Box* HoleShapeCenterBar = new G4Box("HoleShapeCenterBar", - Outer_PCB2_Width*0.5+0.1, - Outer_PCB2_Thickness, - Outer_PCB2_MidWidth*0.5); + G4Box* HoleShapeCenterBar = + new G4Box("HoleShapeCenterBar", Outer_PCB2_Width * 0.5 + 0.1, Outer_PCB2_Thickness, Outer_PCB2_MidWidth * 0.5); - G4SubtractionSolid* PCB2_3 = new G4SubtractionSolid("PCB2_3", PCB2_2, HoleShapeCenterBar, - new G4RotationMatrix,HoleCenterBar); + G4SubtractionSolid* PCB2_3 = + new G4SubtractionSolid("PCB2_3", PCB2_2, HoleShapeCenterBar, new G4RotationMatrix, HoleCenterBar); // Sub Volume PCB - G4LogicalVolume* logicPCB2 = - new G4LogicalVolume(PCB2_3,m_MaterialPCB,"logicPCB2", 0, 0, 0); + G4LogicalVolume* logicPCB2 = new G4LogicalVolume(PCB2_3, m_MaterialPCB, "logicPCB2", 0, 0, 0); logicPCB2->SetVisAttributes(PADVisAtt); // Offset along beam axis between PCB middle and (2*Wafer+MiddleBar) volume center - double CentralZOffset = - Outer_PCB_Length*0.5 - + Outer_PCB_UpstreamWidth - + Outer_Wafer_Length - + Outer_PCB_MidWidth*0.5; + double CentralZOffset = + -Outer_PCB_Length * 0.5 + Outer_PCB_UpstreamWidth + Outer_Wafer_Length + Outer_PCB_MidWidth * 0.5; - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,-0.5*offsetPCB2,CentralZOffset), - logicPCB2,"Strasse_Outer_PCB2",m_OuterDetector, - false,0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, -0.5 * offsetPCB2, CentralZOffset), logicPCB2, + "Strasse_Outer_PCB2", m_OuterDetector, false, 0); ////////////////////////////////////////////////////////////////// // Build the Wafer // Sub volume Wafer - G4Box* WaferShape = new G4Box("WaferShape", - Outer_Wafer_Width*0.5, - Outer_Wafer_Thickness*0.5+Outer_Wafer_AlThickness, - Outer_Wafer_Length*0.5); + G4Box* WaferShape = new G4Box("WaferShape", Outer_Wafer_Width * 0.5, + Outer_Wafer_Thickness * 0.5 + Outer_Wafer_AlThickness, Outer_Wafer_Length * 0.5); - G4LogicalVolume* logicWafer1 = - new G4LogicalVolume(WaferShape,m_MaterialSilicon,"logicWafer1", 0, 0, 0); + G4LogicalVolume* logicWafer1 = new G4LogicalVolume(WaferShape, m_MaterialSilicon, "logicWafer1", 0, 0, 0); logicWafer1->SetVisAttributes(GuardRingVisAtt); - G4LogicalVolume* logicWafer2 = - new G4LogicalVolume(WaferShape,m_MaterialSilicon,"logicWafer2", 0, 0, 0); + G4LogicalVolume* logicWafer2 = new G4LogicalVolume(WaferShape, m_MaterialSilicon, "logicWafer2", 0, 0, 0); logicWafer2->SetVisAttributes(GuardRingVisAtt); // Shift along Y to flush the wafer to the pcb ledge on one side - G4ThreeVector WaferShiftY = G4ThreeVector(0,-0.5*Outer_Wafer_Thickness - -Outer_Wafer_AlThickness - -0.5*Outer_PCB_Thickness - -offsetPCB2-0.05,0); - - //G4ThreeVector WaferShiftZ = G4ThreeVector(0,0,-Outer_PCB_UpstreamWidth-Outer_PCB_MidWidth); - G4ThreeVector WaferShiftZ = G4ThreeVector(0,0,CentralZOffset); - - new G4PVPlacement(new G4RotationMatrix(0,0,0), - WaferShiftY+WaferShiftZ - +HoleShift21, // Shift along Z to put wafer in the 1st hole - logicWafer1,"Strasse_Outer_Wafer1",m_OuterDetector, - false,0); - - new G4PVPlacement(new G4RotationMatrix(0,0,0), - WaferShiftY+WaferShiftZ - +HoleShift22, // Shift along Z to put wafer in the 1st hole - logicWafer2,"Strasse_Outer_Wafer2",m_OuterDetector, - false,0); + G4ThreeVector WaferShiftY = G4ThreeVector( + 0, -0.5 * Outer_Wafer_Thickness - Outer_Wafer_AlThickness - 0.5 * Outer_PCB_Thickness - offsetPCB2 - 0.05, 0); + + // G4ThreeVector WaferShiftZ = G4ThreeVector(0,0,-Outer_PCB_UpstreamWidth-Outer_PCB_MidWidth); + G4ThreeVector WaferShiftZ = G4ThreeVector(0, 0, CentralZOffset); + + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), + WaferShiftY + WaferShiftZ + HoleShift21, // Shift along Z to put wafer in the 1st hole + logicWafer1, "Strasse_Outer_Wafer1", m_OuterDetector, false, 0); + + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), + WaferShiftY + WaferShiftZ + HoleShift22, // Shift along Z to put wafer in the 1st hole + logicWafer2, "Strasse_Outer_Wafer2", m_OuterDetector, false, 0); // Sub volume Active Wafer - G4Box* ActiveWaferShape = new G4Box("OuterActiveWaferShape", - 0.5*m_Active_OuterWafer_Width, - 0.5*Outer_Wafer_Thickness, - 0.5*m_Active_OuterWafer_Length); + G4Box* ActiveWaferShape = new G4Box("OuterActiveWaferShape", 0.5 * m_Active_OuterWafer_Width, + 0.5 * Outer_Wafer_Thickness, 0.5 * m_Active_OuterWafer_Length); G4LogicalVolume* logicActiveWafer1 = - new G4LogicalVolume(ActiveWaferShape,m_MaterialSilicon,"logicActiveWafer1", 0, 0, 0); + new G4LogicalVolume(ActiveWaferShape, m_MaterialSilicon, "logicActiveWafer1", 0, 0, 0); logicActiveWafer1->SetVisAttributes(SiliconVisAtt); logicActiveWafer1->SetSensitiveDetector(m_OuterScorer1); G4LogicalVolume* logicActiveWafer2 = - new G4LogicalVolume(ActiveWaferShape,m_MaterialSilicon,"logicActiveWafer2", 0, 0, 0); + new G4LogicalVolume(ActiveWaferShape, m_MaterialSilicon, "logicActiveWafer2", 0, 0, 0); logicActiveWafer2->SetVisAttributes(SiliconVisAtt); logicActiveWafer2->SetSensitiveDetector(m_OuterScorer2); - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0.5*(Outer_Wafer_PADExternal-Outer_Wafer_PADInternal)), - logicActiveWafer1,"Strasse_Outer_ActiveWafer1",logicWafer1, - false,1); - - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,-0.5*(Outer_Wafer_PADExternal-Outer_Wafer_PADInternal)), - logicActiveWafer2,"Strasse_Outer_ActiveWafer2",logicWafer2, - false,2); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), + G4ThreeVector(0, 0, 0.5 * (Outer_Wafer_PADExternal - Outer_Wafer_PADInternal)), logicActiveWafer1, + "Strasse_Outer_ActiveWafer1", logicWafer1, false, 1); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), + G4ThreeVector(0, 0, -0.5 * (Outer_Wafer_PADExternal - Outer_Wafer_PADInternal)), + logicActiveWafer2, "Strasse_Outer_ActiveWafer2", logicWafer2, false, 2); } return m_OuterDetector; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Strasse::BuildChamber(){ - if(!m_Chamber){ +G4LogicalVolume* Strasse::BuildChamber() { + if (!m_Chamber) { // Needed Element // G4Material* Material = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); G4Material* Material = MaterialManager::getInstance()->GetMaterialFromLibrary("Al5754"); @@ -639,141 +559,118 @@ G4LogicalVolume* Strasse::BuildChamber(){ G4RotationMatrix* Rot = new G4RotationMatrix(); // Main Cylinder - G4Tubs* Cylinder = new G4Tubs("StrasseCylinderVolume", - Chamber_Radius-Chamber_Thickness, - Chamber_Radius,Chamber_Cylinder_Length*0.5, - 0,360*deg); + G4Tubs* Cylinder = new G4Tubs("StrasseCylinderVolume", Chamber_Radius - Chamber_Thickness, Chamber_Radius, + Chamber_Cylinder_Length * 0.5, 0, 360 * deg); // for substraction - G4Tubs* DummyCyl = new G4Tubs("StrasseDummyCylVolume", - 0, - Chamber_Sphere_Radius*1.1,Chamber_Cylinder_Length*0.5, - 0,360*deg); + G4Tubs* DummyCyl = new G4Tubs("StrasseDummyCylVolume", 0, Chamber_Sphere_Radius * 1.1, + Chamber_Cylinder_Length * 0.5, 0, 360 * deg); - - // G4LogicalVolume* ChamberCyl = new G4LogicalVolume(Cyl,Material,"logic_Strasse_Chamber",0,0,0); + // G4LogicalVolume* ChamberCyl = new G4LogicalVolume(Cyl,Material,"logic_Strasse_Chamber",0,0,0); // Entrance Flange - G4Tubs* Flange = new G4Tubs("StrasseFlangeVolume", - Chamber_Flange_Inner_Radius, - Chamber_Radius,1*cm, - 0,360*deg); + G4Tubs* Flange = + new G4Tubs("StrasseFlangeVolume", Chamber_Flange_Inner_Radius, Chamber_Radius, 1 * cm, 0, 360 * deg); - // G4LogicalVolume* ChamberFlange = new G4LogicalVolume(Flange,Material,"logic_Strasse_Flange",0,0,0); + // G4LogicalVolume* ChamberFlange = new G4LogicalVolume(Flange,Material,"logic_Strasse_Flange",0,0,0); // Spherial Portion - G4Sphere* Sphere= new G4Sphere("StrasseSphereVolume", - Chamber_Sphere_Radius-Chamber_Thickness, - Chamber_Sphere_Radius, - 0,360*deg, - 0,180*deg); - + G4Sphere* Sphere = new G4Sphere("StrasseSphereVolume", Chamber_Sphere_Radius - Chamber_Thickness, + Chamber_Sphere_Radius, 0, 360 * deg, 0, 180 * deg); + // Exit tube portion - G4Tubs* Tube = new G4Tubs("StrasseTubeVolume", - Chamber_ExitTube_Radius-Chamber_Thickness, - Chamber_ExitTube_Radius,Chamber_ExitTube_Length*0.5, - 0,360*deg); - G4Tubs* DummyTube = new G4Tubs("StrasseDummyTubeVolume", - 0, - Chamber_ExitTube_Radius*0.99,Chamber_ExitTube_Length*0.5, - 0,360*deg); - - //Partial Sphere - - G4SubtractionSolid* Sphere1= new G4SubtractionSolid("Sphere1",Sphere,DummyCyl, - Rot,G4ThreeVector(0,0,-Chamber_Sphere_Shift)); - G4SubtractionSolid* Sphere2= new G4SubtractionSolid("Sphere2",Sphere1,DummyTube, - Rot,G4ThreeVector(0,0,Chamber_Sphere_Radius+Chamber_ExitTube_Length*0.5-2*cm)); - + G4Tubs* Tube = new G4Tubs("StrasseTubeVolume", Chamber_ExitTube_Radius - Chamber_Thickness, Chamber_ExitTube_Radius, + Chamber_ExitTube_Length * 0.5, 0, 360 * deg); + G4Tubs* DummyTube = new G4Tubs("StrasseDummyTubeVolume", 0, Chamber_ExitTube_Radius * 0.99, + Chamber_ExitTube_Length * 0.5, 0, 360 * deg); + + // Partial Sphere + + G4SubtractionSolid* Sphere1 = + new G4SubtractionSolid("Sphere1", Sphere, DummyCyl, Rot, G4ThreeVector(0, 0, -Chamber_Sphere_Shift)); + G4SubtractionSolid* Sphere2 = + new G4SubtractionSolid("Sphere2", Sphere1, DummyTube, Rot, + G4ThreeVector(0, 0, Chamber_Sphere_Radius + Chamber_ExitTube_Length * 0.5 - 2 * cm)); + // Building the whole chamber - G4UnionSolid* Chamber1= new G4UnionSolid("Chamber1",Cylinder,Flange, - Rot,G4ThreeVector(0,0,-Chamber_Cylinder_Length*0.5)); + G4UnionSolid* Chamber1 = + new G4UnionSolid("Chamber1", Cylinder, Flange, Rot, G4ThreeVector(0, 0, -Chamber_Cylinder_Length * 0.5)); - G4UnionSolid* Chamber2= new G4UnionSolid("Chamber2",Chamber1,Sphere2, - Rot,G4ThreeVector(0,0,Chamber_Sphere_Shift)); + G4UnionSolid* Chamber2 = + new G4UnionSolid("Chamber2", Chamber1, Sphere2, Rot, G4ThreeVector(0, 0, Chamber_Sphere_Shift)); - G4UnionSolid* Chamber3= new G4UnionSolid("Chamber3",Chamber2,Tube, - Rot,G4ThreeVector(0,0,Chamber_Sphere_Shift+Chamber_Sphere_Radius+Chamber_ExitTube_Length*0.5-2*cm)); + G4UnionSolid* Chamber3 = new G4UnionSolid( + "Chamber3", Chamber2, Tube, Rot, + G4ThreeVector(0, 0, Chamber_Sphere_Shift + Chamber_Sphere_Radius + Chamber_ExitTube_Length * 0.5 - 2 * cm)); - m_Chamber = new G4LogicalVolume(Chamber3,Material,"logic_Strasse_Chamber",0,0,0); + m_Chamber = new G4LogicalVolume(Chamber3, Material, "logic_Strasse_Chamber", 0, 0, 0); m_Chamber->SetVisAttributes(ChamberVisAtt); } - return m_Chamber; - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Strasse::BuildChamberFromCAD(string path){ - if(!m_Chamber){ - auto mesh = CADMesh::TessellatedMesh::FromSTL((char*) path.c_str()); - mesh->SetScale(mm); - //mesh->SetOffset(offset); - mesh->SetReverse(false); - - auto cad_solid = mesh->GetSolid(); - m_Chamber = new G4LogicalVolume(cad_solid, - m_MaterialAl, - "Strasse_Chamber", 0, 0, 0); - - m_Chamber->SetVisAttributes(ChamberVisAtt); - } - return m_Chamber; +G4LogicalVolume* Strasse::BuildChamberFromCAD(string path) { + if (!m_Chamber) { + auto mesh = CADMesh::TessellatedMesh::FromSTL((char*)path.c_str()); + mesh->SetScale(mm); + // mesh->SetOffset(offset); + mesh->SetReverse(false); + auto cad_solid = mesh->GetSolid(); + m_Chamber = new G4LogicalVolume(cad_solid, m_MaterialAl, "Strasse_Chamber", 0, 0, 0); + + m_Chamber->SetVisAttributes(ChamberVisAtt); + } + return m_Chamber; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Strasse::BuildBlades(string path){ - if(!m_Blades){ - auto mesh = CADMesh::TessellatedMesh::FromSTL((char*) path.c_str()); - mesh->SetScale(mm); - //mesh->SetOffset(offset); - mesh->SetReverse(false); - - auto cad_solid = mesh->GetSolid(); - m_Blades = new G4LogicalVolume(cad_solid, - m_MaterialCu, - "Strasse_Blades", 0, 0, 0); - - m_Blades->SetVisAttributes(BladeVisAtt); - } - return m_Blades; +G4LogicalVolume* Strasse::BuildBlades(string path) { + if (!m_Blades) { + auto mesh = CADMesh::TessellatedMesh::FromSTL((char*)path.c_str()); + mesh->SetScale(mm); + // mesh->SetOffset(offset); + mesh->SetReverse(false); + + auto cad_solid = mesh->GetSolid(); + m_Blades = new G4LogicalVolume(cad_solid, m_MaterialCu, "Strasse_Blades", 0, 0, 0); + + m_Blades->SetVisAttributes(BladeVisAtt); + } + return m_Blades; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Strasse::BuildStars(string path){ - if(!m_Stars){ - auto mesh = CADMesh::TessellatedMesh::FromSTL((char*) path.c_str()); - mesh->SetScale(mm); - //mesh->SetOffset(offset); - mesh->SetReverse(false); - - auto cad_solid = mesh->GetSolid(); - m_Stars = new G4LogicalVolume(cad_solid, - m_MaterialAl, - "Strasse_Stars", 0, 0, 0); - - m_Stars->SetVisAttributes(StarsVisAtt); - } - return m_Stars; +G4LogicalVolume* Strasse::BuildStars(string path) { + if (!m_Stars) { + auto mesh = CADMesh::TessellatedMesh::FromSTL((char*)path.c_str()); + mesh->SetScale(mm); + // mesh->SetOffset(offset); + mesh->SetReverse(false); + + auto cad_solid = mesh->GetSolid(); + m_Stars = new G4LogicalVolume(cad_solid, m_MaterialAl, "Strasse_Stars", 0, 0, 0); + + m_Stars->SetVisAttributes(StarsVisAtt); + } + return m_Stars; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Strasse::BuildBase(string path){ - if(!m_Base){ - auto mesh = CADMesh::TessellatedMesh::FromSTL((char*) path.c_str()); - mesh->SetScale(mm); - //mesh->SetOffset(offset); - mesh->SetReverse(false); - - auto cad_solid = mesh->GetSolid(); - m_Base = new G4LogicalVolume(cad_solid, - m_MaterialAl, - "Strasse_Base", 0, 0, 0); - - m_Base->SetVisAttributes(StarsVisAtt); - } - return m_Base; +G4LogicalVolume* Strasse::BuildBase(string path) { + if (!m_Base) { + auto mesh = CADMesh::TessellatedMesh::FromSTL((char*)path.c_str()); + mesh->SetScale(mm); + // mesh->SetOffset(offset); + mesh->SetReverse(false); + + auto cad_solid = mesh->GetSolid(); + m_Base = new G4LogicalVolume(cad_solid, m_MaterialAl, "Strasse_Base", 0, 0, 0); + + m_Base->SetVisAttributes(StarsVisAtt); + } + return m_Base; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -783,460 +680,432 @@ G4LogicalVolume* Strasse::BuildBase(string path){ // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Strasse::ReadConfiguration(NPL::InputParser parser){ +void Strasse::ReadConfiguration(NPL::InputParser parser) { // Info block - vector<NPL::InputBlock*> blocks_info = parser.GetAllBlocksWithTokenAndValue("Strasse","Info"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks_info.size() << " info block founds " << endl; + vector<NPL::InputBlock*> blocks_info = parser.GetAllBlocksWithTokenAndValue("Strasse", "Info"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks_info.size() << " info block founds " << endl; - if(blocks_info.size()>1){ - cout << "ERROR: can only accepte one info block, " << blocks_info.size() << " info block founds." << endl; - exit(1); + if (blocks_info.size() > 1) { + cout << "ERROR: can only accepte one info block, " << blocks_info.size() << " info block founds." << endl; + exit(1); } - vector<string> info = { - "Inner_Wafer_Length", - "Inner_Wafer_Width", - "Inner_Wafer_Thickness", - "Inner_Wafer_AlThickness", - "Inner_Wafer_PADExternal", - "Inner_Wafer_PADInternal", - "Inner_Wafer_GuardRing", - "Inner_PCB_PortWidth", - "Inner_PCB_StarboardWidth", - "Inner_PCB_BevelAngle", - "Inner_PCB_UpstreamWidth", - "Inner_PCB_DownstreamWidth", - "Inner_PCB_MidWidth", - "Inner_PCB_Thickness", - "Inner_PCB_Ledge", - "Inner_PCB_Step", - "Inner_Wafer_TransverseStrips", - "Inner_Wafer_LongitudinalStrips", - "Outer_Wafer_Length", - "Outer_Wafer_Width", - "Outer_Wafer_Thickness", - "Outer_Wafer_AlThickness", - "Outer_Wafer_PADExternal", - "Outer_Wafer_PADInternal", - "Outer_Wafer_GuardRing", - "Outer_PCB_PortWidth", - "Outer_PCB_StarboardWidth", - "Outer_PCB_BevelAngle", - "Outer_PCB_UpstreamWidth", - "Outer_PCB_DownstreamWidth", - "Outer_PCB_MidWidth", - "Outer_PCB_Thickness", - "Outer_PCB_Ledge", - "Outer_PCB_Step", - "Outer_Wafer_TransverseStrips", - "Outer_Wafer_LongitudinalStrips", - "Chamber_Thickness", - "Chamber_Cylinder_Length", - "Chamber_Radius", - "Chamber_ExitTube_Radius", - "Chamber_ExitTube_Length", - "Chamber_Flange_Inner_Radius", - "Chamber_Sphere_Radius", - "Chamber_Sphere_Shift" - }; - - if(blocks_info[0]->HasTokenList(info)){ - cout << endl << "//// Strasse info block" << endl; - Inner_Wafer_Length = blocks_info[0]->GetDouble("Inner_Wafer_Length","mm"); - Inner_Wafer_Width = blocks_info[0]->GetDouble("Inner_Wafer_Width","mm"); - Inner_Wafer_Thickness = blocks_info[0]->GetDouble("Inner_Wafer_Thickness","micrometer"); - Inner_Wafer_AlThickness = blocks_info[0]->GetDouble("Inner_Wafer_AlThickness","micrometer"); - Inner_Wafer_PADExternal = blocks_info[0]->GetDouble("Inner_Wafer_PADExternal","mm"); - Inner_Wafer_PADInternal = blocks_info[0]->GetDouble("Inner_Wafer_PADInternal","mm"); - Inner_Wafer_GuardRing = blocks_info[0]->GetDouble("Inner_Wafer_GuardRing","mm"); - Inner_Wafer_TransverseStrips = blocks_info[0]->GetInt("Inner_Wafer_TransverseStrips"); - Inner_Wafer_LongitudinalStrips = blocks_info[0]->GetInt("Inner_Wafer_LongitudinalStrips"); - Inner_PCB_PortWidth = blocks_info[0]->GetDouble("Inner_PCB_PortWidth","mm"); - Inner_PCB_StarboardWidth = blocks_info[0]->GetDouble("Inner_PCB_StarboardWidth","mm"); - Inner_PCB_BevelAngle = blocks_info[0]->GetDouble("Inner_PCB_BevelAngle","mm"); - Inner_PCB_UpstreamWidth = blocks_info[0]->GetDouble("Inner_PCB_UpstreamWidth","mm"); - Inner_PCB_DownstreamWidth = blocks_info[0]->GetDouble("Inner_PCB_DownstreamWidth","mm"); - Inner_PCB_MidWidth = blocks_info[0]->GetDouble("Inner_PCB_MidWidth","mm"); - Inner_PCB_Thickness = blocks_info[0]->GetDouble("Inner_PCB_Thickness","mm"); - Inner_PCB_Ledge = blocks_info[0]->GetDouble("Inner_PCB_Ledge","mm"); - Inner_PCB_Step = blocks_info[0]->GetDouble("Inner_PCB_Step","mm"); - Outer_Wafer_Length = blocks_info[0]->GetDouble("Outer_Wafer_Length","mm"); - Outer_Wafer_Width = blocks_info[0]->GetDouble("Outer_Wafer_Width","mm"); - Outer_Wafer_Thickness = blocks_info[0]->GetDouble("Outer_Wafer_Thickness","mm"); - Outer_Wafer_AlThickness = blocks_info[0]->GetDouble("Outer_Wafer_AlThickness","micrometer"); - Outer_Wafer_PADExternal = blocks_info[0]->GetDouble("Outer_Wafer_PADExternal","mm"); - Outer_Wafer_PADInternal = blocks_info[0]->GetDouble("Outer_Wafer_PADInternal","mm"); - Outer_Wafer_GuardRing = blocks_info[0]->GetDouble("Outer_Wafer_GuardRing","mm"); - Outer_Wafer_TransverseStrips = blocks_info[0]->GetInt("Outer_Wafer_TransverseStrips"); - Outer_Wafer_LongitudinalStrips = blocks_info[0]->GetInt("Outer_Wafer_LongitudinalStrips"); - Outer_PCB_PortWidth = blocks_info[0]->GetDouble("Outer_PCB_PortWidth","mm"); - Outer_PCB_StarboardWidth = blocks_info[0]->GetDouble("Outer_PCB_StarboardWidth","mm"); - Outer_PCB_BevelAngle = blocks_info[0]->GetDouble("Outer_PCB_BevelAngle","deg"); - Outer_PCB_UpstreamWidth = blocks_info[0]->GetDouble("Outer_PCB_UpstreamWidth","mm"); - Outer_PCB_DownstreamWidth = blocks_info[0]->GetDouble("Outer_PCB_DownstreamWidth","mm"); - Outer_PCB_MidWidth = blocks_info[0]->GetDouble("Outer_PCB_MidWidth","mm"); - Outer_PCB_Thickness = blocks_info[0]->GetDouble("Outer_PCB_Thickness","mm"); - Outer_PCB_Ledge = blocks_info[0]->GetDouble("Outer_PCB_Ledge","mm"); - Outer_PCB_Step = blocks_info[0]->GetDouble("Outer_PCB_Step","mm"); - Chamber_Thickness= blocks_info[0]->GetDouble("Chamber_Thickness","mm"); - Chamber_Cylinder_Length= blocks_info[0]->GetDouble("Chamber_Cylinder_Length","mm"); - Chamber_Radius= blocks_info[0]->GetDouble("Chamber_Radius","mm"); - Chamber_ExitTube_Radius=blocks_info[0]->GetDouble("Chamber_ExitTube_Radius","mm"); - Chamber_ExitTube_Length=blocks_info[0]->GetDouble("Chamber_ExitTube_Length","mm"); - Chamber_Flange_Inner_Radius=blocks_info[0]->GetDouble("Chamber_Flange_Inner_Radius","mm"); - Chamber_Sphere_Radius=blocks_info[0]->GetDouble("Chamber_Sphere_Radius","mm"); - Chamber_Sphere_Shift=blocks_info[0]->GetDouble("Chamber_Sphere_Shift","mm"); + vector<string> info = {"Inner_Wafer_Length", + "Inner_Wafer_Width", + "Inner_Wafer_Thickness", + "Inner_Wafer_AlThickness", + "Inner_Wafer_PADExternal", + "Inner_Wafer_PADInternal", + "Inner_Wafer_GuardRing", + "Inner_PCB_PortWidth", + "Inner_PCB_StarboardWidth", + "Inner_PCB_BevelAngle", + "Inner_PCB_UpstreamWidth", + "Inner_PCB_DownstreamWidth", + "Inner_PCB_MidWidth", + "Inner_PCB_Thickness", + "Inner_PCB_Ledge", + "Inner_PCB_Step", + "Inner_Wafer_TransverseStrips", + "Inner_Wafer_LongitudinalStrips", + "Outer_Wafer_Length", + "Outer_Wafer_Width", + "Outer_Wafer_Thickness", + "Outer_Wafer_AlThickness", + "Outer_Wafer_PADExternal", + "Outer_Wafer_PADInternal", + "Outer_Wafer_GuardRing", + "Outer_PCB_PortWidth", + "Outer_PCB_StarboardWidth", + "Outer_PCB_BevelAngle", + "Outer_PCB_UpstreamWidth", + "Outer_PCB_DownstreamWidth", + "Outer_PCB_MidWidth", + "Outer_PCB_Thickness", + "Outer_PCB_Ledge", + "Outer_PCB_Step", + "Outer_Wafer_TransverseStrips", + "Outer_Wafer_LongitudinalStrips", + "Chamber_Thickness", + "Chamber_Cylinder_Length", + "Chamber_Radius", + "Chamber_ExitTube_Radius", + "Chamber_ExitTube_Length", + "Chamber_Flange_Inner_Radius", + "Chamber_Sphere_Radius", + "Chamber_Sphere_Shift"}; + + if (blocks_info[0]->HasTokenList(info)) { + cout << endl << "//// Strasse info block" << endl; + Inner_Wafer_Length = blocks_info[0]->GetDouble("Inner_Wafer_Length", "mm"); + Inner_Wafer_Width = blocks_info[0]->GetDouble("Inner_Wafer_Width", "mm"); + Inner_Wafer_Thickness = blocks_info[0]->GetDouble("Inner_Wafer_Thickness", "micrometer"); + Inner_Wafer_AlThickness = blocks_info[0]->GetDouble("Inner_Wafer_AlThickness", "micrometer"); + Inner_Wafer_PADExternal = blocks_info[0]->GetDouble("Inner_Wafer_PADExternal", "mm"); + Inner_Wafer_PADInternal = blocks_info[0]->GetDouble("Inner_Wafer_PADInternal", "mm"); + Inner_Wafer_GuardRing = blocks_info[0]->GetDouble("Inner_Wafer_GuardRing", "mm"); + Inner_Wafer_TransverseStrips = blocks_info[0]->GetInt("Inner_Wafer_TransverseStrips"); + Inner_Wafer_LongitudinalStrips = blocks_info[0]->GetInt("Inner_Wafer_LongitudinalStrips"); + Inner_PCB_PortWidth = blocks_info[0]->GetDouble("Inner_PCB_PortWidth", "mm"); + Inner_PCB_StarboardWidth = blocks_info[0]->GetDouble("Inner_PCB_StarboardWidth", "mm"); + Inner_PCB_BevelAngle = blocks_info[0]->GetDouble("Inner_PCB_BevelAngle", "mm"); + Inner_PCB_UpstreamWidth = blocks_info[0]->GetDouble("Inner_PCB_UpstreamWidth", "mm"); + Inner_PCB_DownstreamWidth = blocks_info[0]->GetDouble("Inner_PCB_DownstreamWidth", "mm"); + Inner_PCB_MidWidth = blocks_info[0]->GetDouble("Inner_PCB_MidWidth", "mm"); + Inner_PCB_Thickness = blocks_info[0]->GetDouble("Inner_PCB_Thickness", "mm"); + Inner_PCB_Ledge = blocks_info[0]->GetDouble("Inner_PCB_Ledge", "mm"); + Inner_PCB_Step = blocks_info[0]->GetDouble("Inner_PCB_Step", "mm"); + Outer_Wafer_Length = blocks_info[0]->GetDouble("Outer_Wafer_Length", "mm"); + Outer_Wafer_Width = blocks_info[0]->GetDouble("Outer_Wafer_Width", "mm"); + Outer_Wafer_Thickness = blocks_info[0]->GetDouble("Outer_Wafer_Thickness", "mm"); + Outer_Wafer_AlThickness = blocks_info[0]->GetDouble("Outer_Wafer_AlThickness", "micrometer"); + Outer_Wafer_PADExternal = blocks_info[0]->GetDouble("Outer_Wafer_PADExternal", "mm"); + Outer_Wafer_PADInternal = blocks_info[0]->GetDouble("Outer_Wafer_PADInternal", "mm"); + Outer_Wafer_GuardRing = blocks_info[0]->GetDouble("Outer_Wafer_GuardRing", "mm"); + Outer_Wafer_TransverseStrips = blocks_info[0]->GetInt("Outer_Wafer_TransverseStrips"); + Outer_Wafer_LongitudinalStrips = blocks_info[0]->GetInt("Outer_Wafer_LongitudinalStrips"); + Outer_PCB_PortWidth = blocks_info[0]->GetDouble("Outer_PCB_PortWidth", "mm"); + Outer_PCB_StarboardWidth = blocks_info[0]->GetDouble("Outer_PCB_StarboardWidth", "mm"); + Outer_PCB_BevelAngle = blocks_info[0]->GetDouble("Outer_PCB_BevelAngle", "deg"); + Outer_PCB_UpstreamWidth = blocks_info[0]->GetDouble("Outer_PCB_UpstreamWidth", "mm"); + Outer_PCB_DownstreamWidth = blocks_info[0]->GetDouble("Outer_PCB_DownstreamWidth", "mm"); + Outer_PCB_MidWidth = blocks_info[0]->GetDouble("Outer_PCB_MidWidth", "mm"); + Outer_PCB_Thickness = blocks_info[0]->GetDouble("Outer_PCB_Thickness", "mm"); + Outer_PCB_Ledge = blocks_info[0]->GetDouble("Outer_PCB_Ledge", "mm"); + Outer_PCB_Step = blocks_info[0]->GetDouble("Outer_PCB_Step", "mm"); + Chamber_Thickness = blocks_info[0]->GetDouble("Chamber_Thickness", "mm"); + Chamber_Cylinder_Length = blocks_info[0]->GetDouble("Chamber_Cylinder_Length", "mm"); + Chamber_Radius = blocks_info[0]->GetDouble("Chamber_Radius", "mm"); + Chamber_ExitTube_Radius = blocks_info[0]->GetDouble("Chamber_ExitTube_Radius", "mm"); + Chamber_ExitTube_Length = blocks_info[0]->GetDouble("Chamber_ExitTube_Length", "mm"); + Chamber_Flange_Inner_Radius = blocks_info[0]->GetDouble("Chamber_Flange_Inner_Radius", "mm"); + Chamber_Sphere_Radius = blocks_info[0]->GetDouble("Chamber_Sphere_Radius", "mm"); + Chamber_Sphere_Shift = blocks_info[0]->GetDouble("Chamber_Sphere_Shift", "mm"); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } - // Inner Barrel - vector<NPL::InputBlock*> blocks_inner = parser.GetAllBlocksWithTokenAndValue("Strasse","Inner"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks_inner.size() << " inner detectors found " << endl; - - vector<string> coord = {"Radius","Z","Phi","Shift","Ref"}; - - for(unsigned int i = 0 ; i < blocks_inner.size() ; i++){ - if(blocks_inner[i]->HasTokenList(coord)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Strasse inner detector" << i+1 << endl; - - double R = blocks_inner[i]->GetDouble("Radius","mm"); - double Z= blocks_inner[i]->GetDouble("Z","mm"); - double Phi = blocks_inner[i]->GetDouble("Phi","deg"); - double Shift = blocks_inner[i]->GetDouble("Shift","mm"); - G4ThreeVector Ref = NPS::ConvertVector(blocks_inner[i]->GetTVector3("Ref","mm")); - AddInnerDetector(R,Z,Phi,Shift,Ref); + vector<NPL::InputBlock*> blocks_inner = parser.GetAllBlocksWithTokenAndValue("Strasse", "Inner"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks_inner.size() << " inner detectors found " << endl; + + vector<string> coord = {"Radius", "Z", "Phi", "Shift", "Ref"}; + + for (unsigned int i = 0; i < blocks_inner.size(); i++) { + if (blocks_inner[i]->HasTokenList(coord)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Strasse inner detector" << i + 1 << endl; + + double R = blocks_inner[i]->GetDouble("Radius", "mm"); + double Z = blocks_inner[i]->GetDouble("Z", "mm"); + double Phi = blocks_inner[i]->GetDouble("Phi", "deg"); + double Shift = blocks_inner[i]->GetDouble("Shift", "mm"); + G4ThreeVector Ref = NPS::ConvertVector(blocks_inner[i]->GetTVector3("Ref", "mm")); + AddInnerDetector(R, Z, Phi, Shift, Ref); } - else{ - cout << "ERROR: check your input file formatting on " << i+1 << " inner block " <<endl; + else { + cout << "ERROR: check your input file formatting on " << i + 1 << " inner block " << endl; exit(1); } } // Outer barrel - vector<NPL::InputBlock*> blocks_outer = parser.GetAllBlocksWithTokenAndValue("Strasse","Outer"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks_outer.size() << " outer detectors found " << endl; - - for(unsigned int i = 0 ; i < blocks_outer.size() ; i++){ - if(blocks_outer[i]->HasTokenList(coord)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Strasse outer detector" << i+1 << endl; - - double R = blocks_outer[i]->GetDouble("Radius","mm"); - double Z= blocks_outer[i]->GetDouble("Z","mm"); - double Phi = blocks_outer[i]->GetDouble("Phi","deg"); - double Shift = blocks_outer[i]->GetDouble("Shift","mm"); - G4ThreeVector Ref = NPS::ConvertVector(blocks_inner[i]->GetTVector3("Ref","mm")); - AddOuterDetector(R,Z,Phi,Shift,Ref); + vector<NPL::InputBlock*> blocks_outer = parser.GetAllBlocksWithTokenAndValue("Strasse", "Outer"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks_outer.size() << " outer detectors found " << endl; + + for (unsigned int i = 0; i < blocks_outer.size(); i++) { + if (blocks_outer[i]->HasTokenList(coord)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Strasse outer detector" << i + 1 << endl; + + double R = blocks_outer[i]->GetDouble("Radius", "mm"); + double Z = blocks_outer[i]->GetDouble("Z", "mm"); + double Phi = blocks_outer[i]->GetDouble("Phi", "deg"); + double Shift = blocks_outer[i]->GetDouble("Shift", "mm"); + G4ThreeVector Ref = NPS::ConvertVector(blocks_inner[i]->GetTVector3("Ref", "mm")); + AddOuterDetector(R, Z, Phi, Shift, Ref); } - else{ + else { - cout << "ERROR: check your input file formatting on " << i+1 << " outer block " <<endl; + cout << "ERROR: check your input file formatting on " << i + 1 << " outer block " << endl; exit(1); } } // Chamber vector<std::string> token = {"Z"}; - vector<NPL::InputBlock*> blocks_chamber = parser.GetAllBlocksWithTokenAndValue("Strasse","Chamber"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks_chamber.size() << " chamber detectors found " << endl; + vector<NPL::InputBlock*> blocks_chamber = parser.GetAllBlocksWithTokenAndValue("Strasse", "Chamber"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks_chamber.size() << " chamber detectors found " << endl; - for(unsigned int i = 0 ; i < blocks_chamber.size() ; i++){ - if(blocks_chamber[i]->HasTokenList(token)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Strasse chamber detector" << i+1 << endl; + for (unsigned int i = 0; i < blocks_chamber.size(); i++) { + if (blocks_chamber[i]->HasTokenList(token)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Strasse chamber detector" << i + 1 << endl; - double Z= blocks_chamber[i]->GetDouble("Z","mm"); + double Z = blocks_chamber[i]->GetDouble("Z", "mm"); AddChamber(Z); } - else{ + else { - cout << "ERROR: check your input file formatting on " << i+1 << " chamber block " <<endl; + cout << "ERROR: check your input file formatting on " << i + 1 << " chamber block " << endl; exit(1); } } - // Inactive material inside chamber imported form CAD drawings - vector<NPL::InputBlock*> blocks_material = parser.GetAllBlocksWithTokenAndValue("Strasse","InactiveMaterial"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks_material.size() << " inactive material found " << endl; - - for(unsigned int i = 0 ; i < blocks_material.size() ; i++){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Strasse Inactive material from CAD " << i+1 << endl; - - if(blocks_material[i]->HasToken("Chamber")){ - ChamberPath= blocks_material[i]->GetString("Chamber"); - found_chamber = true; - } - if(blocks_material[i]->HasToken("Stars")){ - StarsPath= blocks_material[i]->GetString("Stars"); - found_stars = true; - } - if(blocks_material[i]->HasToken("Blades")){ - BladesPath= blocks_material[i]->GetString("Blades"); - found_blades = true; - } - if(blocks_material[i]->HasToken("Base")){ - BasePath= blocks_material[i]->GetString("Base"); - found_base = true; - } + vector<NPL::InputBlock*> blocks_material = parser.GetAllBlocksWithTokenAndValue("Strasse", "InactiveMaterial"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks_material.size() << " inactive material found " << endl; + + for (unsigned int i = 0; i < blocks_material.size(); i++) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Strasse Inactive material from CAD " << i + 1 << endl; + + if (blocks_material[i]->HasToken("Chamber")) { + ChamberPath = blocks_material[i]->GetString("Chamber"); + found_chamber = true; + } + if (blocks_material[i]->HasToken("Stars")) { + StarsPath = blocks_material[i]->GetString("Stars"); + found_stars = true; + } + if (blocks_material[i]->HasToken("Blades")) { + BladesPath = blocks_material[i]->GetString("Blades"); + found_blades = true; + } + if (blocks_material[i]->HasToken("Base")) { + BasePath = blocks_material[i]->GetString("Base"); + found_base = true; + } } } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void Strasse::ConstructDetector(G4LogicalVolume* world){ +void Strasse::ConstructDetector(G4LogicalVolume* world) { // Inner Barrel - for (unsigned short i = 0 ; i < m_Inner_R.size() ; i++) { - G4ThreeVector Det_pos = G4ThreeVector(m_Inner_Shift[i],m_Inner_R[i]+0.5*Inner_PCB_Thickness+0.001,m_Inner_Z[i]) ; //0.001 offset just to avoid overlap with frame - Det_pos.rotate(-m_Inner_Phi[i],G4ThreeVector(0,0,1)); - G4RotationMatrix* Rot = new G4RotationMatrix(0*deg,0*deg,m_Inner_Phi[i]); - - new G4PVPlacement(G4Transform3D(*Rot,Det_pos+m_Inner_Ref[i]), - BuildInnerDetector(), - "Strasse",world,false,i+1); + for (unsigned short i = 0; i < m_Inner_R.size(); i++) { + G4ThreeVector Det_pos = G4ThreeVector(m_Inner_Shift[i], m_Inner_R[i] + 0.5 * Inner_PCB_Thickness + 0.001, + m_Inner_Z[i]); // 0.001 offset just to avoid overlap with frame + Det_pos.rotate(-m_Inner_Phi[i], G4ThreeVector(0, 0, 1)); + G4RotationMatrix* Rot = new G4RotationMatrix(0 * deg, 0 * deg, m_Inner_Phi[i]); + + new G4PVPlacement(G4Transform3D(*Rot, Det_pos + m_Inner_Ref[i]), BuildInnerDetector(), "Strasse", world, false, + i + 1); + } + + // Outer Barrel + for (unsigned short i = 0; i < m_Outer_R.size(); i++) { + G4ThreeVector Det_pos = G4ThreeVector(m_Outer_Shift[i], m_Outer_R[i] + 0.5 * Inner_PCB_Thickness + 0.001, + m_Outer_Z[i]); // 0.001 offset just to avoid overlap with frame + Det_pos.rotate(-m_Outer_Phi[i], G4ThreeVector(0, 0, 1)); + G4RotationMatrix* Rot = new G4RotationMatrix(0 * deg, 0 * deg, m_Outer_Phi[i]); + + new G4PVPlacement(G4Transform3D(*Rot, Det_pos + m_Outer_Ref[i]), BuildOuterDetector(), "Strasse", world, false, + i + 1); } - // Outer Barrel - for (unsigned short i = 0 ; i < m_Outer_R.size() ; i++) { - G4ThreeVector Det_pos = G4ThreeVector(m_Outer_Shift[i],m_Outer_R[i]+0.5*Inner_PCB_Thickness+0.001,m_Outer_Z[i]) ;//0.001 offset just to avoid overlap with frame - Det_pos.rotate(-m_Outer_Phi[i],G4ThreeVector(0,0,1)); - G4RotationMatrix* Rot = new G4RotationMatrix(0*deg,0*deg,m_Outer_Phi[i]); + // Chamber + + for (unsigned short i = 0; i < m_Chamber_Z.size(); i++) { + G4ThreeVector Det_pos = G4ThreeVector(0, 0, -m_Chamber_Z[i]); + G4RotationMatrix* Rot = new G4RotationMatrix(); - new G4PVPlacement(G4Transform3D(*Rot,Det_pos+m_Outer_Ref[i]), - BuildOuterDetector(), - "Strasse",world,false,i+1); + new G4PVPlacement(G4Transform3D(*Rot, Det_pos), BuildChamber(), "Strasse", world, false, i + 1); } - // Chamber - - for (unsigned short i = 0 ; i < m_Chamber_Z.size() ; i++) { - G4ThreeVector Det_pos = G4ThreeVector(0,0,-m_Chamber_Z[i]) ; - G4RotationMatrix* Rot = new G4RotationMatrix(); + // G4ThreeVector Det_pos = G4ThreeVector(0,0,+11.5) ; + G4ThreeVector Det_pos = G4ThreeVector(0, 0, 0); + G4RotationMatrix* Rot = new G4RotationMatrix(); + Rot->rotateY(270. * deg); + Rot->rotateX(0. * deg); - new G4PVPlacement(G4Transform3D(*Rot,Det_pos), - BuildChamber(), - "Strasse",world,false,i+1); + if (found_chamber) { + new G4PVPlacement(Rot, Det_pos, BuildChamberFromCAD(ChamberPath), "Strasse_Chamber", world, false, 0); } - - - - //G4ThreeVector Det_pos = G4ThreeVector(0,0,+11.5) ; - G4ThreeVector Det_pos = G4ThreeVector(0,0,0) ; - G4RotationMatrix* Rot = new G4RotationMatrix(); - Rot->rotateY(270.*deg); - Rot->rotateX(0.*deg); - - if(found_chamber){ - new G4PVPlacement(Rot, Det_pos, BuildChamberFromCAD(ChamberPath), - "Strasse_Chamber",world, false, 0); - } - - if(found_blades){ - new G4PVPlacement(Rot, Det_pos, BuildBlades(BladesPath), - "Strasse_Blades",world, false, 0); - } - if(found_stars){ - G4ThreeVector Det_pos2 = G4ThreeVector(0,0,0) ; - new G4PVPlacement(Rot, Det_pos2, BuildStars(StarsPath), - "Strasse_Stars",world, false, 0); - } - if(found_base){ - G4ThreeVector Det_pos3 = G4ThreeVector(0,0,0) ; - new G4PVPlacement(Rot, Det_pos3, BuildBase(BasePath), - "Strasse_Base",world, false, 0); - } + if (found_blades) { + new G4PVPlacement(Rot, Det_pos, BuildBlades(BladesPath), "Strasse_Blades", world, false, 0); + } + if (found_stars) { + G4ThreeVector Det_pos2 = G4ThreeVector(0, 0, 0); + new G4PVPlacement(Rot, Det_pos2, BuildStars(StarsPath), "Strasse_Stars", world, false, 0); + } + if (found_base) { + G4ThreeVector Det_pos3 = G4ThreeVector(0, 0, 0); + new G4PVPlacement(Rot, Det_pos3, BuildBase(BasePath), "Strasse_Base", world, false, 0); + } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void Strasse::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("Strasse")){ - pTree->Branch("Strasse", "TStrasseData", &m_Event) ; +void Strasse::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("Strasse")) { + pTree->Branch("Strasse", "TStrasseData", &m_Event); } - pTree->SetBranchAddress("Strasse", &m_Event) ; + pTree->SetBranchAddress("Strasse", &m_Event); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Strasse::ReadSensitive(const G4Event* ){ +void Strasse::ReadSensitive(const G4Event*) { m_Event->Clear(); /////////// // Inner barrel scorer - DSSDScorers::PS_Rectangle* InnerScorer1= (DSSDScorers::PS_Rectangle*) m_InnerScorer1->GetPrimitive(0); + DSSDScorers::PS_Rectangle* InnerScorer1 = (DSSDScorers::PS_Rectangle*)m_InnerScorer1->GetPrimitive(0); - unsigned int size = InnerScorer1->GetWidthMult(); - for(unsigned int i = 0 ; i < size; i++){ - double Energy = RandGauss::shoot(InnerScorer1->GetEnergyWidth(i), ResoEnergy); - if(Energy>EnergyThreshold){ - int DetNbr = InnerScorer1->GetDetectorWidth(i); + unsigned int size = InnerScorer1->GetWidthMult(); + for (unsigned int i = 0; i < size; i++) { + double Energy = RandGauss::shoot(InnerScorer1->GetEnergyWidth(i), ResoEnergy); + if (Energy > EnergyThreshold) { + int DetNbr = InnerScorer1->GetDetectorWidth(i); int StripTransverse = InnerScorer1->GetStripWidth(i); m_Event->SetInnerTE(DetNbr, StripTransverse, Energy); } } - size = InnerScorer1->GetLengthMult(); - for(unsigned int i = 0 ; i < size ; i++){ - double Energy = RandGauss::shoot(InnerScorer1->GetEnergyLength(i), ResoEnergy); - if(Energy>EnergyThreshold){ - int DetNbr = InnerScorer1->GetDetectorLength(i); - int StripLongitudinal= InnerScorer1->GetStripLength(i); + size = InnerScorer1->GetLengthMult(); + for (unsigned int i = 0; i < size; i++) { + double Energy = RandGauss::shoot(InnerScorer1->GetEnergyLength(i), ResoEnergy); + if (Energy > EnergyThreshold) { + int DetNbr = InnerScorer1->GetDetectorLength(i); + int StripLongitudinal = InnerScorer1->GetStripLength(i); m_Event->SetInnerLE(DetNbr, StripLongitudinal, Energy); } } InnerScorer1->clear(); // second silicon - DSSDScorers::PS_Rectangle* InnerScorer2= (DSSDScorers::PS_Rectangle*) m_InnerScorer2->GetPrimitive(0); - - size = InnerScorer2->GetWidthMult(); - for(unsigned int i = 0 ; i < size; i++){ - double Energy = RandGauss::shoot(InnerScorer2->GetEnergyWidth(i), ResoEnergy); - if(Energy>EnergyThreshold){ - int DetNbr = InnerScorer2->GetDetectorWidth(i); - int StripTransverse = InnerScorer2->GetStripWidth(i)+Inner_Wafer_TransverseStrips; + DSSDScorers::PS_Rectangle* InnerScorer2 = (DSSDScorers::PS_Rectangle*)m_InnerScorer2->GetPrimitive(0); + + size = InnerScorer2->GetWidthMult(); + for (unsigned int i = 0; i < size; i++) { + double Energy = RandGauss::shoot(InnerScorer2->GetEnergyWidth(i), ResoEnergy); + if (Energy > EnergyThreshold) { + int DetNbr = InnerScorer2->GetDetectorWidth(i); + int StripTransverse = InnerScorer2->GetStripWidth(i) + Inner_Wafer_TransverseStrips; m_Event->SetInnerTE(DetNbr, StripTransverse, Energy); } } - size = InnerScorer2->GetLengthMult(); - for(unsigned int i = 0 ; i < size ; i++){ - double Energy = RandGauss::shoot(InnerScorer2->GetEnergyLength(i), ResoEnergy); - if(Energy>EnergyThreshold){ - int DetNbr = InnerScorer2->GetDetectorLength(i); - int StripLongitudinal= InnerScorer2->GetStripLength(i); + size = InnerScorer2->GetLengthMult(); + for (unsigned int i = 0; i < size; i++) { + double Energy = RandGauss::shoot(InnerScorer2->GetEnergyLength(i), ResoEnergy); + if (Energy > EnergyThreshold) { + int DetNbr = InnerScorer2->GetDetectorLength(i); + int StripLongitudinal = InnerScorer2->GetStripLength(i); m_Event->SetInnerLE(DetNbr, StripLongitudinal, Energy); } } InnerScorer2->clear(); - - /////////// // Outer barrel scorer - DSSDScorers::PS_Rectangle* OuterScorer1= (DSSDScorers::PS_Rectangle*) m_OuterScorer1->GetPrimitive(0); + DSSDScorers::PS_Rectangle* OuterScorer1 = (DSSDScorers::PS_Rectangle*)m_OuterScorer1->GetPrimitive(0); - size = OuterScorer1->GetWidthMult(); - for(unsigned int i = 0 ; i < size; i++){ - double Energy = RandGauss::shoot(OuterScorer1->GetEnergyWidth(i), ResoEnergy); - if(Energy>EnergyThreshold){ - int DetNbr = OuterScorer1->GetDetectorWidth(i); + size = OuterScorer1->GetWidthMult(); + for (unsigned int i = 0; i < size; i++) { + double Energy = RandGauss::shoot(OuterScorer1->GetEnergyWidth(i), ResoEnergy); + if (Energy > EnergyThreshold) { + int DetNbr = OuterScorer1->GetDetectorWidth(i); int StripTransverse = OuterScorer1->GetStripWidth(i); m_Event->SetOuterTE(DetNbr, StripTransverse, Energy); } } - size = OuterScorer1->GetLengthMult(); - for(unsigned int i = 0 ; i < size ; i++){ - double Energy = RandGauss::shoot(OuterScorer1->GetEnergyLength(i), ResoEnergy); - if(Energy>EnergyThreshold){ - int DetNbr = OuterScorer1->GetDetectorLength(i); - int StripLongitudinal= OuterScorer1->GetStripLength(i); + size = OuterScorer1->GetLengthMult(); + for (unsigned int i = 0; i < size; i++) { + double Energy = RandGauss::shoot(OuterScorer1->GetEnergyLength(i), ResoEnergy); + if (Energy > EnergyThreshold) { + int DetNbr = OuterScorer1->GetDetectorLength(i); + int StripLongitudinal = OuterScorer1->GetStripLength(i); m_Event->SetOuterLE(DetNbr, StripLongitudinal, Energy); } } OuterScorer1->clear(); // Second silicon - DSSDScorers::PS_Rectangle* OuterScorer2= (DSSDScorers::PS_Rectangle*) m_OuterScorer2->GetPrimitive(0); - - size = OuterScorer2->GetWidthMult(); - for(unsigned int i = 0 ; i < size; i++){ - double Energy = RandGauss::shoot(OuterScorer2->GetEnergyWidth(i), ResoEnergy); - if(Energy>EnergyThreshold){ - int DetNbr = OuterScorer2->GetDetectorWidth(i); - int StripTransverse = OuterScorer2->GetStripWidth(i)+Outer_Wafer_TransverseStrips; + DSSDScorers::PS_Rectangle* OuterScorer2 = (DSSDScorers::PS_Rectangle*)m_OuterScorer2->GetPrimitive(0); + + size = OuterScorer2->GetWidthMult(); + for (unsigned int i = 0; i < size; i++) { + double Energy = RandGauss::shoot(OuterScorer2->GetEnergyWidth(i), ResoEnergy); + if (Energy > EnergyThreshold) { + int DetNbr = OuterScorer2->GetDetectorWidth(i); + int StripTransverse = OuterScorer2->GetStripWidth(i) + Outer_Wafer_TransverseStrips; m_Event->SetOuterTE(DetNbr, StripTransverse, Energy); } } - size = OuterScorer2->GetLengthMult(); - for(unsigned int i = 0 ; i < size ; i++){ - double Energy = RandGauss::shoot(OuterScorer2->GetEnergyLength(i), ResoEnergy); - if(Energy>EnergyThreshold){ - int DetNbr = OuterScorer2->GetDetectorLength(i); - int StripLongitudinal= OuterScorer2->GetStripLength(i); + size = OuterScorer2->GetLengthMult(); + for (unsigned int i = 0; i < size; i++) { + double Energy = RandGauss::shoot(OuterScorer2->GetEnergyLength(i), ResoEnergy); + if (Energy > EnergyThreshold) { + int DetNbr = OuterScorer2->GetDetectorLength(i); + int StripLongitudinal = OuterScorer2->GetStripLength(i); m_Event->SetOuterLE(DetNbr, StripLongitudinal, Energy); } } OuterScorer2->clear(); - - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -//////////////////////////////////////////////////////////////// -void Strasse::InitializeScorers() { +//////////////////////////////////////////////////////////////// +void Strasse::InitializeScorers() { // This check is necessary in case the geometry is reloaded - bool already_exist = false; - m_InnerScorer1 = CheckScorer("InnerScorer1",already_exist) ; - m_OuterScorer1 = CheckScorer("OuterScorer1",already_exist) ; - m_InnerScorer2 = CheckScorer("InnerScorer2",already_exist) ; - m_OuterScorer2 = CheckScorer("OuterScorer2",already_exist) ; + bool already_exist = false; + m_InnerScorer1 = CheckScorer("InnerScorer1", already_exist); + m_OuterScorer1 = CheckScorer("OuterScorer1", already_exist); + m_InnerScorer2 = CheckScorer("InnerScorer2", already_exist); + m_OuterScorer2 = CheckScorer("OuterScorer2", already_exist); - if(already_exist) - return ; + if (already_exist) + return; // Otherwise the scorer is initialised - m_Active_InnerWafer_Width= Inner_Wafer_Width-2.*Inner_Wafer_GuardRing; - m_Active_InnerWafer_Length= - Inner_Wafer_Length-Inner_Wafer_PADExternal-Inner_Wafer_PADInternal-2*Inner_Wafer_GuardRing; - - - G4VPrimitiveScorer* InnerScorer1 = new DSSDScorers::PS_Rectangle("InnerScorer1",2, - m_Active_InnerWafer_Width, - m_Active_InnerWafer_Length, - Inner_Wafer_LongitudinalStrips, - Inner_Wafer_TransverseStrips,0,"xz"); - - G4VPrimitiveScorer* InnerScorer2 = new DSSDScorers::PS_Rectangle("InnerScorer2",2, - m_Active_InnerWafer_Width, - m_Active_InnerWafer_Length, - Inner_Wafer_LongitudinalStrips, - Inner_Wafer_TransverseStrips,0,"xz"); - - - m_Active_OuterWafer_Width=Outer_Wafer_Width-2.*Outer_Wafer_GuardRing; - m_Active_OuterWafer_Length= - Outer_Wafer_Length-Outer_Wafer_PADExternal-Outer_Wafer_PADInternal-2*Outer_Wafer_GuardRing; - - - G4VPrimitiveScorer* OuterScorer1 = new DSSDScorers::PS_Rectangle("OuterScorer1",2, - m_Active_OuterWafer_Width, - m_Active_OuterWafer_Length, - Outer_Wafer_LongitudinalStrips, - Outer_Wafer_TransverseStrips,0,"xz"); - - G4VPrimitiveScorer* OuterScorer2 = new DSSDScorers::PS_Rectangle("OuterScorer2",2, - m_Active_OuterWafer_Width, - m_Active_OuterWafer_Length, - Outer_Wafer_LongitudinalStrips, - Outer_Wafer_TransverseStrips,0,"xz"); - - - - G4VPrimitiveScorer* InteractionInner1 = new InteractionScorers::PS_Interactions("InteractionInner1",ms_InterCoord,0); - G4VPrimitiveScorer* InteractionOuter1 = new InteractionScorers::PS_Interactions("InteractionOuter1",ms_InterCoord,0); - G4VPrimitiveScorer* InteractionInner2 = new InteractionScorers::PS_Interactions("InteractionInner2",ms_InterCoord,0); - G4VPrimitiveScorer* InteractionOuter2 = new InteractionScorers::PS_Interactions("InteractionOuter2",ms_InterCoord,0); - + m_Active_InnerWafer_Width = Inner_Wafer_Width - 2. * Inner_Wafer_GuardRing; + m_Active_InnerWafer_Length = + Inner_Wafer_Length - Inner_Wafer_PADExternal - Inner_Wafer_PADInternal - 2 * Inner_Wafer_GuardRing; + + G4VPrimitiveScorer* InnerScorer1 = + new DSSDScorers::PS_Rectangle("InnerScorer1", 2, m_Active_InnerWafer_Width, m_Active_InnerWafer_Length, + Inner_Wafer_LongitudinalStrips, Inner_Wafer_TransverseStrips, 0, "xz"); + + G4VPrimitiveScorer* InnerScorer2 = + new DSSDScorers::PS_Rectangle("InnerScorer2", 2, m_Active_InnerWafer_Width, m_Active_InnerWafer_Length, + Inner_Wafer_LongitudinalStrips, Inner_Wafer_TransverseStrips, 0, "xz"); + + m_Active_OuterWafer_Width = Outer_Wafer_Width - 2. * Outer_Wafer_GuardRing; + m_Active_OuterWafer_Length = + Outer_Wafer_Length - Outer_Wafer_PADExternal - Outer_Wafer_PADInternal - 2 * Outer_Wafer_GuardRing; + + G4VPrimitiveScorer* OuterScorer1 = + new DSSDScorers::PS_Rectangle("OuterScorer1", 2, m_Active_OuterWafer_Width, m_Active_OuterWafer_Length, + Outer_Wafer_LongitudinalStrips, Outer_Wafer_TransverseStrips, 0, "xz"); + + G4VPrimitiveScorer* OuterScorer2 = + new DSSDScorers::PS_Rectangle("OuterScorer2", 2, m_Active_OuterWafer_Width, m_Active_OuterWafer_Length, + Outer_Wafer_LongitudinalStrips, Outer_Wafer_TransverseStrips, 0, "xz"); + + G4VPrimitiveScorer* InteractionInner1 = + new InteractionScorers::PS_Interactions("InteractionInner1", ms_InterCoord, 0); + G4VPrimitiveScorer* InteractionOuter1 = + new InteractionScorers::PS_Interactions("InteractionOuter1", ms_InterCoord, 0); + G4VPrimitiveScorer* InteractionInner2 = + new InteractionScorers::PS_Interactions("InteractionInner2", ms_InterCoord, 0); + G4VPrimitiveScorer* InteractionOuter2 = + new InteractionScorers::PS_Interactions("InteractionOuter2", ms_InterCoord, 0); // Register it to the multifunctionnal detector m_InnerScorer1->RegisterPrimitive(InnerScorer1); @@ -1248,13 +1117,10 @@ void Strasse::InitializeScorers() { m_OuterScorer2->RegisterPrimitive(OuterScorer2); m_OuterScorer2->RegisterPrimitive(InteractionOuter2); - G4SDManager::GetSDMpointer()->AddNewDetector(m_InnerScorer1); G4SDManager::GetSDMpointer()->AddNewDetector(m_OuterScorer1); G4SDManager::GetSDMpointer()->AddNewDetector(m_InnerScorer2); G4SDManager::GetSDMpointer()->AddNewDetector(m_OuterScorer2); - - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -1263,12 +1129,10 @@ void Strasse::InitializeScorers() { //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* Strasse::Construct(){ - return (NPS::VDetector*) new Strasse(); -} +NPS::VDetector* Strasse::Construct() { return (NPS::VDetector*)new Strasse(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Strasse::InitializeMaterial(){ +void Strasse::InitializeMaterial() { m_MaterialSilicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); m_MaterialAl = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); m_MaterialPCB = MaterialManager::getInstance()->GetMaterialFromLibrary("PCB"); @@ -1280,14 +1144,14 @@ void Strasse::InitializeMaterial(){ //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_Strasse{ - public: - proxy_nps_Strasse(){ - NPS::DetectorFactory::getInstance()->AddToken("Strasse","Strasse"); - NPS::DetectorFactory::getInstance()->AddDetector("Strasse",Strasse::Construct); - } - }; - - proxy_nps_Strasse p_nps_Strasse; +extern "C" { +class proxy_nps_Strasse { + public: + proxy_nps_Strasse() { + NPS::DetectorFactory::getInstance()->AddToken("Strasse", "Strasse"); + NPS::DetectorFactory::getInstance()->AddDetector("Strasse", Strasse::Construct); + } +}; + +proxy_nps_Strasse p_nps_Strasse; } diff --git a/NPSimulation/Detectors/SuperX3/SuperX3.cc b/NPSimulation/Detectors/SuperX3/SuperX3.cc index 1438ae98d..2be046a12 100644 --- a/NPSimulation/Detectors/SuperX3/SuperX3.cc +++ b/NPSimulation/Detectors/SuperX3/SuperX3.cc @@ -116,7 +116,7 @@ void SuperX3::VolumeMaker(G4int DetecNumber, G4ThreeVector position, G4RotationM new G4PVPlacement(G4Transform3D(*rotation, position), logicSuperX3, Name, world, false, DetecNumber); - logicSuperX3->SetVisAttributes(G4VisAttributes::Invisible); + logicSuperX3->SetVisAttributes(G4VisAttributes::GetInvisible()); if (m_non_sensitive_part_visiualisation) logicSuperX3->SetVisAttributes(G4VisAttributes(G4Colour(0.90, 0.90, 0.90))); diff --git a/NPSimulation/Detectors/Tiara/Tiara.cc b/NPSimulation/Detectors/Tiara/Tiara.cc index 70a986d7c..c5a0aee92 100644 --- a/NPSimulation/Detectors/Tiara/Tiara.cc +++ b/NPSimulation/Detectors/Tiara/Tiara.cc @@ -20,33 +20,32 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> -//G4 Geometry object +#include <sstream> +// G4 Geometry object #include "G4Box.hh" -#include "G4Tubs.hh" #include "G4Cons.hh" -#include "G4UnionSolid.hh" #include "G4ExtrudedSolid.hh" +#include "G4Tubs.hh" #include "G4TwoVector.hh" -//G4 sensitive +#include "G4UnionSolid.hh" +// G4 sensitive #include "G4SDManager.hh" -//G4 various object -#include "G4Material.hh" -#include "G4Transform3D.hh" -#include "G4PVPlacement.hh" +// G4 various object #include "G4Colour.hh" +#include "G4Material.hh" #include "G4PVDivision.hh" +#include "G4PVPlacement.hh" #include "G4SubtractionSolid.hh" +#include "G4Transform3D.hh" // NPS -#include "Tiara.hh" -#include "NPSDetectorFactory.hh" #include "MaterialManager.hh" #include "NPSDetectorFactory.hh" #include "SiliconScorers.hh" +#include "Tiara.hh" // NPL #include "NPOptionManager.h" @@ -60,85 +59,83 @@ using namespace std; using namespace CLHEP; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Tiara::Tiara(){ +Tiara::Tiara() { InitializeMaterial(); m_EventBarrel = new TTiaraBarrelData(); m_EventHyball = new TTiaraHyballData(); // Dark Grey - SiliconVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)) ; + SiliconVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)); // Green - PCBVisAtt = new G4VisAttributes(G4Colour(0.2, 0.5, 0.2)) ; + PCBVisAtt = new G4VisAttributes(G4Colour(0.2, 0.5, 0.2)); // Gold Yellow - PADVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.2)) ; + PADVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.2)); // Light Grey - FrameVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)) ; + FrameVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)); // Light Blue - GuardRingVisAtt = new G4VisAttributes(G4Colour(0.1, 0.1, 0.1)) ; + GuardRingVisAtt = new G4VisAttributes(G4Colour(0.1, 0.1, 0.1)); m_boolChamber = false; m_boolInner = false; m_boolOuter = false; - m_InnerBarrelScorer = 0 ; - m_OuterBarrelScorer = 0 ; - m_HyballScorer = 0 ; - + m_InnerBarrelScorer = 0; + m_OuterBarrelScorer = 0; + m_HyballScorer = 0; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Tiara::~Tiara(){ -} +Tiara::~Tiara() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Tiara::ReadConfiguration(NPL::InputParser parser){ - vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithTokenAndValue("Tiara","Barrel"); +void Tiara::ReadConfiguration(NPL::InputParser parser) { + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithTokenAndValue("Tiara", "Barrel"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) + if (NPOptionManager::getInstance()->GetVerboseLevel()) cout << "//// " << blocks.size() << " detectors found " << endl; - vector<string> token = {"InnerBarrel","OuterBarrel","Chamber"}; + vector<string> token = {"InnerBarrel", "OuterBarrel", "Chamber"}; - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(token)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Barrel " << i+1 << endl; - m_boolInner = blocks[i]->GetInt("InnerBarrel"); - m_boolOuter = blocks[i]->GetInt("OuterBarrel"); + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(token)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Barrel " << i + 1 << endl; + m_boolInner = blocks[i]->GetInt("InnerBarrel"); + m_boolOuter = blocks[i]->GetInt("OuterBarrel"); m_boolChamber = blocks[i]->GetInt("Chamber"); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } } blocks.clear(); -//by Shuya 180426 - // blocks = parser.GetAllBlocksWithToken("TiaraHyballWedge"); - blocks = parser.GetAllBlocksWithTokenAndValue("Tiara","Hyball"); + // by Shuya 180426 + // blocks = parser.GetAllBlocksWithToken("TiaraHyballWedge"); + blocks = parser.GetAllBlocksWithTokenAndValue("Tiara", "Hyball"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) + if (NPOptionManager::getInstance()->GetVerboseLevel()) cout << "//// " << blocks.size() << " detectors found " << endl; token.clear(); - token = {"Z","R","Phi"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(token)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Hyball Wedge" << i+1 << endl; - double Z = blocks[i]->GetDouble("Z","mm"); - double R = blocks[i]->GetDouble("R","mm"); - double Phi = blocks[i]->GetDouble("Phi","deg"); + token = {"Z", "R", "Phi"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(token)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Hyball Wedge" << i + 1 << endl; + double Z = blocks[i]->GetDouble("Z", "mm"); + double R = blocks[i]->GetDouble("R", "mm"); + double Phi = blocks[i]->GetDouble("Phi", "deg"); m_HyballZ.push_back(Z); m_HyballR.push_back(R); m_HyballPhi.push_back(Phi); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } @@ -148,23 +145,23 @@ void Tiara::ReadConfiguration(NPL::InputParser parser){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void Tiara::ConstructDetector(G4LogicalVolume* world){ +void Tiara::ConstructDetector(G4LogicalVolume* world) { - if(m_boolChamber) + if (m_boolChamber) ConstructChamber(world); - if(m_boolInner) + if (m_boolInner) ConstructInnerBarrel(world); - if(m_boolOuter) + if (m_boolOuter) ConstructOuterBarrel(world); - if(m_HyballZ.size()) + if (m_HyballZ.size()) ConstructHyball(world); } // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Tiara::ReadSensitive(const G4Event* event){ +void Tiara::ReadSensitive(const G4Event* event) { m_EventBarrel->Clear(); m_EventHyball->Clear(); @@ -175,42 +172,44 @@ void Tiara::ReadSensitive(const G4Event* event){ InnerBarrelHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(InnerBarrelCollectionID)); // Loop on the InnerBarrel map - for (InnerBarrel_itr = InnerBarrelHitMap->GetMap()->begin() ; InnerBarrel_itr != InnerBarrelHitMap->GetMap()->end() ; InnerBarrel_itr++){ + for (InnerBarrel_itr = InnerBarrelHitMap->GetMap()->begin(); InnerBarrel_itr != InnerBarrelHitMap->GetMap()->end(); + InnerBarrel_itr++) { G4double* Info = *(InnerBarrel_itr->second); // Downstream Energy - //by Shuya 180504. Note I changed this unit from MeV to keV because Barrel data are given in keV in real data. - //double ED = RandGauss::shoot(Info[0],ResoEnergyInnerBarrel); - double ED = RandGauss::shoot(Info[0]/keV,ResoEnergyInnerBarrel); - if(ED>EnergyThreshold){ - m_EventBarrel->SetFrontDownstreamE(Info[3],Info[4],ED); - m_EventBarrel->SetFrontDownstreamT(Info[3],Info[4],Info[2]); + // by Shuya 180504. Note I changed this unit from MeV to keV because Barrel data are given in keV in real data. + // double ED = RandGauss::shoot(Info[0],ResoEnergyInnerBarrel); + double ED = RandGauss::shoot(Info[0] / keV, ResoEnergyInnerBarrel); + if (ED > EnergyThreshold) { + m_EventBarrel->SetFrontDownstreamE(Info[3], Info[4], ED); + m_EventBarrel->SetFrontDownstreamT(Info[3], Info[4], Info[2]); } // Upstream Energy - //by Shuya 180504. Note I changed this unit from MeV to keV because Barrel data are given in keV in real data. - //double EU = RandGauss::shoot(Info[1],ResoEnergyInnerBarrel); - double EU = RandGauss::shoot(Info[1]/keV,ResoEnergyInnerBarrel); - if(EU>EnergyThreshold){ - m_EventBarrel->SetFrontUpstreamE(Info[3],Info[4],EU); - m_EventBarrel->SetFrontUpstreamT(Info[3],Info[4],Info[2]); - //cout << "BARREL " << Info[3] << " STRIP " << Info[4] << " " << Info[9]/deg << " " << Info[5] << " " << Info[6] << " " << Info[7] << endl; + // by Shuya 180504. Note I changed this unit from MeV to keV because Barrel data are given in keV in real data. + // double EU = RandGauss::shoot(Info[1],ResoEnergyInnerBarrel); + double EU = RandGauss::shoot(Info[1] / keV, ResoEnergyInnerBarrel); + if (EU > EnergyThreshold) { + m_EventBarrel->SetFrontUpstreamE(Info[3], Info[4], EU); + m_EventBarrel->SetFrontUpstreamT(Info[3], Info[4], Info[2]); + // cout << "BARREL " << Info[3] << " STRIP " << Info[4] << " " << Info[9]/deg << " " << Info[5] << " " << Info[6] + // << " " << Info[7] << endl; } // Back Energy - //by Shuya 180504. Note I changed this unit from MeV to keV because Barrel data are given in keV in real data. - //double EB = RandGauss::shoot(Info[1]+Info[0],ResoEnergyInnerBarrel); - double EB = RandGauss::shoot(Info[1]/keV+Info[0]*keV,ResoEnergyInnerBarrel); - if(EB>EnergyThreshold){ - m_EventBarrel->SetBackE(Info[3],EB); - m_EventBarrel->SetBackT(Info[3],Info[2]); + // by Shuya 180504. Note I changed this unit from MeV to keV because Barrel data are given in keV in real data. + // double EB = RandGauss::shoot(Info[1]+Info[0],ResoEnergyInnerBarrel); + double EB = RandGauss::shoot(Info[1] / keV + Info[0] * keV, ResoEnergyInnerBarrel); + if (EB > EnergyThreshold) { + m_EventBarrel->SetBackE(Info[3], EB); + m_EventBarrel->SetBackT(Info[3], Info[2]); } - // Interaction Coordinates - ms_InterCoord->SetDetectedPositionX(Info[5]) ; - ms_InterCoord->SetDetectedPositionY(Info[6]) ; - ms_InterCoord->SetDetectedPositionZ(Info[7]) ; - ms_InterCoord->SetDetectedAngleTheta(Info[8]/deg) ; - ms_InterCoord->SetDetectedAnglePhi(Info[9]/deg) ; + // Interaction Coordinates + ms_InterCoord->SetDetectedPositionX(Info[5]); + ms_InterCoord->SetDetectedPositionY(Info[6]); + ms_InterCoord->SetDetectedPositionZ(Info[7]); + ms_InterCoord->SetDetectedAngleTheta(Info[8] / deg); + ms_InterCoord->SetDetectedAnglePhi(Info[9] / deg); } // Clear Map for next event InnerBarrelHitMap->clear(); @@ -222,25 +221,25 @@ void Tiara::ReadSensitive(const G4Event* event){ OuterBarrelHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(OuterBarrelCollectionID)); // Loop on the OuterBarrel map - for (OuterBarrel_itr = OuterBarrelHitMap->GetMap()->begin() ; OuterBarrel_itr != OuterBarrelHitMap->GetMap()->end() ; OuterBarrel_itr++){ + for (OuterBarrel_itr = OuterBarrelHitMap->GetMap()->begin(); OuterBarrel_itr != OuterBarrelHitMap->GetMap()->end(); + OuterBarrel_itr++) { G4double* Info = *(OuterBarrel_itr->second); - double E = RandGauss::shoot(Info[0]/keV,ResoEnergyOuterBarrel); - if(E>EnergyThreshold){ - m_EventBarrel->SetOuterE(Info[7],Info[9],E); - m_EventBarrel->SetOuterT(Info[7],Info[9],Info[1]); + double E = RandGauss::shoot(Info[0] / keV, ResoEnergyOuterBarrel); + if (E > EnergyThreshold) { + m_EventBarrel->SetOuterE(Info[7], Info[9], E); + m_EventBarrel->SetOuterT(Info[7], Info[9], Info[1]); } - // Interaction Coordinates - ms_InterCoord->SetDetectedPositionX(Info[5]) ; - ms_InterCoord->SetDetectedPositionY(Info[6]) ; - ms_InterCoord->SetDetectedPositionZ(Info[7]) ; - ms_InterCoord->SetDetectedAngleTheta(Info[8]/deg) ; - ms_InterCoord->SetDetectedAnglePhi(Info[9]/deg) ; + // Interaction Coordinates + ms_InterCoord->SetDetectedPositionX(Info[5]); + ms_InterCoord->SetDetectedPositionY(Info[6]); + ms_InterCoord->SetDetectedPositionZ(Info[7]); + ms_InterCoord->SetDetectedAngleTheta(Info[8] / deg); + ms_InterCoord->SetDetectedAnglePhi(Info[9] / deg); } // Clear Map for next event OuterBarrelHitMap->clear(); - // Hyball // NPS::HitsMap<G4double*>* HyballHitMap; std::map<G4int, G4double**>::iterator Hyball_itr; @@ -248,124 +247,125 @@ void Tiara::ReadSensitive(const G4Event* event){ HyballHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(HyballCollectionID)); // Loop on the Hyball map - for (Hyball_itr = HyballHitMap->GetMap()->begin() ; Hyball_itr != HyballHitMap->GetMap()->end() ; Hyball_itr++){ + for (Hyball_itr = HyballHitMap->GetMap()->begin(); Hyball_itr != HyballHitMap->GetMap()->end(); Hyball_itr++) { G4double* Info = *(Hyball_itr->second); // Front Energy - double EF = RandGauss::shoot(Info[0],ResoEnergyHyball); - if(EF>EnergyThreshold){ - int RingNumber=Info[8]; - //by Shuya 171009 - RingNumber=abs(RingNumber); - //RingNumber=abs(RingNumber-17); - Info[8]=RingNumber; - m_EventHyball->SetRingE(Info[7],Info[8],EF); - m_EventHyball->SetRingT(Info[7],Info[8],Info[1]); + double EF = RandGauss::shoot(Info[0], ResoEnergyHyball); + if (EF > EnergyThreshold) { + int RingNumber = Info[8]; + // by Shuya 171009 + RingNumber = abs(RingNumber); + // RingNumber=abs(RingNumber-17); + Info[8] = RingNumber; + m_EventHyball->SetRingE(Info[7], Info[8], EF); + m_EventHyball->SetRingT(Info[7], Info[8], Info[1]); } // Back Energy -//by Shuya 171009. Infor[1] is Timing data... no make sense. - //double EB = RandGauss::shoot(Info[1]+Info[0],ResoEnergyHyball); - double EB = RandGauss::shoot(Info[0],ResoEnergyHyball); - if(EB>EnergyThreshold){ -//by Shuya 171012. - double m_axis = -100.0; - double m_phi = Info[6]; - if(Info[6]<0) m_phi = Info[6]+2.0*M_PI; - - if(Info[7]==1) m_axis = 210.0/180.0*M_PI; - else if(Info[7]==2) m_axis = 150.0/180.0*M_PI; - else if(Info[7]==3) m_axis = 90.0/180.0*M_PI; - else if(Info[7]==4) m_axis = 30.0/180.0*M_PI; - else if(Info[7]==5) m_axis = 330.0/180.0*M_PI; - else if(Info[7]==6) m_axis = 270.0/180.0*M_PI; - - double m_StripPitchSector_Tiara = (0.5*HYBALL_ActiveWafer_Angle-(-0.5*HYBALL_ActiveWafer_Angle))/HYBALL_NumberOfRadialStrip; - Info[9] = (int)((m_phi - (m_axis - 0.5*HYBALL_ActiveWafer_Angle)) / m_StripPitchSector_Tiara ) + 1 ; - -//by Shuya 171009 - //m_EventHyball->SetSectorE(Info[7],Info[9],EF); - m_EventHyball->SetSectorE(Info[7],Info[9],EB); - m_EventHyball->SetSectorT(Info[7],Info[9],Info[1]); + // by Shuya 171009. Infor[1] is Timing data... no make sense. + // double EB = RandGauss::shoot(Info[1]+Info[0],ResoEnergyHyball); + double EB = RandGauss::shoot(Info[0], ResoEnergyHyball); + if (EB > EnergyThreshold) { + // by Shuya 171012. + double m_axis = -100.0; + double m_phi = Info[6]; + if (Info[6] < 0) + m_phi = Info[6] + 2.0 * M_PI; + + if (Info[7] == 1) + m_axis = 210.0 / 180.0 * M_PI; + else if (Info[7] == 2) + m_axis = 150.0 / 180.0 * M_PI; + else if (Info[7] == 3) + m_axis = 90.0 / 180.0 * M_PI; + else if (Info[7] == 4) + m_axis = 30.0 / 180.0 * M_PI; + else if (Info[7] == 5) + m_axis = 330.0 / 180.0 * M_PI; + else if (Info[7] == 6) + m_axis = 270.0 / 180.0 * M_PI; + + double m_StripPitchSector_Tiara = + (0.5 * HYBALL_ActiveWafer_Angle - (-0.5 * HYBALL_ActiveWafer_Angle)) / HYBALL_NumberOfRadialStrip; + Info[9] = (int)((m_phi - (m_axis - 0.5 * HYBALL_ActiveWafer_Angle)) / m_StripPitchSector_Tiara) + 1; + + // by Shuya 171009 + // m_EventHyball->SetSectorE(Info[7],Info[9],EF); + m_EventHyball->SetSectorE(Info[7], Info[9], EB); + m_EventHyball->SetSectorT(Info[7], Info[9], Info[1]); } // Interaction Coordinates -//by Shuya 171009 -/* - ms_InterCoord->SetDetectedPositionX(Info[5]) ; - ms_InterCoord->SetDetectedPositionY(Info[6]) ; - ms_InterCoord->SetDetectedPositionZ(Info[7]) ; - ms_InterCoord->SetDetectedAngleTheta(Info[8]/deg) ; - ms_InterCoord->SetDetectedAnglePhi(Info[9]/deg) ; -*/ - ms_InterCoord->SetDetectedPositionX(Info[2]) ; - ms_InterCoord->SetDetectedPositionY(Info[3]) ; - ms_InterCoord->SetDetectedPositionZ(Info[4]) ; - ms_InterCoord->SetDetectedAngleTheta(Info[5]/deg) ; - ms_InterCoord->SetDetectedAnglePhi(Info[6]/deg) ; + // by Shuya 171009 + /* + ms_InterCoord->SetDetectedPositionX(Info[5]) ; + ms_InterCoord->SetDetectedPositionY(Info[6]) ; + ms_InterCoord->SetDetectedPositionZ(Info[7]) ; + ms_InterCoord->SetDetectedAngleTheta(Info[8]/deg) ; + ms_InterCoord->SetDetectedAnglePhi(Info[9]/deg) ; + */ + ms_InterCoord->SetDetectedPositionX(Info[2]); + ms_InterCoord->SetDetectedPositionY(Info[3]); + ms_InterCoord->SetDetectedPositionZ(Info[4]); + ms_InterCoord->SetDetectedAngleTheta(Info[5] / deg); + ms_InterCoord->SetDetectedAnglePhi(Info[6] / deg); } // Clear Map for next event HyballHitMap->clear(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Tiara::InitializeScorers(){ - //Look for previous definition of the scorer (geometry reload) +void Tiara::InitializeScorers() { + // Look for previous definition of the scorer (geometry reload) bool already_exist = false; - m_InnerBarrelScorer = CheckScorer("Tiara_InnerBarrelScorer",already_exist); - m_OuterBarrelScorer = CheckScorer("Tiara_OuterBarrelScorer",already_exist); - m_HyballScorer = CheckScorer("Tiara_HyballScorer",already_exist); + m_InnerBarrelScorer = CheckScorer("Tiara_InnerBarrelScorer", already_exist); + m_OuterBarrelScorer = CheckScorer("Tiara_OuterBarrelScorer", already_exist); + m_HyballScorer = CheckScorer("Tiara_HyballScorer", already_exist); // if the scorer were created previously nothing else need to be made - if(already_exist) return; + if (already_exist) + return; - G4VPrimitiveScorer* InnerBarrel = new SILICONSCORERS::PS_Silicon_Resistive("InnerBarrel",1, - INNERBARREL_ActiveWafer_Length, - INNERBARREL_ActiveWafer_Width, - INNERBARREL_NumberOfStrip); + G4VPrimitiveScorer* InnerBarrel = new SILICONSCORERS::PS_Silicon_Resistive( + "InnerBarrel", 1, INNERBARREL_ActiveWafer_Length, INNERBARREL_ActiveWafer_Width, INNERBARREL_NumberOfStrip); m_InnerBarrelScorer->RegisterPrimitive(InnerBarrel); - G4VPrimitiveScorer* OuterBarrel = new SILICONSCORERS::PS_Silicon_Rectangle("OuterBarrel",1, - INNERBARREL_ActiveWafer_Length, - INNERBARREL_ActiveWafer_Width, - 1, - OUTERBARREL_NumberOfStrip); + G4VPrimitiveScorer* OuterBarrel = new SILICONSCORERS::PS_Silicon_Rectangle( + "OuterBarrel", 1, INNERBARREL_ActiveWafer_Length, INNERBARREL_ActiveWafer_Width, 1, OUTERBARREL_NumberOfStrip); m_OuterBarrelScorer->RegisterPrimitive(OuterBarrel); - G4VPrimitiveScorer* Hyball= new SILICONSCORERS::PS_Silicon_Annular("Hyball",1, - HYBALL_ActiveWafer_InnerRadius, - HYBALL_ActiveWafer_OuterRadius, - -0.5*HYBALL_ActiveWafer_Angle,0.5*HYBALL_ActiveWafer_Angle, - HYBALL_NumberOfAnnularStrip, - HYBALL_NumberOfRadialStrip); + G4VPrimitiveScorer* Hyball = new SILICONSCORERS::PS_Silicon_Annular( + "Hyball", 1, HYBALL_ActiveWafer_InnerRadius, HYBALL_ActiveWafer_OuterRadius, -0.5 * HYBALL_ActiveWafer_Angle, + 0.5 * HYBALL_ActiveWafer_Angle, HYBALL_NumberOfAnnularStrip, HYBALL_NumberOfRadialStrip); m_HyballScorer->RegisterPrimitive(Hyball); // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_InnerBarrelScorer) ; - G4SDManager::GetSDMpointer()->AddNewDetector(m_OuterBarrelScorer) ; - G4SDManager::GetSDMpointer()->AddNewDetector(m_HyballScorer) ; + G4SDManager::GetSDMpointer()->AddNewDetector(m_InnerBarrelScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_OuterBarrelScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_HyballScorer); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Tiara::InitializeRootOutput(){ - TTree *pTree = RootOutput::getInstance()->GetTree(); - if(!pTree->FindBranch("TiaraBarrel")){ - pTree->Branch("TiaraBarrel", "TTiaraBarrelData", &m_EventBarrel) ; +void Tiara::InitializeRootOutput() { + TTree* pTree = RootOutput::getInstance()->GetTree(); + if (!pTree->FindBranch("TiaraBarrel")) { + pTree->Branch("TiaraBarrel", "TTiaraBarrelData", &m_EventBarrel); } - if(!pTree->FindBranch("TiaraHyball")){ - pTree->Branch("TiaraHyball", "TTiaraHyballData", &m_EventHyball) ; + if (!pTree->FindBranch("TiaraHyball")) { + pTree->Branch("TiaraHyball", "TTiaraHyballData", &m_EventHyball); } // This insure that the object are correctly bind in case of // a redifinition of the geometry in the simulation - pTree->SetBranchAddress("TiaraBarrel", &m_EventBarrel) ; - pTree->SetBranchAddress("TiaraHyball", &m_EventHyball) ; + pTree->SetBranchAddress("TiaraBarrel", &m_EventBarrel); + pTree->SetBranchAddress("TiaraHyball", &m_EventHyball); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Tiara::ConstructInnerBarrel(G4LogicalVolume* world){ +void Tiara::ConstructInnerBarrel(G4LogicalVolume* world) { // Tiara Barrel // The Barrel is made of 8 identical resistive strip detector // The PCB is made from a G4ExtrudeSolid, because it has beveled edge @@ -376,100 +376,75 @@ void Tiara::ConstructInnerBarrel(G4LogicalVolume* world){ // Start by making a full pcb // We start by the definition of the point forming a PCB cross section vector<G4TwoVector> PCBCrossSection; - double l1 = INNERBARREL_PCB_Thickness*0.5/tan(INNERBARREL_PCB_Bevel1_Theta); - double l2 = INNERBARREL_PCB_Thickness*0.5/tan(INNERBARREL_PCB_Bevel2_Theta); + double l1 = INNERBARREL_PCB_Thickness * 0.5 / tan(INNERBARREL_PCB_Bevel1_Theta); + double l2 = INNERBARREL_PCB_Thickness * 0.5 / tan(INNERBARREL_PCB_Bevel2_Theta); - PCBCrossSection.push_back(G4TwoVector(INNERBARREL_PCB_Width/2.-l2,-INNERBARREL_PCB_Thickness*0.5)); - PCBCrossSection.push_back(G4TwoVector(INNERBARREL_PCB_Width/2.,0)); - PCBCrossSection.push_back(G4TwoVector(INNERBARREL_PCB_Width/2.-l1,INNERBARREL_PCB_Thickness*0.5)); + PCBCrossSection.push_back(G4TwoVector(INNERBARREL_PCB_Width / 2. - l2, -INNERBARREL_PCB_Thickness * 0.5)); + PCBCrossSection.push_back(G4TwoVector(INNERBARREL_PCB_Width / 2., 0)); + PCBCrossSection.push_back(G4TwoVector(INNERBARREL_PCB_Width / 2. - l1, INNERBARREL_PCB_Thickness * 0.5)); - PCBCrossSection.push_back(G4TwoVector(-INNERBARREL_PCB_Width/2.+l1,INNERBARREL_PCB_Thickness*0.5)); - PCBCrossSection.push_back(G4TwoVector(-INNERBARREL_PCB_Width/2.,0)); - PCBCrossSection.push_back(G4TwoVector(-INNERBARREL_PCB_Width/2.+l2,-INNERBARREL_PCB_Thickness*0.5)); + PCBCrossSection.push_back(G4TwoVector(-INNERBARREL_PCB_Width / 2. + l1, INNERBARREL_PCB_Thickness * 0.5)); + PCBCrossSection.push_back(G4TwoVector(-INNERBARREL_PCB_Width / 2., 0)); + PCBCrossSection.push_back(G4TwoVector(-INNERBARREL_PCB_Width / 2. + l2, -INNERBARREL_PCB_Thickness * 0.5)); - G4ExtrudedSolid* PCBFull = - new G4ExtrudedSolid("PCBFull", - PCBCrossSection, - INNERBARREL_PCB_Length/2., - G4TwoVector(0,0),1, - G4TwoVector(0,0),1); + G4ExtrudedSolid* PCBFull = new G4ExtrudedSolid("PCBFull", PCBCrossSection, INNERBARREL_PCB_Length / 2., + G4TwoVector(0, 0), 1, G4TwoVector(0, 0), 1); // A box having Wafer dimension but thicker than the PCB // Will be used to remove material from the PCB to have space for the wafer // Calculate the hole shift within the PCB - G4ThreeVector HoleShift = G4ThreeVector( - 0, - 0, - INNERBARREL_PCB_Offset-(INNERBARREL_PCB_Length/2-INNERBARREL_PCB_HoleLength/2)); + G4ThreeVector HoleShift = + G4ThreeVector(0, 0, INNERBARREL_PCB_Offset - (INNERBARREL_PCB_Length / 2 - INNERBARREL_PCB_HoleLength / 2)); - G4Box* HoleShape = new G4Box("HoleShape", - INNERBARREL_ActiveWafer_Width/2., - INNERBARREL_PCB_Thickness/2.+0.1*mm, - INNERBARREL_PCB_HoleLength/2.); + G4Box* HoleShape = new G4Box("HoleShape", INNERBARREL_ActiveWafer_Width / 2., + INNERBARREL_PCB_Thickness / 2. + 0.1 * mm, INNERBARREL_PCB_HoleLength / 2.); - G4Box* WaferShape = new G4Box("WaferShape", - INNERBARREL_InertWafer_Width/2., - INNERBARREL_PCB_Thickness/2., - INNERBARREL_InertWafer_Length/2.); + G4Box* WaferShape = new G4Box("WaferShape", INNERBARREL_InertWafer_Width / 2., INNERBARREL_PCB_Thickness / 2., + INNERBARREL_InertWafer_Length / 2.); // The Silicon Wafer itself - G4Box* InertWaferFull = new G4Box("InertWaferFull", - INNERBARREL_InertWafer_Width/2., - INNERBARREL_InertWafer_Thickness/2., - INNERBARREL_InertWafer_Length/2.); - - G4Box* ActiveWafer = new G4Box("ActiveWafer", - INNERBARREL_ActiveWafer_Width/2., - INNERBARREL_ActiveWafer_Thickness/2., - INNERBARREL_ActiveWafer_Length/2.); + G4Box* InertWaferFull = new G4Box("InertWaferFull", INNERBARREL_InertWafer_Width / 2., + INNERBARREL_InertWafer_Thickness / 2., INNERBARREL_InertWafer_Length / 2.); - G4Box* DeadLayer = new G4Box("DeadLayer", - INNERBARREL_ActiveWafer_Width/2., - INNERBARREL_ActiveWafer_DeadLayerThickness/2., - INNERBARREL_ActiveWafer_Length/2.); + G4Box* ActiveWafer = new G4Box("ActiveWafer", INNERBARREL_ActiveWafer_Width / 2., + INNERBARREL_ActiveWafer_Thickness / 2., INNERBARREL_ActiveWafer_Length / 2.); - G4Box* ActiveWaferShape = new G4Box("ActiveWaferShape", - INNERBARREL_ActiveWafer_Width/2., - INNERBARREL_PCB_Thickness/2., - INNERBARREL_ActiveWafer_Length/2.); + G4Box* DeadLayer = new G4Box("DeadLayer", INNERBARREL_ActiveWafer_Width / 2., + INNERBARREL_ActiveWafer_DeadLayerThickness / 2., INNERBARREL_ActiveWafer_Length / 2.); + G4Box* ActiveWaferShape = new G4Box("ActiveWaferShape", INNERBARREL_ActiveWafer_Width / 2., + INNERBARREL_PCB_Thickness / 2., INNERBARREL_ActiveWafer_Length / 2.); // Substracting the hole Shape from the Stock PCB - G4SubtractionSolid* PCB_1 = new G4SubtractionSolid("PCB_1", PCBFull, HoleShape, - new G4RotationMatrix,HoleShift); + G4SubtractionSolid* PCB_1 = new G4SubtractionSolid("PCB_1", PCBFull, HoleShape, new G4RotationMatrix, HoleShift); // Substracting the wafer space from the Stock PCB - G4SubtractionSolid* PCB = new G4SubtractionSolid("PCB", PCB_1, WaferShape, - new G4RotationMatrix, - G4ThreeVector(0,INNERBARREL_PCB_Thickness/2.-INNERBARREL_PCB_WaferDepth,0)); + G4SubtractionSolid* PCB = + new G4SubtractionSolid("PCB", PCB_1, WaferShape, new G4RotationMatrix, + G4ThreeVector(0, INNERBARREL_PCB_Thickness / 2. - INNERBARREL_PCB_WaferDepth, 0)); // Substract active part from inert part of the Wafer G4SubtractionSolid* InertWafer = new G4SubtractionSolid("InertWafer", InertWaferFull, ActiveWaferShape, - new G4RotationMatrix, - G4ThreeVector(0,0,0)); + new G4RotationMatrix, G4ThreeVector(0, 0, 0)); // Master Volume that encompass everything else - G4LogicalVolume* logicBarrelDetector = - new G4LogicalVolume(PCBFull,m_MaterialVacuum,"logicBoxDetector", 0, 0, 0); - logicBarrelDetector->SetVisAttributes(G4VisAttributes::Invisible); + G4LogicalVolume* logicBarrelDetector = new G4LogicalVolume(PCBFull, m_MaterialVacuum, "logicBoxDetector", 0, 0, 0); + logicBarrelDetector->SetVisAttributes(G4VisAttributes::GetInvisible()); // Sub Volume PCB - G4LogicalVolume* logicPCB = - new G4LogicalVolume(PCB,m_MaterialPCB,"logicPCB", 0, 0, 0); + G4LogicalVolume* logicPCB = new G4LogicalVolume(PCB, m_MaterialPCB, "logicPCB", 0, 0, 0); logicPCB->SetVisAttributes(PCBVisAtt); // Sub Volume Wafer - G4LogicalVolume* logicInertWafer = - new G4LogicalVolume(InertWafer,m_MaterialSilicon,"logicInertWafer", 0, 0, 0); + G4LogicalVolume* logicInertWafer = new G4LogicalVolume(InertWafer, m_MaterialSilicon, "logicInertWafer", 0, 0, 0); logicInertWafer->SetVisAttributes(GuardRingVisAtt); - G4LogicalVolume* logicActiveWafer = - new G4LogicalVolume(ActiveWafer,m_MaterialSilicon,"logicActiveWafer", 0, 0, 0); + G4LogicalVolume* logicActiveWafer = new G4LogicalVolume(ActiveWafer, m_MaterialSilicon, "logicActiveWafer", 0, 0, 0); logicActiveWafer->SetVisAttributes(SiliconVisAtt); G4LogicalVolume* logicDeadLayer = - new G4LogicalVolume(DeadLayer,m_MaterialSilicon,"logicActiveWaferDeadLayer", 0, 0, 0); + new G4LogicalVolume(DeadLayer, m_MaterialSilicon, "logicActiveWaferDeadLayer", 0, 0, 0); logicDeadLayer->SetVisAttributes(SiliconVisAtt); // Set the sensitive volume @@ -478,70 +453,59 @@ void Tiara::ConstructInnerBarrel(G4LogicalVolume* world){ // Place the sub volumes in the master volume // Last argument is the detector number, used in the scorer to get the // revelant information - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0), - logicPCB,"Tiara_Barrel_PCB",logicBarrelDetector, - false,0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicPCB, "Tiara_Barrel_PCB", + logicBarrelDetector, false, 0); - G4ThreeVector WaferPosition(0, - 0.5*(INNERBARREL_PCB_Thickness+INNERBARREL_InertWafer_Thickness)-INNERBARREL_PCB_WaferDepth - ,0); + G4ThreeVector WaferPosition( + 0, 0.5 * (INNERBARREL_PCB_Thickness + INNERBARREL_InertWafer_Thickness) - INNERBARREL_PCB_WaferDepth, 0); - G4ThreeVector DeadLayerPositionF = WaferPosition + G4ThreeVector(0,-INNERBARREL_ActiveWafer_Thickness*0.5-INNERBARREL_ActiveWafer_DeadLayerThickness*0.5,0); + G4ThreeVector DeadLayerPositionF = + WaferPosition + + G4ThreeVector(0, -INNERBARREL_ActiveWafer_Thickness * 0.5 - INNERBARREL_ActiveWafer_DeadLayerThickness * 0.5, 0); - G4ThreeVector DeadLayerPositionB = WaferPosition + G4ThreeVector(0,INNERBARREL_ActiveWafer_Thickness*0.5+INNERBARREL_ActiveWafer_DeadLayerThickness*0.5,0); + G4ThreeVector DeadLayerPositionB = + WaferPosition + + G4ThreeVector(0, INNERBARREL_ActiveWafer_Thickness * 0.5 + INNERBARREL_ActiveWafer_DeadLayerThickness * 0.5, 0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), WaferPosition, logicActiveWafer, "Barrel_Wafer", logicBarrelDetector, + false, 0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), DeadLayerPositionF, logicDeadLayer, "Barrel_WaferDeadLayerFront", + logicBarrelDetector, false, 0); - new G4PVPlacement(new G4RotationMatrix(0,0,0), - WaferPosition, - logicActiveWafer,"Barrel_Wafer", - logicBarrelDetector,false,0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), DeadLayerPositionB, logicDeadLayer, "Barrel_WaferDeadLayerBack", + logicBarrelDetector, false, 0); - new G4PVPlacement(new G4RotationMatrix(0,0,0), - DeadLayerPositionF, - logicDeadLayer,"Barrel_WaferDeadLayerFront", - logicBarrelDetector,false,0); - - new G4PVPlacement(new G4RotationMatrix(0,0,0), - DeadLayerPositionB, - logicDeadLayer,"Barrel_WaferDeadLayerBack", - logicBarrelDetector,false,0); - - - new G4PVPlacement(new G4RotationMatrix(0,0,0), - WaferPosition, - logicInertWafer,"Barrel_Wafer_GuardRing", - logicBarrelDetector,false,0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), WaferPosition, logicInertWafer, "Barrel_Wafer_GuardRing", + logicBarrelDetector, false, 0); // The Distance from target is given by half the lenght of a detector // plus the length of a detector inclined by 45 deg. - G4double DistanceFromTarget = INNERBARREL_PCB_Width*(0.5+sin(45*deg)) ; - for( unsigned int i = 0; i < 8; i ++){ + G4double DistanceFromTarget = INNERBARREL_PCB_Width * (0.5 + sin(45 * deg)); + for (unsigned int i = 0; i < 8; i++) { // The following build the barrel, with detector one at the top // and going clowise looking upstrea // Detector are rotate by 45deg with each other // Detector 3 [i=2] is perpendicular to positive y-axis, Detector 5 [i=4] is perpendicular to positive x-axis, G4RotationMatrix* DetectorRotation = -//by Shuya 180521. This seems to give the right directio of Barrel geometry. Tentative. Wait to be comfirmed. - //new G4RotationMatrix(0*deg,0*deg,(360+(2-i)*45)*deg); - new G4RotationMatrix(0*deg,0*deg,(360+(2-i)*-45)*deg); + // by Shuya 180521. This seems to give the right directio of Barrel geometry. Tentative. Wait to be comfirmed. + // new G4RotationMatrix(0*deg,0*deg,(360+(2-i)*45)*deg); + new G4RotationMatrix(0 * deg, 0 * deg, (360 + (2 - i) * -45) * deg); // There center is also rotated by 45deg - G4ThreeVector DetectorPosition(0,DistanceFromTarget,0); -//by Shuya 180521. This seems to give the right directio of Barrel geometry. Tentative. Wait to be comfirmed. - //DetectorPosition.rotate((360+(2-i)*-45)*deg,G4ThreeVector(0,0,1)); - DetectorPosition.rotate((360+(2-i)*45)*deg,G4ThreeVector(0,0,1)); + G4ThreeVector DetectorPosition(0, DistanceFromTarget, 0); + // by Shuya 180521. This seems to give the right directio of Barrel geometry. Tentative. Wait to be comfirmed. + // DetectorPosition.rotate((360+(2-i)*-45)*deg,G4ThreeVector(0,0,1)); + DetectorPosition.rotate((360 + (2 - i) * 45) * deg, G4ThreeVector(0, 0, 1)); // Place the Master volume with its two daugther volume at the final place - new G4PVPlacement(G4Transform3D(*DetectorRotation,DetectorPosition), - logicBarrelDetector,"Tiara_InnerBarrel_Detector", - world,false,i+1); + new G4PVPlacement(G4Transform3D(*DetectorRotation, DetectorPosition), logicBarrelDetector, + "Tiara_InnerBarrel_Detector", world, false, i + 1); } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Tiara::ConstructOuterBarrel(G4LogicalVolume* world){ +void Tiara::ConstructOuterBarrel(G4LogicalVolume* world) { // Tiara Outer Barrel // The outer Barrel is identical to the inner barrel but wider in terms of // geometry. It feature four non resistive strip on the front face @@ -549,91 +513,68 @@ void Tiara::ConstructOuterBarrel(G4LogicalVolume* world){ // Start by making a full pcb // We start by the definition of the point forming a PCB cross section vector<G4TwoVector> PCBCrossSection; - double l1 = OUTERBARREL_PCB_Thickness*0.5/tan(OUTERBARREL_PCB_Bevel1_Theta); - double l2 = OUTERBARREL_PCB_Thickness*0.5/tan(OUTERBARREL_PCB_Bevel2_Theta); + double l1 = OUTERBARREL_PCB_Thickness * 0.5 / tan(OUTERBARREL_PCB_Bevel1_Theta); + double l2 = OUTERBARREL_PCB_Thickness * 0.5 / tan(OUTERBARREL_PCB_Bevel2_Theta); - PCBCrossSection.push_back(G4TwoVector(OUTERBARREL_PCB_Width/2.-l2,-OUTERBARREL_PCB_Thickness*0.5)); - PCBCrossSection.push_back(G4TwoVector(OUTERBARREL_PCB_Width/2.,0)); - PCBCrossSection.push_back(G4TwoVector(OUTERBARREL_PCB_Width/2.-l1,OUTERBARREL_PCB_Thickness*0.5)); + PCBCrossSection.push_back(G4TwoVector(OUTERBARREL_PCB_Width / 2. - l2, -OUTERBARREL_PCB_Thickness * 0.5)); + PCBCrossSection.push_back(G4TwoVector(OUTERBARREL_PCB_Width / 2., 0)); + PCBCrossSection.push_back(G4TwoVector(OUTERBARREL_PCB_Width / 2. - l1, OUTERBARREL_PCB_Thickness * 0.5)); - PCBCrossSection.push_back(G4TwoVector(-OUTERBARREL_PCB_Width/2.+l1,OUTERBARREL_PCB_Thickness*0.5)); - PCBCrossSection.push_back(G4TwoVector(-OUTERBARREL_PCB_Width/2.,0)); - PCBCrossSection.push_back(G4TwoVector(-OUTERBARREL_PCB_Width/2.+l2,-OUTERBARREL_PCB_Thickness*0.5)); + PCBCrossSection.push_back(G4TwoVector(-OUTERBARREL_PCB_Width / 2. + l1, OUTERBARREL_PCB_Thickness * 0.5)); + PCBCrossSection.push_back(G4TwoVector(-OUTERBARREL_PCB_Width / 2., 0)); + PCBCrossSection.push_back(G4TwoVector(-OUTERBARREL_PCB_Width / 2. + l2, -OUTERBARREL_PCB_Thickness * 0.5)); - G4ExtrudedSolid* PCBFull = - new G4ExtrudedSolid("PCBFull", - PCBCrossSection, - OUTERBARREL_PCB_Length/2., - G4TwoVector(0,0),1, - G4TwoVector(0,0),1); + G4ExtrudedSolid* PCBFull = new G4ExtrudedSolid("PCBFull", PCBCrossSection, OUTERBARREL_PCB_Length / 2., + G4TwoVector(0, 0), 1, G4TwoVector(0, 0), 1); // A box having Wafer dimension but thicker than the PCB // Will be used to remove material from the PCB to have space for the wafer // Calculate the hole shift within the PCB - G4ThreeVector HoleShift = G4ThreeVector( - 0, - 0, - OUTERBARREL_PCB_Offset-(OUTERBARREL_PCB_Length/2-OUTERBARREL_PCB_HoleLength/2)); + G4ThreeVector HoleShift = + G4ThreeVector(0, 0, OUTERBARREL_PCB_Offset - (OUTERBARREL_PCB_Length / 2 - OUTERBARREL_PCB_HoleLength / 2)); - G4Box* HoleShape = new G4Box("HoleShape", - OUTERBARREL_ActiveWafer_Width/2., - OUTERBARREL_PCB_Thickness/2.+0.1*mm, - OUTERBARREL_PCB_HoleLength/2.); + G4Box* HoleShape = new G4Box("HoleShape", OUTERBARREL_ActiveWafer_Width / 2., + OUTERBARREL_PCB_Thickness / 2. + 0.1 * mm, OUTERBARREL_PCB_HoleLength / 2.); - G4Box* WaferShape = new G4Box("WaferShape", - OUTERBARREL_InertWafer_Width/2., - OUTERBARREL_PCB_Thickness/2., - OUTERBARREL_InertWafer_Length/2.); + G4Box* WaferShape = new G4Box("WaferShape", OUTERBARREL_InertWafer_Width / 2., OUTERBARREL_PCB_Thickness / 2., + OUTERBARREL_InertWafer_Length / 2.); // The Silicon Wafer itself - G4Box* InertWaferFull = new G4Box("InertWaferFull", - OUTERBARREL_InertWafer_Width/2., - OUTERBARREL_ActiveWafer_Thickness/2., - OUTERBARREL_InertWafer_Length/2.); + G4Box* InertWaferFull = new G4Box("InertWaferFull", OUTERBARREL_InertWafer_Width / 2., + OUTERBARREL_ActiveWafer_Thickness / 2., OUTERBARREL_InertWafer_Length / 2.); - G4Box* ActiveWafer = new G4Box("ActiveWafer", - OUTERBARREL_ActiveWafer_Width/2., - OUTERBARREL_ActiveWafer_Thickness/2., - OUTERBARREL_ActiveWafer_Length/2.); - - G4Box* ActiveWaferShape = new G4Box("ActiveWaferShape", - OUTERBARREL_ActiveWafer_Width/2., - OUTERBARREL_PCB_Thickness/2., - OUTERBARREL_ActiveWafer_Length/2.); + G4Box* ActiveWafer = new G4Box("ActiveWafer", OUTERBARREL_ActiveWafer_Width / 2., + OUTERBARREL_ActiveWafer_Thickness / 2., OUTERBARREL_ActiveWafer_Length / 2.); + G4Box* ActiveWaferShape = new G4Box("ActiveWaferShape", OUTERBARREL_ActiveWafer_Width / 2., + OUTERBARREL_PCB_Thickness / 2., OUTERBARREL_ActiveWafer_Length / 2.); // Substracting the hole Shape from the Stock PCB - G4SubtractionSolid* PCB_1 = new G4SubtractionSolid("PCB_1", PCBFull, HoleShape, - new G4RotationMatrix,HoleShift); + G4SubtractionSolid* PCB_1 = new G4SubtractionSolid("PCB_1", PCBFull, HoleShape, new G4RotationMatrix, HoleShift); // Substracting the wafer space from the Stock PCB - G4SubtractionSolid* PCB = new G4SubtractionSolid("PCB", PCB_1, WaferShape, - new G4RotationMatrix, - G4ThreeVector(0,OUTERBARREL_PCB_Thickness/2.-OUTERBARREL_PCB_WaferDepth,0)); + G4SubtractionSolid* PCB = + new G4SubtractionSolid("PCB", PCB_1, WaferShape, new G4RotationMatrix, + G4ThreeVector(0, OUTERBARREL_PCB_Thickness / 2. - OUTERBARREL_PCB_WaferDepth, 0)); // Substract active part from inert part of the Wafer G4SubtractionSolid* InertWafer = new G4SubtractionSolid("InertWafer", InertWaferFull, ActiveWaferShape, - new G4RotationMatrix, - G4ThreeVector(0,0,0)); + new G4RotationMatrix, G4ThreeVector(0, 0, 0)); // Master Volume that encompass everything else - G4LogicalVolume* logicBarrelDetector = - new G4LogicalVolume(PCBFull,m_MaterialVacuum,"logicBoxDetector", 0, 0, 0); - logicBarrelDetector->SetVisAttributes(G4VisAttributes::Invisible); + G4LogicalVolume* logicBarrelDetector = new G4LogicalVolume(PCBFull, m_MaterialVacuum, "logicBoxDetector", 0, 0, 0); + logicBarrelDetector->SetVisAttributes(G4VisAttributes::GetInvisible()); // Sub Volume PCB - G4LogicalVolume* logicPCB = - new G4LogicalVolume(PCB,m_MaterialPCB,"logicPCB", 0, 0, 0); + G4LogicalVolume* logicPCB = new G4LogicalVolume(PCB, m_MaterialPCB, "logicPCB", 0, 0, 0); logicPCB->SetVisAttributes(PCBVisAtt); // Sub Volume Wafer - G4LogicalVolume* logicInertWafer = - new G4LogicalVolume(InertWafer,m_MaterialSilicon,"logicInertWafer", 0, 0, 0); + G4LogicalVolume* logicInertWafer = new G4LogicalVolume(InertWafer, m_MaterialSilicon, "logicInertWafer", 0, 0, 0); logicInertWafer->SetVisAttributes(GuardRingVisAtt); - G4LogicalVolume* logicActiveWafer = - new G4LogicalVolume(ActiveWafer,m_MaterialSilicon,"logicActiveWafer", 0, 0, 0); + G4LogicalVolume* logicActiveWafer = new G4LogicalVolume(ActiveWafer, m_MaterialSilicon, "logicActiveWafer", 0, 0, 0); logicActiveWafer->SetVisAttributes(SiliconVisAtt); // Set the sensitive detector @@ -641,177 +582,135 @@ void Tiara::ConstructOuterBarrel(G4LogicalVolume* world){ // The Distance from target is given by half the lenght of a detector // plus the length of a detector inclined by 45 deg. - G4double DistanceFromTarget = OUTERBARREL_PCB_Width*(0.5+sin(45*deg)) ; + G4double DistanceFromTarget = OUTERBARREL_PCB_Width * (0.5 + sin(45 * deg)); // Place the sub volumes in the master volume // Last argument is the detector number, used in the scorer to get the // revelant information - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0), - logicPCB,"Tiara_OuterBarrel_PCB",logicBarrelDetector, - false,0); - - - G4ThreeVector WaferPosition(0, - 0.5*(OUTERBARREL_PCB_Thickness+OUTERBARREL_ActiveWafer_Thickness)-OUTERBARREL_PCB_WaferDepth - ,0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicPCB, "Tiara_OuterBarrel_PCB", + logicBarrelDetector, false, 0); - new G4PVPlacement(new G4RotationMatrix(0,0,0), - WaferPosition, - logicActiveWafer,"OuterBarrel_Wafer", - logicBarrelDetector,false,0); + G4ThreeVector WaferPosition( + 0, 0.5 * (OUTERBARREL_PCB_Thickness + OUTERBARREL_ActiveWafer_Thickness) - OUTERBARREL_PCB_WaferDepth, 0); - new G4PVPlacement(new G4RotationMatrix(0,0,0), - WaferPosition, - logicInertWafer,"OuterBarrel_Wafer_GuardRing", - logicBarrelDetector,false,0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), WaferPosition, logicActiveWafer, "OuterBarrel_Wafer", + logicBarrelDetector, false, 0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), WaferPosition, logicInertWafer, "OuterBarrel_Wafer_GuardRing", + logicBarrelDetector, false, 0); // The following build the barrel, with detector one at the top // and going clowise looking upstrea - for( unsigned int i = 0; i < 8; i ++){ + for (unsigned int i = 0; i < 8; i++) { // Detector are rotate by 45deg with each other - G4RotationMatrix* DetectorRotation = - new G4RotationMatrix(0*deg,0*deg,i*45*deg); + G4RotationMatrix* DetectorRotation = new G4RotationMatrix(0 * deg, 0 * deg, i * 45 * deg); // There center is also rotated by 45deg - G4ThreeVector DetectorPosition(0,DistanceFromTarget,0); - DetectorPosition.rotate(i*45*deg,G4ThreeVector(0,0,-1)); + G4ThreeVector DetectorPosition(0, DistanceFromTarget, 0); + DetectorPosition.rotate(i * 45 * deg, G4ThreeVector(0, 0, -1)); // Place the Master volume with its daugthers at the final place - new G4PVPlacement(G4Transform3D(*DetectorRotation,DetectorPosition), - logicBarrelDetector,"Tiara_OuterBarrel_Detector", - world,false,i+1); + new G4PVPlacement(G4Transform3D(*DetectorRotation, DetectorPosition), logicBarrelDetector, + "Tiara_OuterBarrel_Detector", world, false, i + 1); } - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Tiara::ConstructHyball(G4LogicalVolume* world){ +void Tiara::ConstructHyball(G4LogicalVolume* world) { vector<G4TwoVector> PCBCrossSection; - PCBCrossSection.push_back(G4TwoVector(28.108*mm ,-14.551*mm)); - PCBCrossSection.push_back(G4TwoVector(128.808*mm,-66.683*mm)); - PCBCrossSection.push_back(G4TwoVector(163.618*mm,-30.343*mm)); - PCBCrossSection.push_back(G4TwoVector(163.618*mm, 30.941*mm)); - PCBCrossSection.push_back(G4TwoVector(125.718*mm, 73.677*mm)); - PCBCrossSection.push_back(G4TwoVector(28.108*mm , 16.473*mm)); - - G4ExtrudedSolid* PCBFull = - new G4ExtrudedSolid("PCBFull", - PCBCrossSection, - 0.5*HYBALL_PCB_THICKNESS, - G4TwoVector(0,0),1, - G4TwoVector(0,0),1); + PCBCrossSection.push_back(G4TwoVector(28.108 * mm, -14.551 * mm)); + PCBCrossSection.push_back(G4TwoVector(128.808 * mm, -66.683 * mm)); + PCBCrossSection.push_back(G4TwoVector(163.618 * mm, -30.343 * mm)); + PCBCrossSection.push_back(G4TwoVector(163.618 * mm, 30.941 * mm)); + PCBCrossSection.push_back(G4TwoVector(125.718 * mm, 73.677 * mm)); + PCBCrossSection.push_back(G4TwoVector(28.108 * mm, 16.473 * mm)); + + G4ExtrudedSolid* PCBFull = new G4ExtrudedSolid("PCBFull", PCBCrossSection, 0.5 * HYBALL_PCB_THICKNESS, + G4TwoVector(0, 0), 1, G4TwoVector(0, 0), 1); vector<G4TwoVector> WaferCrossSection; - WaferCrossSection.push_back(G4TwoVector(29.108*mm ,-13.943*mm )); - WaferCrossSection.push_back(G4TwoVector(123.022*mm,-62.561*mm )); - WaferCrossSection.push_back(G4TwoVector(137.00*mm ,-24.157*mm )); - WaferCrossSection.push_back(G4TwoVector(137.00*mm , 24.157*mm )); - WaferCrossSection.push_back(G4TwoVector(122.677*mm, 63.508*mm )); - WaferCrossSection.push_back(G4TwoVector(29.108*mm , 15.069*mm)); - - G4ExtrudedSolid* WaferFull = - new G4ExtrudedSolid("WaferFull", - WaferCrossSection, - 0.5*HYBALL_ActiveWafer_Thickness, - G4TwoVector(0,0),1, - G4TwoVector(0,0),1); - - G4ExtrudedSolid* WaferShape = - new G4ExtrudedSolid("WaferShape", - WaferCrossSection, - 0.6*HYBALL_PCB_THICKNESS, - G4TwoVector(0,0),1, - G4TwoVector(0,0),1); + WaferCrossSection.push_back(G4TwoVector(29.108 * mm, -13.943 * mm)); + WaferCrossSection.push_back(G4TwoVector(123.022 * mm, -62.561 * mm)); + WaferCrossSection.push_back(G4TwoVector(137.00 * mm, -24.157 * mm)); + WaferCrossSection.push_back(G4TwoVector(137.00 * mm, 24.157 * mm)); + WaferCrossSection.push_back(G4TwoVector(122.677 * mm, 63.508 * mm)); + WaferCrossSection.push_back(G4TwoVector(29.108 * mm, 15.069 * mm)); + + G4ExtrudedSolid* WaferFull = new G4ExtrudedSolid("WaferFull", WaferCrossSection, 0.5 * HYBALL_ActiveWafer_Thickness, + G4TwoVector(0, 0), 1, G4TwoVector(0, 0), 1); + + G4ExtrudedSolid* WaferShape = new G4ExtrudedSolid("WaferShape", WaferCrossSection, 0.6 * HYBALL_PCB_THICKNESS, + G4TwoVector(0, 0), 1, G4TwoVector(0, 0), 1); // Active Wafer G4Tubs* ActiveWafer = - new G4Tubs("HyballActiveWafer",HYBALL_ActiveWafer_InnerRadius, - HYBALL_ActiveWafer_OuterRadius,0.5*HYBALL_ActiveWafer_Thickness, - -0.5*HYBALL_ActiveWafer_Angle,HYBALL_ActiveWafer_Angle); + new G4Tubs("HyballActiveWafer", HYBALL_ActiveWafer_InnerRadius, HYBALL_ActiveWafer_OuterRadius, + 0.5 * HYBALL_ActiveWafer_Thickness, -0.5 * HYBALL_ActiveWafer_Angle, HYBALL_ActiveWafer_Angle); G4Tubs* ActiveWaferShape = - new G4Tubs("HyballActiveWaferShape",HYBALL_ActiveWafer_InnerRadius, - HYBALL_ActiveWafer_OuterRadius,0.6*HYBALL_ActiveWafer_Thickness, - -0.5*HYBALL_ActiveWafer_Angle,HYBALL_ActiveWafer_Angle); + new G4Tubs("HyballActiveWaferShape", HYBALL_ActiveWafer_InnerRadius, HYBALL_ActiveWafer_OuterRadius, + 0.6 * HYBALL_ActiveWafer_Thickness, -0.5 * HYBALL_ActiveWafer_Angle, HYBALL_ActiveWafer_Angle); - //by Shuya 180219. Hyball DeadLayer + // by Shuya 180219. Hyball DeadLayer G4Tubs* Hyball_DeadLayer = - new G4Tubs("HyballDeadLayer",HYBALL_ActiveWafer_InnerRadius, - HYBALL_ActiveWafer_OuterRadius,0.5*HYBALL_DeadLayer_Thickness, - -0.5*HYBALL_ActiveWafer_Angle,HYBALL_ActiveWafer_Angle); - + new G4Tubs("HyballDeadLayer", HYBALL_ActiveWafer_InnerRadius, HYBALL_ActiveWafer_OuterRadius, + 0.5 * HYBALL_DeadLayer_Thickness, -0.5 * HYBALL_ActiveWafer_Angle, HYBALL_ActiveWafer_Angle); // Substract Active Wafer from Wafer G4SubtractionSolid* InertWafer = new G4SubtractionSolid("Hyball_InertWafer", WaferFull, ActiveWaferShape, - new G4RotationMatrix(0,0,0),G4ThreeVector(0,0,0)); - + new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0)); // Substract Wafer shape from PCB - G4SubtractionSolid* PCB = new G4SubtractionSolid("Hyball_PCB", PCBFull, WaferShape, - new G4RotationMatrix,G4ThreeVector(0,0,0)); + G4SubtractionSolid* PCB = + new G4SubtractionSolid("Hyball_PCB", PCBFull, WaferShape, new G4RotationMatrix, G4ThreeVector(0, 0, 0)); // Logic Volume // // Logic Mother Volume - G4LogicalVolume* logicHyball = - new G4LogicalVolume(PCBFull,m_MaterialVacuum,"logicHyball", 0, 0, 0); - logicHyball->SetVisAttributes(G4VisAttributes::Invisible); + G4LogicalVolume* logicHyball = new G4LogicalVolume(PCBFull, m_MaterialVacuum, "logicHyball", 0, 0, 0); + logicHyball->SetVisAttributes(G4VisAttributes::GetInvisible()); // logic PCB - G4LogicalVolume* logicPCB = - new G4LogicalVolume(PCB,m_MaterialPCB,"logicPCB", 0, 0, 0); + G4LogicalVolume* logicPCB = new G4LogicalVolume(PCB, m_MaterialPCB, "logicPCB", 0, 0, 0); logicPCB->SetVisAttributes(PCBVisAtt); // logic Inert Wafer - G4LogicalVolume* logicIW = - new G4LogicalVolume(InertWafer,m_MaterialSilicon,"logicIW", 0, 0, 0); + G4LogicalVolume* logicIW = new G4LogicalVolume(InertWafer, m_MaterialSilicon, "logicIW", 0, 0, 0); logicIW->SetVisAttributes(GuardRingVisAtt); // logic Active Wafer - G4LogicalVolume* logicAW = - new G4LogicalVolume(ActiveWafer,m_MaterialSilicon,"logicAW", 0, 0, 0); + G4LogicalVolume* logicAW = new G4LogicalVolume(ActiveWafer, m_MaterialSilicon, "logicAW", 0, 0, 0); logicAW->SetVisAttributes(SiliconVisAtt); logicAW->SetSensitiveDetector(m_HyballScorer); - //by Shuya 180219 - // logic Hyball DeadLayer - G4LogicalVolume* logicDL = - new G4LogicalVolume(Hyball_DeadLayer,m_MaterialSilicon,"logicDL", 0, 0, 0); + // by Shuya 180219 + // logic Hyball DeadLayer + G4LogicalVolume* logicDL = new G4LogicalVolume(Hyball_DeadLayer, m_MaterialSilicon, "logicDL", 0, 0, 0); logicDL->SetVisAttributes(SiliconVisAtt); // Place all the Piece in the mother volume - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0), - logicPCB,"Hyball_PCB", - logicHyball,false,0); - - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0), - logicIW,"Hyball_InertWafer", - logicHyball,false,0); - - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0), - logicAW,"Hyball_ActiveWafer", - logicHyball,false,0); - - //by Shuya 180219. Note beacause Hyball is placed in negative direction (such as -147 mm) in world coordinate, deadlayer (front side) positions must be added in positive direction. - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0.5*HYBALL_ActiveWafer_Thickness+0.5*HYBALL_DeadLayer_Thickness), - logicDL,"Hyball_DeadLayer", - logicHyball,false,0); - - for(unsigned int i = 0 ; i < m_HyballZ.size() ; i++){ + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicPCB, "Hyball_PCB", logicHyball, false, + 0); + + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicIW, "Hyball_InertWafer", logicHyball, + false, 0); + + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicAW, "Hyball_ActiveWafer", logicHyball, + false, 0); + + // by Shuya 180219. Note beacause Hyball is placed in negative direction (such as -147 mm) in world coordinate, + // deadlayer (front side) positions must be added in positive direction. + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), + G4ThreeVector(0, 0, 0.5 * HYBALL_ActiveWafer_Thickness + 0.5 * HYBALL_DeadLayer_Thickness), logicDL, + "Hyball_DeadLayer", logicHyball, false, 0); + + for (unsigned int i = 0; i < m_HyballZ.size(); i++) { // Place mother volume - new G4PVPlacement(new G4RotationMatrix(0,0,m_HyballPhi[i]), - G4ThreeVector(0,0,m_HyballZ[i]), - logicHyball,"Hyball", - world,false,i+1); + new G4PVPlacement(new G4RotationMatrix(0, 0, m_HyballPhi[i]), G4ThreeVector(0, 0, m_HyballZ[i]), logicHyball, + "Hyball", world, false, i + 1); } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Tiara::ConstructChamber(G4LogicalVolume* world){ +void Tiara::ConstructChamber(G4LogicalVolume* world) { // Vaccum Chamber of Tiara // The chamber is made of a central cylinder surrounding the barrel Si // Two Cone that expeand out of the central cylinder to let room for Exogam @@ -825,61 +724,52 @@ void Tiara::ConstructChamber(G4LogicalVolume* world){ // Central Tube G4Tubs* solidCentralTube = - new G4Tubs("TiaraChamberCentralTube",CHAMBER_CentralTube_Inner_Radius, - CHAMBER_CentralTube_Outer_Radius,CHAMBER_CentralTube_Length/2., - 0*deg,360*deg); + new G4Tubs("TiaraChamberCentralTube", CHAMBER_CentralTube_Inner_Radius, CHAMBER_CentralTube_Outer_Radius, + CHAMBER_CentralTube_Length / 2., 0 * deg, 360 * deg); // Forward-Backward Cones G4Cons* solidOuterCone = - new G4Cons("TiaraChamberOuterCone",CHAMBER_CentralTube_Inner_Radius, - CHAMBER_CentralTube_Outer_Radius,CHAMBER_OuterCylinder_Inner_Radius, - CHAMBER_OuterCylinder_Outer_Radius,CHAMBER_OuterCone_Length/2., - 0*deg,360*deg); + new G4Cons("TiaraChamberOuterCone", CHAMBER_CentralTube_Inner_Radius, CHAMBER_CentralTube_Outer_Radius, + CHAMBER_OuterCylinder_Inner_Radius, CHAMBER_OuterCylinder_Outer_Radius, CHAMBER_OuterCone_Length / 2., + 0 * deg, 360 * deg); // Outer Cylinder G4Tubs* solidOuterCylinder = - new G4Tubs("TiaraChamberOuterCylinder",CHAMBER_OuterCylinder_Inner_Radius, - CHAMBER_OuterCylinder_Outer_Radius,CHAMBER_OuterCylinder_Length/2., - 0*deg,360*deg); + new G4Tubs("TiaraChamberOuterCylinder", CHAMBER_OuterCylinder_Inner_Radius, CHAMBER_OuterCylinder_Outer_Radius, + CHAMBER_OuterCylinder_Length / 2., 0 * deg, 360 * deg); // Add the volume together G4UnionSolid* solidTiaraChamberStep1 = - new G4UnionSolid("TiaraChamber", solidCentralTube, solidOuterCone, - new G4RotationMatrix, - G4ThreeVector(0,0,CHAMBER_OuterCone_Z_Pos)); + new G4UnionSolid("TiaraChamber", solidCentralTube, solidOuterCone, new G4RotationMatrix, + G4ThreeVector(0, 0, CHAMBER_OuterCone_Z_Pos)); G4UnionSolid* solidTiaraChamberStep2 = - new G4UnionSolid("TiaraChamber", solidTiaraChamberStep1, solidOuterCone, - new G4RotationMatrix(0,180*deg,0), - G4ThreeVector(0,0,-CHAMBER_OuterCone_Z_Pos)); + new G4UnionSolid("TiaraChamber", solidTiaraChamberStep1, solidOuterCone, new G4RotationMatrix(0, 180 * deg, 0), + G4ThreeVector(0, 0, -CHAMBER_OuterCone_Z_Pos)); G4UnionSolid* solidTiaraChamberStep3 = - new G4UnionSolid("TiaraChamber", solidTiaraChamberStep2, solidOuterCylinder, - new G4RotationMatrix, - G4ThreeVector(0,0,CHAMBER_OuterCylinder_Z_Pos)); + new G4UnionSolid("TiaraChamber", solidTiaraChamberStep2, solidOuterCylinder, new G4RotationMatrix, + G4ThreeVector(0, 0, CHAMBER_OuterCylinder_Z_Pos)); G4UnionSolid* solidTiaraChamberStep4 = - new G4UnionSolid("TiaraChamber", solidTiaraChamberStep3, solidOuterCylinder, - new G4RotationMatrix, - G4ThreeVector(0,0,-CHAMBER_OuterCylinder_Z_Pos)); + new G4UnionSolid("TiaraChamber", solidTiaraChamberStep3, solidOuterCylinder, new G4RotationMatrix, + G4ThreeVector(0, 0, -CHAMBER_OuterCylinder_Z_Pos)); // Create Logic Volume G4LogicalVolume* logicTiaraChamber = - new G4LogicalVolume(solidTiaraChamberStep4,m_MaterialAl,"logicTiaraChamber", 0, 0, 0); + new G4LogicalVolume(solidTiaraChamberStep4, m_MaterialAl, "logicTiaraChamber", 0, 0, 0); // Visual Attribute - G4VisAttributes* ChamberVisAtt - = new G4VisAttributes(G4Colour(0.0,0.4,0.5,0.2)); + G4VisAttributes* ChamberVisAtt = new G4VisAttributes(G4Colour(0.0, 0.4, 0.5, 0.2)); logicTiaraChamber->SetVisAttributes(ChamberVisAtt); // Place the whole chamber - new G4PVPlacement(new G4RotationMatrix(0,0,0), G4ThreeVector(0,0,0), - logicTiaraChamber,"TiaraChamber",world,false,0); - + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicTiaraChamber, "TiaraChamber", world, + false, 0); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Tiara::InitializeMaterial(){ +void Tiara::InitializeMaterial() { m_MaterialSilicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); m_MaterialAl = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); m_MaterialPCB = MaterialManager::getInstance()->GetMaterialFromLibrary("PCB"); @@ -889,20 +779,18 @@ void Tiara::InitializeMaterial(){ //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* Tiara::Construct(){ - return (NPS::VDetector*) new Tiara(); -} +NPS::VDetector* Tiara::Construct() { return (NPS::VDetector*)new Tiara(); } //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern "C"{ -class proxy_nps_tiara{ - public: - proxy_nps_tiara(){ - NPS::DetectorFactory::getInstance()->AddToken("Tiara","Tiara"); - NPS::DetectorFactory::getInstance()->AddDetector("Tiara",Tiara::Construct); - } +extern "C" { +class proxy_nps_tiara { + public: + proxy_nps_tiara() { + NPS::DetectorFactory::getInstance()->AddToken("Tiara", "Tiara"); + NPS::DetectorFactory::getInstance()->AddDetector("Tiara", Tiara::Construct); + } }; proxy_nps_tiara p_nps_tiara; diff --git a/NPSimulation/Detectors/Tigress/Tigress.cc b/NPSimulation/Detectors/Tigress/Tigress.cc index 2e73ef568..10339bea2 100644 --- a/NPSimulation/Detectors/Tigress/Tigress.cc +++ b/NPSimulation/Detectors/Tigress/Tigress.cc @@ -20,44 +20,43 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> -//G4 Geometry object +#include <sstream> +// G4 Geometry object #include "G4Box.hh" -#include "G4Tubs.hh" -#include "G4Trd.hh" -#include "G4Trap.hh" #include "G4Cons.hh" +#include "G4Trap.hh" +#include "G4Trd.hh" +#include "G4Tubs.hh" -//G4 sensitive -#include "G4SDManager.hh" +// G4 sensitive #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" -//G4 various object +// G4 various object +#include "G4Colour.hh" +#include "G4IntersectionSolid.hh" +#include "G4LogicalVolume.hh" #include "G4Material.hh" +#include "G4PVPlacement.hh" #include "G4Polycone.hh" #include "G4Polyhedra.hh" -#include "G4LogicalVolume.hh" -#include "G4ThreeVector.hh" -#include "G4Transform3D.hh" #include "G4RotationMatrix.hh" -#include "G4PVPlacement.hh" -#include "G4VisAttributes.hh" -#include "G4Colour.hh" #include "G4RunManager.hh" -#include "G4ios.hh" #include "G4SubtractionSolid.hh" -#include "G4IntersectionSolid.hh" -#include "G4UnionSolid.hh" #include "G4ThreeVector.hh" +#include "G4Transform3D.hh" +#include "G4UnionSolid.hh" +#include "G4VisAttributes.hh" +#include "G4ios.hh" // NPS -#include "Tigress.hh" -#include "TigressScorers.hh" #include "MaterialManager.hh" #include "NPSDetectorFactory.hh" #include "NPSHitsMap.hh" +#include "Tigress.hh" +#include "TigressScorers.hh" // NPL #include "NPOptionManager.h" @@ -75,92 +74,89 @@ namespace { // Ge crystal // Cylindrical part - const G4double CrystalOuterRadius = 30.0*mm; // outer radius for crystal - const G4double CrystalInnerRadius = 5.0*mm; // inner radius for hole in crystal - const G4double CrystalLength = 90.0*mm; // crystal length - const G4double CrystalHoleDepth = 15.0*mm; // depth at which starts the hole - //const G4double CrystaHoleRadius = 0*cm; - //const G4double CrystalInterDistance = 0.6*mm; // Distance between two crystal + const G4double CrystalOuterRadius = 30.0 * mm; // outer radius for crystal + const G4double CrystalInnerRadius = 5.0 * mm; // inner radius for hole in crystal + const G4double CrystalLength = 90.0 * mm; // crystal length + const G4double CrystalHoleDepth = 15.0 * mm; // depth at which starts the hole + // const G4double CrystaHoleRadius = 0*cm; + // const G4double CrystalInterDistance = 0.6*mm; // Distance between two crystal // Squared part - const G4double CrystalWidth = 56.5*mm; // Width of one crystal + const G4double CrystalWidth = 56.5 * mm; // Width of one crystal // Exogam Stuff - const G4double CrystalEdgeOffset1 = 26.0*mm; // distance of the edge from the center of the crystal - const G4double CrystalEdgeOffset2 = 28.5*mm; // distance of the edge from the center of the crystal + const G4double CrystalEdgeOffset1 = 26.0 * mm; // distance of the edge from the center of the crystal + const G4double CrystalEdgeOffset2 = 28.5 * mm; // distance of the edge from the center of the crystal - const G4double CapsuleWidth = 1.5*mm; // capsule width - const G4double CapsuleLength = 110.*mm; // capsule length - const G4double CapsuleEdgeDepth = 3.3*cm; // same as crystal ! - const G4double CrystalToCapsule = 7*mm; // to be adjusted .. + const G4double CapsuleWidth = 1.5 * mm; // capsule width + const G4double CapsuleLength = 110. * mm; // capsule length + const G4double CapsuleEdgeDepth = 3.3 * cm; // same as crystal ! + const G4double CrystalToCapsule = 7 * mm; // to be adjusted .. - //const G4double BGOLength = 120.0*mm; - //const G4double BGOWidth = 25.0*mm; + // const G4double BGOLength = 120.0*mm; + // const G4double BGOWidth = 25.0*mm; - //const G4double CsILength = 20.0*mm; -} + // const G4double CsILength = 20.0*mm; +} // namespace //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Tigress Specific Method -Tigress::Tigress(){ +Tigress::Tigress() { InitializeMaterial(); m_TigressData = new TTigressData(); - BlueVisAtt = new G4VisAttributes(G4Colour(0, 0, 1)) ; - GreenVisAtt = new G4VisAttributes(G4Colour(0, 1, 0)) ; - RedVisAtt = new G4VisAttributes(G4Colour(1, 0, 0)) ; - WhiteVisAtt = new G4VisAttributes(G4Colour(1, 1, 1)) ; - TrGreyVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5, 0.5)) ; + BlueVisAtt = new G4VisAttributes(G4Colour(0, 0, 1)); + GreenVisAtt = new G4VisAttributes(G4Colour(0, 1, 0)); + RedVisAtt = new G4VisAttributes(G4Colour(1, 0, 0)); + WhiteVisAtt = new G4VisAttributes(G4Colour(1, 1, 1)); + TrGreyVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5, 0.5)); m_LogicClover = 0; - } -Tigress::~Tigress(){ - delete m_MaterialVacuum; -} +Tigress::~Tigress() { delete m_MaterialVacuum; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Tigress::ReadConfiguration(NPL::InputParser parser){ - - vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithTokenAndValue("Tigress","Clover"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " free clovers found " << endl; - - vector<string> token = {"CloverID","R","Theta","Phi","Beta"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(token)){ - double R = blocks[i]->GetDouble("R","mm"); - double Theta = blocks[i]->GetDouble("Theta","deg"); - double Phi = blocks[i]->GetDouble("Phi","deg"); - vector<double> beta = blocks[i]->GetVectorDouble("Beta","deg"); - int id = blocks[i]->GetInt("CloverID"); - AddCloverFreePosition(id,R,Theta,Phi,beta[0],beta[1],beta[2]); +void Tigress::ReadConfiguration(NPL::InputParser parser) { + + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithTokenAndValue("Tigress", "Clover"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " free clovers found " << endl; + + vector<string> token = {"CloverID", "R", "Theta", "Phi", "Beta"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(token)) { + double R = blocks[i]->GetDouble("R", "mm"); + double Theta = blocks[i]->GetDouble("Theta", "deg"); + double Phi = blocks[i]->GetDouble("Phi", "deg"); + vector<double> beta = blocks[i]->GetVectorDouble("Beta", "deg"); + int id = blocks[i]->GetInt("CloverID"); + AddCloverFreePosition(id, R, Theta, Phi, beta[0], beta[1], beta[2]); } - else{ + else { cout << "Warning: check your input file formatting " << endl; } } blocks.clear(); - blocks = parser.GetAllBlocksWithTokenAndValue("Tigress","Standard"); - token.clear(); + blocks = parser.GetAllBlocksWithTokenAndValue("Tigress", "Standard"); + token.clear(); token = {"CloverID"}; - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(token)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// Standard clovers found " << endl; + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(token)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// Standard clovers found " << endl; vector<int> id = blocks[i]->GetVectorInt("CloverID"); - + AddCloverStandard(id); } - else{ + else { cout << "Warning: check your input file formatting " << endl; } } @@ -168,177 +164,175 @@ void Tigress::ReadConfiguration(NPL::InputParser parser){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Return a G4VSolid modeling the Crystal -G4LogicalVolume* Tigress::ConstructCrystal(){ - G4Tubs* Crystal_Cylinder = new G4Tubs("Crystal_Cylinder", 0, CrystalOuterRadius, CrystalLength*0.5, 0, 2*M_PI); +G4LogicalVolume* Tigress::ConstructCrystal() { + G4Tubs* Crystal_Cylinder = new G4Tubs("Crystal_Cylinder", 0, CrystalOuterRadius, CrystalLength * 0.5, 0, 2 * M_PI); // Central Hole for cold finger - G4RotationMatrix* BoxRotation = new G4RotationMatrix(0,0,0); - G4Tubs* Crystal_Hole = new G4Tubs("Crystal_Hole", 0, CrystalInnerRadius, (CrystalLength-CrystalHoleDepth)*0.5, 0, 2*M_PI); - G4SubtractionSolid* Crystal_Stage1 = new G4SubtractionSolid("Crystal_Stage1",Crystal_Cylinder,Crystal_Hole,BoxRotation,G4ThreeVector(0,0,CrystalHoleDepth)); + G4RotationMatrix* BoxRotation = new G4RotationMatrix(0, 0, 0); + G4Tubs* Crystal_Hole = + new G4Tubs("Crystal_Hole", 0, CrystalInnerRadius, (CrystalLength - CrystalHoleDepth) * 0.5, 0, 2 * M_PI); + G4SubtractionSolid* Crystal_Stage1 = new G4SubtractionSolid("Crystal_Stage1", Crystal_Cylinder, Crystal_Hole, + BoxRotation, G4ThreeVector(0, 0, CrystalHoleDepth)); // Flat surface on the side - G4Box* Crystal_Box1 = new G4Box("Crystal_Box1", CrystalWidth*0.6, CrystalWidth*0.6,CrystalLength*0.6); - G4SubtractionSolid* Crystal_Stage2 = new G4SubtractionSolid("Crystal_Stage2",Crystal_Stage1,Crystal_Box1,BoxRotation,G4ThreeVector(24.5+CrystalWidth*0.6,0,0)); - G4SubtractionSolid* Crystal_Stage3 = new G4SubtractionSolid("Crystal_Stage3",Crystal_Stage2,Crystal_Box1,BoxRotation,G4ThreeVector(-29-CrystalWidth*0.6,0,0)); - G4SubtractionSolid* Crystal_Stage4 = new G4SubtractionSolid("Crystal_Stage4",Crystal_Stage3,Crystal_Box1,BoxRotation,G4ThreeVector(0,29+CrystalWidth*0.6,0)); - G4SubtractionSolid* Crystal_Stage5 = new G4SubtractionSolid("Crystal_Stage5",Crystal_Stage4,Crystal_Box1,BoxRotation,G4ThreeVector(0,-24.5-CrystalWidth*0.6,0)); + G4Box* Crystal_Box1 = new G4Box("Crystal_Box1", CrystalWidth * 0.6, CrystalWidth * 0.6, CrystalLength * 0.6); + G4SubtractionSolid* Crystal_Stage2 = new G4SubtractionSolid( + "Crystal_Stage2", Crystal_Stage1, Crystal_Box1, BoxRotation, G4ThreeVector(24.5 + CrystalWidth * 0.6, 0, 0)); + G4SubtractionSolid* Crystal_Stage3 = new G4SubtractionSolid( + "Crystal_Stage3", Crystal_Stage2, Crystal_Box1, BoxRotation, G4ThreeVector(-29 - CrystalWidth * 0.6, 0, 0)); + G4SubtractionSolid* Crystal_Stage4 = new G4SubtractionSolid( + "Crystal_Stage4", Crystal_Stage3, Crystal_Box1, BoxRotation, G4ThreeVector(0, 29 + CrystalWidth * 0.6, 0)); + G4SubtractionSolid* Crystal_Stage5 = new G4SubtractionSolid( + "Crystal_Stage5", Crystal_Stage4, Crystal_Box1, BoxRotation, G4ThreeVector(0, -24.5 - CrystalWidth * 0.6, 0)); // Bezel - G4RotationMatrix* BoxRotation1 = new G4RotationMatrix(0,0,0); - BoxRotation1->rotate(22.5*deg,G4ThreeVector(1,0,0)); - G4SubtractionSolid* Crystal_Stage6= new G4SubtractionSolid("Crystal_Stage6",Crystal_Stage5,Crystal_Box1,BoxRotation1,G4ThreeVector(0,20.54*mm+CrystalWidth*0.6,-45*mm)); - - G4RotationMatrix* BoxRotation2 = new G4RotationMatrix(0,0,0); - BoxRotation2->rotate(22.5*deg,G4ThreeVector(0,1,0)); - G4SubtractionSolid* Crystal_Stage7= new G4SubtractionSolid("Crystal_Stage7",Crystal_Stage6,Crystal_Box1,BoxRotation2,G4ThreeVector(-20.54*mm-CrystalWidth*0.6,0,-45*mm)); - - G4LogicalVolume* logicCrystal = - new G4LogicalVolume(Crystal_Stage7,m_MaterialGe,"LogicCrystal", 0, 0, 0); - - return logicCrystal; + G4RotationMatrix* BoxRotation1 = new G4RotationMatrix(0, 0, 0); + BoxRotation1->rotate(22.5 * deg, G4ThreeVector(1, 0, 0)); + G4SubtractionSolid* Crystal_Stage6 = + new G4SubtractionSolid("Crystal_Stage6", Crystal_Stage5, Crystal_Box1, BoxRotation1, + G4ThreeVector(0, 20.54 * mm + CrystalWidth * 0.6, -45 * mm)); + + G4RotationMatrix* BoxRotation2 = new G4RotationMatrix(0, 0, 0); + BoxRotation2->rotate(22.5 * deg, G4ThreeVector(0, 1, 0)); + G4SubtractionSolid* Crystal_Stage7 = + new G4SubtractionSolid("Crystal_Stage7", Crystal_Stage6, Crystal_Box1, BoxRotation2, + G4ThreeVector(-20.54 * mm - CrystalWidth * 0.6, 0, -45 * mm)); + + G4LogicalVolume* logicCrystal = new G4LogicalVolume(Crystal_Stage7, m_MaterialGe, "LogicCrystal", 0, 0, 0); + + return logicCrystal; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Return a G4VSolid modeling the Capsule -G4LogicalVolume* Tigress::ConstructCapsule(){ +G4LogicalVolume* Tigress::ConstructCapsule() { G4int nbslice = 7; - const G4double widthface = 45.5*mm; - G4double zSlice[7] = { 0.0*mm, - CapsuleWidth-0.1*mm, - CapsuleWidth, - CapsuleEdgeDepth, - CapsuleLength-CapsuleWidth, - CapsuleLength-CapsuleWidth-0.1*mm, - CapsuleLength }; - - G4double InnNullRad[7] = {0,0,0,0,0,0,0}; - - G4double InnRad[7] = { 0.0*mm, - 0.0*mm, - widthface-CapsuleWidth, - CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule - CapsuleWidth, - CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule - CapsuleWidth, - 0.0*mm, - 0.0*mm}; - - G4double OutRad[7] = { widthface-1.5*mm, - widthface, - widthface, - CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule, - CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule, - CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule, - CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule}; + const G4double widthface = 45.5 * mm; + G4double zSlice[7] = {0.0 * mm, CapsuleWidth - 0.1 * mm, CapsuleWidth, + CapsuleEdgeDepth, CapsuleLength - CapsuleWidth, CapsuleLength - CapsuleWidth - 0.1 * mm, + CapsuleLength}; + + G4double InnNullRad[7] = {0, 0, 0, 0, 0, 0, 0}; + + G4double InnRad[7] = {0.0 * mm, + 0.0 * mm, + widthface - CapsuleWidth, + CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule - CapsuleWidth, + CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule - CapsuleWidth, + 0.0 * mm, + 0.0 * mm}; + + G4double OutRad[7] = {widthface - 1.5 * mm, + widthface, + widthface, + CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule, + CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule, + CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule, + CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule}; // The whole volume of the Capsule, made of N2 - G4Polyhedra* caps = new G4Polyhedra(G4String("Capsule"), 45.*deg, 360.*deg, 4, nbslice, zSlice, InnNullRad, OutRad); - G4LogicalVolume* LogicCapsule= - new G4LogicalVolume(caps,m_MaterialN2,"LogicCapsule", 0, 0, 0); - LogicCapsule->SetVisAttributes(G4VisAttributes::Invisible); + G4Polyhedra* caps = + new G4Polyhedra(G4String("Capsule"), 45. * deg, 360. * deg, 4, nbslice, zSlice, InnNullRad, OutRad); + G4LogicalVolume* LogicCapsule = new G4LogicalVolume(caps, m_MaterialN2, "LogicCapsule", 0, 0, 0); + LogicCapsule->SetVisAttributes(G4VisAttributes::GetInvisible()); // The wall of the Capsule made of Al - G4Polyhedra* capsWall = new G4Polyhedra(G4String("CapsuleWall"), 45.*deg, 360.*deg, 4, nbslice, zSlice, InnRad, OutRad); - G4LogicalVolume* logicCapsuleWall = - new G4LogicalVolume(capsWall,m_MaterialAl,"LogicCapsuleWall", 0, 0, 0); + G4Polyhedra* capsWall = + new G4Polyhedra(G4String("CapsuleWall"), 45. * deg, 360. * deg, 4, nbslice, zSlice, InnRad, OutRad); + G4LogicalVolume* logicCapsuleWall = new G4LogicalVolume(capsWall, m_MaterialAl, "LogicCapsuleWall", 0, 0, 0); - new G4PVPlacement(G4Transform3D(*(new G4RotationMatrix()), G4ThreeVector(0,0,0)), - logicCapsuleWall,"CapsuleWall",LogicCapsule,false,1); + new G4PVPlacement(G4Transform3D(*(new G4RotationMatrix()), G4ThreeVector(0, 0, 0)), logicCapsuleWall, "CapsuleWall", + LogicCapsule, false, 1); logicCapsuleWall->SetVisAttributes(TrGreyVisAtt); return LogicCapsule; - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Tigress::ConstructDewar(){ - G4Tubs* DewarSolid = new G4Tubs("DewarSolid",0,90*mm*0.5,90*mm*0.5,0,2*M_PI); - G4Tubs* DewarCFSolid = new G4Tubs("DewarCFSolid",0,45*mm*0.5,145*mm*0.5,0,2*M_PI); +G4LogicalVolume* Tigress::ConstructDewar() { + G4Tubs* DewarSolid = new G4Tubs("DewarSolid", 0, 90 * mm * 0.5, 90 * mm * 0.5, 0, 2 * M_PI); + G4Tubs* DewarCFSolid = new G4Tubs("DewarCFSolid", 0, 45 * mm * 0.5, 145 * mm * 0.5, 0, 2 * M_PI); + + G4UnionSolid* DewarFull = new G4UnionSolid("Dewarfull", DewarSolid, DewarCFSolid, new G4RotationMatrix(), + G4ThreeVector(0, 0, -90 * mm - (145 - 90) * 0.5 * mm)); - G4UnionSolid* DewarFull = - new G4UnionSolid("Dewarfull", DewarSolid, DewarCFSolid, new G4RotationMatrix(),G4ThreeVector(0,0,-90*mm-(145-90)*0.5*mm)); + G4LogicalVolume* LogicDewar = new G4LogicalVolume(DewarFull, m_MaterialAl, "LogicDewar", 0, 0, 0); - G4LogicalVolume* LogicDewar = new G4LogicalVolume(DewarFull,m_MaterialAl,"LogicDewar",0,0,0); + G4Tubs* N2Solid = new G4Tubs("N2Solid", 0, 90 * mm * 0.5 - 1 * mm, 90 * mm * 0.5 - 1 * mm, 0, 2 * M_PI); + G4Tubs* N2CFSolid = new G4Tubs("N2CFSolid", 0, 45 * mm * 0.5 - 1 * mm, 145 * mm * 0.5 - 1 * mm, 0, 2 * M_PI); - G4Tubs* N2Solid = new G4Tubs("N2Solid",0,90*mm*0.5-1*mm,90*mm*0.5-1*mm,0,2*M_PI); - G4Tubs* N2CFSolid = new G4Tubs("N2CFSolid",0,45*mm*0.5-1*mm,145*mm*0.5-1*mm,0,2*M_PI); + G4LogicalVolume* LogicN2 = new G4LogicalVolume(N2Solid, m_MaterialN2, "LogicN2", 0, 0, 0); + G4LogicalVolume* LogicN2CF = new G4LogicalVolume(N2CFSolid, m_MaterialN2, "LogicN2CF", 0, 0, 0); - G4LogicalVolume* LogicN2 = new G4LogicalVolume(N2Solid,m_MaterialN2,"LogicN2",0,0,0); - G4LogicalVolume* LogicN2CF = new G4LogicalVolume(N2CFSolid,m_MaterialN2,"LogicN2CF",0,0,0); - LogicN2->SetVisAttributes(GreenVisAtt); LogicN2CF->SetVisAttributes(GreenVisAtt); - new G4PVPlacement(G4Transform3D(*(new G4RotationMatrix()), G4ThreeVector(0,0,0)), - LogicN2,"N2 Deware",LogicDewar,false,1); - - //new G4PVPlacement(G4Transform3D(*(new G4RotationMatrix()), G4ThreeVector(0,0,-90*mm)), - // LogicN2CF,"N2 Deware",LogicDewar,false,1); + new G4PVPlacement(G4Transform3D(*(new G4RotationMatrix()), G4ThreeVector(0, 0, 0)), LogicN2, "N2 Deware", LogicDewar, + false, 1); + + // new G4PVPlacement(G4Transform3D(*(new G4RotationMatrix()), G4ThreeVector(0,0,-90*mm)), + // LogicN2CF,"N2 Deware",LogicDewar,false,1); LogicDewar->SetVisAttributes(TrGreyVisAtt); return LogicDewar; } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Return a G4VSolid modeling the BGO -G4LogicalVolume* Tigress::ConstructBGO(){ - - return NULL; - -} +G4LogicalVolume* Tigress::ConstructBGO() { return NULL; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Return a clover in the configuration given by option (not use a the moment) -void Tigress::ConstructClover(){ - if(m_LogicClover==0){ +void Tigress::ConstructClover() { + if (m_LogicClover == 0) { // Construct the clover itself m_LogicClover = ConstructCapsule(); - + // Place the cristal in the clover - double CrystalOffset = (24.5*mm+0.5*mm); + double CrystalOffset = (24.5 * mm + 0.5 * mm); G4LogicalVolume* logicCrystal = ConstructCrystal(); - G4RotationMatrix* CrystalRotation = new G4RotationMatrix(0,0,0); - G4ThreeVector CrystalPositionB = G4ThreeVector(-CrystalOffset,+CrystalOffset,0.5*CrystalLength+7*mm); - new G4PVPlacement(G4Transform3D(*CrystalRotation, CrystalPositionB), - logicCrystal,"LogicCrystalB",m_LogicClover,false,1); + G4RotationMatrix* CrystalRotation = new G4RotationMatrix(0, 0, 0); + G4ThreeVector CrystalPositionB = G4ThreeVector(-CrystalOffset, +CrystalOffset, 0.5 * CrystalLength + 7 * mm); + new G4PVPlacement(G4Transform3D(*CrystalRotation, CrystalPositionB), logicCrystal, "LogicCrystalB", m_LogicClover, + false, 1); logicCrystal->SetVisAttributes(BlueVisAtt); - CrystalRotation->rotate(-90*deg, G4ThreeVector(0,0,1)); - G4ThreeVector CrystalPositionG = G4ThreeVector(+CrystalOffset,+CrystalOffset,0.5*CrystalLength+7*mm); - new G4PVPlacement(G4Transform3D(*CrystalRotation, CrystalPositionG), - logicCrystal,"LogicCrystalG",m_LogicClover,false,2); - - CrystalRotation->rotate(-90*deg, G4ThreeVector(0,0,1)); - G4ThreeVector CrystalPositionR = G4ThreeVector(+CrystalOffset,-CrystalOffset,0.5*CrystalLength+7*mm); - new G4PVPlacement(G4Transform3D(*CrystalRotation, CrystalPositionR), - logicCrystal,"LogicCrystalR",m_LogicClover,false,3); + CrystalRotation->rotate(-90 * deg, G4ThreeVector(0, 0, 1)); + G4ThreeVector CrystalPositionG = G4ThreeVector(+CrystalOffset, +CrystalOffset, 0.5 * CrystalLength + 7 * mm); + new G4PVPlacement(G4Transform3D(*CrystalRotation, CrystalPositionG), logicCrystal, "LogicCrystalG", m_LogicClover, + false, 2); - CrystalRotation->rotate(-90*deg, G4ThreeVector(0,0,1)); - G4ThreeVector CrystalPositionW = G4ThreeVector(-CrystalOffset,-CrystalOffset,0.5*CrystalLength+7*mm); - new G4PVPlacement(G4Transform3D(*CrystalRotation, CrystalPositionW), - logicCrystal,"LogicCrystalW",m_LogicClover,false,4); + CrystalRotation->rotate(-90 * deg, G4ThreeVector(0, 0, 1)); + G4ThreeVector CrystalPositionR = G4ThreeVector(+CrystalOffset, -CrystalOffset, 0.5 * CrystalLength + 7 * mm); + new G4PVPlacement(G4Transform3D(*CrystalRotation, CrystalPositionR), logicCrystal, "LogicCrystalR", m_LogicClover, + false, 3); - logicCrystal->SetSensitiveDetector(m_HPGeScorer); - // m_LogicClover->SetSensitiveDetector(m_HPGeScorer); - } + CrystalRotation->rotate(-90 * deg, G4ThreeVector(0, 0, 1)); + G4ThreeVector CrystalPositionW = G4ThreeVector(-CrystalOffset, -CrystalOffset, 0.5 * CrystalLength + 7 * mm); + new G4PVPlacement(G4Transform3D(*CrystalRotation, CrystalPositionW), logicCrystal, "LogicCrystalW", m_LogicClover, + false, 4); + logicCrystal->SetSensitiveDetector(m_HPGeScorer); + // m_LogicClover->SetSensitiveDetector(m_HPGeScorer); + } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void Tigress::ConstructDetector(G4LogicalVolume* world){ +void Tigress::ConstructDetector(G4LogicalVolume* world) { ConstructClover(); - G4RotationMatrix* DetectorRotation = new G4RotationMatrix(0,0,0); - for (unsigned int i = 0 ; i < m_CloverId.size(); i++) { + G4RotationMatrix* DetectorRotation = new G4RotationMatrix(0, 0, 0); + for (unsigned int i = 0; i < m_CloverId.size(); i++) { // Constructing the Detector referential and the transition matrix - G4ThreeVector U,V,W; - G4double wX = sin(m_Theta[i]) * cos(m_Phi[i]) ; - G4double wY = sin(m_Theta[i]) * sin(m_Phi[i]) ; + G4ThreeVector U, V, W; + G4double wX = sin(m_Theta[i]) * cos(m_Phi[i]); + G4double wY = sin(m_Theta[i]) * sin(m_Phi[i]); G4double wZ = cos(m_Theta[i]); - W = G4ThreeVector(wX, wY, wZ) ; + W = G4ThreeVector(wX, wY, wZ); // vector parallel to one axis of the entrance plane G4double vX = cos(m_Theta[i]) * cos(m_Phi[i]); @@ -358,194 +352,193 @@ void Tigress::ConstructDetector(G4LogicalVolume* world){ DetectorRotation->rotate(m_BetaX[i], U); DetectorRotation->rotate(m_BetaY[i], V); DetectorRotation->rotate(m_BetaZ[i], W); - G4ThreeVector DetectorPosition = m_R[i]*W; - - new G4PVPlacement(G4Transform3D(*DetectorRotation, DetectorPosition), - m_LogicClover,"Clover",world,false,m_CloverId[i]); - - G4LogicalVolume* LogicDewar = ConstructDewar(); - - new G4PVPlacement(G4Transform3D(*DetectorRotation, DetectorPosition+W*((90*mm+(145)*mm)+CapsuleLength*0.5+90*0.5*mm)), - LogicDewar,"Dewar",world,false,m_CloverId[i]); + G4ThreeVector DetectorPosition = m_R[i] * W; + new G4PVPlacement(G4Transform3D(*DetectorRotation, DetectorPosition), m_LogicClover, "Clover", world, false, + m_CloverId[i]); + G4LogicalVolume* LogicDewar = ConstructDewar(); + + new G4PVPlacement(G4Transform3D(*DetectorRotation, DetectorPosition + W * ((90 * mm + (145) * mm) + + CapsuleLength * 0.5 + 90 * 0.5 * mm)), + LogicDewar, "Dewar", world, false, m_CloverId[i]); } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add clover at the standard position of the array // Take as argument the standard clover Id. -void Tigress::AddCloverStandard(vector<int> CloverId){ +void Tigress::AddCloverStandard(vector<int> CloverId) { - for (unsigned int i = 0 ; i < CloverId.size(); i++) { - if(CloverId[i] == 1 ){ + for (unsigned int i = 0; i < CloverId.size(); i++) { + if (CloverId[i] == 1) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(45*deg); - m_Phi.push_back(22.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(45 * deg); + m_Phi.push_back(22.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); m_BetaZ.push_back(0); } - else if(CloverId[i] == 2 ){ + else if (CloverId[i] == 2) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(45*deg); - m_Phi.push_back(112.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(45 * deg); + m_Phi.push_back(112.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); m_BetaZ.push_back(0); } - else if(CloverId[i] == 3 ){ + else if (CloverId[i] == 3) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(45*deg); - m_Phi.push_back(202.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(45 * deg); + m_Phi.push_back(202.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); m_BetaZ.push_back(0); } - else if(CloverId[i] == 4 ){ + else if (CloverId[i] == 4) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(45*deg); - m_Phi.push_back(292.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(45 * deg); + m_Phi.push_back(292.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); m_BetaZ.push_back(0); } - else if(CloverId[i] == 5 ){ + else if (CloverId[i] == 5) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(90*deg); - m_Phi.push_back(22.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(90 * deg); + m_Phi.push_back(22.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 6 ){ + else if (CloverId[i] == 6) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(90*deg); - m_Phi.push_back(67.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(90 * deg); + m_Phi.push_back(67.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 7 ){ + else if (CloverId[i] == 7) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(90*deg); - m_Phi.push_back(112.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(90 * deg); + m_Phi.push_back(112.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 8 ){ + else if (CloverId[i] == 8) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(90*deg); - m_Phi.push_back(157.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(90 * deg); + m_Phi.push_back(157.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 9 ){ + else if (CloverId[i] == 9) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(90*deg); - m_Phi.push_back(202.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(90 * deg); + m_Phi.push_back(202.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 10 ){ + else if (CloverId[i] == 10) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(90*deg); - m_Phi.push_back(247.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(90 * deg); + m_Phi.push_back(247.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 11 ){ + else if (CloverId[i] == 11) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(90*deg); - m_Phi.push_back(292.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(90 * deg); + m_Phi.push_back(292.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 12 ){ + else if (CloverId[i] == 12) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(90*deg); - m_Phi.push_back(337.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(90 * deg); + m_Phi.push_back(337.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 13 ){ + else if (CloverId[i] == 13) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(135*deg); - m_Phi.push_back(22.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(135 * deg); + m_Phi.push_back(22.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 14 ){ + else if (CloverId[i] == 14) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(135*deg); - m_Phi.push_back(112.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(135 * deg); + m_Phi.push_back(112.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 15 ){ + else if (CloverId[i] == 15) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(135*deg); - m_Phi.push_back(202.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(135 * deg); + m_Phi.push_back(202.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 16 ){ + else if (CloverId[i] == 16) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(135*deg); - m_Phi.push_back(292.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(135 * deg); + m_Phi.push_back(292.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } } - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add clover at a free position in space with coordinate // in spherical coordinate // Beta are the three angles of rotation in the Clover frame -void Tigress::AddCloverFreePosition(int CloverId,double R,double Theta,double Phi,double BetaX,double BetaY,double BetaZ){ +void Tigress::AddCloverFreePosition(int CloverId, double R, double Theta, double Phi, double BetaX, double BetaY, + double BetaZ) { m_CloverId.push_back(CloverId); m_R.push_back(R); @@ -554,116 +547,113 @@ void Tigress::AddCloverFreePosition(int CloverId,double R,double Theta,double Ph m_BetaX.push_back(BetaX); m_BetaY.push_back(BetaY); m_BetaZ.push_back(BetaZ); - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void Tigress::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("Tigress")){ - pTree->Branch("Tigress", "TTigressData", &m_TigressData) ; +void Tigress::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("Tigress")) { + pTree->Branch("Tigress", "TTigressData", &m_TigressData); } - pTree->SetBranchAddress("Tigress", &m_TigressData) ; + pTree->SetBranchAddress("Tigress", &m_TigressData); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Tigress::ReadSensitive(const G4Event* event){ +void Tigress::ReadSensitive(const G4Event* event) { m_TigressData->Clear(); /////////// // HPGE - NPS::HitsMap<G4double*>* HPGEHitMap; - std::map<G4int, G4double**>::iterator HPGE_itr; + NPS::HitsMap<G4double*>* HPGEHitMap; + std::map<G4int, G4double**>::iterator HPGE_itr; G4int HPGECollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("Tigress_Scorer/Tigress"); - if(HPGECollectionID == -1) { - G4cerr << "ERROR: No Collection found for HPGeScorer: Skipping processing of HPGe Hit" << G4endl; - return; - } + if (HPGECollectionID == -1) { + G4cerr << "ERROR: No Collection found for HPGeScorer: Skipping processing of HPGe Hit" << G4endl; + return; + } HPGEHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(HPGECollectionID)); // Loop on the HPGE map - /* for (HPGE_itr = HPGEHitMap->GetMap()->begin() ; HPGE_itr != HPGEHitMap->GetMap()->end() ; HPGE_itr++){ - - G4double* Info = *(HPGE_itr->second); - - G4double Energy = Info[0]; // RandGauss::shoot(Info[0], ResoEnergy/2.334); - G4double Time = Info[1]; - G4int CloverNbr = (int)Info[7]; - G4int CrystalNbr = (int)Info[8]; - - // Figure out segment number, in progress - G4int SegmentNbr = 0; - G4double zpos = Info[4]; // mm - if(fabs(zpos) < 10) { SegmentNbr = 2; } // MIDDLE - else if(CrystalNbr == 1 || CrystalNbr == 4) { SegmentNbr = 1; } // RIGHT - else { SegmentNbr = 3; } // LEFT - - //m_TigressData->SetCoreE(CloverNbr, CrystalNbr, Energy/keV); - //m_TigressData->SetCoreT(CloverNbr, CrystalNbr, Time/ns); - //m_TigressData->SetSegmentE(CloverNbr, SegmentNbr, Energy/keV); - //m_TigressData->SetSegmentT(CloverNbr, SegmentNbr, Time/keV); - } -*/ + /* for (HPGE_itr = HPGEHitMap->GetMap()->begin() ; HPGE_itr != HPGEHitMap->GetMap()->end() ; HPGE_itr++){ + + G4double* Info = *(HPGE_itr->second); + + G4double Energy = Info[0]; // RandGauss::shoot(Info[0], ResoEnergy/2.334); + G4double Time = Info[1]; + G4int CloverNbr = (int)Info[7]; + G4int CrystalNbr = (int)Info[8]; + + // Figure out segment number, in progress + G4int SegmentNbr = 0; + G4double zpos = Info[4]; // mm + if(fabs(zpos) < 10) { SegmentNbr = 2; } // MIDDLE + else if(CrystalNbr == 1 || CrystalNbr == 4) { SegmentNbr = 1; } // RIGHT + else { SegmentNbr = 3; } // LEFT + + //m_TigressData->SetCoreE(CloverNbr, CrystalNbr, Energy/keV); + //m_TigressData->SetCoreT(CloverNbr, CrystalNbr, Time/ns); + //m_TigressData->SetSegmentE(CloverNbr, SegmentNbr, Energy/keV); + //m_TigressData->SetSegmentT(CloverNbr, SegmentNbr, Time/keV); + } + */ // clear map for next event HPGEHitMap->clear(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Tigress::InitializeScorers(){ - //Look for previous definition of the scorer (geometry reload) - //n.b. calls new G4MultiFunctionalDetector("Tigress_CoreScorer"); +void Tigress::InitializeScorers() { + // Look for previous definition of the scorer (geometry reload) + // n.b. calls new G4MultiFunctionalDetector("Tigress_CoreScorer"); bool already_exist = false; - m_HPGeScorer = CheckScorer("Tigress_Scorer",already_exist); + m_HPGeScorer = CheckScorer("Tigress_Scorer", already_exist); + + // if the scorer were created previously nothing else need to be made + if (already_exist) + return; - // if the scorer were created previously nothing else need to be made - if(already_exist) return; - // HPGe Associate Scorer - G4VPrimitiveScorer* HPGeScorer = new TIGRESSSCORERS::PS_Tigress("Tigress",0); + G4VPrimitiveScorer* HPGeScorer = new TIGRESSSCORERS::PS_Tigress("Tigress", 0); - //and register it to the multifunctionnal detector + // and register it to the multifunctionnal detector m_HPGeScorer->RegisterPrimitive(HPGeScorer); - // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_HPGeScorer) ; + // Add All Scorer to the Global Scorer Manager + G4SDManager::GetSDMpointer()->AddNewDetector(m_HPGeScorer); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //////////////////////////////////////////////////////////////// /////////////////Material Definition /////////////////////////// //////////////////////////////////////////////////////////////// -void Tigress::InitializeMaterial(){ +void Tigress::InitializeMaterial() { m_MaterialVacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); - m_MaterialGe= MaterialManager::getInstance()->GetMaterialFromLibrary("Ge"); - m_MaterialAl= MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); - m_MaterialN2= MaterialManager::getInstance()->GetMaterialFromLibrary("N2_liquid"); + m_MaterialGe = MaterialManager::getInstance()->GetMaterialFromLibrary("Ge"); + m_MaterialAl = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); + m_MaterialN2 = MaterialManager::getInstance()->GetMaterialFromLibrary("N2_liquid"); } - //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* Tigress::Construct(){ - return (NPS::VDetector*) new Tigress(); -} +NPS::VDetector* Tigress::Construct() { return (NPS::VDetector*)new Tigress(); } //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_tigress{ - public: - proxy_nps_tigress(){ - NPS::DetectorFactory::getInstance()->AddToken("Tigress","Tigress"); - NPS::DetectorFactory::getInstance()->AddDetector("Tigress",Tigress::Construct); - } - }; - - proxy_nps_tigress p_nps_tigress; +extern "C" { +class proxy_nps_tigress { + public: + proxy_nps_tigress() { + NPS::DetectorFactory::getInstance()->AddToken("Tigress", "Tigress"); + NPS::DetectorFactory::getInstance()->AddDetector("Tigress", Tigress::Construct); + } +}; + +proxy_nps_tigress p_nps_tigress; } diff --git a/NPSimulation/Detectors/W1/W1.cc b/NPSimulation/Detectors/W1/W1.cc index 87bb907f5..a6916ea15 100644 --- a/NPSimulation/Detectors/W1/W1.cc +++ b/NPSimulation/Detectors/W1/W1.cc @@ -20,36 +20,36 @@ *****************************************************************************/ // C++ headers +#include <cmath> #include <sstream> #include <string> -#include <cmath> // G4 Geometry headers #include "G4Box.hh" #include "G4Tubs.hh" // G4 various headers -#include "G4Material.hh" -#include "G4VisAttributes.hh" #include "G4Colour.hh" +#include "G4Material.hh" +#include "G4PVDivision.hh" +#include "G4PVPlacement.hh" #include "G4RotationMatrix.hh" #include "G4Transform3D.hh" -#include "G4PVPlacement.hh" -#include "G4PVDivision.hh" +#include "G4VisAttributes.hh" // G4 sensitive -#include "G4SDManager.hh" #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" // NPTool headers -#include "ObsoleteGeneralScorers.hh" #include "MaterialManager.hh" +#include "NPOptionManager.h" #include "NPSDetectorFactory.hh" +#include "ObsoleteGeneralScorers.hh" +#include "RootOutput.h" +#include "TW1Data.h" #include "W1.hh" #include "W1Scorers.hh" -#include "TW1Data.h" -#include "RootOutput.h" -#include "NPOptionManager.h" // CLHEP #include "CLHEP/Random/RandGauss.h" @@ -58,46 +58,27 @@ using namespace std; using namespace CLHEP; using namespace W1SQUARE; +W1::W1() : m_Event(new TW1Data) { InitializeMaterials(); } +W1::~W1() { delete m_Event; } -W1::W1() - : m_Event(new TW1Data) -{ - InitializeMaterials(); -} +void W1::AddDetector(G4ThreeVector X1_Y1, G4ThreeVector X16_Y1, G4ThreeVector X1_Y16, G4ThreeVector X16_Y16) { + m_DefinitionType.push_back(true); + m_X1_Y1.push_back(X1_Y1); + m_X16_Y1.push_back(X16_Y1); + m_X1_Y16.push_back(X1_Y16); + m_X16_Y16.push_back(X16_Y16); - -W1::~W1() -{ - delete m_Event; + m_R.push_back(0); + m_Theta.push_back(0); + m_Phi.push_back(0); + m_beta_u.push_back(0); + m_beta_v.push_back(0); + m_beta_w.push_back(0); } - - -void W1::AddDetector(G4ThreeVector X1_Y1, G4ThreeVector X16_Y1, - G4ThreeVector X1_Y16, G4ThreeVector X16_Y16) -{ - m_DefinitionType.push_back(true); - - m_X1_Y1.push_back(X1_Y1); - m_X16_Y1.push_back(X16_Y1); - m_X1_Y16.push_back(X1_Y16); - m_X16_Y16.push_back(X16_Y16); - - m_R.push_back(0); - m_Theta.push_back(0); - m_Phi.push_back(0); - m_beta_u.push_back(0); - m_beta_v.push_back(0); - m_beta_w.push_back(0); -} - - - -void W1::AddDetector(G4double R, G4double Theta, G4double Phi, - G4double beta_u, G4double beta_v, G4double beta_w) -{ +void W1::AddDetector(G4double R, G4double Theta, G4double Phi, G4double beta_u, G4double beta_v, G4double beta_w) { G4ThreeVector empty = G4ThreeVector(0, 0, 0); m_DefinitionType.push_back(false); @@ -113,104 +94,96 @@ void W1::AddDetector(G4double R, G4double Theta, G4double Phi, m_X16_Y1.push_back(empty); m_X1_Y16.push_back(empty); m_X16_Y16.push_back(empty); - } +void W1::VolumeMaker(G4int DetecNumber, G4ThreeVector position, G4RotationMatrix* rotation, G4LogicalVolume* world) { + G4double NbrTelescopes = DetecNumber; + G4String DetectorNumber; + ostringstream Number; + Number << NbrTelescopes; + DetectorNumber = Number.str(); + //////////////////////////////////////////////////////////////// + ////////////// Starting Volume Definition ////////////////////// + //////////////////////////////////////////////////////////////// + G4String Name = "W1Square" + DetectorNumber; -void W1::VolumeMaker(G4int DetecNumber, - G4ThreeVector position, - G4RotationMatrix* rotation, - G4LogicalVolume* world) -{ - G4double NbrTelescopes = DetecNumber; - G4String DetectorNumber; - ostringstream Number; - Number << NbrTelescopes; - DetectorNumber = Number.str(); + // Definition of the volume containing the sensitive detector + G4Box* solidW1 = new G4Box(Name, 0.5 * FaceFront, 0.5 * FaceFront, 0.5 * Length); + G4LogicalVolume* logicW1 = new G4LogicalVolume(solidW1, m_MaterialVacuum, Name, 0, 0, 0); - //////////////////////////////////////////////////////////////// - ////////////// Starting Volume Definition ////////////////////// - //////////////////////////////////////////////////////////////// - G4String Name = "W1Square" + DetectorNumber; + new G4PVPlacement(G4Transform3D(*rotation, position), logicW1, Name, world, false, 0); - // Definition of the volume containing the sensitive detector - G4Box* solidW1 = new G4Box(Name, 0.5*FaceFront, 0.5*FaceFront, 0.5*Length); - G4LogicalVolume* logicW1 = new G4LogicalVolume(solidW1, m_MaterialVacuum, Name, 0, 0, 0); + logicW1->SetVisAttributes(G4VisAttributes::GetInvisible()); + if (m_non_sensitive_part_visiualisation) + logicW1->SetVisAttributes(G4VisAttributes(G4Colour(0.90, 0.90, 0.90))); - new G4PVPlacement(G4Transform3D(*rotation, position), logicW1, Name, world, false, 0); + // Aluminium dead layers + G4ThreeVector positionAluStripFront = G4ThreeVector(0, 0, AluStripFront_PosZ); + G4ThreeVector positionAluStripBack = G4ThreeVector(0, 0, AluStripBack_PosZ); - logicW1->SetVisAttributes(G4VisAttributes::Invisible); - if (m_non_sensitive_part_visiualisation) logicW1->SetVisAttributes(G4VisAttributes(G4Colour(0.90, 0.90, 0.90))); + G4Box* solidAluStrip = new G4Box("AluBox", 0.5 * SiliconFace, 0.5 * SiliconFace, 0.5 * AluStripThickness); + // G4LogicalVolume* logicAluStrip = new G4LogicalVolume(solidAluStrip, m_MaterialAluminium, "logicAluStrip", 0, 0, + // 0); + G4LogicalVolume* logicAluStrip = new G4LogicalVolume(solidAluStrip, m_MaterialVacuum, "logicAluStrip", 0, 0, 0); - // Aluminium dead layers - G4ThreeVector positionAluStripFront = G4ThreeVector(0, 0, AluStripFront_PosZ); - G4ThreeVector positionAluStripBack = G4ThreeVector(0, 0, AluStripBack_PosZ); + new G4PVPlacement(0, positionAluStripFront, logicAluStrip, Name + "_AluStripFront", logicW1, false, 0); + new G4PVPlacement(0, positionAluStripBack, logicAluStrip, Name + "_AluStripBack", logicW1, false, 0); - G4Box* solidAluStrip = new G4Box("AluBox", 0.5*SiliconFace, 0.5*SiliconFace, 0.5*AluStripThickness); -// G4LogicalVolume* logicAluStrip = new G4LogicalVolume(solidAluStrip, m_MaterialAluminium, "logicAluStrip", 0, 0, 0); - G4LogicalVolume* logicAluStrip = new G4LogicalVolume(solidAluStrip, m_MaterialVacuum, "logicAluStrip", 0, 0, 0); + logicAluStrip->SetVisAttributes(G4VisAttributes::GetInvisible()); - new G4PVPlacement(0, positionAluStripFront, logicAluStrip, Name + "_AluStripFront", logicW1, false, 0); - new G4PVPlacement(0, positionAluStripBack, logicAluStrip, Name + "_AluStripBack", logicW1, false, 0); + // Silicon detector itself + G4ThreeVector positionSilicon = G4ThreeVector(0, 0, Silicon_PosZ); - logicAluStrip->SetVisAttributes(G4VisAttributes::Invisible); + G4Box* solidSilicon = new G4Box("solidSilicon", 0.5 * SiliconFace, 0.5 * SiliconFace, 0.5 * SiliconThickness); + G4LogicalVolume* logicSilicon = new G4LogicalVolume(solidSilicon, m_MaterialSilicon, "logicSilicon", 0, 0, 0); - // Silicon detector itself - G4ThreeVector positionSilicon = G4ThreeVector(0, 0, Silicon_PosZ); + new G4PVPlacement(0, positionSilicon, logicSilicon, Name + "_Silicon", logicW1, false, 0); - G4Box* solidSilicon = new G4Box("solidSilicon", 0.5*SiliconFace, 0.5*SiliconFace, 0.5*SiliconThickness); - G4LogicalVolume* logicSilicon = new G4LogicalVolume(solidSilicon, m_MaterialSilicon, "logicSilicon", 0, 0, 0); + // Set Silicon strip sensible + logicSilicon->SetSensitiveDetector(m_Scorer); - new G4PVPlacement(0, positionSilicon, logicSilicon, Name + "_Silicon", logicW1, false, 0); - - // Set Silicon strip sensible - logicSilicon->SetSensitiveDetector(m_Scorer); - - ///Visualisation of Silicon Strip - G4VisAttributes* SiliconVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)); - logicSilicon->SetVisAttributes(SiliconVisAtt); + /// Visualisation of Silicon Strip + G4VisAttributes* SiliconVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)); + logicSilicon->SetVisAttributes(SiliconVisAtt); } - - // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void W1::ReadConfiguration(NPL::InputParser parser){ +void W1::ReadConfiguration(NPL::InputParser parser) { vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("W1"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " detectors found " << endl; - for(unsigned int i = 0 ; i < blocks.size() ; i++){ + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + for (unsigned int i = 0; i < blocks.size(); i++) { // Cartesian Case - vector<string> cart = {"X1_Y1","X1_Y16","X16_Y1","X16_Y16","VIS"}; + vector<string> cart = {"X1_Y1", "X1_Y16", "X16_Y1", "X16_Y16", "VIS"}; // Spherical Case - vector<string> sphe= {"R","THETA","PHI","BETA","VIS"}; - - if(blocks[i]->HasTokenList(cart)){ - cout << endl << "//// W1 " << i+1 << endl; - G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("X1_Y1","mm")); - G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("X16_Y1","mm")); - G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("X1_Y16","mm")); - G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("X16_Y16","mm")); - if(blocks[i]->GetInt("VIS")) + vector<string> sphe = {"R", "THETA", "PHI", "BETA", "VIS"}; + + if (blocks[i]->HasTokenList(cart)) { + cout << endl << "//// W1 " << i + 1 << endl; + G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("X1_Y1", "mm")); + G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("X16_Y1", "mm")); + G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("X1_Y16", "mm")); + G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("X16_Y16", "mm")); + if (blocks[i]->GetInt("VIS")) m_non_sensitive_part_visiualisation = true; - AddDetector(A,B,C,D) ; + AddDetector(A, B, C, D); } - else if(blocks[i]->HasTokenList(sphe)){ - cout << endl << "//// W1 " << i+1 << endl; - double Theta = blocks[i]->GetDouble("THETA","deg"); - double Phi= blocks[i]->GetDouble("PHI","deg"); - double R = blocks[i]->GetDouble("R","mm"); - vector<double> beta = blocks[i]->GetVectorDouble("BETA","deg"); - if(blocks[i]->GetInt("VIS")) + else if (blocks[i]->HasTokenList(sphe)) { + cout << endl << "//// W1 " << i + 1 << endl; + double Theta = blocks[i]->GetDouble("THETA", "deg"); + double Phi = blocks[i]->GetDouble("PHI", "deg"); + double R = blocks[i]->GetDouble("R", "mm"); + vector<double> beta = blocks[i]->GetVectorDouble("BETA", "deg"); + if (blocks[i]->GetInt("VIS")) m_non_sensitive_part_visiualisation = true; - AddDetector(Theta,Phi,R,beta[0],beta[1],beta[2]); - + AddDetector(Theta, Phi, R, beta[0], beta[1], beta[2]); } - else{ + else { cout << "ERROR: Missing token for W1 blocks, check your input file" << endl; exit(1); } @@ -219,396 +192,389 @@ void W1::ReadConfiguration(NPL::InputParser parser){ // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void W1::ConstructDetector(G4LogicalVolume* world) -{ - G4RotationMatrix* W1rot = NULL; - G4ThreeVector W1pos = G4ThreeVector(0, 0, 0) ; - G4ThreeVector W1u = G4ThreeVector(0, 0, 0) ; - G4ThreeVector W1v = G4ThreeVector(0, 0, 0) ; - G4ThreeVector W1w = G4ThreeVector(0, 0, 0) ; - G4ThreeVector W1Center = G4ThreeVector(0, 0, 0) ; - - G4int NumberOfDetector = m_DefinitionType.size() ; - for (G4int i = 0; i < NumberOfDetector; i++) { - // By Point - if (m_DefinitionType[i]) { - // (u,v,w) unitary vector associated to telescope referencial - // (u,v) // to silicon plan - // w perpendicular to (u,v) plan and pointing ThirdStage - W1u = m_X16_Y1[i] - m_X1_Y1[i]; - W1u = W1u.unit(); - - W1v = m_X1_Y16[i] - m_X1_Y1[i]; - W1v = W1v.unit(); - - W1w = W1u.cross(W1v); - W1w = W1w.unit(); - - W1Center = (m_X1_Y1[i] + m_X1_Y16[i] + m_X16_Y1[i] + m_X16_Y16[i]) / 4; - - // Passage Matrix from Lab Referential to Telescope Referential - W1rot = new G4RotationMatrix(W1u, W1v, W1w); - // translation to place Telescope - W1pos = W1w * Length * 0.5 + W1Center; - } +void W1::ConstructDetector(G4LogicalVolume* world) { + G4RotationMatrix* W1rot = NULL; + G4ThreeVector W1pos = G4ThreeVector(0, 0, 0); + G4ThreeVector W1u = G4ThreeVector(0, 0, 0); + G4ThreeVector W1v = G4ThreeVector(0, 0, 0); + G4ThreeVector W1w = G4ThreeVector(0, 0, 0); + G4ThreeVector W1Center = G4ThreeVector(0, 0, 0); + + G4int NumberOfDetector = m_DefinitionType.size(); + for (G4int i = 0; i < NumberOfDetector; i++) { + // By Point + if (m_DefinitionType[i]) { + // (u,v,w) unitary vector associated to telescope referencial + // (u,v) // to silicon plan + // w perpendicular to (u,v) plan and pointing ThirdStage + W1u = m_X16_Y1[i] - m_X1_Y1[i]; + W1u = W1u.unit(); + + W1v = m_X1_Y16[i] - m_X1_Y1[i]; + W1v = W1v.unit(); + + W1w = W1u.cross(W1v); + W1w = W1w.unit(); + + W1Center = (m_X1_Y1[i] + m_X1_Y16[i] + m_X16_Y1[i] + m_X16_Y16[i]) / 4; + + // Passage Matrix from Lab Referential to Telescope Referential + W1rot = new G4RotationMatrix(W1u, W1v, W1w); + // translation to place Telescope + W1pos = W1w * Length * 0.5 + W1Center; + } - // By Angle - else { - G4double Theta = m_Theta[i]; - G4double Phi = m_Phi[i]; - - // (u,v,w) unitary vector associated to telescope referencial - // (u,v) // to silicon plan - // w perpendicular to (u,v) plan and pointing ThirdStage - // Phi is angle between X axis and projection in (X,Y) plan - // Theta is angle between position vector and z axis - G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad); - G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad); - G4double wZ = m_R[i] * cos(Theta / rad); - W1w = G4ThreeVector(wX, wY, wZ); - - // vector corresponding to the center of the module - W1Center = W1w; - - // vector parallel to one axis of silicon plane - G4double ii = cos(Theta / rad) * cos(Phi / rad); - G4double jj = cos(Theta / rad) * sin(Phi / rad); - G4double kk = -sin(Theta / rad); - G4ThreeVector Y = G4ThreeVector(ii, jj, kk); - - W1w = W1w.unit(); - W1u = W1w.cross(Y); - W1v = W1w.cross(W1u); - W1v = W1v.unit(); - W1u = W1u.unit(); - - // Passage Matrix from Lab Referential to Telescope Referential - // MUST2 - W1rot = new G4RotationMatrix(W1u, W1v, W1w); - // Telescope is rotate of Beta angle around W1v axis. - W1rot->rotate(m_beta_u[i], W1u); - W1rot->rotate(m_beta_v[i], W1v); - W1rot->rotate(m_beta_w[i], W1w); - // translation to place Telescope - W1pos = W1w * Length * 0.5 + W1Center; - } + // By Angle + else { + G4double Theta = m_Theta[i]; + G4double Phi = m_Phi[i]; + + // (u,v,w) unitary vector associated to telescope referencial + // (u,v) // to silicon plan + // w perpendicular to (u,v) plan and pointing ThirdStage + // Phi is angle between X axis and projection in (X,Y) plan + // Theta is angle between position vector and z axis + G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad); + G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad); + G4double wZ = m_R[i] * cos(Theta / rad); + W1w = G4ThreeVector(wX, wY, wZ); + + // vector corresponding to the center of the module + W1Center = W1w; + + // vector parallel to one axis of silicon plane + G4double ii = cos(Theta / rad) * cos(Phi / rad); + G4double jj = cos(Theta / rad) * sin(Phi / rad); + G4double kk = -sin(Theta / rad); + G4ThreeVector Y = G4ThreeVector(ii, jj, kk); + + W1w = W1w.unit(); + W1u = W1w.cross(Y); + W1v = W1w.cross(W1u); + W1v = W1v.unit(); + W1u = W1u.unit(); + + // Passage Matrix from Lab Referential to Telescope Referential + // MUST2 + W1rot = new G4RotationMatrix(W1u, W1v, W1w); + // Telescope is rotate of Beta angle around W1v axis. + W1rot->rotate(m_beta_u[i], W1u); + W1rot->rotate(m_beta_v[i], W1v); + W1rot->rotate(m_beta_w[i], W1w); + // translation to place Telescope + W1pos = W1w * Length * 0.5 + W1Center; + } - VolumeMaker(i + 1, W1pos, W1rot, world); - } + VolumeMaker(i + 1, W1pos, W1rot, world); + } - delete W1rot; + delete W1rot; } - - // Connect the GaspardTrackingData class to the output TTree // of the simulation -void W1::InitializeRootOutput() -{ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("W1")){ +void W1::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("W1")) { pTree->Branch("W1", "TW1Data", &m_Event); - } - pTree->SetBranchAddress("W1", &m_Event); + } + pTree->SetBranchAddress("W1", &m_Event); } - - // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void W1::ReadSensitive(const G4Event* event) -{ - // Clear ROOT objects - m_Event->Clear(); - - ////////////////////////////////////////////////////////////////////////////////// - /////////////// Variables Used to Read Event Map of detector //////////////////// - ////////////////////////////////////////////////////////////////////////////////// - // First Stage - std::map<G4int, G4int*>::iterator DetectorNumber_itr; - std::map<G4int, G4double*>::iterator Energy_itr; - std::map<G4int, G4double*>::iterator Time_itr; - std::map<G4int, G4double*>::iterator X_itr; - std::map<G4int, G4double*>::iterator Y_itr; - std::map<G4int, G4double*>::iterator Pos_X_itr; - std::map<G4int, G4double*>::iterator Pos_Y_itr; - std::map<G4int, G4double*>::iterator Pos_Z_itr; - std::map<G4int, G4double*>::iterator Ang_Theta_itr; - std::map<G4int, G4double*>::iterator Ang_Phi_itr; - - NPS::HitsMap<G4int>* DetectorNumberHitMap; - NPS::HitsMap<G4double>* EnergyHitMap; - NPS::HitsMap<G4double>* TimeHitMap; - NPS::HitsMap<G4double>* XHitMap; - NPS::HitsMap<G4double>* YHitMap; - NPS::HitsMap<G4double>* PosXHitMap; - NPS::HitsMap<G4double>* PosYHitMap; - NPS::HitsMap<G4double>* PosZHitMap; - NPS::HitsMap<G4double>* AngThetaHitMap; - NPS::HitsMap<G4double>* AngPhiHitMap; - - ///////////////////////////////////////////////////////////////////////////////// - ////////////////// Read scorers //////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////////////////// - // Read the Scorer associated to the first Stage - //Detector Number - G4int StripDetCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/DetectorNumber"); - DetectorNumberHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripDetCollectionID)); - DetectorNumber_itr = DetectorNumberHitMap->GetMap()->begin(); - - //Energy - G4int StripEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/StripEnergy") ; - EnergyHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripEnergyCollectionID)) ; - Energy_itr = EnergyHitMap->GetMap()->begin() ; - - //Time of Flight - G4int StripTimeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/StripTime") ; - TimeHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripTimeCollectionID)) ; - Time_itr = TimeHitMap->GetMap()->begin() ; - - //Strip Number X - G4int StripXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/FrontStripNumber"); - XHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripXCollectionID)); - X_itr = XHitMap->GetMap()->begin(); - - //Strip Number Y - G4int StripYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/BackStripNumber"); - YHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripYCollectionID)) ; - Y_itr = YHitMap->GetMap()->begin() ; - - //Interaction Coordinate X - G4int InterCoordXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/InterCoordX") ; - PosXHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordXCollectionID)) ; - Pos_X_itr = PosXHitMap->GetMap()->begin() ; - - //Interaction Coordinate Y - G4int InterCoordYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/InterCoordY") ; - PosYHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordYCollectionID)) ; - Pos_Y_itr = PosYHitMap->GetMap()->begin() ; - - //Interaction Coordinate Z - G4int InterCoordZCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/InterCoordZ") ; - PosZHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordZCollectionID)) ; - Pos_Z_itr = PosXHitMap->GetMap()->begin() ; - - //Interaction Coordinate Angle Theta - G4int InterCoordAngThetaCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/InterCoordAngTheta") ; - AngThetaHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngThetaCollectionID)) ; - Ang_Theta_itr = AngThetaHitMap->GetMap()->begin() ; - - //Interaction Coordinate Angle Phi - G4int InterCoordAngPhiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/InterCoordAngPhi"); - AngPhiHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngPhiCollectionID)); - Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); - - // Check the size of different map - G4int sizeN = DetectorNumberHitMap->entries(); - G4int sizeE = EnergyHitMap->entries(); - G4int sizeT = TimeHitMap->entries(); - G4int sizeX = XHitMap->entries(); - G4int sizeY = YHitMap->entries(); - - if (sizeE != sizeT || sizeT != sizeX || sizeX != sizeY) { - G4cout << "No match size Si Event Map: sE:" - << sizeE << " sT:" << sizeT << " sX:" << sizeX << " sY:" << sizeY << G4endl ; - return; - } - - // Loop on W1 number - for (G4int l = 0; l < sizeN; l++) { - G4double N = *(DetectorNumber_itr->second); - G4int NTrackID = DetectorNumber_itr->first - N; - - if (N > 0) { - // Fill detector number - m_Event->SetFrontEDetectorNbr(N); - m_Event->SetFrontTDetectorNbr(N); - m_Event->SetBackEDetectorNbr(N); - m_Event->SetBackTDetectorNbr(N); - - // Energy - Energy_itr = EnergyHitMap->GetMap()->begin(); - for (G4int h = 0 ; h < sizeE ; h++) { - G4int ETrackID = Energy_itr->first - N; - G4double E = *(Energy_itr->second); - if (ETrackID == NTrackID) { - m_Event->SetFrontEEnergy(RandGauss::shoot(E, EnergyResolution)); - m_Event->SetBackEEnergy(RandGauss::shoot(E, EnergyResolution)); - } - Energy_itr++; - } - - // Time - Time_itr = TimeHitMap->GetMap()->begin(); - for (G4int h = 0 ; h < sizeT ; h++) { - G4int TTrackID = Time_itr->first - N; - G4double T = *(Time_itr->second); - if (TTrackID == NTrackID) { - m_Event->SetFrontTTime(RandGauss::shoot(T, TimeResolution)); - m_Event->SetBackTTime(RandGauss::shoot(T, TimeResolution)); - } - Time_itr++; - } - - // strip front - X_itr = XHitMap->GetMap()->begin(); - for (G4int h = 0 ; h < sizeX ; h++) { - G4int XTrackID = X_itr->first - N; - G4double X = *(X_itr->second); - if (XTrackID == NTrackID) { - m_Event->SetFrontEStripNbr(X) ; - m_Event->SetFrontTStripNbr(X) ; - } - X_itr++; - } - - // strip back - Y_itr = YHitMap->GetMap()->begin(); - for (G4int h = 0 ; h < sizeY ; h++) { - G4int YTrackID = Y_itr->first - N; - G4double Y = *(Y_itr->second); - if (YTrackID == NTrackID) { - m_Event->SetBackEStripNbr(Y); - m_Event->SetBackTStripNbr(Y); - } - Y_itr++; - } - - // Pos X - Pos_X_itr = PosXHitMap->GetMap()->begin(); - for (G4int h = 0; h < PosXHitMap->entries(); h++) { - G4int PosXTrackID = Pos_X_itr->first - N; - G4double PosX = *(Pos_X_itr->second); - if (PosXTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionX(PosX); - } - Pos_X_itr++; - } - - // Pos Y - Pos_Y_itr = PosYHitMap->GetMap()->begin(); - for (G4int h = 0; h < PosYHitMap->entries(); h++) { - G4int PosYTrackID = Pos_Y_itr->first - N; - G4double PosY = *(Pos_Y_itr->second); - if (PosYTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionY(PosY); - } - Pos_Y_itr++; - } - - // Pos Z - Pos_Z_itr = PosZHitMap->GetMap()->begin(); - for (G4int h = 0; h < PosZHitMap->entries(); h++) { - G4int PosZTrackID = Pos_Z_itr->first - N; - G4double PosZ = *(Pos_Z_itr->second); - if (PosZTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionZ(PosZ); - } - Pos_Z_itr++; - } - - // Angle Theta - Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); - for (G4int h = 0; h < AngThetaHitMap->entries(); h++) { - G4int AngThetaTrackID = Ang_Theta_itr->first - N; - G4double AngTheta = *(Ang_Theta_itr->second); - if (AngThetaTrackID == NTrackID) { - ms_InterCoord->SetDetectedAngleTheta(AngTheta); - } - Ang_Theta_itr++; - } - - // Angle Phi - Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); - for (G4int h = 0; h < AngPhiHitMap->entries(); h++) { - G4int AngPhiTrackID = Ang_Phi_itr->first - N; - G4double AngPhi = *(Ang_Phi_itr->second); - if (AngPhiTrackID == NTrackID) { - ms_InterCoord->SetDetectedAnglePhi(AngPhi); - } - Ang_Phi_itr++; - } - - } // end if number of detector > 0 - - DetectorNumber_itr++; - } // end loop on detector multiplicity - - // clear map for next event - DetectorNumberHitMap -> clear(); - EnergyHitMap -> clear(); - TimeHitMap -> clear(); - XHitMap -> clear(); - YHitMap -> clear(); - PosXHitMap -> clear(); - PosYHitMap -> clear(); - PosZHitMap -> clear(); - AngThetaHitMap -> clear(); - AngPhiHitMap -> clear(); -} +void W1::ReadSensitive(const G4Event* event) { + // Clear ROOT objects + m_Event->Clear(); + + ////////////////////////////////////////////////////////////////////////////////// + /////////////// Variables Used to Read Event Map of detector //////////////////// + ////////////////////////////////////////////////////////////////////////////////// + // First Stage + std::map<G4int, G4int*>::iterator DetectorNumber_itr; + std::map<G4int, G4double*>::iterator Energy_itr; + std::map<G4int, G4double*>::iterator Time_itr; + std::map<G4int, G4double*>::iterator X_itr; + std::map<G4int, G4double*>::iterator Y_itr; + std::map<G4int, G4double*>::iterator Pos_X_itr; + std::map<G4int, G4double*>::iterator Pos_Y_itr; + std::map<G4int, G4double*>::iterator Pos_Z_itr; + std::map<G4int, G4double*>::iterator Ang_Theta_itr; + std::map<G4int, G4double*>::iterator Ang_Phi_itr; + + NPS::HitsMap<G4int>* DetectorNumberHitMap; + NPS::HitsMap<G4double>* EnergyHitMap; + NPS::HitsMap<G4double>* TimeHitMap; + NPS::HitsMap<G4double>* XHitMap; + NPS::HitsMap<G4double>* YHitMap; + NPS::HitsMap<G4double>* PosXHitMap; + NPS::HitsMap<G4double>* PosYHitMap; + NPS::HitsMap<G4double>* PosZHitMap; + NPS::HitsMap<G4double>* AngThetaHitMap; + NPS::HitsMap<G4double>* AngPhiHitMap; + + ///////////////////////////////////////////////////////////////////////////////// + ////////////////// Read scorers //////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////////////// + // Read the Scorer associated to the first Stage + // Detector Number + G4int StripDetCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/DetectorNumber"); + DetectorNumberHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripDetCollectionID)); + DetectorNumber_itr = DetectorNumberHitMap->GetMap()->begin(); + + // Energy + G4int StripEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/StripEnergy"); + EnergyHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripEnergyCollectionID)); + Energy_itr = EnergyHitMap->GetMap()->begin(); + + // Time of Flight + G4int StripTimeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/StripTime"); + TimeHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripTimeCollectionID)); + Time_itr = TimeHitMap->GetMap()->begin(); + + // Strip Number X + G4int StripXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/FrontStripNumber"); + XHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripXCollectionID)); + X_itr = XHitMap->GetMap()->begin(); + + // Strip Number Y + G4int StripYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/BackStripNumber"); + YHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripYCollectionID)); + Y_itr = YHitMap->GetMap()->begin(); + + // Interaction Coordinate X + G4int InterCoordXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/InterCoordX"); + PosXHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordXCollectionID)); + Pos_X_itr = PosXHitMap->GetMap()->begin(); + + // Interaction Coordinate Y + G4int InterCoordYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/InterCoordY"); + PosYHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordYCollectionID)); + Pos_Y_itr = PosYHitMap->GetMap()->begin(); + + // Interaction Coordinate Z + G4int InterCoordZCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/InterCoordZ"); + PosZHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordZCollectionID)); + Pos_Z_itr = PosXHitMap->GetMap()->begin(); + + // Interaction Coordinate Angle Theta + G4int InterCoordAngThetaCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/InterCoordAngTheta"); + AngThetaHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngThetaCollectionID)); + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); + + // Interaction Coordinate Angle Phi + G4int InterCoordAngPhiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/InterCoordAngPhi"); + AngPhiHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngPhiCollectionID)); + Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); + + // Check the size of different map + G4int sizeN = DetectorNumberHitMap->entries(); + G4int sizeE = EnergyHitMap->entries(); + G4int sizeT = TimeHitMap->entries(); + G4int sizeX = XHitMap->entries(); + G4int sizeY = YHitMap->entries(); + + if (sizeE != sizeT || sizeT != sizeX || sizeX != sizeY) { + G4cout << "No match size Si Event Map: sE:" << sizeE << " sT:" << sizeT << " sX:" << sizeX << " sY:" << sizeY + << G4endl; + return; + } + // Loop on W1 number + for (G4int l = 0; l < sizeN; l++) { + G4double N = *(DetectorNumber_itr->second); + G4int NTrackID = DetectorNumber_itr->first - N; + + if (N > 0) { + // Fill detector number + m_Event->SetFrontEDetectorNbr(N); + m_Event->SetFrontTDetectorNbr(N); + m_Event->SetBackEDetectorNbr(N); + m_Event->SetBackTDetectorNbr(N); + + // Energy + Energy_itr = EnergyHitMap->GetMap()->begin(); + for (G4int h = 0; h < sizeE; h++) { + G4int ETrackID = Energy_itr->first - N; + G4double E = *(Energy_itr->second); + if (ETrackID == NTrackID) { + m_Event->SetFrontEEnergy(RandGauss::shoot(E, EnergyResolution)); + m_Event->SetBackEEnergy(RandGauss::shoot(E, EnergyResolution)); + } + Energy_itr++; + } + // Time + Time_itr = TimeHitMap->GetMap()->begin(); + for (G4int h = 0; h < sizeT; h++) { + G4int TTrackID = Time_itr->first - N; + G4double T = *(Time_itr->second); + if (TTrackID == NTrackID) { + m_Event->SetFrontTTime(RandGauss::shoot(T, TimeResolution)); + m_Event->SetBackTTime(RandGauss::shoot(T, TimeResolution)); + } + Time_itr++; + } -void W1::InitializeMaterials(){ - m_MaterialSilicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); - m_MaterialAluminium =MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); - m_MaterialIron = MaterialManager::getInstance()->GetMaterialFromLibrary("Fe"); - m_MaterialVacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); -} + // strip front + X_itr = XHitMap->GetMap()->begin(); + for (G4int h = 0; h < sizeX; h++) { + G4int XTrackID = X_itr->first - N; + G4double X = *(X_itr->second); + if (XTrackID == NTrackID) { + m_Event->SetFrontEStripNbr(X); + m_Event->SetFrontTStripNbr(X); + } + X_itr++; + } + // strip back + Y_itr = YHitMap->GetMap()->begin(); + for (G4int h = 0; h < sizeY; h++) { + G4int YTrackID = Y_itr->first - N; + G4double Y = *(Y_itr->second); + if (YTrackID == NTrackID) { + m_Event->SetBackEStripNbr(Y); + m_Event->SetBackTStripNbr(Y); + } + Y_itr++; + } + // Pos X + Pos_X_itr = PosXHitMap->GetMap()->begin(); + for (G4int h = 0; h < PosXHitMap->entries(); h++) { + G4int PosXTrackID = Pos_X_itr->first - N; + G4double PosX = *(Pos_X_itr->second); + if (PosXTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionX(PosX); + } + Pos_X_itr++; + } -void W1::InitializeScorers(){ + // Pos Y + Pos_Y_itr = PosYHitMap->GetMap()->begin(); + for (G4int h = 0; h < PosYHitMap->entries(); h++) { + G4int PosYTrackID = Pos_Y_itr->first - N; + G4double PosY = *(Pos_Y_itr->second); + if (PosYTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionY(PosY); + } + Pos_Y_itr++; + } + + // Pos Z + Pos_Z_itr = PosZHitMap->GetMap()->begin(); + for (G4int h = 0; h < PosZHitMap->entries(); h++) { + G4int PosZTrackID = Pos_Z_itr->first - N; + G4double PosZ = *(Pos_Z_itr->second); + if (PosZTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionZ(PosZ); + } + Pos_Z_itr++; + } + + // Angle Theta + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); + for (G4int h = 0; h < AngThetaHitMap->entries(); h++) { + G4int AngThetaTrackID = Ang_Theta_itr->first - N; + G4double AngTheta = *(Ang_Theta_itr->second); + if (AngThetaTrackID == NTrackID) { + ms_InterCoord->SetDetectedAngleTheta(AngTheta); + } + Ang_Theta_itr++; + } + + // Angle Phi + Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); + for (G4int h = 0; h < AngPhiHitMap->entries(); h++) { + G4int AngPhiTrackID = Ang_Phi_itr->first - N; + G4double AngPhi = *(Ang_Phi_itr->second); + if (AngPhiTrackID == NTrackID) { + ms_InterCoord->SetDetectedAnglePhi(AngPhi); + } + Ang_Phi_itr++; + } + + } // end if number of detector > 0 + + DetectorNumber_itr++; + } // end loop on detector multiplicity + + // clear map for next event + DetectorNumberHitMap->clear(); + EnergyHitMap->clear(); + TimeHitMap->clear(); + XHitMap->clear(); + YHitMap->clear(); + PosXHitMap->clear(); + PosYHitMap->clear(); + PosZHitMap->clear(); + AngThetaHitMap->clear(); + AngPhiHitMap->clear(); +} + +void W1::InitializeMaterials() { + m_MaterialSilicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); + m_MaterialAluminium = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); + m_MaterialIron = MaterialManager::getInstance()->GetMaterialFromLibrary("Fe"); + m_MaterialVacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); +} + +void W1::InitializeScorers() { bool already_exist = false; - // Associate Scorer - m_Scorer = CheckScorer("ScorerW1",already_exist); - if(already_exist) return; - - G4VPrimitiveScorer* DetNbr = new OBSOLETEGENERALSCORERS::PSDetectorNumber("DetectorNumber", "W1Square", 0); - G4VPrimitiveScorer* Energy = new OBSOLETEGENERALSCORERS::PSEnergy("StripEnergy", "W1Square", 0); - G4VPrimitiveScorer* TOF = new OBSOLETEGENERALSCORERS::PSTOF("StripTime", "W1Square", 0); - G4VPrimitiveScorer* InteractionCoordinatesX = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesX("InterCoordX","W1Square", 0); - G4VPrimitiveScorer* InteractionCoordinatesY = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesY("InterCoordY","W1Square", 0); - G4VPrimitiveScorer* InteractionCoordinatesZ = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ","W1Square", 0); - G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta","W1Square", 0); - G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi","W1Square", 0); - G4VPrimitiveScorer* ThetaStripPosition = new W1ScorerFrontStripNumber("FrontStripNumber", 0, NbStrips); - G4VPrimitiveScorer* PhiStripPosition = new W1ScorerBackStripNumber("BackStripNumber", 0, NbStrips); - - //and register it to the multifunctionnal detector - m_Scorer->RegisterPrimitive(DetNbr); - m_Scorer->RegisterPrimitive(Energy); - m_Scorer->RegisterPrimitive(TOF); - m_Scorer->RegisterPrimitive(ThetaStripPosition); - m_Scorer->RegisterPrimitive(PhiStripPosition); - m_Scorer->RegisterPrimitive(InteractionCoordinatesX); - m_Scorer->RegisterPrimitive(InteractionCoordinatesY); - m_Scorer->RegisterPrimitive(InteractionCoordinatesZ); - m_Scorer->RegisterPrimitive(InteractionCoordinatesAngleTheta); - m_Scorer->RegisterPrimitive(InteractionCoordinatesAnglePhi); - - // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_Scorer); + // Associate Scorer + m_Scorer = CheckScorer("ScorerW1", already_exist); + if (already_exist) + return; + + G4VPrimitiveScorer* DetNbr = new OBSOLETEGENERALSCORERS::PSDetectorNumber("DetectorNumber", "W1Square", 0); + G4VPrimitiveScorer* Energy = new OBSOLETEGENERALSCORERS::PSEnergy("StripEnergy", "W1Square", 0); + G4VPrimitiveScorer* TOF = new OBSOLETEGENERALSCORERS::PSTOF("StripTime", "W1Square", 0); + G4VPrimitiveScorer* InteractionCoordinatesX = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesX("InterCoordX", "W1Square", 0); + G4VPrimitiveScorer* InteractionCoordinatesY = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesY("InterCoordY", "W1Square", 0); + G4VPrimitiveScorer* InteractionCoordinatesZ = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ", "W1Square", 0); + G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta", "W1Square", 0); + G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi", "W1Square", 0); + G4VPrimitiveScorer* ThetaStripPosition = new W1ScorerFrontStripNumber("FrontStripNumber", 0, NbStrips); + G4VPrimitiveScorer* PhiStripPosition = new W1ScorerBackStripNumber("BackStripNumber", 0, NbStrips); + + // and register it to the multifunctionnal detector + m_Scorer->RegisterPrimitive(DetNbr); + m_Scorer->RegisterPrimitive(Energy); + m_Scorer->RegisterPrimitive(TOF); + m_Scorer->RegisterPrimitive(ThetaStripPosition); + m_Scorer->RegisterPrimitive(PhiStripPosition); + m_Scorer->RegisterPrimitive(InteractionCoordinatesX); + m_Scorer->RegisterPrimitive(InteractionCoordinatesY); + m_Scorer->RegisterPrimitive(InteractionCoordinatesZ); + m_Scorer->RegisterPrimitive(InteractionCoordinatesAngleTheta); + m_Scorer->RegisterPrimitive(InteractionCoordinatesAnglePhi); + + // Add All Scorer to the Global Scorer Manager + G4SDManager::GetSDMpointer()->AddNewDetector(m_Scorer); } - //////////////////////////////////////////////////////////////////////////////// - // Construct Method to be pass to the DetectorFactory // - //////////////////////////////////////////////////////////////////////////////// - NPS::VDetector* W1::Construct(){ - return (NPS::VDetector*) new W1(); - } - - //////////////////////////////////////////////////////////////////////////////// - // Registering the construct method to the factory // - //////////////////////////////////////////////////////////////////////////////// - extern"C" { - class proxy_nps_w1{ - public: - proxy_nps_w1(){ - NPS::DetectorFactory::getInstance()->AddToken("W1","W1"); - NPS::DetectorFactory::getInstance()->AddDetector("W1",W1::Construct); - } +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the DetectorFactory // +//////////////////////////////////////////////////////////////////////////////// +NPS::VDetector* W1::Construct() { return (NPS::VDetector*)new W1(); } + +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern "C" { +class proxy_nps_w1 { + public: + proxy_nps_w1() { + NPS::DetectorFactory::getInstance()->AddToken("W1", "W1"); + NPS::DetectorFactory::getInstance()->AddDetector("W1", W1::Construct); + } }; - proxy_nps_w1 p_nps_w1; - } +proxy_nps_w1 p_nps_w1; +} diff --git a/NPSimulation/Detectors/eAGanil/eAGanil.cc b/NPSimulation/Detectors/eAGanil/eAGanil.cc index c3a5e47ae..c4faf1fcb 100644 --- a/NPSimulation/Detectors/eAGanil/eAGanil.cc +++ b/NPSimulation/Detectors/eAGanil/eAGanil.cc @@ -20,69 +20,67 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> -//G4 Geometry object -#include "G4Tubs.hh" +#include <sstream> +// G4 Geometry object #include "G4Box.hh" +#include "G4Tubs.hh" -//G4 sensitive -#include "G4SDManager.hh" +// G4 sensitive #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" -//G4 various object +// G4 various object +#include "G4Colour.hh" #include "G4Material.hh" -#include "G4Transform3D.hh" #include "G4PVPlacement.hh" +#include "G4Transform3D.hh" #include "G4VisAttributes.hh" -#include "G4Colour.hh" // NPTool header -#include "eAGanil.hh" #include "CalorimeterScorers.hh" #include "InteractionScorers.hh" -#include "RootOutput.h" #include "MaterialManager.hh" -#include "NPSDetectorFactory.hh" #include "NPOptionManager.h" +#include "NPSDetectorFactory.hh" #include "NPSHitsMap.hh" +#include "RootOutput.h" +#include "eAGanil.hh" // CLHEP header #include "CLHEP/Random/RandGauss.h" using namespace std; using namespace CLHEP; - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -namespace eAGanil_NS{ +namespace eAGanil_NS { // Energy and time Resolution - const double EnergyThreshold = 0.1*MeV; - const double ResoTime = 4.5*ns ; - const double ResoEnergy = 1.0*MeV ; - const double Thickness = 500*mm ; + const double EnergyThreshold = 0.1 * MeV; + const double ResoTime = 4.5 * ns; + const double ResoEnergy = 1.0 * MeV; + const double Thickness = 500 * mm; const string Material = "Pb"; -} +} // namespace eAGanil_NS //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // eAGanil Specific Method -eAGanil::eAGanil(){ - m_Event = new TeAGanilData() ; +eAGanil::eAGanil() { + m_Event = new TeAGanilData(); m_eAGanilScorer = 0; - m_Length=0; + m_Length = 0; // RGB Color + Transparency - m_VisDetector = new G4VisAttributes(G4Colour(0, 1, 0, 0.5)); - m_VisTrap = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3, 0.5)); + m_VisDetector = new G4VisAttributes(G4Colour(0, 1, 0, 0.5)); + m_VisTrap = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3, 0.5)); } -eAGanil::~eAGanil(){ -} +eAGanil::~eAGanil() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void eAGanil::AddDetector(double R, double Theta, double Phi, double EntranceWidth,double EntranceHeigh,double MR){ +void eAGanil::AddDetector(double R, double Theta, double Phi, double EntranceWidth, double EntranceHeigh, double MR) { m_SpecR.push_back(R); m_SpecTheta.push_back(Theta); m_SpecPhi.push_back(Phi); @@ -92,60 +90,54 @@ void eAGanil::AddDetector(double R, double Theta, double Phi, double Entrance } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void eAGanil::SetTrap(double Length, double InnerRadius, double OuterRadius, double BladesThickness, int NumberOfBlades,double Phi, double WindowsThickness){ - m_Length=Length; - m_InnerRadius=InnerRadius; - m_OuterRadius=OuterRadius; - m_BladesThickness=BladesThickness; - m_NumberOfBlades=NumberOfBlades; - m_Phi=Phi; - m_WindowsThickness=WindowsThickness; +void eAGanil::SetTrap(double Length, double InnerRadius, double OuterRadius, double BladesThickness, int NumberOfBlades, + double Phi, double WindowsThickness) { + m_Length = Length; + m_InnerRadius = InnerRadius; + m_OuterRadius = OuterRadius; + m_BladesThickness = BladesThickness; + m_NumberOfBlades = NumberOfBlades; + m_Phi = Phi; + m_WindowsThickness = WindowsThickness; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* eAGanil::BuildDetector(unsigned int i){ - G4Box* box = new G4Box("eAGanil_Box",m_SpecEntranceHeigh[i]*0.5, - m_SpecEntranceWidth[i]*0.5,eAGanil_NS::Thickness*0.5); +G4LogicalVolume* eAGanil::BuildDetector(unsigned int i) { + G4Box* box = + new G4Box("eAGanil_Box", m_SpecEntranceHeigh[i] * 0.5, m_SpecEntranceWidth[i] * 0.5, eAGanil_NS::Thickness * 0.5); G4Material* DetectorMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary(eAGanil_NS::Material); - G4LogicalVolume* Detector = new G4LogicalVolume(box,DetectorMaterial,"logic_eAGanil_spec",0,0,0); + G4LogicalVolume* Detector = new G4LogicalVolume(box, DetectorMaterial, "logic_eAGanil_spec", 0, 0, 0); Detector->SetVisAttributes(m_VisDetector); Detector->SetSensitiveDetector(m_eAGanilScorer); return Detector; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* eAGanil::BuildTrap(){ - G4Tubs* tubs = new G4Tubs("eAGanil_Trap",m_InnerRadius*0.9,m_OuterRadius*1.1,m_Length*0.5,0,360*deg ); +G4LogicalVolume* eAGanil::BuildTrap() { + G4Tubs* tubs = new G4Tubs("eAGanil_Trap", m_InnerRadius * 0.9, m_OuterRadius * 1.1, m_Length * 0.5, 0, 360 * deg); G4Material* VacuumMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); - G4LogicalVolume* Trap = new G4LogicalVolume(tubs,VacuumMaterial,"logic_eAGanil_trap",0,0,0); - Trap->SetVisAttributes(G4VisAttributes::Invisible); + G4LogicalVolume* Trap = new G4LogicalVolume(tubs, VacuumMaterial, "logic_eAGanil_trap", 0, 0, 0); + Trap->SetVisAttributes(G4VisAttributes::GetInvisible()); - - G4Box* box = new G4Box("eAGanil_Blades", - m_BladesThickness*0.5, - (m_OuterRadius-m_InnerRadius)*0.5, - m_Length*0.5 - ); + G4Box* box = + new G4Box("eAGanil_Blades", m_BladesThickness * 0.5, (m_OuterRadius - m_InnerRadius) * 0.5, m_Length * 0.5); G4Material* TrapMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); - G4LogicalVolume* Blades = new G4LogicalVolume(box,TrapMaterial,"logic_eAGanil_trap",0,0,0); + G4LogicalVolume* Blades = new G4LogicalVolume(box, TrapMaterial, "logic_eAGanil_trap", 0, 0, 0); Blades->SetVisAttributes(m_VisTrap); G4RotationMatrix* Rot = new G4RotationMatrix(); - G4ThreeVector Pos(0,(m_OuterRadius-m_InnerRadius)*0.5+m_InnerRadius,0); - for(unsigned int i = 0 ; i < m_NumberOfBlades ; i++){ - Rot->rotateZ(360.*deg/m_NumberOfBlades); - Pos.rotateZ(360.*deg/m_NumberOfBlades); - new G4PVPlacement(G4Transform3D(*Rot,Pos), - Blades, - "eAGanil",Trap,false,1); - } - + G4ThreeVector Pos(0, (m_OuterRadius - m_InnerRadius) * 0.5 + m_InnerRadius, 0); + for (unsigned int i = 0; i < m_NumberOfBlades; i++) { + Rot->rotateZ(360. * deg / m_NumberOfBlades); + Pos.rotateZ(360. * deg / m_NumberOfBlades); + new G4PVPlacement(G4Transform3D(*Rot, Pos), Blades, "eAGanil", Trap, false, 1); + } + return Trap; } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -153,151 +145,147 @@ G4LogicalVolume* eAGanil::BuildTrap(){ // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void eAGanil::ReadConfiguration(NPL::InputParser parser){ - vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithTokenAndValue("eAGanil","Spectrometer"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " detectors found " << endl; - - vector<string> sphe = {"R","Theta","Phi","EntranceWidth","EntranceHeight","MomentumResolution"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(sphe)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// eAGanil " << i+1 << endl; - double R = blocks[i]->GetDouble("R","mm"); - double Theta = blocks[i]->GetDouble("Theta","deg"); - double Phi = blocks[i]->GetDouble("Phi","deg"); - double EW = blocks[i]->GetDouble("EntranceWidth","cm"); - double EH = blocks[i]->GetDouble("EntranceHeight","cm"); - double MR = blocks[i]->GetDouble("MomentumResolution","void"); - AddDetector(R,Theta,Phi,EW,EH,MR); +void eAGanil::ReadConfiguration(NPL::InputParser parser) { + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithTokenAndValue("eAGanil", "Spectrometer"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + + vector<string> sphe = {"R", "Theta", "Phi", "EntranceWidth", "EntranceHeight", "MomentumResolution"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(sphe)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// eAGanil " << i + 1 << endl; + double R = blocks[i]->GetDouble("R", "mm"); + double Theta = blocks[i]->GetDouble("Theta", "deg"); + double Phi = blocks[i]->GetDouble("Phi", "deg"); + double EW = blocks[i]->GetDouble("EntranceWidth", "cm"); + double EH = blocks[i]->GetDouble("EntranceHeight", "cm"); + double MR = blocks[i]->GetDouble("MomentumResolution", "void"); + AddDetector(R, Theta, Phi, EW, EH, MR); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } } - blocks = parser.GetAllBlocksWithTokenAndValue("eAGanil","Trap"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " detectors found " << endl; - - vector<string> trap= {"Length","InnerRadius", "OuterRadius","BladesThickness","NumberOfBlades","Phi","WindowsThickness"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(trap)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// eAGanil " << i+1 << endl; - - double L = blocks[i]->GetDouble("Length","mm"); - double iR = blocks[i]->GetDouble("InnerRadius","mm"); - double oR = blocks[i]->GetDouble("OuterRadius","mm"); - double fT = blocks[i]->GetDouble("BladesThickness","mm"); - int nF = blocks[i]->GetInt("NumberOfBlades"); - double Phi = blocks[i]->GetDouble("Phi","deg"); - double wT = blocks[i]->GetDouble("WindowsThickness","mm"); - SetTrap(L,iR,oR,fT,nF,Phi,wT); + blocks = parser.GetAllBlocksWithTokenAndValue("eAGanil", "Trap"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + + vector<string> trap = {"Length", "InnerRadius", "OuterRadius", "BladesThickness", + "NumberOfBlades", "Phi", "WindowsThickness"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(trap)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// eAGanil " << i + 1 << endl; + + double L = blocks[i]->GetDouble("Length", "mm"); + double iR = blocks[i]->GetDouble("InnerRadius", "mm"); + double oR = blocks[i]->GetDouble("OuterRadius", "mm"); + double fT = blocks[i]->GetDouble("BladesThickness", "mm"); + int nF = blocks[i]->GetInt("NumberOfBlades"); + double Phi = blocks[i]->GetDouble("Phi", "deg"); + double wT = blocks[i]->GetDouble("WindowsThickness", "mm"); + SetTrap(L, iR, oR, fT, nF, Phi, wT); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } } - } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void eAGanil::ConstructDetector(G4LogicalVolume* world){ - for (unsigned short i = 0 ; i < m_SpecR.size() ; i++) { - G4double wX = m_SpecR[i] * sin(m_SpecTheta[i] ) * cos(m_SpecPhi[i] ) ; - G4double wY = m_SpecR[i] * sin(m_SpecTheta[i] ) * sin(m_SpecPhi[i] ) ; - G4double wZ = m_SpecR[i] * cos(m_SpecTheta[i] ) ; - G4ThreeVector Det_pos = G4ThreeVector(wX, wY, wZ) ; +void eAGanil::ConstructDetector(G4LogicalVolume* world) { + for (unsigned short i = 0; i < m_SpecR.size(); i++) { + G4double wX = m_SpecR[i] * sin(m_SpecTheta[i]) * cos(m_SpecPhi[i]); + G4double wY = m_SpecR[i] * sin(m_SpecTheta[i]) * sin(m_SpecPhi[i]); + G4double wZ = m_SpecR[i] * cos(m_SpecTheta[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()*eAGanil_NS::Thickness*0.5; + Det_pos += Det_pos.unit() * eAGanil_NS::Thickness * 0.5; // Building Detector reference frame G4double ii = cos(m_SpecTheta[i]) * cos(m_SpecPhi[i]); G4double jj = cos(m_SpecTheta[i]) * sin(m_SpecPhi[i]); G4double kk = -sin(m_SpecTheta[i]); - G4ThreeVector Y(ii,jj,kk); + 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); + G4RotationMatrix* Rot = new G4RotationMatrix(u, v, w); - new G4PVPlacement(G4Transform3D(*Rot,Det_pos), - BuildDetector(i), - "eAGanil",world,false,i+1); + new G4PVPlacement(G4Transform3D(*Rot, Det_pos), BuildDetector(i), "eAGanil", world, false, i + 1); } - if(m_Length){ + if (m_Length) { G4RotationMatrix* Rot = new G4RotationMatrix(); Rot->rotateZ(m_Phi); - - new G4PVPlacement(G4Transform3D(*Rot,G4ThreeVector(0,0,0)), - BuildTrap(), - "eAGanil",world,false,1); + + new G4PVPlacement(G4Transform3D(*Rot, G4ThreeVector(0, 0, 0)), BuildTrap(), "eAGanil", world, false, 1); } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void eAGanil::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("eAGanil")){ - pTree->Branch("eAGanil", "TeAGanilData", &m_Event) ; +void eAGanil::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("eAGanil")) { + pTree->Branch("eAGanil", "TeAGanilData", &m_Event); } - pTree->SetBranchAddress("eAGanil", &m_Event) ; + pTree->SetBranchAddress("eAGanil", &m_Event); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void eAGanil::ReadSensitive(const G4Event* ){ +void eAGanil::ReadSensitive(const G4Event*) { m_Event->Clear(); /////////// // Calorimeter scorer - CalorimeterScorers::PS_Calorimeter* Scorer= (CalorimeterScorers::PS_Calorimeter*) m_eAGanilScorer->GetPrimitive(0); - - unsigned int size = Scorer->GetMult(); - for(unsigned int i = 0 ; i < size ; i++){ - vector<unsigned int> level = Scorer->GetLevel(i); - double Energy = RandGauss::shoot(Scorer->GetEnergy(i),eAGanil_NS::ResoEnergy); - if(Energy>eAGanil_NS::EnergyThreshold){ - double Time = RandGauss::shoot(Scorer->GetTime(i),eAGanil_NS::ResoTime); + CalorimeterScorers::PS_Calorimeter* Scorer = (CalorimeterScorers::PS_Calorimeter*)m_eAGanilScorer->GetPrimitive(0); + + unsigned int size = Scorer->GetMult(); + for (unsigned int i = 0; i < size; i++) { + vector<unsigned int> level = Scorer->GetLevel(i); + double Energy = RandGauss::shoot(Scorer->GetEnergy(i), eAGanil_NS::ResoEnergy); + if (Energy > eAGanil_NS::EnergyThreshold) { + double Time = RandGauss::shoot(Scorer->GetTime(i), eAGanil_NS::ResoTime); int DetectorNbr = level[0]; - m_Event->SetEnergy(DetectorNbr,Energy); - m_Event->SetTime(DetectorNbr,Time); + m_Event->SetEnergy(DetectorNbr, Energy); + m_Event->SetTime(DetectorNbr, Time); } } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -//////////////////////////////////////////////////////////////// -void eAGanil::InitializeScorers() { +//////////////////////////////////////////////////////////////// +void eAGanil::InitializeScorers() { // This check is necessary in case the geometry is reloaded - bool already_exist = false; - m_eAGanilScorer = CheckScorer("eAGanilScorer",already_exist) ; + bool already_exist = false; + m_eAGanilScorer = CheckScorer("eAGanilScorer", already_exist); - if(already_exist) - return ; + if (already_exist) + return; // Otherwise the scorer is initialised - vector<int> level; level.push_back(0); - G4VPrimitiveScorer* Calorimeter= new CalorimeterScorers::PS_Calorimeter("Calorimeter",level, 0) ; - G4VPrimitiveScorer* Interaction= new InteractionScorers::PS_Interactions("Interaction",ms_InterCoord, 0) ; - //and register it to the multifunctionnal detector + vector<int> level; + level.push_back(0); + G4VPrimitiveScorer* Calorimeter = new CalorimeterScorers::PS_Calorimeter("Calorimeter", level, 0); + G4VPrimitiveScorer* Interaction = new InteractionScorers::PS_Interactions("Interaction", ms_InterCoord, 0); + // and register it to the multifunctionnal detector m_eAGanilScorer->RegisterPrimitive(Calorimeter); m_eAGanilScorer->RegisterPrimitive(Interaction); - G4SDManager::GetSDMpointer()->AddNewDetector(m_eAGanilScorer) ; + G4SDManager::GetSDMpointer()->AddNewDetector(m_eAGanilScorer); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -306,22 +294,20 @@ void eAGanil::InitializeScorers() { //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* eAGanil::Construct(){ - return (NPS::VDetector*) new eAGanil(); -} +NPS::VDetector* eAGanil::Construct() { return (NPS::VDetector*)new eAGanil(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_eAGanil{ - public: - proxy_nps_eAGanil(){ - NPS::DetectorFactory::getInstance()->AddToken("eAGanil","eAGanil"); - NPS::DetectorFactory::getInstance()->AddDetector("eAGanil",eAGanil::Construct); - } - }; - - proxy_nps_eAGanil p_nps_eAGanil; +extern "C" { +class proxy_nps_eAGanil { + public: + proxy_nps_eAGanil() { + NPS::DetectorFactory::getInstance()->AddToken("eAGanil", "eAGanil"); + NPS::DetectorFactory::getInstance()->AddDetector("eAGanil", eAGanil::Construct); + } +}; + +proxy_nps_eAGanil p_nps_eAGanil; } -- GitLab