source: trunk/source/processes/electromagnetic/xrays/src/G4VTransitionRadiation.cc @ 961

Last change on this file since 961 was 961, checked in by garnier, 15 years ago

update processes

File size: 5.5 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer                                           *
4// *                                                                  *
5// * The  Geant4 software  is  copyright of the Copyright Holders  of *
6// * the Geant4 Collaboration.  It is provided  under  the terms  and *
7// * conditions of the Geant4 Software License,  included in the file *
8// * LICENSE and available at  http://cern.ch/geant4/license .  These *
9// * include a list of copyright holders.                             *
10// *                                                                  *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work  make  any representation or  warranty, express or implied, *
14// * regarding  this  software system or assume any liability for its *
15// * use.  Please see the license in the file  LICENSE  and URL above *
16// * for the full disclaimer and the limitation of liability.         *
17// *                                                                  *
18// * This  code  implementation is the result of  the  scientific and *
19// * technical work of the GEANT4 collaboration.                      *
20// * By using,  copying,  modifying or  distributing the software (or *
21// * any work based  on the software)  you  agree  to acknowledge its *
22// * use  in  resulting  scientific  publications,  and indicate your *
23// * acceptance of all terms of the Geant4 Software license.          *
24// ********************************************************************
25//
26//
27// $Id: G4VTransitionRadiation.cc,v 1.5 2006/06/29 19:56:23 gunter Exp $
28// GEANT4 tag $Name: geant4-09-02-ref-02 $
29//
30// G4VTransitionRadiation class -- implementation file
31
32// GEANT 4 class implementation file --- Copyright CERN 1995
33// CERN Geneva Switzerland
34
35// History:
36// 29.02.04 V.Ivanchenko create
37// 28.07.05, P.Gumplinger add G4ProcessType to constructor
38
39#include "G4VTransitionRadiation.hh"
40#include "G4ParticleDefinition.hh"
41#include "G4VTRModel.hh"
42#include "G4Material.hh"
43#include "G4Region.hh"
44#include "G4TransportationManager.hh"
45
46///////////////////////////////////////////////////////////////////////
47
48using namespace std;
49
50G4VTransitionRadiation::G4VTransitionRadiation( const G4String& processName,
51                                                      G4ProcessType type )
52  : G4VDiscreteProcess(processName, type),
53  nSteps(0),
54  gammaMin(100),
55  cosDThetaMax(cos(0.1))
56{
57  Clear();
58}
59
60///////////////////////////////////////////////////////////////////////
61
62G4VTransitionRadiation::~G4VTransitionRadiation()
63{
64  Clear();
65}
66
67///////////////////////////////////////////////////////////////////////
68
69void G4VTransitionRadiation::Clear()
70{
71  materials.clear();
72  steps.clear();
73  normals.clear();
74  nSteps = 0;
75}
76
77///////////////////////////////////////////////////////////////////////
78
79G4VParticleChange* G4VTransitionRadiation::PostStepDoIt(
80                                     const G4Track& track,
81                                     const G4Step& step)
82{
83
84  // Fill temporary vectors
85
86  const G4Material* material = track.GetMaterial();
87  G4double length = step.GetStepLength();
88  G4ThreeVector direction = track.GetMomentumDirection();
89
90  if(nSteps == 0) {
91
92    nSteps = 1;
93    materials.push_back(material);
94    steps.push_back(length);
95    const G4StepPoint* point = step.GetPreStepPoint();
96    startingPosition = point->GetPosition();
97    startingDirection = point->GetMomentumDirection();
98    G4bool valid = true;
99    G4ThreeVector n = G4TransportationManager::GetTransportationManager()
100                    ->GetNavigatorForTracking()->GetLocalExitNormal(&valid);
101    if(valid) normals.push_back(n);
102    else      normals.push_back(direction);
103
104  } else {
105
106    if(material == materials[nSteps-1]) {
107      steps[nSteps-1] += length;
108    } else {
109      nSteps++;
110      materials.push_back(material);
111      steps.push_back(length);
112      G4bool valid = true;
113      G4ThreeVector n = G4TransportationManager::GetTransportationManager()
114                      ->GetNavigatorForTracking()->GetLocalExitNormal(&valid);
115      if(valid) normals.push_back(n);
116      else      normals.push_back(direction);
117    }
118  }
119
120  // Check POstStepPoint condition
121
122  if(track.GetTrackStatus() == fStopAndKill ||
123     track.GetVolume()->GetLogicalVolume()->GetRegion() != region ||
124     startingDirection.x()*direction.x() +
125     startingDirection.y()*direction.y() +
126     startingDirection.z()*direction.z() < cosDThetaMax)
127  {
128     if(model) {
129       model->GenerateSecondaries(*pParticleChange, materials, steps,
130                                  normals, startingPosition, track);
131     }
132     Clear();
133  }
134
135  return pParticleChange;
136}
137
138///////////////////////////////////////////////////////////////////////
139
140G4bool G4VTransitionRadiation::IsApplicable(
141                                const G4ParticleDefinition& aParticle)
142{
143  return ( aParticle.GetPDGCharge() != 0.0 );
144}
145
146///////////////////////////////////////////////////////////////////////
147
148
149void G4VTransitionRadiation::SetRegion(const G4Region* reg)
150{
151  region = reg;
152}
153
154///////////////////////////////////////////////////////////////////////
155
156void G4VTransitionRadiation::SetModel(G4VTRModel* m)
157{
158  model = m;
159}
160
161///////////////////////////////////////////////////////////////////////
162
163void G4VTransitionRadiation::PrintInfoDefinition()
164{
165  if(model) model->PrintInfo();
166}
167
168///////////////////////////////////////////////////////////////////////
Note: See TracBrowser for help on using the repository browser.