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 // 26 // 27 /// \file optical/wls/src/WLSTrajectory.cc 27 /// \file optical/wls/src/WLSTrajectory.cc 28 /// \brief Implementation of the WLSTrajectory 28 /// \brief Implementation of the WLSTrajectory class 29 // 29 // 30 // 30 // 31 31 32 #include "WLSTrajectory.hh" 32 #include "WLSTrajectory.hh" 33 33 34 #include "WLSTrajectoryPoint.hh" 34 #include "WLSTrajectoryPoint.hh" 35 35 36 #include "G4AttDef.hh" 36 #include "G4AttDef.hh" 37 #include "G4AttDefStore.hh" 37 #include "G4AttDefStore.hh" 38 #include "G4AttValue.hh" 38 #include "G4AttValue.hh" 39 #include "G4Colour.hh" 39 #include "G4Colour.hh" 40 #include "G4ParticleTable.hh" 40 #include "G4ParticleTable.hh" 41 #include "G4ParticleTypes.hh" 41 #include "G4ParticleTypes.hh" 42 #include "G4Polyline.hh" 42 #include "G4Polyline.hh" 43 #include "G4Polymarker.hh" 43 #include "G4Polymarker.hh" 44 #include "G4UIcommand.hh" 44 #include "G4UIcommand.hh" 45 #include "G4UnitsTable.hh" 45 #include "G4UnitsTable.hh" 46 #include "G4VVisManager.hh" << 47 #include "G4VisAttributes.hh" 46 #include "G4VisAttributes.hh" >> 47 #include "G4VVisManager.hh" 48 48 49 G4ThreadLocal G4Allocator<WLSTrajectory>* WLST 49 G4ThreadLocal G4Allocator<WLSTrajectory>* WLSTrajectoryAllocator = nullptr; 50 50 51 //....oooOO0OOooo........oooOO0OOooo........oo 51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 52 52 >> 53 WLSTrajectory::WLSTrajectory() >> 54 : fpPointsContainer(0) >> 55 , fTrackID(0) >> 56 , fParentID(0) >> 57 , fPDGCharge(0.0) >> 58 , fPDGEncoding(0) >> 59 , fParticleName("") >> 60 , fInitialMomentum(G4ThreeVector()) >> 61 { >> 62 fParticleDefinition = nullptr; >> 63 } >> 64 >> 65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 66 53 WLSTrajectory::WLSTrajectory(const G4Track* aT 67 WLSTrajectory::WLSTrajectory(const G4Track* aTrack) 54 { 68 { 55 fParticleDefinition = aTrack->GetDefinition( 69 fParticleDefinition = aTrack->GetDefinition(); 56 fParticleName = fParticleDefinition->GetPart << 70 fParticleName = fParticleDefinition->GetParticleName(); 57 fPDGCharge = fParticleDefinition->GetPDGChar << 71 fPDGCharge = fParticleDefinition->GetPDGCharge(); 58 fPDGEncoding = fParticleDefinition->GetPDGEn << 72 fPDGEncoding = fParticleDefinition->GetPDGEncoding(); 59 fTrackID = aTrack->GetTrackID(); << 73 fTrackID = aTrack->GetTrackID(); 60 fParentID = aTrack->GetParentID(); << 74 fParentID = aTrack->GetParentID(); 61 fInitialMomentum = aTrack->GetMomentum(); << 75 fInitialMomentum = aTrack->GetMomentum(); 62 fpPointsContainer = new WLSTrajectoryPointCo << 76 fpPointsContainer = new WLSTrajectoryPointContainer(); 63 // Following is for the first trajectory poi 77 // Following is for the first trajectory point 64 fpPointsContainer->push_back(new WLSTrajecto 78 fpPointsContainer->push_back(new WLSTrajectoryPoint(aTrack)); 65 } 79 } 66 80 67 //....oooOO0OOooo........oooOO0OOooo........oo 81 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 68 82 69 WLSTrajectory::WLSTrajectory(WLSTrajectory& ri << 83 WLSTrajectory::WLSTrajectory(WLSTrajectory& right) >> 84 : G4VTrajectory() 70 { 85 { 71 fParticleDefinition = right.fParticleDefinit 86 fParticleDefinition = right.fParticleDefinition; 72 fParticleName = right.fParticleName; << 87 fParticleName = right.fParticleName; 73 fPDGCharge = right.fPDGCharge; << 88 fPDGCharge = right.fPDGCharge; 74 fPDGEncoding = right.fPDGEncoding; << 89 fPDGEncoding = right.fPDGEncoding; 75 fTrackID = right.fTrackID; << 90 fTrackID = right.fTrackID; 76 fParentID = right.fParentID; << 91 fParentID = right.fParentID; 77 fInitialMomentum = right.fInitialMomentum; << 92 fInitialMomentum = right.fInitialMomentum; 78 fpPointsContainer = new WLSTrajectoryPointCo << 93 fpPointsContainer = new WLSTrajectoryPointContainer(); 79 << 94 80 for (size_t i = 0; i < right.fpPointsContain << 95 for(size_t i = 0; i < right.fpPointsContainer->size(); ++i) 81 auto rightPoint = (WLSTrajectoryPoint*)((* << 96 { >> 97 WLSTrajectoryPoint* rightPoint = >> 98 (WLSTrajectoryPoint*) ((*(right.fpPointsContainer))[i]); 82 fpPointsContainer->push_back(new WLSTrajec 99 fpPointsContainer->push_back(new WLSTrajectoryPoint(*rightPoint)); 83 } 100 } 84 } 101 } 85 102 86 //....oooOO0OOooo........oooOO0OOooo........oo 103 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 87 104 88 WLSTrajectory::~WLSTrajectory() 105 WLSTrajectory::~WLSTrajectory() 89 { 106 { 90 for (size_t i = 0; i < fpPointsContainer->si << 107 for(size_t i = 0; i < fpPointsContainer->size(); ++i) 91 delete (*fpPointsContainer)[i]; << 108 { >> 109 delete(*fpPointsContainer)[i]; 92 } 110 } 93 fpPointsContainer->clear(); 111 fpPointsContainer->clear(); 94 delete fpPointsContainer; 112 delete fpPointsContainer; 95 } 113 } 96 114 97 //....oooOO0OOooo........oooOO0OOooo........oo 115 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 98 116 99 void WLSTrajectory::ShowTrajectory(std::ostrea 117 void WLSTrajectory::ShowTrajectory(std::ostream& os) const 100 { 118 { 101 // Invoke the default implementation in G4VT 119 // Invoke the default implementation in G4VTrajectory... 102 G4VTrajectory::ShowTrajectory(os); 120 G4VTrajectory::ShowTrajectory(os); 103 // ... or override with your own code here. 121 // ... or override with your own code here. 104 } 122 } 105 123 106 //....oooOO0OOooo........oooOO0OOooo........oo 124 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 107 125 108 void WLSTrajectory::AppendStep(const G4Step* a 126 void WLSTrajectory::AppendStep(const G4Step* aStep) 109 { 127 { 110 fpPointsContainer->push_back(new WLSTrajecto 128 fpPointsContainer->push_back(new WLSTrajectoryPoint(aStep)); 111 } 129 } 112 130 113 //....oooOO0OOooo........oooOO0OOooo........oo 131 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 114 132 115 G4ParticleDefinition* WLSTrajectory::GetPartic 133 G4ParticleDefinition* WLSTrajectory::GetParticleDefinition() 116 { 134 { 117 return (G4ParticleTable::GetParticleTable()- 135 return (G4ParticleTable::GetParticleTable()->FindParticle(fParticleName)); 118 } 136 } 119 137 120 //....oooOO0OOooo........oooOO0OOooo........oo 138 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 121 139 122 void WLSTrajectory::MergeTrajectory(G4VTraject 140 void WLSTrajectory::MergeTrajectory(G4VTrajectory* secondTrajectory) 123 { 141 { 124 if (!secondTrajectory) return; << 142 if(!secondTrajectory) >> 143 return; 125 144 126 auto second = (WLSTrajectory*)secondTrajecto << 145 WLSTrajectory* second = (WLSTrajectory*) secondTrajectory; 127 G4int ent = second->GetPointEntries(); << 146 G4int ent = second->GetPointEntries(); 128 // initial point of the second trajectory sh 147 // initial point of the second trajectory should not be merged 129 for (G4int i = 1; i < ent; ++i) { << 148 for(G4int i = 1; i < ent; ++i) >> 149 { 130 fpPointsContainer->push_back((*(second->fp 150 fpPointsContainer->push_back((*(second->fpPointsContainer))[i]); 131 } 151 } 132 delete (*second->fpPointsContainer)[0]; << 152 delete(*second->fpPointsContainer)[0]; 133 second->fpPointsContainer->clear(); 153 second->fpPointsContainer->clear(); 134 } 154 } 135 155 136 //....oooOO0OOooo........oooOO0OOooo........oo 156 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 137 157 138 const std::map<G4String, G4AttDef>* WLSTraject 158 const std::map<G4String, G4AttDef>* WLSTrajectory::GetAttDefs() const 139 { 159 { 140 G4bool isNew; 160 G4bool isNew; 141 std::map<G4String, G4AttDef>* store = G4AttD << 161 std::map<G4String, G4AttDef>* store = >> 162 G4AttDefStore::GetInstance("Trajectory", isNew); 142 163 143 if (isNew) { << 164 if(isNew) >> 165 { 144 G4String ID("ID"); 166 G4String ID("ID"); 145 (*store)[ID] = G4AttDef(ID, "Track ID", "B 167 (*store)[ID] = G4AttDef(ID, "Track ID", "Bookkeeping", "", "G4int"); 146 168 147 G4String PID("PID"); 169 G4String PID("PID"); 148 (*store)[PID] = G4AttDef(PID, "Parent ID", 170 (*store)[PID] = G4AttDef(PID, "Parent ID", "Bookkeeping", "", "G4int"); 149 171 150 G4String PN("PN"); 172 G4String PN("PN"); 151 (*store)[PN] = G4AttDef(PN, "Particle Name 173 (*store)[PN] = G4AttDef(PN, "Particle Name", "Physics", "", "G4String"); 152 174 153 G4String Ch("Ch"); 175 G4String Ch("Ch"); 154 (*store)[Ch] = G4AttDef(Ch, "Charge", "Phy 176 (*store)[Ch] = G4AttDef(Ch, "Charge", "Physics", "e+", "G4double"); 155 177 156 G4String PDG("PDG"); 178 G4String PDG("PDG"); 157 (*store)[PDG] = G4AttDef(PDG, "PDG Encodin 179 (*store)[PDG] = G4AttDef(PDG, "PDG Encoding", "Physics", "", "G4int"); 158 180 159 G4String IMom("IMom"); 181 G4String IMom("IMom"); 160 (*store)[IMom] = G4AttDef(IMom, "Momentum << 182 (*store)[IMom] = G4AttDef(IMom, "Momentum of track at start of trajectory", 161 "G4BestUnit", "G << 183 "Physics", "G4BestUnit", "G4ThreeVector"); 162 184 163 G4String IMag("IMag"); 185 G4String IMag("IMag"); 164 (*store)[IMag] = G4AttDef(IMag, "Magnitude << 186 (*store)[IMag] = 165 "Physics", "G4Be << 187 G4AttDef(IMag, "Magnitude of momentum of track at start of trajectory", >> 188 "Physics", "G4BestUnit", "G4double"); 166 189 167 G4String NTP("NTP"); 190 G4String NTP("NTP"); 168 (*store)[NTP] = G4AttDef(NTP, "No. of poin 191 (*store)[NTP] = G4AttDef(NTP, "No. of points", "Bookkeeping", "", "G4int"); 169 } 192 } 170 return store; 193 return store; 171 } 194 } 172 195 173 //....oooOO0OOooo........oooOO0OOooo........oo 196 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 174 197 175 std::vector<G4AttValue>* WLSTrajectory::Create 198 std::vector<G4AttValue>* WLSTrajectory::CreateAttValues() const 176 { 199 { 177 auto values = new std::vector<G4AttValue>; << 200 std::vector<G4AttValue>* values = new std::vector<G4AttValue>; 178 201 179 values->push_back(G4AttValue("ID", G4UIcomma << 202 values->push_back( >> 203 G4AttValue("ID", G4UIcommand::ConvertToString(fTrackID), "")); 180 204 181 values->push_back(G4AttValue("PID", G4UIcomm << 205 values->push_back( >> 206 G4AttValue("PID", G4UIcommand::ConvertToString(fParentID), "")); 182 207 183 values->push_back(G4AttValue("PN", fParticle 208 values->push_back(G4AttValue("PN", fParticleName, "")); 184 209 185 values->push_back(G4AttValue("Ch", G4UIcomma << 210 values->push_back( >> 211 G4AttValue("Ch", G4UIcommand::ConvertToString(fPDGCharge), "")); 186 212 187 values->push_back(G4AttValue("PDG", G4UIcomm << 213 values->push_back( >> 214 G4AttValue("PDG", G4UIcommand::ConvertToString(fPDGEncoding), "")); 188 215 189 values->push_back(G4AttValue("IMom", G4BestU << 216 values->push_back( >> 217 G4AttValue("IMom", G4BestUnit(fInitialMomentum, "Energy"), "")); 190 218 191 values->push_back(G4AttValue("IMag", G4BestU << 219 values->push_back( >> 220 G4AttValue("IMag", G4BestUnit(fInitialMomentum.mag(), "Energy"), "")); 192 221 193 values->push_back(G4AttValue("NTP", G4UIcomm << 222 values->push_back( >> 223 G4AttValue("NTP", G4UIcommand::ConvertToString(GetPointEntries()), "")); 194 224 195 return values; 225 return values; 196 } 226 } 197 227