File indexing completed on 2025-01-31 09:22:22
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 #include "SiliconPixelHit.hh"
0027
0028 #include "G4RotationMatrix.hh"
0029 #include "G4SubtractionSolid.hh"
0030 #include "G4Transform3D.hh"
0031 #include "G4VVisManager.hh"
0032 #include "G4VisAttributes.hh"
0033 #include "HGCalTBMaterials.hh"
0034
0035 #include <cstdlib>
0036
0037
0038
0039 SiliconPixelHit::SiliconPixelHit(G4String aVolumeName, G4int aCopyNumSensor,
0040 G4int aCopyNumCell)
0041 : fVolumeName(aVolumeName), fCopyNumCell(aCopyNumCell),
0042 fCopyNumSensor(aCopyNumSensor) {}
0043
0044
0045
0046 void SiliconPixelHit::Digitise(const G4double aTimeWindow,
0047 const G4double aToaThreshold) {
0048
0049
0050 if (fEdep.empty()) {
0051 fIsValidHit = false;
0052 return;
0053 }
0054
0055 std::sort(fEdep.begin(), fEdep.end(),
0056 [](const std::pair<G4double, G4double> &left,
0057 const std::pair<G4double, G4double> &right) {
0058 return left.second < right.second;
0059 });
0060
0061 G4double firstHitTime = fEdep[0].second;
0062 fEdepDigi = 0;
0063 for (size_t i = 0; i < fEdep.size(); ++i) {
0064 if (aTimeWindow < 0 || fEdep[i].second < firstHitTime + aTimeWindow)
0065 fEdepDigi += fEdep[i].first;
0066 if (fEdepDigi > aToaThreshold) {
0067 if (fTimeOfArrival == -1)
0068 fTimeOfArrival = fEdep[i].second;
0069 fTimeOfArrivalLast = fEdep[i].second;
0070 }
0071 }
0072 fIsValidHit = (fEdepDigi > 0);
0073
0074
0075 if (fEdepNonIonizing.empty())
0076 return;
0077
0078 std::sort(fEdepNonIonizing.begin(), fEdepNonIonizing.end(),
0079 [](const std::pair<G4double, G4double> &left,
0080 const std::pair<G4double, G4double> &right) {
0081 return left.second < right.second;
0082 });
0083
0084 fEdepNonIonizingDigi = 0;
0085 for (size_t i = 0; i < fEdepNonIonizing.size(); ++i) {
0086 if (aTimeWindow == -1 ||
0087 fEdepNonIonizing[i].second < firstHitTime + aTimeWindow)
0088 fEdepNonIonizingDigi += fEdepNonIonizing[i].first;
0089 }
0090 }
0091
0092
0093
0094 void SiliconPixelHit::Draw() {
0095 G4VVisManager *pVVisManager = G4VVisManager::GetConcreteInstance();
0096 if (!(fEdepDigi > 0))
0097 return;
0098 if (pVVisManager) {
0099 if (!pVVisManager->FilterHit(*this))
0100 return;
0101 G4Transform3D trans(G4RotationMatrix(),
0102 G4ThreeVector(fPosX * CLHEP::cm, fPosY * CLHEP::cm, fPosZ * CLHEP::cm));
0103 G4VisAttributes attribs;
0104 auto solid = HexagonSolid("dummy", 0.3 * CLHEP::mm, 0.6496345 * CLHEP::cm);
0105 G4Colour colour(1, 0, 0);
0106 attribs.SetColour(colour);
0107 attribs.SetForceSolid(true);
0108 pVVisManager->Draw(*solid, attribs, trans);
0109 }
0110 }
0111
0112