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