Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 #include "Par04Hit.hh" 27 28 #include "G4AttDef.hh" // for G4AttDef 29 #include "G4AttDefStore.hh" // for GetInstanc 30 #include "G4AttValue.hh" // for G4AttValue 31 #include "G4Colour.hh" // for G4Colour 32 #include "G4SystemOfUnits.hh" // for mm, MeV, 33 #include "G4Tubs.hh" // for G4Tubs 34 #include "G4UnitsTable.hh" // for G4BestUnit 35 #include "G4VVisManager.hh" // for G4VVisMana 36 #include "G4VisAttributes.hh" // for G4VisAtt 37 38 #include <CLHEP/Units/SystemOfUnits.h> // for 39 #include <CLHEP/Vector/ThreeVector.h> // for 40 #include <G4RotationMatrix.hh> // for G4Rotat 41 #include <G4String.hh> // for G4String 42 #include <G4ThreeVector.hh> // for G4ThreeVec 43 #include <G4Transform3D.hh> // for G4Transfor 44 #include <G4VHit.hh> // for G4VHit 45 #include <algorithm> // for max 46 #include <cmath> // for log10 47 #include <iostream> // for operator<<, basic_ 48 #include <string> // for operator< 49 template<class Type> 50 class G4Allocator; 51 52 G4ThreadLocal G4Allocator<Par04Hit>* Par04HitA 53 54 //....oooOO0OOooo........oooOO0OOooo........oo 55 56 Par04Hit::Par04Hit() : G4VHit() {} 57 58 //....oooOO0OOooo........oooOO0OOooo........oo 59 60 Par04Hit::~Par04Hit() = default; 61 62 //....oooOO0OOooo........oooOO0OOooo........oo 63 64 Par04Hit::Par04Hit(const Par04Hit& aRight) : G 65 { 66 fEdep = aRight.fEdep; 67 fNdep = aRight.fNdep; 68 fZId = aRight.fZId; 69 fRhoId = aRight.fRhoId; 70 fPhiId = aRight.fPhiId; 71 fTime = aRight.fTime; 72 fPos = aRight.fPos; 73 fRot = aRight.fRot; 74 fType = aRight.fType; 75 fLogVol = aRight.fLogVol; 76 } 77 78 //....oooOO0OOooo........oooOO0OOooo........oo 79 80 const Par04Hit& Par04Hit::operator=(const Par0 81 { 82 fEdep = aRight.fEdep; 83 fNdep = aRight.fNdep; 84 fZId = aRight.fZId; 85 fRhoId = aRight.fRhoId; 86 fPhiId = aRight.fPhiId; 87 fTime = aRight.fTime; 88 fPos = aRight.fPos; 89 fRot = aRight.fRot; 90 fType = aRight.fType; 91 fLogVol = aRight.fLogVol; 92 return *this; 93 } 94 95 //....oooOO0OOooo........oooOO0OOooo........oo 96 97 int Par04Hit::operator==(const Par04Hit& aRigh 98 { 99 return (fRhoId == aRight.fRhoId && fPhiId == 100 } 101 102 //....oooOO0OOooo........oooOO0OOooo........oo 103 104 void Par04Hit::Draw() 105 { 106 /// Arbitrary size corresponds to the exampl 107 G4ThreeVector meshSize(2.325 * mm, 2 * CLHEP 108 G4int numPhiCells = CLHEP::pi * 2. / meshSiz 109 G4VVisManager* pVVisManager = G4VVisManager: 110 // Hits can be filtered out in visualisation 111 if (!pVVisManager->FilterHit(*this)) return; 112 // Do not plot hits from parallel world 113 if (fType >= 2) return; 114 // Do not draw empty hits 115 if (fEdep <= 0) return; 116 // Do not plot if default values were not ch 117 if (fRhoId == -1 && fZId == -1 && fPhiId == 118 if (pVVisManager) { 119 G4Transform3D trans(fRot, fPos); 120 G4VisAttributes attribs; 121 G4Tubs solid("draw", fRhoId * meshSize.x() 122 (-numPhiCells / 2. + fPhiId) 123 // Set colours depending on type of hit (f 124 G4double colR = fType == 0 ? 0 : 1; 125 G4double colG = fType == 0 ? 1 : 0; 126 G4double colB = 0; 127 // Set transparency depending on the energ 128 // Arbitrary formula 129 G4double alpha = 2 * std::log10(fEdep + 1) 130 G4Colour colour(colR, colG, colB, alpha); 131 attribs.SetColour(colour); 132 attribs.SetForceSolid(true); 133 pVVisManager->Draw(solid, attribs, trans); 134 } 135 } 136 137 //....oooOO0OOooo........oooOO0OOooo........oo 138 139 const std::map<G4String, G4AttDef>* Par04Hit:: 140 { 141 G4bool isNew; 142 std::map<G4String, G4AttDef>* store = G4AttD 143 if (isNew) { 144 (*store)["HitType"] = G4AttDef("HitType", 145 (*store)["Energy"] = 146 G4AttDef("Energy", "Energy Deposited", " 147 (*store)["Time"] = G4AttDef("Time", "Time" 148 (*store)["Pos"] = G4AttDef("Pos", "Positio 149 } 150 return store; 151 } 152 153 //....oooOO0OOooo........oooOO0OOooo........oo 154 155 std::vector<G4AttValue>* Par04Hit::CreateAttVa 156 { 157 std::vector<G4AttValue>* values = new std::v 158 values->push_back(G4AttValue("HitType", "Had 159 values->push_back(G4AttValue("Energy", G4Bes 160 values->push_back(G4AttValue("Time", G4BestU 161 values->push_back(G4AttValue("Pos", G4BestUn 162 return values; 163 } 164 165 //....oooOO0OOooo........oooOO0OOooo........oo 166 167 void Par04Hit::Print() 168 { 169 std::cout << "\tHit " << fEdep / MeV << " Me 170 << " cm rotation " << fRot << " (R 171 << fZId << "), " << fTime << " ns" 172 } 173