File indexing completed on 2026-06-07 07:54:07
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
0027
0028
0029 #include "Par03Hit.hh"
0030
0031 #include "G4AttDef.hh"
0032 #include "G4AttDefStore.hh"
0033 #include "G4AttValue.hh"
0034 #include "G4Colour.hh"
0035 #include "G4LogicalVolume.hh"
0036 #include "G4SystemOfUnits.hh"
0037 #include "G4Tubs.hh"
0038 #include "G4UnitsTable.hh"
0039 #include "G4VVisManager.hh"
0040 #include "G4VisAttributes.hh"
0041
0042 G4ThreadLocal G4Allocator<Par03Hit>* Par03HitAllocator;
0043
0044 Par03Hit::Par03Hit() : G4VHit() {}
0045
0046
0047
0048 Par03Hit::~Par03Hit() = default;
0049
0050
0051
0052 Par03Hit::Par03Hit(const Par03Hit& aRight) : G4VHit()
0053 {
0054 fEdep = aRight.fEdep;
0055 fZId = aRight.fZId;
0056 fRhoId = aRight.fRhoId;
0057 fPhiId = aRight.fPhiId;
0058 fTime = aRight.fTime;
0059 fPos = aRight.fPos;
0060 fRot = aRight.fRot;
0061 fType = aRight.fType;
0062 fLogVol = aRight.fLogVol;
0063 }
0064
0065
0066
0067 const Par03Hit& Par03Hit::operator=(const Par03Hit& aRight)
0068 {
0069 fEdep = aRight.fEdep;
0070 fZId = aRight.fZId;
0071 fRhoId = aRight.fRhoId;
0072 fPhiId = aRight.fPhiId;
0073 fTime = aRight.fTime;
0074 fPos = aRight.fPos;
0075 fRot = aRight.fRot;
0076 fType = aRight.fType;
0077 fLogVol = aRight.fLogVol;
0078 return *this;
0079 }
0080
0081
0082
0083 int Par03Hit::operator==(const Par03Hit& aRight) const
0084 {
0085 return (fRhoId == aRight.fRhoId && fPhiId == aRight.fPhiId && fZId == aRight.fZId);
0086 }
0087
0088
0089
0090 void Par03Hit::Draw()
0091 {
0092 G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
0093
0094 if (!pVVisManager->FilterHit(*this)) return;
0095
0096 if (fEdep < 0) return;
0097 if (pVVisManager) {
0098 G4Transform3D trans(fRot, fPos);
0099 G4VisAttributes attribs;
0100
0101 G4Tubs solid("draw", 0, 1 * cm, 1 * cm, 0, 0.05 * CLHEP::pi);
0102 if (fLogVol) {
0103 const G4VisAttributes* pVA = fLogVol->GetVisAttributes();
0104 if (pVA) attribs = *pVA;
0105
0106
0107 solid = *dynamic_cast<G4Tubs*>(fLogVol->GetSolid());
0108 double dR = solid.GetOuterRadius() - solid.GetInnerRadius();
0109 solid.SetInnerRadius(solid.GetInnerRadius() + fRhoId * dR);
0110 solid.SetOuterRadius(solid.GetOuterRadius() + fRhoId * dR);
0111 }
0112
0113 G4double colR = fType == 0 ? 0 : 1;
0114 G4double colG = fType == 0 ? 1 : 0;
0115 G4double colB = 0;
0116 G4Colour colour(colR, colG, colB, 0.5);
0117 attribs.SetColour(colour);
0118 attribs.SetForceSolid(true);
0119 pVVisManager->Draw(solid, attribs, trans);
0120 }
0121 }
0122
0123
0124
0125 const std::map<G4String, G4AttDef>* Par03Hit::GetAttDefs() const
0126 {
0127 G4bool isNew;
0128 std::map<G4String, G4AttDef>* store = G4AttDefStore::GetInstance("Par03Hit", isNew);
0129 if (isNew) {
0130 (*store)["HitType"] = G4AttDef("HitType", "Hit Type", "Physics", "", "G4String");
0131 (*store)["Energy"] =
0132 G4AttDef("Energy", "Energy Deposited", "Physics", "G4BestUnit", "G4double");
0133 (*store)["Time"] = G4AttDef("Time", "Time", "Physics", "G4BestUnit", "G4double");
0134 (*store)["Pos"] = G4AttDef("Pos", "Position", "Physics", "G4BestUnit", "G4ThreeVector");
0135 }
0136 return store;
0137 }
0138
0139
0140
0141 std::vector<G4AttValue>* Par03Hit::CreateAttValues() const
0142 {
0143 std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
0144 values->push_back(G4AttValue("HitType", "HadPar03Hit", ""));
0145 values->push_back(G4AttValue("Energy", G4BestUnit(fEdep, "Energy"), ""));
0146 values->push_back(G4AttValue("Time", G4BestUnit(fTime, "Time"), ""));
0147 values->push_back(G4AttValue("Pos", G4BestUnit(fPos, "Length"), ""));
0148 return values;
0149 }
0150
0151
0152
0153 void Par03Hit::Print()
0154 {
0155 std::cout << "\tHit " << fEdep / MeV << " MeV at " << fPos / cm << " cm (R,phi,z)= (" << fRhoId
0156 << ", " << fPhiId << ", " << fZId << "), " << fTime << " ns" << std::endl;
0157 }