diff --git a/NPSimulation/Detectors/Helios/Helios.cc b/NPSimulation/Detectors/Helios/Helios.cc index 0adfb7800c17f5475f85a0ea08ce229a5622322b..b17fa7ec91ee14bef6e80d0a6f0106035a7bb826 100644 --- a/NPSimulation/Detectors/Helios/Helios.cc +++ b/NPSimulation/Detectors/Helios/Helios.cc @@ -352,7 +352,7 @@ void Helios::InitializeScorers() { // Otherwise the scorer is initialised G4VPrimitiveScorer* Resistive = - new DSSDScorers::PS_Resistive("Resistive", 1, Helios_NS::WaferLength, Helios_NS::WaferWidth, 1); + new DSSDScorers::PS_Resistive("Resistive", "z", 1, Helios_NS::WaferLength, Helios_NS::WaferWidth, 1); // and register it to the multifunctionnal detector m_HeliosScorer->RegisterPrimitive(Resistive); G4VPrimitiveScorer* Inter = new InteractionScorers::PS_Interactions("Resistive", ms_InterCoord, 1); diff --git a/NPSimulation/Detectors/SuperX3/SuperX3.cc b/NPSimulation/Detectors/SuperX3/SuperX3.cc index 2be046a1297b1149f1e765cd035c3d584f37822b..a571962c06fc605914d8617be676f079b2e68bef 100644 --- a/NPSimulation/Detectors/SuperX3/SuperX3.cc +++ b/NPSimulation/Detectors/SuperX3/SuperX3.cc @@ -338,9 +338,9 @@ void SuperX3::InitializeScorers() { //..... resistive starts.. G4VPrimitiveScorer* resistivestrip = - new DSSDScorers::PS_Resistive("resistivestrip", 1, SiliconFaceLength, SiliconFaceWidth, NbStrips); + new DSSDScorers::PS_Resistive("resistivestrip", "y", 0, SiliconFaceLength, SiliconFaceWidth, NbStrips, 0); G4VPrimitiveScorer* backstrip = - new DSSDScorers::PS_Rectangle("backstrip", 1, SiliconFaceLength, SiliconFaceWidth, 4, 1); + new DSSDScorers::PS_Rectangle("backstrip", 0, SiliconFaceLength, SiliconFaceWidth, 4, 1, 0); G4VPrimitiveScorer* interaction = new InteractionScorers::PS_Interactions("Interaction", ms_InterCoord, 0); //... resistive ends...... diff --git a/NPSimulation/Scorers/DSSDScorers.cc b/NPSimulation/Scorers/DSSDScorers.cc index 0e085c023b39ee000e03f0fc431f86af6546b403..dde7e5ad619559fa30219068325483435688404a 100644 --- a/NPSimulation/Scorers/DSSDScorers.cc +++ b/NPSimulation/Scorers/DSSDScorers.cc @@ -21,22 +21,23 @@ *****************************************************************************/ #include "DSSDScorers.hh" #include "G4UnitsTable.hh" -using namespace DSSDScorers ; -vector<DSSDData>::iterator DSSDDataVector::find(const unsigned int& index){ - for(vector<DSSDData>::iterator it= m_Data.begin() ; it !=m_Data.end() ; it++){ - if((*it).GetIndex()==index) +using namespace DSSDScorers; +vector<DSSDData>::iterator DSSDDataVector::find(const unsigned int& index) { + for (vector<DSSDData>::iterator it = m_Data.begin(); it != m_Data.end(); it++) { + if ((*it).GetIndex() == index) return it; } return m_Data.end(); } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -PS_Images::PS_Images(G4String name, string imageFront,string imageBack,double scalingFront, double scalingBack, double centerOffsetX,double centerOffsetY,unsigned int ignoreValue, G4int depth) :G4VPrimitiveScorer(name, depth){ - m_ImageFront = new NPL::Image(imageFront,scalingFront,scalingFront); - m_ImageBack = new NPL::Image(imageBack,scalingBack,scalingBack); +PS_Images::PS_Images(G4String name, string imageFront, string imageBack, double scalingFront, double scalingBack, + double centerOffsetX, double centerOffsetY, unsigned int ignoreValue, G4int depth) + : G4VPrimitiveScorer(name, depth) { + m_ImageFront = new NPL::Image(imageFront, scalingFront, scalingFront); + m_ImageBack = new NPL::Image(imageBack, scalingBack, scalingBack); m_ScalingFront = scalingFront; - m_ScalingBack = scalingBack; + m_ScalingBack = scalingBack; m_CenterOffsetX = centerOffsetX; m_CenterOffsetY = centerOffsetY; m_IgnoreValue = ignoreValue; @@ -44,210 +45,199 @@ PS_Images::PS_Images(G4String name, string imageFront,string imageBack,double sc } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4bool PS_Images::ProcessHits(G4Step* aStep, G4TouchableHistory*){ +G4bool PS_Images::ProcessHits(G4Step* aStep, G4TouchableHistory*) { // contain Energy Time, DetNbr, PixelFront and PixelBack t_Energy = aStep->GetTotalEnergyDeposit(); t_Time = aStep->GetPreStepPoint()->GetGlobalTime(); t_DetectorNbr = aStep->GetPreStepPoint()->GetTouchableHandle()->GetCopyNumber(m_Level); - t_Position = aStep->GetPreStepPoint()->GetPosition(); + t_Position = aStep->GetPreStepPoint()->GetPosition(); // transforming the position to the local volume - t_Position = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(t_Position); - t_PixelFront = m_ImageFront->GetPixelAtCoordinate(t_Position.x(),t_Position.y()); - t_PixelBack = m_ImageBack->GetPixelAtCoordinate(t_Position.x(),t_Position.y()); + t_Position = + aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(t_Position); + t_PixelFront = m_ImageFront->GetPixelAtCoordinate(t_Position.x(), t_Position.y()); + t_PixelBack = m_ImageBack->GetPixelAtCoordinate(t_Position.x(), t_Position.y()); // If front and back are in inactive part of the wafer, // nothing is added to the unordered_map - if(t_PixelFront == m_IgnoreValue && t_PixelBack == m_IgnoreValue) + if (t_PixelFront == m_IgnoreValue && t_PixelBack == m_IgnoreValue) return FALSE; - // Check if the particle has interact before, if yes, add up the energies. - vector<DSSDData>::iterator it; - - it= m_HitFront.find(DSSDData::CalculateIndex(t_PixelFront,t_DetectorNbr)); - if(it!=m_HitFront.end()){ + vector<DSSDData>::iterator it; + + it = m_HitFront.find(DSSDData::CalculateIndex(t_PixelFront, t_DetectorNbr)); + if (it != m_HitFront.end()) { it->Add(t_Energy); } - else{ - m_HitFront.Set(t_Energy,t_Time,t_PixelFront,t_DetectorNbr); + else { + m_HitFront.Set(t_Energy, t_Time, t_PixelFront, t_DetectorNbr); } // Check if the particle has interact before, if yes, add up the energies. - it= m_HitBack.find(DSSDData::CalculateIndex(t_PixelBack,t_DetectorNbr)); - if(it!=m_HitBack.end()){ + it = m_HitBack.find(DSSDData::CalculateIndex(t_PixelBack, t_DetectorNbr)); + if (it != m_HitBack.end()) { it->Add(t_Energy); } - else{ - m_HitBack.Set(t_Energy,t_Time,t_PixelBack,t_DetectorNbr); + else { + m_HitBack.Set(t_Energy, t_Time, t_PixelBack, t_DetectorNbr); } return TRUE; - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Images::Initialize(G4HCofThisEvent*){ - clear(); -} +void PS_Images::Initialize(G4HCofThisEvent*) { clear(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Images::EndOfEvent(G4HCofThisEvent*){ -} +void PS_Images::EndOfEvent(G4HCofThisEvent*) {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Images::clear(){ +void PS_Images::clear() { m_HitFront.clear(); m_HitBack.clear(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Images::GetARGBFront(unsigned int& i,unsigned int& a,unsigned int& r,unsigned int& g,unsigned int& b){ +void PS_Images::GetARGBFront(unsigned int& i, unsigned int& a, unsigned int& r, unsigned int& g, unsigned int& b) { unsigned int Info = m_HitFront[i]->GetStrip(); - a = (Info>>24)&0xff; - r = (Info>>16)&0xff; - g = (Info>>8)&0xff; - b = (Info>>0)&0xff; + a = (Info >> 24) & 0xff; + r = (Info >> 16) & 0xff; + g = (Info >> 8) & 0xff; + b = (Info >> 0) & 0xff; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Images::GetARGBBack(unsigned int& i,unsigned int& a,unsigned int& r,unsigned int& g,unsigned int& b){ +void PS_Images::GetARGBBack(unsigned int& i, unsigned int& a, unsigned int& r, unsigned int& g, unsigned int& b) { unsigned int Info = m_HitBack[i]->GetStrip(); - a = (Info>>24)&0xff; - r = (Info>>16)&0xff; - g = (Info>>8)&0xff; - b = (Info>>0)&0xff; + a = (Info >> 24) & 0xff; + r = (Info >> 16) & 0xff; + g = (Info >> 8) & 0xff; + b = (Info >> 0) & 0xff; } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -PS_Rectangle::PS_Rectangle(G4String name,G4int Level, G4double StripPlaneLength, G4double StripPlaneWidth, G4int NumberOfStripLength,G4int NumberOfStripWidth,G4int depth,G4String axis) - :G4VPrimitiveScorer(name, depth){ - m_StripPlaneLength = StripPlaneLength; - m_StripPlaneWidth = StripPlaneWidth; - m_NumberOfStripLength = NumberOfStripLength; - m_NumberOfStripWidth = NumberOfStripWidth; - m_StripPitchLength = m_StripPlaneLength / m_NumberOfStripLength; - m_StripPitchWidth = m_StripPlaneWidth / m_NumberOfStripWidth; - m_Level = Level; - if(axis=="xy") - m_Axis=ps_xy; - else if(axis=="yz") - m_Axis=ps_yz; - else if(axis=="xz") - m_Axis=ps_xz; - - - } +PS_Rectangle::PS_Rectangle(G4String name, G4int Level, G4double StripPlaneLength, G4double StripPlaneWidth, + G4int NumberOfStripLength, G4int NumberOfStripWidth, G4int depth, G4String axis) + : G4VPrimitiveScorer(name, depth) { + m_StripPlaneLength = StripPlaneLength; + m_StripPlaneWidth = StripPlaneWidth; + m_NumberOfStripLength = NumberOfStripLength; + m_NumberOfStripWidth = NumberOfStripWidth; + m_StripPitchLength = m_StripPlaneLength / m_NumberOfStripLength; + m_StripPitchWidth = m_StripPlaneWidth / m_NumberOfStripWidth; + m_Level = Level; + if (axis == "xy") + m_Axis = ps_xy; + else if (axis == "yz") + m_Axis = ps_yz; + else if (axis == "xz") + m_Axis = ps_xz; +} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -PS_Rectangle::~PS_Rectangle(){ -} +PS_Rectangle::~PS_Rectangle() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4bool PS_Rectangle::ProcessHits(G4Step* aStep, G4TouchableHistory*){ +G4bool PS_Rectangle::ProcessHits(G4Step* aStep, G4TouchableHistory*) { // contain Energy Time, DetNbr, StripFront and StripBack - t_Energy = aStep->GetTotalEnergyDeposit(); - t_Time = aStep->GetPreStepPoint()->GetGlobalTime(); + t_Energy = aStep->GetTotalEnergyDeposit(); + t_Time = aStep->GetPreStepPoint()->GetGlobalTime(); t_DetectorNumber = aStep->GetPreStepPoint()->GetTouchableHandle()->GetCopyNumber(m_Level); - t_Position = aStep->GetPreStepPoint()->GetPosition(); + t_Position = aStep->GetPreStepPoint()->GetPosition(); - t_Position = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(t_Position); + t_Position = + aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(t_Position); - if(m_Axis==ps_xy){ - t_StripLengthNumber = (int)((t_Position.x() + m_StripPlaneLength / 2.) / m_StripPitchLength ) + 1 ; - t_StripWidthNumber = (int)((t_Position.y() + m_StripPlaneWidth / 2.) / m_StripPitchWidth ) + 1 ; + if (m_Axis == ps_xy) { + t_StripLengthNumber = (int)((t_Position.x() + m_StripPlaneLength / 2.) / m_StripPitchLength) + 1; + t_StripWidthNumber = (int)((t_Position.y() + m_StripPlaneWidth / 2.) / m_StripPitchWidth) + 1; } - else if(m_Axis==ps_yz){ - t_StripLengthNumber = (int)((t_Position.y() + m_StripPlaneLength / 2.) / m_StripPitchLength ) + 1 ; - t_StripWidthNumber = (int)((t_Position.z() + m_StripPlaneWidth / 2.) / m_StripPitchWidth ) + 1 ; + else if (m_Axis == ps_yz) { + t_StripLengthNumber = (int)((t_Position.y() + m_StripPlaneLength / 2.) / m_StripPitchLength) + 1; + t_StripWidthNumber = (int)((t_Position.z() + m_StripPlaneWidth / 2.) / m_StripPitchWidth) + 1; } - else if(m_Axis==ps_xz){ - t_StripLengthNumber = (int)((t_Position.x() + m_StripPlaneLength / 2.) / m_StripPitchLength ) + 1 ; - t_StripWidthNumber = (int)((t_Position.z() + m_StripPlaneWidth / 2.) / m_StripPitchWidth ) + 1 ; + else if (m_Axis == ps_xz) { + t_StripLengthNumber = (int)((t_Position.x() + m_StripPlaneLength / 2.) / m_StripPitchLength) + 1; + t_StripWidthNumber = (int)((t_Position.z() + m_StripPlaneWidth / 2.) / m_StripPitchWidth) + 1; } - //Rare case where particle is close to edge of silicon plan - if (t_StripLengthNumber > m_NumberOfStripLength) t_StripLengthNumber = m_NumberOfStripLength; - if (t_StripWidthNumber > m_NumberOfStripWidth) t_StripWidthNumber = m_NumberOfStripWidth; + // Rare case where particle is close to edge of silicon plan + if (t_StripLengthNumber > m_NumberOfStripLength) + t_StripLengthNumber = m_NumberOfStripLength; + if (t_StripWidthNumber > m_NumberOfStripWidth) + t_StripWidthNumber = m_NumberOfStripWidth; // Check if the particle has interact before, if yes, add up the energies. vector<DSSDData>::iterator it; // Length - it = m_HitLength.find(DSSDData::CalculateIndex(t_StripLengthNumber,t_DetectorNumber)); - if(it!=m_HitLength.end()){ + it = m_HitLength.find(DSSDData::CalculateIndex(t_StripLengthNumber, t_DetectorNumber)); + if (it != m_HitLength.end()) { it->Add(t_Energy); } else - m_HitLength.Set(t_Energy,t_Time,t_StripLengthNumber,t_DetectorNumber); + m_HitLength.Set(t_Energy, t_Time, t_StripLengthNumber, t_DetectorNumber); // Width - it = m_HitWidth.find(DSSDData::CalculateIndex(t_StripWidthNumber,t_DetectorNumber)); - if(it!=m_HitWidth.end()){ + it = m_HitWidth.find(DSSDData::CalculateIndex(t_StripWidthNumber, t_DetectorNumber)); + if (it != m_HitWidth.end()) { it->Add(t_Energy); } else - m_HitWidth.Set(t_Energy,t_Time,t_StripWidthNumber,t_DetectorNumber); - + m_HitWidth.Set(t_Energy, t_Time, t_StripWidthNumber, t_DetectorNumber); -return TRUE; + return TRUE; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Rectangle::Initialize(G4HCofThisEvent*){ - clear(); -} +void PS_Rectangle::Initialize(G4HCofThisEvent*) { clear(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Rectangle::EndOfEvent(G4HCofThisEvent*){ -} +void PS_Rectangle::EndOfEvent(G4HCofThisEvent*) {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Rectangle::clear(){ +void PS_Rectangle::clear() { m_HitLength.clear(); m_HitWidth.clear(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Rectangle::DrawAll(){ - -} +void PS_Rectangle::DrawAll() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Rectangle::PrintAll(){ -} +void PS_Rectangle::PrintAll() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -PS_Annular::PS_Annular(G4String name,G4int Level, G4double StripPlaneInnerRadius, G4double StripPlaneOuterRadius, G4double PhiStart,G4double PhiStop, G4int NumberOfStripRing,G4int NumberOfStripSector,G4int NumberOfQuadrant,G4int depth) - :G4VPrimitiveScorer(name, depth){ - - m_StripPlaneInnerRadius = StripPlaneInnerRadius; - m_StripPlaneOuterRadius = StripPlaneOuterRadius; - m_PhiStart = PhiStart; - m_PhiStop = PhiStop; - m_NumberOfStripRing = NumberOfStripRing; - m_NumberOfStripSector = NumberOfStripSector; - m_NumberOfStripQuadrant = NumberOfQuadrant; - m_StripPitchRing = (m_StripPlaneOuterRadius-m_StripPlaneInnerRadius)/m_NumberOfStripRing; - m_StripPitchSector = (m_PhiStop-m_PhiStart)/m_NumberOfStripSector; - m_StripPitchQuadrant = (m_PhiStop-m_PhiStart)/m_NumberOfStripQuadrant; - m_Level = Level; +PS_Annular::PS_Annular(G4String name, G4int Level, G4double StripPlaneInnerRadius, G4double StripPlaneOuterRadius, + G4double PhiStart, G4double PhiStop, G4int NumberOfStripRing, G4int NumberOfStripSector, + G4int NumberOfQuadrant, G4int depth) + : G4VPrimitiveScorer(name, depth) { - m_uz = G4ThreeVector(0,0,1); - } + m_StripPlaneInnerRadius = StripPlaneInnerRadius; + m_StripPlaneOuterRadius = StripPlaneOuterRadius; + m_PhiStart = PhiStart; + m_PhiStop = PhiStop; + m_NumberOfStripRing = NumberOfStripRing; + m_NumberOfStripSector = NumberOfStripSector; + m_NumberOfStripQuadrant = NumberOfQuadrant; + m_StripPitchRing = (m_StripPlaneOuterRadius - m_StripPlaneInnerRadius) / m_NumberOfStripRing; + m_StripPitchSector = (m_PhiStop - m_PhiStart) / m_NumberOfStripSector; + m_StripPitchQuadrant = (m_PhiStop - m_PhiStart) / m_NumberOfStripQuadrant; + m_Level = Level; -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -PS_Annular::~PS_Annular(){ + m_uz = G4ThreeVector(0, 0, 1); } +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +PS_Annular::~PS_Annular() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4bool PS_Annular::ProcessHits(G4Step* aStep, G4TouchableHistory*){ +G4bool PS_Annular::ProcessHits(G4Step* aStep, G4TouchableHistory*) { t_Energy = aStep->GetTotalEnergyDeposit(); t_Time = aStep->GetPreStepPoint()->GetGlobalTime(); @@ -255,166 +245,169 @@ G4bool PS_Annular::ProcessHits(G4Step* aStep, G4TouchableHistory*){ t_DetectorNumber = aStep->GetPreStepPoint()->GetTouchableHandle()->GetCopyNumber(m_Level); t_Position = aStep->GetPreStepPoint()->GetPosition(); - //Transform into local coordinates - t_Position = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(t_Position); - t_StripRingNumber = (int) ((t_Position.rho() - m_StripPlaneInnerRadius) / m_StripPitchRing ) + 1 ; + // Transform into local coordinates + t_Position = + aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(t_Position); + t_StripRingNumber = (int)((t_Position.rho() - m_StripPlaneInnerRadius) / m_StripPitchRing) + 1; // phi() from G4-CLHEP method return azimuth between [-pi;pi] // we need it in [0;2pi] to calculate sector nbr in [1,NSectors] // only add 360 if the value is negative - double phi = (t_Position.phi()<0)? t_Position.phi()+2*pi : t_Position.phi() ; + double phi = (t_Position.phi() < 0) ? t_Position.phi() + 2 * pi : t_Position.phi(); // factor out the extra 360 degrees before strip/quad calculation - t_StripSectorNumber = (int) ( fmod((phi - m_PhiStart),2*pi) / m_StripPitchSector ) + 1 ; - t_StripQuadrantNumber = (int) ( fmod((phi - m_PhiStart),2*pi) / m_StripPitchQuadrant) + 1 ; + t_StripSectorNumber = (int)(fmod((phi - m_PhiStart), 2 * pi) / m_StripPitchSector) + 1; + t_StripQuadrantNumber = (int)(fmod((phi - m_PhiStart), 2 * pi) / m_StripPitchQuadrant) + 1; - //Rare case where particle is close to edge of silicon plan - if (t_StripRingNumber > m_NumberOfStripRing) t_StripRingNumber = m_NumberOfStripRing; - if (t_StripSectorNumber > m_NumberOfStripSector) t_StripSectorNumber = m_NumberOfStripSector; - if (t_StripQuadrantNumber > m_NumberOfStripQuadrant) t_StripQuadrantNumber = m_NumberOfStripQuadrant; + // Rare case where particle is close to edge of silicon plan + if (t_StripRingNumber > m_NumberOfStripRing) + t_StripRingNumber = m_NumberOfStripRing; + if (t_StripSectorNumber > m_NumberOfStripSector) + t_StripSectorNumber = m_NumberOfStripSector; + if (t_StripQuadrantNumber > m_NumberOfStripQuadrant) + t_StripQuadrantNumber = m_NumberOfStripQuadrant; vector<DSSDData>::iterator it; // Ring - it = m_HitRing.find(DSSDData::CalculateIndex(t_StripRingNumber,t_DetectorNumber)); - if(it!=m_HitRing.end()){ + it = m_HitRing.find(DSSDData::CalculateIndex(t_StripRingNumber, t_DetectorNumber)); + if (it != m_HitRing.end()) { it->Add(t_Energy); } else - m_HitRing.Set(t_Energy,t_Time,t_StripRingNumber,t_DetectorNumber); + m_HitRing.Set(t_Energy, t_Time, t_StripRingNumber, t_DetectorNumber); - //Sector - it = m_HitSector.find(DSSDData::CalculateIndex(t_StripSectorNumber,t_DetectorNumber)); - if(it!=m_HitSector.end()){ + // Sector + it = m_HitSector.find(DSSDData::CalculateIndex(t_StripSectorNumber, t_DetectorNumber)); + if (it != m_HitSector.end()) { it->Add(t_Energy); } else - m_HitSector.Set(t_Energy,t_Time,t_StripSectorNumber,t_DetectorNumber); + m_HitSector.Set(t_Energy, t_Time, t_StripSectorNumber, t_DetectorNumber); - //Quadrant - it = m_HitQuadrant.find(DSSDData::CalculateIndex(t_StripQuadrantNumber,t_DetectorNumber)); - if(it!=m_HitQuadrant.end()){ + // Quadrant + it = m_HitQuadrant.find(DSSDData::CalculateIndex(t_StripQuadrantNumber, t_DetectorNumber)); + if (it != m_HitQuadrant.end()) { it->Add(t_Energy); } else - m_HitQuadrant.Set(t_Energy,t_Time,t_StripQuadrantNumber,t_DetectorNumber); + m_HitQuadrant.Set(t_Energy, t_Time, t_StripQuadrantNumber, t_DetectorNumber); return TRUE; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Annular::Initialize(G4HCofThisEvent*){ - clear(); -} +void PS_Annular::Initialize(G4HCofThisEvent*) { clear(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Annular::EndOfEvent(G4HCofThisEvent*){ -} +void PS_Annular::EndOfEvent(G4HCofThisEvent*) {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Annular::clear(){ +void PS_Annular::clear() { m_HitRing.clear(); m_HitSector.clear(); m_HitQuadrant.clear(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Annular::DrawAll(){ - -} +void PS_Annular::DrawAll() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Annular::PrintAll(){ -} +void PS_Annular::PrintAll() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -PS_Resistive::PS_Resistive(G4String name,G4int Level, G4double StripPlaneLength, G4double StripPlaneWidth, G4int NumberOfStripWidth,G4int depth) - :G4VPrimitiveScorer(name, depth){ - m_StripPlaneLength = StripPlaneLength; - m_StripPlaneWidth = StripPlaneWidth; - m_NumberOfStripWidth = NumberOfStripWidth; - m_StripPitchWidth = m_StripPlaneWidth / m_NumberOfStripWidth; - m_Level = Level; - - t_Position = G4ThreeVector(-1000,-1000,-1000); - t_DetectorNumber = -1; - t_StripWidthNumber = -1; - } +PS_Resistive::PS_Resistive(G4String name, G4String dir, G4int Level, G4double StripPlaneLength, + G4double StripPlaneWidth, G4int NumberOfStripWidth, G4int depth) + : G4VPrimitiveScorer(name, depth) { + m_StripPlaneLength = StripPlaneLength; + m_StripPlaneWidth = StripPlaneWidth; + m_NumberOfStripWidth = NumberOfStripWidth; + m_StripPitchWidth = m_StripPlaneWidth / m_NumberOfStripWidth; + m_Level = Level; + m_dir = dir; -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -PS_Resistive::~PS_Resistive(){ + t_Position = G4ThreeVector(-1000, -1000, -1000); + t_DetectorNumber = -1; + t_StripWidthNumber = -1; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4bool PS_Resistive::ProcessHits(G4Step* aStep, G4TouchableHistory*){ +PS_Resistive::~PS_Resistive() {} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +G4bool PS_Resistive::ProcessHits(G4Step* aStep, G4TouchableHistory*) { // contain Energy Total, E1, E2, Time, DetNbr, and StripWidth - t_Energy = aStep->GetTotalEnergyDeposit(); + t_Energy = aStep->GetTotalEnergyDeposit(); t_Time = aStep->GetPreStepPoint()->GetGlobalTime(); - + t_DetectorNumber = aStep->GetPreStepPoint()->GetTouchableHandle()->GetCopyNumber(m_Level); t_Position = aStep->GetPreStepPoint()->GetPosition(); - t_Position = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(t_Position); + t_Position = + aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(t_Position); - t_StripWidthNumber = (int)((t_Position.x() + m_StripPlaneWidth / 2.) / m_StripPitchWidth ) + 1 ; + t_StripWidthNumber = (int)((t_Position.x() + m_StripPlaneWidth / 2.) / m_StripPitchWidth) + 1; // The energy is divided in two depending on the position // position along the resistive strip - double P = (t_Position.z())/(0.5*m_StripPlaneLength); - // Energy - t_EnergyUp = aStep->GetTotalEnergyDeposit()*(1+P)*0.5; - t_EnergyDown = t_Energy-t_EnergyUp; + double P; + if (m_dir == "x") + P = (t_Position.x()) / (0.5 * m_StripPlaneLength); + else if (m_dir == "y") + P = (t_Position.y()) / (0.5 * m_StripPlaneLength); + else if (m_dir == "z") + P = (t_Position.z()) / (0.5 * m_StripPlaneLength); + else { + std::cout << "Error : Resistive strip DSSD scorer direction incorrect, should be x,y, or z " << std::endl; + exit(1); + } - //Rare case where particle is close to edge of silicon plan - if (t_StripWidthNumber > m_NumberOfStripWidth) t_StripWidthNumber = m_NumberOfStripWidth; + // Energy + t_EnergyUp = aStep->GetTotalEnergyDeposit() * (1 + P) * 0.5; + t_EnergyDown = t_Energy - t_EnergyUp; + // Rare case where particle is close to edge of silicon plan + if (t_StripWidthNumber > m_NumberOfStripWidth) + t_StripWidthNumber = m_NumberOfStripWidth; // Up vector<DSSDData>::iterator it; - it = m_HitUp.find(DSSDData::CalculateIndex(t_DetectorNumber,t_StripWidthNumber)); - if(it!=m_HitUp.end()) + it = m_HitUp.find(DSSDData::CalculateIndex(t_DetectorNumber, t_StripWidthNumber)); + if (it != m_HitUp.end()) it->Add(t_EnergyUp); else - m_HitUp.Set(t_EnergyUp,t_Time,t_StripWidthNumber,t_DetectorNumber); - + m_HitUp.Set(t_EnergyUp, t_Time, t_StripWidthNumber, t_DetectorNumber); + // Down - it = m_HitDown.find(DSSDData::CalculateIndex(t_DetectorNumber,t_StripWidthNumber)); - if(it!=m_HitDown.end()) + it = m_HitDown.find(DSSDData::CalculateIndex(t_DetectorNumber, t_StripWidthNumber)); + if (it != m_HitDown.end()) it->Add(t_EnergyDown); else - m_HitDown.Set(t_EnergyDown,t_Time,t_StripWidthNumber,t_DetectorNumber); - - // Back - it = m_HitBack.find(DSSDData::CalculateIndex(t_DetectorNumber,t_StripWidthNumber)); - if(it!=m_HitBack.end()) + m_HitDown.Set(t_EnergyDown, t_Time, t_StripWidthNumber, t_DetectorNumber); + + // Back + it = m_HitBack.find(DSSDData::CalculateIndex(t_DetectorNumber, t_StripWidthNumber)); + if (it != m_HitBack.end()) it->Add(t_Energy); else - m_HitBack.Set(t_Energy,t_Time,1,t_DetectorNumber); - - - + m_HitBack.Set(t_Energy, t_Time, 1, t_DetectorNumber); + return TRUE; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Resistive::Initialize(G4HCofThisEvent* ){ - clear(); -} +void PS_Resistive::Initialize(G4HCofThisEvent*) { clear(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Resistive::EndOfEvent(G4HCofThisEvent*){ -} +void PS_Resistive::EndOfEvent(G4HCofThisEvent*) {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Resistive::clear(){ +void PS_Resistive::clear() { m_HitUp.clear(); m_HitDown.clear(); m_HitBack.clear(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Resistive::DrawAll(){ - -} +void PS_Resistive::DrawAll() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Resistive::PrintAll(){ -} +void PS_Resistive::PrintAll() {} diff --git a/NPSimulation/Scorers/DSSDScorers.hh b/NPSimulation/Scorers/DSSDScorers.hh index 326c334b3769d0fe9f98328127d86365f530d9dd..c1c4f3a1f823852d0c76fcf5aa60dae49163d15d 100644 --- a/NPSimulation/Scorers/DSSDScorers.hh +++ b/NPSimulation/Scorers/DSSDScorers.hh @@ -25,332 +25,335 @@ *Only one scorer is needed for a detector * *****************************************************************************/ #include "G4VPrimitiveScorer.hh" -#include "NPSHitsMap.hh" #include "NPImage.h" +#include "NPSHitsMap.hh" #include <unordered_map> using namespace std; using namespace CLHEP; namespace DSSDScorers { // Hold data for DSSD hit - class DSSDData{ - public: - DSSDData(){}; - DSSDData(const double& Energy, const double& Time, const unsigned int& Strip, const unsigned int& Detector){ - m_Energy=Energy; - m_Time=Time; - m_Strip=Strip; - m_Detector=Detector; - m_Index = CalculateIndex(m_Strip,m_Detector); - } - - ~DSSDData(){}; - - private: - unsigned int m_Index; - double m_Energy; - double m_Time; - unsigned int m_Strip; - unsigned int m_Detector; - - public : // Modifier - inline void Set(const double& Energy, const double& Time, const unsigned int& Strip, const unsigned int& Detector){ - m_Energy=Energy; - m_Time=Time; - m_Strip=Strip; - m_Detector=Detector; - m_Index = CalculateIndex(m_Strip,m_Detector); - } - - inline void Add(const double& Energy) {m_Energy+=Energy;}; - - public: // Accessor - inline unsigned int GetIndex() const {return m_Index;}; - inline double GetEnergy() const {return m_Energy;}; - inline double GetTime() const {return m_Time;}; - inline unsigned int GetStrip() const {return m_Strip;}; - inline unsigned int GetDetector() const {return m_Detector;}; - - public: - static unsigned int CalculateIndex(const unsigned int& Strip,const unsigned int& Detector) {return Detector*1e6+Strip;} - + class DSSDData { + public: + DSSDData(){}; + DSSDData(const double& Energy, const double& Time, const unsigned int& Strip, const unsigned int& Detector) { + m_Energy = Energy; + m_Time = Time; + m_Strip = Strip; + m_Detector = Detector; + m_Index = CalculateIndex(m_Strip, m_Detector); + } + + ~DSSDData(){}; + + private: + unsigned int m_Index; + double m_Energy; + double m_Time; + unsigned int m_Strip; + unsigned int m_Detector; + + public: // Modifier + inline void Set(const double& Energy, const double& Time, const unsigned int& Strip, const unsigned int& Detector) { + m_Energy = Energy; + m_Time = Time; + m_Strip = Strip; + m_Detector = Detector; + m_Index = CalculateIndex(m_Strip, m_Detector); + } + + inline void Add(const double& Energy) { m_Energy += Energy; }; + + public: // Accessor + inline unsigned int GetIndex() const { return m_Index; }; + inline double GetEnergy() const { return m_Energy; }; + inline double GetTime() const { return m_Time; }; + inline unsigned int GetStrip() const { return m_Strip; }; + inline unsigned int GetDetector() const { return m_Detector; }; + + public: + static unsigned int CalculateIndex(const unsigned int& Strip, const unsigned int& Detector) { + return Detector * 1e6 + Strip; + } }; // Manage a vector of DSSD hit - class DSSDDataVector{ - public: - DSSDDataVector(){}; - ~DSSDDataVector(){}; - - private: - vector<DSSDData> m_Data; - - public: - vector<DSSDData>::iterator find(const unsigned int& index) ; - inline void clear(){m_Data.clear();} ; - inline vector<DSSDData>::iterator end() {return m_Data.end();}; - inline vector<DSSDData>::iterator begin() {return m_Data.begin();}; - inline unsigned int size() {return m_Data.size();}; - inline void Add(const unsigned int& index,const double& Energy) {find(index)->Add(Energy);}; - inline void Set(const double& Energy, const double& Time, const unsigned int& Strip, const unsigned int& Detector) {m_Data.push_back(DSSDData(Energy,Time,Strip,Detector));}; - DSSDData* operator[](const unsigned int& i){return &m_Data[i];}; + class DSSDDataVector { + public: + DSSDDataVector(){}; + ~DSSDDataVector(){}; + + private: + vector<DSSDData> m_Data; + + public: + vector<DSSDData>::iterator find(const unsigned int& index); + inline void clear() { m_Data.clear(); }; + inline vector<DSSDData>::iterator end() { return m_Data.end(); }; + inline vector<DSSDData>::iterator begin() { return m_Data.begin(); }; + inline unsigned int size() { return m_Data.size(); }; + inline void Add(const unsigned int& index, const double& Energy) { find(index)->Add(Energy); }; + inline void Set(const double& Energy, const double& Time, const unsigned int& Strip, const unsigned int& Detector) { + m_Data.push_back(DSSDData(Energy, Time, Strip, Detector)); + }; + DSSDData* operator[](const unsigned int& i) { return &m_Data[i]; }; }; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - class PS_Images : public G4VPrimitiveScorer{ - - public: // with description - PS_Images(G4String name, string imageFront,string imageBack,double scalingFront, double scalingBack, double centerOffsetX,double centerOffsetY,unsigned int ignoreValue, G4int depth=0); - ~PS_Images(){}; - - protected: // with description - G4bool ProcessHits(G4Step*, G4TouchableHistory*); - - public: - void Initialize(G4HCofThisEvent*); - void EndOfEvent(G4HCofThisEvent*); - void clear(); - void DrawAll(){}; - void PrintAll(){}; - - private: // Geometry of the detector - NPL::Image* m_ImageFront; - NPL::Image* m_ImageBack; - double m_ScalingFront; - double m_ScalingBack; - double m_CenterOffsetX; - double m_CenterOffsetY; - unsigned int m_IgnoreValue; - - // Level at which to find the copy number linked to the detector number - G4int m_Level; - - private: // inherited from G4VPrimitiveScorer - DSSDDataVector m_HitFront; - DSSDDataVector m_HitBack; - - private: // Needed for intermediate calculation (avoid multiple instantiation in Processing Hit) - G4ThreeVector t_Position; - double t_Energy; - double t_Time; - unsigned int t_DetectorNbr; - unsigned int t_PixelFront; - unsigned int t_PixelBack; - - public: // information accessor - inline unsigned int GetFrontMult() {return m_HitFront.size();}; - inline unsigned int GetStripFront(const unsigned int& i){return m_HitFront[i]->GetStrip();}; - inline unsigned int GetDetectorFront(const unsigned int& i){return m_HitFront[i]->GetDetector();}; - inline double GetEnergyFront(const unsigned int& i){return m_HitFront[i]->GetEnergy();}; - inline double GetTimeFront(const unsigned int& i){return m_HitFront[i]->GetTime();}; - inline unsigned int GetBackMult() {return m_HitBack.size();}; - inline unsigned int GetStripBack(const unsigned int& i){return m_HitBack[i]->GetStrip();}; - inline unsigned int GetDetectorBack(const unsigned int& i){return m_HitBack[i]->GetDetector();}; - inline double GetEnergyBack(const unsigned int& i){return m_HitBack[i]->GetEnergy();}; - inline double GetTimeBack(const unsigned int& i){return m_HitBack[i]->GetTime();}; - - void GetARGBFront(unsigned int& i,unsigned int& a,unsigned int& r,unsigned int& g,unsigned int& b); - void GetARGBBack(unsigned int& i,unsigned int& a,unsigned int& r,unsigned int& g,unsigned int& b); + class PS_Images : public G4VPrimitiveScorer { + + public: // with description + PS_Images(G4String name, string imageFront, string imageBack, double scalingFront, double scalingBack, + double centerOffsetX, double centerOffsetY, unsigned int ignoreValue, G4int depth = 0); + ~PS_Images(){}; + + protected: // with description + G4bool ProcessHits(G4Step*, G4TouchableHistory*); + + public: + void Initialize(G4HCofThisEvent*); + void EndOfEvent(G4HCofThisEvent*); + void clear(); + void DrawAll(){}; + void PrintAll(){}; + + private: // Geometry of the detector + NPL::Image* m_ImageFront; + NPL::Image* m_ImageBack; + double m_ScalingFront; + double m_ScalingBack; + double m_CenterOffsetX; + double m_CenterOffsetY; + unsigned int m_IgnoreValue; + + // Level at which to find the copy number linked to the detector number + G4int m_Level; + + private: // inherited from G4VPrimitiveScorer + DSSDDataVector m_HitFront; + DSSDDataVector m_HitBack; + + private: // Needed for intermediate calculation (avoid multiple instantiation in Processing Hit) + G4ThreeVector t_Position; + double t_Energy; + double t_Time; + unsigned int t_DetectorNbr; + unsigned int t_PixelFront; + unsigned int t_PixelBack; + + public: // information accessor + inline unsigned int GetFrontMult() { return m_HitFront.size(); }; + inline unsigned int GetStripFront(const unsigned int& i) { return m_HitFront[i]->GetStrip(); }; + inline unsigned int GetDetectorFront(const unsigned int& i) { return m_HitFront[i]->GetDetector(); }; + inline double GetEnergyFront(const unsigned int& i) { return m_HitFront[i]->GetEnergy(); }; + inline double GetTimeFront(const unsigned int& i) { return m_HitFront[i]->GetTime(); }; + inline unsigned int GetBackMult() { return m_HitBack.size(); }; + inline unsigned int GetStripBack(const unsigned int& i) { return m_HitBack[i]->GetStrip(); }; + inline unsigned int GetDetectorBack(const unsigned int& i) { return m_HitBack[i]->GetDetector(); }; + inline double GetEnergyBack(const unsigned int& i) { return m_HitBack[i]->GetEnergy(); }; + inline double GetTimeBack(const unsigned int& i) { return m_HitBack[i]->GetTime(); }; + + void GetARGBFront(unsigned int& i, unsigned int& a, unsigned int& r, unsigned int& g, unsigned int& b); + void GetARGBBack(unsigned int& i, unsigned int& a, unsigned int& r, unsigned int& g, unsigned int& b); }; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - class PS_Rectangle : public G4VPrimitiveScorer{ - - public: // with description - PS_Rectangle(G4String name, G4int Level, G4double StripPlaneLength, G4double StripPlaneWidth, G4int NumberOfStripLength,G4int NumberOfStripWidth,G4int depth=0,G4String axis="xy"); - ~PS_Rectangle(); - - private: - enum psAxis{ps_xy,ps_yz,ps_xz}; - psAxis m_Axis; - - protected: // with description - G4bool ProcessHits(G4Step*, G4TouchableHistory*); - - public: - void Initialize(G4HCofThisEvent*); - void EndOfEvent(G4HCofThisEvent*); - void clear(); - void DrawAll(); - void PrintAll(); - - private: // Geometry of the detector - double m_StripPlaneLength; - double m_StripPlaneWidth; - unsigned int m_NumberOfStripLength; - unsigned int m_NumberOfStripWidth; - double m_StripPitchLength; - double m_StripPitchWidth; - // Level at which to find the copy number linked to the detector number - int m_Level; - - private: // inherited from G4VPrimitiveScorer - DSSDDataVector m_HitLength; - DSSDDataVector m_HitWidth; - private: // Needed for intermediate calculation (avoid multiple instantiation in Processing Hit) - G4ThreeVector t_Position; - double t_Energy; - double t_Time; - unsigned int t_DetectorNumber; - unsigned int t_StripLengthNumber; - unsigned int t_StripWidthNumber; - - public: - inline unsigned int GetLengthMult() {return m_HitLength.size();}; - inline unsigned int GetStripLength(const unsigned int& i){return m_HitLength[i]->GetStrip();}; - inline unsigned int GetDetectorLength(const unsigned int& i){return m_HitLength[i]->GetDetector();}; - inline double GetEnergyLength(const unsigned int& i){return m_HitLength[i]->GetEnergy();}; - inline double GetTimeLength(const unsigned int& i){return m_HitLength[i]->GetTime();}; - inline unsigned int GetWidthMult() {return m_HitWidth.size();}; - inline unsigned int GetStripWidth(const unsigned int& i){return m_HitWidth[i]->GetStrip();}; - inline unsigned int GetDetectorWidth(const unsigned int& i){return m_HitWidth[i]->GetDetector();}; - inline double GetEnergyWidth(const unsigned int& i){return m_HitWidth[i]->GetEnergy();}; - inline double GetTimeWidth(const unsigned int& i){return m_HitWidth[i]->GetTime();}; - - - public: - static unsigned int CalculateIndex(const unsigned int& Strip,const unsigned int& Detector) {return Detector*1e6+Strip;} - - + class PS_Rectangle : public G4VPrimitiveScorer { + + public: // with description + PS_Rectangle(G4String name, G4int Level, G4double StripPlaneLength, G4double StripPlaneWidth, + G4int NumberOfStripLength, G4int NumberOfStripWidth, G4int depth = 0, G4String axis = "xy"); + ~PS_Rectangle(); + + private: + enum psAxis { ps_xy, ps_yz, ps_xz }; + psAxis m_Axis; + + protected: // with description + G4bool ProcessHits(G4Step*, G4TouchableHistory*); + + public: + void Initialize(G4HCofThisEvent*); + void EndOfEvent(G4HCofThisEvent*); + void clear(); + void DrawAll(); + void PrintAll(); + + private: // Geometry of the detector + double m_StripPlaneLength; + double m_StripPlaneWidth; + unsigned int m_NumberOfStripLength; + unsigned int m_NumberOfStripWidth; + double m_StripPitchLength; + double m_StripPitchWidth; + // Level at which to find the copy number linked to the detector number + int m_Level; + + private: // inherited from G4VPrimitiveScorer + DSSDDataVector m_HitLength; + DSSDDataVector m_HitWidth; + + private: // Needed for intermediate calculation (avoid multiple instantiation in Processing Hit) + G4ThreeVector t_Position; + double t_Energy; + double t_Time; + unsigned int t_DetectorNumber; + unsigned int t_StripLengthNumber; + unsigned int t_StripWidthNumber; + + public: + inline unsigned int GetLengthMult() { return m_HitLength.size(); }; + inline unsigned int GetStripLength(const unsigned int& i) { return m_HitLength[i]->GetStrip(); }; + inline unsigned int GetDetectorLength(const unsigned int& i) { return m_HitLength[i]->GetDetector(); }; + inline double GetEnergyLength(const unsigned int& i) { return m_HitLength[i]->GetEnergy(); }; + inline double GetTimeLength(const unsigned int& i) { return m_HitLength[i]->GetTime(); }; + inline unsigned int GetWidthMult() { return m_HitWidth.size(); }; + inline unsigned int GetStripWidth(const unsigned int& i) { return m_HitWidth[i]->GetStrip(); }; + inline unsigned int GetDetectorWidth(const unsigned int& i) { return m_HitWidth[i]->GetDetector(); }; + inline double GetEnergyWidth(const unsigned int& i) { return m_HitWidth[i]->GetEnergy(); }; + inline double GetTimeWidth(const unsigned int& i) { return m_HitWidth[i]->GetTime(); }; + + public: + static unsigned int CalculateIndex(const unsigned int& Strip, const unsigned int& Detector) { + return Detector * 1e6 + Strip; + } }; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - class PS_Annular : public G4VPrimitiveScorer{ - - public: // with description - PS_Annular(G4String name,G4int Level, G4double StripPlaneInnerRadius, G4double StripPlaneOuterRadius, G4double PhiStart,G4double PhiStop, G4int NumberOfStripRing,G4int NumberOfStripSector=1, G4int NumberOfQuadrant=1,G4int depth=0); - ~PS_Annular(); - - protected: // with description - G4bool ProcessHits(G4Step*, G4TouchableHistory*); - - public: - void Initialize(G4HCofThisEvent*); - void EndOfEvent(G4HCofThisEvent*); - void clear(); - void DrawAll(); - void PrintAll(); - - private: // Geometry of the detector - double m_StripPlaneInnerRadius; - double m_StripPlaneOuterRadius; - double m_PhiStart; - double m_PhiStop; - unsigned int m_NumberOfStripRing; - unsigned int m_NumberOfStripSector; - unsigned int m_NumberOfStripQuadrant; - double m_StripPitchRing; - double m_StripPitchSector; - double m_StripPitchQuadrant; - string m_Axis; - // Level at which to find the copy number linked to the detector number - int m_Level; - - - private: // inherited from G4VPrimitiveScorer - DSSDDataVector m_HitRing; - DSSDDataVector m_HitSector; - DSSDDataVector m_HitQuadrant; - - - private: // Needed for intermediate calculation (avoid multiple instantiation in Processing Hit) - G4ThreeVector t_Position; - double t_Energy; - double t_Time; - unsigned int t_DetectorNumber; - unsigned int t_StripRingNumber; - unsigned int t_StripSectorNumber; - unsigned int t_StripQuadrantNumber; - - public: - inline unsigned int GetRingMult() {return m_HitRing.size();}; - inline unsigned int GetStripRing(const unsigned int& i){return m_HitRing[i]->GetStrip();}; - inline unsigned int GetDetectorRing(const unsigned int& i){return m_HitRing[i]->GetDetector();}; - inline double GetEnergyRing(const unsigned int& i){return m_HitRing[i]->GetEnergy();}; - inline double GetTimeRing(const unsigned int& i){return m_HitRing[i]->GetTime();}; - inline unsigned int GetSectorMult() {return m_HitSector.size();}; - inline unsigned int GetStripSector(const unsigned int& i){return m_HitSector[i]->GetStrip();}; - inline unsigned int GetDetectorSector(const unsigned int& i){return m_HitSector[i]->GetDetector();}; - inline double GetEnergySector(const unsigned int& i){return m_HitSector[i]->GetEnergy();}; - inline double GetTimeSector(const unsigned int& i){return m_HitSector[i]->GetTime();}; - inline unsigned int GetQuadrantMult() {return m_HitQuadrant.size();}; - inline unsigned int GetStripQuadrant(const unsigned int& i){return m_HitQuadrant[i]->GetStrip();}; - inline unsigned int GetDetectorQuadrant(const unsigned int& i){return m_HitQuadrant[i]->GetDetector();}; - inline double GetEnergyQuadrant(const unsigned int& i){return m_HitQuadrant[i]->GetEnergy();}; - inline double GetTimeQuadrant(const unsigned int& i){return m_HitQuadrant[i]->GetTime();}; - - private: // Needed for intermediate calculation (avoid multiple instantiation in Processing Hit) - G4ThreeVector m_uz ; - - public: - static unsigned int CalculateIndex(const unsigned int& Strip,const unsigned int& Detector) {return Detector*1e6+Strip;} - - + class PS_Annular : public G4VPrimitiveScorer { + + public: // with description + PS_Annular(G4String name, G4int Level, G4double StripPlaneInnerRadius, G4double StripPlaneOuterRadius, + G4double PhiStart, G4double PhiStop, G4int NumberOfStripRing, G4int NumberOfStripSector = 1, + G4int NumberOfQuadrant = 1, G4int depth = 0); + ~PS_Annular(); + + protected: // with description + G4bool ProcessHits(G4Step*, G4TouchableHistory*); + + public: + void Initialize(G4HCofThisEvent*); + void EndOfEvent(G4HCofThisEvent*); + void clear(); + void DrawAll(); + void PrintAll(); + + private: // Geometry of the detector + double m_StripPlaneInnerRadius; + double m_StripPlaneOuterRadius; + double m_PhiStart; + double m_PhiStop; + unsigned int m_NumberOfStripRing; + unsigned int m_NumberOfStripSector; + unsigned int m_NumberOfStripQuadrant; + double m_StripPitchRing; + double m_StripPitchSector; + double m_StripPitchQuadrant; + string m_Axis; + // Level at which to find the copy number linked to the detector number + int m_Level; + + private: // inherited from G4VPrimitiveScorer + DSSDDataVector m_HitRing; + DSSDDataVector m_HitSector; + DSSDDataVector m_HitQuadrant; + + private: // Needed for intermediate calculation (avoid multiple instantiation in Processing Hit) + G4ThreeVector t_Position; + double t_Energy; + double t_Time; + unsigned int t_DetectorNumber; + unsigned int t_StripRingNumber; + unsigned int t_StripSectorNumber; + unsigned int t_StripQuadrantNumber; + + public: + inline unsigned int GetRingMult() { return m_HitRing.size(); }; + inline unsigned int GetStripRing(const unsigned int& i) { return m_HitRing[i]->GetStrip(); }; + inline unsigned int GetDetectorRing(const unsigned int& i) { return m_HitRing[i]->GetDetector(); }; + inline double GetEnergyRing(const unsigned int& i) { return m_HitRing[i]->GetEnergy(); }; + inline double GetTimeRing(const unsigned int& i) { return m_HitRing[i]->GetTime(); }; + inline unsigned int GetSectorMult() { return m_HitSector.size(); }; + inline unsigned int GetStripSector(const unsigned int& i) { return m_HitSector[i]->GetStrip(); }; + inline unsigned int GetDetectorSector(const unsigned int& i) { return m_HitSector[i]->GetDetector(); }; + inline double GetEnergySector(const unsigned int& i) { return m_HitSector[i]->GetEnergy(); }; + inline double GetTimeSector(const unsigned int& i) { return m_HitSector[i]->GetTime(); }; + inline unsigned int GetQuadrantMult() { return m_HitQuadrant.size(); }; + inline unsigned int GetStripQuadrant(const unsigned int& i) { return m_HitQuadrant[i]->GetStrip(); }; + inline unsigned int GetDetectorQuadrant(const unsigned int& i) { return m_HitQuadrant[i]->GetDetector(); }; + inline double GetEnergyQuadrant(const unsigned int& i) { return m_HitQuadrant[i]->GetEnergy(); }; + inline double GetTimeQuadrant(const unsigned int& i) { return m_HitQuadrant[i]->GetTime(); }; + + private: // Needed for intermediate calculation (avoid multiple instantiation in Processing Hit) + G4ThreeVector m_uz; + + public: + static unsigned int CalculateIndex(const unsigned int& Strip, const unsigned int& Detector) { + return Detector * 1e6 + Strip; + } }; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - class PS_Resistive : public G4VPrimitiveScorer{ - - public: // with description - PS_Resistive(G4String name, G4int Level, - G4double StripPlaneLength, G4double StripPlaneWidth, - G4int NumberOfStripWidth,G4int depth=0); - - ~PS_Resistive(); - - protected: // with description - G4bool ProcessHits(G4Step*, G4TouchableHistory*); - - public: - void Initialize(G4HCofThisEvent*); - void EndOfEvent(G4HCofThisEvent*); - void clear(); - void DrawAll(); - void PrintAll(); - - private: // Geometry of the detector - double m_StripPlaneLength; - double m_StripPlaneWidth; - unsigned int m_NumberOfStripWidth; - double m_StripPitchWidth; - // Level at which to find the copy number linked to the detector number - G4int m_Level; - - private: - // Up and Down are each extremities of the resistive strip - DSSDDataVector m_HitUp; - DSSDDataVector m_HitDown; - DSSDDataVector m_HitBack; - - private: // Needed for intermediate calculation (avoid multiple instantiation in Processing Hit) - G4ThreeVector t_Position; - double t_Energy; - double t_EnergyUp; - double t_EnergyDown; - double t_Time; - unsigned int t_DetectorNumber; - unsigned int t_StripWidthNumber; - public: - inline unsigned int GetUpMult() {return m_HitUp.size();}; - inline unsigned int GetStripUp(const unsigned int& i){return m_HitUp[i]->GetStrip();}; - inline unsigned int GetDetectorUp(const unsigned int& i){return m_HitUp[i]->GetDetector();}; - inline double GetEnergyUp(const unsigned int& i){return m_HitUp[i]->GetEnergy();}; - inline double GetTimeUp(const unsigned int& i){return m_HitUp[i]->GetTime();}; - inline unsigned int GetDownMult() {return m_HitDown.size();}; - inline unsigned int GetStripDown(const unsigned int& i){return m_HitDown[i]->GetStrip();}; - inline unsigned int GetDetectorDown(const unsigned int& i){return m_HitDown[i]->GetDetector();}; - inline double GetEnergyDown(const unsigned int& i){return m_HitDown[i]->GetEnergy();}; - inline double GetTimeDown(const unsigned int& i){return m_HitDown[i]->GetTime();}; - inline unsigned int GetBackMult() {return m_HitBack.size();}; - inline unsigned int GetStripBack(const unsigned int& i){return m_HitBack[i]->GetStrip();}; - inline unsigned int GetDetectorBack(const unsigned int& i){return m_HitBack[i]->GetDetector();}; - inline double GetEnergyBack(const unsigned int& i){return m_HitBack[i]->GetEnergy();}; - inline double GetTimeBack(const unsigned int& i){return m_HitBack[i]->GetTime();}; - - + class PS_Resistive : public G4VPrimitiveScorer { + + public: // with description + PS_Resistive(G4String name, G4String dir, G4int Level, G4double StripPlaneLength, G4double StripPlaneWidth, + G4int NumberOfStripWidth, G4int depth = 0); + + ~PS_Resistive(); + + protected: // with description + G4bool ProcessHits(G4Step*, G4TouchableHistory*); + + public: + void Initialize(G4HCofThisEvent*); + void EndOfEvent(G4HCofThisEvent*); + void clear(); + void DrawAll(); + void PrintAll(); + + private: // Geometry of the detector + double m_StripPlaneLength; + double m_StripPlaneWidth; + unsigned int m_NumberOfStripWidth; + double m_StripPitchWidth; + G4String m_dir; + // Level at which to find the copy number linked to the detector number + G4int m_Level; + + private: + // Up and Down are each extremities of the resistive strip + DSSDDataVector m_HitUp; + DSSDDataVector m_HitDown; + DSSDDataVector m_HitBack; + + private: // Needed for intermediate calculation (avoid multiple instantiation in Processing Hit) + G4ThreeVector t_Position; + double t_Energy; + double t_EnergyUp; + double t_EnergyDown; + double t_Time; + unsigned int t_DetectorNumber; + unsigned int t_StripWidthNumber; + + public: + inline unsigned int GetUpMult() { return m_HitUp.size(); }; + inline unsigned int GetStripUp(const unsigned int& i) { return m_HitUp[i]->GetStrip(); }; + inline unsigned int GetDetectorUp(const unsigned int& i) { return m_HitUp[i]->GetDetector(); }; + inline double GetEnergyUp(const unsigned int& i) { return m_HitUp[i]->GetEnergy(); }; + inline double GetTimeUp(const unsigned int& i) { return m_HitUp[i]->GetTime(); }; + inline unsigned int GetDownMult() { return m_HitDown.size(); }; + inline unsigned int GetStripDown(const unsigned int& i) { return m_HitDown[i]->GetStrip(); }; + inline unsigned int GetDetectorDown(const unsigned int& i) { return m_HitDown[i]->GetDetector(); }; + inline double GetEnergyDown(const unsigned int& i) { return m_HitDown[i]->GetEnergy(); }; + inline double GetTimeDown(const unsigned int& i) { return m_HitDown[i]->GetTime(); }; + inline unsigned int GetBackMult() { return m_HitBack.size(); }; + inline unsigned int GetStripBack(const unsigned int& i) { return m_HitBack[i]->GetStrip(); }; + inline unsigned int GetDetectorBack(const unsigned int& i) { return m_HitBack[i]->GetDetector(); }; + inline double GetEnergyBack(const unsigned int& i) { return m_HitBack[i]->GetEnergy(); }; + inline double GetTimeBack(const unsigned int& i) { return m_HitBack[i]->GetTime(); }; }; -} - +} // namespace DSSDScorers #endif