From 4d12dddca58f280d2d4d571bc45f801f1c76b299 Mon Sep 17 00:00:00 2001 From: matta <matta@npt> Date: Thu, 15 Oct 2009 09:21:47 +0000 Subject: [PATCH] * Major upgrade on Scorer - General Scorer now use the TrackID+DetNbr index system, ensuring more flexibility. - Plastic,MUST2 and ThinSi use the same system and rely on General Scorer * Naming Convention of Detector Volume is define - Volume name should be : DetectorNameX_SubPart - This insure compatibility with the General Scorer * Correcting Bug: if no target the Transfert and TransfertToReasonance method crashed - Fixed by adding a test on the target address * NB: Further test to be made on Gaspard to check everything is fine --- Inputs/EventGenerator/10He.reaction | 4 +- NPSimulation/include/GeneralScorers.hh | 384 ++++++++++-------- NPSimulation/include/Must2Scorers.hh | 45 -- NPSimulation/include/Plastic.hh | 8 +- NPSimulation/include/PlasticScorers.hh | 94 ----- NPSimulation/include/ThinSi.hh | 11 + NPSimulation/include/VDetector.hh | 12 + NPSimulation/src/AnnularS1.cc | 12 +- NPSimulation/src/AnnularS1Scorers.cc | 20 +- .../src/EventGeneratorTransfertToResonance.cc | 16 +- NPSimulation/src/GaspardScorers.cc | 1 - NPSimulation/src/GaspardTrackerAnnular.cc | 12 +- NPSimulation/src/GaspardTrackerDummyShape.cc | 12 +- NPSimulation/src/GaspardTrackerSquare.cc | 12 +- NPSimulation/src/GaspardTrackerTrapezoid.cc | 12 +- NPSimulation/src/GeneralScorers.cc | 221 ++++++---- NPSimulation/src/MUST2Array.cc | 278 ++++++------- NPSimulation/src/Must2Scorers.cc | 143 +------ NPSimulation/src/Plastic.cc | 67 +-- NPSimulation/src/PlasticScorer.cc | 240 ----------- NPSimulation/src/ThinSi.cc | 147 ++++--- NPSimulation/src/VEventGenerator.cc | 108 +++-- 22 files changed, 757 insertions(+), 1102 deletions(-) delete mode 100644 NPSimulation/include/PlasticScorers.hh delete mode 100644 NPSimulation/src/PlasticScorer.cc diff --git a/Inputs/EventGenerator/10He.reaction b/Inputs/EventGenerator/10He.reaction index 18dd9fe54..2c1407b0f 100644 --- a/Inputs/EventGenerator/10He.reaction +++ b/Inputs/EventGenerator/10He.reaction @@ -7,7 +7,7 @@ TransfertToResonance Target= 2H Light= 3He Heavy= 10He - ExcitationEnergy= 4.0 + ExcitationEnergy= 2.0 BeamEnergy= 550 BeamEnergySpread= 0 SigmaThetaX= 0.6921330164 @@ -16,7 +16,7 @@ TransfertToResonance SigmaY= 9.069 ResonanceWidth= 0 ResonanceDecayZ= 2 - ResonanceDecayA= 6 + ResonanceDecayA= 8 CrossSectionPath= 11Li(d,3He)10He.txt ShootLight= 1 ShootHeavy= 1 diff --git a/NPSimulation/include/GeneralScorers.hh b/NPSimulation/include/GeneralScorers.hh index 1591fbab1..70dcc65e5 100644 --- a/NPSimulation/include/GeneralScorers.hh +++ b/NPSimulation/include/GeneralScorers.hh @@ -27,183 +27,217 @@ #include "G4VPrimitiveScorer.hh" #include "G4THitsMap.hh" -class PSEnergy : public G4VPrimitiveScorer +namespace GENERALSCORERS { + //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + // This Threshold is used in the above scorer. Any energy deposit under this threshold will not create an entry. + const double TriggerThreshold = 100*keV ; + + //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + // The following function is used in many scorer. following the Detector Volume Nomenclature + // DetectorNameX_SubPart_SubPart + // where X stand for the detector number. + + int PickUpDetectorNumber(G4Step* aStep, std::string DetName); + + + + //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + class PSDetectorNumber : public G4VPrimitiveScorer + { + + public: // with description + PSDetectorNumber(G4String name, G4String VolumeName = "xxx", G4int depth = 0 ); + virtual ~PSDetectorNumber(); + + 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<G4int>* EvtMap; + + }; + + //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + class PSEnergy : public G4VPrimitiveScorer + { + + public: // with description + PSEnergy(G4String name, G4String VolumeName, G4int depth); + virtual ~PSEnergy(); + + 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; + }; + + //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + class PSTOF : public G4VPrimitiveScorer + { + + public: // with description + PSTOF(G4String name, G4String VolumeName, G4int depth); + virtual ~PSTOF(); + + 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; + }; + + //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + class PSInteractionCoordinatesX : public G4VPrimitiveScorer + { + public: // with description + PSInteractionCoordinatesX(G4String name, G4String VolumeName, G4int depth); + virtual ~PSInteractionCoordinatesX(); + + 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; + }; + + + //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + class PSInteractionCoordinatesY : public G4VPrimitiveScorer + { + public: // with description + PSInteractionCoordinatesY(G4String name, G4String VolumeName, G4int depth); + virtual ~PSInteractionCoordinatesY(); + + 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; + }; + + + //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + class PSInteractionCoordinatesZ : public G4VPrimitiveScorer + { + public: // with description + PSInteractionCoordinatesZ(G4String name, G4String VolumeName, G4int depth); + virtual ~PSInteractionCoordinatesZ(); + + 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; + }; + + + //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + class PSInteractionCoordinatesAngleTheta : public G4VPrimitiveScorer + { + public: // with description + PSInteractionCoordinatesAngleTheta(G4String name, G4String VolumeName, G4int depth); + virtual ~PSInteractionCoordinatesAngleTheta(); + + 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; + }; + + + //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + class PSInteractionCoordinatesAnglePhi : public G4VPrimitiveScorer + { + public: // with description + PSInteractionCoordinatesAnglePhi(G4String name, G4String VolumeName, G4int depth); + virtual ~PSInteractionCoordinatesAnglePhi(); + + 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; + }; + + + + } - public: // with description - PSEnergy(G4String name, G4int depth = 0); - virtual ~PSEnergy(); - 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 HCID; - G4THitsMap<G4double>* EvtMap; - }; - -class PSTOF : public G4VPrimitiveScorer -{ - - public: // with description - PSTOF(G4String name, G4int depth = 0); - virtual ~PSTOF(); - - 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 HCID; - G4THitsMap<G4double>* EvtMap; -}; - - -class PSInteractionCoordinatesX : public G4VPrimitiveScorer - { - public: // with description - PSInteractionCoordinatesX(G4String name, G4int depth = 0); - virtual ~PSInteractionCoordinatesX(); - - 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 HCID; - G4THitsMap<G4double>* EvtMap; - }; - -class PSInteractionCoordinatesY : public G4VPrimitiveScorer - { - public: // with description - PSInteractionCoordinatesY(G4String name, G4int depth = 0); - virtual ~PSInteractionCoordinatesY(); - - 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 HCID; - G4THitsMap<G4double>* EvtMap; - }; - - - -class PSInteractionCoordinatesZ : public G4VPrimitiveScorer - { - public: // with description - PSInteractionCoordinatesZ(G4String name, G4int depth = 0); - virtual ~PSInteractionCoordinatesZ(); - - 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 HCID; - G4THitsMap<G4double>* EvtMap; - }; - - - -class PSInteractionCoordinatesAngleTheta : public G4VPrimitiveScorer -{ -public: // with description - PSInteractionCoordinatesAngleTheta(G4String name, G4int depth = 0); - virtual ~PSInteractionCoordinatesAngleTheta(); - -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 HCID; - G4THitsMap<G4double>* EvtMap; -}; - - - -class PSInteractionCoordinatesAnglePhi : public G4VPrimitiveScorer -{ -public: // with description - PSInteractionCoordinatesAnglePhi(G4String name, G4int depth = 0); - virtual ~PSInteractionCoordinatesAnglePhi(); - -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 HCID; - G4THitsMap<G4double>* EvtMap; -}; - - -class PSDetectorNumber : public G4VPrimitiveScorer - { - - public: // with description - PSDetectorNumber(G4String name, G4int depth = 0 , G4String VolumeName = "xxx"); - virtual ~PSDetectorNumber(); - - 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 HCID; - G4THitsMap<G4int>* EvtMap; - G4String m_VolumeName ; - }; #endif diff --git a/NPSimulation/include/Must2Scorers.hh b/NPSimulation/include/Must2Scorers.hh index 2240f81dc..098cdbd38 100644 --- a/NPSimulation/include/Must2Scorers.hh +++ b/NPSimulation/include/Must2Scorers.hh @@ -27,28 +27,6 @@ #include "G4VPrimitiveScorer.hh" #include "G4THitsMap.hh" namespace MUST2 { - class PSStripE : public G4VPrimitiveScorer - { - - public: // with description - PSStripE(G4String name, G4int depth = 0); - virtual ~PSStripE(); - - 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 HCID; - G4THitsMap<G4double>* EvtMap; - }; - class PSStripNumberX : public G4VPrimitiveScorer { @@ -100,29 +78,6 @@ namespace MUST2 { G4THitsMap<G4double>* EvtMap; }; - class PSDetectorNumber : public G4VPrimitiveScorer - { - - public: // with description - PSDetectorNumber(G4String name, G4int depth = 0 , G4String VolumeName = "xxx"); - virtual ~PSDetectorNumber(); - - 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 HCID; - G4THitsMap<G4int>* EvtMap; - G4String m_VolumeName ; - }; - } #endif diff --git a/NPSimulation/include/Plastic.hh b/NPSimulation/include/Plastic.hh index 6646719c1..ebe673063 100644 --- a/NPSimulation/include/Plastic.hh +++ b/NPSimulation/include/Plastic.hh @@ -84,9 +84,9 @@ public: public: // Material void InitializeMaterial() ; // Platic - G4Material* m_MaterialPlastic_BC400 ; //BC-400 type plastic - G4Material* m_MaterialPlastic_BC452_2 ; //BC452:BC-400 loaded with 2%Pb type plastic - G4Material* m_MaterialPlastic_BC452_5 ; //BC452:BC-400 loaded with 5%Pb type plastic + G4Material* m_MaterialPlastic_BC400 ; //BC-400 type plastic + G4Material* m_MaterialPlastic_BC452_2 ; //BC452:BC-400 loaded with 2%Pb type plastic + G4Material* m_MaterialPlastic_BC452_5 ; //BC452:BC-400 loaded with 5%Pb type plastic G4Material* m_MaterialPlastic_BC452_10 ; //BC452:BC-400 loaded with 10%Pb type plastic // Lead G4Material* m_MaterialLead ; @@ -109,7 +109,7 @@ private: private: // if true a Lead plate is added in front or back of the detector - vector<double> m_LeadThickness ; + vector<double> m_LeadThickness ; vector<double> m_PlasticThickness ; vector<double> m_PlasticRadius ; diff --git a/NPSimulation/include/PlasticScorers.hh b/NPSimulation/include/PlasticScorers.hh deleted file mode 100644 index 7490280c3..000000000 --- a/NPSimulation/include/PlasticScorers.hh +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef GeneralScorers_h -#define GeneralScorers_h 1 -/***************************************************************************** - * Copyright (C) 2009 this file is part of the NPTool Project * - * * - * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * - * For the list of contributors see $NPTOOL/Licence/Contributors * - *****************************************************************************/ - -/***************************************************************************** - * Original Author: Adrien MATTA contact address: matta@ipno.in2p3.fr * - * * - * Creation Date : September 2009 * - * Last update : * - *---------------------------------------------------------------------------* - * Decription: * - * This class old some of the Platic Scorer, shared by different detector. * - *---------------------------------------------------------------------------* - * Comment: * - *****************************************************************************/ -#include "G4VPrimitiveScorer.hh" -#include "G4THitsMap.hh" -namespace PLASTIC { -class PSEnergy : public G4VPrimitiveScorer - { - - public: // with description - PSEnergy(G4String name, G4int depth = 0); - virtual ~PSEnergy(); - - 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 HCID; - G4THitsMap<G4double>* EvtMap; - }; - -class PSTOF : public G4VPrimitiveScorer -{ - - public: // with description - PSTOF(G4String name, G4int depth = 0); - virtual ~PSTOF(); - - 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 HCID; - G4THitsMap<G4double>* EvtMap; -}; - - -class PSDetectorNumber : public G4VPrimitiveScorer - { - - public: // with description - PSDetectorNumber(G4String name, G4int depth = 0 ); - virtual ~PSDetectorNumber(); - - 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 HCID; - G4THitsMap<G4int>* EvtMap; - }; - - -} - -#endif diff --git a/NPSimulation/include/ThinSi.hh b/NPSimulation/include/ThinSi.hh index 8ebee9381..719c3fda6 100644 --- a/NPSimulation/include/ThinSi.hh +++ b/NPSimulation/include/ThinSi.hh @@ -121,6 +121,17 @@ public: private: G4double m_Energy ; + //////////////////////////////////////////////////// + ////////////////// Scorer Things /////////////////// + //////////////////////////////////////////////////// + +private: + // Initialize all Scorer used by the MUST2Array + void InitializeScorers() ; + + // Scorer Associate to the 20um Silicon stage + G4MultiFunctionalDetector* m_StripScorer ; + //////////////////////////////////////////////////// ///////////////Private intern Data////////////////// //////////////////////////////////////////////////// diff --git a/NPSimulation/include/VDetector.hh b/NPSimulation/include/VDetector.hh index 9d07073d9..dd98b31e4 100644 --- a/NPSimulation/include/VDetector.hh +++ b/NPSimulation/include/VDetector.hh @@ -22,6 +22,18 @@ * * *---------------------------------------------------------------------------* * Comment: * + * Detector inheriting from VDetector should follow this Naming convention * + * for logical volume: * + * DetectorNameX_SubPart * + * * + * -DetectorName is the name of the detector, like "MUST2Array", * + * note that use of _ within the name is prohibitted. * + * * + * -X is the detector Number, for example if you have two plastic then you* + * will have Plastic1 and Plastic2 * + * * + * -SubPart is the optionnal sub part, like for examples Si and CsI in * + * MUST2. Note that you can add as many as _SubPart you need * * * *****************************************************************************/ // C++ header diff --git a/NPSimulation/src/AnnularS1.cc b/NPSimulation/src/AnnularS1.cc index 2a908614d..f91826528 100644 --- a/NPSimulation/src/AnnularS1.cc +++ b/NPSimulation/src/AnnularS1.cc @@ -169,7 +169,7 @@ void AnnularS1::VolumeMaker(G4int DetecNumber, G4PVPlacement* PVPBuffer ; // Name of the module - G4String Name = "AnnularS1_" + DetectorNumber; + G4String Name = "S1Annular" + DetectorNumber; // Definition of the volume containing the sensitive detector G4Tubs* solidAnnularS1 = new G4Tubs(Name, @@ -572,11 +572,11 @@ void AnnularS1::InitializeScorers() G4VPrimitiveScorer* TOF = new AnnularS1ScorerTime("StripTime", 0); G4VPrimitiveScorer* ThetaStripPosition = new AnnularS1ScorerThetaStripNumber("ThetaStripNumber", 0); G4VPrimitiveScorer* PhiStripPosition = new AnnularS1ScorerPhiStripNumber("PhiStripNumber", 0); - G4VPrimitiveScorer* InteractionCoordinatesX = new PSInteractionCoordinatesX("InterCoordX", 0); - G4VPrimitiveScorer* InteractionCoordinatesY = new PSInteractionCoordinatesY("InterCoordY", 0); - G4VPrimitiveScorer* InteractionCoordinatesZ = new PSInteractionCoordinatesZ("InterCoordZ", 0); - G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new PSInteractionCoordinatesAngleTheta("InterCoordAngTheta", 0); - G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new PSInteractionCoordinatesAnglePhi("InterCoordAngPhi", 0); + G4VPrimitiveScorer* InteractionCoordinatesX = new GENERALSCORERS::PSInteractionCoordinatesX("InterCoordX","S1Annular", 0); + G4VPrimitiveScorer* InteractionCoordinatesY = new GENERALSCORERS::PSInteractionCoordinatesY("InterCoordY","S1Annular", 0); + G4VPrimitiveScorer* InteractionCoordinatesZ = new GENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ","S1Annular", 0); + G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new GENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta","S1Annular", 0); + G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new GENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi","S1Annular", 0); //and register it to the multifunctionnal detector m_Scorer->RegisterPrimitive(DetNbr); diff --git a/NPSimulation/src/AnnularS1Scorers.cc b/NPSimulation/src/AnnularS1Scorers.cc index 514b61589..bc76aa72b 100644 --- a/NPSimulation/src/AnnularS1Scorers.cc +++ b/NPSimulation/src/AnnularS1Scorers.cc @@ -51,8 +51,8 @@ G4bool AnnularS1ScorerDetectorNumber::ProcessHits(G4Step* aStep, G4TouchableHist std::string name = aStep->GetTrack()->GetVolume()->GetName(); std::string nbr; size_t found; - found = name.find("AnnularS1_"); - found = found + 10; + found = name.find("S1Annular"); + found = found + 9; int numberOfCharacterInDetectorNumber = name.length() - (int)found; @@ -126,8 +126,8 @@ G4bool AnnularS1ScorerEnergy::ProcessHits(G4Step* aStep, G4TouchableHistory*) std::string name = aStep->GetTrack()->GetVolume()->GetName(); std::string nbr; size_t found; - found = name.find("AnnularS1_"); - found = found + 10; + found = name.find("S1Annular"); + found = found + 9; int numberOfCharacterInDetectorNumber = name.length() - (int)found; @@ -201,8 +201,8 @@ G4bool AnnularS1ScorerTime::ProcessHits(G4Step* aStep, G4TouchableHistory*) std::string name = aStep->GetTrack()->GetVolume()->GetName(); std::string nbr; size_t found; - found = name.find("AnnularS1_"); - found = found + 10; + found = name.find("S1Annular"); + found = found + 9; int numberOfCharacterInDetectorNumber = name.length() - (int)found; @@ -270,8 +270,8 @@ G4bool AnnularS1ScorerThetaStripNumber::ProcessHits(G4Step* aStep, G4TouchableHi std::string name = aStep->GetTrack()->GetVolume()->GetName(); std::string nbr; size_t found; - found = name.find("AnnularS1_"); - found = found + 10; + found = name.find("S1Annular"); + found = found + 9; int numberOfCharacterInDetectorNumber = name.length() - (int)found; @@ -367,8 +367,8 @@ G4bool AnnularS1ScorerPhiStripNumber::ProcessHits(G4Step* aStep, G4TouchableHist std::string name = aStep->GetTrack()->GetVolume()->GetName(); std::string nbr; size_t found; - found = name.find("AnnularS1_"); - found = found + 10; + found = name.find("S1Annular"); + found = found + 9; int numberOfCharacterInDetectorNumber = name.length() - (int)found; diff --git a/NPSimulation/src/EventGeneratorTransfertToResonance.cc b/NPSimulation/src/EventGeneratorTransfertToResonance.cc index eeb2e8afc..07742f8c9 100644 --- a/NPSimulation/src/EventGeneratorTransfertToResonance.cc +++ b/NPSimulation/src/EventGeneratorTransfertToResonance.cc @@ -363,7 +363,7 @@ while(ReadingStatus){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void EventGeneratorTransfertToResonance::GenerateEvent(G4Event* anEvent , G4ParticleGun* particleGun) -{ +{ // Clear contents of Precedent event (now stored in ROOTOutput) m_InitConditions->Clear(); @@ -409,7 +409,6 @@ void EventGeneratorTransfertToResonance::GenerateEvent(G4Event* anEvent , G4Part else InterCoord = G4ThreeVector(0,0,0); - // write vertex position to ROOT file G4double x0 = InterCoord.x(); G4double y0 = InterCoord.y(); @@ -417,15 +416,12 @@ void EventGeneratorTransfertToResonance::GenerateEvent(G4Event* anEvent , G4Part m_InitConditions->SetICPositionX(x0); m_InitConditions->SetICPositionY(y0); m_InitConditions->SetICPositionZ(z0); - // write emittance angles to ROOT file m_InitConditions->SetICIncidentEmittanceTheta(Beam_thetaX / deg); m_InitConditions->SetICIncidentEmittancePhi(Beam_phiY / deg); - // write angles to ROOT file m_InitConditions->SetICIncidentAngleTheta(Beam_theta / deg); m_InitConditions->SetICIncidentAnglePhi(Beam_phi / deg); - ////////////////////////////////////////////////////////// ///// Build rotation matrix to go from the incident ////// ///// beam frame to the "world" frame ////// @@ -440,7 +436,6 @@ void EventGeneratorTransfertToResonance::GenerateEvent(G4Event* anEvent , G4Part sin(Beam_theta) * sin(Beam_phi), cos(Beam_theta)); G4RotationMatrix BeamToWorld(col1, col2, col3); - ///////////////////////////////////////////////////////////////// ///// Angles for emitted particles following Cross Section ////// ///// Angles are in the beam frame ////// @@ -457,7 +452,6 @@ void EventGeneratorTransfertToResonance::GenerateEvent(G4Event* anEvent , G4Part // write angles to ROOT file m_InitConditions->SetICEmittedAngleThetaCM(ThetaCM / deg); m_InitConditions->SetICEmittedAnglePhiIncidentFrame(phi / deg); - ////////////////////////////////////////////////// ///// Momentum and angles from kinematics ///// ///// Angles are in the beam frame ///// @@ -478,17 +472,16 @@ void EventGeneratorTransfertToResonance::GenerateEvent(G4Event* anEvent , G4Part cos(ThetaHeavy)); - // Move to the target +if( m_Target !=0) { x0 += m_Target->GetTargetX() ; y0 += m_Target->GetTargetY() ; z0 += m_Target->GetTargetZ() ; - + } // write vertex position to ROOT file m_InitConditions->SetICPositionX(x0); m_InitConditions->SetICPositionY(y0); m_InitConditions->SetICPositionZ(z0); - ////////////////////////////////////////////////// ///////// Set up everything for shooting ///////// ////////////////////////////////////////////////// @@ -534,7 +527,7 @@ void EventGeneratorTransfertToResonance::GenerateEvent(G4Event* anEvent , G4Part G4double theta_world = momentum_kine_world.theta(); G4double phi_world = momentum_kine_world.phi(); if (phi_world < 1e-6) phi_world += 2*pi; - + EventGeneratorTransfertToResonance::ResonanceDecay( EnergyHeavy , theta_world , phi_world , @@ -544,7 +537,6 @@ void EventGeneratorTransfertToResonance::GenerateEvent(G4Event* anEvent , G4Part anEvent , particleGun ); - } diff --git a/NPSimulation/src/GaspardScorers.cc b/NPSimulation/src/GaspardScorers.cc index 8ece0f60b..cd0471257 100644 --- a/NPSimulation/src/GaspardScorers.cc +++ b/NPSimulation/src/GaspardScorers.cc @@ -39,7 +39,6 @@ using namespace GPDDUMMYSHAPE; // 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) GPDScorerFirstStageEnergy::GPDScorerFirstStageEnergy(G4String name, G4int depth) diff --git a/NPSimulation/src/GaspardTrackerAnnular.cc b/NPSimulation/src/GaspardTrackerAnnular.cc index d317818cc..c9441a166 100644 --- a/NPSimulation/src/GaspardTrackerAnnular.cc +++ b/NPSimulation/src/GaspardTrackerAnnular.cc @@ -781,14 +781,14 @@ void GaspardTrackerAnnular::InitializeScorers() m_FirstStageScorer = new G4MultiFunctionalDetector("FirstStageScorerGPDAnnular"); G4VPrimitiveScorer* DetNbr = new GPDScorerDetectorNumber("DetectorNumber", 0, "Silicon"); G4VPrimitiveScorer* Energy = new GPDScorerFirstStageEnergy("StripEnergy", 0); - G4VPrimitiveScorer* TOF = new PSTOF("StripTime", 0); + G4VPrimitiveScorer* TOF = new GENERALSCORERS::PSTOF("StripTime","GPDAnnular", 0); G4VPrimitiveScorer* StripPositionX = new GPDScorerFirstStageFrontStripAnnular("StripNumberX", 0, FirstStageRmax, 128); G4VPrimitiveScorer* StripPositionY = new GPDScorerFirstStageBackStripAnnular("StripNumberY", 0, FirstStageRmax, 128); - G4VPrimitiveScorer* InteractionCoordinatesX = new PSInteractionCoordinatesX("InterCoordX", 0); - G4VPrimitiveScorer* InteractionCoordinatesY = new PSInteractionCoordinatesY("InterCoordY", 0); - G4VPrimitiveScorer* InteractionCoordinatesZ = new PSInteractionCoordinatesZ("InterCoordZ", 0); - G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new PSInteractionCoordinatesAngleTheta("InterCoordAngTheta", 0); - G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new PSInteractionCoordinatesAnglePhi("InterCoordAngPhi", 0); + G4VPrimitiveScorer* InteractionCoordinatesX = new GENERALSCORERS::PSInteractionCoordinatesX("InterCoordX","GPDAnnular", 0); + G4VPrimitiveScorer* InteractionCoordinatesY = new GENERALSCORERS::PSInteractionCoordinatesY("InterCoordY","GPDAnnular", 0); + G4VPrimitiveScorer* InteractionCoordinatesZ = new GENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ","GPDAnnular", 0); + G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new GENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta","GPDAnnular", 0); + G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new GENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi","GPDAnnular", 0); //and register it to the multifunctionnal detector m_FirstStageScorer->RegisterPrimitive(DetNbr); diff --git a/NPSimulation/src/GaspardTrackerDummyShape.cc b/NPSimulation/src/GaspardTrackerDummyShape.cc index 4fdfd5ae9..17ab9f3f0 100644 --- a/NPSimulation/src/GaspardTrackerDummyShape.cc +++ b/NPSimulation/src/GaspardTrackerDummyShape.cc @@ -937,14 +937,14 @@ void GaspardTrackerDummyShape::InitializeScorers() m_FirstStageScorer = new G4MultiFunctionalDetector("FirstStageScorerGPDDummyShape"); G4VPrimitiveScorer* DetNbr = new GPDScorerDetectorNumber("DetectorNumber", 0, "FirstStage"); G4VPrimitiveScorer* Energy = new GPDScorerFirstStageEnergy("StripEnergy", 0); - G4VPrimitiveScorer* TOF = new PSTOF("StripTime", 0); + G4VPrimitiveScorer* TOF = new GENERALSCORERS::PSTOF("StripTime","GPDDummyShape", 0); G4VPrimitiveScorer* StripPositionX = new GPDScorerFirstStageFrontStripDummyShape("StripIDFront", 0, NumberOfStrips); G4VPrimitiveScorer* StripPositionY = new GPDScorerFirstStageBackStripDummyShape("StripIDBack", 0, NumberOfStrips); - G4VPrimitiveScorer* InteractionCoordinatesX = new PSInteractionCoordinatesX("InterCoordX", 0); - G4VPrimitiveScorer* InteractionCoordinatesY = new PSInteractionCoordinatesY("InterCoordY", 0); - G4VPrimitiveScorer* InteractionCoordinatesZ = new PSInteractionCoordinatesZ("InterCoordZ", 0); - G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new PSInteractionCoordinatesAngleTheta("InterCoordAngTheta", 0); - G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new PSInteractionCoordinatesAnglePhi("InterCoordAngPhi", 0); + G4VPrimitiveScorer* InteractionCoordinatesX = new GENERALSCORERS::PSInteractionCoordinatesX("InterCoordX","GPDDummyShape", 0); + G4VPrimitiveScorer* InteractionCoordinatesY = new GENERALSCORERS::PSInteractionCoordinatesY("InterCoordY","GPDDummyShape", 0); + G4VPrimitiveScorer* InteractionCoordinatesZ = new GENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ","GPDDummyShape", 0); + G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new GENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta","GPDDummyShape", 0); + G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new GENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi","GPDDummyShape", 0); //and register it to the multifunctionnal detector m_FirstStageScorer->RegisterPrimitive(DetNbr); diff --git a/NPSimulation/src/GaspardTrackerSquare.cc b/NPSimulation/src/GaspardTrackerSquare.cc index a38205a98..d18134190 100644 --- a/NPSimulation/src/GaspardTrackerSquare.cc +++ b/NPSimulation/src/GaspardTrackerSquare.cc @@ -1134,14 +1134,14 @@ void GaspardTrackerSquare::InitializeScorers() m_FirstStageScorer = new G4MultiFunctionalDetector("FirstStageScorerGPDSquare"); G4VPrimitiveScorer* DetNbr = new GPDScorerDetectorNumber("DetectorNumber", 0, "Silicon"); G4VPrimitiveScorer* Energy = new GPDScorerFirstStageEnergy("StripEnergy", 0); - G4VPrimitiveScorer* TOF = new PSTOF("StripTime", 0); + G4VPrimitiveScorer* TOF = new GENERALSCORERS::PSTOF("StripTime","GPDSquare", 0); G4VPrimitiveScorer* StripPositionX = new GPDScorerFirstStageFrontStripSquare("StripNumberX", 0, NumberOfStrips); G4VPrimitiveScorer* StripPositionY = new GPDScorerFirstStageBackStripSquare("StripNumberY", 0, NumberOfStrips); - G4VPrimitiveScorer* InteractionCoordinatesX = new PSInteractionCoordinatesX("InterCoordX", 0); - G4VPrimitiveScorer* InteractionCoordinatesY = new PSInteractionCoordinatesY("InterCoordY", 0); - G4VPrimitiveScorer* InteractionCoordinatesZ = new PSInteractionCoordinatesZ("InterCoordZ", 0); - G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new PSInteractionCoordinatesAngleTheta("InterCoordAngTheta", 0); - G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new PSInteractionCoordinatesAnglePhi("InterCoordAngPhi", 0); + G4VPrimitiveScorer* InteractionCoordinatesX = new GENERALSCORERS::PSInteractionCoordinatesX("InterCoordX","GPDSquare", 0); + G4VPrimitiveScorer* InteractionCoordinatesY = new GENERALSCORERS::PSInteractionCoordinatesY("InterCoordY","GPDSquare", 0); + G4VPrimitiveScorer* InteractionCoordinatesZ = new GENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ","GPDSquare", 0); + G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new GENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta","GPDSquare", 0); + G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new GENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi","GPDSquare", 0); //and register it to the multifunctionnal detector m_FirstStageScorer->RegisterPrimitive(DetNbr); diff --git a/NPSimulation/src/GaspardTrackerTrapezoid.cc b/NPSimulation/src/GaspardTrackerTrapezoid.cc index f3911bff1..20a694240 100644 --- a/NPSimulation/src/GaspardTrackerTrapezoid.cc +++ b/NPSimulation/src/GaspardTrackerTrapezoid.cc @@ -1002,14 +1002,14 @@ void GaspardTrackerTrapezoid::InitializeScorers() m_FirstStageScorer = new G4MultiFunctionalDetector("FirstStageScorerGPDTrapezoid"); G4VPrimitiveScorer* DetNbr = new GPDScorerDetectorNumber("DetectorNumber", 0, "Silicon"); G4VPrimitiveScorer* Energy = new GPDScorerFirstStageEnergy("StripEnergy", 0); - G4VPrimitiveScorer* TOF = new PSTOF("StripTime", 0); + G4VPrimitiveScorer* TOF = new GENERALSCORERS::PSTOF("StripTime","GPDTrapezoid", 0); G4VPrimitiveScorer* StripPositionX = new GPDScorerFirstStageFrontStripTrapezoid("StripNumberX", 0, NumberOfStripsX); G4VPrimitiveScorer* StripPositionY = new GPDScorerFirstStageBackStripTrapezoid("StripNumberY", 0, NumberOfStripsY); - G4VPrimitiveScorer* InteractionCoordinatesX = new PSInteractionCoordinatesX("InterCoordX", 0); - G4VPrimitiveScorer* InteractionCoordinatesY = new PSInteractionCoordinatesY("InterCoordY", 0); - G4VPrimitiveScorer* InteractionCoordinatesZ = new PSInteractionCoordinatesZ("InterCoordZ", 0); - G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new PSInteractionCoordinatesAngleTheta("InterCoordAngTheta", 0); - G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new PSInteractionCoordinatesAnglePhi("InterCoordAngPhi", 0); + G4VPrimitiveScorer* InteractionCoordinatesX = new GENERALSCORERS::PSInteractionCoordinatesX("InterCoordX","GPDTrapezoid", 0); + G4VPrimitiveScorer* InteractionCoordinatesY = new GENERALSCORERS::PSInteractionCoordinatesY("InterCoordY","GPDTrapezoid", 0); + G4VPrimitiveScorer* InteractionCoordinatesZ = new GENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ","GPDTrapezoid", 0); + G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new GENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta","GPDTrapezoid", 0); + G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new GENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi","GPDTrapezoid", 0); //and register it to the multifunctionnal detector m_FirstStageScorer->RegisterPrimitive(DetNbr); diff --git a/NPSimulation/src/GeneralScorers.cc b/NPSimulation/src/GeneralScorers.cc index f532c4495..7c260c6df 100644 --- a/NPSimulation/src/GeneralScorers.cc +++ b/NPSimulation/src/GeneralScorers.cc @@ -24,15 +24,109 @@ *****************************************************************************/ #include "GeneralScorers.hh" #include "G4UnitsTable.hh" +using namespace GENERALSCORERS ; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +// The following function is used in many scorer. following the Detector Volume Nomenclature +// DetectorNameX_SubPart_SubPart +// where X stand for the detector number. + +int GENERALSCORERS::PickUpDetectorNumber(G4Step* aStep, std::string DetName) + { + std::string name = aStep->GetTrack()->GetVolume()->GetName(); + std::string nbr ; + + size_t start, end ; + start = name.find(DetName) + DetName.length(); + end = name.find("_"); + + int numberOfCharacterInDetectorNumber = (int)end - (int)start ; + + for(unsigned int i = start ; i < start + numberOfCharacterInDetectorNumber ; i++ ) + nbr += name[i] ; + + return (atoi( nbr.c_str() )); + + } + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + //Detector Number Scorer +PSDetectorNumber::PSDetectorNumber(G4String name, G4String VolumeName, G4int depth ) + : G4VPrimitiveScorer(name, depth), HCID(-1) +{ + m_VolumeName = VolumeName; +} + +PSDetectorNumber::~PSDetectorNumber() +{ + ; +} + +G4bool PSDetectorNumber::ProcessHits(G4Step* aStep, G4TouchableHistory*) + { + int DetNumber = PickUpDetectorNumber(aStep, m_VolumeName) ; + + G4double edep = aStep->GetTotalEnergyDeposit(); + + if (edep < TriggerThreshold) return FALSE; + + G4int index = aStep->GetTrack()->GetTrackID(); + + EvtMap->set(index+DetNumber, DetNumber); + return TRUE; +} + +void PSDetectorNumber::Initialize(G4HCofThisEvent* HCE) +{ + EvtMap = new G4THitsMap<G4int>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +void PSDetectorNumber::EndOfEvent(G4HCofThisEvent*) +{ + ; +} + +void PSDetectorNumber::clear() +{ + EvtMap->clear(); +} + +void PSDetectorNumber::DrawAll() +{ + ; +} + +void PSDetectorNumber::PrintAll() +{ + G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl; + G4cout << " PrimitiveScorer " << GetName() << G4endl; + G4cout << " Number of entries " << EvtMap->entries() << G4endl; + std::map<G4int, G4int*>::iterator itr = EvtMap->GetMap()->begin(); + for (; itr != EvtMap->GetMap()->end(); itr++) { + G4cout << " copy no.: " << itr->first + << " energy deposit: " << G4BestUnit(*(itr->second), "Energy") + << G4endl; + } +} + + + + // Energy Scorer (deal with multiple particle hit) -PSEnergy::PSEnergy(G4String name, G4int depth) +PSEnergy::PSEnergy(G4String name, G4String VolumeName, G4int depth) : G4VPrimitiveScorer(name, depth), HCID(-1) { + m_VolumeName = VolumeName; } PSEnergy::~PSEnergy() @@ -41,12 +135,14 @@ PSEnergy::~PSEnergy() G4bool PSEnergy::ProcessHits(G4Step* aStep, G4TouchableHistory*) { + int DetNumber = PickUpDetectorNumber(aStep, m_VolumeName) ; + G4double edep = aStep->GetTotalEnergyDeposit(); - if (edep < 100*keV) return FALSE; + if (edep < TriggerThreshold) return FALSE; G4int index = aStep->GetTrack()->GetTrackID(); - EvtMap->add(index, edep); + EvtMap->add(index+DetNumber, edep); return TRUE; } @@ -89,10 +185,10 @@ void PSEnergy::PrintAll() //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //TOF Scorer// -PSTOF::PSTOF(G4String name, G4int depth) +PSTOF::PSTOF(G4String name, G4String VolumeName, G4int depth) : G4VPrimitiveScorer(name, depth), HCID(-1) { - ; + m_VolumeName = VolumeName; } PSTOF::~PSTOF() @@ -102,11 +198,13 @@ PSTOF::~PSTOF() G4bool PSTOF::ProcessHits(G4Step* aStep, G4TouchableHistory*) { + int DetNumber = PickUpDetectorNumber(aStep, m_VolumeName) ; + G4double TOF = aStep->GetPreStepPoint()->GetGlobalTime(); G4double edep = aStep->GetTotalEnergyDeposit(); - if (edep < 100*keV) return FALSE; + if (edep < TriggerThreshold) return FALSE; G4int index = aStep->GetTrack()->GetTrackID(); - EvtMap->set(index, TOF); + EvtMap->set(index+DetNumber, TOF); return TRUE; } @@ -144,9 +242,10 @@ void PSTOF::PrintAll() //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Interaction coordinates X -PSInteractionCoordinatesX::PSInteractionCoordinatesX(G4String name, G4int depth) +PSInteractionCoordinatesX::PSInteractionCoordinatesX(G4String name, G4String VolumeName, G4int depth) : G4VPrimitiveScorer(name, depth), HCID(-1) { + m_VolumeName = VolumeName; } PSInteractionCoordinatesX::~PSInteractionCoordinatesX() @@ -155,11 +254,13 @@ PSInteractionCoordinatesX::~PSInteractionCoordinatesX() G4bool PSInteractionCoordinatesX::ProcessHits(G4Step* aStep, G4TouchableHistory*) { + int DetNumber = PickUpDetectorNumber(aStep, m_VolumeName) ; + G4ThreeVector POS = aStep->GetPreStepPoint()->GetPosition(); G4double pos_x = POS.x() / mm; G4int index = aStep->GetTrack()->GetTrackID(); - EvtMap->set(index, pos_x); + EvtMap->set(index+DetNumber, pos_x); return TRUE; } @@ -196,9 +297,10 @@ void PSInteractionCoordinatesX::PrintAll() //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Interaction coordinates Y -PSInteractionCoordinatesY::PSInteractionCoordinatesY(G4String name, G4int depth) +PSInteractionCoordinatesY::PSInteractionCoordinatesY(G4String name, G4String VolumeName, G4int depth) : G4VPrimitiveScorer(name, depth), HCID(-1) { + m_VolumeName = VolumeName; } PSInteractionCoordinatesY::~PSInteractionCoordinatesY() @@ -207,16 +309,19 @@ PSInteractionCoordinatesY::~PSInteractionCoordinatesY() G4bool PSInteractionCoordinatesY::ProcessHits(G4Step* aStep, G4TouchableHistory*) { + int DetNumber = PickUpDetectorNumber(aStep, m_VolumeName) ; + G4ThreeVector POS = aStep->GetPreStepPoint()->GetPosition(); G4double pos_y = POS.y() / mm; G4int index = aStep->GetTrack()->GetTrackID(); - EvtMap->set(index, pos_y); + EvtMap->set(index+DetNumber, pos_y); return TRUE; } void PSInteractionCoordinatesY::Initialize(G4HCofThisEvent* HCE) { + EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); if (HCID < 0) { HCID = GetCollectionID(0); @@ -248,9 +353,10 @@ void PSInteractionCoordinatesY::PrintAll() //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Interaction coordinates Z -PSInteractionCoordinatesZ::PSInteractionCoordinatesZ(G4String name, G4int depth) +PSInteractionCoordinatesZ::PSInteractionCoordinatesZ(G4String name, G4String VolumeName, G4int depth) : G4VPrimitiveScorer(name, depth), HCID(-1) { + m_VolumeName = VolumeName; } PSInteractionCoordinatesZ::~PSInteractionCoordinatesZ() @@ -259,11 +365,13 @@ PSInteractionCoordinatesZ::~PSInteractionCoordinatesZ() G4bool PSInteractionCoordinatesZ::ProcessHits(G4Step* aStep, G4TouchableHistory*) { + int DetNumber = PickUpDetectorNumber(aStep, m_VolumeName) ; + G4ThreeVector POS = aStep->GetPreStepPoint()->GetPosition(); G4double pos_z = POS.z() / mm; G4int index = aStep->GetTrack()->GetTrackID(); - EvtMap->set(index, pos_z); + EvtMap->set(index+DetNumber, pos_z); return TRUE; } @@ -301,9 +409,10 @@ void PSInteractionCoordinatesZ::PrintAll() //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Interaction coordinates Angle Theta -PSInteractionCoordinatesAngleTheta::PSInteractionCoordinatesAngleTheta(G4String name, G4int depth) +PSInteractionCoordinatesAngleTheta::PSInteractionCoordinatesAngleTheta(G4String name, G4String VolumeName, G4int depth) : G4VPrimitiveScorer(name, depth), HCID(-1) { + m_VolumeName = VolumeName; } PSInteractionCoordinatesAngleTheta::~PSInteractionCoordinatesAngleTheta() @@ -312,11 +421,13 @@ PSInteractionCoordinatesAngleTheta::~PSInteractionCoordinatesAngleTheta() G4bool PSInteractionCoordinatesAngleTheta::ProcessHits(G4Step* aStep, G4TouchableHistory*) { + int DetNumber = PickUpDetectorNumber(aStep, m_VolumeName) ; + G4ThreeVector POS = aStep->GetPreStepPoint()->GetPosition(); G4double angle_theta = POS.theta() / deg; G4int index = aStep->GetTrack()->GetTrackID(); - EvtMap->set(index, angle_theta); + EvtMap->set(index+DetNumber, angle_theta); return TRUE; } @@ -354,9 +465,10 @@ void PSInteractionCoordinatesAngleTheta::PrintAll() //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Interaction coordinates Angle Phi -PSInteractionCoordinatesAnglePhi::PSInteractionCoordinatesAnglePhi(G4String name, G4int depth) +PSInteractionCoordinatesAnglePhi::PSInteractionCoordinatesAnglePhi(G4String name, G4String VolumeName, G4int depth) : G4VPrimitiveScorer(name, depth), HCID(-1) { + m_VolumeName = VolumeName; } PSInteractionCoordinatesAnglePhi::~PSInteractionCoordinatesAnglePhi() @@ -365,12 +477,14 @@ PSInteractionCoordinatesAnglePhi::~PSInteractionCoordinatesAnglePhi() G4bool PSInteractionCoordinatesAnglePhi::ProcessHits(G4Step* aStep, G4TouchableHistory*) { + int DetNumber = PickUpDetectorNumber(aStep, m_VolumeName) ; + G4ThreeVector POS = aStep->GetPreStepPoint()->GetPosition(); G4double angle_phi = POS.phi() / deg; if (angle_phi < 0) angle_phi += 360; G4int index = aStep->GetTrack()->GetTrackID(); - EvtMap->set(index, angle_phi); + EvtMap->set(index+DetNumber, angle_phi); return TRUE; } @@ -405,77 +519,4 @@ void PSInteractionCoordinatesAnglePhi::PrintAll() G4cout << " Number of entries " << EvtMap->entries() << G4endl ; } -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - //Detector Number Scorer -PSDetectorNumber::PSDetectorNumber(G4String name, G4int depth, G4String VolumeName ) - : G4VPrimitiveScorer(name, depth), HCID(-1) -{ - m_VolumeName = VolumeName; -} - -PSDetectorNumber::~PSDetectorNumber() -{ - ; -} - -G4bool PSDetectorNumber::ProcessHits(G4Step* aStep, G4TouchableHistory*) -{ - std::string name = aStep->GetTrack()->GetVolume()->GetName(); - std::string nbr ; - size_t found; - found=name.find(m_VolumeName); - found = found + m_VolumeName.length(); - - int numberOfCharacterInDetectorNumber = name.length() - (int)found ; - - for(unsigned int i = found ; i < found + numberOfCharacterInDetectorNumber ; i++ ) - nbr += name[i] ; - - G4int DetNbr = atoi( nbr.c_str() ) ; - G4double edep = aStep->GetTotalEnergyDeposit(); - - if (edep < 100*keV) return FALSE; - - G4int index = aStep->GetTrack()->GetTrackID(); - - EvtMap->set(index, DetNbr); - return TRUE; -} -void PSDetectorNumber::Initialize(G4HCofThisEvent* HCE) -{ - EvtMap = new G4THitsMap<G4int>(GetMultiFunctionalDetector()->GetName(), GetName()); - if (HCID < 0) { - HCID = GetCollectionID(0); - } - HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); -} - -void PSDetectorNumber::EndOfEvent(G4HCofThisEvent*) -{ - ; -} - -void PSDetectorNumber::clear() -{ - EvtMap->clear(); -} - -void PSDetectorNumber::DrawAll() -{ - ; -} - -void PSDetectorNumber::PrintAll() -{ - G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl; - G4cout << " PrimitiveScorer " << GetName() << G4endl; - G4cout << " Number of entries " << EvtMap->entries() << G4endl; - std::map<G4int, G4int*>::iterator itr = EvtMap->GetMap()->begin(); - for (; itr != EvtMap->GetMap()->end(); itr++) { - G4cout << " copy no.: " << itr->first - << " energy deposit: " << G4BestUnit(*(itr->second), "Energy") - << G4endl; - } -} diff --git a/NPSimulation/src/MUST2Array.cc b/NPSimulation/src/MUST2Array.cc index 846505d64..5571d5266 100644 --- a/NPSimulation/src/MUST2Array.cc +++ b/NPSimulation/src/MUST2Array.cc @@ -157,10 +157,10 @@ void MUST2Array::VolumeMaker(G4int TelescopeNumber , G4PVPlacement* PVPBuffer ; - G4Trd* solidMM = new G4Trd("MM" + DetectorNumber, 0.5*FaceFront, 0.5*FaceBack, 0.5*FaceFront, 0.5*FaceBack, 0.5*Length); - G4LogicalVolume* logicMM = new G4LogicalVolume(solidMM, m_MaterialIron, "MM" + DetectorNumber, 0, 0, 0) ; + G4Trd* solidMM = new G4Trd("MUST2Telescope" + DetectorNumber, 0.5*FaceFront, 0.5*FaceBack, 0.5*FaceFront, 0.5*FaceBack, 0.5*Length); + G4LogicalVolume* logicMM = new G4LogicalVolume(solidMM, m_MaterialIron, "MUST2Telescope" + DetectorNumber, 0, 0, 0) ; - G4String Name = "MM" + DetectorNumber ; + G4String Name = "MUST2Telescope" + DetectorNumber ; PVPBuffer = new G4PVPlacement(G4Transform3D(*MMrot, MMpos) , @@ -180,7 +180,7 @@ void MUST2Array::VolumeMaker(G4int TelescopeNumber , G4Trd* solidVacBox = new G4Trd("solidVacBox", 0.5*SiliconFace, 0.5*CsIFaceFront, 0.5*SiliconFace, 0.5*CsIFaceFront, 0.5*VacBoxThickness); G4LogicalVolume* logicVacBox = new G4LogicalVolume(solidVacBox, m_MaterialVacuum, "logicVacBox", 0, 0, 0); - PVPBuffer = new G4PVPlacement(0, positionVacBox, logicVacBox, "M" + DetectorNumber + "VacBox", logicMM, false, 0); + PVPBuffer = new G4PVPlacement(0, positionVacBox, logicVacBox, Name + "_VacBox", logicMM, false, 0); logicVacBox->SetVisAttributes(G4VisAttributes::Invisible); @@ -226,8 +226,8 @@ void MUST2Array::VolumeMaker(G4int TelescopeNumber , G4Box* solidAluStrip = new G4Box("AluBox", 0.5*SiliconFace, 0.5*SiliconFace, 0.5*AluStripThickness); G4LogicalVolume* logicAluStrip = new G4LogicalVolume(solidAluStrip, m_MaterialAluminium, "logicAluStrip", 0, 0, 0); - PVPBuffer = new G4PVPlacement(0, positionAluStripFront, logicAluStrip, "M" + DetectorNumber + "AluStripFront", logicMM, false, 0); - PVPBuffer = new G4PVPlacement(0, positionAluStripBack, logicAluStrip, "M" + DetectorNumber + "AluStripBack", logicMM, false, 0); + PVPBuffer = new G4PVPlacement(0, positionAluStripFront, logicAluStrip, Name + "_AluStripFront", logicMM, false, 0); + PVPBuffer = new G4PVPlacement(0, positionAluStripBack, logicAluStrip, Name + "_AluStripBack", logicMM, false, 0); logicAluStrip->SetVisAttributes(G4VisAttributes::Invisible); @@ -236,7 +236,7 @@ void MUST2Array::VolumeMaker(G4int TelescopeNumber , G4Box* solidSilicon = new G4Box("solidSilicon", 0.5*SiliconFace, 0.5*SiliconFace, 0.5*SiliconThickness); G4LogicalVolume* logicSilicon = new G4LogicalVolume(solidSilicon, m_MaterialSilicon, "logicSilicon", 0, 0, 0); - PVPBuffer = new G4PVPlacement(0, positionSilicon, logicSilicon, "M" + DetectorNumber + "Silicon", logicMM, false, 0); + PVPBuffer = new G4PVPlacement(0, positionSilicon, logicSilicon, Name + "_Silicon", logicMM, false, 0); ///Set Silicon strip sensible @@ -261,12 +261,12 @@ void MUST2Array::VolumeMaker(G4int TelescopeNumber , G4Box* solidSiLi = new G4Box("SiLi", 0.5*SiLiFaceX, 0.5*SiLiFaceY, 0.5*SiLiThickness); - G4LogicalVolume* logicSiLi = new G4LogicalVolume(solidSiLi, m_MaterialAluminium, "SiLi" + DetectorNumber, 0, 0, 0); + G4LogicalVolume* logicSiLi = new G4LogicalVolume(solidSiLi, m_MaterialAluminium, Name + "_SiLi" , 0, 0, 0); // First Si(Li) 2 time 4 detectore PVPBuffer = new G4PVPlacement(G4Transform3D(*rotSiLi, positionSiLi) , logicSiLi , - "SiLi" + DetectorNumber , + Name + "_SiLi" , logicVacBox , false , 0); @@ -274,7 +274,7 @@ void MUST2Array::VolumeMaker(G4int TelescopeNumber , // Second Si(Li) 2 time 4 detectore PVPBuffer = new G4PVPlacement(G4Transform3D(*rotSiLi, positionSiLi2) , logicSiLi , - "SiLi" + DetectorNumber , + Name + "_SiLi" , logicVacBox , false , 1); @@ -342,15 +342,15 @@ void MUST2Array::VolumeMaker(G4int TelescopeNumber , -0.5 * SiLi_HighY_Center - 0.5 * interSiLi , 0); - PVPBuffer = new G4PVPlacement(0 , positionSiLi_LT , logicSiLi_LT , "M" + DetectorNumber + "SiLi_LT" , logicSiLi , false , 0) ; - PVPBuffer = new G4PVPlacement(0 , positionSiLi_RT , logicSiLi_RT , "M" + DetectorNumber + "SiLi_RT" , logicSiLi , false , 0) ; - PVPBuffer = new G4PVPlacement(0 , positionSiLi_LC1 , logicSiLi_LC1 , "M" + DetectorNumber + "SiLi_LC1" , logicSiLi , false , 0) ; - PVPBuffer = new G4PVPlacement(0 , positionSiLi_RC1 , logicSiLi_RC1 , "M" + DetectorNumber + "SiLi_RC1" , logicSiLi , false , 0) ; + PVPBuffer = new G4PVPlacement(0 , positionSiLi_LT , logicSiLi_LT , Name + "_SiLi_LT" , logicSiLi , false , 0) ; + PVPBuffer = new G4PVPlacement(0 , positionSiLi_RT , logicSiLi_RT , Name + "_SiLi_RT" , logicSiLi , false , 0) ; + PVPBuffer = new G4PVPlacement(0 , positionSiLi_LC1 , logicSiLi_LC1 , Name + "_SiLi_LC1" , logicSiLi , false , 0) ; + PVPBuffer = new G4PVPlacement(0 , positionSiLi_RC1 , logicSiLi_RC1 , Name + "_SiLi_RC1" , logicSiLi , false , 0) ; - PVPBuffer = new G4PVPlacement(0 , positionSiLi_LB , logicSiLi_LB , "M" + DetectorNumber + "SiLi_LB" , logicSiLi , false , 0) ; - PVPBuffer = new G4PVPlacement(0 , positionSiLi_RB , logicSiLi_RB , "M" + DetectorNumber + "SiLi_RB" , logicSiLi , false , 0) ; - PVPBuffer = new G4PVPlacement(0 , positionSiLi_LC2 , logicSiLi_LC2 , "M" + DetectorNumber + "SiLi_LC2" , logicSiLi , false , 0) ; - PVPBuffer = new G4PVPlacement(0 , positionSiLi_RC2 , logicSiLi_RC2 , "M" + DetectorNumber + "SiLi_RC2" , logicSiLi , false , 0) ; + PVPBuffer = new G4PVPlacement(0 , positionSiLi_LB , logicSiLi_LB , Name + "_SiLi_LB" , logicSiLi , false , 0) ; + PVPBuffer = new G4PVPlacement(0 , positionSiLi_RB , logicSiLi_RB , Name + "_SiLi_RB" , logicSiLi , false , 0) ; + PVPBuffer = new G4PVPlacement(0 , positionSiLi_LC2 , logicSiLi_LC2 , Name + "_SiLi_LC2" , logicSiLi , false , 0) ; + PVPBuffer = new G4PVPlacement(0 , positionSiLi_RC2 , logicSiLi_RC2 , Name + "_SiLi_RC2" , logicSiLi , false , 0) ; logicSiLi->SetVisAttributes(G4VisAttributes(G4Colour(1, 1., 1.))); @@ -386,15 +386,15 @@ void MUST2Array::VolumeMaker(G4int TelescopeNumber , G4ThreeVector positionCsI = G4ThreeVector(0, 0, CsI_PosZ); G4Trd* solidCsI = new G4Trd("csI", 0.5*CsIFaceFront, 0.5*CsIFaceBack, 0.5*CsIFaceFront, 0.5*CsIFaceBack, 0.5*CsIThickness); - G4LogicalVolume* logicCsI = new G4LogicalVolume(solidCsI, m_MaterialAluminium, "CsI" + DetectorNumber, 0, 0, 0); - PVPBuffer = new G4PVPlacement(0, positionCsI, logicCsI, "CsI" + DetectorNumber, logicMM, false, 0); + G4LogicalVolume* logicCsI = new G4LogicalVolume(solidCsI, m_MaterialAluminium, Name + "_CsI_Mylar", 0, 0, 0); + PVPBuffer = new G4PVPlacement(0, positionCsI, logicCsI, Name + "_CsI_Mylar", logicMM, false, 0); G4ThreeVector positionMylarCsI = G4ThreeVector(0, 0, MylarCsIThickness * 0.5 - CsIThickness * 0.5); G4Box* solidMylarCsI = new G4Box("MylarCsIBox", 0.5*CsIFaceFront, 0.5*CsIFaceFront, 0.5*MylarCsIThickness); - G4LogicalVolume* logicMylarCsI = new G4LogicalVolume(solidMylarCsI, m_MaterialMyl, "logicMylarCsI", 0, 0, 0); + G4LogicalVolume* logicMylarCsI = new G4LogicalVolume(solidMylarCsI, m_MaterialMyl, Name + "_CsI_Mylar", 0, 0, 0); - PVPBuffer = new G4PVPlacement(0, positionMylarCsI, logicMylarCsI, "M" + DetectorNumber + "MylarCsI", logicCsI, false, 0); + PVPBuffer = new G4PVPlacement(0, positionMylarCsI, logicMylarCsI, Name + "_CsI_Mylar", logicCsI, false, 0); logicCsI->SetVisAttributes(G4VisAttributes::Invisible); @@ -402,43 +402,43 @@ void MUST2Array::VolumeMaker(G4int TelescopeNumber , // Cristal1 G4Trap* solidCristal1 = new G4Trap("Cristal1", 40.*mm / 2., 6.693896*deg, 41.97814*deg, 33.1*mm / 2., 37.39*mm / 2., 37.39*mm / 2., 0.*deg, 26.9*mm / 2., 30.41*mm / 2., 30.41*mm / 2., 0.*deg); - G4LogicalVolume* logicCristal1 = new G4LogicalVolume(solidCristal1, m_MaterialCsI, "Cristal1", 0, 0, 0); + G4LogicalVolume* logicCristal1 = new G4LogicalVolume(solidCristal1, m_MaterialCsI, Name + "_CsI_Cristal1", 0, 0, 0); // Cristal2 G4Trap* solidCristal2 = new G4Trap("Cristal2", 40.*mm / 2., 17.8836*deg, (74.3122 + 180)*deg, 43.49*mm / 2., 37.39*mm / 2., 37.39*mm / 2., 0.*deg, 31.0377*mm / 2., 30.41*mm / 2., 30.41*mm / 2., 0.*deg); - G4LogicalVolume* logicCristal2 = new G4LogicalVolume(solidCristal2, m_MaterialCsI, "Cristal2", 0, 0, 0); + G4LogicalVolume* logicCristal2 = new G4LogicalVolume(solidCristal2, m_MaterialCsI, Name + "_CsI_Cristal2", 0, 0, 0); // Cristal3 G4Trap* solidCristal3 = new G4Trap("Cristal3", 40.*mm / 2., 18.243*deg, 13.5988*deg, 33.11*mm / 2., 39.25*mm / 2., 39.25*mm / 2., 0.*deg, 26.91*mm / 2., 27.58*mm / 2., 27.58*mm / 2., 0.*deg); - G4LogicalVolume* logicCristal3 = new G4LogicalVolume(solidCristal3, m_MaterialCsI, "Cristal3", 0, 0, 0); + G4LogicalVolume* logicCristal3 = new G4LogicalVolume(solidCristal3, m_MaterialCsI, Name + "_CsI_Cristal3", 0, 0, 0); // Cristal4 G4Trap* solidCristal4 = new G4Trap("Cristal4", 40.*mm / 2., 24.0482*deg, 44.1148*deg, 43.49*mm / 2., 39.19*mm / 2., 39.19*mm / 2., 0.*deg, 31.04*mm / 2., 27.52*mm / 2., 27.52*mm / 2., 0.*deg); - G4LogicalVolume* logicCristal4 = new G4LogicalVolume(solidCristal4, m_MaterialCsI, "Cristal4", 0, 0, 0); + G4LogicalVolume* logicCristal4 = new G4LogicalVolume(solidCristal4, m_MaterialCsI, Name + "_CsI_Cristal4", 0, 0, 0); // Cristal1s G4Trap* solidCristal1s = new G4Trap("Cristal1s", 40.*mm / 2., 6.693896*deg, -41.97814*deg, 33.1*mm / 2., 37.39*mm / 2., 37.39*mm / 2., 0.*deg, 26.9*mm / 2., 30.41*mm / 2., 30.41*mm / 2., 0.*deg); - G4LogicalVolume* logicCristal1s = new G4LogicalVolume(solidCristal1s, m_MaterialCsI, "Cristal1s", 0, 0, 0); + G4LogicalVolume* logicCristal1s = new G4LogicalVolume(solidCristal1s, m_MaterialCsI, Name + "_CsI_Cristal1s", 0, 0, 0); // Cristal2s G4Trap* solidCristal2s = new G4Trap("Cristal2s", 40.*mm / 2., 17.8836*deg, -(74.3122 + 180)*deg, 43.49*mm / 2., 37.39*mm / 2., 37.39*mm / 2., 0.*deg, 31.0377*mm / 2., 30.41*mm / 2., 30.41*mm / 2., 0.*deg); - G4LogicalVolume* logicCristal2s = new G4LogicalVolume(solidCristal2s, m_MaterialCsI, "Cristal2s", 0, 0, 0); + G4LogicalVolume* logicCristal2s = new G4LogicalVolume(solidCristal2s, m_MaterialCsI, Name + "_CsI_Cristal2s", 0, 0, 0); // Cristal3s G4Trap* solidCristal3s = new G4Trap("Cristal3s", 40.*mm / 2., 18.243*deg, -13.5988*deg, 33.11*mm / 2., 39.25*mm / 2., 39.25*mm / 2., 0.*deg, 26.91*mm / 2., 27.58*mm / 2., 27.58*mm / 2., 0.*deg); - G4LogicalVolume* logicCristal3s = new G4LogicalVolume(solidCristal3s, m_MaterialCsI, "Cristal3s", 0, 0, 0); + G4LogicalVolume* logicCristal3s = new G4LogicalVolume(solidCristal3s, m_MaterialCsI, Name + "_CsI_Cristal3s", 0, 0, 0); // Cristal4s G4Trap* solidCristal4s = new G4Trap("Cristal4s", 40.*mm / 2., 24.0482*deg, -44.1148*deg, 43.49*mm / 2., 39.19*mm / 2., 39.19*mm / 2., 0.*deg, 31.04*mm / 2., 27.52*mm / 2., 27.52*mm / 2., 0.*deg); - G4LogicalVolume* logicCristal4s = new G4LogicalVolume(solidCristal4s, m_MaterialCsI, "Cristal4s", 0, 0, 0); + G4LogicalVolume* logicCristal4s = new G4LogicalVolume(solidCristal4s, m_MaterialCsI, Name + "_CsI_Cristal4s", 0, 0, 0); //to see telescope orientation - G4LogicalVolume* logicCristal4sbis = new G4LogicalVolume(solidCristal4s, m_MaterialCsI, "Cristal4s", 0, 0, 0); + G4LogicalVolume* logicCristal4sbis = new G4LogicalVolume(solidCristal4s, m_MaterialCsI, Name + "_CsI_Cristal4s", 0, 0, 0); G4double XEdge1 = 16.96 * mm + DistInterCsI * 0.5; @@ -451,10 +451,10 @@ void MUST2Array::VolumeMaker(G4int TelescopeNumber , G4ThreeVector positionCristal3 = G4ThreeVector(-XEdge2, YEdge1, 0); G4ThreeVector positionCristal4 = G4ThreeVector(-XEdge2, YEdge2, 0); - PVPBuffer = new G4PVPlacement(Rotation(180., 0., 0.), positionCristal1, logicCristal1, "M" + DetectorNumber + "Cristal1", logicCsI, false, 1); - PVPBuffer = new G4PVPlacement(Rotation(180., 0., 180.), positionCristal2, logicCristal2, "M" + DetectorNumber + "Cristal2", logicCsI, false, 2); - PVPBuffer = new G4PVPlacement(Rotation(180., 0., 0.), positionCristal3, logicCristal3, "M" + DetectorNumber + "Cristal3", logicCsI, false, 3); - PVPBuffer = new G4PVPlacement(Rotation(180., 0., 0.), positionCristal4, logicCristal4, "M" + DetectorNumber + "Cristal4", logicCsI, false, 4); + PVPBuffer = new G4PVPlacement(Rotation(180., 0., 0.), positionCristal1, logicCristal1, Name + "_CsI_Cristal1", logicCsI, false, 1); + PVPBuffer = new G4PVPlacement(Rotation(180., 0., 180.), positionCristal2, logicCristal2, Name + "_CsI_Cristal2", logicCsI, false, 2); + PVPBuffer = new G4PVPlacement(Rotation(180., 0., 0.), positionCristal3, logicCristal3, Name + "_CsI_Cristal3", logicCsI, false, 3); + PVPBuffer = new G4PVPlacement(Rotation(180., 0., 0.), positionCristal4, logicCristal4, Name + "_CsI_Cristal4", logicCsI, false, 4); G4ThreeVector positionCristal1b = G4ThreeVector(XEdge1, -YEdge1, 0 * mm); @@ -462,30 +462,30 @@ void MUST2Array::VolumeMaker(G4int TelescopeNumber , G4ThreeVector positionCristal3b = G4ThreeVector(XEdge2, -YEdge1, 0); G4ThreeVector positionCristal4b = G4ThreeVector(XEdge2, -YEdge2, 0); - PVPBuffer = new G4PVPlacement(Rotation(180., 0., 180.), positionCristal1b, logicCristal1, "M" + DetectorNumber + "Cristal5", logicCsI, false, 5); - PVPBuffer = new G4PVPlacement(Rotation(180., 0., 0.), positionCristal2b, logicCristal2, "M" + DetectorNumber + "Cristal6", logicCsI, false, 6); - PVPBuffer = new G4PVPlacement(Rotation(180., 0., 180.), positionCristal3b, logicCristal3, "M" + DetectorNumber + "Cristal7", logicCsI, false, 7); - PVPBuffer = new G4PVPlacement(Rotation(180., 0., 180.), positionCristal4b, logicCristal4, "M" + DetectorNumber + "Cristal8", logicCsI, false, 8); + PVPBuffer = new G4PVPlacement(Rotation(180., 0., 180.), positionCristal1b, logicCristal1, Name + "_CsI_Cristal5", logicCsI, false, 5); + PVPBuffer = new G4PVPlacement(Rotation(180., 0., 0.), positionCristal2b, logicCristal2, Name + "_CsI_Cristal6", logicCsI, false, 6); + PVPBuffer = new G4PVPlacement(Rotation(180., 0., 180.), positionCristal3b, logicCristal3, Name + "_CsI_Cristal7", logicCsI, false, 7); + PVPBuffer = new G4PVPlacement(Rotation(180., 0., 180.), positionCristal4b, logicCristal4, Name + "_CsI_Cristal8", logicCsI, false, 8); G4ThreeVector positionCristal1s = G4ThreeVector(-XEdge1, -YEdge1, 0 * mm); G4ThreeVector positionCristal2s = G4ThreeVector(-XEdge1, -YEdge2, 0); G4ThreeVector positionCristal3s = G4ThreeVector(-XEdge2, -YEdge1, 0); G4ThreeVector positionCristal4s = G4ThreeVector(-XEdge2, -YEdge2, 0); - PVPBuffer = new G4PVPlacement(Rotation(180., 0., 0.), positionCristal1s, logicCristal1s, "M" + DetectorNumber + "Cristal9", logicCsI, false, 9); - PVPBuffer = new G4PVPlacement(Rotation(180., 0., 180.), positionCristal2s, logicCristal2s, "M" + DetectorNumber + "Cristal10", logicCsI, false, 10); - PVPBuffer = new G4PVPlacement(Rotation(180., 0., 0.), positionCristal3s, logicCristal3s, "M" + DetectorNumber + "Cristal11", logicCsI, false, 11); - PVPBuffer = new G4PVPlacement(Rotation(180., 0., 0.), positionCristal4s, logicCristal4sbis, "M" + DetectorNumber + "Cristal12", logicCsI, false, 12); + PVPBuffer = new G4PVPlacement(Rotation(180., 0., 0.), positionCristal1s, logicCristal1s, Name + "_CsI_Cristal9", logicCsI, false, 9); + PVPBuffer = new G4PVPlacement(Rotation(180., 0., 180.), positionCristal2s, logicCristal2s, Name + "_CsI_Cristal10", logicCsI, false, 10); + PVPBuffer = new G4PVPlacement(Rotation(180., 0., 0.), positionCristal3s, logicCristal3s, Name + "_CsI_Cristal11", logicCsI, false, 11); + PVPBuffer = new G4PVPlacement(Rotation(180., 0., 0.), positionCristal4s, logicCristal4sbis, Name + "_CsI_Cristal12", logicCsI, false, 12); G4ThreeVector positionCristal1sb = G4ThreeVector(XEdge1, YEdge1, 0 * mm); G4ThreeVector positionCristal2sb = G4ThreeVector(XEdge1, YEdge2, 0); G4ThreeVector positionCristal3sb = G4ThreeVector(XEdge2, YEdge1, 0); G4ThreeVector positionCristal4sb = G4ThreeVector(XEdge2, YEdge2, 0); - PVPBuffer = new G4PVPlacement(Rotation(180., 0., 180.), positionCristal1sb, logicCristal1s, "M" + DetectorNumber + "Cristal13", logicCsI, false, 13); - PVPBuffer = new G4PVPlacement(Rotation(180, 0, 0), positionCristal2sb, logicCristal2s, "M" + DetectorNumber + "Cristal14", logicCsI, false, 14); - PVPBuffer = new G4PVPlacement(Rotation(180., 0., 180.), positionCristal3sb, logicCristal3s, "M" + DetectorNumber + "Cristal15", logicCsI, false, 15); - PVPBuffer = new G4PVPlacement(Rotation(180., 0., 180.), positionCristal4sb, logicCristal4s, "M" + DetectorNumber + "Cristal16", logicCsI, false, 16); + PVPBuffer = new G4PVPlacement(Rotation(180., 0., 180.), positionCristal1sb, logicCristal1s, Name + "_CsI_Cristal13", logicCsI, false, 13); + PVPBuffer = new G4PVPlacement(Rotation(180, 0, 0), positionCristal2sb, logicCristal2s, Name + "_CsI_Cristal14", logicCsI, false, 14); + PVPBuffer = new G4PVPlacement(Rotation(180., 0., 180.), positionCristal3sb, logicCristal3s, Name + "_CsI_Cristal15", logicCsI, false, 15); + PVPBuffer = new G4PVPlacement(Rotation(180., 0., 180.), positionCristal4sb, logicCristal4s, Name + "_CsI_Cristal16", logicCsI, false, 16); ///Set CsI sensible logicCristal1->SetSensitiveDetector(m_CsIScorer); @@ -958,65 +958,65 @@ void MUST2Array::ReadSensitive(const G4Event* event) // Read the Scorer associate to the Silicon Strip //Detector Number - G4int StripDetCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("StripScorer/DetectorNumber") ; + G4int StripDetCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("MUST2_StripScorer/DetectorNumber") ; DetectorNumberHitMap = (G4THitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripDetCollectionID)) ; DetectorNumber_itr = DetectorNumberHitMap->GetMap()->begin() ; //Energy - G4int StripEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("StripScorer/StripEnergy") ; + G4int StripEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("MUST2_StripScorer/StripEnergy") ; EnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripEnergyCollectionID)) ; Energy_itr = EnergyHitMap->GetMap()->begin() ; //Time of Flight - G4int StripTimeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("StripScorer/StripTime") ; + G4int StripTimeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("MUST2_StripScorer/StripTime") ; TimeHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripTimeCollectionID)) ; Time_itr = TimeHitMap->GetMap()->begin() ; //Strip Number X - G4int StripXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("StripScorer/StripNumberX") ; + G4int StripXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("MUST2_StripScorer/StripNumberX") ; XHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripXCollectionID)) ; X_itr = XHitMap->GetMap()->begin() ; //Strip Number Y - G4int StripYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("StripScorer/StripNumberY") ; + G4int StripYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("MUST2_StripScorer/StripNumberY") ; YHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripYCollectionID)) ; Y_itr = YHitMap->GetMap()->begin() ; //Interaction Coordinate X - G4int InterCoordXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("StripScorer/InterCoordX") ; + G4int InterCoordXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("MUST2_StripScorer/InterCoordX") ; PosXHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordXCollectionID)) ; Pos_X_itr = PosXHitMap->GetMap()->begin() ; //Interaction Coordinate Y - G4int InterCoordYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("StripScorer/InterCoordY") ; + G4int InterCoordYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("MUST2_StripScorer/InterCoordY") ; PosYHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordYCollectionID)) ; Pos_Y_itr = PosYHitMap->GetMap()->begin() ; //Interaction Coordinate Z - G4int InterCoordZCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("StripScorer/InterCoordZ") ; + G4int InterCoordZCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("MUST2_StripScorer/InterCoordZ") ; PosZHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordZCollectionID)) ; Pos_Z_itr = PosXHitMap->GetMap()->begin() ; //Interaction Coordinate Angle Theta - G4int InterCoordAngThetaCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("StripScorer/InterCoordAngTheta") ; + G4int InterCoordAngThetaCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("MUST2_StripScorer/InterCoordAngTheta") ; AngThetaHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngThetaCollectionID)) ; Ang_Theta_itr = AngThetaHitMap->GetMap()->begin() ; //Interaction Coordinate Angle Phi - G4int InterCoordAngPhiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("StripScorer/InterCoordAngPhi") ; + G4int InterCoordAngPhiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("MUST2_StripScorer/InterCoordAngPhi") ; AngPhiHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngPhiCollectionID)) ; Ang_Phi_itr = AngPhiHitMap->GetMap()->begin() ; // Read the Scorer associate to the SiLi //Energy - G4int SiLiEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("SiLiScorer/SiLiEnergy") ; + G4int SiLiEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("MUST2_SiLiScorer/SiLiEnergy") ; SiLiEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(SiLiEnergyCollectionID)) ; SiLiEnergy_itr = SiLiEnergyHitMap->GetMap()->begin() ; // Read the Scorer associate to the CsI crystal //Energy - G4int CsIEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("CsIScorer/CsIEnergy") ; + G4int CsIEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("MUST2_CsIScorer/CsIEnergy") ; CsIEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(CsIEnergyCollectionID)) ; CsIEnergy_itr = CsIEnergyHitMap->GetMap()->begin() ; @@ -1026,55 +1026,55 @@ void MUST2Array::ReadSensitive(const G4Event* event) G4int sizeX = XHitMap->entries() ; G4int sizeY = YHitMap->entries() ; - // Loop on Strip energy - for (G4int l = 0 ; l < sizeE ; l++) { - G4int ETrackID = Energy_itr->first ; - G4double E = *(Energy_itr->second) ; - G4int N = 0 ; + // Loop on Telescope Number entry + for (G4int l = 0 ; l < sizeN ; l++) { + G4int N = *(DetectorNumber_itr->second) ; + G4int NTrackID = DetectorNumber_itr->first - N ; - if (E > 0) { + + if (N > 0) { - m_Event->SetMMStripXEEnergy(RandGauss::shoot(E, ResoStrip)) ; - m_Event->SetMMStripYEEnergy(RandGauss::shoot(E, ResoStrip)) ; - - // Detector Number - DetectorNumber_itr = DetectorNumberHitMap->GetMap()->begin(); - for (G4int h = 0 ; h < sizeN ; h++) { - G4int NTrackID = DetectorNumber_itr->first ; - G4double Nl = *(DetectorNumber_itr->second) ; - - if (NTrackID == ETrackID) { - N = Nl ; - m_Event->SetMMStripXEDetectorNbr(N) ; - m_Event->SetMMStripYEDetectorNbr(N) ; - m_Event->SetMMStripXTDetectorNbr(N) ; - m_Event->SetMMStripYTDetectorNbr(N) ; + m_Event->SetMMStripXEDetectorNbr(N) ; + m_Event->SetMMStripYEDetectorNbr(N) ; + m_Event->SetMMStripXTDetectorNbr(N) ; + m_Event->SetMMStripYTDetectorNbr(N) ; + + // Energy + Energy_itr = EnergyHitMap->GetMap()->begin(); + for (G4int h = 0 ; h < sizeE ; h++) { + G4int ETrackID = Energy_itr->first - N ; + G4double E = *(Energy_itr->second) ; + + if (ETrackID == NTrackID) { + m_Event->SetMMStripXEEnergy(RandGauss::shoot(E, ResoStrip)) ; + m_Event->SetMMStripYEEnergy(RandGauss::shoot(E, ResoStrip)) ; } - else { N = 0 ;} - DetectorNumber_itr++; - } + Energy_itr++; + } // Time Time_itr = TimeHitMap->GetMap()->begin(); for (G4int h = 0 ; h < sizeT ; h++) { - G4int TTrackID = Time_itr->first ; + G4int TTrackID = Time_itr->first - N ; G4double T = *(Time_itr->second) ; - if (TTrackID == ETrackID) { + if (TTrackID == NTrackID) { m_Event->SetMMStripXTTime(RandGauss::shoot(T, ResoTimeMust)) ; m_Event->SetMMStripYTTime(RandGauss::shoot(T, ResoTimeMust)) ; } + Time_itr++; } - // X + + // X X_itr = XHitMap->GetMap()->begin(); for (G4int h = 0 ; h < sizeX ; h++) { - G4int XTrackID = X_itr->first ; + G4int XTrackID = X_itr->first - N ; G4double X = *(X_itr->second) ; - if (XTrackID == ETrackID) { + if (XTrackID == NTrackID) { m_Event->SetMMStripXEStripNbr(X) ; m_Event->SetMMStripXTStripNbr(X) ; } @@ -1085,9 +1085,9 @@ void MUST2Array::ReadSensitive(const G4Event* event) // Y Y_itr = YHitMap->GetMap()->begin() ; for (G4int h = 0 ; h < sizeY ; h++) { - G4int YTrackID = Y_itr->first ; + G4int YTrackID = Y_itr->first - N ; G4double Y = *(Y_itr->second) ; - if (YTrackID == ETrackID) { + if (YTrackID == NTrackID) { m_Event->SetMMStripYEStripNbr(Y) ; m_Event->SetMMStripYTStripNbr(Y) ; } @@ -1098,9 +1098,9 @@ void MUST2Array::ReadSensitive(const G4Event* event) // Pos X Pos_X_itr = PosXHitMap->GetMap()->begin(); for (G4int h = 0 ; h < sizeX ; h++) { - G4int PosXTrackID = Pos_X_itr->first ; + G4int PosXTrackID = Pos_X_itr->first - N ; G4double PosX = *(Pos_X_itr->second) ; - if (PosXTrackID == ETrackID) { + if (PosXTrackID == NTrackID) { ms_InterCoord->SetDetectedPositionX(PosX) ; } Pos_X_itr++; @@ -1109,9 +1109,9 @@ void MUST2Array::ReadSensitive(const G4Event* event) // Pos Y Pos_Y_itr = PosYHitMap->GetMap()->begin(); for (G4int h = 0 ; h < sizeX ; h++) { - G4int PosYTrackID = Pos_Y_itr->first ; + G4int PosYTrackID = Pos_Y_itr->first - N ; G4double PosY = *(Pos_Y_itr->second) ; - if (PosYTrackID == ETrackID) { + if (PosYTrackID == NTrackID) { ms_InterCoord->SetDetectedPositionY(PosY) ; } Pos_Y_itr++; @@ -1120,9 +1120,9 @@ void MUST2Array::ReadSensitive(const G4Event* event) // Pos Z Pos_Z_itr = PosZHitMap->GetMap()->begin(); for (G4int h = 0 ; h < sizeX ; h++) { - G4int PosZTrackID = Pos_Z_itr->first ; + G4int PosZTrackID = Pos_Z_itr->first - N ; G4double PosZ = *(Pos_Z_itr->second) ; - if (PosZTrackID == ETrackID) { + if (PosZTrackID == NTrackID) { ms_InterCoord->SetDetectedPositionZ(PosZ) ; } Pos_Z_itr++; @@ -1131,9 +1131,9 @@ void MUST2Array::ReadSensitive(const G4Event* event) // Angle Theta Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); for (G4int h = 0 ; h < sizeX ; h++) { - G4int AngThetaTrackID = Ang_Theta_itr->first ; + G4int AngThetaTrackID = Ang_Theta_itr->first - N ; G4double AngTheta = *(Ang_Theta_itr->second) ; - if (AngThetaTrackID == ETrackID) { + if (AngThetaTrackID == NTrackID) { ms_InterCoord->SetDetectedAngleTheta(AngTheta) ; } Ang_Theta_itr++; @@ -1142,22 +1142,22 @@ void MUST2Array::ReadSensitive(const G4Event* event) // Angle Phi Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); for (G4int h = 0 ; h < sizeX ; h++) { - G4int AngPhiTrackID = Ang_Phi_itr->first ; + G4int AngPhiTrackID = Ang_Phi_itr->first - N ; G4double AngPhi = *(Ang_Phi_itr->second) ; - if (AngPhiTrackID == ETrackID) { + if (AngPhiTrackID == NTrackID) { ms_InterCoord->SetDetectedAnglePhi(AngPhi) ; } Ang_Phi_itr++; } - // Si(Li) + // Si(Li) SiLiEnergy_itr = SiLiEnergyHitMap->GetMap()->begin() ; for (G4int h = 0 ; h < SiLiEnergyHitMap->entries() ; h++) { - G4int SiLiEnergyTrackID = SiLiEnergy_itr->first ; + G4int SiLiEnergyTrackID = SiLiEnergy_itr->first -N ; G4double SiLiEnergy = *(SiLiEnergy_itr->second) ; - if (SiLiEnergyTrackID == ETrackID) { + if (SiLiEnergyTrackID == NTrackID) { m_Event->SetMMSiLiEEnergy(RandGauss::shoot(SiLiEnergy, ResoSiLi)) ; m_Event->SetMMSiLiEPadNbr(1); m_Event->SetMMSiLiTPadNbr(1); @@ -1170,14 +1170,13 @@ void MUST2Array::ReadSensitive(const G4Event* event) } - // CsI - + // CsI CsIEnergy_itr = CsIEnergyHitMap->GetMap()->begin() ; for (G4int h = 0 ; h < CsIEnergyHitMap->entries() ; h++) { - G4int CsIEnergyTrackID = CsIEnergy_itr->first ; + G4int CsIEnergyTrackID = CsIEnergy_itr->first -N ; G4double CsIEnergy = *(CsIEnergy_itr->second) ; - if (CsIEnergyTrackID == ETrackID) { + if (CsIEnergyTrackID == NTrackID) { m_Event->SetMMCsIEEnergy(RandGauss::shoot(CsIEnergy, ResoCsI*sqrt(CsIEnergy))); m_Event->SetMMCsIECristalNbr(1); m_Event->SetMMCsITCristalNbr(1); @@ -1188,26 +1187,27 @@ void MUST2Array::ReadSensitive(const G4Event* event) CsIEnergy_itr++; } - + + } - Energy_itr++; + DetectorNumber_itr++; } // clear map for next event - DetectorNumberHitMap ->clear(); - EnergyHitMap ->clear() ; - TimeHitMap ->clear() ; - XHitMap ->clear() ; - YHitMap ->clear() ; - CsIEnergyHitMap ->clear() ; - SiLiEnergyHitMap ->clear() ; - PosXHitMap ->clear() ; - PosYHitMap ->clear() ; - PosZHitMap ->clear() ; - AngThetaHitMap ->clear() ; - AngPhiHitMap ->clear() ; + DetectorNumberHitMap ->clear() ; + EnergyHitMap ->clear() ; + TimeHitMap ->clear() ; + XHitMap ->clear() ; + YHitMap ->clear() ; + CsIEnergyHitMap ->clear() ; + SiLiEnergyHitMap ->clear() ; + PosXHitMap ->clear() ; + PosYHitMap ->clear() ; + PosZHitMap ->clear() ; + AngThetaHitMap ->clear() ; + AngPhiHitMap ->clear() ; } @@ -1216,19 +1216,21 @@ void MUST2Array::ReadSensitive(const G4Event* event) void MUST2Array::InitializeScorers() { // Silicon Associate Scorer - m_StripScorer = new G4MultiFunctionalDetector("StripScorer"); + m_StripScorer = new G4MultiFunctionalDetector("MUST2_StripScorer"); + + G4VPrimitiveScorer* DetNbr = new GENERALSCORERS::PSDetectorNumber("DetectorNumber","MUST2Telescope", 0) ; + G4VPrimitiveScorer* Energy = new GENERALSCORERS::PSEnergy("StripEnergy","MUST2Telescope", 0) ; + G4VPrimitiveScorer* TOF = new GENERALSCORERS::PSTOF("StripTime","MUST2Telescope", 0) ; + + G4VPrimitiveScorer* StripPositionX = new PSStripNumberX("StripNumberX", 0, SiliconFace, 128) ; + G4VPrimitiveScorer* StripPositionY = new PSStripNumberY("StripNumberY", 0, SiliconFace, 128) ; + + G4VPrimitiveScorer* InteractionCoordinatesX = new GENERALSCORERS::PSInteractionCoordinatesX("InterCoordX","MUST2Telescope", 0) ; + G4VPrimitiveScorer* InteractionCoordinatesY = new GENERALSCORERS::PSInteractionCoordinatesY("InterCoordY","MUST2Telescope", 0) ; + G4VPrimitiveScorer* InteractionCoordinatesZ = new GENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ","MUST2Telescope", 0) ; + G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new GENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta","MUST2Telescope", 0) ; + G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new GENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi","MUST2Telescope", 0) ; - G4VPrimitiveScorer* DetNbr = new MUST2::PSDetectorNumber("DetectorNumber", 0, "Silicon") ; - G4VPrimitiveScorer* Energy = new PSStripE("StripEnergy", 0) ; - G4VPrimitiveScorer* TOF = new PSTOF("StripTime", 0) ; - G4VPrimitiveScorer* StripPositionX = new PSStripNumberX("StripNumberX", 0, SiliconFace, 128) ; - G4VPrimitiveScorer* StripPositionY = new PSStripNumberY("StripNumberY", 0, SiliconFace, 128) ; - G4VPrimitiveScorer* InteractionCoordinatesX = new PSInteractionCoordinatesX("InterCoordX", 0) ; - G4VPrimitiveScorer* InteractionCoordinatesY = new PSInteractionCoordinatesY("InterCoordY", 0) ; - G4VPrimitiveScorer* InteractionCoordinatesZ = new PSInteractionCoordinatesZ("InterCoordZ", 0) ; - G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new PSInteractionCoordinatesAngleTheta("InterCoordAngTheta", 0) ; - G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new PSInteractionCoordinatesAnglePhi("InterCoordAngPhi", 0) ; - //and register it to the multifunctionnal detector m_StripScorer->RegisterPrimitive(DetNbr) ; @@ -1243,13 +1245,13 @@ void MUST2Array::InitializeScorers() m_StripScorer->RegisterPrimitive(InteractionCoordinatesAnglePhi) ; // SiLi Associate Scorer - m_SiLiScorer = new G4MultiFunctionalDetector("SiLiScorer") ; - G4VPrimitiveScorer* SiLiEnergy = new PSStripE("SiLiEnergy", 0) ; - m_SiLiScorer->RegisterPrimitive(SiLiEnergy) ; + m_SiLiScorer = new G4MultiFunctionalDetector("MUST2_SiLiScorer") ; + G4VPrimitiveScorer* SiLiEnergy = new GENERALSCORERS::PSEnergy("SiLiEnergy","MUST2Telescope", 0) ; + m_SiLiScorer->RegisterPrimitive(SiLiEnergy) ; // CsI Associate Scorer - m_CsIScorer = new G4MultiFunctionalDetector("CsIScorer") ; - G4VPrimitiveScorer* CsIEnergy = new PSStripE("CsIEnergy", 0) ; + m_CsIScorer = new G4MultiFunctionalDetector("MUST2_CsIScorer") ; + G4VPrimitiveScorer* CsIEnergy = new GENERALSCORERS::PSEnergy("CsIEnergy","MUST2Telescope", 0) ; m_CsIScorer->RegisterPrimitive(CsIEnergy) ; // Add All Scorer to the Global Scorer Manager diff --git a/NPSimulation/src/Must2Scorers.cc b/NPSimulation/src/Must2Scorers.cc index 685781f4d..2925a4038 100644 --- a/NPSimulation/src/Must2Scorers.cc +++ b/NPSimulation/src/Must2Scorers.cc @@ -24,6 +24,7 @@ *****************************************************************************/ #include "Must2Scorers.hh" #include "G4UnitsTable.hh" +#include "GeneralScorers.hh" #include <string> using namespace MUST2 ; @@ -35,67 +36,6 @@ using namespace MUST2 ; // 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...... -//Strip Energy Scorer (deal with multiple particle hit) - -PSStripE::PSStripE(G4String name, G4int depth) - : G4VPrimitiveScorer(name, depth), HCID(-1) -{ - ; -} - -PSStripE::~PSStripE() -{ - ; -} - -G4bool PSStripE::ProcessHits(G4Step* aStep, G4TouchableHistory*) -{ - G4double edep = aStep->GetTotalEnergyDeposit(); - if (edep < 100*keV) return FALSE; - G4int index = aStep->GetTrack()->GetTrackID(); - EvtMap->add(index, edep); - return TRUE; -} - -void PSStripE::Initialize(G4HCofThisEvent* HCE) -{ - EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); - if (HCID < 0) { - HCID = GetCollectionID(0); - } - HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); -} - -void PSStripE::EndOfEvent(G4HCofThisEvent*) -{ - ; -} - -void PSStripE::clear() -{ - EvtMap->clear(); -} - -void PSStripE::DrawAll() -{ - ; -} - -void PSStripE::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...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //Strip position Scorer @@ -114,6 +54,8 @@ PSStripNumberX::~PSStripNumberX() G4bool PSStripNumberX::ProcessHits(G4Step* aStep, G4TouchableHistory*) { + int DetNbr = GENERALSCORERS::PickUpDetectorNumber(aStep, "Must2Telescope"); + G4ThreeVector POS = aStep->GetPreStepPoint()->GetPosition(); POS = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(POS); @@ -126,7 +68,7 @@ G4bool PSStripNumberX::ProcessHits(G4Step* aStep, G4TouchableHistory*) G4double edep = aStep->GetTotalEnergyDeposit(); if (edep < 100*keV) return FALSE; G4int index = aStep->GetTrack()->GetTrackID(); - EvtMap->set(index, X); + EvtMap->set(index+DetNbr, X); return TRUE; } @@ -178,6 +120,9 @@ PSStripNumberY::~PSStripNumberY() G4bool PSStripNumberY::ProcessHits(G4Step* aStep, G4TouchableHistory*) { + int DetNbr = GENERALSCORERS::PickUpDetectorNumber(aStep, "Must2Telescope"); + + G4ThreeVector POS = aStep->GetPreStepPoint()->GetPosition(); POS = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(POS); @@ -192,7 +137,7 @@ G4bool PSStripNumberY::ProcessHits(G4Step* aStep, G4TouchableHistory*) G4double edep = aStep->GetTotalEnergyDeposit(); if (edep < 100*keV) return FALSE; G4int index = aStep->GetTrack()->GetTrackID(); - EvtMap->set(index, Y); + EvtMap->set(index+DetNbr, Y); return TRUE; } @@ -226,75 +171,3 @@ void PSStripNumberY::PrintAll() G4cout << " PrimitiveScorer " << GetName() << G4endl ; G4cout << " Number of entries " << EvtMap->entries() << G4endl ; } - -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - //Detector Number Scorer -PSDetectorNumber::PSDetectorNumber(G4String name, G4int depth, G4String VolumeName ) - : G4VPrimitiveScorer(name, depth), HCID(-1) -{ - m_VolumeName = VolumeName; -} - -PSDetectorNumber::~PSDetectorNumber() -{ - ; -} - -G4bool PSDetectorNumber::ProcessHits(G4Step* aStep, G4TouchableHistory*) -{ - std::string name = aStep->GetTrack()->GetVolume()->GetName(); - std::string nbr ; - size_t found; - found=name.find(m_VolumeName); - - int numberOfCharacterInTelescopeNumber = (int)found - 1 ; - - - for( int i = 0 ; i < numberOfCharacterInTelescopeNumber ; i++ ) - nbr += name[i+1] ; - - G4int DetNbr = atof( nbr.c_str() ) ; - G4double edep = aStep->GetTotalEnergyDeposit(); - if (edep < 100*keV) return FALSE; - G4int index = aStep->GetTrack()->GetTrackID(); - EvtMap->set(index, DetNbr); - return TRUE; -} - -void PSDetectorNumber::Initialize(G4HCofThisEvent* HCE) -{ - EvtMap = new G4THitsMap<G4int>(GetMultiFunctionalDetector()->GetName(), GetName()); - if (HCID < 0) { - HCID = GetCollectionID(0); - } - HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); -} - -void PSDetectorNumber::EndOfEvent(G4HCofThisEvent*) -{ - ; -} - -void PSDetectorNumber::clear() -{ - EvtMap->clear(); -} - -void PSDetectorNumber::DrawAll() -{ - ; -} - -void PSDetectorNumber::PrintAll() -{ - G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl; - G4cout << " PrimitiveScorer " << GetName() << G4endl; - G4cout << " Number of entries " << EvtMap->entries() << G4endl; - std::map<G4int, G4int*>::iterator itr = EvtMap->GetMap()->begin(); - for (; itr != EvtMap->GetMap()->end(); itr++) { - G4cout << " copy no.: " << itr->first - << " energy deposit: " << G4BestUnit(*(itr->second), "Energy") - << G4endl; - } -} diff --git a/NPSimulation/src/Plastic.cc b/NPSimulation/src/Plastic.cc index 21005243d..698be1e4f 100644 --- a/NPSimulation/src/Plastic.cc +++ b/NPSimulation/src/Plastic.cc @@ -41,9 +41,9 @@ // NPTool header #include "Plastic.hh" -#include "PlasticScorers.hh" +#include "GeneralScorers.hh" #include "RootOutput.h" -using namespace PLASTIC; +using namespace GENERALSCORERS ; // CLHEP header #include "CLHEP/Random/RandGauss.h" @@ -77,26 +77,27 @@ Plastic::~Plastic() delete m_MaterialPlastic_BC452_2 ; delete m_MaterialPlastic_BC452_5 ; delete m_MaterialPlastic_BC452_10 ; - delete m_MaterialLead ; - delete m_PlasticScorer ; + delete m_MaterialLead ; + delete m_PlasticScorer ; } + //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Plastic::AddPlastic( G4double R , - G4double Theta , - G4double Phi , - G4double PlasticThickness , - G4double PlasticRadius , - G4String Scintillator , - G4double LeadThickness ) +void Plastic::AddPlastic( G4double R , + G4double Theta , + G4double Phi , + G4double PlasticThickness , + G4double PlasticRadius , + G4String Scintillator , + G4double LeadThickness ) { - m_R.push_back(R) ; - m_Theta.push_back(Theta) ; - m_Phi.push_back(Phi) ; - m_PlasticThickness.push_back(PlasticThickness) ; - m_PlasticRadius.push_back(PlasticRadius) ; - m_LeadThickness.push_back(LeadThickness); - m_Scintillator.push_back(Scintillator); + m_R.push_back(R) ; + m_Theta.push_back(Theta) ; + m_Phi.push_back(Phi) ; + m_PlasticThickness.push_back(PlasticThickness) ; + m_PlasticRadius.push_back(PlasticRadius) ; + m_LeadThickness.push_back(LeadThickness) ; + m_Scintillator.push_back(Scintillator) ; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -109,13 +110,13 @@ void Plastic::AddPlastic( G4double R , // Called in DetecorConstruction::ReadDetextorConfiguration Method void Plastic::ReadConfiguration(string Path) { - ifstream ConfigFile ; - ConfigFile.open(Path.c_str()) ; - string LineBuffer ; - string DataBuffer ; + ifstream ConfigFile ; + ConfigFile.open(Path.c_str()) ; + string LineBuffer ; + string DataBuffer ; - G4double Theta = 0 , Phi = 0 , R = 0 , Thickness = 0 , Radius = 0 , LeadThickness = 0; - G4String Scintillator ; + G4double Theta = 0 , Phi = 0 , R = 0 , Thickness = 0 , Radius = 0 , LeadThickness = 0; + G4String Scintillator ; bool check_Theta = false ; bool check_Phi = false ; @@ -309,7 +310,7 @@ void Plastic::VolumeMaker(G4ThreeVector Det_pos, int DetNumber, G4LogicalVolume* 0*deg , 360*deg ); - G4LogicalVolume* logicPlastic = new G4LogicalVolume(solidPlastic, PlasticMaterial, Name, 0, 0, 0); + G4LogicalVolume* logicPlastic = new G4LogicalVolume(solidPlastic, PlasticMaterial, Name+ "_Scintillator", 0, 0, 0); logicPlastic->SetSensitiveDetector(m_PlasticScorer); G4VisAttributes* PlastVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)) ; @@ -320,7 +321,7 @@ void Plastic::VolumeMaker(G4ThreeVector Det_pos, int DetNumber, G4LogicalVolume* PVPBuffer = new G4PVPlacement( 0 , Det_pos , logicPlastic , - Name , + Name + "_Scintillator" , world , false , 0 ); @@ -332,21 +333,21 @@ void Plastic::VolumeMaker(G4ThreeVector Det_pos, int DetNumber, G4LogicalVolume* if(m_LeadThickness[i]>0&& m_PlasticRadius[i]>0) { - G4Tubs* solidLead = new G4Tubs( Name+"Lead" , + G4Tubs* solidLead = new G4Tubs( Name+"_Lead" , 0 , m_PlasticRadius[i] , m_LeadThickness[i]/2 , 0*deg , 360*deg ); - G4LogicalVolume* logicLead = new G4LogicalVolume(solidLead, m_MaterialLead, Name, 0, 0, 0); + G4LogicalVolume* logicLead = new G4LogicalVolume(solidLead, m_MaterialLead, Name+"_Lead", 0, 0, 0); G4VisAttributes* LeadVisAtt = new G4VisAttributes(G4Colour(0.1, 0.1, 0.1)) ; logicLead->SetVisAttributes(LeadVisAtt) ; PVPBuffer = new G4PVPlacement( 0 , Det_pos+(m_PlasticThickness[i]/2+m_LeadThickness[i]/2)*Det_pos.unit() , logicLead , - Name+"Lead" , + Name+"_Lead" , world , false , 0 ); @@ -515,14 +516,14 @@ void Plastic::InitializeScorers() m_PlasticScorer = new G4MultiFunctionalDetector("PlasticScorer") ; G4SDManager::GetSDMpointer()->AddNewDetector(m_PlasticScorer); - G4VPrimitiveScorer* DetNbr = new PSDetectorNumber("PlasticNumber", 0) ; - G4VPrimitiveScorer* Energy = new PSEnergy("Energy", 0) ; - G4VPrimitiveScorer* Time = new PSTOF("Time", 0) ; + G4VPrimitiveScorer* DetNbr = new PSDetectorNumber("PlasticNumber","Plastic", 0) ; + G4VPrimitiveScorer* Energy = new PSEnergy("Energy","Plastic", 0) ; + G4VPrimitiveScorer* Time = new PSTOF("Time","Plastic", 0) ; //and register it to the multifunctionnal detector m_PlasticScorer->RegisterPrimitive(DetNbr) ; m_PlasticScorer->RegisterPrimitive(Energy) ; - m_PlasticScorer->RegisterPrimitive(Time) ; + m_PlasticScorer->RegisterPrimitive(Time) ; } diff --git a/NPSimulation/src/PlasticScorer.cc b/NPSimulation/src/PlasticScorer.cc deleted file mode 100644 index 6e5ab935c..000000000 --- a/NPSimulation/src/PlasticScorer.cc +++ /dev/null @@ -1,240 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2009 this file is part of the NPTool Project * - * * - * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * - * For the list of contributors see $NPTOOL/Licence/Contributors * - *****************************************************************************/ - -/***************************************************************************** - * Original Author: Adrien MATTA contact address: matta@ipno.in2p3.fr * - * * - * Creation Date : September 2009 * - * Last update : * - *---------------------------------------------------------------------------* - * Decription: * - * This class old some of the Platic Scorer. * - *---------------------------------------------------------------------------* - * Comment: * - *****************************************************************************/ -#include "PlasticScorers.hh" -#include "G4UnitsTable.hh" -using namespace PLASTIC; - -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -// Energy Scorer (deal with multiple particle hit) - -PSEnergy::PSEnergy(G4String name, G4int depth) - : G4VPrimitiveScorer(name, depth), HCID(-1) -{ -} - -PSEnergy::~PSEnergy() -{ -} - -G4bool PSEnergy::ProcessHits(G4Step* aStep, G4TouchableHistory*) -{ - std::string name = aStep->GetTrack()->GetVolume()->GetName(); - std::string nbr ; - size_t found; - found=name.find("Plastic"); - found = found + 7; - - int numberOfCharacterInDetectorNumber = name.length() - (int)found ; - - for(unsigned int i = found ; i < found + numberOfCharacterInDetectorNumber ; i++ ) - nbr += name[i] ; - - G4int DetNbr = atoi( nbr.c_str() ) ; - - G4double edep = aStep->GetTotalEnergyDeposit(); - if (edep < 100*keV) return FALSE; - - G4int index = aStep->GetTrack()->GetTrackID(); - - EvtMap->add(DetNbr+index, edep); - return TRUE; -} - -void PSEnergy::Initialize(G4HCofThisEvent* HCE) -{ - EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); - if (HCID < 0) { - HCID = GetCollectionID(0); - } - HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); -} - -void PSEnergy::EndOfEvent(G4HCofThisEvent*) -{ - ; -} - -void PSEnergy::clear() -{ - EvtMap->clear(); -} - -void PSEnergy::DrawAll() -{ - ; -} - -void PSEnergy::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...... -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - //Detector Number Scorer -PSDetectorNumber::PSDetectorNumber(G4String name, G4int depth) - : G4VPrimitiveScorer(name, depth), HCID(-1) -{ -} - -PSDetectorNumber::~PSDetectorNumber() -{ - ; -} - -G4bool PSDetectorNumber::ProcessHits(G4Step* aStep, G4TouchableHistory*) -{ - std::string name = aStep->GetTrack()->GetVolume()->GetName(); - std::string nbr ; - size_t found; - found=name.find("Plastic"); - found = found + 7; - - int numberOfCharacterInDetectorNumber = name.length() - (int)found ; - - for(unsigned int i = found ; i < found + numberOfCharacterInDetectorNumber ; i++ ) - nbr += name[i] ; - - G4int DetNbr = atoi( nbr.c_str() ) ; - G4double edep = aStep->GetTotalEnergyDeposit(); - - if (edep < 100*keV) return FALSE; - - G4int index = aStep->GetTrack()->GetTrackID(); - - EvtMap->set(DetNbr + index, DetNbr); - return TRUE; -} - -void PSDetectorNumber::Initialize(G4HCofThisEvent* HCE) -{ - EvtMap = new G4THitsMap<G4int>(GetMultiFunctionalDetector()->GetName(), GetName()); - if (HCID < 0) { - HCID = GetCollectionID(0); - } - HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); -} - -void PSDetectorNumber::EndOfEvent(G4HCofThisEvent*) -{ - ; -} - -void PSDetectorNumber::clear() -{ - EvtMap->clear(); -} - -void PSDetectorNumber::DrawAll() -{ - ; -} - -void PSDetectorNumber::PrintAll() -{ - G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl; - G4cout << " PrimitiveScorer " << GetName() << G4endl; - G4cout << " Number of entries " << EvtMap->entries() << G4endl; - std::map<G4int, G4int*>::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...... -//TOF Scorer// -PSTOF::PSTOF(G4String name, G4int depth) - : G4VPrimitiveScorer(name, depth), HCID(-1) -{ - ; -} - -PSTOF::~PSTOF() -{ - ; -} - -G4bool PSTOF::ProcessHits(G4Step* aStep, G4TouchableHistory*) -{ - std::string name = aStep->GetTrack()->GetVolume()->GetName(); - std::string nbr ; - size_t found; - found=name.find("Plastic"); - found = found + 7; - - int numberOfCharacterInDetectorNumber = name.length() - (int)found ; - - for(unsigned int i = found ; i < found + numberOfCharacterInDetectorNumber ; i++ ) - nbr += name[i] ; - - G4int DetNbr = atoi( nbr.c_str() ) ; - - - G4double TOF = aStep->GetPreStepPoint()->GetGlobalTime(); - G4double edep = aStep->GetTotalEnergyDeposit(); - if (edep < 100*keV) return FALSE; - G4int index = aStep->GetTrack()->GetTrackID(); - EvtMap->set(DetNbr + index, TOF); - return TRUE; -} - -void PSTOF::Initialize(G4HCofThisEvent* HCE) -{ - EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), - GetName()); - if (HCID < 0) { - HCID = GetCollectionID(0); - } - HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); -} - -void PSTOF::EndOfEvent(G4HCofThisEvent*) -{ - ; -} - -void PSTOF::clear() -{ - EvtMap->clear(); -} - -void PSTOF::DrawAll() -{ - ; -} - -void PSTOF::PrintAll() -{ - G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl ; - G4cout << " PrimitiveScorer " << GetName() << G4endl ; - G4cout << " Number of entries " << EvtMap->entries() << G4endl ; -} diff --git a/NPSimulation/src/ThinSi.cc b/NPSimulation/src/ThinSi.cc index 94a2313ad..e03aeaf94 100644 --- a/NPSimulation/src/ThinSi.cc +++ b/NPSimulation/src/ThinSi.cc @@ -173,8 +173,8 @@ void ThinSi::VolumeMaker( G4int DetNumber , 0); // Frame is made of 4 thick box (2 Horizontal and 2 Vertical) - G4Box* solidFrameHorizontal = new G4Box(Name + "Frame", 0.5*SiliconSize, 0.5*(DetectorSize - SiliconSize) / 2, 0.5*FrameThickness*mm) ; - G4Box* solidFrameVertical = new G4Box(Name + "Frame", 0.5*(DetectorSize - SiliconSize) / 2, 0.5*DetectorSize, 0.5*FrameThickness*mm) ; + G4Box* solidFrameHorizontal = new G4Box(Name + "_Frame", 0.5*SiliconSize, 0.5*(DetectorSize - SiliconSize) / 2, 0.5*FrameThickness*mm) ; + G4Box* solidFrameVertical = new G4Box(Name + "_Frame", 0.5*(DetectorSize - SiliconSize) / 2, 0.5*DetectorSize, 0.5*FrameThickness*mm) ; G4LogicalVolume* logicFrameHorizontal = new G4LogicalVolume(solidFrameHorizontal, Al, Name, 0, 0); @@ -192,7 +192,7 @@ void ThinSi::VolumeMaker( G4int DetNumber , new G4PVPlacement(0 , FrameTopPosition , logicFrameHorizontal , - Name + "Frame" , + Name + "_Frame" , logicThinSi , false , 0); @@ -201,7 +201,7 @@ void ThinSi::VolumeMaker( G4int DetNumber , new G4PVPlacement(0 , FrameBottomPosition , logicFrameHorizontal , - Name + "Frame" , + Name + "_Frame" , logicThinSi , false , 0); @@ -210,7 +210,7 @@ void ThinSi::VolumeMaker( G4int DetNumber , new G4PVPlacement(0 , FrameLeftPosition , logicFrameVertical , - Name + "Frame" , + Name + "_Frame" , logicThinSi , false , 0); @@ -219,7 +219,7 @@ void ThinSi::VolumeMaker( G4int DetNumber , new G4PVPlacement(0 , FrameRightPosition , logicFrameVertical , - Name + "Frame" , + Name + "_Frame" , logicThinSi , false , 0); @@ -236,10 +236,10 @@ void ThinSi::VolumeMaker( G4int DetNumber , new G4LogicalVolume(solidAlu, Al, "logicAlu", 0, 0, 0) ; PVPBuffer = - new G4PVPlacement(0 , posAluFront , logicAlu , Name + "AluFront" , logicThinSi , true, 0) ; + new G4PVPlacement(0 , posAluFront , logicAlu , Name + "_AluFront" , logicThinSi , true, 0) ; PVPBuffer = - new G4PVPlacement(0 , posAluBack , logicAlu , Name + "AluBack" , logicThinSi , true, 0) ; + new G4PVPlacement(0 , posAluBack , logicAlu , Name + "_AluBack" , logicThinSi , true, 0) ; G4Box* solidSi = @@ -249,23 +249,10 @@ void ThinSi::VolumeMaker( G4int DetNumber , new G4LogicalVolume(solidSi, Silicon, "logicSi", 0, 0, 0) ; PVPBuffer = - new G4PVPlacement(0, posSi, logicSi, Name + "Si", logicThinSi, true, 0) ; + new G4PVPlacement(0, posSi, logicSi, Name + "_Si", logicThinSi, true, 0) ; - //Set Add. Silicon strip sensible - //instantiate a new scorer - G4MultiFunctionalDetector* ThinSiScorer = new G4MultiFunctionalDetector("ThinSi" + DetectorNumber); //attach it to the Silicon plate - logicSi ->SetSensitiveDetector(ThinSiScorer); - //and declare it to the SDManager - G4SDManager::GetSDMpointer()->AddNewDetector(ThinSiScorer); - - //instantiate primitive scorer - G4VPrimitiveScorer* ThinSiEnergy ; - - //create primitive scorer - ThinSiEnergy = new MUST2::PSStripE("StripEnergy", 0) ; - //and register it to the multifunctionnal detector - ThinSiScorer->RegisterPrimitive(ThinSiEnergy) ; + logicSi ->SetSensitiveDetector(m_StripScorer); } @@ -597,38 +584,102 @@ void ThinSi::ReadSensitive(const G4Event* event) ////////////////////////////////////////////////////////////////////////////////////// // Si - std::map<G4int, G4double*>::iterator Energy_itr ; - G4THitsMap<G4double>* EnergyHitMap ; - - + G4THitsMap<G4int>* DetNbrHitMap ; + G4THitsMap<G4double>* EnergyHitMap ; + G4THitsMap<G4double>* TimeHitMap ; + std::map<G4int, G4int*>::iterator DetNbr_itr ; + std::map<G4int, G4double*>::iterator Energy_itr ; + std::map<G4int, G4double*>::iterator Time_itr ; ////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// + // Read the Scorer associate to the Silicon Strip - G4int NumberOfDetector = m_DefinitionType.size() ; - for (G4int i = 0 ; i < NumberOfDetector ; i++) { - G4int k = i + 1; - ostringstream buffer; - buffer << k; - DetectorNumber = buffer.str(); + //DetectorNumber + G4int StripDetNbrCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ThinSi_StripScorer/DetectorNumber") ; + DetNbrHitMap = (G4THitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripDetNbrCollectionID)) ; + DetNbr_itr = DetNbrHitMap->GetMap()->begin() ; - // Read the Scorer associate to the Silicon Strip //Energy - G4int StripEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ThinSi" + DetectorNumber + "/StripEnergy") ; + G4int StripEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ThinSi_StripScorer/StripEnergy") ; EnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripEnergyCollectionID)) ; - Energy_itr = EnergyHitMap->GetMap()->begin() ; + Energy_itr = EnergyHitMap->GetMap()->begin() ; + + //Time + G4int StripTimeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ThinSi_StripScorer/StripTime") ; + TimeHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripTimeCollectionID)) ; + Time_itr = TimeHitMap->GetMap()->begin() ; + + G4int sizeN = DetNbrHitMap->entries() ; + G4int sizeE = EnergyHitMap->entries() ; + G4int sizeT = TimeHitMap->entries() ; + + // Loop on Plastic Number + for (G4int l = 0 ; l < sizeN ; l++) + { + G4int N = *(DetNbr_itr->second) ; + G4int NTrackID = DetNbr_itr->first - N ; + + + if (N > 0) + { + + // Energy + Energy_itr = EnergyHitMap->GetMap()->begin(); + for (G4int h = 0 ; h < sizeE ; h++) { + G4int ETrackID = Energy_itr->first - N ; + G4double E = *(Energy_itr->second) ; + + if (ETrackID == NTrackID) { + m_Energy=RandGauss::shoot(E, ResoEnergy ) ; + } + + Energy_itr++; + } + + + // Time + Time_itr = TimeHitMap->GetMap()->begin(); + for (G4int h = 0 ; h < sizeT ; h++) { + G4int TTrackID = Time_itr->first - N ; + G4double T = *(Time_itr->second) ; + + if (TTrackID == NTrackID) { + /*m_Event->SetTime(RandGauss::shoot(T, ResoTime))*/ ; + } + + Time_itr++; + } + + } + + DetNbr_itr++; + } + + // clear map for next event + TimeHitMap ->clear() ; + DetNbrHitMap ->clear() ; + EnergyHitMap ->clear() ; +} - // Loop on Strip energy - for (G4int l = 0 ; l < EnergyHitMap->entries() ; l++) { - //G4int ETrackID = Energy_itr->first ; - G4double E = *(Energy_itr->second) ; - if (E > 0) { - m_Energy = RandGauss::shoot(E, ResoEnergy); - } +void ThinSi::InitializeScorers() + { + + // Silicon Associate Scorer + m_StripScorer = new G4MultiFunctionalDetector("ThinSi_StripScorer"); + + G4VPrimitiveScorer* DetNbr = new GENERALSCORERS::PSDetectorNumber("DetectorNumber","ThinSi_", 0) ; + G4VPrimitiveScorer* Energy = new GENERALSCORERS::PSEnergy("StripEnergy","ThinSi_", 0) ; + G4VPrimitiveScorer* TOF = new GENERALSCORERS::PSTOF("StripTime","ThinSi_", 0) ; + + + //and register it to the multifunctionnal detector + m_StripScorer->RegisterPrimitive(DetNbr) ; + m_StripScorer->RegisterPrimitive(Energy) ; + m_StripScorer->RegisterPrimitive(TOF) ; + + // Add All Scorer to the Global Scorer Manager + G4SDManager::GetSDMpointer()->AddNewDetector(m_StripScorer) ; + } - } - // clear map for next event - EnergyHitMap ->clear() ; - } -} diff --git a/NPSimulation/src/VEventGenerator.cc b/NPSimulation/src/VEventGenerator.cc index 6ab94ebb3..10f6183e0 100644 --- a/NPSimulation/src/VEventGenerator.cc +++ b/NPSimulation/src/VEventGenerator.cc @@ -53,52 +53,70 @@ void VEventGenerator::CalculateBeamInteraction(double MeanPosX, double SigmaPosX G4ThreeVector &InterCoord, double &AngleEmittanceTheta, double &AngleEmittancePhi, double &AngleIncidentTheta, double &AngleIncidentPhi) { - // target parameters - double TargetThickness = target->GetTargetThickness(); - double TargetRadius = target->GetTargetRadius(); - double TargetAngle = target->GetTargetAngle(); - - // beam interaction parameters - double x0 = 1000 * cm; - double y0 = 1000 * cm; - double z0 = 0 * cm; - double dz = 0 * cm; - - // calculate emittance parameters (x,theta) and (y,phi) - if (TargetRadius != 0) { // case of finite target dimensions - while (sqrt(x0*x0 + y0*y0) > TargetRadius) { - RandomGaussian2D(MeanPosX, MeanPosTheta, SigmaPosX, SigmaPosTheta, x0, AngleEmittanceTheta); - RandomGaussian2D(MeanPosY, MeanPosPhi, SigmaPosY, SigmaPosPhi, y0, AngleEmittancePhi); - } - // in case target is tilted, correct the z-position of interaction - dz = x0 * tan(TargetAngle); - } - else { // if no target radius is given consider a point-like target - RandomGaussian2D(0, 0, 0, SigmaPosTheta, x0, AngleEmittanceTheta); - RandomGaussian2D(0, 0, 0, SigmaPosPhi, y0, AngleEmittancePhi); - } - // correct for the target angle wrt the beam axis - // this simple correction is only valid if the beam is parallel to the beam axis - // should be improved in a next version - TargetThickness /= cos(TargetAngle); - z0 = dz + (-TargetThickness / 2 + RandFlat::shoot() * TargetThickness); - - // Move to the target position - x0 += target->GetTargetX(); - y0 += target->GetTargetY(); - z0 += target->GetTargetZ(); - InterCoord = G4ThreeVector(x0, y0, z0); - - // Calculate incident angle in spherical coordinate, passing by the direction vector dir - double Xdir = sin(AngleEmittanceTheta); - double Ydir = sin(AngleEmittancePhi); - double Zdir = cos(AngleEmittanceTheta) + cos(AngleEmittancePhi); - - AngleIncidentTheta = acos(Zdir / sqrt(Xdir*Xdir + Ydir*Ydir + Zdir*Zdir)) * rad; - AngleIncidentPhi = atan2(Ydir, Xdir) * rad; - if (AngleIncidentPhi < 0) AngleIncidentPhi += 2*pi; - if (AngleIncidentTheta < 1e-6) AngleIncidentPhi = 0; + if(target!=0) + { + // target parameters + double TargetThickness = target->GetTargetThickness(); + double TargetRadius = target->GetTargetRadius(); + double TargetAngle = target->GetTargetAngle(); + + // beam interaction parameters + double x0 = 1000 * cm; + double y0 = 1000 * cm; + double z0 = 0 * cm; + double dz = 0 * cm; + + // calculate emittance parameters (x,theta) and (y,phi) + if (TargetRadius != 0) { // case of finite target dimensions + while (sqrt(x0*x0 + y0*y0) > TargetRadius) { + RandomGaussian2D(MeanPosX, MeanPosTheta, SigmaPosX, SigmaPosTheta, x0, AngleEmittanceTheta); + RandomGaussian2D(MeanPosY, MeanPosPhi, SigmaPosY, SigmaPosPhi, y0, AngleEmittancePhi); + } + // in case target is tilted, correct the z-position of interaction + dz = x0 * tan(TargetAngle); + } + else { // if no target radius is given consider a point-like target + RandomGaussian2D(0, 0, 0, SigmaPosTheta, x0, AngleEmittanceTheta); + RandomGaussian2D(0, 0, 0, SigmaPosPhi, y0, AngleEmittancePhi); + } + + // correct for the target angle wrt the beam axis + // this simple correction is only valid if the beam is parallel to the beam axis + // should be improved in a next version + TargetThickness /= cos(TargetAngle); + z0 = dz + (-TargetThickness / 2 + RandFlat::shoot() * TargetThickness); + + // Move to the target position + x0 += target->GetTargetX(); + y0 += target->GetTargetY(); + z0 += target->GetTargetZ(); + InterCoord = G4ThreeVector(x0, y0, z0); + + // Calculate incident angle in spherical coordinate, passing by the direction vector dir + double Xdir = sin(AngleEmittanceTheta); + double Ydir = sin(AngleEmittancePhi); + double Zdir = cos(AngleEmittanceTheta) + cos(AngleEmittancePhi); + + AngleIncidentTheta = acos(Zdir / sqrt(Xdir*Xdir + Ydir*Ydir + Zdir*Zdir)) * rad; + AngleIncidentPhi = atan2(Ydir, Xdir) * rad; + if (AngleIncidentPhi < 0) AngleIncidentPhi += 2*pi; + if (AngleIncidentTheta < 1e-6) AngleIncidentPhi = 0; + + } + + else{ + + + InterCoord = G4ThreeVector(0, 0, 0); + AngleEmittanceTheta=0; + AngleEmittancePhi=0; + AngleIncidentTheta=0; + AngleIncidentPhi=0; + + } + + } -- GitLab