File indexing completed on 2026-09-13 08:30:17
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 "Par04Hit.hh"
0030
0031 #include "G4AttDef.hh" // for G4AttDef
0032 #include "G4AttDefStore.hh" // for GetInstance
0033 #include "G4AttValue.hh" // for G4AttValue
0034 #include "G4Colour.hh" // for G4Colour
0035 #include "G4SystemOfUnits.hh" // for mm, MeV, cm, rad
0036 #include "G4Tubs.hh" // for G4Tubs
0037 #include "G4UnitsTable.hh" // for G4BestUnit
0038 #include "G4VVisManager.hh" // for G4VVisManager
0039 #include "G4VisAttributes.hh" // for G4VisAttributes
0040
0041 #include <CLHEP/Units/SystemOfUnits.h> // for mm, pi, MeV, cm, rad
0042 #include <CLHEP/Vector/ThreeVector.h> // for operator/, operator<<, Hep...
0043 #include <G4RotationMatrix.hh> // for G4RotationMatrix
0044 #include <G4String.hh> // for G4String
0045 #include <G4ThreeVector.hh> // for G4ThreeVector
0046 #include <G4Transform3D.hh> // for G4Transform3D
0047 #include <G4VHit.hh> // for G4VHit
0048 #include <algorithm> // for max
0049 #include <cmath> // for log10
0050 #include <iostream> // for operator<<, basic_ostream:...
0051 #include <string> // for operator<
0052 template<class Type>
0053 class G4Allocator;
0054
0055 G4ThreadLocal G4Allocator<Par04Hit>* Par04HitAllocator;
0056
0057
0058
0059 Par04Hit::Par04Hit() : G4VHit() {}
0060
0061
0062
0063 Par04Hit::~Par04Hit() = default;
0064
0065
0066
0067 Par04Hit::Par04Hit(const Par04Hit& aRight) : G4VHit()
0068 {
0069 fEdep = aRight.fEdep;
0070 fNdep = aRight.fNdep;
0071 fZId = aRight.fZId;
0072 fRhoId = aRight.fRhoId;
0073 fPhiId = aRight.fPhiId;
0074 fTime = aRight.fTime;
0075 fPos = aRight.fPos;
0076 fRot = aRight.fRot;
0077 fType = aRight.fType;
0078 fLogVol = aRight.fLogVol;
0079 }
0080
0081
0082
0083 const Par04Hit& Par04Hit::operator=(const Par04Hit& aRight)
0084 {
0085 fEdep = aRight.fEdep;
0086 fNdep = aRight.fNdep;
0087 fZId = aRight.fZId;
0088 fRhoId = aRight.fRhoId;
0089 fPhiId = aRight.fPhiId;
0090 fTime = aRight.fTime;
0091 fPos = aRight.fPos;
0092 fRot = aRight.fRot;
0093 fType = aRight.fType;
0094 fLogVol = aRight.fLogVol;
0095 return *this;
0096 }
0097
0098
0099
0100 int Par04Hit::operator==(const Par04Hit& aRight) const
0101 {
0102 return (fRhoId == aRight.fRhoId && fPhiId == aRight.fPhiId && fZId == aRight.fZId);
0103 }
0104
0105
0106
0107 void Par04Hit::Draw()
0108 {
0109
0110 G4ThreeVector meshSize(4.65 * mm, 2 * CLHEP::pi / 18. * CLHEP::rad, 3.4 * mm);
0111 G4int numPhiCells = CLHEP::pi * 2. / meshSize.y();
0112 G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
0113
0114 if (!pVVisManager->FilterHit(*this)) return;
0115
0116 if (fType >= 2) return;
0117
0118 if (fEdep <= 0) return;
0119
0120 if (fRhoId == -1 && fZId == -1 && fPhiId == -1) return;
0121 if (pVVisManager) {
0122 G4Transform3D trans(fRot, fPos);
0123 G4VisAttributes attribs;
0124 G4Tubs solid("draw", fRhoId * meshSize.x(), (fRhoId + 1) * meshSize.x(), meshSize.z() / 2.,
0125 (-numPhiCells / 2. + fPhiId) * meshSize.y(), meshSize.y());
0126
0127 G4double colR = fType == 0 ? 0 : 1;
0128 G4double colG = fType == 0 ? 1 : 0;
0129 G4double colB = 0;
0130
0131
0132 G4double alpha = 2 * std::log10(fEdep + 1);
0133 G4Colour colour(colR, colG, colB, alpha);
0134 attribs.SetColour(colour);
0135 attribs.SetForceSolid(true);
0136 pVVisManager->Draw(solid, attribs, trans);
0137 }
0138 }
0139
0140
0141
0142 const std::map<G4String, G4AttDef>* Par04Hit::GetAttDefs() const
0143 {
0144 G4bool isNew;
0145 std::map<G4String, G4AttDef>* store = G4AttDefStore::GetInstance("Par04Hit", isNew);
0146 if (isNew) {
0147 (*store)["HitType"] = G4AttDef("HitType", "Hit Type", "Physics", "", "G4String");
0148 (*store)["Energy"] =
0149 G4AttDef("Energy", "Energy Deposited", "Physics", "G4BestUnit", "G4double");
0150 (*store)["Time"] = G4AttDef("Time", "Time", "Physics", "G4BestUnit", "G4double");
0151 (*store)["Pos"] = G4AttDef("Pos", "Position", "Physics", "G4BestUnit", "G4ThreeVector");
0152 }
0153 return store;
0154 }
0155
0156
0157
0158 std::vector<G4AttValue>* Par04Hit::CreateAttValues() const
0159 {
0160 std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
0161 values->push_back(G4AttValue("HitType", "HadPar04Hit", ""));
0162 values->push_back(G4AttValue("Energy", G4BestUnit(fEdep, "Energy"), ""));
0163 values->push_back(G4AttValue("Time", G4BestUnit(fTime, "Time"), ""));
0164 values->push_back(G4AttValue("Pos", G4BestUnit(fPos, "Length"), ""));
0165 return values;
0166 }
0167
0168
0169
0170 void Par04Hit::Print()
0171 {
0172 G4cout << "\tHit " << fEdep / MeV << " MeV from " << fNdep << " deposits at " << fPos / cm
0173 << " cm with rotation " << fRot << " (R,phi,z)= (" << fRhoId << ", " << fPhiId << ", "
0174 << fZId << "), " << fTime << " ns" << G4endl;
0175 }