From 78d7257c2a0c62cf9c2a6545c99a3bff8e2c44f9 Mon Sep 17 00:00:00 2001 From: nicolas <nicolas@nptool> Date: Thu, 14 Feb 2013 23:00:04 +0000 Subject: [PATCH] * Add Hyde2 to NPSimulation --- NPSimulation/include/Hyde2Scorers.hh | 311 ++++ NPSimulation/include/Hyde2Tracker.hh | 73 + NPSimulation/include/Hyde2TrackerModule.hh | 114 ++ NPSimulation/include/Hyde2TrackerSquare1.hh | 213 +++ .../include/Hyde2TrackerTrapezoid1.hh | 220 +++ .../include/Hyde2TrackerTrapezoid2.hh | 220 +++ NPSimulation/src/DetectorConstruction.cc | 24 + NPSimulation/src/Hyde2Scorers.cc | 820 +++++++++++ NPSimulation/src/Hyde2Tracker.cc | 170 +++ NPSimulation/src/Hyde2TrackerModule.cc | 62 + NPSimulation/src/Hyde2TrackerSquare1.cc | 1252 ++++++++++++++++ NPSimulation/src/Hyde2TrackerTrapezoid1.cc | 1286 +++++++++++++++++ NPSimulation/src/Hyde2TrackerTrapezoid2.cc | 1286 +++++++++++++++++ 13 files changed, 6051 insertions(+) create mode 100644 NPSimulation/include/Hyde2Scorers.hh create mode 100644 NPSimulation/include/Hyde2Tracker.hh create mode 100644 NPSimulation/include/Hyde2TrackerModule.hh create mode 100644 NPSimulation/include/Hyde2TrackerSquare1.hh create mode 100644 NPSimulation/include/Hyde2TrackerTrapezoid1.hh create mode 100644 NPSimulation/include/Hyde2TrackerTrapezoid2.hh create mode 100644 NPSimulation/src/Hyde2Scorers.cc create mode 100644 NPSimulation/src/Hyde2Tracker.cc create mode 100644 NPSimulation/src/Hyde2TrackerModule.cc create mode 100644 NPSimulation/src/Hyde2TrackerSquare1.cc create mode 100644 NPSimulation/src/Hyde2TrackerTrapezoid1.cc create mode 100644 NPSimulation/src/Hyde2TrackerTrapezoid2.cc diff --git a/NPSimulation/include/Hyde2Scorers.hh b/NPSimulation/include/Hyde2Scorers.hh new file mode 100644 index 000000000..56386ea40 --- /dev/null +++ b/NPSimulation/include/Hyde2Scorers.hh @@ -0,0 +1,311 @@ +/***************************************************************************** + * 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : 11/07/09 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: This class holds all the scorers needed by the * + * Hyde2Tracker*** objects. * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#ifndef HYD2Scorer_h +#define HYD2Scorer_h 1 + +#include "G4VPrimitiveScorer.hh" +#include "G4THitsMap.hh" + +namespace HYD2SCORERS +{ + +class HYD2ScorerFirstStageEnergy : public G4VPrimitiveScorer +{ +public: // with description + HYD2ScorerFirstStageEnergy(G4String name, G4String volumeName, G4int depth = 0); + virtual ~HYD2ScorerFirstStageEnergy(); + +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 HYD2ScorerSecondStageEnergy : public G4VPrimitiveScorer +{ +public: // with description + HYD2ScorerSecondStageEnergy(G4String name, G4String volumeName, G4int depth = 0); + virtual ~HYD2ScorerSecondStageEnergy(); + +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 HYD2ScorerThirdStageEnergy : public G4VPrimitiveScorer +{ +public: // with description + HYD2ScorerThirdStageEnergy(G4String name, G4String volumeName, G4int depth = 0); + virtual ~HYD2ScorerThirdStageEnergy(); + +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 HYD2ScorerFourthStageEnergy : public G4VPrimitiveScorer +{ +public: // with description + HYD2ScorerFourthStageEnergy(G4String name, G4String volumeName, G4int depth = 0); + virtual ~HYD2ScorerFourthStageEnergy(); + +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 HYD2ScorerFifthStageEnergy : public G4VPrimitiveScorer +{ +public: // with description + HYD2ScorerFifthStageEnergy(G4String name, G4String volumeName, G4int depth = 0); + virtual ~HYD2ScorerFifthStageEnergy(); + +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 HYD2ScorerSixthStageEnergy : public G4VPrimitiveScorer +{ +public: // with description + HYD2ScorerSixthStageEnergy(G4String name, G4String volumeName, G4int depth = 0); + virtual ~HYD2ScorerSixthStageEnergy(); + +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 HYD2ScorerFirstStageFrontStripSquare1 : public G4VPrimitiveScorer +{ +public: // with description + HYD2ScorerFirstStageFrontStripSquare1(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); + virtual ~HYD2ScorerFirstStageFrontStripSquare1(); + +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<G4double>* EvtMap; +}; + + + +class HYD2ScorerFirstStageBackStripSquare1 : public G4VPrimitiveScorer +{ +public: // with description + HYD2ScorerFirstStageBackStripSquare1(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); + virtual ~HYD2ScorerFirstStageBackStripSquare1(); + +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<G4double>* EvtMap; +}; + + + +class HYD2ScorerFirstStageFrontStripTrapezoid1 : public G4VPrimitiveScorer +{ +public: // with description + HYD2ScorerFirstStageFrontStripTrapezoid1(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); + virtual ~HYD2ScorerFirstStageFrontStripTrapezoid1(); + +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<G4double>* EvtMap; +}; + + + +class HYD2ScorerFirstStageBackStripTrapezoid1 : public G4VPrimitiveScorer +{ +public: // with description + HYD2ScorerFirstStageBackStripTrapezoid1(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); + virtual ~HYD2ScorerFirstStageBackStripTrapezoid1(); + +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<G4double>* EvtMap; +}; + +class HYD2ScorerFirstStageFrontStripTrapezoid2 : public G4VPrimitiveScorer +{ +public: // with description + HYD2ScorerFirstStageFrontStripTrapezoid2(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); + virtual ~HYD2ScorerFirstStageFrontStripTrapezoid2(); + +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<G4double>* EvtMap; +}; + + + +class HYD2ScorerFirstStageBackStripTrapezoid2 : public G4VPrimitiveScorer +{ +public: // with description + HYD2ScorerFirstStageBackStripTrapezoid2(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); + virtual ~HYD2ScorerFirstStageBackStripTrapezoid2(); + +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<G4double>* EvtMap; +}; + +} + +using namespace HYD2SCORERS; +#endif diff --git a/NPSimulation/include/Hyde2Tracker.hh b/NPSimulation/include/Hyde2Tracker.hh new file mode 100644 index 000000000..00c26ff5a --- /dev/null +++ b/NPSimulation/include/Hyde2Tracker.hh @@ -0,0 +1,73 @@ +/***************************************************************************** + * 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : 10/06/09 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: This class manages different shapes of module for the Hyde2 * + * tracker. It allows to have Hyde2 geometries with an * + * heterogeneous set of modules * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#ifndef Hyde2Tracker_h +#define Hyde2Tracker_h 1 + +// C++ headers +#include <vector> + +// NPTool header +#include "VDetector.hh" +#include "Hyde2TrackerModule.hh" + +using namespace std; + + + +class Hyde2Tracker : public VDetector +{ + //////////////////////////////////////////////////// + /////// Default Constructor and Destructor ///////// + //////////////////////////////////////////////////// +public: + Hyde2Tracker(); + virtual ~Hyde2Tracker(); + + //////////////////////////////////////////////////// + ///////// 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); + +public: + // Initialize all scorers necessary for each detector + void InitializeScorers(); + +private: + vector<Hyde2TrackerModule*> m_Modules; +}; +#endif diff --git a/NPSimulation/include/Hyde2TrackerModule.hh b/NPSimulation/include/Hyde2TrackerModule.hh new file mode 100644 index 000000000..4ea863639 --- /dev/null +++ b/NPSimulation/include/Hyde2TrackerModule.hh @@ -0,0 +1,114 @@ +/***************************************************************************** + * 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : 10/06/09 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: This class is an Abstract Base Class (ABC) from which should * + * derive all different modules from the Hyde2 tracker. * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#ifndef Hyde2TrackerModule_h +#define Hyde2TrackerModule_h 1 + +// C++ headers +#include <string> +#include <vector> + +// G4 headers +#include "G4LogicalVolume.hh" +#include "G4Event.hh" +#include "G4MultiFunctionalDetector.hh" + +// NPTool - ROOT headers +#include "TInteractionCoordinates.h" +#include "THyde2TrackerData.h" + +using namespace std; + + + +class Hyde2TrackerModule +{ +public: + Hyde2TrackerModule(); + virtual ~Hyde2TrackerModule(); + +public: + // Read stream at Configfile to pick-up parameters of detector (Position,...) + virtual void ReadConfiguration(string Path) = 0; + + // Construct detector and inialise sensitive part. + virtual void ConstructDetector(G4LogicalVolume* world) = 0; + + // Read sensitive part of a the Hyde2TrackerModule detector and fill the Root tree. + virtual void ReadSensitive(const G4Event* event) = 0; + + // Add Detector branch to the ROOT output tree + virtual void InitializeRootOutput(); + + // Initialize all scorers necessary for each detector + virtual void InitializeScorers() = 0; + + // Give the static TInteractionCoordinates from VDetector to the classes + // deriving from Hyde2TrackerModule + // This is mandatory since the Hyde2Tracker*** does not derive from VDetector + virtual void SetInterCoordPointer(TInteractionCoordinates* interCoord) = 0; + virtual TInteractionCoordinates* GetInterCoordPointer() = 0; + + // Initialize the Index map for the different modules of Hyde2 + void InitializeIndex(); + +public: + THyde2TrackerData* GetEventPointer() {return ms_Event;}; + +protected: + // Class to store the result of simulation + static THyde2TrackerData* ms_Event; + + // Set to true if you want this stage on you telescope + vector<bool> m_wFirstStage; + vector<bool> m_wSecondStage; + vector<bool> m_wThirdStage; + vector<bool> m_wFourthStage; + vector<bool> m_wFifthStage; + vector<bool> m_wSixthStage; + + // Set to true if you want to see Telescope Frame in your visualisation + bool m_non_sensitive_part_visiualisation; + +protected: + // First stage Associate Scorer + G4MultiFunctionalDetector* m_FirstStageScorer; + + // Second stage Associate Scorer + G4MultiFunctionalDetector* m_SecondStageScorer; + + // Third stage Associate Scorer + G4MultiFunctionalDetector* m_ThirdStageScorer; + + // Fourth stage Associate Scorer + G4MultiFunctionalDetector* m_FourthStageScorer; + + // Fifth stage Associate Scorer + G4MultiFunctionalDetector* m_FifthStageScorer; + + // Sixth stage Associate Scorer + G4MultiFunctionalDetector* m_SixthStageScorer; + +protected: + map<string, int> m_index; +}; + +#endif diff --git a/NPSimulation/include/Hyde2TrackerSquare1.hh b/NPSimulation/include/Hyde2TrackerSquare1.hh new file mode 100644 index 000000000..ab6f53da6 --- /dev/null +++ b/NPSimulation/include/Hyde2TrackerSquare1.hh @@ -0,0 +1,213 @@ +/***************************************************************************** + * 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : 10/06/09 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: Define a module of square shape for the Hyde2 tracker * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#ifndef Hyde2TrackerSquare1_h +#define Hyde2TrackerSquare1_h 1 + +// C++ headers +#include <vector> + +// NPTool header +#include "Hyde2TrackerModule.hh" +#include "TInteractionCoordinates.h" + +using namespace std; + + + +class Hyde2TrackerSquare1 : public Hyde2TrackerModule +{ + //////////////////////////////////////////////////// + /////// Default Constructor and Destructor ///////// + //////////////////////////////////////////////////// +public: + Hyde2TrackerSquare1(); + virtual ~Hyde2TrackerSquare1(); + + //////////////////////////////////////////////////// + //////// Specific Function of this Class /////////// + //////////////////////////////////////////////////// +public: + // By Position Method + void AddModule(G4ThreeVector TL , + G4ThreeVector BL , + G4ThreeVector BR , + G4ThreeVector CT , + bool wFirstStage , + bool wSecondStage , + bool wThirdStage , + bool wFourthStage , + bool wFifthStage , + bool wSixthStage); + + // By Angle Method + void 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); + + // Effectively construct Volume + // Avoid to have two time same code for Angle and Point definition + void VolumeMaker(G4int TelescopeNumber , + G4ThreeVector MMpos , + G4RotationMatrix* MMrot , + bool wFirstStage , + bool wSecondStage , + bool wThirdStage , + bool wFourthStage , + bool wFifthStage , + bool wSixthStage , + G4LogicalVolume* world); + + + //////////////////////////////////////////////////// + //// Inherite from Hyde2TrackerModule 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(); + + // Initialize all scorers necessary for the detector + void InitializeScorers(); + + // Read sensitive part and fill the Root tree. + // Called at in the EventAction::EndOfEventAvtion + void ReadSensitive(const G4Event* event); + + // Give the static TInteractionCoordinates from VDetector to the classes + // deriving from Hyde2TrackerModule + // This is mandatory since the Hyde2Tracker*** does not derive from VDetector + void SetInterCoordPointer(TInteractionCoordinates* interCoord); + TInteractionCoordinates* GetInterCoordPointer() {return ms_InterCoord;}; + + + //////////////////////////////////////////////////// + ///////////////Private intern Data////////////////// + //////////////////////////////////////////////////// +private: + // Interaction Coordinates coming from VDetector through the + // SetInteractionCoordinatesPointer method + TInteractionCoordinates* ms_InterCoord; + + // True if Define by Position, False is Define by angle + vector<bool> m_DefinitionType ; + + // Used for "By Point Definition" + vector<G4ThreeVector> m_X1_Y1 ; // Top Left Corner Position Vector + vector<G4ThreeVector> m_X1_Y128 ; // Bottom Left Corner Position Vector + vector<G4ThreeVector> m_X128_Y1 ; // Bottom Right Corner Position Vector + vector<G4ThreeVector> m_X128_Y128 ; // Center Corner Position Vector + + // Used for "By Angle Definition" + vector<G4double> m_R ; // | + vector<G4double> m_Theta ; // > Spherical coordinate of Strips Silicium Plate + vector<G4double> m_Phi ; // | + + vector<G4double> m_beta_u ; // | + vector<G4double> m_beta_v ; // > Tilt angle of the Telescope + vector<G4double> m_beta_w ; // | +}; + + + +namespace HYD2SQUARE1 +{ + // Resolution + // If input resolution is Y in MeV units, what is X?? + //ResoFirstStage = X <- X *2.35 = Y; X = Y/2.35 + // Energy/Time resolutions for the different layers + const G4double ResoFirstStage = 0.04255; // = 100 keV of Resolution // Unit is MeV/2.35 + const G4double ResoSecondStage = 0.01276; // = 30 keV of resolution // Unit is MeV/2.35 + const G4double ResoThirdStage = 0.00851; // = 20 keV of resolution // Unit is MeV/2.35 + const G4double ResoFourthStage = 0.00851; // = 20 keV of resolution // Unit is MeV/2.35 + const G4double ResoFifthStage = 0.00851; // = 20 keV of resolution // Unit is MeV/2.35 + const G4double ResoSixthStage = 0.00851; // = 20 keV of resolution // Unit is MeV/2.35 + const G4double ResoTimeHyd2 = 0.42553; // = 1000ps // Unit is ns/2.35 + const G4double ResoTimePPAC = 0.106382979; // = 250ps // Unit is ns/2.35 + + // Geometry + //HYDE-TDR + const G4double FaceFront = 97.42*mm; + const G4double FaceBack = 97.42*mm; + const G4double Length = 2.0*cm; + const G4double InterStageDistance = 3*mm; + + // First stage + const G4double FirstStageFace = 87.42*mm; + const G4double FirstStageThickness = 20*micrometer; + const G4int NumberOfStrips = 220; + //const G4int NumberOfStrips = 128; +// const G4double AluFrontThickness = 0.1*micrometer; +// const G4double AluBackThickness = 0.4*micrometer; + + // Second stage + const G4double SecondStageFace = FirstStageFace; + const G4double SecondStageThickness = 100*micrometer; + + // Third stage + const G4double ThirdStageFace = FirstStageFace; + const G4double ThirdStageThickness = 500*micrometer; + + // Fourth stage + const G4double FourthStageFace = FirstStageFace; + const G4double FourthStageThickness = 2000*micrometer; + + // Fifth stage + const G4double FifthStageFace = FirstStageFace; + const G4double FifthStageThickness = 2000*micrometer; + + // Sixth stage + const G4double SixthStageFace = FirstStageFace; + const G4double SixthStageThickness = 1.5*mm; + + // Starting at the front of the first stage and pointing to the third stage + const G4double FirstStage_PosZ = Length* -0.5 + 0.5*FirstStageThickness; + const G4double SecondStage_PosZ = Length* -0.5 + 0.5*SecondStageThickness + 1*InterStageDistance; + const G4double ThirdStage_PosZ = Length* -0.5 + 0.5*ThirdStageThickness + 2*InterStageDistance; + const G4double FourthStage_PosZ = Length* -0.5 + 0.5*FourthStageThickness + 3*InterStageDistance; + const G4double FifthStage_PosZ = Length* -0.5 + 0.5*FifthStageThickness + 4*InterStageDistance; + const G4double SixthStage_PosZ = Length* -0.5 + 0.5*SixthStageThickness + 5*InterStageDistance; + +// const G4double AluStripFront_PosZ = Length* -0.5 + 0.5*AluStripThickness ; +// const G4double Silicon_PosZ = AluStripFront_PosZ + 0.5*AluStripThickness + 0.5*SiliconThickness ; +// const G4double AluStripBack_PosZ = Silicon_PosZ + 0.5*SiliconThickness + 0.5*AluStripThickness ; +// const G4double VacBox_PosZ = AluStripBack_PosZ + 0.5*AluStripThickness + 0.5* VacBoxThickness ; +// const G4double ThirdStage_PosZ = VacBox_PosZ + 0.5*VacBoxThickness + 0.5*ThirdStageThickness ; +} + +#endif diff --git a/NPSimulation/include/Hyde2TrackerTrapezoid1.hh b/NPSimulation/include/Hyde2TrackerTrapezoid1.hh new file mode 100644 index 000000000..595b9b115 --- /dev/null +++ b/NPSimulation/include/Hyde2TrackerTrapezoid1.hh @@ -0,0 +1,220 @@ +/***************************************************************************** + * 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : 15/07/09 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: Define a module of trapezoidal shape for the Hyde2 tracker * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#ifndef Hyde2TrackerTrapezoid1_h +#define Hyde2TrackerTrapezoid1_h 1 + +// C++ headers +#include <vector> + +// NPTool header +#include "Hyde2TrackerModule.hh" +#include "TInteractionCoordinates.h" + +using namespace std; + + + +class Hyde2TrackerTrapezoid1 : public Hyde2TrackerModule +{ + //////////////////////////////////////////////////// + /////// Default Constructor and Destructor ///////// + //////////////////////////////////////////////////// +public: + Hyde2TrackerTrapezoid1(); + virtual ~Hyde2TrackerTrapezoid1(); + + //////////////////////////////////////////////////// + //////// Specific Function of this Class /////////// + //////////////////////////////////////////////////// +public: + // By Position Method + void AddModule(G4ThreeVector TL , + G4ThreeVector BL , + G4ThreeVector BR , + G4ThreeVector CT , + bool wFirstStage , + bool wSecondStage , + bool wThirdStage , + bool wFourthStage , + bool wFifthStage , + bool wSixthStage); + + // By Angle Method + void 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); + + // Effectively construct Volume + // Avoid to have two time same code for Angle and Point definition + void VolumeMaker(G4int TelescopeNumber , + G4ThreeVector MMpos , + G4RotationMatrix* MMrot , + bool wFirstStage , + bool wSecondStage , + bool wThirdStage , + bool wFourthStage , + bool wFifthStage , + bool wSixthStage , + G4LogicalVolume* world); + + + //////////////////////////////////////////////////// + //// Inherite from Hyde2TrackerModule 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(); + + // Initialize all scorers necessary for the detector + void InitializeScorers(); + + // Read sensitive part and fill the Root tree. + // Called at in the EventAction::EndOfEventAvtion + void ReadSensitive(const G4Event* event); + + // Give the static TInteractionCoordinates from VDetector to the classes + // deriving from Hyde2TrackerModule + // This is mandatory since the Hyde2Tracker*** does not derive from VDetector + void SetInterCoordPointer(TInteractionCoordinates* interCoord); + TInteractionCoordinates* GetInterCoordPointer() {return ms_InterCoord;}; + + + //////////////////////////////////////////////////// + ///////////////Private intern Data////////////////// + //////////////////////////////////////////////////// +private: + // Interaction Coordinates coming from VDetector through the + // SetInteractionCoordinatesPointer method + TInteractionCoordinates* ms_InterCoord; + + // True if Define by Position, False is Define by angle + vector<bool> m_DefinitionType ; + + // Used for "By Point Definition" + vector<G4ThreeVector> m_X1_Y1 ; // Top Left Corner Position Vector + vector<G4ThreeVector> m_X1_Y128 ; // Bottom Left Corner Position Vector + vector<G4ThreeVector> m_X128_Y1 ; // Bottom Right Corner Position Vector + vector<G4ThreeVector> m_X128_Y128 ; // Center Corner Position Vector + + // Used for "By Angle Definition" + vector<G4double> m_R ; // | + vector<G4double> m_Theta ; // > Spherical coordinate of Strips Silicium Plate + vector<G4double> m_Phi ; // | + + vector<G4double> m_beta_u ; // | + vector<G4double> m_beta_v ; // > Tilt angle of the Telescope + vector<G4double> m_beta_w ; // | +}; + + + +namespace HYD2TRAP1 +{ + // Resolution + // If input resolution is Y in MeV units, what is X?? + //ResoFirstStage = X <- X *2.35 = Y; X = Y/2.35 + // Energy/Time resolutions for the different layers + const G4double ResoFirstStage = 0.04255; // = 100 keV of Resolution // Unit is MeV/2.35 + const G4double ResoSecondStage = 0.01276; // = 30 keV of resolution // Unit is MeV/2.35 + const G4double ResoThirdStage = 0.00851; // = 20 keV of resolution // Unit is MeV/2.35 + const G4double ResoFourthStage = 0.00851; // = 20 keV of resolution // Unit is MeV/2.35 + const G4double ResoFifthStage = 0.00851; // = 20 keV of resolution // Unit is MeV/2.35 + const G4double ResoSixthStage = 0.00851; // = 20 keV of resolution // Unit is MeV/2.35 + const G4double ResoTimeHyd2 = 0.42553; // = 1000ps // Unit is ns/2.35 + const G4double ResoTimePPAC = 0.106382979; // = 250ps // Unit is ns/2.35 + + //HYDE-TDR + const G4double Height = 97.68*mm; + const G4double BaseLarge = 97.43*mm; + const G4double BaseSmall = 62.54*mm; + const G4double Length = 20*mm; + const G4double InterStageDistance = 3*mm; + + // First stage + const G4double FirstStageThickness = 20*micrometer; + const G4int NumberOfStripsX = 214; + const G4int NumberOfStripsY = 220; + //HYDE-TDR + const G4double FirstStageHeight = 87.68*mm; + const G4double FirstStageBaseLarge = 85.48*mm; + const G4double FirstStageBaseSmall = 54.17*mm; + + // Second stage + const G4double SecondStageHeight = FirstStageHeight; + const G4double SecondStageBaseLarge = FirstStageBaseLarge; + const G4double SecondStageBaseSmall = FirstStageBaseSmall; + const G4double SecondStageThickness = 100*micrometer; + + + // Third stage + const G4double ThirdStageHeight = FirstStageHeight; + const G4double ThirdStageBaseLarge = FirstStageBaseLarge; + const G4double ThirdStageBaseSmall = FirstStageBaseSmall; + const G4double ThirdStageThickness = 500*micrometer; + + + // Fourth stage + const G4double FourthStageHeight = FirstStageHeight; + const G4double FourthStageBaseLarge = FirstStageBaseLarge; + const G4double FourthStageBaseSmall = FirstStageBaseSmall; + const G4double FourthStageThickness = 2000*micrometer; + + // Fifth stage + const G4double FifthStageHeight = FirstStageHeight; + const G4double FifthStageBaseLarge = FirstStageBaseLarge; + const G4double FifthStageBaseSmall = FirstStageBaseSmall; + const G4double FifthStageThickness = 2000*micrometer; + + // Sixth stage + const G4double SixthStageHeight = FirstStageHeight; + const G4double SixthStageBaseLarge = FirstStageBaseLarge; + const G4double SixthStageBaseSmall = FirstStageBaseSmall; + const G4double SixthStageThickness = 1.5*mm; + + // Starting at the front of the first stage and pointing to the third stage + const G4double FirstStage_PosZ = Length* -0.5 + 0.5*FirstStageThickness; + const G4double SecondStage_PosZ = Length* -0.5 + 0.5*SecondStageThickness + 1*InterStageDistance; + const G4double ThirdStage_PosZ = Length* -0.5 + 0.5*ThirdStageThickness + 2*InterStageDistance; + const G4double FourthStage_PosZ = Length* -0.5 + 0.5*FourthStageThickness + 3*InterStageDistance; + const G4double FifthStage_PosZ = Length* -0.5 + 0.5*FifthStageThickness + 4*InterStageDistance; + const G4double SixthStage_PosZ = Length* -0.5 + 0.5*SixthStageThickness + 5*InterStageDistance; +} + +#endif diff --git a/NPSimulation/include/Hyde2TrackerTrapezoid2.hh b/NPSimulation/include/Hyde2TrackerTrapezoid2.hh new file mode 100644 index 000000000..3f9559e2e --- /dev/null +++ b/NPSimulation/include/Hyde2TrackerTrapezoid2.hh @@ -0,0 +1,220 @@ +/***************************************************************************** + * 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : 15/07/09 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: Define a module of trapezoidal shape for the Hyde2 tracker * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#ifndef Hyde2TrackerTrapezoid2_h +#define Hyde2TrackerTrapezoid2_h 1 + +// C++ headers +#include <vector> + +// NPTool header +#include "Hyde2TrackerModule.hh" +#include "TInteractionCoordinates.h" + +using namespace std; + + + +class Hyde2TrackerTrapezoid2 : public Hyde2TrackerModule +{ + //////////////////////////////////////////////////// + /////// Default Constructor and Destructor ///////// + //////////////////////////////////////////////////// +public: + Hyde2TrackerTrapezoid2(); + virtual ~Hyde2TrackerTrapezoid2(); + + //////////////////////////////////////////////////// + //////// Specific Function of this Class /////////// + //////////////////////////////////////////////////// +public: + // By Position Method + void AddModule(G4ThreeVector TL , + G4ThreeVector BL , + G4ThreeVector BR , + G4ThreeVector CT , + bool wFirstStage , + bool wSecondStage , + bool wThirdStage , + bool wFourthStage , + bool wFifthStage , + bool wSixthStage); + + // By Angle Method + void 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); + + // Effectively construct Volume + // Avoid to have two time same code for Angle and Point definition + void VolumeMaker(G4int TelescopeNumber , + G4ThreeVector MMpos , + G4RotationMatrix* MMrot , + bool wFirstStage , + bool wSecondStage , + bool wThirdStage , + bool wFourthStage , + bool wFifthStage , + bool wSixthStage , + G4LogicalVolume* world); + + + //////////////////////////////////////////////////// + //// Inherite from Hyde2TrackerModule 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(); + + // Initialize all scorers necessary for the detector + void InitializeScorers(); + + // Read sensitive part and fill the Root tree. + // Called at in the EventAction::EndOfEventAvtion + void ReadSensitive(const G4Event* event); + + // Give the static TInteractionCoordinates from VDetector to the classes + // deriving from Hyde2TrackerModule + // This is mandatory since the Hyde2Tracker*** does not derive from VDetector + void SetInterCoordPointer(TInteractionCoordinates* interCoord); + TInteractionCoordinates* GetInterCoordPointer() {return ms_InterCoord;}; + + + //////////////////////////////////////////////////// + ///////////////Private intern Data////////////////// + //////////////////////////////////////////////////// +private: + // Interaction Coordinates coming from VDetector through the + // SetInteractionCoordinatesPointer method + TInteractionCoordinates* ms_InterCoord; + + // True if Define by Position, False is Define by angle + vector<bool> m_DefinitionType ; + + // Used for "By Point Definition" + vector<G4ThreeVector> m_X1_Y1 ; // Top Left Corner Position Vector + vector<G4ThreeVector> m_X1_Y128 ; // Bottom Left Corner Position Vector + vector<G4ThreeVector> m_X128_Y1 ; // Bottom Right Corner Position Vector + vector<G4ThreeVector> m_X128_Y128 ; // Center Corner Position Vector + + // Used for "By Angle Definition" + vector<G4double> m_R ; // | + vector<G4double> m_Theta ; // > Spherical coordinate of Strips Silicium Plate + vector<G4double> m_Phi ; // | + + vector<G4double> m_beta_u ; // | + vector<G4double> m_beta_v ; // > Tilt angle of the Telescope + vector<G4double> m_beta_w ; // | +}; + + + +namespace HYD2TRAP2 +{ + // Resolution + // If input resolution is Y in MeV units, what is X?? + //ResoFirstStage = X <- X *2.35 = Y; X = Y/2.35 + // Energy/Time resolutions for the different layers + const G4double ResoFirstStage = 0.04255; // = 100 keV of Resolution // Unit is MeV/2.35 + const G4double ResoSecondStage = 0.01276; // = 30 keV of resolution // Unit is MeV/2.35 + const G4double ResoThirdStage = 0.00851; // = 20 keV of resolution // Unit is MeV/2.35 + const G4double ResoFourthStage = 0.00851; // = 20 keV of resolution // Unit is MeV/2.35 + const G4double ResoFifthStage = 0.00851; // = 20 keV of resolution // Unit is MeV/2.35 + const G4double ResoSixthStage = 0.00851; // = 20 keV of resolution // Unit is MeV/2.35 + const G4double ResoTimeHyd2 = 0.42553; // = 1000ps // Unit is ns/2.35 + const G4double ResoTimePPAC = 0.106382979; // = 250ps // Unit is ns/2.35 + + //HYDE-TDR + const G4double Height = 60.52*mm; + const G4double BaseLarge = 62.54*mm; + const G4double BaseSmall = 27.82*mm; + const G4double Length = 20*mm; + const G4double InterStageDistance = 3*mm; + + // First stage + const G4double FirstStageThickness = 20*micrometer; + const G4int NumberOfStripsX = 129; + const G4int NumberOfStripsY = 126; + //HYDE-TDR + const G4double FirstStageHeight = 50.52*mm; + const G4double FirstStageBaseLarge = 51.62*mm; + const G4double FirstStageBaseSmall = 20.30*mm; + + // Second stage + const G4double SecondStageHeight = FirstStageHeight; + const G4double SecondStageBaseLarge = FirstStageBaseLarge; + const G4double SecondStageBaseSmall = FirstStageBaseSmall; + const G4double SecondStageThickness = 100*micrometer; + + + // Third stage + const G4double ThirdStageHeight = FirstStageHeight; + const G4double ThirdStageBaseLarge = FirstStageBaseLarge; + const G4double ThirdStageBaseSmall = FirstStageBaseSmall; + const G4double ThirdStageThickness = 500*micrometer; + + + // Fourth stage + const G4double FourthStageHeight = FirstStageHeight; + const G4double FourthStageBaseLarge = FirstStageBaseLarge; + const G4double FourthStageBaseSmall = FirstStageBaseSmall; + const G4double FourthStageThickness = 2000*micrometer; + + // Fifth stage + const G4double FifthStageHeight = FirstStageHeight; + const G4double FifthStageBaseLarge = FirstStageBaseLarge; + const G4double FifthStageBaseSmall = FirstStageBaseSmall; + const G4double FifthStageThickness = 2000*micrometer; + + // Sixth stage + const G4double SixthStageHeight = FirstStageHeight; + const G4double SixthStageBaseLarge = FirstStageBaseLarge; + const G4double SixthStageBaseSmall = FirstStageBaseSmall; + const G4double SixthStageThickness = 1.5*mm; + + // Starting at the front of the first stage and pointing to the third stage + const G4double FirstStage_PosZ = Length* -0.5 + 0.5*FirstStageThickness; + const G4double SecondStage_PosZ = Length* -0.5 + 0.5*SecondStageThickness + 1*InterStageDistance; + const G4double ThirdStage_PosZ = Length* -0.5 + 0.5*ThirdStageThickness + 2*InterStageDistance; + const G4double FourthStage_PosZ = Length* -0.5 + 0.5*FourthStageThickness + 3*InterStageDistance; + const G4double FifthStage_PosZ = Length* -0.5 + 0.5*FifthStageThickness + 4*InterStageDistance; + const G4double SixthStage_PosZ = Length* -0.5 + 0.5*SixthStageThickness + 5*InterStageDistance; +} + +#endif diff --git a/NPSimulation/src/DetectorConstruction.cc b/NPSimulation/src/DetectorConstruction.cc index b28e6c1c3..ca89e5848 100644 --- a/NPSimulation/src/DetectorConstruction.cc +++ b/NPSimulation/src/DetectorConstruction.cc @@ -56,6 +56,7 @@ #include "GaspardTracker.hh" #include "Helios.hh" #include "HydeTracker.hh" +#include "Hyde2Tracker.hh" #include "MUST2Array.hh" #include "Paris.hh" #include "Plastic.hh" @@ -182,6 +183,7 @@ void DetectorConstruction::ReadConfigurationFile(string Path){ bool cGeneralChamber = false; bool cGPDTracker = false; bool cHYDTracker = false; + bool cHYD2Tracker = false; bool cMUST2 = false; bool cPlastic = false; bool cParis = false; @@ -316,7 +318,29 @@ void DetectorConstruction::ReadConfigurationFile(string Path){ #endif } + + //////////////////////////////////////////// + //////////// Search for Hyde2 //////////// + //////////////////////////////////////////// + else if (LineBuffer.compare(0, 12, "Hyde2Tracker") == 0 && cHYD2Tracker == false) { +#ifdef INC_HYDE2 + cHYD2Tracker = true ; + if(VerboseLevel==1) cout << endl << "//////// Hyde2 Tracker ////////" << endl ; + + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new Hyde2Tracker() ; + + // Read Position of Telescope + ConfigFile.close() ; + myDetector->ReadConfiguration(Path) ; + ConfigFile.open(Path.c_str()) ; + + // Add array to the VDetector Vector + AddDetector(myDetector) ; +#endif + } + //////////////////////////////////////////// //////////// Search for paris //////////// //////////////////////////////////////////// diff --git a/NPSimulation/src/Hyde2Scorers.cc b/NPSimulation/src/Hyde2Scorers.cc new file mode 100644 index 000000000..65e7cdb56 --- /dev/null +++ b/NPSimulation/src/Hyde2Scorers.cc @@ -0,0 +1,820 @@ +/***************************************************************************** + * 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : 11/07/09 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: This class holds all the scorers needed by the * + * Hyde2Tracker*** objects. * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// G4 headers +#include "G4UnitsTable.hh" + +// NPTool headers +#include "GeneralScorers.hh" +#include "Hyde2Scorers.hh" + +#include "Hyde2TrackerSquare1.hh" +#include "Hyde2TrackerTrapezoid1.hh" +#include "Hyde2TrackerTrapezoid2.hh" +using namespace HYD2SQUARE1; +using namespace HYD2TRAP1; +using namespace HYD2TRAP2; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// Added by Adrien MATTA: +// Those Scorer use TrackID as map index. This way ones can rebuild energy deposit, +// time of flight or position,... particle by particle for each event. Because standard +// scorer provide by G4 don't work this way but using a global ID for each event you should +// not use those scorer with some G4 provided ones or being very carefull doing so. + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// FirstStage Energy Scorer (deal with multiple particle hit) +HYD2ScorerFirstStageEnergy::HYD2ScorerFirstStageEnergy(G4String name, G4String volumeName, G4int depth) + : G4VPrimitiveScorer(name, depth), HCID(-1) +{ + m_VolumeName = volumeName; +} + +HYD2ScorerFirstStageEnergy::~HYD2ScorerFirstStageEnergy() +{ +} + +G4bool HYD2ScorerFirstStageEnergy::ProcessHits(G4Step* aStep, G4TouchableHistory*) +{ + // get detector number + int DetNbr = GENERALSCORERS::PickUpDetectorNumber(aStep, m_VolumeName); + + // get energy + G4ThreeVector POS = aStep->GetPreStepPoint()->GetPosition(); + POS = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(POS); + + G4double edep = aStep->GetTotalEnergyDeposit(); + if (edep < 100*keV) return FALSE; + G4int index = aStep->GetTrack()->GetTrackID(); + EvtMap->add(DetNbr + index, edep); + return TRUE; +} + +void HYD2ScorerFirstStageEnergy::Initialize(G4HCofThisEvent* HCE) +{ + EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +void HYD2ScorerFirstStageEnergy::EndOfEvent(G4HCofThisEvent*) +{ +} + +void HYD2ScorerFirstStageEnergy::Clear() +{ + EvtMap->clear(); +} + +void HYD2ScorerFirstStageEnergy::DrawAll() +{ +} + +void HYD2ScorerFirstStageEnergy::PrintAll() +{ + G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl; + G4cout << " PrimitiveScorer " << GetName() << G4endl; + G4cout << " Number of entries " << EvtMap->entries() << G4endl; + std::map<G4int, G4double*>::iterator itr = EvtMap->GetMap()->begin(); + for (; itr != EvtMap->GetMap()->end(); itr++) { + G4cout << " copy no.: " << itr->first + << " energy deposit: " << G4BestUnit(*(itr->second), "Energy") + << G4endl; + } +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// SecondStage Energy Scorer (deal with multiple particle hit) +HYD2ScorerSecondStageEnergy::HYD2ScorerSecondStageEnergy(G4String name, G4String volumeName, G4int depth) + : G4VPrimitiveScorer(name, depth), HCID(-1) +{ + m_VolumeName = volumeName; +} + +HYD2ScorerSecondStageEnergy::~HYD2ScorerSecondStageEnergy() +{ +} + +G4bool HYD2ScorerSecondStageEnergy::ProcessHits(G4Step* aStep, G4TouchableHistory*) +{ + // get detector number + int DetNbr = GENERALSCORERS::PickUpDetectorNumber(aStep, m_VolumeName); + + // get energy + G4ThreeVector POS = aStep->GetPreStepPoint()->GetPosition(); + POS = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(POS); + + G4double edep = aStep->GetTotalEnergyDeposit(); + if (edep < 100*keV) return FALSE; + G4int index = aStep->GetTrack()->GetTrackID(); + EvtMap->add(DetNbr + index, edep); + return TRUE; +} + +void HYD2ScorerSecondStageEnergy::Initialize(G4HCofThisEvent* HCE) +{ + EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +void HYD2ScorerSecondStageEnergy::EndOfEvent(G4HCofThisEvent*) +{ +} + +void HYD2ScorerSecondStageEnergy::Clear() +{ + EvtMap->clear(); +} + +void HYD2ScorerSecondStageEnergy::DrawAll() +{ +} + +void HYD2ScorerSecondStageEnergy::PrintAll() +{ + G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl; + G4cout << " PrimitiveScorer " << GetName() << G4endl; + G4cout << " Number of entries " << EvtMap->entries() << G4endl; + std::map<G4int, G4double*>::iterator itr = EvtMap->GetMap()->begin(); + for (; itr != EvtMap->GetMap()->end(); itr++) { + G4cout << " copy no.: " << itr->first + << " energy deposit: " << G4BestUnit(*(itr->second), "Energy") + << G4endl; + } +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// ThirdStage Energy Scorer (deal with multiple particle hit) +HYD2ScorerThirdStageEnergy::HYD2ScorerThirdStageEnergy(G4String name, G4String volumeName, G4int depth) + : G4VPrimitiveScorer(name, depth), HCID(-1) +{ + m_VolumeName = volumeName; +} + +HYD2ScorerThirdStageEnergy::~HYD2ScorerThirdStageEnergy() +{ +} + +G4bool HYD2ScorerThirdStageEnergy::ProcessHits(G4Step* aStep, G4TouchableHistory*) +{ + // get detector number + int DetNbr = GENERALSCORERS::PickUpDetectorNumber(aStep, m_VolumeName); + + // get energy + G4ThreeVector POS = aStep->GetPreStepPoint()->GetPosition(); + POS = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(POS); + + G4double edep = aStep->GetTotalEnergyDeposit(); + if (edep < 100*keV) return FALSE; + G4int index = aStep->GetTrack()->GetTrackID(); + EvtMap->add(DetNbr + index, edep); + return TRUE; +} + +void HYD2ScorerThirdStageEnergy::Initialize(G4HCofThisEvent* HCE) +{ + EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +void HYD2ScorerThirdStageEnergy::EndOfEvent(G4HCofThisEvent*) +{ +} + +void HYD2ScorerThirdStageEnergy::Clear() +{ + EvtMap->clear(); +} + +void HYD2ScorerThirdStageEnergy::DrawAll() +{ +} + +void HYD2ScorerThirdStageEnergy::PrintAll() +{ + G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl; + G4cout << " PrimitiveScorer " << GetName() << G4endl; + G4cout << " Number of entries " << EvtMap->entries() << G4endl; + std::map<G4int, G4double*>::iterator itr = EvtMap->GetMap()->begin(); + for (; itr != EvtMap->GetMap()->end(); itr++) { + G4cout << " copy no.: " << itr->first + << " energy deposit: " << G4BestUnit(*(itr->second), "Energy") + << G4endl; + } +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// FourthStage Energy Scorer (deal with multiple particle hit) +HYD2ScorerFourthStageEnergy::HYD2ScorerFourthStageEnergy(G4String name, G4String volumeName, G4int depth) + : G4VPrimitiveScorer(name, depth), HCID(-1) +{ + m_VolumeName = volumeName; +} + +HYD2ScorerFourthStageEnergy::~HYD2ScorerFourthStageEnergy() +{ +} + +G4bool HYD2ScorerFourthStageEnergy::ProcessHits(G4Step* aStep, G4TouchableHistory*) +{ + // get detector number + int DetNbr = GENERALSCORERS::PickUpDetectorNumber(aStep, m_VolumeName); + + // get energy + G4ThreeVector POS = aStep->GetPreStepPoint()->GetPosition(); + POS = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(POS); + + G4double edep = aStep->GetTotalEnergyDeposit(); + if (edep < 100*keV) return FALSE; + G4int index = aStep->GetTrack()->GetTrackID(); + EvtMap->add(DetNbr + index, edep); + return TRUE; +} + +void HYD2ScorerFourthStageEnergy::Initialize(G4HCofThisEvent* HCE) +{ + EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +void HYD2ScorerFourthStageEnergy::EndOfEvent(G4HCofThisEvent*) +{ +} + +void HYD2ScorerFourthStageEnergy::Clear() +{ + EvtMap->clear(); +} + +void HYD2ScorerFourthStageEnergy::DrawAll() +{ +} + +void HYD2ScorerFourthStageEnergy::PrintAll() +{ + G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl; + G4cout << " PrimitiveScorer " << GetName() << G4endl; + G4cout << " Number of entries " << EvtMap->entries() << G4endl; + std::map<G4int, G4double*>::iterator itr = EvtMap->GetMap()->begin(); + for (; itr != EvtMap->GetMap()->end(); itr++) { + G4cout << " copy no.: " << itr->first + << " energy deposit: " << G4BestUnit(*(itr->second), "Energy") + << G4endl; + } +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// FifthStage Energy Scorer (deal with multiple particle hit) +HYD2ScorerFifthStageEnergy::HYD2ScorerFifthStageEnergy(G4String name, G4String volumeName, G4int depth) + : G4VPrimitiveScorer(name, depth), HCID(-1) +{ + m_VolumeName = volumeName; +} + +HYD2ScorerFifthStageEnergy::~HYD2ScorerFifthStageEnergy() +{ +} + +G4bool HYD2ScorerFifthStageEnergy::ProcessHits(G4Step* aStep, G4TouchableHistory*) +{ + // get detector number + int DetNbr = GENERALSCORERS::PickUpDetectorNumber(aStep, m_VolumeName); + + // get energy + G4ThreeVector POS = aStep->GetPreStepPoint()->GetPosition(); + POS = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(POS); + + G4double edep = aStep->GetTotalEnergyDeposit(); + if (edep < 100*keV) return FALSE; + G4int index = aStep->GetTrack()->GetTrackID(); + EvtMap->add(DetNbr + index, edep); + return TRUE; +} + +void HYD2ScorerFifthStageEnergy::Initialize(G4HCofThisEvent* HCE) +{ + EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +void HYD2ScorerFifthStageEnergy::EndOfEvent(G4HCofThisEvent*) +{ +} + +void HYD2ScorerFifthStageEnergy::Clear() +{ + EvtMap->clear(); +} + +void HYD2ScorerFifthStageEnergy::DrawAll() +{ +} + +void HYD2ScorerFifthStageEnergy::PrintAll() +{ + G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl; + G4cout << " PrimitiveScorer " << GetName() << G4endl; + G4cout << " Number of entries " << EvtMap->entries() << G4endl; + std::map<G4int, G4double*>::iterator itr = EvtMap->GetMap()->begin(); + for (; itr != EvtMap->GetMap()->end(); itr++) { + G4cout << " copy no.: " << itr->first + << " energy deposit: " << G4BestUnit(*(itr->second), "Energy") + << G4endl; + } +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// SixthStage Energy Scorer (deal with multiple particle hit) +HYD2ScorerSixthStageEnergy::HYD2ScorerSixthStageEnergy(G4String name, G4String volumeName, G4int depth) + : G4VPrimitiveScorer(name, depth), HCID(-1) +{ + m_VolumeName = volumeName; +} + +HYD2ScorerSixthStageEnergy::~HYD2ScorerSixthStageEnergy() +{ +} + +G4bool HYD2ScorerSixthStageEnergy::ProcessHits(G4Step* aStep, G4TouchableHistory*) +{ + // get detector number + int DetNbr = GENERALSCORERS::PickUpDetectorNumber(aStep, m_VolumeName); + + // get energy + G4ThreeVector POS = aStep->GetPreStepPoint()->GetPosition(); + POS = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(POS); + + G4double edep = aStep->GetTotalEnergyDeposit(); + if (edep < 100*keV) return FALSE; + G4int index = aStep->GetTrack()->GetTrackID(); + EvtMap->add(DetNbr + index, edep); + return TRUE; +} + +void HYD2ScorerSixthStageEnergy::Initialize(G4HCofThisEvent* HCE) +{ + EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +void HYD2ScorerSixthStageEnergy::EndOfEvent(G4HCofThisEvent*) +{ +} + +void HYD2ScorerSixthStageEnergy::Clear() +{ + EvtMap->clear(); +} + +void HYD2ScorerSixthStageEnergy::DrawAll() +{ +} + +void HYD2ScorerSixthStageEnergy::PrintAll() +{ + G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl; + G4cout << " PrimitiveScorer " << GetName() << G4endl; + G4cout << " Number of entries " << EvtMap->entries() << G4endl; + std::map<G4int, G4double*>::iterator itr = EvtMap->GetMap()->begin(); + for (; itr != EvtMap->GetMap()->end(); itr++) { + G4cout << " copy no.: " << itr->first + << " energy deposit: " << G4BestUnit(*(itr->second), "Energy") + << G4endl; + } +} + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// FirstStage Front Strip position Scorer for Square1 geometry +HYD2ScorerFirstStageFrontStripSquare1::HYD2ScorerFirstStageFrontStripSquare1(G4String name, G4int depth, G4int NumberOfStrip) + : G4VPrimitiveScorer(name, depth), HCID(-1) +{ + m_NumberOfStrip = NumberOfStrip ; +} + +HYD2ScorerFirstStageFrontStripSquare1::~HYD2ScorerFirstStageFrontStripSquare1() +{ +} + +G4bool HYD2ScorerFirstStageFrontStripSquare1::ProcessHits(G4Step* aStep, G4TouchableHistory*) +{ + // get detector number + int DetNbr = GENERALSCORERS::PickUpDetectorNumber(aStep, "HYD2Square1"); + + // get front strip + G4ThreeVector POS = aStep->GetPreStepPoint()->GetPosition(); + POS = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(POS); + + G4double StripPitch = HYD2SQUARE1::FirstStageFace / m_NumberOfStrip; + + G4double temp = (POS(0) + HYD2SQUARE1::FirstStageFace / 2.) / StripPitch ; + G4double X = int(temp) + 1 ; + //Rare case where particle is close to edge of silicon plan + // if (X == 129) X = 128; Wed Feb 6 19:16:08 CET 2013 angelmsb + if (X == 221) X = 220; + G4double edep = aStep->GetTotalEnergyDeposit(); + if (edep < 100*keV) return FALSE; + G4int index = aStep->GetTrack()->GetTrackID(); + EvtMap->set(DetNbr + index, X); + return TRUE; +} + +void HYD2ScorerFirstStageFrontStripSquare1::Initialize(G4HCofThisEvent* HCE) +{ + EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +void HYD2ScorerFirstStageFrontStripSquare1::EndOfEvent(G4HCofThisEvent*) +{ +} + +void HYD2ScorerFirstStageFrontStripSquare1::Clear() +{ + EvtMap->clear(); +} + +void HYD2ScorerFirstStageFrontStripSquare1::DrawAll() +{ +} + +void HYD2ScorerFirstStageFrontStripSquare1::PrintAll() +{ + G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl ; + G4cout << " PrimitiveScorer " << GetName() << G4endl ; + G4cout << " Number of entries " << EvtMap->entries() << G4endl ; +} + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// FirstStage Back Strip position Scorer for Square1 geometry +HYD2ScorerFirstStageBackStripSquare1::HYD2ScorerFirstStageBackStripSquare1(G4String name, G4int depth, G4int NumberOfStrip) + : G4VPrimitiveScorer(name, depth), HCID(-1) +{ + m_NumberOfStrip = NumberOfStrip ; +} + +HYD2ScorerFirstStageBackStripSquare1::~HYD2ScorerFirstStageBackStripSquare1() +{ +} + +G4bool HYD2ScorerFirstStageBackStripSquare1::ProcessHits(G4Step* aStep, G4TouchableHistory*) +{ + // get detector number + int DetNbr = GENERALSCORERS::PickUpDetectorNumber(aStep, "HYD2Square1"); + + // get back strip + G4ThreeVector POS = aStep->GetPreStepPoint()->GetPosition(); + POS = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(POS); + + G4double StripPitch = HYD2SQUARE1::FirstStageFace / m_NumberOfStrip; + + G4double temp = (POS(1) + HYD2SQUARE1::FirstStageFace / 2.) / StripPitch ; + G4int temp2 = temp ; + G4double Y = temp2 + 1 ; + //Rare case where particle is close to edge of silicon plan + // if (Y == 129) Y = 128; Wed Feb 6 19:16:08 CET 2013 angelmsb + if (Y == 221) Y = 220; + + G4double edep = aStep->GetTotalEnergyDeposit(); + if (edep < 100*keV) return FALSE; + G4int index = aStep->GetTrack()->GetTrackID(); + EvtMap->set(DetNbr + index, Y); + return TRUE; +} + +void HYD2ScorerFirstStageBackStripSquare1::Initialize(G4HCofThisEvent* HCE) +{ + EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +void HYD2ScorerFirstStageBackStripSquare1::EndOfEvent(G4HCofThisEvent*) +{ +} + +void HYD2ScorerFirstStageBackStripSquare1::Clear() +{ + EvtMap->clear(); +} + +void HYD2ScorerFirstStageBackStripSquare1::DrawAll() +{ +} + +void HYD2ScorerFirstStageBackStripSquare1::PrintAll() +{ + G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl ; + G4cout << " PrimitiveScorer " << GetName() << G4endl ; + G4cout << " Number of entries " << EvtMap->entries() << G4endl ; +} + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// FirstStage Front Strip position Scorer for Trapezoid1 geometry +HYD2ScorerFirstStageFrontStripTrapezoid1::HYD2ScorerFirstStageFrontStripTrapezoid1(G4String name, G4int depth, G4int NumberOfStrip) + : G4VPrimitiveScorer(name, depth), HCID(-1) +{ + m_NumberOfStrip = NumberOfStrip; +} + +HYD2ScorerFirstStageFrontStripTrapezoid1::~HYD2ScorerFirstStageFrontStripTrapezoid1() +{ +} + +G4bool HYD2ScorerFirstStageFrontStripTrapezoid1::ProcessHits(G4Step* aStep, G4TouchableHistory*) +{ + // get detector number + int DetNbr = GENERALSCORERS::PickUpDetectorNumber(aStep, "HYD2Trapezoid1"); + + // get front strip + G4ThreeVector POS = aStep->GetPreStepPoint()->GetPosition(); + POS = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(POS); + + G4double StripPitch = HYD2TRAP1::FirstStageBaseLarge / m_NumberOfStrip; + + G4double temp = (POS(0) + HYD2TRAP1::FirstStageBaseLarge / 2.) / StripPitch ; + G4double X = int(temp) + 1; + //Rare case where particle is close to edge of silicon plan + // if (X == 129) X = 128; Wed Feb 6 19:16:08 CET 2013 angelmsb + if (X == 215) X = 214; + G4double edep = aStep->GetTotalEnergyDeposit(); + if (edep < 100*keV) return FALSE; + G4int index = aStep->GetTrack()->GetTrackID(); + EvtMap->set(DetNbr + index, X); + return TRUE; +} + +void HYD2ScorerFirstStageFrontStripTrapezoid1::Initialize(G4HCofThisEvent* HCE) +{ + EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +void HYD2ScorerFirstStageFrontStripTrapezoid1::EndOfEvent(G4HCofThisEvent*) +{ +} + +void HYD2ScorerFirstStageFrontStripTrapezoid1::Clear() +{ + EvtMap->clear(); +} + +void HYD2ScorerFirstStageFrontStripTrapezoid1::DrawAll() +{ +} + +void HYD2ScorerFirstStageFrontStripTrapezoid1::PrintAll() +{ + G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl ; + G4cout << " PrimitiveScorer " << GetName() << G4endl ; + G4cout << " Number of entries " << EvtMap->entries() << G4endl ; +} + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// FirstStage Back Strip position Scorer for Trapezoid1 geometry +HYD2ScorerFirstStageBackStripTrapezoid1::HYD2ScorerFirstStageBackStripTrapezoid1(G4String name, G4int depth, G4int NumberOfStrip) + : G4VPrimitiveScorer(name, depth), HCID(-1) +{ + m_NumberOfStrip = NumberOfStrip; +} + +HYD2ScorerFirstStageBackStripTrapezoid1::~HYD2ScorerFirstStageBackStripTrapezoid1() +{ +} + +G4bool HYD2ScorerFirstStageBackStripTrapezoid1::ProcessHits(G4Step* aStep, G4TouchableHistory*) +{ + // get detector number + int DetNbr = GENERALSCORERS::PickUpDetectorNumber(aStep, "HYD2Trapezoid1"); + + // get back strip + G4ThreeVector POS = aStep->GetPreStepPoint()->GetPosition(); + POS = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(POS); + + G4double StripPitch = HYD2TRAP1::FirstStageHeight / m_NumberOfStrip; + + G4double temp = (POS(1) + HYD2TRAP1::FirstStageHeight / 2.) / StripPitch ; + G4int temp2 = temp ; + G4double Y = temp2 + 1 ; + //Rare case where particle is close to edge of silicon plan + // if (Y == 129) Y = 128; Wed Feb 6 19:16:08 CET 2013 angelmsb + if (Y == 221) Y = 220; + + G4double edep = aStep->GetTotalEnergyDeposit(); + if (edep < 100*keV) return FALSE; + G4int index = aStep->GetTrack()->GetTrackID(); + EvtMap->set(DetNbr + index, Y); + return TRUE; +} + +void HYD2ScorerFirstStageBackStripTrapezoid1::Initialize(G4HCofThisEvent* HCE) +{ + EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +void HYD2ScorerFirstStageBackStripTrapezoid1::EndOfEvent(G4HCofThisEvent*) +{ +} + +void HYD2ScorerFirstStageBackStripTrapezoid1::Clear() +{ + EvtMap->clear(); +} + +void HYD2ScorerFirstStageBackStripTrapezoid1::DrawAll() +{ +} + +void HYD2ScorerFirstStageBackStripTrapezoid1::PrintAll() +{ + G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl ; + G4cout << " PrimitiveScorer " << GetName() << G4endl ; + G4cout << " Number of entries " << EvtMap->entries() << G4endl ; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// FirstStage Front Strip position Scorer for Trapezoid2 geometry +HYD2ScorerFirstStageFrontStripTrapezoid2::HYD2ScorerFirstStageFrontStripTrapezoid2(G4String name, G4int depth, G4int NumberOfStrip) + : G4VPrimitiveScorer(name, depth), HCID(-1) +{ + m_NumberOfStrip = NumberOfStrip; +} + +HYD2ScorerFirstStageFrontStripTrapezoid2::~HYD2ScorerFirstStageFrontStripTrapezoid2() +{ +} + +G4bool HYD2ScorerFirstStageFrontStripTrapezoid2::ProcessHits(G4Step* aStep, G4TouchableHistory*) +{ + // get detector number + int DetNbr = GENERALSCORERS::PickUpDetectorNumber(aStep, "HYD2Trapezoid2"); + + // get front strip + G4ThreeVector POS = aStep->GetPreStepPoint()->GetPosition(); + POS = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(POS); + + G4double StripPitch = HYD2TRAP2::FirstStageBaseLarge / m_NumberOfStrip; + + G4double temp = (POS(0) + HYD2TRAP2::FirstStageBaseLarge / 2.) / StripPitch ; + G4double X = int(temp) + 1; + //Rare case where particle is close to edge of silicon plan + // if (X == 129) X = 128; Wed Feb 6 19:16:08 CET 2013 angelmsb + if (X == 130) X = 129; + G4double edep = aStep->GetTotalEnergyDeposit(); + if (edep < 100*keV) return FALSE; + G4int index = aStep->GetTrack()->GetTrackID(); + EvtMap->set(DetNbr + index, X); + return TRUE; +} + +void HYD2ScorerFirstStageFrontStripTrapezoid2::Initialize(G4HCofThisEvent* HCE) +{ + EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +void HYD2ScorerFirstStageFrontStripTrapezoid2::EndOfEvent(G4HCofThisEvent*) +{ +} + +void HYD2ScorerFirstStageFrontStripTrapezoid2::Clear() +{ + EvtMap->clear(); +} + +void HYD2ScorerFirstStageFrontStripTrapezoid2::DrawAll() +{ +} + +void HYD2ScorerFirstStageFrontStripTrapezoid2::PrintAll() +{ + G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl ; + G4cout << " PrimitiveScorer " << GetName() << G4endl ; + G4cout << " Number of entries " << EvtMap->entries() << G4endl ; +} + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// FirstStage Back Strip position Scorer for Trapezoid2 geometry +HYD2ScorerFirstStageBackStripTrapezoid2::HYD2ScorerFirstStageBackStripTrapezoid2(G4String name, G4int depth, G4int NumberOfStrip) + : G4VPrimitiveScorer(name, depth), HCID(-1) +{ + m_NumberOfStrip = NumberOfStrip; +} + +HYD2ScorerFirstStageBackStripTrapezoid2::~HYD2ScorerFirstStageBackStripTrapezoid2() +{ +} + +G4bool HYD2ScorerFirstStageBackStripTrapezoid2::ProcessHits(G4Step* aStep, G4TouchableHistory*) +{ + // get detector number + int DetNbr = GENERALSCORERS::PickUpDetectorNumber(aStep, "HYD2Trapezoid2"); + + // get back strip + G4ThreeVector POS = aStep->GetPreStepPoint()->GetPosition(); + POS = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(POS); + + G4double StripPitch = HYD2TRAP2::FirstStageHeight / m_NumberOfStrip; + + G4double temp = (POS(1) + HYD2TRAP2::FirstStageHeight / 2.) / StripPitch ; + G4int temp2 = temp ; + G4double Y = temp2 + 1 ; + //Rare case where particle is close to edge of silicon plan + // if (Y == 129) Y = 128; Wed Feb 6 19:16:08 CET 2013 angelmsb + if (Y == 127) Y = 126; + + G4double edep = aStep->GetTotalEnergyDeposit(); + if (edep < 100*keV) return FALSE; + G4int index = aStep->GetTrack()->GetTrackID(); + EvtMap->set(DetNbr + index, Y); + return TRUE; +} + +void HYD2ScorerFirstStageBackStripTrapezoid2::Initialize(G4HCofThisEvent* HCE) +{ + EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +void HYD2ScorerFirstStageBackStripTrapezoid2::EndOfEvent(G4HCofThisEvent*) +{ +} + +void HYD2ScorerFirstStageBackStripTrapezoid2::Clear() +{ + EvtMap->clear(); +} + +void HYD2ScorerFirstStageBackStripTrapezoid2::DrawAll() +{ +} + +void HYD2ScorerFirstStageBackStripTrapezoid2::PrintAll() +{ + G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl ; + G4cout << " PrimitiveScorer " << GetName() << G4endl ; + G4cout << " Number of entries " << EvtMap->entries() << G4endl ; +} + diff --git a/NPSimulation/src/Hyde2Tracker.cc b/NPSimulation/src/Hyde2Tracker.cc new file mode 100644 index 000000000..75cd0a5df --- /dev/null +++ b/NPSimulation/src/Hyde2Tracker.cc @@ -0,0 +1,170 @@ +/***************************************************************************** + * 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : 10/06/09 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: This class manages different shapes of module for the Hyde2 * + * tracker. It allows to have Hyde2 geometries with an * + * heterogeneous set of modules * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// C++ headers +#include <fstream> +#include <sstream> +#include <string> +#include <cmath> + +// NPTool headers +#include "Hyde2Tracker.hh" +#include "Hyde2TrackerSquare1.hh" +#include "Hyde2TrackerTrapezoid1.hh" +#include "Hyde2TrackerTrapezoid2.hh" + +using namespace std; + + +Hyde2Tracker::Hyde2Tracker() +{ +} + + + +Hyde2Tracker::~Hyde2Tracker() +{ +} + + + +// Read stream at Configfile to pick-up parameters of detector (Position,...) +// Called in DetecorConstruction::ReadDetextorConfiguration Method +void Hyde2Tracker::ReadConfiguration(string Path) +{ + // open configuration file + ifstream ConfigFile; + ConfigFile.open(Path.c_str()); + + bool HYD2TrkSquare1 = false; + bool HYD2TrkTrapezoid1 = false; + bool HYD2TrkTrapezoid2 = false; + + string LineBuffer; + while (!ConfigFile.eof()) { + getline(ConfigFile, LineBuffer); + if (LineBuffer.compare(0, 11, "HYD2Square1") == 0 && HYD2TrkSquare1 == false) { + HYD2TrkSquare1 = true; + + // instantiate a new "detector" corresponding to the Square1 elements + Hyde2TrackerModule* myDetector = new Hyde2TrackerSquare1(); + + // read part of the configuration file corresponding to square elements + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); + + // ms_InterCoord comes from VDetector + myDetector->SetInterCoordPointer(ms_InterCoord); + + // store Hyde2TrackerSquare1 "detector" + m_Modules.push_back(myDetector); + } + else if (LineBuffer.compare(0, 14, "HYD2Trapezoid1") == 0 && HYD2TrkTrapezoid1 == false) { + HYD2TrkTrapezoid1 = true; + + // instantiate a new "detector" corresponding to the Trapezoid1 elements + Hyde2TrackerModule* myDetector = new Hyde2TrackerTrapezoid1(); + + // read part of the configuration file corresponding to trapezoid elements + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); + + // ms_InterCoord comes from VDetector + myDetector->SetInterCoordPointer(ms_InterCoord); + + // store Hyde2TrackerTrapezoid1 "detector" + m_Modules.push_back(myDetector); + } + else if (LineBuffer.compare(0, 14, "HYD2Trapezoid2") == 0 && HYD2TrkTrapezoid2 == false) { + HYD2TrkTrapezoid2 = true; + + // instantiate a new "detector" corresponding to the Trapezoid2 elements + Hyde2TrackerModule* myDetector = new Hyde2TrackerTrapezoid2(); + + // read part of the configuration file corresponding to trapezoid elements + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); + + // ms_InterCoord comes from VDetector + myDetector->SetInterCoordPointer(ms_InterCoord); + + // store Hyde2TrackerTrapezoid2 "detector" + m_Modules.push_back(myDetector); + } + } +} + + + +// Construct detector and initialize sensitive part. +// Called After DetecorConstruction::AddDetector Method +void Hyde2Tracker::ConstructDetector(G4LogicalVolume* world) +{ + // loop on sub-detectors belonging to Hyde2Tracker + int nbDetectors = m_Modules.size(); + for (int i = 0; i < nbDetectors; i++) m_Modules[i]->ConstructDetector(world); +} + + + +// Connect the Hyde2TrackingData class to the output TTree +// of the simulation +void Hyde2Tracker::InitializeRootOutput() +{ + // loop on sub-detectors belonging to Hyde2Tracker + int nbDetectors = m_Modules.size(); + for (int i = 0; i < nbDetectors; i++) m_Modules[i]->InitializeRootOutput(); +} + + + +// Initialize all scorers necessary for each detector +void Hyde2Tracker::InitializeScorers() +{ + // loop on sub-detectors belonging to Hyde2Tracker + int nbDetectors = m_Modules.size(); + for (int i = 0; i < nbDetectors; i++) m_Modules[i]->InitializeScorers(); +} + + + +// Read sensitive part and fill the Root tree. +// Called at in the EventAction::EndOfEventAction +void Hyde2Tracker::ReadSensitive(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. + m_Modules[0]->GetInterCoordPointer()->Clear(); + + // We do the same for the static variable ms_Event + m_Modules[0]->GetEventPointer()->Clear(); + + // loop on sub-detectors belonging to Hyde2Tracker + int nbDetectors = m_Modules.size(); + for (int i = 0; i < nbDetectors; i++) m_Modules[i]->ReadSensitive(event); +} diff --git a/NPSimulation/src/Hyde2TrackerModule.cc b/NPSimulation/src/Hyde2TrackerModule.cc new file mode 100644 index 000000000..ab454d7fa --- /dev/null +++ b/NPSimulation/src/Hyde2TrackerModule.cc @@ -0,0 +1,62 @@ +/***************************************************************************** + * 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : 10/06/09 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: This class is an Abstract Base Class (ABC) from which should * + * derive all different modules from the Hyde2 tracker. * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#include "Hyde2TrackerModule.hh" +#include "RootOutput.h" + + +THyde2TrackerData *Hyde2TrackerModule::ms_Event = 0; + + + +Hyde2TrackerModule::Hyde2TrackerModule() +{ + if (ms_Event == 0) ms_Event = new THyde2TrackerData(); + + InitializeRootOutput(); + InitializeIndex(); +} + + + +Hyde2TrackerModule::~Hyde2TrackerModule() +{ +} + + + +void Hyde2TrackerModule::InitializeRootOutput() +{ + RootOutput *pAnalysis = RootOutput::getInstance(); + TTree *pTree = pAnalysis->GetTree(); + // if the branch does not exist yet, create it + if (!pTree->GetBranch("HYDE2")) + pTree->Branch("HYDE2", "THyde2TrackerData", &ms_Event); +} + + + +void Hyde2TrackerModule::InitializeIndex() +{ + m_index["Square1"] = 2000; + m_index["Trapezoid1"] = 2200; + m_index["Trapezoid2"] = 2300; +} diff --git a/NPSimulation/src/Hyde2TrackerSquare1.cc b/NPSimulation/src/Hyde2TrackerSquare1.cc new file mode 100644 index 000000000..eab359718 --- /dev/null +++ b/NPSimulation/src/Hyde2TrackerSquare1.cc @@ -0,0 +1,1252 @@ +/***************************************************************************** + * 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : 10/06/09 * + * Last update : 12/10/09 * + *---------------------------------------------------------------------------* + * Decription: Define a module of square shape for the Hyde2 tracker * + * * + *---------------------------------------------------------------------------* + * Comment: * + * + 07/09/09: Fix bug for placing module with (r,theta,phi) method. * + * (N. de Sereville) * + * + 12/10/09: Change scorer scheme (N. de Sereville) * + * + 01/10/10: Fix bug with TInteractionCoordinate map size in Read * + * Sensitive (N. de Sereville) * + * * + * * + *****************************************************************************/ + +// C++ headers +#include <sstream> +#include <string> +#include <cmath> + +// G4 Geometry headers +#include "G4Trd.hh" +#include "G4Box.hh" +#include "G4Trap.hh" + +// G4 various headers +#include "G4MaterialTable.hh" +#include "G4Element.hh" +#include "G4ElementTable.hh" +#include "G4VisAttributes.hh" +#include "G4Colour.hh" +#include "G4RotationMatrix.hh" +#include "G4Transform3D.hh" +#include "G4PVPlacement.hh" +#include "G4PVDivision.hh" + +// G4 sensitive +#include "G4SDManager.hh" +#include "G4MultiFunctionalDetector.hh" + +// NPTool headers +#include "Hyde2TrackerSquare1.hh" +#include "GeneralScorers.hh" +#include "Hyde2Scorers.hh" +#include "RootOutput.h" + +// CLHEP +#include "CLHEP/Random/RandGauss.h" + +using namespace std; +using namespace CLHEP; +using namespace HYD2SQUARE1; + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +Hyde2TrackerSquare1::Hyde2TrackerSquare1() +{ + ms_InterCoord = 0; +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +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) ; +} + + + +//....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) ; +} + + + +//....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() ; + + ///////////////////////////////////////////////////////////////// + /////////////////Element Definition /////////////////////////// + //////////////////////////////////////////////////////////////// + G4String symbol ; + G4double density = 0. , a = 0, z = 0 ; + G4int ncomponents = 0, natoms = 0 ; + + G4Element* H = new G4Element("Hydrogen" , symbol = "H" , z = 1 , a = 1.01 * g / mole); + G4Element* C = new G4Element("Carbon" , symbol = "C" , z = 6 , a = 12.011 * g / mole); + G4Element* N = new G4Element("Nitrogen" , symbol = "N" , z = 7 , a = 14.01 * g / mole); + G4Element* O = new G4Element("Oxigen" , symbol = "O" , z = 8 , a = 16.00 * g / mole); + G4Element* I = new G4Element("Iode" , symbol = "I" , z = 53 , a = 126.9 * g / mole); + G4Element* Cs = new G4Element("Cesium" , symbol = "Cs" , z = 55 , a = 132.9 * g / mole); + + G4Element* Co = new G4Element("Cobalt" , symbol = "Co" , z = 27 , a = 58.933 * g / mole); + G4Element* Cr = new G4Element("Cromium" , symbol = "Cr" , z = 24 , a = 51.996 * g / mole); + G4Element* Ni = new G4Element("Nickel" , symbol = "Ni" , z = 28 , a = 58.69 * g / mole); + G4Element* Fe = new G4Element("Iron" , symbol = "Fe" , z = 26 , a = 55.847 * g / mole); + G4Element* W = new G4Element("Tungsten" , symbol = "W" , z = 74 , a = 183.5 * g / mole); + + //////////////////////////////////////////////////////////////// + /////////////////Material Definition /////////////////////////// + //////////////////////////////////////////////////////////////// + // Si + a = 28.0855 * g / mole; + density = 2.321 * g / cm3; + G4Material* Silicon = new G4Material("Si", z = 14., a, density); + + // Al + density = 2.702 * g / cm3; + a = 26.98 * g / mole; +// G4Material* Aluminium = new G4Material("Aluminium", z = 13., a, density); + + // Iron +// density = 7.874 * g / cm3; +// a = 55.847 * g / mole; +// G4Material* Iron = new G4Material("Iron", z = 26., a, density); + + // CsI + density = 4.51 * g / cm3; + G4Material* CsI = new G4Material("CsI", density, ncomponents = 2); + CsI->AddElement(Cs , natoms = 1); + CsI->AddElement(I , natoms = 1); + + // Vacuum + density = 0.000000001 * mg / cm3; + G4Material* Vacuum = new G4Material("Vacuum", density, ncomponents = 2); + Vacuum->AddElement(N, .7); + Vacuum->AddElement(O, .3); + + // Mylar + density = 1.397 * g / cm3; + G4Material* Myl = new G4Material("Mylar", density, ncomponents = 3); + Myl->AddElement(C, natoms = 10); + Myl->AddElement(H, natoms = 8); + Myl->AddElement(O, natoms = 4); + + // Havar + G4Material* Harvar = new G4Material("Havar", 8.3*g / cm3, 5); + Harvar->AddElement(Co , 42); + Harvar->AddElement(Cr , 20); + Harvar->AddElement(Ni , 13); + Harvar->AddElement(Fe , 19); + Harvar->AddElement(W , 1); + + //////////////////////////////////////////////////////////////// + ////////////// 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, Vacuum, 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. + /* + G4ThreeVector positionMarkerU = CT*0.98 + MMu*SiliconFace/4; + G4Box* solidMarkerU = new G4Box( "solidMarkerU" , SiliconFace/4 , 1*mm , 1*mm ) ; + G4LogicalVolume* logicMarkerU = new G4LogicalVolume( solidMarkerU , Vacuum , "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 + logicMarkerU->SetVisAttributes(MarkerUVisAtt); + + G4ThreeVector positionMarkerV = CT*0.98 + MMv*SiliconFace/4; + G4Box* solidMarkerV = new G4Box( "solidMarkerU" , 1*mm , SiliconFace/4 , 1*mm ) ; + G4LogicalVolume* logicMarkerV = new G4LogicalVolume( solidMarkerV , Vacuum , "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, Silicon, "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, Silicon, "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, Silicon, "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, Silicon, "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, Silicon, "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, Silicon, "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...... +//....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 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); + cout << "X1 Y1 corner position : " << A << endl; + } + + 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); + cout << "X128 Y1 corner position : " << B << endl; + } + + 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); + cout << "X1 Y128 corner position : " << C << endl; + } + + 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); + cout << "X128 Y128 corner position : " << D << endl; + } + + + // Angle method + else if (DataBuffer.compare(0, 6, "THETA=") == 0) { + check_Theta = true; + ConfigFile >> DataBuffer ; + Theta = atof(DataBuffer.c_str()) ; + Theta = Theta * deg; + cout << "Theta: " << Theta / deg << endl; + } + + else if (DataBuffer.compare(0, 4, "PHI=") == 0) { + check_Phi = true; + ConfigFile >> DataBuffer ; + Phi = atof(DataBuffer.c_str()) ; + Phi = Phi * deg; + cout << "Phi: " << Phi / deg << endl; + } + + else if (DataBuffer.compare(0, 2, "R=") == 0) { + check_R = true; + ConfigFile >> DataBuffer ; + R = atof(DataBuffer.c_str()) ; + R = R * mm; + cout << "R: " << R / mm << endl; + } + + 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); + } + + + } + } +} + +// 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 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 << endl ; + 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 l = 0 ; l < sizeE ; l++) { + 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 (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->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 (G4int 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 (G4int 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 (G4int 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 (G4int 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() +{ + // First stage Associate Scorer + m_FirstStageScorer = new G4MultiFunctionalDetector("FirstStageScorerHYD2Square1"); + G4VPrimitiveScorer* DetNbr = new GENERALSCORERS::PSDetectorNumber("DetectorNumber", "HYD2Square1", 0); + G4VPrimitiveScorer* TOF = new GENERALSCORERS::PSTOF("StripTime","HYD2Square1", 0); + G4VPrimitiveScorer* InteractionCoordinatesX = new GENERALSCORERS::PSInteractionCoordinatesX("InterCoordX","HYD2Square1", 0); + G4VPrimitiveScorer* InteractionCoordinatesY = new GENERALSCORERS::PSInteractionCoordinatesY("InterCoordY","HYD2Square1", 0); + G4VPrimitiveScorer* InteractionCoordinatesZ = new GENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ","HYD2Square1", 0); + G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new GENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta","HYD2Square1", 0); + G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new GENERALSCORERS::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 + m_SecondStageScorer = new G4MultiFunctionalDetector("SecondStageScorerHYD2Square1"); + G4VPrimitiveScorer* SecondStageEnergy = new HYD2ScorerSecondStageEnergy("SecondStageEnergy", "HYD2Square1", 0); + m_SecondStageScorer->RegisterPrimitive(SecondStageEnergy); + + // Third stage Associate Scorer + m_ThirdStageScorer = new G4MultiFunctionalDetector("ThirdStageScorerHYD2Square1"); + G4VPrimitiveScorer* ThirdStageEnergy = new HYD2ScorerThirdStageEnergy("ThirdStageEnergy", "HYD2Square1", 0); + m_ThirdStageScorer->RegisterPrimitive(ThirdStageEnergy); + + // Fourth stage Associate Scorer + m_FourthStageScorer = new G4MultiFunctionalDetector("FourthStageScorerHYD2Square1"); + G4VPrimitiveScorer* FourthStageEnergy = new HYD2ScorerFourthStageEnergy("FourthStageEnergy", "HYD2Square1", 0); + m_FourthStageScorer->RegisterPrimitive(FourthStageEnergy); + + // Fifth stage Associate Scorer + m_FifthStageScorer = new G4MultiFunctionalDetector("FifthStageScorerHYD2Square1"); + G4VPrimitiveScorer* FifthStageEnergy = new HYD2ScorerFifthStageEnergy("FifthStageEnergy", "HYD2Square1", 0); + m_FifthStageScorer->RegisterPrimitive(FifthStageEnergy); + + // Sixth stage Associate Scorer + m_SixthStageScorer = new G4MultiFunctionalDetector("SixthStageScorerHYD2Square1"); + 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/src/Hyde2TrackerTrapezoid1.cc b/NPSimulation/src/Hyde2TrackerTrapezoid1.cc new file mode 100644 index 000000000..fb8fe60d1 --- /dev/null +++ b/NPSimulation/src/Hyde2TrackerTrapezoid1.cc @@ -0,0 +1,1286 @@ +/***************************************************************************** + * 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : 15/07/09 * + * Last update : 12/10/09 * + *---------------------------------------------------------------------------* + * Decription: Define a module of trapezoidal shape for the Hyde2 tracker * + * * + *---------------------------------------------------------------------------* + * Comment: * + * + 12/10/09: Change scorer scheme (N. de Sereville) * + * + 01/10/10: Fix bug with TInteractionCoordinate map size in Read * + * Sensitive (N. de Sereville) * + * * + * * + *****************************************************************************/ + +// C++ headers +#include <sstream> +#include <string> +#include <cmath> + +// G4 Geometry headers +#include "G4Box.hh" +#include "G4Trap.hh" + +// G4 various headers +#include "G4MaterialTable.hh" +#include "G4Element.hh" +#include "G4ElementTable.hh" +#include "G4VisAttributes.hh" +#include "G4Colour.hh" +#include "G4RotationMatrix.hh" +#include "G4Transform3D.hh" +#include "G4PVPlacement.hh" +#include "G4PVDivision.hh" + +// G4 sensitive +#include "G4SDManager.hh" +#include "G4MultiFunctionalDetector.hh" + +// NPTool headers +#include "Hyde2TrackerTrapezoid1.hh" +#include "GeneralScorers.hh" +#include "Hyde2Scorers.hh" +#include "RootOutput.h" + +// CLHEP +#include "CLHEP/Random/RandGauss.h" + +using namespace std; +using namespace CLHEP; +using namespace HYD2TRAP1 ; + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +Hyde2TrackerTrapezoid1::Hyde2TrackerTrapezoid1() +{ + ms_InterCoord = 0; +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +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) ; +} + + + +//....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) ; +} + + + +//....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() ; + + //////////////////////////////////////////////////////////////// + /////////////////Element Definition /////////////////////////// + //////////////////////////////////////////////////////////////// + G4String symbol ; + G4double density = 0. , a = 0, z = 0 ; + G4int ncomponents = 0, natoms = 0 ; + + G4Element* H = new G4Element("Hydrogen" , symbol = "H" , z = 1 , a = 1.01 * g / mole); + G4Element* C = new G4Element("Carbon" , symbol = "C" , z = 6 , a = 12.011 * g / mole); + G4Element* N = new G4Element("Nitrogen" , symbol = "N" , z = 7 , a = 14.01 * g / mole); + G4Element* O = new G4Element("Oxigen" , symbol = "O" , z = 8 , a = 16.00 * g / mole); + G4Element* I = new G4Element("Iode" , symbol = "I" , z = 53 , a = 126.9 * g / mole); + G4Element* Cs = new G4Element("Cesium" , symbol = "Cs" , z = 55 , a = 132.9 * g / mole); + + G4Element* Co = new G4Element("Cobalt" , symbol = "Co" , z = 27 , a = 58.933 * g / mole); + G4Element* Cr = new G4Element("Cromium" , symbol = "Cr" , z = 24 , a = 51.996 * g / mole); + G4Element* Ni = new G4Element("Nickel" , symbol = "Ni" , z = 28 , a = 58.69 * g / mole); + G4Element* Fe = new G4Element("Iron" , symbol = "Fe" , z = 26 , a = 55.847 * g / mole); + G4Element* W = new G4Element("Tungsten" , symbol = "W" , z = 74 , a = 183.5 * g / mole); + + //////////////////////////////////////////////////////////////// + /////////////////Material Definition /////////////////////////// + //////////////////////////////////////////////////////////////// + // Si + a = 28.0855 * g / mole; + density = 2.321 * g / cm3; + G4Material* Silicon = new G4Material("Si", z = 14., a, density); + + // Al +// density = 2.702 * g / cm3; +// a = 26.98 * g / mole; +// G4Material* Aluminium = new G4Material("Aluminium", z = 13., a, density); + + // Iron +// density = 7.874 * g / cm3; +// a = 55.847 * g / mole; +// G4Material* Iron = new G4Material("Iron", z = 26., a, density); + + // CsI + density = 4.51 * g / cm3; + G4Material* CsI = new G4Material("CsI", density, ncomponents = 2); + CsI->AddElement(Cs , natoms = 1); + CsI->AddElement(I , natoms = 1); + + // Vacuum + density = 0.000000001 * mg / cm3; + G4Material* Vacuum = new G4Material("Vacuum", density, ncomponents = 2); + Vacuum->AddElement(N, .7); + Vacuum->AddElement(O, .3); + + // Mylar + density = 1.397 * g / cm3; + G4Material* Myl = new G4Material("Mylar", density, ncomponents = 3); + Myl->AddElement(C, natoms = 10); + Myl->AddElement(H, natoms = 8); + Myl->AddElement(O, natoms = 4); + + // Havar + G4Material* Harvar = new G4Material("Havar", 8.3*g / cm3, 5); + Harvar->AddElement(Co , 42); + Harvar->AddElement(Cr , 20); + Harvar->AddElement(Ni , 13); + Harvar->AddElement(Fe , 19); + Harvar->AddElement(W , 1); + + //////////////////////////////////////////////////////////////// + ////////////// 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, Vacuum, 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. + /* + G4ThreeVector positionMarkerU = CT*0.98 + MMu*SiliconFace/4; + G4Box* solidMarkerU = new G4Box( "solidMarkerU" , SiliconFace/4 , 1*mm , 1*mm ) ; + G4LogicalVolume* logicMarkerU = new G4LogicalVolume( solidMarkerU , Vacuum , "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 + logicMarkerU->SetVisAttributes(MarkerUVisAtt); + + G4ThreeVector positionMarkerV = CT*0.98 + MMv*SiliconFace/4; + G4Box* solidMarkerV = new G4Box( "solidMarkerU" , 1*mm , SiliconFace/4 , 1*mm ) ; + G4LogicalVolume* logicMarkerV = new G4LogicalVolume( solidMarkerV , Vacuum , "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, Silicon, "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, Silicon, "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, Silicon, "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, Silicon, "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, Silicon, "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, Silicon, "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...... +//....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 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); + cout << "X1 Y1 corner position : " << A << endl; + } + + 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); + cout << "X128 Y1 corner position : " << B << endl; + } + + 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); + cout << "X1 Y128 corner position : " << C << endl; + } + + 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); + cout << "X128 Y128 corner position : " << D << endl; + } + + + // Angle method + else if (DataBuffer.compare(0, 6, "THETA=") == 0) { + check_Theta = true; + ConfigFile >> DataBuffer ; + Theta = atof(DataBuffer.c_str()) ; + Theta = Theta * deg; + cout << "Theta: " << Theta / deg << endl; + } + + else if (DataBuffer.compare(0, 4, "PHI=") == 0) { + check_Phi = true; + ConfigFile >> DataBuffer ; + Phi = atof(DataBuffer.c_str()) ; + Phi = Phi * deg; + cout << "Phi: " << Phi / deg << endl; + } + + else if (DataBuffer.compare(0, 2, "R=") == 0) { + check_R = true; + ConfigFile >> DataBuffer ; + R = atof(DataBuffer.c_str()) ; + R = R * mm; + cout << "R: " << R / mm << endl; + } + + 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); + } + + + } + } +} + +// 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 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 << endl ; + 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 l = 0 ; l < sizeE ; l++) { + 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 (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->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 (G4int 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 (G4int 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 (G4int 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 (G4int 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() +{ + // First stage Associate Scorer + m_FirstStageScorer = new G4MultiFunctionalDetector("FirstStageScorerHYD2Trapezoid1"); + G4VPrimitiveScorer* DetNbr = new GENERALSCORERS::PSDetectorNumber("DetectorNumber", "HYD2Trapezoid1", 0); + G4VPrimitiveScorer* TOF = new GENERALSCORERS::PSTOF("StripTime","HYD2Trapezoid1", 0); + G4VPrimitiveScorer* InteractionCoordinatesX = new GENERALSCORERS::PSInteractionCoordinatesX("InterCoordX","HYD2Trapezoid1", 0); + G4VPrimitiveScorer* InteractionCoordinatesY = new GENERALSCORERS::PSInteractionCoordinatesY("InterCoordY","HYD2Trapezoid1", 0); + G4VPrimitiveScorer* InteractionCoordinatesZ = new GENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ","HYD2Trapezoid1", 0); + G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new GENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta","HYD2Trapezoid1", 0); + G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new GENERALSCORERS::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 + m_SecondStageScorer = new G4MultiFunctionalDetector("SecondStageScorerHYD2Trapezoid1"); + G4VPrimitiveScorer* SecondStageEnergy = new HYD2ScorerSecondStageEnergy("SecondStageEnergy", "HYD2Trapezoid1", 0); + m_SecondStageScorer->RegisterPrimitive(SecondStageEnergy); + + // Third stage Associate Scorer + m_ThirdStageScorer = new G4MultiFunctionalDetector("ThirdStageScorerHYD2Trapezoid1"); + G4VPrimitiveScorer* ThirdStageEnergy = new HYD2ScorerThirdStageEnergy("ThirdStageEnergy", "HYD2Trapezoid1", 0); + m_ThirdStageScorer->RegisterPrimitive(ThirdStageEnergy); + + // Fourth stage Associate Scorer + m_FourthStageScorer = new G4MultiFunctionalDetector("FourthStageScorerHYD2Trapezoid1"); + G4VPrimitiveScorer* FourthStageEnergy = new HYD2ScorerFourthStageEnergy("FourthStageEnergy", "HYD2Trapezoid1", 0); + m_FourthStageScorer->RegisterPrimitive(FourthStageEnergy); + + // Fifth stage Associate Scorer + m_FifthStageScorer = new G4MultiFunctionalDetector("FifthStageScorerHYD2Trapezoid1"); + G4VPrimitiveScorer* FifthStageEnergy = new HYD2ScorerFifthStageEnergy("FifthStageEnergy", "HYD2Trapezoid1", 0); + m_FifthStageScorer->RegisterPrimitive(FifthStageEnergy); + + // Sixth stage Associate Scorer + m_SixthStageScorer = new G4MultiFunctionalDetector("SixthStageScorerHYD2Trapezoid1"); + 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/src/Hyde2TrackerTrapezoid2.cc b/NPSimulation/src/Hyde2TrackerTrapezoid2.cc new file mode 100644 index 000000000..ffdecee53 --- /dev/null +++ b/NPSimulation/src/Hyde2TrackerTrapezoid2.cc @@ -0,0 +1,1286 @@ +/***************************************************************************** + * 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : 15/07/09 * + * Last update : 12/10/09 * + *---------------------------------------------------------------------------* + * Decription: Define a module of trapezoidal shape for the Hyde2 tracker * + * * + *---------------------------------------------------------------------------* + * Comment: * + * + 12/10/09: Change scorer scheme (N. de Sereville) * + * + 01/10/10: Fix bug with TInteractionCoordinate map size in Read * + * Sensitive (N. de Sereville) * + * * + * * + *****************************************************************************/ + +// C++ headers +#include <sstream> +#include <string> +#include <cmath> + +// G4 Geometry headers +#include "G4Box.hh" +#include "G4Trap.hh" + +// G4 various headers +#include "G4MaterialTable.hh" +#include "G4Element.hh" +#include "G4ElementTable.hh" +#include "G4VisAttributes.hh" +#include "G4Colour.hh" +#include "G4RotationMatrix.hh" +#include "G4Transform3D.hh" +#include "G4PVPlacement.hh" +#include "G4PVDivision.hh" + +// G4 sensitive +#include "G4SDManager.hh" +#include "G4MultiFunctionalDetector.hh" + +// NPTool headers +#include "Hyde2TrackerTrapezoid2.hh" +#include "GeneralScorers.hh" +#include "Hyde2Scorers.hh" +#include "RootOutput.h" + +// CLHEP +#include "CLHEP/Random/RandGauss.h" + +using namespace std; +using namespace CLHEP; +using namespace HYD2TRAP2 ; + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +Hyde2TrackerTrapezoid2::Hyde2TrackerTrapezoid2() +{ + ms_InterCoord = 0; +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +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) ; +} + + + +//....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) ; +} + + + +//....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() ; + + //////////////////////////////////////////////////////////////// + /////////////////Element Definition /////////////////////////// + //////////////////////////////////////////////////////////////// + G4String symbol ; + G4double density = 0. , a = 0, z = 0 ; + G4int ncomponents = 0, natoms = 0 ; + + G4Element* H = new G4Element("Hydrogen" , symbol = "H" , z = 1 , a = 1.01 * g / mole); + G4Element* C = new G4Element("Carbon" , symbol = "C" , z = 6 , a = 12.011 * g / mole); + G4Element* N = new G4Element("Nitrogen" , symbol = "N" , z = 7 , a = 14.01 * g / mole); + G4Element* O = new G4Element("Oxigen" , symbol = "O" , z = 8 , a = 16.00 * g / mole); + G4Element* I = new G4Element("Iode" , symbol = "I" , z = 53 , a = 126.9 * g / mole); + G4Element* Cs = new G4Element("Cesium" , symbol = "Cs" , z = 55 , a = 132.9 * g / mole); + + G4Element* Co = new G4Element("Cobalt" , symbol = "Co" , z = 27 , a = 58.933 * g / mole); + G4Element* Cr = new G4Element("Cromium" , symbol = "Cr" , z = 24 , a = 51.996 * g / mole); + G4Element* Ni = new G4Element("Nickel" , symbol = "Ni" , z = 28 , a = 58.69 * g / mole); + G4Element* Fe = new G4Element("Iron" , symbol = "Fe" , z = 26 , a = 55.847 * g / mole); + G4Element* W = new G4Element("Tungsten" , symbol = "W" , z = 74 , a = 183.5 * g / mole); + + //////////////////////////////////////////////////////////////// + /////////////////Material Definition /////////////////////////// + //////////////////////////////////////////////////////////////// + // Si + a = 28.0855 * g / mole; + density = 2.321 * g / cm3; + G4Material* Silicon = new G4Material("Si", z = 14., a, density); + + // Al +// density = 2.702 * g / cm3; +// a = 26.98 * g / mole; +// G4Material* Aluminium = new G4Material("Aluminium", z = 13., a, density); + + // Iron +// density = 7.874 * g / cm3; +// a = 55.847 * g / mole; +// G4Material* Iron = new G4Material("Iron", z = 26., a, density); + + // CsI + density = 4.51 * g / cm3; + G4Material* CsI = new G4Material("CsI", density, ncomponents = 2); + CsI->AddElement(Cs , natoms = 1); + CsI->AddElement(I , natoms = 1); + + // Vacuum + density = 0.000000001 * mg / cm3; + G4Material* Vacuum = new G4Material("Vacuum", density, ncomponents = 2); + Vacuum->AddElement(N, .7); + Vacuum->AddElement(O, .3); + + // Mylar + density = 1.397 * g / cm3; + G4Material* Myl = new G4Material("Mylar", density, ncomponents = 3); + Myl->AddElement(C, natoms = 10); + Myl->AddElement(H, natoms = 8); + Myl->AddElement(O, natoms = 4); + + // Havar + G4Material* Harvar = new G4Material("Havar", 8.3*g / cm3, 5); + Harvar->AddElement(Co , 42); + Harvar->AddElement(Cr , 20); + Harvar->AddElement(Ni , 13); + Harvar->AddElement(Fe , 19); + Harvar->AddElement(W , 1); + + //////////////////////////////////////////////////////////////// + ////////////// 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, Vacuum, 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. + /* + G4ThreeVector positionMarkerU = CT*0.98 + MMu*SiliconFace/4; + G4Box* solidMarkerU = new G4Box( "solidMarkerU" , SiliconFace/4 , 1*mm , 1*mm ) ; + G4LogicalVolume* logicMarkerU = new G4LogicalVolume( solidMarkerU , Vacuum , "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 + logicMarkerU->SetVisAttributes(MarkerUVisAtt); + + G4ThreeVector positionMarkerV = CT*0.98 + MMv*SiliconFace/4; + G4Box* solidMarkerV = new G4Box( "solidMarkerU" , 1*mm , SiliconFace/4 , 1*mm ) ; + G4LogicalVolume* logicMarkerV = new G4LogicalVolume( solidMarkerV , Vacuum , "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, Silicon, "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, Silicon, "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, Silicon, "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, Silicon, "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, Silicon, "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, Silicon, "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...... +//....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 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); + cout << "X1 Y1 corner position : " << A << endl; + } + + 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); + cout << "X128 Y1 corner position : " << B << endl; + } + + 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); + cout << "X1 Y128 corner position : " << C << endl; + } + + 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); + cout << "X128 Y128 corner position : " << D << endl; + } + + + // Angle method + else if (DataBuffer.compare(0, 6, "THETA=") == 0) { + check_Theta = true; + ConfigFile >> DataBuffer ; + Theta = atof(DataBuffer.c_str()) ; + Theta = Theta * deg; + cout << "Theta: " << Theta / deg << endl; + } + + else if (DataBuffer.compare(0, 4, "PHI=") == 0) { + check_Phi = true; + ConfigFile >> DataBuffer ; + Phi = atof(DataBuffer.c_str()) ; + Phi = Phi * deg; + cout << "Phi: " << Phi / deg << endl; + } + + else if (DataBuffer.compare(0, 2, "R=") == 0) { + check_R = true; + ConfigFile >> DataBuffer ; + R = atof(DataBuffer.c_str()) ; + R = R * mm; + cout << "R: " << R / mm << endl; + } + + 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); + } + + + } + } +} + +// 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 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 << endl ; + 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 l = 0 ; l < sizeE ; l++) { + 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 (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->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 (G4int 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 (G4int 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 (G4int 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 (G4int 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() +{ + // First stage Associate Scorer + m_FirstStageScorer = new G4MultiFunctionalDetector("FirstStageScorerHYD2Trapezoid2"); + G4VPrimitiveScorer* DetNbr = new GENERALSCORERS::PSDetectorNumber("DetectorNumber", "HYD2Trapezoid2", 0); + G4VPrimitiveScorer* TOF = new GENERALSCORERS::PSTOF("StripTime","HYD2Trapezoid2", 0); + G4VPrimitiveScorer* InteractionCoordinatesX = new GENERALSCORERS::PSInteractionCoordinatesX("InterCoordX","HYD2Trapezoid2", 0); + G4VPrimitiveScorer* InteractionCoordinatesY = new GENERALSCORERS::PSInteractionCoordinatesY("InterCoordY","HYD2Trapezoid2", 0); + G4VPrimitiveScorer* InteractionCoordinatesZ = new GENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ","HYD2Trapezoid2", 0); + G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new GENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta","HYD2Trapezoid2", 0); + G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new GENERALSCORERS::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 + m_SecondStageScorer = new G4MultiFunctionalDetector("SecondStageScorerHYD2Trapezoid2"); + G4VPrimitiveScorer* SecondStageEnergy = new HYD2ScorerSecondStageEnergy("SecondStageEnergy", "HYD2Trapezoid2", 0); + m_SecondStageScorer->RegisterPrimitive(SecondStageEnergy); + + // Third stage Associate Scorer + m_ThirdStageScorer = new G4MultiFunctionalDetector("ThirdStageScorerHYD2Trapezoid2"); + G4VPrimitiveScorer* ThirdStageEnergy = new HYD2ScorerThirdStageEnergy("ThirdStageEnergy", "HYD2Trapezoid2", 0); + m_ThirdStageScorer->RegisterPrimitive(ThirdStageEnergy); + + // Fourth stage Associate Scorer + m_FourthStageScorer = new G4MultiFunctionalDetector("FourthStageScorerHYD2Trapezoid2"); + G4VPrimitiveScorer* FourthStageEnergy = new HYD2ScorerFourthStageEnergy("FourthStageEnergy", "HYD2Trapezoid2", 0); + m_FourthStageScorer->RegisterPrimitive(FourthStageEnergy); + + // Fifth stage Associate Scorer + m_FifthStageScorer = new G4MultiFunctionalDetector("FifthStageScorerHYD2Trapezoid2"); + G4VPrimitiveScorer* FifthStageEnergy = new HYD2ScorerFifthStageEnergy("FifthStageEnergy", "HYD2Trapezoid2", 0); + m_FifthStageScorer->RegisterPrimitive(FifthStageEnergy); + + // Sixth stage Associate Scorer + m_SixthStageScorer = new G4MultiFunctionalDetector("SixthStageScorerHYD2Trapezoid2"); + 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); +} -- GitLab