diff --git a/Inputs/DetectorConfiguration/sharc.detector b/Inputs/DetectorConfiguration/sharc.detector new file mode 100644 index 0000000000000000000000000000000000000000..c5ce63de1b91d439e3506d5576be7d4dba4c9175 --- /dev/null +++ b/Inputs/DetectorConfiguration/sharc.detector @@ -0,0 +1,92 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +GeneralTarget +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Target + THICKNESS= 0.001 + RADIUS= 45 + MATERIAL= CD2 + ANGLE= 0 + X= 0 + Y= 0 + Z= 0 + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Sharc +%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + % Upstream CD + SharcCD + Z= -70 + R= 0 + Phi= 25 + + SharcCD + Z= -70 + R= 0 + Phi= 50 + + SharcCD + Z= -70 + R= 0 + Phi= 75 + + SharcCD + Z= -70 + R= 0 + Phi= 100 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + % Upstream Box + SharcBOX + X= 0 + Y= -36 + Z= -5 + SharcBOX + X= 0 + Y= 36 + Z= -5 + SharcBOX + X= 42.5 + Y= 0 + Z= -5 + SharcBOX + X= -42.5 + Y= 0 + Z= -5 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + % Down Stream Box + SharcBOX + X= 0 + Y= -36 + Z= 9 + SharcBOX + X= 0 + Y= 36 + Z= 9 + SharcBOX + X= 40.5 + Y= 0 + Z= 9 + SharcBOX + X= -40.5 + Y= 0 + Z= 9 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + % Down stream CD + SharcCD + Z= 70 + R= 0 + Phi= 25 + + SharcCD + Z= 70 + R= 0 + Phi= 50 + + SharcCD + Z= 70 + R= 0 + Phi= 75 + + SharcCD + Z= 70 + R= 0 + Phi= 100 \ No newline at end of file diff --git a/Inputs/EventGenerator/10He.reaction b/Inputs/EventGenerator/10He.reaction index 2a8c6d3a37d9a5888036750491f39f73b8980713..e4ab8cab22214279a272cccbc1f25d4003d0e28d 100644 --- a/Inputs/EventGenerator/10He.reaction +++ b/Inputs/EventGenerator/10He.reaction @@ -40,4 +40,4 @@ Transfert %ParticleDecay 9He Daughter= 8He n DifferentialCrossSection= flat.txt - shoot= 1 1 \ No newline at end of file + shoot= 1 1 diff --git a/NPSimulation/Simulation.cc b/NPSimulation/Simulation.cc index 28880753a47ce958c783f9f2f87514d9bd3331cf..16361ce2fcbf29587acbe4ae9aa542af43bb5cdf 100644 --- a/NPSimulation/Simulation.cc +++ b/NPSimulation/Simulation.cc @@ -5,6 +5,13 @@ #include "G4UImanager.hh" #include "G4UIterminal.hh" #include "G4UItcsh.hh" +#ifdef G4VIS_USE +#include "G4VisExecutive.hh" +#endif + +#ifdef G4UI_USE +#include "G4UIExecutive.hh" +#endif // G4 local source #include "DetectorConstruction.hh" @@ -86,13 +93,13 @@ int main(int argc, char** argv) /////////// Define UI terminal for interactive mode /////////// /////////////////////////////////////////////////////////////// #ifdef G4VIS_USE - G4VisManager* visManager = new G4VisExecutive; + G4VisManager* visManager = new G4VisExecutive("Quiet"); visManager->Initialize(); #endif G4UIsession* session = 0; -#ifdef G4UI_USE_TCSH +/*#ifdef G4UI_USE_TCSH session = new G4UIterminal(new G4UItcsh); #else session = new G4UIterminal(); @@ -101,7 +108,21 @@ int main(int argc, char** argv) UI->ApplyCommand("/control/execute vis.mac"); session->SessionStart(); delete session; - +*/ + + // interactive mode : define UI session + // Get the pointer to the User Interface manager + G4UImanager* UImanager = G4UImanager::GetUIpointer(); +#ifdef G4UI_USE + G4UIExecutive* ui = new G4UIExecutive(argc, argv); +#ifdef G4VIS_USE + UImanager->ApplyCommand("/control/execute vis.mac"); +#endif + if (ui->IsGUI()) + UImanager->ApplyCommand("/control/execute gui.mac"); + ui->SessionStart(); + delete ui; +#endif #ifdef G4VIS_USE delete visManager; #endif diff --git a/NPSimulation/gui.mac b/NPSimulation/gui.mac new file mode 100644 index 0000000000000000000000000000000000000000..bcd47fd54c458f7e2869fa6f8d33c23b634de0cb --- /dev/null +++ b/NPSimulation/gui.mac @@ -0,0 +1,25 @@ +# +# This file permits to customize, with commands, +# the menu bar of the G4UIXm, G4UIQt, G4UIWin32 sessions. +# It has no effect with G4UIterminal. +# +# File +# +# +# Vis menu : +/gui/addMenu vis Vis +/gui/addButton vis DAWNFILE "/control/execute visTutor/exN03Vis0.mac" +/gui/addButton vis OpenInventor "/control/execute visTutor/exN03Vis5.mac" +/gui/addButton vis TimeSlicing "/control/execute visTutor/exN03Vis12.mac" +/gui/addButton vis EmShower "/control/execute visTutor/exN03Vis13.mac" +# +# Viewer menu : +/gui/addMenu viewer Viewer +/gui/addButton viewer "Set style surface" "/vis/viewer/set/style surface" +/gui/addButton viewer "Set style wireframe" "/vis/viewer/set/style wire" +/gui/addButton viewer "Refresh viewer" "/vis/viewer/refresh" +/gui/addButton viewer "Update viewer (interaction or end-of-file)" "/vis/viewer/update" +/gui/addButton viewer "Flush viewer (= refresh + update)" "/vis/viewer/flush" +/gui/addButton viewer "Update scene" "/vis/scene/notifyHandlers" +# +# To limit the output flow in the "dump" widget : diff --git a/NPSimulation/include/Sharc.hh b/NPSimulation/include/Sharc.hh new file mode 100644 index 0000000000000000000000000000000000000000..4ad416a643bb34d42613a97408edcbbaa7be57c7 --- /dev/null +++ b/NPSimulation/include/Sharc.hh @@ -0,0 +1,168 @@ +#ifndef Sharc_h +#define Sharc_h 1 +/***************************************************************************** + * Copyright (C) 2009-2010 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Adrien MATTA contact address: matta@ipno.in2p3.fr * + * * + * Creation Date : November 2012 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class describe the Sharc Silicon detector * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ +// C++ header +#include <string> +#include <vector> + +// G4 header defining G4 types +#include "globals.hh" + +// G4 headers +#include "G4ThreeVector.hh" +#include "G4RotationMatrix.hh" +#include "G4LogicalVolume.hh" + +// NPSimulation header +#include "VDetector.hh" + +// NPLib +//#include "TSharcData.h" +using namespace std; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +namespace SHARC +{ + // Energy and time Resolution + const G4double ResoTime = 0 ; + const G4double ResoEnergy = 0.035 ;// = zzkeV of Resolution // Unit is MeV/2.35 + + // Geometry + // BOX PCB + const G4double BOX_PCB_Width = 0; + const G4double BOX_PCB_Length = 0; + const G4double BOX_PCB_Thickness = 0; + const G4double BOX_PCB_Trench_Position = 0; + const G4double BOX_PCB_Trench_Width = 0; + const G4double BOX_PCB_Trench_Deepness = 0; + + // BOX Wafer + const G4double BOX_Wafer_Width = 0; + const G4double BOX_Wafer_Length = 0; + const G4double BOX_Wafer_Thickness = 0; + const G4double BOX_Wafer_DeadLayer_Thickness = 0; + const G4int BOX_Wafer_Front_NumberOfStrip = 16 ; + const G4int BOX_Wafer_Back_NumberOfStrip = 16 ; + + // QQQ PCB + const G4double QQQ_PCB_Outer_Radius = 0; + const G4double QQQ_PCB_Inner_Radius = 0; + const G4double QQQ_PCB_Thickness = 0; + + // BOX Wafer + const G4double QQQ_Wafer_Outer_Radius = 0; + const G4double QQQ_Wafer_Inner_Radius = 0; + const G4double QQQ_Wafer_Thickness = 0; + const G4int QQQ_Wafer_Front_NumberOfStrip = 16 ; + const G4int QQQ_Wafer_Back_NumberOfStrip = 16 ; +} + +using namespace SHARC ; + +class Sharc : public VDetector +{ + //////////////////////////////////////////////////// + /////// Default Constructor and Destructor ///////// + //////////////////////////////////////////////////// +public: + Sharc() ; + virtual ~Sharc() ; + + //////////////////////////////////////////////////// + //////// Specific Function of this Class /////////// + //////////////////////////////////////////////////// +public: + // To add a box detector + void AddBoxDetector(G4ThreeVector Pos); + // To add a Quadrant detector + void AddQQQDetector(G4ThreeVector Pos); + + // Effectively construct Volume + // Avoid to have two time same code for Angle and Point definition + void VolumeMaker(G4int DetectorNumber , + G4ThreeVector MMpos , + G4RotationMatrix* MMrot , + G4LogicalVolume* world ); + + + //////////////////////////////////////////////////// + ///////// Inherite from VDetector class /////////// + //////////////////////////////////////////////////// +public: + // Read stream at Configfile to pick-up parameters of detector (Position,...) + // Called in DetecorConstruction::ReadDetextorConfiguration Method + void ReadConfiguration(string Path) ; + + // Construct detector and inialise sensitive part. + // Called After DetecorConstruction::AddDetector Method + void ConstructDetector(G4LogicalVolume* world) ; + + // Add Detector branch to the EventTree. + // Called After DetecorConstruction::AddDetector Method + void InitializeRootOutput() ; + + // Read sensitive part and fill the Root tree. + // Called at in the EventAction::EndOfEventAvtion + void ReadSensitive(const G4Event* event) ; + + + //////////////////////////////////////////////////// + ///////////Event class to store Data//////////////// + //////////////////////////////////////////////////// +private: + //TSharcData* m_Event ; + + //////////////////////////////////////////////////// + ///////////////// Scorer Related /////////////////// + //////////////////////////////////////////////////// + +private: + // Initialize all Scorer + void InitializeScorers() ; + + // Scorer Associate to the Silicon + G4MultiFunctionalDetector* m_StripScorer ; + +private: + // Initialize material used in detector definition + void InitializeMaterial(); + + // List of material + G4Material* m_MaterialSilicon ; + G4Material* m_MaterialAl ; + G4Material* m_MaterialVacuum ; + + //////////////////////////////////////////////////// + ///////////////Private intern Data////////////////// + //////////////////////////////////////////////////// +private: + // True if the detector is a Box, false if a quadrant + vector<bool> m_Type ; + + // Used for Box and Quadrant detectors + vector<G4ThreeVector> m_Pos ; + + // Set to true if you want to see Telescope Frame in your visualisation + bool m_non_sensitive_part_visiualisation ; + +}; +#endif diff --git a/NPSimulation/src/DetectorConstruction.cc b/NPSimulation/src/DetectorConstruction.cc index 8101ed47cd79abff216495cd448f47ff048ecc71..331b29115da85e4257069ca630c07ac2d0869339 100644 --- a/NPSimulation/src/DetectorConstruction.cc +++ b/NPSimulation/src/DetectorConstruction.cc @@ -52,6 +52,7 @@ #include "Plastic.hh" #include "Target.hh" #include "ThinSi.hh" +#include "Sharc.hh" #include "Shield.hh" #include "W1.hh" @@ -61,82 +62,82 @@ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... DetectorConstruction::DetectorConstruction() - : world_log(0), world_phys(0) +: world_log(0), world_phys(0) { - m_Target = 0; - m_Chamber = 0; + m_Target = 0; + m_Chamber = 0; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... DetectorConstruction::~DetectorConstruction() { - delete m_Target; - delete m_Chamber; + delete m_Target; + delete m_Chamber; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4VPhysicalVolume* DetectorConstruction::Construct() { - //------------------------------------------------------ materials - - G4double a; // atomic mass - G4double z; // atomic number - G4double density; - - - G4Element* N = new G4Element("Nitrogen", "N", z = 7., a = 14.01 * g / mole); - G4Element* O = new G4Element("Oxygen" , "O", z = 8., a = 16.00 * g / mole); - - // Vacuum - density = 0.000000001 * mg / cm3; - G4Material* Vacuum = new G4Material("Vacuum", density, 2); - Vacuum->AddElement(N, .7); - Vacuum->AddElement(O, .3); - - //------------------------------world volume - - G4double world_x = 10.0 * m; - G4double world_y = 10.0 * m; - G4double world_z = 10.0 * m; - - G4Box* world_box - = new G4Box("world_box", world_x, world_y, world_z); - - world_log = new G4LogicalVolume(world_box, Vacuum, "world_log", 0, 0, 0); - - world_phys = new G4PVPlacement(0, G4ThreeVector(), world_log, "world", 0, false, 0); - - // G4VisAttributes* VisAtt = new G4VisAttributes(G4Colour(0.2, 0.2, 0.2)); - G4VisAttributes* VisAtt = new G4VisAttributes(G4VisAttributes::Invisible); - world_log->SetVisAttributes(VisAtt); - - //------------------------------------------------------------------ - - //------------------------------Reaction Chamber volume - /* + //------------------------------------------------------ materials + + G4double a; // atomic mass + G4double z; // atomic number + G4double density; + + + G4Element* N = new G4Element("Nitrogen", "N", z = 7., a = 14.01 * g / mole); + G4Element* O = new G4Element("Oxygen" , "O", z = 8., a = 16.00 * g / mole); + + // Vacuum + density = 0.000000001 * mg / cm3; + G4Material* Vacuum = new G4Material("Vacuum", density, 2); + Vacuum->AddElement(N, .7); + Vacuum->AddElement(O, .3); + + //------------------------------world volume + + G4double world_x = 10.0 * m; + G4double world_y = 10.0 * m; + G4double world_z = 10.0 * m; + + G4Box* world_box + = new G4Box("world_box", world_x, world_y, world_z); + + world_log = new G4LogicalVolume(world_box, Vacuum, "world_log", 0, 0, 0); + + world_phys = new G4PVPlacement(0, G4ThreeVector(), world_log, "world", 0, false, 0); + + // G4VisAttributes* VisAtt = new G4VisAttributes(G4Colour(0.2, 0.2, 0.2)); + G4VisAttributes* VisAtt = new G4VisAttributes(G4VisAttributes::Invisible); + world_log->SetVisAttributes(VisAtt); + + //------------------------------------------------------------------ + + //------------------------------Reaction Chamber volume + /* G4double Chamber_Rmin = 20.0 * cm; G4double Chamber_Rmax = 20.2 * cm; G4double Chamber_ThetaMin = 0.0 * rad; G4double Chamber_ThetaMax = 3.14 * rad; G4double Chamber_PhiMin = 0.0 * rad; G4double Chamber_PhiMax = 6.26 * rad; - + G4Sphere* Chamber_sphere = new G4Sphere("Chamber_sphere", Chamber_Rmin, Chamber_Rmax, Chamber_PhiMin, Chamber_PhiMax, Chamber_ThetaMin, Chamber_ThetaMax ); - + Chamber_log = new G4LogicalVolume(Chamber_sphere, Vacuum, "Chamber_log", 0, 0, 0); - + Chamber_phys = new G4PVPlacement(0, G4ThreeVector(), Chamber_log, "Chamber", world_log, false, 0); - + G4VisAttributes* VisAttChamber = new G4VisAttributes(G4Colour(0.2, 0.2, 0.2)); //G4VisAttributes* VisAtt = new G4VisAttributes(G4VisAttributes::Invisible); Chamber_log->SetVisAttributes(VisAttChamber); */ - //------------------------------------------------------------------ - - - - return world_phys; + //------------------------------------------------------------------ + + + + return world_phys; } @@ -144,17 +145,17 @@ G4VPhysicalVolume* DetectorConstruction::Construct() //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::AddDetector(VDetector* NewDetector) { - // Add new detector to vector - m_Detectors.push_back(NewDetector); - - // Initialize Scorer - NewDetector->InitializeScorers(); - - // Construct new detector - NewDetector->ConstructDetector(world_log); - - // Add Detector to TTree - NewDetector->InitializeRootOutput(); + // Add new detector to vector + m_Detectors.push_back(NewDetector); + + // Initialize Scorer + NewDetector->InitializeScorers(); + + // Construct new detector + NewDetector->ConstructDetector(world_log); + + // Add Detector to TTree + NewDetector->InitializeRootOutput(); } @@ -162,346 +163,366 @@ void DetectorConstruction::AddDetector(VDetector* NewDetector) //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::ReadConfigurationFile(string Path) { - ////////General Reading needs//////// - string LineBuffer; - string DataBuffer; - - /////////Checking Boolean//////////////////// - bool cAddThinSi = false; - bool cComptonTelescope = false; - bool cDummy = false; - bool cEurogam = false; - bool cGeneralTarget = false; - bool cGeneralChamber = false; - bool cGPDTracker = false; // Gaspard Tracker - bool cHYDTracker = false; // Hyde detector - bool cMUST2 = false; - bool cPlastic = false; - bool cParis = false; // Paris Calorimeter - bool cS1 = false; - bool cShield = false; // Paris Shield CsI - bool cW1 = false; // W1 Micron DSSD - ////////////////////////////////////////////////////////////////////////////////////////// - ifstream ConfigFile; - ConfigFile.open(Path.c_str()); - - if (ConfigFile.is_open()) { // should be always be true - cout << " Configuration file " << Path << " loading " << endl; - } - else { - cout << " Error, no configuration file" << Path << " found" << endl; - } - - while (!ConfigFile.eof()) { - //Pick-up next line - getline(ConfigFile, LineBuffer); - //Search for comment Symbol: % - if (LineBuffer.compare(0, 1, "%") == 0) { /*Do Nothing*/;} - - //////////////////////////////////////////// - /////// Search for a Dummy Detector //////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0, 16, "TheDUMMYDetector") == 0 && cDummy == false) { - cDummy = true ; - G4cout << G4endl << "//////// DUMMY DETECTOR ////////" << G4endl << G4endl ; - - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new DUMMYDetector() ; - - // Read Position of detector - ConfigFile.close() ; - myDetector->ReadConfiguration(Path) ; - ConfigFile.open(Path.c_str()) ; - - // Add array to the VDetector Vector - AddDetector(myDetector) ; - } - - - ///////////////////////////////////////////////////// - //////////// Search for ComptonTelescope //////////// - ///////////////////////////////////////////////////// - else if (LineBuffer.compare(0, 16, "ComptonTelescope") == 0 && cComptonTelescope == false) { - cComptonTelescope = true; - G4cout << "//////// ComptonTelescope ////////" << G4endl; - - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new ComptonTelescope(); - - // Read Position of detector - ConfigFile.close(); - myDetector->ReadConfiguration(Path); - ConfigFile.open(Path.c_str()); - - // Add array to the VDetector Vector - AddDetector(myDetector); - } - - - //////////////////////////////////////////// - //////////// Search for Eurogam //////////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0, 7, "Eurogam") == 0 && cEurogam == false) { - cEurogam = true; - G4cout << "//////// Eurogam ////////" << G4endl; - - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new Eurogam(); - - // Read Position of detector - ConfigFile.close(); - myDetector->ReadConfiguration(Path); - ConfigFile.open(Path.c_str()); - - // Add array to the VDetector Vector - AddDetector(myDetector); - } - - - //////////////////////////////////////////// - //////////// Search for Gaspard //////////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0, 14, "GaspardTracker") == 0 && cGPDTracker == false) { - cGPDTracker = true ; - G4cout << G4endl << "//////// Gaspard Tracker ////////" << G4endl ; - - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new GaspardTracker() ; - - // Read Position of Telescope - ConfigFile.close() ; - myDetector->ReadConfiguration(Path) ; - ConfigFile.open(Path.c_str()) ; - - // Add array to the VDetector Vector - AddDetector(myDetector) ; - } - - - //////////////////////////////////////////// - //////////// Search for Hyde //////////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0, 11, "HydeTracker") == 0 && cHYDTracker == false) { - cHYDTracker = true ; - G4cout << G4endl << "//////// Hyde Tracker ////////" << G4endl ; - - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new HydeTracker() ; - - // Read Position of Telescope - ConfigFile.close() ; - myDetector->ReadConfiguration(Path) ; - ConfigFile.open(Path.c_str()) ; - - // Add array to the VDetector Vector - AddDetector(myDetector) ; - } - - - //////////////////////////////////////////// - //////////// Search for paris //////////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0, 5, "Paris") == 0 && cParis == false) { - cParis = true ; - G4cout << G4endl << "//////// Paris ////////" << G4endl ; - - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new Paris() ; - - // Read Position of Telescope - ConfigFile.close() ; - myDetector->ReadConfiguration(Path) ; - ConfigFile.open(Path.c_str()) ; - - // Add array to the VDetector Vector - AddDetector(myDetector) ; - } - - //////////////////////////////////////////// - //////////// Search for paris shield //////////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0, 6, "Shield") == 0 && cShield == false) { - cShield = true ; - G4cout << G4endl << "//////// Shield ////////" << G4endl ; - - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new Shield() ; - - // Read Position of Telescope - ConfigFile.close() ; - myDetector->ReadConfiguration(Path) ; - ConfigFile.open(Path.c_str()) ; - - // Add array to the VDetector Vector - AddDetector(myDetector) ; - } - - //////////////////////////////////////////// - ///// Search for S1 Annular detector ////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0, 9, "AnnularS1") == 0 && cS1 == false) { - cS1 = true ; - G4cout << G4endl << "//////// S1 Annular detector ////////" << G4endl << G4endl ; - - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new AnnularS1() ; - - // Read Position of Telescope - ConfigFile.close() ; - myDetector->ReadConfiguration(Path) ; - ConfigFile.open(Path.c_str()) ; - - // Add array to the VDetector Vector - AddDetector(myDetector) ; - } - - //////////////////////////////////////////// - ///// Search for S1 Annular detector ////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0, 2, "W1") == 0 && cW1 == false) { - cW1 = true ; - G4cout << G4endl << "//////// W1 Square detector ////////" << G4endl << G4endl; - - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new W1(); - - // Read Position of Telescope - ConfigFile.close(); - myDetector->ReadConfiguration(Path); - ConfigFile.open(Path.c_str()); - - // Add array to the VDetector Vector - AddDetector(myDetector); - } - - //////////////////////////////////////////// - //////// Search for MUST2 Array //////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0, 10, "MUST2Array") == 0 && cMUST2 == false) { - cMUST2 = true ; - G4cout << G4endl << "//////// MUST2 Array ////////" << G4endl << G4endl ; - - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new MUST2Array() ; - - // Read Position of Telescope - ConfigFile.close() ; - myDetector->ReadConfiguration(Path) ; - ConfigFile.open(Path.c_str()) ; - - // Add array to the VDetector Vector - AddDetector(myDetector) ; - } - - //////////////////////////////////////////// - ////////// Search for ThinSi /////////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0, 9, "SSSDArray") == 0 && cAddThinSi == false) { - cAddThinSi = true ; - G4cout << G4endl << "//////// SSSD ////////" << G4endl << G4endl ; - - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new ThinSi() ; - - // Read Position of Telescope - ConfigFile.close() ; - myDetector->ReadConfiguration(Path) ; - ConfigFile.open(Path.c_str()) ; - - // Add array to the VDetector Vector - AddDetector(myDetector) ; - } - - //////////////////////////////////////////// - ////////// Search for Plastic /////////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0, 19, "ScintillatorPlastic") == 0 && cPlastic == false) { - cPlastic = true ; - G4cout << G4endl << "//////// Plastic ////////" << G4endl << G4endl ; - - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new Plastic() ; - - // Read Position of detector - ConfigFile.close() ; - myDetector->ReadConfiguration(Path) ; - ConfigFile.open(Path.c_str()) ; - - // Add array to the VDetector Vector - AddDetector(myDetector) ; - } - - //////////////////////////////////////////// - //////////// Search for Target ///////////// - //////////////////////////////////////////// - - else if (LineBuffer.compare(0, 13, "GeneralTarget") == 0 && cGeneralTarget == false) { - cGeneralTarget = true ; - G4cout << G4endl << "////////// Target ///////////" << G4endl << G4endl ; - - // Instantiate the new array as a VDetector Objects - VDetector* myDetector = new Target(); - - // Read Position and target specification - ConfigFile.close(); - myDetector->ReadConfiguration(Path); - ConfigFile.open(Path.c_str()); - - // Add Target to DetectorConstruction - m_Target = (Target*) myDetector; - - // Add target to the VDetector Vector - AddDetector(myDetector); - } - //////////////////////////////////////////// - //////////// Search for Chamber ///////////// - //////////////////////////////////////////// - - else if (LineBuffer.compare(0, 14, "GeneralChamber") == 0 && cGeneralChamber == false) { - cGeneralChamber = true ; - G4cout << G4endl << "////////// Chamber ///////////" << G4endl << G4endl ; - - // Instantiate the new array as a VDetector Objects - VDetector* myDetector = new Chamber(); - - // Read Position and target specification - ConfigFile.close(); - myDetector->ReadConfiguration(Path); - ConfigFile.open(Path.c_str()); - - // Add Target to DetectorConstruction - m_Chamber = (Chamber*) myDetector; - - // Add target to the VDetector Vector - AddDetector(myDetector); - } - - //Nothing understandable - //else ; - } - - ConfigFile.close(); - return ; + ////////General Reading needs//////// + string LineBuffer; + string DataBuffer; + + /////////Checking Boolean//////////////////// + bool cAddThinSi = false; + bool cComptonTelescope = false; + bool cDummy = false; + bool cEurogam = false; + bool cGeneralTarget = false; + bool cGeneralChamber = false; + bool cGPDTracker = false; // Gaspard Tracker + bool cHYDTracker = false; // Hyde detector + bool cMUST2 = false; + bool cPlastic = false; + bool cParis = false; // Paris Calorimeter + bool cS1 = false; + bool cSharc = false; + bool cShield = false; // Paris Shield CsI + bool cW1 = false; // W1 Micron DSSD + ////////////////////////////////////////////////////////////////////////////////////////// + ifstream ConfigFile; + ConfigFile.open(Path.c_str()); + + if (ConfigFile.is_open()) { // should be always be true + cout << " Configuration file " << Path << " loading " << endl; + } + else { + cout << " Error, no configuration file" << Path << " found" << endl; + } + + while (!ConfigFile.eof()) { + //Pick-up next line + getline(ConfigFile, LineBuffer); + //Search for comment Symbol: % + if (LineBuffer.compare(0, 1, "%") == 0) { /*Do Nothing*/;} + + //////////////////////////////////////////// + /////// Search for a Dummy Detector //////// + //////////////////////////////////////////// + else if (LineBuffer.compare(0, 16, "TheDUMMYDetector") == 0 && cDummy == false) { + cDummy = true ; + G4cout << G4endl << "//////// DUMMY DETECTOR ////////" << G4endl << G4endl ; + + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new DUMMYDetector() ; + + // Read Position of detector + ConfigFile.close() ; + myDetector->ReadConfiguration(Path) ; + ConfigFile.open(Path.c_str()) ; + + // Add array to the VDetector Vector + AddDetector(myDetector) ; + } + + + ///////////////////////////////////////////////////// + //////////// Search for ComptonTelescope //////////// + ///////////////////////////////////////////////////// + else if (LineBuffer.compare(0, 16, "ComptonTelescope") == 0 && cComptonTelescope == false) { + cComptonTelescope = true; + G4cout << "//////// ComptonTelescope ////////" << G4endl; + + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new ComptonTelescope(); + + // Read Position of detector + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); + + // Add array to the VDetector Vector + AddDetector(myDetector); + } + + + //////////////////////////////////////////// + //////////// Search for Eurogam //////////// + //////////////////////////////////////////// + else if (LineBuffer.compare(0, 7, "Eurogam") == 0 && cEurogam == false) { + cEurogam = true; + G4cout << "//////// Eurogam ////////" << G4endl; + + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new Eurogam(); + + // Read Position of detector + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); + + // Add array to the VDetector Vector + AddDetector(myDetector); + } + + + //////////////////////////////////////////// + //////////// Search for Gaspard //////////// + //////////////////////////////////////////// + else if (LineBuffer.compare(0, 14, "GaspardTracker") == 0 && cGPDTracker == false) { + cGPDTracker = true ; + G4cout << G4endl << "//////// Gaspard Tracker ////////" << G4endl ; + + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new GaspardTracker() ; + + // Read Position of Telescope + ConfigFile.close() ; + myDetector->ReadConfiguration(Path) ; + ConfigFile.open(Path.c_str()) ; + + // Add array to the VDetector Vector + AddDetector(myDetector) ; + } + + + //////////////////////////////////////////// + //////////// Search for Hyde //////////// + //////////////////////////////////////////// + else if (LineBuffer.compare(0, 11, "HydeTracker") == 0 && cHYDTracker == false) { + cHYDTracker = true ; + G4cout << G4endl << "//////// Hyde Tracker ////////" << G4endl ; + + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new HydeTracker() ; + + // Read Position of Telescope + ConfigFile.close() ; + myDetector->ReadConfiguration(Path) ; + ConfigFile.open(Path.c_str()) ; + + // Add array to the VDetector Vector + AddDetector(myDetector) ; + } + + + //////////////////////////////////////////// + //////////// Search for paris //////////// + //////////////////////////////////////////// + else if (LineBuffer.compare(0, 5, "Paris") == 0 && cParis == false) { + cParis = true ; + G4cout << G4endl << "//////// Paris ////////" << G4endl ; + + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new Paris() ; + + // Read Position of Telescope + ConfigFile.close() ; + myDetector->ReadConfiguration(Path) ; + ConfigFile.open(Path.c_str()) ; + + // Add array to the VDetector Vector + AddDetector(myDetector) ; + } + + //////////////////////////////////////////// + //////////// Search for paris shield //////////// + //////////////////////////////////////////// + else if (LineBuffer.compare(0, 6, "Shield") == 0 && cShield == false) { + cShield = true ; + G4cout << G4endl << "//////// Shield ////////" << G4endl ; + + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new Shield() ; + + // Read Position of Telescope + ConfigFile.close() ; + myDetector->ReadConfiguration(Path) ; + ConfigFile.open(Path.c_str()) ; + + // Add array to the VDetector Vector + AddDetector(myDetector) ; + } + + //////////////////////////////////////////// + ///// Search for S1 Annular detector ////// + //////////////////////////////////////////// + else if (LineBuffer.compare(0, 9, "AnnularS1") == 0 && cS1 == false) { + cS1 = true ; + G4cout << G4endl << "//////// S1 Annular detector ////////" << G4endl << G4endl ; + + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new AnnularS1() ; + + // Read Position of Telescope + ConfigFile.close() ; + myDetector->ReadConfiguration(Path) ; + ConfigFile.open(Path.c_str()) ; + + // Add array to the VDetector Vector + AddDetector(myDetector) ; + } + + //////////////////////////////////////////// + ///// Search for S1 Annular detector ////// + //////////////////////////////////////////// + else if (LineBuffer.compare(0, 2, "W1") == 0 && cW1 == false) { + cW1 = true ; + G4cout << G4endl << "//////// W1 Square detector ////////" << G4endl << G4endl; + + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new W1(); + + // Read Position of Telescope + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); + + // Add array to the VDetector Vector + AddDetector(myDetector); + } + + //////////////////////////////////////////// + //////// Search for MUST2 Array //////// + //////////////////////////////////////////// + else if (LineBuffer.compare(0, 10, "MUST2Array") == 0 && cMUST2 == false) { + cMUST2 = true ; + G4cout << G4endl << "//////// MUST2 Array ////////" << G4endl << G4endl ; + + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new MUST2Array() ; + + // Read Position of Telescope + ConfigFile.close() ; + myDetector->ReadConfiguration(Path) ; + ConfigFile.open(Path.c_str()) ; + + // Add array to the VDetector Vector + AddDetector(myDetector) ; + } + + //////////////////////////////////////////// + ////////// Search for ThinSi /////////// + //////////////////////////////////////////// + else if (LineBuffer.compare(0, 9, "SSSDArray") == 0 && cAddThinSi == false) { + cAddThinSi = true ; + G4cout << G4endl << "//////// SSSD ////////" << G4endl << G4endl ; + + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new ThinSi() ; + + // Read Position of Telescope + ConfigFile.close() ; + myDetector->ReadConfiguration(Path) ; + ConfigFile.open(Path.c_str()) ; + + // Add array to the VDetector Vector + AddDetector(myDetector) ; + } + + //////////////////////////////////////////// + ////////// Search for Sharc /////////// + //////////////////////////////////////////// + else if (LineBuffer.compare(0, 5, "Sharc") == 0 && cSharc == false) { + cSharc = true ; + G4cout << G4endl << "//////// Sharc ////////" << G4endl << G4endl ; + + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new Sharc(); + + // Read Position of detector + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); + + // Add array to the VDetector Vector + AddDetector(myDetector); + } + + //////////////////////////////////////////// + ////////// Search for Plastic /////////// + //////////////////////////////////////////// + else if (LineBuffer.compare(0, 19, "ScintillatorPlastic") == 0 && cPlastic == false) { + cPlastic = true ; + G4cout << G4endl << "//////// Plastic ////////" << G4endl << G4endl ; + + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new Plastic() ; + + // Read Position of detector + ConfigFile.close() ; + myDetector->ReadConfiguration(Path) ; + ConfigFile.open(Path.c_str()) ; + + // Add array to the VDetector Vector + AddDetector(myDetector) ; + } + + //////////////////////////////////////////// + //////////// Search for Target ///////////// + //////////////////////////////////////////// + + else if (LineBuffer.compare(0, 13, "GeneralTarget") == 0 && cGeneralTarget == false) { + cGeneralTarget = true ; + G4cout << G4endl << "////////// Target ///////////" << G4endl << G4endl ; + + // Instantiate the new array as a VDetector Objects + VDetector* myDetector = new Target(); + + // Read Position and target specification + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); + + // Add Target to DetectorConstruction + m_Target = (Target*) myDetector; + + // Add target to the VDetector Vector + AddDetector(myDetector); + } + //////////////////////////////////////////// + //////////// Search for Chamber ///////////// + //////////////////////////////////////////// + + else if (LineBuffer.compare(0, 14, "GeneralChamber") == 0 && cGeneralChamber == false) { + cGeneralChamber = true ; + G4cout << G4endl << "////////// Chamber ///////////" << G4endl << G4endl ; + + // Instantiate the new array as a VDetector Objects + VDetector* myDetector = new Chamber(); + + // Read Position and target specification + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); + + // Add Target to DetectorConstruction + m_Chamber = (Chamber*) myDetector; + + // Add target to the VDetector Vector + AddDetector(myDetector); + } + + //Nothing understandable + //else ; + } + + ConfigFile.close(); + return ; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::ReadAllSensitive(const G4Event* event) { - // Before looping on each sub-detector, clear the static variable - // ms_InterCoord - // This is done on the first element of the m_Modules vector. - // This should be done here since this variable (of type TIneractionCoordinates) - // deals with multiplicity of events > 1. - if(m_Detectors.size()>0) - m_Detectors[0]->GetInterCoordPointer()->Clear(); - - for (unsigned short i = 0 ; i < m_Detectors.size() ; i++) { - m_Detectors[i]->ReadSensitive(event); - } + // Before looping on each sub-detector, clear the static variable + // ms_InterCoord + // This is done on the first element of the m_Modules vector. + // This should be done here since this variable (of type TIneractionCoordinates) + // deals with multiplicity of events > 1. + if(m_Detectors.size()>0) + m_Detectors[0]->GetInterCoordPointer()->Clear(); + + for (unsigned short i = 0 ; i < m_Detectors.size() ; i++) { + m_Detectors[i]->ReadSensitive(event); + } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4LogicalVolume* DetectorConstruction::GetWorldLogic() { - return world_log; + return world_log; } diff --git a/NPSimulation/src/ParticleStack.cc b/NPSimulation/src/ParticleStack.cc index ba6a037852899eac52f74759f7c5ca8cbfeb5e6e..01ff34c02a2e503010a541ef96f28b0da14b5e36 100644 --- a/NPSimulation/src/ParticleStack.cc +++ b/NPSimulation/src/ParticleStack.cc @@ -191,4 +191,5 @@ void ParticleStack::ShootAllParticle(G4Event* anEvent){ } } m_ParticleStack.clear(); + m_InitialConditions->Clear(); } \ No newline at end of file diff --git a/NPSimulation/src/Sharc.cc b/NPSimulation/src/Sharc.cc new file mode 100644 index 0000000000000000000000000000000000000000..7fb04898249796fd6c5b06020918ef222b06f833 --- /dev/null +++ b/NPSimulation/src/Sharc.cc @@ -0,0 +1,540 @@ +/***************************************************************************** + * Copyright (C) 2009-2010 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Adrien MATTA contact address: matta@ipno.in2p3.fr * + * * + * Creation Date : November 2012 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class describe the SHarc Silicon array * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ + +// C++ headers +#include <sstream> +#include <cmath> +#include <limits> +//G4 Geometry object +#include "G4Trd.hh" +#include "G4Box.hh" +#include "G4Trap.hh" + +//G4 sensitive +#include "G4SDManager.hh" +#include "G4MultiFunctionalDetector.hh" + +//G4 various object +#include "G4MaterialTable.hh" +#include "G4Element.hh" +#include "G4ElementTable.hh" +#include "G4Transform3D.hh" +#include "G4PVPlacement.hh" +#include "G4VisAttributes.hh" +#include "G4Colour.hh" +#include "G4PVDivision.hh" +#include "G4SubtractionSolid.hh" + +// NPTool header +#include "Sharc.hh" +#include "GeneralScorers.hh" +//#include "SharcScorers.hh" +#include "RootOutput.h" +using namespace SHARC; + +// 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...... +// Sharc Specific Method +Sharc::Sharc() +{ + InitializeMaterial(); + // m_Event = new TSSSDData(); +} + +Sharc::~Sharc() +{ + delete m_MaterialSilicon; + delete m_MaterialAl; + delete m_MaterialVacuum; + +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void Sharc::AddBoxDetector(G4ThreeVector Pos) +{ + m_Type.push_back(true); + m_Pos.push_back(Pos); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void Sharc::AddQQQDetector(G4ThreeVector Pos) +{ + m_Type.push_back(false); + m_Pos.push_back(Pos); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void Sharc::VolumeMaker(G4int DetNumber , + G4ThreeVector Det_pos , + G4RotationMatrix* Det_rot , + G4LogicalVolume* world ) +{ + // create the DSSD + G4Box* PCBFull = new G4Box("PCBFull" ,90*mm,60*mm,1*mm); + G4Box* Wafer = new G4Box("Wafer",72*mm,48*mm,100*um); + + G4SubtractionSolid* PCB = new G4SubtractionSolid("PCB", PCBFull, Wafer); + + G4LogicalVolume* logicPCB = + new G4LogicalVolume(PCB, m_MaterialSilicon, "logicPCB", 0, 0, 0); + + new G4PVPlacement(0, G4ThreeVector(0,0,0), logicPCB, "TEST", world, false, 0); + +} + +//....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 Sharc::ReadConfiguration(string Path) +{ + ifstream ConfigFile ; + ConfigFile.open(Path.c_str()) ; + string LineBuffer ; + string DataBuffer ; + + G4double R,Phi,X,Y,Z; + G4ThreeVector Pos; + bool check_R = false ; + bool check_Phi = false ; + bool check_X = false ; + bool check_Y = false ; + bool check_Z = false ; + + bool ReadingStatusQQQ = false ; + bool ReadingStatusBOX = false ; + bool ReadingStatus = false ; + while (!ConfigFile.eof()){ + + getline(ConfigFile, LineBuffer); + // cout << LineBuffer << endl; + if (LineBuffer.compare(0, 5, "Sharc") == 0) + ReadingStatus = true; + + while (ReadingStatus && !ConfigFile.eof()) { + ConfigFile >> DataBuffer ; + // Comment Line + if (DataBuffer.compare(0, 1, "%") == 0) { ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );} + + // CD case + if (DataBuffer=="SharcQQQ"){ + G4cout << "///" << G4endl ; + G4cout << "QQQ Quadrant found: " << G4endl ; + ReadingStatusQQQ = true ; + } + + // Box case + else if (DataBuffer=="SharcBOX"){ + G4cout << "///" << G4endl ; + G4cout << "Box Detector found: " << G4endl ; + ReadingStatusBOX = true ; + } + + // Reading Block + while(ReadingStatusQQQ){ + // Pickup Next Word + ConfigFile >> DataBuffer ; + + // Comment Line + if (DataBuffer.compare(0, 1, "%") == 0) { ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );} + + //Position method + else if (DataBuffer == "Z=") { + check_Z = true; + ConfigFile >> DataBuffer ; + Z= atof(DataBuffer.c_str())*mm; + cout << " Z= " << Z/mm << "mm" << endl; + } + + else if (DataBuffer == "R=") { + check_R = true; + ConfigFile >> DataBuffer ; + R= atof(DataBuffer.c_str())*mm; + cout << " R= " << R/mm << "mm" << endl; + } + + else if (DataBuffer == "Phi=") { + check_Phi = true; + ConfigFile >> DataBuffer ; + Phi= atof(DataBuffer.c_str())*deg; + cout << " Phi= " << Phi/deg << "deg" << endl; + } + + /////////////////////////////////////////////////// + // If no Detector Token and no comment, toggle out + else{ + ReadingStatusQQQ = false; + G4cout << "Error: Wrong Token Sequence: Getting out " << DataBuffer << G4endl ; + exit(1); + } + + ///////////////////////////////////////////////// + // If All necessary information there, toggle out + + if (check_R && check_Phi && check_Z){ + + ReadingStatusQQQ = false; + AddQQQDetector(G4ThreeVector(Z,R,Phi)); + // Reinitialisation of Check Boolean + check_R = false ; + check_Phi = false ; + check_X = false; + check_Y = false; + check_Z = false ; + + } + + } + + while(ReadingStatusBOX){ + // Pickup Next Word + ConfigFile >> DataBuffer ; + + // Comment Line + if (DataBuffer.compare(0, 1, "%") == 0) { ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );} + + //Position method + else if (DataBuffer == "X=") { + check_X = true; + ConfigFile >> DataBuffer ; + X= atof(DataBuffer.c_str())*mm; + cout << " X= " << Y/mm << "mm" << endl; + } + + else if (DataBuffer == "Y=") { + check_Y = true; + ConfigFile >> DataBuffer ; + Y= atof(DataBuffer.c_str())*mm; + cout << " Y= " << Y/mm << "mm" << endl; + } + + else if (DataBuffer == "Z=") { + check_Z = true; + ConfigFile >> DataBuffer ; + Z= atof(DataBuffer.c_str())*mm; + cout << " Z= " << Z/mm << "mm" << endl; + } + + /////////////////////////////////////////////////// + // If no Detector Token and no comment, toggle out + else{ + ReadingStatusBOX = false; + G4cout << "Error: Wrong Token Sequence: Getting out " << DataBuffer << G4endl ; + exit(1); + } + + ///////////////////////////////////////////////// + // If All necessary information there, toggle out + + if (check_X && check_Y && check_Z){ + ReadingStatusBOX = false; + AddBoxDetector(G4ThreeVector(X,Y,Z)); + // Reinitialisation of Check Boolean + check_R = false ; + check_Phi = false ; + check_X = false; + check_Y = false; + check_Z = false ; + + } + + } + } + } +} + +// Construct detector and inialise sensitive part. +// Called After DetecorConstruction::AddDetector Method +void Sharc::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); + + 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 outside + Det_u = m_TL[i] - m_BL[i]; + Det_u = Det_u.unit(); + Det_v = m_BR[i] - m_BL[i]; + Det_v = Det_v.unit(); + Det_w = Det_u.cross(Det_v); + Det_w = Det_w.unit(); + // Passage Matrix from Lab Referential to Telescope Referential + // 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 ; + } + + // 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; + + + // (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); + Det_w = G4ThreeVector(wX, wY, wZ); + + // vector corresponding to the center of the module + G4ThreeVector CT = Det_w; + + // 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); + + Det_w = Det_w.unit(); + Det_u = Det_w.cross(Y); + Det_v = Det_w.cross(Det_u); + Det_v = Det_v.unit(); + Det_u = Det_u.unit(); + + // Passage Matrix from Lab Referential to Telescope Referential + // MUST2 + Det_rot = new G4RotationMatrix(Det_u, Det_v, Det_w); + // Telescope is rotate of Beta angle around Det_v axis. + Det_rot->rotate(m_beta_u[i], Det_u); + 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 ; + } + + + + VolumeMaker(i + 1 , Det_pos , Det_rot , world); + } + + delete Det_rot ;*/ + + // create the DSSD + G4Box* PCBFull = new G4Box("PCBFull" ,90*mm,60*mm,1*mm); + G4Box* Wafer = new G4Box("Wafer",72*mm,48*mm,1.01*mm); + G4ThreeVector zTrans(0, 0, 50); + G4SubtractionSolid* PCB = new G4SubtractionSolid("PCB", PCBFull, Wafer,new G4RotationMatrix,G4ThreeVector(10*mm, 10*mm,0 )); + + G4LogicalVolume* logicPCB = + new G4LogicalVolume(PCB, m_MaterialSilicon, "logicPCB", 0, 0, 0); + + new G4PVPlacement(new G4RotationMatrix(0,90*deg,0), G4ThreeVector(0,30*mm,-70), logicPCB, "TEST", world, false, 0); +} + +// Add Detector branch to the EventTree. +// Called After DetecorConstruction::AddDetector Method +void Sharc::InitializeRootOutput() +{ + /* RootOutput *pAnalysis = RootOutput::getInstance(); + TTree *pTree = pAnalysis->GetTree(); + pTree->Branch("SSSD", "TSSSDData", &m_Event) ;*/ +} + +// Read sensitive part and fill the Root tree. +// Called at in the EventAction::EndOfEventAvtion +void Sharc::ReadSensitive(const G4Event* event) +{ + /* m_Event->Clear(); + ////////////////////////////////////////////////////////////////////////////////////// + //////////////////////// Used to Read Event Map of detector ////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + + // Si + G4THitsMap<G4int>* DetNbrHitMap; + G4THitsMap<G4int>* StripNbrHitMap; + G4THitsMap<G4double>* EnergyHitMap; + G4THitsMap<G4double>* TimeHitMap; + + std::map<G4int, G4int*>::iterator DetNbr_itr ; + std::map<G4int, G4int*>::iterator StripNbr_itr ; + std::map<G4int, G4double*>::iterator Energy_itr ; + std::map<G4int, G4double*>::iterator Time_itr ; + ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + // Read the Scorer associate to the Silicon Strip + + //DetectorNumber + G4int DetNbrCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("Sharc_StripScorer/DetectorNumber"); + DetNbrHitMap = (G4THitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(DetNbrCollectionID)); + DetNbr_itr = DetNbrHitMap->GetMap()->begin(); + + //StripNumber + G4int StripNbrCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("Sharc_StripScorer/StripNumber"); + StripNbrHitMap = (G4THitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripNbrCollectionID)); + + //Energy + G4int StripEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("Sharc_StripScorer/StripEnergy"); + EnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripEnergyCollectionID)); + + //Time + G4int StripTimeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("Sharc_StripScorer/StripTime"); + TimeHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripTimeCollectionID)); + + G4int sizeN = DetNbrHitMap ->entries(); + G4int sizeS = StripNbrHitMap ->entries(); + G4int sizeE = EnergyHitMap ->entries(); + G4int sizeT = TimeHitMap ->entries(); + + // Loop on Det Number + for (G4int l = 0 ; l < sizeN ; l++) + { + G4int N = *(DetNbr_itr->second); + G4int NTrackID = DetNbr_itr->first - N; + + if (N > 0) + { + m_Event->SetEnergyDetectorNbr(N); + m_Event->SetTimeDetectorNbr(N); + + // Strip Number + StripNbr_itr = StripNbrHitMap->GetMap()->begin(); + for (G4int h = 0 ; h < sizeS ; h++) { + G4int STrackID = StripNbr_itr->first - N ; + G4int S = *(StripNbr_itr->second); + + if (STrackID == NTrackID) { + m_Event->SetEnergyStripNbr(S); + m_Event->SetTimeStripNbr(S); + } + + StripNbr_itr++; + } + + // 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->SetEnergy( RandGauss::shoot(E, ResoEnergy ) ); + } + + 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->SetTime( RandGauss::shoot(T, ResoTime ) ); + } + + Time_itr++; + } + + } + + DetNbr_itr++; + } + + // clear map for next event + + DetNbrHitMap ->clear(); + StripNbrHitMap ->clear(); + EnergyHitMap ->clear(); + TimeHitMap ->clear();*/ +} + + +void Sharc::InitializeScorers() +{ + /* + // Silicon Associate Scorer + m_StripScorer = new G4MultiFunctionalDetector("Sharc_StripScorer"); + + G4VPrimitiveScorer* DetNbr = new GENERALSCORERS::PSDetectorNumber("DetectorNumber","Sharc_", 0); + G4VPrimitiveScorer* StripNbr = new PSStripNumber("StripNumber",0,SiliconSize, NumberOfStrip); + G4VPrimitiveScorer* Energy = new GENERALSCORERS::PSEnergy("StripEnergy","Sharc_", 0); + G4VPrimitiveScorer* TOF = new GENERALSCORERS::PSTOF("StripTime","Sharc_", 0); + + + //and register it to the multifunctionnal detector + m_StripScorer->RegisterPrimitive(DetNbr); + m_StripScorer->RegisterPrimitive(StripNbr); + m_StripScorer->RegisterPrimitive(Energy); + m_StripScorer->RegisterPrimitive(TOF); + + // Add All Scorer to the Global Scorer Manager + G4SDManager::GetSDMpointer()->AddNewDetector(m_StripScorer) ;*/ +} + +//////////////////////////////////////////////////////////////// +/////////////////Material Definition /////////////////////////// +//////////////////////////////////////////////////////////////// +void Sharc::InitializeMaterial() +{ + + G4Element* N = new G4Element("Nitrogen" , "N" , 7 , 14.01 * g / mole); + G4Element* O = new G4Element("Oxigen" , "O" , 8 , 16.00 * g / mole); + + G4double a, z, density; + // Si + a = 28.0855 * g / mole; + density = 2.321 * g / cm3; + m_MaterialSilicon = new G4Material("Si", z = 14., a, density); + + // Al + density = 2.702 * g / cm3; + a = 26.98 * g / mole; + m_MaterialAl = new G4Material("Al", z = 13., a, density); + + // Vacuum + density = 0.000000001 * mg / cm3; + m_MaterialVacuum = new G4Material("Vacuum", density, 2); + m_MaterialVacuum->AddElement(N, .7); + m_MaterialVacuum->AddElement(O, .3); +} + + diff --git a/NPSimulation/vis.mac b/NPSimulation/vis.mac index c510026907f09b443c90c2c4fc12293827072fe5..807cb6ecdc4472aa01645f87cc2bcf59b10dd986 100644 --- a/NPSimulation/vis.mac +++ b/NPSimulation/vis.mac @@ -1,27 +1,77 @@ -#verbose level -/control/verbose 0 -/material/verbose 0 -/tracking/verbose 0 -/process/verbose 0 -/event/verbose 0 -/run/verbose 0 - -# choose a graphic system -#/vis/open OGLIX -#/vis/open OGLSX -/vis/open VRML2FILE -/vis/scene/create +# Macro file for the initialization phase of "exampleN03.cc" +# when running in interactive mode +# +# Sets some default verbose +# +/control/verbose 2 +/control/saveHistory +/run/verbose 2 +# +# Use this open statement to create an OpenGL view: +/vis/open OGLIQt 600x600-0+0 +# +# Use this open statement to create a .prim file suitable for +# viewing in DAWN: +#/vis/open DAWNFILE +# +# Use this open statement to create a .heprep file suitable for +# viewing in HepRApp: +#/vis/open HepRepFile +# +# Use this open statement to create a .wrl file suitable for +# viewing in a VRML viewer: +#/vis/open VRML2FILE +# +# Disable auto refresh and quieten vis messages whilst scene and +# trajectories are established: +/vis/viewer/set/autoRefresh false +/vis/verbose errors +# +# Draw geometry: /vis/drawVolume -/vis/viewer/set/viewpointThetaPhi 0 0 deg -/vis/viewer/zoom 7 - -## options to draw trajectories -/vis/scene/endOfEventAction accumulate -/vis/scene/add/trajectories 1 -/tracking/storeTrajectory 1 +# +# Specify view angle: +#/vis/viewer/set/viewpointThetaPhi 90. 0. +# +# Specify zoom value: +#/vis/viewer/zoom 2. +# +# Specify style (surface or wireframe): +#/vis/viewer/set/style wireframe +# +# Draw coordinate axes: /vis/scene/add/axes 0 0 0 20 cm -/vis/viewer/refresh - -# run event -#/run/beamOn 0 -#/run/beamOn 10000 +# +# Draw smooth trajectories at end of event, showing trajectory points +# as markers 2 pixels wide: +/vis/scene/add/trajectories smooth +/vis/modeling/trajectories/create/drawByCharge +/vis/modeling/trajectories/drawByCharge-0/default/setDrawStepPts true +/vis/modeling/trajectories/drawByCharge-0/default/setStepPtsSize 1 +# (if too many tracks cause core dump => /tracking/storeTrajectory 0) +# +# Draw hits at end of event: +#vis/scene/add/hits +# +# To draw only gammas: +#/vis/filtering/trajectories/create/particleFilter +#/vis/filtering/trajectories/particleFilter-0/add gamma +# +# To invert the above, drawing all particles except gammas, +# keep the above two lines but also add: +#/vis/filtering/trajectories/particleFilter-0/invert true +# +# Many other options are available with /vis/modeling and /vis/filtering. +# For example, to select colour by particle ID: +#/vis/modeling/trajectories/create/drawByParticleID +#/vis/modeling/trajectories/drawByParticleID-0/set e- blue +# +# To superimpose all of the events from a given run: +/vis/scene/endOfEventAction accumulate +# +# Re-establish auto refreshing and verbosity: +/vis/viewer/set/autoRefresh true +/vis/verbose 0 +# +# For file-based drivers, use this to create an empty detector view: +/vis/viewer/flush