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