Geant4 Cross Reference |
1 // 2 // ******************************************************************** 3 // * License and Disclaimer * 4 // * * 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. * 10 // * * 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitation of liability. * 17 // * * 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************************************** 25 // 26 #include "Par03Hit.hh" 27 28 #include "G4AttDef.hh" 29 #include "G4AttDefStore.hh" 30 #include "G4AttValue.hh" 31 #include "G4Colour.hh" 32 #include "G4LogicalVolume.hh" 33 #include "G4SystemOfUnits.hh" 34 #include "G4Tubs.hh" 35 #include "G4UnitsTable.hh" 36 #include "G4VVisManager.hh" 37 #include "G4VisAttributes.hh" 38 39 G4ThreadLocal G4Allocator<Par03Hit>* Par03HitAllocator; 40 41 Par03Hit::Par03Hit() : G4VHit() {} 42 43 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 44 45 Par03Hit::~Par03Hit() = default; 46 47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 48 49 Par03Hit::Par03Hit(const Par03Hit& aRight) : G4VHit() 50 { 51 fEdep = aRight.fEdep; 52 fZId = aRight.fZId; 53 fRhoId = aRight.fRhoId; 54 fPhiId = aRight.fPhiId; 55 fTime = aRight.fTime; 56 fPos = aRight.fPos; 57 fRot = aRight.fRot; 58 fType = aRight.fType; 59 fLogVol = aRight.fLogVol; 60 } 61 62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 63 64 const Par03Hit& Par03Hit::operator=(const Par03Hit& aRight) 65 { 66 fEdep = aRight.fEdep; 67 fZId = aRight.fZId; 68 fRhoId = aRight.fRhoId; 69 fPhiId = aRight.fPhiId; 70 fTime = aRight.fTime; 71 fPos = aRight.fPos; 72 fRot = aRight.fRot; 73 fType = aRight.fType; 74 fLogVol = aRight.fLogVol; 75 return *this; 76 } 77 78 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 79 80 int Par03Hit::operator==(const Par03Hit& aRight) const 81 { 82 return (fRhoId == aRight.fRhoId && fPhiId == aRight.fPhiId && fZId == aRight.fZId); 83 } 84 85 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 86 87 void Par03Hit::Draw() 88 { 89 G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance(); 90 // Hits can be filtered out in visualisation 91 if (!pVVisManager->FilterHit(*this)) return; 92 // Do not draw empty hits 93 if (fEdep < 0) return; 94 if (pVVisManager) { 95 G4Transform3D trans(fRot, fPos); 96 G4VisAttributes attribs; 97 // Create default dimensions 98 G4Tubs solid("draw", 0, 1 * cm, 1 * cm, 0, 0.05 * CLHEP::pi); 99 if (fLogVol) { 100 const G4VisAttributes* pVA = fLogVol->GetVisAttributes(); 101 if (pVA) attribs = *pVA; 102 // Cannot use directly fLogVol due to rho parametrisation (change of 103 // solid!) Recalculation of radius is needed 104 solid = *dynamic_cast<G4Tubs*>(fLogVol->GetSolid()); 105 double dR = solid.GetOuterRadius() - solid.GetInnerRadius(); 106 solid.SetInnerRadius(solid.GetInnerRadius() + fRhoId * dR); 107 solid.SetOuterRadius(solid.GetOuterRadius() + fRhoId * dR); 108 } 109 // Set colours depending on type of hit (full/fast sim) 110 G4double colR = fType == 0 ? 0 : 1; 111 G4double colG = fType == 0 ? 1 : 0; 112 G4double colB = 0; 113 G4Colour colour(colR, colG, colB, 0.5); 114 attribs.SetColour(colour); 115 attribs.SetForceSolid(true); 116 pVVisManager->Draw(solid, attribs, trans); 117 } 118 } 119 120 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 121 122 const std::map<G4String, G4AttDef>* Par03Hit::GetAttDefs() const 123 { 124 G4bool isNew; 125 std::map<G4String, G4AttDef>* store = G4AttDefStore::GetInstance("Par03Hit", isNew); 126 if (isNew) { 127 (*store)["HitType"] = G4AttDef("HitType", "Hit Type", "Physics", "", "G4String"); 128 (*store)["Energy"] = 129 G4AttDef("Energy", "Energy Deposited", "Physics", "G4BestUnit", "G4double"); 130 (*store)["Time"] = G4AttDef("Time", "Time", "Physics", "G4BestUnit", "G4double"); 131 (*store)["Pos"] = G4AttDef("Pos", "Position", "Physics", "G4BestUnit", "G4ThreeVector"); 132 } 133 return store; 134 } 135 136 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 137 138 std::vector<G4AttValue>* Par03Hit::CreateAttValues() const 139 { 140 std::vector<G4AttValue>* values = new std::vector<G4AttValue>; 141 values->push_back(G4AttValue("HitType", "HadPar03Hit", "")); 142 values->push_back(G4AttValue("Energy", G4BestUnit(fEdep, "Energy"), "")); 143 values->push_back(G4AttValue("Time", G4BestUnit(fTime, "Time"), "")); 144 values->push_back(G4AttValue("Pos", G4BestUnit(fPos, "Length"), "")); 145 return values; 146 } 147 148 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 149 150 void Par03Hit::Print() 151 { 152 std::cout << "\tHit " << fEdep / MeV << " MeV at " << fPos / cm << " cm (R,phi,z)= (" << fRhoId 153 << ", " << fPhiId << ", " << fZId << "), " << fTime << " ns" << std::endl; 154 } 155