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 // G4PrimaryTransformer class implementation << 27 // 26 // 28 // Author: Makoto Asai, 1999 << 27 // $Id: G4PrimaryTransformer.cc,v 1.27 2006/06/29 18:09:58 gunter Exp $ 29 // ------------------------------------------- << 28 // GEANT4 tag $Name: geant4-08-03-patch-02 $ >> 29 // 30 30 31 #include "G4PrimaryTransformer.hh" 31 #include "G4PrimaryTransformer.hh" 32 #include "G4SystemOfUnits.hh" << 33 #include "G4Event.hh" 32 #include "G4Event.hh" 34 #include "G4PrimaryVertex.hh" 33 #include "G4PrimaryVertex.hh" 35 #include "G4ParticleDefinition.hh" 34 #include "G4ParticleDefinition.hh" 36 #include "G4DynamicParticle.hh" 35 #include "G4DynamicParticle.hh" 37 #include "G4Track.hh" 36 #include "G4Track.hh" 38 #include "G4ThreeVector.hh" 37 #include "G4ThreeVector.hh" 39 #include "G4DecayProducts.hh" 38 #include "G4DecayProducts.hh" 40 #include "G4UnitsTable.hh" 39 #include "G4UnitsTable.hh" 41 #include "G4ios.hh" 40 #include "G4ios.hh" 42 #include "Randomize.hh" 41 #include "Randomize.hh" 43 42 44 G4double G4PrimaryTransformer::kETolerance = 1 << 45 G4ExceptionSeverity G4PrimaryTransformer::kETS << 46 << 47 G4PrimaryTransformer::G4PrimaryTransformer() 43 G4PrimaryTransformer::G4PrimaryTransformer() >> 44 :verboseLevel(0),trackID(0),unknown(0),unknownParticleDefined(false) 48 { 45 { 49 particleTable = G4ParticleTable::GetParticle 46 particleTable = G4ParticleTable::GetParticleTable(); 50 CheckUnknown(); 47 CheckUnknown(); 51 } 48 } 52 49 >> 50 G4PrimaryTransformer::~G4PrimaryTransformer() >> 51 {;} >> 52 53 void G4PrimaryTransformer::CheckUnknown() 53 void G4PrimaryTransformer::CheckUnknown() 54 { 54 { 55 unknown = particleTable->FindParticle("unkno 55 unknown = particleTable->FindParticle("unknown"); 56 unknownParticleDefined = unknown != nullptr; << 56 if(unknown) 57 chargedunknown = particleTable->FindParticle << 57 { unknownParticleDefined = true; } 58 chargedUnknownParticleDefined = chargedunkno << 58 else 59 opticalphoton = particleTable->FindParticle( << 59 { unknownParticleDefined = false; } 60 opticalphotonDefined = opticalphoton != null << 61 } 60 } 62 << 61 63 G4TrackVector* << 62 G4TrackVector* G4PrimaryTransformer::GimmePrimaries(G4Event* anEvent,G4int trackIDCounter) 64 G4PrimaryTransformer::GimmePrimaries(G4Event* << 65 { 63 { 66 trackID = trackIDCounter; 64 trackID = trackIDCounter; 67 65 68 for(auto tr : TV) delete tr; << 66 //TV.clearAndDestroy(); >> 67 for( size_t ii=0; ii<TV.size();ii++) >> 68 { delete TV[ii]; } 69 TV.clear(); 69 TV.clear(); 70 << 70 G4int n_vertex = anEvent->GetNumberOfPrimaryVertex(); 71 // Loop over vertices << 71 if(n_vertex==0) return 0; 72 // << 72 for( G4int i=0; i<n_vertex; i++ ) 73 G4PrimaryVertex* nextVertex = anEvent->GetPr << 73 { GenerateTracks( anEvent->GetPrimaryVertex(i) ); } 74 while(nextVertex != nullptr) // Loop checkin << 75 { << 76 GenerateTracks(nextVertex); << 77 nextVertex = nextVertex->GetNext(); << 78 } << 79 return &TV; 74 return &TV; 80 } 75 } 81 76 82 void G4PrimaryTransformer::GenerateTracks(G4Pr 77 void G4PrimaryTransformer::GenerateTracks(G4PrimaryVertex* primaryVertex) 83 { 78 { 84 G4double X0 = primaryVertex->GetX0(); 79 G4double X0 = primaryVertex->GetX0(); 85 G4double Y0 = primaryVertex->GetY0(); 80 G4double Y0 = primaryVertex->GetY0(); 86 G4double Z0 = primaryVertex->GetZ0(); 81 G4double Z0 = primaryVertex->GetZ0(); 87 G4double T0 = primaryVertex->GetT0(); 82 G4double T0 = primaryVertex->GetT0(); 88 G4double WV = primaryVertex->GetWeight(); 83 G4double WV = primaryVertex->GetWeight(); 89 84 90 #ifdef G4VERBOSE 85 #ifdef G4VERBOSE 91 if(verboseLevel>2) << 86 if(verboseLevel>1) 92 { 87 { 93 primaryVertex->Print(); << 94 } << 95 else if (verboseLevel==1) << 96 { << 97 G4cout << "G4PrimaryTransformer::PrimaryVe 88 G4cout << "G4PrimaryTransformer::PrimaryVertex (" 98 << X0 / mm << "(mm)," 89 << X0 / mm << "(mm)," 99 << Y0 / mm << "(mm)," 90 << Y0 / mm << "(mm)," 100 << Z0 / mm << "(mm)," 91 << Z0 / mm << "(mm)," 101 << T0 / nanosecond << "(nsec))" << 92 << T0 / nanosecond << "(nsec))" << G4endl; 102 } 93 } 103 #endif 94 #endif 104 95 105 G4PrimaryParticle* primaryParticle = primary 96 G4PrimaryParticle* primaryParticle = primaryVertex->GetPrimary(); 106 while( primaryParticle != nullptr ) // Loop << 97 while( primaryParticle != 0 ) 107 { 98 { 108 GenerateSingleTrack( primaryParticle, X0, 99 GenerateSingleTrack( primaryParticle, X0, Y0, Z0, T0, WV ); 109 primaryParticle = primaryParticle->GetNext 100 primaryParticle = primaryParticle->GetNext(); 110 } 101 } 111 } 102 } 112 103 113 void G4PrimaryTransformer:: << 104 void G4PrimaryTransformer::GenerateSingleTrack 114 GenerateSingleTrack( G4PrimaryParticle* primar << 105 (G4PrimaryParticle* primaryParticle, 115 G4double x0, G4double y0, << 106 G4double x0,G4double y0,G4double z0,G4double t0,G4double wv) 116 G4double t0, G4double wv) << 107 { 117 { << 108 static G4ParticleDefinition* optPhoton = 0; >> 109 static G4int nWarn = 0; >> 110 if(!optPhoton) optPhoton = particleTable->FindParticle("opticalphoton"); >> 111 118 G4ParticleDefinition* partDef = GetDefinitio 112 G4ParticleDefinition* partDef = GetDefinition(primaryParticle); 119 if(!IsGoodForTrack(partDef)) 113 if(!IsGoodForTrack(partDef)) 120 { // The particle cannot be converted to G4 << 114 // The particle cannot be converted to G4Track, check daughters >> 115 { 121 #ifdef G4VERBOSE 116 #ifdef G4VERBOSE 122 if(verboseLevel>1) << 117 if(verboseLevel>2) 123 { 118 { 124 G4cout << "Primary particle (PDGcode " < 119 G4cout << "Primary particle (PDGcode " << primaryParticle->GetPDGcode() 125 << ") --- Ignored" << G4endl; 120 << ") --- Ignored" << G4endl; 126 } 121 } 127 #endif 122 #endif 128 G4PrimaryParticle* daughter = primaryParti 123 G4PrimaryParticle* daughter = primaryParticle->GetDaughter(); 129 while(daughter != nullptr) // Loop checkin << 124 while(daughter) 130 { 125 { 131 GenerateSingleTrack(daughter,x0,y0,z0,t0 126 GenerateSingleTrack(daughter,x0,y0,z0,t0,wv); 132 daughter = daughter->GetNext(); 127 daughter = daughter->GetNext(); 133 } 128 } 134 } 129 } 135 else // The particle is defined in GEANT4 << 130 >> 131 // The particle is defined in GEANT4 >> 132 else 136 { 133 { 137 // Create G4DynamicParticle object 134 // Create G4DynamicParticle object 138 #ifdef G4VERBOSE 135 #ifdef G4VERBOSE 139 if(verboseLevel>1) 136 if(verboseLevel>1) 140 { 137 { 141 G4cout << "Primary particle (" << partDe 138 G4cout << "Primary particle (" << partDef->GetParticleName() 142 << ") --- Transferred with moment << 139 << ") --- Transfered with momentum " << primaryParticle->GetMomentum() 143 << primaryParticle->GetMomentum() << 144 << G4endl; 140 << G4endl; 145 } 141 } 146 #endif 142 #endif 147 // Check the mass of the "real" particle << 143 G4DynamicParticle* DP = 148 // N.B. PDG code 0 is used for artificial << 144 new G4DynamicParticle(partDef,primaryParticle->GetMomentum()); 149 if(primaryParticle->GetPDGcode() != 0 && k << 145 if(partDef==optPhoton && primaryParticle->GetPolarization().mag2()==0.) 150 { << 151 G4double pmas = partDef->GetPDGMass(); << 152 if(std::abs(pmas - primaryParticle->GetM << 153 G4ExceptionDescription ed; << 154 ed << "Primary particle PDG=" << prima << 155 << " deltaMass(MeV)=" << (std::abs( << 156 << " is larger than the tolerance(M << 157 << "\n Specified mass(MeV)=" << (pr << 158 << " while PDG mass(MEV)=" << pmas/ << 159 << "\n To change the tolerance or t << 160 << " use G4PrimaryTransformer::SetK << 161 G4Exception("G4PrimaryParticle::Set4Mo << 162 } << 163 } << 164 auto* DP = << 165 new G4DynamicParticle(partDef, << 166 primaryParticle->G << 167 primaryParticle->G << 168 if(opticalphotonDefined && partDef==optica << 169 && primaryParticle->GetPolarization().m << 170 { 146 { 171 if(nWarn<10) 147 if(nWarn<10) 172 { 148 { 173 G4Exception("G4PrimaryTransformer::Gen << 149 G4Exception("G4PrimaryTransformer::GenerateSingleTrack","ZeroPolarization",JustWarning, 174 "ZeroPolarization", JustWa << 150 "Polarization of the optical photon is null. Random polarization is assumed."); 175 "Polarization of the optic << 176 Random polarization is as << 177 G4cerr << "This warning message is iss 151 G4cerr << "This warning message is issued up to 10 times." << G4endl; 178 ++nWarn; << 152 nWarn++; 179 } 153 } 180 154 181 G4double angle = G4UniformRand() * 360.0 155 G4double angle = G4UniformRand() * 360.0*deg; 182 G4ThreeVector normal (1., 0., 0.); 156 G4ThreeVector normal (1., 0., 0.); 183 G4ThreeVector kphoton = DP->GetMomentumD 157 G4ThreeVector kphoton = DP->GetMomentumDirection(); 184 G4ThreeVector product = normal.cross(kph 158 G4ThreeVector product = normal.cross(kphoton); 185 G4double modul2 = product*product; 159 G4double modul2 = product*product; 186 160 187 G4ThreeVector e_perpend (0., 0., 1.); 161 G4ThreeVector e_perpend (0., 0., 1.); 188 if (modul2 > 0.) e_perpend = (1./std::sq 162 if (modul2 > 0.) e_perpend = (1./std::sqrt(modul2))*product; 189 G4ThreeVector e_paralle = e_perpend.c 163 G4ThreeVector e_paralle = e_perpend.cross(kphoton); 190 164 191 G4ThreeVector polar = std::cos(angle)*e_ << 165 G4ThreeVector polar = std::cos(angle)*e_paralle + std::sin(angle)*e_perpend; 192 + std::sin(angle)*e_ << 193 DP->SetPolarization(polar.x(),polar.y(), 166 DP->SetPolarization(polar.x(),polar.y(),polar.z()); 194 } 167 } 195 else 168 else 196 { 169 { 197 DP->SetPolarization(primaryParticle->Get 170 DP->SetPolarization(primaryParticle->GetPolX(), 198 primaryParticle->Get 171 primaryParticle->GetPolY(), 199 primaryParticle->Get 172 primaryParticle->GetPolZ()); 200 } 173 } 201 if(primaryParticle->GetProperTime()>=0.0) << 174 if(primaryParticle->GetProperTime()>0.0) 202 { << 175 { DP->SetPreAssignedDecayProperTime(primaryParticle->GetProperTime()); } 203 DP->SetPreAssignedDecayProperTime(primar << 204 } << 205 << 206 // Set Mass if it is specified << 207 // << 208 G4double pmas = primaryParticle->GetMass() << 209 if(pmas>=0.) { DP->SetMass(pmas); } << 210 << 211 // Set Charge if it is specified 176 // Set Charge if it is specified 212 // << 177 if (primaryParticle->GetCharge()<DBL_MAX) { 213 if (primaryParticle->GetCharge()<DBL_MAX) << 178 DP->SetCharge(primaryParticle->GetCharge()); 214 { << 215 if (partDef->GetAtomicNumber() <0) << 216 { << 217 DP->SetCharge(primaryParticle->GetChar << 218 } << 219 else // ions << 220 { << 221 G4int iz = partDef->GetAtomicNumber(); << 222 auto iq = static_cast<G4int>(primaryP << 223 G4int n_e = iz - iq; << 224 if (n_e>0) DP->AddElectron(0,n_e); << 225 } << 226 } 179 } >> 180 // Set Mass if it is specified >> 181 G4double pmas = primaryParticle->GetMass(); >> 182 if(pmas>=0.) >> 183 { DP->SetMass(pmas); } 227 // Set decay products to the DynamicPartic 184 // Set decay products to the DynamicParticle 228 // << 229 SetDecayProducts( primaryParticle, DP ); 185 SetDecayProducts( primaryParticle, DP ); 230 << 231 // Set primary particle 186 // Set primary particle 232 // << 233 DP->SetPrimaryParticle(primaryParticle); 187 DP->SetPrimaryParticle(primaryParticle); 234 << 235 // Set PDG code if it is different from G4 188 // Set PDG code if it is different from G4ParticleDefinition 236 // << 237 if(partDef->GetPDGEncoding()==0 && primary 189 if(partDef->GetPDGEncoding()==0 && primaryParticle->GetPDGcode()!=0) 238 { 190 { 239 DP->SetPDGcode(primaryParticle->GetPDGco 191 DP->SetPDGcode(primaryParticle->GetPDGcode()); 240 } 192 } 241 << 242 // Check the particle is properly construc 193 // Check the particle is properly constructed 243 // << 244 if(!CheckDynamicParticle(DP)) 194 if(!CheckDynamicParticle(DP)) 245 { 195 { 246 delete DP; 196 delete DP; 247 return; 197 return; 248 } 198 } 249 << 250 // Create G4Track object 199 // Create G4Track object 251 // << 200 G4Track* track = new G4Track(DP,t0,G4ThreeVector(x0,y0,z0)); 252 auto track = new G4Track(DP,t0,G4ThreeVec << 253 << 254 // Set trackID and let primary particle kn 201 // Set trackID and let primary particle know it 255 // << 202 trackID++; 256 ++trackID; << 257 track->SetTrackID(trackID); 203 track->SetTrackID(trackID); 258 primaryParticle->SetTrackID(trackID); 204 primaryParticle->SetTrackID(trackID); 259 << 260 // Set parentID to 0 as a primary particle 205 // Set parentID to 0 as a primary particle 261 // << 262 track->SetParentID(0); 206 track->SetParentID(0); 263 << 264 // Set weight ( vertex weight * particle w 207 // Set weight ( vertex weight * particle weight ) 265 // << 266 track->SetWeight(wv*(primaryParticle->GetW 208 track->SetWeight(wv*(primaryParticle->GetWeight())); 267 << 268 // Store it to G4TrackVector 209 // Store it to G4TrackVector 269 // << 270 TV.push_back( track ); 210 TV.push_back( track ); 271 } 211 } 272 } 212 } 273 213 274 void G4PrimaryTransformer:: << 214 void G4PrimaryTransformer::SetDecayProducts 275 SetDecayProducts(G4PrimaryParticle* mother, G4 << 215 (G4PrimaryParticle* mother, G4DynamicParticle* motherDP) 276 { 216 { 277 G4PrimaryParticle* daughter = mother->GetDau 217 G4PrimaryParticle* daughter = mother->GetDaughter(); 278 if(daughter == nullptr) return; << 218 if(!daughter) return; 279 auto* decayProducts << 219 G4DecayProducts* decayProducts = (G4DecayProducts*)(motherDP->GetPreAssignedDecayProducts() ); 280 = (G4DecayProducts*)(motherDP->GetPreAssig << 220 if(!decayProducts) 281 if(decayProducts == nullptr) << 282 { 221 { 283 decayProducts = new G4DecayProducts(*mothe 222 decayProducts = new G4DecayProducts(*motherDP); 284 motherDP->SetPreAssignedDecayProducts(deca 223 motherDP->SetPreAssignedDecayProducts(decayProducts); 285 } 224 } 286 while(daughter != nullptr) << 225 while(daughter) 287 { 226 { 288 G4ParticleDefinition* partDef = GetDefinit 227 G4ParticleDefinition* partDef = GetDefinition(daughter); 289 if(!IsGoodForTrack(partDef)) 228 if(!IsGoodForTrack(partDef)) 290 { 229 { 291 #ifdef G4VERBOSE 230 #ifdef G4VERBOSE 292 if(verboseLevel>2) 231 if(verboseLevel>2) 293 { 232 { 294 G4cout << " >> Decay product (PDGcode 233 G4cout << " >> Decay product (PDGcode " << daughter->GetPDGcode() 295 << ") --- Ignored" << G4endl; 234 << ") --- Ignored" << G4endl; 296 } 235 } 297 #endif 236 #endif 298 SetDecayProducts(daughter,motherDP); 237 SetDecayProducts(daughter,motherDP); 299 } 238 } 300 else 239 else 301 { 240 { 302 #ifdef G4VERBOSE 241 #ifdef G4VERBOSE 303 if(verboseLevel>1) 242 if(verboseLevel>1) 304 { 243 { 305 G4cout << " >> Decay product (" << par 244 G4cout << " >> Decay product (" << partDef->GetParticleName() 306 << ") --- Attached with momentu 245 << ") --- Attached with momentum " << daughter->GetMomentum() 307 << G4endl; 246 << G4endl; 308 } 247 } 309 #endif 248 #endif 310 auto* DP << 249 G4DynamicParticle*DP 311 = new G4DynamicParticle(partDef,daught 250 = new G4DynamicParticle(partDef,daughter->GetMomentum()); 312 DP->SetPrimaryParticle(daughter); 251 DP->SetPrimaryParticle(daughter); 313 << 314 // Decay proper time for daughter 252 // Decay proper time for daughter 315 // << 253 if(daughter->GetProperTime()>0.0) 316 if(daughter->GetProperTime()>=0.0) << 254 { DP->SetPreAssignedDecayProperTime(daughter->GetProperTime()); } 317 { << 255 // Set Charge is specified 318 DP->SetPreAssignedDecayProperTime(daug << 256 if (daughter->GetCharge()<DBL_MAX) { 319 } << 320 << 321 // Set Charge and Mass is specified << 322 // << 323 if (daughter->GetCharge()<DBL_MAX) << 324 { << 325 DP->SetCharge(daughter->GetCharge()); 257 DP->SetCharge(daughter->GetCharge()); 326 } 258 } 327 G4double pmas = daughter->GetMass(); 259 G4double pmas = daughter->GetMass(); 328 if(pmas>=0.) 260 if(pmas>=0.) 329 { << 261 { DP->SetMass(pmas); } 330 DP->SetMass(pmas); << 331 } << 332 << 333 // Set Polarization << 334 // << 335 DP->SetPolarization(daughter->GetPolX(), << 336 daughter->GetPolY(), << 337 daughter->GetPolZ()) << 338 decayProducts->PushProducts(DP); 262 decayProducts->PushProducts(DP); 339 SetDecayProducts(daughter,DP); 263 SetDecayProducts(daughter,DP); 340 << 341 // Check the particle is properly constr 264 // Check the particle is properly constructed 342 // << 343 if(!CheckDynamicParticle(DP)) 265 if(!CheckDynamicParticle(DP)) 344 { 266 { 345 delete DP; 267 delete DP; 346 return; 268 return; 347 } 269 } 348 } 270 } 349 daughter = daughter->GetNext(); 271 daughter = daughter->GetNext(); 350 } 272 } 351 } 273 } 352 274 353 void G4PrimaryTransformer::SetUnknownParticleD << 275 void G4PrimaryTransformer::SetUnknnownParticleDefined(G4bool vl) 354 { 276 { 355 unknownParticleDefined = vl; 277 unknownParticleDefined = vl; 356 if(unknownParticleDefined && (unknown == nul << 278 if(unknownParticleDefined && !unknown) 357 { << 279 { G4cerr << "unknownParticleDefined cannot be set true because G4UnknownParticle is not defined in the physics list." 358 G4cerr << "unknownParticleDefined cannot b << 280 << G4endl << "Command ignored." << G4endl; 359 << "G4UnknownParticle is not define << 360 << "Command ignored." << G4endl; << 361 unknownParticleDefined = false; 281 unknownParticleDefined = false; 362 } 282 } 363 } 283 } 364 284 365 void G4PrimaryTransformer::SetChargedUnknownPa << 285 G4bool G4PrimaryTransformer::CheckDynamicParticle(G4DynamicParticle*DP) 366 { << 367 chargedUnknownParticleDefined = vl; << 368 if(chargedUnknownParticleDefined && (charged << 369 { << 370 G4cerr << "chargedUnknownParticleDefined c << 371 << "G4ChargedUnknownParticle is not << 372 << "Command ignored." << G4endl; << 373 chargedUnknownParticleDefined = false; << 374 } << 375 } << 376 << 377 G4bool G4PrimaryTransformer::CheckDynamicParti << 378 { 286 { 379 if(IsGoodForTrack(DP->GetDefinition())) retu 287 if(IsGoodForTrack(DP->GetDefinition())) return true; 380 auto* decayProducts << 288 G4DecayProducts* decayProducts = (G4DecayProducts*)(DP->GetPreAssignedDecayProducts()); 381 = (G4DecayProducts*)(DP->GetPreAssignedDec << 289 if(decayProducts && decayProducts->entries()>0) return true; 382 if(decayProducts != nullptr && decayProducts << 383 G4cerr << G4endl 290 G4cerr << G4endl 384 << "G4PrimaryTransformer: a shortlive << 291 << "G4PrimaryTransformer: a shortlived primary particle is found" << G4endl 385 << G4endl << 292 << " without any valid decay table nor pre-assigned decay mode." << G4endl; 386 << " without any valid decay table no << 293 G4Exception("G4PrimaryTransformer","InvalidPrimary",JustWarning, 387 << G4endl; << 388 G4Exception("G4PrimaryTransformer", "Invalid << 389 "This primary particle will be i 294 "This primary particle will be ignored."); 390 return false; 295 return false; 391 } 296 } 392 297 393 G4ParticleDefinition* << 298 G4ParticleDefinition* G4PrimaryTransformer::GetDefinition(G4PrimaryParticle*pp) 394 G4PrimaryTransformer::GetDefinition(G4PrimaryP << 395 { 299 { 396 G4ParticleDefinition* partDef = pp->GetG4cod 300 G4ParticleDefinition* partDef = pp->GetG4code(); 397 if(partDef == nullptr) << 301 if(!partDef) partDef = particleTable->FindParticle(pp->GetPDGcode()); 398 { << 302 if(unknownParticleDefined && ((!partDef)||partDef->IsShortLived())) partDef = unknown; 399 partDef = particleTable->FindParticle(pp-> << 400 } << 401 if((partDef == nullptr) || partDef->IsShortL << 402 { << 403 if (chargedUnknownParticleDefined && pp->G << 404 { << 405 partDef = chargedunknown; << 406 } << 407 else if (unknownParticleDefined) << 408 { << 409 partDef = unknown; << 410 } << 411 } << 412 return partDef; 303 return partDef; 413 } 304 } 414 305 415 G4bool G4PrimaryTransformer::IsGoodForTrack(G4 306 G4bool G4PrimaryTransformer::IsGoodForTrack(G4ParticleDefinition* pd) 416 { 307 { 417 if(pd == nullptr) << 308 if(!pd) 418 { return false; } 309 { return false; } 419 if(!(pd->IsShortLived())) << 310 else if(!(pd->IsShortLived())) 420 { return true; } 311 { return true; } 421 // << 312 // Following two lines should be removed if the user does not want to make shortlived 422 // Following two lines should be removed if << 313 // primary particle with proper decay table to be converted into a track. 423 // shortlived primary particle with proper d << 314 else if(pd->GetDecayTable()) 424 // a track. << 425 // << 426 if(pd->GetDecayTable() != nullptr) << 427 { return true; } 315 { return true; } 428 << 429 return false; 316 return false; 430 } 317 } >> 318 431 319