From 39889cec5ffbd2fe64ab1557ee15a0f9c2fd7359 Mon Sep 17 00:00:00 2001 From: matta <matta@npt> Date: Wed, 6 Feb 2013 16:04:16 +0000 Subject: [PATCH] * Sharc scorer compile --- NPSimulation/include/SharcScorers.hh | 9 +++++-- NPSimulation/src/SharcScorers.cc | 35 +++++++++++++++++----------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/NPSimulation/include/SharcScorers.hh b/NPSimulation/include/SharcScorers.hh index 1d8a3f255..98aa7d3ef 100644 --- a/NPSimulation/include/SharcScorers.hh +++ b/NPSimulation/include/SharcScorers.hh @@ -34,7 +34,7 @@ namespace SHARC { class PS_Silicon_Rectangle : public G4VPrimitiveScorer{ public: // with description - PS_Silicon_Rectangle(G4String name, G4double StripPlaneLength, G4double StripPlaneWidth, G4int NumberOfStripLength,G4int NumberOfStripWidth,G4int depth); + PS_Silicon_Rectangle(G4String name, G4double StripPlaneLength, G4double StripPlaneWidth, G4int NumberOfStripLength,G4int NumberOfStripWidth,G4double TriggerThreshold,G4int depth=0); virtual ~PS_Silicon_Rectangle(); protected: // with description @@ -46,6 +46,9 @@ namespace SHARC { virtual void clear(); virtual void DrawAll(); virtual void PrintAll(); + + private: // Threshold + G4double m_TriggerThreshold; private: // Geometry of the detector G4double m_StripPlaneLength; @@ -57,13 +60,15 @@ namespace SHARC { private: // inherited from G4VPrimitiveScorer G4int HCID; - G4THitsMap<G4int>* EvtMap; + G4THitsMap<G4double*>* EvtMap; private: // Needed for intermediate calculation (avoid multiple instantiation in Processing Hit) G4ThreeVector m_Position ; G4int m_DetectorNumber ; G4int m_StripLengthNumber ; G4int m_StripWidthNumber ; + G4int m_Index ; + }; } diff --git a/NPSimulation/src/SharcScorers.cc b/NPSimulation/src/SharcScorers.cc index 6fffecf08..243700fe9 100644 --- a/NPSimulation/src/SharcScorers.cc +++ b/NPSimulation/src/SharcScorers.cc @@ -24,8 +24,8 @@ using namespace SHARC ; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -PS_Silicon_Rectangle::PS_Silicon_Rectangle(G4String name, G4double StripPlaneLength, G4double StripPlaneWidth, G4int NumberOfStripLength,G4int NumberOfStripWidth,G4int depth) -:G4VPrimitiveScorer(name, depth), HCID(-1){ +PS_Silicon_Rectangle::PS_Silicon_Rectangle(G4String name, G4double StripPlaneLength, G4double StripPlaneWidth, G4int NumberOfStripLength,G4int NumberOfStripWidth,G4double TriggerThreshold,G4int depth) +:G4VPrimitiveScorer(name, depth), m_TriggerThreshold(TriggerThreshold),HCID(-1){ m_StripPlaneLength = StripPlaneLength; m_StripPlaneWidth = StripPlaneWidth; m_NumberOfStripLength = NumberOfStripLength; @@ -37,6 +37,7 @@ PS_Silicon_Rectangle::PS_Silicon_Rectangle(G4String name, G4double StripPlaneLen m_DetectorNumber = -1; m_StripLengthNumber = -1; m_StripWidthNumber = -1; + m_Index = -1 ; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -45,32 +46,38 @@ PS_Silicon_Rectangle::~PS_Silicon_Rectangle(){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4bool PS_Silicon_Rectangle::ProcessHits(G4Step* aStep, G4TouchableHistory*){ - + G4double* EnergyAndTime = new G4double[2]; + + EnergyAndTime[0] = aStep->GetTotalEnergyDeposit(); + + // If the energy deposit is below the threshold, the deposit is ignored + if (EnergyAndTime[0] < m_TriggerThreshold){ + delete EnergyAndTime; + return FALSE; + } + + EnergyAndTime[1] = aStep->GetPreStepPoint()->GetGlobalTime(); + m_DetectorNumber = aStep->GetPreStepPoint()->GetTouchableHandle()->GetCopyNumber(0); m_Position = aStep->GetPreStepPoint()->GetPosition(); - m_Position = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(POS); + m_Position = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(m_Position); m_StripLengthNumber = (int)((m_Position(1) + m_StripPlaneLength / 2.) / m_StripPitchLength ) + 1 ; m_StripWidthNumber = (int)((m_Position(2) + m_StripPlaneWidth / 2.) / m_StripPitchWidth ) + 1 ; //Rare case where particle is close to edge of silicon plan if (m_StripLengthNumber == m_NumberOfStripLength+1) m_StripLengthNumber = m_StripLengthNumber; - if (m_StripWidthNumber == m_NumberOfStripWidth+1) m_StripWidthhNumber = m_StripWidthNumber; - - G4double[2] EnergyAndTime; + if (m_StripWidthNumber == m_NumberOfStripWidth+1) m_StripWidthNumber = m_StripWidthNumber; - EnergyAndTime[0] = aStep->GetTotalEnergyDeposit(); - EnergyAndTime[1] = aStep->GetPreStepPoint()->GetGlobalTime();; - - if (edep < TriggerThreshold) return FALSE; - G4int index = aStep->GetTrack()->GetTrackID(); - EvtMap->set(index+DetNbr, X); + m_Index = aStep->GetTrack()->GetTrackID() + m_DetectorNumber * 1e3 + m_StripLengthNumber * 1e6 + m_StripWidthNumber * 1e9; + EvtMap->set(m_Index, EnergyAndTime); return TRUE; + } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void PS_Silicon_Rectangle::Initialize(G4HCofThisEvent* HCE){ - EvtMap = new G4THitsMap<G4int>(GetMultiFunctionalDetector()->GetName(), GetName()); + EvtMap = new G4THitsMap<G4double*>(GetMultiFunctionalDetector()->GetName(), GetName()); if (HCID < 0) { HCID = GetCollectionID(0); } -- GitLab