- Timestamp:
- Nov 5, 2010, 4:08:39 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/examples/extended/medical/GammaTherapy/src/Histo.cc
r807 r1342 24 24 // ******************************************************************** 25 25 // 26 // $Id: Histo.cc,v 1.10 2010/10/26 12:05:14 vnivanch Exp $ 27 // GEANT4 tag $Name: examples-V09-03-09 $ 28 // 26 29 //--------------------------------------------------------------------------- 27 30 // … … 38 41 39 42 #include "Histo.hh" 43 #include "G4Gamma.hh" 44 #include "G4Electron.hh" 45 #include "G4Positron.hh" 46 #include "G4Neutron.hh" 40 47 #include <iomanip> 41 48 … … 65 72 verbose = 1; 66 73 histName = G4String("histo"); 67 histType = G4String(" hbook");74 histType = G4String("root"); 68 75 nHisto = 10; 69 76 nHisto1 = 10; … … 76 83 absorberR = 200.*mm; 77 84 scoreZ = 100.*mm; 85 86 gamma = G4Gamma::Gamma(); 87 electron = G4Electron::Electron(); 88 positron = G4Positron::Positron(); 89 neutron = G4Neutron::Neutron(); 78 90 79 91 #ifdef G4ANALYSIS_USE … … 206 218 } 207 219 tree->close(); 220 delete tree; 221 tree = 0; 208 222 G4cout << "Tree is closed" << G4endl; 209 223 } … … 256 270 257 271 // Creating a tree mapped to a new hbook file. 258 G4String tt = "hbook"; 259 G4String nn = histName + ".hbook"; 260 if(histType == "root") { 261 tt = "root"; 262 nn = histName + ".root"; 263 } else if(histType == "xml" || histType == "XML" 264 || histType == "aida" || histType == "AIDA") { 272 G4String tt = histType; 273 G4String nn = histName + "." + histType; 274 if(histType == "xml" || histType == "XML" || histType == "aida" || 275 histType == "AIDA") { 265 276 tt = "xml"; 266 277 nn = histName + ".aida"; 267 278 } 268 279 269 tree = tf->create(nn,tt,false,true, " --noErrors uncompress");280 tree = tf->create(nn,tt,false,true, ""); 270 281 if(tree) { 271 282 G4cout << "Tree store : " << tree->storeName() << G4endl; … … 317 328 // If using Anaphe HBOOK implementation, there is a limitation on the 318 329 // length of the variable names in a ntuple 319 if(nTuple) 330 if(nTuple) { 320 331 ntup = tpf->create( "100", "Dose deposite","float r, z, e" ); 321 332 } 322 333 delete hf; 323 334 delete tpf; … … 330 341 { 331 342 G4double e = elec->GetKineticEnergy()/MeV; 332 if(e > 0.0) n_elec++;343 if(e > 0.0) { ++n_elec; } 333 344 } 334 345 … … 338 349 { 339 350 G4double e = ph->GetKineticEnergy()/MeV; 340 if(e > 0.0) n_gam++;351 if(e > 0.0) { ++n_gam; } 341 352 } 342 353 … … 346 357 { 347 358 G4double e = ph->GetKineticEnergy()/MeV; 348 if(e > 0.0) n_gam_tar++;359 if(e > 0.0) { ++n_gam_tar; } 349 360 #ifdef G4ANALYSIS_USE 350 361 if(tree) histo[5]->fill(e,1.0); … … 357 368 { 358 369 G4double e = ph->GetKineticEnergy()/MeV; 359 if(e > 0.0) n_gam_ph++;370 if(e > 0.0) { ++n_gam_ph; } 360 371 } 361 372 … … 365 376 { 366 377 G4double e = ph->GetKineticEnergy()/MeV; 367 if(e > 0.0) n_e_tar++;378 if(e > 0.0) { ++n_e_tar; } 368 379 #ifdef G4ANALYSIS_USE 369 380 if(tree) histo[8]->fill(e,1.0); … … 376 387 { 377 388 G4double e = ph->GetKineticEnergy()/MeV; 378 if(e > 0.0) n_e_ph++;389 if(e > 0.0) { ++n_e_ph; } 379 390 #ifdef G4ANALYSIS_USE 380 391 if(tree) histo[7]->fill(e,1.0); … … 389 400 390 401 ResetTrackLength(); 391 G4ParticleDefinition* particle = aTrack->GetDefinition(); 392 G4String name = particle->GetParticleName(); 402 const G4ParticleDefinition* particle = aTrack->GetParticleDefinition(); 393 403 G4int pid = aTrack->GetParentID(); 394 404 G4double kinE = aTrack->GetKineticEnergy(); … … 416 426 417 427 // delta-electron 418 } else if (0 < pid && "e-" == name) {428 } else if (0 < pid && particle == electron) { 419 429 if(1 < verbose) { 420 430 G4cout << "TrackingAction: Secondary electron " << G4endl; 421 431 } 422 432 AddDeltaElectron(dp); 423 if(pv == phantom) AddPhantomElectron(dp);424 else if(pv == target1 || pv == target2) AddTargetElectron(dp);425 426 } else if (0 < pid && "e+" == name) {433 if(pv == phantom) { AddPhantomElectron(dp); } 434 else if(pv == target1 || pv == target2) { AddTargetElectron(dp); } 435 436 } else if (0 < pid && particle == positron) { 427 437 if(1 < verbose) { 428 438 G4cout << "TrackingAction: Secondary positron " << G4endl; … … 430 440 AddPositron(dp); 431 441 432 } else if (0 < pid && "gamma" == name) {442 } else if (0 < pid && particle == gamma) { 433 443 if(1 < verbose) { 434 444 G4cout << "TrackingAction: Secondary gamma; parentID= " << pid … … 436 446 } 437 447 AddPhoton(dp); 438 if(pv == phantom) AddPhantomPhoton(dp);439 else if(pv == target1 || pv == target2) AddTargetPhoton(dp);440 441 } else if (0 < pid && "neutron" == name) {448 if(pv == phantom) { AddPhantomPhoton(dp); } 449 else if(pv == target1 || pv == target2) { AddTargetPhoton(dp); } 450 451 } else if (0 < pid && particle == neutron) { 442 452 n_neutron++; 443 453 if(1 < verbose) { … … 455 465 sumR += e; 456 466 G4int bin = (G4int)(e/stepE); 457 if(bin >= nBinsE) bin = nBinsE-1;467 if(bin >= nBinsE) { bin = nBinsE-1; } 458 468 gammaE[bin] += e; 459 469 G4int bin1 = (G4int)(r/stepR); 460 if(bin1 >= nBinsR) bin1 = nBinsR-1;470 if(bin1 >= nBinsR) { bin1 = nBinsR-1; } 461 471 #ifdef G4ANALYSIS_USE 462 472 if(tree) {
Note: See TracChangeset
for help on using the changeset viewer.