Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SteppingAction.cc
Go to the documentation of this file.
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$
28 // -------------------------------------------------------------------
29 
30 #include "SteppingAction.hh"
31 #include "G4SystemOfUnits.hh"
32 
33 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
34 
36 :Run(run),Detector(det),Primary(pri),Histo(his)
37 { }
38 
39 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
40 
42 { }
43 
44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
45 
47 
48 {
49 
50 if (Detector->GetCoef()==1)
51 {
52 
53  if ( (step->GetTrack()->GetDynamicParticle()->GetDefinition() ==
55 
56 /*
57 // for doublet
58 
59  && (step->GetPostStepPoint()->GetPosition().z()/mm>-3230.2)
60  && (step->GetPostStepPoint()->GetPosition().z()/mm<-3229.8)
61 */
62 
63 // for triplet and whole line
64 
65  && (step->GetPostStepPoint()->GetPosition().z()/mm>249.99999)
66  && (step->GetPostStepPoint()->GetPosition().z()/mm<250.00001)
69  )
70 
71  {
72  xIn = step->GetPostStepPoint()->GetPosition().x();
73  yIn = step->GetPostStepPoint()->GetPosition().y();
74  zIn = step->GetPostStepPoint()->GetPosition().z();
75  E = step->GetTrack()->GetKineticEnergy();
76 
77  G4ThreeVector angleIn;
78  angleIn = step->GetTrack()->GetMomentumDirection();
79 
80  thetaIn = std::asin(angleIn[0]/std::sqrt(angleIn[0]*angleIn[0]+angleIn[1]*angleIn[1]+angleIn[2]*angleIn[2]));
81  phiIn = std::asin(angleIn[1]/std::sqrt(angleIn[0]*angleIn[0]+angleIn[1]*angleIn[1]+angleIn[2]*angleIn[2]));
82 
83  G4cout << " =>IMAGE : X(microns)=" << xIn/micrometer <<" Y(microns)="<< yIn/micrometer << " THETA(mrad)=" << (thetaIn/mrad) << " PHI(mrad)=" << (phiIn/mrad) << G4endl;
84  G4cout << G4endl;
85 
86  Run->AddRow();
87  Run->AddToXVector(xIn/um);
88  Run->AddToYVector(yIn/um);
89  Run->AddToThetaVector(thetaIn/mrad);
90  Run->AddToPhiVector(phiIn/mrad);
91 
92  Histo->FillNtuple(2, 0, xIn/um);
93  Histo->FillNtuple(2, 1, yIn/um);
94  Histo->FillNtuple(2, 2, thetaIn/mrad);
95  Histo->FillNtuple(2, 3, phiIn/mrad);
96  Histo->AddRowNtuple(2);
97 
98  }
99 }
100 
101 if (Detector->GetProfile()==1)
102 {
103 
104  if (
106  && (step->GetPreStepPoint()->GetTouchableHandle()->GetVolume()->GetLogicalVolume() == Detector->GetLogicalVol())
107  && (step->GetPostStepPoint()->GetTouchableHandle()->GetVolume()->GetLogicalVolume() == Detector->GetLogicalVol()) )
108  {
109  xIn = step->GetPostStepPoint()->GetPosition().x();
110  yIn = step->GetPostStepPoint()->GetPosition().y();
111  zIn = step->GetPostStepPoint()->GetPosition().z();
112 
113  Histo->FillNtuple(0, 0, xIn/um);
114  Histo->FillNtuple(0, 1, yIn/um);
115  Histo->FillNtuple(0, 2, zIn/mm);
116  Histo->AddRowNtuple(0);
117  }
118 }
119 
120 if (Detector->GetGrid()==1)
121 {
122 
123  if (
125  && (step->GetPreStepPoint()->GetTouchableHandle()->GetVolume()->GetLogicalVolume() == Detector->GetLogicalGrid())
126  && (step->GetPostStepPoint()->GetTouchableHandle()->GetVolume()->GetLogicalVolume() == Detector->GetLogicalWorld()) )
127  {
128  xIn = step->GetPostStepPoint()->GetPosition().x();
129  yIn = step->GetPostStepPoint()->GetPosition().y();
130  E = step->GetTrack()->GetKineticEnergy();
131 
132  Histo->FillNtuple(1, 0, xIn/um);
133  Histo->FillNtuple(1, 1, yIn/um);
134  Histo->FillNtuple(1, 2, E/MeV);
135  Histo->AddRowNtuple(1);
136  }
137 }
138 
139 // end
140 }